@xortex/xcode 3.0.8 → 3.1.1

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 (57) hide show
  1. package/bin/xcode +33 -85
  2. package/bootstrap/state.ts +1758 -0
  3. package/context/QueuedMessageContext.tsx +63 -0
  4. package/context/fpsMetrics.tsx +30 -0
  5. package/context/mailbox.tsx +38 -0
  6. package/context/modalContext.tsx +58 -0
  7. package/context/notifications.tsx +240 -0
  8. package/context/overlayContext.tsx +151 -0
  9. package/context/promptOverlayContext.tsx +125 -0
  10. package/context/stats.tsx +220 -0
  11. package/context/voice.tsx +88 -0
  12. package/coordinator/coordinatorMode.ts +369 -0
  13. package/entrypoints/cli.tsx +1 -1
  14. package/ink.ts +85 -0
  15. package/interactiveHelpers.tsx +366 -0
  16. package/macro.ts +1 -1
  17. package/memdir/findRelevantMemories.ts +141 -0
  18. package/memdir/memdir.ts +511 -0
  19. package/memdir/memoryAge.ts +53 -0
  20. package/memdir/memoryScan.ts +94 -0
  21. package/memdir/memoryTypes.ts +271 -0
  22. package/memdir/paths.ts +291 -0
  23. package/memdir/teamMemPaths.ts +292 -0
  24. package/memdir/teamMemPrompts.ts +100 -0
  25. package/package.json +42 -28
  26. package/query/config.ts +46 -0
  27. package/query/deps.ts +40 -0
  28. package/query/stopHooks.ts +470 -0
  29. package/query/tokenBudget.ts +93 -0
  30. package/schemas/hooks.ts +222 -0
  31. package/screens/Doctor.tsx +575 -0
  32. package/screens/REPL.tsx +7107 -0
  33. package/screens/ResumeConversation.tsx +399 -0
  34. package/scripts/postinstall.js +90 -0
  35. package/setup.ts +477 -0
  36. package/tasks.ts +39 -0
  37. package/tools.ts +396 -0
  38. package/upstreamproxy/relay.ts +455 -0
  39. package/upstreamproxy/upstreamproxy.ts +285 -0
  40. package/voice/voiceModeEnabled.ts +54 -0
  41. package/inspect.js +0 -7
  42. package/patch-box.js +0 -54
  43. package/patch-compact.js +0 -13
  44. package/patch-condensed-center.js +0 -13
  45. package/patch-condensed-row.js +0 -13
  46. package/patch-condensed.js +0 -13
  47. package/patch-final.js +0 -58
  48. package/patch-input-body.js +0 -46
  49. package/patch-input-body2.js +0 -35
  50. package/patch-input-style.js +0 -13
  51. package/patch-input-width.js +0 -13
  52. package/patch-layout.js +0 -87
  53. package/patch-logo-row.js +0 -12
  54. package/patch-width.js +0 -13
  55. package/patch-width2.js +0 -13
  56. package/patch2.js +0 -74
  57. package/patch3.js +0 -13
@@ -0,0 +1,285 @@
1
+ /**
2
+ * CCR upstreamproxy — container-side wiring.
3
+ *
4
+ * When running inside a CCR session container with upstreamproxy configured,
5
+ * this module:
6
+ * 1. Reads the session token from /run/ccr/session_token
7
+ * 2. Sets prctl(PR_SET_DUMPABLE, 0) to block same-UID ptrace of the heap
8
+ * 3. Downloads the upstreamproxy CA cert and concatenates it with the
9
+ * system bundle so curl/gh/python trust the MITM proxy
10
+ * 4. Starts a local CONNECT→WebSocket relay (see relay.ts)
11
+ * 5. Unlinks the token file (token stays heap-only; file is gone before
12
+ * the agent loop can see it, but only after the relay is confirmed up
13
+ * so a supervisor restart can retry)
14
+ * 6. Exposes HTTPS_PROXY / SSL_CERT_FILE env vars for all agent subprocesses
15
+ *
16
+ * Every step fails open: any error logs a warning and disables the proxy.
17
+ * A broken proxy setup must never break an otherwise-working session.
18
+ *
19
+ * Design doc: api-go/ccr/docs/plans/CCR_AUTH_DESIGN.md § "Week-1 pilot scope".
20
+ */
21
+
22
+ import { mkdir, readFile, unlink, writeFile } from 'fs/promises'
23
+ import { homedir } from 'os'
24
+ import { join } from 'path'
25
+ import { registerCleanup } from '../utils/cleanupRegistry.js'
26
+ import { logForDebugging } from '../utils/debug.js'
27
+ import { isEnvTruthy } from '../utils/envUtils.js'
28
+ import { isENOENT } from '../utils/errors.js'
29
+ import { startUpstreamProxyRelay } from './relay.js'
30
+
31
+ export const SESSION_TOKEN_PATH = '/run/ccr/session_token'
32
+ const SYSTEM_CA_BUNDLE = '/etc/ssl/certs/ca-certificates.crt'
33
+
34
+ // Hosts the proxy must NOT intercept. Covers loopback, RFC1918, the IMDS
35
+ // range, and the package registries + GitHub that CCR containers already
36
+ // reach directly. Mirrors airlock/scripts/sandbox-shell-ccr.sh.
37
+ const NO_PROXY_LIST = [
38
+ 'localhost',
39
+ '127.0.0.1',
40
+ '::1',
41
+ '169.254.0.0/16',
42
+ '10.0.0.0/8',
43
+ '172.16.0.0/12',
44
+ '192.168.0.0/16',
45
+ // Anthropic API: no upstream route will ever match, and the MITM breaks
46
+ // non-Bun runtimes (Python httpx/certifi doesn't trust the forged CA).
47
+ // Three forms because NO_PROXY parsing differs across runtimes:
48
+ // *.googleapis.com — Bun, curl, Go (glob match)
49
+ // .googleapis.com — Python urllib/httpx (suffix match, strips leading dot)
50
+ // googleapis.com — apex domain fallback
51
+ 'googleapis.com',
52
+ '.googleapis.com',
53
+ '*.googleapis.com',
54
+ 'github.com',
55
+ 'api.github.com',
56
+ '*.github.com',
57
+ '*.githubusercontent.com',
58
+ 'registry.npmjs.org',
59
+ 'pypi.org',
60
+ 'files.pythonhosted.org',
61
+ 'index.crates.io',
62
+ 'proxy.golang.org',
63
+ ].join(',')
64
+
65
+ type UpstreamProxyState = {
66
+ enabled: boolean
67
+ port?: number
68
+ caBundlePath?: string
69
+ }
70
+
71
+ let state: UpstreamProxyState = { enabled: false }
72
+
73
+ /**
74
+ * Initialize upstreamproxy. Called once from init.ts. Safe to call when the
75
+ * feature is off or the token file is absent — returns {enabled: false}.
76
+ *
77
+ * Overridable paths are for tests; production uses the defaults.
78
+ */
79
+ export async function initUpstreamProxy(opts?: {
80
+ tokenPath?: string
81
+ systemCaPath?: string
82
+ caBundlePath?: string
83
+ ccrBaseUrl?: string
84
+ }): Promise<UpstreamProxyState> {
85
+ if (!isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
86
+ return state
87
+ }
88
+ // CCR evaluates ccr_upstream_proxy_enabled server-side (where GrowthBook is
89
+ // warm) and injects this env var via StartupContext.EnvironmentVariables.
90
+ // Every CCR session is a fresh container with no GB cache, so a client-side
91
+ // GB check here always returned the default (false).
92
+ if (!isEnvTruthy(process.env.CCR_UPSTREAM_PROXY_ENABLED)) {
93
+ return state
94
+ }
95
+
96
+ const sessionId = process.env.CLAUDE_CODE_REMOTE_SESSION_ID
97
+ if (!sessionId) {
98
+ logForDebugging(
99
+ '[upstreamproxy] CLAUDE_CODE_REMOTE_SESSION_ID unset; proxy disabled',
100
+ { level: 'warn' },
101
+ )
102
+ return state
103
+ }
104
+
105
+ const tokenPath = opts?.tokenPath ?? SESSION_TOKEN_PATH
106
+ const token = await readToken(tokenPath)
107
+ if (!token) {
108
+ logForDebugging('[upstreamproxy] no session token file; proxy disabled')
109
+ return state
110
+ }
111
+
112
+ setNonDumpable()
113
+
114
+ // CCR injects ANTHROPIC_BASE_URL via StartupContext (sessionExecutor.ts /
115
+ // sessionHandler.ts). getOauthConfig() is wrong here: it keys off
116
+ // USER_TYPE + USE_{LOCAL,STAGING}_OAUTH, none of which the container sets,
117
+ // so it always returned the prod URL and the CA fetch 404'd.
118
+ const baseUrl =
119
+ opts?.ccrBaseUrl ??
120
+ process.env.ANTHROPIC_BASE_URL ??
121
+ 'https://api.anthropic.com'
122
+ const caBundlePath =
123
+ opts?.caBundlePath ?? join(homedir(), '.ccr', 'ca-bundle.crt')
124
+
125
+ const caOk = await downloadCaBundle(
126
+ baseUrl,
127
+ opts?.systemCaPath ?? SYSTEM_CA_BUNDLE,
128
+ caBundlePath,
129
+ )
130
+ if (!caOk) return state
131
+
132
+ try {
133
+ const wsUrl = baseUrl.replace(/^http/, 'ws') + '/v1/code/upstreamproxy/ws'
134
+ const relay = await startUpstreamProxyRelay({ wsUrl, sessionId, token })
135
+ registerCleanup(async () => relay.stop())
136
+ state = { enabled: true, port: relay.port, caBundlePath }
137
+ logForDebugging(`[upstreamproxy] enabled on 127.0.0.1:${relay.port}`)
138
+ // Only unlink after the listener is up: if CA download or listen()
139
+ // fails, a supervisor restart can retry with the token still on disk.
140
+ await unlink(tokenPath).catch(() => {
141
+ logForDebugging('[upstreamproxy] token file unlink failed', {
142
+ level: 'warn',
143
+ })
144
+ })
145
+ } catch (err) {
146
+ logForDebugging(
147
+ `[upstreamproxy] relay start failed: ${err instanceof Error ? err.message : String(err)}; proxy disabled`,
148
+ { level: 'warn' },
149
+ )
150
+ }
151
+
152
+ return state
153
+ }
154
+
155
+ /**
156
+ * Env vars to merge into every agent subprocess. Empty when the proxy is
157
+ * disabled. Called from subprocessEnv() so Bash/MCP/LSP/hooks all inherit
158
+ * the same recipe.
159
+ */
160
+ export function getUpstreamProxyEnv(): Record<string, string> {
161
+ if (!state.enabled || !state.port || !state.caBundlePath) {
162
+ // Child CLI processes can't re-initialize the relay (token file was
163
+ // unlinked by the parent), but the parent's relay is still running and
164
+ // reachable at 127.0.0.1:<port>. If we inherited proxy vars from the
165
+ // parent (HTTPS_PROXY + SSL_CERT_FILE both set), pass them through so
166
+ // our subprocesses also route through the parent's relay.
167
+ if (process.env.HTTPS_PROXY && process.env.SSL_CERT_FILE) {
168
+ const inherited: Record<string, string> = {}
169
+ for (const key of [
170
+ 'HTTPS_PROXY',
171
+ 'https_proxy',
172
+ 'NO_PROXY',
173
+ 'no_proxy',
174
+ 'SSL_CERT_FILE',
175
+ 'NODE_EXTRA_CA_CERTS',
176
+ 'REQUESTS_CA_BUNDLE',
177
+ 'CURL_CA_BUNDLE',
178
+ ]) {
179
+ if (process.env[key]) inherited[key] = process.env[key]
180
+ }
181
+ return inherited
182
+ }
183
+ return {}
184
+ }
185
+ const proxyUrl = `http://127.0.0.1:${state.port}`
186
+ // HTTPS only: the relay handles CONNECT and nothing else. Plain HTTP has
187
+ // no credentials to inject, so routing it through the relay would just
188
+ // break the request with a 405.
189
+ return {
190
+ HTTPS_PROXY: proxyUrl,
191
+ https_proxy: proxyUrl,
192
+ NO_PROXY: NO_PROXY_LIST,
193
+ no_proxy: NO_PROXY_LIST,
194
+ SSL_CERT_FILE: state.caBundlePath,
195
+ NODE_EXTRA_CA_CERTS: state.caBundlePath,
196
+ REQUESTS_CA_BUNDLE: state.caBundlePath,
197
+ CURL_CA_BUNDLE: state.caBundlePath,
198
+ }
199
+ }
200
+
201
+ /** Test-only: reset module state between test cases. */
202
+ export function resetUpstreamProxyForTests(): void {
203
+ state = { enabled: false }
204
+ }
205
+
206
+ async function readToken(path: string): Promise<string | null> {
207
+ try {
208
+ const raw = await readFile(path, 'utf8')
209
+ return raw.trim() || null
210
+ } catch (err) {
211
+ if (isENOENT(err)) return null
212
+ logForDebugging(
213
+ `[upstreamproxy] token read failed: ${err instanceof Error ? err.message : String(err)}`,
214
+ { level: 'warn' },
215
+ )
216
+ return null
217
+ }
218
+ }
219
+
220
+ /**
221
+ * prctl(PR_SET_DUMPABLE, 0) via libc FFI. Blocks same-UID ptrace of this
222
+ * process, so a prompt-injected `gdb -p $PPID` can't scrape the token from
223
+ * the heap. Linux-only; silently no-ops elsewhere.
224
+ */
225
+ function setNonDumpable(): void {
226
+ if (process.platform !== 'linux' || typeof Bun === 'undefined') return
227
+ try {
228
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
229
+ const ffi = require('bun:ffi') as typeof import('bun:ffi')
230
+ const lib = ffi.dlopen('libc.so.6', {
231
+ prctl: {
232
+ args: ['int', 'u64', 'u64', 'u64', 'u64'],
233
+ returns: 'int',
234
+ },
235
+ } as const)
236
+ const PR_SET_DUMPABLE = 4
237
+ const rc = lib.symbols.prctl(PR_SET_DUMPABLE, 0n, 0n, 0n, 0n)
238
+ if (rc !== 0) {
239
+ logForDebugging(
240
+ '[upstreamproxy] prctl(PR_SET_DUMPABLE,0) returned nonzero',
241
+ {
242
+ level: 'warn',
243
+ },
244
+ )
245
+ }
246
+ } catch (err) {
247
+ logForDebugging(
248
+ `[upstreamproxy] prctl unavailable: ${err instanceof Error ? err.message : String(err)}`,
249
+ { level: 'warn' },
250
+ )
251
+ }
252
+ }
253
+
254
+ async function downloadCaBundle(
255
+ baseUrl: string,
256
+ systemCaPath: string,
257
+ outPath: string,
258
+ ): Promise<boolean> {
259
+ try {
260
+ // eslint-disable-next-line eslint-plugin-n/no-unsupported-features/node-builtins
261
+ const resp = await fetch(`${baseUrl}/v1/code/upstreamproxy/ca-cert`, {
262
+ // Bun has no default fetch timeout — a hung endpoint would block CLI
263
+ // startup forever. 5s is generous for a small PEM.
264
+ signal: AbortSignal.timeout(5000),
265
+ })
266
+ if (!resp.ok) {
267
+ logForDebugging(
268
+ `[upstreamproxy] ca-cert fetch ${resp.status}; proxy disabled`,
269
+ { level: 'warn' },
270
+ )
271
+ return false
272
+ }
273
+ const ccrCa = await resp.text()
274
+ const systemCa = await readFile(systemCaPath, 'utf8').catch(() => '')
275
+ await mkdir(join(outPath, '..'), { recursive: true })
276
+ await writeFile(outPath, systemCa + '\n' + ccrCa, 'utf8')
277
+ return true
278
+ } catch (err) {
279
+ logForDebugging(
280
+ `[upstreamproxy] ca-cert download failed: ${err instanceof Error ? err.message : String(err)}; proxy disabled`,
281
+ { level: 'warn' },
282
+ )
283
+ return false
284
+ }
285
+ }
@@ -0,0 +1,54 @@
1
+ import { feature } from 'bun:bundle'
2
+ import { getFeatureValue_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js'
3
+ import {
4
+ getClaudeAIOAuthTokens,
5
+ isAnthropicAuthEnabled,
6
+ } from '../utils/auth.js'
7
+
8
+ /**
9
+ * Kill-switch check for voice mode. Returns true unless the
10
+ * `tengu_amber_quartz_disabled` GrowthBook flag is flipped on (emergency
11
+ * off). Default `false` means a missing/stale disk cache reads as "not
12
+ * killed" — so fresh installs get voice working immediately without
13
+ * waiting for GrowthBook init. Use this for deciding whether voice mode
14
+ * should be *visible* (e.g., command registration, config UI).
15
+ */
16
+ export function isVoiceGrowthBookEnabled(): boolean {
17
+ // Positive ternary pattern — see docs/feature-gating.md.
18
+ // Negative pattern (if (!feature(...)) return) does not eliminate
19
+ // inline string literals from external builds.
20
+ return feature('VOICE_MODE')
21
+ ? !getFeatureValue_CACHED_MAY_BE_STALE('tengu_amber_quartz_disabled', false)
22
+ : false
23
+ }
24
+
25
+ /**
26
+ * Auth-only check for voice mode. Returns true when the user has a valid
27
+ * Anthropic OAuth token. Backed by the memoized getClaudeAIOAuthTokens —
28
+ * first call spawns `security` on macOS (~20-50ms), subsequent calls are
29
+ * cache hits. The memoize clears on token refresh (~once/hour), so one
30
+ * cold spawn per refresh is expected. Cheap enough for usage-time checks.
31
+ */
32
+ export function hasVoiceAuth(): boolean {
33
+ // Voice mode requires Anthropic OAuth — it uses the voice_stream
34
+ // endpoint on claude.ai which is not available with API keys,
35
+ // Bedrock, Vertex, or Foundry.
36
+ if (!isAnthropicAuthEnabled()) {
37
+ return false
38
+ }
39
+ // isAnthropicAuthEnabled only checks the auth *provider*, not whether
40
+ // a token exists. Without this check, the voice UI renders but
41
+ // connectVoiceStream fails silently when the user isn't logged in.
42
+ const tokens = getClaudeAIOAuthTokens()
43
+ return Boolean(tokens?.accessToken)
44
+ }
45
+
46
+ /**
47
+ * Full runtime check: auth + GrowthBook kill-switch. Callers: `/voice`
48
+ * (voice.ts, voice/index.ts), ConfigTool, VoiceModeNotice — command-time
49
+ * paths where a fresh keychain read is acceptable. For React render
50
+ * paths use useVoiceEnabled() instead (memoizes the auth half).
51
+ */
52
+ export function isVoiceModeEnabled(): boolean {
53
+ return hasVoiceAuth() && isVoiceGrowthBookEnabled()
54
+ }
package/inspect.js DELETED
@@ -1,7 +0,0 @@
1
- const fs = require('fs');
2
- const inputPath = 'components/PromptInput/PromptInput.tsx';
3
- const src = fs.readFileSync(inputPath, 'utf8');
4
-
5
- // Extract the prompt rendering logic to understand it
6
- const match = src.match(/borderLeft=\{messages\.length === 0.*?(?=minHeight=\{messages\.length)/s);
7
- console.log(match ? match[0] : "Not found");
package/patch-box.js DELETED
@@ -1,54 +0,0 @@
1
- const fs = require('fs');
2
- const inputPath = 'components/PromptInput/PromptInput.tsx';
3
- let src = fs.readFileSync(inputPath, 'utf8');
4
-
5
- // Replace the complicated border logic with a cleaner approach for the first prompt
6
- // By removing Ink's built-in borders, we can simulate the "blue left border" and "grey background" using a parent Box and children.
7
- const oldBoxRegex = /<Box flexDirection="row" alignItems="flex-start" justifyContent="flex-start" borderColor=\{messages\.length === 0 \? "#4285f4" : getBorderColor\(\)\} borderStyle=\{messages\.length === 0 \? "single" : "round"\} borderLeft=\{messages\.length === 0 \? true : false\} borderRight=\{false\} borderBottom=\{messages\.length === 0 \? false : true\} borderTop=\{messages\.length === 0 \? false : true\} backgroundColor=\{messages\.length === 0 \? "#1e1e1e" : undefined\} width=\{messages\.length === 0 \? Math\.floor\(columns \* 0\.6\) : "100%"\} alignSelf="center" borderText=\{messages\.length === 0 \? undefined : buildBorderText\(showFastIcon \?\? false, showFastIconHint, fastModeCooldown\)\} minHeight=\{messages\.length === 0 \? 2 : undefined\} paddingX=\{messages\.length === 0 \? 1 : 0\} paddingY=\{messages\.length === 0 \? 1 : 0\}>/g;
8
-
9
- // If we can't find it, let's just do a simpler replace by reading the file and replacing the specific Box string
10
- let targetPos = src.indexOf('<Box flexDirection="row" alignItems="flex-start" justifyContent="flex-start" borderColor={messages.length === 0 ? "#4285f4"');
11
- if (targetPos > -1) {
12
- let endPos = src.indexOf('>', targetPos);
13
-
14
- const newBox = `
15
- {messages.length === 0 ? (
16
- <Box flexDirection="row" width={Math.floor(columns * 0.6)} alignSelf="center" height={5}>
17
- <Box width={1} backgroundColor="blue" />
18
- <Box flexGrow={1} backgroundColor="#1e1e1e" flexDirection="row" paddingX={1}>
19
- <PromptInputModeIndicator mode={mode} isLoading={isLoading} viewingAgentName={viewingAgentName} viewingAgentColor={viewingAgentColor} />
20
- <Box flexGrow={1} flexShrink={1} flexDirection="column" onClick={handleInputClick}>
21
- <Box flexGrow={1} paddingTop={1}>{textInputElement}</Box>
22
- <Box paddingBottom={1}>
23
- <Text color="blue">Build </Text><Text dimColor>{modelDisplayName}</Text>
24
- </Box>
25
- </Box>
26
- </Box>
27
- </Box>
28
- ) : (
29
- <Box flexDirection="row" alignItems="flex-start" justifyContent="flex-start" borderColor={getBorderColor()} borderStyle="round" borderLeft={false} borderRight={false} borderBottom={true} width="100%" borderText={buildBorderText(showFastIcon ?? false, showFastIconHint, fastModeCooldown)}>
30
- <PromptInputModeIndicator mode={mode} isLoading={isLoading} viewingAgentName={viewingAgentName} viewingAgentColor={viewingAgentColor} />
31
- <Box flexGrow={1} flexShrink={1} flexDirection="column" onClick={handleInputClick}>
32
- <Box>{textInputElement}</Box>
33
- </Box>
34
- </Box>
35
- )}
36
- `;
37
-
38
- // Since we replaced the inner content too, we need to remove the original inner content.
39
- // The original inner content is:
40
- // <PromptInputModeIndicator ... />
41
- // <Box flexGrow={1} ... >
42
- // <Box minHeight={...}>{textInputElement}</Box>
43
- // ... Build modelDisplayName ...
44
- // </Box>
45
- // </Box>}
46
-
47
- const endOfBox = src.indexOf('</Box>}', targetPos);
48
-
49
- src = src.substring(0, targetPos - 4) + newBox + src.substring(endOfBox + 7);
50
- fs.writeFileSync(inputPath, src);
51
- console.log("Updated Box layout!");
52
- } else {
53
- console.log("Could not find the target Box!");
54
- }
package/patch-compact.js DELETED
@@ -1,13 +0,0 @@
1
- const fs = require('fs');
2
-
3
- const logoPath = 'components/LogoV2/LogoV2.tsx';
4
- let logoSrc = fs.readFileSync(logoPath, 'utf8');
5
-
6
- // Replace the compact layout return block
7
- logoSrc = logoSrc.replace(
8
- /<Text bold=\{true\}>\{welcomeMessage\}<\/Text>\{t12\}\{t13\}<Text dimColor=\{true\}>\{billingType\}<\/Text><Text dimColor=\{true\}>\{agentName \? \`@\$\{agentName\} · \$\{truncatedCwd\}\` : truncatedCwd\}<\/Text>/g,
9
- `{t12}<Text bold>X Code v3.0.0</Text><Text bold={true}>{welcomeMessage}</Text>`
10
- );
11
-
12
- fs.writeFileSync(logoPath, logoSrc);
13
- console.log("Patched compact layout!");
@@ -1,13 +0,0 @@
1
- const fs = require('fs');
2
-
3
- const condensedPath = 'components/LogoV2/CondensedLogo.tsx';
4
- let condensedSrc = fs.readFileSync(condensedPath, 'utf8');
5
-
6
- // Replace the return block for condensed logo to add width="100%"
7
- condensedSrc = condensedSrc.replace(
8
- /<OffscreenFreeze><Box flexDirection="column" alignItems="center">\{t4\}\{t6\}<Text bold>Welcome to Xcode now you can you have persistent memory\.<\/Text>\{t10\}\{t11\}<\/Box><\/OffscreenFreeze>/g,
9
- `<OffscreenFreeze><Box width="100%" flexDirection="column" alignItems="center">{t4}{t6}<Text bold align="center">Welcome to Xcode now you can you have persistent memory.</Text>{t10}{t11}</Box></OffscreenFreeze>`
10
- );
11
-
12
- fs.writeFileSync(condensedPath, condensedSrc);
13
- console.log("Patched CondensedLogo centering!");
@@ -1,13 +0,0 @@
1
- const fs = require('fs');
2
-
3
- const condensedPath = 'components/LogoV2/CondensedLogo.tsx';
4
- let condensedSrc = fs.readFileSync(condensedPath, 'utf8');
5
-
6
- // Replace the layout to put logo (t4) and text (t6) in a row
7
- condensedSrc = condensedSrc.replace(
8
- /<OffscreenFreeze><Box width="100%" flexDirection="column" alignItems="center">\{t4\}\{t6\}<Text bold align="center">Welcome to Xcode now you can you have persistent memory\.<\/Text>\{t10\}\{t11\}<\/Box><\/OffscreenFreeze>/g,
9
- `<OffscreenFreeze><Box width="100%" flexDirection="column" alignItems="center"><Box flexDirection="row" alignItems="center" gap={2}>{t4}{t6}</Box><Text bold align="center">Welcome to Xcode now you can you have persistent memory.</Text>{t10}{t11}</Box></OffscreenFreeze>`
10
- );
11
-
12
- fs.writeFileSync(condensedPath, condensedSrc);
13
- console.log("Patched CondensedLogo side-by-side!");
@@ -1,13 +0,0 @@
1
- const fs = require('fs');
2
-
3
- const condensedPath = 'components/LogoV2/CondensedLogo.tsx';
4
- let condensedSrc = fs.readFileSync(condensedPath, 'utf8');
5
-
6
- // Replace the return block for condensed logo
7
- condensedSrc = condensedSrc.replace(
8
- /<OffscreenFreeze><Box flexDirection="row" gap=\{2\} alignItems="center">\{t4\}<Box flexDirection="column">\{t6\}\{t7\}\{t9\}<Text bold>Welcome to Xcode now you can you have persistent memory\.<\/Text>\{t10\}\{t11\}<\/Box><\/Box><\/OffscreenFreeze>/g,
9
- `<OffscreenFreeze><Box flexDirection="column" alignItems="center">{t4}{t6}<Text bold>Welcome to Xcode now you can you have persistent memory.</Text>{t10}{t11}</Box></OffscreenFreeze>`
10
- );
11
-
12
- fs.writeFileSync(condensedPath, condensedSrc);
13
- console.log("Patched CondensedLogo!");
package/patch-final.js DELETED
@@ -1,58 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const inputPath = path.join(__dirname, 'components/PromptInput/PromptInput.tsx');
5
- let src = fs.readFileSync(inputPath, 'utf8');
6
-
7
- // 1. Inject model display name
8
- if (!src.includes('import { useMainLoopModel }')) {
9
- src = src.replace(
10
- "import { useInputBuffer } from '../../hooks/useInputBuffer.js';",
11
- "import { useInputBuffer } from '../../hooks/useInputBuffer.js';\nimport { useMainLoopModel } from '../../hooks/useMainLoopModel.js';\nimport { renderModelSetting } from '../../utils/model/model.js';\nimport { getEffortSuffix } from '../../utils/effort.js';"
12
- );
13
- }
14
-
15
- if (!src.includes('modelDisplayName = renderModelSetting')) {
16
- src = src.replace(
17
- /const maxVisibleLines = isFullscreenEnvEnabled\(\)/,
18
- `const _model = useMainLoopModel();
19
- const _effortValue = useAppState(function(s) { return s.effortValue; });
20
- const _effortSuffix = getEffortSuffix(_model, _effortValue);
21
- const modelDisplayName = renderModelSetting(_model) + _effortSuffix;
22
- const maxVisibleLines = isFullscreenEnvEnabled()`
23
- );
24
- }
25
-
26
- // 2. Replace the layout for messages.length === 0
27
- const targetBoxStr = /<Box flexDirection="row" alignItems="flex-start" justifyContent="flex-start" borderColor=\{getBorderColor\(\)\} borderStyle="round" borderLeft=\{false\} borderRight=\{false\} borderBottom width="100%" borderText=\{buildBorderText\(showFastIcon \?\? false, showFastIconHint, fastModeCooldown\)\} minHeight=\{messages\.length === 0 \? 5 : undefined\}>/g;
28
- if (targetBoxStr.test(src)) {
29
- src = src.replace(
30
- targetBoxStr,
31
- `{messages.length === 0 ? (
32
- <Box flexDirection="row" width={Math.floor(columns * 0.6)} alignSelf="center" height={5} borderStyle="round" borderColor="#4285f4" backgroundColor="#1e1e1e" paddingX={1}>
33
- <PromptInputModeIndicator mode={mode} isLoading={isLoading} viewingAgentName={viewingAgentName} viewingAgentColor={viewingAgentColor} />
34
- <Box flexGrow={1} flexShrink={1} flexDirection="column" onClick={handleInputClick}>
35
- <Box flexGrow={1} paddingTop={0}>{textInputElement}</Box>
36
- <Box paddingBottom={0}>
37
- <Text color="#4285f4">Build </Text><Text dimColor>Gemini 3.1 Pro Preview Google · medium</Text>
38
- </Box>
39
- </Box>
40
- </Box>
41
- ) : (
42
- <Box flexDirection="row" alignItems="flex-start" justifyContent="flex-start" borderColor={getBorderColor()} borderStyle="round" borderLeft={false} borderRight={false} borderBottom={true} width="100%" borderText={buildBorderText(showFastIcon ?? false, showFastIconHint, fastModeCooldown)}>
43
- `
44
- );
45
-
46
- const endBox = /<Box flexGrow=\{1\} flexShrink=\{1\} onClick=\{handleInputClick\}>\s*\{textInputElement\}\s*<\/Box>\s*<\/Box>\}/g;
47
- src = src.replace(
48
- endBox,
49
- `<Box flexGrow={1} flexShrink={1} flexDirection="column" onClick={handleInputClick}>
50
- <Box>{textInputElement}</Box>
51
- </Box>
52
- </Box>
53
- )}`
54
- );
55
- }
56
-
57
- fs.writeFileSync(inputPath, src);
58
- console.log('Applied final prompt input changes with rounded full border');
@@ -1,46 +0,0 @@
1
- const fs = require('fs');
2
- const inputPath = 'components/PromptInput/PromptInput.tsx';
3
- let src = fs.readFileSync(inputPath, 'utf8');
4
-
5
- // Inject the imports
6
- if (!src.includes('renderModelSetting')) {
7
- src = src.replace(
8
- "import { useMainLoopModel } from '../../hooks/useMainLoopModel.js';",
9
- "import { useMainLoopModel } from '../../hooks/useMainLoopModel.js';\nimport { renderModelSetting } from '../../utils/model/model.js';\nimport { getEffortSuffix } from '../../utils/effort.js';"
10
- );
11
- }
12
-
13
- // Inject the modelDisplayName computation in the component body
14
- if (!src.includes('modelDisplayName = renderModelSetting')) {
15
- src = src.replace(
16
- "const mode = isVimModeEnabled() ? vimMode : undefined;",
17
- `const mode = isVimModeEnabled() ? vimMode : undefined;
18
- const _model = useMainLoopModel();
19
- const _effortValue = useAppState(_temp2);
20
- const _effortSuffix = getEffortSuffix(_model, _effortValue);
21
- const modelDisplayName = renderModelSetting(_model) + _effortSuffix;`
22
- );
23
- }
24
-
25
- // Ensure _temp2 is defined. It probably is in LogoV2, but let's just make it a local inline function or use the direct selector `s => s.effortValue`.
26
- // Actually, `useAppState(s => s.effortValue)` might not work because the compiler compiled it. Let's just use an inline function `function(s) { return s.effortValue; }`.
27
- src = src.replace(
28
- `useAppState(_temp2)`,
29
- `useAppState(function(s) { return s.effortValue; })`
30
- );
31
-
32
- // Update the rendering box
33
- const oldRenderBox = /<Box flexGrow=\{1\} flexShrink=\{1\} onClick=\{handleInputClick\}>\s*\{textInputElement\}\s*<\/Box>/g;
34
- const newRenderBox = `<Box flexGrow={1} flexShrink={1} flexDirection="column" onClick={handleInputClick}>
35
- <Box minHeight={messages.length === 0 ? 3 : undefined}>{textInputElement}</Box>
36
- {messages.length === 0 && (
37
- <Box marginTop={1}>
38
- <Text color="blue">Build </Text><Text>{modelDisplayName}</Text>
39
- </Box>
40
- )}
41
- </Box>`;
42
-
43
- src = src.replace(oldRenderBox, newRenderBox);
44
-
45
- fs.writeFileSync(inputPath, src);
46
- console.log("Updated PromptInput rendering box!");
@@ -1,35 +0,0 @@
1
- const fs = require('fs');
2
- const inputPath = 'components/PromptInput/PromptInput.tsx';
3
- let src = fs.readFileSync(inputPath, 'utf8');
4
-
5
- // Inject the modelDisplayName computation right at the top of the PromptInput function body
6
- const funcStart = "function PromptInput({\n";
7
- const funcBodyStart = /\} = t0;\s*const debug = t1 === undefined \? false : t1;/;
8
-
9
- // We can just use string replacement on a known line inside the function
10
- if (!src.includes('modelDisplayName = renderModelSetting')) {
11
- src = src.replace(
12
- /const maxVisibleLines = isFullscreenEnvEnabled\(\)/,
13
- `const _model = useMainLoopModel();
14
- const _effortValue = useAppState(function(s) { return s.effortValue; });
15
- const _effortSuffix = getEffortSuffix(_model, _effortValue);
16
- const modelDisplayName = renderModelSetting(_model) + _effortSuffix;
17
- const maxVisibleLines = isFullscreenEnvEnabled()`
18
- );
19
- }
20
-
21
- // Update the rendering box
22
- const oldRenderBox = /<Box flexGrow=\{1\} flexShrink=\{1\} onClick=\{handleInputClick\}>\s*\{textInputElement\}\s*<\/Box>/g;
23
- const newRenderBox = `<Box flexGrow={1} flexShrink={1} flexDirection="column" onClick={handleInputClick}>
24
- <Box minHeight={messages.length === 0 ? 3 : undefined}>{textInputElement}</Box>
25
- {messages.length === 0 && (
26
- <Box marginTop={1}>
27
- <Text color="blue">Build </Text><Text>{modelDisplayName}</Text>
28
- </Box>
29
- )}
30
- </Box>`;
31
-
32
- src = src.replace(oldRenderBox, newRenderBox);
33
-
34
- fs.writeFileSync(inputPath, src);
35
- console.log("Updated PromptInput rendering box!");
@@ -1,13 +0,0 @@
1
- const fs = require('fs');
2
- const inputPath = 'components/PromptInput/PromptInput.tsx';
3
- let src = fs.readFileSync(inputPath, 'utf8');
4
-
5
- // The string we want to replace
6
- const targetStr = /borderColor=\{getBorderColor\(\)\} borderStyle="round" borderLeft=\{messages\.length === 0 \? true : false\} borderRight=\{messages\.length === 0 \? true : false\} borderBottom width=\{messages\.length === 0 \? Math\.floor\(columns \* 0\.5\) : "100%"\} alignSelf="center" borderText=\{buildBorderText\(showFastIcon \?\? false, showFastIconHint, fastModeCooldown\)\} minHeight=\{messages\.length === 0 \? 2 : undefined\}/;
7
-
8
- const newStr = `borderColor={messages.length === 0 ? "#4285f4" : getBorderColor()} borderStyle={messages.length === 0 ? "single" : "round"} borderLeft={messages.length === 0 ? true : false} borderRight={false} borderBottom={messages.length === 0 ? false : true} borderTop={messages.length === 0 ? false : true} backgroundColor={messages.length === 0 ? "#1e1e1e" : undefined} width={messages.length === 0 ? Math.floor(columns * 0.6) : "100%"} alignSelf="center" borderText={messages.length === 0 ? undefined : buildBorderText(showFastIcon ?? false, showFastIconHint, fastModeCooldown)} minHeight={messages.length === 0 ? 2 : undefined} paddingX={messages.length === 0 ? 1 : 0} paddingY={messages.length === 0 ? 1 : 0}`;
9
-
10
- src = src.replace(targetStr, newStr);
11
-
12
- fs.writeFileSync(inputPath, src);
13
- console.log("Updated PromptInput styling!");
@@ -1,13 +0,0 @@
1
- const fs = require('fs');
2
-
3
- const inputPath = 'components/PromptInput/PromptInput.tsx';
4
- let inputSrc = fs.readFileSync(inputPath, 'utf8');
5
-
6
- // Replace the width calculation
7
- inputSrc = inputSrc.replace(
8
- /borderLeft=\{messages\.length === 0 \? true : false\} borderRight=\{messages\.length === 0 \? true : false\} borderBottom width="100%" borderText=\{buildBorderText\(showFastIcon \?\? false, showFastIconHint, fastModeCooldown\)\} minHeight=\{messages\.length === 0 \? 2 : undefined\}/g,
9
- `borderLeft={messages.length === 0 ? true : false} borderRight={messages.length === 0 ? true : false} borderBottom width={messages.length === 0 ? Math.floor(columns * 0.5) : "100%"} alignSelf="center" borderText={buildBorderText(showFastIcon ?? false, showFastIconHint, fastModeCooldown)} minHeight={messages.length === 0 ? 2 : undefined}`
10
- );
11
-
12
- fs.writeFileSync(inputPath, inputSrc);
13
- console.log("Patched PromptInput width!");