diff --git a/src/tools/crud.ts b/src/tools/crud.ts index 8142d44..6347b82 100644 --- a/src/tools/crud.ts +++ b/src/tools/crud.ts @@ -1,6 +1,6 @@ // CRUD operations for tasks -import { query, queryOne, execute, getNextTaskId, getProjectKey } from '../db.js'; +import { query, queryOne, execute, getNextTaskId, getProjectKey, detectProjectFromCwd } from '../db.js'; import { getEmbedding, formatEmbedding } from '../embeddings.js'; import type { Task, ChecklistItem, TaskLink } from '../types.js'; import { getRecentDelegations } from './delegations.js'; @@ -119,6 +119,7 @@ export async function taskAdd(args: TaskAddArgs): Promise { /** * List tasks with filters + * Auto-detects project from CWD if not explicitly provided */ export async function taskList(args: TaskListArgs): Promise { const { project, status, type, priority, limit = 20 } = args; @@ -127,8 +128,10 @@ export async function taskList(args: TaskListArgs): Promise { const params: unknown[] = []; let paramIndex = 1; - if (project) { - const projectKey = await getProjectKey(project); + // Auto-detect project from CWD if not explicitly provided + const effectiveProject = project || detectProjectFromCwd(); + if (effectiveProject) { + const projectKey = await getProjectKey(effectiveProject); whereClause += ` AND project = $${paramIndex++}`; params.push(projectKey); } @@ -159,7 +162,7 @@ export async function taskList(args: TaskListArgs): Promise { ); if (tasks.length === 0) { - return `No tasks found${project ? ` for project ${project}` : ''}`; + return `No tasks found${effectiveProject ? ` for project ${effectiveProject}` : ''}`; } const lines = tasks.map(t => { @@ -168,7 +171,7 @@ export async function taskList(args: TaskListArgs): Promise { return `${statusIcon} ${t.priority} ${t.id}: ${t.title}${typeLabel}`; }); - return `Tasks${project ? ` (${project})` : ''}:\n\n${lines.join('\n')}`; + return `Tasks${effectiveProject ? ` (${effectiveProject})` : ''}:\n\n${lines.join('\n')}`; } /** diff --git a/src/tools/epics.ts b/src/tools/epics.ts index 71f8ecc..38825a0 100644 --- a/src/tools/epics.ts +++ b/src/tools/epics.ts @@ -1,6 +1,6 @@ // Epic operations for task management -import { query, queryOne, execute, getProjectKey } from '../db.js'; +import { query, queryOne, execute, getProjectKey, detectProjectFromCwd } from '../db.js'; import { getEmbedding, formatEmbedding } from '../embeddings.js'; import type { Epic, Task } from '../types.js'; @@ -71,6 +71,7 @@ export async function epicAdd(args: EpicAddArgs): Promise { /** * List epics with filters + * Auto-detects project from CWD if not explicitly provided */ export async function epicList(args: EpicListArgs): Promise { const { project, status, limit = 20 } = args; @@ -79,8 +80,10 @@ export async function epicList(args: EpicListArgs): Promise { const params: unknown[] = []; let paramIndex = 1; - if (project) { - const projectKey = await getProjectKey(project); + // Auto-detect project from CWD if not explicitly provided + const effectiveProject = project || detectProjectFromCwd(); + if (effectiveProject) { + const projectKey = await getProjectKey(effectiveProject); whereClause += ` AND e.project = $${paramIndex++}`; params.push(projectKey); } @@ -107,7 +110,7 @@ export async function epicList(args: EpicListArgs): Promise { ); if (epics.length === 0) { - return `No epics found${project ? ` for project ${project}` : ''}`; + return `No epics found${effectiveProject ? ` for project ${effectiveProject}` : ''}`; } const lines = epics.map(e => { @@ -116,7 +119,7 @@ export async function epicList(args: EpicListArgs): Promise { return `${statusIcon} ${e.id}: ${e.title}${progress}`; }); - return `Epics${project ? ` (${project})` : ''}:\n\n${lines.join('\n')}`; + return `Epics${effectiveProject ? ` (${effectiveProject})` : ''}:\n\n${lines.join('\n')}`; } /**