@sunasteriskrnd/takumi 1.0.0-dev.34 → 1.0.0-dev.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.36",
|
|
19819
19819
|
description: "CLI tool for bootstrapping and managing Takumi projects",
|
|
19820
19820
|
type: "module",
|
|
19821
19821
|
repository: {
|
|
@@ -43277,6 +43277,43 @@ var init_capabilities = __esm(() => {
|
|
|
43277
43277
|
import_semver4 = __toESM(require_semver2(), 1);
|
|
43278
43278
|
execFileAsync2 = promisify2(execFile2);
|
|
43279
43279
|
CODEX_CAPABILITY_TABLE = [
|
|
43280
|
+
{
|
|
43281
|
+
version: "0.138.0",
|
|
43282
|
+
events: {
|
|
43283
|
+
SessionStart: {
|
|
43284
|
+
supported: true,
|
|
43285
|
+
supportsAdditionalContext: true,
|
|
43286
|
+
allowedMatchers: ["startup", "resume", "clear"]
|
|
43287
|
+
},
|
|
43288
|
+
UserPromptSubmit: {
|
|
43289
|
+
supported: true,
|
|
43290
|
+
supportsAdditionalContext: true
|
|
43291
|
+
},
|
|
43292
|
+
PreToolUse: {
|
|
43293
|
+
supported: true,
|
|
43294
|
+
supportsAdditionalContext: true,
|
|
43295
|
+
permissionDecisionValues: ["deny", "allow", "block"]
|
|
43296
|
+
},
|
|
43297
|
+
PostToolUse: {
|
|
43298
|
+
supported: true,
|
|
43299
|
+
supportsAdditionalContext: true
|
|
43300
|
+
},
|
|
43301
|
+
PermissionRequest: {
|
|
43302
|
+
supported: true,
|
|
43303
|
+
supportsAdditionalContext: false
|
|
43304
|
+
},
|
|
43305
|
+
Stop: {
|
|
43306
|
+
supported: true,
|
|
43307
|
+
supportsAdditionalContext: false
|
|
43308
|
+
},
|
|
43309
|
+
SubagentStop: {
|
|
43310
|
+
supported: true,
|
|
43311
|
+
supportsAdditionalContext: false
|
|
43312
|
+
}
|
|
43313
|
+
},
|
|
43314
|
+
sessionStartMatchersOnly: ["startup", "resume", "clear"],
|
|
43315
|
+
requiresFeatureFlag: true
|
|
43316
|
+
},
|
|
43280
43317
|
{
|
|
43281
43318
|
version: "0.130.0",
|
|
43282
43319
|
events: {
|
|
@@ -49082,11 +49119,11 @@ var exports_monorepo_resolver = {};
|
|
|
49082
49119
|
__export(exports_monorepo_resolver, {
|
|
49083
49120
|
resolveMonorepoRoot: () => resolveMonorepoRoot
|
|
49084
49121
|
});
|
|
49085
|
-
import { existsSync as
|
|
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)}`;
|
|
@@ -54890,11 +54927,15 @@ async function route(req, res, version3) {
|
|
|
54890
54927
|
const pathname = url.pathname;
|
|
54891
54928
|
applyCorsHeaders(req, res);
|
|
54892
54929
|
if (req.method === "OPTIONS") {
|
|
54893
|
-
|
|
54930
|
+
const headers = {
|
|
54894
54931
|
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
54895
54932
|
"Access-Control-Allow-Headers": "content-type",
|
|
54896
54933
|
"Access-Control-Max-Age": "600"
|
|
54897
|
-
}
|
|
54934
|
+
};
|
|
54935
|
+
if (req.headers["access-control-request-private-network"] === "true") {
|
|
54936
|
+
headers["Access-Control-Allow-Private-Network"] = "true";
|
|
54937
|
+
}
|
|
54938
|
+
res.writeHead(204, headers);
|
|
54898
54939
|
res.end();
|
|
54899
54940
|
return;
|
|
54900
54941
|
}
|
|
@@ -56970,6 +57011,26 @@ async function checkCodexHooksHealth() {
|
|
|
56970
57011
|
details: configTomlPath,
|
|
56971
57012
|
autoFixable: false
|
|
56972
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
|
+
});
|
|
56973
57034
|
const missing = await collectMissingWrapperTargets(hooksJsonPath);
|
|
56974
57035
|
results.push(missing.length === 0 ? {
|
|
56975
57036
|
id: "codex-hooks-command-targets",
|
|
@@ -56992,6 +57053,18 @@ async function checkCodexHooksHealth() {
|
|
|
56992
57053
|
});
|
|
56993
57054
|
return results;
|
|
56994
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
|
+
}
|
|
56995
57068
|
async function collectMissingWrapperTargets(hooksJsonPath) {
|
|
56996
57069
|
let parsed;
|
|
56997
57070
|
try {
|
|
@@ -60080,6 +60153,119 @@ async function readStdinJson() {
|
|
|
60080
60153
|
}
|
|
60081
60154
|
}
|
|
60082
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
|
+
|
|
60083
60269
|
// src/domains/hooks/telemetry/lib/detached-put.ts
|
|
60084
60270
|
import { spawn as spawn2 } from "node:child_process";
|
|
60085
60271
|
import { openSync as openSync4 } from "node:fs";
|
|
@@ -60322,7 +60508,7 @@ function buildSessionPayload(args) {
|
|
|
60322
60508
|
|
|
60323
60509
|
// src/domains/hooks/telemetry/lib/summary.ts
|
|
60324
60510
|
import { promises as fs21 } from "node:fs";
|
|
60325
|
-
function
|
|
60511
|
+
function zeroTokens2() {
|
|
60326
60512
|
return { input: 0, output: 0, cache_read: 0, cache_write: 0 };
|
|
60327
60513
|
}
|
|
60328
60514
|
function initialSummary(args) {
|
|
@@ -60334,7 +60520,7 @@ function initialSummary(args) {
|
|
|
60334
60520
|
kit_versions: args.kitVersions ?? {},
|
|
60335
60521
|
project: args.project,
|
|
60336
60522
|
timing: { started_at: args.startedAt, ended_at: null, duration_s: null },
|
|
60337
|
-
main_loop_tokens:
|
|
60523
|
+
main_loop_tokens: zeroTokens2(),
|
|
60338
60524
|
token_usage: {},
|
|
60339
60525
|
subagents: [],
|
|
60340
60526
|
skills: [],
|
|
@@ -60347,7 +60533,7 @@ function initialSummary(args) {
|
|
|
60347
60533
|
subagents: { by_type: {} },
|
|
60348
60534
|
skills: { by_name: {} }
|
|
60349
60535
|
},
|
|
60350
|
-
totals:
|
|
60536
|
+
totals: zeroTokens2(),
|
|
60351
60537
|
pending_user_triggers: [],
|
|
60352
60538
|
skills_in_flight: {},
|
|
60353
60539
|
transcript_offset: 0,
|
|
@@ -60435,119 +60621,6 @@ async function shouldFlush(args) {
|
|
|
60435
60621
|
return false;
|
|
60436
60622
|
}
|
|
60437
60623
|
|
|
60438
|
-
// src/domains/hooks/telemetry/lib/transcript-reader.ts
|
|
60439
|
-
function num2(v2) {
|
|
60440
|
-
return typeof v2 === "number" && Number.isFinite(v2) ? v2 : 0;
|
|
60441
|
-
}
|
|
60442
|
-
function zeroTokens2() {
|
|
60443
|
-
return { input: 0, output: 0, cache_read: 0, cache_write: 0 };
|
|
60444
|
-
}
|
|
60445
|
-
function addTokens2(a3, b3) {
|
|
60446
|
-
return {
|
|
60447
|
-
input: a3.input + b3.input,
|
|
60448
|
-
output: a3.output + b3.output,
|
|
60449
|
-
cache_read: a3.cache_read + b3.cache_read,
|
|
60450
|
-
cache_write: a3.cache_write + b3.cache_write
|
|
60451
|
-
};
|
|
60452
|
-
}
|
|
60453
|
-
function extractTokens(record) {
|
|
60454
|
-
const usage = record.message?.usage;
|
|
60455
|
-
if (!usage)
|
|
60456
|
-
return null;
|
|
60457
|
-
return {
|
|
60458
|
-
input: num2(usage.input_tokens),
|
|
60459
|
-
output: num2(usage.output_tokens),
|
|
60460
|
-
cache_read: num2(usage.cache_read_input_tokens),
|
|
60461
|
-
cache_write: num2(usage.cache_creation_input_tokens)
|
|
60462
|
-
};
|
|
60463
|
-
}
|
|
60464
|
-
async function tailRead(args) {
|
|
60465
|
-
const { records, newOffset } = readNew(args.transcriptPath, args.offset);
|
|
60466
|
-
return { records, nextOffset: newOffset };
|
|
60467
|
-
}
|
|
60468
|
-
function bucketTokens(records) {
|
|
60469
|
-
const mainLoopDelta = zeroTokens2();
|
|
60470
|
-
const subagentDeltas = new Map;
|
|
60471
|
-
const tokenUsageDeltas = new Map;
|
|
60472
|
-
for (const record of records) {
|
|
60473
|
-
if (record.type !== "assistant")
|
|
60474
|
-
continue;
|
|
60475
|
-
const tokens = extractTokens(record);
|
|
60476
|
-
if (!tokens)
|
|
60477
|
-
continue;
|
|
60478
|
-
if (record.isSidechain === true) {
|
|
60479
|
-
const key = record.agentId ?? record.toolUseID;
|
|
60480
|
-
if (!key) {
|
|
60481
|
-
const prev2 = mainLoopDelta;
|
|
60482
|
-
Object.assign(mainLoopDelta, addTokens2(prev2, tokens));
|
|
60483
|
-
continue;
|
|
60484
|
-
}
|
|
60485
|
-
const prev = subagentDeltas.get(key) ?? zeroTokens2();
|
|
60486
|
-
subagentDeltas.set(key, addTokens2(prev, tokens));
|
|
60487
|
-
} else {
|
|
60488
|
-
Object.assign(mainLoopDelta, addTokens2(mainLoopDelta, tokens));
|
|
60489
|
-
}
|
|
60490
|
-
const model = record.message?.model;
|
|
60491
|
-
if (model) {
|
|
60492
|
-
const prev = tokenUsageDeltas.get(model) ?? zeroTokens2();
|
|
60493
|
-
tokenUsageDeltas.set(model, addTokens2(prev, tokens));
|
|
60494
|
-
}
|
|
60495
|
-
}
|
|
60496
|
-
return { mainLoopDelta, subagentDeltas, tokenUsageDeltas };
|
|
60497
|
-
}
|
|
60498
|
-
|
|
60499
|
-
// src/domains/hooks/telemetry/lib/transcript-apply.ts
|
|
60500
|
-
function ensureTokens(t) {
|
|
60501
|
-
return t ?? { input: 0, output: 0, cache_read: 0, cache_write: 0 };
|
|
60502
|
-
}
|
|
60503
|
-
function addTokens3(a3, b3) {
|
|
60504
|
-
return {
|
|
60505
|
-
input: a3.input + b3.input,
|
|
60506
|
-
output: a3.output + b3.output,
|
|
60507
|
-
cache_read: a3.cache_read + b3.cache_read,
|
|
60508
|
-
cache_write: a3.cache_write + b3.cache_write
|
|
60509
|
-
};
|
|
60510
|
-
}
|
|
60511
|
-
function mergeTokenUsageDeltas(existing, deltas) {
|
|
60512
|
-
const out = { ...existing ?? {} };
|
|
60513
|
-
for (const [model, delta] of deltas) {
|
|
60514
|
-
out[model] = addTokens3(ensureTokens(out[model]), delta);
|
|
60515
|
-
}
|
|
60516
|
-
return out;
|
|
60517
|
-
}
|
|
60518
|
-
async function applyTranscriptDelta(args) {
|
|
60519
|
-
if (!args.transcriptPath) {
|
|
60520
|
-
return { summary: args.summary, read: false };
|
|
60521
|
-
}
|
|
60522
|
-
try {
|
|
60523
|
-
const { records, nextOffset } = await tailRead({
|
|
60524
|
-
transcriptPath: args.transcriptPath,
|
|
60525
|
-
offset: args.summary.transcript_offset
|
|
60526
|
-
});
|
|
60527
|
-
if (records.length === 0 && nextOffset === args.summary.transcript_offset) {
|
|
60528
|
-
return { summary: args.summary, read: true };
|
|
60529
|
-
}
|
|
60530
|
-
const { mainLoopDelta, subagentDeltas, tokenUsageDeltas } = bucketTokens(records);
|
|
60531
|
-
const updated = {
|
|
60532
|
-
...args.summary,
|
|
60533
|
-
main_loop_tokens: addTokens3(args.summary.main_loop_tokens, mainLoopDelta),
|
|
60534
|
-
subagents: args.summary.subagents.map((rec) => {
|
|
60535
|
-
const delta = subagentDeltas.get(rec.id);
|
|
60536
|
-
if (!delta)
|
|
60537
|
-
return rec;
|
|
60538
|
-
return { ...rec, tokens: addTokens3(ensureTokens(rec.tokens), delta) };
|
|
60539
|
-
}),
|
|
60540
|
-
token_usage: mergeTokenUsageDeltas(args.summary.token_usage, tokenUsageDeltas),
|
|
60541
|
-
transcript_offset: nextOffset
|
|
60542
|
-
};
|
|
60543
|
-
return { summary: updated, read: true };
|
|
60544
|
-
} catch (e2) {
|
|
60545
|
-
const error = e2?.message ?? String(e2);
|
|
60546
|
-
hookLog("transcript_apply", { error });
|
|
60547
|
-
return { summary: args.summary, read: false, error };
|
|
60548
|
-
}
|
|
60549
|
-
}
|
|
60550
|
-
|
|
60551
60624
|
// src/domains/hooks/telemetry/flush/session-end.ts
|
|
60552
60625
|
var PUT_TIMEOUT_MS = 5000;
|
|
60553
60626
|
function readCliVersion() {
|
|
@@ -60593,7 +60666,7 @@ async function runSessionEndFlush(data, ctx) {
|
|
|
60593
60666
|
const transcriptPath = typeof data.transcript_path === "string" ? data.transcript_path : (await readMeta(sessionDir))?.transcript_path ?? null;
|
|
60594
60667
|
let finalSummary = summary;
|
|
60595
60668
|
if (transcriptPath) {
|
|
60596
|
-
const applied = await
|
|
60669
|
+
const applied = await applyClaudeTranscriptDelta({ summary, transcriptPath });
|
|
60597
60670
|
if (applied.read)
|
|
60598
60671
|
finalSummary = applied.summary;
|
|
60599
60672
|
}
|
|
@@ -60681,13 +60754,123 @@ async function handleSessionEnd(agent, flags = {}) {
|
|
|
60681
60754
|
// src/domains/hooks/telemetry/flush/stop.ts
|
|
60682
60755
|
init_takumi_constants();
|
|
60683
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
|
+
|
|
60684
60867
|
// src/domains/hooks/lib/jsonl-append.ts
|
|
60685
|
-
import { promises as
|
|
60868
|
+
import { promises as fs24, appendFileSync as appendFileSync2, mkdirSync as mkdirSync4 } from "node:fs";
|
|
60686
60869
|
import { dirname as dirname27 } from "node:path";
|
|
60687
60870
|
async function appendJsonl(filePath, record) {
|
|
60688
60871
|
try {
|
|
60689
|
-
await
|
|
60690
|
-
await
|
|
60872
|
+
await fs24.mkdir(dirname27(filePath), { recursive: true });
|
|
60873
|
+
await fs24.appendFile(filePath, `${JSON.stringify(record)}
|
|
60691
60874
|
`, "utf8");
|
|
60692
60875
|
} catch {}
|
|
60693
60876
|
}
|
|
@@ -60841,9 +61024,10 @@ async function runStopFlush(data, ctx) {
|
|
|
60841
61024
|
const endedAtIso = new Date().toISOString();
|
|
60842
61025
|
const startedAtIso = typeof data.session_started_at === "string" ? data.session_started_at : endedAtIso;
|
|
60843
61026
|
const transcriptPath = typeof data.transcript_path === "string" ? data.transcript_path : null;
|
|
61027
|
+
const stdinModel = typeof data.model === "string" && data.model ? data.model : null;
|
|
60844
61028
|
const manifest = readManifestVersions(cwd2);
|
|
60845
61029
|
const cliVersion = readCliVersion2();
|
|
60846
|
-
const hasTranscript = agent === "claude"
|
|
61030
|
+
const hasTranscript = Boolean(transcriptPath) && (agent === "claude" || agent === "codex");
|
|
60847
61031
|
const result = await recordEvent({
|
|
60848
61032
|
agent,
|
|
60849
61033
|
cwd: cwd2,
|
|
@@ -60873,7 +61057,11 @@ async function runStopFlush(data, ctx) {
|
|
|
60873
61057
|
setHookDebugLog(sessionDebugLogPath(result.sessionDir));
|
|
60874
61058
|
let payloadSummary = result.summary;
|
|
60875
61059
|
if (hasTranscript && transcriptPath) {
|
|
60876
|
-
const applied = await
|
|
61060
|
+
const applied = agent === "codex" ? await applyCodexTranscriptDelta({
|
|
61061
|
+
summary: result.summary,
|
|
61062
|
+
transcriptPath,
|
|
61063
|
+
stdinModel
|
|
61064
|
+
}) : await applyClaudeTranscriptDelta({
|
|
60877
61065
|
summary: result.summary,
|
|
60878
61066
|
transcriptPath
|
|
60879
61067
|
});
|
|
@@ -60958,15 +61146,15 @@ async function handleStop(agent, flags = {}) {
|
|
|
60958
61146
|
|
|
60959
61147
|
// src/domains/hooks/telemetry/otlp/observations-export.ts
|
|
60960
61148
|
init_paths2();
|
|
60961
|
-
import { promises as
|
|
61149
|
+
import { promises as fs28, openSync as openSync6 } from "node:fs";
|
|
60962
61150
|
import { join as join99 } from "node:path";
|
|
60963
61151
|
|
|
60964
61152
|
// src/domains/hooks/telemetry/lib/retention.ts
|
|
60965
|
-
import { promises as
|
|
61153
|
+
import { promises as fs25 } from "node:fs";
|
|
60966
61154
|
import { join as join98 } from "node:path";
|
|
60967
61155
|
async function pathExists24(path10) {
|
|
60968
61156
|
try {
|
|
60969
|
-
await
|
|
61157
|
+
await fs25.access(path10);
|
|
60970
61158
|
return true;
|
|
60971
61159
|
} catch {
|
|
60972
61160
|
return false;
|
|
@@ -60978,7 +61166,7 @@ async function hasUnexportedObservations(dir) {
|
|
|
60978
61166
|
async function decideDelete(dir, args) {
|
|
60979
61167
|
let mtimeMs = 0;
|
|
60980
61168
|
try {
|
|
60981
|
-
const stat8 = await
|
|
61169
|
+
const stat8 = await fs25.stat(dir);
|
|
60982
61170
|
if (!stat8.isDirectory())
|
|
60983
61171
|
return false;
|
|
60984
61172
|
mtimeMs = stat8.mtimeMs;
|
|
@@ -60997,8 +61185,8 @@ async function decideDelete(dir, args) {
|
|
|
60997
61185
|
}
|
|
60998
61186
|
async function listChildren(dir) {
|
|
60999
61187
|
try {
|
|
61000
|
-
const names = await
|
|
61001
|
-
return names.map((
|
|
61188
|
+
const names = await fs25.readdir(dir);
|
|
61189
|
+
return names.map((n2) => join98(dir, n2));
|
|
61002
61190
|
} catch {
|
|
61003
61191
|
return [];
|
|
61004
61192
|
}
|
|
@@ -61033,7 +61221,7 @@ async function sweepRetention(args) {
|
|
|
61033
61221
|
continue;
|
|
61034
61222
|
}
|
|
61035
61223
|
try {
|
|
61036
|
-
await
|
|
61224
|
+
await fs25.rm(dir, { recursive: true, force: true });
|
|
61037
61225
|
deleted.push(dir);
|
|
61038
61226
|
} catch {}
|
|
61039
61227
|
}
|
|
@@ -61041,10 +61229,10 @@ async function sweepRetention(args) {
|
|
|
61041
61229
|
}
|
|
61042
61230
|
|
|
61043
61231
|
// src/domains/hooks/telemetry/otlp/observations-export-state.ts
|
|
61044
|
-
import { promises as
|
|
61232
|
+
import { promises as fs26 } from "node:fs";
|
|
61045
61233
|
async function exists(path10) {
|
|
61046
61234
|
try {
|
|
61047
|
-
await
|
|
61235
|
+
await fs26.access(path10);
|
|
61048
61236
|
return true;
|
|
61049
61237
|
} catch {
|
|
61050
61238
|
return false;
|
|
@@ -61056,7 +61244,7 @@ async function stageObservationsForFlush(sessionDir) {
|
|
|
61056
61244
|
return flushing;
|
|
61057
61245
|
const live = getObservationsFile(sessionDir);
|
|
61058
61246
|
try {
|
|
61059
|
-
await
|
|
61247
|
+
await fs26.rename(live, flushing);
|
|
61060
61248
|
return flushing;
|
|
61061
61249
|
} catch {
|
|
61062
61250
|
return null;
|
|
@@ -61064,15 +61252,15 @@ async function stageObservationsForFlush(sessionDir) {
|
|
|
61064
61252
|
}
|
|
61065
61253
|
async function completeObservationsFlush(sessionDir, flushingPath, now) {
|
|
61066
61254
|
try {
|
|
61067
|
-
await
|
|
61255
|
+
await fs26.writeFile(getObservationsPushedFile(sessionDir), String(now), "utf8");
|
|
61068
61256
|
} catch {}
|
|
61069
61257
|
try {
|
|
61070
|
-
await
|
|
61258
|
+
await fs26.rm(flushingPath, { force: true });
|
|
61071
61259
|
} catch {}
|
|
61072
61260
|
}
|
|
61073
61261
|
async function readObsPushed(sessionDir) {
|
|
61074
61262
|
try {
|
|
61075
|
-
const raw = await
|
|
61263
|
+
const raw = await fs26.readFile(getObservationsPushedFile(sessionDir), "utf8");
|
|
61076
61264
|
const parsed = Number.parseInt(raw.trim(), 10);
|
|
61077
61265
|
return Number.isFinite(parsed) ? parsed : null;
|
|
61078
61266
|
} catch {
|
|
@@ -61087,7 +61275,7 @@ async function shouldFlushObservations(sessionDir, gate) {
|
|
|
61087
61275
|
return true;
|
|
61088
61276
|
let size = 0;
|
|
61089
61277
|
try {
|
|
61090
|
-
size = (await
|
|
61278
|
+
size = (await fs26.stat(getObservationsFile(sessionDir))).size;
|
|
61091
61279
|
} catch {
|
|
61092
61280
|
return false;
|
|
61093
61281
|
}
|
|
@@ -61114,7 +61302,7 @@ async function resolveOtlpConfig() {
|
|
|
61114
61302
|
|
|
61115
61303
|
// src/domains/hooks/telemetry/otlp/otlp-post.ts
|
|
61116
61304
|
import { spawn as spawn3 } from "node:child_process";
|
|
61117
|
-
import { promises as
|
|
61305
|
+
import { promises as fs27, openSync as openSync5 } from "node:fs";
|
|
61118
61306
|
|
|
61119
61307
|
// src/domains/hooks/telemetry/otlp/otlp-payload-builder.ts
|
|
61120
61308
|
import { createHash as createHash10 } from "node:crypto";
|
|
@@ -61299,7 +61487,7 @@ async function runOtlpPost(job, deps = {}) {
|
|
|
61299
61487
|
const now = deps.now ?? Date.now;
|
|
61300
61488
|
let content;
|
|
61301
61489
|
try {
|
|
61302
|
-
content = await
|
|
61490
|
+
content = await fs27.readFile(job.flushingPath, "utf8");
|
|
61303
61491
|
} catch {
|
|
61304
61492
|
return { ok: false, skipped: true, error: "no_flushing_file" };
|
|
61305
61493
|
}
|
|
@@ -61443,7 +61631,7 @@ function lockPath() {
|
|
|
61443
61631
|
async function acquireSweepLock(now) {
|
|
61444
61632
|
const path10 = lockPath();
|
|
61445
61633
|
try {
|
|
61446
|
-
await
|
|
61634
|
+
await fs28.mkdir(getConfigDir(), { recursive: true });
|
|
61447
61635
|
} catch {
|
|
61448
61636
|
return false;
|
|
61449
61637
|
}
|
|
@@ -61452,9 +61640,9 @@ async function acquireSweepLock(now) {
|
|
|
61452
61640
|
return true;
|
|
61453
61641
|
} catch {
|
|
61454
61642
|
try {
|
|
61455
|
-
const stat8 = await
|
|
61643
|
+
const stat8 = await fs28.stat(path10);
|
|
61456
61644
|
if (now - stat8.mtimeMs > STALE_LOCK_MS) {
|
|
61457
|
-
await
|
|
61645
|
+
await fs28.rm(path10, { force: true });
|
|
61458
61646
|
openSync6(path10, "wx");
|
|
61459
61647
|
return true;
|
|
61460
61648
|
}
|
|
@@ -61464,7 +61652,7 @@ async function acquireSweepLock(now) {
|
|
|
61464
61652
|
}
|
|
61465
61653
|
async function releaseSweepLock() {
|
|
61466
61654
|
try {
|
|
61467
|
-
await
|
|
61655
|
+
await fs28.rm(lockPath(), { force: true });
|
|
61468
61656
|
} catch {}
|
|
61469
61657
|
}
|
|
61470
61658
|
async function flushOrphanObservations(deps = {}) {
|
|
@@ -61554,6 +61742,10 @@ function classifyTool(toolName, toolInput) {
|
|
|
61554
61742
|
const subagent = typeof input.subagent_type === "string" ? input.subagent_type : null;
|
|
61555
61743
|
return { kind: "agent", name: capName(subagent) || "unknown" };
|
|
61556
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
|
+
}
|
|
61557
61749
|
if (toolName === "Skill") {
|
|
61558
61750
|
const skill = typeof input.skill === "string" ? input.skill : null;
|
|
61559
61751
|
return { kind: "skill", name: capName(skill) || "unknown" };
|
|
@@ -61666,7 +61858,7 @@ async function runPostToolUseCapture(data, ctx) {
|
|
|
61666
61858
|
const before = await readSummary(sessionDir);
|
|
61667
61859
|
const baseline = before?.skills_in_flight[classified.name]?.baseline;
|
|
61668
61860
|
if (before && baseline) {
|
|
61669
|
-
const applied = await
|
|
61861
|
+
const applied = await applyClaudeTranscriptDelta({ summary: before, transcriptPath });
|
|
61670
61862
|
if (applied.read) {
|
|
61671
61863
|
await writeSummary(sessionDir, applied.summary);
|
|
61672
61864
|
skillTokens = diffTokens(applied.summary.main_loop_tokens, baseline);
|
|
@@ -61837,6 +62029,103 @@ async function handleSessionStart(agent, flags = {}) {
|
|
|
61837
62029
|
await runSessionStartCapture(data, { agent, cwd: process.cwd(), flags });
|
|
61838
62030
|
}
|
|
61839
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
|
+
|
|
61840
62129
|
// src/domains/hooks/telemetry/lib/trigger-detector.ts
|
|
61841
62130
|
var SLASH_COMMAND_RE = /\B\/(?:[a-z][a-z0-9-]*:)?([a-z][a-z0-9-]*)/g;
|
|
61842
62131
|
var SUBAGENT_MENTION_RE = /\buse the ([a-z][a-z0-9-]+) (?:agent|subagent)\b/gi;
|
|
@@ -61952,8 +62241,9 @@ var metricsRecord = {
|
|
|
61952
62241
|
name: "metrics-record",
|
|
61953
62242
|
category: "metrics",
|
|
61954
62243
|
policy: "record",
|
|
61955
|
-
events: ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse"],
|
|
62244
|
+
events: ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "SubagentStop"],
|
|
61956
62245
|
matchers: { SessionStart: "startup|resume|clear|compact" },
|
|
62246
|
+
codexOnlyEvents: ["SubagentStop"],
|
|
61957
62247
|
async run(input, ctx) {
|
|
61958
62248
|
const cc = metricsCaptureContext(ctx);
|
|
61959
62249
|
switch (ctx.event) {
|
|
@@ -61969,6 +62259,9 @@ var metricsRecord = {
|
|
|
61969
62259
|
case "PostToolUse":
|
|
61970
62260
|
await runPostToolUseCapture(input, cc);
|
|
61971
62261
|
return METRICS_RECORD_RESULT;
|
|
62262
|
+
case "SubagentStop":
|
|
62263
|
+
await runSubagentStopCapture(input, cc);
|
|
62264
|
+
return METRICS_RECORD_RESULT;
|
|
61972
62265
|
default:
|
|
61973
62266
|
return { status: "no-op", timingMs: 0 };
|
|
61974
62267
|
}
|
|
@@ -61980,7 +62273,7 @@ import { mkdirSync as mkdirSync5 } from "node:fs";
|
|
|
61980
62273
|
import { dirname as dirname28, join as join103 } from "node:path";
|
|
61981
62274
|
|
|
61982
62275
|
// src/domains/hooks/handlers/_shared/project-detector.ts
|
|
61983
|
-
import { existsSync as
|
|
62276
|
+
import { existsSync as existsSync47, readFileSync as readFileSync15 } from "node:fs";
|
|
61984
62277
|
import { join as join100 } from "node:path";
|
|
61985
62278
|
var LOCKFILE_PRIORITY = [
|
|
61986
62279
|
{ manager: "bun", files: ["bun.lockb", "bun.lock"] },
|
|
@@ -62016,7 +62309,7 @@ var APP_FRAMEWORKS = new Set([
|
|
|
62016
62309
|
var WORKSPACE_MARKER_FILES = ["pnpm-workspace.yaml", "turbo.json", "lerna.json"];
|
|
62017
62310
|
function fileExists(cwd2, name) {
|
|
62018
62311
|
try {
|
|
62019
|
-
return
|
|
62312
|
+
return existsSync47(join100(cwd2, name));
|
|
62020
62313
|
} catch {
|
|
62021
62314
|
return false;
|
|
62022
62315
|
}
|
|
@@ -62110,13 +62403,13 @@ import { platform as platform8, userInfo } from "node:os";
|
|
|
62110
62403
|
import { join as join102 } from "node:path";
|
|
62111
62404
|
|
|
62112
62405
|
// src/domains/hooks/handlers/session-init/plan-resolver.ts
|
|
62113
|
-
import { existsSync as
|
|
62406
|
+
import { existsSync as existsSync48, readFileSync as readFileSync16, readdirSync as readdirSync7 } from "node:fs";
|
|
62114
62407
|
import { join as join101 } from "node:path";
|
|
62115
62408
|
var MAX_PLAN_DIRS = 100;
|
|
62116
62409
|
var MAX_PLAN_FILE_BYTES = 64 * 1024;
|
|
62117
62410
|
function listPlanDirs(plansPath) {
|
|
62118
62411
|
try {
|
|
62119
|
-
if (!
|
|
62412
|
+
if (!existsSync48(plansPath))
|
|
62120
62413
|
return [];
|
|
62121
62414
|
return readdirSync7(plansPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().slice(0, MAX_PLAN_DIRS);
|
|
62122
62415
|
} catch {
|
|
@@ -62126,7 +62419,7 @@ function listPlanDirs(plansPath) {
|
|
|
62126
62419
|
function planFileMentionsSession(planDir, sessionId) {
|
|
62127
62420
|
try {
|
|
62128
62421
|
const planFile = join101(planDir, "plan.md");
|
|
62129
|
-
if (!
|
|
62422
|
+
if (!existsSync48(planFile))
|
|
62130
62423
|
return false;
|
|
62131
62424
|
const body = readFileSync16(planFile, { encoding: "utf8" });
|
|
62132
62425
|
if (body.length > MAX_PLAN_FILE_BYTES)
|
|
@@ -62355,7 +62648,7 @@ var sessionInit = {
|
|
|
62355
62648
|
// src/domains/hooks/handlers/_shared/context-assembler.ts
|
|
62356
62649
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
62357
62650
|
import { createHash as createHash12 } from "node:crypto";
|
|
62358
|
-
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";
|
|
62359
62652
|
import { homedir as homedir27, platform as platform9, tmpdir as tmpdir4 } from "node:os";
|
|
62360
62653
|
import { basename as basename18, join as join104, resolve as resolve21 } from "node:path";
|
|
62361
62654
|
var INJECTED_TTL_MS = 12 * 60 * 60 * 1000;
|
|
@@ -62443,7 +62736,7 @@ function stateFile(sessionId, scope, transcriptPath) {
|
|
|
62443
62736
|
}
|
|
62444
62737
|
function readState(file) {
|
|
62445
62738
|
try {
|
|
62446
|
-
if (!
|
|
62739
|
+
if (!existsSync49(file))
|
|
62447
62740
|
return null;
|
|
62448
62741
|
return JSON.parse(readFileSync17(file, "utf8"));
|
|
62449
62742
|
} catch {
|
|
@@ -62510,7 +62803,7 @@ function clearPending(sessionId, scope, transcriptPath) {
|
|
|
62510
62803
|
function resolveSkillsVenv(_cwd) {
|
|
62511
62804
|
const base = join104(homedir27(), ".claude", "skills", ".venv");
|
|
62512
62805
|
const interpreter = platform9() === "win32" ? join104(base, "Scripts", "python.exe") : join104(base, "bin", "python3");
|
|
62513
|
-
return
|
|
62806
|
+
return existsSync49(interpreter) ? interpreter : null;
|
|
62514
62807
|
}
|
|
62515
62808
|
|
|
62516
62809
|
// src/domains/hooks/handlers/session-prompt-context/handler.ts
|
|
@@ -62577,7 +62870,7 @@ function gitFacts(dir) {
|
|
|
62577
62870
|
};
|
|
62578
62871
|
}
|
|
62579
62872
|
function stamp(fmt, now) {
|
|
62580
|
-
const p = (
|
|
62873
|
+
const p = (n2) => String(n2).padStart(2, "0");
|
|
62581
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()));
|
|
62582
62875
|
}
|
|
62583
62876
|
function planDirTemplate(format, dateStr) {
|
|
@@ -63267,7 +63560,7 @@ init_hooks_settings_merger();
|
|
|
63267
63560
|
|
|
63268
63561
|
// src/commands/portable/settings-write-with-confirm.ts
|
|
63269
63562
|
init_safe_prompts();
|
|
63270
|
-
import { existsSync as
|
|
63563
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync7, readFileSync as readFileSync18, renameSync as renameSync3, rmSync as rmSync4, writeFileSync as writeFileSync10 } from "node:fs";
|
|
63271
63564
|
import { dirname as dirname29 } from "node:path";
|
|
63272
63565
|
|
|
63273
63566
|
// node_modules/diff/libesm/diff/base.js
|
|
@@ -64440,7 +64733,7 @@ var EMPTY_RESULT = (status2) => ({
|
|
|
64440
64733
|
backupPath: null
|
|
64441
64734
|
});
|
|
64442
64735
|
function readCurrent(path10) {
|
|
64443
|
-
if (!
|
|
64736
|
+
if (!existsSync50(path10))
|
|
64444
64737
|
return { kind: "missing" };
|
|
64445
64738
|
let raw = "";
|
|
64446
64739
|
try {
|
|
@@ -64557,7 +64850,7 @@ init_dist2();
|
|
|
64557
64850
|
// src/commands/hooks/lib/agent-target-picker.ts
|
|
64558
64851
|
init_safe_prompts();
|
|
64559
64852
|
init_dist2();
|
|
64560
|
-
import { existsSync as
|
|
64853
|
+
import { existsSync as existsSync51 } from "node:fs";
|
|
64561
64854
|
|
|
64562
64855
|
// src/commands/hooks/lib/settings-path-resolver.ts
|
|
64563
64856
|
import { lstatSync as lstatSync3, realpathSync as realpathSync3 } from "node:fs";
|
|
@@ -64596,7 +64889,7 @@ function probe(global3) {
|
|
|
64596
64889
|
return {
|
|
64597
64890
|
agent,
|
|
64598
64891
|
path: location2.realPath,
|
|
64599
|
-
exists:
|
|
64892
|
+
exists: existsSync51(location2.realPath)
|
|
64600
64893
|
};
|
|
64601
64894
|
});
|
|
64602
64895
|
}
|
|
@@ -64683,6 +64976,8 @@ function buildHookExecCommand(handler, event, agent, bin = DEFAULT_HOOK_BIN, fla
|
|
|
64683
64976
|
function planEntry(handler, event, agent, bin, flags) {
|
|
64684
64977
|
if (agent === "codex" && !codexSupportsEvent(event))
|
|
64685
64978
|
return null;
|
|
64979
|
+
if (agent !== "codex" && handler.codexOnlyEvents?.includes(event))
|
|
64980
|
+
return null;
|
|
64686
64981
|
const command = buildHookExecCommand(handler, event, agent, bin, flags);
|
|
64687
64982
|
if (!command)
|
|
64688
64983
|
return null;
|
|
@@ -64717,7 +65012,7 @@ function buildHookSection(agent, bin, flags = {}, handlers3 = HOOK_HANDLERS) {
|
|
|
64717
65012
|
|
|
64718
65013
|
// src/commands/hooks/uninstall-handler.ts
|
|
64719
65014
|
init_logger();
|
|
64720
|
-
import { existsSync as
|
|
65015
|
+
import { existsSync as existsSync52, mkdirSync as mkdirSync8, readFileSync as readFileSync19, renameSync as renameSync4, rmSync as rmSync5, writeFileSync as writeFileSync11 } from "node:fs";
|
|
64721
65016
|
import { dirname as dirname30 } from "node:path";
|
|
64722
65017
|
var AGENT_DISPLAY2 = {
|
|
64723
65018
|
claude: "Claude Code",
|
|
@@ -64777,7 +65072,7 @@ async function uninstallForAgent(agent, options2) {
|
|
|
64777
65072
|
removed: 0,
|
|
64778
65073
|
dryRun: Boolean(options2.dryRun)
|
|
64779
65074
|
};
|
|
64780
|
-
if (!
|
|
65075
|
+
if (!existsSync52(location2.realPath)) {
|
|
64781
65076
|
return result;
|
|
64782
65077
|
}
|
|
64783
65078
|
let parsed;
|
|
@@ -64996,7 +65291,7 @@ async function installHook(options2) {
|
|
|
64996
65291
|
// src/commands/hooks/status.ts
|
|
64997
65292
|
init_takumi_config_manager();
|
|
64998
65293
|
init_logger();
|
|
64999
|
-
import { existsSync as
|
|
65294
|
+
import { existsSync as existsSync53, readFileSync as readFileSync20 } from "node:fs";
|
|
65000
65295
|
var AGENT_DISPLAY4 = { claude: "Claude Code", codex: "Codex" };
|
|
65001
65296
|
var NEW_SHAPE = /\bhook-exec\b.*--hook\s+(guard|session|convention|extension|metrics|perf)\.(\S+).*-a\s+(claude|codex)(?![\w-])/;
|
|
65002
65297
|
var LEGACY_SHAPE = /\bhooks\s+(?:session-start|user-prompt-submit|pre-tool-use|post-tool-use|stop|session-end)\s+-a\s+(claude|codex)(?![\w-])/;
|
|
@@ -65026,7 +65321,7 @@ async function statusForAgent(agent, options2, cwd2 = process.cwd()) {
|
|
|
65026
65321
|
const result = {
|
|
65027
65322
|
agent,
|
|
65028
65323
|
settingsPath: location2.realPath,
|
|
65029
|
-
exists:
|
|
65324
|
+
exists: existsSync53(location2.realPath),
|
|
65030
65325
|
shape: "none",
|
|
65031
65326
|
byCategory: {},
|
|
65032
65327
|
newEntryCount: 0,
|
|
@@ -65064,7 +65359,7 @@ function report(result) {
|
|
|
65064
65359
|
logger.info(`[hooks] ${label}: no settings file at ${result.settingsPath}`);
|
|
65065
65360
|
return;
|
|
65066
65361
|
}
|
|
65067
|
-
const categories = Object.entries(result.byCategory).sort(([a3], [b3]) => a3.localeCompare(b3)).map(([cat,
|
|
65362
|
+
const categories = Object.entries(result.byCategory).sort(([a3], [b3]) => a3.localeCompare(b3)).map(([cat, n2]) => `${cat}=${n2}`).join(", ");
|
|
65068
65363
|
const parts = [`shape=${result.shape}`, `${result.newEntryCount} hook-exec entries`];
|
|
65069
65364
|
if (result.legacyEntryCount > 0)
|
|
65070
65365
|
parts.push(`${result.legacyEntryCount} legacy entries`);
|
|
@@ -66398,7 +66693,7 @@ async function dispatchInstallers(ctx, targetAgents2, lifecycle) {
|
|
|
66398
66693
|
init_logger();
|
|
66399
66694
|
// src/domains/installation/download-extractor.ts
|
|
66400
66695
|
init_auth_client();
|
|
66401
|
-
import * as
|
|
66696
|
+
import * as fs30 from "node:fs";
|
|
66402
66697
|
import * as path10 from "node:path";
|
|
66403
66698
|
|
|
66404
66699
|
// src/domains/github/auth-prompt.ts
|
|
@@ -67229,18 +67524,18 @@ var D = class extends Ti {
|
|
|
67229
67524
|
if (t === "close") {
|
|
67230
67525
|
if (this[Ne] = true, !this[rt] && !this[w3])
|
|
67231
67526
|
return false;
|
|
67232
|
-
let
|
|
67233
|
-
return this.removeAllListeners("close"),
|
|
67527
|
+
let n2 = super.emit("close");
|
|
67528
|
+
return this.removeAllListeners("close"), n2;
|
|
67234
67529
|
} else if (t === "error") {
|
|
67235
67530
|
this[jt] = i, super.emit(Ri, i);
|
|
67236
|
-
let
|
|
67237
|
-
return this[j2](),
|
|
67531
|
+
let n2 = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : false;
|
|
67532
|
+
return this[j2](), n2;
|
|
67238
67533
|
} else if (t === "resume") {
|
|
67239
|
-
let
|
|
67240
|
-
return this[j2](),
|
|
67534
|
+
let n2 = super.emit("resume");
|
|
67535
|
+
return this[j2](), n2;
|
|
67241
67536
|
} else if (t === "finish" || t === "prefinish") {
|
|
67242
|
-
let
|
|
67243
|
-
return this.removeAllListeners(t),
|
|
67537
|
+
let n2 = super.emit(t);
|
|
67538
|
+
return this.removeAllListeners(t), n2;
|
|
67244
67539
|
}
|
|
67245
67540
|
let r2 = super.emit(t, ...e2);
|
|
67246
67541
|
return this[j2](), r2;
|
|
@@ -67298,15 +67593,15 @@ var D = class extends Ti {
|
|
|
67298
67593
|
return Promise.resolve({ done: false, value: r2 });
|
|
67299
67594
|
if (this[q3])
|
|
67300
67595
|
return e2();
|
|
67301
|
-
let
|
|
67596
|
+
let n2, o2, h2 = (d3) => {
|
|
67302
67597
|
this.off("data", a3), this.off("end", l2), this.off(w3, c2), e2(), o2(d3);
|
|
67303
67598
|
}, a3 = (d3) => {
|
|
67304
|
-
this.off("error", h2), this.off("end", l2), this.off(w3, c2), this.pause(),
|
|
67599
|
+
this.off("error", h2), this.off("end", l2), this.off(w3, c2), this.pause(), n2({ value: d3, done: !!this[q3] });
|
|
67305
67600
|
}, l2 = () => {
|
|
67306
|
-
this.off("error", h2), this.off("data", a3), this.off(w3, c2), e2(),
|
|
67601
|
+
this.off("error", h2), this.off("data", a3), this.off(w3, c2), e2(), n2({ done: true, value: undefined });
|
|
67307
67602
|
}, c2 = () => h2(new Error("stream destroyed"));
|
|
67308
67603
|
return new Promise((d3, S3) => {
|
|
67309
|
-
o2 = S3,
|
|
67604
|
+
o2 = S3, n2 = d3, this.once(w3, c2), this.once("error", h2), this.once("end", l2), this.once("data", a3);
|
|
67310
67605
|
});
|
|
67311
67606
|
}, throw: e2, return: e2, [Symbol.asyncIterator]() {
|
|
67312
67607
|
return this;
|
|
@@ -67597,9 +67892,9 @@ var re2 = (s = {}) => {
|
|
|
67597
67892
|
}
|
|
67598
67893
|
return t.chmod === undefined && t.noChmod === false && (t.chmod = true), delete t.noChmod, t;
|
|
67599
67894
|
};
|
|
67600
|
-
var K3 = (s, t, e2, i, r2) => Object.assign((
|
|
67601
|
-
Array.isArray(
|
|
67602
|
-
let a3 = re2(
|
|
67895
|
+
var K3 = (s, t, e2, i, r2) => Object.assign((n2 = [], o2, h2) => {
|
|
67896
|
+
Array.isArray(n2) && (o2 = n2, n2 = {}), typeof o2 == "function" && (h2 = o2, o2 = undefined), o2 = o2 ? Array.from(o2) : [];
|
|
67897
|
+
let a3 = re2(n2);
|
|
67603
67898
|
if (r2?.(a3, o2), As(a3)) {
|
|
67604
67899
|
if (typeof h2 == "function")
|
|
67605
67900
|
throw new TypeError("callback not supported for sync tar functions");
|
|
@@ -67692,7 +67987,7 @@ var ne2 = class extends D {
|
|
|
67692
67987
|
if (typeof e2 == "function" && (i = e2, e2 = "utf8"), typeof t == "string" && (t = gt.from(t, e2)), this.#t)
|
|
67693
67988
|
return;
|
|
67694
67989
|
Mi(this.#e, "zlib binding closed");
|
|
67695
|
-
let r2 = this.#e._handle,
|
|
67990
|
+
let r2 = this.#e._handle, n2 = r2.close;
|
|
67696
67991
|
r2.close = () => {};
|
|
67697
67992
|
let o2 = this.#e.close;
|
|
67698
67993
|
this.#e.close = () => {}, ki(true);
|
|
@@ -67703,7 +67998,7 @@ var ne2 = class extends D {
|
|
|
67703
67998
|
} catch (l2) {
|
|
67704
67999
|
ki(false), this.#o(new Gt(l2, this.write));
|
|
67705
68000
|
} finally {
|
|
67706
|
-
this.#e && (this.#e._handle = r2, r2.close =
|
|
68001
|
+
this.#e && (this.#e._handle = r2, r2.close = n2, this.#e.close = o2, this.#e.removeAllListeners("error"));
|
|
67707
68002
|
}
|
|
67708
68003
|
this.#e && this.#e.on("error", (l2) => this.#o(new Gt(l2, this.write)));
|
|
67709
68004
|
let a3;
|
|
@@ -67733,8 +68028,8 @@ var Be = class extends ne2 {
|
|
|
67733
68028
|
if (this.#t !== t || this.#i !== e2) {
|
|
67734
68029
|
this.flush(M3.Z_SYNC_FLUSH), Mi(this.handle, "zlib binding closed");
|
|
67735
68030
|
let i = this.handle.flush;
|
|
67736
|
-
this.handle.flush = (r2,
|
|
67737
|
-
typeof r2 == "function" && (
|
|
68031
|
+
this.handle.flush = (r2, n2) => {
|
|
68032
|
+
typeof r2 == "function" && (n2 = r2, r2 = this.flushFlag), this.flush(r2), n2?.();
|
|
67738
68033
|
};
|
|
67739
68034
|
try {
|
|
67740
68035
|
this.handle.params(t, e2);
|
|
@@ -67821,8 +68116,8 @@ var Bs = (s) => {
|
|
|
67821
68116
|
};
|
|
67822
68117
|
var rn = (s) => {
|
|
67823
68118
|
for (var t = s.length, e2 = 0, i = false, r2 = t - 1;r2 > -1; r2--) {
|
|
67824
|
-
var
|
|
67825
|
-
i ? o2 = Ps(
|
|
68119
|
+
var n2 = Number(s[r2]), o2;
|
|
68120
|
+
i ? o2 = Ps(n2) : n2 === 0 ? o2 = n2 : (i = true, o2 = zs(n2)), o2 !== 0 && (e2 -= o2 * Math.pow(256, t - r2 - 1));
|
|
67826
68121
|
}
|
|
67827
68122
|
return e2;
|
|
67828
68123
|
};
|
|
@@ -67870,8 +68165,8 @@ var F = class {
|
|
|
67870
68165
|
if (e2 || (e2 = 0), !t || !(t.length >= e2 + 512))
|
|
67871
68166
|
throw new Error("need 512 bytes for header");
|
|
67872
68167
|
this.path = i?.path ?? Tt(t, e2, 100), this.mode = i?.mode ?? r2?.mode ?? at(t, e2 + 100, 8), this.uid = i?.uid ?? r2?.uid ?? at(t, e2 + 108, 8), this.gid = i?.gid ?? r2?.gid ?? at(t, e2 + 116, 8), this.size = i?.size ?? r2?.size ?? at(t, e2 + 124, 12), this.mtime = i?.mtime ?? r2?.mtime ?? Pi(t, e2 + 136, 12), this.cksum = at(t, e2 + 148, 12), r2 && this.#i(r2, true), i && this.#i(i);
|
|
67873
|
-
let
|
|
67874
|
-
if (oe2(
|
|
68168
|
+
let n2 = Tt(t, e2 + 156, 1);
|
|
68169
|
+
if (oe2(n2) && (this.#t = n2 || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = Tt(t, e2 + 157, 100), t.subarray(e2 + 257, e2 + 265).toString() === "ustar\x0000")
|
|
67875
68170
|
if (this.uname = i?.uname ?? r2?.uname ?? Tt(t, e2 + 265, 32), this.gname = i?.gname ?? r2?.gname ?? Tt(t, e2 + 297, 32), this.devmaj = i?.devmaj ?? r2?.devmaj ?? at(t, e2 + 329, 8) ?? 0, this.devmin = i?.devmin ?? r2?.devmin ?? at(t, e2 + 337, 8) ?? 0, t[e2 + 475] !== 0) {
|
|
67876
68171
|
let h2 = Tt(t, e2 + 345, 155);
|
|
67877
68172
|
this.path = h2 + "/" + this.path;
|
|
@@ -67892,8 +68187,8 @@ var F = class {
|
|
|
67892
68187
|
encode(t, e2 = 0) {
|
|
67893
68188
|
if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e2 + 512))
|
|
67894
68189
|
throw new Error("need 512 bytes for header");
|
|
67895
|
-
let i = this.ctime || this.atime ? 130 : 155, r2 = an(this.path || "", i),
|
|
67896
|
-
this.needPax = !!r2[2], this.needPax = xt(t, e2, 100,
|
|
68190
|
+
let i = this.ctime || this.atime ? 130 : 155, r2 = an(this.path || "", i), n2 = r2[0], o2 = r2[1];
|
|
68191
|
+
this.needPax = !!r2[2], this.needPax = xt(t, e2, 100, n2) || this.needPax, this.needPax = lt(t, e2 + 100, 8, this.mode) || this.needPax, this.needPax = lt(t, e2 + 108, 8, this.uid) || this.needPax, this.needPax = lt(t, e2 + 116, 8, this.gid) || this.needPax, this.needPax = lt(t, e2 + 124, 12, this.size) || this.needPax, this.needPax = zi(t, e2 + 136, 12, this.mtime) || this.needPax, t[e2 + 156] = Number(this.#t.codePointAt(0)), this.needPax = xt(t, e2 + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e2 + 257, 8), this.needPax = xt(t, e2 + 265, 32, this.uname) || this.needPax, this.needPax = xt(t, e2 + 297, 32, this.gname) || this.needPax, this.needPax = lt(t, e2 + 329, 8, this.devmaj) || this.needPax, this.needPax = lt(t, e2 + 337, 8, this.devmin) || this.needPax, this.needPax = xt(t, e2 + 345, i, o2) || this.needPax, t[e2 + 475] !== 0 ? this.needPax = xt(t, e2 + 345, 155, o2) || this.needPax : (this.needPax = xt(t, e2 + 345, 130, o2) || this.needPax, this.needPax = zi(t, e2 + 476, 12, this.atime) || this.needPax, this.needPax = zi(t, e2 + 488, 12, this.ctime) || this.needPax);
|
|
67897
68192
|
let h2 = 256;
|
|
67898
68193
|
for (let a3 = e2;a3 < e2 + 148; a3++)
|
|
67899
68194
|
h2 += t[a3];
|
|
@@ -67918,17 +68213,17 @@ var F = class {
|
|
|
67918
68213
|
}
|
|
67919
68214
|
};
|
|
67920
68215
|
var an = (s, t) => {
|
|
67921
|
-
let i = s, r2 = "",
|
|
68216
|
+
let i = s, r2 = "", n2, o2 = Zt.parse(s).root || ".";
|
|
67922
68217
|
if (Buffer.byteLength(i) < 100)
|
|
67923
|
-
|
|
68218
|
+
n2 = [i, r2, false];
|
|
67924
68219
|
else {
|
|
67925
68220
|
r2 = Zt.dirname(i), i = Zt.basename(i);
|
|
67926
68221
|
do
|
|
67927
|
-
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r2) <= t ?
|
|
67928
|
-
while (r2 !== o2 &&
|
|
67929
|
-
|
|
68222
|
+
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r2) <= t ? n2 = [i, r2, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r2) <= t ? n2 = [i.slice(0, 99), r2, true] : (i = Zt.join(Zt.basename(r2), i), r2 = Zt.dirname(r2));
|
|
68223
|
+
while (r2 !== o2 && n2 === undefined);
|
|
68224
|
+
n2 || (n2 = [s.slice(0, 99), "", true]);
|
|
67930
68225
|
}
|
|
67931
|
-
return
|
|
68226
|
+
return n2;
|
|
67932
68227
|
};
|
|
67933
68228
|
var Tt = (s, t, e2) => s.subarray(t, t + e2).toString("utf8").replace(/\0.*/, "");
|
|
67934
68229
|
var Pi = (s, t, e2) => ln(at(s, t, e2));
|
|
@@ -67970,11 +68265,11 @@ var ct = class s {
|
|
|
67970
68265
|
if (t === "")
|
|
67971
68266
|
return Buffer.allocUnsafe(0);
|
|
67972
68267
|
let e2 = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e2 / 512), r2 = Buffer.allocUnsafe(i);
|
|
67973
|
-
for (let
|
|
67974
|
-
r2[
|
|
68268
|
+
for (let n2 = 0;n2 < 512; n2++)
|
|
68269
|
+
r2[n2] = 0;
|
|
67975
68270
|
new F({ path: ("PaxHeader/" + wn(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e2, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r2), r2.write(t, 512, e2, "utf8");
|
|
67976
|
-
for (let
|
|
67977
|
-
r2[
|
|
68271
|
+
for (let n2 = e2 + 512;n2 < r2.length; n2++)
|
|
68272
|
+
r2[n2] = 0;
|
|
67978
68273
|
return r2;
|
|
67979
68274
|
}
|
|
67980
68275
|
encodeBody() {
|
|
@@ -67984,8 +68279,8 @@ var ct = class s {
|
|
|
67984
68279
|
if (this[t] === undefined)
|
|
67985
68280
|
return "";
|
|
67986
68281
|
let e2 = this[t], i = e2 instanceof Date ? e2.getTime() / 1000 : e2, r2 = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
|
|
67987
|
-
`,
|
|
67988
|
-
return
|
|
68282
|
+
`, n2 = Buffer.byteLength(r2), o2 = Math.floor(Math.log(n2) / Math.log(10)) + 1;
|
|
68283
|
+
return n2 + o2 >= Math.pow(10, o2) && (o2 += 1), o2 + n2 + r2;
|
|
67989
68284
|
}
|
|
67990
68285
|
static parse(t, e2, i = false) {
|
|
67991
68286
|
return new s(Sn(yn(t), e2), i);
|
|
@@ -68002,8 +68297,8 @@ var Rn = (s2, t) => {
|
|
|
68002
68297
|
let i = t.split("="), r2 = i.shift();
|
|
68003
68298
|
if (!r2)
|
|
68004
68299
|
return s2;
|
|
68005
|
-
let
|
|
68006
|
-
return s2[
|
|
68300
|
+
let n2 = r2.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o2 = i.join("=");
|
|
68301
|
+
return s2[n2] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n2) ? new Date(Number(o2) * 1000) : /^[0-9]+$/.test(o2) ? +o2 : o2, s2;
|
|
68007
68302
|
};
|
|
68008
68303
|
var bn = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
68009
68304
|
var f3 = bn !== "win32" ? (s2) => s2 : (s2) => s2 && s2.replaceAll(/\\/g, "/");
|
|
@@ -68172,16 +68467,16 @@ var st = class extends _n {
|
|
|
68172
68467
|
else if (!/^(Symbolic)?Link$/.test(r2) && !/^(Global)?ExtendedHeader$/.test(r2) && i.linkpath)
|
|
68173
68468
|
this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
|
|
68174
68469
|
else {
|
|
68175
|
-
let
|
|
68470
|
+
let n2 = this[Nt] = new Yt(i, this[V2], this[ae2]);
|
|
68176
68471
|
if (!this[Dt])
|
|
68177
|
-
if (
|
|
68472
|
+
if (n2.remain) {
|
|
68178
68473
|
let o2 = () => {
|
|
68179
|
-
|
|
68474
|
+
n2.invalid || (this[Dt] = true);
|
|
68180
68475
|
};
|
|
68181
|
-
|
|
68476
|
+
n2.on("end", o2);
|
|
68182
68477
|
} else
|
|
68183
68478
|
this[Dt] = true;
|
|
68184
|
-
|
|
68479
|
+
n2.meta ? n2.size > this.maxMetaEntrySize ? (n2.ignore = true, this[At]("ignoredEntry", n2), this[B2] = "ignore", n2.resume()) : n2.size > 0 && (this[ft] = "", n2.on("data", (o2) => this[ft] += o2), this[B2] = "meta") : (this[V2] = undefined, n2.ignore = n2.ignore || !this.filter(n2.path, n2), n2.ignore ? (this[At]("ignoredEntry", n2), this[B2] = n2.remain ? "ignore" : "header", n2.resume()) : (n2.remain ? this[B2] = "body" : (this[B2] = "header", n2.end()), this[et] ? this[it].push(n2) : (this[it].push(n2), this[Ui]())));
|
|
68185
68480
|
}
|
|
68186
68481
|
}
|
|
68187
68482
|
}
|
|
@@ -68212,8 +68507,8 @@ var st = class extends _n {
|
|
|
68212
68507
|
let i = this[Nt];
|
|
68213
68508
|
if (!i)
|
|
68214
68509
|
throw new Error("attempt to consume body without entry??");
|
|
68215
|
-
let r2 = i.blockRemain ?? 0,
|
|
68216
|
-
return i.write(
|
|
68510
|
+
let r2 = i.blockRemain ?? 0, n2 = r2 >= t.length && e2 === 0 ? t : t.subarray(e2, e2 + r2);
|
|
68511
|
+
return i.write(n2), i.blockRemain || (this[B2] = "header", this[Nt] = undefined, i.end()), n2.length;
|
|
68217
68512
|
}
|
|
68218
68513
|
[Ws](t, e2) {
|
|
68219
68514
|
let i = this[Nt], r2 = this[Wi](t, e2);
|
|
@@ -68289,8 +68584,8 @@ var st = class extends _n {
|
|
|
68289
68584
|
}
|
|
68290
68585
|
}
|
|
68291
68586
|
this[Kt] = true, this[y3] ? this[y3].write(t) : this[Ve](t), this[Kt] = false;
|
|
68292
|
-
let
|
|
68293
|
-
return !
|
|
68587
|
+
let n2 = this[it].length > 0 ? false : this[et] ? this[et].flowing : true;
|
|
68588
|
+
return !n2 && this[it].length === 0 && this[et]?.once("drain", () => this.emit("drain")), i?.(), n2;
|
|
68294
68589
|
}
|
|
68295
68590
|
[Gi](t) {
|
|
68296
68591
|
t && !this[ut] && (this[p] = this[p] ? Buffer.concat([this[p], t]) : t);
|
|
@@ -68363,30 +68658,30 @@ var Nn = (s2) => {
|
|
|
68363
68658
|
} : (e2) => e2.resume();
|
|
68364
68659
|
};
|
|
68365
68660
|
var Ki = (s2, t) => {
|
|
68366
|
-
let e2 = new Map(t.map((
|
|
68367
|
-
let h2 = o2 || Ln(
|
|
68368
|
-
if (
|
|
68661
|
+
let e2 = new Map(t.map((n2) => [mt(n2), true])), i = s2.filter, r2 = (n2, o2 = "") => {
|
|
68662
|
+
let h2 = o2 || Ln(n2).root || ".", a3;
|
|
68663
|
+
if (n2 === h2)
|
|
68369
68664
|
a3 = false;
|
|
68370
68665
|
else {
|
|
68371
|
-
let l2 = e2.get(
|
|
68372
|
-
a3 = l2 !== undefined ? l2 : r2(xn(
|
|
68666
|
+
let l2 = e2.get(n2);
|
|
68667
|
+
a3 = l2 !== undefined ? l2 : r2(xn(n2), h2);
|
|
68373
68668
|
}
|
|
68374
|
-
return e2.set(
|
|
68669
|
+
return e2.set(n2, a3), a3;
|
|
68375
68670
|
};
|
|
68376
|
-
s2.filter = i ? (
|
|
68671
|
+
s2.filter = i ? (n2, o2) => i(n2, o2) && r2(mt(n2)) : (n2) => r2(mt(n2));
|
|
68377
68672
|
};
|
|
68378
68673
|
var An = (s2) => {
|
|
68379
68674
|
let t = new st(s2), e2 = s2.file, i;
|
|
68380
68675
|
try {
|
|
68381
68676
|
i = Vt.openSync(e2, "r");
|
|
68382
|
-
let r2 = Vt.fstatSync(i),
|
|
68383
|
-
if (r2.size <
|
|
68677
|
+
let r2 = Vt.fstatSync(i), n2 = s2.maxReadSize || 16 * 1024 * 1024;
|
|
68678
|
+
if (r2.size < n2) {
|
|
68384
68679
|
let o2 = Buffer.allocUnsafe(r2.size), h2 = Vt.readSync(i, o2, 0, r2.size, 0);
|
|
68385
68680
|
t.end(h2 === o2.byteLength ? o2 : o2.subarray(0, h2));
|
|
68386
68681
|
} else {
|
|
68387
|
-
let o2 = 0, h2 = Buffer.allocUnsafe(
|
|
68682
|
+
let o2 = 0, h2 = Buffer.allocUnsafe(n2);
|
|
68388
68683
|
for (;o2 < r2.size; ) {
|
|
68389
|
-
let a3 = Vt.readSync(i, h2, 0,
|
|
68684
|
+
let a3 = Vt.readSync(i, h2, 0, n2, o2);
|
|
68390
68685
|
if (a3 === 0)
|
|
68391
68686
|
break;
|
|
68392
68687
|
o2 += a3, t.write(h2.subarray(0, a3));
|
|
@@ -68492,8 +68787,8 @@ var de2 = class extends D {
|
|
|
68492
68787
|
o2 && typeof h2 == "string" && (this.path = h2, r2 = o2);
|
|
68493
68788
|
}
|
|
68494
68789
|
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Ks(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f3(i.absolute || $s.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r2 && this.warn("TAR_ENTRY_INFO", `stripping ${r2} from absolute path`, { entry: this, path: r2 + this.path });
|
|
68495
|
-
let
|
|
68496
|
-
|
|
68790
|
+
let n2 = this.statCache.get(this.absolute);
|
|
68791
|
+
n2 ? this[ei](n2) : this[Qi]();
|
|
68497
68792
|
}
|
|
68498
68793
|
warn(t, e2, i = {}) {
|
|
68499
68794
|
return Lt(this, t, e2, i);
|
|
@@ -68588,10 +68883,10 @@ var de2 = class extends D {
|
|
|
68588
68883
|
this.buf = Buffer.allocUnsafe(e2), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ti]();
|
|
68589
68884
|
}
|
|
68590
68885
|
[ti]() {
|
|
68591
|
-
let { fd: t, buf: e2, offset: i, length: r2, pos:
|
|
68886
|
+
let { fd: t, buf: e2, offset: i, length: r2, pos: n2 } = this;
|
|
68592
68887
|
if (t === undefined || e2 === undefined)
|
|
68593
68888
|
throw new Error("cannot read file without first opening");
|
|
68594
|
-
$2.read(t, e2, i, r2,
|
|
68889
|
+
$2.read(t, e2, i, r2, n2, (o2, h2) => {
|
|
68595
68890
|
if (o2)
|
|
68596
68891
|
return this[pt](() => this.emit("error", o2));
|
|
68597
68892
|
this[Ji](h2);
|
|
@@ -68649,10 +68944,10 @@ var si = class extends de2 {
|
|
|
68649
68944
|
[ti]() {
|
|
68650
68945
|
let t = true;
|
|
68651
68946
|
try {
|
|
68652
|
-
let { fd: e2, buf: i, offset: r2, length:
|
|
68947
|
+
let { fd: e2, buf: i, offset: r2, length: n2, pos: o2 } = this;
|
|
68653
68948
|
if (e2 === undefined || i === undefined)
|
|
68654
68949
|
throw new Error("fd and buf must be set in READ method");
|
|
68655
|
-
let h2 = $2.readSync(e2, i, r2,
|
|
68950
|
+
let h2 = $2.readSync(e2, i, r2, n2, o2);
|
|
68656
68951
|
this[Ji](h2), t = false;
|
|
68657
68952
|
} finally {
|
|
68658
68953
|
if (t)
|
|
@@ -68706,12 +69001,12 @@ var ri = class extends D {
|
|
|
68706
69001
|
if (r2 === "Unsupported")
|
|
68707
69002
|
throw new Error("writing entry that should be ignored");
|
|
68708
69003
|
this.type = r2, this.type === "Directory" && this.portable && (this.noMtime = true), this.prefix = i.prefix, this.path = f3(t.path), this.mode = t.mode !== undefined ? this[ii](t.mode) : undefined, this.uid = this.portable ? undefined : t.uid, this.gid = this.portable ? undefined : t.gid, this.uname = this.portable ? undefined : t.uname, this.gname = this.portable ? undefined : t.gname, this.size = t.size, this.mtime = this.noMtime ? undefined : i.mtime || t.mtime, this.atime = this.portable ? undefined : t.atime, this.ctime = this.portable ? undefined : t.ctime, this.linkpath = t.linkpath !== undefined ? f3(t.linkpath) : undefined, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
|
|
68709
|
-
let
|
|
69004
|
+
let n2 = false;
|
|
68710
69005
|
if (!this.preservePaths) {
|
|
68711
69006
|
let [h2, a3] = ce2(this.path);
|
|
68712
|
-
h2 && typeof a3 == "string" && (this.path = a3,
|
|
69007
|
+
h2 && typeof a3 == "string" && (this.path = a3, n2 = h2);
|
|
68713
69008
|
}
|
|
68714
|
-
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 }),
|
|
69009
|
+
this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new F({ path: this[X3](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X3](this.linkpath) : this.linkpath, mode: this.mode, uid: this.portable ? undefined : this.uid, gid: this.portable ? undefined : this.gid, size: this.size, mtime: this.noMtime ? undefined : this.mtime, type: this.type, uname: this.portable ? undefined : this.uname, atime: this.portable ? undefined : this.atime, ctime: this.portable ? undefined : this.ctime }), n2 && this.warn("TAR_ENTRY_INFO", `stripping ${n2} from absolute path`, { entry: this, path: n2 + this.path }), this.header.encode() && !this.noPax && super.write(new ct({ atime: this.portable ? undefined : this.atime, ctime: this.portable ? undefined : this.ctime, gid: this.portable ? undefined : this.gid, mtime: this.noMtime ? undefined : this.mtime, path: this[X3](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X3](this.linkpath) : this.linkpath, size: this.size, uid: this.portable ? undefined : this.uid, uname: this.portable ? undefined : this.uname, dev: this.portable ? undefined : this.readEntry.dev, ino: this.portable ? undefined : this.readEntry.ino, nlink: this.portable ? undefined : this.readEntry.nlink }).encode());
|
|
68715
69010
|
let o2 = this.header?.block;
|
|
68716
69011
|
if (!o2)
|
|
68717
69012
|
throw new Error("failed to encode header");
|
|
@@ -68838,8 +69133,8 @@ var ni = class s2 {
|
|
|
68838
69133
|
r2 = this.head.next, i = this.head.value;
|
|
68839
69134
|
else
|
|
68840
69135
|
throw new TypeError("Reduce of empty list with no initial value");
|
|
68841
|
-
for (var
|
|
68842
|
-
i = t(i, r2.value,
|
|
69136
|
+
for (var n2 = 0;r2; n2++)
|
|
69137
|
+
i = t(i, r2.value, n2), r2 = r2.next;
|
|
68843
69138
|
return i;
|
|
68844
69139
|
}
|
|
68845
69140
|
reduceReverse(t, e2) {
|
|
@@ -68850,8 +69145,8 @@ var ni = class s2 {
|
|
|
68850
69145
|
r2 = this.tail.prev, i = this.tail.value;
|
|
68851
69146
|
else
|
|
68852
69147
|
throw new TypeError("Reduce of empty list with no initial value");
|
|
68853
|
-
for (let
|
|
68854
|
-
i = t(i, r2.value,
|
|
69148
|
+
for (let n2 = this.length - 1;r2; n2--)
|
|
69149
|
+
i = t(i, r2.value, n2), r2 = r2.prev;
|
|
68855
69150
|
return i;
|
|
68856
69151
|
}
|
|
68857
69152
|
toArray() {
|
|
@@ -68872,10 +69167,10 @@ var ni = class s2 {
|
|
|
68872
69167
|
if (e2 < t || e2 < 0)
|
|
68873
69168
|
return i;
|
|
68874
69169
|
t < 0 && (t = 0), e2 > this.length && (e2 = this.length);
|
|
68875
|
-
let r2 = this.head,
|
|
68876
|
-
for (
|
|
69170
|
+
let r2 = this.head, n2 = 0;
|
|
69171
|
+
for (n2 = 0;r2 && n2 < t; n2++)
|
|
68877
69172
|
r2 = r2.next;
|
|
68878
|
-
for (;r2 &&
|
|
69173
|
+
for (;r2 && n2 < e2; n2++, r2 = r2.next)
|
|
68879
69174
|
i.push(r2.value);
|
|
68880
69175
|
return i;
|
|
68881
69176
|
}
|
|
@@ -68885,11 +69180,11 @@ var ni = class s2 {
|
|
|
68885
69180
|
if (e2 < t || e2 < 0)
|
|
68886
69181
|
return i;
|
|
68887
69182
|
t < 0 && (t = 0), e2 > this.length && (e2 = this.length);
|
|
68888
|
-
let r2 = this.length,
|
|
68889
|
-
for (;
|
|
68890
|
-
|
|
68891
|
-
for (;
|
|
68892
|
-
i.push(
|
|
69183
|
+
let r2 = this.length, n2 = this.tail;
|
|
69184
|
+
for (;n2 && r2 > e2; r2--)
|
|
69185
|
+
n2 = n2.prev;
|
|
69186
|
+
for (;n2 && r2 > t; r2--, n2 = n2.prev)
|
|
69187
|
+
i.push(n2.value);
|
|
68893
69188
|
return i;
|
|
68894
69189
|
}
|
|
68895
69190
|
splice(t, e2 = 0, ...i) {
|
|
@@ -68897,13 +69192,13 @@ var ni = class s2 {
|
|
|
68897
69192
|
let r2 = this.head;
|
|
68898
69193
|
for (let o2 = 0;r2 && o2 < t; o2++)
|
|
68899
69194
|
r2 = r2.next;
|
|
68900
|
-
let
|
|
69195
|
+
let n2 = [];
|
|
68901
69196
|
for (let o2 = 0;r2 && o2 < e2; o2++)
|
|
68902
|
-
|
|
69197
|
+
n2.push(r2.value), r2 = this.removeNode(r2);
|
|
68903
69198
|
r2 ? r2 !== this.tail && (r2 = r2.prev) : r2 = this.tail;
|
|
68904
69199
|
for (let o2 of i)
|
|
68905
69200
|
r2 = Bn(this, r2, o2);
|
|
68906
|
-
return
|
|
69201
|
+
return n2;
|
|
68907
69202
|
}
|
|
68908
69203
|
reverse() {
|
|
68909
69204
|
let t = this.head, e2 = this.tail;
|
|
@@ -68915,8 +69210,8 @@ var ni = class s2 {
|
|
|
68915
69210
|
}
|
|
68916
69211
|
};
|
|
68917
69212
|
function Bn(s3, t, e2) {
|
|
68918
|
-
let i = t, r2 = t ? t.next : s3.head,
|
|
68919
|
-
return
|
|
69213
|
+
let i = t, r2 = t ? t.next : s3.head, n2 = new ue2(e2, i, r2, s3);
|
|
69214
|
+
return n2.next === undefined && (s3.tail = n2), n2.prev === undefined && (s3.head = n2), s3.length++, n2;
|
|
68920
69215
|
}
|
|
68921
69216
|
function Pn(s3, t) {
|
|
68922
69217
|
s3.tail = new ue2(t, s3.tail, undefined, s3), s3.head || (s3.head = s3.tail), s3.length++;
|
|
@@ -69111,7 +69406,7 @@ var Et = class extends D {
|
|
|
69111
69406
|
}
|
|
69112
69407
|
[li](t) {
|
|
69113
69408
|
t.piped = true, t.readdir && t.readdir.forEach((r2) => {
|
|
69114
|
-
let
|
|
69409
|
+
let n2 = t.path, o2 = n2 === "./" ? "" : n2.replace(/\/*$/, "/");
|
|
69115
69410
|
this[hi](o2 + r2);
|
|
69116
69411
|
});
|
|
69117
69412
|
let e2 = t.entry, i = this.zip;
|
|
@@ -69147,7 +69442,7 @@ var kt = class extends Et {
|
|
|
69147
69442
|
[li](t) {
|
|
69148
69443
|
let e2 = t.entry, i = this.zip;
|
|
69149
69444
|
if (t.readdir && t.readdir.forEach((r2) => {
|
|
69150
|
-
let
|
|
69445
|
+
let n2 = t.path, o2 = n2 === "./" ? "" : n2.replace(/\/*$/, "/");
|
|
69151
69446
|
this[hi](o2 + r2);
|
|
69152
69447
|
}), !e2)
|
|
69153
69448
|
throw new Error("Cannot pipe without source");
|
|
@@ -69165,10 +69460,10 @@ var Un = (s3, t) => {
|
|
|
69165
69460
|
var Hn = (s3, t) => {
|
|
69166
69461
|
let e2 = new Et(s3), i = new tt(s3.file, { mode: s3.mode || 438 });
|
|
69167
69462
|
e2.pipe(i);
|
|
69168
|
-
let r2 = new Promise((
|
|
69169
|
-
i.on("error", o2), i.on("close",
|
|
69463
|
+
let r2 = new Promise((n2, o2) => {
|
|
69464
|
+
i.on("error", o2), i.on("close", n2), e2.on("error", o2);
|
|
69170
69465
|
});
|
|
69171
|
-
return hr(e2, t).catch((
|
|
69466
|
+
return hr(e2, t).catch((n2) => e2.emit("error", n2)), r2;
|
|
69172
69467
|
};
|
|
69173
69468
|
var or = (s3, t) => {
|
|
69174
69469
|
t.forEach((e2) => {
|
|
@@ -69203,7 +69498,7 @@ var Vn = 512 * 1024;
|
|
|
69203
69498
|
var $n = pr | ur | dr | mr;
|
|
69204
69499
|
var lr = !fr && typeof ar == "number" ? ar | ur | dr | mr : null;
|
|
69205
69500
|
var cs = lr !== null ? () => lr : Kn ? (s3) => s3 < Vn ? $n : "w" : () => "w";
|
|
69206
|
-
var
|
|
69501
|
+
var fs29 = (s3, t, e2) => {
|
|
69207
69502
|
try {
|
|
69208
69503
|
return mi.lchownSync(s3, t, e2);
|
|
69209
69504
|
} catch (i) {
|
|
@@ -69218,28 +69513,28 @@ var ui = (s3, t, e2, i) => {
|
|
|
69218
69513
|
};
|
|
69219
69514
|
var Xn = (s3, t, e2, i, r2) => {
|
|
69220
69515
|
if (t.isDirectory())
|
|
69221
|
-
ds(Ee.resolve(s3, t.name), e2, i, (
|
|
69222
|
-
if (
|
|
69223
|
-
return r2(
|
|
69516
|
+
ds(Ee.resolve(s3, t.name), e2, i, (n2) => {
|
|
69517
|
+
if (n2)
|
|
69518
|
+
return r2(n2);
|
|
69224
69519
|
let o2 = Ee.resolve(s3, t.name);
|
|
69225
69520
|
ui(o2, e2, i, r2);
|
|
69226
69521
|
});
|
|
69227
69522
|
else {
|
|
69228
|
-
let
|
|
69229
|
-
ui(
|
|
69523
|
+
let n2 = Ee.resolve(s3, t.name);
|
|
69524
|
+
ui(n2, e2, i, r2);
|
|
69230
69525
|
}
|
|
69231
69526
|
};
|
|
69232
69527
|
var ds = (s3, t, e2, i) => {
|
|
69233
|
-
mi.readdir(s3, { withFileTypes: true }, (r2,
|
|
69528
|
+
mi.readdir(s3, { withFileTypes: true }, (r2, n2) => {
|
|
69234
69529
|
if (r2) {
|
|
69235
69530
|
if (r2.code === "ENOENT")
|
|
69236
69531
|
return i();
|
|
69237
69532
|
if (r2.code !== "ENOTDIR" && r2.code !== "ENOTSUP")
|
|
69238
69533
|
return i(r2);
|
|
69239
69534
|
}
|
|
69240
|
-
if (r2 || !
|
|
69535
|
+
if (r2 || !n2.length)
|
|
69241
69536
|
return ui(s3, t, e2, i);
|
|
69242
|
-
let o2 =
|
|
69537
|
+
let o2 = n2.length, h2 = null, a3 = (l2) => {
|
|
69243
69538
|
if (!h2) {
|
|
69244
69539
|
if (l2)
|
|
69245
69540
|
return i(h2 = l2);
|
|
@@ -69247,28 +69542,28 @@ var ds = (s3, t, e2, i) => {
|
|
|
69247
69542
|
return ui(s3, t, e2, i);
|
|
69248
69543
|
}
|
|
69249
69544
|
};
|
|
69250
|
-
for (let l2 of
|
|
69545
|
+
for (let l2 of n2)
|
|
69251
69546
|
Xn(s3, l2, t, e2, a3);
|
|
69252
69547
|
});
|
|
69253
69548
|
};
|
|
69254
69549
|
var qn = (s3, t, e2, i) => {
|
|
69255
|
-
t.isDirectory() && us(Ee.resolve(s3, t.name), e2, i),
|
|
69550
|
+
t.isDirectory() && us(Ee.resolve(s3, t.name), e2, i), fs29(Ee.resolve(s3, t.name), e2, i);
|
|
69256
69551
|
};
|
|
69257
69552
|
var us = (s3, t, e2) => {
|
|
69258
69553
|
let i;
|
|
69259
69554
|
try {
|
|
69260
69555
|
i = mi.readdirSync(s3, { withFileTypes: true });
|
|
69261
69556
|
} catch (r2) {
|
|
69262
|
-
let
|
|
69263
|
-
if (
|
|
69557
|
+
let n2 = r2;
|
|
69558
|
+
if (n2?.code === "ENOENT")
|
|
69264
69559
|
return;
|
|
69265
|
-
if (
|
|
69266
|
-
return
|
|
69267
|
-
throw
|
|
69560
|
+
if (n2?.code === "ENOTDIR" || n2?.code === "ENOTSUP")
|
|
69561
|
+
return fs29(s3, t, e2);
|
|
69562
|
+
throw n2;
|
|
69268
69563
|
}
|
|
69269
69564
|
for (let r2 of i)
|
|
69270
69565
|
qn(s3, r2, t, e2);
|
|
69271
|
-
return
|
|
69566
|
+
return fs29(s3, t, e2);
|
|
69272
69567
|
};
|
|
69273
69568
|
var we = class extends Error {
|
|
69274
69569
|
path;
|
|
@@ -69300,8 +69595,8 @@ var Qn = (s3, t) => {
|
|
|
69300
69595
|
};
|
|
69301
69596
|
var Er = (s3, t, e2) => {
|
|
69302
69597
|
s3 = f3(s3);
|
|
69303
|
-
let i = t.umask ?? 18, r2 = t.mode | 448,
|
|
69304
|
-
E2 ? e2(E2) : x3 && a3 ? ds(x3, o2, h2, (xe) => S3(xe)) :
|
|
69598
|
+
let i = t.umask ?? 18, r2 = t.mode | 448, n2 = (r2 & i) !== 0, o2 = t.uid, h2 = t.gid, a3 = typeof o2 == "number" && typeof h2 == "number" && (o2 !== t.processUid || h2 !== t.processGid), l2 = t.preserve, c2 = t.unlink, d3 = f3(t.cwd), S3 = (E2, x3) => {
|
|
69599
|
+
E2 ? e2(E2) : x3 && a3 ? ds(x3, o2, h2, (xe) => S3(xe)) : n2 ? k2.chmod(s3, r2, e2) : e2();
|
|
69305
69600
|
};
|
|
69306
69601
|
if (s3 === d3)
|
|
69307
69602
|
return Qn(s3, S3);
|
|
@@ -69310,30 +69605,30 @@ var Er = (s3, t, e2) => {
|
|
|
69310
69605
|
let N2 = f3(pi.relative(d3, s3)).split("/");
|
|
69311
69606
|
ms(d3, N2, r2, c2, d3, undefined, S3);
|
|
69312
69607
|
};
|
|
69313
|
-
var ms = (s3, t, e2, i, r2,
|
|
69608
|
+
var ms = (s3, t, e2, i, r2, n2, o2) => {
|
|
69314
69609
|
if (t.length === 0)
|
|
69315
|
-
return o2(null,
|
|
69610
|
+
return o2(null, n2);
|
|
69316
69611
|
let h2 = t.shift(), a3 = f3(pi.resolve(s3 + "/" + h2));
|
|
69317
|
-
k2.mkdir(a3, e2, wr(a3, t, e2, i, r2,
|
|
69612
|
+
k2.mkdir(a3, e2, wr(a3, t, e2, i, r2, n2, o2));
|
|
69318
69613
|
};
|
|
69319
|
-
var wr = (s3, t, e2, i, r2,
|
|
69614
|
+
var wr = (s3, t, e2, i, r2, n2, o2) => (h2) => {
|
|
69320
69615
|
h2 ? k2.lstat(s3, (a3, l2) => {
|
|
69321
69616
|
if (a3)
|
|
69322
69617
|
a3.path = a3.path && f3(a3.path), o2(a3);
|
|
69323
69618
|
else if (l2.isDirectory())
|
|
69324
|
-
ms(s3, t, e2, i, r2,
|
|
69619
|
+
ms(s3, t, e2, i, r2, n2, o2);
|
|
69325
69620
|
else if (i)
|
|
69326
69621
|
k2.unlink(s3, (c2) => {
|
|
69327
69622
|
if (c2)
|
|
69328
69623
|
return o2(c2);
|
|
69329
|
-
k2.mkdir(s3, e2, wr(s3, t, e2, i, r2,
|
|
69624
|
+
k2.mkdir(s3, e2, wr(s3, t, e2, i, r2, n2, o2));
|
|
69330
69625
|
});
|
|
69331
69626
|
else {
|
|
69332
69627
|
if (l2.isSymbolicLink())
|
|
69333
69628
|
return o2(new wt(s3, s3 + "/" + t.join("/")));
|
|
69334
69629
|
o2(h2);
|
|
69335
69630
|
}
|
|
69336
|
-
}) : (
|
|
69631
|
+
}) : (n2 = n2 || s3, ms(s3, t, e2, i, r2, n2, o2));
|
|
69337
69632
|
};
|
|
69338
69633
|
var Jn = (s3) => {
|
|
69339
69634
|
let t = false, e2;
|
|
@@ -69348,8 +69643,8 @@ var Jn = (s3) => {
|
|
|
69348
69643
|
};
|
|
69349
69644
|
var Sr = (s3, t) => {
|
|
69350
69645
|
s3 = f3(s3);
|
|
69351
|
-
let e2 = t.umask ?? 18, i = t.mode | 448, r2 = (i & e2) !== 0,
|
|
69352
|
-
E2 && h2 && us(E2,
|
|
69646
|
+
let e2 = t.umask ?? 18, i = t.mode | 448, r2 = (i & e2) !== 0, n2 = t.uid, o2 = t.gid, h2 = typeof n2 == "number" && typeof o2 == "number" && (n2 !== t.processUid || o2 !== t.processGid), a3 = t.preserve, l2 = t.unlink, c2 = f3(t.cwd), d3 = (E2) => {
|
|
69647
|
+
E2 && h2 && us(E2, n2, o2), r2 && k2.chmodSync(s3, i);
|
|
69353
69648
|
};
|
|
69354
69649
|
if (s3 === c2)
|
|
69355
69650
|
return Jn(c2), d3();
|
|
@@ -69398,19 +69693,19 @@ var Ei = class {
|
|
|
69398
69693
|
#s = new Set;
|
|
69399
69694
|
reserve(t, e2) {
|
|
69400
69695
|
t = eo ? ["win32 parallelization disabled"] : t.map((r2) => mt(br(Rr(r2))));
|
|
69401
|
-
let i = new Set(t.map((r2) => io(r2)).reduce((r2,
|
|
69696
|
+
let i = new Set(t.map((r2) => io(r2)).reduce((r2, n2) => r2.concat(n2)));
|
|
69402
69697
|
this.#i.set(e2, { dirs: i, paths: t });
|
|
69403
69698
|
for (let r2 of t) {
|
|
69404
|
-
let
|
|
69405
|
-
|
|
69699
|
+
let n2 = this.#t.get(r2);
|
|
69700
|
+
n2 ? n2.push(e2) : this.#t.set(r2, [e2]);
|
|
69406
69701
|
}
|
|
69407
69702
|
for (let r2 of i) {
|
|
69408
|
-
let
|
|
69409
|
-
if (!
|
|
69703
|
+
let n2 = this.#t.get(r2);
|
|
69704
|
+
if (!n2)
|
|
69410
69705
|
this.#t.set(r2, [new Set([e2])]);
|
|
69411
69706
|
else {
|
|
69412
|
-
let o2 =
|
|
69413
|
-
o2 instanceof Set ? o2.add(e2) :
|
|
69707
|
+
let o2 = n2.at(-1);
|
|
69708
|
+
o2 instanceof Set ? o2.add(e2) : n2.push(new Set([e2]));
|
|
69414
69709
|
}
|
|
69415
69710
|
}
|
|
69416
69711
|
return this.#r(e2);
|
|
@@ -69434,7 +69729,7 @@ var Ei = class {
|
|
|
69434
69729
|
let e2 = this.#i.get(t);
|
|
69435
69730
|
if (!e2)
|
|
69436
69731
|
throw new Error("invalid reservation");
|
|
69437
|
-
let { paths: i, dirs: r2 } = e2,
|
|
69732
|
+
let { paths: i, dirs: r2 } = e2, n2 = new Set;
|
|
69438
69733
|
for (let o2 of i) {
|
|
69439
69734
|
let h2 = this.#t.get(o2);
|
|
69440
69735
|
if (!h2 || h2?.[0] !== t)
|
|
@@ -69445,10 +69740,10 @@ var Ei = class {
|
|
|
69445
69740
|
continue;
|
|
69446
69741
|
}
|
|
69447
69742
|
if (h2.shift(), typeof a3 == "function")
|
|
69448
|
-
|
|
69743
|
+
n2.add(a3);
|
|
69449
69744
|
else
|
|
69450
69745
|
for (let l2 of a3)
|
|
69451
|
-
|
|
69746
|
+
n2.add(l2);
|
|
69452
69747
|
}
|
|
69453
69748
|
for (let o2 of r2) {
|
|
69454
69749
|
let h2 = this.#t.get(o2), a3 = h2?.[0];
|
|
@@ -69459,11 +69754,11 @@ var Ei = class {
|
|
|
69459
69754
|
} else if (a3.size === 1) {
|
|
69460
69755
|
h2.shift();
|
|
69461
69756
|
let l2 = h2[0];
|
|
69462
|
-
typeof l2 == "function" &&
|
|
69757
|
+
typeof l2 == "function" && n2.add(l2);
|
|
69463
69758
|
} else
|
|
69464
69759
|
a3.delete(t);
|
|
69465
69760
|
}
|
|
69466
|
-
return this.#s.delete(t),
|
|
69761
|
+
return this.#s.delete(t), n2.forEach((o2) => this.#r(o2)), true;
|
|
69467
69762
|
}
|
|
69468
69763
|
};
|
|
69469
69764
|
var _r = () => process.umask();
|
|
@@ -69565,7 +69860,7 @@ var qt = class extends st {
|
|
|
69565
69860
|
let i = t[e2], { type: r2 } = t;
|
|
69566
69861
|
if (!i || this.preservePaths)
|
|
69567
69862
|
return true;
|
|
69568
|
-
let [
|
|
69863
|
+
let [n2, o2] = ce2(i), h2 = o2.replaceAll(/\\/g, "/").split("/");
|
|
69569
69864
|
if (h2.includes("..") || Oe && /^[a-z]:\.\.$/i.test(h2[0] ?? "")) {
|
|
69570
69865
|
if (e2 === "path" || r2 === "Link")
|
|
69571
69866
|
return this.warn("TAR_ENTRY_ERROR", `${e2} contains '..'`, { entry: t, [e2]: i }), false;
|
|
@@ -69573,7 +69868,7 @@ var qt = class extends st {
|
|
|
69573
69868
|
if (l2.startsWith("../") || l2 === "..")
|
|
69574
69869
|
return this.warn("TAR_ENTRY_ERROR", `${e2} escapes extraction directory`, { entry: t, [e2]: i }), false;
|
|
69575
69870
|
}
|
|
69576
|
-
return
|
|
69871
|
+
return n2 && (t[e2] = String(o2), this.warn("TAR_ENTRY_INFO", `stripping ${n2} from absolute ${e2}`, { entry: t, [e2]: i })), true;
|
|
69577
69872
|
}
|
|
69578
69873
|
[Nr](t) {
|
|
69579
69874
|
let e2 = f3(t.path), i = e2.split("/");
|
|
@@ -69600,8 +69895,8 @@ var qt = class extends st {
|
|
|
69600
69895
|
if (this.win32) {
|
|
69601
69896
|
let { root: r2 } = R3.win32.parse(String(t.absolute));
|
|
69602
69897
|
t.absolute = r2 + Xi(String(t.absolute).slice(r2.length));
|
|
69603
|
-
let { root:
|
|
69604
|
-
t.path =
|
|
69898
|
+
let { root: n2 } = R3.win32.parse(t.path);
|
|
69899
|
+
t.path = n2 + Xi(t.path.slice(n2.length));
|
|
69605
69900
|
}
|
|
69606
69901
|
return true;
|
|
69607
69902
|
}
|
|
@@ -69642,24 +69937,24 @@ var qt = class extends st {
|
|
|
69642
69937
|
r2.on("error", (a3) => {
|
|
69643
69938
|
r2.fd && u.close(r2.fd, () => {}), r2.write = () => true, this[O2](a3, t), e2();
|
|
69644
69939
|
});
|
|
69645
|
-
let
|
|
69940
|
+
let n2 = 1, o2 = (a3) => {
|
|
69646
69941
|
if (a3) {
|
|
69647
69942
|
r2.fd && u.close(r2.fd, () => {}), this[O2](a3, t), e2();
|
|
69648
69943
|
return;
|
|
69649
69944
|
}
|
|
69650
|
-
--
|
|
69945
|
+
--n2 === 0 && r2.fd !== undefined && u.close(r2.fd, (l2) => {
|
|
69651
69946
|
l2 ? this[O2](l2, t) : this[Xt](), e2();
|
|
69652
69947
|
});
|
|
69653
69948
|
};
|
|
69654
69949
|
r2.on("finish", () => {
|
|
69655
69950
|
let a3 = String(t.absolute), l2 = r2.fd;
|
|
69656
69951
|
if (typeof l2 == "number" && t.mtime && !this.noMtime) {
|
|
69657
|
-
|
|
69952
|
+
n2++;
|
|
69658
69953
|
let c2 = t.atime || new Date, d3 = t.mtime;
|
|
69659
69954
|
u.futimes(l2, c2, d3, (S3) => S3 ? u.utimes(a3, c2, d3, (T3) => o2(T3 && S3)) : o2());
|
|
69660
69955
|
}
|
|
69661
69956
|
if (typeof l2 == "number" && this[Re](t)) {
|
|
69662
|
-
|
|
69957
|
+
n2++;
|
|
69663
69958
|
let c2 = this[be](t), d3 = this[_e](t);
|
|
69664
69959
|
typeof c2 == "number" && typeof d3 == "number" && u.fchown(l2, c2, d3, (S3) => S3 ? u.chown(a3, c2, d3, (T3) => o2(T3 && S3)) : o2());
|
|
69665
69960
|
}
|
|
@@ -69677,10 +69972,10 @@ var qt = class extends st {
|
|
|
69677
69972
|
this[O2](r2, t), e2();
|
|
69678
69973
|
return;
|
|
69679
69974
|
}
|
|
69680
|
-
let
|
|
69681
|
-
--
|
|
69975
|
+
let n2 = 1, o2 = () => {
|
|
69976
|
+
--n2 === 0 && (e2(), this[Xt](), t.resume());
|
|
69682
69977
|
};
|
|
69683
|
-
t.mtime && !this.noMtime && (
|
|
69978
|
+
t.mtime && !this.noMtime && (n2++, u.utimes(String(t.absolute), t.atime || new Date, t.mtime, o2)), this[Re](t) && (n2++, u.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o2)), o2();
|
|
69684
69979
|
});
|
|
69685
69980
|
}
|
|
69686
69981
|
[Lr](t) {
|
|
@@ -69694,11 +69989,11 @@ var qt = class extends st {
|
|
|
69694
69989
|
}
|
|
69695
69990
|
[xr](t, e2) {
|
|
69696
69991
|
let i = f3(R3.resolve(this.cwd, String(t.linkpath))), r2 = f3(String(t.linkpath)).split("/");
|
|
69697
|
-
this[ye](t, this.cwd, r2, () => this[Si](t, i, "link", e2), (
|
|
69698
|
-
this[O2](
|
|
69992
|
+
this[ye](t, this.cwd, r2, () => this[Si](t, i, "link", e2), (n2) => {
|
|
69993
|
+
this[O2](n2, t), e2();
|
|
69699
69994
|
});
|
|
69700
69995
|
}
|
|
69701
|
-
[ye](t, e2, i, r2,
|
|
69996
|
+
[ye](t, e2, i, r2, n2) {
|
|
69702
69997
|
let o2 = i.shift();
|
|
69703
69998
|
if (this.preservePaths || o2 === undefined)
|
|
69704
69999
|
return r2();
|
|
@@ -69707,8 +70002,8 @@ var qt = class extends st {
|
|
|
69707
70002
|
if (a3)
|
|
69708
70003
|
return r2();
|
|
69709
70004
|
if (l2?.isSymbolicLink())
|
|
69710
|
-
return
|
|
69711
|
-
this[ye](t, h2, i, r2,
|
|
70005
|
+
return n2(new wt(h2, R3.resolve(h2, i.join("/"))));
|
|
70006
|
+
this[ye](t, h2, i, r2, n2);
|
|
69712
70007
|
});
|
|
69713
70008
|
}
|
|
69714
70009
|
[Ar]() {
|
|
@@ -69737,9 +70032,9 @@ var qt = class extends st {
|
|
|
69737
70032
|
this[O2](h2, t), i();
|
|
69738
70033
|
return;
|
|
69739
70034
|
}
|
|
69740
|
-
this[ge] = true,
|
|
70035
|
+
this[ge] = true, n2();
|
|
69741
70036
|
});
|
|
69742
|
-
},
|
|
70037
|
+
}, n2 = () => {
|
|
69743
70038
|
if (t.absolute !== this.cwd) {
|
|
69744
70039
|
let h2 = f3(R3.dirname(String(t.absolute)));
|
|
69745
70040
|
if (h2 !== this.cwd)
|
|
@@ -69773,7 +70068,7 @@ var qt = class extends st {
|
|
|
69773
70068
|
oo(String(t.absolute), (l2) => this[P2](l2 ?? null, t, i));
|
|
69774
70069
|
});
|
|
69775
70070
|
};
|
|
69776
|
-
this[ge] ?
|
|
70071
|
+
this[ge] ? n2() : r2();
|
|
69777
70072
|
}
|
|
69778
70073
|
[P2](t, e2, i) {
|
|
69779
70074
|
if (t) {
|
|
@@ -69795,8 +70090,8 @@ var qt = class extends st {
|
|
|
69795
70090
|
}
|
|
69796
70091
|
}
|
|
69797
70092
|
[Si](t, e2, i, r2) {
|
|
69798
|
-
u[i](e2, String(t.absolute), (
|
|
69799
|
-
|
|
70093
|
+
u[i](e2, String(t.absolute), (n2) => {
|
|
70094
|
+
n2 ? this[O2](n2, t) : (this[Xt](), t.resume()), r2();
|
|
69800
70095
|
});
|
|
69801
70096
|
}
|
|
69802
70097
|
};
|
|
@@ -69814,15 +70109,15 @@ var Te = class extends qt {
|
|
|
69814
70109
|
}
|
|
69815
70110
|
[ys](t) {
|
|
69816
70111
|
if (!this[ge]) {
|
|
69817
|
-
let
|
|
69818
|
-
if (
|
|
69819
|
-
return this[O2](
|
|
70112
|
+
let n2 = this[St](this.cwd, this.dmode);
|
|
70113
|
+
if (n2)
|
|
70114
|
+
return this[O2](n2, t);
|
|
69820
70115
|
this[ge] = true;
|
|
69821
70116
|
}
|
|
69822
70117
|
if (t.absolute !== this.cwd) {
|
|
69823
|
-
let
|
|
69824
|
-
if (
|
|
69825
|
-
let o2 = this[St](
|
|
70118
|
+
let n2 = f3(R3.dirname(String(t.absolute)));
|
|
70119
|
+
if (n2 !== this.cwd) {
|
|
70120
|
+
let o2 = this[St](n2, this.dmode);
|
|
69826
70121
|
if (o2)
|
|
69827
70122
|
return this[O2](o2, t);
|
|
69828
70123
|
}
|
|
@@ -69839,8 +70134,8 @@ var Te = class extends qt {
|
|
|
69839
70134
|
}) : [];
|
|
69840
70135
|
return this[P2](h2, t);
|
|
69841
70136
|
}
|
|
69842
|
-
let [
|
|
69843
|
-
this[P2](
|
|
70137
|
+
let [n2] = Se(() => u.rmdirSync(String(t.absolute)));
|
|
70138
|
+
this[P2](n2, t);
|
|
69844
70139
|
}
|
|
69845
70140
|
let [r2] = t.absolute === this.cwd ? [] : Se(() => ho(String(t.absolute)));
|
|
69846
70141
|
this[P2](r2, t);
|
|
@@ -69849,21 +70144,21 @@ var Te = class extends qt {
|
|
|
69849
70144
|
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r2 = (h2) => {
|
|
69850
70145
|
let a3;
|
|
69851
70146
|
try {
|
|
69852
|
-
u.closeSync(
|
|
70147
|
+
u.closeSync(n2);
|
|
69853
70148
|
} catch (l2) {
|
|
69854
70149
|
a3 = l2;
|
|
69855
70150
|
}
|
|
69856
70151
|
(h2 || a3) && this[O2](h2 || a3, t), e2();
|
|
69857
|
-
},
|
|
70152
|
+
}, n2;
|
|
69858
70153
|
try {
|
|
69859
|
-
|
|
70154
|
+
n2 = u.openSync(String(t.absolute), cs(t.size), i);
|
|
69860
70155
|
} catch (h2) {
|
|
69861
70156
|
return r2(h2);
|
|
69862
70157
|
}
|
|
69863
70158
|
let o2 = this.transform && this.transform(t) || t;
|
|
69864
70159
|
o2 !== t && (o2.on("error", (h2) => this[O2](h2, t)), t.pipe(o2)), o2.on("data", (h2) => {
|
|
69865
70160
|
try {
|
|
69866
|
-
u.writeSync(
|
|
70161
|
+
u.writeSync(n2, h2, 0, h2.length);
|
|
69867
70162
|
} catch (a3) {
|
|
69868
70163
|
r2(a3);
|
|
69869
70164
|
}
|
|
@@ -69872,7 +70167,7 @@ var Te = class extends qt {
|
|
|
69872
70167
|
if (t.mtime && !this.noMtime) {
|
|
69873
70168
|
let a3 = t.atime || new Date, l2 = t.mtime;
|
|
69874
70169
|
try {
|
|
69875
|
-
u.futimesSync(
|
|
70170
|
+
u.futimesSync(n2, a3, l2);
|
|
69876
70171
|
} catch (c2) {
|
|
69877
70172
|
try {
|
|
69878
70173
|
u.utimesSync(String(t.absolute), a3, l2);
|
|
@@ -69884,7 +70179,7 @@ var Te = class extends qt {
|
|
|
69884
70179
|
if (this[Re](t)) {
|
|
69885
70180
|
let a3 = this[be](t), l2 = this[_e](t);
|
|
69886
70181
|
try {
|
|
69887
|
-
u.fchownSync(
|
|
70182
|
+
u.fchownSync(n2, Number(a3), Number(l2));
|
|
69888
70183
|
} catch (c2) {
|
|
69889
70184
|
try {
|
|
69890
70185
|
u.chownSync(String(t.absolute), Number(a3), Number(l2));
|
|
@@ -69919,7 +70214,7 @@ var Te = class extends qt {
|
|
|
69919
70214
|
return i;
|
|
69920
70215
|
}
|
|
69921
70216
|
}
|
|
69922
|
-
[ye](t, e2, i, r2,
|
|
70217
|
+
[ye](t, e2, i, r2, n2) {
|
|
69923
70218
|
if (this.preservePaths || i.length === 0)
|
|
69924
70219
|
return r2();
|
|
69925
70220
|
let o2 = e2;
|
|
@@ -69929,14 +70224,14 @@ var Te = class extends qt {
|
|
|
69929
70224
|
if (a3)
|
|
69930
70225
|
return r2();
|
|
69931
70226
|
if (l2.isSymbolicLink())
|
|
69932
|
-
return
|
|
70227
|
+
return n2(new wt(o2, R3.resolve(e2, i.join("/"))));
|
|
69933
70228
|
}
|
|
69934
70229
|
r2();
|
|
69935
70230
|
}
|
|
69936
70231
|
[Si](t, e2, i, r2) {
|
|
69937
|
-
let
|
|
70232
|
+
let n2 = `${i}Sync`;
|
|
69938
70233
|
try {
|
|
69939
|
-
u[
|
|
70234
|
+
u[n2](e2, String(t.absolute)), r2(), t.resume();
|
|
69940
70235
|
} catch (o2) {
|
|
69941
70236
|
return this[O2](o2, t);
|
|
69942
70237
|
}
|
|
@@ -69963,7 +70258,7 @@ var co = K3(ao, lo, (s3) => new Te(s3), (s3) => new qt(s3), (s3, t) => {
|
|
|
69963
70258
|
t?.length && Ki(s3, t);
|
|
69964
70259
|
});
|
|
69965
70260
|
var fo = (s3, t) => {
|
|
69966
|
-
let e2 = new kt(s3), i = true, r2,
|
|
70261
|
+
let e2 = new kt(s3), i = true, r2, n2;
|
|
69967
70262
|
try {
|
|
69968
70263
|
try {
|
|
69969
70264
|
r2 = v2.openSync(s3.file, "r+");
|
|
@@ -69975,9 +70270,9 @@ var fo = (s3, t) => {
|
|
|
69975
70270
|
}
|
|
69976
70271
|
let o2 = v2.fstatSync(r2), h2 = Buffer.alloc(512);
|
|
69977
70272
|
t:
|
|
69978
|
-
for (
|
|
70273
|
+
for (n2 = 0;n2 < o2.size; n2 += 512) {
|
|
69979
70274
|
for (let c2 = 0, d3 = 0;c2 < 512; c2 += d3) {
|
|
69980
|
-
if (d3 = v2.readSync(r2, h2, c2, h2.length - c2,
|
|
70275
|
+
if (d3 = v2.readSync(r2, h2, c2, h2.length - c2, n2 + c2), n2 === 0 && h2[0] === 31 && h2[1] === 139)
|
|
69981
70276
|
throw new Error("cannot append to compressed archives");
|
|
69982
70277
|
if (!d3)
|
|
69983
70278
|
break t;
|
|
@@ -69986,11 +70281,11 @@ var fo = (s3, t) => {
|
|
|
69986
70281
|
if (!a3.cksumValid)
|
|
69987
70282
|
break;
|
|
69988
70283
|
let l2 = 512 * Math.ceil((a3.size || 0) / 512);
|
|
69989
|
-
if (
|
|
70284
|
+
if (n2 + l2 + 512 > o2.size)
|
|
69990
70285
|
break;
|
|
69991
|
-
|
|
70286
|
+
n2 += l2, s3.mtimeCache && a3.mtime && s3.mtimeCache.set(String(a3.path), a3.mtime);
|
|
69992
70287
|
}
|
|
69993
|
-
i = false, uo(s3, e2,
|
|
70288
|
+
i = false, uo(s3, e2, n2, r2, t);
|
|
69994
70289
|
} finally {
|
|
69995
70290
|
if (i)
|
|
69996
70291
|
try {
|
|
@@ -69999,14 +70294,14 @@ var fo = (s3, t) => {
|
|
|
69999
70294
|
}
|
|
70000
70295
|
};
|
|
70001
70296
|
var uo = (s3, t, e2, i, r2) => {
|
|
70002
|
-
let
|
|
70003
|
-
t.pipe(
|
|
70297
|
+
let n2 = new Wt(s3.file, { fd: i, start: e2 });
|
|
70298
|
+
t.pipe(n2), po(t, r2);
|
|
70004
70299
|
};
|
|
70005
70300
|
var mo = (s3, t) => {
|
|
70006
70301
|
t = Array.from(t);
|
|
70007
|
-
let e2 = new Et(s3), i = (
|
|
70302
|
+
let e2 = new Et(s3), i = (n2, o2, h2) => {
|
|
70008
70303
|
let a3 = (T3, N2) => {
|
|
70009
|
-
T3 ? v2.close(
|
|
70304
|
+
T3 ? v2.close(n2, (E2) => h2(T3)) : h2(null, N2);
|
|
70010
70305
|
}, l2 = 0;
|
|
70011
70306
|
if (o2 === 0)
|
|
70012
70307
|
return a3(null, 0);
|
|
@@ -70014,7 +70309,7 @@ var mo = (s3, t) => {
|
|
|
70014
70309
|
if (T3 || N2 === undefined)
|
|
70015
70310
|
return a3(T3);
|
|
70016
70311
|
if (c2 += N2, c2 < 512 && N2)
|
|
70017
|
-
return v2.read(
|
|
70312
|
+
return v2.read(n2, d3, c2, d3.length - c2, l2 + c2, S3);
|
|
70018
70313
|
if (l2 === 0 && d3[0] === 31 && d3[1] === 139)
|
|
70019
70314
|
return a3(new Error("cannot append to compressed archives"));
|
|
70020
70315
|
if (c2 < 512)
|
|
@@ -70025,11 +70320,11 @@ var mo = (s3, t) => {
|
|
|
70025
70320
|
let x3 = 512 * Math.ceil((E2.size ?? 0) / 512);
|
|
70026
70321
|
if (l2 + x3 + 512 > o2 || (l2 += x3 + 512, l2 >= o2))
|
|
70027
70322
|
return a3(null, l2);
|
|
70028
|
-
s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c2 = 0, v2.read(
|
|
70323
|
+
s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c2 = 0, v2.read(n2, d3, 0, 512, l2, S3);
|
|
70029
70324
|
};
|
|
70030
|
-
v2.read(
|
|
70325
|
+
v2.read(n2, d3, 0, 512, l2, S3);
|
|
70031
70326
|
};
|
|
70032
|
-
return new Promise((
|
|
70327
|
+
return new Promise((n2, o2) => {
|
|
70033
70328
|
e2.on("error", o2);
|
|
70034
70329
|
let h2 = "r+", a3 = (l2, c2) => {
|
|
70035
70330
|
if (l2 && l2.code === "ENOENT" && h2 === "r+")
|
|
@@ -70043,7 +70338,7 @@ var mo = (s3, t) => {
|
|
|
70043
70338
|
if (T3)
|
|
70044
70339
|
return o2(T3);
|
|
70045
70340
|
let E2 = new tt(s3.file, { fd: c2, start: N2 });
|
|
70046
|
-
e2.pipe(E2), E2.on("error", o2), E2.on("close",
|
|
70341
|
+
e2.pipe(E2), E2.on("error", o2), E2.on("close", n2), Eo(e2, t);
|
|
70047
70342
|
});
|
|
70048
70343
|
});
|
|
70049
70344
|
};
|
|
@@ -70508,7 +70803,7 @@ function buildReleaseAllowlist(layout) {
|
|
|
70508
70803
|
async function ensureLayoutSourceDir(projectRoot, layout, strict) {
|
|
70509
70804
|
const sourceDir = path10.join(projectRoot, layout.sourceDir);
|
|
70510
70805
|
try {
|
|
70511
|
-
const stat11 = await
|
|
70806
|
+
const stat11 = await fs30.promises.stat(sourceDir);
|
|
70512
70807
|
if (!stat11.isDirectory()) {
|
|
70513
70808
|
throw new Error(`Expected source directory "${layout.sourceDir}" exists but is not a directory.`);
|
|
70514
70809
|
}
|
|
@@ -70533,8 +70828,8 @@ async function materializeRuntimeLayoutInPlace(projectRoot, layout) {
|
|
|
70533
70828
|
}
|
|
70534
70829
|
const sourceDir = path10.join(projectRoot, layout.sourceDir);
|
|
70535
70830
|
const runtimeDir = path10.join(projectRoot, layout.runtimeDir);
|
|
70536
|
-
await
|
|
70537
|
-
await
|
|
70831
|
+
await fs30.promises.rm(runtimeDir, { recursive: true, force: true });
|
|
70832
|
+
await fs30.promises.rename(sourceDir, runtimeDir);
|
|
70538
70833
|
}
|
|
70539
70834
|
async function stageLocalKitPathForRuntimeLayout(kitRoot, layout) {
|
|
70540
70835
|
const sourceDir = await ensureLayoutSourceDir(kitRoot, layout, false);
|
|
@@ -70544,20 +70839,20 @@ async function stageLocalKitPathForRuntimeLayout(kitRoot, layout) {
|
|
|
70544
70839
|
const downloadManager = new DownloadManager;
|
|
70545
70840
|
const tempDir = await downloadManager.createTempDir();
|
|
70546
70841
|
const extractDir = `${tempDir}/extracted`;
|
|
70547
|
-
await
|
|
70548
|
-
const entries = await
|
|
70842
|
+
await fs30.promises.mkdir(extractDir, { recursive: true });
|
|
70843
|
+
const entries = await fs30.promises.readdir(kitRoot);
|
|
70549
70844
|
const allowlist = buildReleaseAllowlist(layout);
|
|
70550
70845
|
for (const entry of entries) {
|
|
70551
70846
|
if (!allowlist.includes(entry) || entry === layout.sourceDir) {
|
|
70552
70847
|
continue;
|
|
70553
70848
|
}
|
|
70554
|
-
await
|
|
70849
|
+
await fs30.promises.cp(path10.join(kitRoot, entry), path10.join(extractDir, entry), {
|
|
70555
70850
|
recursive: true
|
|
70556
70851
|
});
|
|
70557
70852
|
}
|
|
70558
70853
|
const runtimeDir = path10.join(extractDir, layout.runtimeDir);
|
|
70559
|
-
await
|
|
70560
|
-
await
|
|
70854
|
+
await fs30.promises.mkdir(path10.dirname(runtimeDir), { recursive: true });
|
|
70855
|
+
await fs30.promises.cp(sourceDir, runtimeDir, { recursive: true });
|
|
70561
70856
|
logger.verbose("Staged local kit path with runtime layout", {
|
|
70562
70857
|
kitRoot,
|
|
70563
70858
|
extractDir,
|
|
@@ -70586,9 +70881,9 @@ function resolveRepoRootForKit(kitRoot) {
|
|
|
70586
70881
|
try {
|
|
70587
70882
|
const parent = path10.dirname(kitRoot);
|
|
70588
70883
|
const parentPackageJson = path10.join(parent, "package.json");
|
|
70589
|
-
if (!
|
|
70884
|
+
if (!fs30.existsSync(parentPackageJson))
|
|
70590
70885
|
return kitRoot;
|
|
70591
|
-
const pkg = JSON.parse(
|
|
70886
|
+
const pkg = JSON.parse(fs30.readFileSync(parentPackageJson, "utf-8"));
|
|
70592
70887
|
const kitCfg = pkg.takumi;
|
|
70593
70888
|
const sourceDir = kitCfg?.sourceDir;
|
|
70594
70889
|
if (typeof sourceDir === "string" && path10.resolve(parent, sourceDir) === path10.resolve(kitRoot)) {
|
|
@@ -70602,9 +70897,9 @@ async function stageMonorepoForInstallation(kitRoot) {
|
|
|
70602
70897
|
const tempDir = await downloadManager.createTempDir();
|
|
70603
70898
|
const extractDir = `${tempDir}/extracted`;
|
|
70604
70899
|
const claudeDir = path10.join(extractDir, ".claude");
|
|
70605
|
-
await
|
|
70900
|
+
await fs30.promises.mkdir(claudeDir, { recursive: true });
|
|
70606
70901
|
const repoRoot = resolveRepoRootForKit(kitRoot);
|
|
70607
|
-
const kitEntries = await
|
|
70902
|
+
const kitEntries = await fs30.promises.readdir(kitRoot);
|
|
70608
70903
|
const skipLegacyManifest = kitEntries.includes(MANIFEST_FILENAME) && kitEntries.includes(LEGACY_MANIFEST_FILENAME);
|
|
70609
70904
|
for (const entry of kitEntries) {
|
|
70610
70905
|
if (!MONOREPO_KIT_CONTENT.includes(entry))
|
|
@@ -70612,14 +70907,14 @@ async function stageMonorepoForInstallation(kitRoot) {
|
|
|
70612
70907
|
if (skipLegacyManifest && entry === LEGACY_MANIFEST_FILENAME)
|
|
70613
70908
|
continue;
|
|
70614
70909
|
const srcPath = path10.join(kitRoot, entry);
|
|
70615
|
-
await
|
|
70910
|
+
await fs30.promises.cp(srcPath, path10.join(claudeDir, entry), { recursive: true });
|
|
70616
70911
|
}
|
|
70617
|
-
const repoEntries = repoRoot === kitRoot ? kitEntries : await
|
|
70912
|
+
const repoEntries = repoRoot === kitRoot ? kitEntries : await fs30.promises.readdir(repoRoot);
|
|
70618
70913
|
for (const entry of repoEntries) {
|
|
70619
70914
|
if (!RELEASE_ROOT_ALLOWLIST.includes(entry))
|
|
70620
70915
|
continue;
|
|
70621
70916
|
const srcPath = path10.join(repoRoot, entry);
|
|
70622
|
-
await
|
|
70917
|
+
await fs30.promises.cp(srcPath, path10.join(extractDir, entry), { recursive: true });
|
|
70623
70918
|
}
|
|
70624
70919
|
logger.verbose("Staged monorepo for installation", {
|
|
70625
70920
|
kitRoot,
|
|
@@ -70633,13 +70928,13 @@ async function stageMonorepoForInstallation(kitRoot) {
|
|
|
70633
70928
|
async function normalizeFullRepoExtract(dir, strict) {
|
|
70634
70929
|
const layout = resolveKitLayout(dir);
|
|
70635
70930
|
await ensureLayoutSourceDir(dir, layout, strict);
|
|
70636
|
-
const entries = await
|
|
70931
|
+
const entries = await fs30.promises.readdir(dir);
|
|
70637
70932
|
const releaseAllowlist = buildReleaseAllowlist(layout);
|
|
70638
70933
|
let removedCount = 0;
|
|
70639
70934
|
for (const entry of entries) {
|
|
70640
70935
|
if (!releaseAllowlist.includes(entry)) {
|
|
70641
70936
|
const fullPath = path10.join(dir, entry);
|
|
70642
|
-
await
|
|
70937
|
+
await fs30.promises.rm(fullPath, { recursive: true, force: true });
|
|
70643
70938
|
removedCount++;
|
|
70644
70939
|
}
|
|
70645
70940
|
}
|
|
@@ -70754,7 +71049,7 @@ async function useLocalKitPath(kitPath, isMonorepo) {
|
|
|
70754
71049
|
output.section("Using local kit");
|
|
70755
71050
|
const absolutePath = path10.resolve(kitPath);
|
|
70756
71051
|
try {
|
|
70757
|
-
const stat11 = await
|
|
71052
|
+
const stat11 = await fs30.promises.stat(absolutePath);
|
|
70758
71053
|
if (!stat11.isDirectory()) {
|
|
70759
71054
|
throw new Error(`--kit-path must point to a directory, not a file.
|
|
70760
71055
|
|
|
@@ -70793,7 +71088,7 @@ Please verify the path exists and is accessible.`);
|
|
|
70793
71088
|
}
|
|
70794
71089
|
const claudeDir = path10.join(absolutePath, DEFAULT_KIT_LAYOUT.runtimeDir);
|
|
70795
71090
|
try {
|
|
70796
|
-
const stat11 = await
|
|
71091
|
+
const stat11 = await fs30.promises.stat(claudeDir);
|
|
70797
71092
|
if (!stat11.isDirectory()) {
|
|
70798
71093
|
logger.warning(`Warning: ${claudeDir} exists but is not a directory.
|
|
70799
71094
|
This may not be a valid Takumi installation.`);
|
|
@@ -70828,7 +71123,7 @@ async function extractLocalArchive(archivePath, exclude) {
|
|
|
70828
71123
|
const absolutePath = path10.resolve(archivePath);
|
|
70829
71124
|
validateArchiveFormat(absolutePath);
|
|
70830
71125
|
try {
|
|
70831
|
-
const stat11 = await
|
|
71126
|
+
const stat11 = await fs30.promises.stat(absolutePath);
|
|
70832
71127
|
if (!stat11.isFile()) {
|
|
70833
71128
|
throw new Error(`--archive must point to a file, not a directory.
|
|
70834
71129
|
|
|
@@ -70961,7 +71256,7 @@ async function downloadViaWorker(release, kit, isNonInteractive2) {
|
|
|
70961
71256
|
const tempDir = await downloadManager.createTempDir();
|
|
70962
71257
|
const archivePath = path10.join(tempDir, assetName);
|
|
70963
71258
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
70964
|
-
await
|
|
71259
|
+
await fs30.promises.writeFile(archivePath, buf);
|
|
70965
71260
|
const extractDir = `${tempDir}/extracted`;
|
|
70966
71261
|
logger.verbose("Extraction", { archivePath, extractDir });
|
|
70967
71262
|
await downloadManager.extractArchive(archivePath, extractDir);
|
|
@@ -71323,7 +71618,7 @@ init_logger();
|
|
|
71323
71618
|
init_safe_spinner();
|
|
71324
71619
|
init_takumi_constants();
|
|
71325
71620
|
var import_fs_extra32 = __toESM(require_lib(), 1);
|
|
71326
|
-
import { existsSync as
|
|
71621
|
+
import { existsSync as existsSync56, readdirSync as readdirSync9, rmSync as rmSync7, rmdirSync as rmdirSync2, unlinkSync as unlinkSync6 } from "node:fs";
|
|
71327
71622
|
import { dirname as dirname34, join as join117, resolve as resolve27 } from "node:path";
|
|
71328
71623
|
var TAKUMI_SUBDIRECTORIES = ["commands", "agents", "skills", "rules", "hooks"];
|
|
71329
71624
|
async function analyzeFreshInstallation(claudeDir) {
|
|
@@ -71396,7 +71691,7 @@ async function removeFilesByOwnership(claudeDir, analysis, includeModified) {
|
|
|
71396
71691
|
for (const file of filesToRemove) {
|
|
71397
71692
|
const fullPath = join117(claudeDir, file.path);
|
|
71398
71693
|
try {
|
|
71399
|
-
if (
|
|
71694
|
+
if (existsSync56(fullPath)) {
|
|
71400
71695
|
unlinkSync6(fullPath);
|
|
71401
71696
|
removedFiles.push(file.path);
|
|
71402
71697
|
logger.debug(`Removed: ${file.path}`);
|
|
@@ -73581,11 +73876,11 @@ async function initCommand(options2) {
|
|
|
73581
73876
|
}
|
|
73582
73877
|
// src/commands/plan/plan-command.ts
|
|
73583
73878
|
init_output_manager();
|
|
73584
|
-
import { existsSync as
|
|
73879
|
+
import { existsSync as existsSync61, statSync as statSync9 } from "node:fs";
|
|
73585
73880
|
import { dirname as dirname41, join as join128, parse as parse4, resolve as resolve33 } from "node:path";
|
|
73586
73881
|
|
|
73587
73882
|
// src/commands/plan/plan-read-handlers.ts
|
|
73588
|
-
import { existsSync as
|
|
73883
|
+
import { existsSync as existsSync60, statSync as statSync8 } from "node:fs";
|
|
73589
73884
|
import { basename as basename21, dirname as dirname40, join as join127, relative as relative20, resolve as resolve31 } from "node:path";
|
|
73590
73885
|
|
|
73591
73886
|
// src/domains/plan-parser/index.ts
|
|
@@ -73966,20 +74261,20 @@ function parsePlanFile(planFilePath, options2) {
|
|
|
73966
74261
|
return { frontmatter, phases };
|
|
73967
74262
|
}
|
|
73968
74263
|
// src/domains/plan-parser/plan-scanner.ts
|
|
73969
|
-
import { existsSync as
|
|
74264
|
+
import { existsSync as existsSync57, readdirSync as readdirSync10 } from "node:fs";
|
|
73970
74265
|
import { join as join125 } from "node:path";
|
|
73971
74266
|
function scanPlanDir(dir) {
|
|
73972
|
-
if (!
|
|
74267
|
+
if (!existsSync57(dir))
|
|
73973
74268
|
return [];
|
|
73974
74269
|
try {
|
|
73975
|
-
return readdirSync10(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join125(dir, entry.name, "plan.md")).filter(
|
|
74270
|
+
return readdirSync10(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join125(dir, entry.name, "plan.md")).filter(existsSync57);
|
|
73976
74271
|
} catch {
|
|
73977
74272
|
return [];
|
|
73978
74273
|
}
|
|
73979
74274
|
}
|
|
73980
74275
|
// src/domains/plan-parser/plan-validator.ts
|
|
73981
74276
|
var import_gray_matter6 = __toESM(require_gray_matter(), 1);
|
|
73982
|
-
import { existsSync as
|
|
74277
|
+
import { existsSync as existsSync58, readFileSync as readFileSync24 } from "node:fs";
|
|
73983
74278
|
import { basename as basename19, dirname as dirname37 } from "node:path";
|
|
73984
74279
|
function validatePlanFile(filePath, strict = false) {
|
|
73985
74280
|
const content = readFileSync24(filePath, "utf8");
|
|
@@ -74019,7 +74314,7 @@ function validatePlanFile(filePath, strict = false) {
|
|
|
74019
74314
|
});
|
|
74020
74315
|
}
|
|
74021
74316
|
for (const phase of phases) {
|
|
74022
|
-
if (phase.file && !
|
|
74317
|
+
if (phase.file && !existsSync58(phase.file)) {
|
|
74023
74318
|
const fileBasename = basename19(phase.file);
|
|
74024
74319
|
const refLine = lines.findIndex((l2) => l2.includes(fileBasename));
|
|
74025
74320
|
issues.push({
|
|
@@ -74040,7 +74335,7 @@ function validatePlanFile(filePath, strict = false) {
|
|
|
74040
74335
|
// src/domains/plan-parser/plan-writer.ts
|
|
74041
74336
|
var import_gray_matter7 = __toESM(require_gray_matter(), 1);
|
|
74042
74337
|
import { mkdirSync as mkdirSync9, readFileSync as readFileSync25, writeFileSync as writeFileSync12 } from "node:fs";
|
|
74043
|
-
import { existsSync as
|
|
74338
|
+
import { existsSync as existsSync59 } from "node:fs";
|
|
74044
74339
|
import { basename as basename20, dirname as dirname38, join as join126 } from "node:path";
|
|
74045
74340
|
function phaseNameToFilename(id, name) {
|
|
74046
74341
|
const numMatch = /^(\d+)([a-z]*)$/i.exec(id);
|
|
@@ -74135,9 +74430,9 @@ function resolvePhaseIds(phases) {
|
|
|
74135
74430
|
if (p2.id) {
|
|
74136
74431
|
const numMatch = /^(\d+)/.exec(p2.id);
|
|
74137
74432
|
if (numMatch) {
|
|
74138
|
-
const
|
|
74139
|
-
if (
|
|
74140
|
-
nextNum =
|
|
74433
|
+
const n2 = Number.parseInt(numMatch[1], 10);
|
|
74434
|
+
if (n2 >= nextNum)
|
|
74435
|
+
nextNum = n2 + 1;
|
|
74141
74436
|
}
|
|
74142
74437
|
return { id: p2.id, name: p2.name };
|
|
74143
74438
|
}
|
|
@@ -74222,7 +74517,7 @@ function updatePhaseStatus(planFile, phaseId, newStatus) {
|
|
|
74222
74517
|
writeFileSync12(planFile, updatedContent, "utf8");
|
|
74223
74518
|
const planDir = dirname38(planFile);
|
|
74224
74519
|
const phaseFilename = phaseNameFilenameFromTableRow(updatedBody, phaseId, planDir);
|
|
74225
|
-
if (phaseFilename &&
|
|
74520
|
+
if (phaseFilename && existsSync59(phaseFilename)) {
|
|
74226
74521
|
updatePhaseFileFrontmatter(phaseFilename, newStatus);
|
|
74227
74522
|
}
|
|
74228
74523
|
}
|
|
@@ -74262,8 +74557,8 @@ function addPhase(planFile, name, afterId) {
|
|
|
74262
74557
|
phaseId = nextSubPhaseId(afterId, existingIds);
|
|
74263
74558
|
} else {
|
|
74264
74559
|
const maxNum = existingIds.reduce((max, id) => {
|
|
74265
|
-
const
|
|
74266
|
-
return Number.isNaN(
|
|
74560
|
+
const n2 = Number.parseInt(id, 10);
|
|
74561
|
+
return Number.isNaN(n2) ? max : Math.max(max, n2);
|
|
74267
74562
|
}, 0);
|
|
74268
74563
|
phaseId = String(maxNum + 1);
|
|
74269
74564
|
}
|
|
@@ -74419,7 +74714,7 @@ async function handleValidate(target, options2) {
|
|
|
74419
74714
|
}
|
|
74420
74715
|
async function handleStatus(target, options2) {
|
|
74421
74716
|
const t = target ? resolve31(target) : null;
|
|
74422
|
-
const plansDir = t &&
|
|
74717
|
+
const plansDir = t && existsSync60(t) && statSync8(t).isDirectory() && !existsSync60(join127(t, "plan.md")) ? t : null;
|
|
74423
74718
|
if (plansDir) {
|
|
74424
74719
|
const planFiles = scanPlanDir(plansDir);
|
|
74425
74720
|
if (planFiles.length === 0) {
|
|
@@ -74650,12 +74945,12 @@ async function handleAddPhase(target, options2) {
|
|
|
74650
74945
|
// src/commands/plan/plan-command.ts
|
|
74651
74946
|
function resolvePlanFile(target) {
|
|
74652
74947
|
const t = target ? resolve33(target) : process.cwd();
|
|
74653
|
-
if (
|
|
74948
|
+
if (existsSync61(t)) {
|
|
74654
74949
|
const stat13 = statSync9(t);
|
|
74655
74950
|
if (stat13.isFile())
|
|
74656
74951
|
return t;
|
|
74657
74952
|
const candidate = join128(t, "plan.md");
|
|
74658
|
-
if (
|
|
74953
|
+
if (existsSync61(candidate))
|
|
74659
74954
|
return candidate;
|
|
74660
74955
|
}
|
|
74661
74956
|
if (!target) {
|
|
@@ -74663,7 +74958,7 @@ function resolvePlanFile(target) {
|
|
|
74663
74958
|
const root = parse4(dir).root;
|
|
74664
74959
|
while (dir !== root) {
|
|
74665
74960
|
const candidate = join128(dir, "plan.md");
|
|
74666
|
-
if (
|
|
74961
|
+
if (existsSync61(candidate))
|
|
74667
74962
|
return candidate;
|
|
74668
74963
|
dir = dirname41(dir);
|
|
74669
74964
|
}
|
|
@@ -74687,7 +74982,7 @@ function renderPhasesTable(phases) {
|
|
|
74687
74982
|
const maxId = Math.max(4, ...phases.map((p2) => p2.phaseId.length));
|
|
74688
74983
|
const maxName = Math.max(4, ...phases.map((p2) => p2.name.length));
|
|
74689
74984
|
const maxStatus = 11;
|
|
74690
|
-
const pad = (s3,
|
|
74985
|
+
const pad = (s3, n2) => s3.padEnd(n2);
|
|
74691
74986
|
const line = `${"-".repeat(maxId + 2)}+${"-".repeat(maxName + 2)}+${"-".repeat(maxStatus + 2)}`;
|
|
74692
74987
|
console.log(` ${pad("ID", maxId)} | ${pad("Name", maxName)} | Status`);
|
|
74693
74988
|
console.log(` ${line}`);
|
|
@@ -74713,7 +75008,7 @@ async function planCommand(action, target, options2) {
|
|
|
74713
75008
|
let resolvedTarget = target;
|
|
74714
75009
|
if (resolvedAction && !knownActions.has(resolvedAction)) {
|
|
74715
75010
|
const looksLikePath = resolvedAction.includes("/") || resolvedAction.includes("\\") || resolvedAction.endsWith(".md") || resolvedAction === "." || resolvedAction === "..";
|
|
74716
|
-
const existsOnDisk = !looksLikePath &&
|
|
75011
|
+
const existsOnDisk = !looksLikePath && existsSync61(resolve33(resolvedAction));
|
|
74717
75012
|
if (looksLikePath || existsOnDisk) {
|
|
74718
75013
|
resolvedTarget = resolvedAction;
|
|
74719
75014
|
resolvedAction = undefined;
|
|
@@ -74757,7 +75052,7 @@ init_logger();
|
|
|
74757
75052
|
init_logger();
|
|
74758
75053
|
|
|
74759
75054
|
// src/commands/telemetry/shared.ts
|
|
74760
|
-
import { existsSync as
|
|
75055
|
+
import { existsSync as existsSync62, readFileSync as readFileSync26, readdirSync as readdirSync11 } from "node:fs";
|
|
74761
75056
|
import { homedir as homedir29 } from "node:os";
|
|
74762
75057
|
import { join as join129 } from "node:path";
|
|
74763
75058
|
init_token_store();
|
|
@@ -74772,7 +75067,7 @@ var TELEMETRY_HOOK_FIELD = "hooks.telemetry";
|
|
|
74772
75067
|
var TOKEN_PLACEHOLDER = "__INJECT_AT_RELEASE__";
|
|
74773
75068
|
function readUserCache() {
|
|
74774
75069
|
try {
|
|
74775
|
-
if (!
|
|
75070
|
+
if (!existsSync62(USER_CACHE_PATH))
|
|
74776
75071
|
return null;
|
|
74777
75072
|
const parsed = JSON.parse(readFileSync26(USER_CACHE_PATH, "utf8"));
|
|
74778
75073
|
if (!parsed || typeof parsed !== "object")
|
|
@@ -74784,7 +75079,7 @@ function readUserCache() {
|
|
|
74784
75079
|
}
|
|
74785
75080
|
function countBufferFiles() {
|
|
74786
75081
|
try {
|
|
74787
|
-
if (!
|
|
75082
|
+
if (!existsSync62(EVENT_BUFFER_DIR))
|
|
74788
75083
|
return 0;
|
|
74789
75084
|
return readdirSync11(EVENT_BUFFER_DIR).filter((f4) => f4.endsWith(".jsonl")).length;
|
|
74790
75085
|
} catch {
|
|
@@ -74822,8 +75117,8 @@ function collectRuntimeContext() {
|
|
|
74822
75117
|
cacheSource: cache3?.source === "gh" || cache3?.source === "manual" ? cache3.source : null,
|
|
74823
75118
|
bufferFileCount: countBufferFiles(),
|
|
74824
75119
|
bufferDir: EVENT_BUFFER_DIR,
|
|
74825
|
-
rateStateExists:
|
|
74826
|
-
userCacheExists:
|
|
75120
|
+
rateStateExists: existsSync62(RATE_STATE_PATH),
|
|
75121
|
+
userCacheExists: existsSync62(USER_CACHE_PATH),
|
|
74827
75122
|
endpoint,
|
|
74828
75123
|
tokenConfigured: Boolean(token)
|
|
74829
75124
|
};
|
|
@@ -74984,13 +75279,13 @@ init_logger();
|
|
|
74984
75279
|
init_safe_prompts();
|
|
74985
75280
|
init_takumi_constants();
|
|
74986
75281
|
var import_picocolors27 = __toESM(require_picocolors(), 1);
|
|
74987
|
-
import { existsSync as
|
|
75282
|
+
import { existsSync as existsSync63, readdirSync as readdirSync12, rmSync as rmSync8 } from "node:fs";
|
|
74988
75283
|
import { dirname as dirname42, join as join130 } from "node:path";
|
|
74989
75284
|
function listPresentManifestNames(installPath) {
|
|
74990
75285
|
const present = [];
|
|
74991
|
-
if (
|
|
75286
|
+
if (existsSync63(getManifestPath(installPath)))
|
|
74992
75287
|
present.push(MANIFEST_FILENAME);
|
|
74993
|
-
if (
|
|
75288
|
+
if (existsSync63(getLegacyManifestPath(installPath)))
|
|
74994
75289
|
present.push(LEGACY_MANIFEST_FILENAME);
|
|
74995
75290
|
return present;
|
|
74996
75291
|
}
|
|
@@ -75944,13 +76239,13 @@ function registerCommands(cli) {
|
|
|
75944
76239
|
cli.command("console", "Start local bridge and open session console in browser").option("--port <port>", "Bridge port (default: 8765, auto-bump on conflict)").option("--no-open", "Don't open the browser; print URL only").action(async (options2) => {
|
|
75945
76240
|
let port;
|
|
75946
76241
|
if (options2.port !== undefined) {
|
|
75947
|
-
const
|
|
75948
|
-
if (!Number.isInteger(
|
|
76242
|
+
const n2 = Number(options2.port);
|
|
76243
|
+
if (!Number.isInteger(n2) || n2 < 0 || n2 > 65535) {
|
|
75949
76244
|
console.error(`Invalid --port value: ${options2.port}. Expected integer 0-65535.`);
|
|
75950
76245
|
process.exitCode = 1;
|
|
75951
76246
|
return;
|
|
75952
76247
|
}
|
|
75953
|
-
port =
|
|
76248
|
+
port = n2;
|
|
75954
76249
|
}
|
|
75955
76250
|
await consoleCommand({ port, noOpen: options2.open === false });
|
|
75956
76251
|
});
|