@sunasteriskrnd/takumi 1.0.0-dev.35 → 1.0.0-dev.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +703 -408
- 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.
|
|
19818
|
+
version: "1.0.0-dev.37",
|
|
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
|
|
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 (!
|
|
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 (!
|
|
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((
|
|
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
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
60694
|
-
await
|
|
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"
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
61005
|
-
return names.map((
|
|
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
|
|
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
|
|
61232
|
+
import { promises as fs26 } from "node:fs";
|
|
61049
61233
|
async function exists(path10) {
|
|
61050
61234
|
try {
|
|
61051
|
-
await
|
|
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
|
|
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
|
|
61255
|
+
await fs26.writeFile(getObservationsPushedFile(sessionDir), String(now), "utf8");
|
|
61072
61256
|
} catch {}
|
|
61073
61257
|
try {
|
|
61074
|
-
await
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
61643
|
+
const stat8 = await fs28.stat(path10);
|
|
61460
61644
|
if (now - stat8.mtimeMs > STALE_LOCK_MS) {
|
|
61461
|
-
await
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 (!
|
|
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 (!
|
|
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
|
|
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 (!
|
|
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
|
|
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 = (
|
|
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) {
|
|
@@ -62804,6 +63093,10 @@ var HOOK_HANDLERS = [
|
|
|
62804
63093
|
metricsRecord,
|
|
62805
63094
|
metricsFlush
|
|
62806
63095
|
];
|
|
63096
|
+
function shortHandlerName(handler) {
|
|
63097
|
+
const prefix = `${handler.category}-`;
|
|
63098
|
+
return handler.name.startsWith(prefix) ? handler.name.slice(prefix.length) : handler.name;
|
|
63099
|
+
}
|
|
62807
63100
|
var CATEGORY_VALUES2 = new Set([
|
|
62808
63101
|
"guard",
|
|
62809
63102
|
"session",
|
|
@@ -62831,7 +63124,7 @@ function selectHandlers(selector, event, handlers3 = HOOK_HANDLERS) {
|
|
|
62831
63124
|
return handlers3.filter((m2) => {
|
|
62832
63125
|
if (m2.category !== selector.category)
|
|
62833
63126
|
return false;
|
|
62834
|
-
if (selector.handlerName !== null && m2.name !== selector.handlerName)
|
|
63127
|
+
if (selector.handlerName !== null && m2.name !== selector.handlerName && shortHandlerName(m2) !== selector.handlerName)
|
|
62835
63128
|
return false;
|
|
62836
63129
|
return m2.events.includes(event);
|
|
62837
63130
|
});
|
|
@@ -63271,7 +63564,7 @@ init_hooks_settings_merger();
|
|
|
63271
63564
|
|
|
63272
63565
|
// src/commands/portable/settings-write-with-confirm.ts
|
|
63273
63566
|
init_safe_prompts();
|
|
63274
|
-
import { existsSync as
|
|
63567
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync7, readFileSync as readFileSync18, renameSync as renameSync3, rmSync as rmSync4, writeFileSync as writeFileSync10 } from "node:fs";
|
|
63275
63568
|
import { dirname as dirname29 } from "node:path";
|
|
63276
63569
|
|
|
63277
63570
|
// node_modules/diff/libesm/diff/base.js
|
|
@@ -64444,7 +64737,7 @@ var EMPTY_RESULT = (status2) => ({
|
|
|
64444
64737
|
backupPath: null
|
|
64445
64738
|
});
|
|
64446
64739
|
function readCurrent(path10) {
|
|
64447
|
-
if (!
|
|
64740
|
+
if (!existsSync50(path10))
|
|
64448
64741
|
return { kind: "missing" };
|
|
64449
64742
|
let raw = "";
|
|
64450
64743
|
try {
|
|
@@ -64561,7 +64854,7 @@ init_dist2();
|
|
|
64561
64854
|
// src/commands/hooks/lib/agent-target-picker.ts
|
|
64562
64855
|
init_safe_prompts();
|
|
64563
64856
|
init_dist2();
|
|
64564
|
-
import { existsSync as
|
|
64857
|
+
import { existsSync as existsSync51 } from "node:fs";
|
|
64565
64858
|
|
|
64566
64859
|
// src/commands/hooks/lib/settings-path-resolver.ts
|
|
64567
64860
|
import { lstatSync as lstatSync3, realpathSync as realpathSync3 } from "node:fs";
|
|
@@ -64600,7 +64893,7 @@ function probe(global3) {
|
|
|
64600
64893
|
return {
|
|
64601
64894
|
agent,
|
|
64602
64895
|
path: location2.realPath,
|
|
64603
|
-
exists:
|
|
64896
|
+
exists: existsSync51(location2.realPath)
|
|
64604
64897
|
};
|
|
64605
64898
|
});
|
|
64606
64899
|
}
|
|
@@ -64672,7 +64965,7 @@ function buildHookExecCommand(handler, event, agent, bin = DEFAULT_HOOK_BIN, fla
|
|
|
64672
64965
|
bin,
|
|
64673
64966
|
"hook-exec",
|
|
64674
64967
|
"--hook",
|
|
64675
|
-
`${handler.category}.${handler
|
|
64968
|
+
`${handler.category}.${shortHandlerName(handler)}`,
|
|
64676
64969
|
"--event",
|
|
64677
64970
|
kebab,
|
|
64678
64971
|
"-a",
|
|
@@ -64687,6 +64980,8 @@ function buildHookExecCommand(handler, event, agent, bin = DEFAULT_HOOK_BIN, fla
|
|
|
64687
64980
|
function planEntry(handler, event, agent, bin, flags) {
|
|
64688
64981
|
if (agent === "codex" && !codexSupportsEvent(event))
|
|
64689
64982
|
return null;
|
|
64983
|
+
if (agent !== "codex" && handler.codexOnlyEvents?.includes(event))
|
|
64984
|
+
return null;
|
|
64690
64985
|
const command = buildHookExecCommand(handler, event, agent, bin, flags);
|
|
64691
64986
|
if (!command)
|
|
64692
64987
|
return null;
|
|
@@ -64721,7 +65016,7 @@ function buildHookSection(agent, bin, flags = {}, handlers3 = HOOK_HANDLERS) {
|
|
|
64721
65016
|
|
|
64722
65017
|
// src/commands/hooks/uninstall-handler.ts
|
|
64723
65018
|
init_logger();
|
|
64724
|
-
import { existsSync as
|
|
65019
|
+
import { existsSync as existsSync52, mkdirSync as mkdirSync8, readFileSync as readFileSync19, renameSync as renameSync4, rmSync as rmSync5, writeFileSync as writeFileSync11 } from "node:fs";
|
|
64725
65020
|
import { dirname as dirname30 } from "node:path";
|
|
64726
65021
|
var AGENT_DISPLAY2 = {
|
|
64727
65022
|
claude: "Claude Code",
|
|
@@ -64781,7 +65076,7 @@ async function uninstallForAgent(agent, options2) {
|
|
|
64781
65076
|
removed: 0,
|
|
64782
65077
|
dryRun: Boolean(options2.dryRun)
|
|
64783
65078
|
};
|
|
64784
|
-
if (!
|
|
65079
|
+
if (!existsSync52(location2.realPath)) {
|
|
64785
65080
|
return result;
|
|
64786
65081
|
}
|
|
64787
65082
|
let parsed;
|
|
@@ -65000,7 +65295,7 @@ async function installHook(options2) {
|
|
|
65000
65295
|
// src/commands/hooks/status.ts
|
|
65001
65296
|
init_takumi_config_manager();
|
|
65002
65297
|
init_logger();
|
|
65003
|
-
import { existsSync as
|
|
65298
|
+
import { existsSync as existsSync53, readFileSync as readFileSync20 } from "node:fs";
|
|
65004
65299
|
var AGENT_DISPLAY4 = { claude: "Claude Code", codex: "Codex" };
|
|
65005
65300
|
var NEW_SHAPE = /\bhook-exec\b.*--hook\s+(guard|session|convention|extension|metrics|perf)\.(\S+).*-a\s+(claude|codex)(?![\w-])/;
|
|
65006
65301
|
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 +65325,7 @@ async function statusForAgent(agent, options2, cwd2 = process.cwd()) {
|
|
|
65030
65325
|
const result = {
|
|
65031
65326
|
agent,
|
|
65032
65327
|
settingsPath: location2.realPath,
|
|
65033
|
-
exists:
|
|
65328
|
+
exists: existsSync53(location2.realPath),
|
|
65034
65329
|
shape: "none",
|
|
65035
65330
|
byCategory: {},
|
|
65036
65331
|
newEntryCount: 0,
|
|
@@ -65068,7 +65363,7 @@ function report(result) {
|
|
|
65068
65363
|
logger.info(`[hooks] ${label}: no settings file at ${result.settingsPath}`);
|
|
65069
65364
|
return;
|
|
65070
65365
|
}
|
|
65071
|
-
const categories = Object.entries(result.byCategory).sort(([a3], [b3]) => a3.localeCompare(b3)).map(([cat,
|
|
65366
|
+
const categories = Object.entries(result.byCategory).sort(([a3], [b3]) => a3.localeCompare(b3)).map(([cat, n2]) => `${cat}=${n2}`).join(", ");
|
|
65072
65367
|
const parts = [`shape=${result.shape}`, `${result.newEntryCount} hook-exec entries`];
|
|
65073
65368
|
if (result.legacyEntryCount > 0)
|
|
65074
65369
|
parts.push(`${result.legacyEntryCount} legacy entries`);
|
|
@@ -66402,7 +66697,7 @@ async function dispatchInstallers(ctx, targetAgents2, lifecycle) {
|
|
|
66402
66697
|
init_logger();
|
|
66403
66698
|
// src/domains/installation/download-extractor.ts
|
|
66404
66699
|
init_auth_client();
|
|
66405
|
-
import * as
|
|
66700
|
+
import * as fs30 from "node:fs";
|
|
66406
66701
|
import * as path10 from "node:path";
|
|
66407
66702
|
|
|
66408
66703
|
// src/domains/github/auth-prompt.ts
|
|
@@ -67233,18 +67528,18 @@ var D = class extends Ti {
|
|
|
67233
67528
|
if (t === "close") {
|
|
67234
67529
|
if (this[Ne] = true, !this[rt] && !this[w3])
|
|
67235
67530
|
return false;
|
|
67236
|
-
let
|
|
67237
|
-
return this.removeAllListeners("close"),
|
|
67531
|
+
let n2 = super.emit("close");
|
|
67532
|
+
return this.removeAllListeners("close"), n2;
|
|
67238
67533
|
} else if (t === "error") {
|
|
67239
67534
|
this[jt] = i, super.emit(Ri, i);
|
|
67240
|
-
let
|
|
67241
|
-
return this[j2](),
|
|
67535
|
+
let n2 = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : false;
|
|
67536
|
+
return this[j2](), n2;
|
|
67242
67537
|
} else if (t === "resume") {
|
|
67243
|
-
let
|
|
67244
|
-
return this[j2](),
|
|
67538
|
+
let n2 = super.emit("resume");
|
|
67539
|
+
return this[j2](), n2;
|
|
67245
67540
|
} else if (t === "finish" || t === "prefinish") {
|
|
67246
|
-
let
|
|
67247
|
-
return this.removeAllListeners(t),
|
|
67541
|
+
let n2 = super.emit(t);
|
|
67542
|
+
return this.removeAllListeners(t), n2;
|
|
67248
67543
|
}
|
|
67249
67544
|
let r2 = super.emit(t, ...e2);
|
|
67250
67545
|
return this[j2](), r2;
|
|
@@ -67302,15 +67597,15 @@ var D = class extends Ti {
|
|
|
67302
67597
|
return Promise.resolve({ done: false, value: r2 });
|
|
67303
67598
|
if (this[q3])
|
|
67304
67599
|
return e2();
|
|
67305
|
-
let
|
|
67600
|
+
let n2, o2, h2 = (d3) => {
|
|
67306
67601
|
this.off("data", a3), this.off("end", l2), this.off(w3, c2), e2(), o2(d3);
|
|
67307
67602
|
}, a3 = (d3) => {
|
|
67308
|
-
this.off("error", h2), this.off("end", l2), this.off(w3, c2), this.pause(),
|
|
67603
|
+
this.off("error", h2), this.off("end", l2), this.off(w3, c2), this.pause(), n2({ value: d3, done: !!this[q3] });
|
|
67309
67604
|
}, l2 = () => {
|
|
67310
|
-
this.off("error", h2), this.off("data", a3), this.off(w3, c2), e2(),
|
|
67605
|
+
this.off("error", h2), this.off("data", a3), this.off(w3, c2), e2(), n2({ done: true, value: undefined });
|
|
67311
67606
|
}, c2 = () => h2(new Error("stream destroyed"));
|
|
67312
67607
|
return new Promise((d3, S3) => {
|
|
67313
|
-
o2 = S3,
|
|
67608
|
+
o2 = S3, n2 = d3, this.once(w3, c2), this.once("error", h2), this.once("end", l2), this.once("data", a3);
|
|
67314
67609
|
});
|
|
67315
67610
|
}, throw: e2, return: e2, [Symbol.asyncIterator]() {
|
|
67316
67611
|
return this;
|
|
@@ -67601,9 +67896,9 @@ var re2 = (s = {}) => {
|
|
|
67601
67896
|
}
|
|
67602
67897
|
return t.chmod === undefined && t.noChmod === false && (t.chmod = true), delete t.noChmod, t;
|
|
67603
67898
|
};
|
|
67604
|
-
var K3 = (s, t, e2, i, r2) => Object.assign((
|
|
67605
|
-
Array.isArray(
|
|
67606
|
-
let a3 = re2(
|
|
67899
|
+
var K3 = (s, t, e2, i, r2) => Object.assign((n2 = [], o2, h2) => {
|
|
67900
|
+
Array.isArray(n2) && (o2 = n2, n2 = {}), typeof o2 == "function" && (h2 = o2, o2 = undefined), o2 = o2 ? Array.from(o2) : [];
|
|
67901
|
+
let a3 = re2(n2);
|
|
67607
67902
|
if (r2?.(a3, o2), As(a3)) {
|
|
67608
67903
|
if (typeof h2 == "function")
|
|
67609
67904
|
throw new TypeError("callback not supported for sync tar functions");
|
|
@@ -67696,7 +67991,7 @@ var ne2 = class extends D {
|
|
|
67696
67991
|
if (typeof e2 == "function" && (i = e2, e2 = "utf8"), typeof t == "string" && (t = gt.from(t, e2)), this.#t)
|
|
67697
67992
|
return;
|
|
67698
67993
|
Mi(this.#e, "zlib binding closed");
|
|
67699
|
-
let r2 = this.#e._handle,
|
|
67994
|
+
let r2 = this.#e._handle, n2 = r2.close;
|
|
67700
67995
|
r2.close = () => {};
|
|
67701
67996
|
let o2 = this.#e.close;
|
|
67702
67997
|
this.#e.close = () => {}, ki(true);
|
|
@@ -67707,7 +68002,7 @@ var ne2 = class extends D {
|
|
|
67707
68002
|
} catch (l2) {
|
|
67708
68003
|
ki(false), this.#o(new Gt(l2, this.write));
|
|
67709
68004
|
} finally {
|
|
67710
|
-
this.#e && (this.#e._handle = r2, r2.close =
|
|
68005
|
+
this.#e && (this.#e._handle = r2, r2.close = n2, this.#e.close = o2, this.#e.removeAllListeners("error"));
|
|
67711
68006
|
}
|
|
67712
68007
|
this.#e && this.#e.on("error", (l2) => this.#o(new Gt(l2, this.write)));
|
|
67713
68008
|
let a3;
|
|
@@ -67737,8 +68032,8 @@ var Be = class extends ne2 {
|
|
|
67737
68032
|
if (this.#t !== t || this.#i !== e2) {
|
|
67738
68033
|
this.flush(M3.Z_SYNC_FLUSH), Mi(this.handle, "zlib binding closed");
|
|
67739
68034
|
let i = this.handle.flush;
|
|
67740
|
-
this.handle.flush = (r2,
|
|
67741
|
-
typeof r2 == "function" && (
|
|
68035
|
+
this.handle.flush = (r2, n2) => {
|
|
68036
|
+
typeof r2 == "function" && (n2 = r2, r2 = this.flushFlag), this.flush(r2), n2?.();
|
|
67742
68037
|
};
|
|
67743
68038
|
try {
|
|
67744
68039
|
this.handle.params(t, e2);
|
|
@@ -67825,8 +68120,8 @@ var Bs = (s) => {
|
|
|
67825
68120
|
};
|
|
67826
68121
|
var rn = (s) => {
|
|
67827
68122
|
for (var t = s.length, e2 = 0, i = false, r2 = t - 1;r2 > -1; r2--) {
|
|
67828
|
-
var
|
|
67829
|
-
i ? o2 = Ps(
|
|
68123
|
+
var n2 = Number(s[r2]), o2;
|
|
68124
|
+
i ? o2 = Ps(n2) : n2 === 0 ? o2 = n2 : (i = true, o2 = zs(n2)), o2 !== 0 && (e2 -= o2 * Math.pow(256, t - r2 - 1));
|
|
67830
68125
|
}
|
|
67831
68126
|
return e2;
|
|
67832
68127
|
};
|
|
@@ -67874,8 +68169,8 @@ var F = class {
|
|
|
67874
68169
|
if (e2 || (e2 = 0), !t || !(t.length >= e2 + 512))
|
|
67875
68170
|
throw new Error("need 512 bytes for header");
|
|
67876
68171
|
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
|
|
67878
|
-
if (oe2(
|
|
68172
|
+
let n2 = Tt(t, e2 + 156, 1);
|
|
68173
|
+
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
68174
|
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
68175
|
let h2 = Tt(t, e2 + 345, 155);
|
|
67881
68176
|
this.path = h2 + "/" + this.path;
|
|
@@ -67896,8 +68191,8 @@ var F = class {
|
|
|
67896
68191
|
encode(t, e2 = 0) {
|
|
67897
68192
|
if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e2 + 512))
|
|
67898
68193
|
throw new Error("need 512 bytes for header");
|
|
67899
|
-
let i = this.ctime || this.atime ? 130 : 155, r2 = an(this.path || "", i),
|
|
67900
|
-
this.needPax = !!r2[2], this.needPax = xt(t, e2, 100,
|
|
68194
|
+
let i = this.ctime || this.atime ? 130 : 155, r2 = an(this.path || "", i), n2 = r2[0], o2 = r2[1];
|
|
68195
|
+
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
68196
|
let h2 = 256;
|
|
67902
68197
|
for (let a3 = e2;a3 < e2 + 148; a3++)
|
|
67903
68198
|
h2 += t[a3];
|
|
@@ -67922,17 +68217,17 @@ var F = class {
|
|
|
67922
68217
|
}
|
|
67923
68218
|
};
|
|
67924
68219
|
var an = (s, t) => {
|
|
67925
|
-
let i = s, r2 = "",
|
|
68220
|
+
let i = s, r2 = "", n2, o2 = Zt.parse(s).root || ".";
|
|
67926
68221
|
if (Buffer.byteLength(i) < 100)
|
|
67927
|
-
|
|
68222
|
+
n2 = [i, r2, false];
|
|
67928
68223
|
else {
|
|
67929
68224
|
r2 = Zt.dirname(i), i = Zt.basename(i);
|
|
67930
68225
|
do
|
|
67931
|
-
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r2) <= t ?
|
|
67932
|
-
while (r2 !== o2 &&
|
|
67933
|
-
|
|
68226
|
+
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));
|
|
68227
|
+
while (r2 !== o2 && n2 === undefined);
|
|
68228
|
+
n2 || (n2 = [s.slice(0, 99), "", true]);
|
|
67934
68229
|
}
|
|
67935
|
-
return
|
|
68230
|
+
return n2;
|
|
67936
68231
|
};
|
|
67937
68232
|
var Tt = (s, t, e2) => s.subarray(t, t + e2).toString("utf8").replace(/\0.*/, "");
|
|
67938
68233
|
var Pi = (s, t, e2) => ln(at(s, t, e2));
|
|
@@ -67974,11 +68269,11 @@ var ct = class s {
|
|
|
67974
68269
|
if (t === "")
|
|
67975
68270
|
return Buffer.allocUnsafe(0);
|
|
67976
68271
|
let e2 = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e2 / 512), r2 = Buffer.allocUnsafe(i);
|
|
67977
|
-
for (let
|
|
67978
|
-
r2[
|
|
68272
|
+
for (let n2 = 0;n2 < 512; n2++)
|
|
68273
|
+
r2[n2] = 0;
|
|
67979
68274
|
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
|
|
67981
|
-
r2[
|
|
68275
|
+
for (let n2 = e2 + 512;n2 < r2.length; n2++)
|
|
68276
|
+
r2[n2] = 0;
|
|
67982
68277
|
return r2;
|
|
67983
68278
|
}
|
|
67984
68279
|
encodeBody() {
|
|
@@ -67988,8 +68283,8 @@ var ct = class s {
|
|
|
67988
68283
|
if (this[t] === undefined)
|
|
67989
68284
|
return "";
|
|
67990
68285
|
let e2 = this[t], i = e2 instanceof Date ? e2.getTime() / 1000 : e2, r2 = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
|
|
67991
|
-
`,
|
|
67992
|
-
return
|
|
68286
|
+
`, n2 = Buffer.byteLength(r2), o2 = Math.floor(Math.log(n2) / Math.log(10)) + 1;
|
|
68287
|
+
return n2 + o2 >= Math.pow(10, o2) && (o2 += 1), o2 + n2 + r2;
|
|
67993
68288
|
}
|
|
67994
68289
|
static parse(t, e2, i = false) {
|
|
67995
68290
|
return new s(Sn(yn(t), e2), i);
|
|
@@ -68006,8 +68301,8 @@ var Rn = (s2, t) => {
|
|
|
68006
68301
|
let i = t.split("="), r2 = i.shift();
|
|
68007
68302
|
if (!r2)
|
|
68008
68303
|
return s2;
|
|
68009
|
-
let
|
|
68010
|
-
return s2[
|
|
68304
|
+
let n2 = r2.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o2 = i.join("=");
|
|
68305
|
+
return s2[n2] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n2) ? new Date(Number(o2) * 1000) : /^[0-9]+$/.test(o2) ? +o2 : o2, s2;
|
|
68011
68306
|
};
|
|
68012
68307
|
var bn = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
68013
68308
|
var f3 = bn !== "win32" ? (s2) => s2 : (s2) => s2 && s2.replaceAll(/\\/g, "/");
|
|
@@ -68176,16 +68471,16 @@ var st = class extends _n {
|
|
|
68176
68471
|
else if (!/^(Symbolic)?Link$/.test(r2) && !/^(Global)?ExtendedHeader$/.test(r2) && i.linkpath)
|
|
68177
68472
|
this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
|
|
68178
68473
|
else {
|
|
68179
|
-
let
|
|
68474
|
+
let n2 = this[Nt] = new Yt(i, this[V2], this[ae2]);
|
|
68180
68475
|
if (!this[Dt])
|
|
68181
|
-
if (
|
|
68476
|
+
if (n2.remain) {
|
|
68182
68477
|
let o2 = () => {
|
|
68183
|
-
|
|
68478
|
+
n2.invalid || (this[Dt] = true);
|
|
68184
68479
|
};
|
|
68185
|
-
|
|
68480
|
+
n2.on("end", o2);
|
|
68186
68481
|
} else
|
|
68187
68482
|
this[Dt] = true;
|
|
68188
|
-
|
|
68483
|
+
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
68484
|
}
|
|
68190
68485
|
}
|
|
68191
68486
|
}
|
|
@@ -68216,8 +68511,8 @@ var st = class extends _n {
|
|
|
68216
68511
|
let i = this[Nt];
|
|
68217
68512
|
if (!i)
|
|
68218
68513
|
throw new Error("attempt to consume body without entry??");
|
|
68219
|
-
let r2 = i.blockRemain ?? 0,
|
|
68220
|
-
return i.write(
|
|
68514
|
+
let r2 = i.blockRemain ?? 0, n2 = r2 >= t.length && e2 === 0 ? t : t.subarray(e2, e2 + r2);
|
|
68515
|
+
return i.write(n2), i.blockRemain || (this[B2] = "header", this[Nt] = undefined, i.end()), n2.length;
|
|
68221
68516
|
}
|
|
68222
68517
|
[Ws](t, e2) {
|
|
68223
68518
|
let i = this[Nt], r2 = this[Wi](t, e2);
|
|
@@ -68293,8 +68588,8 @@ var st = class extends _n {
|
|
|
68293
68588
|
}
|
|
68294
68589
|
}
|
|
68295
68590
|
this[Kt] = true, this[y3] ? this[y3].write(t) : this[Ve](t), this[Kt] = false;
|
|
68296
|
-
let
|
|
68297
|
-
return !
|
|
68591
|
+
let n2 = this[it].length > 0 ? false : this[et] ? this[et].flowing : true;
|
|
68592
|
+
return !n2 && this[it].length === 0 && this[et]?.once("drain", () => this.emit("drain")), i?.(), n2;
|
|
68298
68593
|
}
|
|
68299
68594
|
[Gi](t) {
|
|
68300
68595
|
t && !this[ut] && (this[p] = this[p] ? Buffer.concat([this[p], t]) : t);
|
|
@@ -68367,30 +68662,30 @@ var Nn = (s2) => {
|
|
|
68367
68662
|
} : (e2) => e2.resume();
|
|
68368
68663
|
};
|
|
68369
68664
|
var Ki = (s2, t) => {
|
|
68370
|
-
let e2 = new Map(t.map((
|
|
68371
|
-
let h2 = o2 || Ln(
|
|
68372
|
-
if (
|
|
68665
|
+
let e2 = new Map(t.map((n2) => [mt(n2), true])), i = s2.filter, r2 = (n2, o2 = "") => {
|
|
68666
|
+
let h2 = o2 || Ln(n2).root || ".", a3;
|
|
68667
|
+
if (n2 === h2)
|
|
68373
68668
|
a3 = false;
|
|
68374
68669
|
else {
|
|
68375
|
-
let l2 = e2.get(
|
|
68376
|
-
a3 = l2 !== undefined ? l2 : r2(xn(
|
|
68670
|
+
let l2 = e2.get(n2);
|
|
68671
|
+
a3 = l2 !== undefined ? l2 : r2(xn(n2), h2);
|
|
68377
68672
|
}
|
|
68378
|
-
return e2.set(
|
|
68673
|
+
return e2.set(n2, a3), a3;
|
|
68379
68674
|
};
|
|
68380
|
-
s2.filter = i ? (
|
|
68675
|
+
s2.filter = i ? (n2, o2) => i(n2, o2) && r2(mt(n2)) : (n2) => r2(mt(n2));
|
|
68381
68676
|
};
|
|
68382
68677
|
var An = (s2) => {
|
|
68383
68678
|
let t = new st(s2), e2 = s2.file, i;
|
|
68384
68679
|
try {
|
|
68385
68680
|
i = Vt.openSync(e2, "r");
|
|
68386
|
-
let r2 = Vt.fstatSync(i),
|
|
68387
|
-
if (r2.size <
|
|
68681
|
+
let r2 = Vt.fstatSync(i), n2 = s2.maxReadSize || 16 * 1024 * 1024;
|
|
68682
|
+
if (r2.size < n2) {
|
|
68388
68683
|
let o2 = Buffer.allocUnsafe(r2.size), h2 = Vt.readSync(i, o2, 0, r2.size, 0);
|
|
68389
68684
|
t.end(h2 === o2.byteLength ? o2 : o2.subarray(0, h2));
|
|
68390
68685
|
} else {
|
|
68391
|
-
let o2 = 0, h2 = Buffer.allocUnsafe(
|
|
68686
|
+
let o2 = 0, h2 = Buffer.allocUnsafe(n2);
|
|
68392
68687
|
for (;o2 < r2.size; ) {
|
|
68393
|
-
let a3 = Vt.readSync(i, h2, 0,
|
|
68688
|
+
let a3 = Vt.readSync(i, h2, 0, n2, o2);
|
|
68394
68689
|
if (a3 === 0)
|
|
68395
68690
|
break;
|
|
68396
68691
|
o2 += a3, t.write(h2.subarray(0, a3));
|
|
@@ -68496,8 +68791,8 @@ var de2 = class extends D {
|
|
|
68496
68791
|
o2 && typeof h2 == "string" && (this.path = h2, r2 = o2);
|
|
68497
68792
|
}
|
|
68498
68793
|
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
|
|
68500
|
-
|
|
68794
|
+
let n2 = this.statCache.get(this.absolute);
|
|
68795
|
+
n2 ? this[ei](n2) : this[Qi]();
|
|
68501
68796
|
}
|
|
68502
68797
|
warn(t, e2, i = {}) {
|
|
68503
68798
|
return Lt(this, t, e2, i);
|
|
@@ -68592,10 +68887,10 @@ var de2 = class extends D {
|
|
|
68592
68887
|
this.buf = Buffer.allocUnsafe(e2), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ti]();
|
|
68593
68888
|
}
|
|
68594
68889
|
[ti]() {
|
|
68595
|
-
let { fd: t, buf: e2, offset: i, length: r2, pos:
|
|
68890
|
+
let { fd: t, buf: e2, offset: i, length: r2, pos: n2 } = this;
|
|
68596
68891
|
if (t === undefined || e2 === undefined)
|
|
68597
68892
|
throw new Error("cannot read file without first opening");
|
|
68598
|
-
$2.read(t, e2, i, r2,
|
|
68893
|
+
$2.read(t, e2, i, r2, n2, (o2, h2) => {
|
|
68599
68894
|
if (o2)
|
|
68600
68895
|
return this[pt](() => this.emit("error", o2));
|
|
68601
68896
|
this[Ji](h2);
|
|
@@ -68653,10 +68948,10 @@ var si = class extends de2 {
|
|
|
68653
68948
|
[ti]() {
|
|
68654
68949
|
let t = true;
|
|
68655
68950
|
try {
|
|
68656
|
-
let { fd: e2, buf: i, offset: r2, length:
|
|
68951
|
+
let { fd: e2, buf: i, offset: r2, length: n2, pos: o2 } = this;
|
|
68657
68952
|
if (e2 === undefined || i === undefined)
|
|
68658
68953
|
throw new Error("fd and buf must be set in READ method");
|
|
68659
|
-
let h2 = $2.readSync(e2, i, r2,
|
|
68954
|
+
let h2 = $2.readSync(e2, i, r2, n2, o2);
|
|
68660
68955
|
this[Ji](h2), t = false;
|
|
68661
68956
|
} finally {
|
|
68662
68957
|
if (t)
|
|
@@ -68710,12 +69005,12 @@ var ri = class extends D {
|
|
|
68710
69005
|
if (r2 === "Unsupported")
|
|
68711
69006
|
throw new Error("writing entry that should be ignored");
|
|
68712
69007
|
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
|
|
69008
|
+
let n2 = false;
|
|
68714
69009
|
if (!this.preservePaths) {
|
|
68715
69010
|
let [h2, a3] = ce2(this.path);
|
|
68716
|
-
h2 && typeof a3 == "string" && (this.path = a3,
|
|
69011
|
+
h2 && typeof a3 == "string" && (this.path = a3, n2 = h2);
|
|
68717
69012
|
}
|
|
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 }),
|
|
69013
|
+
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
69014
|
let o2 = this.header?.block;
|
|
68720
69015
|
if (!o2)
|
|
68721
69016
|
throw new Error("failed to encode header");
|
|
@@ -68842,8 +69137,8 @@ var ni = class s2 {
|
|
|
68842
69137
|
r2 = this.head.next, i = this.head.value;
|
|
68843
69138
|
else
|
|
68844
69139
|
throw new TypeError("Reduce of empty list with no initial value");
|
|
68845
|
-
for (var
|
|
68846
|
-
i = t(i, r2.value,
|
|
69140
|
+
for (var n2 = 0;r2; n2++)
|
|
69141
|
+
i = t(i, r2.value, n2), r2 = r2.next;
|
|
68847
69142
|
return i;
|
|
68848
69143
|
}
|
|
68849
69144
|
reduceReverse(t, e2) {
|
|
@@ -68854,8 +69149,8 @@ var ni = class s2 {
|
|
|
68854
69149
|
r2 = this.tail.prev, i = this.tail.value;
|
|
68855
69150
|
else
|
|
68856
69151
|
throw new TypeError("Reduce of empty list with no initial value");
|
|
68857
|
-
for (let
|
|
68858
|
-
i = t(i, r2.value,
|
|
69152
|
+
for (let n2 = this.length - 1;r2; n2--)
|
|
69153
|
+
i = t(i, r2.value, n2), r2 = r2.prev;
|
|
68859
69154
|
return i;
|
|
68860
69155
|
}
|
|
68861
69156
|
toArray() {
|
|
@@ -68876,10 +69171,10 @@ var ni = class s2 {
|
|
|
68876
69171
|
if (e2 < t || e2 < 0)
|
|
68877
69172
|
return i;
|
|
68878
69173
|
t < 0 && (t = 0), e2 > this.length && (e2 = this.length);
|
|
68879
|
-
let r2 = this.head,
|
|
68880
|
-
for (
|
|
69174
|
+
let r2 = this.head, n2 = 0;
|
|
69175
|
+
for (n2 = 0;r2 && n2 < t; n2++)
|
|
68881
69176
|
r2 = r2.next;
|
|
68882
|
-
for (;r2 &&
|
|
69177
|
+
for (;r2 && n2 < e2; n2++, r2 = r2.next)
|
|
68883
69178
|
i.push(r2.value);
|
|
68884
69179
|
return i;
|
|
68885
69180
|
}
|
|
@@ -68889,11 +69184,11 @@ var ni = class s2 {
|
|
|
68889
69184
|
if (e2 < t || e2 < 0)
|
|
68890
69185
|
return i;
|
|
68891
69186
|
t < 0 && (t = 0), e2 > this.length && (e2 = this.length);
|
|
68892
|
-
let r2 = this.length,
|
|
68893
|
-
for (;
|
|
68894
|
-
|
|
68895
|
-
for (;
|
|
68896
|
-
i.push(
|
|
69187
|
+
let r2 = this.length, n2 = this.tail;
|
|
69188
|
+
for (;n2 && r2 > e2; r2--)
|
|
69189
|
+
n2 = n2.prev;
|
|
69190
|
+
for (;n2 && r2 > t; r2--, n2 = n2.prev)
|
|
69191
|
+
i.push(n2.value);
|
|
68897
69192
|
return i;
|
|
68898
69193
|
}
|
|
68899
69194
|
splice(t, e2 = 0, ...i) {
|
|
@@ -68901,13 +69196,13 @@ var ni = class s2 {
|
|
|
68901
69196
|
let r2 = this.head;
|
|
68902
69197
|
for (let o2 = 0;r2 && o2 < t; o2++)
|
|
68903
69198
|
r2 = r2.next;
|
|
68904
|
-
let
|
|
69199
|
+
let n2 = [];
|
|
68905
69200
|
for (let o2 = 0;r2 && o2 < e2; o2++)
|
|
68906
|
-
|
|
69201
|
+
n2.push(r2.value), r2 = this.removeNode(r2);
|
|
68907
69202
|
r2 ? r2 !== this.tail && (r2 = r2.prev) : r2 = this.tail;
|
|
68908
69203
|
for (let o2 of i)
|
|
68909
69204
|
r2 = Bn(this, r2, o2);
|
|
68910
|
-
return
|
|
69205
|
+
return n2;
|
|
68911
69206
|
}
|
|
68912
69207
|
reverse() {
|
|
68913
69208
|
let t = this.head, e2 = this.tail;
|
|
@@ -68919,8 +69214,8 @@ var ni = class s2 {
|
|
|
68919
69214
|
}
|
|
68920
69215
|
};
|
|
68921
69216
|
function Bn(s3, t, e2) {
|
|
68922
|
-
let i = t, r2 = t ? t.next : s3.head,
|
|
68923
|
-
return
|
|
69217
|
+
let i = t, r2 = t ? t.next : s3.head, n2 = new ue2(e2, i, r2, s3);
|
|
69218
|
+
return n2.next === undefined && (s3.tail = n2), n2.prev === undefined && (s3.head = n2), s3.length++, n2;
|
|
68924
69219
|
}
|
|
68925
69220
|
function Pn(s3, t) {
|
|
68926
69221
|
s3.tail = new ue2(t, s3.tail, undefined, s3), s3.head || (s3.head = s3.tail), s3.length++;
|
|
@@ -69115,7 +69410,7 @@ var Et = class extends D {
|
|
|
69115
69410
|
}
|
|
69116
69411
|
[li](t) {
|
|
69117
69412
|
t.piped = true, t.readdir && t.readdir.forEach((r2) => {
|
|
69118
|
-
let
|
|
69413
|
+
let n2 = t.path, o2 = n2 === "./" ? "" : n2.replace(/\/*$/, "/");
|
|
69119
69414
|
this[hi](o2 + r2);
|
|
69120
69415
|
});
|
|
69121
69416
|
let e2 = t.entry, i = this.zip;
|
|
@@ -69151,7 +69446,7 @@ var kt = class extends Et {
|
|
|
69151
69446
|
[li](t) {
|
|
69152
69447
|
let e2 = t.entry, i = this.zip;
|
|
69153
69448
|
if (t.readdir && t.readdir.forEach((r2) => {
|
|
69154
|
-
let
|
|
69449
|
+
let n2 = t.path, o2 = n2 === "./" ? "" : n2.replace(/\/*$/, "/");
|
|
69155
69450
|
this[hi](o2 + r2);
|
|
69156
69451
|
}), !e2)
|
|
69157
69452
|
throw new Error("Cannot pipe without source");
|
|
@@ -69169,10 +69464,10 @@ var Un = (s3, t) => {
|
|
|
69169
69464
|
var Hn = (s3, t) => {
|
|
69170
69465
|
let e2 = new Et(s3), i = new tt(s3.file, { mode: s3.mode || 438 });
|
|
69171
69466
|
e2.pipe(i);
|
|
69172
|
-
let r2 = new Promise((
|
|
69173
|
-
i.on("error", o2), i.on("close",
|
|
69467
|
+
let r2 = new Promise((n2, o2) => {
|
|
69468
|
+
i.on("error", o2), i.on("close", n2), e2.on("error", o2);
|
|
69174
69469
|
});
|
|
69175
|
-
return hr(e2, t).catch((
|
|
69470
|
+
return hr(e2, t).catch((n2) => e2.emit("error", n2)), r2;
|
|
69176
69471
|
};
|
|
69177
69472
|
var or = (s3, t) => {
|
|
69178
69473
|
t.forEach((e2) => {
|
|
@@ -69207,7 +69502,7 @@ var Vn = 512 * 1024;
|
|
|
69207
69502
|
var $n = pr | ur | dr | mr;
|
|
69208
69503
|
var lr = !fr && typeof ar == "number" ? ar | ur | dr | mr : null;
|
|
69209
69504
|
var cs = lr !== null ? () => lr : Kn ? (s3) => s3 < Vn ? $n : "w" : () => "w";
|
|
69210
|
-
var
|
|
69505
|
+
var fs29 = (s3, t, e2) => {
|
|
69211
69506
|
try {
|
|
69212
69507
|
return mi.lchownSync(s3, t, e2);
|
|
69213
69508
|
} catch (i) {
|
|
@@ -69222,28 +69517,28 @@ var ui = (s3, t, e2, i) => {
|
|
|
69222
69517
|
};
|
|
69223
69518
|
var Xn = (s3, t, e2, i, r2) => {
|
|
69224
69519
|
if (t.isDirectory())
|
|
69225
|
-
ds(Ee.resolve(s3, t.name), e2, i, (
|
|
69226
|
-
if (
|
|
69227
|
-
return r2(
|
|
69520
|
+
ds(Ee.resolve(s3, t.name), e2, i, (n2) => {
|
|
69521
|
+
if (n2)
|
|
69522
|
+
return r2(n2);
|
|
69228
69523
|
let o2 = Ee.resolve(s3, t.name);
|
|
69229
69524
|
ui(o2, e2, i, r2);
|
|
69230
69525
|
});
|
|
69231
69526
|
else {
|
|
69232
|
-
let
|
|
69233
|
-
ui(
|
|
69527
|
+
let n2 = Ee.resolve(s3, t.name);
|
|
69528
|
+
ui(n2, e2, i, r2);
|
|
69234
69529
|
}
|
|
69235
69530
|
};
|
|
69236
69531
|
var ds = (s3, t, e2, i) => {
|
|
69237
|
-
mi.readdir(s3, { withFileTypes: true }, (r2,
|
|
69532
|
+
mi.readdir(s3, { withFileTypes: true }, (r2, n2) => {
|
|
69238
69533
|
if (r2) {
|
|
69239
69534
|
if (r2.code === "ENOENT")
|
|
69240
69535
|
return i();
|
|
69241
69536
|
if (r2.code !== "ENOTDIR" && r2.code !== "ENOTSUP")
|
|
69242
69537
|
return i(r2);
|
|
69243
69538
|
}
|
|
69244
|
-
if (r2 || !
|
|
69539
|
+
if (r2 || !n2.length)
|
|
69245
69540
|
return ui(s3, t, e2, i);
|
|
69246
|
-
let o2 =
|
|
69541
|
+
let o2 = n2.length, h2 = null, a3 = (l2) => {
|
|
69247
69542
|
if (!h2) {
|
|
69248
69543
|
if (l2)
|
|
69249
69544
|
return i(h2 = l2);
|
|
@@ -69251,28 +69546,28 @@ var ds = (s3, t, e2, i) => {
|
|
|
69251
69546
|
return ui(s3, t, e2, i);
|
|
69252
69547
|
}
|
|
69253
69548
|
};
|
|
69254
|
-
for (let l2 of
|
|
69549
|
+
for (let l2 of n2)
|
|
69255
69550
|
Xn(s3, l2, t, e2, a3);
|
|
69256
69551
|
});
|
|
69257
69552
|
};
|
|
69258
69553
|
var qn = (s3, t, e2, i) => {
|
|
69259
|
-
t.isDirectory() && us(Ee.resolve(s3, t.name), e2, i),
|
|
69554
|
+
t.isDirectory() && us(Ee.resolve(s3, t.name), e2, i), fs29(Ee.resolve(s3, t.name), e2, i);
|
|
69260
69555
|
};
|
|
69261
69556
|
var us = (s3, t, e2) => {
|
|
69262
69557
|
let i;
|
|
69263
69558
|
try {
|
|
69264
69559
|
i = mi.readdirSync(s3, { withFileTypes: true });
|
|
69265
69560
|
} catch (r2) {
|
|
69266
|
-
let
|
|
69267
|
-
if (
|
|
69561
|
+
let n2 = r2;
|
|
69562
|
+
if (n2?.code === "ENOENT")
|
|
69268
69563
|
return;
|
|
69269
|
-
if (
|
|
69270
|
-
return
|
|
69271
|
-
throw
|
|
69564
|
+
if (n2?.code === "ENOTDIR" || n2?.code === "ENOTSUP")
|
|
69565
|
+
return fs29(s3, t, e2);
|
|
69566
|
+
throw n2;
|
|
69272
69567
|
}
|
|
69273
69568
|
for (let r2 of i)
|
|
69274
69569
|
qn(s3, r2, t, e2);
|
|
69275
|
-
return
|
|
69570
|
+
return fs29(s3, t, e2);
|
|
69276
69571
|
};
|
|
69277
69572
|
var we = class extends Error {
|
|
69278
69573
|
path;
|
|
@@ -69304,8 +69599,8 @@ var Qn = (s3, t) => {
|
|
|
69304
69599
|
};
|
|
69305
69600
|
var Er = (s3, t, e2) => {
|
|
69306
69601
|
s3 = f3(s3);
|
|
69307
|
-
let i = t.umask ?? 18, r2 = t.mode | 448,
|
|
69308
|
-
E2 ? e2(E2) : x3 && a3 ? ds(x3, o2, h2, (xe) => S3(xe)) :
|
|
69602
|
+
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) => {
|
|
69603
|
+
E2 ? e2(E2) : x3 && a3 ? ds(x3, o2, h2, (xe) => S3(xe)) : n2 ? k2.chmod(s3, r2, e2) : e2();
|
|
69309
69604
|
};
|
|
69310
69605
|
if (s3 === d3)
|
|
69311
69606
|
return Qn(s3, S3);
|
|
@@ -69314,30 +69609,30 @@ var Er = (s3, t, e2) => {
|
|
|
69314
69609
|
let N2 = f3(pi.relative(d3, s3)).split("/");
|
|
69315
69610
|
ms(d3, N2, r2, c2, d3, undefined, S3);
|
|
69316
69611
|
};
|
|
69317
|
-
var ms = (s3, t, e2, i, r2,
|
|
69612
|
+
var ms = (s3, t, e2, i, r2, n2, o2) => {
|
|
69318
69613
|
if (t.length === 0)
|
|
69319
|
-
return o2(null,
|
|
69614
|
+
return o2(null, n2);
|
|
69320
69615
|
let h2 = t.shift(), a3 = f3(pi.resolve(s3 + "/" + h2));
|
|
69321
|
-
k2.mkdir(a3, e2, wr(a3, t, e2, i, r2,
|
|
69616
|
+
k2.mkdir(a3, e2, wr(a3, t, e2, i, r2, n2, o2));
|
|
69322
69617
|
};
|
|
69323
|
-
var wr = (s3, t, e2, i, r2,
|
|
69618
|
+
var wr = (s3, t, e2, i, r2, n2, o2) => (h2) => {
|
|
69324
69619
|
h2 ? k2.lstat(s3, (a3, l2) => {
|
|
69325
69620
|
if (a3)
|
|
69326
69621
|
a3.path = a3.path && f3(a3.path), o2(a3);
|
|
69327
69622
|
else if (l2.isDirectory())
|
|
69328
|
-
ms(s3, t, e2, i, r2,
|
|
69623
|
+
ms(s3, t, e2, i, r2, n2, o2);
|
|
69329
69624
|
else if (i)
|
|
69330
69625
|
k2.unlink(s3, (c2) => {
|
|
69331
69626
|
if (c2)
|
|
69332
69627
|
return o2(c2);
|
|
69333
|
-
k2.mkdir(s3, e2, wr(s3, t, e2, i, r2,
|
|
69628
|
+
k2.mkdir(s3, e2, wr(s3, t, e2, i, r2, n2, o2));
|
|
69334
69629
|
});
|
|
69335
69630
|
else {
|
|
69336
69631
|
if (l2.isSymbolicLink())
|
|
69337
69632
|
return o2(new wt(s3, s3 + "/" + t.join("/")));
|
|
69338
69633
|
o2(h2);
|
|
69339
69634
|
}
|
|
69340
|
-
}) : (
|
|
69635
|
+
}) : (n2 = n2 || s3, ms(s3, t, e2, i, r2, n2, o2));
|
|
69341
69636
|
};
|
|
69342
69637
|
var Jn = (s3) => {
|
|
69343
69638
|
let t = false, e2;
|
|
@@ -69352,8 +69647,8 @@ var Jn = (s3) => {
|
|
|
69352
69647
|
};
|
|
69353
69648
|
var Sr = (s3, t) => {
|
|
69354
69649
|
s3 = f3(s3);
|
|
69355
|
-
let e2 = t.umask ?? 18, i = t.mode | 448, r2 = (i & e2) !== 0,
|
|
69356
|
-
E2 && h2 && us(E2,
|
|
69650
|
+
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) => {
|
|
69651
|
+
E2 && h2 && us(E2, n2, o2), r2 && k2.chmodSync(s3, i);
|
|
69357
69652
|
};
|
|
69358
69653
|
if (s3 === c2)
|
|
69359
69654
|
return Jn(c2), d3();
|
|
@@ -69402,19 +69697,19 @@ var Ei = class {
|
|
|
69402
69697
|
#s = new Set;
|
|
69403
69698
|
reserve(t, e2) {
|
|
69404
69699
|
t = eo ? ["win32 parallelization disabled"] : t.map((r2) => mt(br(Rr(r2))));
|
|
69405
|
-
let i = new Set(t.map((r2) => io(r2)).reduce((r2,
|
|
69700
|
+
let i = new Set(t.map((r2) => io(r2)).reduce((r2, n2) => r2.concat(n2)));
|
|
69406
69701
|
this.#i.set(e2, { dirs: i, paths: t });
|
|
69407
69702
|
for (let r2 of t) {
|
|
69408
|
-
let
|
|
69409
|
-
|
|
69703
|
+
let n2 = this.#t.get(r2);
|
|
69704
|
+
n2 ? n2.push(e2) : this.#t.set(r2, [e2]);
|
|
69410
69705
|
}
|
|
69411
69706
|
for (let r2 of i) {
|
|
69412
|
-
let
|
|
69413
|
-
if (!
|
|
69707
|
+
let n2 = this.#t.get(r2);
|
|
69708
|
+
if (!n2)
|
|
69414
69709
|
this.#t.set(r2, [new Set([e2])]);
|
|
69415
69710
|
else {
|
|
69416
|
-
let o2 =
|
|
69417
|
-
o2 instanceof Set ? o2.add(e2) :
|
|
69711
|
+
let o2 = n2.at(-1);
|
|
69712
|
+
o2 instanceof Set ? o2.add(e2) : n2.push(new Set([e2]));
|
|
69418
69713
|
}
|
|
69419
69714
|
}
|
|
69420
69715
|
return this.#r(e2);
|
|
@@ -69438,7 +69733,7 @@ var Ei = class {
|
|
|
69438
69733
|
let e2 = this.#i.get(t);
|
|
69439
69734
|
if (!e2)
|
|
69440
69735
|
throw new Error("invalid reservation");
|
|
69441
|
-
let { paths: i, dirs: r2 } = e2,
|
|
69736
|
+
let { paths: i, dirs: r2 } = e2, n2 = new Set;
|
|
69442
69737
|
for (let o2 of i) {
|
|
69443
69738
|
let h2 = this.#t.get(o2);
|
|
69444
69739
|
if (!h2 || h2?.[0] !== t)
|
|
@@ -69449,10 +69744,10 @@ var Ei = class {
|
|
|
69449
69744
|
continue;
|
|
69450
69745
|
}
|
|
69451
69746
|
if (h2.shift(), typeof a3 == "function")
|
|
69452
|
-
|
|
69747
|
+
n2.add(a3);
|
|
69453
69748
|
else
|
|
69454
69749
|
for (let l2 of a3)
|
|
69455
|
-
|
|
69750
|
+
n2.add(l2);
|
|
69456
69751
|
}
|
|
69457
69752
|
for (let o2 of r2) {
|
|
69458
69753
|
let h2 = this.#t.get(o2), a3 = h2?.[0];
|
|
@@ -69463,11 +69758,11 @@ var Ei = class {
|
|
|
69463
69758
|
} else if (a3.size === 1) {
|
|
69464
69759
|
h2.shift();
|
|
69465
69760
|
let l2 = h2[0];
|
|
69466
|
-
typeof l2 == "function" &&
|
|
69761
|
+
typeof l2 == "function" && n2.add(l2);
|
|
69467
69762
|
} else
|
|
69468
69763
|
a3.delete(t);
|
|
69469
69764
|
}
|
|
69470
|
-
return this.#s.delete(t),
|
|
69765
|
+
return this.#s.delete(t), n2.forEach((o2) => this.#r(o2)), true;
|
|
69471
69766
|
}
|
|
69472
69767
|
};
|
|
69473
69768
|
var _r = () => process.umask();
|
|
@@ -69569,7 +69864,7 @@ var qt = class extends st {
|
|
|
69569
69864
|
let i = t[e2], { type: r2 } = t;
|
|
69570
69865
|
if (!i || this.preservePaths)
|
|
69571
69866
|
return true;
|
|
69572
|
-
let [
|
|
69867
|
+
let [n2, o2] = ce2(i), h2 = o2.replaceAll(/\\/g, "/").split("/");
|
|
69573
69868
|
if (h2.includes("..") || Oe && /^[a-z]:\.\.$/i.test(h2[0] ?? "")) {
|
|
69574
69869
|
if (e2 === "path" || r2 === "Link")
|
|
69575
69870
|
return this.warn("TAR_ENTRY_ERROR", `${e2} contains '..'`, { entry: t, [e2]: i }), false;
|
|
@@ -69577,7 +69872,7 @@ var qt = class extends st {
|
|
|
69577
69872
|
if (l2.startsWith("../") || l2 === "..")
|
|
69578
69873
|
return this.warn("TAR_ENTRY_ERROR", `${e2} escapes extraction directory`, { entry: t, [e2]: i }), false;
|
|
69579
69874
|
}
|
|
69580
|
-
return
|
|
69875
|
+
return n2 && (t[e2] = String(o2), this.warn("TAR_ENTRY_INFO", `stripping ${n2} from absolute ${e2}`, { entry: t, [e2]: i })), true;
|
|
69581
69876
|
}
|
|
69582
69877
|
[Nr](t) {
|
|
69583
69878
|
let e2 = f3(t.path), i = e2.split("/");
|
|
@@ -69604,8 +69899,8 @@ var qt = class extends st {
|
|
|
69604
69899
|
if (this.win32) {
|
|
69605
69900
|
let { root: r2 } = R3.win32.parse(String(t.absolute));
|
|
69606
69901
|
t.absolute = r2 + Xi(String(t.absolute).slice(r2.length));
|
|
69607
|
-
let { root:
|
|
69608
|
-
t.path =
|
|
69902
|
+
let { root: n2 } = R3.win32.parse(t.path);
|
|
69903
|
+
t.path = n2 + Xi(t.path.slice(n2.length));
|
|
69609
69904
|
}
|
|
69610
69905
|
return true;
|
|
69611
69906
|
}
|
|
@@ -69646,24 +69941,24 @@ var qt = class extends st {
|
|
|
69646
69941
|
r2.on("error", (a3) => {
|
|
69647
69942
|
r2.fd && u.close(r2.fd, () => {}), r2.write = () => true, this[O2](a3, t), e2();
|
|
69648
69943
|
});
|
|
69649
|
-
let
|
|
69944
|
+
let n2 = 1, o2 = (a3) => {
|
|
69650
69945
|
if (a3) {
|
|
69651
69946
|
r2.fd && u.close(r2.fd, () => {}), this[O2](a3, t), e2();
|
|
69652
69947
|
return;
|
|
69653
69948
|
}
|
|
69654
|
-
--
|
|
69949
|
+
--n2 === 0 && r2.fd !== undefined && u.close(r2.fd, (l2) => {
|
|
69655
69950
|
l2 ? this[O2](l2, t) : this[Xt](), e2();
|
|
69656
69951
|
});
|
|
69657
69952
|
};
|
|
69658
69953
|
r2.on("finish", () => {
|
|
69659
69954
|
let a3 = String(t.absolute), l2 = r2.fd;
|
|
69660
69955
|
if (typeof l2 == "number" && t.mtime && !this.noMtime) {
|
|
69661
|
-
|
|
69956
|
+
n2++;
|
|
69662
69957
|
let c2 = t.atime || new Date, d3 = t.mtime;
|
|
69663
69958
|
u.futimes(l2, c2, d3, (S3) => S3 ? u.utimes(a3, c2, d3, (T3) => o2(T3 && S3)) : o2());
|
|
69664
69959
|
}
|
|
69665
69960
|
if (typeof l2 == "number" && this[Re](t)) {
|
|
69666
|
-
|
|
69961
|
+
n2++;
|
|
69667
69962
|
let c2 = this[be](t), d3 = this[_e](t);
|
|
69668
69963
|
typeof c2 == "number" && typeof d3 == "number" && u.fchown(l2, c2, d3, (S3) => S3 ? u.chown(a3, c2, d3, (T3) => o2(T3 && S3)) : o2());
|
|
69669
69964
|
}
|
|
@@ -69681,10 +69976,10 @@ var qt = class extends st {
|
|
|
69681
69976
|
this[O2](r2, t), e2();
|
|
69682
69977
|
return;
|
|
69683
69978
|
}
|
|
69684
|
-
let
|
|
69685
|
-
--
|
|
69979
|
+
let n2 = 1, o2 = () => {
|
|
69980
|
+
--n2 === 0 && (e2(), this[Xt](), t.resume());
|
|
69686
69981
|
};
|
|
69687
|
-
t.mtime && !this.noMtime && (
|
|
69982
|
+
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
69983
|
});
|
|
69689
69984
|
}
|
|
69690
69985
|
[Lr](t) {
|
|
@@ -69698,11 +69993,11 @@ var qt = class extends st {
|
|
|
69698
69993
|
}
|
|
69699
69994
|
[xr](t, e2) {
|
|
69700
69995
|
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), (
|
|
69702
|
-
this[O2](
|
|
69996
|
+
this[ye](t, this.cwd, r2, () => this[Si](t, i, "link", e2), (n2) => {
|
|
69997
|
+
this[O2](n2, t), e2();
|
|
69703
69998
|
});
|
|
69704
69999
|
}
|
|
69705
|
-
[ye](t, e2, i, r2,
|
|
70000
|
+
[ye](t, e2, i, r2, n2) {
|
|
69706
70001
|
let o2 = i.shift();
|
|
69707
70002
|
if (this.preservePaths || o2 === undefined)
|
|
69708
70003
|
return r2();
|
|
@@ -69711,8 +70006,8 @@ var qt = class extends st {
|
|
|
69711
70006
|
if (a3)
|
|
69712
70007
|
return r2();
|
|
69713
70008
|
if (l2?.isSymbolicLink())
|
|
69714
|
-
return
|
|
69715
|
-
this[ye](t, h2, i, r2,
|
|
70009
|
+
return n2(new wt(h2, R3.resolve(h2, i.join("/"))));
|
|
70010
|
+
this[ye](t, h2, i, r2, n2);
|
|
69716
70011
|
});
|
|
69717
70012
|
}
|
|
69718
70013
|
[Ar]() {
|
|
@@ -69741,9 +70036,9 @@ var qt = class extends st {
|
|
|
69741
70036
|
this[O2](h2, t), i();
|
|
69742
70037
|
return;
|
|
69743
70038
|
}
|
|
69744
|
-
this[ge] = true,
|
|
70039
|
+
this[ge] = true, n2();
|
|
69745
70040
|
});
|
|
69746
|
-
},
|
|
70041
|
+
}, n2 = () => {
|
|
69747
70042
|
if (t.absolute !== this.cwd) {
|
|
69748
70043
|
let h2 = f3(R3.dirname(String(t.absolute)));
|
|
69749
70044
|
if (h2 !== this.cwd)
|
|
@@ -69777,7 +70072,7 @@ var qt = class extends st {
|
|
|
69777
70072
|
oo(String(t.absolute), (l2) => this[P2](l2 ?? null, t, i));
|
|
69778
70073
|
});
|
|
69779
70074
|
};
|
|
69780
|
-
this[ge] ?
|
|
70075
|
+
this[ge] ? n2() : r2();
|
|
69781
70076
|
}
|
|
69782
70077
|
[P2](t, e2, i) {
|
|
69783
70078
|
if (t) {
|
|
@@ -69799,8 +70094,8 @@ var qt = class extends st {
|
|
|
69799
70094
|
}
|
|
69800
70095
|
}
|
|
69801
70096
|
[Si](t, e2, i, r2) {
|
|
69802
|
-
u[i](e2, String(t.absolute), (
|
|
69803
|
-
|
|
70097
|
+
u[i](e2, String(t.absolute), (n2) => {
|
|
70098
|
+
n2 ? this[O2](n2, t) : (this[Xt](), t.resume()), r2();
|
|
69804
70099
|
});
|
|
69805
70100
|
}
|
|
69806
70101
|
};
|
|
@@ -69818,15 +70113,15 @@ var Te = class extends qt {
|
|
|
69818
70113
|
}
|
|
69819
70114
|
[ys](t) {
|
|
69820
70115
|
if (!this[ge]) {
|
|
69821
|
-
let
|
|
69822
|
-
if (
|
|
69823
|
-
return this[O2](
|
|
70116
|
+
let n2 = this[St](this.cwd, this.dmode);
|
|
70117
|
+
if (n2)
|
|
70118
|
+
return this[O2](n2, t);
|
|
69824
70119
|
this[ge] = true;
|
|
69825
70120
|
}
|
|
69826
70121
|
if (t.absolute !== this.cwd) {
|
|
69827
|
-
let
|
|
69828
|
-
if (
|
|
69829
|
-
let o2 = this[St](
|
|
70122
|
+
let n2 = f3(R3.dirname(String(t.absolute)));
|
|
70123
|
+
if (n2 !== this.cwd) {
|
|
70124
|
+
let o2 = this[St](n2, this.dmode);
|
|
69830
70125
|
if (o2)
|
|
69831
70126
|
return this[O2](o2, t);
|
|
69832
70127
|
}
|
|
@@ -69843,8 +70138,8 @@ var Te = class extends qt {
|
|
|
69843
70138
|
}) : [];
|
|
69844
70139
|
return this[P2](h2, t);
|
|
69845
70140
|
}
|
|
69846
|
-
let [
|
|
69847
|
-
this[P2](
|
|
70141
|
+
let [n2] = Se(() => u.rmdirSync(String(t.absolute)));
|
|
70142
|
+
this[P2](n2, t);
|
|
69848
70143
|
}
|
|
69849
70144
|
let [r2] = t.absolute === this.cwd ? [] : Se(() => ho(String(t.absolute)));
|
|
69850
70145
|
this[P2](r2, t);
|
|
@@ -69853,21 +70148,21 @@ var Te = class extends qt {
|
|
|
69853
70148
|
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r2 = (h2) => {
|
|
69854
70149
|
let a3;
|
|
69855
70150
|
try {
|
|
69856
|
-
u.closeSync(
|
|
70151
|
+
u.closeSync(n2);
|
|
69857
70152
|
} catch (l2) {
|
|
69858
70153
|
a3 = l2;
|
|
69859
70154
|
}
|
|
69860
70155
|
(h2 || a3) && this[O2](h2 || a3, t), e2();
|
|
69861
|
-
},
|
|
70156
|
+
}, n2;
|
|
69862
70157
|
try {
|
|
69863
|
-
|
|
70158
|
+
n2 = u.openSync(String(t.absolute), cs(t.size), i);
|
|
69864
70159
|
} catch (h2) {
|
|
69865
70160
|
return r2(h2);
|
|
69866
70161
|
}
|
|
69867
70162
|
let o2 = this.transform && this.transform(t) || t;
|
|
69868
70163
|
o2 !== t && (o2.on("error", (h2) => this[O2](h2, t)), t.pipe(o2)), o2.on("data", (h2) => {
|
|
69869
70164
|
try {
|
|
69870
|
-
u.writeSync(
|
|
70165
|
+
u.writeSync(n2, h2, 0, h2.length);
|
|
69871
70166
|
} catch (a3) {
|
|
69872
70167
|
r2(a3);
|
|
69873
70168
|
}
|
|
@@ -69876,7 +70171,7 @@ var Te = class extends qt {
|
|
|
69876
70171
|
if (t.mtime && !this.noMtime) {
|
|
69877
70172
|
let a3 = t.atime || new Date, l2 = t.mtime;
|
|
69878
70173
|
try {
|
|
69879
|
-
u.futimesSync(
|
|
70174
|
+
u.futimesSync(n2, a3, l2);
|
|
69880
70175
|
} catch (c2) {
|
|
69881
70176
|
try {
|
|
69882
70177
|
u.utimesSync(String(t.absolute), a3, l2);
|
|
@@ -69888,7 +70183,7 @@ var Te = class extends qt {
|
|
|
69888
70183
|
if (this[Re](t)) {
|
|
69889
70184
|
let a3 = this[be](t), l2 = this[_e](t);
|
|
69890
70185
|
try {
|
|
69891
|
-
u.fchownSync(
|
|
70186
|
+
u.fchownSync(n2, Number(a3), Number(l2));
|
|
69892
70187
|
} catch (c2) {
|
|
69893
70188
|
try {
|
|
69894
70189
|
u.chownSync(String(t.absolute), Number(a3), Number(l2));
|
|
@@ -69923,7 +70218,7 @@ var Te = class extends qt {
|
|
|
69923
70218
|
return i;
|
|
69924
70219
|
}
|
|
69925
70220
|
}
|
|
69926
|
-
[ye](t, e2, i, r2,
|
|
70221
|
+
[ye](t, e2, i, r2, n2) {
|
|
69927
70222
|
if (this.preservePaths || i.length === 0)
|
|
69928
70223
|
return r2();
|
|
69929
70224
|
let o2 = e2;
|
|
@@ -69933,14 +70228,14 @@ var Te = class extends qt {
|
|
|
69933
70228
|
if (a3)
|
|
69934
70229
|
return r2();
|
|
69935
70230
|
if (l2.isSymbolicLink())
|
|
69936
|
-
return
|
|
70231
|
+
return n2(new wt(o2, R3.resolve(e2, i.join("/"))));
|
|
69937
70232
|
}
|
|
69938
70233
|
r2();
|
|
69939
70234
|
}
|
|
69940
70235
|
[Si](t, e2, i, r2) {
|
|
69941
|
-
let
|
|
70236
|
+
let n2 = `${i}Sync`;
|
|
69942
70237
|
try {
|
|
69943
|
-
u[
|
|
70238
|
+
u[n2](e2, String(t.absolute)), r2(), t.resume();
|
|
69944
70239
|
} catch (o2) {
|
|
69945
70240
|
return this[O2](o2, t);
|
|
69946
70241
|
}
|
|
@@ -69967,7 +70262,7 @@ var co = K3(ao, lo, (s3) => new Te(s3), (s3) => new qt(s3), (s3, t) => {
|
|
|
69967
70262
|
t?.length && Ki(s3, t);
|
|
69968
70263
|
});
|
|
69969
70264
|
var fo = (s3, t) => {
|
|
69970
|
-
let e2 = new kt(s3), i = true, r2,
|
|
70265
|
+
let e2 = new kt(s3), i = true, r2, n2;
|
|
69971
70266
|
try {
|
|
69972
70267
|
try {
|
|
69973
70268
|
r2 = v2.openSync(s3.file, "r+");
|
|
@@ -69979,9 +70274,9 @@ var fo = (s3, t) => {
|
|
|
69979
70274
|
}
|
|
69980
70275
|
let o2 = v2.fstatSync(r2), h2 = Buffer.alloc(512);
|
|
69981
70276
|
t:
|
|
69982
|
-
for (
|
|
70277
|
+
for (n2 = 0;n2 < o2.size; n2 += 512) {
|
|
69983
70278
|
for (let c2 = 0, d3 = 0;c2 < 512; c2 += d3) {
|
|
69984
|
-
if (d3 = v2.readSync(r2, h2, c2, h2.length - c2,
|
|
70279
|
+
if (d3 = v2.readSync(r2, h2, c2, h2.length - c2, n2 + c2), n2 === 0 && h2[0] === 31 && h2[1] === 139)
|
|
69985
70280
|
throw new Error("cannot append to compressed archives");
|
|
69986
70281
|
if (!d3)
|
|
69987
70282
|
break t;
|
|
@@ -69990,11 +70285,11 @@ var fo = (s3, t) => {
|
|
|
69990
70285
|
if (!a3.cksumValid)
|
|
69991
70286
|
break;
|
|
69992
70287
|
let l2 = 512 * Math.ceil((a3.size || 0) / 512);
|
|
69993
|
-
if (
|
|
70288
|
+
if (n2 + l2 + 512 > o2.size)
|
|
69994
70289
|
break;
|
|
69995
|
-
|
|
70290
|
+
n2 += l2, s3.mtimeCache && a3.mtime && s3.mtimeCache.set(String(a3.path), a3.mtime);
|
|
69996
70291
|
}
|
|
69997
|
-
i = false, uo(s3, e2,
|
|
70292
|
+
i = false, uo(s3, e2, n2, r2, t);
|
|
69998
70293
|
} finally {
|
|
69999
70294
|
if (i)
|
|
70000
70295
|
try {
|
|
@@ -70003,14 +70298,14 @@ var fo = (s3, t) => {
|
|
|
70003
70298
|
}
|
|
70004
70299
|
};
|
|
70005
70300
|
var uo = (s3, t, e2, i, r2) => {
|
|
70006
|
-
let
|
|
70007
|
-
t.pipe(
|
|
70301
|
+
let n2 = new Wt(s3.file, { fd: i, start: e2 });
|
|
70302
|
+
t.pipe(n2), po(t, r2);
|
|
70008
70303
|
};
|
|
70009
70304
|
var mo = (s3, t) => {
|
|
70010
70305
|
t = Array.from(t);
|
|
70011
|
-
let e2 = new Et(s3), i = (
|
|
70306
|
+
let e2 = new Et(s3), i = (n2, o2, h2) => {
|
|
70012
70307
|
let a3 = (T3, N2) => {
|
|
70013
|
-
T3 ? v2.close(
|
|
70308
|
+
T3 ? v2.close(n2, (E2) => h2(T3)) : h2(null, N2);
|
|
70014
70309
|
}, l2 = 0;
|
|
70015
70310
|
if (o2 === 0)
|
|
70016
70311
|
return a3(null, 0);
|
|
@@ -70018,7 +70313,7 @@ var mo = (s3, t) => {
|
|
|
70018
70313
|
if (T3 || N2 === undefined)
|
|
70019
70314
|
return a3(T3);
|
|
70020
70315
|
if (c2 += N2, c2 < 512 && N2)
|
|
70021
|
-
return v2.read(
|
|
70316
|
+
return v2.read(n2, d3, c2, d3.length - c2, l2 + c2, S3);
|
|
70022
70317
|
if (l2 === 0 && d3[0] === 31 && d3[1] === 139)
|
|
70023
70318
|
return a3(new Error("cannot append to compressed archives"));
|
|
70024
70319
|
if (c2 < 512)
|
|
@@ -70029,11 +70324,11 @@ var mo = (s3, t) => {
|
|
|
70029
70324
|
let x3 = 512 * Math.ceil((E2.size ?? 0) / 512);
|
|
70030
70325
|
if (l2 + x3 + 512 > o2 || (l2 += x3 + 512, l2 >= o2))
|
|
70031
70326
|
return a3(null, l2);
|
|
70032
|
-
s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c2 = 0, v2.read(
|
|
70327
|
+
s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c2 = 0, v2.read(n2, d3, 0, 512, l2, S3);
|
|
70033
70328
|
};
|
|
70034
|
-
v2.read(
|
|
70329
|
+
v2.read(n2, d3, 0, 512, l2, S3);
|
|
70035
70330
|
};
|
|
70036
|
-
return new Promise((
|
|
70331
|
+
return new Promise((n2, o2) => {
|
|
70037
70332
|
e2.on("error", o2);
|
|
70038
70333
|
let h2 = "r+", a3 = (l2, c2) => {
|
|
70039
70334
|
if (l2 && l2.code === "ENOENT" && h2 === "r+")
|
|
@@ -70047,7 +70342,7 @@ var mo = (s3, t) => {
|
|
|
70047
70342
|
if (T3)
|
|
70048
70343
|
return o2(T3);
|
|
70049
70344
|
let E2 = new tt(s3.file, { fd: c2, start: N2 });
|
|
70050
|
-
e2.pipe(E2), E2.on("error", o2), E2.on("close",
|
|
70345
|
+
e2.pipe(E2), E2.on("error", o2), E2.on("close", n2), Eo(e2, t);
|
|
70051
70346
|
});
|
|
70052
70347
|
});
|
|
70053
70348
|
};
|
|
@@ -70512,7 +70807,7 @@ function buildReleaseAllowlist(layout) {
|
|
|
70512
70807
|
async function ensureLayoutSourceDir(projectRoot, layout, strict) {
|
|
70513
70808
|
const sourceDir = path10.join(projectRoot, layout.sourceDir);
|
|
70514
70809
|
try {
|
|
70515
|
-
const stat11 = await
|
|
70810
|
+
const stat11 = await fs30.promises.stat(sourceDir);
|
|
70516
70811
|
if (!stat11.isDirectory()) {
|
|
70517
70812
|
throw new Error(`Expected source directory "${layout.sourceDir}" exists but is not a directory.`);
|
|
70518
70813
|
}
|
|
@@ -70537,8 +70832,8 @@ async function materializeRuntimeLayoutInPlace(projectRoot, layout) {
|
|
|
70537
70832
|
}
|
|
70538
70833
|
const sourceDir = path10.join(projectRoot, layout.sourceDir);
|
|
70539
70834
|
const runtimeDir = path10.join(projectRoot, layout.runtimeDir);
|
|
70540
|
-
await
|
|
70541
|
-
await
|
|
70835
|
+
await fs30.promises.rm(runtimeDir, { recursive: true, force: true });
|
|
70836
|
+
await fs30.promises.rename(sourceDir, runtimeDir);
|
|
70542
70837
|
}
|
|
70543
70838
|
async function stageLocalKitPathForRuntimeLayout(kitRoot, layout) {
|
|
70544
70839
|
const sourceDir = await ensureLayoutSourceDir(kitRoot, layout, false);
|
|
@@ -70548,20 +70843,20 @@ async function stageLocalKitPathForRuntimeLayout(kitRoot, layout) {
|
|
|
70548
70843
|
const downloadManager = new DownloadManager;
|
|
70549
70844
|
const tempDir = await downloadManager.createTempDir();
|
|
70550
70845
|
const extractDir = `${tempDir}/extracted`;
|
|
70551
|
-
await
|
|
70552
|
-
const entries = await
|
|
70846
|
+
await fs30.promises.mkdir(extractDir, { recursive: true });
|
|
70847
|
+
const entries = await fs30.promises.readdir(kitRoot);
|
|
70553
70848
|
const allowlist = buildReleaseAllowlist(layout);
|
|
70554
70849
|
for (const entry of entries) {
|
|
70555
70850
|
if (!allowlist.includes(entry) || entry === layout.sourceDir) {
|
|
70556
70851
|
continue;
|
|
70557
70852
|
}
|
|
70558
|
-
await
|
|
70853
|
+
await fs30.promises.cp(path10.join(kitRoot, entry), path10.join(extractDir, entry), {
|
|
70559
70854
|
recursive: true
|
|
70560
70855
|
});
|
|
70561
70856
|
}
|
|
70562
70857
|
const runtimeDir = path10.join(extractDir, layout.runtimeDir);
|
|
70563
|
-
await
|
|
70564
|
-
await
|
|
70858
|
+
await fs30.promises.mkdir(path10.dirname(runtimeDir), { recursive: true });
|
|
70859
|
+
await fs30.promises.cp(sourceDir, runtimeDir, { recursive: true });
|
|
70565
70860
|
logger.verbose("Staged local kit path with runtime layout", {
|
|
70566
70861
|
kitRoot,
|
|
70567
70862
|
extractDir,
|
|
@@ -70590,9 +70885,9 @@ function resolveRepoRootForKit(kitRoot) {
|
|
|
70590
70885
|
try {
|
|
70591
70886
|
const parent = path10.dirname(kitRoot);
|
|
70592
70887
|
const parentPackageJson = path10.join(parent, "package.json");
|
|
70593
|
-
if (!
|
|
70888
|
+
if (!fs30.existsSync(parentPackageJson))
|
|
70594
70889
|
return kitRoot;
|
|
70595
|
-
const pkg = JSON.parse(
|
|
70890
|
+
const pkg = JSON.parse(fs30.readFileSync(parentPackageJson, "utf-8"));
|
|
70596
70891
|
const kitCfg = pkg.takumi;
|
|
70597
70892
|
const sourceDir = kitCfg?.sourceDir;
|
|
70598
70893
|
if (typeof sourceDir === "string" && path10.resolve(parent, sourceDir) === path10.resolve(kitRoot)) {
|
|
@@ -70606,9 +70901,9 @@ async function stageMonorepoForInstallation(kitRoot) {
|
|
|
70606
70901
|
const tempDir = await downloadManager.createTempDir();
|
|
70607
70902
|
const extractDir = `${tempDir}/extracted`;
|
|
70608
70903
|
const claudeDir = path10.join(extractDir, ".claude");
|
|
70609
|
-
await
|
|
70904
|
+
await fs30.promises.mkdir(claudeDir, { recursive: true });
|
|
70610
70905
|
const repoRoot = resolveRepoRootForKit(kitRoot);
|
|
70611
|
-
const kitEntries = await
|
|
70906
|
+
const kitEntries = await fs30.promises.readdir(kitRoot);
|
|
70612
70907
|
const skipLegacyManifest = kitEntries.includes(MANIFEST_FILENAME) && kitEntries.includes(LEGACY_MANIFEST_FILENAME);
|
|
70613
70908
|
for (const entry of kitEntries) {
|
|
70614
70909
|
if (!MONOREPO_KIT_CONTENT.includes(entry))
|
|
@@ -70616,14 +70911,14 @@ async function stageMonorepoForInstallation(kitRoot) {
|
|
|
70616
70911
|
if (skipLegacyManifest && entry === LEGACY_MANIFEST_FILENAME)
|
|
70617
70912
|
continue;
|
|
70618
70913
|
const srcPath = path10.join(kitRoot, entry);
|
|
70619
|
-
await
|
|
70914
|
+
await fs30.promises.cp(srcPath, path10.join(claudeDir, entry), { recursive: true });
|
|
70620
70915
|
}
|
|
70621
|
-
const repoEntries = repoRoot === kitRoot ? kitEntries : await
|
|
70916
|
+
const repoEntries = repoRoot === kitRoot ? kitEntries : await fs30.promises.readdir(repoRoot);
|
|
70622
70917
|
for (const entry of repoEntries) {
|
|
70623
70918
|
if (!RELEASE_ROOT_ALLOWLIST.includes(entry))
|
|
70624
70919
|
continue;
|
|
70625
70920
|
const srcPath = path10.join(repoRoot, entry);
|
|
70626
|
-
await
|
|
70921
|
+
await fs30.promises.cp(srcPath, path10.join(extractDir, entry), { recursive: true });
|
|
70627
70922
|
}
|
|
70628
70923
|
logger.verbose("Staged monorepo for installation", {
|
|
70629
70924
|
kitRoot,
|
|
@@ -70637,13 +70932,13 @@ async function stageMonorepoForInstallation(kitRoot) {
|
|
|
70637
70932
|
async function normalizeFullRepoExtract(dir, strict) {
|
|
70638
70933
|
const layout = resolveKitLayout(dir);
|
|
70639
70934
|
await ensureLayoutSourceDir(dir, layout, strict);
|
|
70640
|
-
const entries = await
|
|
70935
|
+
const entries = await fs30.promises.readdir(dir);
|
|
70641
70936
|
const releaseAllowlist = buildReleaseAllowlist(layout);
|
|
70642
70937
|
let removedCount = 0;
|
|
70643
70938
|
for (const entry of entries) {
|
|
70644
70939
|
if (!releaseAllowlist.includes(entry)) {
|
|
70645
70940
|
const fullPath = path10.join(dir, entry);
|
|
70646
|
-
await
|
|
70941
|
+
await fs30.promises.rm(fullPath, { recursive: true, force: true });
|
|
70647
70942
|
removedCount++;
|
|
70648
70943
|
}
|
|
70649
70944
|
}
|
|
@@ -70758,7 +71053,7 @@ async function useLocalKitPath(kitPath, isMonorepo) {
|
|
|
70758
71053
|
output.section("Using local kit");
|
|
70759
71054
|
const absolutePath = path10.resolve(kitPath);
|
|
70760
71055
|
try {
|
|
70761
|
-
const stat11 = await
|
|
71056
|
+
const stat11 = await fs30.promises.stat(absolutePath);
|
|
70762
71057
|
if (!stat11.isDirectory()) {
|
|
70763
71058
|
throw new Error(`--kit-path must point to a directory, not a file.
|
|
70764
71059
|
|
|
@@ -70797,7 +71092,7 @@ Please verify the path exists and is accessible.`);
|
|
|
70797
71092
|
}
|
|
70798
71093
|
const claudeDir = path10.join(absolutePath, DEFAULT_KIT_LAYOUT.runtimeDir);
|
|
70799
71094
|
try {
|
|
70800
|
-
const stat11 = await
|
|
71095
|
+
const stat11 = await fs30.promises.stat(claudeDir);
|
|
70801
71096
|
if (!stat11.isDirectory()) {
|
|
70802
71097
|
logger.warning(`Warning: ${claudeDir} exists but is not a directory.
|
|
70803
71098
|
This may not be a valid Takumi installation.`);
|
|
@@ -70832,7 +71127,7 @@ async function extractLocalArchive(archivePath, exclude) {
|
|
|
70832
71127
|
const absolutePath = path10.resolve(archivePath);
|
|
70833
71128
|
validateArchiveFormat(absolutePath);
|
|
70834
71129
|
try {
|
|
70835
|
-
const stat11 = await
|
|
71130
|
+
const stat11 = await fs30.promises.stat(absolutePath);
|
|
70836
71131
|
if (!stat11.isFile()) {
|
|
70837
71132
|
throw new Error(`--archive must point to a file, not a directory.
|
|
70838
71133
|
|
|
@@ -70965,7 +71260,7 @@ async function downloadViaWorker(release, kit, isNonInteractive2) {
|
|
|
70965
71260
|
const tempDir = await downloadManager.createTempDir();
|
|
70966
71261
|
const archivePath = path10.join(tempDir, assetName);
|
|
70967
71262
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
70968
|
-
await
|
|
71263
|
+
await fs30.promises.writeFile(archivePath, buf);
|
|
70969
71264
|
const extractDir = `${tempDir}/extracted`;
|
|
70970
71265
|
logger.verbose("Extraction", { archivePath, extractDir });
|
|
70971
71266
|
await downloadManager.extractArchive(archivePath, extractDir);
|
|
@@ -71327,7 +71622,7 @@ init_logger();
|
|
|
71327
71622
|
init_safe_spinner();
|
|
71328
71623
|
init_takumi_constants();
|
|
71329
71624
|
var import_fs_extra32 = __toESM(require_lib(), 1);
|
|
71330
|
-
import { existsSync as
|
|
71625
|
+
import { existsSync as existsSync56, readdirSync as readdirSync9, rmSync as rmSync7, rmdirSync as rmdirSync2, unlinkSync as unlinkSync6 } from "node:fs";
|
|
71331
71626
|
import { dirname as dirname34, join as join117, resolve as resolve27 } from "node:path";
|
|
71332
71627
|
var TAKUMI_SUBDIRECTORIES = ["commands", "agents", "skills", "rules", "hooks"];
|
|
71333
71628
|
async function analyzeFreshInstallation(claudeDir) {
|
|
@@ -71400,7 +71695,7 @@ async function removeFilesByOwnership(claudeDir, analysis, includeModified) {
|
|
|
71400
71695
|
for (const file of filesToRemove) {
|
|
71401
71696
|
const fullPath = join117(claudeDir, file.path);
|
|
71402
71697
|
try {
|
|
71403
|
-
if (
|
|
71698
|
+
if (existsSync56(fullPath)) {
|
|
71404
71699
|
unlinkSync6(fullPath);
|
|
71405
71700
|
removedFiles.push(file.path);
|
|
71406
71701
|
logger.debug(`Removed: ${file.path}`);
|
|
@@ -73585,11 +73880,11 @@ async function initCommand(options2) {
|
|
|
73585
73880
|
}
|
|
73586
73881
|
// src/commands/plan/plan-command.ts
|
|
73587
73882
|
init_output_manager();
|
|
73588
|
-
import { existsSync as
|
|
73883
|
+
import { existsSync as existsSync61, statSync as statSync9 } from "node:fs";
|
|
73589
73884
|
import { dirname as dirname41, join as join128, parse as parse4, resolve as resolve33 } from "node:path";
|
|
73590
73885
|
|
|
73591
73886
|
// src/commands/plan/plan-read-handlers.ts
|
|
73592
|
-
import { existsSync as
|
|
73887
|
+
import { existsSync as existsSync60, statSync as statSync8 } from "node:fs";
|
|
73593
73888
|
import { basename as basename21, dirname as dirname40, join as join127, relative as relative20, resolve as resolve31 } from "node:path";
|
|
73594
73889
|
|
|
73595
73890
|
// src/domains/plan-parser/index.ts
|
|
@@ -73970,20 +74265,20 @@ function parsePlanFile(planFilePath, options2) {
|
|
|
73970
74265
|
return { frontmatter, phases };
|
|
73971
74266
|
}
|
|
73972
74267
|
// src/domains/plan-parser/plan-scanner.ts
|
|
73973
|
-
import { existsSync as
|
|
74268
|
+
import { existsSync as existsSync57, readdirSync as readdirSync10 } from "node:fs";
|
|
73974
74269
|
import { join as join125 } from "node:path";
|
|
73975
74270
|
function scanPlanDir(dir) {
|
|
73976
|
-
if (!
|
|
74271
|
+
if (!existsSync57(dir))
|
|
73977
74272
|
return [];
|
|
73978
74273
|
try {
|
|
73979
|
-
return readdirSync10(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join125(dir, entry.name, "plan.md")).filter(
|
|
74274
|
+
return readdirSync10(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join125(dir, entry.name, "plan.md")).filter(existsSync57);
|
|
73980
74275
|
} catch {
|
|
73981
74276
|
return [];
|
|
73982
74277
|
}
|
|
73983
74278
|
}
|
|
73984
74279
|
// src/domains/plan-parser/plan-validator.ts
|
|
73985
74280
|
var import_gray_matter6 = __toESM(require_gray_matter(), 1);
|
|
73986
|
-
import { existsSync as
|
|
74281
|
+
import { existsSync as existsSync58, readFileSync as readFileSync24 } from "node:fs";
|
|
73987
74282
|
import { basename as basename19, dirname as dirname37 } from "node:path";
|
|
73988
74283
|
function validatePlanFile(filePath, strict = false) {
|
|
73989
74284
|
const content = readFileSync24(filePath, "utf8");
|
|
@@ -74023,7 +74318,7 @@ function validatePlanFile(filePath, strict = false) {
|
|
|
74023
74318
|
});
|
|
74024
74319
|
}
|
|
74025
74320
|
for (const phase of phases) {
|
|
74026
|
-
if (phase.file && !
|
|
74321
|
+
if (phase.file && !existsSync58(phase.file)) {
|
|
74027
74322
|
const fileBasename = basename19(phase.file);
|
|
74028
74323
|
const refLine = lines.findIndex((l2) => l2.includes(fileBasename));
|
|
74029
74324
|
issues.push({
|
|
@@ -74044,7 +74339,7 @@ function validatePlanFile(filePath, strict = false) {
|
|
|
74044
74339
|
// src/domains/plan-parser/plan-writer.ts
|
|
74045
74340
|
var import_gray_matter7 = __toESM(require_gray_matter(), 1);
|
|
74046
74341
|
import { mkdirSync as mkdirSync9, readFileSync as readFileSync25, writeFileSync as writeFileSync12 } from "node:fs";
|
|
74047
|
-
import { existsSync as
|
|
74342
|
+
import { existsSync as existsSync59 } from "node:fs";
|
|
74048
74343
|
import { basename as basename20, dirname as dirname38, join as join126 } from "node:path";
|
|
74049
74344
|
function phaseNameToFilename(id, name) {
|
|
74050
74345
|
const numMatch = /^(\d+)([a-z]*)$/i.exec(id);
|
|
@@ -74139,9 +74434,9 @@ function resolvePhaseIds(phases) {
|
|
|
74139
74434
|
if (p2.id) {
|
|
74140
74435
|
const numMatch = /^(\d+)/.exec(p2.id);
|
|
74141
74436
|
if (numMatch) {
|
|
74142
|
-
const
|
|
74143
|
-
if (
|
|
74144
|
-
nextNum =
|
|
74437
|
+
const n2 = Number.parseInt(numMatch[1], 10);
|
|
74438
|
+
if (n2 >= nextNum)
|
|
74439
|
+
nextNum = n2 + 1;
|
|
74145
74440
|
}
|
|
74146
74441
|
return { id: p2.id, name: p2.name };
|
|
74147
74442
|
}
|
|
@@ -74226,7 +74521,7 @@ function updatePhaseStatus(planFile, phaseId, newStatus) {
|
|
|
74226
74521
|
writeFileSync12(planFile, updatedContent, "utf8");
|
|
74227
74522
|
const planDir = dirname38(planFile);
|
|
74228
74523
|
const phaseFilename = phaseNameFilenameFromTableRow(updatedBody, phaseId, planDir);
|
|
74229
|
-
if (phaseFilename &&
|
|
74524
|
+
if (phaseFilename && existsSync59(phaseFilename)) {
|
|
74230
74525
|
updatePhaseFileFrontmatter(phaseFilename, newStatus);
|
|
74231
74526
|
}
|
|
74232
74527
|
}
|
|
@@ -74266,8 +74561,8 @@ function addPhase(planFile, name, afterId) {
|
|
|
74266
74561
|
phaseId = nextSubPhaseId(afterId, existingIds);
|
|
74267
74562
|
} else {
|
|
74268
74563
|
const maxNum = existingIds.reduce((max, id) => {
|
|
74269
|
-
const
|
|
74270
|
-
return Number.isNaN(
|
|
74564
|
+
const n2 = Number.parseInt(id, 10);
|
|
74565
|
+
return Number.isNaN(n2) ? max : Math.max(max, n2);
|
|
74271
74566
|
}, 0);
|
|
74272
74567
|
phaseId = String(maxNum + 1);
|
|
74273
74568
|
}
|
|
@@ -74423,7 +74718,7 @@ async function handleValidate(target, options2) {
|
|
|
74423
74718
|
}
|
|
74424
74719
|
async function handleStatus(target, options2) {
|
|
74425
74720
|
const t = target ? resolve31(target) : null;
|
|
74426
|
-
const plansDir = t &&
|
|
74721
|
+
const plansDir = t && existsSync60(t) && statSync8(t).isDirectory() && !existsSync60(join127(t, "plan.md")) ? t : null;
|
|
74427
74722
|
if (plansDir) {
|
|
74428
74723
|
const planFiles = scanPlanDir(plansDir);
|
|
74429
74724
|
if (planFiles.length === 0) {
|
|
@@ -74654,12 +74949,12 @@ async function handleAddPhase(target, options2) {
|
|
|
74654
74949
|
// src/commands/plan/plan-command.ts
|
|
74655
74950
|
function resolvePlanFile(target) {
|
|
74656
74951
|
const t = target ? resolve33(target) : process.cwd();
|
|
74657
|
-
if (
|
|
74952
|
+
if (existsSync61(t)) {
|
|
74658
74953
|
const stat13 = statSync9(t);
|
|
74659
74954
|
if (stat13.isFile())
|
|
74660
74955
|
return t;
|
|
74661
74956
|
const candidate = join128(t, "plan.md");
|
|
74662
|
-
if (
|
|
74957
|
+
if (existsSync61(candidate))
|
|
74663
74958
|
return candidate;
|
|
74664
74959
|
}
|
|
74665
74960
|
if (!target) {
|
|
@@ -74667,7 +74962,7 @@ function resolvePlanFile(target) {
|
|
|
74667
74962
|
const root = parse4(dir).root;
|
|
74668
74963
|
while (dir !== root) {
|
|
74669
74964
|
const candidate = join128(dir, "plan.md");
|
|
74670
|
-
if (
|
|
74965
|
+
if (existsSync61(candidate))
|
|
74671
74966
|
return candidate;
|
|
74672
74967
|
dir = dirname41(dir);
|
|
74673
74968
|
}
|
|
@@ -74691,7 +74986,7 @@ function renderPhasesTable(phases) {
|
|
|
74691
74986
|
const maxId = Math.max(4, ...phases.map((p2) => p2.phaseId.length));
|
|
74692
74987
|
const maxName = Math.max(4, ...phases.map((p2) => p2.name.length));
|
|
74693
74988
|
const maxStatus = 11;
|
|
74694
|
-
const pad = (s3,
|
|
74989
|
+
const pad = (s3, n2) => s3.padEnd(n2);
|
|
74695
74990
|
const line = `${"-".repeat(maxId + 2)}+${"-".repeat(maxName + 2)}+${"-".repeat(maxStatus + 2)}`;
|
|
74696
74991
|
console.log(` ${pad("ID", maxId)} | ${pad("Name", maxName)} | Status`);
|
|
74697
74992
|
console.log(` ${line}`);
|
|
@@ -74717,7 +75012,7 @@ async function planCommand(action, target, options2) {
|
|
|
74717
75012
|
let resolvedTarget = target;
|
|
74718
75013
|
if (resolvedAction && !knownActions.has(resolvedAction)) {
|
|
74719
75014
|
const looksLikePath = resolvedAction.includes("/") || resolvedAction.includes("\\") || resolvedAction.endsWith(".md") || resolvedAction === "." || resolvedAction === "..";
|
|
74720
|
-
const existsOnDisk = !looksLikePath &&
|
|
75015
|
+
const existsOnDisk = !looksLikePath && existsSync61(resolve33(resolvedAction));
|
|
74721
75016
|
if (looksLikePath || existsOnDisk) {
|
|
74722
75017
|
resolvedTarget = resolvedAction;
|
|
74723
75018
|
resolvedAction = undefined;
|
|
@@ -74761,7 +75056,7 @@ init_logger();
|
|
|
74761
75056
|
init_logger();
|
|
74762
75057
|
|
|
74763
75058
|
// src/commands/telemetry/shared.ts
|
|
74764
|
-
import { existsSync as
|
|
75059
|
+
import { existsSync as existsSync62, readFileSync as readFileSync26, readdirSync as readdirSync11 } from "node:fs";
|
|
74765
75060
|
import { homedir as homedir29 } from "node:os";
|
|
74766
75061
|
import { join as join129 } from "node:path";
|
|
74767
75062
|
init_token_store();
|
|
@@ -74776,7 +75071,7 @@ var TELEMETRY_HOOK_FIELD = "hooks.telemetry";
|
|
|
74776
75071
|
var TOKEN_PLACEHOLDER = "__INJECT_AT_RELEASE__";
|
|
74777
75072
|
function readUserCache() {
|
|
74778
75073
|
try {
|
|
74779
|
-
if (!
|
|
75074
|
+
if (!existsSync62(USER_CACHE_PATH))
|
|
74780
75075
|
return null;
|
|
74781
75076
|
const parsed = JSON.parse(readFileSync26(USER_CACHE_PATH, "utf8"));
|
|
74782
75077
|
if (!parsed || typeof parsed !== "object")
|
|
@@ -74788,7 +75083,7 @@ function readUserCache() {
|
|
|
74788
75083
|
}
|
|
74789
75084
|
function countBufferFiles() {
|
|
74790
75085
|
try {
|
|
74791
|
-
if (!
|
|
75086
|
+
if (!existsSync62(EVENT_BUFFER_DIR))
|
|
74792
75087
|
return 0;
|
|
74793
75088
|
return readdirSync11(EVENT_BUFFER_DIR).filter((f4) => f4.endsWith(".jsonl")).length;
|
|
74794
75089
|
} catch {
|
|
@@ -74826,8 +75121,8 @@ function collectRuntimeContext() {
|
|
|
74826
75121
|
cacheSource: cache3?.source === "gh" || cache3?.source === "manual" ? cache3.source : null,
|
|
74827
75122
|
bufferFileCount: countBufferFiles(),
|
|
74828
75123
|
bufferDir: EVENT_BUFFER_DIR,
|
|
74829
|
-
rateStateExists:
|
|
74830
|
-
userCacheExists:
|
|
75124
|
+
rateStateExists: existsSync62(RATE_STATE_PATH),
|
|
75125
|
+
userCacheExists: existsSync62(USER_CACHE_PATH),
|
|
74831
75126
|
endpoint,
|
|
74832
75127
|
tokenConfigured: Boolean(token)
|
|
74833
75128
|
};
|
|
@@ -74988,13 +75283,13 @@ init_logger();
|
|
|
74988
75283
|
init_safe_prompts();
|
|
74989
75284
|
init_takumi_constants();
|
|
74990
75285
|
var import_picocolors27 = __toESM(require_picocolors(), 1);
|
|
74991
|
-
import { existsSync as
|
|
75286
|
+
import { existsSync as existsSync63, readdirSync as readdirSync12, rmSync as rmSync8 } from "node:fs";
|
|
74992
75287
|
import { dirname as dirname42, join as join130 } from "node:path";
|
|
74993
75288
|
function listPresentManifestNames(installPath) {
|
|
74994
75289
|
const present = [];
|
|
74995
|
-
if (
|
|
75290
|
+
if (existsSync63(getManifestPath(installPath)))
|
|
74996
75291
|
present.push(MANIFEST_FILENAME);
|
|
74997
|
-
if (
|
|
75292
|
+
if (existsSync63(getLegacyManifestPath(installPath)))
|
|
74998
75293
|
present.push(LEGACY_MANIFEST_FILENAME);
|
|
74999
75294
|
return present;
|
|
75000
75295
|
}
|
|
@@ -75948,13 +76243,13 @@ function registerCommands(cli) {
|
|
|
75948
76243
|
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
76244
|
let port;
|
|
75950
76245
|
if (options2.port !== undefined) {
|
|
75951
|
-
const
|
|
75952
|
-
if (!Number.isInteger(
|
|
76246
|
+
const n2 = Number(options2.port);
|
|
76247
|
+
if (!Number.isInteger(n2) || n2 < 0 || n2 > 65535) {
|
|
75953
76248
|
console.error(`Invalid --port value: ${options2.port}. Expected integer 0-65535.`);
|
|
75954
76249
|
process.exitCode = 1;
|
|
75955
76250
|
return;
|
|
75956
76251
|
}
|
|
75957
|
-
port =
|
|
76252
|
+
port = n2;
|
|
75958
76253
|
}
|
|
75959
76254
|
await consoleCommand({ port, noOpen: options2.open === false });
|
|
75960
76255
|
});
|