refactor: move commands barrel to kilocode/, restore index.ts upstream-style chain

This commit is contained in:
kiloconnect[bot]
2026-04-07 14:18:18 +00:00
parent 8fff17c46a
commit 44df3a0dc9
6 changed files with 95 additions and 77 deletions
-52
View File
@@ -1,52 +0,0 @@
// kilocode_change - new file
// Command barrel: exports the list of CommandModules with no side effects.
// Keeping this separate from index.ts allows help.ts and generate-cli-docs.ts
// to import commands for introspection without triggering the CLI startup code
// (middleware, telemetry, migrations, etc.) that lives in index.ts.
import { AcpCommand } from "./cmd/acp"
import { McpCommand } from "./cmd/mcp"
import { TuiThreadCommand } from "./cmd/tui/thread"
import { AttachCommand } from "./cmd/tui/attach"
import { RunCommand } from "./cmd/run"
import { GenerateCommand } from "./cmd/generate"
import { DebugCommand } from "./cmd/debug"
import { AuthCommand } from "./cmd/auth"
import { AgentCommand } from "./cmd/agent"
import { UpgradeCommand } from "./cmd/upgrade"
import { UninstallCommand } from "./cmd/uninstall"
import { ServeCommand } from "./cmd/serve"
import { WebCommand } from "./cmd/web"
import { ModelsCommand } from "./cmd/models"
import { StatsCommand } from "./cmd/stats"
import { ExportCommand } from "./cmd/export"
import { ImportCommand } from "./cmd/import"
import { PrCommand } from "./cmd/pr"
import { SessionCommand } from "./cmd/session"
import { RemoteCommand } from "./cmd/remote" // kilocode_change
import { DbCommand } from "./cmd/db"
import { HelpCommand } from "../kilocode/help-command" // kilocode_change
export const commands = [
AcpCommand,
McpCommand,
TuiThreadCommand,
AttachCommand,
RunCommand,
GenerateCommand,
DebugCommand,
AuthCommand,
AgentCommand,
UpgradeCommand,
UninstallCommand,
ServeCommand,
WebCommand,
ModelsCommand,
StatsCommand,
ExportCommand,
ImportCommand,
PrCommand,
SessionCommand,
RemoteCommand, // kilocode_change
DbCommand,
HelpCommand, // kilocode_change
]
+45 -8
View File
@@ -1,15 +1,36 @@
import yargs from "yargs"
import { hideBin } from "yargs/helpers"
import { commands } from "./cli/commands" // kilocode_change
import { RunCommand } from "./cli/cmd/run"
import { GenerateCommand } from "./cli/cmd/generate"
import { Log } from "./util/log"
import { AuthCommand } from "./cli/cmd/auth"
import { AgentCommand } from "./cli/cmd/agent"
import { UpgradeCommand } from "./cli/cmd/upgrade"
import { UninstallCommand } from "./cli/cmd/uninstall"
import { ModelsCommand } from "./cli/cmd/models"
import { UI } from "./cli/ui"
import { Installation } from "./installation"
import { NamedError } from "@opencode-ai/util/error"
import { FormatError } from "./cli/error"
import { ServeCommand } from "./cli/cmd/serve"
import { WorkspaceServeCommand } from "./cli/cmd/workspace-serve"
import { Filesystem } from "./util/filesystem"
import { DebugCommand } from "./cli/cmd/debug"
import { StatsCommand } from "./cli/cmd/stats"
import { McpCommand } from "./cli/cmd/mcp"
// import { GithubCommand } from "./cli/cmd/github" // kilocode_change
import { ExportCommand } from "./cli/cmd/export"
import { ImportCommand } from "./cli/cmd/import"
import { AttachCommand } from "./cli/cmd/tui/attach"
import { TuiThreadCommand } from "./cli/cmd/tui/thread"
import { AcpCommand } from "./cli/cmd/acp"
import { EOL } from "os"
// import { WebCommand } from "./cli/cmd/web" // kilocode_change (Disabled unsupported opencode web UI)
import { PrCommand } from "./cli/cmd/pr"
import { SessionCommand } from "./cli/cmd/session"
import { RemoteCommand } from "./cli/cmd/remote" // kilocode_change
import { DbCommand } from "./cli/cmd/db"
import { HelpCommand } from "./kilocode/help-command" // kilocode_change
// kilocode_change start - Import telemetry, instance disposal, and legacy migration
import { Telemetry } from "@kilocode/kilo-telemetry"
@@ -154,13 +175,29 @@ let cli = yargs(hideBin(process.argv))
})
.usage("\n" + UI.logo())
.completion("completion", "generate shell completion script")
// kilocode_change start - use commands barrel
for (const command of commands) {
cli.command(command as any)
}
// kilocode_change end
// .command(GithubCommand) // kilocode_change (Disabled until backend is ready)
.command(AcpCommand)
.command(McpCommand)
.command(TuiThreadCommand)
.command(AttachCommand)
.command(RunCommand)
.command(GenerateCommand)
.command(DebugCommand)
.command(AuthCommand)
.command(AgentCommand)
.command(UpgradeCommand)
.command(UninstallCommand)
.command(ServeCommand)
// .command(WebCommand) // kilocode_change (Disabled unsupported opencode web UI)
.command(ModelsCommand)
.command(StatsCommand)
.command(ExportCommand)
.command(ImportCommand)
// .command(GithubCommand) // kilocode_change (Disabled until backend is ready)
.command(PrCommand)
.command(SessionCommand)
.command(RemoteCommand) // kilocode_change
.command(DbCommand)
.command(HelpCommand) // kilocode_change
if (Installation.isLocal()) {
cli = cli.command(WorkspaceServeCommand as any)
@@ -0,0 +1,49 @@
// All CommandModules in one place so help.ts and generate-cli-docs.ts can
// introspect them without importing index.ts (which has startup side effects).
// When upstream adds a new command to index.ts, add it here too.
import type { CommandModule } from "yargs"
import { AcpCommand } from "../cli/cmd/acp"
import { McpCommand } from "../cli/cmd/mcp"
import { TuiThreadCommand } from "../cli/cmd/tui/thread"
import { AttachCommand } from "../cli/cmd/tui/attach"
import { RunCommand } from "../cli/cmd/run"
import { GenerateCommand } from "../cli/cmd/generate"
import { DebugCommand } from "../cli/cmd/debug"
import { AuthCommand } from "../cli/cmd/auth"
import { AgentCommand } from "../cli/cmd/agent"
import { UpgradeCommand } from "../cli/cmd/upgrade"
import { UninstallCommand } from "../cli/cmd/uninstall"
import { ServeCommand } from "../cli/cmd/serve"
import { ModelsCommand } from "../cli/cmd/models"
import { StatsCommand } from "../cli/cmd/stats"
import { ExportCommand } from "../cli/cmd/export"
import { ImportCommand } from "../cli/cmd/import"
import { PrCommand } from "../cli/cmd/pr"
import { SessionCommand } from "../cli/cmd/session"
import { RemoteCommand } from "../cli/cmd/remote"
import { DbCommand } from "../cli/cmd/db"
import { HelpCommand } from "./help-command"
export const commands: CommandModule<any, any>[] = [
AcpCommand,
McpCommand,
TuiThreadCommand,
AttachCommand,
RunCommand,
GenerateCommand,
DebugCommand,
AuthCommand,
AgentCommand,
UpgradeCommand,
UninstallCommand,
ServeCommand,
ModelsCommand,
StatsCommand,
ExportCommand,
ImportCommand,
PrCommand,
SessionCommand,
RemoteCommand,
DbCommand,
HelpCommand,
]
+1 -1
View File
@@ -167,7 +167,7 @@ function formatText(
}
async function loadCommands(): Promise<Cmd[]> {
const { commands } = await import("../cli/commands")
const { commands } = await import("./commands")
return commands as Cmd[]
}