@orkestrel/scaffold 0.0.107 → 0.0.109
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 +326 -91
- package/dist/agents/skills/orkestrel-dispatch/scripts/brief.js +110 -14
- package/dist/agents/skills/orkestrel-dispatch/scripts/chain.js +280 -0
- package/dist/agents/skills/orkestrel-dispatch/scripts/cite.js +188 -26
- package/dist/agents/skills/orkestrel-dispatch/scripts/launch.js +142 -43
- package/dist/agents/skills/orkestrel-dispatch/scripts/login.js +240 -62
- package/dist/agents/skills/orkestrel-dispatch/scripts/patch.js +323 -0
- package/dist/agents/skills/orkestrel-dispatch/scripts/result.js +169 -32
- package/dist/agents/skills/orkestrel-dispatch/scripts/sweep.js +368 -27
- package/dist/agents/skills/orkestrel-falsify/scripts/mutate.js +560 -0
- package/dist/agents/skills/orkestrel-harden/scripts/discovery.js +1052 -205
- package/dist/agents/skills/orkestrel-harden/scripts/measure.js +361 -0
- package/dist/agents/skills/orkestrel-harden/scripts/titles.js +455 -80
- package/dist/agents/skills/orkestrel-parallel/scripts/cases.js +327 -0
- package/dist/agents/skills/orkestrel-publish/scripts/compare.js +298 -51
- package/dist/agents/skills/orkestrel-publish/scripts/pins.js +170 -13
- package/dist/agents/skills/orkestrel-publish/scripts/swap.js +956 -191
- package/dist/agents/skills/orkestrel-publish/scripts/wave.js +707 -112
- package/dist/agents/skills/orkestrel-publish/scripts/window.js +235 -41
- package/dist/agents/skills/orkestrel-scout/scripts/map.js +341 -54
- package/dist/agents/templates/brief.md +1 -1
- package/dist/bin/main.js +51 -46
- package/dist/bin/main.js.map +1 -1
- package/dist/host/AGENTS.md +26 -20
- package/dist/host/agents/orchestration.md +98 -58
- package/dist/host/agents/platforms/posix.md +15 -0
- package/dist/host/agents/platforms/windows.md +37 -0
- package/dist/host/agents/skills/orkestrel-align/SKILL.md +10 -13
- package/dist/host/agents/skills/orkestrel-align/references/fleet.md +4 -10
- package/dist/host/agents/skills/orkestrel-align/references/integration.md +1 -1
- package/dist/host/agents/skills/orkestrel-build/SKILL.md +16 -48
- package/dist/host/agents/skills/orkestrel-build/agents/openai.yaml +1 -1
- package/dist/host/agents/skills/orkestrel-debrief/SKILL.md +19 -16
- package/dist/host/agents/skills/orkestrel-debrief/agents/openai.yaml +1 -1
- package/dist/host/agents/skills/orkestrel-debrief/references/field-testing.md +15 -28
- package/dist/host/agents/skills/orkestrel-debrief/references/instruction-audit.md +5 -6
- package/dist/host/agents/skills/orkestrel-debrief/references/retention.md +12 -14
- package/dist/host/agents/skills/orkestrel-dispatch/SKILL.md +36 -24
- package/dist/host/agents/skills/orkestrel-dispatch/references/launch.md +14 -11
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/bench.ts +366 -75
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/brief.ts +126 -16
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/chain.ts +323 -0
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/cite.ts +220 -31
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/launch.ts +176 -33
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/login.ts +294 -59
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/patch.ts +401 -0
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/result.ts +199 -34
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/sweep.ts +428 -27
- package/dist/host/agents/skills/orkestrel-falsify/SKILL.md +10 -8
- package/dist/host/agents/skills/orkestrel-falsify/references/brief.md +1 -5
- package/dist/host/agents/skills/orkestrel-falsify/references/reconcile.md +1 -1
- package/dist/host/agents/skills/orkestrel-falsify/scripts/mutate.ts +701 -0
- package/dist/host/agents/skills/orkestrel-harden/SKILL.md +16 -12
- package/dist/host/agents/skills/orkestrel-harden/references/bindings.md +23 -81
- package/dist/host/agents/skills/orkestrel-harden/references/centralization.md +4 -5
- package/dist/host/agents/skills/orkestrel-harden/references/contract.md +2 -0
- package/dist/host/agents/skills/orkestrel-harden/references/document.md +33 -0
- package/dist/host/agents/skills/orkestrel-harden/references/equivalence.md +6 -3
- package/dist/host/agents/skills/orkestrel-harden/references/hardening.md +8 -4
- package/dist/host/agents/skills/orkestrel-harden/references/research.md +2 -0
- package/dist/host/agents/skills/orkestrel-harden/scripts/discovery.ts +1272 -279
- package/dist/host/agents/skills/orkestrel-harden/scripts/measure.ts +425 -0
- package/dist/host/agents/skills/orkestrel-harden/scripts/titles.ts +603 -98
- package/dist/host/agents/skills/orkestrel-journey/SKILL.md +75 -98
- package/dist/host/agents/skills/orkestrel-journey/references/captures.md +54 -17
- package/dist/host/agents/skills/orkestrel-journey/references/decide.md +1 -20
- package/dist/host/agents/skills/orkestrel-journey/references/layer.md +21 -31
- package/dist/host/agents/skills/orkestrel-journey/references/styles.md +1 -1
- package/dist/host/agents/skills/orkestrel-parallel/SKILL.md +91 -30
- package/dist/host/agents/skills/orkestrel-parallel/agents/openai.yaml +2 -2
- package/dist/host/agents/skills/orkestrel-parallel/references/claude.md +34 -0
- package/dist/host/agents/skills/orkestrel-parallel/references/codex.md +29 -0
- package/dist/host/agents/skills/orkestrel-parallel/references/cursor.md +29 -0
- package/dist/host/agents/skills/orkestrel-parallel/references/t3.md +31 -0
- package/dist/host/agents/skills/orkestrel-parallel/scripts/cases.ts +389 -0
- package/dist/host/agents/skills/orkestrel-polish/SKILL.md +16 -20
- package/dist/host/agents/skills/orkestrel-polish/references/capture-harness.md +16 -26
- package/dist/host/agents/skills/orkestrel-publish/SKILL.md +12 -26
- package/dist/host/agents/skills/orkestrel-publish/agents/openai.yaml +2 -2
- package/dist/host/agents/skills/orkestrel-publish/references/adopt.md +23 -0
- package/dist/host/agents/skills/orkestrel-publish/references/release.md +4 -4
- package/dist/host/agents/skills/orkestrel-publish/references/wave.md +12 -10
- package/dist/host/agents/skills/orkestrel-publish/references/window.md +20 -25
- package/dist/host/agents/skills/orkestrel-publish/scripts/compare.ts +348 -59
- package/dist/host/agents/skills/orkestrel-publish/scripts/pins.ts +202 -22
- package/dist/host/agents/skills/orkestrel-publish/scripts/swap.ts +1061 -191
- package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +812 -140
- package/dist/host/agents/skills/orkestrel-publish/scripts/window.ts +280 -38
- package/dist/host/agents/skills/orkestrel-scout/SKILL.md +3 -3
- package/dist/host/agents/skills/orkestrel-scout/scripts/map.ts +428 -70
- package/dist/host/agents/templates/brief.md +1 -1
- package/dist/host/agents/transports/claude-cli.md +3 -3
- package/dist/host/agents/transports/codex.md +3 -8
- package/dist/host/agents/transports/cursor.md +2 -3
- package/dist/host/claude/AGENTS.md +7 -10
- package/dist/host/claude/agents/analyst.md +3 -3
- package/dist/host/claude/agents/astra.md +3 -3
- package/dist/host/claude/agents/builder.md +1 -1
- package/dist/host/claude/agents/checker.md +1 -1
- package/dist/host/claude/agents/distiller.md +1 -1
- package/dist/host/claude/agents/grok.md +1 -1
- package/dist/host/claude/agents/opus.md +2 -2
- package/dist/host/claude/agents/orkestrel.md +57 -90
- package/dist/host/claude/agents/researcher.md +1 -1
- package/dist/host/claude/agents/reviewer.md +4 -0
- package/dist/host/claude/agents/scout.md +1 -1
- package/dist/host/claude/agents/verifier.md +1 -1
- package/dist/host/claude/rules/application.md +14 -21
- package/dist/host/claude/rules/architecture.md +34 -44
- package/dist/host/claude/rules/browser.md +3 -4
- package/dist/host/claude/rules/campaign.md +55 -0
- package/dist/host/claude/rules/documentation.md +26 -11
- package/dist/host/claude/rules/names.md +9 -4
- package/dist/host/claude/rules/patterns.md +6 -7
- package/dist/host/claude/rules/portability.md +2 -3
- package/dist/host/claude/rules/quality.md +4 -5
- package/dist/host/claude/rules/styles.md +2 -2
- package/dist/host/claude/rules/tests.md +57 -114
- package/dist/host/claude/rules/typescript.md +8 -10
- package/dist/host/claude/rules/workspace.md +21 -19
- package/dist/host/claude/rules/writing.md +3 -3
- package/dist/host/claude/skills/orkestrel-dispatch/SKILL.md +1 -1
- package/dist/host/claude/skills/orkestrel-harden/SKILL.md +1 -1
- package/dist/host/claude/skills/orkestrel-parallel/SKILL.md +1 -1
- package/dist/host/claude/skills/orkestrel-publish/SKILL.md +1 -1
- package/dist/host/claude/skills/orkestrel-scout/SKILL.md +1 -1
- package/dist/host/codex/agents/analyst.toml +9 -3
- package/dist/host/codex/agents/astra.toml +3 -4
- package/dist/host/codex/agents/builder.toml +1 -1
- package/dist/host/codex/agents/opus.toml +3 -4
- package/dist/host/codex/agents/orkestrel.toml +1 -1
- package/dist/host/codex/agents/researcher.toml +2 -2
- package/dist/host/codex/agents/verifier.toml +1 -1
- package/dist/host/codex/config.toml +3 -3
- package/dist/host/configs/helpers.ts +21 -1
- package/dist/host/configs/policy.ts +405 -16
- package/dist/host/cursor/rules/orchestration.mdc +1 -0
- package/dist/host/dotfiles/oxlintrc.json +141 -5
- package/dist/host/guides/agent.md +111 -134
- package/dist/host/guides/capture.md +801 -0
- package/dist/host/guides/probe.md +27 -8
- package/dist/host/guides/scaffold.md +152 -19
- package/dist/host/guides/study.md +534 -440
- package/dist/host/guides/test.md +111 -44
- package/dist/host/manifest.json +199 -242
- package/dist/host/tests/config.test.ts +1558 -219
- package/dist/host/tests/policy.test.ts +127 -1
- package/dist/host/tests/setupPolicy.ts +1389 -39
- package/dist/src/core/index.cjs +239 -87
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +123 -39
- package/dist/src/core/index.d.ts +123 -39
- package/dist/src/core/index.js +234 -86
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +20 -27
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.js +21 -28
- package/dist/src/server/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/agents/skills/orkestrel-dispatch/scripts/helpers.js +0 -283
- package/dist/host/agents/skills/orkestrel-dispatch/references/bench.md +0 -25
- package/dist/host/agents/skills/orkestrel-dispatch/scripts/helpers.ts +0 -333
- package/dist/host/agents/skills/orkestrel-parallel/references/harnesses.md +0 -19
- package/dist/host/guides/supervisor.md +0 -4890
|
@@ -8,43 +8,203 @@
|
|
|
8
8
|
// range (`>=1.2.0 <2.0.0`, `8.x`) hits its literal bounded the same way and not preceded by another
|
|
9
9
|
// range operator. Each matching line prints once as path:line: text, naming the first requested
|
|
10
10
|
// literal that matched in the order --version then each --range, so the operator rules on it.
|
|
11
|
-
// Exit 0 with no hits, 3 with hits, 64 on usage
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const COMPARATOR =
|
|
11
|
+
// Exit 0 with no hits, 3 with hits, 64 on usage, including a flag the script does not read and the
|
|
12
|
+
// `--flag=value` form.
|
|
13
|
+
import { readdirSync, readFileSync, realpathSync, statSync } from 'node:fs'
|
|
14
|
+
import { join } from 'node:path'
|
|
15
|
+
|
|
16
|
+
/** Matches the file extensions the sweep skips as binary. */
|
|
17
|
+
export const BINARY = /\.(png|jpg|jpeg|gif|webp|ico|woff2?|ttf|otf|eot|zip|tgz|gz|pdf|wasm)$/u
|
|
18
|
+
|
|
19
|
+
/** Matches a range that is one comparator over one full version and captures the version. */
|
|
20
|
+
export const COMPARATOR =
|
|
21
21
|
/^(?:\^|~|>=|>|<=|<|=)?v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)$/u
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/** Names the directories every tree walk skips. */
|
|
24
|
+
export const SKIPPED_DIRECTORIES: ReadonlySet<string> = new Set([
|
|
25
|
+
'node_modules',
|
|
26
|
+
'.git',
|
|
27
|
+
'dist',
|
|
28
|
+
'tmp',
|
|
29
|
+
'.orkestrel',
|
|
30
|
+
'.idea',
|
|
31
|
+
])
|
|
32
|
+
|
|
33
|
+
/** Lists every flag the script reads, value flags and switches alike. */
|
|
34
|
+
export const FLAGS: readonly string[] = ['--version', '--range', '--paths', '--json']
|
|
35
|
+
|
|
36
|
+
/** Holds the usage line the script prints on a usage refusal. */
|
|
37
|
+
export const USAGE =
|
|
38
|
+
'usage: pins.ts --version PRIOR [--range PRIOR_RANGE ...] [--paths src,tests] [--json]'
|
|
39
|
+
|
|
40
|
+
/** Describes one requested literal and the pattern that finds it in a line. */
|
|
41
|
+
export interface Literal {
|
|
24
42
|
readonly literal: string
|
|
25
43
|
readonly pattern: RegExp
|
|
26
44
|
}
|
|
27
45
|
|
|
28
|
-
|
|
46
|
+
/** Describes one line that carries a requested literal. */
|
|
47
|
+
export interface Hit {
|
|
29
48
|
readonly path: string
|
|
30
49
|
readonly line: number
|
|
31
50
|
readonly literal: string
|
|
32
51
|
readonly text: string
|
|
33
52
|
}
|
|
34
53
|
|
|
35
|
-
|
|
54
|
+
/** Describes one file a tree walk found, with the modification time the walk read. */
|
|
55
|
+
export interface WalkedFile {
|
|
56
|
+
readonly path: string
|
|
57
|
+
readonly modified: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Normalizes a host path to forward slashes.
|
|
62
|
+
*
|
|
63
|
+
* @param path - A host path.
|
|
64
|
+
* @returns The same path with every backslash replaced by a slash.
|
|
65
|
+
*/
|
|
66
|
+
export function normalizeSlashes(path: string): string {
|
|
67
|
+
return path.split('\\').join('/')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Reads the value that follows a flag.
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
* Reads `--flag value` pairs: the first occurrence of a flag wins, a following value that opens
|
|
75
|
+
* with `--` is a missing value, and the `--flag=value` form is not read.
|
|
76
|
+
*
|
|
77
|
+
* @param argv - The arguments after the script path.
|
|
78
|
+
* @param name - The flag, such as `--paths`.
|
|
79
|
+
* @returns The value after the flag, or undefined when the flag is absent, last, or followed by
|
|
80
|
+
* another flag.
|
|
81
|
+
*/
|
|
82
|
+
export function readOption(argv: readonly string[], name: string): string | undefined {
|
|
83
|
+
const index = argv.indexOf(name)
|
|
84
|
+
const value = index === -1 ? undefined : argv[index + 1]
|
|
85
|
+
return value === undefined || value.startsWith('--') ? undefined : value
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Names the value flags a caller gave with no value.
|
|
90
|
+
*
|
|
91
|
+
* @param argv - The arguments after the script path.
|
|
92
|
+
* @param names - The flags that take a value.
|
|
93
|
+
* @returns Each named flag that appears last or is followed by another flag, in argument order.
|
|
94
|
+
*/
|
|
95
|
+
export function readMissingFlags(
|
|
96
|
+
argv: readonly string[],
|
|
97
|
+
names: readonly string[],
|
|
98
|
+
): readonly string[] {
|
|
99
|
+
return names.filter((name) => argv.includes(name) && readOption(argv, name) === undefined)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Names the flags a caller gave that the script does not read.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* Reads the arguments before a bare `--`, which opens a command a script passes on. A `--flag=value`
|
|
107
|
+
* argument is unknown, because the script reads no such form.
|
|
108
|
+
*
|
|
109
|
+
* @param argv - The arguments after the script path.
|
|
110
|
+
* @param flags - Every flag the script reads, value flags and switches alike.
|
|
111
|
+
* @returns Each argument that opens with `--` and is not a read flag, in argument order.
|
|
112
|
+
*/
|
|
113
|
+
export function readUnknownFlags(
|
|
114
|
+
argv: readonly string[],
|
|
115
|
+
flags: readonly string[],
|
|
116
|
+
): readonly string[] {
|
|
117
|
+
const end = argv.indexOf('--')
|
|
118
|
+
return (end === -1 ? argv : argv.slice(0, end)).filter(
|
|
119
|
+
(argument) => argument.startsWith('--') && !flags.includes(argument),
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Reads every value that follows a repeatable flag.
|
|
125
|
+
*
|
|
126
|
+
* @param argv - The arguments after the script path.
|
|
127
|
+
* @param name - The flag, such as `--range`.
|
|
128
|
+
* @returns The values in order, empty when the flag never appears.
|
|
129
|
+
*/
|
|
130
|
+
export function readOptions(argv: readonly string[], name: string): readonly string[] {
|
|
131
|
+
return argv.flatMap((argument, index) => {
|
|
132
|
+
const value = argv[index + 1]
|
|
133
|
+
return argument === name && value !== undefined && !value.startsWith('--') ? [value] : []
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Lists every regular file beneath a directory, skipping the directories the sweep never reads.
|
|
139
|
+
*
|
|
140
|
+
* @remarks
|
|
141
|
+
* A skipped name matches a directory at any depth, exactly and case-sensitively, so a
|
|
142
|
+
* `src/dist/` directory is skipped with the build output and a `Node_Modules/` directory is not.
|
|
143
|
+
*
|
|
144
|
+
* @param directory - The directory to walk.
|
|
145
|
+
* @param skipped - The directory names to skip. Default: {@link SKIPPED_DIRECTORIES}.
|
|
146
|
+
* @returns Each file's forward-slash path and modification time, in walk order.
|
|
147
|
+
* @throws Thrown when `directory` does not exist or cannot be read; check `statSync` first.
|
|
148
|
+
*/
|
|
149
|
+
export function listFiles(
|
|
150
|
+
directory: string,
|
|
151
|
+
skipped: ReadonlySet<string> = SKIPPED_DIRECTORIES,
|
|
152
|
+
): readonly WalkedFile[] {
|
|
153
|
+
const files: WalkedFile[] = []
|
|
154
|
+
const pending = [directory]
|
|
155
|
+
while (pending.length > 0) {
|
|
156
|
+
const current = pending.pop()
|
|
157
|
+
if (current === undefined) break
|
|
158
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
159
|
+
if (skipped.has(entry.name)) continue
|
|
160
|
+
const path = join(current, entry.name)
|
|
161
|
+
if (entry.isDirectory()) pending.push(path)
|
|
162
|
+
else if (entry.isFile()) {
|
|
163
|
+
files.push({ path: normalizeSlashes(path), modified: statSync(path).mtimeMs })
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return files
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Escapes a literal for use inside a regular expression.
|
|
172
|
+
*
|
|
173
|
+
* @param literal - The text to match exactly.
|
|
174
|
+
* @returns The text with every regular expression metacharacter backslash-escaped.
|
|
175
|
+
*/
|
|
176
|
+
export function escapePattern(literal: string): string {
|
|
36
177
|
return literal.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')
|
|
37
178
|
}
|
|
38
179
|
|
|
39
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Builds the pattern that finds a version bounded by characters other than digits and dots.
|
|
182
|
+
*
|
|
183
|
+
* @param version - The version literal.
|
|
184
|
+
* @returns The pattern.
|
|
185
|
+
*/
|
|
186
|
+
export function buildVersionPattern(version: string): RegExp {
|
|
40
187
|
return new RegExp(`(?<![0-9.])${escapePattern(version)}(?![0-9.])`, 'u')
|
|
41
188
|
}
|
|
42
189
|
|
|
43
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Builds the literal for a requested version.
|
|
192
|
+
*
|
|
193
|
+
* @param literal - The version as the operator wrote it.
|
|
194
|
+
* @returns The literal with its bounded pattern.
|
|
195
|
+
*/
|
|
196
|
+
export function buildVersionLiteral(literal: string): Literal {
|
|
44
197
|
return { literal, pattern: buildVersionPattern(literal) }
|
|
45
198
|
}
|
|
46
199
|
|
|
47
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Builds the literal for a requested range.
|
|
202
|
+
*
|
|
203
|
+
* @param literal - The range as the operator wrote it.
|
|
204
|
+
* @returns A one-comparator range matched by its bare version in any form, any other range matched as
|
|
205
|
+
* its own text not preceded by a range operator.
|
|
206
|
+
*/
|
|
207
|
+
export function buildRangeLiteral(literal: string): Literal {
|
|
48
208
|
const version = COMPARATOR.exec(literal)?.[1]
|
|
49
209
|
if (version !== undefined) return { literal, pattern: buildVersionPattern(version) }
|
|
50
210
|
return {
|
|
@@ -53,7 +213,14 @@ function buildRangeLiteral(literal: string): Literal {
|
|
|
53
213
|
}
|
|
54
214
|
}
|
|
55
215
|
|
|
56
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Finds the lines of one file that carry a requested literal.
|
|
218
|
+
*
|
|
219
|
+
* @param path - The file to read.
|
|
220
|
+
* @param literals - The literals to look for, in the order that names a line's literal.
|
|
221
|
+
* @returns One hit per matching line, naming the first literal that matched; none for a binary file.
|
|
222
|
+
*/
|
|
223
|
+
export function sweepFile(path: string, literals: readonly Literal[]): readonly Hit[] {
|
|
57
224
|
const content = readFileSync(path)
|
|
58
225
|
if (content.includes(0)) return []
|
|
59
226
|
return content
|
|
@@ -67,7 +234,20 @@ function sweepFile(path: string, literals: readonly Literal[]): readonly Hit[] {
|
|
|
67
234
|
})
|
|
68
235
|
}
|
|
69
236
|
|
|
70
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Runs the sweep and prints its hits.
|
|
239
|
+
*
|
|
240
|
+
* @param argv - The arguments after the script path.
|
|
241
|
+
* @returns The exit code: 0 with no hits, 3 with hits, 64 on usage.
|
|
242
|
+
*/
|
|
243
|
+
export function main(argv: readonly string[]): number {
|
|
244
|
+
const unknown = readUnknownFlags(argv, FLAGS)
|
|
245
|
+
if (unknown.length > 0) {
|
|
246
|
+
console.error(
|
|
247
|
+
`pins: unknown flag ${unknown.join(', ')}; give each flag and its value as separate arguments\n${USAGE}`,
|
|
248
|
+
)
|
|
249
|
+
return 64
|
|
250
|
+
}
|
|
71
251
|
const missing = readMissingFlags(argv, ['--version', '--range', '--paths'])
|
|
72
252
|
if (missing.length > 0) {
|
|
73
253
|
console.error(`pins: ${missing.join(', ')} given with no value`)
|
|
@@ -77,9 +257,7 @@ function main(argv: readonly string[]): number {
|
|
|
77
257
|
const ranges = readOptions(argv, '--range')
|
|
78
258
|
const paths = (readOptions(argv, '--paths')[0] ?? 'src,tests').split(',')
|
|
79
259
|
if (version === undefined && ranges.length === 0) {
|
|
80
|
-
console.error(
|
|
81
|
-
'usage: pins.ts --version PRIOR [--range PRIOR_RANGE ...] [--paths src,tests] [--json]',
|
|
82
|
-
)
|
|
260
|
+
console.error(USAGE)
|
|
83
261
|
return 64
|
|
84
262
|
}
|
|
85
263
|
const literals = [
|
|
@@ -109,4 +287,6 @@ function main(argv: readonly string[]): number {
|
|
|
109
287
|
return hits.length === 0 ? 0 : 3
|
|
110
288
|
}
|
|
111
289
|
|
|
112
|
-
process.
|
|
290
|
+
if (process.argv[1] !== undefined && realpathSync(process.argv[1]) === import.meta.filename) {
|
|
291
|
+
process.exitCode = main(process.argv.slice(2))
|
|
292
|
+
}
|