@allpepper/task-orchestrator 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allpepper/task-orchestrator",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "MCP server for hierarchical task orchestration with SQLite persistence",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -253,12 +253,19 @@ export function deleteProject(id: string, options?: { cascade?: boolean }): Resu
253
253
 
254
254
  const result = transaction(() => {
255
255
  if (cascade) {
256
- // Get all task IDs for this project
257
- const taskIds = queryAll<{ id: string }>(
258
- 'SELECT id FROM tasks WHERE project_id = ?',
256
+ // Get all feature IDs for this project first (needed for task cleanup)
257
+ const featureIds = queryAll<{ id: string }>(
258
+ 'SELECT id FROM features WHERE project_id = ?',
259
259
  [id]
260
260
  );
261
261
 
262
+ // Get all task IDs: tasks directly under project OR under features of this project
263
+ const taskIds = queryAll<{ id: string }>(
264
+ `SELECT id FROM tasks WHERE project_id = ?
265
+ OR feature_id IN (SELECT id FROM features WHERE project_id = ?)`,
266
+ [id, id]
267
+ );
268
+
262
269
  // Delete each task's dependencies, sections, and tags
263
270
  for (const task of taskIds) {
264
271
  execute('DELETE FROM dependencies WHERE from_task_id = ? OR to_task_id = ?', [task.id, task.id]);
@@ -266,13 +273,11 @@ export function deleteProject(id: string, options?: { cascade?: boolean }): Resu
266
273
  deleteTags(task.id, EntityType.TASK);
267
274
  }
268
275
 
269
- // Delete all tasks for this project
270
- execute('DELETE FROM tasks WHERE project_id = ?', [id]);
271
-
272
- // Get all feature IDs for this project
273
- const featureIds = queryAll<{ id: string }>(
274
- 'SELECT id FROM features WHERE project_id = ?',
275
- [id]
276
+ // Delete all tasks: directly under project OR under features of this project
277
+ execute(
278
+ `DELETE FROM tasks WHERE project_id = ?
279
+ OR feature_id IN (SELECT id FROM features WHERE project_id = ?)`,
280
+ [id, id]
276
281
  );
277
282
 
278
283
  // Delete each feature's sections and tags
@@ -73,7 +73,6 @@ function validateComplexity(complexity: number): boolean {
73
73
  // ============================================================================
74
74
 
75
75
  export function createTask(params: {
76
- projectId?: string;
77
76
  featureId?: string;
78
77
  title: string;
79
78
  summary: string;
@@ -97,6 +96,19 @@ export function createTask(params: {
97
96
  return err('Summary is required', 'VALIDATION_ERROR');
98
97
  }
99
98
 
99
+ // Derive projectId from feature - feature is the source of truth for project membership
100
+ let projectId: string | undefined;
101
+ if (params.featureId) {
102
+ const feature = queryOne<{ project_id: string | null }>(
103
+ 'SELECT project_id FROM features WHERE id = ?',
104
+ [params.featureId]
105
+ );
106
+ if (!feature) {
107
+ return err(`Feature not found: ${params.featureId}`, 'NOT_FOUND');
108
+ }
109
+ projectId = feature.project_id ?? undefined;
110
+ }
111
+
100
112
  const id = generateId();
101
113
  const timestamp = now();
102
114
  const status = params.status ?? TaskStatus.PENDING;
@@ -113,7 +125,7 @@ export function createTask(params: {
113
125
  ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
114
126
  [
115
127
  id,
116
- params.projectId ?? null,
128
+ projectId ?? null,
117
129
  params.featureId ?? null,
118
130
  params.title.trim(),
119
131
  params.summary.trim(),
@@ -127,7 +127,6 @@ export function registerManageContainerTool(server: McpServer): void {
127
127
  }
128
128
 
129
129
  result = createTask({
130
- projectId: params.projectId,
131
130
  featureId: params.featureId,
132
131
  title: nameOrTitle,
133
132
  summary: params.summary,