@cjhyy/code-shell 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/README.md +35 -2
  3. package/dist/anthropic-DJXVKFMJ.js +1 -0
  4. package/dist/arena/index.js +1 -1
  5. package/dist/arena-MRBATZFD.js +3 -0
  6. package/dist/{chunk-EU3J7TBP.js → chunk-5QIVXFCT.js} +1 -1
  7. package/dist/{chunk-XXCZE2U2.js → chunk-AFMP73YP.js} +1 -1
  8. package/dist/{chunk-L7B2ORID.js → chunk-D3TVASD2.js} +2 -2
  9. package/dist/chunk-DI26OUIU.js +2 -0
  10. package/dist/chunk-FZXY554D.js +2 -0
  11. package/dist/chunk-GGVAOPI7.js +1 -0
  12. package/dist/chunk-GKAQH2DG.js +2 -0
  13. package/dist/chunk-GYNO4R7R.js +2 -0
  14. package/dist/{chunk-RERBX75D.js → chunk-K4HILJ6G.js} +3 -3
  15. package/dist/{chunk-2EUIMKJA.js → chunk-OWBYLMDD.js} +1 -1
  16. package/dist/chunk-SKIX2M5Z.js +4 -0
  17. package/dist/chunk-SV7H4FKT.js +3 -0
  18. package/dist/{chunk-2GJ7H5NC.js → chunk-WONQHE4P.js} +40 -40
  19. package/dist/{chunk-DEYFK6FP.js → chunk-X2S7ASQ2.js} +1 -1
  20. package/dist/chunk-Z5HKHAO7.js +336 -0
  21. package/dist/cli/commands/builtin/plugin-commands-registration.d.ts +12 -0
  22. package/dist/cli/commands/builtin/plugin-handler.d.ts +6 -0
  23. package/dist/cli/commands/registry.d.ts +9 -2
  24. package/dist/cli/main.js +138 -122
  25. package/dist/client-base-GSFXPP2Y.js +1 -0
  26. package/dist/devtools-FBX4HVVY.js +1 -0
  27. package/dist/engine/engine.d.ts +29 -0
  28. package/dist/engine/turn-loop.d.ts +25 -0
  29. package/dist/hooks/events.d.ts +84 -5
  30. package/dist/hooks/inject.d.ts +19 -0
  31. package/dist/hooks/shell-runner.d.ts +45 -0
  32. package/dist/index.d.ts +3 -2
  33. package/dist/index.js +1 -1
  34. package/dist/llm/api-key-sanitize.d.ts +22 -0
  35. package/dist/llm/providers/openai.d.ts +23 -0
  36. package/dist/llm/retry.d.ts +12 -0
  37. package/dist/llm/stream-watchdog.d.ts +42 -0
  38. package/dist/logging/logger.d.ts +14 -0
  39. package/dist/manager-4XKLZHKE.js +1 -0
  40. package/dist/mcp-manager-3JGHEJO3.js +1 -0
  41. package/dist/openai-OQ6LLN5J.js +1 -0
  42. package/dist/{openrouter-models-GZVCRWD2.js → openrouter-models-ZT4R2AE3.js} +1 -1
  43. package/dist/openrouter-sync-ARMVWY7S.js +1 -0
  44. package/dist/plugin-handler-GJISMH5Q.js +11 -0
  45. package/dist/plugins/gitOps.d.ts +23 -0
  46. package/dist/plugins/installedPlugins.d.ts +15 -0
  47. package/dist/plugins/knownMarketplaces.d.ts +10 -0
  48. package/dist/plugins/loadPluginHooks.d.ts +52 -0
  49. package/dist/plugins/marketplaceManager.d.ts +49 -0
  50. package/dist/plugins/parseMarketplaceInput.d.ts +16 -0
  51. package/dist/plugins/pluginCommandHook.d.ts +54 -0
  52. package/dist/plugins/pluginCommandsLoader.d.ts +25 -0
  53. package/dist/plugins/pluginInstaller.d.ts +36 -0
  54. package/dist/plugins/schemas.d.ts +9 -0
  55. package/dist/plugins/types.d.ts +73 -2
  56. package/dist/plugins/varRewrite.d.ts +42 -0
  57. package/dist/product/index.js +1 -1
  58. package/dist/protocol/helpers.d.ts +42 -0
  59. package/dist/render/clearTerminal.d.ts +9 -3
  60. package/dist/render/components/App.d.ts +1 -0
  61. package/dist/render/components/Static.d.ts +23 -0
  62. package/dist/render/devtools.d.ts +8 -4
  63. package/dist/render/dom.d.ts +2 -1
  64. package/dist/render/frame.d.ts +1 -0
  65. package/dist/render/index.d.ts +10 -0
  66. package/dist/render/ink.d.ts +24 -2
  67. package/dist/render/log-update.d.ts +12 -1
  68. package/dist/render/selection.d.ts +1 -1
  69. package/dist/run/index.js +1 -1
  70. package/dist/services/index.d.ts +1 -0
  71. package/dist/services/memory-orchestrator.d.ts +39 -0
  72. package/dist/settings/schema.d.ts +93 -6
  73. package/dist/skills/frontmatter.d.ts +13 -0
  74. package/dist/skills/index.d.ts +4 -4
  75. package/dist/skills/scanner.d.ts +11 -21
  76. package/dist/tool-summary-HJX6RHG4.js +2 -0
  77. package/dist/tool-system/builtin/agent-notifications.d.ts +55 -0
  78. package/dist/tool-system/builtin/agent-registry.d.ts +35 -4
  79. package/dist/tool-system/builtin/agent-transcript-translator.d.ts +22 -0
  80. package/dist/tool-system/builtin/skill-prompt.d.ts +7 -0
  81. package/dist/tool-system/builtin/skill.d.ts +3 -1
  82. package/dist/tool-system/context.d.ts +23 -0
  83. package/dist/tool-system/executor.d.ts +1 -1
  84. package/dist/tool-system/permission.d.ts +1 -1
  85. package/dist/types.d.ts +35 -0
  86. package/dist/ui/components/AgentBlock.d.ts +5 -2
  87. package/dist/ui/components/AgentDock.d.ts +36 -0
  88. package/dist/ui/components/CommandInput.d.ts +12 -1
  89. package/dist/ui/components/MessageRow.d.ts +54 -0
  90. package/dist/ui/components/SpinnerWithVerb.d.ts +2 -1
  91. package/dist/ui/components/TextInput.d.ts +9 -1
  92. package/dist/ui/components/VirtualMessageList.d.ts +30 -11
  93. package/dist/ui/dev-seed.d.ts +1 -0
  94. package/dist/ui/fullscreen-mode.d.ts +9 -0
  95. package/dist/ui/hooks/useVirtualScroll.d.ts +101 -0
  96. package/dist/ui/perf-probes.d.ts +22 -0
  97. package/dist/ui/query-guard.d.ts +35 -0
  98. package/dist/ui/slice-anchor.d.ts +44 -0
  99. package/dist/ui/store.d.ts +26 -1
  100. package/package.json +5 -3
  101. package/dist/anthropic-OVRWAZRD.js +0 -1
  102. package/dist/arena-64T2EQD4.js +0 -3
  103. package/dist/chunk-A4M2Y42L.js +0 -2
  104. package/dist/chunk-DTPABBSV.js +0 -2
  105. package/dist/chunk-MGP35GKD.js +0 -254
  106. package/dist/chunk-Q3RSX66I.js +0 -1
  107. package/dist/chunk-VKKU4LOM.js +0 -3
  108. package/dist/chunk-ZSAONDT6.js +0 -2
  109. package/dist/client-base-F5FCRSB3.js +0 -1
  110. package/dist/devtools-SGDUOOM4.js +0 -1
  111. package/dist/manager-J6FXEUEK.js +0 -1
  112. package/dist/mcp-manager-27EVBKRT.js +0 -1
  113. package/dist/openai-3QEADSYL.js +0 -1
  114. package/dist/openrouter-sync-WG4AG5NC.js +0 -1
  115. package/dist/plugins/loader.d.ts +0 -72
  116. package/dist/skills/matcher.d.ts +0 -21
  117. package/dist/tool-summary-V2B3MD5N.js +0 -2
  118. package/skills-builtin/codeshell-help.md +0 -135
@@ -1 +0,0 @@
1
- import {M,da,ca,W,fa}from'./chunk-MGP35GKD.js';import {h,a}from'./chunk-3QP5BQ3L.js';import {join}from'path';import {homedir}from'os';h();h();function R(y,s){let{preset:e,adapter:t,contract:o}=y,w=e.name,x=["Read","Write","Edit","Glob","Grep","Bash","AskUserQuestion","Agent","ToolSearch","TaskCreate","TaskList","TaskUpdate","TaskGet"],i=new Set([...x,...t?.enableTools??[]]);for(let n of t?.disableTools??[])i.delete(n);let S=[{tool:"Read",decision:"allow"},{tool:"Glob",decision:"allow"},{tool:"Grep",decision:"allow"},{tool:"AskUserQuestion",decision:"allow"},{tool:"ToolSearch",decision:"allow"},{tool:"TaskCreate",decision:"allow"},{tool:"TaskList",decision:"allow"},{tool:"TaskUpdate",decision:"allow"},{tool:"TaskGet",decision:"allow"},...t?.permissionRules??[]],l={name:w,label:e.label,description:e.description,promptSections:e.sections??["base","orchestration"],injectGitStatus:e.injectGitStatus??false,builtinTools:[...i],defaultPermissionRules:S};M(l);let r;o?.evaluator?Array.isArray(o.evaluator)?r=new da(o.evaluator):r=o.evaluator:r=new ca;let c=t?.tools??[],d=c.map(n=>({definition:n.definition,execute:n.execute})),u=s.runsDir??join(homedir(),".code-shell","runs"),k=new W(u);return {manager:new fa({store:k,executor:{llm:s.llm,maxTurns:o?.maxTurns??30,maxContextTokens:o?.maxContextTokens??2e5,permissionMode:s.permissionMode??"acceptEdits",sessionStorageDir:s.sessionStorageDir,mcpServers:t?.mcpServers,enabledBuiltinTools:[...i],disabledBuiltinTools:t?.disableTools,customSystemPrompt:e.customPrompt,appendSystemPrompt:e.appendPrompt,hooks:t?.hooks,customTools:d.length>0?d:void 0},concurrency:o?.concurrency??1,runsDir:u,evaluator:r,defaultTags:o?.defaultTags,defaultMetadata:o?.defaultMetadata}),preset:l,customTools:c}}a(R,"defineProduct");export{R as a};
@@ -1,3 +0,0 @@
1
- import {a as a$2}from'./chunk-O5HFCH2U.js';import {a as a$1}from'./chunk-2EUIMKJA.js';import {b as b$1,c,d}from'./chunk-FU7AHZNN.js';import {b}from'./chunk-ZSAONDT6.js';import {h,a}from'./chunk-3QP5BQ3L.js';import O from'openai';h();h();h();var I=[{kind:"openai",match:/^(?:o[1-9]\d*|gpt-[5-9])(?:[-.]|$)/i,capability:{tokenLimitField:"max_completion_tokens",rejectedParams:new Set(["temperature","top_p","presence_penalty","frequency_penalty","logit_bias","logprobs","top_logprobs"]),reasoning:{kind:"openai-effort"},echoReasoning:"optional"},why:"OpenAI o-series + gpt-5+ reject classic sampling params; use max_completion_tokens + reasoning_effort."},{kind:"deepseek",match:/^deepseek-v4(?:[-.]|$)/i,capability:{reasoning:{kind:"deepseek-thinking"},echoReasoning:"when-tools"},why:"DeepSeek V4 thinking mode \u2014 top-level thinking:{type}; echo reasoning_content when tools are present."},{kind:"deepseek",match:/^deepseek-reasoner(?:[-.]|$)/i,capability:{reasoning:{kind:"none"},echoReasoning:"never"},why:"deepseek-reasoner refuses prior reasoning_content in input; always-on reasoning, no toggle."},{kind:"zai",match:/^glm-[4-9](?:[-.]|$)/i,capability:{reasoning:{kind:"deepseek-thinking"},echoReasoning:"optional"},why:"Z.AI GLM-4.5+ thinking shape is identical to DeepSeek V4; default is enabled."},{kind:"anthropic",match:/^claude-(?:opus|sonnet|haiku)-4-[6-9](?:[-.]|$)/i,capability:{reasoning:{kind:"anthropic-adaptive"},echoReasoning:"when-tools",parallelToolCalls:"anthropic-disable-flag",streamUsage:"auto"},why:"Claude 4.6+ thinking is adaptive \u2014 no opt-in field. Echo thinking blocks on tool turns."},{kind:"anthropic",match:/^claude-(?:opus|sonnet|haiku)-4(?:[-.]|$)/i,capability:{reasoning:{kind:"anthropic-budget",minBudgetTokens:1024},echoReasoning:"when-tools",parallelToolCalls:"anthropic-disable-flag",streamUsage:"auto"},why:"Claude 4.x \u22644.5 supports explicit thinking:{type:enabled, budget_tokens\u22651024}."},{kind:"anthropic",match:/^claude-/i,capability:{parallelToolCalls:"anthropic-disable-flag",streamUsage:"auto"},why:"Pre-Claude-4 \u2014 no extended thinking; keep Anthropic tool_choice/stream shape."},{kind:"google",match:/^gemini-(?:[2-9]\.\d|[2-9])/i,capability:{reasoning:{kind:"openai-effort"},echoReasoning:"optional"},why:"Gemini 2.5+ via OpenAI-compat \u2014 reasoning_effort is auto-mapped to thinking_level."},{kind:"openrouter",match:/./,capability:{reasoning:{kind:"openrouter-reasoning"},echoReasoning:"optional"},why:"OpenRouter exposes a unified reasoning:{effort,max_tokens,exclude,enabled} field for every backend."},{kind:"xai",match:/^grok-4\.3(?:[-.]|$)/i,capability:{reasoning:{kind:"openai-effort",disabledEffort:"low"}},why:"xAI grok-4.3 supports reasoning_effort none|low|medium|high \u2014 no `minimal`."},{kind:"mistral",match:/^magistral/i,capability:{reasoning:{kind:"openai-effort",disabledEffort:"none"}},why:"Mistral magistral models accept only reasoning_effort `high` or `none`."},{kind:"groq",match:/^(?:gpt-oss-(?:20b|120b)|qwen3-)/i,capability:{reasoning:{kind:"openai-effort"},tokenLimitField:"max_completion_tokens"},why:"Groq reasoning-capable models use max_completion_tokens + reasoning_effort."}];h();var y={tokenLimitField:"max_tokens",rejectedParams:new Set,reasoning:{kind:"none"},echoReasoning:"optional",parallelToolCalls:"openai-flag",streamUsage:"include-usage-flag"};function S(_,e){for(let t of I)if(t.kind===_&&t.match.test(e))return {...y,...t.capability,rejectedParams:t.capability.rejectedParams?new Set(t.capability.rejectedParams):new Set(y.rejectedParams)};return {...y,rejectedParams:new Set(y.rejectedParams)}}a(S,"capabilitiesFor");var E=class extends a$1{static{a(this,"OpenAIClient");}_client=null;_forceMaxCompletionTokens=false;constructor(e){super(e);}initClient(){}get client(){return this._client||(this._client=new O({apiKey:this.config.apiKey??process.env.OPENAI_API_KEY,...this.config.baseUrl?{baseURL:this.config.baseUrl}:{},timeout:this.timeout})),this._client}_capability=null;get capability(){if(!this._capability){let e=this.config.providerKind??"openai";this._capability=S(e,this.model);}return this._capability}async createMessage(e){return this.withRetry(async()=>{let t=e.thinking??this.config.thinking,c=this.buildMessages(e.systemPrompt,e.messages,t),i=e.tools?.length?this.convertTools(e.tools):void 0,a=b.span("llm.request",{cat:"llm",provider:this.provider,model:this.model,stream:!!(e.stream&&e.onChunk),messageCount:c.length,toolCount:i?.length??0});try{let n=e.stream&&e.onChunk?await this.streamMessage(e,c,i,t):await this.nonStreamMessage(e,c,i,t);return a.end({stopReason:n.stopReason,promptTokens:n.usage?.promptTokens,completionTokens:n.usage?.completionTokens,cacheReadTokens:n.usage?.cacheReadTokens,cacheCreationTokens:n.usage?.cacheCreationTokens}),n}catch(n){throw a.fail(n),n}})}buildRequestBody(e,t,c,i,a){let n=this.capability,d=e.maxTokens??this.maxTokens,s=this._forceMaxCompletionTokens||n.tokenLimitField==="max_completion_tokens"?{max_completion_tokens:d}:{max_tokens:d},p={};n.rejectedParams.has("temperature")||(p.temperature=e.temperature!==void 0?e.temperature:this.temperature);let r={};if(i)switch(n.reasoning.kind){case "deepseek-thinking":r.thinking={type:i};break;case "openai-effort":r.reasoning_effort=i==="disabled"?n.reasoning.disabledEffort??"minimal":"medium";break;case "openrouter-reasoning":r.reasoning=i==="disabled"?{effort:"minimal",exclude:true}:{effort:"medium"};break;}return {model:this.model,messages:t,...s,...p,...r,...c?{tools:c}:{},...a?{stream:true,stream_options:{include_usage:true}}:{}}}async nonStreamMessage(e,t,c,i){try{let a=await this.client.chat.completions.create(this.buildRequestBody(e,t,c,i,!1),{signal:e.signal}),n=a.choices[0];if(!n)throw new b$1("No response from OpenAI","openai");let d={promptTokens:a.usage?.prompt_tokens??0,completionTokens:a.usage?.completion_tokens??0,totalTokens:a.usage?.total_tokens??0};return this.recordUsage(d,e),this.processChoice(n,d)}catch(a){throw this.handleApiError(a),a}}async streamMessage(e,t,c,i){try{let a=await this.client.chat.completions.create(this.buildRequestBody(e,t,c,i,!0),{signal:e.signal}),n="",d="",h=new Map,s,p=Date.now(),r=!1;for await(let o of a){o.usage&&(s=o.usage);let m=o.choices[0]?.delta;if(!m)continue;let w=m.reasoning_content;if(typeof w=="string"&&w.length>0&&(d+=w),m.content&&(r||(r=!0,b.debug("llm.first_byte",{cat:"llm",provider:this.provider,model:this.model,ttft_ms:Date.now()-p})),n+=m.content,e.onChunk?.({type:"text",text:m.content,tokens:a$2(m.content)})),m.tool_calls)for(let g of m.tool_calls){let x=g.index;h.has(x)||(h.set(x,{id:g.id??"",name:g.function?.name??"",args:""}),e.onChunk?.({type:"tool_use_start",toolCall:{id:g.id,toolName:g.function?.name}}));let f=h.get(x);if(g.id&&(f.id=g.id),g.function?.name&&(f.name=g.function.name),g.function?.arguments&&(f.args+=g.function.arguments,f.id))try{let U=JSON.parse(f.args||"{}");e.onChunk?.({type:"tool_use_delta",toolCall:{id:f.id,toolName:f.name,args:U}});}catch{}}o.choices[0]?.finish_reason&&e.onChunk?.({type:"stop",stopReason:o.choices[0].finish_reason});}let l=[];for(let[,o]of h){let m={};try{m=JSON.parse(o.args||"{}");}catch{}l.push({id:o.id,toolName:o.name,args:m});}let k={promptTokens:s?.prompt_tokens??0,completionTokens:s?.completion_tokens??0,totalTokens:s?.total_tokens??0};return this.recordUsage(k,e),{text:n,toolCalls:l,usage:k,stopReason:"stop",...d?{reasoningContent:d}:{}}}catch(a){throw this.handleApiError(a),a}}processChoice(e,t){let c=e.message.content??"",i=[];if(e.message.tool_calls)for(let n of e.message.tool_calls){let d={};try{d=JSON.parse(n.function.arguments||"{}");}catch{}i.push({id:n.id,toolName:n.function.name,args:d});}let a=j(e.message);return {text:c,toolCalls:i,usage:t,stopReason:e.finish_reason??void 0,...a?{reasoningContent:a}:{}}}buildMessages(e,t,c){let i=[{role:"system",content:e}],a=this.capability,n=t.some(s=>Array.isArray(s.content)&&s.content.some(p=>p.type==="tool_use"||p.type==="tool_result")),d=c!=="disabled"&&a.echoReasoning==="when-tools"&&n,h=a.echoReasoning==="never";for(let s of t)if(s.role!=="system")if(s.role==="assistant"){let p={role:"assistant"},r;if(typeof s.content=="string")p.content=s.content;else {let l=[],k=[];for(let o of s.content)o.type==="text"&&o.text?l.push(o.text):o.type==="tool_use"&&o.id&&o.name?k.push({id:o.id,type:"function",function:{name:o.name,arguments:JSON.stringify(o.input??{})}}):o.type==="reasoning"&&o.reasoningContent&&(r=o.reasoningContent),!r&&o.reasoningContent&&(r=o.reasoningContent);l.length&&(p.content=l.join(`
2
- `)),k.length&&(p.tool_calls=k);}h?r=void 0:!r&&d&&(r=""),r!==void 0&&(p.reasoning_content=r),i.push(p);}else if(s.role==="tool")i.push({role:"tool",tool_call_id:s.tool_call_id??"",content:typeof s.content=="string"?s.content:""});else if(typeof s.content=="string")i.push({role:"user",content:s.content});else {let p=[],r=[];for(let l of s.content)l.type==="tool_result"&&l.tool_use_id?r.push({tool_use_id:l.tool_use_id,content:typeof l.content=="string"?l.content:""}):l.type==="text"&&l.text&&p.push(l.text);for(let l of r)i.push({role:"tool",tool_call_id:l.tool_use_id,content:l.content});p.length>0&&i.push({role:"user",content:p.join(`
3
- `)});}return i}convertTools(e){return e.map(t=>({type:"function",function:{name:t.name,description:t.description,parameters:t.inputSchema}}))}handleApiError(e){if(e instanceof O.APIError){if(e.status===429)throw new c("openai");let t=(e.message??"").toLowerCase();throw e.status===400&&t.includes("max_tokens")&&t.includes("max_completion_tokens")&&(this._forceMaxCompletionTokens=true),t.includes("context_length_exceeded")||t.includes("maximum context length")||t.includes("too many tokens")||t.includes("prompt is too long")?new d("openai"):e.status===401&&t.includes("provider returned error")?new b$1(`OpenAI-compatible endpoint returned 401 "Provider returned error". Two likely causes: (1) the API key is invalid/revoked, or (2) the upstream provider rejects tool calls for this model (common on OpenRouter's gpt-4o-mini route). Verify the key, then try a tool-capable model such as openai/gpt-4.1-mini or anthropic/claude-3.5-haiku.`,"openai",{status:e.status}):new b$1(`OpenAI API error: ${e.message}`,"openai",{status:e.status})}throw e}};function j(_){let e=_.reasoning_content??_.reasoning;return typeof e=="string"&&e.length>0?e:void 0}a(j,"extractReasoningContent");export{E as a};
@@ -1,2 +0,0 @@
1
- import {h as h$1,a as a$1}from'./chunk-3QP5BQ3L.js';import {existsSync,mkdirSync,appendFileSync,readdirSync,unlinkSync}from'fs';import {join}from'path';import {homedir}from'os';h$1();var l={debug:0,info:1,warn:2,error:3},g=join(homedir(),".code-shell","logs"),h=7,x=100,_=new Set(["ui","ink","render","stream"]);function D(n,e){let r=(n??e??"").toLowerCase();return _.has(r)?"ui-ink":"engine"}a$1(D,"routeBucket");function C(){return process.env.CODE_SHELL_DEV==="1"||process.argv.includes("--debug")||process.argv.includes("-d")||process.argv.some(e=>e.startsWith("--debug="))?true:process.env.NODE_ENV==="test"||process.env.BUN_TEST==="1"||process.argv.some(e=>e.includes("/tests/")||e.endsWith(".test.ts"))?false:!!(process.argv[1]??"").includes("/src/")}a$1(C,"isLocalDev");function O(){let n=process.env.CODE_SHELL_LOG_LEVEL?.toLowerCase().trim();return n&&Object.hasOwn(l,n)?n:C()?"debug":"info"}a$1(O,"resolveDefaultLevel");function F(){let n=process.argv.find(t=>t.startsWith("--debug=")),e;if(n)e=n.slice(8);else {let t=process.env.CODE_SHELL_DEBUG;t&&t!=="1"&&t!=="true"&&(e=t);}if(!e)return null;let r=new Set(e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean));return r.size>0?r:null}a$1(F,"resolveCategoryFilter");var v=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;function M(n){v=n;}a$1(M,"setCurrentSid");function $(){return v}a$1($,"getCurrentSid");var a=[];var d=class n{constructor(e={}){this.context=e;this.enabled=process.env.CODE_SHELL_LOG!=="0",this.minLevel=O(),this.categoryFilter=F(),this.stderrEcho=process.env.CODE_SHELL_DEBUG==="1"||process.argv.includes("--debug-to-stderr")||process.argv.includes("-d2e");}static{a$1(this,"Logger");}enabled;minLevel;categoryFilter;stderrEcho;dirReady=false;child(e){return new n({...this.context,...e})}setSid(e){M(e);}getSid(){return $()}debug(e,r){this.write("debug",e,r);}info(e,r){this.write("info",e,r);}warn(e,r){this.write("warn",e,r);}error(e,r){let t,o;typeof e=="string"?(t=e,r instanceof Error?(o={error:r.message,stack:r.stack}):o=r):e instanceof Error?(t=e.message,o={stack:e.stack}):t=String(e),this.recordError(t,o),this.write("error",t,o);}recordError(e,r){a.length>=x&&a.shift(),a.push({msg:e,t:new Date().toISOString(),data:r});}write(e,r,t){if(!this.enabled||l[e]<l[this.minLevel])return;let o=t?.cat??this.context.cat;if(e==="debug"&&this.categoryFilter&&(!o||!this.categoryFilter.has(o.toLowerCase())))return;let i=new Date().toISOString(),c={t:i,l:e,msg:r,...this.context};o&&!c.cat&&(c.cat=o),c.sid===void 0&&(c.sid=v),t&&(c.d=t);let u=JSON.stringify(c)+`
2
- `;if(this.stderrEcho){process.stderr.write(u);return}try{this.dirReady||(existsSync(g)||mkdirSync(g,{recursive:!0}),this.dirReady=!0);let w=i.slice(0,10),S=D(o,this.context.cat),y=join(g,`${S}-${w}.log`);appendFileSync(y,u,"utf-8");}catch{}}getMinLevel(){return this.minLevel}isCategoryActive(e){return !this.categoryFilter||this.categoryFilter.has(e.toLowerCase())}span(e,r){let t=Date.now();return this.write("debug",`${e}.begin`,r),{end:a$1(o=>{let i=Date.now()-t;this.write("info",`${e}.end`,{...r,...o,duration_ms:i});},"end"),fail:a$1((o,i)=>{let c=Date.now()-t,u=o instanceof Error?o.message:String(o);this.write("error",`${e}.fail`,{...r,...i,duration_ms:c,error:u});},"fail")}}},V=new d;function W(){try{if(!existsSync(g))return;let n=readdirSync(g).filter(e=>e.endsWith(".log")).sort();if(n.length<=h)return;for(let e of n.slice(0,n.length-h))try{unlinkSync(join(g,e));}catch{}}catch{}}a$1(W,"rotateLogs");export{$ as a,V as b,W as c};
@@ -1 +0,0 @@
1
- export{a as LLMClientBase}from'./chunk-2EUIMKJA.js';import'./chunk-FU7AHZNN.js';import'./chunk-ZSAONDT6.js';import'./chunk-3QP5BQ3L.js';
@@ -1 +0,0 @@
1
- import {h}from'./chunk-3QP5BQ3L.js';h();
@@ -1 +0,0 @@
1
- export{c as SettingsManager}from'./chunk-DTPABBSV.js';import'./chunk-3QP5BQ3L.js';
@@ -1 +0,0 @@
1
- export{a as MCPManager}from'./chunk-L7B2ORID.js';import'./chunk-ZSAONDT6.js';import'./chunk-3QP5BQ3L.js';
@@ -1 +0,0 @@
1
- export{a as OpenAIClient}from'./chunk-VKKU4LOM.js';import'./chunk-O5HFCH2U.js';import'./chunk-2EUIMKJA.js';import'./chunk-FU7AHZNN.js';import'./chunk-ZSAONDT6.js';import'./chunk-3QP5BQ3L.js';
@@ -1 +0,0 @@
1
- export{a as syncOpenRouterCatalog}from'./chunk-XXCZE2U2.js';export{b as getOpenRouterSnapshot}from'./chunk-A4M2Y42L.js';import'./chunk-3QP5BQ3L.js';
@@ -1,72 +0,0 @@
1
- /**
2
- * Plugin system — discover, load, and manage plugins.
3
- *
4
- * Plugin directories:
5
- * ~/.code-shell/plugins/
6
- * .code-shell/plugins/ (project-level)
7
- *
8
- * Each plugin is a directory with a manifest.json:
9
- * {
10
- * "name": "my-plugin",
11
- * "version": "1.0.0",
12
- * "description": "...",
13
- * "main": "index.js",
14
- * "skills": [...],
15
- * "hooks": {...},
16
- * "mcpServers": {...},
17
- * "tools": [...]
18
- * }
19
- */
20
- export interface PluginManifest {
21
- name: string;
22
- version: string;
23
- description: string;
24
- main?: string;
25
- enabled?: boolean;
26
- skills?: Array<{
27
- name: string;
28
- description: string;
29
- triggers?: {
30
- keywords?: string[];
31
- tools?: string[];
32
- intents?: string[];
33
- };
34
- }>;
35
- hooks?: Record<string, string>;
36
- mcpServers?: Record<string, {
37
- command: string;
38
- args?: string[];
39
- }>;
40
- tools?: Array<{
41
- name: string;
42
- description: string;
43
- inputSchema: Record<string, unknown>;
44
- handler: string;
45
- }>;
46
- }
47
- export interface LoadedPlugin {
48
- manifest: PluginManifest;
49
- path: string;
50
- enabled: boolean;
51
- error?: string;
52
- }
53
- export declare class PluginLoader {
54
- private plugins;
55
- /**
56
- * Scan plugin directories and load manifests.
57
- */
58
- scan(cwd: string): LoadedPlugin[];
59
- /**
60
- * Load a single plugin from a directory.
61
- */
62
- private loadPlugin;
63
- private registerPlugin;
64
- /** Get a plugin by name. */
65
- get(name: string): LoadedPlugin | undefined;
66
- /** List all discovered plugins. */
67
- list(): LoadedPlugin[];
68
- /** Enable/disable a plugin. */
69
- setEnabled(name: string, enabled: boolean): boolean;
70
- /** Get all enabled plugins. */
71
- getEnabled(): LoadedPlugin[];
72
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Skill matcher — determines which skills are relevant for a given input/context.
3
- */
4
- import type { SkillDefinition } from "./scanner.js";
5
- export interface MatchResult {
6
- skill: SkillDefinition;
7
- score: number;
8
- matchedBy: string;
9
- }
10
- /**
11
- * Match skills against user input text.
12
- */
13
- export declare function matchSkillsByInput(skills: SkillDefinition[], input: string): MatchResult[];
14
- /**
15
- * Match skills by tool name being used.
16
- */
17
- export declare function matchSkillsByTool(skills: SkillDefinition[], toolName: string): MatchResult[];
18
- /**
19
- * Build a skill listing for the system prompt.
20
- */
21
- export declare function buildSkillListing(skills: SkillDefinition[]): string;
@@ -1,2 +0,0 @@
1
- import {b}from'./chunk-ZSAONDT6.js';import {h,a}from'./chunk-3QP5BQ3L.js';h();var p='Generate a very brief (under 40 chars) summary of what these tools did. Use past tense, commit-subject style. Examples: "Read 3 config files", "Fixed import in auth.ts", "Searched for API endpoints". Respond with ONLY the summary text, nothing else.';async function d(r,a,l){if(r.length===0)return null;try{let e=[];for(let t=0;t<r.length;t++){let s=r[t],o=a[t],u=JSON.stringify(s.args).slice(0,200),c=(o?.result??o?.error??"").slice(0,300);e.push(`Tool: ${s.toolName}(${u}) \u2192 ${c}`);}return (await l(p,e.join(`
2
- `)))?.trim()||null}catch(e){return b.warn("tool_summary.failed",{error:e.message}),null}}a(d,"generateToolUseSummary");export{d as generateToolUseSummary};
@@ -1,135 +0,0 @@
1
- ---
2
- name: codeshell-help
3
- description: Use when the user asks how to use code-shell itself — slash commands, login/model setup, settings.json keys, hooks, MCP servers, debugging flags, or "how do I X in code-shell". Skip for general programming questions.
4
- when_to_use: User asks about code-shell features, configuration, slash commands, or runtime behavior. Not for code questions in the user's own project.
5
- ---
6
-
7
- # Using code-shell
8
-
9
- You are running inside **code-shell**, a terminal coding agent. This skill answers user questions about code-shell itself. Quote sections directly where helpful. If a topic isn't covered, say so — don't invent commands.
10
-
11
- ## Getting started
12
-
13
- - `code-shell` — start an interactive REPL in the current directory.
14
- - `code-shell run "<prompt>"` — one-shot non-interactive run, prints final answer and exits.
15
- - `code-shell runs <sid>` — resume a saved session by id.
16
- - First launch shows an onboarding flow that walks through provider + model setup.
17
-
18
- ## Slash commands (run inside the REPL)
19
-
20
- Type `/` and the menu appears. The full list:
21
-
22
- ### Core
23
- - `/help` — show the slash menu.
24
- - `/exit` — quit the REPL.
25
- - `/clear` — clear the conversation (keeps session id).
26
- - `/compact` — manually trigger context compaction.
27
- - `/status` — current model, effort, token usage, working dir.
28
- - `/version` — code-shell version.
29
- - `/cost` — token cost summary for the session.
30
- - `/sid` — print the current session id.
31
- - `/session` — open the session picker.
32
- - `/resume` — resume the most recent session.
33
- - `/diff` — show working-tree diff.
34
- - `/tasks` — current task list (TaskCreate/TaskUpdate state).
35
- - `/tools` — list available tools.
36
- - `/memory` — open the per-project memory file.
37
- - `/export markdown` — export the current conversation to a markdown file.
38
-
39
- ### Models / providers
40
- - `/login` — add a new provider + model via the unified ProviderModelFlow.
41
- - `/logout` — remove a provider's stored credentials.
42
- - `/model` — quick-switch the active model.
43
- - `/models` — open the ModelManager (add, refresh, delete providers and models).
44
-
45
- ### Configuration
46
- - `/config` — open `settings.json` for the active scope.
47
- - `/permissions` — manage tool permission rules.
48
- - `/hooks` — list hooks configured in settings.
49
- - `/mcp` — list and manage MCP servers.
50
- - `/skills` — list discovered skills.
51
- - `/effort` — set reasoning effort (low / medium / high) for reasoning models.
52
-
53
- ### Git / review
54
- - `/commit` — agent drafts a commit from staged changes.
55
- - `/branch` — branch operations.
56
- - `/review` — review pending changes.
57
- - `/pr-comments` — fetch GitHub PR comments.
58
- - `/autofix-pr` — apply review suggestions.
59
- - `/security-review` — run a security-focused review of pending changes.
60
-
61
- ### Misc
62
- - `/init` — scaffold or refresh `CODESHELL.md` / project rules based on repo state.
63
- - `/copy` — copy last response to clipboard.
64
- - `/undo` — undo the most recent file edit done by the agent.
65
- - `/update` — check for and install code-shell updates (auto-installs on exit when npm prefix is writable).
66
- - `/log` — open the session log file.
67
- - `/files` — list files the agent has touched this session.
68
- - `/release-notes` — show CHANGELOG for the running version.
69
- - `/feedback` — open the feedback URL.
70
- - `/voice` — voice input (if enabled).
71
-
72
- ## Provider + model setup
73
-
74
- code-shell uses a **two-layer config**: `providers[]` holds credentials and base URLs; `models[]` references a provider by key.
75
-
76
- - New users: `/login` runs the full wizard — pick provider kind (anthropic / openai / openrouter / deepseek / custom), enter API key, optional base URL, then pick a model from the fetched list.
77
- - Existing users with the legacy flat `models[]` shape: auto-migrated on startup with a `.bak` snapshot written next to `settings.json`.
78
- - Refresh a provider's model list: `/models` → select provider → Refresh. Cached for 7 days under `~/.code-shell/cache/`.
79
-
80
- ## settings.json — key fields
81
-
82
- Located at `~/.code-shell/settings.json` (user scope) or `.code-shell/settings.json` (project scope, takes precedence).
83
-
84
- - `providers[]` — `[{ key, kind, baseUrl, apiKey }]`. Source of credentials.
85
- - `models[]` — `[{ id, providerKey, displayName, contextLength, ... }]`.
86
- - `model` — the default active model id.
87
- - `autoUpdates` — `false` disables the background updater.
88
- - `permissions` — allow/deny rules for the Bash tool and others.
89
- - `hooks` — shell commands to run on events (SessionStart, PreToolUse, etc.).
90
- - `mcpServers` — `{ name: { command, args, env } }` map of MCP servers.
91
-
92
- ## Hooks
93
-
94
- Hooks are shell commands the harness runs on events. Configured in `settings.json` under `hooks`. Common events: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`. Use them for automated behaviors ("each time X happens, run Y") — memory or preferences can't do this because the model doesn't fire actions on schedule, the harness does.
95
-
96
- ## MCP servers
97
-
98
- `code-shell` speaks the Model Context Protocol. Add servers in `settings.json` under `mcpServers`. Each entry is a stdio command code-shell spawns; its tools/resources become available to the agent automatically. List with `/mcp`.
99
-
100
- ## Debugging
101
-
102
- - `CODE_SHELL_DEV=1 code-shell` — dev mode: enables the per-session verbose recorder (JSONL traces under `log/<date>/session-<sid>.jsonl`, 7-day retention), disables auto-update, shows extra UI.
103
- - `--debug` flag has the same effect as `CODE_SHELL_DEV=1`.
104
- - Logs: `~/.code-shell/log/` for general logs; per-session JSONL traces appear there when dev mode is on.
105
- - Investigation guard: re-reading the same file 3× is hard-blocked. 4+ consecutive read-only tool calls inject a "change strategy" reminder. This is intentional — break the loop, don't fight it.
106
- - Update install log: `~/.code-shell/update.log`.
107
-
108
- ## Memory
109
-
110
- code-shell has a per-project memory system at `.code-shell/memory/` (relative to project root) and a global one at `~/.code-shell/memory/`. The `MEMORY.md` index is auto-loaded into context every session. Individual memory files are loaded on demand. Edit with `/memory` or directly.
111
-
112
- ## Skills
113
-
114
- Skills are markdown files with frontmatter that get discovered automatically. Locations scanned:
115
- - `<cwd>/.code-shell/skills/` — project-level
116
- - `<cwd>/.claude/skills/` — project-level (Claude Code compat)
117
- - `~/.code-shell/skills/` — user-level
118
- - `~/.claude/skills/` — user-level (Claude Code compat)
119
- - Built-in skills shipped with the package (e.g. this one).
120
-
121
- List discovered skills with `/skills`. Invoke a skill with the `Skill` tool by name. Frontmatter `description` tells the model when to use it.
122
-
123
- ## Common questions
124
-
125
- **"How do I switch models?"** — `/model <id>` or pick from `/models`.
126
-
127
- **"How do I add a new provider?"** — `/login`, then follow the wizard. Or edit `settings.json` `providers[]` directly.
128
-
129
- **"Why is auto-update not working?"** — `/update` shows the disabled reason. Common: dev build, `DISABLE_AUTOUPDATER=1`, `settings.autoUpdates: false`, or the npm global prefix isn't writable (use the shown `sudo` command).
130
-
131
- **"Where's my session saved?"** — `~/.code-shell/sessions/<sid>/`. State, messages, and tool results all there.
132
-
133
- **"How do I see what tools an agent has?"** — `/tools`.
134
-
135
- **"How do I limit what Bash commands the agent can run?"** — `/permissions` or edit `settings.permissions` directly.