@drewpayment/mink 0.13.0-beta.1 → 0.13.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -20
- package/dashboard/out/404.html +1 -1
- package/dashboard/out/_next/static/U9AeObddt4LmJkKRZpEfy/_buildManifest.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/activity/page-c285fb9f63d9a82a.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/bugs/page-f3ba7d8f50a96568.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/capture/page-e004bec9af99a244.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/compression/page-21e1af119b3f81ff.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/config/page-d47fb6f588ccfd4b.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/daemon/page-52f913e751416717.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/design/page-53a76719b9af5830.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/discord/page-04502d12c4a96cf7.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/file-index/page-a1bd10e04bb219d9.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/insights/page-7367274963571b6b.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/learning/{page-b766adc79099adb4.js → page-4a03cf7b9a6106fd.js} +1 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/overview/page-38b8430b5c56e807.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/scheduler/page-510b78c9b0a61012.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/sync/page-b7215c2a29a7d7a7.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/tokens/page-1be7ed35a5c9bd39.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/waste/page-24a726e6d63f771a.js +1 -0
- package/dashboard/out/_next/static/chunks/app/(panels)/wiki/page-230d2d1cae6507a8.js +1 -0
- package/dashboard/out/_next/static/chunks/app/layout-70a6d18f8e464960.js +1 -0
- package/dashboard/out/action-log.html +1 -1
- package/dashboard/out/action-log.txt +4 -4
- package/dashboard/out/activity.html +1 -1
- package/dashboard/out/activity.txt +5 -5
- package/dashboard/out/bugs.html +1 -1
- package/dashboard/out/bugs.txt +5 -5
- package/dashboard/out/capture.html +1 -1
- package/dashboard/out/capture.txt +5 -5
- package/dashboard/out/compression.html +1 -0
- package/dashboard/out/compression.txt +24 -0
- package/dashboard/out/config.html +1 -1
- package/dashboard/out/config.txt +5 -5
- package/dashboard/out/daemon.html +1 -1
- package/dashboard/out/daemon.txt +5 -5
- package/dashboard/out/design.html +1 -1
- package/dashboard/out/design.txt +5 -5
- package/dashboard/out/discord.html +1 -1
- package/dashboard/out/discord.txt +5 -5
- package/dashboard/out/file-index.html +1 -1
- package/dashboard/out/file-index.txt +5 -5
- package/dashboard/out/index.html +1 -1
- package/dashboard/out/index.txt +4 -4
- package/dashboard/out/insights.html +1 -1
- package/dashboard/out/insights.txt +5 -5
- package/dashboard/out/learning.html +1 -1
- package/dashboard/out/learning.txt +5 -5
- package/dashboard/out/overview.html +1 -1
- package/dashboard/out/overview.txt +5 -5
- package/dashboard/out/scheduler.html +1 -1
- package/dashboard/out/scheduler.txt +5 -5
- package/dashboard/out/sync.html +1 -1
- package/dashboard/out/sync.txt +5 -5
- package/dashboard/out/tokens.html +1 -1
- package/dashboard/out/tokens.txt +5 -5
- package/dashboard/out/waste.html +1 -1
- package/dashboard/out/waste.txt +5 -5
- package/dashboard/out/wiki.html +1 -1
- package/dashboard/out/wiki.txt +5 -5
- package/dist/cli.bun.js +1300 -908
- package/dist/cli.node.js +1319 -928
- package/package.json +1 -1
- package/src/cli.ts +17 -20
- package/src/commands/init.ts +14 -123
- package/src/commands/post-read.ts +18 -0
- package/src/commands/post-tool.ts +48 -0
- package/src/commands/retrieve.ts +32 -0
- package/src/commands/status.ts +13 -1
- package/src/core/code-skeleton.ts +108 -0
- package/src/core/compress-tool-output.ts +127 -0
- package/src/core/compression.ts +81 -0
- package/src/core/dashboard-api.ts +20 -1
- package/src/core/dashboard-server.ts +3 -0
- package/src/core/hook-output.ts +42 -0
- package/src/core/output-compression.ts +252 -0
- package/src/core/token-estimate.ts +40 -0
- package/src/repositories/compression-cache-repo.ts +97 -0
- package/src/repositories/token-ledger-repo.ts +142 -0
- package/src/storage/schema.ts +50 -1
- package/src/types/compression.ts +29 -0
- package/src/types/config.ts +40 -0
- package/src/types/dashboard.ts +22 -1
- package/src/types/hook-input.ts +4 -0
- package/src/types/token-ledger.ts +55 -0
- package/dashboard/out/_next/static/UWfkbJY4zr9fSt7O-CAge/_buildManifest.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/activity/page-096a97ba539d5323.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/bugs/page-449d31c133432458.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/capture/page-c6617aa0a8a7333e.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/config/page-aa0a0623b3fdd0d8.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/daemon/page-7cd3fac2f5d87a0d.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/design/page-5304675c96b6793b.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/discord/page-9940dde80ba2a69e.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/file-index/page-ecd8a753614e981e.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/insights/page-7909d8beb8d8ef7a.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/overview/page-7a9e86dcde67d6a9.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/scheduler/page-a88f93204c9742a1.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/sync/page-8a9ad4c36aa6cb65.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/tokens/page-8dac7d50d4db2756.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/waste/page-bcf56144faf7d133.js +0 -1
- package/dashboard/out/_next/static/chunks/app/(panels)/wiki/page-a32fdbd0bf58b30b.js +0 -1
- package/dashboard/out/_next/static/chunks/app/layout-782cd26e0ccc4514.js +0 -1
- package/src/core/agent-detect.ts +0 -88
- package/src/core/agent-pi.ts +0 -314
- package/src/core/prompt.ts +0 -27
- /package/dashboard/out/_next/static/{UWfkbJY4zr9fSt7O-CAge → U9AeObddt4LmJkKRZpEfy}/_ssgManifest.js +0 -0
package/dist/cli.node.js
CHANGED
|
@@ -422,6 +422,41 @@ var init_config = __esm(() => {
|
|
|
422
422
|
envVar: "MINK_PROJECTS_IDENTITY",
|
|
423
423
|
description: "Project identity strategy: path-derived (legacy) or git-remote (stable across machines)",
|
|
424
424
|
scope: "shared"
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
key: "compression.enabled",
|
|
428
|
+
default: "false",
|
|
429
|
+
envVar: "MINK_COMPRESSION_ENABLED",
|
|
430
|
+
description: "Enable tool-output compression (spec 21). Off until inline compression ships.",
|
|
431
|
+
scope: "shared"
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
key: "compression.threshold-tokens",
|
|
435
|
+
default: "800",
|
|
436
|
+
envVar: "MINK_COMPRESSION_THRESHOLD_TOKENS",
|
|
437
|
+
description: "Minimum estimated token size before a tool output is eligible for compression",
|
|
438
|
+
scope: "shared"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
key: "compression.min-savings-ratio",
|
|
442
|
+
default: "0.25",
|
|
443
|
+
envVar: "MINK_COMPRESSION_MIN_SAVINGS_RATIO",
|
|
444
|
+
description: "Discard a compression attempt unless it saves at least this fraction of tokens",
|
|
445
|
+
scope: "shared"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
key: "compression.holdout-fraction",
|
|
449
|
+
default: "0.1",
|
|
450
|
+
envVar: "MINK_COMPRESSION_HOLDOUT_FRACTION",
|
|
451
|
+
description: "Fraction of eligible outputs left uncompressed as a measured control group",
|
|
452
|
+
scope: "shared"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
key: "compression.retention-hours",
|
|
456
|
+
default: "168",
|
|
457
|
+
envVar: "MINK_COMPRESSION_RETENTION_HOURS",
|
|
458
|
+
description: "How long compressed originals stay retrievable before eviction",
|
|
459
|
+
scope: "shared"
|
|
425
460
|
}
|
|
426
461
|
];
|
|
427
462
|
VALID_KEYS = new Set(CONFIG_KEYS.map((k) => k.key));
|
|
@@ -3096,7 +3131,7 @@ function readMeta(db, key) {
|
|
|
3096
3131
|
function writeMeta(db, key, value) {
|
|
3097
3132
|
db.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(key, value);
|
|
3098
3133
|
}
|
|
3099
|
-
var SCHEMA_VERSION =
|
|
3134
|
+
var SCHEMA_VERSION = 3, INITIAL_SCHEMA = `
|
|
3100
3135
|
CREATE TABLE IF NOT EXISTS meta (
|
|
3101
3136
|
key TEXT PRIMARY KEY,
|
|
3102
3137
|
value TEXT NOT NULL
|
|
@@ -3258,6 +3293,55 @@ CREATE TABLE IF NOT EXISTS counters (
|
|
|
3258
3293
|
file_index_hits INTEGER NOT NULL DEFAULT 0,
|
|
3259
3294
|
file_index_misses INTEGER NOT NULL DEFAULT 0
|
|
3260
3295
|
);
|
|
3296
|
+
|
|
3297
|
+
-- Tool-output compression measurement (spec 21). One row per compression
|
|
3298
|
+
-- decision: either a compressed arm (compressed_tokens < original_tokens) or a
|
|
3299
|
+
-- holdout arm (left uncompressed for control, compressed_tokens = original_tokens).
|
|
3300
|
+
-- These are append-only telemetry, independent of session lifecycle, written at
|
|
3301
|
+
-- the moment a tool output is processed. New table → applied to existing DBs via
|
|
3302
|
+
-- IF NOT EXISTS on the next open.
|
|
3303
|
+
CREATE TABLE IF NOT EXISTS ledger_compressions (
|
|
3304
|
+
id TEXT PRIMARY KEY,
|
|
3305
|
+
created_at TEXT NOT NULL,
|
|
3306
|
+
tool_name TEXT NOT NULL,
|
|
3307
|
+
content_kind TEXT NOT NULL,
|
|
3308
|
+
original_tokens INTEGER NOT NULL DEFAULT 0,
|
|
3309
|
+
compressed_tokens INTEGER NOT NULL DEFAULT 0,
|
|
3310
|
+
holdout INTEGER NOT NULL DEFAULT 0,
|
|
3311
|
+
device_id TEXT NOT NULL
|
|
3312
|
+
);
|
|
3313
|
+
CREATE INDEX IF NOT EXISTS idx_ledger_compressions_created ON ledger_compressions(created_at);
|
|
3314
|
+
CREATE INDEX IF NOT EXISTS idx_ledger_compressions_device ON ledger_compressions(device_id);
|
|
3315
|
+
|
|
3316
|
+
-- Per-device compression aggregates, summed across devices like ledger_lifetime.
|
|
3317
|
+
-- measured_savings only credits compressed arms (holdout arms save nothing by
|
|
3318
|
+
-- construction), so the reported figure is a true measured delta, not an estimate.
|
|
3319
|
+
CREATE TABLE IF NOT EXISTS ledger_compression_lifetime (
|
|
3320
|
+
device_id TEXT PRIMARY KEY,
|
|
3321
|
+
total_events INTEGER NOT NULL DEFAULT 0,
|
|
3322
|
+
total_holdout_events INTEGER NOT NULL DEFAULT 0,
|
|
3323
|
+
total_original_tokens INTEGER NOT NULL DEFAULT 0,
|
|
3324
|
+
total_compressed_tokens INTEGER NOT NULL DEFAULT 0,
|
|
3325
|
+
total_measured_savings INTEGER NOT NULL DEFAULT 0
|
|
3326
|
+
);
|
|
3327
|
+
|
|
3328
|
+
-- Reversible-compression cache (spec 21 §Reversibility). When a tool output is
|
|
3329
|
+
-- compressed, the original is stored here keyed by a short retrieval token and
|
|
3330
|
+
-- embedded in the compressed result; "mink retrieve <token>" returns it
|
|
3331
|
+
-- byte-exact. Rows expire after the configured retention window; an expired or
|
|
3332
|
+
-- unknown token is a graceful miss. This is a local cache, not synced state, so
|
|
3333
|
+
-- (unlike other tables) it carries no merge semantics beyond device_id for audit.
|
|
3334
|
+
CREATE TABLE IF NOT EXISTS compression_cache (
|
|
3335
|
+
token TEXT PRIMARY KEY,
|
|
3336
|
+
created_at TEXT NOT NULL,
|
|
3337
|
+
expires_at TEXT NOT NULL,
|
|
3338
|
+
tool_name TEXT NOT NULL,
|
|
3339
|
+
content_kind TEXT NOT NULL,
|
|
3340
|
+
content TEXT NOT NULL,
|
|
3341
|
+
size_bytes INTEGER NOT NULL,
|
|
3342
|
+
device_id TEXT NOT NULL
|
|
3343
|
+
);
|
|
3344
|
+
CREATE INDEX IF NOT EXISTS idx_compression_cache_expires ON compression_cache(expires_at);
|
|
3261
3345
|
`;
|
|
3262
3346
|
|
|
3263
3347
|
// src/storage/migrate-json.ts
|
|
@@ -3641,7 +3725,8 @@ class TokenLedgerRepo {
|
|
|
3641
3725
|
snapshot() {
|
|
3642
3726
|
const ledger = {
|
|
3643
3727
|
lifetime: this.lifetime(),
|
|
3644
|
-
sessions: this.activeSessions()
|
|
3728
|
+
sessions: this.activeSessions(),
|
|
3729
|
+
compression: this.compressionLifetime()
|
|
3645
3730
|
};
|
|
3646
3731
|
const flagRows = this.db.prepare("SELECT pattern, detected_at, details FROM waste_flags ORDER BY detected_at").all();
|
|
3647
3732
|
if (flagRows.length > 0) {
|
|
@@ -3675,6 +3760,110 @@ class TokenLedgerRepo {
|
|
|
3675
3760
|
}
|
|
3676
3761
|
});
|
|
3677
3762
|
}
|
|
3763
|
+
recordCompression(event, deviceId = getOrCreateDeviceId()) {
|
|
3764
|
+
const id = event.id ?? crypto.randomUUID();
|
|
3765
|
+
const createdAt = event.createdAt ?? new Date().toISOString();
|
|
3766
|
+
const holdout = event.holdout ? 1 : 0;
|
|
3767
|
+
const savings = event.holdout ? 0 : Math.max(0, event.originalTokens - event.compressedTokens);
|
|
3768
|
+
this.db.transaction(() => {
|
|
3769
|
+
this.db.prepare(`
|
|
3770
|
+
INSERT OR REPLACE INTO ledger_compressions
|
|
3771
|
+
(id, created_at, tool_name, content_kind,
|
|
3772
|
+
original_tokens, compressed_tokens, holdout, device_id)
|
|
3773
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
3774
|
+
`).run(id, createdAt, event.toolName, event.contentKind, event.originalTokens, event.compressedTokens, holdout, deviceId);
|
|
3775
|
+
this.db.prepare(`
|
|
3776
|
+
INSERT INTO ledger_compression_lifetime
|
|
3777
|
+
(device_id, total_events, total_holdout_events,
|
|
3778
|
+
total_original_tokens, total_compressed_tokens, total_measured_savings)
|
|
3779
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
3780
|
+
ON CONFLICT(device_id) DO UPDATE SET
|
|
3781
|
+
total_events = ledger_compression_lifetime.total_events + excluded.total_events,
|
|
3782
|
+
total_holdout_events = ledger_compression_lifetime.total_holdout_events + excluded.total_holdout_events,
|
|
3783
|
+
total_original_tokens = ledger_compression_lifetime.total_original_tokens + excluded.total_original_tokens,
|
|
3784
|
+
total_compressed_tokens = ledger_compression_lifetime.total_compressed_tokens + excluded.total_compressed_tokens,
|
|
3785
|
+
total_measured_savings = ledger_compression_lifetime.total_measured_savings + excluded.total_measured_savings
|
|
3786
|
+
`).run(deviceId, 1, holdout, event.originalTokens, event.compressedTokens, savings);
|
|
3787
|
+
});
|
|
3788
|
+
}
|
|
3789
|
+
compressionLifetime() {
|
|
3790
|
+
const row = this.db.prepare(`
|
|
3791
|
+
SELECT
|
|
3792
|
+
COALESCE(SUM(total_events), 0) AS totalEvents,
|
|
3793
|
+
COALESCE(SUM(total_holdout_events), 0) AS totalHoldoutEvents,
|
|
3794
|
+
COALESCE(SUM(total_original_tokens), 0) AS totalOriginalTokens,
|
|
3795
|
+
COALESCE(SUM(total_compressed_tokens), 0) AS totalCompressedTokens,
|
|
3796
|
+
COALESCE(SUM(total_measured_savings), 0) AS totalMeasuredSavings
|
|
3797
|
+
FROM ledger_compression_lifetime
|
|
3798
|
+
`).get();
|
|
3799
|
+
return {
|
|
3800
|
+
totalEvents: Number(row?.totalEvents ?? 0),
|
|
3801
|
+
totalHoldoutEvents: Number(row?.totalHoldoutEvents ?? 0),
|
|
3802
|
+
totalOriginalTokens: Number(row?.totalOriginalTokens ?? 0),
|
|
3803
|
+
totalCompressedTokens: Number(row?.totalCompressedTokens ?? 0),
|
|
3804
|
+
totalMeasuredSavings: Number(row?.totalMeasuredSavings ?? 0)
|
|
3805
|
+
};
|
|
3806
|
+
}
|
|
3807
|
+
compressionEvents(limit = 100) {
|
|
3808
|
+
const rows = this.db.prepare(`
|
|
3809
|
+
SELECT id, created_at, tool_name, content_kind,
|
|
3810
|
+
original_tokens, compressed_tokens, holdout
|
|
3811
|
+
FROM ledger_compressions
|
|
3812
|
+
ORDER BY created_at DESC
|
|
3813
|
+
LIMIT ?
|
|
3814
|
+
`).all(limit);
|
|
3815
|
+
return rows.map((r) => ({
|
|
3816
|
+
id: String(r.id),
|
|
3817
|
+
createdAt: String(r.created_at),
|
|
3818
|
+
toolName: String(r.tool_name),
|
|
3819
|
+
contentKind: String(r.content_kind),
|
|
3820
|
+
originalTokens: Number(r.original_tokens),
|
|
3821
|
+
compressedTokens: Number(r.compressed_tokens),
|
|
3822
|
+
holdout: Number(r.holdout) === 1
|
|
3823
|
+
}));
|
|
3824
|
+
}
|
|
3825
|
+
compressionArms() {
|
|
3826
|
+
const row = this.db.prepare(`
|
|
3827
|
+
SELECT
|
|
3828
|
+
COALESCE(SUM(CASE WHEN holdout = 0 THEN 1 END), 0) AS cEvents,
|
|
3829
|
+
COALESCE(SUM(CASE WHEN holdout = 0 THEN original_tokens END), 0) AS cOriginal,
|
|
3830
|
+
COALESCE(SUM(CASE WHEN holdout = 0 THEN compressed_tokens END), 0) AS cCompressed,
|
|
3831
|
+
COALESCE(SUM(CASE WHEN holdout = 1 THEN 1 END), 0) AS hEvents,
|
|
3832
|
+
COALESCE(SUM(CASE WHEN holdout = 1 THEN original_tokens END), 0) AS hOriginal
|
|
3833
|
+
FROM ledger_compressions
|
|
3834
|
+
`).get();
|
|
3835
|
+
return {
|
|
3836
|
+
compressed: {
|
|
3837
|
+
events: Number(row?.cEvents ?? 0),
|
|
3838
|
+
originalTokens: Number(row?.cOriginal ?? 0),
|
|
3839
|
+
compressedTokens: Number(row?.cCompressed ?? 0)
|
|
3840
|
+
},
|
|
3841
|
+
holdout: {
|
|
3842
|
+
events: Number(row?.hEvents ?? 0),
|
|
3843
|
+
originalTokens: Number(row?.hOriginal ?? 0)
|
|
3844
|
+
}
|
|
3845
|
+
};
|
|
3846
|
+
}
|
|
3847
|
+
compressionBreakdown(dimension) {
|
|
3848
|
+
const rows = this.db.prepare(`
|
|
3849
|
+
SELECT
|
|
3850
|
+
${dimension} AS key,
|
|
3851
|
+
COUNT(*) AS events,
|
|
3852
|
+
COALESCE(SUM(original_tokens), 0) AS originalTokens,
|
|
3853
|
+
COALESCE(SUM(compressed_tokens), 0) AS compressedTokens,
|
|
3854
|
+
COALESCE(SUM(CASE WHEN holdout = 0 THEN original_tokens - compressed_tokens END), 0) AS savings
|
|
3855
|
+
FROM ledger_compressions
|
|
3856
|
+
GROUP BY ${dimension}
|
|
3857
|
+
ORDER BY savings DESC
|
|
3858
|
+
`).all();
|
|
3859
|
+
return rows.map((r) => ({
|
|
3860
|
+
key: String(r.key),
|
|
3861
|
+
events: Number(r.events),
|
|
3862
|
+
originalTokens: Number(r.originalTokens),
|
|
3863
|
+
compressedTokens: Number(r.compressedTokens),
|
|
3864
|
+
savings: Number(r.savings)
|
|
3865
|
+
}));
|
|
3866
|
+
}
|
|
3678
3867
|
insertSessionRow(summary, deviceId, archived) {
|
|
3679
3868
|
this.db.prepare(`
|
|
3680
3869
|
INSERT OR REPLACE INTO ledger_sessions
|
|
@@ -4449,6 +4638,28 @@ function estimateTokens2(content, filePath) {
|
|
|
4449
4638
|
}
|
|
4450
4639
|
return Math.ceil(content.length / ratio);
|
|
4451
4640
|
}
|
|
4641
|
+
function countTokens(text) {
|
|
4642
|
+
if (!text)
|
|
4643
|
+
return 0;
|
|
4644
|
+
const segments = text.match(/[A-Za-z]+|[0-9]+|[^A-Za-z0-9]/g);
|
|
4645
|
+
if (!segments)
|
|
4646
|
+
return 0;
|
|
4647
|
+
let tokens = 0;
|
|
4648
|
+
for (const seg of segments) {
|
|
4649
|
+
const first = seg.charCodeAt(0);
|
|
4650
|
+
if (first >= 65 && first <= 90 || first >= 97 && first <= 122) {
|
|
4651
|
+
tokens += Math.ceil(seg.length / 4);
|
|
4652
|
+
} else if (first >= 48 && first <= 57) {
|
|
4653
|
+
tokens += Math.ceil(seg.length / 3);
|
|
4654
|
+
} else if (seg === `
|
|
4655
|
+
`) {
|
|
4656
|
+
tokens += 1;
|
|
4657
|
+
} else if (seg === " " || seg === "\t" || seg === "\r") {} else {
|
|
4658
|
+
tokens += 1;
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4661
|
+
return tokens;
|
|
4662
|
+
}
|
|
4452
4663
|
var CODE_EXTENSIONS, PROSE_EXTENSIONS, BINARY_EXTENSIONS;
|
|
4453
4664
|
var init_token_estimate = __esm(() => {
|
|
4454
4665
|
CODE_EXTENSIONS = new Set([
|
|
@@ -4897,342 +5108,6 @@ var init_paths2 = __esm(() => {
|
|
|
4897
5108
|
MINK_ROOT2 = resolveMinkRoot2();
|
|
4898
5109
|
});
|
|
4899
5110
|
|
|
4900
|
-
// src/core/agent-detect.ts
|
|
4901
|
-
import { execSync as execSync5 } from "child_process";
|
|
4902
|
-
import { existsSync as existsSync18 } from "fs";
|
|
4903
|
-
import { join as join15 } from "path";
|
|
4904
|
-
import { homedir as homedir4 } from "os";
|
|
4905
|
-
function commandExists(bin) {
|
|
4906
|
-
try {
|
|
4907
|
-
const probe = process.platform === "win32" ? `where ${bin}` : `command -v ${bin}`;
|
|
4908
|
-
execSync5(probe, { stdio: "ignore" });
|
|
4909
|
-
return true;
|
|
4910
|
-
} catch {
|
|
4911
|
-
return false;
|
|
4912
|
-
}
|
|
4913
|
-
}
|
|
4914
|
-
function detectAgent(meta, cwd) {
|
|
4915
|
-
const signals = [];
|
|
4916
|
-
if (existsSync18(join15(cwd, meta.projectDir))) {
|
|
4917
|
-
signals.push(`project config (${meta.projectDir}/)`);
|
|
4918
|
-
}
|
|
4919
|
-
if (existsSync18(meta.globalDir)) {
|
|
4920
|
-
signals.push("global config");
|
|
4921
|
-
}
|
|
4922
|
-
if (commandExists(meta.bin)) {
|
|
4923
|
-
signals.push("on PATH");
|
|
4924
|
-
}
|
|
4925
|
-
return { ...meta, detected: signals.length > 0, signals };
|
|
4926
|
-
}
|
|
4927
|
-
function detectAgents(cwd) {
|
|
4928
|
-
return AGENTS.map((m) => detectAgent(m, cwd));
|
|
4929
|
-
}
|
|
4930
|
-
function resolveTargetsFromFlag(flag) {
|
|
4931
|
-
const normalized = flag.trim().toLowerCase();
|
|
4932
|
-
if (normalized === "all")
|
|
4933
|
-
return AGENTS.map((a) => a.id);
|
|
4934
|
-
const ids = normalized.split(",").map((s) => s.trim()).filter(Boolean);
|
|
4935
|
-
const valid = AGENTS.map((a) => a.id);
|
|
4936
|
-
const resolved = ids.filter((id) => valid.includes(id));
|
|
4937
|
-
return resolved;
|
|
4938
|
-
}
|
|
4939
|
-
var AGENTS;
|
|
4940
|
-
var init_agent_detect = __esm(() => {
|
|
4941
|
-
AGENTS = [
|
|
4942
|
-
{
|
|
4943
|
-
id: "claude",
|
|
4944
|
-
label: "Claude Code",
|
|
4945
|
-
projectDir: ".claude",
|
|
4946
|
-
globalDir: join15(homedir4(), ".claude"),
|
|
4947
|
-
bin: "claude"
|
|
4948
|
-
},
|
|
4949
|
-
{
|
|
4950
|
-
id: "pi",
|
|
4951
|
-
label: "Pi",
|
|
4952
|
-
projectDir: ".pi",
|
|
4953
|
-
globalDir: join15(homedir4(), ".pi"),
|
|
4954
|
-
bin: "pi"
|
|
4955
|
-
}
|
|
4956
|
-
];
|
|
4957
|
-
});
|
|
4958
|
-
|
|
4959
|
-
// src/core/agent-pi.ts
|
|
4960
|
-
import { join as join16, resolve as resolve2, dirname as dirname7 } from "path";
|
|
4961
|
-
import { existsSync as existsSync19, mkdirSync as mkdirSync8, copyFileSync, rmSync as rmSync2 } from "fs";
|
|
4962
|
-
function piExtensionPath(cwd) {
|
|
4963
|
-
return join16(cwd, ".pi", "extensions", "mink.ts");
|
|
4964
|
-
}
|
|
4965
|
-
function piGuidanceSkillPath(cwd) {
|
|
4966
|
-
return join16(cwd, ".pi", "skills", "mink", "SKILL.md");
|
|
4967
|
-
}
|
|
4968
|
-
function piNoteSkillPath(cwd) {
|
|
4969
|
-
return join16(cwd, ".pi", "skills", "mink-note", "SKILL.md");
|
|
4970
|
-
}
|
|
4971
|
-
function buildPiExtension(cliPath) {
|
|
4972
|
-
const isTsSource = cliPath.endsWith(".ts");
|
|
4973
|
-
const cmd = isTsSource ? "bun" : "mink";
|
|
4974
|
-
const baseArgs = isTsSource ? JSON.stringify(["run", cliPath]) : "[]";
|
|
4975
|
-
return `// AUTO-GENERATED by \`mink init\`. Do not edit — re-run \`mink init\` to refresh.
|
|
4976
|
-
//
|
|
4977
|
-
// Mink adapter for the Pi coding agent. Routes Pi lifecycle and tool events
|
|
4978
|
-
// into the \`mink\` CLI so Pi shares the same ~/.mink state, file index, ledger,
|
|
4979
|
-
// and wiki as every other assistant wired to this project.
|
|
4980
|
-
//
|
|
4981
|
-
// Field shapes confirmed against pi source (earendil-works/pi,
|
|
4982
|
-
// packages/coding-agent): read params {path, offset, limit}; write {path,
|
|
4983
|
-
// content}; edit {path, edits:[{oldText,newText}]} (with legacy file_path /
|
|
4984
|
-
// top-level oldText,newText). tool_call/tool_result events expose toolName,
|
|
4985
|
-
// toolCallId, input; tool_result also exposes content (a content-block array),
|
|
4986
|
-
// details, isError. Advisories are surfaced by returning a modified result from
|
|
4987
|
-
// the tool_result handler — the documented mechanism. pi.exec has no stdin, so
|
|
4988
|
-
// the canonical payload is piped to \`mink\` via a spawned child process. Every
|
|
4989
|
-
// host-API access is defensive: the adapter never throws into Pi or blocks a
|
|
4990
|
-
// tool — a failure degrades to "no advisory".
|
|
4991
|
-
|
|
4992
|
-
import { spawn } from "node:child_process";
|
|
4993
|
-
|
|
4994
|
-
const MINK_CMD = ${JSON.stringify(cmd)};
|
|
4995
|
-
const MINK_BASE_ARGS = ${baseArgs};
|
|
4996
|
-
const TIMEOUT_MS = 5000;
|
|
4997
|
-
|
|
4998
|
-
function runMink(sub, payload, cwd) {
|
|
4999
|
-
return new Promise((res) => {
|
|
5000
|
-
let done = false;
|
|
5001
|
-
const finish = (out) => {
|
|
5002
|
-
if (done) return;
|
|
5003
|
-
done = true;
|
|
5004
|
-
res(out);
|
|
5005
|
-
};
|
|
5006
|
-
try {
|
|
5007
|
-
const child = spawn(MINK_CMD, [...MINK_BASE_ARGS, sub], {
|
|
5008
|
-
cwd,
|
|
5009
|
-
stdio: ["pipe", "ignore", "pipe"],
|
|
5010
|
-
});
|
|
5011
|
-
let stderr = "";
|
|
5012
|
-
child.stderr?.on("data", (d) => {
|
|
5013
|
-
stderr += d.toString();
|
|
5014
|
-
});
|
|
5015
|
-
child.on("error", () => finish(""));
|
|
5016
|
-
child.on("close", () => finish(stderr.trim()));
|
|
5017
|
-
const timer = setTimeout(() => {
|
|
5018
|
-
try {
|
|
5019
|
-
child.kill();
|
|
5020
|
-
} catch {}
|
|
5021
|
-
finish("");
|
|
5022
|
-
}, TIMEOUT_MS);
|
|
5023
|
-
timer.unref?.();
|
|
5024
|
-
try {
|
|
5025
|
-
child.stdin?.end(payload ? JSON.stringify(payload) : "");
|
|
5026
|
-
} catch {}
|
|
5027
|
-
} catch {
|
|
5028
|
-
finish("");
|
|
5029
|
-
}
|
|
5030
|
-
});
|
|
5031
|
-
}
|
|
5032
|
-
|
|
5033
|
-
// Pi's edit tool takes an array of { oldText, newText } replacements (legacy
|
|
5034
|
-
// inputs may put oldText/newText/new_string at the top level). Concatenate the
|
|
5035
|
-
// replacement text so Mink's write-enforcement sees everything being written.
|
|
5036
|
-
function editNewText(input) {
|
|
5037
|
-
if (Array.isArray(input.edits)) {
|
|
5038
|
-
return input.edits
|
|
5039
|
-
.map((e) => e?.newText ?? e?.new_string ?? "")
|
|
5040
|
-
.filter(Boolean)
|
|
5041
|
-
.join("\\n");
|
|
5042
|
-
}
|
|
5043
|
-
return input.newText ?? input.new_string ?? input.replacement ?? "";
|
|
5044
|
-
}
|
|
5045
|
-
|
|
5046
|
-
// Resolve Pi's tool name + arguments to Mink's canonical operation. Only the
|
|
5047
|
-
// three file operations matter; anything else returns null and is ignored.
|
|
5048
|
-
function toolInfo(event) {
|
|
5049
|
-
const name = String(event?.toolName ?? event?.tool ?? event?.name ?? "").toLowerCase();
|
|
5050
|
-
const input = event?.input ?? event?.arguments ?? {};
|
|
5051
|
-
const filePath = input.path ?? input.file_path ?? input.filePath;
|
|
5052
|
-
if (!filePath) return null;
|
|
5053
|
-
if (name === "read") return { op: "read", filePath };
|
|
5054
|
-
if (name === "write") return { op: "write", filePath, content: input.content ?? input.text ?? "" };
|
|
5055
|
-
if (name === "edit") return { op: "edit", filePath, newString: editNewText(input) };
|
|
5056
|
-
return null;
|
|
5057
|
-
}
|
|
5058
|
-
|
|
5059
|
-
// A tool_result's content is an array of content blocks ({ type, text }); pull
|
|
5060
|
-
// the text out so Mink's post-read can estimate tokens from real content.
|
|
5061
|
-
function resultContent(event) {
|
|
5062
|
-
const c = event?.content;
|
|
5063
|
-
if (typeof c === "string") return c;
|
|
5064
|
-
if (Array.isArray(c)) {
|
|
5065
|
-
const text = c
|
|
5066
|
-
.map((b) => (typeof b === "string" ? b : b?.text ?? ""))
|
|
5067
|
-
.filter(Boolean)
|
|
5068
|
-
.join("\\n");
|
|
5069
|
-
return text || null;
|
|
5070
|
-
}
|
|
5071
|
-
return null;
|
|
5072
|
-
}
|
|
5073
|
-
|
|
5074
|
-
function prePayload(info) {
|
|
5075
|
-
if (info.op === "read")
|
|
5076
|
-
return { sub: "pre-read", payload: { tool_name: "Read", tool_input: { file_path: info.filePath } } };
|
|
5077
|
-
if (info.op === "write")
|
|
5078
|
-
return {
|
|
5079
|
-
sub: "pre-write",
|
|
5080
|
-
payload: { tool_name: "Write", tool_input: { file_path: info.filePath, content: info.content } },
|
|
5081
|
-
};
|
|
5082
|
-
return {
|
|
5083
|
-
sub: "pre-write",
|
|
5084
|
-
payload: { tool_name: "Edit", tool_input: { file_path: info.filePath, new_string: info.newString } },
|
|
5085
|
-
};
|
|
5086
|
-
}
|
|
5087
|
-
|
|
5088
|
-
function postPayload(info, content) {
|
|
5089
|
-
if (info.op === "read")
|
|
5090
|
-
return {
|
|
5091
|
-
sub: "post-read",
|
|
5092
|
-
payload: {
|
|
5093
|
-
tool_name: "Read",
|
|
5094
|
-
tool_input: { file_path: info.filePath },
|
|
5095
|
-
tool_output: content == null ? undefined : { content },
|
|
5096
|
-
},
|
|
5097
|
-
};
|
|
5098
|
-
if (info.op === "write")
|
|
5099
|
-
return {
|
|
5100
|
-
sub: "post-write",
|
|
5101
|
-
payload: { tool_name: "Write", tool_input: { file_path: info.filePath, content: info.content } },
|
|
5102
|
-
};
|
|
5103
|
-
return {
|
|
5104
|
-
sub: "post-write",
|
|
5105
|
-
payload: { tool_name: "Edit", tool_input: { file_path: info.filePath, new_string: info.newString } },
|
|
5106
|
-
};
|
|
5107
|
-
}
|
|
5108
|
-
|
|
5109
|
-
export default function (pi) {
|
|
5110
|
-
const cwd = pi?.ctx?.cwd || process.cwd();
|
|
5111
|
-
const pending = new Map();
|
|
5112
|
-
const keyOf = (event) => event?.toolCallId ?? event?.id ?? event?.callId ?? "";
|
|
5113
|
-
|
|
5114
|
-
pi.on?.("session_start", (event) => {
|
|
5115
|
-
// Skip hot-reloads so an extension reload mid-task doesn't reset the
|
|
5116
|
-
// ephemeral session state; every genuinely new/resumed session starts fresh.
|
|
5117
|
-
if (event?.reason === "reload") return;
|
|
5118
|
-
void runMink("session-start", null, cwd);
|
|
5119
|
-
});
|
|
5120
|
-
pi.on?.("agent_end", () => {
|
|
5121
|
-
void runMink("session-stop", null, cwd);
|
|
5122
|
-
});
|
|
5123
|
-
pi.on?.("session_shutdown", () => {
|
|
5124
|
-
void runMink("session-stop", null, cwd);
|
|
5125
|
-
});
|
|
5126
|
-
|
|
5127
|
-
pi.on?.("tool_call", async (event) => {
|
|
5128
|
-
const info = toolInfo(event);
|
|
5129
|
-
if (!info) return;
|
|
5130
|
-
const { sub, payload } = prePayload(info);
|
|
5131
|
-
const advisory = await runMink(sub, payload, cwd);
|
|
5132
|
-
if (advisory) pending.set(keyOf(event), advisory);
|
|
5133
|
-
});
|
|
5134
|
-
|
|
5135
|
-
pi.on?.("tool_result", async (event) => {
|
|
5136
|
-
const info = toolInfo(event);
|
|
5137
|
-
if (!info) return;
|
|
5138
|
-
const { sub, payload } = postPayload(info, resultContent(event));
|
|
5139
|
-
const post = await runMink(sub, payload, cwd);
|
|
5140
|
-
const pre = pending.get(keyOf(event)) ?? "";
|
|
5141
|
-
pending.delete(keyOf(event));
|
|
5142
|
-
const advisory = [pre, post].filter(Boolean).join("\\n");
|
|
5143
|
-
if (!advisory) return;
|
|
5144
|
-
|
|
5145
|
-
// Surface Mink's advisory into the model's context by appending a text
|
|
5146
|
-
// block to the tool result — the parity of Claude feeding hook stderr back.
|
|
5147
|
-
const base = Array.isArray(event.content)
|
|
5148
|
-
? event.content
|
|
5149
|
-
: typeof event.content === "string"
|
|
5150
|
-
? [{ type: "text", text: event.content }]
|
|
5151
|
-
: [];
|
|
5152
|
-
return {
|
|
5153
|
-
content: [...base, { type: "text", text: advisory }],
|
|
5154
|
-
details: event.details,
|
|
5155
|
-
isError: event.isError,
|
|
5156
|
-
};
|
|
5157
|
-
});
|
|
5158
|
-
}
|
|
5159
|
-
`;
|
|
5160
|
-
}
|
|
5161
|
-
function resolveSkillsSourceDir() {
|
|
5162
|
-
let dir = dirname7(new URL(import.meta.url).pathname);
|
|
5163
|
-
while (true) {
|
|
5164
|
-
if (existsSync19(join16(dir, "package.json")) && existsSync19(join16(dir, "skills"))) {
|
|
5165
|
-
return join16(dir, "skills");
|
|
5166
|
-
}
|
|
5167
|
-
const parent = dirname7(dir);
|
|
5168
|
-
if (parent === dir)
|
|
5169
|
-
break;
|
|
5170
|
-
dir = parent;
|
|
5171
|
-
}
|
|
5172
|
-
return resolve2(dirname7(new URL(import.meta.url).pathname), "../../skills");
|
|
5173
|
-
}
|
|
5174
|
-
function installPi(cwd, cliPath) {
|
|
5175
|
-
const extensionPath = piExtensionPath(cwd);
|
|
5176
|
-
mkdirSync8(dirname7(extensionPath), { recursive: true });
|
|
5177
|
-
atomicWriteText(extensionPath, buildPiExtension(cliPath));
|
|
5178
|
-
const guidancePath = piGuidanceSkillPath(cwd);
|
|
5179
|
-
mkdirSync8(dirname7(guidancePath), { recursive: true });
|
|
5180
|
-
atomicWriteText(guidancePath, PI_GUIDANCE_SKILL);
|
|
5181
|
-
let notePath = null;
|
|
5182
|
-
try {
|
|
5183
|
-
const src = join16(resolveSkillsSourceDir(), "mink-note", "SKILL.md");
|
|
5184
|
-
if (existsSync19(src)) {
|
|
5185
|
-
notePath = piNoteSkillPath(cwd);
|
|
5186
|
-
mkdirSync8(dirname7(notePath), { recursive: true });
|
|
5187
|
-
copyFileSync(src, notePath);
|
|
5188
|
-
}
|
|
5189
|
-
} catch {
|
|
5190
|
-
notePath = null;
|
|
5191
|
-
}
|
|
5192
|
-
return { extensionPath, guidancePath, notePath };
|
|
5193
|
-
}
|
|
5194
|
-
var PI_GUIDANCE_SKILL = `---
|
|
5195
|
-
name: mink
|
|
5196
|
-
description: Mink context management is active in this project. Read this to understand how Mink memory, write enforcement, and note capture work under Pi.
|
|
5197
|
-
---
|
|
5198
|
-
|
|
5199
|
-
# Mink — context management for this project
|
|
5200
|
-
|
|
5201
|
-
This project uses **Mink** (\`@drewpayment/mink\`) for cross-session context management.
|
|
5202
|
-
|
|
5203
|
-
## How it works
|
|
5204
|
-
- Mink runs automatically through a Pi extension at \`.pi/extensions/mink.ts\` that hooks session start/stop and every read/edit/write tool call.
|
|
5205
|
-
- All state lives in \`~/.mink/\` on the user's machine — **not** in this repository. Do not create or write to any in-repo state directory (no \`.wolf/\`, \`.mink/\`, etc.).
|
|
5206
|
-
- 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.
|
|
5207
|
-
- Mink shares one \`~/.mink/\` state across every assistant wired to this project, so history is unified whether the user runs Pi or another assistant.
|
|
5208
|
-
|
|
5209
|
-
## When to act on Mink
|
|
5210
|
-
- 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\`) — it captures into the user's \`~/.mink/\` vault.
|
|
5211
|
-
- If the extension surfaces a learning, past bug, or repeat-read warning in context, treat that as authoritative project memory and follow it.
|
|
5212
|
-
- The \`mink dashboard\` and \`mink agent\` commands are user tools — do not invoke them on the user's behalf.
|
|
5213
|
-
`;
|
|
5214
|
-
var init_agent_pi = __esm(() => {
|
|
5215
|
-
init_fs_utils();
|
|
5216
|
-
});
|
|
5217
|
-
|
|
5218
|
-
// src/core/prompt.ts
|
|
5219
|
-
import { createInterface } from "readline";
|
|
5220
|
-
function stdinIsInteractive() {
|
|
5221
|
-
const stdin = process.stdin;
|
|
5222
|
-
const stdout = process.stdout;
|
|
5223
|
-
return Boolean(stdin.isTTY) && Boolean(stdout.isTTY) && process.env.MINK_NO_PROMPT !== "1" && !process.env.CI;
|
|
5224
|
-
}
|
|
5225
|
-
function ask(question) {
|
|
5226
|
-
return new Promise((resolve3) => {
|
|
5227
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
5228
|
-
rl.question(question, (answer) => {
|
|
5229
|
-
rl.close();
|
|
5230
|
-
resolve3(answer);
|
|
5231
|
-
});
|
|
5232
|
-
});
|
|
5233
|
-
}
|
|
5234
|
-
var init_prompt = () => {};
|
|
5235
|
-
|
|
5236
5111
|
// src/core/backup.ts
|
|
5237
5112
|
var exports_backup = {};
|
|
5238
5113
|
__export(exports_backup, {
|
|
@@ -5241,14 +5116,14 @@ __export(exports_backup, {
|
|
|
5241
5116
|
createBackup: () => createBackup
|
|
5242
5117
|
});
|
|
5243
5118
|
import {
|
|
5244
|
-
mkdirSync as
|
|
5119
|
+
mkdirSync as mkdirSync8,
|
|
5245
5120
|
readdirSync as readdirSync7,
|
|
5246
5121
|
readFileSync as readFileSync12,
|
|
5247
5122
|
writeFileSync as writeFileSync5,
|
|
5248
|
-
existsSync as
|
|
5123
|
+
existsSync as existsSync18,
|
|
5249
5124
|
statSync as statSync7
|
|
5250
5125
|
} from "fs";
|
|
5251
|
-
import { join as
|
|
5126
|
+
import { join as join15 } from "path";
|
|
5252
5127
|
function formatTimestamp(date) {
|
|
5253
5128
|
const y = date.getFullYear();
|
|
5254
5129
|
const mo = String(date.getMonth() + 1).padStart(2, "0");
|
|
@@ -5260,15 +5135,15 @@ function formatTimestamp(date) {
|
|
|
5260
5135
|
return `${y}${mo}${d}-${h}${mi}${s}${ms}`;
|
|
5261
5136
|
}
|
|
5262
5137
|
function copyDirectoryFiles(srcDir, destDir, excludeDirs) {
|
|
5263
|
-
|
|
5138
|
+
mkdirSync8(destDir, { recursive: true });
|
|
5264
5139
|
const entries = readdirSync7(srcDir, { withFileTypes: true });
|
|
5265
5140
|
for (const entry of entries) {
|
|
5266
5141
|
if (entry.isDirectory()) {
|
|
5267
5142
|
if (excludeDirs.includes(entry.name))
|
|
5268
5143
|
continue;
|
|
5269
|
-
copyDirectoryFiles(
|
|
5144
|
+
copyDirectoryFiles(join15(srcDir, entry.name), join15(destDir, entry.name), excludeDirs);
|
|
5270
5145
|
} else if (entry.isFile()) {
|
|
5271
|
-
writeFileSync5(
|
|
5146
|
+
writeFileSync5(join15(destDir, entry.name), readFileSync12(join15(srcDir, entry.name)));
|
|
5272
5147
|
}
|
|
5273
5148
|
}
|
|
5274
5149
|
}
|
|
@@ -5277,25 +5152,25 @@ function createBackup(cwd) {
|
|
|
5277
5152
|
const dir = backupDirPath(cwd);
|
|
5278
5153
|
let name = base;
|
|
5279
5154
|
let suffix = 1;
|
|
5280
|
-
while (
|
|
5155
|
+
while (existsSync18(join15(dir, name))) {
|
|
5281
5156
|
name = `${base}-${suffix}`;
|
|
5282
5157
|
suffix++;
|
|
5283
5158
|
}
|
|
5284
5159
|
const src = projectDir(cwd);
|
|
5285
|
-
const dest =
|
|
5160
|
+
const dest = join15(dir, name);
|
|
5286
5161
|
copyDirectoryFiles(src, dest, ["backups"]);
|
|
5287
5162
|
return name;
|
|
5288
5163
|
}
|
|
5289
5164
|
function listBackups(cwd) {
|
|
5290
5165
|
const dir = backupDirPath(cwd);
|
|
5291
|
-
if (!
|
|
5166
|
+
if (!existsSync18(dir))
|
|
5292
5167
|
return [];
|
|
5293
5168
|
const entries = readdirSync7(dir, { withFileTypes: true });
|
|
5294
5169
|
const backups = [];
|
|
5295
5170
|
for (const entry of entries) {
|
|
5296
5171
|
if (!entry.isDirectory() || !entry.name.startsWith("backup-"))
|
|
5297
5172
|
continue;
|
|
5298
|
-
const backupPath =
|
|
5173
|
+
const backupPath = join15(dir, entry.name);
|
|
5299
5174
|
const match = entry.name.match(/^backup-(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})(\d{3})?(?:-\d+)?$/);
|
|
5300
5175
|
let timestamp;
|
|
5301
5176
|
if (match) {
|
|
@@ -5318,8 +5193,8 @@ function listBackups(cwd) {
|
|
|
5318
5193
|
return backups;
|
|
5319
5194
|
}
|
|
5320
5195
|
function restoreBackup(cwd, backupName) {
|
|
5321
|
-
const backupPath =
|
|
5322
|
-
if (!
|
|
5196
|
+
const backupPath = join15(backupDirPath(cwd), backupName);
|
|
5197
|
+
if (!existsSync18(backupPath)) {
|
|
5323
5198
|
throw new Error(`backup not found: ${backupName}`);
|
|
5324
5199
|
}
|
|
5325
5200
|
createBackup(cwd);
|
|
@@ -5331,7 +5206,7 @@ var init_backup = __esm(() => {
|
|
|
5331
5206
|
|
|
5332
5207
|
// src/core/scanner.ts
|
|
5333
5208
|
import { readdirSync as readdirSync8, statSync as statSync8 } from "fs";
|
|
5334
|
-
import { join as
|
|
5209
|
+
import { join as join16, relative } from "path";
|
|
5335
5210
|
function matchesPattern(name, pattern) {
|
|
5336
5211
|
if (pattern.includes("*")) {
|
|
5337
5212
|
const regex = new RegExp("^" + pattern.replace(/\./g, "\\.").replace(/\*/g, ".*") + "$");
|
|
@@ -5355,14 +5230,14 @@ function walkDirectory(dir, projectRoot, excludes, results) {
|
|
|
5355
5230
|
if (entry.isDirectory()) {
|
|
5356
5231
|
if (isExcluded(entry.name, excludes))
|
|
5357
5232
|
continue;
|
|
5358
|
-
walkDirectory(
|
|
5233
|
+
walkDirectory(join16(dir, entry.name), projectRoot, excludes, results);
|
|
5359
5234
|
continue;
|
|
5360
5235
|
}
|
|
5361
5236
|
if (entry.isFile()) {
|
|
5362
5237
|
if (isExcluded(entry.name, excludes))
|
|
5363
5238
|
continue;
|
|
5364
5239
|
try {
|
|
5365
|
-
const fullPath =
|
|
5240
|
+
const fullPath = join16(dir, entry.name);
|
|
5366
5241
|
const stat = statSync8(fullPath);
|
|
5367
5242
|
results.push({
|
|
5368
5243
|
relativePath: relative(projectRoot, fullPath),
|
|
@@ -5785,7 +5660,7 @@ __export(exports_scan, {
|
|
|
5785
5660
|
});
|
|
5786
5661
|
import { readFileSync as readFileSync13 } from "fs";
|
|
5787
5662
|
import { createHash as createHash2 } from "crypto";
|
|
5788
|
-
import { join as
|
|
5663
|
+
import { join as join17, relative as relative2 } from "path";
|
|
5789
5664
|
function configRelativePath(cfgPath, cwd) {
|
|
5790
5665
|
const rel = relative2(cwd, cfgPath);
|
|
5791
5666
|
return rel.startsWith("..") ? cfgPath : rel;
|
|
@@ -5836,7 +5711,7 @@ function scan(cwd, options) {
|
|
|
5836
5711
|
if (!stalePaths.has(file.relativePath)) {
|
|
5837
5712
|
continue;
|
|
5838
5713
|
}
|
|
5839
|
-
const fullPath =
|
|
5714
|
+
const fullPath = join17(cwd, file.relativePath);
|
|
5840
5715
|
let content;
|
|
5841
5716
|
try {
|
|
5842
5717
|
content = readFileSync13(fullPath, "utf-8");
|
|
@@ -5925,10 +5800,10 @@ __export(exports_seed, {
|
|
|
5925
5800
|
parseGoMod: () => parseGoMod,
|
|
5926
5801
|
parseCargoToml: () => parseCargoToml
|
|
5927
5802
|
});
|
|
5928
|
-
import { basename as basename4, join as
|
|
5929
|
-
import { readFileSync as readFileSync14, existsSync as
|
|
5803
|
+
import { basename as basename4, join as join18 } from "path";
|
|
5804
|
+
import { readFileSync as readFileSync14, existsSync as existsSync19 } from "fs";
|
|
5930
5805
|
function readFile(filePath) {
|
|
5931
|
-
if (!
|
|
5806
|
+
if (!existsSync19(filePath))
|
|
5932
5807
|
return null;
|
|
5933
5808
|
try {
|
|
5934
5809
|
return readFileSync14(filePath, "utf-8");
|
|
@@ -6021,10 +5896,10 @@ function parseGoMod(filePath) {
|
|
|
6021
5896
|
}
|
|
6022
5897
|
function seedLearningMemory(projectRoot) {
|
|
6023
5898
|
const parsers = [
|
|
6024
|
-
() => parsePackageJson(
|
|
6025
|
-
() => parsePyprojectToml(
|
|
6026
|
-
() => parseCargoToml(
|
|
6027
|
-
() => parseGoMod(
|
|
5899
|
+
() => parsePackageJson(join18(projectRoot, "package.json")),
|
|
5900
|
+
() => parsePyprojectToml(join18(projectRoot, "pyproject.toml")),
|
|
5901
|
+
() => parseCargoToml(join18(projectRoot, "Cargo.toml")),
|
|
5902
|
+
() => parseGoMod(join18(projectRoot, "go.mod"))
|
|
6028
5903
|
];
|
|
6029
5904
|
const infos = parsers.map((fn) => fn()).filter((info) => info !== null);
|
|
6030
5905
|
const projectName = infos.find((i) => i.projectName)?.projectName ?? basename4(projectRoot);
|
|
@@ -6102,37 +5977,34 @@ var init_seed = __esm(() => {
|
|
|
6102
5977
|
var exports_init = {};
|
|
6103
5978
|
__export(exports_init, {
|
|
6104
5979
|
writeMinkRule: () => writeMinkRule,
|
|
6105
|
-
resolveTargetsFromFlag: () => resolveTargetsFromFlag,
|
|
6106
|
-
resolveTargets: () => resolveTargets,
|
|
6107
5980
|
resolveCliPathFrom: () => resolveCliPathFrom,
|
|
6108
5981
|
resolveCliPath: () => resolveCliPath,
|
|
6109
5982
|
mergeHooksIntoSettings: () => mergeHooksIntoSettings,
|
|
6110
|
-
installClaude: () => installClaude,
|
|
6111
5983
|
init: () => init,
|
|
6112
5984
|
detectRuntime: () => detectRuntime,
|
|
6113
5985
|
buildHooksConfig: () => buildHooksConfig
|
|
6114
5986
|
});
|
|
6115
|
-
import { execSync as
|
|
6116
|
-
import { mkdirSync as
|
|
6117
|
-
import { resolve as
|
|
5987
|
+
import { execSync as execSync5 } from "child_process";
|
|
5988
|
+
import { mkdirSync as mkdirSync9, existsSync as existsSync20 } from "fs";
|
|
5989
|
+
import { resolve as resolve2, dirname as dirname7, basename as basename5, join as join19 } from "path";
|
|
6118
5990
|
function detectRuntime() {
|
|
6119
5991
|
try {
|
|
6120
|
-
|
|
5992
|
+
execSync5("bun --version", { stdio: "ignore" });
|
|
6121
5993
|
return "bun";
|
|
6122
5994
|
} catch {
|
|
6123
5995
|
return "node";
|
|
6124
5996
|
}
|
|
6125
5997
|
}
|
|
6126
5998
|
function resolveCliPathFrom(selfPath) {
|
|
6127
|
-
const selfDir =
|
|
5999
|
+
const selfDir = dirname7(selfPath);
|
|
6128
6000
|
if (selfPath.endsWith("dist/cli.js") || selfPath.endsWith("dist/cli.bun.js") || selfPath.endsWith("dist/cli.node.js")) {
|
|
6129
|
-
return
|
|
6001
|
+
return join19(selfDir, "cli.js");
|
|
6130
6002
|
}
|
|
6131
|
-
const packageRoot =
|
|
6132
|
-
const distShim =
|
|
6133
|
-
if (
|
|
6003
|
+
const packageRoot = resolve2(selfDir, "..", "..");
|
|
6004
|
+
const distShim = join19(packageRoot, "dist", "cli.js");
|
|
6005
|
+
if (existsSync20(distShim))
|
|
6134
6006
|
return distShim;
|
|
6135
|
-
return
|
|
6007
|
+
return join19(packageRoot, "src", "cli.ts");
|
|
6136
6008
|
}
|
|
6137
6009
|
function resolveCliPath() {
|
|
6138
6010
|
return resolveCliPathFrom(new URL(import.meta.url).pathname);
|
|
@@ -6152,12 +6024,14 @@ function buildHooksConfig(cliPath) {
|
|
|
6152
6024
|
PostToolUse: [
|
|
6153
6025
|
{ matcher: "Read", hooks: hook(`${prefix} post-read`) },
|
|
6154
6026
|
{ matcher: "Edit", hooks: hook(`${prefix} post-write`) },
|
|
6155
|
-
{ matcher: "Write", hooks: hook(`${prefix} post-write`) }
|
|
6027
|
+
{ matcher: "Write", hooks: hook(`${prefix} post-write`) },
|
|
6028
|
+
{ matcher: "Bash", hooks: hook(`${prefix} post-tool`) },
|
|
6029
|
+
{ matcher: "Grep", hooks: hook(`${prefix} post-tool`) }
|
|
6156
6030
|
]
|
|
6157
6031
|
};
|
|
6158
6032
|
}
|
|
6159
6033
|
function isMinkCommand(cmd) {
|
|
6160
|
-
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");
|
|
6034
|
+
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");
|
|
6161
6035
|
if (!hasMinkSubcommand)
|
|
6162
6036
|
return false;
|
|
6163
6037
|
if (/(^|\/|\s)mink\s/.test(cmd))
|
|
@@ -6174,13 +6048,13 @@ function isMinkHook(entry) {
|
|
|
6174
6048
|
return false;
|
|
6175
6049
|
}
|
|
6176
6050
|
function writeMinkRule(cwd) {
|
|
6177
|
-
const rulePath =
|
|
6178
|
-
|
|
6051
|
+
const rulePath = resolve2(cwd, ".claude", "rules", "mink.md");
|
|
6052
|
+
mkdirSync9(dirname7(rulePath), { recursive: true });
|
|
6179
6053
|
atomicWriteText(rulePath, MINK_RULE_CONTENT);
|
|
6180
6054
|
return rulePath;
|
|
6181
6055
|
}
|
|
6182
6056
|
function mergeHooksIntoSettings(settingsPath, newHooks) {
|
|
6183
|
-
|
|
6057
|
+
mkdirSync9(dirname7(settingsPath), { recursive: true });
|
|
6184
6058
|
const existing = safeReadJson(settingsPath) ?? {};
|
|
6185
6059
|
const existingHooks = existing.hooks ?? {};
|
|
6186
6060
|
for (const [event, entries] of Object.entries(newHooks)) {
|
|
@@ -6191,46 +6065,17 @@ function mergeHooksIntoSettings(settingsPath, newHooks) {
|
|
|
6191
6065
|
existing.hooks = existingHooks;
|
|
6192
6066
|
atomicWriteJson(settingsPath, existing);
|
|
6193
6067
|
}
|
|
6194
|
-
function installClaude(cwd, cliPath) {
|
|
6195
|
-
const settingsPath = resolve3(cwd, ".claude", "settings.json");
|
|
6196
|
-
mergeHooksIntoSettings(settingsPath, buildHooksConfig(cliPath));
|
|
6197
|
-
const rulePath = writeMinkRule(cwd);
|
|
6198
|
-
return { settingsPath, rulePath };
|
|
6199
|
-
}
|
|
6200
|
-
async function resolveTargets(cwd, opts) {
|
|
6201
|
-
if (opts.targets && opts.targets.length > 0)
|
|
6202
|
-
return opts.targets;
|
|
6203
|
-
const detected = detectAgents(cwd);
|
|
6204
|
-
const detectedIds = detected.filter((a) => a.detected).map((a) => a.id);
|
|
6205
|
-
if (opts.interactive && stdinIsInteractive()) {
|
|
6206
|
-
return promptForAgents(detected, detectedIds);
|
|
6207
|
-
}
|
|
6208
|
-
return detectedIds.length > 0 ? detectedIds : ["claude"];
|
|
6209
|
-
}
|
|
6210
|
-
async function promptForAgents(detected, defaults) {
|
|
6211
|
-
const fallback = defaults.length > 0 ? defaults : ["claude"];
|
|
6212
|
-
console.log("Which assistant(s) should Mink work with?");
|
|
6213
|
-
detected.forEach((a, i) => {
|
|
6214
|
-
const tag = a.detected ? ` (detected — ${a.signals.join(", ")})` : "";
|
|
6215
|
-
console.log(` ${i + 1}) ${a.label}${tag}`);
|
|
6216
|
-
});
|
|
6217
|
-
const answer = (await ask(`Enter numbers (comma-separated), 'a' for all [default: ${fallback.join(", ")}]: `)).trim().toLowerCase();
|
|
6218
|
-
if (answer === "")
|
|
6219
|
-
return fallback;
|
|
6220
|
-
if (answer === "a" || answer === "all")
|
|
6221
|
-
return AGENTS.map((a) => a.id);
|
|
6222
|
-
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);
|
|
6223
|
-
return picked.length > 0 ? picked : fallback;
|
|
6224
|
-
}
|
|
6225
6068
|
function isExistingInstallation(cwd) {
|
|
6226
6069
|
const dir = projectDir(cwd);
|
|
6227
|
-
if (!
|
|
6070
|
+
if (!existsSync20(dir))
|
|
6228
6071
|
return false;
|
|
6229
|
-
return
|
|
6072
|
+
return existsSync20(join19(dir, "file-index.json"));
|
|
6230
6073
|
}
|
|
6231
|
-
async function init(cwd
|
|
6074
|
+
async function init(cwd) {
|
|
6232
6075
|
const runtime = detectRuntime();
|
|
6233
6076
|
const cliPath = resolveCliPath();
|
|
6077
|
+
const hooks = buildHooksConfig(cliPath);
|
|
6078
|
+
const settingsPath = resolve2(cwd, ".claude", "settings.json");
|
|
6234
6079
|
const dir = projectDir(cwd);
|
|
6235
6080
|
const upgrading = isExistingInstallation(cwd);
|
|
6236
6081
|
if (upgrading) {
|
|
@@ -6239,22 +6084,9 @@ async function init(cwd, opts = {}) {
|
|
|
6239
6084
|
const backupName = createBackup2(cwd);
|
|
6240
6085
|
console.log(` backup: ${backupName}`);
|
|
6241
6086
|
}
|
|
6242
|
-
|
|
6243
|
-
const
|
|
6244
|
-
|
|
6245
|
-
if (target === "claude") {
|
|
6246
|
-
const { settingsPath, rulePath } = installClaude(cwd, cliPath);
|
|
6247
|
-
wired.claude = [`hooks: ${settingsPath}`, `rule: ${rulePath}`];
|
|
6248
|
-
} else if (target === "pi") {
|
|
6249
|
-
const r = installPi(cwd, cliPath);
|
|
6250
|
-
wired.pi = [
|
|
6251
|
-
`extension: ${r.extensionPath}`,
|
|
6252
|
-
`guidance: ${r.guidancePath}`,
|
|
6253
|
-
...r.notePath ? [`note skill: ${r.notePath}`] : []
|
|
6254
|
-
];
|
|
6255
|
-
}
|
|
6256
|
-
}
|
|
6257
|
-
mkdirSync10(dir, { recursive: true });
|
|
6087
|
+
mergeHooksIntoSettings(settingsPath, hooks);
|
|
6088
|
+
const rulePath = writeMinkRule(cwd);
|
|
6089
|
+
mkdirSync9(dir, { recursive: true });
|
|
6258
6090
|
const identity = resolveProjectIdentity(cwd);
|
|
6259
6091
|
const projectId = identity.id;
|
|
6260
6092
|
const isNotesProject = isWikiEnabled() && isVaultInitialized() && isInsideVault(cwd);
|
|
@@ -6262,8 +6094,6 @@ async function init(cwd, opts = {}) {
|
|
|
6262
6094
|
const existingMeta = safeReadJson(metaPath);
|
|
6263
6095
|
const deviceId = getOrCreateDeviceId();
|
|
6264
6096
|
const existingPathsByDevice = existingMeta?.pathsByDevice && typeof existingMeta.pathsByDevice === "object" && !Array.isArray(existingMeta.pathsByDevice) ? existingMeta.pathsByDevice : {};
|
|
6265
|
-
const priorAgents = Array.isArray(existingMeta?.agents) ? existingMeta.agents : [];
|
|
6266
|
-
const agents = Array.from(new Set([...priorAgents, ...targets]));
|
|
6267
6097
|
atomicWriteJson(metaPath, {
|
|
6268
6098
|
...existingMeta ?? {},
|
|
6269
6099
|
cwd,
|
|
@@ -6271,29 +6101,20 @@ async function init(cwd, opts = {}) {
|
|
|
6271
6101
|
initTimestamp: existingMeta?.initTimestamp ?? new Date().toISOString(),
|
|
6272
6102
|
version: "0.1.0",
|
|
6273
6103
|
pathsByDevice: { ...existingPathsByDevice, [deviceId]: cwd },
|
|
6274
|
-
agents,
|
|
6275
6104
|
...isNotesProject ? { projectType: "notes" } : {}
|
|
6276
6105
|
});
|
|
6277
|
-
const printWiring = () => {
|
|
6278
|
-
for (const id of Object.keys(wired)) {
|
|
6279
|
-
const label = AGENTS.find((a) => a.id === id)?.label ?? id;
|
|
6280
|
-
console.log(` ${label}:`);
|
|
6281
|
-
for (const line of wired[id])
|
|
6282
|
-
console.log(` ${line}`);
|
|
6283
|
-
}
|
|
6284
|
-
};
|
|
6285
6106
|
if (upgrading) {
|
|
6286
6107
|
console.log(`[mink] upgrade complete`);
|
|
6287
6108
|
console.log(` project: ${projectId}`);
|
|
6288
|
-
console.log(`
|
|
6289
|
-
|
|
6109
|
+
console.log(` hooks: ${settingsPath}`);
|
|
6110
|
+
console.log(` rule: ${rulePath}`);
|
|
6290
6111
|
} else {
|
|
6291
6112
|
console.log(`[mink] initialized`);
|
|
6292
6113
|
console.log(` project: ${projectId} (${identity.source})`);
|
|
6293
6114
|
console.log(` state: ${dir}`);
|
|
6294
6115
|
console.log(` runtime: ${runtime}`);
|
|
6295
|
-
console.log(`
|
|
6296
|
-
|
|
6116
|
+
console.log(` hooks: ${settingsPath}`);
|
|
6117
|
+
console.log(` rule: ${rulePath}`);
|
|
6297
6118
|
}
|
|
6298
6119
|
if (identity.source === "path-derived") {
|
|
6299
6120
|
const root = getRepoRoot(cwd);
|
|
@@ -6305,7 +6126,7 @@ async function init(cwd, opts = {}) {
|
|
|
6305
6126
|
scan2(cwd, { check: false });
|
|
6306
6127
|
const { learningMemoryPath: learningMemoryPath3 } = await Promise.resolve().then(() => (init_paths(), exports_paths));
|
|
6307
6128
|
const memPath = learningMemoryPath3(cwd);
|
|
6308
|
-
if (!
|
|
6129
|
+
if (!existsSync20(memPath)) {
|
|
6309
6130
|
const { seedLearningMemory: seedLearningMemory2 } = await Promise.resolve().then(() => (init_seed(), exports_seed));
|
|
6310
6131
|
const { serializeLearningMemory: serializeLearningMemory2 } = await Promise.resolve().then(() => (init_learning_memory(), exports_learning_memory));
|
|
6311
6132
|
const mem = seedLearningMemory2(cwd);
|
|
@@ -6314,8 +6135,8 @@ async function init(cwd, opts = {}) {
|
|
|
6314
6135
|
if (isWikiEnabled() && isVaultInitialized() && !isNotesProject) {
|
|
6315
6136
|
try {
|
|
6316
6137
|
const projectSlug = basename5(cwd);
|
|
6317
|
-
const overviewPath =
|
|
6318
|
-
if (!
|
|
6138
|
+
const overviewPath = join19(vaultProjects(projectSlug), "overview.md");
|
|
6139
|
+
if (!existsSync20(overviewPath)) {
|
|
6319
6140
|
const now = new Date().toISOString();
|
|
6320
6141
|
const overview = [
|
|
6321
6142
|
`---`,
|
|
@@ -6367,9 +6188,6 @@ var init_init = __esm(() => {
|
|
|
6367
6188
|
init_device();
|
|
6368
6189
|
init_git_identity();
|
|
6369
6190
|
init_vault();
|
|
6370
|
-
init_agent_detect();
|
|
6371
|
-
init_agent_pi();
|
|
6372
|
-
init_prompt();
|
|
6373
6191
|
});
|
|
6374
6192
|
|
|
6375
6193
|
// src/repositories/counters-repo.ts
|
|
@@ -6444,12 +6262,12 @@ var init_state_counters = __esm(() => {
|
|
|
6444
6262
|
});
|
|
6445
6263
|
|
|
6446
6264
|
// src/core/channel-templates.ts
|
|
6447
|
-
import { join as
|
|
6448
|
-
import { existsSync as
|
|
6265
|
+
import { join as join20 } from "path";
|
|
6266
|
+
import { existsSync as existsSync21, writeFileSync as writeFileSync6, mkdirSync as mkdirSync10 } from "fs";
|
|
6449
6267
|
function writeCompanionClaudeMd(vaultPath, overwrite = false) {
|
|
6450
|
-
|
|
6451
|
-
const claudeMdPath =
|
|
6452
|
-
if (
|
|
6268
|
+
mkdirSync10(vaultPath, { recursive: true });
|
|
6269
|
+
const claudeMdPath = join20(vaultPath, "CLAUDE.md");
|
|
6270
|
+
if (existsSync21(claudeMdPath) && !overwrite) {
|
|
6453
6271
|
return false;
|
|
6454
6272
|
}
|
|
6455
6273
|
writeFileSync6(claudeMdPath, COMPANION_CLAUDE_MD);
|
|
@@ -6601,8 +6419,8 @@ mink wiki rebuild-index
|
|
|
6601
6419
|
var init_channel_templates = () => {};
|
|
6602
6420
|
|
|
6603
6421
|
// src/core/channel-process.ts
|
|
6604
|
-
import { readFileSync as readFileSync15, writeFileSync as writeFileSync7, unlinkSync as unlinkSync3, mkdirSync as
|
|
6605
|
-
import { dirname as
|
|
6422
|
+
import { readFileSync as readFileSync15, writeFileSync as writeFileSync7, unlinkSync as unlinkSync3, mkdirSync as mkdirSync11, existsSync as existsSync22 } from "fs";
|
|
6423
|
+
import { dirname as dirname8, join as join21 } from "path";
|
|
6606
6424
|
import { spawnSync } from "child_process";
|
|
6607
6425
|
function readChannelPidFile() {
|
|
6608
6426
|
try {
|
|
@@ -6618,7 +6436,7 @@ function readChannelPidFile() {
|
|
|
6618
6436
|
}
|
|
6619
6437
|
function writeChannelPidFile(data) {
|
|
6620
6438
|
const pidPath = channelPidPath();
|
|
6621
|
-
|
|
6439
|
+
mkdirSync11(dirname8(pidPath), { recursive: true });
|
|
6622
6440
|
writeFileSync7(pidPath, JSON.stringify(data, null, 2));
|
|
6623
6441
|
}
|
|
6624
6442
|
function removeChannelPidFile() {
|
|
@@ -6748,12 +6566,12 @@ function getChannelLogs() {
|
|
|
6748
6566
|
return null;
|
|
6749
6567
|
if (!screenSessionExists(pidData.session))
|
|
6750
6568
|
return null;
|
|
6751
|
-
const tmpPath =
|
|
6569
|
+
const tmpPath = join21(minkRoot(), `.channel-capture-${Date.now()}-${process.pid}.txt`);
|
|
6752
6570
|
const result = spawnSync("screen", ["-S", pidData.session, "-X", "hardcopy", "-h", tmpPath], { stdio: "ignore" });
|
|
6753
6571
|
if (result.status !== 0)
|
|
6754
6572
|
return null;
|
|
6755
6573
|
for (let i = 0;i < 20; i++) {
|
|
6756
|
-
if (
|
|
6574
|
+
if (existsSync22(tmpPath))
|
|
6757
6575
|
break;
|
|
6758
6576
|
const delayUntil = Date.now() + 50;
|
|
6759
6577
|
while (Date.now() < delayUntil) {}
|
|
@@ -6857,7 +6675,7 @@ async function runtimeServe(opts) {
|
|
|
6857
6675
|
}
|
|
6858
6676
|
const { createServer } = await import("node:http");
|
|
6859
6677
|
const { Readable } = await import("node:stream");
|
|
6860
|
-
return new Promise((
|
|
6678
|
+
return new Promise((resolve3) => {
|
|
6861
6679
|
const httpServer = createServer(async (req, res) => {
|
|
6862
6680
|
const url = `http://${opts.hostname}:${opts.port}${req.url ?? "/"}`;
|
|
6863
6681
|
const headers = new Headers;
|
|
@@ -6916,7 +6734,7 @@ async function runtimeServe(opts) {
|
|
|
6916
6734
|
httpServer.listen(opts.port, opts.hostname, () => {
|
|
6917
6735
|
const addr = httpServer.address();
|
|
6918
6736
|
const boundPort = typeof addr === "object" && addr ? addr.port : opts.port;
|
|
6919
|
-
|
|
6737
|
+
resolve3({
|
|
6920
6738
|
port: boundPort,
|
|
6921
6739
|
stop: (close) => {
|
|
6922
6740
|
if (close)
|
|
@@ -6934,8 +6752,8 @@ var init_runtime = __esm(() => {
|
|
|
6934
6752
|
|
|
6935
6753
|
// src/core/daemon.ts
|
|
6936
6754
|
import { readFileSync as readFileSync16, writeFileSync as writeFileSync8, unlinkSync as unlinkSync4, openSync } from "fs";
|
|
6937
|
-
import { mkdirSync as
|
|
6938
|
-
import { dirname as
|
|
6755
|
+
import { mkdirSync as mkdirSync12 } from "fs";
|
|
6756
|
+
import { dirname as dirname9, resolve as resolve3 } from "path";
|
|
6939
6757
|
function readPidFile() {
|
|
6940
6758
|
try {
|
|
6941
6759
|
const raw = readFileSync16(schedulerPidPath(), "utf-8");
|
|
@@ -6950,7 +6768,7 @@ function readPidFile() {
|
|
|
6950
6768
|
}
|
|
6951
6769
|
function writePidFile(data) {
|
|
6952
6770
|
const pidPath = schedulerPidPath();
|
|
6953
|
-
|
|
6771
|
+
mkdirSync12(dirname9(pidPath), { recursive: true });
|
|
6954
6772
|
writeFileSync8(pidPath, JSON.stringify(data, null, 2));
|
|
6955
6773
|
}
|
|
6956
6774
|
function removePidFile() {
|
|
@@ -6975,10 +6793,10 @@ function startDaemon(cwd) {
|
|
|
6975
6793
|
if (existing) {
|
|
6976
6794
|
removePidFile();
|
|
6977
6795
|
}
|
|
6978
|
-
const __dir =
|
|
6979
|
-
const cliPath = process.argv[1] ??
|
|
6796
|
+
const __dir = dirname9(new URL(import.meta.url).pathname);
|
|
6797
|
+
const cliPath = process.argv[1] ?? resolve3(__dir, "../cli.ts");
|
|
6980
6798
|
const logPath = schedulerLogPath();
|
|
6981
|
-
|
|
6799
|
+
mkdirSync12(dirname9(logPath), { recursive: true });
|
|
6982
6800
|
const logFd = openSync(logPath, "a");
|
|
6983
6801
|
const proc = runtimeSpawn(["bun", "run", cliPath, "cron", "__daemon"], {
|
|
6984
6802
|
cwd,
|
|
@@ -7092,9 +6910,9 @@ var exports_status = {};
|
|
|
7092
6910
|
__export(exports_status, {
|
|
7093
6911
|
status: () => status
|
|
7094
6912
|
});
|
|
7095
|
-
import { existsSync as
|
|
6913
|
+
import { existsSync as existsSync24, readFileSync as readFileSync17, statSync as statSync9 } from "fs";
|
|
7096
6914
|
function checkJsonFile(name, filePath, validator) {
|
|
7097
|
-
if (!
|
|
6915
|
+
if (!existsSync24(filePath))
|
|
7098
6916
|
return { name, path: filePath, status: "missing" };
|
|
7099
6917
|
const data = safeReadJson(filePath);
|
|
7100
6918
|
if (data === null)
|
|
@@ -7104,7 +6922,7 @@ function checkJsonFile(name, filePath, validator) {
|
|
|
7104
6922
|
return { name, path: filePath, status: "ok" };
|
|
7105
6923
|
}
|
|
7106
6924
|
function checkDbFile(name, filePath) {
|
|
7107
|
-
if (!
|
|
6925
|
+
if (!existsSync24(filePath))
|
|
7108
6926
|
return { name, path: filePath, status: "missing" };
|
|
7109
6927
|
try {
|
|
7110
6928
|
const header = readFileSync17(filePath).slice(0, 16).toString("utf-8");
|
|
@@ -7119,7 +6937,7 @@ function checkDbFile(name, filePath) {
|
|
|
7119
6937
|
function checkShardedText(name, candidatePaths) {
|
|
7120
6938
|
const canonical = candidatePaths[0];
|
|
7121
6939
|
for (const p of candidatePaths) {
|
|
7122
|
-
if (!
|
|
6940
|
+
if (!existsSync24(p))
|
|
7123
6941
|
continue;
|
|
7124
6942
|
try {
|
|
7125
6943
|
if (statSync9(p).size === 0)
|
|
@@ -7194,7 +7012,12 @@ function status(cwd) {
|
|
|
7194
7012
|
console.log(` Sessions: ${lt.totalSessions}`);
|
|
7195
7013
|
console.log(` Total tokens: ${lt.totalTokens.toLocaleString()}`);
|
|
7196
7014
|
console.log(` Reads: ${lt.totalReads} Writes: ${lt.totalWrites}`);
|
|
7197
|
-
console.log(` Estimated savings: ${lt.totalEstimatedSavings.toLocaleString()} tokens`);
|
|
7015
|
+
console.log(` Estimated savings (heuristic): ${lt.totalEstimatedSavings.toLocaleString()} tokens`);
|
|
7016
|
+
const comp = ledger.compression;
|
|
7017
|
+
if (comp && comp.totalEvents > 0) {
|
|
7018
|
+
const ratio = comp.totalOriginalTokens > 0 ? Math.round(comp.totalMeasuredSavings / comp.totalOriginalTokens * 100) : 0;
|
|
7019
|
+
console.log(` Measured compression savings: ${comp.totalMeasuredSavings.toLocaleString()} tokens` + ` (${ratio}% over ${comp.totalEvents} event${comp.totalEvents === 1 ? "" : "s"}` + `, ${comp.totalHoldoutEvents} held out)`);
|
|
7020
|
+
}
|
|
7198
7021
|
} catch {
|
|
7199
7022
|
console.log(" Token ledger: error reading");
|
|
7200
7023
|
}
|
|
@@ -7212,7 +7035,7 @@ function status(cwd) {
|
|
|
7212
7035
|
console.log(` Decision Log: ${mem.sections["Decision Log"].length}`);
|
|
7213
7036
|
console.log(` Total entries: ${total}`);
|
|
7214
7037
|
const memPath = learningMemoryPath(cwd);
|
|
7215
|
-
if (
|
|
7038
|
+
if (existsSync24(memPath)) {
|
|
7216
7039
|
const mtime = statSync9(memPath).mtime;
|
|
7217
7040
|
console.log(` Canonical last modified: ${mtime.toISOString()}`);
|
|
7218
7041
|
}
|
|
@@ -7261,7 +7084,7 @@ __export(exports_scan2, {
|
|
|
7261
7084
|
});
|
|
7262
7085
|
import { readFileSync as readFileSync18 } from "fs";
|
|
7263
7086
|
import { createHash as createHash3 } from "crypto";
|
|
7264
|
-
import { join as
|
|
7087
|
+
import { join as join22, relative as relative3 } from "path";
|
|
7265
7088
|
function configRelativePath2(cfgPath, cwd) {
|
|
7266
7089
|
const rel = relative3(cwd, cfgPath);
|
|
7267
7090
|
return rel.startsWith("..") ? cfgPath : rel;
|
|
@@ -7312,7 +7135,7 @@ function scan2(cwd, options) {
|
|
|
7312
7135
|
if (!stalePaths.has(file.relativePath)) {
|
|
7313
7136
|
continue;
|
|
7314
7137
|
}
|
|
7315
|
-
const fullPath =
|
|
7138
|
+
const fullPath = join22(cwd, file.relativePath);
|
|
7316
7139
|
let content;
|
|
7317
7140
|
try {
|
|
7318
7141
|
content = readFileSync18(fullPath, "utf-8");
|
|
@@ -7397,12 +7220,12 @@ var exports_reflect2 = {};
|
|
|
7397
7220
|
__export(exports_reflect2, {
|
|
7398
7221
|
reflect: () => reflect2
|
|
7399
7222
|
});
|
|
7400
|
-
import { existsSync as
|
|
7401
|
-
import { dirname as
|
|
7223
|
+
import { existsSync as existsSync25 } from "fs";
|
|
7224
|
+
import { dirname as dirname10 } from "path";
|
|
7402
7225
|
function reflect2(_cwd, memoryPath, configPath3) {
|
|
7403
|
-
const projDir =
|
|
7226
|
+
const projDir = dirname10(memoryPath);
|
|
7404
7227
|
const mem = aggregateLearningMemoryAt(projDir);
|
|
7405
|
-
if (totalEntryCount(mem) === 0 && !
|
|
7228
|
+
if (totalEntryCount(mem) === 0 && !existsSync25(memoryPath)) {
|
|
7406
7229
|
console.log("[mink] no learning memory found");
|
|
7407
7230
|
return null;
|
|
7408
7231
|
}
|
|
@@ -7516,6 +7339,488 @@ var init_pre_read = __esm(() => {
|
|
|
7516
7339
|
init_counters_repo();
|
|
7517
7340
|
});
|
|
7518
7341
|
|
|
7342
|
+
// src/core/compression.ts
|
|
7343
|
+
function numberValue(key, fallback, min, max) {
|
|
7344
|
+
const raw = resolveConfigValue(key).value;
|
|
7345
|
+
const n = Number(raw);
|
|
7346
|
+
if (!Number.isFinite(n))
|
|
7347
|
+
return fallback;
|
|
7348
|
+
return Math.min(max, Math.max(min, n));
|
|
7349
|
+
}
|
|
7350
|
+
function loadCompressionConfig() {
|
|
7351
|
+
return {
|
|
7352
|
+
enabled: resolveConfigValue("compression.enabled").value === "true",
|
|
7353
|
+
thresholdTokens: numberValue("compression.threshold-tokens", 800, 0, Number.MAX_SAFE_INTEGER),
|
|
7354
|
+
minSavingsRatio: numberValue("compression.min-savings-ratio", 0.25, 0, 1),
|
|
7355
|
+
holdoutFraction: numberValue("compression.holdout-fraction", 0.1, 0, 1),
|
|
7356
|
+
retentionHours: numberValue("compression.retention-hours", 168, 0, Number.MAX_SAFE_INTEGER)
|
|
7357
|
+
};
|
|
7358
|
+
}
|
|
7359
|
+
function isEligible(originalTokens, config) {
|
|
7360
|
+
return config.enabled && originalTokens >= config.thresholdTokens;
|
|
7361
|
+
}
|
|
7362
|
+
function meetsMinSavings(originalTokens, compressedTokens, config) {
|
|
7363
|
+
if (originalTokens <= 0)
|
|
7364
|
+
return false;
|
|
7365
|
+
const ratio = (originalTokens - compressedTokens) / originalTokens;
|
|
7366
|
+
return ratio >= config.minSavingsRatio;
|
|
7367
|
+
}
|
|
7368
|
+
function hashUnitInterval(key) {
|
|
7369
|
+
let h = 2166136261;
|
|
7370
|
+
for (let i = 0;i < key.length; i++) {
|
|
7371
|
+
h ^= key.charCodeAt(i);
|
|
7372
|
+
h = Math.imul(h, 16777619);
|
|
7373
|
+
}
|
|
7374
|
+
return (h >>> 0) / 4294967296;
|
|
7375
|
+
}
|
|
7376
|
+
function selectHoldout(eventKey, fraction) {
|
|
7377
|
+
if (fraction <= 0)
|
|
7378
|
+
return false;
|
|
7379
|
+
if (fraction >= 1)
|
|
7380
|
+
return true;
|
|
7381
|
+
return hashUnitInterval(eventKey) < fraction;
|
|
7382
|
+
}
|
|
7383
|
+
var init_compression = __esm(() => {
|
|
7384
|
+
init_global_config();
|
|
7385
|
+
});
|
|
7386
|
+
|
|
7387
|
+
// src/core/code-skeleton.ts
|
|
7388
|
+
function countChar(s, c) {
|
|
7389
|
+
let n = 0;
|
|
7390
|
+
for (let i = 0;i < s.length; i++)
|
|
7391
|
+
if (s[i] === c)
|
|
7392
|
+
n++;
|
|
7393
|
+
return n;
|
|
7394
|
+
}
|
|
7395
|
+
function netBraces(line) {
|
|
7396
|
+
let s = line.replace(/\/\/.*$/, "");
|
|
7397
|
+
s = s.replace(/\/\*.*?\*\//g, "");
|
|
7398
|
+
s = s.replace(/"(?:\\.|[^"\\])*"/g, '""');
|
|
7399
|
+
s = s.replace(/'(?:\\.|[^'\\])*'/g, "''");
|
|
7400
|
+
s = s.replace(/`(?:\\.|[^`\\])*`/g, "``");
|
|
7401
|
+
return countChar(s, "{") - countChar(s, "}");
|
|
7402
|
+
}
|
|
7403
|
+
function stripOpenBrace(sig) {
|
|
7404
|
+
return sig.replace(/\{\s*$/, "").trimEnd();
|
|
7405
|
+
}
|
|
7406
|
+
function extractCodeSkeleton(content, opts = {}) {
|
|
7407
|
+
const rawLines = content.split(`
|
|
7408
|
+
`);
|
|
7409
|
+
const totalLines = rawLines.length > 0 && rawLines[rawLines.length - 1] === "" ? rawLines.length - 1 : rawLines.length;
|
|
7410
|
+
const out = [];
|
|
7411
|
+
let depth = 0;
|
|
7412
|
+
let suppress = Infinity;
|
|
7413
|
+
for (const line of rawLines) {
|
|
7414
|
+
if (out.length >= MAX_SIGNATURES)
|
|
7415
|
+
break;
|
|
7416
|
+
const start = depth;
|
|
7417
|
+
const net = netBraces(line);
|
|
7418
|
+
if (start < suppress) {
|
|
7419
|
+
const isHeading = opts.markdown === true && HEADING.test(line);
|
|
7420
|
+
const captured = isHeading || DECL_ALWAYS.test(line) || DECL_EXPORTED_VAR.test(line) || start >= 1 && MEMBER.test(line);
|
|
7421
|
+
if (captured) {
|
|
7422
|
+
const sig = line.trim();
|
|
7423
|
+
if (net > 0) {
|
|
7424
|
+
if (DESCEND.test(line) && !isHeading) {
|
|
7425
|
+
out.push(INDENT.repeat(start) + stripOpenBrace(sig) + " {");
|
|
7426
|
+
} else {
|
|
7427
|
+
out.push(INDENT.repeat(start) + stripOpenBrace(sig) + " { … }");
|
|
7428
|
+
suppress = start + 1;
|
|
7429
|
+
}
|
|
7430
|
+
} else {
|
|
7431
|
+
out.push(INDENT.repeat(start) + sig);
|
|
7432
|
+
}
|
|
7433
|
+
}
|
|
7434
|
+
}
|
|
7435
|
+
depth = Math.max(0, depth + net);
|
|
7436
|
+
if (depth < suppress)
|
|
7437
|
+
suppress = Infinity;
|
|
7438
|
+
}
|
|
7439
|
+
if (out.length === 0)
|
|
7440
|
+
return null;
|
|
7441
|
+
return { lines: out, totalLines };
|
|
7442
|
+
}
|
|
7443
|
+
var MAX_SIGNATURES = 80, INDENT = " ", DECL_ALWAYS, DECL_EXPORTED_VAR, MEMBER, HEADING, DESCEND;
|
|
7444
|
+
var init_code_skeleton = __esm(() => {
|
|
7445
|
+
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/;
|
|
7446
|
+
DECL_EXPORTED_VAR = /^\s*export\s+(?:default\s+)?(?:const|let|var)\b/;
|
|
7447
|
+
MEMBER = /^\s*(?:public\s+|private\s+|protected\s+|readonly\s+|static\s+|async\s+|get\s+|set\s+|#)*[\w$]+\??\s*(?:\(|:|=)/;
|
|
7448
|
+
HEADING = /^#{1,6}\s+\S/;
|
|
7449
|
+
DESCEND = /\b(?:class|interface|enum|namespace|module|struct|trait|impl)\b/;
|
|
7450
|
+
});
|
|
7451
|
+
|
|
7452
|
+
// src/core/output-compression.ts
|
|
7453
|
+
function stripAnsi(s) {
|
|
7454
|
+
return s.replace(ANSI, "");
|
|
7455
|
+
}
|
|
7456
|
+
function omittedMarker(n) {
|
|
7457
|
+
return ` … ${n} line${n === 1 ? "" : "s"} omitted — mink retrieve …`;
|
|
7458
|
+
}
|
|
7459
|
+
function toLines(content) {
|
|
7460
|
+
const lines = content.split(`
|
|
7461
|
+
`);
|
|
7462
|
+
if (lines.length > 0 && lines[lines.length - 1] === "")
|
|
7463
|
+
lines.pop();
|
|
7464
|
+
return lines;
|
|
7465
|
+
}
|
|
7466
|
+
function compressLog(content) {
|
|
7467
|
+
const lines = toLines(stripAnsi(content));
|
|
7468
|
+
const collapsed = [];
|
|
7469
|
+
let i = 0;
|
|
7470
|
+
while (i < lines.length) {
|
|
7471
|
+
let run = 1;
|
|
7472
|
+
while (i + run < lines.length && lines[i + run] === lines[i])
|
|
7473
|
+
run++;
|
|
7474
|
+
collapsed.push(run > 1 ? `${lines[i]} (×${run})` : lines[i]);
|
|
7475
|
+
i += run;
|
|
7476
|
+
}
|
|
7477
|
+
if (collapsed.length <= LOG_HEAD + LOG_TAIL) {
|
|
7478
|
+
if (collapsed.length === lines.length)
|
|
7479
|
+
return null;
|
|
7480
|
+
return {
|
|
7481
|
+
compressed: collapsed.join(`
|
|
7482
|
+
`),
|
|
7483
|
+
omittedNote: `collapsed ${lines.length - collapsed.length} repeated line(s)`
|
|
7484
|
+
};
|
|
7485
|
+
}
|
|
7486
|
+
const omitted = collapsed.length - LOG_HEAD - LOG_TAIL;
|
|
7487
|
+
const head = collapsed.slice(0, LOG_HEAD);
|
|
7488
|
+
const tail = collapsed.slice(collapsed.length - LOG_TAIL);
|
|
7489
|
+
return {
|
|
7490
|
+
compressed: [...head, omittedMarker(omitted), ...tail].join(`
|
|
7491
|
+
`),
|
|
7492
|
+
omittedNote: `${omitted} of ${collapsed.length} log line(s) omitted (middle)`
|
|
7493
|
+
};
|
|
7494
|
+
}
|
|
7495
|
+
function compressSearch(content) {
|
|
7496
|
+
const lines = toLines(content);
|
|
7497
|
+
const seen = new Set;
|
|
7498
|
+
const perFile = new Map;
|
|
7499
|
+
const omittedByFile = new Map;
|
|
7500
|
+
const out = [];
|
|
7501
|
+
for (const line of lines) {
|
|
7502
|
+
if (seen.has(line))
|
|
7503
|
+
continue;
|
|
7504
|
+
seen.add(line);
|
|
7505
|
+
const colon = line.indexOf(":");
|
|
7506
|
+
const file = colon > 0 ? line.slice(0, colon) : line;
|
|
7507
|
+
const count = perFile.get(file) ?? 0;
|
|
7508
|
+
if (count < SEARCH_MAX_PER_FILE) {
|
|
7509
|
+
perFile.set(file, count + 1);
|
|
7510
|
+
out.push(line);
|
|
7511
|
+
} else {
|
|
7512
|
+
omittedByFile.set(file, (omittedByFile.get(file) ?? 0) + 1);
|
|
7513
|
+
}
|
|
7514
|
+
}
|
|
7515
|
+
let totalOmitted = 0;
|
|
7516
|
+
for (const [file, n] of omittedByFile) {
|
|
7517
|
+
totalOmitted += n;
|
|
7518
|
+
out.push(` … +${n} more match(es) in ${file} — mink retrieve …`);
|
|
7519
|
+
}
|
|
7520
|
+
const dedupRemoved = lines.length - seen.size;
|
|
7521
|
+
if (totalOmitted === 0 && dedupRemoved === 0)
|
|
7522
|
+
return null;
|
|
7523
|
+
const notes = [];
|
|
7524
|
+
if (totalOmitted > 0)
|
|
7525
|
+
notes.push(`${totalOmitted} match(es) capped`);
|
|
7526
|
+
if (dedupRemoved > 0)
|
|
7527
|
+
notes.push(`${dedupRemoved} duplicate(s) removed`);
|
|
7528
|
+
return { compressed: out.join(`
|
|
7529
|
+
`), omittedNote: notes.join("; ") };
|
|
7530
|
+
}
|
|
7531
|
+
function compressFile(filePath, content) {
|
|
7532
|
+
const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
|
|
7533
|
+
const markdown = ext === ".md" || ext === ".mdx" || ext === ".markdown";
|
|
7534
|
+
const skeleton = extractCodeSkeleton(content, { markdown });
|
|
7535
|
+
if (!skeleton) {
|
|
7536
|
+
return compressText(content);
|
|
7537
|
+
}
|
|
7538
|
+
const header = `${filePath} — structural summary ` + `(${skeleton.lines.length} signature(s) of ${skeleton.totalLines} lines)`;
|
|
7539
|
+
return {
|
|
7540
|
+
compressed: [header, ...skeleton.lines].join(`
|
|
7541
|
+
`),
|
|
7542
|
+
omittedNote: `bodies elided; ${skeleton.totalLines} lines available via mink retrieve`
|
|
7543
|
+
};
|
|
7544
|
+
}
|
|
7545
|
+
function crush(value) {
|
|
7546
|
+
if (Array.isArray(value)) {
|
|
7547
|
+
let omitted = 0;
|
|
7548
|
+
const mapEl = (el) => {
|
|
7549
|
+
const r = crush(el);
|
|
7550
|
+
omitted += r.omitted;
|
|
7551
|
+
return r.value;
|
|
7552
|
+
};
|
|
7553
|
+
if (value.length <= JSON_ARRAY_HEAD + JSON_ARRAY_TAIL) {
|
|
7554
|
+
return { value: value.map(mapEl), omitted };
|
|
7555
|
+
}
|
|
7556
|
+
const dropped = value.length - JSON_ARRAY_HEAD - JSON_ARRAY_TAIL;
|
|
7557
|
+
omitted += dropped;
|
|
7558
|
+
const out = [
|
|
7559
|
+
...value.slice(0, JSON_ARRAY_HEAD).map(mapEl),
|
|
7560
|
+
`… ${dropped} element(s) omitted — mink retrieve …`,
|
|
7561
|
+
...value.slice(value.length - JSON_ARRAY_TAIL).map(mapEl)
|
|
7562
|
+
];
|
|
7563
|
+
return { value: out, omitted };
|
|
7564
|
+
}
|
|
7565
|
+
if (value && typeof value === "object") {
|
|
7566
|
+
let omitted = 0;
|
|
7567
|
+
const out = {};
|
|
7568
|
+
for (const [k, v] of Object.entries(value)) {
|
|
7569
|
+
const r = crush(v);
|
|
7570
|
+
omitted += r.omitted;
|
|
7571
|
+
out[k] = r.value;
|
|
7572
|
+
}
|
|
7573
|
+
return { value: out, omitted };
|
|
7574
|
+
}
|
|
7575
|
+
return { value, omitted: 0 };
|
|
7576
|
+
}
|
|
7577
|
+
function compressJson(content) {
|
|
7578
|
+
let parsed;
|
|
7579
|
+
try {
|
|
7580
|
+
parsed = JSON.parse(content);
|
|
7581
|
+
} catch {
|
|
7582
|
+
return null;
|
|
7583
|
+
}
|
|
7584
|
+
const { value, omitted } = crush(parsed);
|
|
7585
|
+
if (omitted === 0)
|
|
7586
|
+
return null;
|
|
7587
|
+
return {
|
|
7588
|
+
compressed: JSON.stringify(value, null, 2),
|
|
7589
|
+
omittedNote: `${omitted} array element(s) sampled out`
|
|
7590
|
+
};
|
|
7591
|
+
}
|
|
7592
|
+
function compressText(content) {
|
|
7593
|
+
const lines = toLines(content);
|
|
7594
|
+
if (lines.length <= TEXT_HEAD + TEXT_TAIL)
|
|
7595
|
+
return null;
|
|
7596
|
+
const omitted = lines.length - TEXT_HEAD - TEXT_TAIL;
|
|
7597
|
+
const head = lines.slice(0, TEXT_HEAD);
|
|
7598
|
+
const tail = lines.slice(lines.length - TEXT_TAIL);
|
|
7599
|
+
return {
|
|
7600
|
+
compressed: [...head, omittedMarker(omitted), ...tail].join(`
|
|
7601
|
+
`),
|
|
7602
|
+
omittedNote: `${omitted} of ${lines.length} line(s) omitted (middle)`
|
|
7603
|
+
};
|
|
7604
|
+
}
|
|
7605
|
+
function detectContentKind(toolName, content, filePath) {
|
|
7606
|
+
const t = toolName.toLowerCase();
|
|
7607
|
+
if (t === "read")
|
|
7608
|
+
return "file";
|
|
7609
|
+
if (t === "grep" || t === "glob")
|
|
7610
|
+
return "search";
|
|
7611
|
+
if (t === "bash")
|
|
7612
|
+
return "log";
|
|
7613
|
+
const head = content.trimStart()[0];
|
|
7614
|
+
if (head === "{" || head === "[") {
|
|
7615
|
+
try {
|
|
7616
|
+
JSON.parse(content);
|
|
7617
|
+
return "json";
|
|
7618
|
+
} catch {}
|
|
7619
|
+
}
|
|
7620
|
+
if (filePath)
|
|
7621
|
+
return "file";
|
|
7622
|
+
return "text";
|
|
7623
|
+
}
|
|
7624
|
+
function compressOutput(toolName, content, filePath) {
|
|
7625
|
+
const kind = detectContentKind(toolName, content, filePath);
|
|
7626
|
+
let result;
|
|
7627
|
+
switch (kind) {
|
|
7628
|
+
case "search":
|
|
7629
|
+
result = compressSearch(content);
|
|
7630
|
+
break;
|
|
7631
|
+
case "log":
|
|
7632
|
+
result = compressLog(content);
|
|
7633
|
+
break;
|
|
7634
|
+
case "file":
|
|
7635
|
+
result = compressFile(filePath ?? "file", content);
|
|
7636
|
+
break;
|
|
7637
|
+
case "json":
|
|
7638
|
+
result = compressJson(content);
|
|
7639
|
+
break;
|
|
7640
|
+
case "text":
|
|
7641
|
+
result = compressText(content);
|
|
7642
|
+
break;
|
|
7643
|
+
}
|
|
7644
|
+
if (!result)
|
|
7645
|
+
return null;
|
|
7646
|
+
return { kind, compressed: result.compressed, omittedNote: result.omittedNote };
|
|
7647
|
+
}
|
|
7648
|
+
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;
|
|
7649
|
+
var init_output_compression = __esm(() => {
|
|
7650
|
+
init_code_skeleton();
|
|
7651
|
+
ANSI = /\[[0-9;?]*[ -/]*[@-~]/g;
|
|
7652
|
+
});
|
|
7653
|
+
|
|
7654
|
+
// src/repositories/compression-cache-repo.ts
|
|
7655
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
7656
|
+
|
|
7657
|
+
class CompressionCacheRepo {
|
|
7658
|
+
db;
|
|
7659
|
+
constructor(db) {
|
|
7660
|
+
this.db = db;
|
|
7661
|
+
}
|
|
7662
|
+
static for(cwd) {
|
|
7663
|
+
return new CompressionCacheRepo(openProjectDb(cwd));
|
|
7664
|
+
}
|
|
7665
|
+
static newToken() {
|
|
7666
|
+
return `mc-${randomUUID3().slice(0, 8)}`;
|
|
7667
|
+
}
|
|
7668
|
+
store(input, deviceId = getOrCreateDeviceId()) {
|
|
7669
|
+
const token = input.token ?? CompressionCacheRepo.newToken();
|
|
7670
|
+
const now = input.now ?? new Date;
|
|
7671
|
+
const createdAt = now.toISOString();
|
|
7672
|
+
const expiresAt = new Date(now.getTime() + Math.max(0, input.retentionHours) * 3600000).toISOString();
|
|
7673
|
+
this.db.prepare(`
|
|
7674
|
+
INSERT OR REPLACE INTO compression_cache
|
|
7675
|
+
(token, created_at, expires_at, tool_name, content_kind,
|
|
7676
|
+
content, size_bytes, device_id)
|
|
7677
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
7678
|
+
`).run(token, createdAt, expiresAt, input.toolName, input.contentKind, input.content, Buffer.byteLength(input.content, "utf-8"), deviceId);
|
|
7679
|
+
return token;
|
|
7680
|
+
}
|
|
7681
|
+
get(token, now = new Date) {
|
|
7682
|
+
const row = this.db.prepare("SELECT * FROM compression_cache WHERE token = ?").get(token);
|
|
7683
|
+
if (!row)
|
|
7684
|
+
return null;
|
|
7685
|
+
const expiresAt = String(row.expires_at);
|
|
7686
|
+
if (expiresAt <= now.toISOString()) {
|
|
7687
|
+
try {
|
|
7688
|
+
this.db.prepare("DELETE FROM compression_cache WHERE token = ?").run(token);
|
|
7689
|
+
} catch {}
|
|
7690
|
+
return null;
|
|
7691
|
+
}
|
|
7692
|
+
return {
|
|
7693
|
+
token: String(row.token),
|
|
7694
|
+
createdAt: String(row.created_at),
|
|
7695
|
+
expiresAt,
|
|
7696
|
+
toolName: String(row.tool_name),
|
|
7697
|
+
contentKind: String(row.content_kind),
|
|
7698
|
+
content: String(row.content),
|
|
7699
|
+
sizeBytes: Number(row.size_bytes)
|
|
7700
|
+
};
|
|
7701
|
+
}
|
|
7702
|
+
evictExpired(now = new Date) {
|
|
7703
|
+
const r = this.db.prepare("DELETE FROM compression_cache WHERE expires_at <= ?").run(now.toISOString());
|
|
7704
|
+
return Number(r.changes);
|
|
7705
|
+
}
|
|
7706
|
+
count() {
|
|
7707
|
+
const row = this.db.prepare("SELECT COUNT(*) AS n FROM compression_cache").get();
|
|
7708
|
+
return Number(row.n);
|
|
7709
|
+
}
|
|
7710
|
+
}
|
|
7711
|
+
var init_compression_cache_repo = __esm(() => {
|
|
7712
|
+
init_db();
|
|
7713
|
+
init_device();
|
|
7714
|
+
});
|
|
7715
|
+
|
|
7716
|
+
// src/core/compress-tool-output.ts
|
|
7717
|
+
function contentKey(s) {
|
|
7718
|
+
let h = 2166136261;
|
|
7719
|
+
for (let i = 0;i < s.length; i++) {
|
|
7720
|
+
h ^= s.charCodeAt(i);
|
|
7721
|
+
h = Math.imul(h, 16777619);
|
|
7722
|
+
}
|
|
7723
|
+
return (h >>> 0).toString(16);
|
|
7724
|
+
}
|
|
7725
|
+
function render(result, token) {
|
|
7726
|
+
return result.compressed + `
|
|
7727
|
+
|
|
7728
|
+
` + `— mink: compressed ${result.kind} output (${result.omittedNote}). ` + `Full original: mink retrieve ${token}`;
|
|
7729
|
+
}
|
|
7730
|
+
function safeRecord(cwd, toolName, contentKind, originalTokens, compressedTokens, holdout) {
|
|
7731
|
+
try {
|
|
7732
|
+
TokenLedgerRepo.for(cwd).recordCompression({
|
|
7733
|
+
toolName,
|
|
7734
|
+
contentKind,
|
|
7735
|
+
originalTokens,
|
|
7736
|
+
compressedTokens,
|
|
7737
|
+
holdout
|
|
7738
|
+
});
|
|
7739
|
+
} catch {}
|
|
7740
|
+
}
|
|
7741
|
+
function compressToolOutput(cwd, toolName, output, filePath) {
|
|
7742
|
+
let cfg;
|
|
7743
|
+
try {
|
|
7744
|
+
cfg = loadCompressionConfig();
|
|
7745
|
+
} catch {
|
|
7746
|
+
return null;
|
|
7747
|
+
}
|
|
7748
|
+
if (!cfg.enabled)
|
|
7749
|
+
return null;
|
|
7750
|
+
if (typeof output !== "string" || output.length === 0)
|
|
7751
|
+
return null;
|
|
7752
|
+
const originalTokens = countTokens(output);
|
|
7753
|
+
if (!isEligible(originalTokens, cfg))
|
|
7754
|
+
return null;
|
|
7755
|
+
const eventKey = contentKey(output);
|
|
7756
|
+
if (selectHoldout(eventKey, cfg.holdoutFraction)) {
|
|
7757
|
+
const kind = detectContentKind(toolName, output, filePath);
|
|
7758
|
+
safeRecord(cwd, toolName, kind, originalTokens, originalTokens, true);
|
|
7759
|
+
return null;
|
|
7760
|
+
}
|
|
7761
|
+
const result = compressOutput(toolName, output, filePath);
|
|
7762
|
+
if (!result)
|
|
7763
|
+
return null;
|
|
7764
|
+
const token = CompressionCacheRepo.newToken();
|
|
7765
|
+
const replacement = render(result, token);
|
|
7766
|
+
const compressedTokens = countTokens(replacement);
|
|
7767
|
+
if (!meetsMinSavings(originalTokens, compressedTokens, cfg))
|
|
7768
|
+
return null;
|
|
7769
|
+
try {
|
|
7770
|
+
CompressionCacheRepo.for(cwd).store({
|
|
7771
|
+
toolName,
|
|
7772
|
+
contentKind: result.kind,
|
|
7773
|
+
content: output,
|
|
7774
|
+
retentionHours: cfg.retentionHours,
|
|
7775
|
+
token
|
|
7776
|
+
});
|
|
7777
|
+
} catch {
|
|
7778
|
+
return null;
|
|
7779
|
+
}
|
|
7780
|
+
safeRecord(cwd, toolName, result.kind, originalTokens, compressedTokens, false);
|
|
7781
|
+
return { updatedToolOutput: replacement, token };
|
|
7782
|
+
}
|
|
7783
|
+
var init_compress_tool_output = __esm(() => {
|
|
7784
|
+
init_compression();
|
|
7785
|
+
init_token_estimate();
|
|
7786
|
+
init_output_compression();
|
|
7787
|
+
init_compression_cache_repo();
|
|
7788
|
+
init_token_ledger_repo();
|
|
7789
|
+
});
|
|
7790
|
+
|
|
7791
|
+
// src/core/hook-output.ts
|
|
7792
|
+
function extractToolOutputText(input) {
|
|
7793
|
+
const tr = input.tool_response;
|
|
7794
|
+
if (tr) {
|
|
7795
|
+
if (typeof tr.content === "string")
|
|
7796
|
+
return tr.content;
|
|
7797
|
+
if (Array.isArray(tr.content)) {
|
|
7798
|
+
const parts = tr.content.map((p) => p && typeof p.text === "string" ? p.text : "").filter((s) => s.length > 0);
|
|
7799
|
+
if (parts.length > 0)
|
|
7800
|
+
return parts.join("");
|
|
7801
|
+
}
|
|
7802
|
+
if (typeof tr.stdout === "string" && tr.stdout.length > 0)
|
|
7803
|
+
return tr.stdout;
|
|
7804
|
+
if (typeof tr.text === "string")
|
|
7805
|
+
return tr.text;
|
|
7806
|
+
const file = tr.file;
|
|
7807
|
+
if (file && typeof file.content === "string")
|
|
7808
|
+
return file.content;
|
|
7809
|
+
}
|
|
7810
|
+
const to = input.tool_output;
|
|
7811
|
+
if (to && typeof to.content === "string")
|
|
7812
|
+
return to.content;
|
|
7813
|
+
return null;
|
|
7814
|
+
}
|
|
7815
|
+
function emitUpdatedToolOutput(text) {
|
|
7816
|
+
process.stdout.write(JSON.stringify({
|
|
7817
|
+
hookSpecificOutput: {
|
|
7818
|
+
hookEventName: "PostToolUse",
|
|
7819
|
+
updatedToolOutput: text
|
|
7820
|
+
}
|
|
7821
|
+
}));
|
|
7822
|
+
}
|
|
7823
|
+
|
|
7519
7824
|
// src/commands/post-read.ts
|
|
7520
7825
|
var exports_post_read = {};
|
|
7521
7826
|
__export(exports_post_read, {
|
|
@@ -7645,6 +7950,14 @@ async function postRead(cwd) {
|
|
|
7645
7950
|
logWriter.appendReadEntry(new Date().toISOString(), filePath, result.indexHit, result.estimatedTokens);
|
|
7646
7951
|
} catch {}
|
|
7647
7952
|
atomicWriteJson(sessionPath(cwd), state);
|
|
7953
|
+
const isRanged = input.tool_input.offset != null || input.tool_input.limit != null;
|
|
7954
|
+
if (!isRanged && content && content.length > 0) {
|
|
7955
|
+
try {
|
|
7956
|
+
const outcome = compressToolOutput(cwd, "Read", content, filePath);
|
|
7957
|
+
if (outcome)
|
|
7958
|
+
emitUpdatedToolOutput(outcome.updatedToolOutput);
|
|
7959
|
+
} catch {}
|
|
7960
|
+
}
|
|
7648
7961
|
} catch {} finally {
|
|
7649
7962
|
clearTimeout(timer);
|
|
7650
7963
|
}
|
|
@@ -7658,6 +7971,43 @@ var init_post_read = __esm(() => {
|
|
|
7658
7971
|
init_description();
|
|
7659
7972
|
init_action_log();
|
|
7660
7973
|
init_device();
|
|
7974
|
+
init_compress_tool_output();
|
|
7975
|
+
});
|
|
7976
|
+
|
|
7977
|
+
// src/commands/post-tool.ts
|
|
7978
|
+
var exports_post_tool = {};
|
|
7979
|
+
__export(exports_post_tool, {
|
|
7980
|
+
postTool: () => postTool
|
|
7981
|
+
});
|
|
7982
|
+
function isPostToolUseInput2(value) {
|
|
7983
|
+
if (value === null || typeof value !== "object")
|
|
7984
|
+
return false;
|
|
7985
|
+
const obj = value;
|
|
7986
|
+
return typeof obj.tool_name === "string";
|
|
7987
|
+
}
|
|
7988
|
+
function isCompressibleTool(toolName) {
|
|
7989
|
+
return toolName === "Bash" || toolName === "Grep" || toolName === "Glob" || toolName.startsWith("mcp__");
|
|
7990
|
+
}
|
|
7991
|
+
async function postTool(cwd) {
|
|
7992
|
+
const timer = setTimeout(() => process.exit(0), 5000);
|
|
7993
|
+
try {
|
|
7994
|
+
const input = await readStdinJson();
|
|
7995
|
+
if (!isPostToolUseInput2(input))
|
|
7996
|
+
return;
|
|
7997
|
+
if (!isCompressibleTool(input.tool_name))
|
|
7998
|
+
return;
|
|
7999
|
+
const output = extractToolOutputText(input);
|
|
8000
|
+
if (!output)
|
|
8001
|
+
return;
|
|
8002
|
+
const outcome = compressToolOutput(cwd, input.tool_name, output);
|
|
8003
|
+
if (outcome)
|
|
8004
|
+
emitUpdatedToolOutput(outcome.updatedToolOutput);
|
|
8005
|
+
} catch {} finally {
|
|
8006
|
+
clearTimeout(timer);
|
|
8007
|
+
}
|
|
8008
|
+
}
|
|
8009
|
+
var init_post_tool = __esm(() => {
|
|
8010
|
+
init_compress_tool_output();
|
|
7661
8011
|
});
|
|
7662
8012
|
|
|
7663
8013
|
// src/core/pattern-engine.ts
|
|
@@ -7896,7 +8246,7 @@ function analyzePostWrite(filePath, fileContent, index) {
|
|
|
7896
8246
|
indexEntry
|
|
7897
8247
|
};
|
|
7898
8248
|
}
|
|
7899
|
-
function
|
|
8249
|
+
function isPostToolUseInput3(value) {
|
|
7900
8250
|
if (value === null || typeof value !== "object")
|
|
7901
8251
|
return false;
|
|
7902
8252
|
const obj = value;
|
|
@@ -7910,7 +8260,7 @@ async function postWrite(cwd) {
|
|
|
7910
8260
|
const timer = setTimeout(() => process.exit(0), 1e4);
|
|
7911
8261
|
try {
|
|
7912
8262
|
const input = await readStdinJson();
|
|
7913
|
-
if (!
|
|
8263
|
+
if (!isPostToolUseInput3(input))
|
|
7914
8264
|
return;
|
|
7915
8265
|
if (input.tool_name !== "Write" && input.tool_name !== "Edit")
|
|
7916
8266
|
return;
|
|
@@ -8139,6 +8489,35 @@ var init_detect_waste = __esm(() => {
|
|
|
8139
8489
|
init_device();
|
|
8140
8490
|
});
|
|
8141
8491
|
|
|
8492
|
+
// src/commands/retrieve.ts
|
|
8493
|
+
var exports_retrieve = {};
|
|
8494
|
+
__export(exports_retrieve, {
|
|
8495
|
+
retrieve: () => retrieve
|
|
8496
|
+
});
|
|
8497
|
+
function retrieve(cwd, args) {
|
|
8498
|
+
const token = args[0];
|
|
8499
|
+
if (!token) {
|
|
8500
|
+
process.stderr.write(`[mink] usage: mink retrieve <token>
|
|
8501
|
+
`);
|
|
8502
|
+
return;
|
|
8503
|
+
}
|
|
8504
|
+
let entry = null;
|
|
8505
|
+
try {
|
|
8506
|
+
entry = CompressionCacheRepo.for(cwd).get(token);
|
|
8507
|
+
} catch {
|
|
8508
|
+
entry = null;
|
|
8509
|
+
}
|
|
8510
|
+
if (!entry) {
|
|
8511
|
+
process.stderr.write(`[mink] no retrievable output for token "${token}" (unknown or expired)
|
|
8512
|
+
`);
|
|
8513
|
+
return;
|
|
8514
|
+
}
|
|
8515
|
+
process.stdout.write(entry.content);
|
|
8516
|
+
}
|
|
8517
|
+
var init_retrieve = __esm(() => {
|
|
8518
|
+
init_compression_cache_repo();
|
|
8519
|
+
});
|
|
8520
|
+
|
|
8142
8521
|
// src/core/cron-parser.ts
|
|
8143
8522
|
function parseField(field, min, max) {
|
|
8144
8523
|
const values = new Set;
|
|
@@ -8273,9 +8652,9 @@ __export(exports_self_update, {
|
|
|
8273
8652
|
PACKAGE_NAME: () => PACKAGE_NAME
|
|
8274
8653
|
});
|
|
8275
8654
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
8276
|
-
import { existsSync as
|
|
8277
|
-
import { dirname as
|
|
8278
|
-
import { join as
|
|
8655
|
+
import { existsSync as existsSync26, readFileSync as readFileSync21 } from "fs";
|
|
8656
|
+
import { dirname as dirname11 } from "path";
|
|
8657
|
+
import { join as join23 } from "path";
|
|
8279
8658
|
function parseSemver(input) {
|
|
8280
8659
|
const trimmed = input.trim().replace(/^v/, "");
|
|
8281
8660
|
if (!trimmed)
|
|
@@ -8322,15 +8701,15 @@ function compareSemver(a, b) {
|
|
|
8322
8701
|
function getInstallInfo() {
|
|
8323
8702
|
const selfPath = new URL(import.meta.url).pathname;
|
|
8324
8703
|
const isDevMode = selfPath.endsWith(".ts");
|
|
8325
|
-
let dir =
|
|
8704
|
+
let dir = dirname11(selfPath);
|
|
8326
8705
|
let packageJsonPath = null;
|
|
8327
8706
|
for (let i = 0;i < 10; i++) {
|
|
8328
|
-
const candidate =
|
|
8329
|
-
if (
|
|
8707
|
+
const candidate = join23(dir, "package.json");
|
|
8708
|
+
if (existsSync26(candidate)) {
|
|
8330
8709
|
packageJsonPath = candidate;
|
|
8331
8710
|
break;
|
|
8332
8711
|
}
|
|
8333
|
-
const parent =
|
|
8712
|
+
const parent = dirname11(dir);
|
|
8334
8713
|
if (parent === dir)
|
|
8335
8714
|
break;
|
|
8336
8715
|
dir = parent;
|
|
@@ -8400,7 +8779,7 @@ function buildInstallCommand(pm, version) {
|
|
|
8400
8779
|
return ["npm", "install", "-g", ref];
|
|
8401
8780
|
}
|
|
8402
8781
|
function selfUpdateLogPath() {
|
|
8403
|
-
return
|
|
8782
|
+
return join23(minkRoot(), "self-update.log");
|
|
8404
8783
|
}
|
|
8405
8784
|
function appendLogEntry(entry) {
|
|
8406
8785
|
const path = selfUpdateLogPath();
|
|
@@ -9189,21 +9568,21 @@ var init_cron = __esm(() => {
|
|
|
9189
9568
|
});
|
|
9190
9569
|
|
|
9191
9570
|
// src/core/vault-templates.ts
|
|
9192
|
-
import { join as
|
|
9193
|
-
import { existsSync as
|
|
9571
|
+
import { join as join24 } from "path";
|
|
9572
|
+
import { existsSync as existsSync27, writeFileSync as writeFileSync9, readFileSync as readFileSync22, mkdirSync as mkdirSync13 } from "fs";
|
|
9194
9573
|
function seedTemplates(templatesDir) {
|
|
9195
|
-
|
|
9574
|
+
mkdirSync13(templatesDir, { recursive: true });
|
|
9196
9575
|
for (const [name, content] of Object.entries(DEFAULT_TEMPLATES)) {
|
|
9197
|
-
const filePath =
|
|
9198
|
-
if (!
|
|
9576
|
+
const filePath = join24(templatesDir, `${name}.md`);
|
|
9577
|
+
if (!existsSync27(filePath)) {
|
|
9199
9578
|
writeFileSync9(filePath, content);
|
|
9200
9579
|
}
|
|
9201
9580
|
}
|
|
9202
9581
|
}
|
|
9203
9582
|
function loadTemplate(templatesDir, templateName, vars) {
|
|
9204
|
-
const filePath =
|
|
9583
|
+
const filePath = join24(templatesDir, `${templateName}.md`);
|
|
9205
9584
|
let content;
|
|
9206
|
-
if (
|
|
9585
|
+
if (existsSync27(filePath)) {
|
|
9207
9586
|
content = readFileSync22(filePath, "utf-8");
|
|
9208
9587
|
} else if (DEFAULT_TEMPLATES[templateName]) {
|
|
9209
9588
|
content = DEFAULT_TEMPLATES[templateName];
|
|
@@ -9357,29 +9736,29 @@ category: resources
|
|
|
9357
9736
|
});
|
|
9358
9737
|
|
|
9359
9738
|
// src/core/note-writer.ts
|
|
9360
|
-
import { join as
|
|
9361
|
-
import { existsSync as
|
|
9739
|
+
import { join as join25 } from "path";
|
|
9740
|
+
import { existsSync as existsSync28, readFileSync as readFileSync23 } from "fs";
|
|
9362
9741
|
import { createHash as createHash4 } from "crypto";
|
|
9363
9742
|
function sha256(content) {
|
|
9364
9743
|
return createHash4("sha256").update(content).digest("hex");
|
|
9365
9744
|
}
|
|
9366
9745
|
function resolveUniqueNotePath(dir, baseSlug, content) {
|
|
9367
9746
|
const targetHash = sha256(content);
|
|
9368
|
-
const primary =
|
|
9369
|
-
if (!
|
|
9747
|
+
const primary = join25(dir, `${baseSlug}.md`);
|
|
9748
|
+
if (!existsSync28(primary))
|
|
9370
9749
|
return primary;
|
|
9371
9750
|
if (sameContent(primary, targetHash))
|
|
9372
9751
|
return primary;
|
|
9373
9752
|
const dev4 = getOrCreateDeviceId().replace(/-/g, "").slice(0, 4);
|
|
9374
9753
|
for (let i = 0;i < MAX_COLLISION_ATTEMPTS; i++) {
|
|
9375
9754
|
const suffix = i === 0 ? dev4 : `${dev4}-${i + 1}`;
|
|
9376
|
-
const candidate =
|
|
9377
|
-
if (!
|
|
9755
|
+
const candidate = join25(dir, `${baseSlug}-${suffix}.md`);
|
|
9756
|
+
if (!existsSync28(candidate))
|
|
9378
9757
|
return candidate;
|
|
9379
9758
|
if (sameContent(candidate, targetHash))
|
|
9380
9759
|
return candidate;
|
|
9381
9760
|
}
|
|
9382
|
-
return
|
|
9761
|
+
return join25(dir, `${baseSlug}-${Date.now()}.md`);
|
|
9383
9762
|
}
|
|
9384
9763
|
function sameContent(filePath, expectedHash) {
|
|
9385
9764
|
try {
|
|
@@ -9454,8 +9833,8 @@ ${meta.body}
|
|
|
9454
9833
|
}
|
|
9455
9834
|
function appendToDaily(date, content) {
|
|
9456
9835
|
const dir = vaultDailyDir();
|
|
9457
|
-
const filePath =
|
|
9458
|
-
if (
|
|
9836
|
+
const filePath = join25(dir, `${date}.md`);
|
|
9837
|
+
if (existsSync28(filePath)) {
|
|
9459
9838
|
const timestamp = new Date().toLocaleTimeString("en-US", {
|
|
9460
9839
|
hour: "2-digit",
|
|
9461
9840
|
minute: "2-digit",
|
|
@@ -9564,10 +9943,10 @@ var init_design_eval = __esm(() => {
|
|
|
9564
9943
|
});
|
|
9565
9944
|
|
|
9566
9945
|
// src/core/dashboard-api.ts
|
|
9567
|
-
import { existsSync as
|
|
9946
|
+
import { existsSync as existsSync29, readFileSync as readFileSync24 } from "fs";
|
|
9568
9947
|
import { readdirSync as readdirSync9, readFileSync as readFileSyncFS, existsSync as fsExistsSync } from "fs";
|
|
9569
|
-
import { join as
|
|
9570
|
-
import { execSync as
|
|
9948
|
+
import { join as join26, resolve as resolve5, normalize, sep } from "path";
|
|
9949
|
+
import { execSync as execSync6 } from "child_process";
|
|
9571
9950
|
function isSecretKey(key) {
|
|
9572
9951
|
return SECRET_KEY_PATTERNS.some((re) => re.test(key));
|
|
9573
9952
|
}
|
|
@@ -9579,7 +9958,7 @@ function maskSecret(value, showLast = 4) {
|
|
|
9579
9958
|
return "••••" + value.slice(-showLast);
|
|
9580
9959
|
}
|
|
9581
9960
|
function checkJsonFile2(name, filePath, validator) {
|
|
9582
|
-
if (!
|
|
9961
|
+
if (!existsSync29(filePath))
|
|
9583
9962
|
return { name, status: "missing" };
|
|
9584
9963
|
const data = safeReadJson(filePath);
|
|
9585
9964
|
if (data === null)
|
|
@@ -9589,7 +9968,7 @@ function checkJsonFile2(name, filePath, validator) {
|
|
|
9589
9968
|
return { name, status: "ok" };
|
|
9590
9969
|
}
|
|
9591
9970
|
function checkTextFile(name, filePath) {
|
|
9592
|
-
if (!
|
|
9971
|
+
if (!existsSync29(filePath))
|
|
9593
9972
|
return { name, status: "missing" };
|
|
9594
9973
|
try {
|
|
9595
9974
|
readFileSync24(filePath, "utf-8");
|
|
@@ -9599,7 +9978,7 @@ function checkTextFile(name, filePath) {
|
|
|
9599
9978
|
}
|
|
9600
9979
|
}
|
|
9601
9980
|
function checkDbFile2(name, filePath) {
|
|
9602
|
-
if (!
|
|
9981
|
+
if (!existsSync29(filePath))
|
|
9603
9982
|
return { name, status: "missing" };
|
|
9604
9983
|
try {
|
|
9605
9984
|
const header = readFileSync24(filePath).slice(0, 16).toString("utf-8");
|
|
@@ -9641,14 +10020,26 @@ function loadOverview(cwd) {
|
|
|
9641
10020
|
checkTextFile("action-log.md", actionLogPath(cwd)),
|
|
9642
10021
|
checkJsonFile2("scheduler-manifest.json", schedulerManifestPath(cwd))
|
|
9643
10022
|
];
|
|
9644
|
-
return { project, daemon, summary, stateFiles };
|
|
10023
|
+
return { project, daemon, summary, compression: ledger.compression, stateFiles };
|
|
9645
10024
|
}
|
|
9646
10025
|
function loadTokenLedgerPanel(cwd) {
|
|
9647
10026
|
const ledger = aggregateTokenLedger(cwd);
|
|
9648
10027
|
return {
|
|
9649
10028
|
lifetime: ledger.lifetime,
|
|
9650
10029
|
sessions: ledger.sessions,
|
|
9651
|
-
wasteFlags: ledger.wasteFlags ?? []
|
|
10030
|
+
wasteFlags: ledger.wasteFlags ?? [],
|
|
10031
|
+
compression: ledger.compression
|
|
10032
|
+
};
|
|
10033
|
+
}
|
|
10034
|
+
function loadCompressionPanel(cwd) {
|
|
10035
|
+
const repo = TokenLedgerRepo.for(cwd);
|
|
10036
|
+
return {
|
|
10037
|
+
enabled: loadCompressionConfig().enabled,
|
|
10038
|
+
lifetime: repo.compressionLifetime(),
|
|
10039
|
+
arms: repo.compressionArms(),
|
|
10040
|
+
byKind: repo.compressionBreakdown("content_kind"),
|
|
10041
|
+
byTool: repo.compressionBreakdown("tool_name"),
|
|
10042
|
+
recent: repo.compressionEvents(50)
|
|
9652
10043
|
};
|
|
9653
10044
|
}
|
|
9654
10045
|
function loadFileIndexPanel(cwd) {
|
|
@@ -9781,7 +10172,7 @@ function getAheadBehind(branch) {
|
|
|
9781
10172
|
if (!branch)
|
|
9782
10173
|
return { ahead: 0, behind: 0 };
|
|
9783
10174
|
try {
|
|
9784
|
-
const raw =
|
|
10175
|
+
const raw = execSync6(`git rev-list --left-right --count origin/${branch}...${branch}`, { cwd: minkRoot(), timeout: 5000, stdio: ["pipe", "pipe", "pipe"] }).toString().trim();
|
|
9785
10176
|
const [behindStr, aheadStr] = raw.split(/\s+/);
|
|
9786
10177
|
return {
|
|
9787
10178
|
behind: Number(behindStr) || 0,
|
|
@@ -9793,7 +10184,7 @@ function getAheadBehind(branch) {
|
|
|
9793
10184
|
}
|
|
9794
10185
|
function getPendingChanges() {
|
|
9795
10186
|
try {
|
|
9796
|
-
const raw =
|
|
10187
|
+
const raw = execSync6("git status --porcelain", {
|
|
9797
10188
|
cwd: minkRoot(),
|
|
9798
10189
|
timeout: 5000,
|
|
9799
10190
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -9865,7 +10256,7 @@ function countMarkdownIn(dir) {
|
|
|
9865
10256
|
for (const entry of readdirSync9(dir, { withFileTypes: true })) {
|
|
9866
10257
|
if (WIKI_TREE_EXCLUDES.has(entry.name) || entry.name.startsWith("."))
|
|
9867
10258
|
continue;
|
|
9868
|
-
const fullPath =
|
|
10259
|
+
const fullPath = join26(dir, entry.name);
|
|
9869
10260
|
if (entry.isDirectory()) {
|
|
9870
10261
|
count += countMarkdownIn(fullPath);
|
|
9871
10262
|
} else if (entry.name.endsWith(".md") && !entry.name.startsWith("_")) {
|
|
@@ -9894,7 +10285,7 @@ function buildVaultTree(root) {
|
|
|
9894
10285
|
for (const entry of entries) {
|
|
9895
10286
|
if (!entry.isDir)
|
|
9896
10287
|
continue;
|
|
9897
|
-
const fullPath =
|
|
10288
|
+
const fullPath = join26(dir, entry.name);
|
|
9898
10289
|
const relPath = fullPath.slice(root.length + 1);
|
|
9899
10290
|
const count = countMarkdownIn(fullPath);
|
|
9900
10291
|
nodes.push({ name: entry.name, path: relPath, count, depth });
|
|
@@ -9979,7 +10370,7 @@ function resolveVaultRelativePath(relPath) {
|
|
|
9979
10370
|
if (!relPath || relPath.includes("\x00"))
|
|
9980
10371
|
return null;
|
|
9981
10372
|
const root = resolveVaultPath();
|
|
9982
|
-
const absolute =
|
|
10373
|
+
const absolute = resolve5(root, relPath);
|
|
9983
10374
|
const normalizedRoot = normalize(root) + sep;
|
|
9984
10375
|
if (!absolute.startsWith(normalizedRoot) && absolute !== normalize(root)) {
|
|
9985
10376
|
return null;
|
|
@@ -10317,7 +10708,7 @@ async function triggerIngestFile(sourcePath, category, tags, dedupKey) {
|
|
|
10317
10708
|
if (!isValidCategory(category)) {
|
|
10318
10709
|
return { success: false, error: `Invalid category: ${category}` };
|
|
10319
10710
|
}
|
|
10320
|
-
const expanded = sourcePath.startsWith("~/") ?
|
|
10711
|
+
const expanded = sourcePath.startsWith("~/") ? join26(process.env.HOME ?? "", sourcePath.slice(2)) : sourcePath;
|
|
10321
10712
|
if (!fsExistsSync(expanded)) {
|
|
10322
10713
|
return { success: false, error: `Source file not found: ${sourcePath}` };
|
|
10323
10714
|
}
|
|
@@ -10377,6 +10768,8 @@ var init_dashboard_api = __esm(() => {
|
|
|
10377
10768
|
init_note_writer();
|
|
10378
10769
|
init_paths();
|
|
10379
10770
|
init_config();
|
|
10771
|
+
init_token_ledger_repo();
|
|
10772
|
+
init_compression();
|
|
10380
10773
|
init_design_eval();
|
|
10381
10774
|
SECRET_KEY_PATTERNS = [/token/i, /secret/i, /password/i, /api[-_]?key/i];
|
|
10382
10775
|
BOOLEAN_VALUES = new Set(["true", "false"]);
|
|
@@ -10404,8 +10797,8 @@ __export(exports_dashboard_server, {
|
|
|
10404
10797
|
startDashboardServer: () => startDashboardServer
|
|
10405
10798
|
});
|
|
10406
10799
|
import { watch } from "fs";
|
|
10407
|
-
import { existsSync as
|
|
10408
|
-
import { basename as basename7, dirname as
|
|
10800
|
+
import { existsSync as existsSync30 } from "fs";
|
|
10801
|
+
import { basename as basename7, dirname as dirname12, join as join27, extname as extname2 } from "path";
|
|
10409
10802
|
|
|
10410
10803
|
class SSEManager {
|
|
10411
10804
|
clients = new Map;
|
|
@@ -10582,15 +10975,15 @@ async function startDashboardServer(cwd, options = {}) {
|
|
|
10582
10975
|
timestamp: new Date().toISOString()
|
|
10583
10976
|
});
|
|
10584
10977
|
});
|
|
10585
|
-
const __dir =
|
|
10978
|
+
const __dir = dirname12(new URL(import.meta.url).pathname);
|
|
10586
10979
|
let pkgRoot = __dir;
|
|
10587
|
-
while (pkgRoot !==
|
|
10588
|
-
if (
|
|
10980
|
+
while (pkgRoot !== dirname12(pkgRoot)) {
|
|
10981
|
+
if (existsSync30(join27(pkgRoot, "package.json")))
|
|
10589
10982
|
break;
|
|
10590
|
-
pkgRoot =
|
|
10983
|
+
pkgRoot = dirname12(pkgRoot);
|
|
10591
10984
|
}
|
|
10592
|
-
const dashboardOutDir =
|
|
10593
|
-
const dashboardBuilt =
|
|
10985
|
+
const dashboardOutDir = join27(pkgRoot, "dashboard", "out");
|
|
10986
|
+
const dashboardBuilt = existsSync30(join27(dashboardOutDir, "index.html"));
|
|
10594
10987
|
let clientIdCounter = 0;
|
|
10595
10988
|
if (!dashboardBuilt) {
|
|
10596
10989
|
console.warn("[mink] dashboard not built. Run: cd dashboard && bun run build");
|
|
@@ -10620,9 +11013,9 @@ async function startDashboardServer(cwd, options = {}) {
|
|
|
10620
11013
|
} else {
|
|
10621
11014
|
let filePath;
|
|
10622
11015
|
if (pathname === "/") {
|
|
10623
|
-
filePath =
|
|
11016
|
+
filePath = join27(dashboardOutDir, "index.html");
|
|
10624
11017
|
} else {
|
|
10625
|
-
filePath =
|
|
11018
|
+
filePath = join27(dashboardOutDir, pathname);
|
|
10626
11019
|
}
|
|
10627
11020
|
if (!filePath.startsWith(dashboardOutDir)) {
|
|
10628
11021
|
return jsonResponse({ error: "Forbidden" }, 403);
|
|
@@ -10635,7 +11028,7 @@ async function startDashboardServer(cwd, options = {}) {
|
|
|
10635
11028
|
const htmlServed = await serveFile(filePath + ".html", "text/html; charset=utf-8");
|
|
10636
11029
|
if (htmlServed)
|
|
10637
11030
|
return htmlServed;
|
|
10638
|
-
const indexServed = await serveFile(
|
|
11031
|
+
const indexServed = await serveFile(join27(dashboardOutDir, "index.html"), "text/html; charset=utf-8");
|
|
10639
11032
|
if (indexServed)
|
|
10640
11033
|
return indexServed;
|
|
10641
11034
|
}
|
|
@@ -10726,6 +11119,8 @@ retry: 3000
|
|
|
10726
11119
|
return jsonResponse(loadOverview(resolvedCwd));
|
|
10727
11120
|
case "/api/token-ledger":
|
|
10728
11121
|
return jsonResponse(loadTokenLedgerPanel(resolvedCwd));
|
|
11122
|
+
case "/api/compression":
|
|
11123
|
+
return jsonResponse(loadCompressionPanel(resolvedCwd));
|
|
10729
11124
|
case "/api/file-index":
|
|
10730
11125
|
return jsonResponse(loadFileIndexPanel(resolvedCwd));
|
|
10731
11126
|
case "/api/scheduler":
|
|
@@ -10744,7 +11139,7 @@ retry: 3000
|
|
|
10744
11139
|
if (!filename || filename.includes("..") || filename.includes("/")) {
|
|
10745
11140
|
return jsonResponse({ error: "Invalid filename" }, 400);
|
|
10746
11141
|
}
|
|
10747
|
-
const imgPath =
|
|
11142
|
+
const imgPath = join27(designCapturesDir(resolvedCwd), filename);
|
|
10748
11143
|
const served = await serveFile(imgPath, "image/jpeg");
|
|
10749
11144
|
if (served) {
|
|
10750
11145
|
served.headers.set("Cache-Control", "public, max-age=60");
|
|
@@ -10979,9 +11374,9 @@ __export(exports_dashboard, {
|
|
|
10979
11374
|
resolveStartupCwd: () => resolveStartupCwd,
|
|
10980
11375
|
dashboard: () => dashboard
|
|
10981
11376
|
});
|
|
10982
|
-
import { existsSync as
|
|
11377
|
+
import { existsSync as existsSync31 } from "fs";
|
|
10983
11378
|
function resolveStartupCwd(cwd, registered = listRegisteredProjects()) {
|
|
10984
|
-
if (
|
|
11379
|
+
if (existsSync31(projectDir(cwd))) {
|
|
10985
11380
|
return { kind: "active", cwd };
|
|
10986
11381
|
}
|
|
10987
11382
|
if (registered.length === 0) {
|
|
@@ -11018,18 +11413,18 @@ var init_dashboard = __esm(() => {
|
|
|
11018
11413
|
});
|
|
11019
11414
|
|
|
11020
11415
|
// src/commands/init.ts
|
|
11021
|
-
import { mkdirSync as
|
|
11022
|
-
import { resolve as
|
|
11416
|
+
import { mkdirSync as mkdirSync14, existsSync as existsSync32 } from "fs";
|
|
11417
|
+
import { resolve as resolve6, dirname as dirname13, basename as basename8, join as join28 } from "path";
|
|
11023
11418
|
function resolveCliPathFrom2(selfPath) {
|
|
11024
|
-
const selfDir =
|
|
11419
|
+
const selfDir = dirname13(selfPath);
|
|
11025
11420
|
if (selfPath.endsWith("dist/cli.js") || selfPath.endsWith("dist/cli.bun.js") || selfPath.endsWith("dist/cli.node.js")) {
|
|
11026
|
-
return
|
|
11421
|
+
return join28(selfDir, "cli.js");
|
|
11027
11422
|
}
|
|
11028
|
-
const packageRoot =
|
|
11029
|
-
const distShim =
|
|
11030
|
-
if (
|
|
11423
|
+
const packageRoot = resolve6(selfDir, "..", "..");
|
|
11424
|
+
const distShim = join28(packageRoot, "dist", "cli.js");
|
|
11425
|
+
if (existsSync32(distShim))
|
|
11031
11426
|
return distShim;
|
|
11032
|
-
return
|
|
11427
|
+
return join28(packageRoot, "src", "cli.ts");
|
|
11033
11428
|
}
|
|
11034
11429
|
function resolveCliPath2() {
|
|
11035
11430
|
return resolveCliPathFrom2(new URL(import.meta.url).pathname);
|
|
@@ -11049,12 +11444,14 @@ function buildHooksConfig2(cliPath) {
|
|
|
11049
11444
|
PostToolUse: [
|
|
11050
11445
|
{ matcher: "Read", hooks: hook(`${prefix} post-read`) },
|
|
11051
11446
|
{ matcher: "Edit", hooks: hook(`${prefix} post-write`) },
|
|
11052
|
-
{ matcher: "Write", hooks: hook(`${prefix} post-write`) }
|
|
11447
|
+
{ matcher: "Write", hooks: hook(`${prefix} post-write`) },
|
|
11448
|
+
{ matcher: "Bash", hooks: hook(`${prefix} post-tool`) },
|
|
11449
|
+
{ matcher: "Grep", hooks: hook(`${prefix} post-tool`) }
|
|
11053
11450
|
]
|
|
11054
11451
|
};
|
|
11055
11452
|
}
|
|
11056
11453
|
function isMinkCommand2(cmd) {
|
|
11057
|
-
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");
|
|
11454
|
+
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");
|
|
11058
11455
|
if (!hasMinkSubcommand)
|
|
11059
11456
|
return false;
|
|
11060
11457
|
if (/(^|\/|\s)mink\s/.test(cmd))
|
|
@@ -11071,7 +11468,7 @@ function isMinkHook2(entry) {
|
|
|
11071
11468
|
return false;
|
|
11072
11469
|
}
|
|
11073
11470
|
function mergeHooksIntoSettings2(settingsPath, newHooks) {
|
|
11074
|
-
|
|
11471
|
+
mkdirSync14(dirname13(settingsPath), { recursive: true });
|
|
11075
11472
|
const existing = safeReadJson(settingsPath) ?? {};
|
|
11076
11473
|
const existingHooks = existing.hooks ?? {};
|
|
11077
11474
|
for (const [event, entries] of Object.entries(newHooks)) {
|
|
@@ -11089,16 +11486,13 @@ var init_init2 = __esm(() => {
|
|
|
11089
11486
|
init_device();
|
|
11090
11487
|
init_git_identity();
|
|
11091
11488
|
init_vault();
|
|
11092
|
-
init_agent_detect();
|
|
11093
|
-
init_agent_pi();
|
|
11094
|
-
init_prompt();
|
|
11095
11489
|
});
|
|
11096
11490
|
|
|
11097
11491
|
// src/core/daemon-service.ts
|
|
11098
|
-
import { execSync as
|
|
11099
|
-
import { existsSync as
|
|
11100
|
-
import { homedir as
|
|
11101
|
-
import { dirname as
|
|
11492
|
+
import { execSync as execSync7 } from "child_process";
|
|
11493
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync10 } from "fs";
|
|
11494
|
+
import { homedir as homedir4 } from "os";
|
|
11495
|
+
import { dirname as dirname14, join as join29 } from "path";
|
|
11102
11496
|
function detectPlatform() {
|
|
11103
11497
|
if (process.platform === "linux")
|
|
11104
11498
|
return "systemd";
|
|
@@ -11108,11 +11502,11 @@ function detectPlatform() {
|
|
|
11108
11502
|
}
|
|
11109
11503
|
function resolveServiceInvocation() {
|
|
11110
11504
|
const entry = process.argv[1];
|
|
11111
|
-
if (entry && !/\.(js|ts|mjs|cjs)$/.test(entry) &&
|
|
11505
|
+
if (entry && !/\.(js|ts|mjs|cjs)$/.test(entry) && existsSync33(entry)) {
|
|
11112
11506
|
return {
|
|
11113
11507
|
executable: entry,
|
|
11114
11508
|
args: ["daemon", "start"],
|
|
11115
|
-
pathDir:
|
|
11509
|
+
pathDir: dirname14(entry)
|
|
11116
11510
|
};
|
|
11117
11511
|
}
|
|
11118
11512
|
const cliPath = resolveCliPath2();
|
|
@@ -11120,17 +11514,17 @@ function resolveServiceInvocation() {
|
|
|
11120
11514
|
return {
|
|
11121
11515
|
executable: interpreter,
|
|
11122
11516
|
args: [cliPath, "daemon", "start"],
|
|
11123
|
-
pathDir:
|
|
11517
|
+
pathDir: dirname14(interpreter)
|
|
11124
11518
|
};
|
|
11125
11519
|
}
|
|
11126
11520
|
function servicePaths(platform2) {
|
|
11127
|
-
const home =
|
|
11521
|
+
const home = homedir4();
|
|
11128
11522
|
if (platform2 === "systemd") {
|
|
11129
|
-
const unitDir2 =
|
|
11130
|
-
return { unitDir: unitDir2, unitFile:
|
|
11523
|
+
const unitDir2 = join29(home, ".config", "systemd", "user");
|
|
11524
|
+
return { unitDir: unitDir2, unitFile: join29(unitDir2, "mink-daemon.service") };
|
|
11131
11525
|
}
|
|
11132
|
-
const unitDir =
|
|
11133
|
-
return { unitDir, unitFile:
|
|
11526
|
+
const unitDir = join29(home, "Library", "LaunchAgents");
|
|
11527
|
+
return { unitDir, unitFile: join29(unitDir, "com.mink.daemon.plist") };
|
|
11134
11528
|
}
|
|
11135
11529
|
function renderSystemdUnit(inv) {
|
|
11136
11530
|
const execStart = [inv.executable, ...inv.args].join(" ");
|
|
@@ -11204,17 +11598,17 @@ function installService(options = {}) {
|
|
|
11204
11598
|
process.exit(1);
|
|
11205
11599
|
}
|
|
11206
11600
|
const paths = servicePaths(platform2);
|
|
11207
|
-
if (
|
|
11601
|
+
if (existsSync33(paths.unitFile) && !options.force) {
|
|
11208
11602
|
console.error(`[mink] unit file already exists: ${paths.unitFile}`);
|
|
11209
11603
|
console.error(" re-run with --force to overwrite, or run `mink daemon uninstall` first");
|
|
11210
11604
|
process.exit(1);
|
|
11211
11605
|
}
|
|
11212
11606
|
const inv = resolveServiceInvocation();
|
|
11213
|
-
|
|
11607
|
+
mkdirSync15(paths.unitDir, { recursive: true });
|
|
11214
11608
|
if (platform2 === "systemd") {
|
|
11215
11609
|
writeFileSync10(paths.unitFile, renderSystemdUnit(inv));
|
|
11216
11610
|
try {
|
|
11217
|
-
|
|
11611
|
+
execSync7("systemctl --user daemon-reload", { stdio: "ignore" });
|
|
11218
11612
|
} catch {}
|
|
11219
11613
|
console.log(`[mink] wrote ${paths.unitFile}`);
|
|
11220
11614
|
console.log("[mink] next steps:");
|
|
@@ -11237,24 +11631,24 @@ function uninstallService() {
|
|
|
11237
11631
|
process.exit(1);
|
|
11238
11632
|
}
|
|
11239
11633
|
const paths = servicePaths(platform2);
|
|
11240
|
-
if (!
|
|
11634
|
+
if (!existsSync33(paths.unitFile)) {
|
|
11241
11635
|
console.log(`[mink] no unit file at ${paths.unitFile} — nothing to uninstall`);
|
|
11242
11636
|
return;
|
|
11243
11637
|
}
|
|
11244
11638
|
if (platform2 === "systemd") {
|
|
11245
11639
|
try {
|
|
11246
|
-
|
|
11640
|
+
execSync7("systemctl --user disable --now mink-daemon.service", {
|
|
11247
11641
|
stdio: "ignore"
|
|
11248
11642
|
});
|
|
11249
11643
|
} catch {}
|
|
11250
11644
|
unlinkSync5(paths.unitFile);
|
|
11251
11645
|
try {
|
|
11252
|
-
|
|
11646
|
+
execSync7("systemctl --user daemon-reload", { stdio: "ignore" });
|
|
11253
11647
|
} catch {}
|
|
11254
11648
|
console.log(`[mink] removed ${paths.unitFile}`);
|
|
11255
11649
|
} else {
|
|
11256
11650
|
try {
|
|
11257
|
-
|
|
11651
|
+
execSync7(`launchctl unload -w ${paths.unitFile}`, { stdio: "ignore" });
|
|
11258
11652
|
} catch {}
|
|
11259
11653
|
unlinkSync5(paths.unitFile);
|
|
11260
11654
|
console.log(`[mink] removed ${paths.unitFile}`);
|
|
@@ -11269,7 +11663,7 @@ var exports_daemon = {};
|
|
|
11269
11663
|
__export(exports_daemon, {
|
|
11270
11664
|
daemon: () => daemon
|
|
11271
11665
|
});
|
|
11272
|
-
import { readFileSync as readFileSync25, existsSync as
|
|
11666
|
+
import { readFileSync as readFileSync25, existsSync as existsSync34 } from "fs";
|
|
11273
11667
|
async function daemon(cwd, args) {
|
|
11274
11668
|
const subcommand = args[0];
|
|
11275
11669
|
switch (subcommand) {
|
|
@@ -11285,7 +11679,7 @@ async function daemon(cwd, args) {
|
|
|
11285
11679
|
break;
|
|
11286
11680
|
case "logs": {
|
|
11287
11681
|
const logPath = schedulerLogPath();
|
|
11288
|
-
if (!
|
|
11682
|
+
if (!existsSync34(logPath)) {
|
|
11289
11683
|
console.log("[mink] no log file found");
|
|
11290
11684
|
return;
|
|
11291
11685
|
}
|
|
@@ -11557,13 +11951,13 @@ function printValidKeys() {
|
|
|
11557
11951
|
}
|
|
11558
11952
|
}
|
|
11559
11953
|
function readLineFromStdin() {
|
|
11560
|
-
return new Promise((
|
|
11954
|
+
return new Promise((resolve8) => {
|
|
11561
11955
|
const chunks = [];
|
|
11562
11956
|
process.stdin.resume();
|
|
11563
11957
|
process.stdin.setEncoding("utf-8");
|
|
11564
11958
|
process.stdin.once("data", (data) => {
|
|
11565
11959
|
process.stdin.pause();
|
|
11566
|
-
|
|
11960
|
+
resolve8(String(data).trim());
|
|
11567
11961
|
});
|
|
11568
11962
|
});
|
|
11569
11963
|
}
|
|
@@ -11638,7 +12032,7 @@ var exports_update = {};
|
|
|
11638
12032
|
__export(exports_update, {
|
|
11639
12033
|
update: () => update
|
|
11640
12034
|
});
|
|
11641
|
-
import { resolve as
|
|
12035
|
+
import { resolve as resolve8 } from "path";
|
|
11642
12036
|
function parseArgs(args) {
|
|
11643
12037
|
let dryRun = false;
|
|
11644
12038
|
let project = null;
|
|
@@ -11696,7 +12090,7 @@ async function update(cwd, args) {
|
|
|
11696
12090
|
}
|
|
11697
12091
|
const backupName = createBackup(target.cwd);
|
|
11698
12092
|
console.log(` backup: ${backupName}`);
|
|
11699
|
-
const settingsPath =
|
|
12093
|
+
const settingsPath = resolve8(target.cwd, ".claude", "settings.json");
|
|
11700
12094
|
mergeHooksIntoSettings2(settingsPath, newHooks);
|
|
11701
12095
|
console.log(" hooks: updated");
|
|
11702
12096
|
const metaPath = projectMetaPath(target.cwd);
|
|
@@ -11872,7 +12266,7 @@ var init_restore = __esm(() => {
|
|
|
11872
12266
|
|
|
11873
12267
|
// src/core/design-eval/server-detect.ts
|
|
11874
12268
|
import { readFileSync as readFileSync26 } from "fs";
|
|
11875
|
-
import { join as
|
|
12269
|
+
import { join as join30 } from "path";
|
|
11876
12270
|
async function probePort(port) {
|
|
11877
12271
|
try {
|
|
11878
12272
|
const controller = new AbortController;
|
|
@@ -11894,7 +12288,7 @@ async function findRunningServer(ports = DEFAULT_PROBE_PORTS) {
|
|
|
11894
12288
|
}
|
|
11895
12289
|
function detectDevCommand(cwd) {
|
|
11896
12290
|
try {
|
|
11897
|
-
const raw = readFileSync26(
|
|
12291
|
+
const raw = readFileSync26(join30(cwd, "package.json"), "utf-8");
|
|
11898
12292
|
const pkg = JSON.parse(raw);
|
|
11899
12293
|
const scripts = pkg.scripts;
|
|
11900
12294
|
if (!scripts || typeof scripts !== "object")
|
|
@@ -11914,10 +12308,10 @@ var init_server_detect = __esm(() => {
|
|
|
11914
12308
|
});
|
|
11915
12309
|
|
|
11916
12310
|
// src/core/design-eval/route-detect.ts
|
|
11917
|
-
import { existsSync as
|
|
11918
|
-
import { join as
|
|
12311
|
+
import { existsSync as existsSync35, readdirSync as readdirSync10, statSync as statSync12 } from "fs";
|
|
12312
|
+
import { join as join31, relative as relative8, sep as sep2 } from "path";
|
|
11919
12313
|
function detectFramework(cwd) {
|
|
11920
|
-
const has = (name) => ["js", "mjs", "ts", "cjs"].some((ext) =>
|
|
12314
|
+
const has = (name) => ["js", "mjs", "ts", "cjs"].some((ext) => existsSync35(join31(cwd, `${name}.${ext}`))) || existsSync35(join31(cwd, name));
|
|
11921
12315
|
if (has("next.config"))
|
|
11922
12316
|
return "nextjs";
|
|
11923
12317
|
if (has("svelte.config"))
|
|
@@ -11942,8 +12336,8 @@ function detectRoutes(cwd) {
|
|
|
11942
12336
|
}
|
|
11943
12337
|
function detectNextRoutes(cwd) {
|
|
11944
12338
|
const routes = [];
|
|
11945
|
-
const appDir =
|
|
11946
|
-
if (
|
|
12339
|
+
const appDir = join31(cwd, "app");
|
|
12340
|
+
if (existsSync35(appDir)) {
|
|
11947
12341
|
const pageFiles = findFiles(appDir, /^page\.(tsx?|jsx?)$/);
|
|
11948
12342
|
for (const file of pageFiles) {
|
|
11949
12343
|
const rel = relative8(appDir, file);
|
|
@@ -11954,8 +12348,8 @@ function detectNextRoutes(cwd) {
|
|
|
11954
12348
|
routes.push(route);
|
|
11955
12349
|
}
|
|
11956
12350
|
}
|
|
11957
|
-
const pagesDir =
|
|
11958
|
-
if (
|
|
12351
|
+
const pagesDir = join31(cwd, "pages");
|
|
12352
|
+
if (existsSync35(pagesDir)) {
|
|
11959
12353
|
const pageFiles = findFiles(pagesDir, /\.(tsx?|jsx?)$/);
|
|
11960
12354
|
for (const file of pageFiles) {
|
|
11961
12355
|
const rel = relative8(pagesDir, file);
|
|
@@ -11974,8 +12368,8 @@ function detectNextRoutes(cwd) {
|
|
|
11974
12368
|
return unique.length > 0 ? unique.sort() : ["/"];
|
|
11975
12369
|
}
|
|
11976
12370
|
function detectSvelteKitRoutes(cwd) {
|
|
11977
|
-
const routesDir =
|
|
11978
|
-
if (!
|
|
12371
|
+
const routesDir = join31(cwd, "src", "routes");
|
|
12372
|
+
if (!existsSync35(routesDir))
|
|
11979
12373
|
return ["/"];
|
|
11980
12374
|
const routes = [];
|
|
11981
12375
|
const pageFiles = findFiles(routesDir, /^\+page\.svelte$/);
|
|
@@ -11990,8 +12384,8 @@ function detectSvelteKitRoutes(cwd) {
|
|
|
11990
12384
|
return routes.length > 0 ? routes.sort() : ["/"];
|
|
11991
12385
|
}
|
|
11992
12386
|
function detectNuxtRoutes(cwd) {
|
|
11993
|
-
const pagesDir =
|
|
11994
|
-
if (!
|
|
12387
|
+
const pagesDir = join31(cwd, "pages");
|
|
12388
|
+
if (!existsSync35(pagesDir))
|
|
11995
12389
|
return ["/"];
|
|
11996
12390
|
const routes = [];
|
|
11997
12391
|
const vueFiles = findFiles(pagesDir, /\.vue$/);
|
|
@@ -12017,7 +12411,7 @@ function findFiles(dir, pattern) {
|
|
|
12017
12411
|
for (const entry of entries) {
|
|
12018
12412
|
if (entry.startsWith(".") || entry === "node_modules")
|
|
12019
12413
|
continue;
|
|
12020
|
-
const full =
|
|
12414
|
+
const full = join31(current, entry);
|
|
12021
12415
|
try {
|
|
12022
12416
|
const stat2 = statSync12(full);
|
|
12023
12417
|
if (stat2.isDirectory()) {
|
|
@@ -12045,11 +12439,11 @@ function __extends(d, b) {
|
|
|
12045
12439
|
}
|
|
12046
12440
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
12047
12441
|
function adopt(value) {
|
|
12048
|
-
return value instanceof P ? value : new P(function(
|
|
12049
|
-
|
|
12442
|
+
return value instanceof P ? value : new P(function(resolve9) {
|
|
12443
|
+
resolve9(value);
|
|
12050
12444
|
});
|
|
12051
12445
|
}
|
|
12052
|
-
return new (P || (P = Promise))(function(
|
|
12446
|
+
return new (P || (P = Promise))(function(resolve9, reject) {
|
|
12053
12447
|
function fulfilled(value) {
|
|
12054
12448
|
try {
|
|
12055
12449
|
step(generator.next(value));
|
|
@@ -12065,7 +12459,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
12065
12459
|
}
|
|
12066
12460
|
}
|
|
12067
12461
|
function step(result) {
|
|
12068
|
-
result.done ?
|
|
12462
|
+
result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
12069
12463
|
}
|
|
12070
12464
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12071
12465
|
});
|
|
@@ -12248,14 +12642,14 @@ function __asyncValues(o) {
|
|
|
12248
12642
|
}, i);
|
|
12249
12643
|
function verb(n) {
|
|
12250
12644
|
i[n] = o[n] && function(v) {
|
|
12251
|
-
return new Promise(function(
|
|
12252
|
-
v = o[n](v), settle(
|
|
12645
|
+
return new Promise(function(resolve9, reject) {
|
|
12646
|
+
v = o[n](v), settle(resolve9, reject, v.done, v.value);
|
|
12253
12647
|
});
|
|
12254
12648
|
};
|
|
12255
12649
|
}
|
|
12256
|
-
function settle(
|
|
12650
|
+
function settle(resolve9, reject, d, v) {
|
|
12257
12651
|
Promise.resolve(v).then(function(v2) {
|
|
12258
|
-
|
|
12652
|
+
resolve9({ value: v2, done: d });
|
|
12259
12653
|
}, reject);
|
|
12260
12654
|
}
|
|
12261
12655
|
}
|
|
@@ -12786,7 +13180,7 @@ function of() {
|
|
|
12786
13180
|
}
|
|
12787
13181
|
function lastValueFrom(source, config22) {
|
|
12788
13182
|
var hasConfig = typeof config22 === "object";
|
|
12789
|
-
return new Promise(function(
|
|
13183
|
+
return new Promise(function(resolve9, reject) {
|
|
12790
13184
|
var _hasValue = false;
|
|
12791
13185
|
var _value;
|
|
12792
13186
|
source.subscribe({
|
|
@@ -12797,9 +13191,9 @@ function lastValueFrom(source, config22) {
|
|
|
12797
13191
|
error: reject,
|
|
12798
13192
|
complete: function() {
|
|
12799
13193
|
if (_hasValue) {
|
|
12800
|
-
|
|
13194
|
+
resolve9(_value);
|
|
12801
13195
|
} else if (hasConfig) {
|
|
12802
|
-
|
|
13196
|
+
resolve9(config22.defaultValue);
|
|
12803
13197
|
} else {
|
|
12804
13198
|
reject(new EmptyError);
|
|
12805
13199
|
}
|
|
@@ -12809,16 +13203,16 @@ function lastValueFrom(source, config22) {
|
|
|
12809
13203
|
}
|
|
12810
13204
|
function firstValueFrom(source, config22) {
|
|
12811
13205
|
var hasConfig = typeof config22 === "object";
|
|
12812
|
-
return new Promise(function(
|
|
13206
|
+
return new Promise(function(resolve9, reject) {
|
|
12813
13207
|
var subscriber = new SafeSubscriber({
|
|
12814
13208
|
next: function(value) {
|
|
12815
|
-
|
|
13209
|
+
resolve9(value);
|
|
12816
13210
|
subscriber.unsubscribe();
|
|
12817
13211
|
},
|
|
12818
13212
|
error: reject,
|
|
12819
13213
|
complete: function() {
|
|
12820
13214
|
if (hasConfig) {
|
|
12821
|
-
|
|
13215
|
+
resolve9(config22.defaultValue);
|
|
12822
13216
|
} else {
|
|
12823
13217
|
reject(new EmptyError);
|
|
12824
13218
|
}
|
|
@@ -13870,7 +14264,7 @@ var init_rxjs = __esm(() => {
|
|
|
13870
14264
|
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
13871
14265
|
var _this = this;
|
|
13872
14266
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
13873
|
-
return new promiseCtor(function(
|
|
14267
|
+
return new promiseCtor(function(resolve9, reject) {
|
|
13874
14268
|
var subscriber = new SafeSubscriber({
|
|
13875
14269
|
next: function(value) {
|
|
13876
14270
|
try {
|
|
@@ -13881,7 +14275,7 @@ var init_rxjs = __esm(() => {
|
|
|
13881
14275
|
}
|
|
13882
14276
|
},
|
|
13883
14277
|
error: reject,
|
|
13884
|
-
complete:
|
|
14278
|
+
complete: resolve9
|
|
13885
14279
|
});
|
|
13886
14280
|
_this.subscribe(subscriber);
|
|
13887
14281
|
});
|
|
@@ -13903,14 +14297,14 @@ var init_rxjs = __esm(() => {
|
|
|
13903
14297
|
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
13904
14298
|
var _this = this;
|
|
13905
14299
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
13906
|
-
return new promiseCtor(function(
|
|
14300
|
+
return new promiseCtor(function(resolve9, reject) {
|
|
13907
14301
|
var value;
|
|
13908
14302
|
_this.subscribe(function(x) {
|
|
13909
14303
|
return value = x;
|
|
13910
14304
|
}, function(err) {
|
|
13911
14305
|
return reject(err);
|
|
13912
14306
|
}, function() {
|
|
13913
|
-
return
|
|
14307
|
+
return resolve9(value);
|
|
13914
14308
|
});
|
|
13915
14309
|
});
|
|
13916
14310
|
};
|
|
@@ -15836,8 +16230,8 @@ class Deferred {
|
|
|
15836
16230
|
#isRejected = false;
|
|
15837
16231
|
#value;
|
|
15838
16232
|
#resolve;
|
|
15839
|
-
#taskPromise = new Promise((
|
|
15840
|
-
this.#resolve =
|
|
16233
|
+
#taskPromise = new Promise((resolve9) => {
|
|
16234
|
+
this.#resolve = resolve9;
|
|
15841
16235
|
});
|
|
15842
16236
|
#timeoutId;
|
|
15843
16237
|
#timeoutError;
|
|
@@ -15926,12 +16320,12 @@ var init_Mutex = __esm(() => {
|
|
|
15926
16320
|
return new Mutex.Guard(this, onRelease);
|
|
15927
16321
|
}
|
|
15928
16322
|
release() {
|
|
15929
|
-
const
|
|
15930
|
-
if (!
|
|
16323
|
+
const resolve9 = this.#acquirers.shift();
|
|
16324
|
+
if (!resolve9) {
|
|
15931
16325
|
this.#locked = false;
|
|
15932
16326
|
return;
|
|
15933
16327
|
}
|
|
15934
|
-
|
|
16328
|
+
resolve9();
|
|
15935
16329
|
}
|
|
15936
16330
|
};
|
|
15937
16331
|
});
|
|
@@ -17675,12 +18069,12 @@ var init_locators = __esm(() => {
|
|
|
17675
18069
|
}
|
|
17676
18070
|
return defer(() => {
|
|
17677
18071
|
return from(handle.evaluate((element) => {
|
|
17678
|
-
return new Promise((
|
|
18072
|
+
return new Promise((resolve9) => {
|
|
17679
18073
|
window.requestAnimationFrame(() => {
|
|
17680
18074
|
const rect1 = element.getBoundingClientRect();
|
|
17681
18075
|
window.requestAnimationFrame(() => {
|
|
17682
18076
|
const rect2 = element.getBoundingClientRect();
|
|
17683
|
-
|
|
18077
|
+
resolve9([
|
|
17684
18078
|
{
|
|
17685
18079
|
x: rect1.x,
|
|
17686
18080
|
y: rect1.y,
|
|
@@ -18971,9 +19365,9 @@ var init_ElementHandle = __esm(() => {
|
|
|
18971
19365
|
const handle = await this.#asSVGElementHandle();
|
|
18972
19366
|
const target = __addDisposableResource6(env_5, handle && await handle.#getOwnerSVGElement(), false);
|
|
18973
19367
|
return await (target ?? this).evaluate(async (element, threshold) => {
|
|
18974
|
-
const visibleRatio = await new Promise((
|
|
19368
|
+
const visibleRatio = await new Promise((resolve9) => {
|
|
18975
19369
|
const observer = new IntersectionObserver((entries) => {
|
|
18976
|
-
|
|
19370
|
+
resolve9(entries[0].intersectionRatio);
|
|
18977
19371
|
observer.disconnect();
|
|
18978
19372
|
});
|
|
18979
19373
|
observer.observe(element);
|
|
@@ -19367,7 +19761,7 @@ var init_Frame = __esm(() => {
|
|
|
19367
19761
|
}
|
|
19368
19762
|
type = type ?? "text/javascript";
|
|
19369
19763
|
return await this.mainRealm().transferHandle(await this.isolatedRealm().evaluateHandle(async ({ url, id, type: type2, content: content2 }) => {
|
|
19370
|
-
return await new Promise((
|
|
19764
|
+
return await new Promise((resolve9, reject) => {
|
|
19371
19765
|
const script = document.createElement("script");
|
|
19372
19766
|
script.type = type2;
|
|
19373
19767
|
script.text = content2;
|
|
@@ -19380,12 +19774,12 @@ var init_Frame = __esm(() => {
|
|
|
19380
19774
|
if (url) {
|
|
19381
19775
|
script.src = url;
|
|
19382
19776
|
script.addEventListener("load", () => {
|
|
19383
|
-
|
|
19777
|
+
resolve9(script);
|
|
19384
19778
|
}, { once: true });
|
|
19385
19779
|
document.head.appendChild(script);
|
|
19386
19780
|
} else {
|
|
19387
19781
|
document.head.appendChild(script);
|
|
19388
|
-
|
|
19782
|
+
resolve9(script);
|
|
19389
19783
|
}
|
|
19390
19784
|
});
|
|
19391
19785
|
}, { ...options, type, content }));
|
|
@@ -19402,7 +19796,7 @@ var init_Frame = __esm(() => {
|
|
|
19402
19796
|
options.content = content;
|
|
19403
19797
|
}
|
|
19404
19798
|
return await this.mainRealm().transferHandle(await this.isolatedRealm().evaluateHandle(async ({ url, content: content2 }) => {
|
|
19405
|
-
return await new Promise((
|
|
19799
|
+
return await new Promise((resolve9, reject) => {
|
|
19406
19800
|
let element;
|
|
19407
19801
|
if (!url) {
|
|
19408
19802
|
element = document.createElement("style");
|
|
@@ -19414,7 +19808,7 @@ var init_Frame = __esm(() => {
|
|
|
19414
19808
|
element = link;
|
|
19415
19809
|
}
|
|
19416
19810
|
element.addEventListener("load", () => {
|
|
19417
|
-
|
|
19811
|
+
resolve9(element);
|
|
19418
19812
|
}, { once: true });
|
|
19419
19813
|
element.addEventListener("error", (event) => {
|
|
19420
19814
|
reject(new Error(event.message ?? "Could not load style"));
|
|
@@ -20268,9 +20662,9 @@ var init_Page = __esm(() => {
|
|
|
20268
20662
|
++this.#screencastSessionCount;
|
|
20269
20663
|
if (!this.#startScreencastPromise) {
|
|
20270
20664
|
this.#startScreencastPromise = this.mainFrame().client.send("Page.startScreencast", { format: "png" }).then(() => {
|
|
20271
|
-
return new Promise((
|
|
20665
|
+
return new Promise((resolve9) => {
|
|
20272
20666
|
return this.mainFrame().client.once("Page.screencastFrame", () => {
|
|
20273
|
-
return
|
|
20667
|
+
return resolve9();
|
|
20274
20668
|
});
|
|
20275
20669
|
});
|
|
20276
20670
|
});
|
|
@@ -22928,11 +23322,11 @@ function addPageBinding(type, name, prefix) {
|
|
|
22928
23322
|
return value instanceof Node;
|
|
22929
23323
|
})
|
|
22930
23324
|
}));
|
|
22931
|
-
return new Promise((
|
|
23325
|
+
return new Promise((resolve9, reject) => {
|
|
22932
23326
|
callPuppeteer.callbacks.set(seq, {
|
|
22933
23327
|
resolve(value) {
|
|
22934
23328
|
callPuppeteer.args.delete(seq);
|
|
22935
|
-
|
|
23329
|
+
resolve9(value);
|
|
22936
23330
|
},
|
|
22937
23331
|
reject(value) {
|
|
22938
23332
|
callPuppeteer.args.delete(seq);
|
|
@@ -26395,8 +26789,8 @@ var init_Input2 = __esm(() => {
|
|
|
26395
26789
|
if (typeof delay === "number") {
|
|
26396
26790
|
await Promise.all(actions);
|
|
26397
26791
|
actions.length = 0;
|
|
26398
|
-
await new Promise((
|
|
26399
|
-
setTimeout(
|
|
26792
|
+
await new Promise((resolve9) => {
|
|
26793
|
+
setTimeout(resolve9, delay);
|
|
26400
26794
|
});
|
|
26401
26795
|
}
|
|
26402
26796
|
actions.push(this.up({ ...options, clickCount }));
|
|
@@ -26416,9 +26810,9 @@ var init_Input2 = __esm(() => {
|
|
|
26416
26810
|
});
|
|
26417
26811
|
}
|
|
26418
26812
|
async drag(start, target) {
|
|
26419
|
-
const promise = new Promise((
|
|
26813
|
+
const promise = new Promise((resolve9) => {
|
|
26420
26814
|
this.#client.once("Input.dragIntercepted", (event) => {
|
|
26421
|
-
return
|
|
26815
|
+
return resolve9(event.data);
|
|
26422
26816
|
});
|
|
26423
26817
|
});
|
|
26424
26818
|
await this.move(start.x, start.y);
|
|
@@ -26459,8 +26853,8 @@ var init_Input2 = __esm(() => {
|
|
|
26459
26853
|
await this.dragEnter(target, data);
|
|
26460
26854
|
await this.dragOver(target, data);
|
|
26461
26855
|
if (delay) {
|
|
26462
|
-
await new Promise((
|
|
26463
|
-
return setTimeout(
|
|
26856
|
+
await new Promise((resolve9) => {
|
|
26857
|
+
return setTimeout(resolve9, delay);
|
|
26464
26858
|
});
|
|
26465
26859
|
}
|
|
26466
26860
|
await this.drop(target, data);
|
|
@@ -27272,9 +27666,9 @@ var init_Page2 = __esm(() => {
|
|
|
27272
27666
|
async captureHeapSnapshot(options) {
|
|
27273
27667
|
const { createWriteStream } = environment.value.fs;
|
|
27274
27668
|
const stream = createWriteStream(options.path);
|
|
27275
|
-
const streamPromise = new Promise((
|
|
27669
|
+
const streamPromise = new Promise((resolve9, reject) => {
|
|
27276
27670
|
stream.on("error", reject);
|
|
27277
|
-
stream.on("finish",
|
|
27671
|
+
stream.on("finish", resolve9);
|
|
27278
27672
|
});
|
|
27279
27673
|
const client = this.#primaryTargetClient;
|
|
27280
27674
|
await client.send("HeapProfiler.enable");
|
|
@@ -28787,10 +29181,10 @@ __export(exports_BrowserWebSocketTransport, {
|
|
|
28787
29181
|
|
|
28788
29182
|
class BrowserWebSocketTransport {
|
|
28789
29183
|
static create(url) {
|
|
28790
|
-
return new Promise((
|
|
29184
|
+
return new Promise((resolve9, reject) => {
|
|
28791
29185
|
const ws = new WebSocket(url);
|
|
28792
29186
|
ws.addEventListener("open", () => {
|
|
28793
|
-
return
|
|
29187
|
+
return resolve9(new BrowserWebSocketTransport(ws));
|
|
28794
29188
|
});
|
|
28795
29189
|
ws.addEventListener("error", reject);
|
|
28796
29190
|
});
|
|
@@ -31624,11 +32018,11 @@ var require_BrowsingContextProcessor = __commonJS((exports) => {
|
|
|
31624
32018
|
}
|
|
31625
32019
|
const parentCdpClient = context2.cdpTarget.parentCdpClient;
|
|
31626
32020
|
try {
|
|
31627
|
-
const detachedFromTargetPromise = new Promise((
|
|
32021
|
+
const detachedFromTargetPromise = new Promise((resolve9) => {
|
|
31628
32022
|
const onContextDestroyed = (event) => {
|
|
31629
32023
|
if (event.targetId === params.context) {
|
|
31630
32024
|
parentCdpClient.off("Target.detachedFromTarget", onContextDestroyed);
|
|
31631
|
-
|
|
32025
|
+
resolve9();
|
|
31632
32026
|
}
|
|
31633
32027
|
};
|
|
31634
32028
|
parentCdpClient.on("Target.detachedFromTarget", onContextDestroyed);
|
|
@@ -32948,7 +33342,7 @@ var require_ActionDispatcher = __commonJS((exports) => {
|
|
|
32948
33342
|
}
|
|
32949
33343
|
}
|
|
32950
33344
|
const promises = [
|
|
32951
|
-
new Promise((
|
|
33345
|
+
new Promise((resolve9) => setTimeout(resolve9, this.#tickDuration))
|
|
32952
33346
|
];
|
|
32953
33347
|
for (const option of options) {
|
|
32954
33348
|
promises.push(this.#dispatchAction(option));
|
|
@@ -33547,8 +33941,8 @@ var require_Mutex = __commonJS((exports) => {
|
|
|
33547
33941
|
acquire() {
|
|
33548
33942
|
const state = { resolved: false };
|
|
33549
33943
|
if (this.#locked) {
|
|
33550
|
-
return new Promise((
|
|
33551
|
-
this.#acquirers.push(() =>
|
|
33944
|
+
return new Promise((resolve9) => {
|
|
33945
|
+
this.#acquirers.push(() => resolve9(this.#release.bind(this, state)));
|
|
33552
33946
|
});
|
|
33553
33947
|
}
|
|
33554
33948
|
this.#locked = true;
|
|
@@ -33559,12 +33953,12 @@ var require_Mutex = __commonJS((exports) => {
|
|
|
33559
33953
|
throw new Error("Cannot release more than once.");
|
|
33560
33954
|
}
|
|
33561
33955
|
state.resolved = true;
|
|
33562
|
-
const
|
|
33563
|
-
if (!
|
|
33956
|
+
const resolve9 = this.#acquirers.shift();
|
|
33957
|
+
if (!resolve9) {
|
|
33564
33958
|
this.#locked = false;
|
|
33565
33959
|
return;
|
|
33566
33960
|
}
|
|
33567
|
-
|
|
33961
|
+
resolve9();
|
|
33568
33962
|
}
|
|
33569
33963
|
async run(action) {
|
|
33570
33964
|
const release = await this.acquire();
|
|
@@ -34691,8 +35085,8 @@ var require_ChannelProxy = __commonJS((exports) => {
|
|
|
34691
35085
|
let queueNonEmptyResolver = null;
|
|
34692
35086
|
return {
|
|
34693
35087
|
async getMessage() {
|
|
34694
|
-
const onMessage = queue.length > 0 ? Promise.resolve() : new Promise((
|
|
34695
|
-
queueNonEmptyResolver =
|
|
35088
|
+
const onMessage = queue.length > 0 ? Promise.resolve() : new Promise((resolve9) => {
|
|
35089
|
+
queueNonEmptyResolver = resolve9;
|
|
34696
35090
|
});
|
|
34697
35091
|
await onMessage;
|
|
34698
35092
|
return queue.shift();
|
|
@@ -34778,7 +35172,7 @@ var require_ChannelProxy = __commonJS((exports) => {
|
|
|
34778
35172
|
functionDeclaration: String((id) => {
|
|
34779
35173
|
const w = window;
|
|
34780
35174
|
if (w[id] === undefined) {
|
|
34781
|
-
return new Promise((
|
|
35175
|
+
return new Promise((resolve9) => w[id] = resolve9);
|
|
34782
35176
|
}
|
|
34783
35177
|
const channelProxy = w[id];
|
|
34784
35178
|
delete w[id];
|
|
@@ -36129,8 +36523,8 @@ var require_Deferred = __commonJS((exports) => {
|
|
|
36129
36523
|
return this.#result;
|
|
36130
36524
|
}
|
|
36131
36525
|
constructor() {
|
|
36132
|
-
this.#promise = new Promise((
|
|
36133
|
-
this.#resolve =
|
|
36526
|
+
this.#promise = new Promise((resolve9, reject) => {
|
|
36527
|
+
this.#resolve = resolve9;
|
|
36134
36528
|
this.#reject = reject;
|
|
36135
36529
|
});
|
|
36136
36530
|
this.#promise.catch((_error) => {});
|
|
@@ -40455,11 +40849,11 @@ var require_BrowsingContextStorage = __commonJS((exports) => {
|
|
|
40455
40849
|
if (this.#contexts.has(browsingContextId)) {
|
|
40456
40850
|
return Promise.resolve(this.getContext(browsingContextId));
|
|
40457
40851
|
}
|
|
40458
|
-
return new Promise((
|
|
40852
|
+
return new Promise((resolve9) => {
|
|
40459
40853
|
const listener = (event) => {
|
|
40460
40854
|
if (event.browsingContext.id === browsingContextId) {
|
|
40461
40855
|
this.#eventEmitter.off("added", listener);
|
|
40462
|
-
|
|
40856
|
+
resolve9(event.browsingContext);
|
|
40463
40857
|
}
|
|
40464
40858
|
};
|
|
40465
40859
|
this.#eventEmitter.on("added", listener);
|
|
@@ -43955,8 +44349,8 @@ var init_ExposedFunction = __esm(() => {
|
|
|
43955
44349
|
const functionDeclaration = stringifyFunction(interpolateFunction((callback) => {
|
|
43956
44350
|
Object.assign(globalThis, {
|
|
43957
44351
|
[PLACEHOLDER("name")]: function(...args) {
|
|
43958
|
-
return new Promise((
|
|
43959
|
-
callback([
|
|
44352
|
+
return new Promise((resolve9, reject) => {
|
|
44353
|
+
callback([resolve9, reject, args]);
|
|
43960
44354
|
});
|
|
43961
44355
|
}
|
|
43962
44356
|
});
|
|
@@ -44044,8 +44438,8 @@ var init_ExposedFunction = __esm(() => {
|
|
|
44044
44438
|
return;
|
|
44045
44439
|
}
|
|
44046
44440
|
try {
|
|
44047
|
-
await dataHandle.evaluate(([
|
|
44048
|
-
|
|
44441
|
+
await dataHandle.evaluate(([resolve9], result2) => {
|
|
44442
|
+
resolve9(result2);
|
|
44049
44443
|
}, result);
|
|
44050
44444
|
} catch (error) {
|
|
44051
44445
|
debugError(error);
|
|
@@ -51337,7 +51731,7 @@ __export(exports_NodeWebSocketTransport, {
|
|
|
51337
51731
|
|
|
51338
51732
|
class NodeWebSocketTransport {
|
|
51339
51733
|
static create(url, headers) {
|
|
51340
|
-
return new Promise((
|
|
51734
|
+
return new Promise((resolve9, reject) => {
|
|
51341
51735
|
const ws = new wrapper_default(url, [], {
|
|
51342
51736
|
followRedirects: true,
|
|
51343
51737
|
perMessageDeflate: false,
|
|
@@ -51349,7 +51743,7 @@ class NodeWebSocketTransport {
|
|
|
51349
51743
|
}
|
|
51350
51744
|
});
|
|
51351
51745
|
ws.addEventListener("open", () => {
|
|
51352
|
-
return
|
|
51746
|
+
return resolve9(new NodeWebSocketTransport(ws));
|
|
51353
51747
|
});
|
|
51354
51748
|
ws.addEventListener("error", reject);
|
|
51355
51749
|
});
|
|
@@ -54241,8 +54635,8 @@ var require_helpers = __commonJS((exports) => {
|
|
|
54241
54635
|
function req(url, opts = {}) {
|
|
54242
54636
|
const href = typeof url === "string" ? url : url.href;
|
|
54243
54637
|
const req2 = (href.startsWith("https:") ? https : http).request(url, opts);
|
|
54244
|
-
const promise = new Promise((
|
|
54245
|
-
req2.once("response",
|
|
54638
|
+
const promise = new Promise((resolve9, reject) => {
|
|
54639
|
+
req2.once("response", resolve9).once("error", reject).end();
|
|
54246
54640
|
});
|
|
54247
54641
|
req2.then = promise.then.bind(promise);
|
|
54248
54642
|
return req2;
|
|
@@ -54613,7 +55007,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
|
|
|
54613
55007
|
var debug_1 = __importDefault(require_src());
|
|
54614
55008
|
var debug2 = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
54615
55009
|
function parseProxyResponse(socket) {
|
|
54616
|
-
return new Promise((
|
|
55010
|
+
return new Promise((resolve9, reject) => {
|
|
54617
55011
|
let buffersLength = 0;
|
|
54618
55012
|
const buffers = [];
|
|
54619
55013
|
function read() {
|
|
@@ -54682,7 +55076,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
|
|
|
54682
55076
|
}
|
|
54683
55077
|
debug2("got proxy server response: %o %o", firstLine, headers);
|
|
54684
55078
|
cleanup();
|
|
54685
|
-
|
|
55079
|
+
resolve9({
|
|
54686
55080
|
connect: {
|
|
54687
55081
|
statusCode,
|
|
54688
55082
|
statusText,
|
|
@@ -56786,11 +57180,11 @@ var require_receivebuffer = __commonJS((exports) => {
|
|
|
56786
57180
|
var require_socksclient = __commonJS((exports) => {
|
|
56787
57181
|
var __awaiter2 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
56788
57182
|
function adopt(value) {
|
|
56789
|
-
return value instanceof P ? value : new P(function(
|
|
56790
|
-
|
|
57183
|
+
return value instanceof P ? value : new P(function(resolve9) {
|
|
57184
|
+
resolve9(value);
|
|
56791
57185
|
});
|
|
56792
57186
|
}
|
|
56793
|
-
return new (P || (P = Promise))(function(
|
|
57187
|
+
return new (P || (P = Promise))(function(resolve9, reject) {
|
|
56794
57188
|
function fulfilled(value) {
|
|
56795
57189
|
try {
|
|
56796
57190
|
step(generator.next(value));
|
|
@@ -56806,7 +57200,7 @@ var require_socksclient = __commonJS((exports) => {
|
|
|
56806
57200
|
}
|
|
56807
57201
|
}
|
|
56808
57202
|
function step(result) {
|
|
56809
|
-
result.done ?
|
|
57203
|
+
result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
56810
57204
|
}
|
|
56811
57205
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
56812
57206
|
});
|
|
@@ -56833,13 +57227,13 @@ var require_socksclient = __commonJS((exports) => {
|
|
|
56833
57227
|
this.setState(constants_1.SocksClientState.Created);
|
|
56834
57228
|
}
|
|
56835
57229
|
static createConnection(options, callback) {
|
|
56836
|
-
return new Promise((
|
|
57230
|
+
return new Promise((resolve9, reject) => {
|
|
56837
57231
|
try {
|
|
56838
57232
|
(0, helpers_1.validateSocksClientOptions)(options, ["connect"]);
|
|
56839
57233
|
} catch (err) {
|
|
56840
57234
|
if (typeof callback === "function") {
|
|
56841
57235
|
callback(err);
|
|
56842
|
-
return
|
|
57236
|
+
return resolve9(err);
|
|
56843
57237
|
} else {
|
|
56844
57238
|
return reject(err);
|
|
56845
57239
|
}
|
|
@@ -56850,16 +57244,16 @@ var require_socksclient = __commonJS((exports) => {
|
|
|
56850
57244
|
client.removeAllListeners();
|
|
56851
57245
|
if (typeof callback === "function") {
|
|
56852
57246
|
callback(null, info);
|
|
56853
|
-
|
|
57247
|
+
resolve9(info);
|
|
56854
57248
|
} else {
|
|
56855
|
-
|
|
57249
|
+
resolve9(info);
|
|
56856
57250
|
}
|
|
56857
57251
|
});
|
|
56858
57252
|
client.once("error", (err) => {
|
|
56859
57253
|
client.removeAllListeners();
|
|
56860
57254
|
if (typeof callback === "function") {
|
|
56861
57255
|
callback(err);
|
|
56862
|
-
|
|
57256
|
+
resolve9(err);
|
|
56863
57257
|
} else {
|
|
56864
57258
|
reject(err);
|
|
56865
57259
|
}
|
|
@@ -56867,13 +57261,13 @@ var require_socksclient = __commonJS((exports) => {
|
|
|
56867
57261
|
});
|
|
56868
57262
|
}
|
|
56869
57263
|
static createConnectionChain(options, callback) {
|
|
56870
|
-
return new Promise((
|
|
57264
|
+
return new Promise((resolve9, reject) => __awaiter2(this, undefined, undefined, function* () {
|
|
56871
57265
|
try {
|
|
56872
57266
|
(0, helpers_1.validateSocksClientChainOptions)(options);
|
|
56873
57267
|
} catch (err) {
|
|
56874
57268
|
if (typeof callback === "function") {
|
|
56875
57269
|
callback(err);
|
|
56876
|
-
return
|
|
57270
|
+
return resolve9(err);
|
|
56877
57271
|
} else {
|
|
56878
57272
|
return reject(err);
|
|
56879
57273
|
}
|
|
@@ -56899,14 +57293,14 @@ var require_socksclient = __commonJS((exports) => {
|
|
|
56899
57293
|
}
|
|
56900
57294
|
if (typeof callback === "function") {
|
|
56901
57295
|
callback(null, { socket: sock });
|
|
56902
|
-
|
|
57296
|
+
resolve9({ socket: sock });
|
|
56903
57297
|
} else {
|
|
56904
|
-
|
|
57298
|
+
resolve9({ socket: sock });
|
|
56905
57299
|
}
|
|
56906
57300
|
} catch (err) {
|
|
56907
57301
|
if (typeof callback === "function") {
|
|
56908
57302
|
callback(err);
|
|
56909
|
-
|
|
57303
|
+
resolve9(err);
|
|
56910
57304
|
} else {
|
|
56911
57305
|
reject(err);
|
|
56912
57306
|
}
|
|
@@ -57506,12 +57900,12 @@ var require_dist4 = __commonJS((exports) => {
|
|
|
57506
57900
|
let { host } = opts;
|
|
57507
57901
|
const { port, lookup: lookupFn = dns.lookup } = opts;
|
|
57508
57902
|
if (shouldLookup) {
|
|
57509
|
-
host = await new Promise((
|
|
57903
|
+
host = await new Promise((resolve9, reject) => {
|
|
57510
57904
|
lookupFn(host, {}, (err, res) => {
|
|
57511
57905
|
if (err) {
|
|
57512
57906
|
reject(err);
|
|
57513
57907
|
} else {
|
|
57514
|
-
|
|
57908
|
+
resolve9(res);
|
|
57515
57909
|
}
|
|
57516
57910
|
});
|
|
57517
57911
|
});
|
|
@@ -58518,7 +58912,7 @@ var require_netUtils = __commonJS((exports) => {
|
|
|
58518
58912
|
return `${socket.remoteAddress}:${socket.remotePort}`;
|
|
58519
58913
|
}
|
|
58520
58914
|
function upgradeSocket(socket, options) {
|
|
58521
|
-
return new Promise((
|
|
58915
|
+
return new Promise((resolve9, reject) => {
|
|
58522
58916
|
const tlsOptions = Object.assign({}, options, {
|
|
58523
58917
|
socket
|
|
58524
58918
|
});
|
|
@@ -58528,7 +58922,7 @@ var require_netUtils = __commonJS((exports) => {
|
|
|
58528
58922
|
reject(tlsSocket.authorizationError);
|
|
58529
58923
|
} else {
|
|
58530
58924
|
tlsSocket.removeAllListeners("error");
|
|
58531
|
-
|
|
58925
|
+
resolve9(tlsSocket);
|
|
58532
58926
|
}
|
|
58533
58927
|
}).once("error", (error) => {
|
|
58534
58928
|
reject(error);
|
|
@@ -58620,7 +59014,7 @@ var require_transfer = __commonJS((exports) => {
|
|
|
58620
59014
|
};
|
|
58621
59015
|
}
|
|
58622
59016
|
function connectForPassiveTransfer(host, port, ftp) {
|
|
58623
|
-
return new Promise((
|
|
59017
|
+
return new Promise((resolve9, reject) => {
|
|
58624
59018
|
let socket = ftp._newSocket();
|
|
58625
59019
|
const handleConnErr = function(err) {
|
|
58626
59020
|
err.message = "Can't open data connection in passive mode: " + err.message;
|
|
@@ -58643,7 +59037,7 @@ var require_transfer = __commonJS((exports) => {
|
|
|
58643
59037
|
socket.removeListener("error", handleConnErr);
|
|
58644
59038
|
socket.removeListener("timeout", handleTimeout);
|
|
58645
59039
|
ftp.dataSocket = socket;
|
|
58646
|
-
|
|
59040
|
+
resolve9();
|
|
58647
59041
|
});
|
|
58648
59042
|
});
|
|
58649
59043
|
}
|
|
@@ -60721,7 +61115,7 @@ var require_util2 = __commonJS((exports) => {
|
|
|
60721
61115
|
return path;
|
|
60722
61116
|
}
|
|
60723
61117
|
exports.normalize = normalize2;
|
|
60724
|
-
function
|
|
61118
|
+
function join32(aRoot, aPath) {
|
|
60725
61119
|
if (aRoot === "") {
|
|
60726
61120
|
aRoot = ".";
|
|
60727
61121
|
}
|
|
@@ -60753,7 +61147,7 @@ var require_util2 = __commonJS((exports) => {
|
|
|
60753
61147
|
}
|
|
60754
61148
|
return joined;
|
|
60755
61149
|
}
|
|
60756
|
-
exports.join =
|
|
61150
|
+
exports.join = join32;
|
|
60757
61151
|
exports.isAbsolute = function(aPath) {
|
|
60758
61152
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
60759
61153
|
};
|
|
@@ -60926,7 +61320,7 @@ var require_util2 = __commonJS((exports) => {
|
|
|
60926
61320
|
parsed.path = parsed.path.substring(0, index + 1);
|
|
60927
61321
|
}
|
|
60928
61322
|
}
|
|
60929
|
-
sourceURL =
|
|
61323
|
+
sourceURL = join32(urlGenerate(parsed), sourceURL);
|
|
60930
61324
|
}
|
|
60931
61325
|
return normalize2(sourceURL);
|
|
60932
61326
|
}
|
|
@@ -62658,7 +63052,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
62658
63052
|
function noEmptySpace() {
|
|
62659
63053
|
return space ? space : " ";
|
|
62660
63054
|
}
|
|
62661
|
-
function
|
|
63055
|
+
function join32(left, right) {
|
|
62662
63056
|
var leftSource, rightSource, leftCharCode, rightCharCode;
|
|
62663
63057
|
leftSource = toSourceNodeWhenNeeded(left).toString();
|
|
62664
63058
|
if (leftSource.length === 0) {
|
|
@@ -62999,8 +63393,8 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
62999
63393
|
} else {
|
|
63000
63394
|
result.push(that.generateExpression(stmt.left, Precedence.Call, E_TTT));
|
|
63001
63395
|
}
|
|
63002
|
-
result =
|
|
63003
|
-
result = [
|
|
63396
|
+
result = join32(result, operator);
|
|
63397
|
+
result = [join32(result, that.generateExpression(stmt.right, Precedence.Assignment, E_TTT)), ")"];
|
|
63004
63398
|
});
|
|
63005
63399
|
result.push(this.maybeBlock(stmt.body, flags));
|
|
63006
63400
|
return result;
|
|
@@ -63138,11 +63532,11 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63138
63532
|
var result, fragment;
|
|
63139
63533
|
result = ["class"];
|
|
63140
63534
|
if (stmt.id) {
|
|
63141
|
-
result =
|
|
63535
|
+
result = join32(result, this.generateExpression(stmt.id, Precedence.Sequence, E_TTT));
|
|
63142
63536
|
}
|
|
63143
63537
|
if (stmt.superClass) {
|
|
63144
|
-
fragment =
|
|
63145
|
-
result =
|
|
63538
|
+
fragment = join32("extends", this.generateExpression(stmt.superClass, Precedence.Unary, E_TTT));
|
|
63539
|
+
result = join32(result, fragment);
|
|
63146
63540
|
}
|
|
63147
63541
|
result.push(space);
|
|
63148
63542
|
result.push(this.generateStatement(stmt.body, S_TFFT));
|
|
@@ -63155,9 +63549,9 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63155
63549
|
return escapeDirective(stmt.directive) + this.semicolon(flags);
|
|
63156
63550
|
},
|
|
63157
63551
|
DoWhileStatement: function(stmt, flags) {
|
|
63158
|
-
var result =
|
|
63552
|
+
var result = join32("do", this.maybeBlock(stmt.body, S_TFFF));
|
|
63159
63553
|
result = this.maybeBlockSuffix(stmt.body, result);
|
|
63160
|
-
return
|
|
63554
|
+
return join32(result, [
|
|
63161
63555
|
"while" + space + "(",
|
|
63162
63556
|
this.generateExpression(stmt.test, Precedence.Sequence, E_TTT),
|
|
63163
63557
|
")" + this.semicolon(flags)
|
|
@@ -63193,11 +63587,11 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63193
63587
|
ExportDefaultDeclaration: function(stmt, flags) {
|
|
63194
63588
|
var result = ["export"], bodyFlags;
|
|
63195
63589
|
bodyFlags = flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF;
|
|
63196
|
-
result =
|
|
63590
|
+
result = join32(result, "default");
|
|
63197
63591
|
if (isStatement(stmt.declaration)) {
|
|
63198
|
-
result =
|
|
63592
|
+
result = join32(result, this.generateStatement(stmt.declaration, bodyFlags));
|
|
63199
63593
|
} else {
|
|
63200
|
-
result =
|
|
63594
|
+
result = join32(result, this.generateExpression(stmt.declaration, Precedence.Assignment, E_TTT) + this.semicolon(flags));
|
|
63201
63595
|
}
|
|
63202
63596
|
return result;
|
|
63203
63597
|
},
|
|
@@ -63205,15 +63599,15 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63205
63599
|
var result = ["export"], bodyFlags, that = this;
|
|
63206
63600
|
bodyFlags = flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF;
|
|
63207
63601
|
if (stmt.declaration) {
|
|
63208
|
-
return
|
|
63602
|
+
return join32(result, this.generateStatement(stmt.declaration, bodyFlags));
|
|
63209
63603
|
}
|
|
63210
63604
|
if (stmt.specifiers) {
|
|
63211
63605
|
if (stmt.specifiers.length === 0) {
|
|
63212
|
-
result =
|
|
63606
|
+
result = join32(result, "{" + space + "}");
|
|
63213
63607
|
} else if (stmt.specifiers[0].type === Syntax.ExportBatchSpecifier) {
|
|
63214
|
-
result =
|
|
63608
|
+
result = join32(result, this.generateExpression(stmt.specifiers[0], Precedence.Sequence, E_TTT));
|
|
63215
63609
|
} else {
|
|
63216
|
-
result =
|
|
63610
|
+
result = join32(result, "{");
|
|
63217
63611
|
withIndent(function(indent2) {
|
|
63218
63612
|
var i, iz;
|
|
63219
63613
|
result.push(newline);
|
|
@@ -63231,7 +63625,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63231
63625
|
result.push(base + "}");
|
|
63232
63626
|
}
|
|
63233
63627
|
if (stmt.source) {
|
|
63234
|
-
result =
|
|
63628
|
+
result = join32(result, [
|
|
63235
63629
|
"from" + space,
|
|
63236
63630
|
this.generateExpression(stmt.source, Precedence.Sequence, E_TTT),
|
|
63237
63631
|
this.semicolon(flags)
|
|
@@ -63315,7 +63709,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63315
63709
|
];
|
|
63316
63710
|
cursor = 0;
|
|
63317
63711
|
if (stmt.specifiers[cursor].type === Syntax.ImportDefaultSpecifier) {
|
|
63318
|
-
result =
|
|
63712
|
+
result = join32(result, [
|
|
63319
63713
|
this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)
|
|
63320
63714
|
]);
|
|
63321
63715
|
++cursor;
|
|
@@ -63325,7 +63719,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63325
63719
|
result.push(",");
|
|
63326
63720
|
}
|
|
63327
63721
|
if (stmt.specifiers[cursor].type === Syntax.ImportNamespaceSpecifier) {
|
|
63328
|
-
result =
|
|
63722
|
+
result = join32(result, [
|
|
63329
63723
|
space,
|
|
63330
63724
|
this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)
|
|
63331
63725
|
]);
|
|
@@ -63354,7 +63748,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63354
63748
|
}
|
|
63355
63749
|
}
|
|
63356
63750
|
}
|
|
63357
|
-
result =
|
|
63751
|
+
result = join32(result, [
|
|
63358
63752
|
"from" + space,
|
|
63359
63753
|
this.generateExpression(stmt.source, Precedence.Sequence, E_TTT),
|
|
63360
63754
|
this.semicolon(flags)
|
|
@@ -63408,7 +63802,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63408
63802
|
return result;
|
|
63409
63803
|
},
|
|
63410
63804
|
ThrowStatement: function(stmt, flags) {
|
|
63411
|
-
return [
|
|
63805
|
+
return [join32("throw", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
|
|
63412
63806
|
},
|
|
63413
63807
|
TryStatement: function(stmt, flags) {
|
|
63414
63808
|
var result, i, iz, guardedHandlers;
|
|
@@ -63416,7 +63810,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63416
63810
|
result = this.maybeBlockSuffix(stmt.block, result);
|
|
63417
63811
|
if (stmt.handlers) {
|
|
63418
63812
|
for (i = 0, iz = stmt.handlers.length;i < iz; ++i) {
|
|
63419
|
-
result =
|
|
63813
|
+
result = join32(result, this.generateStatement(stmt.handlers[i], S_TFFF));
|
|
63420
63814
|
if (stmt.finalizer || i + 1 !== iz) {
|
|
63421
63815
|
result = this.maybeBlockSuffix(stmt.handlers[i].body, result);
|
|
63422
63816
|
}
|
|
@@ -63424,7 +63818,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63424
63818
|
} else {
|
|
63425
63819
|
guardedHandlers = stmt.guardedHandlers || [];
|
|
63426
63820
|
for (i = 0, iz = guardedHandlers.length;i < iz; ++i) {
|
|
63427
|
-
result =
|
|
63821
|
+
result = join32(result, this.generateStatement(guardedHandlers[i], S_TFFF));
|
|
63428
63822
|
if (stmt.finalizer || i + 1 !== iz) {
|
|
63429
63823
|
result = this.maybeBlockSuffix(guardedHandlers[i].body, result);
|
|
63430
63824
|
}
|
|
@@ -63432,13 +63826,13 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63432
63826
|
if (stmt.handler) {
|
|
63433
63827
|
if (Array.isArray(stmt.handler)) {
|
|
63434
63828
|
for (i = 0, iz = stmt.handler.length;i < iz; ++i) {
|
|
63435
|
-
result =
|
|
63829
|
+
result = join32(result, this.generateStatement(stmt.handler[i], S_TFFF));
|
|
63436
63830
|
if (stmt.finalizer || i + 1 !== iz) {
|
|
63437
63831
|
result = this.maybeBlockSuffix(stmt.handler[i].body, result);
|
|
63438
63832
|
}
|
|
63439
63833
|
}
|
|
63440
63834
|
} else {
|
|
63441
|
-
result =
|
|
63835
|
+
result = join32(result, this.generateStatement(stmt.handler, S_TFFF));
|
|
63442
63836
|
if (stmt.finalizer) {
|
|
63443
63837
|
result = this.maybeBlockSuffix(stmt.handler.body, result);
|
|
63444
63838
|
}
|
|
@@ -63446,7 +63840,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63446
63840
|
}
|
|
63447
63841
|
}
|
|
63448
63842
|
if (stmt.finalizer) {
|
|
63449
|
-
result =
|
|
63843
|
+
result = join32(result, ["finally", this.maybeBlock(stmt.finalizer, S_TFFF)]);
|
|
63450
63844
|
}
|
|
63451
63845
|
return result;
|
|
63452
63846
|
},
|
|
@@ -63480,7 +63874,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63480
63874
|
withIndent(function() {
|
|
63481
63875
|
if (stmt.test) {
|
|
63482
63876
|
result = [
|
|
63483
|
-
|
|
63877
|
+
join32("case", that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)),
|
|
63484
63878
|
":"
|
|
63485
63879
|
];
|
|
63486
63880
|
} else {
|
|
@@ -63528,9 +63922,9 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63528
63922
|
result.push(this.maybeBlock(stmt.consequent, S_TFFF));
|
|
63529
63923
|
result = this.maybeBlockSuffix(stmt.consequent, result);
|
|
63530
63924
|
if (stmt.alternate.type === Syntax.IfStatement) {
|
|
63531
|
-
result =
|
|
63925
|
+
result = join32(result, ["else ", this.generateStatement(stmt.alternate, bodyFlags)]);
|
|
63532
63926
|
} else {
|
|
63533
|
-
result =
|
|
63927
|
+
result = join32(result, join32("else", this.maybeBlock(stmt.alternate, bodyFlags)));
|
|
63534
63928
|
}
|
|
63535
63929
|
} else {
|
|
63536
63930
|
result.push(this.maybeBlock(stmt.consequent, bodyFlags));
|
|
@@ -63632,7 +64026,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63632
64026
|
},
|
|
63633
64027
|
ReturnStatement: function(stmt, flags) {
|
|
63634
64028
|
if (stmt.argument) {
|
|
63635
|
-
return [
|
|
64029
|
+
return [join32("return", this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)), this.semicolon(flags)];
|
|
63636
64030
|
}
|
|
63637
64031
|
return ["return" + this.semicolon(flags)];
|
|
63638
64032
|
},
|
|
@@ -63714,14 +64108,14 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63714
64108
|
if (leftSource.charCodeAt(leftSource.length - 1) === 47 && esutils.code.isIdentifierPartES5(expr.operator.charCodeAt(0))) {
|
|
63715
64109
|
result = [fragment, noEmptySpace(), expr.operator];
|
|
63716
64110
|
} else {
|
|
63717
|
-
result =
|
|
64111
|
+
result = join32(fragment, expr.operator);
|
|
63718
64112
|
}
|
|
63719
64113
|
fragment = this.generateExpression(expr.right, rightPrecedence, flags);
|
|
63720
64114
|
if (expr.operator === "/" && fragment.toString().charAt(0) === "/" || expr.operator.slice(-1) === "<" && fragment.toString().slice(0, 3) === "!--") {
|
|
63721
64115
|
result.push(noEmptySpace());
|
|
63722
64116
|
result.push(fragment);
|
|
63723
64117
|
} else {
|
|
63724
|
-
result =
|
|
64118
|
+
result = join32(result, fragment);
|
|
63725
64119
|
}
|
|
63726
64120
|
if (expr.operator === "in" && !(flags & F_ALLOW_IN)) {
|
|
63727
64121
|
return ["(", result, ")"];
|
|
@@ -63761,7 +64155,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63761
64155
|
var result, length, i, iz, itemFlags;
|
|
63762
64156
|
length = expr["arguments"].length;
|
|
63763
64157
|
itemFlags = flags & F_ALLOW_UNPARATH_NEW && !parentheses && length === 0 ? E_TFT : E_TFF;
|
|
63764
|
-
result =
|
|
64158
|
+
result = join32("new", this.generateExpression(expr.callee, Precedence.New, itemFlags));
|
|
63765
64159
|
if (!(flags & F_ALLOW_UNPARATH_NEW) || parentheses || length > 0) {
|
|
63766
64160
|
result.push("(");
|
|
63767
64161
|
for (i = 0, iz = length;i < iz; ++i) {
|
|
@@ -63808,11 +64202,11 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63808
64202
|
var result, fragment, rightCharCode, leftSource, leftCharCode;
|
|
63809
64203
|
fragment = this.generateExpression(expr.argument, Precedence.Unary, E_TTT);
|
|
63810
64204
|
if (space === "") {
|
|
63811
|
-
result =
|
|
64205
|
+
result = join32(expr.operator, fragment);
|
|
63812
64206
|
} else {
|
|
63813
64207
|
result = [expr.operator];
|
|
63814
64208
|
if (expr.operator.length > 2) {
|
|
63815
|
-
result =
|
|
64209
|
+
result = join32(result, fragment);
|
|
63816
64210
|
} else {
|
|
63817
64211
|
leftSource = toSourceNodeWhenNeeded(result).toString();
|
|
63818
64212
|
leftCharCode = leftSource.charCodeAt(leftSource.length - 1);
|
|
@@ -63835,12 +64229,12 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63835
64229
|
result = "yield";
|
|
63836
64230
|
}
|
|
63837
64231
|
if (expr.argument) {
|
|
63838
|
-
result =
|
|
64232
|
+
result = join32(result, this.generateExpression(expr.argument, Precedence.Yield, E_TTT));
|
|
63839
64233
|
}
|
|
63840
64234
|
return parenthesize(result, Precedence.Yield, precedence);
|
|
63841
64235
|
},
|
|
63842
64236
|
AwaitExpression: function(expr, precedence, flags) {
|
|
63843
|
-
var result =
|
|
64237
|
+
var result = join32(expr.all ? "await*" : "await", this.generateExpression(expr.argument, Precedence.Await, E_TTT));
|
|
63844
64238
|
return parenthesize(result, Precedence.Await, precedence);
|
|
63845
64239
|
},
|
|
63846
64240
|
UpdateExpression: function(expr, precedence, flags) {
|
|
@@ -63912,11 +64306,11 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63912
64306
|
var result, fragment;
|
|
63913
64307
|
result = ["class"];
|
|
63914
64308
|
if (expr.id) {
|
|
63915
|
-
result =
|
|
64309
|
+
result = join32(result, this.generateExpression(expr.id, Precedence.Sequence, E_TTT));
|
|
63916
64310
|
}
|
|
63917
64311
|
if (expr.superClass) {
|
|
63918
|
-
fragment =
|
|
63919
|
-
result =
|
|
64312
|
+
fragment = join32("extends", this.generateExpression(expr.superClass, Precedence.Unary, E_TTT));
|
|
64313
|
+
result = join32(result, fragment);
|
|
63920
64314
|
}
|
|
63921
64315
|
result.push(space);
|
|
63922
64316
|
result.push(this.generateStatement(expr.body, S_TFFT));
|
|
@@ -63931,7 +64325,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63931
64325
|
}
|
|
63932
64326
|
if (expr.kind === "get" || expr.kind === "set") {
|
|
63933
64327
|
fragment = [
|
|
63934
|
-
|
|
64328
|
+
join32(expr.kind, this.generatePropertyKey(expr.key, expr.computed)),
|
|
63935
64329
|
this.generateFunctionBody(expr.value)
|
|
63936
64330
|
];
|
|
63937
64331
|
} else {
|
|
@@ -63941,7 +64335,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
63941
64335
|
this.generateFunctionBody(expr.value)
|
|
63942
64336
|
];
|
|
63943
64337
|
}
|
|
63944
|
-
return
|
|
64338
|
+
return join32(result, fragment);
|
|
63945
64339
|
},
|
|
63946
64340
|
Property: function(expr, precedence, flags) {
|
|
63947
64341
|
if (expr.kind === "get" || expr.kind === "set") {
|
|
@@ -64135,7 +64529,7 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
64135
64529
|
for (i = 0, iz = expr.blocks.length;i < iz; ++i) {
|
|
64136
64530
|
fragment = that.generateExpression(expr.blocks[i], Precedence.Sequence, E_TTT);
|
|
64137
64531
|
if (i > 0 || extra.moz.comprehensionExpressionStartsWithAssignment) {
|
|
64138
|
-
result =
|
|
64532
|
+
result = join32(result, fragment);
|
|
64139
64533
|
} else {
|
|
64140
64534
|
result.push(fragment);
|
|
64141
64535
|
}
|
|
@@ -64143,13 +64537,13 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
64143
64537
|
});
|
|
64144
64538
|
}
|
|
64145
64539
|
if (expr.filter) {
|
|
64146
|
-
result =
|
|
64540
|
+
result = join32(result, "if" + space);
|
|
64147
64541
|
fragment = this.generateExpression(expr.filter, Precedence.Sequence, E_TTT);
|
|
64148
|
-
result =
|
|
64542
|
+
result = join32(result, ["(", fragment, ")"]);
|
|
64149
64543
|
}
|
|
64150
64544
|
if (!extra.moz.comprehensionExpressionStartsWithAssignment) {
|
|
64151
64545
|
fragment = this.generateExpression(expr.body, Precedence.Assignment, E_TTT);
|
|
64152
|
-
result =
|
|
64546
|
+
result = join32(result, fragment);
|
|
64153
64547
|
}
|
|
64154
64548
|
result.push(expr.type === Syntax.GeneratorExpression ? ")" : "]");
|
|
64155
64549
|
return result;
|
|
@@ -64165,8 +64559,8 @@ var require_escodegen = __commonJS((exports) => {
|
|
|
64165
64559
|
} else {
|
|
64166
64560
|
fragment = this.generateExpression(expr.left, Precedence.Call, E_TTT);
|
|
64167
64561
|
}
|
|
64168
|
-
fragment =
|
|
64169
|
-
fragment =
|
|
64562
|
+
fragment = join32(fragment, expr.of ? "of" : "in");
|
|
64563
|
+
fragment = join32(fragment, this.generateExpression(expr.right, Precedence.Sequence, E_TTT));
|
|
64170
64564
|
return ["for" + space + "(", fragment, ")"];
|
|
64171
64565
|
},
|
|
64172
64566
|
SpreadElement: function(expr, precedence, flags) {
|
|
@@ -70654,11 +71048,11 @@ var require_tslib = __commonJS((exports, module) => {
|
|
|
70654
71048
|
};
|
|
70655
71049
|
__awaiter2 = function(thisArg, _arguments, P, generator) {
|
|
70656
71050
|
function adopt(value) {
|
|
70657
|
-
return value instanceof P ? value : new P(function(
|
|
70658
|
-
|
|
71051
|
+
return value instanceof P ? value : new P(function(resolve9) {
|
|
71052
|
+
resolve9(value);
|
|
70659
71053
|
});
|
|
70660
71054
|
}
|
|
70661
|
-
return new (P || (P = Promise))(function(
|
|
71055
|
+
return new (P || (P = Promise))(function(resolve9, reject) {
|
|
70662
71056
|
function fulfilled(value) {
|
|
70663
71057
|
try {
|
|
70664
71058
|
step(generator.next(value));
|
|
@@ -70674,7 +71068,7 @@ var require_tslib = __commonJS((exports, module) => {
|
|
|
70674
71068
|
}
|
|
70675
71069
|
}
|
|
70676
71070
|
function step(result) {
|
|
70677
|
-
result.done ?
|
|
71071
|
+
result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
70678
71072
|
}
|
|
70679
71073
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
70680
71074
|
});
|
|
@@ -70903,14 +71297,14 @@ var require_tslib = __commonJS((exports, module) => {
|
|
|
70903
71297
|
}, i);
|
|
70904
71298
|
function verb(n) {
|
|
70905
71299
|
i[n] = o[n] && function(v) {
|
|
70906
|
-
return new Promise(function(
|
|
70907
|
-
v = o[n](v), settle(
|
|
71300
|
+
return new Promise(function(resolve9, reject) {
|
|
71301
|
+
v = o[n](v), settle(resolve9, reject, v.done, v.value);
|
|
70908
71302
|
});
|
|
70909
71303
|
};
|
|
70910
71304
|
}
|
|
70911
|
-
function settle(
|
|
71305
|
+
function settle(resolve9, reject, d, v) {
|
|
70912
71306
|
Promise.resolve(v).then(function(v2) {
|
|
70913
|
-
|
|
71307
|
+
resolve9({ value: v2, done: d });
|
|
70914
71308
|
}, reject);
|
|
70915
71309
|
}
|
|
70916
71310
|
};
|
|
@@ -74149,12 +74543,12 @@ var require_util3 = __commonJS((exports) => {
|
|
|
74149
74543
|
exports.isGMT = exports.dnsLookup = undefined;
|
|
74150
74544
|
var dns_1 = __require("dns");
|
|
74151
74545
|
function dnsLookup(host, opts) {
|
|
74152
|
-
return new Promise((
|
|
74546
|
+
return new Promise((resolve9, reject) => {
|
|
74153
74547
|
(0, dns_1.lookup)(host, opts, (err, res) => {
|
|
74154
74548
|
if (err) {
|
|
74155
74549
|
reject(err);
|
|
74156
74550
|
} else {
|
|
74157
|
-
|
|
74551
|
+
resolve9(res);
|
|
74158
74552
|
}
|
|
74159
74553
|
});
|
|
74160
74554
|
});
|
|
@@ -74728,10 +75122,10 @@ var require_myIpAddress = __commonJS((exports) => {
|
|
|
74728
75122
|
var ip_1 = require_ip();
|
|
74729
75123
|
var net_1 = __importDefault(__require("net"));
|
|
74730
75124
|
async function myIpAddress() {
|
|
74731
|
-
return new Promise((
|
|
75125
|
+
return new Promise((resolve9, reject) => {
|
|
74732
75126
|
const socket = net_1.default.connect({ host: "8.8.8.8", port: 53 });
|
|
74733
75127
|
const onError = () => {
|
|
74734
|
-
|
|
75128
|
+
resolve9(ip_1.ip.address());
|
|
74735
75129
|
};
|
|
74736
75130
|
socket.once("error", onError);
|
|
74737
75131
|
socket.once("connect", () => {
|
|
@@ -74739,9 +75133,9 @@ var require_myIpAddress = __commonJS((exports) => {
|
|
|
74739
75133
|
const addr = socket.address();
|
|
74740
75134
|
socket.destroy();
|
|
74741
75135
|
if (typeof addr === "string") {
|
|
74742
|
-
|
|
75136
|
+
resolve9(addr);
|
|
74743
75137
|
} else if (addr.address) {
|
|
74744
|
-
|
|
75138
|
+
resolve9(addr.address);
|
|
74745
75139
|
} else {
|
|
74746
75140
|
reject(new Error("Expected a `string`"));
|
|
74747
75141
|
}
|
|
@@ -75255,8 +75649,8 @@ var require_deferred_promise = __commonJS((exports) => {
|
|
|
75255
75649
|
this.context = args.context;
|
|
75256
75650
|
this.owner = args.context.runtime;
|
|
75257
75651
|
this.handle = args.promiseHandle;
|
|
75258
|
-
this.settled = new Promise((
|
|
75259
|
-
this.onSettled =
|
|
75652
|
+
this.settled = new Promise((resolve9) => {
|
|
75653
|
+
this.onSettled = resolve9;
|
|
75260
75654
|
});
|
|
75261
75655
|
this.resolveHandle = args.resolveHandle;
|
|
75262
75656
|
this.rejectHandle = args.rejectHandle;
|
|
@@ -75648,13 +76042,13 @@ var require_context = __commonJS((exports) => {
|
|
|
75648
76042
|
if (vmResolveResult.error) {
|
|
75649
76043
|
return Promise.resolve(vmResolveResult);
|
|
75650
76044
|
}
|
|
75651
|
-
return new Promise((
|
|
76045
|
+
return new Promise((resolve9) => {
|
|
75652
76046
|
lifetime_1.Scope.withScope((scope) => {
|
|
75653
76047
|
const resolveHandle = scope.manage(this.newFunction("resolve", (value) => {
|
|
75654
|
-
|
|
76048
|
+
resolve9({ value: value && value.dup() });
|
|
75655
76049
|
}));
|
|
75656
76050
|
const rejectHandle = scope.manage(this.newFunction("reject", (error) => {
|
|
75657
|
-
|
|
76051
|
+
resolve9({ error: error && error.dup() });
|
|
75658
76052
|
}));
|
|
75659
76053
|
const promiseHandle = scope.manage(vmResolveResult.value);
|
|
75660
76054
|
const promiseThenHandle = scope.manage(this.getProp(promiseHandle, "then"));
|
|
@@ -77486,7 +77880,7 @@ var require_dist10 = __commonJS((exports) => {
|
|
|
77486
77880
|
exports.PacProxyAgent = undefined;
|
|
77487
77881
|
var net = __importStar(__require("net"));
|
|
77488
77882
|
var tls = __importStar(__require("tls"));
|
|
77489
|
-
var
|
|
77883
|
+
var crypto2 = __importStar(__require("crypto"));
|
|
77490
77884
|
var events_1 = __require("events");
|
|
77491
77885
|
var debug_1 = __importDefault(require_src());
|
|
77492
77886
|
var url_1 = __require("url");
|
|
@@ -77536,7 +77930,7 @@ var require_dist10 = __commonJS((exports) => {
|
|
|
77536
77930
|
(0, quickjs_emscripten_1.getQuickJS)(),
|
|
77537
77931
|
this.loadPacFile()
|
|
77538
77932
|
]);
|
|
77539
|
-
const hash =
|
|
77933
|
+
const hash = crypto2.createHash("sha1").update(code).digest("hex");
|
|
77540
77934
|
if (this.resolver && this.resolverHash === hash) {
|
|
77541
77935
|
debug2("Same sha1 hash for code - contents have not changed, reusing previous proxy resolver");
|
|
77542
77936
|
return this.resolver;
|
|
@@ -77768,13 +78162,13 @@ import * as http from "node:http";
|
|
|
77768
78162
|
import * as https from "node:https";
|
|
77769
78163
|
import { URL as URL2, urlToHttpOptions } from "node:url";
|
|
77770
78164
|
function headHttpRequest(url) {
|
|
77771
|
-
return new Promise((
|
|
78165
|
+
return new Promise((resolve9) => {
|
|
77772
78166
|
const request3 = httpRequest(url, "HEAD", (response) => {
|
|
77773
78167
|
response.resume();
|
|
77774
|
-
|
|
78168
|
+
resolve9(response.statusCode === 200);
|
|
77775
78169
|
}, false);
|
|
77776
78170
|
request3.on("error", () => {
|
|
77777
|
-
|
|
78171
|
+
resolve9(false);
|
|
77778
78172
|
});
|
|
77779
78173
|
});
|
|
77780
78174
|
}
|
|
@@ -77802,7 +78196,7 @@ function httpRequest(url, method, response, keepAlive = true) {
|
|
|
77802
78196
|
return request3;
|
|
77803
78197
|
}
|
|
77804
78198
|
function downloadFile(url, destinationPath, progressCallback) {
|
|
77805
|
-
return new Promise((
|
|
78199
|
+
return new Promise((resolve9, reject) => {
|
|
77806
78200
|
let downloadedBytes = 0;
|
|
77807
78201
|
let totalBytes = 0;
|
|
77808
78202
|
function onData(chunk) {
|
|
@@ -77818,7 +78212,7 @@ function downloadFile(url, destinationPath, progressCallback) {
|
|
|
77818
78212
|
}
|
|
77819
78213
|
const file = createWriteStream(destinationPath);
|
|
77820
78214
|
file.on("close", () => {
|
|
77821
|
-
return
|
|
78215
|
+
return resolve9();
|
|
77822
78216
|
});
|
|
77823
78217
|
file.on("error", (error) => {
|
|
77824
78218
|
return reject(error);
|
|
@@ -77843,7 +78237,7 @@ async function getJSON(url) {
|
|
|
77843
78237
|
}
|
|
77844
78238
|
}
|
|
77845
78239
|
function getText(url) {
|
|
77846
|
-
return new Promise((
|
|
78240
|
+
return new Promise((resolve9, reject) => {
|
|
77847
78241
|
const request3 = httpRequest(url, "GET", (response) => {
|
|
77848
78242
|
let data = "";
|
|
77849
78243
|
if (response.statusCode && response.statusCode >= 400) {
|
|
@@ -77854,7 +78248,7 @@ function getText(url) {
|
|
|
77854
78248
|
});
|
|
77855
78249
|
response.on("end", () => {
|
|
77856
78250
|
try {
|
|
77857
|
-
return
|
|
78251
|
+
return resolve9(String(data));
|
|
77858
78252
|
} catch {
|
|
77859
78253
|
return reject(new Error(`Failed to read text response from ${url}`));
|
|
77860
78254
|
}
|
|
@@ -77871,7 +78265,7 @@ var init_httpUtil = __esm(() => {
|
|
|
77871
78265
|
});
|
|
77872
78266
|
|
|
77873
78267
|
// node_modules/@puppeteer/browsers/lib/esm/browser-data/chrome.js
|
|
77874
|
-
import { execSync as
|
|
78268
|
+
import { execSync as execSync8 } from "node:child_process";
|
|
77875
78269
|
import os from "node:os";
|
|
77876
78270
|
import path from "node:path";
|
|
77877
78271
|
function folder(platform2) {
|
|
@@ -77961,7 +78355,7 @@ function getChromeWindowsLocation(channel2, locationsPrefixes) {
|
|
|
77961
78355
|
}
|
|
77962
78356
|
function getWslVariable(variable) {
|
|
77963
78357
|
try {
|
|
77964
|
-
const result =
|
|
78358
|
+
const result = execSync8(`cmd.exe /c echo %${variable.toLocaleUpperCase()}%`, {
|
|
77965
78359
|
stdio: ["ignore", "pipe", "ignore"],
|
|
77966
78360
|
encoding: "utf-8"
|
|
77967
78361
|
}).trim();
|
|
@@ -77972,7 +78366,7 @@ function getWslVariable(variable) {
|
|
|
77972
78366
|
return;
|
|
77973
78367
|
}
|
|
77974
78368
|
function getWslLocation(channel2) {
|
|
77975
|
-
const wslVersion =
|
|
78369
|
+
const wslVersion = execSync8("wslinfo --version", {
|
|
77976
78370
|
stdio: ["ignore", "pipe", "ignore"],
|
|
77977
78371
|
encoding: "utf-8"
|
|
77978
78372
|
}).trim();
|
|
@@ -77988,7 +78382,7 @@ function getWslLocation(channel2) {
|
|
|
77988
78382
|
}
|
|
77989
78383
|
const windowsPath = getChromeWindowsLocation(channel2, wslPrefixes);
|
|
77990
78384
|
return windowsPath.map((path2) => {
|
|
77991
|
-
return
|
|
78385
|
+
return execSync8(`wslpath "${path2}"`).toString().trim();
|
|
77992
78386
|
});
|
|
77993
78387
|
}
|
|
77994
78388
|
function getChromeLinuxOrWslLocation(channel2) {
|
|
@@ -79075,7 +79469,7 @@ class Process {
|
|
|
79075
79469
|
if (opts.onExit) {
|
|
79076
79470
|
this.#onExitHook = opts.onExit;
|
|
79077
79471
|
}
|
|
79078
|
-
this.#browserProcessExiting = new Promise((
|
|
79472
|
+
this.#browserProcessExiting = new Promise((resolve9, reject) => {
|
|
79079
79473
|
this.#browserProcess.once("exit", async () => {
|
|
79080
79474
|
debugLaunch(`Browser process ${this.#browserProcess.pid} onExit`);
|
|
79081
79475
|
this.#clearListeners();
|
|
@@ -79086,7 +79480,7 @@ class Process {
|
|
|
79086
79480
|
reject(err);
|
|
79087
79481
|
return;
|
|
79088
79482
|
}
|
|
79089
|
-
|
|
79483
|
+
resolve9();
|
|
79090
79484
|
});
|
|
79091
79485
|
});
|
|
79092
79486
|
}
|
|
@@ -79196,7 +79590,7 @@ Error cause: ${isErrorLike2(error) ? error.stack : error}`);
|
|
|
79196
79590
|
return [...this.#logs];
|
|
79197
79591
|
}
|
|
79198
79592
|
waitForLineOutput(regex, timeout2 = 0) {
|
|
79199
|
-
return new Promise((
|
|
79593
|
+
return new Promise((resolve9, reject) => {
|
|
79200
79594
|
const onClose = (errorOrCode) => {
|
|
79201
79595
|
cleanup();
|
|
79202
79596
|
reject(new Error([
|
|
@@ -79234,7 +79628,7 @@ Error cause: ${isErrorLike2(error) ? error.stack : error}`);
|
|
|
79234
79628
|
return;
|
|
79235
79629
|
}
|
|
79236
79630
|
cleanup();
|
|
79237
|
-
|
|
79631
|
+
resolve9(match[1]);
|
|
79238
79632
|
}
|
|
79239
79633
|
});
|
|
79240
79634
|
}
|
|
@@ -79764,7 +80158,7 @@ var require_get_stream = __commonJS((exports, module) => {
|
|
|
79764
80158
|
};
|
|
79765
80159
|
const { maxBuffer } = options;
|
|
79766
80160
|
let stream;
|
|
79767
|
-
await new Promise((
|
|
80161
|
+
await new Promise((resolve9, reject) => {
|
|
79768
80162
|
const rejectPromise = (error) => {
|
|
79769
80163
|
if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
|
|
79770
80164
|
error.bufferedData = stream.getBufferedValue();
|
|
@@ -79776,7 +80170,7 @@ var require_get_stream = __commonJS((exports, module) => {
|
|
|
79776
80170
|
rejectPromise(error);
|
|
79777
80171
|
return;
|
|
79778
80172
|
}
|
|
79779
|
-
|
|
80173
|
+
resolve9();
|
|
79780
80174
|
});
|
|
79781
80175
|
stream.on("data", () => {
|
|
79782
80176
|
if (stream.getBufferedLength() > maxBuffer) {
|
|
@@ -81137,7 +81531,7 @@ var require_extract_zip = __commonJS((exports, module) => {
|
|
|
81137
81531
|
debug4("opening", this.zipPath, "with opts", this.opts);
|
|
81138
81532
|
this.zipfile = await openZip(this.zipPath, { lazyEntries: true });
|
|
81139
81533
|
this.canceled = false;
|
|
81140
|
-
return new Promise((
|
|
81534
|
+
return new Promise((resolve9, reject) => {
|
|
81141
81535
|
this.zipfile.on("error", (err) => {
|
|
81142
81536
|
this.canceled = true;
|
|
81143
81537
|
reject(err);
|
|
@@ -81146,7 +81540,7 @@ var require_extract_zip = __commonJS((exports, module) => {
|
|
|
81146
81540
|
this.zipfile.on("close", () => {
|
|
81147
81541
|
if (!this.canceled) {
|
|
81148
81542
|
debug4("zip extraction complete");
|
|
81149
|
-
|
|
81543
|
+
resolve9();
|
|
81150
81544
|
}
|
|
81151
81545
|
});
|
|
81152
81546
|
this.zipfile.on("entry", async (entry) => {
|
|
@@ -82488,8 +82882,8 @@ var require_streamx = __commonJS((exports, module) => {
|
|
|
82488
82882
|
return this;
|
|
82489
82883
|
},
|
|
82490
82884
|
next() {
|
|
82491
|
-
return new Promise(function(
|
|
82492
|
-
promiseResolve =
|
|
82885
|
+
return new Promise(function(resolve9, reject) {
|
|
82886
|
+
promiseResolve = resolve9;
|
|
82493
82887
|
promiseReject = reject;
|
|
82494
82888
|
const data = stream.read();
|
|
82495
82889
|
if (data !== null)
|
|
@@ -82526,14 +82920,14 @@ var require_streamx = __commonJS((exports, module) => {
|
|
|
82526
82920
|
}
|
|
82527
82921
|
function destroy(err) {
|
|
82528
82922
|
stream.destroy(err);
|
|
82529
|
-
return new Promise((
|
|
82923
|
+
return new Promise((resolve9, reject) => {
|
|
82530
82924
|
if (stream._duplexState & DESTROYED)
|
|
82531
|
-
return
|
|
82925
|
+
return resolve9({ value: undefined, done: true });
|
|
82532
82926
|
stream.once("close", function() {
|
|
82533
82927
|
if (err)
|
|
82534
82928
|
reject(err);
|
|
82535
82929
|
else
|
|
82536
|
-
|
|
82930
|
+
resolve9({ value: undefined, done: true });
|
|
82537
82931
|
});
|
|
82538
82932
|
});
|
|
82539
82933
|
}
|
|
@@ -82585,8 +82979,8 @@ var require_streamx = __commonJS((exports, module) => {
|
|
|
82585
82979
|
return Promise.resolve(true);
|
|
82586
82980
|
if (state.drains === null)
|
|
82587
82981
|
state.drains = [];
|
|
82588
|
-
return new Promise((
|
|
82589
|
-
state.drains.push({ writes, resolve:
|
|
82982
|
+
return new Promise((resolve9) => {
|
|
82983
|
+
state.drains.push({ writes, resolve: resolve9 });
|
|
82590
82984
|
});
|
|
82591
82985
|
}
|
|
82592
82986
|
write(data) {
|
|
@@ -82700,11 +83094,11 @@ var require_streamx = __commonJS((exports, module) => {
|
|
|
82700
83094
|
cb(null);
|
|
82701
83095
|
}
|
|
82702
83096
|
function pipelinePromise(...streams) {
|
|
82703
|
-
return new Promise((
|
|
83097
|
+
return new Promise((resolve9, reject) => {
|
|
82704
83098
|
return pipeline(...streams, (err) => {
|
|
82705
83099
|
if (err)
|
|
82706
83100
|
return reject(err);
|
|
82707
|
-
|
|
83101
|
+
resolve9();
|
|
82708
83102
|
});
|
|
82709
83103
|
});
|
|
82710
83104
|
}
|
|
@@ -83418,16 +83812,16 @@ var require_extract = __commonJS((exports, module) => {
|
|
|
83418
83812
|
entryCallback = null;
|
|
83419
83813
|
cb(err);
|
|
83420
83814
|
}
|
|
83421
|
-
function onnext(
|
|
83815
|
+
function onnext(resolve9, reject) {
|
|
83422
83816
|
if (error) {
|
|
83423
83817
|
return reject(error);
|
|
83424
83818
|
}
|
|
83425
83819
|
if (entryStream) {
|
|
83426
|
-
|
|
83820
|
+
resolve9({ value: entryStream, done: false });
|
|
83427
83821
|
entryStream = null;
|
|
83428
83822
|
return;
|
|
83429
83823
|
}
|
|
83430
|
-
promiseResolve =
|
|
83824
|
+
promiseResolve = resolve9;
|
|
83431
83825
|
promiseReject = reject;
|
|
83432
83826
|
consumeCallback(null);
|
|
83433
83827
|
if (extract._finished && promiseResolve) {
|
|
@@ -83458,14 +83852,14 @@ var require_extract = __commonJS((exports, module) => {
|
|
|
83458
83852
|
function destroy(err) {
|
|
83459
83853
|
extract.destroy(err);
|
|
83460
83854
|
consumeCallback(err);
|
|
83461
|
-
return new Promise((
|
|
83855
|
+
return new Promise((resolve9, reject) => {
|
|
83462
83856
|
if (extract.destroyed)
|
|
83463
|
-
return
|
|
83857
|
+
return resolve9({ value: undefined, done: true });
|
|
83464
83858
|
extract.once("close", function() {
|
|
83465
83859
|
if (err)
|
|
83466
83860
|
reject(err);
|
|
83467
83861
|
else
|
|
83468
|
-
|
|
83862
|
+
resolve9({ value: undefined, done: true });
|
|
83469
83863
|
});
|
|
83470
83864
|
});
|
|
83471
83865
|
}
|
|
@@ -84263,7 +84657,7 @@ var init_fileUtil = __esm(() => {
|
|
|
84263
84657
|
// node_modules/@puppeteer/browsers/lib/esm/install.js
|
|
84264
84658
|
import assert2 from "node:assert";
|
|
84265
84659
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
84266
|
-
import { existsSync as
|
|
84660
|
+
import { existsSync as existsSync36, readFileSync as readFileSync27 } from "node:fs";
|
|
84267
84661
|
import { mkdir as mkdir2, unlink } from "node:fs/promises";
|
|
84268
84662
|
import os5 from "node:os";
|
|
84269
84663
|
import path8 from "node:path";
|
|
@@ -84316,7 +84710,7 @@ async function installWithProviders(options) {
|
|
|
84316
84710
|
continue;
|
|
84317
84711
|
}
|
|
84318
84712
|
debugInstall(`Successfully got URL from ${provider.getName()}: ${url}`);
|
|
84319
|
-
if (!
|
|
84713
|
+
if (!existsSync36(browserRoot)) {
|
|
84320
84714
|
await mkdir2(browserRoot, { recursive: true });
|
|
84321
84715
|
}
|
|
84322
84716
|
return await installUrl(url, options, provider);
|
|
@@ -84349,7 +84743,7 @@ async function installDeps(installedBrowser) {
|
|
|
84349
84743
|
return;
|
|
84350
84744
|
}
|
|
84351
84745
|
const depsPath = path8.join(path8.dirname(installedBrowser.executablePath), "deb.deps");
|
|
84352
|
-
if (!
|
|
84746
|
+
if (!existsSync36(depsPath)) {
|
|
84353
84747
|
debugInstall(`deb.deps file was not found at ${depsPath}`);
|
|
84354
84748
|
return;
|
|
84355
84749
|
}
|
|
@@ -84391,11 +84785,11 @@ async function installUrl(url, options, provider) {
|
|
|
84391
84785
|
const cache = new Cache(options.cacheDir);
|
|
84392
84786
|
const browserRoot = cache.browserRoot(options.browser);
|
|
84393
84787
|
const archivePath = path8.join(browserRoot, `${options.buildId}-${fileName}`);
|
|
84394
|
-
if (!
|
|
84788
|
+
if (!existsSync36(browserRoot)) {
|
|
84395
84789
|
await mkdir2(browserRoot, { recursive: true });
|
|
84396
84790
|
}
|
|
84397
84791
|
if (!options.unpack) {
|
|
84398
|
-
if (
|
|
84792
|
+
if (existsSync36(archivePath)) {
|
|
84399
84793
|
return archivePath;
|
|
84400
84794
|
}
|
|
84401
84795
|
debugInstall(`Downloading binary from ${url}`);
|
|
@@ -84416,8 +84810,8 @@ async function installUrl(url, options, provider) {
|
|
|
84416
84810
|
cache.writeExecutablePath(options.browser, options.platform, options.buildId, relativeExecutablePath6);
|
|
84417
84811
|
}
|
|
84418
84812
|
try {
|
|
84419
|
-
if (
|
|
84420
|
-
if (!
|
|
84813
|
+
if (existsSync36(outputPath)) {
|
|
84814
|
+
if (!existsSync36(installedBrowser.executablePath)) {
|
|
84421
84815
|
throw new Error(`The browser folder (${outputPath}) exists but the executable (${installedBrowser.executablePath}) is missing`);
|
|
84422
84816
|
}
|
|
84423
84817
|
await runSetup(installedBrowser);
|
|
@@ -84426,7 +84820,7 @@ async function installUrl(url, options, provider) {
|
|
|
84426
84820
|
}
|
|
84427
84821
|
return installedBrowser;
|
|
84428
84822
|
}
|
|
84429
|
-
if (!
|
|
84823
|
+
if (!existsSync36(archivePath)) {
|
|
84430
84824
|
debugInstall(`Downloading binary from ${url}`);
|
|
84431
84825
|
try {
|
|
84432
84826
|
debugTime("download");
|
|
@@ -84455,7 +84849,7 @@ async function installUrl(url, options, provider) {
|
|
|
84455
84849
|
}
|
|
84456
84850
|
return installedBrowser;
|
|
84457
84851
|
} finally {
|
|
84458
|
-
if (
|
|
84852
|
+
if (existsSync36(archivePath)) {
|
|
84459
84853
|
await unlink(archivePath);
|
|
84460
84854
|
}
|
|
84461
84855
|
}
|
|
@@ -84466,7 +84860,7 @@ async function runSetup(installedBrowser) {
|
|
|
84466
84860
|
debugTime("permissions");
|
|
84467
84861
|
const browserDir = path8.dirname(installedBrowser.executablePath);
|
|
84468
84862
|
const setupExePath = path8.join(browserDir, "setup.exe");
|
|
84469
|
-
if (!
|
|
84863
|
+
if (!existsSync36(setupExePath)) {
|
|
84470
84864
|
return;
|
|
84471
84865
|
}
|
|
84472
84866
|
spawnSync4(path8.join(browserDir, "setup.exe"), [`--configure-browser-in-directory=` + browserDir], {
|
|
@@ -84807,12 +85201,12 @@ var init_lib = __esm(() => {
|
|
|
84807
85201
|
});
|
|
84808
85202
|
|
|
84809
85203
|
// node_modules/cliui/build/lib/string-utils.js
|
|
84810
|
-
function
|
|
85204
|
+
function stripAnsi2(str) {
|
|
84811
85205
|
return str.replace(ansi, "");
|
|
84812
85206
|
}
|
|
84813
85207
|
function wrap(str, width) {
|
|
84814
85208
|
const [start, end] = str.match(ansi) || ["", ""];
|
|
84815
|
-
str =
|
|
85209
|
+
str = stripAnsi2(str);
|
|
84816
85210
|
let wrapped = "";
|
|
84817
85211
|
for (let i = 0;i < str.length; i++) {
|
|
84818
85212
|
if (i !== 0 && i % width === 0) {
|
|
@@ -84837,7 +85231,7 @@ function ui(opts) {
|
|
|
84837
85231
|
stringWidth: (str) => {
|
|
84838
85232
|
return [...str].length;
|
|
84839
85233
|
},
|
|
84840
|
-
stripAnsi,
|
|
85234
|
+
stripAnsi: stripAnsi2,
|
|
84841
85235
|
wrap
|
|
84842
85236
|
});
|
|
84843
85237
|
}
|
|
@@ -84847,19 +85241,19 @@ var init_cliui = __esm(() => {
|
|
|
84847
85241
|
});
|
|
84848
85242
|
|
|
84849
85243
|
// node_modules/escalade/sync/index.mjs
|
|
84850
|
-
import { dirname as
|
|
85244
|
+
import { dirname as dirname15, resolve as resolve10 } from "path";
|
|
84851
85245
|
import { readdirSync as readdirSync11, statSync as statSync13 } from "fs";
|
|
84852
85246
|
function sync_default(start, callback) {
|
|
84853
|
-
let dir =
|
|
85247
|
+
let dir = resolve10(".", start);
|
|
84854
85248
|
let tmp, stats = statSync13(dir);
|
|
84855
85249
|
if (!stats.isDirectory()) {
|
|
84856
|
-
dir =
|
|
85250
|
+
dir = dirname15(dir);
|
|
84857
85251
|
}
|
|
84858
85252
|
while (true) {
|
|
84859
85253
|
tmp = callback(dir, readdirSync11(dir));
|
|
84860
85254
|
if (tmp)
|
|
84861
|
-
return
|
|
84862
|
-
dir =
|
|
85255
|
+
return resolve10(dir, tmp);
|
|
85256
|
+
dir = dirname15(tmp = dir);
|
|
84863
85257
|
if (tmp === dir)
|
|
84864
85258
|
break;
|
|
84865
85259
|
}
|
|
@@ -85805,7 +86199,7 @@ var init_yargs_parser = __esm(() => {
|
|
|
85805
86199
|
|
|
85806
86200
|
// node_modules/yargs-parser/build/lib/index.js
|
|
85807
86201
|
import { format } from "util";
|
|
85808
|
-
import { normalize as normalize2, resolve as
|
|
86202
|
+
import { normalize as normalize2, resolve as resolve11 } from "path";
|
|
85809
86203
|
var _a3, _b, _c, minNodeVersion, nodeVersion, env, parser, yargsParser = function Parser(args, opts) {
|
|
85810
86204
|
const result = parser.parse(args.slice(), opts);
|
|
85811
86205
|
return result.argv;
|
|
@@ -85828,7 +86222,7 @@ var init_lib2 = __esm(() => {
|
|
|
85828
86222
|
},
|
|
85829
86223
|
format,
|
|
85830
86224
|
normalize: normalize2,
|
|
85831
|
-
resolve:
|
|
86225
|
+
resolve: resolve11,
|
|
85832
86226
|
require: (path9) => {
|
|
85833
86227
|
if (true) {
|
|
85834
86228
|
return __require(path9);
|
|
@@ -85880,7 +86274,7 @@ var init_yerror = __esm(() => {
|
|
|
85880
86274
|
// node_modules/y18n/build/lib/platform-shims/node.js
|
|
85881
86275
|
import { readFileSync as readFileSync28, statSync as statSync14, writeFile } from "fs";
|
|
85882
86276
|
import { format as format2 } from "util";
|
|
85883
|
-
import { resolve as
|
|
86277
|
+
import { resolve as resolve12 } from "path";
|
|
85884
86278
|
var node_default;
|
|
85885
86279
|
var init_node = __esm(() => {
|
|
85886
86280
|
node_default = {
|
|
@@ -85889,7 +86283,7 @@ var init_node = __esm(() => {
|
|
|
85889
86283
|
writeFile
|
|
85890
86284
|
},
|
|
85891
86285
|
format: format2,
|
|
85892
|
-
resolve:
|
|
86286
|
+
resolve: resolve12,
|
|
85893
86287
|
exists: (file) => {
|
|
85894
86288
|
try {
|
|
85895
86289
|
return statSync14(file).isFile();
|
|
@@ -86072,7 +86466,7 @@ import { notStrictEqual, strictEqual } from "assert";
|
|
|
86072
86466
|
import { inspect } from "util";
|
|
86073
86467
|
import { readFileSync as readFileSync29 } from "fs";
|
|
86074
86468
|
import { fileURLToPath } from "url";
|
|
86075
|
-
import { basename as basename9, dirname as
|
|
86469
|
+
import { basename as basename9, dirname as dirname16, extname as extname3, relative as relative9, resolve as resolve13 } from "path";
|
|
86076
86470
|
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;
|
|
86077
86471
|
var init_esm = __esm(() => {
|
|
86078
86472
|
init_cliui();
|
|
@@ -86105,10 +86499,10 @@ var init_esm = __esm(() => {
|
|
|
86105
86499
|
Parser: lib_default,
|
|
86106
86500
|
path: {
|
|
86107
86501
|
basename: basename9,
|
|
86108
|
-
dirname:
|
|
86502
|
+
dirname: dirname16,
|
|
86109
86503
|
extname: extname3,
|
|
86110
86504
|
relative: relative9,
|
|
86111
|
-
resolve:
|
|
86505
|
+
resolve: resolve13
|
|
86112
86506
|
},
|
|
86113
86507
|
process: {
|
|
86114
86508
|
argv: () => process.argv,
|
|
@@ -86130,7 +86524,7 @@ var init_esm = __esm(() => {
|
|
|
86130
86524
|
return [...str].length;
|
|
86131
86525
|
},
|
|
86132
86526
|
y18n: y18n_default({
|
|
86133
|
-
directory:
|
|
86527
|
+
directory: resolve13(__dirname2, "../../../locales"),
|
|
86134
86528
|
updateFiles: false
|
|
86135
86529
|
})
|
|
86136
86530
|
};
|
|
@@ -88378,12 +88772,12 @@ var init_yargs_factory = __esm(() => {
|
|
|
88378
88772
|
async getCompletion(args, done) {
|
|
88379
88773
|
argsert("<array> [function]", [args, done], arguments.length);
|
|
88380
88774
|
if (!done) {
|
|
88381
|
-
return new Promise((
|
|
88775
|
+
return new Promise((resolve14, reject) => {
|
|
88382
88776
|
__classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
|
|
88383
88777
|
if (err)
|
|
88384
88778
|
reject(err);
|
|
88385
88779
|
else
|
|
88386
|
-
|
|
88780
|
+
resolve14(completions);
|
|
88387
88781
|
});
|
|
88388
88782
|
});
|
|
88389
88783
|
} else {
|
|
@@ -89818,9 +90212,9 @@ async function getConnectionTransport(options) {
|
|
|
89818
90212
|
throw new Error("Could not detect required browser platform");
|
|
89819
90213
|
}
|
|
89820
90214
|
const { convertPuppeteerChannelToBrowsersChannel: convertPuppeteerChannelToBrowsersChannel2 } = await Promise.resolve().then(() => (init_LaunchOptions(), exports_LaunchOptions));
|
|
89821
|
-
const { join:
|
|
90215
|
+
const { join: join33 } = await import("node:path");
|
|
89822
90216
|
const userDataDir = resolveDefaultUserDataDir3(Browser7.CHROME, platform2, convertPuppeteerChannelToBrowsersChannel2(options.channel));
|
|
89823
|
-
const portPath =
|
|
90217
|
+
const portPath = join33(userDataDir, "DevToolsActivePort");
|
|
89824
90218
|
try {
|
|
89825
90219
|
const fileContent = await environment.value.fs.promises.readFile(portPath, "ascii");
|
|
89826
90220
|
const [rawPort, rawPath] = fileContent.split(`
|
|
@@ -90044,9 +90438,9 @@ var init_PipeTransport = __esm(() => {
|
|
|
90044
90438
|
});
|
|
90045
90439
|
|
|
90046
90440
|
// node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserLauncher.js
|
|
90047
|
-
import { existsSync as
|
|
90441
|
+
import { existsSync as existsSync37 } from "node:fs";
|
|
90048
90442
|
import { tmpdir } from "node:os";
|
|
90049
|
-
import { join as
|
|
90443
|
+
import { join as join33 } from "node:path";
|
|
90050
90444
|
|
|
90051
90445
|
class BrowserLauncher {
|
|
90052
90446
|
#browser;
|
|
@@ -90071,7 +90465,7 @@ class BrowserLauncher {
|
|
|
90071
90465
|
...options,
|
|
90072
90466
|
protocol
|
|
90073
90467
|
});
|
|
90074
|
-
if (!
|
|
90468
|
+
if (!existsSync37(launchArgs.executablePath)) {
|
|
90075
90469
|
throw new Error(`Browser was not found at the configured executablePath (${launchArgs.executablePath})`);
|
|
90076
90470
|
}
|
|
90077
90471
|
const usePipe = launchArgs.args.includes("--remote-debugging-pipe");
|
|
@@ -90146,7 +90540,7 @@ class BrowserLauncher {
|
|
|
90146
90540
|
browserCloseCallback();
|
|
90147
90541
|
const logs = browserProcess.getRecentLogs().join(`
|
|
90148
90542
|
`);
|
|
90149
|
-
if (logs.includes("Failed to create a ProcessSingleton for your profile directory") || process.platform === "win32" &&
|
|
90543
|
+
if (logs.includes("Failed to create a ProcessSingleton for your profile directory") || process.platform === "win32" && existsSync37(join33(launchArgs.userDataDir, "lockfile"))) {
|
|
90150
90544
|
throw new Error(`The browser is already running for ${launchArgs.userDataDir}. Use a different \`userDataDir\` or stop the running browser first.`);
|
|
90151
90545
|
}
|
|
90152
90546
|
if (logs.includes("Missing X server") && options.headless === false) {
|
|
@@ -90236,12 +90630,12 @@ class BrowserLauncher {
|
|
|
90236
90630
|
});
|
|
90237
90631
|
}
|
|
90238
90632
|
getProfilePath() {
|
|
90239
|
-
return
|
|
90633
|
+
return join33(this.puppeteer.configuration.temporaryDirectory ?? tmpdir(), `puppeteer_dev_${this.browser}_profile-`);
|
|
90240
90634
|
}
|
|
90241
90635
|
resolveExecutablePath(headless, validatePath = true) {
|
|
90242
90636
|
let executablePath = this.puppeteer.configuration.executablePath;
|
|
90243
90637
|
if (executablePath) {
|
|
90244
|
-
if (validatePath && !
|
|
90638
|
+
if (validatePath && !existsSync37(executablePath)) {
|
|
90245
90639
|
throw new Error(`Tried to find the browser at the configured path (${executablePath}), but no executable was found.`);
|
|
90246
90640
|
}
|
|
90247
90641
|
return executablePath;
|
|
@@ -90264,7 +90658,7 @@ class BrowserLauncher {
|
|
|
90264
90658
|
browser: browserType,
|
|
90265
90659
|
buildId: this.puppeteer.browserVersion
|
|
90266
90660
|
});
|
|
90267
|
-
if (validatePath && !
|
|
90661
|
+
if (validatePath && !existsSync37(executablePath)) {
|
|
90268
90662
|
const configVersion = this.puppeteer.configuration?.[this.browser]?.version;
|
|
90269
90663
|
if (configVersion) {
|
|
90270
90664
|
throw new Error(`Tried to find the browser at the configured path (${executablePath}) for version ${configVersion}, but no executable was found.`);
|
|
@@ -90802,7 +91196,7 @@ var init_PuppeteerNode = __esm(() => {
|
|
|
90802
91196
|
import { spawn as spawn2, spawnSync as spawnSync5 } from "node:child_process";
|
|
90803
91197
|
import fs5 from "node:fs";
|
|
90804
91198
|
import os8 from "node:os";
|
|
90805
|
-
import { dirname as
|
|
91199
|
+
import { dirname as dirname17 } from "node:path";
|
|
90806
91200
|
import { PassThrough } from "node:stream";
|
|
90807
91201
|
var import_debug6, __runInitializers22 = function(thisArg, initializers, value) {
|
|
90808
91202
|
var useValue = arguments.length > 2;
|
|
@@ -90876,8 +91270,8 @@ var init_ScreenRecorder = __esm(() => {
|
|
|
90876
91270
|
static {
|
|
90877
91271
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : undefined;
|
|
90878
91272
|
__esDecorate22(this, _private_writeFrame_descriptor = { value: __setFunctionName5(async function(buffer) {
|
|
90879
|
-
const error = await new Promise((
|
|
90880
|
-
this.#process.stdin.write(buffer,
|
|
91273
|
+
const error = await new Promise((resolve14) => {
|
|
91274
|
+
this.#process.stdin.write(buffer, resolve14);
|
|
90881
91275
|
});
|
|
90882
91276
|
if (error) {
|
|
90883
91277
|
console.log(`ffmpeg failed to write: ${error.message}.`);
|
|
@@ -90926,7 +91320,7 @@ var init_ScreenRecorder = __esm(() => {
|
|
|
90926
91320
|
filters.push(formatArgs.splice(vf, 2).at(-1) ?? "");
|
|
90927
91321
|
}
|
|
90928
91322
|
if (path11) {
|
|
90929
|
-
fs5.mkdirSync(
|
|
91323
|
+
fs5.mkdirSync(dirname17(path11), { recursive: overwrite });
|
|
90930
91324
|
}
|
|
90931
91325
|
this.#process = spawn2(ffmpegPath, [
|
|
90932
91326
|
["-loglevel", "error"],
|
|
@@ -91032,8 +91426,8 @@ var init_ScreenRecorder = __esm(() => {
|
|
|
91032
91426
|
const [buffer, timestamp] = await this.#lastFrame;
|
|
91033
91427
|
await Promise.all(Array(Math.max(1, Math.round(this.#fps * (performance.now() - timestamp) / 1000))).fill(buffer).map(this.#writeFrame.bind(this)));
|
|
91034
91428
|
this.#process.stdin.end();
|
|
91035
|
-
await new Promise((
|
|
91036
|
-
this.#process.once("close",
|
|
91429
|
+
await new Promise((resolve14) => {
|
|
91430
|
+
this.#process.once("close", resolve14);
|
|
91037
91431
|
});
|
|
91038
91432
|
}
|
|
91039
91433
|
async[(_private_writeFrame_decorators = [guarded()], _stop_decorators = [guarded()], asyncDisposeSymbol)]() {
|
|
@@ -91079,17 +91473,17 @@ var init_puppeteer_core = __esm(() => {
|
|
|
91079
91473
|
});
|
|
91080
91474
|
|
|
91081
91475
|
// src/core/design-eval/capture.ts
|
|
91082
|
-
import { mkdirSync as
|
|
91083
|
-
import { join as
|
|
91476
|
+
import { mkdirSync as mkdirSync16, statSync as statSync15, existsSync as existsSync38 } from "fs";
|
|
91477
|
+
import { join as join34 } from "path";
|
|
91084
91478
|
function findBrowser() {
|
|
91085
91479
|
const platform2 = process.platform;
|
|
91086
91480
|
const paths = CHROME_PATHS[platform2] ?? [];
|
|
91087
91481
|
for (const p of paths) {
|
|
91088
|
-
if (
|
|
91482
|
+
if (existsSync38(p))
|
|
91089
91483
|
return p;
|
|
91090
91484
|
}
|
|
91091
|
-
const minkBrowsers =
|
|
91092
|
-
if (
|
|
91485
|
+
const minkBrowsers = join34(minkRoot(), "browsers");
|
|
91486
|
+
if (existsSync38(minkBrowsers)) {
|
|
91093
91487
|
const found = findChromeInDir(minkBrowsers);
|
|
91094
91488
|
if (found)
|
|
91095
91489
|
return found;
|
|
@@ -91110,7 +91504,7 @@ function findChromeInDir(dir) {
|
|
|
91110
91504
|
try {
|
|
91111
91505
|
const entries = readdirSync12(dir);
|
|
91112
91506
|
for (const entry of entries) {
|
|
91113
|
-
const full =
|
|
91507
|
+
const full = join34(dir, entry);
|
|
91114
91508
|
try {
|
|
91115
91509
|
const stat2 = statSync16(full);
|
|
91116
91510
|
if (stat2.isDirectory()) {
|
|
@@ -91158,7 +91552,7 @@ async function captureRoute(page, route, baseUrl, viewport, options) {
|
|
|
91158
91552
|
const y = section * viewport.height;
|
|
91159
91553
|
const clipHeight = Math.min(viewport.height, pageHeight - y);
|
|
91160
91554
|
const fileName = `${prefix}-${viewport.name}-${section}.jpg`;
|
|
91161
|
-
const filePath =
|
|
91555
|
+
const filePath = join34(options.outputDir, fileName);
|
|
91162
91556
|
await page.screenshot({
|
|
91163
91557
|
path: filePath,
|
|
91164
91558
|
type: "jpeg",
|
|
@@ -91190,7 +91584,7 @@ async function captureRoute(page, route, baseUrl, viewport, options) {
|
|
|
91190
91584
|
return results;
|
|
91191
91585
|
}
|
|
91192
91586
|
async function captureAllRoutes(routes, baseUrl, viewports, options, outputDir) {
|
|
91193
|
-
|
|
91587
|
+
mkdirSync16(outputDir, { recursive: true });
|
|
91194
91588
|
const executablePath = findBrowser();
|
|
91195
91589
|
const browser = await puppeteer_core_default.launch({
|
|
91196
91590
|
executablePath,
|
|
@@ -92627,9 +93021,9 @@ var exports_wiki = {};
|
|
|
92627
93021
|
__export(exports_wiki, {
|
|
92628
93022
|
wiki: () => wiki
|
|
92629
93023
|
});
|
|
92630
|
-
import { existsSync as
|
|
92631
|
-
import { resolve as
|
|
92632
|
-
import { homedir as
|
|
93024
|
+
import { existsSync as existsSync39, statSync as statSync16 } from "fs";
|
|
93025
|
+
import { resolve as resolve14 } from "path";
|
|
93026
|
+
import { homedir as homedir5 } from "os";
|
|
92633
93027
|
async function wiki(_cwd, args) {
|
|
92634
93028
|
const sub = args[0];
|
|
92635
93029
|
switch (sub) {
|
|
@@ -92685,7 +93079,7 @@ async function wikiInit(args) {
|
|
|
92685
93079
|
console.log(`[mink] initializing vault at ${targetPath}`);
|
|
92686
93080
|
console.log(" (set a custom path with: mink wiki init /path/to/vault)");
|
|
92687
93081
|
}
|
|
92688
|
-
const isExisting =
|
|
93082
|
+
const isExisting = existsSync39(targetPath) && statSync16(targetPath).isDirectory();
|
|
92689
93083
|
setConfigValue("wiki.path", targetPath);
|
|
92690
93084
|
ensureVaultStructure();
|
|
92691
93085
|
seedTemplates(vaultTemplates());
|
|
@@ -92895,9 +93289,9 @@ function wikiLinks() {
|
|
|
92895
93289
|
}
|
|
92896
93290
|
function expandPath(raw) {
|
|
92897
93291
|
if (raw.startsWith("~/")) {
|
|
92898
|
-
return
|
|
93292
|
+
return resolve14(homedir5(), raw.slice(2));
|
|
92899
93293
|
}
|
|
92900
|
-
return
|
|
93294
|
+
return resolve14(raw);
|
|
92901
93295
|
}
|
|
92902
93296
|
var init_wiki = __esm(() => {
|
|
92903
93297
|
init_vault();
|
|
@@ -92913,8 +93307,8 @@ var exports_note = {};
|
|
|
92913
93307
|
__export(exports_note, {
|
|
92914
93308
|
note: () => note
|
|
92915
93309
|
});
|
|
92916
|
-
import { resolve as
|
|
92917
|
-
import { existsSync as
|
|
93310
|
+
import { resolve as resolve15 } from "path";
|
|
93311
|
+
import { existsSync as existsSync40, readFileSync as readFileSync30 } from "fs";
|
|
92918
93312
|
async function note(cwd, args) {
|
|
92919
93313
|
if (!isWikiEnabled()) {
|
|
92920
93314
|
console.error("[mink] wiki feature is disabled");
|
|
@@ -92944,8 +93338,8 @@ async function note(cwd, args) {
|
|
|
92944
93338
|
return;
|
|
92945
93339
|
}
|
|
92946
93340
|
if (parsed.file) {
|
|
92947
|
-
const sourcePath =
|
|
92948
|
-
if (!
|
|
93341
|
+
const sourcePath = resolve15(cwd, parsed.file);
|
|
93342
|
+
if (!existsSync40(sourcePath)) {
|
|
92949
93343
|
console.error(`[mink] file not found: ${sourcePath}`);
|
|
92950
93344
|
process.exit(1);
|
|
92951
93345
|
}
|
|
@@ -93106,39 +93500,39 @@ var exports_skill = {};
|
|
|
93106
93500
|
__export(exports_skill, {
|
|
93107
93501
|
skill: () => skill
|
|
93108
93502
|
});
|
|
93109
|
-
import { join as
|
|
93110
|
-
import { homedir as
|
|
93503
|
+
import { join as join35, resolve as resolve16, dirname as dirname18 } from "path";
|
|
93504
|
+
import { homedir as homedir6 } from "os";
|
|
93111
93505
|
import {
|
|
93112
|
-
existsSync as
|
|
93113
|
-
mkdirSync as
|
|
93114
|
-
copyFileSync
|
|
93506
|
+
existsSync as existsSync41,
|
|
93507
|
+
mkdirSync as mkdirSync17,
|
|
93508
|
+
copyFileSync,
|
|
93115
93509
|
unlinkSync as unlinkSync6,
|
|
93116
93510
|
readdirSync as readdirSync12,
|
|
93117
|
-
rmSync as
|
|
93511
|
+
rmSync as rmSync2,
|
|
93118
93512
|
symlinkSync as symlinkSync2,
|
|
93119
93513
|
lstatSync as lstatSync2
|
|
93120
93514
|
} from "fs";
|
|
93121
93515
|
function getSkillsSourceDir() {
|
|
93122
|
-
let dir =
|
|
93516
|
+
let dir = dirname18(new URL(import.meta.url).pathname);
|
|
93123
93517
|
while (true) {
|
|
93124
|
-
if (
|
|
93125
|
-
return
|
|
93518
|
+
if (existsSync41(join35(dir, "package.json")) && existsSync41(join35(dir, "skills"))) {
|
|
93519
|
+
return join35(dir, "skills");
|
|
93126
93520
|
}
|
|
93127
|
-
const parent =
|
|
93521
|
+
const parent = dirname18(dir);
|
|
93128
93522
|
if (parent === dir)
|
|
93129
93523
|
break;
|
|
93130
93524
|
dir = parent;
|
|
93131
93525
|
}
|
|
93132
|
-
return
|
|
93526
|
+
return resolve16(dirname18(new URL(import.meta.url).pathname), "../../skills");
|
|
93133
93527
|
}
|
|
93134
93528
|
function getAvailableSkills() {
|
|
93135
93529
|
const dir = getSkillsSourceDir();
|
|
93136
|
-
if (!
|
|
93530
|
+
if (!existsSync41(dir))
|
|
93137
93531
|
return [];
|
|
93138
|
-
return readdirSync12(dir, { withFileTypes: true }).filter((d) => d.isDirectory() &&
|
|
93532
|
+
return readdirSync12(dir, { withFileTypes: true }).filter((d) => d.isDirectory() && existsSync41(join35(dir, d.name, "SKILL.md"))).map((d) => d.name);
|
|
93139
93533
|
}
|
|
93140
93534
|
function isInstalled(skillName) {
|
|
93141
|
-
return
|
|
93535
|
+
return existsSync41(join35(AGENTS_SKILLS_DIR, skillName, "SKILL.md"));
|
|
93142
93536
|
}
|
|
93143
93537
|
async function skill(args) {
|
|
93144
93538
|
const sub = args[0];
|
|
@@ -93172,28 +93566,28 @@ function skillInstall(name) {
|
|
|
93172
93566
|
console.error(" Expected skills at: " + sourceDir);
|
|
93173
93567
|
return;
|
|
93174
93568
|
}
|
|
93175
|
-
|
|
93569
|
+
mkdirSync17(AGENTS_SKILLS_DIR, { recursive: true });
|
|
93176
93570
|
for (const skillName of skills) {
|
|
93177
|
-
const srcDir =
|
|
93178
|
-
const srcFile =
|
|
93179
|
-
const destDir =
|
|
93180
|
-
if (!
|
|
93571
|
+
const srcDir = join35(sourceDir, skillName);
|
|
93572
|
+
const srcFile = join35(srcDir, "SKILL.md");
|
|
93573
|
+
const destDir = join35(AGENTS_SKILLS_DIR, skillName);
|
|
93574
|
+
if (!existsSync41(srcFile)) {
|
|
93181
93575
|
console.error(`[mink] skill not found: ${skillName}`);
|
|
93182
93576
|
continue;
|
|
93183
93577
|
}
|
|
93184
|
-
|
|
93578
|
+
mkdirSync17(destDir, { recursive: true });
|
|
93185
93579
|
copyDirRecursive2(srcDir, destDir);
|
|
93186
|
-
|
|
93187
|
-
const symlink =
|
|
93580
|
+
mkdirSync17(CLAUDE_SKILLS_DIR, { recursive: true });
|
|
93581
|
+
const symlink = join35(CLAUDE_SKILLS_DIR, skillName);
|
|
93188
93582
|
try {
|
|
93189
|
-
if (
|
|
93583
|
+
if (existsSync41(symlink)) {
|
|
93190
93584
|
if (lstatSync2(symlink).isSymbolicLink() || lstatSync2(symlink).isFile()) {
|
|
93191
93585
|
unlinkSync6(symlink);
|
|
93192
93586
|
} else {
|
|
93193
|
-
|
|
93587
|
+
rmSync2(symlink, { recursive: true, force: true });
|
|
93194
93588
|
}
|
|
93195
93589
|
}
|
|
93196
|
-
const relativeTarget =
|
|
93590
|
+
const relativeTarget = join35("..", "..", ".agents", "skills", skillName);
|
|
93197
93591
|
symlinkSync2(relativeTarget, symlink);
|
|
93198
93592
|
} catch {}
|
|
93199
93593
|
console.log(`[mink] installed: ${skillName} -> ${destDir}`);
|
|
@@ -93204,15 +93598,15 @@ function skillInstall(name) {
|
|
|
93204
93598
|
function skillUninstall(name) {
|
|
93205
93599
|
const skills = name ? [name] : getAvailableSkills();
|
|
93206
93600
|
for (const skillName of skills) {
|
|
93207
|
-
const destDir =
|
|
93208
|
-
if (!
|
|
93601
|
+
const destDir = join35(AGENTS_SKILLS_DIR, skillName);
|
|
93602
|
+
if (!existsSync41(destDir)) {
|
|
93209
93603
|
console.log(`[mink] not installed: ${skillName}`);
|
|
93210
93604
|
continue;
|
|
93211
93605
|
}
|
|
93212
|
-
|
|
93213
|
-
const symlink =
|
|
93606
|
+
rmSync2(destDir, { recursive: true, force: true });
|
|
93607
|
+
const symlink = join35(CLAUDE_SKILLS_DIR, skillName);
|
|
93214
93608
|
try {
|
|
93215
|
-
if (
|
|
93609
|
+
if (existsSync41(symlink))
|
|
93216
93610
|
unlinkSync6(symlink);
|
|
93217
93611
|
} catch {}
|
|
93218
93612
|
console.log(`[mink] uninstalled: ${skillName}`);
|
|
@@ -93227,7 +93621,7 @@ function skillList() {
|
|
|
93227
93621
|
if (installed.length > 0) {
|
|
93228
93622
|
console.log(" Installed:");
|
|
93229
93623
|
for (const s of installed) {
|
|
93230
|
-
console.log(` ${s} (${
|
|
93624
|
+
console.log(` ${s} (${join35(AGENTS_SKILLS_DIR, s)})`);
|
|
93231
93625
|
}
|
|
93232
93626
|
}
|
|
93233
93627
|
if (notInstalled.length > 0) {
|
|
@@ -93246,20 +93640,20 @@ function skillList() {
|
|
|
93246
93640
|
function copyDirRecursive2(src, dest) {
|
|
93247
93641
|
const entries = readdirSync12(src, { withFileTypes: true });
|
|
93248
93642
|
for (const entry of entries) {
|
|
93249
|
-
const srcPath =
|
|
93250
|
-
const destPath =
|
|
93643
|
+
const srcPath = join35(src, entry.name);
|
|
93644
|
+
const destPath = join35(dest, entry.name);
|
|
93251
93645
|
if (entry.isDirectory()) {
|
|
93252
|
-
|
|
93646
|
+
mkdirSync17(destPath, { recursive: true });
|
|
93253
93647
|
copyDirRecursive2(srcPath, destPath);
|
|
93254
93648
|
} else {
|
|
93255
|
-
|
|
93649
|
+
copyFileSync(srcPath, destPath);
|
|
93256
93650
|
}
|
|
93257
93651
|
}
|
|
93258
93652
|
}
|
|
93259
93653
|
var AGENTS_SKILLS_DIR, CLAUDE_SKILLS_DIR;
|
|
93260
93654
|
var init_skill = __esm(() => {
|
|
93261
|
-
AGENTS_SKILLS_DIR =
|
|
93262
|
-
CLAUDE_SKILLS_DIR =
|
|
93655
|
+
AGENTS_SKILLS_DIR = join35(homedir6(), ".agents", "skills");
|
|
93656
|
+
CLAUDE_SKILLS_DIR = join35(homedir6(), ".claude", "skills");
|
|
93263
93657
|
});
|
|
93264
93658
|
|
|
93265
93659
|
// src/commands/agent.ts
|
|
@@ -93267,41 +93661,41 @@ var exports_agent = {};
|
|
|
93267
93661
|
__export(exports_agent, {
|
|
93268
93662
|
agent: () => agent
|
|
93269
93663
|
});
|
|
93270
|
-
import { join as
|
|
93271
|
-
import { homedir as
|
|
93664
|
+
import { join as join36, resolve as resolve17, dirname as dirname19 } from "path";
|
|
93665
|
+
import { homedir as homedir7 } from "os";
|
|
93272
93666
|
import {
|
|
93273
|
-
existsSync as
|
|
93274
|
-
mkdirSync as
|
|
93667
|
+
existsSync as existsSync42,
|
|
93668
|
+
mkdirSync as mkdirSync18,
|
|
93275
93669
|
readFileSync as readFileSync31,
|
|
93276
93670
|
writeFileSync as writeFileSync11
|
|
93277
93671
|
} from "fs";
|
|
93278
93672
|
import { createHash as createHash5 } from "crypto";
|
|
93279
93673
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
93280
93674
|
function getAgentTemplatePath() {
|
|
93281
|
-
let dir =
|
|
93675
|
+
let dir = dirname19(new URL(import.meta.url).pathname);
|
|
93282
93676
|
while (true) {
|
|
93283
|
-
if (
|
|
93284
|
-
return
|
|
93677
|
+
if (existsSync42(join36(dir, "package.json")) && existsSync42(join36(dir, "agents", TEMPLATE_FILE))) {
|
|
93678
|
+
return join36(dir, "agents", TEMPLATE_FILE);
|
|
93285
93679
|
}
|
|
93286
|
-
const parent =
|
|
93680
|
+
const parent = dirname19(dir);
|
|
93287
93681
|
if (parent === dir)
|
|
93288
93682
|
break;
|
|
93289
93683
|
dir = parent;
|
|
93290
93684
|
}
|
|
93291
|
-
return
|
|
93685
|
+
return resolve17(dirname19(new URL(import.meta.url).pathname), "../../agents", TEMPLATE_FILE);
|
|
93292
93686
|
}
|
|
93293
93687
|
function getMinkVersion() {
|
|
93294
|
-
let dir =
|
|
93688
|
+
let dir = dirname19(new URL(import.meta.url).pathname);
|
|
93295
93689
|
while (true) {
|
|
93296
|
-
const pkgPath =
|
|
93297
|
-
if (
|
|
93690
|
+
const pkgPath = join36(dir, "package.json");
|
|
93691
|
+
if (existsSync42(pkgPath)) {
|
|
93298
93692
|
try {
|
|
93299
93693
|
const pkg = JSON.parse(readFileSync31(pkgPath, "utf-8"));
|
|
93300
93694
|
if (pkg.name && pkg.version)
|
|
93301
93695
|
return pkg.version;
|
|
93302
93696
|
} catch {}
|
|
93303
93697
|
}
|
|
93304
|
-
const parent =
|
|
93698
|
+
const parent = dirname19(dir);
|
|
93305
93699
|
if (parent === dir)
|
|
93306
93700
|
break;
|
|
93307
93701
|
dir = parent;
|
|
@@ -93319,19 +93713,19 @@ function sha2562(text) {
|
|
|
93319
93713
|
return createHash5("sha256").update(text).digest("hex");
|
|
93320
93714
|
}
|
|
93321
93715
|
function claudeAgentsDir() {
|
|
93322
|
-
return
|
|
93716
|
+
return join36(homedir7(), ".claude", "agents");
|
|
93323
93717
|
}
|
|
93324
93718
|
function installedAgentPath() {
|
|
93325
|
-
return
|
|
93719
|
+
return join36(claudeAgentsDir(), INSTALLED_FILE);
|
|
93326
93720
|
}
|
|
93327
93721
|
function installAgentDefinition(opts) {
|
|
93328
93722
|
const templatePath = getAgentTemplatePath();
|
|
93329
|
-
if (!
|
|
93723
|
+
if (!existsSync42(templatePath)) {
|
|
93330
93724
|
throw new Error(`[mink agent] bundled agent template not found at ${templatePath}
|
|
93331
93725
|
` + " This usually means the package was installed without bundled assets.");
|
|
93332
93726
|
}
|
|
93333
93727
|
const installed = installedAgentPath();
|
|
93334
|
-
if (opts.skip &&
|
|
93728
|
+
if (opts.skip && existsSync42(installed)) {
|
|
93335
93729
|
return { action: "skipped", path: installed };
|
|
93336
93730
|
}
|
|
93337
93731
|
const template = readFileSync31(templatePath, "utf-8");
|
|
@@ -93340,14 +93734,14 @@ function installAgentDefinition(opts) {
|
|
|
93340
93734
|
VAULT_PATH: resolveVaultPath(),
|
|
93341
93735
|
MINK_VERSION: getMinkVersion()
|
|
93342
93736
|
});
|
|
93343
|
-
const exists =
|
|
93737
|
+
const exists = existsSync42(installed);
|
|
93344
93738
|
if (!opts.force && exists) {
|
|
93345
93739
|
const current = readFileSync31(installed, "utf-8");
|
|
93346
93740
|
if (sha2562(current) === sha2562(rendered)) {
|
|
93347
93741
|
return { action: "unchanged", path: installed };
|
|
93348
93742
|
}
|
|
93349
93743
|
}
|
|
93350
|
-
|
|
93744
|
+
mkdirSync18(claudeAgentsDir(), { recursive: true });
|
|
93351
93745
|
writeFileSync11(installed, rendered);
|
|
93352
93746
|
return {
|
|
93353
93747
|
action: exists ? "updated" : "installed",
|
|
@@ -93418,8 +93812,8 @@ async function agent(_cwd, rawArgs) {
|
|
|
93418
93812
|
}
|
|
93419
93813
|
const skipUpdate = args.noUpdate || process.env.MINK_AGENT_NO_UPDATE === "1";
|
|
93420
93814
|
const root = minkRoot();
|
|
93421
|
-
if (!
|
|
93422
|
-
|
|
93815
|
+
if (!existsSync42(root)) {
|
|
93816
|
+
mkdirSync18(root, { recursive: true });
|
|
93423
93817
|
}
|
|
93424
93818
|
let result;
|
|
93425
93819
|
try {
|
|
@@ -93470,13 +93864,13 @@ var init_agent = __esm(() => {
|
|
|
93470
93864
|
});
|
|
93471
93865
|
|
|
93472
93866
|
// src/core/sync-merge-drivers.ts
|
|
93473
|
-
import { readFileSync as readFileSync32, writeFileSync as writeFileSync12, appendFileSync as appendFileSync2, copyFileSync as
|
|
93474
|
-
import { join as
|
|
93867
|
+
import { readFileSync as readFileSync32, writeFileSync as writeFileSync12, appendFileSync as appendFileSync2, copyFileSync as copyFileSync2, renameSync as renameSync4, unlinkSync as unlinkSync7 } from "fs";
|
|
93868
|
+
import { join as join37 } from "path";
|
|
93475
93869
|
function logWarning(driver, args, err) {
|
|
93476
93870
|
try {
|
|
93477
93871
|
const line = `[${new Date().toISOString()}] ${driver} fallback for ${args.filePath}: ${err instanceof Error ? err.message : String(err)}
|
|
93478
93872
|
`;
|
|
93479
|
-
appendFileSync2(
|
|
93873
|
+
appendFileSync2(join37(minkRoot(), "sync-warnings.log"), line);
|
|
93480
93874
|
} catch {}
|
|
93481
93875
|
}
|
|
93482
93876
|
function readJsonOrNull(path12) {
|
|
@@ -93711,7 +94105,7 @@ function mergeDbDriver(args) {
|
|
|
93711
94105
|
const tmp = `${args.oursPath}.merge-${process.pid}-${Date.now()}.tmp`;
|
|
93712
94106
|
let ours = null;
|
|
93713
94107
|
try {
|
|
93714
|
-
|
|
94108
|
+
copyFileSync2(args.oursPath, tmp);
|
|
93715
94109
|
ours = openDriver(tmp);
|
|
93716
94110
|
ours.exec("PRAGMA journal_mode = WAL");
|
|
93717
94111
|
ours.exec("PRAGMA foreign_keys = ON");
|
|
@@ -94227,22 +94621,8 @@ switch (command2) {
|
|
|
94227
94621
|
sessionStop(sessionPath2(cwd));
|
|
94228
94622
|
break;
|
|
94229
94623
|
case "init": {
|
|
94230
|
-
const { init: init2
|
|
94231
|
-
|
|
94232
|
-
const agentFlagIndex = args.findIndex((a) => a === "--agent" || a.startsWith("--agent="));
|
|
94233
|
-
let agentValue;
|
|
94234
|
-
if (agentFlagIndex !== -1) {
|
|
94235
|
-
const a = args[agentFlagIndex];
|
|
94236
|
-
agentValue = a.includes("=") ? a.split("=").slice(1).join("=") : args[agentFlagIndex + 1];
|
|
94237
|
-
}
|
|
94238
|
-
const yes = args.includes("--yes") || args.includes("-y");
|
|
94239
|
-
const targets = agentValue ? resolveTargetsFromFlag2(agentValue) : undefined;
|
|
94240
|
-
if (agentValue && (!targets || targets.length === 0)) {
|
|
94241
|
-
console.error(`[mink] unknown --agent value: ${agentValue}`);
|
|
94242
|
-
console.error(" Valid: claude, pi, all (or a comma-separated list)");
|
|
94243
|
-
process.exit(1);
|
|
94244
|
-
}
|
|
94245
|
-
await init2(cwd, { targets, interactive: !yes });
|
|
94624
|
+
const { init: init2 } = await Promise.resolve().then(() => (init_init(), exports_init));
|
|
94625
|
+
await init2(cwd);
|
|
94246
94626
|
break;
|
|
94247
94627
|
}
|
|
94248
94628
|
case "status": {
|
|
@@ -94272,6 +94652,11 @@ switch (command2) {
|
|
|
94272
94652
|
await postRead2(cwd);
|
|
94273
94653
|
break;
|
|
94274
94654
|
}
|
|
94655
|
+
case "post-tool": {
|
|
94656
|
+
const { postTool: postTool2 } = await Promise.resolve().then(() => (init_post_tool(), exports_post_tool));
|
|
94657
|
+
await postTool2(cwd);
|
|
94658
|
+
break;
|
|
94659
|
+
}
|
|
94275
94660
|
case "pre-write": {
|
|
94276
94661
|
const { preWrite: preWrite2 } = await Promise.resolve().then(() => (init_pre_write(), exports_pre_write));
|
|
94277
94662
|
await preWrite2(cwd);
|
|
@@ -94287,6 +94672,11 @@ switch (command2) {
|
|
|
94287
94672
|
detectWaste3(cwd);
|
|
94288
94673
|
break;
|
|
94289
94674
|
}
|
|
94675
|
+
case "retrieve": {
|
|
94676
|
+
const { retrieve: retrieve2 } = await Promise.resolve().then(() => (init_retrieve(), exports_retrieve));
|
|
94677
|
+
retrieve2(cwd, process.argv.slice(3));
|
|
94678
|
+
break;
|
|
94679
|
+
}
|
|
94290
94680
|
case "cron": {
|
|
94291
94681
|
const { cron: cron2 } = await Promise.resolve().then(() => (init_cron(), exports_cron));
|
|
94292
94682
|
await cron2(cwd, process.argv.slice(3));
|
|
@@ -94386,12 +94776,12 @@ switch (command2) {
|
|
|
94386
94776
|
case "version":
|
|
94387
94777
|
case "--version":
|
|
94388
94778
|
case "-v": {
|
|
94389
|
-
const { resolve:
|
|
94779
|
+
const { resolve: resolve18, dirname: dirname20, basename: basename10 } = await import("path");
|
|
94390
94780
|
const bundlePath = new URL(import.meta.url).pathname;
|
|
94391
|
-
const cliPath =
|
|
94781
|
+
const cliPath = resolve18(dirname20(bundlePath));
|
|
94392
94782
|
const { readFileSync: readFileSync33 } = await import("fs");
|
|
94393
94783
|
try {
|
|
94394
|
-
const pkg = JSON.parse(readFileSync33(
|
|
94784
|
+
const pkg = JSON.parse(readFileSync33(resolve18(cliPath, "../package.json"), "utf-8"));
|
|
94395
94785
|
console.log(`mink ${pkg.version}`);
|
|
94396
94786
|
} catch {
|
|
94397
94787
|
console.log("mink (unknown version)");
|
|
@@ -94414,8 +94804,7 @@ switch (command2) {
|
|
|
94414
94804
|
console.log("Usage: mink <command> [options]");
|
|
94415
94805
|
console.log();
|
|
94416
94806
|
console.log("Commands:");
|
|
94417
|
-
console.log(" init
|
|
94418
|
-
console.log(" --agent claude|pi|all (default: detect & prompt)");
|
|
94807
|
+
console.log(" init Initialize Mink in the current project");
|
|
94419
94808
|
console.log(" status Display project health at a glance");
|
|
94420
94809
|
console.log(" scan [--check] Force a full file index rescan");
|
|
94421
94810
|
console.log(" config [key] [value] Manage global user settings");
|
|
@@ -94457,6 +94846,7 @@ switch (command2) {
|
|
|
94457
94846
|
console.log(" restore [backup] Restore state from a backup");
|
|
94458
94847
|
console.log(" bug search <term> Search the bug log");
|
|
94459
94848
|
console.log(" detect-waste Detect and flag wasteful patterns");
|
|
94849
|
+
console.log(" retrieve <token> Return a compressed tool output's original (spec 21)");
|
|
94460
94850
|
console.log(" reflect Generate learning memory reflections");
|
|
94461
94851
|
console.log(" designqc [target] Capture design screenshots (spec 13)");
|
|
94462
94852
|
console.log(" framework-advisor Generate framework advisor knowledge file (spec 14)");
|
|
@@ -94466,6 +94856,7 @@ switch (command2) {
|
|
|
94466
94856
|
console.log(" session-stop Finalize session and log data");
|
|
94467
94857
|
console.log(" pre-read / post-read File read hooks");
|
|
94468
94858
|
console.log(" pre-write / post-write File write hooks");
|
|
94859
|
+
console.log(" post-tool Tool-output compression hook (Bash/Grep/MCP, spec 21)");
|
|
94469
94860
|
break;
|
|
94470
94861
|
default:
|
|
94471
94862
|
console.error(`[mink] unknown command: ${command2 ?? "(none)"}`);
|