Repository navigation
chore(dead-code): drop ~2k lines of unreachable exports and orphan modules - #12077
Conversation
…ules Ran knip across every build entry (main, preload, renderer, popout, web, cli, relay, workers, forked sidecars, config scripts) and removed what no entry graph can reach. - 11 orphan modules nothing imported, plus one test that only covered them - 159 unused exports/types, with their now-dead helpers, imports and tests Each candidate was verified against dynamic references before deletion. 42 knip hits were false positives and are kept: shared modules consumed by the mobile/ workspace, the src/shared/plugins/** public API, vendored shadcn primitives, and relay wire-protocol constants held for compatibility. Adds knip.json + `pnpm audit:dead-code` so this stays measurable. Verified: pnpm typecheck, pnpm lint, and 2081 tests across the 73 affected test files all pass.
|
Too many files changed for review. ( Bypass the limit by tagging |
|
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: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded a Knip configuration and 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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: 2
🧹 Nitpick comments (1)
package.json (1)
19-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePin the Knip analyzer to a locked version.
pnpm dlx knip@5resolves theknip@5semver range from the registry rather than executing a package tracked inpackage.json/pnpm-lock.yaml, so the audit can follow different analyzer code after upstream 5.x releases. Add an exactknipdevDependency and runpnpm exec knipduring maintenance.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 06271489-2612-46cb-82bc-a69aed3c16f3
📒 Files selected for processing (146)
knip.jsonpackage.jsonsrc/cli/runtime/environments.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-protocol.tssrc/main/claude-usage/scanner.tssrc/main/codex-usage/scanner.tssrc/main/computer/macos-native-provider-paths.tssrc/main/daemon/terminal-private-mode-tracker.tssrc/main/emulator/android/android-input-mapping.tssrc/main/emulator/emulator-types.tssrc/main/git/git-username.tssrc/main/git/repo.tssrc/main/github/github-api-repository.tssrc/main/github/github-enterprise-repository.tssrc/main/github/project-view.tssrc/main/github/project-view/internals.tssrc/main/gitlab/gl-utils.tssrc/main/ipc/feedback-image-attachments.tssrc/main/ipc/parcel-watcher-host-subscriptions.tssrc/main/ipc/parcel-watcher-process.tssrc/main/ipc/runtime-environment-request-connections.tssrc/main/ipc/worktree-change-invalidators.tssrc/main/observability/index.tssrc/main/observability/instrumentation.tssrc/main/observability/redactor.tssrc/main/pi/prefill-extension-source.tssrc/main/pi/titlebar-extension-service.tssrc/main/plugins/plugin-enablement.tssrc/main/providers/pty-process-list-admission.tssrc/main/providers/types.tssrc/main/rate-limits/grok-auth.tssrc/main/runtime/orca-runtime-emulator.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/orchestration/groups.tssrc/main/runtime/rpc/schemas.tssrc/main/shell-ready-marker-scanner.tssrc/main/ssh/relay-protocol.tssrc/main/ssh/sftp-namespace-resolution.tssrc/main/ssh/sftp-upload.tssrc/main/ssh/ssh-pty-consumer-session.tssrc/main/ssh/ssh-relay-session-managed-hooks.test.tssrc/main/ssh/ssh-relay-session.test.tssrc/main/system-fonts.tssrc/main/telemetry/client.tssrc/relay/fs-handler-file-read.tssrc/renderer/src/components/automations/automation-page-parts.tsxsrc/renderer/src/components/browser-pane/browser-automation-visibility.tssrc/renderer/src/components/browser-pane/browser-page-zoom.tssrc/renderer/src/components/dashboard/useDashboardData.tssrc/renderer/src/components/editor/NotesSendMenu.test.tsxsrc/renderer/src/components/editor/ReviewNotesSendMenuContent.test.tsxsrc/renderer/src/components/editor/markdown-round-trip.tssrc/renderer/src/components/emulator-pane/emulator-keyboard-paste.tssrc/renderer/src/components/emulator-pane/emulator-pane-types.tssrc/renderer/src/components/github-project/column-widths.tssrc/renderer/src/components/github/github-issue-comment-helpers.tssrc/renderer/src/components/linear-issue-workspace-text.tssrc/renderer/src/components/native-chat/native-chat-composer-state.tssrc/renderer/src/components/onboarding/use-onboarding-flow.tssrc/renderer/src/components/repo/repo-icon.tsxsrc/renderer/src/components/right-sidebar/CreateHostedReviewComposer.tsxsrc/renderer/src/components/right-sidebar/commit-failure-dialog-state.tssrc/renderer/src/components/right-sidebar/file-explorer-operation-owner.tssrc/renderer/src/components/right-sidebar/file-explorer-runtime-owner-boundary.test.tssrc/renderer/src/components/right-sidebar/push-failure-summary.tssrc/renderer/src/components/right-sidebar/source-control-active-open-file-keys.tssrc/renderer/src/components/right-sidebar/source-control-ai-commit-failure-launch.test.tssrc/renderer/src/components/right-sidebar/source-control-ai-commit-failure-launch.tssrc/renderer/src/components/right-sidebar/source-control-ai-push-failure-launch.tssrc/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.tssrc/renderer/src/components/right-sidebar/source-control-primary-action-types.tssrc/renderer/src/components/settings/SettingsConstants.tssrc/renderer/src/components/settings/general-search.tssrc/renderer/src/components/settings/terminal-windows-search.tssrc/renderer/src/components/sidebar/WorktreeCardHelpers.tsxsrc/renderer/src/components/sidebar/WorktreeCardPorts.tsxsrc/renderer/src/components/sidebar/create-project-defaults.tssrc/renderer/src/components/sidebar/project-header-drop.tssrc/renderer/src/components/sidebar/sidebar-host-options.tssrc/renderer/src/components/sidebar/sidebar-nav-controls.tsxsrc/renderer/src/components/sidebar/workspace-kanban-card-drag-preview-dom.tssrc/renderer/src/components/tab-bar/shell-icons.tsxsrc/renderer/src/components/tab-bar/tab-create-entry-path-validation.tssrc/renderer/src/components/tab-group/tab-drag-context.tsxsrc/renderer/src/components/terminal-pane/pty-delivery-interest.tssrc/renderer/src/components/terminal-pane/pty-pre-handler-buffer.tssrc/renderer/src/components/terminal-pane/terminal-hidden-delivery-gate.tssrc/renderer/src/components/terminal/terminal-tab-actions.tssrc/renderer/src/constants/terminal.tssrc/renderer/src/hooks/useAutomationDispatchEvents.test.tssrc/renderer/src/hooks/useIssueMetadata.tssrc/renderer/src/hooks/useShortcutLabel.tssrc/renderer/src/lib/active-agent-note-send.tssrc/renderer/src/lib/active-agent-note-target.tssrc/renderer/src/lib/agent-hibernation-coordinator.tssrc/renderer/src/lib/agent-paste-draft.tssrc/renderer/src/lib/crash-diagnostics.test.tssrc/renderer/src/lib/crash-diagnostics.tssrc/renderer/src/lib/ensure-simulator-tab.tssrc/renderer/src/lib/keyboard-layout/input-source-id.tssrc/renderer/src/lib/keyboard-layout/option-as-alt-probe.tssrc/renderer/src/lib/open-mobile-emulator-tab.test.tssrc/renderer/src/lib/repo-slug-index.tssrc/renderer/src/lib/setup-script-status.tssrc/renderer/src/lib/workspace-port-actions.tssrc/renderer/src/store/slices/runtime-detected-agents.tssrc/shared/agent-session-host-authority.tssrc/shared/agent-session-option-catalog.tssrc/shared/commit-message-generation.tssrc/shared/custom-pet-media-limits.tssrc/shared/daemon-audit-eligibility.tssrc/shared/daemon-lifecycle-telemetry.tssrc/shared/ephemeral-vm-recipes.tssrc/shared/ephemeral-vm-runtimes.tssrc/shared/folder-workspaces.tssrc/shared/hermes-run-output-limits.tssrc/shared/hermes-run-ref-retention.tssrc/shared/hosted-review.tssrc/shared/html-to-pdf-memory-limit.tssrc/shared/left-sidebar-appearance.tssrc/shared/linear-agent-access.tssrc/shared/linux-proc-port-scan-limits.tssrc/shared/native-file-drop.tssrc/shared/persisted-state-file-bounds.tssrc/shared/pr-refresh-memory-limits.tssrc/shared/pty-source-credit-contract.tssrc/shared/relay-json-admission.tssrc/shared/remote-runtime-memory-limits.tssrc/shared/remote-runtime-shared-control-state.tssrc/shared/remote-workspace-types.tssrc/shared/runtime-bootstrap.tssrc/shared/runtime-environments.tssrc/shared/runtime-types.tssrc/shared/serve-update-handoff.tssrc/shared/source-control-create-review-intent.tssrc/shared/ssh-retained-payload-admission.tssrc/shared/task-source-context.tssrc/shared/telemetry-events.tssrc/shared/terminal-custom-themes.tssrc/shared/terminal-scrollback-policy.tssrc/shared/terminal-size-limits.tssrc/shared/terminal-title-display.tssrc/shared/terminal-title-status.tssrc/shared/work-items.tssrc/shared/workspace-scope.tssrc/shared/wsl-hook-relay-contract.ts
💤 Files with no reviewable changes (124)
- src/renderer/src/components/settings/general-search.ts
- src/main/gitlab/gl-utils.ts
- src/main/observability/redactor.ts
- src/shared/pr-refresh-memory-limits.ts
- src/renderer/src/components/tab-group/tab-drag-context.tsx
- src/renderer/src/components/linear-issue-workspace-text.ts
- src/renderer/src/store/slices/runtime-detected-agents.ts
- src/renderer/src/lib/keyboard-layout/option-as-alt-probe.ts
- src/main/git/git-username.ts
- src/renderer/src/components/right-sidebar/CreateHostedReviewComposer.tsx
- src/main/emulator/emulator-types.ts
- src/main/ssh/ssh-relay-session.test.ts
- src/renderer/src/components/native-chat/native-chat-composer-state.ts
- src/shared/pty-source-credit-contract.ts
- src/renderer/src/components/right-sidebar/source-control-ai-commit-failure-launch.test.ts
- src/renderer/src/components/right-sidebar/commit-failure-dialog-state.ts
- src/main/ipc/runtime-environment-request-connections.ts
- src/main/git/repo.ts
- src/renderer/src/components/right-sidebar/source-control-ai-commit-failure-launch.ts
- src/cli/runtime/environments.ts
- src/main/github/project-view/internals.ts
- src/renderer/src/components/sidebar/workspace-kanban-card-drag-preview-dom.ts
- src/shared/runtime-environments.ts
- src/main/ipc/worktree-change-invalidators.ts
- src/renderer/src/components/repo/repo-icon.tsx
- src/shared/relay-json-admission.ts
- src/renderer/src/components/sidebar/create-project-defaults.ts
- src/main/telemetry/client.ts
- src/main/observability/instrumentation.ts
- src/shared/commit-message-generation.ts
- src/shared/ssh-retained-payload-admission.ts
- src/renderer/src/components/sidebar/project-header-drop.ts
- src/main/rate-limits/grok-auth.ts
- src/renderer/src/lib/agent-paste-draft.ts
- src/main/pi/titlebar-extension-service.ts
- src/renderer/src/components/browser-pane/browser-page-zoom.ts
- src/main/shell-ready-marker-scanner.ts
- src/renderer/src/components/github-project/column-widths.ts
- src/renderer/src/components/right-sidebar/source-control-active-open-file-keys.ts
- src/shared/wsl-hook-relay-contract.ts
- src/main/codex-usage/scanner.ts
- src/renderer/src/constants/terminal.ts
- src/shared/source-control-create-review-intent.ts
- src/shared/agent-session-option-catalog.ts
- src/renderer/src/components/right-sidebar/file-explorer-operation-owner.ts
- src/shared/agent-session-host-authority.ts
- src/renderer/src/components/automations/automation-page-parts.tsx
- src/renderer/src/components/sidebar/sidebar-host-options.ts
- src/shared/daemon-audit-eligibility.ts
- src/renderer/src/lib/keyboard-layout/input-source-id.ts
- src/shared/hermes-run-output-limits.ts
- src/shared/custom-pet-media-limits.ts
- src/renderer/src/components/right-sidebar/source-control-primary-action-types.ts
- src/renderer/src/lib/repo-slug-index.ts
- src/main/github/github-api-repository.ts
- src/renderer/src/hooks/useIssueMetadata.ts
- src/main/computer/macos-native-provider-paths.ts
- src/main/runtime/rpc/schemas.ts
- src/main/ipc/parcel-watcher-process.ts
- src/renderer/src/components/emulator-pane/emulator-keyboard-paste.ts
- src/main/runtime/orchestration/groups.ts
- src/main/system-fonts.ts
- src/renderer/src/components/settings/SettingsConstants.ts
- src/renderer/src/components/github/github-issue-comment-helpers.ts
- src/shared/remote-runtime-memory-limits.ts
- src/renderer/src/components/right-sidebar/push-failure-summary.ts
- src/renderer/src/components/emulator-pane/emulator-pane-types.ts
- src/shared/terminal-scrollback-policy.ts
- src/renderer/src/components/right-sidebar/source-control-ai-push-failure-launch.ts
- src/main/ssh/ssh-relay-session-managed-hooks.test.ts
- src/main/pi/prefill-extension-source.ts
- src/renderer/src/components/browser-pane/browser-automation-visibility.ts
- src/renderer/src/components/tab-bar/shell-icons.tsx
- src/renderer/src/components/terminal-pane/pty-delivery-interest.ts
- src/main/providers/pty-process-list-admission.ts
- src/shared/runtime-bootstrap.ts
- src/renderer/src/components/tab-bar/tab-create-entry-path-validation.ts
- src/shared/remote-workspace-types.ts
- src/shared/linear-agent-access.ts
- src/renderer/src/components/settings/terminal-windows-search.ts
- src/renderer/src/lib/active-agent-note-send.ts
- src/main/ssh/relay-protocol.ts
- src/shared/terminal-custom-themes.ts
- src/shared/terminal-title-display.ts
- src/shared/terminal-title-status.ts
- src/main/claude-usage/scanner.ts
- src/shared/hermes-run-ref-retention.ts
- src/shared/ephemeral-vm-runtimes.ts
- src/shared/workspace-scope.ts
- src/shared/hosted-review.ts
- src/shared/linux-proc-port-scan-limits.ts
- src/main/runtime/orca-runtime-emulator.ts
- src/renderer/src/components/terminal-pane/terminal-hidden-delivery-gate.ts
- src/shared/telemetry-events.ts
- src/shared/task-source-context.ts
- src/main/daemon/terminal-private-mode-tracker.ts
- src/renderer/src/components/onboarding/use-onboarding-flow.ts
- src/main/observability/index.ts
- src/shared/daemon-lifecycle-telemetry.ts
- src/main/plugins/plugin-enablement.ts
- src/renderer/src/lib/agent-hibernation-coordinator.ts
- src/main/ssh/sftp-upload.ts
- src/shared/runtime-types.ts
- src/shared/left-sidebar-appearance.ts
- src/main/github/github-enterprise-repository.ts
- src/renderer/src/components/terminal-pane/pty-pre-handler-buffer.ts
- src/renderer/src/components/editor/markdown-round-trip.ts
- src/renderer/src/components/sidebar/sidebar-nav-controls.tsx
- src/renderer/src/lib/ensure-simulator-tab.ts
- src/shared/html-to-pdf-memory-limit.ts
- src/renderer/src/lib/workspace-port-actions.ts
- src/shared/remote-runtime-shared-control-state.ts
- src/main/ssh/ssh-pty-consumer-session.ts
- src/renderer/src/components/sidebar/WorktreeCardPorts.tsx
- src/renderer/src/hooks/useShortcutLabel.ts
- src/main/emulator/android/android-input-mapping.ts
- src/shared/native-file-drop.ts
- src/main/ipc/parcel-watcher-host-subscriptions.ts
- src/shared/serve-update-handoff.ts
- src/renderer/src/components/terminal/terminal-tab-actions.ts
- src/renderer/src/lib/crash-diagnostics.ts
- src/main/ipc/feedback-image-attachments.ts
- src/shared/terminal-size-limits.ts
- src/renderer/src/lib/active-agent-note-target.ts
| ], | ||
| "project": ["src/**/*.{ts,tsx}", "config/scripts/**/*.{mjs,cjs,js,ts}", "build-plugins/**/*.ts"], | ||
| "ignore": ["mobile/**", "out/**", "dist/**", "node_modules/**", "resources/**"], | ||
| "ignoreDependencies": ["electron", "@types/*"], |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
node -p "new RegExp('`@types/`*').test('`@types/node`')"
pnpm audit:dead-code -- --include dependenciesRepository: stablyai/orca
Length of output: 5929
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== knip version/config snippets =="
python3 - <<'PY'
import json, pathlib
p=pathlib.Path('knip.json')
if p.exists():
data=json.loads(p.read_text())
print(json.dumps(data.get('ignoreDependencies'), indent=2))
PY
echo
echo "== package metadata =="
if [ -f package.json ]; then
node -e "const p=require('./package.json'); console.log(JSON.stringify({scripts:p.scripts,packageManager:p.packageManager,dependencies:p.dependencies,devDependencies:p.devDependencies}, null, 2))"
fi
echo
if [ -f pnpm-lock.yaml ]; then
rg -n "knip:|version: 5|`@types/node`|`@types/react`|electron" pnpm-lock.yaml | head -80 || true
fi
echo
echo "== JavaScript regex semantics for `@types/`* =="
node - <<'JS'
const values=["`@types/node`","`@types/react`","`@types/something`@1","`@types/a`","`@types/a/b`","types/","types/node","`@types`"]
for (const value of values) {
const rx = new RegExp('`@types/`*');
console.log(`${value} -> ${rx.test(value)}`);
}
const corrected = /^`@types/`.+/;
console.log('corrected:', values.map(v => `${v} -> ${corrected.test(v)}`).join('\n'));
JSRepository: stablyai/orca
Length of output: 21518
🌐 Web query:
Knip v5 ignoreDependencies glob regex asterisk pattern documentation
💡 Result:
In Knip v5, the ignoreDependencies configuration option allows you to exclude specific dependencies from the report [1][2]. You can use both plain strings (for exact package names) and regular expressions to define these patterns [1][2]. Important details regarding patterns in ignoreDependencies: 1. Supported Patterns: - Plain strings: Use the exact name of the dependency to be ignored (e.g., ["hidden-package"]) [1][2]. - Regular Expressions: You can use regex patterns to match groups of dependencies [1][2]. In JSON configuration files (knip.json), these are provided as strings that Knip interprets as regex (e.g., ["@org/.+"]) [1][2]. In dynamic configuration files (knip.ts), you can use actual RegExp objects (e.g., [/@org/./]) [1][2]. 2. Asterisks and Glob vs. Regex: - The ignoreDependencies option uses regex, not glob patterns [1][2]. While you might be accustomed to glob patterns (which often use asterisks) for file matching in Knip (such as in entry or project configurations), ignoreDependencies specifically expects strings that function as regular expressions [1][2]. - If you need to match multiple packages, ensure your asterisk usage follows standard regex syntax (e.g.,. for "any character repeated") rather than glob syntax [1][2]. 3. Usage Examples: - JSON (knip.json): { "ignoreDependencies": ["hidden-package", "@org/.+"] } [1][2] - TypeScript (knip.ts): export default { ignoreDependencies: [/@org/.*/, /^lib-.+/], }; [1][2] 4. Production-only ignores: - You can suffix an item in the ignoreDependencies array with a "!" to enable that specific ignore rule only when Knip is running in production mode [1]. If you find yourself frequently using ignoreDependencies, it is often recommended to first check if better entry and project file coverage or a missing/incomplete plugin is the underlying cause, as these are more robust solutions for dependency reporting issues [3][4].
Citations:
- 1: https://knip.dev/reference/configuration
- 2: https://github.com/webpro-nl/knip/blob/e2943ed8/packages/knip/src/schema/configuration.ts
- 3: https://knip.dev/guides/handling-issues
- 4: https://github.com/webpro-nl/knip/blob/main/packages/docs/src/content/docs/guides/handling-issues.mdx
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== lockfile `@types` entries =="
rg -n "(`@types/`)(node|react-dom|qrcode|ssh2|ws):|/(`@types/`)(node|react-dom|qrcode|ssh2|ws):" pnpm-lock.yaml | head -80 || true
echo
echo "== package.json `@types` dependencies =="
node - <<'JS'
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const pairs = Object.entries({...pkg.dependencies, ...pkg.devDependencies}).filter(([name]) => name.startsWith('`@types/`'));
console.log(JSON.stringify(pairs.map(([name, version]) => `${name}.${version}`), null, 2));
JSRepository: stablyai/orca
Length of output: 380
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== current dead-code audit exit =="
pnpm audit:dead-code --dependencies --no-progress 2>&1 | head -200
status=$?
echo "exit_code=$status"
echo
echo "== `@types` package instances in lockfile =="
node - <<'JS'
const fs = require('fs');
const lock = fs.readFileSync('pnpm-lock.yaml', 'utf8');
for (const name of ['`@types/node`', '`@types/react`', '`@types/react-dom`', '`@types/qrcode`', '`@types/ssh2`', '`@types/ws`']) {
const idx = lock.indexOf(`${name}@`);
console.log(`${name}: ${idx === -1 ? 'missing' : 'present at char ' + idx}`);
}
console.log('line count=', lock.split('\n').length);
console.log('`@types` lines=',(lock.match(/^ `@types`\//gm) || []).length);
JSRepository: stablyai/orca
Length of output: 3664
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== pnpm lockfile pnpm settings =="
sed -n '1,45p' pnpm-lock.yaml || true
echo
echo "== lockfile header tail =="
sed -n '1,20p' pnpm-lock.yaml | cat -n
echo
echo "== package manager and pnpm options =="
python3 - <<'PY'
import json, pathlib
for p in ['package.json','.npmrc','pnpm-workspace.yaml']:
path=pathlib.Path(p)
print(f'-- {p} -- exists={path.exists()}')
if path.exists():
data=path.read_text()
if p=='package.json':
obj=json.loads(data)
print('packageManager=', obj.get('packageManager'))
print('pnpm=', obj.get('pnpm'))
else:
print(data[:800])
PYRepository: stablyai/orca
Length of output: 4149
Fix the @types/* ignore pattern.
Knip v5 interprets ignoreDependencies strings as regular expressions, so @types/* expands slash repeatedly and does not match scoped packages such as @types/node, @types/react, or @types/qrcode.
Proposed fix
- "ignoreDependencies": ["electron", "`@types/`*"],
+ "ignoreDependencies": ["electron", "^`@types/`.+$"],📝 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.
| "ignoreDependencies": ["electron", "@types/*"], | |
| "ignoreDependencies": ["electron", "^`@types/`.+$"], |
| "ignore": ["mobile/**", "out/**", "dist/**", "node_modules/**", "resources/**"], | ||
| "ignoreDependencies": ["electron", "@types/*"], | ||
| "ignoreExportsUsedInFile": true, | ||
| "includeEntryExports": false |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
pnpm audit:dead-code -- --include exports,types
pnpm audit:dead-code -- --include exports,types --include-entry-exportsRepository: stablyai/orca
Length of output: 11440
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== package scripts and package manager =="
node -e "const p=require('./package.json'); console.log(JSON.stringify({scripts:p.scripts, packageManager:p.packageManager}, null, 2))"
echo
echo "== knip config =="
cat -n knip.json
echo
echo "== entry references in scripts and package.json =="
json -p "scripts.*dead-code|audit.*dead|dead.*code" package.json || true
rg -n "audit:dead-code|dead-code|knip|include-entry-exports|includeEntryExports|--include" package.json knip.json package-lock.json pnpm-lock.yaml 2>/dev/null || trueRepository: stablyai/orca
Length of output: 14818
Verify Knip entry-export coverage.
includeEntryExports: false suppresses unused export reports from the configured entry files. Since the audit script runs Knip without --include-entry-exports, and the entry list includes runtime/worker/config/test files, unexpected exports in those entries will not be reported. Run the audit with --include entry-exists --include-entry-exports and confirm any differences are intentional dynamic or public entry exports.
Root-level additions are blocked by the root directory guard. Co-authored-by: Orca <[email protected]>
… contract (#12082) * refactor(usage): share the session/daily fold between Codex and OpenCode The Codex and OpenCode scanners each carried their own byte-identical copy of the ~325-line aggregation pipeline (createEmptySession, the three breakdown folds, finalizeSessions, mergeSessions, mergeDailyAggregates). Two copies means a token-accounting fix — a bucket that double-counts, a merge that drops a breakdown row — lands in one provider and silently not the other. The copies had already started to drift in comments only; the next drift would have been in arithmetic. The providers differ in exactly one dimension: the extra metric folded alongside the token counters (Codex `hasInferredPricing`, OpenCode `estimatedCostUsd`). That is now injected as an empty/fromEvent/fold triple, so the shared code stays generic without collapsing the two record schemas into a nullable union. The clone strategy stays per-provider (`cloneSessionForMerge` vs `structuredClone`) rather than being unified on the assumption that the difference is accidental. `usage-provider-contract.ts` is the seam a plugin-contributed usage source will implement. It is deliberately generic over each provider's record types: Claude bills per turn while Codex/OpenCode bill per event, and `cachedInput` is a subset of `input` for the latter but a peer bucket for Claude, so a single normalized record would push nullable handling onto every consumer. No behavior change. Emitted objects are byte-identical, including key insertion order — verified by diffing JSON.stringify of the scan output before and after across mixed models, mixed locations, an inferred-pricing flip, and null vs non-null cost. Persisted field names and schemaVersion are untouched, so caches do not invalidate. * refactor(usage): make the provider contract load-bearing and dedupe worktree refs Follow-up to the aggregation extraction, addressing three review points. `UsageProvider`/`UsageScanResult` were declaration-only, which is the same speculative-interface problem #12077 just deleted 8,900 lines of. They are now implemented by both real providers via `satisfies`, so the seam is typechecked against actual scan functions rather than asserted. The blocker was that codex returns `processedFiles` and opencode returns `processedDatabases`; rather than rename persisted-adjacent fields, the source key is a type parameter, so each provider keeps its own on-disk name and the contract still binds. Verified the constraint bites: swapping the key to 'processedSources' fails typecheck. `schemaVersion` is part of provider identity in the contract, so each provider's SCHEMA_VERSION constant (with its cache-invalidation rationale) moves into the provider module and the store imports it. Values are unchanged (codex 5, opencode 2) and the stores compare them exactly as before, so no cache invalidates. This also keeps store -> provider -> scanner acyclic. `UsageWorktreeRef` collided with the existing export in usage-worktree-metadata (3 fields, no repoId). Two different exported types under one name in src/main is worse than the duplication being removed, so the scan-input type is now `UsageScanWorktreeRef`; usage-worktree-metadata is untouched. `createWorktreeRefs` was triplicated. Codex, OpenCode, and Claude copies are byte-identical apart from the return type name (verified by diff), and all three ref types have the same four fields, so one shared copy replaces all three. This is the only change to claude-usage/. No behavior change: same functions, same arguments, same call order. The store tests' `./scanner` mock still intercepts scanning because the provider captures the mocked binding; their now-inert `createWorktreeRefs` mock key is dropped so it does not read as still mocking something.
pnpm dlx knip@5 downloads and runs whatever the newest 5.x is at invocation time, outside lockfile integrity review — flagged P2 by the v1.4.165-rc.0 release scan. Pin the exact version, matching the [email protected] pattern one line up. Why dlx rather than a devDependency: knip 5.x peer-depends on typescript@^5, and this repo is on typescript 7.0.2 — installed as a devDependency, pnpm resolves knip against TS 7 and knip crashes at module load (verified: same knip against a TS 5 peer runs clean). The dlx sandbox auto-installs knip's own TS 5, which is the environment the original #12077 sweep actually ran in.
…dules (stablyai#12077) * chore(dead-code): drop 2k lines of unreachable exports and orphan modules Ran knip across every build entry (main, preload, renderer, popout, web, cli, relay, workers, forked sidecars, config scripts) and removed what no entry graph can reach. - 11 orphan modules nothing imported, plus one test that only covered them - 159 unused exports/types, with their now-dead helpers, imports and tests Each candidate was verified against dynamic references before deletion. 42 knip hits were false positives and are kept: shared modules consumed by the mobile/ workspace, the src/shared/plugins/** public API, vendored shadcn primitives, and relay wire-protocol constants held for compatibility. Adds knip.json + `pnpm audit:dead-code` so this stays measurable. Verified: pnpm typecheck, pnpm lint, and 2081 tests across the 73 affected test files all pass. * chore(dead-code): move knip config under config/ Root-level additions are blocked by the root directory guard. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
… contract (stablyai#12082) * refactor(usage): share the session/daily fold between Codex and OpenCode The Codex and OpenCode scanners each carried their own byte-identical copy of the ~325-line aggregation pipeline (createEmptySession, the three breakdown folds, finalizeSessions, mergeSessions, mergeDailyAggregates). Two copies means a token-accounting fix — a bucket that double-counts, a merge that drops a breakdown row — lands in one provider and silently not the other. The copies had already started to drift in comments only; the next drift would have been in arithmetic. The providers differ in exactly one dimension: the extra metric folded alongside the token counters (Codex `hasInferredPricing`, OpenCode `estimatedCostUsd`). That is now injected as an empty/fromEvent/fold triple, so the shared code stays generic without collapsing the two record schemas into a nullable union. The clone strategy stays per-provider (`cloneSessionForMerge` vs `structuredClone`) rather than being unified on the assumption that the difference is accidental. `usage-provider-contract.ts` is the seam a plugin-contributed usage source will implement. It is deliberately generic over each provider's record types: Claude bills per turn while Codex/OpenCode bill per event, and `cachedInput` is a subset of `input` for the latter but a peer bucket for Claude, so a single normalized record would push nullable handling onto every consumer. No behavior change. Emitted objects are byte-identical, including key insertion order — verified by diffing JSON.stringify of the scan output before and after across mixed models, mixed locations, an inferred-pricing flip, and null vs non-null cost. Persisted field names and schemaVersion are untouched, so caches do not invalidate. * refactor(usage): make the provider contract load-bearing and dedupe worktree refs Follow-up to the aggregation extraction, addressing three review points. `UsageProvider`/`UsageScanResult` were declaration-only, which is the same speculative-interface problem stablyai#12077 just deleted 8,900 lines of. They are now implemented by both real providers via `satisfies`, so the seam is typechecked against actual scan functions rather than asserted. The blocker was that codex returns `processedFiles` and opencode returns `processedDatabases`; rather than rename persisted-adjacent fields, the source key is a type parameter, so each provider keeps its own on-disk name and the contract still binds. Verified the constraint bites: swapping the key to 'processedSources' fails typecheck. `schemaVersion` is part of provider identity in the contract, so each provider's SCHEMA_VERSION constant (with its cache-invalidation rationale) moves into the provider module and the store imports it. Values are unchanged (codex 5, opencode 2) and the stores compare them exactly as before, so no cache invalidates. This also keeps store -> provider -> scanner acyclic. `UsageWorktreeRef` collided with the existing export in usage-worktree-metadata (3 fields, no repoId). Two different exported types under one name in src/main is worse than the duplication being removed, so the scan-input type is now `UsageScanWorktreeRef`; usage-worktree-metadata is untouched. `createWorktreeRefs` was triplicated. Codex, OpenCode, and Claude copies are byte-identical apart from the return type name (verified by diff), and all three ref types have the same four fields, so one shared copy replaces all three. This is the only change to claude-usage/. No behavior change: same functions, same arguments, same call order. The store tests' `./scanner` mock still intercepts scanning because the provider captures the mocked binding; their now-inert `createWorktreeRefs` mock key is dropped so it does not read as still mocking something.
pnpm dlx knip@5 downloads and runs whatever the newest 5.x is at invocation time, outside lockfile integrity review — flagged P2 by the v1.4.165-rc.0 release scan. Pin the exact version, matching the [email protected] pattern one line up. Why dlx rather than a devDependency: knip 5.x peer-depends on typescript@^5, and this repo is on typescript 7.0.2 — installed as a devDependency, pnpm resolves knip against TS 7 and knip crashes at module load (verified: same knip against a TS 5 peer runs clean). The dlx sandbox auto-installs knip's own TS 5, which is the environment the original stablyai#12077 sweep actually ran in.
What
Ran
knipacross every build entry — main, preload, renderer, popout, web, cli, relay, workers, forked sidecars, config scripts — and removed what no entry graph can reach.146 files changed, +71 / −2,102.
Verification
Every candidate was checked for dynamic references before deletion — IPC channel strings,
window.apibridge keys,import()/require(), worker construction, build config, and themobile/workspace — not just the static import graph.42 of knip's hits were false positives and are kept:
mobile/workspacemergeNativeChatMessages,RelayMovedSchema,toolFilePathsrc/shared/plugins/**)PluginPanelContribution,PluginWorktreeCreatedPayloadContextMenuGroup,SheetFooter,CardActionTIMEOUT_MSinsrc/relay/protocol.tsBrowserErrorCodeAlso deliberately kept: the two
monaco-content-sync*.bench.tsfiles. Knip flags them because nothing imports them, but they're a developer perf tool for a latency-sensitive editor path (pnpm vitest bench), not dead product code.Keeping it measurable
Adds
knip.jsonandpnpm audit:dead-code, following the existingaudit:*script convention. Usespnpm dlxso it adds no dependency.Checks
pnpm typecheck— passes (clean before and after)pnpm lint— passes (full suite incl. reliability gates, max-lines ratchet, localization)pnpm viteston all 73 affected test files — 2,081 passed, 1 skippedknipre-run confirms: unused files 13 → 2, exports 142 → 31, types 59 → 16Note on scope
For context on how much fat is actually here:
jscpdmeasures copy-paste duplication at 0.13%, and this dead code was ~0.1% of the tree. This codebase is not carrying much unreachable weight — it's heavy with live code. A follow-up PR deduplicates the one genuinely large clone (a 264-lineFrameDecodercopied verbatim betweensrc/relay/andsrc/main/ssh/).Made with Orca 🐋