@skillrecordings/cli 0.19.0 → 0.20.0
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 +89 -303
- package/dist/index.js +503 -329
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9714,9 +9714,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
9714
9714
|
}
|
|
9715
9715
|
close(callback) {
|
|
9716
9716
|
if (callback === void 0) {
|
|
9717
|
-
return new Promise((
|
|
9717
|
+
return new Promise((resolve11, reject) => {
|
|
9718
9718
|
this.close((err, data2) => {
|
|
9719
|
-
return err ? reject(err) :
|
|
9719
|
+
return err ? reject(err) : resolve11(data2);
|
|
9720
9720
|
});
|
|
9721
9721
|
});
|
|
9722
9722
|
}
|
|
@@ -9754,9 +9754,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
9754
9754
|
err = null;
|
|
9755
9755
|
}
|
|
9756
9756
|
if (callback === void 0) {
|
|
9757
|
-
return new Promise((
|
|
9757
|
+
return new Promise((resolve11, reject) => {
|
|
9758
9758
|
this.destroy(err, (err2, data2) => {
|
|
9759
|
-
return err2 ? reject(err2) :
|
|
9759
|
+
return err2 ? reject(err2) : resolve11(data2);
|
|
9760
9760
|
});
|
|
9761
9761
|
});
|
|
9762
9762
|
}
|
|
@@ -13248,8 +13248,8 @@ var require_promise = __commonJS({
|
|
|
13248
13248
|
function createDeferredPromise() {
|
|
13249
13249
|
let res;
|
|
13250
13250
|
let rej;
|
|
13251
|
-
const promise = new Promise((
|
|
13252
|
-
res =
|
|
13251
|
+
const promise = new Promise((resolve11, reject) => {
|
|
13252
|
+
res = resolve11;
|
|
13253
13253
|
rej = reject;
|
|
13254
13254
|
});
|
|
13255
13255
|
return { promise, resolve: res, reject: rej };
|
|
@@ -14552,12 +14552,12 @@ upgrade: ${upgrade}\r
|
|
|
14552
14552
|
cb();
|
|
14553
14553
|
}
|
|
14554
14554
|
}
|
|
14555
|
-
const waitForDrain = () => new Promise((
|
|
14555
|
+
const waitForDrain = () => new Promise((resolve11, reject) => {
|
|
14556
14556
|
assert(callback === null);
|
|
14557
14557
|
if (socket[kError]) {
|
|
14558
14558
|
reject(socket[kError]);
|
|
14559
14559
|
} else {
|
|
14560
|
-
callback =
|
|
14560
|
+
callback = resolve11;
|
|
14561
14561
|
}
|
|
14562
14562
|
});
|
|
14563
14563
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -15368,12 +15368,12 @@ var require_client_h2 = __commonJS({
|
|
|
15368
15368
|
cb();
|
|
15369
15369
|
}
|
|
15370
15370
|
}
|
|
15371
|
-
const waitForDrain = () => new Promise((
|
|
15371
|
+
const waitForDrain = () => new Promise((resolve11, reject) => {
|
|
15372
15372
|
assert(callback === null);
|
|
15373
15373
|
if (socket[kError]) {
|
|
15374
15374
|
reject(socket[kError]);
|
|
15375
15375
|
} else {
|
|
15376
|
-
callback =
|
|
15376
|
+
callback = resolve11;
|
|
15377
15377
|
}
|
|
15378
15378
|
});
|
|
15379
15379
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -15676,16 +15676,16 @@ var require_client = __commonJS({
|
|
|
15676
15676
|
return this[kNeedDrain] < 2;
|
|
15677
15677
|
}
|
|
15678
15678
|
[kClose]() {
|
|
15679
|
-
return new Promise((
|
|
15679
|
+
return new Promise((resolve11) => {
|
|
15680
15680
|
if (this[kSize]) {
|
|
15681
|
-
this[kClosedResolve] =
|
|
15681
|
+
this[kClosedResolve] = resolve11;
|
|
15682
15682
|
} else {
|
|
15683
|
-
|
|
15683
|
+
resolve11(null);
|
|
15684
15684
|
}
|
|
15685
15685
|
});
|
|
15686
15686
|
}
|
|
15687
15687
|
[kDestroy](err) {
|
|
15688
|
-
return new Promise((
|
|
15688
|
+
return new Promise((resolve11) => {
|
|
15689
15689
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
15690
15690
|
for (let i = 0; i < requests.length; i++) {
|
|
15691
15691
|
const request = requests[i];
|
|
@@ -15696,7 +15696,7 @@ var require_client = __commonJS({
|
|
|
15696
15696
|
this[kClosedResolve]();
|
|
15697
15697
|
this[kClosedResolve] = null;
|
|
15698
15698
|
}
|
|
15699
|
-
|
|
15699
|
+
resolve11(null);
|
|
15700
15700
|
};
|
|
15701
15701
|
if (this[kHTTPContext]) {
|
|
15702
15702
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -16089,8 +16089,8 @@ var require_pool_base = __commonJS({
|
|
|
16089
16089
|
}
|
|
16090
16090
|
return Promise.all(closeAll);
|
|
16091
16091
|
} else {
|
|
16092
|
-
return new Promise((
|
|
16093
|
-
this[kClosedResolve] =
|
|
16092
|
+
return new Promise((resolve11) => {
|
|
16093
|
+
this[kClosedResolve] = resolve11;
|
|
16094
16094
|
});
|
|
16095
16095
|
}
|
|
16096
16096
|
}
|
|
@@ -17629,7 +17629,7 @@ var require_readable = __commonJS({
|
|
|
17629
17629
|
if (this._readableState.closeEmitted) {
|
|
17630
17630
|
return Promise.resolve(null);
|
|
17631
17631
|
}
|
|
17632
|
-
return new Promise((
|
|
17632
|
+
return new Promise((resolve11, reject) => {
|
|
17633
17633
|
if (this[kContentLength] && this[kContentLength] > limit2 || this[kBytesRead] > limit2) {
|
|
17634
17634
|
this.destroy(new AbortError2());
|
|
17635
17635
|
}
|
|
@@ -17643,11 +17643,11 @@ var require_readable = __commonJS({
|
|
|
17643
17643
|
if (signal.aborted) {
|
|
17644
17644
|
reject(signal.reason ?? new AbortError2());
|
|
17645
17645
|
} else {
|
|
17646
|
-
|
|
17646
|
+
resolve11(null);
|
|
17647
17647
|
}
|
|
17648
17648
|
});
|
|
17649
17649
|
} else {
|
|
17650
|
-
this.on("close",
|
|
17650
|
+
this.on("close", resolve11);
|
|
17651
17651
|
}
|
|
17652
17652
|
this.on("error", noop).on("data", () => {
|
|
17653
17653
|
if (this[kBytesRead] > limit2) {
|
|
@@ -17675,7 +17675,7 @@ var require_readable = __commonJS({
|
|
|
17675
17675
|
}
|
|
17676
17676
|
function consume(stream, type) {
|
|
17677
17677
|
assert(!stream[kConsume]);
|
|
17678
|
-
return new Promise((
|
|
17678
|
+
return new Promise((resolve11, reject) => {
|
|
17679
17679
|
if (isUnusable(stream)) {
|
|
17680
17680
|
const rState = stream._readableState;
|
|
17681
17681
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -17690,7 +17690,7 @@ var require_readable = __commonJS({
|
|
|
17690
17690
|
stream[kConsume] = {
|
|
17691
17691
|
type,
|
|
17692
17692
|
stream,
|
|
17693
|
-
resolve:
|
|
17693
|
+
resolve: resolve11,
|
|
17694
17694
|
reject,
|
|
17695
17695
|
length: 0,
|
|
17696
17696
|
body: []
|
|
@@ -17764,18 +17764,18 @@ var require_readable = __commonJS({
|
|
|
17764
17764
|
return buffer;
|
|
17765
17765
|
}
|
|
17766
17766
|
function consumeEnd(consume2, encoding) {
|
|
17767
|
-
const { type, body, resolve:
|
|
17767
|
+
const { type, body, resolve: resolve11, stream, length } = consume2;
|
|
17768
17768
|
try {
|
|
17769
17769
|
if (type === "text") {
|
|
17770
|
-
|
|
17770
|
+
resolve11(chunksDecode(body, length, encoding));
|
|
17771
17771
|
} else if (type === "json") {
|
|
17772
|
-
|
|
17772
|
+
resolve11(JSON.parse(chunksDecode(body, length, encoding)));
|
|
17773
17773
|
} else if (type === "arrayBuffer") {
|
|
17774
|
-
|
|
17774
|
+
resolve11(chunksConcat(body, length).buffer);
|
|
17775
17775
|
} else if (type === "blob") {
|
|
17776
|
-
|
|
17776
|
+
resolve11(new Blob(body, { type: stream[kContentType] }));
|
|
17777
17777
|
} else if (type === "bytes") {
|
|
17778
|
-
|
|
17778
|
+
resolve11(chunksConcat(body, length));
|
|
17779
17779
|
}
|
|
17780
17780
|
consumeFinish(consume2);
|
|
17781
17781
|
} catch (err) {
|
|
@@ -17966,9 +17966,9 @@ var require_api_request = __commonJS({
|
|
|
17966
17966
|
};
|
|
17967
17967
|
function request(opts, callback) {
|
|
17968
17968
|
if (callback === void 0) {
|
|
17969
|
-
return new Promise((
|
|
17969
|
+
return new Promise((resolve11, reject) => {
|
|
17970
17970
|
request.call(this, opts, (err, data2) => {
|
|
17971
|
-
return err ? reject(err) :
|
|
17971
|
+
return err ? reject(err) : resolve11(data2);
|
|
17972
17972
|
});
|
|
17973
17973
|
});
|
|
17974
17974
|
}
|
|
@@ -18182,9 +18182,9 @@ var require_api_stream = __commonJS({
|
|
|
18182
18182
|
};
|
|
18183
18183
|
function stream(opts, factory, callback) {
|
|
18184
18184
|
if (callback === void 0) {
|
|
18185
|
-
return new Promise((
|
|
18185
|
+
return new Promise((resolve11, reject) => {
|
|
18186
18186
|
stream.call(this, opts, factory, (err, data2) => {
|
|
18187
|
-
return err ? reject(err) :
|
|
18187
|
+
return err ? reject(err) : resolve11(data2);
|
|
18188
18188
|
});
|
|
18189
18189
|
});
|
|
18190
18190
|
}
|
|
@@ -18474,9 +18474,9 @@ var require_api_upgrade = __commonJS({
|
|
|
18474
18474
|
};
|
|
18475
18475
|
function upgrade(opts, callback) {
|
|
18476
18476
|
if (callback === void 0) {
|
|
18477
|
-
return new Promise((
|
|
18477
|
+
return new Promise((resolve11, reject) => {
|
|
18478
18478
|
upgrade.call(this, opts, (err, data2) => {
|
|
18479
|
-
return err ? reject(err) :
|
|
18479
|
+
return err ? reject(err) : resolve11(data2);
|
|
18480
18480
|
});
|
|
18481
18481
|
});
|
|
18482
18482
|
}
|
|
@@ -18570,9 +18570,9 @@ var require_api_connect = __commonJS({
|
|
|
18570
18570
|
};
|
|
18571
18571
|
function connect(opts, callback) {
|
|
18572
18572
|
if (callback === void 0) {
|
|
18573
|
-
return new Promise((
|
|
18573
|
+
return new Promise((resolve11, reject) => {
|
|
18574
18574
|
connect.call(this, opts, (err, data2) => {
|
|
18575
|
-
return err ? reject(err) :
|
|
18575
|
+
return err ? reject(err) : resolve11(data2);
|
|
18576
18576
|
});
|
|
18577
18577
|
});
|
|
18578
18578
|
}
|
|
@@ -19851,8 +19851,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19851
19851
|
"../../node_modules/.bun/undici@7.20.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
19852
19852
|
"use strict";
|
|
19853
19853
|
init_esm_shims();
|
|
19854
|
-
var { writeFile:
|
|
19855
|
-
var { dirname:
|
|
19854
|
+
var { writeFile: writeFile11, readFile: readFile12, mkdir: mkdir5 } = __require("fs/promises");
|
|
19855
|
+
var { dirname: dirname11, resolve: resolve11 } = __require("path");
|
|
19856
19856
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("timers");
|
|
19857
19857
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
19858
19858
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -20053,7 +20053,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
20053
20053
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
20054
20054
|
}
|
|
20055
20055
|
try {
|
|
20056
|
-
const data2 = await
|
|
20056
|
+
const data2 = await readFile12(resolve11(path3), "utf8");
|
|
20057
20057
|
const parsed = JSON.parse(data2);
|
|
20058
20058
|
if (Array.isArray(parsed)) {
|
|
20059
20059
|
this.#snapshots.clear();
|
|
@@ -20082,13 +20082,13 @@ var require_snapshot_recorder = __commonJS({
|
|
|
20082
20082
|
if (!path3) {
|
|
20083
20083
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
20084
20084
|
}
|
|
20085
|
-
const resolvedPath =
|
|
20086
|
-
await
|
|
20085
|
+
const resolvedPath = resolve11(path3);
|
|
20086
|
+
await mkdir5(dirname11(resolvedPath), { recursive: true });
|
|
20087
20087
|
const data2 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
20088
20088
|
hash,
|
|
20089
20089
|
snapshot
|
|
20090
20090
|
}));
|
|
20091
|
-
await
|
|
20091
|
+
await writeFile11(resolvedPath, JSON.stringify(data2, null, 2), { flush: true });
|
|
20092
20092
|
}
|
|
20093
20093
|
/**
|
|
20094
20094
|
* Clears all recorded snapshots
|
|
@@ -26660,7 +26660,7 @@ var require_fetch = __commonJS({
|
|
|
26660
26660
|
function dispatch({ body }) {
|
|
26661
26661
|
const url = requestCurrentURL(request);
|
|
26662
26662
|
const agent = fetchParams.controller.dispatcher;
|
|
26663
|
-
return new Promise((
|
|
26663
|
+
return new Promise((resolve11, reject) => agent.dispatch(
|
|
26664
26664
|
{
|
|
26665
26665
|
path: url.pathname + url.search,
|
|
26666
26666
|
origin: url.origin,
|
|
@@ -26740,7 +26740,7 @@ var require_fetch = __commonJS({
|
|
|
26740
26740
|
}
|
|
26741
26741
|
}
|
|
26742
26742
|
const onError = this.onError.bind(this);
|
|
26743
|
-
|
|
26743
|
+
resolve11({
|
|
26744
26744
|
status,
|
|
26745
26745
|
statusText,
|
|
26746
26746
|
headersList,
|
|
@@ -26783,7 +26783,7 @@ var require_fetch = __commonJS({
|
|
|
26783
26783
|
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
26784
26784
|
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString("latin1"), true);
|
|
26785
26785
|
}
|
|
26786
|
-
|
|
26786
|
+
resolve11({
|
|
26787
26787
|
status,
|
|
26788
26788
|
statusText: STATUS_CODES2[status],
|
|
26789
26789
|
headersList,
|
|
@@ -62996,7 +62996,7 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
62996
62996
|
}
|
|
62997
62997
|
url.path = path3;
|
|
62998
62998
|
}
|
|
62999
|
-
function
|
|
62999
|
+
function resolve11(input2, base) {
|
|
63000
63000
|
if (!input2 && !base)
|
|
63001
63001
|
return "";
|
|
63002
63002
|
const url = parseUrl(input2);
|
|
@@ -63049,7 +63049,7 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
63049
63049
|
return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
|
|
63050
63050
|
}
|
|
63051
63051
|
}
|
|
63052
|
-
return
|
|
63052
|
+
return resolve11;
|
|
63053
63053
|
}));
|
|
63054
63054
|
}
|
|
63055
63055
|
});
|
|
@@ -63396,8 +63396,8 @@ var require_trace_mapping_umd = __commonJS({
|
|
|
63396
63396
|
this.sources = sources;
|
|
63397
63397
|
this.sourcesContent = sourcesContent;
|
|
63398
63398
|
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
63399
|
-
const
|
|
63400
|
-
this.resolvedSources = sources.map(
|
|
63399
|
+
const resolve11 = resolver(mapUrl, sourceRoot);
|
|
63400
|
+
this.resolvedSources = sources.map(resolve11);
|
|
63401
63401
|
const { mappings } = parsed;
|
|
63402
63402
|
if (typeof mappings === "string") {
|
|
63403
63403
|
this._encoded = mappings;
|
|
@@ -72931,7 +72931,7 @@ var require_introspection = __commonJS({
|
|
|
72931
72931
|
exports.isStatic = isStatic;
|
|
72932
72932
|
exports.matchesPattern = matchesPattern;
|
|
72933
72933
|
exports.referencesImport = referencesImport;
|
|
72934
|
-
exports.resolve =
|
|
72934
|
+
exports.resolve = resolve11;
|
|
72935
72935
|
exports.willIMaybeExecuteBefore = willIMaybeExecuteBefore;
|
|
72936
72936
|
var _t = require_lib6();
|
|
72937
72937
|
var {
|
|
@@ -73189,7 +73189,7 @@ var require_introspection = __commonJS({
|
|
|
73189
73189
|
nodeMap.set(target.node, result);
|
|
73190
73190
|
return result;
|
|
73191
73191
|
}
|
|
73192
|
-
function
|
|
73192
|
+
function resolve11(dangerous, resolved) {
|
|
73193
73193
|
return _resolve.call(this, dangerous, resolved) || this;
|
|
73194
73194
|
}
|
|
73195
73195
|
function _resolve(dangerous, resolved) {
|
|
@@ -74551,7 +74551,7 @@ var require_lib10 = __commonJS({
|
|
|
74551
74551
|
|
|
74552
74552
|
// src/index.ts
|
|
74553
74553
|
init_esm_shims();
|
|
74554
|
-
import { resolve as
|
|
74554
|
+
import { resolve as resolve10 } from "path";
|
|
74555
74555
|
|
|
74556
74556
|
// src/core/config-loader.ts
|
|
74557
74557
|
init_esm_shims();
|
|
@@ -74627,7 +74627,7 @@ function parseEnvContent(content) {
|
|
|
74627
74627
|
return env;
|
|
74628
74628
|
}
|
|
74629
74629
|
async function decryptEnvFile(encryptedPath) {
|
|
74630
|
-
const { readFile:
|
|
74630
|
+
const { readFile: readFile12 } = await import("fs/promises");
|
|
74631
74631
|
if (!existsSync2(encryptedPath)) {
|
|
74632
74632
|
return {};
|
|
74633
74633
|
}
|
|
@@ -74637,7 +74637,7 @@ async function decryptEnvFile(encryptedPath) {
|
|
|
74637
74637
|
}
|
|
74638
74638
|
try {
|
|
74639
74639
|
const { decrypt } = await import("./crypto-MTXIOCYL.js");
|
|
74640
|
-
const encrypted = await
|
|
74640
|
+
const encrypted = await readFile12(encryptedPath);
|
|
74641
74641
|
const decrypted = await decrypt(encrypted, ageKey);
|
|
74642
74642
|
return parseEnvContent(decrypted);
|
|
74643
74643
|
} catch {
|
|
@@ -75293,7 +75293,12 @@ async function oauthSpikeAction(ctx, options) {
|
|
|
75293
75293
|
// src/commands/auth/setup.ts
|
|
75294
75294
|
init_esm_shims();
|
|
75295
75295
|
import { execSync as execSync2 } from "child_process";
|
|
75296
|
+
import { existsSync as existsSync3 } from "fs";
|
|
75296
75297
|
import { chmodSync, mkdirSync, writeFileSync } from "fs";
|
|
75298
|
+
import { mkdir as mkdir2, readFile as readFile2, writeFile } from "fs/promises";
|
|
75299
|
+
import { homedir as homedir2 } from "os";
|
|
75300
|
+
import { dirname, join as join2, resolve as resolve2 } from "path";
|
|
75301
|
+
import { fileURLToPath } from "url";
|
|
75297
75302
|
import { confirm } from "@inquirer/prompts";
|
|
75298
75303
|
|
|
75299
75304
|
// src/core/errors.ts
|
|
@@ -75707,6 +75712,13 @@ async function authSetupAction(ctx, options = {}) {
|
|
|
75707
75712
|
);
|
|
75708
75713
|
}
|
|
75709
75714
|
}
|
|
75715
|
+
try {
|
|
75716
|
+
await installCompanionSkill();
|
|
75717
|
+
if (!outputJson) {
|
|
75718
|
+
ctx.output.data(" companion skill: \u2705 installed for AI agents");
|
|
75719
|
+
}
|
|
75720
|
+
} catch {
|
|
75721
|
+
}
|
|
75710
75722
|
writeResult2(ctx, options, {
|
|
75711
75723
|
success: true,
|
|
75712
75724
|
tokenConfigured: true,
|
|
@@ -75715,6 +75727,31 @@ async function authSetupAction(ctx, options = {}) {
|
|
|
75715
75727
|
tokenSource
|
|
75716
75728
|
});
|
|
75717
75729
|
}
|
|
75730
|
+
async function installCompanionSkill() {
|
|
75731
|
+
const skillSource = resolve2(
|
|
75732
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
75733
|
+
"../../../../../skills/skill-support/SKILL.md"
|
|
75734
|
+
);
|
|
75735
|
+
let content;
|
|
75736
|
+
if (existsSync3(skillSource)) {
|
|
75737
|
+
content = await readFile2(skillSource, "utf-8");
|
|
75738
|
+
} else {
|
|
75739
|
+
const resp = await fetch(
|
|
75740
|
+
"https://raw.githubusercontent.com/skillrecordings/support/main/skills/skill-support/SKILL.md"
|
|
75741
|
+
);
|
|
75742
|
+
if (!resp.ok) return;
|
|
75743
|
+
content = await resp.text();
|
|
75744
|
+
}
|
|
75745
|
+
const targets = [
|
|
75746
|
+
join2(homedir2(), ".agents", "skills", "skill-support"),
|
|
75747
|
+
join2(homedir2(), ".pi", "agent", "skills", "skill-support"),
|
|
75748
|
+
join2(homedir2(), ".claude", "skills", "skill-support")
|
|
75749
|
+
];
|
|
75750
|
+
for (const dir of targets) {
|
|
75751
|
+
await mkdir2(dir, { recursive: true });
|
|
75752
|
+
await writeFile(join2(dir, "SKILL.md"), content, "utf-8");
|
|
75753
|
+
}
|
|
75754
|
+
}
|
|
75718
75755
|
|
|
75719
75756
|
// src/commands/auth/status.ts
|
|
75720
75757
|
init_esm_shims();
|
|
@@ -76082,12 +76119,12 @@ function parseTimeRange(since) {
|
|
|
76082
76119
|
// src/lib/vercel-client.ts
|
|
76083
76120
|
init_esm_shims();
|
|
76084
76121
|
import { execSync as execSync3 } from "child_process";
|
|
76085
|
-
import { existsSync as
|
|
76122
|
+
import { existsSync as existsSync4, readFileSync as readFileSync2 } from "fs";
|
|
76086
76123
|
import path from "path";
|
|
76087
76124
|
var DEFAULT_VERCEL_SCOPE = "skillrecordings";
|
|
76088
76125
|
function hasWorkspaceVercelDependency(dir) {
|
|
76089
76126
|
const packageJsonPath = path.join(dir, "package.json");
|
|
76090
|
-
if (!
|
|
76127
|
+
if (!existsSync4(packageJsonPath)) return false;
|
|
76091
76128
|
try {
|
|
76092
76129
|
const pkg = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
76093
76130
|
const hasWorkspaces = Array.isArray(pkg.workspaces);
|
|
@@ -76103,7 +76140,7 @@ function findPreferredNodeModulesBinDir(startDir) {
|
|
|
76103
76140
|
while (true) {
|
|
76104
76141
|
const candidate = path.join(dir, "node_modules", ".bin");
|
|
76105
76142
|
const vercelBin = process.platform === "win32" ? path.join(candidate, "vercel.cmd") : path.join(candidate, "vercel");
|
|
76106
|
-
if (
|
|
76143
|
+
if (existsSync4(vercelBin)) {
|
|
76107
76144
|
candidates.push(candidate);
|
|
76108
76145
|
}
|
|
76109
76146
|
const parent2 = path.dirname(dir);
|
|
@@ -77882,29 +77919,165 @@ function registerDatasetCommands(program3) {
|
|
|
77882
77919
|
});
|
|
77883
77920
|
}
|
|
77884
77921
|
|
|
77922
|
+
// src/commands/companion.ts
|
|
77923
|
+
init_esm_shims();
|
|
77924
|
+
import { existsSync as existsSync5 } from "fs";
|
|
77925
|
+
import { mkdir as mkdir3, readFile as readFile3, readlink, rm, writeFile as writeFile2 } from "fs/promises";
|
|
77926
|
+
import { homedir as homedir3 } from "os";
|
|
77927
|
+
import { dirname as dirname2, join as join3, resolve as resolve3 } from "path";
|
|
77928
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
77929
|
+
var SKILL_NAME = "skill-support";
|
|
77930
|
+
var SKILL_SOURCE = resolve3(
|
|
77931
|
+
dirname2(fileURLToPath2(import.meta.url)),
|
|
77932
|
+
"../../../../skills",
|
|
77933
|
+
SKILL_NAME,
|
|
77934
|
+
"SKILL.md"
|
|
77935
|
+
);
|
|
77936
|
+
var SKILL_RAW_URL = `https://raw.githubusercontent.com/skillrecordings/support/main/skills/${SKILL_NAME}/SKILL.md`;
|
|
77937
|
+
var TARGET_DIRS = [
|
|
77938
|
+
join3(homedir3(), ".agents", "skills", SKILL_NAME),
|
|
77939
|
+
join3(homedir3(), ".pi", "agent", "skills", SKILL_NAME),
|
|
77940
|
+
join3(homedir3(), ".claude", "skills", SKILL_NAME)
|
|
77941
|
+
];
|
|
77942
|
+
async function resolveSkillContent() {
|
|
77943
|
+
if (existsSync5(SKILL_SOURCE)) {
|
|
77944
|
+
return readFile3(SKILL_SOURCE, "utf-8");
|
|
77945
|
+
}
|
|
77946
|
+
const resp = await fetch(SKILL_RAW_URL);
|
|
77947
|
+
if (!resp.ok) {
|
|
77948
|
+
throw new Error(
|
|
77949
|
+
`Failed to fetch skill from GitHub: ${resp.status} ${resp.statusText}`
|
|
77950
|
+
);
|
|
77951
|
+
}
|
|
77952
|
+
return resp.text();
|
|
77953
|
+
}
|
|
77954
|
+
async function installToDir(dir, content) {
|
|
77955
|
+
const target = join3(dir, "SKILL.md");
|
|
77956
|
+
try {
|
|
77957
|
+
await mkdir3(dir, { recursive: true });
|
|
77958
|
+
if (existsSync5(target)) {
|
|
77959
|
+
try {
|
|
77960
|
+
const linkTarget = await readlink(target);
|
|
77961
|
+
await rm(target);
|
|
77962
|
+
} catch {
|
|
77963
|
+
const existing = await readFile3(target, "utf-8");
|
|
77964
|
+
if (existing === content) {
|
|
77965
|
+
return { dir, status: "unchanged" };
|
|
77966
|
+
}
|
|
77967
|
+
}
|
|
77968
|
+
}
|
|
77969
|
+
await writeFile2(target, content, "utf-8");
|
|
77970
|
+
const existed = existsSync5(target);
|
|
77971
|
+
return { dir, status: existed ? "updated" : "installed" };
|
|
77972
|
+
} catch (error) {
|
|
77973
|
+
return {
|
|
77974
|
+
dir,
|
|
77975
|
+
status: "error",
|
|
77976
|
+
message: error instanceof Error ? error.message : String(error)
|
|
77977
|
+
};
|
|
77978
|
+
}
|
|
77979
|
+
}
|
|
77980
|
+
async function companionInstallAction(ctx, _options) {
|
|
77981
|
+
const content = await resolveSkillContent();
|
|
77982
|
+
const results = [];
|
|
77983
|
+
for (const dir of TARGET_DIRS) {
|
|
77984
|
+
results.push(await installToDir(dir, content));
|
|
77985
|
+
}
|
|
77986
|
+
const installed = results.filter(
|
|
77987
|
+
(r) => r.status === "installed" || r.status === "updated"
|
|
77988
|
+
);
|
|
77989
|
+
const errors2 = results.filter((r) => r.status === "error");
|
|
77990
|
+
ctx.output.data({
|
|
77991
|
+
success: errors2.length === 0,
|
|
77992
|
+
skill: SKILL_NAME,
|
|
77993
|
+
results: results.map((r) => ({
|
|
77994
|
+
dir: r.dir,
|
|
77995
|
+
status: r.status,
|
|
77996
|
+
...r.message && { message: r.message }
|
|
77997
|
+
})),
|
|
77998
|
+
summary: `${installed.length} installed/updated, ${results.filter((r) => r.status === "unchanged").length} unchanged, ${errors2.length} errors`,
|
|
77999
|
+
hint: "AI agents (pi, Claude Code, Codex) will now discover the skill-support skill automatically."
|
|
78000
|
+
});
|
|
78001
|
+
}
|
|
78002
|
+
async function companionStatusAction(ctx, _options) {
|
|
78003
|
+
const results = await Promise.all(
|
|
78004
|
+
TARGET_DIRS.map(async (dir) => {
|
|
78005
|
+
const target = join3(dir, "SKILL.md");
|
|
78006
|
+
const exists = existsSync5(target);
|
|
78007
|
+
let isSymlink = false;
|
|
78008
|
+
let linkTarget;
|
|
78009
|
+
if (exists) {
|
|
78010
|
+
try {
|
|
78011
|
+
linkTarget = await readlink(target);
|
|
78012
|
+
isSymlink = true;
|
|
78013
|
+
} catch {
|
|
78014
|
+
}
|
|
78015
|
+
}
|
|
78016
|
+
return {
|
|
78017
|
+
dir,
|
|
78018
|
+
installed: exists,
|
|
78019
|
+
isSymlink,
|
|
78020
|
+
...linkTarget && { linkTarget }
|
|
78021
|
+
};
|
|
78022
|
+
})
|
|
78023
|
+
);
|
|
78024
|
+
ctx.output.data({
|
|
78025
|
+
success: true,
|
|
78026
|
+
skill: SKILL_NAME,
|
|
78027
|
+
locations: results,
|
|
78028
|
+
allInstalled: results.every((r) => r.installed),
|
|
78029
|
+
hint: results.every((r) => r.installed) ? "Companion skill is installed in all agent directories." : "Run `skill companion install` to install missing locations."
|
|
78030
|
+
});
|
|
78031
|
+
}
|
|
78032
|
+
function registerCompanionCommands(program3) {
|
|
78033
|
+
const companion = program3.command("companion").description(
|
|
78034
|
+
"Manage the companion agent skill (installs to ~/.agents, ~/.pi, ~/.claude)"
|
|
78035
|
+
);
|
|
78036
|
+
companion.command("install").description(
|
|
78037
|
+
"Install or update the companion skill for AI agents (pi, Claude Code, Codex)"
|
|
78038
|
+
).option("--json", "Output as JSON").action(async (options, command) => {
|
|
78039
|
+
const opts = typeof command.optsWithGlobals === "function" ? command.optsWithGlobals() : { ...command.parent?.opts(), ...command.opts() };
|
|
78040
|
+
const ctx = await createContext({
|
|
78041
|
+
format: options.json ? "json" : opts.format,
|
|
78042
|
+
verbose: opts.verbose,
|
|
78043
|
+
quiet: opts.quiet
|
|
78044
|
+
});
|
|
78045
|
+
await companionInstallAction(ctx, options);
|
|
78046
|
+
});
|
|
78047
|
+
companion.command("status").description("Check companion skill installation status").option("--json", "Output as JSON").action(async (options, command) => {
|
|
78048
|
+
const opts = typeof command.optsWithGlobals === "function" ? command.optsWithGlobals() : { ...command.parent?.opts(), ...command.opts() };
|
|
78049
|
+
const ctx = await createContext({
|
|
78050
|
+
format: options.json ? "json" : opts.format,
|
|
78051
|
+
verbose: opts.verbose,
|
|
78052
|
+
quiet: opts.quiet
|
|
78053
|
+
});
|
|
78054
|
+
await companionStatusAction(ctx, options);
|
|
78055
|
+
});
|
|
78056
|
+
}
|
|
78057
|
+
|
|
77885
78058
|
// src/commands/config/index.ts
|
|
77886
78059
|
init_esm_shims();
|
|
77887
78060
|
|
|
77888
78061
|
// src/commands/config/get.ts
|
|
77889
78062
|
init_esm_shims();
|
|
77890
|
-
import { existsSync as
|
|
78063
|
+
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "fs";
|
|
77891
78064
|
import { Decrypter as Decrypter2 } from "age-encryption";
|
|
77892
78065
|
|
|
77893
78066
|
// src/commands/config/set.ts
|
|
77894
78067
|
init_esm_shims();
|
|
77895
|
-
import { existsSync as
|
|
78068
|
+
import { existsSync as existsSync6, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
77896
78069
|
import { password, select } from "@inquirer/prompts";
|
|
77897
78070
|
import { Decrypter, Encrypter, identityToRecipient } from "age-encryption";
|
|
77898
78071
|
|
|
77899
78072
|
// src/commands/config/init.ts
|
|
77900
78073
|
init_esm_shims();
|
|
77901
|
-
import { homedir as
|
|
77902
|
-
import { join as
|
|
78074
|
+
import { homedir as homedir4 } from "os";
|
|
78075
|
+
import { join as join4 } from "path";
|
|
77903
78076
|
function getUserConfigDir2() {
|
|
77904
|
-
return
|
|
78077
|
+
return join4(homedir4(), ".config", "skill");
|
|
77905
78078
|
}
|
|
77906
78079
|
function getAgeKeyPath2() {
|
|
77907
|
-
return
|
|
78080
|
+
return join4(getUserConfigDir2(), "age.key");
|
|
77908
78081
|
}
|
|
77909
78082
|
async function configInitAction(ctx, options = {}) {
|
|
77910
78083
|
const outputJson = options.json === true || ctx.format === "json";
|
|
@@ -77941,7 +78114,7 @@ function parseKeyValue(input2) {
|
|
|
77941
78114
|
return { key, value };
|
|
77942
78115
|
}
|
|
77943
78116
|
async function readExistingConfig(identity, configPath) {
|
|
77944
|
-
if (!
|
|
78117
|
+
if (!existsSync6(configPath)) {
|
|
77945
78118
|
return {};
|
|
77946
78119
|
}
|
|
77947
78120
|
try {
|
|
@@ -77968,7 +78141,7 @@ async function readExistingConfig(identity, configPath) {
|
|
|
77968
78141
|
async function configSetAction(ctx, keyValue, options = {}) {
|
|
77969
78142
|
const outputJson = options.json === true || ctx.format === "json";
|
|
77970
78143
|
const keyPath = getAgeKeyPath2();
|
|
77971
|
-
if (!
|
|
78144
|
+
if (!existsSync6(keyPath)) {
|
|
77972
78145
|
const result = {
|
|
77973
78146
|
success: false,
|
|
77974
78147
|
error: "Age key not found. Run: skill config init"
|
|
@@ -78057,7 +78230,7 @@ async function configSetAction(ctx, keyValue, options = {}) {
|
|
|
78057
78230
|
// src/commands/config/get.ts
|
|
78058
78231
|
async function decryptConfig(identity) {
|
|
78059
78232
|
const configPath = getEncryptedConfigPath();
|
|
78060
|
-
if (!
|
|
78233
|
+
if (!existsSync7(configPath)) {
|
|
78061
78234
|
return {};
|
|
78062
78235
|
}
|
|
78063
78236
|
const encrypted = readFileSync4(configPath);
|
|
@@ -78142,11 +78315,11 @@ async function configGetAction(ctx, key, options = {}) {
|
|
|
78142
78315
|
|
|
78143
78316
|
// src/commands/config/list.ts
|
|
78144
78317
|
init_esm_shims();
|
|
78145
|
-
import { existsSync as
|
|
78318
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5 } from "fs";
|
|
78146
78319
|
import { Decrypter as Decrypter3 } from "age-encryption";
|
|
78147
78320
|
async function decryptConfig2(identity) {
|
|
78148
78321
|
const configPath = getEncryptedConfigPath();
|
|
78149
|
-
if (!
|
|
78322
|
+
if (!existsSync8(configPath)) {
|
|
78150
78323
|
return {};
|
|
78151
78324
|
}
|
|
78152
78325
|
const encrypted = readFileSync5(configPath);
|
|
@@ -78370,13 +78543,13 @@ var registerDbStatusCommand = (prog) => {
|
|
|
78370
78543
|
// src/commands/deploys.ts
|
|
78371
78544
|
init_esm_shims();
|
|
78372
78545
|
import { execSync as execSync4 } from "child_process";
|
|
78373
|
-
import { existsSync as
|
|
78546
|
+
import { existsSync as existsSync9, readFileSync as readFileSync6 } from "fs";
|
|
78374
78547
|
import path2 from "path";
|
|
78375
78548
|
import "commander";
|
|
78376
78549
|
var VERCEL_SCOPE = "skillrecordings";
|
|
78377
78550
|
function hasWorkspaceVercelDependency2(dir) {
|
|
78378
78551
|
const packageJsonPath = path2.join(dir, "package.json");
|
|
78379
|
-
if (!
|
|
78552
|
+
if (!existsSync9(packageJsonPath)) return false;
|
|
78380
78553
|
try {
|
|
78381
78554
|
const pkg = JSON.parse(readFileSync6(packageJsonPath, "utf-8"));
|
|
78382
78555
|
const hasWorkspaces = Array.isArray(pkg.workspaces);
|
|
@@ -78392,7 +78565,7 @@ function findPreferredNodeModulesBinDir2(startDir) {
|
|
|
78392
78565
|
while (true) {
|
|
78393
78566
|
const candidate = path2.join(dir, "node_modules", ".bin");
|
|
78394
78567
|
const vercelBin = process.platform === "win32" ? path2.join(candidate, "vercel.cmd") : path2.join(candidate, "vercel");
|
|
78395
|
-
if (
|
|
78568
|
+
if (existsSync9(vercelBin)) {
|
|
78396
78569
|
candidates.push(candidate);
|
|
78397
78570
|
}
|
|
78398
78571
|
const parent2 = path2.dirname(dir);
|
|
@@ -78662,9 +78835,9 @@ function registerDeployCommands(program3) {
|
|
|
78662
78835
|
// src/commands/doctor.ts
|
|
78663
78836
|
init_esm_shims();
|
|
78664
78837
|
import { execSync as execSync5 } from "child_process";
|
|
78665
|
-
import { existsSync as
|
|
78666
|
-
import { homedir as
|
|
78667
|
-
import { dirname, join as
|
|
78838
|
+
import { existsSync as existsSync10, lstatSync, readdirSync, readlinkSync } from "fs";
|
|
78839
|
+
import { homedir as homedir5 } from "os";
|
|
78840
|
+
import { dirname as dirname3, join as join5, resolve as resolve4 } from "path";
|
|
78668
78841
|
var REQUIRED_ENV_VARS = [
|
|
78669
78842
|
"DATABASE_URL",
|
|
78670
78843
|
"INNGEST_SIGNING_KEY",
|
|
@@ -78677,21 +78850,21 @@ var REQUIRED_ENV_VARS = [
|
|
|
78677
78850
|
"UPSTASH_VECTOR_REST_URL"
|
|
78678
78851
|
];
|
|
78679
78852
|
var SKILL_TARGET_ROOTS = [
|
|
78680
|
-
{ label: "~/.agents/skills", path:
|
|
78681
|
-
{ label: "~/.claude/skills", path:
|
|
78853
|
+
{ label: "~/.agents/skills", path: join5(homedir5(), ".agents", "skills") },
|
|
78854
|
+
{ label: "~/.claude/skills", path: join5(homedir5(), ".claude", "skills") },
|
|
78682
78855
|
{
|
|
78683
78856
|
label: "~/.pi/agent/skills",
|
|
78684
|
-
path:
|
|
78857
|
+
path: join5(homedir5(), ".pi", "agent", "skills")
|
|
78685
78858
|
}
|
|
78686
78859
|
];
|
|
78687
78860
|
function resolveSkillsSourceDir(startDir = process.cwd()) {
|
|
78688
|
-
let current =
|
|
78861
|
+
let current = resolve4(startDir);
|
|
78689
78862
|
while (true) {
|
|
78690
|
-
const candidate =
|
|
78691
|
-
if (
|
|
78863
|
+
const candidate = join5(current, "skills");
|
|
78864
|
+
if (existsSync10(candidate)) {
|
|
78692
78865
|
return candidate;
|
|
78693
78866
|
}
|
|
78694
|
-
const parent2 =
|
|
78867
|
+
const parent2 = dirname3(current);
|
|
78695
78868
|
if (parent2 === current) {
|
|
78696
78869
|
return null;
|
|
78697
78870
|
}
|
|
@@ -78700,7 +78873,7 @@ function resolveSkillsSourceDir(startDir = process.cwd()) {
|
|
|
78700
78873
|
}
|
|
78701
78874
|
function listSkillNames(skillsDir) {
|
|
78702
78875
|
const entries = readdirSync(skillsDir, { withFileTypes: true });
|
|
78703
|
-
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) =>
|
|
78876
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => existsSync10(join5(skillsDir, name, "SKILL.md"))).sort((a, b) => a.localeCompare(b));
|
|
78704
78877
|
}
|
|
78705
78878
|
function checkEnvVars() {
|
|
78706
78879
|
return REQUIRED_ENV_VARS.map((varName) => {
|
|
@@ -78729,7 +78902,7 @@ function checkKeychain() {
|
|
|
78729
78902
|
});
|
|
78730
78903
|
const ageKey = getFromKeychain("age-private-key");
|
|
78731
78904
|
const ageKeyPath = getAgeKeyPath();
|
|
78732
|
-
const ageKeyFileExists =
|
|
78905
|
+
const ageKeyFileExists = existsSync10(ageKeyPath);
|
|
78733
78906
|
checks.push({
|
|
78734
78907
|
name: "SKILL_AGE_KEY (file/keychain)",
|
|
78735
78908
|
status: ageKey || ageKeyFileExists ? "ok" : "warn",
|
|
@@ -78753,11 +78926,11 @@ function checkTools() {
|
|
|
78753
78926
|
}
|
|
78754
78927
|
function checkWorkspace() {
|
|
78755
78928
|
const checks = [];
|
|
78756
|
-
const hivePath =
|
|
78929
|
+
const hivePath = join5(process.cwd(), ".hive");
|
|
78757
78930
|
checks.push({
|
|
78758
78931
|
name: ".hive directory",
|
|
78759
|
-
status:
|
|
78760
|
-
message:
|
|
78932
|
+
status: existsSync10(hivePath) ? "ok" : "warn",
|
|
78933
|
+
message: existsSync10(hivePath) ? void 0 : "Not found in current directory"
|
|
78761
78934
|
});
|
|
78762
78935
|
return checks;
|
|
78763
78936
|
}
|
|
@@ -78795,9 +78968,9 @@ function checkSkillLinks() {
|
|
|
78795
78968
|
let missing = 0;
|
|
78796
78969
|
let conflicts = 0;
|
|
78797
78970
|
for (const skillName of skillNames) {
|
|
78798
|
-
const sourceSkillPath =
|
|
78799
|
-
const targetSkillPath =
|
|
78800
|
-
if (!
|
|
78971
|
+
const sourceSkillPath = join5(sourceDir, skillName);
|
|
78972
|
+
const targetSkillPath = join5(target.path, skillName);
|
|
78973
|
+
if (!existsSync10(targetSkillPath)) {
|
|
78801
78974
|
missing++;
|
|
78802
78975
|
continue;
|
|
78803
78976
|
}
|
|
@@ -78807,7 +78980,7 @@ function checkSkillLinks() {
|
|
|
78807
78980
|
continue;
|
|
78808
78981
|
}
|
|
78809
78982
|
const linkTarget = readlinkSync(targetSkillPath);
|
|
78810
|
-
const resolvedTarget =
|
|
78983
|
+
const resolvedTarget = resolve4(dirname3(targetSkillPath), linkTarget);
|
|
78811
78984
|
if (resolvedTarget === sourceSkillPath) {
|
|
78812
78985
|
linked++;
|
|
78813
78986
|
} else {
|
|
@@ -78918,7 +79091,7 @@ function buildAgentGuidance(categories, status, skillDiagnostics) {
|
|
|
78918
79091
|
(check) => `${check.name}: ${check.message ?? "Not ready"}`
|
|
78919
79092
|
),
|
|
78920
79093
|
fixSteps: [
|
|
78921
|
-
`cd ${skillDiagnostics.sourceDir ?
|
|
79094
|
+
`cd ${skillDiagnostics.sourceDir ? dirname3(skillDiagnostics.sourceDir) : process.cwd()}`,
|
|
78922
79095
|
"npx skills add -y -g ./skills",
|
|
78923
79096
|
"skill list --json"
|
|
78924
79097
|
],
|
|
@@ -79072,7 +79245,7 @@ function registerDoctorCommand(program3) {
|
|
|
79072
79245
|
|
|
79073
79246
|
// src/commands/eval.ts
|
|
79074
79247
|
init_esm_shims();
|
|
79075
|
-
import { access, readFile as
|
|
79248
|
+
import { access, readFile as readFile4 } from "fs/promises";
|
|
79076
79249
|
async function runEval(ctx, evalType, datasetPath, options = {}) {
|
|
79077
79250
|
const outputJson = options.json === true || ctx.format === "json";
|
|
79078
79251
|
const { gates } = options;
|
|
@@ -79099,7 +79272,7 @@ async function runEval(ctx, evalType, datasetPath, options = {}) {
|
|
|
79099
79272
|
}
|
|
79100
79273
|
let dataset;
|
|
79101
79274
|
try {
|
|
79102
|
-
const content = await
|
|
79275
|
+
const content = await readFile4(datasetPath, "utf-8");
|
|
79103
79276
|
dataset = JSON.parse(content);
|
|
79104
79277
|
} catch (error) {
|
|
79105
79278
|
throw new CLIError({
|
|
@@ -79491,7 +79664,7 @@ async function checkRedis() {
|
|
|
79491
79664
|
signal: AbortSignal.timeout(5e3)
|
|
79492
79665
|
}).catch(() => null);
|
|
79493
79666
|
const net = await import("net");
|
|
79494
|
-
return new Promise((
|
|
79667
|
+
return new Promise((resolve11) => {
|
|
79495
79668
|
const socket = new net.Socket();
|
|
79496
79669
|
socket.setTimeout(5e3);
|
|
79497
79670
|
socket.on("connect", () => {
|
|
@@ -79501,13 +79674,13 @@ async function checkRedis() {
|
|
|
79501
79674
|
const response2 = data2.toString();
|
|
79502
79675
|
socket.destroy();
|
|
79503
79676
|
if (response2.includes("PONG")) {
|
|
79504
|
-
|
|
79677
|
+
resolve11({
|
|
79505
79678
|
service: "Redis",
|
|
79506
79679
|
healthy: true,
|
|
79507
79680
|
message: "Redis responding to PING"
|
|
79508
79681
|
});
|
|
79509
79682
|
} else {
|
|
79510
|
-
|
|
79683
|
+
resolve11({
|
|
79511
79684
|
service: "Redis",
|
|
79512
79685
|
healthy: false,
|
|
79513
79686
|
message: "Unexpected response"
|
|
@@ -79516,7 +79689,7 @@ async function checkRedis() {
|
|
|
79516
79689
|
});
|
|
79517
79690
|
socket.on("timeout", () => {
|
|
79518
79691
|
socket.destroy();
|
|
79519
|
-
|
|
79692
|
+
resolve11({
|
|
79520
79693
|
service: "Redis",
|
|
79521
79694
|
healthy: false,
|
|
79522
79695
|
message: "Connection timeout"
|
|
@@ -79524,7 +79697,7 @@ async function checkRedis() {
|
|
|
79524
79697
|
});
|
|
79525
79698
|
socket.on("error", (err) => {
|
|
79526
79699
|
socket.destroy();
|
|
79527
|
-
|
|
79700
|
+
resolve11({
|
|
79528
79701
|
service: "Redis",
|
|
79529
79702
|
healthy: false,
|
|
79530
79703
|
message: err.message
|
|
@@ -79765,7 +79938,7 @@ var Helpfulness = ({
|
|
|
79765
79938
|
|
|
79766
79939
|
// src/commands/eval-local/run.ts
|
|
79767
79940
|
import { generateText, stepCountIs, tool as tool2 } from "ai";
|
|
79768
|
-
import { readFile as
|
|
79941
|
+
import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
79769
79942
|
import { glob } from "glob";
|
|
79770
79943
|
import { z as z3 } from "zod";
|
|
79771
79944
|
|
|
@@ -80492,14 +80665,14 @@ async function run(ctx, options) {
|
|
|
80492
80665
|
}
|
|
80493
80666
|
let systemPrompt = SUPPORT_AGENT_PROMPT;
|
|
80494
80667
|
if (promptPath) {
|
|
80495
|
-
systemPrompt = await
|
|
80668
|
+
systemPrompt = await readFile5(promptPath, "utf-8");
|
|
80496
80669
|
log(`Using prompt from: ${promptPath}`);
|
|
80497
80670
|
} else {
|
|
80498
80671
|
log("Using production prompt");
|
|
80499
80672
|
}
|
|
80500
80673
|
let scenarios = [];
|
|
80501
80674
|
if (datasetPath) {
|
|
80502
|
-
const datasetContent = await
|
|
80675
|
+
const datasetContent = await readFile5(datasetPath, "utf-8");
|
|
80503
80676
|
const dataset = JSON.parse(datasetContent);
|
|
80504
80677
|
scenarios = dataset.map((item) => {
|
|
80505
80678
|
const trigger = item.triggerMessage || {
|
|
@@ -80532,7 +80705,7 @@ async function run(ctx, options) {
|
|
|
80532
80705
|
}
|
|
80533
80706
|
scenarios = await Promise.all(
|
|
80534
80707
|
scenarioFiles.map(async (file) => {
|
|
80535
|
-
const content = await
|
|
80708
|
+
const content = await readFile5(file, "utf-8");
|
|
80536
80709
|
return JSON.parse(content);
|
|
80537
80710
|
})
|
|
80538
80711
|
);
|
|
@@ -80570,7 +80743,7 @@ async function run(ctx, options) {
|
|
|
80570
80743
|
const summary = aggregateResults(results, totalDuration);
|
|
80571
80744
|
if (baseline) {
|
|
80572
80745
|
try {
|
|
80573
|
-
const baselineContent = await
|
|
80746
|
+
const baselineContent = await readFile5(baseline, "utf-8");
|
|
80574
80747
|
const baselineData = JSON.parse(baselineContent);
|
|
80575
80748
|
printComparison(ctx, summary, baselineData.summary || baselineData);
|
|
80576
80749
|
} catch (e) {
|
|
@@ -80580,7 +80753,7 @@ async function run(ctx, options) {
|
|
|
80580
80753
|
}
|
|
80581
80754
|
}
|
|
80582
80755
|
if (output) {
|
|
80583
|
-
await
|
|
80756
|
+
await writeFile3(output, JSON.stringify({ summary, results }, null, 2));
|
|
80584
80757
|
log(`Results saved to ${output}`);
|
|
80585
80758
|
}
|
|
80586
80759
|
if (outputJson) {
|
|
@@ -80897,14 +81070,14 @@ function printComparison(ctx, current, baseline) {
|
|
|
80897
81070
|
|
|
80898
81071
|
// src/commands/eval-local/score-production.ts
|
|
80899
81072
|
init_esm_shims();
|
|
80900
|
-
import { readFile as
|
|
81073
|
+
import { readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
|
|
80901
81074
|
async function scoreProduction(ctx, options) {
|
|
80902
81075
|
const { dataset: datasetPath, output, verbose, json } = options;
|
|
80903
81076
|
const outputJson = json === true || ctx.format === "json";
|
|
80904
81077
|
const log = (text3) => {
|
|
80905
81078
|
if (!outputJson) ctx.output.data(text3);
|
|
80906
81079
|
};
|
|
80907
|
-
const datasetContent = await
|
|
81080
|
+
const datasetContent = await readFile6(datasetPath, "utf-8");
|
|
80908
81081
|
const dataset = JSON.parse(datasetContent);
|
|
80909
81082
|
log(`
|
|
80910
81083
|
\u{1F4CA} Scoring ${dataset.length} production responses
|
|
@@ -81018,7 +81191,7 @@ async function scoreProduction(ctx, options) {
|
|
|
81018
81191
|
const withResponses = passed + failed;
|
|
81019
81192
|
const passRate = withResponses > 0 ? passed / withResponses * 100 : 0;
|
|
81020
81193
|
if (output) {
|
|
81021
|
-
await
|
|
81194
|
+
await writeFile4(
|
|
81022
81195
|
output,
|
|
81023
81196
|
JSON.stringify(
|
|
81024
81197
|
{
|
|
@@ -81077,13 +81250,13 @@ async function scoreProduction(ctx, options) {
|
|
|
81077
81250
|
|
|
81078
81251
|
// src/commands/eval-local/seed.ts
|
|
81079
81252
|
init_esm_shims();
|
|
81080
|
-
import { join as
|
|
81253
|
+
import { join as join7 } from "path";
|
|
81081
81254
|
import { glob as glob3 } from "glob";
|
|
81082
81255
|
|
|
81083
81256
|
// src/lib/eval-seed.ts
|
|
81084
81257
|
init_esm_shims();
|
|
81085
|
-
import { join as
|
|
81086
|
-
import { readFile as
|
|
81258
|
+
import { join as join6 } from "path";
|
|
81259
|
+
import { readFile as readFile7, readdir } from "fs/promises";
|
|
81087
81260
|
import { glob as glob2 } from "glob";
|
|
81088
81261
|
import matter from "gray-matter";
|
|
81089
81262
|
function generateUUID() {
|
|
@@ -81128,7 +81301,7 @@ async function loadJsonFiles(dirPath) {
|
|
|
81128
81301
|
const jsonFiles = files.filter((f) => f.endsWith(".json"));
|
|
81129
81302
|
const items = await Promise.all(
|
|
81130
81303
|
jsonFiles.map(async (file) => {
|
|
81131
|
-
const content = await
|
|
81304
|
+
const content = await readFile7(join6(dirPath, file), "utf-8");
|
|
81132
81305
|
return JSON.parse(content);
|
|
81133
81306
|
})
|
|
81134
81307
|
);
|
|
@@ -81138,10 +81311,10 @@ async function loadJsonFiles(dirPath) {
|
|
|
81138
81311
|
}
|
|
81139
81312
|
}
|
|
81140
81313
|
async function loadKnowledgeFiles(basePath) {
|
|
81141
|
-
const files = await glob2(
|
|
81314
|
+
const files = await glob2(join6(basePath, "**/*.md"));
|
|
81142
81315
|
const docs = [];
|
|
81143
81316
|
for (const filePath of files) {
|
|
81144
|
-
const content = await
|
|
81317
|
+
const content = await readFile7(filePath, "utf-8");
|
|
81145
81318
|
const { data: frontmatter, content: body } = matter(content);
|
|
81146
81319
|
const titleMatch = body.match(/^#\s+(.+)$/m);
|
|
81147
81320
|
const title = titleMatch?.[1] ?? filePath.split("/").pop()?.replace(".md", "") ?? "Untitled";
|
|
@@ -81328,16 +81501,16 @@ async function seed(ctx, options) {
|
|
|
81328
81501
|
await cleanQdrant();
|
|
81329
81502
|
}
|
|
81330
81503
|
log("\u{1F4E6} Seeding apps...");
|
|
81331
|
-
const apps = await loadJsonFiles(
|
|
81504
|
+
const apps = await loadJsonFiles(join7(fixturesPath, "apps"));
|
|
81332
81505
|
result.apps = await seedApps(connection, apps);
|
|
81333
81506
|
log("\u{1F465} Loading customer fixtures...");
|
|
81334
|
-
const customers = await loadJsonFiles(
|
|
81507
|
+
const customers = await loadJsonFiles(join7(fixturesPath, "customers"));
|
|
81335
81508
|
result.customers = customers.length;
|
|
81336
81509
|
log("\u{1F4DA} Seeding knowledge base...");
|
|
81337
|
-
const knowledge = await loadKnowledgeFiles(
|
|
81510
|
+
const knowledge = await loadKnowledgeFiles(join7(fixturesPath, "knowledge"));
|
|
81338
81511
|
result.knowledge = knowledge.length;
|
|
81339
81512
|
result.embeddings = await seedKnowledgeBase(knowledge, !outputJson);
|
|
81340
|
-
const scenarioFiles = await glob3(
|
|
81513
|
+
const scenarioFiles = await glob3(join7(fixturesPath, "scenarios/**/*.json"));
|
|
81341
81514
|
result.scenarios = scenarioFiles.length;
|
|
81342
81515
|
await connection.end();
|
|
81343
81516
|
if (outputJson) {
|
|
@@ -81413,9 +81586,9 @@ init_esm_shims();
|
|
|
81413
81586
|
// src/commands/eval-pipeline/run.ts
|
|
81414
81587
|
init_esm_shims();
|
|
81415
81588
|
import { createHash as createHash2 } from "crypto";
|
|
81416
|
-
import { existsSync as
|
|
81417
|
-
import { join as
|
|
81418
|
-
import { readFile as
|
|
81589
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync2, readFileSync as readFileSync7, rmSync, writeFileSync as writeFileSync4 } from "fs";
|
|
81590
|
+
import { join as join8 } from "path";
|
|
81591
|
+
import { readFile as readFile8 } from "fs/promises";
|
|
81419
81592
|
import { glob as glob4 } from "glob";
|
|
81420
81593
|
|
|
81421
81594
|
// src/commands/eval-pipeline/real-tools.ts
|
|
@@ -81827,11 +82000,11 @@ function getCacheKey(scenarioId, classifySourceHash) {
|
|
|
81827
82000
|
function getClassifySourceHash() {
|
|
81828
82001
|
try {
|
|
81829
82002
|
const possiblePaths = [
|
|
81830
|
-
|
|
81831
|
-
|
|
82003
|
+
join8(process.cwd(), "packages/core/src/pipeline/classify.ts"),
|
|
82004
|
+
join8(process.cwd(), "../core/src/pipeline/classify.ts")
|
|
81832
82005
|
];
|
|
81833
82006
|
for (const path3 of possiblePaths) {
|
|
81834
|
-
if (
|
|
82007
|
+
if (existsSync11(path3)) {
|
|
81835
82008
|
const content = readFileSync7(path3, "utf-8");
|
|
81836
82009
|
return createHash2("md5").update(content).digest("hex");
|
|
81837
82010
|
}
|
|
@@ -81841,9 +82014,9 @@ function getClassifySourceHash() {
|
|
|
81841
82014
|
return createHash2("md5").update(Math.floor(Date.now() / 3e5).toString()).digest("hex");
|
|
81842
82015
|
}
|
|
81843
82016
|
function loadCachedClassify(cacheKey) {
|
|
81844
|
-
const cachePath =
|
|
82017
|
+
const cachePath = join8(CACHE_DIR, `${cacheKey}.json`);
|
|
81845
82018
|
try {
|
|
81846
|
-
if (
|
|
82019
|
+
if (existsSync11(cachePath)) {
|
|
81847
82020
|
return JSON.parse(readFileSync7(cachePath, "utf-8"));
|
|
81848
82021
|
}
|
|
81849
82022
|
} catch {
|
|
@@ -81852,17 +82025,17 @@ function loadCachedClassify(cacheKey) {
|
|
|
81852
82025
|
}
|
|
81853
82026
|
function saveCachedClassify(cacheKey, result) {
|
|
81854
82027
|
try {
|
|
81855
|
-
if (!
|
|
82028
|
+
if (!existsSync11(CACHE_DIR)) {
|
|
81856
82029
|
mkdirSync2(CACHE_DIR, { recursive: true });
|
|
81857
82030
|
}
|
|
81858
|
-
const cachePath =
|
|
82031
|
+
const cachePath = join8(CACHE_DIR, `${cacheKey}.json`);
|
|
81859
82032
|
writeFileSync4(cachePath, JSON.stringify(result));
|
|
81860
82033
|
} catch {
|
|
81861
82034
|
}
|
|
81862
82035
|
}
|
|
81863
82036
|
function clearClassifyCache() {
|
|
81864
82037
|
try {
|
|
81865
|
-
if (
|
|
82038
|
+
if (existsSync11(CACHE_DIR)) {
|
|
81866
82039
|
rmSync(CACHE_DIR, { recursive: true, force: true });
|
|
81867
82040
|
}
|
|
81868
82041
|
} catch {
|
|
@@ -82001,7 +82174,7 @@ async function run2(ctx, options) {
|
|
|
82001
82174
|
}
|
|
82002
82175
|
async function loadScenarios(scenarioGlob, datasetPath) {
|
|
82003
82176
|
if (datasetPath) {
|
|
82004
|
-
const content = await
|
|
82177
|
+
const content = await readFile8(datasetPath, "utf-8");
|
|
82005
82178
|
const data2 = JSON.parse(content);
|
|
82006
82179
|
return data2.map((item) => ({
|
|
82007
82180
|
id: item.id || item.conversationId,
|
|
@@ -82025,7 +82198,7 @@ async function loadScenarios(scenarioGlob, datasetPath) {
|
|
|
82025
82198
|
}
|
|
82026
82199
|
return Promise.all(
|
|
82027
82200
|
files.map(async (file) => {
|
|
82028
|
-
const content = await
|
|
82201
|
+
const content = await readFile8(file, "utf-8");
|
|
82029
82202
|
return JSON.parse(content);
|
|
82030
82203
|
})
|
|
82031
82204
|
);
|
|
@@ -82738,7 +82911,7 @@ Latency: ${avgLatency.toFixed(0)}ms avg`);
|
|
|
82738
82911
|
|
|
82739
82912
|
// src/commands/eval-pipeline/seed.ts
|
|
82740
82913
|
init_esm_shims();
|
|
82741
|
-
import { join as
|
|
82914
|
+
import { join as join9 } from "path";
|
|
82742
82915
|
import { glob as glob5 } from "glob";
|
|
82743
82916
|
async function seed2(ctx, options) {
|
|
82744
82917
|
const fixturesPath = options.fixtures || "fixtures";
|
|
@@ -82769,20 +82942,20 @@ async function seed2(ctx, options) {
|
|
|
82769
82942
|
await cleanQdrant();
|
|
82770
82943
|
}
|
|
82771
82944
|
if (!outputJson) ctx.output.message("\u{1F4E6} Seeding apps...");
|
|
82772
|
-
const apps = await loadJsonFiles(
|
|
82945
|
+
const apps = await loadJsonFiles(join9(fixturesPath, "apps"));
|
|
82773
82946
|
result.apps = await seedApps(connection, apps);
|
|
82774
82947
|
const [trustRows] = await connection.execute(
|
|
82775
82948
|
"SELECT COUNT(*) as count FROM SUPPORT_trust_scores"
|
|
82776
82949
|
);
|
|
82777
82950
|
result.trustScores = trustRows[0].count;
|
|
82778
82951
|
if (!outputJson) ctx.output.message("\u{1F465} Loading customer fixtures...");
|
|
82779
|
-
const customers = await loadJsonFiles(
|
|
82952
|
+
const customers = await loadJsonFiles(join9(fixturesPath, "customers"));
|
|
82780
82953
|
result.customers = customers.length;
|
|
82781
82954
|
if (!outputJson) ctx.output.message("\u{1F4DA} Seeding knowledge base...");
|
|
82782
|
-
const knowledge = await loadKnowledgeFiles(
|
|
82955
|
+
const knowledge = await loadKnowledgeFiles(join9(fixturesPath, "knowledge"));
|
|
82783
82956
|
result.knowledge = knowledge.length;
|
|
82784
82957
|
result.embeddings = await seedKnowledgeBase(knowledge, !outputJson);
|
|
82785
|
-
const scenarioFiles = await glob5(
|
|
82958
|
+
const scenarioFiles = await glob5(join9(fixturesPath, "scenarios/**/*.json"));
|
|
82786
82959
|
result.scenarios = scenarioFiles.length;
|
|
82787
82960
|
await connection.end();
|
|
82788
82961
|
if (outputJson) {
|
|
@@ -82854,7 +83027,7 @@ function registerEvalPipelineCommands(program3) {
|
|
|
82854
83027
|
|
|
82855
83028
|
// src/commands/eval-prompt.ts
|
|
82856
83029
|
init_esm_shims();
|
|
82857
|
-
import { existsSync as
|
|
83030
|
+
import { existsSync as existsSync12, readFileSync as readFileSync8, writeFileSync as writeFileSync5 } from "fs";
|
|
82858
83031
|
import { generateText as generateText2, stepCountIs as stepCountIs2, tool as tool4 } from "ai";
|
|
82859
83032
|
import { z as z5 } from "zod";
|
|
82860
83033
|
var leakPatterns = [
|
|
@@ -83041,7 +83214,7 @@ async function runEval2(ctx, options) {
|
|
|
83041
83214
|
try {
|
|
83042
83215
|
let prompt = SUPPORT_AGENT_PROMPT;
|
|
83043
83216
|
if (promptPath) {
|
|
83044
|
-
if (!
|
|
83217
|
+
if (!existsSync12(promptPath)) {
|
|
83045
83218
|
throw new CLIError({
|
|
83046
83219
|
userMessage: `Prompt file not found: ${promptPath}.`,
|
|
83047
83220
|
suggestion: "Verify the prompt path and try again."
|
|
@@ -83054,7 +83227,7 @@ async function runEval2(ctx, options) {
|
|
|
83054
83227
|
} else if (!outputJson) {
|
|
83055
83228
|
ctx.output.message("Using production prompt");
|
|
83056
83229
|
}
|
|
83057
|
-
if (!
|
|
83230
|
+
if (!existsSync12(datasetPath)) {
|
|
83058
83231
|
throw new CLIError({
|
|
83059
83232
|
userMessage: `Dataset not found: ${datasetPath}.`,
|
|
83060
83233
|
suggestion: "Provide a valid dataset file path."
|
|
@@ -83166,7 +83339,7 @@ async function comparePrompts(ctx, options) {
|
|
|
83166
83339
|
try {
|
|
83167
83340
|
const baselinePrompt = baseline ? readFileSync8(baseline, "utf-8") : SUPPORT_AGENT_PROMPT;
|
|
83168
83341
|
const candidatePrompt = readFileSync8(candidate, "utf-8");
|
|
83169
|
-
if (!
|
|
83342
|
+
if (!existsSync12(datasetPath)) {
|
|
83170
83343
|
throw new CLIError({
|
|
83171
83344
|
userMessage: `Dataset not found: ${datasetPath}.`,
|
|
83172
83345
|
suggestion: "Provide a valid dataset file path."
|
|
@@ -83314,20 +83487,20 @@ init_esm_shims();
|
|
|
83314
83487
|
|
|
83315
83488
|
// src/commands/faq/classify.ts
|
|
83316
83489
|
init_esm_shims();
|
|
83317
|
-
import { appendFileSync, existsSync as
|
|
83318
|
-
import { dirname as
|
|
83490
|
+
import { appendFileSync, existsSync as existsSync13, mkdirSync as mkdirSync3, readFileSync as readFileSync9 } from "fs";
|
|
83491
|
+
import { dirname as dirname5, join as join10, resolve as resolve5 } from "path";
|
|
83319
83492
|
import { generateObject } from "ai";
|
|
83320
83493
|
import { z as z6 } from "zod";
|
|
83321
|
-
var PROJECT_ROOT =
|
|
83322
|
-
var DEFAULT_PARQUET_PATH =
|
|
83494
|
+
var PROJECT_ROOT = resolve5(__dirname, "../../../..");
|
|
83495
|
+
var DEFAULT_PARQUET_PATH = join10(
|
|
83323
83496
|
PROJECT_ROOT,
|
|
83324
83497
|
"artifacts/phase-0/embeddings/v2/conversations.parquet"
|
|
83325
83498
|
);
|
|
83326
|
-
var DEFAULT_TAXONOMY_PATH =
|
|
83499
|
+
var DEFAULT_TAXONOMY_PATH = join10(
|
|
83327
83500
|
PROJECT_ROOT,
|
|
83328
83501
|
"artifacts/phase-1/llm-topics/taxonomy.json"
|
|
83329
83502
|
);
|
|
83330
|
-
var DEFAULT_OUTPUT_PATH =
|
|
83503
|
+
var DEFAULT_OUTPUT_PATH = join10(
|
|
83331
83504
|
PROJECT_ROOT,
|
|
83332
83505
|
"artifacts/phase-1/llm-topics/classifications.jsonl"
|
|
83333
83506
|
);
|
|
@@ -83382,7 +83555,7 @@ async function loadConversationsFromParquet(parquetPath) {
|
|
|
83382
83555
|
}
|
|
83383
83556
|
function loadExistingClassifications(outputPath) {
|
|
83384
83557
|
const classifiedIds = /* @__PURE__ */ new Set();
|
|
83385
|
-
if (!
|
|
83558
|
+
if (!existsSync13(outputPath)) {
|
|
83386
83559
|
return classifiedIds;
|
|
83387
83560
|
}
|
|
83388
83561
|
const content = readFileSync9(outputPath, "utf-8");
|
|
@@ -83500,7 +83673,7 @@ async function faqClassify(ctx, options) {
|
|
|
83500
83673
|
ctx.output.data(` Dry run: ${options.dryRun ?? false}`);
|
|
83501
83674
|
ctx.output.data("");
|
|
83502
83675
|
}
|
|
83503
|
-
if (!
|
|
83676
|
+
if (!existsSync13(parquetPath)) {
|
|
83504
83677
|
handleFaqClassifyError(
|
|
83505
83678
|
ctx,
|
|
83506
83679
|
new CLIError({
|
|
@@ -83511,7 +83684,7 @@ async function faqClassify(ctx, options) {
|
|
|
83511
83684
|
);
|
|
83512
83685
|
return;
|
|
83513
83686
|
}
|
|
83514
|
-
if (!
|
|
83687
|
+
if (!existsSync13(taxonomyPath)) {
|
|
83515
83688
|
handleFaqClassifyError(
|
|
83516
83689
|
ctx,
|
|
83517
83690
|
new CLIError({
|
|
@@ -83522,8 +83695,8 @@ async function faqClassify(ctx, options) {
|
|
|
83522
83695
|
);
|
|
83523
83696
|
return;
|
|
83524
83697
|
}
|
|
83525
|
-
const outputDir =
|
|
83526
|
-
if (!
|
|
83698
|
+
const outputDir = dirname5(outputPath);
|
|
83699
|
+
if (!existsSync13(outputDir)) {
|
|
83527
83700
|
mkdirSync3(outputDir, { recursive: true });
|
|
83528
83701
|
}
|
|
83529
83702
|
if (!outputJson) ctx.output.data("\u{1F4DA} Loading taxonomy...");
|
|
@@ -83692,18 +83865,18 @@ function registerFaqClassifyCommands(program3) {
|
|
|
83692
83865
|
|
|
83693
83866
|
// src/commands/faq/cluster.ts
|
|
83694
83867
|
init_esm_shims();
|
|
83695
|
-
import { existsSync as
|
|
83696
|
-
import { join as
|
|
83868
|
+
import { existsSync as existsSync15 } from "fs";
|
|
83869
|
+
import { join as join12, resolve as resolve6 } from "path";
|
|
83697
83870
|
|
|
83698
83871
|
// ../core/src/faq/production-clusterer.ts
|
|
83699
83872
|
init_esm_shims();
|
|
83700
|
-
import { existsSync as
|
|
83701
|
-
import { join as
|
|
83873
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync4, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "fs";
|
|
83874
|
+
import { join as join11 } from "path";
|
|
83702
83875
|
function readPhase0Assignments(phase0Path) {
|
|
83703
|
-
const assignmentsPath =
|
|
83704
|
-
if (!
|
|
83705
|
-
const latestPath =
|
|
83706
|
-
if (!
|
|
83876
|
+
const assignmentsPath = join11(phase0Path, "clusters/v1/assignments.json");
|
|
83877
|
+
if (!existsSync14(assignmentsPath)) {
|
|
83878
|
+
const latestPath = join11(phase0Path, "clusters/latest/assignments.json");
|
|
83879
|
+
if (!existsSync14(latestPath)) {
|
|
83707
83880
|
throw new Error(`Phase 0 assignments not found at ${assignmentsPath}`);
|
|
83708
83881
|
}
|
|
83709
83882
|
const content2 = readFileSync10(latestPath, "utf-8");
|
|
@@ -83713,10 +83886,10 @@ function readPhase0Assignments(phase0Path) {
|
|
|
83713
83886
|
return JSON.parse(content);
|
|
83714
83887
|
}
|
|
83715
83888
|
function readPhase0Labels(phase0Path) {
|
|
83716
|
-
const labelsPath =
|
|
83717
|
-
if (!
|
|
83718
|
-
const latestPath =
|
|
83719
|
-
if (!
|
|
83889
|
+
const labelsPath = join11(phase0Path, "clusters/v1/labels.json");
|
|
83890
|
+
if (!existsSync14(labelsPath)) {
|
|
83891
|
+
const latestPath = join11(phase0Path, "clusters/latest/labels.json");
|
|
83892
|
+
if (!existsSync14(latestPath)) {
|
|
83720
83893
|
throw new Error(`Phase 0 labels not found at ${labelsPath}`);
|
|
83721
83894
|
}
|
|
83722
83895
|
const content2 = readFileSync10(latestPath, "utf-8");
|
|
@@ -83728,10 +83901,10 @@ function readPhase0Labels(phase0Path) {
|
|
|
83728
83901
|
return parsed.clusters || [];
|
|
83729
83902
|
}
|
|
83730
83903
|
function readPhase0Metrics(phase0Path) {
|
|
83731
|
-
const metricsPath =
|
|
83732
|
-
if (!
|
|
83733
|
-
const latestPath =
|
|
83734
|
-
if (!
|
|
83904
|
+
const metricsPath = join11(phase0Path, "clusters/v1/metrics.json");
|
|
83905
|
+
if (!existsSync14(metricsPath)) {
|
|
83906
|
+
const latestPath = join11(phase0Path, "clusters/latest/metrics.json");
|
|
83907
|
+
if (!existsSync14(latestPath)) {
|
|
83735
83908
|
throw new Error(`Phase 0 metrics not found at ${metricsPath}`);
|
|
83736
83909
|
}
|
|
83737
83910
|
return JSON.parse(readFileSync10(latestPath, "utf-8"));
|
|
@@ -83851,17 +84024,17 @@ async function generateProductionClustering(options) {
|
|
|
83851
84024
|
return result;
|
|
83852
84025
|
}
|
|
83853
84026
|
function writeProductionArtifacts(result, outputPath) {
|
|
83854
|
-
const versionPath =
|
|
83855
|
-
if (!
|
|
84027
|
+
const versionPath = join11(outputPath, result.version);
|
|
84028
|
+
if (!existsSync14(versionPath)) {
|
|
83856
84029
|
mkdirSync4(versionPath, { recursive: true });
|
|
83857
84030
|
}
|
|
83858
|
-
const resultPath =
|
|
84031
|
+
const resultPath = join11(versionPath, "clustering-result.json");
|
|
83859
84032
|
writeFileSync6(resultPath, JSON.stringify(result, null, 2));
|
|
83860
84033
|
console.log(`\u2705 Written: ${resultPath}`);
|
|
83861
|
-
const assignmentsPath =
|
|
84034
|
+
const assignmentsPath = join11(versionPath, "assignments.json");
|
|
83862
84035
|
writeFileSync6(assignmentsPath, JSON.stringify(result.assignments, null, 2));
|
|
83863
84036
|
console.log(`\u2705 Written: ${assignmentsPath}`);
|
|
83864
|
-
const clustersPath =
|
|
84037
|
+
const clustersPath = join11(versionPath, "clusters.json");
|
|
83865
84038
|
writeFileSync6(
|
|
83866
84039
|
clustersPath,
|
|
83867
84040
|
JSON.stringify(
|
|
@@ -83876,7 +84049,7 @@ function writeProductionArtifacts(result, outputPath) {
|
|
|
83876
84049
|
)
|
|
83877
84050
|
);
|
|
83878
84051
|
console.log(`\u2705 Written: ${clustersPath}`);
|
|
83879
|
-
const summaryPath =
|
|
84052
|
+
const summaryPath = join11(versionPath, "summary.json");
|
|
83880
84053
|
const summary = {
|
|
83881
84054
|
version: result.version,
|
|
83882
84055
|
generatedAt: result.generatedAt,
|
|
@@ -83890,8 +84063,8 @@ function writeProductionArtifacts(result, outputPath) {
|
|
|
83890
84063
|
};
|
|
83891
84064
|
writeFileSync6(summaryPath, JSON.stringify(summary, null, 2));
|
|
83892
84065
|
console.log(`\u2705 Written: ${summaryPath}`);
|
|
83893
|
-
const latestPath =
|
|
83894
|
-
if (
|
|
84066
|
+
const latestPath = join11(outputPath, "latest");
|
|
84067
|
+
if (existsSync14(latestPath)) {
|
|
83895
84068
|
const { rmSync: rmSync2 } = __require("fs");
|
|
83896
84069
|
rmSync2(latestPath, { recursive: true, force: true });
|
|
83897
84070
|
}
|
|
@@ -83902,8 +84075,8 @@ function writeProductionArtifacts(result, outputPath) {
|
|
|
83902
84075
|
"clusters.json",
|
|
83903
84076
|
"summary.json"
|
|
83904
84077
|
]) {
|
|
83905
|
-
const src =
|
|
83906
|
-
const dst =
|
|
84078
|
+
const src = join11(versionPath, file);
|
|
84079
|
+
const dst = join11(latestPath, file);
|
|
83907
84080
|
writeFileSync6(dst, readFileSync10(src));
|
|
83908
84081
|
}
|
|
83909
84082
|
console.log(`\u2705 Updated: ${latestPath}`);
|
|
@@ -83955,26 +84128,26 @@ function displayClusteringSummary(result) {
|
|
|
83955
84128
|
}
|
|
83956
84129
|
|
|
83957
84130
|
// src/commands/faq/cluster.ts
|
|
83958
|
-
var PROJECT_ROOT2 =
|
|
83959
|
-
var DEFAULT_PHASE0_PATH =
|
|
83960
|
-
var DEFAULT_OUTPUT_PATH2 =
|
|
84131
|
+
var PROJECT_ROOT2 = resolve6(__dirname, "../../../..");
|
|
84132
|
+
var DEFAULT_PHASE0_PATH = join12(PROJECT_ROOT2, "artifacts/phase-0");
|
|
84133
|
+
var DEFAULT_OUTPUT_PATH2 = join12(PROJECT_ROOT2, "artifacts/phase-1/clustering");
|
|
83961
84134
|
function validatePaths(phase0Path) {
|
|
83962
|
-
const assignmentsPath =
|
|
83963
|
-
const labelsPath =
|
|
83964
|
-
const metricsPath =
|
|
83965
|
-
if (!
|
|
84135
|
+
const assignmentsPath = join12(phase0Path, "clusters/v1/assignments.json");
|
|
84136
|
+
const labelsPath = join12(phase0Path, "clusters/v1/labels.json");
|
|
84137
|
+
const metricsPath = join12(phase0Path, "clusters/v1/metrics.json");
|
|
84138
|
+
if (!existsSync15(assignmentsPath)) {
|
|
83966
84139
|
throw new CLIError({
|
|
83967
84140
|
userMessage: `Phase 0 assignments not found at ${assignmentsPath}.`,
|
|
83968
84141
|
suggestion: "Run Phase 0 clustering first or specify the correct --phase0-path."
|
|
83969
84142
|
});
|
|
83970
84143
|
}
|
|
83971
|
-
if (!
|
|
84144
|
+
if (!existsSync15(labelsPath)) {
|
|
83972
84145
|
throw new CLIError({
|
|
83973
84146
|
userMessage: `Phase 0 labels not found at ${labelsPath}.`,
|
|
83974
84147
|
suggestion: "Verify the --phase0-path points to valid artifacts."
|
|
83975
84148
|
});
|
|
83976
84149
|
}
|
|
83977
|
-
if (!
|
|
84150
|
+
if (!existsSync15(metricsPath)) {
|
|
83978
84151
|
throw new CLIError({
|
|
83979
84152
|
userMessage: `Phase 0 metrics not found at ${metricsPath}.`,
|
|
83980
84153
|
suggestion: "Verify the --phase0-path points to valid artifacts."
|
|
@@ -84012,7 +84185,7 @@ async function faqCluster(ctx, options) {
|
|
|
84012
84185
|
writeProductionArtifacts(result, outputPath);
|
|
84013
84186
|
if (!outputJson) {
|
|
84014
84187
|
ctx.output.data("\n\u2705 Production clustering complete!");
|
|
84015
|
-
ctx.output.data(` Artifacts written to: ${
|
|
84188
|
+
ctx.output.data(` Artifacts written to: ${join12(outputPath, version)}`);
|
|
84016
84189
|
}
|
|
84017
84190
|
} else {
|
|
84018
84191
|
if (!outputJson) ctx.output.data("\n\u{1F9EA} Dry run - no artifacts written");
|
|
@@ -84055,13 +84228,13 @@ function registerFaqClusterCommands(program3) {
|
|
|
84055
84228
|
|
|
84056
84229
|
// src/commands/faq/extract.ts
|
|
84057
84230
|
init_esm_shims();
|
|
84058
|
-
import { existsSync as
|
|
84059
|
-
import { join as
|
|
84231
|
+
import { existsSync as existsSync17 } from "fs";
|
|
84232
|
+
import { join as join14, resolve as resolve7 } from "path";
|
|
84060
84233
|
|
|
84061
84234
|
// ../core/src/faq/extractor.ts
|
|
84062
84235
|
init_esm_shims();
|
|
84063
|
-
import { existsSync as
|
|
84064
|
-
import { join as
|
|
84236
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync5, readFileSync as readFileSync11, writeFileSync as writeFileSync7 } from "fs";
|
|
84237
|
+
import { join as join13 } from "path";
|
|
84065
84238
|
|
|
84066
84239
|
// ../core/src/faq/review.ts
|
|
84067
84240
|
init_esm_shims();
|
|
@@ -84675,14 +84848,14 @@ async function extractFaqCandidates(options) {
|
|
|
84675
84848
|
return result;
|
|
84676
84849
|
}
|
|
84677
84850
|
function writeExtractionArtifacts(result, outputPath) {
|
|
84678
|
-
const versionPath =
|
|
84679
|
-
if (!
|
|
84851
|
+
const versionPath = join13(outputPath, result.version);
|
|
84852
|
+
if (!existsSync16(versionPath)) {
|
|
84680
84853
|
mkdirSync5(versionPath, { recursive: true });
|
|
84681
84854
|
}
|
|
84682
|
-
const resultPath =
|
|
84855
|
+
const resultPath = join13(versionPath, "extraction-result.json");
|
|
84683
84856
|
writeFileSync7(resultPath, JSON.stringify(result, null, 2));
|
|
84684
84857
|
console.log(`\u2705 Written: ${resultPath}`);
|
|
84685
|
-
const candidatesPath =
|
|
84858
|
+
const candidatesPath = join13(versionPath, "candidates.json");
|
|
84686
84859
|
const candidatesData = {
|
|
84687
84860
|
version: result.version,
|
|
84688
84861
|
extractedAt: result.extractedAt,
|
|
@@ -84702,7 +84875,7 @@ function writeExtractionArtifacts(result, outputPath) {
|
|
|
84702
84875
|
};
|
|
84703
84876
|
writeFileSync7(candidatesPath, JSON.stringify(candidatesData, null, 2));
|
|
84704
84877
|
console.log(`\u2705 Written: ${candidatesPath}`);
|
|
84705
|
-
const statsPath =
|
|
84878
|
+
const statsPath = join13(versionPath, "stats.json");
|
|
84706
84879
|
writeFileSync7(
|
|
84707
84880
|
statsPath,
|
|
84708
84881
|
JSON.stringify(
|
|
@@ -84716,8 +84889,8 @@ function writeExtractionArtifacts(result, outputPath) {
|
|
|
84716
84889
|
)
|
|
84717
84890
|
);
|
|
84718
84891
|
console.log(`\u2705 Written: ${statsPath}`);
|
|
84719
|
-
const latestPath =
|
|
84720
|
-
if (
|
|
84892
|
+
const latestPath = join13(outputPath, "latest");
|
|
84893
|
+
if (existsSync16(latestPath)) {
|
|
84721
84894
|
const { rmSync: rmSync2 } = __require("fs");
|
|
84722
84895
|
rmSync2(latestPath, { recursive: true, force: true });
|
|
84723
84896
|
}
|
|
@@ -84727,9 +84900,9 @@ function writeExtractionArtifacts(result, outputPath) {
|
|
|
84727
84900
|
"candidates.json",
|
|
84728
84901
|
"stats.json"
|
|
84729
84902
|
]) {
|
|
84730
|
-
const src =
|
|
84731
|
-
const dst =
|
|
84732
|
-
if (
|
|
84903
|
+
const src = join13(versionPath, file);
|
|
84904
|
+
const dst = join13(latestPath, file);
|
|
84905
|
+
if (existsSync16(src)) {
|
|
84733
84906
|
writeFileSync7(dst, readFileSync11(src));
|
|
84734
84907
|
}
|
|
84735
84908
|
}
|
|
@@ -84782,25 +84955,25 @@ ${i + 1}. [${confPct}%]${golden} ${candidate.suggestedCategory}`
|
|
|
84782
84955
|
}
|
|
84783
84956
|
|
|
84784
84957
|
// src/commands/faq/extract.ts
|
|
84785
|
-
var PROJECT_ROOT3 =
|
|
84786
|
-
var DEFAULT_CLUSTERING_PATH =
|
|
84958
|
+
var PROJECT_ROOT3 = resolve7(__dirname, "../../../..");
|
|
84959
|
+
var DEFAULT_CLUSTERING_PATH = join14(
|
|
84787
84960
|
PROJECT_ROOT3,
|
|
84788
84961
|
"artifacts/phase-1/clustering/v1/clustering-result.json"
|
|
84789
84962
|
);
|
|
84790
|
-
var DEFAULT_GOLDEN_PATH =
|
|
84963
|
+
var DEFAULT_GOLDEN_PATH = join14(
|
|
84791
84964
|
PROJECT_ROOT3,
|
|
84792
84965
|
"artifacts/phase-0/golden/latest/responses.json"
|
|
84793
84966
|
);
|
|
84794
|
-
var DEFAULT_OUTPUT_PATH3 =
|
|
84967
|
+
var DEFAULT_OUTPUT_PATH3 = join14(PROJECT_ROOT3, "artifacts/phase-1/extraction");
|
|
84795
84968
|
var DEFAULT_CACHE_PATH = `${process.env.HOME}/skill/data/front-cache.db`;
|
|
84796
84969
|
function validatePaths2(ctx, clusteringPath, goldenPath, outputJson) {
|
|
84797
|
-
if (!
|
|
84970
|
+
if (!existsSync17(clusteringPath)) {
|
|
84798
84971
|
throw new CLIError({
|
|
84799
84972
|
userMessage: `Clustering result not found at ${clusteringPath}.`,
|
|
84800
84973
|
suggestion: "Run `bun src/index.ts faq cluster` first to generate clustering."
|
|
84801
84974
|
});
|
|
84802
84975
|
}
|
|
84803
|
-
if (goldenPath && !
|
|
84976
|
+
if (goldenPath && !existsSync17(goldenPath)) {
|
|
84804
84977
|
if (!outputJson) {
|
|
84805
84978
|
ctx.output.warn(`Golden responses not found at ${goldenPath}`);
|
|
84806
84979
|
ctx.output.warn("Golden matching will be disabled.");
|
|
@@ -84829,7 +85002,7 @@ async function faqExtract(ctx, options) {
|
|
|
84829
85002
|
ctx.output.data("");
|
|
84830
85003
|
}
|
|
84831
85004
|
validatePaths2(ctx, clusteringPath, goldenPath, outputJson);
|
|
84832
|
-
if (!
|
|
85005
|
+
if (!existsSync17(cachePath)) {
|
|
84833
85006
|
const cliError = new CLIError({
|
|
84834
85007
|
userMessage: `DuckDB cache not found at ${cachePath}.`,
|
|
84835
85008
|
suggestion: "Run `bun src/index.ts front-cache sync` first to populate cache."
|
|
@@ -84851,7 +85024,7 @@ async function faqExtract(ctx, options) {
|
|
|
84851
85024
|
}
|
|
84852
85025
|
const extractionOptions = {
|
|
84853
85026
|
clusteringPath,
|
|
84854
|
-
goldenPath:
|
|
85027
|
+
goldenPath: existsSync17(goldenPath) ? goldenPath : void 0,
|
|
84855
85028
|
source,
|
|
84856
85029
|
outputPath,
|
|
84857
85030
|
version,
|
|
@@ -84896,7 +85069,7 @@ async function faqExtract(ctx, options) {
|
|
|
84896
85069
|
if (!options.dryRun) {
|
|
84897
85070
|
ctx.output.data(`
|
|
84898
85071
|
\u2705 Extraction complete!`);
|
|
84899
|
-
ctx.output.data(` Artifacts written to: ${
|
|
85072
|
+
ctx.output.data(` Artifacts written to: ${join14(outputPath, version)}`);
|
|
84900
85073
|
if (options.pushRedis && options.app) {
|
|
84901
85074
|
ctx.output.data(
|
|
84902
85075
|
` Candidates pushed to Redis queue: faq:pending:${options.app}`
|
|
@@ -85716,7 +85889,7 @@ function consumeBody() {
|
|
|
85716
85889
|
let accum = [];
|
|
85717
85890
|
let accumBytes = 0;
|
|
85718
85891
|
let abort = false;
|
|
85719
|
-
return new Body.Promise(function(
|
|
85892
|
+
return new Body.Promise(function(resolve11, reject) {
|
|
85720
85893
|
let resTimeout;
|
|
85721
85894
|
if (_this4.timeout) {
|
|
85722
85895
|
resTimeout = setTimeout(function() {
|
|
@@ -85750,7 +85923,7 @@ function consumeBody() {
|
|
|
85750
85923
|
}
|
|
85751
85924
|
clearTimeout(resTimeout);
|
|
85752
85925
|
try {
|
|
85753
|
-
|
|
85926
|
+
resolve11(Buffer.concat(accum, accumBytes));
|
|
85754
85927
|
} catch (err) {
|
|
85755
85928
|
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
|
|
85756
85929
|
}
|
|
@@ -86425,7 +86598,7 @@ function fetch3(url, opts) {
|
|
|
86425
86598
|
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
86426
86599
|
}
|
|
86427
86600
|
Body.Promise = fetch3.Promise;
|
|
86428
|
-
return new fetch3.Promise(function(
|
|
86601
|
+
return new fetch3.Promise(function(resolve11, reject) {
|
|
86429
86602
|
const request = new Request2(url, opts);
|
|
86430
86603
|
const options = getNodeRequestOptions(request);
|
|
86431
86604
|
const send = (options.protocol === "https:" ? https : http).request;
|
|
@@ -86558,7 +86731,7 @@ function fetch3(url, opts) {
|
|
|
86558
86731
|
requestOpts.body = void 0;
|
|
86559
86732
|
requestOpts.headers.delete("content-length");
|
|
86560
86733
|
}
|
|
86561
|
-
|
|
86734
|
+
resolve11(fetch3(new Request2(locationURL, requestOpts)));
|
|
86562
86735
|
finalize();
|
|
86563
86736
|
return;
|
|
86564
86737
|
}
|
|
@@ -86579,7 +86752,7 @@ function fetch3(url, opts) {
|
|
|
86579
86752
|
const codings = headers.get("Content-Encoding");
|
|
86580
86753
|
if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
86581
86754
|
response = new Response2(body, response_options);
|
|
86582
|
-
|
|
86755
|
+
resolve11(response);
|
|
86583
86756
|
return;
|
|
86584
86757
|
}
|
|
86585
86758
|
const zlibOptions = {
|
|
@@ -86589,7 +86762,7 @@ function fetch3(url, opts) {
|
|
|
86589
86762
|
if (codings == "gzip" || codings == "x-gzip") {
|
|
86590
86763
|
body = body.pipe(zlib.createGunzip(zlibOptions));
|
|
86591
86764
|
response = new Response2(body, response_options);
|
|
86592
|
-
|
|
86765
|
+
resolve11(response);
|
|
86593
86766
|
return;
|
|
86594
86767
|
}
|
|
86595
86768
|
if (codings == "deflate" || codings == "x-deflate") {
|
|
@@ -86601,12 +86774,12 @@ function fetch3(url, opts) {
|
|
|
86601
86774
|
body = body.pipe(zlib.createInflateRaw());
|
|
86602
86775
|
}
|
|
86603
86776
|
response = new Response2(body, response_options);
|
|
86604
|
-
|
|
86777
|
+
resolve11(response);
|
|
86605
86778
|
});
|
|
86606
86779
|
raw.on("end", function() {
|
|
86607
86780
|
if (!response) {
|
|
86608
86781
|
response = new Response2(body, response_options);
|
|
86609
|
-
|
|
86782
|
+
resolve11(response);
|
|
86610
86783
|
}
|
|
86611
86784
|
});
|
|
86612
86785
|
return;
|
|
@@ -86614,11 +86787,11 @@ function fetch3(url, opts) {
|
|
|
86614
86787
|
if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
|
|
86615
86788
|
body = body.pipe(zlib.createBrotliDecompress());
|
|
86616
86789
|
response = new Response2(body, response_options);
|
|
86617
|
-
|
|
86790
|
+
resolve11(response);
|
|
86618
86791
|
return;
|
|
86619
86792
|
}
|
|
86620
86793
|
response = new Response2(body, response_options);
|
|
86621
|
-
|
|
86794
|
+
resolve11(response);
|
|
86622
86795
|
});
|
|
86623
86796
|
writeToStream(req, request);
|
|
86624
86797
|
});
|
|
@@ -87700,8 +87873,8 @@ function _addRequestID(value, response) {
|
|
|
87700
87873
|
}
|
|
87701
87874
|
var APIPromise = class _APIPromise extends Promise {
|
|
87702
87875
|
constructor(responsePromise, parseResponse2 = defaultParseResponse) {
|
|
87703
|
-
super((
|
|
87704
|
-
|
|
87876
|
+
super((resolve11) => {
|
|
87877
|
+
resolve11(null);
|
|
87705
87878
|
});
|
|
87706
87879
|
this.responsePromise = responsePromise;
|
|
87707
87880
|
this.parseResponse = parseResponse2;
|
|
@@ -88276,7 +88449,7 @@ var startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
|
88276
88449
|
var isAbsoluteURL = (url) => {
|
|
88277
88450
|
return startsWithSchemeRegexp.test(url);
|
|
88278
88451
|
};
|
|
88279
|
-
var sleep = (ms) => new Promise((
|
|
88452
|
+
var sleep = (ms) => new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
88280
88453
|
var validatePositiveInteger = (name, n) => {
|
|
88281
88454
|
if (typeof n !== "number" || !Number.isInteger(n)) {
|
|
88282
88455
|
throw new OpenAIError(`${name} must be an integer`);
|
|
@@ -88741,12 +88914,12 @@ var EventStream = class {
|
|
|
88741
88914
|
_EventStream_errored.set(this, false);
|
|
88742
88915
|
_EventStream_aborted.set(this, false);
|
|
88743
88916
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
88744
|
-
__classPrivateFieldSet4(this, _EventStream_connectedPromise, new Promise((
|
|
88745
|
-
__classPrivateFieldSet4(this, _EventStream_resolveConnectedPromise,
|
|
88917
|
+
__classPrivateFieldSet4(this, _EventStream_connectedPromise, new Promise((resolve11, reject) => {
|
|
88918
|
+
__classPrivateFieldSet4(this, _EventStream_resolveConnectedPromise, resolve11, "f");
|
|
88746
88919
|
__classPrivateFieldSet4(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
88747
88920
|
}), "f");
|
|
88748
|
-
__classPrivateFieldSet4(this, _EventStream_endPromise, new Promise((
|
|
88749
|
-
__classPrivateFieldSet4(this, _EventStream_resolveEndPromise,
|
|
88921
|
+
__classPrivateFieldSet4(this, _EventStream_endPromise, new Promise((resolve11, reject) => {
|
|
88922
|
+
__classPrivateFieldSet4(this, _EventStream_resolveEndPromise, resolve11, "f");
|
|
88750
88923
|
__classPrivateFieldSet4(this, _EventStream_rejectEndPromise, reject, "f");
|
|
88751
88924
|
}), "f");
|
|
88752
88925
|
__classPrivateFieldGet5(this, _EventStream_connectedPromise, "f").catch(() => {
|
|
@@ -88830,11 +89003,11 @@ var EventStream = class {
|
|
|
88830
89003
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
88831
89004
|
*/
|
|
88832
89005
|
emitted(event) {
|
|
88833
|
-
return new Promise((
|
|
89006
|
+
return new Promise((resolve11, reject) => {
|
|
88834
89007
|
__classPrivateFieldSet4(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
88835
89008
|
if (event !== "error")
|
|
88836
89009
|
this.once("error", reject);
|
|
88837
|
-
this.once(event,
|
|
89010
|
+
this.once(event, resolve11);
|
|
88838
89011
|
});
|
|
88839
89012
|
}
|
|
88840
89013
|
async done() {
|
|
@@ -88987,7 +89160,7 @@ var AssistantStream = class _AssistantStream extends EventStream {
|
|
|
88987
89160
|
if (done) {
|
|
88988
89161
|
return { value: void 0, done: true };
|
|
88989
89162
|
}
|
|
88990
|
-
return new Promise((
|
|
89163
|
+
return new Promise((resolve11, reject) => readQueue.push({ resolve: resolve11, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
88991
89164
|
}
|
|
88992
89165
|
const chunk = pushQueue.shift();
|
|
88993
89166
|
return { value: chunk, done: false };
|
|
@@ -90627,7 +90800,7 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
|
|
|
90627
90800
|
if (done) {
|
|
90628
90801
|
return { value: void 0, done: true };
|
|
90629
90802
|
}
|
|
90630
|
-
return new Promise((
|
|
90803
|
+
return new Promise((resolve11, reject) => readQueue.push({ resolve: resolve11, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
90631
90804
|
}
|
|
90632
90805
|
const chunk = pushQueue.shift();
|
|
90633
90806
|
return { value: chunk, done: false };
|
|
@@ -92337,7 +92510,7 @@ var ResponseStream = class _ResponseStream extends EventStream {
|
|
|
92337
92510
|
if (done) {
|
|
92338
92511
|
return { value: void 0, done: true };
|
|
92339
92512
|
}
|
|
92340
|
-
return new Promise((
|
|
92513
|
+
return new Promise((resolve11, reject) => readQueue.push({ resolve: resolve11, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
|
|
92341
92514
|
}
|
|
92342
92515
|
const event = pushQueue.shift();
|
|
92343
92516
|
return { value: event, done: false };
|
|
@@ -93925,9 +94098,9 @@ function registerFaqMineCommands(program3) {
|
|
|
93925
94098
|
// src/commands/faq/review.ts
|
|
93926
94099
|
init_esm_shims();
|
|
93927
94100
|
import { spawnSync } from "child_process";
|
|
93928
|
-
import { existsSync as
|
|
94101
|
+
import { existsSync as existsSync18, readFileSync as readFileSync12, unlinkSync, writeFileSync as writeFileSync9 } from "fs";
|
|
93929
94102
|
import { tmpdir } from "os";
|
|
93930
|
-
import { join as
|
|
94103
|
+
import { join as join15 } from "path";
|
|
93931
94104
|
import { confirm as confirm2, select as select2 } from "@inquirer/prompts";
|
|
93932
94105
|
var COLORS2 = {
|
|
93933
94106
|
reset: "\x1B[0m",
|
|
@@ -93988,7 +94161,7 @@ function getEditor() {
|
|
|
93988
94161
|
}
|
|
93989
94162
|
function editInEditor(ctx, question, answer) {
|
|
93990
94163
|
const editor = getEditor();
|
|
93991
|
-
const tmpFile =
|
|
94164
|
+
const tmpFile = join15(tmpdir(), `faq-edit-${Date.now()}.md`);
|
|
93992
94165
|
const content = `# FAQ Edit
|
|
93993
94166
|
|
|
93994
94167
|
## Question
|
|
@@ -94031,7 +94204,7 @@ The sections are separated by "## Question" and "## Answer" headers.
|
|
|
94031
94204
|
answer: editedAnswer
|
|
94032
94205
|
};
|
|
94033
94206
|
} finally {
|
|
94034
|
-
if (
|
|
94207
|
+
if (existsSync18(tmpFile)) {
|
|
94035
94208
|
unlinkSync(tmpFile);
|
|
94036
94209
|
}
|
|
94037
94210
|
}
|
|
@@ -94552,8 +94725,8 @@ var FrontRateLimiter = class {
|
|
|
94552
94725
|
)
|
|
94553
94726
|
);
|
|
94554
94727
|
}
|
|
94555
|
-
return new Promise((
|
|
94556
|
-
const item = { resolve:
|
|
94728
|
+
return new Promise((resolve11, reject) => {
|
|
94729
|
+
const item = { resolve: resolve11, reject, signal };
|
|
94557
94730
|
if (signal) {
|
|
94558
94731
|
const onAbort = () => {
|
|
94559
94732
|
this.removeFromQueue(item);
|
|
@@ -94614,9 +94787,9 @@ var FrontRateLimiter = class {
|
|
|
94614
94787
|
return 0;
|
|
94615
94788
|
}
|
|
94616
94789
|
sleep(ms, signal) {
|
|
94617
|
-
return new Promise((
|
|
94790
|
+
return new Promise((resolve11, reject) => {
|
|
94618
94791
|
if (ms <= 0) {
|
|
94619
|
-
|
|
94792
|
+
resolve11();
|
|
94620
94793
|
return;
|
|
94621
94794
|
}
|
|
94622
94795
|
let settled = false;
|
|
@@ -94624,7 +94797,7 @@ var FrontRateLimiter = class {
|
|
|
94624
94797
|
if (settled) return;
|
|
94625
94798
|
settled = true;
|
|
94626
94799
|
if (signal) signal.removeEventListener("abort", onAbort);
|
|
94627
|
-
|
|
94800
|
+
resolve11();
|
|
94628
94801
|
};
|
|
94629
94802
|
const onAbort = () => {
|
|
94630
94803
|
if (settled) return;
|
|
@@ -96735,7 +96908,7 @@ function truncate2(str2, len) {
|
|
|
96735
96908
|
return str2.slice(0, len - 3) + "...";
|
|
96736
96909
|
}
|
|
96737
96910
|
function sleep2(ms) {
|
|
96738
|
-
return new Promise((
|
|
96911
|
+
return new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
96739
96912
|
}
|
|
96740
96913
|
async function getConversationCount(front, tagId) {
|
|
96741
96914
|
try {
|
|
@@ -98220,10 +98393,10 @@ async function promptForName(ctx) {
|
|
|
98220
98393
|
input: ctx.stdin,
|
|
98221
98394
|
output: ctx.stdout
|
|
98222
98395
|
});
|
|
98223
|
-
return new Promise((
|
|
98396
|
+
return new Promise((resolve11) => {
|
|
98224
98397
|
rl.question("App name: ", (answer) => {
|
|
98225
98398
|
rl.close();
|
|
98226
|
-
|
|
98399
|
+
resolve11(answer.trim() || "my-app");
|
|
98227
98400
|
});
|
|
98228
98401
|
});
|
|
98229
98402
|
}
|
|
@@ -115358,7 +115531,7 @@ function registerKbCommands(program3) {
|
|
|
115358
115531
|
|
|
115359
115532
|
// src/commands/keys/index.ts
|
|
115360
115533
|
init_esm_shims();
|
|
115361
|
-
import { existsSync as
|
|
115534
|
+
import { existsSync as existsSync19, readFileSync as readFileSync14 } from "fs";
|
|
115362
115535
|
import { password as password2, select as select4 } from "@inquirer/prompts";
|
|
115363
115536
|
import { Decrypter as Decrypter4 } from "age-encryption";
|
|
115364
115537
|
var buildContext4 = async (command, json) => {
|
|
@@ -115375,7 +115548,7 @@ var buildContext4 = async (command, json) => {
|
|
|
115375
115548
|
async function getUserConfiguredKeys() {
|
|
115376
115549
|
const keyPath = getAgeKeyPath2();
|
|
115377
115550
|
const configPath = getEncryptedConfigPath();
|
|
115378
|
-
if (!
|
|
115551
|
+
if (!existsSync19(keyPath) || !existsSync19(configPath)) {
|
|
115379
115552
|
return /* @__PURE__ */ new Set();
|
|
115380
115553
|
}
|
|
115381
115554
|
try {
|
|
@@ -115443,7 +115616,7 @@ async function showKeyStatus(ctx) {
|
|
|
115443
115616
|
}
|
|
115444
115617
|
async function interactiveKeySetup(ctx) {
|
|
115445
115618
|
const keyPath = getAgeKeyPath2();
|
|
115446
|
-
if (!
|
|
115619
|
+
if (!existsSync19(keyPath)) {
|
|
115447
115620
|
ctx.output.data("\n\u{1F511} First time setup - creating your encryption key...\n");
|
|
115448
115621
|
await configInitAction(ctx, { json: false });
|
|
115449
115622
|
ctx.output.data("");
|
|
@@ -115536,7 +115709,7 @@ function registerKeysCommands(program3) {
|
|
|
115536
115709
|
).option("--json", "Output as JSON").action(async (keyValue, options, command) => {
|
|
115537
115710
|
const ctx = await buildContext4(command, options.json);
|
|
115538
115711
|
const keyPath = getAgeKeyPath2();
|
|
115539
|
-
if (!
|
|
115712
|
+
if (!existsSync19(keyPath)) {
|
|
115540
115713
|
if (process.stdin.isTTY && !options.json) {
|
|
115541
115714
|
ctx.output.data(
|
|
115542
115715
|
"\u{1F511} First time setup - creating your encryption key...\n"
|
|
@@ -118276,21 +118449,21 @@ Examples:
|
|
|
118276
118449
|
|
|
118277
118450
|
// src/commands/list.ts
|
|
118278
118451
|
init_esm_shims();
|
|
118279
|
-
import { existsSync as
|
|
118280
|
-
import { dirname as
|
|
118452
|
+
import { existsSync as existsSync20, readFileSync as readFileSync15, readdirSync as readdirSync2, statSync } from "fs";
|
|
118453
|
+
import { dirname as dirname6, join as join16 } from "path";
|
|
118281
118454
|
function discoverSkills(skillsDir) {
|
|
118282
|
-
if (!
|
|
118455
|
+
if (!existsSync20(skillsDir)) {
|
|
118283
118456
|
return [];
|
|
118284
118457
|
}
|
|
118285
118458
|
const skills = [];
|
|
118286
118459
|
try {
|
|
118287
118460
|
const entries = readdirSync2(skillsDir);
|
|
118288
118461
|
for (const entry of entries) {
|
|
118289
|
-
const entryPath =
|
|
118462
|
+
const entryPath = join16(skillsDir, entry);
|
|
118290
118463
|
const stat = statSync(entryPath);
|
|
118291
118464
|
if (!stat.isDirectory()) continue;
|
|
118292
|
-
const skillPath =
|
|
118293
|
-
if (!
|
|
118465
|
+
const skillPath = join16(entryPath, "SKILL.md");
|
|
118466
|
+
if (!existsSync20(skillPath)) continue;
|
|
118294
118467
|
const content = readFileSync15(skillPath, "utf8");
|
|
118295
118468
|
const description = extractDescription(content);
|
|
118296
118469
|
skills.push({
|
|
@@ -118349,13 +118522,13 @@ async function listAction(options, command) {
|
|
|
118349
118522
|
const resolveSkillsDir = () => {
|
|
118350
118523
|
let current = process.cwd();
|
|
118351
118524
|
while (true) {
|
|
118352
|
-
const candidate =
|
|
118353
|
-
if (
|
|
118354
|
-
const parent2 =
|
|
118525
|
+
const candidate = join16(current, "skills");
|
|
118526
|
+
if (existsSync20(candidate)) return candidate;
|
|
118527
|
+
const parent2 = dirname6(current);
|
|
118355
118528
|
if (parent2 === current) break;
|
|
118356
118529
|
current = parent2;
|
|
118357
118530
|
}
|
|
118358
|
-
return
|
|
118531
|
+
return join16(process.cwd(), "skills");
|
|
118359
118532
|
};
|
|
118360
118533
|
const skillsDir = resolveSkillsDir();
|
|
118361
118534
|
const skills = discoverSkills(skillsDir);
|
|
@@ -118803,10 +118976,10 @@ init_esm_shims();
|
|
|
118803
118976
|
|
|
118804
118977
|
// ../core/src/pipeline/evals/classify.eval.ts
|
|
118805
118978
|
init_esm_shims();
|
|
118806
|
-
import { readFile as
|
|
118979
|
+
import { readFile as readFile9, writeFile as writeFile6 } from "fs/promises";
|
|
118807
118980
|
async function runClassifyEval2(options) {
|
|
118808
118981
|
const { dataset, output, verbose, json, forceLLM, model } = options;
|
|
118809
|
-
const datasetContent = await
|
|
118982
|
+
const datasetContent = await readFile9(dataset, "utf-8");
|
|
118810
118983
|
const scenarios = JSON.parse(datasetContent);
|
|
118811
118984
|
if (!json) {
|
|
118812
118985
|
console.log(`
|
|
@@ -118871,7 +119044,7 @@ async function runClassifyEval2(options) {
|
|
|
118871
119044
|
byTag
|
|
118872
119045
|
};
|
|
118873
119046
|
if (output) {
|
|
118874
|
-
await
|
|
119047
|
+
await writeFile6(
|
|
118875
119048
|
output,
|
|
118876
119049
|
JSON.stringify({ summary, results, confusion }, null, 2)
|
|
118877
119050
|
);
|
|
@@ -118907,7 +119080,7 @@ Latency: ${(totalDuration / results.length).toFixed(0)}ms avg`
|
|
|
118907
119080
|
return summary;
|
|
118908
119081
|
}
|
|
118909
119082
|
async function buildClassifyDataset(productionDataPath, outputPath) {
|
|
118910
|
-
const content = await
|
|
119083
|
+
const content = await readFile9(productionDataPath, "utf-8");
|
|
118911
119084
|
const production = JSON.parse(content);
|
|
118912
119085
|
const categoryMap = {
|
|
118913
119086
|
"tool-assisted": "support_access",
|
|
@@ -118941,14 +119114,14 @@ async function buildClassifyDataset(productionDataPath, outputPath) {
|
|
|
118941
119114
|
tags: [category]
|
|
118942
119115
|
};
|
|
118943
119116
|
});
|
|
118944
|
-
await
|
|
119117
|
+
await writeFile6(outputPath, JSON.stringify(scenarios, null, 2));
|
|
118945
119118
|
console.log(`Built ${scenarios.length} scenarios \u2192 ${outputPath}`);
|
|
118946
119119
|
console.log("\u26A0\uFE0F Categories are auto-inferred - review and correct manually!");
|
|
118947
119120
|
}
|
|
118948
119121
|
|
|
118949
119122
|
// ../core/src/pipeline/evals/e2e.eval.ts
|
|
118950
119123
|
init_esm_shims();
|
|
118951
|
-
import { readFile as
|
|
119124
|
+
import { readFile as readFile10, writeFile as writeFile7 } from "fs/promises";
|
|
118952
119125
|
async function runE2EEval2(options) {
|
|
118953
119126
|
const {
|
|
118954
119127
|
dataset,
|
|
@@ -118958,7 +119131,7 @@ async function runE2EEval2(options) {
|
|
|
118958
119131
|
limit: limit2,
|
|
118959
119132
|
model = "anthropic/claude-sonnet-4-5"
|
|
118960
119133
|
} = options;
|
|
118961
|
-
const content = await
|
|
119134
|
+
const content = await readFile10(dataset, "utf-8");
|
|
118962
119135
|
let scenarios = JSON.parse(content);
|
|
118963
119136
|
if (limit2) {
|
|
118964
119137
|
scenarios = scenarios.slice(0, limit2);
|
|
@@ -119085,7 +119258,7 @@ async function runE2EEval2(options) {
|
|
|
119085
119258
|
latency
|
|
119086
119259
|
};
|
|
119087
119260
|
if (output) {
|
|
119088
|
-
await
|
|
119261
|
+
await writeFile7(output, JSON.stringify({ summary, results }, null, 2));
|
|
119089
119262
|
if (!json) console.log(`Results saved to ${output}`);
|
|
119090
119263
|
}
|
|
119091
119264
|
if (json) {
|
|
@@ -119113,7 +119286,7 @@ async function runE2EEval2(options) {
|
|
|
119113
119286
|
|
|
119114
119287
|
// ../core/src/pipeline/evals/validate.eval.ts
|
|
119115
119288
|
init_esm_shims();
|
|
119116
|
-
import { readFile as
|
|
119289
|
+
import { readFile as readFile11, writeFile as writeFile8 } from "fs/promises";
|
|
119117
119290
|
var BUILT_IN_SCENARIOS = [
|
|
119118
119291
|
// Internal leaks
|
|
119119
119292
|
{
|
|
@@ -119245,7 +119418,7 @@ async function runValidateEval2(options) {
|
|
|
119245
119418
|
const { dataset, output, verbose, json } = options;
|
|
119246
119419
|
let scenarios;
|
|
119247
119420
|
if (dataset) {
|
|
119248
|
-
const content = await
|
|
119421
|
+
const content = await readFile11(dataset, "utf-8");
|
|
119249
119422
|
scenarios = JSON.parse(content);
|
|
119250
119423
|
} else {
|
|
119251
119424
|
scenarios = BUILT_IN_SCENARIOS;
|
|
@@ -119324,7 +119497,7 @@ async function runValidateEval2(options) {
|
|
|
119324
119497
|
byTag
|
|
119325
119498
|
};
|
|
119326
119499
|
if (output) {
|
|
119327
|
-
await
|
|
119500
|
+
await writeFile8(output, JSON.stringify({ summary, results }, null, 2));
|
|
119328
119501
|
if (!json) console.log(`Results saved to ${output}`);
|
|
119329
119502
|
}
|
|
119330
119503
|
if (json) {
|
|
@@ -119352,7 +119525,7 @@ Latency: ${(totalDuration / results.length).toFixed(2)}ms avg`
|
|
|
119352
119525
|
return summary;
|
|
119353
119526
|
}
|
|
119354
119527
|
async function buildValidateDatasetFromProduction(productionResultsPath, outputPath) {
|
|
119355
|
-
const content = await
|
|
119528
|
+
const content = await readFile11(productionResultsPath, "utf-8");
|
|
119356
119529
|
const production = JSON.parse(content);
|
|
119357
119530
|
const scenarios = production.results.filter((r) => !r.passed && r.productionResponse).map((r, i) => ({
|
|
119358
119531
|
id: `prod-fail-${i}`,
|
|
@@ -119368,7 +119541,7 @@ async function buildValidateDatasetFromProduction(productionResultsPath, outputP
|
|
|
119368
119541
|
shouldPass: false,
|
|
119369
119542
|
tags: ["production_failure"]
|
|
119370
119543
|
}));
|
|
119371
|
-
await
|
|
119544
|
+
await writeFile8(outputPath, JSON.stringify(scenarios, null, 2));
|
|
119372
119545
|
console.log(
|
|
119373
119546
|
`Built ${scenarios.length} scenarios from production failures \u2192 ${outputPath}`
|
|
119374
119547
|
);
|
|
@@ -119508,17 +119681,17 @@ function registerPipelineCommands(program3) {
|
|
|
119508
119681
|
|
|
119509
119682
|
// src/commands/plugin-sync.ts
|
|
119510
119683
|
init_esm_shims();
|
|
119511
|
-
import { homedir as
|
|
119512
|
-
import { dirname as
|
|
119513
|
-
import { fileURLToPath } from "url";
|
|
119514
|
-
var PLUGIN_SOURCE_DIR =
|
|
119515
|
-
|
|
119684
|
+
import { homedir as homedir6 } from "os";
|
|
119685
|
+
import { dirname as dirname7, join as join17, resolve as resolve8 } from "path";
|
|
119686
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
119687
|
+
var PLUGIN_SOURCE_DIR = resolve8(
|
|
119688
|
+
dirname7(fileURLToPath3(import.meta.url)),
|
|
119516
119689
|
"../../plugin"
|
|
119517
119690
|
);
|
|
119518
|
-
var PLUGIN_MANIFEST_RELATIVE =
|
|
119691
|
+
var PLUGIN_MANIFEST_RELATIVE = join17(".claude-plugin", "plugin.json");
|
|
119519
119692
|
var resolveTargetDir = (global2) => {
|
|
119520
|
-
const base =
|
|
119521
|
-
return
|
|
119693
|
+
const base = join17(homedir6(), ".claude", global2 ? "skills" : "plugins");
|
|
119694
|
+
return join17(base, "skill-cli");
|
|
119522
119695
|
};
|
|
119523
119696
|
var readManifest = async (path3) => {
|
|
119524
119697
|
const manifest = await readJson(path3);
|
|
@@ -119547,7 +119720,7 @@ var writeResult4 = (ctx, payload) => {
|
|
|
119547
119720
|
};
|
|
119548
119721
|
async function executePluginSync(ctx, options) {
|
|
119549
119722
|
try {
|
|
119550
|
-
const sourceManifestPath =
|
|
119723
|
+
const sourceManifestPath = join17(PLUGIN_SOURCE_DIR, PLUGIN_MANIFEST_RELATIVE);
|
|
119551
119724
|
const sourceExists = await pathExists(sourceManifestPath);
|
|
119552
119725
|
if (!sourceExists) {
|
|
119553
119726
|
throw new CLIError({
|
|
@@ -119557,7 +119730,7 @@ async function executePluginSync(ctx, options) {
|
|
|
119557
119730
|
}
|
|
119558
119731
|
const sourceManifest = await readManifest(sourceManifestPath);
|
|
119559
119732
|
const targetDir = resolveTargetDir(options.global);
|
|
119560
|
-
const targetManifestPath =
|
|
119733
|
+
const targetManifestPath = join17(targetDir, PLUGIN_MANIFEST_RELATIVE);
|
|
119561
119734
|
const targetExists = await pathExists(targetManifestPath);
|
|
119562
119735
|
if (targetExists && !options.force) {
|
|
119563
119736
|
const targetManifest = await readManifest(targetManifestPath);
|
|
@@ -120798,9 +120971,9 @@ async function wizard(ctx, options = {}) {
|
|
|
120798
120971
|
// src/core/auto-update.ts
|
|
120799
120972
|
init_esm_shims();
|
|
120800
120973
|
import { spawn } from "child_process";
|
|
120801
|
-
import { writeFile as
|
|
120802
|
-
import { homedir as
|
|
120803
|
-
import { dirname as
|
|
120974
|
+
import { writeFile as writeFile9 } from "fs/promises";
|
|
120975
|
+
import { homedir as homedir7 } from "os";
|
|
120976
|
+
import { dirname as dirname8, join as join18 } from "path";
|
|
120804
120977
|
var CONFIG_DIR_NAME = "skill-cli";
|
|
120805
120978
|
var AUTO_UPDATE_STATE_FILE = "auto-update.json";
|
|
120806
120979
|
var DEFAULT_PACKAGE = "@skillrecordings/cli";
|
|
@@ -120812,7 +120985,7 @@ var AutoUpdateStore = class {
|
|
|
120812
120985
|
now;
|
|
120813
120986
|
constructor(options = {}) {
|
|
120814
120987
|
const configDir = resolveConfigDir(options.configDir);
|
|
120815
|
-
this.filePath =
|
|
120988
|
+
this.filePath = join18(configDir, AUTO_UPDATE_STATE_FILE);
|
|
120816
120989
|
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
120817
120990
|
}
|
|
120818
120991
|
getNow() {
|
|
@@ -120830,8 +121003,8 @@ var AutoUpdateStore = class {
|
|
|
120830
121003
|
}
|
|
120831
121004
|
async save(state) {
|
|
120832
121005
|
try {
|
|
120833
|
-
await ensureDir(
|
|
120834
|
-
await
|
|
121006
|
+
await ensureDir(dirname8(this.filePath));
|
|
121007
|
+
await writeFile9(this.filePath, JSON.stringify(state, null, 2), "utf-8");
|
|
120835
121008
|
} catch {
|
|
120836
121009
|
}
|
|
120837
121010
|
}
|
|
@@ -120840,9 +121013,9 @@ function resolveConfigDir(configDir) {
|
|
|
120840
121013
|
if (configDir) return configDir;
|
|
120841
121014
|
const xdgConfigHome = process.env.XDG_CONFIG_HOME;
|
|
120842
121015
|
if (xdgConfigHome && xdgConfigHome.trim() !== "") {
|
|
120843
|
-
return
|
|
121016
|
+
return join18(xdgConfigHome, CONFIG_DIR_NAME);
|
|
120844
121017
|
}
|
|
120845
|
-
return
|
|
121018
|
+
return join18(homedir7(), ".config", CONFIG_DIR_NAME);
|
|
120846
121019
|
}
|
|
120847
121020
|
function isAutoUpdateState(value) {
|
|
120848
121021
|
if (!value || typeof value !== "object") return false;
|
|
@@ -120960,16 +121133,16 @@ async function performUpdate(options = {}) {
|
|
|
120960
121133
|
const packageManager = resolvePackageManager(options.userAgent);
|
|
120961
121134
|
const spawnFn = options.spawnFn ?? spawn;
|
|
120962
121135
|
const [command, args] = packageManager === "bun" ? ["bun", ["add", "-g", packageName]] : ["npm", ["install", "-g", packageName]];
|
|
120963
|
-
const exitCode = await new Promise((
|
|
121136
|
+
const exitCode = await new Promise((resolve11) => {
|
|
120964
121137
|
try {
|
|
120965
121138
|
const child = spawnFn(command, args, {
|
|
120966
121139
|
stdio: "ignore",
|
|
120967
121140
|
env: process.env
|
|
120968
121141
|
});
|
|
120969
|
-
child.on("error", () =>
|
|
120970
|
-
child.on("close", (code) =>
|
|
121142
|
+
child.on("error", () => resolve11(1));
|
|
121143
|
+
child.on("close", (code) => resolve11(code ?? 1));
|
|
120971
121144
|
} catch {
|
|
120972
|
-
|
|
121145
|
+
resolve11(1);
|
|
120973
121146
|
}
|
|
120974
121147
|
});
|
|
120975
121148
|
if (exitCode === 0) {
|
|
@@ -121137,30 +121310,30 @@ var writeHints = (hints, stderr) => {
|
|
|
121137
121310
|
|
|
121138
121311
|
// src/core/skill-link.ts
|
|
121139
121312
|
init_esm_shims();
|
|
121140
|
-
import { existsSync as
|
|
121141
|
-
import { lstat, mkdir as
|
|
121142
|
-
import { homedir as
|
|
121143
|
-
import { dirname as
|
|
121144
|
-
import { fileURLToPath as
|
|
121145
|
-
var DEFAULT_SKILL_SOURCE_DIR =
|
|
121146
|
-
|
|
121313
|
+
import { existsSync as existsSync21 } from "fs";
|
|
121314
|
+
import { lstat, mkdir as mkdir4, readdir as readdir2, readlink as readlink2, symlink } from "fs/promises";
|
|
121315
|
+
import { homedir as homedir8 } from "os";
|
|
121316
|
+
import { dirname as dirname9, join as join19, resolve as resolve9 } from "path";
|
|
121317
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
121318
|
+
var DEFAULT_SKILL_SOURCE_DIR = resolve9(
|
|
121319
|
+
dirname9(fileURLToPath4(import.meta.url)),
|
|
121147
121320
|
"../../../../skills"
|
|
121148
121321
|
);
|
|
121149
121322
|
var DEFAULT_TARGET_ROOTS = [
|
|
121150
|
-
|
|
121151
|
-
|
|
121152
|
-
|
|
121323
|
+
join19(homedir8(), ".agents", "skills"),
|
|
121324
|
+
join19(homedir8(), ".claude", "skills"),
|
|
121325
|
+
join19(homedir8(), ".pi", "agent", "skills")
|
|
121153
121326
|
];
|
|
121154
|
-
var hasSkillFile = (dir) =>
|
|
121327
|
+
var hasSkillFile = (dir) => existsSync21(join19(dir, "SKILL.md"));
|
|
121155
121328
|
var resolveTargetRoots = (targetRoots) => {
|
|
121156
121329
|
if (targetRoots && targetRoots.length > 0) {
|
|
121157
|
-
return targetRoots.map((root2) =>
|
|
121330
|
+
return targetRoots.map((root2) => resolve9(root2));
|
|
121158
121331
|
}
|
|
121159
|
-
return DEFAULT_TARGET_ROOTS.map((root2) =>
|
|
121332
|
+
return DEFAULT_TARGET_ROOTS.map((root2) => resolve9(root2));
|
|
121160
121333
|
};
|
|
121161
121334
|
var listSkillDirs = async (sourceDir) => {
|
|
121162
121335
|
const entries = await readdir2(sourceDir, { withFileTypes: true });
|
|
121163
|
-
const skills = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => hasSkillFile(
|
|
121336
|
+
const skills = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => hasSkillFile(join19(sourceDir, name)));
|
|
121164
121337
|
return skills.sort((a, b) => a.localeCompare(b));
|
|
121165
121338
|
};
|
|
121166
121339
|
var isMissingPathError = (error) => error?.code === "ENOENT";
|
|
@@ -121171,7 +121344,7 @@ var linkSkill = async (source, target) => {
|
|
|
121171
121344
|
stats4 = await lstat(target);
|
|
121172
121345
|
} catch (error) {
|
|
121173
121346
|
if (isMissingPathError(error)) {
|
|
121174
|
-
await
|
|
121347
|
+
await mkdir4(dirname9(target), { recursive: true });
|
|
121175
121348
|
await symlink(source, target, "dir");
|
|
121176
121349
|
return {
|
|
121177
121350
|
status: "linked",
|
|
@@ -121183,8 +121356,8 @@ var linkSkill = async (source, target) => {
|
|
|
121183
121356
|
throw error;
|
|
121184
121357
|
}
|
|
121185
121358
|
if (stats4.isSymbolicLink()) {
|
|
121186
|
-
const linkTarget = await
|
|
121187
|
-
const resolvedLinkTarget =
|
|
121359
|
+
const linkTarget = await readlink2(target);
|
|
121360
|
+
const resolvedLinkTarget = resolve9(dirname9(target), linkTarget);
|
|
121188
121361
|
if (resolvedLinkTarget === source || linkTarget === source) {
|
|
121189
121362
|
return {
|
|
121190
121363
|
status: "exists",
|
|
@@ -121216,15 +121389,15 @@ var linkSkill = async (source, target) => {
|
|
|
121216
121389
|
}
|
|
121217
121390
|
};
|
|
121218
121391
|
async function autoLinkSkills(options = {}) {
|
|
121219
|
-
const sourceDir =
|
|
121392
|
+
const sourceDir = resolve9(options.sourceDir ?? DEFAULT_SKILL_SOURCE_DIR);
|
|
121220
121393
|
const targetRoots = resolveTargetRoots(options.targetRoots);
|
|
121221
121394
|
try {
|
|
121222
121395
|
const skillNames = await listSkillDirs(sourceDir);
|
|
121223
121396
|
const results = [];
|
|
121224
121397
|
for (const skillName of skillNames) {
|
|
121225
|
-
const source =
|
|
121398
|
+
const source = join19(sourceDir, skillName);
|
|
121226
121399
|
for (const targetRoot of targetRoots) {
|
|
121227
|
-
const target =
|
|
121400
|
+
const target = join19(targetRoot, skillName);
|
|
121228
121401
|
results.push(await linkSkill(source, target));
|
|
121229
121402
|
}
|
|
121230
121403
|
}
|
|
@@ -121303,18 +121476,18 @@ async function sendTelemetryEvent(event) {
|
|
|
121303
121476
|
|
|
121304
121477
|
// src/core/usage-tracker.ts
|
|
121305
121478
|
init_esm_shims();
|
|
121306
|
-
import { writeFile as
|
|
121307
|
-
import { homedir as
|
|
121308
|
-
import { dirname as
|
|
121479
|
+
import { writeFile as writeFile10 } from "fs/promises";
|
|
121480
|
+
import { homedir as homedir9 } from "os";
|
|
121481
|
+
import { dirname as dirname10, join as join20 } from "path";
|
|
121309
121482
|
var CONFIG_DIR_NAME2 = "skill-cli";
|
|
121310
121483
|
var USAGE_FILE_NAME = "usage.json";
|
|
121311
121484
|
function resolveConfigDir2(configDir) {
|
|
121312
121485
|
if (configDir) return configDir;
|
|
121313
121486
|
const xdgConfigHome = process.env.XDG_CONFIG_HOME;
|
|
121314
121487
|
if (xdgConfigHome && xdgConfigHome.trim() !== "") {
|
|
121315
|
-
return
|
|
121488
|
+
return join20(xdgConfigHome, CONFIG_DIR_NAME2);
|
|
121316
121489
|
}
|
|
121317
|
-
return
|
|
121490
|
+
return join20(homedir9(), ".config", CONFIG_DIR_NAME2);
|
|
121318
121491
|
}
|
|
121319
121492
|
function createDefaultState(now) {
|
|
121320
121493
|
return {
|
|
@@ -121352,7 +121525,7 @@ var UsageTracker = class {
|
|
|
121352
121525
|
statePromise;
|
|
121353
121526
|
constructor(options = {}) {
|
|
121354
121527
|
const configDir = resolveConfigDir2(options.configDir);
|
|
121355
|
-
this.filePath =
|
|
121528
|
+
this.filePath = join20(configDir, USAGE_FILE_NAME);
|
|
121356
121529
|
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
121357
121530
|
}
|
|
121358
121531
|
async loadState() {
|
|
@@ -121375,8 +121548,8 @@ var UsageTracker = class {
|
|
|
121375
121548
|
}
|
|
121376
121549
|
async saveState(state) {
|
|
121377
121550
|
try {
|
|
121378
|
-
await ensureDir(
|
|
121379
|
-
await
|
|
121551
|
+
await ensureDir(dirname10(this.filePath));
|
|
121552
|
+
await writeFile10(this.filePath, JSON.stringify(state, null, 2), "utf-8");
|
|
121380
121553
|
} catch {
|
|
121381
121554
|
}
|
|
121382
121555
|
}
|
|
@@ -121670,14 +121843,14 @@ async function createToolContext() {
|
|
|
121670
121843
|
return ctx;
|
|
121671
121844
|
}
|
|
121672
121845
|
function captureOutput(stream) {
|
|
121673
|
-
return new Promise((
|
|
121846
|
+
return new Promise((resolve11) => {
|
|
121674
121847
|
let buffer = "";
|
|
121675
121848
|
stream.on("data", (chunk) => {
|
|
121676
121849
|
buffer += chunk.toString();
|
|
121677
121850
|
});
|
|
121678
|
-
stream.on("end", () =>
|
|
121679
|
-
stream.on("close", () =>
|
|
121680
|
-
stream.on("finish", () =>
|
|
121851
|
+
stream.on("end", () => resolve11(buffer));
|
|
121852
|
+
stream.on("close", () => resolve11(buffer));
|
|
121853
|
+
stream.on("finish", () => resolve11(buffer));
|
|
121681
121854
|
});
|
|
121682
121855
|
}
|
|
121683
121856
|
function parseJsonOutput(stdout) {
|
|
@@ -121909,15 +122082,15 @@ function createMcpServer(options = {}) {
|
|
|
121909
122082
|
const onSigterm = () => stop();
|
|
121910
122083
|
process.once("SIGTERM", onSigterm);
|
|
121911
122084
|
removeSigterm = () => process.off("SIGTERM", onSigterm);
|
|
121912
|
-
return new Promise((
|
|
121913
|
-
resolveStop =
|
|
122085
|
+
return new Promise((resolve11) => {
|
|
122086
|
+
resolveStop = resolve11;
|
|
121914
122087
|
});
|
|
121915
122088
|
};
|
|
121916
122089
|
return { start, stop };
|
|
121917
122090
|
}
|
|
121918
122091
|
|
|
121919
122092
|
// src/index.ts
|
|
121920
|
-
var cliRoot =
|
|
122093
|
+
var cliRoot = resolve10(import.meta.dirname, "..");
|
|
121921
122094
|
await initConfig(cliRoot);
|
|
121922
122095
|
var plaintextEnv = loadPlaintextEnv(cliRoot);
|
|
121923
122096
|
var envLoaded = false;
|
|
@@ -121931,8 +122104,8 @@ if (!envLoaded && !process.env.DATABASE_URL) {
|
|
|
121931
122104
|
process.env.SKIP_ENV_VALIDATION = "1";
|
|
121932
122105
|
}
|
|
121933
122106
|
var runtimeTarget = `bun-${process.platform}-${process.arch}`;
|
|
121934
|
-
var buildVersion = "0.
|
|
121935
|
-
var buildCommit = "
|
|
122107
|
+
var buildVersion = "0.20.0".length > 0 ? "0.20.0" : "0.0.0-dev";
|
|
122108
|
+
var buildCommit = "150b8cc".length > 0 ? "150b8cc" : "dev";
|
|
121936
122109
|
var buildTarget = "node".length > 0 ? "node" : runtimeTarget;
|
|
121937
122110
|
var isDevBuild = buildVersion.includes("dev") || buildCommit === "dev";
|
|
121938
122111
|
var versionLabel = `skill v${buildVersion} (${buildCommit}) ${buildTarget}`;
|
|
@@ -122139,6 +122312,7 @@ registerConfigCommands(program2);
|
|
|
122139
122312
|
registerKeysCommands(program2);
|
|
122140
122313
|
registerDoctorCommand(program2);
|
|
122141
122314
|
registerListCommand(program2);
|
|
122315
|
+
registerCompanionCommands(program2);
|
|
122142
122316
|
registerPluginSyncCommand(program2);
|
|
122143
122317
|
program2.command("mcp").description(
|
|
122144
122318
|
"Start MCP server for AI coding agent integration.\n Exposes 9 Front tools over JSON-RPC stdio for Claude Code, Cursor, etc.\n Tools: inbox, conversation, message, assign, reply, tag, archive, search, report\n Usage: skill mcp (then connect your AI editor to stdin/stdout)"
|