@bicorne/task-flow 0.2.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 (56) hide show
  1. package/README.md +2 -4
  2. package/SKILL.md +2 -4
  3. package/dist/commands/analyze.js +160 -318
  4. package/dist/commands/archive.js +44 -48
  5. package/dist/commands/design.js +225 -400
  6. package/dist/commands/extract.js +174 -303
  7. package/dist/commands/init.js +103 -147
  8. package/dist/commands/merge/index.js +184 -295
  9. package/dist/commands/merge/merger.js +112 -134
  10. package/dist/commands/merge/types.js +3 -5
  11. package/dist/commands/merge/validators.js +115 -132
  12. package/dist/commands/merge.js +46 -13
  13. package/dist/commands/start.js +155 -248
  14. package/dist/commands/status.js +68 -129
  15. package/dist/commands/sync.js +37 -53
  16. package/dist/commands/tasks-gen/doc-parser.js +148 -228
  17. package/dist/commands/tasks-gen/generators.js +104 -116
  18. package/dist/commands/tasks-gen/index.js +206 -314
  19. package/dist/commands/tasks-gen/parsers.js +131 -232
  20. package/dist/commands/tasks-gen/templates.js +9 -10
  21. package/dist/commands/tasks-gen/types.js +36 -14
  22. package/dist/commands/tasks-gen/validators.js +33 -49
  23. package/dist/commands/tasks.js +58 -20
  24. package/dist/commands/worktree.js +167 -249
  25. package/dist/hooks/check-prd-exists.js +45 -55
  26. package/dist/hooks/check-worktree-conflict.js +68 -101
  27. package/dist/hooks/hook-runner/executor.js +134 -126
  28. package/dist/hooks/hook-runner/index.js +181 -196
  29. package/dist/hooks/hook-runner/loader.js +74 -113
  30. package/dist/hooks/hook-runner/types.js +3 -5
  31. package/dist/hooks/hook-runner.js +94 -28
  32. package/dist/hooks/phase-complete-detector.js +125 -191
  33. package/dist/hooks/phase-gate-validator.js +315 -376
  34. package/dist/hooks/save-checkpoint.js +87 -130
  35. package/dist/hooks/start-mcp-servers.js +50 -65
  36. package/dist/hooks/stop-mcp-servers.js +40 -49
  37. package/dist/index.js +84 -153
  38. package/dist/lib/archive.js +126 -209
  39. package/dist/lib/config.js +141 -226
  40. package/dist/lib/constants.js +155 -145
  41. package/dist/lib/interactive.js +98 -148
  42. package/dist/lib/mcp-client.js +197 -320
  43. package/dist/lib/state.js +142 -253
  44. package/dist/slash/executor.js +299 -330
  45. package/dist/slash/index.js +69 -43
  46. package/dist/slash/parser.js +84 -97
  47. package/dist/slash/registry.js +100 -88
  48. package/dist/spec/openspec-to-task/builders.js +96 -109
  49. package/dist/spec/openspec-to-task/index.js +112 -173
  50. package/dist/spec/openspec-to-task/parsers.js +148 -219
  51. package/dist/spec/openspec-to-task/types.js +3 -5
  52. package/dist/spec/sync-openspec-to-task.js +47 -19
  53. package/dist/spec/sync-task-to-openspec.js +241 -272
  54. package/dist/types/ai-context.js +3 -8
  55. package/package.json +8 -6
  56. package/references/CLI-TUTORIAL.md +4 -10
@@ -1,232 +1,161 @@
1
- "use strict";
2
- /**
3
- * spec/openspec-to-task/parsers.ts
4
- * Parsing and extraction utilities for Spec to task sync
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);
30
- };
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;
1
+ function e(t) {
2
+ return "function" != typeof WeakMap ? null : (e = function(e) {
3
+ return new WeakMap();
4
+ })(t);
5
+ }
6
+ function t(t, r) {
7
+ var n, s, i;
8
+ if (!r && t && t.__esModule) return t;
9
+ if (null === t || "object" != typeof t && "function" != typeof t) return {
10
+ default: t
37
11
  };
38
- })();
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.parseArgs = parseArgs;
41
- exports.ensurePosix = ensurePosix;
42
- exports.toTaskId = toTaskId;
43
- exports.toWorktreeName = toWorktreeName;
44
- exports.readIfExists = readIfExists;
45
- exports.readJsonIfExists = readJsonIfExists;
46
- exports.uniqueArray = uniqueArray;
47
- exports.normalizeBoolean = normalizeBoolean;
48
- exports.extractTitle = extractTitle;
49
- exports.extractChecklistItems = extractChecklistItems;
50
- exports.extractFileCandidates = extractFileCandidates;
51
- exports.inferImplementationValidations = inferImplementationValidations;
52
- exports.inferReviewValidations = inferReviewValidations;
53
- exports.resolveStructuredConfig = resolveStructuredConfig;
54
- const fs = __importStar(require("fs"));
55
- const path = __importStar(require("path"));
56
- /**
57
- * Parse CLI arguments
58
- */
59
- function parseArgs(argv) {
60
- const args = {};
61
- for (let i = 2; i < argv.length; i += 1) {
62
- const token = argv[i] || '';
63
- if (!token.startsWith('--')) {
64
- continue;
65
- }
66
- const key = token.slice(2);
67
- const next = argv[i + 1] || '';
68
- if (!next || next.startsWith('--')) {
69
- args[key] = true;
12
+ if ((n = e(r)) && n.has(t)) return n.get(t);
13
+ for(var u in s = {
14
+ __proto__: null
15
+ }, i = Object.defineProperty && Object.getOwnPropertyDescriptor, t)if ("default" !== u && Object.prototype.hasOwnProperty.call(t, u)) {
16
+ var o = i ? Object.getOwnPropertyDescriptor(t, u) : null;
17
+ o && (o.get || o.set) ? Object.defineProperty(s, u, o) : s[u] = t[u];
18
+ }
19
+ return s.default = t, n && n.set(t, s), s;
20
+ }
21
+ function r(e) {
22
+ let t = {};
23
+ for(let r = 2; r < e.length; r += 1){
24
+ let n = e[r] || '';
25
+ if (!n.startsWith('--')) continue;
26
+ let s = n.slice(2), i = e[r + 1] || '';
27
+ if (!i || i.startsWith('--')) {
28
+ t[s] = !0;
70
29
  continue;
71
30
  }
72
- args[key] = next;
73
- i += 1;
74
- }
75
- return args;
76
- }
77
- /**
78
- * Ensure POSIX path
79
- */
80
- function ensurePosix(p) {
81
- return String(p || '').replace(/\\/g, '/');
82
- }
83
- /**
84
- * Sanitize task ID
85
- */
86
- function toTaskId(input) {
87
- return String(input || '')
88
- .trim()
89
- .replace(/[^a-zA-Z0-9-_]/g, '-')
90
- .replace(/-+/g, '-')
91
- .replace(/^-|-$/g, '');
92
- }
93
- /**
94
- * Generate worktree name
95
- */
96
- function toWorktreeName(type, taskId) {
97
- return `harness-${type}-${taskId}`;
98
- }
99
- /**
100
- * Read file if exists
101
- */
102
- function readIfExists(filePath) {
103
- if (!fs.existsSync(filePath)) {
104
- return '';
105
- }
106
- return fs.readFileSync(filePath, 'utf8');
107
- }
108
- /**
109
- * Read JSON if exists
110
- */
111
- function readJsonIfExists(filePath) {
112
- if (!fs.existsSync(filePath)) {
113
- return null;
31
+ t[s] = i, r += 1;
114
32
  }
33
+ return t;
34
+ }
35
+ function n(e) {
36
+ return String(e || '').replace(/\\/g, '/');
37
+ }
38
+ function s(e) {
39
+ return String(e || '').trim().replace(/[^a-zA-Z0-9-_]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '');
40
+ }
41
+ function i(e, t) {
42
+ return `harness-${e}-${t}`;
43
+ }
44
+ function u(e) {
45
+ return x.existsSync(e) ? x.readFileSync(e, 'utf8') : '';
46
+ }
47
+ function o(e) {
48
+ if (!x.existsSync(e)) return null;
115
49
  try {
116
- return JSON.parse(fs.readFileSync(filePath, 'utf8'));
117
- }
118
- catch (error) {
119
- throw new Error(`Invalid JSON: ${ensurePosix(filePath)} (${error instanceof Error ? error.message : 'Unknown error'})`, { cause: error });
50
+ return JSON.parse(x.readFileSync(e, 'utf8'));
51
+ } catch (t) {
52
+ throw Error(`Invalid JSON: ${n(e)} (${t instanceof Error ? t.message : 'Unknown error'})`, {
53
+ cause: t
54
+ });
120
55
  }
121
56
  }
122
- /**
123
- * Deduplicate array
124
- */
125
- function uniqueArray(items) {
126
- return [...new Set((Array.isArray(items) ? items : []).filter(Boolean).map((item) => ensurePosix(String(item).trim())))];
127
- }
128
- /**
129
- * Normalize boolean
130
- */
131
- function normalizeBoolean(value, fallback) {
132
- if (typeof value === 'boolean') {
133
- return value;
134
- }
135
- if (typeof value === 'string') {
136
- if (value === 'true') {
137
- return true;
138
- }
139
- if (value === 'false') {
140
- return false;
141
- }
142
- }
143
- return fallback;
144
- }
145
- /**
146
- * Extract title from proposal
147
- */
148
- function extractTitle(changeName, proposalContent) {
149
- const lines = proposalContent.split(/\r?\n/);
150
- const heading = lines.find((line) => /^#\s+/.test(line));
151
- if (!heading) {
152
- return `Spec 变更:${changeName}`;
153
- }
154
- return heading.replace(/^#\s+/, '').trim();
155
- }
156
- /**
157
- * Extract checklist items from tasks.md
158
- */
159
- function extractChecklistItems(tasksContent) {
160
- const lines = tasksContent.split(/\r?\n/);
161
- const items = [];
162
- for (const line of lines) {
163
- const match = line.match(/^\s*[-*]\s+\[(?: |x|X)\]\s+(.+)\s*$/);
164
- if (match) {
165
- items.push(match?.[1]?.trim() || '');
166
- }
167
- }
168
- return items;
169
- }
170
- /**
171
- * Extract file candidates from text
172
- */
173
- function extractFileCandidates(texts) {
174
- const merged = texts.filter(Boolean).join('\n');
175
- const regex = /(?:^|[\s(])((?:server|web|docs|scripts|spec|\.harness|packages)\/[^\s):`'"]+\.[a-zA-Z0-9]+)(?=$|[\s),`'"])/gm;
176
- const result = [];
177
- let match = regex.exec(merged);
178
- while (match) {
179
- const file = ensurePosix(match?.[1]?.trim() || '');
180
- if (file && !result.includes(file)) {
181
- result.push(file);
182
- }
183
- match = regex.exec(merged);
184
- }
185
- return result;
186
- }
187
- /**
188
- * Infer implementation validations
189
- */
190
- function inferImplementationValidations(checklistItems) {
191
- const source = checklistItems.join('\n').toLowerCase();
192
- const values = [];
193
- if (/build|构建/.test(source)) {
194
- values.push('build-passes');
195
- }
196
- if (/test|测试|回归/.test(source)) {
197
- values.push('tests-pass');
198
- }
199
- if (/type|类型/.test(source)) {
200
- values.push('typecheck-passes');
201
- }
202
- if (/lint|格式|规范/.test(source)) {
203
- values.push('lint-passes');
57
+ function a(e) {
58
+ return [
59
+ ...new Set((Array.isArray(e) ? e : []).filter(Boolean).map((e)=>n(String(e).trim())))
60
+ ];
61
+ }
62
+ function c(e, t) {
63
+ if ('boolean' == typeof e) return e;
64
+ if ('string' == typeof e) {
65
+ if ('true' === e) return !0;
66
+ if ('false' === e) return !1;
204
67
  }
205
- if (values.length === 0) {
206
- values.push('build-passes', 'tests-pass', 'typecheck-passes', 'lint-passes');
68
+ return t;
69
+ }
70
+ function l(e, t) {
71
+ let r = t.split(/\r?\n/).find((e)=>/^#\s+/.test(e));
72
+ return r ? r.replace(/^#\s+/, '').trim() : `Spec 变更:${e}`;
73
+ }
74
+ function f(e) {
75
+ let t = e.split(/\r?\n/), r = [];
76
+ for (let e of t){
77
+ let t = e.match(/^\s*[-*]\s+\[(?: |x|X)\]\s+(.+)\s*$/);
78
+ t && r.push(t?.[1]?.trim() || '');
207
79
  }
208
- return values;
209
- }
210
- /**
211
- * Infer review validations
212
- */
213
- function inferReviewValidations(checklistItems) {
214
- const source = checklistItems.join('\n').toLowerCase();
215
- const values = ['security-check', 'review-conclusion'];
216
- if (/cover|覆盖率/.test(source)) {
217
- values.splice(1, 0, 'coverage-ge-80');
80
+ return r;
81
+ }
82
+ function p(e) {
83
+ let t = e.filter(Boolean).join('\n'), r = /(?:^|[\s(])((?:server|web|docs|scripts|spec|\.harness|packages)\/[^\s):`'"]+\.[a-zA-Z0-9]+)(?=$|[\s),`'"])/gm, s = [], i = r.exec(t);
84
+ for(; i;){
85
+ let e = n(i?.[1]?.trim() || '');
86
+ e && !s.includes(e) && s.push(e), i = r.exec(t);
218
87
  }
219
- return values;
220
- }
221
- /**
222
- * Resolve structured config from change directory
223
- */
224
- function resolveStructuredConfig(changeDir, changeName) {
225
- const manifestPath = path.resolve(changeDir, 'manifest.json');
226
- const manifest = readJsonIfExists(manifestPath) || {};
88
+ return s;
89
+ }
90
+ function g(e) {
91
+ let t = e.join('\n').toLowerCase(), r = [];
92
+ return /build|构建/.test(t) && r.push('build-passes'), /test|测试|回归/.test(t) && r.push('tests-pass'), /type|类型/.test(t) && r.push('typecheck-passes'), /lint|格式|规范/.test(t) && r.push('lint-passes'), 0 === r.length && r.push('build-passes', 'tests-pass', 'typecheck-passes', 'lint-passes'), r;
93
+ }
94
+ function d(e) {
95
+ let t = e.join('\n').toLowerCase(), r = [
96
+ 'security-check',
97
+ 'review-conclusion'
98
+ ];
99
+ return /cover|覆盖率/.test(t) && r.splice(1, 0, 'coverage-ge-80'), r;
100
+ }
101
+ function h(e, t) {
102
+ let r = b.resolve(e, 'manifest.json'), s = o(r) || {};
227
103
  return {
228
- manifestPath: ensurePosix(path.relative(process.cwd(), manifestPath)),
229
- manifest,
230
- executionPath: ensurePosix(manifest.execution || `spec/changes/${changeName}/execution.json`),
104
+ manifestPath: n(b.relative(process.cwd(), r)),
105
+ manifest: s,
106
+ executionPath: n(s.execution || `spec/changes/${t}/execution.json`)
231
107
  };
232
108
  }
109
+ "use strict";
110
+ Object.defineProperty(exports, "__esModule", {
111
+ value: !0
112
+ });
113
+ var y = exports, m = {
114
+ get ensurePosix () {
115
+ return n;
116
+ },
117
+ get extractChecklistItems () {
118
+ return f;
119
+ },
120
+ get extractFileCandidates () {
121
+ return p;
122
+ },
123
+ get extractTitle () {
124
+ return l;
125
+ },
126
+ get inferImplementationValidations () {
127
+ return g;
128
+ },
129
+ get inferReviewValidations () {
130
+ return d;
131
+ },
132
+ get normalizeBoolean () {
133
+ return c;
134
+ },
135
+ get parseArgs () {
136
+ return r;
137
+ },
138
+ get readIfExists () {
139
+ return u;
140
+ },
141
+ get readJsonIfExists () {
142
+ return o;
143
+ },
144
+ get resolveStructuredConfig () {
145
+ return h;
146
+ },
147
+ get toTaskId () {
148
+ return s;
149
+ },
150
+ get toWorktreeName () {
151
+ return i;
152
+ },
153
+ get uniqueArray () {
154
+ return a;
155
+ }
156
+ };
157
+ for(var _ in m)Object.defineProperty(y, _, {
158
+ enumerable: !0,
159
+ get: Object.getOwnPropertyDescriptor(m, _).get
160
+ });
161
+ let x = /*#__PURE__*/ t(require("fs")), b = /*#__PURE__*/ t(require("path"));
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * spec/openspec-to-task/types.ts
4
- * Type definitions for Spec to task sync
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: !0
4
+ });
@@ -1,21 +1,49 @@
1
+ function e(t) {
2
+ return "function" != typeof WeakMap ? null : (e = function(e) {
3
+ return new WeakMap();
4
+ })(t);
5
+ }
1
6
  "use strict";
2
- /**
3
- * sync-openspec-to-task.ts
4
- * Backward-compatible re-export from openspec-to-task/ module
5
- * @deprecated Import from '../spec/openspec-to-task/index' directly
6
- */
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: !0
9
+ });
10
+ var t = exports, r = {
11
+ get ManifestJson () {
12
+ return u.ManifestJson;
13
+ },
14
+ get SyncOptions () {
15
+ return u.SyncOptions;
16
+ },
17
+ get SyncResult () {
18
+ return u.SyncResult;
19
+ },
20
+ get default () {
21
+ return o.default;
22
+ },
23
+ get main () {
24
+ return o.main;
25
+ },
26
+ get syncSpecToTask () {
27
+ return o.syncSpecToTask;
28
+ }
9
29
  };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.default = exports.main = exports.syncSpecToTask = void 0;
12
- var index_1 = require("./openspec-to-task/index");
13
- Object.defineProperty(exports, "syncSpecToTask", { enumerable: true, get: function () { return index_1.syncSpecToTask; } });
14
- Object.defineProperty(exports, "main", { enumerable: true, get: function () { return index_1.main; } });
15
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(index_1).default; } });
16
- // Allow direct execution when invoked via spawnSync
17
- // eslint-disable-next-line @typescript-eslint/no-require-imports
18
- const { main: runMain } = require('./openspec-to-task/index');
19
- if (require.main === module) {
20
- runMain();
21
- }
30
+ for(var n in r)Object.defineProperty(t, n, {
31
+ enumerable: !0,
32
+ get: Object.getOwnPropertyDescriptor(r, n).get
33
+ });
34
+ let o = /*#__PURE__*/ function(t) {
35
+ var r, n, o;
36
+ if (t && t.__esModule) return t;
37
+ if (null === t || "object" != typeof t && "function" != typeof t) return {
38
+ default: t
39
+ };
40
+ if ((r = e(void 0)) && r.has(t)) return r.get(t);
41
+ for(var u in n = {
42
+ __proto__: null
43
+ }, o = Object.defineProperty && Object.getOwnPropertyDescriptor, t)if ("default" !== u && Object.prototype.hasOwnProperty.call(t, u)) {
44
+ var i = o ? Object.getOwnPropertyDescriptor(t, u) : null;
45
+ i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = t[u];
46
+ }
47
+ return n.default = t, r && r.set(t, n), n;
48
+ }(require("./openspec-to-task/index")), u = require("./openspec-to-task/types"), { main: i } = require('./openspec-to-task/index');
49
+ require.main === module && i();