@e0ipso/ai-task-manager 1.36.1 → 1.37.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,376 @@
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/create-feature-branch.ts
31
+ var create_feature_branch_exports = {};
32
+ __export(create_feature_branch_exports, {
33
+ _extractPlanName: () => _extractPlanName,
34
+ _sanitizeBranchName: () => _sanitizeBranchName,
35
+ main: () => main
36
+ });
37
+ module.exports = __toCommonJS(create_feature_branch_exports);
38
+ var path4 = __toESM(require("path"));
39
+
40
+ // src/skill-scripts/shared/git-utils.ts
41
+ var import_child_process = require("child_process");
42
+ var execGit = (command) => {
43
+ try {
44
+ return (0, import_child_process.execSync)(command, { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }).trim();
45
+ } catch (_error) {
46
+ return null;
47
+ }
48
+ };
49
+
50
+ // src/skill-scripts/shared/plan-resolve.ts
51
+ var fs3 = __toESM(require("fs"));
52
+ var path3 = __toESM(require("path"));
53
+
54
+ // src/skill-scripts/shared/root.ts
55
+ var fs = __toESM(require("fs"));
56
+ var path = __toESM(require("path"));
57
+ var EXPECTED_SCHEMA = true ? 1 : 1;
58
+ var isValidTaskManagerRoot = (taskManagerPath) => {
59
+ try {
60
+ if (!fs.existsSync(taskManagerPath)) return false;
61
+ if (!fs.lstatSync(taskManagerPath).isDirectory()) return false;
62
+ const metadataPath = path.join(taskManagerPath, ".init-metadata.json");
63
+ if (!fs.existsSync(metadataPath)) return false;
64
+ const metadata = JSON.parse(fs.readFileSync(metadataPath, "utf8"));
65
+ return metadata && typeof metadata === "object" && "version" in metadata;
66
+ } catch (_err) {
67
+ return false;
68
+ }
69
+ };
70
+ var getTaskManagerAt = (directory) => {
71
+ const taskManagerPath = path.join(directory, ".ai", "task-manager");
72
+ return isValidTaskManagerRoot(taskManagerPath) ? taskManagerPath : null;
73
+ };
74
+ var getParentPaths = (currentPath, acc = []) => {
75
+ const absolutePath = path.resolve(currentPath);
76
+ const nextAcc = [...acc, absolutePath];
77
+ const parentPath = path.dirname(absolutePath);
78
+ if (parentPath === absolutePath) return nextAcc;
79
+ return getParentPaths(parentPath, nextAcc);
80
+ };
81
+ var checkWorkspaceSchema = (metadataPath) => {
82
+ let metadata;
83
+ try {
84
+ metadata = JSON.parse(fs.readFileSync(metadataPath, "utf8"));
85
+ } catch {
86
+ return;
87
+ }
88
+ const actual = typeof metadata.workspaceSchemaVersion === "number" ? metadata.workspaceSchemaVersion : 1;
89
+ if (actual === EXPECTED_SCHEMA) return;
90
+ if (actual < EXPECTED_SCHEMA) {
91
+ process.stderr.write(
92
+ `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.
93
+ `
94
+ );
95
+ } else {
96
+ process.stderr.write(
97
+ `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.
98
+ `
99
+ );
100
+ }
101
+ process.exit(1);
102
+ };
103
+ var findTaskManagerRoot = (startPath = process.cwd()) => {
104
+ const paths = getParentPaths(startPath);
105
+ const found = paths.find((p) => getTaskManagerAt(p));
106
+ if (!found) return null;
107
+ const root = getTaskManagerAt(found);
108
+ if (root) checkWorkspaceSchema(path.join(root, ".init-metadata.json"));
109
+ return root;
110
+ };
111
+
112
+ // src/skill-scripts/shared/plan-scan.ts
113
+ var fs2 = __toESM(require("fs"));
114
+ var path2 = __toESM(require("path"));
115
+
116
+ // src/skill-scripts/shared/frontmatter.ts
117
+ var ID_PATTERNS = [
118
+ /^\s*["']?id["']?\s*:\s*["']?([+-]?\d+)["']?\s*(?:#.*)?$/im,
119
+ /^\s*id\s*:\s*([+-]?\d+)\s*(?:#.*)?$/im,
120
+ /^\s*["']?id["']?\s*:\s*"([+-]?\d+)"\s*(?:#.*)?$/im,
121
+ /^\s*["']?id["']?\s*:\s*'([+-]?\d+)'\s*(?:#.*)?$/im,
122
+ /^\s*["']id["']\s*:\s*([+-]?\d+)\s*(?:#.*)?$/im,
123
+ /^\s*id\s*:\s*[|>]\s*([+-]?\d+)\s*$/im
124
+ ];
125
+ var validateId = (rawId) => {
126
+ const id = parseInt(rawId, 10);
127
+ if (Number.isNaN(id) || id < 0 || id > Number.MAX_SAFE_INTEGER) return null;
128
+ return id;
129
+ };
130
+ var extractIdFromMarkdown = (content) => {
131
+ const frontmatterMatch = content.match(/^---\s*\r?\n([\s\S]*?)\r?\n---/);
132
+ if (!frontmatterMatch || !frontmatterMatch[1]) return null;
133
+ const block = frontmatterMatch[1];
134
+ for (const pattern of ID_PATTERNS) {
135
+ const match = block.match(pattern);
136
+ if (match && match[1]) {
137
+ const id = validateId(match[1]);
138
+ if (id !== null) return id;
139
+ }
140
+ }
141
+ return null;
142
+ };
143
+ var extractIdFromHtml = (content) => {
144
+ const headMatch = content.match(/<head[^>]*>([\s\S]*?)<\/head>/i);
145
+ const scope = headMatch && headMatch[1] ? headMatch[1] : content;
146
+ const metaPatterns = [
147
+ /<meta\s+[^>]*name\s*=\s*["']id["'][^>]*content\s*=\s*["']([+-]?\d+)["'][^>]*\/?>/i,
148
+ /<meta\s+[^>]*content\s*=\s*["']([+-]?\d+)["'][^>]*name\s*=\s*["']id["'][^>]*\/?>/i
149
+ ];
150
+ for (const pattern of metaPatterns) {
151
+ const match = scope.match(pattern);
152
+ if (match && match[1]) {
153
+ const id = validateId(match[1]);
154
+ if (id !== null) return id;
155
+ }
156
+ }
157
+ return null;
158
+ };
159
+ var extractPlanId = (content, filePath) => {
160
+ if (filePath.toLowerCase().endsWith(".html")) return extractIdFromHtml(content);
161
+ return extractIdFromMarkdown(content);
162
+ };
163
+
164
+ // src/skill-scripts/shared/plan-scan.ts
165
+ var PLAN_EXTENSIONS = [".md", ".html"];
166
+ var scanPlanDir = (planDirPath, dirName, isArchive) => {
167
+ let entries;
168
+ try {
169
+ entries = fs2.readdirSync(planDirPath, { withFileTypes: true });
170
+ } catch (_err) {
171
+ return [];
172
+ }
173
+ return entries.filter((e) => e.isFile() && PLAN_EXTENSIONS.some((ext) => e.name.endsWith(ext))).flatMap((e) => {
174
+ const filePath = path2.join(planDirPath, e.name);
175
+ try {
176
+ const content = fs2.readFileSync(filePath, "utf8");
177
+ const id = extractPlanId(content, filePath);
178
+ if (id === null) return [];
179
+ return [{ id, file: filePath, dir: planDirPath, isArchive, name: dirName }];
180
+ } catch (_err) {
181
+ return [];
182
+ }
183
+ });
184
+ };
185
+ var getAllPlans = (taskManagerRoot) => {
186
+ const sources = [
187
+ { dir: path2.join(taskManagerRoot, "plans"), isArchive: false },
188
+ { dir: path2.join(taskManagerRoot, "archive"), isArchive: true }
189
+ ];
190
+ return sources.flatMap(({ dir, isArchive }) => {
191
+ if (!fs2.existsSync(dir)) return [];
192
+ let entries;
193
+ try {
194
+ entries = fs2.readdirSync(dir, { withFileTypes: true });
195
+ } catch (_err) {
196
+ return [];
197
+ }
198
+ return entries.filter((e) => e.isDirectory()).flatMap((e) => scanPlanDir(path2.join(dir, e.name), e.name, isArchive));
199
+ });
200
+ };
201
+
202
+ // src/skill-scripts/shared/plan-resolve.ts
203
+ var isValidRootDir = (taskManagerPath) => {
204
+ try {
205
+ if (!fs3.existsSync(taskManagerPath)) return false;
206
+ if (!fs3.lstatSync(taskManagerPath).isDirectory()) return false;
207
+ const metadataPath = path3.join(taskManagerPath, ".init-metadata.json");
208
+ if (!fs3.existsSync(metadataPath)) return false;
209
+ const metadata = JSON.parse(fs3.readFileSync(metadataPath, "utf8"));
210
+ return metadata && typeof metadata === "object" && "version" in metadata;
211
+ } catch (_err) {
212
+ return false;
213
+ }
214
+ };
215
+ var checkStandardRootShortcut = (filePath) => {
216
+ const planDir = path3.dirname(filePath);
217
+ const parentDir = path3.dirname(planDir);
218
+ const possibleRoot = path3.dirname(parentDir);
219
+ const parentBase = path3.basename(parentDir);
220
+ if (parentBase !== "plans" && parentBase !== "archive") return null;
221
+ if (path3.basename(possibleRoot) !== "task-manager") return null;
222
+ const dotAiDir = path3.dirname(possibleRoot);
223
+ if (path3.basename(dotAiDir) !== ".ai") return null;
224
+ return isValidRootDir(possibleRoot) ? possibleRoot : null;
225
+ };
226
+ var resolveByPath = (absolutePath) => {
227
+ let content;
228
+ try {
229
+ content = fs3.readFileSync(absolutePath, "utf8");
230
+ } catch (_err) {
231
+ return null;
232
+ }
233
+ const planId = extractPlanId(content, absolutePath);
234
+ if (planId === null) return null;
235
+ const tmRoot = checkStandardRootShortcut(absolutePath) || findTaskManagerRoot(path3.dirname(absolutePath));
236
+ if (!tmRoot) return null;
237
+ return {
238
+ planFile: absolutePath,
239
+ planDir: path3.dirname(absolutePath),
240
+ taskManagerRoot: tmRoot,
241
+ planId
242
+ };
243
+ };
244
+ var resolveByIdInAncestry = (planId, startPath, searched = /* @__PURE__ */ new Set()) => {
245
+ const tmRoot = findTaskManagerRoot(startPath);
246
+ if (!tmRoot) return null;
247
+ const normalized = path3.normalize(tmRoot);
248
+ if (searched.has(normalized)) return null;
249
+ searched.add(normalized);
250
+ const plans = getAllPlans(tmRoot);
251
+ const match = plans.find((p) => p.id === planId);
252
+ if (match) {
253
+ return {
254
+ planFile: match.file,
255
+ planDir: match.dir,
256
+ taskManagerRoot: tmRoot,
257
+ planId
258
+ };
259
+ }
260
+ const parentOfRoot = path3.dirname(path3.dirname(tmRoot));
261
+ if (parentOfRoot === tmRoot) return null;
262
+ return resolveByIdInAncestry(planId, parentOfRoot, searched);
263
+ };
264
+ var resolvePlan = (input, startPath = process.cwd()) => {
265
+ if (input === null || input === void 0 || input === "") return null;
266
+ const inputStr = String(input);
267
+ if (inputStr.startsWith("/")) {
268
+ return resolveByPath(inputStr);
269
+ }
270
+ const planId = parseInt(inputStr, 10);
271
+ if (Number.isNaN(planId)) return null;
272
+ return resolveByIdInAncestry(planId, startPath);
273
+ };
274
+
275
+ // src/skill-scripts/create-feature-branch.ts
276
+ var _printError = (message) => {
277
+ console.error(`ERROR: ${message}`);
278
+ };
279
+ var _printSuccess = (message) => {
280
+ console.log(`\u2713 ${message}`);
281
+ };
282
+ var _printWarning = (message) => {
283
+ console.log(`\u26A0 ${message}`);
284
+ };
285
+ var _printInfo = (message) => {
286
+ console.log(message);
287
+ };
288
+ var _isGitRepo = () => {
289
+ const result = execGit("git rev-parse --is-inside-work-tree");
290
+ return result === "true";
291
+ };
292
+ var _getCurrentBranch = () => {
293
+ return execGit("git rev-parse --abbrev-ref HEAD");
294
+ };
295
+ var _hasUncommittedChanges = () => {
296
+ const status = execGit("git status --porcelain");
297
+ return status !== null && status.length > 0;
298
+ };
299
+ var _branchExists = (branchName) => {
300
+ const localBranches = execGit("git branch --list");
301
+ if (localBranches && localBranches.split("\n").some((b) => b.trim().replace("* ", "") === branchName)) {
302
+ return true;
303
+ }
304
+ const remoteBranches = execGit("git branch -r --list");
305
+ if (remoteBranches && remoteBranches.split("\n").some((b) => b.trim().includes(branchName))) {
306
+ return true;
307
+ }
308
+ return false;
309
+ };
310
+ var _sanitizeBranchName = (planName) => {
311
+ return planName.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").substring(0, 60);
312
+ };
313
+ var _extractPlanName = (planDir) => {
314
+ const dirName = path4.basename(planDir);
315
+ const match = dirName.match(/^\d+--(.+)$/);
316
+ return match && match[1] ? match[1] : dirName;
317
+ };
318
+ var main = (startPath = process.cwd()) => {
319
+ if (process.argv.length < 3) {
320
+ _printError("Missing plan ID argument");
321
+ console.log("Usage: node create-feature-branch.cjs <plan-id-or-path>");
322
+ console.log("Example: node create-feature-branch.cjs 58");
323
+ process.exit(1);
324
+ }
325
+ const inputId = process.argv[2];
326
+ if (!_isGitRepo()) {
327
+ _printError("Not a git repository");
328
+ process.exit(1);
329
+ }
330
+ const resolved = resolvePlan(inputId, startPath);
331
+ if (!resolved) {
332
+ _printError(`Plan "${inputId}" not found or invalid`);
333
+ process.exit(1);
334
+ }
335
+ const { planDir, planId } = resolved;
336
+ _printInfo(`Found plan: ${path4.basename(planDir)}`);
337
+ const currentBranch = _getCurrentBranch();
338
+ if (!currentBranch) {
339
+ _printError("Could not determine current git branch");
340
+ process.exit(1);
341
+ }
342
+ if (currentBranch !== "main" && currentBranch !== "master") {
343
+ _printWarning(`Not on main/master branch (current: ${currentBranch})`);
344
+ _printInfo("Proceeding without creating a new branch");
345
+ process.exit(0);
346
+ }
347
+ if (_hasUncommittedChanges()) {
348
+ _printError("Uncommitted changes detected in working tree");
349
+ _printInfo("Please commit or stash your changes before creating a feature branch");
350
+ process.exit(1);
351
+ }
352
+ const planName = _extractPlanName(planDir);
353
+ const sanitizedName = _sanitizeBranchName(planName);
354
+ const branchName = `feature/${planId}--${sanitizedName}`;
355
+ if (_branchExists(branchName)) {
356
+ _printWarning(`Branch "${branchName}" already exists`);
357
+ _printInfo("Proceeding with existing branch");
358
+ process.exit(0);
359
+ }
360
+ const createResult = execGit(`git checkout -b "${branchName}"`);
361
+ if (createResult === null) {
362
+ _printError(`Failed to create branch "${branchName}"`);
363
+ process.exit(1);
364
+ }
365
+ _printSuccess(`Created and switched to branch: ${branchName}`);
366
+ process.exit(0);
367
+ };
368
+ if (require.main === module) {
369
+ main();
370
+ }
371
+ // Annotate the CommonJS export names for ESM import in node:
372
+ 0 && (module.exports = {
373
+ _extractPlanName,
374
+ _sanitizeBranchName,
375
+ main
376
+ });
@@ -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
+ });