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
|
@@ -20,6 +20,8 @@ export interface VisualVisibility {
|
|
|
20
20
|
modelDetails: boolean;
|
|
21
21
|
/** High-context warning notice; independent from audio notifications. */
|
|
22
22
|
contextWarning: boolean;
|
|
23
|
+
/** Session statistics in the Status rail (spend, tokens, cache, tools, per model); the Power user preset turns it on. */
|
|
24
|
+
stats: boolean;
|
|
23
25
|
}
|
|
24
26
|
export interface VisualSettings {
|
|
25
27
|
statusPlacement: StatusPlacement;
|
|
@@ -31,12 +33,45 @@ export const DEFAULT_VISUAL_SETTINGS: VisualSettings = {
|
|
|
31
33
|
statusPlacement: STATUS_PLACEMENT.AUTO,
|
|
32
34
|
headerPlacement: HEADER_PLACEMENT.TOP,
|
|
33
35
|
density: DENSITY.COMFORTABLE,
|
|
34
|
-
visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true },
|
|
36
|
+
visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: false },
|
|
35
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Presets bundle the density and visibility switches (design/shell-rework/inventory.md):
|
|
40
|
+
* Light is the minimal edition: Status at the bottom (no rail) and priority 1
|
|
41
|
+
* only (model, context, agent questions, review); Neutral is the default;
|
|
42
|
+
* Power user adds session Stats at Neutral's spacing. They keep the header
|
|
43
|
+
* placement; the active preset is whichever bundle the current settings match.
|
|
44
|
+
*/
|
|
45
|
+
export const VISUAL_PRESET = { LIGHT: "light", NEUTRAL: "neutral", POWER_USER: "power-user" } as const;
|
|
46
|
+
export type VisualPreset = (typeof VISUAL_PRESET)[keyof typeof VISUAL_PRESET];
|
|
47
|
+
const PRESET_BUNDLES: Record<VisualPreset, Pick<VisualSettings, "density" | "visibility">> = {
|
|
48
|
+
[VISUAL_PRESET.LIGHT]: { density: DENSITY.MINIMAL, visibility: { changes: false, rdd: true, agents: true, todo: false, usageCost: true, modelDetails: true, contextWarning: true, stats: false } },
|
|
49
|
+
[VISUAL_PRESET.NEUTRAL]: { density: DEFAULT_VISUAL_SETTINGS.density, visibility: { ...DEFAULT_VISUAL_SETTINGS.visibility } },
|
|
50
|
+
// Same spacing as Neutral: what Power user adds is content (Stats), not density.
|
|
51
|
+
[VISUAL_PRESET.POWER_USER]: { density: DEFAULT_VISUAL_SETTINGS.density, visibility: { changes: true, rdd: true, agents: true, todo: true, usageCost: true, modelDetails: true, contextWarning: true, stats: true } },
|
|
52
|
+
};
|
|
53
|
+
export function applyVisualPreset(settings: VisualSettings, preset: VisualPreset): VisualSettings {
|
|
54
|
+
const bundle = PRESET_BUNDLES[preset];
|
|
55
|
+
// Light is the minimal edition without the rail (Status at the bottom);
|
|
56
|
+
// leaving it brings the rail back, and the other presets keep any placement.
|
|
57
|
+
const leavingLight = visualPresetOf(settings) === VISUAL_PRESET.LIGHT;
|
|
58
|
+
const statusPlacement = preset === VISUAL_PRESET.LIGHT ? STATUS_PLACEMENT.BOTTOM
|
|
59
|
+
: leavingLight ? STATUS_PLACEMENT.AUTO : settings.statusPlacement;
|
|
60
|
+
return { ...settings, statusPlacement, density: bundle.density, visibility: { ...bundle.visibility } };
|
|
61
|
+
}
|
|
62
|
+
/** The preset the settings match, or undefined for a hand-tuned mix. */
|
|
63
|
+
export function visualPresetOf(settings: VisualSettings): VisualPreset | undefined {
|
|
64
|
+
return (Object.values(VISUAL_PRESET) as VisualPreset[]).find((preset) => {
|
|
65
|
+
const bundle = PRESET_BUNDLES[preset];
|
|
66
|
+
if ((settings.statusPlacement === STATUS_PLACEMENT.BOTTOM) !== (preset === VISUAL_PRESET.LIGHT)) return false;
|
|
67
|
+
return bundle.density === settings.density && (Object.keys(bundle.visibility) as (keyof VisualVisibility)[]).every((key) => bundle.visibility[key] === settings.visibility[key]);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
36
70
|
/** Sections row order; `rdd` follows `changes` as the RDD group follows Changes in the Status card. */
|
|
37
|
-
export const VISUAL_SECTION_KEYS = ["changes", "rdd", "agents", "todo", "usageCost", "modelDetails", "contextWarning"] as const satisfies readonly (keyof VisualVisibility)[];
|
|
38
|
-
/** Keys added after v1 shipped
|
|
39
|
-
const
|
|
71
|
+
export const VISUAL_SECTION_KEYS = ["changes", "rdd", "agents", "todo", "usageCost", "modelDetails", "contextWarning", "stats"] as const satisfies readonly (keyof VisualVisibility)[];
|
|
72
|
+
/** Keys added after v1 shipped, with the value a stored file that omits them loads as. */
|
|
73
|
+
const ADDED_SECTION_DEFAULTS: Partial<Record<keyof VisualVisibility, boolean>> = { rdd: true, contextWarning: true, stats: false };
|
|
74
|
+
const ADDED_SECTION_KEYS = Object.keys(ADDED_SECTION_DEFAULTS) as (keyof VisualVisibility)[];
|
|
40
75
|
const BASE_SECTION_KEYS = VISUAL_SECTION_KEYS.filter((key) => !ADDED_SECTION_KEYS.includes(key));
|
|
41
76
|
interface VisualOptions { gentlePiConfigHome?: string }
|
|
42
77
|
export interface VisualResolution {
|
|
@@ -69,7 +104,7 @@ export function isVisualSettings(value: unknown): value is VisualSettings {
|
|
|
69
104
|
/**
|
|
70
105
|
* Reader-side validation: accepts the current shape plus every historical one.
|
|
71
106
|
* Every key must be known, every base key present, and every present value a
|
|
72
|
-
* boolean; missing added keys (`rdd`, `contextWarning`
|
|
107
|
+
* boolean; missing added keys then take their default (`rdd`, `contextWarning` shown, `stats` hidden),
|
|
73
108
|
* while present values (including `rdd: false`) are preserved. Writers stay strict.
|
|
74
109
|
*/
|
|
75
110
|
export function normalizeVisualSettings(value: unknown): VisualSettings | undefined {
|
|
@@ -81,7 +116,7 @@ export function normalizeVisualSettings(value: unknown): VisualSettings | undefi
|
|
|
81
116
|
if (!Object.keys(visibility).every((key) => typeof visibility[key] === "boolean")) return undefined;
|
|
82
117
|
const candidate = keysMatch(visibility, VISUAL_SECTION_KEYS)
|
|
83
118
|
? value
|
|
84
|
-
: { ...value, visibility: Object.fromEntries(VISUAL_SECTION_KEYS.map((key) => [key, visibility[key] ?? true])) };
|
|
119
|
+
: { ...value, visibility: Object.fromEntries(VISUAL_SECTION_KEYS.map((key) => [key, visibility[key] ?? ADDED_SECTION_DEFAULTS[key] ?? true])) };
|
|
85
120
|
return isVisualSettings(candidate) ? candidate : undefined;
|
|
86
121
|
}
|
|
87
122
|
export function parseVisualSettingsFile(raw: string): VisualSettings | undefined {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sanitizeTerminalText } from "./terminal-theme.ts";
|
|
1
2
|
import { decodeKittyPrintable, isKeyRelease, matchesKey, Key, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
3
|
import type { VisualProfile } from "./visual-profiles.ts";
|
|
3
4
|
import { CARD_PADDING, renderPaletteCard, renderPaletteSelection } from "./command-palette.ts";
|
|
@@ -30,9 +31,12 @@ function dropLastGrapheme(text: string): string {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/** Category-aware footer; the audio card advertises audio keys, never the visual profiles pane. */
|
|
33
|
-
function footerHint(category: string, navOnly: boolean, previewLines: number, keyhint?: string): string {
|
|
34
|
+
function footerHint(category: string, navOnly: boolean, previewLines: number, keyhint?: string, setting = false, applyOnMove = true): string {
|
|
34
35
|
if (navOnly) return "↑/↓ categories · → open · Esc close";
|
|
36
|
+
if (setting && category === "Notifications") return keyhint ?? "←/→ choose · Enter apply · Tab panes · Esc close";
|
|
37
|
+
if (setting) return applyOnMove ? "↑/↓ settings · ←/→ change · Tab categories · p profiles · Esc close" : "←/→ choose · Enter apply · ↑/↓ settings · Tab panes · Esc close";
|
|
35
38
|
if (category === "Notifications") return keyhint ?? "Tab panes · Enter change · p test · Esc close";
|
|
39
|
+
if (category === "Keymaps") return keyhint ?? "Enter assign · Tab panes · Esc close";
|
|
36
40
|
return previewLines ? "←/→ or Tab panes · ↑/↓ move · Enter apply · p profiles · Esc close" : "Preview omitted · ←/→ panes · ↑/↓ move · Enter apply · Esc close";
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -42,13 +46,21 @@ function rowVisible(row: CustomizeRow): boolean {
|
|
|
42
46
|
try { return row.visible() !== false; } catch { return false; }
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
type LineEntry = { first: number; count: number; setting?: string };
|
|
50
|
+
|
|
51
|
+
export type CustomizeCategory = "Animations" | "Banner" | "Themes" | "Editor" | "History" | "Notifications" | "Layout" | "Cards" | "Sections" | "Keymaps" | "Profiles" | "Reset";
|
|
46
52
|
|
|
47
53
|
export interface CustomizeRow {
|
|
48
54
|
category?: CustomizeCategory;
|
|
49
55
|
label: string | (() => string);
|
|
50
|
-
/** Read-only representation of the highlighted choice, never an application. */
|
|
56
|
+
/** Read-only representation of the highlighted choice, never an application; `sample` may span lines. */
|
|
51
57
|
preview?: () => { title: string; sample: string };
|
|
58
|
+
/**
|
|
59
|
+
* One value of a setting. Consecutive rows of the same `setting` render as one
|
|
60
|
+
* line with their values inline. Layout choices apply on ←/→; set applyOnMove
|
|
61
|
+
* to false for preview-first, permission or privacy settings that need Enter.
|
|
62
|
+
*/
|
|
63
|
+
choice?: { setting: string; value: string; current(): boolean; hint?: string; applyOnMove?: boolean };
|
|
52
64
|
/** When present and it returns false the row is hidden from its category; an exception fails closed. */
|
|
53
65
|
visible?: () => boolean;
|
|
54
66
|
/** Audio-footer hint for this row; omitted rows use the category default (never advertising `f WAV`). */
|
|
@@ -64,6 +76,8 @@ export interface CustomizeRow {
|
|
|
64
76
|
export interface CustomizeInline {
|
|
65
77
|
/** Opens an inline field on the highlighted row; resolves on submit or undefined when cancelled. */
|
|
66
78
|
input(request: { prompt: string; value: string }): Promise<string | undefined>;
|
|
79
|
+
/** Waits for the next raw key press on the highlighted row; resolves undefined on Esc or when the prompt is not fully visible. */
|
|
80
|
+
capture(prompt: string): Promise<string | undefined>;
|
|
67
81
|
/** Opens an inline confirmation; resolves true only after an explicit, fully visible yes. */
|
|
68
82
|
confirm(message: string): Promise<boolean>;
|
|
69
83
|
/** Set once the owning card is disposed; a row must never persist after this. */
|
|
@@ -108,8 +122,10 @@ export class VisualCustomizeView {
|
|
|
108
122
|
private profileBusy = false;
|
|
109
123
|
private inlineInput?: { prompt: string; value: string; resolve: (value: string | undefined) => void; visible: boolean };
|
|
110
124
|
private inlineConfirm?: { message: string; resolve: (value: boolean) => void; visible: boolean };
|
|
125
|
+
private inlineCapture?: { prompt: string; resolve: (value: string | undefined) => void; visible: boolean };
|
|
111
126
|
private readonly inline: CustomizeInline = {
|
|
112
127
|
input: request => this.openInlineInput(request),
|
|
128
|
+
capture: prompt => this.openInlineCapture(prompt),
|
|
113
129
|
confirm: message => this.openInlineConfirm(message),
|
|
114
130
|
disposed: false,
|
|
115
131
|
};
|
|
@@ -122,6 +138,23 @@ export class VisualCustomizeView {
|
|
|
122
138
|
if (input) { this.inlineInput = undefined; input.resolve(undefined); }
|
|
123
139
|
const confirm = this.inlineConfirm;
|
|
124
140
|
if (confirm) { this.inlineConfirm = undefined; confirm.resolve(false); }
|
|
141
|
+
const capture = this.inlineCapture;
|
|
142
|
+
if (capture) { this.inlineCapture = undefined; capture.resolve(undefined); }
|
|
143
|
+
}
|
|
144
|
+
private openInlineCapture(prompt: string): Promise<string | undefined> {
|
|
145
|
+
if (this.closed) return Promise.resolve(undefined);
|
|
146
|
+
return new Promise(resolve => { this.inlineCapture = { prompt, resolve, visible: false }; });
|
|
147
|
+
}
|
|
148
|
+
/** The next key answers the capture; Esc, or a prompt the card could not show, cancels it. */
|
|
149
|
+
private handleInlineCapture(data: string): void {
|
|
150
|
+
const capture = this.inlineCapture!;
|
|
151
|
+
// Same guard as the inline confirmation: a resize that hides the prompt cancels it.
|
|
152
|
+
const area = this.previewCapacity();
|
|
153
|
+
capture.visible = area !== undefined && !area.navOnly && area.lines > 0
|
|
154
|
+
&& this.wrapInline(`${capture.prompt} · Esc cancel`, area.inner, area.lines) !== undefined;
|
|
155
|
+
this.inlineCapture = undefined;
|
|
156
|
+
capture.resolve(matchesKey(data, Key.escape) || !capture.visible ? undefined : data);
|
|
157
|
+
this.options.requestRender();
|
|
125
158
|
}
|
|
126
159
|
private openInlineInput(request: { prompt: string; value: string }): Promise<string | undefined> {
|
|
127
160
|
if (this.closed) return Promise.resolve(undefined);
|
|
@@ -183,7 +216,8 @@ export class VisualCustomizeView {
|
|
|
183
216
|
if (!matchesKey(data, Key.enter)) field.value = appendInput(field.value, data.slice(0, -1));
|
|
184
217
|
// Guard against a resize that hides the field before this Enter: an unseen value never submits.
|
|
185
218
|
const area = this.previewCapacity();
|
|
186
|
-
field.visible = area !== undefined && !area.navOnly
|
|
219
|
+
field.visible = area !== undefined && !area.navOnly
|
|
220
|
+
&& this.wrapInline(`${field.prompt}: ${field.value}▏`, area.inner, area.lines) !== undefined;
|
|
187
221
|
if (field.visible) { this.inlineInput = undefined; field.resolve(field.value); }
|
|
188
222
|
} else if (matchesKey(data, Key.backspace) || data === "\x7f") field.value = dropLastGrapheme(field.value);
|
|
189
223
|
else { const text = decodeKittyPrintable(data) ?? data; if (safeText(text)) field.value = appendInput(field.value, text); }
|
|
@@ -302,10 +336,61 @@ export class VisualCustomizeView {
|
|
|
302
336
|
return this.options.rows.filter(row => (row.category ?? "Settings") === this.categories[this.categoryIndex] && rowVisible(row));
|
|
303
337
|
}
|
|
304
338
|
|
|
339
|
+
/** The category's lines: a plain row, or every consecutive choice of one setting. */
|
|
340
|
+
private lineEntries(rows: readonly CustomizeRow[]): LineEntry[] {
|
|
341
|
+
const entries: LineEntry[] = [];
|
|
342
|
+
rows.forEach((row, index) => {
|
|
343
|
+
const last = entries.at(-1);
|
|
344
|
+
if (row.choice && last?.setting === row.choice.setting && last.first + last.count === index) last.count++;
|
|
345
|
+
else entries.push({ first: index, count: 1, setting: row.choice?.setting });
|
|
346
|
+
});
|
|
347
|
+
return entries;
|
|
348
|
+
}
|
|
349
|
+
private lineOf(entries: readonly LineEntry[], index: number): number {
|
|
350
|
+
return Math.max(0, entries.findIndex(entry => index >= entry.first && index < entry.first + entry.count));
|
|
351
|
+
}
|
|
352
|
+
/** A setting line is entered on its current value. */
|
|
353
|
+
private landOn(rows: readonly CustomizeRow[], entry: LineEntry | undefined): number {
|
|
354
|
+
if (!entry) return 0;
|
|
355
|
+
if (!entry.setting) return entry.first;
|
|
356
|
+
for (let i = entry.first; i < entry.first + entry.count; i++) {
|
|
357
|
+
try { if (rows[i]!.choice!.current()) return i; } catch { /* An unreadable value lands on the first choice. */ }
|
|
358
|
+
}
|
|
359
|
+
return entry.first;
|
|
360
|
+
}
|
|
361
|
+
private enterControls(): void {
|
|
362
|
+
this.pane = "controls";
|
|
363
|
+
const category = this.categories[this.categoryIndex]!;
|
|
364
|
+
const rows = this.categoryRows();
|
|
365
|
+
const entries = this.lineEntries(rows);
|
|
366
|
+
this.controls.set(category, this.landOn(rows, entries[this.lineOf(entries, Math.min(this.controls.get(category) ?? 0, Math.max(0, rows.length - 1)))]));
|
|
367
|
+
}
|
|
368
|
+
/** The last render showed the controls (not the "Enlarge terminal" fallback), so a key may apply one. */
|
|
369
|
+
private controlsShown(): boolean {
|
|
370
|
+
return this.mainWidth !== undefined && this.mainWidth >= CARD_PADDING + 3 && (this.options.rowsAvailable?.() ?? 24) >= 4;
|
|
371
|
+
}
|
|
372
|
+
/** Moves the selection to the first row whose label contains `label`, without applying it. */
|
|
373
|
+
focus(label: string): boolean {
|
|
374
|
+
const previous = this.categoryIndex;
|
|
375
|
+
for (let index = 0; index < this.categories.length; index++) {
|
|
376
|
+
this.categoryIndex = index;
|
|
377
|
+
const found = this.categoryRows().findIndex(row => (typeof row.label === "function" ? row.label() : row.label).includes(label));
|
|
378
|
+
if (found >= 0) {
|
|
379
|
+
this.pane = "controls";
|
|
380
|
+
this.controls.set(this.categories[index]!, found);
|
|
381
|
+
this.options.requestRender();
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
this.categoryIndex = previous;
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
|
|
305
389
|
handleInput(data: string): void {
|
|
306
390
|
if (this.closed || isKeyRelease(data)) return;
|
|
307
391
|
if (this.inlineInput) { this.handleInlineInput(data); return; }
|
|
308
392
|
if (this.inlineConfirm) { this.handleInlineConfirm(data); return; }
|
|
393
|
+
if (this.inlineCapture) { this.handleInlineCapture(data); return; }
|
|
309
394
|
if (this.profileOpen && this.options.profiles) { this.handleProfiles(data); return; }
|
|
310
395
|
if (matchesKey(data, Key.escape)) { this.dispose(); this.options.onClose(); return; }
|
|
311
396
|
const rows = this.categoryRows();
|
|
@@ -334,23 +419,58 @@ export class VisualCustomizeView {
|
|
|
334
419
|
if (matchesKey(data, "p") && this.pane === "controls" && (this.categories[this.categoryIndex] ?? "Settings") === "Notifications") { this.options.requestRender(); return; }
|
|
335
420
|
if (this.options.profiles && matchesKey(data, "p")) { this.openProfiles(); return; }
|
|
336
421
|
if (!length) return;
|
|
337
|
-
|
|
338
|
-
|
|
422
|
+
const entries = this.lineEntries(rows);
|
|
423
|
+
const line = this.lineOf(entries, this.selected);
|
|
424
|
+
const entry = entries[line];
|
|
425
|
+
const category = this.categories[this.categoryIndex]!;
|
|
426
|
+
// Walk inline values; live choices apply immediately, deferred choices wait for Enter.
|
|
427
|
+
// Moving left past the first value returns to the categories.
|
|
428
|
+
const step = this.pane === "controls" && entry?.setting ? matchesKey(data, Key.left) ? -1 : matchesKey(data, Key.right) ? 1 : 0 : 0;
|
|
429
|
+
if (step === -1 && this.selected === entry!.first) this.pane = "categories";
|
|
430
|
+
else if (step) {
|
|
431
|
+
const next = this.selected + step;
|
|
432
|
+
// Same guard as Enter: never apply a value the card is too small to show.
|
|
433
|
+
if (next >= entry!.first && next < entry!.first + entry!.count && !this.busy && this.controlsShown()) {
|
|
434
|
+
this.controls.set(category, next);
|
|
435
|
+
if (rows[next]!.choice?.applyOnMove !== false) this.withBusy(() => rows[next]!.action(this.inline));
|
|
436
|
+
}
|
|
437
|
+
} else if (matchesKey(data, Key.left) || matchesKey(data, Key.tab) && this.pane === "controls") this.pane = "categories";
|
|
438
|
+
else if (matchesKey(data, Key.right) || matchesKey(data, Key.tab) && this.pane === "categories") this.enterControls();
|
|
339
439
|
else if (matchesKey(data, Key.up) || matchesKey(data, "k")) {
|
|
340
440
|
if (this.pane === "categories") this.categoryIndex = (this.categoryIndex + length - 1) % length;
|
|
341
|
-
else this.controls.set(this.
|
|
441
|
+
else this.controls.set(category, this.landOn(rows, entries[(line + entries.length - 1) % entries.length]));
|
|
342
442
|
} else if (matchesKey(data, Key.down) || matchesKey(data, "j")) {
|
|
343
443
|
if (this.pane === "categories") this.categoryIndex = (this.categoryIndex + 1) % length;
|
|
344
|
-
else this.controls.set(this.
|
|
345
|
-
} else if ((matchesKey(data, Key.enter) || matchesKey(data, Key.space)) && this.pane === "categories") this.
|
|
346
|
-
else if ((matchesKey(data, Key.enter) || matchesKey(data, Key.space)) && !this.busy &&
|
|
347
|
-
this.mainWidth !== undefined && this.mainWidth >= CARD_PADDING + 3 &&
|
|
348
|
-
(this.options.rowsAvailable?.() ?? 24) >= 4 && rows[this.selected]) {
|
|
444
|
+
else this.controls.set(category, this.landOn(rows, entries[(line + 1) % entries.length]));
|
|
445
|
+
} else if ((matchesKey(data, Key.enter) || matchesKey(data, Key.space)) && this.pane === "categories") this.enterControls();
|
|
446
|
+
else if ((matchesKey(data, Key.enter) || matchesKey(data, Key.space)) && !this.busy && this.controlsShown() && rows[this.selected]) {
|
|
349
447
|
this.withBusy(() => rows[this.selected]!.action(this.inline));
|
|
350
448
|
}
|
|
351
449
|
this.options.requestRender();
|
|
352
450
|
}
|
|
353
451
|
|
|
452
|
+
/** One setting with its values inline (● current, ○ other); too wide, only the selected value with arrows. */
|
|
453
|
+
private renderSettingLine(rows: readonly CustomizeRow[], entry: LineEntry, width: number, nameWidth: number, focused: boolean, theme: CustomizeViewOptions["theme"]): string {
|
|
454
|
+
const choices = rows.slice(entry.first, entry.first + entry.count).map(row => row.choice!);
|
|
455
|
+
const isCurrent = (choice: NonNullable<CustomizeRow["choice"]>) => { try { return choice.current(); } catch { return false; } };
|
|
456
|
+
const name = sanitizeTerminalText(entry.setting!);
|
|
457
|
+
const lead = `${name}${" ".repeat(Math.max(0, nameWidth - visibleWidth(name)))} `;
|
|
458
|
+
const shown = focused ? rows[this.selected]?.choice ?? choices[0]! : choices.find(isCurrent) ?? choices[0]!;
|
|
459
|
+
// ● marks the current value; on the focused line › marks the cursor when it is elsewhere.
|
|
460
|
+
const mark = (choice: NonNullable<CustomizeRow["choice"]>) => {
|
|
461
|
+
const cursor = focused && choice === shown && !isCurrent(choice);
|
|
462
|
+
const text = `${isCurrent(choice) ? "●" : cursor ? "›" : "○"} ${sanitizeTerminalText(choice.value)}`;
|
|
463
|
+
return theme.fg(isCurrent(choice) || cursor ? "accent" : "muted", text);
|
|
464
|
+
};
|
|
465
|
+
let body = choices.map(mark).join(" ");
|
|
466
|
+
if (2 + visibleWidth(lead) + visibleWidth(body) > width) {
|
|
467
|
+
body = `${theme.fg("accent", `‹ ${sanitizeTerminalText(shown.value)} ›`)} ${theme.fg("muted", `${choices.indexOf(shown) + 1}/${choices.length}`)}`;
|
|
468
|
+
}
|
|
469
|
+
const text = truncateToWidth(`${focused ? theme.fg("accent", "▸ ") : " "}${theme.fg(focused ? "text" : "muted", lead)}${body}`, width, "…");
|
|
470
|
+
const padded = text + " ".repeat(Math.max(0, width - visibleWidth(text)));
|
|
471
|
+
return focused && theme.bg ? theme.bg("selectedBg", padded) : padded;
|
|
472
|
+
}
|
|
473
|
+
|
|
354
474
|
render(width: number): string[] {
|
|
355
475
|
if (this.profileOpen && this.options.profiles) {
|
|
356
476
|
if (width <= 0) { this.confirmationVisible = false; return []; }
|
|
@@ -371,15 +491,19 @@ export class VisualCustomizeView {
|
|
|
371
491
|
const navOnly = narrow && this.pane === "categories" && this.categories.length > 1;
|
|
372
492
|
const leftWidth = narrow ? 0 : Math.min(20, Math.max(14, Math.floor(inner * 0.28)));
|
|
373
493
|
const rightWidth = inner - leftWidth - (leftWidth ? 3 : 0);
|
|
374
|
-
const previewLines = height >= 11 ? 3 : height >= 8 ? 1 : 0;
|
|
494
|
+
const previewLines = height >= 18 ? 6 : height >= 11 ? 3 : height >= 8 ? 1 : 0;
|
|
375
495
|
const showHeading = height >= 6;
|
|
376
496
|
const showTopGap = height >= 12;
|
|
377
497
|
const showBottomGap = height >= 9;
|
|
378
498
|
const chrome = 1 + Number(showHeading) * 2 + Number(showTopGap) + Number(showBottomGap);
|
|
379
499
|
const contentHeight = Math.max(1, height - 2 - chrome - previewLines);
|
|
380
500
|
this.selected = Math.min(this.controls.get(category) ?? 0, Math.max(0, rows.length - 1));
|
|
381
|
-
const
|
|
382
|
-
const
|
|
501
|
+
const entries = this.lineEntries(rows);
|
|
502
|
+
const line = this.lineOf(entries, this.selected);
|
|
503
|
+
const focusedSetting = this.pane === "controls" && entries[line]?.setting ? rows[this.selected]?.choice : undefined;
|
|
504
|
+
const position = navOnly ? this.categoryIndex : line;
|
|
505
|
+
const listLength = navOnly ? this.categories.length : entries.length;
|
|
506
|
+
const nameWidth = Math.min(20, Math.max(0, ...entries.map(entry => entry.setting ? visibleWidth(entry.setting) : 0)));
|
|
383
507
|
const start = Math.min(Math.max(0, position - contentHeight + 1), Math.max(0, listLength - contentHeight));
|
|
384
508
|
const navStart = Math.min(Math.max(0, this.categoryIndex - contentHeight + 1), Math.max(0, this.categories.length - contentHeight));
|
|
385
509
|
const paint = (text: string, size: number, role = "text") => {
|
|
@@ -387,7 +511,7 @@ export class VisualCustomizeView {
|
|
|
387
511
|
return this.options.theme.fg(role, clipped + " ".repeat(Math.max(0, size - visibleWidth(clipped))));
|
|
388
512
|
};
|
|
389
513
|
const join = (left: string, right: string) => leftWidth ? `${left}${" ".repeat(Math.max(0, leftWidth - visibleWidth(stripAnsi(left))))} ${paint("│", 1, "border")} ${right}` : right;
|
|
390
|
-
const heading = navOnly ? "Categories · choose a category →" : `${category} · ${rows.length ? `${
|
|
514
|
+
const heading = navOnly ? "Categories · choose a category →" : `${category} · ${rows.length ? `${line + 1}/${entries.length}` : "empty"}`;
|
|
391
515
|
const lines: string[] = [paint(this.title(), inner, "accent")];
|
|
392
516
|
// Commands uses a header, grouped section labels, whitespace and a footer.
|
|
393
517
|
if (showHeading) lines.push(join(leftWidth ? paint("CATEGORIES", leftWidth, "accent") : "", paint(heading, rightWidth, "accent")));
|
|
@@ -395,9 +519,12 @@ export class VisualCustomizeView {
|
|
|
395
519
|
for (let i = 0; i < contentHeight; i++) {
|
|
396
520
|
const nav = this.categories[navStart + i];
|
|
397
521
|
const left = nav ? renderPaletteSelection(nav, leftWidth, navStart + i === this.categoryIndex, this.pane === "categories" ? this.options.theme : { fg: this.options.theme.fg.bind(this.options.theme) }) : "";
|
|
398
|
-
const
|
|
522
|
+
const entry = navOnly ? undefined : entries[start + i];
|
|
523
|
+
const row = entry ? rows[entry.first] : undefined;
|
|
399
524
|
const item = navOnly ? this.categories[start + i] : row ? typeof row.label === "function" ? row.label() : row.label : undefined;
|
|
400
|
-
const
|
|
525
|
+
const rowTheme = navOnly || this.pane === "controls" ? this.options.theme : { fg: this.options.theme.fg.bind(this.options.theme) };
|
|
526
|
+
const right = entry?.setting ? this.renderSettingLine(rows, entry, rightWidth, nameWidth, start + i === position, rowTheme)
|
|
527
|
+
: item ? renderPaletteSelection(item, rightWidth, start + i === position, rowTheme) : rows.length ? "" : paint("No settings available", rightWidth, "muted");
|
|
401
528
|
lines.push(join(left, right));
|
|
402
529
|
}
|
|
403
530
|
if (this.inlineConfirm) {
|
|
@@ -405,22 +532,33 @@ export class VisualCustomizeView {
|
|
|
405
532
|
this.inlineConfirm.visible = shows !== undefined;
|
|
406
533
|
if (shows) for (const line of shows) lines.push(paint(line, inner, "warning"));
|
|
407
534
|
else if (previewLines > 0) lines.push(paint("Confirmation needs more space · enlarge terminal", inner, "warning"));
|
|
535
|
+
} else if (this.inlineCapture) {
|
|
536
|
+
const shows = !navOnly && previewLines > 0 ? this.wrapInline(`${this.inlineCapture.prompt} · Esc cancel`, inner, previewLines) : undefined;
|
|
537
|
+
this.inlineCapture.visible = shows !== undefined;
|
|
538
|
+
if (shows) for (const line of shows) lines.push(paint(line, inner, "accent"));
|
|
539
|
+
else if (previewLines > 0) lines.push(paint("Key capture needs more space · enlarge terminal", inner, "warning"));
|
|
408
540
|
} else if (this.inlineInput) {
|
|
409
541
|
const field = `${this.inlineInput.prompt}: ${this.inlineInput.value}▏`;
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
542
|
+
const shows = !navOnly ? this.wrapInline(field, inner, previewLines) : undefined;
|
|
543
|
+
this.inlineInput.visible = shows !== undefined;
|
|
544
|
+
if (shows) {
|
|
545
|
+
for (const line of shows) lines.push(paint(line, inner, "accent"));
|
|
546
|
+
if (shows.length < previewLines) lines.push(paint("Enter confirm · Esc cancel", inner, "muted"));
|
|
547
|
+
} else if (previewLines > 0) {
|
|
548
|
+
lines.push(paint(`Needs ${visibleWidth(field) + CARD_PADDING} columns for one line · Esc cancel`, inner, "warning"));
|
|
414
549
|
}
|
|
415
|
-
} else if (previewLines
|
|
550
|
+
} else if (previewLines >= 3) {
|
|
416
551
|
let preview: ReturnType<NonNullable<CustomizeRow["preview"]>> | undefined;
|
|
417
552
|
try { if (!navOnly) preview = rows[this.selected]?.preview?.(); } catch { /* Never substitute the active theme for an unreadable source. */ }
|
|
418
553
|
lines.push("");
|
|
419
|
-
|
|
420
|
-
|
|
554
|
+
// The focused setting says what it does; the preview below shows the highlighted value.
|
|
555
|
+
const headline = focusedSetting?.hint ? `${focusedSetting.setting} — ${focusedSetting.hint}` : preview ? `Preview · ${preview.title}` : "Preview unavailable";
|
|
556
|
+
lines.push(paint(navOnly ? "→ controls · Esc close" : headline, inner, "accent"));
|
|
557
|
+
const sample = navOnly ? [""] : (preview?.sample ?? "No read-only sample for this choice").split("\n");
|
|
558
|
+
for (let i = 0; i < previewLines - 2; i++) lines.push(paint(sample[i] ?? "", inner, "muted"));
|
|
421
559
|
} else if (previewLines === 1) lines.push(paint(navOnly ? "→ controls · Esc close" : "Preview omitted · enlarge terminal", inner, "muted"));
|
|
422
560
|
if (showBottomGap) lines.push("");
|
|
423
|
-
if (showHeading) lines.push(paint(footerHint(category, navOnly, previewLines, rows[this.selected]?.keyhint), inner, "muted"));
|
|
561
|
+
if (showHeading) lines.push(paint(footerHint(category, navOnly, previewLines, rows[this.selected]?.keyhint, focusedSetting !== undefined, focusedSetting?.applyOnMove !== false), inner, "muted"));
|
|
424
562
|
// The top-right close hint mirrors Commands without consuming another row.
|
|
425
563
|
const title = this.title();
|
|
426
564
|
lines[0] = paint(title + " ".repeat(Math.max(1, inner - visibleWidth(title) - 3)) + "esc", inner, "accent");
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { VISUAL_SECTION_KEYS, VisualSettings } from "./visual-customization-policy.ts";
|
|
2
|
+
|
|
3
|
+
// A four-line schematic of the fullscreen layout for the Customize preview:
|
|
4
|
+
// where the header and the input go, whether Status is a rail, a bottom bar
|
|
5
|
+
// or hidden, and which rail sections the settings show.
|
|
6
|
+
|
|
7
|
+
const MAIN = 26;
|
|
8
|
+
const RAIL = 22;
|
|
9
|
+
/** Rail sections in rail order, named as the rail labels them. */
|
|
10
|
+
const RAIL_SECTIONS: ReadonlyArray<[(typeof VISUAL_SECTION_KEYS)[number], string]> = [["todo", "todos"], ["agents", "agents"], ["changes", "changes"], ["rdd", "review"], ["stats", "stats"]];
|
|
11
|
+
|
|
12
|
+
const fill = (text: string, width: number) => (text.length > width ? text.slice(0, width - 1) + "…" : text + " ".repeat(width - text.length));
|
|
13
|
+
const rule = (label: string, width: number) => (label ? `─ ${label} ` : "").padEnd(width, "─").slice(0, width);
|
|
14
|
+
|
|
15
|
+
export function layoutSchematic(settings: VisualSettings): string {
|
|
16
|
+
const rail = settings.statusPlacement === "right" || settings.statusPlacement === "auto";
|
|
17
|
+
const top = settings.headerPlacement === "top";
|
|
18
|
+
// Two rail rows, filled word by word in rail order.
|
|
19
|
+
const railRows = ["", ""];
|
|
20
|
+
let row = 0;
|
|
21
|
+
for (const [key, name] of RAIL_SECTIONS) {
|
|
22
|
+
if (!settings.visibility[key]) continue;
|
|
23
|
+
const next = railRows[row] ? `${railRows[row]} ${name}` : name;
|
|
24
|
+
if (next.length > RAIL - 1 && row === 0) { row = 1; railRows[1] = name; }
|
|
25
|
+
else railRows[row] = next;
|
|
26
|
+
}
|
|
27
|
+
const input = top ? "› input" : "› input · header";
|
|
28
|
+
const main = ["conversation", input];
|
|
29
|
+
const width = MAIN + (rail ? RAIL + 1 : 0);
|
|
30
|
+
const bottom = settings.statusPlacement === "bottom" ? "status bar" : settings.statusPlacement === "auto" ? "bar under 140 cols" : "";
|
|
31
|
+
if (rail) {
|
|
32
|
+
return [
|
|
33
|
+
`┌${rule(top ? "header" : "", MAIN)}┬${rule("Status", RAIL)}┐`,
|
|
34
|
+
...main.map((text, line) => `│ ${fill(text, MAIN - 1)}│ ${fill(railRows[line] ?? "", RAIL - 1)}│`),
|
|
35
|
+
`└${rule(bottom, MAIN)}┴${"─".repeat(RAIL)}┘`,
|
|
36
|
+
].join("\n");
|
|
37
|
+
}
|
|
38
|
+
return [
|
|
39
|
+
`┌${rule(top ? "header" : "", width)}┐`,
|
|
40
|
+
...main.map((text) => `│ ${fill(text, width - 1)}│`),
|
|
41
|
+
`└${rule(bottom, width)}┘`,
|
|
42
|
+
].join("\n");
|
|
43
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Text, type TUI } from "@earendil-works/pi-tui";
|
|
3
|
+
import { sidebarState } from "./shell-sidebar.ts";
|
|
2
4
|
import { appendSystemPromptOnce, type AppendableSystemPromptOptions } from "./append-system-prompt.ts";
|
|
3
5
|
import { sameReviewSessionIdentity, resolveCanonicalGitRepositoryIdentity, type ReviewSessionIdentity } from "./review-session-standing-permission.ts";
|
|
4
6
|
import { realpath } from "node:fs/promises";
|
|
@@ -92,6 +94,27 @@ export function discoverYoloUiAdapter(pi: ExtensionAPI, context: ExtensionContex
|
|
|
92
94
|
catch { settled = true; clearTimeout(timer); resolve(undefined); }
|
|
93
95
|
});
|
|
94
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* The above-editor YOLO banner: the same padded text Pi draws for a string
|
|
99
|
+
* widget, painted nothing while the IDE chrome's status bar already shows the
|
|
100
|
+
* permission mode (sidebarState(tui).statusBarShowsMode).
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* The banner as a widget: the terminal UI gets the component that steps aside
|
|
104
|
+
* behind the status bar; every other host (RPC forwards only string widgets,
|
|
105
|
+
* e.g. the desktop app) keeps the plain string widget.
|
|
106
|
+
*/
|
|
107
|
+
export function yoloBannerContent(mode: string | undefined, text: string): string[] | ReturnType<typeof yoloBanner> {
|
|
108
|
+
return mode === "tui" ? yoloBanner(text) : [text];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function yoloBanner(text: string) {
|
|
112
|
+
return (tui: TUI) => {
|
|
113
|
+
const banner = new Text(text, 1, 0);
|
|
114
|
+
const quiet = () => Boolean((tui as { terminal?: unknown }).terminal && sidebarState(tui).statusBarShowsMode?.());
|
|
115
|
+
return { render: (width: number) => (quiet() ? [] : banner.render(width)), invalidate: () => banner.invalidate() };
|
|
116
|
+
};
|
|
117
|
+
}
|
|
95
118
|
export interface YoloSessionController {
|
|
96
119
|
active(context: ExtensionContext): Promise<boolean>;
|
|
97
120
|
superActive(context: ExtensionContext): Promise<boolean>;
|
|
@@ -153,7 +176,11 @@ export function registerYoloSessionPolicy(pi: ExtensionAPI, env: NodeJS.ProcessE
|
|
|
153
176
|
if (previous && previous.yolo === yolo && previous.modeText === modeText) return;
|
|
154
177
|
let painted = true;
|
|
155
178
|
try { ctx.ui.setStatus(YOLO_STATUS_KEY, yolo); } catch { painted = false; /* display only */ }
|
|
156
|
-
try {
|
|
179
|
+
try {
|
|
180
|
+
const banner = yolo ? yoloBannerContent(ctx.mode, yolo) : undefined;
|
|
181
|
+
if (typeof banner === "function") ctx.ui.setWidget(YOLO_STATUS_KEY, banner);
|
|
182
|
+
else ctx.ui.setWidget(YOLO_STATUS_KEY, banner);
|
|
183
|
+
} catch { painted = false; /* display only */ }
|
|
157
184
|
try { ctx.ui.setStatus(MODE_STATUS_KEY, modeText); } catch { painted = false; /* display only */ }
|
|
158
185
|
if (painted) published.set(ctx, { yolo, modeText });
|
|
159
186
|
};
|
package/package.json
CHANGED
|
@@ -215,6 +215,9 @@ function linkDir(env , homedir )
|
|
|
215
215
|
// launched from inside a Gentle Shell session sees the outer isolated home as
|
|
216
216
|
// PI_CODING_AGENT_DIR, so `--link` must not re-select it (#2015).
|
|
217
217
|
export const USER_PI_HOME_ENV = "GENTLE_SHELL_USER_PI_HOME";
|
|
218
|
+
// Set by bin/gentle-shell.mjs only when Gentle Shell, not Herdr's Pi bridge,
|
|
219
|
+
// owns the pane's Herdr agent reports (extensions/gentle-herdr-agent.ts).
|
|
220
|
+
export const HERDR_REPORTER_ENV = "GENTLE_SHELL_HERDR_REPORTER";
|
|
218
221
|
|
|
219
222
|
export function userPiHome(env , homedir ) {
|
|
220
223
|
return env[USER_PI_HOME_ENV] || linkDir(env, homedir);
|
|
@@ -1084,6 +1087,7 @@ export function buildPiInvocation(input ) {
|
|
|
1084
1087
|
const env = {
|
|
1085
1088
|
...input.baseEnv,
|
|
1086
1089
|
PI_CODING_AGENT_DIR: input.home.dir,
|
|
1090
|
+
PI_PROGRAM_STATUS_APP: "gentle-shell",
|
|
1087
1091
|
GENTLE_PI_AGENT_HOME: input.home.dir,
|
|
1088
1092
|
[USER_PI_HOME_ENV]: userPiHome(input.baseEnv, input.homedir),
|
|
1089
1093
|
};
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
decodeReviewStartV3,
|
|
20
20
|
decodeReviewStartV4,
|
|
21
21
|
decodeReviewStatusV3,
|
|
22
|
+
intendedUntrackedSubmissionCarriesTarget,
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
|
|
@@ -2400,7 +2401,11 @@ export class NativeReviewCliV216 {
|
|
|
2400
2401
|
// value for the same flag. providerFlagValue also fails closed on a
|
|
2401
2402
|
// dangling `--flag` (last token, no value) or an empty `--flag=`.
|
|
2402
2403
|
const submittedBaseRefValue = submittedTokens === undefined ? undefined : providerFlagValue(submittedTokens, "base-ref");
|
|
2403
|
-
|
|
2404
|
+
// A provider-issued base-diff selector (base tree plus scope) already binds
|
|
2405
|
+
// the target the request named; the tree is not textually comparable to
|
|
2406
|
+
// the request's ref, so it runs as issued and nothing is re-forwarded.
|
|
2407
|
+
const providerOwnsTarget = submitted !== undefined && intendedUntrackedSubmissionCarriesTarget(submitted.argumentTokens);
|
|
2408
|
+
if (!providerOwnsTarget && request.baseRef !== undefined && submittedBaseRefValue !== undefined && submittedBaseRefValue !== request.baseRef) throw new TypeError("Native intended-untracked selection already carries a conflicting base-ref");
|
|
2404
2409
|
const submittedLineageValue = submittedTokens === undefined ? undefined : providerFlagValue(submittedTokens, "lineage");
|
|
2405
2410
|
if (request.lineageId !== undefined && submittedLineageValue !== undefined && submittedLineageValue !== request.lineageId) throw new TypeError("Native intended-untracked selection already carries a conflicting lineage");
|
|
2406
2411
|
let submittedHasCommittedOnly = false;
|
|
@@ -2413,7 +2418,7 @@ export class NativeReviewCliV216 {
|
|
|
2413
2418
|
// Append only the half of the base-ref/committed-only pair the provider
|
|
2414
2419
|
// did not already carry (a present base-ref already equals
|
|
2415
2420
|
// request.baseRef; the throw above ruled out the conflicting case).
|
|
2416
|
-
const forwardedBaseRef = request.baseRef === undefined ? [] : [
|
|
2421
|
+
const forwardedBaseRef = request.baseRef === undefined || providerOwnsTarget ? [] : [
|
|
2417
2422
|
...(submittedBaseRefValue === undefined ? ["--base-ref", request.baseRef] : []),
|
|
2418
2423
|
...(submittedHasCommittedOnly ? [] : ["--committed-only"]),
|
|
2419
2424
|
];
|
|
@@ -1467,17 +1467,32 @@ function decodeTransitionArguments(value , label )
|
|
|
1467
1467
|
});
|
|
1468
1468
|
}
|
|
1469
1469
|
|
|
1470
|
+
// The intended-untracked submission re-enters STATUS for the same target: the
|
|
1471
|
+
// workspace projection, or a provider-issued base-diff selector (a base tree
|
|
1472
|
+
// plus --committed-only or --workspace-overlay). No other selector is accepted.
|
|
1473
|
+
const INTENDED_UNTRACKED_PREFIX = ["--contract=gentle-ai.review-integration/v2", "--next-transition=true", "--agent=pi"] ;
|
|
1474
|
+
const INTENDED_UNTRACKED_SELECTION_TOKEN = "--intended-untracked-selection={{value}}";
|
|
1475
|
+
const INTENDED_UNTRACKED_BASE_TREE = /^--base-ref=[0-9a-f]{40}(?:[0-9a-f]{24})?$/;
|
|
1476
|
+
|
|
1477
|
+
/** True when a validated submission already carries the provider-issued base-diff target selector. */
|
|
1478
|
+
export function intendedUntrackedSubmissionCarriesTarget(tokens ) {
|
|
1479
|
+
return isIntendedUntrackedSubmissionTokens(tokens) && tokens.length === INTENDED_UNTRACKED_PREFIX.length + 3;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
function isIntendedUntrackedSubmissionTokens(tokens ) {
|
|
1483
|
+
if (INTENDED_UNTRACKED_PREFIX.some((token, index) => tokens[index] !== token) || tokens[tokens.length - 1] !== INTENDED_UNTRACKED_SELECTION_TOKEN) return false;
|
|
1484
|
+
const selector = tokens.slice(INTENDED_UNTRACKED_PREFIX.length, -1);
|
|
1485
|
+
if (selector.length === 1) return selector[0] === "--projection=workspace";
|
|
1486
|
+
return selector.length === 2 && INTENDED_UNTRACKED_BASE_TREE.test(selector[0] ) && (selector[1] === "--committed-only=true" || selector[1] === "--workspace-overlay=true");
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1470
1489
|
function decodeCaptureSubmission(value , label , v5 , v6 , captureOperation ) {
|
|
1471
1490
|
// status/v6 adds the provider-owned intended-untracked selection form.
|
|
1472
1491
|
if (v6 && captureOperation === "external.select_intended_untracked" && typeof value === "object" && value !== null && (value ).operation_token === "status") {
|
|
1473
1492
|
const submission = exactRecord(value, label, ["operation_token", "argument_tokens", "value"]);
|
|
1474
|
-
const expectedTokens = [
|
|
1475
|
-
"--contract=gentle-ai.review-integration/v2", "--next-transition=true", "--agent=pi",
|
|
1476
|
-
"--projection=workspace", "--intended-untracked-selection={{value}}",
|
|
1477
|
-
] ;
|
|
1478
1493
|
const operationToken = enumeration(submission.operation_token, ["status"] , `${label}.operation_token`);
|
|
1479
|
-
const argumentTokens = stringArray(submission.argument_tokens, `${label}.argument_tokens`, { minimum:
|
|
1480
|
-
if (argumentTokens
|
|
1494
|
+
const argumentTokens = stringArray(submission.argument_tokens, `${label}.argument_tokens`, { minimum: 5, maximum: 6 });
|
|
1495
|
+
if (!isIntendedUntrackedSubmissionTokens(argumentTokens)) throw new TypeError(`${label}.argument_tokens substitution binding is invalid`);
|
|
1481
1496
|
const row = exactRecord(submission.value, `${label}.value`, ["slot", "domain", "schema", "substitution_location"]);
|
|
1482
1497
|
return {
|
|
1483
1498
|
operationToken,
|
|
@@ -1486,7 +1501,7 @@ function decodeCaptureSubmission(value , label , v5 , v6
|
|
|
1486
1501
|
slot: enumeration(row.slot, ["intended_untracked_selection"] , `${label}.value.slot`),
|
|
1487
1502
|
domain: enumeration(row.domain, ["schema_bound_json"] , `${label}.value.domain`),
|
|
1488
1503
|
schema: enumeration(row.schema, ["gentle-ai.review-intended-untracked-selection/v1"] , `${label}.value.schema`),
|
|
1489
|
-
substitutionLocation: integer(row.substitution_location, `${label}.value.substitution_location`,
|
|
1504
|
+
substitutionLocation: integer(row.substitution_location, `${label}.value.substitution_location`, argumentTokens.length - 1, argumentTokens.length - 1),
|
|
1490
1505
|
}],
|
|
1491
1506
|
};
|
|
1492
1507
|
}
|