saarthiclaw 0.0.0-stage → 0.2.1
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/CHANGELOG.md +54 -0
- package/LICENSE +21 -0
- package/README.md +335 -2
- package/dist/chunks/chunk-2GDAWRT7.js +339 -0
- package/dist/chunks/chunk-2OOG5CBM.js +12 -0
- package/dist/chunks/chunk-4CNBITFA.js +106 -0
- package/dist/chunks/chunk-4YYY2YOT.js +389 -0
- package/dist/chunks/chunk-5WH3FNFK.js +147 -0
- package/dist/chunks/chunk-BTFIQWAE.js +185 -0
- package/dist/chunks/chunk-E4DRW4AW.js +126 -0
- package/dist/chunks/chunk-EG5A2Q6X.js +121 -0
- package/dist/chunks/chunk-G6GCAEKE.js +64 -0
- package/dist/chunks/chunk-GSBUJPPF.js +135 -0
- package/dist/chunks/chunk-HGBZ55ND.js +80 -0
- package/dist/chunks/chunk-IT46XDPQ.js +100 -0
- package/dist/chunks/chunk-MMIJKDOU.js +35 -0
- package/dist/chunks/chunk-OICPXSO2.js +93 -0
- package/dist/chunks/chunk-OS5GVLKA.js +502 -0
- package/dist/chunks/chunk-QFVMJJQY.js +411 -0
- package/dist/chunks/chunk-QRAFFI5V.js +356 -0
- package/dist/chunks/chunk-R7ID2QVW.js +39 -0
- package/dist/chunks/chunk-SANS45ER.js +41 -0
- package/dist/chunks/chunk-SKYTL7AH.js +83 -0
- package/dist/chunks/chunk-VAP6FVF5.js +319 -0
- package/dist/chunks/chunk-XTVJWMUH.js +143 -0
- package/dist/chunks/chunk-ZXVP7JFV.js +232 -0
- package/dist/chunks/client-5WRI2PBK.js +18 -0
- package/dist/chunks/config-PA5NJ37O.js +27 -0
- package/dist/chunks/context-AP3U34DQ.js +20 -0
- package/dist/chunks/doctor-O3R2YTRO.js +170 -0
- package/dist/chunks/errors-ZXTAHCZI.js +13 -0
- package/dist/chunks/history-FANJN33X.js +54 -0
- package/dist/chunks/init-GCJNYE3Y.js +199 -0
- package/dist/chunks/orchestrator-4SMA442I.js +24 -0
- package/dist/chunks/orchestrator-CYIGQH74.js +32 -0
- package/dist/chunks/orchestrator-L4TOOHXY.js +23 -0
- package/dist/chunks/prompter-AAH4A3BG.js +14 -0
- package/dist/chunks/session-FPFJMS7Y.js +19 -0
- package/dist/chunks/signals-ZO4DZ4OK.js +18 -0
- package/dist/chunks/store-KW257WIV.js +40 -0
- package/dist/chunks/sync-S2A65FIE.js +21 -0
- package/dist/chunks/team-OFNBRXVP.js +378 -0
- package/dist/chunks/telegram-LPSIQBQX.js +483 -0
- package/dist/chunks/wakeup-M5EIP54K.js +167 -0
- package/dist/chunks/workspace-PFJUEHAB.js +10 -0
- package/dist/index.js +215 -0
- package/package.json +68 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. This project follows [Semantic Versioning](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
## 0.2.1 — 2026-11-18
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- **Keys are saved per project folder.** Two folders on one computer (for example the Admin's copy and a teammate's copy during a demo) keep separate keys; no `SAARTHICLAW_HOME` trick needed. A copied project folder never inherits someone else's key: it asks for its own `team connect`. Keys saved by 0.2.0 must be connected once more.
|
|
9
|
+
- After sending changes for approval, the agent offers to **wait right there** and applies them as soon as the Admin approves — one command instead of `agent` + `team sync --wait`.
|
|
10
|
+
- `team connect` asks before switching a folder to a different person (wrong key pasted), warns when the folder has no AI key yet, and prints the next command for your level. On a fresh dashboard it asks to *link* the folder (not "update").
|
|
11
|
+
- `team invite <name>` for someone already on the team offers a new key instead of creating a duplicate member.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- **Team mode** with the SaarthiClaw web dashboard: `saarthiclaw team connect | status | sync | suggest | invite | inbox | disconnect`, plus a 👥 Team entry in the main menu.
|
|
17
|
+
- Permission levels decide what happens after Agent / Plan / Ask `--save`:
|
|
18
|
+
- Admin and Trusted review and apply locally; the result is logged on the dashboard.
|
|
19
|
+
- Needs approval sends the changes to the Admin, and `team sync` applies the approved ones.
|
|
20
|
+
- Suggest only sends a suggestion instead.
|
|
21
|
+
- `team sync --wait` waits for the Admin's decision and applies as soon as it arrives.
|
|
22
|
+
- Approved changes are applied only if the file still matches the version the agent saw (SHA-256), so an approval never overwrites newer work.
|
|
23
|
+
- `doctor` reports the team connection; `init` mentions team mode.
|
|
24
|
+
- New audit event `submitted` (sent for approval; nothing written).
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- Agent, Plan and Ask `--save` share one final review/apply step (`team/finalize.ts`); solo behaviour is unchanged.
|
|
28
|
+
- Telegram remote control is limited to the Admin and Trusted members when a project is in team mode.
|
|
29
|
+
|
|
30
|
+
## 0.1.0 — 2026-11-17
|
|
31
|
+
|
|
32
|
+
First public release on npm.
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- `saarthiclaw` binary for Node.js ≥ 22.12 (no Bun required); `saarthiclaw-build` kept as an alias.
|
|
36
|
+
- Commands: `wakeup` (aliases `wake`, `start`; also the default in a terminal), `init`, `doctor`, `ask`, `plan`, `agent`, `telegram`, `history`.
|
|
37
|
+
- Global options: `--cwd`, `--model`, `--allow-shell`, `--debug`, `--no-banner`, `--version`, `--help`.
|
|
38
|
+
- Configuration resolution: flags → env → project `.env` → `.saarthiclaw/config.json` → `~/.saarthiclaw/config.json`, validated with zod.
|
|
39
|
+
- Guided, idempotent `init` that writes secrets to `.env`, settings to `.saarthiclaw/config.json`, updates `.gitignore` and can add an npm script.
|
|
40
|
+
- Project brief (package.json summary, stack hints, shallow file tree, README excerpt) and mode-specific instructions injected into every agent.
|
|
41
|
+
- Approval flow with risk labels, colourised diffs, deletion warnings, verbatim shell commands, extra confirmation for high-risk items and a final "Apply N changes?" step.
|
|
42
|
+
- Transactional apply with rollback of file changes on failure.
|
|
43
|
+
- Audit trail in `.saarthiclaw/logs/actions.jsonl` and `saarthiclaw history`.
|
|
44
|
+
- Friendly error messages for missing/invalid keys, credits, rate limits (with automatic retries), unknown models, network failures and timeouts.
|
|
45
|
+
- Ctrl+C cancels a running AI task cleanly and discards staged changes.
|
|
46
|
+
|
|
47
|
+
### Reliability
|
|
48
|
+
- Planning always produces a plan, even when a model loops on tools; repeated identical tool calls are short-circuited and every run's final step must produce an answer.
|
|
49
|
+
- Ask mode reads the real code instead of relying on the README.
|
|
50
|
+
|
|
51
|
+
### Security
|
|
52
|
+
- Shell execution is off by default everywhere; destructive commands are flagged.
|
|
53
|
+
- Workspace jail (no `..`, outside absolute paths or escaping symlinks) and a fixed secret blocklist (`.env*`, keys, `.npmrc`, `.saarthiclaw/`).
|
|
54
|
+
- Telegram: every update from a non-owner is dropped by a global guard.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hritik Vishnoi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,336 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SaarthiClaw
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**An AI developer assistant that lives in your project's terminal — the AI proposes, you approve.**
|
|
4
|
+
|
|
5
|
+
SaarthiClaw is like a very capable intern who always asks the senior first.
|
|
6
|
+
It reads your codebase, answers questions, drafts plans and stages code changes — but nothing touches your disk until you have reviewed the diff and said yes.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install --save-dev saarthiclaw
|
|
10
|
+
npx saarthiclaw init # one-time setup
|
|
11
|
+
npx saarthiclaw # wake it up
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Contents
|
|
17
|
+
|
|
18
|
+
- [Install](#install)
|
|
19
|
+
- [60-second quick start](#60-second-quick-start)
|
|
20
|
+
- [The modes](#the-modes)
|
|
21
|
+
- [How approval works](#how-approval-works)
|
|
22
|
+
- [Safety model](#safety-model)
|
|
23
|
+
- [Working with a team](#working-with-a-team)
|
|
24
|
+
- [Configuration](#configuration)
|
|
25
|
+
- [Command reference](#command-reference)
|
|
26
|
+
- [Telegram setup](#telegram-setup)
|
|
27
|
+
- [Free models and rate limits](#free-models-and-rate-limits)
|
|
28
|
+
- [Troubleshooting](#troubleshooting)
|
|
29
|
+
- [FAQ](#faq)
|
|
30
|
+
- [Roadmap](#roadmap)
|
|
31
|
+
- [Contributing](#contributing)
|
|
32
|
+
- [Publishing (maintainers)](#publishing-maintainers)
|
|
33
|
+
- [License](#license)
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
Requires **Node.js 22.12 or newer** (no Bun needed). Works on macOS, Linux and Windows.
|
|
38
|
+
|
|
39
|
+
As a dev dependency of the project you want help with (recommended — it becomes that project's "plugin"):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cd my-project
|
|
43
|
+
npm install --save-dev saarthiclaw
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or globally:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install -g saarthiclaw
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
You also need an [OpenRouter API key](https://openrouter.ai/keys) (free models are available).
|
|
53
|
+
|
|
54
|
+
## 60-second quick start
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx saarthiclaw init # paste your OpenRouter key, pick a model, choose safety options
|
|
58
|
+
npx saarthiclaw wakeup # banner → pick CLI (Ask / Plan / Agent) or Telegram
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`init` writes your key to the project's `.env`, settings to `.saarthiclaw/config.json`, makes sure both are git-ignored, and (optionally) adds an npm script so `npm run saarthiclaw` opens the menu.
|
|
62
|
+
|
|
63
|
+
Check everything is wired up with:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx saarthiclaw doctor
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## The modes
|
|
70
|
+
|
|
71
|
+
### 💬 Ask — questions about your codebase (read-only)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx saarthiclaw ask "Where is the JWT verified and what happens when it expires?"
|
|
75
|
+
npx saarthiclaw ask "Summarise the database layer" --save notes.md
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Ask uses read-only tools (read / list / search files, analyse structure) and cites the file paths it relied on.
|
|
79
|
+
With `--save`, the answer is staged as a Markdown file and goes through the normal approval flow.
|
|
80
|
+
Web search is added automatically when a `FIRECRAWL_API_KEY` is configured.
|
|
81
|
+
|
|
82
|
+
### ✍️ Plan — a step-by-step plan, then execution
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx saarthiclaw plan "Add rate limiting to the public API routes"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
1. SaarthiClaw researches the code (read-only) and prints a numbered plan with complexity labels.
|
|
89
|
+
2. Optionally save it as `PLAN.md`.
|
|
90
|
+
3. Tick the steps you want (space toggles), confirm.
|
|
91
|
+
4. Each selected step runs with the agent (`Step 2/5 — Add middleware`), all sharing one staging area.
|
|
92
|
+
5. One approval screen at the end shows every staged change from every step.
|
|
93
|
+
|
|
94
|
+
### 🕵️ Agent — make changes with your sign-off
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx saarthiclaw agent "Add a /health route that returns the package version"
|
|
98
|
+
npx saarthiclaw agent "Upgrade zod usage to the new API and run the tests" --allow-shell
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The agent reads files, then **stages** creates, modifications, deletions, new folders and (only if you allowed it) shell commands.
|
|
102
|
+
You see progress (`✓ read_file {"path":"src/server.ts"}`), a summary table of staged actions with risk labels, and then the approval flow.
|
|
103
|
+
Press **Ctrl+C** during a run to cancel cleanly: staging is discarded and nothing is written.
|
|
104
|
+
|
|
105
|
+
### 📱 Telegram — the same engine from your phone
|
|
106
|
+
|
|
107
|
+
Pick **Telegram** in the menu (or run `npx saarthiclaw telegram`). Commands: `/ask`, `/agent`, `/plan`, `/help`. Only the configured owner can use the bot. See [Telegram setup](#telegram-setup).
|
|
108
|
+
|
|
109
|
+
## How approval works
|
|
110
|
+
|
|
111
|
+
After a run you get a table like:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
Type Path / command Risk
|
|
115
|
+
────── ──────────────────────── ──────
|
|
116
|
+
create src/routes/health.ts LOW
|
|
117
|
+
modify src/server.ts MEDIUM
|
|
118
|
+
delete src/old-health.ts HIGH
|
|
119
|
+
shell npm test HIGH
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Then choose **Review one by one**, **Approve all** or **Reject all**:
|
|
123
|
+
|
|
124
|
+
- **Modifications** show a colourised unified diff (you can re-show it).
|
|
125
|
+
- **Deletions** show a clear red warning.
|
|
126
|
+
- **Shell commands** are shown verbatim, with warnings if they look destructive.
|
|
127
|
+
- **High-risk** items (deletions, shell commands) need a second, explicit "Really approve this?" — even after "Approve all".
|
|
128
|
+
- Every per-change prompt starts on **Reject**, so pressing Enter never approves by accident. Very fast repeated keypresses are ignored.
|
|
129
|
+
- Several edits to the same file are reviewed together as one item (labelled "N edits combined").
|
|
130
|
+
- You see a list of what will be applied and what will be skipped, then a final **"Apply 3 changes (skip 1)?"** confirmation, which defaults to **No**. Saying no writes nothing.
|
|
131
|
+
|
|
132
|
+
Risk levels: **low** = new file / new folder, **medium** = modify, **high** = delete or shell.
|
|
133
|
+
|
|
134
|
+
If applying a file change fails half-way, every file change from that batch is **rolled back** and shell commands are skipped.
|
|
135
|
+
|
|
136
|
+
## Safety model
|
|
137
|
+
|
|
138
|
+
| Guard | What it does |
|
|
139
|
+
| --- | --- |
|
|
140
|
+
| Shell **off** by default | The shell tool is not even offered to the model unless you pass `--allow-shell`, set `allowShellExecution: true`, or say yes to "Allow shell commands in this session?" at the start of Agent mode. Every command still needs per-command approval. |
|
|
141
|
+
| Destructive-command detection | `rm -rf`, `sudo`, `curl … \| sh`, `chmod -R`, `git push --force`, `git reset --hard`, `del /s`, paths outside the workspace, etc. are flagged in red. |
|
|
142
|
+
| Workspace jail | Every path from the model is resolved against the project root. `..` escapes, absolute paths outside the root, Windows drive/UNC paths and symlinks that point outside are rejected. |
|
|
143
|
+
| Secrets are invisible | `.env*`, `*.pem`, `*.key`, `id_rsa*`, `.npmrc`, `.ssh/`, `.aws/` and `.saarthiclaw/` can never be read, listed, written or deleted by tools. They are also never included in the project brief. |
|
|
144
|
+
| Size limits | Reads are capped (`maxFileSizeToRead`, 1 MiB) and tool output sent to the model is truncated (`maxToolOutputChars`, 20 000). |
|
|
145
|
+
| Audit log | Every staged / approved / rejected / applied / failed event is appended to `.saarthiclaw/logs/actions.jsonl` (timestamp, mode, type, path, risk, status — never file contents or commands). View it with `saarthiclaw history`. |
|
|
146
|
+
| Keys never logged | API keys are masked in `init`, `doctor` and `--debug` output. |
|
|
147
|
+
|
|
148
|
+
## Working with a team
|
|
149
|
+
|
|
150
|
+
Working alone needs none of this. With a team, SaarthiClaw connects to the **SaarthiClaw web dashboard** (a separate app the Admin runs). One person is the **Admin**; everyone else gets their own access key and a permission level the Admin can change at any time.
|
|
151
|
+
|
|
152
|
+
| Level | What happens when the agent finishes |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| **Admin** | You review and apply in your terminal, as in solo mode. Each applied change is also logged on the dashboard. |
|
|
155
|
+
| **Trusted** | Same as Admin: you approve your own changes; they are logged on the dashboard. |
|
|
156
|
+
| **Needs approval** (default) | Nothing is written. The changes go to the dashboard; the Admin approves or rejects each one. Then `saarthiclaw team sync` applies the approved ones on your computer. |
|
|
157
|
+
| **Suggest only** | Ask and Plan work; the agent can't change code. Your idea is sent as a suggestion instead. |
|
|
158
|
+
|
|
159
|
+
**Admin, once:**
|
|
160
|
+
```bash
|
|
161
|
+
npx saarthiclaw team connect http://127.0.0.1:3000 # paste the Admin key the dashboard printed on its first `npm start`
|
|
162
|
+
npx saarthiclaw team invite Riya --level needs-approval # prints Riya's one-time key
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Each developer, once (in their own copy of the project):**
|
|
166
|
+
```bash
|
|
167
|
+
npx saarthiclaw team connect http://<admin-address>:3000 # paste your key
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Day to day (Needs approval) — one command:**
|
|
171
|
+
```bash
|
|
172
|
+
npx saarthiclaw agent "validate todo text"
|
|
173
|
+
# → review the diff → "Send all for approval" → "Wait here?" Yes
|
|
174
|
+
# the Admin approves on the dashboard → the change is applied here a few seconds later
|
|
175
|
+
```
|
|
176
|
+
Closed the terminal before the Admin decided? `npx saarthiclaw team sync` applies whatever was approved since.
|
|
177
|
+
|
|
178
|
+
How it stays safe:
|
|
179
|
+
- **The dashboard never touches files.** It stores the proposal and the decision; your own terminal applies it.
|
|
180
|
+
- **No overwriting newer work.** Each proposal carries a hash of the file it was based on. If the file changed since, `team sync` does not apply it and reports it as failed; ask the agent again.
|
|
181
|
+
- **Keys stay out of the project.** They are saved in `~/.saarthiclaw/credentials.json` (owner-only), never in the repo, and **per project folder**: two folders on one computer can belong to two people (handy for a demo), and a copied folder never inherits someone else's key — it needs its own `team connect`. `SAARTHICLAW_TEAM_KEY` overrides it for CI.
|
|
182
|
+
- **Levels are checked on the server** on every request; a revoked key or a paused project stops changes immediately.
|
|
183
|
+
- Approved shell commands still ask you once more before running (or pass `--allow-shell`).
|
|
184
|
+
|
|
185
|
+
Use Git for the rest as usual: commit what `team sync` applied and open a pull request. For extra safety, protect the main branch on GitHub too.
|
|
186
|
+
|
|
187
|
+
> Friends on other computers can't reach `127.0.0.1`. Start the dashboard with `HOST=0.0.0.0` and share your LAN address, or host it behind HTTPS.
|
|
188
|
+
|
|
189
|
+
## Configuration
|
|
190
|
+
|
|
191
|
+
Resolution order, first match wins per key:
|
|
192
|
+
|
|
193
|
+
**CLI flags → environment variables → project `.env` → `.saarthiclaw/config.json` (project) → `~/.saarthiclaw/config.json` (user) → defaults**
|
|
194
|
+
|
|
195
|
+
### Environment variables (put secrets in the project `.env`)
|
|
196
|
+
|
|
197
|
+
| Variable | Required | Default | Purpose |
|
|
198
|
+
| --- | --- | --- | --- |
|
|
199
|
+
| `OPENROUTER_API_KEY` | yes | — | Your OpenRouter key |
|
|
200
|
+
| `OPENROUTER_DEFAULT_MODEL` | no | `qwen/qwen3-coder:free` | Model id |
|
|
201
|
+
| `FIRECRAWL_API_KEY` | no | — | Enables `web_search`, `web_crawl`, `fetch_url` tools |
|
|
202
|
+
| `TELEGRAM_BOT_TOKEN` | Telegram only | — | Bot token from @BotFather |
|
|
203
|
+
| `TELEGRAM_OWNER_ID` | Telegram only | — | Your numeric Telegram user id (legacy `TELEGRAM_BOT_ID` still works, with a deprecation note) |
|
|
204
|
+
| `SKILLS_DIRS` | no | — | Extra folders containing `SKILL.md` files (`:` or `;` separated) |
|
|
205
|
+
| `SAARTHICLAW_HOME` | no | `~/.saarthiclaw` | Location of the user config folder |
|
|
206
|
+
|
|
207
|
+
### Config file keys (`.saarthiclaw/config.json` or `~/.saarthiclaw/config.json`)
|
|
208
|
+
|
|
209
|
+
| Key | Default | Notes |
|
|
210
|
+
| --- | --- | --- |
|
|
211
|
+
| `model` | `qwen/qwen3-coder:free` | Same as `OPENROUTER_DEFAULT_MODEL` |
|
|
212
|
+
| `allowShellExecution` | `false` | Offer the shell tool by default |
|
|
213
|
+
| `maxSteps.ask` / `.plan` / `.agent` | `20` / `30` / `40` | Max tool-loop steps per run (plan = per step) |
|
|
214
|
+
| `excludePatterns` | `[]` | **Added** to the defaults `node_modules .git dist build .next .cache coverage *.log` |
|
|
215
|
+
| `maxFileSizeToRead` | `1048576` | Bytes |
|
|
216
|
+
| `maxToolOutputChars` | `20000` | Characters returned to the model per tool call |
|
|
217
|
+
| `context.maxReadmeChars` | `1500` | README excerpt in the project brief |
|
|
218
|
+
| `context.maxTreeLines` / `.maxTreeDepth` | `150` / `3` | File tree in the project brief |
|
|
219
|
+
| `context.maxBriefChars` | `8000` | Hard cap on the whole project brief |
|
|
220
|
+
| `skillsDirs` | `[]` | Same as `SKILLS_DIRS` |
|
|
221
|
+
|
|
222
|
+
Example:
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"model": "openai/gpt-oss-120b:free",
|
|
227
|
+
"allowShellExecution": false,
|
|
228
|
+
"maxSteps": { "agent": 30 },
|
|
229
|
+
"excludePatterns": ["fixtures", "*.snap"]
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Command reference
|
|
234
|
+
|
|
235
|
+
| Command | Behaviour |
|
|
236
|
+
| --- | --- |
|
|
237
|
+
| `saarthiclaw` | Same as `wakeup` in a terminal; prints help (exit 1) when not a TTY |
|
|
238
|
+
| `saarthiclaw wakeup` (aliases `wake`, `start`) | Banner → CLI / Telegram / Exit → Ask / Plan / Agent / Back. Ctrl+C or Esc at a prompt exits with a goodbye (exit 0) |
|
|
239
|
+
| `saarthiclaw init` | Interactive, idempotent setup |
|
|
240
|
+
| `saarthiclaw doctor [--offline]` | Checklist: Node, OS, root, config sources, key, model, live test call, Firecrawl, Telegram, shell setting, writable `.saarthiclaw/`. Exit 1 if a required check fails |
|
|
241
|
+
| `saarthiclaw ask "<question>" [--save file.md]` | Non-interactive answer (no prompts unless `--save`) |
|
|
242
|
+
| `saarthiclaw plan "<goal>"` | Plan mode with the goal pre-filled |
|
|
243
|
+
| `saarthiclaw agent "<task>"` | Agent mode with the task pre-filled |
|
|
244
|
+
| `saarthiclaw telegram` | Run the Telegram bot until Ctrl+C |
|
|
245
|
+
| `saarthiclaw history [--last N]` | Pretty-print the audit log (default 20) |
|
|
246
|
+
| `saarthiclaw team` / `team status` | Solo or team; your level; what is waiting |
|
|
247
|
+
| `saarthiclaw team connect [url]` (alias `join`) | Link this project to a dashboard with your key |
|
|
248
|
+
| `saarthiclaw team sync [--wait] [--yes]` | Apply your changes the Admin approved; show rejections. `--wait` keeps polling until everything is decided |
|
|
249
|
+
| `saarthiclaw team suggest "<idea>"` | Send an idea to the Admin |
|
|
250
|
+
| `saarthiclaw team invite <name> [--level trusted\|needs-approval\|suggest-only]` | (Admin) add a developer, print their one-time key |
|
|
251
|
+
| `saarthiclaw team inbox` | (Admin) suggestions you forwarded to the agent; run the agent on one |
|
|
252
|
+
| `saarthiclaw team disconnect` (alias `leave`) | Back to solo mode |
|
|
253
|
+
|
|
254
|
+
Global options: `--cwd <path>`, `--model <id>`, `--allow-shell`, `--debug`, `--no-banner`, `-v/--version`, `-h/--help`.
|
|
255
|
+
|
|
256
|
+
**Workspace root:** SaarthiClaw walks up from the current folder to the nearest directory containing `package.json` or `.git` and prints it once at startup. Override with `--cwd`.
|
|
257
|
+
|
|
258
|
+
`saarthiclaw-build` is kept as an alias binary for backwards compatibility.
|
|
259
|
+
|
|
260
|
+
## Telegram setup
|
|
261
|
+
|
|
262
|
+
1. Talk to [@BotFather](https://t.me/BotFather) → `/newbot` → copy the token.
|
|
263
|
+
2. Get your numeric user id from [@userinfobot](https://t.me/userinfobot).
|
|
264
|
+
3. Run `npx saarthiclaw init` and answer yes to Telegram (or add `TELEGRAM_BOT_TOKEN` and `TELEGRAM_OWNER_ID` to `.env`).
|
|
265
|
+
4. Run `npx saarthiclaw telegram`, open your bot and press **Start**.
|
|
266
|
+
|
|
267
|
+
Every update from anyone other than the owner is dropped before any handler runs. Changes from `/agent` and `/plan` are staged and shown with **Show Diff / Accept All / Reject All** buttons; high-risk batches need a second confirmation. Shell commands follow your `allowShellExecution` setting (off by default). Stop the bot with Ctrl+C.
|
|
268
|
+
|
|
269
|
+
## Free models and rate limits
|
|
270
|
+
|
|
271
|
+
- Free OpenRouter models are limited to roughly **20 requests per minute and 200 per day**. One agent run can use many requests (one per tool-loop step).
|
|
272
|
+
- SaarthiClaw retries 429 / 5xx responses automatically (3 retries with exponential backoff) and then explains the limit.
|
|
273
|
+
- The free lineup **rotates**. If you see "That model is not available", pick another in `saarthiclaw init` or pass `--model`. Good starting points: `qwen/qwen3-coder:free`, `openai/gpt-oss-120b:free`, `openai/gpt-oss-20b:free`.
|
|
274
|
+
|
|
275
|
+
## Troubleshooting
|
|
276
|
+
|
|
277
|
+
| Symptom | Fix |
|
|
278
|
+
| --- | --- |
|
|
279
|
+
| "No OpenRouter API key configured" | Run `npx saarthiclaw init`, or add `OPENROUTER_API_KEY=…` to the project `.env` |
|
|
280
|
+
| "Rate limited by OpenRouter (429)" | Wait a minute, use a different free model, or add credits |
|
|
281
|
+
| "OpenRouter rejected the API key (401)" | The key is wrong or revoked — create a new one and re-run `init` |
|
|
282
|
+
| "needs an interactive terminal (TTY)" | Run in a real terminal, or use `saarthiclaw ask "<question>"` in scripts/CI |
|
|
283
|
+
| Windows: arrow keys or colours look odd | Use Windows Terminal or PowerShell 7; set `NO_COLOR=1` to disable colours |
|
|
284
|
+
| Windows: shell commands | Commands run through the platform shell (`cmd.exe` on Windows), so write them for that shell |
|
|
285
|
+
| Anything else | `npx saarthiclaw doctor`, then re-run with `--debug` for a stack trace |
|
|
286
|
+
|
|
287
|
+
## FAQ
|
|
288
|
+
|
|
289
|
+
**Is this DevOps?**
|
|
290
|
+
It borrows DevOps ideas — approval gates, risk levels, audit logs — but it is an AI-assisted *development* tool that works inside one project on your machine.
|
|
291
|
+
|
|
292
|
+
**Does anything get sent besides my question?**
|
|
293
|
+
The model receives its instructions, a compact project brief (package.json summary, a shallow file tree, a README excerpt) and the content of files the tools read. Secret files are never readable.
|
|
294
|
+
|
|
295
|
+
**Can it run without approval?**
|
|
296
|
+
No. That is the whole point.
|
|
297
|
+
|
|
298
|
+
## Roadmap
|
|
299
|
+
|
|
300
|
+
- WhatsApp remote mode
|
|
301
|
+
- Database-backed history (the audit trail is already an event subscriber, so it can be swapped)
|
|
302
|
+
|
|
303
|
+
## Contributing
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
git clone https://github.com/hritik0447/SaarthiClaw.git
|
|
307
|
+
cd SaarthiClaw
|
|
308
|
+
npm install
|
|
309
|
+
npm run typecheck && npm test && npm run build
|
|
310
|
+
node dist/index.js --help
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Source layout: `index.ts` (entry) · `cli/` (commands: init, doctor, history) · `config/` (env/.env/config files) · `context/` (project brief + instructions) · `ai/` (model + error mapping) · `modes/ask|plan|agent|telegram` · `tui/` (menu, prompts, spinner, markdown) · `tests/`.
|
|
314
|
+
|
|
315
|
+
Tests use Node's built-in test runner with the AI SDK's mock model — no network, no real LLM. Issues and PRs welcome at <https://github.com/hritik0447/SaarthiClaw/issues>.
|
|
316
|
+
|
|
317
|
+
## Publishing (maintainers)
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
npm login # use an account with 2FA enabled (npm profile enable-2fa auth-and-writes)
|
|
321
|
+
npm view saarthiclaw name # "404 Not Found" means the name is free
|
|
322
|
+
npm run typecheck && npm test && npm run build
|
|
323
|
+
npm pack --dry-run # should list only dist/, README.md, LICENSE, CHANGELOG.md, package.json
|
|
324
|
+
npm publish # prepublishOnly re-runs typecheck + tests + build
|
|
325
|
+
npm i -g saarthiclaw && saarthiclaw --version # verify on a clean machine
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
If the unscoped name is taken: set `"name": "@hritik0447/saarthiclaw"` and `"publishConfig": { "access": "public" }`, then `npm publish --access public`. The binary is still called `saarthiclaw`.
|
|
329
|
+
|
|
330
|
+
Releases follow semver: `npm version patch` (bug fix, 0.1.0 → 0.1.1), `npm version minor` (new feature), `npm version major` (breaking). `npm version` bumps `package.json`, commits and tags; then `git push --follow-tags && npm publish`. Add an entry to `CHANGELOG.md` first.
|
|
331
|
+
|
|
332
|
+
Pulling a bad release: prefer `npm deprecate saarthiclaw@0.1.1 "Broken, use 0.1.2"` and ship a fixed patch. `npm unpublish saarthiclaw@0.1.1` only works within 72 hours and the version number can never be reused.
|
|
333
|
+
|
|
334
|
+
## License
|
|
335
|
+
|
|
336
|
+
[MIT](LICENSE) © Hritik Vishnoi
|