saarthiclaw 0.2.1 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project are documented here. This project follows [Semantic Versioning](https://semver.org/).
4
4
 
5
+ ## 0.2.2 — 2026-11-19
6
+
7
+ ### Fixed
8
+ - Agent mode: some models described the change (or pasted the code) and asked "Would you like me to create the file?" instead of calling a tool, so nothing was staged. The instructions now say plainly to stage changes with the tools and never ask permission (approval happens afterwards). If a model still only describes the change, the agent tells it once to go ahead and stage it.
9
+
5
10
  ## 0.2.1 — 2026-11-18
6
11
 
7
12
  ### Changed
@@ -4,7 +4,7 @@ import {
4
4
  finishOnLastStep,
5
5
  generateWithProgress,
6
6
  renderTerminalMarkdown
7
- } from "./chunk-QFVMJJQY.js";
7
+ } from "./chunk-DSQDVSZS.js";
8
8
  import {
9
9
  ToolExecutor
10
10
  } from "./chunk-OS5GVLKA.js";
@@ -20,7 +20,7 @@ import {
20
20
  agentConfigFrom,
21
21
  createTracker,
22
22
  instructionsFor
23
- } from "./chunk-4YYY2YOT.js";
23
+ } from "./chunk-GX2I7K4S.js";
24
24
  import {
25
25
  AI_MAX_RETRIES
26
26
  } from "./chunk-BTFIQWAE.js";
@@ -85,7 +85,20 @@ async function runAgentTask(session, task, opts) {
85
85
  maxOutputTokens: 4e3,
86
86
  maxRetries: AI_MAX_RETRIES
87
87
  });
88
- const { text } = await generateWithProgress(agent, task, "Agent is thinking…");
88
+ let { text } = await generateWithProgress(agent, task, "Agent is thinking…");
89
+ if (tracker.PendingMutation().length === 0 && onlyDescribedTheChange(text)) {
90
+ console.log(chalk.dim("\nThe AI described the change instead of staging it; asking it to stage it now…"));
91
+ const followUp = await generateWithProgress(
92
+ agent,
93
+ [
94
+ { role: "user", content: task },
95
+ { role: "assistant", content: text },
96
+ { role: "user", content: "Yes, go ahead. Stage it now with the file tools (create_file / modify_file). Do not ask again; I will review the diff before anything is written." }
97
+ ],
98
+ "Staging the change…"
99
+ );
100
+ text = followUp.text || text;
101
+ }
89
102
  if (text.trim()) console.log("\n" + renderTerminalMarkdown(text) + "\n");
90
103
  const outcome = await finalizeStaged(session, tracker, executor, { task, summary: text, autoSend: opts.autoSend });
91
104
  return { text, ...outcome };
@@ -99,8 +112,15 @@ async function runAgentTask(session, task, opts) {
99
112
  executor.clearStaging();
100
113
  }
101
114
  }
115
+ function onlyDescribedTheChange(text) {
116
+ const t = text.trim();
117
+ if (!t) return false;
118
+ if (/```|^ {4}\S/m.test(t)) return true;
119
+ return /(would you like|shall i|should i|do you want|want me to|let me know if you('d| would)? like|can i go ahead|proceed\?)/i.test(t);
120
+ }
102
121
 
103
122
  export {
104
123
  runAgentMode,
105
- runAgentTask
124
+ runAgentTask,
125
+ onlyDescribedTheChange
106
126
  };
@@ -135,7 +135,7 @@ async function generateWithProgress(agent, prompt, label) {
135
135
  try {
136
136
  const result = await runCancellable(
137
137
  (signal) => agent.generate({
138
- prompt,
138
+ ...typeof prompt === "string" ? { prompt } : { messages: prompt },
139
139
  abortSignal: signal,
140
140
  onStepFinish: (step) => {
141
141
  const parts = step.content ?? [];
@@ -175,7 +175,12 @@ function buildProjectBrief(root, budgets = {}) {
175
175
  }
176
176
 
177
177
  // context/instructions.ts
178
- var PERSONA = "You are SaarthiClaw, a careful coding assistant that lives in the developer's terminal. You behave like a very capable intern: you investigate first, explain your intent, and always let the senior developer (the human) approve changes.";
178
+ var PERSONA = "You are SaarthiClaw, a careful coding assistant that lives in the developer's terminal. You behave like a very capable intern: you investigate first, then do the work. The senior developer (the human) reviews and approves every staged change afterwards.";
179
+ var ACT_RULES = [
180
+ 'Do NOT ask for permission or confirmation before making a change, and do not end with a question like "Would you like me to create the file?" — staging IS the safe step; the human approves afterwards.',
181
+ "Never paste the code into your reply instead of staging it. If the task asks for code, a file, a fix or a feature, call create_file / modify_file / create_folder (or delete_file) so the change is staged.",
182
+ "If the request is ambiguous, pick the most reasonable interpretation, stage it, and mention the assumption in your summary."
183
+ ];
179
184
  var MODE_RULES = {
180
185
  ask: [
181
186
  "Mode: ASK (read-only). Answer the question about this codebase.",
@@ -199,18 +204,21 @@ var MODE_RULES = {
199
204
  ],
200
205
  "plan-step": [
201
206
  "Mode: AGENT executing ONE step of an approved plan.",
207
+ ...ACT_RULES,
202
208
  "Only do the work for the current step; earlier steps' staged changes are visible to read_file.",
203
209
  "Stage changes with the file tools; prefer minimal, focused diffs.",
204
210
  "Finish with a short summary of what you staged and why."
205
211
  ],
206
212
  agent: [
207
213
  "Mode: AGENT. Complete the user's task by staging changes with the tools.",
214
+ ...ACT_RULES,
208
215
  "Read the relevant files first, then stage the smallest correct change (minimal diffs, keep the existing style).",
209
- "Explain your intent briefly before and after making changes.",
216
+ "Only answer without staging anything when the user clearly asked a question rather than for a change.",
210
217
  "Finish with a short summary listing every staged change."
211
218
  ],
212
219
  "telegram-agent": [
213
220
  "Mode: AGENT via Telegram. Complete the task by staging changes with the tools.",
221
+ ...ACT_RULES,
214
222
  "Read relevant files first; stage minimal diffs; finish with a short summary of staged changes."
215
223
  ]
216
224
  };
@@ -8,7 +8,7 @@ import {
8
8
  finishOnLastStep,
9
9
  generateWithProgress,
10
10
  renderTerminalMarkdown
11
- } from "./chunk-QFVMJJQY.js";
11
+ } from "./chunk-DSQDVSZS.js";
12
12
  import {
13
13
  ToolExecutor
14
14
  } from "./chunk-OS5GVLKA.js";
@@ -17,7 +17,7 @@ import {
17
17
  createTracker,
18
18
  instructionsFor,
19
19
  readOnlyAgentConfig
20
- } from "./chunk-4YYY2YOT.js";
20
+ } from "./chunk-GX2I7K4S.js";
21
21
  import {
22
22
  AI_MAX_RETRIES
23
23
  } from "./chunk-BTFIQWAE.js";
@@ -10,7 +10,7 @@ import {
10
10
  finishOnLastStep,
11
11
  generateWithProgress,
12
12
  renderTerminalMarkdown
13
- } from "./chunk-QFVMJJQY.js";
13
+ } from "./chunk-DSQDVSZS.js";
14
14
  import {
15
15
  ToolExecutor,
16
16
  clipOutput
@@ -31,7 +31,7 @@ import {
31
31
  createTracker,
32
32
  instructionsFor,
33
33
  readOnlyAgentConfig
34
- } from "./chunk-4YYY2YOT.js";
34
+ } from "./chunk-GX2I7K4S.js";
35
35
  import {
36
36
  AI_MAX_RETRIES
37
37
  } from "./chunk-BTFIQWAE.js";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  runPlanMode,
3
3
  stepPrompt
4
- } from "./chunk-VAP6FVF5.js";
4
+ } from "./chunk-VDYO3QC7.js";
5
5
  import "./chunk-OICPXSO2.js";
6
- import "./chunk-QFVMJJQY.js";
6
+ import "./chunk-DSQDVSZS.js";
7
7
  import "./chunk-OS5GVLKA.js";
8
8
  import "./chunk-QRAFFI5V.js";
9
9
  import "./chunk-SKYTL7AH.js";
10
10
  import "./chunk-E4DRW4AW.js";
11
11
  import "./chunk-HGBZ55ND.js";
12
- import "./chunk-4YYY2YOT.js";
12
+ import "./chunk-GX2I7K4S.js";
13
13
  import "./chunk-5WH3FNFK.js";
14
14
  import "./chunk-EG5A2Q6X.js";
15
15
  import "./chunk-G6GCAEKE.js";
@@ -5,15 +5,15 @@ import {
5
5
  runAskOnce,
6
6
  saveAnswer,
7
7
  validateMdFilename
8
- } from "./chunk-GSBUJPPF.js";
8
+ } from "./chunk-TTT3KK46.js";
9
9
  import "./chunk-OICPXSO2.js";
10
- import "./chunk-QFVMJJQY.js";
10
+ import "./chunk-DSQDVSZS.js";
11
11
  import "./chunk-OS5GVLKA.js";
12
12
  import "./chunk-QRAFFI5V.js";
13
13
  import "./chunk-SKYTL7AH.js";
14
14
  import "./chunk-E4DRW4AW.js";
15
15
  import "./chunk-HGBZ55ND.js";
16
- import "./chunk-4YYY2YOT.js";
16
+ import "./chunk-GX2I7K4S.js";
17
17
  import "./chunk-5WH3FNFK.js";
18
18
  import "./chunk-EG5A2Q6X.js";
19
19
  import "./chunk-G6GCAEKE.js";
@@ -1,14 +1,15 @@
1
1
  import {
2
+ onlyDescribedTheChange,
2
3
  runAgentMode,
3
4
  runAgentTask
4
- } from "./chunk-4CNBITFA.js";
5
- import "./chunk-QFVMJJQY.js";
5
+ } from "./chunk-3UFD5346.js";
6
+ import "./chunk-DSQDVSZS.js";
6
7
  import "./chunk-OS5GVLKA.js";
7
8
  import "./chunk-QRAFFI5V.js";
8
9
  import "./chunk-SKYTL7AH.js";
9
10
  import "./chunk-E4DRW4AW.js";
10
11
  import "./chunk-HGBZ55ND.js";
11
- import "./chunk-4YYY2YOT.js";
12
+ import "./chunk-GX2I7K4S.js";
12
13
  import "./chunk-5WH3FNFK.js";
13
14
  import "./chunk-EG5A2Q6X.js";
14
15
  import "./chunk-G6GCAEKE.js";
@@ -18,6 +19,7 @@ import "./chunk-BTFIQWAE.js";
18
19
  import "./chunk-2GDAWRT7.js";
19
20
  import "./chunk-MMIJKDOU.js";
20
21
  export {
22
+ onlyDescribedTheChange,
21
23
  runAgentMode,
22
24
  runAgentTask
23
25
  };
@@ -4,7 +4,7 @@ import {
4
4
  hasWebTools,
5
5
  instructionsFor,
6
6
  reportAiError
7
- } from "./chunk-4YYY2YOT.js";
7
+ } from "./chunk-GX2I7K4S.js";
8
8
  import "./chunk-5WH3FNFK.js";
9
9
  import "./chunk-XTVJWMUH.js";
10
10
  import "./chunk-BTFIQWAE.js";
@@ -338,7 +338,7 @@ async function teamInbox(session) {
338
338
  });
339
339
  if (what === "back") continue;
340
340
  if (what === "run") {
341
- const { runAgentTask } = await import("./orchestrator-L4TOOHXY.js");
341
+ const { runAgentTask } = await import("./orchestrator-NIDJK4C3.js");
342
342
  const task = `${item.message}${item.adminNote ? `
343
343
 
344
344
  Admin note: ${item.adminNote}` : ""}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  generatePlan,
3
3
  stepPrompt
4
- } from "./chunk-VAP6FVF5.js";
4
+ } from "./chunk-VDYO3QC7.js";
5
5
  import {
6
6
  createWebTools
7
7
  } from "./chunk-OICPXSO2.js";
@@ -10,7 +10,7 @@ import {
10
10
  createReadOnlyTools,
11
11
  dedupeReadOnlyTools,
12
12
  finishOnLastStep
13
- } from "./chunk-QFVMJJQY.js";
13
+ } from "./chunk-DSQDVSZS.js";
14
14
  import {
15
15
  ToolExecutor
16
16
  } from "./chunk-OS5GVLKA.js";
@@ -27,7 +27,7 @@ import {
27
27
  createTracker,
28
28
  instructionsFor,
29
29
  readOnlyAgentConfig
30
- } from "./chunk-4YYY2YOT.js";
30
+ } from "./chunk-GX2I7K4S.js";
31
31
  import "./chunk-5WH3FNFK.js";
32
32
  import "./chunk-EG5A2Q6X.js";
33
33
  import {
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  runAgentMode
3
- } from "./chunk-4CNBITFA.js";
3
+ } from "./chunk-3UFD5346.js";
4
4
  import {
5
5
  runAskMode
6
- } from "./chunk-GSBUJPPF.js";
6
+ } from "./chunk-TTT3KK46.js";
7
7
  import {
8
8
  runPlanMode
9
- } from "./chunk-VAP6FVF5.js";
9
+ } from "./chunk-VDYO3QC7.js";
10
10
  import "./chunk-OICPXSO2.js";
11
- import "./chunk-QFVMJJQY.js";
11
+ import "./chunk-DSQDVSZS.js";
12
12
  import "./chunk-OS5GVLKA.js";
13
13
  import "./chunk-QRAFFI5V.js";
14
14
  import "./chunk-SKYTL7AH.js";
@@ -16,7 +16,7 @@ import "./chunk-E4DRW4AW.js";
16
16
  import {
17
17
  RunCancelledError
18
18
  } from "./chunk-HGBZ55ND.js";
19
- import "./chunk-4YYY2YOT.js";
19
+ import "./chunk-GX2I7K4S.js";
20
20
  import "./chunk-5WH3FNFK.js";
21
21
  import "./chunk-EG5A2Q6X.js";
22
22
  import {
@@ -124,14 +124,14 @@ async function runWakeup(session) {
124
124
  }
125
125
  if (choice === MainMenu.Telegram) {
126
126
  await runModeSafely(session, async () => {
127
- const { runTelegramMode } = await import("./telegram-LPSIQBQX.js");
127
+ const { runTelegramMode } = await import("./telegram-JSGRYPIX.js");
128
128
  await runTelegramMode(session);
129
129
  });
130
130
  }
131
131
  }
132
132
  }
133
133
  async function runTeamMenu(session) {
134
- const team = await import("./team-OFNBRXVP.js");
134
+ const team = await import("./team-RBSOK3HT.js");
135
135
  const { readTeamLink } = await import("./store-KW257WIV.js");
136
136
  while (true) {
137
137
  const link = readTeamLink(session.root, session.env ?? process.env);
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ async function bootstrap(cmd, opts = {}) {
17
17
  import("./chunks/workspace-PFJUEHAB.js"),
18
18
  import("./chunks/config-PA5NJ37O.js"),
19
19
  import("./chunks/prompter-AAH4A3BG.js"),
20
- import("./chunks/session-FPFJMS7Y.js")
20
+ import("./chunks/session-CRFC3IEU.js")
21
21
  ]);
22
22
  if (opts.needsTty && !prompterMod.isInteractiveTerminal()) {
23
23
  throw new prompterMod.NonInteractiveError(opts.needsTty);
@@ -37,7 +37,7 @@ async function bootstrap(cmd, opts = {}) {
37
37
  async function startWakeup(cmd) {
38
38
  const session = await bootstrap(cmd, { needsTty: "`saarthiclaw wakeup`" });
39
39
  const g = cmd.optsWithGlobals();
40
- const { renderBanner, runWakeup } = await import("./chunks/wakeup-M5EIP54K.js");
40
+ const { renderBanner, runWakeup } = await import("./chunks/wakeup-4IP4JXVF.js");
41
41
  if (g.banner !== false) console.log(renderBanner(getVersion()) + "\n");
42
42
  if (!session.config.openrouterApiKey) {
43
43
  console.log(chalk.yellow("⚠ No OpenRouter API key found. Run `saarthiclaw init` first (Ask/Plan/Agent need it).\n"));
@@ -77,24 +77,24 @@ function buildProgram() {
77
77
  program.command("ask").argument("[question...]", "question about the codebase (omit for the interactive prompt)").option("--save <file.md>", "save the answer as Markdown (goes through the approval flow)").description("ask a question about this codebase (read-only)").action(async (words, opts, cmd) => {
78
78
  const question = joinWords(words);
79
79
  const session = await bootstrap(cmd, { needsTty: question && !opts.save ? void 0 : "`saarthiclaw ask` without a question or with --save" });
80
- const ask = await import("./chunks/orchestrator-CYIGQH74.js");
80
+ const ask = await import("./chunks/orchestrator-KNCW4K57.js");
81
81
  if (question) await ask.runAskOnce(session, question, opts.save);
82
82
  else await ask.runAskMode(session);
83
83
  });
84
84
  program.command("plan").argument("[goal...]", "what you want to achieve").description("generate a step-by-step plan, pick steps, execute them with approval").action(async (words, _opts, cmd) => {
85
85
  const session = await bootstrap(cmd, { needsTty: "`saarthiclaw plan`" });
86
- const { runPlanMode } = await import("./chunks/orchestrator-4SMA442I.js");
86
+ const { runPlanMode } = await import("./chunks/orchestrator-JFJU4FGP.js");
87
87
  await runPlanMode(session, joinWords(words));
88
88
  });
89
89
  program.command("agent").argument("[task...]", "task for the agent").description("let the agent stage changes; you review and approve every diff").option("--send", "team (Needs approval): send the changes to the Admin without asking; no shell commands").action(async (words, opts, cmd) => {
90
90
  const task = joinWords(words);
91
91
  const session = await bootstrap(cmd, { needsTty: opts.send && task ? void 0 : "`saarthiclaw agent`" });
92
- const { runAgentMode } = await import("./chunks/orchestrator-L4TOOHXY.js");
92
+ const { runAgentMode } = await import("./chunks/orchestrator-NIDJK4C3.js");
93
93
  await runAgentMode(session, task, { send: opts.send });
94
94
  });
95
95
  program.command("telegram").description("run the Telegram remote-control bot (owner only) until Ctrl+C").action(async (_opts, cmd) => {
96
96
  const session = await bootstrap(cmd);
97
- const { runTelegramMode } = await import("./chunks/telegram-LPSIQBQX.js");
97
+ const { runTelegramMode } = await import("./chunks/telegram-JSGRYPIX.js");
98
98
  await runTelegramMode(session);
99
99
  });
100
100
  program.command("history").description("show the audit trail of staged / approved / applied actions").option("--last <n>", "number of events to show", "20").action(async (opts, cmd) => {
@@ -106,44 +106,44 @@ function buildProgram() {
106
106
  });
107
107
  const team = program.command("team").description("work with a team dashboard: connect, sync approved changes, suggest, invite").action(async (_opts, cmd) => {
108
108
  const session = await bootstrap(cmd);
109
- const { teamStatus } = await import("./chunks/team-OFNBRXVP.js");
109
+ const { teamStatus } = await import("./chunks/team-RBSOK3HT.js");
110
110
  await teamStatus(session);
111
111
  });
112
112
  team.command("connect").alias("join").argument("[url]", "dashboard address, e.g. http://127.0.0.1:3000").description("link this project to a dashboard with your access key (Admin or member)").action(async (url, _opts, cmd) => {
113
113
  const session = await bootstrap(cmd, { needsTty: process.env.SAARTHICLAW_TEAM_KEY ? void 0 : "`saarthiclaw team connect` (or set SAARTHICLAW_TEAM_KEY)" });
114
- const { teamConnect } = await import("./chunks/team-OFNBRXVP.js");
114
+ const { teamConnect } = await import("./chunks/team-RBSOK3HT.js");
115
115
  await teamConnect(session, url);
116
116
  });
117
117
  team.command("status").description("who you are, your level, and what is waiting").action(async (_opts, cmd) => {
118
118
  const session = await bootstrap(cmd);
119
- const { teamStatus } = await import("./chunks/team-OFNBRXVP.js");
119
+ const { teamStatus } = await import("./chunks/team-RBSOK3HT.js");
120
120
  await teamStatus(session);
121
121
  });
122
122
  team.command("sync").description("apply your changes the Admin approved; show rejections").option("-y, --yes", "apply approved changes without asking").option("-w, --wait", "keep waiting until the Admin has decided on everything").action(async (opts, cmd) => {
123
123
  const session = await bootstrap(cmd);
124
124
  const g = cmd.optsWithGlobals();
125
- const { teamSync } = await import("./chunks/team-OFNBRXVP.js");
125
+ const { teamSync } = await import("./chunks/team-RBSOK3HT.js");
126
126
  await teamSync(session, { yes: opts.yes, wait: opts.wait, allowShell: g.allowShell });
127
127
  });
128
128
  team.command("suggest").argument("[idea...]", "your idea for the Admin").description("send an idea to the Admin (any level, including Suggest only)").action(async (words, _opts, cmd) => {
129
129
  const idea = joinWords(words);
130
130
  const session = await bootstrap(cmd, { needsTty: idea ? void 0 : "`saarthiclaw team suggest` without text" });
131
- const { teamSuggest } = await import("./chunks/team-OFNBRXVP.js");
131
+ const { teamSuggest } = await import("./chunks/team-RBSOK3HT.js");
132
132
  await teamSuggest(session, idea);
133
133
  });
134
134
  team.command("invite").argument("[name]", "developer's name").option("--level <level>", "trusted | needs-approval | suggest-only").description("(Admin) add a developer and print their one-time access key").action(async (name, opts, cmd) => {
135
135
  const session = await bootstrap(cmd, { needsTty: name ? void 0 : "`saarthiclaw team invite` without a name" });
136
- const { teamInvite } = await import("./chunks/team-OFNBRXVP.js");
136
+ const { teamInvite } = await import("./chunks/team-RBSOK3HT.js");
137
137
  await teamInvite(session, name ?? "", opts.level);
138
138
  });
139
139
  team.command("inbox").description("(Admin) suggestions you forwarded to the agent; run the agent on one").action(async (_opts, cmd) => {
140
140
  const session = await bootstrap(cmd);
141
- const { teamInbox } = await import("./chunks/team-OFNBRXVP.js");
141
+ const { teamInbox } = await import("./chunks/team-RBSOK3HT.js");
142
142
  await teamInbox(session);
143
143
  });
144
144
  team.command("disconnect").alias("leave").description("unlink this project from the dashboard (back to solo mode)").action(async (_opts, cmd) => {
145
145
  const session = await bootstrap(cmd, { needsTty: "`saarthiclaw team disconnect`" });
146
- const { teamDisconnect } = await import("./chunks/team-OFNBRXVP.js");
146
+ const { teamDisconnect } = await import("./chunks/team-RBSOK3HT.js");
147
147
  await teamDisconnect(session);
148
148
  });
149
149
  program.addHelpText(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saarthiclaw",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "An AI developer assistant that lives in your project's terminal. Ask, Plan and Agent modes — the AI proposes, you approve every change.",
5
5
  "keywords": [
6
6
  "ai",