@gajae-code/coding-agent 0.11.7 → 0.11.9

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.
Files changed (213) hide show
  1. package/CHANGELOG.md +73 -1
  2. package/dist/types/cli/args.d.ts +0 -2
  3. package/dist/types/cli.d.ts +1 -0
  4. package/dist/types/config/keybindings.d.ts +33 -3
  5. package/dist/types/config/model-profile-activation.d.ts +4 -3
  6. package/dist/types/config/model-profile-contract.d.ts +38 -0
  7. package/dist/types/config/model-profiles.d.ts +2 -3
  8. package/dist/types/config/settings-schema.d.ts +15 -2
  9. package/dist/types/edit/modes/patch.d.ts +13 -0
  10. package/dist/types/edit/path-mutation-lock.d.ts +15 -0
  11. package/dist/types/eval/py/executor.d.ts +1 -1
  12. package/dist/types/eval/py/tool-bridge.d.ts +1 -2
  13. package/dist/types/gjc-runtime/deep-interview-ambiguity.d.ts +12 -5
  14. package/dist/types/gjc-runtime/deep-interview-draft.d.ts +8 -0
  15. package/dist/types/gjc-runtime/deep-interview-payload.d.ts +41 -0
  16. package/dist/types/gjc-runtime/deep-interview-recorder.d.ts +32 -17
  17. package/dist/types/gjc-runtime/deep-interview-repair.d.ts +17 -0
  18. package/dist/types/gjc-runtime/deep-interview-state.d.ts +135 -4
  19. package/dist/types/gjc-runtime/repository-binding.d.ts +63 -0
  20. package/dist/types/gjc-runtime/state-writer.d.ts +44 -0
  21. package/dist/types/gjc-runtime/ultragoal-guard.d.ts +1 -0
  22. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +24 -0
  23. package/dist/types/gjc-runtime/workflow-manifest.d.ts +5 -3
  24. package/dist/types/main.d.ts +8 -0
  25. package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +2 -1
  26. package/dist/types/modes/components/tool-status-header.d.ts +3 -2
  27. package/dist/types/modes/components/welcome.d.ts +4 -0
  28. package/dist/types/modes/controllers/command-controller.d.ts +2 -0
  29. package/dist/types/modes/controllers/selector-controller.d.ts +2 -1
  30. package/dist/types/modes/interactive-mode.d.ts +5 -2
  31. package/dist/types/modes/prompt-action-autocomplete.d.ts +6 -1
  32. package/dist/types/modes/prompt-suggestion-controller.d.ts +35 -0
  33. package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +2 -2
  34. package/dist/types/modes/types.d.ts +3 -0
  35. package/dist/types/modes/utils/hotkeys-markdown.d.ts +2 -1
  36. package/dist/types/runtime-mcp/manager.d.ts +1 -1
  37. package/dist/types/runtime-mcp/oauth-flow.d.ts +0 -5
  38. package/dist/types/runtime-mcp/plugin-network-boundary.d.ts +14 -0
  39. package/dist/types/runtime-mcp/redaction.d.ts +2 -0
  40. package/dist/types/sdk/broker/broker.d.ts +2 -0
  41. package/dist/types/sdk/broker/lifecycle.d.ts +6 -0
  42. package/dist/types/sdk/bus/chat-daemon-control.d.ts +7 -1
  43. package/dist/types/sdk/bus/config-commands.d.ts +2 -2
  44. package/dist/types/sdk/bus/config.d.ts +2 -0
  45. package/dist/types/sdk/bus/conversation-store.d.ts +1 -0
  46. package/dist/types/sdk/bus/index.d.ts +25 -0
  47. package/dist/types/sdk/bus/notification-orchestration.d.ts +1 -0
  48. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +105 -0
  49. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +15 -3
  50. package/dist/types/sdk/bus/telegram-daemon-control.d.ts +5 -1
  51. package/dist/types/sdk/bus/telegram-daemon.d.ts +128 -1
  52. package/dist/types/sdk/bus/telegram-reference.d.ts +2 -0
  53. package/dist/types/sdk/host/control/operations.d.ts +1 -1
  54. package/dist/types/sdk/host/host.d.ts +1 -1
  55. package/dist/types/sdk/host/query/handlers.d.ts +9 -0
  56. package/dist/types/sdk/index.d.ts +2 -0
  57. package/dist/types/sdk/prompt-status.d.ts +88 -0
  58. package/dist/types/sdk/session-directory.d.ts +1 -1
  59. package/dist/types/sdk/startup-capability.d.ts +3 -0
  60. package/dist/types/session/agent-session.d.ts +2 -0
  61. package/dist/types/session/internal/managed-session-scope.d.ts +22 -3
  62. package/dist/types/session/internal/managed-session-storage.d.ts +24 -4
  63. package/dist/types/session/internal/native-publish-outcome.d.ts +48 -0
  64. package/dist/types/session/session-manager.d.ts +5 -1
  65. package/dist/types/session/session-storage.d.ts +31 -0
  66. package/dist/types/skill-state/active-state.d.ts +4 -0
  67. package/dist/types/task/index.d.ts +3 -1
  68. package/dist/types/task/receipt.d.ts +2 -0
  69. package/dist/types/task/types.d.ts +94 -0
  70. package/dist/types/tools/ask.d.ts +454 -174
  71. package/dist/types/tools/image-gen.d.ts +47 -1
  72. package/dist/types/tools/index.d.ts +4 -0
  73. package/dist/types/utils/prompt-suggestion.d.ts +33 -0
  74. package/package.json +8 -8
  75. package/scripts/capture-platform-shortcut-labels-showcase.ts +342 -0
  76. package/scripts/dogfood-repository-binding.ts +209 -0
  77. package/scripts/generate-sdk-operation-inventory.ts +2 -0
  78. package/scripts/run-test-manifest.ts +4 -4
  79. package/src/cli/args.ts +2 -92
  80. package/src/cli/mcp-cli.ts +4 -21
  81. package/src/cli/notify-cli.ts +5 -38
  82. package/src/cli.ts +50 -0
  83. package/src/commands/deep-interview.ts +9 -4
  84. package/src/commands/sdk.ts +2 -2
  85. package/src/commit/agentic/index.ts +3 -3
  86. package/src/commit/map-reduce/index.ts +2 -2
  87. package/src/config/keybindings.ts +157 -24
  88. package/src/config/model-profile-activation.ts +7 -18
  89. package/src/config/model-profile-contract.ts +161 -0
  90. package/src/config/model-profiles.ts +2 -3
  91. package/src/config/model-registry.ts +11 -1
  92. package/src/config/settings-schema.ts +17 -2
  93. package/src/coordinator-mcp/model-preset.ts +21 -74
  94. package/src/defaults/gjc/skills/deep-interview/SKILL.md +80 -165
  95. package/src/defaults/gjc/skills/ralplan/SKILL.md +3 -1
  96. package/src/edit/index.ts +3 -6
  97. package/src/edit/modes/patch.ts +38 -1
  98. package/src/edit/modes/replace.ts +42 -0
  99. package/src/edit/path-mutation-lock.ts +112 -0
  100. package/src/eval/py/executor.ts +30 -11
  101. package/src/eval/py/prelude.py +2 -2
  102. package/src/eval/py/tool-bridge.ts +34 -18
  103. package/src/extensibility/gjc-plugins/runtime-adapters.ts +2 -1
  104. package/src/gjc-runtime/deep-interview-ambiguity.ts +68 -47
  105. package/src/gjc-runtime/deep-interview-draft.ts +842 -0
  106. package/src/gjc-runtime/deep-interview-payload.ts +262 -0
  107. package/src/gjc-runtime/deep-interview-recorder.ts +294 -226
  108. package/src/gjc-runtime/deep-interview-repair.ts +1674 -0
  109. package/src/gjc-runtime/deep-interview-runtime.ts +264 -103
  110. package/src/gjc-runtime/deep-interview-state.ts +916 -4
  111. package/src/gjc-runtime/launch-tmux.ts +1 -1
  112. package/src/gjc-runtime/managed-owner-supervisor.ts +83 -4
  113. package/src/gjc-runtime/ralplan-runtime.ts +78 -4
  114. package/src/gjc-runtime/repository-binding.ts +267 -0
  115. package/src/gjc-runtime/session-state-sidecar.ts +25 -9
  116. package/src/gjc-runtime/state-writer.ts +166 -2
  117. package/src/gjc-runtime/tmux-owner-isolation.ts +2 -1
  118. package/src/gjc-runtime/tmux-sessions.ts +45 -6
  119. package/src/gjc-runtime/ultragoal-guard.ts +5 -5
  120. package/src/gjc-runtime/ultragoal-runtime.ts +181 -19
  121. package/src/gjc-runtime/workflow-manifest.generated.json +386 -1
  122. package/src/gjc-runtime/workflow-manifest.ts +191 -5
  123. package/src/internal-urls/docs-index.generated.ts +8 -6
  124. package/src/internal-urls/local-protocol.ts +33 -16
  125. package/src/internal-urls/mcp-protocol.ts +73 -11
  126. package/src/main.ts +25 -10
  127. package/src/modes/DESIGN.md +5 -0
  128. package/src/modes/acp/acp-agent.ts +50 -16
  129. package/src/modes/components/model-selector.ts +42 -8
  130. package/src/modes/components/plan-preview-overlay.ts +1 -1
  131. package/src/modes/components/runtime-mcp-add-wizard.ts +5 -0
  132. package/src/modes/components/tool-status-header.ts +20 -4
  133. package/src/modes/components/welcome.ts +32 -20
  134. package/src/modes/controllers/command-controller.ts +97 -54
  135. package/src/modes/controllers/event-controller.ts +10 -0
  136. package/src/modes/controllers/input-controller.ts +7 -2
  137. package/src/modes/controllers/runtime-mcp-command-controller.ts +29 -6
  138. package/src/modes/controllers/selector-controller.ts +46 -54
  139. package/src/modes/interactive-mode.ts +70 -36
  140. package/src/modes/prompt-action-autocomplete.ts +32 -13
  141. package/src/modes/prompt-suggestion-controller.ts +96 -0
  142. package/src/modes/shared/agent-wire/workflow-gate-broker.ts +2 -2
  143. package/src/modes/types.ts +3 -0
  144. package/src/modes/utils/hotkeys-markdown.ts +64 -36
  145. package/src/modes/utils/ui-helpers.ts +5 -3
  146. package/src/prompts/agents/architect.md +0 -1
  147. package/src/prompts/agents/critic.md +0 -1
  148. package/src/prompts/system/prompt-suggestion-system.md +32 -0
  149. package/src/prompts/system/system-prompt.md +7 -4
  150. package/src/prompts/tools/cron.md +3 -1
  151. package/src/runtime-mcp/json-rpc.ts +7 -4
  152. package/src/runtime-mcp/manager.ts +51 -53
  153. package/src/runtime-mcp/oauth-flow.ts +0 -72
  154. package/src/runtime-mcp/plugin-network-boundary.ts +101 -0
  155. package/src/runtime-mcp/redaction.ts +30 -0
  156. package/src/runtime-mcp/transports/http.ts +13 -6
  157. package/src/sdk/broker/broker.ts +34 -20
  158. package/src/sdk/broker/lifecycle.ts +185 -36
  159. package/src/sdk/broker/session-index.ts +11 -1
  160. package/src/sdk/bus/chat-daemon-control.ts +20 -5
  161. package/src/sdk/bus/config-commands.ts +2 -2
  162. package/src/sdk/bus/config.ts +9 -1
  163. package/src/sdk/bus/conversation-store.ts +40 -6
  164. package/src/sdk/bus/index.ts +240 -65
  165. package/src/sdk/bus/lifecycle-commands.ts +47 -3
  166. package/src/sdk/bus/lifecycle-control-runtime.ts +11 -2
  167. package/src/sdk/bus/lifecycle-orchestrator.ts +32 -1
  168. package/src/sdk/bus/notification-orchestration.ts +12 -0
  169. package/src/sdk/bus/notification-service.ts +27 -2
  170. package/src/sdk/bus/prompt-reconciliation.ts +239 -0
  171. package/src/sdk/bus/recent-activity.ts +90 -26
  172. package/src/sdk/bus/telegram-daemon-contract.ts +15 -3
  173. package/src/sdk/bus/telegram-daemon-control.ts +145 -33
  174. package/src/sdk/bus/telegram-daemon.ts +853 -112
  175. package/src/sdk/bus/telegram-reference.ts +20 -2
  176. package/src/sdk/cli/session-cli.ts +15 -2
  177. package/src/sdk/host/control/dispatch.ts +1 -1
  178. package/src/sdk/host/control/operations.ts +1 -1
  179. package/src/sdk/host/host.ts +2 -6
  180. package/src/sdk/host/query/handlers.ts +70 -5
  181. package/src/sdk/index.ts +12 -0
  182. package/src/sdk/prompt-status.ts +97 -0
  183. package/src/sdk/protocol/operation-inventory.generated.json +47 -0
  184. package/src/sdk/protocol/operation-registry.ts +18 -4
  185. package/src/sdk/session-directory.ts +5 -1
  186. package/src/sdk/session.ts +2 -0
  187. package/src/sdk/startup-capability.ts +9 -1
  188. package/src/session/agent-session.ts +138 -5
  189. package/src/session/blob-store.ts +7 -2
  190. package/src/session/internal/managed-session-scope.ts +998 -133
  191. package/src/session/internal/managed-session-storage.ts +268 -203
  192. package/src/session/internal/native-publish-outcome.ts +266 -0
  193. package/src/session/session-manager.ts +406 -360
  194. package/src/session/session-storage.ts +151 -11
  195. package/src/skill-state/active-state.ts +10 -0
  196. package/src/task/executor.ts +13 -5
  197. package/src/task/gjc-command.ts +2 -2
  198. package/src/task/index.ts +121 -15
  199. package/src/task/receipt.ts +3 -0
  200. package/src/task/types.ts +34 -3
  201. package/src/tools/ask.ts +199 -88
  202. package/src/tools/ast-edit.ts +2 -2
  203. package/src/tools/bash-pty-selection.ts +2 -2
  204. package/src/tools/browser/screenshot-format.ts +6 -1
  205. package/src/tools/cron.ts +1 -1
  206. package/src/tools/image-gen.ts +178 -6
  207. package/src/tools/index.ts +4 -0
  208. package/src/tools/render-utils.ts +7 -1
  209. package/src/utils/edit-mode.ts +2 -2
  210. package/src/utils/prompt-suggestion.ts +265 -0
  211. package/src/utils/sixel.ts +3 -3
  212. package/src/web/insane/url-guard.ts +3 -1
  213. package/src/web/scrapers/docs-rs.ts +30 -5
@@ -2,7 +2,7 @@ import { type Model } from "@gajae-code/ai";
2
2
  import * as z from "zod/v4";
3
3
  import { type ModelRegistry } from "../config/model-registry";
4
4
  import type { CustomTool } from "../extensibility/custom-tools/types";
5
- type ImageProvider = "antigravity" | "gemini" | "openai" | "openai-codex" | "openrouter";
5
+ type ImageProvider = "alibaba" | "antigravity" | "gemini" | "openai" | "openai-codex" | "openrouter";
6
6
  declare const responseModalitySchema: z.ZodEnum<{
7
7
  IMAGE: "IMAGE";
8
8
  TEXT: "TEXT";
@@ -55,6 +55,52 @@ interface OpenAIResponsesUsage {
55
55
  total_tokens?: number;
56
56
  }
57
57
  type ImageUsageMetadata = GeminiUsageMetadata | OpenAIResponsesUsage;
58
+ interface AlibabaImageContentPart {
59
+ type?: string;
60
+ text?: string;
61
+ image?: string;
62
+ }
63
+ interface AlibabaImageResponse {
64
+ code?: string;
65
+ message?: string;
66
+ output?: {
67
+ choices?: Array<{
68
+ message?: {
69
+ content?: AlibabaImageContentPart[];
70
+ };
71
+ }>;
72
+ };
73
+ }
74
+ /** Map the tool's image_size values onto wan2.7's 1K/2K size classes. */
75
+ export declare function resolveAlibabaImageSize(imageSize: string | undefined): string | undefined;
76
+ /**
77
+ * Build the Bailian multimodal-generation request body for wan2.7 image
78
+ * generation/editing. Input images ride along as data URLs; generation-only
79
+ * calls send just the prompt text. The sync endpoint returns OSS URLs inline.
80
+ */
81
+ export declare function buildAlibabaImageRequest(model: string, promptText: string, inputImages: InlineImageData[], imageSize: string | undefined): {
82
+ model: string;
83
+ input: {
84
+ messages: Array<{
85
+ role: "user";
86
+ content: Array<{
87
+ text: string;
88
+ } | {
89
+ image: string;
90
+ }>;
91
+ }>;
92
+ };
93
+ parameters: {
94
+ n: number;
95
+ watermark: boolean;
96
+ size?: string;
97
+ };
98
+ };
99
+ /** Collect OSS image URLs and any text parts from a Bailian image response. */
100
+ export declare function collectAlibabaImageResult(response: AlibabaImageResponse): {
101
+ imageUrls: string[];
102
+ responseText?: string;
103
+ };
58
104
  interface ImageGenToolDetails {
59
105
  provider: ImageProvider;
60
106
  model: string;
@@ -82,6 +82,8 @@ export interface AskAnswerRequest {
82
82
  options: string[];
83
83
  interaction: "selector" | "custom_editor" | "clarification_editor";
84
84
  controls: readonly AskRemoteControl[];
85
+ /** Optional zero-based recommendation into the authoritative raw options. */
86
+ recommendedIndex?: number;
85
87
  }
86
88
  export type AskRemoteInteraction = {
87
89
  kind: "value";
@@ -155,6 +157,8 @@ export interface ToolSession {
155
157
  * its terminal-phase chain guard. Returns the raw phase string or undefined
156
158
  * when no active skill (or accessor) is available. */
157
159
  getActiveSkillPhase?: () => string | undefined;
160
+ /** Restrict provider-facing deep-interview ask metadata to the active workflow stage. */
161
+ getDeepInterviewAskStage?: () => "topology" | "post-topology" | undefined;
158
162
  /** Pre-loaded prompt templates */
159
163
  promptTemplates?: PromptTemplate[];
160
164
  /** Whether LSP integrations are enabled */
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Predict the user's likely next prompt after an agent turn using a smol,
3
+ * fast model. Native GJC port of the ghost-text prompt-suggestion behavior
4
+ * from Claude Code: the prediction renders as dim ghost text in the empty
5
+ * composer and Tab accepts it.
6
+ */
7
+ import type { AgentMessage } from "@gajae-code/agent-core";
8
+ import { type Api, type Model } from "@gajae-code/ai";
9
+ import type { ModelRegistry } from "../config/model-registry";
10
+ import type { Settings } from "../config/settings";
11
+ export declare const PROMPT_SUGGESTION_MAX_WORDS = 12;
12
+ export declare const PROMPT_SUGGESTION_MAX_CHARS = 100;
13
+ /**
14
+ * Strip wrapper tags and label prefixes a model sometimes adds despite being
15
+ * told to reply with only the suggestion.
16
+ */
17
+ export declare function sanitizePromptSuggestion(raw: string): string;
18
+ /**
19
+ * Heuristic gate rejecting model output that would make a bad ghost-text
20
+ * suggestion. Returns the rejection reason, or null when the text is usable.
21
+ */
22
+ export declare function suppressPromptSuggestionReason(text: string): string | null;
23
+ /**
24
+ * Build a compact recent-conversation transcript for the prediction request.
25
+ * Returns null when there is no user message to predict from.
26
+ */
27
+ export declare function buildPromptSuggestionContext(messages: AgentMessage[]): string | null;
28
+ /**
29
+ * Generate a predicted next user prompt from the recent conversation.
30
+ * Returns null when no usable suggestion is produced (silence is the
31
+ * expected steady state).
32
+ */
33
+ export declare function generatePromptSuggestion(messages: AgentMessage[], registry: ModelRegistry, settings: Settings, sessionId?: string, currentModel?: Model<Api>, metadataResolver?: (provider: string) => Record<string, unknown> | undefined): Promise<string | null>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/coding-agent",
4
- "version": "0.11.7",
4
+ "version": "0.11.9",
5
5
  "description": "Gajae Code CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo and Gajae Code Contributors",
@@ -53,13 +53,13 @@
53
53
  "@agentclientprotocol/sdk": "1.2.1",
54
54
  "@babel/parser": "^7.29.3",
55
55
  "@mozilla/readability": "^0.6.0",
56
- "@gajae-code/stats": "0.11.7",
57
- "@gajae-code/agent-core": "0.11.7",
58
- "@gajae-code/ai": "0.11.7",
59
- "@gajae-code/bridge-client": "0.11.7",
60
- "@gajae-code/natives": "0.11.7",
61
- "@gajae-code/tui": "0.11.7",
62
- "@gajae-code/utils": "0.11.7",
56
+ "@gajae-code/stats": "0.11.9",
57
+ "@gajae-code/agent-core": "0.11.9",
58
+ "@gajae-code/ai": "0.11.9",
59
+ "@gajae-code/bridge-client": "0.11.9",
60
+ "@gajae-code/natives": "0.11.9",
61
+ "@gajae-code/tui": "0.11.9",
62
+ "@gajae-code/utils": "0.11.9",
63
63
  "@puppeteer/browsers": "^2.13.0",
64
64
  "@types/turndown": "5.0.6",
65
65
  "@xterm/headless": "^6.0.0",
@@ -0,0 +1,342 @@
1
+ import * as fs from "node:fs/promises";
2
+ import * as path from "node:path";
3
+ import {
4
+ PLATFORM_SHORTCUT_LABELS_SHOWCASE_ENTRIES,
5
+ PLATFORM_SHORTCUT_LABELS_SHOWCASE_EXPECTED_ENTRY_COUNT,
6
+ type PlatformShortcutLabelsShowcaseEntry,
7
+ renderPlatformShortcutLabelsShowcase,
8
+ } from "../test/fixtures/tui/platform-shortcut-labels-showcase";
9
+
10
+ const CANONICAL_COMMAND =
11
+ "bun packages/coding-agent/scripts/capture-platform-shortcut-labels-showcase.ts --output .gjc/qa/platform-shortcut-labels";
12
+ const CAPTURE_TOOL_VERSION = "platform-shortcut-labels-fixture-injected-platform-v1";
13
+ const EXPECTED_KEYS = [
14
+ "darwin/composer-idle/80x24/unicode-color",
15
+ "darwin/composer-idle/120x36/unicode-color",
16
+ "darwin/composer-idle/160x48/unicode-color",
17
+ "darwin/composer-busy-effective-queue-remap/80x24/unicode-color",
18
+ "darwin/composer-busy-effective-queue-remap/120x36/unicode-color",
19
+ "darwin/composer-busy-effective-queue-remap/160x48/unicode-color",
20
+ "darwin/status-effective-remap-unbound/80x24/unicode-color",
21
+ "darwin/status-effective-remap-unbound/120x36/unicode-color",
22
+ "darwin/status-effective-remap-unbound/160x48/unicode-color",
23
+ "darwin/welcome-flow/80x24/unicode-color",
24
+ "darwin/welcome-flow/120x36/unicode-color",
25
+ "darwin/welcome-flow/160x48/unicode-color",
26
+ "win32/composer-idle/80x24/unicode-color",
27
+ "win32/composer-idle/120x36/unicode-color",
28
+ "win32/composer-busy-effective-queue-remap/80x24/unicode-color",
29
+ "win32/composer-busy-effective-queue-remap/120x36/unicode-color",
30
+ "win32/status-effective-remap-unbound/80x24/unicode-color",
31
+ "win32/status-effective-remap-unbound/120x36/unicode-color",
32
+ "win32/welcome-flow/80x24/unicode-color",
33
+ "win32/welcome-flow/120x36/unicode-color",
34
+ "linux/composer-idle/80x24/unicode-color",
35
+ "linux/composer-idle/120x36/unicode-color",
36
+ "linux/composer-busy-effective-queue-remap/80x24/unicode-color",
37
+ "linux/composer-busy-effective-queue-remap/120x36/unicode-color",
38
+ "linux/status-effective-remap-unbound/80x24/unicode-color",
39
+ "linux/status-effective-remap-unbound/120x36/unicode-color",
40
+ "linux/welcome-flow/80x24/unicode-color",
41
+ "linux/welcome-flow/120x36/unicode-color",
42
+ "darwin/composer-idle/80x24/ascii-no-color",
43
+ "darwin/composer-busy-effective-queue-remap/80x24/ascii-no-color",
44
+ "darwin/status-effective-remap-unbound/80x24/ascii-no-color",
45
+ "darwin/welcome-flow/80x24/ascii-no-color",
46
+ "darwin/status-effective-remap-unbound/48x36/unicode-color",
47
+ "darwin/welcome-flow/48x36/unicode-color",
48
+ ] as const;
49
+
50
+ type ArtifactFile = { path: string; sha256: string; byte_length: number };
51
+ type ManifestEntry = {
52
+ key: string;
53
+ platform: string;
54
+ surface: string;
55
+ viewport: { id: string; columns: number; rows: number };
56
+ render_mode: string;
57
+ capture_mode: "fixture-injected-platform";
58
+ files: ArtifactFile[];
59
+ };
60
+
61
+ function usage(): never {
62
+ throw new Error(`Usage: ${CANONICAL_COMMAND}`);
63
+ }
64
+ function outputPath(args: string[]): string {
65
+ if (args.length !== 2 || args[0] !== "--output" || !args[1]) usage();
66
+ return args[1];
67
+ }
68
+ function json(value: unknown): string {
69
+ return `${JSON.stringify(value, null, 2)}\n`;
70
+ }
71
+ function sha256(value: string): string {
72
+ return new Bun.CryptoHasher("sha256").update(value).digest("hex");
73
+ }
74
+ function escapeHtml(value: string): string {
75
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
76
+ }
77
+
78
+ type AnsiStyle = {
79
+ foreground?: string;
80
+ background?: string;
81
+ bold?: boolean;
82
+ dim?: boolean;
83
+ italic?: boolean;
84
+ underline?: boolean;
85
+ inverse?: boolean;
86
+ };
87
+
88
+ const ANSI_COLORS: Record<number, string> = {
89
+ 30: "#000000",
90
+ 31: "#cc0000",
91
+ 32: "#4e9a06",
92
+ 33: "#c4a000",
93
+ 34: "#3465a4",
94
+ 35: "#75507b",
95
+ 36: "#06989a",
96
+ 37: "#d3d7cf",
97
+ 90: "#555753",
98
+ 91: "#ef2929",
99
+ 92: "#8ae234",
100
+ 93: "#fce94f",
101
+ 94: "#729fcf",
102
+ 95: "#ad7fa8",
103
+ 96: "#34e2e2",
104
+ 97: "#eeeeec",
105
+ };
106
+
107
+ function ansi256Color(index: number): string {
108
+ if (index < 16) return ANSI_COLORS[index < 8 ? index + 30 : index + 82] ?? "#ffffff";
109
+ if (index >= 232) {
110
+ const value = (index - 232) * 10 + 8;
111
+ return `rgb(${value},${value},${value})`;
112
+ }
113
+ const value = index - 16;
114
+ const red = Math.floor(value / 36);
115
+ const green = Math.floor((value % 36) / 6);
116
+ const blue = value % 6;
117
+ const channel = (component: number) => (component === 0 ? 0 : component * 40 + 55);
118
+ return `rgb(${channel(red)},${channel(green)},${channel(blue)})`;
119
+ }
120
+
121
+ function styleAttribute(style: AnsiStyle): string {
122
+ const declarations: string[] = [];
123
+ if (style.foreground) declarations.push(`color:${style.foreground}`);
124
+ if (style.background) declarations.push(`background-color:${style.background}`);
125
+ if (style.bold) declarations.push("font-weight:700");
126
+ if (style.dim) declarations.push("opacity:.65");
127
+ if (style.italic) declarations.push("font-style:italic");
128
+ if (style.underline) declarations.push("text-decoration:underline");
129
+ if (style.inverse) declarations.push("filter:invert(1)");
130
+ return declarations.join(";");
131
+ }
132
+
133
+ const NON_VISUAL_TERMINAL_CONTROL = /\x1b_[^\x1b\x07]*(?:\x07|\x1b\\)/g;
134
+
135
+ /** Render emitted SGR styles as safe inline CSS without retaining terminal control codes. */
136
+ function ansiToHtml(value: string): string {
137
+ const visibleText = value.replace(NON_VISUAL_TERMINAL_CONTROL, "");
138
+ const sgr = /\x1b\[([0-9;]*)m/g;
139
+ let body = "";
140
+ let offset = 0;
141
+ let spanOpen = false;
142
+ let style: AnsiStyle = {};
143
+ const close = () => {
144
+ if (!spanOpen) return;
145
+ body += "</span>";
146
+ spanOpen = false;
147
+ };
148
+ const open = () => {
149
+ const attribute = styleAttribute(style);
150
+ if (!attribute) return;
151
+ body += `<span style="${attribute}">`;
152
+ spanOpen = true;
153
+ };
154
+
155
+ for (const match of visibleText.matchAll(sgr)) {
156
+ body += escapeHtml(visibleText.slice(offset, match.index));
157
+ offset = (match.index ?? 0) + match[0].length;
158
+ close();
159
+ const codes = (match[1] || "0").split(";").map(Number);
160
+ for (let index = 0; index < codes.length; index += 1) {
161
+ const code = codes[index];
162
+ if (code === 0) style = {};
163
+ else if (code === 1) style.bold = true;
164
+ else if (code === 2) style.dim = true;
165
+ else if (code === 3) style.italic = true;
166
+ else if (code === 4) style.underline = true;
167
+ else if (code === 7) style.inverse = true;
168
+ else if (code === 22) {
169
+ style.bold = false;
170
+ style.dim = false;
171
+ } else if (code === 23) style.italic = false;
172
+ else if (code === 24) style.underline = false;
173
+ else if (code === 27) style.inverse = false;
174
+ else if (code === 39) style.foreground = undefined;
175
+ else if (code === 49) style.background = undefined;
176
+ else if (code in ANSI_COLORS) style.foreground = ANSI_COLORS[code];
177
+ else if (code >= 40 && code <= 47) style.background = ANSI_COLORS[code - 10];
178
+ else if (code >= 100 && code <= 107) style.background = ANSI_COLORS[code - 10];
179
+ else if (code === 38 || code === 48) {
180
+ const colorMode = codes[index + 1];
181
+ if (colorMode === 2) {
182
+ const red = codes[index + 2];
183
+ const green = codes[index + 3];
184
+ const blue = codes[index + 4];
185
+ if ([red, green, blue].every(Number.isInteger)) {
186
+ if (code === 38) style.foreground = `rgb(${red},${green},${blue})`;
187
+ else style.background = `rgb(${red},${green},${blue})`;
188
+ }
189
+ index += 4;
190
+ } else if (colorMode === 5 && Number.isInteger(codes[index + 2])) {
191
+ if (code === 38) style.foreground = ansi256Color(codes[index + 2]!);
192
+ else style.background = ansi256Color(codes[index + 2]!);
193
+ index += 2;
194
+ }
195
+ }
196
+ }
197
+ open();
198
+ }
199
+ body += escapeHtml(visibleText.slice(offset));
200
+ close();
201
+ return `<!doctype html>\n<html lang="en"><head><meta charset="utf-8"><meta name="color-scheme" content="dark"><title>Platform shortcut labels showcase</title><style>body{margin:0;background:#110b0b;color:#ffe7dc;overflow:auto}pre{margin:0;padding:1em;white-space:pre;font-family:ui-monospace,monospace;line-height:1.2}</style></head><body><pre>${body}</pre></body></html>\n`;
202
+ }
203
+ function validateMatrix(entries: readonly PlatformShortcutLabelsShowcaseEntry[]): void {
204
+ if (PLATFORM_SHORTCUT_LABELS_SHOWCASE_EXPECTED_ENTRY_COUNT !== 34)
205
+ throw new Error("Expected showcase entry count must remain 34");
206
+ if (entries.length !== PLATFORM_SHORTCUT_LABELS_SHOWCASE_EXPECTED_ENTRY_COUNT)
207
+ throw new Error(`Showcase matrix changed: expected 34 entries, received ${entries.length}`);
208
+ const actual = entries.map(entry => entry.key);
209
+ if (new Set(actual).size !== actual.length) throw new Error("Showcase matrix contains duplicate entry keys");
210
+ const expected = new Set<string>(EXPECTED_KEYS);
211
+ const missing = EXPECTED_KEYS.filter(key => !actual.includes(key));
212
+ const surplus = actual.filter(key => !expected.has(key));
213
+ if (missing.length || surplus.length || actual.some((key, index) => key !== EXPECTED_KEYS[index]))
214
+ throw new Error(
215
+ `Showcase matrix keys differ; missing=${missing.join(",") || "none"}; surplus=${surplus.join(",") || "none"}`,
216
+ );
217
+ }
218
+ async function writeArtifact(filePath: string, content: string, outputRoot: string): Promise<ArtifactFile> {
219
+ await Bun.write(filePath, content);
220
+ return {
221
+ path: path.relative(outputRoot, filePath).split(path.sep).join("/"),
222
+ sha256: sha256(content),
223
+ byte_length: Buffer.byteLength(content, "utf8"),
224
+ };
225
+ }
226
+ async function captureEntry(
227
+ entry: PlatformShortcutLabelsShowcaseEntry,
228
+ outputRoot: string,
229
+ capturedAt: string,
230
+ ): Promise<ManifestEntry> {
231
+ const rendered = await renderPlatformShortcutLabelsShowcase(entry);
232
+ const directory = path.join(outputRoot, entry.platform, entry.surface, entry.viewport.id, entry.renderMode);
233
+ await fs.mkdir(directory, { recursive: true });
234
+ const html = ansiToHtml(rendered.terminalAnsiText);
235
+ const metadata = json({
236
+ schema_version: 1,
237
+ entry_key: entry.key,
238
+ platform: entry.platform,
239
+ viewport: entry.viewport,
240
+ render_mode: entry.renderMode,
241
+ capture_mode: rendered.captureMode,
242
+ platform_provenance: rendered.platformProvenance,
243
+ key_display_context: rendered.keyDisplayContext,
244
+ components: rendered.components,
245
+ capture_timestamp: capturedAt,
246
+ command_or_replay_source: CANONICAL_COMMAND,
247
+ fixture_source: "packages/coding-agent/test/fixtures/tui/platform-shortcut-labels-showcase.ts",
248
+ tool_version: CAPTURE_TOOL_VERSION,
249
+ terminal: {
250
+ columns: entry.viewport.columns,
251
+ rows: entry.viewport.rows,
252
+ font_rendering_assumptions:
253
+ "Embedded red-claw truecolor theme; HTML uses a monospace terminal fallback stack.",
254
+ wrapping_policy:
255
+ "Real components render at the recorded terminal-cell width; CJK content is retained for width review.",
256
+ ansi_control_semantics:
257
+ "terminal-ansi.txt preserves emitted SGR sequences; terminal.txt strips them; ascii-no-color strips styling only.",
258
+ },
259
+ provenance: {
260
+ platform: "fixture-injected-platform",
261
+ live_capture: false,
262
+ native_platform_claim: entry.platform === "darwin" ? "none (fixture only)" : "none",
263
+ },
264
+ fixed_clock_timestamp: rendered.fixedClockTimestamp,
265
+ });
266
+ const files = await Promise.all([
267
+ writeArtifact(path.join(directory, "terminal.txt"), rendered.terminalText, outputRoot),
268
+ writeArtifact(path.join(directory, "terminal-ansi.txt"), rendered.terminalAnsiText, outputRoot),
269
+ writeArtifact(path.join(directory, "terminal.html"), html, outputRoot),
270
+ writeArtifact(path.join(directory, "metadata.json"), metadata, outputRoot),
271
+ ]);
272
+ return {
273
+ key: entry.key,
274
+ platform: entry.platform,
275
+ surface: entry.surface,
276
+ viewport: entry.viewport,
277
+ render_mode: entry.renderMode,
278
+ capture_mode: rendered.captureMode,
279
+ files,
280
+ };
281
+ }
282
+ async function main(): Promise<void> {
283
+ const root = path.resolve(outputPath(process.argv.slice(2)));
284
+ const capturedAt = new Date().toISOString();
285
+ validateMatrix(PLATFORM_SHORTCUT_LABELS_SHOWCASE_ENTRIES);
286
+ await fs.mkdir(root, { recursive: true });
287
+ const entries: ManifestEntry[] = [];
288
+ for (const entry of PLATFORM_SHORTCUT_LABELS_SHOWCASE_ENTRIES)
289
+ entries.push(await captureEntry(entry, root, capturedAt));
290
+ const manifest = json({
291
+ schema_version: 1,
292
+ capture_tool: CAPTURE_TOOL_VERSION,
293
+ capture_mode: "fixture-injected-platform",
294
+ command: CANONICAL_COMMAND,
295
+ capture_timestamp: capturedAt,
296
+ expected_entry_count: 34,
297
+ entry_count: entries.length,
298
+ ordered_keys: EXPECTED_KEYS,
299
+ provenance: "fixture-injected-platform",
300
+ review_input_file: "visual-review-input.json",
301
+ entries,
302
+ });
303
+ const manifestSha256 = sha256(manifest);
304
+ await Bun.write(path.join(root, "manifest.json"), manifest);
305
+ await Bun.write(
306
+ path.join(root, "visual-review-input.json"),
307
+ json({
308
+ schema_version: 1,
309
+ manifest_sha256: manifestSha256,
310
+ expected_manifest_entries: 34,
311
+ ordered_keys: EXPECTED_KEYS,
312
+ evidence_scope: {
313
+ component_surface: "Real CustomEditor, StatusLineComponent, and WelcomeComponent rendering.",
314
+ operations_boundary: "Fixed clock, in-memory settings, and explicit injected KeyDisplayContext platform.",
315
+ external_effects: "No network, filesystem settings, daemon, or live native platform capture is invoked.",
316
+ },
317
+ review_requirements: [
318
+ "Inspect every recorded key.",
319
+ "Confirm Darwin glyphs and ASCII/no-color variants retain the same labels.",
320
+ "Confirm CJK and terminal-cell width evidence in both 48x36 entries.",
321
+ "Confirm all platform provenance is fixture-injected-platform.",
322
+ ],
323
+ required_feature_cases: [
324
+ {
325
+ id: "darwin-composer",
326
+ entry_key: "darwin/composer-idle/80x24/unicode-color",
327
+ focus: "Darwin modifier and Enter glyph labels.",
328
+ },
329
+ {
330
+ id: "effective-remap",
331
+ entry_key: "darwin/status-effective-remap-unbound/80x24/unicode-color",
332
+ focus: "Effective remap and unbound action labels.",
333
+ },
334
+ { id: "cjk-width", entry_key: "darwin/welcome-flow/48x36/unicode-color", focus: "CJK width and wrapping." },
335
+ ],
336
+ }),
337
+ );
338
+ process.stdout.write(
339
+ `Captured ${entries.length} deterministic platform shortcut showcase entries to ${root}\nmanifest.json sha256: ${manifestSha256}\n`,
340
+ );
341
+ }
342
+ await main();