@blackbelt-technology/pi-agent-dashboard 0.3.0 → 0.4.0
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/AGENTS.md +67 -116
- package/README.md +93 -7
- package/docs/architecture.md +408 -9
- package/package.json +6 -4
- package/packages/extension/package.json +11 -3
- package/packages/extension/src/__tests__/enrich-model-metadata.test.ts +201 -0
- package/packages/extension/src/__tests__/git-info.test.ts +67 -55
- package/packages/extension/src/__tests__/openspec-poller.test.ts +101 -96
- package/packages/extension/src/__tests__/process-scanner-kill.test.ts +61 -0
- package/packages/extension/src/__tests__/provider-register-reload.test.ts +394 -0
- package/packages/extension/src/__tests__/server-auto-start.test.ts +95 -4
- package/packages/extension/src/__tests__/server-launcher.test.ts +16 -0
- package/packages/extension/src/bridge.ts +69 -2
- package/packages/extension/src/dev-build.ts +1 -1
- package/packages/extension/src/git-info.ts +9 -19
- package/packages/extension/src/pi-env.d.ts +1 -0
- package/packages/extension/src/process-scanner.ts +72 -38
- package/packages/extension/src/provider-register.ts +304 -16
- package/packages/extension/src/server-auto-start.ts +27 -1
- package/packages/extension/src/server-launcher.ts +71 -27
- package/packages/server/package.json +16 -2
- package/packages/server/src/__tests__/bootstrap-queue.test.ts +120 -0
- package/packages/server/src/__tests__/bootstrap-routes.test.ts +125 -0
- package/packages/server/src/__tests__/bootstrap-state.test.ts +119 -0
- package/packages/server/src/__tests__/browse-endpoint.test.ts +17 -0
- package/packages/server/src/__tests__/cli-parse.test.ts +11 -0
- package/packages/server/src/__tests__/concurrent-launch.test.ts +110 -0
- package/packages/server/src/__tests__/config-api.test.ts +68 -0
- package/packages/server/src/__tests__/crash-recovery.test.ts +88 -0
- package/packages/server/src/__tests__/directory-service.test.ts +234 -8
- package/packages/server/src/__tests__/editor-registry.test.ts +28 -15
- package/packages/server/src/__tests__/extension-register-appimage.test.ts +5 -1
- package/packages/server/src/__tests__/extension-register.test.ts +3 -1
- package/packages/server/src/__tests__/find-port-holders.test.ts +94 -0
- package/packages/server/src/__tests__/force-kill-handler.test.ts +57 -8
- package/packages/server/src/__tests__/home-lock-escape-hatch.test.ts +60 -0
- package/packages/server/src/__tests__/home-lock-release.test.ts +85 -0
- package/packages/server/src/__tests__/home-lock.test.ts +308 -0
- package/packages/server/src/__tests__/is-pi-process.test.ts +36 -0
- package/packages/server/src/__tests__/node-guard.test.ts +85 -0
- package/packages/server/src/__tests__/package-manager-wrapper-resolve.test.ts +5 -1
- package/packages/server/src/__tests__/package-manager-wrapper.test.ts +45 -10
- package/packages/server/src/__tests__/pi-version-skew.test.ts +165 -0
- package/packages/server/src/__tests__/preferences-store.test.ts +73 -4
- package/packages/server/src/__tests__/process-manager.test.ts +45 -18
- package/packages/server/src/__tests__/provider-probe.test.ts +287 -0
- package/packages/server/src/__tests__/provider-test-route.test.ts +149 -0
- package/packages/server/src/__tests__/restart-helper.test.ts +83 -0
- package/packages/server/src/__tests__/session-action-handler-headless-reload.test.ts +467 -0
- package/packages/server/src/__tests__/session-action-handler-reload-predicate.test.ts +73 -0
- package/packages/server/src/__tests__/session-action-handler-spawn-error.test.ts +74 -0
- package/packages/server/src/__tests__/terminal-manager.test.ts +41 -1
- package/packages/server/src/__tests__/tool-routes.test.ts +277 -0
- package/packages/server/src/__tests__/trusted-networks-config.test.ts +19 -0
- package/packages/server/src/__tests__/trusted-networks-no-oauth-roundtrip.test.ts +126 -0
- package/packages/server/src/__tests__/tunnel-cleanup.test.ts +90 -0
- package/packages/server/src/__tests__/tunnel.test.ts +13 -7
- package/packages/server/src/__tests__/wsl-tmux-probe-cache.test.ts +44 -0
- package/packages/server/src/bootstrap-queue.ts +130 -0
- package/packages/server/src/bootstrap-state.ts +131 -0
- package/packages/server/src/browse.ts +8 -3
- package/packages/server/src/browser-handlers/directory-handler.ts +23 -8
- package/packages/server/src/browser-handlers/session-action-handler.ts +213 -79
- package/packages/server/src/browser-handlers/session-action-helpers.ts +36 -0
- package/packages/server/src/cli.ts +256 -32
- package/packages/server/src/config-api.ts +16 -0
- package/packages/server/src/directory-service.ts +270 -39
- package/packages/server/src/editor-detection.ts +12 -9
- package/packages/server/src/editor-manager.ts +19 -4
- package/packages/server/src/editor-pid-registry.ts +9 -8
- package/packages/server/src/editor-registry.ts +22 -25
- package/packages/server/src/git-operations.ts +1 -1
- package/packages/server/src/headless-pid-registry.ts +7 -20
- package/packages/server/src/home-lock-release.ts +72 -0
- package/packages/server/src/home-lock.ts +389 -0
- package/packages/server/src/node-guard.ts +52 -0
- package/packages/server/src/package-manager-wrapper.ts +207 -47
- package/packages/server/src/pi-core-checker.ts +1 -1
- package/packages/server/src/pi-core-updater.ts +7 -1
- package/packages/server/src/pi-resource-scanner.ts +5 -8
- package/packages/server/src/pi-version-skew.ts +196 -0
- package/packages/server/src/preferences-store.ts +17 -3
- package/packages/server/src/process-manager.ts +403 -222
- package/packages/server/src/provider-probe.ts +234 -0
- package/packages/server/src/restart-helper.ts +130 -0
- package/packages/server/src/routes/bootstrap-routes.ts +88 -0
- package/packages/server/src/routes/openspec-routes.ts +25 -1
- package/packages/server/src/routes/pi-core-routes.ts +24 -1
- package/packages/server/src/routes/provider-auth-routes.ts +8 -8
- package/packages/server/src/routes/provider-routes.ts +43 -0
- package/packages/server/src/routes/recommended-routes.ts +10 -12
- package/packages/server/src/routes/system-routes.ts +20 -33
- package/packages/server/src/routes/tool-routes.ts +153 -0
- package/packages/server/src/server-pid.ts +5 -9
- package/packages/server/src/server.ts +211 -10
- package/packages/server/src/session-api.ts +77 -8
- package/packages/server/src/session-bootstrap.ts +17 -3
- package/packages/server/src/session-diff.ts +21 -21
- package/packages/server/src/terminal-manager.ts +61 -20
- package/packages/server/src/tunnel.ts +42 -28
- package/packages/shared/package.json +10 -3
- package/packages/shared/src/__tests__/{tool-resolver.test.ts → binary-lookup.test.ts} +32 -12
- package/packages/shared/src/__tests__/bootstrap/README.md +133 -0
- package/packages/shared/src/__tests__/bootstrap/__snapshots__/cube.test.ts.snap +370 -0
- package/packages/shared/src/__tests__/bootstrap/assertions.ts +136 -0
- package/packages/shared/src/__tests__/bootstrap/cube.test.ts +47 -0
- package/packages/shared/src/__tests__/bootstrap/cube.ts +66 -0
- package/packages/shared/src/__tests__/bootstrap/families/__snapshots__/a-electron.test.ts.snap +83 -0
- package/packages/shared/src/__tests__/bootstrap/families/__snapshots__/b-npm-global.test.ts.snap +89 -0
- package/packages/shared/src/__tests__/bootstrap/families/__snapshots__/c-dev-monorepo.test.ts.snap +33 -0
- package/packages/shared/src/__tests__/bootstrap/families/__snapshots__/d-overrides.test.ts.snap +20 -0
- package/packages/shared/src/__tests__/bootstrap/families/__snapshots__/e-stale-partial.test.ts.snap +61 -0
- package/packages/shared/src/__tests__/bootstrap/families/__snapshots__/f-cwd-variants.test.ts.snap +33 -0
- package/packages/shared/src/__tests__/bootstrap/families/__snapshots__/g-windows-specifics.test.ts.snap +46 -0
- package/packages/shared/src/__tests__/bootstrap/families/__snapshots__/j-path-gui-minimal.test.ts.snap +12 -0
- package/packages/shared/src/__tests__/bootstrap/families/a-electron.test.ts +156 -0
- package/packages/shared/src/__tests__/bootstrap/families/b-npm-global.test.ts +157 -0
- package/packages/shared/src/__tests__/bootstrap/families/c-dev-monorepo.test.ts +102 -0
- package/packages/shared/src/__tests__/bootstrap/families/d-overrides.test.ts +76 -0
- package/packages/shared/src/__tests__/bootstrap/families/e-stale-partial.test.ts +94 -0
- package/packages/shared/src/__tests__/bootstrap/families/f-cwd-variants.test.ts +87 -0
- package/packages/shared/src/__tests__/bootstrap/families/g-windows-specifics.test.ts +143 -0
- package/packages/shared/src/__tests__/bootstrap/families/h-home-drift.test.ts +64 -0
- package/packages/shared/src/__tests__/bootstrap/families/i-malformed-settings.test.ts +77 -0
- package/packages/shared/src/__tests__/bootstrap/families/index.ts +19 -0
- package/packages/shared/src/__tests__/bootstrap/families/j-path-gui-minimal.test.ts +61 -0
- package/packages/shared/src/__tests__/bootstrap/families/k-dashboard-absent.test.ts +50 -0
- package/packages/shared/src/__tests__/bootstrap/families/l-instance-coordination.test.ts +272 -0
- package/packages/shared/src/__tests__/bootstrap/fixtures/dev-monorepo.ts +58 -0
- package/packages/shared/src/__tests__/bootstrap/fixtures/electron-layout.ts +84 -0
- package/packages/shared/src/__tests__/bootstrap/fixtures/index.ts +9 -0
- package/packages/shared/src/__tests__/bootstrap/fixtures/managed-install.ts +85 -0
- package/packages/shared/src/__tests__/bootstrap/fixtures/npm-global-layout.ts +122 -0
- package/packages/shared/src/__tests__/bootstrap/fixtures/pi-versions.ts +36 -0
- package/packages/shared/src/__tests__/bootstrap/fixtures/settings-json.ts +39 -0
- package/packages/shared/src/__tests__/bootstrap/harness.smoke.test.ts +220 -0
- package/packages/shared/src/__tests__/bootstrap/harness.ts +413 -0
- package/packages/shared/src/__tests__/bootstrap/scenarios-skipped.ts +125 -0
- package/packages/shared/src/__tests__/bootstrap/scenarios.ts +132 -0
- package/packages/shared/src/__tests__/bridge-register.test.ts +29 -6
- package/packages/shared/src/__tests__/config-openspec.test.ts +106 -0
- package/packages/shared/src/__tests__/config.test.ts +56 -0
- package/packages/shared/src/__tests__/detached-spawn.test.ts +243 -0
- package/packages/shared/src/__tests__/managed-paths.test.ts +60 -0
- package/packages/shared/src/__tests__/no-direct-child-process.test.ts +112 -0
- package/packages/shared/src/__tests__/no-direct-platform-branch.test.ts +174 -0
- package/packages/shared/src/__tests__/no-direct-process-kill.test.ts +105 -0
- package/packages/shared/src/__tests__/platform-commands.test.ts +108 -0
- package/packages/shared/src/__tests__/platform-exec.test.ts +103 -0
- package/packages/shared/src/__tests__/platform-git.test.ts +194 -0
- package/packages/shared/src/__tests__/platform-npm.test.ts +137 -0
- package/packages/shared/src/__tests__/platform-openspec.test.ts +92 -0
- package/packages/shared/src/__tests__/platform-paths.test.ts +284 -0
- package/packages/shared/src/__tests__/platform-process-scan.test.ts +55 -0
- package/packages/shared/src/__tests__/platform-process.test.ts +160 -0
- package/packages/shared/src/__tests__/platform-runner.test.ts +173 -0
- package/packages/shared/src/__tests__/platform-shell.test.ts +74 -0
- package/packages/shared/src/__tests__/process-identify.test.ts +113 -0
- package/packages/shared/src/__tests__/recommended-extensions.test.ts +40 -7
- package/packages/shared/src/__tests__/resolve-jiti.test.ts +43 -7
- package/packages/shared/src/__tests__/semaphore.test.ts +119 -0
- package/packages/shared/src/__tests__/spawn-mechanism.test.ts +131 -0
- package/packages/shared/src/__tests__/tool-registry-definitions.test.ts +239 -0
- package/packages/shared/src/__tests__/tool-registry-overrides.test.ts +137 -0
- package/packages/shared/src/__tests__/tool-registry-registry.test.ts +343 -0
- package/packages/shared/src/bootstrap-install.ts +212 -0
- package/packages/shared/src/bridge-register.ts +87 -20
- package/packages/shared/src/browser-protocol.ts +71 -1
- package/packages/shared/src/config.ts +87 -15
- package/packages/shared/src/managed-paths.ts +31 -4
- package/packages/shared/src/openspec-poller.ts +63 -46
- package/packages/shared/src/{tool-resolver.ts → platform/binary-lookup.ts} +125 -25
- package/packages/shared/src/platform/commands.ts +100 -0
- package/packages/shared/src/platform/detached-spawn.ts +305 -0
- package/packages/shared/src/platform/exec.ts +220 -0
- package/packages/shared/src/platform/git.ts +155 -0
- package/packages/shared/src/platform/index.ts +15 -0
- package/packages/shared/src/platform/npm.ts +162 -0
- package/packages/shared/src/platform/openspec.ts +91 -0
- package/packages/shared/src/platform/paths.ts +276 -0
- package/packages/shared/src/platform/process-identify.ts +126 -0
- package/packages/shared/src/platform/process-scan.ts +94 -0
- package/packages/shared/src/platform/process.ts +168 -0
- package/packages/shared/src/platform/runner.ts +369 -0
- package/packages/shared/src/platform/shell.ts +44 -0
- package/packages/shared/src/platform/spawn-mechanism.ts +124 -0
- package/packages/shared/src/platform/subprocess-adapter.ts +124 -0
- package/packages/shared/src/recommended-extensions.ts +18 -2
- package/packages/shared/src/resolve-jiti.ts +62 -3
- package/packages/shared/src/rest-api.ts +26 -0
- package/packages/shared/src/semaphore.ts +83 -0
- package/packages/shared/src/tool-registry/definitions.ts +342 -0
- package/packages/shared/src/tool-registry/index.ts +56 -0
- package/packages/shared/src/tool-registry/overrides.ts +118 -0
- package/packages/shared/src/tool-registry/registry.ts +262 -0
- package/packages/shared/src/tool-registry/strategies.ts +198 -0
- package/packages/shared/src/tool-registry/types.ts +180 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Bootstrap Resolution Harness
|
|
2
|
+
|
|
3
|
+
In-memory test harness for the dashboard's bootstrap resolution —
|
|
4
|
+
`ToolRegistry` + bridge-extension registration — across install
|
|
5
|
+
mechanics, platforms, and HOME/path drift.
|
|
6
|
+
|
|
7
|
+
**See** `openspec/changes/bootstrap-resolution-harness/{proposal,design}.md`
|
|
8
|
+
for the full design rationale.
|
|
9
|
+
|
|
10
|
+
## Why
|
|
11
|
+
|
|
12
|
+
The dashboard resolves pi, node, openspec, tsx across 5 strategies on
|
|
13
|
+
3 platforms. It writes bridge registration into pi's `settings.json` at
|
|
14
|
+
a HOME-dependent path. Small changes in these code paths can silently
|
|
15
|
+
break a specific install mechanic (`npm i -g pi-dashboard` on Windows,
|
|
16
|
+
Electron AppImage, GUI-launched PATH, etc.). This harness captures the
|
|
17
|
+
full state space in a memfs-backed cube so regressions surface in ms.
|
|
18
|
+
|
|
19
|
+
## File layout
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
bootstrap/
|
|
23
|
+
├── harness.ts ← withFakeEnv(), layer(), memfs wiring
|
|
24
|
+
├── assertions.ts ← snapshotTrail, snapshotSettingsDelta
|
|
25
|
+
├── scenarios.ts ← register(), skip(), cellKey(), enumerateCube()
|
|
26
|
+
├── scenarios-skipped.ts ← bulk-skip manifest (everything defaults to skipped)
|
|
27
|
+
├── cube.ts ← sweepCube() + formatUnclassifiedError()
|
|
28
|
+
├── cube.test.ts ← fail-closed sweep (breaks CI on unclassified cells)
|
|
29
|
+
├── fixtures/
|
|
30
|
+
│ ├── managed-install.ts ← ~/.pi-dashboard/ layout
|
|
31
|
+
│ ├── npm-global-layout.ts ← /usr/lib/node_modules + %APPDATA%\Roaming\npm
|
|
32
|
+
│ ├── electron-layout.ts ← packaged Electron resources
|
|
33
|
+
│ ├── dev-monorepo.ts ← workspace + hoisted deps
|
|
34
|
+
│ ├── settings-json.ts ← pi's settings.json variants
|
|
35
|
+
│ └── pi-versions.ts ← package.json stampers
|
|
36
|
+
└── families/
|
|
37
|
+
├── index.ts ← barrel — imports every family file
|
|
38
|
+
├── a-electron.test.ts ← Family A
|
|
39
|
+
├── b-npm-global.test.ts ← Family B (contains ⚠ Windows bug capture)
|
|
40
|
+
├── ... c through k
|
|
41
|
+
└── __snapshots__/ ← trail + settings-delta snapshots
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Running
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
npm run test:bootstrap # one-shot
|
|
48
|
+
npm run test:bootstrap:watch # iteration mode
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Runs in ~2 seconds. Produces 80+ tests, 40+ trail snapshots.
|
|
52
|
+
|
|
53
|
+
## Adding a scenario
|
|
54
|
+
|
|
55
|
+
1. Identify the cell-key: `<platform>/<dash>/<pi>/<settings>/<env>`
|
|
56
|
+
(see `scenarios.ts` for axis values).
|
|
57
|
+
|
|
58
|
+
2. Write a family test (or extend an existing one):
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const MY_CELLS = [
|
|
62
|
+
{ platform: "win32", dash: "managed", pi: "present-valid",
|
|
63
|
+
settings: "valid", env: "normal" },
|
|
64
|
+
] as const;
|
|
65
|
+
for (const cell of MY_CELLS) {
|
|
66
|
+
register(cell, "families/my-family.test.ts");
|
|
67
|
+
SKIPPED_SCENARIOS.delete(cellKey(cell));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
describe("My family", () => {
|
|
71
|
+
it("demonstrates something", async () => {
|
|
72
|
+
await withFakeEnv(
|
|
73
|
+
{ platform: "win32", homedir: "C:\\Users\\R",
|
|
74
|
+
fs: fixtures.managedInstall({ homedir: "C:\\Users\\R", platform: "win32" }) },
|
|
75
|
+
(ctx) => {
|
|
76
|
+
const registry = ctx.createRegistry();
|
|
77
|
+
registerDefaultTools(registry, ctx.createStrategyDeps());
|
|
78
|
+
const res = registry.resolve("pi");
|
|
79
|
+
expect(res.ok).toBe(true);
|
|
80
|
+
expect(snapshotTrail(res, ctx)).toMatchSnapshot();
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
3. Add the file to `families/index.ts` so the cube sweep picks up
|
|
88
|
+
its registrations.
|
|
89
|
+
|
|
90
|
+
4. Run `npm run test:bootstrap -- -u` to write the snapshot.
|
|
91
|
+
|
|
92
|
+
## Adding a skip
|
|
93
|
+
|
|
94
|
+
Pure skip (no test):
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
// in scenarios-skipped.ts, extend skipReasonFor()
|
|
98
|
+
if (cell.platform === "win32" && cell.env === "spaces-unicode") {
|
|
99
|
+
return "win32 + spaces-unicode: add when a bug reports here";
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Skips MUST have a non-empty reason — enforced by `skip()` at runtime.
|
|
104
|
+
|
|
105
|
+
## Fail-closed invariant
|
|
106
|
+
|
|
107
|
+
`cube.test.ts` fails if any cell is neither registered nor explicitly
|
|
108
|
+
skipped. Adding a new axis value (e.g. a new platform or install
|
|
109
|
+
location) breaks the test until each resulting cell is categorized.
|
|
110
|
+
|
|
111
|
+
Cube shape: 3 platforms × 5 dash-locations × 6 pi-states × 4 settings
|
|
112
|
+
× 3 env = **1080 cells**.
|
|
113
|
+
|
|
114
|
+
Current state: ~30 registered, ~1050 skipped with documented reasons.
|
|
115
|
+
|
|
116
|
+
## Snapshot stability
|
|
117
|
+
|
|
118
|
+
`normalizePath` rewrites `<HOME>`, `<NPM_ROOT>`, flips separators. This
|
|
119
|
+
makes snapshots stable across macOS/Linux CI. Windows CI snapshots may
|
|
120
|
+
shift marginally when run natively (path-join behavior); if that
|
|
121
|
+
surfaces, add platform-specific snapshot files.
|
|
122
|
+
|
|
123
|
+
## Downstream handoff
|
|
124
|
+
|
|
125
|
+
- **B1 snapshot** (Windows `npm i -g pi-dashboard` → pi unresolved)
|
|
126
|
+
is the input for `unified-bootstrap-install` (proposal 2). When (2)
|
|
127
|
+
lands, the expected outcome flips from "unresolved" to "resolves
|
|
128
|
+
via managed after bootstrap." Update the snapshot as part of (2)'s
|
|
129
|
+
task list.
|
|
130
|
+
|
|
131
|
+
- **Family L cells** (lock-file scenarios) will be added by
|
|
132
|
+
`single-dashboard-per-home` (proposal 3). That proposal introduces
|
|
133
|
+
a new axis (lock state) not modelled in the current cube.
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Family A — electron-packaged > A1 — electron-fresh (bundled dashboard, no pi) > resolves nothing for pi (darwin) 1`] = `
|
|
4
|
+
"name: pi
|
|
5
|
+
ok: false
|
|
6
|
+
source: —
|
|
7
|
+
path: —
|
|
8
|
+
tried:
|
|
9
|
+
override no override set
|
|
10
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
11
|
+
where not found on PATH"
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
exports[`Family A — electron-packaged > A1 — electron-fresh (bundled dashboard, no pi) > resolves nothing for pi (linux) 1`] = `
|
|
15
|
+
"name: pi
|
|
16
|
+
ok: false
|
|
17
|
+
source: —
|
|
18
|
+
path: —
|
|
19
|
+
tried:
|
|
20
|
+
override no override set
|
|
21
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
22
|
+
where not found on PATH"
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
exports[`Family A — electron-packaged > A1 — electron-fresh (bundled dashboard, no pi) > resolves nothing for pi (win32) 1`] = `
|
|
26
|
+
"name: pi
|
|
27
|
+
ok: false
|
|
28
|
+
source: —
|
|
29
|
+
path: —
|
|
30
|
+
tried:
|
|
31
|
+
override no override set
|
|
32
|
+
bare-import cannot resolve @mariozechner/pi-coding-agent/package.json
|
|
33
|
+
bare-import cannot resolve @oh-my-pi/pi-coding-agent/package.json
|
|
34
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
|
|
35
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@oh-my-pi/pi-coding-agent/dist/cli.js
|
|
36
|
+
npm-global missing: <NPM_ROOT>/@mariozechner/pi-coding-agent/dist/cli.js
|
|
37
|
+
npm-global missing: <NPM_ROOT>/@oh-my-pi/pi-coding-agent/dist/cli.js
|
|
38
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi.cmd
|
|
39
|
+
where not found on PATH"
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
exports[`Family A — electron-packaged > A2 — electron-prewarmed (bundled + managed pi) > resolves pi via managed (darwin) 1`] = `
|
|
43
|
+
"name: pi
|
|
44
|
+
ok: true
|
|
45
|
+
source: managed
|
|
46
|
+
path: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
47
|
+
tried:
|
|
48
|
+
override no override set
|
|
49
|
+
managed ok"
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
exports[`Family A — electron-packaged > A2 — electron-prewarmed (bundled + managed pi) > resolves pi via managed (linux) 1`] = `
|
|
53
|
+
"name: pi
|
|
54
|
+
ok: true
|
|
55
|
+
source: managed
|
|
56
|
+
path: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
57
|
+
tried:
|
|
58
|
+
override no override set
|
|
59
|
+
managed ok"
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
exports[`Family A — electron-packaged > A2 — electron-prewarmed (bundled + managed pi) > resolves pi via managed (win32) 1`] = `
|
|
63
|
+
"name: pi
|
|
64
|
+
ok: true
|
|
65
|
+
source: managed
|
|
66
|
+
path: <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
|
|
67
|
+
tried:
|
|
68
|
+
override no override set
|
|
69
|
+
bare-import cannot resolve @mariozechner/pi-coding-agent/package.json
|
|
70
|
+
bare-import cannot resolve @oh-my-pi/pi-coding-agent/package.json
|
|
71
|
+
managed ok"
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
exports[`Family A — electron-packaged > A3 — electron + pre-existing global pi > global npm pi takes precedence over managed-bin fallback (linux) 1`] = `
|
|
75
|
+
"name: pi
|
|
76
|
+
ok: true
|
|
77
|
+
source: system
|
|
78
|
+
path: /usr/local/bin/pi
|
|
79
|
+
tried:
|
|
80
|
+
override no override set
|
|
81
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
82
|
+
where ok"
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
exports[`Family B — npm-global > B1 — npm-g dash-only (⚠ captures current Windows bug) > pi unresolved on darwin 1`] = `
|
|
86
|
+
"name: pi
|
|
87
|
+
ok: false
|
|
88
|
+
source: —
|
|
89
|
+
path: —
|
|
90
|
+
tried:
|
|
91
|
+
override no override set
|
|
92
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
93
|
+
where not found on PATH"
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
exports[`Family B — npm-global > B1 — npm-g dash-only (⚠ captures current Windows bug) > pi unresolved on linux 1`] = `
|
|
97
|
+
"name: pi
|
|
98
|
+
ok: false
|
|
99
|
+
source: —
|
|
100
|
+
path: —
|
|
101
|
+
tried:
|
|
102
|
+
override no override set
|
|
103
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
104
|
+
where not found on PATH"
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
exports[`Family B — npm-global > B1 — npm-g dash-only (⚠ captures current Windows bug) > pi unresolved on win32 1`] = `
|
|
108
|
+
"name: pi
|
|
109
|
+
ok: false
|
|
110
|
+
source: —
|
|
111
|
+
path: —
|
|
112
|
+
tried:
|
|
113
|
+
override no override set
|
|
114
|
+
bare-import cannot resolve @mariozechner/pi-coding-agent/package.json
|
|
115
|
+
bare-import cannot resolve @oh-my-pi/pi-coding-agent/package.json
|
|
116
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
|
|
117
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@oh-my-pi/pi-coding-agent/dist/cli.js
|
|
118
|
+
npm-global missing: <NPM_ROOT>/@mariozechner/pi-coding-agent/dist/cli.js
|
|
119
|
+
npm-global missing: <NPM_ROOT>/@oh-my-pi/pi-coding-agent/dist/cli.js
|
|
120
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi.cmd
|
|
121
|
+
where not found on PATH"
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
exports[`Family B — npm-global > B2 — npm-g full (pi + openspec via global npm) > pi resolves via npm-global on darwin 1`] = `
|
|
125
|
+
"name: pi
|
|
126
|
+
ok: true
|
|
127
|
+
source: system
|
|
128
|
+
path: /usr/local/bin/pi
|
|
129
|
+
tried:
|
|
130
|
+
override no override set
|
|
131
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
132
|
+
where ok"
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
exports[`Family B — npm-global > B2 — npm-g full (pi + openspec via global npm) > pi resolves via npm-global on linux 1`] = `
|
|
136
|
+
"name: pi
|
|
137
|
+
ok: true
|
|
138
|
+
source: system
|
|
139
|
+
path: /usr/local/bin/pi
|
|
140
|
+
tried:
|
|
141
|
+
override no override set
|
|
142
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
143
|
+
where ok"
|
|
144
|
+
`;
|
|
145
|
+
|
|
146
|
+
exports[`Family B — npm-global > B2 — npm-g full (pi + openspec via global npm) > pi resolves via npm-global on win32 (with node.exe toArgv) 1`] = `
|
|
147
|
+
"name: pi
|
|
148
|
+
ok: true
|
|
149
|
+
source: npm-global
|
|
150
|
+
path: <NPM_ROOT>/@mariozechner/pi-coding-agent/dist/cli.js
|
|
151
|
+
tried:
|
|
152
|
+
override no override set
|
|
153
|
+
bare-import cannot resolve @mariozechner/pi-coding-agent/package.json
|
|
154
|
+
bare-import cannot resolve @oh-my-pi/pi-coding-agent/package.json
|
|
155
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
|
|
156
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@oh-my-pi/pi-coding-agent/dist/cli.js
|
|
157
|
+
npm-global ok
|
|
158
|
+
argv:
|
|
159
|
+
- C:/Program Files/nodejs/node.exe
|
|
160
|
+
- <NPM_ROOT>/@mariozechner/pi-coding-agent/dist/cli.js"
|
|
161
|
+
`;
|
|
162
|
+
|
|
163
|
+
exports[`Family B — npm-global > B3 — npm-g pi-installed-first (bridge needs registration) > settings.json present but lacks bridge entry (linux) 1`] = `
|
|
164
|
+
"settings-delta:
|
|
165
|
+
added:
|
|
166
|
+
(none)
|
|
167
|
+
removed:
|
|
168
|
+
(none)
|
|
169
|
+
preserved:
|
|
170
|
+
(none)"
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
exports[`Family C — dev monorepo > C1 — posix (managed/where chain, no bare-import for pi) > pi chain runs on darwin 1`] = `
|
|
174
|
+
"name: pi
|
|
175
|
+
ok: false
|
|
176
|
+
source: —
|
|
177
|
+
path: —
|
|
178
|
+
tried:
|
|
179
|
+
override no override set
|
|
180
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
181
|
+
where not found on PATH"
|
|
182
|
+
`;
|
|
183
|
+
|
|
184
|
+
exports[`Family C — dev monorepo > C1 — posix (managed/where chain, no bare-import for pi) > pi chain runs on linux 1`] = `
|
|
185
|
+
"name: pi
|
|
186
|
+
ok: false
|
|
187
|
+
source: —
|
|
188
|
+
path: —
|
|
189
|
+
tried:
|
|
190
|
+
override no override set
|
|
191
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
192
|
+
where not found on PATH"
|
|
193
|
+
`;
|
|
194
|
+
|
|
195
|
+
exports[`Family C — dev monorepo > C2 — win32 (bare-import from workspace) > resolves pi via workspace bare-import 1`] = `
|
|
196
|
+
"name: pi
|
|
197
|
+
ok: true
|
|
198
|
+
source: bare-import
|
|
199
|
+
path: dist/cli.js
|
|
200
|
+
tried:
|
|
201
|
+
override no override set
|
|
202
|
+
bare-import ok"
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
exports[`Family D — overrides > D1 — override-valid: pi resolves via override 1`] = `
|
|
206
|
+
"name: pi
|
|
207
|
+
ok: true
|
|
208
|
+
source: override
|
|
209
|
+
path: /opt/custom/bin/pi
|
|
210
|
+
tried:
|
|
211
|
+
override ok"
|
|
212
|
+
`;
|
|
213
|
+
|
|
214
|
+
exports[`Family D — overrides > D2 — override-invalid: path doesn't exist, chain falls through 1`] = `
|
|
215
|
+
"name: pi
|
|
216
|
+
ok: true
|
|
217
|
+
source: managed
|
|
218
|
+
path: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
219
|
+
tried:
|
|
220
|
+
override invalid: path does not exist: /nonexistent/broken/pi
|
|
221
|
+
managed ok"
|
|
222
|
+
`;
|
|
223
|
+
|
|
224
|
+
exports[`Family E — stale / partial > E1 — stale managed pi (old version) > current strategies resolve without version gating (darwin) 1`] = `
|
|
225
|
+
"name: pi
|
|
226
|
+
ok: true
|
|
227
|
+
source: managed
|
|
228
|
+
path: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
229
|
+
tried:
|
|
230
|
+
override no override set
|
|
231
|
+
managed ok"
|
|
232
|
+
`;
|
|
233
|
+
|
|
234
|
+
exports[`Family E — stale / partial > E1 — stale managed pi (old version) > current strategies resolve without version gating (linux) 1`] = `
|
|
235
|
+
"name: pi
|
|
236
|
+
ok: true
|
|
237
|
+
source: managed
|
|
238
|
+
path: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
239
|
+
tried:
|
|
240
|
+
override no override set
|
|
241
|
+
managed ok"
|
|
242
|
+
`;
|
|
243
|
+
|
|
244
|
+
exports[`Family E — stale / partial > E1 — stale managed pi (old version) > current strategies resolve without version gating (win32) 1`] = `
|
|
245
|
+
"name: pi
|
|
246
|
+
ok: true
|
|
247
|
+
source: managed
|
|
248
|
+
path: <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
|
|
249
|
+
tried:
|
|
250
|
+
override no override set
|
|
251
|
+
bare-import cannot resolve @mariozechner/pi-coding-agent/package.json
|
|
252
|
+
bare-import cannot resolve @oh-my-pi/pi-coding-agent/package.json
|
|
253
|
+
managed ok"
|
|
254
|
+
`;
|
|
255
|
+
|
|
256
|
+
exports[`Family E — stale / partial > E2 — partial managed install (package.json, no dist) > strategy skips when entry file absent (linux) 1`] = `
|
|
257
|
+
"name: pi
|
|
258
|
+
ok: false
|
|
259
|
+
source: —
|
|
260
|
+
path: —
|
|
261
|
+
tried:
|
|
262
|
+
override no override set
|
|
263
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
264
|
+
where not found on PATH"
|
|
265
|
+
`;
|
|
266
|
+
|
|
267
|
+
exports[`Family E — stale / partial > E2 — partial managed install (package.json, no dist) > strategy skips when entry file absent (win32) 1`] = `
|
|
268
|
+
"name: pi
|
|
269
|
+
ok: false
|
|
270
|
+
source: —
|
|
271
|
+
path: —
|
|
272
|
+
tried:
|
|
273
|
+
override no override set
|
|
274
|
+
bare-import cannot resolve @mariozechner/pi-coding-agent/package.json
|
|
275
|
+
bare-import cannot resolve @oh-my-pi/pi-coding-agent/package.json
|
|
276
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
|
|
277
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@oh-my-pi/pi-coding-agent/dist/cli.js
|
|
278
|
+
npm-global missing: <NPM_ROOT>/@mariozechner/pi-coding-agent/dist/cli.js
|
|
279
|
+
npm-global missing: <NPM_ROOT>/@oh-my-pi/pi-coding-agent/dist/cli.js
|
|
280
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi.cmd
|
|
281
|
+
where not found on PATH"
|
|
282
|
+
`;
|
|
283
|
+
|
|
284
|
+
exports[`Family F — cwd variants > F1 — resolves normally with Program Files (x86) cwd (win32) 1`] = `
|
|
285
|
+
"name: pi
|
|
286
|
+
ok: true
|
|
287
|
+
source: managed
|
|
288
|
+
path: <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
|
|
289
|
+
tried:
|
|
290
|
+
override no override set
|
|
291
|
+
bare-import cannot resolve @mariozechner/pi-coding-agent/package.json
|
|
292
|
+
bare-import cannot resolve @oh-my-pi/pi-coding-agent/package.json
|
|
293
|
+
managed ok"
|
|
294
|
+
`;
|
|
295
|
+
|
|
296
|
+
exports[`Family F — cwd variants > F1 — resolves normally with spaces in cwd (linux) 1`] = `
|
|
297
|
+
"name: pi
|
|
298
|
+
ok: true
|
|
299
|
+
source: managed
|
|
300
|
+
path: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
301
|
+
tried:
|
|
302
|
+
override no override set
|
|
303
|
+
managed ok"
|
|
304
|
+
`;
|
|
305
|
+
|
|
306
|
+
exports[`Family F — cwd variants > F2 — resolves with Greek/Cyrillic/emoji in cwd 1`] = `
|
|
307
|
+
"name: pi
|
|
308
|
+
ok: true
|
|
309
|
+
source: managed
|
|
310
|
+
path: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
311
|
+
tried:
|
|
312
|
+
override no override set
|
|
313
|
+
managed ok"
|
|
314
|
+
`;
|
|
315
|
+
|
|
316
|
+
exports[`Family G — Windows specifics > G1 — pi.cmd resolved + toArgv prepends node.exe (no-cmd-flash) 1`] = `
|
|
317
|
+
"name: pi
|
|
318
|
+
ok: true
|
|
319
|
+
source: managed
|
|
320
|
+
path: <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
|
|
321
|
+
tried:
|
|
322
|
+
override no override set
|
|
323
|
+
bare-import cannot resolve @mariozechner/pi-coding-agent/package.json
|
|
324
|
+
bare-import cannot resolve @oh-my-pi/pi-coding-agent/package.json
|
|
325
|
+
managed ok
|
|
326
|
+
argv:
|
|
327
|
+
- C:/Program Files/nodejs/node.exe
|
|
328
|
+
- <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js"
|
|
329
|
+
`;
|
|
330
|
+
|
|
331
|
+
exports[`Family G — Windows specifics > G2 — npm-g at %APPDATA%\\Roaming\\npm (argv prepends node.exe) 1`] = `
|
|
332
|
+
"name: pi
|
|
333
|
+
ok: true
|
|
334
|
+
source: npm-global
|
|
335
|
+
path: <NPM_ROOT>/@mariozechner/pi-coding-agent/dist/cli.js
|
|
336
|
+
tried:
|
|
337
|
+
override no override set
|
|
338
|
+
bare-import cannot resolve @mariozechner/pi-coding-agent/package.json
|
|
339
|
+
bare-import cannot resolve @oh-my-pi/pi-coding-agent/package.json
|
|
340
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
|
|
341
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/@oh-my-pi/pi-coding-agent/dist/cli.js
|
|
342
|
+
npm-global ok
|
|
343
|
+
argv:
|
|
344
|
+
- C:/Program Files/nodejs/node.exe
|
|
345
|
+
- <NPM_ROOT>/@mariozechner/pi-coding-agent/dist/cli.js"
|
|
346
|
+
`;
|
|
347
|
+
|
|
348
|
+
exports[`Family G — Windows specifics > G4 — node.exe at C:\\Program Files\\nodejs\\node.exe 1`] = `
|
|
349
|
+
"name: node
|
|
350
|
+
ok: true
|
|
351
|
+
source: system
|
|
352
|
+
path: C:/Program Files/nodejs/node.exe
|
|
353
|
+
tried:
|
|
354
|
+
override no override set
|
|
355
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/node.cmd
|
|
356
|
+
where ok
|
|
357
|
+
argv:
|
|
358
|
+
- C:/Program Files/nodejs/node.exe"
|
|
359
|
+
`;
|
|
360
|
+
|
|
361
|
+
exports[`Family J — minimal PATH > J1 — GUI-launched minimal PATH: pi does NOT resolve on posix (limitation) 1`] = `
|
|
362
|
+
"name: pi
|
|
363
|
+
ok: false
|
|
364
|
+
source: —
|
|
365
|
+
path: —
|
|
366
|
+
tried:
|
|
367
|
+
override no override set
|
|
368
|
+
managed missing: <HOME>/.pi-dashboard/node_modules/.bin/pi
|
|
369
|
+
where not found on PATH"
|
|
370
|
+
`;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot helpers — normalize environment-specific paths so snapshots
|
|
3
|
+
* are stable across OS/CI runs.
|
|
4
|
+
*
|
|
5
|
+
* See openspec/changes/bootstrap-resolution-harness/design.md §8, §9.
|
|
6
|
+
*/
|
|
7
|
+
import type { ExecutorResolution, Resolution } from "../../tool-registry/types.js";
|
|
8
|
+
import type { HarnessContext } from "./harness.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A resolution that may carry executor argv. Trail snapshots accept
|
|
12
|
+
* both plain `Resolution` (from `registry.resolve()`) and
|
|
13
|
+
* `ExecutorResolution` (from `registry.resolveExecutor()`) — when argv
|
|
14
|
+
* is present, it's rendered in the snapshot to lock in the
|
|
15
|
+
* no-cmd-flash / node-prepend invariant on Windows.
|
|
16
|
+
*/
|
|
17
|
+
type MaybeExecutor = Resolution | ExecutorResolution;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Normalize a path for snapshot stability:
|
|
21
|
+
* - replace homedir with `<HOME>`
|
|
22
|
+
* - replace npm-root with `<NPM_ROOT>`
|
|
23
|
+
* - flip backslashes to forward slashes
|
|
24
|
+
* - collapse duplicate slashes
|
|
25
|
+
*/
|
|
26
|
+
export function normalizePath(
|
|
27
|
+
p: string | null | undefined,
|
|
28
|
+
ctx: Pick<HarnessContext, "homedir" | "npmRootGlobal">,
|
|
29
|
+
): string | null {
|
|
30
|
+
if (p == null) return null;
|
|
31
|
+
let out = p;
|
|
32
|
+
// Order matters: replace longer prefixes first.
|
|
33
|
+
const homeVariants = [ctx.homedir, ctx.homedir.replace(/\\/g, "/")];
|
|
34
|
+
const npmVariants = [ctx.npmRootGlobal, ctx.npmRootGlobal.replace(/\\/g, "/")];
|
|
35
|
+
for (const v of npmVariants) {
|
|
36
|
+
if (v) out = out.split(v).join("<NPM_ROOT>");
|
|
37
|
+
}
|
|
38
|
+
for (const v of homeVariants) {
|
|
39
|
+
if (v) out = out.split(v).join("<HOME>");
|
|
40
|
+
}
|
|
41
|
+
out = out.replace(/\\/g, "/");
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Trail snapshot. Primary assertion for ToolRegistry resolution tests.
|
|
47
|
+
* Output is a multiline string ready for `toMatchSnapshot()`.
|
|
48
|
+
*
|
|
49
|
+
* When passed an `ExecutorResolution` (from `registry.resolveExecutor`),
|
|
50
|
+
* renders an `argv:` section proving the `toArgv` transform. On
|
|
51
|
+
* Windows this locks in the no-cmd-flash invariant — argv for a
|
|
52
|
+
* resolved `.js` target MUST be `[<node.exe>, <cli.js>]`, not the
|
|
53
|
+
* `.cmd` shim that would allocate a console.
|
|
54
|
+
*/
|
|
55
|
+
export function snapshotTrail(
|
|
56
|
+
resolution: MaybeExecutor,
|
|
57
|
+
ctx: Pick<HarnessContext, "homedir" | "npmRootGlobal">,
|
|
58
|
+
): string {
|
|
59
|
+
const lines: string[] = [];
|
|
60
|
+
lines.push(`name: ${resolution.name}`);
|
|
61
|
+
lines.push(`ok: ${resolution.ok}`);
|
|
62
|
+
lines.push(`source: ${resolution.source ?? "—"}`);
|
|
63
|
+
lines.push(`path: ${normalizePath(resolution.path, ctx) ?? "—"}`);
|
|
64
|
+
lines.push("tried:");
|
|
65
|
+
for (const entry of resolution.tried) {
|
|
66
|
+
// Normalize paths embedded in the reason string too (e.g.
|
|
67
|
+
// "missing: <HOME>/.pi-dashboard/...") so snapshots are
|
|
68
|
+
// stable across OS CI runners.
|
|
69
|
+
const result = normalizePath(entry.result, ctx) ?? entry.result;
|
|
70
|
+
lines.push(` ${entry.strategy.padEnd(12)} ${result}`);
|
|
71
|
+
}
|
|
72
|
+
// argv section — present only when the caller invoked
|
|
73
|
+
// registry.resolveExecutor() (ExecutorResolution has `argv`).
|
|
74
|
+
const argv = (resolution as ExecutorResolution).argv;
|
|
75
|
+
if (Array.isArray(argv) && argv.length > 0) {
|
|
76
|
+
lines.push("argv:");
|
|
77
|
+
for (const a of argv) {
|
|
78
|
+
lines.push(` - ${normalizePath(a, ctx) ?? a}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return lines.join("\n");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Diff two settings-json snapshots: which entries were added, removed,
|
|
86
|
+
* or preserved.
|
|
87
|
+
*/
|
|
88
|
+
export function snapshotSettingsDelta(
|
|
89
|
+
before: { packages?: readonly string[] } | null,
|
|
90
|
+
after: { packages?: readonly string[] } | null,
|
|
91
|
+
ctx: Pick<HarnessContext, "homedir" | "npmRootGlobal">,
|
|
92
|
+
): string {
|
|
93
|
+
const beforeSet = new Set(before?.packages ?? []);
|
|
94
|
+
const afterSet = new Set(after?.packages ?? []);
|
|
95
|
+
const added = [...afterSet].filter((p) => !beforeSet.has(p));
|
|
96
|
+
const removed = [...beforeSet].filter((p) => !afterSet.has(p));
|
|
97
|
+
const preserved = [...beforeSet].filter((p) => afterSet.has(p));
|
|
98
|
+
|
|
99
|
+
const norm = (arr: string[]) =>
|
|
100
|
+
arr
|
|
101
|
+
.map((p) => normalizePath(p, ctx))
|
|
102
|
+
.filter((p): p is string => p !== null)
|
|
103
|
+
.sort();
|
|
104
|
+
|
|
105
|
+
const lines: string[] = [];
|
|
106
|
+
lines.push("settings-delta:");
|
|
107
|
+
lines.push(` added:`);
|
|
108
|
+
for (const p of norm(added)) lines.push(` + ${p}`);
|
|
109
|
+
if (added.length === 0) lines.push(" (none)");
|
|
110
|
+
lines.push(` removed:`);
|
|
111
|
+
for (const p of norm(removed)) lines.push(` - ${p}`);
|
|
112
|
+
if (removed.length === 0) lines.push(" (none)");
|
|
113
|
+
lines.push(` preserved:`);
|
|
114
|
+
for (const p of norm(preserved)) lines.push(` = ${p}`);
|
|
115
|
+
if (preserved.length === 0) lines.push(" (none)");
|
|
116
|
+
return lines.join("\n");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Simple snapshot of a settings.json object as a sorted list. Used when
|
|
121
|
+
* only the "after" state matters.
|
|
122
|
+
*/
|
|
123
|
+
export function snapshotSettings(
|
|
124
|
+
settings: { packages?: readonly string[] } | null,
|
|
125
|
+
ctx: Pick<HarnessContext, "homedir" | "npmRootGlobal">,
|
|
126
|
+
): string {
|
|
127
|
+
if (!settings) return "settings.json: (absent)";
|
|
128
|
+
const packages = (settings.packages ?? [])
|
|
129
|
+
.map((p) => normalizePath(p, ctx))
|
|
130
|
+
.filter((p): p is string => p !== null)
|
|
131
|
+
.sort();
|
|
132
|
+
const lines: string[] = ["settings.json:", " packages:"];
|
|
133
|
+
for (const p of packages) lines.push(` - ${p}`);
|
|
134
|
+
if (packages.length === 0) lines.push(" (empty)");
|
|
135
|
+
return lines.join("\n");
|
|
136
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cube sweep — the fail-closed invariant. Every cell must be either
|
|
3
|
+
* registered (by a family-test file) or explicitly skipped (in
|
|
4
|
+
* `scenarios-skipped.ts`).
|
|
5
|
+
*
|
|
6
|
+
* New cells added to the enumeration — by extending PLATFORMS,
|
|
7
|
+
* DASH_LOCATIONS, PI_STATES, SETTINGS_STATES, or ENV_STATES in
|
|
8
|
+
* `scenarios.ts` — will break this test until a decision is made.
|
|
9
|
+
* This is intentional: the test forces every install mechanic to
|
|
10
|
+
* be categorized.
|
|
11
|
+
*/
|
|
12
|
+
import { describe, expect, it } from "vitest";
|
|
13
|
+
import { sweepCube, formatUnclassifiedError } from "./cube.js";
|
|
14
|
+
// IMPORTANT: import the skip manifest BEFORE any family-test file, so
|
|
15
|
+
// the bulk skips are applied first and families override them via
|
|
16
|
+
// `register()`.
|
|
17
|
+
import "./scenarios-skipped.js";
|
|
18
|
+
// Then import family files so their top-level `register(cell, tag)`
|
|
19
|
+
// calls execute. Each family file clears the corresponding skip entry.
|
|
20
|
+
import "./families/index.js";
|
|
21
|
+
|
|
22
|
+
describe("bootstrap scenario cube", () => {
|
|
23
|
+
it("every cell is either registered or skipped (fail-closed)", () => {
|
|
24
|
+
const report = sweepCube();
|
|
25
|
+
if (report.unclassified.length > 0) {
|
|
26
|
+
throw new Error(formatUnclassifiedError(report));
|
|
27
|
+
}
|
|
28
|
+
expect(report.unclassified.length).toBe(0);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("cube has the expected shape (3 × 5 × 6 × 4 × 3 = 1080 cells)", () => {
|
|
32
|
+
const report = sweepCube();
|
|
33
|
+
expect(report.total).toBe(1080);
|
|
34
|
+
expect(report.registered + report.skipped).toBe(report.total);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("at least one family registered a cell (smoke)", () => {
|
|
38
|
+
const report = sweepCube();
|
|
39
|
+
expect(report.registered).toBeGreaterThan(0);
|
|
40
|
+
// Visible in test output so cube growth is trackable without
|
|
41
|
+
// digging into internals.
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log(
|
|
44
|
+
`[cube] registered=${report.registered} skipped=${report.skipped} total=${report.total}`,
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
});
|