@crewx/wbs 0.1.10-rc.172 → 0.1.10-rc.173

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/dist/cli.js CHANGED
@@ -1,347 +1,27 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.formatDisplayTimestamp = formatDisplayTimestamp;
38
- exports.main = main;
39
- const child_process_1 = require("child_process");
40
- const path = __importStar(require("path"));
41
- const fs = __importStar(require("fs"));
42
- const engine_1 = require("./src/engine");
43
- const sdk_1 = require("@crewx/sdk");
44
- let PKG_VERSION = 'unknown';
45
- try {
46
- const _pkgPath = fs.existsSync(path.join(__dirname, 'package.json'))
47
- ? path.join(__dirname, 'package.json')
48
- : path.join(__dirname, '..', 'package.json');
49
- const _pkg = JSON.parse(fs.readFileSync(_pkgPath, 'utf-8'));
50
- if (_pkg?.version)
51
- PKG_VERSION = String(_pkg.version);
52
- }
53
- catch { }
54
- async function loadTracer() {
55
- try {
56
- return await Promise.resolve().then(() => __importStar(require('@crewx/shared/skill-tracer')));
57
- }
58
- catch {
59
- return null;
60
- }
61
- }
62
- const STATUS_ICONS = {
63
- pending: '⬜️',
64
- running: '🟡',
65
- completed: '✅',
66
- failed: '❌',
67
- on_hold: '⏸️',
68
- planning: '📝',
69
- partial: '⚠️',
70
- };
71
- function icon(status) {
72
- return STATUS_ICONS[status] ?? '❓';
73
- }
74
- function getDisplayWidth(str) {
75
- let width = 0;
76
- for (const char of String(str)) {
77
- const code = char.codePointAt(0) ?? 0;
78
- if ((code >= 0x1100 && code <= 0x11FF) || (code >= 0x3000 && code <= 0x303F) ||
79
- (code >= 0x3040 && code <= 0x309F) || (code >= 0x30A0 && code <= 0x30FF) ||
80
- (code >= 0x3130 && code <= 0x318F) || (code >= 0x3200 && code <= 0x32FF) ||
81
- (code >= 0x4E00 && code <= 0x9FFF) || (code >= 0xAC00 && code <= 0xD7AF) ||
82
- (code >= 0xF900 && code <= 0xFAFF) || (code >= 0xFF00 && code <= 0xFFEF) ||
83
- (code >= 0x1F300 && code <= 0x1F9FF) || (code >= 0x2600 && code <= 0x26FF) ||
84
- (code >= 0x2700 && code <= 0x27BF)) {
85
- width += 2;
86
- }
87
- else {
88
- width += 1;
89
- }
90
- }
91
- return width;
92
- }
93
- function pad(str, targetWidth) {
94
- const s = String(str);
95
- const diff = targetWidth - getDisplayWidth(s);
96
- return diff > 0 ? s + ' '.repeat(diff) : s;
97
- }
98
- function colWidths(headers, rows) {
99
- const widths = headers.map(h => getDisplayWidth(h));
100
- rows.forEach(row => row.forEach((cell, i) => {
101
- const w = getDisplayWidth(String(cell));
102
- if (w > (widths[i] ?? 0))
103
- widths[i] = w;
104
- }));
105
- return widths;
106
- }
107
- function fmtRow(cells, widths) {
108
- return '| ' + cells.map((c, i) => pad(String(c), widths[i] ?? 0)).join(' | ') + ' |';
109
- }
110
- function fmtSep(widths) {
111
- return '|' + widths.map(w => '-'.repeat(w + 2)).join('|') + '|';
112
- }
113
- function fmtTable(headers, rows) {
114
- const w = colWidths(headers, rows);
115
- return [fmtRow(headers, w), fmtSep(w), ...rows.map(r => fmtRow(r, w))].join('\n');
116
- }
117
- function formatDisplayTimestamp(date) {
118
- const iso = date.toISOString();
119
- return `${iso.slice(0, 10)} ${iso.slice(11, 19)} UTC`;
120
- }
121
- function fmtProjectList(projects) {
122
- if (!projects || projects.length === 0)
123
- return '📋 WBS Projects (0)\n\nNo projects found.';
124
- const rows = projects.map(p => {
125
- const jobs = engine_1.engine.listJobs(p.id);
126
- const done = jobs.filter(j => j.status === 'completed').length;
127
- const total = jobs.length;
128
- const progress = total > 0 ? Math.round((done / total) * 100) : 0;
129
- const statusIcon = p.status === 'completed' ? icon('completed')
130
- : (p.status === 'running' || jobs.some(j => j.status === 'running')) ? icon('running')
131
- : done > 0 ? icon('running') : icon('pending');
132
- return [statusIcon, p.id, p.title, String(total), `${progress}%`];
133
- });
134
- return `📋 WBS Projects (${projects.length})\n\n${fmtTable(['Status', 'ID', 'Project', 'Jobs', 'Progress'], rows)}`;
135
- }
136
- function fmtStatus(result) {
137
- if (!result.project)
138
- return '❌ Project not found';
139
- const { project, jobs, summary } = result;
140
- const lines = [];
141
- lines.push(`📋 ${project.title} (${project.id})`);
142
- if (summary)
143
- lines.push(` Status: ${project.status} | Progress: ${summary.progress}% (${summary.completed}/${summary.total})`);
144
- if (project.detail_path)
145
- lines.push(` Detail: ${project.detail_path}`);
146
- lines.push('');
147
- if (jobs.length === 0) {
148
- lines.push(' Jobs: None');
149
- }
150
- else {
151
- lines.push(' Jobs:');
152
- const table = fmtTable(['Status', '#', 'Slug', 'ID', 'Job', 'Owner'], jobs.map((j, i) => [icon(j.status), String(i + 1), (0, engine_1.getJobSlug)(j), j.id, j.title, j.agent]));
153
- table.split('\n').forEach(l => lines.push(' ' + l));
154
- }
155
- return lines.join('\n');
156
- }
157
- function fmtJobList(jobs, wbsId) {
158
- if (!jobs || jobs.length === 0)
159
- return `📋 Jobs for ${wbsId} (0)\n\nNo jobs found.`;
160
- const done = jobs.filter(j => j.status === 'completed').length;
161
- const progress = jobs.length > 0 ? Math.round((done / jobs.length) * 100) : 0;
162
- const table = fmtTable(['Status', '#', 'Slug', 'ID', 'Job', 'Owner', 'Status'], jobs.map((j, i) => [icon(j.status), String(i + 1), (0, engine_1.getJobSlug)(j), j.id, j.title, j.agent, j.status]));
163
- return `📋 Jobs for ${wbsId} (${jobs.length})\n Progress: ${progress}% (${done}/${jobs.length})\n\n${table}`;
164
- }
165
- function fmtExecList(execs, jobId) {
166
- if (execs.length === 0)
167
- return `No executions found for job: ${jobId}`;
168
- const headers = ['Status', 'ID', 'PID', 'Task ID', 'Start', 'End', 'Code'];
169
- const rows = execs.map(e => [
170
- icon(e.status), e.id, String(e.pid ?? '-'), e.task_id ?? '-',
171
- e.started_at ? formatDisplayTimestamp(new Date(e.started_at)) : '-',
172
- e.ended_at ? formatDisplayTimestamp(new Date(e.ended_at)) : '-',
173
- e.exit_code !== null ? String(e.exit_code) : '-',
174
- ]);
175
- return `📋 Executions for ${jobId}\n\n${fmtTable(headers, rows)}`;
176
- }
177
- function fmtExecStatus(exec) {
178
- return `\n📋 Execution: ${exec.id}\n\nStatus: ${icon(exec.status)} ${exec.status}\nJob ID: ${exec.job_id}\nPID: ${exec.pid ?? '-'}\nTask ID: ${exec.task_id ?? '-'}\nStarted: ${exec.started_at ? formatDisplayTimestamp(new Date(exec.started_at)) : '-'}\nEnded: ${exec.ended_at ? formatDisplayTimestamp(new Date(exec.ended_at)) : '-'}\nExit Code: ${exec.exit_code !== null ? exec.exit_code : '-'}\nError: ${exec.error ?? '-'}\n`;
179
- }
180
- function fmtRunning(execs) {
181
- if (execs.length === 0)
182
- return 'No running executions';
183
- const headers = ['Status', 'Exec ID', 'Job ID', 'PID', 'Task ID', 'Start'];
184
- const rows = execs.map(e => [
185
- icon(e.status), e.id, e.job_id, String(e.pid ?? '-'), e.task_id ?? '-',
186
- e.started_at ? formatDisplayTimestamp(new Date(e.started_at)) : '-',
187
- ]);
188
- return `🟡 Running Executions (${execs.length})\n\n${fmtTable(headers, rows)}`;
189
- }
190
- function hasJson(args) { return args.includes('--json'); }
191
- function hasFlag(args, name) { return args.includes(`--${name}`); }
192
- function getBooleanOpt(args, opts, name) {
193
- const inlinePrefix = `--${name}=`;
194
- const inlineArg = args.find(arg => arg.startsWith(inlinePrefix));
195
- if (inlineArg) {
196
- const rawInline = inlineArg.slice(inlinePrefix.length);
197
- if (rawInline === 'true' || rawInline === '1')
198
- return true;
199
- if (rawInline === 'false' || rawInline === '0')
200
- return false;
201
- console.error(`Invalid boolean for --${name}: ${rawInline} (use true/false)`);
202
- process.exit(1);
203
- }
204
- if (hasFlag(args, name))
205
- return true;
206
- const raw = opts[name];
207
- if (raw === undefined)
208
- return undefined;
209
- if (raw === 'true' || raw === '1')
210
- return true;
211
- if (raw === 'false' || raw === '0')
212
- return false;
213
- console.error(`Invalid boolean for --${name}: ${raw} (use true/false)`);
214
- process.exit(1);
215
- }
216
- function parseOpts(args, start = 0) {
217
- const opts = {};
218
- for (let i = start; i < args.length; i++) {
219
- const current = args[i];
220
- if (!current)
221
- continue;
222
- const next = args[i + 1];
223
- if (current.startsWith('--') && next && !next.startsWith('--')) {
224
- opts[current.slice(2)] = next;
225
- i++;
226
- }
227
- }
228
- return opts;
229
- }
230
- function handleJob(args) {
231
- const sub = args[0];
232
- switch (sub) {
233
- case 'list': {
234
- const wbsId = args[1];
235
- if (!wbsId) {
236
- console.error('Usage: wbs job list <wbs-id> [--json]');
237
- process.exit(1);
238
- }
239
- const jobs = engine_1.engine.listJobs(wbsId);
240
- console.log(hasJson(args) ? JSON.stringify(jobs, null, 2) : fmtJobList(jobs, wbsId));
241
- break;
242
- }
243
- case 'add': {
244
- const wbsId = args[1];
245
- const opts = parseOpts(args, 2);
246
- const { title, agent } = opts;
247
- const description = opts.desc || opts.description || null;
248
- const seq = opts.seq ? parseInt(opts.seq, 10) : 0;
249
- const issue_number = opts.issue ? parseInt(opts.issue, 10) : null;
250
- const no_git = getBooleanOpt(args, opts, 'no-git') ?? false;
251
- if (!wbsId || !title || !agent) {
252
- console.error('Usage: wbs job add <wbs-id> --title "Job Title" --agent "@agent" [--desc "..."] [--seq N] [--issue N] [--no-git]');
253
- process.exit(1);
254
- }
255
- const jobId = engine_1.engine.addJob(wbsId, { title, description, agent, seq, issue_number, no_git });
256
- (0, engine_1.generateDetailFile)(wbsId);
257
- console.log(JSON.stringify({ jobId, wbsId, title, description, agent, seq, issue_number, no_git }, null, 2));
258
- break;
259
- }
260
- case 'update': {
261
- const jobIdArg = args[1];
262
- if (!jobIdArg) {
263
- console.error('Usage: wbs job update <job-id|slug> [--status ...] [--title ...] [--agent ...] [--seq N] [--desc ...] [--issue N] [--no-git[=true|false]]');
264
- process.exit(1);
265
- }
266
- const opts = parseOpts(args, 2);
267
- const job = (0, engine_1.resolveJobId)(jobIdArg);
268
- if (!job) {
269
- console.error(`Job not found: ${jobIdArg}`);
270
- process.exit(1);
271
- }
272
- const jobId = job.id;
273
- const fields = {};
274
- if (opts.status) {
275
- if (!['pending', 'running', 'completed', 'failed'].includes(opts.status)) {
276
- console.error('Invalid status. Must be: pending, running, completed, or failed');
277
- process.exit(1);
278
- }
279
- fields.status = opts.status;
280
- }
281
- if (opts.title)
282
- fields.title = opts.title;
283
- if (opts.agent)
284
- fields.agent = opts.agent;
285
- if (opts.seq !== undefined)
286
- fields.seq = parseInt(opts.seq, 10);
287
- if (opts.desc || opts.description)
288
- fields.description = opts.desc || opts.description;
289
- if (opts.issue !== undefined)
290
- fields.issue_number = opts.issue ? parseInt(opts.issue, 10) : null;
291
- const noGitOpt = getBooleanOpt(args, opts, 'no-git');
292
- if (noGitOpt !== undefined)
293
- fields.no_git = noGitOpt;
294
- if (Object.keys(fields).length === 0) {
295
- console.error('No update options provided.');
296
- process.exit(1);
297
- }
298
- engine_1.engine.updateJob(jobId, fields);
299
- const updated = engine_1.engine.getJob(jobId);
300
- console.log(JSON.stringify(updated, null, 2));
301
- break;
302
- }
303
- case 'next': {
304
- const wbsId = args[1];
305
- if (!wbsId) {
306
- console.error('Usage: wbs job next <wbs-id>');
307
- process.exit(1);
308
- }
309
- const job = engine_1.engine.getNextJob(wbsId);
310
- if (job) {
311
- engine_1.engine.runWorker(job).then(r => console.log(JSON.stringify(r, null, 2)));
312
- }
313
- else {
314
- console.log('No pending jobs');
315
- }
316
- break;
317
- }
318
- case 'run': {
319
- const wbsId = args[1];
320
- if (!wbsId) {
321
- console.error('Usage: wbs job run <wbs-id>');
322
- process.exit(1);
323
- }
324
- engine_1.engine.run(wbsId);
325
- break;
326
- }
327
- case 'retry': {
328
- const jobIdArg = args[1];
329
- if (!jobIdArg) {
330
- console.error('Usage: wbs job retry <job-id|slug>');
331
- process.exit(1);
332
- }
333
- const job = (0, engine_1.resolveJobId)(jobIdArg);
334
- if (!job) {
335
- console.error(`Job not found: ${jobIdArg}`);
336
- process.exit(1);
337
- }
338
- engine_1.engine.updateJob(job.id, { status: 'pending' });
339
- console.log(`[WBS] Retrying job: ${job.title}`);
340
- engine_1.engine.runWorker(job).then(r => console.log(JSON.stringify(r, null, 2)));
341
- break;
342
- }
343
- default:
344
- console.log(`
2
+ "use strict";var E=exports&&exports.__createBinding||(Object.create?(function(n,o,t,e){if(e===void 0)e=t;var s=Object.getOwnPropertyDescriptor(o,t);if(!s||("get"in s?!o.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return o[t]}}}Object.defineProperty(n,e,s)}):(function(n,o,t,e){if(e===void 0)e=t;n[e]=o[t]}));var B=exports&&exports.__setModuleDefault||(Object.create?(function(n,o){Object.defineProperty(n,"default",{enumerable:true,value:o})}):function(n,o){n["default"]=o});var x=exports&&exports.__importStar||(function(){var n=function(o){n=Object.getOwnPropertyNames||function(t){var e=[];for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s))e[e.length]=s;return e};return n(o)};return function(o){if(o&&o.__esModule)return o;var t={};if(o!=null){for(var e=n(o),s=0;s<e.length;s++)if(e[s]!=="default")E(t,o,e[s])}B(t,o);return t}})();Object.defineProperty(exports,"__esModule",{value:true});exports.formatDisplayTimestamp=p;exports.main=I;const F=require("child_process");const w=x(require("path"));const d=x(require("fs"));const c=require("./src/engine");const h=require("@crewx/sdk");let _="unknown";try{const n=d.existsSync(w.join(__dirname,"package.json"))?w.join(__dirname,"package.json"):w.join(__dirname,"..","package.json");const o=JSON.parse(d.readFileSync(n,"utf-8"));if(o?.version)_=String(o.version)}catch{}async function W(){try{return await Promise.resolve().then(()=>x(require("@crewx/shared/skill-tracer")))}catch{return null}}const q={pending:"\u2B1C\uFE0F",running:"\u{1F7E1}",completed:"\u2705",failed:"\u274C",on_hold:"\u23F8\uFE0F",planning:"\u{1F4DD}",partial:"\u26A0\uFE0F"};function b(n){return q[n]??"\u2753"}function $(n){let o=0;for(const t of String(n)){const e=t.codePointAt(0)??0;if(e>=4352&&e<=4607||e>=12288&&e<=12351||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=12592&&e<=12687||e>=12800&&e<=13055||e>=19968&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519||e>=127744&&e<=129535||e>=9728&&e<=9983||e>=9984&&e<=10175){o+=2}else{o+=1}}return o}function A(n,o){const t=String(n);const e=o-$(t);return e>0?t+" ".repeat(e):t}function R(n,o){const t=n.map(e=>$(e));o.forEach(e=>e.forEach((s,i)=>{const r=$(String(s));if(r>(t[i]??0))t[i]=r}));return t}function O(n,o){return"| "+n.map((t,e)=>A(String(t),o[e]??0)).join(" | ")+" |"}function C(n){return"|"+n.map(o=>"-".repeat(o+2)).join("|")+"|"}function j(n,o){const t=R(n,o);return[O(n,t),C(t),...o.map(e=>O(e,t))].join("\n")}function p(n){const o=n.toISOString();return`${o.slice(0,10)} ${o.slice(11,19)} UTC`}function U(n){if(!n||n.length===0)return"\u{1F4CB} WBS Projects (0)\n\nNo projects found.";const o=n.map(t=>{const e=c.engine.listJobs(t.id);const s=e.filter(u=>u.status==="completed").length;const i=e.length;const r=i>0?Math.round(s/i*100):0;const a=t.status==="completed"?b("completed"):t.status==="running"||e.some(u=>u.status==="running")?b("running"):s>0?b("running"):b("pending");return[a,t.id,t.title,String(i),`${r}%`]});return`\u{1F4CB} WBS Projects (${n.length})
3
+
4
+ ${j(["Status","ID","Project","Jobs","Progress"],o)}`}function T(n){if(!n.project)return"\u274C Project not found";const{project:o,jobs:t,summary:e}=n;const s=[];s.push(`\u{1F4CB} ${o.title} (${o.id})`);if(e)s.push(` Status: ${o.status} | Progress: ${e.progress}% (${e.completed}/${e.total})`);if(o.detail_path)s.push(` Detail: ${o.detail_path}`);s.push("");if(t.length===0){s.push(" Jobs: None")}else{s.push(" Jobs:");const i=j(["Status","#","Slug","ID","Job","Owner"],t.map((r,a)=>[b(r.status),String(a+1),(0,c.getJobSlug)(r),r.id,r.title,r.agent]));i.split("\n").forEach(r=>s.push(" "+r))}return s.join("\n")}function L(n,o){if(!n||n.length===0)return`\u{1F4CB} Jobs for ${o} (0)
5
+
6
+ No jobs found.`;const t=n.filter(i=>i.status==="completed").length;const e=n.length>0?Math.round(t/n.length*100):0;const s=j(["Status","#","Slug","ID","Job","Owner","Status"],n.map((i,r)=>[b(i.status),String(r+1),(0,c.getJobSlug)(i),i.id,i.title,i.agent,i.status]));return`\u{1F4CB} Jobs for ${o} (${n.length})
7
+ Progress: ${e}% (${t}/${n.length})
8
+
9
+ ${s}`}function M(n,o){if(n.length===0)return`No executions found for job: ${o}`;const t=["Status","ID","PID","Task ID","Start","End","Code"];const e=n.map(s=>[b(s.status),s.id,String(s.pid??"-"),s.task_id??"-",s.started_at?p(new Date(s.started_at)):"-",s.ended_at?p(new Date(s.ended_at)):"-",s.exit_code!==null?String(s.exit_code):"-"]);return`\u{1F4CB} Executions for ${o}
10
+
11
+ ${j(t,e)}`}function G(n){return`
12
+ \u{1F4CB} Execution: ${n.id}
13
+
14
+ Status: ${b(n.status)} ${n.status}
15
+ Job ID: ${n.job_id}
16
+ PID: ${n.pid??"-"}
17
+ Task ID: ${n.task_id??"-"}
18
+ Started: ${n.started_at?p(new Date(n.started_at)):"-"}
19
+ Ended: ${n.ended_at?p(new Date(n.ended_at)):"-"}
20
+ Exit Code: ${n.exit_code!==null?n.exit_code:"-"}
21
+ Error: ${n.error??"-"}
22
+ `}function K(n){if(n.length===0)return"No running executions";const o=["Status","Exec ID","Job ID","PID","Task ID","Start"];const t=n.map(e=>[b(e.status),e.id,e.job_id,String(e.pid??"-"),e.task_id??"-",e.started_at?p(new Date(e.started_at)):"-"]);return`\u{1F7E1} Running Executions (${n.length})
23
+
24
+ ${j(o,t)}`}function f(n){return n.includes("--json")}function V(n,o){return n.includes(`--${o}`)}function P(n,o,t){const e=`--${t}=`;const s=n.find(r=>r.startsWith(e));if(s){const r=s.slice(e.length);if(r==="true"||r==="1")return true;if(r==="false"||r==="0")return false;console.error(`Invalid boolean for --${t}: ${r} (use true/false)`);process.exit(1)}if(V(n,t))return true;const i=o[t];if(i===void 0)return void 0;if(i==="true"||i==="1")return true;if(i==="false"||i==="0")return false;console.error(`Invalid boolean for --${t}: ${i} (use true/false)`);process.exit(1)}function D(n,o=0){const t={};for(let e=o;e<n.length;e++){const s=n[e];if(!s)continue;const i=n[e+1];if(s.startsWith("--")&&i&&!i.startsWith("--")){t[s.slice(2)]=i;e++}}return t}function H(n){const o=n[0];switch(o){case"list":{const t=n[1];if(!t){console.error("Usage: wbs job list <wbs-id> [--json]");process.exit(1)}const e=c.engine.listJobs(t);console.log(f(n)?JSON.stringify(e,null,2):L(e,t));break}case"add":{const t=n[1];const e=D(n,2);const{title:s,agent:i}=e;const r=e.desc||e.description||null;const a=e.seq?parseInt(e.seq,10):0;const u=e.issue?parseInt(e.issue,10):null;const l=P(n,e,"no-git")??false;if(!t||!s||!i){console.error('Usage: wbs job add <wbs-id> --title "Job Title" --agent "@agent" [--desc "..."] [--seq N] [--issue N] [--no-git]');process.exit(1)}const g=c.engine.addJob(t,{title:s,description:r,agent:i,seq:a,issue_number:u,no_git:l});(0,c.generateDetailFile)(t);console.log(JSON.stringify({jobId:g,wbsId:t,title:s,description:r,agent:i,seq:a,issue_number:u,no_git:l},null,2));break}case"update":{const t=n[1];if(!t){console.error("Usage: wbs job update <job-id|slug> [--status ...] [--title ...] [--agent ...] [--seq N] [--desc ...] [--issue N] [--no-git[=true|false]]");process.exit(1)}const e=D(n,2);const s=(0,c.resolveJobId)(t);if(!s){console.error(`Job not found: ${t}`);process.exit(1)}const i=s.id;const r={};if(e.status){if(!["pending","running","completed","failed"].includes(e.status)){console.error("Invalid status. Must be: pending, running, completed, or failed");process.exit(1)}r.status=e.status}if(e.title)r.title=e.title;if(e.agent)r.agent=e.agent;if(e.seq!==void 0)r.seq=parseInt(e.seq,10);if(e.desc||e.description)r.description=e.desc||e.description;if(e.issue!==void 0)r.issue_number=e.issue?parseInt(e.issue,10):null;const a=P(n,e,"no-git");if(a!==void 0)r.no_git=a;if(Object.keys(r).length===0){console.error("No update options provided.");process.exit(1)}c.engine.updateJob(i,r);const u=c.engine.getJob(i);console.log(JSON.stringify(u,null,2));break}case"next":{const t=n[1];if(!t){console.error("Usage: wbs job next <wbs-id>");process.exit(1)}const e=c.engine.getNextJob(t);if(e){c.engine.runWorker(e).then(s=>console.log(JSON.stringify(s,null,2)))}else{console.log("No pending jobs")}break}case"run":{const t=n[1];if(!t){console.error("Usage: wbs job run <wbs-id>");process.exit(1)}c.engine.run(t);break}case"retry":{const t=n[1];if(!t){console.error("Usage: wbs job retry <job-id|slug>");process.exit(1)}const e=(0,c.resolveJobId)(t);if(!e){console.error(`Job not found: ${t}`);process.exit(1)}c.engine.updateJob(e.id,{status:"pending"});console.log(`[WBS] Retrying job: ${e.title}`);c.engine.runWorker(e).then(s=>console.log(JSON.stringify(s,null,2)));break}default:console.log(`
345
25
  Job Commands - Manage jobs within a WBS project
346
26
 
347
27
  Usage:
@@ -365,61 +45,7 @@ Options for 'job update':
365
45
 
366
46
  Options for 'job run':
367
47
  --parallel Run same-seq pending jobs concurrently (job run only)
368
- `);
369
- }
370
- }
371
- function handleExec(args) {
372
- const sub = args[0];
373
- switch (sub) {
374
- case 'list': {
375
- const jobIdArg = args[1];
376
- if (!jobIdArg) {
377
- console.error('Usage: wbs exec list <job-id|slug> [--json]');
378
- process.exit(1);
379
- }
380
- const resolvedJob = (0, engine_1.resolveJobId)(jobIdArg);
381
- const jobId = resolvedJob?.id ?? jobIdArg;
382
- const execs = engine_1.engine.listExecutions(jobId);
383
- console.log(hasJson(args) ? JSON.stringify(execs, null, 2) : fmtExecList(execs, jobId));
384
- break;
385
- }
386
- case 'status': {
387
- const execId = args[1];
388
- if (!execId) {
389
- console.error('Usage: wbs exec status <exec-id> [--json]');
390
- process.exit(1);
391
- }
392
- const exec = engine_1.engine.getExecution(execId);
393
- if (!exec) {
394
- console.error(`Execution not found: ${execId}`);
395
- process.exit(1);
396
- }
397
- console.log(hasJson(args) ? JSON.stringify(exec, null, 2) : fmtExecStatus(exec));
398
- break;
399
- }
400
- case 'kill': {
401
- const execId = args[1];
402
- if (!execId) {
403
- console.error('Usage: wbs exec kill <exec-id>');
404
- process.exit(1);
405
- }
406
- const ok = engine_1.engine.killExecution(execId);
407
- if (ok) {
408
- console.log(`Killed execution: ${execId}`);
409
- }
410
- else {
411
- console.error(`Could not kill execution: ${execId} (not running or not found)`);
412
- process.exit(1);
413
- }
414
- break;
415
- }
416
- case 'running': {
417
- const execs = engine_1.engine.getRunningExecutions();
418
- console.log(hasJson(args) ? JSON.stringify(execs, null, 2) : fmtRunning(execs));
419
- break;
420
- }
421
- default:
422
- console.log(`
48
+ `)}}function Z(n){const o=n[0];switch(o){case"list":{const t=n[1];if(!t){console.error("Usage: wbs exec list <job-id|slug> [--json]");process.exit(1)}const e=(0,c.resolveJobId)(t);const s=e?.id??t;const i=c.engine.listExecutions(s);console.log(f(n)?JSON.stringify(i,null,2):M(i,s));break}case"status":{const t=n[1];if(!t){console.error("Usage: wbs exec status <exec-id> [--json]");process.exit(1)}const e=c.engine.getExecution(t);if(!e){console.error(`Execution not found: ${t}`);process.exit(1)}console.log(f(n)?JSON.stringify(e,null,2):G(e));break}case"kill":{const t=n[1];if(!t){console.error("Usage: wbs exec kill <exec-id>");process.exit(1)}const e=c.engine.killExecution(t);if(e){console.log(`Killed execution: ${t}`)}else{console.error(`Could not kill execution: ${t} (not running or not found)`);process.exit(1)}break}case"running":{const t=c.engine.getRunningExecutions();console.log(f(n)?JSON.stringify(t,null,2):K(t));break}default:console.log(`
423
49
  Execution Commands - Manage job executions
424
50
 
425
51
  Usage:
@@ -427,165 +53,8 @@ Usage:
427
53
  wbs exec status <exec-id> [--json] Get execution details
428
54
  wbs exec kill <exec-id> Kill a running execution
429
55
  wbs exec running [--json] List all running executions
430
- `);
431
- }
432
- }
433
- function daemonTick() {
434
- const ts = formatDisplayTimestamp(new Date());
435
- console.log(`[${ts}] Daemon tick`);
436
- const zombies = engine_1.engine.checkAndFixZombies();
437
- if (zombies.length > 0) {
438
- console.log(`[${ts}] Fixed ${zombies.length} zombie(s):`);
439
- zombies.forEach(z => console.log(` - ${z.jobId}: ${z.reason}`));
440
- }
441
- const activeProjects = engine_1.engine.getActiveProjects();
442
- if (activeProjects.length === 0) {
443
- console.log(`[${ts}] No active projects`);
444
- return;
445
- }
446
- for (const project of activeProjects) {
447
- const nextSeq = engine_1.engine.getNextSeq(project.id);
448
- if (nextSeq === null) {
449
- console.log(`[${ts}] ${project.id}: No pending jobs`);
450
- continue;
451
- }
452
- const running = engine_1.engine.getJobsBySeq(project.id, nextSeq, 'running');
453
- const pending = engine_1.engine.getJobsBySeq(project.id, nextSeq, 'pending');
454
- if (running.length > 0) {
455
- console.log(`[${ts}] ${project.id}: ${running.length} job(s) running in seq ${nextSeq}`);
456
- continue;
457
- }
458
- if (pending.length > 0) {
459
- console.log(`[${ts}] ${project.id}: Starting next seq ${nextSeq} (${pending.length} pending)`);
460
- try {
461
- const workingDir = (0, engine_1.getProjectRoot)();
462
- const env = { ...process.env };
463
- delete env.CLAUDECODE;
464
- const resolution = (0, sdk_1.resolveCrewxExecutable)({ env, cwd: workingDir });
465
- if (!resolution.ok) {
466
- const error = new Error((0, sdk_1.formatCrewxExecutableFailure)(resolution));
467
- Object.assign(error, { code: 'CLI_UNRESOLVABLE' });
468
- throw error;
469
- }
470
- const childInvocation = (0, sdk_1.createCrewxChildInvocation)(resolution, { baseEnv: env });
471
- const program = (0, sdk_1.resolveWindowsSpawnProgram)({
472
- command: childInvocation.command,
473
- env: childInvocation.env,
474
- cwd: workingDir,
475
- packageName: 'crewx',
476
- allowShellFallback: true,
477
- });
478
- const invocation = (0, sdk_1.materializeWindowsSpawnProgram)(program, [
479
- ...childInvocation.args,
480
- 'x',
481
- `@wbs_coordinator ${project.id} continue with the next job`,
482
- ]);
483
- (0, child_process_1.execFileSync)(invocation.command, invocation.argv, {
484
- stdio: 'inherit',
485
- cwd: workingDir,
486
- env: childInvocation.env,
487
- ...(invocation.shell === undefined ? {} : { shell: invocation.shell }),
488
- ...(invocation.windowsHide === undefined ? {} : { windowsHide: invocation.windowsHide }),
489
- });
490
- }
491
- catch (e) {
492
- console.error(`[${ts}] Failed to call coordinator: ${e.message}`);
493
- }
494
- }
495
- }
496
- }
497
- function startDaemon() {
498
- const pidFile = engine_1.engine.daemonPidFile;
499
- if (fs.existsSync(pidFile)) {
500
- const pid = parseInt(fs.readFileSync(pidFile, 'utf8').trim(), 10);
501
- if (engine_1.engine.isProcessAlive(pid)) {
502
- console.error(`[WBS Daemon] Already running (PID: ${pid})`);
503
- return false;
504
- }
505
- fs.unlinkSync(pidFile);
506
- }
507
- const logFile = engine_1.engine.daemonLogFile;
508
- const out = fs.openSync(logFile, 'a');
509
- const daemonEnv = { ...process.env };
510
- if (process.versions.electron) {
511
- daemonEnv.ELECTRON_RUN_AS_NODE = '1';
512
- }
513
- const child = (0, child_process_1.spawn)(process.execPath, [__filename, 'daemon', '--foreground'], {
514
- detached: true,
515
- stdio: ['ignore', out, out],
516
- cwd: (0, engine_1.getProjectRoot)(),
517
- env: daemonEnv,
518
- });
519
- fs.writeFileSync(pidFile, String(child.pid));
520
- child.unref();
521
- console.log(`[WBS Daemon] Started (PID: ${child.pid})`);
522
- console.log(`[WBS Daemon] Log: ${logFile}`);
523
- return true;
524
- }
525
- function stopDaemon() {
526
- const pidFile = engine_1.engine.daemonPidFile;
527
- if (!fs.existsSync(pidFile)) {
528
- console.error('[WBS Daemon] Not running (no PID file)');
529
- return false;
530
- }
531
- const pid = parseInt(fs.readFileSync(pidFile, 'utf8').trim(), 10);
532
- if (!engine_1.engine.isProcessAlive(pid)) {
533
- console.log('[WBS Daemon] Process not found, cleaning up PID file');
534
- fs.unlinkSync(pidFile);
535
- return true;
536
- }
537
- try {
538
- process.kill(pid, 'SIGTERM');
539
- fs.unlinkSync(pidFile);
540
- console.log(`[WBS Daemon] Stopped (PID: ${pid})`);
541
- return true;
542
- }
543
- catch (e) {
544
- console.error(`[WBS Daemon] Failed to stop: ${e.message}`);
545
- return false;
546
- }
547
- }
548
- function handleDaemon(args) {
549
- const sub = args[0];
550
- switch (sub) {
551
- case 'start':
552
- startDaemon();
553
- break;
554
- case 'stop':
555
- stopDaemon();
556
- break;
557
- case 'status': {
558
- const pidFile = engine_1.engine.daemonPidFile;
559
- if (!fs.existsSync(pidFile)) {
560
- const msg = { running: false, message: 'Not running' };
561
- console.log(hasJson(args) ? JSON.stringify(msg) : `[WBS Daemon] Not running`);
562
- }
563
- else {
564
- const pid = parseInt(fs.readFileSync(pidFile, 'utf8').trim(), 10);
565
- const alive = engine_1.engine.isProcessAlive(pid);
566
- const msg = alive ? { running: true, pid, message: `Running (PID: ${pid})` } : { running: false, pid, message: 'Stale PID file (process dead)' };
567
- console.log(hasJson(args) ? JSON.stringify(msg, null, 2) : `[WBS Daemon] ${msg.message}`);
568
- }
569
- break;
570
- }
571
- case 'restart':
572
- stopDaemon();
573
- setTimeout(() => startDaemon(), 1000);
574
- break;
575
- case '--foreground': {
576
- console.log(`[WBS Daemon] Starting in foreground mode`);
577
- console.log(`[WBS Daemon] Interval: ${engine_1.DAEMON_INTERVAL_MS / 1000 / 60} minutes`);
578
- console.log(`[WBS Daemon] Zombie timeout: ${engine_1.ZOMBIE_TIMEOUT_MS / 1000 / 60} minutes`);
579
- console.log(`[WBS Daemon] Press Ctrl+C to stop\n`);
580
- daemonTick();
581
- setInterval(daemonTick, engine_1.DAEMON_INTERVAL_MS);
582
- break;
583
- }
584
- case 'tick':
585
- daemonTick();
586
- break;
587
- default:
588
- console.log(`
56
+ `)}}function k(){const n=p(new Date);console.log(`[${n}] Daemon tick`);const o=c.engine.checkAndFixZombies();if(o.length>0){console.log(`[${n}] Fixed ${o.length} zombie(s):`);o.forEach(e=>console.log(` - ${e.jobId}: ${e.reason}`))}const t=c.engine.getActiveProjects();if(t.length===0){console.log(`[${n}] No active projects`);return}for(const e of t){const s=c.engine.getNextSeq(e.id);if(s===null){console.log(`[${n}] ${e.id}: No pending jobs`);continue}const i=c.engine.getJobsBySeq(e.id,s,"running");const r=c.engine.getJobsBySeq(e.id,s,"pending");if(i.length>0){console.log(`[${n}] ${e.id}: ${i.length} job(s) running in seq ${s}`);continue}if(r.length>0){console.log(`[${n}] ${e.id}: Starting next seq ${s} (${r.length} pending)`);try{const a=(0,c.getProjectRoot)();const u={...process.env};delete u.CLAUDECODE;const l=(0,h.resolveCrewxExecutable)({env:u,cwd:a});if(!l.ok){const v=new Error((0,h.formatCrewxExecutableFailure)(l));Object.assign(v,{code:"CLI_UNRESOLVABLE"});throw v}const g=(0,h.createCrewxChildInvocation)(l,{baseEnv:u});const S=(0,h.resolveWindowsSpawnProgram)({command:g.command,env:g.env,cwd:a,packageName:"crewx",allowShellFallback:true});const m=(0,h.materializeWindowsSpawnProgram)(S,[...g.args,"x",`@wbs_coordinator ${e.id} continue with the next job`]);(0,F.execFileSync)(m.command,m.argv,{stdio:"inherit",cwd:a,env:g.env,...m.shell===void 0?{}:{shell:m.shell},...m.windowsHide===void 0?{}:{windowsHide:m.windowsHide}})}catch(a){console.error(`[${n}] Failed to call coordinator: ${a.message}`)}}}}function J(){const n=c.engine.daemonPidFile;if(d.existsSync(n)){const i=parseInt(d.readFileSync(n,"utf8").trim(),10);if(c.engine.isProcessAlive(i)){console.error(`[WBS Daemon] Already running (PID: ${i})`);return false}d.unlinkSync(n)}const o=c.engine.daemonLogFile;const t=d.openSync(o,"a");const e={...process.env};if(process.versions.electron){e.ELECTRON_RUN_AS_NODE="1"}const s=(0,F.spawn)(process.execPath,[__filename,"daemon","--foreground"],{detached:true,stdio:["ignore",t,t],cwd:(0,c.getProjectRoot)(),env:e});d.writeFileSync(n,String(s.pid));s.unref();console.log(`[WBS Daemon] Started (PID: ${s.pid})`);console.log(`[WBS Daemon] Log: ${o}`);return true}function N(){const n=c.engine.daemonPidFile;if(!d.existsSync(n)){console.error("[WBS Daemon] Not running (no PID file)");return false}const o=parseInt(d.readFileSync(n,"utf8").trim(),10);if(!c.engine.isProcessAlive(o)){console.log("[WBS Daemon] Process not found, cleaning up PID file");d.unlinkSync(n);return true}try{process.kill(o,"SIGTERM");d.unlinkSync(n);console.log(`[WBS Daemon] Stopped (PID: ${o})`);return true}catch(t){console.error(`[WBS Daemon] Failed to stop: ${t.message}`);return false}}function z(n){const o=n[0];switch(o){case"start":J();break;case"stop":N();break;case"status":{const t=c.engine.daemonPidFile;if(!d.existsSync(t)){const e={running:false,message:"Not running"};console.log(f(n)?JSON.stringify(e):`[WBS Daemon] Not running`)}else{const e=parseInt(d.readFileSync(t,"utf8").trim(),10);const s=c.engine.isProcessAlive(e);const i=s?{running:true,pid:e,message:`Running (PID: ${e})`}:{running:false,pid:e,message:"Stale PID file (process dead)"};console.log(f(n)?JSON.stringify(i,null,2):`[WBS Daemon] ${i.message}`)}break}case"restart":N();setTimeout(()=>J(),1e3);break;case"--foreground":{console.log(`[WBS Daemon] Starting in foreground mode`);console.log(`[WBS Daemon] Interval: ${c.DAEMON_INTERVAL_MS/1e3/60} minutes`);console.log(`[WBS Daemon] Zombie timeout: ${c.ZOMBIE_TIMEOUT_MS/1e3/60} minutes`);console.log(`[WBS Daemon] Press Ctrl+C to stop
57
+ `);k();setInterval(k,c.DAEMON_INTERVAL_MS);break}case"tick":k();break;default:console.log(`
589
58
  Daemon Commands - Background scheduler for WBS
590
59
 
591
60
  Usage:
@@ -594,21 +63,8 @@ Usage:
594
63
  wbs daemon status Check daemon status
595
64
  wbs daemon restart Restart daemon
596
65
  wbs daemon tick Manual tick (for testing)
597
- `);
598
- }
599
- }
600
- function showDetailedUsage() {
601
- const skillMd = path.join(__dirname, '..', 'SKILL.md');
602
- if (fs.existsSync(skillMd)) {
603
- process.stdout.write(fs.readFileSync(skillMd, 'utf-8'));
604
- }
605
- else {
606
- showHelp();
607
- }
608
- }
609
- function showHelp() {
610
- console.log(`
611
- @crewx/wbs@${PKG_VERSION} - Work Breakdown Structure for AI agent teams
66
+ `)}}function Q(){const n=w.join(__dirname,"..","SKILL.md");if(d.existsSync(n)){process.stdout.write(d.readFileSync(n,"utf-8"))}else{y()}}function y(){console.log(`
67
+ @crewx/wbs@${_} - Work Breakdown Structure for AI agent teams
612
68
 
613
69
  Usage:
614
70
  wbs <command> [options]
@@ -652,102 +108,17 @@ Examples:
652
108
  wbs job run wbs-1
653
109
 
654
110
  For detailed usage guide: wbs usage
655
- `);
656
- }
657
- async function main(inputArgs) {
658
- const args = inputArgs ?? process.argv.slice(2);
659
- const command = args[0];
660
- if (command === '--version') {
661
- console.log(PKG_VERSION);
662
- return;
663
- }
664
- switch (command) {
665
- case 'create': {
666
- const title = args[1];
667
- if (!title) {
668
- console.error('Usage: wbs create "Project Title" [--detail "path"] [--source "branch"] [--target "branch"]');
669
- process.exit(1);
670
- }
671
- const opts = parseOpts(args, 2);
672
- const detailOpt = opts.detail ?? null;
673
- const sourceBranchOpt = opts.source || undefined;
674
- const targetBranchOpt = opts.target || undefined;
675
- const id = engine_1.engine.create(title, detailOpt, sourceBranchOpt, targetBranchOpt);
676
- let detailPath = detailOpt;
677
- if (!detailPath) {
678
- const detailsDir = path.join(process.cwd(), 'wbs-details');
679
- if (!fs.existsSync(detailsDir))
680
- fs.mkdirSync(detailsDir, { recursive: true });
681
- detailPath = `wbs-details/${id}-detail.md`;
682
- const detailFile = path.join(process.cwd(), detailPath);
683
- fs.writeFileSync(detailFile, `# ${title}\n\n## Overview\n\n(Describe the project.)\n\n## Requirements\n\n(Write the requirements.)\n\n## References\n\n(Add reference links or notes.)\n`);
684
- engine_1.engine.updateDetailPath(id, detailPath);
685
- }
686
- console.log(JSON.stringify({ id, title, detailPath }, null, 2));
687
- break;
688
- }
689
- case 'list': {
690
- const projects = engine_1.engine.list();
691
- console.log(hasJson(args) ? JSON.stringify(projects, null, 2) : fmtProjectList(projects));
692
- break;
693
- }
694
- case 'status': {
695
- const wbsId = args[1];
696
- if (!wbsId) {
697
- console.error('Usage: wbs status <wbs-id> [--json]');
698
- process.exit(1);
699
- }
700
- const result = engine_1.engine.status(wbsId);
701
- if (result.project) {
702
- const pending = result.jobs.filter(j => j.status === 'pending').length;
703
- const running = result.jobs.filter(j => j.status === 'running').length;
704
- const completed = result.jobs.filter(j => j.status === 'completed').length;
705
- const failed = result.jobs.filter(j => j.status === 'failed').length;
706
- result.summary = {
707
- total: result.jobs.length, pending, running, completed, failed,
708
- progress: result.jobs.length > 0 ? Math.round((completed / result.jobs.length) * 100) : 0,
709
- };
710
- }
711
- console.log(hasJson(args) ? JSON.stringify(result, null, 2) : fmtStatus(result));
712
- break;
713
- }
714
- case 'delete': {
715
- const wbsId = args[1];
716
- if (!wbsId) {
717
- console.error('Usage: wbs delete <wbs-id>');
718
- process.exit(1);
719
- }
720
- engine_1.engine.delete(wbsId);
721
- console.log(`Deleted: ${wbsId}`);
722
- break;
723
- }
724
- case 'help':
725
- showHelp();
726
- break;
727
- case 'usage':
728
- showDetailedUsage();
729
- break;
730
- case 'job':
731
- handleJob(args.slice(1));
732
- break;
733
- case 'exec':
734
- handleExec(args.slice(1));
735
- break;
736
- case 'daemon':
737
- handleDaemon(args.slice(1));
738
- break;
739
- default: showHelp();
740
- }
741
- }
742
- if (require.main === module) {
743
- const _args = process.argv.slice(2);
744
- const _isDaemonForeground = _args[0] === 'daemon' && _args.includes('--foreground');
745
- (_isDaemonForeground ? Promise.resolve(null) : loadTracer()).then(tracer => {
746
- const opts = tracer ? { skillVersion: tracer.getOwnSkillVersion(__dirname) } : {};
747
- return tracer ? tracer.run('crewx/wbs', () => main(), opts) : main();
748
- }).catch((e) => {
749
- console.error(e.message);
750
- process.exit(1);
751
- });
752
- }
753
- //# sourceMappingURL=cli.js.map
111
+ `)}async function I(n){const o=n??process.argv.slice(2);const t=o[0];if(t==="--version"){console.log(_);return}switch(t){case"create":{const e=o[1];if(!e){console.error('Usage: wbs create "Project Title" [--detail "path"] [--source "branch"] [--target "branch"]');process.exit(1)}const s=D(o,2);const i=s.detail??null;const r=s.source||void 0;const a=s.target||void 0;const u=c.engine.create(e,i,r,a);let l=i;if(!l){const g=w.join(process.cwd(),"wbs-details");if(!d.existsSync(g))d.mkdirSync(g,{recursive:true});l=`wbs-details/${u}-detail.md`;const S=w.join(process.cwd(),l);d.writeFileSync(S,`# ${e}
112
+
113
+ ## Overview
114
+
115
+ (Describe the project.)
116
+
117
+ ## Requirements
118
+
119
+ (Write the requirements.)
120
+
121
+ ## References
122
+
123
+ (Add reference links or notes.)
124
+ `);c.engine.updateDetailPath(u,l)}console.log(JSON.stringify({id:u,title:e,detailPath:l},null,2));break}case"list":{const e=c.engine.list();console.log(f(o)?JSON.stringify(e,null,2):U(e));break}case"status":{const e=o[1];if(!e){console.error("Usage: wbs status <wbs-id> [--json]");process.exit(1)}const s=c.engine.status(e);if(s.project){const i=s.jobs.filter(l=>l.status==="pending").length;const r=s.jobs.filter(l=>l.status==="running").length;const a=s.jobs.filter(l=>l.status==="completed").length;const u=s.jobs.filter(l=>l.status==="failed").length;s.summary={total:s.jobs.length,pending:i,running:r,completed:a,failed:u,progress:s.jobs.length>0?Math.round(a/s.jobs.length*100):0}}console.log(f(o)?JSON.stringify(s,null,2):T(s));break}case"delete":{const e=o[1];if(!e){console.error("Usage: wbs delete <wbs-id>");process.exit(1)}c.engine.delete(e);console.log(`Deleted: ${e}`);break}case"help":y();break;case"usage":Q();break;case"job":H(o.slice(1));break;case"exec":Z(o.slice(1));break;case"daemon":z(o.slice(1));break;default:y()}}if(require.main===module){const n=process.argv.slice(2);const o=n[0]==="daemon"&&n.includes("--foreground");(o?Promise.resolve(null):W()).then(t=>{const e=t?{skillVersion:t.getOwnSkillVersion(__dirname)}:{};return t?t.run("crewx/wbs",()=>I(),e):I()}).catch(t=>{console.error(t.message);process.exit(1)})}