@blackbelt-technology/pi-dashboard-extension 0.7.0 → 0.8.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/.pi/skills/browser/SKILL.md +28 -14
- package/.pi/skills/browser/UPSTREAM.md +10 -1
- package/.pi/skills/browser/references/electron.agent.md +57 -0
- package/.pi/skills/browser/references/own-browser.md +299 -0
- package/.pi/skills/browser/references/web.agent.md +323 -0
- package/.pi/skills/browser/scripts/check-panerelay.sh +157 -0
- package/.pi/skills/doctor/SKILL.md +3 -9
- package/.pi/skills/doctor/_lib/checks.ts +14 -68
- package/.pi/skills/doctor/_lib/derive-tokens.ts +1 -0
- package/.pi/skills/doctor/modules/apple-tools.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/apple-tools.md +51 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.md +71 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
- package/.pi/skills/doctor/modules/pi-resolution.md +21 -1
- package/.pi/skills/pi-dashboard/references/api-reference.agent.md +69 -0
- package/.pi/skills/project-init/SKILL.md +1 -7
- package/.pi/skills/project-init/dox-doctrine.md +42 -0
- package/.pi/skills/project-init/profiles/docs/profile.json +1 -1
- package/README.md +19 -0
- package/agents/DoxTriage.md +80 -0
- package/package.json +22 -11
- package/src/agent-settled.ts +27 -9
- package/src/auto-session-namer.ts +486 -70
- package/src/autostart-guard.ts +99 -0
- package/src/autostart-lock.ts +258 -0
- package/src/bridge-context.ts +86 -5
- package/src/bridge-ticket-client.ts +105 -0
- package/src/bridge.ts +917 -213
- package/src/command-handler.ts +332 -57
- package/src/connect-target.ts +130 -0
- package/src/connection.ts +371 -7
- package/src/endpoint-resolution.ts +221 -0
- package/src/flow-event-wiring.ts +125 -3
- package/src/followup-buffer.ts +217 -0
- package/src/instance-verification.ts +125 -0
- package/src/local-token-header.ts +44 -0
- package/src/model-refresh.ts +95 -0
- package/src/notify-proxy.ts +33 -0
- package/src/pi-env.d.ts +4 -0
- package/src/pi-retry-settings.ts +91 -0
- package/src/provider-register.ts +86 -21
- package/src/remote-registration-gate.ts +102 -0
- package/src/retry-tracker.ts +265 -86
- package/src/role-manager.ts +20 -0
- package/src/role-model-tools.ts +38 -3
- package/src/server-auto-start.ts +144 -2
- package/src/server-pin-store.ts +92 -0
- package/src/session-move.ts +275 -0
- package/src/session-sync.ts +24 -5
- package/src/subagent-forward-sites.ts +69 -0
- package/src/subagent-frame-buffer.ts +24 -3
- package/src/subagent-frame-strip.ts +109 -0
- package/src/subagent-tick-throttle.ts +250 -0
- package/src/transcript-backfill.ts +151 -0
- package/src/transcript-request-guard.ts +76 -0
- package/src/transport-diagnostics.ts +76 -0
- package/src/turn-actionability.ts +20 -0
- package/src/ui-stale-guard.ts +58 -0
- package/.pi/skills/doctor/AGENTS.md +0 -27
- package/src/AGENTS.md +0 -57
- package/src/__tests__/abort-latch.test.ts +0 -97
- package/src/__tests__/agent-settled.test.ts +0 -82
- package/src/__tests__/artifact-roots.test.ts +0 -83
- package/src/__tests__/ask-user-attachments.test.ts +0 -106
- package/src/__tests__/ask-user-schema-discriminator.test.ts +0 -141
- package/src/__tests__/ask-user-tool.test.ts +0 -571
- package/src/__tests__/auto-session-namer.test.ts +0 -339
- package/src/__tests__/bridge-default-model-apply.test.ts +0 -242
- package/src/__tests__/bridge-default-model-gate.test.ts +0 -50
- package/src/__tests__/bridge-entry-id-pi-070.test.ts +0 -174
- package/src/__tests__/bridge-followup-chat-order.test.ts +0 -215
- package/src/__tests__/bridge-followup-multi-entry.test.ts +0 -202
- package/src/__tests__/bridge-followup-mutation.test.ts +0 -217
- package/src/__tests__/bridge-followup-queue-drain.test.ts +0 -266
- package/src/__tests__/bridge-hasui-flip.test.ts +0 -109
- package/src/__tests__/bridge-no-queue-mutation.test.ts +0 -112
- package/src/__tests__/bridge-plugin-emit-event.test.ts +0 -44
- package/src/__tests__/bridge-queue-update-forward.test.ts +0 -77
- package/src/__tests__/bridge-resume-disconnect.test.ts +0 -333
- package/src/__tests__/bridge-shadow-queue-gate.test.ts +0 -299
- package/src/__tests__/bridge-shutdown-reset.test.ts +0 -159
- package/src/__tests__/bridge-slash-command-routing.test.ts +0 -458
- package/src/__tests__/bridge-stop-after-turn.test.ts +0 -72
- package/src/__tests__/bridge-system-followup.test.ts +0 -163
- package/src/__tests__/bridge-thinking-level-select.test.ts +0 -68
- package/src/__tests__/browser-skill-registered.test.ts +0 -84
- package/src/__tests__/build-provider-catalogue.test.ts +0 -210
- package/src/__tests__/command-handler.test.ts +0 -1180
- package/src/__tests__/commit-draft.test.ts +0 -100
- package/src/__tests__/connection-dropped-frames.test.ts +0 -78
- package/src/__tests__/connection-suppress-auto-start.test.ts +0 -97
- package/src/__tests__/connection.test.ts +0 -344
- package/src/__tests__/credentials-updated.test.ts +0 -26
- package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +0 -128
- package/src/__tests__/cwd-missing-probe.test.ts +0 -82
- package/src/__tests__/dashboard-commands-shipped.test.ts +0 -53
- package/src/__tests__/dashboard-context-injector.test.ts +0 -190
- package/src/__tests__/dashboard-default-adapter.test.ts +0 -77
- package/src/__tests__/dev-build.test.ts +0 -79
- package/src/__tests__/doctor/checks.test.ts +0 -121
- package/src/__tests__/doctor/modules.test.ts +0 -64
- package/src/__tests__/doctor/provenance-hash.test.ts +0 -94
- package/src/__tests__/doctor/router.test.ts +0 -143
- package/src/__tests__/empty-actionable-guard-config.test.ts +0 -32
- package/src/__tests__/empty-actionable-guard.test.ts +0 -73
- package/src/__tests__/enrich-model-metadata.test.ts +0 -222
- package/src/__tests__/event-forwarder.test.ts +0 -119
- package/src/__tests__/extension-slash-command-detection.test.ts +0 -143
- package/src/__tests__/filter-enabled-models.test.ts +0 -151
- package/src/__tests__/fixtures/turn-actionability-fixtures.ts +0 -69
- package/src/__tests__/fork-entryid-timing.test.ts +0 -88
- package/src/__tests__/git-info-status.test.ts +0 -73
- package/src/__tests__/git-link-builder.test.ts +0 -102
- package/src/__tests__/git-poll.test.ts +0 -69
- package/src/__tests__/markdown-image-inliner.test.ts +0 -392
- package/src/__tests__/model-resolve.test.ts +0 -379
- package/src/__tests__/multiselect-dashboard-routing.test.ts +0 -203
- package/src/__tests__/multiselect-list.test.ts +0 -137
- package/src/__tests__/multiselect-polyfill.test.ts +0 -92
- package/src/__tests__/no-session-replacement-calls.test.ts +0 -99
- package/src/__tests__/no-tui-multiselect-arm-regression.test.ts +0 -81
- package/src/__tests__/openspec-activity-detector.test.ts +0 -337
- package/src/__tests__/openspec-cli-shim.test.ts +0 -145
- package/src/__tests__/openspec-poller.test.ts +0 -124
- package/src/__tests__/pi-version-tracker.test.ts +0 -109
- package/src/__tests__/process-metrics.test.ts +0 -47
- package/src/__tests__/process-scanner-kill.test.ts +0 -61
- package/src/__tests__/process-scanner.test.ts +0 -292
- package/src/__tests__/project-init-detect-stack.test.ts +0 -61
- package/src/__tests__/project-init-dox-kb-config.test.ts +0 -53
- package/src/__tests__/project-init-profiles.test.ts +0 -84
- package/src/__tests__/project-init-scaffold.test.ts +0 -139
- package/src/__tests__/project-init-seed-doctrine.test.ts +0 -100
- package/src/__tests__/project-trust.test.ts +0 -92
- package/src/__tests__/prompt-bus-wiring.test.ts +0 -791
- package/src/__tests__/prompt-bus.test.ts +0 -513
- package/src/__tests__/prompt-expander.test.ts +0 -398
- package/src/__tests__/provider-register-native-models.test.ts +0 -182
- package/src/__tests__/provider-register-reload.test.ts +0 -498
- package/src/__tests__/provider-register-thinking-levels.test.ts +0 -104
- package/src/__tests__/retry-tracker.test.ts +0 -152
- package/src/__tests__/role-manager.test.ts +0 -585
- package/src/__tests__/role-model-tools-registry-readiness.test.ts +0 -114
- package/src/__tests__/role-model-tools.test.ts +0 -229
- package/src/__tests__/search-files-completeness.test.ts +0 -111
- package/src/__tests__/search-files-ranking.test.ts +0 -168
- package/src/__tests__/server-auto-start.test.ts +0 -375
- package/src/__tests__/server-launcher-launch.test.ts +0 -96
- package/src/__tests__/server-launcher.test.ts +0 -101
- package/src/__tests__/server-probe.test.ts +0 -25
- package/src/__tests__/session-switch.test.ts +0 -139
- package/src/__tests__/session-sync.test.ts +0 -243
- package/src/__tests__/single-derivation-guard.test.ts +0 -39
- package/src/__tests__/source-detector.test.ts +0 -88
- package/src/__tests__/stats-extractor.test.ts +0 -92
- package/src/__tests__/subagent-frame-buffer.test.ts +0 -239
- package/src/__tests__/tool-result-image-inliner.test.ts +0 -206
- package/src/__tests__/tui-prompt-adapter.test.ts +0 -213
- package/src/__tests__/turn-actionability.test.ts +0 -86
- package/src/__tests__/ui-decorators.test.ts +0 -309
- package/src/__tests__/ui-modules.test.ts +0 -293
- package/src/__tests__/vcs-info.test.ts +0 -265
- package/src/__tests__/visibility-intent.test.ts +0 -43
- package/src/__tests__/watchdog.test.ts +0 -161
- package/src/abort-latch.ts.AGENTS.md +0 -3
- package/src/agent-settled.ts.AGENTS.md +0 -3
- package/src/artifact-roots.ts.AGENTS.md +0 -3
- package/src/ask-user-attachments.ts.AGENTS.md +0 -3
- package/src/ask-user-tool.ts.AGENTS.md +0 -3
- package/src/auto-session-namer.ts.AGENTS.md +0 -3
- package/src/bridge-context.ts.AGENTS.md +0 -3
- package/src/bridge-default-model-gate.ts.AGENTS.md +0 -3
- package/src/bridge.ts.AGENTS.md +0 -3
- package/src/command-handler.ts.AGENTS.md +0 -3
- package/src/commit-draft-agent.ts.AGENTS.md +0 -3
- package/src/commit-draft.ts.AGENTS.md +0 -3
- package/src/connection.ts.AGENTS.md +0 -3
- package/src/dashboard-context-injector.ts.AGENTS.md +0 -3
- package/src/dashboard-default-adapter.ts.AGENTS.md +0 -3
- package/src/dev-build.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard-config.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard.ts.AGENTS.md +0 -3
- package/src/event-forwarder.ts.AGENTS.md +0 -3
- package/src/flow-event-wiring.ts.AGENTS.md +0 -3
- package/src/git-link-builder.ts.AGENTS.md +0 -3
- package/src/git-poll.ts.AGENTS.md +0 -3
- package/src/hasui-flip.ts.AGENTS.md +0 -3
- package/src/markdown-image-inliner.ts.AGENTS.md +0 -3
- package/src/model-tracker.ts.AGENTS.md +0 -3
- package/src/multiselect-decode.ts.AGENTS.md +0 -3
- package/src/multiselect-list.ts.AGENTS.md +0 -3
- package/src/multiselect-polyfill.ts.AGENTS.md +0 -3
- package/src/openspec-cli-shim.ts.AGENTS.md +0 -7
- package/src/process-metrics.ts.AGENTS.md +0 -3
- package/src/process-scanner.ts.AGENTS.md +0 -3
- package/src/project-init/AGENTS.md +0 -12
- package/src/project-trust.ts.AGENTS.md +0 -3
- package/src/prompt-bus.ts.AGENTS.md +0 -3
- package/src/prompt-expander.ts.AGENTS.md +0 -3
- package/src/provider-register.ts.AGENTS.md +0 -3
- package/src/retry-tracker.ts.AGENTS.md +0 -3
- package/src/role-manager.ts.AGENTS.md +0 -3
- package/src/role-model-tools.ts.AGENTS.md +0 -3
- package/src/server-auto-start.ts.AGENTS.md +0 -3
- package/src/server-launcher.ts.AGENTS.md +0 -3
- package/src/session-sync.ts.AGENTS.md +0 -3
- package/src/slash-dispatch.ts.AGENTS.md +0 -3
- package/src/source-detector.ts.AGENTS.md +0 -3
- package/src/subagent-frame-buffer.ts.AGENTS.md +0 -3
- package/src/tool-result-image-inliner.ts.AGENTS.md +0 -3
- package/src/tui-prompt-adapter.ts.AGENTS.md +0 -3
- package/src/turn-actionability.ts.AGENTS.md +0 -3
- package/src/ui-modules.ts.AGENTS.md +0 -3
- package/src/vcs-info.ts.AGENTS.md +0 -3
- package/src/visibility-intent.ts.AGENTS.md +0 -3
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Profile resolver: shipped ∪ user, user-wins-by-name; dox flag default + explicit.
|
|
3
|
-
* See change: project-init-skill-and-profiles.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
6
|
-
import * as fs from "node:fs";
|
|
7
|
-
import * as os from "node:os";
|
|
8
|
-
import * as path from "node:path";
|
|
9
|
-
import { resolveProfiles, readProfile, shippedProfilesDir } from "../project-init/profiles.js";
|
|
10
|
-
|
|
11
|
-
function makeProfile(root: string, name: string, opts: { dox?: boolean; description?: string } = {}): string {
|
|
12
|
-
const dir = path.join(root, name);
|
|
13
|
-
fs.mkdirSync(path.join(dir, "prompts"), { recursive: true });
|
|
14
|
-
fs.writeFileSync(path.join(dir, "AGENTS.md.tmpl"), "# tmpl\n");
|
|
15
|
-
fs.writeFileSync(path.join(dir, "settings.json.tmpl"), "{}\n");
|
|
16
|
-
const manifest: Record<string, unknown> = {};
|
|
17
|
-
if (opts.dox !== undefined) manifest.dox = opts.dox;
|
|
18
|
-
if (opts.description) manifest.description = opts.description;
|
|
19
|
-
fs.writeFileSync(path.join(dir, "profile.json"), JSON.stringify(manifest));
|
|
20
|
-
return dir;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("project-init profile resolver", () => {
|
|
24
|
-
let tmp: string;
|
|
25
|
-
let shipped: string;
|
|
26
|
-
let user: string;
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
tmp = fs.mkdtempSync(path.join(os.tmpdir(), "pi-profiles-"));
|
|
30
|
-
shipped = path.join(tmp, "shipped");
|
|
31
|
-
user = path.join(tmp, "user");
|
|
32
|
-
fs.mkdirSync(shipped, { recursive: true });
|
|
33
|
-
fs.mkdirSync(user, { recursive: true });
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
afterEach(() => {
|
|
37
|
-
fs.rmSync(tmp, { recursive: true, force: true });
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("returns shipped profiles when no user profiles exist", () => {
|
|
41
|
-
makeProfile(shipped, "coding");
|
|
42
|
-
makeProfile(shipped, "docs");
|
|
43
|
-
const profiles = resolveProfiles({ shippedDir: shipped, userDir: user });
|
|
44
|
-
expect(profiles.map((p) => p.name)).toEqual(["coding", "docs"]);
|
|
45
|
-
expect(profiles.every((p) => p.source === "shipped")).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("user profile overrides shipped by name", () => {
|
|
49
|
-
makeProfile(shipped, "coding", { description: "shipped coding" });
|
|
50
|
-
makeProfile(user, "coding", { description: "user coding" });
|
|
51
|
-
const profiles = resolveProfiles({ shippedDir: shipped, userDir: user });
|
|
52
|
-
const coding = profiles.find((p) => p.name === "coding");
|
|
53
|
-
expect(coding?.source).toBe("user");
|
|
54
|
-
expect(coding?.description).toBe("user coding");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("user profiles add to the set", () => {
|
|
58
|
-
makeProfile(shipped, "coding");
|
|
59
|
-
makeProfile(user, "research");
|
|
60
|
-
const names = resolveProfiles({ shippedDir: shipped, userDir: user }).map((p) => p.name);
|
|
61
|
-
expect(names).toEqual(["coding", "research"]);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("dox defaults to false and honors an explicit true", () => {
|
|
65
|
-
makeProfile(shipped, "plain");
|
|
66
|
-
makeProfile(shipped, "doxed", { dox: true });
|
|
67
|
-
const profiles = resolveProfiles({ shippedDir: shipped, userDir: user });
|
|
68
|
-
expect(profiles.find((p) => p.name === "plain")?.dox).toBe(false);
|
|
69
|
-
expect(profiles.find((p) => p.name === "doxed")?.dox).toBe(true);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("rejects a directory missing required templates", () => {
|
|
73
|
-
const dir = path.join(shipped, "broken");
|
|
74
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
75
|
-
fs.writeFileSync(path.join(dir, "AGENTS.md.tmpl"), "# only one template\n");
|
|
76
|
-
expect(readProfile(dir, "shipped")).toBeNull();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("the shipped profiles ship coding and docs", () => {
|
|
80
|
-
const names = resolveProfiles({ shippedDir: shippedProfilesDir(), userDir: user }).map((p) => p.name);
|
|
81
|
-
expect(names).toContain("coding");
|
|
82
|
-
expect(names).toContain("docs");
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scaffold: writes AGENTS.md + settings + prompts; DOX seeds doctrine + kb config;
|
|
3
|
-
* hook validity; idempotency conflict reporting.
|
|
4
|
-
* See change: project-init-skill-and-profiles.
|
|
5
|
-
*/
|
|
6
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
7
|
-
import * as fs from "node:fs";
|
|
8
|
-
import * as os from "node:os";
|
|
9
|
-
import * as path from "node:path";
|
|
10
|
-
import type { Profile } from "../project-init/profiles.js";
|
|
11
|
-
import { planScaffold, scaffoldProfile, isValidWorktreeInit } from "../project-init/scaffold.js";
|
|
12
|
-
import { DOX_MARKER } from "../project-init/seed-doctrine.js";
|
|
13
|
-
import { STACKS, stackSubstitutions } from "../project-init/detect-stack.js";
|
|
14
|
-
|
|
15
|
-
/** A coding-style profile whose templates carry stack placeholders. */
|
|
16
|
-
function makeStackProfile(root: string, name: string): Profile {
|
|
17
|
-
const dir = path.join(root, name);
|
|
18
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
19
|
-
fs.writeFileSync(path.join(dir, "AGENTS.md.tmpl"), "# {{PROJECT_NAME}}\n\n{{INSTALL_CMD}} {{TEST_CMD}} {{BUILD_CMD}}\n");
|
|
20
|
-
fs.writeFileSync(
|
|
21
|
-
path.join(dir, "settings.json.tmpl"),
|
|
22
|
-
'{ "worktreeInit": { "gate": "{{INIT_GATE}}", "run": { "type": "script", "command": "{{INIT_COMMAND}}" } } }',
|
|
23
|
-
);
|
|
24
|
-
return { name, dox: false, stackAware: true, dir, source: "shipped" };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function makeProfileDir(root: string, name: string, opts: { dox?: boolean; hook?: unknown } = {}): Profile {
|
|
28
|
-
const dir = path.join(root, name);
|
|
29
|
-
fs.mkdirSync(path.join(dir, "prompts"), { recursive: true });
|
|
30
|
-
fs.writeFileSync(path.join(dir, "AGENTS.md.tmpl"), "# {{PROJECT_NAME}}\n\nbody\n");
|
|
31
|
-
const hook = opts.hook ?? { gate: "test ! -d node_modules", run: { type: "script", command: "npm ci" } };
|
|
32
|
-
fs.writeFileSync(path.join(dir, "settings.json.tmpl"), JSON.stringify({ worktreeInit: hook }, null, 2));
|
|
33
|
-
fs.writeFileSync(path.join(dir, "prompts", "a.md"), "prompt a\n");
|
|
34
|
-
return { name, dox: !!opts.dox, stackAware: false, dir, source: "shipped" };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
describe("project-init scaffold", () => {
|
|
38
|
-
let tmp: string;
|
|
39
|
-
let profilesRoot: string;
|
|
40
|
-
let target: string;
|
|
41
|
-
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
tmp = fs.mkdtempSync(path.join(os.tmpdir(), "pi-scaffold-"));
|
|
44
|
-
profilesRoot = path.join(tmp, "profiles");
|
|
45
|
-
target = path.join(tmp, "project");
|
|
46
|
-
fs.mkdirSync(profilesRoot, { recursive: true });
|
|
47
|
-
fs.mkdirSync(target, { recursive: true });
|
|
48
|
-
});
|
|
49
|
-
afterEach(() => fs.rmSync(tmp, { recursive: true, force: true }));
|
|
50
|
-
|
|
51
|
-
it("writes AGENTS.md, settings.json, and prompt files", () => {
|
|
52
|
-
const profile = makeProfileDir(profilesRoot, "coding");
|
|
53
|
-
const res = scaffoldProfile({ profile, targetDir: target, projectName: "Demo" });
|
|
54
|
-
expect(fs.readFileSync(path.join(target, "AGENTS.md"), "utf8")).toContain("# Demo");
|
|
55
|
-
const settings = JSON.parse(fs.readFileSync(path.join(target, ".pi", "settings.json"), "utf8"));
|
|
56
|
-
expect(settings.worktreeInit.run.command).toBe("npm ci");
|
|
57
|
-
expect(fs.existsSync(path.join(target, ".pi", "prompts", "a.md"))).toBe(true);
|
|
58
|
-
expect(res.hookValid).toBe(true);
|
|
59
|
-
expect(res.doctrineSeeded).toBe(false);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("DOX profile seeds the doctrine into AGENTS.md and writes the kb config", () => {
|
|
63
|
-
const profile = makeProfileDir(profilesRoot, "coding", { dox: true });
|
|
64
|
-
const res = scaffoldProfile({ profile, targetDir: target });
|
|
65
|
-
expect(res.doctrineSeeded).toBe(true);
|
|
66
|
-
expect(fs.readFileSync(path.join(target, "AGENTS.md"), "utf8")).toContain(DOX_MARKER);
|
|
67
|
-
expect(fs.existsSync(path.join(target, ".pi", "dashboard", "knowledge_base.json"))).toBe(true);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("planScaffold reports existing files as conflicts", () => {
|
|
71
|
-
const profile = makeProfileDir(profilesRoot, "coding");
|
|
72
|
-
fs.writeFileSync(path.join(target, "AGENTS.md"), "pre-existing\n");
|
|
73
|
-
const plan = planScaffold({ profile, targetDir: target });
|
|
74
|
-
expect(plan.conflicts).toContain(path.join(target, "AGENTS.md"));
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("refuses to overwrite unless overwrite:true", () => {
|
|
78
|
-
const profile = makeProfileDir(profilesRoot, "coding");
|
|
79
|
-
fs.writeFileSync(path.join(target, "AGENTS.md"), "pre-existing\n");
|
|
80
|
-
expect(() => scaffoldProfile({ profile, targetDir: target })).toThrow(/overwrite/);
|
|
81
|
-
expect(() => scaffoldProfile({ profile, targetDir: target, overwrite: true })).not.toThrow();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("substitutes a detected stack into placeholder templates (no leftovers)", () => {
|
|
85
|
-
const profile = makeStackProfile(profilesRoot, "coding");
|
|
86
|
-
const res = scaffoldProfile({
|
|
87
|
-
profile, targetDir: target, projectName: "Demo",
|
|
88
|
-
substitutions: stackSubstitutions(STACKS.cargo!),
|
|
89
|
-
});
|
|
90
|
-
expect(res.leftover).toEqual([]);
|
|
91
|
-
expect(fs.readFileSync(path.join(target, "AGENTS.md"), "utf8")).toContain("cargo test");
|
|
92
|
-
const settings = JSON.parse(fs.readFileSync(path.join(target, ".pi", "settings.json"), "utf8"));
|
|
93
|
-
expect(settings.worktreeInit.gate).toBe("test ! -d target");
|
|
94
|
-
expect(settings.worktreeInit.run.command).toBe("cargo fetch");
|
|
95
|
-
expect(res.hookValid).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("JSON-escapes substitutions so a quote/backslash cannot corrupt settings.json", () => {
|
|
99
|
-
const profile = makeStackProfile(profilesRoot, "coding");
|
|
100
|
-
const subs = { ...stackSubstitutions(STACKS.npm!), INIT_COMMAND: 'echo "hi" && npm ci' };
|
|
101
|
-
const res = scaffoldProfile({ profile, targetDir: target, substitutions: subs });
|
|
102
|
-
// Must still be valid JSON on disk, with the value preserved verbatim.
|
|
103
|
-
const settings = JSON.parse(fs.readFileSync(path.join(target, ".pi", "settings.json"), "utf8"));
|
|
104
|
-
expect(settings.worktreeInit.run.command).toBe('echo "hi" && npm ci');
|
|
105
|
-
expect(res.hookValid).toBe(true);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("overwrite:true rewrites a pre-existing knowledge_base.json (DOX)", () => {
|
|
109
|
-
const profile = makeProfileDir(profilesRoot, "coding", { dox: true });
|
|
110
|
-
const kbPath = path.join(target, ".pi", "dashboard", "knowledge_base.json");
|
|
111
|
-
fs.mkdirSync(path.dirname(kbPath), { recursive: true });
|
|
112
|
-
fs.writeFileSync(kbPath, '{"sources":[]}\n');
|
|
113
|
-
scaffoldProfile({ profile, targetDir: target, overwrite: true });
|
|
114
|
-
const kb = JSON.parse(fs.readFileSync(kbPath, "utf8"));
|
|
115
|
-
expect(kb.indexAgentsFiles).toBe(true);
|
|
116
|
-
expect(kb.directoryLevelAgents.enabled).toBe(true);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("reports leftover placeholders when no stack substitutions are supplied", () => {
|
|
120
|
-
const profile = makeStackProfile(profilesRoot, "coding");
|
|
121
|
-
const res = scaffoldProfile({ profile, targetDir: target });
|
|
122
|
-
expect(res.leftover).toContain("INSTALL_CMD");
|
|
123
|
-
expect(res.leftover).toContain("INIT_GATE");
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("flags an invalid worktreeInit hook (would fail-open)", () => {
|
|
127
|
-
const profile = makeProfileDir(profilesRoot, "bad", { hook: { gate: "", run: {} } });
|
|
128
|
-
const res = scaffoldProfile({ profile, targetDir: target });
|
|
129
|
-
expect(res.hookValid).toBe(false);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("isValidWorktreeInit mirrors change-A schema", () => {
|
|
133
|
-
expect(isValidWorktreeInit({ gate: "true", run: { type: "script", command: "x" } })).toBe(true);
|
|
134
|
-
expect(isValidWorktreeInit({ gate: "true", run: { type: "agent", prompt: "x" } })).toBe(true);
|
|
135
|
-
expect(isValidWorktreeInit({ gate: "", run: { type: "script", command: "x" } })).toBe(false);
|
|
136
|
-
expect(isValidWorktreeInit({ gate: "true", run: { type: "script" } })).toBe(false);
|
|
137
|
-
expect(isValidWorktreeInit(null)).toBe(false);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOX-doctrine seeding: marker-gated idempotency + kb-wired vs manual READ variant.
|
|
3
|
-
* See change: project-init-skill-and-profiles.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
6
|
-
import * as fs from "node:fs";
|
|
7
|
-
import * as os from "node:os";
|
|
8
|
-
import * as path from "node:path";
|
|
9
|
-
import { buildDoctrineBlock, seedDoctrine, DOX_MARKER, doctrinePath } from "../project-init/seed-doctrine.js";
|
|
10
|
-
|
|
11
|
-
describe("project-init dox doctrine seeding", () => {
|
|
12
|
-
let tmp: string;
|
|
13
|
-
let agentsMd: string;
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
tmp = fs.mkdtempSync(path.join(os.tmpdir(), "pi-dox-"));
|
|
17
|
-
agentsMd = path.join(tmp, "AGENTS.md");
|
|
18
|
-
});
|
|
19
|
-
afterEach(() => fs.rmSync(tmp, { recursive: true, force: true }));
|
|
20
|
-
|
|
21
|
-
it("kb-wired seed references kb_search / kb agents; manual does not", () => {
|
|
22
|
-
const kb = buildDoctrineBlock({ kbWired: true });
|
|
23
|
-
const manual = buildDoctrineBlock({ kbWired: false });
|
|
24
|
-
expect(kb).toContain("kb_search");
|
|
25
|
-
expect(kb).toContain("kb agents");
|
|
26
|
-
expect(manual).not.toContain("kb_search");
|
|
27
|
-
expect(manual).not.toContain("kb agents");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("kb-wired READ discipline carries the kb substitution table", () => {
|
|
31
|
-
// Spec: kb-read-discipline → "New projects inherit the substitution table"
|
|
32
|
-
// (Scenario: kb-wired seed carries the table).
|
|
33
|
-
const kb = buildDoctrineBlock({ kbWired: true });
|
|
34
|
-
expect(kb).toContain("You're about to"); // the table exists
|
|
35
|
-
expect(kb).toContain("kb_search --doc-type agents"); // symbol-lookup row, named case
|
|
36
|
-
expect(kb).toContain("kb_neighbors"); // chase imports / callers chain-through
|
|
37
|
-
expect(kb).toContain("kb_get"); // read one doc section chain-through
|
|
38
|
-
// Fall-through stays explicit — the table must not read as "kb replaces grep".
|
|
39
|
-
expect(kb).toContain("Fall-through (explicit)");
|
|
40
|
-
expect(kb).toContain("does NOT replace grep");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("manual READ discipline carries a degraded same-shape table (no kb tools)", () => {
|
|
44
|
-
// Spec: kb-read-discipline (Scenario: Manual seed carries a degraded table).
|
|
45
|
-
const manual = buildDoctrineBlock({ kbWired: false });
|
|
46
|
-
expect(manual).toContain("You're about to"); // same-shape table exists
|
|
47
|
-
expect(manual).toContain("nearest directory"); // lookup rows walk the AGENTS.md chain
|
|
48
|
-
expect(manual).toContain("Fall-through (explicit)"); // fall-through still explicit
|
|
49
|
-
// Degraded variant references no kb tooling at all.
|
|
50
|
-
expect(manual).not.toContain("kb_neighbors");
|
|
51
|
-
expect(manual).not.toContain("kb_get");
|
|
52
|
-
expect(manual).not.toContain("--doc-type agents");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("both variants carry the WRITE size-split rule", () => {
|
|
56
|
-
for (const kbWired of [true, false]) {
|
|
57
|
-
const block = buildDoctrineBlock({ kbWired });
|
|
58
|
-
expect(block).toContain(".AGENTS.md");
|
|
59
|
-
expect(block.toLowerCase()).toContain("split");
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("seeds once when the marker is absent", () => {
|
|
64
|
-
const res = seedDoctrine(agentsMd, { kbWired: true });
|
|
65
|
-
expect(res.seeded).toBe(true);
|
|
66
|
-
const content = fs.readFileSync(agentsMd, "utf8");
|
|
67
|
-
expect(content).toContain(DOX_MARKER);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("no-ops when the marker is already present", () => {
|
|
71
|
-
fs.writeFileSync(agentsMd, `# Existing\n\n${DOX_MARKER}\n\nold doctrine\n`);
|
|
72
|
-
const before = fs.readFileSync(agentsMd, "utf8");
|
|
73
|
-
const res = seedDoctrine(agentsMd, { kbWired: true });
|
|
74
|
-
expect(res.seeded).toBe(false);
|
|
75
|
-
expect(fs.readFileSync(agentsMd, "utf8")).toBe(before);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("re-running never double-seeds", () => {
|
|
79
|
-
seedDoctrine(agentsMd, { kbWired: false });
|
|
80
|
-
seedDoctrine(agentsMd, { kbWired: false });
|
|
81
|
-
seedDoctrine(agentsMd, { kbWired: false });
|
|
82
|
-
const markers = fs.readFileSync(agentsMd, "utf8").split(DOX_MARKER).length - 1;
|
|
83
|
-
expect(markers).toBe(1);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("preserves existing AGENTS.md content when appending", () => {
|
|
87
|
-
fs.writeFileSync(agentsMd, "# Project\n\nprose\n");
|
|
88
|
-
seedDoctrine(agentsMd, { kbWired: true });
|
|
89
|
-
const content = fs.readFileSync(agentsMd, "utf8");
|
|
90
|
-
expect(content).toContain("# Project");
|
|
91
|
-
expect(content).toContain(DOX_MARKER);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("the shipped doctrine file exists and defines all three sections", () => {
|
|
95
|
-
const raw = fs.readFileSync(doctrinePath(), "utf8");
|
|
96
|
-
expect(raw).toContain("dox:write:start");
|
|
97
|
-
expect(raw).toContain("dox:read:kb:start");
|
|
98
|
-
expect(raw).toContain("dox:read:manual:start");
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `project_trust` auto-decision gate + defensive cwd read.
|
|
3
|
-
*
|
|
4
|
-
* Deny-by-default: trust ONLY a dashboard-spawned headless session whose event
|
|
5
|
-
* cwd still equals the activation cwd; every other case defers to pi's default.
|
|
6
|
-
*
|
|
7
|
-
* See change: adopt-pi-074-080-features (A.3 — E5, X1, X3).
|
|
8
|
-
*/
|
|
9
|
-
import { describe, expect, it } from "vitest";
|
|
10
|
-
import { decideProjectTrust, readEventCwd } from "../project-trust.js";
|
|
11
|
-
|
|
12
|
-
const CWD = "/work/proj";
|
|
13
|
-
|
|
14
|
-
describe("E5: decideProjectTrust 3-bool matrix", () => {
|
|
15
|
-
const cwdMatch = { same: CWD, diff: "/work/other" };
|
|
16
|
-
// Enumerate dashboardSpawned × isHeadless × (eventCwd===activationCwd).
|
|
17
|
-
const rows: Array<[boolean, boolean, "same" | "diff", "trust" | "defer"]> = [
|
|
18
|
-
[true, true, "same", "trust"], // T·T·T — the ONLY trust row
|
|
19
|
-
[true, true, "diff", "defer"],
|
|
20
|
-
[true, false, "same", "defer"],
|
|
21
|
-
[true, false, "diff", "defer"],
|
|
22
|
-
[false, true, "same", "defer"],
|
|
23
|
-
[false, true, "diff", "defer"],
|
|
24
|
-
[false, false, "same", "defer"],
|
|
25
|
-
[false, false, "diff", "defer"],
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
it.each(rows)(
|
|
29
|
-
"dashboardSpawned=%s isHeadless=%s cwd=%s → %s",
|
|
30
|
-
(dashboardSpawned, isHeadless, cwd, expected) => {
|
|
31
|
-
expect(
|
|
32
|
-
decideProjectTrust({
|
|
33
|
-
dashboardSpawned,
|
|
34
|
-
isHeadless,
|
|
35
|
-
eventCwd: cwdMatch[cwd],
|
|
36
|
-
activationCwd: CWD,
|
|
37
|
-
}),
|
|
38
|
-
).toBe(expected);
|
|
39
|
-
},
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
it("trusts on the single T·T·T row only (exactly one of the 8)", () => {
|
|
43
|
-
const trusted = rows.filter(([, , , expected]) => expected === "trust");
|
|
44
|
-
expect(trusted).toHaveLength(1);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe("X1: unreadable event cwd defers (no crash)", () => {
|
|
49
|
-
it("readEventCwd returns undefined when the cwd getter throws", () => {
|
|
50
|
-
const staleCtx = {
|
|
51
|
-
get cwd(): string {
|
|
52
|
-
throw new Error("session replaced — cwd getter throws");
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
expect(readEventCwd(undefined, staleCtx)).toBeUndefined();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("an undefined eventCwd defers even for a dashboard-spawned headless session", () => {
|
|
59
|
-
expect(
|
|
60
|
-
decideProjectTrust({ dashboardSpawned: true, isHeadless: true, eventCwd: undefined, activationCwd: CWD }),
|
|
61
|
-
).toBe("defer");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("prefers the event cwd, falls back to ctx cwd", () => {
|
|
65
|
-
expect(readEventCwd({ cwd: "/from/event" }, { cwd: "/from/ctx" })).toBe("/from/event");
|
|
66
|
-
expect(readEventCwd({}, { cwd: "/from/ctx" })).toBe("/from/ctx");
|
|
67
|
-
expect(readEventCwd(null, null)).toBeUndefined();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe("X3: activation-cwd capture guards the pre-session_start ordering", () => {
|
|
72
|
-
it("a defined activationCwd (captured at activation, not session_start) compares real cwds", () => {
|
|
73
|
-
// The event fires BEFORE session_start; because activationCwd is captured
|
|
74
|
-
// at bridge activation it is already a real path, so the gate compares
|
|
75
|
-
// real cwds and can trust — instead of comparing against `undefined`.
|
|
76
|
-
expect(
|
|
77
|
-
decideProjectTrust({ dashboardSpawned: true, isHeadless: true, eventCwd: CWD, activationCwd: CWD }),
|
|
78
|
-
).toBe("trust");
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("regression: if activationCwd had been captured too late (undefined), it would defer", () => {
|
|
82
|
-
// Documents the cycle-2 dead-on-arrival bug the activation capture fixes.
|
|
83
|
-
expect(
|
|
84
|
-
decideProjectTrust({
|
|
85
|
-
dashboardSpawned: true,
|
|
86
|
-
isHeadless: true,
|
|
87
|
-
eventCwd: CWD,
|
|
88
|
-
activationCwd: undefined as unknown as string,
|
|
89
|
-
}),
|
|
90
|
-
).toBe("defer");
|
|
91
|
-
});
|
|
92
|
-
});
|