@vzn/vx 0.0.638 → 0.0.639

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 (103) hide show
  1. package/docs/caching.md +44 -15
  2. package/docs/cli.md +168 -345
  3. package/docs/execution.md +18 -43
  4. package/docs/features.md +7 -10
  5. package/docs/patterns.md +5 -7
  6. package/docs/schema.md +47 -49
  7. package/package.json +5 -5
  8. package/schemas/last.json +7 -4
  9. package/skills/vx/SKILL.md +6 -4
  10. package/src/cache/cache.ts +40 -10
  11. package/src/cache/git-inputs.ts +6 -0
  12. package/src/cache/index.ts +2 -2
  13. package/src/cache/layer.ts +25 -11
  14. package/src/cache/layered-cache.ts +108 -315
  15. package/src/cache/plugin-cache.ts +2 -10
  16. package/src/cache/remote-lane.ts +383 -0
  17. package/src/cache/run-history.ts +24 -8
  18. package/src/cache/run-store.ts +4 -4
  19. package/src/cache/schema.ts +6 -4
  20. package/src/cache/scoped-cache.ts +7 -0
  21. package/src/cli/completions.ts +2 -2
  22. package/src/cli/foreign-flags.ts +10 -22
  23. package/src/cli/help.ts +6 -31
  24. package/src/cli/info.ts +2 -1
  25. package/src/cli/last.ts +6 -3
  26. package/src/cli/plan-format.ts +5 -58
  27. package/src/cli/plugin-commands.ts +2 -2
  28. package/src/cli/run.ts +23 -185
  29. package/src/cli/show.ts +6 -0
  30. package/src/cli/upgrade.ts +123 -39
  31. package/src/cli/watch-cycle.ts +2 -1
  32. package/src/cli/watch.ts +29 -14
  33. package/src/cli/why.ts +4 -4
  34. package/src/config.ts +0 -6
  35. package/src/exec/executor.ts +1 -1
  36. package/src/exec/sandbox-runtime.ts +1 -1
  37. package/src/exec/sandbox-violations.ts +3 -1
  38. package/src/graph/index.ts +9 -1
  39. package/src/graph/priorities.ts +1 -1
  40. package/src/graph/scheduler.ts +4 -16
  41. package/src/graph/task-graph.ts +87 -17
  42. package/src/graph/task-status.ts +95 -0
  43. package/src/{orchestrator → history}/failure-mode.ts +1 -1
  44. package/src/{orchestrator → history}/history.ts +1 -1
  45. package/src/history/index.ts +48 -0
  46. package/src/{orchestrator → history}/metrics.ts +7 -20
  47. package/src/{orchestrator → history}/miss-reason.ts +1 -1
  48. package/src/index.ts +10 -28
  49. package/src/orchestrator/doctor.ts +1 -1
  50. package/src/orchestrator/execute-args.ts +80 -0
  51. package/src/orchestrator/execute-task.ts +21 -386
  52. package/src/orchestrator/fingerprint-watch.ts +2 -2
  53. package/src/orchestrator/index.ts +1 -73
  54. package/src/orchestrator/miss-save.ts +33 -3
  55. package/src/orchestrator/options.ts +1 -36
  56. package/src/orchestrator/output-host.ts +4 -3
  57. package/src/orchestrator/persistent-task.ts +321 -0
  58. package/src/orchestrator/persistent.ts +130 -3
  59. package/src/orchestrator/placement.ts +3 -3
  60. package/src/orchestrator/plan.ts +18 -5
  61. package/src/orchestrator/plugin-host.ts +67 -47
  62. package/src/orchestrator/plugin.ts +6 -6
  63. package/src/orchestrator/prepare.ts +28 -29
  64. package/src/orchestrator/remote-prefetch.ts +14 -1
  65. package/src/orchestrator/run-artifacts.ts +5 -177
  66. package/src/orchestrator/run-context.ts +55 -0
  67. package/src/orchestrator/run-failures.ts +15 -3
  68. package/src/orchestrator/run-records.ts +35 -3
  69. package/src/orchestrator/run-report.ts +81 -179
  70. package/src/orchestrator/run-settings.ts +1 -16
  71. package/src/orchestrator/run-stop.ts +153 -0
  72. package/src/orchestrator/run.ts +260 -601
  73. package/src/orchestrator/sandbox-fix.ts +0 -16
  74. package/src/orchestrator/signals.ts +14 -6
  75. package/src/orchestrator/stable-keys.ts +107 -3
  76. package/src/orchestrator/steps.ts +50 -0
  77. package/src/orchestrator/task-hash.ts +3 -16
  78. package/src/orchestrator/task-log-buffer.ts +1 -1
  79. package/src/orchestrator/task-process.ts +94 -0
  80. package/src/orchestrator/telemetry-host.ts +1 -1
  81. package/src/orchestrator/telemetry.ts +5 -82
  82. package/src/{orchestrator → report}/events.ts +41 -8
  83. package/src/{orchestrator → report}/forecast.ts +35 -2
  84. package/src/{orchestrator → report}/framed-output.ts +39 -33
  85. package/src/report/index.ts +36 -0
  86. package/src/{orchestrator → report}/logger.ts +158 -20
  87. package/src/{orchestrator → report}/status-line.ts +84 -7
  88. package/src/{orchestrator → report}/summary.ts +126 -35
  89. package/src/report/tally.ts +83 -0
  90. package/src/settings.ts +1 -22
  91. package/src/util/colors.ts +44 -4
  92. package/src/util/git-ignored.ts +143 -0
  93. package/src/util/index.ts +19 -4
  94. package/src/util/report.ts +13 -5
  95. package/src/util/settle.ts +14 -39
  96. package/src/util/tail.ts +1 -1
  97. package/src/util/ui.ts +17 -6
  98. package/schemas/summary.json +0 -133
  99. package/src/cache/chained-cache.ts +0 -280
  100. package/src/orchestrator/tally.ts +0 -112
  101. /package/src/{orchestrator → report}/path-links.ts +0 -0
  102. /package/src/{orchestrator → report}/plain-output.ts +0 -0
  103. /package/src/{orchestrator → report}/terminal-signals.ts +0 -0
package/src/cli/help.ts CHANGED
@@ -171,12 +171,6 @@ export function helpText(pluginCommands: readonly string[] = []): string {
171
171
  " --timeout <duration> A task's time limit (30s, 10m), for tasks",
172
172
  ' without their own exec.timeout. A task past it',
173
173
  ' is killed and fails.',
174
- ' --kill-grace <duration> How long a task that ignores SIGTERM gets',
175
- ' before SIGKILL (default 2s).',
176
- " --teardown-timeout <duration> The bound on each plugin's end-of-run flush",
177
- ' (default 3s).',
178
- ' --ready-notice <duration> When vx says a persistent task still waits for',
179
- ' readyWhen (default 10s).',
180
174
  ' --continue[=<mode>] What a failed task takes down: never | deps-ok',
181
175
  ' (default, skips its dependents) | always (bare',
182
176
  ' form; dependents run, never save).',
@@ -190,18 +184,9 @@ export function helpText(pluginCommands: readonly string[] = []): string {
190
184
  'Planning (for run — skips execution):',
191
185
  " --dry[=text|json] Print the task graph and each task's predicted hit",
192
186
  ' or miss.',
193
- ' --graph[=<path>] Emit Graphviz DOT (stdout if no path).',
194
187
  '',
195
188
  'Artifacts (for run):',
196
- ' --format <fmt> pretty (default) | json: print the --summarize',
197
- ' document on stdout when the run ends; every other',
198
- ' line goes to stderr.',
199
- ' --summarize[=<path>] Write per-run JSON to <cacheDir>/runs/<run_id>.json.',
200
189
  ' --profile[=<path>] Write Chrome-trace JSON (default profile.json).',
201
- ' --report[=markdown] Print a markdown run report to stdout after the run.',
202
- ' --report-file <path> Append that report to <path> ($GITHUB_STEP_SUMMARY).',
203
- ' --tag <k=v> Label this invocation (repeatable); recorded on its',
204
- ' history row.',
205
190
  '',
206
191
  'Extensions (plugins):',
207
192
  ' vx core runs tasks in-process and nothing else. A dashboard, remote',
@@ -223,12 +208,11 @@ export function helpText(pluginCommands: readonly string[] = []): string {
223
208
  'Watch mode:',
224
209
  ' vx watch <task> Initial run, then re-run on filesystem changes.',
225
210
  ' Uses the same flags as `vx run` except --dry /',
226
- ' --graph / --summarize / --profile / --report /',
227
- ' --report-file / --verbosity (they plan or report',
228
- ' one run), plus --poll (watch.poll: poll instead of',
229
- ' the OS watcher). Press Ctrl+C to stop. Cache means most',
230
- ' re-runs are near-zero cost (cache hits restore',
231
- ' outputs + replay logs).',
211
+ ' --profile / --verbosity (they plan or report one',
212
+ ' run), plus --poll (watch.poll: poll instead of',
213
+ ' the OS watcher). Press Ctrl+C to stop.',
214
+ ' Cache means most re-runs are near-zero cost',
215
+ ' (cache hits restore outputs + replay logs).',
232
216
  '',
233
217
  'Cache management:',
234
218
  ' vx cache clean --older-than 30d Evict entries last accessed > 30 days ago.',
@@ -402,16 +386,7 @@ export function documentedFlags(verb: string, text = helpText()): string[] {
402
386
  * The `vx run` flags `vx watch` refuses: each plans or reports ONE run
403
387
  * (`watchRefusal` in watch.ts, held to this list by a test).
404
388
  */
405
- export const WATCH_REFUSED_FLAGS: readonly string[] = [
406
- '--dry',
407
- '--graph',
408
- '--summarize',
409
- '--profile',
410
- '--report',
411
- '--report-file',
412
- '--verbosity',
413
- '--format',
414
- ]
389
+ export const WATCH_REFUSED_FLAGS: readonly string[] = ['--dry', '--profile', '--verbosity']
415
390
 
416
391
  /**
417
392
  * The flags one verb accepts: those on its own Usage line, and for a verb
package/src/cli/info.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  // from the orchestrator's `collectInfo` (doctor.ts); this file parses the flags and renders the rows.
5
5
 
6
6
  import os from 'node:os'
7
- import { collectInfo, type FlakyTask, type InfoFacts } from '../orchestrator/index.js'
7
+ import { collectInfo, type InfoFacts } from '../orchestrator/index.js'
8
+ import { type FlakyTask } from '../history/index.js'
8
9
  import { flagHint, formatValue, refuse, refusedWord, seeHelp } from './help.js'
9
10
  import { namedCacheDir, parseCacheDirFlag, warnToStderr } from './workspace-config.js'
10
11
  import { formatBytes } from './format.js'
package/src/cli/last.ts CHANGED
@@ -9,21 +9,23 @@ import { Cache } from '../cache/index.js'
9
9
  import { formatBytes } from './format.js'
10
10
  import { flagHint, formatValue, seeHelp } from './help.js'
11
11
  import {
12
- currentBranch,
13
- exitSignal,
14
12
  type FailureMode,
15
13
  getInvocation,
16
14
  getRun,
17
15
  type InvocationDetail,
18
16
  listInvocations,
19
17
  LocalHistoryProvider,
20
- outcomeWord,
21
18
  type RunSummaryRow,
19
+ } from '../history/index.js'
20
+ import {
21
+ currentBranch,
22
+ exitSignal,
22
23
  resolveRunId,
23
24
  runFailures,
24
25
  shortRunId,
25
26
  taskLog,
26
27
  } from '../orchestrator/index.js'
28
+ import { outcomeWord } from '../report/index.js'
27
29
  import { formatElapsed, refusal, splitTaskId, UserError, sayNotice, ui } from '../util/index.js'
28
30
  import { findWorkspaceRoot } from '../workspace/index.js'
29
31
  import { cliCacheDir, parseCacheDirFlag } from './workspace-config.js'
@@ -319,6 +321,7 @@ function reasonParts(t: RunSummaryRow): string {
319
321
  } else if (t.status === 'skipped' && t.blockedBy !== null) {
320
322
  parts.push(`after ${t.blockedBy} failed`)
321
323
  }
324
+ if (t.remoteError !== null) parts.push(`remote \u2717 ${t.remoteError}`)
322
325
  return parts.map((p) => ` ${p}`).join('')
323
326
  }
324
327
 
@@ -1,4 +1,4 @@
1
- // Formatters for `--dry-run` (human / JSON) and `--graph` (DOT).
1
+ // Formatters for `--dry` (human / JSON).
2
2
 
3
3
  import type { AffectedReason, CacheStatus, RunPlan } from '../orchestrator/index.js'
4
4
  import { formatElapsed, maskedCommand } from '../util/index.js'
@@ -9,7 +9,7 @@ import { formatElapsed, maskedCommand } from '../util/index.js'
9
9
  * task with recorded history also shows its typical duration (~p50).
10
10
  *
11
11
  * would run:
12
- * ◉ @vzn/vx#lint cache hit (local) abc12345
12
+ * ✓ @vzn/vx#lint cache hit (local) abc12345
13
13
  * ↓ @vzn/vx#test cache hit (remote) def67890
14
14
  * ▶ @vzn/vx#build cache miss — would exec fedcba98 ~1.20s
15
15
  *
@@ -33,7 +33,7 @@ export function formatPlanText(plan: RunPlan): string {
33
33
  for (const t of real) {
34
34
  // `@noop`: the run succeeds it without running, whatever its key says.
35
35
  const skipped = t.executor === 'noop'
36
- const sym = skipped ? '∅' : symbolFor(t.cacheStatus)
36
+ const sym = skipped ? '·' : symbolFor(t.cacheStatus)
37
37
  const desc = skipped ? 'noop — would not run' : describe(t.cacheStatus)
38
38
  const shortHash = t.hash ? t.hash.slice(0, 8) : ''
39
39
  const executes = !skipped && (t.cacheStatus === 'miss' || t.cacheStatus === 'no-cache')
@@ -186,52 +186,16 @@ export function formatPlanJson(plan: RunPlan, affectedBase?: string): string {
186
186
  )
187
187
  }
188
188
 
189
- /**
190
- * Render the task graph as a Graphviz DOT document. Includes group
191
- * nodes — they're real nodes in the graph (just not real units of
192
- * work), and a `--graph` consumer wants to see the whole structure.
193
- *
194
- * Layout: `rankdir=LR`. Node fillcolor varies by predicted cache
195
- * status so a quick visual scan tells you which boxes get to skip
196
- * actual work.
197
- */
198
- export function formatGraphDot(plan: RunPlan): string {
199
- const lines: string[] = ['digraph TaskGraph {', ' rankdir=LR;', ' node [shape=box];']
200
- for (const t of plan.tasks) {
201
- const color = dotColor(t.cacheStatus)
202
- lines.push(
203
- ` ${dotString(t.node.id)} [label=${dotString(`${t.node.id}\n${t.hash.slice(0, 8)}`)}, style="filled", fillcolor="${color}"];`,
204
- )
205
- }
206
- for (const t of plan.tasks) {
207
- for (const dep of t.deps) {
208
- lines.push(` ${dotString(dep)} -> ${dotString(t.node.id)};`)
209
- }
210
- }
211
- lines.push('}')
212
- return lines.join('\n') + '\n'
213
- }
214
-
215
- /**
216
- * A DOT double-quoted ID. A task name is any object key in a config, so
217
- * `"`, `\` and a newline are all reachable; unescaped they end the
218
- * string early and the document stops parsing. `\n` is DOT's own line
219
- * break inside a label.
220
- */
221
- function dotString(s: string): string {
222
- return `"${s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\r?\n/g, '\\n')}"`
223
- }
224
-
225
189
  function symbolFor(s: CacheStatus): string {
226
190
  switch (s) {
227
191
  case 'hit-local':
228
- return '◉'
192
+ return '✓'
229
193
  case 'hit-remote':
230
194
  return '↓'
231
195
  case 'miss':
232
196
  return '▶'
233
197
  case 'no-cache':
234
- return '·'
198
+ return '∅'
235
199
  case 'group':
236
200
  return '○'
237
201
  case 'not-started':
@@ -255,20 +219,3 @@ function describe(s: CacheStatus): string {
255
219
  return 'not started (unneeded)'
256
220
  }
257
221
  }
258
-
259
- function dotColor(s: CacheStatus): string {
260
- switch (s) {
261
- case 'hit-local':
262
- return '#bbf7d0' // green-200
263
- case 'hit-remote':
264
- return '#bae6fd' // sky-200
265
- case 'miss':
266
- return '#fed7aa' // orange-200
267
- case 'no-cache':
268
- return '#e5e7eb' // gray-200
269
- case 'group':
270
- return '#f5d0fe' // fuchsia-200
271
- case 'not-started':
272
- return '#ffffff'
273
- }
274
- }
@@ -7,7 +7,7 @@
7
7
  // reports an unknown command as it always did. Core's verbs are matched
8
8
  // before this is asked, so a plugin cannot shadow `run`.
9
9
 
10
- import type { CachePolicy, PluginCache, PluginCacheRemote } from '../cache/index.js'
10
+ import type { CachePolicy, PluginCache, ResolvedRemote } from '../cache/index.js'
11
11
  import type { WorkspaceConfig } from '../config.js'
12
12
  import type { VxPlugin, PluginCommand, CommandContext } from '../orchestrator/index.js'
13
13
  import { cacheScopeEnvError, findWorkspaceRoot, isCacheScope } from '../workspace/index.js'
@@ -151,7 +151,7 @@ async function verbCache(
151
151
  'open',
152
152
  await ws.storeRoot,
153
153
  )
154
- const remotes: PluginCacheRemote[] = []
154
+ const remotes: ResolvedRemote[] = []
155
155
  await resolveCache(ws.plugins, {
156
156
  workspaceRoot: ws.workspaceRoot,
157
157
  cacheDir: ws.cacheDir,
package/src/cli/run.ts CHANGED
@@ -1,18 +1,14 @@
1
- import { appendFileSync, mkdirSync } from 'node:fs'
2
- import path from 'node:path'
3
1
  import { isatty } from 'node:tty'
4
2
  import { cacheScopeError, findWorkspaceRoot, isCacheScope } from '../workspace/index.js'
5
3
  import { translateForeign } from './foreign-flags.js'
6
- import { flagHint, formatValue, refuse, seeHelp } from './help.js'
4
+ import { flagHint, refuse, seeHelp } from './help.js'
7
5
  import {
8
6
  planRun,
9
- formatRunReportMarkdown,
10
- projectOutcome,
11
7
  run as runOrchestrator,
12
8
  shellQuote,
13
9
  type RunOptions,
14
10
  } from '../orchestrator/index.js'
15
- import type { ContinueMode, TaskOutcome } from '../graph/index.js'
11
+ import type { ContinueMode } from '../graph/index.js'
16
12
  import {
17
13
  applyCacheFlags,
18
14
  type CacheFlags,
@@ -25,7 +21,7 @@ import { affectedFilterFor, findCwdSelection, pickTask, resolveFilters } from '.
25
21
  import { nxTargetHint, taskNamesHere } from './task-verb.js'
26
22
  import { parseDecimalInt, sayNotice, sayLine } from '../util/index.js'
27
23
  import { kindHint, parseSettingValue, type Setting, SETTINGS, settingRefusal } from '../settings.js'
28
- import { formatGraphDot, formatPlanJson, formatPlanText } from './plan-format.js'
24
+ import { formatPlanJson, formatPlanText } from './plan-format.js'
29
25
 
30
26
  export interface RunArgs {
31
27
  /** Failure propagation (`--continue[=never|deps-ok|always]`). */
@@ -71,10 +67,6 @@ export interface RunArgs {
71
67
  forwardArgs: string[]
72
68
  verbosity: number
73
69
  dry: 'text' | 'json' | undefined
74
- /** `--format json`: the run's result document on stdout, every other line on stderr. */
75
- format: 'pretty' | 'json'
76
- graph: string | undefined
77
- summarize: string | undefined
78
70
  profile: string | undefined
79
71
  /**
80
72
  * `--affected[=<base>]`. When undefined the flag wasn't passed.
@@ -82,16 +74,6 @@ export interface RunArgs {
82
74
  * `defaultAffectedBase`). Any other string is an explicit git ref.
83
75
  */
84
76
  affected: string | undefined
85
- /** `--tag k=v` pairs (repeatable). Empty key is a parse error. */
86
- tags: Record<string, string>
87
- /** `--report[=markdown]`. Undefined when the flag wasn't passed. */
88
- report: 'markdown' | undefined
89
- /**
90
- * `--report-file=<path>`. Undefined when the flag wasn't passed. Writes
91
- * the same markdown as `--report`, but to a file — because redirecting
92
- * vx's stdout captures the whole run log, not just the report.
93
- */
94
- reportFile: string | undefined
95
77
  error?: string
96
78
  }
97
79
 
@@ -130,9 +112,6 @@ const SETTING_OPTIONS = [
130
112
  ['run.timeout', 'timeout'],
131
113
  ['run.retries', 'retries'],
132
114
  ['run.outputLogs', 'outputLogs'],
133
- ['run.killGrace', 'killGrace'],
134
- ['run.teardownTimeout', 'teardownTimeout'],
135
- ['run.readyNotice', 'readyNotice'],
136
115
  ['cache.download', 'download'],
137
116
  ] as const satisfies readonly (readonly [string, keyof RunOptions])[]
138
117
 
@@ -150,14 +129,8 @@ export function parseRunArgs(rawArgs: readonly string[], verb: 'run' | 'watch' =
150
129
  forwardArgs: [],
151
130
  verbosity: 0,
152
131
  dry: undefined,
153
- format: 'pretty',
154
- graph: undefined,
155
- summarize: undefined,
156
132
  profile: undefined,
157
133
  affected: undefined,
158
- tags: {},
159
- report: undefined,
160
- reportFile: undefined,
161
134
  }
162
135
 
163
136
  // A Turbo or Nx spelling becomes vx's, or a refusal naming vx's.
@@ -301,58 +274,18 @@ export function parseRunArgs(rawArgs: readonly string[], verb: 'run' | 'watch' =
301
274
  return { ...out, error: `--dry must be text or json (got ${fmt})` }
302
275
  }
303
276
  out.dry = fmt
304
- } else if (a === '--format' || a?.startsWith('--format=')) {
305
- const f = formatValue(a === '--format' ? before[++i] : a.slice('--format='.length), verb)
306
- if (typeof f !== 'string') return { ...out, error: f.error }
307
- out.format = f
308
- } else if (a === '--graph') {
309
- out.graph = ''
310
- } else if (a?.startsWith('--graph=')) {
311
- out.graph = a.slice('--graph='.length)
312
- } else if (a === '--summarize') {
313
- out.summarize = ''
314
- } else if (a?.startsWith('--summarize=')) {
315
- out.summarize = a.slice('--summarize='.length)
316
277
  } else if (a === '--profile') {
317
278
  out.profile = 'profile.json'
318
279
  } else if (a?.startsWith('--profile=')) {
319
280
  // An optional-value flag: an empty `=` means "no value given", so it
320
281
  // takes the same documented default as the bare form. Resolving ''
321
282
  // against cwd would name the cwd DIRECTORY and die with EISDIR after
322
- // the whole run — and `--summarize=` already degrades to its default.
283
+ // the whole run.
323
284
  out.profile = a.slice('--profile='.length) || 'profile.json'
324
285
  } else if (a === '--affected') {
325
286
  out.affected = ''
326
287
  } else if (a?.startsWith('--affected=')) {
327
288
  out.affected = a.slice('--affected='.length)
328
- } else if (a === '--tag' || a?.startsWith('--tag=')) {
329
- const raw = a === '--tag' ? before[++i] : a.slice('--tag='.length)
330
- if (raw === undefined) return { ...out, error: `${a} requires a value (k=v)` }
331
- // Split on the FIRST `=` so values may contain `=` (e.g. a URL).
332
- const eq = raw.indexOf('=')
333
- if (eq <= 0) return { ...out, error: `--tag must be k=v (got ${raw})` }
334
- out.tags[raw.slice(0, eq)] = raw.slice(eq + 1)
335
- } else if (a === '--report-file' || a?.startsWith('--report-file=')) {
336
- const v = a === '--report-file' ? before[++i] : a.slice('--report-file='.length)
337
- if (v === undefined || v === '') return { ...out, error: `--report-file requires a path` }
338
- // Same reasoning as --cache-dir: a path is an arbitrary string, so
339
- // nothing about its shape rejects a swallowed flag. A path starting
340
- // with `-` needs the `=` form.
341
- if (a === '--report-file' && v.startsWith('-')) {
342
- return {
343
- ...out,
344
- error: `--report-file requires a path (got flag ${v}; a path that starts with - needs --report-file=${v})`,
345
- }
346
- }
347
- out.reportFile = v
348
- } else if (a === '--report') {
349
- out.report = 'markdown'
350
- } else if (a?.startsWith('--report=')) {
351
- const fmt = a.slice('--report='.length)
352
- if (fmt !== 'markdown') {
353
- return { ...out, error: `--report must be markdown (got ${fmt})` }
354
- }
355
- out.report = fmt
356
289
  } else if (verb === 'watch' && a === '--poll') {
357
290
  out.poll = true
358
291
  } else if (a !== undefined && settingFlagOf(a) !== undefined) {
@@ -400,39 +333,10 @@ export function parseRunArgs(rawArgs: readonly string[], verb: 'run' | 'watch' =
400
333
  out.cache = applyCacheFlags(cachePolicy, flags)
401
334
  if (!cacheFlag && envSpec === undefined) out.cacheFlags = flags
402
335
 
403
- if (out.dry !== undefined && out.graph !== undefined) {
404
- return { ...out, error: '--dry and --graph are mutually exclusive' }
405
- }
406
- // Every flag that promises a file or a section about the run: the
407
- // planning branch returns before any of them is written, and
408
- // `--report-file="$GITHUB_STEP_SUMMARY" --dry` exited 0 having written
409
- // nothing (item 992).
410
- const needsRun =
411
- out.summarize !== undefined ||
412
- out.profile !== undefined ||
413
- out.report !== undefined ||
414
- out.reportFile !== undefined
415
- const runOnly = '--summarize / --profile / --report / --report-file need a real run'
416
- if (out.dry !== undefined && needsRun) {
417
- return { ...out, error: `--dry skips execution; ${runOnly}` }
418
- }
419
- if (out.graph !== undefined && needsRun) {
420
- return { ...out, error: `--graph skips execution; ${runOnly}` }
421
- }
422
- if (out.format === 'json') {
423
- // Each of these prints something else on stdout, which the document owns.
424
- if (out.dry !== undefined)
425
- return { ...out, error: '--format json runs the tasks; --dry=json prints the plan' }
426
- if (out.graph === '')
427
- return {
428
- ...out,
429
- error: '--format json and --graph both print on stdout; give --graph a file',
430
- }
431
- if (out.report === 'markdown')
432
- return {
433
- ...out,
434
- error: '--format json and --report=markdown both print on stdout; use --report-file',
435
- }
336
+ // A profile is about a run: the planning branch returns before it is
337
+ // written (item 992).
338
+ if (out.dry !== undefined && out.profile !== undefined) {
339
+ return { ...out, error: '--dry skips execution; --profile needs a real run' }
436
340
  }
437
341
  return out
438
342
  }
@@ -619,10 +523,7 @@ export async function resolveRunOptions(
619
523
  for (const [path, field] of SETTING_OPTIONS) {
620
524
  if (parsed.settings[path] !== undefined) Object.assign(opts, { [field]: parsed.settings[path] })
621
525
  }
622
- if (parsed.summarize !== undefined) opts.summarize = parsed.summarize
623
- if (parsed.format === 'json') opts.json = true
624
526
  if (parsed.profile !== undefined) opts.profile = parsed.profile
625
- if (Object.keys(parsed.tags).length > 0) opts.tags = parsed.tags
626
527
 
627
528
  return opts
628
529
  }
@@ -646,7 +547,7 @@ export async function runCmd(args: readonly string[]): Promise<number> {
646
547
  if (tasks.length === 0) {
647
548
  // A JSON answer is for a program, which cannot pick from a menu: an
648
549
  // agent on a pty waited at the picker forever.
649
- const forProgram = parsed.format === 'json' || parsed.dry === 'json'
550
+ const forProgram = parsed.dry === 'json'
650
551
  if (!process.stdin.isTTY || forProgram) {
651
552
  const names = await taskNamesHere(cwd)
652
553
  const shown = (names ?? []).slice(0, TASKS_SHOWN)
@@ -710,17 +611,17 @@ export async function runCmd(args: readonly string[]): Promise<number> {
710
611
  ...args.map(shellQuote),
711
612
  ].join(' ')
712
613
 
713
- // Planning paths short-circuit execution. Both build the full task
714
- // graph + probe the cache; the difference is just the formatter.
715
- if (parsed.dry !== undefined || parsed.graph !== undefined) {
614
+ // Planning short-circuits execution: the full task graph + a cache probe.
615
+ if (parsed.dry !== undefined) {
716
616
  const plan = await planRun(opts)
617
+ // Refused as a run refuses: `--dry=json` gets the error document.
717
618
  if (plan.unresolvedTasks !== undefined && plan.unresolvedTasks.length > 0) {
718
- sayNotice(
719
- 'error',
720
- 'vx run',
619
+ return refuse(
620
+ 'run',
621
+ args,
721
622
  `no projects declare task(s): ${plan.unresolvedTasks.join(', ')}.${plan.unresolvedHint ?? ''}`,
623
+ 'VX_E_UNKNOWN_TASK',
722
624
  )
723
- return 1
724
625
  }
725
626
  if (plan.tasks.length === 0) {
726
627
  // The run's own line: a dry run that guessed from the scope alone
@@ -733,27 +634,14 @@ export async function runCmd(args: readonly string[]): Promise<number> {
733
634
  sayNotice('info', 'vx run', `no affected project declares task(s): ${tasks.join(', ')}`)
734
635
  return 0
735
636
  }
736
- sayNotice('error', 'vx run', `no projects declare task(s): ${tasks.join(', ')}`)
737
- return 1
637
+ return refuse(
638
+ 'run',
639
+ args,
640
+ `no projects declare task(s): ${tasks.join(', ')}`,
641
+ 'VX_E_UNKNOWN_TASK',
642
+ )
738
643
  }
739
- if (parsed.graph !== undefined) {
740
- const out = formatGraphDot(plan)
741
- if (parsed.graph === '') {
742
- process.stdout.write(out)
743
- } else {
744
- // The graph is the command's one product, so a path it cannot write
745
- // is exit 1, said in one line as the other output paths say theirs:
746
- // a directory or an unreachable path printed a raw stack (item 993).
747
- const target = path.resolve(cwd, parsed.graph)
748
- try {
749
- await Bun.write(target, out)
750
- } catch (err) {
751
- const message = err instanceof Error ? err.message : String(err)
752
- sayNotice('error', 'vx run', `failed to write graph to ${target}: ${message}`)
753
- return 1
754
- }
755
- }
756
- } else if (parsed.dry === 'json') {
644
+ if (parsed.dry === 'json') {
757
645
  process.stdout.write(formatPlanJson(plan, scopeOut.affectedBase))
758
646
  } else {
759
647
  process.stdout.write(formatPlanText(plan))
@@ -761,25 +649,6 @@ export async function runCmd(args: readonly string[]): Promise<number> {
761
649
  return 0
762
650
  }
763
651
 
764
- // The report prints above the footer: nothing prints below it (owner).
765
- // Rendered once, however many sinks asked for it; a kept server's crash
766
- // after the footer re-renders the file's copy (C-53).
767
- const wantsReport = parsed.report === 'markdown' || parsed.reportFile !== undefined
768
- let reported: { outcomes: readonly TaskOutcome[]; md: string } | undefined
769
- if (wantsReport) {
770
- opts.beforeFooter = (outcomes, ok) => {
771
- reported = {
772
- outcomes,
773
- md: formatRunReportMarkdown({ ok, outcomes: outcomes.map(projectOutcome) }),
774
- }
775
- // `--report` writes stdout. The report ITSELF is machine-clean, but
776
- // stdout is not vx's alone — the status logger writes there too, so
777
- // `--report=markdown >> "$GITHUB_STEP_SUMMARY"` captures every frame,
778
- // meter bar and `::group::` command above the table. `--report-file`
779
- // is the redirect-free form.
780
- return parsed.report === 'markdown' ? reported.md : ''
781
- }
782
- }
783
652
  // A run executes in THIS process, always. Where an individual task's
784
653
  // command runs is the `executor` capability's business (per task, with
785
654
  // the scheduler, cache, retries and telemetry unchanged above it); there
@@ -789,37 +658,6 @@ export async function runCmd(args: readonly string[]): Promise<number> {
789
658
  const unknown = summary.refused.startsWith('no projects declare')
790
659
  return refuse('run', args, summary.refused, unknown ? 'VX_E_UNKNOWN_TASK' : 'VX_E_REFUSED')
791
660
  }
792
- if (wantsReport) {
793
- const md =
794
- reported?.outcomes === summary.outcomes
795
- ? reported.md
796
- : formatRunReportMarkdown({
797
- ok: summary.ok,
798
- outcomes: summary.outcomes.map(projectOutcome),
799
- })
800
- if (parsed.reportFile !== undefined) {
801
- const target = path.resolve(cwd, parsed.reportFile)
802
- try {
803
- // APPEND, not overwrite: the flag exists for `$GITHUB_STEP_SUMMARY`,
804
- // which GitHub documents as append-only and which other steps in the
805
- // same job also write to. Truncating it would silently destroy their
806
- // content, and would make replacing the documented `>>` recipe a
807
- // behaviour change rather than a drop-in.
808
- // Its directory made first, as `--summarize`, `--profile` and
809
- // `--graph` make theirs: `nr/r.md` failed alone of the four (item 993).
810
- // Sync: on a Ctrl-C the signal path exits once stdout drains, and
811
- // an awaited write lost the race every time (E-23).
812
- mkdirSync(path.dirname(target), { recursive: true })
813
- appendFileSync(target, md)
814
- } catch (err) {
815
- // Same contract as --summarize / --profile: the run already
816
- // happened, so a write failure is reported, not fatal.
817
- const message = err instanceof Error ? err.message : String(err)
818
- sayNotice('warn', 'vx run', `failed to write report to ${target}: ${message}`)
819
- }
820
- }
821
- }
822
- if (summary.json !== undefined) process.stdout.write(`${JSON.stringify(summary.json)}\n`)
823
661
  return summary.ok ? 0 : 1
824
662
  }
825
663
 
package/src/cli/show.ts CHANGED
@@ -169,6 +169,12 @@ export async function showCmd(args: readonly string[]): Promise<number> {
169
169
  const projects = await loadCliProjects(root, metas, scope, { closure: true })
170
170
 
171
171
  if (parsed.target === undefined) {
172
+ if (metas.length === 0)
173
+ sayNotice(
174
+ 'info',
175
+ 'vx show',
176
+ 'no projects: no directory holds a vx.config — run `vx init` to write them, then `vx lock`',
177
+ )
172
178
  const shown = metas.filter((m) => inSelection(m.name))
173
179
  process.stdout.write(renderList(root, shown, projects, parsed.format, colorsOut()))
174
180
  return 0