@bicorne/task-flow 0.1.0 → 0.2.1

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 (58) hide show
  1. package/README.md +337 -145
  2. package/SKILL.md +9 -5
  3. package/assets/.harnessrc +0 -1
  4. package/dist/commands/analyze.js +160 -318
  5. package/dist/commands/archive.js +44 -48
  6. package/dist/commands/design.js +225 -400
  7. package/dist/commands/extract.js +174 -303
  8. package/dist/commands/init.js +103 -148
  9. package/dist/commands/merge/index.js +184 -295
  10. package/dist/commands/merge/merger.js +112 -134
  11. package/dist/commands/merge/types.js +3 -5
  12. package/dist/commands/merge/validators.js +115 -132
  13. package/dist/commands/merge.js +46 -13
  14. package/dist/commands/start.js +155 -248
  15. package/dist/commands/status.js +68 -129
  16. package/dist/commands/sync.js +37 -53
  17. package/dist/commands/tasks-gen/doc-parser.js +148 -228
  18. package/dist/commands/tasks-gen/generators.js +104 -116
  19. package/dist/commands/tasks-gen/index.js +206 -314
  20. package/dist/commands/tasks-gen/parsers.js +131 -232
  21. package/dist/commands/tasks-gen/templates.js +9 -10
  22. package/dist/commands/tasks-gen/types.js +36 -14
  23. package/dist/commands/tasks-gen/validators.js +33 -49
  24. package/dist/commands/tasks.js +58 -20
  25. package/dist/commands/worktree.js +167 -249
  26. package/dist/hooks/check-prd-exists.js +45 -55
  27. package/dist/hooks/check-worktree-conflict.js +68 -101
  28. package/dist/hooks/hook-runner/executor.js +134 -126
  29. package/dist/hooks/hook-runner/index.js +181 -196
  30. package/dist/hooks/hook-runner/loader.js +74 -113
  31. package/dist/hooks/hook-runner/types.js +3 -5
  32. package/dist/hooks/hook-runner.js +94 -28
  33. package/dist/hooks/phase-complete-detector.js +125 -191
  34. package/dist/hooks/phase-gate-validator.js +315 -376
  35. package/dist/hooks/save-checkpoint.js +87 -130
  36. package/dist/hooks/start-mcp-servers.js +50 -65
  37. package/dist/hooks/stop-mcp-servers.js +40 -49
  38. package/dist/index.js +84 -153
  39. package/dist/lib/archive.js +126 -209
  40. package/dist/lib/config.d.ts +0 -2
  41. package/dist/lib/config.js +141 -230
  42. package/dist/lib/constants.js +155 -145
  43. package/dist/lib/interactive.js +98 -148
  44. package/dist/lib/mcp-client.js +197 -320
  45. package/dist/lib/state.js +142 -253
  46. package/dist/slash/executor.js +309 -233
  47. package/dist/slash/index.js +69 -43
  48. package/dist/slash/parser.js +84 -97
  49. package/dist/slash/registry.js +100 -88
  50. package/dist/spec/openspec-to-task/builders.js +96 -109
  51. package/dist/spec/openspec-to-task/index.js +112 -173
  52. package/dist/spec/openspec-to-task/parsers.js +148 -219
  53. package/dist/spec/openspec-to-task/types.js +3 -5
  54. package/dist/spec/sync-openspec-to-task.js +47 -19
  55. package/dist/spec/sync-task-to-openspec.js +241 -272
  56. package/dist/types/ai-context.js +3 -8
  57. package/package.json +9 -7
  58. package/references/CLI-TUTORIAL.md +4 -10
@@ -1,107 +1,74 @@
1
- "use strict";
2
- /**
3
- * hooks/check-worktree-conflict.ts
4
- * Check for worktree conflicts to prevent multi-agent file conflicts
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || (function () {
23
- var ownKeys = function(o) {
24
- ownKeys = Object.getOwnPropertyNames || function (o) {
25
- var ar = [];
26
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
- return ar;
28
- };
29
- return ownKeys(o);
1
+ let e, t, r;
2
+ function o(e) {
3
+ return "function" != typeof WeakMap ? null : (o = function(e) {
4
+ return new WeakMap();
5
+ })(e);
6
+ }
7
+ function n(e, t) {
8
+ if (!e || 'string' != typeof e) return '';
9
+ let r = a.isAbsolute(e) ? e : a.resolve(t, e);
10
+ return a.relative(t, r).replace(/\\/g, '/');
11
+ }
12
+ function i(e) {
13
+ let { input: t, config: r } = e, o = process.env.WORKTREE_NAME, i = (0, s.getActiveWorktrees)(r);
14
+ if (i.length <= 1) return {
15
+ conflict: !1,
16
+ reason: 'single-worktree'
30
17
  };
31
- return function (mod) {
32
- if (mod && mod.__esModule) return mod;
33
- var result = {};
34
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
- __setModuleDefault(result, mod);
36
- return result;
18
+ let l = n(t.tool_input?.file_path || t.tool_input?.path, r.projectRoot);
19
+ if (!l) return {
20
+ conflict: !1,
21
+ reason: 'no-file-path'
22
+ };
23
+ for (let e of i)if (e.name !== o && (e.pendingChanges || []).map((e)=>n(e, r.projectRoot)).filter(Boolean).includes(l)) return {
24
+ conflict: !0,
25
+ file: l,
26
+ conflictingWorktree: e.name,
27
+ message: `File ${l} is being modified by ${e.name}`
28
+ };
29
+ return {
30
+ conflict: !1,
31
+ reason: 'no-conflict'
37
32
  };
38
- })();
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.normalizePath = normalizePath;
41
- exports.checkWorktreeConflict = checkWorktreeConflict;
42
- const path = __importStar(require("path"));
43
- const config_1 = require("../lib/config");
44
- const state_1 = require("../lib/state");
45
- function normalizePath(inputPath, projectRoot) {
46
- if (!inputPath || typeof inputPath !== 'string') {
47
- return '';
48
- }
49
- const absolutePath = path.isAbsolute(inputPath) ? inputPath : path.resolve(projectRoot, inputPath);
50
- return path.relative(projectRoot, absolutePath).replace(/\\/g, '/');
51
33
  }
52
- /**
53
- * Check for worktree conflicts
54
- * @param options - Options
55
- * @returns Result
56
- */
57
- function checkWorktreeConflict(options) {
58
- const { input, config } = options;
59
- const currentWorktree = process.env.WORKTREE_NAME;
60
- const activeWorktrees = (0, state_1.getActiveWorktrees)(config);
61
- if (activeWorktrees.length <= 1) {
62
- return { conflict: false, reason: 'single-worktree' };
63
- }
64
- // Check if current operation involves file path
65
- const targetFile = normalizePath(input.tool_input?.file_path || input.tool_input?.path, config.projectRoot);
66
- if (!targetFile) {
67
- return { conflict: false, reason: 'no-file-path' };
68
- }
69
- // Check if other active worktrees are modifying the same file
70
- for (const wt of activeWorktrees) {
71
- if (wt.name !== currentWorktree) {
72
- const wtChanges = (wt.pendingChanges || [])
73
- .map((p) => normalizePath(p, config.projectRoot))
74
- .filter(Boolean);
75
- if (wtChanges.includes(targetFile)) {
76
- return {
77
- conflict: true,
78
- file: targetFile,
79
- conflictingWorktree: wt.name,
80
- message: `File ${targetFile} is being modified by ${wt.name}`,
81
- };
82
- }
83
- }
34
+ "use strict";
35
+ Object.defineProperty(exports, "__esModule", {
36
+ value: !0
37
+ });
38
+ var l = exports, c = {
39
+ get checkWorktreeConflict () {
40
+ return i;
41
+ },
42
+ get default () {
43
+ return p;
44
+ },
45
+ get normalizePath () {
46
+ return n;
84
47
  }
85
- return { conflict: false, reason: 'no-conflict' };
86
- }
87
- /**
88
- * Main entry point for hook usage
89
- */
90
- function main() {
91
- const input = JSON.parse(process.argv[2] || '{}');
92
- const config = (0, config_1.loadConfig)();
93
- (0, state_1.loadState)(config);
94
- const result = checkWorktreeConflict({ input, config });
95
- if (result.conflict) {
96
- console.error(`[CONFLICT] ${result.message}`);
97
- console.error(`[CONFLICT] Suggestion: Wait for ${result.conflictingWorktree} to complete or use a different file`);
98
- process.exit(2); // Non-zero exit to block operation
48
+ };
49
+ for(var f in c)Object.defineProperty(l, f, {
50
+ enumerable: !0,
51
+ get: Object.getOwnPropertyDescriptor(c, f).get
52
+ });
53
+ let a = /*#__PURE__*/ function(e) {
54
+ var t, r, n;
55
+ if (e && e.__esModule) return e;
56
+ if (null === e || "object" != typeof e && "function" != typeof e) return {
57
+ default: e
58
+ };
59
+ if ((t = o(void 0)) && t.has(e)) return t.get(e);
60
+ for(var i in r = {
61
+ __proto__: null
62
+ }, n = Object.defineProperty && Object.getOwnPropertyDescriptor, e)if ("default" !== i && Object.prototype.hasOwnProperty.call(e, i)) {
63
+ var l = n ? Object.getOwnPropertyDescriptor(e, i) : null;
64
+ l && (l.get || l.set) ? Object.defineProperty(r, i, l) : r[i] = e[i];
99
65
  }
100
- process.exit(0);
101
- }
102
- if (require.main === module) {
103
- main();
104
- }
105
- exports.default = {
106
- checkWorktreeConflict,
66
+ return r.default = e, t && t.set(e, r), r;
67
+ }(require("path")), u = require("../lib/config"), s = require("../lib/state");
68
+ require.main === module && (e = JSON.parse(process.argv[2] || '{}'), t = (0, u.loadConfig)(), (0, s.loadState)(t), (r = i({
69
+ input: e,
70
+ config: t
71
+ })).conflict && (console.error(`[CONFLICT] ${r.message}`), console.error(`[CONFLICT] Suggestion: Wait for ${r.conflictingWorktree} to complete or use a different file`), process.exit(2)), process.exit(0));
72
+ let p = {
73
+ checkWorktreeConflict: i
107
74
  };
@@ -1,143 +1,151 @@
1
- "use strict";
2
- /**
3
- * hooks/hook-runner/executor.ts
4
- * Hook execution utilities
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
1
+ function e(r) {
2
+ return "function" != typeof WeakMap ? null : (e = function(e) {
3
+ return new WeakMap();
4
+ })(r);
5
+ }
6
+ function r(r, o) {
7
+ var t, n, s;
8
+ if (!o && r && r.__esModule) return r;
9
+ if (null === r || "object" != typeof r && "function" != typeof r) return {
10
+ default: r
11
+ };
12
+ if ((t = e(o)) && t.has(r)) return t.get(r);
13
+ for(var c in n = {
14
+ __proto__: null
15
+ }, s = Object.defineProperty && Object.getOwnPropertyDescriptor, r)if ("default" !== c && Object.prototype.hasOwnProperty.call(r, c)) {
16
+ var u = s ? Object.getOwnPropertyDescriptor(r, c) : null;
17
+ u && (u.get || u.set) ? Object.defineProperty(n, c, u) : n[c] = r[c];
11
18
  }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || (function () {
23
- var ownKeys = function(o) {
24
- ownKeys = Object.getOwnPropertyNames || function (o) {
25
- var ar = [];
26
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
- return ar;
28
- };
29
- return ownKeys(o);
19
+ return n.default = r, t && t.set(r, n), n;
20
+ }
21
+ async function o(e, r) {
22
+ if (!e) return {
23
+ success: !1,
24
+ error: 'hook-module-not-found'
30
25
  };
31
- return function (mod) {
32
- if (mod && mod.__esModule) return mod;
33
- var result = {};
34
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
- __setModuleDefault(result, mod);
36
- return result;
26
+ let o = e?.run || e?.execute || e?.default || e;
27
+ if ('function' != typeof o) return {
28
+ success: !1,
29
+ error: 'hook-function-not-found'
37
30
  };
38
- })();
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.executeHookFunction = executeHookFunction;
41
- exports.executeSingleHookAsync = executeSingleHookAsync;
42
- exports.executeSingleHookSync = executeSingleHookSync;
43
- const fs = __importStar(require("fs"));
44
- const path = __importStar(require("path"));
45
- const loader_1 = require("./loader");
46
- /**
47
- * Execute a hook module
48
- */
49
- async function executeHookFunction(hookModule, context) {
50
- if (!hookModule) {
51
- return { success: false, error: 'hook-module-not-found' };
52
- }
53
- const hookFn = hookModule?.run
54
- || hookModule?.execute
55
- || hookModule?.default
56
- || hookModule;
57
- if (typeof hookFn !== 'function') {
58
- return { success: false, error: 'hook-function-not-found' };
59
- }
60
31
  try {
61
- const result = hookFn(context);
62
- if (result && typeof result.then === 'function') {
63
- const asyncResult = await result;
64
- return { success: true, result: asyncResult };
32
+ let e = o(r);
33
+ if (e && 'function' == typeof e.then) {
34
+ let r = await e;
35
+ return {
36
+ success: !0,
37
+ result: r
38
+ };
65
39
  }
66
- return { success: true, result };
67
- }
68
- catch (error) {
69
- console.error('[HOOK-RUNNER] Hook execution failed:', error instanceof Error ? error.message : 'Unknown error');
70
- return { success: false, error: error instanceof Error ? error.message : 'Unknown error', stack: error instanceof Error ? error.stack : undefined };
40
+ return {
41
+ success: !0,
42
+ result: e
43
+ };
44
+ } catch (e) {
45
+ return console.error('[HOOK-RUNNER] Hook execution failed:', e instanceof Error ? e.message : 'Unknown error'), {
46
+ success: !1,
47
+ error: e instanceof Error ? e.message : 'Unknown error',
48
+ stack: e instanceof Error ? e.stack : void 0
49
+ };
71
50
  }
72
51
  }
73
- /**
74
- * Execute a single hook with timeout control
75
- */
76
- async function executeSingleHookAsync(hookConfig, context, config) {
77
- const { name, script, timeout = 30000 } = hookConfig;
78
- console.log(`[HOOK-RUNNER] Executing hook: ${name} (${hookConfig.hookName || 'unknown'})`);
79
- // Use dynamic import for async execution
80
- const cfg = config || (await Promise.resolve().then(() => __importStar(require('../../lib/config')))).loadConfig();
81
- const absolutePath = path.isAbsolute(script)
82
- ? script
83
- : path.resolve(cfg.projectRoot, script);
84
- if (!fs.existsSync(absolutePath)) {
85
- return { name, success: false, error: 'script-not-found', script };
86
- }
52
+ async function t(e, t, n) {
53
+ let { name: s, script: c, timeout: u = 30000 } = e;
54
+ console.log(`[HOOK-RUNNER] Executing hook: ${s} (${e.hookName || 'unknown'})`);
55
+ let f = n || (await Promise.resolve().then(()=>/*#__PURE__*/ r(require("../../lib/config")))).loadConfig(), l = a.isAbsolute(c) ? c : a.resolve(f.projectRoot, c);
56
+ if (!i.existsSync(l)) return {
57
+ name: s,
58
+ success: !1,
59
+ error: "script-not-found",
60
+ script: c
61
+ };
87
62
  try {
88
- const fileUrl = `file://${absolutePath}?t=${Date.now()}`;
89
- const hookModule = await Promise.resolve(`${fileUrl}`).then(s => __importStar(require(s)));
90
- const abortController = new AbortController();
91
- const timeoutId = setTimeout(() => {
92
- abortController.abort(new Error(`hook-timeout:${timeout}ms`));
93
- }, timeout);
63
+ let e = `file://${l}?t=${Date.now()}`, n = await Promise.resolve(e).then((e)=>/*#__PURE__*/ r(require(e))), i = new AbortController(), a = setTimeout(()=>{
64
+ i.abort(Error(`hook-timeout:${u}ms`));
65
+ }, u);
94
66
  try {
95
- const executePromise = executeHookFunction(hookModule.default || hookModule, context);
96
- const result = await Promise.race([
97
- executePromise,
98
- new Promise((_, reject) => {
99
- abortController.signal.addEventListener('abort', () => {
100
- reject(abortController.signal.reason);
67
+ let e = o(n.default || n, t), r = await Promise.race([
68
+ e,
69
+ new Promise((e, r)=>{
70
+ i.signal.addEventListener('abort', ()=>{
71
+ r(i.signal.reason);
101
72
  });
102
- }),
73
+ })
103
74
  ]);
104
- return { name, ...result, script };
105
- }
106
- finally {
107
- clearTimeout(timeoutId);
75
+ return {
76
+ name: s,
77
+ ...r,
78
+ script: c
79
+ };
80
+ } finally{
81
+ clearTimeout(a);
108
82
  }
109
- }
110
- catch (error) {
111
- return { name, success: false, error: error instanceof Error ? error.message : 'Unknown error', script };
83
+ } catch (e) {
84
+ return {
85
+ name: s,
86
+ success: !1,
87
+ error: e instanceof Error ? e.message : 'Unknown error',
88
+ script: c
89
+ };
112
90
  }
113
91
  }
114
- /**
115
- * Execute a single hook synchronously
116
- */
117
- function executeSingleHookSync(hookConfig, context, config) {
118
- const { name, script } = hookConfig;
119
- console.log(`[HOOK-RUNNER] Executing hook (sync): ${name} (${hookConfig.hookName || 'unknown'})`);
120
- const hookModule = (0, loader_1.loadHookScript)(script, config);
121
- if (!hookModule) {
122
- return { name, success: false, error: 'script-not-found', script };
123
- }
124
- const hookFn = hookModule?.run
125
- || hookModule?.execute
126
- || hookModule?.default
127
- || hookModule;
128
- if (typeof hookFn !== 'function') {
129
- return { name, success: false, error: 'hook-function-not-found', script };
130
- }
92
+ function n(e, r, o) {
93
+ let { name: t, script: n } = e;
94
+ console.log(`[HOOK-RUNNER] Executing hook (sync): ${t} (${e.hookName || 'unknown'})`);
95
+ let s = (0, f.loadHookScript)(n, o);
96
+ if (!s) return {
97
+ name: t,
98
+ success: !1,
99
+ error: "script-not-found",
100
+ script: n
101
+ };
102
+ let c = s?.run || s?.execute || s?.default || s;
103
+ if ('function' != typeof c) return {
104
+ name: t,
105
+ success: !1,
106
+ error: 'hook-function-not-found',
107
+ script: n
108
+ };
131
109
  try {
132
- const result = hookFn(context);
133
- if (result && typeof result.then === 'function') {
134
- console.warn('[HOOK-RUNNER] Async hook detected in sync execution:', name);
135
- return { name, success: false, error: 'async-hook-in-sync-mode', script };
136
- }
137
- return { name, success: true, result, script };
138
- }
139
- catch (error) {
140
- console.error('[HOOK-RUNNER] Hook execution failed:', error instanceof Error ? error.message : 'Unknown error');
141
- return { name, success: false, error: error instanceof Error ? error.message : 'Unknown error', script };
110
+ let e = c(r);
111
+ if (e && 'function' == typeof e.then) return console.warn('[HOOK-RUNNER] Async hook detected in sync execution:', t), {
112
+ name: t,
113
+ success: !1,
114
+ error: 'async-hook-in-sync-mode',
115
+ script: n
116
+ };
117
+ return {
118
+ name: t,
119
+ success: !0,
120
+ result: e,
121
+ script: n
122
+ };
123
+ } catch (e) {
124
+ return console.error('[HOOK-RUNNER] Hook execution failed:', e instanceof Error ? e.message : 'Unknown error'), {
125
+ name: t,
126
+ success: !1,
127
+ error: e instanceof Error ? e.message : 'Unknown error',
128
+ script: n
129
+ };
142
130
  }
143
131
  }
132
+ "use strict";
133
+ Object.defineProperty(exports, "__esModule", {
134
+ value: !0
135
+ });
136
+ var s = exports, c = {
137
+ get executeHookFunction () {
138
+ return o;
139
+ },
140
+ get executeSingleHookAsync () {
141
+ return t;
142
+ },
143
+ get executeSingleHookSync () {
144
+ return n;
145
+ }
146
+ };
147
+ for(var u in c)Object.defineProperty(s, u, {
148
+ enumerable: !0,
149
+ get: Object.getOwnPropertyDescriptor(c, u).get
150
+ });
151
+ let i = /*#__PURE__*/ r(require("fs")), a = /*#__PURE__*/ r(require("path")), f = require("./loader");