@sunasteriskrnd/takumi 1.0.0-dev.54 → 1.0.0-dev.56
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 +122 -83
- 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.56",
|
|
19819
19819
|
description: "CLI tool for bootstrapping and managing Takumi projects",
|
|
19820
19820
|
type: "module",
|
|
19821
19821
|
repository: {
|
|
@@ -20011,7 +20011,7 @@ function getLegacyManifestPath(providerRoot) {
|
|
|
20011
20011
|
return join4(providerRoot, LEGACY_MANIFEST_FILENAME);
|
|
20012
20012
|
}
|
|
20013
20013
|
function getCliVersion() {
|
|
20014
|
-
return "1.0.0-dev.
|
|
20014
|
+
return "1.0.0-dev.56"?.trim() || process.env.npm_package_version?.trim() || "unknown";
|
|
20015
20015
|
}
|
|
20016
20016
|
function getCliUserAgent() {
|
|
20017
20017
|
return `${TAKUMI_CLI_NPM_PACKAGE_NAME}/${getCliVersion()}`;
|
|
@@ -50589,23 +50589,23 @@ import {
|
|
|
50589
50589
|
closeSync as closeSync5,
|
|
50590
50590
|
constants as fsConstants3,
|
|
50591
50591
|
fstatSync,
|
|
50592
|
-
mkdirSync as
|
|
50593
|
-
openSync as
|
|
50592
|
+
mkdirSync as mkdirSync4,
|
|
50593
|
+
openSync as openSync6,
|
|
50594
50594
|
readSync as readSync5,
|
|
50595
50595
|
renameSync as renameSync3,
|
|
50596
50596
|
rmSync as rmSync4,
|
|
50597
50597
|
writeFileSync as writeFileSync9
|
|
50598
50598
|
} from "node:fs";
|
|
50599
|
-
import { join as
|
|
50599
|
+
import { join as join103 } from "node:path";
|
|
50600
50600
|
function getStatuslineCacheDir() {
|
|
50601
|
-
return
|
|
50601
|
+
return join103(getConfigDir(), "cache", "statusline");
|
|
50602
50602
|
}
|
|
50603
50603
|
function getStatuslineCachePath(fileName) {
|
|
50604
|
-
return
|
|
50604
|
+
return join103(getStatuslineCacheDir(), fileName);
|
|
50605
50605
|
}
|
|
50606
50606
|
function ensureStatuslineCacheDir() {
|
|
50607
50607
|
try {
|
|
50608
|
-
|
|
50608
|
+
mkdirSync4(getStatuslineCacheDir(), { recursive: true, mode: 448 });
|
|
50609
50609
|
return true;
|
|
50610
50610
|
} catch {
|
|
50611
50611
|
return false;
|
|
@@ -50614,7 +50614,7 @@ function ensureStatuslineCacheDir() {
|
|
|
50614
50614
|
function readCacheFileSafe(path10) {
|
|
50615
50615
|
let fd;
|
|
50616
50616
|
try {
|
|
50617
|
-
fd =
|
|
50617
|
+
fd = openSync6(path10, fsConstants3.O_RDONLY | fsConstants3.O_NOFOLLOW);
|
|
50618
50618
|
const stat8 = fstatSync(fd);
|
|
50619
50619
|
if (!stat8.isFile())
|
|
50620
50620
|
return null;
|
|
@@ -50627,10 +50627,10 @@ function readCacheFileSafe(path10) {
|
|
|
50627
50627
|
const buf = Buffer.allocUnsafe(size);
|
|
50628
50628
|
let read = 0;
|
|
50629
50629
|
while (read < size) {
|
|
50630
|
-
const
|
|
50631
|
-
if (
|
|
50630
|
+
const n = readSync5(fd, buf, read, size - read, read);
|
|
50631
|
+
if (n <= 0)
|
|
50632
50632
|
break;
|
|
50633
|
-
read +=
|
|
50633
|
+
read += n;
|
|
50634
50634
|
}
|
|
50635
50635
|
return buf.toString("utf8", 0, read);
|
|
50636
50636
|
} catch {
|
|
@@ -50664,10 +50664,10 @@ var init_cache_dir = __esm(() => {
|
|
|
50664
50664
|
});
|
|
50665
50665
|
|
|
50666
50666
|
// src/domains/hooks/handlers/usage-cache/usage-credential.ts
|
|
50667
|
-
import { execFileSync as
|
|
50668
|
-
import { closeSync as closeSync6, constants as fsConstants4, fstatSync as fstatSync2, openSync as
|
|
50669
|
-
import { homedir as
|
|
50670
|
-
import { join as
|
|
50667
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
50668
|
+
import { closeSync as closeSync6, constants as fsConstants4, fstatSync as fstatSync2, openSync as openSync7, readFileSync as readFileSync15 } from "node:fs";
|
|
50669
|
+
import { homedir as homedir28, platform as platform8 } from "node:os";
|
|
50670
|
+
import { join as join104 } from "node:path";
|
|
50671
50671
|
function hasAnthropicRuntimeOverride(env2 = process.env) {
|
|
50672
50672
|
return OVERRIDE_ENV_KEYS.some((key) => {
|
|
50673
50673
|
const value = env2[key];
|
|
@@ -50696,7 +50696,7 @@ function parseOAuth(raw) {
|
|
|
50696
50696
|
function readTrustedFile(path10) {
|
|
50697
50697
|
let fd;
|
|
50698
50698
|
try {
|
|
50699
|
-
fd =
|
|
50699
|
+
fd = openSync7(path10, fsConstants4.O_RDONLY | fsConstants4.O_NOFOLLOW);
|
|
50700
50700
|
const stat8 = fstatSync2(fd);
|
|
50701
50701
|
if (!stat8.isFile())
|
|
50702
50702
|
return null;
|
|
@@ -50705,7 +50705,7 @@ function readTrustedFile(path10) {
|
|
|
50705
50705
|
return null;
|
|
50706
50706
|
if ((stat8.mode & 18) !== 0)
|
|
50707
50707
|
return null;
|
|
50708
|
-
return
|
|
50708
|
+
return readFileSync15(fd, "utf8");
|
|
50709
50709
|
} catch {
|
|
50710
50710
|
return null;
|
|
50711
50711
|
} finally {
|
|
@@ -50717,7 +50717,7 @@ function readTrustedFile(path10) {
|
|
|
50717
50717
|
}
|
|
50718
50718
|
}
|
|
50719
50719
|
function fromCredentialsFile() {
|
|
50720
|
-
const raw = readTrustedFile(
|
|
50720
|
+
const raw = readTrustedFile(join104(homedir28(), ".claude", ".credentials.json"));
|
|
50721
50721
|
if (!raw)
|
|
50722
50722
|
return null;
|
|
50723
50723
|
try {
|
|
@@ -50727,10 +50727,10 @@ function fromCredentialsFile() {
|
|
|
50727
50727
|
}
|
|
50728
50728
|
}
|
|
50729
50729
|
function fromKeychain() {
|
|
50730
|
-
if (
|
|
50730
|
+
if (platform8() !== "darwin")
|
|
50731
50731
|
return null;
|
|
50732
50732
|
try {
|
|
50733
|
-
const out =
|
|
50733
|
+
const out = execFileSync2("security", ["find-generic-password", "-s", KEYCHAIN_SERVICE, "-w"], {
|
|
50734
50734
|
timeout: 5000,
|
|
50735
50735
|
encoding: "utf8",
|
|
50736
50736
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -72743,6 +72743,42 @@ function decodeJobArgv(argv) {
|
|
|
72743
72743
|
}
|
|
72744
72744
|
}
|
|
72745
72745
|
|
|
72746
|
+
// src/domains/hooks/telemetry/lib/quota-snapshot.ts
|
|
72747
|
+
init_usage_limits_cache();
|
|
72748
|
+
function isoFromDateLike(raw) {
|
|
72749
|
+
if (typeof raw !== "string")
|
|
72750
|
+
return null;
|
|
72751
|
+
const ms = Date.parse(raw);
|
|
72752
|
+
return Number.isFinite(ms) ? new Date(ms).toISOString() : null;
|
|
72753
|
+
}
|
|
72754
|
+
function isoFromEpochMs(ms) {
|
|
72755
|
+
if (typeof ms !== "number" || !Number.isFinite(ms))
|
|
72756
|
+
return null;
|
|
72757
|
+
return new Date(ms).toISOString();
|
|
72758
|
+
}
|
|
72759
|
+
function toQuotaSnapshot(cache3) {
|
|
72760
|
+
if (!cache3 || cache3.status !== "available")
|
|
72761
|
+
return null;
|
|
72762
|
+
const weeklyPct = cache3.snapshot?.weekPercent;
|
|
72763
|
+
if (typeof weeklyPct !== "number" || !Number.isFinite(weeklyPct) || weeklyPct < 0) {
|
|
72764
|
+
return null;
|
|
72765
|
+
}
|
|
72766
|
+
const resetsAt = isoFromDateLike(cache3.data?.seven_day?.resets_at);
|
|
72767
|
+
if (!resetsAt)
|
|
72768
|
+
return null;
|
|
72769
|
+
const capturedAt = isoFromDateLike(cache3.snapshot?.fetchedAt) ?? isoFromEpochMs(cache3.timestamp);
|
|
72770
|
+
if (!capturedAt)
|
|
72771
|
+
return null;
|
|
72772
|
+
return { weekly_pct: weeklyPct, resets_at: resetsAt, captured_at: capturedAt };
|
|
72773
|
+
}
|
|
72774
|
+
function readQuotaSnapshot() {
|
|
72775
|
+
try {
|
|
72776
|
+
return toQuotaSnapshot(readUsageCache());
|
|
72777
|
+
} catch {
|
|
72778
|
+
return null;
|
|
72779
|
+
}
|
|
72780
|
+
}
|
|
72781
|
+
|
|
72746
72782
|
// src/domains/hooks/telemetry/lib/session-lifecycle.ts
|
|
72747
72783
|
function elapsedSeconds(sinceIso, nowIso) {
|
|
72748
72784
|
if (!sinceIso)
|
|
@@ -72819,6 +72855,7 @@ function buildSessionPayload(args) {
|
|
|
72819
72855
|
...summary.turn_count !== undefined ? { turn_count: summary.turn_count } : {},
|
|
72820
72856
|
...summary.api_error_count !== undefined ? { api_error_count: summary.api_error_count } : {},
|
|
72821
72857
|
...summary.agent_busy_time_s !== undefined ? { agent_busy_time_s: Math.round(summary.agent_busy_time_s) } : {},
|
|
72858
|
+
...args.quota ? { quota: args.quota } : {},
|
|
72822
72859
|
summary_generated_at: new Date().toISOString()
|
|
72823
72860
|
}
|
|
72824
72861
|
};
|
|
@@ -72923,8 +72960,8 @@ async function runSessionEndFlush(data, ctx) {
|
|
|
72923
72960
|
session_end_raw: data
|
|
72924
72961
|
};
|
|
72925
72962
|
const { promises: fs25 } = await import("node:fs");
|
|
72926
|
-
const { join:
|
|
72927
|
-
const target =
|
|
72963
|
+
const { join: join105 } = await import("node:path");
|
|
72964
|
+
const target = join105(sessionDir, "meta.json");
|
|
72928
72965
|
const tmp = `${target}.tmp`;
|
|
72929
72966
|
await fs25.writeFile(tmp, JSON.stringify(updated), "utf8");
|
|
72930
72967
|
await fs25.rename(tmp, target);
|
|
@@ -72952,7 +72989,8 @@ async function runSessionEndFlush(data, ctx) {
|
|
|
72952
72989
|
cliVersion: readCliVersion(),
|
|
72953
72990
|
kitVersions: manifest.kitVersions,
|
|
72954
72991
|
milestone: null,
|
|
72955
|
-
errorCount: 0
|
|
72992
|
+
errorCount: 0,
|
|
72993
|
+
quota: readQuotaSnapshot()
|
|
72956
72994
|
});
|
|
72957
72995
|
const url = `${endpoint.url}/api/v1/telemetry/sessions/${sessionId}`;
|
|
72958
72996
|
const mode = effectiveDetachMode(flags);
|
|
@@ -73108,7 +73146,7 @@ async function applyCodexTranscriptDelta(args) {
|
|
|
73108
73146
|
}
|
|
73109
73147
|
|
|
73110
73148
|
// src/domains/hooks/lib/jsonl-append.ts
|
|
73111
|
-
import { promises as fs26, appendFileSync as appendFileSync2, mkdirSync as
|
|
73149
|
+
import { promises as fs26, appendFileSync as appendFileSync2, mkdirSync as mkdirSync5 } from "node:fs";
|
|
73112
73150
|
import { dirname as dirname28 } from "node:path";
|
|
73113
73151
|
async function appendJsonl(filePath, record) {
|
|
73114
73152
|
try {
|
|
@@ -73119,7 +73157,7 @@ async function appendJsonl(filePath, record) {
|
|
|
73119
73157
|
}
|
|
73120
73158
|
function appendJsonlLineSync(filePath, line) {
|
|
73121
73159
|
try {
|
|
73122
|
-
|
|
73160
|
+
mkdirSync5(dirname28(filePath), { recursive: true });
|
|
73123
73161
|
appendFileSync2(filePath, `${line}
|
|
73124
73162
|
`, "utf8");
|
|
73125
73163
|
} catch {}
|
|
@@ -73350,7 +73388,8 @@ async function runStopFlush(data, ctx) {
|
|
|
73350
73388
|
cliVersion,
|
|
73351
73389
|
kitVersions: manifest.kitVersions,
|
|
73352
73390
|
milestone,
|
|
73353
|
-
errorCount
|
|
73391
|
+
errorCount,
|
|
73392
|
+
quota: readQuotaSnapshot()
|
|
73354
73393
|
});
|
|
73355
73394
|
const url = `${endpoint.url}/api/v1/telemetry/sessions/${sessionId}`;
|
|
73356
73395
|
const mode = effectiveDetachMode(flags);
|
|
@@ -73409,12 +73448,12 @@ async function handleStop(agent, flags = {}) {
|
|
|
73409
73448
|
|
|
73410
73449
|
// src/domains/hooks/telemetry/otlp/observations-export.ts
|
|
73411
73450
|
init_paths2();
|
|
73412
|
-
import { promises as fs30, openSync as
|
|
73413
|
-
import { join as
|
|
73451
|
+
import { promises as fs30, openSync as openSync9 } from "node:fs";
|
|
73452
|
+
import { join as join106 } from "node:path";
|
|
73414
73453
|
|
|
73415
73454
|
// src/domains/hooks/telemetry/lib/retention.ts
|
|
73416
73455
|
import { promises as fs27 } from "node:fs";
|
|
73417
|
-
import { join as
|
|
73456
|
+
import { join as join105 } from "node:path";
|
|
73418
73457
|
async function pathExists25(path10) {
|
|
73419
73458
|
try {
|
|
73420
73459
|
await fs27.access(path10);
|
|
@@ -73449,7 +73488,7 @@ async function decideDelete(dir, args) {
|
|
|
73449
73488
|
async function listChildren(dir) {
|
|
73450
73489
|
try {
|
|
73451
73490
|
const names = await fs27.readdir(dir);
|
|
73452
|
-
return names.map((n2) =>
|
|
73491
|
+
return names.map((n2) => join105(dir, n2));
|
|
73453
73492
|
} catch {
|
|
73454
73493
|
return [];
|
|
73455
73494
|
}
|
|
@@ -73460,7 +73499,7 @@ async function collectV2Sessions() {
|
|
|
73460
73499
|
const sessions = [];
|
|
73461
73500
|
for (const projectDir of projects) {
|
|
73462
73501
|
for (const agentDir of await listChildren(projectDir)) {
|
|
73463
|
-
for (const sessionDir of await listChildren(
|
|
73502
|
+
for (const sessionDir of await listChildren(join105(agentDir, "sessions"))) {
|
|
73464
73503
|
sessions.push(sessionDir);
|
|
73465
73504
|
}
|
|
73466
73505
|
}
|
|
@@ -73565,7 +73604,7 @@ async function resolveOtlpConfig() {
|
|
|
73565
73604
|
|
|
73566
73605
|
// src/domains/hooks/telemetry/otlp/otlp-post.ts
|
|
73567
73606
|
import { spawn as spawn3 } from "node:child_process";
|
|
73568
|
-
import { promises as fs29, openSync as
|
|
73607
|
+
import { promises as fs29, openSync as openSync8 } from "node:fs";
|
|
73569
73608
|
|
|
73570
73609
|
// src/domains/hooks/telemetry/otlp/otlp-payload-builder.ts
|
|
73571
73610
|
import { createHash as createHash13 } from "node:crypto";
|
|
@@ -73808,7 +73847,7 @@ function postOtlpDetached(job) {
|
|
|
73808
73847
|
let stdio = "ignore";
|
|
73809
73848
|
if (job.debug) {
|
|
73810
73849
|
try {
|
|
73811
|
-
const fd =
|
|
73850
|
+
const fd = openSync8(sessionDebugLogPath(job.sessionDir), "a");
|
|
73812
73851
|
stdio = ["ignore", fd, fd];
|
|
73813
73852
|
} catch {
|
|
73814
73853
|
stdio = "ignore";
|
|
@@ -73889,7 +73928,7 @@ async function exportSessionObservations(sessionDir, opts = {}, deps = {}) {
|
|
|
73889
73928
|
}
|
|
73890
73929
|
}
|
|
73891
73930
|
function lockPath() {
|
|
73892
|
-
return
|
|
73931
|
+
return join106(getConfigDir(), "obs-flush.lock");
|
|
73893
73932
|
}
|
|
73894
73933
|
async function acquireSweepLock(now) {
|
|
73895
73934
|
const path10 = lockPath();
|
|
@@ -73899,14 +73938,14 @@ async function acquireSweepLock(now) {
|
|
|
73899
73938
|
return false;
|
|
73900
73939
|
}
|
|
73901
73940
|
try {
|
|
73902
|
-
|
|
73941
|
+
openSync9(path10, "wx");
|
|
73903
73942
|
return true;
|
|
73904
73943
|
} catch {
|
|
73905
73944
|
try {
|
|
73906
73945
|
const stat8 = await fs30.stat(path10);
|
|
73907
73946
|
if (now - stat8.mtimeMs > STALE_LOCK_MS) {
|
|
73908
73947
|
await fs30.rm(path10, { force: true });
|
|
73909
|
-
|
|
73948
|
+
openSync9(path10, "wx");
|
|
73910
73949
|
return true;
|
|
73911
73950
|
}
|
|
73912
73951
|
} catch {}
|
|
@@ -74528,7 +74567,7 @@ var metricsRecord = {
|
|
|
74528
74567
|
|
|
74529
74568
|
// src/domains/statusline/activity-cache.ts
|
|
74530
74569
|
import { readdirSync as readdirSync8, rmSync as rmSync5, statSync as statSync8 } from "node:fs";
|
|
74531
|
-
import { join as
|
|
74570
|
+
import { join as join107 } from "node:path";
|
|
74532
74571
|
|
|
74533
74572
|
// src/domains/statusline/activity-snapshot.ts
|
|
74534
74573
|
import { existsSync as existsSync51 } from "node:fs";
|
|
@@ -74988,7 +75027,7 @@ function cleanupStaleActivity(now = Date.now()) {
|
|
|
74988
75027
|
for (const entry of entries) {
|
|
74989
75028
|
if (!entry.startsWith(FILE_PREFIX) || !entry.endsWith(FILE_SUFFIX))
|
|
74990
75029
|
continue;
|
|
74991
|
-
const full =
|
|
75030
|
+
const full = join107(getStatuslineCacheDir(), entry);
|
|
74992
75031
|
try {
|
|
74993
75032
|
if (now - statSync8(full).mtimeMs > ACTIVITY_TTL_MS)
|
|
74994
75033
|
rmSync5(full, { force: true });
|
|
@@ -75053,11 +75092,11 @@ var sessionActivity = {
|
|
|
75053
75092
|
|
|
75054
75093
|
// src/domains/hooks/handlers/session-init/handler.ts
|
|
75055
75094
|
import { mkdirSync as mkdirSync6 } from "node:fs";
|
|
75056
|
-
import { dirname as dirname29, join as
|
|
75095
|
+
import { dirname as dirname29, join as join111 } from "node:path";
|
|
75057
75096
|
|
|
75058
75097
|
// src/domains/hooks/handlers/_shared/project-detector.ts
|
|
75059
|
-
import { existsSync as existsSync52, readFileSync as
|
|
75060
|
-
import { join as
|
|
75098
|
+
import { existsSync as existsSync52, readFileSync as readFileSync16 } from "node:fs";
|
|
75099
|
+
import { join as join108 } from "node:path";
|
|
75061
75100
|
var LOCKFILE_PRIORITY = [
|
|
75062
75101
|
{ manager: "bun", files: ["bun.lockb", "bun.lock"] },
|
|
75063
75102
|
{ manager: "pnpm", files: ["pnpm-lock.yaml"] },
|
|
@@ -75092,14 +75131,14 @@ var APP_FRAMEWORKS = new Set([
|
|
|
75092
75131
|
var WORKSPACE_MARKER_FILES = ["pnpm-workspace.yaml", "turbo.json", "lerna.json"];
|
|
75093
75132
|
function fileExists(cwd2, name2) {
|
|
75094
75133
|
try {
|
|
75095
|
-
return existsSync52(
|
|
75134
|
+
return existsSync52(join108(cwd2, name2));
|
|
75096
75135
|
} catch {
|
|
75097
75136
|
return false;
|
|
75098
75137
|
}
|
|
75099
75138
|
}
|
|
75100
75139
|
function readPackageJson(cwd2) {
|
|
75101
75140
|
try {
|
|
75102
|
-
const raw =
|
|
75141
|
+
const raw = readFileSync16(join108(cwd2, "package.json"), "utf8");
|
|
75103
75142
|
const parsed = JSON.parse(raw);
|
|
75104
75143
|
if (parsed && typeof parsed === "object")
|
|
75105
75144
|
return parsed;
|
|
@@ -75182,12 +75221,12 @@ function detectProject(cwd2) {
|
|
|
75182
75221
|
|
|
75183
75222
|
// src/domains/hooks/handlers/session-init/env-entries.ts
|
|
75184
75223
|
import { createHash as createHash14 } from "node:crypto";
|
|
75185
|
-
import { platform as
|
|
75186
|
-
import { join as
|
|
75224
|
+
import { platform as platform9, userInfo } from "node:os";
|
|
75225
|
+
import { join as join110 } from "node:path";
|
|
75187
75226
|
|
|
75188
75227
|
// src/domains/hooks/handlers/session-init/plan-resolver.ts
|
|
75189
|
-
import { existsSync as existsSync53, readFileSync as
|
|
75190
|
-
import { join as
|
|
75228
|
+
import { existsSync as existsSync53, readFileSync as readFileSync17, readdirSync as readdirSync9 } from "node:fs";
|
|
75229
|
+
import { join as join109 } from "node:path";
|
|
75191
75230
|
var MAX_PLAN_DIRS = 100;
|
|
75192
75231
|
var MAX_PLAN_FILE_BYTES = 64 * 1024;
|
|
75193
75232
|
function listPlanDirs(plansPath) {
|
|
@@ -75201,10 +75240,10 @@ function listPlanDirs(plansPath) {
|
|
|
75201
75240
|
}
|
|
75202
75241
|
function planFileMentionsSession(planDir, sessionId) {
|
|
75203
75242
|
try {
|
|
75204
|
-
const planFile =
|
|
75243
|
+
const planFile = join109(planDir, "plan.md");
|
|
75205
75244
|
if (!existsSync53(planFile))
|
|
75206
75245
|
return false;
|
|
75207
|
-
const body =
|
|
75246
|
+
const body = readFileSync17(planFile, { encoding: "utf8" });
|
|
75208
75247
|
if (body.length > MAX_PLAN_FILE_BYTES)
|
|
75209
75248
|
return false;
|
|
75210
75249
|
return body.includes(sessionId);
|
|
@@ -75216,7 +75255,7 @@ function resolveActivePlan(plansPath, sessionId) {
|
|
|
75216
75255
|
if (!sessionId)
|
|
75217
75256
|
return "";
|
|
75218
75257
|
for (const name2 of listPlanDirs(plansPath)) {
|
|
75219
|
-
const dir =
|
|
75258
|
+
const dir = join109(plansPath, name2);
|
|
75220
75259
|
if (name2.includes(sessionId) || planFileMentionsSession(dir, sessionId)) {
|
|
75221
75260
|
return dir;
|
|
75222
75261
|
}
|
|
@@ -75237,7 +75276,7 @@ function resolveSuggestedPlan(plansPath, branch, branchPattern) {
|
|
|
75237
75276
|
return "";
|
|
75238
75277
|
for (const name2 of listPlanDirs(plansPath)) {
|
|
75239
75278
|
if (name2.includes(slug))
|
|
75240
|
-
return
|
|
75279
|
+
return join109(plansPath, name2);
|
|
75241
75280
|
}
|
|
75242
75281
|
return "";
|
|
75243
75282
|
}
|
|
@@ -75291,18 +75330,18 @@ function buildEnvEntries(params) {
|
|
|
75291
75330
|
const plan = config.plan ?? {};
|
|
75292
75331
|
const locale = config.locale ?? {};
|
|
75293
75332
|
const validation = plan.validation ?? {};
|
|
75294
|
-
const settingsDir =
|
|
75295
|
-
const docsPath =
|
|
75296
|
-
const plansPath =
|
|
75333
|
+
const settingsDir = join110(projectRoot, ".claude");
|
|
75334
|
+
const docsPath = join110(projectRoot, paths.docs ?? "docs");
|
|
75335
|
+
const plansPath = join110(projectRoot, paths.plans ?? "plans");
|
|
75297
75336
|
const reportsDir = plan.reportsDir ?? "reports";
|
|
75298
|
-
const reportsPath =
|
|
75337
|
+
const reportsPath = join110(plansPath, reportsDir);
|
|
75299
75338
|
const namingFormat = plan.namingFormat ?? "";
|
|
75300
75339
|
const activePlan = resolveActivePlan(plansPath, ctx.sessionId);
|
|
75301
75340
|
const suggestedPlan = resolveSuggestedPlan(plansPath, branch, plan.resolution?.branchPattern ?? "");
|
|
75302
75341
|
return {
|
|
75303
75342
|
TKM_SESSION_ID: ctx.sessionId ?? "",
|
|
75304
75343
|
TKM_USER: resolveUser(),
|
|
75305
|
-
TKM_OS_PLATFORM:
|
|
75344
|
+
TKM_OS_PLATFORM: platform9(),
|
|
75306
75345
|
TKM_NODE_VERSION: process.versions.node ?? "",
|
|
75307
75346
|
TKM_TIMEZONE: resolveTimezone(),
|
|
75308
75347
|
TKM_LOCALE: process.env.LANG || process.env.LC_ALL || "",
|
|
@@ -75342,12 +75381,12 @@ function numberString(value) {
|
|
|
75342
75381
|
}
|
|
75343
75382
|
|
|
75344
75383
|
// src/domains/hooks/handlers/session-init/git-facts.ts
|
|
75345
|
-
import { execFileSync as
|
|
75384
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
75346
75385
|
var GIT_TIMEOUT_MS = 800;
|
|
75347
75386
|
var GIT_STATUS_TIMEOUT_MS = 500;
|
|
75348
75387
|
function runGit(cwd2, args, timeoutMs = GIT_TIMEOUT_MS) {
|
|
75349
75388
|
try {
|
|
75350
|
-
const out =
|
|
75389
|
+
const out = execFileSync3("git", ["-C", cwd2, ...args], {
|
|
75351
75390
|
encoding: "utf8",
|
|
75352
75391
|
timeout: timeoutMs,
|
|
75353
75392
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -75384,7 +75423,7 @@ function resolveEnvFilePath(settingsDir) {
|
|
|
75384
75423
|
const override = process.env.CLAUDE_ENV_FILE;
|
|
75385
75424
|
if (override && override.trim().length > 0)
|
|
75386
75425
|
return override;
|
|
75387
|
-
return
|
|
75426
|
+
return join111(settingsDir, DEFAULT_ENV_FILE);
|
|
75388
75427
|
}
|
|
75389
75428
|
function persistEntries(envFilePath, entries) {
|
|
75390
75429
|
try {
|
|
@@ -75437,16 +75476,16 @@ var sessionInit = {
|
|
|
75437
75476
|
};
|
|
75438
75477
|
|
|
75439
75478
|
// src/domains/hooks/handlers/_shared/context-assembler.ts
|
|
75440
|
-
import { execFileSync as
|
|
75479
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
75441
75480
|
import { createHash as createHash15 } from "node:crypto";
|
|
75442
|
-
import { existsSync as existsSync54, mkdirSync as mkdirSync7, readFileSync as
|
|
75443
|
-
import { homedir as
|
|
75444
|
-
import { basename as basename18, join as
|
|
75481
|
+
import { existsSync as existsSync54, mkdirSync as mkdirSync7, readFileSync as readFileSync18, rmSync as rmSync6, statSync as statSync9, writeFileSync as writeFileSync10 } from "node:fs";
|
|
75482
|
+
import { homedir as homedir29, platform as platform10, tmpdir as tmpdir4 } from "node:os";
|
|
75483
|
+
import { basename as basename18, join as join112, resolve as resolve24 } from "node:path";
|
|
75445
75484
|
var INJECTED_TTL_MS = 12 * 60 * 60 * 1000;
|
|
75446
75485
|
var RESERVATION_TTL_MS = 60 * 1000;
|
|
75447
75486
|
function gitBranch(dir) {
|
|
75448
75487
|
try {
|
|
75449
|
-
const out =
|
|
75488
|
+
const out = execFileSync4("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
75450
75489
|
cwd: dir,
|
|
75451
75490
|
timeout: 500,
|
|
75452
75491
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -75518,18 +75557,18 @@ function scopeKey(baseDir) {
|
|
|
75518
75557
|
return `${slug}-${hash}`;
|
|
75519
75558
|
}
|
|
75520
75559
|
function stateDir() {
|
|
75521
|
-
return
|
|
75560
|
+
return join112(tmpdir4(), "takumi-context-throttle");
|
|
75522
75561
|
}
|
|
75523
75562
|
function stateFile(sessionId, scope, transcriptPath) {
|
|
75524
75563
|
const key = `${sessionId}\x00${scope}\x00${transcriptPath ?? ""}`;
|
|
75525
75564
|
const hash = createHash15("sha256").update(key).digest("hex").slice(0, 32);
|
|
75526
|
-
return
|
|
75565
|
+
return join112(stateDir(), `${hash}.json`);
|
|
75527
75566
|
}
|
|
75528
75567
|
function readState(file) {
|
|
75529
75568
|
try {
|
|
75530
75569
|
if (!existsSync54(file))
|
|
75531
75570
|
return null;
|
|
75532
|
-
return JSON.parse(
|
|
75571
|
+
return JSON.parse(readFileSync18(file, "utf8"));
|
|
75533
75572
|
} catch {
|
|
75534
75573
|
return null;
|
|
75535
75574
|
}
|
|
@@ -75592,8 +75631,8 @@ function clearPending(sessionId, scope, transcriptPath) {
|
|
|
75592
75631
|
} catch {}
|
|
75593
75632
|
}
|
|
75594
75633
|
function resolveSkillsVenv(_cwd) {
|
|
75595
|
-
const base =
|
|
75596
|
-
const interpreter =
|
|
75634
|
+
const base = join112(homedir29(), ".claude", "skills", ".venv");
|
|
75635
|
+
const interpreter = platform10() === "win32" ? join112(base, "Scripts", "python.exe") : join112(base, "bin", "python3");
|
|
75597
75636
|
return existsSync54(interpreter) ? interpreter : null;
|
|
75598
75637
|
}
|
|
75599
75638
|
|
|
@@ -75632,18 +75671,18 @@ var sessionPromptContext = {
|
|
|
75632
75671
|
};
|
|
75633
75672
|
|
|
75634
75673
|
// src/domains/hooks/handlers/session-subagent-init/context-block.ts
|
|
75635
|
-
import { join as
|
|
75674
|
+
import { join as join114 } from "node:path";
|
|
75636
75675
|
|
|
75637
75676
|
// src/domains/hooks/handlers/session-subagent-init/context-sources.ts
|
|
75638
|
-
import { execFileSync as
|
|
75677
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
75639
75678
|
import { readdirSync as readdirSync10, statSync as statSync10 } from "node:fs";
|
|
75640
|
-
import { isAbsolute as isAbsolute5, join as
|
|
75679
|
+
import { isAbsolute as isAbsolute5, join as join113, resolve as resolve25 } from "node:path";
|
|
75641
75680
|
var MAX_DOCS_FILES = 15;
|
|
75642
75681
|
var MAX_DOCS_SUBDIRS = 5;
|
|
75643
75682
|
function gitFacts(dir) {
|
|
75644
75683
|
const run2 = (args) => {
|
|
75645
75684
|
try {
|
|
75646
|
-
const out =
|
|
75685
|
+
const out = execFileSync5("git", args, {
|
|
75647
75686
|
cwd: dir,
|
|
75648
75687
|
timeout: 500,
|
|
75649
75688
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -75674,11 +75713,11 @@ function detectPlan(plansAbs) {
|
|
|
75674
75713
|
for (const e2 of entries) {
|
|
75675
75714
|
if (!e2.isDirectory())
|
|
75676
75715
|
continue;
|
|
75677
|
-
const dir =
|
|
75716
|
+
const dir = join113(plansAbs, e2.name);
|
|
75678
75717
|
try {
|
|
75679
75718
|
if (!readdirSync10(dir).includes("plan.md"))
|
|
75680
75719
|
continue;
|
|
75681
|
-
const mtime = statSync10(
|
|
75720
|
+
const mtime = statSync10(join113(dir, "plan.md")).mtimeMs;
|
|
75682
75721
|
if (!best || mtime > best.mtime)
|
|
75683
75722
|
best = { name: e2.name, mtime };
|
|
75684
75723
|
} catch {}
|
|
@@ -75701,7 +75740,7 @@ function docsCatalogue(docsAbs) {
|
|
|
75701
75740
|
for (const d3 of subdirs.slice(0, MAX_DOCS_SUBDIRS)) {
|
|
75702
75741
|
let count = 0;
|
|
75703
75742
|
try {
|
|
75704
|
-
count = readdirSync10(
|
|
75743
|
+
count = readdirSync10(join113(docsAbs, d3)).length;
|
|
75705
75744
|
} catch {}
|
|
75706
75745
|
lines.push(`- ${d3}/ (${count} entries)`);
|
|
75707
75746
|
}
|
|
@@ -75745,11 +75784,11 @@ function buildSubagentContext(input, ctx) {
|
|
|
75745
75784
|
const agentId = strField(input, "agent_id") || "unknown";
|
|
75746
75785
|
const plansAbs = abs(base, cfg.paths?.plans?.trim() || "plans");
|
|
75747
75786
|
const docsAbs = abs(base, cfg.paths?.docs?.trim() || "docs");
|
|
75748
|
-
const reportsAbs =
|
|
75787
|
+
const reportsAbs = join114(plansAbs, cfg.plan?.reportsDir?.trim() || "reports");
|
|
75749
75788
|
const dateStr = stamp(cfg.plan?.dateFormat?.trim() || "YYMMDD-HHmm", new Date);
|
|
75750
75789
|
const namingFormat = cfg.plan?.namingFormat?.trim() || "{date}-{slug}";
|
|
75751
|
-
const planDir =
|
|
75752
|
-
const reportFile =
|
|
75790
|
+
const planDir = join114(plansAbs, planDirTemplate(namingFormat, dateStr));
|
|
75791
|
+
const reportFile = join114(reportsAbs, `${agentKey}-${dateStr}-{slug}-report.md`);
|
|
75753
75792
|
const activePlan = detectPlan(plansAbs);
|
|
75754
75793
|
const venv = resolveSkillsVenv(effectiveCwd);
|
|
75755
75794
|
const respLang = cfg.locale?.responseLanguage?.trim() || null;
|
|
@@ -75825,12 +75864,12 @@ var sessionSubagentInit = {
|
|
|
75825
75864
|
};
|
|
75826
75865
|
|
|
75827
75866
|
// src/domains/hooks/handlers/session-wip-checkpoint/handler.ts
|
|
75828
|
-
import { execFileSync as
|
|
75867
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
75829
75868
|
var CONFIG_KEY5 = "precompact-guard";
|
|
75830
75869
|
var GIT_STATUS_TIMEOUT_MS2 = 800;
|
|
75831
75870
|
function countUncommittedEntries(cwd2) {
|
|
75832
75871
|
try {
|
|
75833
|
-
const stdout =
|
|
75872
|
+
const stdout = execFileSync6("git", ["status", "--porcelain"], {
|
|
75834
75873
|
cwd: cwd2,
|
|
75835
75874
|
timeout: GIT_STATUS_TIMEOUT_MS2,
|
|
75836
75875
|
encoding: "utf8",
|
|
@@ -90899,7 +90938,7 @@ function normalizeSkillGroupFlag(value) {
|
|
|
90899
90938
|
|
|
90900
90939
|
// src/cli/command-registry.ts
|
|
90901
90940
|
function registerCommands(cli) {
|
|
90902
|
-
cli.command("init", "Initialize or update Takumi project (with interactive version selection)").option("--dir <dir>", "Target directory (default: .)").option("--kit <kit>", "Kit(s) to install (core, extras). Repeat the flag to install multiple kits, e.g. --kit core --kit extras.").option("-r, --release <version>", "Skip version selection, use specific version (e.g., latest, v1.0.0)").option("--exclude <pattern>", "Exclude files matching glob pattern (can be used multiple times)").option("--only <pattern>", "Include only files matching glob pattern (can be used multiple times)").option("--skill-role <role>", "Install only skills tagged with these role(s) (comma-separated or repeatable). Combines with --skill-category as a union.").option("--skill-category <category>", "Install only skills in these categor(y/ies) (comma-separated or repeatable). Combines with --skill-role as a union.").option("-g, --global", "Use platform-specific user configuration directory").option("--fresh", "Full reset: remove takumi files, replace settings.json and CLAUDE.md, reinstall from scratch").option("--force", "Force reinstall even if already at latest version (use with --yes; re-onboards missing files without full reset)").option("--install-skills", "Install skills dependencies (non-interactive mode)").option("--install-hooks", "Install all agent hooks (guard, session, convention, extension). Default installs only telemetry hooks.").option("--with-sudo", "Include system packages requiring sudo (Linux: ffmpeg, imagemagick)").option("--prefix", "Add /tkm: prefix to all slash commands by moving them to commands/tkm/ subdirectory").option("--beta", "Show beta versions in selection prompt").option("--refresh", "Bypass release cache to fetch latest versions from GitHub").option("--dry-run", "Preview changes without applying them (requires --prefix)").option("--force-overwrite", "Override ownership protections and delete user-modified files (requires --prefix)").option("--force-overwrite-settings", "Fully replace settings.json instead of selective merge (destroys user customizations)").option("--docs-dir <name>", "Custom docs folder name (default: docs)").option("--plans-dir <name>", "Custom plans folder name (default: plans)").option("-y, --yes", "Non-interactive mode with sensible defaults (skip all prompts)").option("--sync", "Sync config files from upstream with interactive hunk-by-hunk merge").option("--use-git", "Use git clone instead of GitHub API (uses SSH/HTTPS credentials)").option("--archive <path>", "Use local archive file instead of downloading (zip/tar.gz)").option("--kit-path <path>", "Use local kit directory instead of downloading").option("--local", "Use local monorepo as kit source (auto-detects from CLI location)").option("--use-gh", "Force GitHub release source (bypass Worker
|
|
90941
|
+
cli.command("init", "Initialize or update Takumi project (with interactive version selection)").option("--dir <dir>", "Target directory (default: .)").option("--kit <kit>", "Kit(s) to install (core, extras). Repeat the flag to install multiple kits, e.g. --kit core --kit extras.").option("-r, --release <version>", "Skip version selection, use specific version (e.g., latest, v1.0.0)").option("--exclude <pattern>", "Exclude files matching glob pattern (can be used multiple times)").option("--only <pattern>", "Include only files matching glob pattern (can be used multiple times)").option("--skill-role <role>", "Install only skills tagged with these role(s) (comma-separated or repeatable). Combines with --skill-category as a union.").option("--skill-category <category>", "Install only skills in these categor(y/ies) (comma-separated or repeatable). Combines with --skill-role as a union.").option("-g, --global", "Use platform-specific user configuration directory").option("--fresh", "Full reset: remove takumi files, replace settings.json and CLAUDE.md, reinstall from scratch").option("--force", "Force reinstall even if already at latest version (use with --yes; re-onboards missing files without full reset)").option("--install-skills", "Install skills dependencies (non-interactive mode)").option("--install-hooks", "Install all agent hooks (guard, session, convention, extension). Default installs only telemetry hooks.").option("--with-sudo", "Include system packages requiring sudo (Linux: ffmpeg, imagemagick)").option("--prefix", "Add /tkm: prefix to all slash commands by moving them to commands/tkm/ subdirectory").option("--beta", "Show beta versions in selection prompt").option("--refresh", "Bypass release cache to fetch latest versions from GitHub").option("--dry-run", "Preview changes without applying them (requires --prefix)").option("--force-overwrite", "Override ownership protections and delete user-modified files (requires --prefix)").option("--force-overwrite-settings", "Fully replace settings.json instead of selective merge (destroys user customizations)").option("--docs-dir <name>", "Custom docs folder name (default: docs)").option("--plans-dir <name>", "Custom plans folder name (default: plans)").option("-y, --yes", "Non-interactive mode with sensible defaults (skip all prompts)").option("--sync", "Sync config files from upstream with interactive hunk-by-hunk merge").option("--use-git", "Use git clone instead of GitHub API (uses SSH/HTTPS credentials)").option("--archive <path>", "Use local archive file instead of downloading (zip/tar.gz)").option("--kit-path <path>", "Use local kit directory instead of downloading").option("--local", "Use local monorepo as kit source (auto-detects from CLI location)").option("--use-gh", "Force GitHub release source (bypass the Worker release distribution API; default uses Worker)").option("-a, --agent <agents...>", "Target agents (claude-code, codex). Default: claude-code").action(async (options2) => {
|
|
90903
90942
|
if (options2.exclude && !Array.isArray(options2.exclude)) {
|
|
90904
90943
|
options2.exclude = [options2.exclude];
|
|
90905
90944
|
}
|