Repository navigation
refactor(hooks,relay): split agent hook services and relay under the max-lines budget - #14725
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 9ca84a6f9bec0a9f64cc31e8b1cf6129cef3e7cc and 2e91b9d. 📒 Files selected for processing (12)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (10)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change extracts hook, runner, configuration, plugin, relay, and filesystem logic into dedicated modules. It adds AMP, Antigravity, Copilot, and Hermes integrations with platform-specific scripts and installation handling. It adds effective hook policies, runtime targeting, issue-command overrides, and worktree runner creation. Relay event processing now uses shared envelopes and retry scheduling. Relay filesystem operations use dedicated metadata, mutation, and fallback modules. Tests and TypeScript project configuration were updated. Merge Risk: 🟠 High · up to This refactor leaves unresolved risks in hook installation and relay file handling: existing user plugin artifacts may be overwritten, and a stalled git process may block file-listing requests indefinitely. Additional integration concerns could misreport installation status or break WSL/runtime behavior, so the PR is not ready to merge without owner review and fixes. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/main/amp/managed-plugin-install-status.ts (1)
27-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDerive the completeness markers from the generated source module.
isCompleteManagedPluginmatches literal text thatgetAmpPluginSourceemits, including the single-quote style inamp.on('session.start'. The two modules are now separate files, so an edit to the generated source can break detection silently. The result is apartialstatus with the detail "Managed Amp plugin is missing required handlers" even though the plugin is correct.Export the required markers from
agent-status-plugin-source.tsand consume them here. A test that assertsisCompleteManagedPlugin(getAmpPluginSource())also closes the gap.♻️ Proposed refactor
In
src/main/amp/agent-status-plugin-source.ts:+export const AMP_PLUGIN_REQUIRED_MARKERS = [ + '/hook/amp', + "amp.on('session.start'", + "amp.on('agent.start'", + "amp.on('tool.call'", + "amp.on('tool.result'", + "amp.on('agent.end'" +] as constIn
src/main/amp/managed-plugin-install-status.ts:-import { AMP_PLUGIN_FILE, AMP_PLUGIN_MARKER } from './agent-status-plugin-source' +import { + AMP_PLUGIN_FILE, + AMP_PLUGIN_MARKER, + AMP_PLUGIN_REQUIRED_MARKERS +} from './agent-status-plugin-source' @@ function isCompleteManagedPlugin(content: string): boolean { - return ( - isManagedPlugin(content) && - content.includes('/hook/amp') && - content.includes("amp.on('session.start'") && - content.includes("amp.on('agent.start'") && - content.includes("amp.on('tool.call'") && - content.includes("amp.on('tool.result'") && - content.includes("amp.on('agent.end'") - ) + return ( + isManagedPlugin(content) && + AMP_PLUGIN_REQUIRED_MARKERS.every((marker) => content.includes(marker)) + ) }src/relay/fs-path-mutation-requests.ts (1)
42-47: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer a static
node:pathimport.
dirnameis required on every call, so the dynamic import adds no deferral benefit. Relay code is bundled separately for remote deploy, so a static import of a built-in keeps resolution predictable in the bundle.Based on learnings,
src/relayis bundled separately for remote deploy, so relay modules should keep their dependencies resolvable at bundle time.♻️ Proposed refactor
import { writeFile, stat, lstat, mkdir, rename, cp, rm } from 'node:fs/promises' +import { dirname } from 'node:path' import { expandTilde } from './context'export async function createRelayFile(params: Record<string, unknown>) { const filePath = expandTilde(params.filePath as string) - const { dirname } = await import('node:path') await mkdir(dirname(filePath), { recursive: true }) await writeFile(filePath, '', { encoding: 'utf-8', flag: 'wx' }) }Source: Learnings
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 29e8da77-1e2e-4a4f-83bb-e44d60a7ff16
📒 Files selected for processing (48)
config/max-lines-baseline.txtconfig/tsconfig.cli.jsonsrc/main/amp/agent-status-plugin-source.tssrc/main/amp/hook-service.tssrc/main/amp/managed-plugin-install-status.tssrc/main/antigravity/hook-events.tssrc/main/antigravity/hook-script.tssrc/main/antigravity/hook-service.tssrc/main/antigravity/hooks-json-bundle.tssrc/main/copilot/copilot-managed-hook-definitions.tssrc/main/copilot/copilot-managed-script.tssrc/main/copilot/copilot-remote-hook-install.tssrc/main/copilot/hook-service.tssrc/main/effective-hook-config.tssrc/main/global-fetch-call-site-audit.test.tssrc/main/hermes/hermes-config-yaml.tssrc/main/hermes/hermes-home-filesystem.tssrc/main/hermes/hermes-managed-plugin-source.tssrc/main/hermes/hook-service.tssrc/main/hook-runtime-target.tssrc/main/hooks-runner.test.tssrc/main/hooks.test.tssrc/main/hooks.tssrc/main/ipc/worktree-remote.tssrc/main/ipc/worktrees-windows.test.tssrc/main/ipc/worktrees.test.tssrc/main/ipc/worktrees.tssrc/main/issue-command-file.tssrc/main/runtime/fit-override-integration.test.tssrc/main/runtime/mobile-presence-lock.test.tssrc/main/runtime/mobile-subscribe-integration.test.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/remote-desktop-driver.test.tssrc/main/setup-hook-env-vars.tssrc/main/setup-runner-script-text.tssrc/main/worktree-runner-script.tssrc/relay/agent-hook-endpoint-coordinates.tssrc/relay/agent-hook-envelope-build.tssrc/relay/agent-hook-result-retry-scheduler.tssrc/relay/agent-hook-server.test.tssrc/relay/agent-hook-server.tssrc/relay/fs-handler-ripgrep-fallback.test.tssrc/relay/fs-handler.tssrc/relay/fs-list-files-fallback-chain.tssrc/relay/fs-path-metadata-requests.tssrc/relay/fs-path-mutation-requests.tssrc/relay/relay.ts
💤 Files with no reviewable changes (1)
- config/max-lines-baseline.txt
| export function writePluginFiles(pluginDir = getPluginDir()): void { | ||
| mkdirSync(pluginDir, { recursive: true }) | ||
| writeFileSync(getManifestPath(pluginDir), getPluginManifest(), 'utf-8') | ||
| writeFileSync(getInitPath(pluginDir), getPluginInitSource(), 'utf-8') |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Do not overwrite unmanaged plugin files.
writePluginFiles overwrites existing plugin.yaml and __init__.py files. getPluginFilesState already identifies unmanaged plugin files, but this write path does not use that result. Reject unmanaged or partial plugin directories before writing. Apply the same ownership check before the remote install path writes these files.
Proposed local guard
export function writePluginFiles(pluginDir = getPluginDir()): void {
+ const manifestPath = getManifestPath(pluginDir)
+ const initPath = getInitPath(pluginDir)
+ if ((existsSync(manifestPath) || existsSync(initPath)) && !getPluginFilesState(pluginDir).managed) {
+ throw new Error('Refusing to overwrite unmanaged Hermes plugin files')
+ }
mkdirSync(pluginDir, { recursive: true })
- writeFileSync(getManifestPath(pluginDir), getPluginManifest(), 'utf-8')
- writeFileSync(getInitPath(pluginDir), getPluginInitSource(), 'utf-8')
+ writeFileSync(manifestPath, getPluginManifest(), 'utf-8')
+ writeFileSync(initPath, getPluginInitSource(), 'utf-8')
}| getEffectiveHooks: vi.fn().mockReturnValue(null), | ||
| runHook: vi.fn().mockResolvedValue({ success: true, output: '' }) | ||
| })) | ||
| vi.mock('../worktree-runner-script', () => ({ createSetupRunnerScript: vi.fn() })) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# List worktree-runner-script exports, then compare with each runtime test mock factory.
echo "== exports =="
rg -nP '^export (function|const|type) \w+' src/main/worktree-runner-script.ts
echo "== importers under src/main/runtime =="
rg -nPU "(?s)import (type )?\{.*?\} from '\.\./worktree-runner-script'" src/main/runtime
echo "== mock factories =="
rg -nPU -A 6 "vi\.mock\('\.\./worktree-runner-script'" src/main/runtimeRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -e
for f in \
src/main/runtime/fit-override-integration.test.ts \
src/main/runtime/mobile-presence-lock.test.ts \
src/main/runtime/mobile-subscribe-integration.test.ts \
src/main/runtime/orca-runtime.ts \
src/main/worktree-runner-script.ts
do
echo "== $f =="
rg -n -C 3 "worktree-runner-script|createSetupRunnerScript|createIssueCommandRunnerScript|resolveSetupRunnerShell" "$f"
doneRepository: stablyai/orca
Length of output: 2934
🏁 Script executed:
#!/bin/bash
set -e
for f in \
src/main/runtime/fit-override-integration.test.ts \
src/main/runtime/mobile-presence-lock.test.ts \
src/main/runtime/mobile-subscribe-integration.test.ts
do
echo "== $f: test cases and setup-related fixtures =="
rg -n -C 2 "describe\(|it\(|test\(|setup|createSetupRunnerScript|resolveSetupRunnerShell|createWorktree|worktree" "$f" | head -n 240
done
echo "== all runtime imports of worktree-runner-script =="
rg -n -U -P "from ['\"]\.\./worktree-runner-script['\"]" src/main/runtime --glob '*.ts' | grep -B 8 -A 2 "worktree-runner-script"Repository: stablyai/orca
Length of output: 22392
Add resolveSetupRunnerShell to the three ../worktree-runner-script mocks.
orca-runtime.ts imports and calls this function during worktree setup. createIssueCommandRunnerScript is not imported by orca-runtime.ts and does not need to be mocked.
📍 Affects 3 files
src/main/runtime/fit-override-integration.test.ts#L26-L26(this comment)src/main/runtime/mobile-presence-lock.test.ts#L16-L16src/main/runtime/mobile-subscribe-integration.test.ts#L26-L26
| // Why: setup script runs inside WSL bash, so translate the Windows UNC env-var paths to Linux paths. | ||
| if (wslWorktree) { | ||
| for (const key of Object.keys(envVars)) { | ||
| envVars[key] = toLinuxPath(envVars[key]) | ||
| } | ||
| } else if (nativeWindowsWorktree && runnerShell.family === 'posix') { | ||
| // Why: a Git Bash runner already receives its own path as /c/..., and the shell exports HOME | ||
| // and PWD the same way, so leaving ORCA_* in C:\ form would make them the lone exception. | ||
| // Only path-valued keys convert; the workspace name and policy values are not paths. | ||
| for (const key of SETUP_RUNNER_PATH_ENV_KEYS) { | ||
| const value = envVars[key] | ||
| if (value) { | ||
| envVars[key] = nativeWindowsPathToPosixShellPath(value) | ||
| } | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Restrict WSL conversion to path variables.
Line 135 converts every setup environment value. getSetupRunnerEnvVars also returns ORCA_WORKSPACE_NAME and the credential-guard policy. Pass only SETUP_RUNNER_PATH_ENV_KEYS to toLinuxPath.
Proposed fix
- for (const key of Object.keys(envVars)) {
- envVars[key] = toLinuxPath(envVars[key])
+ for (const key of SETUP_RUNNER_PATH_ENV_KEYS) {
+ const value = envVars[key]
+ if (value) {
+ envVars[key] = toLinuxPath(value)
+ }
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Why: setup script runs inside WSL bash, so translate the Windows UNC env-var paths to Linux paths. | |
| if (wslWorktree) { | |
| for (const key of Object.keys(envVars)) { | |
| envVars[key] = toLinuxPath(envVars[key]) | |
| } | |
| } else if (nativeWindowsWorktree && runnerShell.family === 'posix') { | |
| // Why: a Git Bash runner already receives its own path as /c/..., and the shell exports HOME | |
| // and PWD the same way, so leaving ORCA_* in C:\ form would make them the lone exception. | |
| // Only path-valued keys convert; the workspace name and policy values are not paths. | |
| for (const key of SETUP_RUNNER_PATH_ENV_KEYS) { | |
| const value = envVars[key] | |
| if (value) { | |
| envVars[key] = nativeWindowsPathToPosixShellPath(value) | |
| } | |
| } | |
| // Why: setup script runs inside WSL bash, so translate the Windows UNC env-var paths to Linux paths. | |
| if (wslWorktree) { | |
| for (const key of SETUP_RUNNER_PATH_ENV_KEYS) { | |
| const value = envVars[key] | |
| if (value) { | |
| envVars[key] = toLinuxPath(value) | |
| } | |
| } | |
| } else if (nativeWindowsWorktree && runnerShell.family === 'posix') { | |
| // Why: a Git Bash runner already receives its own path as /c/..., and the shell exports HOME | |
| // and PWD the same way, so leaving ORCA_* in C:\ form would make them the lone exception. | |
| // Only path-valued keys convert; the workspace name and policy values are not paths. | |
| for (const key of SETUP_RUNNER_PATH_ENV_KEYS) { | |
| const value = envVars[key] | |
| if (value) { | |
| envVars[key] = nativeWindowsPathToPosixShellPath(value) | |
| } | |
| } |
3bed660 to
9ca84a6
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 330a515b-b8db-4c7e-a5da-49160f26ee97
📥 Commits
Reviewing files that changed from the base of the PR and between 93ab6e1 and 9ca84a6f9bec0a9f64cc31e8b1cf6129cef3e7cc.
📒 Files selected for processing (78)
config/max-lines-baseline.txtconfig/tsconfig.cli.jsonsrc/main/amp/agent-status-plugin-source.tssrc/main/amp/hook-service.tssrc/main/amp/managed-plugin-install-status.tssrc/main/antigravity/hook-events.tssrc/main/antigravity/hook-script.tssrc/main/antigravity/hook-service.tssrc/main/antigravity/hooks-json-bundle.tssrc/main/copilot/copilot-managed-hook-definitions.tssrc/main/copilot/copilot-managed-script.tssrc/main/copilot/copilot-remote-hook-install.tssrc/main/copilot/hook-service.tssrc/main/effective-hook-config.tssrc/main/global-fetch-call-site-audit.test.tssrc/main/hermes/hermes-config-yaml.tssrc/main/hermes/hermes-home-filesystem.tssrc/main/hermes/hermes-managed-plugin-source.tssrc/main/hermes/hook-service.tssrc/main/hook-runtime-target.tssrc/main/hooks-effective-hook-resolution.test.tssrc/main/hooks-issue-command.test.tssrc/main/hooks-runner.test.tssrc/main/hooks-setup-runner-script.test.tssrc/main/hooks.test.tssrc/main/hooks.tssrc/main/ipc/worktree-remote.tssrc/main/ipc/worktrees-create-metadata-persistence.test.tssrc/main/ipc/worktrees-delete-pty-teardown.test.tssrc/main/ipc/worktrees-detected-scan-cache.test.tssrc/main/ipc/worktrees-discovery-metadata-backfill.test.tssrc/main/ipc/worktrees-existing-branch-checkout.test.tssrc/main/ipc/worktrees-forget-local.test.tssrc/main/ipc/worktrees-issue-command-overrides.test.tssrc/main/ipc/worktrees-lineage-hydration.test.tssrc/main/ipc/worktrees-listing-fallback-rows.test.tssrc/main/ipc/worktrees-local-base-ref-resolution.test.tssrc/main/ipc/worktrees-local-create-flow.test.tssrc/main/ipc/worktrees-orphan-directory-cleanup.test.tssrc/main/ipc/worktrees-preserved-branch-fork-remote.test.tssrc/main/ipc/worktrees-removal-recovery.test.tssrc/main/ipc/worktrees-remove-archive-hooks.test.tssrc/main/ipc/worktrees-remove-host-disambiguation.test.tssrc/main/ipc/worktrees-remove-preflight.test.tssrc/main/ipc/worktrees-setup-launch-sparse-checkout.test.tssrc/main/ipc/worktrees-ssh-base-ref-resolution.test.tssrc/main/ipc/worktrees-ssh-branch-conflict-suffixing.test.tssrc/main/ipc/worktrees-ssh-create-base-prefetch.test.tssrc/main/ipc/worktrees-ssh-local-base-refresh.test.tssrc/main/ipc/worktrees-ssh-pr-head-fetch.test.tssrc/main/ipc/worktrees-ssh-provider-authority.test.tssrc/main/ipc/worktrees-ssh-repo-owner-resolution.test.tssrc/main/ipc/worktrees-ssh-setup-launch.test.tssrc/main/ipc/worktrees-test-module-mocks.tssrc/main/ipc/worktrees-windows.test.tssrc/main/ipc/worktrees-wsl-runtime-routing.test.tssrc/main/ipc/worktrees.tssrc/main/issue-command-file.tssrc/main/runtime/fit-override-integration.test.tssrc/main/runtime/mobile-presence-lock.test.tssrc/main/runtime/mobile-subscribe-integration.test.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/remote-desktop-driver.test.tssrc/main/setup-hook-env-vars.tssrc/main/setup-runner-script-text.tssrc/main/worktree-runner-script.tssrc/relay/agent-hook-endpoint-coordinates.tssrc/relay/agent-hook-envelope-build.tssrc/relay/agent-hook-result-retry-scheduler.tssrc/relay/agent-hook-server.test.tssrc/relay/agent-hook-server.tssrc/relay/fs-handler-ripgrep-fallback.test.tssrc/relay/fs-handler.tssrc/relay/fs-list-files-fallback-chain.tssrc/relay/fs-path-metadata-requests.tssrc/relay/fs-path-mutation-requests.tssrc/relay/relay.ts
💤 Files with no reviewable changes (1)
- config/max-lines-baseline.txt
🚧 Files skipped from review as they are similar to previous changes (43)
- src/relay/relay.ts
- src/main/ipc/worktree-remote.ts
- src/main/runtime/mobile-presence-lock.test.ts
- src/main/runtime/mobile-subscribe-integration.test.ts
- src/relay/agent-hook-server.test.ts
- src/main/global-fetch-call-site-audit.test.ts
- src/main/ipc/worktrees-windows.test.ts
- src/main/runtime/remote-desktop-driver.test.ts
- src/main/runtime/orca-runtime.test.ts
- src/main/ipc/worktrees.ts
- src/main/runtime/orca-runtime.ts
- src/main/hooks.test.ts
- src/main/setup-hook-env-vars.ts
- src/main/copilot/copilot-remote-hook-install.ts
- src/main/hook-runtime-target.ts
- src/main/antigravity/hook-events.ts
- src/main/runtime/fit-override-integration.test.ts
- src/relay/fs-handler.ts
- src/relay/agent-hook-endpoint-coordinates.ts
- src/main/hermes/hermes-home-filesystem.ts
- src/main/copilot/hook-service.ts
- config/tsconfig.cli.json
- src/main/amp/managed-plugin-install-status.ts
- src/main/antigravity/hook-script.ts
- src/relay/fs-path-mutation-requests.ts
- src/main/amp/hook-service.ts
- src/relay/fs-handler-ripgrep-fallback.test.ts
- src/relay/fs-path-metadata-requests.ts
- src/main/worktree-runner-script.ts
- src/relay/agent-hook-envelope-build.ts
- src/main/effective-hook-config.ts
- src/main/antigravity/hook-service.ts
- src/main/hermes/hook-service.ts
- src/relay/agent-hook-result-retry-scheduler.ts
- src/main/setup-runner-script-text.ts
- src/main/copilot/copilot-managed-hook-definitions.ts
- src/main/antigravity/hooks-json-bundle.ts
- src/main/copilot/copilot-managed-script.ts
- src/main/hermes/hermes-managed-plugin-source.ts
- src/main/issue-command-file.ts
- src/relay/agent-hook-server.ts
- src/main/hermes/hermes-config-yaml.ts
- src/main/amp/agent-status-plugin-source.ts
| const isGitRepo = await new Promise<boolean>((resolve) => { | ||
| execFile( | ||
| 'git', | ||
| ['rev-parse', '--is-inside-work-tree'], | ||
| { cwd: rootPath, env: buildRelayCommandEnv() }, | ||
| (err) => resolve(!err) | ||
| ) | ||
| }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm the execFile options contract and check for an existing probe-timeout convention in the relay bundle.
set -euo pipefail
echo '--- other execFile call sites in src/relay ---'
rg -nP -C4 '\bexecFile\s*\(' src/relay
echo '--- existing timeout constants in src/relay ---'
rg -nP 'timeout' src/relay -g '*.ts' | rg -nP 'TIMEOUT|timeout:'
echo '--- declared Node types version ---'
fd -t f 'package.json' -d 2 --exec rg -n '"`@types/node`"|"node":' {}Repository: stablyai/orca
Length of output: 6832
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- file outline ---'
ast-grep outline src/relay/fs-list-files-fallback-chain.ts
echo '--- target implementation ---'
cat -n src/relay/fs-list-files-fallback-chain.ts
echo '--- callers and cancellation helpers ---'
rg -n -C4 'runListFilesScan|listFilesWithGit|listFilesWithReaddir|throwIfFileListingCancelled|AbortSignal' src/relay -g '*.ts'
echo '--- relevant tests ---'
rg -n -C5 'fs-list-files-fallback-chain|rev-parse|listFilesWithGit|listFilesWithReaddir|runListFilesScan' src/relay -g '*test.ts'Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- cancellation implementation ---'
cat -n src/shared/file-listing-cancellation.ts
echo '--- focused fallback-chain test section ---'
sed -n '1,180p' src/relay/fs-handler-ripgrep-fallback.test.ts
echo '--- list-files handler call site ---'
rg -n -C8 'runListFilesScan\(' src/relay -g '*.ts' -g '!*.test.ts'
echo '--- walker budget and deadline definitions ---'
rg -n -C6 'createQuickOpenReaddirBudget|deadline|timeout|AbortSignal|signal' \
src/relay/fs-handler-git-fallback.ts \
src/relay/fs-handler-readdir-fallback.ts \
src/shared/quick-open-readdir-walk.ts \
src/relay/fs-handler-list-files.ts
echo '--- execFile type declarations ---'
rg -n -C8 'function execFile|execFile\(' node_modules/@types/node/child_process.d.ts 2>/dev/null || trueRepository: stablyai/orca
Length of output: 48119
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- quick-open walker entry checks ---'
sed -n '111,180p' src/shared/quick-open-readdir-walk.ts
sed -n '1,90p' src/shared/quick-open-readdir-budget.ts
echo '--- scan coordinator cancellation behavior ---'
rg -n -C8 'class .*Scan|listFilesScans|start\(|abort\(|AbortController' src/relay -g '*scan*.ts' -g '*.ts' | head -240
echo '--- Node execFile timeout and signal behavior ---'
node - <<'JS'
const { execFile } = require('node:child_process');
function probe(options, abortDelay) {
return new Promise((resolve) => {
const started = Date.now();
const controller = options.signal ? new AbortController() : null;
const finalOptions = controller ? { ...options, signal: controller.signal } : options;
const child = execFile(
process.execPath,
['-e', 'setTimeout(() => {}, 60_000)'],
finalOptions,
(error) => resolve({
elapsedMs: Date.now() - started,
errorName: error?.name ?? null,
killed: child.killed,
signalCode: child.signalCode
})
);
if (controller) setTimeout(() => controller.abort(), abortDelay);
});
}
(async () => {
console.log('timeout', await probe({ timeout: 50 }));
console.log('abort', await probe({ signal: true }, 50));
})();
JSRepository: stablyai/orca
Length of output: 23748
Bound and cancel the git rev-parse probe.
Pass a bounded timeout and signal to execFile. Call throwIfFileListingCancelled(signal) after the probe so AbortError cannot enter fallback logic.
🧰 Tools
🪛 ast-grep (0.45.1)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { execFile } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
Source: Linters/SAST tools
…max-lines budget The four agent hook services, the main hooks module, and the two relay modules each carried a file-level `eslint-disable max-lines` and ran 365-628 counted lines against a 300-line budget. AGENTS.md calls for splitting rather than suppressing, and config/max-lines-baseline.txt is a shrink-only ratchet, so this removes all seven suppressions and prunes their entries (341 -> 334). Pure move, no behavior change. Each hook service splits into its managed script source, its config/bundle serialization, and its remote-install path, keeping the per-agent integrations independent: copilot, amp, antigravity and hermes each retain their own getManagedScript rather than sharing one, because each emits a different script body for a different agent. Merging them by name would have been a behavior change, not a refactor. For antigravity the suppression's stated rationale -- that local install, Windows wrapper generation, status cleanup, and SSH remote install must share one event list and managed-command matcher so stale-hook cleanup cannot drift by platform -- is now enforced structurally instead: both install paths call buildInstalledConfig + createAntigravityManagedCommandMatcher over the single ANTIGRAVITY_EVENTS catalog, with the graph a strict DAG. Also registers the six new antigravity/ and copilot/ modules in config/tsconfig.cli.json. That project uses a curated `include` list rather than a glob, so an unlisted module fails `tsc -p config/tsconfig.tc.cli.json` with TS6307 even though the entire unit suite passes. Verified: oxlint clean, ratchet passes, typecheck clean, full unit suite green (remaining failures are pre-existing load flakes in untouched files, green when re-run serially), no new runtime import cycles, and no lint suppression added.
9ca84a6 to
2e91b9d
Compare
…max-lines budget (#14725) The four agent hook services, the main hooks module, and the two relay modules each carried a file-level `eslint-disable max-lines` and ran 365-628 counted lines against a 300-line budget. AGENTS.md calls for splitting rather than suppressing, and config/max-lines-baseline.txt is a shrink-only ratchet, so this removes all seven suppressions and prunes their entries (341 -> 334). Pure move, no behavior change. Each hook service splits into its managed script source, its config/bundle serialization, and its remote-install path, keeping the per-agent integrations independent: copilot, amp, antigravity and hermes each retain their own getManagedScript rather than sharing one, because each emits a different script body for a different agent. Merging them by name would have been a behavior change, not a refactor. For antigravity the suppression's stated rationale -- that local install, Windows wrapper generation, status cleanup, and SSH remote install must share one event list and managed-command matcher so stale-hook cleanup cannot drift by platform -- is now enforced structurally instead: both install paths call buildInstalledConfig + createAntigravityManagedCommandMatcher over the single ANTIGRAVITY_EVENTS catalog, with the graph a strict DAG. Also registers the six new antigravity/ and copilot/ modules in config/tsconfig.cli.json. That project uses a curated `include` list rather than a glob, so an unlisted module fails `tsc -p config/tsconfig.tc.cli.json` with TS6307 even though the entire unit suite passes. Verified: oxlint clean, ratchet passes, typecheck clean, full unit suite green (remaining failures are pre-existing load flakes in untouched files, green when re-run serially), no new runtime import cycles, and no lint suppression added.
One conflicting file, src/relay/agent-hook-server.ts, and the conflict is entirely stablyai#14725's split of that file: main moved the endpoint coordinates, the envelope builder and the assistant-message/codex retry scheduling out into three modules, so every constant, import and method this branch had added sat next to something that had left. Resolved by keeping only what the merged file still reaches: the cwd attribution imports and FOREIGN_CWD_WARN_PANE_CAP stay, the retry and endpoint constants go with the code that moved, and the class keeps both sides' fields. The one resolution git could not have reached on its own is in a file it reported as clean. This branch added `sourceCwd` to the envelope inside the private `forwardEvent`; stablyai#14725 extracted that method into buildRelayHookEnvelope in agent-hook-envelope-build.ts, before the field existed, and repointed both the live and replay call sites at it. Taking either side alone drops the field silently — the method is dead with no callers, and the builder never carried it. `sourceCwd` now lives in the builder, which is what both legs go through. Verified by removing that one line again: 'forwards a parsed Claude UserPromptSubmit POST as a normalized envelope' fails with `expected undefined to be '/srv/app'`. relay, shared agent-hook and main/agent-hooks suites: 197 files, 2010 passing. tsc clean on the node project, oxlint and oxfmt clean, 85 reliability gates, ratchet at 190.
…max-lines budget (stablyai#14725) The four agent hook services, the main hooks module, and the two relay modules each carried a file-level `eslint-disable max-lines` and ran 365-628 counted lines against a 300-line budget. AGENTS.md calls for splitting rather than suppressing, and config/max-lines-baseline.txt is a shrink-only ratchet, so this removes all seven suppressions and prunes their entries (341 -> 334). Pure move, no behavior change. Each hook service splits into its managed script source, its config/bundle serialization, and its remote-install path, keeping the per-agent integrations independent: copilot, amp, antigravity and hermes each retain their own getManagedScript rather than sharing one, because each emits a different script body for a different agent. Merging them by name would have been a behavior change, not a refactor. For antigravity the suppression's stated rationale -- that local install, Windows wrapper generation, status cleanup, and SSH remote install must share one event list and managed-command matcher so stale-hook cleanup cannot drift by platform -- is now enforced structurally instead: both install paths call buildInstalledConfig + createAntigravityManagedCommandMatcher over the single ANTIGRAVITY_EVENTS catalog, with the graph a strict DAG. Also registers the six new antigravity/ and copilot/ modules in config/tsconfig.cli.json. That project uses a curated `include` list rather than a glob, so an unlisted module fails `tsc -p config/tsconfig.tc.cli.json` with TS6307 even though the entire unit suite passes. Verified: oxlint clean, ratchet passes, typecheck clean, full unit suite green (remaining failures are pre-existing load flakes in untouched files, green when re-run serially), no new runtime import cycles, and no lint suppression added.
What
Splits the four agent hook services, the main hooks module, and the two relay modules into focused modules; removes their
eslint-disable max-linessuppressions; prunes the seven corresponding ratchet-baseline entries (341 → 334).No behavior change.
Why
Each file carried a file-level
max-linessuppression and ran 365–628 counted lines against a 300-line budget. PerAGENTS.md→ "Do Not Disable Max Lines", the fix is to split, not suppress;config/max-lines-baseline.txtis a shrink-only ratchet.How it was split
main/hooks.tshermes/hook-service.tshermes-managed-plugin-source,hermes-config-yaml,hermes-home-filesystemrelay/agent-hook-server.tsantigravity/hook-service.tshook-events,hook-script,hooks-json-bundleamp/hook-service.tsagent-status-plugin-source,managed-plugin-install-statuscopilot/hook-service.tscopilot-managed-script,copilot-managed-hook-definitions,copilot-remote-hook-installrelay/fs-handler.tsThe per-agent integrations stay independent.
copilot,amp,antigravityandhermeseach keep their owngetManagedScript, and each folder keeps its own one-lineisRecordguard. These collide by name only — each emits a different script body for a different agent — so merging them would be a behavior change and would introduce cross-agent coupling the original code does not have.For
antigravity, the removed suppression's stated rationale (local install, Windows wrapper generation, status cleanup, and SSH remote install must share one event list and managed-command matcher so stale-hook cleanup cannot drift by platform) is now enforced structurally instead of by co-location: bothinstallandinstallRemotecallbuildInstalledConfig+createAntigravityManagedCommandMatcherover the singleANTIGRAVITY_EVENTScatalog, with the module graph a strict DAG.Similarly for
amp,AMP_PLUGIN_MARKERstays a single exported constant imported by both the emitter andisManagedPlugin, so install and detect cannot diverge.No barrel exports; every new module owns real logic and importers point at the owner.
Verification
npx oxlint(whole repo) — cleanpnpm check:max-lines-ratchet— passes; baseline 341 → 334pnpm typecheck(node + cli + web) — cleanpnpm test— full suite green; remaining failures are pre-existing load-induced timeouts in files this branch does not touch, each verified passing when re-run seriallyeslint/oxlint-disabledirective added anywhere, confirmed by diff grepA CLI-build break the test suite could not catch
The full 4906-file unit suite passed 100% green on the first pass, while
pnpm typecheckfailed with sixTS6307errors.config/tsconfig.cli.jsonuses a curatedincludelist rather than a glob, so any module extracted from a CLI-visible file must be registered there explicitly. Without it the CLI build breaks while every test still passes.This PR adds the six missing
antigravity/andcopilot/entries in alphabetical position. Worth knowing for any future split in this area.Pre-existing issues found and deliberately NOT changed
copilot/hook-service.ts:definitionsChangedcompares elements by reference identity (definition !== before[index]), soremove()depends onremoveManagedCommandsreturning identical object references for untouched entries. If that helper ever starts cloning,remove()would rewritehooks/orca.jsonon every call.antigravity/hooks-json-bundle.ts: detection asymmetry —hasManagedCommand(used bygetStatus) inspects onlydefinition.commandanddefinition.hooks[].command, whilebundleHasStaleManagedCommandalso inspectsdefinition.bashanddefinition.powershell. A managed command written into abash/powershellfield is counted stale but never counted present, pinninggetStatusatpartial.antigravity/hooks-json-bundle.ts:buildInstalledConfigprunes managed commands across the whole bundle and then again per event — idempotent, so harmless, but dead work.amp/hook-service.ts:remove()callsunlinkSyncunguarded on a managed file, so a concurrent delete would throw out ofremove.