gentle-pi 4.5.1 → 4.6.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 +9 -6
- package/assets/agents/gentle-ai-verify.md +4 -0
- package/assets/agents/gentle-ai-worker.md +1 -0
- package/assets/migrations/agent-body-history.json +147 -0
- package/assets/orchestrator-delegation-reference.md +3 -3
- package/assets/orchestrator-delegation.md +2 -2
- package/assets/orchestrator-verification.md +10 -6
- package/assets/orchestrator.md +8 -8
- package/bin/gentle-shell.mjs +61 -26
- package/docs/ci-performance.md +11 -0
- package/docs/delegated-verification.md +6 -0
- package/docs/fast-mode.md +15 -0
- package/docs/gentle-agents-activity.md +8 -0
- package/docs/gentle-shell.md +69 -19
- package/docs/install-wizard.md +1 -1
- package/docs/mcp-status.md +52 -0
- package/docs/prompt-budget.md +28 -0
- package/docs/readme-reference.md +79 -20
- package/docs/session-profile-format.md +20 -5
- package/docs/sound-notifications.md +1 -1
- package/docs/star-prompt.md +32 -0
- package/docs/work-continuity.md +46 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/codegraph-tools.ts +38 -4
- package/extensions/gentle-agents.ts +477 -50
- package/extensions/gentle-ai.ts +1041 -188
- package/extensions/gentle-fast.ts +61 -0
- package/extensions/gentle-guide.ts +174 -0
- package/extensions/gentle-herdr-activity.ts +21 -1
- package/extensions/gentle-herdr-agent.ts +144 -0
- package/extensions/gentle-program-identity.ts +61 -0
- package/extensions/gentle-shell.ts +642 -97
- package/extensions/gentle-star-prompt.ts +334 -0
- package/extensions/gentle-stats.ts +5 -5
- package/extensions/gentle-todo.ts +42 -22
- package/extensions/history/store.ts +18 -12
- package/extensions/skill-registry.ts +35 -3
- package/extensions/startup-banner.ts +39 -7
- package/lib/agent-assets.ts +74 -17
- package/lib/agent-profiles.ts +1 -1
- package/lib/agents-config.ts +12 -3
- package/lib/agents-keys.ts +8 -16
- package/lib/agents-protocol.ts +80 -4
- package/lib/agents-runner.ts +105 -4
- package/lib/agents-view.ts +6 -1
- package/lib/agents-widget.ts +132 -9
- package/lib/bridge-cost.ts +28 -0
- package/lib/codemode-renderer.ts +16 -0
- package/lib/command-palette-catalog.ts +1 -0
- package/lib/command-palette.ts +21 -8
- package/lib/exploration-budget.ts +62 -0
- package/lib/gentle-guide.ts +201 -0
- package/lib/gentle-shell-launcher.ts +4 -0
- package/lib/herdr-activity.ts +9 -3
- package/lib/herdr-task-summary-policy.ts +85 -0
- package/lib/inprocess-reviewer.ts +33 -13
- package/lib/jobs-sidebar-state.ts +5 -6
- package/lib/jobs-widget.ts +16 -52
- package/lib/keymaps-customize.ts +81 -0
- package/lib/keymaps.ts +291 -0
- package/lib/model-fallback-notice.ts +61 -0
- package/lib/model-fallback-policy.ts +141 -0
- package/lib/model-fallback-store.ts +143 -0
- package/lib/model-routing-authority.ts +10 -2
- package/lib/nan-provider.ts +3 -2
- package/lib/native-review-cli.ts +7 -2
- package/lib/notification-customize.ts +48 -51
- package/lib/openai-fast-tier.ts +22 -0
- package/lib/orchestrator-discovery.ts +5 -1
- package/lib/orchestrator-fallback.ts +75 -0
- package/lib/pasted-image-paths.ts +113 -0
- package/lib/questionnaire/questionnaire-view.ts +121 -7
- package/lib/review-candidate-view-owner.ts +4 -0
- package/lib/review-candidate-view.ts +10 -7
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +22 -7
- package/lib/review-repository.ts +5 -0
- package/lib/session-profile-append-controller.ts +21 -6
- package/lib/session-profile-authority.ts +119 -0
- package/lib/session-profile-binding.ts +54 -5
- package/lib/session-profile-freeze.ts +105 -9
- package/lib/session-profile-integration.ts +313 -0
- package/lib/session-profile-persistence.ts +63 -9
- package/lib/shell-bar.ts +171 -56
- package/lib/shell-card.ts +26 -6
- package/lib/shell-page.ts +120 -0
- package/lib/shell-panel.ts +149 -0
- package/lib/shell-prompt.ts +53 -1
- package/lib/shell-sidebar-layout.ts +98 -25
- package/lib/shell-sidebar.ts +54 -1
- package/lib/shell-stats.ts +123 -0
- package/lib/shell-todo.ts +71 -0
- package/lib/shell-usage.ts +12 -2
- package/lib/star-prompt.ts +197 -0
- package/lib/verifier-admission.ts +18 -8
- package/lib/verifier-settle-reminder.ts +64 -0
- package/lib/vim-editor-adapter.ts +6 -1
- package/lib/visual-customization-policy.ts +41 -6
- package/lib/visual-customize-view.ts +164 -26
- package/lib/visual-layout-preview.ts +43 -0
- package/lib/yolo-session-policy.ts +28 -1
- package/package.json +1 -1
- package/runtime/gentle-shell-launcher.mjs +4 -0
- package/runtime/native-review-cli.mjs +7 -2
- package/runtime/review-integration-v2.mjs +22 -7
- package/runtime/windows-session-transport.ps1 +60 -3
- package/scripts/bootstrap.sh +4 -1
- package/scripts/installer-preflight.mjs +1 -1
- package/scripts/pi-update.mjs +113 -3
- package/scripts/run-test-suite.mjs +17 -1
- package/scripts/shell-snapshot.mjs +340 -0
- package/scripts/test-packed-runner.mjs +1 -1
- package/scripts/update-agent-body-history.mjs +41 -0
- package/scripts/verify-installer-tap.mjs +45 -0
- package/scripts/verify-package-files.mjs +2 -0
- package/skills/gentle-ai/SKILL.md +2 -2
- package/skills/tui-design/NOTICE.md +5 -0
- package/skills/tui-design/SKILL.md +56 -0
- package/skills/tui-design/references/commands.md +75 -0
- package/skills/tui-design/references/critique.md +48 -0
- package/skills/tui-design/references/design-doc.md +44 -0
- package/skills/tui-design/references/terminal-craft.md +64 -0
- package/skills/tui-design/references/visual-loop.md +32 -0
- package/tests/agents-protocol.test.ts +53 -1
- package/tests/agents-runner.test.ts +168 -3
- package/tests/agents-view.test.ts +27 -0
- package/tests/agents-widget.test.ts +312 -10
- package/tests/bounded-scan-contract.test.ts +39 -0
- package/tests/bridge-cost.test.ts +32 -0
- package/tests/bundled-install.test.ts +6 -4
- package/tests/ci-concurrency.test.ts +11 -0
- package/tests/ci-merge-base-identity.test.ts +114 -0
- package/tests/codegraph-tools.test.ts +69 -0
- package/tests/codemode-rendering.test.ts +22 -2
- package/tests/command-palette.test.ts +16 -2
- package/tests/commit-slice-signal.test.ts +11 -9
- package/tests/delegate-for-reason-contract.test.ts +5 -4
- package/tests/exploration-budget.test.ts +128 -0
- package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
- package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +18 -10
- package/tests/fixtures/session-profile-v1/replay.ts +125 -0
- package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
- package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
- package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
- package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
- package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
- package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
- package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
- package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
- package/tests/gentle-agents.test.ts +416 -21
- package/tests/gentle-ai-exploration-budget.test.ts +135 -0
- package/tests/gentle-ai.test.ts +1007 -33
- package/tests/gentle-fast.test.ts +73 -0
- package/tests/gentle-guide.test.ts +208 -0
- package/tests/gentle-herdr-activity.test.ts +76 -2
- package/tests/gentle-herdr-agent.test.ts +111 -0
- package/tests/gentle-program-identity.test.ts +197 -0
- package/tests/gentle-shell-bin.test.ts +49 -26
- package/tests/gentle-shell-launcher.test.ts +18 -2
- package/tests/gentle-shell.test.ts +1068 -37
- package/tests/gentle-stats.test.ts +15 -2
- package/tests/gentle-todo.test.ts +50 -4
- package/tests/herdr-task-summary-policy.test.ts +128 -0
- package/tests/history-store-private-mode.test.ts +40 -0
- package/tests/image-paste-chips.test.ts +42 -0
- package/tests/inprocess-reviewer.test.ts +122 -0
- package/tests/installer-posix-bootstrap.test.ts +67 -5
- package/tests/installer-server.test.ts +2 -2
- package/tests/installer-windows-diagnostics.test.ts +4 -5
- package/tests/isolated-config-home.ts +28 -0
- package/tests/jobs-widget.test.ts +25 -37
- package/tests/keymaps-customize.test.ts +114 -0
- package/tests/keymaps.test.ts +103 -0
- package/tests/maintainer/mcp-status.maintest.ts +88 -0
- package/tests/maintainer/pi-update-source.maintest.ts +116 -0
- package/tests/model-fallback-notice.test.ts +45 -0
- package/tests/model-fallback-policy.test.ts +83 -0
- package/tests/model-fallback-store.test.ts +111 -0
- package/tests/nan-provider.test.ts +4 -4
- package/tests/no-self-pause-contract.test.ts +19 -0
- package/tests/notification-customize.test.ts +58 -34
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/odd-routing-contract.test.ts +1 -1
- package/tests/orchestrator-fallback.test.ts +82 -0
- package/tests/orchestrator-prompt-budget.test.ts +131 -0
- package/tests/package-manifest.test.ts +160 -7
- package/tests/pasted-image-paths.test.ts +118 -0
- package/tests/persona-reply-language.test.ts +20 -1
- package/tests/pi-update-launcher.test.ts +32 -8
- package/tests/pi-update-source.test.ts +162 -0
- package/tests/profile-fast-tier.test.ts +311 -0
- package/tests/profile-tier-footer.test.ts +79 -0
- package/tests/questionnaire-view.test.ts +150 -0
- package/tests/review-candidate-owner-sweep.test.ts +93 -0
- package/tests/review-candidate-view.test.ts +51 -0
- package/tests/review-controller-native-routing.test.ts +120 -6
- package/tests/review-gate.test.ts +24 -0
- package/tests/review-inspect-preflight.test.ts +197 -0
- package/tests/review-integration-v2-forward.test.ts +59 -0
- package/tests/review-repository.test.ts +52 -1
- package/tests/review-sidebar-state.test.ts +5 -5
- package/tests/run-test-suite.test.ts +61 -5
- package/tests/sensitive-path-tools.test.ts +74 -0
- package/tests/session-profile-append-controller.test.ts +63 -0
- package/tests/session-profile-authority.test.ts +259 -0
- package/tests/session-profile-binding.test.ts +15 -0
- package/tests/session-profile-extension.test.ts +615 -0
- package/tests/session-profile-freeze.test.ts +110 -2
- package/tests/session-profile-integration.test.ts +857 -0
- package/tests/session-profile-persistence.test.ts +57 -0
- package/tests/session-profile-v1-compat.test.ts +221 -0
- package/tests/shell-bar.test.ts +113 -55
- package/tests/shell-card.test.ts +13 -1
- package/tests/shell-page.test.ts +108 -0
- package/tests/shell-panel.test.ts +332 -0
- package/tests/shell-prompt.test.ts +54 -0
- package/tests/shell-render-cache.test.ts +5 -0
- package/tests/shell-sidebar-fullscreen.test.ts +12 -0
- package/tests/shell-sidebar-layout.test.ts +159 -27
- package/tests/shell-stats.test.ts +90 -0
- package/tests/shell-usage.test.ts +14 -0
- package/tests/skill-registry.test.ts +68 -1
- package/tests/star-prompt.test.ts +470 -0
- package/tests/startup-banner.test.ts +57 -1
- package/tests/task-size-routing-contract.test.ts +45 -1
- package/tests/verifier-settle-reminder.test.ts +281 -0
- package/tests/verify-first-launch-contract.test.ts +56 -5
- package/tests/verify-installer-tap.test.ts +57 -0
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +61 -7
- package/tests/visual-customize-view.test.ts +253 -8
- package/tests/visual-layout-preview.test.ts +28 -0
- package/tests/windows-session-bootstrap.test.ts +105 -2
- package/tests/work-continuity-contract.test.ts +86 -0
- package/tests/writer-surfaces.test.ts +12 -10
- package/tests/yolo-customize.test.ts +30 -11
- package/tests/yolo-mode-runtime.test.ts +4 -2
- package/tests/yolo-mode.test.ts +16 -2
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import {
|
|
4
|
+
mkdirSync,
|
|
5
|
+
mkdtempSync,
|
|
6
|
+
readFileSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
} from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import {
|
|
13
|
+
createEventBus,
|
|
14
|
+
createExtensionRuntime,
|
|
15
|
+
ExtensionRunner,
|
|
16
|
+
SessionManager,
|
|
17
|
+
type ExtensionAPI,
|
|
18
|
+
type ExtensionUIContext,
|
|
19
|
+
} from "@earendil-works/pi-coding-agent";
|
|
20
|
+
import { loadExtensionFromFactory } from "../node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js";
|
|
21
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
22
|
+
import gentleAgents, {
|
|
23
|
+
type SessionTransportFactory,
|
|
24
|
+
} from "../extensions/gentle-agents.ts";
|
|
25
|
+
import { bindSessionRepositoryPreparation } from "../lib/bounded-writer-admission.ts";
|
|
26
|
+
import { SESSION_PROFILE_CUSTOM_TYPE } from "../lib/session-profile-persistence.ts";
|
|
27
|
+
import { publishSessionProfileOutcome, readSessionProfileAuthority } from "../lib/session-profile-authority.ts";
|
|
28
|
+
import { bindSessionProfile, readSessionProfileBinding, readSessionProfileStartupNone } from "../lib/session-profile-binding.ts";
|
|
29
|
+
import type { SessionProfileLifecycleManager } from "../lib/session-profile-integration.ts";
|
|
30
|
+
|
|
31
|
+
// Admission tests use actual factory loader/runner and manager. They do not
|
|
32
|
+
// claim runtime lifecycle or visual evidence: those are separate fixtures.
|
|
33
|
+
for (const order of ["agents-only", "agents-first", "owner-first"] as const)
|
|
34
|
+
for (const agent of ["explore", "worker"] as const)
|
|
35
|
+
test(`U3 unavailable authority blocks ${agent} admission before effects (${order})`, async (t) => {
|
|
36
|
+
const root = mkdtempSync(join(tmpdir(), "u3-admission-")),
|
|
37
|
+
home = join(root, "home");
|
|
38
|
+
const definitions = join(home, ".pi", "agent", "agents");
|
|
39
|
+
mkdirSync(definitions, { recursive: true });
|
|
40
|
+
for (const name of ["explore", "worker"])
|
|
41
|
+
writeFileSync(
|
|
42
|
+
join(definitions, `${name}.md`),
|
|
43
|
+
"---\ndescription: fixture\nmodel: openai/gpt-4o\ntools: [read]\n---\nOffline fixture",
|
|
44
|
+
);
|
|
45
|
+
const manager = SessionManager.create(root, join(root, "sessions"));
|
|
46
|
+
manager.appendMessage({ role: "user", content: "fixture", timestamp: 1 });
|
|
47
|
+
manager.appendCustomEntry("gentle-pi.session-profile/v99", {
|
|
48
|
+
kind: "future",
|
|
49
|
+
});
|
|
50
|
+
const initialDisk = readFileSync(manager.getSessionFile()!, "utf8");
|
|
51
|
+
const counts = { registry: 0, prepare: 0, child: 0, config: 0 };
|
|
52
|
+
const transport: SessionTransportFactory = {
|
|
53
|
+
createRegistry: async () => ({
|
|
54
|
+
list: async () => [],
|
|
55
|
+
listActivations: async () => [],
|
|
56
|
+
}),
|
|
57
|
+
createListener: (registry) => ({
|
|
58
|
+
registry,
|
|
59
|
+
start: async () => {},
|
|
60
|
+
close: async () => {},
|
|
61
|
+
}),
|
|
62
|
+
createClient: () => ({
|
|
63
|
+
close() {},
|
|
64
|
+
sendNotification: async () => {
|
|
65
|
+
throw Error("no messaging in fixture");
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
const runtime = createExtensionRuntime(),
|
|
70
|
+
bus = createEventBus();
|
|
71
|
+
const agentsFactory = (pi: ExtensionAPI) =>
|
|
72
|
+
gentleAgents(
|
|
73
|
+
pi,
|
|
74
|
+
{},
|
|
75
|
+
{
|
|
76
|
+
home,
|
|
77
|
+
agentHome: join(home, ".pi", "agent"),
|
|
78
|
+
env: { GENTLE_PI_CONFIG_HOME: join(root, "config") },
|
|
79
|
+
sessionTransport: transport,
|
|
80
|
+
schedule: () => () => {},
|
|
81
|
+
childExtensionPaths: [],
|
|
82
|
+
resolveWorktree: () => {
|
|
83
|
+
counts.registry++;
|
|
84
|
+
return undefined;
|
|
85
|
+
},
|
|
86
|
+
spawn: () => {
|
|
87
|
+
counts.child++;
|
|
88
|
+
throw Error("fixture forbids actual children");
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
const ownerFactory = createGentleAiExtension({
|
|
93
|
+
nativeReviewCli: null,
|
|
94
|
+
candidateViews: null,
|
|
95
|
+
processEnv: { GENTLE_PI_AGENTS_CHILD: "1" },
|
|
96
|
+
});
|
|
97
|
+
const factories =
|
|
98
|
+
order === "agents-only"
|
|
99
|
+
? [agentsFactory]
|
|
100
|
+
: order === "agents-first"
|
|
101
|
+
? [agentsFactory, ownerFactory]
|
|
102
|
+
: [ownerFactory, agentsFactory];
|
|
103
|
+
const extensions = [];
|
|
104
|
+
for (const factory of factories)
|
|
105
|
+
extensions.push(
|
|
106
|
+
await loadExtensionFromFactory(factory, root, bus, runtime),
|
|
107
|
+
);
|
|
108
|
+
const runner = new ExtensionRunner(extensions, runtime, root, manager, {
|
|
109
|
+
find: () => {
|
|
110
|
+
counts.config++;
|
|
111
|
+
return { provider: "openai", id: "gpt-4o" };
|
|
112
|
+
},
|
|
113
|
+
getAll: () => [],
|
|
114
|
+
} as never);
|
|
115
|
+
runner.setUIContext(
|
|
116
|
+
{
|
|
117
|
+
notify() {},
|
|
118
|
+
setStatus() {},
|
|
119
|
+
setWidget() {},
|
|
120
|
+
} as unknown as ExtensionUIContext,
|
|
121
|
+
"tui",
|
|
122
|
+
);
|
|
123
|
+
runner.bindCommandContext();
|
|
124
|
+
await runner.emit({ type: "session_start", reason: "startup" });
|
|
125
|
+
const unbind = bindSessionRepositoryPreparation(
|
|
126
|
+
manager,
|
|
127
|
+
root,
|
|
128
|
+
async () => {
|
|
129
|
+
counts.prepare++;
|
|
130
|
+
return false;
|
|
131
|
+
},
|
|
132
|
+
() => true,
|
|
133
|
+
);
|
|
134
|
+
t.after(async () => {
|
|
135
|
+
unbind();
|
|
136
|
+
await runner.emit({ type: "session_shutdown", reason: "quit" });
|
|
137
|
+
runner.invalidate();
|
|
138
|
+
rmSync(root, { recursive: true, force: true });
|
|
139
|
+
});
|
|
140
|
+
counts.registry = 0;
|
|
141
|
+
counts.config = 0;
|
|
142
|
+
const entries = manager.getEntries().length;
|
|
143
|
+
const tool = runner
|
|
144
|
+
.getAllRegisteredTools()
|
|
145
|
+
.find(({ definition }) => definition.name === "subagent_run")!.definition;
|
|
146
|
+
await assert.rejects(
|
|
147
|
+
tool.execute(
|
|
148
|
+
"unavailable",
|
|
149
|
+
{
|
|
150
|
+
agent,
|
|
151
|
+
task:
|
|
152
|
+
agent === "worker"
|
|
153
|
+
? "Implement\n## Allowed edit surfaces\nsrc/app.ts"
|
|
154
|
+
: "Map safely",
|
|
155
|
+
mode: "background",
|
|
156
|
+
} as never,
|
|
157
|
+
undefined,
|
|
158
|
+
undefined,
|
|
159
|
+
runner.createCommandContext() as never,
|
|
160
|
+
),
|
|
161
|
+
/session profile authority unavailable/i,
|
|
162
|
+
);
|
|
163
|
+
assert.deepEqual(
|
|
164
|
+
counts,
|
|
165
|
+
{ registry: 0, prepare: 0, child: 0, config: 0 },
|
|
166
|
+
"unavailable authority cannot silently fall through to shared routing",
|
|
167
|
+
);
|
|
168
|
+
assert.equal(
|
|
169
|
+
manager.getEntries().length,
|
|
170
|
+
entries,
|
|
171
|
+
"no queue/publication entries",
|
|
172
|
+
);
|
|
173
|
+
assert.equal(
|
|
174
|
+
readFileSync(manager.getSessionFile()!, "utf8"),
|
|
175
|
+
initialDisk,
|
|
176
|
+
"rejected data and disk remain unchanged",
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("U3 independently evaluated binding readers share only process-local snapshots", async () => {
|
|
181
|
+
const {
|
|
182
|
+
bindSessionProfile,
|
|
183
|
+
readSessionProfileBinding,
|
|
184
|
+
clearSessionProfileBinding,
|
|
185
|
+
} = await import("../lib/session-profile-binding.ts");
|
|
186
|
+
const moduleUrl = new URL(
|
|
187
|
+
"../lib/session-profile-binding.ts?u3-module-isolation",
|
|
188
|
+
import.meta.url,
|
|
189
|
+
).href;
|
|
190
|
+
const copy = (await import(
|
|
191
|
+
moduleUrl
|
|
192
|
+
)) as typeof import("../lib/session-profile-binding.ts");
|
|
193
|
+
const models = { worker: { model: "openai/gpt-4o" } };
|
|
194
|
+
bindSessionProfile("u3-module", "team", models);
|
|
195
|
+
models.worker.model = "changed";
|
|
196
|
+
assert.equal(
|
|
197
|
+
copy.readSessionProfileBinding("u3-module")?.modelProfiles.worker?.model,
|
|
198
|
+
"openai/gpt-4o",
|
|
199
|
+
);
|
|
200
|
+
const snapshot = copy.readSessionProfileBinding("u3-module")!;
|
|
201
|
+
snapshot.modelProfiles.worker.model = "changed-reader";
|
|
202
|
+
assert.equal(
|
|
203
|
+
readSessionProfileBinding("u3-module")?.modelProfiles.worker?.model,
|
|
204
|
+
"openai/gpt-4o",
|
|
205
|
+
);
|
|
206
|
+
clearSessionProfileBinding("u3-module");
|
|
207
|
+
assert.equal(copy.readSessionProfileBinding("u3-module"), undefined);
|
|
208
|
+
assert.equal(SESSION_PROFILE_CUSTOM_TYPE, "gentle-pi.session-profile/v1");
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Profile-less branches never depend on parsing the rest of the session file.
|
|
212
|
+
function savedProfileLessSession(t: test.TestContext) {
|
|
213
|
+
const root = mkdtempSync(join(tmpdir(), "u3-profileless-"));
|
|
214
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
215
|
+
const manager = SessionManager.create(root, join(root, "sessions"));
|
|
216
|
+
manager.appendMessage({ role: "user", content: "fixture", timestamp: 1 });
|
|
217
|
+
manager.appendMessage({ role: "assistant", content: [{ type: "text", text: "ok" }], api: "openai-completions", provider: "openai", model: "gpt-4o", usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } }, stopReason: "stop", timestamp: 2 } as never);
|
|
218
|
+
const file = manager.getSessionFile()!;
|
|
219
|
+
assert.ok(readFileSync(file, "utf8").length > 0, "fixture session is flushed");
|
|
220
|
+
return { manager, file };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
test("unrelated session-file corruption does not block a profile-less branch", (t) => {
|
|
224
|
+
const { manager, file } = savedProfileLessSession(t);
|
|
225
|
+
writeFileSync(file, `${readFileSync(file, "utf8")}{not json\n`);
|
|
226
|
+
assert.deepEqual(readSessionProfileAuthority(manager), { available: true });
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test("a profile-less saved branch drops a binding left from another branch", (t) => {
|
|
230
|
+
const { manager } = savedProfileLessSession(t);
|
|
231
|
+
bindSessionProfile(manager.getSessionId(), "other-branch", { worker: { model: "openai/gpt-4o" } });
|
|
232
|
+
assert.deepEqual(readSessionProfileAuthority(manager), { available: true });
|
|
233
|
+
assert.equal(readSessionProfileBinding(manager.getSessionId()), undefined);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// A2 (gentle-shell#2742, section 4): the newest corroborated record publishes
|
|
237
|
+
// its origin and startup state, and a startup-none clear stays distinct from a
|
|
238
|
+
// legacy clear; each later record replaces it, as on /tree.
|
|
239
|
+
test("publishing keeps the record's origin and startup state, and the newest record replaces them", () => {
|
|
240
|
+
const manager = { getSessionId: () => "a2-publish" } as SessionProfileLifecycleManager;
|
|
241
|
+
const publish = (state: unknown) => publishSessionProfileOutcome(manager, { status: "persisted", state } as never);
|
|
242
|
+
const team = { worker: { model: "openai/gpt-5" }, orchestrator: { model: "openai/gpt-5" } };
|
|
243
|
+
const startup = publish({ status: "bound", binding: { kind: "bind", origin: "repo", name: "team", modelProfiles: team } });
|
|
244
|
+
assert.deepEqual(startup, { available: true, binding: { name: "team", origin: "repo", modelProfiles: team } });
|
|
245
|
+
const known = { origin: "global" as const, name: "team", modelProfiles: team };
|
|
246
|
+
publish({ status: "bound", binding: { kind: "bind", origin: "user", name: "fast", modelProfiles: team, startup: known } });
|
|
247
|
+
assert.deepEqual(readSessionProfileBinding("a2-publish")?.startup, known);
|
|
248
|
+
assert.deepEqual(publish({ status: "cleared", startup: "none" }), { available: true });
|
|
249
|
+
assert.equal(readSessionProfileBinding("a2-publish"), undefined);
|
|
250
|
+
assert.equal(readSessionProfileStartupNone("a2-publish"), true);
|
|
251
|
+
publish({ status: "cleared" });
|
|
252
|
+
assert.equal(readSessionProfileStartupNone("a2-publish"), false, "a legacy clear carries no startup state");
|
|
253
|
+
publish({ status: "cleared", startup: "none" });
|
|
254
|
+
publish({ status: "bound", binding: { kind: "bind", origin: "user", name: "fast", modelProfiles: team } });
|
|
255
|
+
assert.equal(readSessionProfileStartupNone("a2-publish"), false, "a newer bind wins");
|
|
256
|
+
publish({ status: "cleared", startup: "none" });
|
|
257
|
+
assert.deepEqual(publish({ status: "invalid" }), { available: false });
|
|
258
|
+
assert.equal(readSessionProfileStartupNone("a2-publish"), false, "an unreadable record keeps no startup state");
|
|
259
|
+
});
|
|
@@ -161,3 +161,18 @@ test("each entrypoint still hands out private copies of the shared store", (t) =
|
|
|
161
161
|
);
|
|
162
162
|
resetSessionProfileBindingsForTesting();
|
|
163
163
|
});
|
|
164
|
+
|
|
165
|
+
test("the store keeps a binding's origin and startup state as private copies", () => {
|
|
166
|
+
resetSessionProfileBindingsForTesting();
|
|
167
|
+
bindSessionProfile("session-a", "work", ROUTING);
|
|
168
|
+
assert.deepEqual(readSessionProfileBinding("session-a"), { name: "work", origin: "user", modelProfiles: ROUTING });
|
|
169
|
+
const startup = { origin: "repo" as const, name: "team", modelProfiles: ROUTING };
|
|
170
|
+
bindSessionProfile("session-b", "work", ROUTING, { startup });
|
|
171
|
+
bindSessionProfile("session-c", "team", ROUTING, { origin: "global" });
|
|
172
|
+
startup.modelProfiles = {};
|
|
173
|
+
const read = readSessionProfileBinding("session-b");
|
|
174
|
+
assert.deepEqual(read, { name: "work", origin: "user", modelProfiles: ROUTING, startup: { origin: "repo", name: "team", modelProfiles: ROUTING } });
|
|
175
|
+
if (typeof read?.startup === "object") read.startup.modelProfiles.worker!.model = "edited/model";
|
|
176
|
+
assert.deepEqual(readSessionProfileBinding("session-b")?.startup, { origin: "repo", name: "team", modelProfiles: ROUTING });
|
|
177
|
+
assert.deepEqual(readSessionProfileBinding("session-c"), { name: "team", origin: "global", modelProfiles: ROUTING });
|
|
178
|
+
});
|