saarthiclaw 0.2.3 → 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.
- package/CHANGELOG.md +11 -0
- package/README.md +8 -0
- package/dist/chunks/{chunk-OJCC4JH2.js → chunk-33MUQ6E5.js} +8 -0
- package/dist/chunks/{chunk-XNIFO3FV.js → chunk-N33J57DT.js} +2 -2
- package/dist/chunks/{chunk-44LLGJXH.js → chunk-OF5PQQQ4.js} +2 -2
- package/dist/chunks/{chunk-OLL2WJVK.js → chunk-S6YZ2A73.js} +1 -1
- package/dist/chunks/{chunk-BBQ26JQA.js → chunk-SYH37PL6.js} +1 -1
- package/dist/chunks/{chunk-CUC6MUW7.js → chunk-XATEICDJ.js} +1 -1
- package/dist/chunks/{chunk-CGTA77EE.js → chunk-XT5WAZRV.js} +2 -2
- package/dist/chunks/{client-O4UP5DCM.js → client-TI5W2YDP.js} +1 -1
- package/dist/chunks/{context-OL7JU4XA.js → context-RKFGCGP7.js} +2 -2
- package/dist/chunks/{doctor-OBO4MCDY.js → doctor-ZQICU2F4.js} +1 -1
- package/dist/chunks/{orchestrator-QAFNDXD2.js → orchestrator-ATA2LHPJ.js} +4 -4
- package/dist/chunks/{orchestrator-HUHXYUUM.js → orchestrator-NJ7US5XC.js} +4 -4
- package/dist/chunks/{orchestrator-IKYROOM5.js → orchestrator-XLVMKC4V.js} +4 -4
- package/dist/chunks/{sync-LTPGXMRU.js → sync-ESB3YWI2.js} +3 -3
- package/dist/chunks/{team-AOMHCEDT.js → team-PFETXIEC.js} +102 -7
- package/dist/chunks/{telegram-KO7VH46G.js → telegram-IMADPCKR.js} +5 -5
- package/dist/chunks/{wakeup-YZNEVSVH.js → wakeup-UX6AM7M6.js} +8 -8
- package/dist/chunks/workspace-XERWEYJB.js +281 -0
- package/dist/index.js +21 -15
- package/package.json +1 -1
- package/dist/chunks/{init-GCJNYE3Y.js → init-5ENYFSX2.js} +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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.3.0 — 2026-11-29
|
|
6
|
+
|
|
7
|
+
- **`saarthiclaw team watch`** keeps a project folder and the team website (dashboard → Code) in step.
|
|
8
|
+
- Website → laptop for everyone: web edits, approved requests, AI changes and reverts are written into the folder within a couple of seconds.
|
|
9
|
+
- Laptop → website for the Admin and Trusted members: edits, new files and deletions in the folder become a version on the website (revertable from History).
|
|
10
|
+
- Safe by design: a file you edited locally is never overwritten — if both sides changed it, it is reported and left alone until you choose `--prefer website` or `--prefer laptop`. Pushes carry the hash of the version they are based on, so a newer website change is never lost. Only text files sync; `node_modules`, build and dot-folders, images and secrets (`.env`, keys) never leave the laptop. A folder that suddenly looks empty does not wipe the website.
|
|
11
|
+
- First sync: an empty website gets the folder; an empty folder gets the website; when both differ you choose which version wins.
|
|
12
|
+
- Options: `--once`, `--prefer website|laptop`, `--interval <seconds>`.
|
|
13
|
+
- `team connect` now points to `team watch`.
|
|
14
|
+
- Needs the dashboard v0.4 (web workspace).
|
|
15
|
+
|
|
5
16
|
## 0.2.3 — 2026-11-19
|
|
6
17
|
|
|
7
18
|
### Added
|
package/README.md
CHANGED
|
@@ -175,6 +175,14 @@ npx saarthiclaw agent "validate todo text"
|
|
|
175
175
|
```
|
|
176
176
|
Closed the terminal before the Admin decided? `npx saarthiclaw team sync` applies whatever was approved since.
|
|
177
177
|
|
|
178
|
+
### Keep the folder in step with the team website
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npx saarthiclaw team watch
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Leave it running. Changes made on the website (web editor, approved requests, AI changes, reverts) appear in this folder within seconds. For the Admin and Trusted members it also works the other way: edit files in your folder and they become a new version on the website. If a file was changed on both sides it is left alone and reported; run with `--prefer website` or `--prefer laptop` to settle it. Only text files are synced — `node_modules`, images and secrets such as `.env` never leave your computer.
|
|
185
|
+
|
|
178
186
|
**AI for the whole team (one key):** the Admin adds an OpenRouter key on the dashboard under **Settings → Team AI**. From then on every teammate's `ask`, `plan` and `agent` use it through the dashboard, so teammates need **no AI key of their own**. The key never leaves the dashboard, and everyone uses the model the Admin chose. (`SAARTHICLAW_OWN_AI_KEY=1` makes a terminal use its own key instead.)
|
|
179
187
|
|
|
180
188
|
How it stays safe:
|
|
@@ -108,6 +108,14 @@ var TeamClient = class {
|
|
|
108
108
|
inboxDone(id) {
|
|
109
109
|
return this.call("POST", `/inbox/${id}/done`);
|
|
110
110
|
}
|
|
111
|
+
/** Website copy of the project: everything after `since` (or a full snapshot when since=0). */
|
|
112
|
+
workspace(since) {
|
|
113
|
+
return this.call("GET", `/workspace?since=${Math.max(0, Math.floor(since))}`);
|
|
114
|
+
}
|
|
115
|
+
/** Admin / Trusted: send laptop edits to the website copy as one version. */
|
|
116
|
+
pushWorkspace(changes, message) {
|
|
117
|
+
return this.call("POST", "/workspace/push", { changes, message });
|
|
118
|
+
}
|
|
111
119
|
invite(name, permissionLevel, regenerate = false) {
|
|
112
120
|
return this.call("POST", "/members", { name, permissionLevel, ...regenerate ? { regenerate: true } : {} });
|
|
113
121
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
finishOnLastStep,
|
|
11
11
|
generateWithProgress,
|
|
12
12
|
renderTerminalMarkdown
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OF5PQQQ4.js";
|
|
14
14
|
import {
|
|
15
15
|
ToolExecutor,
|
|
16
16
|
clipOutput
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
import {
|
|
22
22
|
describeTeamMode,
|
|
23
23
|
getTeamContext
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-S6YZ2A73.js";
|
|
25
25
|
import {
|
|
26
26
|
RunCancelledError,
|
|
27
27
|
runCancellable
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-QRAFFI5V.js";
|
|
9
9
|
import {
|
|
10
10
|
getTeamContext
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-S6YZ2A73.js";
|
|
12
12
|
import {
|
|
13
13
|
RunCancelledError,
|
|
14
14
|
runCancellable
|
|
@@ -361,7 +361,7 @@ async function sendForApproval(session, tracker, info, team) {
|
|
|
361
361
|
📨 Sent ${res.ids.length} change${res.ids.length === 1 ? "" : "s"} to the Admin for approval.`) + chalk2.dim(" Nothing was written yet.\n"));
|
|
362
362
|
const wait = session.prompter.interactive ? await session.prompter.confirm({ message: "Wait here for the Admin's decision? (approved changes are applied here right after)", initialValue: true }) : false;
|
|
363
363
|
if (wait) {
|
|
364
|
-
const { runTeamSync } = await import("./sync-
|
|
364
|
+
const { runTeamSync } = await import("./sync-ESB3YWI2.js");
|
|
365
365
|
const summary = await runTeamSync(session, { wait: true });
|
|
366
366
|
return { approved: summary.applied > 0, sent: res.ids.length };
|
|
367
367
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
finishOnLastStep,
|
|
5
5
|
generateWithProgress,
|
|
6
6
|
renderTerminalMarkdown
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OF5PQQQ4.js";
|
|
8
8
|
import {
|
|
9
9
|
ToolExecutor
|
|
10
10
|
} from "./chunk-CGJ4VEUD.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
assertProjectOpen,
|
|
13
13
|
describeTeamMode,
|
|
14
14
|
getTeamContext
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-S6YZ2A73.js";
|
|
16
16
|
import {
|
|
17
17
|
RunCancelledError
|
|
18
18
|
} from "./chunk-HGBZ55ND.js";
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
describeTeamMode,
|
|
4
4
|
getTeamContext,
|
|
5
5
|
teamClientFor
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-S6YZ2A73.js";
|
|
7
|
+
import "./chunk-33MUQ6E5.js";
|
|
8
8
|
import "./chunk-H2FAKNUI.js";
|
|
9
9
|
import "./chunk-R4PMMMD5.js";
|
|
10
10
|
import "./chunk-2GDAWRT7.js";
|
|
@@ -130,7 +130,7 @@ async function checkTeam(session, live) {
|
|
|
130
130
|
if (!readKey(link.server, session.root, env)) return { name: "Team dashboard", status: "warn", detail: `no key saved for ${link.server} — run \`saarthiclaw team connect\``, required: false };
|
|
131
131
|
if (!live) return { name: "Team dashboard", status: "info", detail: `${link.server} (not contacted: --offline)`, required: false };
|
|
132
132
|
try {
|
|
133
|
-
const { TeamClient } = await import("./client-
|
|
133
|
+
const { TeamClient } = await import("./client-TI5W2YDP.js");
|
|
134
134
|
const me = await new TeamClient(link.server, readKey(link.server, session.root, env), session.teamFetch, 8e3).whoami();
|
|
135
135
|
return { name: "Team dashboard", status: "pass", detail: `${me.name} (${me.permissionLevel.replace("_", " ")}) at ${link.server}`, required: false };
|
|
136
136
|
} catch (e) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runPlanMode,
|
|
3
3
|
stepPrompt
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-N33J57DT.js";
|
|
5
5
|
import "./chunk-HFMRQTXE.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-OF5PQQQ4.js";
|
|
7
7
|
import "./chunk-CGJ4VEUD.js";
|
|
8
8
|
import "./chunk-QRAFFI5V.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-S6YZ2A73.js";
|
|
10
|
+
import "./chunk-33MUQ6E5.js";
|
|
11
11
|
import "./chunk-HGBZ55ND.js";
|
|
12
12
|
import "./chunk-KAWTUWO2.js";
|
|
13
13
|
import "./chunk-5WH3FNFK.js";
|
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
onlyDescribedTheChange,
|
|
3
3
|
runAgentMode,
|
|
4
4
|
runAgentTask
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-XT5WAZRV.js";
|
|
6
|
+
import "./chunk-OF5PQQQ4.js";
|
|
7
7
|
import "./chunk-CGJ4VEUD.js";
|
|
8
8
|
import "./chunk-QRAFFI5V.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-S6YZ2A73.js";
|
|
10
|
+
import "./chunk-33MUQ6E5.js";
|
|
11
11
|
import "./chunk-HGBZ55ND.js";
|
|
12
12
|
import "./chunk-KAWTUWO2.js";
|
|
13
13
|
import "./chunk-5WH3FNFK.js";
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
runAskOnce,
|
|
6
6
|
saveAnswer,
|
|
7
7
|
validateMdFilename
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SYH37PL6.js";
|
|
9
9
|
import "./chunk-HFMRQTXE.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-OF5PQQQ4.js";
|
|
11
11
|
import "./chunk-CGJ4VEUD.js";
|
|
12
12
|
import "./chunk-QRAFFI5V.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-S6YZ2A73.js";
|
|
14
|
+
import "./chunk-33MUQ6E5.js";
|
|
15
15
|
import "./chunk-HGBZ55ND.js";
|
|
16
16
|
import "./chunk-KAWTUWO2.js";
|
|
17
17
|
import "./chunk-5WH3FNFK.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyRemoteAction,
|
|
3
3
|
runTeamSync
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XATEICDJ.js";
|
|
5
5
|
import "./chunk-CGJ4VEUD.js";
|
|
6
6
|
import "./chunk-QRAFFI5V.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-S6YZ2A73.js";
|
|
8
|
+
import "./chunk-33MUQ6E5.js";
|
|
9
9
|
import "./chunk-HGBZ55ND.js";
|
|
10
10
|
import "./chunk-5WH3FNFK.js";
|
|
11
11
|
import "./chunk-H2FAKNUI.js";
|
|
@@ -3,19 +3,19 @@ import {
|
|
|
3
3
|
} from "./chunk-R7ID2QVW.js";
|
|
4
4
|
import {
|
|
5
5
|
runTeamSync
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XATEICDJ.js";
|
|
7
7
|
import "./chunk-CGJ4VEUD.js";
|
|
8
8
|
import "./chunk-QRAFFI5V.js";
|
|
9
9
|
import {
|
|
10
10
|
describeTeamMode,
|
|
11
11
|
getTeamContext,
|
|
12
12
|
teamClientFor
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-S6YZ2A73.js";
|
|
14
14
|
import {
|
|
15
15
|
LEVEL_LABEL,
|
|
16
16
|
TeamApiError,
|
|
17
17
|
TeamClient
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-33MUQ6E5.js";
|
|
19
19
|
import "./chunk-HGBZ55ND.js";
|
|
20
20
|
import "./chunk-5WH3FNFK.js";
|
|
21
21
|
import {
|
|
@@ -203,7 +203,8 @@ ${explainLevel(me)}
|
|
|
203
203
|
if (link) writeTeamLink(session.root, { ...link, projectName: p.name });
|
|
204
204
|
console.log(chalk.green(`✓ Dashboard project: ${p.name}`));
|
|
205
205
|
}
|
|
206
|
-
console.log(chalk.dim("\nNext: invite developers with ") + chalk.bold("saarthiclaw team invite <name>") + chalk.dim(" (or on the dashboard → Members)
|
|
206
|
+
console.log(chalk.dim("\nNext: invite developers with ") + chalk.bold("saarthiclaw team invite <name>") + chalk.dim(" (or on the dashboard → Members)."));
|
|
207
|
+
console.log(chalk.dim("Keep this folder and the website in step: ") + chalk.bold("npx saarthiclaw team watch") + "\n");
|
|
207
208
|
} else {
|
|
208
209
|
if (!me.project?.linked) console.log(chalk.yellow("The Admin has not linked a project yet. You can still connect; changes are accepted once they do.\n"));
|
|
209
210
|
const next = {
|
|
@@ -211,7 +212,8 @@ ${explainLevel(me)}
|
|
|
211
212
|
needs_approval: 'npx saarthiclaw agent "describe the change" (it waits for the Admin, then applies)',
|
|
212
213
|
suggest_only: 'npx saarthiclaw team suggest "your idea"'
|
|
213
214
|
};
|
|
214
|
-
console.log(chalk.dim("Next: ") + chalk.bold(next[me.permissionLevel] ?? "npx saarthiclaw")
|
|
215
|
+
console.log(chalk.dim("Next: ") + chalk.bold(next[me.permissionLevel] ?? "npx saarthiclaw"));
|
|
216
|
+
console.log(chalk.dim("Get the team's latest code in this folder automatically: ") + chalk.bold("npx saarthiclaw team watch") + "\n");
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
async function teamStatus(session) {
|
|
@@ -343,7 +345,7 @@ async function teamInbox(session) {
|
|
|
343
345
|
});
|
|
344
346
|
if (what === "back") continue;
|
|
345
347
|
if (what === "run") {
|
|
346
|
-
const { runAgentTask } = await import("./orchestrator-
|
|
348
|
+
const { runAgentTask } = await import("./orchestrator-NJ7US5XC.js");
|
|
347
349
|
const task = `${item.message}${item.adminNote ? `
|
|
348
350
|
|
|
349
351
|
Admin note: ${item.adminNote}` : ""}
|
|
@@ -371,6 +373,98 @@ async function teamDisconnect(session) {
|
|
|
371
373
|
await getTeamContext(session, { refresh: true });
|
|
372
374
|
console.log(chalk.green("\n✓ Disconnected. SaarthiClaw now works solo in this project.\n"));
|
|
373
375
|
}
|
|
376
|
+
async function teamWatch(session, opts) {
|
|
377
|
+
const { syncWorkspace, readWorkspaceState } = await import("./workspace-XERWEYJB.js");
|
|
378
|
+
const { client, link } = requireLinked(session);
|
|
379
|
+
const me = await client.whoami();
|
|
380
|
+
const canPush = me.role === "admin" || me.permissionLevel === "trusted";
|
|
381
|
+
let prefer;
|
|
382
|
+
if (opts.prefer) {
|
|
383
|
+
const p = opts.prefer.trim().toLowerCase();
|
|
384
|
+
if (p !== "website" && p !== "laptop") throw new UserFacingError(`Unknown --prefer "${opts.prefer}".`, "Use --prefer website or --prefer laptop.");
|
|
385
|
+
if (p === "laptop" && !canPush) throw new UserFacingError("Only the Admin and Trusted members can send this folder's version to the website.", "Use --prefer website, or send changes for review with the agent.");
|
|
386
|
+
prefer = p;
|
|
387
|
+
}
|
|
388
|
+
const seconds = Math.min(60, Math.max(1, Number.parseFloat(opts.interval ?? "2") || 2));
|
|
389
|
+
console.log(chalk.bold(`
|
|
390
|
+
🔄 Syncing this folder with the team website (${link.server})`));
|
|
391
|
+
console.log(chalk.dim(canPush ? " Two-way: approved website changes come down here; your edits in this folder go up to the website (as a version you can revert)." : " One-way: approved website changes come down here. Your own edits go through the agent / website for review."));
|
|
392
|
+
console.log(chalk.dim(" Only text files are synced (no node_modules, build folders, images or secrets like .env).\n"));
|
|
393
|
+
const stamp = () => chalk.dim((/* @__PURE__ */ new Date()).toLocaleTimeString());
|
|
394
|
+
const shownConflicts = /* @__PURE__ */ new Set();
|
|
395
|
+
let offline = false;
|
|
396
|
+
const round = async () => {
|
|
397
|
+
const report = await syncWorkspace(session.root, client, { canPush, prefer });
|
|
398
|
+
if (report.needsChoice) {
|
|
399
|
+
const { differing, onlyLaptop, onlyWebsite } = report.needsChoice;
|
|
400
|
+
console.log(chalk.yellow("This folder and the website have different versions of the project:"));
|
|
401
|
+
if (differing.length) console.log(` • ${differing.length} file(s) differ: ${differing.slice(0, 8).join(", ")}${differing.length > 8 ? ", …" : ""}`);
|
|
402
|
+
if (onlyLaptop.length) console.log(` • ${onlyLaptop.length} file(s) only in this folder: ${onlyLaptop.slice(0, 8).join(", ")}${onlyLaptop.length > 8 ? ", …" : ""}`);
|
|
403
|
+
if (onlyWebsite.length) console.log(` • ${onlyWebsite.length} file(s) only on the website: ${onlyWebsite.slice(0, 8).join(", ")}${onlyWebsite.length > 8 ? ", …" : ""}`);
|
|
404
|
+
if (!session.prompter.interactive) throw new UserFacingError("Choose which version to keep.", `Run again with --prefer website${canPush ? " or --prefer laptop" : ""}.`);
|
|
405
|
+
const options = [
|
|
406
|
+
{ value: "website", label: "Use the website version", hint: "overwrites the differing files in this folder" }
|
|
407
|
+
];
|
|
408
|
+
if (canPush) options.push({ value: "laptop", label: "Use this folder's version", hint: "sends it to the website as a new version (revertable)" });
|
|
409
|
+
options.push({ value: "cancel", label: "Cancel" });
|
|
410
|
+
const choice = await session.prompter.select({ message: "Which version should both sides use?", options });
|
|
411
|
+
if (choice === "cancel") return false;
|
|
412
|
+
prefer = choice;
|
|
413
|
+
return round();
|
|
414
|
+
}
|
|
415
|
+
for (const p of report.pulled) console.log(`${stamp()} ${chalk.cyan("⬇")} ${p} ${chalk.dim("(from the website)")}`);
|
|
416
|
+
for (const p of report.deletedLocal) console.log(`${stamp()} ${chalk.cyan("⬇")} ${p} ${chalk.dim("deleted (from the website)")}`);
|
|
417
|
+
if (report.pushed.length) console.log(`${stamp()} ${chalk.green("⬆")} ${report.pushed.join(", ")} ${chalk.dim(`→ website${report.versionNote ? ` (${report.versionNote})` : ""}`)}`);
|
|
418
|
+
if (report.skippedDeletes) console.log(chalk.yellow(`${stamp()} ⚠ ${report.skippedDeletes} files are missing from this folder. Not deleting them on the website — if that was on purpose, delete them on the website instead.`));
|
|
419
|
+
for (const p of report.conflicts) {
|
|
420
|
+
if (shownConflicts.has(p)) continue;
|
|
421
|
+
shownConflicts.add(p);
|
|
422
|
+
console.log(chalk.yellow(`${stamp()} ⚠ ${p} changed both here and on the website. Your file was left as it is.`));
|
|
423
|
+
console.log(chalk.dim(` Keep the website's: run with --prefer website.${canPush ? " Keep yours: --prefer laptop." : ""} Or compare on the website (Code / History).`));
|
|
424
|
+
}
|
|
425
|
+
return true;
|
|
426
|
+
};
|
|
427
|
+
if (opts.once) {
|
|
428
|
+
if (await round()) {
|
|
429
|
+
const st = readWorkspaceState(session.root);
|
|
430
|
+
console.log(chalk.green(`
|
|
431
|
+
✓ In sync with website version #${st.lastVersionId}.`) + "\n");
|
|
432
|
+
}
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
let stop = false;
|
|
436
|
+
const onSig = () => {
|
|
437
|
+
stop = true;
|
|
438
|
+
console.log(chalk.dim("\nStopped syncing."));
|
|
439
|
+
};
|
|
440
|
+
process.once("SIGINT", onSig);
|
|
441
|
+
console.log(chalk.dim("Watching… press Ctrl+C to stop.\n"));
|
|
442
|
+
try {
|
|
443
|
+
while (!stop) {
|
|
444
|
+
try {
|
|
445
|
+
const okRound = await round();
|
|
446
|
+
if (!okRound) return;
|
|
447
|
+
if (offline) {
|
|
448
|
+
console.log(chalk.green(`${stamp()} ✓ Connected again.`));
|
|
449
|
+
offline = false;
|
|
450
|
+
}
|
|
451
|
+
if (prefer) prefer = void 0;
|
|
452
|
+
} catch (e) {
|
|
453
|
+
if (e instanceof UserFacingError && !(e instanceof TeamApiError)) {
|
|
454
|
+
if (!offline) console.log(chalk.yellow(`${stamp()} ⚠ ${e.message} Retrying…`));
|
|
455
|
+
offline = true;
|
|
456
|
+
} else if (e instanceof TeamApiError && (e.status === 401 || e.status === 403)) {
|
|
457
|
+
throw e;
|
|
458
|
+
} else {
|
|
459
|
+
console.log(chalk.yellow(`${stamp()} ⚠ ${e.message}`));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
for (let i = 0; i < seconds * 10 && !stop; i++) await new Promise((r) => setTimeout(r, 100));
|
|
463
|
+
}
|
|
464
|
+
} finally {
|
|
465
|
+
process.removeListener("SIGINT", onSig);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
374
468
|
export {
|
|
375
469
|
DEFAULT_SERVER,
|
|
376
470
|
teamConnect,
|
|
@@ -379,5 +473,6 @@ export {
|
|
|
379
473
|
teamInvite,
|
|
380
474
|
teamStatus,
|
|
381
475
|
teamSuggest,
|
|
382
|
-
teamSync
|
|
476
|
+
teamSync,
|
|
477
|
+
teamWatch
|
|
383
478
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generatePlan,
|
|
3
3
|
stepPrompt
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-N33J57DT.js";
|
|
5
5
|
import {
|
|
6
6
|
createWebTools
|
|
7
7
|
} from "./chunk-HFMRQTXE.js";
|
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
createReadOnlyTools,
|
|
11
11
|
dedupeReadOnlyTools,
|
|
12
12
|
finishOnLastStep
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OF5PQQQ4.js";
|
|
14
14
|
import {
|
|
15
15
|
ToolExecutor
|
|
16
16
|
} from "./chunk-CGJ4VEUD.js";
|
|
17
17
|
import {
|
|
18
18
|
groupPending
|
|
19
19
|
} from "./chunk-QRAFFI5V.js";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-S6YZ2A73.js";
|
|
21
|
+
import "./chunk-33MUQ6E5.js";
|
|
22
22
|
import {
|
|
23
23
|
waitForInterrupt
|
|
24
24
|
} from "./chunk-HGBZ55ND.js";
|
|
@@ -411,7 +411,7 @@ ${list}`);
|
|
|
411
411
|
|
|
412
412
|
// modes/telegram/index.ts
|
|
413
413
|
async function runTelegramMode(session) {
|
|
414
|
-
const { getTeamContext } = await import("./context-
|
|
414
|
+
const { getTeamContext } = await import("./context-RKFGCGP7.js");
|
|
415
415
|
const team = await getTeamContext(session);
|
|
416
416
|
if (team.mode === "needs_approval" || team.mode === "suggest_only") {
|
|
417
417
|
throw new UserFacingError(
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runAgentMode
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XT5WAZRV.js";
|
|
4
4
|
import {
|
|
5
5
|
runAskMode
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SYH37PL6.js";
|
|
7
7
|
import {
|
|
8
8
|
runPlanMode
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-N33J57DT.js";
|
|
10
10
|
import "./chunk-HFMRQTXE.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-OF5PQQQ4.js";
|
|
12
12
|
import "./chunk-CGJ4VEUD.js";
|
|
13
13
|
import "./chunk-QRAFFI5V.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-S6YZ2A73.js";
|
|
15
|
+
import "./chunk-33MUQ6E5.js";
|
|
16
16
|
import {
|
|
17
17
|
RunCancelledError
|
|
18
18
|
} from "./chunk-HGBZ55ND.js";
|
|
@@ -122,14 +122,14 @@ async function runWakeup(session) {
|
|
|
122
122
|
}
|
|
123
123
|
if (choice === MainMenu.Telegram) {
|
|
124
124
|
await runModeSafely(session, async () => {
|
|
125
|
-
const { runTelegramMode } = await import("./telegram-
|
|
125
|
+
const { runTelegramMode } = await import("./telegram-IMADPCKR.js");
|
|
126
126
|
await runTelegramMode(session);
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
async function runTeamMenu(session) {
|
|
132
|
-
const team = await import("./team-
|
|
132
|
+
const team = await import("./team-PFETXIEC.js");
|
|
133
133
|
const { readTeamLink } = await import("./store-JG5OKLEO.js");
|
|
134
134
|
while (true) {
|
|
135
135
|
const link = readTeamLink(session.root, session.env ?? process.env);
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TeamApiError
|
|
3
|
+
} from "./chunk-33MUQ6E5.js";
|
|
4
|
+
import {
|
|
5
|
+
sha256Hex
|
|
6
|
+
} from "./chunk-H2FAKNUI.js";
|
|
7
|
+
import {
|
|
8
|
+
isSecretPath
|
|
9
|
+
} from "./chunk-R4PMMMD5.js";
|
|
10
|
+
import "./chunk-2GDAWRT7.js";
|
|
11
|
+
import {
|
|
12
|
+
projectStateDir
|
|
13
|
+
} from "./chunk-MMIJKDOU.js";
|
|
14
|
+
import "./chunk-IT46XDPQ.js";
|
|
15
|
+
|
|
16
|
+
// team/workspace.ts
|
|
17
|
+
import fs from "node:fs";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "out", "coverage", "__pycache__", "venv", ".venv", "vendor"]);
|
|
20
|
+
var BINARY_EXT = /\.(png|jpe?g|gif|webp|ico|bmp|pdf|zip|gz|tar|rar|7z|woff2?|ttf|otf|eot|mp3|mp4|wav|mov|avi|exe|dll|so|dylib|class|jar|db|sqlite|lockb)$/i;
|
|
21
|
+
var MAX_FILE = 1024 * 1024;
|
|
22
|
+
var MAX_FILES = 2e3;
|
|
23
|
+
function workspaceStateFile(root) {
|
|
24
|
+
return path.join(projectStateDir(root), "workspace-sync.json");
|
|
25
|
+
}
|
|
26
|
+
function readWorkspaceState(root) {
|
|
27
|
+
try {
|
|
28
|
+
const raw = JSON.parse(fs.readFileSync(workspaceStateFile(root), "utf8"));
|
|
29
|
+
return {
|
|
30
|
+
lastVersionId: Number.isInteger(raw.lastVersionId) ? Number(raw.lastVersionId) : 0,
|
|
31
|
+
files: raw.files && typeof raw.files === "object" ? raw.files : {},
|
|
32
|
+
conflicts: raw.conflicts && typeof raw.conflicts === "object" ? raw.conflicts : {}
|
|
33
|
+
};
|
|
34
|
+
} catch {
|
|
35
|
+
return { lastVersionId: 0, files: {}, conflicts: {} };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function writeWorkspaceState(root, state) {
|
|
39
|
+
const file = workspaceStateFile(root);
|
|
40
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
41
|
+
const tmp = `${file}.tmp`;
|
|
42
|
+
fs.writeFileSync(tmp, JSON.stringify(state, null, 2));
|
|
43
|
+
fs.renameSync(tmp, file);
|
|
44
|
+
}
|
|
45
|
+
function resetWorkspaceState(root) {
|
|
46
|
+
try {
|
|
47
|
+
fs.unlinkSync(workspaceStateFile(root));
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function scanLocal(root) {
|
|
52
|
+
const out = /* @__PURE__ */ new Map();
|
|
53
|
+
const walk = (dir, rel) => {
|
|
54
|
+
let entries;
|
|
55
|
+
try {
|
|
56
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
57
|
+
} catch {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
for (const ent of entries) {
|
|
61
|
+
if (out.size >= MAX_FILES) return;
|
|
62
|
+
const relPath = rel ? `${rel}/${ent.name}` : ent.name;
|
|
63
|
+
if (ent.isSymbolicLink()) continue;
|
|
64
|
+
if (ent.isDirectory()) {
|
|
65
|
+
if (ent.name.startsWith(".") || SKIP_DIRS.has(ent.name)) continue;
|
|
66
|
+
walk(path.join(dir, ent.name), relPath);
|
|
67
|
+
} else if (ent.isFile()) {
|
|
68
|
+
if (!isSyncable(relPath)) continue;
|
|
69
|
+
const full = path.join(dir, ent.name);
|
|
70
|
+
try {
|
|
71
|
+
if (fs.statSync(full).size > MAX_FILE) continue;
|
|
72
|
+
const text = fs.readFileSync(full, "utf8");
|
|
73
|
+
if (text.includes("\0")) continue;
|
|
74
|
+
out.set(relPath, text);
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
walk(root, "");
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
function isSyncable(relPosix) {
|
|
84
|
+
if (!relPosix || relPosix.split("/").some((p) => p === ".." || p.startsWith(".") || SKIP_DIRS.has(p))) return false;
|
|
85
|
+
if (isSecretPath(relPosix) || BINARY_EXT.test(relPosix)) return false;
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
function resolveInside(root, rel) {
|
|
89
|
+
const full = path.resolve(root, ...rel.split("/"));
|
|
90
|
+
const r = path.resolve(root);
|
|
91
|
+
if (full !== r && !full.startsWith(r + path.sep)) throw new Error(`Refusing a path outside the project: ${rel}`);
|
|
92
|
+
return full;
|
|
93
|
+
}
|
|
94
|
+
function writeLocal(root, rel, content) {
|
|
95
|
+
if (!isSyncable(rel)) return;
|
|
96
|
+
const full = resolveInside(root, rel);
|
|
97
|
+
if (content === null) {
|
|
98
|
+
try {
|
|
99
|
+
fs.unlinkSync(full);
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
let dir = path.dirname(full);
|
|
103
|
+
while (dir !== path.resolve(root) && dir.startsWith(path.resolve(root))) {
|
|
104
|
+
try {
|
|
105
|
+
if (fs.readdirSync(dir).length) break;
|
|
106
|
+
fs.rmdirSync(dir);
|
|
107
|
+
} catch {
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
dir = path.dirname(dir);
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
fs.mkdirSync(path.dirname(full), { recursive: true });
|
|
115
|
+
const tmp = `${full}.saarthiclaw-tmp`;
|
|
116
|
+
fs.writeFileSync(tmp, content, "utf8");
|
|
117
|
+
fs.renameSync(tmp, full);
|
|
118
|
+
}
|
|
119
|
+
var hashOf = (text) => text === void 0 || text === null ? null : sha256Hex(text);
|
|
120
|
+
async function syncWorkspace(root, client, opts) {
|
|
121
|
+
const state = readWorkspaceState(root);
|
|
122
|
+
const report = { pulled: [], pushed: [], deletedLocal: [], conflicts: [] };
|
|
123
|
+
const local = scanLocal(root);
|
|
124
|
+
if (state.lastVersionId === 0 && Object.keys(state.files).length === 0) {
|
|
125
|
+
const first = await firstSync(root, client, state, local, opts, report);
|
|
126
|
+
writeWorkspaceState(root, state);
|
|
127
|
+
if (!first) return report;
|
|
128
|
+
return report;
|
|
129
|
+
}
|
|
130
|
+
const changes = await client.workspace(state.lastVersionId);
|
|
131
|
+
if (changes.snapshot) {
|
|
132
|
+
const server = new Map(changes.snapshot.map((f) => [f.path, f.content]));
|
|
133
|
+
const paths = /* @__PURE__ */ new Set([...server.keys(), ...Object.keys(state.files)]);
|
|
134
|
+
for (const p of paths) applyServerFile(root, state, local, p, server.has(p) ? server.get(p) : null, opts, report);
|
|
135
|
+
} else {
|
|
136
|
+
for (const v of changes.versions ?? []) for (const f of v.files) applyServerFile(root, state, local, f.path, f.after, opts, report);
|
|
137
|
+
}
|
|
138
|
+
state.lastVersionId = changes.latestVersionId;
|
|
139
|
+
writeWorkspaceState(root, state);
|
|
140
|
+
if (opts.canPush) await pushLocal(root, client, state, scanLocal(root), opts, report);
|
|
141
|
+
writeWorkspaceState(root, state);
|
|
142
|
+
return report;
|
|
143
|
+
}
|
|
144
|
+
function applyServerFile(root, state, local, p, after, opts, report) {
|
|
145
|
+
if (!isSyncable(p)) return;
|
|
146
|
+
const localText = local.has(p) ? local.get(p) : null;
|
|
147
|
+
const localHash = hashOf(localText), afterHash = hashOf(after), recorded = state.files[p] ?? null;
|
|
148
|
+
if (localHash === afterHash) {
|
|
149
|
+
if (afterHash) state.files[p] = afterHash;
|
|
150
|
+
else delete state.files[p];
|
|
151
|
+
delete state.conflicts[p];
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const untouched = localHash === recorded;
|
|
155
|
+
if (untouched || opts.prefer === "website") {
|
|
156
|
+
writeLocal(root, p, after);
|
|
157
|
+
if (after === null) {
|
|
158
|
+
delete state.files[p];
|
|
159
|
+
local.delete(p);
|
|
160
|
+
report.deletedLocal.push(p);
|
|
161
|
+
} else {
|
|
162
|
+
state.files[p] = afterHash;
|
|
163
|
+
local.set(p, after);
|
|
164
|
+
report.pulled.push(p);
|
|
165
|
+
}
|
|
166
|
+
delete state.conflicts[p];
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (opts.prefer === "laptop" && opts.canPush) {
|
|
170
|
+
state.conflicts[p] = afterHash ?? "deleted";
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
state.conflicts[p] = afterHash ?? "deleted";
|
|
174
|
+
report.conflicts.push(p);
|
|
175
|
+
}
|
|
176
|
+
async function pushLocal(root, client, state, local, opts, report) {
|
|
177
|
+
const changes = [];
|
|
178
|
+
const paths = /* @__PURE__ */ new Set([...local.keys(), ...Object.keys(state.files)]);
|
|
179
|
+
for (const p of paths) {
|
|
180
|
+
const text = local.has(p) ? local.get(p) : null;
|
|
181
|
+
const h = hashOf(text), recorded = state.files[p] ?? null;
|
|
182
|
+
if (h === recorded) continue;
|
|
183
|
+
if (state.conflicts[p] !== void 0) {
|
|
184
|
+
if (opts.prefer !== "laptop") continue;
|
|
185
|
+
const serverHash = state.conflicts[p] === "deleted" ? null : state.conflicts[p];
|
|
186
|
+
changes.push({ path: p, content: text, baseHash: serverHash });
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
changes.push({ path: p, content: text, baseHash: recorded });
|
|
190
|
+
}
|
|
191
|
+
if (!changes.length) return;
|
|
192
|
+
const deletes = changes.filter((c) => c.content === null).length;
|
|
193
|
+
const max = opts.maxDeletes ?? 25;
|
|
194
|
+
if (deletes > max && deletes > Object.keys(state.files).length / 2) {
|
|
195
|
+
report.skippedDeletes = deletes;
|
|
196
|
+
const keep = changes.filter((c) => c.content !== null);
|
|
197
|
+
if (!keep.length) return;
|
|
198
|
+
changes.length = 0;
|
|
199
|
+
changes.push(...keep);
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const res = await client.pushWorkspace(changes.slice(0, MAX_FILES));
|
|
203
|
+
for (const c of changes) {
|
|
204
|
+
if (c.content === null) delete state.files[c.path];
|
|
205
|
+
else state.files[c.path] = sha256Hex(c.content);
|
|
206
|
+
delete state.conflicts[c.path];
|
|
207
|
+
report.pushed.push(c.path);
|
|
208
|
+
}
|
|
209
|
+
if (res.version) report.versionNote = `version #${res.version.id}`;
|
|
210
|
+
} catch (e) {
|
|
211
|
+
if (e instanceof TeamApiError && e.code === "CONFLICT") {
|
|
212
|
+
for (const c of changes) if (!report.conflicts.includes(c.path)) report.conflicts.push(c.path);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
throw e;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
async function firstSync(root, client, state, local, opts, report) {
|
|
219
|
+
const snap = await client.workspace(0);
|
|
220
|
+
const server = new Map((snap.snapshot ?? []).map((f) => [f.path, f.content]));
|
|
221
|
+
const differing = [], onlyLaptop = [], onlyWebsite = [];
|
|
222
|
+
for (const [p, c] of server) {
|
|
223
|
+
if (!isSyncable(p)) continue;
|
|
224
|
+
if (!local.has(p)) onlyWebsite.push(p);
|
|
225
|
+
else if (local.get(p) !== c) differing.push(p);
|
|
226
|
+
}
|
|
227
|
+
for (const p of local.keys()) if (!server.has(p)) onlyLaptop.push(p);
|
|
228
|
+
const websiteEmpty = server.size === 0;
|
|
229
|
+
const needChoice = differing.length > 0 || onlyLaptop.length > 0 && !websiteEmpty;
|
|
230
|
+
if (needChoice && !opts.prefer) {
|
|
231
|
+
report.needsChoice = { differing, onlyLaptop, onlyWebsite };
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
const laptopWins = opts.prefer === "laptop" || websiteEmpty && opts.canPush;
|
|
235
|
+
if (laptopWins && !opts.canPush) throw new Error("Only the Admin and Trusted members can send this folder to the website.");
|
|
236
|
+
for (const [p, c] of server) if (local.get(p) === c) state.files[p] = sha256Hex(c);
|
|
237
|
+
if (laptopWins) {
|
|
238
|
+
const changes = [];
|
|
239
|
+
for (const p of [...differing, ...onlyLaptop]) changes.push({ path: p, content: local.get(p), baseHash: hashOf(server.get(p)) });
|
|
240
|
+
for (const p of onlyWebsite) {
|
|
241
|
+
writeLocal(root, p, server.get(p));
|
|
242
|
+
state.files[p] = sha256Hex(server.get(p));
|
|
243
|
+
report.pulled.push(p);
|
|
244
|
+
}
|
|
245
|
+
if (changes.length) {
|
|
246
|
+
const res = await client.pushWorkspace(changes, "Synced from the laptop folder");
|
|
247
|
+
for (const c of changes) {
|
|
248
|
+
state.files[c.path] = sha256Hex(c.content);
|
|
249
|
+
report.pushed.push(c.path);
|
|
250
|
+
}
|
|
251
|
+
if (res.version) report.versionNote = `version #${res.version.id}`;
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
for (const p of [...differing, ...onlyWebsite]) {
|
|
255
|
+
writeLocal(root, p, server.get(p));
|
|
256
|
+
state.files[p] = sha256Hex(server.get(p));
|
|
257
|
+
report.pulled.push(p);
|
|
258
|
+
}
|
|
259
|
+
if (opts.canPush && onlyLaptop.length) {
|
|
260
|
+
const changes = onlyLaptop.map((p) => ({ path: p, content: local.get(p), baseHash: null }));
|
|
261
|
+
const res = await client.pushWorkspace(changes, "Synced from the laptop folder");
|
|
262
|
+
for (const c of changes) {
|
|
263
|
+
state.files[c.path] = sha256Hex(c.content);
|
|
264
|
+
report.pushed.push(c.path);
|
|
265
|
+
}
|
|
266
|
+
if (res.version) report.versionNote = `version #${res.version.id}`;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const after = await client.workspace(0);
|
|
270
|
+
state.lastVersionId = after.latestVersionId;
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
export {
|
|
274
|
+
isSyncable,
|
|
275
|
+
readWorkspaceState,
|
|
276
|
+
resetWorkspaceState,
|
|
277
|
+
scanLocal,
|
|
278
|
+
syncWorkspace,
|
|
279
|
+
workspaceStateFile,
|
|
280
|
+
writeWorkspaceState
|
|
281
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -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-
|
|
40
|
+
const { renderBanner, runWakeup } = await import("./chunks/wakeup-UX6AM7M6.js");
|
|
41
41
|
if (g.banner !== false) console.log(renderBanner(getVersion()) + "\n");
|
|
42
42
|
const { hasAiAccess } = await import("./chunks/session-ZC5D2O77.js");
|
|
43
43
|
if (!hasAiAccess(session)) {
|
|
@@ -66,36 +66,36 @@ function buildProgram() {
|
|
|
66
66
|
program.command("wakeup").aliases(["wake", "start"]).description("open the interactive menu (CLI: Ask / Plan / Agent, or Telegram)").action(async (_opts, cmd) => startWakeup(cmd));
|
|
67
67
|
program.command("init").description("guided one-time setup (API key, model, safety options)").action(async (_opts, cmd) => {
|
|
68
68
|
const session = await bootstrap(cmd, { needsTty: "`saarthiclaw init`" });
|
|
69
|
-
const { runInit } = await import("./chunks/init-
|
|
69
|
+
const { runInit } = await import("./chunks/init-5ENYFSX2.js");
|
|
70
70
|
await runInit({ root: session.root, prompter: session.prompter, decorate: true });
|
|
71
71
|
});
|
|
72
72
|
program.command("doctor").description("check your setup (Node, config, API key, a live test call)").option("--offline", "skip the live model call").action(async (opts, cmd) => {
|
|
73
73
|
const session = await bootstrap(cmd);
|
|
74
|
-
const { runDoctor } = await import("./chunks/doctor-
|
|
74
|
+
const { runDoctor } = await import("./chunks/doctor-ZQICU2F4.js");
|
|
75
75
|
const code = await runDoctor(session, { live: !opts.offline });
|
|
76
76
|
if (code !== 0) throw new CommanderError(code, "saarthiclaw.doctorFailed", "");
|
|
77
77
|
});
|
|
78
78
|
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) => {
|
|
79
79
|
const question = joinWords(words);
|
|
80
80
|
const session = await bootstrap(cmd, { needsTty: question && !opts.save ? void 0 : "`saarthiclaw ask` without a question or with --save" });
|
|
81
|
-
const ask = await import("./chunks/orchestrator-
|
|
81
|
+
const ask = await import("./chunks/orchestrator-XLVMKC4V.js");
|
|
82
82
|
if (question) await ask.runAskOnce(session, question, opts.save);
|
|
83
83
|
else await ask.runAskMode(session);
|
|
84
84
|
});
|
|
85
85
|
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) => {
|
|
86
86
|
const session = await bootstrap(cmd, { needsTty: "`saarthiclaw plan`" });
|
|
87
|
-
const { runPlanMode } = await import("./chunks/orchestrator-
|
|
87
|
+
const { runPlanMode } = await import("./chunks/orchestrator-ATA2LHPJ.js");
|
|
88
88
|
await runPlanMode(session, joinWords(words));
|
|
89
89
|
});
|
|
90
90
|
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) => {
|
|
91
91
|
const task = joinWords(words);
|
|
92
92
|
const session = await bootstrap(cmd, { needsTty: opts.send && task ? void 0 : "`saarthiclaw agent`" });
|
|
93
|
-
const { runAgentMode } = await import("./chunks/orchestrator-
|
|
93
|
+
const { runAgentMode } = await import("./chunks/orchestrator-NJ7US5XC.js");
|
|
94
94
|
await runAgentMode(session, task, { send: opts.send });
|
|
95
95
|
});
|
|
96
96
|
program.command("telegram").description("run the Telegram remote-control bot (owner only) until Ctrl+C").action(async (_opts, cmd) => {
|
|
97
97
|
const session = await bootstrap(cmd);
|
|
98
|
-
const { runTelegramMode } = await import("./chunks/telegram-
|
|
98
|
+
const { runTelegramMode } = await import("./chunks/telegram-IMADPCKR.js");
|
|
99
99
|
await runTelegramMode(session);
|
|
100
100
|
});
|
|
101
101
|
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) => {
|
|
@@ -107,44 +107,49 @@ function buildProgram() {
|
|
|
107
107
|
});
|
|
108
108
|
const team = program.command("team").description("work with a team dashboard: connect, sync approved changes, suggest, invite").action(async (_opts, cmd) => {
|
|
109
109
|
const session = await bootstrap(cmd);
|
|
110
|
-
const { teamStatus } = await import("./chunks/team-
|
|
110
|
+
const { teamStatus } = await import("./chunks/team-PFETXIEC.js");
|
|
111
111
|
await teamStatus(session);
|
|
112
112
|
});
|
|
113
113
|
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) => {
|
|
114
114
|
const session = await bootstrap(cmd, { needsTty: process.env.SAARTHICLAW_TEAM_KEY ? void 0 : "`saarthiclaw team connect` (or set SAARTHICLAW_TEAM_KEY)" });
|
|
115
|
-
const { teamConnect } = await import("./chunks/team-
|
|
115
|
+
const { teamConnect } = await import("./chunks/team-PFETXIEC.js");
|
|
116
116
|
await teamConnect(session, url);
|
|
117
117
|
});
|
|
118
118
|
team.command("status").description("who you are, your level, and what is waiting").action(async (_opts, cmd) => {
|
|
119
119
|
const session = await bootstrap(cmd);
|
|
120
|
-
const { teamStatus } = await import("./chunks/team-
|
|
120
|
+
const { teamStatus } = await import("./chunks/team-PFETXIEC.js");
|
|
121
121
|
await teamStatus(session);
|
|
122
122
|
});
|
|
123
123
|
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) => {
|
|
124
124
|
const session = await bootstrap(cmd);
|
|
125
125
|
const g = cmd.optsWithGlobals();
|
|
126
|
-
const { teamSync } = await import("./chunks/team-
|
|
126
|
+
const { teamSync } = await import("./chunks/team-PFETXIEC.js");
|
|
127
127
|
await teamSync(session, { yes: opts.yes, wait: opts.wait, allowShell: g.allowShell });
|
|
128
128
|
});
|
|
129
|
+
team.command("watch").description("keep this folder and the team website in step (approved website changes come down here; Admin/Trusted edits go up)").option("--once", "sync one time and exit").option("--prefer <side>", "when both sides changed a file: website | laptop").option("--interval <seconds>", "how often to check (default 2)").action(async (opts, cmd) => {
|
|
130
|
+
const session = await bootstrap(cmd);
|
|
131
|
+
const { teamWatch } = await import("./chunks/team-PFETXIEC.js");
|
|
132
|
+
await teamWatch(session, opts);
|
|
133
|
+
});
|
|
129
134
|
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) => {
|
|
130
135
|
const idea = joinWords(words);
|
|
131
136
|
const session = await bootstrap(cmd, { needsTty: idea ? void 0 : "`saarthiclaw team suggest` without text" });
|
|
132
|
-
const { teamSuggest } = await import("./chunks/team-
|
|
137
|
+
const { teamSuggest } = await import("./chunks/team-PFETXIEC.js");
|
|
133
138
|
await teamSuggest(session, idea);
|
|
134
139
|
});
|
|
135
140
|
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) => {
|
|
136
141
|
const session = await bootstrap(cmd, { needsTty: name ? void 0 : "`saarthiclaw team invite` without a name" });
|
|
137
|
-
const { teamInvite } = await import("./chunks/team-
|
|
142
|
+
const { teamInvite } = await import("./chunks/team-PFETXIEC.js");
|
|
138
143
|
await teamInvite(session, name ?? "", opts.level);
|
|
139
144
|
});
|
|
140
145
|
team.command("inbox").description("(Admin) suggestions you forwarded to the agent; run the agent on one").action(async (_opts, cmd) => {
|
|
141
146
|
const session = await bootstrap(cmd);
|
|
142
|
-
const { teamInbox } = await import("./chunks/team-
|
|
147
|
+
const { teamInbox } = await import("./chunks/team-PFETXIEC.js");
|
|
143
148
|
await teamInbox(session);
|
|
144
149
|
});
|
|
145
150
|
team.command("disconnect").alias("leave").description("unlink this project from the dashboard (back to solo mode)").action(async (_opts, cmd) => {
|
|
146
151
|
const session = await bootstrap(cmd, { needsTty: "`saarthiclaw team disconnect`" });
|
|
147
|
-
const { teamDisconnect } = await import("./chunks/team-
|
|
152
|
+
const { teamDisconnect } = await import("./chunks/team-PFETXIEC.js");
|
|
148
153
|
await teamDisconnect(session);
|
|
149
154
|
});
|
|
150
155
|
program.addHelpText(
|
|
@@ -152,6 +157,7 @@ function buildProgram() {
|
|
|
152
157
|
`
|
|
153
158
|
Examples:
|
|
154
159
|
$ npx saarthiclaw init one-time setup
|
|
160
|
+
$ npx saarthiclaw team watch keep this folder in step with the team website
|
|
155
161
|
$ npx saarthiclaw open the menu (same as wakeup)
|
|
156
162
|
$ npx saarthiclaw ask "where is auth handled?"
|
|
157
163
|
$ npx saarthiclaw agent "add a /health route" --allow-shell
|
package/package.json
CHANGED