The open source coding agent.
TypeScript
fix(cli): add help text to debug command and subcommands (#7328)
Sercan Sagmanadae0d185340
diff --git a/packages/opencode/src/cli/cmd/debug/agent.ts b/packages/opencode/src/cli/cmd/debug/agent.tsindex 6bd04a0eecb..ec5ef0c437d 100644--- a/packages/opencode/src/cli/cmd/debug/agent.ts+++ b/packages/opencode/src/cli/cmd/debug/agent.ts@@ -6,6 +6,7 @@ import { cmd } from "../cmd"export const AgentCommand = cmd({command: "agent <name>",+ describe: "show agent configuration details",builder: (yargs) =>yargs.positional("name", {type: "string",diff --git a/packages/opencode/src/cli/cmd/debug/config.ts b/packages/opencode/src/cli/cmd/debug/config.tsindex aafcf04697e..af536f93ceb 100644--- a/packages/opencode/src/cli/cmd/debug/config.ts+++ b/packages/opencode/src/cli/cmd/debug/config.ts@@ -5,6 +5,7 @@ import { cmd } from "../cmd"export const ConfigCommand = cmd({command: "config",+ describe: "show resolved configuration",builder: (yargs) => yargs,async handler() {await bootstrap(process.cwd(), async () => {diff --git a/packages/opencode/src/cli/cmd/debug/file.ts b/packages/opencode/src/cli/cmd/debug/file.tsindex 51196614ce1..d3136952bc5 100644--- a/packages/opencode/src/cli/cmd/debug/file.ts+++ b/packages/opencode/src/cli/cmd/debug/file.ts@@ -6,6 +6,7 @@ import { Ripgrep } from "@/file/ripgrep"const FileSearchCommand = cmd({command: "search <query>",+ describe: "search files by query",builder: (yargs) =>yargs.positional("query", {type: "string",@@ -22,6 +23,7 @@ const FileSearchCommand = cmd({const FileReadCommand = cmd({command: "read <path>",+ describe: "read file contents as JSON",builder: (yargs) =>yargs.positional("path", {type: "string",@@ -38,6 +40,7 @@ const FileReadCommand = cmd({const FileStatusCommand = cmd({command: "status",+ describe: "show file status information",builder: (yargs) => yargs,async handler() {await bootstrap(process.cwd(), async () => {@@ -49,6 +52,7 @@ const FileStatusCommand = cmd({const FileListCommand = cmd({command: "list <path>",+ describe: "list files in a directory",builder: (yargs) =>yargs.positional("path", {type: "string",@@ -65,6 +69,7 @@ const FileListCommand = cmd({const FileTreeCommand = cmd({command: "tree [dir]",+ describe: "show directory tree",builder: (yargs) =>yargs.positional("dir", {type: "string",@@ -79,6 +84,7 @@ const FileTreeCommand = cmd({export const FileCommand = cmd({command: "file",+ describe: "file system debugging utilities",builder: (yargs) =>yargs.command(FileReadCommand)diff --git a/packages/opencode/src/cli/cmd/debug/index.ts b/packages/opencode/src/cli/cmd/debug/index.tsindex 789c726ccec..8da6ff55937 100644--- a/packages/opencode/src/cli/cmd/debug/index.ts+++ b/packages/opencode/src/cli/cmd/debug/index.ts@@ -12,6 +12,7 @@ import { AgentCommand } from "./agent"export const DebugCommand = cmd({command: "debug",+ describe: "debugging and troubleshooting tools",builder: (yargs) =>yargs.command(ConfigCommand)@@ -25,6 +26,7 @@ export const DebugCommand = cmd({.command(PathsCommand).command({command: "wait",+ describe: "wait indefinitely (for debugging)",async handler() {await bootstrap(process.cwd(), async () => {await new Promise((resolve) => setTimeout(resolve, 1_000 * 60 * 60 * 24))@@ -37,6 +39,7 @@ export const DebugCommand = cmd({const PathsCommand = cmd({command: "paths",+ describe: "show global paths (data, config, cache, state)",handler() {for (const [key, value] of Object.entries(Global.Path)) {console.log(key.padEnd(10), value)diff --git a/packages/opencode/src/cli/cmd/debug/lsp.ts b/packages/opencode/src/cli/cmd/debug/lsp.tsindex 97cb1a0f3bd..d83c4ed8a43 100644--- a/packages/opencode/src/cli/cmd/debug/lsp.ts+++ b/packages/opencode/src/cli/cmd/debug/lsp.ts@@ -6,6 +6,7 @@ import { EOL } from "os"export const LSPCommand = cmd({command: "lsp",+ describe: "LSP debugging utilities",builder: (yargs) =>yargs.command(DiagnosticsCommand).command(SymbolsCommand).command(DocumentSymbolsCommand).demandCommand(),async handler() {},@@ -13,6 +14,7 @@ export const LSPCommand = cmd({const DiagnosticsCommand = cmd({command: "diagnostics <file>",+ describe: "get diagnostics for a file",builder: (yargs) => yargs.positional("file", { type: "string", demandOption: true }),async handler(args) {await bootstrap(process.cwd(), async () => {@@ -25,6 +27,7 @@ const DiagnosticsCommand = cmd({export const SymbolsCommand = cmd({command: "symbols <query>",+ describe: "search workspace symbols",builder: (yargs) => yargs.positional("query", { type: "string", demandOption: true }),async handler(args) {await bootstrap(process.cwd(), async () => {@@ -37,6 +40,7 @@ export const SymbolsCommand = cmd({export const DocumentSymbolsCommand = cmd({command: "document-symbols <uri>",+ describe: "get symbols from a document",builder: (yargs) => yargs.positional("uri", { type: "string", demandOption: true }),async handler(args) {await bootstrap(process.cwd(), async () => {diff --git a/packages/opencode/src/cli/cmd/debug/ripgrep.ts b/packages/opencode/src/cli/cmd/debug/ripgrep.tsindex 4c18bce90c9..a4cebc5b8fa 100644--- a/packages/opencode/src/cli/cmd/debug/ripgrep.ts+++ b/packages/opencode/src/cli/cmd/debug/ripgrep.ts@@ -6,12 +6,14 @@ import { cmd } from "../cmd"export const RipgrepCommand = cmd({command: "rg",+ describe: "ripgrep debugging utilities",builder: (yargs) => yargs.command(TreeCommand).command(FilesCommand).command(SearchCommand).demandCommand(),async handler() {},})const TreeCommand = cmd({command: "tree",+ describe: "show file tree using ripgrep",builder: (yargs) =>yargs.option("limit", {type: "number",@@ -25,6 +27,7 @@ const TreeCommand = cmd({const FilesCommand = cmd({command: "files",+ describe: "list files using ripgrep",builder: (yargs) =>yargs.option("query", {@@ -56,6 +59,7 @@ const FilesCommand = cmd({const SearchCommand = cmd({command: "search <pattern>",+ describe: "search file contents using ripgrep",builder: (yargs) =>yargs.positional("pattern", {diff --git a/packages/opencode/src/cli/cmd/debug/scrap.ts b/packages/opencode/src/cli/cmd/debug/scrap.tsindex 3580aba9097..f4b96e883a6 100644--- a/packages/opencode/src/cli/cmd/debug/scrap.ts+++ b/packages/opencode/src/cli/cmd/debug/scrap.ts@@ -5,6 +5,7 @@ import { cmd } from "../cmd"export const ScrapCommand = cmd({command: "scrap",+ describe: "list all known projects",builder: (yargs) => yargs,async handler() {const timer = Log.Default.time("scrap")diff --git a/packages/opencode/src/cli/cmd/debug/skill.ts b/packages/opencode/src/cli/cmd/debug/skill.tsindex 8079b688eab..ebe3df1808e 100644--- a/packages/opencode/src/cli/cmd/debug/skill.ts+++ b/packages/opencode/src/cli/cmd/debug/skill.ts@@ -5,6 +5,7 @@ import { cmd } from "../cmd"export const SkillCommand = cmd({command: "skill",+ describe: "list all available skills",builder: (yargs) => yargs,async handler() {await bootstrap(process.cwd(), async () => {diff --git a/packages/opencode/src/cli/cmd/debug/snapshot.ts b/packages/opencode/src/cli/cmd/debug/snapshot.tsindex 1849fe2700a..4a409dc54e1 100644--- a/packages/opencode/src/cli/cmd/debug/snapshot.ts+++ b/packages/opencode/src/cli/cmd/debug/snapshot.ts@@ -4,12 +4,14 @@ import { cmd } from "../cmd"export const SnapshotCommand = cmd({command: "snapshot",+ describe: "snapshot debugging utilities",builder: (yargs) => yargs.command(TrackCommand).command(PatchCommand).command(DiffCommand).demandCommand(),async handler() {},})const TrackCommand = cmd({command: "track",+ describe: "track current snapshot state",async handler() {await bootstrap(process.cwd(), async () => {console.log(await Snapshot.track())@@ -19,6 +21,7 @@ const TrackCommand = cmd({const PatchCommand = cmd({command: "patch <hash>",+ describe: "show patch for a snapshot hash",builder: (yargs) =>yargs.positional("hash", {type: "string",@@ -34,6 +37,7 @@ const PatchCommand = cmd({const DiffCommand = cmd({command: "diff <hash>",+ describe: "show diff for a snapshot hash",builder: (yargs) =>yargs.positional("hash", {type: "string",diff --git a/packages/opencode/src/cli/cmd/web.ts b/packages/opencode/src/cli/cmd/web.tsindex fb32472d7ab..e2ecc1187d3 100644--- a/packages/opencode/src/cli/cmd/web.ts+++ b/packages/opencode/src/cli/cmd/web.ts@@ -30,7 +30,7 @@ function getNetworkIPs() {export const WebCommand = cmd({command: "web",builder: (yargs) => withNetworkOptions(yargs),- describe: "starts a headless opencode server",+ describe: "start opencode server and open web interface",handler: async (args) => {const opts = await resolveNetworkOptions(args)const server = Server.listen(opts)diff --git a/packages/opencode/src/index.ts b/packages/opencode/src/index.tsindex 03ccf76042f..e1c2cbd1d51 100644--- a/packages/opencode/src/index.ts+++ b/packages/opencode/src/index.ts@@ -101,9 +101,9 @@ const cli = yargs(hideBin(process.argv)).command(SessionCommand).fail((msg) => {if (- msg.startsWith("Unknown argument") ||- msg.startsWith("Not enough non-option arguments") ||- msg.startsWith("Invalid values:")+ msg?.startsWith("Unknown argument") ||+ msg?.startsWith("Not enough non-option arguments") ||+ msg?.startsWith("Invalid values:")) {cli.showHelp("log")}