clawborrator-cli 0.0.7 → 0.0.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.
Files changed (2) hide show
  1. package/dist-bundled/claw.cjs +10 -164
  2. package/package.json +1 -1
@@ -6876,11 +6876,10 @@ var sessionAttach = new Command("attach").description("open a TUI on a session \
6876
6876
  }
6877
6877
  let sessionId = ref;
6878
6878
  if (sessionId.startsWith("@")) {
6879
- const wanted = sessionId.slice(1);
6880
6879
  const data = await api.get("/api/v1/sessions");
6881
- const match = data.items.find((s) => s.routingName === wanted);
6880
+ const match = data.items.find((s) => s.routingName === sessionId);
6882
6881
  if (!match) {
6883
- console.error(`error: no session with routing name @${wanted} (run \`claw session list\` to see what's available)`);
6882
+ console.error(`error: no session with routing name ${sessionId} (run \`claw session list\` to see what's available)`);
6884
6883
  process.exit(2);
6885
6884
  }
6886
6885
  sessionId = match.id;
@@ -7112,158 +7111,6 @@ function truncate(s, max) {
7112
7111
  return s.slice(0, max - 1) + "\u2026";
7113
7112
  }
7114
7113
 
7115
- // src/commands/session-init.ts
7116
- var import_node_path2 = require("node:path");
7117
- var import_node_fs2 = require("node:fs");
7118
- var import_node_child_process = require("node:child_process");
7119
- var HOOK_NAMES = [
7120
- "SessionStart",
7121
- "SessionEnd",
7122
- "UserPromptSubmit",
7123
- "PreToolUse",
7124
- "PostToolUse",
7125
- "PostToolUseFailure",
7126
- "TaskCreated",
7127
- "SubagentStart",
7128
- "SubagentStop",
7129
- "TaskCompleted",
7130
- "Stop",
7131
- "Notification"
7132
- ];
7133
- var TAG = "clawborrator-hook";
7134
- function hookCommand(name) {
7135
- return `node ".claude/hooks/clawborrator-tail.mjs" ${name} #${TAG}`;
7136
- }
7137
- function isOurHook(h) {
7138
- return h.type === "command" && h.command.includes(`#${TAG}`);
7139
- }
7140
- function fetchHookBundle() {
7141
- try {
7142
- const stdout = (0, import_node_child_process.execFileSync)("npx", ["-y", "clawborrator-mcp", "--print-hook-file"], {
7143
- stdio: ["ignore", "pipe", "inherit"],
7144
- encoding: "utf8",
7145
- // npx may take a while if the cache is cold (download + extract).
7146
- timeout: 12e4,
7147
- shell: true
7148
- // cross-platform PATH resolution on Windows
7149
- });
7150
- if (!stdout || !stdout.trim()) {
7151
- throw new Error("--print-hook-file returned empty output");
7152
- }
7153
- return stdout;
7154
- } catch (e) {
7155
- throw new Error(`failed to fetch hook bundle via npx: ${e?.message ?? String(e)}`);
7156
- }
7157
- }
7158
- var sessionInit = new Command("init").description("install clawborrator hooks into <cwd>/.claude/settings.json + .claude/hooks/").option("--cwd <dir>", "project directory (defaults to current cwd)").option("--remove", "remove the clawborrator hooks (and the bundled .mjs)").option("--refresh-hook", "re-fetch the bundled hook file even if it already exists").action(async (opts) => {
7159
- const root = (0, import_node_path2.resolve)(opts.cwd ?? process.cwd());
7160
- const claudeDir = (0, import_node_path2.resolve)(root, ".claude");
7161
- const hooksDir = (0, import_node_path2.resolve)(claudeDir, "hooks");
7162
- const hookFile = (0, import_node_path2.resolve)(hooksDir, "clawborrator-tail.mjs");
7163
- const settings = (0, import_node_path2.resolve)(claudeDir, "settings.json");
7164
- if (opts.remove) {
7165
- removeHooks(settings, hookFile);
7166
- return;
7167
- }
7168
- if (!(0, import_node_fs2.existsSync)(hooksDir)) (0, import_node_fs2.mkdirSync)(hooksDir, { recursive: true });
7169
- if (!(0, import_node_fs2.existsSync)(hookFile) || opts.refreshHook) {
7170
- console.log("fetching bundled hook from npm via `npx -y clawborrator-mcp --print-hook-file`...");
7171
- const bundle = fetchHookBundle();
7172
- (0, import_node_fs2.writeFileSync)(hookFile, bundle, "utf8");
7173
- try {
7174
- (0, import_node_fs2.chmodSync)(hookFile, 493);
7175
- } catch {
7176
- }
7177
- console.log(`\u2713 wrote ${hookFile} (${bundle.length} bytes)`);
7178
- } else {
7179
- console.log(`(${hookFile} already present \u2014 pass --refresh-hook to overwrite)`);
7180
- }
7181
- if (!(0, import_node_fs2.existsSync)(claudeDir)) (0, import_node_fs2.mkdirSync)(claudeDir, { recursive: true });
7182
- let s = {};
7183
- if ((0, import_node_fs2.existsSync)(settings)) {
7184
- try {
7185
- const raw = (0, import_node_fs2.readFileSync)(settings, "utf8");
7186
- if (raw.trim()) s = JSON.parse(raw);
7187
- } catch (e) {
7188
- console.error(`error: could not parse existing ${settings}: ${e?.message ?? e}`);
7189
- console.error(" fix the JSON and re-run `claw session init`");
7190
- process.exit(2);
7191
- }
7192
- }
7193
- if (!s.hooks) s.hooks = {};
7194
- let added = 0, alreadyPresent = 0, refreshed = 0;
7195
- for (const name of HOOK_NAMES) {
7196
- const arr = s.hooks[name] ??= [];
7197
- let entry = arr.find((e) => (e.matcher ?? ".*") === ".*");
7198
- if (!entry) {
7199
- entry = { matcher: ".*", hooks: [] };
7200
- arr.push(entry);
7201
- }
7202
- const existingIdx = entry.hooks.findIndex(isOurHook);
7203
- const desiredCmd = hookCommand(name);
7204
- if (existingIdx >= 0) {
7205
- if (entry.hooks[existingIdx].command !== desiredCmd) {
7206
- entry.hooks[existingIdx] = { type: "command", command: desiredCmd };
7207
- refreshed++;
7208
- } else {
7209
- alreadyPresent++;
7210
- }
7211
- continue;
7212
- }
7213
- entry.hooks.push({ type: "command", command: desiredCmd });
7214
- added++;
7215
- }
7216
- (0, import_node_fs2.writeFileSync)(settings, JSON.stringify(s, null, 2) + "\n");
7217
- if (added > 0) console.log(`\u2713 installed ${added} clawborrator hook${added === 1 ? "" : "s"} \u2192 ${settings}`);
7218
- if (refreshed > 0) console.log(`\u2713 refreshed ${refreshed} command line${refreshed === 1 ? "" : "s"} (e.g. updated to call the local file)`);
7219
- if (alreadyPresent > 0) console.log(` (${alreadyPresent} already up-to-date, untouched)`);
7220
- console.log("");
7221
- console.log("next: drop a .mcp.json with your channel token (`claw token mint --kind=channel");
7222
- console.log(" --name=<label> --mcp-snippet --out=.mcp.json`), then start CC with:");
7223
- console.log(" claude --dangerously-load-development-channels server:clawborrator");
7224
- console.log(" events will flow as you prompt; watch via `claw session attach <id>`.");
7225
- });
7226
- function removeHooks(settingsPath, hookFile) {
7227
- if ((0, import_node_fs2.existsSync)(hookFile)) {
7228
- try {
7229
- (0, import_node_fs2.unlinkSync)(hookFile);
7230
- console.log(`\u2713 removed ${hookFile}`);
7231
- } catch (e) {
7232
- console.warn(`warning: could not delete ${hookFile}: ${e?.message ?? e}`);
7233
- }
7234
- }
7235
- if (!(0, import_node_fs2.existsSync)(settingsPath)) {
7236
- console.log("(no settings.json to clean up)");
7237
- return;
7238
- }
7239
- let s;
7240
- try {
7241
- const raw = (0, import_node_fs2.readFileSync)(settingsPath, "utf8");
7242
- s = raw.trim() ? JSON.parse(raw) : {};
7243
- } catch (e) {
7244
- console.error(`error: could not parse ${settingsPath}: ${e?.message ?? e}`);
7245
- process.exit(2);
7246
- }
7247
- if (!s.hooks) {
7248
- console.log("(no hooks block in settings.json)");
7249
- return;
7250
- }
7251
- let touched = 0;
7252
- for (const name of HOOK_NAMES) {
7253
- const arr = s.hooks[name];
7254
- if (!arr) continue;
7255
- for (const entry of arr) {
7256
- const before = entry.hooks.length;
7257
- entry.hooks = entry.hooks.filter((h) => !isOurHook(h));
7258
- if (entry.hooks.length !== before) touched++;
7259
- }
7260
- s.hooks[name] = arr.filter((e) => e.hooks.length > 0);
7261
- if (s.hooks[name].length === 0) delete s.hooks[name];
7262
- }
7263
- (0, import_node_fs2.writeFileSync)(settingsPath, JSON.stringify(s, null, 2) + "\n");
7264
- console.log(`\u2713 removed ${touched} clawborrator hook entr${touched === 1 ? "y" : "ies"} from ${settingsPath}`);
7265
- }
7266
-
7267
7114
  // src/commands/session.ts
7268
7115
  function fmtDuration(ms) {
7269
7116
  if (!Number.isFinite(ms) || ms < 0) return "\u2014";
@@ -7280,11 +7127,10 @@ function fmtAgo(iso) {
7280
7127
  }
7281
7128
  async function resolveSessionId(idOrName) {
7282
7129
  if (!idOrName.startsWith("@")) return idOrName;
7283
- const wanted = idOrName.slice(1);
7284
7130
  const data = await api.get("/api/v1/sessions");
7285
- const match = data.items.find((s) => s.routingName === wanted);
7131
+ const match = data.items.find((s) => s.routingName === idOrName);
7286
7132
  if (!match) {
7287
- const err = new Error(`no session with routing name @${wanted} (run \`claw session list\` to see what's available)`);
7133
+ const err = new Error(`no session with routing name ${idOrName} (run \`claw session list\` to see what's available)`);
7288
7134
  err.code = "CLW_NO_ROUTING_MATCH";
7289
7135
  throw err;
7290
7136
  }
@@ -7391,11 +7237,11 @@ var sessionMessages = new Command("messages").alias("msgs").description("dump op
7391
7237
  console.log(`(more \u2014 older: --before ${data.firstId} \xB7 newer: --after ${data.lastId})`);
7392
7238
  }
7393
7239
  });
7394
- var sessionCmd = new Command("session").description("manage Claude Code sessions registered with this hub").addCommand(sessionList).addCommand(sessionInfo).addCommand(sessionAttach).addCommand(sessionInit).addCommand(sessionEvents).addCommand(sessionMessages);
7240
+ var sessionCmd = new Command("session").description("manage Claude Code sessions registered with this hub").addCommand(sessionList).addCommand(sessionInfo).addCommand(sessionAttach).addCommand(sessionEvents).addCommand(sessionMessages);
7395
7241
 
7396
7242
  // src/commands/token.ts
7397
- var import_node_fs3 = require("node:fs");
7398
- var import_node_path3 = require("node:path");
7243
+ var import_node_fs2 = require("node:fs");
7244
+ var import_node_path2 = require("node:path");
7399
7245
 
7400
7246
  // ../shared/dist/scopes.js
7401
7247
  var ALL_SCOPES = [
@@ -7452,8 +7298,8 @@ var tokenMint = new Command("mint").description("create a new token").requiredOp
7452
7298
  }
7453
7299
  }, null, 2) + "\n";
7454
7300
  if (opts.out) {
7455
- const target = (0, import_node_path3.resolve)(opts.out);
7456
- (0, import_node_fs3.writeFileSync)(target, json, "utf8");
7301
+ const target = (0, import_node_path2.resolve)(opts.out);
7302
+ (0, import_node_fs2.writeFileSync)(target, json, "utf8");
7457
7303
  prose("");
7458
7304
  prose(`\u2713 wrote ${target}`);
7459
7305
  } else {
@@ -7599,7 +7445,7 @@ var webhookCmd = new Command("webhook").description("manage webhook subscription
7599
7445
 
7600
7446
  // src/index.ts
7601
7447
  var program2 = new Command();
7602
- program2.name("claw").description("clawborrator CLI \u2014 control your Claude Code sessions from the terminal").version("0.0.7");
7448
+ program2.name("claw").description("clawborrator CLI \u2014 control your Claude Code sessions from the terminal").version("0.0.9");
7603
7449
  program2.addCommand(loginCmd);
7604
7450
  program2.addCommand(logoutCmd);
7605
7451
  program2.addCommand(whoamiCmd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawborrator-cli",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "description": "claw — command-line client for clawborrator hub_v1. Manages PATs, channel tokens, sessions, cross-session routing, and webhooks; ships an inline TUI for live multi-operator session attach.",
6
6
  "license": "MIT",