@blackbelt-technology/pi-agent-dashboard 0.6.0 → 0.7.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/README.md +40 -38
- package/docs/architecture.md +148 -2
- package/package.json +6 -4
- package/packages/extension/package.json +4 -3
- package/packages/extension/src/AGENTS.md +1 -0
- package/packages/extension/src/__tests__/bridge-resume-disconnect.test.ts +333 -0
- package/packages/extension/src/__tests__/openspec-cli-shim.test.ts +145 -0
- package/packages/extension/src/__tests__/provider-register-native-models.test.ts +182 -0
- package/packages/extension/src/__tests__/provider-register-thinking-levels.test.ts +54 -1
- package/packages/extension/src/__tests__/single-derivation-guard.test.ts +39 -0
- package/packages/extension/src/bridge-context.ts +21 -0
- package/packages/extension/src/bridge.ts +41 -6
- package/packages/extension/src/openspec-cli-shim.ts +173 -0
- package/packages/extension/src/openspec-cli-shim.ts.AGENTS.md +7 -0
- package/packages/extension/src/provider-register.ts +180 -17
- package/packages/extension/src/provider-register.ts.AGENTS.md +1 -1
- package/packages/extension/src/session-sync.ts +9 -4
- package/packages/server/package.json +8 -8
- package/packages/server/src/__tests__/decorate-goals-spend.test.ts +79 -0
- package/packages/server/src/__tests__/embed-lifecycle-boot-smoke.test.ts +44 -0
- package/packages/server/src/__tests__/goal-routes.test.ts +62 -7
- package/packages/server/src/__tests__/goal-supervisor.test.ts +4 -4
- package/packages/server/src/__tests__/headless-pid-registry.test.ts +7 -3
- package/packages/server/src/__tests__/memory-event-store.test.ts +369 -13
- package/packages/server/src/__tests__/models-introspection-thinking-map.test.ts +67 -0
- package/packages/server/src/__tests__/pi-changelog-routes.test.ts +9 -2
- package/packages/server/src/__tests__/recovery-offer.test.ts +42 -7
- package/packages/server/src/__tests__/recovery-reattach-retraction.test.ts +188 -0
- package/packages/server/src/__tests__/session-tags-persistence.test.ts +29 -0
- package/packages/server/src/browser-handlers/AGENTS.md +1 -1
- package/packages/server/src/browser-handlers/__tests__/session-meta-handler.test.ts +98 -1
- package/packages/server/src/browser-handlers/handler-context.ts +24 -13
- package/packages/server/src/browser-handlers/session-action-handler.ts +12 -1
- package/packages/server/src/browser-handlers/session-meta-handler.ts +29 -0
- package/packages/server/src/embed-lifecycle/AGENTS.md +17 -0
- package/packages/server/src/embed-lifecycle/__tests__/caps.test.ts +129 -0
- package/packages/server/src/embed-lifecycle/__tests__/embed-lifecycle-controller.test.ts +84 -0
- package/packages/server/src/embed-lifecycle/__tests__/identity-key.test.ts +73 -0
- package/packages/server/src/embed-lifecycle/__tests__/idle-reaper.test.ts +173 -0
- package/packages/server/src/embed-lifecycle/__tests__/lifecycle-config.test.ts +26 -0
- package/packages/server/src/embed-lifecycle/__tests__/lifecycle-event-capture.test.ts +32 -0
- package/packages/server/src/embed-lifecycle/__tests__/lifecycle-marker-persistence.test.ts +106 -0
- package/packages/server/src/embed-lifecycle/__tests__/lifecycle-metrics.test.ts +39 -0
- package/packages/server/src/embed-lifecycle/__tests__/liveness-probe.test.ts +77 -0
- package/packages/server/src/embed-lifecycle/__tests__/quiescence.test.ts +175 -0
- package/packages/server/src/embed-lifecycle/__tests__/reclamation-soak.test.ts +77 -0
- package/packages/server/src/embed-lifecycle/__tests__/session-lifecycle-policy.test.ts +38 -0
- package/packages/server/src/embed-lifecycle/__tests__/visitor-session-registry.test.ts +140 -0
- package/packages/server/src/embed-lifecycle/caps.ts +88 -0
- package/packages/server/src/embed-lifecycle/cwd-allowlist.ts +50 -0
- package/packages/server/src/embed-lifecycle/embed-lifecycle-controller.ts +90 -0
- package/packages/server/src/embed-lifecycle/identity-key.ts +73 -0
- package/packages/server/src/embed-lifecycle/idle-reaper.ts +161 -0
- package/packages/server/src/embed-lifecycle/lifecycle-event-capture.ts +30 -0
- package/packages/server/src/embed-lifecycle/lifecycle-metrics.ts +70 -0
- package/packages/server/src/embed-lifecycle/liveness-probe.ts +123 -0
- package/packages/server/src/embed-lifecycle/quiescence.ts +159 -0
- package/packages/server/src/embed-lifecycle/session-lifecycle-policy.ts +31 -0
- package/packages/server/src/embed-lifecycle/visitor-session-registry.ts +178 -0
- package/packages/server/src/event-wiring.ts +20 -0
- package/packages/server/src/event-wiring.ts.AGENTS.md +1 -0
- package/packages/server/src/goal/AGENTS.md +1 -0
- package/packages/server/src/goal/decorate-goals-spend.ts +47 -0
- package/packages/server/src/goal/goal-supervisor.ts +5 -3
- package/packages/server/src/model-proxy/AGENTS.md +2 -2
- package/packages/server/src/model-proxy/__tests__/internal-registry-native-merge.test.ts +155 -0
- package/packages/server/src/model-proxy/__tests__/read-native-models.test.ts +92 -0
- package/packages/server/src/model-proxy/internal-registry.ts +49 -23
- package/packages/server/src/model-proxy/registry-singleton.ts +15 -9
- package/packages/server/src/pairing/browser-gateway.ts +40 -11
- package/packages/server/src/pairing/browser-gateway.ts.AGENTS.md +1 -1
- package/packages/server/src/persistence/memory-event-store.ts +369 -23
- package/packages/server/src/persistence/memory-event-store.ts.AGENTS.md +1 -1
- package/packages/server/src/routes/AGENTS.md +2 -2
- package/packages/server/src/routes/goal-routes.ts +14 -9
- package/packages/server/src/routes/models-introspection-routes.ts +10 -0
- package/packages/server/src/routes/system-routes.ts +16 -1
- package/packages/server/src/server.ts +216 -65
- package/packages/server/src/server.ts.AGENTS.md +1 -1
- package/packages/server/src/session/memory-session-manager.ts +4 -0
- package/packages/server/src/session/session-scanner.ts +9 -0
- package/packages/server/src/session/session-to-meta.ts +6 -0
- package/packages/server/src/spawn-process/headless-pid-registry.ts +14 -4
- package/packages/shared/package.json +1 -1
- package/packages/shared/src/AGENTS.md +5 -3
- package/packages/shared/src/__tests__/models-json-reader.test.ts +100 -0
- package/packages/shared/src/__tests__/nightly-workflow-contract.test.ts +125 -0
- package/packages/shared/src/__tests__/openspec-poller-1.6.0-compat.test.ts +112 -0
- package/packages/shared/src/__tests__/pnpm-migration-contract.test.ts +177 -0
- package/packages/shared/src/__tests__/publish-workflow-contract.test.ts +6 -3
- package/packages/shared/src/browser-protocol.ts +22 -0
- package/packages/shared/src/config.ts +70 -0
- package/packages/shared/src/dashboard-plugin/AGENTS.md +1 -1
- package/packages/shared/src/dashboard-plugin/slot-props.ts +9 -0
- package/packages/shared/src/dashboard-plugin/ui-primitives.ts +19 -0
- package/packages/shared/src/models-json-reader.ts +98 -0
- package/packages/shared/src/platform/AGENTS.md +1 -1
- package/packages/shared/src/platform/paths.ts +12 -0
- package/packages/shared/src/session-meta.ts +9 -0
- package/packages/shared/src/types.ts +52 -1
- package/docs/AGENTS.md +0 -47
- package/packages/extension/AGENTS.md +0 -7
- package/packages/server/AGENTS.md +0 -7
- package/packages/shared/AGENTS.md +0 -7
- package/scripts/AGENTS.md +0 -38
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared `flattenModelsJson` reader: nested native flatten + parent-key
|
|
3
|
+
* precedence + legacy shapes + per-provider defensiveness.
|
|
4
|
+
*
|
|
5
|
+
* See change: honor-native-models-json-metadata (test-plan E1/E2/E3/X1).
|
|
6
|
+
*/
|
|
7
|
+
import { describe, expect, it } from "vitest";
|
|
8
|
+
import { flattenModelsJson } from "../models-json-reader.js";
|
|
9
|
+
|
|
10
|
+
describe("flattenModelsJson — native nested flatten (E1)", () => {
|
|
11
|
+
it("flattens providers.<p>.models[] stamping the parent provider, carrying all fields", () => {
|
|
12
|
+
const map = { minimal: null, xhigh: "xhigh", max: "max" };
|
|
13
|
+
const compat = { thinkingFormat: "deepseek", supportsReasoningEffort: true };
|
|
14
|
+
const out = flattenModelsJson({
|
|
15
|
+
providers: {
|
|
16
|
+
newapi: {
|
|
17
|
+
models: [
|
|
18
|
+
{
|
|
19
|
+
id: "glm-5.2",
|
|
20
|
+
contextWindow: 200000,
|
|
21
|
+
maxTokens: 65536,
|
|
22
|
+
reasoning: true,
|
|
23
|
+
thinkingLevelMap: map,
|
|
24
|
+
compat,
|
|
25
|
+
input: ["text", "image"],
|
|
26
|
+
cost: { input: 1, output: 2 },
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
expect(out).toHaveLength(1);
|
|
33
|
+
expect(out[0]).toMatchObject({
|
|
34
|
+
provider: "newapi",
|
|
35
|
+
id: "glm-5.2",
|
|
36
|
+
contextWindow: 200000,
|
|
37
|
+
maxTokens: 65536,
|
|
38
|
+
reasoning: true,
|
|
39
|
+
thinkingLevelMap: map,
|
|
40
|
+
compat,
|
|
41
|
+
input: ["text", "image"],
|
|
42
|
+
cost: { input: 1, output: 2 },
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("flattenModelsJson — parent key wins over in-entry provider (E2)", () => {
|
|
48
|
+
it("stamps the parent provider key, not the entry's own provider field", () => {
|
|
49
|
+
const out = flattenModelsJson({
|
|
50
|
+
providers: { newapi: { models: [{ id: "glm-5.2", provider: "other" }] } },
|
|
51
|
+
});
|
|
52
|
+
expect(out).toHaveLength(1);
|
|
53
|
+
expect(out[0].provider).toBe("newapi");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("flattenModelsJson — legacy shapes + nested wins on collision (E3)", () => {
|
|
58
|
+
it("accepts a legacy top-level array", () => {
|
|
59
|
+
const out = flattenModelsJson([{ provider: "newapi", id: "glm-5.2", maxTokens: 8192 }]);
|
|
60
|
+
expect(out).toEqual([{ provider: "newapi", id: "glm-5.2", maxTokens: 8192 }]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("accepts a legacy { models: [] } object", () => {
|
|
64
|
+
const out = flattenModelsJson({ models: [{ provider: "newapi", id: "glm-5.2", maxTokens: 8192 }] });
|
|
65
|
+
expect(out).toHaveLength(1);
|
|
66
|
+
expect(out[0]).toMatchObject({ provider: "newapi", id: "glm-5.2", maxTokens: 8192 });
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("nested native entry wins over a legacy top-level entry on provider/id collision", () => {
|
|
70
|
+
const out = flattenModelsJson({
|
|
71
|
+
models: [{ provider: "newapi", id: "glm-5.2", maxTokens: 8192 }],
|
|
72
|
+
providers: { newapi: { models: [{ id: "glm-5.2", maxTokens: 65536 }] } },
|
|
73
|
+
});
|
|
74
|
+
expect(out).toHaveLength(1);
|
|
75
|
+
expect(out[0].maxTokens).toBe(65536);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe("flattenModelsJson — per-provider defensiveness (X1)", () => {
|
|
80
|
+
it("a malformed provider block yields no entries for that block but keeps others", () => {
|
|
81
|
+
const out = flattenModelsJson({
|
|
82
|
+
providers: {
|
|
83
|
+
bad: { models: "not-an-array" },
|
|
84
|
+
good: { models: [{ id: "m1" }] },
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
expect(out).toEqual([{ provider: "good", id: "m1" }]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("entries without a string id are skipped", () => {
|
|
91
|
+
const out = flattenModelsJson({ providers: { p: { models: [{ noId: true }, { id: "" }, { id: "ok" }] } } });
|
|
92
|
+
expect(out).toEqual([{ provider: "p", id: "ok" }]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("non-object input returns []", () => {
|
|
96
|
+
expect(flattenModelsJson(null)).toEqual([]);
|
|
97
|
+
expect(flattenModelsJson("x")).toEqual([]);
|
|
98
|
+
expect(flattenModelsJson(42)).toEqual([]);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repo-level safety contract for the nightly Verdaccio build (change:
|
|
3
|
+
* add-nightly-verdaccio-build, task 5).
|
|
4
|
+
*
|
|
5
|
+
* The nightly's hard requirement is ZERO public npm writes and NO release
|
|
6
|
+
* side effects. This test locks that as a repo-lint so a future edit cannot
|
|
7
|
+
* silently turn the nightly into a real release:
|
|
8
|
+
*
|
|
9
|
+
* nightly.yml:
|
|
10
|
+
* - every `npm publish` MUST be `--dry-run` OR carry
|
|
11
|
+
* `--registry http://localhost` (a dry-run writes nothing; the REAL
|
|
12
|
+
* publishes live in scripts/nightly-verdaccio-publish.mjs and target
|
|
13
|
+
* http://localhost:4873);
|
|
14
|
+
* - NO `softprops/action-gh-release` (no GitHub Release);
|
|
15
|
+
* - NO tag `git push`;
|
|
16
|
+
* - NO version-bump `git commit`.
|
|
17
|
+
*
|
|
18
|
+
* _electron-build.yml:
|
|
19
|
+
* - the pre-existing "pure artifact producer" invariant is UNTOUCHED by
|
|
20
|
+
* the `registry_url` addition: still no `npm publish`, no Release,
|
|
21
|
+
* no tag push.
|
|
22
|
+
*
|
|
23
|
+
* If this test fails, the nightly is at risk of polluting public npm or
|
|
24
|
+
* cutting an unintended Release — revert the offending line.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import fs from "node:fs";
|
|
28
|
+
import path from "node:path";
|
|
29
|
+
import url from "node:url";
|
|
30
|
+
import { describe, expect, it } from "vitest";
|
|
31
|
+
|
|
32
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
33
|
+
const REPO_ROOT = path.resolve(__dirname, "..", "..", "..", "..");
|
|
34
|
+
const NIGHTLY = path.join(REPO_ROOT, ".github", "workflows", "nightly.yml");
|
|
35
|
+
const ELECTRON_BUILD = path.join(
|
|
36
|
+
REPO_ROOT,
|
|
37
|
+
".github",
|
|
38
|
+
"workflows",
|
|
39
|
+
"_electron-build.yml",
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
/** Non-comment lines only (drops YAML full-line `#` comments). */
|
|
43
|
+
function codeLines(yaml: string): string[] {
|
|
44
|
+
return yaml.split("\n").filter((l) => !/^\s*#/.test(l));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe("nightly.yml — zero-public-write safety contract", () => {
|
|
48
|
+
const yaml = fs.readFileSync(NIGHTLY, "utf8");
|
|
49
|
+
const lines = codeLines(yaml);
|
|
50
|
+
|
|
51
|
+
it("every `npm publish` is --dry-run or targets a loopback registry", () => {
|
|
52
|
+
const offenders = lines.filter(
|
|
53
|
+
(l) =>
|
|
54
|
+
/npm\s+publish/.test(l) &&
|
|
55
|
+
!/--dry-run/.test(l) &&
|
|
56
|
+
!/--registry\s+http:\/\/localhost/.test(l),
|
|
57
|
+
);
|
|
58
|
+
expect(
|
|
59
|
+
offenders,
|
|
60
|
+
"nightly.yml has an `npm publish` that could reach public npm — it must " +
|
|
61
|
+
"be `--dry-run` or carry `--registry http://localhost`. Offending line(s):\n" +
|
|
62
|
+
offenders.join("\n"),
|
|
63
|
+
).toEqual([]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("contains no GitHub Release action", () => {
|
|
67
|
+
const offenders = lines.filter((l) => /softprops\/action-gh-release/.test(l));
|
|
68
|
+
expect(offenders, "nightly.yml must not create a GitHub Release").toEqual([]);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("contains no tag `git push`", () => {
|
|
72
|
+
const offenders = lines.filter(
|
|
73
|
+
(l) => /git\s+push/.test(l) && !/--dry-run/.test(l),
|
|
74
|
+
);
|
|
75
|
+
expect(
|
|
76
|
+
offenders,
|
|
77
|
+
"nightly.yml must not push a tag/branch. Offending line(s):\n" +
|
|
78
|
+
offenders.join("\n"),
|
|
79
|
+
).toEqual([]);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("contains no version-bump `git commit`", () => {
|
|
83
|
+
const offenders = lines.filter((l) => /git\s+commit/.test(l));
|
|
84
|
+
expect(
|
|
85
|
+
offenders,
|
|
86
|
+
"nightly.yml must not commit a version bump. Offending line(s):\n" +
|
|
87
|
+
offenders.join("\n"),
|
|
88
|
+
).toEqual([]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("the electron job drives Verdaccio via a loopback registry_url", () => {
|
|
92
|
+
// Positive assertion: the round-trip mechanism is present and loopback.
|
|
93
|
+
const m = yaml.match(/^\s+registry_url:\s*(\S+)\s*$/m);
|
|
94
|
+
expect(m, "electron job must pass registry_url to _electron-build.yml").toBeTruthy();
|
|
95
|
+
expect(m?.[1]).toMatch(/^http:\/\/localhost(:\d+)?$/);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe("_electron-build.yml — pure-artifact-producer invariant (untouched by registry_url)", () => {
|
|
100
|
+
const yaml = fs.readFileSync(ELECTRON_BUILD, "utf8");
|
|
101
|
+
const lines = codeLines(yaml);
|
|
102
|
+
|
|
103
|
+
it("contains no `npm publish` (the reusable build never publishes)", () => {
|
|
104
|
+
const offenders = lines.filter((l) => /npm\s+publish/.test(l));
|
|
105
|
+
expect(
|
|
106
|
+
offenders,
|
|
107
|
+
"_electron-build.yml must not publish to any registry. The nightly " +
|
|
108
|
+
"publishes via scripts/nightly-verdaccio-publish.mjs, not the reusable " +
|
|
109
|
+
"workflow. Offending line(s):\n" + offenders.join("\n"),
|
|
110
|
+
).toEqual([]);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("contains no GitHub Release action", () => {
|
|
114
|
+
const offenders = lines.filter(
|
|
115
|
+
(l) =>
|
|
116
|
+
/softprops\/action-gh-release/.test(l) || /actions\/create-release/.test(l),
|
|
117
|
+
);
|
|
118
|
+
expect(offenders, "_electron-build.yml must not create a Release").toEqual([]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("contains no tag `git push`", () => {
|
|
122
|
+
const offenders = lines.filter((l) => /git\s+push\s+origin\s+v/.test(l));
|
|
123
|
+
expect(offenders, "_electron-build.yml must not push a tag").toEqual([]);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T-S3 (test-plan #S3): poller + init compat with openspec 1.6.0.
|
|
3
|
+
*
|
|
4
|
+
* Risk gate for `provision-openspec-cli-in-sessions`: raising the installed
|
|
5
|
+
* `@fission-ai/openspec` 1.4.1 → 1.6.0 moves the server poller too. The poller
|
|
6
|
+
* fails SILENT-EMPTY (`{ initialized: true, changes: [] }`) on a `status|list
|
|
7
|
+
* --json` schema break — no error. This test feeds a payload CAPTURED from the
|
|
8
|
+
* real 1.6.0 CLI (`openspec list --json` + `openspec status --change --json`,
|
|
9
|
+
* bin `node_modules/@fission-ai/openspec@1.6.0/bin/openspec.js`) into
|
|
10
|
+
* `buildOpenSpecData` and asserts it stays NON-empty with 1.4.1 parity shape:
|
|
11
|
+
* changes map, artifacts `{ id, status }`, `isComplete`.
|
|
12
|
+
*
|
|
13
|
+
* See change: provision-openspec-cli-in-sessions.
|
|
14
|
+
*/
|
|
15
|
+
import { describe, expect, it } from "vitest";
|
|
16
|
+
import { buildOpenSpecData } from "../openspec-poller.js";
|
|
17
|
+
|
|
18
|
+
// Captured verbatim from @fission-ai/openspec@1.6.0. list --json carries the
|
|
19
|
+
// extra `lastModified` + `root` keys (1.6.0) the poller ignores; the fields the
|
|
20
|
+
// poller consumes (name, status, completedTasks, totalTasks) are unchanged from
|
|
21
|
+
// 1.4.1. status --json carries extra keys (planningHome, artifactPaths, …) the
|
|
22
|
+
// poller ignores; `artifacts[]` is `{ id, outputPath, status }`.
|
|
23
|
+
const LIST_1_6_0 = {
|
|
24
|
+
root: "/repo/openspec",
|
|
25
|
+
changes: [
|
|
26
|
+
{
|
|
27
|
+
name: "provision-openspec-cli-in-sessions",
|
|
28
|
+
completedTasks: 0,
|
|
29
|
+
totalTasks: 25,
|
|
30
|
+
lastModified: "2026-07-20T22:12:54.766Z",
|
|
31
|
+
status: "in-progress",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "windows-authenticode-signing",
|
|
35
|
+
completedTasks: 21,
|
|
36
|
+
totalTasks: 21,
|
|
37
|
+
lastModified: "2026-07-20T22:12:54.766Z",
|
|
38
|
+
status: "complete",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const STATUS_1_6_0: Record<
|
|
44
|
+
string,
|
|
45
|
+
{ artifacts: Array<{ id: string; outputPath: string; status: string }>; isComplete: boolean }
|
|
46
|
+
> = {
|
|
47
|
+
"provision-openspec-cli-in-sessions": {
|
|
48
|
+
artifacts: [
|
|
49
|
+
{ id: "proposal", outputPath: "proposal.md", status: "done" },
|
|
50
|
+
{ id: "design", outputPath: "design.md", status: "done" },
|
|
51
|
+
{ id: "specs", outputPath: "specs/**/*.md", status: "done" },
|
|
52
|
+
{ id: "tasks", outputPath: "tasks.md", status: "done" },
|
|
53
|
+
],
|
|
54
|
+
isComplete: false,
|
|
55
|
+
},
|
|
56
|
+
"windows-authenticode-signing": {
|
|
57
|
+
artifacts: [
|
|
58
|
+
{ id: "proposal", outputPath: "proposal.md", status: "done" },
|
|
59
|
+
{ id: "design", outputPath: "design.md", status: "done" },
|
|
60
|
+
{ id: "specs", outputPath: "specs/**/*.md", status: "done" },
|
|
61
|
+
{ id: "tasks", outputPath: "tasks.md", status: "done" },
|
|
62
|
+
],
|
|
63
|
+
isComplete: true,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
describe("openspec-poller compat with 1.6.0 payload (T-S3)", () => {
|
|
68
|
+
it("parses a captured 1.6.0 list+status payload NON-empty (no silent-empty regression)", () => {
|
|
69
|
+
const statusResults = new Map(
|
|
70
|
+
LIST_1_6_0.changes.map((c) => [c.name, STATUS_1_6_0[c.name]] as const),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const data = buildOpenSpecData(LIST_1_6_0, statusResults);
|
|
74
|
+
|
|
75
|
+
// Non-empty parity: initialized + one change per list entry (the
|
|
76
|
+
// silent-empty failure mode would yield changes.length === 0).
|
|
77
|
+
expect(data.initialized).toBe(true);
|
|
78
|
+
expect(data.changes).toHaveLength(LIST_1_6_0.changes.length);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("maps 1.6.0 artifacts to the 1.4.1 OpenSpecData shape", () => {
|
|
82
|
+
const statusResults = new Map(
|
|
83
|
+
LIST_1_6_0.changes.map((c) => [c.name, STATUS_1_6_0[c.name]] as const),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const data = buildOpenSpecData(LIST_1_6_0, statusResults);
|
|
87
|
+
const change = data.changes.find((c) => c.name === "provision-openspec-cli-in-sessions");
|
|
88
|
+
|
|
89
|
+
expect(change).toBeDefined();
|
|
90
|
+
expect(change?.status).toBe("in-progress");
|
|
91
|
+
expect(change?.completedTasks).toBe(0);
|
|
92
|
+
expect(change?.totalTasks).toBe(25);
|
|
93
|
+
// artifacts flattened to { id, status } — the extra 1.6.0 outputPath dropped.
|
|
94
|
+
expect(change?.artifacts).toEqual([
|
|
95
|
+
{ id: "proposal", status: "done" },
|
|
96
|
+
{ id: "design", status: "done" },
|
|
97
|
+
{ id: "specs", status: "done" },
|
|
98
|
+
{ id: "tasks", status: "done" },
|
|
99
|
+
]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("preserves isComplete from the 1.6.0 status payload", () => {
|
|
103
|
+
const statusResults = new Map(
|
|
104
|
+
LIST_1_6_0.changes.map((c) => [c.name, STATUS_1_6_0[c.name]] as const),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const data = buildOpenSpecData(LIST_1_6_0, statusResults);
|
|
108
|
+
const complete = data.changes.find((c) => c.name === "windows-authenticode-signing");
|
|
109
|
+
|
|
110
|
+
expect(complete?.isComplete).toBe(true);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pnpm-migration-contract.test.ts — static contracts for change
|
|
3
|
+
* adopt-pnpm-for-dev-ci. Folds the statically-verifiable automated scenarios
|
|
4
|
+
* from test-plan.md (X3, X5, X6, X7, E8) into repo-lint assertions.
|
|
5
|
+
*
|
|
6
|
+
* NOT covered here (require CI / VM / docker harness): E1/E2/E3/X1 (L2 qa
|
|
7
|
+
* smoke), E5/E6/E7 (electron — verified locally via bundle-server +
|
|
8
|
+
* electron-forge package), X2/X8 (real publish/smoke runs). X4 (full
|
|
9
|
+
* ci-electron.yml installer matrix) passed on a dispatched run.
|
|
10
|
+
*/
|
|
11
|
+
import { describe, it, expect } from "vitest";
|
|
12
|
+
import fs from "node:fs";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
import url from "node:url";
|
|
15
|
+
|
|
16
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
17
|
+
const REPO_ROOT = path.resolve(__dirname, "..", "..", "..", "..");
|
|
18
|
+
const WF = path.join(REPO_ROOT, ".github", "workflows");
|
|
19
|
+
const read = (p: string) => fs.readFileSync(path.join(REPO_ROOT, p), "utf8");
|
|
20
|
+
const readWf = (name: string) => fs.readFileSync(path.join(WF, name), "utf8");
|
|
21
|
+
|
|
22
|
+
// ── root-script phantom-dep guard (pnpm hoisted ≠ npm accidental hoist) ─────
|
|
23
|
+
describe("root scripts/ workspace imports are declared in root package.json", () => {
|
|
24
|
+
// Under npm, an undeclared `@blackbelt-technology/*` import in a root script
|
|
25
|
+
// resolved via accidental hoist to root node_modules. pnpm's hoisted linker
|
|
26
|
+
// only links a workspace package into importers that DECLARE it, so a root
|
|
27
|
+
// script importing an undeclared workspace pkg fails ERR_MODULE_NOT_FOUND
|
|
28
|
+
// (regressed the Windows introspection smoke). See change: adopt-pnpm-for-dev-ci.
|
|
29
|
+
const scriptsDir = path.join(REPO_ROOT, "scripts");
|
|
30
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(REPO_ROOT, "package.json"), "utf8"));
|
|
31
|
+
const declared = new Set([
|
|
32
|
+
...Object.keys(pkg.dependencies || {}),
|
|
33
|
+
...Object.keys(pkg.devDependencies || {}),
|
|
34
|
+
// The root metapackage's own name is always resolvable (it IS the repo) —
|
|
35
|
+
// a script naming it (e.g. `nightly-verdaccio-publish.mjs`'s ROOT_META
|
|
36
|
+
// publish-ordering sentinel) is never a pnpm phantom-dep hazard.
|
|
37
|
+
pkg.name,
|
|
38
|
+
]);
|
|
39
|
+
const importRe = /['"](@blackbelt-technology\/[a-z0-9-]+)(?:\/[^'"]*)?['"]/g;
|
|
40
|
+
const files = fs
|
|
41
|
+
.readdirSync(scriptsDir)
|
|
42
|
+
.filter((f) => /\.(ts|mjs|js|cjs)$/.test(f));
|
|
43
|
+
for (const f of files) {
|
|
44
|
+
it(`scripts/${f} imports only declared workspace packages`, () => {
|
|
45
|
+
const src = fs.readFileSync(path.join(scriptsDir, f), "utf8");
|
|
46
|
+
const missing = new Set<string>();
|
|
47
|
+
for (const m of src.matchAll(importRe)) {
|
|
48
|
+
if (!declared.has(m[1])) missing.add(m[1]);
|
|
49
|
+
}
|
|
50
|
+
if (missing.size) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`scripts/${f} imports undeclared workspace package(s): ${[...missing].join(", ")}. ` +
|
|
53
|
+
"Add them to root package.json devDependencies — pnpm's hoisted linker " +
|
|
54
|
+
"only links declared deps to root node_modules (npm hoisted them by accident). " +
|
|
55
|
+
"See change: adopt-pnpm-for-dev-ci.",
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ── E4: single lockfile hygiene (post-§9 swap) ────────────────────────────
|
|
63
|
+
describe("E4 — pnpm-lock.yaml is the single committed lockfile", () => {
|
|
64
|
+
it("pnpm-lock.yaml is present at the repo root", () => {
|
|
65
|
+
expect(fs.existsSync(path.join(REPO_ROOT, "pnpm-lock.yaml"))).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
it("package-lock.json is absent at the repo root", () => {
|
|
68
|
+
expect(fs.existsSync(path.join(REPO_ROOT, "package-lock.json"))).toBe(false);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// ── X3: runtime installs stay npm (Column C guard) ────────────────────────
|
|
73
|
+
// The shipped server / electron app installs pi-core on END-USER machines via
|
|
74
|
+
// `npm install` (npm ships in Node). These MUST NOT be rewritten to pnpm.
|
|
75
|
+
// `"pnpm".includes("npm")` is true, so npm-presence uses a word boundary.
|
|
76
|
+
describe("X3 — runtime pi-core installs stay npm (never pnpm)", () => {
|
|
77
|
+
const columnC = [
|
|
78
|
+
"packages/server/src/pi/pi-core-updater.ts",
|
|
79
|
+
"packages/server/src/pi/pi-core-checker.ts",
|
|
80
|
+
"packages/server/src/lifecycle/recovery-server.ts",
|
|
81
|
+
"packages/electron/src/lib/update-checker.ts",
|
|
82
|
+
];
|
|
83
|
+
for (const file of columnC) {
|
|
84
|
+
it(`${file} invokes npm and is not rewritten to pnpm`, () => {
|
|
85
|
+
const src = read(file);
|
|
86
|
+
expect(/\bnpm\b/.test(src), `${file} must reference npm (Column C runtime)`).toBe(true);
|
|
87
|
+
if (/\bpnpm\b/.test(src)) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`${file} references pnpm — Column C runtime installs MUST stay npm ` +
|
|
90
|
+
"(they run on end-user machines against the public registry, where " +
|
|
91
|
+
"pnpm is not present). See change: adopt-pnpm-for-dev-ci (§1.2 / X3).",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// ── X5: CI cache flip — dev/CI workflows use pnpm, not `npm ci` ────────────
|
|
99
|
+
describe("X5 — root/workspace workflows install with pnpm", () => {
|
|
100
|
+
const migrated = [
|
|
101
|
+
"ci.yml",
|
|
102
|
+
"publish.yml",
|
|
103
|
+
"_electron-build.yml",
|
|
104
|
+
"_smoke.yml",
|
|
105
|
+
"ci-e2e-electron.yml",
|
|
106
|
+
];
|
|
107
|
+
for (const wf of migrated) {
|
|
108
|
+
it(`${wf} uses pnpm/action-setup + cache: pnpm and no \`npm ci\``, () => {
|
|
109
|
+
const y = readWf(wf);
|
|
110
|
+
expect(y, `${wf} missing pnpm/action-setup`).toContain("pnpm/action-setup");
|
|
111
|
+
expect(y, `${wf} missing \`cache: pnpm\``).toMatch(/cache:\s*pnpm/);
|
|
112
|
+
expect(y, `${wf} still installs with pnpm`).toMatch(/pnpm install/);
|
|
113
|
+
if (/\bnpm ci\b/.test(y)) {
|
|
114
|
+
throw new Error(
|
|
115
|
+
`${wf} still runs \`npm ci\` — every root/workspace install must be ` +
|
|
116
|
+
"`pnpm install --frozen-lockfile`. See change: adopt-pnpm-for-dev-ci (§6.2).",
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
it("publish.yml drops the npm@11.12.1 EALLOWGIT pin (§8.3)", () => {
|
|
123
|
+
expect(readWf("publish.yml")).not.toContain("npm@11.12.1");
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// ── X6: deploy-site is dual-install — site/ stays npm, root uses pnpm ──────
|
|
128
|
+
describe("X6 — deploy-site.yml dual-install regression", () => {
|
|
129
|
+
const y = readWf("deploy-site.yml");
|
|
130
|
+
it("site/ job keeps its own npm lockfile + npm ci (unmigrated)", () => {
|
|
131
|
+
expect(y).toContain("cache-dependency-path: site/package-lock.json");
|
|
132
|
+
expect(y, "site/ install must stay `npm ci`").toMatch(/\bnpm ci\b/);
|
|
133
|
+
});
|
|
134
|
+
it("root shell install uses pnpm", () => {
|
|
135
|
+
expect(y).toContain("pnpm/action-setup");
|
|
136
|
+
expect(y).toMatch(/pnpm install --frozen-lockfile/);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// ── X7: the npm/cli#4828 `rm -f package-lock.json` hack is gone ────────────
|
|
141
|
+
describe("X7 — #4828 lockfile-nuke workaround removed from all workflows", () => {
|
|
142
|
+
const files = fs.readdirSync(WF).filter((f) => f.endsWith(".yml"));
|
|
143
|
+
for (const f of files) {
|
|
144
|
+
it(`${f} has no package-lock.json clean-install hack`, () => {
|
|
145
|
+
const y = readWf(f);
|
|
146
|
+
const patterns = [
|
|
147
|
+
/rm -rf node_modules package-lock\.json/,
|
|
148
|
+
/rm -f package-lock\.json/,
|
|
149
|
+
/Remove-Item[^\n]*package-lock\.json/,
|
|
150
|
+
];
|
|
151
|
+
for (const re of patterns) {
|
|
152
|
+
if (re.test(y)) {
|
|
153
|
+
throw new Error(
|
|
154
|
+
`${f} still contains the npm/cli#4828 lockfile-nuke hack (${re}). ` +
|
|
155
|
+
"pnpm re-resolves the platform optional-dep tree from " +
|
|
156
|
+
"pnpm-lock.yaml, so the workaround must be removed. See change: " +
|
|
157
|
+
"adopt-pnpm-for-dev-ci (§6.5 / X7).",
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// ── E8: bundle-server cpSync filter is Windows-safe (split, not path.sep) ──
|
|
166
|
+
describe("E8 — bundle-server.mjs node_modules filter is Windows-safe", () => {
|
|
167
|
+
const src = read("packages/electron/scripts/bundle-server.mjs");
|
|
168
|
+
it("excludes node_modules via a `/[\\\\/]/` split (both separators)", () => {
|
|
169
|
+
expect(src).toMatch(/split\(\/\[\\\\\/\]\/\)/);
|
|
170
|
+
expect(src).toContain('includes("node_modules")');
|
|
171
|
+
});
|
|
172
|
+
it("does not gate the filter on path.sep (breaks the win32 node-pty leg)", () => {
|
|
173
|
+
// A path.sep-based split misses `/` on win32 (or `\` on POSIX), copying
|
|
174
|
+
// broken pnpm store-symlinks into the bundle → empty node-pty prebuilds.
|
|
175
|
+
expect(src).not.toMatch(/split\(path\.sep\)/);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
@@ -351,7 +351,9 @@ describe("publish.yml — tag-and-push job lockfile-regen contract", () => {
|
|
|
351
351
|
it("tag-and-push job regenerates lockfile after version bump (fix-release-lockfile-drift)", () => {
|
|
352
352
|
const syncIdx = tagAndPushSteps.findIndex((s) => /sync-versions\.js/.test(s.run || ""));
|
|
353
353
|
const regenIdx = tagAndPushSteps.findIndex((s) =>
|
|
354
|
-
|
|
354
|
+
// change adopt-pnpm-for-dev-ci (§6.3): npm install --package-lock-only
|
|
355
|
+
// → pnpm install --lockfile-only (pnpm-lock.yaml is the single lockfile).
|
|
356
|
+
/pnpm install --lockfile-only/.test(s.run || ""),
|
|
355
357
|
);
|
|
356
358
|
const commitIdx = tagAndPushSteps.findIndex((s) =>
|
|
357
359
|
/git commit -m "chore\(release\)/.test(s.run || ""),
|
|
@@ -508,11 +510,12 @@ describe("publish.yml — release-gate contract (gate-publish-on-smoke-and-tests
|
|
|
508
510
|
"See change: gate-publish-on-smoke-and-tests (clause 2).",
|
|
509
511
|
);
|
|
510
512
|
}
|
|
511
|
-
for (
|
|
513
|
+
// change adopt-pnpm-for-dev-ci (§6.4): npm run … → pnpm run … .
|
|
514
|
+
for (const cmd of ["pnpm run lint", "pnpm test", "pnpm run build"]) {
|
|
512
515
|
if (!ciChecksBlock.includes(cmd)) {
|
|
513
516
|
throw new Error(
|
|
514
517
|
"ci-checks job MUST run `" + cmd + "`. See change:\n" +
|
|
515
|
-
"gate-publish-on-smoke-and-tests (clause 2). Job block:\n" +
|
|
518
|
+
"gate-publish-on-smoke-and-tests (clause 2); adopt-pnpm-for-dev-ci (§6.4). Job block:\n" +
|
|
516
519
|
ciChecksBlock,
|
|
517
520
|
);
|
|
518
521
|
}
|
|
@@ -78,6 +78,18 @@ export interface SetSessionTagsBrowserMessage {
|
|
|
78
78
|
tags: string[];
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Browser → server: strip a single user tag from every session that carries
|
|
83
|
+
* it. The server normalizes the inbound tag first; a blank/whitespace-only
|
|
84
|
+
* tag (normalizes to empty) is a no-op. Fan-out reuses the per-session
|
|
85
|
+
* normalize → update → broadcast path (one `session_updated` per changed
|
|
86
|
+
* session). Bridges never send this. See change: sidebar-tag-collapse-and-delete.
|
|
87
|
+
*/
|
|
88
|
+
export interface RemoveTagGloballyBrowserMessage {
|
|
89
|
+
type: "remove_tag_globally";
|
|
90
|
+
tag: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
81
93
|
// ── Server → Browser ────────────────────────────────────────────────
|
|
82
94
|
|
|
83
95
|
export interface SessionAddedMessage {
|
|
@@ -767,6 +779,15 @@ export interface RecoveryCandidate {
|
|
|
767
779
|
export interface RecoveryOfferMessage {
|
|
768
780
|
type: "recovery_offer";
|
|
769
781
|
candidates: RecoveryCandidate[];
|
|
782
|
+
/**
|
|
783
|
+
* Epoch-ms deadline until which each candidate's process liveness is still
|
|
784
|
+
* being resolved (the Class-2 bridge-reattach grace window). While
|
|
785
|
+
* `Date.now() < graceUntil` the offer is shown but Reopen is NOT actionable —
|
|
786
|
+
* a still-alive bridge may reattach and retract the candidate, and reopening
|
|
787
|
+
* it early would double-spawn pi for one sessionId. Absent/past ⇒ liveness is
|
|
788
|
+
* finalized and Reopen is active. See change: fix-recovery-offer-bridge-liveness-gate.
|
|
789
|
+
*/
|
|
790
|
+
graceUntil?: number;
|
|
770
791
|
}
|
|
771
792
|
|
|
772
793
|
/**
|
|
@@ -1601,6 +1622,7 @@ export type BrowserToServerMessage =
|
|
|
1601
1622
|
| SetSessionDisplayPrefsBrowserMessage
|
|
1602
1623
|
| SetSessionProcessDrawerBrowserMessage
|
|
1603
1624
|
| SetSessionTagsBrowserMessage
|
|
1625
|
+
| RemoveTagGloballyBrowserMessage
|
|
1604
1626
|
| RecoveryDismissMessage
|
|
1605
1627
|
| SubagentResyncRequestBrowserMessage
|
|
1606
1628
|
| WatchFilesBrowserMessage;
|