#!/usr/bin/env node
import{a as h}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var y={name:"commands",summary:"list all available ag-bash commands",usage:"commands [OPTIONS] [name]",options:["--list          flat list of command names (one per line)","--category CAT  filter by category (core, text, search, data, agentic, network)","--search TERM   search commands by name or description"],examples:["commands                  # show all commands grouped by category","commands --list           # flat list for scripting","commands --search json    # find JSON-related commands","commands --category data  # show data/structured commands","commands echo             # show help for echo command"]},d=Object.create(null);Object.assign(d,{core:{label:"Core I/O",commands:["echo","cat","ls","cp","mv","rm","mkdir","rmdir","touch","ln","stat","du","tree","pwd","cd","tee","printf","readlink","basename","dirname","env","whoami","hostname","date","sleep","seq","timeout","clear"]},text:{label:"Text Processing",commands:["grep","sed","awk","cut","tr","sort","uniq","wc","head","tail","tac","rev","paste","join","comm","column","fold","expand","nl","od","strings","split","xargs"]},search:{label:"Search & Find",commands:["find","rg","ag-grep","ag-find-files","ag-find-symbol","ag-references","ag-hover"]},data:{label:"Data & Structured",commands:["jq","yq","xan","sqlite3","python3","js-exec","base64","md5sum","file","diff"]},agentic:{label:"Agentic Tools",commands:["ag-edit","ag-diff","ag-analyze","ag-explain","ag-convert","ag-snapshot","ag-plan","ag-task","ag-todo","ag-team","ag-orchestration","ag-mcp","ag-cron","ag-worktree","ag-web","ag-message","ag-notebook","ag-glob"]},archive:{label:"Archive & Encoding",commands:["tar","gzip","base64","html-to-markdown"]},network:{label:"Network",commands:["curl"]}});var l=Object.create(null);Object.assign(l,{echo:"display text",cat:"concatenate and print files",ls:"list directory contents",cp:"copy files and directories",mv:"move/rename files",rm:"remove files or directories",mkdir:"create directories",touch:"create empty files or update timestamps",grep:"search text with patterns",sed:"stream editor for text transformation",awk:"pattern scanning and processing",find:"search for files in directory tree",rg:"ripgrep \u2014 fast recursive search",jq:"JSON processor",yq:"YAML/TOML/XML processor",curl:"transfer data via HTTP",sort:"sort lines of text",wc:"count lines, words, and bytes",head:"output first lines of files",tail:"output last lines of files",cut:"extract columns from text",tr:"translate or delete characters",uniq:"filter duplicate lines",xargs:"build and execute commands from stdin",tee:"read stdin and write to files and stdout",diff:"compare files line by line",tar:"archive files",tree:"display directory tree",stat:"display file status",du:"estimate file space usage","ag-edit":"surgical line-based file editing","ag-diff":"semantic code diffing","ag-analyze":"code structure analysis","ag-explain":"explain code or commands","ag-snapshot":"state snapshotting","ag-plan":"planning mode toggle","ag-task":"task management","ag-todo":"TODO tracking","ag-team":"multi-agent collaboration","ag-mcp":"MCP tool integration","ag-cron":"scheduled job management","ag-web":"web search and fetch",sqlite3:"SQLite database engine",python3:"Python interpreter (WASM)","js-exec":"JavaScript runtime (QuickJS)",about:"show ag-bash features and info",doctor:"verify environment health",commands:"list all available commands"});function p(t,c){let n=t.indexOf(c);if(n!==-1&&n+1<t.length)return t[n+1]}var x={name:"commands",execute:async(t,c)=>{if(t.includes("--help")||t.includes("-h"))return h(y);let n=c.getRegisteredCommands?c.getRegisteredCommands():[],u=t.filter(e=>!e.startsWith("-")&&e!==t[t.indexOf("--category")+1]&&e!==t[t.indexOf("--search")+1]);if(u.length>0&&!t.includes("--list")&&!t.includes("--category")&&!t.includes("--search")){let e=u[0];return c.exec?await c.exec(`${e} --help`,{cwd:c.cwd}):{stdout:"",stderr:`commands: cannot show help for '${e}'
`,exitCode:1}}if(t.includes("--list"))return{stdout:`${[...n].sort().join(`
`)}
`,stderr:"",exitCode:0};let m=p(t,"--search");if(m){let e=m.toLowerCase(),r=n.filter(a=>{let i=l[a]??"";return a.toLowerCase().includes(e)||i.toLowerCase().includes(e)}).sort();if(r.length===0)return{stdout:`No commands matching '${m}'
`,stderr:"",exitCode:0};let o=`Commands matching '${m}':

`;for(let a of r){let i=l[a]??"";o+=`  ${a.padEnd(20)} ${i}
`}return{stdout:o,stderr:"",exitCode:0}}let f=p(t,"--category");if(f){let e=d[f.toLowerCase()];if(!e){let a=Object.keys(d).join(", ");return{stdout:"",stderr:`commands: unknown category '${f}'. Available: ${a}
`,exitCode:1}}let r=e.commands.filter(a=>n.includes(a)),o=`${e.label} (${r.length} commands):

`;for(let a of r){let i=l[a]??"";o+=`  ${a.padEnd(20)} ${i}
`}return{stdout:o,stderr:"",exitCode:0}}let s=`ag-bash commands (${n.length} total):

`;for(let[,e]of Object.entries(d)){let r=e.commands.filter(o=>n.includes(o));if(r.length!==0){s+=`${e.label}:
`;for(let o of r){let a=l[o]??"";s+=`  ${o.padEnd(20)} ${a}
`}s+=`
`}}let b=new Set(Object.values(d).flatMap(e=>e.commands)),g=n.filter(e=>!b.has(e)).sort();if(g.length>0){s+=`Other (${g.length}):
`;for(let e of g)s+=`  ${e}
`;s+=`
`}return s+=`Use 'commands <name>' for help on a specific command.
`,s+=`Use 'commands --search <term>' to search.
`,{stdout:s,stderr:"",exitCode:0}}};export{x as commandsCommand};
