erosolar-cli 1.0.1 → 1.0.2

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 (2) hide show
  1. package/README.md +277 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,277 @@
1
+ # Erosolar CLI
2
+
3
+ Erosolar CLI is a modular, profile aware command-line assistant that bundles a locally running AI agent, tool runtime, and capability registry into a single npm package. It ships with both the balanced **Erosolar** profile (`general`) and the deterministic **Erosolar Code** profile (`erosolar-code`), plus a provider registry that can drive OpenAI, Anthropic, DeepSeek, xAI Grok, Google Gemini, or any custom LLM you register. The CLI bootstraps a structured workspace context, exposes file/search/bash tooling, and lets you opt into external capabilities (like Tavily web search) without editing source code.
4
+
5
+ > This README is the canonical reference for the published npm module. Update it together with `SOURCE_OF_TRUTH.json` or `ARCHITECTURE.json` when behavior changes.
6
+
7
+ ## Why Erosolar CLI?
8
+
9
+ - **Single binary experience** – `npm i -g erosolar-cli` installs the interactive `erosolar` command and ready-to-run TypeScript runtime.
10
+ - **Profile aware** – switch between general reasoning or deterministic coding prompts via `/agents`, `--profile`, or environment overrides.
11
+ - **Provider agnostic** – swap between OpenAI, Anthropic, DeepSeek, xAI, Gemini, or custom providers without forking the CLI.
12
+ - **Deterministic tooling** – filesystem/search/bash tools log every invocation and emit reproducible summaries.
13
+ - **Composable runtime** – plug in new `CapabilityModule`s or `ToolPlugin`s to expose internal APIs, SaaS connectors, or research workflows.
14
+ - **Operator ergonomics** – bracketed paste handling, slash commands, saved preferences, and context summarization make long sessions manageable.
15
+
16
+ ## Installation
17
+
18
+ ### Prerequisites
19
+
20
+ - Node.js **20.0.0 or newer** (check with `node -v`).
21
+ - API keys for the models you plan to use (see [Provider support](#provider-support--api-keys)).
22
+ - macOS/Linux shell. Windows works inside WSL2.
23
+
24
+ ### Install the CLI
25
+
26
+ ```bash
27
+ npm install -g erosolar-cli # global install
28
+ # or keep it local
29
+ npm install erosolar-cli --save-dev
30
+ # or run ad-hoc without installing
31
+ npx erosolar --version
32
+ ```
33
+
34
+ Verify the install:
35
+
36
+ ```bash
37
+ erosolar --help
38
+ ```
39
+
40
+ The binary lives at `dist/bin/erosolar.js` and is exposed through the `erosolar` bin entry.
41
+
42
+ ## Quick Start
43
+
44
+ 1. **Launch the shell**
45
+ ```bash
46
+ erosolar # boots the default erosolar-code profile
47
+ erosolar --profile general # balanced workflow
48
+ erosolar "Explain src/index.ts" # run once without entering REPL
49
+ ```
50
+ 2. **Configure secrets** – inside the shell run `/secrets` and paste your `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, etc. Secrets are saved to `~/.codex/secrets.json` (override with `CODEX_HOME`).
51
+ 3. **Choose a model** – run `/model` to switch providers or presets (OpenAI GPT-5, Claude, DeepSeek, Grok, Gemini, …). Preferences persist in `~/.erosolar/settings.json`.
52
+ 4. **Toggle tools** – `/tools` enables/disables filesystem, search, bash, or Tavily suites per profile.
53
+ 5. **Chat or automate** – type instructions, paste code blocks (bracketed paste supported), or kick off `/agents` to switch the default profile for future launches.
54
+
55
+ The shell prints every tool invocation (e.g., `Read(src/app.ts)`), shows diffs for writes, and summarizes bash output so you can audit what happened.
56
+
57
+ ## CLI Basics
58
+
59
+ ### Launch options
60
+
61
+ - `erosolar` – start interactive mode (default profile `erosolar-code`).
62
+ - `erosolar "Fix lint"` – run a single turn and exit.
63
+ - `erosolar --profile general` / `-p general` – override profile.
64
+ - `EROSOLAR_PROFILE=general erosolar` – set default profile via env var.
65
+
66
+ ### Slash commands
67
+
68
+ | Command | Description |
69
+ |-------------|-------------|
70
+ | `/model` | Choose provider/model, temperature, max tokens, or thought level presets (direct/balanced/deep). |
71
+ | `/secrets` | List, add, or update API keys. Stored encrypted-at-rest in `~/.codex/secrets.json`. |
72
+ | `/tools` | Enable/disable capability suites (filesystem, search, bash, Tavily). Preferences save to `~/.erosolar/settings.json`. |
73
+ | `/agents` | (When enabled) switch the default profile for future launches. |
74
+ | `/clear` | Reset the working conversation. |
75
+ | `/log` | Show the recent transcript. |
76
+ | `/exit` | Quit the shell. |
77
+
78
+ ## Agent Profiles
79
+
80
+ | Name | Label | Default provider/model | Intent | Env overrides |
81
+ |-----------------|----------------|------------------------|--------|---------------|
82
+ | `general` | **Erosolar** | OpenAI `gpt-5.1` | Balanced research/writing/coding. | `GENERAL_MODEL`, `GENERAL_PROVIDER`, `GENERAL_SYSTEM_PROMPT` |
83
+ | `erosolar-code` | **Erosolar Code** | OpenAI `gpt-5.1-codex` | Rapid, deterministic code edits with aggressive tool usage. | `EROSOLAR_CODE_MODEL`, `EROSOLAR_CODE_PROVIDER`, `EROSOLAR_CODE_SYSTEM_PROMPT` |
84
+
85
+ Each profile is registered in `src/config.ts`. Add new profiles via `registerAgentProfile()` or override defaults with environment variables before launching the CLI. `EROSOLAR_PROFILE` selects which profile boots by default.
86
+
87
+ ## Provider support & API keys
88
+
89
+ | Provider ID | Sample models | Required secret | CLI usage |
90
+ |-------------|---------------|-----------------|-----------|
91
+ | `openai` | `gpt-5.1`, `gpt-5.1-codex`, `gpt-5-pro`, `gpt-5-mini`, `gpt-5-nano` | `OPENAI_API_KEY` | `/model → OpenAI` |
92
+ | `anthropic` | `claude-sonnet-4.5`, `claude-opus-4.1`, `claude-haiku-4.5` | `ANTHROPIC_API_KEY` | `/model → Anthropic` |
93
+ | `deepseek` | `deepseek-reasoner`, `deepseek-chat` | `DEEPSEEK_API_KEY` | `/model → DeepSeek` |
94
+ | `xai` | `grok-4`, `grok-4-fast-reasoning`, `grok-4-fast-non-reasoning`, `grok-code-fast-1` | `XAI_API_KEY` | `/model → xAI` |
95
+ | `google` | `gemini-2.5-pro`, `gemini-2.5-flash` | `GEMINI_API_KEY` | `/model → Google Gemini` |
96
+ | `tavily` | `tavily_search`, `tavily_extract` tools | `TAVILY_API_KEY` | Enable via `/tools` |
97
+
98
+ Secrets are read from environment variables first, then from `~/.codex/secrets.json`. Use `/secrets` to manage them interactively.
99
+
100
+ ## Built-in tools & capability suites
101
+
102
+ The CLI composes tools via `CapabilityModule`s. The default Node runtime registers:
103
+
104
+ - **Filesystem suite (`filesystemCapability.ts`)** – `read_file`, `write_file` (with diff previews), `list_files`, `search_files`. Uses deterministic ignore lists and protects against accidental binary writes.
105
+ - **Search suite (`searchCapability.ts`)** – `grep_search`, `find_definition` over repo text. Regex friendly, case sensitive toggle, built-in binary detection.
106
+ - **Bash suite (`bashCapability.ts`)** – `execute_bash` runs commands inside a sandbox rooted at `<workspace>/.erosolar/shell-sandbox`. HOME/TMP/XDG paths are rewritten unless `EROSOLAR_PRESERVE_HOME=1` is set. Streaming mode placeholder exists (`execute_bash_stream`).
107
+ - **Tavily suite (`tavilyCapability.ts`)** – opt-in live web search/extract. Requires `TAVILY_API_KEY` and the `/tools` toggle.
108
+ - **Runtime metadata tools (`core/toolRuntime.ts`)** – `context_snapshot`, `capabilities_overview`, `profile_details` for deterministic context recall.
109
+
110
+ Tool invocations are narrated via the interactive shell (`Read(src/api.ts)`, `Bash(npm test)`). Warnings surface when tools are disabled or missing secrets so you can remediate without rerunning the CLI.
111
+
112
+ ## Workspace context & prompts
113
+
114
+ On launch, `buildWorkspaceContext()` (see `src/workspace.ts`) captures:
115
+
116
+ 1. The current working directory path.
117
+ 2. A trimmed file tree (depth 2, up to 200 entries, ignoring `.git`, `node_modules`, `dist`).
118
+ 3. Contents/snippets of `README.md`, `SOURCE_OF_TRUTH.json`, `ARCHITECTURE.json`, and `package.json` when present.
119
+
120
+ The snapshot is appended to the active system prompt and exposed via the `context_snapshot` tool so the agent always has a deterministic view of the repo even before reading files manually.
121
+
122
+ ## Architectural overview
123
+
124
+ ```
125
+ ┌────────────┐ ┌────────────────┐ ┌─────────────┐ ┌──────────────┐
126
+ │ Interactive│→→│ AgentSession │→→│ AgentRuntime │→→│ Provider SDK │
127
+ │ Shell │ │ (profile/model │ │ (conversation│ │ (OpenAI, etc.)│
128
+ │ (/model…) │ │ resolution) │ │ loop + tools)│ │ │
129
+ └────┬───────┘ └────────┬───────┘ └──────┬──────┘ └──────┬───────┘
130
+ │ Workspace context │ ToolRuntime/logging │
131
+ ▼ ▼ ▼
132
+ Capability modules (filesystem/search/bash/Tavily/…) loaded via AgentHost/RuntimeAdapter
133
+ ```
134
+
135
+ - **Interactive shell (`src/shell/interactiveShell.ts`)** renders prompts, manages slash commands, handles bracketed paste, streams assistant tokens, and persists preferences.
136
+ - **AgentHost (`src/runtime/agentHost.ts`)** loads capability modules and resolves tool suites before the session starts.
137
+ - **CapabilityModule interface** describes any pluggable feature: return tool suites, metadata, and teardown logic. Modules can be registered by adapters, plugins, or downstream apps.
138
+ - **RuntimeAdapter (`src/adapters/types.ts`)** creates modules for specific targets (Node CLI, browser sandbox, server worker). The Node adapter wires in filesystem/search/bash/Tavily plugins.
139
+ - **AgentSession (`src/runtime/agentSession.ts`)** resolves the profile config, builds the tool runtime, and instantiates providers.
140
+ - **AgentRuntime (`src/core/agent.ts`)** runs the LLM loop, interleaving provider calls and tool execution.
141
+
142
+ Thanks to this separation, you can reuse the runtime in Electron apps, remote agents, or serverless workers without rewriting orchestration.
143
+
144
+ ## Extending the CLI
145
+
146
+ ### Add a custom capability
147
+
148
+ ```ts
149
+ import type { CapabilityModule, CapabilityContext, CapabilityContribution } from 'erosolar-cli/runtime';
150
+
151
+ export class MyApiCapability implements CapabilityModule {
152
+ id = 'capability.my_api';
153
+ async create(context: CapabilityContext): Promise<CapabilityContribution> {
154
+ return {
155
+ id: 'my_api.tools',
156
+ description: 'Custom SaaS actions',
157
+ toolSuite: {
158
+ id: 'my-api',
159
+ tools: [
160
+ {
161
+ name: 'create_ticket',
162
+ description: 'Open a ticket via REST',
163
+ parameters: { type: 'object', properties: { title: { type: 'string' } }, required: ['title'] },
164
+ handler: async ({ title }) => {
165
+ const url = await createTicket(title as string, context.env.MY_API_TOKEN);
166
+ return `Opened ticket ${url}`;
167
+ },
168
+ },
169
+ ],
170
+ },
171
+ };
172
+ }
173
+ }
174
+ ```
175
+
176
+ Register it via a tool plugin:
177
+
178
+ ```ts
179
+ import { registerToolPlugin } from 'erosolar-cli/plugins/tools';
180
+ registerToolPlugin({
181
+ id: 'tool.my_api',
182
+ targets: ['node', 'cloud'],
183
+ create: () => new MyApiCapability(),
184
+ });
185
+ ```
186
+
187
+ ### Register another provider
188
+
189
+ ```ts
190
+ import { registerProvider } from 'erosolar-cli/providers/providerFactory.js';
191
+ registerProvider('my-llm', (config) => new MyProviderSdk({
192
+ apiKey: process.env.MY_API_KEY!,
193
+ model: config.model,
194
+ }));
195
+ ```
196
+
197
+ Expose it through `/model` by adding presets in `src/shell/interactiveShell.ts`.
198
+
199
+ ### Add an agent profile
200
+
201
+ ```ts
202
+ import { registerAgentProfile } from 'erosolar-cli/core/agentProfiles.js';
203
+ registerAgentProfile({
204
+ name: 'docs',
205
+ label: 'Docs Agent',
206
+ description: 'Summaries only',
207
+ defaultProvider: 'openai',
208
+ defaultModel: 'gpt-5-mini',
209
+ defaultSystemPrompt: 'Only answer with documentation.',
210
+ });
211
+ ```
212
+
213
+ ## Configuration reference
214
+
215
+ - `EROSOLAR_PROFILE` – boot this profile unless `--profile` overrides it.
216
+ - `<PROFILE>_MODEL`, `<PROFILE>_PROVIDER`, `<PROFILE>_SYSTEM_PROMPT` – lock a profile to custom defaults. Examples: `GENERAL_MODEL=claude-sonnet-4.5`, `EROSOLAR_CODE_SYSTEM_PROMPT="..."`.
217
+ - `EROSOLAR_PRESERVE_HOME=1` – skip rewriting `$HOME`/`XDG_*` paths when running bash commands.
218
+ - `CODEX_HOME` – change where CLI secrets are stored (defaults to `~/.codex`).
219
+ - `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `DEEPSEEK_API_KEY`, `XAI_API_KEY`, `GEMINI_API_KEY`, `TAVILY_API_KEY` – provider credentials.
220
+ - `GENERAL_MODEL`, `EROSOLAR_CODE_MODEL` – shorthand for the two built-in profiles.
221
+ - `PATH`, `TMPDIR`, etc. – inherited by bash tools after sandboxing.
222
+
223
+ User preferences (model presets, enabled tools, saved profile) live in `~/.erosolar/settings.json`.
224
+
225
+ ## Development workflow
226
+
227
+ ```bash
228
+ git clone https://github.com/bo/bo-cli.git
229
+ cd bo-cli
230
+ npm install
231
+ npm run dev # ts-node/tsx entry for iterating without building
232
+ npm run build # clean + tsc compile to dist/
233
+ npm run start # run the compiled CLI
234
+ npm run clean # remove dist/
235
+ ```
236
+
237
+ Notes:
238
+
239
+ - The repo uses strict ES modules and TypeScript 5.3+.
240
+ - `dist/bin/erosolar.js` must stay executable; `npm run postbuild` sets `chmod 755`.
241
+ - Keep new files ASCII by default; use comments sparingly (see `apply_patch` guidelines in this repo).
242
+ - `ARCHITECTURE.json`, `MODULAR_RUNTIME.md`, and `Agents.md` document the same defaults—update them if you change prompts or modules.
243
+
244
+ ## Release & publishing checklist
245
+
246
+ 1. Update docs/metadata (README, `package.json` description, architectural JSON files if needed).
247
+ 2. Run `npm run build` to refresh `dist/`.
248
+ 3. Inspect the diff and run any smoke tests (e.g., `npx tsx src/bin/erosolar.ts --version`).
249
+ 4. Bump the version: `npm version patch` (or `minor`/`major`) to keep npm in sync.
250
+ 5. Publish: `npm publish`.
251
+ 6. Verify on npmjs.com that the README renders and the new version lists the correct files.
252
+
253
+ The `files` array in `package.json` already limits what goes to npm (`dist`, README, docs JSON, license, preinstall script).
254
+
255
+ ## Repository layout
256
+
257
+ - `src/bin/erosolar.ts` – CLI entrypoint.
258
+ - `src/shell/` – interactive shell UX, slash commands, tool logging.
259
+ - `src/runtime/` – AgentHost, AgentSession, adapters.
260
+ - `src/capabilities/` & `src/tools/` – filesystem/search/bash/Tavily implementations.
261
+ - `src/plugins/` – provider + tool plugin registries.
262
+ - `src/providers/` – LLM client shims (OpenAI Responses, Chat Completions, etc.).
263
+ - `src/core/` – agent runtime, tool runtime, preferences, secrets.
264
+ - `dist/` – compiled JS published to npm (generated by `npm run build`).
265
+
266
+ ## Troubleshooting
267
+
268
+ - **“Missing required environment variable …”** – run `/secrets` or export the needed API key before launching. Provider plugins throw if secrets are absent.
269
+ - **“Provider X is not registered”** – ensure you imported the plugin that registers it (`registerDefaultProviderPlugins()` is called automatically in `AgentSession`; custom runtimes must do the same).
270
+ - **Filesystem writes fail or appear outside the repo** – bash commands run inside `<workspace>/.erosolar/shell-sandbox`. Set `EROSOLAR_PRESERVE_HOME=1` if you need real HOME access (only when safe).
271
+ - **Context too large** – the shell automatically summarizes older transcripts when 90% of the context window is used, but you can force `/clear` to reset.
272
+ - **Node <20** – install the required LTS (`nvm install 20 && nvm use 20`).
273
+ - **Publishing errors** – ensure you are logged in to npm (`npm whoami`), bump the version, and verify `npm run build` before `npm publish`.
274
+
275
+ ## License
276
+
277
+ MIT © Erosolar AI. See `LICENSE` for the full text.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "erosolar-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Modular Erosolar CLI with general + Erosolar Code profiles and pluggable providers",
5
5
  "main": "dist/bin/erosolar.js",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "scripts/preinstall-clean-bins.mjs"
15
15
  ],
16
16
  "bin": {
17
- "erosolar": "./dist/bin/erosolar.js"
17
+ "erosolar": "dist/bin/erosolar.js"
18
18
  },
19
19
  "scripts": {
20
20
  "preinstall": "node scripts/preinstall-clean-bins.mjs",