@sunasteriskrnd/takumi 1.0.0-dev.35 → 1.0.0-dev.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +697 -406
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19815,7 +19815,7 @@ var package_default;
19815
19815
  var init_package = __esm(() => {
19816
19816
  package_default = {
19817
19817
  name: "@sunasteriskrnd/takumi",
19818
- version: "1.0.0-dev.35",
19818
+ version: "1.0.0-dev.36",
19819
19819
  description: "CLI tool for bootstrapping and managing Takumi projects",
19820
19820
  type: "module",
19821
19821
  repository: {
@@ -43277,6 +43277,43 @@ var init_capabilities = __esm(() => {
43277
43277
  import_semver4 = __toESM(require_semver2(), 1);
43278
43278
  execFileAsync2 = promisify2(execFile2);
43279
43279
  CODEX_CAPABILITY_TABLE = [
43280
+ {
43281
+ version: "0.138.0",
43282
+ events: {
43283
+ SessionStart: {
43284
+ supported: true,
43285
+ supportsAdditionalContext: true,
43286
+ allowedMatchers: ["startup", "resume", "clear"]
43287
+ },
43288
+ UserPromptSubmit: {
43289
+ supported: true,
43290
+ supportsAdditionalContext: true
43291
+ },
43292
+ PreToolUse: {
43293
+ supported: true,
43294
+ supportsAdditionalContext: true,
43295
+ permissionDecisionValues: ["deny", "allow", "block"]
43296
+ },
43297
+ PostToolUse: {
43298
+ supported: true,
43299
+ supportsAdditionalContext: true
43300
+ },
43301
+ PermissionRequest: {
43302
+ supported: true,
43303
+ supportsAdditionalContext: false
43304
+ },
43305
+ Stop: {
43306
+ supported: true,
43307
+ supportsAdditionalContext: false
43308
+ },
43309
+ SubagentStop: {
43310
+ supported: true,
43311
+ supportsAdditionalContext: false
43312
+ }
43313
+ },
43314
+ sessionStartMatchersOnly: ["startup", "resume", "clear"],
43315
+ requiresFeatureFlag: true
43316
+ },
43280
43317
  {
43281
43318
  version: "0.130.0",
43282
43319
  events: {
@@ -49082,11 +49119,11 @@ var exports_monorepo_resolver = {};
49082
49119
  __export(exports_monorepo_resolver, {
49083
49120
  resolveMonorepoRoot: () => resolveMonorepoRoot
49084
49121
  });
49085
- import { existsSync as existsSync54, readFileSync as readFileSync22 } from "node:fs";
49122
+ import { existsSync as existsSync55, readFileSync as readFileSync22 } from "node:fs";
49086
49123
  import { dirname as dirname33, join as join116, resolve as resolve26 } from "node:path";
49087
49124
  import { fileURLToPath as fileURLToPath3 } from "node:url";
49088
49125
  function parseMetadataAt(metadataPath) {
49089
- if (!existsSync54(metadataPath))
49126
+ if (!existsSync55(metadataPath))
49090
49127
  return null;
49091
49128
  try {
49092
49129
  const raw = readFileSync22(metadataPath, "utf-8");
@@ -49101,7 +49138,7 @@ function parseMetadataAt(metadataPath) {
49101
49138
  }
49102
49139
  function readSourceDirFromPackageJson(candidateRoot) {
49103
49140
  const packageJsonPath = join116(candidateRoot, "package.json");
49104
- if (!existsSync54(packageJsonPath))
49141
+ if (!existsSync55(packageJsonPath))
49105
49142
  return null;
49106
49143
  try {
49107
49144
  const parsed = JSON.parse(readFileSync22(packageJsonPath, "utf-8"));
@@ -49938,7 +49975,7 @@ function renderGlobalHelp(commands, options2 = DEFAULT_HELP_OPTIONS) {
49938
49975
  theme.heading("Commands:")
49939
49976
  ];
49940
49977
  const commandNames = Object.keys(commands);
49941
- const maxNameWidth = Math.max(...commandNames.map((n) => n.length));
49978
+ const maxNameWidth = Math.max(...commandNames.map((n2) => n2.length));
49942
49979
  const sortedCommands = Object.entries(commands).sort(([a3], [b4]) => a3.localeCompare(b4));
49943
49980
  for (const [name, help] of sortedCommands) {
49944
49981
  const cmdPart = ` ${padEnd(theme.command(name), maxNameWidth + 4)}`;
@@ -56974,6 +57011,26 @@ async function checkCodexHooksHealth() {
56974
57011
  details: configTomlPath,
56975
57012
  autoFixable: false
56976
57013
  });
57014
+ const hasSubagentStop = await hasSubagentStopEntry(hooksJsonPath);
57015
+ results.push(hasSubagentStop ? {
57016
+ id: "codex-hooks-subagent-stop",
57017
+ name: "Codex SubagentStop telemetry",
57018
+ group: "takumi",
57019
+ priority: "standard",
57020
+ status: "pass",
57021
+ message: "SubagentStop hook wired (per-subagent token attribution active)",
57022
+ details: hooksJsonPath,
57023
+ autoFixable: false
57024
+ } : {
57025
+ id: "codex-hooks-subagent-stop",
57026
+ name: "Codex SubagentStop telemetry",
57027
+ group: "takumi",
57028
+ priority: "standard",
57029
+ status: "warn",
57030
+ message: "No SubagentStop hook — per-subagent tokens won't be attributed. Expected on Codex < 0.138; otherwise re-run `tkm init -a codex`.",
57031
+ details: hooksJsonPath,
57032
+ autoFixable: false
57033
+ });
56977
57034
  const missing = await collectMissingWrapperTargets(hooksJsonPath);
56978
57035
  results.push(missing.length === 0 ? {
56979
57036
  id: "codex-hooks-command-targets",
@@ -56996,6 +57053,18 @@ async function checkCodexHooksHealth() {
56996
57053
  });
56997
57054
  return results;
56998
57055
  }
57056
+ async function hasSubagentStopEntry(hooksJsonPath) {
57057
+ let parsed;
57058
+ try {
57059
+ parsed = JSON.parse(await readFile33(hooksJsonPath, "utf8"));
57060
+ } catch {
57061
+ return false;
57062
+ }
57063
+ const groups = parsed?.hooks?.SubagentStop;
57064
+ if (!Array.isArray(groups))
57065
+ return false;
57066
+ return groups.some((group) => Array.isArray(group?.hooks) && group.hooks.length > 0);
57067
+ }
56999
57068
  async function collectMissingWrapperTargets(hooksJsonPath) {
57000
57069
  let parsed;
57001
57070
  try {
@@ -60084,6 +60153,119 @@ async function readStdinJson() {
60084
60153
  }
60085
60154
  }
60086
60155
 
60156
+ // src/domains/hooks/telemetry/lib/claude-transcript-reader.ts
60157
+ function num2(v2) {
60158
+ return typeof v2 === "number" && Number.isFinite(v2) ? v2 : 0;
60159
+ }
60160
+ function zeroTokens() {
60161
+ return { input: 0, output: 0, cache_read: 0, cache_write: 0 };
60162
+ }
60163
+ function addTokens2(a3, b3) {
60164
+ return {
60165
+ input: a3.input + b3.input,
60166
+ output: a3.output + b3.output,
60167
+ cache_read: a3.cache_read + b3.cache_read,
60168
+ cache_write: a3.cache_write + b3.cache_write
60169
+ };
60170
+ }
60171
+ function extractTokens(record) {
60172
+ const usage = record.message?.usage;
60173
+ if (!usage)
60174
+ return null;
60175
+ return {
60176
+ input: num2(usage.input_tokens),
60177
+ output: num2(usage.output_tokens),
60178
+ cache_read: num2(usage.cache_read_input_tokens),
60179
+ cache_write: num2(usage.cache_creation_input_tokens)
60180
+ };
60181
+ }
60182
+ async function tailRead(args) {
60183
+ const { records, newOffset } = readNew(args.transcriptPath, args.offset);
60184
+ return { records, nextOffset: newOffset };
60185
+ }
60186
+ function bucketTokens(records) {
60187
+ const mainLoopDelta = zeroTokens();
60188
+ const subagentDeltas = new Map;
60189
+ const tokenUsageDeltas = new Map;
60190
+ for (const record of records) {
60191
+ if (record.type !== "assistant")
60192
+ continue;
60193
+ const tokens = extractTokens(record);
60194
+ if (!tokens)
60195
+ continue;
60196
+ if (record.isSidechain === true) {
60197
+ const key = record.agentId ?? record.toolUseID;
60198
+ if (!key) {
60199
+ const prev2 = mainLoopDelta;
60200
+ Object.assign(mainLoopDelta, addTokens2(prev2, tokens));
60201
+ continue;
60202
+ }
60203
+ const prev = subagentDeltas.get(key) ?? zeroTokens();
60204
+ subagentDeltas.set(key, addTokens2(prev, tokens));
60205
+ } else {
60206
+ Object.assign(mainLoopDelta, addTokens2(mainLoopDelta, tokens));
60207
+ }
60208
+ const model = record.message?.model;
60209
+ if (model) {
60210
+ const prev = tokenUsageDeltas.get(model) ?? zeroTokens();
60211
+ tokenUsageDeltas.set(model, addTokens2(prev, tokens));
60212
+ }
60213
+ }
60214
+ return { mainLoopDelta, subagentDeltas, tokenUsageDeltas };
60215
+ }
60216
+
60217
+ // src/domains/hooks/telemetry/lib/claude-transcript-apply.ts
60218
+ function ensureTokens(t) {
60219
+ return t ?? { input: 0, output: 0, cache_read: 0, cache_write: 0 };
60220
+ }
60221
+ function addTokens3(a3, b3) {
60222
+ return {
60223
+ input: a3.input + b3.input,
60224
+ output: a3.output + b3.output,
60225
+ cache_read: a3.cache_read + b3.cache_read,
60226
+ cache_write: a3.cache_write + b3.cache_write
60227
+ };
60228
+ }
60229
+ function mergeTokenUsageDeltas(existing, deltas) {
60230
+ const out = { ...existing ?? {} };
60231
+ for (const [model, delta] of deltas) {
60232
+ out[model] = addTokens3(ensureTokens(out[model]), delta);
60233
+ }
60234
+ return out;
60235
+ }
60236
+ async function applyClaudeTranscriptDelta(args) {
60237
+ if (!args.transcriptPath) {
60238
+ return { summary: args.summary, read: false };
60239
+ }
60240
+ try {
60241
+ const { records, nextOffset } = await tailRead({
60242
+ transcriptPath: args.transcriptPath,
60243
+ offset: args.summary.transcript_offset
60244
+ });
60245
+ if (records.length === 0 && nextOffset === args.summary.transcript_offset) {
60246
+ return { summary: args.summary, read: true };
60247
+ }
60248
+ const { mainLoopDelta, subagentDeltas, tokenUsageDeltas } = bucketTokens(records);
60249
+ const updated = {
60250
+ ...args.summary,
60251
+ main_loop_tokens: addTokens3(args.summary.main_loop_tokens, mainLoopDelta),
60252
+ subagents: args.summary.subagents.map((rec) => {
60253
+ const delta = subagentDeltas.get(rec.id);
60254
+ if (!delta)
60255
+ return rec;
60256
+ return { ...rec, tokens: addTokens3(ensureTokens(rec.tokens), delta) };
60257
+ }),
60258
+ token_usage: mergeTokenUsageDeltas(args.summary.token_usage, tokenUsageDeltas),
60259
+ transcript_offset: nextOffset
60260
+ };
60261
+ return { summary: updated, read: true };
60262
+ } catch (e2) {
60263
+ const error = e2?.message ?? String(e2);
60264
+ hookLog("transcript_apply", { error });
60265
+ return { summary: args.summary, read: false, error };
60266
+ }
60267
+ }
60268
+
60087
60269
  // src/domains/hooks/telemetry/lib/detached-put.ts
60088
60270
  import { spawn as spawn2 } from "node:child_process";
60089
60271
  import { openSync as openSync4 } from "node:fs";
@@ -60326,7 +60508,7 @@ function buildSessionPayload(args) {
60326
60508
 
60327
60509
  // src/domains/hooks/telemetry/lib/summary.ts
60328
60510
  import { promises as fs21 } from "node:fs";
60329
- function zeroTokens() {
60511
+ function zeroTokens2() {
60330
60512
  return { input: 0, output: 0, cache_read: 0, cache_write: 0 };
60331
60513
  }
60332
60514
  function initialSummary(args) {
@@ -60338,7 +60520,7 @@ function initialSummary(args) {
60338
60520
  kit_versions: args.kitVersions ?? {},
60339
60521
  project: args.project,
60340
60522
  timing: { started_at: args.startedAt, ended_at: null, duration_s: null },
60341
- main_loop_tokens: zeroTokens(),
60523
+ main_loop_tokens: zeroTokens2(),
60342
60524
  token_usage: {},
60343
60525
  subagents: [],
60344
60526
  skills: [],
@@ -60351,7 +60533,7 @@ function initialSummary(args) {
60351
60533
  subagents: { by_type: {} },
60352
60534
  skills: { by_name: {} }
60353
60535
  },
60354
- totals: zeroTokens(),
60536
+ totals: zeroTokens2(),
60355
60537
  pending_user_triggers: [],
60356
60538
  skills_in_flight: {},
60357
60539
  transcript_offset: 0,
@@ -60439,119 +60621,6 @@ async function shouldFlush(args) {
60439
60621
  return false;
60440
60622
  }
60441
60623
 
60442
- // src/domains/hooks/telemetry/lib/transcript-reader.ts
60443
- function num2(v2) {
60444
- return typeof v2 === "number" && Number.isFinite(v2) ? v2 : 0;
60445
- }
60446
- function zeroTokens2() {
60447
- return { input: 0, output: 0, cache_read: 0, cache_write: 0 };
60448
- }
60449
- function addTokens2(a3, b3) {
60450
- return {
60451
- input: a3.input + b3.input,
60452
- output: a3.output + b3.output,
60453
- cache_read: a3.cache_read + b3.cache_read,
60454
- cache_write: a3.cache_write + b3.cache_write
60455
- };
60456
- }
60457
- function extractTokens(record) {
60458
- const usage = record.message?.usage;
60459
- if (!usage)
60460
- return null;
60461
- return {
60462
- input: num2(usage.input_tokens),
60463
- output: num2(usage.output_tokens),
60464
- cache_read: num2(usage.cache_read_input_tokens),
60465
- cache_write: num2(usage.cache_creation_input_tokens)
60466
- };
60467
- }
60468
- async function tailRead(args) {
60469
- const { records, newOffset } = readNew(args.transcriptPath, args.offset);
60470
- return { records, nextOffset: newOffset };
60471
- }
60472
- function bucketTokens(records) {
60473
- const mainLoopDelta = zeroTokens2();
60474
- const subagentDeltas = new Map;
60475
- const tokenUsageDeltas = new Map;
60476
- for (const record of records) {
60477
- if (record.type !== "assistant")
60478
- continue;
60479
- const tokens = extractTokens(record);
60480
- if (!tokens)
60481
- continue;
60482
- if (record.isSidechain === true) {
60483
- const key = record.agentId ?? record.toolUseID;
60484
- if (!key) {
60485
- const prev2 = mainLoopDelta;
60486
- Object.assign(mainLoopDelta, addTokens2(prev2, tokens));
60487
- continue;
60488
- }
60489
- const prev = subagentDeltas.get(key) ?? zeroTokens2();
60490
- subagentDeltas.set(key, addTokens2(prev, tokens));
60491
- } else {
60492
- Object.assign(mainLoopDelta, addTokens2(mainLoopDelta, tokens));
60493
- }
60494
- const model = record.message?.model;
60495
- if (model) {
60496
- const prev = tokenUsageDeltas.get(model) ?? zeroTokens2();
60497
- tokenUsageDeltas.set(model, addTokens2(prev, tokens));
60498
- }
60499
- }
60500
- return { mainLoopDelta, subagentDeltas, tokenUsageDeltas };
60501
- }
60502
-
60503
- // src/domains/hooks/telemetry/lib/transcript-apply.ts
60504
- function ensureTokens(t) {
60505
- return t ?? { input: 0, output: 0, cache_read: 0, cache_write: 0 };
60506
- }
60507
- function addTokens3(a3, b3) {
60508
- return {
60509
- input: a3.input + b3.input,
60510
- output: a3.output + b3.output,
60511
- cache_read: a3.cache_read + b3.cache_read,
60512
- cache_write: a3.cache_write + b3.cache_write
60513
- };
60514
- }
60515
- function mergeTokenUsageDeltas(existing, deltas) {
60516
- const out = { ...existing ?? {} };
60517
- for (const [model, delta] of deltas) {
60518
- out[model] = addTokens3(ensureTokens(out[model]), delta);
60519
- }
60520
- return out;
60521
- }
60522
- async function applyTranscriptDelta(args) {
60523
- if (!args.transcriptPath) {
60524
- return { summary: args.summary, read: false };
60525
- }
60526
- try {
60527
- const { records, nextOffset } = await tailRead({
60528
- transcriptPath: args.transcriptPath,
60529
- offset: args.summary.transcript_offset
60530
- });
60531
- if (records.length === 0 && nextOffset === args.summary.transcript_offset) {
60532
- return { summary: args.summary, read: true };
60533
- }
60534
- const { mainLoopDelta, subagentDeltas, tokenUsageDeltas } = bucketTokens(records);
60535
- const updated = {
60536
- ...args.summary,
60537
- main_loop_tokens: addTokens3(args.summary.main_loop_tokens, mainLoopDelta),
60538
- subagents: args.summary.subagents.map((rec) => {
60539
- const delta = subagentDeltas.get(rec.id);
60540
- if (!delta)
60541
- return rec;
60542
- return { ...rec, tokens: addTokens3(ensureTokens(rec.tokens), delta) };
60543
- }),
60544
- token_usage: mergeTokenUsageDeltas(args.summary.token_usage, tokenUsageDeltas),
60545
- transcript_offset: nextOffset
60546
- };
60547
- return { summary: updated, read: true };
60548
- } catch (e2) {
60549
- const error = e2?.message ?? String(e2);
60550
- hookLog("transcript_apply", { error });
60551
- return { summary: args.summary, read: false, error };
60552
- }
60553
- }
60554
-
60555
60624
  // src/domains/hooks/telemetry/flush/session-end.ts
60556
60625
  var PUT_TIMEOUT_MS = 5000;
60557
60626
  function readCliVersion() {
@@ -60597,7 +60666,7 @@ async function runSessionEndFlush(data, ctx) {
60597
60666
  const transcriptPath = typeof data.transcript_path === "string" ? data.transcript_path : (await readMeta(sessionDir))?.transcript_path ?? null;
60598
60667
  let finalSummary = summary;
60599
60668
  if (transcriptPath) {
60600
- const applied = await applyTranscriptDelta({ summary, transcriptPath });
60669
+ const applied = await applyClaudeTranscriptDelta({ summary, transcriptPath });
60601
60670
  if (applied.read)
60602
60671
  finalSummary = applied.summary;
60603
60672
  }
@@ -60685,13 +60754,123 @@ async function handleSessionEnd(agent, flags = {}) {
60685
60754
  // src/domains/hooks/telemetry/flush/stop.ts
60686
60755
  init_takumi_constants();
60687
60756
 
60757
+ // src/domains/hooks/telemetry/lib/codex-tokens.ts
60758
+ import * as fs23 from "node:fs";
60759
+ function n(v2) {
60760
+ return typeof v2 === "number" && Number.isFinite(v2) ? v2 : 0;
60761
+ }
60762
+ function codexTokensOf(rec) {
60763
+ const r2 = rec;
60764
+ if (r2?.type !== "event_msg")
60765
+ return null;
60766
+ if (r2?.payload?.type !== "token_count")
60767
+ return null;
60768
+ const u = r2?.payload?.info?.last_token_usage;
60769
+ if (!u)
60770
+ return null;
60771
+ const input = n(u.input_tokens);
60772
+ const cached = n(u.cached_input_tokens);
60773
+ return {
60774
+ input: Math.max(0, input - cached),
60775
+ output: n(u.output_tokens) + n(u.reasoning_output_tokens),
60776
+ cache_read: cached,
60777
+ cache_write: 0
60778
+ };
60779
+ }
60780
+ function sumCodexChildTokens(jsonlPath) {
60781
+ const acc = { input: 0, output: 0, cache_read: 0, cache_write: 0 };
60782
+ if (!jsonlPath || !fs23.existsSync(jsonlPath))
60783
+ return acc;
60784
+ const { records } = readNew(jsonlPath, 0);
60785
+ for (const rec of records) {
60786
+ const tok = codexTokensOf(rec);
60787
+ if (!tok)
60788
+ continue;
60789
+ acc.input += tok.input;
60790
+ acc.output += tok.output;
60791
+ acc.cache_read += tok.cache_read;
60792
+ acc.cache_write += tok.cache_write;
60793
+ }
60794
+ return acc;
60795
+ }
60796
+
60797
+ // src/domains/hooks/telemetry/lib/codex-transcript-apply.ts
60798
+ function addTokens4(a3, b3) {
60799
+ return {
60800
+ input: a3.input + b3.input,
60801
+ output: a3.output + b3.output,
60802
+ cache_read: a3.cache_read + b3.cache_read,
60803
+ cache_write: a3.cache_write + b3.cache_write
60804
+ };
60805
+ }
60806
+ function turnContextModel(rec) {
60807
+ const r2 = rec;
60808
+ if (r2?.type !== "turn_context")
60809
+ return null;
60810
+ const m2 = r2.payload?.model;
60811
+ return typeof m2 === "string" && m2 ? m2 : null;
60812
+ }
60813
+ async function applyCodexTranscriptDelta(args) {
60814
+ if (!args.transcriptPath) {
60815
+ return { summary: args.summary, read: false };
60816
+ }
60817
+ try {
60818
+ const fromOffset = args.summary.transcript_offset;
60819
+ const { records, newOffset } = readNew(args.transcriptPath, fromOffset);
60820
+ if (records.length === 0 && newOffset === fromOffset) {
60821
+ return { summary: args.summary, read: true };
60822
+ }
60823
+ let currentModel = args.summary.last_codex_model ?? args.stdinModel ?? null;
60824
+ const mainLoopDelta = { input: 0, output: 0, cache_read: 0, cache_write: 0 };
60825
+ const tokenUsageDeltas = new Map;
60826
+ for (const rec of records) {
60827
+ const model = turnContextModel(rec);
60828
+ if (model) {
60829
+ currentModel = model;
60830
+ continue;
60831
+ }
60832
+ const tok = codexTokensOf(rec);
60833
+ if (!tok)
60834
+ continue;
60835
+ mainLoopDelta.input += tok.input;
60836
+ mainLoopDelta.output += tok.output;
60837
+ mainLoopDelta.cache_read += tok.cache_read;
60838
+ mainLoopDelta.cache_write += tok.cache_write;
60839
+ if (currentModel) {
60840
+ tokenUsageDeltas.set(currentModel, addTokens4(tokenUsageDeltas.get(currentModel) ?? {
60841
+ input: 0,
60842
+ output: 0,
60843
+ cache_read: 0,
60844
+ cache_write: 0
60845
+ }, tok));
60846
+ }
60847
+ }
60848
+ const tokenUsage = { ...args.summary.token_usage ?? {} };
60849
+ for (const [model, delta] of tokenUsageDeltas) {
60850
+ tokenUsage[model] = addTokens4(tokenUsage[model] ?? { input: 0, output: 0, cache_read: 0, cache_write: 0 }, delta);
60851
+ }
60852
+ const updated = {
60853
+ ...args.summary,
60854
+ main_loop_tokens: addTokens4(args.summary.main_loop_tokens, mainLoopDelta),
60855
+ token_usage: tokenUsage,
60856
+ transcript_offset: newOffset,
60857
+ ...currentModel ? { last_codex_model: currentModel } : {}
60858
+ };
60859
+ return { summary: updated, read: true };
60860
+ } catch (e2) {
60861
+ const error = e2?.message ?? String(e2);
60862
+ hookLog("codex_transcript_apply", { error });
60863
+ return { summary: args.summary, read: false, error };
60864
+ }
60865
+ }
60866
+
60688
60867
  // src/domains/hooks/lib/jsonl-append.ts
60689
- import { promises as fs23, appendFileSync as appendFileSync2, mkdirSync as mkdirSync4 } from "node:fs";
60868
+ import { promises as fs24, appendFileSync as appendFileSync2, mkdirSync as mkdirSync4 } from "node:fs";
60690
60869
  import { dirname as dirname27 } from "node:path";
60691
60870
  async function appendJsonl(filePath, record) {
60692
60871
  try {
60693
- await fs23.mkdir(dirname27(filePath), { recursive: true });
60694
- await fs23.appendFile(filePath, `${JSON.stringify(record)}
60872
+ await fs24.mkdir(dirname27(filePath), { recursive: true });
60873
+ await fs24.appendFile(filePath, `${JSON.stringify(record)}
60695
60874
  `, "utf8");
60696
60875
  } catch {}
60697
60876
  }
@@ -60845,9 +61024,10 @@ async function runStopFlush(data, ctx) {
60845
61024
  const endedAtIso = new Date().toISOString();
60846
61025
  const startedAtIso = typeof data.session_started_at === "string" ? data.session_started_at : endedAtIso;
60847
61026
  const transcriptPath = typeof data.transcript_path === "string" ? data.transcript_path : null;
61027
+ const stdinModel = typeof data.model === "string" && data.model ? data.model : null;
60848
61028
  const manifest = readManifestVersions(cwd2);
60849
61029
  const cliVersion = readCliVersion2();
60850
- const hasTranscript = agent === "claude" && Boolean(transcriptPath);
61030
+ const hasTranscript = Boolean(transcriptPath) && (agent === "claude" || agent === "codex");
60851
61031
  const result = await recordEvent({
60852
61032
  agent,
60853
61033
  cwd: cwd2,
@@ -60877,7 +61057,11 @@ async function runStopFlush(data, ctx) {
60877
61057
  setHookDebugLog(sessionDebugLogPath(result.sessionDir));
60878
61058
  let payloadSummary = result.summary;
60879
61059
  if (hasTranscript && transcriptPath) {
60880
- const applied = await applyTranscriptDelta({
61060
+ const applied = agent === "codex" ? await applyCodexTranscriptDelta({
61061
+ summary: result.summary,
61062
+ transcriptPath,
61063
+ stdinModel
61064
+ }) : await applyClaudeTranscriptDelta({
60881
61065
  summary: result.summary,
60882
61066
  transcriptPath
60883
61067
  });
@@ -60962,15 +61146,15 @@ async function handleStop(agent, flags = {}) {
60962
61146
 
60963
61147
  // src/domains/hooks/telemetry/otlp/observations-export.ts
60964
61148
  init_paths2();
60965
- import { promises as fs27, openSync as openSync6 } from "node:fs";
61149
+ import { promises as fs28, openSync as openSync6 } from "node:fs";
60966
61150
  import { join as join99 } from "node:path";
60967
61151
 
60968
61152
  // src/domains/hooks/telemetry/lib/retention.ts
60969
- import { promises as fs24 } from "node:fs";
61153
+ import { promises as fs25 } from "node:fs";
60970
61154
  import { join as join98 } from "node:path";
60971
61155
  async function pathExists24(path10) {
60972
61156
  try {
60973
- await fs24.access(path10);
61157
+ await fs25.access(path10);
60974
61158
  return true;
60975
61159
  } catch {
60976
61160
  return false;
@@ -60982,7 +61166,7 @@ async function hasUnexportedObservations(dir) {
60982
61166
  async function decideDelete(dir, args) {
60983
61167
  let mtimeMs = 0;
60984
61168
  try {
60985
- const stat8 = await fs24.stat(dir);
61169
+ const stat8 = await fs25.stat(dir);
60986
61170
  if (!stat8.isDirectory())
60987
61171
  return false;
60988
61172
  mtimeMs = stat8.mtimeMs;
@@ -61001,8 +61185,8 @@ async function decideDelete(dir, args) {
61001
61185
  }
61002
61186
  async function listChildren(dir) {
61003
61187
  try {
61004
- const names = await fs24.readdir(dir);
61005
- return names.map((n) => join98(dir, n));
61188
+ const names = await fs25.readdir(dir);
61189
+ return names.map((n2) => join98(dir, n2));
61006
61190
  } catch {
61007
61191
  return [];
61008
61192
  }
@@ -61037,7 +61221,7 @@ async function sweepRetention(args) {
61037
61221
  continue;
61038
61222
  }
61039
61223
  try {
61040
- await fs24.rm(dir, { recursive: true, force: true });
61224
+ await fs25.rm(dir, { recursive: true, force: true });
61041
61225
  deleted.push(dir);
61042
61226
  } catch {}
61043
61227
  }
@@ -61045,10 +61229,10 @@ async function sweepRetention(args) {
61045
61229
  }
61046
61230
 
61047
61231
  // src/domains/hooks/telemetry/otlp/observations-export-state.ts
61048
- import { promises as fs25 } from "node:fs";
61232
+ import { promises as fs26 } from "node:fs";
61049
61233
  async function exists(path10) {
61050
61234
  try {
61051
- await fs25.access(path10);
61235
+ await fs26.access(path10);
61052
61236
  return true;
61053
61237
  } catch {
61054
61238
  return false;
@@ -61060,7 +61244,7 @@ async function stageObservationsForFlush(sessionDir) {
61060
61244
  return flushing;
61061
61245
  const live = getObservationsFile(sessionDir);
61062
61246
  try {
61063
- await fs25.rename(live, flushing);
61247
+ await fs26.rename(live, flushing);
61064
61248
  return flushing;
61065
61249
  } catch {
61066
61250
  return null;
@@ -61068,15 +61252,15 @@ async function stageObservationsForFlush(sessionDir) {
61068
61252
  }
61069
61253
  async function completeObservationsFlush(sessionDir, flushingPath, now) {
61070
61254
  try {
61071
- await fs25.writeFile(getObservationsPushedFile(sessionDir), String(now), "utf8");
61255
+ await fs26.writeFile(getObservationsPushedFile(sessionDir), String(now), "utf8");
61072
61256
  } catch {}
61073
61257
  try {
61074
- await fs25.rm(flushingPath, { force: true });
61258
+ await fs26.rm(flushingPath, { force: true });
61075
61259
  } catch {}
61076
61260
  }
61077
61261
  async function readObsPushed(sessionDir) {
61078
61262
  try {
61079
- const raw = await fs25.readFile(getObservationsPushedFile(sessionDir), "utf8");
61263
+ const raw = await fs26.readFile(getObservationsPushedFile(sessionDir), "utf8");
61080
61264
  const parsed = Number.parseInt(raw.trim(), 10);
61081
61265
  return Number.isFinite(parsed) ? parsed : null;
61082
61266
  } catch {
@@ -61091,7 +61275,7 @@ async function shouldFlushObservations(sessionDir, gate) {
61091
61275
  return true;
61092
61276
  let size = 0;
61093
61277
  try {
61094
- size = (await fs25.stat(getObservationsFile(sessionDir))).size;
61278
+ size = (await fs26.stat(getObservationsFile(sessionDir))).size;
61095
61279
  } catch {
61096
61280
  return false;
61097
61281
  }
@@ -61118,7 +61302,7 @@ async function resolveOtlpConfig() {
61118
61302
 
61119
61303
  // src/domains/hooks/telemetry/otlp/otlp-post.ts
61120
61304
  import { spawn as spawn3 } from "node:child_process";
61121
- import { promises as fs26, openSync as openSync5 } from "node:fs";
61305
+ import { promises as fs27, openSync as openSync5 } from "node:fs";
61122
61306
 
61123
61307
  // src/domains/hooks/telemetry/otlp/otlp-payload-builder.ts
61124
61308
  import { createHash as createHash10 } from "node:crypto";
@@ -61303,7 +61487,7 @@ async function runOtlpPost(job, deps = {}) {
61303
61487
  const now = deps.now ?? Date.now;
61304
61488
  let content;
61305
61489
  try {
61306
- content = await fs26.readFile(job.flushingPath, "utf8");
61490
+ content = await fs27.readFile(job.flushingPath, "utf8");
61307
61491
  } catch {
61308
61492
  return { ok: false, skipped: true, error: "no_flushing_file" };
61309
61493
  }
@@ -61447,7 +61631,7 @@ function lockPath() {
61447
61631
  async function acquireSweepLock(now) {
61448
61632
  const path10 = lockPath();
61449
61633
  try {
61450
- await fs27.mkdir(getConfigDir(), { recursive: true });
61634
+ await fs28.mkdir(getConfigDir(), { recursive: true });
61451
61635
  } catch {
61452
61636
  return false;
61453
61637
  }
@@ -61456,9 +61640,9 @@ async function acquireSweepLock(now) {
61456
61640
  return true;
61457
61641
  } catch {
61458
61642
  try {
61459
- const stat8 = await fs27.stat(path10);
61643
+ const stat8 = await fs28.stat(path10);
61460
61644
  if (now - stat8.mtimeMs > STALE_LOCK_MS) {
61461
- await fs27.rm(path10, { force: true });
61645
+ await fs28.rm(path10, { force: true });
61462
61646
  openSync6(path10, "wx");
61463
61647
  return true;
61464
61648
  }
@@ -61468,7 +61652,7 @@ async function acquireSweepLock(now) {
61468
61652
  }
61469
61653
  async function releaseSweepLock() {
61470
61654
  try {
61471
- await fs27.rm(lockPath(), { force: true });
61655
+ await fs28.rm(lockPath(), { force: true });
61472
61656
  } catch {}
61473
61657
  }
61474
61658
  async function flushOrphanObservations(deps = {}) {
@@ -61558,6 +61742,10 @@ function classifyTool(toolName, toolInput) {
61558
61742
  const subagent = typeof input.subagent_type === "string" ? input.subagent_type : null;
61559
61743
  return { kind: "agent", name: capName(subagent) || "unknown" };
61560
61744
  }
61745
+ if (toolName === "spawn_agent") {
61746
+ const agentType = typeof input.agent_type === "string" ? input.agent_type : null;
61747
+ return { kind: "agent", name: capName(agentType) || "unknown" };
61748
+ }
61561
61749
  if (toolName === "Skill") {
61562
61750
  const skill = typeof input.skill === "string" ? input.skill : null;
61563
61751
  return { kind: "skill", name: capName(skill) || "unknown" };
@@ -61670,7 +61858,7 @@ async function runPostToolUseCapture(data, ctx) {
61670
61858
  const before = await readSummary(sessionDir);
61671
61859
  const baseline = before?.skills_in_flight[classified.name]?.baseline;
61672
61860
  if (before && baseline) {
61673
- const applied = await applyTranscriptDelta({ summary: before, transcriptPath });
61861
+ const applied = await applyClaudeTranscriptDelta({ summary: before, transcriptPath });
61674
61862
  if (applied.read) {
61675
61863
  await writeSummary(sessionDir, applied.summary);
61676
61864
  skillTokens = diffTokens(applied.summary.main_loop_tokens, baseline);
@@ -61841,6 +62029,103 @@ async function handleSessionStart(agent, flags = {}) {
61841
62029
  await runSessionStartCapture(data, { agent, cwd: process.cwd(), flags });
61842
62030
  }
61843
62031
 
62032
+ // src/domains/hooks/telemetry/capture/subagent-stop.ts
62033
+ function zeroTokens3() {
62034
+ return { input: 0, output: 0, cache_read: 0, cache_write: 0 };
62035
+ }
62036
+ function addTokens5(a3, b3) {
62037
+ return {
62038
+ input: a3.input + b3.input,
62039
+ output: a3.output + b3.output,
62040
+ cache_read: a3.cache_read + b3.cache_read,
62041
+ cache_write: a3.cache_write + b3.cache_write
62042
+ };
62043
+ }
62044
+ function projectSubagentTokensByType(s) {
62045
+ const sums = new Map;
62046
+ for (const rec of s.subagents) {
62047
+ if (!rec.tokens)
62048
+ continue;
62049
+ sums.set(rec.type, addTokens5(sums.get(rec.type) ?? zeroTokens3(), rec.tokens));
62050
+ }
62051
+ for (const [type, tokens] of sums) {
62052
+ const entry = s.tool_stats.subagents.by_type[type] ?? {
62053
+ invocations: 0,
62054
+ user_triggered: 0,
62055
+ agent_triggered: 0
62056
+ };
62057
+ entry.tokens = tokens;
62058
+ s.tool_stats.subagents.by_type[type] = entry;
62059
+ }
62060
+ }
62061
+ function upsertCodexSubagent(s, agentId, agentType, tokens) {
62062
+ const existing = s.subagents.find((r2) => r2.id === agentId);
62063
+ if (existing) {
62064
+ if (agentType && agentType !== "unknown")
62065
+ existing.type = agentType;
62066
+ if (tokens)
62067
+ existing.tokens = tokens;
62068
+ } else {
62069
+ const rec = { id: agentId, type: agentType };
62070
+ if (tokens)
62071
+ rec.tokens = tokens;
62072
+ s.subagents.push(rec);
62073
+ }
62074
+ projectSubagentTokensByType(s);
62075
+ return s;
62076
+ }
62077
+ async function runSubagentStopCapture(data, ctx) {
62078
+ const { agent, cwd: cwd2, flags } = ctx;
62079
+ try {
62080
+ if (agent !== "codex") {
62081
+ hookLog("subagent-stop", { agent, skipped: "not_codex" });
62082
+ return;
62083
+ }
62084
+ const sessionId = typeof data.session_id === "string" ? data.session_id : null;
62085
+ if (!sessionId) {
62086
+ hookLog("subagent-stop", { agent, skipped: "no_session_id" });
62087
+ return;
62088
+ }
62089
+ const agentId = typeof data.agent_id === "string" && data.agent_id ? data.agent_id : null;
62090
+ if (!agentId) {
62091
+ hookLog("subagent-stop", { agent, session_id: sessionId, skipped: "no_agent_id" });
62092
+ return;
62093
+ }
62094
+ const agentType = typeof data.agent_type === "string" && data.agent_type ? data.agent_type : "unknown";
62095
+ const childPath = typeof data.agent_transcript_path === "string" ? data.agent_transcript_path : null;
62096
+ const transcriptPath = typeof data.transcript_path === "string" ? data.transcript_path : null;
62097
+ if (flags.debug) {
62098
+ const sessionDir = getSessionDirV2({ agent, cwd: cwd2, sessionId });
62099
+ if (sessionDir)
62100
+ setHookDebugLog(sessionDebugLogPath(sessionDir));
62101
+ }
62102
+ const tokens = childPath ? sumCodexChildTokens(childPath) : null;
62103
+ const tsIso = new Date().toISOString();
62104
+ const result = await recordEvent({
62105
+ agent,
62106
+ cwd: cwd2,
62107
+ sessionId,
62108
+ startedAt: tsIso,
62109
+ transcriptPath,
62110
+ bufferEvent: { event_type: "subagent", event_name: agentType, ts: tsIso },
62111
+ mutate: (s) => upsertCodexSubagent(s, agentId, agentType, tokens)
62112
+ });
62113
+ if (!result) {
62114
+ hookLog("subagent-stop", { agent, session_id: sessionId, skipped: "bad_session_dir" });
62115
+ return;
62116
+ }
62117
+ hookLog("subagent-stop", {
62118
+ agent,
62119
+ session_id: sessionId,
62120
+ agent_id: agentId,
62121
+ type: agentType,
62122
+ tokens: tokens ? tokens.input + tokens.output : null
62123
+ });
62124
+ } catch (e2) {
62125
+ hookLog("subagent-stop", { error: e2?.message ?? String(e2) });
62126
+ }
62127
+ }
62128
+
61844
62129
  // src/domains/hooks/telemetry/lib/trigger-detector.ts
61845
62130
  var SLASH_COMMAND_RE = /\B\/(?:[a-z][a-z0-9-]*:)?([a-z][a-z0-9-]*)/g;
61846
62131
  var SUBAGENT_MENTION_RE = /\buse the ([a-z][a-z0-9-]+) (?:agent|subagent)\b/gi;
@@ -61956,8 +62241,9 @@ var metricsRecord = {
61956
62241
  name: "metrics-record",
61957
62242
  category: "metrics",
61958
62243
  policy: "record",
61959
- events: ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse"],
62244
+ events: ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "SubagentStop"],
61960
62245
  matchers: { SessionStart: "startup|resume|clear|compact" },
62246
+ codexOnlyEvents: ["SubagentStop"],
61961
62247
  async run(input, ctx) {
61962
62248
  const cc = metricsCaptureContext(ctx);
61963
62249
  switch (ctx.event) {
@@ -61973,6 +62259,9 @@ var metricsRecord = {
61973
62259
  case "PostToolUse":
61974
62260
  await runPostToolUseCapture(input, cc);
61975
62261
  return METRICS_RECORD_RESULT;
62262
+ case "SubagentStop":
62263
+ await runSubagentStopCapture(input, cc);
62264
+ return METRICS_RECORD_RESULT;
61976
62265
  default:
61977
62266
  return { status: "no-op", timingMs: 0 };
61978
62267
  }
@@ -61984,7 +62273,7 @@ import { mkdirSync as mkdirSync5 } from "node:fs";
61984
62273
  import { dirname as dirname28, join as join103 } from "node:path";
61985
62274
 
61986
62275
  // src/domains/hooks/handlers/_shared/project-detector.ts
61987
- import { existsSync as existsSync46, readFileSync as readFileSync15 } from "node:fs";
62276
+ import { existsSync as existsSync47, readFileSync as readFileSync15 } from "node:fs";
61988
62277
  import { join as join100 } from "node:path";
61989
62278
  var LOCKFILE_PRIORITY = [
61990
62279
  { manager: "bun", files: ["bun.lockb", "bun.lock"] },
@@ -62020,7 +62309,7 @@ var APP_FRAMEWORKS = new Set([
62020
62309
  var WORKSPACE_MARKER_FILES = ["pnpm-workspace.yaml", "turbo.json", "lerna.json"];
62021
62310
  function fileExists(cwd2, name) {
62022
62311
  try {
62023
- return existsSync46(join100(cwd2, name));
62312
+ return existsSync47(join100(cwd2, name));
62024
62313
  } catch {
62025
62314
  return false;
62026
62315
  }
@@ -62114,13 +62403,13 @@ import { platform as platform8, userInfo } from "node:os";
62114
62403
  import { join as join102 } from "node:path";
62115
62404
 
62116
62405
  // src/domains/hooks/handlers/session-init/plan-resolver.ts
62117
- import { existsSync as existsSync47, readFileSync as readFileSync16, readdirSync as readdirSync7 } from "node:fs";
62406
+ import { existsSync as existsSync48, readFileSync as readFileSync16, readdirSync as readdirSync7 } from "node:fs";
62118
62407
  import { join as join101 } from "node:path";
62119
62408
  var MAX_PLAN_DIRS = 100;
62120
62409
  var MAX_PLAN_FILE_BYTES = 64 * 1024;
62121
62410
  function listPlanDirs(plansPath) {
62122
62411
  try {
62123
- if (!existsSync47(plansPath))
62412
+ if (!existsSync48(plansPath))
62124
62413
  return [];
62125
62414
  return readdirSync7(plansPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().slice(0, MAX_PLAN_DIRS);
62126
62415
  } catch {
@@ -62130,7 +62419,7 @@ function listPlanDirs(plansPath) {
62130
62419
  function planFileMentionsSession(planDir, sessionId) {
62131
62420
  try {
62132
62421
  const planFile = join101(planDir, "plan.md");
62133
- if (!existsSync47(planFile))
62422
+ if (!existsSync48(planFile))
62134
62423
  return false;
62135
62424
  const body = readFileSync16(planFile, { encoding: "utf8" });
62136
62425
  if (body.length > MAX_PLAN_FILE_BYTES)
@@ -62359,7 +62648,7 @@ var sessionInit = {
62359
62648
  // src/domains/hooks/handlers/_shared/context-assembler.ts
62360
62649
  import { execFileSync as execFileSync3 } from "node:child_process";
62361
62650
  import { createHash as createHash12 } from "node:crypto";
62362
- import { existsSync as existsSync48, mkdirSync as mkdirSync6, readFileSync as readFileSync17, rmSync as rmSync3, statSync as statSync6, writeFileSync as writeFileSync9 } from "node:fs";
62651
+ import { existsSync as existsSync49, mkdirSync as mkdirSync6, readFileSync as readFileSync17, rmSync as rmSync3, statSync as statSync6, writeFileSync as writeFileSync9 } from "node:fs";
62363
62652
  import { homedir as homedir27, platform as platform9, tmpdir as tmpdir4 } from "node:os";
62364
62653
  import { basename as basename18, join as join104, resolve as resolve21 } from "node:path";
62365
62654
  var INJECTED_TTL_MS = 12 * 60 * 60 * 1000;
@@ -62447,7 +62736,7 @@ function stateFile(sessionId, scope, transcriptPath) {
62447
62736
  }
62448
62737
  function readState(file) {
62449
62738
  try {
62450
- if (!existsSync48(file))
62739
+ if (!existsSync49(file))
62451
62740
  return null;
62452
62741
  return JSON.parse(readFileSync17(file, "utf8"));
62453
62742
  } catch {
@@ -62514,7 +62803,7 @@ function clearPending(sessionId, scope, transcriptPath) {
62514
62803
  function resolveSkillsVenv(_cwd) {
62515
62804
  const base = join104(homedir27(), ".claude", "skills", ".venv");
62516
62805
  const interpreter = platform9() === "win32" ? join104(base, "Scripts", "python.exe") : join104(base, "bin", "python3");
62517
- return existsSync48(interpreter) ? interpreter : null;
62806
+ return existsSync49(interpreter) ? interpreter : null;
62518
62807
  }
62519
62808
 
62520
62809
  // src/domains/hooks/handlers/session-prompt-context/handler.ts
@@ -62581,7 +62870,7 @@ function gitFacts(dir) {
62581
62870
  };
62582
62871
  }
62583
62872
  function stamp(fmt, now) {
62584
- const p = (n) => String(n).padStart(2, "0");
62873
+ const p = (n2) => String(n2).padStart(2, "0");
62585
62874
  return fmt.replace(/YYYY/g, String(now.getFullYear())).replace(/YY/g, p(now.getFullYear() % 100)).replace(/MM/g, p(now.getMonth() + 1)).replace(/DD/g, p(now.getDate())).replace(/HH/g, p(now.getHours())).replace(/mm/g, p(now.getMinutes())).replace(/ss/g, p(now.getSeconds()));
62586
62875
  }
62587
62876
  function planDirTemplate(format, dateStr) {
@@ -63271,7 +63560,7 @@ init_hooks_settings_merger();
63271
63560
 
63272
63561
  // src/commands/portable/settings-write-with-confirm.ts
63273
63562
  init_safe_prompts();
63274
- import { existsSync as existsSync49, mkdirSync as mkdirSync7, readFileSync as readFileSync18, renameSync as renameSync3, rmSync as rmSync4, writeFileSync as writeFileSync10 } from "node:fs";
63563
+ import { existsSync as existsSync50, mkdirSync as mkdirSync7, readFileSync as readFileSync18, renameSync as renameSync3, rmSync as rmSync4, writeFileSync as writeFileSync10 } from "node:fs";
63275
63564
  import { dirname as dirname29 } from "node:path";
63276
63565
 
63277
63566
  // node_modules/diff/libesm/diff/base.js
@@ -64444,7 +64733,7 @@ var EMPTY_RESULT = (status2) => ({
64444
64733
  backupPath: null
64445
64734
  });
64446
64735
  function readCurrent(path10) {
64447
- if (!existsSync49(path10))
64736
+ if (!existsSync50(path10))
64448
64737
  return { kind: "missing" };
64449
64738
  let raw = "";
64450
64739
  try {
@@ -64561,7 +64850,7 @@ init_dist2();
64561
64850
  // src/commands/hooks/lib/agent-target-picker.ts
64562
64851
  init_safe_prompts();
64563
64852
  init_dist2();
64564
- import { existsSync as existsSync50 } from "node:fs";
64853
+ import { existsSync as existsSync51 } from "node:fs";
64565
64854
 
64566
64855
  // src/commands/hooks/lib/settings-path-resolver.ts
64567
64856
  import { lstatSync as lstatSync3, realpathSync as realpathSync3 } from "node:fs";
@@ -64600,7 +64889,7 @@ function probe(global3) {
64600
64889
  return {
64601
64890
  agent,
64602
64891
  path: location2.realPath,
64603
- exists: existsSync50(location2.realPath)
64892
+ exists: existsSync51(location2.realPath)
64604
64893
  };
64605
64894
  });
64606
64895
  }
@@ -64687,6 +64976,8 @@ function buildHookExecCommand(handler, event, agent, bin = DEFAULT_HOOK_BIN, fla
64687
64976
  function planEntry(handler, event, agent, bin, flags) {
64688
64977
  if (agent === "codex" && !codexSupportsEvent(event))
64689
64978
  return null;
64979
+ if (agent !== "codex" && handler.codexOnlyEvents?.includes(event))
64980
+ return null;
64690
64981
  const command = buildHookExecCommand(handler, event, agent, bin, flags);
64691
64982
  if (!command)
64692
64983
  return null;
@@ -64721,7 +65012,7 @@ function buildHookSection(agent, bin, flags = {}, handlers3 = HOOK_HANDLERS) {
64721
65012
 
64722
65013
  // src/commands/hooks/uninstall-handler.ts
64723
65014
  init_logger();
64724
- import { existsSync as existsSync51, mkdirSync as mkdirSync8, readFileSync as readFileSync19, renameSync as renameSync4, rmSync as rmSync5, writeFileSync as writeFileSync11 } from "node:fs";
65015
+ import { existsSync as existsSync52, mkdirSync as mkdirSync8, readFileSync as readFileSync19, renameSync as renameSync4, rmSync as rmSync5, writeFileSync as writeFileSync11 } from "node:fs";
64725
65016
  import { dirname as dirname30 } from "node:path";
64726
65017
  var AGENT_DISPLAY2 = {
64727
65018
  claude: "Claude Code",
@@ -64781,7 +65072,7 @@ async function uninstallForAgent(agent, options2) {
64781
65072
  removed: 0,
64782
65073
  dryRun: Boolean(options2.dryRun)
64783
65074
  };
64784
- if (!existsSync51(location2.realPath)) {
65075
+ if (!existsSync52(location2.realPath)) {
64785
65076
  return result;
64786
65077
  }
64787
65078
  let parsed;
@@ -65000,7 +65291,7 @@ async function installHook(options2) {
65000
65291
  // src/commands/hooks/status.ts
65001
65292
  init_takumi_config_manager();
65002
65293
  init_logger();
65003
- import { existsSync as existsSync52, readFileSync as readFileSync20 } from "node:fs";
65294
+ import { existsSync as existsSync53, readFileSync as readFileSync20 } from "node:fs";
65004
65295
  var AGENT_DISPLAY4 = { claude: "Claude Code", codex: "Codex" };
65005
65296
  var NEW_SHAPE = /\bhook-exec\b.*--hook\s+(guard|session|convention|extension|metrics|perf)\.(\S+).*-a\s+(claude|codex)(?![\w-])/;
65006
65297
  var LEGACY_SHAPE = /\bhooks\s+(?:session-start|user-prompt-submit|pre-tool-use|post-tool-use|stop|session-end)\s+-a\s+(claude|codex)(?![\w-])/;
@@ -65030,7 +65321,7 @@ async function statusForAgent(agent, options2, cwd2 = process.cwd()) {
65030
65321
  const result = {
65031
65322
  agent,
65032
65323
  settingsPath: location2.realPath,
65033
- exists: existsSync52(location2.realPath),
65324
+ exists: existsSync53(location2.realPath),
65034
65325
  shape: "none",
65035
65326
  byCategory: {},
65036
65327
  newEntryCount: 0,
@@ -65068,7 +65359,7 @@ function report(result) {
65068
65359
  logger.info(`[hooks] ${label}: no settings file at ${result.settingsPath}`);
65069
65360
  return;
65070
65361
  }
65071
- const categories = Object.entries(result.byCategory).sort(([a3], [b3]) => a3.localeCompare(b3)).map(([cat, n]) => `${cat}=${n}`).join(", ");
65362
+ const categories = Object.entries(result.byCategory).sort(([a3], [b3]) => a3.localeCompare(b3)).map(([cat, n2]) => `${cat}=${n2}`).join(", ");
65072
65363
  const parts = [`shape=${result.shape}`, `${result.newEntryCount} hook-exec entries`];
65073
65364
  if (result.legacyEntryCount > 0)
65074
65365
  parts.push(`${result.legacyEntryCount} legacy entries`);
@@ -66402,7 +66693,7 @@ async function dispatchInstallers(ctx, targetAgents2, lifecycle) {
66402
66693
  init_logger();
66403
66694
  // src/domains/installation/download-extractor.ts
66404
66695
  init_auth_client();
66405
- import * as fs29 from "node:fs";
66696
+ import * as fs30 from "node:fs";
66406
66697
  import * as path10 from "node:path";
66407
66698
 
66408
66699
  // src/domains/github/auth-prompt.ts
@@ -67233,18 +67524,18 @@ var D = class extends Ti {
67233
67524
  if (t === "close") {
67234
67525
  if (this[Ne] = true, !this[rt] && !this[w3])
67235
67526
  return false;
67236
- let n = super.emit("close");
67237
- return this.removeAllListeners("close"), n;
67527
+ let n2 = super.emit("close");
67528
+ return this.removeAllListeners("close"), n2;
67238
67529
  } else if (t === "error") {
67239
67530
  this[jt] = i, super.emit(Ri, i);
67240
- let n = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : false;
67241
- return this[j2](), n;
67531
+ let n2 = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : false;
67532
+ return this[j2](), n2;
67242
67533
  } else if (t === "resume") {
67243
- let n = super.emit("resume");
67244
- return this[j2](), n;
67534
+ let n2 = super.emit("resume");
67535
+ return this[j2](), n2;
67245
67536
  } else if (t === "finish" || t === "prefinish") {
67246
- let n = super.emit(t);
67247
- return this.removeAllListeners(t), n;
67537
+ let n2 = super.emit(t);
67538
+ return this.removeAllListeners(t), n2;
67248
67539
  }
67249
67540
  let r2 = super.emit(t, ...e2);
67250
67541
  return this[j2](), r2;
@@ -67302,15 +67593,15 @@ var D = class extends Ti {
67302
67593
  return Promise.resolve({ done: false, value: r2 });
67303
67594
  if (this[q3])
67304
67595
  return e2();
67305
- let n, o2, h2 = (d3) => {
67596
+ let n2, o2, h2 = (d3) => {
67306
67597
  this.off("data", a3), this.off("end", l2), this.off(w3, c2), e2(), o2(d3);
67307
67598
  }, a3 = (d3) => {
67308
- this.off("error", h2), this.off("end", l2), this.off(w3, c2), this.pause(), n({ value: d3, done: !!this[q3] });
67599
+ this.off("error", h2), this.off("end", l2), this.off(w3, c2), this.pause(), n2({ value: d3, done: !!this[q3] });
67309
67600
  }, l2 = () => {
67310
- this.off("error", h2), this.off("data", a3), this.off(w3, c2), e2(), n({ done: true, value: undefined });
67601
+ this.off("error", h2), this.off("data", a3), this.off(w3, c2), e2(), n2({ done: true, value: undefined });
67311
67602
  }, c2 = () => h2(new Error("stream destroyed"));
67312
67603
  return new Promise((d3, S3) => {
67313
- o2 = S3, n = d3, this.once(w3, c2), this.once("error", h2), this.once("end", l2), this.once("data", a3);
67604
+ o2 = S3, n2 = d3, this.once(w3, c2), this.once("error", h2), this.once("end", l2), this.once("data", a3);
67314
67605
  });
67315
67606
  }, throw: e2, return: e2, [Symbol.asyncIterator]() {
67316
67607
  return this;
@@ -67601,9 +67892,9 @@ var re2 = (s = {}) => {
67601
67892
  }
67602
67893
  return t.chmod === undefined && t.noChmod === false && (t.chmod = true), delete t.noChmod, t;
67603
67894
  };
67604
- var K3 = (s, t, e2, i, r2) => Object.assign((n = [], o2, h2) => {
67605
- Array.isArray(n) && (o2 = n, n = {}), typeof o2 == "function" && (h2 = o2, o2 = undefined), o2 = o2 ? Array.from(o2) : [];
67606
- let a3 = re2(n);
67895
+ var K3 = (s, t, e2, i, r2) => Object.assign((n2 = [], o2, h2) => {
67896
+ Array.isArray(n2) && (o2 = n2, n2 = {}), typeof o2 == "function" && (h2 = o2, o2 = undefined), o2 = o2 ? Array.from(o2) : [];
67897
+ let a3 = re2(n2);
67607
67898
  if (r2?.(a3, o2), As(a3)) {
67608
67899
  if (typeof h2 == "function")
67609
67900
  throw new TypeError("callback not supported for sync tar functions");
@@ -67696,7 +67987,7 @@ var ne2 = class extends D {
67696
67987
  if (typeof e2 == "function" && (i = e2, e2 = "utf8"), typeof t == "string" && (t = gt.from(t, e2)), this.#t)
67697
67988
  return;
67698
67989
  Mi(this.#e, "zlib binding closed");
67699
- let r2 = this.#e._handle, n = r2.close;
67990
+ let r2 = this.#e._handle, n2 = r2.close;
67700
67991
  r2.close = () => {};
67701
67992
  let o2 = this.#e.close;
67702
67993
  this.#e.close = () => {}, ki(true);
@@ -67707,7 +67998,7 @@ var ne2 = class extends D {
67707
67998
  } catch (l2) {
67708
67999
  ki(false), this.#o(new Gt(l2, this.write));
67709
68000
  } finally {
67710
- this.#e && (this.#e._handle = r2, r2.close = n, this.#e.close = o2, this.#e.removeAllListeners("error"));
68001
+ this.#e && (this.#e._handle = r2, r2.close = n2, this.#e.close = o2, this.#e.removeAllListeners("error"));
67711
68002
  }
67712
68003
  this.#e && this.#e.on("error", (l2) => this.#o(new Gt(l2, this.write)));
67713
68004
  let a3;
@@ -67737,8 +68028,8 @@ var Be = class extends ne2 {
67737
68028
  if (this.#t !== t || this.#i !== e2) {
67738
68029
  this.flush(M3.Z_SYNC_FLUSH), Mi(this.handle, "zlib binding closed");
67739
68030
  let i = this.handle.flush;
67740
- this.handle.flush = (r2, n) => {
67741
- typeof r2 == "function" && (n = r2, r2 = this.flushFlag), this.flush(r2), n?.();
68031
+ this.handle.flush = (r2, n2) => {
68032
+ typeof r2 == "function" && (n2 = r2, r2 = this.flushFlag), this.flush(r2), n2?.();
67742
68033
  };
67743
68034
  try {
67744
68035
  this.handle.params(t, e2);
@@ -67825,8 +68116,8 @@ var Bs = (s) => {
67825
68116
  };
67826
68117
  var rn = (s) => {
67827
68118
  for (var t = s.length, e2 = 0, i = false, r2 = t - 1;r2 > -1; r2--) {
67828
- var n = Number(s[r2]), o2;
67829
- i ? o2 = Ps(n) : n === 0 ? o2 = n : (i = true, o2 = zs(n)), o2 !== 0 && (e2 -= o2 * Math.pow(256, t - r2 - 1));
68119
+ var n2 = Number(s[r2]), o2;
68120
+ i ? o2 = Ps(n2) : n2 === 0 ? o2 = n2 : (i = true, o2 = zs(n2)), o2 !== 0 && (e2 -= o2 * Math.pow(256, t - r2 - 1));
67830
68121
  }
67831
68122
  return e2;
67832
68123
  };
@@ -67874,8 +68165,8 @@ var F = class {
67874
68165
  if (e2 || (e2 = 0), !t || !(t.length >= e2 + 512))
67875
68166
  throw new Error("need 512 bytes for header");
67876
68167
  this.path = i?.path ?? Tt(t, e2, 100), this.mode = i?.mode ?? r2?.mode ?? at(t, e2 + 100, 8), this.uid = i?.uid ?? r2?.uid ?? at(t, e2 + 108, 8), this.gid = i?.gid ?? r2?.gid ?? at(t, e2 + 116, 8), this.size = i?.size ?? r2?.size ?? at(t, e2 + 124, 12), this.mtime = i?.mtime ?? r2?.mtime ?? Pi(t, e2 + 136, 12), this.cksum = at(t, e2 + 148, 12), r2 && this.#i(r2, true), i && this.#i(i);
67877
- let n = Tt(t, e2 + 156, 1);
67878
- if (oe2(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = Tt(t, e2 + 157, 100), t.subarray(e2 + 257, e2 + 265).toString() === "ustar\x0000")
68168
+ let n2 = Tt(t, e2 + 156, 1);
68169
+ if (oe2(n2) && (this.#t = n2 || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = Tt(t, e2 + 157, 100), t.subarray(e2 + 257, e2 + 265).toString() === "ustar\x0000")
67879
68170
  if (this.uname = i?.uname ?? r2?.uname ?? Tt(t, e2 + 265, 32), this.gname = i?.gname ?? r2?.gname ?? Tt(t, e2 + 297, 32), this.devmaj = i?.devmaj ?? r2?.devmaj ?? at(t, e2 + 329, 8) ?? 0, this.devmin = i?.devmin ?? r2?.devmin ?? at(t, e2 + 337, 8) ?? 0, t[e2 + 475] !== 0) {
67880
68171
  let h2 = Tt(t, e2 + 345, 155);
67881
68172
  this.path = h2 + "/" + this.path;
@@ -67896,8 +68187,8 @@ var F = class {
67896
68187
  encode(t, e2 = 0) {
67897
68188
  if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e2 + 512))
67898
68189
  throw new Error("need 512 bytes for header");
67899
- let i = this.ctime || this.atime ? 130 : 155, r2 = an(this.path || "", i), n = r2[0], o2 = r2[1];
67900
- this.needPax = !!r2[2], this.needPax = xt(t, e2, 100, n) || this.needPax, this.needPax = lt(t, e2 + 100, 8, this.mode) || this.needPax, this.needPax = lt(t, e2 + 108, 8, this.uid) || this.needPax, this.needPax = lt(t, e2 + 116, 8, this.gid) || this.needPax, this.needPax = lt(t, e2 + 124, 12, this.size) || this.needPax, this.needPax = zi(t, e2 + 136, 12, this.mtime) || this.needPax, t[e2 + 156] = Number(this.#t.codePointAt(0)), this.needPax = xt(t, e2 + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e2 + 257, 8), this.needPax = xt(t, e2 + 265, 32, this.uname) || this.needPax, this.needPax = xt(t, e2 + 297, 32, this.gname) || this.needPax, this.needPax = lt(t, e2 + 329, 8, this.devmaj) || this.needPax, this.needPax = lt(t, e2 + 337, 8, this.devmin) || this.needPax, this.needPax = xt(t, e2 + 345, i, o2) || this.needPax, t[e2 + 475] !== 0 ? this.needPax = xt(t, e2 + 345, 155, o2) || this.needPax : (this.needPax = xt(t, e2 + 345, 130, o2) || this.needPax, this.needPax = zi(t, e2 + 476, 12, this.atime) || this.needPax, this.needPax = zi(t, e2 + 488, 12, this.ctime) || this.needPax);
68190
+ let i = this.ctime || this.atime ? 130 : 155, r2 = an(this.path || "", i), n2 = r2[0], o2 = r2[1];
68191
+ this.needPax = !!r2[2], this.needPax = xt(t, e2, 100, n2) || this.needPax, this.needPax = lt(t, e2 + 100, 8, this.mode) || this.needPax, this.needPax = lt(t, e2 + 108, 8, this.uid) || this.needPax, this.needPax = lt(t, e2 + 116, 8, this.gid) || this.needPax, this.needPax = lt(t, e2 + 124, 12, this.size) || this.needPax, this.needPax = zi(t, e2 + 136, 12, this.mtime) || this.needPax, t[e2 + 156] = Number(this.#t.codePointAt(0)), this.needPax = xt(t, e2 + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e2 + 257, 8), this.needPax = xt(t, e2 + 265, 32, this.uname) || this.needPax, this.needPax = xt(t, e2 + 297, 32, this.gname) || this.needPax, this.needPax = lt(t, e2 + 329, 8, this.devmaj) || this.needPax, this.needPax = lt(t, e2 + 337, 8, this.devmin) || this.needPax, this.needPax = xt(t, e2 + 345, i, o2) || this.needPax, t[e2 + 475] !== 0 ? this.needPax = xt(t, e2 + 345, 155, o2) || this.needPax : (this.needPax = xt(t, e2 + 345, 130, o2) || this.needPax, this.needPax = zi(t, e2 + 476, 12, this.atime) || this.needPax, this.needPax = zi(t, e2 + 488, 12, this.ctime) || this.needPax);
67901
68192
  let h2 = 256;
67902
68193
  for (let a3 = e2;a3 < e2 + 148; a3++)
67903
68194
  h2 += t[a3];
@@ -67922,17 +68213,17 @@ var F = class {
67922
68213
  }
67923
68214
  };
67924
68215
  var an = (s, t) => {
67925
- let i = s, r2 = "", n, o2 = Zt.parse(s).root || ".";
68216
+ let i = s, r2 = "", n2, o2 = Zt.parse(s).root || ".";
67926
68217
  if (Buffer.byteLength(i) < 100)
67927
- n = [i, r2, false];
68218
+ n2 = [i, r2, false];
67928
68219
  else {
67929
68220
  r2 = Zt.dirname(i), i = Zt.basename(i);
67930
68221
  do
67931
- Buffer.byteLength(i) <= 100 && Buffer.byteLength(r2) <= t ? n = [i, r2, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r2) <= t ? n = [i.slice(0, 99), r2, true] : (i = Zt.join(Zt.basename(r2), i), r2 = Zt.dirname(r2));
67932
- while (r2 !== o2 && n === undefined);
67933
- n || (n = [s.slice(0, 99), "", true]);
68222
+ Buffer.byteLength(i) <= 100 && Buffer.byteLength(r2) <= t ? n2 = [i, r2, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r2) <= t ? n2 = [i.slice(0, 99), r2, true] : (i = Zt.join(Zt.basename(r2), i), r2 = Zt.dirname(r2));
68223
+ while (r2 !== o2 && n2 === undefined);
68224
+ n2 || (n2 = [s.slice(0, 99), "", true]);
67934
68225
  }
67935
- return n;
68226
+ return n2;
67936
68227
  };
67937
68228
  var Tt = (s, t, e2) => s.subarray(t, t + e2).toString("utf8").replace(/\0.*/, "");
67938
68229
  var Pi = (s, t, e2) => ln(at(s, t, e2));
@@ -67974,11 +68265,11 @@ var ct = class s {
67974
68265
  if (t === "")
67975
68266
  return Buffer.allocUnsafe(0);
67976
68267
  let e2 = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e2 / 512), r2 = Buffer.allocUnsafe(i);
67977
- for (let n = 0;n < 512; n++)
67978
- r2[n] = 0;
68268
+ for (let n2 = 0;n2 < 512; n2++)
68269
+ r2[n2] = 0;
67979
68270
  new F({ path: ("PaxHeader/" + wn(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e2, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r2), r2.write(t, 512, e2, "utf8");
67980
- for (let n = e2 + 512;n < r2.length; n++)
67981
- r2[n] = 0;
68271
+ for (let n2 = e2 + 512;n2 < r2.length; n2++)
68272
+ r2[n2] = 0;
67982
68273
  return r2;
67983
68274
  }
67984
68275
  encodeBody() {
@@ -67988,8 +68279,8 @@ var ct = class s {
67988
68279
  if (this[t] === undefined)
67989
68280
  return "";
67990
68281
  let e2 = this[t], i = e2 instanceof Date ? e2.getTime() / 1000 : e2, r2 = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
67991
- `, n = Buffer.byteLength(r2), o2 = Math.floor(Math.log(n) / Math.log(10)) + 1;
67992
- return n + o2 >= Math.pow(10, o2) && (o2 += 1), o2 + n + r2;
68282
+ `, n2 = Buffer.byteLength(r2), o2 = Math.floor(Math.log(n2) / Math.log(10)) + 1;
68283
+ return n2 + o2 >= Math.pow(10, o2) && (o2 += 1), o2 + n2 + r2;
67993
68284
  }
67994
68285
  static parse(t, e2, i = false) {
67995
68286
  return new s(Sn(yn(t), e2), i);
@@ -68006,8 +68297,8 @@ var Rn = (s2, t) => {
68006
68297
  let i = t.split("="), r2 = i.shift();
68007
68298
  if (!r2)
68008
68299
  return s2;
68009
- let n = r2.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o2 = i.join("=");
68010
- return s2[n] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n) ? new Date(Number(o2) * 1000) : /^[0-9]+$/.test(o2) ? +o2 : o2, s2;
68300
+ let n2 = r2.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o2 = i.join("=");
68301
+ return s2[n2] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n2) ? new Date(Number(o2) * 1000) : /^[0-9]+$/.test(o2) ? +o2 : o2, s2;
68011
68302
  };
68012
68303
  var bn = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
68013
68304
  var f3 = bn !== "win32" ? (s2) => s2 : (s2) => s2 && s2.replaceAll(/\\/g, "/");
@@ -68176,16 +68467,16 @@ var st = class extends _n {
68176
68467
  else if (!/^(Symbolic)?Link$/.test(r2) && !/^(Global)?ExtendedHeader$/.test(r2) && i.linkpath)
68177
68468
  this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
68178
68469
  else {
68179
- let n = this[Nt] = new Yt(i, this[V2], this[ae2]);
68470
+ let n2 = this[Nt] = new Yt(i, this[V2], this[ae2]);
68180
68471
  if (!this[Dt])
68181
- if (n.remain) {
68472
+ if (n2.remain) {
68182
68473
  let o2 = () => {
68183
- n.invalid || (this[Dt] = true);
68474
+ n2.invalid || (this[Dt] = true);
68184
68475
  };
68185
- n.on("end", o2);
68476
+ n2.on("end", o2);
68186
68477
  } else
68187
68478
  this[Dt] = true;
68188
- n.meta ? n.size > this.maxMetaEntrySize ? (n.ignore = true, this[At]("ignoredEntry", n), this[B2] = "ignore", n.resume()) : n.size > 0 && (this[ft] = "", n.on("data", (o2) => this[ft] += o2), this[B2] = "meta") : (this[V2] = undefined, n.ignore = n.ignore || !this.filter(n.path, n), n.ignore ? (this[At]("ignoredEntry", n), this[B2] = n.remain ? "ignore" : "header", n.resume()) : (n.remain ? this[B2] = "body" : (this[B2] = "header", n.end()), this[et] ? this[it].push(n) : (this[it].push(n), this[Ui]())));
68479
+ n2.meta ? n2.size > this.maxMetaEntrySize ? (n2.ignore = true, this[At]("ignoredEntry", n2), this[B2] = "ignore", n2.resume()) : n2.size > 0 && (this[ft] = "", n2.on("data", (o2) => this[ft] += o2), this[B2] = "meta") : (this[V2] = undefined, n2.ignore = n2.ignore || !this.filter(n2.path, n2), n2.ignore ? (this[At]("ignoredEntry", n2), this[B2] = n2.remain ? "ignore" : "header", n2.resume()) : (n2.remain ? this[B2] = "body" : (this[B2] = "header", n2.end()), this[et] ? this[it].push(n2) : (this[it].push(n2), this[Ui]())));
68189
68480
  }
68190
68481
  }
68191
68482
  }
@@ -68216,8 +68507,8 @@ var st = class extends _n {
68216
68507
  let i = this[Nt];
68217
68508
  if (!i)
68218
68509
  throw new Error("attempt to consume body without entry??");
68219
- let r2 = i.blockRemain ?? 0, n = r2 >= t.length && e2 === 0 ? t : t.subarray(e2, e2 + r2);
68220
- return i.write(n), i.blockRemain || (this[B2] = "header", this[Nt] = undefined, i.end()), n.length;
68510
+ let r2 = i.blockRemain ?? 0, n2 = r2 >= t.length && e2 === 0 ? t : t.subarray(e2, e2 + r2);
68511
+ return i.write(n2), i.blockRemain || (this[B2] = "header", this[Nt] = undefined, i.end()), n2.length;
68221
68512
  }
68222
68513
  [Ws](t, e2) {
68223
68514
  let i = this[Nt], r2 = this[Wi](t, e2);
@@ -68293,8 +68584,8 @@ var st = class extends _n {
68293
68584
  }
68294
68585
  }
68295
68586
  this[Kt] = true, this[y3] ? this[y3].write(t) : this[Ve](t), this[Kt] = false;
68296
- let n = this[it].length > 0 ? false : this[et] ? this[et].flowing : true;
68297
- return !n && this[it].length === 0 && this[et]?.once("drain", () => this.emit("drain")), i?.(), n;
68587
+ let n2 = this[it].length > 0 ? false : this[et] ? this[et].flowing : true;
68588
+ return !n2 && this[it].length === 0 && this[et]?.once("drain", () => this.emit("drain")), i?.(), n2;
68298
68589
  }
68299
68590
  [Gi](t) {
68300
68591
  t && !this[ut] && (this[p] = this[p] ? Buffer.concat([this[p], t]) : t);
@@ -68367,30 +68658,30 @@ var Nn = (s2) => {
68367
68658
  } : (e2) => e2.resume();
68368
68659
  };
68369
68660
  var Ki = (s2, t) => {
68370
- let e2 = new Map(t.map((n) => [mt(n), true])), i = s2.filter, r2 = (n, o2 = "") => {
68371
- let h2 = o2 || Ln(n).root || ".", a3;
68372
- if (n === h2)
68661
+ let e2 = new Map(t.map((n2) => [mt(n2), true])), i = s2.filter, r2 = (n2, o2 = "") => {
68662
+ let h2 = o2 || Ln(n2).root || ".", a3;
68663
+ if (n2 === h2)
68373
68664
  a3 = false;
68374
68665
  else {
68375
- let l2 = e2.get(n);
68376
- a3 = l2 !== undefined ? l2 : r2(xn(n), h2);
68666
+ let l2 = e2.get(n2);
68667
+ a3 = l2 !== undefined ? l2 : r2(xn(n2), h2);
68377
68668
  }
68378
- return e2.set(n, a3), a3;
68669
+ return e2.set(n2, a3), a3;
68379
68670
  };
68380
- s2.filter = i ? (n, o2) => i(n, o2) && r2(mt(n)) : (n) => r2(mt(n));
68671
+ s2.filter = i ? (n2, o2) => i(n2, o2) && r2(mt(n2)) : (n2) => r2(mt(n2));
68381
68672
  };
68382
68673
  var An = (s2) => {
68383
68674
  let t = new st(s2), e2 = s2.file, i;
68384
68675
  try {
68385
68676
  i = Vt.openSync(e2, "r");
68386
- let r2 = Vt.fstatSync(i), n = s2.maxReadSize || 16 * 1024 * 1024;
68387
- if (r2.size < n) {
68677
+ let r2 = Vt.fstatSync(i), n2 = s2.maxReadSize || 16 * 1024 * 1024;
68678
+ if (r2.size < n2) {
68388
68679
  let o2 = Buffer.allocUnsafe(r2.size), h2 = Vt.readSync(i, o2, 0, r2.size, 0);
68389
68680
  t.end(h2 === o2.byteLength ? o2 : o2.subarray(0, h2));
68390
68681
  } else {
68391
- let o2 = 0, h2 = Buffer.allocUnsafe(n);
68682
+ let o2 = 0, h2 = Buffer.allocUnsafe(n2);
68392
68683
  for (;o2 < r2.size; ) {
68393
- let a3 = Vt.readSync(i, h2, 0, n, o2);
68684
+ let a3 = Vt.readSync(i, h2, 0, n2, o2);
68394
68685
  if (a3 === 0)
68395
68686
  break;
68396
68687
  o2 += a3, t.write(h2.subarray(0, a3));
@@ -68496,8 +68787,8 @@ var de2 = class extends D {
68496
68787
  o2 && typeof h2 == "string" && (this.path = h2, r2 = o2);
68497
68788
  }
68498
68789
  this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Ks(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f3(i.absolute || $s.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r2 && this.warn("TAR_ENTRY_INFO", `stripping ${r2} from absolute path`, { entry: this, path: r2 + this.path });
68499
- let n = this.statCache.get(this.absolute);
68500
- n ? this[ei](n) : this[Qi]();
68790
+ let n2 = this.statCache.get(this.absolute);
68791
+ n2 ? this[ei](n2) : this[Qi]();
68501
68792
  }
68502
68793
  warn(t, e2, i = {}) {
68503
68794
  return Lt(this, t, e2, i);
@@ -68592,10 +68883,10 @@ var de2 = class extends D {
68592
68883
  this.buf = Buffer.allocUnsafe(e2), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ti]();
68593
68884
  }
68594
68885
  [ti]() {
68595
- let { fd: t, buf: e2, offset: i, length: r2, pos: n } = this;
68886
+ let { fd: t, buf: e2, offset: i, length: r2, pos: n2 } = this;
68596
68887
  if (t === undefined || e2 === undefined)
68597
68888
  throw new Error("cannot read file without first opening");
68598
- $2.read(t, e2, i, r2, n, (o2, h2) => {
68889
+ $2.read(t, e2, i, r2, n2, (o2, h2) => {
68599
68890
  if (o2)
68600
68891
  return this[pt](() => this.emit("error", o2));
68601
68892
  this[Ji](h2);
@@ -68653,10 +68944,10 @@ var si = class extends de2 {
68653
68944
  [ti]() {
68654
68945
  let t = true;
68655
68946
  try {
68656
- let { fd: e2, buf: i, offset: r2, length: n, pos: o2 } = this;
68947
+ let { fd: e2, buf: i, offset: r2, length: n2, pos: o2 } = this;
68657
68948
  if (e2 === undefined || i === undefined)
68658
68949
  throw new Error("fd and buf must be set in READ method");
68659
- let h2 = $2.readSync(e2, i, r2, n, o2);
68950
+ let h2 = $2.readSync(e2, i, r2, n2, o2);
68660
68951
  this[Ji](h2), t = false;
68661
68952
  } finally {
68662
68953
  if (t)
@@ -68710,12 +69001,12 @@ var ri = class extends D {
68710
69001
  if (r2 === "Unsupported")
68711
69002
  throw new Error("writing entry that should be ignored");
68712
69003
  this.type = r2, this.type === "Directory" && this.portable && (this.noMtime = true), this.prefix = i.prefix, this.path = f3(t.path), this.mode = t.mode !== undefined ? this[ii](t.mode) : undefined, this.uid = this.portable ? undefined : t.uid, this.gid = this.portable ? undefined : t.gid, this.uname = this.portable ? undefined : t.uname, this.gname = this.portable ? undefined : t.gname, this.size = t.size, this.mtime = this.noMtime ? undefined : i.mtime || t.mtime, this.atime = this.portable ? undefined : t.atime, this.ctime = this.portable ? undefined : t.ctime, this.linkpath = t.linkpath !== undefined ? f3(t.linkpath) : undefined, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
68713
- let n = false;
69004
+ let n2 = false;
68714
69005
  if (!this.preservePaths) {
68715
69006
  let [h2, a3] = ce2(this.path);
68716
- h2 && typeof a3 == "string" && (this.path = a3, n = h2);
69007
+ h2 && typeof a3 == "string" && (this.path = a3, n2 = h2);
68717
69008
  }
68718
- this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new F({ path: this[X3](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X3](this.linkpath) : this.linkpath, mode: this.mode, uid: this.portable ? undefined : this.uid, gid: this.portable ? undefined : this.gid, size: this.size, mtime: this.noMtime ? undefined : this.mtime, type: this.type, uname: this.portable ? undefined : this.uname, atime: this.portable ? undefined : this.atime, ctime: this.portable ? undefined : this.ctime }), n && this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute path`, { entry: this, path: n + this.path }), this.header.encode() && !this.noPax && super.write(new ct({ atime: this.portable ? undefined : this.atime, ctime: this.portable ? undefined : this.ctime, gid: this.portable ? undefined : this.gid, mtime: this.noMtime ? undefined : this.mtime, path: this[X3](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X3](this.linkpath) : this.linkpath, size: this.size, uid: this.portable ? undefined : this.uid, uname: this.portable ? undefined : this.uname, dev: this.portable ? undefined : this.readEntry.dev, ino: this.portable ? undefined : this.readEntry.ino, nlink: this.portable ? undefined : this.readEntry.nlink }).encode());
69009
+ this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new F({ path: this[X3](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X3](this.linkpath) : this.linkpath, mode: this.mode, uid: this.portable ? undefined : this.uid, gid: this.portable ? undefined : this.gid, size: this.size, mtime: this.noMtime ? undefined : this.mtime, type: this.type, uname: this.portable ? undefined : this.uname, atime: this.portable ? undefined : this.atime, ctime: this.portable ? undefined : this.ctime }), n2 && this.warn("TAR_ENTRY_INFO", `stripping ${n2} from absolute path`, { entry: this, path: n2 + this.path }), this.header.encode() && !this.noPax && super.write(new ct({ atime: this.portable ? undefined : this.atime, ctime: this.portable ? undefined : this.ctime, gid: this.portable ? undefined : this.gid, mtime: this.noMtime ? undefined : this.mtime, path: this[X3](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X3](this.linkpath) : this.linkpath, size: this.size, uid: this.portable ? undefined : this.uid, uname: this.portable ? undefined : this.uname, dev: this.portable ? undefined : this.readEntry.dev, ino: this.portable ? undefined : this.readEntry.ino, nlink: this.portable ? undefined : this.readEntry.nlink }).encode());
68719
69010
  let o2 = this.header?.block;
68720
69011
  if (!o2)
68721
69012
  throw new Error("failed to encode header");
@@ -68842,8 +69133,8 @@ var ni = class s2 {
68842
69133
  r2 = this.head.next, i = this.head.value;
68843
69134
  else
68844
69135
  throw new TypeError("Reduce of empty list with no initial value");
68845
- for (var n = 0;r2; n++)
68846
- i = t(i, r2.value, n), r2 = r2.next;
69136
+ for (var n2 = 0;r2; n2++)
69137
+ i = t(i, r2.value, n2), r2 = r2.next;
68847
69138
  return i;
68848
69139
  }
68849
69140
  reduceReverse(t, e2) {
@@ -68854,8 +69145,8 @@ var ni = class s2 {
68854
69145
  r2 = this.tail.prev, i = this.tail.value;
68855
69146
  else
68856
69147
  throw new TypeError("Reduce of empty list with no initial value");
68857
- for (let n = this.length - 1;r2; n--)
68858
- i = t(i, r2.value, n), r2 = r2.prev;
69148
+ for (let n2 = this.length - 1;r2; n2--)
69149
+ i = t(i, r2.value, n2), r2 = r2.prev;
68859
69150
  return i;
68860
69151
  }
68861
69152
  toArray() {
@@ -68876,10 +69167,10 @@ var ni = class s2 {
68876
69167
  if (e2 < t || e2 < 0)
68877
69168
  return i;
68878
69169
  t < 0 && (t = 0), e2 > this.length && (e2 = this.length);
68879
- let r2 = this.head, n = 0;
68880
- for (n = 0;r2 && n < t; n++)
69170
+ let r2 = this.head, n2 = 0;
69171
+ for (n2 = 0;r2 && n2 < t; n2++)
68881
69172
  r2 = r2.next;
68882
- for (;r2 && n < e2; n++, r2 = r2.next)
69173
+ for (;r2 && n2 < e2; n2++, r2 = r2.next)
68883
69174
  i.push(r2.value);
68884
69175
  return i;
68885
69176
  }
@@ -68889,11 +69180,11 @@ var ni = class s2 {
68889
69180
  if (e2 < t || e2 < 0)
68890
69181
  return i;
68891
69182
  t < 0 && (t = 0), e2 > this.length && (e2 = this.length);
68892
- let r2 = this.length, n = this.tail;
68893
- for (;n && r2 > e2; r2--)
68894
- n = n.prev;
68895
- for (;n && r2 > t; r2--, n = n.prev)
68896
- i.push(n.value);
69183
+ let r2 = this.length, n2 = this.tail;
69184
+ for (;n2 && r2 > e2; r2--)
69185
+ n2 = n2.prev;
69186
+ for (;n2 && r2 > t; r2--, n2 = n2.prev)
69187
+ i.push(n2.value);
68897
69188
  return i;
68898
69189
  }
68899
69190
  splice(t, e2 = 0, ...i) {
@@ -68901,13 +69192,13 @@ var ni = class s2 {
68901
69192
  let r2 = this.head;
68902
69193
  for (let o2 = 0;r2 && o2 < t; o2++)
68903
69194
  r2 = r2.next;
68904
- let n = [];
69195
+ let n2 = [];
68905
69196
  for (let o2 = 0;r2 && o2 < e2; o2++)
68906
- n.push(r2.value), r2 = this.removeNode(r2);
69197
+ n2.push(r2.value), r2 = this.removeNode(r2);
68907
69198
  r2 ? r2 !== this.tail && (r2 = r2.prev) : r2 = this.tail;
68908
69199
  for (let o2 of i)
68909
69200
  r2 = Bn(this, r2, o2);
68910
- return n;
69201
+ return n2;
68911
69202
  }
68912
69203
  reverse() {
68913
69204
  let t = this.head, e2 = this.tail;
@@ -68919,8 +69210,8 @@ var ni = class s2 {
68919
69210
  }
68920
69211
  };
68921
69212
  function Bn(s3, t, e2) {
68922
- let i = t, r2 = t ? t.next : s3.head, n = new ue2(e2, i, r2, s3);
68923
- return n.next === undefined && (s3.tail = n), n.prev === undefined && (s3.head = n), s3.length++, n;
69213
+ let i = t, r2 = t ? t.next : s3.head, n2 = new ue2(e2, i, r2, s3);
69214
+ return n2.next === undefined && (s3.tail = n2), n2.prev === undefined && (s3.head = n2), s3.length++, n2;
68924
69215
  }
68925
69216
  function Pn(s3, t) {
68926
69217
  s3.tail = new ue2(t, s3.tail, undefined, s3), s3.head || (s3.head = s3.tail), s3.length++;
@@ -69115,7 +69406,7 @@ var Et = class extends D {
69115
69406
  }
69116
69407
  [li](t) {
69117
69408
  t.piped = true, t.readdir && t.readdir.forEach((r2) => {
69118
- let n = t.path, o2 = n === "./" ? "" : n.replace(/\/*$/, "/");
69409
+ let n2 = t.path, o2 = n2 === "./" ? "" : n2.replace(/\/*$/, "/");
69119
69410
  this[hi](o2 + r2);
69120
69411
  });
69121
69412
  let e2 = t.entry, i = this.zip;
@@ -69151,7 +69442,7 @@ var kt = class extends Et {
69151
69442
  [li](t) {
69152
69443
  let e2 = t.entry, i = this.zip;
69153
69444
  if (t.readdir && t.readdir.forEach((r2) => {
69154
- let n = t.path, o2 = n === "./" ? "" : n.replace(/\/*$/, "/");
69445
+ let n2 = t.path, o2 = n2 === "./" ? "" : n2.replace(/\/*$/, "/");
69155
69446
  this[hi](o2 + r2);
69156
69447
  }), !e2)
69157
69448
  throw new Error("Cannot pipe without source");
@@ -69169,10 +69460,10 @@ var Un = (s3, t) => {
69169
69460
  var Hn = (s3, t) => {
69170
69461
  let e2 = new Et(s3), i = new tt(s3.file, { mode: s3.mode || 438 });
69171
69462
  e2.pipe(i);
69172
- let r2 = new Promise((n, o2) => {
69173
- i.on("error", o2), i.on("close", n), e2.on("error", o2);
69463
+ let r2 = new Promise((n2, o2) => {
69464
+ i.on("error", o2), i.on("close", n2), e2.on("error", o2);
69174
69465
  });
69175
- return hr(e2, t).catch((n) => e2.emit("error", n)), r2;
69466
+ return hr(e2, t).catch((n2) => e2.emit("error", n2)), r2;
69176
69467
  };
69177
69468
  var or = (s3, t) => {
69178
69469
  t.forEach((e2) => {
@@ -69207,7 +69498,7 @@ var Vn = 512 * 1024;
69207
69498
  var $n = pr | ur | dr | mr;
69208
69499
  var lr = !fr && typeof ar == "number" ? ar | ur | dr | mr : null;
69209
69500
  var cs = lr !== null ? () => lr : Kn ? (s3) => s3 < Vn ? $n : "w" : () => "w";
69210
- var fs28 = (s3, t, e2) => {
69501
+ var fs29 = (s3, t, e2) => {
69211
69502
  try {
69212
69503
  return mi.lchownSync(s3, t, e2);
69213
69504
  } catch (i) {
@@ -69222,28 +69513,28 @@ var ui = (s3, t, e2, i) => {
69222
69513
  };
69223
69514
  var Xn = (s3, t, e2, i, r2) => {
69224
69515
  if (t.isDirectory())
69225
- ds(Ee.resolve(s3, t.name), e2, i, (n) => {
69226
- if (n)
69227
- return r2(n);
69516
+ ds(Ee.resolve(s3, t.name), e2, i, (n2) => {
69517
+ if (n2)
69518
+ return r2(n2);
69228
69519
  let o2 = Ee.resolve(s3, t.name);
69229
69520
  ui(o2, e2, i, r2);
69230
69521
  });
69231
69522
  else {
69232
- let n = Ee.resolve(s3, t.name);
69233
- ui(n, e2, i, r2);
69523
+ let n2 = Ee.resolve(s3, t.name);
69524
+ ui(n2, e2, i, r2);
69234
69525
  }
69235
69526
  };
69236
69527
  var ds = (s3, t, e2, i) => {
69237
- mi.readdir(s3, { withFileTypes: true }, (r2, n) => {
69528
+ mi.readdir(s3, { withFileTypes: true }, (r2, n2) => {
69238
69529
  if (r2) {
69239
69530
  if (r2.code === "ENOENT")
69240
69531
  return i();
69241
69532
  if (r2.code !== "ENOTDIR" && r2.code !== "ENOTSUP")
69242
69533
  return i(r2);
69243
69534
  }
69244
- if (r2 || !n.length)
69535
+ if (r2 || !n2.length)
69245
69536
  return ui(s3, t, e2, i);
69246
- let o2 = n.length, h2 = null, a3 = (l2) => {
69537
+ let o2 = n2.length, h2 = null, a3 = (l2) => {
69247
69538
  if (!h2) {
69248
69539
  if (l2)
69249
69540
  return i(h2 = l2);
@@ -69251,28 +69542,28 @@ var ds = (s3, t, e2, i) => {
69251
69542
  return ui(s3, t, e2, i);
69252
69543
  }
69253
69544
  };
69254
- for (let l2 of n)
69545
+ for (let l2 of n2)
69255
69546
  Xn(s3, l2, t, e2, a3);
69256
69547
  });
69257
69548
  };
69258
69549
  var qn = (s3, t, e2, i) => {
69259
- t.isDirectory() && us(Ee.resolve(s3, t.name), e2, i), fs28(Ee.resolve(s3, t.name), e2, i);
69550
+ t.isDirectory() && us(Ee.resolve(s3, t.name), e2, i), fs29(Ee.resolve(s3, t.name), e2, i);
69260
69551
  };
69261
69552
  var us = (s3, t, e2) => {
69262
69553
  let i;
69263
69554
  try {
69264
69555
  i = mi.readdirSync(s3, { withFileTypes: true });
69265
69556
  } catch (r2) {
69266
- let n = r2;
69267
- if (n?.code === "ENOENT")
69557
+ let n2 = r2;
69558
+ if (n2?.code === "ENOENT")
69268
69559
  return;
69269
- if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP")
69270
- return fs28(s3, t, e2);
69271
- throw n;
69560
+ if (n2?.code === "ENOTDIR" || n2?.code === "ENOTSUP")
69561
+ return fs29(s3, t, e2);
69562
+ throw n2;
69272
69563
  }
69273
69564
  for (let r2 of i)
69274
69565
  qn(s3, r2, t, e2);
69275
- return fs28(s3, t, e2);
69566
+ return fs29(s3, t, e2);
69276
69567
  };
69277
69568
  var we = class extends Error {
69278
69569
  path;
@@ -69304,8 +69595,8 @@ var Qn = (s3, t) => {
69304
69595
  };
69305
69596
  var Er = (s3, t, e2) => {
69306
69597
  s3 = f3(s3);
69307
- let i = t.umask ?? 18, r2 = t.mode | 448, n = (r2 & i) !== 0, o2 = t.uid, h2 = t.gid, a3 = typeof o2 == "number" && typeof h2 == "number" && (o2 !== t.processUid || h2 !== t.processGid), l2 = t.preserve, c2 = t.unlink, d3 = f3(t.cwd), S3 = (E2, x3) => {
69308
- E2 ? e2(E2) : x3 && a3 ? ds(x3, o2, h2, (xe) => S3(xe)) : n ? k2.chmod(s3, r2, e2) : e2();
69598
+ let i = t.umask ?? 18, r2 = t.mode | 448, n2 = (r2 & i) !== 0, o2 = t.uid, h2 = t.gid, a3 = typeof o2 == "number" && typeof h2 == "number" && (o2 !== t.processUid || h2 !== t.processGid), l2 = t.preserve, c2 = t.unlink, d3 = f3(t.cwd), S3 = (E2, x3) => {
69599
+ E2 ? e2(E2) : x3 && a3 ? ds(x3, o2, h2, (xe) => S3(xe)) : n2 ? k2.chmod(s3, r2, e2) : e2();
69309
69600
  };
69310
69601
  if (s3 === d3)
69311
69602
  return Qn(s3, S3);
@@ -69314,30 +69605,30 @@ var Er = (s3, t, e2) => {
69314
69605
  let N2 = f3(pi.relative(d3, s3)).split("/");
69315
69606
  ms(d3, N2, r2, c2, d3, undefined, S3);
69316
69607
  };
69317
- var ms = (s3, t, e2, i, r2, n, o2) => {
69608
+ var ms = (s3, t, e2, i, r2, n2, o2) => {
69318
69609
  if (t.length === 0)
69319
- return o2(null, n);
69610
+ return o2(null, n2);
69320
69611
  let h2 = t.shift(), a3 = f3(pi.resolve(s3 + "/" + h2));
69321
- k2.mkdir(a3, e2, wr(a3, t, e2, i, r2, n, o2));
69612
+ k2.mkdir(a3, e2, wr(a3, t, e2, i, r2, n2, o2));
69322
69613
  };
69323
- var wr = (s3, t, e2, i, r2, n, o2) => (h2) => {
69614
+ var wr = (s3, t, e2, i, r2, n2, o2) => (h2) => {
69324
69615
  h2 ? k2.lstat(s3, (a3, l2) => {
69325
69616
  if (a3)
69326
69617
  a3.path = a3.path && f3(a3.path), o2(a3);
69327
69618
  else if (l2.isDirectory())
69328
- ms(s3, t, e2, i, r2, n, o2);
69619
+ ms(s3, t, e2, i, r2, n2, o2);
69329
69620
  else if (i)
69330
69621
  k2.unlink(s3, (c2) => {
69331
69622
  if (c2)
69332
69623
  return o2(c2);
69333
- k2.mkdir(s3, e2, wr(s3, t, e2, i, r2, n, o2));
69624
+ k2.mkdir(s3, e2, wr(s3, t, e2, i, r2, n2, o2));
69334
69625
  });
69335
69626
  else {
69336
69627
  if (l2.isSymbolicLink())
69337
69628
  return o2(new wt(s3, s3 + "/" + t.join("/")));
69338
69629
  o2(h2);
69339
69630
  }
69340
- }) : (n = n || s3, ms(s3, t, e2, i, r2, n, o2));
69631
+ }) : (n2 = n2 || s3, ms(s3, t, e2, i, r2, n2, o2));
69341
69632
  };
69342
69633
  var Jn = (s3) => {
69343
69634
  let t = false, e2;
@@ -69352,8 +69643,8 @@ var Jn = (s3) => {
69352
69643
  };
69353
69644
  var Sr = (s3, t) => {
69354
69645
  s3 = f3(s3);
69355
- let e2 = t.umask ?? 18, i = t.mode | 448, r2 = (i & e2) !== 0, n = t.uid, o2 = t.gid, h2 = typeof n == "number" && typeof o2 == "number" && (n !== t.processUid || o2 !== t.processGid), a3 = t.preserve, l2 = t.unlink, c2 = f3(t.cwd), d3 = (E2) => {
69356
- E2 && h2 && us(E2, n, o2), r2 && k2.chmodSync(s3, i);
69646
+ let e2 = t.umask ?? 18, i = t.mode | 448, r2 = (i & e2) !== 0, n2 = t.uid, o2 = t.gid, h2 = typeof n2 == "number" && typeof o2 == "number" && (n2 !== t.processUid || o2 !== t.processGid), a3 = t.preserve, l2 = t.unlink, c2 = f3(t.cwd), d3 = (E2) => {
69647
+ E2 && h2 && us(E2, n2, o2), r2 && k2.chmodSync(s3, i);
69357
69648
  };
69358
69649
  if (s3 === c2)
69359
69650
  return Jn(c2), d3();
@@ -69402,19 +69693,19 @@ var Ei = class {
69402
69693
  #s = new Set;
69403
69694
  reserve(t, e2) {
69404
69695
  t = eo ? ["win32 parallelization disabled"] : t.map((r2) => mt(br(Rr(r2))));
69405
- let i = new Set(t.map((r2) => io(r2)).reduce((r2, n) => r2.concat(n)));
69696
+ let i = new Set(t.map((r2) => io(r2)).reduce((r2, n2) => r2.concat(n2)));
69406
69697
  this.#i.set(e2, { dirs: i, paths: t });
69407
69698
  for (let r2 of t) {
69408
- let n = this.#t.get(r2);
69409
- n ? n.push(e2) : this.#t.set(r2, [e2]);
69699
+ let n2 = this.#t.get(r2);
69700
+ n2 ? n2.push(e2) : this.#t.set(r2, [e2]);
69410
69701
  }
69411
69702
  for (let r2 of i) {
69412
- let n = this.#t.get(r2);
69413
- if (!n)
69703
+ let n2 = this.#t.get(r2);
69704
+ if (!n2)
69414
69705
  this.#t.set(r2, [new Set([e2])]);
69415
69706
  else {
69416
- let o2 = n.at(-1);
69417
- o2 instanceof Set ? o2.add(e2) : n.push(new Set([e2]));
69707
+ let o2 = n2.at(-1);
69708
+ o2 instanceof Set ? o2.add(e2) : n2.push(new Set([e2]));
69418
69709
  }
69419
69710
  }
69420
69711
  return this.#r(e2);
@@ -69438,7 +69729,7 @@ var Ei = class {
69438
69729
  let e2 = this.#i.get(t);
69439
69730
  if (!e2)
69440
69731
  throw new Error("invalid reservation");
69441
- let { paths: i, dirs: r2 } = e2, n = new Set;
69732
+ let { paths: i, dirs: r2 } = e2, n2 = new Set;
69442
69733
  for (let o2 of i) {
69443
69734
  let h2 = this.#t.get(o2);
69444
69735
  if (!h2 || h2?.[0] !== t)
@@ -69449,10 +69740,10 @@ var Ei = class {
69449
69740
  continue;
69450
69741
  }
69451
69742
  if (h2.shift(), typeof a3 == "function")
69452
- n.add(a3);
69743
+ n2.add(a3);
69453
69744
  else
69454
69745
  for (let l2 of a3)
69455
- n.add(l2);
69746
+ n2.add(l2);
69456
69747
  }
69457
69748
  for (let o2 of r2) {
69458
69749
  let h2 = this.#t.get(o2), a3 = h2?.[0];
@@ -69463,11 +69754,11 @@ var Ei = class {
69463
69754
  } else if (a3.size === 1) {
69464
69755
  h2.shift();
69465
69756
  let l2 = h2[0];
69466
- typeof l2 == "function" && n.add(l2);
69757
+ typeof l2 == "function" && n2.add(l2);
69467
69758
  } else
69468
69759
  a3.delete(t);
69469
69760
  }
69470
- return this.#s.delete(t), n.forEach((o2) => this.#r(o2)), true;
69761
+ return this.#s.delete(t), n2.forEach((o2) => this.#r(o2)), true;
69471
69762
  }
69472
69763
  };
69473
69764
  var _r = () => process.umask();
@@ -69569,7 +69860,7 @@ var qt = class extends st {
69569
69860
  let i = t[e2], { type: r2 } = t;
69570
69861
  if (!i || this.preservePaths)
69571
69862
  return true;
69572
- let [n, o2] = ce2(i), h2 = o2.replaceAll(/\\/g, "/").split("/");
69863
+ let [n2, o2] = ce2(i), h2 = o2.replaceAll(/\\/g, "/").split("/");
69573
69864
  if (h2.includes("..") || Oe && /^[a-z]:\.\.$/i.test(h2[0] ?? "")) {
69574
69865
  if (e2 === "path" || r2 === "Link")
69575
69866
  return this.warn("TAR_ENTRY_ERROR", `${e2} contains '..'`, { entry: t, [e2]: i }), false;
@@ -69577,7 +69868,7 @@ var qt = class extends st {
69577
69868
  if (l2.startsWith("../") || l2 === "..")
69578
69869
  return this.warn("TAR_ENTRY_ERROR", `${e2} escapes extraction directory`, { entry: t, [e2]: i }), false;
69579
69870
  }
69580
- return n && (t[e2] = String(o2), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e2}`, { entry: t, [e2]: i })), true;
69871
+ return n2 && (t[e2] = String(o2), this.warn("TAR_ENTRY_INFO", `stripping ${n2} from absolute ${e2}`, { entry: t, [e2]: i })), true;
69581
69872
  }
69582
69873
  [Nr](t) {
69583
69874
  let e2 = f3(t.path), i = e2.split("/");
@@ -69604,8 +69895,8 @@ var qt = class extends st {
69604
69895
  if (this.win32) {
69605
69896
  let { root: r2 } = R3.win32.parse(String(t.absolute));
69606
69897
  t.absolute = r2 + Xi(String(t.absolute).slice(r2.length));
69607
- let { root: n } = R3.win32.parse(t.path);
69608
- t.path = n + Xi(t.path.slice(n.length));
69898
+ let { root: n2 } = R3.win32.parse(t.path);
69899
+ t.path = n2 + Xi(t.path.slice(n2.length));
69609
69900
  }
69610
69901
  return true;
69611
69902
  }
@@ -69646,24 +69937,24 @@ var qt = class extends st {
69646
69937
  r2.on("error", (a3) => {
69647
69938
  r2.fd && u.close(r2.fd, () => {}), r2.write = () => true, this[O2](a3, t), e2();
69648
69939
  });
69649
- let n = 1, o2 = (a3) => {
69940
+ let n2 = 1, o2 = (a3) => {
69650
69941
  if (a3) {
69651
69942
  r2.fd && u.close(r2.fd, () => {}), this[O2](a3, t), e2();
69652
69943
  return;
69653
69944
  }
69654
- --n === 0 && r2.fd !== undefined && u.close(r2.fd, (l2) => {
69945
+ --n2 === 0 && r2.fd !== undefined && u.close(r2.fd, (l2) => {
69655
69946
  l2 ? this[O2](l2, t) : this[Xt](), e2();
69656
69947
  });
69657
69948
  };
69658
69949
  r2.on("finish", () => {
69659
69950
  let a3 = String(t.absolute), l2 = r2.fd;
69660
69951
  if (typeof l2 == "number" && t.mtime && !this.noMtime) {
69661
- n++;
69952
+ n2++;
69662
69953
  let c2 = t.atime || new Date, d3 = t.mtime;
69663
69954
  u.futimes(l2, c2, d3, (S3) => S3 ? u.utimes(a3, c2, d3, (T3) => o2(T3 && S3)) : o2());
69664
69955
  }
69665
69956
  if (typeof l2 == "number" && this[Re](t)) {
69666
- n++;
69957
+ n2++;
69667
69958
  let c2 = this[be](t), d3 = this[_e](t);
69668
69959
  typeof c2 == "number" && typeof d3 == "number" && u.fchown(l2, c2, d3, (S3) => S3 ? u.chown(a3, c2, d3, (T3) => o2(T3 && S3)) : o2());
69669
69960
  }
@@ -69681,10 +69972,10 @@ var qt = class extends st {
69681
69972
  this[O2](r2, t), e2();
69682
69973
  return;
69683
69974
  }
69684
- let n = 1, o2 = () => {
69685
- --n === 0 && (e2(), this[Xt](), t.resume());
69975
+ let n2 = 1, o2 = () => {
69976
+ --n2 === 0 && (e2(), this[Xt](), t.resume());
69686
69977
  };
69687
- t.mtime && !this.noMtime && (n++, u.utimes(String(t.absolute), t.atime || new Date, t.mtime, o2)), this[Re](t) && (n++, u.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o2)), o2();
69978
+ t.mtime && !this.noMtime && (n2++, u.utimes(String(t.absolute), t.atime || new Date, t.mtime, o2)), this[Re](t) && (n2++, u.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o2)), o2();
69688
69979
  });
69689
69980
  }
69690
69981
  [Lr](t) {
@@ -69698,11 +69989,11 @@ var qt = class extends st {
69698
69989
  }
69699
69990
  [xr](t, e2) {
69700
69991
  let i = f3(R3.resolve(this.cwd, String(t.linkpath))), r2 = f3(String(t.linkpath)).split("/");
69701
- this[ye](t, this.cwd, r2, () => this[Si](t, i, "link", e2), (n) => {
69702
- this[O2](n, t), e2();
69992
+ this[ye](t, this.cwd, r2, () => this[Si](t, i, "link", e2), (n2) => {
69993
+ this[O2](n2, t), e2();
69703
69994
  });
69704
69995
  }
69705
- [ye](t, e2, i, r2, n) {
69996
+ [ye](t, e2, i, r2, n2) {
69706
69997
  let o2 = i.shift();
69707
69998
  if (this.preservePaths || o2 === undefined)
69708
69999
  return r2();
@@ -69711,8 +70002,8 @@ var qt = class extends st {
69711
70002
  if (a3)
69712
70003
  return r2();
69713
70004
  if (l2?.isSymbolicLink())
69714
- return n(new wt(h2, R3.resolve(h2, i.join("/"))));
69715
- this[ye](t, h2, i, r2, n);
70005
+ return n2(new wt(h2, R3.resolve(h2, i.join("/"))));
70006
+ this[ye](t, h2, i, r2, n2);
69716
70007
  });
69717
70008
  }
69718
70009
  [Ar]() {
@@ -69741,9 +70032,9 @@ var qt = class extends st {
69741
70032
  this[O2](h2, t), i();
69742
70033
  return;
69743
70034
  }
69744
- this[ge] = true, n();
70035
+ this[ge] = true, n2();
69745
70036
  });
69746
- }, n = () => {
70037
+ }, n2 = () => {
69747
70038
  if (t.absolute !== this.cwd) {
69748
70039
  let h2 = f3(R3.dirname(String(t.absolute)));
69749
70040
  if (h2 !== this.cwd)
@@ -69777,7 +70068,7 @@ var qt = class extends st {
69777
70068
  oo(String(t.absolute), (l2) => this[P2](l2 ?? null, t, i));
69778
70069
  });
69779
70070
  };
69780
- this[ge] ? n() : r2();
70071
+ this[ge] ? n2() : r2();
69781
70072
  }
69782
70073
  [P2](t, e2, i) {
69783
70074
  if (t) {
@@ -69799,8 +70090,8 @@ var qt = class extends st {
69799
70090
  }
69800
70091
  }
69801
70092
  [Si](t, e2, i, r2) {
69802
- u[i](e2, String(t.absolute), (n) => {
69803
- n ? this[O2](n, t) : (this[Xt](), t.resume()), r2();
70093
+ u[i](e2, String(t.absolute), (n2) => {
70094
+ n2 ? this[O2](n2, t) : (this[Xt](), t.resume()), r2();
69804
70095
  });
69805
70096
  }
69806
70097
  };
@@ -69818,15 +70109,15 @@ var Te = class extends qt {
69818
70109
  }
69819
70110
  [ys](t) {
69820
70111
  if (!this[ge]) {
69821
- let n = this[St](this.cwd, this.dmode);
69822
- if (n)
69823
- return this[O2](n, t);
70112
+ let n2 = this[St](this.cwd, this.dmode);
70113
+ if (n2)
70114
+ return this[O2](n2, t);
69824
70115
  this[ge] = true;
69825
70116
  }
69826
70117
  if (t.absolute !== this.cwd) {
69827
- let n = f3(R3.dirname(String(t.absolute)));
69828
- if (n !== this.cwd) {
69829
- let o2 = this[St](n, this.dmode);
70118
+ let n2 = f3(R3.dirname(String(t.absolute)));
70119
+ if (n2 !== this.cwd) {
70120
+ let o2 = this[St](n2, this.dmode);
69830
70121
  if (o2)
69831
70122
  return this[O2](o2, t);
69832
70123
  }
@@ -69843,8 +70134,8 @@ var Te = class extends qt {
69843
70134
  }) : [];
69844
70135
  return this[P2](h2, t);
69845
70136
  }
69846
- let [n] = Se(() => u.rmdirSync(String(t.absolute)));
69847
- this[P2](n, t);
70137
+ let [n2] = Se(() => u.rmdirSync(String(t.absolute)));
70138
+ this[P2](n2, t);
69848
70139
  }
69849
70140
  let [r2] = t.absolute === this.cwd ? [] : Se(() => ho(String(t.absolute)));
69850
70141
  this[P2](r2, t);
@@ -69853,21 +70144,21 @@ var Te = class extends qt {
69853
70144
  let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r2 = (h2) => {
69854
70145
  let a3;
69855
70146
  try {
69856
- u.closeSync(n);
70147
+ u.closeSync(n2);
69857
70148
  } catch (l2) {
69858
70149
  a3 = l2;
69859
70150
  }
69860
70151
  (h2 || a3) && this[O2](h2 || a3, t), e2();
69861
- }, n;
70152
+ }, n2;
69862
70153
  try {
69863
- n = u.openSync(String(t.absolute), cs(t.size), i);
70154
+ n2 = u.openSync(String(t.absolute), cs(t.size), i);
69864
70155
  } catch (h2) {
69865
70156
  return r2(h2);
69866
70157
  }
69867
70158
  let o2 = this.transform && this.transform(t) || t;
69868
70159
  o2 !== t && (o2.on("error", (h2) => this[O2](h2, t)), t.pipe(o2)), o2.on("data", (h2) => {
69869
70160
  try {
69870
- u.writeSync(n, h2, 0, h2.length);
70161
+ u.writeSync(n2, h2, 0, h2.length);
69871
70162
  } catch (a3) {
69872
70163
  r2(a3);
69873
70164
  }
@@ -69876,7 +70167,7 @@ var Te = class extends qt {
69876
70167
  if (t.mtime && !this.noMtime) {
69877
70168
  let a3 = t.atime || new Date, l2 = t.mtime;
69878
70169
  try {
69879
- u.futimesSync(n, a3, l2);
70170
+ u.futimesSync(n2, a3, l2);
69880
70171
  } catch (c2) {
69881
70172
  try {
69882
70173
  u.utimesSync(String(t.absolute), a3, l2);
@@ -69888,7 +70179,7 @@ var Te = class extends qt {
69888
70179
  if (this[Re](t)) {
69889
70180
  let a3 = this[be](t), l2 = this[_e](t);
69890
70181
  try {
69891
- u.fchownSync(n, Number(a3), Number(l2));
70182
+ u.fchownSync(n2, Number(a3), Number(l2));
69892
70183
  } catch (c2) {
69893
70184
  try {
69894
70185
  u.chownSync(String(t.absolute), Number(a3), Number(l2));
@@ -69923,7 +70214,7 @@ var Te = class extends qt {
69923
70214
  return i;
69924
70215
  }
69925
70216
  }
69926
- [ye](t, e2, i, r2, n) {
70217
+ [ye](t, e2, i, r2, n2) {
69927
70218
  if (this.preservePaths || i.length === 0)
69928
70219
  return r2();
69929
70220
  let o2 = e2;
@@ -69933,14 +70224,14 @@ var Te = class extends qt {
69933
70224
  if (a3)
69934
70225
  return r2();
69935
70226
  if (l2.isSymbolicLink())
69936
- return n(new wt(o2, R3.resolve(e2, i.join("/"))));
70227
+ return n2(new wt(o2, R3.resolve(e2, i.join("/"))));
69937
70228
  }
69938
70229
  r2();
69939
70230
  }
69940
70231
  [Si](t, e2, i, r2) {
69941
- let n = `${i}Sync`;
70232
+ let n2 = `${i}Sync`;
69942
70233
  try {
69943
- u[n](e2, String(t.absolute)), r2(), t.resume();
70234
+ u[n2](e2, String(t.absolute)), r2(), t.resume();
69944
70235
  } catch (o2) {
69945
70236
  return this[O2](o2, t);
69946
70237
  }
@@ -69967,7 +70258,7 @@ var co = K3(ao, lo, (s3) => new Te(s3), (s3) => new qt(s3), (s3, t) => {
69967
70258
  t?.length && Ki(s3, t);
69968
70259
  });
69969
70260
  var fo = (s3, t) => {
69970
- let e2 = new kt(s3), i = true, r2, n;
70261
+ let e2 = new kt(s3), i = true, r2, n2;
69971
70262
  try {
69972
70263
  try {
69973
70264
  r2 = v2.openSync(s3.file, "r+");
@@ -69979,9 +70270,9 @@ var fo = (s3, t) => {
69979
70270
  }
69980
70271
  let o2 = v2.fstatSync(r2), h2 = Buffer.alloc(512);
69981
70272
  t:
69982
- for (n = 0;n < o2.size; n += 512) {
70273
+ for (n2 = 0;n2 < o2.size; n2 += 512) {
69983
70274
  for (let c2 = 0, d3 = 0;c2 < 512; c2 += d3) {
69984
- if (d3 = v2.readSync(r2, h2, c2, h2.length - c2, n + c2), n === 0 && h2[0] === 31 && h2[1] === 139)
70275
+ if (d3 = v2.readSync(r2, h2, c2, h2.length - c2, n2 + c2), n2 === 0 && h2[0] === 31 && h2[1] === 139)
69985
70276
  throw new Error("cannot append to compressed archives");
69986
70277
  if (!d3)
69987
70278
  break t;
@@ -69990,11 +70281,11 @@ var fo = (s3, t) => {
69990
70281
  if (!a3.cksumValid)
69991
70282
  break;
69992
70283
  let l2 = 512 * Math.ceil((a3.size || 0) / 512);
69993
- if (n + l2 + 512 > o2.size)
70284
+ if (n2 + l2 + 512 > o2.size)
69994
70285
  break;
69995
- n += l2, s3.mtimeCache && a3.mtime && s3.mtimeCache.set(String(a3.path), a3.mtime);
70286
+ n2 += l2, s3.mtimeCache && a3.mtime && s3.mtimeCache.set(String(a3.path), a3.mtime);
69996
70287
  }
69997
- i = false, uo(s3, e2, n, r2, t);
70288
+ i = false, uo(s3, e2, n2, r2, t);
69998
70289
  } finally {
69999
70290
  if (i)
70000
70291
  try {
@@ -70003,14 +70294,14 @@ var fo = (s3, t) => {
70003
70294
  }
70004
70295
  };
70005
70296
  var uo = (s3, t, e2, i, r2) => {
70006
- let n = new Wt(s3.file, { fd: i, start: e2 });
70007
- t.pipe(n), po(t, r2);
70297
+ let n2 = new Wt(s3.file, { fd: i, start: e2 });
70298
+ t.pipe(n2), po(t, r2);
70008
70299
  };
70009
70300
  var mo = (s3, t) => {
70010
70301
  t = Array.from(t);
70011
- let e2 = new Et(s3), i = (n, o2, h2) => {
70302
+ let e2 = new Et(s3), i = (n2, o2, h2) => {
70012
70303
  let a3 = (T3, N2) => {
70013
- T3 ? v2.close(n, (E2) => h2(T3)) : h2(null, N2);
70304
+ T3 ? v2.close(n2, (E2) => h2(T3)) : h2(null, N2);
70014
70305
  }, l2 = 0;
70015
70306
  if (o2 === 0)
70016
70307
  return a3(null, 0);
@@ -70018,7 +70309,7 @@ var mo = (s3, t) => {
70018
70309
  if (T3 || N2 === undefined)
70019
70310
  return a3(T3);
70020
70311
  if (c2 += N2, c2 < 512 && N2)
70021
- return v2.read(n, d3, c2, d3.length - c2, l2 + c2, S3);
70312
+ return v2.read(n2, d3, c2, d3.length - c2, l2 + c2, S3);
70022
70313
  if (l2 === 0 && d3[0] === 31 && d3[1] === 139)
70023
70314
  return a3(new Error("cannot append to compressed archives"));
70024
70315
  if (c2 < 512)
@@ -70029,11 +70320,11 @@ var mo = (s3, t) => {
70029
70320
  let x3 = 512 * Math.ceil((E2.size ?? 0) / 512);
70030
70321
  if (l2 + x3 + 512 > o2 || (l2 += x3 + 512, l2 >= o2))
70031
70322
  return a3(null, l2);
70032
- s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c2 = 0, v2.read(n, d3, 0, 512, l2, S3);
70323
+ s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c2 = 0, v2.read(n2, d3, 0, 512, l2, S3);
70033
70324
  };
70034
- v2.read(n, d3, 0, 512, l2, S3);
70325
+ v2.read(n2, d3, 0, 512, l2, S3);
70035
70326
  };
70036
- return new Promise((n, o2) => {
70327
+ return new Promise((n2, o2) => {
70037
70328
  e2.on("error", o2);
70038
70329
  let h2 = "r+", a3 = (l2, c2) => {
70039
70330
  if (l2 && l2.code === "ENOENT" && h2 === "r+")
@@ -70047,7 +70338,7 @@ var mo = (s3, t) => {
70047
70338
  if (T3)
70048
70339
  return o2(T3);
70049
70340
  let E2 = new tt(s3.file, { fd: c2, start: N2 });
70050
- e2.pipe(E2), E2.on("error", o2), E2.on("close", n), Eo(e2, t);
70341
+ e2.pipe(E2), E2.on("error", o2), E2.on("close", n2), Eo(e2, t);
70051
70342
  });
70052
70343
  });
70053
70344
  };
@@ -70512,7 +70803,7 @@ function buildReleaseAllowlist(layout) {
70512
70803
  async function ensureLayoutSourceDir(projectRoot, layout, strict) {
70513
70804
  const sourceDir = path10.join(projectRoot, layout.sourceDir);
70514
70805
  try {
70515
- const stat11 = await fs29.promises.stat(sourceDir);
70806
+ const stat11 = await fs30.promises.stat(sourceDir);
70516
70807
  if (!stat11.isDirectory()) {
70517
70808
  throw new Error(`Expected source directory "${layout.sourceDir}" exists but is not a directory.`);
70518
70809
  }
@@ -70537,8 +70828,8 @@ async function materializeRuntimeLayoutInPlace(projectRoot, layout) {
70537
70828
  }
70538
70829
  const sourceDir = path10.join(projectRoot, layout.sourceDir);
70539
70830
  const runtimeDir = path10.join(projectRoot, layout.runtimeDir);
70540
- await fs29.promises.rm(runtimeDir, { recursive: true, force: true });
70541
- await fs29.promises.rename(sourceDir, runtimeDir);
70831
+ await fs30.promises.rm(runtimeDir, { recursive: true, force: true });
70832
+ await fs30.promises.rename(sourceDir, runtimeDir);
70542
70833
  }
70543
70834
  async function stageLocalKitPathForRuntimeLayout(kitRoot, layout) {
70544
70835
  const sourceDir = await ensureLayoutSourceDir(kitRoot, layout, false);
@@ -70548,20 +70839,20 @@ async function stageLocalKitPathForRuntimeLayout(kitRoot, layout) {
70548
70839
  const downloadManager = new DownloadManager;
70549
70840
  const tempDir = await downloadManager.createTempDir();
70550
70841
  const extractDir = `${tempDir}/extracted`;
70551
- await fs29.promises.mkdir(extractDir, { recursive: true });
70552
- const entries = await fs29.promises.readdir(kitRoot);
70842
+ await fs30.promises.mkdir(extractDir, { recursive: true });
70843
+ const entries = await fs30.promises.readdir(kitRoot);
70553
70844
  const allowlist = buildReleaseAllowlist(layout);
70554
70845
  for (const entry of entries) {
70555
70846
  if (!allowlist.includes(entry) || entry === layout.sourceDir) {
70556
70847
  continue;
70557
70848
  }
70558
- await fs29.promises.cp(path10.join(kitRoot, entry), path10.join(extractDir, entry), {
70849
+ await fs30.promises.cp(path10.join(kitRoot, entry), path10.join(extractDir, entry), {
70559
70850
  recursive: true
70560
70851
  });
70561
70852
  }
70562
70853
  const runtimeDir = path10.join(extractDir, layout.runtimeDir);
70563
- await fs29.promises.mkdir(path10.dirname(runtimeDir), { recursive: true });
70564
- await fs29.promises.cp(sourceDir, runtimeDir, { recursive: true });
70854
+ await fs30.promises.mkdir(path10.dirname(runtimeDir), { recursive: true });
70855
+ await fs30.promises.cp(sourceDir, runtimeDir, { recursive: true });
70565
70856
  logger.verbose("Staged local kit path with runtime layout", {
70566
70857
  kitRoot,
70567
70858
  extractDir,
@@ -70590,9 +70881,9 @@ function resolveRepoRootForKit(kitRoot) {
70590
70881
  try {
70591
70882
  const parent = path10.dirname(kitRoot);
70592
70883
  const parentPackageJson = path10.join(parent, "package.json");
70593
- if (!fs29.existsSync(parentPackageJson))
70884
+ if (!fs30.existsSync(parentPackageJson))
70594
70885
  return kitRoot;
70595
- const pkg = JSON.parse(fs29.readFileSync(parentPackageJson, "utf-8"));
70886
+ const pkg = JSON.parse(fs30.readFileSync(parentPackageJson, "utf-8"));
70596
70887
  const kitCfg = pkg.takumi;
70597
70888
  const sourceDir = kitCfg?.sourceDir;
70598
70889
  if (typeof sourceDir === "string" && path10.resolve(parent, sourceDir) === path10.resolve(kitRoot)) {
@@ -70606,9 +70897,9 @@ async function stageMonorepoForInstallation(kitRoot) {
70606
70897
  const tempDir = await downloadManager.createTempDir();
70607
70898
  const extractDir = `${tempDir}/extracted`;
70608
70899
  const claudeDir = path10.join(extractDir, ".claude");
70609
- await fs29.promises.mkdir(claudeDir, { recursive: true });
70900
+ await fs30.promises.mkdir(claudeDir, { recursive: true });
70610
70901
  const repoRoot = resolveRepoRootForKit(kitRoot);
70611
- const kitEntries = await fs29.promises.readdir(kitRoot);
70902
+ const kitEntries = await fs30.promises.readdir(kitRoot);
70612
70903
  const skipLegacyManifest = kitEntries.includes(MANIFEST_FILENAME) && kitEntries.includes(LEGACY_MANIFEST_FILENAME);
70613
70904
  for (const entry of kitEntries) {
70614
70905
  if (!MONOREPO_KIT_CONTENT.includes(entry))
@@ -70616,14 +70907,14 @@ async function stageMonorepoForInstallation(kitRoot) {
70616
70907
  if (skipLegacyManifest && entry === LEGACY_MANIFEST_FILENAME)
70617
70908
  continue;
70618
70909
  const srcPath = path10.join(kitRoot, entry);
70619
- await fs29.promises.cp(srcPath, path10.join(claudeDir, entry), { recursive: true });
70910
+ await fs30.promises.cp(srcPath, path10.join(claudeDir, entry), { recursive: true });
70620
70911
  }
70621
- const repoEntries = repoRoot === kitRoot ? kitEntries : await fs29.promises.readdir(repoRoot);
70912
+ const repoEntries = repoRoot === kitRoot ? kitEntries : await fs30.promises.readdir(repoRoot);
70622
70913
  for (const entry of repoEntries) {
70623
70914
  if (!RELEASE_ROOT_ALLOWLIST.includes(entry))
70624
70915
  continue;
70625
70916
  const srcPath = path10.join(repoRoot, entry);
70626
- await fs29.promises.cp(srcPath, path10.join(extractDir, entry), { recursive: true });
70917
+ await fs30.promises.cp(srcPath, path10.join(extractDir, entry), { recursive: true });
70627
70918
  }
70628
70919
  logger.verbose("Staged monorepo for installation", {
70629
70920
  kitRoot,
@@ -70637,13 +70928,13 @@ async function stageMonorepoForInstallation(kitRoot) {
70637
70928
  async function normalizeFullRepoExtract(dir, strict) {
70638
70929
  const layout = resolveKitLayout(dir);
70639
70930
  await ensureLayoutSourceDir(dir, layout, strict);
70640
- const entries = await fs29.promises.readdir(dir);
70931
+ const entries = await fs30.promises.readdir(dir);
70641
70932
  const releaseAllowlist = buildReleaseAllowlist(layout);
70642
70933
  let removedCount = 0;
70643
70934
  for (const entry of entries) {
70644
70935
  if (!releaseAllowlist.includes(entry)) {
70645
70936
  const fullPath = path10.join(dir, entry);
70646
- await fs29.promises.rm(fullPath, { recursive: true, force: true });
70937
+ await fs30.promises.rm(fullPath, { recursive: true, force: true });
70647
70938
  removedCount++;
70648
70939
  }
70649
70940
  }
@@ -70758,7 +71049,7 @@ async function useLocalKitPath(kitPath, isMonorepo) {
70758
71049
  output.section("Using local kit");
70759
71050
  const absolutePath = path10.resolve(kitPath);
70760
71051
  try {
70761
- const stat11 = await fs29.promises.stat(absolutePath);
71052
+ const stat11 = await fs30.promises.stat(absolutePath);
70762
71053
  if (!stat11.isDirectory()) {
70763
71054
  throw new Error(`--kit-path must point to a directory, not a file.
70764
71055
 
@@ -70797,7 +71088,7 @@ Please verify the path exists and is accessible.`);
70797
71088
  }
70798
71089
  const claudeDir = path10.join(absolutePath, DEFAULT_KIT_LAYOUT.runtimeDir);
70799
71090
  try {
70800
- const stat11 = await fs29.promises.stat(claudeDir);
71091
+ const stat11 = await fs30.promises.stat(claudeDir);
70801
71092
  if (!stat11.isDirectory()) {
70802
71093
  logger.warning(`Warning: ${claudeDir} exists but is not a directory.
70803
71094
  This may not be a valid Takumi installation.`);
@@ -70832,7 +71123,7 @@ async function extractLocalArchive(archivePath, exclude) {
70832
71123
  const absolutePath = path10.resolve(archivePath);
70833
71124
  validateArchiveFormat(absolutePath);
70834
71125
  try {
70835
- const stat11 = await fs29.promises.stat(absolutePath);
71126
+ const stat11 = await fs30.promises.stat(absolutePath);
70836
71127
  if (!stat11.isFile()) {
70837
71128
  throw new Error(`--archive must point to a file, not a directory.
70838
71129
 
@@ -70965,7 +71256,7 @@ async function downloadViaWorker(release, kit, isNonInteractive2) {
70965
71256
  const tempDir = await downloadManager.createTempDir();
70966
71257
  const archivePath = path10.join(tempDir, assetName);
70967
71258
  const buf = Buffer.from(await res.arrayBuffer());
70968
- await fs29.promises.writeFile(archivePath, buf);
71259
+ await fs30.promises.writeFile(archivePath, buf);
70969
71260
  const extractDir = `${tempDir}/extracted`;
70970
71261
  logger.verbose("Extraction", { archivePath, extractDir });
70971
71262
  await downloadManager.extractArchive(archivePath, extractDir);
@@ -71327,7 +71618,7 @@ init_logger();
71327
71618
  init_safe_spinner();
71328
71619
  init_takumi_constants();
71329
71620
  var import_fs_extra32 = __toESM(require_lib(), 1);
71330
- import { existsSync as existsSync55, readdirSync as readdirSync9, rmSync as rmSync7, rmdirSync as rmdirSync2, unlinkSync as unlinkSync6 } from "node:fs";
71621
+ import { existsSync as existsSync56, readdirSync as readdirSync9, rmSync as rmSync7, rmdirSync as rmdirSync2, unlinkSync as unlinkSync6 } from "node:fs";
71331
71622
  import { dirname as dirname34, join as join117, resolve as resolve27 } from "node:path";
71332
71623
  var TAKUMI_SUBDIRECTORIES = ["commands", "agents", "skills", "rules", "hooks"];
71333
71624
  async function analyzeFreshInstallation(claudeDir) {
@@ -71400,7 +71691,7 @@ async function removeFilesByOwnership(claudeDir, analysis, includeModified) {
71400
71691
  for (const file of filesToRemove) {
71401
71692
  const fullPath = join117(claudeDir, file.path);
71402
71693
  try {
71403
- if (existsSync55(fullPath)) {
71694
+ if (existsSync56(fullPath)) {
71404
71695
  unlinkSync6(fullPath);
71405
71696
  removedFiles.push(file.path);
71406
71697
  logger.debug(`Removed: ${file.path}`);
@@ -73585,11 +73876,11 @@ async function initCommand(options2) {
73585
73876
  }
73586
73877
  // src/commands/plan/plan-command.ts
73587
73878
  init_output_manager();
73588
- import { existsSync as existsSync60, statSync as statSync9 } from "node:fs";
73879
+ import { existsSync as existsSync61, statSync as statSync9 } from "node:fs";
73589
73880
  import { dirname as dirname41, join as join128, parse as parse4, resolve as resolve33 } from "node:path";
73590
73881
 
73591
73882
  // src/commands/plan/plan-read-handlers.ts
73592
- import { existsSync as existsSync59, statSync as statSync8 } from "node:fs";
73883
+ import { existsSync as existsSync60, statSync as statSync8 } from "node:fs";
73593
73884
  import { basename as basename21, dirname as dirname40, join as join127, relative as relative20, resolve as resolve31 } from "node:path";
73594
73885
 
73595
73886
  // src/domains/plan-parser/index.ts
@@ -73970,20 +74261,20 @@ function parsePlanFile(planFilePath, options2) {
73970
74261
  return { frontmatter, phases };
73971
74262
  }
73972
74263
  // src/domains/plan-parser/plan-scanner.ts
73973
- import { existsSync as existsSync56, readdirSync as readdirSync10 } from "node:fs";
74264
+ import { existsSync as existsSync57, readdirSync as readdirSync10 } from "node:fs";
73974
74265
  import { join as join125 } from "node:path";
73975
74266
  function scanPlanDir(dir) {
73976
- if (!existsSync56(dir))
74267
+ if (!existsSync57(dir))
73977
74268
  return [];
73978
74269
  try {
73979
- return readdirSync10(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join125(dir, entry.name, "plan.md")).filter(existsSync56);
74270
+ return readdirSync10(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join125(dir, entry.name, "plan.md")).filter(existsSync57);
73980
74271
  } catch {
73981
74272
  return [];
73982
74273
  }
73983
74274
  }
73984
74275
  // src/domains/plan-parser/plan-validator.ts
73985
74276
  var import_gray_matter6 = __toESM(require_gray_matter(), 1);
73986
- import { existsSync as existsSync57, readFileSync as readFileSync24 } from "node:fs";
74277
+ import { existsSync as existsSync58, readFileSync as readFileSync24 } from "node:fs";
73987
74278
  import { basename as basename19, dirname as dirname37 } from "node:path";
73988
74279
  function validatePlanFile(filePath, strict = false) {
73989
74280
  const content = readFileSync24(filePath, "utf8");
@@ -74023,7 +74314,7 @@ function validatePlanFile(filePath, strict = false) {
74023
74314
  });
74024
74315
  }
74025
74316
  for (const phase of phases) {
74026
- if (phase.file && !existsSync57(phase.file)) {
74317
+ if (phase.file && !existsSync58(phase.file)) {
74027
74318
  const fileBasename = basename19(phase.file);
74028
74319
  const refLine = lines.findIndex((l2) => l2.includes(fileBasename));
74029
74320
  issues.push({
@@ -74044,7 +74335,7 @@ function validatePlanFile(filePath, strict = false) {
74044
74335
  // src/domains/plan-parser/plan-writer.ts
74045
74336
  var import_gray_matter7 = __toESM(require_gray_matter(), 1);
74046
74337
  import { mkdirSync as mkdirSync9, readFileSync as readFileSync25, writeFileSync as writeFileSync12 } from "node:fs";
74047
- import { existsSync as existsSync58 } from "node:fs";
74338
+ import { existsSync as existsSync59 } from "node:fs";
74048
74339
  import { basename as basename20, dirname as dirname38, join as join126 } from "node:path";
74049
74340
  function phaseNameToFilename(id, name) {
74050
74341
  const numMatch = /^(\d+)([a-z]*)$/i.exec(id);
@@ -74139,9 +74430,9 @@ function resolvePhaseIds(phases) {
74139
74430
  if (p2.id) {
74140
74431
  const numMatch = /^(\d+)/.exec(p2.id);
74141
74432
  if (numMatch) {
74142
- const n = Number.parseInt(numMatch[1], 10);
74143
- if (n >= nextNum)
74144
- nextNum = n + 1;
74433
+ const n2 = Number.parseInt(numMatch[1], 10);
74434
+ if (n2 >= nextNum)
74435
+ nextNum = n2 + 1;
74145
74436
  }
74146
74437
  return { id: p2.id, name: p2.name };
74147
74438
  }
@@ -74226,7 +74517,7 @@ function updatePhaseStatus(planFile, phaseId, newStatus) {
74226
74517
  writeFileSync12(planFile, updatedContent, "utf8");
74227
74518
  const planDir = dirname38(planFile);
74228
74519
  const phaseFilename = phaseNameFilenameFromTableRow(updatedBody, phaseId, planDir);
74229
- if (phaseFilename && existsSync58(phaseFilename)) {
74520
+ if (phaseFilename && existsSync59(phaseFilename)) {
74230
74521
  updatePhaseFileFrontmatter(phaseFilename, newStatus);
74231
74522
  }
74232
74523
  }
@@ -74266,8 +74557,8 @@ function addPhase(planFile, name, afterId) {
74266
74557
  phaseId = nextSubPhaseId(afterId, existingIds);
74267
74558
  } else {
74268
74559
  const maxNum = existingIds.reduce((max, id) => {
74269
- const n = Number.parseInt(id, 10);
74270
- return Number.isNaN(n) ? max : Math.max(max, n);
74560
+ const n2 = Number.parseInt(id, 10);
74561
+ return Number.isNaN(n2) ? max : Math.max(max, n2);
74271
74562
  }, 0);
74272
74563
  phaseId = String(maxNum + 1);
74273
74564
  }
@@ -74423,7 +74714,7 @@ async function handleValidate(target, options2) {
74423
74714
  }
74424
74715
  async function handleStatus(target, options2) {
74425
74716
  const t = target ? resolve31(target) : null;
74426
- const plansDir = t && existsSync59(t) && statSync8(t).isDirectory() && !existsSync59(join127(t, "plan.md")) ? t : null;
74717
+ const plansDir = t && existsSync60(t) && statSync8(t).isDirectory() && !existsSync60(join127(t, "plan.md")) ? t : null;
74427
74718
  if (plansDir) {
74428
74719
  const planFiles = scanPlanDir(plansDir);
74429
74720
  if (planFiles.length === 0) {
@@ -74654,12 +74945,12 @@ async function handleAddPhase(target, options2) {
74654
74945
  // src/commands/plan/plan-command.ts
74655
74946
  function resolvePlanFile(target) {
74656
74947
  const t = target ? resolve33(target) : process.cwd();
74657
- if (existsSync60(t)) {
74948
+ if (existsSync61(t)) {
74658
74949
  const stat13 = statSync9(t);
74659
74950
  if (stat13.isFile())
74660
74951
  return t;
74661
74952
  const candidate = join128(t, "plan.md");
74662
- if (existsSync60(candidate))
74953
+ if (existsSync61(candidate))
74663
74954
  return candidate;
74664
74955
  }
74665
74956
  if (!target) {
@@ -74667,7 +74958,7 @@ function resolvePlanFile(target) {
74667
74958
  const root = parse4(dir).root;
74668
74959
  while (dir !== root) {
74669
74960
  const candidate = join128(dir, "plan.md");
74670
- if (existsSync60(candidate))
74961
+ if (existsSync61(candidate))
74671
74962
  return candidate;
74672
74963
  dir = dirname41(dir);
74673
74964
  }
@@ -74691,7 +74982,7 @@ function renderPhasesTable(phases) {
74691
74982
  const maxId = Math.max(4, ...phases.map((p2) => p2.phaseId.length));
74692
74983
  const maxName = Math.max(4, ...phases.map((p2) => p2.name.length));
74693
74984
  const maxStatus = 11;
74694
- const pad = (s3, n) => s3.padEnd(n);
74985
+ const pad = (s3, n2) => s3.padEnd(n2);
74695
74986
  const line = `${"-".repeat(maxId + 2)}+${"-".repeat(maxName + 2)}+${"-".repeat(maxStatus + 2)}`;
74696
74987
  console.log(` ${pad("ID", maxId)} | ${pad("Name", maxName)} | Status`);
74697
74988
  console.log(` ${line}`);
@@ -74717,7 +75008,7 @@ async function planCommand(action, target, options2) {
74717
75008
  let resolvedTarget = target;
74718
75009
  if (resolvedAction && !knownActions.has(resolvedAction)) {
74719
75010
  const looksLikePath = resolvedAction.includes("/") || resolvedAction.includes("\\") || resolvedAction.endsWith(".md") || resolvedAction === "." || resolvedAction === "..";
74720
- const existsOnDisk = !looksLikePath && existsSync60(resolve33(resolvedAction));
75011
+ const existsOnDisk = !looksLikePath && existsSync61(resolve33(resolvedAction));
74721
75012
  if (looksLikePath || existsOnDisk) {
74722
75013
  resolvedTarget = resolvedAction;
74723
75014
  resolvedAction = undefined;
@@ -74761,7 +75052,7 @@ init_logger();
74761
75052
  init_logger();
74762
75053
 
74763
75054
  // src/commands/telemetry/shared.ts
74764
- import { existsSync as existsSync61, readFileSync as readFileSync26, readdirSync as readdirSync11 } from "node:fs";
75055
+ import { existsSync as existsSync62, readFileSync as readFileSync26, readdirSync as readdirSync11 } from "node:fs";
74765
75056
  import { homedir as homedir29 } from "node:os";
74766
75057
  import { join as join129 } from "node:path";
74767
75058
  init_token_store();
@@ -74776,7 +75067,7 @@ var TELEMETRY_HOOK_FIELD = "hooks.telemetry";
74776
75067
  var TOKEN_PLACEHOLDER = "__INJECT_AT_RELEASE__";
74777
75068
  function readUserCache() {
74778
75069
  try {
74779
- if (!existsSync61(USER_CACHE_PATH))
75070
+ if (!existsSync62(USER_CACHE_PATH))
74780
75071
  return null;
74781
75072
  const parsed = JSON.parse(readFileSync26(USER_CACHE_PATH, "utf8"));
74782
75073
  if (!parsed || typeof parsed !== "object")
@@ -74788,7 +75079,7 @@ function readUserCache() {
74788
75079
  }
74789
75080
  function countBufferFiles() {
74790
75081
  try {
74791
- if (!existsSync61(EVENT_BUFFER_DIR))
75082
+ if (!existsSync62(EVENT_BUFFER_DIR))
74792
75083
  return 0;
74793
75084
  return readdirSync11(EVENT_BUFFER_DIR).filter((f4) => f4.endsWith(".jsonl")).length;
74794
75085
  } catch {
@@ -74826,8 +75117,8 @@ function collectRuntimeContext() {
74826
75117
  cacheSource: cache3?.source === "gh" || cache3?.source === "manual" ? cache3.source : null,
74827
75118
  bufferFileCount: countBufferFiles(),
74828
75119
  bufferDir: EVENT_BUFFER_DIR,
74829
- rateStateExists: existsSync61(RATE_STATE_PATH),
74830
- userCacheExists: existsSync61(USER_CACHE_PATH),
75120
+ rateStateExists: existsSync62(RATE_STATE_PATH),
75121
+ userCacheExists: existsSync62(USER_CACHE_PATH),
74831
75122
  endpoint,
74832
75123
  tokenConfigured: Boolean(token)
74833
75124
  };
@@ -74988,13 +75279,13 @@ init_logger();
74988
75279
  init_safe_prompts();
74989
75280
  init_takumi_constants();
74990
75281
  var import_picocolors27 = __toESM(require_picocolors(), 1);
74991
- import { existsSync as existsSync62, readdirSync as readdirSync12, rmSync as rmSync8 } from "node:fs";
75282
+ import { existsSync as existsSync63, readdirSync as readdirSync12, rmSync as rmSync8 } from "node:fs";
74992
75283
  import { dirname as dirname42, join as join130 } from "node:path";
74993
75284
  function listPresentManifestNames(installPath) {
74994
75285
  const present = [];
74995
- if (existsSync62(getManifestPath(installPath)))
75286
+ if (existsSync63(getManifestPath(installPath)))
74996
75287
  present.push(MANIFEST_FILENAME);
74997
- if (existsSync62(getLegacyManifestPath(installPath)))
75288
+ if (existsSync63(getLegacyManifestPath(installPath)))
74998
75289
  present.push(LEGACY_MANIFEST_FILENAME);
74999
75290
  return present;
75000
75291
  }
@@ -75948,13 +76239,13 @@ function registerCommands(cli) {
75948
76239
  cli.command("console", "Start local bridge and open session console in browser").option("--port <port>", "Bridge port (default: 8765, auto-bump on conflict)").option("--no-open", "Don't open the browser; print URL only").action(async (options2) => {
75949
76240
  let port;
75950
76241
  if (options2.port !== undefined) {
75951
- const n = Number(options2.port);
75952
- if (!Number.isInteger(n) || n < 0 || n > 65535) {
76242
+ const n2 = Number(options2.port);
76243
+ if (!Number.isInteger(n2) || n2 < 0 || n2 > 65535) {
75953
76244
  console.error(`Invalid --port value: ${options2.port}. Expected integer 0-65535.`);
75954
76245
  process.exitCode = 1;
75955
76246
  return;
75956
76247
  }
75957
- port = n;
76248
+ port = n2;
75958
76249
  }
75959
76250
  await consoleCommand({ port, noOpen: options2.open === false });
75960
76251
  });