@e0ipso/ai-task-manager 1.36.1 → 1.38.0

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.
Files changed (72) hide show
  1. package/README.md +26 -21
  2. package/dist/cli.js +1 -32
  3. package/dist/cli.js.map +1 -1
  4. package/dist/conflict-detector.d.ts.map +1 -1
  5. package/dist/conflict-detector.js +0 -4
  6. package/dist/conflict-detector.js.map +1 -1
  7. package/dist/index.d.ts +3 -16
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +50 -245
  10. package/dist/index.js.map +1 -1
  11. package/dist/metadata.d.ts +9 -0
  12. package/dist/metadata.d.ts.map +1 -1
  13. package/dist/metadata.js +14 -0
  14. package/dist/metadata.js.map +1 -1
  15. package/dist/types.d.ts +18 -18
  16. package/dist/types.d.ts.map +1 -1
  17. package/dist/utils.d.ts +27 -58
  18. package/dist/utils.d.ts.map +1 -1
  19. package/dist/utils.js +93 -219
  20. package/dist/utils.js.map +1 -1
  21. package/package.json +4 -2
  22. package/templates/ai-task-manager/config/TASK_MANAGER.md +3 -3
  23. package/templates/ai-task-manager/config/hooks/PRE_PHASE.md +6 -26
  24. package/templates/ai-task-manager/config/hooks/PRE_TASK_ASSIGNMENT.md +6 -24
  25. package/templates/ai-task-manager/config/templates/PLAN_TEMPLATE.md +1 -1
  26. package/templates/{assistant → harness}/agents/plan-creator.md +2 -2
  27. package/templates/harness/skills/task-create-plan/SKILL.md +120 -0
  28. package/templates/harness/skills/task-create-plan/scripts/find-task-manager-root.cjs +116 -0
  29. package/templates/harness/skills/task-create-plan/scripts/get-next-plan-id.cjs +214 -0
  30. package/templates/harness/skills/task-execute-blueprint/SKILL.md +139 -0
  31. package/templates/harness/skills/task-execute-blueprint/scripts/create-feature-branch.cjs +376 -0
  32. package/templates/harness/skills/task-execute-blueprint/scripts/find-task-manager-root.cjs +116 -0
  33. package/templates/harness/skills/task-execute-blueprint/scripts/validate-plan-blueprint.cjs +375 -0
  34. package/templates/harness/skills/task-execute-task/SKILL.md +195 -0
  35. package/templates/harness/skills/task-execute-task/scripts/check-task-dependencies.cjs +437 -0
  36. package/templates/harness/skills/task-execute-task/scripts/find-task-manager-root.cjs +116 -0
  37. package/templates/harness/skills/task-execute-task/scripts/validate-plan-blueprint.cjs +375 -0
  38. package/templates/harness/skills/task-full-workflow/SKILL.md +378 -0
  39. package/templates/harness/skills/task-full-workflow/scripts/create-feature-branch.cjs +376 -0
  40. package/templates/harness/skills/task-full-workflow/scripts/find-task-manager-root.cjs +116 -0
  41. package/templates/harness/skills/task-full-workflow/scripts/get-next-plan-id.cjs +214 -0
  42. package/templates/harness/skills/task-full-workflow/scripts/get-next-task-id.cjs +312 -0
  43. package/templates/harness/skills/task-full-workflow/scripts/validate-plan-blueprint.cjs +375 -0
  44. package/templates/harness/skills/task-generate-tasks/SKILL.md +244 -0
  45. package/templates/harness/skills/task-generate-tasks/scripts/find-task-manager-root.cjs +116 -0
  46. package/templates/harness/skills/task-generate-tasks/scripts/get-next-task-id.cjs +312 -0
  47. package/templates/harness/skills/task-generate-tasks/scripts/validate-plan-blueprint.cjs +375 -0
  48. package/templates/harness/skills/task-refine-plan/SKILL.md +205 -0
  49. package/templates/harness/skills/task-refine-plan/scripts/find-task-manager-root.cjs +116 -0
  50. package/templates/harness/skills/task-refine-plan/scripts/validate-plan-blueprint.cjs +375 -0
  51. package/dist/exec.d.ts +0 -13
  52. package/dist/exec.d.ts.map +0 -1
  53. package/dist/exec.js +0 -261
  54. package/dist/exec.js.map +0 -1
  55. package/templates/ai-task-manager/config/scripts/check-task-dependencies.cjs +0 -240
  56. package/templates/ai-task-manager/config/scripts/compose-prompt.cjs +0 -234
  57. package/templates/ai-task-manager/config/scripts/create-feature-branch.cjs +0 -204
  58. package/templates/ai-task-manager/config/scripts/extract-task-skills.cjs +0 -84
  59. package/templates/ai-task-manager/config/scripts/find-root.cjs +0 -10
  60. package/templates/ai-task-manager/config/scripts/get-next-plan-id.cjs +0 -49
  61. package/templates/ai-task-manager/config/scripts/get-next-task-id.cjs +0 -81
  62. package/templates/ai-task-manager/config/scripts/shared-utils.cjs +0 -418
  63. package/templates/ai-task-manager/config/scripts/validate-plan-blueprint.cjs +0 -138
  64. package/templates/assistant/commands/tasks/create-plan-auto.md +0 -174
  65. package/templates/assistant/commands/tasks/create-plan.md +0 -175
  66. package/templates/assistant/commands/tasks/execute-blueprint.md +0 -233
  67. package/templates/assistant/commands/tasks/execute-task.md +0 -351
  68. package/templates/assistant/commands/tasks/fix-broken-tests.md +0 -44
  69. package/templates/assistant/commands/tasks/full-workflow.md +0 -849
  70. package/templates/assistant/commands/tasks/generate-tasks.md +0 -348
  71. package/templates/assistant/commands/tasks/refine-plan-auto.md +0 -172
  72. package/templates/assistant/commands/tasks/refine-plan.md +0 -163
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/skill-scripts/find-task-manager-root.ts
31
+ var find_task_manager_root_exports = {};
32
+ __export(find_task_manager_root_exports, {
33
+ main: () => main
34
+ });
35
+ module.exports = __toCommonJS(find_task_manager_root_exports);
36
+
37
+ // src/skill-scripts/shared/root.ts
38
+ var fs = __toESM(require("fs"));
39
+ var path = __toESM(require("path"));
40
+ var EXPECTED_SCHEMA = true ? 1 : 1;
41
+ var isValidTaskManagerRoot = (taskManagerPath) => {
42
+ try {
43
+ if (!fs.existsSync(taskManagerPath)) return false;
44
+ if (!fs.lstatSync(taskManagerPath).isDirectory()) return false;
45
+ const metadataPath = path.join(taskManagerPath, ".init-metadata.json");
46
+ if (!fs.existsSync(metadataPath)) return false;
47
+ const metadata = JSON.parse(fs.readFileSync(metadataPath, "utf8"));
48
+ return metadata && typeof metadata === "object" && "version" in metadata;
49
+ } catch (_err) {
50
+ return false;
51
+ }
52
+ };
53
+ var getTaskManagerAt = (directory) => {
54
+ const taskManagerPath = path.join(directory, ".ai", "task-manager");
55
+ return isValidTaskManagerRoot(taskManagerPath) ? taskManagerPath : null;
56
+ };
57
+ var getParentPaths = (currentPath, acc = []) => {
58
+ const absolutePath = path.resolve(currentPath);
59
+ const nextAcc = [...acc, absolutePath];
60
+ const parentPath = path.dirname(absolutePath);
61
+ if (parentPath === absolutePath) return nextAcc;
62
+ return getParentPaths(parentPath, nextAcc);
63
+ };
64
+ var checkWorkspaceSchema = (metadataPath) => {
65
+ let metadata;
66
+ try {
67
+ metadata = JSON.parse(fs.readFileSync(metadataPath, "utf8"));
68
+ } catch {
69
+ return;
70
+ }
71
+ const actual = typeof metadata.workspaceSchemaVersion === "number" ? metadata.workspaceSchemaVersion : 1;
72
+ if (actual === EXPECTED_SCHEMA) return;
73
+ if (actual < EXPECTED_SCHEMA) {
74
+ process.stderr.write(
75
+ `Workspace schema v${actual} is older than this skill requires (v${EXPECTED_SCHEMA}). Re-run \`npx @e0ipso/ai-task-manager init\` with the latest CLI to update.
76
+ `
77
+ );
78
+ } else {
79
+ process.stderr.write(
80
+ `This skill (built for workspace schema v${EXPECTED_SCHEMA}) is older than the workspace (v${actual}). Re-run \`npx skills add e0ipso/ai-task-manager\` to update skills.
81
+ `
82
+ );
83
+ }
84
+ process.exit(1);
85
+ };
86
+ var findTaskManagerRoot = (startPath = process.cwd()) => {
87
+ const paths = getParentPaths(startPath);
88
+ const found = paths.find((p) => getTaskManagerAt(p));
89
+ if (!found) return null;
90
+ const root = getTaskManagerAt(found);
91
+ if (root) checkWorkspaceSchema(path.join(root, ".init-metadata.json"));
92
+ return root;
93
+ };
94
+
95
+ // src/skill-scripts/find-task-manager-root.ts
96
+ var main = () => {
97
+ const startPath = process.argv[2] || process.cwd();
98
+ const root = findTaskManagerRoot(startPath);
99
+ if (!root) {
100
+ process.stderr.write(
101
+ `Could not find .ai/task-manager root from ${startPath} or any parent directory.
102
+ `
103
+ );
104
+ process.exit(1);
105
+ }
106
+ process.stdout.write(`${root}
107
+ `);
108
+ process.exit(0);
109
+ };
110
+ if (require.main === module) {
111
+ main();
112
+ }
113
+ // Annotate the CommonJS export names for ESM import in node:
114
+ 0 && (module.exports = {
115
+ main
116
+ });
@@ -0,0 +1,312 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/skill-scripts/get-next-task-id.ts
31
+ var get_next_task_id_exports = {};
32
+ __export(get_next_task_id_exports, {
33
+ main: () => main
34
+ });
35
+ module.exports = __toCommonJS(get_next_task_id_exports);
36
+
37
+ // src/skill-scripts/shared/plan-resolve.ts
38
+ var fs3 = __toESM(require("fs"));
39
+ var path3 = __toESM(require("path"));
40
+
41
+ // src/skill-scripts/shared/root.ts
42
+ var fs = __toESM(require("fs"));
43
+ var path = __toESM(require("path"));
44
+ var EXPECTED_SCHEMA = true ? 1 : 1;
45
+ var isValidTaskManagerRoot = (taskManagerPath) => {
46
+ try {
47
+ if (!fs.existsSync(taskManagerPath)) return false;
48
+ if (!fs.lstatSync(taskManagerPath).isDirectory()) return false;
49
+ const metadataPath = path.join(taskManagerPath, ".init-metadata.json");
50
+ if (!fs.existsSync(metadataPath)) return false;
51
+ const metadata = JSON.parse(fs.readFileSync(metadataPath, "utf8"));
52
+ return metadata && typeof metadata === "object" && "version" in metadata;
53
+ } catch (_err) {
54
+ return false;
55
+ }
56
+ };
57
+ var getTaskManagerAt = (directory) => {
58
+ const taskManagerPath = path.join(directory, ".ai", "task-manager");
59
+ return isValidTaskManagerRoot(taskManagerPath) ? taskManagerPath : null;
60
+ };
61
+ var getParentPaths = (currentPath, acc = []) => {
62
+ const absolutePath = path.resolve(currentPath);
63
+ const nextAcc = [...acc, absolutePath];
64
+ const parentPath = path.dirname(absolutePath);
65
+ if (parentPath === absolutePath) return nextAcc;
66
+ return getParentPaths(parentPath, nextAcc);
67
+ };
68
+ var checkWorkspaceSchema = (metadataPath) => {
69
+ let metadata;
70
+ try {
71
+ metadata = JSON.parse(fs.readFileSync(metadataPath, "utf8"));
72
+ } catch {
73
+ return;
74
+ }
75
+ const actual = typeof metadata.workspaceSchemaVersion === "number" ? metadata.workspaceSchemaVersion : 1;
76
+ if (actual === EXPECTED_SCHEMA) return;
77
+ if (actual < EXPECTED_SCHEMA) {
78
+ process.stderr.write(
79
+ `Workspace schema v${actual} is older than this skill requires (v${EXPECTED_SCHEMA}). Re-run \`npx @e0ipso/ai-task-manager init\` with the latest CLI to update.
80
+ `
81
+ );
82
+ } else {
83
+ process.stderr.write(
84
+ `This skill (built for workspace schema v${EXPECTED_SCHEMA}) is older than the workspace (v${actual}). Re-run \`npx skills add e0ipso/ai-task-manager\` to update skills.
85
+ `
86
+ );
87
+ }
88
+ process.exit(1);
89
+ };
90
+ var findTaskManagerRoot = (startPath = process.cwd()) => {
91
+ const paths = getParentPaths(startPath);
92
+ const found = paths.find((p) => getTaskManagerAt(p));
93
+ if (!found) return null;
94
+ const root = getTaskManagerAt(found);
95
+ if (root) checkWorkspaceSchema(path.join(root, ".init-metadata.json"));
96
+ return root;
97
+ };
98
+
99
+ // src/skill-scripts/shared/plan-scan.ts
100
+ var fs2 = __toESM(require("fs"));
101
+ var path2 = __toESM(require("path"));
102
+
103
+ // src/skill-scripts/shared/frontmatter.ts
104
+ var ID_PATTERNS = [
105
+ /^\s*["']?id["']?\s*:\s*["']?([+-]?\d+)["']?\s*(?:#.*)?$/im,
106
+ /^\s*id\s*:\s*([+-]?\d+)\s*(?:#.*)?$/im,
107
+ /^\s*["']?id["']?\s*:\s*"([+-]?\d+)"\s*(?:#.*)?$/im,
108
+ /^\s*["']?id["']?\s*:\s*'([+-]?\d+)'\s*(?:#.*)?$/im,
109
+ /^\s*["']id["']\s*:\s*([+-]?\d+)\s*(?:#.*)?$/im,
110
+ /^\s*id\s*:\s*[|>]\s*([+-]?\d+)\s*$/im
111
+ ];
112
+ var validateId = (rawId) => {
113
+ const id = parseInt(rawId, 10);
114
+ if (Number.isNaN(id) || id < 0 || id > Number.MAX_SAFE_INTEGER) return null;
115
+ return id;
116
+ };
117
+ var extractIdFromMarkdown = (content) => {
118
+ const frontmatterMatch = content.match(/^---\s*\r?\n([\s\S]*?)\r?\n---/);
119
+ if (!frontmatterMatch || !frontmatterMatch[1]) return null;
120
+ const block = frontmatterMatch[1];
121
+ for (const pattern of ID_PATTERNS) {
122
+ const match = block.match(pattern);
123
+ if (match && match[1]) {
124
+ const id = validateId(match[1]);
125
+ if (id !== null) return id;
126
+ }
127
+ }
128
+ return null;
129
+ };
130
+ var extractIdFromHtml = (content) => {
131
+ const headMatch = content.match(/<head[^>]*>([\s\S]*?)<\/head>/i);
132
+ const scope = headMatch && headMatch[1] ? headMatch[1] : content;
133
+ const metaPatterns = [
134
+ /<meta\s+[^>]*name\s*=\s*["']id["'][^>]*content\s*=\s*["']([+-]?\d+)["'][^>]*\/?>/i,
135
+ /<meta\s+[^>]*content\s*=\s*["']([+-]?\d+)["'][^>]*name\s*=\s*["']id["'][^>]*\/?>/i
136
+ ];
137
+ for (const pattern of metaPatterns) {
138
+ const match = scope.match(pattern);
139
+ if (match && match[1]) {
140
+ const id = validateId(match[1]);
141
+ if (id !== null) return id;
142
+ }
143
+ }
144
+ return null;
145
+ };
146
+ var extractPlanId = (content, filePath) => {
147
+ if (filePath.toLowerCase().endsWith(".html")) return extractIdFromHtml(content);
148
+ return extractIdFromMarkdown(content);
149
+ };
150
+
151
+ // src/skill-scripts/shared/plan-scan.ts
152
+ var PLAN_EXTENSIONS = [".md", ".html"];
153
+ var scanPlanDir = (planDirPath, dirName, isArchive) => {
154
+ let entries;
155
+ try {
156
+ entries = fs2.readdirSync(planDirPath, { withFileTypes: true });
157
+ } catch (_err) {
158
+ return [];
159
+ }
160
+ return entries.filter((e) => e.isFile() && PLAN_EXTENSIONS.some((ext) => e.name.endsWith(ext))).flatMap((e) => {
161
+ const filePath = path2.join(planDirPath, e.name);
162
+ try {
163
+ const content = fs2.readFileSync(filePath, "utf8");
164
+ const id = extractPlanId(content, filePath);
165
+ if (id === null) return [];
166
+ return [{ id, file: filePath, dir: planDirPath, isArchive, name: dirName }];
167
+ } catch (_err) {
168
+ return [];
169
+ }
170
+ });
171
+ };
172
+ var getAllPlans = (taskManagerRoot) => {
173
+ const sources = [
174
+ { dir: path2.join(taskManagerRoot, "plans"), isArchive: false },
175
+ { dir: path2.join(taskManagerRoot, "archive"), isArchive: true }
176
+ ];
177
+ return sources.flatMap(({ dir, isArchive }) => {
178
+ if (!fs2.existsSync(dir)) return [];
179
+ let entries;
180
+ try {
181
+ entries = fs2.readdirSync(dir, { withFileTypes: true });
182
+ } catch (_err) {
183
+ return [];
184
+ }
185
+ return entries.filter((e) => e.isDirectory()).flatMap((e) => scanPlanDir(path2.join(dir, e.name), e.name, isArchive));
186
+ });
187
+ };
188
+
189
+ // src/skill-scripts/shared/plan-resolve.ts
190
+ var isValidRootDir = (taskManagerPath) => {
191
+ try {
192
+ if (!fs3.existsSync(taskManagerPath)) return false;
193
+ if (!fs3.lstatSync(taskManagerPath).isDirectory()) return false;
194
+ const metadataPath = path3.join(taskManagerPath, ".init-metadata.json");
195
+ if (!fs3.existsSync(metadataPath)) return false;
196
+ const metadata = JSON.parse(fs3.readFileSync(metadataPath, "utf8"));
197
+ return metadata && typeof metadata === "object" && "version" in metadata;
198
+ } catch (_err) {
199
+ return false;
200
+ }
201
+ };
202
+ var checkStandardRootShortcut = (filePath) => {
203
+ const planDir = path3.dirname(filePath);
204
+ const parentDir = path3.dirname(planDir);
205
+ const possibleRoot = path3.dirname(parentDir);
206
+ const parentBase = path3.basename(parentDir);
207
+ if (parentBase !== "plans" && parentBase !== "archive") return null;
208
+ if (path3.basename(possibleRoot) !== "task-manager") return null;
209
+ const dotAiDir = path3.dirname(possibleRoot);
210
+ if (path3.basename(dotAiDir) !== ".ai") return null;
211
+ return isValidRootDir(possibleRoot) ? possibleRoot : null;
212
+ };
213
+ var resolveByPath = (absolutePath) => {
214
+ let content;
215
+ try {
216
+ content = fs3.readFileSync(absolutePath, "utf8");
217
+ } catch (_err) {
218
+ return null;
219
+ }
220
+ const planId = extractPlanId(content, absolutePath);
221
+ if (planId === null) return null;
222
+ const tmRoot = checkStandardRootShortcut(absolutePath) || findTaskManagerRoot(path3.dirname(absolutePath));
223
+ if (!tmRoot) return null;
224
+ return {
225
+ planFile: absolutePath,
226
+ planDir: path3.dirname(absolutePath),
227
+ taskManagerRoot: tmRoot,
228
+ planId
229
+ };
230
+ };
231
+ var resolveByIdInAncestry = (planId, startPath, searched = /* @__PURE__ */ new Set()) => {
232
+ const tmRoot = findTaskManagerRoot(startPath);
233
+ if (!tmRoot) return null;
234
+ const normalized = path3.normalize(tmRoot);
235
+ if (searched.has(normalized)) return null;
236
+ searched.add(normalized);
237
+ const plans = getAllPlans(tmRoot);
238
+ const match = plans.find((p) => p.id === planId);
239
+ if (match) {
240
+ return {
241
+ planFile: match.file,
242
+ planDir: match.dir,
243
+ taskManagerRoot: tmRoot,
244
+ planId
245
+ };
246
+ }
247
+ const parentOfRoot = path3.dirname(path3.dirname(tmRoot));
248
+ if (parentOfRoot === tmRoot) return null;
249
+ return resolveByIdInAncestry(planId, parentOfRoot, searched);
250
+ };
251
+ var resolvePlan = (input, startPath = process.cwd()) => {
252
+ if (input === null || input === void 0 || input === "") return null;
253
+ const inputStr = String(input);
254
+ if (inputStr.startsWith("/")) {
255
+ return resolveByPath(inputStr);
256
+ }
257
+ const planId = parseInt(inputStr, 10);
258
+ if (Number.isNaN(planId)) return null;
259
+ return resolveByIdInAncestry(planId, startPath);
260
+ };
261
+
262
+ // src/skill-scripts/shared/task-scan.ts
263
+ var fs4 = __toESM(require("fs"));
264
+ var path4 = __toESM(require("path"));
265
+ var computeNextTaskId = (planDir) => {
266
+ const tasksDir = path4.join(planDir, "tasks");
267
+ if (!fs4.existsSync(tasksDir)) return 1;
268
+ let entries;
269
+ try {
270
+ entries = fs4.readdirSync(tasksDir, { withFileTypes: true });
271
+ } catch (_err) {
272
+ return 1;
273
+ }
274
+ if (entries.length === 0) return 1;
275
+ const ids = entries.filter((e) => e.isFile() && e.name.endsWith(".md")).flatMap((e) => {
276
+ const filePath = path4.join(tasksDir, e.name);
277
+ try {
278
+ const content = fs4.readFileSync(filePath, "utf8");
279
+ const id = extractPlanId(content, filePath);
280
+ return id === null ? [] : [id];
281
+ } catch (_err) {
282
+ return [];
283
+ }
284
+ });
285
+ const max = ids.reduce((acc, id) => Math.max(acc, id), 0);
286
+ return max + 1;
287
+ };
288
+
289
+ // src/skill-scripts/get-next-task-id.ts
290
+ var main = () => {
291
+ const inputId = process.argv[2];
292
+ if (!inputId) {
293
+ process.stderr.write("Error: Plan ID or path is required\n");
294
+ process.exit(1);
295
+ }
296
+ const resolved = resolvePlan(inputId);
297
+ if (!resolved) {
298
+ process.stderr.write(`Error: Plan "${inputId}" not found or invalid.
299
+ `);
300
+ process.exit(1);
301
+ }
302
+ process.stdout.write(`${computeNextTaskId(resolved.planDir)}
303
+ `);
304
+ process.exit(0);
305
+ };
306
+ if (require.main === module) {
307
+ main();
308
+ }
309
+ // Annotate the CommonJS export names for ESM import in node:
310
+ 0 && (module.exports = {
311
+ main
312
+ });