Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/opencode/src/cli/cmd/debug/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/cli/cmd/debug/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/opencode/src/cli/cmd/debug/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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 () => {
Expand All @@ -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",
Expand All @@ -65,6 +69,7 @@ const FileListCommand = cmd({

const FileTreeCommand = cmd({
command: "tree [dir]",
describe: "show directory tree",
builder: (yargs) =>
yargs.positional("dir", {
type: "string",
Expand All @@ -79,6 +84,7 @@ const FileTreeCommand = cmd({

export const FileCommand = cmd({
command: "file",
describe: "file system debugging utilities",
builder: (yargs) =>
yargs
.command(FileReadCommand)
Expand Down
3 changes: 3 additions & 0 deletions packages/opencode/src/cli/cmd/debug/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { AgentCommand } from "./agent"

export const DebugCommand = cmd({
command: "debug",
describe: "debugging and troubleshooting tools",
builder: (yargs) =>
yargs
.command(ConfigCommand)
Expand All @@ -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))
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions packages/opencode/src/cli/cmd/debug/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ 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() {},
})

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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/opencode/src/cli/cmd/debug/ripgrep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -25,6 +27,7 @@ const TreeCommand = cmd({

const FilesCommand = cmd({
command: "files",
describe: "list files using ripgrep",
builder: (yargs) =>
yargs
.option("query", {
Expand Down Expand Up @@ -56,6 +59,7 @@ const FilesCommand = cmd({

const SearchCommand = cmd({
command: "search <pattern>",
describe: "search file contents using ripgrep",
builder: (yargs) =>
yargs
.positional("pattern", {
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/cli/cmd/debug/scrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/cli/cmd/debug/skill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/opencode/src/cli/cmd/debug/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/cli/cmd/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions packages/opencode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down