split cli/utils.ts into focused modules and add shared logger/db helpers#14210
Conversation
Replace the monolithic cli/utils.ts with four focused modules: - cli/output.ts: writeOutput, shouldOutputJson, runRead (8 consumers) - cli/gateway-client.ts: gatewayGet, gatewayPost, toQueryString, asRecord - cli/logger.ts: shared CLI logger instance + getCliLogger re-export (14 consumers) - cli/db.ts: initializeDb re-export from memory/db (7 consumers) Update all 21 command files to import from the new modules instead of the old utils.ts and ../../util/logger.js / ../../memory/db.js paths. Co-Authored-By: Claude <noreply@anthropic.com>
| return value as Record<string, unknown>; | ||
| } |
There was a problem hiding this comment.
🟡 Dead code (asRecord) retained in gateway-client.ts, violating AGENTS.md dead-code removal rule
The asRecord function is exported from assistant/src/cli/gateway-client.ts:9-14 but is never imported by any file in the codebase (verified via grep). It was carried over from the old utils.ts during this refactoring split. The root AGENTS.md mandates: "Proactively remove unused code during every change. Remove code your change makes unused, clean up adjacent dead code... Ask: 'After my change, is there any code that nothing calls, imports, or references?' If yes, delete it."
(Refers to lines 9-14)
Was this helpful? React with 👍 or 👎 to provide feedback.
| import { gatewayGet, toQueryString } from "../gateway-client.js"; | ||
| import { runRead } from "../output.js"; |
There was a problem hiding this comment.
🚩 channels.ts continues to proxy through gateway HTTP API (pre-existing)
The channels.ts command imports gatewayGet from ../gateway-client.js and calls the gateway HTTP API (/v1/channels/readiness) rather than calling the service/store layer directly. The assistant/src/cli/AGENTS.md rule "Service calls — no gateway proxying" says CLI commands must call the service layer directly. However, this is pre-existing behavior — the PR only changed the import path from ../utils.js to ../gateway-client.js. Channel readiness may legitimately require the gateway to be running (the help text says "The assistant must be running — channel status is read from the live gateway"), so this may be an intentional exception. Worth reviewing whether a direct service call is feasible here.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
cli/utils.tsintocli/output.ts(output formatting),cli/gateway-client.ts(gateway HTTP helpers),cli/logger.ts(shared CLI logger), andcli/db.ts(shared db init)const log = getCliLogger("cli")boilerplate across 13 files and shortening../../memory/db.jsimports in 6 filescli/utils.tsOriginal prompt
Split utils.ts into output.ts and gateway-client.ts, add shared logger.ts and db.ts helpers
🤖 Generated with Claude Code