Skip to content

Commit 1cbc0f4

Browse files
authored
deps(knip): enable production mode and remove dead code (Zoo-Code-Org#527)
* deps(knip): configuring knip and removing dead code * deps(knip): removing unused exports and deps * deps(knip): address warnings introduced since branch was cut * chore(knip): enable production mode and remove confirmed dead code * fix: address PR review feedback * chore(knip): enforce production analysis and verify CI guardrails * fix(knip): exclude visual fixtures from production analysis
1 parent c00676c commit 1cbc0f4

121 files changed

Lines changed: 475 additions & 4372 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/cli-release.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,11 @@ jobs:
9696
type: 'module',
9797
dependencies: {
9898
'@inkjs/ui': pkg.dependencies['@inkjs/ui'],
99-
'@trpc/client': pkg.dependencies['@trpc/client'],
10099
'commander': pkg.dependencies.commander,
101100
'fuzzysort': pkg.dependencies.fuzzysort,
102101
'ink': pkg.dependencies.ink,
103102
'p-wait-for': pkg.dependencies['p-wait-for'],
104103
'react': pkg.dependencies.react,
105-
'superjson': pkg.dependencies.superjson,
106104
'zustand': pkg.dependencies.zustand
107105
}
108106
};

‎.github/workflows/code-qa.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ jobs:
7676
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7777
- name: Setup Node.js and pnpm
7878
uses: ./.github/actions/setup-node-pnpm
79+
- name: Verify Knip guardrails
80+
run: pnpm test:knip-policy
7981
- name: Run knip checks
8082
run: pnpm knip
83+
- name: Run production Knip checks
84+
run: pnpm knip:production
8185

8286
compile:
8387
runs-on: ubuntu-latest

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pnpm install
119119
- Follow the ESLint and TypeScript best practices.
120120
- Write clear, descriptive commits that reference issues (for example, `Fixes #123`). Follow the [Writing Style](#writing-style).
121121
- Test your change fully (`npm test`).
122+
- Run both dead-code checks: `pnpm knip` and `pnpm knip:production`. See [Dead-code checks before review](docs/development-quality-checks.md) for findings, exceptions, and verification.
122123
- Rebase onto the latest `main` branch before you submit.
123124

124125
### Submitting a Pull Request

‎apps/cli/package.json‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,21 @@
2626
"@roo-code/core": "workspace:^",
2727
"@roo-code/types": "workspace:^",
2828
"@roo-code/vscode-shim": "workspace:^",
29-
"@trpc/client": "^11.18.0",
3029
"@vscode/ripgrep": "^1.15.9",
3130
"commander": "^12.1.0",
32-
"execa": "^9.5.2",
3331
"fuzzysort": "^3.1.0",
3432
"ink": "^6.6.0",
3533
"p-wait-for": "^5.0.2",
3634
"react": "^19.1.0",
37-
"superjson": "^2.2.6",
3835
"zustand": "^5.0.14"
3936
},
4037
"devDependencies": {
4138
"@roo-code/config-eslint": "workspace:^",
42-
"@trpc/server": "11.18.0",
4339
"@roo-code/config-typescript": "workspace:^",
4440
"@types/node": "22.20.1",
4541
"@types/react": "18.3.31",
4642
"@vitest/coverage-v8": "4.1.9",
43+
"execa": "^9.5.2",
4744
"ink-testing-library": "4.0.0",
4845
"rimraf": "6.0.1",
4946
"tsup": "8.5.1",

‎apps/cli/scripts/build.sh‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,11 @@ create_tarball() {
151151
type: 'module',
152152
dependencies: {
153153
'@inkjs/ui': pkg.dependencies['@inkjs/ui'],
154-
'@trpc/client': pkg.dependencies['@trpc/client'],
155154
'commander': pkg.dependencies.commander,
156155
'fuzzysort': pkg.dependencies.fuzzysort,
157156
'ink': pkg.dependencies.ink,
158157
'p-wait-for': pkg.dependencies['p-wait-for'],
159158
'react': pkg.dependencies.react,
160-
'superjson': pkg.dependencies.superjson,
161159
'zustand': pkg.dependencies.zustand
162160
}
163161
};

‎apps/cli/src/agent/__tests__/extension-host.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function createTestHost({
3535
}: Partial<ExtensionHostOptions> = {}): ExtensionHost {
3636
return new ExtensionHost({
3737
mode,
38-
user: null,
3938
provider,
4039
model,
4140
workspacePath: "/test/workspace",
@@ -112,7 +111,6 @@ describe("ExtensionHost", () => {
112111
mode: "code",
113112
workspacePath: "/my/workspace",
114113
extensionPath: "/my/extension",
115-
user: null,
116114
apiKey: "test-key",
117115
provider: providerIdentifiers.openrouter,
118116
model: "test-model",

‎apps/cli/src/agent/agent-state.ts‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -436,28 +436,3 @@ export function detectAgentState(messages: ClineMessage[]): AgentStateInfo {
436436
description: getStateDescription(AgentLoopState.RUNNING),
437437
}
438438
}
439-
440-
/**
441-
* Quick check: Is the agent waiting for user input?
442-
*
443-
* This is a convenience function for simple use cases where you just need
444-
* to know if user action is required.
445-
*/
446-
export function isAgentWaitingForInput(messages: ClineMessage[]): boolean {
447-
return detectAgentState(messages).isWaitingForInput
448-
}
449-
450-
/**
451-
* Quick check: Is the agent actively running (not waiting)?
452-
*/
453-
export function isAgentRunning(messages: ClineMessage[]): boolean {
454-
const state = detectAgentState(messages)
455-
return state.isRunning && !state.isWaitingForInput
456-
}
457-
458-
/**
459-
* Quick check: Is content currently streaming?
460-
*/
461-
export function isContentStreaming(messages: ClineMessage[]): boolean {
462-
return detectAgentState(messages).isStreaming
463-
}

‎apps/cli/src/agent/extension-client.ts‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -539,21 +539,10 @@ export class ExtensionClient {
539539
// Factory Functions
540540
// =============================================================================
541541

542-
/**
543-
* Create a new ExtensionClient instance.
544-
*
545-
* This is a convenience function that creates a client with default settings.
546-
*
547-
* @param sendMessage - Function to send messages to the extension
548-
* @returns A new ExtensionClient instance
549-
*/
550-
export function createClient(sendMessage: (message: WebviewMessage) => void): ExtensionClient {
551-
return new ExtensionClient({ sendMessage })
552-
}
553-
554542
/**
555543
* Create a mock client for testing.
556544
*
545+
* @internal
557546
* The mock client captures all sent messages for verification.
558547
*
559548
* @returns An object with the client and captured messages

‎apps/cli/src/agent/extension-host.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { createVSCodeAPI, IExtensionHost, ExtensionHostEventMap, setRuntimeConfi
2727
import { DebugLogger, setDebugLogEnabled } from "@roo-code/core/cli"
2828

2929
import { DEFAULT_FLAGS, type SupportedProvider } from "@/types/index.js"
30-
import type { User } from "@/lib/sdk/index.js"
3130
import { getProviderSettings } from "@/lib/utils/provider.js"
3231
import { createEphemeralStorageDir } from "@/lib/storage/index.js"
3332

@@ -67,7 +66,6 @@ export interface ExtensionHostOptions {
6766
mode: string
6867
reasoningEffort?: ReasoningEffortExtended | "unspecified" | "disabled"
6968
consecutiveMistakeLimit?: number
70-
user: User | null
7169
provider: SupportedProvider
7270
apiKey?: string
7371
model: string

‎apps/cli/src/agent/message-processor.ts‎

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -404,29 +404,6 @@ export class MessageProcessor {
404404
// Message Validation Helpers
405405
// =============================================================================
406406

407-
/**
408-
* Check if a message is a valid ClineMessage.
409-
* Useful for validating messages before processing.
410-
*/
411-
export function isValidClineMessage(message: unknown): message is ClineMessage {
412-
if (!message || typeof message !== "object") {
413-
return false
414-
}
415-
416-
const msg = message as Record<string, unknown>
417-
418-
// Required fields
419-
if (typeof msg.ts !== "number") {
420-
return false
421-
}
422-
423-
if (msg.type !== "ask" && msg.type !== "say") {
424-
return false
425-
}
426-
427-
return true
428-
}
429-
430407
/**
431408
* Check if a message is a valid ExtensionMessage.
432409
*/
@@ -464,19 +441,3 @@ export function parseExtensionMessage(json: string): ExtensionMessage | undefine
464441
return undefined
465442
}
466443
}
467-
468-
/**
469-
* Parse the text field of an api_req_started message.
470-
* Returns undefined if parsing fails or text is not present.
471-
*/
472-
export function parseApiReqStartedText(message: ClineMessage): { cost?: number } | undefined {
473-
if (message.say !== "api_req_started" || !message.text) {
474-
return undefined
475-
}
476-
477-
try {
478-
return JSON.parse(message.text)
479-
} catch {
480-
return undefined
481-
}
482-
}

0 commit comments

Comments
 (0)