Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

test: remove low-value catalog cases and source guard suites (#36175)

OrcaWin349f46f6084c
diff --git a/config/reliability-gates.jsonc b/config/reliability-gates.jsonc
index 9e40dff0e5e..3651eb8e150 100644
--- a/config/reliability-gates.jsonc
+++ b/config/reliability-gates.jsonc
@@ -9700,7 +9700,7 @@
"providers": ["local", "daemon", "ssh", "wsl", "remote-runtime"],
"coveredPlatforms": ["macos"],
"coveredProviders": ["local", "ssh", "remote-runtime"],
- "coverageNotes": "Local macOS evidence covers the shared missing-dir fallback policy, main pty:spawn recovery and metadata, no-flag and reattach strictness, renderer IPC flag routing, SSH-tagged and remote-runtime omission, and the visibility-gated terminal notice. Real Bash and Zsh node-pty tests replace the active cwd inode and exercise the shared POSIX OMP wrapper; generated-file snapshots pin identical local, daemon/SSH, and relay wrappers. Daemon shares the same pre-provider main cwd decision but lacks a live daemon-provider run; WSL UNC paths are exempt from the spawn probe and lack a live run; native PowerShell is unaffected; Linux/Windows and mobile/API strictness remain gaps.",
+ "coverageNotes": "Local macOS evidence covers the shared missing-dir fallback policy, main pty:spawn recovery and metadata, no-flag and reattach strictness, renderer IPC flag routing, SSH-tagged and remote-runtime omission, and the visibility-gated terminal notice. Real Bash and Zsh node-pty tests replace the active cwd inode and exercise the shared POSIX OMP wrapper; audit829 removes generated-file snapshots and their current byte-parity claim. No equivalent replacement for generated-script byte checks is claimed. Daemon shares the same pre-provider main cwd decision but lacks a live daemon-provider run; WSL UNC paths are exempt from the spawn probe and lack a live run; native PowerShell is unaffected; Linux/Windows and mobile/API strictness remain gaps.",
"motivatingLinks": [
"https://github.com/stablyai/orca/issues/7239",
"https://github.com/stablyai/orca/pull/7750",
@@ -9715,7 +9715,7 @@
"pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/pty/pty-spawn-cwd-fallback.test.ts",
"pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-transport-connect-spawn.test.ts",
"pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-connection-spawn-and-startup.test.ts",
- "pnpm exec vitest run --config config/vitest.config.ts src/main/pty/omp-shell-wrapper.node-pty.test.ts src/main/pty/omp-shell-wrapper-alias-safety.test.ts src/main/shell-wrapper-generated-file-snapshot.test.ts"
+ "pnpm exec vitest run --config config/vitest.config.ts src/main/pty/omp-shell-wrapper.node-pty.test.ts src/main/pty/omp-shell-wrapper-alias-safety.test.ts"
],
"testFiles": [
"src/shared/terminal-startup-cwd.test.ts",
@@ -9723,8 +9723,7 @@
"src/renderer/src/components/terminal-pane/pty-transport-connect-spawn.test.ts",
"src/renderer/src/components/terminal-pane/pty-connection-spawn-and-startup.test.ts",
"src/main/pty/omp-shell-wrapper.node-pty.test.ts",
- "src/main/pty/omp-shell-wrapper-alias-safety.test.ts",
- "src/main/shell-wrapper-generated-file-snapshot.test.ts"
+ "src/main/pty/omp-shell-wrapper-alias-safety.test.ts"
],
"assertionRefs": [
{
@@ -9779,12 +9778,6 @@
"extension argv and a nonzero OMP exit status survive the recovery subshell",
"a subsequently missing logical cwd prints an actionable error and does not invoke OMP again"
]
- },
- {
- "file": "src/main/shell-wrapper-generated-file-snapshot.test.ts",
- "assertions": [
- "local, daemon/SSH, and relay Bash/Zsh files contain the byte-identical shared OMP wrapper"
- ]
}
],
"evidenceRuns": [
@@ -9831,6 +9824,7 @@
"runner": "local",
"platform": "macos",
"command": "pnpm exec vitest run --config config/vitest.config.ts src/main/pty/omp-shell-wrapper.node-pty.test.ts src/main/pty/omp-shell-wrapper-alias-safety.test.ts src/main/shell-wrapper-generated-file-snapshot.test.ts",
+ "currentCommand": "pnpm exec vitest run --config config/vitest.config.ts src/main/pty/omp-shell-wrapper.node-pty.test.ts src/main/pty/omp-shell-wrapper-alias-safety.test.ts",
"result": "passed",
"durationSeconds": 3,
"summary": "3 test files passed; real Bash and Zsh PTYs covered usable physical cwd authority, stale-inode recovery with set and unset PWD, extension-enabled and extension-skipping argv, parent-shell isolation, exit status, missing-path visibility, alias safety, and generated local/daemon/relay parity."
@@ -9838,7 +9832,7 @@
],
"runtimeBudget": {
"p95Seconds": 40,
- "scope": "focused unit, IPC, generated-wrapper, and real Bash/Zsh PTY contracts"
+ "scope": "focused unit, IPC, and real Bash/Zsh PTY contracts"
},
"flakeHistory": {
"status": "unknown",
diff --git a/config/scripts/check-daemon-blocking-call-ratchet.test.mjs b/config/scripts/check-daemon-blocking-call-ratchet.test.mjs
deleted file mode 100644
index 215ff441c07..00000000000
--- a/config/scripts/check-daemon-blocking-call-ratchet.test.mjs
+++ /dev/null
@@ -1,24 +0,0 @@
-import { describe, expect, it } from 'vitest'
-
-import { countBlockingCalls } from './check-daemon-blocking-call-ratchet.mjs'
-
-const count = (source) => countBlockingCalls('src/main/daemon/example.ts', source)
-
-describe('countBlockingCalls', () => {
- it('counts synchronous file writes through named, namespace and default imports', () => {
- expect(
- count(
- "import { appendFileSync } from 'node:fs'\nimport * as fs from 'fs'\nimport nodeFs from 'node:fs'\n" +
- 'appendFileSync(p, line)\nfs.writeSync(fd, line)\nnodeFs.appendFileSync(p, line)'
- )
- ).toBe(3)
- })
-
- it('ignores same-named methods on other objects and other fs calls', () => {
- expect(
- count(
- "import { writeFileSync } from 'node:fs'\nemulator.writeSync(chunk)\nwriter.writeSync(save)\nwriteFileSync(p, x)"
- )
- ).toBe(0)
- })
-})
diff --git a/config/scripts/check-has-restyle-scope.test.mjs b/config/scripts/check-has-restyle-scope.test.mjs
deleted file mode 100644
index 3836094c1fb..00000000000
--- a/config/scripts/check-has-restyle-scope.test.mjs
+++ /dev/null
@@ -1,68 +0,0 @@
-import path from 'node:path'
-import { describe, expect, it } from 'vitest'
-import { compileTailwind, findHasRestyleProblems } from './check-has-restyle-scope.mjs'
-
-// Compiled shapes (the Tailwind spelling that emits each is noted); each restyles the whole anchor subtree.
-// Rules need a declaration: lightningcss drops empty ones before the check sees them.
-const subtreeWide = [
- '.a:is(:where(.group\\/row):has(:is(:focus-visible)) *)', // group-has-[…]/row
- '.a:is(:where(.group\\/x):is(:has(:focus-visible)) *)', // group-[:has(…)]/x
- '.a:is(:where(.peer):is(:has(.x)) ~ *)', // peer-[:has(…)]
- '.a:is(:where(.peer):has(:checked) ~ *)', // peer-has-checked
- '.a:not(:is(:where(.group):has(:is(.x)) *))', // not-group-has-[…]
- '.a:is(:where(.group):not(:has(:is(.x))) *)', // group-not-has-[…]
- ':is(.a:has(.x) > *)', // [&:has(x)]:*:
- ':is(.a:has(.x) *)', // [&:has(x)]:**:
- ':is(.a:has(:is(.x)) *)', // has-[x]:**:
- '.row:has(.x) .a *', // [.row:has(x)_&_*]
- '.a:has(:is(.x)) svg', // has-[x]:[&_svg]:
- '.a:has(.x) svg', // [&:has(x)_svg]
- ':is(.anchor:has(.trigger) .scoped) *', // [&:is(.anchor:has(.trigger)_.scoped)_*]
- '.a:nth-child(2n of .g:has(.x) *)',
- '.zz:has(.a + .b) span',
- '.foo:has(.a ~ .b) *',
- '.zz:has(:focus-visible) span',
- '.zz:has(.x) ::before',
- ':is(body:has(.modal)) span'
-]
-
-const scoped = [
- "[class~='group/row']:has(:focus-visible) .a",
- '.card:has([data-slot="card-action"])',
- '.x .comment-md-p > strong:first-child:has(+ br) + br',
- '.zz:has(~ .y) span',
- 'body:has(.qq) .yy',
- ':is(body:has(.modal)) .x',
- ':is(.anchor:has(.trigger) .scoped) .ok',
- '.a:is(:where(.group\\/row):hover *)',
- '.anchor:has(.x) :where(.scoped), .anchor:has(.x) :is(.scoped, #target)',
- ':host(.dark) .card:has(.x)',
- "body > :is([data-slot='dialog-content']):has(~ [data-slot='dialog-overlay'])"
-]
-
-describe('findHasRestyleProblems', () => {
- it.each(subtreeWide)('flags %s', (selector) => {
- expect(findHasRestyleProblems(`${selector} { color: red }`)).toHaveLength(1)
- })
-
- it.each(scoped)('allows %s', (selector) => {
- expect(findHasRestyleProblems(`${selector} { color: red }`)).toEqual([])
- })
-
- it('sees rules through nesting, @layer and @media', () => {
- expect(findHasRestyleProblems('.zz:has(.x) { & * { color: red } }')).toHaveLength(1)
- expect(
- findHasRestyleProblems('@layer u { @media (hover: hover) { .zz:has(.x) i { color: red } } }')
- ).toHaveLength(1)
- })
-
- it('flags a group-has-* utility through the real Tailwind compile', async () => {
- const css = await compileTailwind(
- "@import 'tailwindcss/utilities' source(none);\n@source inline('group-has-[:focus-visible]/row:opacity-100');",
- { base: path.resolve(import.meta.dirname, '../../src/renderer/src/assets') }
- )
- expect(findHasRestyleProblems(css)).toEqual([
- '.group-has-\\[\\:focus-visible\\]\\/row\\:opacity-100:is(:where(.group\\/row):has(:focus-visible) *)'
- ])
- })
-})
diff --git a/config/scripts/check-memo-translate-subscription-ratchet.test.mjs b/config/scripts/check-memo-translate-subscription-ratchet.test.mjs
deleted file mode 100644
index 0f03d938a11..00000000000
--- a/config/scripts/check-memo-translate-subscription-ratchet.test.mjs
+++ /dev/null
@@ -1,35 +0,0 @@
-import { describe, expect, it } from 'vitest'
-
-import { findUnsubscribedMemoComponents } from './check-memo-translate-subscription-ratchet.mjs'
-
-describe('findUnsubscribedMemoComponents', () => {
- it('flags inline and named memo components in translating files', () => {
- const source = [
- 'const Row = React.memo(function Row() {',
- " return <span>{translate('k', 'Row')}</span>",
- '})',
- 'function PickerInner(): React.JSX.Element {',
- ' return <Label />',
- '}',
- 'export const Picker = memo(PickerInner)'
- ].join('\n')
- expect(findUnsubscribedMemoComponents(source)).toEqual(['Row', 'PickerInner'])
- })
-
- it('accepts subscribed components, imported targets and files without translate()', () => {
- expect(
- findUnsubscribedMemoComponents(
- [
- 'const Row = memo(function Row() {',
- ' useUiLanguageRevision()',
- " return translate('k', 'Row')",
- '})',
- 'const Imported = memo(ImportedButton)'
- ].join('\n')
- )
- ).toEqual([])
- expect(
- findUnsubscribedMemoComponents('const Row = memo(function Row() { return null })')
- ).toEqual([])
- })
-})
diff --git a/config/scripts/ci-shard-timings.json b/config/scripts/ci-shard-timings.json
index 0750d953b4a..c91991797ae 100644
--- a/config/scripts/ci-shard-timings.json
+++ b/config/scripts/ci-shard-timings.json
@@ -3332,7 +3332,6 @@
"src/main/ipc/wsl-move-handlers.test.ts": 399,
"src/main/ipc/zcode-plan-credentials.test.ts": 50,
"src/main/issue-command-ignore.test.ts": 724,
- "src/main/jcode/hook-command-quoting.test.ts": 41,
"src/main/jcode/hook-config.test.ts": 64,
"src/main/jcode/hook-gate-script.test.ts": 134,
"src/main/jcode/hook-service.test.ts": 67,
@@ -4612,7 +4611,6 @@
"src/main/pty/legacy-terminal-windows-tombstone.test.ts": 49,
"src/main/pty/managed-ssh-host-login-shell.test.ts": 40,
"src/main/pty/node-pty-master-fd-retirement.test.ts": 2376,
- "src/main/pty/node-pty-self-exit-pseudoconsole-close.test.ts": 37,
"src/main/pty/overlay-mirror.test.ts": 73,
"src/main/pty/pi-process-owner-env.test.ts": 350,
"src/main/pty/posix-pty-foreground-group.test.ts": 42,
@@ -6115,7 +6113,6 @@
"src/main/shell-startup-identity-scanner.test.ts": 23,
"src/main/shell-startup-output-scanner.test.ts": 34,
"src/main/shell-wrapper-content-address.test.ts": 38,
- "src/main/shell-wrapper-generated-file-snapshot.test.ts": 94,
"src/main/sidecar-snapshot-file.test.ts": 68,
"src/main/skills/agent-skill-selection.test.ts": 138,
"src/main/skills/antigravity-skill-discovery.test.ts": 193,
diff --git a/config/scripts/pr-code-change-scope-sparse-checkout.test.mjs b/config/scripts/pr-code-change-scope-sparse-checkout.test.mjs
deleted file mode 100644
index 95ce9c9c964..00000000000
--- a/config/scripts/pr-code-change-scope-sparse-checkout.test.mjs
+++ /dev/null
@@ -1,50 +0,0 @@
-import { readFileSync } from 'node:fs'
-import path from 'node:path'
-import { describe, expect, it } from 'vitest'
-import { parse } from 'yaml'
-
-const projectDir = path.resolve(import.meta.dirname, '../..')
-const SCOPE_SCRIPT = 'config/scripts/pr-code-change-scope.mjs'
-
-// The relative modules a script loads, followed transitively.
-function localImports(entry) {
- const seen = new Set()
- const pending = [entry]
- while (pending.length > 0) {
- const file = pending.pop()
- if (seen.has(file)) {
- continue
- }
- seen.add(file)
- const source = readFileSync(path.join(projectDir, file), 'utf8')
- for (const match of source.matchAll(/(?:from|import)\s*\(?\s*'(\.{1,2}\/[^']+\.mjs)'/g)) {
- pending.push(path.posix.join(path.posix.dirname(file), match[1]))
- }
- }
- return [...seen]
-}
-
-// The detector job sparse-checks-out a fixed list, so a module the scope script imports but the list
-// omits fails that job with ERR_MODULE_NOT_FOUND.
-describe('the change detector sparse checkout', () => {
- it('includes every module pr-code-change-scope.mjs loads', () => {
- const workflow = parse(readFileSync(path.join(projectDir, '.github/workflows/pr.yml'), 'utf8'))
- const checkouts = Object.values(workflow.jobs)
- .flatMap((job) => job.steps ?? [])
- .map((step) => step.with?.['sparse-checkout'])
- .filter((list) => typeof list === 'string' && list.includes(`/${SCOPE_SCRIPT}`))
- expect(checkouts).toHaveLength(1)
- const sparse = new Set(
- checkouts[0]
- .trim()
- .split('\n')
- .map((line) => line.trim())
- )
- const missing = localImports(SCOPE_SCRIPT).filter(
- (file) =>
- !sparse.has(`/${file}`) &&
- ![...sparse].some((entry) => entry.endsWith('/') && `/${file}`.startsWith(entry))
- )
- expect(missing).toEqual([])
- })
-})
diff --git a/config/scripts/verify-mobile-localization.test.mjs b/config/scripts/verify-mobile-localization.test.mjs
deleted file mode 100644
index ebe340b4497..00000000000
--- a/config/scripts/verify-mobile-localization.test.mjs
+++ /dev/null
@@ -1,71 +0,0 @@
-import { describe, expect, it } from 'vitest'
-
-import {
- collectExtractionProblems,
- collectIncompletePluralFamilies,
- collectLiveSwitchViolations
-} from './verify-mobile-localization.mjs'
-
-describe('verify-mobile-localization', () => {
- it('rejects translations that cannot follow a live language switch', () => {
- const source = [
- "const LABELS = [translate('a.b', 'Module scope')]",
- 'export function Row({ items }) {',
- " const onPress = () => Alert.alert(translate('a.d', 'Handler runs at press time'))",
- " useEffect(() => setTitle(translate('a.h', 'Effect')), [])",
- " const label = useMemo(() => translate('a.g', 'Memo'), [])",
- " return items.map((item) => <Text key={item}>{translate('a.c', 'Render callback')}</Text>)",
- '}',
- 'export function Subscribed() {',
- ' const t = useMobileTranslation()',
- " return <Pressable onPress={() => translate('a.i', 'Pressed')}>{t('a.e', 'Hook')}</Pressable>",
- '}',
- "export function rowLabel() { return translate('a.f', 'Helper') }",
- "export default function () { return <Text>{translate('a.j', 'Screen')}</Text> }"
- ].join('\n')
-
- expect(collectLiveSwitchViolations('mobile/src/row.tsx', source)).toEqual([
- 'mobile/src/row.tsx:1 translates at module scope; translate when rendering instead',
- 'mobile/src/row.tsx:5 calls translate() in a component or hook; use `const t = useMobileTranslation()`',
- 'mobile/src/row.tsx:6 calls translate() in a component or hook; use `const t = useMobileTranslation()`',
- 'mobile/src/row.tsx:13 calls translate() in a component or hook; use `const t = useMobileTranslation()`'
- ])
- })
-
- it('requires every CLDR category once a locale translates a plural family', () => {
- const english = new Map([
- ['files_one', '{{count}} file'],
- ['files_other', '{{count}} files']
- ])
-
- expect(
- collectIncompletePluralFamilies(
- english,
- new Map([
- ['files_one', '{{count}} файл'],
- ['files_other', '{{count}} файла']
- ]),
- 'ru'
- )
- ).toEqual(['files: missing _few, _many'])
- expect(
- collectIncompletePluralFamilies(english, new Map([['files_other', '{{count}} 件']]), 'ja')
- ).toEqual([])
- })
-
- it('keeps a plural family while any of its forms is referenced', () => {
- const english = {
- items_one: '{{count}} item',
- items_other: '{{count}} items',
- gone_one: '{{count}} gone',
- gone_other: '{{count}} gone'
- }
- const references = [{ key: 'items_one', fallback: '{{count}} item' }]
- const evidence = { literals: new Set(), dynamicPrefixes: new Set() }
-
- expect(collectExtractionProblems(references, english, evidence).unreferenced).toEqual([
- 'gone_one',
- 'gone_other'
- ])
- })
-})
diff --git a/config/scripts/verify-wsl-no-background-boot-participation.test.mjs b/config/scripts/verify-wsl-no-background-boot-participation.test.mjs
deleted file mode 100644
index 300eb32b276..00000000000
--- a/config/scripts/verify-wsl-no-background-boot-participation.test.mjs
+++ /dev/null
@@ -1,39 +0,0 @@
-import { describe, expect, it } from 'vitest'
-import {
- verifyWslNoBackgroundBootParticipation,
- WSL_NO_BACKGROUND_BOOT_TITLES
-} from './verify-wsl-no-background-boot-participation.mjs'
-
-function report(runs = 3) {
- return {
- stats: {
- expected: runs * WSL_NO_BACKGROUND_BOOT_TITLES.length,
- skipped: 0,
- unexpected: 0,
- flaky: 0
- },
- suites: [
- {
- specs: WSL_NO_BACKGROUND_BOOT_TITLES.map((title) => ({
- title,
- tests: Array.from({ length: runs }, () => ({
- expectedStatus: 'passed',
- results: [{ status: 'passed' }]
- }))
- }))
- }
- ]
- }
-}
-
-describe('WSL E9 guard participation', () => {
- it('accepts both guards executed three times', () => {
- expect(() => verifyWslNoBackgroundBootParticipation(report())).not.toThrow()
- })
- it('rejects a run where the guard skipped', () => {
- const value = report()
- value.stats.skipped = 3
- value.stats.expected = 0
- expect(() => verifyWslNoBackgroundBootParticipation(value)).toThrow('participation failed')
- })
-})
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/README.md b/src/main/__fixtures__/shell-wrapper-snapshots/README.md
deleted file mode 100644
index 6674985fd43..00000000000
--- a/src/main/__fixtures__/shell-wrapper-snapshots/README.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# Shell wrapper snapshots
-
-Generated test fixtures. **Do not edit by hand.**
-
-Each `.txt` here is the byte-exact content of one shell startup file Orca writes
-into a pane's wrapper `ZDOTDIR`, captured per transport:
-
-| | |
-| :--------- | :---------------- |
-| `local-*` | local PTY |
-| `daemon-*` | daemon / SSH host |
-| `relay-*` | relay overlay |
-
-Owned by [`../../shell-wrapper-generated-file-snapshot.test.ts`](../../shell-wrapper-generated-file-snapshot.test.ts),
-which drives the real wrapper entry points, reads the files back off disk and
-compares them here. The temp wrapper root is normalized to `<WRAPPER_ROOT>` —
-the only path-dependent bytes in the output.
-
-## Why these exist
-
-The three zsh generators were once copy-pasted and drifted, so a fix landed in
-one transport and silently missed the other two. These pin all three at once, so
-drift shows up as a reviewable shell diff instead of hiding in a TypeScript
-template literal.
-
-## Regenerating
-
-Run the test and review the resulting diff:
-
-```sh
-npx vitest run --config config/vitest.config.ts src/main/shell-wrapper-generated-file-snapshot.test.ts
-```
-
-⚠️ `toMatchFileSnapshot` **rewrites these files on mismatch when run locally** —
-only CI fails. So a passing local run proves nothing on its own: always
-`git diff` this directory afterwards, and treat any change as a real behavior
-change to what users' shells execute until you have explained it.
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt
deleted file mode 100644
index 1c93e48d78c..00000000000
--- a/src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt
+++ /dev/null
@@ -1,455 +0,0 @@
-# Orca daemon bash shell-ready wrapper
-_orca_shell_features=",${ORCA_SHELL_FEATURES:-},"
-builtin unset ORCA_SHELL_FEATURES
-__orca_has_feature() { [[ "$_orca_shell_features" == *",$1,"* ]]; }
-__orca_has_feature identity && printf "\033]777;orca-shell-start:%s\007" "$$"
-# Consume the feature channel before profiles so child processes cannot inherit the selection.
-__orca_ready_marker=""
-__orca_has_feature ready && __orca_ready_marker=1
-unset _orca_shell_features
-unset -f __orca_has_feature
-# A system bashrc may already run ble.sh; it never exports this state, so exported copies are inherited.
-for __orca_ble_var in _ble_attached _ble_decode_bind_state; do
- [[ -n "${!__orca_ble_var+set}" ]] || continue
- case "$(declare -p "$__orca_ble_var" 2>/dev/null)" in "declare -x"*) unset "$__orca_ble_var" ;; esac
-done
-unset __orca_ble_var
-[[ -f /etc/profile ]] && source /etc/profile
-if [[ -f "$HOME/.bash_profile" ]]; then
- source "$HOME/.bash_profile"
-elif [[ -f "$HOME/.bash_login" ]]; then
- source "$HOME/.bash_login"
-elif [[ -f "$HOME/.profile" ]]; then
- source "$HOME/.profile"
-fi
-# Force bracketed paste on older readline so multiline startup prompts remain one literal paste.
-[[ $- == *i* ]] && bind 'set enable-bracketed-paste on' 2>/dev/null
-__orca_restore_agent_teams_path() {
- [[ -n "${ORCA_AGENT_TEAMS_SHIM_DIR:-}" ]] || return 0
- case "$PATH" in
- "${ORCA_AGENT_TEAMS_SHIM_DIR}"|"${ORCA_AGENT_TEAMS_SHIM_DIR}:"*) return 0 ;;
- esac
- export PATH="${ORCA_AGENT_TEAMS_SHIM_DIR}:$PATH"
-}
-__orca_restore_agent_teams_path
-if [ -n "${ORCA_CLI_BIN_DIR:-}" ]; then
- case "${PATH:-}" in
- "$ORCA_CLI_BIN_DIR"|"$ORCA_CLI_BIN_DIR":*) ;;
- *) export PATH="$ORCA_CLI_BIN_DIR${PATH:+:$PATH}" ;;
- esac
-fi
-# Restore the managed OpenCode config after user profiles may have replaced it.
-[[ -n "${ORCA_OPENCODE_CONFIG_DIR:-}" ]] && export OPENCODE_CONFIG_DIR="${ORCA_OPENCODE_CONFIG_DIR}"
-if [[ -n "${ORCA_DATA_ACCOUNT_DATA_HOME:-}" ]]; then
- export XDG_DATA_HOME="${ORCA_DATA_ACCOUNT_DATA_HOME}"
- export XDG_STATE_HOME="${ORCA_DATA_ACCOUNT_STATE_HOME}"
- if [[ "${ORCA_DATA_ACCOUNT_PROVIDER:-}" == opencode ]]; then
- export OPENCODE_AUTH_CONTENT=""
- export OPENCODE_DB="opencode.db"
- fi
-fi
-[[ -n "${ORCA_MIMOCODE_CONFIG_DIR:-}" ]] && export MIMOCODE_CONFIG_DIR="${ORCA_MIMOCODE_CONFIG_DIR}"
-# Why: OMP does not auto-load Orca's managed status extension; wrap only
-# interactive launch invocations so subcommands such as `omp config` keep
-# their normal argv shape.
-__orca_omp_should_skip_extension() {
- case "${1:-}" in
- 'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
- '__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
- esac
- return 1
-}
-__orca_omp_cwd_is_usable() {
- local __orca_physical_cwd
- [[ -x . ]] || return 1
- if [[ -n "${PWD:-}" && -d "${PWD:-}" ]]; then
- [[ "${PWD}" -ef . ]]
- else
- # Why compare the path: shell builtins can print a cached path for a deleted cwd.
- __orca_physical_cwd="$(builtin pwd -P 2>/dev/null)" || return 1
- [[ -d "$__orca_physical_cwd" && "$__orca_physical_cwd" -ef . ]]
- fi
-}
-__orca_omp_invoke() {
- local __orca_use_extension="$1"
- shift
- if [[ $__orca_use_extension -eq 1 && -n "${ORCA_OMP_STATUS_EXTENSION:-}" && -f "${ORCA_OMP_STATUS_EXTENSION}" ]]; then
- if [[ "${1:-}" == "launch" ]]; then
- shift
- command omp launch --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- else
- command omp --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- fi
- else
- command omp "$@"
- fi
-}
-__orca_omp() {
- local __orca_use_extension=1
- __orca_omp_should_skip_extension "${1:-}" && __orca_use_extension=0
- if ! __orca_omp_cwd_is_usable; then
- local __orca_logical_cwd="${PWD:-${ORCA_WORKTREE_PATH:-${ORCA_ROOT_PATH:-}}}"
- # Why: a restored shell can retain the deleted directory inode after its path is recreated.
- (
- if [[ -z "$__orca_logical_cwd" ]]; then
- printf 'Orca: OMP cannot start because no terminal working directory is available. Open a new terminal in an existing directory.\n' >&2
- return 1
- fi
- if ! builtin cd -P -- "$__orca_logical_cwd" 2>/dev/null; then
- printf 'Orca: OMP cannot access the terminal working directory "%s". Open a new terminal in an existing directory.\n' "$__orca_logical_cwd" >&2
- return 1
- fi
- __orca_omp_invoke "$__orca_use_extension" "$@"
- )
- else
- __orca_omp_invoke "$__orca_use_extension" "$@"
- fi
-}
-if [[ -n "${ORCA_OMP_STATUS_EXTENSION:-}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name, which
- # an `alias omp` otherwise rewrites at parse time, aborting the rest of the file.
- function omp { __orca_omp "$@"; }
-fi
-
-# Preserve the managed CODEX_HOME after user profiles.
-[[ -n "${ORCA_CODEX_HOME:-}" ]] && export CODEX_HOME="${ORCA_CODEX_HOME}"
-# Why: a typed alias expands inside the shell, after pane launch prep.
-# Why unalias inside the substitution: an alias named codex makes command -v
-# report the alias text, and the subshell leaves the user's own alias intact.
-# Why || : twice — zsh alone aborts inside the substitution, but every shell's
-# assignment adopts its exit status, so an absent codex trips set -e in bash too.
-__orca_codex_binary="$(unalias codex 2>/dev/null || :; command -v codex 2>/dev/null || :)"
-if [[ -n "${__orca_codex_binary:-}" && -x "${__orca_codex_binary}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name,
- # which otherwise rewrites this header at parse time and aborts the whole file.
- function codex {
- # Why local: zsh's warn_create_global warns for each global a function creates.
- local __orca_codex_arg __orca_codex_isolate="${ORCA_CODEX_ISOLATE:-1}" __orca_codex_identity="${ORCA_CODEX_ISOLATE:-1}"
- if [[ "${ORCA_REMOTE_VIEWER_CLIPBOARD:-}" == 1 && -z "${SSH_CONNECTION+x}" && -z "${SSH_TTY+x}" ]]; then
- local -x SSH_CONNECTION='127.0.0.1 0 127.0.0.1 0'
- fi
- if [[ -n "${ORCA_CODEX_LAUNCH_PREFLIGHT:-}" && -x "${ORCA_CODEX_LAUNCH_PREFLIGHT}" ]]; then
- "${ORCA_CODEX_LAUNCH_PREFLIGHT}" agent hooks prepare-codex >/dev/null 2>&1 || :
- fi
- for __orca_codex_arg in "$@"; do
- case "$__orca_codex_arg" in
- --no-daemon) __orca_codex_isolate=0 ;;
- agents|queue|--remote|--remote=*) __orca_codex_isolate=0 __orca_codex_identity=0 ;;
- esac
- done
- if [[ "$__orca_codex_identity" != 0 ]]; then
- [[ -z "${ORCA_TERMINAL_HANDLE:-}" || "${ORCA_TERMINAL_HANDLE}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_TERMINAL_HANDLE='${ORCA_TERMINAL_HANDLE}'" "$@"
- [[ -z "${ORCA_PANE_KEY:-}" || "${ORCA_PANE_KEY}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_PANE_KEY='${ORCA_PANE_KEY}'" "$@"
- [[ -z "${ORCA_WORKTREE_ID:-}" || "${ORCA_WORKTREE_ID}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_WORKTREE_ID='${ORCA_WORKTREE_ID}'" "$@"
- [[ -z "${ORCA_WORKSPACE_ID:-}" || "${ORCA_WORKSPACE_ID}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_WORKSPACE_ID='${ORCA_WORKSPACE_ID}'" "$@"
- [[ -z "${ORCA_USER_DATA_PATH:-}" || "${ORCA_USER_DATA_PATH}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_USER_DATA_PATH='${ORCA_USER_DATA_PATH}'" "$@"
- fi
- # Why probe every launch: a cached answer goes stale across an upgrade, and 0.155 and older exit 2 on the flag.
- if [[ "$__orca_codex_isolate" != 0 ]]; then
- case "$(command codex --help 2>/dev/null </dev/null)" in *--no-daemon*) set -- --no-daemon "$@" ;; esac
- fi
- command codex "$@"
- }
-fi
-unset __orca_codex_binary
-__orca_claude_binary="$(unalias claude 2>/dev/null || :; command -v claude 2>/dev/null || :)"
-if [[ -n "${ORCA_CLAUDE_PROFILE_POINTER:-}" && -n "${__orca_claude_binary:-}" && -x "${__orca_claude_binary}" ]]; then
- function claude {
- local __orca_claude_home __orca_claude_pointer="${ORCA_CLAUDE_PROFILE_POINTER:-}"
- # Why: a WSL pane's pointer is relative to the guest home, which the host cannot know at spawn.
- case "$__orca_claude_pointer" in '~/'*) __orca_claude_pointer="${HOME:-}/${__orca_claude_pointer#??}" ;; esac
- __orca_claude_home="$(cat "$__orca_claude_pointer" 2>/dev/null || :)"
- if [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ "$CLAUDE_CONFIG_DIR" != "${ORCA_CLAUDE_INJECTED_CONFIG_DIR:-}" ] &&
- { [ -z "${ORCA_CLAUDE_USER_CONFIG_DIR:-}" ] || [ "${CLAUDE_CONFIG_DIR%/}" != "${ORCA_CLAUDE_USER_CONFIG_DIR%/}" ]; }; then
- command claude "$@"; return
- fi
- # Why: Orca's value replaced the user's own at spawn, so System default restores theirs.
- if [ -z "$__orca_claude_home" ] && [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ -n "${ORCA_CLAUDE_USER_CONFIG_DIR:-}" ]; then
- ( unset ORCA_CLAUDE_INJECTED_CONFIG_DIR; export CLAUDE_CONFIG_DIR="$ORCA_CLAUDE_USER_CONFIG_DIR"; command claude "$@" ); return
- fi
- if [ -z "$__orca_claude_home" ]; then
- ( unset CLAUDE_CONFIG_DIR ORCA_CLAUDE_INJECTED_CONFIG_DIR; command claude "$@" ); return
- fi
- case "$__orca_claude_home" in /*|[A-Za-z]:*) ;; *) return 1 ;; esac
- # Why -m 700: matches the folder Orca's setup creates; a credentials folder stays private.
- [ -d "$__orca_claude_home" ] || mkdir -p -m 700 -- "$__orca_claude_home" 2>/dev/null
- ( export CLAUDE_CONFIG_DIR="$__orca_claude_home" ORCA_CLAUDE_INJECTED_CONFIG_DIR="$__orca_claude_home"; command claude "$@" )
- }
-fi
-unset __orca_claude_binary
-
-# OSC 133 C/D clears stale agent status when a CLI exits without a stop hook.
-__orca_initializing_wrapper=1
-__orca_osc133_precmd() {
- local exit_code=$?
- __orca_in_prompt_command=1
- if [[ -n "${__orca_in_command:-}" ]]; then
- printf "\033]133;D;%s\007" "$exit_code"
- unset __orca_in_command
- fi
- printf "\033]133;A\007"
- return "$exit_code"
-}
-__orca_osc133_preexec() {
- if [[ -n "${__orca_prompt_status_capture_command:-}" && "$BASH_COMMAND" == "$__orca_prompt_status_capture_command" ]]; then
- unset __orca_initial_prompt
- __orca_in_legacy_prompt_wrapper=1
- return 0
- fi
- if [[ -n "${__orca_initializing_wrapper:-}${__orca_in_debug_capture:-}${__orca_initial_prompt:-}${__orca_in_prompt_dispatch:-}${__orca_in_legacy_prompt_wrapper:-}${__orca_in_prompt_command:-}" ]]; then
- [[ -z "${__orca_initializing_wrapper:-}${__orca_in_debug_capture:-}" ]] || return 0
- if [[ -n "${__orca_initial_prompt:-}" && "$BASH_COMMAND" == "__orca_osc133_precmd" ]]; then
- unset __orca_initial_prompt; return 0
- fi
- if [[ -n "${__orca_in_prompt_dispatch:-}" ]]; then
- [[ -n "${__orca_dispatching_user_prompt_command:-}" ]] || return 0
- if [[ "${FUNCNAME[1]:-}" == "__orca_run_prompt_command_array" ]]; then
- case "$BASH_COMMAND" in
- '(( __orca_exit_code == 0 ))'|'__orca_restore_prompt_status "$__orca_exit_code"'|'eval "$__orca_prompt_part"'|'eval "$__orca_final_prompt_command"'|__orca_dispatching_user_prompt_command=*|__orca_osc133_precmd|__orca_osc133_epilogue) return 0 ;;
- esac
- fi
- elif [[ "${FUNCNAME[1]:-}" == "__orca_run_prompt_command_array" || "$BASH_COMMAND" == "__orca_run_prompt_command_array" ]]; then
- return 0
- fi
- [[ -z "${__orca_in_legacy_prompt_wrapper:-}" || -n "${__orca_dispatching_user_prompt_command:-}" ]] || return 0
- if [[ -n "${__orca_in_prompt_command:-}" && "$BASH_COMMAND" == "__orca_in_debug_capture=1" ]]; then
- return 0
- fi
- fi
- case "${FUNCNAME[1]:-}" in
- __orca_osc133_*|__orca_restore_prompt_status|__bp_*) return 0 ;;
- esac
- case "$BASH_COMMAND" in
- __orca_osc133_precmd|__orca_osc133_epilogue) return 0 ;;
- # The prefix is only special while bash-preexec prompt hooks run.
- __bp_*) [[ -n "${__orca_in_prompt_command:-}" ]] && return 0 ;;
- esac
- __orca_run_user_debug_trap
- # Chain the framework trap captured before each prompt's lifecycle re-arm.
- if [[ -n "${__orca_chained_debug_trap:-}" ]]; then
- eval "$__orca_chained_debug_trap" || true
- fi
- [[ -z "${__orca_in_prompt_command:-}" ]] || return 0
- # Emit C once per foreground command, excluding prompt hooks and repeated chained-trap calls.
- [[ -z "${__orca_in_command:-}" ]] || return 0
- printf "\033]133;C\007"
- __orca_in_command=1
-}
-# Adopt the latest user trap before reclaiming lifecycle ownership.
-__orca_osc133_epilogue() {
- unset __orca_in_prompt_command
- __orca_adopt_outer_debug_trap
- trap '__orca_osc133_preexec' DEBUG
- # Readline renders PS1 after entering raw mode; prompt hooks still run in cooked mode.
- if [[ -n "$__orca_ready_marker" ]]; then
- # Attached ble.sh (0.3+) discards Bash's own prompt output and owns the TTY, so print directly.
- if [[ -n "${_ble_attached-}" ]]; then
- # Its first render runs this before the key decoder attaches; wait for a later prompt.
- if [[ "${_ble_decode_bind_state:-none}" != none ]]; then
- printf "\033]777;orca-shell-ready\007"
- __orca_ready_marker=""
- fi
- else
- PS1="${PS1-}"'\[\e]777;orca-shell-ready\a\]'
- __orca_ready_marker=""
- fi
- fi
-}
-__orca_normalize_prompt_command_part() {
- local __orca_value="$1" __orca_output_name="$2" __orca_character __orca_chunk
- local __orca_value_length=${#1} __orca_suffix_length=0 __orca_backslash_length=0
- local __orca_output_length __orca_scan_start
- while (( __orca_value_length - __orca_suffix_length >= 1024 )); do
- __orca_scan_start=$(( __orca_value_length - __orca_suffix_length - 1024 ))
- __orca_chunk="${__orca_value:__orca_scan_start:1024}"
- case "$__orca_chunk" in
- *[!$' \t\n;']*) break ;;
- *) __orca_suffix_length=$(( __orca_suffix_length + 1024 )) ;;
- esac
- done
- while (( __orca_suffix_length < __orca_value_length )); do
- __orca_character="${__orca_value: -__orca_suffix_length - 1:1}"
- case "$__orca_character" in
- ' '|$'\t'|$'\n'|';') __orca_suffix_length=$(( __orca_suffix_length + 1 )) ;;
- *) break ;;
- esac
- done
- __orca_output_length=$(( ${#__orca_value} - __orca_suffix_length ))
- while (( __orca_output_length - __orca_backslash_length >= 1024 )); do
- __orca_scan_start=$(( __orca_output_length - __orca_backslash_length - 1024 ))
- __orca_chunk="${__orca_value:__orca_scan_start:1024}"
- case "$__orca_chunk" in
- *[!\\]*) break ;;
- *) __orca_backslash_length=$(( __orca_backslash_length + 1024 )) ;;
- esac
- done
- while (( __orca_backslash_length < __orca_output_length )); do
- __orca_character="${__orca_value:__orca_output_length - __orca_backslash_length - 1:1}"
- [[ "$__orca_character" == '\' ]] || break
- __orca_backslash_length=$(( __orca_backslash_length + 1 ))
- done
- # Preserve the first separator when an odd backslash run escapes it.
- if (( __orca_suffix_length > 0 && __orca_backslash_length % 2 == 1 )); then
- __orca_suffix_length=$(( __orca_suffix_length - 1 ))
- __orca_backslash_length=0
- fi
- __orca_output_length=$(( ${#__orca_value} - __orca_suffix_length ))
- __orca_value="${__orca_value:0:__orca_output_length}"
- # Bash 4.4-5.0 scalar prompt evaluation preserves an odd terminal backslash.
- if (( __orca_suffix_length == 0 && ((BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4) || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] == 0)) && __orca_backslash_length % 2 == 1 )); then
- __orca_value="$__orca_value\\"
- fi
- printf -v "$__orca_output_name" '%s' "$__orca_value"
-}
-__orca_restore_prompt_status() {
- return "$1"
-}
-__orca_update_user_debug_trap() {
- local __orca_debug_trap_spec="$1" __orca_unchanged_debug_trap_spec="$2"
- local __orca_debug_trap_command
- [[ "$__orca_debug_trap_spec" != "$__orca_unchanged_debug_trap_spec" ]] || return 0
- [[ "$__orca_debug_trap_spec" != "trap -- '__orca_osc133_preexec' DEBUG" ]] || return 0
- if [[ -z "$__orca_debug_trap_spec" ]]; then
- __orca_user_debug_trap=""
- unset __orca_chained_debug_trap
- return 0
- fi
- __orca_debug_trap_command="${__orca_debug_trap_spec#trap -- }"
- __orca_debug_trap_command="${__orca_debug_trap_command% DEBUG}"
- eval "__orca_user_debug_trap=$__orca_debug_trap_command"
- unset __orca_chained_debug_trap
-}
-__orca_run_user_debug_trap() {
- if [[ -n "${__orca_user_debug_trap:-}" ]]; then
- eval "$__orca_user_debug_trap" || true
- fi
-}
-__orca_adopt_outer_debug_trap() {
- local __orca_debug_trap_spec="${__orca_outer_debug_trap_spec:-}"
- unset __orca_outer_debug_trap_spec
- __orca_update_user_debug_trap "$__orca_debug_trap_spec" "trap -- '__orca_osc133_preexec' DEBUG"
-}
-__orca_run_prompt_command_array() {
- local __orca_exit_code="${__orca_prompt_status:-$?}" __orca_prompt_part __orca_prompt_index __orca_user_count
- local __orca_suffix_part
- local __orca_final_prompt_command
- local __orca_in_prompt_dispatch=1 __orca_dispatching_user_prompt_command=""
- unset __orca_prompt_status
- __orca_adopt_outer_debug_trap
- trap '__orca_osc133_preexec' DEBUG
- for __orca_prompt_part in "${__orca_prompt_command_prefix[@]+"${__orca_prompt_command_prefix[@]}"}"; do
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_prompt_part"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_prompt_part"
- fi
- done
- __orca_user_count=0
- for __orca_prompt_part in "${__orca_prompt_command_array[@]+"${__orca_prompt_command_array[@]}"}"; do
- __orca_user_count=$(( __orca_user_count + 1 ))
- done
- for (( __orca_prompt_index = 0; __orca_prompt_index + 1 < __orca_user_count; __orca_prompt_index++ )); do
- __orca_prompt_part="${__orca_prompt_command_array[__orca_prompt_index]}"
- __orca_dispatching_user_prompt_command=1
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_prompt_part"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_prompt_part"
- fi
- __orca_dispatching_user_prompt_command=""
- done
- if (( __orca_user_count > 0 )); then
- __orca_prompt_part="${__orca_prompt_command_array[__orca_user_count - 1]}"
- # Why: keep the final user hook and Orca suffixes in one status-preserving eval.
- __orca_final_prompt_command='eval "$__orca_prompt_part"'
- for __orca_suffix_part in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- __orca_final_prompt_command+=$'\n'"$__orca_suffix_part"
- done
- __orca_dispatching_user_prompt_command=1
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_final_prompt_command"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_final_prompt_command"
- fi
- __orca_dispatching_user_prompt_command=""
- else
- for __orca_prompt_part in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_prompt_part"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_prompt_part"
- fi
- done
- fi
- return "$__orca_exit_code"
-}
-__orca_finish_legacy_prompt_dispatch() {
- local __orca_suffix_part
- if [[ -n "${__orca_in_prompt_command:-}" ]]; then
- for __orca_suffix_part in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- eval "$__orca_suffix_part"
- done
- fi
-}
-__orca_normalize_prompt_command() {
- [[ -z "${__orca_prompt_command_normalized:-}" ]] || return 0
- local __orca_prompt_part
- local -a __orca_normalized=()
- for __orca_prompt_part in "${PROMPT_COMMAND[@]+"${PROMPT_COMMAND[@]}"}"; do
- __orca_normalize_prompt_command_part "$__orca_prompt_part" __orca_prompt_part
- [[ -n "$__orca_prompt_part" ]] && __orca_normalized+=("$__orca_prompt_part")
- done
- __orca_prompt_command_normalized=1
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- PROMPT_COMMAND=("${__orca_normalized[@]+"${__orca_normalized[@]}"}")
- else
- __orca_prompt_command_array=("${__orca_normalized[@]+"${__orca_normalized[@]}"}")
- __orca_prompt_command_prefix=()
- __orca_prompt_command_suffix=()
- unset PROMPT_COMMAND
- # Why: PID scope distinguishes legacy prompt dispatch from ordinary user command text.
- __orca_prompt_status_variable="__orca_prompt_status_$$"
- __orca_prompt_status_capture_command="$__orca_prompt_status_variable=\$?"
- __orca_prompt_status_value="\${$__orca_prompt_status_variable}"
- # Why: a changed DEBUG trap misses the capture command, and bash <= 4.3 reverts traps set in functions.
- PROMPT_COMMAND="$__orca_prompt_status_capture_command; __orca_in_legacy_prompt_wrapper=1; __orca_prompt_status=$__orca_prompt_status_value"'; __orca_prompt_had_functrace=""; if [[ -o functrace ]]; then __orca_prompt_had_functrace=1; set +T; fi; __orca_outer_debug_trap_spec="$(trap -p DEBUG)"; [[ -z "$__orca_prompt_had_functrace" ]] || set -T; unset __orca_prompt_had_functrace; __orca_run_prompt_command_array; __orca_finish_legacy_prompt_dispatch; trap __orca_osc133_preexec DEBUG; unset __orca_in_legacy_prompt_wrapper'
- fi
-}
-__orca_prepend_prompt_command() {
- local command="$1"
- __orca_normalize_prompt_command
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- PROMPT_COMMAND=("$command" "${PROMPT_COMMAND[@]+"${PROMPT_COMMAND[@]}"}")
- else
- __orca_prompt_command_prefix=("$command" "${__orca_prompt_command_prefix[@]+"${__orca_prompt_command_prefix[@]}"}")
- fi
-}
-__orca_append_prompt_command() {
- local command="$1"
- __orca_normalize_prompt_command
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- PROMPT_COMMAND+=("$command")
- else
- __orca_prompt_command_suffix+=("$command")
- fi
-}
-__orca_prepend_prompt_command "__orca_osc133_precmd"
-__orca_append_prompt_command '__orca_in_debug_capture=1; __orca_prompt_had_functrace=""; if [[ -o functrace ]]; then __orca_prompt_had_functrace=1; set +T; fi; __orca_outer_debug_trap_spec="$(trap -p DEBUG)"; [[ -z "$__orca_prompt_had_functrace" ]] || set -T; unset __orca_prompt_had_functrace __orca_in_debug_capture'
-__orca_append_prompt_command "__orca_osc133_epilogue"
-__orca_had_functrace=""
-[[ -o functrace ]] && __orca_had_functrace=1
-set +T
-__orca_debug_trap_spec="$(trap -p DEBUG)"
-[[ -z "$__orca_had_functrace" ]] || set -T
-if [[ -n "$__orca_debug_trap_spec" && "$__orca_debug_trap_spec" != "trap -- '__orca_osc133_preexec' DEBUG" ]]; then
- __orca_debug_trap_command="${__orca_debug_trap_spec#trap -- }"
- __orca_debug_trap_command="${__orca_debug_trap_command% DEBUG}"
- eval "__orca_user_debug_trap=$__orca_debug_trap_command"
-fi
-unset __orca_debug_trap_spec __orca_debug_trap_command __orca_had_functrace
-unset -f __orca_normalize_prompt_command_part __orca_normalize_prompt_command __orca_prepend_prompt_command __orca_append_prompt_command
-unset __orca_prompt_command_normalized
-# Arm DEBUG after setup so rcfile commands cannot emit a fake lifecycle before the first prompt.
-__orca_initial_prompt=1
-trap '__orca_osc133_preexec' DEBUG
-unset __orca_initializing_wrapper
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt
deleted file mode 100644
index 7c53db56ee8..00000000000
--- a/src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-function __orca_shell_ready_marker --on-event fish_prompt
- builtin printf "\033]777;orca-shell-ready\007"
- functions -e __orca_shell_ready_marker
-end
-# Why captured: an unquoted (type -t codex) expands to zero words when codex is
-# absent, leaving "test = file" — fish then errors instead of failing closed.
-# Quoting in place is not the fix; fish never substitutes inside double quotes.
-set -l __orca_codex_type (type -t codex 2>/dev/null)
-if test "$__orca_codex_type" = file
- function codex
- if test -x "$ORCA_CODEX_LAUNCH_PREFLIGHT"
- command "$ORCA_CODEX_LAUNCH_PREFLIGHT" agent hooks prepare-codex >/dev/null 2>&1; or true
- end
- if test "$ORCA_CODEX_ISOLATE" != 0; and not string match -qr -- '^(agents|queue|--remote|--remote=.*)$' $argv
- test -n "$ORCA_TERMINAL_HANDLE"; and not string match -q -- "*'*" "$ORCA_TERMINAL_HANDLE"; and set argv -c "shell_environment_policy.set.ORCA_TERMINAL_HANDLE='$ORCA_TERMINAL_HANDLE'" $argv
- test -n "$ORCA_PANE_KEY"; and not string match -q -- "*'*" "$ORCA_PANE_KEY"; and set argv -c "shell_environment_policy.set.ORCA_PANE_KEY='$ORCA_PANE_KEY'" $argv
- test -n "$ORCA_WORKTREE_ID"; and not string match -q -- "*'*" "$ORCA_WORKTREE_ID"; and set argv -c "shell_environment_policy.set.ORCA_WORKTREE_ID='$ORCA_WORKTREE_ID'" $argv
- test -n "$ORCA_WORKSPACE_ID"; and not string match -q -- "*'*" "$ORCA_WORKSPACE_ID"; and set argv -c "shell_environment_policy.set.ORCA_WORKSPACE_ID='$ORCA_WORKSPACE_ID'" $argv
- test -n "$ORCA_USER_DATA_PATH"; and not string match -q -- "*'*" "$ORCA_USER_DATA_PATH"; and set argv -c "shell_environment_policy.set.ORCA_USER_DATA_PATH='$ORCA_USER_DATA_PATH'" $argv
- end
- if test "$ORCA_CODEX_ISOLATE" != 0; and not string match -qr -- '^(agents|queue|--remote|--no-daemon|--remote=.*)$' $argv; and command codex --help 2>/dev/null </dev/null | string match -q -- '*--no-daemon*'
- set argv --no-daemon $argv
- end
- if test "$ORCA_REMOTE_VIEWER_CLIPBOARD" = 1; and not set -q SSH_CONNECTION; and not set -q SSH_TTY
- set -lx SSH_CONNECTION '127.0.0.1 0 127.0.0.1 0'
- command codex $argv
- else
- command codex $argv
- end
- end
-end
-set -e __orca_codex_type
-set -l __orca_claude_type (type -t claude 2>/dev/null)
-if test -n "$ORCA_CLAUDE_PROFILE_POINTER"; and test "$__orca_claude_type" = file
- function claude
- # Why: a WSL pane's pointer is relative to the guest home, which the host cannot know at spawn.
- set -l pointer (string replace -r '^~/' "$HOME/" -- "$ORCA_CLAUDE_PROFILE_POINTER")
- set -l profile (cat "$pointer" 2>/dev/null)
- set -l own (string trim -r -c / -- "$ORCA_CLAUDE_USER_CONFIG_DIR")
- set -l current (string trim -r -c / -- "$CLAUDE_CONFIG_DIR")
- if test -n "$CLAUDE_CONFIG_DIR"; and test "$CLAUDE_CONFIG_DIR" != "$ORCA_CLAUDE_INJECTED_CONFIG_DIR"; and begin; test -z "$own"; or test "$current" != "$own"; end
- command claude $argv
- return $status
- end
- if test -z "$profile"; and test -n "$CLAUDE_CONFIG_DIR"; and test -n "$ORCA_CLAUDE_USER_CONFIG_DIR"
- env -u ORCA_CLAUDE_INJECTED_CONFIG_DIR CLAUDE_CONFIG_DIR="$ORCA_CLAUDE_USER_CONFIG_DIR" claude $argv
- return $status
- end
- if test -z "$profile"
- env -u CLAUDE_CONFIG_DIR -u ORCA_CLAUDE_INJECTED_CONFIG_DIR claude $argv
- return $status
- end
- if not string match -qr '^(/|[A-Za-z]:)' -- "$profile"
- return 1
- end
- test -d "$profile"; or mkdir -p -m 700 -- "$profile" 2>/dev/null
- env CLAUDE_CONFIG_DIR="$profile" ORCA_CLAUDE_INJECTED_CONFIG_DIR="$profile" claude $argv
- end
-end
-set -e __orca_claude_type
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
deleted file mode 100644
index d34d74bfe28..00000000000
--- a/src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
+++ /dev/null
@@ -1,296 +0,0 @@
-# Orca daemon zsh shell-ready wrapper
-__orca_usable_zdotdir() {
- [[ -n "${1:-}" ]] || return 1
- [[ "$1" != */shell-ready/zsh ]] || return 1
- [[ ! -f "$1/.orca-shell-wrapper" ]] || return 1
- # Reject empty config roots so stale wrapper state cannot hide the user's real .zshenv.
- local _orca_startup_file
- for _orca_startup_file in .zshenv .zshrc .zprofile .zlogin; do
- [[ -r "$1/$_orca_startup_file" ]] && return 0
- done
- return 1
-}
-if __orca_usable_zdotdir "${ORCA_ORIG_ZDOTDIR:-}"; then
- builtin export ZDOTDIR="$ORCA_ORIG_ZDOTDIR"
-else
- builtin unset ZDOTDIR
-fi
-builtin unset ORCA_ORIG_ZDOTDIR ORCA_ZSHENV_SOURCE_DIR
-builtin unfunction __orca_usable_zdotdir
-builtin typeset -ga _orca_shell_features
-_orca_shell_features=(${(s:,:)${ORCA_SHELL_FEATURES:-}})
-builtin unset ORCA_SHELL_FEATURES
-# Consume now: user config can drop the deferred hook, leaving exported history state to leak into children.
-builtin typeset -g _orca_histfile="${ORCA_HISTFILE:-}"
-builtin unset ORCA_HISTFILE
-__orca_has_feature() { (( ${_orca_shell_features[(Ie)$1]} )) }
-__orca_has_feature identity && printf "\033]777;orca-shell-start:%s\007" "$$"
-__orca_osc133_precmd() {
- local exit_code=$?
- if [[ -n "${__orca_in_command:-}" ]]; then
- builtin printf "\033]133;D;%s\007" "$exit_code"
- builtin unset __orca_in_command
- fi
- builtin printf "\033]133;A\007"
-}
-__orca_osc133_preexec() {
- builtin printf "\033]133;C\007"
- # Declare explicitly to avoid warn_create_global output above every command.
- builtin typeset -g __orca_in_command=1
-}
-__orca_deferred_line_init() {
- builtin emulate -L zsh
- if [[ "${CONTEXT-}" != start ]]; then
- (( ${+widgets[__orca_saved_line_init]} )) && zle __orca_saved_line_init "$@"
- return 0
- fi
- (( ${+functions[__orca_deferred_init]} )) || return 0
- local __orca_direct_line_init=0
- [[ "${widgets[zle-line-init]:-}" == user:__orca_deferred_line_init ]] && __orca_direct_line_init=1
- __orca_deferred_init
- if (( __orca_direct_line_init && ${+widgets[zle-line-init]} )); then
- zle zle-line-init "$@"
- elif [[ "${widgets[zle-line-init]:-}" == user:__orca_prompt_mark ]]; then
- local __orca_prev_line_init_fn=""
- __orca_prompt_mark "$@"
- fi
-}
-# Run after user prompt hooks without copying their function metadata.
-__orca_deferred_sched_init() {
- local __orca_prompt_status=$?
- builtin emulate -L zsh
- (( ${+functions[__orca_deferred_init]} )) && __orca_deferred_init
- builtin unset __orca_deferred_sched_armed
- (( ${+functions[__orca_deferred_sched_init]} )) && builtin unfunction __orca_deferred_sched_init
- return $__orca_prompt_status
-}
-__orca_arm_deferred_line_init() {
- builtin emulate -L zsh
- if [[ "${widgets[zle-line-init]:-}" != user:__orca_deferred_line_init ]]; then
- if (( ${+widgets[zle-line-init]} )); then
- zle -A zle-line-init __orca_saved_line_init
- fi
- zle -N zle-line-init __orca_deferred_line_init
- fi
- if (( ! $+__orca_deferred_sched_armed )) && builtin zmodload -F zsh/sched b:sched 2>/dev/null; then
- builtin sched +0 __orca_deferred_sched_init && builtin typeset -g __orca_deferred_sched_armed=1
- fi
-}
-__orca_deferred_init() {
- # Reset user options: NO_UNSET can abort hooks and KSH_ARRAYS breaks the feature lookup.
- builtin emulate -L zsh
- # Startup files can invoke prompt hooks or nested editors before initialization ends.
- [[ ":$ZSH_EVAL_CONTEXT:" == *:file:* ]] && return 0
- (( $+_orca_deferred_init_done )) && return 0
- builtin typeset -g _orca_deferred_init_done=1
- builtin typeset -g precmd_functions
- if (( ${+widgets[__orca_saved_line_init]} )); then
- if [[ "${widgets[zle-line-init]:-}" == user:__orca_deferred_line_init ]]; then
- zle -A __orca_saved_line_init zle-line-init
- fi
- zle -D __orca_saved_line_init
- elif [[ "${widgets[zle-line-init]:-}" == user:__orca_deferred_line_init ]]; then
- zle -D zle-line-init
- fi
- if __orca_has_feature markers; then
- precmd_functions=(${precmd_functions:/__orca_deferred_init/__orca_osc133_precmd})
- (( ${precmd_functions[(Ie)__orca_osc133_precmd]} )) || precmd_functions+=(__orca_osc133_precmd)
- preexec_functions=(__orca_osc133_preexec ${preexec_functions[@]})
- else
- precmd_functions=(${precmd_functions:#__orca_deferred_init})
- fi
- if [ -n "${ORCA_CLI_BIN_DIR:-}" ]; then
- case "${PATH:-}" in
- "$ORCA_CLI_BIN_DIR"|"$ORCA_CLI_BIN_DIR":*) ;;
- *) export PATH="$ORCA_CLI_BIN_DIR${PATH:+:$PATH}" ;;
- esac
- fi
- if __orca_has_feature overlay; then
- # Why: ~/.zshrc can export the user's default OpenCode config after spawn.
- __orca_restore_agent_teams_path() {
- [[ -n "${ORCA_AGENT_TEAMS_SHIM_DIR:-}" ]] || return 0
- case "$PATH" in
- "${ORCA_AGENT_TEAMS_SHIM_DIR}"|"${ORCA_AGENT_TEAMS_SHIM_DIR}:"*) return 0 ;;
- esac
- export PATH="${ORCA_AGENT_TEAMS_SHIM_DIR}:$PATH"
- }
- __orca_restore_agent_teams_path
- [[ -n "${ORCA_OPENCODE_CONFIG_DIR:-}" ]] && export OPENCODE_CONFIG_DIR="${ORCA_OPENCODE_CONFIG_DIR}"
- if [[ -n "${ORCA_DATA_ACCOUNT_DATA_HOME:-}" ]]; then
- export XDG_DATA_HOME="${ORCA_DATA_ACCOUNT_DATA_HOME}"
- export XDG_STATE_HOME="${ORCA_DATA_ACCOUNT_STATE_HOME}"
- if [[ "${ORCA_DATA_ACCOUNT_PROVIDER:-}" == opencode ]]; then
- export OPENCODE_AUTH_CONTENT=""
- export OPENCODE_DB="opencode.db"
- fi
- fi
- [[ -n "${ORCA_MIMOCODE_CONFIG_DIR:-}" ]] && export MIMOCODE_CONFIG_DIR="${ORCA_MIMOCODE_CONFIG_DIR}"
- # Why: OMP does not auto-load Orca's managed status extension; wrap only
- # interactive launch invocations so subcommands such as `omp config` keep
- # their normal argv shape.
- __orca_omp_should_skip_extension() {
- case "${1:-}" in
- 'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
- '__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
- esac
- return 1
- }
- __orca_omp_cwd_is_usable() {
- local __orca_physical_cwd
- [[ -x . ]] || return 1
- if [[ -n "${PWD:-}" && -d "${PWD:-}" ]]; then
- [[ "${PWD}" -ef . ]]
- else
- # Why compare the path: shell builtins can print a cached path for a deleted cwd.
- __orca_physical_cwd="$(builtin pwd -P 2>/dev/null)" || return 1
- [[ -d "$__orca_physical_cwd" && "$__orca_physical_cwd" -ef . ]]
- fi
- }
- __orca_omp_invoke() {
- local __orca_use_extension="$1"
- shift
- if [[ $__orca_use_extension -eq 1 && -n "${ORCA_OMP_STATUS_EXTENSION:-}" && -f "${ORCA_OMP_STATUS_EXTENSION}" ]]; then
- if [[ "${1:-}" == "launch" ]]; then
- shift
- command omp launch --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- else
- command omp --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- fi
- else
- command omp "$@"
- fi
- }
- __orca_omp() {
- local __orca_use_extension=1
- __orca_omp_should_skip_extension "${1:-}" && __orca_use_extension=0
- if ! __orca_omp_cwd_is_usable; then
- local __orca_logical_cwd="${PWD:-${ORCA_WORKTREE_PATH:-${ORCA_ROOT_PATH:-}}}"
- # Why: a restored shell can retain the deleted directory inode after its path is recreated.
- (
- if [[ -z "$__orca_logical_cwd" ]]; then
- printf 'Orca: OMP cannot start because no terminal working directory is available. Open a new terminal in an existing directory.\n' >&2
- return 1
- fi
- if ! builtin cd -P -- "$__orca_logical_cwd" 2>/dev/null; then
- printf 'Orca: OMP cannot access the terminal working directory "%s". Open a new terminal in an existing directory.\n' "$__orca_logical_cwd" >&2
- return 1
- fi
- __orca_omp_invoke "$__orca_use_extension" "$@"
- )
- else
- __orca_omp_invoke "$__orca_use_extension" "$@"
- fi
- }
- if [[ -n "${ORCA_OMP_STATUS_EXTENSION:-}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name, which
- # an `alias omp` otherwise rewrites at parse time, aborting the rest of the file.
- function omp { __orca_omp "$@"; }
- fi
-
- # Restore the runtime CODEX_HOME after user rc files.
- [[ -n "${ORCA_CODEX_HOME:-}" ]] && export CODEX_HOME="${ORCA_CODEX_HOME}"
- fi
- # Why: a typed alias expands inside the shell, after pane launch prep.
- # Why unalias inside the substitution: an alias named codex makes command -v
- # report the alias text, and the subshell leaves the user's own alias intact.
- # Why || : twice — zsh alone aborts inside the substitution, but every shell's
- # assignment adopts its exit status, so an absent codex trips set -e in bash too.
- __orca_codex_binary="$(unalias codex 2>/dev/null || :; command -v codex 2>/dev/null || :)"
- if [[ -n "${__orca_codex_binary:-}" && -x "${__orca_codex_binary}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name,
- # which otherwise rewrites this header at parse time and aborts the whole file.
- function codex {
- # Why local: zsh's warn_create_global warns for each global a function creates.
- local __orca_codex_arg __orca_codex_isolate="${ORCA_CODEX_ISOLATE:-1}" __orca_codex_identity="${ORCA_CODEX_ISOLATE:-1}"
- if [[ "${ORCA_REMOTE_VIEWER_CLIPBOARD:-}" == 1 && -z "${SSH_CONNECTION+x}" && -z "${SSH_TTY+x}" ]]; then
- local -x SSH_CONNECTION='127.0.0.1 0 127.0.0.1 0'
- fi
- if [[ -n "${ORCA_CODEX_LAUNCH_PREFLIGHT:-}" && -x "${ORCA_CODEX_LAUNCH_PREFLIGHT}" ]]; then
- "${ORCA_CODEX_LAUNCH_PREFLIGHT}" agent hooks prepare-codex >/dev/null 2>&1 || :
- fi
- for __orca_codex_arg in "$@"; do
- case "$__orca_codex_arg" in
- --no-daemon) __orca_codex_isolate=0 ;;
- agents|queue|--remote|--remote=*) __orca_codex_isolate=0 __orca_codex_identity=0 ;;
- esac
- done
- if [[ "$__orca_codex_identity" != 0 ]]; then
- [[ -z "${ORCA_TERMINAL_HANDLE:-}" || "${ORCA_TERMINAL_HANDLE}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_TERMINAL_HANDLE='${ORCA_TERMINAL_HANDLE}'" "$@"
- [[ -z "${ORCA_PANE_KEY:-}" || "${ORCA_PANE_KEY}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_PANE_KEY='${ORCA_PANE_KEY}'" "$@"
- [[ -z "${ORCA_WORKTREE_ID:-}" || "${ORCA_WORKTREE_ID}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_WORKTREE_ID='${ORCA_WORKTREE_ID}'" "$@"
- [[ -z "${ORCA_WORKSPACE_ID:-}" || "${ORCA_WORKSPACE_ID}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_WORKSPACE_ID='${ORCA_WORKSPACE_ID}'" "$@"
- [[ -z "${ORCA_USER_DATA_PATH:-}" || "${ORCA_USER_DATA_PATH}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_USER_DATA_PATH='${ORCA_USER_DATA_PATH}'" "$@"
- fi
- # Why probe every launch: a cached answer goes stale across an upgrade, and 0.155 and older exit 2 on the flag.
- if [[ "$__orca_codex_isolate" != 0 ]]; then
- case "$(command codex --help 2>/dev/null </dev/null)" in *--no-daemon*) set -- --no-daemon "$@" ;; esac
- fi
- command codex "$@"
- }
- fi
- unset __orca_codex_binary
- __orca_claude_binary="$(unalias claude 2>/dev/null || :; command -v claude 2>/dev/null || :)"
- if [[ -n "${ORCA_CLAUDE_PROFILE_POINTER:-}" && -n "${__orca_claude_binary:-}" && -x "${__orca_claude_binary}" ]]; then
- function claude {
- local __orca_claude_home __orca_claude_pointer="${ORCA_CLAUDE_PROFILE_POINTER:-}"
- # Why: a WSL pane's pointer is relative to the guest home, which the host cannot know at spawn.
- case "$__orca_claude_pointer" in '~/'*) __orca_claude_pointer="${HOME:-}/${__orca_claude_pointer#??}" ;; esac
- __orca_claude_home="$(cat "$__orca_claude_pointer" 2>/dev/null || :)"
- if [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ "$CLAUDE_CONFIG_DIR" != "${ORCA_CLAUDE_INJECTED_CONFIG_DIR:-}" ] &&
- { [ -z "${ORCA_CLAUDE_USER_CONFIG_DIR:-}" ] || [ "${CLAUDE_CONFIG_DIR%/}" != "${ORCA_CLAUDE_USER_CONFIG_DIR%/}" ]; }; then
- command claude "$@"; return
- fi
- # Why: Orca's value replaced the user's own at spawn, so System default restores theirs.
- if [ -z "$__orca_claude_home" ] && [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ -n "${ORCA_CLAUDE_USER_CONFIG_DIR:-}" ]; then
- ( unset ORCA_CLAUDE_INJECTED_CONFIG_DIR; export CLAUDE_CONFIG_DIR="$ORCA_CLAUDE_USER_CONFIG_DIR"; command claude "$@" ); return
- fi
- if [ -z "$__orca_claude_home" ]; then
- ( unset CLAUDE_CONFIG_DIR ORCA_CLAUDE_INJECTED_CONFIG_DIR; command claude "$@" ); return
- fi
- case "$__orca_claude_home" in /*|[A-Za-z]:*) ;; *) return 1 ;; esac
- # Why -m 700: matches the folder Orca's setup creates; a credentials folder stays private.
- [ -d "$__orca_claude_home" ] || mkdir -p -m 700 -- "$__orca_claude_home" 2>/dev/null
- ( export CLAUDE_CONFIG_DIR="$__orca_claude_home" ORCA_CLAUDE_INJECTED_CONFIG_DIR="$__orca_claude_home"; command claude "$@" )
- }
- fi
- unset __orca_claude_binary
- if [[ -n "${_orca_histfile:-}" ]]; then
- HISTFILE="$_orca_histfile"
- fi
- if __orca_has_feature ready; then
- # Preserve the original user widget across re-sourcing; builtin/completion widgets cannot chain as plain functions.
- if [[ "${widgets[zle-line-init]:-}" == "user:__orca_prompt_mark" ]]; then
- :
- elif (( ${+widgets[zle-line-init]} )) && [[ "${widgets[zle-line-init]}" == user:* ]]; then
- __orca_prev_line_init_fn="${widgets[zle-line-init]#user:}"
- else
- __orca_prev_line_init_fn=""
- fi
- __orca_prompt_mark() {
- printf "\033]777;orca-shell-ready\007"
- # Call as a function so $WIDGET remains zle-line-init for add-zle-hook-widget dispatchers.
- if [[ -n "${__orca_prev_line_init_fn:-}" ]]; then
- "${__orca_prev_line_init_fn}" "$@"
- fi
- }
- zle -N zle-line-init __orca_prompt_mark
- fi
- # The permanent hook was added during this sweep; run it now so the first prompt gets its mark.
- __orca_has_feature markers && __orca_osc133_precmd
- builtin unset _orca_shell_features _orca_histfile
- if (( ! $+__orca_deferred_sched_armed && ${+functions[__orca_deferred_sched_init]} )); then
- builtin unfunction __orca_deferred_sched_init
- fi
- builtin unfunction __orca_deferred_init __orca_has_feature __orca_arm_deferred_line_init
-}
-{
- builtin typeset _orca_user_zshenv="${ZDOTDIR-$HOME}/.zshenv"
- [[ ! -r "$_orca_user_zshenv" ]] || builtin source -- "$_orca_user_zshenv"
-} always {
- builtin unset _orca_user_zshenv
- if (( ! $+_orca_deferred_init_done )); then
- builtin typeset -ag precmd_functions
- (( ${precmd_functions[(Ie)__orca_deferred_init]} )) || precmd_functions+=(__orca_deferred_init)
- __orca_arm_deferred_line_init
- fi
-}
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
deleted file mode 100644
index 47cbee76e2b..00000000000
--- a/src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
+++ /dev/null
@@ -1,488 +0,0 @@
-# Orca bash shell-ready wrapper
-_orca_shell_features=",${ORCA_SHELL_FEATURES:-},"
-builtin unset ORCA_SHELL_FEATURES
-__orca_has_feature() { [[ "$_orca_shell_features" == *",$1,"* ]]; }
-__orca_has_feature identity && printf "\033]777;orca-shell-start:%s\007" "$$"
-# Consume feature selection before startup files can inherit it into children.
-__orca_ready_marker=""
-__orca_has_feature ready && __orca_ready_marker=1
-unset _orca_shell_features
-unset -f __orca_has_feature
-[[ -f /etc/profile ]] && source /etc/profile
-if [[ -f "$HOME/.bash_profile" ]]; then
- source "$HOME/.bash_profile"
-elif [[ -f "$HOME/.bash_login" ]]; then
- source "$HOME/.bash_login"
-elif [[ -f "$HOME/.profile" ]]; then
- source "$HOME/.profile"
-fi
-# Older readline needs explicit bracketed paste so multiline prompts do not submit each newline.
-[[ $- == *i* ]] && bind 'set enable-bracketed-paste on' 2>/dev/null
-# Login profiles may already source .bashrc; sourcing it again would duplicate PATH, hooks and prompt setup.
-__orca_restore_agent_teams_path() {
- [[ -n "${ORCA_AGENT_TEAMS_SHIM_DIR:-}" ]] || return 0
- case "$PATH" in
- "${ORCA_AGENT_TEAMS_SHIM_DIR}"|"${ORCA_AGENT_TEAMS_SHIM_DIR}:"*) return 0 ;;
- esac
- export PATH="${ORCA_AGENT_TEAMS_SHIM_DIR}:$PATH"
-}
-__orca_restore_agent_teams_path
-if [ -n "${ORCA_CLI_BIN_DIR:-}" ]; then
- case "${PATH:-}" in
- "$ORCA_CLI_BIN_DIR"|"$ORCA_CLI_BIN_DIR":*) ;;
- *) export PATH="$ORCA_CLI_BIN_DIR${PATH:+:$PATH}" ;;
- esac
-fi
-if [ -n "${ORCA_WSL_CLI_DIR:-}" ]; then
- if [ -x "$ORCA_WSL_CLI_DIR/${ORCA_CLI_COMMAND:-}" ]; then
- export PATH="$ORCA_WSL_CLI_DIR${PATH:+:$PATH}"
- else
- printf 'Orca CLI unavailable: cannot run %s. Check WSL Windows-drive mount options.\n' "$ORCA_WSL_CLI_DIR/${ORCA_CLI_COMMAND:-}" >&2
- fi
-fi
-# Restore Orca-managed config after user startup files may override it.
-[[ -n "${ORCA_OPENCODE_CONFIG_DIR:-}" ]] && export OPENCODE_CONFIG_DIR="${ORCA_OPENCODE_CONFIG_DIR}"
-if [[ -n "${ORCA_DATA_ACCOUNT_DATA_HOME:-}" ]]; then
- export XDG_DATA_HOME="${ORCA_DATA_ACCOUNT_DATA_HOME}"
- export XDG_STATE_HOME="${ORCA_DATA_ACCOUNT_STATE_HOME}"
- if [[ "${ORCA_DATA_ACCOUNT_PROVIDER:-}" == opencode ]]; then
- export OPENCODE_AUTH_CONTENT=""
- export OPENCODE_DB="opencode.db"
- fi
-fi
-[[ -n "${ORCA_MIMOCODE_CONFIG_DIR:-}" ]] && export MIMOCODE_CONFIG_DIR="${ORCA_MIMOCODE_CONFIG_DIR}"
-# Why: OMP does not auto-load Orca's managed status extension; wrap only
-# interactive launch invocations so subcommands such as `omp config` keep
-# their normal argv shape.
-__orca_omp_should_skip_extension() {
- case "${1:-}" in
- 'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
- '__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
- esac
- return 1
-}
-__orca_omp_cwd_is_usable() {
- local __orca_physical_cwd
- [[ -x . ]] || return 1
- if [[ -n "${PWD:-}" && -d "${PWD:-}" ]]; then
- [[ "${PWD}" -ef . ]]
- else
- # Why compare the path: shell builtins can print a cached path for a deleted cwd.
- __orca_physical_cwd="$(builtin pwd -P 2>/dev/null)" || return 1
- [[ -d "$__orca_physical_cwd" && "$__orca_physical_cwd" -ef . ]]
- fi
-}
-__orca_omp_invoke() {
- local __orca_use_extension="$1"
- shift
- if [[ $__orca_use_extension -eq 1 && -n "${ORCA_OMP_STATUS_EXTENSION:-}" && -f "${ORCA_OMP_STATUS_EXTENSION}" ]]; then
- if [[ "${1:-}" == "launch" ]]; then
- shift
- command omp launch --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- else
- command omp --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- fi
- else
- command omp "$@"
- fi
-}
-__orca_omp() {
- local __orca_use_extension=1
- __orca_omp_should_skip_extension "${1:-}" && __orca_use_extension=0
- if ! __orca_omp_cwd_is_usable; then
- local __orca_logical_cwd="${PWD:-${ORCA_WORKTREE_PATH:-${ORCA_ROOT_PATH:-}}}"
- # Why: a restored shell can retain the deleted directory inode after its path is recreated.
- (
- if [[ -z "$__orca_logical_cwd" ]]; then
- printf 'Orca: OMP cannot start because no terminal working directory is available. Open a new terminal in an existing directory.\n' >&2
- return 1
- fi
- if ! builtin cd -P -- "$__orca_logical_cwd" 2>/dev/null; then
- printf 'Orca: OMP cannot access the terminal working directory "%s". Open a new terminal in an existing directory.\n' "$__orca_logical_cwd" >&2
- return 1
- fi
- __orca_omp_invoke "$__orca_use_extension" "$@"
- )
- else
- __orca_omp_invoke "$__orca_use_extension" "$@"
- fi
-}
-if [[ -n "${ORCA_OMP_STATUS_EXTENSION:-}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name, which
- # an `alias omp` otherwise rewrites at parse time, aborting the rest of the file.
- function omp { __orca_omp "$@"; }
-fi
-
-# Profile scripts must not replace Orca's runtime CODEX_HOME.
-[[ -n "${ORCA_CODEX_HOME:-}" ]] && export CODEX_HOME="${ORCA_CODEX_HOME}"
-# Why: a typed alias expands inside the shell, after pane launch prep.
-# Why unalias inside the substitution: an alias named codex makes command -v
-# report the alias text, and the subshell leaves the user's own alias intact.
-# Why || : twice — zsh alone aborts inside the substitution, but every shell's
-# assignment adopts its exit status, so an absent codex trips set -e in bash too.
-__orca_codex_binary="$(unalias codex 2>/dev/null || :; command -v codex 2>/dev/null || :)"
-if [[ -n "${__orca_codex_binary:-}" && -x "${__orca_codex_binary}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name,
- # which otherwise rewrites this header at parse time and aborts the whole file.
- function codex {
- # Why local: zsh's warn_create_global warns for each global a function creates.
- local __orca_codex_arg __orca_codex_isolate="${ORCA_CODEX_ISOLATE:-1}" __orca_codex_identity="${ORCA_CODEX_ISOLATE:-1}"
- if [[ "${ORCA_REMOTE_VIEWER_CLIPBOARD:-}" == 1 && -z "${SSH_CONNECTION+x}" && -z "${SSH_TTY+x}" ]]; then
- local -x SSH_CONNECTION='127.0.0.1 0 127.0.0.1 0'
- fi
- if [[ -n "${ORCA_CODEX_LAUNCH_PREFLIGHT:-}" && -x "${ORCA_CODEX_LAUNCH_PREFLIGHT}" ]]; then
- "${ORCA_CODEX_LAUNCH_PREFLIGHT}" agent hooks prepare-codex >/dev/null 2>&1 || :
- fi
- for __orca_codex_arg in "$@"; do
- case "$__orca_codex_arg" in
- --no-daemon) __orca_codex_isolate=0 ;;
- agents|queue|--remote|--remote=*) __orca_codex_isolate=0 __orca_codex_identity=0 ;;
- esac
- done
- if [[ "$__orca_codex_identity" != 0 ]]; then
- [[ -z "${ORCA_TERMINAL_HANDLE:-}" || "${ORCA_TERMINAL_HANDLE}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_TERMINAL_HANDLE='${ORCA_TERMINAL_HANDLE}'" "$@"
- [[ -z "${ORCA_PANE_KEY:-}" || "${ORCA_PANE_KEY}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_PANE_KEY='${ORCA_PANE_KEY}'" "$@"
- [[ -z "${ORCA_WORKTREE_ID:-}" || "${ORCA_WORKTREE_ID}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_WORKTREE_ID='${ORCA_WORKTREE_ID}'" "$@"
- [[ -z "${ORCA_WORKSPACE_ID:-}" || "${ORCA_WORKSPACE_ID}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_WORKSPACE_ID='${ORCA_WORKSPACE_ID}'" "$@"
- [[ -z "${ORCA_USER_DATA_PATH:-}" || "${ORCA_USER_DATA_PATH}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_USER_DATA_PATH='${ORCA_USER_DATA_PATH}'" "$@"
- fi
- # Why probe every launch: a cached answer goes stale across an upgrade, and 0.155 and older exit 2 on the flag.
- if [[ "$__orca_codex_isolate" != 0 ]]; then
- case "$(command codex --help 2>/dev/null </dev/null)" in *--no-daemon*) set -- --no-daemon "$@" ;; esac
- fi
- command codex "$@"
- }
-fi
-unset __orca_codex_binary
-__orca_claude_binary="$(unalias claude 2>/dev/null || :; command -v claude 2>/dev/null || :)"
-if [[ -n "${ORCA_CLAUDE_PROFILE_POINTER:-}" && -n "${__orca_claude_binary:-}" && -x "${__orca_claude_binary}" ]]; then
- function claude {
- local __orca_claude_home __orca_claude_pointer="${ORCA_CLAUDE_PROFILE_POINTER:-}"
- # Why: a WSL pane's pointer is relative to the guest home, which the host cannot know at spawn.
- case "$__orca_claude_pointer" in '~/'*) __orca_claude_pointer="${HOME:-}/${__orca_claude_pointer#??}" ;; esac
- __orca_claude_home="$(cat "$__orca_claude_pointer" 2>/dev/null || :)"
- if [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ "$CLAUDE_CONFIG_DIR" != "${ORCA_CLAUDE_INJECTED_CONFIG_DIR:-}" ] &&
- { [ -z "${ORCA_CLAUDE_USER_CONFIG_DIR:-}" ] || [ "${CLAUDE_CONFIG_DIR%/}" != "${ORCA_CLAUDE_USER_CONFIG_DIR%/}" ]; }; then
- command claude "$@"; return
- fi
- # Why: Orca's value replaced the user's own at spawn, so System default restores theirs.
- if [ -z "$__orca_claude_home" ] && [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ -n "${ORCA_CLAUDE_USER_CONFIG_DIR:-}" ]; then
- ( unset ORCA_CLAUDE_INJECTED_CONFIG_DIR; export CLAUDE_CONFIG_DIR="$ORCA_CLAUDE_USER_CONFIG_DIR"; command claude "$@" ); return
- fi
- if [ -z "$__orca_claude_home" ]; then
- ( unset CLAUDE_CONFIG_DIR ORCA_CLAUDE_INJECTED_CONFIG_DIR; command claude "$@" ); return
- fi
- case "$__orca_claude_home" in /*|[A-Za-z]:*) ;; *) return 1 ;; esac
- # Why -m 700: matches the folder Orca's setup creates; a credentials folder stays private.
- [ -d "$__orca_claude_home" ] || mkdir -p -m 700 -- "$__orca_claude_home" 2>/dev/null
- ( export CLAUDE_CONFIG_DIR="$__orca_claude_home" ORCA_CLAUDE_INJECTED_CONFIG_DIR="$__orca_claude_home"; command claude "$@" )
- }
-fi
-unset __orca_claude_binary
-
-__orca_wsl_cwd_report() {
- [[ -n "${WSL_DISTRO_NAME:-}" ]] || return 0
- if [[ "$PWD" != "${__orca_wsl_cwd_reported-}" ]]; then
- __orca_wsl_cwd_reported=$PWD
- local LC_ALL=C __orca_e= __orca_c __orca_i
- for (( __orca_i = 0; __orca_i < ${#PWD}; __orca_i++ )); do
- __orca_c=${PWD:__orca_i:1}
- case $__orca_c in
- [A-Za-z0-9/._~-]) __orca_e+=$__orca_c ;;
- *) printf -v __orca_c '%d' "'$__orca_c"; printf -v __orca_c '%%%02X' $(( __orca_c & 255 )); __orca_e+=$__orca_c ;;
- esac
- done
- __orca_wsl_cwd_encoded=$__orca_e
- fi
- printf '\033]7;file://%s\007' "${__orca_wsl_cwd_encoded-}"
-}
-# OSC 133 C/D clears agent status after interrupted CLIs exit without sending Stop/SessionEnd hooks.
-__orca_initializing_wrapper=1
-__orca_osc133_precmd() {
- local exit_code=$?
- __orca_in_prompt_command=1
- if [[ -n "${__orca_in_command:-}" ]]; then
- printf "\033]133;D;%s\007" "$exit_code"
- unset __orca_in_command
- fi
- printf "\033]133;A\007"
- __orca_wsl_cwd_report
- return "$exit_code"
-}
-__orca_osc133_prompt_done() {
- unset __orca_in_prompt_command
- __orca_adopt_outer_debug_trap
- trap '__orca_osc133_preexec' DEBUG
-}
-__orca_osc133_preexec() {
- if [[ -n "${__orca_prompt_status_capture_command:-}" && "$BASH_COMMAND" == "$__orca_prompt_status_capture_command" ]]; then
- unset __orca_initial_prompt
- __orca_in_legacy_prompt_wrapper=1
- return 0
- fi
- if [[ -n "${__orca_initializing_wrapper:-}${__orca_in_debug_capture:-}${__orca_initial_prompt:-}${__orca_in_prompt_dispatch:-}${__orca_in_legacy_prompt_wrapper:-}${__orca_in_prompt_command:-}" ]]; then
- [[ -z "${__orca_initializing_wrapper:-}${__orca_in_debug_capture:-}" ]] || return 0
- if [[ -n "${__orca_initial_prompt:-}" && "$BASH_COMMAND" == "__orca_osc133_precmd" ]]; then
- unset __orca_initial_prompt; return 0
- fi
- if [[ -n "${__orca_in_prompt_dispatch:-}" ]]; then
- [[ -n "${__orca_dispatching_user_prompt_command:-}" ]] || return 0
- if [[ "${FUNCNAME[1]:-}" == "__orca_run_prompt_command_array" ]]; then
- case "$BASH_COMMAND" in
- '(( __orca_exit_code == 0 ))'|'__orca_restore_prompt_status "$__orca_exit_code"'|'eval "$__orca_prompt_part"'|'eval "$__orca_final_prompt_command"'|__orca_dispatching_user_prompt_command=*|__orca_osc133_precmd|__orca_osc133_prompt_done|__orca_prompt_mark) return 0 ;;
- esac
- fi
- elif [[ "${FUNCNAME[1]:-}" == "__orca_run_prompt_command_array" || "$BASH_COMMAND" == "__orca_run_prompt_command_array" ]]; then
- return 0
- fi
- [[ -z "${__orca_in_legacy_prompt_wrapper:-}" || -n "${__orca_dispatching_user_prompt_command:-}" ]] || return 0
- if [[ -n "${__orca_in_prompt_command:-}" && "$BASH_COMMAND" == "__orca_in_debug_capture=1" ]]; then
- return 0
- fi
- fi
- case "${FUNCNAME[1]:-}" in __orca_osc133_*|__orca_prompt_mark|__orca_restore_prompt_status) return 0 ;; esac
- case "$BASH_COMMAND" in __orca_osc133_precmd|__orca_osc133_prompt_done|__orca_prompt_mark) return 0 ;; esac
- __orca_run_user_debug_trap
- [[ -z "${__orca_in_prompt_command:-}" ]] || return 0
- [[ -z "${__orca_in_command:-}" ]] || return 0
- # DEBUG runs per simple command; chained traps may reenter for the same foreground command.
- printf "\033]133;C\007"
- __orca_in_command=1
-}
-# Capture $? before the user's PROMPT_COMMAND chain mutates it.
-__orca_normalize_prompt_command_part() {
- local __orca_value="$1" __orca_output_name="$2" __orca_character __orca_chunk
- local __orca_value_length=${#1} __orca_suffix_length=0 __orca_backslash_length=0
- local __orca_output_length __orca_scan_start
- while (( __orca_value_length - __orca_suffix_length >= 1024 )); do
- __orca_scan_start=$(( __orca_value_length - __orca_suffix_length - 1024 ))
- __orca_chunk="${__orca_value:__orca_scan_start:1024}"
- case "$__orca_chunk" in
- *[!$' \t\n;']*) break ;;
- *) __orca_suffix_length=$(( __orca_suffix_length + 1024 )) ;;
- esac
- done
- while (( __orca_suffix_length < __orca_value_length )); do
- __orca_character="${__orca_value: -__orca_suffix_length - 1:1}"
- case "$__orca_character" in
- ' '|$'\t'|$'\n'|';') __orca_suffix_length=$(( __orca_suffix_length + 1 )) ;;
- *) break ;;
- esac
- done
- __orca_output_length=$(( ${#__orca_value} - __orca_suffix_length ))
- while (( __orca_output_length - __orca_backslash_length >= 1024 )); do
- __orca_scan_start=$(( __orca_output_length - __orca_backslash_length - 1024 ))
- __orca_chunk="${__orca_value:__orca_scan_start:1024}"
- case "$__orca_chunk" in
- *[!\\]*) break ;;
- *) __orca_backslash_length=$(( __orca_backslash_length + 1024 )) ;;
- esac
- done
- while (( __orca_backslash_length < __orca_output_length )); do
- __orca_character="${__orca_value:__orca_output_length - __orca_backslash_length - 1:1}"
- [[ "$__orca_character" == '\' ]] || break
- __orca_backslash_length=$(( __orca_backslash_length + 1 ))
- done
- # Preserve the first separator when an odd backslash run escapes it.
- if (( __orca_suffix_length > 0 && __orca_backslash_length % 2 == 1 )); then
- __orca_suffix_length=$(( __orca_suffix_length - 1 ))
- __orca_backslash_length=0
- fi
- __orca_output_length=$(( ${#__orca_value} - __orca_suffix_length ))
- __orca_value="${__orca_value:0:__orca_output_length}"
- # Bash 4.4-5.0 scalar prompt evaluation preserves an odd terminal backslash.
- if (( __orca_suffix_length == 0 && ((BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4) || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] == 0)) && __orca_backslash_length % 2 == 1 )); then
- __orca_value="$__orca_value\\"
- fi
- printf -v "$__orca_output_name" '%s' "$__orca_value"
-}
-__orca_restore_prompt_status() {
- return "$1"
-}
-__orca_update_user_debug_trap() {
- local __orca_debug_trap_spec="$1" __orca_unchanged_debug_trap_spec="$2"
- local __orca_debug_trap_command
- [[ "$__orca_debug_trap_spec" != "$__orca_unchanged_debug_trap_spec" ]] || return 0
- [[ "$__orca_debug_trap_spec" != "trap -- '__orca_osc133_preexec' DEBUG" ]] || return 0
- if [[ -z "$__orca_debug_trap_spec" ]]; then
- __orca_user_debug_trap=""
- unset __orca_chained_debug_trap
- return 0
- fi
- __orca_debug_trap_command="${__orca_debug_trap_spec#trap -- }"
- __orca_debug_trap_command="${__orca_debug_trap_command% DEBUG}"
- eval "__orca_user_debug_trap=$__orca_debug_trap_command"
- unset __orca_chained_debug_trap
-}
-__orca_run_user_debug_trap() {
- if [[ -n "${__orca_user_debug_trap:-}" ]]; then
- eval "$__orca_user_debug_trap" || true
- fi
-}
-__orca_adopt_outer_debug_trap() {
- local __orca_debug_trap_spec="${__orca_outer_debug_trap_spec:-}"
- unset __orca_outer_debug_trap_spec
- __orca_update_user_debug_trap "$__orca_debug_trap_spec" "trap -- '__orca_osc133_preexec' DEBUG"
-}
-__orca_run_prompt_command_array() {
- local __orca_exit_code="${__orca_prompt_status:-$?}" __orca_prompt_part __orca_prompt_index __orca_user_count
- local __orca_suffix_part
- local __orca_final_prompt_command
- local __orca_in_prompt_dispatch=1 __orca_dispatching_user_prompt_command=""
- unset __orca_prompt_status
- __orca_adopt_outer_debug_trap
- trap '__orca_osc133_preexec' DEBUG
- for __orca_prompt_part in "${__orca_prompt_command_prefix[@]+"${__orca_prompt_command_prefix[@]}"}"; do
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_prompt_part"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_prompt_part"
- fi
- done
- __orca_user_count=0
- for __orca_prompt_part in "${__orca_prompt_command_array[@]+"${__orca_prompt_command_array[@]}"}"; do
- __orca_user_count=$(( __orca_user_count + 1 ))
- done
- for (( __orca_prompt_index = 0; __orca_prompt_index + 1 < __orca_user_count; __orca_prompt_index++ )); do
- __orca_prompt_part="${__orca_prompt_command_array[__orca_prompt_index]}"
- __orca_dispatching_user_prompt_command=1
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_prompt_part"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_prompt_part"
- fi
- __orca_dispatching_user_prompt_command=""
- done
- if (( __orca_user_count > 0 )); then
- __orca_prompt_part="${__orca_prompt_command_array[__orca_user_count - 1]}"
- # Why: keep the final user hook and Orca suffixes in one status-preserving eval.
- __orca_final_prompt_command='eval "$__orca_prompt_part"'
- for __orca_suffix_part in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- __orca_final_prompt_command+=$'\n'"$__orca_suffix_part"
- done
- __orca_dispatching_user_prompt_command=1
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_final_prompt_command"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_final_prompt_command"
- fi
- __orca_dispatching_user_prompt_command=""
- else
- for __orca_prompt_part in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_prompt_part"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_prompt_part"
- fi
- done
- fi
- return "$__orca_exit_code"
-}
-__orca_finish_legacy_prompt_dispatch() {
- local __orca_suffix_part
- if [[ -n "${__orca_in_prompt_command:-}" ]]; then
- for __orca_suffix_part in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- eval "$__orca_suffix_part"
- done
- fi
-}
-__orca_normalize_prompt_command() {
- [[ -z "${__orca_prompt_command_normalized:-}" ]] || return 0
- local __orca_prompt_part
- local -a __orca_normalized=()
- for __orca_prompt_part in "${PROMPT_COMMAND[@]+"${PROMPT_COMMAND[@]}"}"; do
- __orca_normalize_prompt_command_part "$__orca_prompt_part" __orca_prompt_part
- [[ -n "$__orca_prompt_part" ]] && __orca_normalized+=("$__orca_prompt_part")
- done
- __orca_prompt_command_normalized=1
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- PROMPT_COMMAND=("${__orca_normalized[@]+"${__orca_normalized[@]}"}")
- else
- __orca_prompt_command_array=("${__orca_normalized[@]+"${__orca_normalized[@]}"}")
- __orca_prompt_command_prefix=()
- __orca_prompt_command_suffix=()
- unset PROMPT_COMMAND
- # Why: PID scope distinguishes legacy prompt dispatch from ordinary user command text.
- __orca_prompt_status_variable="__orca_prompt_status_$$"
- __orca_prompt_status_capture_command="$__orca_prompt_status_variable=\$?"
- __orca_prompt_status_value="\${$__orca_prompt_status_variable}"
- # Why: a changed DEBUG trap misses the capture command, and bash <= 4.3 reverts traps set in functions.
- PROMPT_COMMAND="$__orca_prompt_status_capture_command; __orca_in_legacy_prompt_wrapper=1; __orca_prompt_status=$__orca_prompt_status_value"'; __orca_prompt_had_functrace=""; if [[ -o functrace ]]; then __orca_prompt_had_functrace=1; set +T; fi; __orca_outer_debug_trap_spec="$(trap -p DEBUG)"; [[ -z "$__orca_prompt_had_functrace" ]] || set -T; unset __orca_prompt_had_functrace; __orca_run_prompt_command_array; __orca_finish_legacy_prompt_dispatch; trap __orca_osc133_preexec DEBUG; unset __orca_in_legacy_prompt_wrapper'
- fi
-}
-__orca_prepend_prompt_command() {
- local command="$1"
- __orca_normalize_prompt_command
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- PROMPT_COMMAND=("$command" "${PROMPT_COMMAND[@]+"${PROMPT_COMMAND[@]}"}")
- else
- __orca_prompt_command_prefix=("$command" "${__orca_prompt_command_prefix[@]+"${__orca_prompt_command_prefix[@]}"}")
- fi
-}
-__orca_append_prompt_command() {
- local command="$1"
- __orca_normalize_prompt_command
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- PROMPT_COMMAND+=("$command")
- else
- __orca_prompt_command_suffix+=("$command")
- fi
-}
-__orca_prepend_prompt_command "__orca_osc133_precmd"
-# Mark readiness after user prompt setup without rerunning startup files.
-if [[ -n "$__orca_ready_marker" ]]; then
- __orca_prompt_mark() {
- printf "\033]777;orca-shell-ready\007"
- }
- __orca_append_prompt_command "__orca_prompt_mark"
-fi
-__orca_append_prompt_command '__orca_in_debug_capture=1; __orca_prompt_had_functrace=""; if [[ -o functrace ]]; then __orca_prompt_had_functrace=1; set +T; fi; __orca_outer_debug_trap_spec="$(trap -p DEBUG)"; [[ -z "$__orca_prompt_had_functrace" ]] || set -T; unset __orca_prompt_had_functrace __orca_in_debug_capture'
-__orca_append_prompt_command "__orca_osc133_prompt_done"
-if [[ ${ORCA_POSIX_SHELL_STARTUP_COMMAND+present} == present ]]; then
- __orca_remove_startup_command_prompt_hook() {
- local __orca_item
- local -a __orca_remaining=()
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- for __orca_item in "${PROMPT_COMMAND[@]+"${PROMPT_COMMAND[@]}"}"; do
- [[ "$__orca_item" == "__orca_run_startup_command" ]] || __orca_remaining+=("$__orca_item")
- done
- PROMPT_COMMAND=("${__orca_remaining[@]+"${__orca_remaining[@]}"}")
- else
- for __orca_item in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- [[ "$__orca_item" == "__orca_run_startup_command" ]] || __orca_remaining+=("$__orca_item")
- done
- __orca_prompt_command_suffix=("${__orca_remaining[@]+"${__orca_remaining[@]}"}")
- fi
- }
- __orca_run_startup_command() {
- local __orca_command="$ORCA_POSIX_SHELL_STARTUP_COMMAND" __orca_status
- unset ORCA_POSIX_SHELL_STARTUP_COMMAND
- __orca_remove_startup_command_prompt_hook
- unset -f __orca_remove_startup_command_prompt_hook
- builtin history -s "$__orca_command" 2>/dev/null || true
- builtin printf '%s
-' "$__orca_command"
- eval "$__orca_command"
- __orca_status=$?
- unset -f __orca_run_startup_command
- return "$__orca_status"
- }
- __orca_append_prompt_command "__orca_run_startup_command"
-fi
-__orca_had_functrace=""
-[[ -o functrace ]] && __orca_had_functrace=1
-set +T
-__orca_debug_trap_spec="$(trap -p DEBUG)"
-[[ -z "$__orca_had_functrace" ]] || set -T
-if [[ -n "$__orca_debug_trap_spec" && "$__orca_debug_trap_spec" != "trap -- '__orca_osc133_preexec' DEBUG" ]]; then
- __orca_debug_trap_command="${__orca_debug_trap_spec#trap -- }"
- __orca_debug_trap_command="${__orca_debug_trap_command% DEBUG}"
- eval "__orca_user_debug_trap=$__orca_debug_trap_command"
-fi
-unset __orca_debug_trap_spec __orca_debug_trap_command __orca_had_functrace
-unset -f __orca_normalize_prompt_command_part __orca_normalize_prompt_command __orca_prepend_prompt_command __orca_append_prompt_command
-unset __orca_prompt_command_normalized
-# Arm DEBUG after wrapper setup to avoid fake foreground C/D events before the first prompt.
-__orca_initial_prompt=1
-trap '__orca_osc133_preexec' DEBUG
-unset __orca_initializing_wrapper
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt b/src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt
deleted file mode 100644
index 7c53db56ee8..00000000000
--- a/src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-function __orca_shell_ready_marker --on-event fish_prompt
- builtin printf "\033]777;orca-shell-ready\007"
- functions -e __orca_shell_ready_marker
-end
-# Why captured: an unquoted (type -t codex) expands to zero words when codex is
-# absent, leaving "test = file" — fish then errors instead of failing closed.
-# Quoting in place is not the fix; fish never substitutes inside double quotes.
-set -l __orca_codex_type (type -t codex 2>/dev/null)
-if test "$__orca_codex_type" = file
- function codex
- if test -x "$ORCA_CODEX_LAUNCH_PREFLIGHT"
- command "$ORCA_CODEX_LAUNCH_PREFLIGHT" agent hooks prepare-codex >/dev/null 2>&1; or true
- end
- if test "$ORCA_CODEX_ISOLATE" != 0; and not string match -qr -- '^(agents|queue|--remote|--remote=.*)$' $argv
- test -n "$ORCA_TERMINAL_HANDLE"; and not string match -q -- "*'*" "$ORCA_TERMINAL_HANDLE"; and set argv -c "shell_environment_policy.set.ORCA_TERMINAL_HANDLE='$ORCA_TERMINAL_HANDLE'" $argv
- test -n "$ORCA_PANE_KEY"; and not string match -q -- "*'*" "$ORCA_PANE_KEY"; and set argv -c "shell_environment_policy.set.ORCA_PANE_KEY='$ORCA_PANE_KEY'" $argv
- test -n "$ORCA_WORKTREE_ID"; and not string match -q -- "*'*" "$ORCA_WORKTREE_ID"; and set argv -c "shell_environment_policy.set.ORCA_WORKTREE_ID='$ORCA_WORKTREE_ID'" $argv
- test -n "$ORCA_WORKSPACE_ID"; and not string match -q -- "*'*" "$ORCA_WORKSPACE_ID"; and set argv -c "shell_environment_policy.set.ORCA_WORKSPACE_ID='$ORCA_WORKSPACE_ID'" $argv
- test -n "$ORCA_USER_DATA_PATH"; and not string match -q -- "*'*" "$ORCA_USER_DATA_PATH"; and set argv -c "shell_environment_policy.set.ORCA_USER_DATA_PATH='$ORCA_USER_DATA_PATH'" $argv
- end
- if test "$ORCA_CODEX_ISOLATE" != 0; and not string match -qr -- '^(agents|queue|--remote|--no-daemon|--remote=.*)$' $argv; and command codex --help 2>/dev/null </dev/null | string match -q -- '*--no-daemon*'
- set argv --no-daemon $argv
- end
- if test "$ORCA_REMOTE_VIEWER_CLIPBOARD" = 1; and not set -q SSH_CONNECTION; and not set -q SSH_TTY
- set -lx SSH_CONNECTION '127.0.0.1 0 127.0.0.1 0'
- command codex $argv
- else
- command codex $argv
- end
- end
-end
-set -e __orca_codex_type
-set -l __orca_claude_type (type -t claude 2>/dev/null)
-if test -n "$ORCA_CLAUDE_PROFILE_POINTER"; and test "$__orca_claude_type" = file
- function claude
- # Why: a WSL pane's pointer is relative to the guest home, which the host cannot know at spawn.
- set -l pointer (string replace -r '^~/' "$HOME/" -- "$ORCA_CLAUDE_PROFILE_POINTER")
- set -l profile (cat "$pointer" 2>/dev/null)
- set -l own (string trim -r -c / -- "$ORCA_CLAUDE_USER_CONFIG_DIR")
- set -l current (string trim -r -c / -- "$CLAUDE_CONFIG_DIR")
- if test -n "$CLAUDE_CONFIG_DIR"; and test "$CLAUDE_CONFIG_DIR" != "$ORCA_CLAUDE_INJECTED_CONFIG_DIR"; and begin; test -z "$own"; or test "$current" != "$own"; end
- command claude $argv
- return $status
- end
- if test -z "$profile"; and test -n "$CLAUDE_CONFIG_DIR"; and test -n "$ORCA_CLAUDE_USER_CONFIG_DIR"
- env -u ORCA_CLAUDE_INJECTED_CONFIG_DIR CLAUDE_CONFIG_DIR="$ORCA_CLAUDE_USER_CONFIG_DIR" claude $argv
- return $status
- end
- if test -z "$profile"
- env -u CLAUDE_CONFIG_DIR -u ORCA_CLAUDE_INJECTED_CONFIG_DIR claude $argv
- return $status
- end
- if not string match -qr '^(/|[A-Za-z]:)' -- "$profile"
- return 1
- end
- test -d "$profile"; or mkdir -p -m 700 -- "$profile" 2>/dev/null
- env CLAUDE_CONFIG_DIR="$profile" ORCA_CLAUDE_INJECTED_CONFIG_DIR="$profile" claude $argv
- end
-end
-set -e __orca_claude_type
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt b/src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
deleted file mode 100644
index 570320bed02..00000000000
--- a/src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
+++ /dev/null
@@ -1,335 +0,0 @@
-# Orca zsh shell-ready wrapper
-__orca_usable_zdotdir() {
- [[ -n "${1:-}" ]] || return 1
- [[ "$1" != */shell-ready/zsh ]] || return 1
- [[ ! -f "$1/.orca-shell-wrapper" ]] || return 1
- # Reject empty config roots so stale wrapper state cannot hide the user's real .zshenv.
- local _orca_startup_file
- for _orca_startup_file in .zshenv .zshrc .zprofile .zlogin; do
- [[ -r "$1/$_orca_startup_file" ]] && return 0
- done
- return 1
-}
-if __orca_usable_zdotdir "${ORCA_ORIG_ZDOTDIR:-}"; then
- builtin export ZDOTDIR="$ORCA_ORIG_ZDOTDIR"
-else
- builtin unset ZDOTDIR
-fi
-builtin unset ORCA_ORIG_ZDOTDIR ORCA_ZSHENV_SOURCE_DIR
-builtin unfunction __orca_usable_zdotdir
-builtin typeset -ga _orca_shell_features
-_orca_shell_features=(${(s:,:)${ORCA_SHELL_FEATURES:-}})
-builtin unset ORCA_SHELL_FEATURES
-# Consume now: user config can drop the deferred hook, leaving exported history state to leak into children.
-builtin typeset -g _orca_histfile="${ORCA_HISTFILE:-}"
-builtin unset ORCA_HISTFILE
-__orca_has_feature() { (( ${_orca_shell_features[(Ie)$1]} )) }
-__orca_has_feature identity && printf "\033]777;orca-shell-start:%s\007" "$$"
-__orca_osc133_precmd() {
- local exit_code=$?
- if [[ -n "${__orca_in_command:-}" ]]; then
- builtin printf "\033]133;D;%s\007" "$exit_code"
- builtin unset __orca_in_command
- fi
- builtin printf "\033]133;A\007"
-}
-__orca_osc133_preexec() {
- builtin printf "\033]133;C\007"
- # Declare explicitly to avoid warn_create_global output above every command.
- builtin typeset -g __orca_in_command=1
-}
-__orca_wsl_cwd_report() {
- builtin emulate -L zsh
- builtin setopt no_multibyte
- [[ -n ${WSL_DISTRO_NAME:-} ]] || return 0
- if [[ $PWD != ${__orca_wsl_cwd_reported-} ]]; then
- builtin typeset -g __orca_wsl_cwd_reported=$PWD
- local __orca_e= __orca_c __orca_i
- for (( __orca_i = 1; __orca_i <= $#PWD; __orca_i++ )); do
- __orca_c=$PWD[__orca_i]
- case $__orca_c in
- ([A-Za-z0-9/._~-]) __orca_e+=$__orca_c ;;
- (*) builtin printf -v __orca_c '%d' "'$__orca_c"; builtin printf -v __orca_c '%%%02X' $(( __orca_c & 255 )); __orca_e+=$__orca_c ;;
- esac
- done
- builtin typeset -g __orca_wsl_cwd_encoded=$__orca_e
- fi
- builtin printf '\033]7;file://%s\007' "${__orca_wsl_cwd_encoded-}"
-}
-__orca_deferred_line_init() {
- builtin emulate -L zsh
- if [[ "${CONTEXT-}" != start ]]; then
- (( ${+widgets[__orca_saved_line_init]} )) && zle __orca_saved_line_init "$@"
- return 0
- fi
- (( ${+functions[__orca_deferred_init]} )) || return 0
- local __orca_direct_line_init=0
- [[ "${widgets[zle-line-init]:-}" == user:__orca_deferred_line_init ]] && __orca_direct_line_init=1
- __orca_deferred_init
- if (( __orca_direct_line_init && ${+widgets[zle-line-init]} )); then
- zle zle-line-init "$@"
- elif [[ "${widgets[zle-line-init]:-}" == user:__orca_prompt_mark ]]; then
- local __orca_prev_line_init_fn=""
- __orca_prompt_mark "$@"
- fi
-}
-# Run after user prompt hooks without copying their function metadata.
-__orca_deferred_sched_init() {
- local __orca_prompt_status=$?
- builtin emulate -L zsh
- (( ${+functions[__orca_deferred_init]} )) && __orca_deferred_init
- builtin unset __orca_deferred_sched_armed
- (( ${+functions[__orca_deferred_sched_init]} )) && builtin unfunction __orca_deferred_sched_init
- return $__orca_prompt_status
-}
-__orca_arm_deferred_line_init() {
- builtin emulate -L zsh
- if [[ "${widgets[zle-line-init]:-}" != user:__orca_deferred_line_init ]]; then
- if (( ${+widgets[zle-line-init]} )); then
- zle -A zle-line-init __orca_saved_line_init
- fi
- zle -N zle-line-init __orca_deferred_line_init
- fi
- if (( ! $+__orca_deferred_sched_armed )) && builtin zmodload -F zsh/sched b:sched 2>/dev/null; then
- builtin sched +0 __orca_deferred_sched_init && builtin typeset -g __orca_deferred_sched_armed=1
- fi
-}
-__orca_deferred_init() {
- # Reset user options: NO_UNSET can abort hooks and KSH_ARRAYS breaks the feature lookup.
- builtin emulate -L zsh
- # Startup files can invoke prompt hooks or nested editors before initialization ends.
- [[ ":$ZSH_EVAL_CONTEXT:" == *:file:* ]] && return 0
- (( $+_orca_deferred_init_done )) && return 0
- builtin typeset -g _orca_deferred_init_done=1
- builtin typeset -g precmd_functions
- if (( ${+widgets[__orca_saved_line_init]} )); then
- if [[ "${widgets[zle-line-init]:-}" == user:__orca_deferred_line_init ]]; then
- zle -A __orca_saved_line_init zle-line-init
- fi
- zle -D __orca_saved_line_init
- elif [[ "${widgets[zle-line-init]:-}" == user:__orca_deferred_line_init ]]; then
- zle -D zle-line-init
- fi
- if __orca_has_feature markers; then
- precmd_functions=(${precmd_functions:/__orca_deferred_init/__orca_osc133_precmd})
- (( ${precmd_functions[(Ie)__orca_osc133_precmd]} )) || precmd_functions+=(__orca_osc133_precmd)
- preexec_functions=(__orca_osc133_preexec ${preexec_functions[@]})
- else
- precmd_functions=(${precmd_functions:#__orca_deferred_init})
- fi
- if [[ -n ${WSL_DISTRO_NAME:-} ]]; then
- (( ${precmd_functions[(Ie)__orca_wsl_cwd_report]} )) || precmd_functions+=(__orca_wsl_cwd_report)
- __orca_wsl_cwd_report
- fi
- if [ -n "${ORCA_WSL_CLI_DIR:-}" ]; then
- if [ -x "$ORCA_WSL_CLI_DIR/${ORCA_CLI_COMMAND:-}" ]; then
- export PATH="$ORCA_WSL_CLI_DIR${PATH:+:$PATH}"
- else
- printf 'Orca CLI unavailable: cannot run %s. Check WSL Windows-drive mount options.\n' "$ORCA_WSL_CLI_DIR/${ORCA_CLI_COMMAND:-}" >&2
- fi
- fi
- if [ -n "${ORCA_CLI_BIN_DIR:-}" ]; then
- case "${PATH:-}" in
- "$ORCA_CLI_BIN_DIR"|"$ORCA_CLI_BIN_DIR":*) ;;
- *) export PATH="$ORCA_CLI_BIN_DIR${PATH:+:$PATH}" ;;
- esac
- fi
- if __orca_has_feature overlay; then
- # Why: ~/.zshrc can export the user's default OpenCode config after spawn.
- __orca_restore_agent_teams_path() {
- [[ -n "${ORCA_AGENT_TEAMS_SHIM_DIR:-}" ]] || return 0
- case "$PATH" in
- "${ORCA_AGENT_TEAMS_SHIM_DIR}"|"${ORCA_AGENT_TEAMS_SHIM_DIR}:"*) return 0 ;;
- esac
- export PATH="${ORCA_AGENT_TEAMS_SHIM_DIR}:$PATH"
- }
- __orca_restore_agent_teams_path
- [[ -n "${ORCA_OPENCODE_CONFIG_DIR:-}" ]] && export OPENCODE_CONFIG_DIR="${ORCA_OPENCODE_CONFIG_DIR}"
- if [[ -n "${ORCA_DATA_ACCOUNT_DATA_HOME:-}" ]]; then
- export XDG_DATA_HOME="${ORCA_DATA_ACCOUNT_DATA_HOME}"
- export XDG_STATE_HOME="${ORCA_DATA_ACCOUNT_STATE_HOME}"
- if [[ "${ORCA_DATA_ACCOUNT_PROVIDER:-}" == opencode ]]; then
- export OPENCODE_AUTH_CONTENT=""
- export OPENCODE_DB="opencode.db"
- fi
- fi
- [[ -n "${ORCA_MIMOCODE_CONFIG_DIR:-}" ]] && export MIMOCODE_CONFIG_DIR="${ORCA_MIMOCODE_CONFIG_DIR}"
- # Why: OMP does not auto-load Orca's managed status extension; wrap only
- # interactive launch invocations so subcommands such as `omp config` keep
- # their normal argv shape.
- __orca_omp_should_skip_extension() {
- case "${1:-}" in
- 'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
- '__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
- esac
- return 1
- }
- __orca_omp_cwd_is_usable() {
- local __orca_physical_cwd
- [[ -x . ]] || return 1
- if [[ -n "${PWD:-}" && -d "${PWD:-}" ]]; then
- [[ "${PWD}" -ef . ]]
- else
- # Why compare the path: shell builtins can print a cached path for a deleted cwd.
- __orca_physical_cwd="$(builtin pwd -P 2>/dev/null)" || return 1
- [[ -d "$__orca_physical_cwd" && "$__orca_physical_cwd" -ef . ]]
- fi
- }
- __orca_omp_invoke() {
- local __orca_use_extension="$1"
- shift
- if [[ $__orca_use_extension -eq 1 && -n "${ORCA_OMP_STATUS_EXTENSION:-}" && -f "${ORCA_OMP_STATUS_EXTENSION}" ]]; then
- if [[ "${1:-}" == "launch" ]]; then
- shift
- command omp launch --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- else
- command omp --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- fi
- else
- command omp "$@"
- fi
- }
- __orca_omp() {
- local __orca_use_extension=1
- __orca_omp_should_skip_extension "${1:-}" && __orca_use_extension=0
- if ! __orca_omp_cwd_is_usable; then
- local __orca_logical_cwd="${PWD:-${ORCA_WORKTREE_PATH:-${ORCA_ROOT_PATH:-}}}"
- # Why: a restored shell can retain the deleted directory inode after its path is recreated.
- (
- if [[ -z "$__orca_logical_cwd" ]]; then
- printf 'Orca: OMP cannot start because no terminal working directory is available. Open a new terminal in an existing directory.\n' >&2
- return 1
- fi
- if ! builtin cd -P -- "$__orca_logical_cwd" 2>/dev/null; then
- printf 'Orca: OMP cannot access the terminal working directory "%s". Open a new terminal in an existing directory.\n' "$__orca_logical_cwd" >&2
- return 1
- fi
- __orca_omp_invoke "$__orca_use_extension" "$@"
- )
- else
- __orca_omp_invoke "$__orca_use_extension" "$@"
- fi
- }
- if [[ -n "${ORCA_OMP_STATUS_EXTENSION:-}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name, which
- # an `alias omp` otherwise rewrites at parse time, aborting the rest of the file.
- function omp { __orca_omp "$@"; }
- fi
-
- # Restore the runtime CODEX_HOME after user rc files.
- [[ -n "${ORCA_CODEX_HOME:-}" ]] && export CODEX_HOME="${ORCA_CODEX_HOME}"
- fi
- # Why: a typed alias expands inside the shell, after pane launch prep.
- # Why unalias inside the substitution: an alias named codex makes command -v
- # report the alias text, and the subshell leaves the user's own alias intact.
- # Why || : twice — zsh alone aborts inside the substitution, but every shell's
- # assignment adopts its exit status, so an absent codex trips set -e in bash too.
- __orca_codex_binary="$(unalias codex 2>/dev/null || :; command -v codex 2>/dev/null || :)"
- if [[ -n "${__orca_codex_binary:-}" && -x "${__orca_codex_binary}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name,
- # which otherwise rewrites this header at parse time and aborts the whole file.
- function codex {
- # Why local: zsh's warn_create_global warns for each global a function creates.
- local __orca_codex_arg __orca_codex_isolate="${ORCA_CODEX_ISOLATE:-1}" __orca_codex_identity="${ORCA_CODEX_ISOLATE:-1}"
- if [[ "${ORCA_REMOTE_VIEWER_CLIPBOARD:-}" == 1 && -z "${SSH_CONNECTION+x}" && -z "${SSH_TTY+x}" ]]; then
- local -x SSH_CONNECTION='127.0.0.1 0 127.0.0.1 0'
- fi
- if [[ -n "${ORCA_CODEX_LAUNCH_PREFLIGHT:-}" && -x "${ORCA_CODEX_LAUNCH_PREFLIGHT}" ]]; then
- "${ORCA_CODEX_LAUNCH_PREFLIGHT}" agent hooks prepare-codex >/dev/null 2>&1 || :
- fi
- for __orca_codex_arg in "$@"; do
- case "$__orca_codex_arg" in
- --no-daemon) __orca_codex_isolate=0 ;;
- agents|queue|--remote|--remote=*) __orca_codex_isolate=0 __orca_codex_identity=0 ;;
- esac
- done
- if [[ "$__orca_codex_identity" != 0 ]]; then
- [[ -z "${ORCA_TERMINAL_HANDLE:-}" || "${ORCA_TERMINAL_HANDLE}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_TERMINAL_HANDLE='${ORCA_TERMINAL_HANDLE}'" "$@"
- [[ -z "${ORCA_PANE_KEY:-}" || "${ORCA_PANE_KEY}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_PANE_KEY='${ORCA_PANE_KEY}'" "$@"
- [[ -z "${ORCA_WORKTREE_ID:-}" || "${ORCA_WORKTREE_ID}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_WORKTREE_ID='${ORCA_WORKTREE_ID}'" "$@"
- [[ -z "${ORCA_WORKSPACE_ID:-}" || "${ORCA_WORKSPACE_ID}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_WORKSPACE_ID='${ORCA_WORKSPACE_ID}'" "$@"
- [[ -z "${ORCA_USER_DATA_PATH:-}" || "${ORCA_USER_DATA_PATH}" == *"'"* ]] || set -- -c "shell_environment_policy.set.ORCA_USER_DATA_PATH='${ORCA_USER_DATA_PATH}'" "$@"
- fi
- # Why probe every launch: a cached answer goes stale across an upgrade, and 0.155 and older exit 2 on the flag.
- if [[ "$__orca_codex_isolate" != 0 ]]; then
- case "$(command codex --help 2>/dev/null </dev/null)" in *--no-daemon*) set -- --no-daemon "$@" ;; esac
- fi
- command codex "$@"
- }
- fi
- unset __orca_codex_binary
- __orca_claude_binary="$(unalias claude 2>/dev/null || :; command -v claude 2>/dev/null || :)"
- if [[ -n "${ORCA_CLAUDE_PROFILE_POINTER:-}" && -n "${__orca_claude_binary:-}" && -x "${__orca_claude_binary}" ]]; then
- function claude {
- local __orca_claude_home __orca_claude_pointer="${ORCA_CLAUDE_PROFILE_POINTER:-}"
- # Why: a WSL pane's pointer is relative to the guest home, which the host cannot know at spawn.
- case "$__orca_claude_pointer" in '~/'*) __orca_claude_pointer="${HOME:-}/${__orca_claude_pointer#??}" ;; esac
- __orca_claude_home="$(cat "$__orca_claude_pointer" 2>/dev/null || :)"
- if [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ "$CLAUDE_CONFIG_DIR" != "${ORCA_CLAUDE_INJECTED_CONFIG_DIR:-}" ] &&
- { [ -z "${ORCA_CLAUDE_USER_CONFIG_DIR:-}" ] || [ "${CLAUDE_CONFIG_DIR%/}" != "${ORCA_CLAUDE_USER_CONFIG_DIR%/}" ]; }; then
- command claude "$@"; return
- fi
- # Why: Orca's value replaced the user's own at spawn, so System default restores theirs.
- if [ -z "$__orca_claude_home" ] && [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ -n "${ORCA_CLAUDE_USER_CONFIG_DIR:-}" ]; then
- ( unset ORCA_CLAUDE_INJECTED_CONFIG_DIR; export CLAUDE_CONFIG_DIR="$ORCA_CLAUDE_USER_CONFIG_DIR"; command claude "$@" ); return
- fi
- if [ -z "$__orca_claude_home" ]; then
- ( unset CLAUDE_CONFIG_DIR ORCA_CLAUDE_INJECTED_CONFIG_DIR; command claude "$@" ); return
- fi
- case "$__orca_claude_home" in /*|[A-Za-z]:*) ;; *) return 1 ;; esac
- # Why -m 700: matches the folder Orca's setup creates; a credentials folder stays private.
- [ -d "$__orca_claude_home" ] || mkdir -p -m 700 -- "$__orca_claude_home" 2>/dev/null
- ( export CLAUDE_CONFIG_DIR="$__orca_claude_home" ORCA_CLAUDE_INJECTED_CONFIG_DIR="$__orca_claude_home"; command claude "$@" )
- }
- fi
- unset __orca_claude_binary
- if [[ -n "${_orca_histfile:-}" ]]; then
- HISTFILE="$_orca_histfile"
- fi
- if __orca_has_feature ready || __orca_has_feature startup; then
- __orca_emit_ready_marker=""
- __orca_has_feature ready && __orca_emit_ready_marker=1
- # Preserve the original user widget across re-sourcing; builtin/completion widgets cannot chain as plain functions.
- if [[ "${widgets[zle-line-init]:-}" == "user:__orca_prompt_mark" ]]; then
- :
- elif (( ${+widgets[zle-line-init]} )) && [[ "${widgets[zle-line-init]}" == user:* ]]; then
- __orca_prev_line_init_fn="${widgets[zle-line-init]#user:}"
- else
- __orca_prev_line_init_fn=""
- fi
- __orca_prompt_mark() {
- if [[ "${__orca_emit_ready_marker-1}" == 1 ]]; then
- printf "\033]777;orca-shell-ready\007"
- fi
- # Call as a function so $WIDGET remains zle-line-init for add-zle-hook-widget dispatchers.
- if [[ -n "${__orca_prev_line_init_fn:-}" ]]; then
- "${__orca_prev_line_init_fn}" "$@"
- fi
- if (( ${+ORCA_POSIX_SHELL_STARTUP_COMMAND} )); then
- BUFFER="$ORCA_POSIX_SHELL_STARTUP_COMMAND"
- CURSOR=${#BUFFER}
- builtin unset ORCA_POSIX_SHELL_STARTUP_COMMAND
- zle accept-line
- fi
- }
- zle -N zle-line-init __orca_prompt_mark
- fi
- # The permanent hook was added during this sweep; run it now so the first prompt gets its mark.
- __orca_has_feature markers && __orca_osc133_precmd
- builtin unset _orca_shell_features _orca_histfile
- if (( ! $+__orca_deferred_sched_armed && ${+functions[__orca_deferred_sched_init]} )); then
- builtin unfunction __orca_deferred_sched_init
- fi
- builtin unfunction __orca_deferred_init __orca_has_feature __orca_arm_deferred_line_init
-}
-{
- builtin typeset _orca_user_zshenv="${ZDOTDIR-$HOME}/.zshenv"
- [[ ! -r "$_orca_user_zshenv" ]] || builtin source -- "$_orca_user_zshenv"
-} always {
- builtin unset _orca_user_zshenv
- if (( ! $+_orca_deferred_init_done )); then
- builtin typeset -ag precmd_functions
- (( ${precmd_functions[(Ie)__orca_deferred_init]} )) || precmd_functions+=(__orca_deferred_init)
- __orca_arm_deferred_line_init
- fi
-}
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt
deleted file mode 100644
index 894f53fd4ce..00000000000
--- a/src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt
+++ /dev/null
@@ -1,392 +0,0 @@
-# Orca relay bash overlay wrapper
-_orca_shell_features=",${ORCA_SHELL_FEATURES:-},"
-builtin unset ORCA_SHELL_FEATURES
-__orca_has_feature() { [[ "$_orca_shell_features" == *",$1,"* ]]; }
-__orca_has_feature identity && printf "\033]777;orca-shell-start:%s\007" "$$"
-# Why a plain variable: the channel is consumed and destroyed in these first
-# lines, so nothing this shell later spawns can see or inherit the selection.
-__orca_ready_marker=""
-__orca_has_feature ready && __orca_ready_marker=1
-unset _orca_shell_features
-unset -f __orca_has_feature
-[[ -f /etc/profile ]] && source /etc/profile
-if [[ -f "$HOME/.bash_profile" ]]; then
- source "$HOME/.bash_profile"
-elif [[ -f "$HOME/.bash_login" ]]; then
- source "$HOME/.bash_login"
-elif [[ -f "$HOME/.profile" ]]; then
- source "$HOME/.profile"
-fi
-# Why: enable bracketed paste so Orca can deliver a multiline startup prompt as
-# a single literal paste (ESC[200~…ESC[201~); without it, older readline builds
-# treat each embedded newline as Enter and mangle the prompt into PS2
-# continuation. Modern readline defaults this on; force it for the rest.
-[[ $- == *i* ]] && bind 'set enable-bracketed-paste on' 2>/dev/null
-# Why: remote startup files can re-export user defaults after relay spawn.
-[[ -n "${ORCA_OPENCODE_CONFIG_DIR:-}" ]] && export OPENCODE_CONFIG_DIR="${ORCA_OPENCODE_CONFIG_DIR}"
-[[ -n "${ORCA_MIMOCODE_CONFIG_DIR:-}" ]] && export MIMOCODE_CONFIG_DIR="${ORCA_MIMOCODE_CONFIG_DIR}"
-[[ -n "${ORCA_REMOTE_CLI_BIN_DIR:-}" ]] && case ":$PATH:" in *:"${ORCA_REMOTE_CLI_BIN_DIR}":*) ;; *) export PATH="${ORCA_REMOTE_CLI_BIN_DIR}:$PATH" ;; esac
-if [ -n "${ORCA_CLI_BIN_DIR:-}" ]; then
- case "${PATH:-}" in
- "$ORCA_CLI_BIN_DIR"|"$ORCA_CLI_BIN_DIR":*) ;;
- *) export PATH="$ORCA_CLI_BIN_DIR${PATH:+:$PATH}" ;;
- esac
-fi
-# Why: OMP does not auto-load Orca's managed status extension; wrap only
-# interactive launch invocations so subcommands such as `omp config` keep
-# their normal argv shape.
-__orca_omp_should_skip_extension() {
- case "${1:-}" in
- 'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
- '__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
- esac
- return 1
-}
-__orca_omp_cwd_is_usable() {
- local __orca_physical_cwd
- [[ -x . ]] || return 1
- if [[ -n "${PWD:-}" && -d "${PWD:-}" ]]; then
- [[ "${PWD}" -ef . ]]
- else
- # Why compare the path: shell builtins can print a cached path for a deleted cwd.
- __orca_physical_cwd="$(builtin pwd -P 2>/dev/null)" || return 1
- [[ -d "$__orca_physical_cwd" && "$__orca_physical_cwd" -ef . ]]
- fi
-}
-__orca_omp_invoke() {
- local __orca_use_extension="$1"
- shift
- if [[ $__orca_use_extension -eq 1 && -n "${ORCA_OMP_STATUS_EXTENSION:-}" && -f "${ORCA_OMP_STATUS_EXTENSION}" ]]; then
- if [[ "${1:-}" == "launch" ]]; then
- shift
- command omp launch --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- else
- command omp --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- fi
- else
- command omp "$@"
- fi
-}
-__orca_omp() {
- local __orca_use_extension=1
- __orca_omp_should_skip_extension "${1:-}" && __orca_use_extension=0
- if ! __orca_omp_cwd_is_usable; then
- local __orca_logical_cwd="${PWD:-${ORCA_WORKTREE_PATH:-${ORCA_ROOT_PATH:-}}}"
- # Why: a restored shell can retain the deleted directory inode after its path is recreated.
- (
- if [[ -z "$__orca_logical_cwd" ]]; then
- printf 'Orca: OMP cannot start because no terminal working directory is available. Open a new terminal in an existing directory.\n' >&2
- return 1
- fi
- if ! builtin cd -P -- "$__orca_logical_cwd" 2>/dev/null; then
- printf 'Orca: OMP cannot access the terminal working directory "%s". Open a new terminal in an existing directory.\n' "$__orca_logical_cwd" >&2
- return 1
- fi
- __orca_omp_invoke "$__orca_use_extension" "$@"
- )
- else
- __orca_omp_invoke "$__orca_use_extension" "$@"
- fi
-}
-if [[ -n "${ORCA_OMP_STATUS_EXTENSION:-}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name, which
- # an `alias omp` otherwise rewrites at parse time, aborting the rest of the file.
- function omp { __orca_omp "$@"; }
-fi
-
-# Why: a typed alias expands inside the shell, after pane launch prep.
-# Why unalias inside the substitution: an alias named codex makes command -v
-# report the alias text, and the subshell leaves the user's own alias intact.
-# Why || : twice — zsh alone aborts inside the substitution, but every shell's
-# assignment adopts its exit status, so an absent codex trips set -e in bash too.
-__orca_codex_binary="$(unalias codex 2>/dev/null || :; command -v codex 2>/dev/null || :)"
-if [[ -n "${__orca_codex_binary:-}" && -x "${__orca_codex_binary}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name,
- # which otherwise rewrites this header at parse time and aborts the whole file.
- function codex {
- # Why local: zsh's warn_create_global warns for each global a function creates.
- local __orca_codex_arg __orca_codex_isolate="${ORCA_CODEX_ISOLATE:-1}"
- if [[ -n "${ORCA_CODEX_LAUNCH_PREFLIGHT:-}" && -x "${ORCA_CODEX_LAUNCH_PREFLIGHT}" ]]; then
- "${ORCA_CODEX_LAUNCH_PREFLIGHT}" agent hooks prepare-codex >/dev/null 2>&1 || :
- fi
- for __orca_codex_arg in "$@"; do
- case "$__orca_codex_arg" in agents|queue|--no-daemon|--remote|--remote=*) __orca_codex_isolate=0 ;; esac
- done
- # Why probe every launch: a cached answer goes stale across an upgrade, and 0.155 and older exit 2 on the flag.
- if [[ "$__orca_codex_isolate" != 0 ]]; then
- case "$(command codex --help 2>/dev/null </dev/null)" in *--no-daemon*) set -- --no-daemon "$@" ;; esac
- fi
- command codex "$@"
- }
-fi
-unset __orca_codex_binary
-if [[ -n "${ORCA_HISTFILE:-}" ]]; then
- HISTFILE="$ORCA_HISTFILE"
- builtin unset ORCA_HISTFILE
-elif [[ "${HISTFILE:-}" == "$ZDOTDIR/.zsh_history" ]]; then
- # Why also when Orca injected nothing: /etc/zshrc derived this from Orca's
- # wrapper ZDOTDIR, so history would accumulate INSIDE the wrapper dir and the
- # user's real history would be invisible — the plain #11044 bug, with no
- # per-worktree scoping involved. Matching the exact clobbered value means a
- # HISTFILE the user set deliberately is never touched.
- HISTFILE="${ORCA_ORIG_ZDOTDIR:-$HOME}/.zsh_history"
-fi
-# Why: SSH bash sessions need the same command lifecycle markers as local
-# bash so agent rows stop showing "working" when the foreground command exits.
-__orca_initializing_wrapper=1
-__orca_osc133_precmd() {
- local exit_code=$?
- __orca_in_prompt_command=1
- if [[ -n "${__orca_in_command:-}" ]]; then
- printf "\033]133;D;%s\007" "$exit_code"
- unset __orca_in_command
- fi
- printf "\033]133;A\007"
- return "$exit_code"
-}
-__orca_osc133_prompt_done() {
- unset __orca_in_prompt_command; __orca_adopt_outer_debug_trap
- trap '__orca_osc133_preexec' DEBUG
-}
-__orca_osc133_preexec() {
- if [[ -n "${__orca_prompt_status_capture_command:-}" && "$BASH_COMMAND" == "$__orca_prompt_status_capture_command" ]]; then
- unset __orca_initial_prompt
- __orca_in_legacy_prompt_wrapper=1
- return 0
- fi
- if [[ -n "${__orca_initializing_wrapper:-}${__orca_in_debug_capture:-}${__orca_initial_prompt:-}${__orca_in_prompt_dispatch:-}${__orca_in_legacy_prompt_wrapper:-}${__orca_in_prompt_command:-}" ]]; then
- [[ -z "${__orca_initializing_wrapper:-}${__orca_in_debug_capture:-}" ]] || return 0
- if [[ -n "${__orca_initial_prompt:-}" && "$BASH_COMMAND" == "__orca_osc133_precmd" ]]; then
- unset __orca_initial_prompt; return 0
- fi
- if [[ -n "${__orca_in_prompt_dispatch:-}" ]]; then
- [[ -n "${__orca_dispatching_user_prompt_command:-}" ]] || return 0
- if [[ "${FUNCNAME[1]:-}" == "__orca_run_prompt_command_array" ]]; then
- case "$BASH_COMMAND" in
- '(( __orca_exit_code == 0 ))'|'__orca_restore_prompt_status "$__orca_exit_code"'|'eval "$__orca_prompt_part"'|'eval "$__orca_final_prompt_command"'|__orca_dispatching_user_prompt_command=*|__orca_osc133_precmd|__orca_osc133_prompt_done|__orca_prompt_mark) return 0 ;;
- esac
- fi
- elif [[ "${FUNCNAME[1]:-}" == "__orca_run_prompt_command_array" || "$BASH_COMMAND" == "__orca_run_prompt_command_array" ]]; then
- return 0
- fi
- [[ -z "${__orca_in_legacy_prompt_wrapper:-}" || -n "${__orca_dispatching_user_prompt_command:-}" ]] || return 0
- if [[ -n "${__orca_in_prompt_command:-}" && "$BASH_COMMAND" == "__orca_in_debug_capture=1" ]]; then
- return 0
- fi
- fi
- case "${FUNCNAME[1]:-}" in __orca_osc133_*|__orca_prompt_mark|__orca_restore_prompt_status) return 0 ;; esac
- case "$BASH_COMMAND" in __orca_osc133_precmd|__orca_osc133_prompt_done|__orca_prompt_mark) return 0 ;; esac
- __orca_run_user_debug_trap
- [[ -z "${__orca_in_prompt_command:-}" ]] || return 0
- [[ -z "${__orca_in_command:-}" ]] || return 0
- printf "\033]133;C\007"
- __orca_in_command=1
-}
-__orca_normalize_prompt_command_part() {
- local __orca_value="$1" __orca_output_name="$2" __orca_character __orca_chunk
- local __orca_value_length=${#1} __orca_suffix_length=0 __orca_backslash_length=0
- local __orca_output_length __orca_scan_start
- while (( __orca_value_length - __orca_suffix_length >= 1024 )); do
- __orca_scan_start=$(( __orca_value_length - __orca_suffix_length - 1024 ))
- __orca_chunk="${__orca_value:__orca_scan_start:1024}"
- case "$__orca_chunk" in
- *[!$' \t\n;']*) break ;;
- *) __orca_suffix_length=$(( __orca_suffix_length + 1024 )) ;;
- esac
- done
- while (( __orca_suffix_length < __orca_value_length )); do
- __orca_character="${__orca_value: -__orca_suffix_length - 1:1}"
- case "$__orca_character" in
- ' '|$'\t'|$'\n'|';') __orca_suffix_length=$(( __orca_suffix_length + 1 )) ;;
- *) break ;;
- esac
- done
- __orca_output_length=$(( ${#__orca_value} - __orca_suffix_length ))
- while (( __orca_output_length - __orca_backslash_length >= 1024 )); do
- __orca_scan_start=$(( __orca_output_length - __orca_backslash_length - 1024 ))
- __orca_chunk="${__orca_value:__orca_scan_start:1024}"
- case "$__orca_chunk" in
- *[!\\]*) break ;;
- *) __orca_backslash_length=$(( __orca_backslash_length + 1024 )) ;;
- esac
- done
- while (( __orca_backslash_length < __orca_output_length )); do
- __orca_character="${__orca_value:__orca_output_length - __orca_backslash_length - 1:1}"
- [[ "$__orca_character" == '\' ]] || break
- __orca_backslash_length=$(( __orca_backslash_length + 1 ))
- done
- # Preserve the first separator when an odd backslash run escapes it.
- if (( __orca_suffix_length > 0 && __orca_backslash_length % 2 == 1 )); then
- __orca_suffix_length=$(( __orca_suffix_length - 1 ))
- __orca_backslash_length=0
- fi
- __orca_output_length=$(( ${#__orca_value} - __orca_suffix_length ))
- __orca_value="${__orca_value:0:__orca_output_length}"
- # Bash 4.4-5.0 scalar prompt evaluation preserves an odd terminal backslash.
- if (( __orca_suffix_length == 0 && ((BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4) || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] == 0)) && __orca_backslash_length % 2 == 1 )); then
- __orca_value="$__orca_value\\"
- fi
- printf -v "$__orca_output_name" '%s' "$__orca_value"
-}
-__orca_restore_prompt_status() {
- return "$1"
-}
-__orca_update_user_debug_trap() {
- local __orca_debug_trap_spec="$1" __orca_unchanged_debug_trap_spec="$2"
- local __orca_debug_trap_command
- [[ "$__orca_debug_trap_spec" != "$__orca_unchanged_debug_trap_spec" ]] || return 0
- [[ "$__orca_debug_trap_spec" != "trap -- '__orca_osc133_preexec' DEBUG" ]] || return 0
- if [[ -z "$__orca_debug_trap_spec" ]]; then
- __orca_user_debug_trap=""
- unset __orca_chained_debug_trap
- return 0
- fi
- __orca_debug_trap_command="${__orca_debug_trap_spec#trap -- }"
- __orca_debug_trap_command="${__orca_debug_trap_command% DEBUG}"
- eval "__orca_user_debug_trap=$__orca_debug_trap_command"
- unset __orca_chained_debug_trap
-}
-__orca_run_user_debug_trap() {
- if [[ -n "${__orca_user_debug_trap:-}" ]]; then
- eval "$__orca_user_debug_trap" || true
- fi
-}
-__orca_adopt_outer_debug_trap() {
- local __orca_debug_trap_spec="${__orca_outer_debug_trap_spec:-}"
- unset __orca_outer_debug_trap_spec
- __orca_update_user_debug_trap "$__orca_debug_trap_spec" "trap -- '__orca_osc133_preexec' DEBUG"
-}
-__orca_run_prompt_command_array() {
- local __orca_exit_code="${__orca_prompt_status:-$?}" __orca_prompt_part __orca_prompt_index __orca_user_count
- local __orca_suffix_part
- local __orca_final_prompt_command
- local __orca_in_prompt_dispatch=1 __orca_dispatching_user_prompt_command=""
- unset __orca_prompt_status
- __orca_adopt_outer_debug_trap
- trap '__orca_osc133_preexec' DEBUG
- for __orca_prompt_part in "${__orca_prompt_command_prefix[@]+"${__orca_prompt_command_prefix[@]}"}"; do
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_prompt_part"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_prompt_part"
- fi
- done
- __orca_user_count=0
- for __orca_prompt_part in "${__orca_prompt_command_array[@]+"${__orca_prompt_command_array[@]}"}"; do
- __orca_user_count=$(( __orca_user_count + 1 ))
- done
- for (( __orca_prompt_index = 0; __orca_prompt_index + 1 < __orca_user_count; __orca_prompt_index++ )); do
- __orca_prompt_part="${__orca_prompt_command_array[__orca_prompt_index]}"
- __orca_dispatching_user_prompt_command=1
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_prompt_part"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_prompt_part"
- fi
- __orca_dispatching_user_prompt_command=""
- done
- if (( __orca_user_count > 0 )); then
- __orca_prompt_part="${__orca_prompt_command_array[__orca_user_count - 1]}"
- # Why: keep the final user hook and Orca suffixes in one status-preserving eval.
- __orca_final_prompt_command='eval "$__orca_prompt_part"'
- for __orca_suffix_part in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- __orca_final_prompt_command+=$'\n'"$__orca_suffix_part"
- done
- __orca_dispatching_user_prompt_command=1
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_final_prompt_command"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_final_prompt_command"
- fi
- __orca_dispatching_user_prompt_command=""
- else
- for __orca_prompt_part in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- if (( __orca_exit_code == 0 )); then
- eval "$__orca_prompt_part"
- else
- __orca_restore_prompt_status "$__orca_exit_code" || eval "$__orca_prompt_part"
- fi
- done
- fi
- return "$__orca_exit_code"
-}
-__orca_finish_legacy_prompt_dispatch() {
- local __orca_suffix_part
- if [[ -n "${__orca_in_prompt_command:-}" ]]; then
- for __orca_suffix_part in "${__orca_prompt_command_suffix[@]+"${__orca_prompt_command_suffix[@]}"}"; do
- eval "$__orca_suffix_part"
- done
- fi
- trap '__orca_osc133_preexec' DEBUG
- unset __orca_in_legacy_prompt_wrapper
-}
-__orca_normalize_prompt_command() {
- [[ -z "${__orca_prompt_command_normalized:-}" ]] || return 0
- local __orca_prompt_part
- local -a __orca_normalized=()
- for __orca_prompt_part in "${PROMPT_COMMAND[@]+"${PROMPT_COMMAND[@]}"}"; do
- __orca_normalize_prompt_command_part "$__orca_prompt_part" __orca_prompt_part
- [[ -n "$__orca_prompt_part" ]] && __orca_normalized+=("$__orca_prompt_part")
- done
- __orca_prompt_command_normalized=1
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- PROMPT_COMMAND=("${__orca_normalized[@]+"${__orca_normalized[@]}"}")
- else
- __orca_prompt_command_array=("${__orca_normalized[@]+"${__orca_normalized[@]}"}")
- __orca_prompt_command_prefix=()
- __orca_prompt_command_suffix=()
- unset PROMPT_COMMAND
- # Why: PID scope distinguishes legacy prompt dispatch from ordinary user command text.
- __orca_prompt_status_variable="__orca_prompt_status_$$"
- __orca_prompt_status_capture_command="$__orca_prompt_status_variable=\$?"
- __orca_prompt_status_value="\${$__orca_prompt_status_variable}"
- PROMPT_COMMAND="$__orca_prompt_status_capture_command; __orca_prompt_status=$__orca_prompt_status_value"'; __orca_prompt_had_functrace=""; if [[ -o functrace ]]; then __orca_prompt_had_functrace=1; set +T; fi; __orca_outer_debug_trap_spec="$(trap -p DEBUG)"; [[ -z "$__orca_prompt_had_functrace" ]] || set -T; unset __orca_prompt_had_functrace; __orca_run_prompt_command_array; __orca_finish_legacy_prompt_dispatch'
- fi
-}
-__orca_prepend_prompt_command() {
- local command="$1"
- __orca_normalize_prompt_command
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- PROMPT_COMMAND=("$command" "${PROMPT_COMMAND[@]+"${PROMPT_COMMAND[@]}"}")
- else
- __orca_prompt_command_prefix=("$command" "${__orca_prompt_command_prefix[@]+"${__orca_prompt_command_prefix[@]}"}")
- fi
-}
-__orca_append_prompt_command() {
- local command="$1"
- __orca_normalize_prompt_command
- if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 1) )); then
- PROMPT_COMMAND+=("$command")
- else
- __orca_prompt_command_suffix+=("$command")
- fi
-}
-__orca_prepend_prompt_command "__orca_osc133_precmd"
-# Why: SSH startup commands are renderer-delivered; emit the same internal
-# readiness marker as local shells only when that delivery mode asks for it.
-if [[ -n "$__orca_ready_marker" ]]; then
- __orca_prompt_mark() {
- printf "\033]777;orca-shell-ready\007"
- }
- __orca_append_prompt_command "__orca_prompt_mark"
-fi
-__orca_append_prompt_command '__orca_in_debug_capture=1; __orca_prompt_had_functrace=""; if [[ -o functrace ]]; then __orca_prompt_had_functrace=1; set +T; fi; __orca_outer_debug_trap_spec="$(trap -p DEBUG)"; [[ -z "$__orca_prompt_had_functrace" ]] || set -T; unset __orca_prompt_had_functrace __orca_in_debug_capture'
-__orca_append_prompt_command "__orca_osc133_prompt_done"
-__orca_had_functrace=""
-[[ -o functrace ]] && __orca_had_functrace=1
-set +T
-__orca_debug_trap_spec="$(trap -p DEBUG)"
-[[ -z "$__orca_had_functrace" ]] || set -T
-if [[ -n "$__orca_debug_trap_spec" && "$__orca_debug_trap_spec" != "trap -- '__orca_osc133_preexec' DEBUG" ]]; then
- __orca_debug_trap_command="${__orca_debug_trap_spec#trap -- }"
- __orca_debug_trap_command="${__orca_debug_trap_command% DEBUG}"
- eval "__orca_user_debug_trap=$__orca_debug_trap_command"
-fi
-unset __orca_debug_trap_spec __orca_debug_trap_command __orca_had_functrace
-unset -f __orca_normalize_prompt_command_part __orca_normalize_prompt_command __orca_prepend_prompt_command __orca_append_prompt_command
-unset __orca_prompt_command_normalized
-# Why: arm DEBUG after wrapper setup so the relay rcfile itself does not emit
-# fake command-start/end markers before the first prompt.
-__orca_initial_prompt=1
-trap '__orca_osc133_preexec' DEBUG
-unset __orca_initializing_wrapper
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt b/src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt
deleted file mode 100644
index 57ec4bbef5a..00000000000
--- a/src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt
+++ /dev/null
@@ -1,258 +0,0 @@
-# Orca relay zsh overlay wrapper
-__orca_usable_zdotdir() {
- [[ -n "${1:-}" ]] || return 1
- # Orca's own dir, by marker file or by the shape older builds wrote.
- [[ "$1" != */shell-ready/zsh ]] || return 1
- [[ ! -f "$1/.orca-shell-wrapper" ]] || return 1
- # A directory holding no zsh startup file at all is not a config root,
- # whoever wrote it — and a stale value pointing at one would stop zsh from
- # ever reading the user's real .zshenv.
- local _orca_startup_file
- for _orca_startup_file in .zshenv .zshrc .zprofile .zlogin; do
- [[ -r "$1/$_orca_startup_file" ]] && return 0
- done
- return 1
-}
-if __orca_usable_zdotdir "${ORCA_ORIG_ZDOTDIR:-}"; then
- builtin export ZDOTDIR="$ORCA_ORIG_ZDOTDIR"
-else
- builtin unset ZDOTDIR
-fi
-builtin unset ORCA_ORIG_ZDOTDIR ORCA_ZSHENV_SOURCE_DIR
-builtin unfunction __orca_usable_zdotdir
-builtin typeset -ga _orca_shell_features
-_orca_shell_features=(${(s:,:)${ORCA_SHELL_FEATURES:-}})
-builtin unset ORCA_SHELL_FEATURES
-# Why ORCA_HISTFILE is consumed HERE and not in the deferred hook: a user config
-# that replaces precmd_functions wholesale drops the hook, and an exported value
-# nothing will ever consume is then inherited by every child of this pane,
-# including a nested Orca (#11146). Captured non-exported, it cannot escape.
-builtin typeset -g _orca_histfile="${ORCA_HISTFILE:-}"
-builtin unset ORCA_HISTFILE
-__orca_has_feature() { (( ${_orca_shell_features[(Ie)$1]} )) }
-__orca_has_feature identity && printf "\033]777;orca-shell-start:%s\007" "$$"
-__orca_deferred_line_init() {
- builtin emulate -L zsh
- (( ${+functions[__orca_deferred_init]} )) || return 0
- local __orca_direct_line_init=0
- [[ "${widgets[zle-line-init]:-}" == user:__orca_deferred_line_init ]] && __orca_direct_line_init=1
- __orca_deferred_init
- if (( __orca_direct_line_init && ${+widgets[zle-line-init]} )); then
- zle zle-line-init "$@"
- elif [[ "${widgets[zle-line-init]:-}" == user:__orca_prompt_mark ]]; then
- local __orca_prev_line_init_fn=""
- __orca_prompt_mark "$@"
- fi
-}
-# Why: scheduled callbacks run after user prompt hooks without copying their function metadata.
-__orca_deferred_sched_init() {
- local __orca_prompt_status=$?
- builtin emulate -L zsh
- (( ${+functions[__orca_deferred_init]} )) && __orca_deferred_init
- builtin unset __orca_deferred_sched_armed
- builtin unfunction __orca_deferred_sched_init
- return $__orca_prompt_status
-}
-__orca_arm_deferred_line_init() {
- builtin emulate -L zsh
- if [[ "${widgets[zle-line-init]:-}" != user:__orca_deferred_line_init ]]; then
- if (( ${+widgets[zle-line-init]} )); then
- zle -A zle-line-init __orca_saved_line_init
- fi
- zle -N zle-line-init __orca_deferred_line_init
- fi
- if (( ! $+__orca_deferred_sched_armed )) && builtin zmodload -F zsh/sched b:sched 2>/dev/null; then
- builtin sched +0 __orca_deferred_sched_init && builtin typeset -g __orca_deferred_sched_armed=1
- fi
-}
-__orca_deferred_init() {
- # Why first: this body runs after the user's own config, so it would otherwise
- # inherit whatever options that config left set. Under NO_UNSET an unset
- # precmd_functions is fatal, and KSH_ARRAYS makes the 1-based feature lookup
- # drop whichever feature is listed first.
- builtin emulate -L zsh
- (( $+_orca_deferred_init_done )) && return 0
- builtin typeset -g _orca_deferred_init_done=1
- builtin typeset -g precmd_functions
- if (( ${+widgets[__orca_saved_line_init]} )); then
- if [[ "${widgets[zle-line-init]:-}" == user:__orca_deferred_line_init ]]; then
- zle -A __orca_saved_line_init zle-line-init
- fi
- zle -D __orca_saved_line_init
- elif [[ "${widgets[zle-line-init]:-}" == user:__orca_deferred_line_init ]]; then
- zle -D zle-line-init
- fi
- precmd_functions=(${precmd_functions:#__orca_deferred_init})
- if [ -n "${ORCA_CLI_BIN_DIR:-}" ]; then
- case "${PATH:-}" in
- "$ORCA_CLI_BIN_DIR"|"$ORCA_CLI_BIN_DIR":*) ;;
- *) export PATH="$ORCA_CLI_BIN_DIR${PATH:+:$PATH}" ;;
- esac
- fi
- if __orca_has_feature overlay; then
- # Why: remote startup files can re-export user defaults after relay spawn.
- [[ -n "${ORCA_OPENCODE_CONFIG_DIR:-}" ]] && export OPENCODE_CONFIG_DIR="${ORCA_OPENCODE_CONFIG_DIR}"
- if [[ -n "${ORCA_DATA_ACCOUNT_DATA_HOME:-}" ]]; then
- export XDG_DATA_HOME="${ORCA_DATA_ACCOUNT_DATA_HOME}"
- export XDG_STATE_HOME="${ORCA_DATA_ACCOUNT_STATE_HOME}"
- if [[ "${ORCA_DATA_ACCOUNT_PROVIDER:-}" == opencode ]]; then
- export OPENCODE_AUTH_CONTENT=""
- export OPENCODE_DB="opencode.db"
- fi
- fi
- [[ -n "${ORCA_MIMOCODE_CONFIG_DIR:-}" ]] && export MIMOCODE_CONFIG_DIR="${ORCA_MIMOCODE_CONFIG_DIR}"
- [[ -n "${ORCA_REMOTE_CLI_BIN_DIR:-}" ]] && case ":$PATH:" in *:"${ORCA_REMOTE_CLI_BIN_DIR}":*) ;; *) export PATH="${ORCA_REMOTE_CLI_BIN_DIR}:$PATH" ;; esac
- # Why: OMP does not auto-load Orca's managed status extension; wrap only
- # interactive launch invocations so subcommands such as `omp config` keep
- # their normal argv shape.
- __orca_omp_should_skip_extension() {
- case "${1:-}" in
- 'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
- '__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
- esac
- return 1
- }
- __orca_omp_cwd_is_usable() {
- local __orca_physical_cwd
- [[ -x . ]] || return 1
- if [[ -n "${PWD:-}" && -d "${PWD:-}" ]]; then
- [[ "${PWD}" -ef . ]]
- else
- # Why compare the path: shell builtins can print a cached path for a deleted cwd.
- __orca_physical_cwd="$(builtin pwd -P 2>/dev/null)" || return 1
- [[ -d "$__orca_physical_cwd" && "$__orca_physical_cwd" -ef . ]]
- fi
- }
- __orca_omp_invoke() {
- local __orca_use_extension="$1"
- shift
- if [[ $__orca_use_extension -eq 1 && -n "${ORCA_OMP_STATUS_EXTENSION:-}" && -f "${ORCA_OMP_STATUS_EXTENSION}" ]]; then
- if [[ "${1:-}" == "launch" ]]; then
- shift
- command omp launch --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- else
- command omp --extension "${ORCA_OMP_STATUS_EXTENSION}" "$@"
- fi
- else
- command omp "$@"
- fi
- }
- __orca_omp() {
- local __orca_use_extension=1
- __orca_omp_should_skip_extension "${1:-}" && __orca_use_extension=0
- if ! __orca_omp_cwd_is_usable; then
- local __orca_logical_cwd="${PWD:-${ORCA_WORKTREE_PATH:-${ORCA_ROOT_PATH:-}}}"
- # Why: a restored shell can retain the deleted directory inode after its path is recreated.
- (
- if [[ -z "$__orca_logical_cwd" ]]; then
- printf 'Orca: OMP cannot start because no terminal working directory is available. Open a new terminal in an existing directory.\n' >&2
- return 1
- fi
- if ! builtin cd -P -- "$__orca_logical_cwd" 2>/dev/null; then
- printf 'Orca: OMP cannot access the terminal working directory "%s". Open a new terminal in an existing directory.\n' "$__orca_logical_cwd" >&2
- return 1
- fi
- __orca_omp_invoke "$__orca_use_extension" "$@"
- )
- else
- __orca_omp_invoke "$__orca_use_extension" "$@"
- fi
- }
- if [[ -n "${ORCA_OMP_STATUS_EXTENSION:-}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name, which
- # an `alias omp` otherwise rewrites at parse time, aborting the rest of the file.
- function omp { __orca_omp "$@"; }
- fi
- fi
- # Why: a typed alias expands inside the shell, after pane launch prep.
- # Why unalias inside the substitution: an alias named codex makes command -v
- # report the alias text, and the subshell leaves the user's own alias intact.
- # Why || : twice — zsh alone aborts inside the substitution, but every shell's
- # assignment adopts its exit status, so an absent codex trips set -e in bash too.
- __orca_codex_binary="$(unalias codex 2>/dev/null || :; command -v codex 2>/dev/null || :)"
- if [[ -n "${__orca_codex_binary:-}" && -x "${__orca_codex_binary}" ]]; then
- # Why the function reserved word: it suppresses alias expansion of the name,
- # which otherwise rewrites this header at parse time and aborts the whole file.
- function codex {
- # Why local: zsh's warn_create_global warns for each global a function creates.
- local __orca_codex_arg __orca_codex_isolate="${ORCA_CODEX_ISOLATE:-1}"
- if [[ -n "${ORCA_CODEX_LAUNCH_PREFLIGHT:-}" && -x "${ORCA_CODEX_LAUNCH_PREFLIGHT}" ]]; then
- "${ORCA_CODEX_LAUNCH_PREFLIGHT}" agent hooks prepare-codex >/dev/null 2>&1 || :
- fi
- for __orca_codex_arg in "$@"; do
- case "$__orca_codex_arg" in agents|queue|--no-daemon|--remote|--remote=*) __orca_codex_isolate=0 ;; esac
- done
- # Why probe every launch: a cached answer goes stale across an upgrade, and 0.155 and older exit 2 on the flag.
- if [[ "$__orca_codex_isolate" != 0 ]]; then
- case "$(command codex --help 2>/dev/null </dev/null)" in *--no-daemon*) set -- --no-daemon "$@" ;; esac
- fi
- command codex "$@"
- }
- fi
- unset __orca_codex_binary
- __orca_claude_binary="$(unalias claude 2>/dev/null || :; command -v claude 2>/dev/null || :)"
- if [[ -n "${ORCA_CLAUDE_PROFILE_POINTER:-}" && -n "${__orca_claude_binary:-}" && -x "${__orca_claude_binary}" ]]; then
- function claude {
- local __orca_claude_home __orca_claude_pointer="${ORCA_CLAUDE_PROFILE_POINTER:-}"
- # Why: a WSL pane's pointer is relative to the guest home, which the host cannot know at spawn.
- case "$__orca_claude_pointer" in '~/'*) __orca_claude_pointer="${HOME:-}/${__orca_claude_pointer#??}" ;; esac
- __orca_claude_home="$(cat "$__orca_claude_pointer" 2>/dev/null || :)"
- if [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ "$CLAUDE_CONFIG_DIR" != "${ORCA_CLAUDE_INJECTED_CONFIG_DIR:-}" ]; then
- command claude "$@"; return
- fi
- # Why: Orca's value replaced the user's own at spawn, so System default restores theirs.
- if [ -z "$__orca_claude_home" ] && [ -n "${CLAUDE_CONFIG_DIR:-}" ] && [ -n "${ORCA_CLAUDE_USER_CONFIG_DIR:-}" ]; then
- ( unset ORCA_CLAUDE_INJECTED_CONFIG_DIR; export CLAUDE_CONFIG_DIR="$ORCA_CLAUDE_USER_CONFIG_DIR"; command claude "$@" ); return
- fi
- if [ -z "$__orca_claude_home" ]; then
- ( unset CLAUDE_CONFIG_DIR ORCA_CLAUDE_INJECTED_CONFIG_DIR; command claude "$@" ); return
- fi
- case "$__orca_claude_home" in /*|[A-Za-z]:*) ;; *) return 1 ;; esac
- # Why -m 700: matches the folder Orca's setup creates; a credentials folder stays private.
- [ -d "$__orca_claude_home" ] || mkdir -p -m 700 -- "$__orca_claude_home" 2>/dev/null
- ( export CLAUDE_CONFIG_DIR="$__orca_claude_home" ORCA_CLAUDE_INJECTED_CONFIG_DIR="$__orca_claude_home"; command claude "$@" )
- }
- fi
- unset __orca_claude_binary
- if [[ -n "${_orca_histfile:-}" ]]; then
- HISTFILE="$_orca_histfile"
- fi
- if __orca_has_feature ready; then
- # Why: capture the prior zle-line-init so the marker chains to it. On a
- # re-source we are already the bound widget, so keep the function captured
- # the first time instead of clobbering it to empty (which would silently
- # drop the user's widget on every prompt after the second source). Only
- # user-defined widgets are chainable as plain functions; builtin/completion
- # forms (rare for zle-line-init) are left unchained.
- if [[ "${widgets[zle-line-init]:-}" == "user:__orca_prompt_mark" ]]; then
- :
- elif (( ${+widgets[zle-line-init]} )) && [[ "${widgets[zle-line-init]}" == user:* ]]; then
- __orca_prev_line_init_fn="${widgets[zle-line-init]#user:}"
- else
- __orca_prev_line_init_fn=""
- fi
- __orca_prompt_mark() {
- printf "\033]777;orca-shell-ready\007"
- # Why: call the prior hook as a plain function, not an aliased widget, so
- # $WIDGET stays zle-line-init for add-zle-hook-widget dispatchers.
- if [[ -n "${__orca_prev_line_init_fn:-}" ]]; then
- "${__orca_prev_line_init_fn}" "$@"
- fi
- }
- zle -N zle-line-init __orca_prompt_mark
- fi
- builtin unset _orca_shell_features _orca_histfile
- (( $+__orca_deferred_sched_armed )) || builtin unfunction __orca_deferred_sched_init
- builtin unfunction __orca_deferred_init __orca_has_feature __orca_arm_deferred_line_init
-}
-{
- builtin typeset _orca_user_zshenv="${ZDOTDIR-$HOME}/.zshenv"
- [[ ! -r "$_orca_user_zshenv" ]] || builtin source -- "$_orca_user_zshenv"
-} always {
- builtin unset _orca_user_zshenv
- if (( ! $+_orca_deferred_init_done )); then
- builtin typeset -ag precmd_functions
- (( ${precmd_functions[(Ie)__orca_deferred_init]} )) || precmd_functions+=(__orca_deferred_init)
- __orca_arm_deferred_line_init
- fi
-}
diff --git a/src/main/git/command-runner/local-git-runtime-route-guard.test.ts b/src/main/git/command-runner/local-git-runtime-route-guard.test.ts
deleted file mode 100644
index bc0b677235a..00000000000
--- a/src/main/git/command-runner/local-git-runtime-route-guard.test.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Guards the runtime routing of local Git: every runner entry point that takes Git options routes
- * them, and every deliberate `hostGit: true` says why on the line above.
- */
-import { readdirSync, readFileSync } from 'node:fs'
-import { join, relative } from 'node:path'
-import { describe, expect, it } from 'vitest'
-
-const RUNNER_DIR = join(__dirname)
-const ENTRY_FILES = ['git-exec-file.ts', 'git-spawn.ts', 'git-stream-stdout.ts']
-// Tests, mocks, harnesses and fixtures stand in for Git; they run none.
-const TEST_SUPPORT = /\.test\.ts$|mock|harness|fixture/i
-const MAIN_DIR = join(__dirname, '..', '..')
-const REPO_ROOT = join(MAIN_DIR, '..', '..')
-
-const COMMENT_LINE = /^\s*(\*|\/\/|\/\*)/
-const HOST_GIT = 'hostGit: true'
-
-let hostGitSources: string[] | null = null
-
-/** Files whose code, not only a comment, sets `hostGit: true`; one read of src/main per run. */
-function hostGitCallSources(): string[] {
- hostGitSources ??= readdirSync(MAIN_DIR, { recursive: true, encoding: 'utf8' })
- .filter((file) => file.endsWith('.ts') && !TEST_SUPPORT.test(file))
- .map((file) => join(MAIN_DIR, file))
- .filter((file) => {
- const source = readFileSync(file, 'utf8')
- return (
- source.includes(HOST_GIT) &&
- source.split('\n').some((line) => line.includes(HOST_GIT) && !COMMENT_LINE.test(line))
- )
- })
- .map((file) => relative(REPO_ROOT, file).replaceAll('\\', '/'))
- return hostGitSources
-}
-
-const HOST_ONLY_ENTRIES = new Set<string>()
-
-describe('local Git runtime routing guard', () => {
- it('routes the options of every exported runner entry point', () => {
- const checked: string[] = []
- for (const file of ENTRY_FILES) {
- const source = readFileSync(join(RUNNER_DIR, file), 'utf8')
- for (const body of source.split(/\nexport (?:async )?function /).slice(1)) {
- const name = body.slice(0, body.indexOf('('))
- if (HOST_ONLY_ENTRIES.has(name)) {
- continue
- }
- checked.push(name)
- expect(body.slice(0, 400), `${file}: ${name}`).toContain(
- 'routeLocalGitOptions(callerOptions)'
- )
- }
- }
- expect(checked).toHaveLength(6)
- })
-
- it('has a reason above every deliberate host-Git call', () => {
- const files = hostGitCallSources()
- expect(files.length).toBeGreaterThan(0)
- for (const file of files) {
- const lines = readFileSync(join(REPO_ROOT, file), 'utf8').split('\n')
- lines.forEach((line, index) => {
- // Code only: a doc comment may name the option.
- if (!line.includes('hostGit: true') || COMMENT_LINE.test(line)) {
- return
- }
- const above = [lines[index - 1] ?? '', lines[index - 2] ?? ''].join('\n')
- expect(above, `${file}:${index + 1}`).toMatch(/\/\/ Host Git on purpose: \S/)
- })
- }
- })
-
- it('keeps deliberate host Git to the calls that run before a project owns the folder', () => {
- expect([...hostGitCallSources()].sort()).toEqual([
- // Repo detection, read-only.
- 'src/main/git/repo-detection-command.ts',
- // Clone and init make a new repo.
- 'src/main/ipc/repos/repo-clone-lifecycle.ts',
- 'src/main/ipc/repos/repo-creation-handlers.ts',
- // The checks whether Git for Windows can take a project over.
- 'src/main/ipc/wsl-drive-project-handlers.ts',
- 'src/main/ipc/wsl-drive-unc-conversion-handlers.ts',
- // The remote read while a project is being added.
- 'src/main/repo-icon-autodetect.ts',
- 'src/main/runtime/runtime-repository-clone-controller.ts',
- 'src/main/runtime/runtime-repository-registration-controller.ts',
- // The setup runner's path lookup, synchronous; with the router on it reads the link instead.
- 'src/main/worktree-runner-script.ts'
- ])
- })
-
- it('keeps synchronous Git host-only, so routing never puts wsl.exe on the main thread', () => {
- const sync = readFileSync(join(RUNNER_DIR, 'git-exec-file-sync.ts'), 'utf8')
- expect(sync).not.toContain('routeLocalGitOptions')
- expect(sync).toContain('hostGit: HostGitOnly')
- })
-
- it('names which Git ran on every runner span', () => {
- for (const file of ENTRY_FILES) {
- const source = readFileSync(join(RUNNER_DIR, file), 'utf8')
- const spans = source.match(/\b(withGitSpan|startGitSpan)\(/g) ?? []
- const runsIn = source.match(/'git\.runs_in'/g) ?? []
- expect(spans.length, file).toBeGreaterThan(0)
- expect(runsIn.length, file).toBe(spans.length)
- }
- })
-})
diff --git a/src/main/jcode/hook-command-quoting.test.ts b/src/main/jcode/hook-command-quoting.test.ts
deleted file mode 100644
index 369c7d7776c..00000000000
--- a/src/main/jcode/hook-command-quoting.test.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import { describe, expect, it } from 'vitest'
-import { getJcodeManagedCommand, isJcodeManagedCommand } from './hook-settings'
-
-/** Mirror parse_hook_command in crates/jcode-terminal-launch/src/lib.rs: shell-style tokenization before direct execution. */
-function tokenizeLikeJcode(raw: string): string[] {
- const parts: string[] = []
- let current = ''
- let quote: string | null = null
- let escaped = false
- let started = false
- for (const char of raw) {
- if (escaped) {
- current += char
- started = true
- escaped = false
- } else if (quote) {
- if (char === quote) {
- quote = null
- } else if (char === '\\' && quote === '"') {
- escaped = true
- } else {
- current += char
- started = true
- }
- } else if (char === '\\') {
- escaped = true
- started = true
- } else if (char === "'" || char === '"') {
- quote = char
- started = true
- } else if (/\s/.test(char)) {
- if (started) {
- parts.push(current)
- current = ''
- started = false
- }
- } else {
- current += char
- started = true
- }
- }
- if (started) {
- parts.push(current)
- }
- return parts
-}
-
-describe('jcode managed hook command quoting', () => {
- const paths = [
- 'C:\\Users\\me\\.orca\\agent-hooks\\jcode-hook.cmd',
- 'C:\\Users\\First Last\\.orca\\agent-hooks\\jcode-hook.cmd',
- '/home/me/.orca/agent-hooks/jcode-hook.sh',
- '/Users/First Last/.orca/agent-hooks/jcode-hook.sh',
- "/Users/o'brien/.orca/agent-hooks/jcode-hook.sh",
- '/Users/quote"odd/.orca/agent-hooks/jcode-hook.sh'
- ]
-
- it.each(paths)('survives jcode\u2019s tokenizer as one argument: %s', (scriptPath) => {
- expect(tokenizeLikeJcode(getJcodeManagedCommand(scriptPath))).toEqual([scriptPath])
- })
-
- it('is what a bare path fails to do, which is why the quoting exists', () => {
- // Unquoted Windows separators are consumed as escapes before direct execution.
- expect(tokenizeLikeJcode('C:\\Users\\me\\.orca\\agent-hooks\\jcode-hook.cmd')).toEqual([
- 'C:Usersme.orcaagent-hooksjcode-hook.cmd'
- ])
- })
-
- it('still recognizes its own managed entry on either separator', () => {
- for (const scriptPath of paths) {
- expect(isJcodeManagedCommand(getJcodeManagedCommand(scriptPath))).toBe(true)
- }
- expect(isJcodeManagedCommand("'/home/me/.config/my-own-hook.sh'")).toBe(false)
- })
-})
diff --git a/src/main/pty/node-pty-self-exit-pseudoconsole-close.test.ts b/src/main/pty/node-pty-self-exit-pseudoconsole-close.test.ts
deleted file mode 100644
index a08c0829222..00000000000
--- a/src/main/pty/node-pty-self-exit-pseudoconsole-close.test.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-import { readFileSync } from 'node:fs'
-import { join } from 'node:path'
-import { describe, expect, it } from 'vitest'
-
-/** Pin both self-exit leaks: the watcher must retain the baton for ClosePseudoConsole, and DLL kill must dispose conout without more data.
- * Windows 11 measurements (20 cycles): desktop +200 and relay +60 handles became flat with both fixes; desktop alone needs both.
- * Patch pins protect resyncs: leaked handles reference exited objects, so process/pipe disappearance could not detect them. */
-
-const PATCH = readFileSync(join(__dirname, '../../../config/patches/[email protected]'), 'utf8')
-
-/** Restrict to PtyKill: matching shared markers in PtyConnect made assertions vacuously pass. */
-const ptyKillHunk = (() => {
- // Function context survives unrelated patch line-number changes.
- const header = /^@@ .* @@ static Napi::Value PtyKill\(.*$/m.exec(PATCH)
- if (!header) {
- throw new Error('no PtyKill hunk in config/patches/[email protected]')
- }
- const from = header.index
- const next = PATCH.indexOf('\n@@ ', from + 1)
- return PATCH.slice(from, next === -1 ? undefined : next)
-})()
-
-/** Missing markers must fail instead of making slice/order assertions vacuous. */
-function indexIn(haystack: string, marker: string): number {
- const at = haystack.indexOf(marker)
- if (at === -1) {
- throw new Error(`marker not found in the PtyKill hunk: ${marker}`)
- }
- return at
-}
-
-describe('node-pty patch: pseudoconsole close on the self-exit path', () => {
- it('does not let the exit watcher free the baton while the close is still owed', () => {
- // Erasing outside consoleClosed loses the baton before self-exit cleanup can close it.
- expect(PATCH).toContain(
- [
- '+ baton->shellExited = true;',
- '+ if (baton->consoleClosed) {',
- '+ const bool removed = remove_pty_baton_locked(baton->id);',
- '+ assert(removed);',
- '+ (void)removed;',
- '+ }'
- ].join('\n')
- )
- })
-
- it('closes the pseudoconsole from PtyKill even after the shell has exited', () => {
- // hpc is copied out under the lock, so the close survives the baton's removal.
- expect(PATCH).toContain('+ hpc = handle->hpc;')
- expect(PATCH).toContain('+ pfnClosePseudoConsole(hpc);')
- })
-
- it('resolves the ConPTY DLL before it claims the close', () => {
- // Resolve DLL inside PtyKill before claiming consoleClosed; a throw afterward would prevent retries.
- const dllResolve = indexIn(
- ptyKillHunk,
- '+ HANDLE hLibrary = LoadConptyDll(info, useConptyDll);'
- )
- const claim = indexIn(ptyKillHunk, '+ handle->consoleClosed = true;')
- expect(dllResolve).toBeLessThan(claim)
- })
-
- it('reaches hShell only under the null check the watcher can trip', () => {
- // The watcher nulls hShell; both duplication and fallback termination need the guard.
- const start = indexIn(ptyKillHunk, '+ if (useConptyDll && handle->hShell != nullptr) {')
- const end = indexIn(ptyKillHunk, '+ if (handle->shellExited) {')
- const guarded = ptyKillHunk.slice(start, end)
- expect(guarded).toContain('DuplicateHandle(GetCurrentProcess(), handle->hShell')
- expect(guarded).toContain('TerminateProcess(handle->hShell, 1);')
- // Inspect added lines only; removed upstream lines deliberately retain the old unguarded call.
- const strayAdds = PATCH.replace(guarded, '')
- .split('\n')
- .filter((line) => line.startsWith('+') && line.includes('TerminateProcess(handle->hShell'))
- expect(strayAdds).toEqual([])
- })
-
- it('frees the baton from PtyKill when the shell has already exited', () => {
- // Without this handshake, self-exit then kill leaks a baton and its linear-scan vector entry.
- expect(ptyKillHunk).toContain(
- [
- '+ if (handle->shellExited) {',
- '+ const bool removed = remove_pty_baton_locked(id);',
- '+ assert(removed);',
- '+ (void)removed;'
- ].join('\n')
- )
- })
-
- it('still kills the shell when DuplicateHandle fails', () => {
- // Duplication failure must not look like self-exit and silently leave the shell alive.
- expect(PATCH).toContain(
- [
- '+ hShellDup = nullptr;',
- '+ TerminateProcess(handle->hShell, 1);',
- '+ }'
- ].join('\n')
- )
- })
-
- it('keeps the close idempotent so a second kill cannot double-close', () => {
- expect(PATCH).toContain('+ if (handle != nullptr && !handle->consoleClosed) {')
- expect(PATCH).toContain('+ handle->consoleClosed = true;')
- })
-})
-
-describe('node-pty patch: conout worker disposal on the self-exit path', () => {
- // Conout disposal accounts for eight of ten leaked desktop handles per cycle.
- it('disposes the conout worker unconditionally in the useConptyDll branch', () => {
- expect(PATCH).toContain('+ this._conoutSocketWorker.dispose();')
- // Self-exit can leave no further data to trigger this handler.
- expect(PATCH).toContain("- this._outSocket.on('data', function () {")
- expect(PATCH).toContain('- _this._conoutSocketWorker.dispose();')
- })
-
- it('applies the same change to the TypeScript source the patch also carries', () => {
- expect(PATCH).toContain('+ this._conoutSocketWorker.dispose();')
- expect(PATCH).toContain("- this._outSocket.on('data', () => {")
- })
-})
diff --git a/src/main/shell-wrapper-generated-file-snapshot.test.ts b/src/main/shell-wrapper-generated-file-snapshot.test.ts
deleted file mode 100644
index 5ef32a08f39..00000000000
--- a/src/main/shell-wrapper-generated-file-snapshot.test.ts
+++ /dev/null
@@ -1,150 +0,0 @@
-// Read __fixtures__/shell-wrapper-snapshots/README.md before accepting snapshot changes.
-import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
-import { tmpdir } from 'node:os'
-import { join } from 'node:path'
-import { afterEach, beforeEach, describe, expect, it } from 'vitest'
-import { ensureShellReadyWrappersAt } from './providers/local-pty-shell-ready-wrapper-generation'
-import {
- getShellLaunchConfig as getDaemonShellLaunchConfig,
- getShellReadyWrapperRoot as getDaemonShellReadyWrapperRoot
-} from './daemon/shell-ready'
-import { getShellLaunchConfig as getLocalShellLaunchConfig } from './providers/local-pty-shell-ready'
-import { selectShellStartupFeatures } from './shell-startup-features'
-
-const STARTUP_COMMAND_FEATURES = selectShellStartupFeatures({
- shellPath: 'zsh',
- env: {},
- hasStartupCommand: true,
- waitsForShellReady: true,
- emitsStartupIdentity: true
-})
-
-// ZDOTDIR handback lets zsh read later startup files directly from the user's directory.
-const WRAPPER_FILES = [
- ['zsh-zshenv', join('zsh', '.zshenv')],
- ['bash-rcfile', join('bash', 'rcfile')]
-] as const
-
-const SNAPSHOT_DIR = join(__dirname, '__fixtures__', 'shell-wrapper-snapshots')
-
-// Bash still embeds a temporary wrapper root that varies per run.
-function withStableRoot(content: string, root: string): string {
- return content.split(root).join('<WRAPPER_ROOT>')
-}
-
-function snapshotPath(transport: string, label: string): string {
- return join(SNAPSHOT_DIR, `${transport}-${label}.txt`)
-}
-
-async function expectWrapperFiles(transport: string, root: string): Promise<void> {
- for (const [label, relativePath] of WRAPPER_FILES) {
- const content = readFileSync(join(root, relativePath), 'utf8')
- await expect(withStableRoot(content, root)).toMatchFileSnapshot(snapshotPath(transport, label))
- }
-}
-
-// Non-Orca globals allowed by the shell or agent-overlay contracts.
-const CONTRACT_GLOBALS = new Set([
- 'BUFFER',
- 'CODEX_HOME',
- // Exported only in the claude function's subshell.
- 'CLAUDE_CONFIG_DIR',
- 'HISTFILE',
- 'MIMOCODE_CONFIG_DIR',
- 'OPENCODE_CONFIG_DIR',
- 'OPENCODE_AUTH_CONTENT',
- 'OPENCODE_DB',
- 'XDG_DATA_HOME',
- 'XDG_STATE_HOME',
- 'PATH',
- 'PROMPT_COMMAND',
- 'PS1', // Bash appends its non-printing Readline readiness marker.
- 'CURSOR',
- 'ZDOTDIR',
- 'precmd_functions',
- 'preexec_functions'
-])
-
-// `local`/`local -a` declarations are function-scoped and cannot collide.
-const LINE_START_ASSIGNMENT =
- /^[ \t]*(?:builtin[ \t]+)?(?:export[ \t]+|typeset[ \t]+-[a-zA-Z]+[ \t]+|declare[ \t]+-[a-zA-Z]+[ \t]+)?([A-Za-z_][A-Za-z0-9_]*)\+?=/
-const INLINE_EXPORT = /\bexport[ \t]+([A-Za-z_][A-Za-z0-9_]*)\+?=/g
-
-function foreignGlobalsWritten(content: string): string[] {
- const names = new Set<string>()
- for (const line of content.split('\n')) {
- if (/^[ \t]*#/.test(line) || /^[ \t]*local\b/.test(line)) {
- continue
- }
- for (const name of [
- LINE_START_ASSIGNMENT.exec(line)?.[1],
- ...[...line.matchAll(INLINE_EXPORT)].map((match) => match[1])
- ]) {
- if (name && !/^_{0,2}orca_/i.test(name) && !CONTRACT_GLOBALS.has(name)) {
- names.add(name)
- }
- }
- }
- return [...names].sort()
-}
-
-// Wrapping is POSIX-only; native Windows paths would make these fixtures unstable.
-const describePosix = process.platform === 'win32' ? describe.skip : describe
-
-describePosix('generated shell wrapper files', () => {
- let root = ''
- let previousUserDataPath: string | undefined
-
- beforeEach(() => {
- root = mkdtempSync(join(tmpdir(), 'orca-wrapper-snapshot-'))
- previousUserDataPath = process.env.ORCA_USER_DATA_PATH
- })
-
- afterEach(() => {
- if (previousUserDataPath === undefined) {
- delete process.env.ORCA_USER_DATA_PATH
- } else {
- process.env.ORCA_USER_DATA_PATH = previousUserDataPath
- }
- rmSync(root, { recursive: true, force: true })
- })
-
- it('local PTY wrappers', async () => {
- ensureShellReadyWrappersAt(root)
- await expectWrapperFiles('local', root)
- })
-
- it('daemon wrappers', async () => {
- process.env.ORCA_USER_DATA_PATH = root
- getDaemonShellLaunchConfig('/bin/zsh', STARTUP_COMMAND_FEATURES)
- await expectWrapperFiles('daemon', getDaemonShellReadyWrapperRoot())
- })
-
- // User configs may constrain shell globals such as readonly REPLY; use Orca-owned scratch names.
- it.each([
- ['local', (): void => void ensureShellReadyWrappersAt(root), (): string => root],
- [
- 'daemon',
- (): void => {
- process.env.ORCA_USER_DATA_PATH = root
- getDaemonShellLaunchConfig('/bin/zsh', STARTUP_COMMAND_FEATURES)
- },
- (): string => getDaemonShellReadyWrapperRoot()
- ]
- ])('%s wrappers write no shell global outside Orca’s namespace', (_transport, generate, dir) => {
- generate()
-
- for (const [, relativePath] of WRAPPER_FILES) {
- const content = readFileSync(join(dir(), relativePath), 'utf8')
- expect({ [relativePath]: foreignGlobalsWritten(content) }).toEqual({ [relativePath]: [] })
- }
- })
-
- it('fish shell-ready init commands', async () => {
- process.env.ORCA_USER_DATA_PATH = root
- const local = getLocalShellLaunchConfig('/usr/bin/fish', STARTUP_COMMAND_FEATURES)
- const daemon = getDaemonShellLaunchConfig('/usr/bin/fish', STARTUP_COMMAND_FEATURES)
- await expect(local.args?.[2]).toMatchFileSnapshot(snapshotPath('local', 'fish-init'))
- await expect(daemon.args?.[2]).toMatchFileSnapshot(snapshotPath('daemon', 'fish-init'))
- })
-})
diff --git a/src/renderer/src/components/plugins/state/plugin-try-action.test.ts b/src/renderer/src/components/plugins/state/plugin-try-action.test.ts
deleted file mode 100644
index e1fd1e06bcc..00000000000
--- a/src/renderer/src/components/plugins/state/plugin-try-action.test.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { describe, expect, it, vi } from 'vitest'
-import { pluginManifestSchema } from '../../../../../shared/plugins/manifest/plugin-manifest'
-import { pluginSyntaxSample, pluginTryAction } from './plugin-try-action'
-
-vi.mock('@/store', () => ({ useAppStore: { getState: vi.fn() } }))
-
-const manifest = (contributes: Record<string, unknown>) =>
- pluginManifestSchema.parse({
- manifestVersion: 1,
- id: 'p',
- publisher: 'acme',
- name: 'P',
- version: '1.0.0',
- engines: { orca: '>=1.0.0' },
- pluginApi: 1,
- contributes
- })
-
-const syntax = (extensions: string[]) => ({
- id: 's',
- title: 'S',
- scopeName: 'source.s',
- path: 's.json',
- extensions
-})
-
-describe('pluginTryAction', () => {
- it('has a sample for a known grammar, matched ignoring case', () => {
- expect(pluginSyntaxSample([{ extensions: ['.GLEAM'] }])?.content).toContain('pub fn main')
- expect(pluginTryAction('acme.p', manifest({ syntaxes: [syntax(['.gleam'])] }))).toBeTypeOf(
- 'function'
- )
- })
-
- it('offers nothing for a grammar without a sample or a theme-only plugin', () => {
- expect(pluginTryAction('acme.p', manifest({ syntaxes: [syntax(['.zzz'])] }))).toBeNull()
- expect(
- pluginTryAction(
- 'acme.p',
- manifest({ themes: [{ id: 'd', title: 'D', path: 'themes/d.json' }] })
- )
- ).toBeNull()
- })
-})
diff --git a/src/renderer/src/store/slices/repos-catalog-merge-identity.spec.ts b/src/renderer/src/store/slices/repos-catalog-merge-identity.spec.ts
index c1e07a38c61..24ff6aa082f 100644
--- a/src/renderer/src/store/slices/repos-catalog-merge-identity.spec.ts
+++ b/src/renderer/src/store/slices/repos-catalog-merge-identity.spec.ts
@@ -110,33 +110,6 @@ export function registerReposCatalogMergeIdentityTests(): void {
})
describe('catalog merge referential stability', () => {
- it('keeps the same projectGroups array when a refetch changes nothing', async () => {
- const store = createTestStore()
-
- await store.getState().fetchProjectGroups(catalogOwner(store))
- const first = store.getState().projectGroups
- expect(first).toEqual([{ ...projectGroup, executionHostId: 'local' }])
-
- await store.getState().fetchProjectGroups(catalogOwner(store))
-
- expect(store.getState().projectGroups).toBe(first)
- })
-
- it('keeps the same folderWorkspaces array (and entries) when a refetch changes nothing', async () => {
- const store = createTestStore()
- store.setState({ projectGroups: [{ ...projectGroup, executionHostId: 'local' }] })
-
- await store.getState().fetchFolderWorkspaces(catalogOwner(store))
- const first = store.getState().folderWorkspaces
- expect(first).toHaveLength(1)
- const firstEntry = first[0]
-
- await store.getState().fetchFolderWorkspaces(catalogOwner(store))
-
- expect(store.getState().folderWorkspaces).toBe(first)
- expect(store.getState().folderWorkspaces[0]).toBe(firstEntry)
- })
-
it('appends new entries and replaces changed ones while keeping order', async () => {
const store = createTestStore()
@@ -210,55 +183,6 @@ export function registerReposCatalogMergeIdentityTests(): void {
// No-op arrays must preserve sidebar refill cache or stale-folder checks silently fail open.
describe('folder path status cache retention across catalog fetches', () => {
- it('keeps cached path statuses when a project-group refetch changes nothing', async () => {
- const store = createTestStore()
- await store.getState().fetchProjectGroups(catalogOwner(store))
- store.setState({ folderWorkspacePathStatuses: cachedPathStatuses })
-
- await store.getState().fetchProjectGroups(catalogOwner(store))
-
- expect(store.getState().folderWorkspacePathStatuses).toBe(cachedPathStatuses)
- })
-
- it('clears cached path statuses when the project-group catalog changes', async () => {
- const store = createTestStore()
- await store.getState().fetchProjectGroups(catalogOwner(store))
- store.setState({ folderWorkspacePathStatuses: cachedPathStatuses })
-
- projectGroupsList.mockImplementation(async () => [
- clone(projectGroup),
- clone(secondProjectGroup)
- ])
- await store.getState().fetchProjectGroups(catalogOwner(store))
-
- expect(store.getState().folderWorkspacePathStatuses).toEqual({})
- })
-
- it('keeps cached path statuses when a folder-workspace refetch changes nothing', async () => {
- const store = createTestStore()
- store.setState({ projectGroups: [{ ...projectGroup, executionHostId: 'local' }] })
- await store.getState().fetchFolderWorkspaces(catalogOwner(store))
- store.setState({ folderWorkspacePathStatuses: cachedPathStatuses })
-
- await store.getState().fetchFolderWorkspaces(catalogOwner(store))
-
- expect(store.getState().folderWorkspacePathStatuses).toBe(cachedPathStatuses)
- })
-
- it('clears cached path statuses when a folder workspace path changes', async () => {
- const store = createTestStore()
- store.setState({ projectGroups: [{ ...projectGroup, executionHostId: 'local' }] })
- await store.getState().fetchFolderWorkspaces(catalogOwner(store))
- store.setState({ folderWorkspacePathStatuses: cachedPathStatuses })
-
- folderWorkspacesList.mockImplementation(async () => [
- clone({ ...folderWorkspace, folderPath: '/parent/folder-1-renamed' })
- ])
- await store.getState().fetchFolderWorkspaces(catalogOwner(store))
-
- expect(store.getState().folderWorkspacePathStatuses).toEqual({})
- })
-
it('keeps cached path statuses when a repo refetch changes nothing', async () => {
const store = createTestStore()
await store.getState().fetchRepos(catalogOwner(store))
diff --git a/src/renderer/src/store/slices/repos-refresh-identity.spec.ts b/src/renderer/src/store/slices/repos-refresh-identity.spec.ts
index 14438834697..a8d2cc0f8ae 100644
--- a/src/renderer/src/store/slices/repos-refresh-identity.spec.ts
+++ b/src/renderer/src/store/slices/repos-refresh-identity.spec.ts
@@ -77,37 +77,6 @@ export function registerReposRefreshIdentityTests(): void {
})
describe('repo catalog refresh identity', () => {
- it('keeps the projects and host setups arrays and entries across a no-op refetch', async () => {
- const store = createTestStore()
- await store.getState().fetchRepos(catalogOwner(store))
- const projects = store.getState().projects
- const setups = store.getState().projectHostSetups
- expect(projects).toHaveLength(1)
- expect(setups).toHaveLength(1)
-
- await store.getState().fetchRepos(catalogOwner(store))
-
- expect(store.getState().projects).toBe(projects)
- expect(store.getState().projects[0]).toBe(projects[0])
- expect(store.getState().projectHostSetups).toBe(setups)
- expect(store.getState().projectHostSetups[0]).toBe(setups[0])
- })
-
- it('lets a nested hookSettings change through', async () => {
- const store = createTestStore()
- await store.getState().fetchRepos(catalogOwner(store))
- const setups = store.getState().projectHostSetups
-
- mockRepos({
- ...repo,
- hookSettings: { mode: 'override', scripts: { setup: '', archive: '' } }
- })
- await store.getState().fetchRepos(catalogOwner(store))
-
- expect(store.getState().projectHostSetups).not.toBe(setups)
- expect(store.getState().projectHostSetups[0]?.hookSettings?.mode).toBe('override')
- })
-
it('lets a displayName change through on projects', async () => {
const store = createTestStore()
await store.getState().fetchRepos(catalogOwner(store))
@@ -357,15 +326,6 @@ export function registerReposRefreshIdentityTests(): void {
expect(store.getState().filterRepoIds).toBe(first)
})
- it('still prunes a filtered repo id that no longer exists', async () => {
- const store = createTestStore()
- store.setState({ filterRepoIds: [repo.id, 'gone'] })
-
- await store.getState().fetchRepos(catalogOwner(store))
-
- expect(store.getState().filterRepoIds).toEqual([repo.id])
- })
-
it('prunes only the vanished id and reallocates', async () => {
mockRepos(repo)
const store = createTestStore()
diff --git a/src/renderer/src/store/slices/repos-shared-project-badge-color.spec.ts b/src/renderer/src/store/slices/repos-shared-project-badge-color.spec.ts
index b954ca79aa2..a11f6c25932 100644
--- a/src/renderer/src/store/slices/repos-shared-project-badge-color.spec.ts
+++ b/src/renderer/src/store/slices/repos-shared-project-badge-color.spec.ts
@@ -135,15 +135,6 @@ export function registerReposSharedProjectBadgeColorTests(): void {
}
describe('shared project badge color across hosts', () => {
- it('keeps the local color when a remote host shares the project name', async () => {
- const store = createTestStore()
- store.setState({ settings: { activeRuntimeEnvironmentId: 'env-1' } as never })
-
- await store.getState().fetchReposForAllHosts()
-
- expect(badgeColor(store)).toBe(LOCAL_GREEN)
- })
-
it('keeps the local color when a runtime-only refresh lands after startup', async () => {
const store = createTestStore()
store.setState({ settings: { activeRuntimeEnvironmentId: 'env-1' } as never })
diff --git a/src/renderer/src/store/slices/repos-stale-fetch.spec.ts b/src/renderer/src/store/slices/repos-stale-fetch.spec.ts
index 490d9448963..e7cbcace385 100644
--- a/src/renderer/src/store/slices/repos-stale-fetch.spec.ts
+++ b/src/renderer/src/store/slices/repos-stale-fetch.spec.ts
@@ -1,5 +1,4 @@
import { describe, expect, it, vi, beforeEach } from 'vitest'
-import { getRepoExecutionHostId } from '../../../../shared/execution-host'
import { createTestStore, makeLayout, makeTab } from './store-test-helpers'
import type { Repo } from '../../../../shared/repo-types'
import type { WorkspaceSessionState } from '../../../../shared/workspace-session-state-types'
@@ -105,25 +104,6 @@ export function registerReposStaleFetchTests(): void {
expect(store.getState().repos).toEqual([])
})
- it('reapplies an in-flight catalog after the repo is removed', async () => {
- const { promise: catalog, resolve: resolveCatalog } = Promise.withResolvers<Repo[]>()
- reposList.mockReturnValueOnce(catalog)
- const store = createTestStore()
- store.setState({ repos: [localRepo] })
-
- const pending = store.getState().fetchRepos(catalogOwner(store))
- await store
- .getState()
- .removeProject(localRepo.id, { hostId: getRepoExecutionHostId(localRepo) })
- expect(store.getState().repos).toEqual([])
-
- resolveCatalog([localRepo])
- await pending
-
- // Current contract: removal does not claim a catalog generation, so the latest fetch can resurrect it.
- expect(store.getState().repos).toEqual([{ ...localRepo, executionHostId: 'local' }])
- })
-
it('waits for the superseding catalog fetch before startup hydration', async () => {
let resolveStartup!: (repos: Repo[]) => void
let resolveRefresh!: (repos: Repo[]) => void
diff --git a/src/shared/plugins/catalog/plugin-detail-fields.test.ts b/src/shared/plugins/catalog/plugin-detail-fields.test.ts
index 27905034fc0..cf1e974b1c9 100644
--- a/src/shared/plugins/catalog/plugin-detail-fields.test.ts
+++ b/src/shared/plugins/catalog/plugin-detail-fields.test.ts
@@ -26,20 +26,6 @@ function v2Manifest(overrides: Record<string, unknown>): Record<string, unknown>
}
describe('plugin detail fields', () => {
- it('keeps valid catalog release details', () => {
- const details = {
- license: 'Apache-2.0 OR MIT',
- repository: 'https://github.com/acme/demo',
- homepage: 'https://example.com/demo',
- updatedAt: '2026-10-20T09:30:00Z',
- changelog: 'Adds Portuguese.'
- }
- expect(pluginCatalogReleaseSchema.parse({ ...release, ...details })).toMatchObject(details)
- expect(pluginCatalogReleaseSchema.parse({ ...release, updatedAt: '2026-10-20' })).toMatchObject(
- { updatedAt: '2026-10-20' }
- )
- })
-
it('drops invalid catalog release details instead of hiding the release', () => {
const parsed = pluginCatalogReleaseSchema.parse({
...release,