@drewpayment/mink 0.13.0-beta.1 → 0.13.0-beta.3

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 (105) hide show
  1. package/README.md +4 -20
  2. package/dashboard/out/404.html +1 -1
  3. package/dashboard/out/_next/static/U9AeObddt4LmJkKRZpEfy/_buildManifest.js +1 -0
  4. package/dashboard/out/_next/static/chunks/app/(panels)/activity/page-c285fb9f63d9a82a.js +1 -0
  5. package/dashboard/out/_next/static/chunks/app/(panels)/bugs/page-f3ba7d8f50a96568.js +1 -0
  6. package/dashboard/out/_next/static/chunks/app/(panels)/capture/page-e004bec9af99a244.js +1 -0
  7. package/dashboard/out/_next/static/chunks/app/(panels)/compression/page-21e1af119b3f81ff.js +1 -0
  8. package/dashboard/out/_next/static/chunks/app/(panels)/config/page-d47fb6f588ccfd4b.js +1 -0
  9. package/dashboard/out/_next/static/chunks/app/(panels)/daemon/page-52f913e751416717.js +1 -0
  10. package/dashboard/out/_next/static/chunks/app/(panels)/design/page-53a76719b9af5830.js +1 -0
  11. package/dashboard/out/_next/static/chunks/app/(panels)/discord/page-04502d12c4a96cf7.js +1 -0
  12. package/dashboard/out/_next/static/chunks/app/(panels)/file-index/page-a1bd10e04bb219d9.js +1 -0
  13. package/dashboard/out/_next/static/chunks/app/(panels)/insights/page-7367274963571b6b.js +1 -0
  14. package/dashboard/out/_next/static/chunks/app/(panels)/learning/{page-b766adc79099adb4.js → page-4a03cf7b9a6106fd.js} +1 -1
  15. package/dashboard/out/_next/static/chunks/app/(panels)/overview/page-38b8430b5c56e807.js +1 -0
  16. package/dashboard/out/_next/static/chunks/app/(panels)/scheduler/page-510b78c9b0a61012.js +1 -0
  17. package/dashboard/out/_next/static/chunks/app/(panels)/sync/page-b7215c2a29a7d7a7.js +1 -0
  18. package/dashboard/out/_next/static/chunks/app/(panels)/tokens/page-1be7ed35a5c9bd39.js +1 -0
  19. package/dashboard/out/_next/static/chunks/app/(panels)/waste/page-24a726e6d63f771a.js +1 -0
  20. package/dashboard/out/_next/static/chunks/app/(panels)/wiki/page-230d2d1cae6507a8.js +1 -0
  21. package/dashboard/out/_next/static/chunks/app/layout-70a6d18f8e464960.js +1 -0
  22. package/dashboard/out/action-log.html +1 -1
  23. package/dashboard/out/action-log.txt +4 -4
  24. package/dashboard/out/activity.html +1 -1
  25. package/dashboard/out/activity.txt +5 -5
  26. package/dashboard/out/bugs.html +1 -1
  27. package/dashboard/out/bugs.txt +5 -5
  28. package/dashboard/out/capture.html +1 -1
  29. package/dashboard/out/capture.txt +5 -5
  30. package/dashboard/out/compression.html +1 -0
  31. package/dashboard/out/compression.txt +24 -0
  32. package/dashboard/out/config.html +1 -1
  33. package/dashboard/out/config.txt +5 -5
  34. package/dashboard/out/daemon.html +1 -1
  35. package/dashboard/out/daemon.txt +5 -5
  36. package/dashboard/out/design.html +1 -1
  37. package/dashboard/out/design.txt +5 -5
  38. package/dashboard/out/discord.html +1 -1
  39. package/dashboard/out/discord.txt +5 -5
  40. package/dashboard/out/file-index.html +1 -1
  41. package/dashboard/out/file-index.txt +5 -5
  42. package/dashboard/out/index.html +1 -1
  43. package/dashboard/out/index.txt +4 -4
  44. package/dashboard/out/insights.html +1 -1
  45. package/dashboard/out/insights.txt +5 -5
  46. package/dashboard/out/learning.html +1 -1
  47. package/dashboard/out/learning.txt +5 -5
  48. package/dashboard/out/overview.html +1 -1
  49. package/dashboard/out/overview.txt +5 -5
  50. package/dashboard/out/scheduler.html +1 -1
  51. package/dashboard/out/scheduler.txt +5 -5
  52. package/dashboard/out/sync.html +1 -1
  53. package/dashboard/out/sync.txt +5 -5
  54. package/dashboard/out/tokens.html +1 -1
  55. package/dashboard/out/tokens.txt +5 -5
  56. package/dashboard/out/waste.html +1 -1
  57. package/dashboard/out/waste.txt +5 -5
  58. package/dashboard/out/wiki.html +1 -1
  59. package/dashboard/out/wiki.txt +5 -5
  60. package/dist/cli.bun.js +1300 -908
  61. package/dist/cli.node.js +1319 -928
  62. package/package.json +1 -1
  63. package/src/cli.ts +17 -20
  64. package/src/commands/init.ts +14 -123
  65. package/src/commands/post-read.ts +18 -0
  66. package/src/commands/post-tool.ts +48 -0
  67. package/src/commands/retrieve.ts +32 -0
  68. package/src/commands/status.ts +13 -1
  69. package/src/core/code-skeleton.ts +108 -0
  70. package/src/core/compress-tool-output.ts +127 -0
  71. package/src/core/compression.ts +81 -0
  72. package/src/core/dashboard-api.ts +20 -1
  73. package/src/core/dashboard-server.ts +3 -0
  74. package/src/core/hook-output.ts +42 -0
  75. package/src/core/output-compression.ts +252 -0
  76. package/src/core/token-estimate.ts +40 -0
  77. package/src/repositories/compression-cache-repo.ts +97 -0
  78. package/src/repositories/token-ledger-repo.ts +142 -0
  79. package/src/storage/schema.ts +50 -1
  80. package/src/types/compression.ts +29 -0
  81. package/src/types/config.ts +40 -0
  82. package/src/types/dashboard.ts +22 -1
  83. package/src/types/hook-input.ts +4 -0
  84. package/src/types/token-ledger.ts +55 -0
  85. package/dashboard/out/_next/static/UWfkbJY4zr9fSt7O-CAge/_buildManifest.js +0 -1
  86. package/dashboard/out/_next/static/chunks/app/(panels)/activity/page-096a97ba539d5323.js +0 -1
  87. package/dashboard/out/_next/static/chunks/app/(panels)/bugs/page-449d31c133432458.js +0 -1
  88. package/dashboard/out/_next/static/chunks/app/(panels)/capture/page-c6617aa0a8a7333e.js +0 -1
  89. package/dashboard/out/_next/static/chunks/app/(panels)/config/page-aa0a0623b3fdd0d8.js +0 -1
  90. package/dashboard/out/_next/static/chunks/app/(panels)/daemon/page-7cd3fac2f5d87a0d.js +0 -1
  91. package/dashboard/out/_next/static/chunks/app/(panels)/design/page-5304675c96b6793b.js +0 -1
  92. package/dashboard/out/_next/static/chunks/app/(panels)/discord/page-9940dde80ba2a69e.js +0 -1
  93. package/dashboard/out/_next/static/chunks/app/(panels)/file-index/page-ecd8a753614e981e.js +0 -1
  94. package/dashboard/out/_next/static/chunks/app/(panels)/insights/page-7909d8beb8d8ef7a.js +0 -1
  95. package/dashboard/out/_next/static/chunks/app/(panels)/overview/page-7a9e86dcde67d6a9.js +0 -1
  96. package/dashboard/out/_next/static/chunks/app/(panels)/scheduler/page-a88f93204c9742a1.js +0 -1
  97. package/dashboard/out/_next/static/chunks/app/(panels)/sync/page-8a9ad4c36aa6cb65.js +0 -1
  98. package/dashboard/out/_next/static/chunks/app/(panels)/tokens/page-8dac7d50d4db2756.js +0 -1
  99. package/dashboard/out/_next/static/chunks/app/(panels)/waste/page-bcf56144faf7d133.js +0 -1
  100. package/dashboard/out/_next/static/chunks/app/(panels)/wiki/page-a32fdbd0bf58b30b.js +0 -1
  101. package/dashboard/out/_next/static/chunks/app/layout-782cd26e0ccc4514.js +0 -1
  102. package/src/core/agent-detect.ts +0 -88
  103. package/src/core/agent-pi.ts +0 -314
  104. package/src/core/prompt.ts +0 -27
  105. /package/dashboard/out/_next/static/{UWfkbJY4zr9fSt7O-CAge → U9AeObddt4LmJkKRZpEfy}/_ssgManifest.js +0 -0
package/dist/cli.bun.js CHANGED
@@ -421,6 +421,41 @@ var init_config = __esm(() => {
421
421
  envVar: "MINK_PROJECTS_IDENTITY",
422
422
  description: "Project identity strategy: path-derived (legacy) or git-remote (stable across machines)",
423
423
  scope: "shared"
424
+ },
425
+ {
426
+ key: "compression.enabled",
427
+ default: "false",
428
+ envVar: "MINK_COMPRESSION_ENABLED",
429
+ description: "Enable tool-output compression (spec 21). Off until inline compression ships.",
430
+ scope: "shared"
431
+ },
432
+ {
433
+ key: "compression.threshold-tokens",
434
+ default: "800",
435
+ envVar: "MINK_COMPRESSION_THRESHOLD_TOKENS",
436
+ description: "Minimum estimated token size before a tool output is eligible for compression",
437
+ scope: "shared"
438
+ },
439
+ {
440
+ key: "compression.min-savings-ratio",
441
+ default: "0.25",
442
+ envVar: "MINK_COMPRESSION_MIN_SAVINGS_RATIO",
443
+ description: "Discard a compression attempt unless it saves at least this fraction of tokens",
444
+ scope: "shared"
445
+ },
446
+ {
447
+ key: "compression.holdout-fraction",
448
+ default: "0.1",
449
+ envVar: "MINK_COMPRESSION_HOLDOUT_FRACTION",
450
+ description: "Fraction of eligible outputs left uncompressed as a measured control group",
451
+ scope: "shared"
452
+ },
453
+ {
454
+ key: "compression.retention-hours",
455
+ default: "168",
456
+ envVar: "MINK_COMPRESSION_RETENTION_HOURS",
457
+ description: "How long compressed originals stay retrievable before eviction",
458
+ scope: "shared"
424
459
  }
425
460
  ];
426
461
  VALID_KEYS = new Set(CONFIG_KEYS.map((k) => k.key));
@@ -3095,7 +3130,7 @@ function readMeta(db, key) {
3095
3130
  function writeMeta(db, key, value) {
3096
3131
  db.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(key, value);
3097
3132
  }
3098
- var SCHEMA_VERSION = 1, INITIAL_SCHEMA = `
3133
+ var SCHEMA_VERSION = 3, INITIAL_SCHEMA = `
3099
3134
  CREATE TABLE IF NOT EXISTS meta (
3100
3135
  key TEXT PRIMARY KEY,
3101
3136
  value TEXT NOT NULL
@@ -3257,6 +3292,55 @@ CREATE TABLE IF NOT EXISTS counters (
3257
3292
  file_index_hits INTEGER NOT NULL DEFAULT 0,
3258
3293
  file_index_misses INTEGER NOT NULL DEFAULT 0
3259
3294
  );
3295
+
3296
+ -- Tool-output compression measurement (spec 21). One row per compression
3297
+ -- decision: either a compressed arm (compressed_tokens < original_tokens) or a
3298
+ -- holdout arm (left uncompressed for control, compressed_tokens = original_tokens).
3299
+ -- These are append-only telemetry, independent of session lifecycle, written at
3300
+ -- the moment a tool output is processed. New table \u2192 applied to existing DBs via
3301
+ -- IF NOT EXISTS on the next open.
3302
+ CREATE TABLE IF NOT EXISTS ledger_compressions (
3303
+ id TEXT PRIMARY KEY,
3304
+ created_at TEXT NOT NULL,
3305
+ tool_name TEXT NOT NULL,
3306
+ content_kind TEXT NOT NULL,
3307
+ original_tokens INTEGER NOT NULL DEFAULT 0,
3308
+ compressed_tokens INTEGER NOT NULL DEFAULT 0,
3309
+ holdout INTEGER NOT NULL DEFAULT 0,
3310
+ device_id TEXT NOT NULL
3311
+ );
3312
+ CREATE INDEX IF NOT EXISTS idx_ledger_compressions_created ON ledger_compressions(created_at);
3313
+ CREATE INDEX IF NOT EXISTS idx_ledger_compressions_device ON ledger_compressions(device_id);
3314
+
3315
+ -- Per-device compression aggregates, summed across devices like ledger_lifetime.
3316
+ -- measured_savings only credits compressed arms (holdout arms save nothing by
3317
+ -- construction), so the reported figure is a true measured delta, not an estimate.
3318
+ CREATE TABLE IF NOT EXISTS ledger_compression_lifetime (
3319
+ device_id TEXT PRIMARY KEY,
3320
+ total_events INTEGER NOT NULL DEFAULT 0,
3321
+ total_holdout_events INTEGER NOT NULL DEFAULT 0,
3322
+ total_original_tokens INTEGER NOT NULL DEFAULT 0,
3323
+ total_compressed_tokens INTEGER NOT NULL DEFAULT 0,
3324
+ total_measured_savings INTEGER NOT NULL DEFAULT 0
3325
+ );
3326
+
3327
+ -- Reversible-compression cache (spec 21 \xA7Reversibility). When a tool output is
3328
+ -- compressed, the original is stored here keyed by a short retrieval token and
3329
+ -- embedded in the compressed result; "mink retrieve <token>" returns it
3330
+ -- byte-exact. Rows expire after the configured retention window; an expired or
3331
+ -- unknown token is a graceful miss. This is a local cache, not synced state, so
3332
+ -- (unlike other tables) it carries no merge semantics beyond device_id for audit.
3333
+ CREATE TABLE IF NOT EXISTS compression_cache (
3334
+ token TEXT PRIMARY KEY,
3335
+ created_at TEXT NOT NULL,
3336
+ expires_at TEXT NOT NULL,
3337
+ tool_name TEXT NOT NULL,
3338
+ content_kind TEXT NOT NULL,
3339
+ content TEXT NOT NULL,
3340
+ size_bytes INTEGER NOT NULL,
3341
+ device_id TEXT NOT NULL
3342
+ );
3343
+ CREATE INDEX IF NOT EXISTS idx_compression_cache_expires ON compression_cache(expires_at);
3260
3344
  `;
3261
3345
 
3262
3346
  // src/storage/migrate-json.ts
@@ -3640,7 +3724,8 @@ class TokenLedgerRepo {
3640
3724
  snapshot() {
3641
3725
  const ledger = {
3642
3726
  lifetime: this.lifetime(),
3643
- sessions: this.activeSessions()
3727
+ sessions: this.activeSessions(),
3728
+ compression: this.compressionLifetime()
3644
3729
  };
3645
3730
  const flagRows = this.db.prepare("SELECT pattern, detected_at, details FROM waste_flags ORDER BY detected_at").all();
3646
3731
  if (flagRows.length > 0) {
@@ -3674,6 +3759,110 @@ class TokenLedgerRepo {
3674
3759
  }
3675
3760
  });
3676
3761
  }
3762
+ recordCompression(event, deviceId = getOrCreateDeviceId()) {
3763
+ const id = event.id ?? crypto.randomUUID();
3764
+ const createdAt = event.createdAt ?? new Date().toISOString();
3765
+ const holdout = event.holdout ? 1 : 0;
3766
+ const savings = event.holdout ? 0 : Math.max(0, event.originalTokens - event.compressedTokens);
3767
+ this.db.transaction(() => {
3768
+ this.db.prepare(`
3769
+ INSERT OR REPLACE INTO ledger_compressions
3770
+ (id, created_at, tool_name, content_kind,
3771
+ original_tokens, compressed_tokens, holdout, device_id)
3772
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
3773
+ `).run(id, createdAt, event.toolName, event.contentKind, event.originalTokens, event.compressedTokens, holdout, deviceId);
3774
+ this.db.prepare(`
3775
+ INSERT INTO ledger_compression_lifetime
3776
+ (device_id, total_events, total_holdout_events,
3777
+ total_original_tokens, total_compressed_tokens, total_measured_savings)
3778
+ VALUES (?, ?, ?, ?, ?, ?)
3779
+ ON CONFLICT(device_id) DO UPDATE SET
3780
+ total_events = ledger_compression_lifetime.total_events + excluded.total_events,
3781
+ total_holdout_events = ledger_compression_lifetime.total_holdout_events + excluded.total_holdout_events,
3782
+ total_original_tokens = ledger_compression_lifetime.total_original_tokens + excluded.total_original_tokens,
3783
+ total_compressed_tokens = ledger_compression_lifetime.total_compressed_tokens + excluded.total_compressed_tokens,
3784
+ total_measured_savings = ledger_compression_lifetime.total_measured_savings + excluded.total_measured_savings
3785
+ `).run(deviceId, 1, holdout, event.originalTokens, event.compressedTokens, savings);
3786
+ });
3787
+ }
3788
+ compressionLifetime() {
3789
+ const row = this.db.prepare(`
3790
+ SELECT
3791
+ COALESCE(SUM(total_events), 0) AS totalEvents,
3792
+ COALESCE(SUM(total_holdout_events), 0) AS totalHoldoutEvents,
3793
+ COALESCE(SUM(total_original_tokens), 0) AS totalOriginalTokens,
3794
+ COALESCE(SUM(total_compressed_tokens), 0) AS totalCompressedTokens,
3795
+ COALESCE(SUM(total_measured_savings), 0) AS totalMeasuredSavings
3796
+ FROM ledger_compression_lifetime
3797
+ `).get();
3798
+ return {
3799
+ totalEvents: Number(row?.totalEvents ?? 0),
3800
+ totalHoldoutEvents: Number(row?.totalHoldoutEvents ?? 0),
3801
+ totalOriginalTokens: Number(row?.totalOriginalTokens ?? 0),
3802
+ totalCompressedTokens: Number(row?.totalCompressedTokens ?? 0),
3803
+ totalMeasuredSavings: Number(row?.totalMeasuredSavings ?? 0)
3804
+ };
3805
+ }
3806
+ compressionEvents(limit = 100) {
3807
+ const rows = this.db.prepare(`
3808
+ SELECT id, created_at, tool_name, content_kind,
3809
+ original_tokens, compressed_tokens, holdout
3810
+ FROM ledger_compressions
3811
+ ORDER BY created_at DESC
3812
+ LIMIT ?
3813
+ `).all(limit);
3814
+ return rows.map((r) => ({
3815
+ id: String(r.id),
3816
+ createdAt: String(r.created_at),
3817
+ toolName: String(r.tool_name),
3818
+ contentKind: String(r.content_kind),
3819
+ originalTokens: Number(r.original_tokens),
3820
+ compressedTokens: Number(r.compressed_tokens),
3821
+ holdout: Number(r.holdout) === 1
3822
+ }));
3823
+ }
3824
+ compressionArms() {
3825
+ const row = this.db.prepare(`
3826
+ SELECT
3827
+ COALESCE(SUM(CASE WHEN holdout = 0 THEN 1 END), 0) AS cEvents,
3828
+ COALESCE(SUM(CASE WHEN holdout = 0 THEN original_tokens END), 0) AS cOriginal,
3829
+ COALESCE(SUM(CASE WHEN holdout = 0 THEN compressed_tokens END), 0) AS cCompressed,
3830
+ COALESCE(SUM(CASE WHEN holdout = 1 THEN 1 END), 0) AS hEvents,
3831
+ COALESCE(SUM(CASE WHEN holdout = 1 THEN original_tokens END), 0) AS hOriginal
3832
+ FROM ledger_compressions
3833
+ `).get();
3834
+ return {
3835
+ compressed: {
3836
+ events: Number(row?.cEvents ?? 0),
3837
+ originalTokens: Number(row?.cOriginal ?? 0),
3838
+ compressedTokens: Number(row?.cCompressed ?? 0)
3839
+ },
3840
+ holdout: {
3841
+ events: Number(row?.hEvents ?? 0),
3842
+ originalTokens: Number(row?.hOriginal ?? 0)
3843
+ }
3844
+ };
3845
+ }
3846
+ compressionBreakdown(dimension) {
3847
+ const rows = this.db.prepare(`
3848
+ SELECT
3849
+ ${dimension} AS key,
3850
+ COUNT(*) AS events,
3851
+ COALESCE(SUM(original_tokens), 0) AS originalTokens,
3852
+ COALESCE(SUM(compressed_tokens), 0) AS compressedTokens,
3853
+ COALESCE(SUM(CASE WHEN holdout = 0 THEN original_tokens - compressed_tokens END), 0) AS savings
3854
+ FROM ledger_compressions
3855
+ GROUP BY ${dimension}
3856
+ ORDER BY savings DESC
3857
+ `).all();
3858
+ return rows.map((r) => ({
3859
+ key: String(r.key),
3860
+ events: Number(r.events),
3861
+ originalTokens: Number(r.originalTokens),
3862
+ compressedTokens: Number(r.compressedTokens),
3863
+ savings: Number(r.savings)
3864
+ }));
3865
+ }
3677
3866
  insertSessionRow(summary, deviceId, archived) {
3678
3867
  this.db.prepare(`
3679
3868
  INSERT OR REPLACE INTO ledger_sessions
@@ -4448,6 +4637,28 @@ function estimateTokens2(content, filePath) {
4448
4637
  }
4449
4638
  return Math.ceil(content.length / ratio);
4450
4639
  }
4640
+ function countTokens(text) {
4641
+ if (!text)
4642
+ return 0;
4643
+ const segments = text.match(/[A-Za-z]+|[0-9]+|[^A-Za-z0-9]/g);
4644
+ if (!segments)
4645
+ return 0;
4646
+ let tokens = 0;
4647
+ for (const seg of segments) {
4648
+ const first = seg.charCodeAt(0);
4649
+ if (first >= 65 && first <= 90 || first >= 97 && first <= 122) {
4650
+ tokens += Math.ceil(seg.length / 4);
4651
+ } else if (first >= 48 && first <= 57) {
4652
+ tokens += Math.ceil(seg.length / 3);
4653
+ } else if (seg === `
4654
+ `) {
4655
+ tokens += 1;
4656
+ } else if (seg === " " || seg === "\t" || seg === "\r") {} else {
4657
+ tokens += 1;
4658
+ }
4659
+ }
4660
+ return tokens;
4661
+ }
4451
4662
  var CODE_EXTENSIONS, PROSE_EXTENSIONS, BINARY_EXTENSIONS;
4452
4663
  var init_token_estimate = __esm(() => {
4453
4664
  CODE_EXTENSIONS = new Set([
@@ -4727,342 +4938,6 @@ var init_reflect = __esm(() => {
4727
4938
  init_fs_utils();
4728
4939
  });
4729
4940
 
4730
- // src/core/agent-detect.ts
4731
- import { execSync as execSync5 } from "child_process";
4732
- import { existsSync as existsSync17 } from "fs";
4733
- import { join as join14 } from "path";
4734
- import { homedir as homedir3 } from "os";
4735
- function commandExists(bin) {
4736
- try {
4737
- const probe = process.platform === "win32" ? `where ${bin}` : `command -v ${bin}`;
4738
- execSync5(probe, { stdio: "ignore" });
4739
- return true;
4740
- } catch {
4741
- return false;
4742
- }
4743
- }
4744
- function detectAgent(meta, cwd) {
4745
- const signals = [];
4746
- if (existsSync17(join14(cwd, meta.projectDir))) {
4747
- signals.push(`project config (${meta.projectDir}/)`);
4748
- }
4749
- if (existsSync17(meta.globalDir)) {
4750
- signals.push("global config");
4751
- }
4752
- if (commandExists(meta.bin)) {
4753
- signals.push("on PATH");
4754
- }
4755
- return { ...meta, detected: signals.length > 0, signals };
4756
- }
4757
- function detectAgents(cwd) {
4758
- return AGENTS.map((m) => detectAgent(m, cwd));
4759
- }
4760
- function resolveTargetsFromFlag(flag) {
4761
- const normalized = flag.trim().toLowerCase();
4762
- if (normalized === "all")
4763
- return AGENTS.map((a) => a.id);
4764
- const ids = normalized.split(",").map((s) => s.trim()).filter(Boolean);
4765
- const valid = AGENTS.map((a) => a.id);
4766
- const resolved = ids.filter((id) => valid.includes(id));
4767
- return resolved;
4768
- }
4769
- var AGENTS;
4770
- var init_agent_detect = __esm(() => {
4771
- AGENTS = [
4772
- {
4773
- id: "claude",
4774
- label: "Claude Code",
4775
- projectDir: ".claude",
4776
- globalDir: join14(homedir3(), ".claude"),
4777
- bin: "claude"
4778
- },
4779
- {
4780
- id: "pi",
4781
- label: "Pi",
4782
- projectDir: ".pi",
4783
- globalDir: join14(homedir3(), ".pi"),
4784
- bin: "pi"
4785
- }
4786
- ];
4787
- });
4788
-
4789
- // src/core/agent-pi.ts
4790
- import { join as join15, resolve as resolve2, dirname as dirname7 } from "path";
4791
- import { existsSync as existsSync18, mkdirSync as mkdirSync8, copyFileSync, rmSync as rmSync2 } from "fs";
4792
- function piExtensionPath(cwd) {
4793
- return join15(cwd, ".pi", "extensions", "mink.ts");
4794
- }
4795
- function piGuidanceSkillPath(cwd) {
4796
- return join15(cwd, ".pi", "skills", "mink", "SKILL.md");
4797
- }
4798
- function piNoteSkillPath(cwd) {
4799
- return join15(cwd, ".pi", "skills", "mink-note", "SKILL.md");
4800
- }
4801
- function buildPiExtension(cliPath) {
4802
- const isTsSource = cliPath.endsWith(".ts");
4803
- const cmd = isTsSource ? "bun" : "mink";
4804
- const baseArgs = isTsSource ? JSON.stringify(["run", cliPath]) : "[]";
4805
- return `// AUTO-GENERATED by \`mink init\`. Do not edit \u2014 re-run \`mink init\` to refresh.
4806
- //
4807
- // Mink adapter for the Pi coding agent. Routes Pi lifecycle and tool events
4808
- // into the \`mink\` CLI so Pi shares the same ~/.mink state, file index, ledger,
4809
- // and wiki as every other assistant wired to this project.
4810
- //
4811
- // Field shapes confirmed against pi source (earendil-works/pi,
4812
- // packages/coding-agent): read params {path, offset, limit}; write {path,
4813
- // content}; edit {path, edits:[{oldText,newText}]} (with legacy file_path /
4814
- // top-level oldText,newText). tool_call/tool_result events expose toolName,
4815
- // toolCallId, input; tool_result also exposes content (a content-block array),
4816
- // details, isError. Advisories are surfaced by returning a modified result from
4817
- // the tool_result handler \u2014 the documented mechanism. pi.exec has no stdin, so
4818
- // the canonical payload is piped to \`mink\` via a spawned child process. Every
4819
- // host-API access is defensive: the adapter never throws into Pi or blocks a
4820
- // tool \u2014 a failure degrades to "no advisory".
4821
-
4822
- import { spawn } from "node:child_process";
4823
-
4824
- const MINK_CMD = ${JSON.stringify(cmd)};
4825
- const MINK_BASE_ARGS = ${baseArgs};
4826
- const TIMEOUT_MS = 5000;
4827
-
4828
- function runMink(sub, payload, cwd) {
4829
- return new Promise((res) => {
4830
- let done = false;
4831
- const finish = (out) => {
4832
- if (done) return;
4833
- done = true;
4834
- res(out);
4835
- };
4836
- try {
4837
- const child = spawn(MINK_CMD, [...MINK_BASE_ARGS, sub], {
4838
- cwd,
4839
- stdio: ["pipe", "ignore", "pipe"],
4840
- });
4841
- let stderr = "";
4842
- child.stderr?.on("data", (d) => {
4843
- stderr += d.toString();
4844
- });
4845
- child.on("error", () => finish(""));
4846
- child.on("close", () => finish(stderr.trim()));
4847
- const timer = setTimeout(() => {
4848
- try {
4849
- child.kill();
4850
- } catch {}
4851
- finish("");
4852
- }, TIMEOUT_MS);
4853
- timer.unref?.();
4854
- try {
4855
- child.stdin?.end(payload ? JSON.stringify(payload) : "");
4856
- } catch {}
4857
- } catch {
4858
- finish("");
4859
- }
4860
- });
4861
- }
4862
-
4863
- // Pi's edit tool takes an array of { oldText, newText } replacements (legacy
4864
- // inputs may put oldText/newText/new_string at the top level). Concatenate the
4865
- // replacement text so Mink's write-enforcement sees everything being written.
4866
- function editNewText(input) {
4867
- if (Array.isArray(input.edits)) {
4868
- return input.edits
4869
- .map((e) => e?.newText ?? e?.new_string ?? "")
4870
- .filter(Boolean)
4871
- .join("\\n");
4872
- }
4873
- return input.newText ?? input.new_string ?? input.replacement ?? "";
4874
- }
4875
-
4876
- // Resolve Pi's tool name + arguments to Mink's canonical operation. Only the
4877
- // three file operations matter; anything else returns null and is ignored.
4878
- function toolInfo(event) {
4879
- const name = String(event?.toolName ?? event?.tool ?? event?.name ?? "").toLowerCase();
4880
- const input = event?.input ?? event?.arguments ?? {};
4881
- const filePath = input.path ?? input.file_path ?? input.filePath;
4882
- if (!filePath) return null;
4883
- if (name === "read") return { op: "read", filePath };
4884
- if (name === "write") return { op: "write", filePath, content: input.content ?? input.text ?? "" };
4885
- if (name === "edit") return { op: "edit", filePath, newString: editNewText(input) };
4886
- return null;
4887
- }
4888
-
4889
- // A tool_result's content is an array of content blocks ({ type, text }); pull
4890
- // the text out so Mink's post-read can estimate tokens from real content.
4891
- function resultContent(event) {
4892
- const c = event?.content;
4893
- if (typeof c === "string") return c;
4894
- if (Array.isArray(c)) {
4895
- const text = c
4896
- .map((b) => (typeof b === "string" ? b : b?.text ?? ""))
4897
- .filter(Boolean)
4898
- .join("\\n");
4899
- return text || null;
4900
- }
4901
- return null;
4902
- }
4903
-
4904
- function prePayload(info) {
4905
- if (info.op === "read")
4906
- return { sub: "pre-read", payload: { tool_name: "Read", tool_input: { file_path: info.filePath } } };
4907
- if (info.op === "write")
4908
- return {
4909
- sub: "pre-write",
4910
- payload: { tool_name: "Write", tool_input: { file_path: info.filePath, content: info.content } },
4911
- };
4912
- return {
4913
- sub: "pre-write",
4914
- payload: { tool_name: "Edit", tool_input: { file_path: info.filePath, new_string: info.newString } },
4915
- };
4916
- }
4917
-
4918
- function postPayload(info, content) {
4919
- if (info.op === "read")
4920
- return {
4921
- sub: "post-read",
4922
- payload: {
4923
- tool_name: "Read",
4924
- tool_input: { file_path: info.filePath },
4925
- tool_output: content == null ? undefined : { content },
4926
- },
4927
- };
4928
- if (info.op === "write")
4929
- return {
4930
- sub: "post-write",
4931
- payload: { tool_name: "Write", tool_input: { file_path: info.filePath, content: info.content } },
4932
- };
4933
- return {
4934
- sub: "post-write",
4935
- payload: { tool_name: "Edit", tool_input: { file_path: info.filePath, new_string: info.newString } },
4936
- };
4937
- }
4938
-
4939
- export default function (pi) {
4940
- const cwd = pi?.ctx?.cwd || process.cwd();
4941
- const pending = new Map();
4942
- const keyOf = (event) => event?.toolCallId ?? event?.id ?? event?.callId ?? "";
4943
-
4944
- pi.on?.("session_start", (event) => {
4945
- // Skip hot-reloads so an extension reload mid-task doesn't reset the
4946
- // ephemeral session state; every genuinely new/resumed session starts fresh.
4947
- if (event?.reason === "reload") return;
4948
- void runMink("session-start", null, cwd);
4949
- });
4950
- pi.on?.("agent_end", () => {
4951
- void runMink("session-stop", null, cwd);
4952
- });
4953
- pi.on?.("session_shutdown", () => {
4954
- void runMink("session-stop", null, cwd);
4955
- });
4956
-
4957
- pi.on?.("tool_call", async (event) => {
4958
- const info = toolInfo(event);
4959
- if (!info) return;
4960
- const { sub, payload } = prePayload(info);
4961
- const advisory = await runMink(sub, payload, cwd);
4962
- if (advisory) pending.set(keyOf(event), advisory);
4963
- });
4964
-
4965
- pi.on?.("tool_result", async (event) => {
4966
- const info = toolInfo(event);
4967
- if (!info) return;
4968
- const { sub, payload } = postPayload(info, resultContent(event));
4969
- const post = await runMink(sub, payload, cwd);
4970
- const pre = pending.get(keyOf(event)) ?? "";
4971
- pending.delete(keyOf(event));
4972
- const advisory = [pre, post].filter(Boolean).join("\\n");
4973
- if (!advisory) return;
4974
-
4975
- // Surface Mink's advisory into the model's context by appending a text
4976
- // block to the tool result \u2014 the parity of Claude feeding hook stderr back.
4977
- const base = Array.isArray(event.content)
4978
- ? event.content
4979
- : typeof event.content === "string"
4980
- ? [{ type: "text", text: event.content }]
4981
- : [];
4982
- return {
4983
- content: [...base, { type: "text", text: advisory }],
4984
- details: event.details,
4985
- isError: event.isError,
4986
- };
4987
- });
4988
- }
4989
- `;
4990
- }
4991
- function resolveSkillsSourceDir() {
4992
- let dir = dirname7(new URL(import.meta.url).pathname);
4993
- while (true) {
4994
- if (existsSync18(join15(dir, "package.json")) && existsSync18(join15(dir, "skills"))) {
4995
- return join15(dir, "skills");
4996
- }
4997
- const parent = dirname7(dir);
4998
- if (parent === dir)
4999
- break;
5000
- dir = parent;
5001
- }
5002
- return resolve2(dirname7(new URL(import.meta.url).pathname), "../../skills");
5003
- }
5004
- function installPi(cwd, cliPath) {
5005
- const extensionPath = piExtensionPath(cwd);
5006
- mkdirSync8(dirname7(extensionPath), { recursive: true });
5007
- atomicWriteText(extensionPath, buildPiExtension(cliPath));
5008
- const guidancePath = piGuidanceSkillPath(cwd);
5009
- mkdirSync8(dirname7(guidancePath), { recursive: true });
5010
- atomicWriteText(guidancePath, PI_GUIDANCE_SKILL);
5011
- let notePath = null;
5012
- try {
5013
- const src = join15(resolveSkillsSourceDir(), "mink-note", "SKILL.md");
5014
- if (existsSync18(src)) {
5015
- notePath = piNoteSkillPath(cwd);
5016
- mkdirSync8(dirname7(notePath), { recursive: true });
5017
- copyFileSync(src, notePath);
5018
- }
5019
- } catch {
5020
- notePath = null;
5021
- }
5022
- return { extensionPath, guidancePath, notePath };
5023
- }
5024
- var PI_GUIDANCE_SKILL = `---
5025
- name: mink
5026
- description: Mink context management is active in this project. Read this to understand how Mink memory, write enforcement, and note capture work under Pi.
5027
- ---
5028
-
5029
- # Mink \u2014 context management for this project
5030
-
5031
- This project uses **Mink** (\`@drewpayment/mink\`) for cross-session context management.
5032
-
5033
- ## How it works
5034
- - Mink runs automatically through a Pi extension at \`.pi/extensions/mink.ts\` that hooks session start/stop and every read/edit/write tool call.
5035
- - All state lives in \`~/.mink/\` on the user's machine \u2014 **not** in this repository. Do not create or write to any in-repo state directory (no \`.wolf/\`, \`.mink/\`, etc.).
5036
- - Read intelligence, write enforcement, bug memory, and the token ledger are handled by the extension. You do not need to manually read or update any state files.
5037
- - Mink shares one \`~/.mink/\` state across every assistant wired to this project, so history is unified whether the user runs Pi or another assistant.
5038
-
5039
- ## When to act on Mink
5040
- - If the user asks to "save a note", "remember this", "log this to my wiki", or similar, use the \`mink-note\` skill (\`/skill:mink-note\`) \u2014 it captures into the user's \`~/.mink/\` vault.
5041
- - If the extension surfaces a learning, past bug, or repeat-read warning in context, treat that as authoritative project memory and follow it.
5042
- - The \`mink dashboard\` and \`mink agent\` commands are user tools \u2014 do not invoke them on the user's behalf.
5043
- `;
5044
- var init_agent_pi = __esm(() => {
5045
- init_fs_utils();
5046
- });
5047
-
5048
- // src/core/prompt.ts
5049
- import { createInterface } from "readline";
5050
- function stdinIsInteractive() {
5051
- const stdin = process.stdin;
5052
- const stdout = process.stdout;
5053
- return Boolean(stdin.isTTY) && Boolean(stdout.isTTY) && process.env.MINK_NO_PROMPT !== "1" && !process.env.CI;
5054
- }
5055
- function ask(question) {
5056
- return new Promise((resolve3) => {
5057
- const rl = createInterface({ input: process.stdin, output: process.stdout });
5058
- rl.question(question, (answer) => {
5059
- rl.close();
5060
- resolve3(answer);
5061
- });
5062
- });
5063
- }
5064
- var init_prompt = () => {};
5065
-
5066
4941
  // src/core/backup.ts
5067
4942
  var exports_backup = {};
5068
4943
  __export(exports_backup, {
@@ -5071,14 +4946,14 @@ __export(exports_backup, {
5071
4946
  createBackup: () => createBackup
5072
4947
  });
5073
4948
  import {
5074
- mkdirSync as mkdirSync9,
4949
+ mkdirSync as mkdirSync8,
5075
4950
  readdirSync as readdirSync7,
5076
4951
  readFileSync as readFileSync12,
5077
4952
  writeFileSync as writeFileSync5,
5078
- existsSync as existsSync19,
4953
+ existsSync as existsSync17,
5079
4954
  statSync as statSync7
5080
4955
  } from "fs";
5081
- import { join as join16 } from "path";
4956
+ import { join as join14 } from "path";
5082
4957
  function formatTimestamp(date) {
5083
4958
  const y = date.getFullYear();
5084
4959
  const mo = String(date.getMonth() + 1).padStart(2, "0");
@@ -5090,15 +4965,15 @@ function formatTimestamp(date) {
5090
4965
  return `${y}${mo}${d}-${h}${mi}${s}${ms}`;
5091
4966
  }
5092
4967
  function copyDirectoryFiles(srcDir, destDir, excludeDirs) {
5093
- mkdirSync9(destDir, { recursive: true });
4968
+ mkdirSync8(destDir, { recursive: true });
5094
4969
  const entries = readdirSync7(srcDir, { withFileTypes: true });
5095
4970
  for (const entry of entries) {
5096
4971
  if (entry.isDirectory()) {
5097
4972
  if (excludeDirs.includes(entry.name))
5098
4973
  continue;
5099
- copyDirectoryFiles(join16(srcDir, entry.name), join16(destDir, entry.name), excludeDirs);
4974
+ copyDirectoryFiles(join14(srcDir, entry.name), join14(destDir, entry.name), excludeDirs);
5100
4975
  } else if (entry.isFile()) {
5101
- writeFileSync5(join16(destDir, entry.name), readFileSync12(join16(srcDir, entry.name)));
4976
+ writeFileSync5(join14(destDir, entry.name), readFileSync12(join14(srcDir, entry.name)));
5102
4977
  }
5103
4978
  }
5104
4979
  }
@@ -5107,25 +4982,25 @@ function createBackup(cwd) {
5107
4982
  const dir = backupDirPath(cwd);
5108
4983
  let name = base;
5109
4984
  let suffix = 1;
5110
- while (existsSync19(join16(dir, name))) {
4985
+ while (existsSync17(join14(dir, name))) {
5111
4986
  name = `${base}-${suffix}`;
5112
4987
  suffix++;
5113
4988
  }
5114
4989
  const src = projectDir(cwd);
5115
- const dest = join16(dir, name);
4990
+ const dest = join14(dir, name);
5116
4991
  copyDirectoryFiles(src, dest, ["backups"]);
5117
4992
  return name;
5118
4993
  }
5119
4994
  function listBackups(cwd) {
5120
4995
  const dir = backupDirPath(cwd);
5121
- if (!existsSync19(dir))
4996
+ if (!existsSync17(dir))
5122
4997
  return [];
5123
4998
  const entries = readdirSync7(dir, { withFileTypes: true });
5124
4999
  const backups = [];
5125
5000
  for (const entry of entries) {
5126
5001
  if (!entry.isDirectory() || !entry.name.startsWith("backup-"))
5127
5002
  continue;
5128
- const backupPath = join16(dir, entry.name);
5003
+ const backupPath = join14(dir, entry.name);
5129
5004
  const match = entry.name.match(/^backup-(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})(\d{3})?(?:-\d+)?$/);
5130
5005
  let timestamp;
5131
5006
  if (match) {
@@ -5148,8 +5023,8 @@ function listBackups(cwd) {
5148
5023
  return backups;
5149
5024
  }
5150
5025
  function restoreBackup(cwd, backupName) {
5151
- const backupPath = join16(backupDirPath(cwd), backupName);
5152
- if (!existsSync19(backupPath)) {
5026
+ const backupPath = join14(backupDirPath(cwd), backupName);
5027
+ if (!existsSync17(backupPath)) {
5153
5028
  throw new Error(`backup not found: ${backupName}`);
5154
5029
  }
5155
5030
  createBackup(cwd);
@@ -5161,7 +5036,7 @@ var init_backup = __esm(() => {
5161
5036
 
5162
5037
  // src/core/scanner.ts
5163
5038
  import { readdirSync as readdirSync8, statSync as statSync8 } from "fs";
5164
- import { join as join17, relative } from "path";
5039
+ import { join as join15, relative } from "path";
5165
5040
  function matchesPattern(name, pattern) {
5166
5041
  if (pattern.includes("*")) {
5167
5042
  const regex = new RegExp("^" + pattern.replace(/\./g, "\\.").replace(/\*/g, ".*") + "$");
@@ -5185,14 +5060,14 @@ function walkDirectory(dir, projectRoot, excludes, results) {
5185
5060
  if (entry.isDirectory()) {
5186
5061
  if (isExcluded(entry.name, excludes))
5187
5062
  continue;
5188
- walkDirectory(join17(dir, entry.name), projectRoot, excludes, results);
5063
+ walkDirectory(join15(dir, entry.name), projectRoot, excludes, results);
5189
5064
  continue;
5190
5065
  }
5191
5066
  if (entry.isFile()) {
5192
5067
  if (isExcluded(entry.name, excludes))
5193
5068
  continue;
5194
5069
  try {
5195
- const fullPath = join17(dir, entry.name);
5070
+ const fullPath = join15(dir, entry.name);
5196
5071
  const stat = statSync8(fullPath);
5197
5072
  results.push({
5198
5073
  relativePath: relative(projectRoot, fullPath),
@@ -5615,7 +5490,7 @@ __export(exports_scan, {
5615
5490
  });
5616
5491
  import { readFileSync as readFileSync13 } from "fs";
5617
5492
  import { createHash as createHash2 } from "crypto";
5618
- import { join as join18, relative as relative2 } from "path";
5493
+ import { join as join16, relative as relative2 } from "path";
5619
5494
  function configRelativePath(cfgPath, cwd) {
5620
5495
  const rel = relative2(cwd, cfgPath);
5621
5496
  return rel.startsWith("..") ? cfgPath : rel;
@@ -5666,7 +5541,7 @@ function scan(cwd, options) {
5666
5541
  if (!stalePaths.has(file.relativePath)) {
5667
5542
  continue;
5668
5543
  }
5669
- const fullPath = join18(cwd, file.relativePath);
5544
+ const fullPath = join16(cwd, file.relativePath);
5670
5545
  let content;
5671
5546
  try {
5672
5547
  content = readFileSync13(fullPath, "utf-8");
@@ -5755,10 +5630,10 @@ __export(exports_seed, {
5755
5630
  parseGoMod: () => parseGoMod,
5756
5631
  parseCargoToml: () => parseCargoToml
5757
5632
  });
5758
- import { basename as basename4, join as join19 } from "path";
5759
- import { readFileSync as readFileSync14, existsSync as existsSync20 } from "fs";
5633
+ import { basename as basename4, join as join17 } from "path";
5634
+ import { readFileSync as readFileSync14, existsSync as existsSync18 } from "fs";
5760
5635
  function readFile(filePath) {
5761
- if (!existsSync20(filePath))
5636
+ if (!existsSync18(filePath))
5762
5637
  return null;
5763
5638
  try {
5764
5639
  return readFileSync14(filePath, "utf-8");
@@ -5851,10 +5726,10 @@ function parseGoMod(filePath) {
5851
5726
  }
5852
5727
  function seedLearningMemory(projectRoot) {
5853
5728
  const parsers = [
5854
- () => parsePackageJson(join19(projectRoot, "package.json")),
5855
- () => parsePyprojectToml(join19(projectRoot, "pyproject.toml")),
5856
- () => parseCargoToml(join19(projectRoot, "Cargo.toml")),
5857
- () => parseGoMod(join19(projectRoot, "go.mod"))
5729
+ () => parsePackageJson(join17(projectRoot, "package.json")),
5730
+ () => parsePyprojectToml(join17(projectRoot, "pyproject.toml")),
5731
+ () => parseCargoToml(join17(projectRoot, "Cargo.toml")),
5732
+ () => parseGoMod(join17(projectRoot, "go.mod"))
5858
5733
  ];
5859
5734
  const infos = parsers.map((fn) => fn()).filter((info) => info !== null);
5860
5735
  const projectName = infos.find((i) => i.projectName)?.projectName ?? basename4(projectRoot);
@@ -5932,37 +5807,34 @@ var init_seed = __esm(() => {
5932
5807
  var exports_init = {};
5933
5808
  __export(exports_init, {
5934
5809
  writeMinkRule: () => writeMinkRule,
5935
- resolveTargetsFromFlag: () => resolveTargetsFromFlag,
5936
- resolveTargets: () => resolveTargets,
5937
5810
  resolveCliPathFrom: () => resolveCliPathFrom,
5938
5811
  resolveCliPath: () => resolveCliPath,
5939
5812
  mergeHooksIntoSettings: () => mergeHooksIntoSettings,
5940
- installClaude: () => installClaude,
5941
5813
  init: () => init,
5942
5814
  detectRuntime: () => detectRuntime,
5943
5815
  buildHooksConfig: () => buildHooksConfig
5944
5816
  });
5945
- import { execSync as execSync6 } from "child_process";
5946
- import { mkdirSync as mkdirSync10, existsSync as existsSync21 } from "fs";
5947
- import { resolve as resolve3, dirname as dirname8, basename as basename5, join as join20 } from "path";
5817
+ import { execSync as execSync5 } from "child_process";
5818
+ import { mkdirSync as mkdirSync9, existsSync as existsSync19 } from "fs";
5819
+ import { resolve as resolve2, dirname as dirname7, basename as basename5, join as join18 } from "path";
5948
5820
  function detectRuntime() {
5949
5821
  try {
5950
- execSync6("bun --version", { stdio: "ignore" });
5822
+ execSync5("bun --version", { stdio: "ignore" });
5951
5823
  return "bun";
5952
5824
  } catch {
5953
5825
  return "node";
5954
5826
  }
5955
5827
  }
5956
5828
  function resolveCliPathFrom(selfPath) {
5957
- const selfDir = dirname8(selfPath);
5829
+ const selfDir = dirname7(selfPath);
5958
5830
  if (selfPath.endsWith("dist/cli.js") || selfPath.endsWith("dist/cli.bun.js") || selfPath.endsWith("dist/cli.node.js")) {
5959
- return join20(selfDir, "cli.js");
5831
+ return join18(selfDir, "cli.js");
5960
5832
  }
5961
- const packageRoot = resolve3(selfDir, "..", "..");
5962
- const distShim = join20(packageRoot, "dist", "cli.js");
5963
- if (existsSync21(distShim))
5833
+ const packageRoot = resolve2(selfDir, "..", "..");
5834
+ const distShim = join18(packageRoot, "dist", "cli.js");
5835
+ if (existsSync19(distShim))
5964
5836
  return distShim;
5965
- return join20(packageRoot, "src", "cli.ts");
5837
+ return join18(packageRoot, "src", "cli.ts");
5966
5838
  }
5967
5839
  function resolveCliPath() {
5968
5840
  return resolveCliPathFrom(new URL(import.meta.url).pathname);
@@ -5982,12 +5854,14 @@ function buildHooksConfig(cliPath) {
5982
5854
  PostToolUse: [
5983
5855
  { matcher: "Read", hooks: hook(`${prefix} post-read`) },
5984
5856
  { matcher: "Edit", hooks: hook(`${prefix} post-write`) },
5985
- { matcher: "Write", hooks: hook(`${prefix} post-write`) }
5857
+ { matcher: "Write", hooks: hook(`${prefix} post-write`) },
5858
+ { matcher: "Bash", hooks: hook(`${prefix} post-tool`) },
5859
+ { matcher: "Grep", hooks: hook(`${prefix} post-tool`) }
5986
5860
  ]
5987
5861
  };
5988
5862
  }
5989
5863
  function isMinkCommand(cmd) {
5990
- const hasMinkSubcommand = cmd.includes("session-start") || cmd.includes("session-stop") || cmd.includes("pre-read") || cmd.includes("post-read") || cmd.includes("pre-write") || cmd.includes("post-write");
5864
+ const hasMinkSubcommand = cmd.includes("session-start") || cmd.includes("session-stop") || cmd.includes("pre-read") || cmd.includes("post-read") || cmd.includes("pre-write") || cmd.includes("post-write") || cmd.includes("post-tool");
5991
5865
  if (!hasMinkSubcommand)
5992
5866
  return false;
5993
5867
  if (/(^|\/|\s)mink\s/.test(cmd))
@@ -6004,13 +5878,13 @@ function isMinkHook(entry) {
6004
5878
  return false;
6005
5879
  }
6006
5880
  function writeMinkRule(cwd) {
6007
- const rulePath = resolve3(cwd, ".claude", "rules", "mink.md");
6008
- mkdirSync10(dirname8(rulePath), { recursive: true });
5881
+ const rulePath = resolve2(cwd, ".claude", "rules", "mink.md");
5882
+ mkdirSync9(dirname7(rulePath), { recursive: true });
6009
5883
  atomicWriteText(rulePath, MINK_RULE_CONTENT);
6010
5884
  return rulePath;
6011
5885
  }
6012
5886
  function mergeHooksIntoSettings(settingsPath, newHooks) {
6013
- mkdirSync10(dirname8(settingsPath), { recursive: true });
5887
+ mkdirSync9(dirname7(settingsPath), { recursive: true });
6014
5888
  const existing = safeReadJson(settingsPath) ?? {};
6015
5889
  const existingHooks = existing.hooks ?? {};
6016
5890
  for (const [event, entries] of Object.entries(newHooks)) {
@@ -6021,46 +5895,17 @@ function mergeHooksIntoSettings(settingsPath, newHooks) {
6021
5895
  existing.hooks = existingHooks;
6022
5896
  atomicWriteJson(settingsPath, existing);
6023
5897
  }
6024
- function installClaude(cwd, cliPath) {
6025
- const settingsPath = resolve3(cwd, ".claude", "settings.json");
6026
- mergeHooksIntoSettings(settingsPath, buildHooksConfig(cliPath));
6027
- const rulePath = writeMinkRule(cwd);
6028
- return { settingsPath, rulePath };
6029
- }
6030
- async function resolveTargets(cwd, opts) {
6031
- if (opts.targets && opts.targets.length > 0)
6032
- return opts.targets;
6033
- const detected = detectAgents(cwd);
6034
- const detectedIds = detected.filter((a) => a.detected).map((a) => a.id);
6035
- if (opts.interactive && stdinIsInteractive()) {
6036
- return promptForAgents(detected, detectedIds);
6037
- }
6038
- return detectedIds.length > 0 ? detectedIds : ["claude"];
6039
- }
6040
- async function promptForAgents(detected, defaults) {
6041
- const fallback = defaults.length > 0 ? defaults : ["claude"];
6042
- console.log("Which assistant(s) should Mink work with?");
6043
- detected.forEach((a, i) => {
6044
- const tag = a.detected ? ` (detected \u2014 ${a.signals.join(", ")})` : "";
6045
- console.log(` ${i + 1}) ${a.label}${tag}`);
6046
- });
6047
- const answer = (await ask(`Enter numbers (comma-separated), 'a' for all [default: ${fallback.join(", ")}]: `)).trim().toLowerCase();
6048
- if (answer === "")
6049
- return fallback;
6050
- if (answer === "a" || answer === "all")
6051
- return AGENTS.map((a) => a.id);
6052
- const picked = answer.split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => Number.isInteger(n) && n >= 1 && n <= detected.length).map((n) => detected[n - 1].id);
6053
- return picked.length > 0 ? picked : fallback;
6054
- }
6055
5898
  function isExistingInstallation(cwd) {
6056
5899
  const dir = projectDir(cwd);
6057
- if (!existsSync21(dir))
5900
+ if (!existsSync19(dir))
6058
5901
  return false;
6059
- return existsSync21(join20(dir, "file-index.json"));
5902
+ return existsSync19(join18(dir, "file-index.json"));
6060
5903
  }
6061
- async function init(cwd, opts = {}) {
5904
+ async function init(cwd) {
6062
5905
  const runtime = detectRuntime();
6063
5906
  const cliPath = resolveCliPath();
5907
+ const hooks = buildHooksConfig(cliPath);
5908
+ const settingsPath = resolve2(cwd, ".claude", "settings.json");
6064
5909
  const dir = projectDir(cwd);
6065
5910
  const upgrading = isExistingInstallation(cwd);
6066
5911
  if (upgrading) {
@@ -6069,22 +5914,9 @@ async function init(cwd, opts = {}) {
6069
5914
  const backupName = createBackup2(cwd);
6070
5915
  console.log(` backup: ${backupName}`);
6071
5916
  }
6072
- const targets = await resolveTargets(cwd, opts);
6073
- const wired = {};
6074
- for (const target of targets) {
6075
- if (target === "claude") {
6076
- const { settingsPath, rulePath } = installClaude(cwd, cliPath);
6077
- wired.claude = [`hooks: ${settingsPath}`, `rule: ${rulePath}`];
6078
- } else if (target === "pi") {
6079
- const r = installPi(cwd, cliPath);
6080
- wired.pi = [
6081
- `extension: ${r.extensionPath}`,
6082
- `guidance: ${r.guidancePath}`,
6083
- ...r.notePath ? [`note skill: ${r.notePath}`] : []
6084
- ];
6085
- }
6086
- }
6087
- mkdirSync10(dir, { recursive: true });
5917
+ mergeHooksIntoSettings(settingsPath, hooks);
5918
+ const rulePath = writeMinkRule(cwd);
5919
+ mkdirSync9(dir, { recursive: true });
6088
5920
  const identity = resolveProjectIdentity(cwd);
6089
5921
  const projectId = identity.id;
6090
5922
  const isNotesProject = isWikiEnabled() && isVaultInitialized() && isInsideVault(cwd);
@@ -6092,8 +5924,6 @@ async function init(cwd, opts = {}) {
6092
5924
  const existingMeta = safeReadJson(metaPath);
6093
5925
  const deviceId = getOrCreateDeviceId();
6094
5926
  const existingPathsByDevice = existingMeta?.pathsByDevice && typeof existingMeta.pathsByDevice === "object" && !Array.isArray(existingMeta.pathsByDevice) ? existingMeta.pathsByDevice : {};
6095
- const priorAgents = Array.isArray(existingMeta?.agents) ? existingMeta.agents : [];
6096
- const agents = Array.from(new Set([...priorAgents, ...targets]));
6097
5927
  atomicWriteJson(metaPath, {
6098
5928
  ...existingMeta ?? {},
6099
5929
  cwd,
@@ -6101,29 +5931,20 @@ async function init(cwd, opts = {}) {
6101
5931
  initTimestamp: existingMeta?.initTimestamp ?? new Date().toISOString(),
6102
5932
  version: "0.1.0",
6103
5933
  pathsByDevice: { ...existingPathsByDevice, [deviceId]: cwd },
6104
- agents,
6105
5934
  ...isNotesProject ? { projectType: "notes" } : {}
6106
5935
  });
6107
- const printWiring = () => {
6108
- for (const id of Object.keys(wired)) {
6109
- const label = AGENTS.find((a) => a.id === id)?.label ?? id;
6110
- console.log(` ${label}:`);
6111
- for (const line of wired[id])
6112
- console.log(` ${line}`);
6113
- }
6114
- };
6115
5936
  if (upgrading) {
6116
5937
  console.log(`[mink] upgrade complete`);
6117
5938
  console.log(` project: ${projectId}`);
6118
- console.log(` agents: ${agents.join(", ")}`);
6119
- printWiring();
5939
+ console.log(` hooks: ${settingsPath}`);
5940
+ console.log(` rule: ${rulePath}`);
6120
5941
  } else {
6121
5942
  console.log(`[mink] initialized`);
6122
5943
  console.log(` project: ${projectId} (${identity.source})`);
6123
5944
  console.log(` state: ${dir}`);
6124
5945
  console.log(` runtime: ${runtime}`);
6125
- console.log(` agents: ${agents.join(", ")}`);
6126
- printWiring();
5946
+ console.log(` hooks: ${settingsPath}`);
5947
+ console.log(` rule: ${rulePath}`);
6127
5948
  }
6128
5949
  if (identity.source === "path-derived") {
6129
5950
  const root = getRepoRoot(cwd);
@@ -6135,7 +5956,7 @@ async function init(cwd, opts = {}) {
6135
5956
  scan2(cwd, { check: false });
6136
5957
  const { learningMemoryPath: learningMemoryPath2 } = await Promise.resolve().then(() => (init_paths(), exports_paths));
6137
5958
  const memPath = learningMemoryPath2(cwd);
6138
- if (!existsSync21(memPath)) {
5959
+ if (!existsSync19(memPath)) {
6139
5960
  const { seedLearningMemory: seedLearningMemory2 } = await Promise.resolve().then(() => (init_seed(), exports_seed));
6140
5961
  const { serializeLearningMemory: serializeLearningMemory2 } = await Promise.resolve().then(() => (init_learning_memory(), exports_learning_memory));
6141
5962
  const mem = seedLearningMemory2(cwd);
@@ -6144,8 +5965,8 @@ async function init(cwd, opts = {}) {
6144
5965
  if (isWikiEnabled() && isVaultInitialized() && !isNotesProject) {
6145
5966
  try {
6146
5967
  const projectSlug = basename5(cwd);
6147
- const overviewPath = join20(vaultProjects(projectSlug), "overview.md");
6148
- if (!existsSync21(overviewPath)) {
5968
+ const overviewPath = join18(vaultProjects(projectSlug), "overview.md");
5969
+ if (!existsSync19(overviewPath)) {
6149
5970
  const now = new Date().toISOString();
6150
5971
  const overview = [
6151
5972
  `---`,
@@ -6197,9 +6018,6 @@ var init_init = __esm(() => {
6197
6018
  init_device();
6198
6019
  init_git_identity();
6199
6020
  init_vault();
6200
- init_agent_detect();
6201
- init_agent_pi();
6202
- init_prompt();
6203
6021
  });
6204
6022
 
6205
6023
  // src/repositories/counters-repo.ts
@@ -6274,12 +6092,12 @@ var init_state_counters = __esm(() => {
6274
6092
  });
6275
6093
 
6276
6094
  // src/core/channel-templates.ts
6277
- import { join as join21 } from "path";
6278
- import { existsSync as existsSync22, writeFileSync as writeFileSync6, mkdirSync as mkdirSync11 } from "fs";
6095
+ import { join as join19 } from "path";
6096
+ import { existsSync as existsSync20, writeFileSync as writeFileSync6, mkdirSync as mkdirSync10 } from "fs";
6279
6097
  function writeCompanionClaudeMd(vaultPath, overwrite = false) {
6280
- mkdirSync11(vaultPath, { recursive: true });
6281
- const claudeMdPath = join21(vaultPath, "CLAUDE.md");
6282
- if (existsSync22(claudeMdPath) && !overwrite) {
6098
+ mkdirSync10(vaultPath, { recursive: true });
6099
+ const claudeMdPath = join19(vaultPath, "CLAUDE.md");
6100
+ if (existsSync20(claudeMdPath) && !overwrite) {
6283
6101
  return false;
6284
6102
  }
6285
6103
  writeFileSync6(claudeMdPath, COMPANION_CLAUDE_MD);
@@ -6431,8 +6249,8 @@ mink wiki rebuild-index
6431
6249
  var init_channel_templates = () => {};
6432
6250
 
6433
6251
  // src/core/channel-process.ts
6434
- import { readFileSync as readFileSync15, writeFileSync as writeFileSync7, unlinkSync as unlinkSync3, mkdirSync as mkdirSync12, existsSync as existsSync23 } from "fs";
6435
- import { dirname as dirname9, join as join22 } from "path";
6252
+ import { readFileSync as readFileSync15, writeFileSync as writeFileSync7, unlinkSync as unlinkSync3, mkdirSync as mkdirSync11, existsSync as existsSync21 } from "fs";
6253
+ import { dirname as dirname8, join as join20 } from "path";
6436
6254
  import { spawnSync } from "child_process";
6437
6255
  function readChannelPidFile() {
6438
6256
  try {
@@ -6448,7 +6266,7 @@ function readChannelPidFile() {
6448
6266
  }
6449
6267
  function writeChannelPidFile(data) {
6450
6268
  const pidPath = channelPidPath();
6451
- mkdirSync12(dirname9(pidPath), { recursive: true });
6269
+ mkdirSync11(dirname8(pidPath), { recursive: true });
6452
6270
  writeFileSync7(pidPath, JSON.stringify(data, null, 2));
6453
6271
  }
6454
6272
  function removeChannelPidFile() {
@@ -6578,12 +6396,12 @@ function getChannelLogs() {
6578
6396
  return null;
6579
6397
  if (!screenSessionExists(pidData.session))
6580
6398
  return null;
6581
- const tmpPath = join22(minkRoot(), `.channel-capture-${Date.now()}-${process.pid}.txt`);
6399
+ const tmpPath = join20(minkRoot(), `.channel-capture-${Date.now()}-${process.pid}.txt`);
6582
6400
  const result = spawnSync("screen", ["-S", pidData.session, "-X", "hardcopy", "-h", tmpPath], { stdio: "ignore" });
6583
6401
  if (result.status !== 0)
6584
6402
  return null;
6585
6403
  for (let i = 0;i < 20; i++) {
6586
- if (existsSync23(tmpPath))
6404
+ if (existsSync21(tmpPath))
6587
6405
  break;
6588
6406
  const delayUntil = Date.now() + 50;
6589
6407
  while (Date.now() < delayUntil) {}
@@ -6687,7 +6505,7 @@ async function runtimeServe(opts) {
6687
6505
  }
6688
6506
  const { createServer } = await import("http");
6689
6507
  const { Readable } = await import("stream");
6690
- return new Promise((resolve4) => {
6508
+ return new Promise((resolve3) => {
6691
6509
  const httpServer = createServer(async (req, res) => {
6692
6510
  const url = `http://${opts.hostname}:${opts.port}${req.url ?? "/"}`;
6693
6511
  const headers = new Headers;
@@ -6746,7 +6564,7 @@ async function runtimeServe(opts) {
6746
6564
  httpServer.listen(opts.port, opts.hostname, () => {
6747
6565
  const addr = httpServer.address();
6748
6566
  const boundPort = typeof addr === "object" && addr ? addr.port : opts.port;
6749
- resolve4({
6567
+ resolve3({
6750
6568
  port: boundPort,
6751
6569
  stop: (close) => {
6752
6570
  if (close)
@@ -6764,8 +6582,8 @@ var init_runtime = __esm(() => {
6764
6582
 
6765
6583
  // src/core/daemon.ts
6766
6584
  import { readFileSync as readFileSync16, writeFileSync as writeFileSync8, unlinkSync as unlinkSync4, openSync } from "fs";
6767
- import { mkdirSync as mkdirSync13 } from "fs";
6768
- import { dirname as dirname10, resolve as resolve4 } from "path";
6585
+ import { mkdirSync as mkdirSync12 } from "fs";
6586
+ import { dirname as dirname9, resolve as resolve3 } from "path";
6769
6587
  function readPidFile() {
6770
6588
  try {
6771
6589
  const raw = readFileSync16(schedulerPidPath(), "utf-8");
@@ -6780,7 +6598,7 @@ function readPidFile() {
6780
6598
  }
6781
6599
  function writePidFile(data) {
6782
6600
  const pidPath = schedulerPidPath();
6783
- mkdirSync13(dirname10(pidPath), { recursive: true });
6601
+ mkdirSync12(dirname9(pidPath), { recursive: true });
6784
6602
  writeFileSync8(pidPath, JSON.stringify(data, null, 2));
6785
6603
  }
6786
6604
  function removePidFile() {
@@ -6805,10 +6623,10 @@ function startDaemon(cwd) {
6805
6623
  if (existing) {
6806
6624
  removePidFile();
6807
6625
  }
6808
- const __dir = dirname10(new URL(import.meta.url).pathname);
6809
- const cliPath = process.argv[1] ?? resolve4(__dir, "../cli.ts");
6626
+ const __dir = dirname9(new URL(import.meta.url).pathname);
6627
+ const cliPath = process.argv[1] ?? resolve3(__dir, "../cli.ts");
6810
6628
  const logPath = schedulerLogPath();
6811
- mkdirSync13(dirname10(logPath), { recursive: true });
6629
+ mkdirSync12(dirname9(logPath), { recursive: true });
6812
6630
  const logFd = openSync(logPath, "a");
6813
6631
  const proc = runtimeSpawn(["bun", "run", cliPath, "cron", "__daemon"], {
6814
6632
  cwd,
@@ -6922,9 +6740,9 @@ var exports_status = {};
6922
6740
  __export(exports_status, {
6923
6741
  status: () => status
6924
6742
  });
6925
- import { existsSync as existsSync25, readFileSync as readFileSync17, statSync as statSync9 } from "fs";
6743
+ import { existsSync as existsSync23, readFileSync as readFileSync17, statSync as statSync9 } from "fs";
6926
6744
  function checkJsonFile(name, filePath, validator) {
6927
- if (!existsSync25(filePath))
6745
+ if (!existsSync23(filePath))
6928
6746
  return { name, path: filePath, status: "missing" };
6929
6747
  const data = safeReadJson(filePath);
6930
6748
  if (data === null)
@@ -6934,7 +6752,7 @@ function checkJsonFile(name, filePath, validator) {
6934
6752
  return { name, path: filePath, status: "ok" };
6935
6753
  }
6936
6754
  function checkDbFile(name, filePath) {
6937
- if (!existsSync25(filePath))
6755
+ if (!existsSync23(filePath))
6938
6756
  return { name, path: filePath, status: "missing" };
6939
6757
  try {
6940
6758
  const header = readFileSync17(filePath).slice(0, 16).toString("utf-8");
@@ -6949,7 +6767,7 @@ function checkDbFile(name, filePath) {
6949
6767
  function checkShardedText(name, candidatePaths) {
6950
6768
  const canonical = candidatePaths[0];
6951
6769
  for (const p of candidatePaths) {
6952
- if (!existsSync25(p))
6770
+ if (!existsSync23(p))
6953
6771
  continue;
6954
6772
  try {
6955
6773
  if (statSync9(p).size === 0)
@@ -7024,7 +6842,12 @@ function status(cwd) {
7024
6842
  console.log(` Sessions: ${lt.totalSessions}`);
7025
6843
  console.log(` Total tokens: ${lt.totalTokens.toLocaleString()}`);
7026
6844
  console.log(` Reads: ${lt.totalReads} Writes: ${lt.totalWrites}`);
7027
- console.log(` Estimated savings: ${lt.totalEstimatedSavings.toLocaleString()} tokens`);
6845
+ console.log(` Estimated savings (heuristic): ${lt.totalEstimatedSavings.toLocaleString()} tokens`);
6846
+ const comp = ledger.compression;
6847
+ if (comp && comp.totalEvents > 0) {
6848
+ const ratio = comp.totalOriginalTokens > 0 ? Math.round(comp.totalMeasuredSavings / comp.totalOriginalTokens * 100) : 0;
6849
+ console.log(` Measured compression savings: ${comp.totalMeasuredSavings.toLocaleString()} tokens` + ` (${ratio}% over ${comp.totalEvents} event${comp.totalEvents === 1 ? "" : "s"}` + `, ${comp.totalHoldoutEvents} held out)`);
6850
+ }
7028
6851
  } catch {
7029
6852
  console.log(" Token ledger: error reading");
7030
6853
  }
@@ -7042,7 +6865,7 @@ function status(cwd) {
7042
6865
  console.log(` Decision Log: ${mem.sections["Decision Log"].length}`);
7043
6866
  console.log(` Total entries: ${total}`);
7044
6867
  const memPath = learningMemoryPath(cwd);
7045
- if (existsSync25(memPath)) {
6868
+ if (existsSync23(memPath)) {
7046
6869
  const mtime = statSync9(memPath).mtime;
7047
6870
  console.log(` Canonical last modified: ${mtime.toISOString()}`);
7048
6871
  }
@@ -7177,6 +7000,488 @@ var init_pre_read = __esm(() => {
7177
7000
  init_counters_repo();
7178
7001
  });
7179
7002
 
7003
+ // src/core/compression.ts
7004
+ function numberValue(key, fallback, min, max) {
7005
+ const raw = resolveConfigValue(key).value;
7006
+ const n = Number(raw);
7007
+ if (!Number.isFinite(n))
7008
+ return fallback;
7009
+ return Math.min(max, Math.max(min, n));
7010
+ }
7011
+ function loadCompressionConfig() {
7012
+ return {
7013
+ enabled: resolveConfigValue("compression.enabled").value === "true",
7014
+ thresholdTokens: numberValue("compression.threshold-tokens", 800, 0, Number.MAX_SAFE_INTEGER),
7015
+ minSavingsRatio: numberValue("compression.min-savings-ratio", 0.25, 0, 1),
7016
+ holdoutFraction: numberValue("compression.holdout-fraction", 0.1, 0, 1),
7017
+ retentionHours: numberValue("compression.retention-hours", 168, 0, Number.MAX_SAFE_INTEGER)
7018
+ };
7019
+ }
7020
+ function isEligible(originalTokens, config) {
7021
+ return config.enabled && originalTokens >= config.thresholdTokens;
7022
+ }
7023
+ function meetsMinSavings(originalTokens, compressedTokens, config) {
7024
+ if (originalTokens <= 0)
7025
+ return false;
7026
+ const ratio = (originalTokens - compressedTokens) / originalTokens;
7027
+ return ratio >= config.minSavingsRatio;
7028
+ }
7029
+ function hashUnitInterval(key) {
7030
+ let h = 2166136261;
7031
+ for (let i = 0;i < key.length; i++) {
7032
+ h ^= key.charCodeAt(i);
7033
+ h = Math.imul(h, 16777619);
7034
+ }
7035
+ return (h >>> 0) / 4294967296;
7036
+ }
7037
+ function selectHoldout(eventKey, fraction) {
7038
+ if (fraction <= 0)
7039
+ return false;
7040
+ if (fraction >= 1)
7041
+ return true;
7042
+ return hashUnitInterval(eventKey) < fraction;
7043
+ }
7044
+ var init_compression = __esm(() => {
7045
+ init_global_config();
7046
+ });
7047
+
7048
+ // src/core/code-skeleton.ts
7049
+ function countChar(s, c) {
7050
+ let n = 0;
7051
+ for (let i = 0;i < s.length; i++)
7052
+ if (s[i] === c)
7053
+ n++;
7054
+ return n;
7055
+ }
7056
+ function netBraces(line) {
7057
+ let s = line.replace(/\/\/.*$/, "");
7058
+ s = s.replace(/\/\*.*?\*\//g, "");
7059
+ s = s.replace(/"(?:\\.|[^"\\])*"/g, '""');
7060
+ s = s.replace(/'(?:\\.|[^'\\])*'/g, "''");
7061
+ s = s.replace(/`(?:\\.|[^`\\])*`/g, "``");
7062
+ return countChar(s, "{") - countChar(s, "}");
7063
+ }
7064
+ function stripOpenBrace(sig) {
7065
+ return sig.replace(/\{\s*$/, "").trimEnd();
7066
+ }
7067
+ function extractCodeSkeleton(content, opts = {}) {
7068
+ const rawLines = content.split(`
7069
+ `);
7070
+ const totalLines = rawLines.length > 0 && rawLines[rawLines.length - 1] === "" ? rawLines.length - 1 : rawLines.length;
7071
+ const out = [];
7072
+ let depth = 0;
7073
+ let suppress = Infinity;
7074
+ for (const line of rawLines) {
7075
+ if (out.length >= MAX_SIGNATURES)
7076
+ break;
7077
+ const start = depth;
7078
+ const net = netBraces(line);
7079
+ if (start < suppress) {
7080
+ const isHeading = opts.markdown === true && HEADING.test(line);
7081
+ const captured = isHeading || DECL_ALWAYS.test(line) || DECL_EXPORTED_VAR.test(line) || start >= 1 && MEMBER.test(line);
7082
+ if (captured) {
7083
+ const sig = line.trim();
7084
+ if (net > 0) {
7085
+ if (DESCEND.test(line) && !isHeading) {
7086
+ out.push(INDENT.repeat(start) + stripOpenBrace(sig) + " {");
7087
+ } else {
7088
+ out.push(INDENT.repeat(start) + stripOpenBrace(sig) + " { \u2026 }");
7089
+ suppress = start + 1;
7090
+ }
7091
+ } else {
7092
+ out.push(INDENT.repeat(start) + sig);
7093
+ }
7094
+ }
7095
+ }
7096
+ depth = Math.max(0, depth + net);
7097
+ if (depth < suppress)
7098
+ suppress = Infinity;
7099
+ }
7100
+ if (out.length === 0)
7101
+ return null;
7102
+ return { lines: out, totalLines };
7103
+ }
7104
+ var MAX_SIGNATURES = 80, INDENT = " ", DECL_ALWAYS, DECL_EXPORTED_VAR, MEMBER, HEADING, DESCEND;
7105
+ var init_code_skeleton = __esm(() => {
7106
+ DECL_ALWAYS = /^\s*(?:export\s+)?(?:default\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|interface|type|enum|namespace|module|def|fn|func|impl|struct|trait)\b/;
7107
+ DECL_EXPORTED_VAR = /^\s*export\s+(?:default\s+)?(?:const|let|var)\b/;
7108
+ MEMBER = /^\s*(?:public\s+|private\s+|protected\s+|readonly\s+|static\s+|async\s+|get\s+|set\s+|#)*[\w$]+\??\s*(?:\(|:|=)/;
7109
+ HEADING = /^#{1,6}\s+\S/;
7110
+ DESCEND = /\b(?:class|interface|enum|namespace|module|struct|trait|impl)\b/;
7111
+ });
7112
+
7113
+ // src/core/output-compression.ts
7114
+ function stripAnsi(s) {
7115
+ return s.replace(ANSI, "");
7116
+ }
7117
+ function omittedMarker(n) {
7118
+ return ` \u2026 ${n} line${n === 1 ? "" : "s"} omitted \u2014 mink retrieve \u2026`;
7119
+ }
7120
+ function toLines(content) {
7121
+ const lines = content.split(`
7122
+ `);
7123
+ if (lines.length > 0 && lines[lines.length - 1] === "")
7124
+ lines.pop();
7125
+ return lines;
7126
+ }
7127
+ function compressLog(content) {
7128
+ const lines = toLines(stripAnsi(content));
7129
+ const collapsed = [];
7130
+ let i = 0;
7131
+ while (i < lines.length) {
7132
+ let run = 1;
7133
+ while (i + run < lines.length && lines[i + run] === lines[i])
7134
+ run++;
7135
+ collapsed.push(run > 1 ? `${lines[i]} (\xD7${run})` : lines[i]);
7136
+ i += run;
7137
+ }
7138
+ if (collapsed.length <= LOG_HEAD + LOG_TAIL) {
7139
+ if (collapsed.length === lines.length)
7140
+ return null;
7141
+ return {
7142
+ compressed: collapsed.join(`
7143
+ `),
7144
+ omittedNote: `collapsed ${lines.length - collapsed.length} repeated line(s)`
7145
+ };
7146
+ }
7147
+ const omitted = collapsed.length - LOG_HEAD - LOG_TAIL;
7148
+ const head = collapsed.slice(0, LOG_HEAD);
7149
+ const tail = collapsed.slice(collapsed.length - LOG_TAIL);
7150
+ return {
7151
+ compressed: [...head, omittedMarker(omitted), ...tail].join(`
7152
+ `),
7153
+ omittedNote: `${omitted} of ${collapsed.length} log line(s) omitted (middle)`
7154
+ };
7155
+ }
7156
+ function compressSearch(content) {
7157
+ const lines = toLines(content);
7158
+ const seen = new Set;
7159
+ const perFile = new Map;
7160
+ const omittedByFile = new Map;
7161
+ const out = [];
7162
+ for (const line of lines) {
7163
+ if (seen.has(line))
7164
+ continue;
7165
+ seen.add(line);
7166
+ const colon = line.indexOf(":");
7167
+ const file = colon > 0 ? line.slice(0, colon) : line;
7168
+ const count = perFile.get(file) ?? 0;
7169
+ if (count < SEARCH_MAX_PER_FILE) {
7170
+ perFile.set(file, count + 1);
7171
+ out.push(line);
7172
+ } else {
7173
+ omittedByFile.set(file, (omittedByFile.get(file) ?? 0) + 1);
7174
+ }
7175
+ }
7176
+ let totalOmitted = 0;
7177
+ for (const [file, n] of omittedByFile) {
7178
+ totalOmitted += n;
7179
+ out.push(` \u2026 +${n} more match(es) in ${file} \u2014 mink retrieve \u2026`);
7180
+ }
7181
+ const dedupRemoved = lines.length - seen.size;
7182
+ if (totalOmitted === 0 && dedupRemoved === 0)
7183
+ return null;
7184
+ const notes = [];
7185
+ if (totalOmitted > 0)
7186
+ notes.push(`${totalOmitted} match(es) capped`);
7187
+ if (dedupRemoved > 0)
7188
+ notes.push(`${dedupRemoved} duplicate(s) removed`);
7189
+ return { compressed: out.join(`
7190
+ `), omittedNote: notes.join("; ") };
7191
+ }
7192
+ function compressFile(filePath, content) {
7193
+ const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
7194
+ const markdown = ext === ".md" || ext === ".mdx" || ext === ".markdown";
7195
+ const skeleton = extractCodeSkeleton(content, { markdown });
7196
+ if (!skeleton) {
7197
+ return compressText(content);
7198
+ }
7199
+ const header = `${filePath} \u2014 structural summary ` + `(${skeleton.lines.length} signature(s) of ${skeleton.totalLines} lines)`;
7200
+ return {
7201
+ compressed: [header, ...skeleton.lines].join(`
7202
+ `),
7203
+ omittedNote: `bodies elided; ${skeleton.totalLines} lines available via mink retrieve`
7204
+ };
7205
+ }
7206
+ function crush(value) {
7207
+ if (Array.isArray(value)) {
7208
+ let omitted = 0;
7209
+ const mapEl = (el) => {
7210
+ const r = crush(el);
7211
+ omitted += r.omitted;
7212
+ return r.value;
7213
+ };
7214
+ if (value.length <= JSON_ARRAY_HEAD + JSON_ARRAY_TAIL) {
7215
+ return { value: value.map(mapEl), omitted };
7216
+ }
7217
+ const dropped = value.length - JSON_ARRAY_HEAD - JSON_ARRAY_TAIL;
7218
+ omitted += dropped;
7219
+ const out = [
7220
+ ...value.slice(0, JSON_ARRAY_HEAD).map(mapEl),
7221
+ `\u2026 ${dropped} element(s) omitted \u2014 mink retrieve \u2026`,
7222
+ ...value.slice(value.length - JSON_ARRAY_TAIL).map(mapEl)
7223
+ ];
7224
+ return { value: out, omitted };
7225
+ }
7226
+ if (value && typeof value === "object") {
7227
+ let omitted = 0;
7228
+ const out = {};
7229
+ for (const [k, v] of Object.entries(value)) {
7230
+ const r = crush(v);
7231
+ omitted += r.omitted;
7232
+ out[k] = r.value;
7233
+ }
7234
+ return { value: out, omitted };
7235
+ }
7236
+ return { value, omitted: 0 };
7237
+ }
7238
+ function compressJson(content) {
7239
+ let parsed;
7240
+ try {
7241
+ parsed = JSON.parse(content);
7242
+ } catch {
7243
+ return null;
7244
+ }
7245
+ const { value, omitted } = crush(parsed);
7246
+ if (omitted === 0)
7247
+ return null;
7248
+ return {
7249
+ compressed: JSON.stringify(value, null, 2),
7250
+ omittedNote: `${omitted} array element(s) sampled out`
7251
+ };
7252
+ }
7253
+ function compressText(content) {
7254
+ const lines = toLines(content);
7255
+ if (lines.length <= TEXT_HEAD + TEXT_TAIL)
7256
+ return null;
7257
+ const omitted = lines.length - TEXT_HEAD - TEXT_TAIL;
7258
+ const head = lines.slice(0, TEXT_HEAD);
7259
+ const tail = lines.slice(lines.length - TEXT_TAIL);
7260
+ return {
7261
+ compressed: [...head, omittedMarker(omitted), ...tail].join(`
7262
+ `),
7263
+ omittedNote: `${omitted} of ${lines.length} line(s) omitted (middle)`
7264
+ };
7265
+ }
7266
+ function detectContentKind(toolName, content, filePath) {
7267
+ const t = toolName.toLowerCase();
7268
+ if (t === "read")
7269
+ return "file";
7270
+ if (t === "grep" || t === "glob")
7271
+ return "search";
7272
+ if (t === "bash")
7273
+ return "log";
7274
+ const head = content.trimStart()[0];
7275
+ if (head === "{" || head === "[") {
7276
+ try {
7277
+ JSON.parse(content);
7278
+ return "json";
7279
+ } catch {}
7280
+ }
7281
+ if (filePath)
7282
+ return "file";
7283
+ return "text";
7284
+ }
7285
+ function compressOutput(toolName, content, filePath) {
7286
+ const kind = detectContentKind(toolName, content, filePath);
7287
+ let result;
7288
+ switch (kind) {
7289
+ case "search":
7290
+ result = compressSearch(content);
7291
+ break;
7292
+ case "log":
7293
+ result = compressLog(content);
7294
+ break;
7295
+ case "file":
7296
+ result = compressFile(filePath ?? "file", content);
7297
+ break;
7298
+ case "json":
7299
+ result = compressJson(content);
7300
+ break;
7301
+ case "text":
7302
+ result = compressText(content);
7303
+ break;
7304
+ }
7305
+ if (!result)
7306
+ return null;
7307
+ return { kind, compressed: result.compressed, omittedNote: result.omittedNote };
7308
+ }
7309
+ var SEARCH_MAX_PER_FILE = 5, LOG_HEAD = 40, LOG_TAIL = 40, TEXT_HEAD = 30, TEXT_TAIL = 20, JSON_ARRAY_HEAD = 20, JSON_ARRAY_TAIL = 5, ANSI;
7310
+ var init_output_compression = __esm(() => {
7311
+ init_code_skeleton();
7312
+ ANSI = /\u001B\[[0-9;?]*[ -/]*[@-~]/g;
7313
+ });
7314
+
7315
+ // src/repositories/compression-cache-repo.ts
7316
+ import { randomUUID as randomUUID3 } from "crypto";
7317
+
7318
+ class CompressionCacheRepo {
7319
+ db;
7320
+ constructor(db) {
7321
+ this.db = db;
7322
+ }
7323
+ static for(cwd) {
7324
+ return new CompressionCacheRepo(openProjectDb(cwd));
7325
+ }
7326
+ static newToken() {
7327
+ return `mc-${randomUUID3().slice(0, 8)}`;
7328
+ }
7329
+ store(input, deviceId = getOrCreateDeviceId()) {
7330
+ const token = input.token ?? CompressionCacheRepo.newToken();
7331
+ const now = input.now ?? new Date;
7332
+ const createdAt = now.toISOString();
7333
+ const expiresAt = new Date(now.getTime() + Math.max(0, input.retentionHours) * 3600000).toISOString();
7334
+ this.db.prepare(`
7335
+ INSERT OR REPLACE INTO compression_cache
7336
+ (token, created_at, expires_at, tool_name, content_kind,
7337
+ content, size_bytes, device_id)
7338
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
7339
+ `).run(token, createdAt, expiresAt, input.toolName, input.contentKind, input.content, Buffer.byteLength(input.content, "utf-8"), deviceId);
7340
+ return token;
7341
+ }
7342
+ get(token, now = new Date) {
7343
+ const row = this.db.prepare("SELECT * FROM compression_cache WHERE token = ?").get(token);
7344
+ if (!row)
7345
+ return null;
7346
+ const expiresAt = String(row.expires_at);
7347
+ if (expiresAt <= now.toISOString()) {
7348
+ try {
7349
+ this.db.prepare("DELETE FROM compression_cache WHERE token = ?").run(token);
7350
+ } catch {}
7351
+ return null;
7352
+ }
7353
+ return {
7354
+ token: String(row.token),
7355
+ createdAt: String(row.created_at),
7356
+ expiresAt,
7357
+ toolName: String(row.tool_name),
7358
+ contentKind: String(row.content_kind),
7359
+ content: String(row.content),
7360
+ sizeBytes: Number(row.size_bytes)
7361
+ };
7362
+ }
7363
+ evictExpired(now = new Date) {
7364
+ const r = this.db.prepare("DELETE FROM compression_cache WHERE expires_at <= ?").run(now.toISOString());
7365
+ return Number(r.changes);
7366
+ }
7367
+ count() {
7368
+ const row = this.db.prepare("SELECT COUNT(*) AS n FROM compression_cache").get();
7369
+ return Number(row.n);
7370
+ }
7371
+ }
7372
+ var init_compression_cache_repo = __esm(() => {
7373
+ init_db();
7374
+ init_device();
7375
+ });
7376
+
7377
+ // src/core/compress-tool-output.ts
7378
+ function contentKey(s) {
7379
+ let h = 2166136261;
7380
+ for (let i = 0;i < s.length; i++) {
7381
+ h ^= s.charCodeAt(i);
7382
+ h = Math.imul(h, 16777619);
7383
+ }
7384
+ return (h >>> 0).toString(16);
7385
+ }
7386
+ function render(result, token) {
7387
+ return result.compressed + `
7388
+
7389
+ ` + `\u2014 mink: compressed ${result.kind} output (${result.omittedNote}). ` + `Full original: mink retrieve ${token}`;
7390
+ }
7391
+ function safeRecord(cwd, toolName, contentKind, originalTokens, compressedTokens, holdout) {
7392
+ try {
7393
+ TokenLedgerRepo.for(cwd).recordCompression({
7394
+ toolName,
7395
+ contentKind,
7396
+ originalTokens,
7397
+ compressedTokens,
7398
+ holdout
7399
+ });
7400
+ } catch {}
7401
+ }
7402
+ function compressToolOutput(cwd, toolName, output, filePath) {
7403
+ let cfg;
7404
+ try {
7405
+ cfg = loadCompressionConfig();
7406
+ } catch {
7407
+ return null;
7408
+ }
7409
+ if (!cfg.enabled)
7410
+ return null;
7411
+ if (typeof output !== "string" || output.length === 0)
7412
+ return null;
7413
+ const originalTokens = countTokens(output);
7414
+ if (!isEligible(originalTokens, cfg))
7415
+ return null;
7416
+ const eventKey = contentKey(output);
7417
+ if (selectHoldout(eventKey, cfg.holdoutFraction)) {
7418
+ const kind = detectContentKind(toolName, output, filePath);
7419
+ safeRecord(cwd, toolName, kind, originalTokens, originalTokens, true);
7420
+ return null;
7421
+ }
7422
+ const result = compressOutput(toolName, output, filePath);
7423
+ if (!result)
7424
+ return null;
7425
+ const token = CompressionCacheRepo.newToken();
7426
+ const replacement = render(result, token);
7427
+ const compressedTokens = countTokens(replacement);
7428
+ if (!meetsMinSavings(originalTokens, compressedTokens, cfg))
7429
+ return null;
7430
+ try {
7431
+ CompressionCacheRepo.for(cwd).store({
7432
+ toolName,
7433
+ contentKind: result.kind,
7434
+ content: output,
7435
+ retentionHours: cfg.retentionHours,
7436
+ token
7437
+ });
7438
+ } catch {
7439
+ return null;
7440
+ }
7441
+ safeRecord(cwd, toolName, result.kind, originalTokens, compressedTokens, false);
7442
+ return { updatedToolOutput: replacement, token };
7443
+ }
7444
+ var init_compress_tool_output = __esm(() => {
7445
+ init_compression();
7446
+ init_token_estimate();
7447
+ init_output_compression();
7448
+ init_compression_cache_repo();
7449
+ init_token_ledger_repo();
7450
+ });
7451
+
7452
+ // src/core/hook-output.ts
7453
+ function extractToolOutputText(input) {
7454
+ const tr = input.tool_response;
7455
+ if (tr) {
7456
+ if (typeof tr.content === "string")
7457
+ return tr.content;
7458
+ if (Array.isArray(tr.content)) {
7459
+ const parts = tr.content.map((p) => p && typeof p.text === "string" ? p.text : "").filter((s) => s.length > 0);
7460
+ if (parts.length > 0)
7461
+ return parts.join("");
7462
+ }
7463
+ if (typeof tr.stdout === "string" && tr.stdout.length > 0)
7464
+ return tr.stdout;
7465
+ if (typeof tr.text === "string")
7466
+ return tr.text;
7467
+ const file = tr.file;
7468
+ if (file && typeof file.content === "string")
7469
+ return file.content;
7470
+ }
7471
+ const to = input.tool_output;
7472
+ if (to && typeof to.content === "string")
7473
+ return to.content;
7474
+ return null;
7475
+ }
7476
+ function emitUpdatedToolOutput(text) {
7477
+ process.stdout.write(JSON.stringify({
7478
+ hookSpecificOutput: {
7479
+ hookEventName: "PostToolUse",
7480
+ updatedToolOutput: text
7481
+ }
7482
+ }));
7483
+ }
7484
+
7180
7485
  // src/commands/post-read.ts
7181
7486
  var exports_post_read = {};
7182
7487
  __export(exports_post_read, {
@@ -7306,6 +7611,14 @@ async function postRead(cwd) {
7306
7611
  logWriter.appendReadEntry(new Date().toISOString(), filePath, result.indexHit, result.estimatedTokens);
7307
7612
  } catch {}
7308
7613
  atomicWriteJson(sessionPath(cwd), state);
7614
+ const isRanged = input.tool_input.offset != null || input.tool_input.limit != null;
7615
+ if (!isRanged && content && content.length > 0) {
7616
+ try {
7617
+ const outcome = compressToolOutput(cwd, "Read", content, filePath);
7618
+ if (outcome)
7619
+ emitUpdatedToolOutput(outcome.updatedToolOutput);
7620
+ } catch {}
7621
+ }
7309
7622
  } catch {} finally {
7310
7623
  clearTimeout(timer);
7311
7624
  }
@@ -7319,6 +7632,43 @@ var init_post_read = __esm(() => {
7319
7632
  init_description();
7320
7633
  init_action_log();
7321
7634
  init_device();
7635
+ init_compress_tool_output();
7636
+ });
7637
+
7638
+ // src/commands/post-tool.ts
7639
+ var exports_post_tool = {};
7640
+ __export(exports_post_tool, {
7641
+ postTool: () => postTool
7642
+ });
7643
+ function isPostToolUseInput2(value) {
7644
+ if (value === null || typeof value !== "object")
7645
+ return false;
7646
+ const obj = value;
7647
+ return typeof obj.tool_name === "string";
7648
+ }
7649
+ function isCompressibleTool(toolName) {
7650
+ return toolName === "Bash" || toolName === "Grep" || toolName === "Glob" || toolName.startsWith("mcp__");
7651
+ }
7652
+ async function postTool(cwd) {
7653
+ const timer = setTimeout(() => process.exit(0), 5000);
7654
+ try {
7655
+ const input = await readStdinJson();
7656
+ if (!isPostToolUseInput2(input))
7657
+ return;
7658
+ if (!isCompressibleTool(input.tool_name))
7659
+ return;
7660
+ const output = extractToolOutputText(input);
7661
+ if (!output)
7662
+ return;
7663
+ const outcome = compressToolOutput(cwd, input.tool_name, output);
7664
+ if (outcome)
7665
+ emitUpdatedToolOutput(outcome.updatedToolOutput);
7666
+ } catch {} finally {
7667
+ clearTimeout(timer);
7668
+ }
7669
+ }
7670
+ var init_post_tool = __esm(() => {
7671
+ init_compress_tool_output();
7322
7672
  });
7323
7673
 
7324
7674
  // src/core/pattern-engine.ts
@@ -7557,7 +7907,7 @@ function analyzePostWrite(filePath, fileContent, index) {
7557
7907
  indexEntry
7558
7908
  };
7559
7909
  }
7560
- function isPostToolUseInput2(value) {
7910
+ function isPostToolUseInput3(value) {
7561
7911
  if (value === null || typeof value !== "object")
7562
7912
  return false;
7563
7913
  const obj = value;
@@ -7571,7 +7921,7 @@ async function postWrite(cwd) {
7571
7921
  const timer = setTimeout(() => process.exit(0), 1e4);
7572
7922
  try {
7573
7923
  const input = await readStdinJson();
7574
- if (!isPostToolUseInput2(input))
7924
+ if (!isPostToolUseInput3(input))
7575
7925
  return;
7576
7926
  if (input.tool_name !== "Write" && input.tool_name !== "Edit")
7577
7927
  return;
@@ -7800,6 +8150,35 @@ var init_detect_waste = __esm(() => {
7800
8150
  init_device();
7801
8151
  });
7802
8152
 
8153
+ // src/commands/retrieve.ts
8154
+ var exports_retrieve = {};
8155
+ __export(exports_retrieve, {
8156
+ retrieve: () => retrieve
8157
+ });
8158
+ function retrieve(cwd, args) {
8159
+ const token = args[0];
8160
+ if (!token) {
8161
+ process.stderr.write(`[mink] usage: mink retrieve <token>
8162
+ `);
8163
+ return;
8164
+ }
8165
+ let entry = null;
8166
+ try {
8167
+ entry = CompressionCacheRepo.for(cwd).get(token);
8168
+ } catch {
8169
+ entry = null;
8170
+ }
8171
+ if (!entry) {
8172
+ process.stderr.write(`[mink] no retrievable output for token "${token}" (unknown or expired)
8173
+ `);
8174
+ return;
8175
+ }
8176
+ process.stdout.write(entry.content);
8177
+ }
8178
+ var init_retrieve = __esm(() => {
8179
+ init_compression_cache_repo();
8180
+ });
8181
+
7803
8182
  // src/core/cron-parser.ts
7804
8183
  function parseField(field, min, max) {
7805
8184
  const values = new Set;
@@ -7882,9 +8261,9 @@ __export(exports_self_update, {
7882
8261
  PACKAGE_NAME: () => PACKAGE_NAME
7883
8262
  });
7884
8263
  import { spawnSync as spawnSync2 } from "child_process";
7885
- import { existsSync as existsSync26, readFileSync as readFileSync20 } from "fs";
7886
- import { dirname as dirname11 } from "path";
7887
- import { join as join23 } from "path";
8264
+ import { existsSync as existsSync24, readFileSync as readFileSync20 } from "fs";
8265
+ import { dirname as dirname10 } from "path";
8266
+ import { join as join21 } from "path";
7888
8267
  function parseSemver(input) {
7889
8268
  const trimmed = input.trim().replace(/^v/, "");
7890
8269
  if (!trimmed)
@@ -7931,15 +8310,15 @@ function compareSemver(a, b) {
7931
8310
  function getInstallInfo() {
7932
8311
  const selfPath = new URL(import.meta.url).pathname;
7933
8312
  const isDevMode = selfPath.endsWith(".ts");
7934
- let dir = dirname11(selfPath);
8313
+ let dir = dirname10(selfPath);
7935
8314
  let packageJsonPath = null;
7936
8315
  for (let i = 0;i < 10; i++) {
7937
- const candidate = join23(dir, "package.json");
7938
- if (existsSync26(candidate)) {
8316
+ const candidate = join21(dir, "package.json");
8317
+ if (existsSync24(candidate)) {
7939
8318
  packageJsonPath = candidate;
7940
8319
  break;
7941
8320
  }
7942
- const parent = dirname11(dir);
8321
+ const parent = dirname10(dir);
7943
8322
  if (parent === dir)
7944
8323
  break;
7945
8324
  dir = parent;
@@ -8009,7 +8388,7 @@ function buildInstallCommand(pm, version) {
8009
8388
  return ["npm", "install", "-g", ref];
8010
8389
  }
8011
8390
  function selfUpdateLogPath() {
8012
- return join23(minkRoot(), "self-update.log");
8391
+ return join21(minkRoot(), "self-update.log");
8013
8392
  }
8014
8393
  function appendLogEntry(entry) {
8015
8394
  const path = selfUpdateLogPath();
@@ -8798,21 +9177,21 @@ var init_cron = __esm(() => {
8798
9177
  });
8799
9178
 
8800
9179
  // src/core/vault-templates.ts
8801
- import { join as join24 } from "path";
8802
- import { existsSync as existsSync27, writeFileSync as writeFileSync9, readFileSync as readFileSync21, mkdirSync as mkdirSync14 } from "fs";
9180
+ import { join as join22 } from "path";
9181
+ import { existsSync as existsSync25, writeFileSync as writeFileSync9, readFileSync as readFileSync21, mkdirSync as mkdirSync13 } from "fs";
8803
9182
  function seedTemplates(templatesDir) {
8804
- mkdirSync14(templatesDir, { recursive: true });
9183
+ mkdirSync13(templatesDir, { recursive: true });
8805
9184
  for (const [name, content] of Object.entries(DEFAULT_TEMPLATES)) {
8806
- const filePath = join24(templatesDir, `${name}.md`);
8807
- if (!existsSync27(filePath)) {
9185
+ const filePath = join22(templatesDir, `${name}.md`);
9186
+ if (!existsSync25(filePath)) {
8808
9187
  writeFileSync9(filePath, content);
8809
9188
  }
8810
9189
  }
8811
9190
  }
8812
9191
  function loadTemplate(templatesDir, templateName, vars) {
8813
- const filePath = join24(templatesDir, `${templateName}.md`);
9192
+ const filePath = join22(templatesDir, `${templateName}.md`);
8814
9193
  let content;
8815
- if (existsSync27(filePath)) {
9194
+ if (existsSync25(filePath)) {
8816
9195
  content = readFileSync21(filePath, "utf-8");
8817
9196
  } else if (DEFAULT_TEMPLATES[templateName]) {
8818
9197
  content = DEFAULT_TEMPLATES[templateName];
@@ -8966,29 +9345,29 @@ category: resources
8966
9345
  });
8967
9346
 
8968
9347
  // src/core/note-writer.ts
8969
- import { join as join25 } from "path";
8970
- import { existsSync as existsSync28, readFileSync as readFileSync22 } from "fs";
9348
+ import { join as join23 } from "path";
9349
+ import { existsSync as existsSync26, readFileSync as readFileSync22 } from "fs";
8971
9350
  import { createHash as createHash3 } from "crypto";
8972
9351
  function sha256(content) {
8973
9352
  return createHash3("sha256").update(content).digest("hex");
8974
9353
  }
8975
9354
  function resolveUniqueNotePath(dir, baseSlug, content) {
8976
9355
  const targetHash = sha256(content);
8977
- const primary = join25(dir, `${baseSlug}.md`);
8978
- if (!existsSync28(primary))
9356
+ const primary = join23(dir, `${baseSlug}.md`);
9357
+ if (!existsSync26(primary))
8979
9358
  return primary;
8980
9359
  if (sameContent(primary, targetHash))
8981
9360
  return primary;
8982
9361
  const dev4 = getOrCreateDeviceId().replace(/-/g, "").slice(0, 4);
8983
9362
  for (let i = 0;i < MAX_COLLISION_ATTEMPTS; i++) {
8984
9363
  const suffix = i === 0 ? dev4 : `${dev4}-${i + 1}`;
8985
- const candidate = join25(dir, `${baseSlug}-${suffix}.md`);
8986
- if (!existsSync28(candidate))
9364
+ const candidate = join23(dir, `${baseSlug}-${suffix}.md`);
9365
+ if (!existsSync26(candidate))
8987
9366
  return candidate;
8988
9367
  if (sameContent(candidate, targetHash))
8989
9368
  return candidate;
8990
9369
  }
8991
- return join25(dir, `${baseSlug}-${Date.now()}.md`);
9370
+ return join23(dir, `${baseSlug}-${Date.now()}.md`);
8992
9371
  }
8993
9372
  function sameContent(filePath, expectedHash) {
8994
9373
  try {
@@ -9063,8 +9442,8 @@ ${meta.body}
9063
9442
  }
9064
9443
  function appendToDaily(date, content) {
9065
9444
  const dir = vaultDailyDir();
9066
- const filePath = join25(dir, `${date}.md`);
9067
- if (existsSync28(filePath)) {
9445
+ const filePath = join23(dir, `${date}.md`);
9446
+ if (existsSync26(filePath)) {
9068
9447
  const timestamp = new Date().toLocaleTimeString("en-US", {
9069
9448
  hour: "2-digit",
9070
9449
  minute: "2-digit",
@@ -9173,10 +9552,10 @@ var init_design_eval = __esm(() => {
9173
9552
  });
9174
9553
 
9175
9554
  // src/core/dashboard-api.ts
9176
- import { existsSync as existsSync29, readFileSync as readFileSync23 } from "fs";
9555
+ import { existsSync as existsSync27, readFileSync as readFileSync23 } from "fs";
9177
9556
  import { readdirSync as readdirSync9, readFileSync as readFileSyncFS, existsSync as fsExistsSync } from "fs";
9178
- import { join as join26, resolve as resolve6, normalize, sep } from "path";
9179
- import { execSync as execSync7 } from "child_process";
9557
+ import { join as join24, resolve as resolve5, normalize, sep } from "path";
9558
+ import { execSync as execSync6 } from "child_process";
9180
9559
  function isSecretKey(key) {
9181
9560
  return SECRET_KEY_PATTERNS.some((re) => re.test(key));
9182
9561
  }
@@ -9188,7 +9567,7 @@ function maskSecret(value, showLast = 4) {
9188
9567
  return "\u2022\u2022\u2022\u2022" + value.slice(-showLast);
9189
9568
  }
9190
9569
  function checkJsonFile2(name, filePath, validator) {
9191
- if (!existsSync29(filePath))
9570
+ if (!existsSync27(filePath))
9192
9571
  return { name, status: "missing" };
9193
9572
  const data = safeReadJson(filePath);
9194
9573
  if (data === null)
@@ -9198,7 +9577,7 @@ function checkJsonFile2(name, filePath, validator) {
9198
9577
  return { name, status: "ok" };
9199
9578
  }
9200
9579
  function checkTextFile(name, filePath) {
9201
- if (!existsSync29(filePath))
9580
+ if (!existsSync27(filePath))
9202
9581
  return { name, status: "missing" };
9203
9582
  try {
9204
9583
  readFileSync23(filePath, "utf-8");
@@ -9208,7 +9587,7 @@ function checkTextFile(name, filePath) {
9208
9587
  }
9209
9588
  }
9210
9589
  function checkDbFile2(name, filePath) {
9211
- if (!existsSync29(filePath))
9590
+ if (!existsSync27(filePath))
9212
9591
  return { name, status: "missing" };
9213
9592
  try {
9214
9593
  const header = readFileSync23(filePath).slice(0, 16).toString("utf-8");
@@ -9250,14 +9629,26 @@ function loadOverview(cwd) {
9250
9629
  checkTextFile("action-log.md", actionLogPath(cwd)),
9251
9630
  checkJsonFile2("scheduler-manifest.json", schedulerManifestPath(cwd))
9252
9631
  ];
9253
- return { project, daemon, summary, stateFiles };
9632
+ return { project, daemon, summary, compression: ledger.compression, stateFiles };
9254
9633
  }
9255
9634
  function loadTokenLedgerPanel(cwd) {
9256
9635
  const ledger = aggregateTokenLedger(cwd);
9257
9636
  return {
9258
9637
  lifetime: ledger.lifetime,
9259
9638
  sessions: ledger.sessions,
9260
- wasteFlags: ledger.wasteFlags ?? []
9639
+ wasteFlags: ledger.wasteFlags ?? [],
9640
+ compression: ledger.compression
9641
+ };
9642
+ }
9643
+ function loadCompressionPanel(cwd) {
9644
+ const repo = TokenLedgerRepo.for(cwd);
9645
+ return {
9646
+ enabled: loadCompressionConfig().enabled,
9647
+ lifetime: repo.compressionLifetime(),
9648
+ arms: repo.compressionArms(),
9649
+ byKind: repo.compressionBreakdown("content_kind"),
9650
+ byTool: repo.compressionBreakdown("tool_name"),
9651
+ recent: repo.compressionEvents(50)
9261
9652
  };
9262
9653
  }
9263
9654
  function loadFileIndexPanel(cwd) {
@@ -9390,7 +9781,7 @@ function getAheadBehind(branch) {
9390
9781
  if (!branch)
9391
9782
  return { ahead: 0, behind: 0 };
9392
9783
  try {
9393
- const raw = execSync7(`git rev-list --left-right --count origin/${branch}...${branch}`, { cwd: minkRoot(), timeout: 5000, stdio: ["pipe", "pipe", "pipe"] }).toString().trim();
9784
+ const raw = execSync6(`git rev-list --left-right --count origin/${branch}...${branch}`, { cwd: minkRoot(), timeout: 5000, stdio: ["pipe", "pipe", "pipe"] }).toString().trim();
9394
9785
  const [behindStr, aheadStr] = raw.split(/\s+/);
9395
9786
  return {
9396
9787
  behind: Number(behindStr) || 0,
@@ -9402,7 +9793,7 @@ function getAheadBehind(branch) {
9402
9793
  }
9403
9794
  function getPendingChanges() {
9404
9795
  try {
9405
- const raw = execSync7("git status --porcelain", {
9796
+ const raw = execSync6("git status --porcelain", {
9406
9797
  cwd: minkRoot(),
9407
9798
  timeout: 5000,
9408
9799
  stdio: ["pipe", "pipe", "pipe"]
@@ -9474,7 +9865,7 @@ function countMarkdownIn(dir) {
9474
9865
  for (const entry of readdirSync9(dir, { withFileTypes: true })) {
9475
9866
  if (WIKI_TREE_EXCLUDES.has(entry.name) || entry.name.startsWith("."))
9476
9867
  continue;
9477
- const fullPath = join26(dir, entry.name);
9868
+ const fullPath = join24(dir, entry.name);
9478
9869
  if (entry.isDirectory()) {
9479
9870
  count += countMarkdownIn(fullPath);
9480
9871
  } else if (entry.name.endsWith(".md") && !entry.name.startsWith("_")) {
@@ -9503,7 +9894,7 @@ function buildVaultTree(root) {
9503
9894
  for (const entry of entries) {
9504
9895
  if (!entry.isDir)
9505
9896
  continue;
9506
- const fullPath = join26(dir, entry.name);
9897
+ const fullPath = join24(dir, entry.name);
9507
9898
  const relPath = fullPath.slice(root.length + 1);
9508
9899
  const count = countMarkdownIn(fullPath);
9509
9900
  nodes.push({ name: entry.name, path: relPath, count, depth });
@@ -9588,7 +9979,7 @@ function resolveVaultRelativePath(relPath) {
9588
9979
  if (!relPath || relPath.includes("\x00"))
9589
9980
  return null;
9590
9981
  const root = resolveVaultPath();
9591
- const absolute = resolve6(root, relPath);
9982
+ const absolute = resolve5(root, relPath);
9592
9983
  const normalizedRoot = normalize(root) + sep;
9593
9984
  if (!absolute.startsWith(normalizedRoot) && absolute !== normalize(root)) {
9594
9985
  return null;
@@ -9926,7 +10317,7 @@ async function triggerIngestFile(sourcePath, category, tags, dedupKey) {
9926
10317
  if (!isValidCategory(category)) {
9927
10318
  return { success: false, error: `Invalid category: ${category}` };
9928
10319
  }
9929
- const expanded = sourcePath.startsWith("~/") ? join26(process.env.HOME ?? "", sourcePath.slice(2)) : sourcePath;
10320
+ const expanded = sourcePath.startsWith("~/") ? join24(process.env.HOME ?? "", sourcePath.slice(2)) : sourcePath;
9930
10321
  if (!fsExistsSync(expanded)) {
9931
10322
  return { success: false, error: `Source file not found: ${sourcePath}` };
9932
10323
  }
@@ -9986,6 +10377,8 @@ var init_dashboard_api = __esm(() => {
9986
10377
  init_note_writer();
9987
10378
  init_paths();
9988
10379
  init_config();
10380
+ init_token_ledger_repo();
10381
+ init_compression();
9989
10382
  init_design_eval();
9990
10383
  SECRET_KEY_PATTERNS = [/token/i, /secret/i, /password/i, /api[-_]?key/i];
9991
10384
  BOOLEAN_VALUES = new Set(["true", "false"]);
@@ -10013,8 +10406,8 @@ __export(exports_dashboard_server, {
10013
10406
  startDashboardServer: () => startDashboardServer
10014
10407
  });
10015
10408
  import { watch } from "fs";
10016
- import { existsSync as existsSync30 } from "fs";
10017
- import { basename as basename7, dirname as dirname12, join as join27, extname as extname2 } from "path";
10409
+ import { existsSync as existsSync28 } from "fs";
10410
+ import { basename as basename7, dirname as dirname11, join as join25, extname as extname2 } from "path";
10018
10411
 
10019
10412
  class SSEManager {
10020
10413
  clients = new Map;
@@ -10191,15 +10584,15 @@ async function startDashboardServer(cwd, options = {}) {
10191
10584
  timestamp: new Date().toISOString()
10192
10585
  });
10193
10586
  });
10194
- const __dir = dirname12(new URL(import.meta.url).pathname);
10587
+ const __dir = dirname11(new URL(import.meta.url).pathname);
10195
10588
  let pkgRoot = __dir;
10196
- while (pkgRoot !== dirname12(pkgRoot)) {
10197
- if (existsSync30(join27(pkgRoot, "package.json")))
10589
+ while (pkgRoot !== dirname11(pkgRoot)) {
10590
+ if (existsSync28(join25(pkgRoot, "package.json")))
10198
10591
  break;
10199
- pkgRoot = dirname12(pkgRoot);
10592
+ pkgRoot = dirname11(pkgRoot);
10200
10593
  }
10201
- const dashboardOutDir = join27(pkgRoot, "dashboard", "out");
10202
- const dashboardBuilt = existsSync30(join27(dashboardOutDir, "index.html"));
10594
+ const dashboardOutDir = join25(pkgRoot, "dashboard", "out");
10595
+ const dashboardBuilt = existsSync28(join25(dashboardOutDir, "index.html"));
10203
10596
  let clientIdCounter = 0;
10204
10597
  if (!dashboardBuilt) {
10205
10598
  console.warn("[mink] dashboard not built. Run: cd dashboard && bun run build");
@@ -10229,9 +10622,9 @@ async function startDashboardServer(cwd, options = {}) {
10229
10622
  } else {
10230
10623
  let filePath;
10231
10624
  if (pathname === "/") {
10232
- filePath = join27(dashboardOutDir, "index.html");
10625
+ filePath = join25(dashboardOutDir, "index.html");
10233
10626
  } else {
10234
- filePath = join27(dashboardOutDir, pathname);
10627
+ filePath = join25(dashboardOutDir, pathname);
10235
10628
  }
10236
10629
  if (!filePath.startsWith(dashboardOutDir)) {
10237
10630
  return jsonResponse({ error: "Forbidden" }, 403);
@@ -10244,7 +10637,7 @@ async function startDashboardServer(cwd, options = {}) {
10244
10637
  const htmlServed = await serveFile(filePath + ".html", "text/html; charset=utf-8");
10245
10638
  if (htmlServed)
10246
10639
  return htmlServed;
10247
- const indexServed = await serveFile(join27(dashboardOutDir, "index.html"), "text/html; charset=utf-8");
10640
+ const indexServed = await serveFile(join25(dashboardOutDir, "index.html"), "text/html; charset=utf-8");
10248
10641
  if (indexServed)
10249
10642
  return indexServed;
10250
10643
  }
@@ -10335,6 +10728,8 @@ retry: 3000
10335
10728
  return jsonResponse(loadOverview(resolvedCwd));
10336
10729
  case "/api/token-ledger":
10337
10730
  return jsonResponse(loadTokenLedgerPanel(resolvedCwd));
10731
+ case "/api/compression":
10732
+ return jsonResponse(loadCompressionPanel(resolvedCwd));
10338
10733
  case "/api/file-index":
10339
10734
  return jsonResponse(loadFileIndexPanel(resolvedCwd));
10340
10735
  case "/api/scheduler":
@@ -10353,7 +10748,7 @@ retry: 3000
10353
10748
  if (!filename || filename.includes("..") || filename.includes("/")) {
10354
10749
  return jsonResponse({ error: "Invalid filename" }, 400);
10355
10750
  }
10356
- const imgPath = join27(designCapturesDir(resolvedCwd), filename);
10751
+ const imgPath = join25(designCapturesDir(resolvedCwd), filename);
10357
10752
  const served = await serveFile(imgPath, "image/jpeg");
10358
10753
  if (served) {
10359
10754
  served.headers.set("Cache-Control", "public, max-age=60");
@@ -10588,9 +10983,9 @@ __export(exports_dashboard, {
10588
10983
  resolveStartupCwd: () => resolveStartupCwd,
10589
10984
  dashboard: () => dashboard
10590
10985
  });
10591
- import { existsSync as existsSync31 } from "fs";
10986
+ import { existsSync as existsSync29 } from "fs";
10592
10987
  function resolveStartupCwd(cwd, registered = listRegisteredProjects()) {
10593
- if (existsSync31(projectDir(cwd))) {
10988
+ if (existsSync29(projectDir(cwd))) {
10594
10989
  return { kind: "active", cwd };
10595
10990
  }
10596
10991
  if (registered.length === 0) {
@@ -10627,10 +11022,10 @@ var init_dashboard = __esm(() => {
10627
11022
  });
10628
11023
 
10629
11024
  // src/core/daemon-service.ts
10630
- import { execSync as execSync8 } from "child_process";
10631
- import { existsSync as existsSync32, mkdirSync as mkdirSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync10 } from "fs";
10632
- import { homedir as homedir4 } from "os";
10633
- import { dirname as dirname13, join as join28 } from "path";
11025
+ import { execSync as execSync7 } from "child_process";
11026
+ import { existsSync as existsSync30, mkdirSync as mkdirSync14, unlinkSync as unlinkSync5, writeFileSync as writeFileSync10 } from "fs";
11027
+ import { homedir as homedir3 } from "os";
11028
+ import { dirname as dirname12, join as join26 } from "path";
10634
11029
  function detectPlatform() {
10635
11030
  if (process.platform === "linux")
10636
11031
  return "systemd";
@@ -10640,11 +11035,11 @@ function detectPlatform() {
10640
11035
  }
10641
11036
  function resolveServiceInvocation() {
10642
11037
  const entry = process.argv[1];
10643
- if (entry && !/\.(js|ts|mjs|cjs)$/.test(entry) && existsSync32(entry)) {
11038
+ if (entry && !/\.(js|ts|mjs|cjs)$/.test(entry) && existsSync30(entry)) {
10644
11039
  return {
10645
11040
  executable: entry,
10646
11041
  args: ["daemon", "start"],
10647
- pathDir: dirname13(entry)
11042
+ pathDir: dirname12(entry)
10648
11043
  };
10649
11044
  }
10650
11045
  const cliPath = resolveCliPath();
@@ -10652,17 +11047,17 @@ function resolveServiceInvocation() {
10652
11047
  return {
10653
11048
  executable: interpreter,
10654
11049
  args: [cliPath, "daemon", "start"],
10655
- pathDir: dirname13(interpreter)
11050
+ pathDir: dirname12(interpreter)
10656
11051
  };
10657
11052
  }
10658
11053
  function servicePaths(platform2) {
10659
- const home = homedir4();
11054
+ const home = homedir3();
10660
11055
  if (platform2 === "systemd") {
10661
- const unitDir2 = join28(home, ".config", "systemd", "user");
10662
- return { unitDir: unitDir2, unitFile: join28(unitDir2, "mink-daemon.service") };
11056
+ const unitDir2 = join26(home, ".config", "systemd", "user");
11057
+ return { unitDir: unitDir2, unitFile: join26(unitDir2, "mink-daemon.service") };
10663
11058
  }
10664
- const unitDir = join28(home, "Library", "LaunchAgents");
10665
- return { unitDir, unitFile: join28(unitDir, "com.mink.daemon.plist") };
11059
+ const unitDir = join26(home, "Library", "LaunchAgents");
11060
+ return { unitDir, unitFile: join26(unitDir, "com.mink.daemon.plist") };
10666
11061
  }
10667
11062
  function renderSystemdUnit(inv) {
10668
11063
  const execStart = [inv.executable, ...inv.args].join(" ");
@@ -10736,17 +11131,17 @@ function installService(options = {}) {
10736
11131
  process.exit(1);
10737
11132
  }
10738
11133
  const paths = servicePaths(platform2);
10739
- if (existsSync32(paths.unitFile) && !options.force) {
11134
+ if (existsSync30(paths.unitFile) && !options.force) {
10740
11135
  console.error(`[mink] unit file already exists: ${paths.unitFile}`);
10741
11136
  console.error(" re-run with --force to overwrite, or run `mink daemon uninstall` first");
10742
11137
  process.exit(1);
10743
11138
  }
10744
11139
  const inv = resolveServiceInvocation();
10745
- mkdirSync15(paths.unitDir, { recursive: true });
11140
+ mkdirSync14(paths.unitDir, { recursive: true });
10746
11141
  if (platform2 === "systemd") {
10747
11142
  writeFileSync10(paths.unitFile, renderSystemdUnit(inv));
10748
11143
  try {
10749
- execSync8("systemctl --user daemon-reload", { stdio: "ignore" });
11144
+ execSync7("systemctl --user daemon-reload", { stdio: "ignore" });
10750
11145
  } catch {}
10751
11146
  console.log(`[mink] wrote ${paths.unitFile}`);
10752
11147
  console.log("[mink] next steps:");
@@ -10769,24 +11164,24 @@ function uninstallService() {
10769
11164
  process.exit(1);
10770
11165
  }
10771
11166
  const paths = servicePaths(platform2);
10772
- if (!existsSync32(paths.unitFile)) {
11167
+ if (!existsSync30(paths.unitFile)) {
10773
11168
  console.log(`[mink] no unit file at ${paths.unitFile} \u2014 nothing to uninstall`);
10774
11169
  return;
10775
11170
  }
10776
11171
  if (platform2 === "systemd") {
10777
11172
  try {
10778
- execSync8("systemctl --user disable --now mink-daemon.service", {
11173
+ execSync7("systemctl --user disable --now mink-daemon.service", {
10779
11174
  stdio: "ignore"
10780
11175
  });
10781
11176
  } catch {}
10782
11177
  unlinkSync5(paths.unitFile);
10783
11178
  try {
10784
- execSync8("systemctl --user daemon-reload", { stdio: "ignore" });
11179
+ execSync7("systemctl --user daemon-reload", { stdio: "ignore" });
10785
11180
  } catch {}
10786
11181
  console.log(`[mink] removed ${paths.unitFile}`);
10787
11182
  } else {
10788
11183
  try {
10789
- execSync8(`launchctl unload -w ${paths.unitFile}`, { stdio: "ignore" });
11184
+ execSync7(`launchctl unload -w ${paths.unitFile}`, { stdio: "ignore" });
10790
11185
  } catch {}
10791
11186
  unlinkSync5(paths.unitFile);
10792
11187
  console.log(`[mink] removed ${paths.unitFile}`);
@@ -10801,7 +11196,7 @@ var exports_daemon = {};
10801
11196
  __export(exports_daemon, {
10802
11197
  daemon: () => daemon
10803
11198
  });
10804
- import { readFileSync as readFileSync24, existsSync as existsSync33 } from "fs";
11199
+ import { readFileSync as readFileSync24, existsSync as existsSync31 } from "fs";
10805
11200
  async function daemon(cwd, args) {
10806
11201
  const subcommand = args[0];
10807
11202
  switch (subcommand) {
@@ -10817,7 +11212,7 @@ async function daemon(cwd, args) {
10817
11212
  break;
10818
11213
  case "logs": {
10819
11214
  const logPath = schedulerLogPath();
10820
- if (!existsSync33(logPath)) {
11215
+ if (!existsSync31(logPath)) {
10821
11216
  console.log("[mink] no log file found");
10822
11217
  return;
10823
11218
  }
@@ -11089,13 +11484,13 @@ function printValidKeys() {
11089
11484
  }
11090
11485
  }
11091
11486
  function readLineFromStdin() {
11092
- return new Promise((resolve8) => {
11487
+ return new Promise((resolve7) => {
11093
11488
  const chunks = [];
11094
11489
  process.stdin.resume();
11095
11490
  process.stdin.setEncoding("utf-8");
11096
11491
  process.stdin.once("data", (data) => {
11097
11492
  process.stdin.pause();
11098
- resolve8(String(data).trim());
11493
+ resolve7(String(data).trim());
11099
11494
  });
11100
11495
  });
11101
11496
  }
@@ -11170,7 +11565,7 @@ var exports_update = {};
11170
11565
  __export(exports_update, {
11171
11566
  update: () => update
11172
11567
  });
11173
- import { resolve as resolve8 } from "path";
11568
+ import { resolve as resolve7 } from "path";
11174
11569
  function parseArgs(args) {
11175
11570
  let dryRun = false;
11176
11571
  let project = null;
@@ -11228,7 +11623,7 @@ async function update(cwd, args) {
11228
11623
  }
11229
11624
  const backupName = createBackup(target.cwd);
11230
11625
  console.log(` backup: ${backupName}`);
11231
- const settingsPath = resolve8(target.cwd, ".claude", "settings.json");
11626
+ const settingsPath = resolve7(target.cwd, ".claude", "settings.json");
11232
11627
  mergeHooksIntoSettings(settingsPath, newHooks);
11233
11628
  console.log(" hooks: updated");
11234
11629
  const metaPath = projectMetaPath(target.cwd);
@@ -11404,7 +11799,7 @@ var init_restore = __esm(() => {
11404
11799
 
11405
11800
  // src/core/design-eval/server-detect.ts
11406
11801
  import { readFileSync as readFileSync25 } from "fs";
11407
- import { join as join29 } from "path";
11802
+ import { join as join27 } from "path";
11408
11803
  async function probePort(port) {
11409
11804
  try {
11410
11805
  const controller = new AbortController;
@@ -11426,7 +11821,7 @@ async function findRunningServer(ports = DEFAULT_PROBE_PORTS) {
11426
11821
  }
11427
11822
  function detectDevCommand(cwd) {
11428
11823
  try {
11429
- const raw = readFileSync25(join29(cwd, "package.json"), "utf-8");
11824
+ const raw = readFileSync25(join27(cwd, "package.json"), "utf-8");
11430
11825
  const pkg = JSON.parse(raw);
11431
11826
  const scripts = pkg.scripts;
11432
11827
  if (!scripts || typeof scripts !== "object")
@@ -11446,10 +11841,10 @@ var init_server_detect = __esm(() => {
11446
11841
  });
11447
11842
 
11448
11843
  // src/core/design-eval/route-detect.ts
11449
- import { existsSync as existsSync34, readdirSync as readdirSync10, statSync as statSync11 } from "fs";
11450
- import { join as join30, relative as relative7, sep as sep2 } from "path";
11844
+ import { existsSync as existsSync32, readdirSync as readdirSync10, statSync as statSync11 } from "fs";
11845
+ import { join as join28, relative as relative7, sep as sep2 } from "path";
11451
11846
  function detectFramework(cwd) {
11452
- const has = (name) => ["js", "mjs", "ts", "cjs"].some((ext) => existsSync34(join30(cwd, `${name}.${ext}`))) || existsSync34(join30(cwd, name));
11847
+ const has = (name) => ["js", "mjs", "ts", "cjs"].some((ext) => existsSync32(join28(cwd, `${name}.${ext}`))) || existsSync32(join28(cwd, name));
11453
11848
  if (has("next.config"))
11454
11849
  return "nextjs";
11455
11850
  if (has("svelte.config"))
@@ -11474,8 +11869,8 @@ function detectRoutes(cwd) {
11474
11869
  }
11475
11870
  function detectNextRoutes(cwd) {
11476
11871
  const routes = [];
11477
- const appDir = join30(cwd, "app");
11478
- if (existsSync34(appDir)) {
11872
+ const appDir = join28(cwd, "app");
11873
+ if (existsSync32(appDir)) {
11479
11874
  const pageFiles = findFiles(appDir, /^page\.(tsx?|jsx?)$/);
11480
11875
  for (const file of pageFiles) {
11481
11876
  const rel = relative7(appDir, file);
@@ -11486,8 +11881,8 @@ function detectNextRoutes(cwd) {
11486
11881
  routes.push(route);
11487
11882
  }
11488
11883
  }
11489
- const pagesDir = join30(cwd, "pages");
11490
- if (existsSync34(pagesDir)) {
11884
+ const pagesDir = join28(cwd, "pages");
11885
+ if (existsSync32(pagesDir)) {
11491
11886
  const pageFiles = findFiles(pagesDir, /\.(tsx?|jsx?)$/);
11492
11887
  for (const file of pageFiles) {
11493
11888
  const rel = relative7(pagesDir, file);
@@ -11506,8 +11901,8 @@ function detectNextRoutes(cwd) {
11506
11901
  return unique.length > 0 ? unique.sort() : ["/"];
11507
11902
  }
11508
11903
  function detectSvelteKitRoutes(cwd) {
11509
- const routesDir = join30(cwd, "src", "routes");
11510
- if (!existsSync34(routesDir))
11904
+ const routesDir = join28(cwd, "src", "routes");
11905
+ if (!existsSync32(routesDir))
11511
11906
  return ["/"];
11512
11907
  const routes = [];
11513
11908
  const pageFiles = findFiles(routesDir, /^\+page\.svelte$/);
@@ -11522,8 +11917,8 @@ function detectSvelteKitRoutes(cwd) {
11522
11917
  return routes.length > 0 ? routes.sort() : ["/"];
11523
11918
  }
11524
11919
  function detectNuxtRoutes(cwd) {
11525
- const pagesDir = join30(cwd, "pages");
11526
- if (!existsSync34(pagesDir))
11920
+ const pagesDir = join28(cwd, "pages");
11921
+ if (!existsSync32(pagesDir))
11527
11922
  return ["/"];
11528
11923
  const routes = [];
11529
11924
  const vueFiles = findFiles(pagesDir, /\.vue$/);
@@ -11549,7 +11944,7 @@ function findFiles(dir, pattern) {
11549
11944
  for (const entry of entries) {
11550
11945
  if (entry.startsWith(".") || entry === "node_modules")
11551
11946
  continue;
11552
- const full = join30(current, entry);
11947
+ const full = join28(current, entry);
11553
11948
  try {
11554
11949
  const stat2 = statSync11(full);
11555
11950
  if (stat2.isDirectory()) {
@@ -11577,11 +11972,11 @@ function __extends(d, b) {
11577
11972
  }
11578
11973
  function __awaiter(thisArg, _arguments, P, generator) {
11579
11974
  function adopt(value) {
11580
- return value instanceof P ? value : new P(function(resolve9) {
11581
- resolve9(value);
11975
+ return value instanceof P ? value : new P(function(resolve8) {
11976
+ resolve8(value);
11582
11977
  });
11583
11978
  }
11584
- return new (P || (P = Promise))(function(resolve9, reject) {
11979
+ return new (P || (P = Promise))(function(resolve8, reject) {
11585
11980
  function fulfilled(value) {
11586
11981
  try {
11587
11982
  step(generator.next(value));
@@ -11597,7 +11992,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
11597
11992
  }
11598
11993
  }
11599
11994
  function step(result) {
11600
- result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
11995
+ result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
11601
11996
  }
11602
11997
  step((generator = generator.apply(thisArg, _arguments || [])).next());
11603
11998
  });
@@ -11780,14 +12175,14 @@ function __asyncValues(o) {
11780
12175
  }, i);
11781
12176
  function verb(n) {
11782
12177
  i[n] = o[n] && function(v) {
11783
- return new Promise(function(resolve9, reject) {
11784
- v = o[n](v), settle(resolve9, reject, v.done, v.value);
12178
+ return new Promise(function(resolve8, reject) {
12179
+ v = o[n](v), settle(resolve8, reject, v.done, v.value);
11785
12180
  });
11786
12181
  };
11787
12182
  }
11788
- function settle(resolve9, reject, d, v) {
12183
+ function settle(resolve8, reject, d, v) {
11789
12184
  Promise.resolve(v).then(function(v2) {
11790
- resolve9({ value: v2, done: d });
12185
+ resolve8({ value: v2, done: d });
11791
12186
  }, reject);
11792
12187
  }
11793
12188
  }
@@ -12318,7 +12713,7 @@ function of() {
12318
12713
  }
12319
12714
  function lastValueFrom(source, config22) {
12320
12715
  var hasConfig = typeof config22 === "object";
12321
- return new Promise(function(resolve9, reject) {
12716
+ return new Promise(function(resolve8, reject) {
12322
12717
  var _hasValue = false;
12323
12718
  var _value;
12324
12719
  source.subscribe({
@@ -12329,9 +12724,9 @@ function lastValueFrom(source, config22) {
12329
12724
  error: reject,
12330
12725
  complete: function() {
12331
12726
  if (_hasValue) {
12332
- resolve9(_value);
12727
+ resolve8(_value);
12333
12728
  } else if (hasConfig) {
12334
- resolve9(config22.defaultValue);
12729
+ resolve8(config22.defaultValue);
12335
12730
  } else {
12336
12731
  reject(new EmptyError);
12337
12732
  }
@@ -12341,16 +12736,16 @@ function lastValueFrom(source, config22) {
12341
12736
  }
12342
12737
  function firstValueFrom(source, config22) {
12343
12738
  var hasConfig = typeof config22 === "object";
12344
- return new Promise(function(resolve9, reject) {
12739
+ return new Promise(function(resolve8, reject) {
12345
12740
  var subscriber = new SafeSubscriber({
12346
12741
  next: function(value) {
12347
- resolve9(value);
12742
+ resolve8(value);
12348
12743
  subscriber.unsubscribe();
12349
12744
  },
12350
12745
  error: reject,
12351
12746
  complete: function() {
12352
12747
  if (hasConfig) {
12353
- resolve9(config22.defaultValue);
12748
+ resolve8(config22.defaultValue);
12354
12749
  } else {
12355
12750
  reject(new EmptyError);
12356
12751
  }
@@ -13402,7 +13797,7 @@ var init_rxjs = __esm(() => {
13402
13797
  Observable2.prototype.forEach = function(next, promiseCtor) {
13403
13798
  var _this = this;
13404
13799
  promiseCtor = getPromiseCtor(promiseCtor);
13405
- return new promiseCtor(function(resolve9, reject) {
13800
+ return new promiseCtor(function(resolve8, reject) {
13406
13801
  var subscriber = new SafeSubscriber({
13407
13802
  next: function(value) {
13408
13803
  try {
@@ -13413,7 +13808,7 @@ var init_rxjs = __esm(() => {
13413
13808
  }
13414
13809
  },
13415
13810
  error: reject,
13416
- complete: resolve9
13811
+ complete: resolve8
13417
13812
  });
13418
13813
  _this.subscribe(subscriber);
13419
13814
  });
@@ -13435,14 +13830,14 @@ var init_rxjs = __esm(() => {
13435
13830
  Observable2.prototype.toPromise = function(promiseCtor) {
13436
13831
  var _this = this;
13437
13832
  promiseCtor = getPromiseCtor(promiseCtor);
13438
- return new promiseCtor(function(resolve9, reject) {
13833
+ return new promiseCtor(function(resolve8, reject) {
13439
13834
  var value;
13440
13835
  _this.subscribe(function(x) {
13441
13836
  return value = x;
13442
13837
  }, function(err) {
13443
13838
  return reject(err);
13444
13839
  }, function() {
13445
- return resolve9(value);
13840
+ return resolve8(value);
13446
13841
  });
13447
13842
  });
13448
13843
  };
@@ -15368,8 +15763,8 @@ class Deferred {
15368
15763
  #isRejected = false;
15369
15764
  #value;
15370
15765
  #resolve;
15371
- #taskPromise = new Promise((resolve9) => {
15372
- this.#resolve = resolve9;
15766
+ #taskPromise = new Promise((resolve8) => {
15767
+ this.#resolve = resolve8;
15373
15768
  });
15374
15769
  #timeoutId;
15375
15770
  #timeoutError;
@@ -15458,12 +15853,12 @@ var init_Mutex = __esm(() => {
15458
15853
  return new Mutex.Guard(this, onRelease);
15459
15854
  }
15460
15855
  release() {
15461
- const resolve9 = this.#acquirers.shift();
15462
- if (!resolve9) {
15856
+ const resolve8 = this.#acquirers.shift();
15857
+ if (!resolve8) {
15463
15858
  this.#locked = false;
15464
15859
  return;
15465
15860
  }
15466
- resolve9();
15861
+ resolve8();
15467
15862
  }
15468
15863
  };
15469
15864
  });
@@ -17207,12 +17602,12 @@ var init_locators = __esm(() => {
17207
17602
  }
17208
17603
  return defer(() => {
17209
17604
  return from(handle.evaluate((element) => {
17210
- return new Promise((resolve9) => {
17605
+ return new Promise((resolve8) => {
17211
17606
  window.requestAnimationFrame(() => {
17212
17607
  const rect1 = element.getBoundingClientRect();
17213
17608
  window.requestAnimationFrame(() => {
17214
17609
  const rect2 = element.getBoundingClientRect();
17215
- resolve9([
17610
+ resolve8([
17216
17611
  {
17217
17612
  x: rect1.x,
17218
17613
  y: rect1.y,
@@ -18503,9 +18898,9 @@ var init_ElementHandle = __esm(() => {
18503
18898
  const handle = await this.#asSVGElementHandle();
18504
18899
  const target = __addDisposableResource6(env_5, handle && await handle.#getOwnerSVGElement(), false);
18505
18900
  return await (target ?? this).evaluate(async (element, threshold) => {
18506
- const visibleRatio = await new Promise((resolve9) => {
18901
+ const visibleRatio = await new Promise((resolve8) => {
18507
18902
  const observer = new IntersectionObserver((entries) => {
18508
- resolve9(entries[0].intersectionRatio);
18903
+ resolve8(entries[0].intersectionRatio);
18509
18904
  observer.disconnect();
18510
18905
  });
18511
18906
  observer.observe(element);
@@ -18899,7 +19294,7 @@ var init_Frame = __esm(() => {
18899
19294
  }
18900
19295
  type = type ?? "text/javascript";
18901
19296
  return await this.mainRealm().transferHandle(await this.isolatedRealm().evaluateHandle(async ({ url, id, type: type2, content: content2 }) => {
18902
- return await new Promise((resolve9, reject) => {
19297
+ return await new Promise((resolve8, reject) => {
18903
19298
  const script = document.createElement("script");
18904
19299
  script.type = type2;
18905
19300
  script.text = content2;
@@ -18912,12 +19307,12 @@ var init_Frame = __esm(() => {
18912
19307
  if (url) {
18913
19308
  script.src = url;
18914
19309
  script.addEventListener("load", () => {
18915
- resolve9(script);
19310
+ resolve8(script);
18916
19311
  }, { once: true });
18917
19312
  document.head.appendChild(script);
18918
19313
  } else {
18919
19314
  document.head.appendChild(script);
18920
- resolve9(script);
19315
+ resolve8(script);
18921
19316
  }
18922
19317
  });
18923
19318
  }, { ...options, type, content }));
@@ -18934,7 +19329,7 @@ var init_Frame = __esm(() => {
18934
19329
  options.content = content;
18935
19330
  }
18936
19331
  return await this.mainRealm().transferHandle(await this.isolatedRealm().evaluateHandle(async ({ url, content: content2 }) => {
18937
- return await new Promise((resolve9, reject) => {
19332
+ return await new Promise((resolve8, reject) => {
18938
19333
  let element;
18939
19334
  if (!url) {
18940
19335
  element = document.createElement("style");
@@ -18946,7 +19341,7 @@ var init_Frame = __esm(() => {
18946
19341
  element = link;
18947
19342
  }
18948
19343
  element.addEventListener("load", () => {
18949
- resolve9(element);
19344
+ resolve8(element);
18950
19345
  }, { once: true });
18951
19346
  element.addEventListener("error", (event) => {
18952
19347
  reject(new Error(event.message ?? "Could not load style"));
@@ -19800,9 +20195,9 @@ var init_Page = __esm(() => {
19800
20195
  ++this.#screencastSessionCount;
19801
20196
  if (!this.#startScreencastPromise) {
19802
20197
  this.#startScreencastPromise = this.mainFrame().client.send("Page.startScreencast", { format: "png" }).then(() => {
19803
- return new Promise((resolve9) => {
20198
+ return new Promise((resolve8) => {
19804
20199
  return this.mainFrame().client.once("Page.screencastFrame", () => {
19805
- return resolve9();
20200
+ return resolve8();
19806
20201
  });
19807
20202
  });
19808
20203
  });
@@ -22460,11 +22855,11 @@ function addPageBinding(type, name, prefix) {
22460
22855
  return value instanceof Node;
22461
22856
  })
22462
22857
  }));
22463
- return new Promise((resolve9, reject) => {
22858
+ return new Promise((resolve8, reject) => {
22464
22859
  callPuppeteer.callbacks.set(seq, {
22465
22860
  resolve(value) {
22466
22861
  callPuppeteer.args.delete(seq);
22467
- resolve9(value);
22862
+ resolve8(value);
22468
22863
  },
22469
22864
  reject(value) {
22470
22865
  callPuppeteer.args.delete(seq);
@@ -25927,8 +26322,8 @@ var init_Input2 = __esm(() => {
25927
26322
  if (typeof delay === "number") {
25928
26323
  await Promise.all(actions);
25929
26324
  actions.length = 0;
25930
- await new Promise((resolve9) => {
25931
- setTimeout(resolve9, delay);
26325
+ await new Promise((resolve8) => {
26326
+ setTimeout(resolve8, delay);
25932
26327
  });
25933
26328
  }
25934
26329
  actions.push(this.up({ ...options, clickCount }));
@@ -25948,9 +26343,9 @@ var init_Input2 = __esm(() => {
25948
26343
  });
25949
26344
  }
25950
26345
  async drag(start, target) {
25951
- const promise = new Promise((resolve9) => {
26346
+ const promise = new Promise((resolve8) => {
25952
26347
  this.#client.once("Input.dragIntercepted", (event) => {
25953
- return resolve9(event.data);
26348
+ return resolve8(event.data);
25954
26349
  });
25955
26350
  });
25956
26351
  await this.move(start.x, start.y);
@@ -25991,8 +26386,8 @@ var init_Input2 = __esm(() => {
25991
26386
  await this.dragEnter(target, data);
25992
26387
  await this.dragOver(target, data);
25993
26388
  if (delay) {
25994
- await new Promise((resolve9) => {
25995
- return setTimeout(resolve9, delay);
26389
+ await new Promise((resolve8) => {
26390
+ return setTimeout(resolve8, delay);
25996
26391
  });
25997
26392
  }
25998
26393
  await this.drop(target, data);
@@ -26804,9 +27199,9 @@ var init_Page2 = __esm(() => {
26804
27199
  async captureHeapSnapshot(options) {
26805
27200
  const { createWriteStream } = environment.value.fs;
26806
27201
  const stream = createWriteStream(options.path);
26807
- const streamPromise = new Promise((resolve9, reject) => {
27202
+ const streamPromise = new Promise((resolve8, reject) => {
26808
27203
  stream.on("error", reject);
26809
- stream.on("finish", resolve9);
27204
+ stream.on("finish", resolve8);
26810
27205
  });
26811
27206
  const client = this.#primaryTargetClient;
26812
27207
  await client.send("HeapProfiler.enable");
@@ -28319,10 +28714,10 @@ __export(exports_BrowserWebSocketTransport, {
28319
28714
 
28320
28715
  class BrowserWebSocketTransport {
28321
28716
  static create(url) {
28322
- return new Promise((resolve9, reject) => {
28717
+ return new Promise((resolve8, reject) => {
28323
28718
  const ws = new WebSocket(url);
28324
28719
  ws.addEventListener("open", () => {
28325
- return resolve9(new BrowserWebSocketTransport(ws));
28720
+ return resolve8(new BrowserWebSocketTransport(ws));
28326
28721
  });
28327
28722
  ws.addEventListener("error", reject);
28328
28723
  });
@@ -31156,11 +31551,11 @@ var require_BrowsingContextProcessor = __commonJS((exports) => {
31156
31551
  }
31157
31552
  const parentCdpClient = context2.cdpTarget.parentCdpClient;
31158
31553
  try {
31159
- const detachedFromTargetPromise = new Promise((resolve9) => {
31554
+ const detachedFromTargetPromise = new Promise((resolve8) => {
31160
31555
  const onContextDestroyed = (event) => {
31161
31556
  if (event.targetId === params.context) {
31162
31557
  parentCdpClient.off("Target.detachedFromTarget", onContextDestroyed);
31163
- resolve9();
31558
+ resolve8();
31164
31559
  }
31165
31560
  };
31166
31561
  parentCdpClient.on("Target.detachedFromTarget", onContextDestroyed);
@@ -32480,7 +32875,7 @@ var require_ActionDispatcher = __commonJS((exports) => {
32480
32875
  }
32481
32876
  }
32482
32877
  const promises = [
32483
- new Promise((resolve9) => setTimeout(resolve9, this.#tickDuration))
32878
+ new Promise((resolve8) => setTimeout(resolve8, this.#tickDuration))
32484
32879
  ];
32485
32880
  for (const option of options) {
32486
32881
  promises.push(this.#dispatchAction(option));
@@ -33079,8 +33474,8 @@ var require_Mutex = __commonJS((exports) => {
33079
33474
  acquire() {
33080
33475
  const state = { resolved: false };
33081
33476
  if (this.#locked) {
33082
- return new Promise((resolve9) => {
33083
- this.#acquirers.push(() => resolve9(this.#release.bind(this, state)));
33477
+ return new Promise((resolve8) => {
33478
+ this.#acquirers.push(() => resolve8(this.#release.bind(this, state)));
33084
33479
  });
33085
33480
  }
33086
33481
  this.#locked = true;
@@ -33091,12 +33486,12 @@ var require_Mutex = __commonJS((exports) => {
33091
33486
  throw new Error("Cannot release more than once.");
33092
33487
  }
33093
33488
  state.resolved = true;
33094
- const resolve9 = this.#acquirers.shift();
33095
- if (!resolve9) {
33489
+ const resolve8 = this.#acquirers.shift();
33490
+ if (!resolve8) {
33096
33491
  this.#locked = false;
33097
33492
  return;
33098
33493
  }
33099
- resolve9();
33494
+ resolve8();
33100
33495
  }
33101
33496
  async run(action) {
33102
33497
  const release = await this.acquire();
@@ -34223,8 +34618,8 @@ var require_ChannelProxy = __commonJS((exports) => {
34223
34618
  let queueNonEmptyResolver = null;
34224
34619
  return {
34225
34620
  async getMessage() {
34226
- const onMessage = queue.length > 0 ? Promise.resolve() : new Promise((resolve9) => {
34227
- queueNonEmptyResolver = resolve9;
34621
+ const onMessage = queue.length > 0 ? Promise.resolve() : new Promise((resolve8) => {
34622
+ queueNonEmptyResolver = resolve8;
34228
34623
  });
34229
34624
  await onMessage;
34230
34625
  return queue.shift();
@@ -34310,7 +34705,7 @@ var require_ChannelProxy = __commonJS((exports) => {
34310
34705
  functionDeclaration: String((id) => {
34311
34706
  const w = window;
34312
34707
  if (w[id] === undefined) {
34313
- return new Promise((resolve9) => w[id] = resolve9);
34708
+ return new Promise((resolve8) => w[id] = resolve8);
34314
34709
  }
34315
34710
  const channelProxy = w[id];
34316
34711
  delete w[id];
@@ -35661,8 +36056,8 @@ var require_Deferred = __commonJS((exports) => {
35661
36056
  return this.#result;
35662
36057
  }
35663
36058
  constructor() {
35664
- this.#promise = new Promise((resolve9, reject) => {
35665
- this.#resolve = resolve9;
36059
+ this.#promise = new Promise((resolve8, reject) => {
36060
+ this.#resolve = resolve8;
35666
36061
  this.#reject = reject;
35667
36062
  });
35668
36063
  this.#promise.catch((_error) => {});
@@ -39987,11 +40382,11 @@ var require_BrowsingContextStorage = __commonJS((exports) => {
39987
40382
  if (this.#contexts.has(browsingContextId)) {
39988
40383
  return Promise.resolve(this.getContext(browsingContextId));
39989
40384
  }
39990
- return new Promise((resolve9) => {
40385
+ return new Promise((resolve8) => {
39991
40386
  const listener = (event) => {
39992
40387
  if (event.browsingContext.id === browsingContextId) {
39993
40388
  this.#eventEmitter.off("added", listener);
39994
- resolve9(event.browsingContext);
40389
+ resolve8(event.browsingContext);
39995
40390
  }
39996
40391
  };
39997
40392
  this.#eventEmitter.on("added", listener);
@@ -43487,8 +43882,8 @@ var init_ExposedFunction = __esm(() => {
43487
43882
  const functionDeclaration = stringifyFunction(interpolateFunction((callback) => {
43488
43883
  Object.assign(globalThis, {
43489
43884
  [PLACEHOLDER("name")]: function(...args) {
43490
- return new Promise((resolve9, reject) => {
43491
- callback([resolve9, reject, args]);
43885
+ return new Promise((resolve8, reject) => {
43886
+ callback([resolve8, reject, args]);
43492
43887
  });
43493
43888
  }
43494
43889
  });
@@ -43576,8 +43971,8 @@ var init_ExposedFunction = __esm(() => {
43576
43971
  return;
43577
43972
  }
43578
43973
  try {
43579
- await dataHandle.evaluate(([resolve9], result2) => {
43580
- resolve9(result2);
43974
+ await dataHandle.evaluate(([resolve8], result2) => {
43975
+ resolve8(result2);
43581
43976
  }, result);
43582
43977
  } catch (error) {
43583
43978
  debugError(error);
@@ -48004,7 +48399,7 @@ import NodeWebSocket from "ws";
48004
48399
 
48005
48400
  class NodeWebSocketTransport {
48006
48401
  static create(url, headers) {
48007
- return new Promise((resolve9, reject) => {
48402
+ return new Promise((resolve8, reject) => {
48008
48403
  const ws = new NodeWebSocket(url, [], {
48009
48404
  followRedirects: true,
48010
48405
  perMessageDeflate: false,
@@ -48016,7 +48411,7 @@ class NodeWebSocketTransport {
48016
48411
  }
48017
48412
  });
48018
48413
  ws.addEventListener("open", () => {
48019
- return resolve9(new NodeWebSocketTransport(ws));
48414
+ return resolve8(new NodeWebSocketTransport(ws));
48020
48415
  });
48021
48416
  ws.addEventListener("error", reject);
48022
48417
  });
@@ -50906,8 +51301,8 @@ var require_helpers = __commonJS((exports) => {
50906
51301
  function req(url, opts = {}) {
50907
51302
  const href = typeof url === "string" ? url : url.href;
50908
51303
  const req2 = (href.startsWith("https:") ? https : http).request(url, opts);
50909
- const promise = new Promise((resolve9, reject) => {
50910
- req2.once("response", resolve9).once("error", reject).end();
51304
+ const promise = new Promise((resolve8, reject) => {
51305
+ req2.once("response", resolve8).once("error", reject).end();
50911
51306
  });
50912
51307
  req2.then = promise.then.bind(promise);
50913
51308
  return req2;
@@ -51278,7 +51673,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
51278
51673
  var debug_1 = __importDefault(require_src());
51279
51674
  var debug2 = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
51280
51675
  function parseProxyResponse(socket) {
51281
- return new Promise((resolve9, reject) => {
51676
+ return new Promise((resolve8, reject) => {
51282
51677
  let buffersLength = 0;
51283
51678
  const buffers = [];
51284
51679
  function read() {
@@ -51347,7 +51742,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
51347
51742
  }
51348
51743
  debug2("got proxy server response: %o %o", firstLine, headers);
51349
51744
  cleanup();
51350
- resolve9({
51745
+ resolve8({
51351
51746
  connect: {
51352
51747
  statusCode,
51353
51748
  statusText,
@@ -53451,11 +53846,11 @@ var require_receivebuffer = __commonJS((exports) => {
53451
53846
  var require_socksclient = __commonJS((exports) => {
53452
53847
  var __awaiter2 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
53453
53848
  function adopt(value) {
53454
- return value instanceof P ? value : new P(function(resolve9) {
53455
- resolve9(value);
53849
+ return value instanceof P ? value : new P(function(resolve8) {
53850
+ resolve8(value);
53456
53851
  });
53457
53852
  }
53458
- return new (P || (P = Promise))(function(resolve9, reject) {
53853
+ return new (P || (P = Promise))(function(resolve8, reject) {
53459
53854
  function fulfilled(value) {
53460
53855
  try {
53461
53856
  step(generator.next(value));
@@ -53471,7 +53866,7 @@ var require_socksclient = __commonJS((exports) => {
53471
53866
  }
53472
53867
  }
53473
53868
  function step(result) {
53474
- result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
53869
+ result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
53475
53870
  }
53476
53871
  step((generator = generator.apply(thisArg, _arguments || [])).next());
53477
53872
  });
@@ -53498,13 +53893,13 @@ var require_socksclient = __commonJS((exports) => {
53498
53893
  this.setState(constants_1.SocksClientState.Created);
53499
53894
  }
53500
53895
  static createConnection(options, callback) {
53501
- return new Promise((resolve9, reject) => {
53896
+ return new Promise((resolve8, reject) => {
53502
53897
  try {
53503
53898
  (0, helpers_1.validateSocksClientOptions)(options, ["connect"]);
53504
53899
  } catch (err) {
53505
53900
  if (typeof callback === "function") {
53506
53901
  callback(err);
53507
- return resolve9(err);
53902
+ return resolve8(err);
53508
53903
  } else {
53509
53904
  return reject(err);
53510
53905
  }
@@ -53515,16 +53910,16 @@ var require_socksclient = __commonJS((exports) => {
53515
53910
  client.removeAllListeners();
53516
53911
  if (typeof callback === "function") {
53517
53912
  callback(null, info);
53518
- resolve9(info);
53913
+ resolve8(info);
53519
53914
  } else {
53520
- resolve9(info);
53915
+ resolve8(info);
53521
53916
  }
53522
53917
  });
53523
53918
  client.once("error", (err) => {
53524
53919
  client.removeAllListeners();
53525
53920
  if (typeof callback === "function") {
53526
53921
  callback(err);
53527
- resolve9(err);
53922
+ resolve8(err);
53528
53923
  } else {
53529
53924
  reject(err);
53530
53925
  }
@@ -53532,13 +53927,13 @@ var require_socksclient = __commonJS((exports) => {
53532
53927
  });
53533
53928
  }
53534
53929
  static createConnectionChain(options, callback) {
53535
- return new Promise((resolve9, reject) => __awaiter2(this, undefined, undefined, function* () {
53930
+ return new Promise((resolve8, reject) => __awaiter2(this, undefined, undefined, function* () {
53536
53931
  try {
53537
53932
  (0, helpers_1.validateSocksClientChainOptions)(options);
53538
53933
  } catch (err) {
53539
53934
  if (typeof callback === "function") {
53540
53935
  callback(err);
53541
- return resolve9(err);
53936
+ return resolve8(err);
53542
53937
  } else {
53543
53938
  return reject(err);
53544
53939
  }
@@ -53564,14 +53959,14 @@ var require_socksclient = __commonJS((exports) => {
53564
53959
  }
53565
53960
  if (typeof callback === "function") {
53566
53961
  callback(null, { socket: sock });
53567
- resolve9({ socket: sock });
53962
+ resolve8({ socket: sock });
53568
53963
  } else {
53569
- resolve9({ socket: sock });
53964
+ resolve8({ socket: sock });
53570
53965
  }
53571
53966
  } catch (err) {
53572
53967
  if (typeof callback === "function") {
53573
53968
  callback(err);
53574
- resolve9(err);
53969
+ resolve8(err);
53575
53970
  } else {
53576
53971
  reject(err);
53577
53972
  }
@@ -54171,12 +54566,12 @@ var require_dist4 = __commonJS((exports) => {
54171
54566
  let { host } = opts;
54172
54567
  const { port, lookup: lookupFn = dns.lookup } = opts;
54173
54568
  if (shouldLookup) {
54174
- host = await new Promise((resolve9, reject) => {
54569
+ host = await new Promise((resolve8, reject) => {
54175
54570
  lookupFn(host, {}, (err, res) => {
54176
54571
  if (err) {
54177
54572
  reject(err);
54178
54573
  } else {
54179
- resolve9(res);
54574
+ resolve8(res);
54180
54575
  }
54181
54576
  });
54182
54577
  });
@@ -55183,7 +55578,7 @@ var require_netUtils = __commonJS((exports) => {
55183
55578
  return `${socket.remoteAddress}:${socket.remotePort}`;
55184
55579
  }
55185
55580
  function upgradeSocket(socket, options) {
55186
- return new Promise((resolve9, reject) => {
55581
+ return new Promise((resolve8, reject) => {
55187
55582
  const tlsOptions = Object.assign({}, options, {
55188
55583
  socket
55189
55584
  });
@@ -55193,7 +55588,7 @@ var require_netUtils = __commonJS((exports) => {
55193
55588
  reject(tlsSocket.authorizationError);
55194
55589
  } else {
55195
55590
  tlsSocket.removeAllListeners("error");
55196
- resolve9(tlsSocket);
55591
+ resolve8(tlsSocket);
55197
55592
  }
55198
55593
  }).once("error", (error) => {
55199
55594
  reject(error);
@@ -55285,7 +55680,7 @@ var require_transfer = __commonJS((exports) => {
55285
55680
  };
55286
55681
  }
55287
55682
  function connectForPassiveTransfer(host, port, ftp) {
55288
- return new Promise((resolve9, reject) => {
55683
+ return new Promise((resolve8, reject) => {
55289
55684
  let socket = ftp._newSocket();
55290
55685
  const handleConnErr = function(err) {
55291
55686
  err.message = "Can't open data connection in passive mode: " + err.message;
@@ -55308,7 +55703,7 @@ var require_transfer = __commonJS((exports) => {
55308
55703
  socket.removeListener("error", handleConnErr);
55309
55704
  socket.removeListener("timeout", handleTimeout);
55310
55705
  ftp.dataSocket = socket;
55311
- resolve9();
55706
+ resolve8();
55312
55707
  });
55313
55708
  });
55314
55709
  }
@@ -57386,7 +57781,7 @@ var require_util2 = __commonJS((exports) => {
57386
57781
  return path;
57387
57782
  }
57388
57783
  exports.normalize = normalize2;
57389
- function join31(aRoot, aPath) {
57784
+ function join29(aRoot, aPath) {
57390
57785
  if (aRoot === "") {
57391
57786
  aRoot = ".";
57392
57787
  }
@@ -57418,7 +57813,7 @@ var require_util2 = __commonJS((exports) => {
57418
57813
  }
57419
57814
  return joined;
57420
57815
  }
57421
- exports.join = join31;
57816
+ exports.join = join29;
57422
57817
  exports.isAbsolute = function(aPath) {
57423
57818
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
57424
57819
  };
@@ -57591,7 +57986,7 @@ var require_util2 = __commonJS((exports) => {
57591
57986
  parsed.path = parsed.path.substring(0, index + 1);
57592
57987
  }
57593
57988
  }
57594
- sourceURL = join31(urlGenerate(parsed), sourceURL);
57989
+ sourceURL = join29(urlGenerate(parsed), sourceURL);
57595
57990
  }
57596
57991
  return normalize2(sourceURL);
57597
57992
  }
@@ -59323,7 +59718,7 @@ var require_escodegen = __commonJS((exports) => {
59323
59718
  function noEmptySpace() {
59324
59719
  return space ? space : " ";
59325
59720
  }
59326
- function join31(left, right) {
59721
+ function join29(left, right) {
59327
59722
  var leftSource, rightSource, leftCharCode, rightCharCode;
59328
59723
  leftSource = toSourceNodeWhenNeeded(left).toString();
59329
59724
  if (leftSource.length === 0) {
@@ -59664,8 +60059,8 @@ var require_escodegen = __commonJS((exports) => {
59664
60059
  } else {
59665
60060
  result.push(that.generateExpression(stmt.left, Precedence.Call, E_TTT));
59666
60061
  }
59667
- result = join31(result, operator);
59668
- result = [join31(result, that.generateExpression(stmt.right, Precedence.Assignment, E_TTT)), ")"];
60062
+ result = join29(result, operator);
60063
+ result = [join29(result, that.generateExpression(stmt.right, Precedence.Assignment, E_TTT)), ")"];
59669
60064
  });
59670
60065
  result.push(this.maybeBlock(stmt.body, flags));
59671
60066
  return result;
@@ -59803,11 +60198,11 @@ var require_escodegen = __commonJS((exports) => {
59803
60198
  var result, fragment;
59804
60199
  result = ["class"];
59805
60200
  if (stmt.id) {
59806
- result = join31(result, this.generateExpression(stmt.id, Precedence.Sequence, E_TTT));
60201
+ result = join29(result, this.generateExpression(stmt.id, Precedence.Sequence, E_TTT));
59807
60202
  }
59808
60203
  if (stmt.superClass) {
59809
- fragment = join31("extends", this.generateExpression(stmt.superClass, Precedence.Unary, E_TTT));
59810
- result = join31(result, fragment);
60204
+ fragment = join29("extends", this.generateExpression(stmt.superClass, Precedence.Unary, E_TTT));
60205
+ result = join29(result, fragment);
59811
60206
  }
59812
60207
  result.push(space);
59813
60208
  result.push(this.generateStatement(stmt.body, S_TFFT));
@@ -59820,9 +60215,9 @@ var require_escodegen = __commonJS((exports) => {
59820
60215
  return escapeDirective(stmt.directive) + this.semicolon(flags);
59821
60216
  },
59822
60217
  DoWhileStatement: function(stmt, flags) {
59823
- var result = join31("do", this.maybeBlock(stmt.body, S_TFFF));
60218
+ var result = join29("do", this.maybeBlock(stmt.body, S_TFFF));
59824
60219
  result = this.maybeBlockSuffix(stmt.body, result);
59825
- return join31(result, [
60220
+ return join29(result, [
59826
60221
  "while" + space + "(",
59827
60222
  this.generateExpression(stmt.test, Precedence.Sequence, E_TTT),
59828
60223
  ")" + this.semicolon(flags)
@@ -59858,11 +60253,11 @@ var require_escodegen = __commonJS((exports) => {
59858
60253
  ExportDefaultDeclaration: function(stmt, flags) {
59859
60254
  var result = ["export"], bodyFlags;
59860
60255
  bodyFlags = flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF;
59861
- result = join31(result, "default");
60256
+ result = join29(result, "default");
59862
60257
  if (isStatement(stmt.declaration)) {
59863
- result = join31(result, this.generateStatement(stmt.declaration, bodyFlags));
60258
+ result = join29(result, this.generateStatement(stmt.declaration, bodyFlags));
59864
60259
  } else {
59865
- result = join31(result, this.generateExpression(stmt.declaration, Precedence.Assignment, E_TTT) + this.semicolon(flags));
60260
+ result = join29(result, this.generateExpression(stmt.declaration, Precedence.Assignment, E_TTT) + this.semicolon(flags));
59866
60261
  }
59867
60262
  return result;
59868
60263
  },
@@ -59870,15 +60265,15 @@ var require_escodegen = __commonJS((exports) => {
59870
60265
  var result = ["export"], bodyFlags, that = this;
59871
60266
  bodyFlags = flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF;
59872
60267
  if (stmt.declaration) {
59873
- return join31(result, this.generateStatement(stmt.declaration, bodyFlags));
60268
+ return join29(result, this.generateStatement(stmt.declaration, bodyFlags));
59874
60269
  }
59875
60270
  if (stmt.specifiers) {
59876
60271
  if (stmt.specifiers.length === 0) {
59877
- result = join31(result, "{" + space + "}");
60272
+ result = join29(result, "{" + space + "}");
59878
60273
  } else if (stmt.specifiers[0].type === Syntax.ExportBatchSpecifier) {
59879
- result = join31(result, this.generateExpression(stmt.specifiers[0], Precedence.Sequence, E_TTT));
60274
+ result = join29(result, this.generateExpression(stmt.specifiers[0], Precedence.Sequence, E_TTT));
59880
60275
  } else {
59881
- result = join31(result, "{");
60276
+ result = join29(result, "{");
59882
60277
  withIndent(function(indent2) {
59883
60278
  var i, iz;
59884
60279
  result.push(newline);
@@ -59896,7 +60291,7 @@ var require_escodegen = __commonJS((exports) => {
59896
60291
  result.push(base + "}");
59897
60292
  }
59898
60293
  if (stmt.source) {
59899
- result = join31(result, [
60294
+ result = join29(result, [
59900
60295
  "from" + space,
59901
60296
  this.generateExpression(stmt.source, Precedence.Sequence, E_TTT),
59902
60297
  this.semicolon(flags)
@@ -59980,7 +60375,7 @@ var require_escodegen = __commonJS((exports) => {
59980
60375
  ];
59981
60376
  cursor = 0;
59982
60377
  if (stmt.specifiers[cursor].type === Syntax.ImportDefaultSpecifier) {
59983
- result = join31(result, [
60378
+ result = join29(result, [
59984
60379
  this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)
59985
60380
  ]);
59986
60381
  ++cursor;
@@ -59990,7 +60385,7 @@ var require_escodegen = __commonJS((exports) => {
59990
60385
  result.push(",");
59991
60386
  }
59992
60387
  if (stmt.specifiers[cursor].type === Syntax.ImportNamespaceSpecifier) {
59993
- result = join31(result, [
60388
+ result = join29(result, [
59994
60389
  space,
59995
60390
  this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)
59996
60391
  ]);
@@ -60019,7 +60414,7 @@ var require_escodegen = __commonJS((exports) => {
60019
60414
  }
60020
60415
  }
60021
60416
  }
60022
- result = join31(result, [
60417
+ result = join29(result, [
60023
60418
  "from" + space,
60024
60419
  this.generateExpression(stmt.source, Precedence.Sequence, E_TTT),
60025
60420
  this.semicolon(flags)
@@ -60073,7 +60468,7 @@ var require_escodegen = __commonJS((exports) => {
60073
60468
  return result;
60074
60469
  },
60075
60470
  ThrowStatement: function(stmt, flags) {
60076
- return [join31("throw", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
60471
+ return [join29("throw", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
60077
60472
  },
60078
60473
  TryStatement: function(stmt, flags) {
60079
60474
  var result, i, iz, guardedHandlers;
@@ -60081,7 +60476,7 @@ var require_escodegen = __commonJS((exports) => {
60081
60476
  result = this.maybeBlockSuffix(stmt.block, result);
60082
60477
  if (stmt.handlers) {
60083
60478
  for (i = 0, iz = stmt.handlers.length;i < iz; ++i) {
60084
- result = join31(result, this.generateStatement(stmt.handlers[i], S_TFFF));
60479
+ result = join29(result, this.generateStatement(stmt.handlers[i], S_TFFF));
60085
60480
  if (stmt.finalizer || i + 1 !== iz) {
60086
60481
  result = this.maybeBlockSuffix(stmt.handlers[i].body, result);
60087
60482
  }
@@ -60089,7 +60484,7 @@ var require_escodegen = __commonJS((exports) => {
60089
60484
  } else {
60090
60485
  guardedHandlers = stmt.guardedHandlers || [];
60091
60486
  for (i = 0, iz = guardedHandlers.length;i < iz; ++i) {
60092
- result = join31(result, this.generateStatement(guardedHandlers[i], S_TFFF));
60487
+ result = join29(result, this.generateStatement(guardedHandlers[i], S_TFFF));
60093
60488
  if (stmt.finalizer || i + 1 !== iz) {
60094
60489
  result = this.maybeBlockSuffix(guardedHandlers[i].body, result);
60095
60490
  }
@@ -60097,13 +60492,13 @@ var require_escodegen = __commonJS((exports) => {
60097
60492
  if (stmt.handler) {
60098
60493
  if (Array.isArray(stmt.handler)) {
60099
60494
  for (i = 0, iz = stmt.handler.length;i < iz; ++i) {
60100
- result = join31(result, this.generateStatement(stmt.handler[i], S_TFFF));
60495
+ result = join29(result, this.generateStatement(stmt.handler[i], S_TFFF));
60101
60496
  if (stmt.finalizer || i + 1 !== iz) {
60102
60497
  result = this.maybeBlockSuffix(stmt.handler[i].body, result);
60103
60498
  }
60104
60499
  }
60105
60500
  } else {
60106
- result = join31(result, this.generateStatement(stmt.handler, S_TFFF));
60501
+ result = join29(result, this.generateStatement(stmt.handler, S_TFFF));
60107
60502
  if (stmt.finalizer) {
60108
60503
  result = this.maybeBlockSuffix(stmt.handler.body, result);
60109
60504
  }
@@ -60111,7 +60506,7 @@ var require_escodegen = __commonJS((exports) => {
60111
60506
  }
60112
60507
  }
60113
60508
  if (stmt.finalizer) {
60114
- result = join31(result, ["finally", this.maybeBlock(stmt.finalizer, S_TFFF)]);
60509
+ result = join29(result, ["finally", this.maybeBlock(stmt.finalizer, S_TFFF)]);
60115
60510
  }
60116
60511
  return result;
60117
60512
  },
@@ -60145,7 +60540,7 @@ var require_escodegen = __commonJS((exports) => {
60145
60540
  withIndent(function() {
60146
60541
  if (stmt.test) {
60147
60542
  result = [
60148
- join31("case", that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)),
60543
+ join29("case", that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)),
60149
60544
  ":"
60150
60545
  ];
60151
60546
  } else {
@@ -60193,9 +60588,9 @@ var require_escodegen = __commonJS((exports) => {
60193
60588
  result.push(this.maybeBlock(stmt.consequent, S_TFFF));
60194
60589
  result = this.maybeBlockSuffix(stmt.consequent, result);
60195
60590
  if (stmt.alternate.type === Syntax.IfStatement) {
60196
- result = join31(result, ["else ", this.generateStatement(stmt.alternate, bodyFlags)]);
60591
+ result = join29(result, ["else ", this.generateStatement(stmt.alternate, bodyFlags)]);
60197
60592
  } else {
60198
- result = join31(result, join31("else", this.maybeBlock(stmt.alternate, bodyFlags)));
60593
+ result = join29(result, join29("else", this.maybeBlock(stmt.alternate, bodyFlags)));
60199
60594
  }
60200
60595
  } else {
60201
60596
  result.push(this.maybeBlock(stmt.consequent, bodyFlags));
@@ -60297,7 +60692,7 @@ var require_escodegen = __commonJS((exports) => {
60297
60692
  },
60298
60693
  ReturnStatement: function(stmt, flags) {
60299
60694
  if (stmt.argument) {
60300
- return [join31("return", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
60695
+ return [join29("return", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
60301
60696
  }
60302
60697
  return ["return" + this.semicolon(flags)];
60303
60698
  },
@@ -60379,14 +60774,14 @@ var require_escodegen = __commonJS((exports) => {
60379
60774
  if (leftSource.charCodeAt(leftSource.length - 1) === 47 && esutils.code.isIdentifierPartES5(expr.operator.charCodeAt(0))) {
60380
60775
  result = [fragment, noEmptySpace(), expr.operator];
60381
60776
  } else {
60382
- result = join31(fragment, expr.operator);
60777
+ result = join29(fragment, expr.operator);
60383
60778
  }
60384
60779
  fragment = this.generateExpression(expr.right, rightPrecedence, flags);
60385
60780
  if (expr.operator === "/" && fragment.toString().charAt(0) === "/" || expr.operator.slice(-1) === "<" && fragment.toString().slice(0, 3) === "!--") {
60386
60781
  result.push(noEmptySpace());
60387
60782
  result.push(fragment);
60388
60783
  } else {
60389
- result = join31(result, fragment);
60784
+ result = join29(result, fragment);
60390
60785
  }
60391
60786
  if (expr.operator === "in" && !(flags & F_ALLOW_IN)) {
60392
60787
  return ["(", result, ")"];
@@ -60426,7 +60821,7 @@ var require_escodegen = __commonJS((exports) => {
60426
60821
  var result, length, i, iz, itemFlags;
60427
60822
  length = expr["arguments"].length;
60428
60823
  itemFlags = flags & F_ALLOW_UNPARATH_NEW && !parentheses && length === 0 ? E_TFT : E_TFF;
60429
- result = join31("new", this.generateExpression(expr.callee, Precedence.New, itemFlags));
60824
+ result = join29("new", this.generateExpression(expr.callee, Precedence.New, itemFlags));
60430
60825
  if (!(flags & F_ALLOW_UNPARATH_NEW) || parentheses || length > 0) {
60431
60826
  result.push("(");
60432
60827
  for (i = 0, iz = length;i < iz; ++i) {
@@ -60473,11 +60868,11 @@ var require_escodegen = __commonJS((exports) => {
60473
60868
  var result, fragment, rightCharCode, leftSource, leftCharCode;
60474
60869
  fragment = this.generateExpression(expr.argument, Precedence.Unary, E_TTT);
60475
60870
  if (space === "") {
60476
- result = join31(expr.operator, fragment);
60871
+ result = join29(expr.operator, fragment);
60477
60872
  } else {
60478
60873
  result = [expr.operator];
60479
60874
  if (expr.operator.length > 2) {
60480
- result = join31(result, fragment);
60875
+ result = join29(result, fragment);
60481
60876
  } else {
60482
60877
  leftSource = toSourceNodeWhenNeeded(result).toString();
60483
60878
  leftCharCode = leftSource.charCodeAt(leftSource.length - 1);
@@ -60500,12 +60895,12 @@ var require_escodegen = __commonJS((exports) => {
60500
60895
  result = "yield";
60501
60896
  }
60502
60897
  if (expr.argument) {
60503
- result = join31(result, this.generateExpression(expr.argument, Precedence.Yield, E_TTT));
60898
+ result = join29(result, this.generateExpression(expr.argument, Precedence.Yield, E_TTT));
60504
60899
  }
60505
60900
  return parenthesize(result, Precedence.Yield, precedence);
60506
60901
  },
60507
60902
  AwaitExpression: function(expr, precedence, flags) {
60508
- var result = join31(expr.all ? "await*" : "await", this.generateExpression(expr.argument, Precedence.Await, E_TTT));
60903
+ var result = join29(expr.all ? "await*" : "await", this.generateExpression(expr.argument, Precedence.Await, E_TTT));
60509
60904
  return parenthesize(result, Precedence.Await, precedence);
60510
60905
  },
60511
60906
  UpdateExpression: function(expr, precedence, flags) {
@@ -60577,11 +60972,11 @@ var require_escodegen = __commonJS((exports) => {
60577
60972
  var result, fragment;
60578
60973
  result = ["class"];
60579
60974
  if (expr.id) {
60580
- result = join31(result, this.generateExpression(expr.id, Precedence.Sequence, E_TTT));
60975
+ result = join29(result, this.generateExpression(expr.id, Precedence.Sequence, E_TTT));
60581
60976
  }
60582
60977
  if (expr.superClass) {
60583
- fragment = join31("extends", this.generateExpression(expr.superClass, Precedence.Unary, E_TTT));
60584
- result = join31(result, fragment);
60978
+ fragment = join29("extends", this.generateExpression(expr.superClass, Precedence.Unary, E_TTT));
60979
+ result = join29(result, fragment);
60585
60980
  }
60586
60981
  result.push(space);
60587
60982
  result.push(this.generateStatement(expr.body, S_TFFT));
@@ -60596,7 +60991,7 @@ var require_escodegen = __commonJS((exports) => {
60596
60991
  }
60597
60992
  if (expr.kind === "get" || expr.kind === "set") {
60598
60993
  fragment = [
60599
- join31(expr.kind, this.generatePropertyKey(expr.key, expr.computed)),
60994
+ join29(expr.kind, this.generatePropertyKey(expr.key, expr.computed)),
60600
60995
  this.generateFunctionBody(expr.value)
60601
60996
  ];
60602
60997
  } else {
@@ -60606,7 +61001,7 @@ var require_escodegen = __commonJS((exports) => {
60606
61001
  this.generateFunctionBody(expr.value)
60607
61002
  ];
60608
61003
  }
60609
- return join31(result, fragment);
61004
+ return join29(result, fragment);
60610
61005
  },
60611
61006
  Property: function(expr, precedence, flags) {
60612
61007
  if (expr.kind === "get" || expr.kind === "set") {
@@ -60800,7 +61195,7 @@ var require_escodegen = __commonJS((exports) => {
60800
61195
  for (i = 0, iz = expr.blocks.length;i < iz; ++i) {
60801
61196
  fragment = that.generateExpression(expr.blocks[i], Precedence.Sequence, E_TTT);
60802
61197
  if (i > 0 || extra.moz.comprehensionExpressionStartsWithAssignment) {
60803
- result = join31(result, fragment);
61198
+ result = join29(result, fragment);
60804
61199
  } else {
60805
61200
  result.push(fragment);
60806
61201
  }
@@ -60808,13 +61203,13 @@ var require_escodegen = __commonJS((exports) => {
60808
61203
  });
60809
61204
  }
60810
61205
  if (expr.filter) {
60811
- result = join31(result, "if" + space);
61206
+ result = join29(result, "if" + space);
60812
61207
  fragment = this.generateExpression(expr.filter, Precedence.Sequence, E_TTT);
60813
- result = join31(result, ["(", fragment, ")"]);
61208
+ result = join29(result, ["(", fragment, ")"]);
60814
61209
  }
60815
61210
  if (!extra.moz.comprehensionExpressionStartsWithAssignment) {
60816
61211
  fragment = this.generateExpression(expr.body, Precedence.Assignment, E_TTT);
60817
- result = join31(result, fragment);
61212
+ result = join29(result, fragment);
60818
61213
  }
60819
61214
  result.push(expr.type === Syntax.GeneratorExpression ? ")" : "]");
60820
61215
  return result;
@@ -60830,8 +61225,8 @@ var require_escodegen = __commonJS((exports) => {
60830
61225
  } else {
60831
61226
  fragment = this.generateExpression(expr.left, Precedence.Call, E_TTT);
60832
61227
  }
60833
- fragment = join31(fragment, expr.of ? "of" : "in");
60834
- fragment = join31(fragment, this.generateExpression(expr.right, Precedence.Sequence, E_TTT));
61228
+ fragment = join29(fragment, expr.of ? "of" : "in");
61229
+ fragment = join29(fragment, this.generateExpression(expr.right, Precedence.Sequence, E_TTT));
60835
61230
  return ["for" + space + "(", fragment, ")"];
60836
61231
  },
60837
61232
  SpreadElement: function(expr, precedence, flags) {
@@ -67319,11 +67714,11 @@ var require_tslib = __commonJS((exports, module) => {
67319
67714
  };
67320
67715
  __awaiter2 = function(thisArg, _arguments, P, generator) {
67321
67716
  function adopt(value) {
67322
- return value instanceof P ? value : new P(function(resolve9) {
67323
- resolve9(value);
67717
+ return value instanceof P ? value : new P(function(resolve8) {
67718
+ resolve8(value);
67324
67719
  });
67325
67720
  }
67326
- return new (P || (P = Promise))(function(resolve9, reject) {
67721
+ return new (P || (P = Promise))(function(resolve8, reject) {
67327
67722
  function fulfilled(value) {
67328
67723
  try {
67329
67724
  step(generator.next(value));
@@ -67339,7 +67734,7 @@ var require_tslib = __commonJS((exports, module) => {
67339
67734
  }
67340
67735
  }
67341
67736
  function step(result) {
67342
- result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
67737
+ result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
67343
67738
  }
67344
67739
  step((generator = generator.apply(thisArg, _arguments || [])).next());
67345
67740
  });
@@ -67568,14 +67963,14 @@ var require_tslib = __commonJS((exports, module) => {
67568
67963
  }, i);
67569
67964
  function verb(n) {
67570
67965
  i[n] = o[n] && function(v) {
67571
- return new Promise(function(resolve9, reject) {
67572
- v = o[n](v), settle(resolve9, reject, v.done, v.value);
67966
+ return new Promise(function(resolve8, reject) {
67967
+ v = o[n](v), settle(resolve8, reject, v.done, v.value);
67573
67968
  });
67574
67969
  };
67575
67970
  }
67576
- function settle(resolve9, reject, d, v) {
67971
+ function settle(resolve8, reject, d, v) {
67577
67972
  Promise.resolve(v).then(function(v2) {
67578
- resolve9({ value: v2, done: d });
67973
+ resolve8({ value: v2, done: d });
67579
67974
  }, reject);
67580
67975
  }
67581
67976
  };
@@ -70814,12 +71209,12 @@ var require_util3 = __commonJS((exports) => {
70814
71209
  exports.isGMT = exports.dnsLookup = undefined;
70815
71210
  var dns_1 = __require("dns");
70816
71211
  function dnsLookup(host, opts) {
70817
- return new Promise((resolve9, reject) => {
71212
+ return new Promise((resolve8, reject) => {
70818
71213
  (0, dns_1.lookup)(host, opts, (err, res) => {
70819
71214
  if (err) {
70820
71215
  reject(err);
70821
71216
  } else {
70822
- resolve9(res);
71217
+ resolve8(res);
70823
71218
  }
70824
71219
  });
70825
71220
  });
@@ -71393,10 +71788,10 @@ var require_myIpAddress = __commonJS((exports) => {
71393
71788
  var ip_1 = require_ip();
71394
71789
  var net_1 = __importDefault(__require("net"));
71395
71790
  async function myIpAddress() {
71396
- return new Promise((resolve9, reject) => {
71791
+ return new Promise((resolve8, reject) => {
71397
71792
  const socket = net_1.default.connect({ host: "8.8.8.8", port: 53 });
71398
71793
  const onError = () => {
71399
- resolve9(ip_1.ip.address());
71794
+ resolve8(ip_1.ip.address());
71400
71795
  };
71401
71796
  socket.once("error", onError);
71402
71797
  socket.once("connect", () => {
@@ -71404,9 +71799,9 @@ var require_myIpAddress = __commonJS((exports) => {
71404
71799
  const addr = socket.address();
71405
71800
  socket.destroy();
71406
71801
  if (typeof addr === "string") {
71407
- resolve9(addr);
71802
+ resolve8(addr);
71408
71803
  } else if (addr.address) {
71409
- resolve9(addr.address);
71804
+ resolve8(addr.address);
71410
71805
  } else {
71411
71806
  reject(new Error("Expected a `string`"));
71412
71807
  }
@@ -71920,8 +72315,8 @@ var require_deferred_promise = __commonJS((exports) => {
71920
72315
  this.context = args.context;
71921
72316
  this.owner = args.context.runtime;
71922
72317
  this.handle = args.promiseHandle;
71923
- this.settled = new Promise((resolve9) => {
71924
- this.onSettled = resolve9;
72318
+ this.settled = new Promise((resolve8) => {
72319
+ this.onSettled = resolve8;
71925
72320
  });
71926
72321
  this.resolveHandle = args.resolveHandle;
71927
72322
  this.rejectHandle = args.rejectHandle;
@@ -72313,13 +72708,13 @@ var require_context = __commonJS((exports) => {
72313
72708
  if (vmResolveResult.error) {
72314
72709
  return Promise.resolve(vmResolveResult);
72315
72710
  }
72316
- return new Promise((resolve9) => {
72711
+ return new Promise((resolve8) => {
72317
72712
  lifetime_1.Scope.withScope((scope) => {
72318
72713
  const resolveHandle = scope.manage(this.newFunction("resolve", (value) => {
72319
- resolve9({ value: value && value.dup() });
72714
+ resolve8({ value: value && value.dup() });
72320
72715
  }));
72321
72716
  const rejectHandle = scope.manage(this.newFunction("reject", (error) => {
72322
- resolve9({ error: error && error.dup() });
72717
+ resolve8({ error: error && error.dup() });
72323
72718
  }));
72324
72719
  const promiseHandle = scope.manage(vmResolveResult.value);
72325
72720
  const promiseThenHandle = scope.manage(this.getProp(promiseHandle, "then"));
@@ -74151,7 +74546,7 @@ var require_dist10 = __commonJS((exports) => {
74151
74546
  exports.PacProxyAgent = undefined;
74152
74547
  var net = __importStar(__require("net"));
74153
74548
  var tls = __importStar(__require("tls"));
74154
- var crypto = __importStar(__require("crypto"));
74549
+ var crypto2 = __importStar(__require("crypto"));
74155
74550
  var events_1 = __require("events");
74156
74551
  var debug_1 = __importDefault(require_src());
74157
74552
  var url_1 = __require("url");
@@ -74201,7 +74596,7 @@ var require_dist10 = __commonJS((exports) => {
74201
74596
  (0, quickjs_emscripten_1.getQuickJS)(),
74202
74597
  this.loadPacFile()
74203
74598
  ]);
74204
- const hash = crypto.createHash("sha1").update(code).digest("hex");
74599
+ const hash = crypto2.createHash("sha1").update(code).digest("hex");
74205
74600
  if (this.resolver && this.resolverHash === hash) {
74206
74601
  debug2("Same sha1 hash for code - contents have not changed, reusing previous proxy resolver");
74207
74602
  return this.resolver;
@@ -74433,13 +74828,13 @@ import * as http from "http";
74433
74828
  import * as https from "https";
74434
74829
  import { URL as URL2, urlToHttpOptions } from "url";
74435
74830
  function headHttpRequest(url) {
74436
- return new Promise((resolve9) => {
74831
+ return new Promise((resolve8) => {
74437
74832
  const request3 = httpRequest(url, "HEAD", (response) => {
74438
74833
  response.resume();
74439
- resolve9(response.statusCode === 200);
74834
+ resolve8(response.statusCode === 200);
74440
74835
  }, false);
74441
74836
  request3.on("error", () => {
74442
- resolve9(false);
74837
+ resolve8(false);
74443
74838
  });
74444
74839
  });
74445
74840
  }
@@ -74467,7 +74862,7 @@ function httpRequest(url, method, response, keepAlive = true) {
74467
74862
  return request3;
74468
74863
  }
74469
74864
  function downloadFile(url, destinationPath, progressCallback) {
74470
- return new Promise((resolve9, reject) => {
74865
+ return new Promise((resolve8, reject) => {
74471
74866
  let downloadedBytes = 0;
74472
74867
  let totalBytes = 0;
74473
74868
  function onData(chunk) {
@@ -74483,7 +74878,7 @@ function downloadFile(url, destinationPath, progressCallback) {
74483
74878
  }
74484
74879
  const file = createWriteStream(destinationPath);
74485
74880
  file.on("close", () => {
74486
- return resolve9();
74881
+ return resolve8();
74487
74882
  });
74488
74883
  file.on("error", (error) => {
74489
74884
  return reject(error);
@@ -74508,7 +74903,7 @@ async function getJSON(url) {
74508
74903
  }
74509
74904
  }
74510
74905
  function getText(url) {
74511
- return new Promise((resolve9, reject) => {
74906
+ return new Promise((resolve8, reject) => {
74512
74907
  const request3 = httpRequest(url, "GET", (response) => {
74513
74908
  let data = "";
74514
74909
  if (response.statusCode && response.statusCode >= 400) {
@@ -74519,7 +74914,7 @@ function getText(url) {
74519
74914
  });
74520
74915
  response.on("end", () => {
74521
74916
  try {
74522
- return resolve9(String(data));
74917
+ return resolve8(String(data));
74523
74918
  } catch {
74524
74919
  return reject(new Error(`Failed to read text response from ${url}`));
74525
74920
  }
@@ -74536,7 +74931,7 @@ var init_httpUtil = __esm(() => {
74536
74931
  });
74537
74932
 
74538
74933
  // node_modules/@puppeteer/browsers/lib/esm/browser-data/chrome.js
74539
- import { execSync as execSync9 } from "child_process";
74934
+ import { execSync as execSync8 } from "child_process";
74540
74935
  import os from "os";
74541
74936
  import path from "path";
74542
74937
  function folder(platform2) {
@@ -74626,7 +75021,7 @@ function getChromeWindowsLocation(channel2, locationsPrefixes) {
74626
75021
  }
74627
75022
  function getWslVariable(variable) {
74628
75023
  try {
74629
- const result = execSync9(`cmd.exe /c echo %${variable.toLocaleUpperCase()}%`, {
75024
+ const result = execSync8(`cmd.exe /c echo %${variable.toLocaleUpperCase()}%`, {
74630
75025
  stdio: ["ignore", "pipe", "ignore"],
74631
75026
  encoding: "utf-8"
74632
75027
  }).trim();
@@ -74637,7 +75032,7 @@ function getWslVariable(variable) {
74637
75032
  return;
74638
75033
  }
74639
75034
  function getWslLocation(channel2) {
74640
- const wslVersion = execSync9("wslinfo --version", {
75035
+ const wslVersion = execSync8("wslinfo --version", {
74641
75036
  stdio: ["ignore", "pipe", "ignore"],
74642
75037
  encoding: "utf-8"
74643
75038
  }).trim();
@@ -74653,7 +75048,7 @@ function getWslLocation(channel2) {
74653
75048
  }
74654
75049
  const windowsPath = getChromeWindowsLocation(channel2, wslPrefixes);
74655
75050
  return windowsPath.map((path2) => {
74656
- return execSync9(`wslpath "${path2}"`).toString().trim();
75051
+ return execSync8(`wslpath "${path2}"`).toString().trim();
74657
75052
  });
74658
75053
  }
74659
75054
  function getChromeLinuxOrWslLocation(channel2) {
@@ -75740,7 +76135,7 @@ class Process {
75740
76135
  if (opts.onExit) {
75741
76136
  this.#onExitHook = opts.onExit;
75742
76137
  }
75743
- this.#browserProcessExiting = new Promise((resolve9, reject) => {
76138
+ this.#browserProcessExiting = new Promise((resolve8, reject) => {
75744
76139
  this.#browserProcess.once("exit", async () => {
75745
76140
  debugLaunch(`Browser process ${this.#browserProcess.pid} onExit`);
75746
76141
  this.#clearListeners();
@@ -75751,7 +76146,7 @@ class Process {
75751
76146
  reject(err);
75752
76147
  return;
75753
76148
  }
75754
- resolve9();
76149
+ resolve8();
75755
76150
  });
75756
76151
  });
75757
76152
  }
@@ -75861,7 +76256,7 @@ Error cause: ${isErrorLike2(error) ? error.stack : error}`);
75861
76256
  return [...this.#logs];
75862
76257
  }
75863
76258
  waitForLineOutput(regex, timeout2 = 0) {
75864
- return new Promise((resolve9, reject) => {
76259
+ return new Promise((resolve8, reject) => {
75865
76260
  const onClose = (errorOrCode) => {
75866
76261
  cleanup();
75867
76262
  reject(new Error([
@@ -75899,7 +76294,7 @@ Error cause: ${isErrorLike2(error) ? error.stack : error}`);
75899
76294
  return;
75900
76295
  }
75901
76296
  cleanup();
75902
- resolve9(match[1]);
76297
+ resolve8(match[1]);
75903
76298
  }
75904
76299
  });
75905
76300
  }
@@ -76429,7 +76824,7 @@ var require_get_stream = __commonJS((exports, module) => {
76429
76824
  };
76430
76825
  const { maxBuffer } = options;
76431
76826
  let stream;
76432
- await new Promise((resolve9, reject) => {
76827
+ await new Promise((resolve8, reject) => {
76433
76828
  const rejectPromise = (error) => {
76434
76829
  if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
76435
76830
  error.bufferedData = stream.getBufferedValue();
@@ -76441,7 +76836,7 @@ var require_get_stream = __commonJS((exports, module) => {
76441
76836
  rejectPromise(error);
76442
76837
  return;
76443
76838
  }
76444
- resolve9();
76839
+ resolve8();
76445
76840
  });
76446
76841
  stream.on("data", () => {
76447
76842
  if (stream.getBufferedLength() > maxBuffer) {
@@ -77802,7 +78197,7 @@ var require_extract_zip = __commonJS((exports, module) => {
77802
78197
  debug4("opening", this.zipPath, "with opts", this.opts);
77803
78198
  this.zipfile = await openZip(this.zipPath, { lazyEntries: true });
77804
78199
  this.canceled = false;
77805
- return new Promise((resolve9, reject) => {
78200
+ return new Promise((resolve8, reject) => {
77806
78201
  this.zipfile.on("error", (err) => {
77807
78202
  this.canceled = true;
77808
78203
  reject(err);
@@ -77811,7 +78206,7 @@ var require_extract_zip = __commonJS((exports, module) => {
77811
78206
  this.zipfile.on("close", () => {
77812
78207
  if (!this.canceled) {
77813
78208
  debug4("zip extraction complete");
77814
- resolve9();
78209
+ resolve8();
77815
78210
  }
77816
78211
  });
77817
78212
  this.zipfile.on("entry", async (entry) => {
@@ -79153,8 +79548,8 @@ var require_streamx = __commonJS((exports, module) => {
79153
79548
  return this;
79154
79549
  },
79155
79550
  next() {
79156
- return new Promise(function(resolve9, reject) {
79157
- promiseResolve = resolve9;
79551
+ return new Promise(function(resolve8, reject) {
79552
+ promiseResolve = resolve8;
79158
79553
  promiseReject = reject;
79159
79554
  const data = stream.read();
79160
79555
  if (data !== null)
@@ -79191,14 +79586,14 @@ var require_streamx = __commonJS((exports, module) => {
79191
79586
  }
79192
79587
  function destroy(err) {
79193
79588
  stream.destroy(err);
79194
- return new Promise((resolve9, reject) => {
79589
+ return new Promise((resolve8, reject) => {
79195
79590
  if (stream._duplexState & DESTROYED)
79196
- return resolve9({ value: undefined, done: true });
79591
+ return resolve8({ value: undefined, done: true });
79197
79592
  stream.once("close", function() {
79198
79593
  if (err)
79199
79594
  reject(err);
79200
79595
  else
79201
- resolve9({ value: undefined, done: true });
79596
+ resolve8({ value: undefined, done: true });
79202
79597
  });
79203
79598
  });
79204
79599
  }
@@ -79250,8 +79645,8 @@ var require_streamx = __commonJS((exports, module) => {
79250
79645
  return Promise.resolve(true);
79251
79646
  if (state.drains === null)
79252
79647
  state.drains = [];
79253
- return new Promise((resolve9) => {
79254
- state.drains.push({ writes, resolve: resolve9 });
79648
+ return new Promise((resolve8) => {
79649
+ state.drains.push({ writes, resolve: resolve8 });
79255
79650
  });
79256
79651
  }
79257
79652
  write(data) {
@@ -79365,11 +79760,11 @@ var require_streamx = __commonJS((exports, module) => {
79365
79760
  cb(null);
79366
79761
  }
79367
79762
  function pipelinePromise(...streams) {
79368
- return new Promise((resolve9, reject) => {
79763
+ return new Promise((resolve8, reject) => {
79369
79764
  return pipeline(...streams, (err) => {
79370
79765
  if (err)
79371
79766
  return reject(err);
79372
- resolve9();
79767
+ resolve8();
79373
79768
  });
79374
79769
  });
79375
79770
  }
@@ -80083,16 +80478,16 @@ var require_extract = __commonJS((exports, module) => {
80083
80478
  entryCallback = null;
80084
80479
  cb(err);
80085
80480
  }
80086
- function onnext(resolve9, reject) {
80481
+ function onnext(resolve8, reject) {
80087
80482
  if (error) {
80088
80483
  return reject(error);
80089
80484
  }
80090
80485
  if (entryStream) {
80091
- resolve9({ value: entryStream, done: false });
80486
+ resolve8({ value: entryStream, done: false });
80092
80487
  entryStream = null;
80093
80488
  return;
80094
80489
  }
80095
- promiseResolve = resolve9;
80490
+ promiseResolve = resolve8;
80096
80491
  promiseReject = reject;
80097
80492
  consumeCallback(null);
80098
80493
  if (extract._finished && promiseResolve) {
@@ -80123,14 +80518,14 @@ var require_extract = __commonJS((exports, module) => {
80123
80518
  function destroy(err) {
80124
80519
  extract.destroy(err);
80125
80520
  consumeCallback(err);
80126
- return new Promise((resolve9, reject) => {
80521
+ return new Promise((resolve8, reject) => {
80127
80522
  if (extract.destroyed)
80128
- return resolve9({ value: undefined, done: true });
80523
+ return resolve8({ value: undefined, done: true });
80129
80524
  extract.once("close", function() {
80130
80525
  if (err)
80131
80526
  reject(err);
80132
80527
  else
80133
- resolve9({ value: undefined, done: true });
80528
+ resolve8({ value: undefined, done: true });
80134
80529
  });
80135
80530
  });
80136
80531
  }
@@ -80928,7 +81323,7 @@ var init_fileUtil = __esm(() => {
80928
81323
  // node_modules/@puppeteer/browsers/lib/esm/install.js
80929
81324
  import assert2 from "assert";
80930
81325
  import { spawnSync as spawnSync4 } from "child_process";
80931
- import { existsSync as existsSync35, readFileSync as readFileSync26 } from "fs";
81326
+ import { existsSync as existsSync33, readFileSync as readFileSync26 } from "fs";
80932
81327
  import { mkdir as mkdir2, unlink } from "fs/promises";
80933
81328
  import os5 from "os";
80934
81329
  import path8 from "path";
@@ -80981,7 +81376,7 @@ async function installWithProviders(options) {
80981
81376
  continue;
80982
81377
  }
80983
81378
  debugInstall(`Successfully got URL from ${provider.getName()}: ${url}`);
80984
- if (!existsSync35(browserRoot)) {
81379
+ if (!existsSync33(browserRoot)) {
80985
81380
  await mkdir2(browserRoot, { recursive: true });
80986
81381
  }
80987
81382
  return await installUrl(url, options, provider);
@@ -81014,7 +81409,7 @@ async function installDeps(installedBrowser) {
81014
81409
  return;
81015
81410
  }
81016
81411
  const depsPath = path8.join(path8.dirname(installedBrowser.executablePath), "deb.deps");
81017
- if (!existsSync35(depsPath)) {
81412
+ if (!existsSync33(depsPath)) {
81018
81413
  debugInstall(`deb.deps file was not found at ${depsPath}`);
81019
81414
  return;
81020
81415
  }
@@ -81056,11 +81451,11 @@ async function installUrl(url, options, provider) {
81056
81451
  const cache = new Cache(options.cacheDir);
81057
81452
  const browserRoot = cache.browserRoot(options.browser);
81058
81453
  const archivePath = path8.join(browserRoot, `${options.buildId}-${fileName}`);
81059
- if (!existsSync35(browserRoot)) {
81454
+ if (!existsSync33(browserRoot)) {
81060
81455
  await mkdir2(browserRoot, { recursive: true });
81061
81456
  }
81062
81457
  if (!options.unpack) {
81063
- if (existsSync35(archivePath)) {
81458
+ if (existsSync33(archivePath)) {
81064
81459
  return archivePath;
81065
81460
  }
81066
81461
  debugInstall(`Downloading binary from ${url}`);
@@ -81081,8 +81476,8 @@ async function installUrl(url, options, provider) {
81081
81476
  cache.writeExecutablePath(options.browser, options.platform, options.buildId, relativeExecutablePath6);
81082
81477
  }
81083
81478
  try {
81084
- if (existsSync35(outputPath)) {
81085
- if (!existsSync35(installedBrowser.executablePath)) {
81479
+ if (existsSync33(outputPath)) {
81480
+ if (!existsSync33(installedBrowser.executablePath)) {
81086
81481
  throw new Error(`The browser folder (${outputPath}) exists but the executable (${installedBrowser.executablePath}) is missing`);
81087
81482
  }
81088
81483
  await runSetup(installedBrowser);
@@ -81091,7 +81486,7 @@ async function installUrl(url, options, provider) {
81091
81486
  }
81092
81487
  return installedBrowser;
81093
81488
  }
81094
- if (!existsSync35(archivePath)) {
81489
+ if (!existsSync33(archivePath)) {
81095
81490
  debugInstall(`Downloading binary from ${url}`);
81096
81491
  try {
81097
81492
  debugTime("download");
@@ -81120,7 +81515,7 @@ async function installUrl(url, options, provider) {
81120
81515
  }
81121
81516
  return installedBrowser;
81122
81517
  } finally {
81123
- if (existsSync35(archivePath)) {
81518
+ if (existsSync33(archivePath)) {
81124
81519
  await unlink(archivePath);
81125
81520
  }
81126
81521
  }
@@ -81131,7 +81526,7 @@ async function runSetup(installedBrowser) {
81131
81526
  debugTime("permissions");
81132
81527
  const browserDir = path8.dirname(installedBrowser.executablePath);
81133
81528
  const setupExePath = path8.join(browserDir, "setup.exe");
81134
- if (!existsSync35(setupExePath)) {
81529
+ if (!existsSync33(setupExePath)) {
81135
81530
  return;
81136
81531
  }
81137
81532
  spawnSync4(path8.join(browserDir, "setup.exe"), [`--configure-browser-in-directory=` + browserDir], {
@@ -81472,12 +81867,12 @@ var init_lib = __esm(() => {
81472
81867
  });
81473
81868
 
81474
81869
  // node_modules/cliui/build/lib/string-utils.js
81475
- function stripAnsi(str) {
81870
+ function stripAnsi2(str) {
81476
81871
  return str.replace(ansi, "");
81477
81872
  }
81478
81873
  function wrap(str, width) {
81479
81874
  const [start, end] = str.match(ansi) || ["", ""];
81480
- str = stripAnsi(str);
81875
+ str = stripAnsi2(str);
81481
81876
  let wrapped = "";
81482
81877
  for (let i = 0;i < str.length; i++) {
81483
81878
  if (i !== 0 && i % width === 0) {
@@ -81502,7 +81897,7 @@ function ui(opts) {
81502
81897
  stringWidth: (str) => {
81503
81898
  return [...str].length;
81504
81899
  },
81505
- stripAnsi,
81900
+ stripAnsi: stripAnsi2,
81506
81901
  wrap
81507
81902
  });
81508
81903
  }
@@ -81512,19 +81907,19 @@ var init_cliui = __esm(() => {
81512
81907
  });
81513
81908
 
81514
81909
  // node_modules/escalade/sync/index.mjs
81515
- import { dirname as dirname14, resolve as resolve10 } from "path";
81910
+ import { dirname as dirname13, resolve as resolve9 } from "path";
81516
81911
  import { readdirSync as readdirSync11, statSync as statSync12 } from "fs";
81517
81912
  function sync_default(start, callback) {
81518
- let dir = resolve10(".", start);
81913
+ let dir = resolve9(".", start);
81519
81914
  let tmp, stats = statSync12(dir);
81520
81915
  if (!stats.isDirectory()) {
81521
- dir = dirname14(dir);
81916
+ dir = dirname13(dir);
81522
81917
  }
81523
81918
  while (true) {
81524
81919
  tmp = callback(dir, readdirSync11(dir));
81525
81920
  if (tmp)
81526
- return resolve10(dir, tmp);
81527
- dir = dirname14(tmp = dir);
81921
+ return resolve9(dir, tmp);
81922
+ dir = dirname13(tmp = dir);
81528
81923
  if (tmp === dir)
81529
81924
  break;
81530
81925
  }
@@ -82470,7 +82865,7 @@ var init_yargs_parser = __esm(() => {
82470
82865
 
82471
82866
  // node_modules/yargs-parser/build/lib/index.js
82472
82867
  import { format } from "util";
82473
- import { normalize as normalize2, resolve as resolve11 } from "path";
82868
+ import { normalize as normalize2, resolve as resolve10 } from "path";
82474
82869
  var _a3, _b, _c, minNodeVersion, nodeVersion, env, parser, yargsParser = function Parser(args, opts) {
82475
82870
  const result = parser.parse(args.slice(), opts);
82476
82871
  return result.argv;
@@ -82493,7 +82888,7 @@ var init_lib2 = __esm(() => {
82493
82888
  },
82494
82889
  format,
82495
82890
  normalize: normalize2,
82496
- resolve: resolve11,
82891
+ resolve: resolve10,
82497
82892
  require: (path9) => {
82498
82893
  if (true) {
82499
82894
  return __require(path9);
@@ -82545,7 +82940,7 @@ var init_yerror = __esm(() => {
82545
82940
  // node_modules/y18n/build/lib/platform-shims/node.js
82546
82941
  import { readFileSync as readFileSync27, statSync as statSync13, writeFile } from "fs";
82547
82942
  import { format as format2 } from "util";
82548
- import { resolve as resolve12 } from "path";
82943
+ import { resolve as resolve11 } from "path";
82549
82944
  var node_default;
82550
82945
  var init_node = __esm(() => {
82551
82946
  node_default = {
@@ -82554,7 +82949,7 @@ var init_node = __esm(() => {
82554
82949
  writeFile
82555
82950
  },
82556
82951
  format: format2,
82557
- resolve: resolve12,
82952
+ resolve: resolve11,
82558
82953
  exists: (file) => {
82559
82954
  try {
82560
82955
  return statSync13(file).isFile();
@@ -82737,7 +83132,7 @@ import { notStrictEqual, strictEqual } from "assert";
82737
83132
  import { inspect } from "util";
82738
83133
  import { readFileSync as readFileSync28 } from "fs";
82739
83134
  import { fileURLToPath } from "url";
82740
- import { basename as basename8, dirname as dirname15, extname as extname3, relative as relative8, resolve as resolve13 } from "path";
83135
+ import { basename as basename8, dirname as dirname14, extname as extname3, relative as relative8, resolve as resolve12 } from "path";
82741
83136
  var REQUIRE_ERROR = "require is not supported by ESM", REQUIRE_DIRECTORY_ERROR = "loading a directory of commands is not supported yet for ESM", __dirname2, mainFilename, esm_default;
82742
83137
  var init_esm = __esm(() => {
82743
83138
  init_cliui();
@@ -82770,10 +83165,10 @@ var init_esm = __esm(() => {
82770
83165
  Parser: lib_default,
82771
83166
  path: {
82772
83167
  basename: basename8,
82773
- dirname: dirname15,
83168
+ dirname: dirname14,
82774
83169
  extname: extname3,
82775
83170
  relative: relative8,
82776
- resolve: resolve13
83171
+ resolve: resolve12
82777
83172
  },
82778
83173
  process: {
82779
83174
  argv: () => process.argv,
@@ -82795,7 +83190,7 @@ var init_esm = __esm(() => {
82795
83190
  return [...str].length;
82796
83191
  },
82797
83192
  y18n: y18n_default({
82798
- directory: resolve13(__dirname2, "../../../locales"),
83193
+ directory: resolve12(__dirname2, "../../../locales"),
82799
83194
  updateFiles: false
82800
83195
  })
82801
83196
  };
@@ -85043,12 +85438,12 @@ var init_yargs_factory = __esm(() => {
85043
85438
  async getCompletion(args, done) {
85044
85439
  argsert("<array> [function]", [args, done], arguments.length);
85045
85440
  if (!done) {
85046
- return new Promise((resolve14, reject) => {
85441
+ return new Promise((resolve13, reject) => {
85047
85442
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
85048
85443
  if (err)
85049
85444
  reject(err);
85050
85445
  else
85051
- resolve14(completions);
85446
+ resolve13(completions);
85052
85447
  });
85053
85448
  });
85054
85449
  } else {
@@ -86483,9 +86878,9 @@ async function getConnectionTransport(options) {
86483
86878
  throw new Error("Could not detect required browser platform");
86484
86879
  }
86485
86880
  const { convertPuppeteerChannelToBrowsersChannel: convertPuppeteerChannelToBrowsersChannel2 } = await Promise.resolve().then(() => (init_LaunchOptions(), exports_LaunchOptions));
86486
- const { join: join32 } = await import("path");
86881
+ const { join: join30 } = await import("path");
86487
86882
  const userDataDir = resolveDefaultUserDataDir3(Browser7.CHROME, platform2, convertPuppeteerChannelToBrowsersChannel2(options.channel));
86488
- const portPath = join32(userDataDir, "DevToolsActivePort");
86883
+ const portPath = join30(userDataDir, "DevToolsActivePort");
86489
86884
  try {
86490
86885
  const fileContent = await environment.value.fs.promises.readFile(portPath, "ascii");
86491
86886
  const [rawPort, rawPath] = fileContent.split(`
@@ -86709,9 +87104,9 @@ var init_PipeTransport = __esm(() => {
86709
87104
  });
86710
87105
 
86711
87106
  // node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserLauncher.js
86712
- import { existsSync as existsSync36 } from "fs";
87107
+ import { existsSync as existsSync34 } from "fs";
86713
87108
  import { tmpdir } from "os";
86714
- import { join as join32 } from "path";
87109
+ import { join as join30 } from "path";
86715
87110
 
86716
87111
  class BrowserLauncher {
86717
87112
  #browser;
@@ -86736,7 +87131,7 @@ class BrowserLauncher {
86736
87131
  ...options,
86737
87132
  protocol
86738
87133
  });
86739
- if (!existsSync36(launchArgs.executablePath)) {
87134
+ if (!existsSync34(launchArgs.executablePath)) {
86740
87135
  throw new Error(`Browser was not found at the configured executablePath (${launchArgs.executablePath})`);
86741
87136
  }
86742
87137
  const usePipe = launchArgs.args.includes("--remote-debugging-pipe");
@@ -86811,7 +87206,7 @@ class BrowserLauncher {
86811
87206
  browserCloseCallback();
86812
87207
  const logs = browserProcess.getRecentLogs().join(`
86813
87208
  `);
86814
- if (logs.includes("Failed to create a ProcessSingleton for your profile directory") || process.platform === "win32" && existsSync36(join32(launchArgs.userDataDir, "lockfile"))) {
87209
+ if (logs.includes("Failed to create a ProcessSingleton for your profile directory") || process.platform === "win32" && existsSync34(join30(launchArgs.userDataDir, "lockfile"))) {
86815
87210
  throw new Error(`The browser is already running for ${launchArgs.userDataDir}. Use a different \`userDataDir\` or stop the running browser first.`);
86816
87211
  }
86817
87212
  if (logs.includes("Missing X server") && options.headless === false) {
@@ -86901,12 +87296,12 @@ class BrowserLauncher {
86901
87296
  });
86902
87297
  }
86903
87298
  getProfilePath() {
86904
- return join32(this.puppeteer.configuration.temporaryDirectory ?? tmpdir(), `puppeteer_dev_${this.browser}_profile-`);
87299
+ return join30(this.puppeteer.configuration.temporaryDirectory ?? tmpdir(), `puppeteer_dev_${this.browser}_profile-`);
86905
87300
  }
86906
87301
  resolveExecutablePath(headless, validatePath = true) {
86907
87302
  let executablePath = this.puppeteer.configuration.executablePath;
86908
87303
  if (executablePath) {
86909
- if (validatePath && !existsSync36(executablePath)) {
87304
+ if (validatePath && !existsSync34(executablePath)) {
86910
87305
  throw new Error(`Tried to find the browser at the configured path (${executablePath}), but no executable was found.`);
86911
87306
  }
86912
87307
  return executablePath;
@@ -86929,7 +87324,7 @@ class BrowserLauncher {
86929
87324
  browser: browserType,
86930
87325
  buildId: this.puppeteer.browserVersion
86931
87326
  });
86932
- if (validatePath && !existsSync36(executablePath)) {
87327
+ if (validatePath && !existsSync34(executablePath)) {
86933
87328
  const configVersion = this.puppeteer.configuration?.[this.browser]?.version;
86934
87329
  if (configVersion) {
86935
87330
  throw new Error(`Tried to find the browser at the configured path (${executablePath}) for version ${configVersion}, but no executable was found.`);
@@ -87467,7 +87862,7 @@ var init_PuppeteerNode = __esm(() => {
87467
87862
  import { spawn as spawn2, spawnSync as spawnSync5 } from "child_process";
87468
87863
  import fs5 from "fs";
87469
87864
  import os8 from "os";
87470
- import { dirname as dirname16 } from "path";
87865
+ import { dirname as dirname15 } from "path";
87471
87866
  import { PassThrough } from "stream";
87472
87867
  var import_debug6, __runInitializers22 = function(thisArg, initializers, value) {
87473
87868
  var useValue = arguments.length > 2;
@@ -87541,8 +87936,8 @@ var init_ScreenRecorder = __esm(() => {
87541
87936
  static {
87542
87937
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : undefined;
87543
87938
  __esDecorate22(this, _private_writeFrame_descriptor = { value: __setFunctionName5(async function(buffer) {
87544
- const error = await new Promise((resolve14) => {
87545
- this.#process.stdin.write(buffer, resolve14);
87939
+ const error = await new Promise((resolve13) => {
87940
+ this.#process.stdin.write(buffer, resolve13);
87546
87941
  });
87547
87942
  if (error) {
87548
87943
  console.log(`ffmpeg failed to write: ${error.message}.`);
@@ -87591,7 +87986,7 @@ var init_ScreenRecorder = __esm(() => {
87591
87986
  filters.push(formatArgs.splice(vf, 2).at(-1) ?? "");
87592
87987
  }
87593
87988
  if (path11) {
87594
- fs5.mkdirSync(dirname16(path11), { recursive: overwrite });
87989
+ fs5.mkdirSync(dirname15(path11), { recursive: overwrite });
87595
87990
  }
87596
87991
  this.#process = spawn2(ffmpegPath, [
87597
87992
  ["-loglevel", "error"],
@@ -87697,8 +88092,8 @@ var init_ScreenRecorder = __esm(() => {
87697
88092
  const [buffer, timestamp] = await this.#lastFrame;
87698
88093
  await Promise.all(Array(Math.max(1, Math.round(this.#fps * (performance.now() - timestamp) / 1000))).fill(buffer).map(this.#writeFrame.bind(this)));
87699
88094
  this.#process.stdin.end();
87700
- await new Promise((resolve14) => {
87701
- this.#process.once("close", resolve14);
88095
+ await new Promise((resolve13) => {
88096
+ this.#process.once("close", resolve13);
87702
88097
  });
87703
88098
  }
87704
88099
  async[(_private_writeFrame_decorators = [guarded()], _stop_decorators = [guarded()], asyncDisposeSymbol)]() {
@@ -87744,17 +88139,17 @@ var init_puppeteer_core = __esm(() => {
87744
88139
  });
87745
88140
 
87746
88141
  // src/core/design-eval/capture.ts
87747
- import { mkdirSync as mkdirSync16, statSync as statSync14, existsSync as existsSync37 } from "fs";
87748
- import { join as join33 } from "path";
88142
+ import { mkdirSync as mkdirSync15, statSync as statSync14, existsSync as existsSync35 } from "fs";
88143
+ import { join as join31 } from "path";
87749
88144
  function findBrowser() {
87750
88145
  const platform2 = process.platform;
87751
88146
  const paths = CHROME_PATHS[platform2] ?? [];
87752
88147
  for (const p of paths) {
87753
- if (existsSync37(p))
88148
+ if (existsSync35(p))
87754
88149
  return p;
87755
88150
  }
87756
- const minkBrowsers = join33(minkRoot(), "browsers");
87757
- if (existsSync37(minkBrowsers)) {
88151
+ const minkBrowsers = join31(minkRoot(), "browsers");
88152
+ if (existsSync35(minkBrowsers)) {
87758
88153
  const found = findChromeInDir(minkBrowsers);
87759
88154
  if (found)
87760
88155
  return found;
@@ -87775,7 +88170,7 @@ function findChromeInDir(dir) {
87775
88170
  try {
87776
88171
  const entries = readdirSync12(dir);
87777
88172
  for (const entry of entries) {
87778
- const full = join33(dir, entry);
88173
+ const full = join31(dir, entry);
87779
88174
  try {
87780
88175
  const stat2 = statSync15(full);
87781
88176
  if (stat2.isDirectory()) {
@@ -87823,7 +88218,7 @@ async function captureRoute(page, route, baseUrl, viewport, options) {
87823
88218
  const y = section * viewport.height;
87824
88219
  const clipHeight = Math.min(viewport.height, pageHeight - y);
87825
88220
  const fileName = `${prefix}-${viewport.name}-${section}.jpg`;
87826
- const filePath = join33(options.outputDir, fileName);
88221
+ const filePath = join31(options.outputDir, fileName);
87827
88222
  await page.screenshot({
87828
88223
  path: filePath,
87829
88224
  type: "jpeg",
@@ -87855,7 +88250,7 @@ async function captureRoute(page, route, baseUrl, viewport, options) {
87855
88250
  return results;
87856
88251
  }
87857
88252
  async function captureAllRoutes(routes, baseUrl, viewports, options, outputDir) {
87858
- mkdirSync16(outputDir, { recursive: true });
88253
+ mkdirSync15(outputDir, { recursive: true });
87859
88254
  const executablePath = findBrowser();
87860
88255
  const browser = await puppeteer_core_default.launch({
87861
88256
  executablePath,
@@ -89292,9 +89687,9 @@ var exports_wiki = {};
89292
89687
  __export(exports_wiki, {
89293
89688
  wiki: () => wiki
89294
89689
  });
89295
- import { existsSync as existsSync38, statSync as statSync15 } from "fs";
89296
- import { resolve as resolve14 } from "path";
89297
- import { homedir as homedir5 } from "os";
89690
+ import { existsSync as existsSync36, statSync as statSync15 } from "fs";
89691
+ import { resolve as resolve13 } from "path";
89692
+ import { homedir as homedir4 } from "os";
89298
89693
  async function wiki(_cwd, args) {
89299
89694
  const sub = args[0];
89300
89695
  switch (sub) {
@@ -89350,7 +89745,7 @@ async function wikiInit(args) {
89350
89745
  console.log(`[mink] initializing vault at ${targetPath}`);
89351
89746
  console.log(" (set a custom path with: mink wiki init /path/to/vault)");
89352
89747
  }
89353
- const isExisting = existsSync38(targetPath) && statSync15(targetPath).isDirectory();
89748
+ const isExisting = existsSync36(targetPath) && statSync15(targetPath).isDirectory();
89354
89749
  setConfigValue("wiki.path", targetPath);
89355
89750
  ensureVaultStructure();
89356
89751
  seedTemplates(vaultTemplates());
@@ -89560,9 +89955,9 @@ function wikiLinks() {
89560
89955
  }
89561
89956
  function expandPath(raw) {
89562
89957
  if (raw.startsWith("~/")) {
89563
- return resolve14(homedir5(), raw.slice(2));
89958
+ return resolve13(homedir4(), raw.slice(2));
89564
89959
  }
89565
- return resolve14(raw);
89960
+ return resolve13(raw);
89566
89961
  }
89567
89962
  var init_wiki = __esm(() => {
89568
89963
  init_vault();
@@ -89578,8 +89973,8 @@ var exports_note = {};
89578
89973
  __export(exports_note, {
89579
89974
  note: () => note
89580
89975
  });
89581
- import { resolve as resolve15 } from "path";
89582
- import { existsSync as existsSync39, readFileSync as readFileSync29 } from "fs";
89976
+ import { resolve as resolve14 } from "path";
89977
+ import { existsSync as existsSync37, readFileSync as readFileSync29 } from "fs";
89583
89978
  async function note(cwd, args) {
89584
89979
  if (!isWikiEnabled()) {
89585
89980
  console.error("[mink] wiki feature is disabled");
@@ -89609,8 +90004,8 @@ async function note(cwd, args) {
89609
90004
  return;
89610
90005
  }
89611
90006
  if (parsed.file) {
89612
- const sourcePath = resolve15(cwd, parsed.file);
89613
- if (!existsSync39(sourcePath)) {
90007
+ const sourcePath = resolve14(cwd, parsed.file);
90008
+ if (!existsSync37(sourcePath)) {
89614
90009
  console.error(`[mink] file not found: ${sourcePath}`);
89615
90010
  process.exit(1);
89616
90011
  }
@@ -89771,39 +90166,39 @@ var exports_skill = {};
89771
90166
  __export(exports_skill, {
89772
90167
  skill: () => skill
89773
90168
  });
89774
- import { join as join34, resolve as resolve16, dirname as dirname17 } from "path";
89775
- import { homedir as homedir6 } from "os";
90169
+ import { join as join32, resolve as resolve15, dirname as dirname16 } from "path";
90170
+ import { homedir as homedir5 } from "os";
89776
90171
  import {
89777
- existsSync as existsSync40,
89778
- mkdirSync as mkdirSync17,
89779
- copyFileSync as copyFileSync2,
90172
+ existsSync as existsSync38,
90173
+ mkdirSync as mkdirSync16,
90174
+ copyFileSync,
89780
90175
  unlinkSync as unlinkSync6,
89781
90176
  readdirSync as readdirSync12,
89782
- rmSync as rmSync3,
90177
+ rmSync as rmSync2,
89783
90178
  symlinkSync as symlinkSync2,
89784
90179
  lstatSync as lstatSync2
89785
90180
  } from "fs";
89786
90181
  function getSkillsSourceDir() {
89787
- let dir = dirname17(new URL(import.meta.url).pathname);
90182
+ let dir = dirname16(new URL(import.meta.url).pathname);
89788
90183
  while (true) {
89789
- if (existsSync40(join34(dir, "package.json")) && existsSync40(join34(dir, "skills"))) {
89790
- return join34(dir, "skills");
90184
+ if (existsSync38(join32(dir, "package.json")) && existsSync38(join32(dir, "skills"))) {
90185
+ return join32(dir, "skills");
89791
90186
  }
89792
- const parent = dirname17(dir);
90187
+ const parent = dirname16(dir);
89793
90188
  if (parent === dir)
89794
90189
  break;
89795
90190
  dir = parent;
89796
90191
  }
89797
- return resolve16(dirname17(new URL(import.meta.url).pathname), "../../skills");
90192
+ return resolve15(dirname16(new URL(import.meta.url).pathname), "../../skills");
89798
90193
  }
89799
90194
  function getAvailableSkills() {
89800
90195
  const dir = getSkillsSourceDir();
89801
- if (!existsSync40(dir))
90196
+ if (!existsSync38(dir))
89802
90197
  return [];
89803
- return readdirSync12(dir, { withFileTypes: true }).filter((d) => d.isDirectory() && existsSync40(join34(dir, d.name, "SKILL.md"))).map((d) => d.name);
90198
+ return readdirSync12(dir, { withFileTypes: true }).filter((d) => d.isDirectory() && existsSync38(join32(dir, d.name, "SKILL.md"))).map((d) => d.name);
89804
90199
  }
89805
90200
  function isInstalled(skillName) {
89806
- return existsSync40(join34(AGENTS_SKILLS_DIR, skillName, "SKILL.md"));
90201
+ return existsSync38(join32(AGENTS_SKILLS_DIR, skillName, "SKILL.md"));
89807
90202
  }
89808
90203
  async function skill(args) {
89809
90204
  const sub = args[0];
@@ -89837,28 +90232,28 @@ function skillInstall(name) {
89837
90232
  console.error(" Expected skills at: " + sourceDir);
89838
90233
  return;
89839
90234
  }
89840
- mkdirSync17(AGENTS_SKILLS_DIR, { recursive: true });
90235
+ mkdirSync16(AGENTS_SKILLS_DIR, { recursive: true });
89841
90236
  for (const skillName of skills) {
89842
- const srcDir = join34(sourceDir, skillName);
89843
- const srcFile = join34(srcDir, "SKILL.md");
89844
- const destDir = join34(AGENTS_SKILLS_DIR, skillName);
89845
- if (!existsSync40(srcFile)) {
90237
+ const srcDir = join32(sourceDir, skillName);
90238
+ const srcFile = join32(srcDir, "SKILL.md");
90239
+ const destDir = join32(AGENTS_SKILLS_DIR, skillName);
90240
+ if (!existsSync38(srcFile)) {
89846
90241
  console.error(`[mink] skill not found: ${skillName}`);
89847
90242
  continue;
89848
90243
  }
89849
- mkdirSync17(destDir, { recursive: true });
90244
+ mkdirSync16(destDir, { recursive: true });
89850
90245
  copyDirRecursive2(srcDir, destDir);
89851
- mkdirSync17(CLAUDE_SKILLS_DIR, { recursive: true });
89852
- const symlink = join34(CLAUDE_SKILLS_DIR, skillName);
90246
+ mkdirSync16(CLAUDE_SKILLS_DIR, { recursive: true });
90247
+ const symlink = join32(CLAUDE_SKILLS_DIR, skillName);
89853
90248
  try {
89854
- if (existsSync40(symlink)) {
90249
+ if (existsSync38(symlink)) {
89855
90250
  if (lstatSync2(symlink).isSymbolicLink() || lstatSync2(symlink).isFile()) {
89856
90251
  unlinkSync6(symlink);
89857
90252
  } else {
89858
- rmSync3(symlink, { recursive: true, force: true });
90253
+ rmSync2(symlink, { recursive: true, force: true });
89859
90254
  }
89860
90255
  }
89861
- const relativeTarget = join34("..", "..", ".agents", "skills", skillName);
90256
+ const relativeTarget = join32("..", "..", ".agents", "skills", skillName);
89862
90257
  symlinkSync2(relativeTarget, symlink);
89863
90258
  } catch {}
89864
90259
  console.log(`[mink] installed: ${skillName} -> ${destDir}`);
@@ -89869,15 +90264,15 @@ function skillInstall(name) {
89869
90264
  function skillUninstall(name) {
89870
90265
  const skills = name ? [name] : getAvailableSkills();
89871
90266
  for (const skillName of skills) {
89872
- const destDir = join34(AGENTS_SKILLS_DIR, skillName);
89873
- if (!existsSync40(destDir)) {
90267
+ const destDir = join32(AGENTS_SKILLS_DIR, skillName);
90268
+ if (!existsSync38(destDir)) {
89874
90269
  console.log(`[mink] not installed: ${skillName}`);
89875
90270
  continue;
89876
90271
  }
89877
- rmSync3(destDir, { recursive: true, force: true });
89878
- const symlink = join34(CLAUDE_SKILLS_DIR, skillName);
90272
+ rmSync2(destDir, { recursive: true, force: true });
90273
+ const symlink = join32(CLAUDE_SKILLS_DIR, skillName);
89879
90274
  try {
89880
- if (existsSync40(symlink))
90275
+ if (existsSync38(symlink))
89881
90276
  unlinkSync6(symlink);
89882
90277
  } catch {}
89883
90278
  console.log(`[mink] uninstalled: ${skillName}`);
@@ -89892,7 +90287,7 @@ function skillList() {
89892
90287
  if (installed.length > 0) {
89893
90288
  console.log(" Installed:");
89894
90289
  for (const s of installed) {
89895
- console.log(` ${s} (${join34(AGENTS_SKILLS_DIR, s)})`);
90290
+ console.log(` ${s} (${join32(AGENTS_SKILLS_DIR, s)})`);
89896
90291
  }
89897
90292
  }
89898
90293
  if (notInstalled.length > 0) {
@@ -89911,20 +90306,20 @@ function skillList() {
89911
90306
  function copyDirRecursive2(src, dest) {
89912
90307
  const entries = readdirSync12(src, { withFileTypes: true });
89913
90308
  for (const entry of entries) {
89914
- const srcPath = join34(src, entry.name);
89915
- const destPath = join34(dest, entry.name);
90309
+ const srcPath = join32(src, entry.name);
90310
+ const destPath = join32(dest, entry.name);
89916
90311
  if (entry.isDirectory()) {
89917
- mkdirSync17(destPath, { recursive: true });
90312
+ mkdirSync16(destPath, { recursive: true });
89918
90313
  copyDirRecursive2(srcPath, destPath);
89919
90314
  } else {
89920
- copyFileSync2(srcPath, destPath);
90315
+ copyFileSync(srcPath, destPath);
89921
90316
  }
89922
90317
  }
89923
90318
  }
89924
90319
  var AGENTS_SKILLS_DIR, CLAUDE_SKILLS_DIR;
89925
90320
  var init_skill = __esm(() => {
89926
- AGENTS_SKILLS_DIR = join34(homedir6(), ".agents", "skills");
89927
- CLAUDE_SKILLS_DIR = join34(homedir6(), ".claude", "skills");
90321
+ AGENTS_SKILLS_DIR = join32(homedir5(), ".agents", "skills");
90322
+ CLAUDE_SKILLS_DIR = join32(homedir5(), ".claude", "skills");
89928
90323
  });
89929
90324
 
89930
90325
  // src/commands/agent.ts
@@ -89932,41 +90327,41 @@ var exports_agent = {};
89932
90327
  __export(exports_agent, {
89933
90328
  agent: () => agent
89934
90329
  });
89935
- import { join as join35, resolve as resolve17, dirname as dirname18 } from "path";
89936
- import { homedir as homedir7 } from "os";
90330
+ import { join as join33, resolve as resolve16, dirname as dirname17 } from "path";
90331
+ import { homedir as homedir6 } from "os";
89937
90332
  import {
89938
- existsSync as existsSync41,
89939
- mkdirSync as mkdirSync18,
90333
+ existsSync as existsSync39,
90334
+ mkdirSync as mkdirSync17,
89940
90335
  readFileSync as readFileSync30,
89941
90336
  writeFileSync as writeFileSync11
89942
90337
  } from "fs";
89943
90338
  import { createHash as createHash4 } from "crypto";
89944
90339
  import { spawnSync as spawnSync6 } from "child_process";
89945
90340
  function getAgentTemplatePath() {
89946
- let dir = dirname18(new URL(import.meta.url).pathname);
90341
+ let dir = dirname17(new URL(import.meta.url).pathname);
89947
90342
  while (true) {
89948
- if (existsSync41(join35(dir, "package.json")) && existsSync41(join35(dir, "agents", TEMPLATE_FILE))) {
89949
- return join35(dir, "agents", TEMPLATE_FILE);
90343
+ if (existsSync39(join33(dir, "package.json")) && existsSync39(join33(dir, "agents", TEMPLATE_FILE))) {
90344
+ return join33(dir, "agents", TEMPLATE_FILE);
89950
90345
  }
89951
- const parent = dirname18(dir);
90346
+ const parent = dirname17(dir);
89952
90347
  if (parent === dir)
89953
90348
  break;
89954
90349
  dir = parent;
89955
90350
  }
89956
- return resolve17(dirname18(new URL(import.meta.url).pathname), "../../agents", TEMPLATE_FILE);
90351
+ return resolve16(dirname17(new URL(import.meta.url).pathname), "../../agents", TEMPLATE_FILE);
89957
90352
  }
89958
90353
  function getMinkVersion() {
89959
- let dir = dirname18(new URL(import.meta.url).pathname);
90354
+ let dir = dirname17(new URL(import.meta.url).pathname);
89960
90355
  while (true) {
89961
- const pkgPath = join35(dir, "package.json");
89962
- if (existsSync41(pkgPath)) {
90356
+ const pkgPath = join33(dir, "package.json");
90357
+ if (existsSync39(pkgPath)) {
89963
90358
  try {
89964
90359
  const pkg = JSON.parse(readFileSync30(pkgPath, "utf-8"));
89965
90360
  if (pkg.name && pkg.version)
89966
90361
  return pkg.version;
89967
90362
  } catch {}
89968
90363
  }
89969
- const parent = dirname18(dir);
90364
+ const parent = dirname17(dir);
89970
90365
  if (parent === dir)
89971
90366
  break;
89972
90367
  dir = parent;
@@ -89984,19 +90379,19 @@ function sha2562(text) {
89984
90379
  return createHash4("sha256").update(text).digest("hex");
89985
90380
  }
89986
90381
  function claudeAgentsDir() {
89987
- return join35(homedir7(), ".claude", "agents");
90382
+ return join33(homedir6(), ".claude", "agents");
89988
90383
  }
89989
90384
  function installedAgentPath() {
89990
- return join35(claudeAgentsDir(), INSTALLED_FILE);
90385
+ return join33(claudeAgentsDir(), INSTALLED_FILE);
89991
90386
  }
89992
90387
  function installAgentDefinition(opts) {
89993
90388
  const templatePath = getAgentTemplatePath();
89994
- if (!existsSync41(templatePath)) {
90389
+ if (!existsSync39(templatePath)) {
89995
90390
  throw new Error(`[mink agent] bundled agent template not found at ${templatePath}
89996
90391
  ` + " This usually means the package was installed without bundled assets.");
89997
90392
  }
89998
90393
  const installed = installedAgentPath();
89999
- if (opts.skip && existsSync41(installed)) {
90394
+ if (opts.skip && existsSync39(installed)) {
90000
90395
  return { action: "skipped", path: installed };
90001
90396
  }
90002
90397
  const template = readFileSync30(templatePath, "utf-8");
@@ -90005,14 +90400,14 @@ function installAgentDefinition(opts) {
90005
90400
  VAULT_PATH: resolveVaultPath(),
90006
90401
  MINK_VERSION: getMinkVersion()
90007
90402
  });
90008
- const exists = existsSync41(installed);
90403
+ const exists = existsSync39(installed);
90009
90404
  if (!opts.force && exists) {
90010
90405
  const current = readFileSync30(installed, "utf-8");
90011
90406
  if (sha2562(current) === sha2562(rendered)) {
90012
90407
  return { action: "unchanged", path: installed };
90013
90408
  }
90014
90409
  }
90015
- mkdirSync18(claudeAgentsDir(), { recursive: true });
90410
+ mkdirSync17(claudeAgentsDir(), { recursive: true });
90016
90411
  writeFileSync11(installed, rendered);
90017
90412
  return {
90018
90413
  action: exists ? "updated" : "installed",
@@ -90083,8 +90478,8 @@ async function agent(_cwd, rawArgs) {
90083
90478
  }
90084
90479
  const skipUpdate = args.noUpdate || process.env.MINK_AGENT_NO_UPDATE === "1";
90085
90480
  const root = minkRoot();
90086
- if (!existsSync41(root)) {
90087
- mkdirSync18(root, { recursive: true });
90481
+ if (!existsSync39(root)) {
90482
+ mkdirSync17(root, { recursive: true });
90088
90483
  }
90089
90484
  let result;
90090
90485
  try {
@@ -90135,13 +90530,13 @@ var init_agent = __esm(() => {
90135
90530
  });
90136
90531
 
90137
90532
  // src/core/sync-merge-drivers.ts
90138
- import { readFileSync as readFileSync31, writeFileSync as writeFileSync12, appendFileSync as appendFileSync2, copyFileSync as copyFileSync3, renameSync as renameSync4, unlinkSync as unlinkSync7 } from "fs";
90139
- import { join as join36 } from "path";
90533
+ import { readFileSync as readFileSync31, writeFileSync as writeFileSync12, appendFileSync as appendFileSync2, copyFileSync as copyFileSync2, renameSync as renameSync4, unlinkSync as unlinkSync7 } from "fs";
90534
+ import { join as join34 } from "path";
90140
90535
  function logWarning(driver, args, err) {
90141
90536
  try {
90142
90537
  const line = `[${new Date().toISOString()}] ${driver} fallback for ${args.filePath}: ${err instanceof Error ? err.message : String(err)}
90143
90538
  `;
90144
- appendFileSync2(join36(minkRoot(), "sync-warnings.log"), line);
90539
+ appendFileSync2(join34(minkRoot(), "sync-warnings.log"), line);
90145
90540
  } catch {}
90146
90541
  }
90147
90542
  function readJsonOrNull(path12) {
@@ -90376,7 +90771,7 @@ function mergeDbDriver(args) {
90376
90771
  const tmp = `${args.oursPath}.merge-${process.pid}-${Date.now()}.tmp`;
90377
90772
  let ours = null;
90378
90773
  try {
90379
- copyFileSync3(args.oursPath, tmp);
90774
+ copyFileSync2(args.oursPath, tmp);
90380
90775
  ours = openDriver(tmp);
90381
90776
  ours.exec("PRAGMA journal_mode = WAL");
90382
90777
  ours.exec("PRAGMA foreign_keys = ON");
@@ -90892,22 +91287,8 @@ switch (command2) {
90892
91287
  sessionStop(sessionPath(cwd));
90893
91288
  break;
90894
91289
  case "init": {
90895
- const { init: init2, resolveTargetsFromFlag: resolveTargetsFromFlag2 } = await Promise.resolve().then(() => (init_init(), exports_init));
90896
- const args = process.argv.slice(3);
90897
- const agentFlagIndex = args.findIndex((a) => a === "--agent" || a.startsWith("--agent="));
90898
- let agentValue;
90899
- if (agentFlagIndex !== -1) {
90900
- const a = args[agentFlagIndex];
90901
- agentValue = a.includes("=") ? a.split("=").slice(1).join("=") : args[agentFlagIndex + 1];
90902
- }
90903
- const yes = args.includes("--yes") || args.includes("-y");
90904
- const targets = agentValue ? resolveTargetsFromFlag2(agentValue) : undefined;
90905
- if (agentValue && (!targets || targets.length === 0)) {
90906
- console.error(`[mink] unknown --agent value: ${agentValue}`);
90907
- console.error(" Valid: claude, pi, all (or a comma-separated list)");
90908
- process.exit(1);
90909
- }
90910
- await init2(cwd, { targets, interactive: !yes });
91290
+ const { init: init2 } = await Promise.resolve().then(() => (init_init(), exports_init));
91291
+ await init2(cwd);
90911
91292
  break;
90912
91293
  }
90913
91294
  case "status": {
@@ -90937,6 +91318,11 @@ switch (command2) {
90937
91318
  await postRead2(cwd);
90938
91319
  break;
90939
91320
  }
91321
+ case "post-tool": {
91322
+ const { postTool: postTool2 } = await Promise.resolve().then(() => (init_post_tool(), exports_post_tool));
91323
+ await postTool2(cwd);
91324
+ break;
91325
+ }
90940
91326
  case "pre-write": {
90941
91327
  const { preWrite: preWrite2 } = await Promise.resolve().then(() => (init_pre_write(), exports_pre_write));
90942
91328
  await preWrite2(cwd);
@@ -90952,6 +91338,11 @@ switch (command2) {
90952
91338
  detectWaste2(cwd);
90953
91339
  break;
90954
91340
  }
91341
+ case "retrieve": {
91342
+ const { retrieve: retrieve2 } = await Promise.resolve().then(() => (init_retrieve(), exports_retrieve));
91343
+ retrieve2(cwd, process.argv.slice(3));
91344
+ break;
91345
+ }
90955
91346
  case "cron": {
90956
91347
  const { cron: cron2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
90957
91348
  await cron2(cwd, process.argv.slice(3));
@@ -91051,12 +91442,12 @@ switch (command2) {
91051
91442
  case "version":
91052
91443
  case "--version":
91053
91444
  case "-v": {
91054
- const { resolve: resolve18, dirname: dirname19, basename: basename9 } = await import("path");
91445
+ const { resolve: resolve17, dirname: dirname18, basename: basename9 } = await import("path");
91055
91446
  const bundlePath = new URL(import.meta.url).pathname;
91056
- const cliPath = resolve18(dirname19(bundlePath));
91447
+ const cliPath = resolve17(dirname18(bundlePath));
91057
91448
  const { readFileSync: readFileSync32 } = await import("fs");
91058
91449
  try {
91059
- const pkg = JSON.parse(readFileSync32(resolve18(cliPath, "../package.json"), "utf-8"));
91450
+ const pkg = JSON.parse(readFileSync32(resolve17(cliPath, "../package.json"), "utf-8"));
91060
91451
  console.log(`mink ${pkg.version}`);
91061
91452
  } catch {
91062
91453
  console.log("mink (unknown version)");
@@ -91079,8 +91470,7 @@ switch (command2) {
91079
91470
  console.log("Usage: mink <command> [options]");
91080
91471
  console.log();
91081
91472
  console.log("Commands:");
91082
- console.log(" init [--agent X] [--yes] Initialize Mink in the current project");
91083
- console.log(" --agent claude|pi|all (default: detect & prompt)");
91473
+ console.log(" init Initialize Mink in the current project");
91084
91474
  console.log(" status Display project health at a glance");
91085
91475
  console.log(" scan [--check] Force a full file index rescan");
91086
91476
  console.log(" config [key] [value] Manage global user settings");
@@ -91122,6 +91512,7 @@ switch (command2) {
91122
91512
  console.log(" restore [backup] Restore state from a backup");
91123
91513
  console.log(" bug search <term> Search the bug log");
91124
91514
  console.log(" detect-waste Detect and flag wasteful patterns");
91515
+ console.log(" retrieve <token> Return a compressed tool output's original (spec 21)");
91125
91516
  console.log(" reflect Generate learning memory reflections");
91126
91517
  console.log(" designqc [target] Capture design screenshots (spec 13)");
91127
91518
  console.log(" framework-advisor Generate framework advisor knowledge file (spec 14)");
@@ -91131,6 +91522,7 @@ switch (command2) {
91131
91522
  console.log(" session-stop Finalize session and log data");
91132
91523
  console.log(" pre-read / post-read File read hooks");
91133
91524
  console.log(" pre-write / post-write File write hooks");
91525
+ console.log(" post-tool Tool-output compression hook (Bash/Grep/MCP, spec 21)");
91134
91526
  break;
91135
91527
  default:
91136
91528
  console.error(`[mink] unknown command: ${command2 ?? "(none)"}`);