@autocodeflow/cli 1.5.1 → 1.5.3

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.
@@ -1,56 +1,27 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.tasksCommand = void 0;
30
- const commander_1 = require("commander");
31
- const cli_table3_1 = __importDefault(require("cli-table3"));
32
- const chalk_1 = __importDefault(require("chalk"));
33
- const ora_1 = __importDefault(require("ora"));
34
- const axios_1 = __importDefault(require("axios"));
35
- const child_process_1 = require("child_process");
36
- const fs = __importStar(require("fs"));
37
- const path = __importStar(require("path"));
38
- const client_1 = require("../client");
1
+ import { Command, InvalidArgumentError } from 'commander';
2
+ import Table from 'cli-table3';
3
+ import chalk from 'chalk';
4
+ import ora from 'ora';
5
+ import axios from 'axios';
6
+ import { spawnSync } from 'child_process';
7
+ import * as fs from 'fs';
8
+ import * as path from 'path';
9
+ import { get, post, patch, del, formatApiError, ANALYZE_TIMEOUT_MS } from '../client.js';
39
10
  function statusColor(s) {
40
11
  if (s === 'success')
41
- return chalk_1.default.green(s);
12
+ return chalk.green(s);
42
13
  if (s === 'failed' || s === 'timeout' || s === 'killed')
43
- return chalk_1.default.red(s);
14
+ return chalk.red(s);
44
15
  if (s === 'running')
45
- return chalk_1.default.cyan(s);
16
+ return chalk.cyan(s);
46
17
  if (s === 'active')
47
- return chalk_1.default.green(s);
18
+ return chalk.green(s);
48
19
  if (s === 'paused')
49
- return chalk_1.default.yellow(s);
50
- return chalk_1.default.gray(s);
20
+ return chalk.yellow(s);
21
+ return chalk.gray(s);
51
22
  }
52
- function tasksCommand() {
53
- const cmd = new commander_1.Command('task').description('Manage tasks');
23
+ export function tasksCommand() {
24
+ const cmd = new Command('task').description('Manage tasks');
54
25
  // acf task list
55
26
  cmd.command('list')
56
27
  .description('List all tasks')
@@ -60,10 +31,10 @@ function tasksCommand() {
60
31
  .option('-n, --page-size <n>', 'Items per page', '20')
61
32
  .option('--json', 'Emit raw JSON (CI-consumable, no table)')
62
33
  .action(async (opts) => {
63
- const spinner = (0, ora_1.default)('Fetching tasks…').start();
34
+ const spinner = ora('Fetching tasks…').start();
64
35
  try {
65
36
  // ListTasksQueryDto has `name` (no `keyword`)
66
- const data = await (0, client_1.get)('/tasks', {
37
+ const data = await get('/tasks', {
67
38
  page: opts.page,
68
39
  pageSize: opts.pageSize,
69
40
  status: opts.status,
@@ -75,7 +46,7 @@ function tasksCommand() {
75
46
  console.log(JSON.stringify(data));
76
47
  return;
77
48
  }
78
- const table = new cli_table3_1.default({
49
+ const table = new Table({
79
50
  head: ['ID', 'Name', 'Runtime', 'Status', 'Cron'],
80
51
  colWidths: [14, 30, 12, 10, 20],
81
52
  style: { head: ['cyan'] },
@@ -84,11 +55,11 @@ function tasksCommand() {
84
55
  table.push([t.id.slice(0, 12), t.name, t.runtime, statusColor(t.status), t.cronExpression ?? '-']);
85
56
  }
86
57
  console.log(table.toString());
87
- console.log(chalk_1.default.gray(`Total: ${data.total} page ${data.page}/${Math.ceil(data.total / data.pageSize)}`));
58
+ console.log(chalk.gray(`Total: ${data.total} page ${data.page}/${Math.ceil(data.total / data.pageSize)}`));
88
59
  }
89
60
  catch (e) {
90
61
  spinner.fail('Failed to list tasks');
91
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
62
+ console.error(chalk.red(formatApiError(e)));
92
63
  process.exit(1);
93
64
  }
94
65
  });
@@ -96,11 +67,11 @@ function tasksCommand() {
96
67
  cmd.command('get <id>')
97
68
  .description('Show task details')
98
69
  .action(async (id) => {
99
- const spinner = (0, ora_1.default)('Fetching task…').start();
70
+ const spinner = ora('Fetching task…').start();
100
71
  try {
101
- const t = await (0, client_1.get)(`/tasks/${id}`);
72
+ const t = await get(`/tasks/${id}`);
102
73
  spinner.stop();
103
- console.log(chalk_1.default.bold('Task Details'));
74
+ console.log(chalk.bold('Task Details'));
104
75
  console.log(' ID :', t.id);
105
76
  console.log(' Name :', t.name);
106
77
  console.log(' Runtime :', t.runtime);
@@ -109,7 +80,7 @@ function tasksCommand() {
109
80
  }
110
81
  catch (e) {
111
82
  spinner.fail('Failed');
112
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
83
+ console.error(chalk.red(formatApiError(e)));
113
84
  process.exit(1);
114
85
  }
115
86
  });
@@ -123,7 +94,7 @@ function tasksCommand() {
123
94
  .option('--wait-timeout <seconds>', 'Max seconds to keep polling with --wait before giving up (default 600)', (v) => {
124
95
  const n = Number.parseInt(v, 10);
125
96
  if (!Number.isFinite(n) || n <= 0) {
126
- throw new commander_1.InvalidArgumentError('must be a positive integer (seconds)');
97
+ throw new InvalidArgumentError('must be a positive integer (seconds)');
127
98
  }
128
99
  return n;
129
100
  }, 600)
@@ -133,9 +104,9 @@ function tasksCommand() {
133
104
  // supported by the backend as a task-level field (tasks.executorId) — set
134
105
  // it via `acf task create/update --executor <id>`, not per run.
135
106
  .action(async (id, opts) => {
136
- const spinner = (0, ora_1.default)('Triggering task…').start();
107
+ const spinner = ora('Triggering task…').start();
137
108
  try {
138
- const exec = await (0, client_1.post)(`/tasks/${id}/trigger`);
109
+ const exec = await post(`/tasks/${id}/trigger`);
139
110
  spinner.succeed(`Execution started: ${exec.id}`);
140
111
  if (opts.wait) {
141
112
  await pollExecution(exec.id, opts.waitTimeout);
@@ -143,7 +114,7 @@ function tasksCommand() {
143
114
  }
144
115
  catch (e) {
145
116
  spinner.fail('Failed to trigger');
146
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
117
+ console.error(chalk.red(formatApiError(e)));
147
118
  process.exit(1);
148
119
  }
149
120
  });
@@ -152,16 +123,16 @@ function tasksCommand() {
152
123
  .description('List recent executions for a task')
153
124
  .option('-n, --limit <n>', 'Number of results', '10')
154
125
  .action(async (id, opts) => {
155
- const spinner = (0, ora_1.default)('Fetching executions…').start();
126
+ const spinner = ora('Fetching executions…').start();
156
127
  try {
157
128
  // 后端 PaginationDto 只认 page/pageSize——不发送 `limit`,
158
129
  // 否则开启 forbidNonWhitelisted 后必然 400(N7/N10)。
159
- const data = await (0, client_1.get)(`/tasks/${id}/executions`, {
130
+ const data = await get(`/tasks/${id}/executions`, {
160
131
  pageSize: opts.limit,
161
132
  page: 1,
162
133
  });
163
134
  spinner.stop();
164
- const table = new cli_table3_1.default({
135
+ const table = new Table({
165
136
  // U11: exitCode column — distinguishes "failed by callback
166
137
  // report" (exit 0 / null) from "process died" (non-zero).
167
138
  head: ['Exec ID', 'Status', 'Duration', 'Exit', 'Started'],
@@ -181,7 +152,7 @@ function tasksCommand() {
181
152
  }
182
153
  catch (e) {
183
154
  spinner.fail('Failed');
184
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
155
+ console.error(chalk.red(formatApiError(e)));
185
156
  process.exit(1);
186
157
  }
187
158
  });
@@ -192,38 +163,38 @@ function tasksCommand() {
192
163
  .option('-n, --limit <n>', 'Max lines to fetch (max 2000)', '200')
193
164
  .option('--tail <n>', 'Show last N lines (overrides --from-line)')
194
165
  .action(async (execId, opts) => {
195
- const spinner = (0, ora_1.default)('Fetching logs…').start();
166
+ const spinner = ora('Fetching logs…').start();
196
167
  try {
197
168
  if (opts.tail) {
198
169
  const tail = Math.max(1, parseInt(opts.tail, 10) || 50);
199
- const head = await (0, client_1.get)(`/tasks/executions/${execId}/logs`, {
170
+ const head = await get(`/tasks/executions/${execId}/logs`, {
200
171
  fromLine: 0,
201
172
  limit: 1,
202
173
  });
203
174
  const from = Math.max(0, head.totalLines - tail);
204
- const data = await (0, client_1.get)(`/tasks/executions/${execId}/logs`, { fromLine: from, limit: tail });
175
+ const data = await get(`/tasks/executions/${execId}/logs`, { fromLine: from, limit: tail });
205
176
  spinner.stop();
206
177
  for (const l of data.lines ?? [])
207
178
  console.log(l);
208
- console.log(chalk_1.default.gray(`\n(${data.lines?.length ?? 0}/${data.totalLines} lines — last ${tail})`));
179
+ console.log(chalk.gray(`\n(${data.lines?.length ?? 0}/${data.totalLines} lines — last ${tail})`));
209
180
  }
210
181
  else {
211
182
  const fromLine = parseInt(opts.fromLine, 10) || 0;
212
- const data = await (0, client_1.get)(`/tasks/executions/${execId}/logs`, { fromLine, limit: opts.limit });
183
+ const data = await get(`/tasks/executions/${execId}/logs`, { fromLine, limit: opts.limit });
213
184
  spinner.stop();
214
185
  for (const l of data.lines ?? [])
215
186
  console.log(l);
216
187
  if (data.hasMore) {
217
- console.log(chalk_1.default.gray(`\n… hasMore — next: acf task logs ${execId} --from-line ${fromLine + (data.lines?.length ?? 0)}`));
188
+ console.log(chalk.gray(`\n… hasMore — next: acf task logs ${execId} --from-line ${fromLine + (data.lines?.length ?? 0)}`));
218
189
  }
219
190
  else {
220
- console.log(chalk_1.default.gray(`\n(${data.totalLines} lines total)`));
191
+ console.log(chalk.gray(`\n(${data.totalLines} lines total)`));
221
192
  }
222
193
  }
223
194
  }
224
195
  catch (e) {
225
196
  spinner.fail('Failed to fetch logs');
226
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
197
+ console.error(chalk.red(formatApiError(e)));
227
198
  process.exit(1);
228
199
  }
229
200
  });
@@ -231,18 +202,18 @@ function tasksCommand() {
231
202
  cmd.command('analyze <taskId> <execId>')
232
203
  .description('Run AI analysis on a failed execution')
233
204
  .action(async (taskId, execId) => {
234
- const spinner = (0, ora_1.default)('Running AI analysis…').start();
205
+ const spinner = ora('Running AI analysis…').start();
235
206
  try {
236
207
  // NETOPT-6④:同步 AI 端点(服务端预算 60s×2)用 120s per-call 覆盖,
237
208
  // 否则默认 30s 结构性小于服务端预算,AI 跑满预算成功返回时 CLI 已超时。
238
- const result = await (0, client_1.post)(`/tasks/${taskId}/executions/${execId}/analyze`, undefined, client_1.ANALYZE_TIMEOUT_MS);
209
+ const result = await post(`/tasks/${taskId}/executions/${execId}/analyze`, undefined, ANALYZE_TIMEOUT_MS);
239
210
  spinner.stop();
240
- console.log(chalk_1.default.bold('\nAI Analysis'));
211
+ console.log(chalk.bold('\nAI Analysis'));
241
212
  console.log(result.aiAnalysis || 'No analysis available (AI not configured).');
242
213
  }
243
214
  catch (e) {
244
215
  spinner.fail('Analysis failed');
245
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
216
+ console.error(chalk.red(formatApiError(e)));
246
217
  process.exit(1);
247
218
  }
248
219
  });
@@ -250,20 +221,20 @@ function tasksCommand() {
250
221
  cmd.command('suggest-schedule <id>')
251
222
  .description('Ask AI to suggest an optimal cron schedule')
252
223
  .action(async (id) => {
253
- const spinner = (0, ora_1.default)('Asking AI for schedule suggestion…').start();
224
+ const spinner = ora('Asking AI for schedule suggestion…').start();
254
225
  try {
255
226
  // NETOPT-6④:同上——suggest-schedule 也是同步 AI 端点。
256
- const result = await (0, client_1.post)(`/tasks/${id}/suggest-schedule`, undefined, client_1.ANALYZE_TIMEOUT_MS);
227
+ const result = await post(`/tasks/${id}/suggest-schedule`, undefined, ANALYZE_TIMEOUT_MS);
257
228
  spinner.stop();
258
- console.log(chalk_1.default.bold('Schedule Suggestion'));
229
+ console.log(chalk.bold('Schedule Suggestion'));
259
230
  console.log(' Current :', result.currentCron ?? '(none)');
260
- console.log(' Suggested :', chalk_1.default.green(result.suggestedCron));
231
+ console.log(' Suggested :', chalk.green(result.suggestedCron));
261
232
  console.log('\nReasoning:');
262
233
  console.log(result.reasoning);
263
234
  }
264
235
  catch (e) {
265
236
  spinner.fail('Failed');
266
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
237
+ console.error(chalk.red(formatApiError(e)));
267
238
  process.exit(1);
268
239
  }
269
240
  });
@@ -271,18 +242,18 @@ function tasksCommand() {
271
242
  cmd.command('stats <id>')
272
243
  .description('Show execution statistics for a task')
273
244
  .action(async (id) => {
274
- const spinner = (0, ora_1.default)('Fetching stats…').start();
245
+ const spinner = ora('Fetching stats…').start();
275
246
  try {
276
- const s = await (0, client_1.get)(`/tasks/${id}/stats`);
247
+ const s = await get(`/tasks/${id}/stats`);
277
248
  spinner.stop();
278
- console.log(chalk_1.default.bold('Execution Stats'));
279
- console.log(` Success rate : ${chalk_1.default.green(s.successRate + '%')}`);
249
+ console.log(chalk.bold('Execution Stats'));
250
+ console.log(` Success rate : ${chalk.green(s.successRate + '%')}`);
280
251
  console.log(` Avg duration : ${s.avgDuration}ms`);
281
252
  console.log(` Total runs : ${s.totalRuns}`);
282
253
  }
283
254
  catch (e) {
284
255
  spinner.fail('Failed');
285
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
256
+ console.error(chalk.red(formatApiError(e)));
286
257
  process.exit(1);
287
258
  }
288
259
  });
@@ -290,11 +261,11 @@ function tasksCommand() {
290
261
  cmd.command('versions <id>')
291
262
  .description('List historical versions of a task')
292
263
  .action(async (id) => {
293
- const spinner = (0, ora_1.default)('Fetching task versions…').start();
264
+ const spinner = ora('Fetching task versions…').start();
294
265
  try {
295
- const versions = await (0, client_1.get)(`/tasks/${id}/versions`);
266
+ const versions = await get(`/tasks/${id}/versions`);
296
267
  spinner.stop();
297
- const table = new cli_table3_1.default({
268
+ const table = new Table({
298
269
  head: ['Version', 'Commit', 'Created By', 'Created', 'Description'],
299
270
  colWidths: [12, 14, 16, 25, 30],
300
271
  style: { head: ['cyan'] },
@@ -312,7 +283,7 @@ function tasksCommand() {
312
283
  }
313
284
  catch (e) {
314
285
  spinner.fail('Failed to list versions');
315
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
286
+ console.error(chalk.red(formatApiError(e)));
316
287
  process.exit(1);
317
288
  }
318
289
  });
@@ -321,15 +292,15 @@ function tasksCommand() {
321
292
  .description('Roll a task back to a specific historical version snapshot')
322
293
  .requiredOption('--version <versionId>', 'Version ID to roll back to (see: acf task versions <id>)')
323
294
  .action(async (id, opts) => {
324
- const spinner = (0, ora_1.default)('Rolling back task…').start();
295
+ const spinner = ora('Rolling back task…').start();
325
296
  try {
326
- const t = await (0, client_1.post)(`/tasks/${id}/versions/${opts.version}/rollback`);
297
+ const t = await post(`/tasks/${id}/versions/${opts.version}/rollback`);
327
298
  spinner.succeed(`Task rolled back: ${t.id}`);
328
- console.log(chalk_1.default.gray(` name: ${t.name} status: ${statusColor(t.status)}`));
299
+ console.log(chalk.gray(` name: ${t.name} status: ${statusColor(t.status)}`));
329
300
  }
330
301
  catch (e) {
331
302
  spinner.fail('Failed to roll back');
332
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
303
+ console.error(chalk.red(formatApiError(e)));
333
304
  process.exit(1);
334
305
  }
335
306
  });
@@ -337,16 +308,16 @@ function tasksCommand() {
337
308
  cmd.command('compare <id> <versionId1> <versionId2>')
338
309
  .description('Diff two task versions (shows fields whose values differ)')
339
310
  .action(async (id, versionId1, versionId2) => {
340
- const spinner = (0, ora_1.default)('Comparing versions…').start();
311
+ const spinner = ora('Comparing versions…').start();
341
312
  try {
342
- const diff = await (0, client_1.get)(`/tasks/${id}/versions/${versionId1}/compare/${versionId2}`);
313
+ const diff = await get(`/tasks/${id}/versions/${versionId1}/compare/${versionId2}`);
343
314
  spinner.stop();
344
315
  const keys = Object.keys(diff ?? {});
345
316
  if (keys.length === 0) {
346
- console.log(chalk_1.default.green('No differences between the two versions.'));
317
+ console.log(chalk.green('No differences between the two versions.'));
347
318
  return;
348
319
  }
349
- const table = new cli_table3_1.default({
320
+ const table = new Table({
350
321
  head: ['Field', 'Version 1', 'Version 2'],
351
322
  colWidths: [24, 38, 38],
352
323
  style: { head: ['cyan'] },
@@ -363,7 +334,7 @@ function tasksCommand() {
363
334
  }
364
335
  catch (e) {
365
336
  spinner.fail('Failed to compare versions');
366
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
337
+ console.error(chalk.red(formatApiError(e)));
367
338
  process.exit(1);
368
339
  }
369
340
  });
@@ -374,9 +345,9 @@ function tasksCommand() {
374
345
  .option('--file <path>', 'Read task body from a JSON file (overrides --json)')
375
346
  .option('--executor <id>', 'Pin the task to a specific executor ID (uuid); mutually exclusive with executeMode=broadcast')
376
347
  .action(async (opts) => {
377
- const spinner = (0, ora_1.default)('Creating task…').start();
348
+ const spinner = ora('Creating task…').start();
378
349
  try {
379
- const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
350
+ const fs = await import('fs/promises');
380
351
  const raw = opts.file
381
352
  ? await fs.readFile(opts.file, 'utf-8')
382
353
  : opts.json;
@@ -384,13 +355,13 @@ function tasksCommand() {
384
355
  // R7 (N20): 显式 --executor 覆盖/补写 body.executorId(pinning)。
385
356
  if (opts.executor)
386
357
  body.executorId = opts.executor;
387
- const t = await (0, client_1.post)('/tasks', body);
358
+ const t = await post('/tasks', body);
388
359
  spinner.succeed(`Task created: ${t.id}`);
389
- console.log(chalk_1.default.gray(` name: ${t.name} status: ${statusColor(t.status)}`));
360
+ console.log(chalk.gray(` name: ${t.name} status: ${statusColor(t.status)}`));
390
361
  }
391
362
  catch (e) {
392
363
  spinner.fail('Failed to create task');
393
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
364
+ console.error(chalk.red(formatApiError(e)));
394
365
  process.exit(1);
395
366
  }
396
367
  });
@@ -401,9 +372,9 @@ function tasksCommand() {
401
372
  .option('--file <path>', 'Read task patch body from a JSON file (overrides --json)')
402
373
  .option('--executor <id>', 'Pin the task to a specific executor ID (uuid); pass --json {"executorId":null} to clear. Mutually exclusive with executeMode=broadcast')
403
374
  .action(async (id, opts) => {
404
- const spinner = (0, ora_1.default)('Updating task…').start();
375
+ const spinner = ora('Updating task…').start();
405
376
  try {
406
- const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
377
+ const fs = await import('fs/promises');
407
378
  const raw = opts.file
408
379
  ? await fs.readFile(opts.file, 'utf-8')
409
380
  : opts.json;
@@ -411,13 +382,13 @@ function tasksCommand() {
411
382
  // R7 (N20): 显式 --executor 覆盖/补写 body.executorId(pinning)。
412
383
  if (opts.executor)
413
384
  body.executorId = opts.executor;
414
- const t = await (0, client_1.patch)(`/tasks/${id}`, body);
385
+ const t = await patch(`/tasks/${id}`, body);
415
386
  spinner.succeed(`Task updated: ${t.id}`);
416
- console.log(chalk_1.default.gray(` name: ${t.name} status: ${statusColor(t.status)}`));
387
+ console.log(chalk.gray(` name: ${t.name} status: ${statusColor(t.status)}`));
417
388
  }
418
389
  catch (e) {
419
390
  spinner.fail('Failed to update task');
420
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
391
+ console.error(chalk.red(formatApiError(e)));
421
392
  process.exit(1);
422
393
  }
423
394
  });
@@ -427,23 +398,23 @@ function tasksCommand() {
427
398
  .option('-y, --yes', 'Skip confirmation prompt', false)
428
399
  .action(async (id, opts) => {
429
400
  if (!opts.yes) {
430
- const readline = await Promise.resolve().then(() => __importStar(require('readline/promises')));
401
+ const readline = await import('readline/promises');
431
402
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
432
403
  const answer = await rl.question(`Delete task ${id}? Running executions will be force-terminated. [y/N] `);
433
404
  rl.close();
434
405
  if (!/^y(es)?$/i.test(answer)) {
435
- console.log(chalk_1.default.yellow('Aborted.'));
406
+ console.log(chalk.yellow('Aborted.'));
436
407
  return;
437
408
  }
438
409
  }
439
- const spinner = (0, ora_1.default)('Deleting task…').start();
410
+ const spinner = ora('Deleting task…').start();
440
411
  try {
441
- await (0, client_1.del)(`/tasks/${id}`);
412
+ await del(`/tasks/${id}`);
442
413
  spinner.succeed(`Task ${id} deleted`);
443
414
  }
444
415
  catch (e) {
445
416
  spinner.fail('Failed to delete task');
446
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
417
+ console.error(chalk.red(formatApiError(e)));
447
418
  process.exit(1);
448
419
  }
449
420
  });
@@ -451,15 +422,15 @@ function tasksCommand() {
451
422
  cmd.command('pause <id>')
452
423
  .description('Pause task scheduled execution')
453
424
  .action(async (id) => {
454
- const spinner = (0, ora_1.default)('Pausing task…').start();
425
+ const spinner = ora('Pausing task…').start();
455
426
  try {
456
- const t = await (0, client_1.post)(`/tasks/${id}/pause`);
427
+ const t = await post(`/tasks/${id}/pause`);
457
428
  spinner.succeed(`Task ${id} paused`);
458
- console.log(chalk_1.default.gray(` status: ${statusColor(t.status)}`));
429
+ console.log(chalk.gray(` status: ${statusColor(t.status)}`));
459
430
  }
460
431
  catch (e) {
461
432
  spinner.fail('Failed to pause task');
462
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
433
+ console.error(chalk.red(formatApiError(e)));
463
434
  process.exit(1);
464
435
  }
465
436
  });
@@ -467,15 +438,15 @@ function tasksCommand() {
467
438
  cmd.command('resume <id>')
468
439
  .description('Resume task scheduled execution')
469
440
  .action(async (id) => {
470
- const spinner = (0, ora_1.default)('Resuming task…').start();
441
+ const spinner = ora('Resuming task…').start();
471
442
  try {
472
- const t = await (0, client_1.post)(`/tasks/${id}/resume`);
443
+ const t = await post(`/tasks/${id}/resume`);
473
444
  spinner.succeed(`Task ${id} resumed`);
474
- console.log(chalk_1.default.gray(` status: ${statusColor(t.status)}`));
445
+ console.log(chalk.gray(` status: ${statusColor(t.status)}`));
475
446
  }
476
447
  catch (e) {
477
448
  spinner.fail('Failed to resume task');
478
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
449
+ console.error(chalk.red(formatApiError(e)));
479
450
  process.exit(1);
480
451
  }
481
452
  });
@@ -483,14 +454,14 @@ function tasksCommand() {
483
454
  cmd.command('kill <taskId> <execId>')
484
455
  .description('Force-cancel a running or pending execution')
485
456
  .action(async (taskId, execId) => {
486
- const spinner = (0, ora_1.default)('Cancelling execution…').start();
457
+ const spinner = ora('Cancelling execution…').start();
487
458
  try {
488
- const r = await (0, client_1.post)(`/tasks/${taskId}/executions/${execId}/kill`);
459
+ const r = await post(`/tasks/${taskId}/executions/${execId}/kill`);
489
460
  spinner.succeed(r.message || 'Execution cancelled');
490
461
  }
491
462
  catch (e) {
492
463
  spinner.fail('Failed to cancel execution');
493
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
464
+ console.error(chalk.red(formatApiError(e)));
494
465
  process.exit(1);
495
466
  }
496
467
  });
@@ -506,7 +477,7 @@ function tasksCommand() {
506
477
  source = fs.readFileSync(file, 'utf-8');
507
478
  }
508
479
  catch {
509
- console.error(chalk_1.default.red(`Cannot read file: ${file}`));
480
+ console.error(chalk.red(`Cannot read file: ${file}`));
510
481
  process.exit(1);
511
482
  }
512
483
  const ext = path.extname(file).toLowerCase();
@@ -519,11 +490,11 @@ function tasksCommand() {
519
490
  ? 'shell'
520
491
  : undefined);
521
492
  if (!lang) {
522
- console.error(chalk_1.default.red(`Cannot infer language from extension "${ext}" — pass --language node|python|shell`));
493
+ console.error(chalk.red(`Cannot infer language from extension "${ext}" — pass --language node|python|shell`));
523
494
  process.exit(1);
524
495
  }
525
496
  const ok = (msg) => {
526
- console.log(chalk_1.default.green(`✔ ${file}: ${msg}`));
497
+ console.log(chalk.green(`✔ ${file}: ${msg}`));
527
498
  process.exit(0);
528
499
  };
529
500
  if (lang === 'node') {
@@ -534,35 +505,35 @@ function tasksCommand() {
534
505
  new Function(source);
535
506
  }
536
507
  catch (err) {
537
- console.error(chalk_1.default.red(`✗ ${file}: syntax error`));
538
- console.error(chalk_1.default.red(err instanceof Error ? err.message : String(err)));
508
+ console.error(chalk.red(`✗ ${file}: syntax error`));
509
+ console.error(chalk.red(err instanceof Error ? err.message : String(err)));
539
510
  process.exit(1);
540
511
  }
541
512
  ok('syntax OK (node)');
542
513
  }
543
514
  else if (lang === 'python') {
544
515
  const py = ['python3', 'python'].find((bin) => {
545
- const r = (0, child_process_1.spawnSync)(bin, ['--version'], { stdio: 'ignore' });
516
+ const r = spawnSync(bin, ['--version'], { stdio: 'ignore' });
546
517
  return r.status === 0;
547
518
  });
548
519
  if (!py) {
549
- console.error(chalk_1.default.red('python not found on PATH — install Python 3 to lint python glue'));
520
+ console.error(chalk.red('python not found on PATH — install Python 3 to lint python glue'));
550
521
  process.exit(1);
551
522
  }
552
- const r = (0, child_process_1.spawnSync)(py, ['-c', `import ast,sys; ast.parse(open(sys.argv[1],encoding='utf-8').read())`, file], {
523
+ const r = spawnSync(py, ['-c', `import ast,sys; ast.parse(open(sys.argv[1],encoding='utf-8').read())`, file], {
553
524
  stdio: 'pipe',
554
525
  });
555
526
  if (r.status !== 0) {
556
- console.error(chalk_1.default.red(`✗ ${file}: syntax error`));
527
+ console.error(chalk.red(`✗ ${file}: syntax error`));
557
528
  process.stderr.write(r.stderr?.toString() ?? '');
558
529
  process.exit(1);
559
530
  }
560
531
  ok('syntax OK (python, ast.parse)');
561
532
  }
562
533
  else {
563
- const r = (0, child_process_1.spawnSync)('bash', ['-n', file], { stdio: 'pipe' });
534
+ const r = spawnSync('bash', ['-n', file], { stdio: 'pipe' });
564
535
  if (r.status !== 0) {
565
- console.error(chalk_1.default.red(`✗ ${file}: syntax error`));
536
+ console.error(chalk.red(`✗ ${file}: syntax error`));
566
537
  process.stderr.write(r.stderr?.toString() ?? '');
567
538
  process.exit(1);
568
539
  }
@@ -571,16 +542,15 @@ function tasksCommand() {
571
542
  });
572
543
  return cmd;
573
544
  }
574
- exports.tasksCommand = tasksCommand;
575
545
  async function pollExecution(execId, waitTimeoutSeconds = 600) {
576
546
  const INTERVAL = 2000;
577
547
  const MAX_WAIT = waitTimeoutSeconds * 1000;
578
- const spinner = (0, ora_1.default)('Waiting for execution…').start();
548
+ const spinner = ora('Waiting for execution…').start();
579
549
  const start = Date.now();
580
550
  while (Date.now() - start < MAX_WAIT) {
581
551
  await sleep(INTERVAL);
582
552
  try {
583
- const exec = await (0, client_1.get)(`/tasks/executions/${execId}`);
553
+ const exec = await get(`/tasks/executions/${execId}`);
584
554
  // killed 是后端 ExecutionStatus 的合法终态(acf task kill / Web 端),
585
555
  // 遗漏会让 --wait 在被 kill 后空转到 MAX_WAIT 并误报超时(N10)。
586
556
  if (['success', 'failed', 'timeout', 'cancelled', 'killed'].includes(exec.status)) {
@@ -603,16 +573,16 @@ async function pollExecution(execId, waitTimeoutSeconds = 600) {
603
573
  // so a non-zero exit or timeout reason was invisible without
604
574
  // digging through `acf task logs`.
605
575
  if (exec.exitCode !== null && exec.exitCode !== undefined) {
606
- console.log(chalk_1.default.yellow(' Exit code :'), exec.exitCode);
576
+ console.log(chalk.yellow(' Exit code :'), exec.exitCode);
607
577
  }
608
578
  if (exec.failureReason) {
609
- console.log(chalk_1.default.yellow(' Failure reason :'), exec.failureReason);
579
+ console.log(chalk.yellow(' Failure reason :'), exec.failureReason);
610
580
  }
611
581
  if (exec.errorMessage) {
612
- console.log(chalk_1.default.yellow(' Error :'), exec.errorMessage);
582
+ console.log(chalk.yellow(' Error :'), exec.errorMessage);
613
583
  }
614
584
  if (exec.aiAnalysis) {
615
- console.log(chalk_1.default.yellow('\nAI Analysis:'), exec.aiAnalysis);
585
+ console.log(chalk.yellow('\nAI Analysis:'), exec.aiAnalysis);
616
586
  }
617
587
  }
618
588
  return;
@@ -622,10 +592,10 @@ async function pollExecution(execId, waitTimeoutSeconds = 600) {
622
592
  catch (e) {
623
593
  // 4xx(除 429)是确定性失败(token 失效/执行不存在等)——继续轮询只会
624
594
  // 空转到 MAX_WAIT 并误报超时,掩盖真实错误;立即退出并透出后端消息。
625
- const status = axios_1.default.isAxiosError(e) ? e.response?.status : undefined;
595
+ const status = axios.isAxiosError(e) ? e.response?.status : undefined;
626
596
  if (status && status >= 400 && status < 500 && status !== 429) {
627
597
  spinner.fail('Waiting for execution failed');
628
- console.error(chalk_1.default.red((0, client_1.formatApiError)(e)));
598
+ console.error(chalk.red(formatApiError(e)));
629
599
  process.exit(1);
630
600
  }
631
601
  // transient (network / 429 / 5xx), keep polling
@@ -637,7 +607,7 @@ async function pollExecution(execId, waitTimeoutSeconds = 600) {
637
607
  // 与上方失败终态的 CLI-EXIT-01 语义对齐:置 exitCode=1,并明示执行仍在
638
608
  // 运行、如何继续观察(exec tail)或放宽等待上限(--wait-timeout)。
639
609
  spinner.fail(`Timed out waiting for execution after ${waitTimeoutSeconds}s`);
640
- console.error(chalk_1.default.red(`The execution is still running — no terminal status within ${waitTimeoutSeconds}s. ` +
610
+ console.error(chalk.red(`The execution is still running — no terminal status within ${waitTimeoutSeconds}s. ` +
641
611
  `Follow it later with 'acf exec tail ${execId}' or raise --wait-timeout.`));
642
612
  process.exitCode = 1;
643
613
  }