Skip to content

chore(dead-code): drop ~2k lines of unreachable exports and orphan modules - #12077

Merged
nwparker merged 2 commits into
stablyai:mainfrom
nwparker:nwparker/slim-dead-code
Aug 2, 2026
Merged

nwparker merged 2 commits into
stablyai:mainfrom
nwparker:nwparker/slim-dead-code

Conversation

@nwparker

@nwparker nwparker commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

What

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 the one test that only covered them
  • 159 unused exports/types, along with their now-dead helpers, imports, and test cases

146 files changed, +71 / −2,102.

Verification

Every candidate was checked for dynamic references before deletion — IPC channel strings, window.api bridge keys, import()/require(), worker construction, build config, and the mobile/ workspace — not just the static import graph.

42 of knip's hits were false positives and are kept:

Category Example
Consumed by the mobile/ workspace mergeNativeChatMessages, RelayMovedSchema, toolFilePath
Public plugin API (src/shared/plugins/**) PluginPanelContribution, PluginWorktreeCreatedPayload
Vendored shadcn primitives ContextMenuGroup, SheetFooter, CardAction
Wire-protocol compatibility constants TIMEOUT_MS in src/relay/protocol.ts
Agent-facing error-code contract BrowserErrorCode

Also deliberately kept: the two monaco-content-sync*.bench.ts files. 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.json and pnpm audit:dead-code, following the existing audit:* script convention. Uses pnpm dlx so 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 vitest on all 73 affected test files — 2,081 passed, 1 skipped
  • knip re-run confirms: unused files 13 → 2, exports 142 → 31, types 59 → 16

Note on scope

For context on how much fat is actually here: jscpd measures 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-line FrameDecoder copied verbatim between src/relay/ and src/main/ssh/).

Made with Orca 🐋

…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.
@greptile-apps

greptile-apps Bot commented Aug 2, 2026

Copy link
Copy Markdown

Too many files changed for review. (146 files found, 100 file limit)

Bypass the limit by tagging @greptile-apps to review.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a12c999e-4f37-43ac-852e-0cdb186b397b

📥 Commits

Reviewing files that changed from the base of the PR and between 01005cd and 9f3a0fe.

📒 Files selected for processing (2)
  • config/knip.json
  • package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

📝 Walkthrough

Walkthrough

Added a Knip configuration and audit:dead-code package script. Removed unused exports, types, constants, parsers, helpers, compatibility wrappers, and test-only APIs across main, renderer, relay, and shared modules. Updated related imports and mocks. Reworked workspace port handling to support stop-specific scans, runtime-target-aware merging, scan deduplication, and local or remote port termination. Added and retained shared runtime contract exports where required.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing unreachable exports and orphan modules.
Description check ✅ Passed The description clearly covers the change, validation, testing results, Knip configuration, false positives, and scope; it is mostly complete despite different section headings.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
package.json (1)

19-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Pin the Knip analyzer to a locked version.

pnpm dlx knip@5 resolves the knip@5 semver range from the registry rather than executing a package tracked in package.json/pnpm-lock.yaml, so the audit can follow different analyzer code after upstream 5.x releases. Add an exact knip devDependency and run pnpm exec knip during maintenance.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 06271489-2612-46cb-82bc-a69aed3c16f3

📥 Commits

Reviewing files that changed from the base of the PR and between 711491b and 01005cd.

📒 Files selected for processing (146)
  • knip.json
  • package.json
  • src/cli/runtime/environments.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite-worker-protocol.ts
  • src/main/claude-usage/scanner.ts
  • src/main/codex-usage/scanner.ts
  • src/main/computer/macos-native-provider-paths.ts
  • src/main/daemon/terminal-private-mode-tracker.ts
  • src/main/emulator/android/android-input-mapping.ts
  • src/main/emulator/emulator-types.ts
  • src/main/git/git-username.ts
  • src/main/git/repo.ts
  • src/main/github/github-api-repository.ts
  • src/main/github/github-enterprise-repository.ts
  • src/main/github/project-view.ts
  • src/main/github/project-view/internals.ts
  • src/main/gitlab/gl-utils.ts
  • src/main/ipc/feedback-image-attachments.ts
  • src/main/ipc/parcel-watcher-host-subscriptions.ts
  • src/main/ipc/parcel-watcher-process.ts
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/main/ipc/worktree-change-invalidators.ts
  • src/main/observability/index.ts
  • src/main/observability/instrumentation.ts
  • src/main/observability/redactor.ts
  • src/main/pi/prefill-extension-source.ts
  • src/main/pi/titlebar-extension-service.ts
  • src/main/plugins/plugin-enablement.ts
  • src/main/providers/pty-process-list-admission.ts
  • src/main/providers/types.ts
  • src/main/rate-limits/grok-auth.ts
  • src/main/runtime/orca-runtime-emulator.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/orchestration/groups.ts
  • src/main/runtime/rpc/schemas.ts
  • src/main/shell-ready-marker-scanner.ts
  • src/main/ssh/relay-protocol.ts
  • src/main/ssh/sftp-namespace-resolution.ts
  • src/main/ssh/sftp-upload.ts
  • src/main/ssh/ssh-pty-consumer-session.ts
  • src/main/ssh/ssh-relay-session-managed-hooks.test.ts
  • src/main/ssh/ssh-relay-session.test.ts
  • src/main/system-fonts.ts
  • src/main/telemetry/client.ts
  • src/relay/fs-handler-file-read.ts
  • src/renderer/src/components/automations/automation-page-parts.tsx
  • src/renderer/src/components/browser-pane/browser-automation-visibility.ts
  • src/renderer/src/components/browser-pane/browser-page-zoom.ts
  • src/renderer/src/components/dashboard/useDashboardData.ts
  • src/renderer/src/components/editor/NotesSendMenu.test.tsx
  • src/renderer/src/components/editor/ReviewNotesSendMenuContent.test.tsx
  • src/renderer/src/components/editor/markdown-round-trip.ts
  • src/renderer/src/components/emulator-pane/emulator-keyboard-paste.ts
  • src/renderer/src/components/emulator-pane/emulator-pane-types.ts
  • src/renderer/src/components/github-project/column-widths.ts
  • src/renderer/src/components/github/github-issue-comment-helpers.ts
  • src/renderer/src/components/linear-issue-workspace-text.ts
  • src/renderer/src/components/native-chat/native-chat-composer-state.ts
  • src/renderer/src/components/onboarding/use-onboarding-flow.ts
  • src/renderer/src/components/repo/repo-icon.tsx
  • src/renderer/src/components/right-sidebar/CreateHostedReviewComposer.tsx
  • src/renderer/src/components/right-sidebar/commit-failure-dialog-state.ts
  • src/renderer/src/components/right-sidebar/file-explorer-operation-owner.ts
  • src/renderer/src/components/right-sidebar/file-explorer-runtime-owner-boundary.test.ts
  • src/renderer/src/components/right-sidebar/push-failure-summary.ts
  • src/renderer/src/components/right-sidebar/source-control-active-open-file-keys.ts
  • src/renderer/src/components/right-sidebar/source-control-ai-commit-failure-launch.test.ts
  • src/renderer/src/components/right-sidebar/source-control-ai-commit-failure-launch.ts
  • src/renderer/src/components/right-sidebar/source-control-ai-push-failure-launch.ts
  • src/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.ts
  • src/renderer/src/components/right-sidebar/source-control-primary-action-types.ts
  • src/renderer/src/components/settings/SettingsConstants.ts
  • src/renderer/src/components/settings/general-search.ts
  • src/renderer/src/components/settings/terminal-windows-search.ts
  • src/renderer/src/components/sidebar/WorktreeCardHelpers.tsx
  • src/renderer/src/components/sidebar/WorktreeCardPorts.tsx
  • src/renderer/src/components/sidebar/create-project-defaults.ts
  • src/renderer/src/components/sidebar/project-header-drop.ts
  • src/renderer/src/components/sidebar/sidebar-host-options.ts
  • src/renderer/src/components/sidebar/sidebar-nav-controls.tsx
  • src/renderer/src/components/sidebar/workspace-kanban-card-drag-preview-dom.ts
  • src/renderer/src/components/tab-bar/shell-icons.tsx
  • src/renderer/src/components/tab-bar/tab-create-entry-path-validation.ts
  • src/renderer/src/components/tab-group/tab-drag-context.tsx
  • src/renderer/src/components/terminal-pane/pty-delivery-interest.ts
  • src/renderer/src/components/terminal-pane/pty-pre-handler-buffer.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-delivery-gate.ts
  • src/renderer/src/components/terminal/terminal-tab-actions.ts
  • src/renderer/src/constants/terminal.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.test.ts
  • src/renderer/src/hooks/useIssueMetadata.ts
  • src/renderer/src/hooks/useShortcutLabel.ts
  • src/renderer/src/lib/active-agent-note-send.ts
  • src/renderer/src/lib/active-agent-note-target.ts
  • src/renderer/src/lib/agent-hibernation-coordinator.ts
  • src/renderer/src/lib/agent-paste-draft.ts
  • src/renderer/src/lib/crash-diagnostics.test.ts
  • src/renderer/src/lib/crash-diagnostics.ts
  • src/renderer/src/lib/ensure-simulator-tab.ts
  • src/renderer/src/lib/keyboard-layout/input-source-id.ts
  • src/renderer/src/lib/keyboard-layout/option-as-alt-probe.ts
  • src/renderer/src/lib/open-mobile-emulator-tab.test.ts
  • src/renderer/src/lib/repo-slug-index.ts
  • src/renderer/src/lib/setup-script-status.ts
  • src/renderer/src/lib/workspace-port-actions.ts
  • src/renderer/src/store/slices/runtime-detected-agents.ts
  • src/shared/agent-session-host-authority.ts
  • src/shared/agent-session-option-catalog.ts
  • src/shared/commit-message-generation.ts
  • src/shared/custom-pet-media-limits.ts
  • src/shared/daemon-audit-eligibility.ts
  • src/shared/daemon-lifecycle-telemetry.ts
  • src/shared/ephemeral-vm-recipes.ts
  • src/shared/ephemeral-vm-runtimes.ts
  • src/shared/folder-workspaces.ts
  • src/shared/hermes-run-output-limits.ts
  • src/shared/hermes-run-ref-retention.ts
  • src/shared/hosted-review.ts
  • src/shared/html-to-pdf-memory-limit.ts
  • src/shared/left-sidebar-appearance.ts
  • src/shared/linear-agent-access.ts
  • src/shared/linux-proc-port-scan-limits.ts
  • src/shared/native-file-drop.ts
  • src/shared/persisted-state-file-bounds.ts
  • src/shared/pr-refresh-memory-limits.ts
  • src/shared/pty-source-credit-contract.ts
  • src/shared/relay-json-admission.ts
  • src/shared/remote-runtime-memory-limits.ts
  • src/shared/remote-runtime-shared-control-state.ts
  • src/shared/remote-workspace-types.ts
  • src/shared/runtime-bootstrap.ts
  • src/shared/runtime-environments.ts
  • src/shared/runtime-types.ts
  • src/shared/serve-update-handoff.ts
  • src/shared/source-control-create-review-intent.ts
  • src/shared/ssh-retained-payload-admission.ts
  • src/shared/task-source-context.ts
  • src/shared/telemetry-events.ts
  • src/shared/terminal-custom-themes.ts
  • src/shared/terminal-scrollback-policy.ts
  • src/shared/terminal-size-limits.ts
  • src/shared/terminal-title-display.ts
  • src/shared/terminal-title-status.ts
  • src/shared/work-items.ts
  • src/shared/workspace-scope.ts
  • src/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

Comment thread config/knip.json
],
"project": ["src/**/*.{ts,tsx}", "config/scripts/**/*.{mjs,cjs,js,ts}", "build-plugins/**/*.ts"],
"ignore": ["mobile/**", "out/**", "dist/**", "node_modules/**", "resources/**"],
"ignoreDependencies": ["electron", "@types/*"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

node -p "new RegExp('`@types/`*').test('`@types/node`')"
pnpm audit:dead-code -- --include dependencies

Repository: 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'));
JS

Repository: 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:


🏁 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));
JS

Repository: 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);
JS

Repository: 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])
PY

Repository: 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.

Suggested change
"ignoreDependencies": ["electron", "@types/*"],
"ignoreDependencies": ["electron", "^`@types/`.+$"],

Comment thread config/knip.json
"ignore": ["mobile/**", "out/**", "dist/**", "node_modules/**", "resources/**"],
"ignoreDependencies": ["electron", "@types/*"],
"ignoreExportsUsedInFile": true,
"includeEntryExports": false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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-exports

Repository: 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 || true

Repository: 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]>
@nwparker
nwparker merged commit 73c5009 into stablyai:main Aug 2, 2026
48 checks passed
nwparker added a commit that referenced this pull request Aug 2, 2026
… 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.
brennanb2025 added a commit that referenced this pull request Aug 3, 2026
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.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… 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.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant