@orkestrel/scaffold 0.0.132 → 0.0.134

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 (86) hide show
  1. package/dist/agents/skills/orkestrel-dispatch/scripts/bench.js +61 -96
  2. package/dist/agents/skills/orkestrel-dispatch/scripts/brief.js +48 -76
  3. package/dist/agents/skills/orkestrel-dispatch/scripts/chain.js +27 -66
  4. package/dist/agents/skills/orkestrel-dispatch/scripts/cite.js +31 -64
  5. package/dist/agents/skills/orkestrel-dispatch/scripts/launch.js +43 -57
  6. package/dist/agents/skills/orkestrel-dispatch/scripts/login.js +43 -86
  7. package/dist/agents/skills/orkestrel-dispatch/scripts/patch.js +68 -104
  8. package/dist/agents/skills/orkestrel-dispatch/scripts/result.js +35 -69
  9. package/dist/agents/skills/orkestrel-dispatch/scripts/sweep.js +47 -84
  10. package/dist/agents/skills/orkestrel-falsify/scripts/mutate.js +134 -116
  11. package/dist/agents/skills/orkestrel-harden/scripts/discovery.js +38 -90
  12. package/dist/agents/skills/orkestrel-harden/scripts/interleave.js +39 -103
  13. package/dist/agents/skills/orkestrel-harden/scripts/measure.js +40 -89
  14. package/dist/agents/skills/orkestrel-harden/scripts/titles.js +41 -87
  15. package/dist/agents/skills/orkestrel-parallel/scripts/cases.js +43 -88
  16. package/dist/agents/skills/orkestrel-parallel/scripts/lane.js +1018 -194
  17. package/dist/agents/skills/orkestrel-publish/scripts/compare.js +40 -60
  18. package/dist/agents/skills/orkestrel-publish/scripts/pins.js +47 -81
  19. package/dist/agents/skills/orkestrel-publish/scripts/steps.js +66 -104
  20. package/dist/agents/skills/orkestrel-publish/scripts/swap.js +74 -88
  21. package/dist/agents/skills/orkestrel-publish/scripts/wave.js +95 -108
  22. package/dist/agents/skills/orkestrel-publish/scripts/window.js +55 -96
  23. package/dist/agents/skills/orkestrel-scout/scripts/map.js +54 -101
  24. package/dist/bin/main.js +30 -6
  25. package/dist/bin/main.js.map +1 -1
  26. package/dist/host/agents/orchestration.md +1 -0
  27. package/dist/host/agents/skills/orkestrel-dispatch/scripts/bench.ts +81 -97
  28. package/dist/host/agents/skills/orkestrel-dispatch/scripts/brief.ts +64 -72
  29. package/dist/host/agents/skills/orkestrel-dispatch/scripts/chain.ts +41 -63
  30. package/dist/host/agents/skills/orkestrel-dispatch/scripts/cite.ts +56 -79
  31. package/dist/host/agents/skills/orkestrel-dispatch/scripts/launch.ts +61 -74
  32. package/dist/host/agents/skills/orkestrel-dispatch/scripts/login.ts +59 -89
  33. package/dist/host/agents/skills/orkestrel-dispatch/scripts/patch.ts +87 -106
  34. package/dist/host/agents/skills/orkestrel-dispatch/scripts/result.ts +57 -76
  35. package/dist/host/agents/skills/orkestrel-dispatch/scripts/sweep.ts +73 -88
  36. package/dist/host/agents/skills/orkestrel-falsify/SKILL.md +2 -2
  37. package/dist/host/agents/skills/orkestrel-falsify/scripts/mutate.ts +167 -119
  38. package/dist/host/agents/skills/orkestrel-harden/references/methods.md +1 -1
  39. package/dist/host/agents/skills/orkestrel-harden/scripts/discovery.ts +58 -75
  40. package/dist/host/agents/skills/orkestrel-harden/scripts/interleave.ts +55 -99
  41. package/dist/host/agents/skills/orkestrel-harden/scripts/measure.ts +59 -90
  42. package/dist/host/agents/skills/orkestrel-harden/scripts/titles.ts +60 -80
  43. package/dist/host/agents/skills/orkestrel-parallel/SKILL.md +4 -4
  44. package/dist/host/agents/skills/orkestrel-parallel/scripts/cases.ts +71 -108
  45. package/dist/host/agents/skills/orkestrel-parallel/scripts/lane.ts +1288 -239
  46. package/dist/host/agents/skills/orkestrel-publish/references/wave.md +10 -6
  47. package/dist/host/agents/skills/orkestrel-publish/scripts/compare.ts +58 -79
  48. package/dist/host/agents/skills/orkestrel-publish/scripts/pins.ts +66 -87
  49. package/dist/host/agents/skills/orkestrel-publish/scripts/steps.ts +84 -102
  50. package/dist/host/agents/skills/orkestrel-publish/scripts/swap.ts +92 -99
  51. package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +130 -126
  52. package/dist/host/agents/skills/orkestrel-publish/scripts/window.ts +82 -120
  53. package/dist/host/agents/skills/orkestrel-scout/SKILL.md +3 -3
  54. package/dist/host/agents/skills/orkestrel-scout/scripts/map.ts +85 -112
  55. package/dist/host/claude/agents/orkestrel.md +54 -54
  56. package/dist/host/claude/rules/documentation.md +1 -1
  57. package/dist/host/claude/rules/patterns.md +5 -4
  58. package/dist/host/claude/rules/styles.md +1 -1
  59. package/dist/host/claude/rules/tests.md +8 -3
  60. package/dist/host/claude/rules/workspace.md +47 -35
  61. package/dist/host/configs/helpers.ts +40 -15
  62. package/dist/host/dotfiles/oxlintrc.json +62 -0
  63. package/dist/host/guides/browser.md +1 -1
  64. package/dist/host/guides/form.md +79 -4
  65. package/dist/host/guides/queue.md +3 -1
  66. package/dist/host/guides/scaffold.md +95 -67
  67. package/dist/host/guides/table.md +20 -6
  68. package/dist/host/guides/test.md +342 -202
  69. package/dist/host/guides/workflow.md +4 -2
  70. package/dist/host/manifest.json +48 -48
  71. package/dist/host/tests/config.test.ts +201 -11
  72. package/dist/host/tests/policy.test.ts +15 -22
  73. package/dist/host/tests/setupPolicy.ts +43 -36
  74. package/dist/src/core/index.cjs +194 -97
  75. package/dist/src/core/index.cjs.map +1 -1
  76. package/dist/src/core/index.d.cts +27 -13
  77. package/dist/src/core/index.d.ts +27 -13
  78. package/dist/src/core/index.js +192 -97
  79. package/dist/src/core/index.js.map +1 -1
  80. package/dist/src/server/index.cjs +8 -9
  81. package/dist/src/server/index.cjs.map +1 -1
  82. package/dist/src/server/index.d.cts +1 -1
  83. package/dist/src/server/index.d.ts +1 -1
  84. package/dist/src/server/index.js +8 -9
  85. package/dist/src/server/index.js.map +1 -1
  86. package/package.json +5 -5
@@ -3,7 +3,10 @@
3
3
  // node .agents/skills/orkestrel-publish/scripts/wave.ts --plan [--catalog PATH] [--json]
4
4
  // --visit runs the visit `wave.md` § Visit a repository fixes, in order, stopping at the first step
5
5
  // that fails: pin (read `scaffold audit --json`, whose drift exit is the reading the pin closes, then
6
- // re-pin every range the audit release readings name to the registry caret and install), commit (`git commit --only` of
6
+ // re-pin every `dependencies` and `devDependencies` range the audit release readings name to the registry caret and
7
+ // install; the pin step raises a `peerDependencies` range only when its floor fails the release, and no reading the
8
+ // visit takes names such a floor, so every peer stays as declared and the rewrite row names each peer it left
9
+ // alone), commit (`git commit --only` of
7
10
  // the manifest and lockfile as the preparation commit), overwrite (`scaffold overwrite --json`, then
8
11
  // `scaffold audit` exiting 0; offline, an exit of 1 whose note names the skipped catalog step is
9
12
  // accepted; on @orkestrel/scaffold itself both are skipped with a note, because the vendored host
@@ -22,8 +25,9 @@
22
25
  // ruling is unanswered. --plan reads the marker-bounded catalog table in
23
26
  // `.claude/agents/orkestrel.md` and prints the packages by layer. The pins and compare steps run
24
27
  // `pins.ts` and `compare.ts` as child commands. Exit 0 when every step passed, 1 when a step
25
- // failed, 2 when a reading failed, 64 on usage, including --plan --regenerate, a flag the script
26
- // does not read, and the `--flag=value` form.
28
+ // failed, 2 when a reading failed, 64 on usage, including --plan --regenerate. The script reads its
29
+ // flags with `parseArgs` in strict mode.
30
+ import type { ParseArgsOptionsConfig } from 'node:util'
27
31
  import type { SpawnSyncReturns } from 'node:child_process'
28
32
  import { spawnSync } from 'node:child_process'
29
33
  import { createHash } from 'node:crypto'
@@ -41,6 +45,7 @@ import {
41
45
  } from 'node:fs'
42
46
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
43
47
  import { fileURLToPath } from 'node:url'
48
+ import { parseArgs } from 'node:util'
44
49
 
45
50
  /** Lists the steps of a visit in the order they run. */
46
51
  export const STEPS: readonly string[] = [
@@ -119,26 +124,59 @@ export const PINS = fileURLToPath(new URL(`./pins${EXTENSION}`, import.meta.url)
119
124
  export const DIRTY_ENTRY =
120
125
  /(?=[RC][^\0]|[^\0][RC])[^\0]{2} ([^\0]*)\0([^\0]*)(?:\0|$)|[^\0]{2} ([^\0]*)(?:\0|$)/gu
121
126
 
122
- /** Lists every flag the script reads, value flags and switches alike. */
123
- export const FLAGS: readonly string[] = [
124
- '--visit',
125
- '--plan',
126
- '--target',
127
- '--offline',
128
- '--regenerate',
129
- '--from',
130
- '--to',
131
- '--prior',
132
- '--dry-run',
133
- '--json',
134
- '--out',
135
- '--catalog',
136
- ]
137
-
138
127
  /** Holds the usage line the script prints when no mode was given. */
139
128
  export const USAGE =
140
129
  'usage: wave.ts --visit [--target DIR] [--offline] [--regenerate] [--from STEP] [--to STEP] [--prior VERSION] [--dry-run] [--json] [--out FILE] | --plan [--catalog PATH] [--json]'
141
130
 
131
+ /** Declares every flag the script reads, for `parseArgs`. */
132
+ export const OPTIONS: ParseArgsOptionsConfig = Object.freeze({
133
+ visit: Object.freeze({ type: 'boolean' }),
134
+ plan: Object.freeze({ type: 'boolean' }),
135
+ target: Object.freeze({ type: 'string' }),
136
+ offline: Object.freeze({ type: 'boolean' }),
137
+ regenerate: Object.freeze({ type: 'boolean' }),
138
+ from: Object.freeze({ type: 'string' }),
139
+ to: Object.freeze({ type: 'string' }),
140
+ prior: Object.freeze({ type: 'string' }),
141
+ 'dry-run': Object.freeze({ type: 'boolean' }),
142
+ json: Object.freeze({ type: 'boolean' }),
143
+ out: Object.freeze({ type: 'string' }),
144
+ catalog: Object.freeze({ type: 'string' }),
145
+ })
146
+
147
+ /** Describes the arguments `parseArgs` read: each flag's value by name, and the positionals. */
148
+ export interface Arguments {
149
+ readonly values: Readonly<
150
+ Record<string, string | boolean | ReadonlyArray<string | boolean> | undefined>
151
+ >
152
+ readonly positionals: readonly string[]
153
+ }
154
+
155
+ /** Describes how `parseArgs` read the arguments: the arguments, or the message it refused them with. */
156
+ export type ArgumentsResult =
157
+ | { readonly success: true; readonly value: Arguments }
158
+ | { readonly success: false; readonly error: string }
159
+
160
+ /**
161
+ * Parses the arguments in strict mode against `OPTIONS`.
162
+ *
163
+ * @param argv - The arguments after the script path.
164
+ * @returns The values and positionals, or the message `parseArgs` refused the arguments with.
165
+ */
166
+ export function parseArguments(argv: readonly string[]): ArgumentsResult {
167
+ try {
168
+ const { values, positionals } = parseArgs({
169
+ args: [...argv],
170
+ options: OPTIONS,
171
+ strict: true,
172
+ allowPositionals: false,
173
+ })
174
+ return { success: true, value: { values, positionals } }
175
+ } catch (error) {
176
+ return { success: false, error: error instanceof Error ? error.message : String(error) }
177
+ }
178
+ }
179
+
142
180
  /** Names the manifest fields that hold specs, including nested overrides. */
143
181
  export const SPEC_FIELDS: readonly string[] = Object.freeze([
144
182
  'dependencies',
@@ -188,6 +226,12 @@ export interface RangeMove {
188
226
  readonly moved: readonly string[]
189
227
  }
190
228
 
229
+ /** Describes a manifest re-pin: the ranges it moved and the peer ranges it left at their floor. */
230
+ export interface Rewrite {
231
+ readonly moved: readonly string[]
232
+ readonly kept: readonly string[]
233
+ }
234
+
191
235
  /** Describes the bump ruling a visit reaches. */
192
236
  export interface Ruling {
193
237
  readonly distMoved: boolean | undefined
@@ -325,60 +369,7 @@ export function removeTree(path: string): void {
325
369
  * @returns The same path with every backslash replaced by a slash.
326
370
  */
327
371
  export function normalizeSlashes(path: string): string {
328
- return path.split('\\').join('/')
329
- }
330
-
331
- /**
332
- * Reads the value that follows a flag.
333
- *
334
- * @remarks
335
- * Reads `--flag value` pairs: the first occurrence of a flag wins, a following value that opens
336
- * with `--` is a missing value, and the `--flag=value` form is not read.
337
- *
338
- * @param argv - The arguments after the script path.
339
- * @param name - The flag, such as `--target`.
340
- * @returns The value after the flag, or undefined when the flag is absent, last, or followed by
341
- * another flag.
342
- */
343
- export function readOption(argv: readonly string[], name: string): string | undefined {
344
- const index = argv.indexOf(name)
345
- const value = index === -1 ? undefined : argv[index + 1]
346
- return value === undefined || value.startsWith('--') ? undefined : value
347
- }
348
-
349
- /**
350
- * Names the value flags a caller gave with no value.
351
- *
352
- * @param argv - The arguments after the script path.
353
- * @param names - The flags that take a value.
354
- * @returns Each named flag that appears last or is followed by another flag, in argument order.
355
- */
356
- export function readMissingFlags(
357
- argv: readonly string[],
358
- names: readonly string[],
359
- ): readonly string[] {
360
- return names.filter((name) => argv.includes(name) && readOption(argv, name) === undefined)
361
- }
362
-
363
- /**
364
- * Names the flags a caller gave that the script does not read.
365
- *
366
- * @remarks
367
- * Reads the arguments before a bare `--`, which opens a command a script passes on. A `--flag=value`
368
- * argument is unknown, because the script reads no such form.
369
- *
370
- * @param argv - The arguments after the script path.
371
- * @param flags - Every flag the script reads, value flags and switches alike.
372
- * @returns Each argument that opens with `--` and is not a read flag, in argument order.
373
- */
374
- export function readUnknownFlags(
375
- argv: readonly string[],
376
- flags: readonly string[],
377
- ): readonly string[] {
378
- const end = argv.indexOf('--')
379
- return (end === -1 ? argv : argv.slice(0, end)).filter(
380
- (argument) => argument.startsWith('--') && !flags.includes(argument),
381
- )
372
+ return path.replaceAll('\\', '/')
382
373
  }
383
374
 
384
375
  /**
@@ -1606,29 +1597,51 @@ export function computeRanges(
1606
1597
  }
1607
1598
 
1608
1599
  /**
1609
- * Writes the re-pinned ranges into the target's manifest.
1600
+ * Writes the re-pinned ranges into the target's manifest, keeping every peer range at its floor.
1601
+ *
1602
+ * @remarks
1603
+ * A `peerDependencies` range moves only when its floor fails the release, and no reading the visit
1604
+ * takes names a floor the release needs, so every peer the registry moved past stays as declared and
1605
+ * is reported as kept.
1610
1606
  *
1611
1607
  * @param target - The target directory.
1612
1608
  * @param releases - The audit's release readings.
1613
- * @returns One message per range moved; the manifest is rewritten only when a range moved.
1609
+ * @returns One message per range moved and one per peer range kept; the manifest is rewritten only
1610
+ * when a range moved.
1611
+ * @example
1612
+ * ```ts
1613
+ * writeRanges('.', [{ name: 'vite', range: '^8', latest: '8.3.8' }])
1614
+ * // { moved: ['vite ^8.3.7 -> ^8.3.8'], kept: ['peer vite ^8.3.7 left alone, not ^8.3.8'] }
1615
+ * ```
1614
1616
  */
1615
- export function writeRanges(target: string, releases: readonly Release[]): readonly string[] {
1617
+ export function writeRanges(target: string, releases: readonly Release[]): Rewrite {
1616
1618
  const manifest = readManifest(target)
1617
- if (manifest === undefined) return []
1619
+ if (manifest === undefined) return { moved: [], kept: [] }
1618
1620
  const fields = RANGE_FIELDS.flatMap((field) => {
1619
1621
  const block = manifest[field]
1620
1622
  if (typeof block !== 'object' || block === null) return []
1621
- return [{ field, ...computeRanges(Object.fromEntries(Object.entries(block)), releases) }]
1623
+ const ranges = Object.fromEntries(Object.entries(block))
1624
+ return [{ field, ranges, moves: computeRanges(ranges, releases) }]
1622
1625
  })
1623
- const moved = fields.flatMap((entry) => entry.moved)
1626
+ const peers = fields.filter((entry) => entry.field === 'peerDependencies')
1627
+ const kept = peers.flatMap((entry) =>
1628
+ Object.entries(entry.ranges)
1629
+ .filter(([name, range]) => entry.moves.ranges[name] !== range)
1630
+ .map(
1631
+ ([name, range]) =>
1632
+ `peer ${name} ${String(range)} left alone, not ${String(entry.moves.ranges[name])}`,
1633
+ ),
1634
+ )
1635
+ const pinned = fields.filter((entry) => entry.field !== 'peerDependencies')
1636
+ const moved = pinned.flatMap((entry) => entry.moves.moved)
1624
1637
  if (moved.length > 0) {
1625
1638
  const written = {
1626
1639
  ...manifest,
1627
- ...Object.fromEntries(fields.map((entry) => [entry.field, entry.ranges])),
1640
+ ...Object.fromEntries(pinned.map((entry) => [entry.field, entry.moves.ranges])),
1628
1641
  }
1629
1642
  writeFileSync(join(target, 'package.json'), `${JSON.stringify(written, null, '\t')}\n`)
1630
1643
  }
1631
- return moved
1644
+ return { moved, kept }
1632
1645
  }
1633
1646
 
1634
1647
  /**
@@ -1657,12 +1670,12 @@ export function runPin(
1657
1670
  if (audit !== undefined) {
1658
1671
  const releases = readReleases(audit.stdout)
1659
1672
  if (releases === undefined || (audit.status !== 0 && audit.status !== 1)) return
1660
- const moved = writeRanges(runner.target, releases)
1673
+ const { moved, kept } = writeRanges(runner.target, releases)
1661
1674
  appendStep(
1662
1675
  runner,
1663
1676
  'pin',
1664
1677
  'rewrite audit release ranges to the registry caret',
1665
- moved.length === 0 ? 'no range moved' : moved.join(', '),
1678
+ [moved.length === 0 ? 'no range moved' : moved.join(', '), ...kept].join('; '),
1666
1679
  )
1667
1680
  } else {
1668
1681
  appendStep(runner, 'pin', 'rewrite audit release ranges to the registry caret', 'dry run')
@@ -1975,12 +1988,12 @@ export function describeChange(
1975
1988
  /**
1976
1989
  * Runs one repository's visit.
1977
1990
  *
1978
- * @param argv - The arguments after the script path.
1991
+ * @param values - The flag values `parseArgs` read.
1979
1992
  * @returns The finished visit, or undefined when the target carries no readable manifest or no
1980
1993
  * scaffold executable.
1981
1994
  */
1982
- export function runVisit(argv: readonly string[]): Visit | undefined {
1983
- const target = readOption(argv, '--target') ?? process.cwd()
1995
+ export function runVisit(values: Arguments['values']): Visit | undefined {
1996
+ const target = typeof values.target === 'string' ? values.target : process.cwd()
1984
1997
  if (!existsSync(join(target, 'package.json'))) {
1985
1998
  console.error(`wave: ${target} carries no package.json`)
1986
1999
  return undefined
@@ -1999,8 +2012,8 @@ export function runVisit(argv: readonly string[]): Visit | undefined {
1999
2012
  }
2000
2013
  const [scaffoldFile, ...scaffoldPrefix] = scaffold
2001
2014
  if (scaffoldFile === undefined) return undefined
2002
- const from = STEPS.indexOf(readOption(argv, '--from') ?? 'pin')
2003
- const to = STEPS.indexOf(readOption(argv, '--to') ?? 'compare')
2015
+ const from = STEPS.indexOf(typeof values.from === 'string' ? values.from : 'pin')
2016
+ const to = STEPS.indexOf(typeof values.to === 'string' ? values.to : 'compare')
2004
2017
  const selected = new Set(STEPS.slice(from, to + 1))
2005
2018
  const manifest = readManifest(target)
2006
2019
  if (manifest === undefined) {
@@ -2011,11 +2024,11 @@ export function runVisit(argv: readonly string[]): Visit | undefined {
2011
2024
  const version = readString(manifest, 'version')
2012
2025
  const runner: Runner = {
2013
2026
  target: resolve(target),
2014
- dry: argv.includes('--dry-run'),
2015
- offline: argv.includes('--offline'),
2016
- regenerate: argv.includes('--regenerate'),
2027
+ dry: values['dry-run'] === true,
2028
+ offline: values.offline === true,
2029
+ regenerate: values.regenerate === true,
2017
2030
  directory:
2018
- argv.includes('--dry-run') ||
2031
+ values['dry-run'] === true ||
2019
2032
  (name === SCAFFOLD && from === STEPS.indexOf('record') && to === from)
2020
2033
  ? undefined
2021
2034
  : readJournalDirectory(resolve(target)),
@@ -2049,7 +2062,7 @@ export function runVisit(argv: readonly string[]): Visit | undefined {
2049
2062
  if (selected.has('install') && !failed(runner.steps)) runInstall(runner, 'install')
2050
2063
  const hits =
2051
2064
  selected.has('pins') && !failed(runner.steps)
2052
- ? runPins(runner, before, readOption(argv, '--prior') ?? version)
2065
+ ? runPins(runner, before, typeof values.prior === 'string' ? values.prior : version)
2053
2066
  : undefined
2054
2067
  const format = selected.has('format') && !failed(runner.steps) ? runFormat(runner) : undefined
2055
2068
  if (selected.has('record') && !failed(runner.steps)) runRecord(runner, name, format)
@@ -2165,64 +2178,55 @@ export function renderVisit(visit: Visit): string {
2165
2178
  * on usage.
2166
2179
  */
2167
2180
  export function main(argv: readonly string[]): number {
2168
- const unknown = readUnknownFlags(argv, FLAGS)
2169
- if (unknown.length > 0) {
2170
- console.error(
2171
- `wave: unknown flag ${unknown.join(', ')}; give each flag and its value as separate arguments\n${USAGE}`,
2172
- )
2173
- return 64
2174
- }
2175
- const missing = readMissingFlags(argv, [
2176
- '--target',
2177
- '--from',
2178
- '--to',
2179
- '--prior',
2180
- '--catalog',
2181
- '--out',
2182
- ])
2183
- if (missing.length > 0) {
2184
- console.error(`wave: ${missing.join(', ')} given with no value`)
2181
+ const parsed = parseArguments(argv)
2182
+ if (!parsed.success) {
2183
+ console.error(`wave: ${parsed.error}; ${USAGE}`)
2185
2184
  return 64
2186
2185
  }
2187
- if (argv.includes('--plan') && argv.includes('--visit')) {
2188
- console.error('wave: --plan and --visit are two modes; name one')
2186
+ const { values } = parsed.value
2187
+ if (values.plan === true && values.visit === true) {
2188
+ console.error(`wave: --plan and --visit are two modes; name one; ${USAGE}`)
2189
2189
  return 64
2190
2190
  }
2191
- if (argv.includes('--plan')) {
2192
- if (argv.includes('--regenerate')) {
2193
- console.error('wave: --regenerate requires --visit, not --plan')
2191
+ if (values.plan === true) {
2192
+ if (values.regenerate === true) {
2193
+ console.error(`wave: --regenerate requires --visit, not --plan; ${USAGE}`)
2194
2194
  return 64
2195
2195
  }
2196
- const layers = readLayers(readOption(argv, '--catalog') ?? CATALOG)
2196
+ const layers = readLayers(typeof values.catalog === 'string' ? values.catalog : CATALOG)
2197
2197
  if (layers === undefined) {
2198
2198
  console.error('wave: no marker-bounded catalog table; run scaffold catalog first')
2199
2199
  return 2
2200
2200
  }
2201
- if (argv.includes('--json')) console.log(JSON.stringify(Object.fromEntries(layers)))
2201
+ if (values.json === true) console.log(JSON.stringify(Object.fromEntries(layers)))
2202
2202
  else for (const [layer, members] of layers) console.log(`${layer}\t${members.join(', ')}`)
2203
2203
  return 0
2204
2204
  }
2205
- if (!argv.includes('--visit')) {
2205
+ if (values.visit !== true) {
2206
2206
  console.error(USAGE)
2207
2207
  return 64
2208
2208
  }
2209
- const from = STEPS.indexOf(readOption(argv, '--from') ?? 'pin')
2210
- const to = STEPS.indexOf(readOption(argv, '--to') ?? 'compare')
2209
+ const first = typeof values.from === 'string' ? values.from : 'pin'
2210
+ const last = typeof values.to === 'string' ? values.to : 'compare'
2211
+ const from = STEPS.indexOf(first)
2212
+ const to = STEPS.indexOf(last)
2211
2213
  if (from === -1 || to === -1 || to < from) {
2212
- console.error(`wave: --from and --to name steps in order from: ${STEPS.join(', ')}`)
2214
+ console.error(
2215
+ `wave: --from and --to take steps in order from: ${STEPS.join(', ')}, not ${JSON.stringify(first)} and ${JSON.stringify(last)}; ${USAGE}`,
2216
+ )
2213
2217
  return 64
2214
2218
  }
2215
- const prior = readOption(argv, '--prior')
2219
+ const prior = typeof values.prior === 'string' ? values.prior : undefined
2216
2220
  if (prior !== undefined && !VERSION.test(prior)) {
2217
2221
  console.error(
2218
- 'wave: --prior takes the version the package carried before its bump, MAJOR.MINOR.PATCH',
2222
+ `wave: --prior takes the version the package carried before its bump, MAJOR.MINOR.PATCH, not ${JSON.stringify(prior)}; ${USAGE}`,
2219
2223
  )
2220
2224
  return 64
2221
2225
  }
2222
- const visit = runVisit(argv)
2226
+ const visit = runVisit(values)
2223
2227
  if (visit === undefined) return 2
2224
- const output = argv.includes('--json') ? `${JSON.stringify(visit)}\n` : renderVisit(visit)
2225
- const out = readOption(argv, '--out')
2228
+ const output = values.json === true ? `${JSON.stringify(visit)}\n` : renderVisit(visit)
2229
+ const out = typeof values.out === 'string' ? values.out : undefined
2226
2230
  if (out === undefined) process.stdout.write(output)
2227
2231
  else {
2228
2232
  mkdirSync(dirname(out), { recursive: true })