@sunasteriskrnd/takumi 1.0.0-dev.31 → 1.0.0-dev.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +36 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19815,7 +19815,7 @@ var package_default;
19815
19815
  var init_package = __esm(() => {
19816
19816
  package_default = {
19817
19817
  name: "@sunasteriskrnd/takumi",
19818
- version: "1.0.0-dev.31",
19818
+ version: "1.0.0-dev.33",
19819
19819
  description: "CLI tool for bootstrapping and managing Takumi projects",
19820
19820
  type: "module",
19821
19821
  repository: {
@@ -22283,6 +22283,7 @@ var init_commands = __esm(() => {
22283
22283
  fresh: exports_external.boolean().default(false),
22284
22284
  force: exports_external.boolean().default(false),
22285
22285
  installSkills: exports_external.boolean().default(false),
22286
+ installHooks: exports_external.boolean().default(false),
22286
22287
  withSudo: exports_external.boolean().default(false),
22287
22288
  prefix: exports_external.boolean().default(false),
22288
22289
  beta: exports_external.boolean().default(false),
@@ -61954,6 +61955,7 @@ function buildSessionPayload(args) {
61954
61955
  const endedAt = summary.timing.ended_at ?? startedAt;
61955
61956
  const durationS = summary.timing.duration_s ?? Math.max(0, Math.round((Date.parse(endedAt) - Date.parse(startedAt)) / 1000));
61956
61957
  const tokens = summary.totals;
61958
+ const hasTokenUsage = summary.token_usage && Object.keys(summary.token_usage).length > 0;
61957
61959
  return {
61958
61960
  session: {
61959
61961
  id: summary.session_id,
@@ -61970,7 +61972,8 @@ function buildSessionPayload(args) {
61970
61972
  cache_write_tokens: tokens.cache_write,
61971
61973
  milestone_completed: args.milestone,
61972
61974
  error_count: args.errorCount,
61973
- tool_stats: summary.tool_stats
61975
+ tool_stats: summary.tool_stats,
61976
+ ...hasTokenUsage ? { token_usage: summary.token_usage } : {}
61974
61977
  }
61975
61978
  };
61976
61979
  }
@@ -61990,6 +61993,7 @@ function initialSummary(args) {
61990
61993
  project: args.project,
61991
61994
  timing: { started_at: args.startedAt, ended_at: null, duration_s: null },
61992
61995
  main_loop_tokens: zeroTokens(),
61996
+ token_usage: {},
61993
61997
  subagents: [],
61994
61998
  skills: [],
61995
61999
  tool_stats: {
@@ -62122,6 +62126,7 @@ async function tailRead(args) {
62122
62126
  function bucketTokens(records) {
62123
62127
  const mainLoopDelta = zeroTokens2();
62124
62128
  const subagentDeltas = new Map;
62129
+ const tokenUsageDeltas = new Map;
62125
62130
  for (const record of records) {
62126
62131
  if (record.type !== "assistant")
62127
62132
  continue;
@@ -62140,8 +62145,13 @@ function bucketTokens(records) {
62140
62145
  } else {
62141
62146
  Object.assign(mainLoopDelta, addTokens2(mainLoopDelta, tokens));
62142
62147
  }
62148
+ const model = record.message?.model;
62149
+ if (model) {
62150
+ const prev = tokenUsageDeltas.get(model) ?? zeroTokens2();
62151
+ tokenUsageDeltas.set(model, addTokens2(prev, tokens));
62152
+ }
62143
62153
  }
62144
- return { mainLoopDelta, subagentDeltas };
62154
+ return { mainLoopDelta, subagentDeltas, tokenUsageDeltas };
62145
62155
  }
62146
62156
 
62147
62157
  // src/domains/hooks/telemetry/lib/transcript-apply.ts
@@ -62156,6 +62166,13 @@ function addTokens3(a3, b3) {
62156
62166
  cache_write: a3.cache_write + b3.cache_write
62157
62167
  };
62158
62168
  }
62169
+ function mergeTokenUsageDeltas(existing, deltas) {
62170
+ const out = { ...existing ?? {} };
62171
+ for (const [model, delta] of deltas) {
62172
+ out[model] = addTokens3(ensureTokens(out[model]), delta);
62173
+ }
62174
+ return out;
62175
+ }
62159
62176
  async function applyTranscriptDelta(args) {
62160
62177
  if (!args.transcriptPath) {
62161
62178
  return { summary: args.summary, read: false };
@@ -62168,7 +62185,7 @@ async function applyTranscriptDelta(args) {
62168
62185
  if (records.length === 0 && nextOffset === args.summary.transcript_offset) {
62169
62186
  return { summary: args.summary, read: true };
62170
62187
  }
62171
- const { mainLoopDelta, subagentDeltas } = bucketTokens(records);
62188
+ const { mainLoopDelta, subagentDeltas, tokenUsageDeltas } = bucketTokens(records);
62172
62189
  const updated = {
62173
62190
  ...args.summary,
62174
62191
  main_loop_tokens: addTokens3(args.summary.main_loop_tokens, mainLoopDelta),
@@ -62178,6 +62195,7 @@ async function applyTranscriptDelta(args) {
62178
62195
  return rec;
62179
62196
  return { ...rec, tokens: addTokens3(ensureTokens(rec.tokens), delta) };
62180
62197
  }),
62198
+ token_usage: mergeTokenUsageDeltas(args.summary.token_usage, tokenUsageDeltas),
62181
62199
  transcript_offset: nextOffset
62182
62200
  };
62183
62201
  return { summary: updated, read: true };
@@ -66467,6 +66485,12 @@ var AGENT_DISPLAY3 = {
66467
66485
  claude: "Claude Code",
66468
66486
  codex: "Codex"
66469
66487
  };
66488
+ function selectHandlersForInstall(categories) {
66489
+ if (!categories)
66490
+ return HOOK_HANDLERS;
66491
+ const wanted = new Set(categories);
66492
+ return HOOK_HANDLERS.filter((h2) => wanted.has(h2.category));
66493
+ }
66470
66494
  function countEntries(section) {
66471
66495
  let count = 0;
66472
66496
  for (const groups of Object.values(section)) {
@@ -66483,7 +66507,7 @@ async function installForAgent(agent, options2, interactive, useStepUI) {
66483
66507
  const section = buildHookSection(agent, options2.bin, {
66484
66508
  noDetach: options2.noDetach,
66485
66509
  debug: options2.debug
66486
- });
66510
+ }, selectHandlersForInstall(options2.categories));
66487
66511
  const entriesPlanned = countEntries(section);
66488
66512
  const result = await writeSettingsWithConfirm({
66489
66513
  path: location2.realPath,
@@ -67952,6 +67976,7 @@ function createInitContext(rawOptions, prompts) {
67952
67976
  exclude: [],
67953
67977
  only: [],
67954
67978
  installSkills: false,
67979
+ installHooks: false,
67955
67980
  withSudo: false,
67956
67981
  forceOverwrite: false,
67957
67982
  forceOverwriteSettings: false,
@@ -72669,6 +72694,7 @@ async function resolveOptions(ctx) {
72669
72694
  docsDir: parsed.docsDir,
72670
72695
  plansDir: parsed.plansDir,
72671
72696
  installSkills: parsed.installSkills ?? false,
72697
+ installHooks: parsed.installHooks ?? false,
72672
72698
  withSudo: parsed.withSudo ?? false,
72673
72699
  forceOverwrite: parsed.forceOverwrite ?? false,
72674
72700
  forceOverwriteSettings: parsed.forceOverwriteSettings ?? false,
@@ -75020,6 +75046,7 @@ function mapAgentToHookAgent(agent) {
75020
75046
  return null;
75021
75047
  }
75022
75048
  async function installTkmHooksForAgents(targetAgents2, options2) {
75049
+ const categories = options2.installHooks ? undefined : ["metrics"];
75023
75050
  for (const agent of targetAgents2) {
75024
75051
  const hookAgent = mapAgentToHookAgent(agent);
75025
75052
  if (!hookAgent)
@@ -75029,6 +75056,7 @@ async function installTkmHooksForAgents(targetAgents2, options2) {
75029
75056
  agent: hookAgent,
75030
75057
  global: options2.global,
75031
75058
  dryRun: options2.dryRun,
75059
+ categories,
75032
75060
  yes: true
75033
75061
  });
75034
75062
  } catch (err) {
@@ -75148,7 +75176,8 @@ async function executeInit(options2, prompts) {
75148
75176
  if (!isSyncMode) {
75149
75177
  await installTkmHooksForAgents(targetAgents2, {
75150
75178
  global: Boolean(ctx.options.global),
75151
- dryRun: Boolean(ctx.options.dryRun)
75179
+ dryRun: Boolean(ctx.options.dryRun),
75180
+ installHooks: Boolean(ctx.options.installHooks)
75152
75181
  });
75153
75182
  }
75154
75183
  if (targetAgents2.length > 1) {
@@ -77525,7 +77554,7 @@ ${import_picocolors29.default.bold(import_picocolors29.default.cyan(result.kitCo
77525
77554
  // src/cli/command-registry.ts
77526
77555
  init_logger();
77527
77556
  function registerCommands(cli) {
77528
- 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("-g, --global", "Use platform-specific user configuration directory").option("--fresh", "Full reset: remove SK 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("--with-sudo", "Include system packages requiring sudo (Linux: ffmpeg, imagemagick)").option("--prefix", "Add /sk: prefix to all slash commands by moving them to commands/sk/ 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 R2 proxy; default uses Worker)").option("-a, --agent <agents...>", "Target agents (claude-code, codex). Default: claude-code").action(async (options2) => {
77557
+ 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("-g, --global", "Use platform-specific user configuration directory").option("--fresh", "Full reset: remove SK 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 /sk: prefix to all slash commands by moving them to commands/sk/ 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 R2 proxy; default uses Worker)").option("-a, --agent <agents...>", "Target agents (claude-code, codex). Default: claude-code").action(async (options2) => {
77529
77558
  if (options2.exclude && !Array.isArray(options2.exclude)) {
77530
77559
  options2.exclude = [options2.exclude];
77531
77560
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunasteriskrnd/takumi",
3
- "version": "1.0.0-dev.31",
3
+ "version": "1.0.0-dev.33",
4
4
  "description": "CLI tool for bootstrapping and managing Takumi projects",
5
5
  "type": "module",
6
6
  "repository": {