@orkestrel/scaffold 0.0.112 → 0.0.114
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/agents/skills/orkestrel-harden/scripts/titles.js +3 -3
- package/dist/agents/skills/orkestrel-publish/scripts/wave.js +120 -21
- package/dist/bin/main.js +71 -23
- package/dist/bin/main.js.map +1 -1
- package/dist/host/agents/platforms/windows.md +1 -1
- package/dist/host/agents/skills/orkestrel-harden/scripts/titles.ts +3 -3
- package/dist/host/agents/skills/orkestrel-publish/SKILL.md +7 -7
- package/dist/host/agents/skills/orkestrel-publish/references/wave.md +25 -8
- package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +187 -54
- package/dist/host/claude/agents/orkestrel.md +53 -53
- package/dist/host/claude/rules/architecture.md +4 -3
- package/dist/host/claude/rules/tests.md +24 -7
- package/dist/host/claude/rules/typescript.md +11 -2
- package/dist/host/claude/rules/workspace.md +32 -28
- package/dist/host/configs/policy.ts +49 -0
- package/dist/host/dotfiles/gitignore +1 -0
- package/dist/host/dotfiles/oxlintrc.json +6 -0
- package/dist/host/guides/agent.md +13 -13
- package/dist/host/guides/brief.md +4 -0
- package/dist/host/guides/browser.md +162 -44
- package/dist/host/guides/budget.md +1 -1
- package/dist/host/guides/capture.md +4 -0
- package/dist/host/guides/console.md +13 -0
- package/dist/host/guides/contract.md +38 -3
- package/dist/host/guides/csv.md +5 -0
- package/dist/host/guides/database.md +58 -8
- package/dist/host/guides/form.md +17 -0
- package/dist/host/guides/guide.md +36 -33
- package/dist/host/guides/html.md +72 -44
- package/dist/host/guides/indexeddb.md +4 -0
- package/dist/host/guides/lsp.md +49 -8
- package/dist/host/guides/markdown.md +146 -1
- package/dist/host/guides/mcp.md +117 -22
- package/dist/host/guides/middleware.md +194 -26
- package/dist/host/guides/msg.md +9 -5
- package/dist/host/guides/pool.md +8 -1
- package/dist/host/guides/probe.md +13 -1
- package/dist/host/guides/process.md +102 -90
- package/dist/host/guides/program.md +4 -0
- package/dist/host/guides/qualifier.md +4 -0
- package/dist/host/guides/rater.md +4 -0
- package/dist/host/guides/reason.md +6 -4
- package/dist/host/guides/relation.md +4 -0
- package/dist/host/guides/scaffold.md +32 -14
- package/dist/host/guides/server.md +29 -13
- package/dist/host/guides/sqlite.md +6 -0
- package/dist/host/guides/sse.md +6 -0
- package/dist/host/guides/study.md +473 -473
- package/dist/host/guides/table.md +3 -0
- package/dist/host/guides/template.md +3 -0
- package/dist/host/guides/test.md +38 -20
- package/dist/host/guides/tool.md +3 -0
- package/dist/host/guides/toolbox.md +21 -0
- package/dist/host/guides/websocket.md +3 -1
- package/dist/host/guides/workflow.md +103 -11
- package/dist/host/guides/workspace.md +4 -0
- package/dist/host/manifest.json +56 -56
- package/dist/host/tests/config.test.ts +72 -16
- package/dist/host/tests/policy.test.ts +21 -7
- package/dist/host/tests/setupPolicy.ts +147 -12
- package/dist/src/core/index.cjs +22 -28
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +8 -8
- package/dist/src/core/index.d.ts +8 -8
- package/dist/src/core/index.js +22 -28
- package/dist/src/core/index.js.map +1 -1
- package/package.json +12 -12
|
@@ -38,5 +38,5 @@ The commands an agent runs on a Windows host, and their quirks. `.claude/rules/p
|
|
|
38
38
|
## Deleting untracked files
|
|
39
39
|
|
|
40
40
|
- When a sweep you run by hand deletes untracked files, send them to the Recycle Bin through a shell file operation with undo, never permanent deletion, and report what went there. Leave emptying the bin to the user; hand them `Clear-RecycleBin -Force`.
|
|
41
|
-
- `DeleteDirectory(..., SendToRecycleBin)`
|
|
41
|
+
- Recycle a folder with `DeleteDirectory(..., SendToRecycleBin)` first; it recycled four npm-installed clones holding no links, 24,600 files, in 6.8 seconds (2026-10-29). When it refuses a tree, recycle each file with `DeleteFile` and remove the emptied folders.
|
|
42
42
|
- Remove a worktree with `git worktree remove`. Delete a leftover `node_modules` junction without recursing into its target.
|
|
@@ -349,7 +349,7 @@ export class TokenScanner {
|
|
|
349
349
|
previous.prefix === true ||
|
|
350
350
|
(previous.category === 'code' &&
|
|
351
351
|
(REGEX_PREFIX.test(spelling) ||
|
|
352
|
-
!/^(?:[\p{ID_Continue}$]
|
|
352
|
+
!/^(?:[\p{ID_Continue}$]+|\d[\w.]*|[\])}]|\+\+|--)$/u.test(spelling))))
|
|
353
353
|
const category = rest.startsWith('//')
|
|
354
354
|
? 'line'
|
|
355
355
|
: rest.startsWith('/*')
|
|
@@ -366,8 +366,8 @@ export class TokenScanner {
|
|
|
366
366
|
? /^\/\*[\s\S]*?\*\//u.exec(rest)
|
|
367
367
|
: category === 'string'
|
|
368
368
|
? (character === "'"
|
|
369
|
-
? /^'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n
|
|
370
|
-
: /^"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n
|
|
369
|
+
? /^'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*'/u
|
|
370
|
+
: /^"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/u
|
|
371
371
|
).exec(rest)
|
|
372
372
|
: category === 'regex'
|
|
373
373
|
? /^\/(?:\\[^\r\n]|\[(?:\\[^\r\n]|[^\]\\\r\n])*\]|[^/\\[\r\n])*\/[a-z]*/iu.exec(
|
|
@@ -21,13 +21,13 @@ description: Run an Orkestrel release from layer order to registry confirmation,
|
|
|
21
21
|
|
|
22
22
|
## Scripts
|
|
23
23
|
|
|
24
|
-
| Script | Does
|
|
25
|
-
| -------------------- |
|
|
26
|
-
| `scripts/compare.ts` | `[--package NAME] [--version V] [--tarball PATH] [--dist dist] [--json]`, run from the package root after its build: fetches the published tarball and lists the material differences from the rebuilt `dist/` (sourcemaps excluded, whitespace-only differences ignored). Exit 0 when nothing differs, 3 when something does, 2 when the tarball cannot be read, 64 on usage (no package name, no `dist/`, or `--tarball` with no path).
|
|
27
|
-
| `scripts/pins.ts` | `--version PRIOR [--range PRIOR_RANGE ...] [--paths src,tests] [--json]`, run from the package root: lists every line under the paths carrying the prior version literal or a prior range literal, once per line, sweeping a one-comparator range such as `^8.3.0` for its bare version in any form. Exit 0 with no hits, 3 with hits, 64 on usage (no literal, or a flag with no value).
|
|
28
|
-
| `scripts/swap.ts` | One mode per run, from any directory: `--pin --consumer DIR --source DIR [--source DIR ...] [--override NAME ...] [--no-build] [--dry-run] [--json]` refuses a source whose packed manifest names a local dependency spec in any dependency field (a `file:` or `link:` prefix, a path start of `.`, `~/`, `/`, `\`, or a drive letter, or a protocol-free archive name ending in `.tgz`, `.tar.gz`, or `.tar` that is not a `user/repo` shorthand), builds and packs each source into `<consumer>/tmp/tarballs/` under a name carrying its SHA-256, records each replaced range in the ledger `pins.json` there, the record of which build the consumer runs, writes each tarball's absolute `file:` spec and each `--override` (repeatable, like `--source`) where oxfmt sorts it, installs, and proves that every pinned source, an override-only one included, is installed with the source's bytes; `--restore --consumer DIR [--package NAME ...] [--json]` puts back each recorded range and override, keeps an `overrides` block that existed before the pin, installs, proves the restored copy, and lists the re-pin arguments, and refuses with 64, before it writes anything, a ledger whose package or override keys are not package names or whose removal would leave `node_modules`; `--status --consumer DIR [--json]` writes nothing and reports drift between the ledger, the manifest, the tarballs, the installed bytes, and the source commits, a manifest spec holding its tarball only when it names the ledger archive's location. `--pin` and `--restore` write a receipt under `tmp/units/`. Exit 0 on success, 1 when a command or a proof failed, 3 when `--status` reports drift, 64 on usage.
|
|
29
|
-
| `scripts/wave.ts` | `--visit [--target DIR] [--offline] [--regenerate] [--from STEP] [--to STEP] [--prior VERSION] [--dry-run] [--json] [--out FILE]` runs one repository's visit in the order [wave.md](references/wave.md) § Visit a repository fixes (pin, commit, overwrite, verify, install, pins, format, record, gates, compare), stops at the first failing step, journals each executed step's full output under the target's `tmp/units/wave/` when the work tree ignores `tmp/` and names the journal in its row, and prints each step's exit (a failed step names the `code: message` refusal or the `note` a JSON verb writes on stdout, else the last stderr lines), the bump ruling (the rebuilt dist against the published tarball, and the final runtime dependency set against the published manifest), and a row for `.orkestrel/release.md`; `--prior` names the version a pre-ruled bump replaced so the self-pin sweep finds it; `--plan` prints the packages by layer from the catalog table. An install that fails `ERESOLVE` names the rerun command, and `--regenerate` replaces the lockfile and `node_modules` from the manifest under the refusals and proof [wave.md](references/wave.md) § Regenerate a lock the install cannot move states; `record` commits the overwrite's writes as `Overwrite with scaffold VERSION
|
|
30
|
-
| `scripts/window.ts` | `--whoami [--wait SECONDS]` reads or polls `npm whoami`; `--login` prints the operator's login command and polls `whoami` until it answers; `--publish DIR... --otp CODE` refuses a batch whose nearest `.git` entry is a file, including ancestor entries, with exit 3 before contacting npm; it names a linked worktree's primary clone or identifies a submodule, then uploads back to back with `npm publish --ignore-scripts --otp`, journals each upload under `tmp/units/`, stops at the first refusal naming where to resume, and confirms each accepted version against the registry; `--confirm NAME@VERSION...` re-reads the registry until it serves the version. Exit 0 on success, 3 when not, 64 on usage.
|
|
24
|
+
| Script | Does |
|
|
25
|
+
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| `scripts/compare.ts` | `[--package NAME] [--version V] [--tarball PATH] [--dist dist] [--json]`, run from the package root after its build: fetches the published tarball and lists the material differences from the rebuilt `dist/` (sourcemaps excluded, whitespace-only differences ignored). Exit 0 when nothing differs, 3 when something does, 2 when the tarball cannot be read, 64 on usage (no package name, no `dist/`, or `--tarball` with no path). |
|
|
27
|
+
| `scripts/pins.ts` | `--version PRIOR [--range PRIOR_RANGE ...] [--paths src,tests] [--json]`, run from the package root: lists every line under the paths carrying the prior version literal or a prior range literal, once per line, sweeping a one-comparator range such as `^8.3.0` for its bare version in any form. Exit 0 with no hits, 3 with hits, 64 on usage (no literal, or a flag with no value). |
|
|
28
|
+
| `scripts/swap.ts` | One mode per run, from any directory: `--pin --consumer DIR --source DIR [--source DIR ...] [--override NAME ...] [--no-build] [--dry-run] [--json]` refuses a source whose packed manifest names a local dependency spec in any dependency field (a `file:` or `link:` prefix, a path start of `.`, `~/`, `/`, `\`, or a drive letter, or a protocol-free archive name ending in `.tgz`, `.tar.gz`, or `.tar` that is not a `user/repo` shorthand), builds and packs each source into `<consumer>/tmp/tarballs/` under a name carrying its SHA-256, records each replaced range in the ledger `pins.json` there, the record of which build the consumer runs, writes each tarball's absolute `file:` spec and each `--override` (repeatable, like `--source`) where oxfmt sorts it, installs, and proves that every pinned source, an override-only one included, is installed with the source's bytes; `--restore --consumer DIR [--package NAME ...] [--json]` puts back each recorded range and override, keeps an `overrides` block that existed before the pin, installs, proves the restored copy, and lists the re-pin arguments, and refuses with 64, before it writes anything, a ledger whose package or override keys are not package names or whose removal would leave `node_modules`; `--status --consumer DIR [--json]` writes nothing and reports drift between the ledger, the manifest, the tarballs, the installed bytes, and the source commits, a manifest spec holding its tarball only when it names the ledger archive's location. `--pin` and `--restore` write a receipt under `tmp/units/`. Exit 0 on success, 1 when a command or a proof failed, 3 when `--status` reports drift, 64 on usage. |
|
|
29
|
+
| `scripts/wave.ts` | `--visit [--target DIR] [--offline] [--regenerate] [--from STEP] [--to STEP] [--prior VERSION] [--dry-run] [--json] [--out FILE]` runs one repository's visit in the order [wave.md](references/wave.md) § Visit a repository fixes (pin, commit, overwrite, verify, install, pins, format, record, gates, compare), stops at the first failing step, journals each executed step's full output under the target's `tmp/units/wave/` when the work tree ignores `tmp/` and names the journal in its row, and prints each step's exit (a failed step names the `code: message` refusal or the `note` a JSON verb writes on stdout, else the last stderr lines), the bump ruling (the rebuilt dist against the published tarball, and the final runtime dependency set against the published manifest), and a row for `.orkestrel/release.md`; `--prior` names the version a pre-ruled bump replaced so the self-pin sweep finds it; `--plan` prints the packages by layer from the catalog table. An install that fails `ERESOLVE` names the rerun command, and `--regenerate` replaces the lockfile and `node_modules` from the manifest under the refusals and proof [wave.md](references/wave.md) § Regenerate a lock the install cannot move states; `record` commits the overwrite's writes as `Overwrite with scaffold VERSION`, then paths dirtied only by that invocation's successful `format` step as `Format with oxfmt VERSION`, reading the formatter version from the target's installed manifest and attributing paths from dirty sets collected immediately before and after formatting; it refuses every other dirty path by name before committing. On `--from record`, it reports the absent format evidence and commits only the overwrite receipt's paths and the manifest pair. The visit runs the target's own executable as scaffold only when the target's manifest names `@orkestrel/scaffold`, and otherwise refuses, naming the install the target needs. Exit 0 when every step passed, 1 when one failed, 2 when a reading failed, 64 on usage, including `--regenerate` with `--plan`. |
|
|
30
|
+
| `scripts/window.ts` | `--whoami [--wait SECONDS]` reads or polls `npm whoami`; `--login` prints the operator's login command and polls `whoami` until it answers; `--publish DIR... --otp CODE` refuses a batch whose nearest `.git` entry is a file, including ancestor entries, with exit 3 before contacting npm; it names a linked worktree's primary clone or identifies a submodule, then uploads back to back with `npm publish --ignore-scripts --otp`, journals each upload under `tmp/units/`, stops at the first refusal naming where to resume, and confirms each accepted version against the registry; `--confirm NAME@VERSION...` re-reads the registry until it serves the version. Exit 0 on success, 3 when not, 64 on usage. |
|
|
31
31
|
|
|
32
32
|
The user's current instruction wins. `references/release.md` binds every release: the credential and authorization law, the upload serialization, the tarball swap, what a bump obliges downstream, and the layer order. Nothing here weakens it. Where this skill disagrees with it, report the drift instead of following the skill.
|
|
33
33
|
|
|
@@ -23,7 +23,11 @@ overwrite receipts are written only where the work tree ignores `tmp/`.
|
|
|
23
23
|
rewrite a peer range only when its name shares an audited release reading. For example, with
|
|
24
24
|
peer-only `@orkestrel/peer-only: ^0.0.1`, leave that peer unchanged; with a planned tool whose
|
|
25
25
|
registry serves `8.3.4`, apply `vite: ~8.2.0 -> ^8.3.4` even though the tilde excludes `8.3.4`.
|
|
26
|
-
Keep
|
|
26
|
+
Keep this pin step within each declared major; step 5 states the overwrite's lift.
|
|
27
|
+
A range joined by `||` names one supported major per
|
|
28
|
+
arm, so move only the arm in the release's major and keep every other arm: with
|
|
29
|
+
`vitest: ^4.1.11 || ^5.0.5` and a registry serving `4.1.12`, apply `^4.1.12 || ^5.0.5`.
|
|
30
|
+
For a workspace whose selected framework activates a
|
|
27
31
|
`TOOLCHAIN_HOLDS` row, keep the tool within that range's major; read the audit question for its reason. Prove
|
|
28
32
|
that framework on the later major before lifting its hold.
|
|
29
33
|
2. Commit the manifest and the lockfile as the preparation commit. `scaffold overwrite` refuses a
|
|
@@ -49,16 +53,29 @@ overwrite receipts are written only where the work tree ignores `tmp/`.
|
|
|
49
53
|
again. Keep a local MCP server registration outside the repository rather than at `.mcp.json`.
|
|
50
54
|
4. Force-verify the same audit population and lookup bounds against a registry sweep taken after
|
|
51
55
|
the previous layer published. Do not infer verification of peer-only declarations from that audit.
|
|
52
|
-
5. Run the full install
|
|
53
|
-
|
|
54
|
-
manifest.
|
|
56
|
+
5. Run the full install after the overwrite lifts each planned foreign tool's `devDependencies`
|
|
57
|
+
declaration whose major trails the canon's to the canon's planned range, its selected framework
|
|
58
|
+
holds included, and declares each planned dependency the manifest lacks. The lift reads a major
|
|
59
|
+
only from `^MAJOR` or a full version, optionally under `^` or `~`, and lifts a `||` range only
|
|
60
|
+
when every arm trails; it keeps an equal or later major, every other range form, and every
|
|
61
|
+
`dependencies` declaration. Read each lift's `from` and `to` ranges from the overwrite result's
|
|
62
|
+
`lifts`, and regenerate the lockfile against the resulting manifest.
|
|
55
63
|
6. Sweep the self-pins, per § Sweep the self-pins: the re-pin moves the snapshot class.
|
|
56
64
|
7. Run the mutating `format` script to converge generated writes.
|
|
57
65
|
8. Commit the overwrite's writes as `Overwrite with scaffold <version>`: every path the overwrite
|
|
58
|
-
wrote or removed, and the manifest and lockfile the install converged.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
wrote or removed, and the manifest and lockfile the install converged. Then commit the remaining
|
|
67
|
+
paths this run's `format` step dirtied as `Format with oxfmt <version>`, using the version read
|
|
68
|
+
from the target's installed `node_modules/oxfmt/package.json`. Attribute those paths only from
|
|
69
|
+
the dirty sets read immediately before and after that successful format step. Refuse every
|
|
70
|
+
dirty path neither group accounts for, naming each path, before either commit. Keep a path that
|
|
71
|
+
was already dirty outside the overwrite group refused even when the formatter rewrites it.
|
|
72
|
+
When resuming with `--from record`, report the absent format evidence and commit only paths the
|
|
73
|
+
valid overwrite receipt and manifest pair account for; never recover attribution from file
|
|
74
|
+
content or a previous run's journals. After an unrelated commit, or a refusal of the formatter's
|
|
75
|
+
rewrites on a resumed run, complete the intended overwrite commit by hand: inspect the receipt's
|
|
76
|
+
written and removed paths, stage those paths and the converged manifest and lockfile, and commit
|
|
77
|
+
them as `Overwrite with scaffold <version>`; then commit the formatter's remaining rewrites as
|
|
78
|
+
`Format with oxfmt <version>`. Then resume with `--from gates`.
|
|
62
79
|
Treat the receipt as stale after any intervening commit; never use that receipt to authorize
|
|
63
80
|
another `record` commit. Skip this step for an offline overwrite and the `@orkestrel/scaffold` package.
|
|
64
81
|
9. Run the quality gates.
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
// the audit's writable dependency population matches its lookup bounds; on @orkestrel/scaffold itself an audit exit of 1 is
|
|
12
12
|
// read as the expected foreign-path findings of its own canonical sources), install,
|
|
13
13
|
// pins (the self-pin sweep with --prior or the manifest version and every range the visit moved; hits are reported, not
|
|
14
|
-
// fatal), format, record (commit the overwrite paths
|
|
14
|
+
// fatal), format, record (commit the overwrite paths, then this run's formatter rewrites), gates
|
|
15
|
+
// (format:check, lint:check, check, build, test), and compare (the rebuilt
|
|
15
16
|
// dist against the published tarball, and the final runtime dependency set against the published
|
|
16
17
|
// manifest `npm view NAME --json` serves; both readings are reported, not fatal). The summary
|
|
17
18
|
// carries each step's exit and duration, a failed step's refusal (the `code: message` envelope or
|
|
@@ -211,6 +212,12 @@ export interface OverwriteReceipt {
|
|
|
211
212
|
readonly removed: readonly string[]
|
|
212
213
|
}
|
|
213
214
|
|
|
215
|
+
/** Describes the paths dirtied by this visit's format step and its installed formatter version. */
|
|
216
|
+
export interface FormatReceipt {
|
|
217
|
+
readonly paths: readonly string[]
|
|
218
|
+
readonly version: string | undefined
|
|
219
|
+
}
|
|
220
|
+
|
|
214
221
|
/** Describes the outcome of writing a journal file. */
|
|
215
222
|
export interface Journal {
|
|
216
223
|
readonly path?: string
|
|
@@ -508,14 +515,15 @@ export function compareRanges(
|
|
|
508
515
|
* Resolves the scaffold executable a target runs.
|
|
509
516
|
*
|
|
510
517
|
* @param target - The target directory.
|
|
511
|
-
* @returns Node and the installed scaffold entry, else Node and the target's own built entry
|
|
512
|
-
* none.
|
|
518
|
+
* @returns Node and the installed scaffold entry, else Node and the target's own built entry when
|
|
519
|
+
* its manifest names @orkestrel/scaffold, else none.
|
|
513
520
|
*/
|
|
514
521
|
export function resolveScaffold(target: string): readonly string[] {
|
|
515
522
|
const installed = join(target, 'node_modules', '@orkestrel', 'scaffold', 'dist', 'bin', 'main.js')
|
|
516
523
|
if (existsSync(installed)) return [process.execPath, installed]
|
|
517
524
|
const own = join(target, 'dist', 'bin', 'main.js')
|
|
518
|
-
if (
|
|
525
|
+
if (readString(readManifest(target), 'name') === SCAFFOLD && existsSync(own))
|
|
526
|
+
return [process.execPath, own]
|
|
519
527
|
return []
|
|
520
528
|
}
|
|
521
529
|
|
|
@@ -1274,32 +1282,51 @@ export function readReceipt(target: string): OverwriteReceipt | undefined {
|
|
|
1274
1282
|
*
|
|
1275
1283
|
* @param runner - The visit's state.
|
|
1276
1284
|
* @param name - The package name the manifest declares.
|
|
1277
|
-
* @
|
|
1278
|
-
*
|
|
1285
|
+
* @param format - The evidence collected by this invocation's format step. Without it, paths outside
|
|
1286
|
+
* the overwrite receipt and manifest pair are refused.
|
|
1287
|
+
* @returns Nothing after the rows are appended; each attributed group is committed separately when
|
|
1288
|
+
* every dirty path belongs to the overwrite or this invocation's formatter rewrites.
|
|
1279
1289
|
*/
|
|
1280
|
-
export function runRecord(runner: Runner, name: string | undefined): void {
|
|
1290
|
+
export function runRecord(runner: Runner, name: string | undefined, format?: FormatReceipt): void {
|
|
1281
1291
|
if (name === SCAFFOLD) {
|
|
1282
1292
|
appendStep(runner, 'record', 'git commit', `skipped: ${SCAFFOLD}`)
|
|
1283
1293
|
return
|
|
1284
1294
|
}
|
|
1285
1295
|
if (refuseLocalSpecs(runner, 'record')) return
|
|
1286
1296
|
if (runner.dry) {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1297
|
+
for (const message of ['Overwrite with scaffold <version>', 'Format with oxfmt <version>']) {
|
|
1298
|
+
runStep(
|
|
1299
|
+
runner,
|
|
1300
|
+
'record',
|
|
1301
|
+
'git',
|
|
1302
|
+
['--literal-pathspecs', 'add', '-A', '--pathspec-from-file=-', '--pathspec-file-nul'],
|
|
1303
|
+
runner.target,
|
|
1304
|
+
)
|
|
1305
|
+
runStep(
|
|
1306
|
+
runner,
|
|
1307
|
+
'record',
|
|
1308
|
+
'git',
|
|
1309
|
+
[
|
|
1310
|
+
'--literal-pathspecs',
|
|
1311
|
+
'commit',
|
|
1312
|
+
'--only',
|
|
1313
|
+
'-m',
|
|
1314
|
+
message,
|
|
1315
|
+
'--pathspec-from-file=-',
|
|
1316
|
+
'--pathspec-file-nul',
|
|
1317
|
+
],
|
|
1318
|
+
runner.target,
|
|
1319
|
+
)
|
|
1320
|
+
}
|
|
1321
|
+
return
|
|
1322
|
+
}
|
|
1323
|
+
if (format === undefined)
|
|
1324
|
+
appendStep(
|
|
1295
1325
|
runner,
|
|
1296
1326
|
'record',
|
|
1297
|
-
'
|
|
1298
|
-
|
|
1299
|
-
runner.target,
|
|
1327
|
+
'attribute format paths',
|
|
1328
|
+
'format evidence is absent in this run; only overwrite receipt paths and the manifest pair can be committed',
|
|
1300
1329
|
)
|
|
1301
|
-
return
|
|
1302
|
-
}
|
|
1303
1330
|
const status = runStep(
|
|
1304
1331
|
runner,
|
|
1305
1332
|
'record',
|
|
@@ -1337,17 +1364,20 @@ export function runRecord(runner: Runner, name: string | undefined): void {
|
|
|
1337
1364
|
const allowed = [...receipt.written, ...receipt.removed, 'package.json', 'package-lock.json'].map(
|
|
1338
1365
|
(path) => normalizeSlashes(relative(runner.target, resolve(runner.target, path))),
|
|
1339
1366
|
)
|
|
1340
|
-
const
|
|
1341
|
-
(
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1367
|
+
const overwritten = dirty.filter((path) =>
|
|
1368
|
+
allowed.some(
|
|
1369
|
+
(entry) =>
|
|
1370
|
+
entry !== '' &&
|
|
1371
|
+
entry !== '..' &&
|
|
1372
|
+
!entry.startsWith('../') &&
|
|
1373
|
+
!isAbsolute(entry) &&
|
|
1374
|
+
path === entry,
|
|
1375
|
+
),
|
|
1376
|
+
)
|
|
1377
|
+
const formatted = dirty.filter(
|
|
1378
|
+
(path) => !overwritten.includes(path) && format?.paths.includes(path),
|
|
1350
1379
|
)
|
|
1380
|
+
const outside = dirty.filter((path) => !overwritten.includes(path) && !formatted.includes(path))
|
|
1351
1381
|
if (outside.length > 0) {
|
|
1352
1382
|
appendStep(
|
|
1353
1383
|
runner,
|
|
@@ -1358,36 +1388,129 @@ export function runRecord(runner: Runner, name: string | undefined): void {
|
|
|
1358
1388
|
)
|
|
1359
1389
|
return
|
|
1360
1390
|
}
|
|
1361
|
-
|
|
1391
|
+
if (formatted.length > 0 && (format?.version === undefined || !VERSION.test(format.version))) {
|
|
1392
|
+
appendStep(
|
|
1393
|
+
runner,
|
|
1394
|
+
'record',
|
|
1395
|
+
'read formatter version',
|
|
1396
|
+
'cannot read the installed formatter version from node_modules/oxfmt/package.json; restore the oxfmt install before recording',
|
|
1397
|
+
1,
|
|
1398
|
+
)
|
|
1399
|
+
return
|
|
1400
|
+
}
|
|
1401
|
+
for (const group of [
|
|
1402
|
+
{ paths: overwritten, message: `Overwrite with scaffold ${receipt.version}` },
|
|
1403
|
+
{ paths: formatted, message: `Format with oxfmt ${format?.version}` },
|
|
1404
|
+
]) {
|
|
1405
|
+
if (group.paths.length === 0) continue
|
|
1406
|
+
const input = `${group.paths.join('\0')}\0`
|
|
1407
|
+
runStep(
|
|
1408
|
+
runner,
|
|
1409
|
+
'record',
|
|
1410
|
+
'git',
|
|
1411
|
+
['--literal-pathspecs', 'add', '-A', '--pathspec-from-file=-', '--pathspec-file-nul'],
|
|
1412
|
+
runner.target,
|
|
1413
|
+
readVerdict,
|
|
1414
|
+
input,
|
|
1415
|
+
)
|
|
1416
|
+
if (failed(runner.steps)) return
|
|
1417
|
+
runStep(
|
|
1418
|
+
runner,
|
|
1419
|
+
'record',
|
|
1420
|
+
'git',
|
|
1421
|
+
[
|
|
1422
|
+
'--literal-pathspecs',
|
|
1423
|
+
'commit',
|
|
1424
|
+
'--only',
|
|
1425
|
+
'-m',
|
|
1426
|
+
group.message,
|
|
1427
|
+
'--pathspec-from-file=-',
|
|
1428
|
+
'--pathspec-file-nul',
|
|
1429
|
+
],
|
|
1430
|
+
runner.target,
|
|
1431
|
+
readVerdict,
|
|
1432
|
+
input,
|
|
1433
|
+
)
|
|
1434
|
+
if (failed(runner.steps)) return
|
|
1435
|
+
}
|
|
1436
|
+
if (failed(runner.steps)) return
|
|
1437
|
+
runStep(runner, 'record', 'git', ['status', '--porcelain'], runner.target, (result) =>
|
|
1438
|
+
result.status === 0 && result.stdout.trim() !== ''
|
|
1439
|
+
? { exit: 1, note: `tree remains dirty: ${result.stdout}` }
|
|
1440
|
+
: readVerdict(result),
|
|
1441
|
+
)
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* Runs the formatter and attributes paths from the dirty sets read immediately before and after it.
|
|
1446
|
+
*
|
|
1447
|
+
* @param runner - The visit's state.
|
|
1448
|
+
* @returns This invocation's evidence, or undefined for a dry run or a failed step.
|
|
1449
|
+
*/
|
|
1450
|
+
export function runFormat(runner: Runner): FormatReceipt | undefined {
|
|
1451
|
+
if (runner.dry) {
|
|
1452
|
+
runNpmStep(runner, 'format', ['run', 'format'])
|
|
1453
|
+
return undefined
|
|
1454
|
+
}
|
|
1455
|
+
const version = readString(readManifest(join(runner.target, 'node_modules', 'oxfmt')), 'version')
|
|
1456
|
+
const before = runStep(
|
|
1362
1457
|
runner,
|
|
1363
|
-
'
|
|
1458
|
+
'format',
|
|
1364
1459
|
'git',
|
|
1365
|
-
['
|
|
1460
|
+
['status', '--porcelain=v1', '-z', '--untracked-files=all'],
|
|
1366
1461
|
runner.target,
|
|
1367
|
-
readVerdict,
|
|
1368
|
-
`${dirty.join('\0')}\0`,
|
|
1369
1462
|
)
|
|
1370
|
-
if (failed(runner.steps)) return
|
|
1371
|
-
|
|
1463
|
+
if (before?.status !== 0 || failed(runner.steps)) return undefined
|
|
1464
|
+
runNpmStep(runner, 'format', ['run', 'format'])
|
|
1465
|
+
if (failed(runner.steps)) return undefined
|
|
1466
|
+
const after = runStep(
|
|
1372
1467
|
runner,
|
|
1373
|
-
'
|
|
1468
|
+
'format',
|
|
1374
1469
|
'git',
|
|
1375
|
-
['
|
|
1470
|
+
['status', '--porcelain=v1', '-z', '--untracked-files=all'],
|
|
1376
1471
|
runner.target,
|
|
1377
1472
|
)
|
|
1378
|
-
if (failed(runner.steps)) return
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1473
|
+
if (after?.status !== 0 || failed(runner.steps)) return undefined
|
|
1474
|
+
const prior = new Set(readDirtyPaths(before.stdout))
|
|
1475
|
+
return {
|
|
1476
|
+
paths: [...new Set(readDirtyPaths(after.stdout))].filter((path) => !prior.has(path)),
|
|
1477
|
+
version,
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* Moves one declared range to the registry caret of a release, keeping every other major a
|
|
1483
|
+
* disjunctive range admits.
|
|
1484
|
+
*
|
|
1485
|
+
* @remarks
|
|
1486
|
+
* A range of one comparator set becomes the caret. A range joined by `||` names one supported major
|
|
1487
|
+
* per arm, so only the arm in the release's major becomes the caret; a range with no arm in that
|
|
1488
|
+
* major stays as declared, which keeps the wave inside each declared major.
|
|
1489
|
+
*
|
|
1490
|
+
* @param current - The declared range.
|
|
1491
|
+
* @param latest - The release's version.
|
|
1492
|
+
* @returns The moved range.
|
|
1493
|
+
* @example
|
|
1494
|
+
* ```ts
|
|
1495
|
+
* moveRange('^4.1.11 || ^5.0.4', '5.0.5') // '^4.1.11 || ^5.0.5'
|
|
1496
|
+
* ```
|
|
1497
|
+
*/
|
|
1498
|
+
export function moveRange(current: unknown, latest: string): unknown {
|
|
1499
|
+
const caret = `^${latest}`
|
|
1500
|
+
if (typeof current !== 'string' || !current.includes('||')) return caret
|
|
1501
|
+
const major = /^(\d+)\./u.exec(latest)?.[1]
|
|
1502
|
+
return current
|
|
1503
|
+
.split(/\s*\|\|\s*/u)
|
|
1504
|
+
.map((arm) => (/^[\^~=v\s]*(\d+)/u.exec(arm)?.[1] === major ? caret : arm))
|
|
1505
|
+
.join(' || ')
|
|
1384
1506
|
}
|
|
1385
1507
|
|
|
1386
1508
|
/**
|
|
1387
1509
|
* Moves each named dependency to the registry caret of its latest release.
|
|
1388
1510
|
*
|
|
1389
1511
|
* @remarks
|
|
1390
|
-
* A later release of the same name reads the range the earlier reading wrote.
|
|
1512
|
+
* A later release of the same name reads the range the earlier reading wrote. A disjunctive range
|
|
1513
|
+
* moves only its arm in the release's major, per {@link moveRange}.
|
|
1391
1514
|
*
|
|
1392
1515
|
* @param ranges - The block's ranges by name.
|
|
1393
1516
|
* @param releases - The audit's release readings.
|
|
@@ -1400,12 +1523,16 @@ export function computeRanges(
|
|
|
1400
1523
|
return releases.reduce<RangeMove>(
|
|
1401
1524
|
(state, release) => {
|
|
1402
1525
|
if (release.latest === undefined || !(release.name in state.ranges)) return state
|
|
1403
|
-
const
|
|
1404
|
-
|
|
1526
|
+
const current = state.ranges[release.name]
|
|
1527
|
+
const next = moveRange(current, release.latest)
|
|
1528
|
+
return current === next
|
|
1405
1529
|
? state
|
|
1406
1530
|
: {
|
|
1407
|
-
ranges: { ...state.ranges, [release.name]:
|
|
1408
|
-
moved: [
|
|
1531
|
+
ranges: { ...state.ranges, [release.name]: next },
|
|
1532
|
+
moved: [
|
|
1533
|
+
...state.moved,
|
|
1534
|
+
`${release.name} ${typeof current === 'string' ? current : String(release.range)} -> ${String(next)}`,
|
|
1535
|
+
],
|
|
1409
1536
|
}
|
|
1410
1537
|
},
|
|
1411
1538
|
{ ranges, moved: [] },
|
|
@@ -1716,7 +1843,14 @@ export function runVisit(argv: readonly string[]): Visit | undefined {
|
|
|
1716
1843
|
}
|
|
1717
1844
|
const scaffold = resolveScaffold(target)
|
|
1718
1845
|
if (scaffold.length === 0) {
|
|
1719
|
-
|
|
1846
|
+
const declared = [...readRanges(readManifest(target) ?? {}, RANGE_FIELDS).keys()].some((key) =>
|
|
1847
|
+
key.endsWith(` ${SCAFFOLD}`),
|
|
1848
|
+
)
|
|
1849
|
+
console.error(
|
|
1850
|
+
declared
|
|
1851
|
+
? `wave: no @orkestrel/scaffold executable under ${target}; run npm install to install its declared @orkestrel/scaffold dependency first`
|
|
1852
|
+
: `wave: no @orkestrel/scaffold executable under ${target}, and its manifest declares none; run npm install --save-dev @orkestrel/scaffold first`,
|
|
1853
|
+
)
|
|
1720
1854
|
return undefined
|
|
1721
1855
|
}
|
|
1722
1856
|
const [scaffoldFile, ...scaffoldPrefix] = scaffold
|
|
@@ -1773,9 +1907,8 @@ export function runVisit(argv: readonly string[]): Visit | undefined {
|
|
|
1773
1907
|
selected.has('pins') && !failed(runner.steps)
|
|
1774
1908
|
? runPins(runner, before, readOption(argv, '--prior') ?? version)
|
|
1775
1909
|
: undefined
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
if (selected.has('record') && !failed(runner.steps)) runRecord(runner, name)
|
|
1910
|
+
const format = selected.has('format') && !failed(runner.steps) ? runFormat(runner) : undefined
|
|
1911
|
+
if (selected.has('record') && !failed(runner.steps)) runRecord(runner, name, format)
|
|
1779
1912
|
if (selected.has('gates') && !failed(runner.steps)) {
|
|
1780
1913
|
for (const gate of GATES) {
|
|
1781
1914
|
if (failed(runner.steps)) break
|