@rucher/cli 0.2.0-beta.8 → 0.2.0-beta.9
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/dist/cli.mjs +19 -15
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { defineCommand, runMain } from "citty";
|
|
|
3
3
|
import { existsSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
5
5
|
import tab from "@bomb.sh/tab/citty";
|
|
6
|
-
import { AGENT_KINDS, BLOCKED_HEADER, CarnetError, GUARDED_TOOLS, KIND_LEGEND, KIND_TAG_PATTERN, LEGEND, MAIN_HEADER, MAIN_IDLE, NOTES_HEADER, NOTE_KINDS, SIMILAR_PREFIX, SUBAGENT_RULES, WAITING_TOOL, WORKSPACE_FILE, addWorkspaceRepo, appendPromptFile, archiveWorkspaceSessions, claudeCode, createWorkspace, definitionInstructions, deleteWorkspaceNotes, dropWorkspace, formatClock, guardSubagentCall, handleSessionEnd, handleSessionStart, handleStop, handleToolStart, handleToolUse, handleUserPromptSubmit, hostById, isAgentKind, isWorkspaceName, kindTag, listWorkspaces, loadWorkspace, memoryHalfLife, moveSession, openCarnet, openResolvedCarnet, openWorkspaceCarnet, removeWorkspaceRepo, renderRunDirectory, renderSections, repoNameFor, repoPathFor, requireWorkspace, resolveWorkspace, shortId, statusLinePath, workspaceExists, workspaceLabel, workspaceLastActive, workspaceRepoNames, workspaceSessionCounts, writeStatusLine } from "@rucher/carnet";
|
|
6
|
+
import { AGENT_KINDS, BLOCKED_HEADER, CarnetError, GUARDED_TOOLS, KIND_LEGEND, KIND_TAG_PATTERN, LAUNCH_TOOLS, LEGEND, MAIN_HEADER, MAIN_IDLE, NOTES_HEADER, NOTE_KINDS, SIMILAR_PREFIX, SUBAGENT_RULES, WAITING_TOOL, WORKSPACE_FILE, addWorkspaceRepo, appendPromptFile, archiveWorkspaceSessions, claudeCode, createWorkspace, definitionInstructions, deleteWorkspaceNotes, dropWorkspace, formatClock, guardMainLaunch, guardSubagentCall, handleSessionEnd, handleSessionStart, handleStop, handleToolStart, handleToolUse, handleUserPromptSubmit, hostById, isAgentKind, isWorkspaceName, kindTag, labelStatusLine, listWorkspaces, loadWorkspace, memoryHalfLife, moveSession, openCarnet, openResolvedCarnet, openWorkspaceCarnet, removeWorkspaceRepo, renderRunDirectory, renderSections, repoNameFor, repoPathFor, requireWorkspace, resolveWorkspace, shortId, statusLinePath, workspaceExists, workspaceLabel, workspaceLastActive, workspaceRepoNames, workspaceSessionCounts, writeStatusLine } from "@rucher/carnet";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
9
9
|
import { spawnSync } from "node:child_process";
|
|
@@ -246,7 +246,7 @@ async function setupCompletion(main) {
|
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
248
|
// package.json
|
|
249
|
-
var version = "0.2.0-beta.
|
|
249
|
+
var version = "0.2.0-beta.9";
|
|
250
250
|
// src/plugin.ts
|
|
251
251
|
const CLI_VERSION = version;
|
|
252
252
|
function readJson(path) {
|
|
@@ -374,7 +374,7 @@ function subagentStart(stdinText, io) {
|
|
|
374
374
|
return runHook(io, () => {
|
|
375
375
|
const payload = host.parseSubagentPayload(stdinText);
|
|
376
376
|
withCarnet$1(payload, io, (carnet) => {
|
|
377
|
-
carnet.agents.pairSubagent(payload.session_id, payload.agent_id);
|
|
377
|
+
carnet.agents.pairSubagent(payload.session_id, payload.agent_id, host.subagentNames(payload));
|
|
378
378
|
});
|
|
379
379
|
if (host.subagentInheritsContext(payload)) return;
|
|
380
380
|
const hookSpecificOutput = {
|
|
@@ -430,21 +430,24 @@ function scratchRoot(io) {
|
|
|
430
430
|
const uid = process.getuid?.() ?? 0;
|
|
431
431
|
return join(io.env.CLAUDE_CODE_TMPDIR ?? tmpdir(), `claude-${uid}`);
|
|
432
432
|
}
|
|
433
|
+
function denyToolCall(io, reason) {
|
|
434
|
+
const hookSpecificOutput = {
|
|
435
|
+
hookEventName: "PreToolUse",
|
|
436
|
+
permissionDecision: "deny",
|
|
437
|
+
permissionDecisionReason: reason
|
|
438
|
+
};
|
|
439
|
+
io.stdout(`${JSON.stringify({ hookSpecificOutput })}\n`);
|
|
440
|
+
}
|
|
433
441
|
function preToolUse(stdinText, io) {
|
|
434
442
|
return runHook(io, () => {
|
|
435
443
|
const payload = host.parseToolPayload(stdinText);
|
|
436
|
-
const
|
|
437
|
-
|
|
444
|
+
const tool = payload.tool_name ?? "";
|
|
445
|
+
const guarded = Boolean(payload.agent_id) && GUARDED_TOOLS.has(tool);
|
|
446
|
+
const launch = !payload.agent_id && LAUNCH_TOOLS.has(tool);
|
|
447
|
+
if (!guarded && !launch && (payload.agent_id || tool !== WAITING_TOOL)) return;
|
|
438
448
|
withCarnet$1(payload, io, (carnet) => {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (!reason) return;
|
|
442
|
-
const hookSpecificOutput = {
|
|
443
|
-
hookEventName: "PreToolUse",
|
|
444
|
-
permissionDecision: "deny",
|
|
445
|
-
permissionDecisionReason: reason
|
|
446
|
-
};
|
|
447
|
-
io.stdout(`${JSON.stringify({ hookSpecificOutput })}\n`);
|
|
449
|
+
const reason = guarded ? guardSubagentCall(carnet, payload, scratchRoot(io)) : launch ? guardMainLaunch(carnet, payload) : handleToolStart(carnet, payload);
|
|
450
|
+
if (reason) denyToolCall(io, reason);
|
|
448
451
|
});
|
|
449
452
|
});
|
|
450
453
|
}
|
|
@@ -1487,7 +1490,7 @@ function statusLine(stdinText, io) {
|
|
|
1487
1490
|
return 0;
|
|
1488
1491
|
}
|
|
1489
1492
|
if (typeof sessionId !== "string" || !/^[\w-]+$/.test(sessionId)) return 0;
|
|
1490
|
-
const line = readStatusLine(sessionId, io.env);
|
|
1493
|
+
const line = labelStatusLine(readStatusLine(sessionId, io.env));
|
|
1491
1494
|
if (line) io.stdout(`${line}\n`);
|
|
1492
1495
|
return 0;
|
|
1493
1496
|
}
|
|
@@ -1703,6 +1706,7 @@ function workspaceDrop(name, io, options = {}) {
|
|
|
1703
1706
|
refuseLive(carnet, "drop", options.isAlive ?? processIsAlive);
|
|
1704
1707
|
const at = (options.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
|
|
1705
1708
|
const archived = archiveWorkspaceSessions(carnet.db, name, at);
|
|
1709
|
+
carnet.releaseClosedSandboxes();
|
|
1706
1710
|
const deletedNotes = options.purge ? deleteWorkspaceNotes(carnet.db, name) : 0;
|
|
1707
1711
|
const workspace = dropWorkspace(name, {
|
|
1708
1712
|
purge: options.purge,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rucher/cli",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.9",
|
|
4
4
|
"description": "rucher: status, journal and sessions of your Claude Code sub-agents, from the terminal",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@bomb.sh/tab": "0.0.22",
|
|
38
|
-
"@rucher/carnet": "0.2.0-beta.
|
|
38
|
+
"@rucher/carnet": "0.2.0-beta.9",
|
|
39
39
|
"citty": "^0.2.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|