@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.
- package/dist/agents/skills/orkestrel-dispatch/scripts/bench.js +61 -96
- package/dist/agents/skills/orkestrel-dispatch/scripts/brief.js +48 -76
- package/dist/agents/skills/orkestrel-dispatch/scripts/chain.js +27 -66
- package/dist/agents/skills/orkestrel-dispatch/scripts/cite.js +31 -64
- package/dist/agents/skills/orkestrel-dispatch/scripts/launch.js +43 -57
- package/dist/agents/skills/orkestrel-dispatch/scripts/login.js +43 -86
- package/dist/agents/skills/orkestrel-dispatch/scripts/patch.js +68 -104
- package/dist/agents/skills/orkestrel-dispatch/scripts/result.js +35 -69
- package/dist/agents/skills/orkestrel-dispatch/scripts/sweep.js +47 -84
- package/dist/agents/skills/orkestrel-falsify/scripts/mutate.js +134 -116
- package/dist/agents/skills/orkestrel-harden/scripts/discovery.js +38 -90
- package/dist/agents/skills/orkestrel-harden/scripts/interleave.js +39 -103
- package/dist/agents/skills/orkestrel-harden/scripts/measure.js +40 -89
- package/dist/agents/skills/orkestrel-harden/scripts/titles.js +41 -87
- package/dist/agents/skills/orkestrel-parallel/scripts/cases.js +43 -88
- package/dist/agents/skills/orkestrel-parallel/scripts/lane.js +1018 -194
- package/dist/agents/skills/orkestrel-publish/scripts/compare.js +40 -60
- package/dist/agents/skills/orkestrel-publish/scripts/pins.js +47 -81
- package/dist/agents/skills/orkestrel-publish/scripts/steps.js +66 -104
- package/dist/agents/skills/orkestrel-publish/scripts/swap.js +74 -88
- package/dist/agents/skills/orkestrel-publish/scripts/wave.js +95 -108
- package/dist/agents/skills/orkestrel-publish/scripts/window.js +55 -96
- package/dist/agents/skills/orkestrel-scout/scripts/map.js +54 -101
- package/dist/bin/main.js +30 -6
- package/dist/bin/main.js.map +1 -1
- package/dist/host/agents/orchestration.md +1 -0
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/bench.ts +81 -97
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/brief.ts +64 -72
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/chain.ts +41 -63
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/cite.ts +56 -79
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/launch.ts +61 -74
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/login.ts +59 -89
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/patch.ts +87 -106
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/result.ts +57 -76
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/sweep.ts +73 -88
- package/dist/host/agents/skills/orkestrel-falsify/SKILL.md +2 -2
- package/dist/host/agents/skills/orkestrel-falsify/scripts/mutate.ts +167 -119
- package/dist/host/agents/skills/orkestrel-harden/references/methods.md +1 -1
- package/dist/host/agents/skills/orkestrel-harden/scripts/discovery.ts +58 -75
- package/dist/host/agents/skills/orkestrel-harden/scripts/interleave.ts +55 -99
- package/dist/host/agents/skills/orkestrel-harden/scripts/measure.ts +59 -90
- package/dist/host/agents/skills/orkestrel-harden/scripts/titles.ts +60 -80
- package/dist/host/agents/skills/orkestrel-parallel/SKILL.md +4 -4
- package/dist/host/agents/skills/orkestrel-parallel/scripts/cases.ts +71 -108
- package/dist/host/agents/skills/orkestrel-parallel/scripts/lane.ts +1288 -239
- package/dist/host/agents/skills/orkestrel-publish/references/wave.md +10 -6
- package/dist/host/agents/skills/orkestrel-publish/scripts/compare.ts +58 -79
- package/dist/host/agents/skills/orkestrel-publish/scripts/pins.ts +66 -87
- package/dist/host/agents/skills/orkestrel-publish/scripts/steps.ts +84 -102
- package/dist/host/agents/skills/orkestrel-publish/scripts/swap.ts +92 -99
- package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +130 -126
- package/dist/host/agents/skills/orkestrel-publish/scripts/window.ts +82 -120
- package/dist/host/agents/skills/orkestrel-scout/SKILL.md +3 -3
- package/dist/host/agents/skills/orkestrel-scout/scripts/map.ts +85 -112
- package/dist/host/claude/agents/orkestrel.md +54 -54
- package/dist/host/claude/rules/documentation.md +1 -1
- package/dist/host/claude/rules/patterns.md +5 -4
- package/dist/host/claude/rules/styles.md +1 -1
- package/dist/host/claude/rules/tests.md +8 -3
- package/dist/host/claude/rules/workspace.md +47 -35
- package/dist/host/configs/helpers.ts +40 -15
- package/dist/host/dotfiles/oxlintrc.json +62 -0
- package/dist/host/guides/browser.md +1 -1
- package/dist/host/guides/form.md +79 -4
- package/dist/host/guides/queue.md +3 -1
- package/dist/host/guides/scaffold.md +95 -67
- package/dist/host/guides/table.md +20 -6
- package/dist/host/guides/test.md +342 -202
- package/dist/host/guides/workflow.md +4 -2
- package/dist/host/manifest.json +48 -48
- package/dist/host/tests/config.test.ts +201 -11
- package/dist/host/tests/policy.test.ts +15 -22
- package/dist/host/tests/setupPolicy.ts +43 -36
- package/dist/src/core/index.cjs +194 -97
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +27 -13
- package/dist/src/core/index.d.ts +27 -13
- package/dist/src/core/index.js +192 -97
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +8 -9
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +1 -1
- package/dist/src/server/index.d.ts +1 -1
- package/dist/src/server/index.js +8 -9
- package/dist/src/server/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,78 +1,43 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { setTimeout } from 'node:timers/promises';
|
|
3
4
|
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { parseArgs } from 'node:util';
|
|
4
6
|
/** Holds the milliseconds between two polls of the registry. */
|
|
5
7
|
export const POLL_MS = 5_000;
|
|
6
8
|
/** Matches the acceptance line `npm publish` prints and captures the name and the version. */
|
|
7
9
|
export const ACCEPTED = /^\+ (\S+)@(\S+)\s*$/mu;
|
|
8
|
-
/** Lists every flag the script reads, value flags and switches alike. */
|
|
9
|
-
export const FLAGS = [
|
|
10
|
-
'--whoami',
|
|
11
|
-
'--login',
|
|
12
|
-
'--publish',
|
|
13
|
-
'--confirm',
|
|
14
|
-
'--wait',
|
|
15
|
-
'--otp',
|
|
16
|
-
'--json',
|
|
17
|
-
];
|
|
18
10
|
/** Holds the usage line the script prints when no mode or two modes were given. */
|
|
19
11
|
export const USAGE = 'usage: window.ts --whoami [--wait SECONDS] | --login [--wait SECONDS] | --publish DIR... --otp CODE [--json] | --confirm NAME@VERSION... [--wait SECONDS]';
|
|
12
|
+
/** Declares every flag the script reads, for `parseArgs`. */
|
|
13
|
+
export const OPTIONS = Object.freeze({
|
|
14
|
+
whoami: Object.freeze({ type: 'boolean' }),
|
|
15
|
+
login: Object.freeze({ type: 'boolean' }),
|
|
16
|
+
publish: Object.freeze({ type: 'boolean' }),
|
|
17
|
+
confirm: Object.freeze({ type: 'boolean' }),
|
|
18
|
+
wait: Object.freeze({ type: 'string' }),
|
|
19
|
+
otp: Object.freeze({ type: 'string' }),
|
|
20
|
+
json: Object.freeze({ type: 'boolean' }),
|
|
21
|
+
});
|
|
20
22
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* Reads `--flag value` pairs: the first occurrence of a flag wins, a following value that opens
|
|
25
|
-
* with `--` is a missing value, and the `--flag=value` form is not read.
|
|
26
|
-
*
|
|
27
|
-
* @param argv - The arguments after the script path.
|
|
28
|
-
* @param name - The flag, such as `--otp`.
|
|
29
|
-
* @returns The value after the flag, or undefined when the flag is absent, last, or followed by
|
|
30
|
-
* another flag.
|
|
31
|
-
*/
|
|
32
|
-
export function readOption(argv, name) {
|
|
33
|
-
const index = argv.indexOf(name);
|
|
34
|
-
const value = index === -1 ? undefined : argv[index + 1];
|
|
35
|
-
return value === undefined || value.startsWith('--') ? undefined : value;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Names the value flags a caller gave with no value.
|
|
39
|
-
*
|
|
40
|
-
* @param argv - The arguments after the script path.
|
|
41
|
-
* @param names - The flags that take a value.
|
|
42
|
-
* @returns Each named flag that appears last or is followed by another flag, in argument order.
|
|
43
|
-
*/
|
|
44
|
-
export function readMissingFlags(argv, names) {
|
|
45
|
-
return names.filter((name) => argv.includes(name) && readOption(argv, name) === undefined);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Names the flags a caller gave that the script does not read.
|
|
49
|
-
*
|
|
50
|
-
* @remarks
|
|
51
|
-
* Reads the arguments before a bare `--`, which opens a command a script passes on. A `--flag=value`
|
|
52
|
-
* argument is unknown, because the script reads no such form.
|
|
53
|
-
*
|
|
54
|
-
* @param argv - The arguments after the script path.
|
|
55
|
-
* @param flags - Every flag the script reads, value flags and switches alike.
|
|
56
|
-
* @returns Each argument that opens with `--` and is not a read flag, in argument order.
|
|
57
|
-
*/
|
|
58
|
-
export function readUnknownFlags(argv, flags) {
|
|
59
|
-
const end = argv.indexOf('--');
|
|
60
|
-
return (end === -1 ? argv : argv.slice(0, end)).filter((argument) => argument.startsWith('--') && !flags.includes(argument));
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Reads the values that follow a flag up to the next flag.
|
|
23
|
+
* Parses the arguments in strict mode against `OPTIONS`.
|
|
64
24
|
*
|
|
65
25
|
* @param argv - The arguments after the script path.
|
|
66
|
-
* @
|
|
67
|
-
* @returns The values between the flag and the next `--` argument, empty when the flag is absent.
|
|
26
|
+
* @returns The values and positionals, or the message `parseArgs` refused the arguments with.
|
|
68
27
|
*/
|
|
69
|
-
export function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
28
|
+
export function parseArguments(argv) {
|
|
29
|
+
try {
|
|
30
|
+
const { values, positionals } = parseArgs({
|
|
31
|
+
args: [...argv],
|
|
32
|
+
options: OPTIONS,
|
|
33
|
+
strict: true,
|
|
34
|
+
allowPositionals: true,
|
|
35
|
+
});
|
|
36
|
+
return { success: true, value: { values, positionals } };
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
40
|
+
}
|
|
76
41
|
}
|
|
77
42
|
/**
|
|
78
43
|
* Parses a whole text as one JSON object.
|
|
@@ -133,17 +98,6 @@ export function runNpm(args, cwd) {
|
|
|
133
98
|
...(cwd === undefined ? {} : { cwd }),
|
|
134
99
|
});
|
|
135
100
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Waits for a number of milliseconds.
|
|
138
|
-
*
|
|
139
|
-
* @param ms - The delay.
|
|
140
|
-
* @returns A promise that settles after the delay.
|
|
141
|
-
*/
|
|
142
|
-
export function waitFor(ms) {
|
|
143
|
-
return new Promise((settle) => {
|
|
144
|
-
setTimeout(settle, ms);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
101
|
/**
|
|
148
102
|
* Reads the account `npm whoami` names once.
|
|
149
103
|
*
|
|
@@ -165,7 +119,7 @@ export async function pollWhoami(waitSeconds, started = Date.now()) {
|
|
|
165
119
|
const user = readWhoami();
|
|
166
120
|
if (user !== undefined || Date.now() - started >= waitSeconds * 1000)
|
|
167
121
|
return user;
|
|
168
|
-
await
|
|
122
|
+
await setTimeout(POLL_MS);
|
|
169
123
|
return pollWhoami(waitSeconds, started);
|
|
170
124
|
}
|
|
171
125
|
/**
|
|
@@ -192,7 +146,7 @@ export async function confirmServed(name, version, waitSeconds, started = Date.n
|
|
|
192
146
|
const served = readServed(name, version);
|
|
193
147
|
if (served || Date.now() - started >= waitSeconds * 1000)
|
|
194
148
|
return served;
|
|
195
|
-
await
|
|
149
|
+
await setTimeout(POLL_MS);
|
|
196
150
|
return confirmServed(name, version, waitSeconds, started);
|
|
197
151
|
}
|
|
198
152
|
/**
|
|
@@ -307,39 +261,44 @@ export async function publishAll(directories, otp, waitSeconds) {
|
|
|
307
261
|
* @returns The exit code: 0 when the mode succeeded, 3 when it did not, 64 on usage.
|
|
308
262
|
*/
|
|
309
263
|
export async function main(argv) {
|
|
310
|
-
const
|
|
311
|
-
if (
|
|
312
|
-
console.error(`window:
|
|
264
|
+
const parsed = parseArguments(argv);
|
|
265
|
+
if (!parsed.success) {
|
|
266
|
+
console.error(`window: ${parsed.error}; ${USAGE}`);
|
|
267
|
+
return 64;
|
|
268
|
+
}
|
|
269
|
+
const { values, positionals } = parsed.value;
|
|
270
|
+
const modes = [values.whoami, values.login, values.publish, values.confirm].filter((value) => value === true);
|
|
271
|
+
if (modes.length > 1) {
|
|
272
|
+
console.error(USAGE);
|
|
313
273
|
return 64;
|
|
314
274
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
275
|
+
const given = typeof values.wait === 'string' ? values.wait : undefined;
|
|
276
|
+
const wait = Number(given ?? 120);
|
|
277
|
+
if (given !== undefined && (given.trim() === '' || !Number.isFinite(wait) || wait < 0)) {
|
|
278
|
+
console.error(`window: --wait takes a number of seconds from 0, not ${JSON.stringify(given)}; ${USAGE}`);
|
|
318
279
|
return 64;
|
|
319
280
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (modes.length > 1 || (argv.includes('--wait') && (!Number.isFinite(wait) || wait < 0))) {
|
|
323
|
-
console.error('usage: window.ts names one mode (--whoami | --login | --publish | --confirm), and --wait takes a number of seconds');
|
|
281
|
+
if (positionals.length > 0 && values.publish !== true && values.confirm !== true) {
|
|
282
|
+
console.error(`window: ${positionals.map((value) => JSON.stringify(value)).join(', ')} given without --publish or --confirm, the modes that take a list; ${USAGE}`);
|
|
324
283
|
return 64;
|
|
325
284
|
}
|
|
326
|
-
if (
|
|
327
|
-
const user = await pollWhoami(
|
|
285
|
+
if (values.whoami === true) {
|
|
286
|
+
const user = await pollWhoami(given === undefined ? 0 : wait);
|
|
328
287
|
console.log(JSON.stringify({ mode: 'whoami', user, live: user !== undefined }));
|
|
329
288
|
return user === undefined ? 3 : 0;
|
|
330
289
|
}
|
|
331
|
-
if (
|
|
290
|
+
if (values.login === true) {
|
|
332
291
|
const command = process.platform === 'win32'
|
|
333
292
|
? 'npm login --browser=false'
|
|
334
293
|
: "script -qfc 'npm login --browser=false' tmp/units/npm-login.log";
|
|
335
294
|
console.error(`window: run this in a real terminal, then approve the URL it prints on its first line: ${command}`);
|
|
336
|
-
const user = await pollWhoami(
|
|
295
|
+
const user = await pollWhoami(given === undefined ? 300 : wait);
|
|
337
296
|
console.log(JSON.stringify({ mode: 'login', command, user, live: user !== undefined }));
|
|
338
297
|
return user === undefined ? 3 : 0;
|
|
339
298
|
}
|
|
340
|
-
if (
|
|
341
|
-
const directories =
|
|
342
|
-
const otp =
|
|
299
|
+
if (values.publish === true) {
|
|
300
|
+
const directories = positionals;
|
|
301
|
+
const otp = typeof values.otp === 'string' ? values.otp : undefined;
|
|
343
302
|
if (directories.length === 0 ||
|
|
344
303
|
otp === undefined ||
|
|
345
304
|
!/^\d{6,8}$/u.test(otp) ||
|
|
@@ -350,7 +309,7 @@ export async function main(argv) {
|
|
|
350
309
|
for (const directory of directories) {
|
|
351
310
|
const root = findGitRoot(resolve(directory));
|
|
352
311
|
const entry = join(root, '.git');
|
|
353
|
-
if (
|
|
312
|
+
if (statSync(entry, { throwIfNoEntry: false })?.isFile() !== true)
|
|
354
313
|
continue;
|
|
355
314
|
const line = readFileSync(entry, 'utf8')
|
|
356
315
|
.split(/\r\n|\n/u)
|
|
@@ -376,7 +335,7 @@ export async function main(argv) {
|
|
|
376
335
|
return 3;
|
|
377
336
|
}
|
|
378
337
|
const uploads = await publishAll(directories, otp, wait);
|
|
379
|
-
if (
|
|
338
|
+
if (values.json === true)
|
|
380
339
|
console.log(JSON.stringify({ mode: 'publish', uploads }));
|
|
381
340
|
else {
|
|
382
341
|
for (const upload of uploads) {
|
|
@@ -385,8 +344,8 @@ export async function main(argv) {
|
|
|
385
344
|
}
|
|
386
345
|
return uploads.every((upload) => upload.accepted && upload.confirmed) ? 0 : 3;
|
|
387
346
|
}
|
|
388
|
-
if (
|
|
389
|
-
const targets =
|
|
347
|
+
if (values.confirm === true) {
|
|
348
|
+
const targets = positionals;
|
|
390
349
|
if (targets.length === 0 || targets.some((target) => !/^@?[^@]+@\S+$/u.test(target))) {
|
|
391
350
|
console.error('usage: window.ts --confirm NAME@VERSION... [--wait SECONDS]');
|
|
392
351
|
return 64;
|
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
// Map terrain before a brief, an absorption lane, or a rename. Run from the checkout root:
|
|
2
|
-
// node .agents/skills/orkestrel-scout/scripts/map.ts --tree PATH... [--headings PATH...] [--frontmatter PATH...] [--exports PATH...] [--census TERM...] [--refs PATH] [--anchors PATH...] [--paths a,b] [--ignore-case] [--json] [--out FILE]
|
|
3
|
-
// --tree lists every file under each path with its line count and size. --headings lists every
|
|
4
|
-
// Markdown heading with its line; a heading inside a fenced block is no heading, where a fence
|
|
5
|
-
// opens with a run of three or more backticks or tildes indented up to three spaces and closes with
|
|
6
|
-
// a run of the same character at least as long. --frontmatter lists every key of a Markdown
|
|
7
|
-
// frontmatter block, a TOML file, or a YAML file with its whole value, a nested key dotted under its
|
|
8
|
-
// parents (`interface.default_prompt`) and a TOML key under its table. --exports lists every
|
|
9
|
-
// `export` declaration line in a TypeScript file (a text reading, not the compiler's). --census
|
|
10
|
-
// lists every line carrying a term. --refs lists
|
|
11
|
-
// every line naming a path or its basename. --anchors lists every `§ Heading` reference whose
|
|
12
|
-
// heading the named file, or the same file, does not carry. Walks skip node_modules, .git, dist,
|
|
13
|
-
// tmp, .orkestrel, .idea, and host.json; --paths narrows a census or refs walk. Modes combine, each
|
|
14
|
-
// printing its section; --json prints one object; --out writes the output to FILE instead of the
|
|
15
|
-
// terminal. Give each flag once; a later duplicate is not read. A value that opens with `--` is a
|
|
16
|
-
// missing value, so census a custom property without its leading dashes. The script refuses a flag
|
|
17
|
-
// it does not read, the `--flag=value` form included, and names every unknown flag and every flag
|
|
18
|
-
// given with no value in one refusal. Exit 0, or 64 when no mode is given, a flag is given with no
|
|
19
|
-
// value, or a flag is unknown.
|
|
20
1
|
import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, statSync, writeFileSync, } from 'node:fs';
|
|
21
2
|
import { basename, dirname, join } from 'node:path';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
22
4
|
/** Matches an `export` declaration line and captures its kind and name. */
|
|
23
5
|
export const EXPORT = /^export\s+(?:default\s+)?(?:async\s+)?(?:abstract\s+)?(function\*?|const|let|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/u;
|
|
24
6
|
/** Matches a Markdown heading line and captures its marker and text. */
|
|
@@ -38,78 +20,52 @@ export const SKIPPED_DIRECTORIES = new Set([
|
|
|
38
20
|
'.orkestrel',
|
|
39
21
|
'.idea',
|
|
40
22
|
]);
|
|
41
|
-
/** Lists the flags that take a value. */
|
|
42
|
-
export const VALUE_FLAGS = [
|
|
43
|
-
'--tree',
|
|
44
|
-
'--headings',
|
|
45
|
-
'--frontmatter',
|
|
46
|
-
'--exports',
|
|
47
|
-
'--census',
|
|
48
|
-
'--refs',
|
|
49
|
-
'--anchors',
|
|
50
|
-
'--paths',
|
|
51
|
-
'--out',
|
|
52
|
-
];
|
|
53
|
-
/** Lists every flag the script reads, value flags and switches alike. */
|
|
54
|
-
export const FLAGS = [...VALUE_FLAGS, '--ignore-case', '--json'];
|
|
55
23
|
/** Holds the usage line printed when a call names no mode. */
|
|
56
|
-
export const USAGE = 'usage: map.ts [--tree PATH...] [--headings PATH...] [--frontmatter PATH...] [--exports PATH...] [--census TERM...] [--refs PATH] [--anchors PATH...] [--paths a,b] [--ignore-case] [--json] [--out FILE]';
|
|
24
|
+
export const USAGE = 'usage: map.ts [--tree PATH ...] [--headings PATH ...] [--frontmatter PATH ...] [--exports PATH ...] [--census TERM ...] [--refs PATH] [--anchors PATH ...] [--paths a,b] [--ignore-case] [--json] [--out FILE]; name one mode or more; each mode flag but --refs repeats, one value per flag';
|
|
25
|
+
/** Declares every flag the script reads, for `parseArgs`. */
|
|
26
|
+
export const OPTIONS = Object.freeze({
|
|
27
|
+
tree: Object.freeze({ type: 'string', multiple: true }),
|
|
28
|
+
headings: Object.freeze({ type: 'string', multiple: true }),
|
|
29
|
+
frontmatter: Object.freeze({ type: 'string', multiple: true }),
|
|
30
|
+
exports: Object.freeze({ type: 'string', multiple: true }),
|
|
31
|
+
census: Object.freeze({ type: 'string', multiple: true }),
|
|
32
|
+
refs: Object.freeze({ type: 'string' }),
|
|
33
|
+
anchors: Object.freeze({ type: 'string', multiple: true }),
|
|
34
|
+
paths: Object.freeze({ type: 'string' }),
|
|
35
|
+
'ignore-case': Object.freeze({ type: 'boolean' }),
|
|
36
|
+
json: Object.freeze({ type: 'boolean' }),
|
|
37
|
+
out: Object.freeze({ type: 'string' }),
|
|
38
|
+
});
|
|
57
39
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @remarks
|
|
61
|
-
* The first occurrence of a flag wins, a following value that opens with `--` is a missing value,
|
|
62
|
-
* and the `--flag=value` form is not read.
|
|
63
|
-
*
|
|
64
|
-
* @param argv - The arguments after the script path.
|
|
65
|
-
* @param name - The flag, such as `--paths`.
|
|
66
|
-
* @returns The value after the flag, or undefined when the flag is absent, last, or followed by
|
|
67
|
-
* another flag.
|
|
68
|
-
*/
|
|
69
|
-
export function readOption(argv, name) {
|
|
70
|
-
const index = argv.indexOf(name);
|
|
71
|
-
const value = index === -1 ? undefined : argv[index + 1];
|
|
72
|
-
return value === undefined || value.startsWith('--') ? undefined : value;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Names the value flags a caller gave with no value.
|
|
76
|
-
*
|
|
77
|
-
* @param argv - The arguments after the script path.
|
|
78
|
-
* @param names - The flags that take a value.
|
|
79
|
-
* @returns Each named flag that appears last or is followed by another flag, in argument order.
|
|
80
|
-
*/
|
|
81
|
-
export function readMissingFlags(argv, names) {
|
|
82
|
-
return names.filter((name) => argv.includes(name) && readOption(argv, name) === undefined);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Names the flags a caller gave that the script does not read.
|
|
86
|
-
*
|
|
87
|
-
* @remarks
|
|
88
|
-
* A `--flag=value` argument is unknown, because the script reads no such form. A bare `--` ends the
|
|
89
|
-
* scan.
|
|
40
|
+
* Parses the arguments in strict mode against `OPTIONS`.
|
|
90
41
|
*
|
|
91
42
|
* @param argv - The arguments after the script path.
|
|
92
|
-
* @
|
|
93
|
-
* @returns Each argument that opens with `--` and is not a read flag, in argument order.
|
|
43
|
+
* @returns The values and positionals, or the message `parseArgs` refused the arguments with.
|
|
94
44
|
*/
|
|
95
|
-
export function
|
|
96
|
-
|
|
97
|
-
|
|
45
|
+
export function parseArguments(argv) {
|
|
46
|
+
try {
|
|
47
|
+
const { values, positionals } = parseArgs({
|
|
48
|
+
args: [...argv],
|
|
49
|
+
options: OPTIONS,
|
|
50
|
+
strict: true,
|
|
51
|
+
allowPositionals: false,
|
|
52
|
+
});
|
|
53
|
+
return { success: true, value: { values, positionals } };
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
57
|
+
}
|
|
98
58
|
}
|
|
99
59
|
/**
|
|
100
|
-
*
|
|
60
|
+
* Collects the strings a repeatable flag's value holds.
|
|
101
61
|
*
|
|
102
|
-
* @param
|
|
103
|
-
* @
|
|
104
|
-
* @returns The values between the flag and the next `--` argument, empty when the flag is absent.
|
|
62
|
+
* @param value - The value `parseArgs` read for a flag declared with `multiple: true`.
|
|
63
|
+
* @returns Each string in order, empty when the flag never appears.
|
|
105
64
|
*/
|
|
106
|
-
export function
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const rest = argv.slice(index + 1);
|
|
111
|
-
const end = rest.findIndex((argument) => argument.startsWith('--'));
|
|
112
|
-
return end === -1 ? rest : rest.slice(0, end);
|
|
65
|
+
export function collectStrings(value) {
|
|
66
|
+
return Array.isArray(value)
|
|
67
|
+
? value.filter((member) => typeof member === 'string')
|
|
68
|
+
: [];
|
|
113
69
|
}
|
|
114
70
|
/**
|
|
115
71
|
* Normalizes a host path to forward slashes.
|
|
@@ -118,7 +74,7 @@ export function readList(argv, name) {
|
|
|
118
74
|
* @returns The same path with every backslash replaced by a slash.
|
|
119
75
|
*/
|
|
120
76
|
export function normalizeSlashes(path) {
|
|
121
|
-
return path.
|
|
77
|
+
return path.replaceAll('\\', '/');
|
|
122
78
|
}
|
|
123
79
|
/**
|
|
124
80
|
* Lists every regular file beneath a directory, skipping the directories the script never reads.
|
|
@@ -543,24 +499,21 @@ export function renderReport(report) {
|
|
|
543
499
|
* @returns The exit code: 0 on success, 64 on usage.
|
|
544
500
|
*/
|
|
545
501
|
export function main(argv) {
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
console.error(`map: ${[
|
|
550
|
-
...(unknown.length > 0 ? [`${unknown.join(', ')} is not a flag this script reads`] : []),
|
|
551
|
-
...(missing.length > 0 ? [`${missing.join(', ')} given with no value`] : []),
|
|
552
|
-
].join('; ')}; ${USAGE}`);
|
|
502
|
+
const parsed = parseArguments(argv);
|
|
503
|
+
if (!parsed.success) {
|
|
504
|
+
console.error(`map: ${parsed.error}; ${USAGE}`);
|
|
553
505
|
return 64;
|
|
554
506
|
}
|
|
555
|
-
const
|
|
556
|
-
const
|
|
557
|
-
const
|
|
558
|
-
const
|
|
559
|
-
const
|
|
560
|
-
const
|
|
561
|
-
const
|
|
562
|
-
const
|
|
563
|
-
const
|
|
507
|
+
const { values } = parsed.value;
|
|
508
|
+
const roots = (typeof values.paths === 'string' ? values.paths : '.').split(',');
|
|
509
|
+
const ignoreCase = values['ignore-case'] === true;
|
|
510
|
+
const tree = collectStrings(values.tree);
|
|
511
|
+
const headings = collectStrings(values.headings);
|
|
512
|
+
const frontmatter = collectStrings(values.frontmatter);
|
|
513
|
+
const exports = collectStrings(values.exports);
|
|
514
|
+
const census = collectStrings(values.census);
|
|
515
|
+
const refs = typeof values.refs === 'string' ? values.refs : undefined;
|
|
516
|
+
const anchors = collectStrings(values.anchors);
|
|
564
517
|
if (tree.length +
|
|
565
518
|
headings.length +
|
|
566
519
|
frontmatter.length +
|
|
@@ -581,8 +534,8 @@ export function main(argv) {
|
|
|
581
534
|
...(refs === undefined ? {} : { refs: mapRefs(refs, roots) }),
|
|
582
535
|
...(anchors.length > 0 ? { anchors: mapAnchors(anchors) } : {}),
|
|
583
536
|
};
|
|
584
|
-
const output =
|
|
585
|
-
const out =
|
|
537
|
+
const output = values.json === true ? `${JSON.stringify(report)}\n` : renderReport(report);
|
|
538
|
+
const out = typeof values.out === 'string' ? values.out : undefined;
|
|
586
539
|
if (out === undefined)
|
|
587
540
|
process.stdout.write(output);
|
|
588
541
|
else {
|
package/dist/bin/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { align, renderTable, strip, stripControls, width } from "@orkestrel/console";
|
|
3
3
|
import { attempt, isArray, isDefined, isError, isInstance, isRecord, isString, parseJSON } from "@orkestrel/contract";
|
|
4
|
-
import { ARTIFACT_GROUPS, AXES, BIN_ENTRY_PATH, CATALOG_AGENT_PATH, CONFORMANCE_TEST_PATH, Compiler, DEPENDENCY_NAME_PATTERN, ENVIRONMENTS, FRAMEWORKS, GLOBAL_SETUP_PATH, GUIDES_TEST_PATH, HOST_PATHS, INTEGRATION_TEST_PATH, JOURNEY_CONFIG_PATH, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, RESERVED_SHEET_NAMES, SERVICE_SETUP_PATH, SHEET_ENTRY_NAME, SHOWCASE_CONFIG_PATH, SHOWCASE_DEV_DEPENDENCIES, SHOWCASE_PAGES_PATH, SKILLS_CONFIG_PATH, STYLES_ENTRY_PATH, ScaffoldError, THEMES_BARREL_PATH, THEMES_ENTRY_PATH, TREE_TEST_PATH, blueprintToConfigArtifacts, blueprintToDevDependencies, blueprintToFaces, blueprintToManifestOverrides, blueprintToProjects, blueprintToScripts, blueprintToSheets, blueprintToTestArtifacts, blueprintToToolchainHolds, blueprintToWritableScripts, collectSurfaceAdvisories, collectSurfaceCollisions, compareSurfaceCollisions, compareVersions, createBlueprint, extractRangeMajor, extractVersion, isFloorPath, isScaffoldError, isSheetName, iterateAnswers, manifestToDependencies, manifestToName, matchesGuideRefusal, nameToGuide, parseExtension, replaceManifestOverrides, replaceManifestScripts, replacePlanRanges } from "../src/core/index.js";
|
|
4
|
+
import { ARTIFACT_GROUPS, AXES, BIN_ENTRY_PATH, CATALOG_AGENT_PATH, CONFORMANCE_TEST_PATH, Compiler, DEPENDENCY_NAME_PATTERN, ENVIRONMENTS, FRAMEWORKS, GLOBAL_SETUP_PATH, GUIDES_TEST_PATH, HOST_PATHS, INTEGRATION_TEST_PATH, JOURNEY_CONFIG_PATH, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, REPORTER_ENTRY_PATH, RESERVED_SHEET_NAMES, SERVICE_SETUP_PATH, SHEET_ENTRY_NAME, SHOWCASE_CONFIG_PATH, SHOWCASE_DEV_DEPENDENCIES, SHOWCASE_PAGES_PATH, SKILLS_CONFIG_PATH, STYLES_ENTRY_PATH, ScaffoldError, THEMES_BARREL_PATH, THEMES_ENTRY_PATH, TREE_TEST_PATH, blueprintToConfigArtifacts, blueprintToDevDependencies, blueprintToFaces, blueprintToManifestOverrides, blueprintToProjects, blueprintToScripts, blueprintToSheets, blueprintToTestArtifacts, blueprintToToolchainHolds, blueprintToWritableScripts, collectSurfaceAdvisories, collectSurfaceCollisions, compareSurfaceCollisions, compareVersions, createBlueprint, extractRangeMajor, extractVersion, isFloorPath, isScaffoldError, isSheetName, iterateAnswers, manifestToDependencies, manifestToName, matchesBarrel, matchesGuideRefusal, nameToGuide, parseExtension, replaceManifestOverrides, replaceManifestScripts, replacePlanRanges } from "../src/core/index.js";
|
|
5
5
|
import { MAX_INVENTORY_PATHS, Materializer, Upstream, filesToHost, isExactCaseFile, isPhysicalDirectory, isWorktree, listFiles, readFileText, readHostFloor, readHostManifest, readSnapshot, readSurfaceCandidate, readSurfaceFile, readSurfaceGuide, readSurfaceRecord, resolveContainedPath, resolveSurfaceLoader } from "../src/server/index.js";
|
|
6
6
|
import { join, normalize, resolve } from "node:path";
|
|
7
7
|
import { createDuplex } from "@orkestrel/process/server";
|
|
@@ -10,7 +10,7 @@ import { readdirSync } from "node:fs";
|
|
|
10
10
|
import { parseArgs } from "node:util";
|
|
11
11
|
var package_default = {
|
|
12
12
|
name: "@orkestrel/scaffold",
|
|
13
|
-
version: "0.0.
|
|
13
|
+
version: "0.0.134",
|
|
14
14
|
description: "Scaffold workspaces with commands: new, audit, surface, repair, catalog, and overwrite.",
|
|
15
15
|
keywords: [
|
|
16
16
|
"audit",
|
|
@@ -111,11 +111,11 @@ var package_default = {
|
|
|
111
111
|
},
|
|
112
112
|
devDependencies: {
|
|
113
113
|
"@microsoft/api-extractor": "^7.60.1",
|
|
114
|
-
"@orkestrel/browser": "^0.0.
|
|
115
|
-
"@orkestrel/guide": "^0.0.
|
|
114
|
+
"@orkestrel/browser": "^0.0.33",
|
|
115
|
+
"@orkestrel/guide": "^0.0.31",
|
|
116
116
|
"@orkestrel/html": "^0.0.16",
|
|
117
|
-
"@orkestrel/probe": "^0.0.
|
|
118
|
-
"@orkestrel/test": "^0.0.
|
|
117
|
+
"@orkestrel/probe": "^0.0.30",
|
|
118
|
+
"@orkestrel/test": "^0.0.37",
|
|
119
119
|
"@types/node": "^24.19.2",
|
|
120
120
|
"@vitest/browser-playwright": "^5.1.0",
|
|
121
121
|
"oxfmt": "^0.78.0",
|
|
@@ -2610,6 +2610,7 @@ var CLI = class {
|
|
|
2610
2610
|
const declared = manifestToName(manifest);
|
|
2611
2611
|
if (declared === void 0) throw new ScaffoldError("TARGET", `The manifest at ${target} declares no package name.`, { target });
|
|
2612
2612
|
const bin = resolveContainedPath(target, BIN_ENTRY_PATH);
|
|
2613
|
+
const reporter = resolveContainedPath(target, REPORTER_ENTRY_PATH);
|
|
2613
2614
|
const tests = resolveContainedPath(target, "tests");
|
|
2614
2615
|
const guides = resolveContainedPath(target, GUIDES_TEST_PATH);
|
|
2615
2616
|
const integration = resolveContainedPath(target, INTEGRATION_TEST_PATH);
|
|
@@ -2639,6 +2640,7 @@ var CLI = class {
|
|
|
2639
2640
|
app: targetToEnvironments(target, "app"),
|
|
2640
2641
|
dependencies: manifestToDependencies(manifest).runtime,
|
|
2641
2642
|
bin: bin !== void 0 && isExactCaseFile(bin),
|
|
2643
|
+
reporter: reporter !== void 0 && isExactCaseFile(reporter),
|
|
2642
2644
|
setup: [...setup],
|
|
2643
2645
|
guides: guides !== void 0 && isExactCaseFile(guides),
|
|
2644
2646
|
integration: integration !== void 0 && isExactCaseFile(integration),
|
|
@@ -2757,6 +2759,26 @@ var CLI = class {
|
|
|
2757
2759
|
groups: ["configs"]
|
|
2758
2760
|
};
|
|
2759
2761
|
}
|
|
2762
|
+
#barrelQuestion(target, blueprint) {
|
|
2763
|
+
if (!matchesBarrel(blueprint)) return void 0;
|
|
2764
|
+
const text = this.#manifest(target);
|
|
2765
|
+
const manifest = replaceManifestScripts(text, manifestToWritableScripts(text, blueprint)) ?? text;
|
|
2766
|
+
const parsed = parseJSON(manifest);
|
|
2767
|
+
const chain = collectScriptChain("build", isRecord(parsed) && isRecord(parsed.scripts) ? parsed.scripts : {}, /* @__PURE__ */ new Map());
|
|
2768
|
+
if (chain.visited.has("build:app:barrel")) return void 0;
|
|
2769
|
+
if (chain.unreadable.size > 0) return {
|
|
2770
|
+
field: "scripts",
|
|
2771
|
+
message: `The manifest at ${target} declares a build chain the audit could not read literally, so it cannot confirm that npm run build reaches the planned script build:app:barrel. The unreadable scripts are ${[...chain.unreadable].sort().join(", ")}, because each command is not a literal sequence of npm run scripts. Replace each with literal npm run script names.`,
|
|
2772
|
+
blocking: false,
|
|
2773
|
+
groups: ["manifest"]
|
|
2774
|
+
};
|
|
2775
|
+
return {
|
|
2776
|
+
field: "scripts",
|
|
2777
|
+
message: `The manifest at ${target} does not reach the planned script build:app:barrel from build, so npm run build does not emit dist/app/server/index.js. Invoke npm run build:app:barrel from the build chain, after npm run build:app:server.`,
|
|
2778
|
+
blocking: false,
|
|
2779
|
+
groups: ["manifest"]
|
|
2780
|
+
};
|
|
2781
|
+
}
|
|
2760
2782
|
#scriptQuestion(target, blueprint) {
|
|
2761
2783
|
const text = this.#manifest(target);
|
|
2762
2784
|
const writable = blueprintToWritableScripts(blueprint);
|
|
@@ -2899,6 +2921,8 @@ var CLI = class {
|
|
|
2899
2921
|
const script = this.#scriptQuestion(target, blueprint);
|
|
2900
2922
|
if (script !== void 0) questions.push(script);
|
|
2901
2923
|
}
|
|
2924
|
+
const barrel = this.#barrelQuestion(target, blueprint);
|
|
2925
|
+
if (barrel !== void 0) questions.push(barrel);
|
|
2902
2926
|
const project = this.#projectQuestion(target, blueprint, writing);
|
|
2903
2927
|
if (project !== void 0) questions.push(project);
|
|
2904
2928
|
const dependency = this.#dependencyQuestion(target, blueprint, writing, declaring);
|