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

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 (64) hide show
  1. package/README.md +4 -20
  2. package/dashboard/out/404.html +1 -1
  3. package/dashboard/out/action-log.html +1 -1
  4. package/dashboard/out/action-log.txt +1 -1
  5. package/dashboard/out/activity.html +1 -1
  6. package/dashboard/out/activity.txt +1 -1
  7. package/dashboard/out/bugs.html +1 -1
  8. package/dashboard/out/bugs.txt +1 -1
  9. package/dashboard/out/capture.html +1 -1
  10. package/dashboard/out/capture.txt +1 -1
  11. package/dashboard/out/config.html +1 -1
  12. package/dashboard/out/config.txt +1 -1
  13. package/dashboard/out/daemon.html +1 -1
  14. package/dashboard/out/daemon.txt +1 -1
  15. package/dashboard/out/design.html +1 -1
  16. package/dashboard/out/design.txt +1 -1
  17. package/dashboard/out/discord.html +1 -1
  18. package/dashboard/out/discord.txt +1 -1
  19. package/dashboard/out/file-index.html +1 -1
  20. package/dashboard/out/file-index.txt +1 -1
  21. package/dashboard/out/index.html +1 -1
  22. package/dashboard/out/index.txt +1 -1
  23. package/dashboard/out/insights.html +1 -1
  24. package/dashboard/out/insights.txt +1 -1
  25. package/dashboard/out/learning.html +1 -1
  26. package/dashboard/out/learning.txt +1 -1
  27. package/dashboard/out/overview.html +1 -1
  28. package/dashboard/out/overview.txt +1 -1
  29. package/dashboard/out/scheduler.html +1 -1
  30. package/dashboard/out/scheduler.txt +1 -1
  31. package/dashboard/out/sync.html +1 -1
  32. package/dashboard/out/sync.txt +1 -1
  33. package/dashboard/out/tokens.html +1 -1
  34. package/dashboard/out/tokens.txt +1 -1
  35. package/dashboard/out/waste.html +1 -1
  36. package/dashboard/out/waste.txt +1 -1
  37. package/dashboard/out/wiki.html +1 -1
  38. package/dashboard/out/wiki.txt +1 -1
  39. package/dist/cli.bun.js +1232 -904
  40. package/dist/cli.node.js +1251 -924
  41. package/package.json +1 -1
  42. package/src/cli.ts +17 -20
  43. package/src/commands/init.ts +14 -123
  44. package/src/commands/post-read.ts +18 -0
  45. package/src/commands/post-tool.ts +48 -0
  46. package/src/commands/retrieve.ts +32 -0
  47. package/src/core/code-skeleton.ts +108 -0
  48. package/src/core/compress-tool-output.ts +127 -0
  49. package/src/core/compression.ts +81 -0
  50. package/src/core/hook-output.ts +42 -0
  51. package/src/core/output-compression.ts +252 -0
  52. package/src/core/token-estimate.ts +40 -0
  53. package/src/repositories/compression-cache-repo.ts +97 -0
  54. package/src/repositories/token-ledger-repo.ts +87 -0
  55. package/src/storage/schema.ts +50 -1
  56. package/src/types/compression.ts +29 -0
  57. package/src/types/config.ts +40 -0
  58. package/src/types/hook-input.ts +4 -0
  59. package/src/types/token-ledger.ts +33 -0
  60. package/src/core/agent-detect.ts +0 -88
  61. package/src/core/agent-pi.ts +0 -314
  62. package/src/core/prompt.ts +0 -27
  63. /package/dashboard/out/_next/static/{UWfkbJY4zr9fSt7O-CAge → Yl3F-J4CwvYf6yWG-SSmG}/_buildManifest.js +0 -0
  64. /package/dashboard/out/_next/static/{UWfkbJY4zr9fSt7O-CAge → Yl3F-J4CwvYf6yWG-SSmG}/_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
@@ -3674,6 +3758,68 @@ class TokenLedgerRepo {
3674
3758
  }
3675
3759
  });
3676
3760
  }
3761
+ recordCompression(event, deviceId = getOrCreateDeviceId()) {
3762
+ const id = event.id ?? crypto.randomUUID();
3763
+ const createdAt = event.createdAt ?? new Date().toISOString();
3764
+ const holdout = event.holdout ? 1 : 0;
3765
+ const savings = event.holdout ? 0 : Math.max(0, event.originalTokens - event.compressedTokens);
3766
+ this.db.transaction(() => {
3767
+ this.db.prepare(`
3768
+ INSERT OR REPLACE INTO ledger_compressions
3769
+ (id, created_at, tool_name, content_kind,
3770
+ original_tokens, compressed_tokens, holdout, device_id)
3771
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
3772
+ `).run(id, createdAt, event.toolName, event.contentKind, event.originalTokens, event.compressedTokens, holdout, deviceId);
3773
+ this.db.prepare(`
3774
+ INSERT INTO ledger_compression_lifetime
3775
+ (device_id, total_events, total_holdout_events,
3776
+ total_original_tokens, total_compressed_tokens, total_measured_savings)
3777
+ VALUES (?, ?, ?, ?, ?, ?)
3778
+ ON CONFLICT(device_id) DO UPDATE SET
3779
+ total_events = ledger_compression_lifetime.total_events + excluded.total_events,
3780
+ total_holdout_events = ledger_compression_lifetime.total_holdout_events + excluded.total_holdout_events,
3781
+ total_original_tokens = ledger_compression_lifetime.total_original_tokens + excluded.total_original_tokens,
3782
+ total_compressed_tokens = ledger_compression_lifetime.total_compressed_tokens + excluded.total_compressed_tokens,
3783
+ total_measured_savings = ledger_compression_lifetime.total_measured_savings + excluded.total_measured_savings
3784
+ `).run(deviceId, 1, holdout, event.originalTokens, event.compressedTokens, savings);
3785
+ });
3786
+ }
3787
+ compressionLifetime() {
3788
+ const row = this.db.prepare(`
3789
+ SELECT
3790
+ COALESCE(SUM(total_events), 0) AS totalEvents,
3791
+ COALESCE(SUM(total_holdout_events), 0) AS totalHoldoutEvents,
3792
+ COALESCE(SUM(total_original_tokens), 0) AS totalOriginalTokens,
3793
+ COALESCE(SUM(total_compressed_tokens), 0) AS totalCompressedTokens,
3794
+ COALESCE(SUM(total_measured_savings), 0) AS totalMeasuredSavings
3795
+ FROM ledger_compression_lifetime
3796
+ `).get();
3797
+ return {
3798
+ totalEvents: Number(row?.totalEvents ?? 0),
3799
+ totalHoldoutEvents: Number(row?.totalHoldoutEvents ?? 0),
3800
+ totalOriginalTokens: Number(row?.totalOriginalTokens ?? 0),
3801
+ totalCompressedTokens: Number(row?.totalCompressedTokens ?? 0),
3802
+ totalMeasuredSavings: Number(row?.totalMeasuredSavings ?? 0)
3803
+ };
3804
+ }
3805
+ compressionEvents(limit = 100) {
3806
+ const rows = this.db.prepare(`
3807
+ SELECT id, created_at, tool_name, content_kind,
3808
+ original_tokens, compressed_tokens, holdout
3809
+ FROM ledger_compressions
3810
+ ORDER BY created_at DESC
3811
+ LIMIT ?
3812
+ `).all(limit);
3813
+ return rows.map((r) => ({
3814
+ id: String(r.id),
3815
+ createdAt: String(r.created_at),
3816
+ toolName: String(r.tool_name),
3817
+ contentKind: String(r.content_kind),
3818
+ originalTokens: Number(r.original_tokens),
3819
+ compressedTokens: Number(r.compressed_tokens),
3820
+ holdout: Number(r.holdout) === 1
3821
+ }));
3822
+ }
3677
3823
  insertSessionRow(summary, deviceId, archived) {
3678
3824
  this.db.prepare(`
3679
3825
  INSERT OR REPLACE INTO ledger_sessions
@@ -4448,6 +4594,28 @@ function estimateTokens2(content, filePath) {
4448
4594
  }
4449
4595
  return Math.ceil(content.length / ratio);
4450
4596
  }
4597
+ function countTokens(text) {
4598
+ if (!text)
4599
+ return 0;
4600
+ const segments = text.match(/[A-Za-z]+|[0-9]+|[^A-Za-z0-9]/g);
4601
+ if (!segments)
4602
+ return 0;
4603
+ let tokens = 0;
4604
+ for (const seg of segments) {
4605
+ const first = seg.charCodeAt(0);
4606
+ if (first >= 65 && first <= 90 || first >= 97 && first <= 122) {
4607
+ tokens += Math.ceil(seg.length / 4);
4608
+ } else if (first >= 48 && first <= 57) {
4609
+ tokens += Math.ceil(seg.length / 3);
4610
+ } else if (seg === `
4611
+ `) {
4612
+ tokens += 1;
4613
+ } else if (seg === " " || seg === "\t" || seg === "\r") {} else {
4614
+ tokens += 1;
4615
+ }
4616
+ }
4617
+ return tokens;
4618
+ }
4451
4619
  var CODE_EXTENSIONS, PROSE_EXTENSIONS, BINARY_EXTENSIONS;
4452
4620
  var init_token_estimate = __esm(() => {
4453
4621
  CODE_EXTENSIONS = new Set([
@@ -4727,342 +4895,6 @@ var init_reflect = __esm(() => {
4727
4895
  init_fs_utils();
4728
4896
  });
4729
4897
 
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
4898
  // src/core/backup.ts
5067
4899
  var exports_backup = {};
5068
4900
  __export(exports_backup, {
@@ -5071,14 +4903,14 @@ __export(exports_backup, {
5071
4903
  createBackup: () => createBackup
5072
4904
  });
5073
4905
  import {
5074
- mkdirSync as mkdirSync9,
4906
+ mkdirSync as mkdirSync8,
5075
4907
  readdirSync as readdirSync7,
5076
4908
  readFileSync as readFileSync12,
5077
4909
  writeFileSync as writeFileSync5,
5078
- existsSync as existsSync19,
4910
+ existsSync as existsSync17,
5079
4911
  statSync as statSync7
5080
4912
  } from "fs";
5081
- import { join as join16 } from "path";
4913
+ import { join as join14 } from "path";
5082
4914
  function formatTimestamp(date) {
5083
4915
  const y = date.getFullYear();
5084
4916
  const mo = String(date.getMonth() + 1).padStart(2, "0");
@@ -5090,15 +4922,15 @@ function formatTimestamp(date) {
5090
4922
  return `${y}${mo}${d}-${h}${mi}${s}${ms}`;
5091
4923
  }
5092
4924
  function copyDirectoryFiles(srcDir, destDir, excludeDirs) {
5093
- mkdirSync9(destDir, { recursive: true });
4925
+ mkdirSync8(destDir, { recursive: true });
5094
4926
  const entries = readdirSync7(srcDir, { withFileTypes: true });
5095
4927
  for (const entry of entries) {
5096
4928
  if (entry.isDirectory()) {
5097
4929
  if (excludeDirs.includes(entry.name))
5098
4930
  continue;
5099
- copyDirectoryFiles(join16(srcDir, entry.name), join16(destDir, entry.name), excludeDirs);
4931
+ copyDirectoryFiles(join14(srcDir, entry.name), join14(destDir, entry.name), excludeDirs);
5100
4932
  } else if (entry.isFile()) {
5101
- writeFileSync5(join16(destDir, entry.name), readFileSync12(join16(srcDir, entry.name)));
4933
+ writeFileSync5(join14(destDir, entry.name), readFileSync12(join14(srcDir, entry.name)));
5102
4934
  }
5103
4935
  }
5104
4936
  }
@@ -5107,25 +4939,25 @@ function createBackup(cwd) {
5107
4939
  const dir = backupDirPath(cwd);
5108
4940
  let name = base;
5109
4941
  let suffix = 1;
5110
- while (existsSync19(join16(dir, name))) {
4942
+ while (existsSync17(join14(dir, name))) {
5111
4943
  name = `${base}-${suffix}`;
5112
4944
  suffix++;
5113
4945
  }
5114
4946
  const src = projectDir(cwd);
5115
- const dest = join16(dir, name);
4947
+ const dest = join14(dir, name);
5116
4948
  copyDirectoryFiles(src, dest, ["backups"]);
5117
4949
  return name;
5118
4950
  }
5119
4951
  function listBackups(cwd) {
5120
4952
  const dir = backupDirPath(cwd);
5121
- if (!existsSync19(dir))
4953
+ if (!existsSync17(dir))
5122
4954
  return [];
5123
4955
  const entries = readdirSync7(dir, { withFileTypes: true });
5124
4956
  const backups = [];
5125
4957
  for (const entry of entries) {
5126
4958
  if (!entry.isDirectory() || !entry.name.startsWith("backup-"))
5127
4959
  continue;
5128
- const backupPath = join16(dir, entry.name);
4960
+ const backupPath = join14(dir, entry.name);
5129
4961
  const match = entry.name.match(/^backup-(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})(\d{3})?(?:-\d+)?$/);
5130
4962
  let timestamp;
5131
4963
  if (match) {
@@ -5148,8 +4980,8 @@ function listBackups(cwd) {
5148
4980
  return backups;
5149
4981
  }
5150
4982
  function restoreBackup(cwd, backupName) {
5151
- const backupPath = join16(backupDirPath(cwd), backupName);
5152
- if (!existsSync19(backupPath)) {
4983
+ const backupPath = join14(backupDirPath(cwd), backupName);
4984
+ if (!existsSync17(backupPath)) {
5153
4985
  throw new Error(`backup not found: ${backupName}`);
5154
4986
  }
5155
4987
  createBackup(cwd);
@@ -5161,7 +4993,7 @@ var init_backup = __esm(() => {
5161
4993
 
5162
4994
  // src/core/scanner.ts
5163
4995
  import { readdirSync as readdirSync8, statSync as statSync8 } from "fs";
5164
- import { join as join17, relative } from "path";
4996
+ import { join as join15, relative } from "path";
5165
4997
  function matchesPattern(name, pattern) {
5166
4998
  if (pattern.includes("*")) {
5167
4999
  const regex = new RegExp("^" + pattern.replace(/\./g, "\\.").replace(/\*/g, ".*") + "$");
@@ -5185,14 +5017,14 @@ function walkDirectory(dir, projectRoot, excludes, results) {
5185
5017
  if (entry.isDirectory()) {
5186
5018
  if (isExcluded(entry.name, excludes))
5187
5019
  continue;
5188
- walkDirectory(join17(dir, entry.name), projectRoot, excludes, results);
5020
+ walkDirectory(join15(dir, entry.name), projectRoot, excludes, results);
5189
5021
  continue;
5190
5022
  }
5191
5023
  if (entry.isFile()) {
5192
5024
  if (isExcluded(entry.name, excludes))
5193
5025
  continue;
5194
5026
  try {
5195
- const fullPath = join17(dir, entry.name);
5027
+ const fullPath = join15(dir, entry.name);
5196
5028
  const stat = statSync8(fullPath);
5197
5029
  results.push({
5198
5030
  relativePath: relative(projectRoot, fullPath),
@@ -5615,7 +5447,7 @@ __export(exports_scan, {
5615
5447
  });
5616
5448
  import { readFileSync as readFileSync13 } from "fs";
5617
5449
  import { createHash as createHash2 } from "crypto";
5618
- import { join as join18, relative as relative2 } from "path";
5450
+ import { join as join16, relative as relative2 } from "path";
5619
5451
  function configRelativePath(cfgPath, cwd) {
5620
5452
  const rel = relative2(cwd, cfgPath);
5621
5453
  return rel.startsWith("..") ? cfgPath : rel;
@@ -5666,7 +5498,7 @@ function scan(cwd, options) {
5666
5498
  if (!stalePaths.has(file.relativePath)) {
5667
5499
  continue;
5668
5500
  }
5669
- const fullPath = join18(cwd, file.relativePath);
5501
+ const fullPath = join16(cwd, file.relativePath);
5670
5502
  let content;
5671
5503
  try {
5672
5504
  content = readFileSync13(fullPath, "utf-8");
@@ -5755,10 +5587,10 @@ __export(exports_seed, {
5755
5587
  parseGoMod: () => parseGoMod,
5756
5588
  parseCargoToml: () => parseCargoToml
5757
5589
  });
5758
- import { basename as basename4, join as join19 } from "path";
5759
- import { readFileSync as readFileSync14, existsSync as existsSync20 } from "fs";
5590
+ import { basename as basename4, join as join17 } from "path";
5591
+ import { readFileSync as readFileSync14, existsSync as existsSync18 } from "fs";
5760
5592
  function readFile(filePath) {
5761
- if (!existsSync20(filePath))
5593
+ if (!existsSync18(filePath))
5762
5594
  return null;
5763
5595
  try {
5764
5596
  return readFileSync14(filePath, "utf-8");
@@ -5851,10 +5683,10 @@ function parseGoMod(filePath) {
5851
5683
  }
5852
5684
  function seedLearningMemory(projectRoot) {
5853
5685
  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"))
5686
+ () => parsePackageJson(join17(projectRoot, "package.json")),
5687
+ () => parsePyprojectToml(join17(projectRoot, "pyproject.toml")),
5688
+ () => parseCargoToml(join17(projectRoot, "Cargo.toml")),
5689
+ () => parseGoMod(join17(projectRoot, "go.mod"))
5858
5690
  ];
5859
5691
  const infos = parsers.map((fn) => fn()).filter((info) => info !== null);
5860
5692
  const projectName = infos.find((i) => i.projectName)?.projectName ?? basename4(projectRoot);
@@ -5932,37 +5764,34 @@ var init_seed = __esm(() => {
5932
5764
  var exports_init = {};
5933
5765
  __export(exports_init, {
5934
5766
  writeMinkRule: () => writeMinkRule,
5935
- resolveTargetsFromFlag: () => resolveTargetsFromFlag,
5936
- resolveTargets: () => resolveTargets,
5937
5767
  resolveCliPathFrom: () => resolveCliPathFrom,
5938
5768
  resolveCliPath: () => resolveCliPath,
5939
5769
  mergeHooksIntoSettings: () => mergeHooksIntoSettings,
5940
- installClaude: () => installClaude,
5941
5770
  init: () => init,
5942
5771
  detectRuntime: () => detectRuntime,
5943
5772
  buildHooksConfig: () => buildHooksConfig
5944
5773
  });
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";
5774
+ import { execSync as execSync5 } from "child_process";
5775
+ import { mkdirSync as mkdirSync9, existsSync as existsSync19 } from "fs";
5776
+ import { resolve as resolve2, dirname as dirname7, basename as basename5, join as join18 } from "path";
5948
5777
  function detectRuntime() {
5949
5778
  try {
5950
- execSync6("bun --version", { stdio: "ignore" });
5779
+ execSync5("bun --version", { stdio: "ignore" });
5951
5780
  return "bun";
5952
5781
  } catch {
5953
5782
  return "node";
5954
5783
  }
5955
5784
  }
5956
5785
  function resolveCliPathFrom(selfPath) {
5957
- const selfDir = dirname8(selfPath);
5786
+ const selfDir = dirname7(selfPath);
5958
5787
  if (selfPath.endsWith("dist/cli.js") || selfPath.endsWith("dist/cli.bun.js") || selfPath.endsWith("dist/cli.node.js")) {
5959
- return join20(selfDir, "cli.js");
5788
+ return join18(selfDir, "cli.js");
5960
5789
  }
5961
- const packageRoot = resolve3(selfDir, "..", "..");
5962
- const distShim = join20(packageRoot, "dist", "cli.js");
5963
- if (existsSync21(distShim))
5790
+ const packageRoot = resolve2(selfDir, "..", "..");
5791
+ const distShim = join18(packageRoot, "dist", "cli.js");
5792
+ if (existsSync19(distShim))
5964
5793
  return distShim;
5965
- return join20(packageRoot, "src", "cli.ts");
5794
+ return join18(packageRoot, "src", "cli.ts");
5966
5795
  }
5967
5796
  function resolveCliPath() {
5968
5797
  return resolveCliPathFrom(new URL(import.meta.url).pathname);
@@ -5982,12 +5811,14 @@ function buildHooksConfig(cliPath) {
5982
5811
  PostToolUse: [
5983
5812
  { matcher: "Read", hooks: hook(`${prefix} post-read`) },
5984
5813
  { matcher: "Edit", hooks: hook(`${prefix} post-write`) },
5985
- { matcher: "Write", hooks: hook(`${prefix} post-write`) }
5814
+ { matcher: "Write", hooks: hook(`${prefix} post-write`) },
5815
+ { matcher: "Bash", hooks: hook(`${prefix} post-tool`) },
5816
+ { matcher: "Grep", hooks: hook(`${prefix} post-tool`) }
5986
5817
  ]
5987
5818
  };
5988
5819
  }
5989
5820
  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");
5821
+ 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
5822
  if (!hasMinkSubcommand)
5992
5823
  return false;
5993
5824
  if (/(^|\/|\s)mink\s/.test(cmd))
@@ -6004,13 +5835,13 @@ function isMinkHook(entry) {
6004
5835
  return false;
6005
5836
  }
6006
5837
  function writeMinkRule(cwd) {
6007
- const rulePath = resolve3(cwd, ".claude", "rules", "mink.md");
6008
- mkdirSync10(dirname8(rulePath), { recursive: true });
5838
+ const rulePath = resolve2(cwd, ".claude", "rules", "mink.md");
5839
+ mkdirSync9(dirname7(rulePath), { recursive: true });
6009
5840
  atomicWriteText(rulePath, MINK_RULE_CONTENT);
6010
5841
  return rulePath;
6011
5842
  }
6012
5843
  function mergeHooksIntoSettings(settingsPath, newHooks) {
6013
- mkdirSync10(dirname8(settingsPath), { recursive: true });
5844
+ mkdirSync9(dirname7(settingsPath), { recursive: true });
6014
5845
  const existing = safeReadJson(settingsPath) ?? {};
6015
5846
  const existingHooks = existing.hooks ?? {};
6016
5847
  for (const [event, entries] of Object.entries(newHooks)) {
@@ -6021,46 +5852,17 @@ function mergeHooksIntoSettings(settingsPath, newHooks) {
6021
5852
  existing.hooks = existingHooks;
6022
5853
  atomicWriteJson(settingsPath, existing);
6023
5854
  }
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
5855
  function isExistingInstallation(cwd) {
6056
5856
  const dir = projectDir(cwd);
6057
- if (!existsSync21(dir))
5857
+ if (!existsSync19(dir))
6058
5858
  return false;
6059
- return existsSync21(join20(dir, "file-index.json"));
5859
+ return existsSync19(join18(dir, "file-index.json"));
6060
5860
  }
6061
- async function init(cwd, opts = {}) {
5861
+ async function init(cwd) {
6062
5862
  const runtime = detectRuntime();
6063
5863
  const cliPath = resolveCliPath();
5864
+ const hooks = buildHooksConfig(cliPath);
5865
+ const settingsPath = resolve2(cwd, ".claude", "settings.json");
6064
5866
  const dir = projectDir(cwd);
6065
5867
  const upgrading = isExistingInstallation(cwd);
6066
5868
  if (upgrading) {
@@ -6069,22 +5871,9 @@ async function init(cwd, opts = {}) {
6069
5871
  const backupName = createBackup2(cwd);
6070
5872
  console.log(` backup: ${backupName}`);
6071
5873
  }
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 });
5874
+ mergeHooksIntoSettings(settingsPath, hooks);
5875
+ const rulePath = writeMinkRule(cwd);
5876
+ mkdirSync9(dir, { recursive: true });
6088
5877
  const identity = resolveProjectIdentity(cwd);
6089
5878
  const projectId = identity.id;
6090
5879
  const isNotesProject = isWikiEnabled() && isVaultInitialized() && isInsideVault(cwd);
@@ -6092,8 +5881,6 @@ async function init(cwd, opts = {}) {
6092
5881
  const existingMeta = safeReadJson(metaPath);
6093
5882
  const deviceId = getOrCreateDeviceId();
6094
5883
  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
5884
  atomicWriteJson(metaPath, {
6098
5885
  ...existingMeta ?? {},
6099
5886
  cwd,
@@ -6101,29 +5888,20 @@ async function init(cwd, opts = {}) {
6101
5888
  initTimestamp: existingMeta?.initTimestamp ?? new Date().toISOString(),
6102
5889
  version: "0.1.0",
6103
5890
  pathsByDevice: { ...existingPathsByDevice, [deviceId]: cwd },
6104
- agents,
6105
5891
  ...isNotesProject ? { projectType: "notes" } : {}
6106
5892
  });
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
5893
  if (upgrading) {
6116
5894
  console.log(`[mink] upgrade complete`);
6117
5895
  console.log(` project: ${projectId}`);
6118
- console.log(` agents: ${agents.join(", ")}`);
6119
- printWiring();
5896
+ console.log(` hooks: ${settingsPath}`);
5897
+ console.log(` rule: ${rulePath}`);
6120
5898
  } else {
6121
5899
  console.log(`[mink] initialized`);
6122
5900
  console.log(` project: ${projectId} (${identity.source})`);
6123
5901
  console.log(` state: ${dir}`);
6124
5902
  console.log(` runtime: ${runtime}`);
6125
- console.log(` agents: ${agents.join(", ")}`);
6126
- printWiring();
5903
+ console.log(` hooks: ${settingsPath}`);
5904
+ console.log(` rule: ${rulePath}`);
6127
5905
  }
6128
5906
  if (identity.source === "path-derived") {
6129
5907
  const root = getRepoRoot(cwd);
@@ -6135,7 +5913,7 @@ async function init(cwd, opts = {}) {
6135
5913
  scan2(cwd, { check: false });
6136
5914
  const { learningMemoryPath: learningMemoryPath2 } = await Promise.resolve().then(() => (init_paths(), exports_paths));
6137
5915
  const memPath = learningMemoryPath2(cwd);
6138
- if (!existsSync21(memPath)) {
5916
+ if (!existsSync19(memPath)) {
6139
5917
  const { seedLearningMemory: seedLearningMemory2 } = await Promise.resolve().then(() => (init_seed(), exports_seed));
6140
5918
  const { serializeLearningMemory: serializeLearningMemory2 } = await Promise.resolve().then(() => (init_learning_memory(), exports_learning_memory));
6141
5919
  const mem = seedLearningMemory2(cwd);
@@ -6144,8 +5922,8 @@ async function init(cwd, opts = {}) {
6144
5922
  if (isWikiEnabled() && isVaultInitialized() && !isNotesProject) {
6145
5923
  try {
6146
5924
  const projectSlug = basename5(cwd);
6147
- const overviewPath = join20(vaultProjects(projectSlug), "overview.md");
6148
- if (!existsSync21(overviewPath)) {
5925
+ const overviewPath = join18(vaultProjects(projectSlug), "overview.md");
5926
+ if (!existsSync19(overviewPath)) {
6149
5927
  const now = new Date().toISOString();
6150
5928
  const overview = [
6151
5929
  `---`,
@@ -6197,9 +5975,6 @@ var init_init = __esm(() => {
6197
5975
  init_device();
6198
5976
  init_git_identity();
6199
5977
  init_vault();
6200
- init_agent_detect();
6201
- init_agent_pi();
6202
- init_prompt();
6203
5978
  });
6204
5979
 
6205
5980
  // src/repositories/counters-repo.ts
@@ -6274,12 +6049,12 @@ var init_state_counters = __esm(() => {
6274
6049
  });
6275
6050
 
6276
6051
  // 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";
6052
+ import { join as join19 } from "path";
6053
+ import { existsSync as existsSync20, writeFileSync as writeFileSync6, mkdirSync as mkdirSync10 } from "fs";
6279
6054
  function writeCompanionClaudeMd(vaultPath, overwrite = false) {
6280
- mkdirSync11(vaultPath, { recursive: true });
6281
- const claudeMdPath = join21(vaultPath, "CLAUDE.md");
6282
- if (existsSync22(claudeMdPath) && !overwrite) {
6055
+ mkdirSync10(vaultPath, { recursive: true });
6056
+ const claudeMdPath = join19(vaultPath, "CLAUDE.md");
6057
+ if (existsSync20(claudeMdPath) && !overwrite) {
6283
6058
  return false;
6284
6059
  }
6285
6060
  writeFileSync6(claudeMdPath, COMPANION_CLAUDE_MD);
@@ -6431,8 +6206,8 @@ mink wiki rebuild-index
6431
6206
  var init_channel_templates = () => {};
6432
6207
 
6433
6208
  // 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";
6209
+ import { readFileSync as readFileSync15, writeFileSync as writeFileSync7, unlinkSync as unlinkSync3, mkdirSync as mkdirSync11, existsSync as existsSync21 } from "fs";
6210
+ import { dirname as dirname8, join as join20 } from "path";
6436
6211
  import { spawnSync } from "child_process";
6437
6212
  function readChannelPidFile() {
6438
6213
  try {
@@ -6448,7 +6223,7 @@ function readChannelPidFile() {
6448
6223
  }
6449
6224
  function writeChannelPidFile(data) {
6450
6225
  const pidPath = channelPidPath();
6451
- mkdirSync12(dirname9(pidPath), { recursive: true });
6226
+ mkdirSync11(dirname8(pidPath), { recursive: true });
6452
6227
  writeFileSync7(pidPath, JSON.stringify(data, null, 2));
6453
6228
  }
6454
6229
  function removeChannelPidFile() {
@@ -6578,12 +6353,12 @@ function getChannelLogs() {
6578
6353
  return null;
6579
6354
  if (!screenSessionExists(pidData.session))
6580
6355
  return null;
6581
- const tmpPath = join22(minkRoot(), `.channel-capture-${Date.now()}-${process.pid}.txt`);
6356
+ const tmpPath = join20(minkRoot(), `.channel-capture-${Date.now()}-${process.pid}.txt`);
6582
6357
  const result = spawnSync("screen", ["-S", pidData.session, "-X", "hardcopy", "-h", tmpPath], { stdio: "ignore" });
6583
6358
  if (result.status !== 0)
6584
6359
  return null;
6585
6360
  for (let i = 0;i < 20; i++) {
6586
- if (existsSync23(tmpPath))
6361
+ if (existsSync21(tmpPath))
6587
6362
  break;
6588
6363
  const delayUntil = Date.now() + 50;
6589
6364
  while (Date.now() < delayUntil) {}
@@ -6687,7 +6462,7 @@ async function runtimeServe(opts) {
6687
6462
  }
6688
6463
  const { createServer } = await import("http");
6689
6464
  const { Readable } = await import("stream");
6690
- return new Promise((resolve4) => {
6465
+ return new Promise((resolve3) => {
6691
6466
  const httpServer = createServer(async (req, res) => {
6692
6467
  const url = `http://${opts.hostname}:${opts.port}${req.url ?? "/"}`;
6693
6468
  const headers = new Headers;
@@ -6746,7 +6521,7 @@ async function runtimeServe(opts) {
6746
6521
  httpServer.listen(opts.port, opts.hostname, () => {
6747
6522
  const addr = httpServer.address();
6748
6523
  const boundPort = typeof addr === "object" && addr ? addr.port : opts.port;
6749
- resolve4({
6524
+ resolve3({
6750
6525
  port: boundPort,
6751
6526
  stop: (close) => {
6752
6527
  if (close)
@@ -6764,8 +6539,8 @@ var init_runtime = __esm(() => {
6764
6539
 
6765
6540
  // src/core/daemon.ts
6766
6541
  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";
6542
+ import { mkdirSync as mkdirSync12 } from "fs";
6543
+ import { dirname as dirname9, resolve as resolve3 } from "path";
6769
6544
  function readPidFile() {
6770
6545
  try {
6771
6546
  const raw = readFileSync16(schedulerPidPath(), "utf-8");
@@ -6780,7 +6555,7 @@ function readPidFile() {
6780
6555
  }
6781
6556
  function writePidFile(data) {
6782
6557
  const pidPath = schedulerPidPath();
6783
- mkdirSync13(dirname10(pidPath), { recursive: true });
6558
+ mkdirSync12(dirname9(pidPath), { recursive: true });
6784
6559
  writeFileSync8(pidPath, JSON.stringify(data, null, 2));
6785
6560
  }
6786
6561
  function removePidFile() {
@@ -6805,10 +6580,10 @@ function startDaemon(cwd) {
6805
6580
  if (existing) {
6806
6581
  removePidFile();
6807
6582
  }
6808
- const __dir = dirname10(new URL(import.meta.url).pathname);
6809
- const cliPath = process.argv[1] ?? resolve4(__dir, "../cli.ts");
6583
+ const __dir = dirname9(new URL(import.meta.url).pathname);
6584
+ const cliPath = process.argv[1] ?? resolve3(__dir, "../cli.ts");
6810
6585
  const logPath = schedulerLogPath();
6811
- mkdirSync13(dirname10(logPath), { recursive: true });
6586
+ mkdirSync12(dirname9(logPath), { recursive: true });
6812
6587
  const logFd = openSync(logPath, "a");
6813
6588
  const proc = runtimeSpawn(["bun", "run", cliPath, "cron", "__daemon"], {
6814
6589
  cwd,
@@ -6922,9 +6697,9 @@ var exports_status = {};
6922
6697
  __export(exports_status, {
6923
6698
  status: () => status
6924
6699
  });
6925
- import { existsSync as existsSync25, readFileSync as readFileSync17, statSync as statSync9 } from "fs";
6700
+ import { existsSync as existsSync23, readFileSync as readFileSync17, statSync as statSync9 } from "fs";
6926
6701
  function checkJsonFile(name, filePath, validator) {
6927
- if (!existsSync25(filePath))
6702
+ if (!existsSync23(filePath))
6928
6703
  return { name, path: filePath, status: "missing" };
6929
6704
  const data = safeReadJson(filePath);
6930
6705
  if (data === null)
@@ -6934,7 +6709,7 @@ function checkJsonFile(name, filePath, validator) {
6934
6709
  return { name, path: filePath, status: "ok" };
6935
6710
  }
6936
6711
  function checkDbFile(name, filePath) {
6937
- if (!existsSync25(filePath))
6712
+ if (!existsSync23(filePath))
6938
6713
  return { name, path: filePath, status: "missing" };
6939
6714
  try {
6940
6715
  const header = readFileSync17(filePath).slice(0, 16).toString("utf-8");
@@ -6949,7 +6724,7 @@ function checkDbFile(name, filePath) {
6949
6724
  function checkShardedText(name, candidatePaths) {
6950
6725
  const canonical = candidatePaths[0];
6951
6726
  for (const p of candidatePaths) {
6952
- if (!existsSync25(p))
6727
+ if (!existsSync23(p))
6953
6728
  continue;
6954
6729
  try {
6955
6730
  if (statSync9(p).size === 0)
@@ -7042,7 +6817,7 @@ function status(cwd) {
7042
6817
  console.log(` Decision Log: ${mem.sections["Decision Log"].length}`);
7043
6818
  console.log(` Total entries: ${total}`);
7044
6819
  const memPath = learningMemoryPath(cwd);
7045
- if (existsSync25(memPath)) {
6820
+ if (existsSync23(memPath)) {
7046
6821
  const mtime = statSync9(memPath).mtime;
7047
6822
  console.log(` Canonical last modified: ${mtime.toISOString()}`);
7048
6823
  }
@@ -7177,6 +6952,488 @@ var init_pre_read = __esm(() => {
7177
6952
  init_counters_repo();
7178
6953
  });
7179
6954
 
6955
+ // src/core/compression.ts
6956
+ function numberValue(key, fallback, min, max) {
6957
+ const raw = resolveConfigValue(key).value;
6958
+ const n = Number(raw);
6959
+ if (!Number.isFinite(n))
6960
+ return fallback;
6961
+ return Math.min(max, Math.max(min, n));
6962
+ }
6963
+ function loadCompressionConfig() {
6964
+ return {
6965
+ enabled: resolveConfigValue("compression.enabled").value === "true",
6966
+ thresholdTokens: numberValue("compression.threshold-tokens", 800, 0, Number.MAX_SAFE_INTEGER),
6967
+ minSavingsRatio: numberValue("compression.min-savings-ratio", 0.25, 0, 1),
6968
+ holdoutFraction: numberValue("compression.holdout-fraction", 0.1, 0, 1),
6969
+ retentionHours: numberValue("compression.retention-hours", 168, 0, Number.MAX_SAFE_INTEGER)
6970
+ };
6971
+ }
6972
+ function isEligible(originalTokens, config) {
6973
+ return config.enabled && originalTokens >= config.thresholdTokens;
6974
+ }
6975
+ function meetsMinSavings(originalTokens, compressedTokens, config) {
6976
+ if (originalTokens <= 0)
6977
+ return false;
6978
+ const ratio = (originalTokens - compressedTokens) / originalTokens;
6979
+ return ratio >= config.minSavingsRatio;
6980
+ }
6981
+ function hashUnitInterval(key) {
6982
+ let h = 2166136261;
6983
+ for (let i = 0;i < key.length; i++) {
6984
+ h ^= key.charCodeAt(i);
6985
+ h = Math.imul(h, 16777619);
6986
+ }
6987
+ return (h >>> 0) / 4294967296;
6988
+ }
6989
+ function selectHoldout(eventKey, fraction) {
6990
+ if (fraction <= 0)
6991
+ return false;
6992
+ if (fraction >= 1)
6993
+ return true;
6994
+ return hashUnitInterval(eventKey) < fraction;
6995
+ }
6996
+ var init_compression = __esm(() => {
6997
+ init_global_config();
6998
+ });
6999
+
7000
+ // src/core/code-skeleton.ts
7001
+ function countChar(s, c) {
7002
+ let n = 0;
7003
+ for (let i = 0;i < s.length; i++)
7004
+ if (s[i] === c)
7005
+ n++;
7006
+ return n;
7007
+ }
7008
+ function netBraces(line) {
7009
+ let s = line.replace(/\/\/.*$/, "");
7010
+ s = s.replace(/\/\*.*?\*\//g, "");
7011
+ s = s.replace(/"(?:\\.|[^"\\])*"/g, '""');
7012
+ s = s.replace(/'(?:\\.|[^'\\])*'/g, "''");
7013
+ s = s.replace(/`(?:\\.|[^`\\])*`/g, "``");
7014
+ return countChar(s, "{") - countChar(s, "}");
7015
+ }
7016
+ function stripOpenBrace(sig) {
7017
+ return sig.replace(/\{\s*$/, "").trimEnd();
7018
+ }
7019
+ function extractCodeSkeleton(content, opts = {}) {
7020
+ const rawLines = content.split(`
7021
+ `);
7022
+ const totalLines = rawLines.length > 0 && rawLines[rawLines.length - 1] === "" ? rawLines.length - 1 : rawLines.length;
7023
+ const out = [];
7024
+ let depth = 0;
7025
+ let suppress = Infinity;
7026
+ for (const line of rawLines) {
7027
+ if (out.length >= MAX_SIGNATURES)
7028
+ break;
7029
+ const start = depth;
7030
+ const net = netBraces(line);
7031
+ if (start < suppress) {
7032
+ const isHeading = opts.markdown === true && HEADING.test(line);
7033
+ const captured = isHeading || DECL_ALWAYS.test(line) || DECL_EXPORTED_VAR.test(line) || start >= 1 && MEMBER.test(line);
7034
+ if (captured) {
7035
+ const sig = line.trim();
7036
+ if (net > 0) {
7037
+ if (DESCEND.test(line) && !isHeading) {
7038
+ out.push(INDENT.repeat(start) + stripOpenBrace(sig) + " {");
7039
+ } else {
7040
+ out.push(INDENT.repeat(start) + stripOpenBrace(sig) + " { \u2026 }");
7041
+ suppress = start + 1;
7042
+ }
7043
+ } else {
7044
+ out.push(INDENT.repeat(start) + sig);
7045
+ }
7046
+ }
7047
+ }
7048
+ depth = Math.max(0, depth + net);
7049
+ if (depth < suppress)
7050
+ suppress = Infinity;
7051
+ }
7052
+ if (out.length === 0)
7053
+ return null;
7054
+ return { lines: out, totalLines };
7055
+ }
7056
+ var MAX_SIGNATURES = 80, INDENT = " ", DECL_ALWAYS, DECL_EXPORTED_VAR, MEMBER, HEADING, DESCEND;
7057
+ var init_code_skeleton = __esm(() => {
7058
+ 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/;
7059
+ DECL_EXPORTED_VAR = /^\s*export\s+(?:default\s+)?(?:const|let|var)\b/;
7060
+ MEMBER = /^\s*(?:public\s+|private\s+|protected\s+|readonly\s+|static\s+|async\s+|get\s+|set\s+|#)*[\w$]+\??\s*(?:\(|:|=)/;
7061
+ HEADING = /^#{1,6}\s+\S/;
7062
+ DESCEND = /\b(?:class|interface|enum|namespace|module|struct|trait|impl)\b/;
7063
+ });
7064
+
7065
+ // src/core/output-compression.ts
7066
+ function stripAnsi(s) {
7067
+ return s.replace(ANSI, "");
7068
+ }
7069
+ function omittedMarker(n) {
7070
+ return ` \u2026 ${n} line${n === 1 ? "" : "s"} omitted \u2014 mink retrieve \u2026`;
7071
+ }
7072
+ function toLines(content) {
7073
+ const lines = content.split(`
7074
+ `);
7075
+ if (lines.length > 0 && lines[lines.length - 1] === "")
7076
+ lines.pop();
7077
+ return lines;
7078
+ }
7079
+ function compressLog(content) {
7080
+ const lines = toLines(stripAnsi(content));
7081
+ const collapsed = [];
7082
+ let i = 0;
7083
+ while (i < lines.length) {
7084
+ let run = 1;
7085
+ while (i + run < lines.length && lines[i + run] === lines[i])
7086
+ run++;
7087
+ collapsed.push(run > 1 ? `${lines[i]} (\xD7${run})` : lines[i]);
7088
+ i += run;
7089
+ }
7090
+ if (collapsed.length <= LOG_HEAD + LOG_TAIL) {
7091
+ if (collapsed.length === lines.length)
7092
+ return null;
7093
+ return {
7094
+ compressed: collapsed.join(`
7095
+ `),
7096
+ omittedNote: `collapsed ${lines.length - collapsed.length} repeated line(s)`
7097
+ };
7098
+ }
7099
+ const omitted = collapsed.length - LOG_HEAD - LOG_TAIL;
7100
+ const head = collapsed.slice(0, LOG_HEAD);
7101
+ const tail = collapsed.slice(collapsed.length - LOG_TAIL);
7102
+ return {
7103
+ compressed: [...head, omittedMarker(omitted), ...tail].join(`
7104
+ `),
7105
+ omittedNote: `${omitted} of ${collapsed.length} log line(s) omitted (middle)`
7106
+ };
7107
+ }
7108
+ function compressSearch(content) {
7109
+ const lines = toLines(content);
7110
+ const seen = new Set;
7111
+ const perFile = new Map;
7112
+ const omittedByFile = new Map;
7113
+ const out = [];
7114
+ for (const line of lines) {
7115
+ if (seen.has(line))
7116
+ continue;
7117
+ seen.add(line);
7118
+ const colon = line.indexOf(":");
7119
+ const file = colon > 0 ? line.slice(0, colon) : line;
7120
+ const count = perFile.get(file) ?? 0;
7121
+ if (count < SEARCH_MAX_PER_FILE) {
7122
+ perFile.set(file, count + 1);
7123
+ out.push(line);
7124
+ } else {
7125
+ omittedByFile.set(file, (omittedByFile.get(file) ?? 0) + 1);
7126
+ }
7127
+ }
7128
+ let totalOmitted = 0;
7129
+ for (const [file, n] of omittedByFile) {
7130
+ totalOmitted += n;
7131
+ out.push(` \u2026 +${n} more match(es) in ${file} \u2014 mink retrieve \u2026`);
7132
+ }
7133
+ const dedupRemoved = lines.length - seen.size;
7134
+ if (totalOmitted === 0 && dedupRemoved === 0)
7135
+ return null;
7136
+ const notes = [];
7137
+ if (totalOmitted > 0)
7138
+ notes.push(`${totalOmitted} match(es) capped`);
7139
+ if (dedupRemoved > 0)
7140
+ notes.push(`${dedupRemoved} duplicate(s) removed`);
7141
+ return { compressed: out.join(`
7142
+ `), omittedNote: notes.join("; ") };
7143
+ }
7144
+ function compressFile(filePath, content) {
7145
+ const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
7146
+ const markdown = ext === ".md" || ext === ".mdx" || ext === ".markdown";
7147
+ const skeleton = extractCodeSkeleton(content, { markdown });
7148
+ if (!skeleton) {
7149
+ return compressText(content);
7150
+ }
7151
+ const header = `${filePath} \u2014 structural summary ` + `(${skeleton.lines.length} signature(s) of ${skeleton.totalLines} lines)`;
7152
+ return {
7153
+ compressed: [header, ...skeleton.lines].join(`
7154
+ `),
7155
+ omittedNote: `bodies elided; ${skeleton.totalLines} lines available via mink retrieve`
7156
+ };
7157
+ }
7158
+ function crush(value) {
7159
+ if (Array.isArray(value)) {
7160
+ let omitted = 0;
7161
+ const mapEl = (el) => {
7162
+ const r = crush(el);
7163
+ omitted += r.omitted;
7164
+ return r.value;
7165
+ };
7166
+ if (value.length <= JSON_ARRAY_HEAD + JSON_ARRAY_TAIL) {
7167
+ return { value: value.map(mapEl), omitted };
7168
+ }
7169
+ const dropped = value.length - JSON_ARRAY_HEAD - JSON_ARRAY_TAIL;
7170
+ omitted += dropped;
7171
+ const out = [
7172
+ ...value.slice(0, JSON_ARRAY_HEAD).map(mapEl),
7173
+ `\u2026 ${dropped} element(s) omitted \u2014 mink retrieve \u2026`,
7174
+ ...value.slice(value.length - JSON_ARRAY_TAIL).map(mapEl)
7175
+ ];
7176
+ return { value: out, omitted };
7177
+ }
7178
+ if (value && typeof value === "object") {
7179
+ let omitted = 0;
7180
+ const out = {};
7181
+ for (const [k, v] of Object.entries(value)) {
7182
+ const r = crush(v);
7183
+ omitted += r.omitted;
7184
+ out[k] = r.value;
7185
+ }
7186
+ return { value: out, omitted };
7187
+ }
7188
+ return { value, omitted: 0 };
7189
+ }
7190
+ function compressJson(content) {
7191
+ let parsed;
7192
+ try {
7193
+ parsed = JSON.parse(content);
7194
+ } catch {
7195
+ return null;
7196
+ }
7197
+ const { value, omitted } = crush(parsed);
7198
+ if (omitted === 0)
7199
+ return null;
7200
+ return {
7201
+ compressed: JSON.stringify(value, null, 2),
7202
+ omittedNote: `${omitted} array element(s) sampled out`
7203
+ };
7204
+ }
7205
+ function compressText(content) {
7206
+ const lines = toLines(content);
7207
+ if (lines.length <= TEXT_HEAD + TEXT_TAIL)
7208
+ return null;
7209
+ const omitted = lines.length - TEXT_HEAD - TEXT_TAIL;
7210
+ const head = lines.slice(0, TEXT_HEAD);
7211
+ const tail = lines.slice(lines.length - TEXT_TAIL);
7212
+ return {
7213
+ compressed: [...head, omittedMarker(omitted), ...tail].join(`
7214
+ `),
7215
+ omittedNote: `${omitted} of ${lines.length} line(s) omitted (middle)`
7216
+ };
7217
+ }
7218
+ function detectContentKind(toolName, content, filePath) {
7219
+ const t = toolName.toLowerCase();
7220
+ if (t === "read")
7221
+ return "file";
7222
+ if (t === "grep" || t === "glob")
7223
+ return "search";
7224
+ if (t === "bash")
7225
+ return "log";
7226
+ const head = content.trimStart()[0];
7227
+ if (head === "{" || head === "[") {
7228
+ try {
7229
+ JSON.parse(content);
7230
+ return "json";
7231
+ } catch {}
7232
+ }
7233
+ if (filePath)
7234
+ return "file";
7235
+ return "text";
7236
+ }
7237
+ function compressOutput(toolName, content, filePath) {
7238
+ const kind = detectContentKind(toolName, content, filePath);
7239
+ let result;
7240
+ switch (kind) {
7241
+ case "search":
7242
+ result = compressSearch(content);
7243
+ break;
7244
+ case "log":
7245
+ result = compressLog(content);
7246
+ break;
7247
+ case "file":
7248
+ result = compressFile(filePath ?? "file", content);
7249
+ break;
7250
+ case "json":
7251
+ result = compressJson(content);
7252
+ break;
7253
+ case "text":
7254
+ result = compressText(content);
7255
+ break;
7256
+ }
7257
+ if (!result)
7258
+ return null;
7259
+ return { kind, compressed: result.compressed, omittedNote: result.omittedNote };
7260
+ }
7261
+ 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;
7262
+ var init_output_compression = __esm(() => {
7263
+ init_code_skeleton();
7264
+ ANSI = /\u001B\[[0-9;?]*[ -/]*[@-~]/g;
7265
+ });
7266
+
7267
+ // src/repositories/compression-cache-repo.ts
7268
+ import { randomUUID as randomUUID3 } from "crypto";
7269
+
7270
+ class CompressionCacheRepo {
7271
+ db;
7272
+ constructor(db) {
7273
+ this.db = db;
7274
+ }
7275
+ static for(cwd) {
7276
+ return new CompressionCacheRepo(openProjectDb(cwd));
7277
+ }
7278
+ static newToken() {
7279
+ return `mc-${randomUUID3().slice(0, 8)}`;
7280
+ }
7281
+ store(input, deviceId = getOrCreateDeviceId()) {
7282
+ const token = input.token ?? CompressionCacheRepo.newToken();
7283
+ const now = input.now ?? new Date;
7284
+ const createdAt = now.toISOString();
7285
+ const expiresAt = new Date(now.getTime() + Math.max(0, input.retentionHours) * 3600000).toISOString();
7286
+ this.db.prepare(`
7287
+ INSERT OR REPLACE INTO compression_cache
7288
+ (token, created_at, expires_at, tool_name, content_kind,
7289
+ content, size_bytes, device_id)
7290
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
7291
+ `).run(token, createdAt, expiresAt, input.toolName, input.contentKind, input.content, Buffer.byteLength(input.content, "utf-8"), deviceId);
7292
+ return token;
7293
+ }
7294
+ get(token, now = new Date) {
7295
+ const row = this.db.prepare("SELECT * FROM compression_cache WHERE token = ?").get(token);
7296
+ if (!row)
7297
+ return null;
7298
+ const expiresAt = String(row.expires_at);
7299
+ if (expiresAt <= now.toISOString()) {
7300
+ try {
7301
+ this.db.prepare("DELETE FROM compression_cache WHERE token = ?").run(token);
7302
+ } catch {}
7303
+ return null;
7304
+ }
7305
+ return {
7306
+ token: String(row.token),
7307
+ createdAt: String(row.created_at),
7308
+ expiresAt,
7309
+ toolName: String(row.tool_name),
7310
+ contentKind: String(row.content_kind),
7311
+ content: String(row.content),
7312
+ sizeBytes: Number(row.size_bytes)
7313
+ };
7314
+ }
7315
+ evictExpired(now = new Date) {
7316
+ const r = this.db.prepare("DELETE FROM compression_cache WHERE expires_at <= ?").run(now.toISOString());
7317
+ return Number(r.changes);
7318
+ }
7319
+ count() {
7320
+ const row = this.db.prepare("SELECT COUNT(*) AS n FROM compression_cache").get();
7321
+ return Number(row.n);
7322
+ }
7323
+ }
7324
+ var init_compression_cache_repo = __esm(() => {
7325
+ init_db();
7326
+ init_device();
7327
+ });
7328
+
7329
+ // src/core/compress-tool-output.ts
7330
+ function contentKey(s) {
7331
+ let h = 2166136261;
7332
+ for (let i = 0;i < s.length; i++) {
7333
+ h ^= s.charCodeAt(i);
7334
+ h = Math.imul(h, 16777619);
7335
+ }
7336
+ return (h >>> 0).toString(16);
7337
+ }
7338
+ function render(result, token) {
7339
+ return result.compressed + `
7340
+
7341
+ ` + `\u2014 mink: compressed ${result.kind} output (${result.omittedNote}). ` + `Full original: mink retrieve ${token}`;
7342
+ }
7343
+ function safeRecord(cwd, toolName, contentKind, originalTokens, compressedTokens, holdout) {
7344
+ try {
7345
+ TokenLedgerRepo.for(cwd).recordCompression({
7346
+ toolName,
7347
+ contentKind,
7348
+ originalTokens,
7349
+ compressedTokens,
7350
+ holdout
7351
+ });
7352
+ } catch {}
7353
+ }
7354
+ function compressToolOutput(cwd, toolName, output, filePath) {
7355
+ let cfg;
7356
+ try {
7357
+ cfg = loadCompressionConfig();
7358
+ } catch {
7359
+ return null;
7360
+ }
7361
+ if (!cfg.enabled)
7362
+ return null;
7363
+ if (typeof output !== "string" || output.length === 0)
7364
+ return null;
7365
+ const originalTokens = countTokens(output);
7366
+ if (!isEligible(originalTokens, cfg))
7367
+ return null;
7368
+ const eventKey = contentKey(output);
7369
+ if (selectHoldout(eventKey, cfg.holdoutFraction)) {
7370
+ const kind = detectContentKind(toolName, output, filePath);
7371
+ safeRecord(cwd, toolName, kind, originalTokens, originalTokens, true);
7372
+ return null;
7373
+ }
7374
+ const result = compressOutput(toolName, output, filePath);
7375
+ if (!result)
7376
+ return null;
7377
+ const token = CompressionCacheRepo.newToken();
7378
+ const replacement = render(result, token);
7379
+ const compressedTokens = countTokens(replacement);
7380
+ if (!meetsMinSavings(originalTokens, compressedTokens, cfg))
7381
+ return null;
7382
+ try {
7383
+ CompressionCacheRepo.for(cwd).store({
7384
+ toolName,
7385
+ contentKind: result.kind,
7386
+ content: output,
7387
+ retentionHours: cfg.retentionHours,
7388
+ token
7389
+ });
7390
+ } catch {
7391
+ return null;
7392
+ }
7393
+ safeRecord(cwd, toolName, result.kind, originalTokens, compressedTokens, false);
7394
+ return { updatedToolOutput: replacement, token };
7395
+ }
7396
+ var init_compress_tool_output = __esm(() => {
7397
+ init_compression();
7398
+ init_token_estimate();
7399
+ init_output_compression();
7400
+ init_compression_cache_repo();
7401
+ init_token_ledger_repo();
7402
+ });
7403
+
7404
+ // src/core/hook-output.ts
7405
+ function extractToolOutputText(input) {
7406
+ const tr = input.tool_response;
7407
+ if (tr) {
7408
+ if (typeof tr.content === "string")
7409
+ return tr.content;
7410
+ if (Array.isArray(tr.content)) {
7411
+ const parts = tr.content.map((p) => p && typeof p.text === "string" ? p.text : "").filter((s) => s.length > 0);
7412
+ if (parts.length > 0)
7413
+ return parts.join("");
7414
+ }
7415
+ if (typeof tr.stdout === "string" && tr.stdout.length > 0)
7416
+ return tr.stdout;
7417
+ if (typeof tr.text === "string")
7418
+ return tr.text;
7419
+ const file = tr.file;
7420
+ if (file && typeof file.content === "string")
7421
+ return file.content;
7422
+ }
7423
+ const to = input.tool_output;
7424
+ if (to && typeof to.content === "string")
7425
+ return to.content;
7426
+ return null;
7427
+ }
7428
+ function emitUpdatedToolOutput(text) {
7429
+ process.stdout.write(JSON.stringify({
7430
+ hookSpecificOutput: {
7431
+ hookEventName: "PostToolUse",
7432
+ updatedToolOutput: text
7433
+ }
7434
+ }));
7435
+ }
7436
+
7180
7437
  // src/commands/post-read.ts
7181
7438
  var exports_post_read = {};
7182
7439
  __export(exports_post_read, {
@@ -7306,6 +7563,14 @@ async function postRead(cwd) {
7306
7563
  logWriter.appendReadEntry(new Date().toISOString(), filePath, result.indexHit, result.estimatedTokens);
7307
7564
  } catch {}
7308
7565
  atomicWriteJson(sessionPath(cwd), state);
7566
+ const isRanged = input.tool_input.offset != null || input.tool_input.limit != null;
7567
+ if (!isRanged && content && content.length > 0) {
7568
+ try {
7569
+ const outcome = compressToolOutput(cwd, "Read", content, filePath);
7570
+ if (outcome)
7571
+ emitUpdatedToolOutput(outcome.updatedToolOutput);
7572
+ } catch {}
7573
+ }
7309
7574
  } catch {} finally {
7310
7575
  clearTimeout(timer);
7311
7576
  }
@@ -7319,6 +7584,43 @@ var init_post_read = __esm(() => {
7319
7584
  init_description();
7320
7585
  init_action_log();
7321
7586
  init_device();
7587
+ init_compress_tool_output();
7588
+ });
7589
+
7590
+ // src/commands/post-tool.ts
7591
+ var exports_post_tool = {};
7592
+ __export(exports_post_tool, {
7593
+ postTool: () => postTool
7594
+ });
7595
+ function isPostToolUseInput2(value) {
7596
+ if (value === null || typeof value !== "object")
7597
+ return false;
7598
+ const obj = value;
7599
+ return typeof obj.tool_name === "string";
7600
+ }
7601
+ function isCompressibleTool(toolName) {
7602
+ return toolName === "Bash" || toolName === "Grep" || toolName === "Glob" || toolName.startsWith("mcp__");
7603
+ }
7604
+ async function postTool(cwd) {
7605
+ const timer = setTimeout(() => process.exit(0), 5000);
7606
+ try {
7607
+ const input = await readStdinJson();
7608
+ if (!isPostToolUseInput2(input))
7609
+ return;
7610
+ if (!isCompressibleTool(input.tool_name))
7611
+ return;
7612
+ const output = extractToolOutputText(input);
7613
+ if (!output)
7614
+ return;
7615
+ const outcome = compressToolOutput(cwd, input.tool_name, output);
7616
+ if (outcome)
7617
+ emitUpdatedToolOutput(outcome.updatedToolOutput);
7618
+ } catch {} finally {
7619
+ clearTimeout(timer);
7620
+ }
7621
+ }
7622
+ var init_post_tool = __esm(() => {
7623
+ init_compress_tool_output();
7322
7624
  });
7323
7625
 
7324
7626
  // src/core/pattern-engine.ts
@@ -7557,7 +7859,7 @@ function analyzePostWrite(filePath, fileContent, index) {
7557
7859
  indexEntry
7558
7860
  };
7559
7861
  }
7560
- function isPostToolUseInput2(value) {
7862
+ function isPostToolUseInput3(value) {
7561
7863
  if (value === null || typeof value !== "object")
7562
7864
  return false;
7563
7865
  const obj = value;
@@ -7571,7 +7873,7 @@ async function postWrite(cwd) {
7571
7873
  const timer = setTimeout(() => process.exit(0), 1e4);
7572
7874
  try {
7573
7875
  const input = await readStdinJson();
7574
- if (!isPostToolUseInput2(input))
7876
+ if (!isPostToolUseInput3(input))
7575
7877
  return;
7576
7878
  if (input.tool_name !== "Write" && input.tool_name !== "Edit")
7577
7879
  return;
@@ -7800,6 +8102,35 @@ var init_detect_waste = __esm(() => {
7800
8102
  init_device();
7801
8103
  });
7802
8104
 
8105
+ // src/commands/retrieve.ts
8106
+ var exports_retrieve = {};
8107
+ __export(exports_retrieve, {
8108
+ retrieve: () => retrieve
8109
+ });
8110
+ function retrieve(cwd, args) {
8111
+ const token = args[0];
8112
+ if (!token) {
8113
+ process.stderr.write(`[mink] usage: mink retrieve <token>
8114
+ `);
8115
+ return;
8116
+ }
8117
+ let entry = null;
8118
+ try {
8119
+ entry = CompressionCacheRepo.for(cwd).get(token);
8120
+ } catch {
8121
+ entry = null;
8122
+ }
8123
+ if (!entry) {
8124
+ process.stderr.write(`[mink] no retrievable output for token "${token}" (unknown or expired)
8125
+ `);
8126
+ return;
8127
+ }
8128
+ process.stdout.write(entry.content);
8129
+ }
8130
+ var init_retrieve = __esm(() => {
8131
+ init_compression_cache_repo();
8132
+ });
8133
+
7803
8134
  // src/core/cron-parser.ts
7804
8135
  function parseField(field, min, max) {
7805
8136
  const values = new Set;
@@ -7882,9 +8213,9 @@ __export(exports_self_update, {
7882
8213
  PACKAGE_NAME: () => PACKAGE_NAME
7883
8214
  });
7884
8215
  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";
8216
+ import { existsSync as existsSync24, readFileSync as readFileSync20 } from "fs";
8217
+ import { dirname as dirname10 } from "path";
8218
+ import { join as join21 } from "path";
7888
8219
  function parseSemver(input) {
7889
8220
  const trimmed = input.trim().replace(/^v/, "");
7890
8221
  if (!trimmed)
@@ -7931,15 +8262,15 @@ function compareSemver(a, b) {
7931
8262
  function getInstallInfo() {
7932
8263
  const selfPath = new URL(import.meta.url).pathname;
7933
8264
  const isDevMode = selfPath.endsWith(".ts");
7934
- let dir = dirname11(selfPath);
8265
+ let dir = dirname10(selfPath);
7935
8266
  let packageJsonPath = null;
7936
8267
  for (let i = 0;i < 10; i++) {
7937
- const candidate = join23(dir, "package.json");
7938
- if (existsSync26(candidate)) {
8268
+ const candidate = join21(dir, "package.json");
8269
+ if (existsSync24(candidate)) {
7939
8270
  packageJsonPath = candidate;
7940
8271
  break;
7941
8272
  }
7942
- const parent = dirname11(dir);
8273
+ const parent = dirname10(dir);
7943
8274
  if (parent === dir)
7944
8275
  break;
7945
8276
  dir = parent;
@@ -8009,7 +8340,7 @@ function buildInstallCommand(pm, version) {
8009
8340
  return ["npm", "install", "-g", ref];
8010
8341
  }
8011
8342
  function selfUpdateLogPath() {
8012
- return join23(minkRoot(), "self-update.log");
8343
+ return join21(minkRoot(), "self-update.log");
8013
8344
  }
8014
8345
  function appendLogEntry(entry) {
8015
8346
  const path = selfUpdateLogPath();
@@ -8798,21 +9129,21 @@ var init_cron = __esm(() => {
8798
9129
  });
8799
9130
 
8800
9131
  // 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";
9132
+ import { join as join22 } from "path";
9133
+ import { existsSync as existsSync25, writeFileSync as writeFileSync9, readFileSync as readFileSync21, mkdirSync as mkdirSync13 } from "fs";
8803
9134
  function seedTemplates(templatesDir) {
8804
- mkdirSync14(templatesDir, { recursive: true });
9135
+ mkdirSync13(templatesDir, { recursive: true });
8805
9136
  for (const [name, content] of Object.entries(DEFAULT_TEMPLATES)) {
8806
- const filePath = join24(templatesDir, `${name}.md`);
8807
- if (!existsSync27(filePath)) {
9137
+ const filePath = join22(templatesDir, `${name}.md`);
9138
+ if (!existsSync25(filePath)) {
8808
9139
  writeFileSync9(filePath, content);
8809
9140
  }
8810
9141
  }
8811
9142
  }
8812
9143
  function loadTemplate(templatesDir, templateName, vars) {
8813
- const filePath = join24(templatesDir, `${templateName}.md`);
9144
+ const filePath = join22(templatesDir, `${templateName}.md`);
8814
9145
  let content;
8815
- if (existsSync27(filePath)) {
9146
+ if (existsSync25(filePath)) {
8816
9147
  content = readFileSync21(filePath, "utf-8");
8817
9148
  } else if (DEFAULT_TEMPLATES[templateName]) {
8818
9149
  content = DEFAULT_TEMPLATES[templateName];
@@ -8966,29 +9297,29 @@ category: resources
8966
9297
  });
8967
9298
 
8968
9299
  // src/core/note-writer.ts
8969
- import { join as join25 } from "path";
8970
- import { existsSync as existsSync28, readFileSync as readFileSync22 } from "fs";
9300
+ import { join as join23 } from "path";
9301
+ import { existsSync as existsSync26, readFileSync as readFileSync22 } from "fs";
8971
9302
  import { createHash as createHash3 } from "crypto";
8972
9303
  function sha256(content) {
8973
9304
  return createHash3("sha256").update(content).digest("hex");
8974
9305
  }
8975
9306
  function resolveUniqueNotePath(dir, baseSlug, content) {
8976
9307
  const targetHash = sha256(content);
8977
- const primary = join25(dir, `${baseSlug}.md`);
8978
- if (!existsSync28(primary))
9308
+ const primary = join23(dir, `${baseSlug}.md`);
9309
+ if (!existsSync26(primary))
8979
9310
  return primary;
8980
9311
  if (sameContent(primary, targetHash))
8981
9312
  return primary;
8982
9313
  const dev4 = getOrCreateDeviceId().replace(/-/g, "").slice(0, 4);
8983
9314
  for (let i = 0;i < MAX_COLLISION_ATTEMPTS; i++) {
8984
9315
  const suffix = i === 0 ? dev4 : `${dev4}-${i + 1}`;
8985
- const candidate = join25(dir, `${baseSlug}-${suffix}.md`);
8986
- if (!existsSync28(candidate))
9316
+ const candidate = join23(dir, `${baseSlug}-${suffix}.md`);
9317
+ if (!existsSync26(candidate))
8987
9318
  return candidate;
8988
9319
  if (sameContent(candidate, targetHash))
8989
9320
  return candidate;
8990
9321
  }
8991
- return join25(dir, `${baseSlug}-${Date.now()}.md`);
9322
+ return join23(dir, `${baseSlug}-${Date.now()}.md`);
8992
9323
  }
8993
9324
  function sameContent(filePath, expectedHash) {
8994
9325
  try {
@@ -9063,8 +9394,8 @@ ${meta.body}
9063
9394
  }
9064
9395
  function appendToDaily(date, content) {
9065
9396
  const dir = vaultDailyDir();
9066
- const filePath = join25(dir, `${date}.md`);
9067
- if (existsSync28(filePath)) {
9397
+ const filePath = join23(dir, `${date}.md`);
9398
+ if (existsSync26(filePath)) {
9068
9399
  const timestamp = new Date().toLocaleTimeString("en-US", {
9069
9400
  hour: "2-digit",
9070
9401
  minute: "2-digit",
@@ -9173,10 +9504,10 @@ var init_design_eval = __esm(() => {
9173
9504
  });
9174
9505
 
9175
9506
  // src/core/dashboard-api.ts
9176
- import { existsSync as existsSync29, readFileSync as readFileSync23 } from "fs";
9507
+ import { existsSync as existsSync27, readFileSync as readFileSync23 } from "fs";
9177
9508
  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";
9509
+ import { join as join24, resolve as resolve5, normalize, sep } from "path";
9510
+ import { execSync as execSync6 } from "child_process";
9180
9511
  function isSecretKey(key) {
9181
9512
  return SECRET_KEY_PATTERNS.some((re) => re.test(key));
9182
9513
  }
@@ -9188,7 +9519,7 @@ function maskSecret(value, showLast = 4) {
9188
9519
  return "\u2022\u2022\u2022\u2022" + value.slice(-showLast);
9189
9520
  }
9190
9521
  function checkJsonFile2(name, filePath, validator) {
9191
- if (!existsSync29(filePath))
9522
+ if (!existsSync27(filePath))
9192
9523
  return { name, status: "missing" };
9193
9524
  const data = safeReadJson(filePath);
9194
9525
  if (data === null)
@@ -9198,7 +9529,7 @@ function checkJsonFile2(name, filePath, validator) {
9198
9529
  return { name, status: "ok" };
9199
9530
  }
9200
9531
  function checkTextFile(name, filePath) {
9201
- if (!existsSync29(filePath))
9532
+ if (!existsSync27(filePath))
9202
9533
  return { name, status: "missing" };
9203
9534
  try {
9204
9535
  readFileSync23(filePath, "utf-8");
@@ -9208,7 +9539,7 @@ function checkTextFile(name, filePath) {
9208
9539
  }
9209
9540
  }
9210
9541
  function checkDbFile2(name, filePath) {
9211
- if (!existsSync29(filePath))
9542
+ if (!existsSync27(filePath))
9212
9543
  return { name, status: "missing" };
9213
9544
  try {
9214
9545
  const header = readFileSync23(filePath).slice(0, 16).toString("utf-8");
@@ -9390,7 +9721,7 @@ function getAheadBehind(branch) {
9390
9721
  if (!branch)
9391
9722
  return { ahead: 0, behind: 0 };
9392
9723
  try {
9393
- const raw = execSync7(`git rev-list --left-right --count origin/${branch}...${branch}`, { cwd: minkRoot(), timeout: 5000, stdio: ["pipe", "pipe", "pipe"] }).toString().trim();
9724
+ const raw = execSync6(`git rev-list --left-right --count origin/${branch}...${branch}`, { cwd: minkRoot(), timeout: 5000, stdio: ["pipe", "pipe", "pipe"] }).toString().trim();
9394
9725
  const [behindStr, aheadStr] = raw.split(/\s+/);
9395
9726
  return {
9396
9727
  behind: Number(behindStr) || 0,
@@ -9402,7 +9733,7 @@ function getAheadBehind(branch) {
9402
9733
  }
9403
9734
  function getPendingChanges() {
9404
9735
  try {
9405
- const raw = execSync7("git status --porcelain", {
9736
+ const raw = execSync6("git status --porcelain", {
9406
9737
  cwd: minkRoot(),
9407
9738
  timeout: 5000,
9408
9739
  stdio: ["pipe", "pipe", "pipe"]
@@ -9474,7 +9805,7 @@ function countMarkdownIn(dir) {
9474
9805
  for (const entry of readdirSync9(dir, { withFileTypes: true })) {
9475
9806
  if (WIKI_TREE_EXCLUDES.has(entry.name) || entry.name.startsWith("."))
9476
9807
  continue;
9477
- const fullPath = join26(dir, entry.name);
9808
+ const fullPath = join24(dir, entry.name);
9478
9809
  if (entry.isDirectory()) {
9479
9810
  count += countMarkdownIn(fullPath);
9480
9811
  } else if (entry.name.endsWith(".md") && !entry.name.startsWith("_")) {
@@ -9503,7 +9834,7 @@ function buildVaultTree(root) {
9503
9834
  for (const entry of entries) {
9504
9835
  if (!entry.isDir)
9505
9836
  continue;
9506
- const fullPath = join26(dir, entry.name);
9837
+ const fullPath = join24(dir, entry.name);
9507
9838
  const relPath = fullPath.slice(root.length + 1);
9508
9839
  const count = countMarkdownIn(fullPath);
9509
9840
  nodes.push({ name: entry.name, path: relPath, count, depth });
@@ -9588,7 +9919,7 @@ function resolveVaultRelativePath(relPath) {
9588
9919
  if (!relPath || relPath.includes("\x00"))
9589
9920
  return null;
9590
9921
  const root = resolveVaultPath();
9591
- const absolute = resolve6(root, relPath);
9922
+ const absolute = resolve5(root, relPath);
9592
9923
  const normalizedRoot = normalize(root) + sep;
9593
9924
  if (!absolute.startsWith(normalizedRoot) && absolute !== normalize(root)) {
9594
9925
  return null;
@@ -9926,7 +10257,7 @@ async function triggerIngestFile(sourcePath, category, tags, dedupKey) {
9926
10257
  if (!isValidCategory(category)) {
9927
10258
  return { success: false, error: `Invalid category: ${category}` };
9928
10259
  }
9929
- const expanded = sourcePath.startsWith("~/") ? join26(process.env.HOME ?? "", sourcePath.slice(2)) : sourcePath;
10260
+ const expanded = sourcePath.startsWith("~/") ? join24(process.env.HOME ?? "", sourcePath.slice(2)) : sourcePath;
9930
10261
  if (!fsExistsSync(expanded)) {
9931
10262
  return { success: false, error: `Source file not found: ${sourcePath}` };
9932
10263
  }
@@ -10013,8 +10344,8 @@ __export(exports_dashboard_server, {
10013
10344
  startDashboardServer: () => startDashboardServer
10014
10345
  });
10015
10346
  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";
10347
+ import { existsSync as existsSync28 } from "fs";
10348
+ import { basename as basename7, dirname as dirname11, join as join25, extname as extname2 } from "path";
10018
10349
 
10019
10350
  class SSEManager {
10020
10351
  clients = new Map;
@@ -10191,15 +10522,15 @@ async function startDashboardServer(cwd, options = {}) {
10191
10522
  timestamp: new Date().toISOString()
10192
10523
  });
10193
10524
  });
10194
- const __dir = dirname12(new URL(import.meta.url).pathname);
10525
+ const __dir = dirname11(new URL(import.meta.url).pathname);
10195
10526
  let pkgRoot = __dir;
10196
- while (pkgRoot !== dirname12(pkgRoot)) {
10197
- if (existsSync30(join27(pkgRoot, "package.json")))
10527
+ while (pkgRoot !== dirname11(pkgRoot)) {
10528
+ if (existsSync28(join25(pkgRoot, "package.json")))
10198
10529
  break;
10199
- pkgRoot = dirname12(pkgRoot);
10530
+ pkgRoot = dirname11(pkgRoot);
10200
10531
  }
10201
- const dashboardOutDir = join27(pkgRoot, "dashboard", "out");
10202
- const dashboardBuilt = existsSync30(join27(dashboardOutDir, "index.html"));
10532
+ const dashboardOutDir = join25(pkgRoot, "dashboard", "out");
10533
+ const dashboardBuilt = existsSync28(join25(dashboardOutDir, "index.html"));
10203
10534
  let clientIdCounter = 0;
10204
10535
  if (!dashboardBuilt) {
10205
10536
  console.warn("[mink] dashboard not built. Run: cd dashboard && bun run build");
@@ -10229,9 +10560,9 @@ async function startDashboardServer(cwd, options = {}) {
10229
10560
  } else {
10230
10561
  let filePath;
10231
10562
  if (pathname === "/") {
10232
- filePath = join27(dashboardOutDir, "index.html");
10563
+ filePath = join25(dashboardOutDir, "index.html");
10233
10564
  } else {
10234
- filePath = join27(dashboardOutDir, pathname);
10565
+ filePath = join25(dashboardOutDir, pathname);
10235
10566
  }
10236
10567
  if (!filePath.startsWith(dashboardOutDir)) {
10237
10568
  return jsonResponse({ error: "Forbidden" }, 403);
@@ -10244,7 +10575,7 @@ async function startDashboardServer(cwd, options = {}) {
10244
10575
  const htmlServed = await serveFile(filePath + ".html", "text/html; charset=utf-8");
10245
10576
  if (htmlServed)
10246
10577
  return htmlServed;
10247
- const indexServed = await serveFile(join27(dashboardOutDir, "index.html"), "text/html; charset=utf-8");
10578
+ const indexServed = await serveFile(join25(dashboardOutDir, "index.html"), "text/html; charset=utf-8");
10248
10579
  if (indexServed)
10249
10580
  return indexServed;
10250
10581
  }
@@ -10353,7 +10684,7 @@ retry: 3000
10353
10684
  if (!filename || filename.includes("..") || filename.includes("/")) {
10354
10685
  return jsonResponse({ error: "Invalid filename" }, 400);
10355
10686
  }
10356
- const imgPath = join27(designCapturesDir(resolvedCwd), filename);
10687
+ const imgPath = join25(designCapturesDir(resolvedCwd), filename);
10357
10688
  const served = await serveFile(imgPath, "image/jpeg");
10358
10689
  if (served) {
10359
10690
  served.headers.set("Cache-Control", "public, max-age=60");
@@ -10588,9 +10919,9 @@ __export(exports_dashboard, {
10588
10919
  resolveStartupCwd: () => resolveStartupCwd,
10589
10920
  dashboard: () => dashboard
10590
10921
  });
10591
- import { existsSync as existsSync31 } from "fs";
10922
+ import { existsSync as existsSync29 } from "fs";
10592
10923
  function resolveStartupCwd(cwd, registered = listRegisteredProjects()) {
10593
- if (existsSync31(projectDir(cwd))) {
10924
+ if (existsSync29(projectDir(cwd))) {
10594
10925
  return { kind: "active", cwd };
10595
10926
  }
10596
10927
  if (registered.length === 0) {
@@ -10627,10 +10958,10 @@ var init_dashboard = __esm(() => {
10627
10958
  });
10628
10959
 
10629
10960
  // 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";
10961
+ import { execSync as execSync7 } from "child_process";
10962
+ import { existsSync as existsSync30, mkdirSync as mkdirSync14, unlinkSync as unlinkSync5, writeFileSync as writeFileSync10 } from "fs";
10963
+ import { homedir as homedir3 } from "os";
10964
+ import { dirname as dirname12, join as join26 } from "path";
10634
10965
  function detectPlatform() {
10635
10966
  if (process.platform === "linux")
10636
10967
  return "systemd";
@@ -10640,11 +10971,11 @@ function detectPlatform() {
10640
10971
  }
10641
10972
  function resolveServiceInvocation() {
10642
10973
  const entry = process.argv[1];
10643
- if (entry && !/\.(js|ts|mjs|cjs)$/.test(entry) && existsSync32(entry)) {
10974
+ if (entry && !/\.(js|ts|mjs|cjs)$/.test(entry) && existsSync30(entry)) {
10644
10975
  return {
10645
10976
  executable: entry,
10646
10977
  args: ["daemon", "start"],
10647
- pathDir: dirname13(entry)
10978
+ pathDir: dirname12(entry)
10648
10979
  };
10649
10980
  }
10650
10981
  const cliPath = resolveCliPath();
@@ -10652,17 +10983,17 @@ function resolveServiceInvocation() {
10652
10983
  return {
10653
10984
  executable: interpreter,
10654
10985
  args: [cliPath, "daemon", "start"],
10655
- pathDir: dirname13(interpreter)
10986
+ pathDir: dirname12(interpreter)
10656
10987
  };
10657
10988
  }
10658
10989
  function servicePaths(platform2) {
10659
- const home = homedir4();
10990
+ const home = homedir3();
10660
10991
  if (platform2 === "systemd") {
10661
- const unitDir2 = join28(home, ".config", "systemd", "user");
10662
- return { unitDir: unitDir2, unitFile: join28(unitDir2, "mink-daemon.service") };
10992
+ const unitDir2 = join26(home, ".config", "systemd", "user");
10993
+ return { unitDir: unitDir2, unitFile: join26(unitDir2, "mink-daemon.service") };
10663
10994
  }
10664
- const unitDir = join28(home, "Library", "LaunchAgents");
10665
- return { unitDir, unitFile: join28(unitDir, "com.mink.daemon.plist") };
10995
+ const unitDir = join26(home, "Library", "LaunchAgents");
10996
+ return { unitDir, unitFile: join26(unitDir, "com.mink.daemon.plist") };
10666
10997
  }
10667
10998
  function renderSystemdUnit(inv) {
10668
10999
  const execStart = [inv.executable, ...inv.args].join(" ");
@@ -10736,17 +11067,17 @@ function installService(options = {}) {
10736
11067
  process.exit(1);
10737
11068
  }
10738
11069
  const paths = servicePaths(platform2);
10739
- if (existsSync32(paths.unitFile) && !options.force) {
11070
+ if (existsSync30(paths.unitFile) && !options.force) {
10740
11071
  console.error(`[mink] unit file already exists: ${paths.unitFile}`);
10741
11072
  console.error(" re-run with --force to overwrite, or run `mink daemon uninstall` first");
10742
11073
  process.exit(1);
10743
11074
  }
10744
11075
  const inv = resolveServiceInvocation();
10745
- mkdirSync15(paths.unitDir, { recursive: true });
11076
+ mkdirSync14(paths.unitDir, { recursive: true });
10746
11077
  if (platform2 === "systemd") {
10747
11078
  writeFileSync10(paths.unitFile, renderSystemdUnit(inv));
10748
11079
  try {
10749
- execSync8("systemctl --user daemon-reload", { stdio: "ignore" });
11080
+ execSync7("systemctl --user daemon-reload", { stdio: "ignore" });
10750
11081
  } catch {}
10751
11082
  console.log(`[mink] wrote ${paths.unitFile}`);
10752
11083
  console.log("[mink] next steps:");
@@ -10769,24 +11100,24 @@ function uninstallService() {
10769
11100
  process.exit(1);
10770
11101
  }
10771
11102
  const paths = servicePaths(platform2);
10772
- if (!existsSync32(paths.unitFile)) {
11103
+ if (!existsSync30(paths.unitFile)) {
10773
11104
  console.log(`[mink] no unit file at ${paths.unitFile} \u2014 nothing to uninstall`);
10774
11105
  return;
10775
11106
  }
10776
11107
  if (platform2 === "systemd") {
10777
11108
  try {
10778
- execSync8("systemctl --user disable --now mink-daemon.service", {
11109
+ execSync7("systemctl --user disable --now mink-daemon.service", {
10779
11110
  stdio: "ignore"
10780
11111
  });
10781
11112
  } catch {}
10782
11113
  unlinkSync5(paths.unitFile);
10783
11114
  try {
10784
- execSync8("systemctl --user daemon-reload", { stdio: "ignore" });
11115
+ execSync7("systemctl --user daemon-reload", { stdio: "ignore" });
10785
11116
  } catch {}
10786
11117
  console.log(`[mink] removed ${paths.unitFile}`);
10787
11118
  } else {
10788
11119
  try {
10789
- execSync8(`launchctl unload -w ${paths.unitFile}`, { stdio: "ignore" });
11120
+ execSync7(`launchctl unload -w ${paths.unitFile}`, { stdio: "ignore" });
10790
11121
  } catch {}
10791
11122
  unlinkSync5(paths.unitFile);
10792
11123
  console.log(`[mink] removed ${paths.unitFile}`);
@@ -10801,7 +11132,7 @@ var exports_daemon = {};
10801
11132
  __export(exports_daemon, {
10802
11133
  daemon: () => daemon
10803
11134
  });
10804
- import { readFileSync as readFileSync24, existsSync as existsSync33 } from "fs";
11135
+ import { readFileSync as readFileSync24, existsSync as existsSync31 } from "fs";
10805
11136
  async function daemon(cwd, args) {
10806
11137
  const subcommand = args[0];
10807
11138
  switch (subcommand) {
@@ -10817,7 +11148,7 @@ async function daemon(cwd, args) {
10817
11148
  break;
10818
11149
  case "logs": {
10819
11150
  const logPath = schedulerLogPath();
10820
- if (!existsSync33(logPath)) {
11151
+ if (!existsSync31(logPath)) {
10821
11152
  console.log("[mink] no log file found");
10822
11153
  return;
10823
11154
  }
@@ -11089,13 +11420,13 @@ function printValidKeys() {
11089
11420
  }
11090
11421
  }
11091
11422
  function readLineFromStdin() {
11092
- return new Promise((resolve8) => {
11423
+ return new Promise((resolve7) => {
11093
11424
  const chunks = [];
11094
11425
  process.stdin.resume();
11095
11426
  process.stdin.setEncoding("utf-8");
11096
11427
  process.stdin.once("data", (data) => {
11097
11428
  process.stdin.pause();
11098
- resolve8(String(data).trim());
11429
+ resolve7(String(data).trim());
11099
11430
  });
11100
11431
  });
11101
11432
  }
@@ -11170,7 +11501,7 @@ var exports_update = {};
11170
11501
  __export(exports_update, {
11171
11502
  update: () => update
11172
11503
  });
11173
- import { resolve as resolve8 } from "path";
11504
+ import { resolve as resolve7 } from "path";
11174
11505
  function parseArgs(args) {
11175
11506
  let dryRun = false;
11176
11507
  let project = null;
@@ -11228,7 +11559,7 @@ async function update(cwd, args) {
11228
11559
  }
11229
11560
  const backupName = createBackup(target.cwd);
11230
11561
  console.log(` backup: ${backupName}`);
11231
- const settingsPath = resolve8(target.cwd, ".claude", "settings.json");
11562
+ const settingsPath = resolve7(target.cwd, ".claude", "settings.json");
11232
11563
  mergeHooksIntoSettings(settingsPath, newHooks);
11233
11564
  console.log(" hooks: updated");
11234
11565
  const metaPath = projectMetaPath(target.cwd);
@@ -11404,7 +11735,7 @@ var init_restore = __esm(() => {
11404
11735
 
11405
11736
  // src/core/design-eval/server-detect.ts
11406
11737
  import { readFileSync as readFileSync25 } from "fs";
11407
- import { join as join29 } from "path";
11738
+ import { join as join27 } from "path";
11408
11739
  async function probePort(port) {
11409
11740
  try {
11410
11741
  const controller = new AbortController;
@@ -11426,7 +11757,7 @@ async function findRunningServer(ports = DEFAULT_PROBE_PORTS) {
11426
11757
  }
11427
11758
  function detectDevCommand(cwd) {
11428
11759
  try {
11429
- const raw = readFileSync25(join29(cwd, "package.json"), "utf-8");
11760
+ const raw = readFileSync25(join27(cwd, "package.json"), "utf-8");
11430
11761
  const pkg = JSON.parse(raw);
11431
11762
  const scripts = pkg.scripts;
11432
11763
  if (!scripts || typeof scripts !== "object")
@@ -11446,10 +11777,10 @@ var init_server_detect = __esm(() => {
11446
11777
  });
11447
11778
 
11448
11779
  // 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";
11780
+ import { existsSync as existsSync32, readdirSync as readdirSync10, statSync as statSync11 } from "fs";
11781
+ import { join as join28, relative as relative7, sep as sep2 } from "path";
11451
11782
  function detectFramework(cwd) {
11452
- const has = (name) => ["js", "mjs", "ts", "cjs"].some((ext) => existsSync34(join30(cwd, `${name}.${ext}`))) || existsSync34(join30(cwd, name));
11783
+ const has = (name) => ["js", "mjs", "ts", "cjs"].some((ext) => existsSync32(join28(cwd, `${name}.${ext}`))) || existsSync32(join28(cwd, name));
11453
11784
  if (has("next.config"))
11454
11785
  return "nextjs";
11455
11786
  if (has("svelte.config"))
@@ -11474,8 +11805,8 @@ function detectRoutes(cwd) {
11474
11805
  }
11475
11806
  function detectNextRoutes(cwd) {
11476
11807
  const routes = [];
11477
- const appDir = join30(cwd, "app");
11478
- if (existsSync34(appDir)) {
11808
+ const appDir = join28(cwd, "app");
11809
+ if (existsSync32(appDir)) {
11479
11810
  const pageFiles = findFiles(appDir, /^page\.(tsx?|jsx?)$/);
11480
11811
  for (const file of pageFiles) {
11481
11812
  const rel = relative7(appDir, file);
@@ -11486,8 +11817,8 @@ function detectNextRoutes(cwd) {
11486
11817
  routes.push(route);
11487
11818
  }
11488
11819
  }
11489
- const pagesDir = join30(cwd, "pages");
11490
- if (existsSync34(pagesDir)) {
11820
+ const pagesDir = join28(cwd, "pages");
11821
+ if (existsSync32(pagesDir)) {
11491
11822
  const pageFiles = findFiles(pagesDir, /\.(tsx?|jsx?)$/);
11492
11823
  for (const file of pageFiles) {
11493
11824
  const rel = relative7(pagesDir, file);
@@ -11506,8 +11837,8 @@ function detectNextRoutes(cwd) {
11506
11837
  return unique.length > 0 ? unique.sort() : ["/"];
11507
11838
  }
11508
11839
  function detectSvelteKitRoutes(cwd) {
11509
- const routesDir = join30(cwd, "src", "routes");
11510
- if (!existsSync34(routesDir))
11840
+ const routesDir = join28(cwd, "src", "routes");
11841
+ if (!existsSync32(routesDir))
11511
11842
  return ["/"];
11512
11843
  const routes = [];
11513
11844
  const pageFiles = findFiles(routesDir, /^\+page\.svelte$/);
@@ -11522,8 +11853,8 @@ function detectSvelteKitRoutes(cwd) {
11522
11853
  return routes.length > 0 ? routes.sort() : ["/"];
11523
11854
  }
11524
11855
  function detectNuxtRoutes(cwd) {
11525
- const pagesDir = join30(cwd, "pages");
11526
- if (!existsSync34(pagesDir))
11856
+ const pagesDir = join28(cwd, "pages");
11857
+ if (!existsSync32(pagesDir))
11527
11858
  return ["/"];
11528
11859
  const routes = [];
11529
11860
  const vueFiles = findFiles(pagesDir, /\.vue$/);
@@ -11549,7 +11880,7 @@ function findFiles(dir, pattern) {
11549
11880
  for (const entry of entries) {
11550
11881
  if (entry.startsWith(".") || entry === "node_modules")
11551
11882
  continue;
11552
- const full = join30(current, entry);
11883
+ const full = join28(current, entry);
11553
11884
  try {
11554
11885
  const stat2 = statSync11(full);
11555
11886
  if (stat2.isDirectory()) {
@@ -11577,11 +11908,11 @@ function __extends(d, b) {
11577
11908
  }
11578
11909
  function __awaiter(thisArg, _arguments, P, generator) {
11579
11910
  function adopt(value) {
11580
- return value instanceof P ? value : new P(function(resolve9) {
11581
- resolve9(value);
11911
+ return value instanceof P ? value : new P(function(resolve8) {
11912
+ resolve8(value);
11582
11913
  });
11583
11914
  }
11584
- return new (P || (P = Promise))(function(resolve9, reject) {
11915
+ return new (P || (P = Promise))(function(resolve8, reject) {
11585
11916
  function fulfilled(value) {
11586
11917
  try {
11587
11918
  step(generator.next(value));
@@ -11597,7 +11928,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
11597
11928
  }
11598
11929
  }
11599
11930
  function step(result) {
11600
- result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
11931
+ result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
11601
11932
  }
11602
11933
  step((generator = generator.apply(thisArg, _arguments || [])).next());
11603
11934
  });
@@ -11780,14 +12111,14 @@ function __asyncValues(o) {
11780
12111
  }, i);
11781
12112
  function verb(n) {
11782
12113
  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);
12114
+ return new Promise(function(resolve8, reject) {
12115
+ v = o[n](v), settle(resolve8, reject, v.done, v.value);
11785
12116
  });
11786
12117
  };
11787
12118
  }
11788
- function settle(resolve9, reject, d, v) {
12119
+ function settle(resolve8, reject, d, v) {
11789
12120
  Promise.resolve(v).then(function(v2) {
11790
- resolve9({ value: v2, done: d });
12121
+ resolve8({ value: v2, done: d });
11791
12122
  }, reject);
11792
12123
  }
11793
12124
  }
@@ -12318,7 +12649,7 @@ function of() {
12318
12649
  }
12319
12650
  function lastValueFrom(source, config22) {
12320
12651
  var hasConfig = typeof config22 === "object";
12321
- return new Promise(function(resolve9, reject) {
12652
+ return new Promise(function(resolve8, reject) {
12322
12653
  var _hasValue = false;
12323
12654
  var _value;
12324
12655
  source.subscribe({
@@ -12329,9 +12660,9 @@ function lastValueFrom(source, config22) {
12329
12660
  error: reject,
12330
12661
  complete: function() {
12331
12662
  if (_hasValue) {
12332
- resolve9(_value);
12663
+ resolve8(_value);
12333
12664
  } else if (hasConfig) {
12334
- resolve9(config22.defaultValue);
12665
+ resolve8(config22.defaultValue);
12335
12666
  } else {
12336
12667
  reject(new EmptyError);
12337
12668
  }
@@ -12341,16 +12672,16 @@ function lastValueFrom(source, config22) {
12341
12672
  }
12342
12673
  function firstValueFrom(source, config22) {
12343
12674
  var hasConfig = typeof config22 === "object";
12344
- return new Promise(function(resolve9, reject) {
12675
+ return new Promise(function(resolve8, reject) {
12345
12676
  var subscriber = new SafeSubscriber({
12346
12677
  next: function(value) {
12347
- resolve9(value);
12678
+ resolve8(value);
12348
12679
  subscriber.unsubscribe();
12349
12680
  },
12350
12681
  error: reject,
12351
12682
  complete: function() {
12352
12683
  if (hasConfig) {
12353
- resolve9(config22.defaultValue);
12684
+ resolve8(config22.defaultValue);
12354
12685
  } else {
12355
12686
  reject(new EmptyError);
12356
12687
  }
@@ -13402,7 +13733,7 @@ var init_rxjs = __esm(() => {
13402
13733
  Observable2.prototype.forEach = function(next, promiseCtor) {
13403
13734
  var _this = this;
13404
13735
  promiseCtor = getPromiseCtor(promiseCtor);
13405
- return new promiseCtor(function(resolve9, reject) {
13736
+ return new promiseCtor(function(resolve8, reject) {
13406
13737
  var subscriber = new SafeSubscriber({
13407
13738
  next: function(value) {
13408
13739
  try {
@@ -13413,7 +13744,7 @@ var init_rxjs = __esm(() => {
13413
13744
  }
13414
13745
  },
13415
13746
  error: reject,
13416
- complete: resolve9
13747
+ complete: resolve8
13417
13748
  });
13418
13749
  _this.subscribe(subscriber);
13419
13750
  });
@@ -13435,14 +13766,14 @@ var init_rxjs = __esm(() => {
13435
13766
  Observable2.prototype.toPromise = function(promiseCtor) {
13436
13767
  var _this = this;
13437
13768
  promiseCtor = getPromiseCtor(promiseCtor);
13438
- return new promiseCtor(function(resolve9, reject) {
13769
+ return new promiseCtor(function(resolve8, reject) {
13439
13770
  var value;
13440
13771
  _this.subscribe(function(x) {
13441
13772
  return value = x;
13442
13773
  }, function(err) {
13443
13774
  return reject(err);
13444
13775
  }, function() {
13445
- return resolve9(value);
13776
+ return resolve8(value);
13446
13777
  });
13447
13778
  });
13448
13779
  };
@@ -15368,8 +15699,8 @@ class Deferred {
15368
15699
  #isRejected = false;
15369
15700
  #value;
15370
15701
  #resolve;
15371
- #taskPromise = new Promise((resolve9) => {
15372
- this.#resolve = resolve9;
15702
+ #taskPromise = new Promise((resolve8) => {
15703
+ this.#resolve = resolve8;
15373
15704
  });
15374
15705
  #timeoutId;
15375
15706
  #timeoutError;
@@ -15458,12 +15789,12 @@ var init_Mutex = __esm(() => {
15458
15789
  return new Mutex.Guard(this, onRelease);
15459
15790
  }
15460
15791
  release() {
15461
- const resolve9 = this.#acquirers.shift();
15462
- if (!resolve9) {
15792
+ const resolve8 = this.#acquirers.shift();
15793
+ if (!resolve8) {
15463
15794
  this.#locked = false;
15464
15795
  return;
15465
15796
  }
15466
- resolve9();
15797
+ resolve8();
15467
15798
  }
15468
15799
  };
15469
15800
  });
@@ -17207,12 +17538,12 @@ var init_locators = __esm(() => {
17207
17538
  }
17208
17539
  return defer(() => {
17209
17540
  return from(handle.evaluate((element) => {
17210
- return new Promise((resolve9) => {
17541
+ return new Promise((resolve8) => {
17211
17542
  window.requestAnimationFrame(() => {
17212
17543
  const rect1 = element.getBoundingClientRect();
17213
17544
  window.requestAnimationFrame(() => {
17214
17545
  const rect2 = element.getBoundingClientRect();
17215
- resolve9([
17546
+ resolve8([
17216
17547
  {
17217
17548
  x: rect1.x,
17218
17549
  y: rect1.y,
@@ -18503,9 +18834,9 @@ var init_ElementHandle = __esm(() => {
18503
18834
  const handle = await this.#asSVGElementHandle();
18504
18835
  const target = __addDisposableResource6(env_5, handle && await handle.#getOwnerSVGElement(), false);
18505
18836
  return await (target ?? this).evaluate(async (element, threshold) => {
18506
- const visibleRatio = await new Promise((resolve9) => {
18837
+ const visibleRatio = await new Promise((resolve8) => {
18507
18838
  const observer = new IntersectionObserver((entries) => {
18508
- resolve9(entries[0].intersectionRatio);
18839
+ resolve8(entries[0].intersectionRatio);
18509
18840
  observer.disconnect();
18510
18841
  });
18511
18842
  observer.observe(element);
@@ -18899,7 +19230,7 @@ var init_Frame = __esm(() => {
18899
19230
  }
18900
19231
  type = type ?? "text/javascript";
18901
19232
  return await this.mainRealm().transferHandle(await this.isolatedRealm().evaluateHandle(async ({ url, id, type: type2, content: content2 }) => {
18902
- return await new Promise((resolve9, reject) => {
19233
+ return await new Promise((resolve8, reject) => {
18903
19234
  const script = document.createElement("script");
18904
19235
  script.type = type2;
18905
19236
  script.text = content2;
@@ -18912,12 +19243,12 @@ var init_Frame = __esm(() => {
18912
19243
  if (url) {
18913
19244
  script.src = url;
18914
19245
  script.addEventListener("load", () => {
18915
- resolve9(script);
19246
+ resolve8(script);
18916
19247
  }, { once: true });
18917
19248
  document.head.appendChild(script);
18918
19249
  } else {
18919
19250
  document.head.appendChild(script);
18920
- resolve9(script);
19251
+ resolve8(script);
18921
19252
  }
18922
19253
  });
18923
19254
  }, { ...options, type, content }));
@@ -18934,7 +19265,7 @@ var init_Frame = __esm(() => {
18934
19265
  options.content = content;
18935
19266
  }
18936
19267
  return await this.mainRealm().transferHandle(await this.isolatedRealm().evaluateHandle(async ({ url, content: content2 }) => {
18937
- return await new Promise((resolve9, reject) => {
19268
+ return await new Promise((resolve8, reject) => {
18938
19269
  let element;
18939
19270
  if (!url) {
18940
19271
  element = document.createElement("style");
@@ -18946,7 +19277,7 @@ var init_Frame = __esm(() => {
18946
19277
  element = link;
18947
19278
  }
18948
19279
  element.addEventListener("load", () => {
18949
- resolve9(element);
19280
+ resolve8(element);
18950
19281
  }, { once: true });
18951
19282
  element.addEventListener("error", (event) => {
18952
19283
  reject(new Error(event.message ?? "Could not load style"));
@@ -19800,9 +20131,9 @@ var init_Page = __esm(() => {
19800
20131
  ++this.#screencastSessionCount;
19801
20132
  if (!this.#startScreencastPromise) {
19802
20133
  this.#startScreencastPromise = this.mainFrame().client.send("Page.startScreencast", { format: "png" }).then(() => {
19803
- return new Promise((resolve9) => {
20134
+ return new Promise((resolve8) => {
19804
20135
  return this.mainFrame().client.once("Page.screencastFrame", () => {
19805
- return resolve9();
20136
+ return resolve8();
19806
20137
  });
19807
20138
  });
19808
20139
  });
@@ -22460,11 +22791,11 @@ function addPageBinding(type, name, prefix) {
22460
22791
  return value instanceof Node;
22461
22792
  })
22462
22793
  }));
22463
- return new Promise((resolve9, reject) => {
22794
+ return new Promise((resolve8, reject) => {
22464
22795
  callPuppeteer.callbacks.set(seq, {
22465
22796
  resolve(value) {
22466
22797
  callPuppeteer.args.delete(seq);
22467
- resolve9(value);
22798
+ resolve8(value);
22468
22799
  },
22469
22800
  reject(value) {
22470
22801
  callPuppeteer.args.delete(seq);
@@ -25927,8 +26258,8 @@ var init_Input2 = __esm(() => {
25927
26258
  if (typeof delay === "number") {
25928
26259
  await Promise.all(actions);
25929
26260
  actions.length = 0;
25930
- await new Promise((resolve9) => {
25931
- setTimeout(resolve9, delay);
26261
+ await new Promise((resolve8) => {
26262
+ setTimeout(resolve8, delay);
25932
26263
  });
25933
26264
  }
25934
26265
  actions.push(this.up({ ...options, clickCount }));
@@ -25948,9 +26279,9 @@ var init_Input2 = __esm(() => {
25948
26279
  });
25949
26280
  }
25950
26281
  async drag(start, target) {
25951
- const promise = new Promise((resolve9) => {
26282
+ const promise = new Promise((resolve8) => {
25952
26283
  this.#client.once("Input.dragIntercepted", (event) => {
25953
- return resolve9(event.data);
26284
+ return resolve8(event.data);
25954
26285
  });
25955
26286
  });
25956
26287
  await this.move(start.x, start.y);
@@ -25991,8 +26322,8 @@ var init_Input2 = __esm(() => {
25991
26322
  await this.dragEnter(target, data);
25992
26323
  await this.dragOver(target, data);
25993
26324
  if (delay) {
25994
- await new Promise((resolve9) => {
25995
- return setTimeout(resolve9, delay);
26325
+ await new Promise((resolve8) => {
26326
+ return setTimeout(resolve8, delay);
25996
26327
  });
25997
26328
  }
25998
26329
  await this.drop(target, data);
@@ -26804,9 +27135,9 @@ var init_Page2 = __esm(() => {
26804
27135
  async captureHeapSnapshot(options) {
26805
27136
  const { createWriteStream } = environment.value.fs;
26806
27137
  const stream = createWriteStream(options.path);
26807
- const streamPromise = new Promise((resolve9, reject) => {
27138
+ const streamPromise = new Promise((resolve8, reject) => {
26808
27139
  stream.on("error", reject);
26809
- stream.on("finish", resolve9);
27140
+ stream.on("finish", resolve8);
26810
27141
  });
26811
27142
  const client = this.#primaryTargetClient;
26812
27143
  await client.send("HeapProfiler.enable");
@@ -28319,10 +28650,10 @@ __export(exports_BrowserWebSocketTransport, {
28319
28650
 
28320
28651
  class BrowserWebSocketTransport {
28321
28652
  static create(url) {
28322
- return new Promise((resolve9, reject) => {
28653
+ return new Promise((resolve8, reject) => {
28323
28654
  const ws = new WebSocket(url);
28324
28655
  ws.addEventListener("open", () => {
28325
- return resolve9(new BrowserWebSocketTransport(ws));
28656
+ return resolve8(new BrowserWebSocketTransport(ws));
28326
28657
  });
28327
28658
  ws.addEventListener("error", reject);
28328
28659
  });
@@ -31156,11 +31487,11 @@ var require_BrowsingContextProcessor = __commonJS((exports) => {
31156
31487
  }
31157
31488
  const parentCdpClient = context2.cdpTarget.parentCdpClient;
31158
31489
  try {
31159
- const detachedFromTargetPromise = new Promise((resolve9) => {
31490
+ const detachedFromTargetPromise = new Promise((resolve8) => {
31160
31491
  const onContextDestroyed = (event) => {
31161
31492
  if (event.targetId === params.context) {
31162
31493
  parentCdpClient.off("Target.detachedFromTarget", onContextDestroyed);
31163
- resolve9();
31494
+ resolve8();
31164
31495
  }
31165
31496
  };
31166
31497
  parentCdpClient.on("Target.detachedFromTarget", onContextDestroyed);
@@ -32480,7 +32811,7 @@ var require_ActionDispatcher = __commonJS((exports) => {
32480
32811
  }
32481
32812
  }
32482
32813
  const promises = [
32483
- new Promise((resolve9) => setTimeout(resolve9, this.#tickDuration))
32814
+ new Promise((resolve8) => setTimeout(resolve8, this.#tickDuration))
32484
32815
  ];
32485
32816
  for (const option of options) {
32486
32817
  promises.push(this.#dispatchAction(option));
@@ -33079,8 +33410,8 @@ var require_Mutex = __commonJS((exports) => {
33079
33410
  acquire() {
33080
33411
  const state = { resolved: false };
33081
33412
  if (this.#locked) {
33082
- return new Promise((resolve9) => {
33083
- this.#acquirers.push(() => resolve9(this.#release.bind(this, state)));
33413
+ return new Promise((resolve8) => {
33414
+ this.#acquirers.push(() => resolve8(this.#release.bind(this, state)));
33084
33415
  });
33085
33416
  }
33086
33417
  this.#locked = true;
@@ -33091,12 +33422,12 @@ var require_Mutex = __commonJS((exports) => {
33091
33422
  throw new Error("Cannot release more than once.");
33092
33423
  }
33093
33424
  state.resolved = true;
33094
- const resolve9 = this.#acquirers.shift();
33095
- if (!resolve9) {
33425
+ const resolve8 = this.#acquirers.shift();
33426
+ if (!resolve8) {
33096
33427
  this.#locked = false;
33097
33428
  return;
33098
33429
  }
33099
- resolve9();
33430
+ resolve8();
33100
33431
  }
33101
33432
  async run(action) {
33102
33433
  const release = await this.acquire();
@@ -34223,8 +34554,8 @@ var require_ChannelProxy = __commonJS((exports) => {
34223
34554
  let queueNonEmptyResolver = null;
34224
34555
  return {
34225
34556
  async getMessage() {
34226
- const onMessage = queue.length > 0 ? Promise.resolve() : new Promise((resolve9) => {
34227
- queueNonEmptyResolver = resolve9;
34557
+ const onMessage = queue.length > 0 ? Promise.resolve() : new Promise((resolve8) => {
34558
+ queueNonEmptyResolver = resolve8;
34228
34559
  });
34229
34560
  await onMessage;
34230
34561
  return queue.shift();
@@ -34310,7 +34641,7 @@ var require_ChannelProxy = __commonJS((exports) => {
34310
34641
  functionDeclaration: String((id) => {
34311
34642
  const w = window;
34312
34643
  if (w[id] === undefined) {
34313
- return new Promise((resolve9) => w[id] = resolve9);
34644
+ return new Promise((resolve8) => w[id] = resolve8);
34314
34645
  }
34315
34646
  const channelProxy = w[id];
34316
34647
  delete w[id];
@@ -35661,8 +35992,8 @@ var require_Deferred = __commonJS((exports) => {
35661
35992
  return this.#result;
35662
35993
  }
35663
35994
  constructor() {
35664
- this.#promise = new Promise((resolve9, reject) => {
35665
- this.#resolve = resolve9;
35995
+ this.#promise = new Promise((resolve8, reject) => {
35996
+ this.#resolve = resolve8;
35666
35997
  this.#reject = reject;
35667
35998
  });
35668
35999
  this.#promise.catch((_error) => {});
@@ -39987,11 +40318,11 @@ var require_BrowsingContextStorage = __commonJS((exports) => {
39987
40318
  if (this.#contexts.has(browsingContextId)) {
39988
40319
  return Promise.resolve(this.getContext(browsingContextId));
39989
40320
  }
39990
- return new Promise((resolve9) => {
40321
+ return new Promise((resolve8) => {
39991
40322
  const listener = (event) => {
39992
40323
  if (event.browsingContext.id === browsingContextId) {
39993
40324
  this.#eventEmitter.off("added", listener);
39994
- resolve9(event.browsingContext);
40325
+ resolve8(event.browsingContext);
39995
40326
  }
39996
40327
  };
39997
40328
  this.#eventEmitter.on("added", listener);
@@ -43487,8 +43818,8 @@ var init_ExposedFunction = __esm(() => {
43487
43818
  const functionDeclaration = stringifyFunction(interpolateFunction((callback) => {
43488
43819
  Object.assign(globalThis, {
43489
43820
  [PLACEHOLDER("name")]: function(...args) {
43490
- return new Promise((resolve9, reject) => {
43491
- callback([resolve9, reject, args]);
43821
+ return new Promise((resolve8, reject) => {
43822
+ callback([resolve8, reject, args]);
43492
43823
  });
43493
43824
  }
43494
43825
  });
@@ -43576,8 +43907,8 @@ var init_ExposedFunction = __esm(() => {
43576
43907
  return;
43577
43908
  }
43578
43909
  try {
43579
- await dataHandle.evaluate(([resolve9], result2) => {
43580
- resolve9(result2);
43910
+ await dataHandle.evaluate(([resolve8], result2) => {
43911
+ resolve8(result2);
43581
43912
  }, result);
43582
43913
  } catch (error) {
43583
43914
  debugError(error);
@@ -48004,7 +48335,7 @@ import NodeWebSocket from "ws";
48004
48335
 
48005
48336
  class NodeWebSocketTransport {
48006
48337
  static create(url, headers) {
48007
- return new Promise((resolve9, reject) => {
48338
+ return new Promise((resolve8, reject) => {
48008
48339
  const ws = new NodeWebSocket(url, [], {
48009
48340
  followRedirects: true,
48010
48341
  perMessageDeflate: false,
@@ -48016,7 +48347,7 @@ class NodeWebSocketTransport {
48016
48347
  }
48017
48348
  });
48018
48349
  ws.addEventListener("open", () => {
48019
- return resolve9(new NodeWebSocketTransport(ws));
48350
+ return resolve8(new NodeWebSocketTransport(ws));
48020
48351
  });
48021
48352
  ws.addEventListener("error", reject);
48022
48353
  });
@@ -50906,8 +51237,8 @@ var require_helpers = __commonJS((exports) => {
50906
51237
  function req(url, opts = {}) {
50907
51238
  const href = typeof url === "string" ? url : url.href;
50908
51239
  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();
51240
+ const promise = new Promise((resolve8, reject) => {
51241
+ req2.once("response", resolve8).once("error", reject).end();
50911
51242
  });
50912
51243
  req2.then = promise.then.bind(promise);
50913
51244
  return req2;
@@ -51278,7 +51609,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
51278
51609
  var debug_1 = __importDefault(require_src());
51279
51610
  var debug2 = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
51280
51611
  function parseProxyResponse(socket) {
51281
- return new Promise((resolve9, reject) => {
51612
+ return new Promise((resolve8, reject) => {
51282
51613
  let buffersLength = 0;
51283
51614
  const buffers = [];
51284
51615
  function read() {
@@ -51347,7 +51678,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
51347
51678
  }
51348
51679
  debug2("got proxy server response: %o %o", firstLine, headers);
51349
51680
  cleanup();
51350
- resolve9({
51681
+ resolve8({
51351
51682
  connect: {
51352
51683
  statusCode,
51353
51684
  statusText,
@@ -53451,11 +53782,11 @@ var require_receivebuffer = __commonJS((exports) => {
53451
53782
  var require_socksclient = __commonJS((exports) => {
53452
53783
  var __awaiter2 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
53453
53784
  function adopt(value) {
53454
- return value instanceof P ? value : new P(function(resolve9) {
53455
- resolve9(value);
53785
+ return value instanceof P ? value : new P(function(resolve8) {
53786
+ resolve8(value);
53456
53787
  });
53457
53788
  }
53458
- return new (P || (P = Promise))(function(resolve9, reject) {
53789
+ return new (P || (P = Promise))(function(resolve8, reject) {
53459
53790
  function fulfilled(value) {
53460
53791
  try {
53461
53792
  step(generator.next(value));
@@ -53471,7 +53802,7 @@ var require_socksclient = __commonJS((exports) => {
53471
53802
  }
53472
53803
  }
53473
53804
  function step(result) {
53474
- result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
53805
+ result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
53475
53806
  }
53476
53807
  step((generator = generator.apply(thisArg, _arguments || [])).next());
53477
53808
  });
@@ -53498,13 +53829,13 @@ var require_socksclient = __commonJS((exports) => {
53498
53829
  this.setState(constants_1.SocksClientState.Created);
53499
53830
  }
53500
53831
  static createConnection(options, callback) {
53501
- return new Promise((resolve9, reject) => {
53832
+ return new Promise((resolve8, reject) => {
53502
53833
  try {
53503
53834
  (0, helpers_1.validateSocksClientOptions)(options, ["connect"]);
53504
53835
  } catch (err) {
53505
53836
  if (typeof callback === "function") {
53506
53837
  callback(err);
53507
- return resolve9(err);
53838
+ return resolve8(err);
53508
53839
  } else {
53509
53840
  return reject(err);
53510
53841
  }
@@ -53515,16 +53846,16 @@ var require_socksclient = __commonJS((exports) => {
53515
53846
  client.removeAllListeners();
53516
53847
  if (typeof callback === "function") {
53517
53848
  callback(null, info);
53518
- resolve9(info);
53849
+ resolve8(info);
53519
53850
  } else {
53520
- resolve9(info);
53851
+ resolve8(info);
53521
53852
  }
53522
53853
  });
53523
53854
  client.once("error", (err) => {
53524
53855
  client.removeAllListeners();
53525
53856
  if (typeof callback === "function") {
53526
53857
  callback(err);
53527
- resolve9(err);
53858
+ resolve8(err);
53528
53859
  } else {
53529
53860
  reject(err);
53530
53861
  }
@@ -53532,13 +53863,13 @@ var require_socksclient = __commonJS((exports) => {
53532
53863
  });
53533
53864
  }
53534
53865
  static createConnectionChain(options, callback) {
53535
- return new Promise((resolve9, reject) => __awaiter2(this, undefined, undefined, function* () {
53866
+ return new Promise((resolve8, reject) => __awaiter2(this, undefined, undefined, function* () {
53536
53867
  try {
53537
53868
  (0, helpers_1.validateSocksClientChainOptions)(options);
53538
53869
  } catch (err) {
53539
53870
  if (typeof callback === "function") {
53540
53871
  callback(err);
53541
- return resolve9(err);
53872
+ return resolve8(err);
53542
53873
  } else {
53543
53874
  return reject(err);
53544
53875
  }
@@ -53564,14 +53895,14 @@ var require_socksclient = __commonJS((exports) => {
53564
53895
  }
53565
53896
  if (typeof callback === "function") {
53566
53897
  callback(null, { socket: sock });
53567
- resolve9({ socket: sock });
53898
+ resolve8({ socket: sock });
53568
53899
  } else {
53569
- resolve9({ socket: sock });
53900
+ resolve8({ socket: sock });
53570
53901
  }
53571
53902
  } catch (err) {
53572
53903
  if (typeof callback === "function") {
53573
53904
  callback(err);
53574
- resolve9(err);
53905
+ resolve8(err);
53575
53906
  } else {
53576
53907
  reject(err);
53577
53908
  }
@@ -54171,12 +54502,12 @@ var require_dist4 = __commonJS((exports) => {
54171
54502
  let { host } = opts;
54172
54503
  const { port, lookup: lookupFn = dns.lookup } = opts;
54173
54504
  if (shouldLookup) {
54174
- host = await new Promise((resolve9, reject) => {
54505
+ host = await new Promise((resolve8, reject) => {
54175
54506
  lookupFn(host, {}, (err, res) => {
54176
54507
  if (err) {
54177
54508
  reject(err);
54178
54509
  } else {
54179
- resolve9(res);
54510
+ resolve8(res);
54180
54511
  }
54181
54512
  });
54182
54513
  });
@@ -55183,7 +55514,7 @@ var require_netUtils = __commonJS((exports) => {
55183
55514
  return `${socket.remoteAddress}:${socket.remotePort}`;
55184
55515
  }
55185
55516
  function upgradeSocket(socket, options) {
55186
- return new Promise((resolve9, reject) => {
55517
+ return new Promise((resolve8, reject) => {
55187
55518
  const tlsOptions = Object.assign({}, options, {
55188
55519
  socket
55189
55520
  });
@@ -55193,7 +55524,7 @@ var require_netUtils = __commonJS((exports) => {
55193
55524
  reject(tlsSocket.authorizationError);
55194
55525
  } else {
55195
55526
  tlsSocket.removeAllListeners("error");
55196
- resolve9(tlsSocket);
55527
+ resolve8(tlsSocket);
55197
55528
  }
55198
55529
  }).once("error", (error) => {
55199
55530
  reject(error);
@@ -55285,7 +55616,7 @@ var require_transfer = __commonJS((exports) => {
55285
55616
  };
55286
55617
  }
55287
55618
  function connectForPassiveTransfer(host, port, ftp) {
55288
- return new Promise((resolve9, reject) => {
55619
+ return new Promise((resolve8, reject) => {
55289
55620
  let socket = ftp._newSocket();
55290
55621
  const handleConnErr = function(err) {
55291
55622
  err.message = "Can't open data connection in passive mode: " + err.message;
@@ -55308,7 +55639,7 @@ var require_transfer = __commonJS((exports) => {
55308
55639
  socket.removeListener("error", handleConnErr);
55309
55640
  socket.removeListener("timeout", handleTimeout);
55310
55641
  ftp.dataSocket = socket;
55311
- resolve9();
55642
+ resolve8();
55312
55643
  });
55313
55644
  });
55314
55645
  }
@@ -57386,7 +57717,7 @@ var require_util2 = __commonJS((exports) => {
57386
57717
  return path;
57387
57718
  }
57388
57719
  exports.normalize = normalize2;
57389
- function join31(aRoot, aPath) {
57720
+ function join29(aRoot, aPath) {
57390
57721
  if (aRoot === "") {
57391
57722
  aRoot = ".";
57392
57723
  }
@@ -57418,7 +57749,7 @@ var require_util2 = __commonJS((exports) => {
57418
57749
  }
57419
57750
  return joined;
57420
57751
  }
57421
- exports.join = join31;
57752
+ exports.join = join29;
57422
57753
  exports.isAbsolute = function(aPath) {
57423
57754
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
57424
57755
  };
@@ -57591,7 +57922,7 @@ var require_util2 = __commonJS((exports) => {
57591
57922
  parsed.path = parsed.path.substring(0, index + 1);
57592
57923
  }
57593
57924
  }
57594
- sourceURL = join31(urlGenerate(parsed), sourceURL);
57925
+ sourceURL = join29(urlGenerate(parsed), sourceURL);
57595
57926
  }
57596
57927
  return normalize2(sourceURL);
57597
57928
  }
@@ -59323,7 +59654,7 @@ var require_escodegen = __commonJS((exports) => {
59323
59654
  function noEmptySpace() {
59324
59655
  return space ? space : " ";
59325
59656
  }
59326
- function join31(left, right) {
59657
+ function join29(left, right) {
59327
59658
  var leftSource, rightSource, leftCharCode, rightCharCode;
59328
59659
  leftSource = toSourceNodeWhenNeeded(left).toString();
59329
59660
  if (leftSource.length === 0) {
@@ -59664,8 +59995,8 @@ var require_escodegen = __commonJS((exports) => {
59664
59995
  } else {
59665
59996
  result.push(that.generateExpression(stmt.left, Precedence.Call, E_TTT));
59666
59997
  }
59667
- result = join31(result, operator);
59668
- result = [join31(result, that.generateExpression(stmt.right, Precedence.Assignment, E_TTT)), ")"];
59998
+ result = join29(result, operator);
59999
+ result = [join29(result, that.generateExpression(stmt.right, Precedence.Assignment, E_TTT)), ")"];
59669
60000
  });
59670
60001
  result.push(this.maybeBlock(stmt.body, flags));
59671
60002
  return result;
@@ -59803,11 +60134,11 @@ var require_escodegen = __commonJS((exports) => {
59803
60134
  var result, fragment;
59804
60135
  result = ["class"];
59805
60136
  if (stmt.id) {
59806
- result = join31(result, this.generateExpression(stmt.id, Precedence.Sequence, E_TTT));
60137
+ result = join29(result, this.generateExpression(stmt.id, Precedence.Sequence, E_TTT));
59807
60138
  }
59808
60139
  if (stmt.superClass) {
59809
- fragment = join31("extends", this.generateExpression(stmt.superClass, Precedence.Unary, E_TTT));
59810
- result = join31(result, fragment);
60140
+ fragment = join29("extends", this.generateExpression(stmt.superClass, Precedence.Unary, E_TTT));
60141
+ result = join29(result, fragment);
59811
60142
  }
59812
60143
  result.push(space);
59813
60144
  result.push(this.generateStatement(stmt.body, S_TFFT));
@@ -59820,9 +60151,9 @@ var require_escodegen = __commonJS((exports) => {
59820
60151
  return escapeDirective(stmt.directive) + this.semicolon(flags);
59821
60152
  },
59822
60153
  DoWhileStatement: function(stmt, flags) {
59823
- var result = join31("do", this.maybeBlock(stmt.body, S_TFFF));
60154
+ var result = join29("do", this.maybeBlock(stmt.body, S_TFFF));
59824
60155
  result = this.maybeBlockSuffix(stmt.body, result);
59825
- return join31(result, [
60156
+ return join29(result, [
59826
60157
  "while" + space + "(",
59827
60158
  this.generateExpression(stmt.test, Precedence.Sequence, E_TTT),
59828
60159
  ")" + this.semicolon(flags)
@@ -59858,11 +60189,11 @@ var require_escodegen = __commonJS((exports) => {
59858
60189
  ExportDefaultDeclaration: function(stmt, flags) {
59859
60190
  var result = ["export"], bodyFlags;
59860
60191
  bodyFlags = flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF;
59861
- result = join31(result, "default");
60192
+ result = join29(result, "default");
59862
60193
  if (isStatement(stmt.declaration)) {
59863
- result = join31(result, this.generateStatement(stmt.declaration, bodyFlags));
60194
+ result = join29(result, this.generateStatement(stmt.declaration, bodyFlags));
59864
60195
  } else {
59865
- result = join31(result, this.generateExpression(stmt.declaration, Precedence.Assignment, E_TTT) + this.semicolon(flags));
60196
+ result = join29(result, this.generateExpression(stmt.declaration, Precedence.Assignment, E_TTT) + this.semicolon(flags));
59866
60197
  }
59867
60198
  return result;
59868
60199
  },
@@ -59870,15 +60201,15 @@ var require_escodegen = __commonJS((exports) => {
59870
60201
  var result = ["export"], bodyFlags, that = this;
59871
60202
  bodyFlags = flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF;
59872
60203
  if (stmt.declaration) {
59873
- return join31(result, this.generateStatement(stmt.declaration, bodyFlags));
60204
+ return join29(result, this.generateStatement(stmt.declaration, bodyFlags));
59874
60205
  }
59875
60206
  if (stmt.specifiers) {
59876
60207
  if (stmt.specifiers.length === 0) {
59877
- result = join31(result, "{" + space + "}");
60208
+ result = join29(result, "{" + space + "}");
59878
60209
  } else if (stmt.specifiers[0].type === Syntax.ExportBatchSpecifier) {
59879
- result = join31(result, this.generateExpression(stmt.specifiers[0], Precedence.Sequence, E_TTT));
60210
+ result = join29(result, this.generateExpression(stmt.specifiers[0], Precedence.Sequence, E_TTT));
59880
60211
  } else {
59881
- result = join31(result, "{");
60212
+ result = join29(result, "{");
59882
60213
  withIndent(function(indent2) {
59883
60214
  var i, iz;
59884
60215
  result.push(newline);
@@ -59896,7 +60227,7 @@ var require_escodegen = __commonJS((exports) => {
59896
60227
  result.push(base + "}");
59897
60228
  }
59898
60229
  if (stmt.source) {
59899
- result = join31(result, [
60230
+ result = join29(result, [
59900
60231
  "from" + space,
59901
60232
  this.generateExpression(stmt.source, Precedence.Sequence, E_TTT),
59902
60233
  this.semicolon(flags)
@@ -59980,7 +60311,7 @@ var require_escodegen = __commonJS((exports) => {
59980
60311
  ];
59981
60312
  cursor = 0;
59982
60313
  if (stmt.specifiers[cursor].type === Syntax.ImportDefaultSpecifier) {
59983
- result = join31(result, [
60314
+ result = join29(result, [
59984
60315
  this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)
59985
60316
  ]);
59986
60317
  ++cursor;
@@ -59990,7 +60321,7 @@ var require_escodegen = __commonJS((exports) => {
59990
60321
  result.push(",");
59991
60322
  }
59992
60323
  if (stmt.specifiers[cursor].type === Syntax.ImportNamespaceSpecifier) {
59993
- result = join31(result, [
60324
+ result = join29(result, [
59994
60325
  space,
59995
60326
  this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)
59996
60327
  ]);
@@ -60019,7 +60350,7 @@ var require_escodegen = __commonJS((exports) => {
60019
60350
  }
60020
60351
  }
60021
60352
  }
60022
- result = join31(result, [
60353
+ result = join29(result, [
60023
60354
  "from" + space,
60024
60355
  this.generateExpression(stmt.source, Precedence.Sequence, E_TTT),
60025
60356
  this.semicolon(flags)
@@ -60073,7 +60404,7 @@ var require_escodegen = __commonJS((exports) => {
60073
60404
  return result;
60074
60405
  },
60075
60406
  ThrowStatement: function(stmt, flags) {
60076
- return [join31("throw", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
60407
+ return [join29("throw", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
60077
60408
  },
60078
60409
  TryStatement: function(stmt, flags) {
60079
60410
  var result, i, iz, guardedHandlers;
@@ -60081,7 +60412,7 @@ var require_escodegen = __commonJS((exports) => {
60081
60412
  result = this.maybeBlockSuffix(stmt.block, result);
60082
60413
  if (stmt.handlers) {
60083
60414
  for (i = 0, iz = stmt.handlers.length;i < iz; ++i) {
60084
- result = join31(result, this.generateStatement(stmt.handlers[i], S_TFFF));
60415
+ result = join29(result, this.generateStatement(stmt.handlers[i], S_TFFF));
60085
60416
  if (stmt.finalizer || i + 1 !== iz) {
60086
60417
  result = this.maybeBlockSuffix(stmt.handlers[i].body, result);
60087
60418
  }
@@ -60089,7 +60420,7 @@ var require_escodegen = __commonJS((exports) => {
60089
60420
  } else {
60090
60421
  guardedHandlers = stmt.guardedHandlers || [];
60091
60422
  for (i = 0, iz = guardedHandlers.length;i < iz; ++i) {
60092
- result = join31(result, this.generateStatement(guardedHandlers[i], S_TFFF));
60423
+ result = join29(result, this.generateStatement(guardedHandlers[i], S_TFFF));
60093
60424
  if (stmt.finalizer || i + 1 !== iz) {
60094
60425
  result = this.maybeBlockSuffix(guardedHandlers[i].body, result);
60095
60426
  }
@@ -60097,13 +60428,13 @@ var require_escodegen = __commonJS((exports) => {
60097
60428
  if (stmt.handler) {
60098
60429
  if (Array.isArray(stmt.handler)) {
60099
60430
  for (i = 0, iz = stmt.handler.length;i < iz; ++i) {
60100
- result = join31(result, this.generateStatement(stmt.handler[i], S_TFFF));
60431
+ result = join29(result, this.generateStatement(stmt.handler[i], S_TFFF));
60101
60432
  if (stmt.finalizer || i + 1 !== iz) {
60102
60433
  result = this.maybeBlockSuffix(stmt.handler[i].body, result);
60103
60434
  }
60104
60435
  }
60105
60436
  } else {
60106
- result = join31(result, this.generateStatement(stmt.handler, S_TFFF));
60437
+ result = join29(result, this.generateStatement(stmt.handler, S_TFFF));
60107
60438
  if (stmt.finalizer) {
60108
60439
  result = this.maybeBlockSuffix(stmt.handler.body, result);
60109
60440
  }
@@ -60111,7 +60442,7 @@ var require_escodegen = __commonJS((exports) => {
60111
60442
  }
60112
60443
  }
60113
60444
  if (stmt.finalizer) {
60114
- result = join31(result, ["finally", this.maybeBlock(stmt.finalizer, S_TFFF)]);
60445
+ result = join29(result, ["finally", this.maybeBlock(stmt.finalizer, S_TFFF)]);
60115
60446
  }
60116
60447
  return result;
60117
60448
  },
@@ -60145,7 +60476,7 @@ var require_escodegen = __commonJS((exports) => {
60145
60476
  withIndent(function() {
60146
60477
  if (stmt.test) {
60147
60478
  result = [
60148
- join31("case", that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)),
60479
+ join29("case", that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)),
60149
60480
  ":"
60150
60481
  ];
60151
60482
  } else {
@@ -60193,9 +60524,9 @@ var require_escodegen = __commonJS((exports) => {
60193
60524
  result.push(this.maybeBlock(stmt.consequent, S_TFFF));
60194
60525
  result = this.maybeBlockSuffix(stmt.consequent, result);
60195
60526
  if (stmt.alternate.type === Syntax.IfStatement) {
60196
- result = join31(result, ["else ", this.generateStatement(stmt.alternate, bodyFlags)]);
60527
+ result = join29(result, ["else ", this.generateStatement(stmt.alternate, bodyFlags)]);
60197
60528
  } else {
60198
- result = join31(result, join31("else", this.maybeBlock(stmt.alternate, bodyFlags)));
60529
+ result = join29(result, join29("else", this.maybeBlock(stmt.alternate, bodyFlags)));
60199
60530
  }
60200
60531
  } else {
60201
60532
  result.push(this.maybeBlock(stmt.consequent, bodyFlags));
@@ -60297,7 +60628,7 @@ var require_escodegen = __commonJS((exports) => {
60297
60628
  },
60298
60629
  ReturnStatement: function(stmt, flags) {
60299
60630
  if (stmt.argument) {
60300
- return [join31("return", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
60631
+ return [join29("return", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
60301
60632
  }
60302
60633
  return ["return" + this.semicolon(flags)];
60303
60634
  },
@@ -60379,14 +60710,14 @@ var require_escodegen = __commonJS((exports) => {
60379
60710
  if (leftSource.charCodeAt(leftSource.length - 1) === 47 && esutils.code.isIdentifierPartES5(expr.operator.charCodeAt(0))) {
60380
60711
  result = [fragment, noEmptySpace(), expr.operator];
60381
60712
  } else {
60382
- result = join31(fragment, expr.operator);
60713
+ result = join29(fragment, expr.operator);
60383
60714
  }
60384
60715
  fragment = this.generateExpression(expr.right, rightPrecedence, flags);
60385
60716
  if (expr.operator === "/" && fragment.toString().charAt(0) === "/" || expr.operator.slice(-1) === "<" && fragment.toString().slice(0, 3) === "!--") {
60386
60717
  result.push(noEmptySpace());
60387
60718
  result.push(fragment);
60388
60719
  } else {
60389
- result = join31(result, fragment);
60720
+ result = join29(result, fragment);
60390
60721
  }
60391
60722
  if (expr.operator === "in" && !(flags & F_ALLOW_IN)) {
60392
60723
  return ["(", result, ")"];
@@ -60426,7 +60757,7 @@ var require_escodegen = __commonJS((exports) => {
60426
60757
  var result, length, i, iz, itemFlags;
60427
60758
  length = expr["arguments"].length;
60428
60759
  itemFlags = flags & F_ALLOW_UNPARATH_NEW && !parentheses && length === 0 ? E_TFT : E_TFF;
60429
- result = join31("new", this.generateExpression(expr.callee, Precedence.New, itemFlags));
60760
+ result = join29("new", this.generateExpression(expr.callee, Precedence.New, itemFlags));
60430
60761
  if (!(flags & F_ALLOW_UNPARATH_NEW) || parentheses || length > 0) {
60431
60762
  result.push("(");
60432
60763
  for (i = 0, iz = length;i < iz; ++i) {
@@ -60473,11 +60804,11 @@ var require_escodegen = __commonJS((exports) => {
60473
60804
  var result, fragment, rightCharCode, leftSource, leftCharCode;
60474
60805
  fragment = this.generateExpression(expr.argument, Precedence.Unary, E_TTT);
60475
60806
  if (space === "") {
60476
- result = join31(expr.operator, fragment);
60807
+ result = join29(expr.operator, fragment);
60477
60808
  } else {
60478
60809
  result = [expr.operator];
60479
60810
  if (expr.operator.length > 2) {
60480
- result = join31(result, fragment);
60811
+ result = join29(result, fragment);
60481
60812
  } else {
60482
60813
  leftSource = toSourceNodeWhenNeeded(result).toString();
60483
60814
  leftCharCode = leftSource.charCodeAt(leftSource.length - 1);
@@ -60500,12 +60831,12 @@ var require_escodegen = __commonJS((exports) => {
60500
60831
  result = "yield";
60501
60832
  }
60502
60833
  if (expr.argument) {
60503
- result = join31(result, this.generateExpression(expr.argument, Precedence.Yield, E_TTT));
60834
+ result = join29(result, this.generateExpression(expr.argument, Precedence.Yield, E_TTT));
60504
60835
  }
60505
60836
  return parenthesize(result, Precedence.Yield, precedence);
60506
60837
  },
60507
60838
  AwaitExpression: function(expr, precedence, flags) {
60508
- var result = join31(expr.all ? "await*" : "await", this.generateExpression(expr.argument, Precedence.Await, E_TTT));
60839
+ var result = join29(expr.all ? "await*" : "await", this.generateExpression(expr.argument, Precedence.Await, E_TTT));
60509
60840
  return parenthesize(result, Precedence.Await, precedence);
60510
60841
  },
60511
60842
  UpdateExpression: function(expr, precedence, flags) {
@@ -60577,11 +60908,11 @@ var require_escodegen = __commonJS((exports) => {
60577
60908
  var result, fragment;
60578
60909
  result = ["class"];
60579
60910
  if (expr.id) {
60580
- result = join31(result, this.generateExpression(expr.id, Precedence.Sequence, E_TTT));
60911
+ result = join29(result, this.generateExpression(expr.id, Precedence.Sequence, E_TTT));
60581
60912
  }
60582
60913
  if (expr.superClass) {
60583
- fragment = join31("extends", this.generateExpression(expr.superClass, Precedence.Unary, E_TTT));
60584
- result = join31(result, fragment);
60914
+ fragment = join29("extends", this.generateExpression(expr.superClass, Precedence.Unary, E_TTT));
60915
+ result = join29(result, fragment);
60585
60916
  }
60586
60917
  result.push(space);
60587
60918
  result.push(this.generateStatement(expr.body, S_TFFT));
@@ -60596,7 +60927,7 @@ var require_escodegen = __commonJS((exports) => {
60596
60927
  }
60597
60928
  if (expr.kind === "get" || expr.kind === "set") {
60598
60929
  fragment = [
60599
- join31(expr.kind, this.generatePropertyKey(expr.key, expr.computed)),
60930
+ join29(expr.kind, this.generatePropertyKey(expr.key, expr.computed)),
60600
60931
  this.generateFunctionBody(expr.value)
60601
60932
  ];
60602
60933
  } else {
@@ -60606,7 +60937,7 @@ var require_escodegen = __commonJS((exports) => {
60606
60937
  this.generateFunctionBody(expr.value)
60607
60938
  ];
60608
60939
  }
60609
- return join31(result, fragment);
60940
+ return join29(result, fragment);
60610
60941
  },
60611
60942
  Property: function(expr, precedence, flags) {
60612
60943
  if (expr.kind === "get" || expr.kind === "set") {
@@ -60800,7 +61131,7 @@ var require_escodegen = __commonJS((exports) => {
60800
61131
  for (i = 0, iz = expr.blocks.length;i < iz; ++i) {
60801
61132
  fragment = that.generateExpression(expr.blocks[i], Precedence.Sequence, E_TTT);
60802
61133
  if (i > 0 || extra.moz.comprehensionExpressionStartsWithAssignment) {
60803
- result = join31(result, fragment);
61134
+ result = join29(result, fragment);
60804
61135
  } else {
60805
61136
  result.push(fragment);
60806
61137
  }
@@ -60808,13 +61139,13 @@ var require_escodegen = __commonJS((exports) => {
60808
61139
  });
60809
61140
  }
60810
61141
  if (expr.filter) {
60811
- result = join31(result, "if" + space);
61142
+ result = join29(result, "if" + space);
60812
61143
  fragment = this.generateExpression(expr.filter, Precedence.Sequence, E_TTT);
60813
- result = join31(result, ["(", fragment, ")"]);
61144
+ result = join29(result, ["(", fragment, ")"]);
60814
61145
  }
60815
61146
  if (!extra.moz.comprehensionExpressionStartsWithAssignment) {
60816
61147
  fragment = this.generateExpression(expr.body, Precedence.Assignment, E_TTT);
60817
- result = join31(result, fragment);
61148
+ result = join29(result, fragment);
60818
61149
  }
60819
61150
  result.push(expr.type === Syntax.GeneratorExpression ? ")" : "]");
60820
61151
  return result;
@@ -60830,8 +61161,8 @@ var require_escodegen = __commonJS((exports) => {
60830
61161
  } else {
60831
61162
  fragment = this.generateExpression(expr.left, Precedence.Call, E_TTT);
60832
61163
  }
60833
- fragment = join31(fragment, expr.of ? "of" : "in");
60834
- fragment = join31(fragment, this.generateExpression(expr.right, Precedence.Sequence, E_TTT));
61164
+ fragment = join29(fragment, expr.of ? "of" : "in");
61165
+ fragment = join29(fragment, this.generateExpression(expr.right, Precedence.Sequence, E_TTT));
60835
61166
  return ["for" + space + "(", fragment, ")"];
60836
61167
  },
60837
61168
  SpreadElement: function(expr, precedence, flags) {
@@ -67319,11 +67650,11 @@ var require_tslib = __commonJS((exports, module) => {
67319
67650
  };
67320
67651
  __awaiter2 = function(thisArg, _arguments, P, generator) {
67321
67652
  function adopt(value) {
67322
- return value instanceof P ? value : new P(function(resolve9) {
67323
- resolve9(value);
67653
+ return value instanceof P ? value : new P(function(resolve8) {
67654
+ resolve8(value);
67324
67655
  });
67325
67656
  }
67326
- return new (P || (P = Promise))(function(resolve9, reject) {
67657
+ return new (P || (P = Promise))(function(resolve8, reject) {
67327
67658
  function fulfilled(value) {
67328
67659
  try {
67329
67660
  step(generator.next(value));
@@ -67339,7 +67670,7 @@ var require_tslib = __commonJS((exports, module) => {
67339
67670
  }
67340
67671
  }
67341
67672
  function step(result) {
67342
- result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
67673
+ result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
67343
67674
  }
67344
67675
  step((generator = generator.apply(thisArg, _arguments || [])).next());
67345
67676
  });
@@ -67568,14 +67899,14 @@ var require_tslib = __commonJS((exports, module) => {
67568
67899
  }, i);
67569
67900
  function verb(n) {
67570
67901
  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);
67902
+ return new Promise(function(resolve8, reject) {
67903
+ v = o[n](v), settle(resolve8, reject, v.done, v.value);
67573
67904
  });
67574
67905
  };
67575
67906
  }
67576
- function settle(resolve9, reject, d, v) {
67907
+ function settle(resolve8, reject, d, v) {
67577
67908
  Promise.resolve(v).then(function(v2) {
67578
- resolve9({ value: v2, done: d });
67909
+ resolve8({ value: v2, done: d });
67579
67910
  }, reject);
67580
67911
  }
67581
67912
  };
@@ -70814,12 +71145,12 @@ var require_util3 = __commonJS((exports) => {
70814
71145
  exports.isGMT = exports.dnsLookup = undefined;
70815
71146
  var dns_1 = __require("dns");
70816
71147
  function dnsLookup(host, opts) {
70817
- return new Promise((resolve9, reject) => {
71148
+ return new Promise((resolve8, reject) => {
70818
71149
  (0, dns_1.lookup)(host, opts, (err, res) => {
70819
71150
  if (err) {
70820
71151
  reject(err);
70821
71152
  } else {
70822
- resolve9(res);
71153
+ resolve8(res);
70823
71154
  }
70824
71155
  });
70825
71156
  });
@@ -71393,10 +71724,10 @@ var require_myIpAddress = __commonJS((exports) => {
71393
71724
  var ip_1 = require_ip();
71394
71725
  var net_1 = __importDefault(__require("net"));
71395
71726
  async function myIpAddress() {
71396
- return new Promise((resolve9, reject) => {
71727
+ return new Promise((resolve8, reject) => {
71397
71728
  const socket = net_1.default.connect({ host: "8.8.8.8", port: 53 });
71398
71729
  const onError = () => {
71399
- resolve9(ip_1.ip.address());
71730
+ resolve8(ip_1.ip.address());
71400
71731
  };
71401
71732
  socket.once("error", onError);
71402
71733
  socket.once("connect", () => {
@@ -71404,9 +71735,9 @@ var require_myIpAddress = __commonJS((exports) => {
71404
71735
  const addr = socket.address();
71405
71736
  socket.destroy();
71406
71737
  if (typeof addr === "string") {
71407
- resolve9(addr);
71738
+ resolve8(addr);
71408
71739
  } else if (addr.address) {
71409
- resolve9(addr.address);
71740
+ resolve8(addr.address);
71410
71741
  } else {
71411
71742
  reject(new Error("Expected a `string`"));
71412
71743
  }
@@ -71920,8 +72251,8 @@ var require_deferred_promise = __commonJS((exports) => {
71920
72251
  this.context = args.context;
71921
72252
  this.owner = args.context.runtime;
71922
72253
  this.handle = args.promiseHandle;
71923
- this.settled = new Promise((resolve9) => {
71924
- this.onSettled = resolve9;
72254
+ this.settled = new Promise((resolve8) => {
72255
+ this.onSettled = resolve8;
71925
72256
  });
71926
72257
  this.resolveHandle = args.resolveHandle;
71927
72258
  this.rejectHandle = args.rejectHandle;
@@ -72313,13 +72644,13 @@ var require_context = __commonJS((exports) => {
72313
72644
  if (vmResolveResult.error) {
72314
72645
  return Promise.resolve(vmResolveResult);
72315
72646
  }
72316
- return new Promise((resolve9) => {
72647
+ return new Promise((resolve8) => {
72317
72648
  lifetime_1.Scope.withScope((scope) => {
72318
72649
  const resolveHandle = scope.manage(this.newFunction("resolve", (value) => {
72319
- resolve9({ value: value && value.dup() });
72650
+ resolve8({ value: value && value.dup() });
72320
72651
  }));
72321
72652
  const rejectHandle = scope.manage(this.newFunction("reject", (error) => {
72322
- resolve9({ error: error && error.dup() });
72653
+ resolve8({ error: error && error.dup() });
72323
72654
  }));
72324
72655
  const promiseHandle = scope.manage(vmResolveResult.value);
72325
72656
  const promiseThenHandle = scope.manage(this.getProp(promiseHandle, "then"));
@@ -74151,7 +74482,7 @@ var require_dist10 = __commonJS((exports) => {
74151
74482
  exports.PacProxyAgent = undefined;
74152
74483
  var net = __importStar(__require("net"));
74153
74484
  var tls = __importStar(__require("tls"));
74154
- var crypto = __importStar(__require("crypto"));
74485
+ var crypto2 = __importStar(__require("crypto"));
74155
74486
  var events_1 = __require("events");
74156
74487
  var debug_1 = __importDefault(require_src());
74157
74488
  var url_1 = __require("url");
@@ -74201,7 +74532,7 @@ var require_dist10 = __commonJS((exports) => {
74201
74532
  (0, quickjs_emscripten_1.getQuickJS)(),
74202
74533
  this.loadPacFile()
74203
74534
  ]);
74204
- const hash = crypto.createHash("sha1").update(code).digest("hex");
74535
+ const hash = crypto2.createHash("sha1").update(code).digest("hex");
74205
74536
  if (this.resolver && this.resolverHash === hash) {
74206
74537
  debug2("Same sha1 hash for code - contents have not changed, reusing previous proxy resolver");
74207
74538
  return this.resolver;
@@ -74433,13 +74764,13 @@ import * as http from "http";
74433
74764
  import * as https from "https";
74434
74765
  import { URL as URL2, urlToHttpOptions } from "url";
74435
74766
  function headHttpRequest(url) {
74436
- return new Promise((resolve9) => {
74767
+ return new Promise((resolve8) => {
74437
74768
  const request3 = httpRequest(url, "HEAD", (response) => {
74438
74769
  response.resume();
74439
- resolve9(response.statusCode === 200);
74770
+ resolve8(response.statusCode === 200);
74440
74771
  }, false);
74441
74772
  request3.on("error", () => {
74442
- resolve9(false);
74773
+ resolve8(false);
74443
74774
  });
74444
74775
  });
74445
74776
  }
@@ -74467,7 +74798,7 @@ function httpRequest(url, method, response, keepAlive = true) {
74467
74798
  return request3;
74468
74799
  }
74469
74800
  function downloadFile(url, destinationPath, progressCallback) {
74470
- return new Promise((resolve9, reject) => {
74801
+ return new Promise((resolve8, reject) => {
74471
74802
  let downloadedBytes = 0;
74472
74803
  let totalBytes = 0;
74473
74804
  function onData(chunk) {
@@ -74483,7 +74814,7 @@ function downloadFile(url, destinationPath, progressCallback) {
74483
74814
  }
74484
74815
  const file = createWriteStream(destinationPath);
74485
74816
  file.on("close", () => {
74486
- return resolve9();
74817
+ return resolve8();
74487
74818
  });
74488
74819
  file.on("error", (error) => {
74489
74820
  return reject(error);
@@ -74508,7 +74839,7 @@ async function getJSON(url) {
74508
74839
  }
74509
74840
  }
74510
74841
  function getText(url) {
74511
- return new Promise((resolve9, reject) => {
74842
+ return new Promise((resolve8, reject) => {
74512
74843
  const request3 = httpRequest(url, "GET", (response) => {
74513
74844
  let data = "";
74514
74845
  if (response.statusCode && response.statusCode >= 400) {
@@ -74519,7 +74850,7 @@ function getText(url) {
74519
74850
  });
74520
74851
  response.on("end", () => {
74521
74852
  try {
74522
- return resolve9(String(data));
74853
+ return resolve8(String(data));
74523
74854
  } catch {
74524
74855
  return reject(new Error(`Failed to read text response from ${url}`));
74525
74856
  }
@@ -74536,7 +74867,7 @@ var init_httpUtil = __esm(() => {
74536
74867
  });
74537
74868
 
74538
74869
  // node_modules/@puppeteer/browsers/lib/esm/browser-data/chrome.js
74539
- import { execSync as execSync9 } from "child_process";
74870
+ import { execSync as execSync8 } from "child_process";
74540
74871
  import os from "os";
74541
74872
  import path from "path";
74542
74873
  function folder(platform2) {
@@ -74626,7 +74957,7 @@ function getChromeWindowsLocation(channel2, locationsPrefixes) {
74626
74957
  }
74627
74958
  function getWslVariable(variable) {
74628
74959
  try {
74629
- const result = execSync9(`cmd.exe /c echo %${variable.toLocaleUpperCase()}%`, {
74960
+ const result = execSync8(`cmd.exe /c echo %${variable.toLocaleUpperCase()}%`, {
74630
74961
  stdio: ["ignore", "pipe", "ignore"],
74631
74962
  encoding: "utf-8"
74632
74963
  }).trim();
@@ -74637,7 +74968,7 @@ function getWslVariable(variable) {
74637
74968
  return;
74638
74969
  }
74639
74970
  function getWslLocation(channel2) {
74640
- const wslVersion = execSync9("wslinfo --version", {
74971
+ const wslVersion = execSync8("wslinfo --version", {
74641
74972
  stdio: ["ignore", "pipe", "ignore"],
74642
74973
  encoding: "utf-8"
74643
74974
  }).trim();
@@ -74653,7 +74984,7 @@ function getWslLocation(channel2) {
74653
74984
  }
74654
74985
  const windowsPath = getChromeWindowsLocation(channel2, wslPrefixes);
74655
74986
  return windowsPath.map((path2) => {
74656
- return execSync9(`wslpath "${path2}"`).toString().trim();
74987
+ return execSync8(`wslpath "${path2}"`).toString().trim();
74657
74988
  });
74658
74989
  }
74659
74990
  function getChromeLinuxOrWslLocation(channel2) {
@@ -75740,7 +76071,7 @@ class Process {
75740
76071
  if (opts.onExit) {
75741
76072
  this.#onExitHook = opts.onExit;
75742
76073
  }
75743
- this.#browserProcessExiting = new Promise((resolve9, reject) => {
76074
+ this.#browserProcessExiting = new Promise((resolve8, reject) => {
75744
76075
  this.#browserProcess.once("exit", async () => {
75745
76076
  debugLaunch(`Browser process ${this.#browserProcess.pid} onExit`);
75746
76077
  this.#clearListeners();
@@ -75751,7 +76082,7 @@ class Process {
75751
76082
  reject(err);
75752
76083
  return;
75753
76084
  }
75754
- resolve9();
76085
+ resolve8();
75755
76086
  });
75756
76087
  });
75757
76088
  }
@@ -75861,7 +76192,7 @@ Error cause: ${isErrorLike2(error) ? error.stack : error}`);
75861
76192
  return [...this.#logs];
75862
76193
  }
75863
76194
  waitForLineOutput(regex, timeout2 = 0) {
75864
- return new Promise((resolve9, reject) => {
76195
+ return new Promise((resolve8, reject) => {
75865
76196
  const onClose = (errorOrCode) => {
75866
76197
  cleanup();
75867
76198
  reject(new Error([
@@ -75899,7 +76230,7 @@ Error cause: ${isErrorLike2(error) ? error.stack : error}`);
75899
76230
  return;
75900
76231
  }
75901
76232
  cleanup();
75902
- resolve9(match[1]);
76233
+ resolve8(match[1]);
75903
76234
  }
75904
76235
  });
75905
76236
  }
@@ -76429,7 +76760,7 @@ var require_get_stream = __commonJS((exports, module) => {
76429
76760
  };
76430
76761
  const { maxBuffer } = options;
76431
76762
  let stream;
76432
- await new Promise((resolve9, reject) => {
76763
+ await new Promise((resolve8, reject) => {
76433
76764
  const rejectPromise = (error) => {
76434
76765
  if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
76435
76766
  error.bufferedData = stream.getBufferedValue();
@@ -76441,7 +76772,7 @@ var require_get_stream = __commonJS((exports, module) => {
76441
76772
  rejectPromise(error);
76442
76773
  return;
76443
76774
  }
76444
- resolve9();
76775
+ resolve8();
76445
76776
  });
76446
76777
  stream.on("data", () => {
76447
76778
  if (stream.getBufferedLength() > maxBuffer) {
@@ -77802,7 +78133,7 @@ var require_extract_zip = __commonJS((exports, module) => {
77802
78133
  debug4("opening", this.zipPath, "with opts", this.opts);
77803
78134
  this.zipfile = await openZip(this.zipPath, { lazyEntries: true });
77804
78135
  this.canceled = false;
77805
- return new Promise((resolve9, reject) => {
78136
+ return new Promise((resolve8, reject) => {
77806
78137
  this.zipfile.on("error", (err) => {
77807
78138
  this.canceled = true;
77808
78139
  reject(err);
@@ -77811,7 +78142,7 @@ var require_extract_zip = __commonJS((exports, module) => {
77811
78142
  this.zipfile.on("close", () => {
77812
78143
  if (!this.canceled) {
77813
78144
  debug4("zip extraction complete");
77814
- resolve9();
78145
+ resolve8();
77815
78146
  }
77816
78147
  });
77817
78148
  this.zipfile.on("entry", async (entry) => {
@@ -79153,8 +79484,8 @@ var require_streamx = __commonJS((exports, module) => {
79153
79484
  return this;
79154
79485
  },
79155
79486
  next() {
79156
- return new Promise(function(resolve9, reject) {
79157
- promiseResolve = resolve9;
79487
+ return new Promise(function(resolve8, reject) {
79488
+ promiseResolve = resolve8;
79158
79489
  promiseReject = reject;
79159
79490
  const data = stream.read();
79160
79491
  if (data !== null)
@@ -79191,14 +79522,14 @@ var require_streamx = __commonJS((exports, module) => {
79191
79522
  }
79192
79523
  function destroy(err) {
79193
79524
  stream.destroy(err);
79194
- return new Promise((resolve9, reject) => {
79525
+ return new Promise((resolve8, reject) => {
79195
79526
  if (stream._duplexState & DESTROYED)
79196
- return resolve9({ value: undefined, done: true });
79527
+ return resolve8({ value: undefined, done: true });
79197
79528
  stream.once("close", function() {
79198
79529
  if (err)
79199
79530
  reject(err);
79200
79531
  else
79201
- resolve9({ value: undefined, done: true });
79532
+ resolve8({ value: undefined, done: true });
79202
79533
  });
79203
79534
  });
79204
79535
  }
@@ -79250,8 +79581,8 @@ var require_streamx = __commonJS((exports, module) => {
79250
79581
  return Promise.resolve(true);
79251
79582
  if (state.drains === null)
79252
79583
  state.drains = [];
79253
- return new Promise((resolve9) => {
79254
- state.drains.push({ writes, resolve: resolve9 });
79584
+ return new Promise((resolve8) => {
79585
+ state.drains.push({ writes, resolve: resolve8 });
79255
79586
  });
79256
79587
  }
79257
79588
  write(data) {
@@ -79365,11 +79696,11 @@ var require_streamx = __commonJS((exports, module) => {
79365
79696
  cb(null);
79366
79697
  }
79367
79698
  function pipelinePromise(...streams) {
79368
- return new Promise((resolve9, reject) => {
79699
+ return new Promise((resolve8, reject) => {
79369
79700
  return pipeline(...streams, (err) => {
79370
79701
  if (err)
79371
79702
  return reject(err);
79372
- resolve9();
79703
+ resolve8();
79373
79704
  });
79374
79705
  });
79375
79706
  }
@@ -80083,16 +80414,16 @@ var require_extract = __commonJS((exports, module) => {
80083
80414
  entryCallback = null;
80084
80415
  cb(err);
80085
80416
  }
80086
- function onnext(resolve9, reject) {
80417
+ function onnext(resolve8, reject) {
80087
80418
  if (error) {
80088
80419
  return reject(error);
80089
80420
  }
80090
80421
  if (entryStream) {
80091
- resolve9({ value: entryStream, done: false });
80422
+ resolve8({ value: entryStream, done: false });
80092
80423
  entryStream = null;
80093
80424
  return;
80094
80425
  }
80095
- promiseResolve = resolve9;
80426
+ promiseResolve = resolve8;
80096
80427
  promiseReject = reject;
80097
80428
  consumeCallback(null);
80098
80429
  if (extract._finished && promiseResolve) {
@@ -80123,14 +80454,14 @@ var require_extract = __commonJS((exports, module) => {
80123
80454
  function destroy(err) {
80124
80455
  extract.destroy(err);
80125
80456
  consumeCallback(err);
80126
- return new Promise((resolve9, reject) => {
80457
+ return new Promise((resolve8, reject) => {
80127
80458
  if (extract.destroyed)
80128
- return resolve9({ value: undefined, done: true });
80459
+ return resolve8({ value: undefined, done: true });
80129
80460
  extract.once("close", function() {
80130
80461
  if (err)
80131
80462
  reject(err);
80132
80463
  else
80133
- resolve9({ value: undefined, done: true });
80464
+ resolve8({ value: undefined, done: true });
80134
80465
  });
80135
80466
  });
80136
80467
  }
@@ -80928,7 +81259,7 @@ var init_fileUtil = __esm(() => {
80928
81259
  // node_modules/@puppeteer/browsers/lib/esm/install.js
80929
81260
  import assert2 from "assert";
80930
81261
  import { spawnSync as spawnSync4 } from "child_process";
80931
- import { existsSync as existsSync35, readFileSync as readFileSync26 } from "fs";
81262
+ import { existsSync as existsSync33, readFileSync as readFileSync26 } from "fs";
80932
81263
  import { mkdir as mkdir2, unlink } from "fs/promises";
80933
81264
  import os5 from "os";
80934
81265
  import path8 from "path";
@@ -80981,7 +81312,7 @@ async function installWithProviders(options) {
80981
81312
  continue;
80982
81313
  }
80983
81314
  debugInstall(`Successfully got URL from ${provider.getName()}: ${url}`);
80984
- if (!existsSync35(browserRoot)) {
81315
+ if (!existsSync33(browserRoot)) {
80985
81316
  await mkdir2(browserRoot, { recursive: true });
80986
81317
  }
80987
81318
  return await installUrl(url, options, provider);
@@ -81014,7 +81345,7 @@ async function installDeps(installedBrowser) {
81014
81345
  return;
81015
81346
  }
81016
81347
  const depsPath = path8.join(path8.dirname(installedBrowser.executablePath), "deb.deps");
81017
- if (!existsSync35(depsPath)) {
81348
+ if (!existsSync33(depsPath)) {
81018
81349
  debugInstall(`deb.deps file was not found at ${depsPath}`);
81019
81350
  return;
81020
81351
  }
@@ -81056,11 +81387,11 @@ async function installUrl(url, options, provider) {
81056
81387
  const cache = new Cache(options.cacheDir);
81057
81388
  const browserRoot = cache.browserRoot(options.browser);
81058
81389
  const archivePath = path8.join(browserRoot, `${options.buildId}-${fileName}`);
81059
- if (!existsSync35(browserRoot)) {
81390
+ if (!existsSync33(browserRoot)) {
81060
81391
  await mkdir2(browserRoot, { recursive: true });
81061
81392
  }
81062
81393
  if (!options.unpack) {
81063
- if (existsSync35(archivePath)) {
81394
+ if (existsSync33(archivePath)) {
81064
81395
  return archivePath;
81065
81396
  }
81066
81397
  debugInstall(`Downloading binary from ${url}`);
@@ -81081,8 +81412,8 @@ async function installUrl(url, options, provider) {
81081
81412
  cache.writeExecutablePath(options.browser, options.platform, options.buildId, relativeExecutablePath6);
81082
81413
  }
81083
81414
  try {
81084
- if (existsSync35(outputPath)) {
81085
- if (!existsSync35(installedBrowser.executablePath)) {
81415
+ if (existsSync33(outputPath)) {
81416
+ if (!existsSync33(installedBrowser.executablePath)) {
81086
81417
  throw new Error(`The browser folder (${outputPath}) exists but the executable (${installedBrowser.executablePath}) is missing`);
81087
81418
  }
81088
81419
  await runSetup(installedBrowser);
@@ -81091,7 +81422,7 @@ async function installUrl(url, options, provider) {
81091
81422
  }
81092
81423
  return installedBrowser;
81093
81424
  }
81094
- if (!existsSync35(archivePath)) {
81425
+ if (!existsSync33(archivePath)) {
81095
81426
  debugInstall(`Downloading binary from ${url}`);
81096
81427
  try {
81097
81428
  debugTime("download");
@@ -81120,7 +81451,7 @@ async function installUrl(url, options, provider) {
81120
81451
  }
81121
81452
  return installedBrowser;
81122
81453
  } finally {
81123
- if (existsSync35(archivePath)) {
81454
+ if (existsSync33(archivePath)) {
81124
81455
  await unlink(archivePath);
81125
81456
  }
81126
81457
  }
@@ -81131,7 +81462,7 @@ async function runSetup(installedBrowser) {
81131
81462
  debugTime("permissions");
81132
81463
  const browserDir = path8.dirname(installedBrowser.executablePath);
81133
81464
  const setupExePath = path8.join(browserDir, "setup.exe");
81134
- if (!existsSync35(setupExePath)) {
81465
+ if (!existsSync33(setupExePath)) {
81135
81466
  return;
81136
81467
  }
81137
81468
  spawnSync4(path8.join(browserDir, "setup.exe"), [`--configure-browser-in-directory=` + browserDir], {
@@ -81472,12 +81803,12 @@ var init_lib = __esm(() => {
81472
81803
  });
81473
81804
 
81474
81805
  // node_modules/cliui/build/lib/string-utils.js
81475
- function stripAnsi(str) {
81806
+ function stripAnsi2(str) {
81476
81807
  return str.replace(ansi, "");
81477
81808
  }
81478
81809
  function wrap(str, width) {
81479
81810
  const [start, end] = str.match(ansi) || ["", ""];
81480
- str = stripAnsi(str);
81811
+ str = stripAnsi2(str);
81481
81812
  let wrapped = "";
81482
81813
  for (let i = 0;i < str.length; i++) {
81483
81814
  if (i !== 0 && i % width === 0) {
@@ -81502,7 +81833,7 @@ function ui(opts) {
81502
81833
  stringWidth: (str) => {
81503
81834
  return [...str].length;
81504
81835
  },
81505
- stripAnsi,
81836
+ stripAnsi: stripAnsi2,
81506
81837
  wrap
81507
81838
  });
81508
81839
  }
@@ -81512,19 +81843,19 @@ var init_cliui = __esm(() => {
81512
81843
  });
81513
81844
 
81514
81845
  // node_modules/escalade/sync/index.mjs
81515
- import { dirname as dirname14, resolve as resolve10 } from "path";
81846
+ import { dirname as dirname13, resolve as resolve9 } from "path";
81516
81847
  import { readdirSync as readdirSync11, statSync as statSync12 } from "fs";
81517
81848
  function sync_default(start, callback) {
81518
- let dir = resolve10(".", start);
81849
+ let dir = resolve9(".", start);
81519
81850
  let tmp, stats = statSync12(dir);
81520
81851
  if (!stats.isDirectory()) {
81521
- dir = dirname14(dir);
81852
+ dir = dirname13(dir);
81522
81853
  }
81523
81854
  while (true) {
81524
81855
  tmp = callback(dir, readdirSync11(dir));
81525
81856
  if (tmp)
81526
- return resolve10(dir, tmp);
81527
- dir = dirname14(tmp = dir);
81857
+ return resolve9(dir, tmp);
81858
+ dir = dirname13(tmp = dir);
81528
81859
  if (tmp === dir)
81529
81860
  break;
81530
81861
  }
@@ -82470,7 +82801,7 @@ var init_yargs_parser = __esm(() => {
82470
82801
 
82471
82802
  // node_modules/yargs-parser/build/lib/index.js
82472
82803
  import { format } from "util";
82473
- import { normalize as normalize2, resolve as resolve11 } from "path";
82804
+ import { normalize as normalize2, resolve as resolve10 } from "path";
82474
82805
  var _a3, _b, _c, minNodeVersion, nodeVersion, env, parser, yargsParser = function Parser(args, opts) {
82475
82806
  const result = parser.parse(args.slice(), opts);
82476
82807
  return result.argv;
@@ -82493,7 +82824,7 @@ var init_lib2 = __esm(() => {
82493
82824
  },
82494
82825
  format,
82495
82826
  normalize: normalize2,
82496
- resolve: resolve11,
82827
+ resolve: resolve10,
82497
82828
  require: (path9) => {
82498
82829
  if (true) {
82499
82830
  return __require(path9);
@@ -82545,7 +82876,7 @@ var init_yerror = __esm(() => {
82545
82876
  // node_modules/y18n/build/lib/platform-shims/node.js
82546
82877
  import { readFileSync as readFileSync27, statSync as statSync13, writeFile } from "fs";
82547
82878
  import { format as format2 } from "util";
82548
- import { resolve as resolve12 } from "path";
82879
+ import { resolve as resolve11 } from "path";
82549
82880
  var node_default;
82550
82881
  var init_node = __esm(() => {
82551
82882
  node_default = {
@@ -82554,7 +82885,7 @@ var init_node = __esm(() => {
82554
82885
  writeFile
82555
82886
  },
82556
82887
  format: format2,
82557
- resolve: resolve12,
82888
+ resolve: resolve11,
82558
82889
  exists: (file) => {
82559
82890
  try {
82560
82891
  return statSync13(file).isFile();
@@ -82737,7 +83068,7 @@ import { notStrictEqual, strictEqual } from "assert";
82737
83068
  import { inspect } from "util";
82738
83069
  import { readFileSync as readFileSync28 } from "fs";
82739
83070
  import { fileURLToPath } from "url";
82740
- import { basename as basename8, dirname as dirname15, extname as extname3, relative as relative8, resolve as resolve13 } from "path";
83071
+ import { basename as basename8, dirname as dirname14, extname as extname3, relative as relative8, resolve as resolve12 } from "path";
82741
83072
  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
83073
  var init_esm = __esm(() => {
82743
83074
  init_cliui();
@@ -82770,10 +83101,10 @@ var init_esm = __esm(() => {
82770
83101
  Parser: lib_default,
82771
83102
  path: {
82772
83103
  basename: basename8,
82773
- dirname: dirname15,
83104
+ dirname: dirname14,
82774
83105
  extname: extname3,
82775
83106
  relative: relative8,
82776
- resolve: resolve13
83107
+ resolve: resolve12
82777
83108
  },
82778
83109
  process: {
82779
83110
  argv: () => process.argv,
@@ -82795,7 +83126,7 @@ var init_esm = __esm(() => {
82795
83126
  return [...str].length;
82796
83127
  },
82797
83128
  y18n: y18n_default({
82798
- directory: resolve13(__dirname2, "../../../locales"),
83129
+ directory: resolve12(__dirname2, "../../../locales"),
82799
83130
  updateFiles: false
82800
83131
  })
82801
83132
  };
@@ -85043,12 +85374,12 @@ var init_yargs_factory = __esm(() => {
85043
85374
  async getCompletion(args, done) {
85044
85375
  argsert("<array> [function]", [args, done], arguments.length);
85045
85376
  if (!done) {
85046
- return new Promise((resolve14, reject) => {
85377
+ return new Promise((resolve13, reject) => {
85047
85378
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
85048
85379
  if (err)
85049
85380
  reject(err);
85050
85381
  else
85051
- resolve14(completions);
85382
+ resolve13(completions);
85052
85383
  });
85053
85384
  });
85054
85385
  } else {
@@ -86483,9 +86814,9 @@ async function getConnectionTransport(options) {
86483
86814
  throw new Error("Could not detect required browser platform");
86484
86815
  }
86485
86816
  const { convertPuppeteerChannelToBrowsersChannel: convertPuppeteerChannelToBrowsersChannel2 } = await Promise.resolve().then(() => (init_LaunchOptions(), exports_LaunchOptions));
86486
- const { join: join32 } = await import("path");
86817
+ const { join: join30 } = await import("path");
86487
86818
  const userDataDir = resolveDefaultUserDataDir3(Browser7.CHROME, platform2, convertPuppeteerChannelToBrowsersChannel2(options.channel));
86488
- const portPath = join32(userDataDir, "DevToolsActivePort");
86819
+ const portPath = join30(userDataDir, "DevToolsActivePort");
86489
86820
  try {
86490
86821
  const fileContent = await environment.value.fs.promises.readFile(portPath, "ascii");
86491
86822
  const [rawPort, rawPath] = fileContent.split(`
@@ -86709,9 +87040,9 @@ var init_PipeTransport = __esm(() => {
86709
87040
  });
86710
87041
 
86711
87042
  // node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserLauncher.js
86712
- import { existsSync as existsSync36 } from "fs";
87043
+ import { existsSync as existsSync34 } from "fs";
86713
87044
  import { tmpdir } from "os";
86714
- import { join as join32 } from "path";
87045
+ import { join as join30 } from "path";
86715
87046
 
86716
87047
  class BrowserLauncher {
86717
87048
  #browser;
@@ -86736,7 +87067,7 @@ class BrowserLauncher {
86736
87067
  ...options,
86737
87068
  protocol
86738
87069
  });
86739
- if (!existsSync36(launchArgs.executablePath)) {
87070
+ if (!existsSync34(launchArgs.executablePath)) {
86740
87071
  throw new Error(`Browser was not found at the configured executablePath (${launchArgs.executablePath})`);
86741
87072
  }
86742
87073
  const usePipe = launchArgs.args.includes("--remote-debugging-pipe");
@@ -86811,7 +87142,7 @@ class BrowserLauncher {
86811
87142
  browserCloseCallback();
86812
87143
  const logs = browserProcess.getRecentLogs().join(`
86813
87144
  `);
86814
- if (logs.includes("Failed to create a ProcessSingleton for your profile directory") || process.platform === "win32" && existsSync36(join32(launchArgs.userDataDir, "lockfile"))) {
87145
+ if (logs.includes("Failed to create a ProcessSingleton for your profile directory") || process.platform === "win32" && existsSync34(join30(launchArgs.userDataDir, "lockfile"))) {
86815
87146
  throw new Error(`The browser is already running for ${launchArgs.userDataDir}. Use a different \`userDataDir\` or stop the running browser first.`);
86816
87147
  }
86817
87148
  if (logs.includes("Missing X server") && options.headless === false) {
@@ -86901,12 +87232,12 @@ class BrowserLauncher {
86901
87232
  });
86902
87233
  }
86903
87234
  getProfilePath() {
86904
- return join32(this.puppeteer.configuration.temporaryDirectory ?? tmpdir(), `puppeteer_dev_${this.browser}_profile-`);
87235
+ return join30(this.puppeteer.configuration.temporaryDirectory ?? tmpdir(), `puppeteer_dev_${this.browser}_profile-`);
86905
87236
  }
86906
87237
  resolveExecutablePath(headless, validatePath = true) {
86907
87238
  let executablePath = this.puppeteer.configuration.executablePath;
86908
87239
  if (executablePath) {
86909
- if (validatePath && !existsSync36(executablePath)) {
87240
+ if (validatePath && !existsSync34(executablePath)) {
86910
87241
  throw new Error(`Tried to find the browser at the configured path (${executablePath}), but no executable was found.`);
86911
87242
  }
86912
87243
  return executablePath;
@@ -86929,7 +87260,7 @@ class BrowserLauncher {
86929
87260
  browser: browserType,
86930
87261
  buildId: this.puppeteer.browserVersion
86931
87262
  });
86932
- if (validatePath && !existsSync36(executablePath)) {
87263
+ if (validatePath && !existsSync34(executablePath)) {
86933
87264
  const configVersion = this.puppeteer.configuration?.[this.browser]?.version;
86934
87265
  if (configVersion) {
86935
87266
  throw new Error(`Tried to find the browser at the configured path (${executablePath}) for version ${configVersion}, but no executable was found.`);
@@ -87467,7 +87798,7 @@ var init_PuppeteerNode = __esm(() => {
87467
87798
  import { spawn as spawn2, spawnSync as spawnSync5 } from "child_process";
87468
87799
  import fs5 from "fs";
87469
87800
  import os8 from "os";
87470
- import { dirname as dirname16 } from "path";
87801
+ import { dirname as dirname15 } from "path";
87471
87802
  import { PassThrough } from "stream";
87472
87803
  var import_debug6, __runInitializers22 = function(thisArg, initializers, value) {
87473
87804
  var useValue = arguments.length > 2;
@@ -87541,8 +87872,8 @@ var init_ScreenRecorder = __esm(() => {
87541
87872
  static {
87542
87873
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : undefined;
87543
87874
  __esDecorate22(this, _private_writeFrame_descriptor = { value: __setFunctionName5(async function(buffer) {
87544
- const error = await new Promise((resolve14) => {
87545
- this.#process.stdin.write(buffer, resolve14);
87875
+ const error = await new Promise((resolve13) => {
87876
+ this.#process.stdin.write(buffer, resolve13);
87546
87877
  });
87547
87878
  if (error) {
87548
87879
  console.log(`ffmpeg failed to write: ${error.message}.`);
@@ -87591,7 +87922,7 @@ var init_ScreenRecorder = __esm(() => {
87591
87922
  filters.push(formatArgs.splice(vf, 2).at(-1) ?? "");
87592
87923
  }
87593
87924
  if (path11) {
87594
- fs5.mkdirSync(dirname16(path11), { recursive: overwrite });
87925
+ fs5.mkdirSync(dirname15(path11), { recursive: overwrite });
87595
87926
  }
87596
87927
  this.#process = spawn2(ffmpegPath, [
87597
87928
  ["-loglevel", "error"],
@@ -87697,8 +88028,8 @@ var init_ScreenRecorder = __esm(() => {
87697
88028
  const [buffer, timestamp] = await this.#lastFrame;
87698
88029
  await Promise.all(Array(Math.max(1, Math.round(this.#fps * (performance.now() - timestamp) / 1000))).fill(buffer).map(this.#writeFrame.bind(this)));
87699
88030
  this.#process.stdin.end();
87700
- await new Promise((resolve14) => {
87701
- this.#process.once("close", resolve14);
88031
+ await new Promise((resolve13) => {
88032
+ this.#process.once("close", resolve13);
87702
88033
  });
87703
88034
  }
87704
88035
  async[(_private_writeFrame_decorators = [guarded()], _stop_decorators = [guarded()], asyncDisposeSymbol)]() {
@@ -87744,17 +88075,17 @@ var init_puppeteer_core = __esm(() => {
87744
88075
  });
87745
88076
 
87746
88077
  // 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";
88078
+ import { mkdirSync as mkdirSync15, statSync as statSync14, existsSync as existsSync35 } from "fs";
88079
+ import { join as join31 } from "path";
87749
88080
  function findBrowser() {
87750
88081
  const platform2 = process.platform;
87751
88082
  const paths = CHROME_PATHS[platform2] ?? [];
87752
88083
  for (const p of paths) {
87753
- if (existsSync37(p))
88084
+ if (existsSync35(p))
87754
88085
  return p;
87755
88086
  }
87756
- const minkBrowsers = join33(minkRoot(), "browsers");
87757
- if (existsSync37(minkBrowsers)) {
88087
+ const minkBrowsers = join31(minkRoot(), "browsers");
88088
+ if (existsSync35(minkBrowsers)) {
87758
88089
  const found = findChromeInDir(minkBrowsers);
87759
88090
  if (found)
87760
88091
  return found;
@@ -87775,7 +88106,7 @@ function findChromeInDir(dir) {
87775
88106
  try {
87776
88107
  const entries = readdirSync12(dir);
87777
88108
  for (const entry of entries) {
87778
- const full = join33(dir, entry);
88109
+ const full = join31(dir, entry);
87779
88110
  try {
87780
88111
  const stat2 = statSync15(full);
87781
88112
  if (stat2.isDirectory()) {
@@ -87823,7 +88154,7 @@ async function captureRoute(page, route, baseUrl, viewport, options) {
87823
88154
  const y = section * viewport.height;
87824
88155
  const clipHeight = Math.min(viewport.height, pageHeight - y);
87825
88156
  const fileName = `${prefix}-${viewport.name}-${section}.jpg`;
87826
- const filePath = join33(options.outputDir, fileName);
88157
+ const filePath = join31(options.outputDir, fileName);
87827
88158
  await page.screenshot({
87828
88159
  path: filePath,
87829
88160
  type: "jpeg",
@@ -87855,7 +88186,7 @@ async function captureRoute(page, route, baseUrl, viewport, options) {
87855
88186
  return results;
87856
88187
  }
87857
88188
  async function captureAllRoutes(routes, baseUrl, viewports, options, outputDir) {
87858
- mkdirSync16(outputDir, { recursive: true });
88189
+ mkdirSync15(outputDir, { recursive: true });
87859
88190
  const executablePath = findBrowser();
87860
88191
  const browser = await puppeteer_core_default.launch({
87861
88192
  executablePath,
@@ -89292,9 +89623,9 @@ var exports_wiki = {};
89292
89623
  __export(exports_wiki, {
89293
89624
  wiki: () => wiki
89294
89625
  });
89295
- import { existsSync as existsSync38, statSync as statSync15 } from "fs";
89296
- import { resolve as resolve14 } from "path";
89297
- import { homedir as homedir5 } from "os";
89626
+ import { existsSync as existsSync36, statSync as statSync15 } from "fs";
89627
+ import { resolve as resolve13 } from "path";
89628
+ import { homedir as homedir4 } from "os";
89298
89629
  async function wiki(_cwd, args) {
89299
89630
  const sub = args[0];
89300
89631
  switch (sub) {
@@ -89350,7 +89681,7 @@ async function wikiInit(args) {
89350
89681
  console.log(`[mink] initializing vault at ${targetPath}`);
89351
89682
  console.log(" (set a custom path with: mink wiki init /path/to/vault)");
89352
89683
  }
89353
- const isExisting = existsSync38(targetPath) && statSync15(targetPath).isDirectory();
89684
+ const isExisting = existsSync36(targetPath) && statSync15(targetPath).isDirectory();
89354
89685
  setConfigValue("wiki.path", targetPath);
89355
89686
  ensureVaultStructure();
89356
89687
  seedTemplates(vaultTemplates());
@@ -89560,9 +89891,9 @@ function wikiLinks() {
89560
89891
  }
89561
89892
  function expandPath(raw) {
89562
89893
  if (raw.startsWith("~/")) {
89563
- return resolve14(homedir5(), raw.slice(2));
89894
+ return resolve13(homedir4(), raw.slice(2));
89564
89895
  }
89565
- return resolve14(raw);
89896
+ return resolve13(raw);
89566
89897
  }
89567
89898
  var init_wiki = __esm(() => {
89568
89899
  init_vault();
@@ -89578,8 +89909,8 @@ var exports_note = {};
89578
89909
  __export(exports_note, {
89579
89910
  note: () => note
89580
89911
  });
89581
- import { resolve as resolve15 } from "path";
89582
- import { existsSync as existsSync39, readFileSync as readFileSync29 } from "fs";
89912
+ import { resolve as resolve14 } from "path";
89913
+ import { existsSync as existsSync37, readFileSync as readFileSync29 } from "fs";
89583
89914
  async function note(cwd, args) {
89584
89915
  if (!isWikiEnabled()) {
89585
89916
  console.error("[mink] wiki feature is disabled");
@@ -89609,8 +89940,8 @@ async function note(cwd, args) {
89609
89940
  return;
89610
89941
  }
89611
89942
  if (parsed.file) {
89612
- const sourcePath = resolve15(cwd, parsed.file);
89613
- if (!existsSync39(sourcePath)) {
89943
+ const sourcePath = resolve14(cwd, parsed.file);
89944
+ if (!existsSync37(sourcePath)) {
89614
89945
  console.error(`[mink] file not found: ${sourcePath}`);
89615
89946
  process.exit(1);
89616
89947
  }
@@ -89771,39 +90102,39 @@ var exports_skill = {};
89771
90102
  __export(exports_skill, {
89772
90103
  skill: () => skill
89773
90104
  });
89774
- import { join as join34, resolve as resolve16, dirname as dirname17 } from "path";
89775
- import { homedir as homedir6 } from "os";
90105
+ import { join as join32, resolve as resolve15, dirname as dirname16 } from "path";
90106
+ import { homedir as homedir5 } from "os";
89776
90107
  import {
89777
- existsSync as existsSync40,
89778
- mkdirSync as mkdirSync17,
89779
- copyFileSync as copyFileSync2,
90108
+ existsSync as existsSync38,
90109
+ mkdirSync as mkdirSync16,
90110
+ copyFileSync,
89780
90111
  unlinkSync as unlinkSync6,
89781
90112
  readdirSync as readdirSync12,
89782
- rmSync as rmSync3,
90113
+ rmSync as rmSync2,
89783
90114
  symlinkSync as symlinkSync2,
89784
90115
  lstatSync as lstatSync2
89785
90116
  } from "fs";
89786
90117
  function getSkillsSourceDir() {
89787
- let dir = dirname17(new URL(import.meta.url).pathname);
90118
+ let dir = dirname16(new URL(import.meta.url).pathname);
89788
90119
  while (true) {
89789
- if (existsSync40(join34(dir, "package.json")) && existsSync40(join34(dir, "skills"))) {
89790
- return join34(dir, "skills");
90120
+ if (existsSync38(join32(dir, "package.json")) && existsSync38(join32(dir, "skills"))) {
90121
+ return join32(dir, "skills");
89791
90122
  }
89792
- const parent = dirname17(dir);
90123
+ const parent = dirname16(dir);
89793
90124
  if (parent === dir)
89794
90125
  break;
89795
90126
  dir = parent;
89796
90127
  }
89797
- return resolve16(dirname17(new URL(import.meta.url).pathname), "../../skills");
90128
+ return resolve15(dirname16(new URL(import.meta.url).pathname), "../../skills");
89798
90129
  }
89799
90130
  function getAvailableSkills() {
89800
90131
  const dir = getSkillsSourceDir();
89801
- if (!existsSync40(dir))
90132
+ if (!existsSync38(dir))
89802
90133
  return [];
89803
- return readdirSync12(dir, { withFileTypes: true }).filter((d) => d.isDirectory() && existsSync40(join34(dir, d.name, "SKILL.md"))).map((d) => d.name);
90134
+ return readdirSync12(dir, { withFileTypes: true }).filter((d) => d.isDirectory() && existsSync38(join32(dir, d.name, "SKILL.md"))).map((d) => d.name);
89804
90135
  }
89805
90136
  function isInstalled(skillName) {
89806
- return existsSync40(join34(AGENTS_SKILLS_DIR, skillName, "SKILL.md"));
90137
+ return existsSync38(join32(AGENTS_SKILLS_DIR, skillName, "SKILL.md"));
89807
90138
  }
89808
90139
  async function skill(args) {
89809
90140
  const sub = args[0];
@@ -89837,28 +90168,28 @@ function skillInstall(name) {
89837
90168
  console.error(" Expected skills at: " + sourceDir);
89838
90169
  return;
89839
90170
  }
89840
- mkdirSync17(AGENTS_SKILLS_DIR, { recursive: true });
90171
+ mkdirSync16(AGENTS_SKILLS_DIR, { recursive: true });
89841
90172
  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)) {
90173
+ const srcDir = join32(sourceDir, skillName);
90174
+ const srcFile = join32(srcDir, "SKILL.md");
90175
+ const destDir = join32(AGENTS_SKILLS_DIR, skillName);
90176
+ if (!existsSync38(srcFile)) {
89846
90177
  console.error(`[mink] skill not found: ${skillName}`);
89847
90178
  continue;
89848
90179
  }
89849
- mkdirSync17(destDir, { recursive: true });
90180
+ mkdirSync16(destDir, { recursive: true });
89850
90181
  copyDirRecursive2(srcDir, destDir);
89851
- mkdirSync17(CLAUDE_SKILLS_DIR, { recursive: true });
89852
- const symlink = join34(CLAUDE_SKILLS_DIR, skillName);
90182
+ mkdirSync16(CLAUDE_SKILLS_DIR, { recursive: true });
90183
+ const symlink = join32(CLAUDE_SKILLS_DIR, skillName);
89853
90184
  try {
89854
- if (existsSync40(symlink)) {
90185
+ if (existsSync38(symlink)) {
89855
90186
  if (lstatSync2(symlink).isSymbolicLink() || lstatSync2(symlink).isFile()) {
89856
90187
  unlinkSync6(symlink);
89857
90188
  } else {
89858
- rmSync3(symlink, { recursive: true, force: true });
90189
+ rmSync2(symlink, { recursive: true, force: true });
89859
90190
  }
89860
90191
  }
89861
- const relativeTarget = join34("..", "..", ".agents", "skills", skillName);
90192
+ const relativeTarget = join32("..", "..", ".agents", "skills", skillName);
89862
90193
  symlinkSync2(relativeTarget, symlink);
89863
90194
  } catch {}
89864
90195
  console.log(`[mink] installed: ${skillName} -> ${destDir}`);
@@ -89869,15 +90200,15 @@ function skillInstall(name) {
89869
90200
  function skillUninstall(name) {
89870
90201
  const skills = name ? [name] : getAvailableSkills();
89871
90202
  for (const skillName of skills) {
89872
- const destDir = join34(AGENTS_SKILLS_DIR, skillName);
89873
- if (!existsSync40(destDir)) {
90203
+ const destDir = join32(AGENTS_SKILLS_DIR, skillName);
90204
+ if (!existsSync38(destDir)) {
89874
90205
  console.log(`[mink] not installed: ${skillName}`);
89875
90206
  continue;
89876
90207
  }
89877
- rmSync3(destDir, { recursive: true, force: true });
89878
- const symlink = join34(CLAUDE_SKILLS_DIR, skillName);
90208
+ rmSync2(destDir, { recursive: true, force: true });
90209
+ const symlink = join32(CLAUDE_SKILLS_DIR, skillName);
89879
90210
  try {
89880
- if (existsSync40(symlink))
90211
+ if (existsSync38(symlink))
89881
90212
  unlinkSync6(symlink);
89882
90213
  } catch {}
89883
90214
  console.log(`[mink] uninstalled: ${skillName}`);
@@ -89892,7 +90223,7 @@ function skillList() {
89892
90223
  if (installed.length > 0) {
89893
90224
  console.log(" Installed:");
89894
90225
  for (const s of installed) {
89895
- console.log(` ${s} (${join34(AGENTS_SKILLS_DIR, s)})`);
90226
+ console.log(` ${s} (${join32(AGENTS_SKILLS_DIR, s)})`);
89896
90227
  }
89897
90228
  }
89898
90229
  if (notInstalled.length > 0) {
@@ -89911,20 +90242,20 @@ function skillList() {
89911
90242
  function copyDirRecursive2(src, dest) {
89912
90243
  const entries = readdirSync12(src, { withFileTypes: true });
89913
90244
  for (const entry of entries) {
89914
- const srcPath = join34(src, entry.name);
89915
- const destPath = join34(dest, entry.name);
90245
+ const srcPath = join32(src, entry.name);
90246
+ const destPath = join32(dest, entry.name);
89916
90247
  if (entry.isDirectory()) {
89917
- mkdirSync17(destPath, { recursive: true });
90248
+ mkdirSync16(destPath, { recursive: true });
89918
90249
  copyDirRecursive2(srcPath, destPath);
89919
90250
  } else {
89920
- copyFileSync2(srcPath, destPath);
90251
+ copyFileSync(srcPath, destPath);
89921
90252
  }
89922
90253
  }
89923
90254
  }
89924
90255
  var AGENTS_SKILLS_DIR, CLAUDE_SKILLS_DIR;
89925
90256
  var init_skill = __esm(() => {
89926
- AGENTS_SKILLS_DIR = join34(homedir6(), ".agents", "skills");
89927
- CLAUDE_SKILLS_DIR = join34(homedir6(), ".claude", "skills");
90257
+ AGENTS_SKILLS_DIR = join32(homedir5(), ".agents", "skills");
90258
+ CLAUDE_SKILLS_DIR = join32(homedir5(), ".claude", "skills");
89928
90259
  });
89929
90260
 
89930
90261
  // src/commands/agent.ts
@@ -89932,41 +90263,41 @@ var exports_agent = {};
89932
90263
  __export(exports_agent, {
89933
90264
  agent: () => agent
89934
90265
  });
89935
- import { join as join35, resolve as resolve17, dirname as dirname18 } from "path";
89936
- import { homedir as homedir7 } from "os";
90266
+ import { join as join33, resolve as resolve16, dirname as dirname17 } from "path";
90267
+ import { homedir as homedir6 } from "os";
89937
90268
  import {
89938
- existsSync as existsSync41,
89939
- mkdirSync as mkdirSync18,
90269
+ existsSync as existsSync39,
90270
+ mkdirSync as mkdirSync17,
89940
90271
  readFileSync as readFileSync30,
89941
90272
  writeFileSync as writeFileSync11
89942
90273
  } from "fs";
89943
90274
  import { createHash as createHash4 } from "crypto";
89944
90275
  import { spawnSync as spawnSync6 } from "child_process";
89945
90276
  function getAgentTemplatePath() {
89946
- let dir = dirname18(new URL(import.meta.url).pathname);
90277
+ let dir = dirname17(new URL(import.meta.url).pathname);
89947
90278
  while (true) {
89948
- if (existsSync41(join35(dir, "package.json")) && existsSync41(join35(dir, "agents", TEMPLATE_FILE))) {
89949
- return join35(dir, "agents", TEMPLATE_FILE);
90279
+ if (existsSync39(join33(dir, "package.json")) && existsSync39(join33(dir, "agents", TEMPLATE_FILE))) {
90280
+ return join33(dir, "agents", TEMPLATE_FILE);
89950
90281
  }
89951
- const parent = dirname18(dir);
90282
+ const parent = dirname17(dir);
89952
90283
  if (parent === dir)
89953
90284
  break;
89954
90285
  dir = parent;
89955
90286
  }
89956
- return resolve17(dirname18(new URL(import.meta.url).pathname), "../../agents", TEMPLATE_FILE);
90287
+ return resolve16(dirname17(new URL(import.meta.url).pathname), "../../agents", TEMPLATE_FILE);
89957
90288
  }
89958
90289
  function getMinkVersion() {
89959
- let dir = dirname18(new URL(import.meta.url).pathname);
90290
+ let dir = dirname17(new URL(import.meta.url).pathname);
89960
90291
  while (true) {
89961
- const pkgPath = join35(dir, "package.json");
89962
- if (existsSync41(pkgPath)) {
90292
+ const pkgPath = join33(dir, "package.json");
90293
+ if (existsSync39(pkgPath)) {
89963
90294
  try {
89964
90295
  const pkg = JSON.parse(readFileSync30(pkgPath, "utf-8"));
89965
90296
  if (pkg.name && pkg.version)
89966
90297
  return pkg.version;
89967
90298
  } catch {}
89968
90299
  }
89969
- const parent = dirname18(dir);
90300
+ const parent = dirname17(dir);
89970
90301
  if (parent === dir)
89971
90302
  break;
89972
90303
  dir = parent;
@@ -89984,19 +90315,19 @@ function sha2562(text) {
89984
90315
  return createHash4("sha256").update(text).digest("hex");
89985
90316
  }
89986
90317
  function claudeAgentsDir() {
89987
- return join35(homedir7(), ".claude", "agents");
90318
+ return join33(homedir6(), ".claude", "agents");
89988
90319
  }
89989
90320
  function installedAgentPath() {
89990
- return join35(claudeAgentsDir(), INSTALLED_FILE);
90321
+ return join33(claudeAgentsDir(), INSTALLED_FILE);
89991
90322
  }
89992
90323
  function installAgentDefinition(opts) {
89993
90324
  const templatePath = getAgentTemplatePath();
89994
- if (!existsSync41(templatePath)) {
90325
+ if (!existsSync39(templatePath)) {
89995
90326
  throw new Error(`[mink agent] bundled agent template not found at ${templatePath}
89996
90327
  ` + " This usually means the package was installed without bundled assets.");
89997
90328
  }
89998
90329
  const installed = installedAgentPath();
89999
- if (opts.skip && existsSync41(installed)) {
90330
+ if (opts.skip && existsSync39(installed)) {
90000
90331
  return { action: "skipped", path: installed };
90001
90332
  }
90002
90333
  const template = readFileSync30(templatePath, "utf-8");
@@ -90005,14 +90336,14 @@ function installAgentDefinition(opts) {
90005
90336
  VAULT_PATH: resolveVaultPath(),
90006
90337
  MINK_VERSION: getMinkVersion()
90007
90338
  });
90008
- const exists = existsSync41(installed);
90339
+ const exists = existsSync39(installed);
90009
90340
  if (!opts.force && exists) {
90010
90341
  const current = readFileSync30(installed, "utf-8");
90011
90342
  if (sha2562(current) === sha2562(rendered)) {
90012
90343
  return { action: "unchanged", path: installed };
90013
90344
  }
90014
90345
  }
90015
- mkdirSync18(claudeAgentsDir(), { recursive: true });
90346
+ mkdirSync17(claudeAgentsDir(), { recursive: true });
90016
90347
  writeFileSync11(installed, rendered);
90017
90348
  return {
90018
90349
  action: exists ? "updated" : "installed",
@@ -90083,8 +90414,8 @@ async function agent(_cwd, rawArgs) {
90083
90414
  }
90084
90415
  const skipUpdate = args.noUpdate || process.env.MINK_AGENT_NO_UPDATE === "1";
90085
90416
  const root = minkRoot();
90086
- if (!existsSync41(root)) {
90087
- mkdirSync18(root, { recursive: true });
90417
+ if (!existsSync39(root)) {
90418
+ mkdirSync17(root, { recursive: true });
90088
90419
  }
90089
90420
  let result;
90090
90421
  try {
@@ -90135,13 +90466,13 @@ var init_agent = __esm(() => {
90135
90466
  });
90136
90467
 
90137
90468
  // 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";
90469
+ import { readFileSync as readFileSync31, writeFileSync as writeFileSync12, appendFileSync as appendFileSync2, copyFileSync as copyFileSync2, renameSync as renameSync4, unlinkSync as unlinkSync7 } from "fs";
90470
+ import { join as join34 } from "path";
90140
90471
  function logWarning(driver, args, err) {
90141
90472
  try {
90142
90473
  const line = `[${new Date().toISOString()}] ${driver} fallback for ${args.filePath}: ${err instanceof Error ? err.message : String(err)}
90143
90474
  `;
90144
- appendFileSync2(join36(minkRoot(), "sync-warnings.log"), line);
90475
+ appendFileSync2(join34(minkRoot(), "sync-warnings.log"), line);
90145
90476
  } catch {}
90146
90477
  }
90147
90478
  function readJsonOrNull(path12) {
@@ -90376,7 +90707,7 @@ function mergeDbDriver(args) {
90376
90707
  const tmp = `${args.oursPath}.merge-${process.pid}-${Date.now()}.tmp`;
90377
90708
  let ours = null;
90378
90709
  try {
90379
- copyFileSync3(args.oursPath, tmp);
90710
+ copyFileSync2(args.oursPath, tmp);
90380
90711
  ours = openDriver(tmp);
90381
90712
  ours.exec("PRAGMA journal_mode = WAL");
90382
90713
  ours.exec("PRAGMA foreign_keys = ON");
@@ -90892,22 +91223,8 @@ switch (command2) {
90892
91223
  sessionStop(sessionPath(cwd));
90893
91224
  break;
90894
91225
  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 });
91226
+ const { init: init2 } = await Promise.resolve().then(() => (init_init(), exports_init));
91227
+ await init2(cwd);
90911
91228
  break;
90912
91229
  }
90913
91230
  case "status": {
@@ -90937,6 +91254,11 @@ switch (command2) {
90937
91254
  await postRead2(cwd);
90938
91255
  break;
90939
91256
  }
91257
+ case "post-tool": {
91258
+ const { postTool: postTool2 } = await Promise.resolve().then(() => (init_post_tool(), exports_post_tool));
91259
+ await postTool2(cwd);
91260
+ break;
91261
+ }
90940
91262
  case "pre-write": {
90941
91263
  const { preWrite: preWrite2 } = await Promise.resolve().then(() => (init_pre_write(), exports_pre_write));
90942
91264
  await preWrite2(cwd);
@@ -90952,6 +91274,11 @@ switch (command2) {
90952
91274
  detectWaste2(cwd);
90953
91275
  break;
90954
91276
  }
91277
+ case "retrieve": {
91278
+ const { retrieve: retrieve2 } = await Promise.resolve().then(() => (init_retrieve(), exports_retrieve));
91279
+ retrieve2(cwd, process.argv.slice(3));
91280
+ break;
91281
+ }
90955
91282
  case "cron": {
90956
91283
  const { cron: cron2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
90957
91284
  await cron2(cwd, process.argv.slice(3));
@@ -91051,12 +91378,12 @@ switch (command2) {
91051
91378
  case "version":
91052
91379
  case "--version":
91053
91380
  case "-v": {
91054
- const { resolve: resolve18, dirname: dirname19, basename: basename9 } = await import("path");
91381
+ const { resolve: resolve17, dirname: dirname18, basename: basename9 } = await import("path");
91055
91382
  const bundlePath = new URL(import.meta.url).pathname;
91056
- const cliPath = resolve18(dirname19(bundlePath));
91383
+ const cliPath = resolve17(dirname18(bundlePath));
91057
91384
  const { readFileSync: readFileSync32 } = await import("fs");
91058
91385
  try {
91059
- const pkg = JSON.parse(readFileSync32(resolve18(cliPath, "../package.json"), "utf-8"));
91386
+ const pkg = JSON.parse(readFileSync32(resolve17(cliPath, "../package.json"), "utf-8"));
91060
91387
  console.log(`mink ${pkg.version}`);
91061
91388
  } catch {
91062
91389
  console.log("mink (unknown version)");
@@ -91079,8 +91406,7 @@ switch (command2) {
91079
91406
  console.log("Usage: mink <command> [options]");
91080
91407
  console.log();
91081
91408
  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)");
91409
+ console.log(" init Initialize Mink in the current project");
91084
91410
  console.log(" status Display project health at a glance");
91085
91411
  console.log(" scan [--check] Force a full file index rescan");
91086
91412
  console.log(" config [key] [value] Manage global user settings");
@@ -91122,6 +91448,7 @@ switch (command2) {
91122
91448
  console.log(" restore [backup] Restore state from a backup");
91123
91449
  console.log(" bug search <term> Search the bug log");
91124
91450
  console.log(" detect-waste Detect and flag wasteful patterns");
91451
+ console.log(" retrieve <token> Return a compressed tool output's original (spec 21)");
91125
91452
  console.log(" reflect Generate learning memory reflections");
91126
91453
  console.log(" designqc [target] Capture design screenshots (spec 13)");
91127
91454
  console.log(" framework-advisor Generate framework advisor knowledge file (spec 14)");
@@ -91131,6 +91458,7 @@ switch (command2) {
91131
91458
  console.log(" session-stop Finalize session and log data");
91132
91459
  console.log(" pre-read / post-read File read hooks");
91133
91460
  console.log(" pre-write / post-write File write hooks");
91461
+ console.log(" post-tool Tool-output compression hook (Bash/Grep/MCP, spec 21)");
91134
91462
  break;
91135
91463
  default:
91136
91464
  console.error(`[mink] unknown command: ${command2 ?? "(none)"}`);