gentle-pi 4.5.0 → 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-music.md +6 -3
- package/docs/gentle-shell.md +70 -20
- 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 +82 -21
- 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 +1046 -191
- 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-music.ts +10 -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/design-canvas-server.test.ts +6 -2
- 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 +1011 -37
- 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-music.test.ts +36 -1
- 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 +61 -0
- 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,470 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { createStarPromptExtension } from "../extensions/gentle-star-prompt.ts";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_STAR_PROMPT_STATE,
|
|
10
|
+
DISMISS_CHORD,
|
|
11
|
+
PROMPTS_BEFORE_ASKING,
|
|
12
|
+
STAR_CHORD,
|
|
13
|
+
STAR_PROMPT_IDLE_MS,
|
|
14
|
+
STAR_PROMPT_VISIBLE_MS,
|
|
15
|
+
ghStarred,
|
|
16
|
+
readStarPromptState,
|
|
17
|
+
shouldOfferStarPrompt,
|
|
18
|
+
writeStarPromptState,
|
|
19
|
+
type StarPromptState,
|
|
20
|
+
} from "../lib/star-prompt.ts";
|
|
21
|
+
|
|
22
|
+
// ---------- lib: state ----------
|
|
23
|
+
|
|
24
|
+
test("star prompt state: a missing file reads as fresh defaults and stays usable", () => {
|
|
25
|
+
const dir = join(tmpdir(), `star-prompt-${Date.now()}-${Math.random()}`);
|
|
26
|
+
try {
|
|
27
|
+
const read = readStarPromptState(dir);
|
|
28
|
+
assert.equal(read.unusable, false);
|
|
29
|
+
assert.equal(read.state.sent, 0);
|
|
30
|
+
assert.equal(read.state.dismissed, false);
|
|
31
|
+
} finally {
|
|
32
|
+
rm(dir, { recursive: true, force: true }).catch(() => {});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("star prompt state: malformed JSON fails closed as unusable", async () => {
|
|
37
|
+
const dir = await mkdtemp(join(tmpdir(), "star-prompt-"));
|
|
38
|
+
try {
|
|
39
|
+
await writeFile(join(dir, "star-prompt.json"), "{not json");
|
|
40
|
+
const read = readStarPromptState(dir);
|
|
41
|
+
assert.equal(read.malformed, true);
|
|
42
|
+
assert.equal(read.unusable, true);
|
|
43
|
+
} finally {
|
|
44
|
+
await rm(dir, { recursive: true, force: true });
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("star prompt state: valid content round-trips", async () => {
|
|
49
|
+
const dir = await mkdtemp(join(tmpdir(), "star-prompt-"));
|
|
50
|
+
try {
|
|
51
|
+
writeStarPromptState(dir, { schema: "gentle-shell.star-prompt/v1", sent: 7, dismissed: true });
|
|
52
|
+
const raw = JSON.parse(await readFile(join(dir, "star-prompt.json"), "utf8"));
|
|
53
|
+
assert.equal(raw.sent, 7);
|
|
54
|
+
const read = readStarPromptState(dir);
|
|
55
|
+
assert.equal(read.unusable, false);
|
|
56
|
+
assert.equal(read.state.sent, 7);
|
|
57
|
+
} finally {
|
|
58
|
+
await rm(dir, { recursive: true, force: true });
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ---------- lib: decision ----------
|
|
63
|
+
|
|
64
|
+
test("decision: silent through the threshold, eligible from sent + 1", () => {
|
|
65
|
+
const base = { sent: 0, dismissed: false, unusable: false, offeredThisSession: false, agentRunning: false };
|
|
66
|
+
for (let sent = 0; sent <= PROMPTS_BEFORE_ASKING; sent++) {
|
|
67
|
+
assert.equal(shouldOfferStarPrompt({ ...base, sent }), false, `sent=${sent}`);
|
|
68
|
+
}
|
|
69
|
+
assert.equal(shouldOfferStarPrompt({ ...base, sent: PROMPTS_BEFORE_ASKING + 1 }), true);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("decision: dismissal, unusable state, already offered, or a running agent blocks the offer", () => {
|
|
73
|
+
const base = { sent: PROMPTS_BEFORE_ASKING + 1, dismissed: false, unusable: false, offeredThisSession: false, agentRunning: false };
|
|
74
|
+
assert.equal(shouldOfferStarPrompt({ ...base, dismissed: true }), false);
|
|
75
|
+
assert.equal(shouldOfferStarPrompt({ ...base, unusable: true }), false);
|
|
76
|
+
assert.equal(shouldOfferStarPrompt({ ...base, offeredThisSession: true }), false);
|
|
77
|
+
assert.equal(shouldOfferStarPrompt({ ...base, agentRunning: true }), false);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// ---------- harness ----------
|
|
81
|
+
|
|
82
|
+
const drain = async () => { for (let i = 0; i < 20; i++) await Promise.resolve(); };
|
|
83
|
+
|
|
84
|
+
interface OfferRow {
|
|
85
|
+
render(width: number): string[];
|
|
86
|
+
handleMouse(event: never): unknown;
|
|
87
|
+
dispose?(): void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface HarnessOptions {
|
|
91
|
+
state?: unknown;
|
|
92
|
+
unusable?: boolean;
|
|
93
|
+
writeState?: (_configHome: string, state: StarPromptState) => void;
|
|
94
|
+
ghStarOutcome?: "yes" | "unknown";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function harness(options: HarnessOptions = {}) {
|
|
98
|
+
const handlers = new Map<string, Set<(event: any, ctx: ExtensionContext) => unknown>>();
|
|
99
|
+
const on = (event: string, handler: (event: any, ctx: ExtensionContext) => unknown) => {
|
|
100
|
+
if (!handlers.has(event)) handlers.set(event, new Set());
|
|
101
|
+
handlers.get(event)!.add(handler);
|
|
102
|
+
return () => handlers.get(event)!.delete(handler);
|
|
103
|
+
};
|
|
104
|
+
const pi = { on } as unknown as ExtensionAPI;
|
|
105
|
+
|
|
106
|
+
const statuses: Array<string | undefined> = [];
|
|
107
|
+
const notes: string[] = [];
|
|
108
|
+
let terminalHandler: ((data: string) => { consume?: boolean } | undefined) | undefined;
|
|
109
|
+
const theme = { fg: (color: string, text: string) => `<${color}>${text}</${color}>` };
|
|
110
|
+
let widget: OfferRow | undefined;
|
|
111
|
+
let renders = 0;
|
|
112
|
+
const tui = { requestRender: () => void renders++ };
|
|
113
|
+
const ctx = {
|
|
114
|
+
ui: {
|
|
115
|
+
theme,
|
|
116
|
+
setStatus: (_key: string, text: string | undefined) => statuses.push(text),
|
|
117
|
+
// The offer row: wide enough here that the offer text is never truncated.
|
|
118
|
+
setWidget: (_key: string, factory: ((tui: unknown, theme: unknown) => OfferRow) | undefined, options?: { placement?: string }) => {
|
|
119
|
+
widget?.dispose?.();
|
|
120
|
+
widget = factory?.(tui, theme);
|
|
121
|
+
if (widget) assert.equal(options?.placement, "belowEditor");
|
|
122
|
+
statuses.push(widget?.render(400).join("\n"));
|
|
123
|
+
},
|
|
124
|
+
notify: (message: string) => notes.push(message),
|
|
125
|
+
onTerminalInput: (handler: (data: string) => { consume?: boolean } | undefined) => {
|
|
126
|
+
terminalHandler = handler;
|
|
127
|
+
return () => {
|
|
128
|
+
terminalHandler = undefined;
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
} as unknown as ExtensionContext;
|
|
133
|
+
|
|
134
|
+
const written: Array<{ sent: number; dismissed: boolean }> = [];
|
|
135
|
+
let clock = 1_000_000;
|
|
136
|
+
const scheduled: Array<{ ms: number; fn: () => void; cancelled: boolean }> = [];
|
|
137
|
+
const schedule = (ms: number, fn: () => void) => {
|
|
138
|
+
const timer = { ms, fn, cancelled: false };
|
|
139
|
+
scheduled.push(timer);
|
|
140
|
+
return { cancel: () => void (timer.cancelled = true) };
|
|
141
|
+
};
|
|
142
|
+
const advance = (ms: number) => void (clock += ms);
|
|
143
|
+
|
|
144
|
+
const gh = { starred: 0, star: 0 };
|
|
145
|
+
const openedUrls: string[] = [];
|
|
146
|
+
const deps = {
|
|
147
|
+
configHome: "/unused",
|
|
148
|
+
readState: () => ({ state: (options.state ?? { schema: "gentle-shell.star-prompt/v1", sent: 0, dismissed: false }) as StarPromptState, unusable: options.unusable ?? false }),
|
|
149
|
+
writeState: options.writeState ?? ((_configHome: string, state: StarPromptState) => {
|
|
150
|
+
written.push(state);
|
|
151
|
+
}),
|
|
152
|
+
schedule,
|
|
153
|
+
now: () => clock,
|
|
154
|
+
ghStarred: () => {
|
|
155
|
+
gh.starred++;
|
|
156
|
+
return Promise.resolve("no" as const);
|
|
157
|
+
},
|
|
158
|
+
ghStar: () => {
|
|
159
|
+
gh.star++;
|
|
160
|
+
return Promise.resolve(options.ghStarOutcome ?? "yes");
|
|
161
|
+
},
|
|
162
|
+
openRepository: (url: string) => {
|
|
163
|
+
openedUrls.push(url);
|
|
164
|
+
return Promise.resolve({ opened: true });
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
createStarPromptExtension(pi, deps);
|
|
169
|
+
const fire = async (event: string, payload: Record<string, unknown> = {}) => {
|
|
170
|
+
for (const handler of handlers.get(event) ?? []) handler({ type: event, ...payload } as any, ctx);
|
|
171
|
+
await drain();
|
|
172
|
+
};
|
|
173
|
+
const send = (text: string) => fire("input", { text, source: "interactive" });
|
|
174
|
+
const key = (data: string) => terminalHandler?.(data);
|
|
175
|
+
|
|
176
|
+
return { fire, send, key, statuses, notes, written, scheduled, advance, gh, openedUrls, get terminalHandler() { return terminalHandler; }, get widget() { return widget; }, get renders() { return renders; } };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const stateWith = (sent: number, extra: Record<string, unknown> = {}) => ({ schema: "gentle-shell.star-prompt/v1", sent, dismissed: false, ...extra });
|
|
180
|
+
|
|
181
|
+
// ---------- extension ----------
|
|
182
|
+
|
|
183
|
+
test("extension: counts sent prompts and persists the counter", async () => {
|
|
184
|
+
const h = harness();
|
|
185
|
+
await h.send("one");
|
|
186
|
+
await h.send("two");
|
|
187
|
+
assert.equal(h.written.length, 2);
|
|
188
|
+
assert.equal(h.written[1].sent, 2);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test("extension: an unwritable counter disables asking (fail closed)", async () => {
|
|
192
|
+
const persistFailures = { count: 0 };
|
|
193
|
+
const h = harness({ writeState: () => {
|
|
194
|
+
persistFailures.count++;
|
|
195
|
+
throw new Error("EACCES");
|
|
196
|
+
} });
|
|
197
|
+
await h.send("one");
|
|
198
|
+
assert.equal(persistFailures.count, 1);
|
|
199
|
+
// Sent past the threshold; the next agent_end must not even schedule an idle wait.
|
|
200
|
+
for (let i = 0; i < 10; i++) await h.send(`spam-${i}`);
|
|
201
|
+
await h.fire("agent_end");
|
|
202
|
+
assert.equal(h.scheduled.filter((t) => t.ms === STAR_PROMPT_IDLE_MS).length, 0);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test("extension: no offer before the threshold; idle offer after the 5th prompt", async () => {
|
|
206
|
+
const h = harness({ state: stateWith(4) });
|
|
207
|
+
await h.fire("agent_end");
|
|
208
|
+
assert.equal(h.scheduled.length, 0);
|
|
209
|
+
|
|
210
|
+
await h.send("fifth");
|
|
211
|
+
await h.send("sixth");
|
|
212
|
+
await h.fire("agent_end");
|
|
213
|
+
assert.deepEqual(h.scheduled.map((t) => t.ms), [STAR_PROMPT_IDLE_MS]);
|
|
214
|
+
|
|
215
|
+
// Idle elapses with no activity: the footer shows the offer.
|
|
216
|
+
h.advance(STAR_PROMPT_IDLE_MS);
|
|
217
|
+
h.scheduled[0].fn();
|
|
218
|
+
assert.ok(h.statuses.some((text) => typeof text === "string" && text.includes("Ctrl+G")));
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("extension: activity during the idle wait re-arms and defers the offer", async () => {
|
|
222
|
+
const h = harness({ state: stateWith(9) });
|
|
223
|
+
await h.fire("agent_end");
|
|
224
|
+
h.advance(STAR_PROMPT_IDLE_MS - 1);
|
|
225
|
+
h.key("x"); // typing resets the idle clock; never consumed
|
|
226
|
+
assert.equal(h.scheduled.length, 2); // the stale wait was cancelled and a fresh one armed
|
|
227
|
+
h.advance(STAR_PROMPT_IDLE_MS - 2);
|
|
228
|
+
h.scheduled[1].fn();
|
|
229
|
+
assert.equal(h.statuses.some((text) => typeof text === "string"), false);
|
|
230
|
+
|
|
231
|
+
// Staying idle across the re-armed window finally shows the offer.
|
|
232
|
+
h.advance(2); // now - lastInputAt reaches exactly IDLE_MS
|
|
233
|
+
h.scheduled[2].fn();
|
|
234
|
+
assert.ok(h.statuses.some((text) => typeof text === "string" && text.includes("Ctrl+G")));
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test("extension: a second agent_end while an idle wait is pending schedules nothing new", async () => {
|
|
238
|
+
const h = harness({ state: stateWith(9) });
|
|
239
|
+
await h.fire("agent_end");
|
|
240
|
+
await h.fire("agent_end");
|
|
241
|
+
assert.equal(h.scheduled.filter((t) => t.ms === STAR_PROMPT_IDLE_MS).length, 1);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test("extension: Ctrl+G stars via gh, thanks, and dismisses forever", async () => {
|
|
245
|
+
const h = harness({ state: stateWith(9) });
|
|
246
|
+
await h.fire("agent_end");
|
|
247
|
+
h.advance(STAR_PROMPT_IDLE_MS);
|
|
248
|
+
h.scheduled[0].fn();
|
|
249
|
+
assert.equal(h.gh.starred, 1); // users who already starred are never asked
|
|
250
|
+
assert.equal(typeof h.statuses.at(-1), "string");
|
|
251
|
+
|
|
252
|
+
const consumed = h.key(STAR_CHORD);
|
|
253
|
+
assert.deepEqual(consumed, { consume: true });
|
|
254
|
+
assert.equal(h.gh.star, 1);
|
|
255
|
+
await drain(); // starNow resolves async
|
|
256
|
+
assert.ok(h.notes[0].includes("Thanks for the star"));
|
|
257
|
+
assert.equal(h.written.at(-1)?.dismissed, true);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test("extension: a state file from the removed directStar opt-in still stars through gh, never the browser", async () => {
|
|
261
|
+
const h = harness({ state: stateWith(9, { directStar: false }) });
|
|
262
|
+
await h.fire("agent_end");
|
|
263
|
+
h.advance(STAR_PROMPT_IDLE_MS);
|
|
264
|
+
h.scheduled[0].fn();
|
|
265
|
+
assert.equal(h.gh.starred, 1);
|
|
266
|
+
assert.deepEqual(h.key(STAR_CHORD), { consume: true });
|
|
267
|
+
assert.equal(h.gh.star, 1);
|
|
268
|
+
await drain();
|
|
269
|
+
assert.deepEqual(h.openedUrls, []);
|
|
270
|
+
assert.ok(h.notes[0].includes("Thanks for the star"));
|
|
271
|
+
assert.equal(h.written.at(-1)?.dismissed, true);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test("extension: the offer is painted in the theme's success green, like added lines in the changes view", async () => {
|
|
275
|
+
const h = harness({ state: stateWith(9) });
|
|
276
|
+
await h.fire("agent_end");
|
|
277
|
+
h.advance(STAR_PROMPT_IDLE_MS);
|
|
278
|
+
h.scheduled[0].fn();
|
|
279
|
+
const offer = h.statuses.at(-1);
|
|
280
|
+
assert.ok(typeof offer === "string" && offer.startsWith("<success>Enjoying Gentle Shell?") && offer.includes("never asks again</success>"));
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const mouse = (type: "move" | "click", x: number, button: "none" | "left" | "right" = type === "move" ? "none" : "left") =>
|
|
284
|
+
({ type, button, x, y: 0, screenX: x, screenY: 0, width: 400, height: 1, shift: false, alt: false, ctrl: false }) as never;
|
|
285
|
+
|
|
286
|
+
async function visibleOffer(state = stateWith(9)) {
|
|
287
|
+
const h = harness({ state });
|
|
288
|
+
await h.fire("agent_end");
|
|
289
|
+
h.advance(STAR_PROMPT_IDLE_MS);
|
|
290
|
+
h.scheduled[0].fn();
|
|
291
|
+
const row = h.widget!.render(400)[0]!;
|
|
292
|
+
const plain = row.replace(/<\/?[a-z]+>/g, "");
|
|
293
|
+
return { h, buttonX: plain.indexOf("[star]") };
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
test("extension: the offer row ends with a [star] button painted like the sidebar's clickable controls", async () => {
|
|
297
|
+
const { h, buttonX } = await visibleOffer();
|
|
298
|
+
assert.ok(buttonX > 0);
|
|
299
|
+
assert.match(h.widget!.render(400)[0]!, /<\/success> +<accent>\[star\]<\/accent>$/);
|
|
300
|
+
|
|
301
|
+
assert.deepEqual(h.widget!.handleMouse(mouse("move", buttonX + 2)), { handled: true, render: true });
|
|
302
|
+
assert.ok(h.widget!.render(400)[0]!.endsWith("<warning>[star]</warning>"), "hover uses the shared hover role");
|
|
303
|
+
assert.deepEqual(h.widget!.handleMouse(mouse("move", buttonX + 2)), { handled: true });
|
|
304
|
+
|
|
305
|
+
h.widget!.handleMouse(mouse("move", 3));
|
|
306
|
+
assert.ok(h.widget!.render(400)[0]!.endsWith("<accent>[star]</accent>"), "moving off the button clears the hover");
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
test("extension: a left click on [star] stars exactly like Ctrl+G and removes the button", async () => {
|
|
310
|
+
const { h, buttonX } = await visibleOffer({ ...DEFAULT_STAR_PROMPT_STATE, sent: 9 });
|
|
311
|
+
const row = h.widget!;
|
|
312
|
+
assert.equal(row.handleMouse(mouse("click", 3)), undefined, "the offer text is not the button");
|
|
313
|
+
assert.equal(row.handleMouse(mouse("click", buttonX, "right")), undefined);
|
|
314
|
+
assert.equal(h.gh.star, 0);
|
|
315
|
+
|
|
316
|
+
assert.deepEqual(row.handleMouse(mouse("click", buttonX)), { handled: true, render: true });
|
|
317
|
+
assert.equal(h.gh.star, 1);
|
|
318
|
+
assert.equal(h.widget, undefined);
|
|
319
|
+
assert.equal(h.statuses.at(-1), undefined);
|
|
320
|
+
await drain();
|
|
321
|
+
assert.deepEqual(h.openedUrls, []);
|
|
322
|
+
assert.ok(h.notes[0].includes("Thanks for the star"));
|
|
323
|
+
assert.equal(h.written.at(-1)?.dismissed, true);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
test("extension: the offer is responsive: the longest whole wording that fits, with [star] right-aligned", async () => {
|
|
327
|
+
const { h } = await visibleOffer();
|
|
328
|
+
const plain = (width: number) => h.widget!.render(width)[0]!.replace(/<\/?[a-z]+>/g, "");
|
|
329
|
+
const wording = (width: number) => plain(width).slice(0, -"[star]".length).trimEnd();
|
|
330
|
+
const cases: Array<[number, string]> = [
|
|
331
|
+
[400, "Enjoying Gentle Shell? Ctrl+G stars both Gentleman-Programming repos (github.com/Gentleman-Programming/gentle-shell and github.com/Gentleman-Programming/gentle-ai) on GitHub, Alt+D never asks again"],
|
|
332
|
+
[120, "Enjoying Gentle Shell? Ctrl+G stars gentle-shell and gentle-ai on GitHub, Alt+D never asks again"],
|
|
333
|
+
[90, "Enjoying Gentle Shell? Ctrl+G stars us on GitHub, Alt+D never asks again"],
|
|
334
|
+
[60, "Ctrl+G stars us on GitHub, Alt+D never asks again"],
|
|
335
|
+
[36, "Ctrl+G star, Alt+D dismiss"],
|
|
336
|
+
[20, "Ctrl+G star"],
|
|
337
|
+
[8, ""],
|
|
338
|
+
];
|
|
339
|
+
for (const [width, expected] of cases) {
|
|
340
|
+
assert.equal(wording(width), expected, `width ${width}`);
|
|
341
|
+
assert.equal(plain(width).length, width, `width ${width} fills the row exactly`);
|
|
342
|
+
assert.ok(plain(width).endsWith("[star]"), `width ${width} keeps the button at the right edge`);
|
|
343
|
+
assert.ok(!plain(width).includes("…"), `width ${width} never cuts a word`);
|
|
344
|
+
}
|
|
345
|
+
assert.ok(plain(4).length <= 4, "a row narrower than the button never overflows");
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
test("extension: the right-aligned [star] stays clickable at any width", async () => {
|
|
349
|
+
const { h } = await visibleOffer({ ...DEFAULT_STAR_PROMPT_STATE, sent: 9 });
|
|
350
|
+
h.widget!.render(60);
|
|
351
|
+
const click = { type: "click", button: "left", x: 60 - "[star]".length, y: 0, screenX: 54, screenY: 0, width: 60, height: 1, shift: false, alt: false, ctrl: false } as never;
|
|
352
|
+
assert.deepEqual(h.widget!.handleMouse(click), { handled: true, render: true });
|
|
353
|
+
assert.equal(h.gh.star, 1);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
test("extension: when gh cannot star, Ctrl+G falls back to opening both repos in the browser", async () => {
|
|
357
|
+
const h = harness({ state: stateWith(9), ghStarOutcome: "unknown" });
|
|
358
|
+
await h.fire("agent_end");
|
|
359
|
+
h.advance(STAR_PROMPT_IDLE_MS);
|
|
360
|
+
h.scheduled[0].fn();
|
|
361
|
+
const consumed = h.key(STAR_CHORD);
|
|
362
|
+
assert.deepEqual(consumed, { consume: true });
|
|
363
|
+
assert.equal(h.gh.star, 1);
|
|
364
|
+
await drain();
|
|
365
|
+
assert.deepEqual(h.notes, []);
|
|
366
|
+
// Both sibling repos open so the chord never dead-ends.
|
|
367
|
+
assert.deepEqual(h.openedUrls, [
|
|
368
|
+
"https://github.com/Gentleman-Programming/gentle-shell",
|
|
369
|
+
"https://github.com/Gentleman-Programming/gentle-ai",
|
|
370
|
+
]);
|
|
371
|
+
assert.equal(h.written.at(-1)?.dismissed, true);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
test("extension: Alt+D dismisses forever and the offer never returns", async () => {
|
|
375
|
+
const h = harness({ state: stateWith(9) });
|
|
376
|
+
await h.fire("agent_end");
|
|
377
|
+
h.advance(STAR_PROMPT_IDLE_MS);
|
|
378
|
+
h.scheduled[0].fn();
|
|
379
|
+
const consumed = h.key(DISMISS_CHORD);
|
|
380
|
+
assert.deepEqual(consumed, { consume: true });
|
|
381
|
+
assert.equal(h.written.at(-1)?.dismissed, true);
|
|
382
|
+
assert.ok(h.statuses.at(-1) === undefined);
|
|
383
|
+
|
|
384
|
+
await h.fire("agent_end");
|
|
385
|
+
assert.equal(h.scheduled.filter((t) => t.ms === STAR_PROMPT_IDLE_MS).length, 1); // no new wait
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
test("extension: an unanswered offer auto-hides and asks no more this session", async () => {
|
|
389
|
+
const h = harness({ state: stateWith(9) });
|
|
390
|
+
await h.fire("agent_end");
|
|
391
|
+
h.advance(STAR_PROMPT_IDLE_MS);
|
|
392
|
+
h.scheduled[0].fn();
|
|
393
|
+
const visibleTimers = h.scheduled.filter((t) => t.ms === STAR_PROMPT_VISIBLE_MS);
|
|
394
|
+
assert.equal(visibleTimers.length, 1);
|
|
395
|
+
h.advance(STAR_PROMPT_VISIBLE_MS);
|
|
396
|
+
visibleTimers[0].fn();
|
|
397
|
+
assert.ok(h.statuses.at(-1) === undefined);
|
|
398
|
+
|
|
399
|
+
await h.fire("agent_end");
|
|
400
|
+
assert.equal(h.scheduled.filter((t) => t.ms === STAR_PROMPT_IDLE_MS).length, 1);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
test("extension: chords are never consumed while the offer is hidden", () => {
|
|
404
|
+
const h = harness({ state: stateWith(9) });
|
|
405
|
+
assert.equal(h.key(STAR_CHORD), undefined);
|
|
406
|
+
assert.equal(h.key(DISMISS_CHORD), undefined);
|
|
407
|
+
assert.equal(h.gh.star, 0);
|
|
408
|
+
assert.deepEqual(h.openedUrls, []);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
test("extension: unusable state never offers", async () => {
|
|
412
|
+
const h = harness({ unusable: true, state: stateWith(50) });
|
|
413
|
+
await h.fire("agent_end");
|
|
414
|
+
assert.equal(h.scheduled.length, 0);
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
test("extension: already-starred skips the offer and marks dismissed", async () => {
|
|
418
|
+
const handlers = new Map<string, Set<(event: any, ctx: ExtensionContext) => unknown>>();
|
|
419
|
+
const pi = { on: (event: string, handler: (event: any, ctx: ExtensionContext) => unknown) => {
|
|
420
|
+
if (!handlers.has(event)) handlers.set(event, new Set());
|
|
421
|
+
handlers.get(event)!.add(handler);
|
|
422
|
+
return () => {};
|
|
423
|
+
} } as unknown as ExtensionAPI;
|
|
424
|
+
const ctx = {
|
|
425
|
+
ui: {
|
|
426
|
+
setStatus: () => {},
|
|
427
|
+
notify: () => {},
|
|
428
|
+
onTerminalInput: () => () => {},
|
|
429
|
+
},
|
|
430
|
+
} as unknown as ExtensionContext;
|
|
431
|
+
const written: Array<{ dismissed: boolean }> = [];
|
|
432
|
+
createStarPromptExtension(pi, {
|
|
433
|
+
configHome: "/unused",
|
|
434
|
+
readState: () => ({ state: stateWith(50) as StarPromptState, unusable: false }),
|
|
435
|
+
writeState: (_: string, state: { dismissed: boolean }) => written.push(state),
|
|
436
|
+
schedule: () => ({ cancel: () => {} }),
|
|
437
|
+
now: () => 0,
|
|
438
|
+
ghStarred: () => Promise.resolve("yes" as const),
|
|
439
|
+
ghStar: () => Promise.resolve("yes" as const),
|
|
440
|
+
openRepository: () => Promise.resolve({ opened: true }),
|
|
441
|
+
});
|
|
442
|
+
for (const handler of handlers.get("agent_end") ?? []) handler({ type: "agent_end" }, ctx);
|
|
443
|
+
await drain();
|
|
444
|
+
assert.equal(written.length, 1);
|
|
445
|
+
assert.equal(written[0].dismissed, true);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
test("lib: ghStarred classifies 404 as no and other failures as unknown", async () => {
|
|
449
|
+
const failWith = (stderr: string) => ((_command: string, _args: readonly string[], _opts: unknown, cb: (e: Error | undefined, _o: string, stderr: string) => void) => cb(new Error("failed"), "", stderr));
|
|
450
|
+
const notStarred = await ghStarred({ exec: failWith("HTTP 404") as never, repositories: ["x/y"] });
|
|
451
|
+
assert.equal(notStarred, "no");
|
|
452
|
+
const broken = await ghStarred({ exec: ((_command: string, _args: readonly string[], _opts: unknown, cb: (e: Error | undefined) => void) => cb(new Error("boom"))) as never, repositories: ["x/y"] });
|
|
453
|
+
assert.equal(broken, "unknown");
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
test("lib: a failed PUT, including HTTP 404, is never reported as starred", async () => {
|
|
457
|
+
const { ghStar } = await import("../lib/star-prompt.ts");
|
|
458
|
+
const failWith = (stderr: string) => ((_command: string, _args: readonly string[], _opts: unknown, cb: (e: Error | undefined, _o: string, stderr: string) => void) => cb(new Error("failed"), "", stderr));
|
|
459
|
+
// A 404 on PUT means the repository is missing or the token cannot star it: thanking would be a lie.
|
|
460
|
+
assert.equal(await ghStar({ exec: failWith("gh: Not Found (HTTP 404)") as never, repositories: ["x/y"] }), "unknown");
|
|
461
|
+
assert.equal(await ghStar({ exec: failWith("boom") as never, repositories: ["x/y"] }), "unknown");
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
test("lib: execFile's null error (exit 0) means starred, and a null error on PUT means starred", async () => {
|
|
465
|
+
// Real child_process passes error = null on success; that must not crash (found in TUI smoke).
|
|
466
|
+
const ok = ((_command: string, _args: readonly string[], _opts: unknown, cb: (e: Error | null, _o: string, _s: string) => void) => cb(null, "", "")) as never;
|
|
467
|
+
assert.equal(await ghStarred({ exec: ok, repositories: ["x/y"] }), "yes");
|
|
468
|
+
const { ghStar } = await import("../lib/star-prompt.ts");
|
|
469
|
+
assert.equal(await ghStar({ exec: ok, repositories: ["x/y"] }), "yes");
|
|
470
|
+
});
|
|
@@ -223,6 +223,16 @@ test("animation modes retain banner lifetime policy, final artwork and approxima
|
|
|
223
223
|
}
|
|
224
224
|
header!.dispose();
|
|
225
225
|
}
|
|
226
|
+
|
|
227
|
+
// Slow device: 5s wall-clock cap hits before animation reaches natural finish.
|
|
228
|
+
save("quality");
|
|
229
|
+
await start!({}, ctx); boot!();
|
|
230
|
+
for (let i = 0; i < 15; i++) await new Promise<void>((resolve) => setImmediate(resolve));
|
|
231
|
+
clock += 5100;
|
|
232
|
+
pulse!();
|
|
233
|
+
assert.equal(active, false, "clears interval on 5s timeout");
|
|
234
|
+
assert.equal(stripAnsi(header!.render(200).join("\n")), staticArt, "fast-forwards to complete static artwork on 5s timeout without frozen letters or sparkle");
|
|
235
|
+
header!.dispose();
|
|
226
236
|
} finally { shutdown!(); }
|
|
227
237
|
});
|
|
228
238
|
|
|
@@ -274,6 +284,8 @@ for (const showRose of [false, true]) for (const showTextLogo of [false, true])
|
|
|
274
284
|
if (width >= 160) {
|
|
275
285
|
assert.equal(/[\u2800-\u28ff]/.test(text), showRose);
|
|
276
286
|
assert.equal(/[▒▄▀█]/.test(text), showTextLogo);
|
|
287
|
+
} else if (width === 80 && showTextLogo) {
|
|
288
|
+
assert.match(text, /✿ Gentle Shell ✿/, "narrow terminal shows graceful fallback branding");
|
|
277
289
|
}
|
|
278
290
|
assert.match(lines.join("\n"), /\x1b\[38;2;85;170;205m/, "startup labels use the saved cyan palette");
|
|
279
291
|
}
|
|
@@ -290,7 +302,11 @@ for (const showRose of [false, true]) for (const showTextLogo of [false, true])
|
|
|
290
302
|
t.mock.timers.tick(150);
|
|
291
303
|
const minimal = stripAnsi(header!.render(80).join("\n"));
|
|
292
304
|
assert.doesNotMatch(minimal, /[\u2800-\u28ff]/);
|
|
293
|
-
assert.equal(
|
|
305
|
+
assert.equal(/✿ Gentle Shell ✿/.test(minimal), showTextLogo);
|
|
306
|
+
if (showTextLogo) {
|
|
307
|
+
const wideMinimal = stripAnsi(header!.render(160).join("\n"));
|
|
308
|
+
assert.equal(/[▒▄▀█]/.test(wideMinimal), true);
|
|
309
|
+
}
|
|
294
310
|
assert.deepEqual(writes, [], "Pi owns stdout during startup and resize");
|
|
295
311
|
} finally {
|
|
296
312
|
shutdown!();
|
|
@@ -511,3 +527,43 @@ for (const kind of ["unset", "empty", "bundled"] as const) {
|
|
|
511
527
|
assert.deepEqual(await readBannerConfig(), { showRose: false, showTextLogo: true, color: "cyan" });
|
|
512
528
|
});
|
|
513
529
|
}
|
|
530
|
+
|
|
531
|
+
test("the banner ends with a /gentle:guide reminder on every start, only when the command exists", async (t) => {
|
|
532
|
+
const home = mkdtempSync(join(tmpdir(), "gp-banner-guide-"));
|
|
533
|
+
writeFileSync(join(home, "animations.json"), '{"schema":"gentle-pi.animations/v1","policy":"potato"}');
|
|
534
|
+
const previousHome = process.env.GENTLE_PI_CONFIG_HOME;
|
|
535
|
+
process.env.GENTLE_PI_CONFIG_HOME = home;
|
|
536
|
+
t.after(() => {
|
|
537
|
+
if (previousHome === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
538
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previousHome;
|
|
539
|
+
rmSync(home, { recursive: true, force: true });
|
|
540
|
+
});
|
|
541
|
+
t.mock.timers.enable({ apis: ["setTimeout", "setInterval", "Date"] });
|
|
542
|
+
t.mock.method(fs, "readFile", async () => JSON.stringify({ showRose: true, showTextLogo: true, color: "pink" }));
|
|
543
|
+
syncBuiltinESMExports();
|
|
544
|
+
t.after(() => { t.mock.restoreAll(); syncBuiltinESMExports(); });
|
|
545
|
+
const argv = process.argv;
|
|
546
|
+
process.argv = ["node"];
|
|
547
|
+
t.after(() => { process.argv = argv; });
|
|
548
|
+
for (const [key, value] of [["rows", 40], ["columns", 160]] as const) {
|
|
549
|
+
const descriptor = Object.getOwnPropertyDescriptor(process.stdout, key);
|
|
550
|
+
Object.defineProperty(process.stdout, key, { configurable: true, writable: true, value });
|
|
551
|
+
t.after(() => descriptor ? Object.defineProperty(process.stdout, key, descriptor) : Reflect.deleteProperty(process.stdout, key));
|
|
552
|
+
}
|
|
553
|
+
const render = async (commands: { name: string }[]) => {
|
|
554
|
+
let start: Function;
|
|
555
|
+
let header: { render(width: number): string[]; dispose(): void };
|
|
556
|
+
startup({ on: (name: string, fn: Function) => { if (name === "session_start") start = fn; }, registerCommand() {}, getCommands: () => commands, getAllTools: () => [] } as unknown as ExtensionAPI);
|
|
557
|
+
await start!({}, { hasUI: true, cwd: "/fixture", ui: { setHeader: (factory: Function) => {
|
|
558
|
+
header = factory({ requestRender() {} }, { fg: (_role: string, text: string) => text });
|
|
559
|
+
} } });
|
|
560
|
+
t.mock.timers.tick(50);
|
|
561
|
+
const lines = header!.render(160).map(stripAnsi);
|
|
562
|
+
header!.dispose();
|
|
563
|
+
return lines;
|
|
564
|
+
};
|
|
565
|
+
const withGuide = await render([{ name: "gentle:guide" }]);
|
|
566
|
+
assert.equal(withGuide.filter((line) => line.trim() !== "").at(-1)?.trim(), "Tip: run /gentle:guide for a guided tour of Gentle Shell");
|
|
567
|
+
assert.equal((await render([{ name: "gentle:guide" }])).filter((line) => line.includes("/gentle:guide")).length, 1, "shown again on the next start, once");
|
|
568
|
+
assert.equal((await render([])).some((line) => line.includes("/gentle:guide")), false);
|
|
569
|
+
});
|
|
@@ -63,7 +63,7 @@ test("AC3: small work runs its checks inline and keeps test-first", () => {
|
|
|
63
63
|
for (const clause of [
|
|
64
64
|
"run the focused test and the suite inline in one command",
|
|
65
65
|
"observe RED inline before the fix",
|
|
66
|
-
"No explore, worker, or verifier",
|
|
66
|
+
"No explore, worker, or verifier unless a trigger fires",
|
|
67
67
|
"no feature document, mirror, or commits unless the user asks",
|
|
68
68
|
"needs no lazy asset",
|
|
69
69
|
]) {
|
|
@@ -294,6 +294,50 @@ test("T6: each delegation module carries its own clauses and names the modules i
|
|
|
294
294
|
assert.ok(!delegation.includes("precedence in rule 2"), "cross-references name rules, not ambiguous numbers");
|
|
295
295
|
});
|
|
296
296
|
|
|
297
|
+
// These assertions exercise the shipped core rendering, not model behavior.
|
|
298
|
+
const renderedCore = __testing.renderOrchestratorPrompt(join(REPO_ROOT, "assets"));
|
|
299
|
+
|
|
300
|
+
test("S1: a fired evidence trigger overrides an initial size classification", () => {
|
|
301
|
+
assert.match(renderedCore, /A fired trigger overrides initial size/);
|
|
302
|
+
assert.match(renderedCore, /stop and delegate/);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
test("S1: iterative discovery reassesses cumulative evidence without resetting batches", () => {
|
|
306
|
+
assert.match(renderedCore, /Reassess cumulative discovery each batch, never reset/);
|
|
307
|
+
assert.match(renderedCore, /more than one read batch or >~5 sequential lookups/);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test("S1: task size uses only small and large", () => {
|
|
311
|
+
const size = sectionOf(renderedCore, "## Task Size");
|
|
312
|
+
assert.match(size, /Task size: small or large/);
|
|
313
|
+
assert.doesNotMatch(size, /small-ish/);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test("S1: read-only authorization does not exempt exploration from the budget", () => {
|
|
317
|
+
assert.match(renderedCore, /including read-only: it limits mutation, not routing/);
|
|
318
|
+
assert.match(renderedCore, /Exempt only preparation for an understood inline write, not discovery/);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
test("S1: routing guidance mirrors cumulative precedence and the narrow preparation exception", () => {
|
|
322
|
+
const card = read("assets/orchestrator-delegation.md");
|
|
323
|
+
for (const clause of [
|
|
324
|
+
"Reassess cumulative discovery after each batch; never reset it",
|
|
325
|
+
"the trigger overrides initial size, including for read-only work",
|
|
326
|
+
"Preparation for an already understood inline write stays inline, not further discovery",
|
|
327
|
+
]) assert.ok(card.includes(clause), `delegation card is missing: ${clause}`);
|
|
328
|
+
assert.ok(skill.includes("A fired trigger overrides initial task size; read-only restricts mutation, not exploration"));
|
|
329
|
+
assert.ok(read("docs/readme-reference.md").includes("a fired evidence-budget trigger takes precedence over initial size"));
|
|
330
|
+
assert.match(sectionOf(core, "## Task Size"), /No explore, worker, or verifier unless a trigger fires/);
|
|
331
|
+
assert.doesNotMatch(sectionOf(core, "## Mechanisms"), /when in doubt work inline(?! within the evidence budget)/);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
test("S1: a known small targeted request within budget keeps the inline path", () => {
|
|
335
|
+
const size = sectionOf(renderedCore, "## Task Size");
|
|
336
|
+
assert.match(size, /Small path: inline/);
|
|
337
|
+
assert.match(size, /one bounded read batch \(at most 3 calls, ~10k tokens\)/);
|
|
338
|
+
assert.match(size, /run the focused test and the suite inline in one command/);
|
|
339
|
+
});
|
|
340
|
+
|
|
297
341
|
test("T6: the readme no longer sends every suite to a verifier or tracks 'substantial' work", () => {
|
|
298
342
|
const readme = read("docs/readme-reference.md");
|
|
299
343
|
assert.ok(!readme.includes("send full suites and builds to a verifier"), "readme still delegates every suite");
|