@useanvil/claude-code 0.8.0 → 0.8.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.
@@ -3232,11 +3232,22 @@ var init_modes = __esm({
3232
3232
  }
3233
3233
  });
3234
3234
 
3235
+ // src/coding-agents/claude-code/own.ts
3236
+ function table(entries) {
3237
+ return Object.assign(/* @__PURE__ */ Object.create(null), entries);
3238
+ }
3239
+ var init_own = __esm({
3240
+ "src/coding-agents/claude-code/own.ts"() {
3241
+ "use strict";
3242
+ }
3243
+ });
3244
+
3235
3245
  // src/coding-agents/claude-code/money.ts
3236
3246
  var MONEY, CURRENCIES;
3237
3247
  var init_money = __esm({
3238
3248
  "src/coding-agents/claude-code/money.ts"() {
3239
3249
  "use strict";
3250
+ init_own();
3240
3251
  MONEY = [
3241
3252
  {
3242
3253
  app: "stripe",
@@ -3378,7 +3389,7 @@ var init_money = __esm({
3378
3389
  nameless: ["/admin/api/*/graphql.json refundCreate", "/admin/api/*/orders/*/refunds.json"]
3379
3390
  }
3380
3391
  ];
3381
- CURRENCIES = {
3392
+ CURRENCIES = /* @__PURE__ */ table({
3382
3393
  usd: 2,
3383
3394
  eur: 2,
3384
3395
  gbp: 2,
@@ -3429,7 +3440,7 @@ var init_money = __esm({
3429
3440
  cop: 2,
3430
3441
  pen: 2,
3431
3442
  uyu: 2
3432
- };
3443
+ });
3433
3444
  }
3434
3445
  });
3435
3446
 
@@ -3633,9 +3644,9 @@ function commands(s2) {
3633
3644
  end();
3634
3645
  return to ? null : out;
3635
3646
  }
3636
- function pathKeys(table2, raw) {
3647
+ function pathKeys(table3, raw) {
3637
3648
  const p = raw.replace(/\/{2,}/g, "/").replace(/(.)\/$/, "$1").split("/");
3638
- return Object.keys(table2).filter((k) => {
3649
+ return Object.keys(table3).filter((k) => {
3639
3650
  const s2 = k.split(" ")[0].split("/");
3640
3651
  return k[0] === "/" && s2.length === p.length && s2.every((x, i) => x === "*" ? p[i] !== "" : x === p[i]);
3641
3652
  });
@@ -3697,7 +3708,7 @@ function inObject(row2, fields, o, text, drop) {
3697
3708
  const names3 = paths(fields);
3698
3709
  return Math.max(named(names3, text), named(names3, JSON.stringify(o))) > spots.length + aside ? UNREAD : spots;
3699
3710
  }
3700
- function fromGraphql(row2, table2, keys2, body2) {
3711
+ function fromGraphql(row2, table3, keys2, body2) {
3701
3712
  const b = body2;
3702
3713
  const vars = b?.["variables"] ?? {};
3703
3714
  const src = b?.["query"];
@@ -3798,7 +3809,7 @@ function fromGraphql(row2, table2, keys2, body2) {
3798
3809
  skip();
3799
3810
  }
3800
3811
  const key2 = keys2.find((k) => k.endsWith(` ${field}`));
3801
- calls.push(key2 ? inObject(row2, table2[key2], a, JSON.stringify(a), row2.nameless?.includes(key2)) : UNREAD);
3812
+ calls.push(key2 ? inObject(row2, table3[key2], a, JSON.stringify(a), row2.nameless?.includes(key2)) : UNREAD);
3802
3813
  }
3803
3814
  take2();
3804
3815
  if (calls.length === 0) throw new Error();
@@ -3840,7 +3851,7 @@ function pair(p, kv, decode) {
3840
3851
  put(p, k, { w: v, d: kv.d && v.includes("$"), x: false });
3841
3852
  return true;
3842
3853
  }
3843
- function fromCli(row2, table2, ws, text, none) {
3854
+ function fromCli(row2, table3, ws, text, none) {
3844
3855
  const pos = [];
3845
3856
  const p = /* @__PURE__ */ new Map();
3846
3857
  for (let j = 0; j < ws.length; j++) {
@@ -3865,13 +3876,13 @@ function fromCli(row2, table2, ws, text, none) {
3865
3876
  const [a = "", b = ""] = pos.map((x) => x.w);
3866
3877
  if (a === "get" || b === "list" || b === "retrieve") return "read";
3867
3878
  const raw = `${a} ${b}`;
3868
- const k = Object.hasOwn(table2, raw) ? raw : /^(?:post|delete)$/.test(a) && b[0] === "/" ? pathKeys(table2, b.split("?")[0]).find((x) => !x.includes(" ")) : void 0;
3879
+ const k = Object.hasOwn(table3, raw) ? raw : /^(?:post|delete)$/.test(a) && b[0] === "/" ? pathKeys(table3, b.split("?")[0]).find((x) => !x.includes(" ")) : void 0;
3869
3880
  if (!k) return none;
3870
3881
  if (k !== raw) {
3871
3882
  if (pos[1].d) return UNREAD;
3872
3883
  for (const [qk, qv] of new URLSearchParams(b.includes("?") ? b.slice(b.indexOf("?") + 1) : "")) put(p, qk, { w: qv, d: false, x: false });
3873
3884
  }
3874
- return inParams(table2[k], p, text, !!row2.nameless?.includes(k));
3885
+ return inParams(table3[k], p, text, !!row2.nameless?.includes(k));
3875
3886
  }
3876
3887
  function urlOf(w) {
3877
3888
  try {
@@ -3880,7 +3891,7 @@ function urlOf(w) {
3880
3891
  return null;
3881
3892
  }
3882
3893
  }
3883
- function fromCurl(row2, table2, ws, text, none) {
3894
+ function fromCurl(row2, table3, ws, text, none) {
3884
3895
  let url = null;
3885
3896
  let urlWord = "";
3886
3897
  let method = "";
@@ -3930,7 +3941,7 @@ function fromCurl(row2, table2, ws, text, none) {
3930
3941
  } catch {
3931
3942
  return UNREAD;
3932
3943
  }
3933
- const keys2 = pathKeys(table2, path);
3944
+ const keys2 = pathKeys(table3, path);
3934
3945
  const k = keys2.find((x) => !x.includes(" "));
3935
3946
  if (!k && keys2.length === 0) return none;
3936
3947
  const p = /* @__PURE__ */ new Map();
@@ -3949,13 +3960,13 @@ function fromCurl(row2, table2, ws, text, none) {
3949
3960
  }
3950
3961
  if ((json2 !== void 0 || row2.json) && p.size > 0) return UNREAD;
3951
3962
  if (!k) {
3952
- const g = json2 === void 0 || p.size > 0 ? UNREAD : fromGraphql(row2, table2, keys2, json2);
3963
+ const g = json2 === void 0 || p.size > 0 ? UNREAD : fromGraphql(row2, table3, keys2, json2);
3953
3964
  return typeof g === "string" ? g : { many: g };
3954
3965
  }
3955
3966
  const drop = !!row2.nameless?.includes(k);
3956
- return json2 !== void 0 ? inObject(row2, table2[k], json2, text, drop) : inParams(table2[k], p, text, drop);
3967
+ return json2 !== void 0 ? inObject(row2, table3[k], json2, text, drop) : inParams(table3[k], p, text, drop);
3957
3968
  }
3958
- function fromCommand(row2, table2, call, none) {
3969
+ function fromCommand(row2, table3, call, none) {
3959
3970
  const cmd = call.input?.["command"];
3960
3971
  const all2 = typeof cmd === "string" && !SCRIPT.test(cmd) ? commands(cmd) : null;
3961
3972
  if (!all2) return UNREAD;
@@ -3967,7 +3978,7 @@ function fromCommand(row2, table2, call, none) {
3967
3978
  while (i < ws.length && WRAP.test(ws[i].w)) i++;
3968
3979
  const prog = (ws[i]?.w ?? "").replace(/^.*\//, "");
3969
3980
  const args = ws.slice(i + 1);
3970
- const one3 = row2.clis.includes(prog) ? fromCli(row2, table2, args, text, none) : prog === "curl" ? fromCurl(row2, table2, args, text, none) : null;
3981
+ const one3 = row2.clis.includes(prog) ? fromCli(row2, table3, args, text, none) : prog === "curl" ? fromCurl(row2, table3, args, text, none) : null;
3971
3982
  if (one3 === null) {
3972
3983
  if (!/^(?:cd|pushd)$/.test(prog) && ws.some((x) => name.test(x.w))) return UNREAD;
3973
3984
  continue;
@@ -3989,6 +4000,7 @@ function total(spots, row2, c) {
3989
4000
  const m = (row2.minor ? /^(\d+)()$/ : DECIMAL).exec(numeral(v));
3990
4001
  const n4 = q === void 0 ? null : DECIMAL.exec(numeral(q));
3991
4002
  if (!m || q !== void 0 && !n4) return UNREAD;
4003
+ if ((m[1] + (m[2] ?? "")).length > 30 || n4 !== null && (n4[1] + (n4[2] ?? "")).length > 30) return UNREAD;
3992
4004
  const at2 = (row2.minor ? row2.digits?.[code] ?? c.digits : (m[2] ?? "").length) + (n4?.[2] ?? "").length;
3993
4005
  const top = Math.max(k, at2);
3994
4006
  sum = sum * 10n ** BigInt(top - k) + BigInt(m[1] + (m[2] ?? "")) * BigInt(n4 ? n4[1] + (n4[2] ?? "") : 1) * 10n ** BigInt(top - at2);
@@ -3998,16 +4010,19 @@ function total(spots, row2, c) {
3998
4010
  }
3999
4011
  function shown(n4, k, sign) {
4000
4012
  const s2 = n4.toString().padStart(k + 1, "0");
4001
- return `${sign}${s2.slice(0, s2.length - k).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${k > 0 ? `.${s2.slice(-k)}` : ""}`;
4013
+ const whole2 = s2.slice(0, s2.length - k);
4014
+ let grouped = "";
4015
+ for (let end = whole2.length; end > 0; end -= 3) grouped = `${whole2.slice(Math.max(0, end - 3), end)}${grouped ? `,${grouped}` : ""}`;
4016
+ return `${sign}${grouped}${k > 0 ? `.${s2.slice(-k)}` : ""}`;
4002
4017
  }
4003
4018
  function callsOf(c, part, call) {
4004
4019
  const row2 = rowOf(part);
4005
- const table2 = c.invoice ? row2?.invoices : row2?.at;
4020
+ const table3 = c.invoice ? row2?.invoices : row2?.at;
4006
4021
  const tool = call.tool?.startsWith("mcp__") ? call.tool.split("__").slice(2).join("__") : "";
4007
4022
  const o = call.input;
4008
- const k = !o || Object.hasOwn(table2 ?? {}, tool) ? tool : `${tool} ${String(o["service"]).toLowerCase()} ${String(o["method"])}`;
4023
+ const k = !o || Object.hasOwn(table3 ?? {}, tool) ? tool : `${tool} ${String(o["service"]).toLowerCase()} ${String(o["method"])}`;
4009
4024
  const none = c.invoice ? NO_TOTAL : UNREAD;
4010
- return !row2 || !table2 || !c.apps.includes(row2.app) ? UNREAD : part.action !== MCP ? fromCommand(row2, table2, call, none) : o && Object.hasOwn(table2, k) ? [inObject(row2, table2[k], o, JSON.stringify(o), row2.nameless?.includes(k))] : none;
4025
+ return !row2 || !table3 || !c.apps.includes(row2.app) ? UNREAD : part.action !== MCP ? fromCommand(row2, table3, call, none) : o && Object.hasOwn(table3, k) ? [inObject(row2, table3[k], o, JSON.stringify(o), row2.nameless?.includes(k))] : none;
4011
4026
  }
4012
4027
  function movedBy(m, part, call) {
4013
4028
  const calls = callsOf(m, part, call);
@@ -4037,6 +4052,13 @@ function capMoved(cap, call) {
4037
4052
  return Number.isSafeInteger(sum) ? sum : "Anvil can't count an amount that large";
4038
4053
  }
4039
4054
  function matchAmount(c, part, call) {
4055
+ try {
4056
+ return amountAnswer(c, part, call);
4057
+ } catch {
4058
+ return { hit: "unknown", why: "Anvil can't read the amount this moves" };
4059
+ }
4060
+ }
4061
+ function amountAnswer(c, part, call) {
4040
4062
  const row2 = rowOf(part);
4041
4063
  const calls = callsOf(c, part, call);
4042
4064
  const said = (w) => c.invoice && w === SAYS_NONE ? NO_TOTAL : w;
@@ -4458,12 +4480,13 @@ var init_narrow_target = __esm({
4458
4480
  "use strict";
4459
4481
  init_win_path();
4460
4482
  init_store();
4483
+ init_own();
4461
4484
  FIELDS = /* @__PURE__ */ new Set(["outside_project", "environment", "repo"]);
4462
4485
  inside = (path, root) => {
4463
4486
  const r = root.endsWith("/") ? root.slice(0, -1) : root;
4464
4487
  return path === r || path.startsWith(`${r}/`);
4465
4488
  };
4466
- SAY_WHERE = {
4489
+ SAY_WHERE = /* @__PURE__ */ table({
4467
4490
  vercel: "vercel deploy --prod, or --target staging",
4468
4491
  netlify: "netlify deploy --prod, or --context staging",
4469
4492
  fly: "fly deploy -a <an app named for staging>",
@@ -4477,7 +4500,7 @@ var init_narrow_target = __esm({
4477
4500
  firebase: "firebase deploy -P staging",
4478
4501
  serverless: "serverless deploy --stage staging",
4479
4502
  wrangler: "wrangler deploy --env staging"
4480
- };
4503
+ });
4481
4504
  }
4482
4505
  });
4483
4506
 
@@ -5243,6 +5266,7 @@ var TO_FIELDS, LIST_APPS, key, toFields, TO, FROM, LISTED, ANSWERS, ASKED, IDS,
5243
5266
  var init_recipients = __esm({
5244
5267
  "src/coding-agents/claude-code/recipients.ts"() {
5245
5268
  "use strict";
5269
+ init_own();
5246
5270
  TO_FIELDS = "to cc bcc torecipients ccrecipients bccrecipients toaddresses ccaddresses bccaddresses toaddress ccaddress bccaddress rcptto recipient recipients attendee attendees optionalattendees requiredattendees guests invitees recipientemail extrarecipients toemail toemails ccemails bccemails";
5247
5271
  LIST_APPS = "klaviyo himalaya convertkit api.kit.com activecampaign api-us1.com activehosted constantcontact constant_contact api.cc.email beehiiv helpscout help_scout freshdesk substack";
5248
5272
  key = (s2) => s2.toLowerCase().replace(/[^a-z0-9]/g, "");
@@ -5269,7 +5293,7 @@ var init_recipients = __esm({
5269
5293
  opens = (s2, j) => s2[j] === "`" || s2[j] === "$" && s2[j + 1] === "(" && s2[j + 2] !== "(";
5270
5294
  MAIL = ["srAaSqTOuC", "cb", "tfHE"];
5271
5295
  MUTT = ["sifmQd", "cb", "HeF"];
5272
- MAILERS = { mail: MAIL, mailx: MAIL, "s-nail": MAIL, sendmail: ["fFOpRVNLBXh", "", "tC"], msmtp: ["afCX", "", "t"], mutt: MUTT, neomutt: MUTT };
5296
+ MAILERS = /* @__PURE__ */ table({ mail: MAIL, mailx: MAIL, "s-nail": MAIL, sendmail: ["fFOpRVNLBXh", "", "tC"], msmtp: ["afCX", "", "t"], mutt: MUTT, neomutt: MUTT });
5273
5297
  HEADER = /^\s*(?:to|cc|bcc)\s*:/i;
5274
5298
  SETTINGS = "Anvil can't read who this goes to: it may read them from the message or its settings";
5275
5299
  CURL_VALUE = "AbcCdDeEFHKmoPQrtTuUwxXyYz";
@@ -6125,10 +6149,10 @@ function evaluateCompiledPolicy(policy, call, rates, now) {
6125
6149
  }
6126
6150
  return ALLOW;
6127
6151
  }
6128
- function evaluateCompiledWithBaseline(table2, call, rates, now, projectDir) {
6152
+ function evaluateCompiledWithBaseline(table3, call, rates, now, projectDir) {
6129
6153
  let best = ALLOW;
6130
6154
  let baseline = ALLOW;
6131
- for (const policy of table2.policies) {
6155
+ for (const policy of table3.policies) {
6132
6156
  if (!inScope(policy, projectDir)) continue;
6133
6157
  const d = evaluateCompiledPolicy(policy, call, rates, now);
6134
6158
  if (policy.origin === "baseline" && STRENGTH[d.verdict] > STRENGTH[baseline.verdict]) baseline = d;
@@ -6141,9 +6165,9 @@ function evaluateCompiledWithBaseline(table2, call, rates, now, projectDir) {
6141
6165
  function inScope(policy, projectDir) {
6142
6166
  return policy.origin !== "project" || Boolean(projectDir && policy.project_dir && sameOrInside(projectDir, policy.project_dir));
6143
6167
  }
6144
- function ownMode(table2, action, projectDir) {
6168
+ function ownMode(table3, action, projectDir) {
6145
6169
  let best = null;
6146
- for (const p of table2.policies) {
6170
+ for (const p of table3.policies) {
6147
6171
  if (p.origin === "baseline" || !inScope(p, projectDir)) continue;
6148
6172
  for (const r of p.rules) if (r.mode && applies(r, action)) best = strongerMode(best, r.mode);
6149
6173
  if (p.off?.includes(action)) best = strongerMode(best, "off");
@@ -6338,6 +6362,7 @@ var init_compiled = __esm({
6338
6362
  init_narrowed();
6339
6363
  init_narrow_app();
6340
6364
  init_win_path();
6365
+ init_own();
6341
6366
  COMPILED_FORMAT = "anvil-claude-compiled/1";
6342
6367
  ALLOW = { verdict: "allow", policy: null, origin: null, ruleId: null, blockedBy: null, source: null };
6343
6368
  STRENGTH = { allow: 0, hold: 1, block: 2 };
@@ -6380,7 +6405,7 @@ var init_compiled = __esm({
6380
6405
  durable_key_dedup: { reproduces: ["ttl_ms"], inert: {} }
6381
6406
  };
6382
6407
  isPrimitive = (p) => typeof p === "string" && Object.hasOwn(PARAMS, p);
6383
- BUDGET_WINDOWS = { usd: ["day", "week", "task"], tokens: ["day", "week", "task"], plan: ["five_hour", "seven_day"] };
6408
+ BUDGET_WINDOWS = /* @__PURE__ */ table({ usd: ["day", "week", "task"], tokens: ["day", "week", "task"], plan: ["five_hour", "seven_day"] });
6384
6409
  HELPER_MODELS = /* @__PURE__ */ new Set(["sonnet", "opus", "haiku", "fable"]);
6385
6410
  CAP_UNITS = /* @__PURE__ */ new Set(["calls", "machines", "hours", "usd", "money"]);
6386
6411
  CAP_WINDOWS = /* @__PURE__ */ new Set(["minute", "hour", "day", "week"]);
@@ -6570,8 +6595,8 @@ function floorLines(members = FLOOR) {
6570
6595
  const holds3 = members.filter((m) => m.verdict === "hold").map((m) => m.short);
6571
6596
  return [...blocks.length > 0 ? [`blocks ${blocks.join("; ")}`] : [], ...holds3.length > 0 ? [`holds ${list2(holds3)}`] : []];
6572
6597
  }
6573
- function presentFloor(table2) {
6574
- const lost = new Set(missingFloorRules(table2));
6598
+ function presentFloor(table3) {
6599
+ const lost = new Set(missingFloorRules(table3));
6575
6600
  return FLOOR.filter((m) => !Object.entries(FLOOR_NEEDS).some(([id, members]) => members.includes(m.id) && lost.has(id)));
6576
6601
  }
6577
6602
  function inHome(target, home2) {
@@ -6612,8 +6637,8 @@ function floorFor(i) {
6612
6637
  if (SECRET_ACTIONS.has(i.action) && isAccountCredential(i.target, i.home)) return floorMember("keep-keys-in");
6613
6638
  return null;
6614
6639
  }
6615
- function missingFloorRules(table2) {
6616
- const present = new Set(table2.policies.filter((p) => p.origin === "baseline").flatMap((p) => p.rules.map((r) => r.id)));
6640
+ function missingFloorRules(table3) {
6641
+ const present = new Set(table3.policies.filter((p) => p.origin === "baseline").flatMap((p) => p.rules.map((r) => r.id)));
6617
6642
  return Object.keys(FLOOR_NEEDS).filter((id) => !present.has(id));
6618
6643
  }
6619
6644
  var FLOOR, FLOOR_BLOCKS, FLOOR_HEADLINE, BY_ID2, FLOOR_RULES, FLOOR_SLUGS, FLOOR_NEEDS, ALWAYS_ACTIONS, SECRET_ACTIONS, ACCOUNT_KEYS;
@@ -6622,6 +6647,7 @@ var init_floor = __esm({
6622
6647
  "use strict";
6623
6648
  init_modes();
6624
6649
  init_dirs();
6650
+ init_own();
6625
6651
  FLOOR = [
6626
6652
  {
6627
6653
  id: "protect",
@@ -6679,20 +6705,20 @@ var init_floor = __esm({
6679
6705
  FLOOR_BLOCKS = "home and project wipes and force-pushes to main";
6680
6706
  FLOOR_HEADLINE = `always blocking ${FLOOR_BLOCKS}`;
6681
6707
  BY_ID2 = new Map(FLOOR.map((m) => [m.id, m]));
6682
- FLOOR_RULES = {
6708
+ FLOOR_RULES = /* @__PURE__ */ table({
6683
6709
  "block-protected-targets": "protect",
6684
6710
  "hold-delete-bursts": "stop-loops",
6685
6711
  "hold-repeated-side-effect": "stop-loops",
6686
6712
  "hold-helper-bursts": "stop-helper-bursts"
6687
- };
6713
+ });
6688
6714
  FLOOR_SLUGS = new Set(FLOOR.flatMap((m) => Object.keys(m.slugs)));
6689
- FLOOR_NEEDS = {
6715
+ FLOOR_NEEDS = /* @__PURE__ */ table({
6690
6716
  "block-protected-targets": ["protect"],
6691
6717
  "hold-delete-bursts": ["stop-loops"],
6692
6718
  "hold-repeated-side-effect": ["stop-loops"],
6693
6719
  "hold-helper-bursts": ["stop-helper-bursts"],
6694
6720
  "hold-risky-actions": ["keep-anvil-on", "keep-keys-in"]
6695
- };
6721
+ });
6696
6722
  ALWAYS_ACTIONS = /* @__PURE__ */ new Set([CONTROLS_ACTION, "claude.bash.secrets.expose"]);
6697
6723
  SECRET_ACTIONS = /* @__PURE__ */ new Set(["claude.file.read_secret", "claude.file.write_secret", "claude.bash.secrets.print"]);
6698
6724
  ACCOUNT_KEYS = /^(?:\.ssh\/(?!known_hosts|authorized_keys|config$|environment$|rc$)[^/]+(?<!\.pub)|\.aws\/credentials|\.kube\/config|\.docker\/config\.json|\.gnupg\/[^/].*|\.config\/gh\/hosts\.yml|\.npmrc|\.pypirc|\.netrc|\.git-credentials|\.pgpass|\.vault-token|\.config\/gcloud\/[^/].*|\.azure\/[^/].*|\.config\/solana\/id\.json)$/;
@@ -6722,9 +6748,9 @@ function actionsForSlug(slug2) {
6722
6748
  if (slug2 === "helper-burst") return ["claude.agent.helper"];
6723
6749
  return [];
6724
6750
  }
6725
- function ruleCount(table2) {
6751
+ function ruleCount(table3) {
6726
6752
  const names3 = new Set(FLOOR_SLUGS);
6727
- for (const p of table2.policies) {
6753
+ for (const p of table3.policies) {
6728
6754
  for (const r of p.rules) {
6729
6755
  if (r.primitive === "durable_key_dedup") continue;
6730
6756
  if (r.id === "hold-risky-actions") for (const a of r.applies_to ?? []) names3.add(ruleSlug(null, a));
@@ -6733,13 +6759,13 @@ function ruleCount(table2) {
6733
6759
  }
6734
6760
  return names3.size;
6735
6761
  }
6736
- function stoppableActions(table2) {
6762
+ function stoppableActions(table3) {
6737
6763
  const out = /* @__PURE__ */ new Set();
6738
- for (const p of table2.policies) for (const r of p.rules) if (r.primitive !== "durable_key_dedup") for (const a of r.applies_to ?? p.allowed_actions) out.add(a);
6764
+ for (const p of table3.policies) for (const r of p.rules) if (r.primitive !== "durable_key_dedup") for (const a of r.applies_to ?? p.allowed_actions) out.add(a);
6739
6765
  return [...out];
6740
6766
  }
6741
- function modeSummary(table2, modes) {
6742
- const actions = stoppableActions(table2).filter((a) => ACTION_LABELS[a]);
6767
+ function modeSummary(table3, modes) {
6768
+ const actions = stoppableActions(table3).filter((a) => ACTION_LABELS[a]);
6743
6769
  const enforced = actions.filter((a) => modeFor(modes, a) === "enforce");
6744
6770
  return { enforced, text: enforced.length === 0 ? "ghost" : enforced.length === actions.length ? "enforce" : `${enforced.length} enforced, rest ghost` };
6745
6771
  }
@@ -6749,7 +6775,8 @@ var init_labels = __esm({
6749
6775
  "use strict";
6750
6776
  init_floor();
6751
6777
  init_modes();
6752
- ACTION_LABELS = {
6778
+ init_own();
6779
+ ACTION_LABELS = /* @__PURE__ */ table({
6753
6780
  "claude.bash.fs.delete_recursive": { slug: "delete", text: "recursive delete" },
6754
6781
  "claude.bash.fs.delete_disposable": { slug: "delete-temp", text: "delete of temp or build files" },
6755
6782
  "claude.bash.git.force_push": { slug: "force-push", text: "force-push" },
@@ -6776,16 +6803,16 @@ var init_labels = __esm({
6776
6803
  "claude.mcp.call": { slug: "mcp-read", text: "MCP tool call" },
6777
6804
  "claude.bash.unclassified": { slug: "other", text: "command" },
6778
6805
  "claude.tool.other": { slug: "tool", text: "tool call" }
6779
- };
6806
+ });
6780
6807
  DAY_ONE_LABEL = { slug: "catastrophic", text: "cluster, cloud and database destroys, and cloud-credential prints" };
6781
- RULE_LABELS = {
6808
+ RULE_LABELS = /* @__PURE__ */ table({
6782
6809
  "block-protected-targets": { slug: "protected", text: "never: home, root, project root, .git, main, every process" },
6783
6810
  "hold-repeated-side-effect": { slug: "repeat", text: "the same MCP action again within 10 minutes" },
6784
6811
  "hold-delete-bursts": { slug: "delete-burst", text: "more than 20 deletes in a minute" },
6785
6812
  "hold-helper-bursts": { slug: "helper-burst", text: "more than 20 helper launches in 10 minutes" },
6786
6813
  "too-long-to-check": { slug: "too-long-to-check", text: "too long to check in time" },
6787
6814
  "could-not-check": { slug: "could-not-check", text: "could not be checked" }
6788
- };
6815
+ });
6789
6816
  }
6790
6817
  });
6791
6818
 
@@ -6840,9 +6867,10 @@ var init_say = __esm({
6840
6867
  init_look();
6841
6868
  init_labels();
6842
6869
  init_kit_command();
6870
+ init_own();
6843
6871
  ANVIL = "\u{1F539}";
6844
6872
  lead = (said) => `${ANVIL} ${said} ${ANVIL}`;
6845
- SHORT = {
6873
+ SHORT = /* @__PURE__ */ table({
6846
6874
  "claude.bash.git.push_main": "pushes to main",
6847
6875
  "claude.agent.controls": "its own settings",
6848
6876
  "claude.bash.git.force_push": "force-pushes",
@@ -6855,7 +6883,7 @@ var init_say = __esm({
6855
6883
  "claude.bash.spend": "paid compute",
6856
6884
  "claude.bash.external_write": "outside writes",
6857
6885
  "claude.mcp.side_effect": "app changes"
6858
- };
6886
+ });
6859
6887
  shortAction = (action) => SHORT[action] ?? actionText(action);
6860
6888
  then = (text) => `
6861
6889
  ${MARK.next} ${text}`;
@@ -7674,8 +7702,8 @@ function writeSealed(paths2, file, value, lkg) {
7674
7702
  function writeModesFile(paths2, modes) {
7675
7703
  writeSealed(paths2, paths2.modes, modes, MODES_LKG);
7676
7704
  }
7677
- function writeCompiledFile(paths2, table2) {
7678
- writeSealed(paths2, paths2.compiled, table2, COMPILED_LKG);
7705
+ function writeCompiledFile(paths2, table3) {
7706
+ writeSealed(paths2, paths2.compiled, table3, COMPILED_LKG);
7679
7707
  }
7680
7708
  function wasSealed(paths2) {
7681
7709
  return existsSync5(join7(paths2.bin, "claude-hook.sh")) || everSealed(paths2);
@@ -7830,17 +7858,18 @@ var init_integrity = __esm({
7830
7858
  init_modes();
7831
7859
  init_store();
7832
7860
  init_kit_command();
7861
+ init_own();
7833
7862
  SEAL_FIELD = "_seal";
7834
7863
  SealKeyGone = class extends Error {
7835
7864
  };
7836
7865
  MODES_LKG = "modes.json";
7837
7866
  COMPILED_LKG = "compiled.json";
7838
- WHY = {
7867
+ WHY = /* @__PURE__ */ table({
7839
7868
  missing: "is missing",
7840
7869
  unreadable: "cannot be read",
7841
7870
  unsealed: "was changed outside Anvil",
7842
7871
  changed: "was changed outside Anvil"
7843
- };
7872
+ });
7844
7873
  }
7845
7874
  });
7846
7875
 
@@ -7883,9 +7912,9 @@ async function baselineSource() {
7883
7912
  const loaded = await loadCodingAgentPolicy();
7884
7913
  return { raw: loaded.raw, origin: "baseline", label: "coding-agent-baseline" };
7885
7914
  }
7886
- function writeCompiledTable(paths2, table2) {
7915
+ function writeCompiledTable(paths2, table3) {
7887
7916
  ensureDir(paths2.dir);
7888
- writeCompiledFile(paths2, table2);
7917
+ writeCompiledFile(paths2, table3);
7889
7918
  }
7890
7919
  var PolicyRejected, isRecord2;
7891
7920
  var init_compile = __esm({
@@ -8132,11 +8161,11 @@ function narrowParts(c) {
8132
8161
  const bare2 = c.also.filter((a) => !seen.has(a)).map((action) => ({ action, service: null, target: null, host: null, attributes: {} }));
8133
8162
  return [lead2, ...later, ...bare2];
8134
8163
  }
8135
- function judgeCall(table2, c, modes, rates, now, projectDir, session, home2 = null, histories = []) {
8164
+ function judgeCall(table3, c, modes, rates, now, projectDir, session, home2 = null, histories = []) {
8136
8165
  const sessionMeta = session ? { session_id: session } : {};
8137
8166
  const actions = [c.action, ...c.also.filter((a) => a !== c.action)];
8138
- const modeOf = (action, floor, catastrophic) => floor ? "enforce" : effectiveMode(modes, action, ownMode(table2, action, projectDir), catastrophic);
8139
- const dayOne = (action, floor, catastrophic) => !floor && catastrophic && heldByDayOne(modes, action, ownMode(table2, action, projectDir));
8167
+ const modeOf = (action, floor, catastrophic) => floor ? "enforce" : effectiveMode(modes, action, ownMode(table3, action, projectDir), catastrophic);
8168
+ const dayOne = (action, floor, catastrophic) => !floor && catastrophic && heldByDayOne(modes, action, ownMode(table3, action, projectDir));
8140
8169
  const catastrophicOf = (action) => {
8141
8170
  if (action === c.action && c.catastrophic) return { why: c.why };
8142
8171
  const f = (c.findings ?? []).find((x) => x.action === action && x.catastrophic);
@@ -8145,7 +8174,7 @@ function judgeCall(table2, c, modes, rates, now, projectDir, session, home2 = nu
8145
8174
  const judged = [];
8146
8175
  actions.forEach((action, i) => {
8147
8176
  const first = i === 0;
8148
- const { decision, baseline } = evaluateCompiledWithBaseline(table2, first ? { action, service: c.service, metadata: { ...c.attributes, ...sessionMeta } } : { action, service: null, metadata: sessionMeta }, rates, now, projectDir);
8177
+ const { decision, baseline } = evaluateCompiledWithBaseline(table3, first ? { action, service: c.service, metadata: { ...c.attributes, ...sessionMeta } } : { action, service: null, metadata: sessionMeta }, rates, now, projectDir);
8149
8178
  const floor = floorFor({ action, decision, baseline, service: first ? c.service : null, target: first ? c.attributes.target ?? null : null, projectDir, home: home2, histories });
8150
8179
  const cat = catastrophicOf(action);
8151
8180
  const mode = modeOf(action, floor, cat !== null);
@@ -8159,16 +8188,16 @@ function judgeCall(table2, c, modes, rates, now, projectDir, session, home2 = nu
8159
8188
  const key2 = `${f.action}\0${f.service ?? ""}\0${f.target ?? ""}`;
8160
8189
  if (seen.has(key2)) continue;
8161
8190
  seen.add(key2);
8162
- const { decision, baseline } = evaluateCompiledWithBaseline(table2, { action: f.action, service: f.service, metadata: { target: f.target, ...sessionMeta } }, NO_RATES, now, projectDir);
8191
+ const { decision, baseline } = evaluateCompiledWithBaseline(table3, { action: f.action, service: f.service, metadata: { target: f.target, ...sessionMeta } }, NO_RATES, now, projectDir);
8163
8192
  if (decision.verdict === "allow") continue;
8164
8193
  const floor = floorFor({ action: f.action, decision, baseline, service: f.service, target: f.target, projectDir, home: home2, histories });
8165
8194
  const cat = f.catastrophic === true;
8166
8195
  const mode = modeOf(f.action, floor, cat);
8167
8196
  if (mode !== "off") judged.push({ action: f.action, decision, mode, floor: floor?.id ?? null, why: cat && dayOne(f.action, floor, true) ? `${f.why} \xB7 ${DAY_ONE_NOTE}` : f.why, target: f.target });
8168
8197
  }
8169
- if (table2.policies.some((p) => p.narrowed && p.narrowed.length > 0)) {
8198
+ if (table3.policies.some((p) => p.narrowed && p.narrowed.length > 0)) {
8170
8199
  const call = { tool: c.tool ?? null, parts: narrowParts(c), touched: c.touched ?? null, projectDir, home: home2, command: c.command ?? null, input: c.input ?? null, ...now > 0 ? { now } : {} };
8171
- for (const p of table2.policies) {
8200
+ for (const p of table3.policies) {
8172
8201
  if (!p.narrowed || !inScope(p, projectDir)) continue;
8173
8202
  for (const n4 of p.narrowed) {
8174
8203
  const hit = narrowedHit(n4, { ...call, root: p.origin === "project" ? p.project_dir ?? null : null });
@@ -8332,6 +8361,21 @@ var init_approvals = __esm({
8332
8361
  }
8333
8362
  });
8334
8363
 
8364
+ // src/coding-agents/claude-code/visible.ts
8365
+ function visible(text) {
8366
+ return text.replace(HIDDEN, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
8367
+ }
8368
+ function hasHidden(text) {
8369
+ return /[\u0000-\u0008\u000b-\u001f\u007f-\u009f؜‎‏‪-‮⁦-⁩]/.test(text);
8370
+ }
8371
+ var HIDDEN;
8372
+ var init_visible = __esm({
8373
+ "src/coding-agents/claude-code/visible.ts"() {
8374
+ "use strict";
8375
+ HIDDEN = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f؜‎‏‪-‮⁦-⁩]/g;
8376
+ }
8377
+ });
8378
+
8335
8379
  // src/coding-agents/claude-code/hook/run.ts
8336
8380
  import { spawnSync as spawnSync2 } from "child_process";
8337
8381
  import { createHash as createHash5 } from "crypto";
@@ -8365,7 +8409,8 @@ var RATES;
8365
8409
  var init_prices = __esm({
8366
8410
  "src/coding-agents/claude-code/prices.ts"() {
8367
8411
  "use strict";
8368
- RATES = {
8412
+ init_own();
8413
+ RATES = /* @__PURE__ */ table({
8369
8414
  "claude-fable-5-2": { input: 8, output: 40, read: 0.2 },
8370
8415
  "claude-mythos-5-2": { input: 8, output: 40, read: 0.2 },
8371
8416
  "claude-fable-5-1": { input: 10, output: 50, read: 0.25 },
@@ -8389,7 +8434,7 @@ var init_prices = __esm({
8389
8434
  "claude-sonnet-4": { input: 3, output: 15 },
8390
8435
  "claude-haiku-5-5": { input: 0.1, output: 0.5, tier: { above: 1e5, over: { input: 0.5, output: 2.5 } } },
8391
8436
  "claude-haiku-4-5": { input: 1, output: 5 }
8392
- };
8437
+ });
8393
8438
  }
8394
8439
  });
8395
8440
 
@@ -9786,8 +9831,8 @@ import { createHash as createHash7 } from "crypto";
9786
9831
  import { accessSync, closeSync as closeSync6, constants as constants4, openSync as openSync6, readdirSync as readdirSync11, readFileSync as readFileSync6, rmSync as rmSync2 } from "fs";
9787
9832
  import { homedir as homedir3 } from "os";
9788
9833
  import { basename as basename6, dirname as dirname9, join as join13 } from "path";
9789
- function budgetsOf(table2) {
9790
- return (table2?.policies ?? []).flatMap((p) => p.budgets ?? []);
9834
+ function budgetsOf(table3) {
9835
+ return (table3?.policies ?? []).flatMap((p) => p.budgets ?? []);
9791
9836
  }
9792
9837
  function readTask(paths2, session) {
9793
9838
  if (!sessionOk(session)) return null;
@@ -9901,8 +9946,8 @@ function runningOks(paths2, now) {
9901
9946
  }
9902
9947
  return out;
9903
9948
  }
9904
- function budgetStanding(paths2, table2, now, scope) {
9905
- const budgets = budgetsOf(table2);
9949
+ function budgetStanding(paths2, table3, now, scope) {
9950
+ const budgets = budgetsOf(table3);
9906
9951
  if (budgets.length === 0) return [];
9907
9952
  const sc = scope ?? screenScope(claudeConfigDir(process.env, homedir3()));
9908
9953
  let reading2;
@@ -10010,7 +10055,7 @@ function noPlanReading(h, stale, age) {
10010
10055
  if (failed) return { says: `can't be measured right now: Claude Code's /usage didn't answer \xB7 asked again within 15 min${stale ? ago3 : ""}`, fix: null, lasting: false };
10011
10056
  return { says: `measured at your next message, from Claude Code's /usage${stale ? ago3 : ""}`, fix: null, lasting: false };
10012
10057
  }
10013
- function limitStates(table2, dir, h, standing, now, capUse = () => null) {
10058
+ function limitStates(table3, dir, h, standing, now, capUse = () => null) {
10014
10059
  const out = [];
10015
10060
  const off2 = offHere(h);
10016
10061
  const ear = unheard(h);
@@ -10018,7 +10063,7 @@ function limitStates(table2, dir, h, standing, now, capUse = () => null) {
10018
10063
  const state = (b, health, says, fix, lasting = health !== "enforced" && health !== "ok") => ({ ...b, health, says, fix, lasting });
10019
10064
  const blocked = (b) => off2 ? state(b, "off", off2.says, off2.fix, off2.lasting) : null;
10020
10065
  const meterOff = (b) => h.meterGone ? state(b, "off", "can't be checked: Anvil's meter file is missing", `run ${claudeHead(h.cli)} on`) : null;
10021
- for (const pol of (table2?.policies ?? []).filter((p) => inScope(p, dir))) {
10066
+ for (const pol of (table3?.policies ?? []).filter((p) => inScope(p, dir))) {
10022
10067
  const project = pol.origin === "project";
10023
10068
  for (const c of pol.caps ?? []) {
10024
10069
  const b = { ...base("cap", c.id, c.text, c.source, project), standing: capUse(c) };
@@ -10096,11 +10141,11 @@ function limitStates(table2, dir, h, standing, now, capUse = () => null) {
10096
10141
  }
10097
10142
  return out;
10098
10143
  }
10099
- function limitsElsewhere(table2, dir) {
10100
- return (table2?.policies ?? []).filter((p) => !inScope(p, dir)).reduce((n4, p) => n4 + countIn(p), 0);
10144
+ function limitsElsewhere(table3, dir) {
10145
+ return (table3?.policies ?? []).filter((p) => !inScope(p, dir)).reduce((n4, p) => n4 + countIn(p), 0);
10101
10146
  }
10102
- function limitCount(table2) {
10103
- return (table2?.policies ?? []).reduce((n4, p) => n4 + countIn(p), 0);
10147
+ function limitCount(table3) {
10148
+ return (table3?.policies ?? []).reduce((n4, p) => n4 + countIn(p), 0);
10104
10149
  }
10105
10150
  function limitMark(s2, marks) {
10106
10151
  if (s2.lasting) return marks.problem;
@@ -10716,7 +10761,7 @@ function buildProof(input) {
10716
10761
  }
10717
10762
  }
10718
10763
  const rows = [...groups.values()].map((g) => {
10719
- const calls = g.d.map((d) => ({ ts: Date.parse(d.ts), outcome: g.enforced ? d.verdict === "block" ? "blocked" : "held" : "watched", project: d.project ? d.project.split("/").filter(Boolean).pop() ?? null : null, why: d.why ?? "" })).sort((a, b) => b.ts - a.ts);
10764
+ const calls = g.d.map((d) => ({ ts: Date.parse(d.ts), outcome: g.enforced ? d.verdict === "block" ? "blocked" : "held" : "watched", project: d.project ? visible(d.project.split("/").filter(Boolean).pop() ?? "") || null : null, why: visible(d.why ?? "") })).sort((a, b) => b.ts - a.ts);
10720
10765
  return {
10721
10766
  action: g.action,
10722
10767
  slug: ACTION_LABELS[g.action]?.slug ?? BUDGET_ROWS[g.action]?.slug ?? g.action,
@@ -10791,12 +10836,14 @@ var init_proof = __esm({
10791
10836
  init_say();
10792
10837
  init_classify();
10793
10838
  init_labels();
10794
- BUDGET_ROWS = {
10839
+ init_own();
10840
+ init_visible();
10841
+ BUDGET_ROWS = /* @__PURE__ */ table({
10795
10842
  "claude.budget": { slug: "budget", text: "action at your budget" },
10796
10843
  "claude.prompt": { slug: "budget", text: "message at your budget" },
10797
10844
  "claude.model.switch": { slug: "model", text: "model switch refused" },
10798
10845
  "claude.model.message": { slug: "model", text: "message on a model you said never" }
10799
- };
10846
+ });
10800
10847
  DAY = 864e5;
10801
10848
  MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
10802
10849
  WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
@@ -10995,7 +11042,7 @@ function machineHealth(input) {
10995
11042
  }
10996
11043
  function anvilVersion() {
10997
11044
  try {
10998
- return /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]{1,20})?$/.test("0.8.0") ? "0.8.0" : null;
11045
+ return /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]{1,20})?$/.test("0.8.1") ? "0.8.1" : null;
10999
11046
  } catch {
11000
11047
  return null;
11001
11048
  }
@@ -11277,7 +11324,27 @@ function removePending(paths2, decided) {
11277
11324
  `);
11278
11325
  });
11279
11326
  }
11327
+ function cannotSend(identity) {
11328
+ if (!/^[\x21-\x7e]+$/.test(identity.apiKey)) return "the key has characters no key has";
11329
+ let u;
11330
+ try {
11331
+ u = new URL(identity.baseUrl);
11332
+ } catch {
11333
+ return "the workspace address isn't a URL";
11334
+ }
11335
+ if (u.username || u.password) return "the workspace address carries a password";
11336
+ const local = ["localhost", "127.0.0.1", "[::1]"].includes(u.hostname) || u.hostname.endsWith(".localhost") || u.hostname.endsWith(".test");
11337
+ if (u.protocol !== "https:" && !(u.protocol === "http:" && local)) return "the workspace address isn't https";
11338
+ return null;
11339
+ }
11340
+ function failedAs(err) {
11341
+ if (err instanceof Error && err.name === "TimeoutError") return "timed out";
11342
+ const code = err?.cause?.code;
11343
+ return typeof code === "string" && /^[A-Z][A-Z0-9_]{1,40}$/.test(code) ? code : "no answer";
11344
+ }
11280
11345
  async function request2(deps, identity, method, path, body2) {
11346
+ const refused = cannotSend(identity);
11347
+ if (refused) return { status: 0, body: null, retryAfterMs: null, error: refused };
11281
11348
  try {
11282
11349
  const res = await deps.fetch(`${identity.baseUrl}${path}`, {
11283
11350
  method,
@@ -11300,7 +11367,7 @@ async function request2(deps, identity, method, path, body2) {
11300
11367
  const ra = Number(res.headers.get("retry-after"));
11301
11368
  return { status: res.status, body: parsed2, retryAfterMs: Number.isFinite(ra) && ra > 0 ? ra * 1e3 : null, error: null };
11302
11369
  } catch (err) {
11303
- return { status: 0, body: null, retryAfterMs: null, error: err instanceof Error ? err.name === "TimeoutError" ? "timed out" : err.message : String(err) };
11370
+ return { status: 0, body: null, retryAfterMs: null, error: failedAs(err) };
11304
11371
  }
11305
11372
  }
11306
11373
  function describe(a, identity, cli = "anvil") {
@@ -11312,8 +11379,8 @@ function describe(a, identity, cli = "anvil") {
11312
11379
  const code = a.body && typeof a.body === "object" ? a.body["code"] : null;
11313
11380
  return `HTTP ${a.status}${typeof code === "string" && /^[a-z][a-z0-9_]{0,39}$/.test(code) ? ` (${code})` : ""}`;
11314
11381
  }
11315
- function syncedActions(table2) {
11316
- return table2 ? stoppableActions(table2).filter((a) => a.startsWith("claude.")).sort().slice(0, MODES_BATCH_MAX) : [];
11382
+ function syncedActions(table3) {
11383
+ return table3 ? stoppableActions(table3).filter((a) => a.startsWith("claude.")).sort().slice(0, MODES_BATCH_MAX) : [];
11317
11384
  }
11318
11385
  async function setWorkspaceMode(deps, identity, action, mode, register = false) {
11319
11386
  return request2(deps, identity, "POST", "/v1/modes", register ? { action, mode: "ghost", if_not_stronger: true } : { action, mode, reason: `anvil claude ${mode} (Claude Code on ${deps.machine})` });
@@ -11689,6 +11756,7 @@ var init_sync = __esm({
11689
11756
  init_integrity();
11690
11757
  init_store();
11691
11758
  init_machine_health();
11759
+ init_own();
11692
11760
  PUSH_PER_MINUTE = 50;
11693
11761
  MODES_BATCH_MAX = 50;
11694
11762
  REQUEST_TIMEOUT_MS = 1e4;
@@ -11696,7 +11764,7 @@ var init_sync = __esm({
11696
11764
  MAX_WAIT_MS = 30 * 6e4;
11697
11765
  MACHINE_REPORT_PATH = "/v1/claude-code/machine";
11698
11766
  MACHINE_REPORT_RETRY_UNKNOWN_MS = 6 * 60 * 6e4;
11699
- WIRE_CODES = {
11767
+ WIRE_CODES = /* @__PURE__ */ table({
11700
11768
  confirmation_required: "confirmation_required",
11701
11769
  service_in_blocklist: "service_in_blocklist",
11702
11770
  resource_mutation_rate_exceeded: "resource_mutation_rate_exceeded",
@@ -11704,7 +11772,7 @@ var init_sync = __esm({
11704
11772
  spend_per_user: "spend_per_user",
11705
11773
  // A call the hook could not judge (out of time, or the classifier failed on it): held in enforce, recorded in ghost.
11706
11774
  time_limit: "anvil_unavailable"
11707
- };
11775
+ });
11708
11776
  s = (v) => typeof v === "string" && v.length > 0 ? v : null;
11709
11777
  changeKey = (c) => `${c.identity}|${c.action}|${c.at}`;
11710
11778
  notLinked = { linked: false, sent: 0, rejected: 0, waiting: 0, modesPulled: false, modesChanged: false, error: null };
@@ -11766,25 +11834,25 @@ function doesRows(o, p = paint(false), inner = boxInner()) {
11766
11834
  function doesBox(o, p = paint(false), w = WIDTH, extra = [], title = "What it does now") {
11767
11835
  return box(title, [...doesRows(o, p, boxInner(w)), ...extra], p, w);
11768
11836
  }
11769
- function blockingKinds(table2, projectDir) {
11837
+ function blockingKinds(table3, projectDir) {
11770
11838
  const out = /* @__PURE__ */ new Set();
11771
- for (const p of table2?.policies ?? []) {
11839
+ for (const p of table3?.policies ?? []) {
11772
11840
  if (p.origin === "baseline" || !inScope(p, projectDir)) continue;
11773
11841
  for (const r of p.rules) if (r.intent === "block") for (const a of r.applies_to ?? []) out.add(a);
11774
11842
  }
11775
11843
  return out;
11776
11844
  }
11777
- function heldKinds(table2, modes, projectDir) {
11778
- return SWITCHABLE_KINDS.filter((k) => effectiveMode(modes, k, table2 ? ownMode(table2, k, projectDir) : null) === "enforce");
11845
+ function heldKinds(table3, modes, projectDir) {
11846
+ return SWITCHABLE_KINDS.filter((k) => effectiveMode(modes, k, table3 ? ownMode(table3, k, projectDir) : null) === "enforce");
11779
11847
  }
11780
- function offKinds(table2, modes, projectDir) {
11781
- return SWITCHABLE_KINDS.filter((k) => effectiveMode(modes, k, table2 ? ownMode(table2, k, projectDir) : null) === "off");
11848
+ function offKinds(table3, modes, projectDir) {
11849
+ return SWITCHABLE_KINDS.filter((k) => effectiveMode(modes, k, table3 ? ownMode(table3, k, projectDir) : null) === "off");
11782
11850
  }
11783
11851
  function choosable(kinds) {
11784
11852
  return kinds.filter((k) => !ALWAYS_ACTIONS.has(k));
11785
11853
  }
11786
- function dayOneApplies(modes, table2) {
11787
- return table2 && !DAY_ONE_KINDS.some((a) => heldByDayOne(modes, a, ownMode(table2, a, null))) ? null : dayOneWords(modes);
11854
+ function dayOneApplies(modes, table3) {
11855
+ return table3 && !DAY_ONE_KINDS.some((a) => heldByDayOne(modes, a, ownMode(table3, a, null))) ? null : dayOneWords(modes);
11788
11856
  }
11789
11857
  function stoppedText(stopped, approved, declined) {
11790
11858
  const floor = stopped.filter((d) => d.floor).length;
@@ -11799,8 +11867,8 @@ function capResets(cap, now) {
11799
11867
  if (cap.window === "minute" || cap.window === "hour") return "rolling";
11800
11868
  return cap.window === "day" ? "resets at midnight" : `resets ${new Date(windowEnd(cap, now.getTime())).toLocaleDateString("en-US", { weekday: "long" })}`;
11801
11869
  }
11802
- function capRows(table2, paths2, now, p = paint(false), projectDir = null) {
11803
- const caps = (table2?.policies ?? []).filter((x) => inScope(x, projectDir)).flatMap((x) => x.caps ?? []);
11870
+ function capRows(table3, paths2, now, p = paint(false), projectDir = null) {
11871
+ const caps = (table3?.policies ?? []).filter((x) => inScope(x, projectDir)).flatMap((x) => x.caps ?? []);
11804
11872
  if (caps.length === 0) return [];
11805
11873
  const ledger = new CapLedger(join19(paths2.dir, "caps"));
11806
11874
  return caps.map((cap, i) => {
@@ -12263,13 +12331,13 @@ function printStatus(paths2) {
12263
12331
  setCliName(named3(recorded) ? recorded : "anvil");
12264
12332
  const t = loadEffectiveTable(paths2, PLUGIN_BASELINE ?? join22(HERE, "baseline.json"));
12265
12333
  const m = loadEffectiveModes(paths2);
12266
- const table2 = t.value;
12267
- const cli = [table2?.cli, recorded].find(named3) ?? "anvil";
12334
+ const table3 = t.value;
12335
+ const cli = [table3?.cli, recorded].find(named3) ?? "anvil";
12268
12336
  setCliName(cli);
12269
12337
  const cannotStart = Object.values(install?.installs ?? {}).filter((rec) => rec && typeof rec.command === "string" && !hookCanStart(rec)).map((rec) => `Anvil's hook in ${rec.settings_path} can't start (its files are gone), so new sessions are not checked: run ${fixCommand("on")}`);
12270
12338
  const key2 = readSealKey(paths2);
12271
12339
  const problems = [...new Set([...cannotStart, t.problem, m.problem, ...checkInstalls(paths2, key2, homedir6()), ...fileProblems(paths2, homedir6(), key2), ...readHealth(paths2)?.problems ?? []].filter((p) => !!p))];
12272
- const lines = statusLines({ paths: paths2, table: table2, modes: m.value, identity: readSyncIdentity(process.env, homedir6()), machine: readMachineLabel(paths2, hostname2()), now: /* @__PURE__ */ new Date(), cli, problems, installed: Object.keys(install?.installs ?? {}).length > 0 });
12340
+ const lines = statusLines({ paths: paths2, table: table3, modes: m.value, identity: readSyncIdentity(process.env, homedir6()), machine: readMachineLabel(paths2, hostname2()), now: /* @__PURE__ */ new Date(), cli, problems, installed: Object.keys(install?.installs ?? {}).length > 0 });
12273
12341
  process.stdout.write(`${lines.join("\n")}
12274
12342
  `);
12275
12343
  }
@@ -12726,9 +12794,9 @@ function psArgs(pid) {
12726
12794
  function claudeCodeParent(deps = {}) {
12727
12795
  const platform = deps.platform ?? process.platform;
12728
12796
  const linux = platform === "linux" && !deps.processes;
12729
- const table2 = linux ? null : (deps.processes ?? (() => readProcesses(platform)))();
12730
- if (!linux && table2 === null) return { found: null, unknown: true, detached: false };
12731
- const byPid = new Map((table2 ?? []).map((r) => [r.pid, r]));
12797
+ const table3 = linux ? null : (deps.processes ?? (() => readProcesses(platform)))();
12798
+ if (!linux && table3 === null) return { found: null, unknown: true, detached: false };
12799
+ const byPid = new Map((table3 ?? []).map((r) => [r.pid, r]));
12732
12800
  const rowOf2 = (pid2) => linux ? procParent(pid2) : byPid.get(pid2) ?? null;
12733
12801
  const argsOf = deps.argsOf ?? (linux ? procArgs : platform === "win32" ? (pid2) => windowsLines.get(pid2) ?? null : psArgs);
12734
12802
  let pid = deps.ppid ?? process.ppid;
@@ -12753,18 +12821,20 @@ function claudeCodeParent(deps = {}) {
12753
12821
  top = row2;
12754
12822
  pid = row2.ppid;
12755
12823
  }
12756
- return { found: null, unknown: false, detached: reachedInit && (top === null || LOOSE.has(plainName(top.program))) };
12824
+ const detached = reachedInit && (top === null || LOOSE.has(plainName(top.program)));
12825
+ return { found: null, unknown: false, detached, ...detached && top !== null && MAKES_A_TERMINAL.has(plainName(top.program)) ? { madeTerminal: true } : {} };
12757
12826
  }
12758
12827
  function insideClaudeCode(env, deps = {}) {
12759
12828
  if (sessionMarker(env) !== null) return { inside: true, how: "marker", parent: null, parentsUnknown: false };
12760
12829
  if (deps.markerOnly) return { inside: false, how: null, parent: null, parentsUnknown: true };
12761
- const { found, unknown, detached } = claudeCodeParent(deps);
12830
+ const parents = claudeCodeParent(deps);
12831
+ const { found, unknown, detached } = parents;
12762
12832
  if (found) return { inside: true, how: "parent", parent: found, parentsUnknown: false };
12763
- if (detached && deps.stdinTTY !== true) return { inside: true, how: "detached", parent: null, parentsUnknown: false };
12833
+ if (detached && (deps.stdinTTY !== true || parents.madeTerminal === true)) return { inside: true, how: "detached", parent: null, parentsUnknown: false };
12764
12834
  if (unknown && (deps.platform ?? process.platform) === "win32" && deps.stdinTTY !== true) return { inside: true, how: "detached", parent: null, parentsUnknown: true };
12765
12835
  return { inside: false, how: null, parent: null, parentsUnknown: unknown };
12766
12836
  }
12767
- var SESSION_MARKERS, SCRIPT_RUNNERS, lastName, windowsLines, FIRST, LOOSE, WINDOWS_HOSTS, plainName;
12837
+ var SESSION_MARKERS, SCRIPT_RUNNERS, lastName, windowsLines, FIRST, LOOSE, MAKES_A_TERMINAL, WINDOWS_HOSTS, plainName;
12768
12838
  var init_inside_claude = __esm({
12769
12839
  "src/coding-agents/claude-code/inside-claude.ts"() {
12770
12840
  "use strict";
@@ -12773,7 +12843,60 @@ var init_inside_claude = __esm({
12773
12843
  lastName = (p) => p.trim().split(/[\\/]/).pop() ?? "";
12774
12844
  windowsLines = /* @__PURE__ */ new Map();
12775
12845
  FIRST = /^(launchd|init|systemd|tini|dumb-init|catatonit|s6-svscan|runsvdir)$/;
12776
- LOOSE = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash", "fish", "ksh", "mksh", "tcsh", "csh", "nohup", "env", "setsid", "timeout", "xargs", "script", "make", "node", "nodejs", "bun", "deno", "python", "python3", "perl", "ruby", "php", "osascript"]);
12846
+ LOOSE = /* @__PURE__ */ new Set([
12847
+ "sh",
12848
+ "bash",
12849
+ "zsh",
12850
+ "dash",
12851
+ "fish",
12852
+ "ksh",
12853
+ "mksh",
12854
+ "tcsh",
12855
+ "csh",
12856
+ "nohup",
12857
+ "env",
12858
+ "setsid",
12859
+ "timeout",
12860
+ "gtimeout",
12861
+ "xargs",
12862
+ "script",
12863
+ "make",
12864
+ "gmake",
12865
+ "node",
12866
+ "nodejs",
12867
+ "bun",
12868
+ "deno",
12869
+ "python",
12870
+ "python3",
12871
+ "perl",
12872
+ "ruby",
12873
+ "php",
12874
+ "osascript",
12875
+ "time",
12876
+ "gtime",
12877
+ "nice",
12878
+ "caffeinate",
12879
+ "stdbuf",
12880
+ "gstdbuf",
12881
+ "chronic",
12882
+ "flock",
12883
+ "ionice",
12884
+ "taskset",
12885
+ "unbuffer",
12886
+ "expect",
12887
+ "sandbox-exec",
12888
+ "arch",
12889
+ "awk",
12890
+ "gawk",
12891
+ "mawk",
12892
+ "nawk",
12893
+ "watch",
12894
+ "entr",
12895
+ "parallel",
12896
+ "tclsh",
12897
+ "lua"
12898
+ ]);
12899
+ MAKES_A_TERMINAL = /* @__PURE__ */ new Set(["script", "expect", "unbuffer", "empty", "pty", "socat"]);
12777
12900
  WINDOWS_HOSTS = /* @__PURE__ */ new Set(["svchost", "services", "wininit", "wmiprvse", "taskhostw", "taskhost", "taskeng", "smss", "csrss", "winlogon", "lsass", "system", "wsmprovhost"]);
12778
12901
  plainName = (program2) => lastName(program2).replace(/\.exe$/i, "").replace(/^-/, "").replace(/[\d.]+$/, "");
12779
12902
  }
@@ -13646,6 +13769,7 @@ var init_cond_amount2 = __esm({
13646
13769
  init_money();
13647
13770
  init_apps();
13648
13771
  init_rules_md();
13772
+ init_own();
13649
13773
  lazy = (make) => {
13650
13774
  let r;
13651
13775
  return () => r ??= make();
@@ -13672,19 +13796,19 @@ var init_cond_amount2 = __esm({
13672
13796
  MONEY_ON = "refunds, charges, payments, payouts and transfers";
13673
13797
  listed = (xs) => xs.length > 1 ? `${xs.slice(0, -1).join(", ")} and ${xs[xs.length - 1]}` : xs[0] ?? "";
13674
13798
  changesOf = (r) => listed((r.changes ?? MOVES).filter((x) => x !== "pay").map((x) => `${x}s`));
13675
- SIGNS = { us$: "usd", ca$: "cad", c$: "cad", au$: "aud", a$: "aud", nz$: "nzd", hk$: "hkd", sg$: "sgd", s$: "sgd", nt$: "twd", mx$: "mxn", r$: "brl", $: "$", "\u20AC": "eur", "\xA3": "gbp", "\xA5": "\xA5", "\u20B9": "inr", "\u20A9": "krw", "\u20BA": "try", "\u20AA": "ils", "\u20A6": "ngn", "\u20B1": "php", "\u0E3F": "thb", "\u20AB": "vnd", rs: "inr", "rs.": "inr", kr: "kr", "kr.": "kr", fr: "chf", "fr.": "chf", sfr: "chf" };
13676
- WORDS = { dollar: "$", dollars: "$", buck: "$", bucks: "$", euro: "eur", euros: "eur", pound: "gbp", pounds: "gbp", quid: "gbp", sterling: "gbp", yen: "jpy", yuan: "cny", rmb: "cny", renminbi: "cny", rupee: "inr", rupees: "inr", won: "krw", real: "brl", reais: "brl", rand: "zar", lira: "try", zloty: "pln", z\u0142: "pln", peso: "peso", pesos: "peso", franc: "franc", francs: "franc", krona: "kr", kronor: "kr", krone: "kr", kroner: "kr", kr: "kr", cent: "\xA2", cents: "\xA2", "\xA2": "\xA2", p: "p", pence: "p" };
13677
- NATIONS = { us: "usd", "u.s.": "usd", american: "usd", canadian: "cad", australian: "aud", "new zealand": "nzd", "hong kong": "hkd", singapore: "sgd", taiwan: "twd", taiwanese: "twd", mexican: "mxn", japanese: "jpy", british: "gbp", swiss: "chf", indian: "inr", chinese: "cny", swedish: "sek", norwegian: "nok", danish: "dkk", brazilian: "brl" };
13678
- SHOWN = { usd: "$", eur: "\u20AC", gbp: "\xA3", jpy: "\xA5" };
13799
+ SIGNS = /* @__PURE__ */ table({ us$: "usd", ca$: "cad", c$: "cad", au$: "aud", a$: "aud", nz$: "nzd", hk$: "hkd", sg$: "sgd", s$: "sgd", nt$: "twd", mx$: "mxn", r$: "brl", $: "$", "\u20AC": "eur", "\xA3": "gbp", "\xA5": "\xA5", "\u20B9": "inr", "\u20A9": "krw", "\u20BA": "try", "\u20AA": "ils", "\u20A6": "ngn", "\u20B1": "php", "\u0E3F": "thb", "\u20AB": "vnd", rs: "inr", "rs.": "inr", kr: "kr", "kr.": "kr", fr: "chf", "fr.": "chf", sfr: "chf" });
13800
+ WORDS = /* @__PURE__ */ table({ dollar: "$", dollars: "$", buck: "$", bucks: "$", euro: "eur", euros: "eur", pound: "gbp", pounds: "gbp", quid: "gbp", sterling: "gbp", yen: "jpy", yuan: "cny", rmb: "cny", renminbi: "cny", rupee: "inr", rupees: "inr", won: "krw", real: "brl", reais: "brl", rand: "zar", lira: "try", zloty: "pln", z\u0142: "pln", peso: "peso", pesos: "peso", franc: "franc", francs: "franc", krona: "kr", kronor: "kr", krone: "kr", kroner: "kr", kr: "kr", cent: "\xA2", cents: "\xA2", "\xA2": "\xA2", p: "p", pence: "p" });
13801
+ NATIONS = /* @__PURE__ */ table({ us: "usd", "u.s.": "usd", american: "usd", canadian: "cad", australian: "aud", "new zealand": "nzd", "hong kong": "hkd", singapore: "sgd", taiwan: "twd", taiwanese: "twd", mexican: "mxn", japanese: "jpy", british: "gbp", swiss: "chf", indian: "inr", chinese: "cny", swedish: "sek", norwegian: "nok", danish: "dkk", brazilian: "brl" });
13802
+ SHOWN = /* @__PURE__ */ table({ usd: "$", eur: "\u20AC", gbp: "\xA3", jpy: "\xA5" });
13679
13803
  DOLLARS = /* @__PURE__ */ new Set(["usd", "cad", "aud", "nzd", "hkd", "sgd", "twd", "mxn"]);
13680
- FAMILIES = { peso: /* @__PURE__ */ new Set(["mxn", "php", "clp", "cop", "ars", "uyu"]), franc: /* @__PURE__ */ new Set(["chf"]), kr: /* @__PURE__ */ new Set(["sek", "nok", "dkk", "isk"]) };
13804
+ FAMILIES = /* @__PURE__ */ table({ peso: /* @__PURE__ */ new Set(["mxn", "php", "clp", "cop", "ars", "uyu"]), franc: /* @__PURE__ */ new Set(["chf"]), kr: /* @__PURE__ */ new Set(["sek", "nok", "dkk", "isk"]) });
13681
13805
  CRYPTO = /^(?:btc|eth|sol|usdc|usdt|dai|bnb|xrp|ada|doge|ltc|matic|avax|bitcoins?|ether|ethereum|satoshis?|sats?|gwei|wei|lamports?)$/i;
13682
13806
  isCurrency = (x) => SIGNS[x] !== void 0 || WORDS[x] !== void 0 || CURRENCIES[x] !== void 0 || CRYPTO.test(x);
13683
13807
  NUMBER = /(?<![\d.,'])\d[\d,.'  ]*\d|(?<![\d.,'])\d|(?<=[$€£¥₹]\s?)\.\d+/g;
13684
13808
  BEFORE = /(?:\b(?:US|CA|C|AU|A|NZ|HK|SG|S|NT|MX|R))?[$€£¥₹₩₺₪₦₱฿₫]\s?$|\b(rs\.?|kr\.?|s?fr\.?)\s?$|\b([A-Za-z]{3})\s?$/i;
13685
13809
  MULT_WORD = /^\s?(hundred|thousand|grand|million|billion|mm|mn|bn|m|k|b)/i;
13686
13810
  MULT_FOLDED = lazy(() => /^\s?(k|hundred|thousand|grand|mm|mn|m|million|bn|b|billion)(?![\p{L}\p{N}])/iu);
13687
- MULTS = { k: 3, hundred: 2, thousand: 3, grand: 3, mm: 6, mn: 6, m: 6, million: 6, bn: 9, b: 9, billion: 9 };
13811
+ MULTS = /* @__PURE__ */ table({ k: 3, hundred: 2, thousand: 3, grand: 3, mm: 6, mn: 6, m: 6, million: 6, bn: 9, b: 9, billion: 9 });
13688
13812
  MULT_AGAIN = /^\s+(?:hundred|thousand|grand|million|billion)\b/i;
13689
13813
  SMALL = "zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen".split(" ");
13690
13814
  TENS = "twenty thirty forty fifty sixty seventy eighty ninety".split(" ");
@@ -13867,7 +13991,7 @@ function walk2(app, v, at2, out) {
13867
13991
  };
13868
13992
  go(v, 0);
13869
13993
  }
13870
- function table(app, text, at2, out) {
13994
+ function table2(app, text, at2, out) {
13871
13995
  const lines = text.split(/\r?\n/).filter((l) => l.trim() && !/^\s*\|?\s*:?-{3,}/.test(l));
13872
13996
  const cells = (l) => {
13873
13997
  const sep2 = l.includes(" ") ? " " : l.includes("|") ? "|" : ",";
@@ -13923,7 +14047,7 @@ function replyFacts(io, app, item2, structured, at2) {
13923
14047
  } catch {
13924
14048
  }
13925
14049
  }
13926
- table(app, s2, at2, out);
14050
+ table2(app, s2, at2, out);
13927
14051
  }
13928
14052
  return out;
13929
14053
  }
@@ -14294,6 +14418,7 @@ var init_cond_part2 = __esm({
14294
14418
  init_app_part_ids();
14295
14419
  init_cond_part();
14296
14420
  init_rules_md();
14421
+ init_own();
14297
14422
  PART_NOUN_HERE = /team|project|board|channel|workspace|database|space|folder|repo|org|list|base|calendar|label|server|group|squad|sprint|milestone|doc|sheet|account/;
14298
14423
  PART = lazy2(() => new RegExp("\\b(?:in|on|for|of|within|inside|from|under|to)\\s+(?:the\\s+|our\\s+|my\\s+|a\\s+|their\\s+|your\\s+)?((?!(?:my|our|your|their|his|her|its|the|a|an|this|that|these|those|any|every|each|all|some|one|which|whichever|other|another)\\b)(?:\\p{Lu}[\\p{L}\\p{N}_.&'-]*|[\\p{Ll}\\p{N}]+(?:[-_][\\p{L}\\p{N}]+)+|[\\p{Ll}\\p{N}][\\p{L}\\p{N}.]*(?=\\s+repo(?:sitory)?s?\\b))(?:\\s+(?:\\p{Lu}[\\p{L}\\p{N}_.&'-]*|[\\p{Ll}\\p{N}]+(?:[-_][\\p{L}\\p{N}]+)+))*)\\s+(team|project|board|channel|workspace|database|space|folder|repo|repository|org|organization|list|base|calendar|label|server|group|squad|sprint|milestone|doc|document|sheet|account)s?\\b", "u"));
14299
14424
  APP_NAMES = /* @__PURE__ */ new WeakMap();
@@ -14347,7 +14472,7 @@ var init_cond_part2 = __esm({
14347
14472
  for (const f of [...found].sort((a, b) => b.at - a.at)) t = `${t.slice(0, f.at)} ${f.keep ?? ""} ${t.slice(f.at + f.text.length)}`;
14348
14473
  return t.replace(/(?:\s*(?:,|\band\b|\bor\b|&|\bplus\b))+(?=\s*(?:[,.;:!?]|$))/gi, "").replace(/\s+([,.;:!?])/g, "$1").replace(/\s{2,}/g, " ").trim();
14349
14474
  };
14350
- READ = { slack: "slack", github: "github", linear: "linear", jira: "jira" };
14475
+ READ = /* @__PURE__ */ table({ slack: "slack", github: "github", linear: "linear", jira: "jira" });
14351
14476
  NOUNS = { slack: /* @__PURE__ */ new Set(["#", "channel"]), github: /* @__PURE__ */ new Set(["repo"]), linear: /* @__PURE__ */ new Set(["team"]), jira: /* @__PURE__ */ new Set(["project", "space"]) };
14352
14477
  partReader = {
14353
14478
  type: "part",
@@ -14835,6 +14960,7 @@ var init_apps = __esm({
14835
14960
  init_cond_amount2();
14836
14961
  init_cond_part2();
14837
14962
  init_rules_md();
14963
+ init_own();
14838
14964
  SIDE = "claude.mcp.side_effect";
14839
14965
  WRITE = "claude.bash.external_write";
14840
14966
  DELETE = "claude.bash.fs.delete_recursive";
@@ -15107,14 +15233,14 @@ var init_apps = __esm({
15107
15233
  COMMAND3 = /:\/\/|(?:^|\s)--?[a-z]/i;
15108
15234
  listed2 = (xs) => xs.length <= 1 ? xs[0] ?? "" : `${xs.slice(0, -1).join(", ")} and ${xs[xs.length - 1]}`;
15109
15235
  EMAIL_APPS = new Set(FAMILIES2.find((f) => f[0] === "email")[2].split(" "));
15110
- CATEGORY = {
15236
+ CATEGORY = /* @__PURE__ */ table({
15111
15237
  email: { apps: "email apps", tag: "every email app" },
15112
15238
  sms: { apps: "texting apps", tag: "every texting app" },
15113
15239
  payments: { apps: "payments apps", tag: "every payments app" },
15114
15240
  messaging: { apps: "apps that send messages (chat, email and texts)", tag: "every messaging app" },
15115
15241
  social: { apps: "social media apps", tag: "every social app" },
15116
15242
  calendar: { apps: "calendar apps", tag: "every calendar app" }
15117
- };
15243
+ });
15118
15244
  }
15119
15245
  });
15120
15246
 
@@ -15379,6 +15505,7 @@ var init_cond_recipient2 = __esm({
15379
15505
  init_recipient_apps();
15380
15506
  init_recipients();
15381
15507
  init_rules_md();
15508
+ init_own();
15382
15509
  LEAD2 = String.raw`(?:(?:my|our|the|a|an|any|all|each|every|one|some|none|most|real|actual|paying|existing|new|potential|current|external)\s+(?:of\s+)?)*`;
15383
15510
  GROUP2 = String.raw`(?:customers?|clients?|prospects?|leads?|vendors?|suppliers?|partners?|investors?|candidates?|applicants?|recruiters?|press|journalists?|reporters?|board(?:\s+(?:members?|of\s+directors))?|directors|lawyers?|attorneys?|counsel|auditors?|accountants?|advisors?|advisers?|consultants?|contractors?|freelancers?|competitors?|regulators?|executives|execs|managers|interns|subscribers?|members?|patients?|students?|donors?|users?|contacts?|team(?:mates)?(?!\s+(?:channel|space|workspace|board|project|repo|folder|database|calendar|drive|chat|site|page)s?\b)|colleagues|co-?workers|staff|employees|family|friends|strangers)(?![\w/@-]|\.\w)`;
15384
15511
  GROUP_GATE = /customer|client|prospect|lead|vendor|supplier|partner|investor|candidate|applicant|recruiter|press|journalist|reporter|board|director|lawyer|attorney|counsel|auditor|accountant|advis|consultant|contractor|freelancer|competitor|regulator|exec|manager|intern|subscriber|member|patient|student|donor|user|contact|team|colleague|co-?worker|staff|employee|famil|friend|stranger/i;
@@ -15423,14 +15550,14 @@ var init_cond_recipient2 = __esm({
15423
15550
  TO_GROUP = once(() => new RegExp(String.raw`\b(?:to|for|with|reach(?:es|ed|ing)?|contact(?:s|ed|ing)?)\s+(${LEAD2}${MOD}(${GROUP2}))`, "iu"));
15424
15551
  VERB_GROUP = once(() => new RegExp(String.raw`(\b(?:e-?mail(?:s|ing|ed)?|text(?:s|ing|ed)?|messag(?:e|es|ing|ed)|dm(?:s|ing)?|b?cc(?:s|ing)?|invit(?:e|es|ing))\s+)(${LEAD2}${MOD}(${GROUP2}))`, "iu"));
15425
15552
  PRONOUN = /(\b(?:e-?mail(?:s|ing|ed)?|text(?:s|ing|ed)?|messag(?:e|es|ing|ed)|dm(?:s|ing)?|b?cc(?:s|ing)?|invit(?:e|es|ing)|contact(?:s|ing|ed)?|reach(?:es|ing|ed)?)\s+|\bto\s+)(them|others|me|myself|us|ourselves)(?![\p{L}\p{N}@'’-])/iu;
15426
- PRONOUN_WHY = {
15553
+ PRONOUN_WHY = /* @__PURE__ */ table({
15427
15554
  them: `Anvil can't tell who "them" is, so name who it holds (their addresses or domains)`,
15428
15555
  others: `Anvil can't tell who "others" are, so name who it holds (their addresses or domains)`,
15429
15556
  me: "Anvil doesn't know your own address, so write it (to you@your-company.com)",
15430
15557
  myself: "Anvil doesn't know your own address, so write it (to you@your-company.com)",
15431
15558
  us: `Anvil can't tell who "us" is, so name the addresses or domains (to @your-company.com)`,
15432
15559
  ourselves: `Anvil can't tell who "us" is, so name the addresses or domains (to @your-company.com)`
15433
- };
15560
+ });
15434
15561
  FROM_GROUP = once(() => new RegExp(String.raw`\b(?:from|sent\s+by)\s+(${LEAD2}${MOD}(${GROUP2}))`, "iu"));
15435
15562
  PEOPLE_AT = once(() => new RegExp(String.raw`^${PEOPLE}\s+(?:(?:at|on|from)\s+)?`, "iu"));
15436
15563
  GROUP_WORD = once(() => new RegExp(String.raw`\b${GROUP2}`, "iu"));
@@ -16050,6 +16177,7 @@ var init_cond_when2 = __esm({
16050
16177
  "use strict";
16051
16178
  init_cond_when();
16052
16179
  init_rules_md();
16180
+ init_own();
16053
16181
  TIME = /\b(?:(?:on|during|after|before|at|over|every|each|between|outside)\s+(?:the\s+|a\s+)?(?:mondays?|tuesdays?|wednesdays?|thursdays?|fridays?|saturdays?|sundays?|weekends?|weekdays?|nights?|nighttime|business hours|work(?:ing)? hours|office hours|holidays?|evenings?|mornings?|afternoons?|midnight|noon|(?:\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2})(?:\s*(?:and|to|until|till|-|–)\s*(?:\d{1,2}(?::\d{2})?\s*(?:am|pm)?|noon|midnight))?|launch day|release day)|at night|overnight|after hours|out of hours|off hours|today|tonight|tomorrow|this week|next week)\b/i;
16054
16182
  TIME_NAME = /^(?:mondays?|tuesdays?|wednesdays?|thursdays?|fridays?|saturdays?|sundays?|weekends?|weekdays?|nights?|evenings?|mornings?|afternoons?|holidays?|today|tonight|tomorrow|weekdays)$/i;
16055
16183
  DAY_MINUTES = 1440;
@@ -16065,8 +16193,8 @@ var init_cond_when2 = __esm({
16065
16193
  morning: { from: 6 * 60, to: 12 * 60, named: "morning" },
16066
16194
  afternoon: { from: 12 * 60, to: 18 * 60, named: "afternoon" }
16067
16195
  };
16068
- DAY_NAMES = { sunday: 0, monday: 1, tuesday: 2, wednesday: 3, thursday: 4, friday: 5, saturday: 6 };
16069
- DAY_SHORT = { sun: 0, mon: 1, tue: 2, tues: 2, wed: 3, weds: 3, thu: 4, thur: 4, thurs: 4, fri: 5, sat: 6 };
16196
+ DAY_NAMES = /* @__PURE__ */ table({ sunday: 0, monday: 1, tuesday: 2, wednesday: 3, thursday: 4, friday: 5, saturday: 6 });
16197
+ DAY_SHORT = /* @__PURE__ */ table({ sun: 0, mon: 1, tue: 2, tues: 2, wed: 3, weds: 3, thu: 4, thur: 4, thurs: 4, fri: 5, sat: 6 });
16070
16198
  PLAIN_SHORT = /* @__PURE__ */ new Set(["mon", "tue", "tues", "thu", "thur", "thurs", "fri"]);
16071
16199
  DAY_LONG = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
16072
16200
  COMPOUND = /^(?:late|night|nights|after|hours|out|of|off|time|day|days|week|end|weekend|weekday|weekdays|weekends|work|workday|workdays|\d{1,2}(?:[:.]\d{2})?(?:am|pm|a|p)?|sun|mon|tue|tues|wed|weds|thu|thur|thurs|fri|sat|sundays?|mondays?|tuesdays?|wednesdays?|thursdays?|fridays?|saturdays?|noon|midnight|midday)$/;
@@ -17087,8 +17215,9 @@ var init_narrowing = __esm({
17087
17215
  init_path_rules();
17088
17216
  init_rules_md();
17089
17217
  init_target_rules();
17218
+ init_own();
17090
17219
  NARROW_REFUSALS = /* @__PURE__ */ new Set(["not-connected", "every-file", "read-only", "target"]);
17091
- KIND_SAID = {
17220
+ KIND_SAID = /* @__PURE__ */ table({
17092
17221
  "claude.bash.fs.delete_recursive": "recursive deletes",
17093
17222
  "claude.bash.fs.delete_disposable": "deletes of temp or build files",
17094
17223
  "claude.bash.git.force_push": "force-pushes",
@@ -17112,7 +17241,7 @@ var init_narrowing = __esm({
17112
17241
  "claude.file.write_secret": "secrets file writes",
17113
17242
  "claude.file.read_secret": "secrets file reads",
17114
17243
  "claude.mcp.side_effect": "app changes"
17115
- };
17244
+ });
17116
17245
  PATH_TOKEN = /(?:^|\s)["'`]?[\w.~-]*[\w~]\/|(?:^|\s)["'`]?\.?\/[\w.-]|(?:^|\s)["'`]?[\w-]+\.(?:json|ya?ml|toml|lock|md|sql|ts|tsx|js|mjs|cjs|py|rb|go|rs|sh|env|tf|prisma|txt)\b|\b(?:folders?|director(?:y|ies)|dirs?)\b/i;
17117
17246
  }
17118
17247
  });
@@ -17278,6 +17407,10 @@ function compileRulesMd(text, opts) {
17278
17407
  results.push({ line: e.line, verb: e.verb, words: e.words.slice(0, 60), kinds: [], became: null, error: `longer than ${MAX_LINE2} characters: one rule per line`, notes: [] });
17279
17408
  continue;
17280
17409
  }
17410
+ if (hasHidden(e.words)) {
17411
+ results.push({ line: e.line, verb: e.verb, words: visible(e.words).slice(0, 120), kinds: [], became: null, error: "it has characters a screen doesn't show (an escape, a backspace, a direction mark): write it again in plain text", notes: [] });
17412
+ continue;
17413
+ }
17281
17414
  if (e.verb === "budget") {
17282
17415
  const r = opts.project ? { error: "a budget is yours, not one project's: put it in ~/.anvil/rules.md" } : parseBudget(e.words, `${at2} \xB7 ${e.words}`, budgetIds);
17283
17416
  if ("error" in r) results.push({ line: e.line, verb: "budget", words: e.words, kinds: [], became: null, error: r.error, notes: [] });
@@ -17901,11 +18034,13 @@ var init_rules_md = __esm({
17901
18034
  init_path_rules();
17902
18035
  init_apps();
17903
18036
  init_cond_amount2();
18037
+ init_own();
18038
+ init_visible();
17904
18039
  SECRET_FILE_KINDS = /* @__PURE__ */ new Set(["claude.file.read_secret", "claude.file.write_secret"]);
17905
18040
  LINE = /^\s{0,3}(?:[-*+]\s+|\d{1,3}[.)]\s+)?(block|hold|watch|off|cap|budget)\s*:(.*)$/i;
17906
18041
  MAX_LINE2 = 400;
17907
18042
  NOT_A_RULE = /* @__PURE__ */ new Set(["claude.bash.unclassified", "claude.tool.other", "claude.mcp.call"]);
17908
- MORE_NAMES = {
18043
+ MORE_NAMES = /* @__PURE__ */ table({
17909
18044
  "claude.bash.fs.delete_recursive": ["delete", "deletes", "deleting", "recursive deletes", "rm -rf"],
17910
18045
  "claude.bash.git.force_push": ["force push", "force pushes", "force pushing", "force-pushes", "force-pushing"],
17911
18046
  "claude.bash.git.push_main": ["push to main", "pushes to main", "pushing to main", "merge to main", "merges to main", "merging to main"],
@@ -17922,7 +18057,7 @@ var init_rules_md = __esm({
17922
18057
  "claude.mcp.side_effect": ["mcp changes", "app changes"],
17923
18058
  "claude.agent.controls": ["anvil", "changes to anvil", "claude code settings", "claude settings", "its own settings", "its own hooks"],
17924
18059
  "claude.agent.helper": ["helper agents", "helper agent", "subagents", "subagent", "sub-agents", "sub-agent", "agent launches"]
17925
- };
18060
+ });
17926
18061
  FILLER4 = new Set("a an the any anything all every each that this these those to of or and on in into with my our your its it is are be by for from never ask before always please do not dont don t touches touching touch changes change making make doing do run running when me i we us need needs needing ok okay approval permission confirm confirmation first without use uses using git".split(" "));
17927
18062
  VERB_SAYS = { block: "blocks", hold: "holds", watch: "watches", off: "turns off" };
17928
18063
  norm2 = (s2) => ` ${s2.toLowerCase().replace(/[^a-z0-9.\-]+/g, " ").trim()} `;
@@ -17978,7 +18113,7 @@ var init_rules_md = __esm({
17978
18113
  slugOf = (action) => ACTION_LABELS[action]?.slug ?? action;
17979
18114
  blocksByWords = (words3) => matchClaudeMdLine(words3, "").kind === "block";
17980
18115
  textOf = (action) => ACTION_LABELS[action]?.text ?? action;
17981
- STILL_ALWAYS = {
18116
+ STILL_ALWAYS = /* @__PURE__ */ table({
17982
18117
  "claude.bash.fs.delete_recursive": "wiping your home folder or the project stays blocked (always on)",
17983
18118
  "claude.bash.git.force_push": "force-pushing main stays blocked (always on)",
17984
18119
  "claude.bash.git.push_main": "force-pushing or deleting main stays blocked (always on)",
@@ -17986,7 +18121,7 @@ var init_rules_md = __esm({
17986
18121
  "claude.file.read_secret": "your account keys stay held (always on)",
17987
18122
  "claude.file.write_secret": "your account keys stay held (always on)",
17988
18123
  "claude.bash.secrets.print": "printing your account keys stays held (always on)"
17989
- };
18124
+ });
17990
18125
  STRENGTH3 = { off: 0, watch: 1, hold: 2, block: 3 };
17991
18126
  PAST = { block: "blocked", hold: "held", watch: "watched", off: "off" };
17992
18127
  NEAR = /^\s*((?:(?:[-*+•>|]|\d{1,3}[.)])\s*)*)(?:\[[ xX]\]\s*)?[*_`]*\s*(?:block|hold|watch|off|cap|budget)s?\b\s*[*_`]*\s*(:)?/i;
@@ -17995,14 +18130,14 @@ var init_rules_md = __esm({
17995
18130
  NEAR_DEFINE = /^\s*(?:(?:[-*+•>|]|\d{1,3}[.)])\s*)+(?:\[[ xX]\]\s*)?[*_`]*\s*defines?\b\s*[*_`]*\s*(?::|\s+[^:=\s][^:=]*=)|^\s*(?:\[[ xX]\]\s*)?[*_`]+\s*defines?\b\s*[*_`]+\s*:/i;
17996
18131
  DEFINE_NAME = /^[a-z][a-z0-9 '_-]{0,39}$/;
17997
18132
  MAX_DEFINE = 300;
17998
- NUMBER_WORDS = { one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7, eight: 8, nine: 9, ten: 10, twelve: 12, twenty: 20 };
18133
+ NUMBER_WORDS = /* @__PURE__ */ table({ one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7, eight: 8, nine: 9, ten: 10, twelve: 12, twenty: 20 });
17999
18134
  WINDOW = /\b(?:(?:a|an|per|each|every)\s+(minute|hour|day|week)|(hourly|daily|weekly)|at\s+(?:once|a\s+time))\b/i;
18000
18135
  MACHINES = /\b(machines?|instances?|vms?|nodes?|servers?|boxes)\b/i;
18001
18136
  HOURS = /\bhours?\b/i;
18002
18137
  GPU = /\bgpus?\b/i;
18003
18138
  tidy2 = (words3) => words3.replace(/\s+/g, " ").trim().replace(/\.$/, "");
18004
18139
  AMOUNT_PHRASE = /(?:[$€£¥]\s?\d[\d.,]*(?:\s?(?:k|m|thousand|million)\b)?|\b\d[\d.,]*(?:\s?(?:k|m|thousand|million))?\s?(?:dollars?|usd|eur|euros?|gbp|pounds?|yen|cents?)\b)(?:\s+(?:of|in|on|worth of)\b)?/i;
18005
- TOKEN_SCALE = { k: 1e3, thousand: 1e3, m: 1e6, million: 1e6, b: 1e9, billion: 1e9 };
18140
+ TOKEN_SCALE = /* @__PURE__ */ table({ k: 1e3, thousand: 1e3, m: 1e6, million: 1e6, b: 1e9, billion: 1e9 });
18006
18141
  BUDGET_EXAMPLES = "budget: $50 a day, budget: 5M new tokens a day or budget: 80% of my weekly limit";
18007
18142
  COMPUTE = /\b(?:paid compute|compute|gpus?|machines?|instances?|vms?|servers?|clusters?)\b/i;
18008
18143
  RULES_MD_HEAD = [
@@ -18526,6 +18661,7 @@ var init_claude_md_model = __esm({
18526
18661
  var claude_rules_md_exports = {};
18527
18662
  __export(claude_rules_md_exports, {
18528
18663
  MAX_RULES_MD_BYTES: () => MAX_RULES_MD_BYTES,
18664
+ appliesUnseen: () => appliesUnseen,
18529
18665
  applyRulesMd: () => applyRulesMd,
18530
18666
  conditionsAt: () => conditionsAt,
18531
18667
  fileName: () => fileName,
@@ -18588,6 +18724,9 @@ function fileName(file, home2) {
18588
18724
  const dir = file.projectDir.startsWith(`${home2}/`) ? `~${file.projectDir.slice(home2.length)}` : file.projectDir;
18589
18725
  return `${file.label} in ${dir}`;
18590
18726
  }
18727
+ function appliesUnseen(paths2, file) {
18728
+ return file.origin !== "project" && readApplied(paths2, file.path).state === "ok";
18729
+ }
18591
18730
  function unappliedChanges(paths2, file) {
18592
18731
  const record = readApplied(paths2, file.path);
18593
18732
  if (record.state === "changed") return true;
@@ -18781,7 +18920,8 @@ function showCompiled(file, r, out, quiet = false, name = file.label) {
18781
18920
  function lineText(l) {
18782
18921
  const at2 = ` line ${String(l.line).padEnd(4)}`;
18783
18922
  const pad = " ".repeat(at2.length);
18784
- const words3 = l.words.length > 90 ? `${l.words.slice(0, 89)}\u2026` : l.words;
18923
+ const shownWords = visible(l.words);
18924
+ const words3 = shownWords.length > 90 ? `${shownWords.slice(0, 89)}\u2026` : shownWords;
18785
18925
  const lines = [`${at2}${l.asWritten ? words3 : `${l.verb}: ${words3}`}`];
18786
18926
  if (l.error) lines.push(`${pad}\u2715 ${l.error}`);
18787
18927
  else lines.push(`${pad}\u2192 ${l.became ?? (l.notes.length > 0 ? "not used" : "nothing")}`);
@@ -18851,6 +18991,7 @@ var init_claude_rules_md = __esm({
18851
18991
  init_claude_typed_command();
18852
18992
  init_claude_connected();
18853
18993
  init_kit_command();
18994
+ init_visible();
18854
18995
  MAX_RULES_MD_BYTES = 256 * 1024;
18855
18996
  }
18856
18997
  });
@@ -19199,9 +19340,9 @@ function addedSays(verb, became, s2) {
19199
19340
  }
19200
19341
  function modelConflicts(paths2, cwd, only) {
19201
19342
  try {
19202
- const table2 = loadEffectiveTable(paths2, installedBaseline(paths2)).value;
19343
+ const table3 = loadEffectiveTable(paths2, installedBaseline(paths2)).value;
19203
19344
  const here = normalDir(cwd);
19204
- const inForce = (table2?.policies ?? []).filter((p) => inScope(p, here));
19345
+ const inForce = (table3?.policies ?? []).filter((p) => inScope(p, here));
19205
19346
  const at2 = (source) => source.split(" \xB7 ")[0] ?? source;
19206
19347
  const guards = inForce.flatMap((p) => (p.model_rules?.guards ?? []).map((g) => ({ ...g, project: p.origin === "project" })));
19207
19348
  const never = inForce.flatMap((p) => p.model_rules?.never ?? []);
@@ -19255,7 +19396,7 @@ async function save(policy, target, io, paths2, now, cli) {
19255
19396
  throw e;
19256
19397
  }
19257
19398
  }
19258
- function rulesListing(table2, modes, cli, p = paint(false), w = WIDTH, limits = null, dir) {
19399
+ function rulesListing(table3, modes, cli, p = paint(false), w = WIDTH, limits = null, dir) {
19259
19400
  const inner = boxInner(w);
19260
19401
  const SLUG = 19;
19261
19402
  const STATE = 7;
@@ -19267,16 +19408,16 @@ function rulesListing(table2, modes, cli, p = paint(false), w = WIDTH, limits =
19267
19408
  });
19268
19409
  const head2 = p.dim(` ${"Rule".padEnd(SLUG)}${"Does".padEnd(STATE)}What it stops`);
19269
19410
  const applied = (kinds, projectDir) => {
19270
- const each = new Set(kinds.map((a) => effectiveMode(modes, a, ownMode(table2, a, projectDir))));
19411
+ const each = new Set(kinds.map((a) => effectiveMode(modes, a, ownMode(table3, a, projectDir))));
19271
19412
  return each.size === 1 ? [...each][0] : "mixed";
19272
19413
  };
19273
19414
  const state = (verdict, mode) => mode === "enforce" ? verdict : mode === "ghost" ? "watch" : mode;
19274
19415
  const always = FLOOR.flatMap((m) => Object.keys(m.slugs).map((slug2) => ({ slug: slug2, state: m.verdict, what: floorSlugText(slug2) })));
19275
19416
  const yours = [];
19276
- const dayOne = dayOneApplies(modes, table2) !== null;
19417
+ const dayOne = dayOneApplies(modes, table3) !== null;
19277
19418
  if (dayOne) yours.push({ slug: DAY_ONE_LABEL.slug, state: "hold", what: `${DAY_ONE_LABEL.text} (day one)` });
19278
19419
  let elsewhere2 = 0;
19279
- for (const pol of table2.policies) {
19420
+ for (const pol of table3.policies) {
19280
19421
  if (dir !== void 0 && !inScope(pol, dir)) {
19281
19422
  elsewhere2 += pol.rules.filter((r) => r.primitive !== "durable_key_dedup").length;
19282
19423
  continue;
@@ -19417,7 +19558,7 @@ function rulesHere(io) {
19417
19558
  return { defines: { ...at2.defines, ...own }, place: at2.place };
19418
19559
  }
19419
19560
  function loadScreen(io, paths2, now) {
19420
- const table2 = loadEffectiveTable(paths2, void 0).value;
19561
+ const table3 = loadEffectiveTable(paths2, void 0).value;
19421
19562
  const effective = loadEffectiveModes(paths2);
19422
19563
  const modes = effective.value;
19423
19564
  const project = projectWithRulesMd(io.cwd, io.home);
@@ -19447,9 +19588,9 @@ function loadScreen(io, paths2, now) {
19447
19588
  }
19448
19589
  }
19449
19590
  const rows = SWITCHABLE.map((kind) => {
19450
- const own = table2 ? ownMode(table2, kind, project ?? io.cwd) : null;
19591
+ const own = table3 ? ownMode(table3, kind, project ?? io.cwd) : null;
19451
19592
  const mode = effectiveMode(modes, kind, own);
19452
- const blocks = table2?.policies.some((p) => p.origin !== "baseline" && inScope(p, project ?? io.cwd) && p.rules.some((r) => r.intent === "block" && (r.applies_to ?? []).includes(kind)));
19593
+ const blocks = table3?.policies.some((p) => p.origin !== "baseline" && inScope(p, project ?? io.cwd) && p.rules.some((r) => r.intent === "block" && (r.applies_to ?? []).includes(kind)));
19453
19594
  const state = mode === "off" ? "off" : mode === "ghost" ? "watch" : blocks ? "block" : "hold";
19454
19595
  const set = explicitMode(modes, kind);
19455
19596
  const decided = sources.get(kind);
@@ -19474,8 +19615,8 @@ function loadScreen(io, paths2, now) {
19474
19615
  let budgets = [];
19475
19616
  let elsewhere2 = 0;
19476
19617
  try {
19477
- const l = limitsHere(io, paths2, now, table2);
19478
- limits = withCatches(l.states, catchesOf(table2, connected, { defines, place: conditionsAt(io, file).place })).sort((a, b) => GROUP3[a.kind] - GROUP3[b.kind]);
19618
+ const l = limitsHere(io, paths2, now, table3);
19619
+ limits = withCatches(l.states, catchesOf(table3, connected, { defines, place: conditionsAt(io, file).place })).sort((a, b) => GROUP3[a.kind] - GROUP3[b.kind]);
19479
19620
  budgets = l.standing;
19480
19621
  elsewhere2 = l.elsewhere;
19481
19622
  } catch {
@@ -19495,14 +19636,16 @@ function loadScreen(io, paths2, now) {
19495
19636
  });
19496
19637
  const written = sources.size > 0 || limits.length > 0;
19497
19638
  const claudeMd = !written && [join32(project ?? io.cwd, "CLAUDE.md"), join32(io.home, ".claude", "CLAUDE.md")].some((f) => existsSync18(f));
19498
- return { pending: edited.length > 0 ? edited.map((f) => f.label).join(" and ") : null, claudeMd, rows, limits, elsewhere: elsewhere2, budgets, helpers: helperRows(table2, modes, project ?? io.cwd, sources.get(HELPER) ?? null), floor: floorLines(table2 ? presentFloor(table2) : FLOOR), spend, checked: checkedSince(paths2, week), held: decisions.filter((d) => d.delivered === "deny" || d.delivered === "ask").length, file, compiled: table2 !== null, allOn: modes?.default_mode === "enforce", modesBroken: effective.source === "strict" ? effective.problem : null, connected, defines, place: conditionsAt(io, file).place, definitions, narrowable };
19639
+ const quick = edited.filter((f) => appliesUnseen(paths2, f));
19640
+ const unseen = edited.filter((f) => !quick.includes(f));
19641
+ return { pending: quick.length > 0 ? quick.map((f) => f.label).join(" and ") : null, review: unseen.length > 0 ? unseen.map((f) => f.label).join(" and ") : null, claudeMd, rows, limits, elsewhere: elsewhere2, budgets, helpers: helperRows(table3, modes, project ?? io.cwd, sources.get(HELPER) ?? null), floor: floorLines(table3 ? presentFloor(table3) : FLOOR), spend, checked: checkedSince(paths2, week), held: decisions.filter((d) => d.delivered === "deny" || d.delivered === "ask").length, file, compiled: table3 !== null, allOn: modes?.default_mode === "enforce", modesBroken: effective.source === "strict" ? effective.problem : null, connected, defines, place: conditionsAt(io, file).place, definitions, narrowable };
19499
19642
  }
19500
19643
  function withCatches(states, catches) {
19501
19644
  return states.map((s2) => s2.kind === "narrowed" && catches[s2.where] ? { ...s2, says: `${s2.says} \xB7 ${catches[s2.where]}` } : s2);
19502
19645
  }
19503
- function catchesOf(table2, connected, here = { defines: {} }) {
19646
+ function catchesOf(table3, connected, here = { defines: {} }) {
19504
19647
  const out = {};
19505
- for (const pol of table2?.policies ?? []) {
19648
+ for (const pol of table3?.policies ?? []) {
19506
19649
  for (const n4 of pol.narrowed ?? []) {
19507
19650
  const caught = narrowCatch({ kinds: n4.kinds, narrowing: n4.narrowing, ...n4.when ? { when: n4.when.map((condition) => ({ condition })) } : {}, ...n4.caught ? { caught: n4.caught } : {} }, connected, n4.mode === "ghost" ? "watch" : n4.intent, here);
19508
19651
  if (caught) out[n4.source.split(" \xB7 ")[0] ?? n4.source] = caught.tag;
@@ -19510,9 +19653,9 @@ function catchesOf(table2, connected, here = { defines: {} }) {
19510
19653
  }
19511
19654
  return out;
19512
19655
  }
19513
- function helperRows(table2, modes, dir, line) {
19514
- if (!table2) return [];
19515
- const own = ownMode(table2, HELPER, dir);
19656
+ function helperRows(table3, modes, dir, line) {
19657
+ if (!table3) return [];
19658
+ const own = ownMode(table3, HELPER, dir);
19516
19659
  if (own === null || !line) return [];
19517
19660
  const mode = effectiveMode(modes, HELPER, own);
19518
19661
  return [{ mark: mode === "off" ? "\xB7" : mode === "ghost" ? MARK.watching : MARK.held, text: `${mode === "off" ? "off" : mode === "ghost" ? "watch" : "hold"}: every launch`, where: `${line.file.label}:${line.line}` }];
@@ -19742,6 +19885,7 @@ function underBox(m, view2, p, w) {
19742
19885
  return i === 0 && tail ? `${lead2}${" ".repeat(Math.max(3, w - 1 - cols(lead2) - tail.length))}${p.dim(tail)}` : lead2;
19743
19886
  });
19744
19887
  if (!(view2.text ?? "").trim() || !r) {
19888
+ if (m.review) return say(p.amber(MARK.problem), `${m.review} isn't applied yet`, `${fixCommand("sync")} shows it first`);
19745
19889
  if (m.pending) return say(p.amber(MARK.problem), `${m.pending} changed outside this screen`, "enter applies it");
19746
19890
  const lines = [examples()];
19747
19891
  if (m.claudeMd) lines.push(` ${p.dim("Your CLAUDE.md has rules too: type import")}`);
@@ -20871,9 +21015,9 @@ function transcriptOf(file) {
20871
21015
  function loadProof(io, paths2, now, window) {
20872
21016
  const kept = readKept(paths2);
20873
21017
  const from = windowFrom2(window, now, kept.keptFrom);
20874
- const table2 = loadEffectiveTable(paths2, void 0).value;
21018
+ const table3 = loadEffectiveTable(paths2, void 0).value;
20875
21019
  const ledger = new CapLedger(join34(paths2.dir, "caps"));
20876
- const caps = (table2?.policies ?? []).filter((p) => inScope(p, io.cwd)).flatMap((p) => p.caps ?? []).map((c) => {
21020
+ const caps = (table3?.policies ?? []).filter((p) => inScope(p, io.cwd)).flatMap((p) => p.caps ?? []).map((c) => {
20877
21021
  let used = null;
20878
21022
  try {
20879
21023
  used = ledger.used(c, now.getTime());
@@ -20990,17 +21134,17 @@ function worstLine(p, st, w) {
20990
21134
  }
20991
21135
  function listLines(p, st, w, rows, selected, scroll) {
20992
21136
  const textW = Math.max(16, Math.min(38, w - GUTTER.length - 2 - 6 - 3 - 13));
20993
- const visible = p.rows.slice(scroll, scroll + rows);
20994
- const range = p.rows.length > visible.length ? ` \xB7 ${scroll + 1}\u2013${scroll + visible.length} of ${p.rows.length}` : "";
21137
+ const visible2 = p.rows.slice(scroll, scroll + rows);
21138
+ const range = p.rows.length > visible2.length ? ` \xB7 ${scroll + 1}\u2013${scroll + visible2.length} of ${p.rows.length}` : "";
20995
21139
  const out = [fit3([S(GUTTER), S(`Risky actions, worst first${range}`.padEnd(textW + 2), st.dim), S("count".padStart(6), st.dim), S(" "), S("caught by", st.dim)], w)];
20996
- visible.forEach((r, i) => {
21140
+ visible2.forEach((r, i) => {
20997
21141
  const sel = selected === scroll + i;
20998
21142
  const by = r.enforced ? r.by : "watched";
20999
21143
  const segs = [S(sel ? " \u203A " : GUTTER, st.blue), S(rowMark(r), st.mark), S(" "), S(r.text.length > textW ? `${r.text.slice(0, textW - 1)}\u2026`.padEnd(textW) : r.text.padEnd(textW), r.enforced ? void 0 : st.grey), S(`${r.count}${p.capped ? "+" : ""}`.padStart(6), r.enforced ? st.bold : st.grey), S(" "), S(by, st.dim)];
21000
21144
  const line = fill(segs, w);
21001
21145
  out.push(sel && st.on ? st.field(line) : line.replace(/ +$/, ""));
21002
21146
  });
21003
- if (p.rows.length > scroll + visible.length && selected === null) out.push(fit3([S(GUTTER), S(`\u2026 ${p.rows.length - scroll - visible.length} more: ${claudeHead(cliName())}, then tab`, st.dim)], w));
21147
+ if (p.rows.length > scroll + visible2.length && selected === null) out.push(fit3([S(GUTTER), S(`\u2026 ${p.rows.length - scroll - visible2.length} more: ${claudeHead(cliName())}, then tab`, st.dim)], w));
21004
21148
  return out;
21005
21149
  }
21006
21150
  function capLines(p, st, w) {
@@ -21086,9 +21230,9 @@ function listBox(p, st, outer, rows, selected, scroll) {
21086
21230
  const w = Math.floor((outer - 3) / 3) * 3 + 2;
21087
21231
  const inner = w - 4;
21088
21232
  const textW = Math.min(34, inner - 1 - 1 - 5 - 2 - 10 - 2 - 13);
21089
- const visible = p.rows.slice(scroll, scroll + rows);
21233
+ const visible2 = p.rows.slice(scroll, scroll + rows);
21090
21234
  const most = Math.max(1, ...p.rows.map((r) => r.count));
21091
- const laid = visible.map((r, i) => {
21235
+ const laid = visible2.map((r, i) => {
21092
21236
  const sel = selected === scroll + i;
21093
21237
  const filled = Math.max(1, Math.round(r.count / most * 10));
21094
21238
  const segs = [
@@ -21105,7 +21249,7 @@ function listBox(p, st, outer, rows, selected, scroll) {
21105
21249
  const line = fill(segs, inner);
21106
21250
  return sel ? st.field(line) : line;
21107
21251
  });
21108
- const note = p.rows.length > visible.length ? `${scroll + 1}\u2013${scroll + visible.length} of ${p.rows.length}` : "count \xB7 caught by";
21252
+ const note = p.rows.length > visible2.length ? `${scroll + 1}\u2013${scroll + visible2.length} of ${p.rows.length}` : "count \xB7 caught by";
21109
21253
  return boxed([S("Risky actions, worst first", st.bold)], laid, w, st.grey, st, note).map((l) => ` ${l}`);
21110
21254
  }
21111
21255
  function capGauges(p, st, w) {
@@ -21322,13 +21466,13 @@ __export(claude_try_exports, {
21322
21466
  });
21323
21467
  import { tmpdir as tmpdir2 } from "os";
21324
21468
  import { pathToFileURL as pathToFileURL4 } from "url";
21325
- async function tryExamples(coreFile, table2, modes, home2, cwd, now = Date.now()) {
21469
+ async function tryExamples(coreFile, table3, modes, home2, cwd, now = Date.now()) {
21326
21470
  const core = await import(pathToFileURL4(coreFile).href);
21327
21471
  return TRY_EXAMPLES.map((ex) => {
21328
21472
  const c = core.classifyRequest({ tool_name: ex.tool_name, tool_input: ex.tool_input, cwd, git_branch: null, project_dir: cwd, session_id: null, home: home2, tmpdir: tmpdir2() });
21329
- const { lead: lead2, mode } = judgeCall(table2, { ...c, input: ex.tool_input }, modes, new MemoryRateStore(), now, cwd, null, home2);
21473
+ const { lead: lead2, mode } = judgeCall(table3, { ...c, input: ex.tool_input }, modes, new MemoryRateStore(), now, cwd, null, home2);
21330
21474
  const verdict = !lead2 ? "run" : mode !== "enforce" ? "watch" : lead2.decision.verdict === "block" ? "block" : "hold";
21331
- const rule = verdict === "run" && c.action === "claude.agent.helper" && modes?.kill_switch !== true ? modelRuleFor(table2.policies.filter((p) => p.helpers && inScope(p, cwd)), String(ex.tool_input["subagent_type"] ?? "general-purpose")) : null;
21475
+ const rule = verdict === "run" && c.action === "claude.agent.helper" && modes?.kill_switch !== true ? modelRuleFor(table3.policies.filter((p) => p.helpers && inScope(p, cwd)), String(ex.tool_input["subagent_type"] ?? "general-purpose")) : null;
21332
21476
  return { what: ex.what, shown: ex.shown, verdict: rule ? "switch" : verdict, ...rule ? { model: rule.model } : {} };
21333
21477
  });
21334
21478
  }
@@ -21405,8 +21549,8 @@ function accountCommand(io, verb) {
21405
21549
  const pkg = anvilPackageOf(io);
21406
21550
  return pkg && packageName(pkg) === "@useanvil/claude-code" ? `npx @useanvil/sdk ${verb}` : `${io.cli ?? "anvil"} ${verb}`;
21407
21551
  }
21408
- function listedRules(table2, modes) {
21409
- return ruleCount(table2) + (dayOneApplies(modes, table2) ? 1 : 0);
21552
+ function listedRules(table3, modes) {
21553
+ return ruleCount(table3) + (dayOneApplies(modes, table3) ? 1 : 0);
21410
21554
  }
21411
21555
  function newerVersion(a, b) {
21412
21556
  const n4 = (v) => v.split(/[.-]/).slice(0, 3).map((x2) => Number(x2) || 0);
@@ -21538,9 +21682,9 @@ function homeState(io, paths2, now) {
21538
21682
  }
21539
21683
  function limitsNow(io, paths2, now) {
21540
21684
  try {
21541
- const table2 = loadEffectiveTable(paths2, installedBaseline(paths2)).value;
21542
- if (limitCount(table2) === 0) return {};
21543
- const { states } = limitsHere(io, paths2, now, table2);
21685
+ const table3 = loadEffectiveTable(paths2, installedBaseline(paths2)).value;
21686
+ if (limitCount(table3) === 0) return {};
21687
+ const { states } = limitsHere(io, paths2, now, table3);
21544
21688
  const budgets = states.filter((s2) => s2.kind === "budget" && s2.short !== null && s2.share !== null && s2.health !== "off").sort((a, b) => b.share - a.share);
21545
21689
  const spent = budgets.find((s2) => s2.share >= 1 && s2.health !== "ok");
21546
21690
  const ok = budgets.find((s2) => s2.health === "ok");
@@ -21979,10 +22123,10 @@ function enforcedPolicy(paths2, rulesJson, label) {
21979
22123
  return raw && !raw["_rules_md"] ? raw : null;
21980
22124
  }
21981
22125
  async function syncRules(paths2, home2, now, cli = "anvil", io) {
21982
- const table2 = await buildCompiledTable(await policySources(paths2, home2), now, cli);
21983
- writeCompiledTable(paths2, table2);
21984
- if (io && budgetsOf(table2).length > 0) catchUpUsage(io, paths2, startOfWeek(now.getTime()));
21985
- return table2;
22126
+ const table3 = await buildCompiledTable(await policySources(paths2, home2), now, cli);
22127
+ writeCompiledTable(paths2, table3);
22128
+ if (io && budgetsOf(table3).length > 0) catchUpUsage(io, paths2, startOfWeek(now.getTime()));
22129
+ return table3;
21986
22130
  }
21987
22131
  async function compileRules(paths2, home2, now, cli) {
21988
22132
  return buildCompiledTable(await policySources(paths2, home2), now, cli);
@@ -22084,9 +22228,9 @@ function hearingFor(io, paths2, now) {
22084
22228
  home: io.home
22085
22229
  };
22086
22230
  }
22087
- function readPlanNow(io, paths2, now, table2) {
22231
+ function readPlanNow(io, paths2, now, table3) {
22088
22232
  try {
22089
- if (!budgetsOf(table2).some((b) => b.unit === "plan")) return;
22233
+ if (!budgetsOf(table3).some((b) => b.unit === "plan")) return;
22090
22234
  const r = lastReading(paths2, now.getTime(), screenPlanScope(io.env, io.home));
22091
22235
  if (r && now.getTime() - r.at < PROBE_EVERY_MS) return;
22092
22236
  const configDir = claudeConfigDir(io.env, io.home);
@@ -22108,14 +22252,14 @@ function readPlanNow(io, paths2, now, table2) {
22108
22252
  } catch {
22109
22253
  }
22110
22254
  }
22111
- function limitsHere(io, paths2, now, table2 = loadEffectiveTable(paths2, installedBaseline(paths2)).value) {
22112
- if (limitCount(table2) === 0) return { states: [], hearing: NOTHING_HEARD, elsewhere: 0, standing: [] };
22255
+ function limitsHere(io, paths2, now, table3 = loadEffectiveTable(paths2, installedBaseline(paths2)).value) {
22256
+ if (limitCount(table3) === 0) return { states: [], hearing: NOTHING_HEARD, elsewhere: 0, standing: [] };
22113
22257
  const hearing = hearingFor(io, paths2, now);
22114
22258
  let standing = [];
22115
22259
  try {
22116
- if (budgetsOf(table2).length > 0) {
22260
+ if (budgetsOf(table3).length > 0) {
22117
22261
  catchUpUsage({ env: io.env, home: io.home, stderr: io.stderr ?? new PassThrough2() }, paths2, startOfWeek(now.getTime()));
22118
- standing = budgetStanding(paths2, table2, now.getTime(), screenPlanScope(io.env, io.home));
22262
+ standing = budgetStanding(paths2, table3, now.getTime(), screenPlanScope(io.env, io.home));
22119
22263
  }
22120
22264
  } catch {
22121
22265
  standing = [];
@@ -22132,7 +22276,7 @@ function limitsHere(io, paths2, now, table2 = loadEffectiveTable(paths2, install
22132
22276
  const resets2 = cap.window === "minute" || cap.window === "hour" ? "" : cap.window === "day" ? " \xB7 resets at midnight" : ` \xB7 resets ${new Date(windowEnd(cap, now.getTime())).toLocaleDateString("en-US", { weekday: "long" })}`;
22133
22277
  return `${capShown(cap, used)} of ${capShown(cap, cap.limit)} used${resets2}${cap.unit !== "calls" && cap.unit !== "money" ? " \xB7 an estimate" : ""}`;
22134
22278
  };
22135
- return { states: limitStates(table2, dir, hearing, standing, now.getTime(), capUse), hearing, elsewhere: limitsElsewhere(table2, dir), standing };
22279
+ return { states: limitStates(table3, dir, hearing, standing, now.getTime(), capUse), hearing, elsewhere: limitsElsewhere(table3, dir), standing };
22136
22280
  }
22137
22281
  function limitBox(states, elsewhere2, p, w, cli, opts = {}) {
22138
22282
  if (states.length === 0 && elsewhere2 === 0) return [];
@@ -22425,9 +22569,9 @@ async function runClaude(args, io = processIO()) {
22425
22569
  err(`${fixCommand("try")}: the built hook is missing (dist/claude-hook-core.js). Reinstall ${packageName(anvilPackageOf(io))}.`);
22426
22570
  return 1;
22427
22571
  }
22428
- const table2 = compiled2 ?? await buildCompiledTable([await baselineSource()], now(), io.cli ?? "anvil");
22572
+ const table3 = compiled2 ?? await buildCompiledTable([await baselineSource()], now(), io.cli ?? "anvil");
22429
22573
  const { tryExamples: tryExamples2, tryLines: tryLines2 } = await Promise.resolve().then(() => (init_claude_try(), claude_try_exports));
22430
- const rows = await tryExamples2(coreFile, table2, compiled2 ? loadEffectiveModes(paths2).value : null, io.home, io.cwd, now().getTime());
22574
+ const rows = await tryExamples2(coreFile, table3, compiled2 ? loadEffectiveModes(paths2).value : null, io.home, io.cwd, now().getTime());
22431
22575
  for (const l of tryLines2(rows, onAnywhere(io, paths2, now()), io.cli ?? "anvil", colourFor(io), widthFor(io), io.fromHome === true)) out(l);
22432
22576
  return 0;
22433
22577
  }
@@ -22453,12 +22597,12 @@ async function runClaude(args, io = processIO()) {
22453
22597
  const { askYesNo: askYesNo2, canAsk: canAsk2 } = await Promise.resolve().then(() => (init_claude_rules(), claude_rules_exports));
22454
22598
  const md = await applyRulesMd2(io, paths2, now(), out, { yes: rest.includes("--yes") || rest.includes("-y"), noModel: rest.includes("--no-model"), ask: (q) => askYesNo2(io, q), canAsk: canAsk2(io) });
22455
22599
  if (md.changed > 0) out("");
22456
- const table2 = await syncRules(paths2, io.home, now(), cli, io);
22600
+ const table3 = await syncRules(paths2, io.home, now(), cli, io);
22457
22601
  const sp = colourFor(io);
22458
22602
  if (!(md.waiting > 0 && md.applied === 0)) {
22459
22603
  out(bar("Sync", "", sp, widthFor(io)));
22460
22604
  out("");
22461
- out(head(MARK.on, `Rules applied \xB7 ${listedRules(table2, readJsonFile(paths2.modes))} rules, compiled for the hook`, sp));
22605
+ out(head(MARK.on, `Rules applied \xB7 ${listedRules(table3, readJsonFile(paths2.modes))} rules, compiled for the hook`, sp));
22462
22606
  out("");
22463
22607
  }
22464
22608
  if (md.errors > 0) err(`${md.errors} ${md.errors === 1 ? "line" : "lines"} can't be enforced (shown above with the reason): fix or remove ${md.errors === 1 ? "it" : "them"}.`);
@@ -22528,12 +22672,12 @@ async function on(args, io, paths2, now, out, err) {
22528
22672
  return 1;
22529
22673
  }
22530
22674
  const cli = io.cli ?? "anvil";
22531
- const table2 = await compileRules(paths2, io.home, now, cli);
22675
+ const table3 = await compileRules(paths2, io.home, now, cli);
22532
22676
  clearPlace(paths2.state, true);
22533
22677
  clearPlace(join35(paths2.state, "lkg"), true);
22534
22678
  for (const f of [join35(paths2.dir, "seal.key"), paths2.compiled, paths2.modes, paths2.install]) clearPlace(f);
22535
22679
  const restored = repairForOn(paths2, now);
22536
- writeCompiledFile(paths2, table2);
22680
+ writeCompiledFile(paths2, table3);
22537
22681
  const { hookFile, banner, second } = copyHookFiles(hookDir, paths2);
22538
22682
  clearPlace(join35(paths2.bin, "baseline.json"));
22539
22683
  writeFileAtomic(join35(paths2.bin, "baseline.json"), `${JSON.stringify(await buildCompiledTable([await baselineSource()], now, cli))}
@@ -22572,8 +22716,8 @@ async function on(args, io, paths2, now, out, err) {
22572
22716
  for (const l of box("What it does", [...item(MARK.blocked, "Blocks", "what can't be undone, always", p, boxInner(w)), ...item(MARK.held, "Holds", "what's dangerous, until you say OK", p, boxInner(w)), ...item(MARK.watching, "Watches", "everything else risky: it runs, and tells you", p, boxInner(w))], p, w)) out(l);
22573
22717
  out(" Most rules start out watching. Hold the ones you care about:");
22574
22718
  out(` ${p.bold(`${claudeHead(cli)} rules edit`)}, or all of them: ${p.bold(`${claudeHead(cli)} enforce all`)}`);
22575
- readPlanNow(io, paths2, now, table2);
22576
- limitLines(limitsHere(io, paths2, now, table2), p, out);
22719
+ readPlanNow(io, paths2, now, table3);
22720
+ limitLines(limitsHere(io, paths2, now, table3), p, out);
22577
22721
  }
22578
22722
  const extra = [];
22579
22723
  if (restored) extra.push(row("Modes", restored, p));
@@ -22619,8 +22763,8 @@ function widthFor(io) {
22619
22763
  const s2 = io.stdout;
22620
22764
  return s2.isTTY === true && typeof s2.columns === "number" && s2.columns > 0 ? Math.max(64, Math.min(WIDTH, s2.columns)) : WIDTH;
22621
22765
  }
22622
- function doesFor(table2, modes, cwd, all2) {
22623
- return { floor: table2 ? presentFloor(table2) : FLOOR, held: heldKinds(table2, modes, cwd), blocking: blockingKinds(table2, cwd), off: offKinds(table2, modes, cwd), dayOne: dayOneApplies(modes, table2) !== null, all: all2, spend: null };
22766
+ function doesFor(table3, modes, cwd, all2) {
22767
+ return { floor: table3 ? presentFloor(table3) : FLOOR, held: heldKinds(table3, modes, cwd), blocking: blockingKinds(table3, cwd), off: offKinds(table3, modes, cwd), dayOne: dayOneApplies(modes, table3) !== null, all: all2, spend: null };
22624
22768
  }
22625
22769
  function off(args, io, paths2, out, err) {
22626
22770
  if (args.includes("--purge")) return purge(io, paths2, out, err, args.includes("--force"));
@@ -22703,6 +22847,14 @@ function anvilCommandIn(file) {
22703
22847
  }
22704
22848
  return null;
22705
22849
  }
22850
+ function ownHookRun(command, paths2, cli) {
22851
+ const hook = join35(paths2.bin, "claude-hook.js");
22852
+ if (typeof command !== "string") return command.args.includes(hook) ? { command: process.execPath, args: [hook] } : null;
22853
+ const files2 = hookCommandFiles(command);
22854
+ if (!files2 || files2[1] !== hook) return null;
22855
+ const launcher = join35(paths2.bin, "claude-hook.sh");
22856
+ return files2[0] === launcher ? hookCommand(process.execPath, hook, launcher, cli, "PreToolUse") : hookCommand(process.execPath, hook);
22857
+ }
22706
22858
  function stopSync(paths2) {
22707
22859
  const lock = join35(paths2.state, "sync.lock");
22708
22860
  const pid = readJsonFile(lock)?.pid;
@@ -22853,7 +23005,7 @@ async function status(io, paths2, now, out) {
22853
23005
  const installs = Object.values(state.installs);
22854
23006
  const effectiveTable = loadEffectiveTable(paths2, installedBaseline(paths2));
22855
23007
  const effectiveModes = loadEffectiveModes(paths2);
22856
- const table2 = effectiveTable.value;
23008
+ const table3 = effectiveTable.value;
22857
23009
  const modes = effectiveModes.value;
22858
23010
  const actions = choosable(Object.keys(ACTION_LABELS).filter((a) => !["claude.bash.unclassified", "claude.tool.other", "claude.mcp.call", "claude.agent.helper"].includes(a)));
22859
23011
  const installRead = readSealed(paths2.install, readSealKey(paths2), 4 * 1024 * 1024);
@@ -22864,7 +23016,9 @@ async function status(io, paths2, now, out) {
22864
23016
  const unrecordedProblems = [...installProblem ? [`${installProblem}, so Anvil cannot tell which settings files it is in`] : [], ...[effectiveTable.problem, effectiveModes.problem].filter((p2) => !!p2)];
22865
23017
  for (const f of unrecorded) {
22866
23018
  const command = anvilCommandIn(f);
22867
- const a = command ? askHook(command, io.env, io.home) : null;
23019
+ const own = command ? ownHookRun(command, paths2, cli) : null;
23020
+ if (command && !own) unrecordedProblems.unshift(`the hook in ${tildify2(f, io.home)} isn't one Anvil wrote, so Anvil didn't run it to check it`);
23021
+ const a = own ? askHook(own, io.env, io.home) : null;
22868
23022
  if (a && !a.checking) unrecordedProblems.unshift(a.detail === "no answer" ? `the hook in ${tildify2(f, io.home)} answers nothing, so Claude Code runs calls unchecked` : `the hook in ${tildify2(f, io.home)} isn't working (${a.detail}), so Claude Code holds every call until it's fixed`);
22869
23023
  }
22870
23024
  const said = `Anvil for Claude Code \xB7 on, with ${installProblem ? "a damaged record" : "no record"} of turning it on \xB7 ${unrecorded.map((f) => tildify2(f, io.home)).join(", ")}`;
@@ -22879,7 +23033,7 @@ async function status(io, paths2, now, out) {
22879
23033
  }
22880
23034
  const seen = pluginSeenAt(paths2);
22881
23035
  if (installs.length === 0 && (anvilPluginEnabled(io) || seen !== null && now.getTime() - seen < 7 * 864e5)) {
22882
- const pluginTable = table2 ?? null;
23036
+ const pluginTable = table3 ?? null;
22883
23037
  const p2 = colourFor(io);
22884
23038
  const w2 = widthFor(io);
22885
23039
  out(bar("Report", "on, through the plugin", p2, w2));
@@ -22916,7 +23070,7 @@ async function status(io, paths2, now, out) {
22916
23070
  const disabledBy = hooksDisabledBy(io);
22917
23071
  const health = claudeCodeHealth(paths2, io.env, io.home);
22918
23072
  const notChecking = health.hooks.length > 0 && health.hooks.every((h) => !h.answer.checking);
22919
- const problems = [...health.problems, ...meterMissing(paths2) && needsMeter(table2) ? [`Budgets and model rules can't be checked: Anvil's meter file (claude-meter.js) is missing \xB7 run ${claudeHead(cli)} on`] : []];
23073
+ const problems = [...health.problems, ...meterMissing(paths2) && needsMeter(table3) ? [`Budgets and model rules can't be checked: Anvil's meter file (claude-meter.js) is missing \xB7 run ${claudeHead(cli)} on`] : []];
22920
23074
  const elsewhere2 = onElsewhere(io, paths2);
22921
23075
  const p = colourFor(io);
22922
23076
  const w = widthFor(io);
@@ -22938,7 +23092,7 @@ async function status(io, paths2, now, out) {
22938
23092
  out("");
22939
23093
  }
22940
23094
  if (!notChecking && !disabledBy && !elsewhere2) {
22941
- for (const l of doesBox(doesFor(table2 ?? null, modes, io.cwd, actions.length), p, w)) out(l);
23095
+ for (const l of doesBox(doesFor(table3 ?? null, modes, io.cwd, actions.length), p, w)) out(l);
22942
23096
  out("");
22943
23097
  }
22944
23098
  const { loadProof: loadProof2, tileBoxes: tileBoxes2 } = await Promise.resolve().then(() => (init_claude_proof(), claude_proof_exports));
@@ -22963,10 +23117,10 @@ async function status(io, paths2, now, out) {
22963
23117
  if (ghost.length > 0) out(row("Watched", `would have stopped ${n3(ghost.length)}, and they ran \xB7 ${bySlug2(ghost)}`, p));
22964
23118
  if (stopped.length > 0 || ghost.length > 0) out("");
22965
23119
  const { usageBox: usageBox2 } = await Promise.resolve().then(() => (init_claude_usage(), claude_usage_exports));
22966
- readPlanNow(io, paths2, now, table2);
23120
+ readPlanNow(io, paths2, now, table3);
22967
23121
  for (const l of usageBox2(io, paths2, now, p, w)) out(l);
22968
23122
  out("");
22969
- const limits = limitsHere(io, paths2, now, table2);
23123
+ const limits = limitsHere(io, paths2, now, table3);
22970
23124
  const limitRows2 = limitBox(limits.states, limits.elsewhere, p, w, cli);
22971
23125
  if (limitRows2.length > 0) {
22972
23126
  for (const l of limitRows2) out(l);
@@ -22978,7 +23132,7 @@ async function status(io, paths2, now, out) {
22978
23132
  if (refused) out(notice("Changes", `${refused[0].toUpperCase()}${refused.slice(1)}`, p, "amber"));
22979
23133
  if (waitingNow.length > 0 || errors > 0 || refused) out("");
22980
23134
  for (const f of Object.keys(state.installs)) out(row("Settings", tildify2(f, io.home), p));
22981
- out(row("Rules", `${table2 ? listedRules(table2, modes) : 0}${table2 ? ` ${p.dim(`${claudeHead(cli)} rules lists them`)}` : ` \xB7 not compiled: run ${claudeHead(cli)} sync`}`, p));
23135
+ out(row("Rules", `${table3 ? listedRules(table3, modes) : 0}${table3 ? ` ${p.dim(`${claudeHead(cli)} rules lists them`)}` : ` \xB7 not compiled: run ${claudeHead(cli)} sync`}`, p));
22982
23136
  const { rulesMdState: rulesMdState2 } = await Promise.resolve().then(() => (init_claude_rules_md(), claude_rules_md_exports));
22983
23137
  for (const s2 of rulesMdState2(io, paths2)) out(row("Rules file", `${s2.label} \xB7 ${s2.state === "applied" ? "applied" : `${s2.state === "changed" ? "changed since it was applied" : s2.state === "removed" ? "removed: its rules still hold" : s2.state === "unreadable" ? "can't be read: the rules applied from it still hold" : "not applied yet"} \xB7 run ${claudeHead(cli)} sync`}`, p));
22984
23138
  const link = dashboardLine2(io, paths2, readSyncIdentity(io.env, io.home), now, p);
@@ -22992,14 +23146,14 @@ async function status(io, paths2, now, out) {
22992
23146
  if (broken) out(next(`${claudeHead(cli)} on`, "reinstalls the hook and restores what Anvil last set", p));
22993
23147
  return problems.length > 0 || disabledBy ? 1 : 0;
22994
23148
  }
22995
- function knownSlugs(table2) {
23149
+ function knownSlugs(table3) {
22996
23150
  const map = /* @__PURE__ */ new Map();
22997
23151
  for (const [action, label] of Object.entries(ACTION_LABELS)) {
22998
23152
  if (["claude.bash.unclassified", "claude.tool.other", "claude.mcp.call", "claude.agent.helper"].includes(action)) continue;
22999
23153
  map.set(label.slug, [...map.get(label.slug) ?? [], action]);
23000
23154
  }
23001
23155
  for (const slug2 of ["protected", "repeat", "delete-burst", "helper-burst"]) map.set(slug2, actionsForSlug(slug2));
23002
- for (const p of table2?.policies ?? []) {
23156
+ for (const p of table3?.policies ?? []) {
23003
23157
  if (p.origin === "baseline") continue;
23004
23158
  for (const r of p.rules) map.set(r.id, [...r.applies_to ?? p.allowed_actions]);
23005
23159
  }
@@ -23053,14 +23207,14 @@ function clearUnsealed(paths2) {
23053
23207
  }
23054
23208
  async function saveScreen(staged, m, io, paths2, now, err) {
23055
23209
  const { editedRulesMd: editedRulesMd2, loadScreen: loadScreen2 } = await Promise.resolve().then(() => (init_claude_screen(), claude_screen_exports));
23056
- const { applyRulesMd: applyRulesMd2, readRulesMdOr: readRulesMdOr2, unappliedChanges: unappliedChanges2, unappliedMessage: unappliedMessage2, userRulesMdFile: userRulesMdFile2 } = await Promise.resolve().then(() => (init_claude_rules_md(), claude_rules_md_exports));
23210
+ const { applyRulesMd: applyRulesMd2, appliesUnseen: appliesUnseen2, readRulesMdOr: readRulesMdOr2, unappliedChanges: unappliedChanges2, unappliedMessage: unappliedMessage2, userRulesMdFile: userRulesMdFile2 } = await Promise.resolve().then(() => (init_claude_rules_md(), claude_rules_md_exports));
23057
23211
  const { parseRulesMd: parseRulesMd2, withoutLine: withoutLine2, withRuleLine: withRuleLine2 } = await Promise.resolve().then(() => (init_rules_md(), rules_md_exports));
23058
23212
  const said = [];
23059
23213
  const quiet = () => void 0;
23060
23214
  const slugOf2 = (a) => ACTION_LABELS[a]?.slug ?? a;
23061
23215
  if (staged.applyPending && m.pending) {
23062
23216
  let errors = 0;
23063
- for (const f of [m.file, ...m.file.origin === "project" ? [userRulesMdFile2(io.home)] : []]) errors += (await applyRulesMd2(io, paths2, now, quiet, { yes: true, only: f, quiet: true })).errors;
23217
+ for (const f of [m.file, ...m.file.origin === "project" ? [userRulesMdFile2(io.home)] : []].filter((f2) => appliesUnseen2(paths2, f2))) errors += (await applyRulesMd2(io, paths2, now, quiet, { yes: true, only: f, quiet: true })).errors;
23064
23218
  await syncRules(paths2, io.home, now, io.cli ?? "anvil", io);
23065
23219
  const cant2 = errors > 0 ? ` \xB7 ${errors} ${errors === 1 ? "line Anvil can't use" : "lines Anvil can't use"}: ${claudeHead(io.cli ?? "anvil")} sync shows ${errors === 1 ? "it" : "them"}` : "";
23066
23220
  return [`${head(MARK.ok, `Applied ${m.pending}${cant2}`, colourFor(io))}`];
@@ -23141,7 +23295,7 @@ async function saveScreen(staged, m, io, paths2, now, err) {
23141
23295
  return lines;
23142
23296
  }
23143
23297
  async function setMode(mode, args, io, paths2, now, out, err) {
23144
- const table2 = loadEffectiveTable(paths2, void 0).value ?? await buildCompiledTable([await baselineSource()]);
23298
+ const table3 = loadEffectiveTable(paths2, void 0).value ?? await buildCompiledTable([await baselineSource()]);
23145
23299
  const names3 = args.filter((a) => !a.startsWith("--"));
23146
23300
  const effective = loadEffectiveModes(paths2);
23147
23301
  if (effective.source === "strict") {
@@ -23154,7 +23308,7 @@ async function setMode(mode, args, io, paths2, now, out, err) {
23154
23308
  return 1;
23155
23309
  }
23156
23310
  if (names3.length === 0 || names3.includes("all")) {
23157
- const linked2 = await flipInWorkspace(mode, syncedActions(table2), io, paths2, now);
23311
+ const linked2 = await flipInWorkspace(mode, syncedActions(table3), io, paths2, now);
23158
23312
  writeModes(paths2, withModes(current, mode, "all", now), current);
23159
23313
  const p2 = colourFor(io);
23160
23314
  const w2 = widthFor(io);
@@ -23181,7 +23335,7 @@ async function setMode(mode, args, io, paths2, now, out, err) {
23181
23335
  return 0;
23182
23336
  }
23183
23337
  names3.splice(0, names3.length, ...rest);
23184
- const slugs2 = knownSlugs(table2);
23338
+ const slugs2 = knownSlugs(table3);
23185
23339
  const unknown = names3.filter((s2) => !slugs2.has(s2));
23186
23340
  if (unknown.length > 0) {
23187
23341
  err(`${claudeHead(io.cli ?? "anvil")} ${mode}: no rule called ${unknown.map((u) => `'${u}'`).join(", ")}. Rules: ${[...slugs2.keys()].join(", ")}`);
@@ -23250,7 +23404,7 @@ function allowed(io, paths2, hold, file, out, err) {
23250
23404
  out(next("Send your message again, or ask Claude to go on", "within 10 minutes", p));
23251
23405
  return 0;
23252
23406
  }
23253
- out(head(MARK.ok, `Allowed once \xB7 ${hold.why}${hold.project_name ? ` \xB7 ${hold.project_name}` : ""}`, p));
23407
+ out(head(MARK.ok, `Allowed once \xB7 ${visible(hold.why)}${hold.project_name ? ` \xB7 ${visible(hold.project_name)}` : ""}`, p));
23254
23408
  out("");
23255
23409
  out(next("Ask Claude to try it again", "within 10 minutes, this call only", p));
23256
23410
  return 0;
@@ -23286,8 +23440,8 @@ async function allowWaiting(io, paths2, now, out, err) {
23286
23440
  waiting.forEach(({ hold }, i) => {
23287
23441
  const made2 = Date.parse(hold.created_at);
23288
23442
  if (i > 0) laid.push("");
23289
- laid.push(`${p.blue(p.bold(String(i + 1)))} ${p.bold(cut(hold.why, inner - 3))}`);
23290
- if (typeof hold.command === "string") laid.push(` ${cut(hold.command, inner - 3)}`);
23443
+ laid.push(`${p.blue(p.bold(String(i + 1)))} ${p.bold(cut(visible(hold.why), inner - 3))}`);
23444
+ if (typeof hold.command === "string") laid.push(` ${cut(visible(hold.command), inner - 3)}`);
23291
23445
  laid.push(` ${p.dim(cut([hold.project ? tildify2(hold.project, io.home) : hold.project_name, ago2(t - made2), left(Date.parse(hold.expires_at) - t)].filter(Boolean).join(" \xB7 "), inner - 3))}`);
23292
23446
  });
23293
23447
  for (const l of box("Waiting for your OK", laid, p, w, { mark: MARK.held, note: `${waiting.length} ${waiting.length === 1 ? "call" : "calls"}` })) out(l);
@@ -23387,13 +23541,13 @@ async function rules(args, io, paths2, now, out, err) {
23387
23541
  out(` ${p.mark(MARK.blocked)} block and ${p.mark(MARK.held)} hold stop Claude. ${p.mark(MARK.watching)} watch lets it run, and tells you.`);
23388
23542
  out(" Most start as watch: hold the ones you care about, or all of them.");
23389
23543
  out("");
23390
- const table2 = compiled2 ?? await buildCompiledTable([await baselineSource()], now, io.cli ?? "anvil");
23544
+ const table3 = compiled2 ?? await buildCompiledTable([await baselineSource()], now, io.cli ?? "anvil");
23391
23545
  const { rulesListing: rulesListing2 } = await Promise.resolve().then(() => (init_claude_rules(), claude_rules_exports));
23392
- const found = compiled2 ? limitsHere(io, paths2, now, table2) : null;
23546
+ const found = compiled2 ? limitsHere(io, paths2, now, table3) : null;
23393
23547
  const { catchesOf: catchesOf2, rulesHere: rulesHere2, withCatches: withCatches2 } = await Promise.resolve().then(() => (init_claude_screen(), claude_screen_exports));
23394
23548
  const { connectedHere: connectedHere2 } = await Promise.resolve().then(() => (init_claude_connected(), claude_connected_exports));
23395
- const limits = found ? { ...found, states: withCatches2(found.states, catchesOf2(table2, connectedHere2(io.home, normalDir(io.cwd)), rulesHere2(io))) } : null;
23396
- for (const l of rulesListing2(table2, compiled2 ? loadEffectiveModes(paths2).value : null, io.cli ?? "anvil", p, w, limits, normalDir(io.cwd))) out(l);
23549
+ const limits = found ? { ...found, states: withCatches2(found.states, catchesOf2(table3, connectedHere2(io.home, normalDir(io.cwd)), rulesHere2(io))) } : null;
23550
+ for (const l of rulesListing2(table3, compiled2 ? loadEffectiveModes(paths2).value : null, io.cli ?? "anvil", p, w, limits, normalDir(io.cwd))) out(l);
23397
23551
  const { definitionsIn: definitionsIn2 } = await Promise.resolve().then(() => (init_rules_md(), rules_md_exports));
23398
23552
  const { projectRulesMdFile: projectRulesMdFile2, projectWithRulesMd: projectWithRulesMd2, readRulesMdOr: readRulesMdOr2, userRulesMdFile: userRulesMdFile2 } = await Promise.resolve().then(() => (init_claude_rules_md(), claude_rules_md_exports));
23399
23553
  const here = projectWithRulesMd2(io.cwd, io.home);
@@ -23447,6 +23601,7 @@ var init_claude = __esm({
23447
23601
  init_control_log();
23448
23602
  init_install();
23449
23603
  init_kit_command();
23604
+ init_visible();
23450
23605
  TIGHTENS = /* @__PURE__ */ new Set(["enforce"]);
23451
23606
  n3 = (v) => v.toLocaleString("en-US");
23452
23607
  SHOWN_FROM_HOME = /* @__PURE__ */ new Set(["rules", "help", "report", "proof", "try", "on"]);
@@ -23454,7 +23609,7 @@ var init_claude = __esm({
23454
23609
  ANVIL_PLUGIN_ID = "anvil@anvil";
23455
23610
  HOOK_FILES = ["claude-hook-core.js", "claude-sync.js", "claude-hook.js"];
23456
23611
  OPTIONAL_HOOK_FILES = ["claude-meter.js", "claude-helpers.js", "claude-conditions.js", "claude-powershell.cjs"];
23457
- needsMeter = (table2) => (table2?.policies ?? []).some((p) => (p.budgets?.length ?? 0) > 0 || (p.model_rules?.guards?.length ?? 0) > 0 || (p.model_rules?.never?.length ?? 0) > 0);
23612
+ needsMeter = (table3) => (table3?.policies ?? []).some((p) => (p.budgets?.length ?? 0) > 0 || (p.model_rules?.guards?.length ?? 0) > 0 || (p.model_rules?.never?.length ?? 0) > 0);
23458
23613
  NOTHING_HEARD = { route: "none", elsewhere: null, disabled: null, killed: false, meterGone: false, quiet: /* @__PURE__ */ new Set(), codes: [], hookGone: false, feeds: () => ({ any: false, plan: false, off: false }), probe: () => null, cli: "anvil", home: "" };
23459
23614
  BUILD_LIST = "files.json";
23460
23615
  sha2562 = (b) => createHash13("sha256").update(b).digest("hex");