goatchain-cli 0.0.3-beta.1 → 0.0.3-beta.4

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.
package/README.md CHANGED
@@ -83,6 +83,24 @@ npx github:zjywill/GoatChain#main:packages/cli
83
83
 
84
84
  ## ⚙️ Configuration
85
85
 
86
+ ### Quick Setup with --save-config
87
+
88
+ Save your configuration once and reuse it across sessions:
89
+
90
+ ```bash
91
+ # Save configuration with DeepSeek API
92
+ npx goatchain-cli \
93
+ --model deepseek-v3.1 \
94
+ --api-key sk-your-key \
95
+ --base-url https://api.deepseek.com/v1 \
96
+ --save-config
97
+
98
+ # Now run without any arguments
99
+ npx goatchain-cli
100
+ ```
101
+
102
+ The `--save-config` flag saves your settings to `.goatchain/config.json` and exits without starting the CLI.
103
+
86
104
  ### Environment Variables
87
105
 
88
106
  ```bash
@@ -104,24 +122,33 @@ export GOATCHAIN_PLAN_MODE=1
104
122
 
105
123
  ### Local Configuration File
106
124
 
107
- Create `.goatchain/config.json` in your project:
125
+ The CLI automatically creates `.goatchain/config.json` when you use `--save-config`:
108
126
 
109
127
  ```json
110
128
  {
111
- "model": {
112
- "provider": "openai",
113
- "modelId": "gpt-4o"
129
+ "schemaVersion": 1,
130
+ "openai": {
131
+ "apiKey": "sk-...",
132
+ "baseUrl": "https://api.deepseek.com/v1"
133
+ },
134
+ "defaults": {
135
+ "modelId": "deepseek-v3.1",
136
+ "requestDefaults": {
137
+ "temperature": 0.7,
138
+ "maxOutputTokens": 2000
139
+ }
114
140
  },
115
141
  "tools": {
116
142
  "webSearch": {
117
143
  "apiKey": "your-serper-key",
118
144
  "numResults": 10
119
145
  }
120
- },
121
- "planMode": "on"
146
+ }
122
147
  }
123
148
  ```
124
149
 
150
+ **See [CLI Configuration Guide](../../docs/cli-configuration.md) for detailed configuration options.**
151
+
125
152
  ## 🎯 Commands Reference
126
153
 
127
154
  ### Core Commands
@@ -262,8 +289,28 @@ goatchain --base-url https://api.openai.com/v1
262
289
 
263
290
  # Configure request parameters
264
291
  goatchain --max-tokens 2000 --temperature 0.7
292
+
293
+ # Save configuration for future use
294
+ goatchain --model deepseek-v3.1 \
295
+ --api-key sk-your-key \
296
+ --base-url https://next-api.fazhiplus.com/v1 \
297
+ --save-config
298
+
299
+ # Auto-approve tool executions (for one-shot commands)
300
+ goatchain --auto-approval "read the README.md and summarize it"
265
301
  ```
266
302
 
303
+ ### Configuration Priority
304
+
305
+ Settings are resolved in the following order (highest to lowest):
306
+
307
+ 1. **Command-line arguments** - `--model`, `--api-key`, etc.
308
+ 2. **Environment variables** - `GOATCHAIN_MODEL`, `OPENAI_API_KEY`, etc.
309
+ 3. **Configuration file** - `.goatchain/config.json`
310
+ 4. **Default values**
311
+
312
+ When you pass CLI arguments (with or without `--save-config`), they automatically update the configuration file for future sessions.
313
+
267
314
  ### Integration with Projects
268
315
 
269
316
  ```bash
@@ -1,2 +1,2 @@
1
1
  import{Command as e,InvalidArgumentError as t}from"commander";function n(e){let t=String(e??``).trim().toLowerCase().replace(/[-\s]+/g,`_`);return t===`read`||t===`readonly`||t===`read_only`?`read_only`:t===`agent`||t===`default`?`agent`:t===`full`||t===`full_access`||t===`agent_full`||t===`agent_full_access`?`full_access`:`read_only`}function r(e){return e===`read_only`?`Read Only`:e===`agent`?`Agent (current)`:`Agent (full access)`}function i(e){return{strategy:`high_risk`,autoApprove:e.envAutoApprove===`1`||e.envAutoApprove===!0||e.mode!==`read_only`}}function a(e){return{allowOutsideWorkspace:e===`full_access`,allowNetwork:e===`full_access`||e===`read_only`}}function o(){return[``,`Interactive slash commands:`,` /help Show help`,` /clear Clear pending attachments`,` /approvals Select approval mode (interactive)`,` /model [id] Show/set model id`,` /workspace Switch workspace root (interactive)`,` /files Attach file(s) (interactive)`,` /images Attach image(s) (interactive)`,` /settings Base URL / API key / tokens`,` /config [--json] Print full config (secrets redacted)`,` /output Output & UX options`,` /agent Switch to agent mode (normal operation)`,` /plan Switch to plan mode (read-only planning with TodoWrite)`,` /diag Show last turn stop reason + tool calls`,` /diagnostics Alias for /diag`,` /edit Compose a message in $EDITOR`,` /multiline Start multiline input (.send/.cancel)`,` /set <k> <v> Set request param (maxTokens/temperature/topP/...)`,` /unset <k> Clear request param`,` /params Show current request params`,` /base-url <url> Set base URL (recreates client if needed)`,` /api-key <key> Set API key for this process (not printed)`,` /web-search-key <key> Set Serper API key for WebSearch tool (not printed)`,` /tools List enabled tools`,` /mcp [subcmd] MCP servers (connect/disconnect/tools)`,` /sessions List/pick/delete sessions`,` /use <sessionId> Switch session (restore history)`,` /rm <sessionId...> Delete session(s)`,` /save Save current session/config`,` /status Show current session/model info`,` /new Start a new conversation (clears history)`,` /compact Manually compress context (generate summary)`,` /exit Exit`,``,`Mentions:`,` @<query> Search workspace files/dirs (Enter inserts @path)`,``,`Keybindings:`,` (Type @ or / to show suggestions; filters as you type)`,` Tab Fill the selected suggestion`,` ↑/↓ Select a suggestion`,` Enter Run /command, or insert @workspace path selection`,` PgUp/PgDn/Home/End Scroll fullscreen log`,` Ctrl+K Open command palette`,` Ctrl+O Manage attachments`,` Ctrl+G Clear attachments`,``,`UI:`,` GOATCHAIN_UI=inline Disable fullscreen UI`,` GOATCHAIN_UI=legacy Disable interactive UI`,` GOATCHAIN_UI=full Force fullscreen UI`,` GOATCHAIN_THEME=dark Dark terminal theme (default)`,` GOATCHAIN_THEME=light Light terminal theme`,` GOATCHAIN_ANIMATE=0 Disable splash animation`,``,`Approvals:`,` GOATCHAIN_APPROVAL_MODE=read_only|agent|full_access`,` (You can also change this in-app via /approvals)`,``,`Image attachments:`,` (Also configurable via .goatchain/config.json -> ui.attachImages.*)`,` GOATCHAIN_ATTACH_IMAGES_NOTE_TEMPLATE=<text> Template supports {{items}}/{{count}}/{{json}}`,` GOATCHAIN_ATTACH_IMAGES_NOTE_POSITION=start|before_images|after_images|before_text|after_text|end`,` GOATCHAIN_ATTACH_IMAGES_IMAGES_POSITION=start|before_text|after_text|end`,` GOATCHAIN_ATTACH_IMAGES_DATA_URL_MODE=none|prefix|full`,` GOATCHAIN_ATTACH_IMAGES_MAX_DATA_URL_CHARS=8000`,``].join(`
2
- `)}function s(e){return n=>{let r=Number(n);if(!Number.isFinite(r))throw new t(`Invalid ${e}: ${n}`);return r}}function c(e){return n=>{let r=Number.parseInt(n,10);if(!Number.isFinite(r))throw new t(`Invalid ${e}: ${n}`);return r}}function l(t){return new e().name(`goatchain`).description(`A tiny interactive chat CLI built on agent-loop`).argument(`[prompt...]`,`one-shot prompt (omit to start interactive mode)`).option(`-k, --api-key <key>`,`OpenAI API key (or set OPENAI_API_KEY)`).option(`-m, --model <id>`,`Default model id (OpenAI)`).option(`--system <prompt>`,`System prompt`).option(`--base-url <url>`,`Override OpenAI base URL (proxy)`).option(`--serper-api-key <key>`,`Serper API key (enables WebSearch tool)`).option(`--web-search-api-key <key>`,`Alias for --serper-api-key`).option(`--serper-api-endpoint <url>`,`Serper API endpoint (WebSearch tool)`).option(`--web-search-api-endpoint <url>`,`Alias for --serper-api-endpoint`).option(`--serper-num-results <n>`,`Serper number of results (WebSearch tool)`,c(`serper-num-results`)).option(`--web-search-num-results <n>`,`Alias for --serper-num-results`,c(`web-search-num-results`)).option(`--max-tokens <n>`,`Max completion tokens`,c(`max-tokens`)).option(`--temperature <n>`,`Temperature (0-2)`,s(`temperature`)).option(`--top-p <n>`,`Top-p (0-1)`,s(`top-p`)).option(`--presence-penalty <n>`,`Presence penalty (-2..2)`,s(`presence-penalty`)).option(`--frequency-penalty <n>`,`Frequency penalty (-2..2)`,s(`frequency-penalty`)).option(`--seed <n>`,`Random seed`,c(`seed`)).option(`--timeout-ms <n>`,`Request timeout in ms`,c(`timeout-ms`)).option(`--session <id>`,`Use a saved session id (optional)`).version(t,`-v, --version`,`Show version`).helpOption(`-h, --help`,`Show help`).showHelpAfterError().showSuggestionAfterError().addHelpText(`after`,o())}function u(e,t){let n=l(t);n.parse(e,{from:`user`});let r=n.opts(),i=Array.isArray(n.args)?n.args.join(` `).trim():``,a=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,o=e=>typeof e==`number`&&Number.isFinite(e)?Math.trunc(e):void 0;return{apiKey:typeof r.apiKey==`string`&&r.apiKey.trim()?r.apiKey:void 0,modelId:typeof r.model==`string`&&r.model.trim()?r.model:void 0,system:typeof r.system==`string`&&r.system.trim()?r.system:void 0,baseUrl:typeof r.baseUrl==`string`&&r.baseUrl.trim()?r.baseUrl:void 0,webSearchApiKey:typeof r.webSearchApiKey==`string`&&r.webSearchApiKey.trim()?r.webSearchApiKey:typeof r.serperApiKey==`string`&&r.serperApiKey.trim()?r.serperApiKey:void 0,webSearchApiEndpoint:typeof r.webSearchApiEndpoint==`string`&&r.webSearchApiEndpoint.trim()?r.webSearchApiEndpoint:typeof r.serperApiEndpoint==`string`&&r.serperApiEndpoint.trim()?r.serperApiEndpoint:void 0,webSearchNumResults:typeof r.webSearchNumResults==`number`&&Number.isFinite(r.webSearchNumResults)?Math.trunc(r.webSearchNumResults):o(r.serperNumResults),maxTokens:o(r.maxTokens),temperature:a(r.temperature),topP:a(r.topP),presencePenalty:a(r.presencePenalty),frequencyPenalty:a(r.frequencyPenalty),seed:o(r.seed),timeoutMs:o(r.timeoutMs),sessionId:typeof r.session==`string`&&r.session.trim()?r.session:void 0,prompt:i}}export{a,r as i,o as n,i as o,u as r,n as s,l as t};
2
+ `)}function s(e){return n=>{let r=Number(n);if(!Number.isFinite(r))throw new t(`Invalid ${e}: ${n}`);return r}}function c(e){return n=>{let r=Number.parseInt(n,10);if(!Number.isFinite(r))throw new t(`Invalid ${e}: ${n}`);return r}}function l(t){return new e().name(`goatchain`).description(`A tiny interactive chat CLI built on agent-loop`).argument(`[prompt...]`,`one-shot prompt (omit to start interactive mode)`).option(`-k, --api-key <key>`,`OpenAI API key (or set OPENAI_API_KEY)`).option(`-m, --model <id>`,`Default model id (OpenAI)`).option(`--system <prompt>`,`System prompt`).option(`--base-url <url>`,`Override OpenAI base URL (proxy)`).option(`--save-config`,`Save config and exit (use with --api-key, --model, --base-url, etc.)`).option(`--auto-approval`,`Auto-approve all tool executions (for one-shot prompts)`).option(`--serper-api-key <key>`,`Serper API key (enables WebSearch tool)`).option(`--web-search-api-key <key>`,`Alias for --serper-api-key`).option(`--serper-api-endpoint <url>`,`Serper API endpoint (WebSearch tool)`).option(`--web-search-api-endpoint <url>`,`Alias for --serper-api-endpoint`).option(`--serper-num-results <n>`,`Serper number of results (WebSearch tool)`,c(`serper-num-results`)).option(`--web-search-num-results <n>`,`Alias for --serper-num-results`,c(`web-search-num-results`)).option(`--max-tokens <n>`,`Max completion tokens`,c(`max-tokens`)).option(`--temperature <n>`,`Temperature (0-2)`,s(`temperature`)).option(`--top-p <n>`,`Top-p (0-1)`,s(`top-p`)).option(`--presence-penalty <n>`,`Presence penalty (-2..2)`,s(`presence-penalty`)).option(`--frequency-penalty <n>`,`Frequency penalty (-2..2)`,s(`frequency-penalty`)).option(`--seed <n>`,`Random seed`,c(`seed`)).option(`--timeout-ms <n>`,`Request timeout in ms`,c(`timeout-ms`)).option(`--session <id>`,`Use a saved session id (optional)`).version(t,`-v, --version`,`Show version`).helpOption(`-h, --help`,`Show help`).showHelpAfterError().showSuggestionAfterError().addHelpText(`after`,o())}function u(e,t){let n=l(t);n.parse(e,{from:`user`});let r=n.opts(),i=Array.isArray(n.args)?n.args.join(` `).trim():``,a=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,o=e=>typeof e==`number`&&Number.isFinite(e)?Math.trunc(e):void 0;return{apiKey:typeof r.apiKey==`string`&&r.apiKey.trim()?r.apiKey:void 0,modelId:typeof r.model==`string`&&r.model.trim()?r.model:void 0,system:typeof r.system==`string`&&r.system.trim()?r.system:void 0,baseUrl:typeof r.baseUrl==`string`&&r.baseUrl.trim()?r.baseUrl:void 0,saveConfigOnly:!!r.saveConfig,autoApproval:!!r.autoApproval,webSearchApiKey:typeof r.webSearchApiKey==`string`&&r.webSearchApiKey.trim()?r.webSearchApiKey:typeof r.serperApiKey==`string`&&r.serperApiKey.trim()?r.serperApiKey:void 0,webSearchApiEndpoint:typeof r.webSearchApiEndpoint==`string`&&r.webSearchApiEndpoint.trim()?r.webSearchApiEndpoint:typeof r.serperApiEndpoint==`string`&&r.serperApiEndpoint.trim()?r.serperApiEndpoint:void 0,webSearchNumResults:typeof r.webSearchNumResults==`number`&&Number.isFinite(r.webSearchNumResults)?Math.trunc(r.webSearchNumResults):o(r.serperNumResults),maxTokens:o(r.maxTokens),temperature:a(r.temperature),topP:a(r.topP),presencePenalty:a(r.presencePenalty),frequencyPenalty:a(r.frequencyPenalty),seed:o(r.seed),timeoutMs:o(r.timeoutMs),sessionId:typeof r.session==`string`&&r.session.trim()?r.session:void 0,prompt:i}}const d=1e4;export{r as a,n as c,u as i,l as n,a as o,o as r,i as s,d as t};