@orkestrel/scaffold 0.0.112 → 0.0.113
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 +37 -5
- package/dist/bin/main.js +1 -1
- 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/references/wave.md +4 -1
- package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +37 -5
- package/dist/host/claude/agents/orkestrel.md +1 -1
- package/dist/host/claude/rules/architecture.md +4 -3
- package/dist/host/claude/rules/tests.md +18 -3
- package/dist/host/claude/rules/typescript.md +11 -2
- package/dist/host/claude/rules/workspace.md +4 -0
- 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/manifest.json +16 -16
- package/dist/host/tests/config.test.ts +65 -3
- package/dist/host/tests/policy.test.ts +21 -7
- package/dist/host/tests/setupPolicy.ts +147 -12
- package/dist/src/core/index.cjs +3 -1
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +1 -1
- package/dist/src/core/index.d.ts +1 -1
- package/dist/src/core/index.js +3 -1
- package/dist/src/core/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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(
|
|
@@ -23,7 +23,10 @@ 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 a wave within each declared major.
|
|
26
|
+
Keep a wave within each declared major. A range joined by `||` names one supported major per
|
|
27
|
+
arm, so move only the arm in the release's major and keep every other arm: with
|
|
28
|
+
`vitest: ^4.1.11 || ^5.0.5` and a registry serving `4.1.12`, apply `^4.1.12 || ^5.0.5`.
|
|
29
|
+
For a workspace whose selected framework activates a
|
|
27
30
|
`TOOLCHAIN_HOLDS` row, keep the tool within that range's major; read the audit question for its reason. Prove
|
|
28
31
|
that framework on the later major before lifting its hold.
|
|
29
32
|
2. Commit the manifest and the lockfile as the preparation commit. `scaffold overwrite` refuses a
|
|
@@ -1383,11 +1383,39 @@ export function runRecord(runner: Runner, name: string | undefined): void {
|
|
|
1383
1383
|
)
|
|
1384
1384
|
}
|
|
1385
1385
|
|
|
1386
|
+
/**
|
|
1387
|
+
* Moves one declared range to the registry caret of a release, keeping every other major a
|
|
1388
|
+
* disjunctive range admits.
|
|
1389
|
+
*
|
|
1390
|
+
* @remarks
|
|
1391
|
+
* A range of one comparator set becomes the caret. A range joined by `||` names one supported major
|
|
1392
|
+
* per arm, so only the arm in the release's major becomes the caret; a range with no arm in that
|
|
1393
|
+
* major stays as declared, which keeps the wave inside each declared major.
|
|
1394
|
+
*
|
|
1395
|
+
* @param current - The declared range.
|
|
1396
|
+
* @param latest - The release's version.
|
|
1397
|
+
* @returns The moved range.
|
|
1398
|
+
* @example
|
|
1399
|
+
* ```ts
|
|
1400
|
+
* moveRange('^4.1.11 || ^5.0.4', '5.0.5') // '^4.1.11 || ^5.0.5'
|
|
1401
|
+
* ```
|
|
1402
|
+
*/
|
|
1403
|
+
export function moveRange(current: unknown, latest: string): unknown {
|
|
1404
|
+
const caret = `^${latest}`
|
|
1405
|
+
if (typeof current !== 'string' || !current.includes('||')) return caret
|
|
1406
|
+
const major = /^(\d+)\./u.exec(latest)?.[1]
|
|
1407
|
+
return current
|
|
1408
|
+
.split(/\s*\|\|\s*/u)
|
|
1409
|
+
.map((arm) => (/^[\^~=v\s]*(\d+)/u.exec(arm)?.[1] === major ? caret : arm))
|
|
1410
|
+
.join(' || ')
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1386
1413
|
/**
|
|
1387
1414
|
* Moves each named dependency to the registry caret of its latest release.
|
|
1388
1415
|
*
|
|
1389
1416
|
* @remarks
|
|
1390
|
-
* A later release of the same name reads the range the earlier reading wrote.
|
|
1417
|
+
* A later release of the same name reads the range the earlier reading wrote. A disjunctive range
|
|
1418
|
+
* moves only its arm in the release's major, per {@link moveRange}.
|
|
1391
1419
|
*
|
|
1392
1420
|
* @param ranges - The block's ranges by name.
|
|
1393
1421
|
* @param releases - The audit's release readings.
|
|
@@ -1400,12 +1428,16 @@ export function computeRanges(
|
|
|
1400
1428
|
return releases.reduce<RangeMove>(
|
|
1401
1429
|
(state, release) => {
|
|
1402
1430
|
if (release.latest === undefined || !(release.name in state.ranges)) return state
|
|
1403
|
-
const
|
|
1404
|
-
|
|
1431
|
+
const current = state.ranges[release.name]
|
|
1432
|
+
const next = moveRange(current, release.latest)
|
|
1433
|
+
return current === next
|
|
1405
1434
|
? state
|
|
1406
1435
|
: {
|
|
1407
|
-
ranges: { ...state.ranges, [release.name]:
|
|
1408
|
-
moved: [
|
|
1436
|
+
ranges: { ...state.ranges, [release.name]: next },
|
|
1437
|
+
moved: [
|
|
1438
|
+
...state.moved,
|
|
1439
|
+
`${release.name} ${typeof current === 'string' ? current : String(release.range)} -> ${String(next)}`,
|
|
1440
|
+
],
|
|
1409
1441
|
}
|
|
1410
1442
|
},
|
|
1411
1443
|
{ ranges, moved: [] },
|
|
@@ -79,7 +79,7 @@ so network-controlled descriptions never enter agent instruction context.
|
|
|
79
79
|
| `@orkestrel/reason` | `0.0.13` | L2 | `@orkestrel/emitter` `^0.0.12`, `@orkestrel/contract` `^0.0.19` | |
|
|
80
80
|
| `@orkestrel/relation` | `0.0.16` | L3 | `@orkestrel/emitter` `^0.0.12`, `@orkestrel/contract` `^0.0.19`, `@orkestrel/database` `^0.0.18` | |
|
|
81
81
|
| `@orkestrel/router` | `0.0.17` | L2 | `@orkestrel/abort` `^0.0.13`, `@orkestrel/emitter` `^0.0.12`, `@orkestrel/contract` `^0.0.19` | |
|
|
82
|
-
| `@orkestrel/scaffold` | `0.0.
|
|
82
|
+
| `@orkestrel/scaffold` | `0.0.112` | L3 | `@orkestrel/console` `^0.0.16`, `@orkestrel/emitter` `^0.0.12`, `@orkestrel/process` `^0.0.15`, `@orkestrel/contract` `^0.0.19`, `@orkestrel/markdown` `^0.0.17`, `@orkestrel/template` `^0.0.10` | |
|
|
83
83
|
| `@orkestrel/sea` | `0.0.19` | L3 | `@orkestrel/emitter` `^0.0.12`, `@orkestrel/process` `^0.0.15`, `@orkestrel/contract` `^0.0.19` | |
|
|
84
84
|
| `@orkestrel/server` | `0.0.23` | L3 | `@orkestrel/abort` `^0.0.13`, `@orkestrel/codec` `^0.0.6`, `@orkestrel/router` `^0.0.17`, `@orkestrel/emitter` `^0.0.12`, `@orkestrel/timeout` `^0.0.13`, `@orkestrel/contract` `^0.0.19` | |
|
|
85
85
|
| `@orkestrel/sqlite` | `0.0.14` | L1 | `@orkestrel/contract` `^0.0.19` | |
|
|
@@ -48,8 +48,8 @@ Use only the centralized files an environment needs.
|
|
|
48
48
|
- A function module contains imports and exactly one exported function named for its file. Everything else extracts by kind exactly as it does from a class module.
|
|
49
49
|
- Extract local declarations by kind. “Only used here” and “not exported” are not exemptions.
|
|
50
50
|
- Every declaration in a centralized file is exported. Fold away a trivial single-use declaration or export/test it; never leave it hidden.
|
|
51
|
-
-
|
|
52
|
-
- Treat `src/bin/main.ts`, `app/browser/main.ts`, `app/vue/main.ts`, and `app/server/main.ts` as fixed runtime entries. Declare no module-scope constant or function in them; import what they need and run.
|
|
51
|
+
- When a runtime entrypoint must be self-contained and cannot import siblings, such as raw source loaded in a worker, import only installed packages and `node:` modules there and explain that necessity in a comment. Keep its declarations in the kind its file names, as every other file does: inline what a sibling would supply as a callback argument, and keep per-run state in the call's own entities, such as an `AbortController` instance whose signal scopes a listener.
|
|
52
|
+
- Treat `src/bin/main.ts`, `app/browser/main.ts`, `app/vue/main.ts`, and `app/server/main.ts` as fixed runtime entries. Declare no module-scope constant or function in them; import what they need and run.
|
|
53
53
|
- Perform a cleanup pass after implementation: no stray implementation-file declarations, non-exported/wrong-kind centralized declarations, prohibited nested declarations, duplicate implementations, compatibility aliases, superfluous wrappers, stale imports/barrel rows, or untested extracted functions.
|
|
54
54
|
|
|
55
55
|
## Kind purity
|
|
@@ -256,10 +256,11 @@ Choose the access shape:
|
|
|
256
256
|
|
|
257
257
|
- **Point access:** `get`, `set`, `delete`.
|
|
258
258
|
- **Bulk restore:** `save`, `load`, `remove`, `clear`.
|
|
259
|
+
- **Atomic update:** one verb that reads, decides, and writes a key's entry in one call, such as `consume(key, now, limits)`, for a counter or budget store whose read-modify-write must not interleave across an `await`.
|
|
259
260
|
|
|
260
261
|
Every shape obeys:
|
|
261
262
|
|
|
262
|
-
- The stored value carries its own id; do not pass a separate id to `set`/`save`.
|
|
263
|
+
- The stored value carries its own id; do not pass a separate id to `set`/`save`. An atomic update takes the key of the entry it changes, because the caller passes no stored value.
|
|
263
264
|
- Every primitive is async and returns a `Promise`.
|
|
264
265
|
- Deleting/removing a missing key is a no-op.
|
|
265
266
|
- Concrete stores live in `stores/`; the interface stays in module-root `types.ts`; `create*Store` factories stay in `factories.ts`.
|
|
@@ -20,7 +20,8 @@ These rules govern what a test asserts and where it lives, the cross-cutting and
|
|
|
20
20
|
not add `tests/configs/`.
|
|
21
21
|
- Resolve a mirrored module through `.ts`, `.tsx`, `.mts`, `.cts`, `.vue`, `.scss`, or `.css`.
|
|
22
22
|
- Resolve a Sass or CSS partial through the module's leading underscore.
|
|
23
|
-
- Mirror root setup modules and proofs in both
|
|
23
|
+
- Mirror the root setup modules § Shared test infrastructure places, and their proofs, in both
|
|
24
|
+
directions; that section's list is the whole set of names. A root `tests/setup<Name>.test.ts`
|
|
24
25
|
resolves to `tests/setup<Name>.ts`. A root `tests/setup<Name>.ts` that declares an export has
|
|
25
26
|
`tests/setup<Name>.test.ts` or is imported by `tests/setup.test.ts`, which can prove several
|
|
26
27
|
setup modules when their helpers serve several projects. The setup modules scaffold owns are
|
|
@@ -201,7 +202,10 @@ Test helpers are shared infrastructure, not local test-file clutter.
|
|
|
201
202
|
- Export every reusable helper, fixture type, factory, constant, and guard from setup files.
|
|
202
203
|
- A setup file owns everything an assertion needs and nothing an assertion is: `describe`, `it`, `test`, and `expect` never appear in a `setup*.ts`; lint refuses their import from `vitest` there.
|
|
203
204
|
- Data tables and case matrices belong in a setup file at any size; test registration does not.
|
|
204
|
-
- Test files import shared infrastructure rather than declaring local fixture factories.
|
|
205
|
+
- Test files import shared infrastructure rather than declaring local fixture factories. The
|
|
206
|
+
`policy/no-test-helper` lint rule refuses a module-scope function, class, or function-valued
|
|
207
|
+
binding in a mirrored test file (`tests/src/**`, `tests/app/**`) or a root setup proof; move each
|
|
208
|
+
into the setup module its environment names.
|
|
205
209
|
- Never reimplement a framework helper in tests or fixtures; import the real parser, signer, flattener, or other helper.
|
|
206
210
|
- Prefer small customizable factories/stubs that seed inert data for a real scenario over repeated inline setup.
|
|
207
211
|
- Helper names follow module-helper naming: `createFixtureServer`, `buildElement`, `appendItems`, `renderRows`, `waitForReady`, `extractDetail`.
|
|
@@ -209,13 +213,24 @@ Test helpers are shared infrastructure, not local test-file clutter.
|
|
|
209
213
|
- A module reads no live host object at import; it reads one inside the function that needs it.
|
|
210
214
|
- A fixture that stands in for another package's platform behavior copies that package's own proof of the behavior rather than re-deriving it.
|
|
211
215
|
|
|
212
|
-
|
|
216
|
+
Declare test infrastructure only in the root modules the following list places, each in the
|
|
217
|
+
environment it names, and in scaffold's vendored `tests/setupPolicy.ts`. Never create another
|
|
218
|
+
`tests/setup<Name>.ts`, a nested setup module, or a helper, type, suite, or builder module anywhere
|
|
219
|
+
else under `tests/`. Put a cross-cutting proof's helpers in the module of the environment the proof
|
|
220
|
+
runs in: `tests/setupServer.ts` for the Node `conformance`, `tree`, and `integration` proofs. A file
|
|
221
|
+
under a `fixtures/` directory is data or an entry a test runs or loads on its own, never a helper a
|
|
222
|
+
test file imports. The policy sweep's `mirror` rule refuses every other TypeScript module under
|
|
223
|
+
`tests/` that is not a test, a bench, or a declaration file; it reads paths, not imports, so review
|
|
224
|
+
refuses a helper placed under `fixtures/`.
|
|
213
225
|
|
|
214
226
|
- `tests/setup.ts`: host-independent; no `node:*`, DOM, `window`, or Vue. Lint refuses a `node:` or Vue import there.
|
|
215
227
|
- `tests/setupServer.ts`: Node-only helpers and `node:fs` loaders anchored to `WORKSPACE_ROOT`.
|
|
216
228
|
- `tests/setupBrowser.ts`: DOM/Vue/browser helpers and setup CSS. Lint refuses a `node:` import here and in `tests/setupStyles.ts`.
|
|
217
229
|
- `tests/setupStyles.ts`: the CSSOM and sheet helpers `.claude/rules/styles.md` places there; a
|
|
218
230
|
sheet-face project loads it after `tests/setupBrowser.ts` when the target has the file.
|
|
231
|
+
- `tests/setupService.ts`: the `service` project's readiness setup, per § Live-service tests.
|
|
232
|
+
- `tests/setupGlobal.ts`: the `globalSetup` module `.claude/rules/workspace.md` § Test project
|
|
233
|
+
matrix assigns to `src:browser`, `setup:browser`, and `integration`.
|
|
219
234
|
- `tests/setupStudy.ts`: the harness module the study tests import and, in a study-engine package,
|
|
220
235
|
its source tests too. Name it in no project's `setupFiles`; tests import it, as the policy proof
|
|
221
236
|
imports `tests/setupPolicy.ts`.
|
|
@@ -87,7 +87,9 @@ The non-negotiables and design laws in `AGENTS.md` apply without exception and a
|
|
|
87
87
|
reached, such as a child directory, a dependency, an amendment, or a child process. Count as one
|
|
88
88
|
step a complete iteration that removes or visits an entry of the worklist, its nested loops
|
|
89
89
|
included. Treat a worklist that no step can add more than one entry to as a cursor, and return
|
|
90
|
-
what it reaches from a bounded recursion
|
|
90
|
+
what it reaches from a bounded recursion. When only an input limit bounds the walk's depth, as
|
|
91
|
+
a linked chain's length does, walk it through an iterator created for the call instead, under
|
|
92
|
+
the **Per-call state** rule, with the cursor in that iterator's `#` field;
|
|
91
93
|
- a traversal's membership set or map, which the traversal reads to avoid revisiting a node or to
|
|
92
94
|
discover the nodes reachable from nodes it has recorded, whether or not it iterates that
|
|
93
95
|
collection, and to which the cursor condition never applies;
|
|
@@ -220,12 +222,19 @@ type Result<T, E = Error> = Success<T> | Failure<E>
|
|
|
220
222
|
declares, checked against its declared type, under the guard law in
|
|
221
223
|
`.claude/rules/patterns.md` § Validation and contracts; never require the class's `name`, which
|
|
222
224
|
a subclass replaces;
|
|
225
|
+
- check a member whose type the package declares against every value that type admits, a class
|
|
226
|
+
instance and a callable object carrying the declared members included. Check a member whose type
|
|
227
|
+
`@orkestrel/contract` defines, such as a JSON value, a fault, or an array of either, through that
|
|
228
|
+
package's guard for the type, which fixes its data shape: a plain record, own array indices, and
|
|
229
|
+
the enumerable members that JSON reads. The one exception is a number, where the guard accepts
|
|
230
|
+
any number the type admits;
|
|
223
231
|
- where `@orkestrel/contract` is declared, read through its `INTRINSICS` constant inside its
|
|
224
232
|
`holds` function.
|
|
225
233
|
- Prove the guard in `tests/distribution.test.ts` against two copies of the packed package, each
|
|
226
234
|
copy's guard reading the other copy's error: the `require` entry against the `import` entry where
|
|
227
235
|
the package ships both, and the installed package against a copy of its files at a second path.
|
|
228
|
-
|
|
236
|
+
Assert that the loaded copies' error constructors are pairwise distinct, so that the proof cannot
|
|
237
|
+
pass on one module instance. Prove beside it that the guard accepts an instance of a subclass and refuses a look-alike error
|
|
229
238
|
with the same `code` and no brand, a transparent `Proxy` object over a branded error, and a plain
|
|
230
239
|
object that only carries the brand.
|
|
231
240
|
|
|
@@ -85,6 +85,10 @@ private copy of that environment into the face, so the vendored `.oxlintrc.json`
|
|
|
85
85
|
`devDependencies` there: the root config bundles the file into every config load, builds
|
|
86
86
|
included, and the bundle resolves no workspace alias. Load workspace source inside a command
|
|
87
87
|
body through `context.project.vitest.import`, never through a static import.
|
|
88
|
+
- Keep `fsModuleCache: false` in the root configuration's `test` block. Vitest 5.0.5 reads a cached
|
|
89
|
+
module's code as bytes, and with the cache on, every stack read inside source a command loads
|
|
90
|
+
through `context.project.vitest.import` throws (measured 2026-10-29 in `@orkestrel/test`'s
|
|
91
|
+
`chooseFiles` command). Remove the setting only after a Vitest release reads that code as text.
|
|
88
92
|
- Keep `configs/helpers.ts` free of any dependency a core-only workspace does not declare. It is
|
|
89
93
|
vendored byte-identical to every workspace, so an import there must resolve in all of them.
|
|
90
94
|
`configs/browsers.ts` exists for that reason: it imports `playwright` and
|
|
@@ -321,6 +321,16 @@ export const POLICY_NESTED_GLOBS: readonly string[] = Object.freeze(
|
|
|
321
321
|
),
|
|
322
322
|
)
|
|
323
323
|
|
|
324
|
+
/**
|
|
325
|
+
* Matches the lint population the test-helper rule runs over, as the Oxlint configuration declares
|
|
326
|
+
* it: the mirrored test files and the root setup proofs.
|
|
327
|
+
*/
|
|
328
|
+
export const POLICY_TEST_GLOBS: readonly string[] = Object.freeze([
|
|
329
|
+
'tests/src/**/*.test.ts',
|
|
330
|
+
'tests/app/**/*.test.ts',
|
|
331
|
+
'tests/setup*.test.ts',
|
|
332
|
+
])
|
|
333
|
+
|
|
324
334
|
/**
|
|
325
335
|
* Matches the lint population the skill-script rules run over, as the Oxlint configuration declares
|
|
326
336
|
* it.
|
|
@@ -1225,6 +1235,22 @@ export function reportData(context: PolicyContext, node: PolicyExpression): void
|
|
|
1225
1235
|
}
|
|
1226
1236
|
}
|
|
1227
1237
|
|
|
1238
|
+
/** Reports a module-scope function, class, or function-valued binding a test file declares. */
|
|
1239
|
+
export function reportTestHelper(context: PolicyContext, node: PolicyExpression): void {
|
|
1240
|
+
if (!isPolicyTop(node)) return
|
|
1241
|
+
if (node.type !== 'VariableDeclaration') {
|
|
1242
|
+
context.report({ node, messageId: 'helper' })
|
|
1243
|
+
return
|
|
1244
|
+
}
|
|
1245
|
+
for (const declarator of node.declarations ?? []) {
|
|
1246
|
+
const init = declarator.init
|
|
1247
|
+
if (init === undefined || init === null) continue
|
|
1248
|
+
if (isPolicyFunction(init) || init.type === 'ClassExpression') {
|
|
1249
|
+
context.report({ node: declarator, messageId: 'helper' })
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1228
1254
|
/** Reports module function syntax outside a function-kind file. */
|
|
1229
1255
|
export function reportFunction(context: PolicyContext, node: PolicyExpression): void {
|
|
1230
1256
|
if (isPolicyAmbient(context.filename)) return
|
|
@@ -1827,6 +1853,28 @@ export const MUTABLE_RULE: PolicyRuleInterface = {
|
|
|
1827
1853
|
},
|
|
1828
1854
|
}
|
|
1829
1855
|
|
|
1856
|
+
/** Bans a module-scope function, class, or fixture factory in a mirrored test file or setup proof. */
|
|
1857
|
+
export const HELPER_RULE: PolicyRuleInterface = {
|
|
1858
|
+
meta: {
|
|
1859
|
+
type: 'problem',
|
|
1860
|
+
docs: {
|
|
1861
|
+
description:
|
|
1862
|
+
'Disallow a module-scope function, class, or function-valued binding in a test file; shared test infrastructure lives in the root setup modules.',
|
|
1863
|
+
},
|
|
1864
|
+
messages: {
|
|
1865
|
+
helper:
|
|
1866
|
+
'Move this declaration into the root setup module its environment names (tests/setup.ts, tests/setupServer.ts, or tests/setupBrowser.ts), export it, and import it; a test file imports shared infrastructure and declares none of its own.',
|
|
1867
|
+
},
|
|
1868
|
+
},
|
|
1869
|
+
create(context) {
|
|
1870
|
+
return {
|
|
1871
|
+
FunctionDeclaration: (node) => reportTestHelper(context, node),
|
|
1872
|
+
ClassDeclaration: (node) => reportTestHelper(context, node),
|
|
1873
|
+
VariableDeclaration: (node) => reportTestHelper(context, node),
|
|
1874
|
+
}
|
|
1875
|
+
},
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1830
1878
|
/** Bans a comment carrying a term the substitution table bans unconditionally. */
|
|
1831
1879
|
export const TERM_RULE: PolicyRuleInterface = {
|
|
1832
1880
|
meta: {
|
|
@@ -1870,5 +1918,6 @@ export default {
|
|
|
1870
1918
|
'no-banned-term': TERM_RULE,
|
|
1871
1919
|
'no-malformed-script': SCRIPT_RULE,
|
|
1872
1920
|
'no-mutable-property': MUTABLE_RULE,
|
|
1921
|
+
'no-test-helper': HELPER_RULE,
|
|
1873
1922
|
},
|
|
1874
1923
|
}
|
package/dist/host/manifest.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"storage": "agents/platforms/windows.md",
|
|
29
29
|
"destination": ".agents/platforms/windows.md",
|
|
30
30
|
"executable": false,
|
|
31
|
-
"digest": "
|
|
31
|
+
"digest": "0504d1ee45e180e732508a385e349a08ce1edd0827f4d810086ef708d1af5e09"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"storage": "agents/skills/enterprise-bootstrap/SKILL.md",
|
|
@@ -328,7 +328,7 @@
|
|
|
328
328
|
"storage": "agents/skills/orkestrel-harden/scripts/titles.ts",
|
|
329
329
|
"destination": ".agents/skills/orkestrel-harden/scripts/titles.ts",
|
|
330
330
|
"executable": false,
|
|
331
|
-
"digest": "
|
|
331
|
+
"digest": "b9eec5b1fcf2a4c3470021408e694caf9188a445c78a19c9b85f46a7f787d29d"
|
|
332
332
|
},
|
|
333
333
|
{
|
|
334
334
|
"storage": "agents/skills/orkestrel-journey/SKILL.md",
|
|
@@ -472,7 +472,7 @@
|
|
|
472
472
|
"storage": "agents/skills/orkestrel-publish/references/wave.md",
|
|
473
473
|
"destination": ".agents/skills/orkestrel-publish/references/wave.md",
|
|
474
474
|
"executable": false,
|
|
475
|
-
"digest": "
|
|
475
|
+
"digest": "fc032347f23deb3d21da8ac4ba7e6e6c5e7deb3ddba103f046b6681066fe590d"
|
|
476
476
|
},
|
|
477
477
|
{
|
|
478
478
|
"storage": "agents/skills/orkestrel-publish/references/window.md",
|
|
@@ -502,7 +502,7 @@
|
|
|
502
502
|
"storage": "agents/skills/orkestrel-publish/scripts/wave.ts",
|
|
503
503
|
"destination": ".agents/skills/orkestrel-publish/scripts/wave.ts",
|
|
504
504
|
"executable": false,
|
|
505
|
-
"digest": "
|
|
505
|
+
"digest": "b3161a8890d2bf28e749c27ddb86a0831b3200d88d64478fd713dc6baad8d421"
|
|
506
506
|
},
|
|
507
507
|
{
|
|
508
508
|
"storage": "agents/skills/orkestrel-publish/scripts/window.ts",
|
|
@@ -604,7 +604,7 @@
|
|
|
604
604
|
"storage": "claude/agents/orkestrel.md",
|
|
605
605
|
"destination": ".claude/agents/orkestrel.md",
|
|
606
606
|
"executable": false,
|
|
607
|
-
"digest": "
|
|
607
|
+
"digest": "f8f70955ba02ae23b7a501de9415b4e0de914b355a03974eeee0d648232b37c2"
|
|
608
608
|
},
|
|
609
609
|
{
|
|
610
610
|
"storage": "claude/agents/planner.md",
|
|
@@ -646,7 +646,7 @@
|
|
|
646
646
|
"storage": "claude/rules/architecture.md",
|
|
647
647
|
"destination": ".claude/rules/architecture.md",
|
|
648
648
|
"executable": false,
|
|
649
|
-
"digest": "
|
|
649
|
+
"digest": "e096a38930147d66c04948f02d4f797935bd8633ed98abf04f8732618dab8133"
|
|
650
650
|
},
|
|
651
651
|
{
|
|
652
652
|
"storage": "claude/rules/browser.md",
|
|
@@ -700,19 +700,19 @@
|
|
|
700
700
|
"storage": "claude/rules/tests.md",
|
|
701
701
|
"destination": ".claude/rules/tests.md",
|
|
702
702
|
"executable": false,
|
|
703
|
-
"digest": "
|
|
703
|
+
"digest": "28d8cb65fbebd35b1608ccc9a4416bd8ad43e23343221ae7941daca1add5b32f"
|
|
704
704
|
},
|
|
705
705
|
{
|
|
706
706
|
"storage": "claude/rules/typescript.md",
|
|
707
707
|
"destination": ".claude/rules/typescript.md",
|
|
708
708
|
"executable": false,
|
|
709
|
-
"digest": "
|
|
709
|
+
"digest": "dbbb6685847dd31752ba62dd2fbdc9d1b47402aaa247529684a5c192040e07e1"
|
|
710
710
|
},
|
|
711
711
|
{
|
|
712
712
|
"storage": "claude/rules/workspace.md",
|
|
713
713
|
"destination": ".claude/rules/workspace.md",
|
|
714
714
|
"executable": false,
|
|
715
|
-
"digest": "
|
|
715
|
+
"digest": "b0dd50110df9e3e05adf270d4e4ecfbe9ff9867102c1de811da2d411c5815714"
|
|
716
716
|
},
|
|
717
717
|
{
|
|
718
718
|
"storage": "claude/rules/writing.md",
|
|
@@ -892,7 +892,7 @@
|
|
|
892
892
|
"storage": "configs/policy.ts",
|
|
893
893
|
"destination": "configs/policy.ts",
|
|
894
894
|
"executable": false,
|
|
895
|
-
"digest": "
|
|
895
|
+
"digest": "b80d6a2b5e4d693341cec7c02ad6097d04218d4adcd4640976971c19fda219ab"
|
|
896
896
|
},
|
|
897
897
|
{
|
|
898
898
|
"storage": "cursor/mcp.json",
|
|
@@ -922,7 +922,7 @@
|
|
|
922
922
|
"storage": "dotfiles/gitignore",
|
|
923
923
|
"destination": ".gitignore",
|
|
924
924
|
"executable": false,
|
|
925
|
-
"digest": "
|
|
925
|
+
"digest": "300f28f9058bb54c50af1615b38b8347fa5126b03e0ec90ae92824538ac5d089"
|
|
926
926
|
},
|
|
927
927
|
{
|
|
928
928
|
"storage": "dotfiles/mcp.json",
|
|
@@ -946,7 +946,7 @@
|
|
|
946
946
|
"storage": "dotfiles/oxlintrc.json",
|
|
947
947
|
"destination": ".oxlintrc.json",
|
|
948
948
|
"executable": false,
|
|
949
|
-
"digest": "
|
|
949
|
+
"digest": "8c459fbf2120d1de42cdf6380e26988c96044253578c6b2b9749cab322155c62"
|
|
950
950
|
},
|
|
951
951
|
{
|
|
952
952
|
"storage": "dotfiles/prettierignore",
|
|
@@ -1306,19 +1306,19 @@
|
|
|
1306
1306
|
"storage": "tests/config.test.ts",
|
|
1307
1307
|
"destination": "tests/config.test.ts",
|
|
1308
1308
|
"executable": false,
|
|
1309
|
-
"digest": "
|
|
1309
|
+
"digest": "2890c13c60e8d9a7ff5194ce766d00648043a518d003e04c104afaabcd6823a6"
|
|
1310
1310
|
},
|
|
1311
1311
|
{
|
|
1312
1312
|
"storage": "tests/policy.test.ts",
|
|
1313
1313
|
"destination": "tests/policy.test.ts",
|
|
1314
1314
|
"executable": false,
|
|
1315
|
-
"digest": "
|
|
1315
|
+
"digest": "af7f29b43ea7761f99bfd40a9253ccd4bc200908d8ff0ffc6429f5b2b39ce516"
|
|
1316
1316
|
},
|
|
1317
1317
|
{
|
|
1318
1318
|
"storage": "tests/setupPolicy.ts",
|
|
1319
1319
|
"destination": "tests/setupPolicy.ts",
|
|
1320
1320
|
"executable": false,
|
|
1321
|
-
"digest": "
|
|
1321
|
+
"digest": "311efff7dce707c5f8553271076d7de853da5c9f795f2ba83f19e35131bbc6ce"
|
|
1322
1322
|
}
|
|
1323
1323
|
],
|
|
1324
1324
|
"roots": [
|
|
@@ -2141,5 +2141,5 @@
|
|
|
2141
2141
|
]
|
|
2142
2142
|
}
|
|
2143
2143
|
],
|
|
2144
|
-
"digest": "
|
|
2144
|
+
"digest": "7bd2e51dd3c4b00b3761e46008436322f93f0b4d14955dc357b32a9352cb0bba"
|
|
2145
2145
|
}
|
|
@@ -39,6 +39,7 @@ import policyPlugin, {
|
|
|
39
39
|
LET_RULE,
|
|
40
40
|
MOCKING_RULE,
|
|
41
41
|
MUTABLE_RULE,
|
|
42
|
+
HELPER_RULE,
|
|
42
43
|
NESTED_RULE,
|
|
43
44
|
PARSER_RULE,
|
|
44
45
|
PLUGIN_RULE,
|
|
@@ -46,6 +47,7 @@ import policyPlugin, {
|
|
|
46
47
|
POLICY_ENDING_GLOBS,
|
|
47
48
|
POLICY_JUDGED_TERMS,
|
|
48
49
|
POLICY_NESTED_GLOBS,
|
|
50
|
+
POLICY_TEST_GLOBS,
|
|
49
51
|
POLICY_PLACEMENT_GLOBS,
|
|
50
52
|
POLICY_SCRIPT_GLOBS,
|
|
51
53
|
POLICY_VOICE_STOPWORDS,
|
|
@@ -2806,6 +2808,53 @@ createSomething({
|
|
|
2806
2808
|
],
|
|
2807
2809
|
})
|
|
2808
2810
|
|
|
2811
|
+
tester.run('no-test-helper', HELPER_RULE, {
|
|
2812
|
+
valid: [
|
|
2813
|
+
{
|
|
2814
|
+
name: 'accepts imports, registrations, and module data in a mirrored test',
|
|
2815
|
+
filename: 'tests/src/core/helpers.test.ts',
|
|
2816
|
+
code: "import { it } from 'vitest'\nconst CASES = Object.freeze([1, 2])\nit('reads', () => { const read = () => CASES[0]; void read })",
|
|
2817
|
+
},
|
|
2818
|
+
{
|
|
2819
|
+
name: 'accepts a callback passed to a registration',
|
|
2820
|
+
filename: 'tests/setupServer.test.ts',
|
|
2821
|
+
code: "import { describe, it } from 'vitest'\ndescribe('server', () => { it('reads', function () {}) })",
|
|
2822
|
+
},
|
|
2823
|
+
],
|
|
2824
|
+
invalid: [
|
|
2825
|
+
{
|
|
2826
|
+
name: 'rejects a module-scope function declaration [membership: module-scope declarations of a mirrored test]',
|
|
2827
|
+
filename: 'tests/src/core/helpers.test.ts',
|
|
2828
|
+
code: 'function buildValue(): number { return 1 }\nvoid buildValue',
|
|
2829
|
+
errors: [{ messageId: 'helper' }],
|
|
2830
|
+
},
|
|
2831
|
+
{
|
|
2832
|
+
name: 'rejects a function-valued binding [membership: module-scope declarations of a mirrored test]',
|
|
2833
|
+
filename: 'tests/app/browser/App.test.ts',
|
|
2834
|
+
code: 'const createFixture = () => ({ id: 1 })\nvoid createFixture',
|
|
2835
|
+
errors: [{ messageId: 'helper' }],
|
|
2836
|
+
},
|
|
2837
|
+
{
|
|
2838
|
+
name: 'rejects an exported function expression [membership: module-scope declarations of a mirrored test]',
|
|
2839
|
+
filename: 'tests/src/core/helpers.test.ts',
|
|
2840
|
+
code: 'export const readValue = function (): number { return 1 }',
|
|
2841
|
+
errors: [{ messageId: 'helper' }],
|
|
2842
|
+
},
|
|
2843
|
+
{
|
|
2844
|
+
name: 'rejects a module-scope class [membership: module-scope declarations of a root setup proof]',
|
|
2845
|
+
filename: 'tests/setupBrowser.test.ts',
|
|
2846
|
+
code: 'class Fixture {}\nvoid Fixture',
|
|
2847
|
+
errors: [{ messageId: 'helper' }],
|
|
2848
|
+
},
|
|
2849
|
+
{
|
|
2850
|
+
name: 'rejects a class-valued binding [membership: module-scope declarations of a mirrored test]',
|
|
2851
|
+
filename: 'tests/src/core/helpers.test.ts',
|
|
2852
|
+
code: 'const Fixture = class {}\nvoid Fixture',
|
|
2853
|
+
errors: [{ messageId: 'helper' }],
|
|
2854
|
+
},
|
|
2855
|
+
],
|
|
2856
|
+
})
|
|
2857
|
+
|
|
2809
2858
|
tester.run('no-mutable-property', MUTABLE_RULE, {
|
|
2810
2859
|
valid: [
|
|
2811
2860
|
{
|
|
@@ -4329,18 +4378,25 @@ createSomething({
|
|
|
4329
4378
|
expect(declared).toContain('no-cross-vue-face')
|
|
4330
4379
|
expect(declared).toContain('no-malformed-script')
|
|
4331
4380
|
expect(declared).toContain('no-mutable-property')
|
|
4381
|
+
expect(declared).toContain('no-test-helper')
|
|
4332
4382
|
expect(
|
|
4333
4383
|
inspectPolicyWiring(
|
|
4334
4384
|
parsed,
|
|
4335
4385
|
declared.map((name) => `policy/${name}`),
|
|
4336
|
-
[
|
|
4386
|
+
[
|
|
4387
|
+
POLICY_PLACEMENT_GLOBS,
|
|
4388
|
+
POLICY_ENDING_GLOBS,
|
|
4389
|
+
POLICY_SCRIPT_GLOBS,
|
|
4390
|
+
POLICY_NESTED_GLOBS,
|
|
4391
|
+
POLICY_TEST_GLOBS,
|
|
4392
|
+
],
|
|
4337
4393
|
),
|
|
4338
4394
|
).toEqual([])
|
|
4339
4395
|
// The controls: a configuration with the skill-script override or the nested-function
|
|
4340
4396
|
// override removed reports the population it no longer declares.
|
|
4341
4397
|
const overrides: unknown = Object.getOwnPropertyDescriptor(parsed, 'overrides')?.value
|
|
4342
4398
|
if (!Array.isArray(overrides)) throw new Error('The Oxlint configuration has no overrides')
|
|
4343
|
-
for (const population of [POLICY_SCRIPT_GLOBS, POLICY_NESTED_GLOBS]) {
|
|
4399
|
+
for (const population of [POLICY_SCRIPT_GLOBS, POLICY_NESTED_GLOBS, POLICY_TEST_GLOBS]) {
|
|
4344
4400
|
const trimmed = {
|
|
4345
4401
|
...readConfigRecord(parsed),
|
|
4346
4402
|
overrides: overrides.filter((override: unknown) => {
|
|
@@ -4352,7 +4408,13 @@ createSomething({
|
|
|
4352
4408
|
inspectPolicyWiring(
|
|
4353
4409
|
trimmed,
|
|
4354
4410
|
[],
|
|
4355
|
-
[
|
|
4411
|
+
[
|
|
4412
|
+
POLICY_PLACEMENT_GLOBS,
|
|
4413
|
+
POLICY_ENDING_GLOBS,
|
|
4414
|
+
POLICY_SCRIPT_GLOBS,
|
|
4415
|
+
POLICY_NESTED_GLOBS,
|
|
4416
|
+
POLICY_TEST_GLOBS,
|
|
4417
|
+
],
|
|
4356
4418
|
),
|
|
4357
4419
|
).toEqual([`no override files list declares the population exactly: ${population.join(' ')}`])
|
|
4358
4420
|
}
|