forge-cw 0.1.15 → 0.1.16
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/console/assets/index-DiFbTaPf.js +31 -0
- package/console/index.html +1 -1
- package/dist/index.js +1400 -1211
- package/package.json +1 -1
- package/console/assets/index-m_7gobK_.js +0 -31
package/dist/index.js
CHANGED
|
@@ -38,8 +38,8 @@ import { createRequire } from "node:module";
|
|
|
38
38
|
function quietSqliteWarning() {
|
|
39
39
|
const emitWarning = process.emitWarning;
|
|
40
40
|
process.emitWarning = function(warning, ...rest) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const text2 = typeof warning === "string" ? warning : warning.message;
|
|
42
|
+
if (text2.startsWith("SQLite is an experimental feature"))
|
|
43
43
|
return;
|
|
44
44
|
return emitWarning.call(process, warning, ...rest);
|
|
45
45
|
};
|
|
@@ -972,8 +972,8 @@ function createDoctorClient(cwBin) {
|
|
|
972
972
|
}
|
|
973
973
|
function readContextTokens(cwHome, env = process.env) {
|
|
974
974
|
const file = join3(cwHome, "tokens.env");
|
|
975
|
-
const
|
|
976
|
-
const has = (name) => Boolean(env[name]?.trim()) || new RegExp(`^\\s*(export\\s+)?${name}\\s*=\\s*\\S`, "m").test(
|
|
975
|
+
const text2 = existsSync3(file) ? readFileSync3(file, "utf-8") : "";
|
|
976
|
+
const has = (name) => Boolean(env[name]?.trim()) || new RegExp(`^\\s*(export\\s+)?${name}\\s*=\\s*\\S`, "m").test(text2);
|
|
977
977
|
return { linear: has("LINEAR_API_KEY"), notion: has("NOTION_TOKEN") };
|
|
978
978
|
}
|
|
979
979
|
var CACHE_MS, TIMEOUT_MS;
|
|
@@ -1004,8 +1004,8 @@ function summarizeChecks(rollup) {
|
|
|
1004
1004
|
return "pending";
|
|
1005
1005
|
return "passing";
|
|
1006
1006
|
}
|
|
1007
|
-
function parseShortstat(
|
|
1008
|
-
const num2 = (re) => Number(re.exec(
|
|
1007
|
+
function parseShortstat(text2) {
|
|
1008
|
+
const num2 = (re) => Number(re.exec(text2)?.[1] ?? 0);
|
|
1009
1009
|
return {
|
|
1010
1010
|
files: num2(/(\d+) files? changed/),
|
|
1011
1011
|
insertions: num2(/(\d+) insertions?\(\+\)/),
|
|
@@ -1286,7 +1286,7 @@ var init_task_review = __esm({
|
|
|
1286
1286
|
runCommand = createRunner();
|
|
1287
1287
|
GitReadError = class extends Error {
|
|
1288
1288
|
};
|
|
1289
|
-
lines = (
|
|
1289
|
+
lines = (text2) => text2.split("\n").filter((line) => line.length > 0);
|
|
1290
1290
|
CW_LINKED_FILES = /* @__PURE__ */ new Set([".claude", ".env", "TASK_NOTES.md", "SHARED_CONTEXT.md"]);
|
|
1291
1291
|
PR_FIELDS = "number,state,url,isDraft,baseRefName,headRefOid,reviewDecision,statusCheckRollup";
|
|
1292
1292
|
PR_STATES = /* @__PURE__ */ new Set(["OPEN", "MERGED", "CLOSED"]);
|
|
@@ -1494,20 +1494,20 @@ function callCodexAppServer(bin, codexHome, timeoutMs = TIMEOUT_MS3) {
|
|
|
1494
1494
|
for (const line of lines2) {
|
|
1495
1495
|
if (!line.trim())
|
|
1496
1496
|
continue;
|
|
1497
|
-
let
|
|
1497
|
+
let message2;
|
|
1498
1498
|
try {
|
|
1499
|
-
|
|
1499
|
+
message2 = JSON.parse(line);
|
|
1500
1500
|
} catch {
|
|
1501
1501
|
continue;
|
|
1502
1502
|
}
|
|
1503
|
-
if (
|
|
1503
|
+
if (message2.id !== READ_ID)
|
|
1504
1504
|
continue;
|
|
1505
|
-
if (
|
|
1506
|
-
return fail(new Error(String(
|
|
1507
|
-
return done(obj(
|
|
1505
|
+
if (message2.error)
|
|
1506
|
+
return fail(new Error(String(message2.error.message ?? "codex app-server returned an error")));
|
|
1507
|
+
return done(obj(message2.result) ?? {});
|
|
1508
1508
|
}
|
|
1509
1509
|
});
|
|
1510
|
-
const send = (
|
|
1510
|
+
const send = (message2) => child.stdin.write(`${JSON.stringify(message2)}
|
|
1511
1511
|
`);
|
|
1512
1512
|
send({ jsonrpc: "2.0", id: 1, method: "initialize", params: { clientInfo: { name: "forge", title: "Forge", version: "0.1.0" } } });
|
|
1513
1513
|
send({ jsonrpc: "2.0", method: "initialized", params: {} });
|
|
@@ -1748,7 +1748,7 @@ var init_login_manager = __esm({
|
|
|
1748
1748
|
import { spawn as spawn4 } from "node:child_process";
|
|
1749
1749
|
function importApiKey(cwBin, account, harness, apiKey) {
|
|
1750
1750
|
return new Promise((resolve10) => {
|
|
1751
|
-
const redact = (
|
|
1751
|
+
const redact = (text2) => text2.split(apiKey).join("***").trim();
|
|
1752
1752
|
const child = spawn4(cwBin, ["account", "login", account, "--harness", harness, "--with-api-key", "-"], {
|
|
1753
1753
|
env: envWithoutHarness(),
|
|
1754
1754
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -1840,15 +1840,15 @@ var init_editors = __esm({
|
|
|
1840
1840
|
});
|
|
1841
1841
|
|
|
1842
1842
|
// ../core/dist/output.js
|
|
1843
|
-
function tailOutput(
|
|
1844
|
-
return stripAnsi(
|
|
1843
|
+
function tailOutput(text2, max = 20) {
|
|
1844
|
+
return stripAnsi(text2).split("\n").map((line) => line.trimEnd()).filter((line) => line.length > 0).slice(-max).join("\n");
|
|
1845
1845
|
}
|
|
1846
1846
|
var ANSI_RE2, stripAnsi;
|
|
1847
1847
|
var init_output = __esm({
|
|
1848
1848
|
"../core/dist/output.js"() {
|
|
1849
1849
|
"use strict";
|
|
1850
1850
|
ANSI_RE2 = /\x1b\[[0-9;]*[A-Za-z]/g;
|
|
1851
|
-
stripAnsi = (
|
|
1851
|
+
stripAnsi = (text2) => text2.replace(ANSI_RE2, "");
|
|
1852
1852
|
}
|
|
1853
1853
|
});
|
|
1854
1854
|
|
|
@@ -1986,8 +1986,8 @@ function cwRoutes(reader, options = {}) {
|
|
|
1986
1986
|
return c.json({ ok: true, name: trimmed });
|
|
1987
1987
|
} catch (err) {
|
|
1988
1988
|
const stderr = err.stderr?.trim().split("\n")[0];
|
|
1989
|
-
const
|
|
1990
|
-
return c.json({ ok: false, error: `Failed to create account: ${
|
|
1989
|
+
const message2 = stderr || (err instanceof Error ? err.message : "Unknown error");
|
|
1990
|
+
return c.json({ ok: false, error: `Failed to create account: ${message2}` }, 500);
|
|
1991
1991
|
}
|
|
1992
1992
|
});
|
|
1993
1993
|
app.delete("/accounts/:name", async (c) => {
|
|
@@ -2004,8 +2004,8 @@ function cwRoutes(reader, options = {}) {
|
|
|
2004
2004
|
rmSync4(accountDir, { recursive: true, force: true });
|
|
2005
2005
|
return c.json({ ok: true });
|
|
2006
2006
|
} catch (err) {
|
|
2007
|
-
const
|
|
2008
|
-
return c.json({ ok: false, error: `Failed to remove account: ${
|
|
2007
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
2008
|
+
return c.json({ ok: false, error: `Failed to remove account: ${message2}` }, 500);
|
|
2009
2009
|
}
|
|
2010
2010
|
});
|
|
2011
2011
|
app.post("/accounts/:name/login", async (c) => {
|
|
@@ -2445,8 +2445,8 @@ ${result2.stderr}`);
|
|
|
2445
2445
|
writeFileSync(join7(reader.cwHome, "projects.json"), JSON.stringify(projects, null, 2));
|
|
2446
2446
|
return c.json({ ok: true });
|
|
2447
2447
|
} catch (err) {
|
|
2448
|
-
const
|
|
2449
|
-
return c.json({ ok: false, error: `Failed to update projects: ${
|
|
2448
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
2449
|
+
return c.json({ ok: false, error: `Failed to update projects: ${message2}` }, 500);
|
|
2450
2450
|
}
|
|
2451
2451
|
});
|
|
2452
2452
|
app.post("/delete-project", async (c) => {
|
|
@@ -2506,8 +2506,8 @@ ${result2.stderr}`);
|
|
|
2506
2506
|
try {
|
|
2507
2507
|
entries = readdirSync3(target, { withFileTypes: true });
|
|
2508
2508
|
} catch (err) {
|
|
2509
|
-
const
|
|
2510
|
-
return c.json({ ok: false, error: `Cannot read directory: ${
|
|
2509
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
2510
|
+
return c.json({ ok: false, error: `Cannot read directory: ${message2}` }, 500);
|
|
2511
2511
|
}
|
|
2512
2512
|
const dirs = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map(({ name }) => {
|
|
2513
2513
|
const full = join7(target, name);
|
|
@@ -2558,8 +2558,8 @@ ${result2.stderr}`);
|
|
|
2558
2558
|
options.events?.emit("project.registered", { project: projectName, path: projectPath });
|
|
2559
2559
|
return c.json({ ok: true, project: projectName });
|
|
2560
2560
|
} catch (err) {
|
|
2561
|
-
const
|
|
2562
|
-
return c.json({ ok: false, error: `Failed to register project: ${
|
|
2561
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
2562
|
+
return c.json({ ok: false, error: `Failed to register project: ${message2}` }, 500);
|
|
2563
2563
|
}
|
|
2564
2564
|
});
|
|
2565
2565
|
return app;
|
|
@@ -2697,6 +2697,20 @@ function projectSkillNames(projectPath) {
|
|
|
2697
2697
|
return [];
|
|
2698
2698
|
return readdirSync4(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && existsSync6(join8(dir, e.name, "SKILL.md"))).map((e) => e.name).sort();
|
|
2699
2699
|
}
|
|
2700
|
+
function installsOf(reader, name) {
|
|
2701
|
+
return pluginScopes(reader).flatMap(({ scope, scopeRef }) => {
|
|
2702
|
+
const configDir = reader.getSkillConfigDir(scope, scopeRef);
|
|
2703
|
+
const installed = readJson(join8(configDir, "plugins", "installed_plugins.json"))["plugins"];
|
|
2704
|
+
if (!isRecord(installed))
|
|
2705
|
+
return [];
|
|
2706
|
+
return Object.entries(installed).flatMap(([id, entries]) => {
|
|
2707
|
+
const user = Array.isArray(entries) ? entries.find((e) => isRecord(e) && e["scope"] === "user") : void 0;
|
|
2708
|
+
if (!user || splitPluginId(id).name !== name)
|
|
2709
|
+
return [];
|
|
2710
|
+
return [{ id, scope, scopeRef, version: String(user["version"] ?? ""), configDir, update: pluginUpdateArgs(id) }];
|
|
2711
|
+
});
|
|
2712
|
+
});
|
|
2713
|
+
}
|
|
2700
2714
|
async function listPlugins(reader, remoteOf) {
|
|
2701
2715
|
const found = /* @__PURE__ */ new Map();
|
|
2702
2716
|
for (const { scope, scopeRef } of pluginScopes(reader)) {
|
|
@@ -2796,7 +2810,7 @@ function marketplaceSourceOf(reader, marketplace) {
|
|
|
2796
2810
|
}
|
|
2797
2811
|
return void 0;
|
|
2798
2812
|
}
|
|
2799
|
-
var isRecord, inside, pluginScopes, knownMarketplaces, numeric, knowsMarketplace;
|
|
2813
|
+
var isRecord, inside, pluginScopes, knownMarketplaces, numeric, pluginUpdateArgs, knowsMarketplace;
|
|
2800
2814
|
var init_plugins = __esm({
|
|
2801
2815
|
"../core/dist/plugins.js"() {
|
|
2802
2816
|
"use strict";
|
|
@@ -2812,6 +2826,7 @@ var init_plugins = __esm({
|
|
|
2812
2826
|
];
|
|
2813
2827
|
knownMarketplaces = (configDir) => readJson(join8(configDir, "plugins", "known_marketplaces.json"));
|
|
2814
2828
|
numeric = (v) => /^\d+(\.\d+)*$/.test(v) ? v.split(".").map(Number) : null;
|
|
2829
|
+
pluginUpdateArgs = (id) => [["plugin", "marketplace", "update", splitPluginId(id).marketplace], ["plugin", "update", id]];
|
|
2815
2830
|
knowsMarketplace = (configDir, marketplace) => isRecord(knownMarketplaces(configDir)[marketplace]);
|
|
2816
2831
|
}
|
|
2817
2832
|
});
|
|
@@ -2904,8 +2919,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2904
2919
|
cpSync(source, target, { recursive: true });
|
|
2905
2920
|
return c.json({ ok: true });
|
|
2906
2921
|
} catch (err) {
|
|
2907
|
-
const
|
|
2908
|
-
return c.json({ error: `Failed to copy skill: ${
|
|
2922
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
2923
|
+
return c.json({ error: `Failed to copy skill: ${message2}` }, 500);
|
|
2909
2924
|
}
|
|
2910
2925
|
});
|
|
2911
2926
|
app.get("/global/:name", (c) => {
|
|
@@ -2941,8 +2956,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2941
2956
|
writeFileSync2(join9(dir, "SKILL.md"), content, "utf-8");
|
|
2942
2957
|
return c.json({ ok: true, dir });
|
|
2943
2958
|
} catch (err) {
|
|
2944
|
-
const
|
|
2945
|
-
return c.json({ error: `Failed to create skill: ${
|
|
2959
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
2960
|
+
return c.json({ error: `Failed to create skill: ${message2}` }, 500);
|
|
2946
2961
|
}
|
|
2947
2962
|
});
|
|
2948
2963
|
const scopePatterns = [
|
|
@@ -2968,8 +2983,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2968
2983
|
writeFileSync2(skillMd, content, "utf-8");
|
|
2969
2984
|
return c.json({ ok: true });
|
|
2970
2985
|
} catch (err) {
|
|
2971
|
-
const
|
|
2972
|
-
return c.json({ error: `Failed to update skill: ${
|
|
2986
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
2987
|
+
return c.json({ error: `Failed to update skill: ${message2}` }, 500);
|
|
2973
2988
|
}
|
|
2974
2989
|
});
|
|
2975
2990
|
app.put(`${pattern}/references/:filename`, async (c) => {
|
|
@@ -2992,8 +3007,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2992
3007
|
writeFileSync2(join9(refsDir, filename), content, "utf-8");
|
|
2993
3008
|
return c.json({ ok: true });
|
|
2994
3009
|
} catch (err) {
|
|
2995
|
-
const
|
|
2996
|
-
return c.json({ error: `Failed to write reference: ${
|
|
3010
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
3011
|
+
return c.json({ error: `Failed to write reference: ${message2}` }, 500);
|
|
2997
3012
|
}
|
|
2998
3013
|
});
|
|
2999
3014
|
app.delete(`${pattern}/references/:filename`, (c) => {
|
|
@@ -3013,8 +3028,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
3013
3028
|
unlinkSync(refFile);
|
|
3014
3029
|
return c.json({ ok: true });
|
|
3015
3030
|
} catch (err) {
|
|
3016
|
-
const
|
|
3017
|
-
return c.json({ error: `Failed to delete reference: ${
|
|
3031
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
3032
|
+
return c.json({ error: `Failed to delete reference: ${message2}` }, 500);
|
|
3018
3033
|
}
|
|
3019
3034
|
});
|
|
3020
3035
|
app.delete(pattern, (c) => {
|
|
@@ -3032,8 +3047,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
3032
3047
|
rmSync2(dir, { recursive: true, force: true });
|
|
3033
3048
|
return c.json({ ok: true });
|
|
3034
3049
|
} catch (err) {
|
|
3035
|
-
const
|
|
3036
|
-
return c.json({ error: `Failed to delete skill: ${
|
|
3050
|
+
const message2 = err instanceof Error ? err.message : "Unknown error";
|
|
3051
|
+
return c.json({ error: `Failed to delete skill: ${message2}` }, 500);
|
|
3037
3052
|
}
|
|
3038
3053
|
});
|
|
3039
3054
|
}
|
|
@@ -3096,7 +3111,7 @@ function skillRoutes(reader, options = {}) {
|
|
|
3096
3111
|
const install = plugin?.installs.find((i) => i.scope === scope && i.scopeRef === ref);
|
|
3097
3112
|
if (!plugin || !install)
|
|
3098
3113
|
return c.json({ error: `${id} is not installed in ${ref || "that scope"}` }, 404);
|
|
3099
|
-
const failed = await runClaude(install.scope, ref,
|
|
3114
|
+
const failed = await runClaude(install.scope, ref, pluginUpdateArgs(plugin.id), `Failed to update ${plugin.name}`);
|
|
3100
3115
|
if (failed)
|
|
3101
3116
|
return c.json({ error: failed.error }, failed.status);
|
|
3102
3117
|
const version = (await find())?.installs.find((i) => i.scope === install.scope && i.scopeRef === ref)?.version ?? install.version;
|
|
@@ -3303,10 +3318,10 @@ var init_pty_manager = __esm({
|
|
|
3303
3318
|
if (ptySession.scrollback.length > SCROLLBACK_LIMIT) {
|
|
3304
3319
|
ptySession.scrollback.splice(0, ptySession.scrollback.length - SCROLLBACK_LIMIT);
|
|
3305
3320
|
}
|
|
3306
|
-
const
|
|
3321
|
+
const message2 = JSON.stringify({ type: "output", data });
|
|
3307
3322
|
for (const client of ptySession.clients) {
|
|
3308
3323
|
try {
|
|
3309
|
-
client.send(
|
|
3324
|
+
client.send(message2);
|
|
3310
3325
|
} catch {
|
|
3311
3326
|
ptySession.clients.delete(client);
|
|
3312
3327
|
}
|
|
@@ -3314,10 +3329,10 @@ var init_pty_manager = __esm({
|
|
|
3314
3329
|
});
|
|
3315
3330
|
ptySession.onExitDisposable = ptyProcess.onExit(({ exitCode }) => {
|
|
3316
3331
|
this.states?.exit(key, exitCode);
|
|
3317
|
-
const
|
|
3332
|
+
const message2 = JSON.stringify({ type: "exit", code: exitCode });
|
|
3318
3333
|
for (const client of ptySession.clients) {
|
|
3319
3334
|
try {
|
|
3320
|
-
client.send(
|
|
3335
|
+
client.send(message2);
|
|
3321
3336
|
} catch {
|
|
3322
3337
|
}
|
|
3323
3338
|
}
|
|
@@ -3371,11 +3386,11 @@ var init_pty_manager = __esm({
|
|
|
3371
3386
|
return this.sessions.get(sessionId);
|
|
3372
3387
|
}
|
|
3373
3388
|
// types a line into a live session, then Enter apart, so the agent's prompt takes it as typed and not as a paste
|
|
3374
|
-
typeLine(project, sessionDir,
|
|
3389
|
+
typeLine(project, sessionDir, text2) {
|
|
3375
3390
|
const session = this.sessions.get(this.makeKey(project, sessionDir));
|
|
3376
3391
|
if (!session)
|
|
3377
3392
|
return false;
|
|
3378
|
-
session.pty.write(
|
|
3393
|
+
session.pty.write(text2);
|
|
3379
3394
|
setTimeout(() => session.pty.write("\r"), 150);
|
|
3380
3395
|
return true;
|
|
3381
3396
|
}
|
|
@@ -3412,11 +3427,11 @@ var init_pty_manager = __esm({
|
|
|
3412
3427
|
});
|
|
3413
3428
|
|
|
3414
3429
|
// ../core/dist/state-classifier-local.js
|
|
3415
|
-
function latestMarker(
|
|
3430
|
+
function latestMarker(text2, markers) {
|
|
3416
3431
|
let best = null;
|
|
3417
3432
|
let bestAt = -1;
|
|
3418
3433
|
for (const marker of markers) {
|
|
3419
|
-
const at = lastIndex(
|
|
3434
|
+
const at = lastIndex(text2, marker.re);
|
|
3420
3435
|
if (at > bestAt) {
|
|
3421
3436
|
best = marker;
|
|
3422
3437
|
bestAt = at;
|
|
@@ -3451,9 +3466,9 @@ var init_state_classifier_local = __esm({
|
|
|
3451
3466
|
// a spinner that stopped moving: a stall or a slow redraw, so it is only a guess
|
|
3452
3467
|
{ state: "working", confidence: 0.5, re: new RegExp("\\p{Lu}\\p{Ll}+ing\u2026|\\(\\d+s \xB7 |esc to interrupt", "gu") }
|
|
3453
3468
|
];
|
|
3454
|
-
lastIndex = (
|
|
3469
|
+
lastIndex = (text2, re) => {
|
|
3455
3470
|
let at = -1;
|
|
3456
|
-
for (const m of
|
|
3471
|
+
for (const m of text2.matchAll(re))
|
|
3457
3472
|
at = (m.index ?? 0) + m[0].length;
|
|
3458
3473
|
return at;
|
|
3459
3474
|
};
|
|
@@ -3462,8 +3477,8 @@ var init_state_classifier_local = __esm({
|
|
|
3462
3477
|
});
|
|
3463
3478
|
|
|
3464
3479
|
// ../core/dist/state-classifier-jev.js
|
|
3465
|
-
function jevScreen(
|
|
3466
|
-
const kept =
|
|
3480
|
+
function jevScreen(text2, lines2 = SCREEN_LINES) {
|
|
3481
|
+
const kept = text2.split("\n").map((l) => l.replace(FOOTER_NOISE, "").trim()).filter(Boolean).filter((l, i, all) => l !== all[i - 1]).slice(-lines2).join("\n");
|
|
3467
3482
|
return kept.slice(-SCREEN_CHARS);
|
|
3468
3483
|
}
|
|
3469
3484
|
function createJevClassifier({ apiKey, model = "jev-latest", timeoutMs = 3e3, fetch: fetch2 = globalThis.fetch }) {
|
|
@@ -3556,11 +3571,11 @@ var init_terminal_screen = __esm({
|
|
|
3556
3571
|
const line = buffer.getLine(y);
|
|
3557
3572
|
if (!line)
|
|
3558
3573
|
continue;
|
|
3559
|
-
const
|
|
3574
|
+
const text2 = line.translateToString(false);
|
|
3560
3575
|
if (line.isWrapped && rows.length)
|
|
3561
|
-
rows[rows.length - 1] +=
|
|
3576
|
+
rows[rows.length - 1] += text2;
|
|
3562
3577
|
else
|
|
3563
|
-
rows.push(
|
|
3578
|
+
rows.push(text2);
|
|
3564
3579
|
}
|
|
3565
3580
|
const trimmed = rows.map((r) => r.trimEnd());
|
|
3566
3581
|
while (trimmed.length && !trimmed[trimmed.length - 1])
|
|
@@ -3992,8 +4007,8 @@ var init_liveframe = __esm({
|
|
|
3992
4007
|
init_output();
|
|
3993
4008
|
LiveframeError = class extends Error {
|
|
3994
4009
|
status;
|
|
3995
|
-
constructor(
|
|
3996
|
-
super(
|
|
4010
|
+
constructor(message2, status = 502) {
|
|
4011
|
+
super(message2);
|
|
3997
4012
|
this.status = status;
|
|
3998
4013
|
}
|
|
3999
4014
|
};
|
|
@@ -4299,785 +4314,301 @@ var init_cw_install = __esm({
|
|
|
4299
4314
|
}
|
|
4300
4315
|
});
|
|
4301
4316
|
|
|
4302
|
-
//
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
output = (output + data).slice(-64 * 1024);
|
|
4332
|
-
});
|
|
4333
|
-
proc.onExit(({ exitCode }) => {
|
|
4334
|
-
clearTimeout(timer);
|
|
4335
|
-
const json = stripAnsi(output).split(/\r?\n/).reverse().map((line) => line.slice(line.indexOf("{")).trim()).find((line) => parseJson(line) !== null);
|
|
4336
|
-
resolve10({ code: exitCode, stdout: json ?? "", stderr: output });
|
|
4337
|
-
});
|
|
4338
|
-
});
|
|
4339
|
-
}
|
|
4340
|
-
function parseJson(text) {
|
|
4341
|
-
try {
|
|
4342
|
-
return JSON.parse(text);
|
|
4343
|
-
} catch {
|
|
4344
|
-
return null;
|
|
4317
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
|
|
4318
|
+
var require_constants = __commonJS({
|
|
4319
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js"(exports, module) {
|
|
4320
|
+
"use strict";
|
|
4321
|
+
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
4322
|
+
var MAX_LENGTH = 256;
|
|
4323
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
4324
|
+
9007199254740991;
|
|
4325
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
4326
|
+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
4327
|
+
var RELEASE_TYPES = [
|
|
4328
|
+
"major",
|
|
4329
|
+
"premajor",
|
|
4330
|
+
"minor",
|
|
4331
|
+
"preminor",
|
|
4332
|
+
"patch",
|
|
4333
|
+
"prepatch",
|
|
4334
|
+
"prerelease"
|
|
4335
|
+
];
|
|
4336
|
+
module.exports = {
|
|
4337
|
+
MAX_LENGTH,
|
|
4338
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
4339
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
4340
|
+
MAX_SAFE_INTEGER,
|
|
4341
|
+
RELEASE_TYPES,
|
|
4342
|
+
SEMVER_SPEC_VERSION,
|
|
4343
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
4344
|
+
FLAG_LOOSE: 2
|
|
4345
|
+
};
|
|
4345
4346
|
}
|
|
4346
|
-
}
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
while (next < items.length) {
|
|
4352
|
-
const i = next++;
|
|
4353
|
-
out[i] = await fn(items[i]);
|
|
4354
|
-
}
|
|
4355
|
-
};
|
|
4356
|
-
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
4357
|
-
return out;
|
|
4358
|
-
}
|
|
4359
|
-
var PAGE_TYPES, KiokuError, NOT_INSTALLED, START_TIMEOUT_MS, WRITE_TIMEOUT_MS, PUBLISH_TIMEOUT_MS, CACHE_MS2, ACTIVITY_SINCE, ACTIVITY_LIMIT, PARALLEL, TIERS, REPO, AREA, LANGUAGE, MISSING, brainName, Kioku;
|
|
4360
|
-
var init_kioku = __esm({
|
|
4361
|
-
"../core/dist/kioku.js"() {
|
|
4347
|
+
});
|
|
4348
|
+
|
|
4349
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js
|
|
4350
|
+
var require_debug = __commonJS({
|
|
4351
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js"(exports, module) {
|
|
4362
4352
|
"use strict";
|
|
4363
|
-
|
|
4364
|
-
init_cw_doctor();
|
|
4365
|
-
init_cw_install();
|
|
4366
|
-
init_output();
|
|
4367
|
-
PAGE_TYPES = {
|
|
4368
|
-
memory: { kind: "memory" },
|
|
4369
|
-
instinct: { kind: "memory", sub: "instinct" },
|
|
4370
|
-
decision: { kind: "knowledge", sub: "decision" },
|
|
4371
|
-
playbook: { kind: "knowledge", sub: "playbook" },
|
|
4372
|
-
context: { kind: "knowledge", sub: "context" },
|
|
4373
|
-
rule: { kind: "rule" }
|
|
4353
|
+
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
|
|
4374
4354
|
};
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4355
|
+
module.exports = debug;
|
|
4356
|
+
}
|
|
4357
|
+
});
|
|
4358
|
+
|
|
4359
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js
|
|
4360
|
+
var require_re = __commonJS({
|
|
4361
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js"(exports, module) {
|
|
4362
|
+
"use strict";
|
|
4363
|
+
var {
|
|
4364
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
4365
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
4366
|
+
MAX_LENGTH
|
|
4367
|
+
} = require_constants();
|
|
4368
|
+
var debug = require_debug();
|
|
4369
|
+
exports = module.exports = {};
|
|
4370
|
+
var re = exports.re = [];
|
|
4371
|
+
var safeRe = exports.safeRe = [];
|
|
4372
|
+
var src = exports.src = [];
|
|
4373
|
+
var safeSrc = exports.safeSrc = [];
|
|
4374
|
+
var t = exports.t = {};
|
|
4375
|
+
var R = 0;
|
|
4376
|
+
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
4377
|
+
var safeRegexReplacements = [
|
|
4378
|
+
["\\s", 1],
|
|
4379
|
+
["\\d", MAX_LENGTH],
|
|
4380
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
4381
|
+
];
|
|
4382
|
+
var makeSafeRegex = (value) => {
|
|
4383
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
4384
|
+
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
4380
4385
|
}
|
|
4386
|
+
return value;
|
|
4381
4387
|
};
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4388
|
+
var createToken = (name, value, isGlobal) => {
|
|
4389
|
+
const safe = makeSafeRegex(value);
|
|
4390
|
+
const index = R++;
|
|
4391
|
+
debug(name, index, value);
|
|
4392
|
+
t[name] = index;
|
|
4393
|
+
src[index] = value;
|
|
4394
|
+
safeSrc[index] = safe;
|
|
4395
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
4396
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
4397
|
+
};
|
|
4398
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
4399
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
4400
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
4401
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
4402
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
4403
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
4404
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
4405
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
4406
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
4407
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
4408
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
4409
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
4410
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
4411
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
4412
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
4413
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
4414
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
4415
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
4416
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
4417
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
4418
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
4419
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
4420
|
+
createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
4421
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
4422
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
4423
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
4424
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
4425
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
4426
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
4427
|
+
exports.tildeTrimReplace = "$1~";
|
|
4428
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
4429
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
4430
|
+
createToken("LONECARET", "(?:\\^)");
|
|
4431
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
4432
|
+
exports.caretTrimReplace = "$1^";
|
|
4433
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
4434
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
4435
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
4436
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
4437
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
4438
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
4439
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
4440
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
4441
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
4442
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
4443
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
4444
|
+
}
|
|
4445
|
+
});
|
|
4446
|
+
|
|
4447
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js
|
|
4448
|
+
var require_parse_options = __commonJS({
|
|
4449
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js"(exports, module) {
|
|
4450
|
+
"use strict";
|
|
4451
|
+
var looseOption = Object.freeze({ loose: true });
|
|
4452
|
+
var emptyOpts = Object.freeze({});
|
|
4453
|
+
var parseOptions = (options) => {
|
|
4454
|
+
if (!options) {
|
|
4455
|
+
return emptyOpts;
|
|
4414
4456
|
}
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
return this.binPath ??= resolveKiokuBin();
|
|
4457
|
+
if (typeof options !== "object") {
|
|
4458
|
+
return looseOption;
|
|
4418
4459
|
}
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4460
|
+
return options;
|
|
4461
|
+
};
|
|
4462
|
+
module.exports = parseOptions;
|
|
4463
|
+
}
|
|
4464
|
+
});
|
|
4465
|
+
|
|
4466
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js
|
|
4467
|
+
var require_identifiers = __commonJS({
|
|
4468
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js"(exports, module) {
|
|
4469
|
+
"use strict";
|
|
4470
|
+
var numeric2 = /^[0-9]+$/;
|
|
4471
|
+
var compareIdentifiers = (a, b) => {
|
|
4472
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
4473
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
4432
4474
|
}
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4475
|
+
const anum = numeric2.test(a);
|
|
4476
|
+
const bnum = numeric2.test(b);
|
|
4477
|
+
if (anum && bnum) {
|
|
4478
|
+
a = +a;
|
|
4479
|
+
b = +b;
|
|
4436
4480
|
}
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
};
|
|
4461
|
-
const readChain = async (path) => (await this.json(["brain", "list"], path))?.chain ?? [];
|
|
4462
|
-
const [perBrain, chains] = await Promise.all([
|
|
4463
|
-
mapLimit(listed, PARALLEL / 2, readBrain),
|
|
4464
|
-
mapLimit(entries, PARALLEL / 2, ([, p]) => readChain(p.path))
|
|
4465
|
-
]);
|
|
4466
|
-
const activity = perBrain.flatMap((p) => p.writes).sort((x, y) => y.date.localeCompare(x.date));
|
|
4467
|
-
const brains = listed.map((b, i) => {
|
|
4468
|
-
const { kinds, namespaces } = perBrain[i];
|
|
4469
|
-
const name = brainName(b);
|
|
4470
|
-
return {
|
|
4471
|
-
...b,
|
|
4472
|
-
pages: Object.values(kinds).reduce((sum, n) => sum + n, 0),
|
|
4473
|
-
kinds,
|
|
4474
|
-
namespaces,
|
|
4475
|
-
touched: activity.find((w) => w.brain === name)?.date ?? null
|
|
4476
|
-
};
|
|
4477
|
-
});
|
|
4478
|
-
const projects = Object.fromEntries(entries.map(([name], i) => [name, chains[i].map(({ name: name2, tier }) => ({ name: name2, tier }))]));
|
|
4479
|
-
return {
|
|
4480
|
-
installed: true,
|
|
4481
|
-
version: parseJson(version.stdout)?.version ?? null,
|
|
4482
|
-
brains,
|
|
4483
|
-
projects,
|
|
4484
|
-
activity: activity.slice(0, ACTIVITY_LIMIT).map(({ verb, title, path, date, author, brain }) => ({ verb, title, path, date, author, brain }))
|
|
4485
|
-
};
|
|
4481
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
4482
|
+
};
|
|
4483
|
+
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
4484
|
+
module.exports = {
|
|
4485
|
+
compareIdentifiers,
|
|
4486
|
+
rcompareIdentifiers
|
|
4487
|
+
};
|
|
4488
|
+
}
|
|
4489
|
+
});
|
|
4490
|
+
|
|
4491
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js
|
|
4492
|
+
var require_semver = __commonJS({
|
|
4493
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js"(exports, module) {
|
|
4494
|
+
"use strict";
|
|
4495
|
+
var debug = require_debug();
|
|
4496
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
4497
|
+
var { safeRe: re, t } = require_re();
|
|
4498
|
+
var parseOptions = require_parse_options();
|
|
4499
|
+
var { compareIdentifiers } = require_identifiers();
|
|
4500
|
+
var isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
4501
|
+
const identifiers = identifier.split(".");
|
|
4502
|
+
if (identifiers.length > prerelease.length) {
|
|
4503
|
+
return false;
|
|
4486
4504
|
}
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
if (!type)
|
|
4491
|
-
throw new KiokuError(`unknown page type ${input.type}`, 400);
|
|
4492
|
-
const brain = await this.findBrain(input.brain);
|
|
4493
|
-
const args = [
|
|
4494
|
-
"page",
|
|
4495
|
-
"save",
|
|
4496
|
-
"--brain",
|
|
4497
|
-
brain.key,
|
|
4498
|
-
"--kind",
|
|
4499
|
-
type.kind,
|
|
4500
|
-
...type.sub ? ["--sub", type.sub] : [],
|
|
4501
|
-
"--title",
|
|
4502
|
-
input.title,
|
|
4503
|
-
"--summary",
|
|
4504
|
-
input.summary,
|
|
4505
|
-
"--source",
|
|
4506
|
-
"Forge",
|
|
4507
|
-
...input.namespace ? ["--namespace", input.namespace] : [],
|
|
4508
|
-
...input.create ? ["--create"] : [],
|
|
4509
|
-
"--json"
|
|
4510
|
-
];
|
|
4511
|
-
const { out, fail } = await this.invoke(args, brain.folder, this.write, input.body);
|
|
4512
|
-
if (out?.status === "done" && out.path) {
|
|
4513
|
-
this.expire();
|
|
4514
|
-
return { status: "done", brain: brainName(brain), path: out.path, publication: out.publication ?? null };
|
|
4505
|
+
for (let i = 0; i < identifiers.length; i++) {
|
|
4506
|
+
if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
|
|
4507
|
+
return false;
|
|
4515
4508
|
}
|
|
4516
|
-
if (out?.status === "similar")
|
|
4517
|
-
return { status: "similar", similar: (out.similar ?? []).map(({ brain: brain2, path, title, summary }) => ({ brain: brain2, path, title, summary })) };
|
|
4518
|
-
if (out?.status === "namespace")
|
|
4519
|
-
return { status: "namespace", namespaces: (out.namespaces ?? []).map(({ namespace, summary }) => ({ namespace, summary })) };
|
|
4520
|
-
throw fail("kioku could not save the page");
|
|
4521
4509
|
}
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4510
|
+
return true;
|
|
4511
|
+
};
|
|
4512
|
+
var SemVer = class _SemVer {
|
|
4513
|
+
constructor(version, options) {
|
|
4514
|
+
options = parseOptions(options);
|
|
4515
|
+
if (version instanceof _SemVer) {
|
|
4516
|
+
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
4517
|
+
return version;
|
|
4518
|
+
} else {
|
|
4519
|
+
version = version.version;
|
|
4520
|
+
}
|
|
4521
|
+
} else if (typeof version !== "string") {
|
|
4522
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
4523
|
+
}
|
|
4524
|
+
if (version.length > MAX_LENGTH) {
|
|
4525
|
+
throw new TypeError(
|
|
4526
|
+
`version is longer than ${MAX_LENGTH} characters`
|
|
4527
|
+
);
|
|
4528
|
+
}
|
|
4529
|
+
debug("SemVer", version, options);
|
|
4530
|
+
this.options = options;
|
|
4531
|
+
this.loose = !!options.loose;
|
|
4532
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
4533
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
4534
|
+
if (!m) {
|
|
4535
|
+
throw new TypeError(`Invalid Version: ${version}`);
|
|
4536
|
+
}
|
|
4537
|
+
this.raw = version;
|
|
4538
|
+
this.major = +m[1];
|
|
4539
|
+
this.minor = +m[2];
|
|
4540
|
+
this.patch = +m[3];
|
|
4541
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
4542
|
+
throw new TypeError("Invalid major version");
|
|
4543
|
+
}
|
|
4544
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
4545
|
+
throw new TypeError("Invalid minor version");
|
|
4546
|
+
}
|
|
4547
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
4548
|
+
throw new TypeError("Invalid patch version");
|
|
4549
|
+
}
|
|
4550
|
+
if (!m[4]) {
|
|
4551
|
+
this.prerelease = [];
|
|
4552
|
+
} else {
|
|
4553
|
+
this.prerelease = m[4].split(".").map((id) => {
|
|
4554
|
+
if (/^[0-9]+$/.test(id)) {
|
|
4555
|
+
const num2 = +id;
|
|
4556
|
+
if (num2 >= 0 && num2 < MAX_SAFE_INTEGER) {
|
|
4557
|
+
return num2;
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
return id;
|
|
4561
|
+
});
|
|
4562
|
+
}
|
|
4563
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
4564
|
+
this.format();
|
|
4525
4565
|
}
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
if (
|
|
4529
|
-
|
|
4530
|
-
|
|
4566
|
+
format() {
|
|
4567
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
4568
|
+
if (this.prerelease.length) {
|
|
4569
|
+
this.version += `-${this.prerelease.join(".")}`;
|
|
4570
|
+
}
|
|
4571
|
+
return this.version;
|
|
4531
4572
|
}
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
if (this.snapshot)
|
|
4535
|
-
this.snapshot.at = -Infinity;
|
|
4573
|
+
toString() {
|
|
4574
|
+
return this.version;
|
|
4536
4575
|
}
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4576
|
+
compare(other) {
|
|
4577
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
4578
|
+
if (!(other instanceof _SemVer)) {
|
|
4579
|
+
if (typeof other === "string" && other === this.version) {
|
|
4580
|
+
return 0;
|
|
4581
|
+
}
|
|
4582
|
+
other = new _SemVer(other, this.options);
|
|
4583
|
+
}
|
|
4584
|
+
if (other.version === this.version) {
|
|
4585
|
+
return 0;
|
|
4586
|
+
}
|
|
4587
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
4544
4588
|
}
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
this.
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
if (
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
...input.language ? ["--language", input.language] : []
|
|
4569
|
-
];
|
|
4570
|
-
const { brain, name, path } = await this.change(args, homedir5());
|
|
4571
|
-
return { brain, name, path };
|
|
4572
|
-
}
|
|
4573
|
-
async addArea(key, area, summary) {
|
|
4574
|
-
if (!AREA.test(area))
|
|
4575
|
-
throw new KiokuError("an area is letters, digits, dots, dashes and underscores, with / between parts", 400);
|
|
4576
|
-
if (!summary)
|
|
4577
|
-
throw new KiokuError("say what the area is for", 400);
|
|
4578
|
-
const brain = await this.findBrain(key);
|
|
4579
|
-
const out = await this.change(["namespace", "add", area, `--summary=${summary}`, "--brain", brain.key], brain.folder);
|
|
4580
|
-
return { brain: out.brain, namespace: out.namespace };
|
|
4581
|
-
}
|
|
4582
|
-
// writes the project's kioku.yaml; a brain the machine does not know is made first, since kioku links only known brains without a terminal
|
|
4583
|
-
async linkProject(input) {
|
|
4584
|
-
if (!input.brain && !input.team)
|
|
4585
|
-
throw new KiokuError("name a project brain, a team brain, or both", 400);
|
|
4586
|
-
const path = this.projects()[input.project]?.path;
|
|
4587
|
-
if (!path || !existsSync12(path))
|
|
4588
|
-
throw new KiokuError(`no CW project ${input.project} on this machine`, 404);
|
|
4589
|
-
if (input.brain)
|
|
4590
|
-
assertRepo(input.brain, "the project brain");
|
|
4591
|
-
if (input.team)
|
|
4592
|
-
assertRepo(input.team, "the team brain");
|
|
4593
|
-
const known = await this.listBrains();
|
|
4594
|
-
const isKnown = (repo) => known.some((b) => b.key === repo || b.key.endsWith(`/${repo}`));
|
|
4595
|
-
const created = [];
|
|
4596
|
-
if (input.team && !isKnown(input.team))
|
|
4597
|
-
created.push((await this.createBrain({ repo: input.team, tier: "team" })).brain);
|
|
4598
|
-
if (input.brain && !isKnown(input.brain))
|
|
4599
|
-
created.push((await this.createBrain({ repo: input.brain, tier: "project", team: input.team })).brain);
|
|
4600
|
-
const args = ["init", ...input.brain ? [input.brain] : [], ...input.team ? ["--team", input.team] : []];
|
|
4601
|
-
const { file } = await this.change(args, path);
|
|
4602
|
-
return { file, created };
|
|
4603
|
-
}
|
|
4604
|
-
// the only verb that reaches a git host: without `to`, kioku makes a private GitHub repository with gh
|
|
4605
|
-
async publish(key, to) {
|
|
4606
|
-
if (to?.startsWith("-"))
|
|
4607
|
-
throw new KiokuError("the address cannot start with -", 400);
|
|
4608
|
-
const brain = await this.findBrain(key);
|
|
4609
|
-
if (brain.remote)
|
|
4610
|
-
throw new KiokuError(`${brainName(brain)} already has a repository: ${brain.remote}`, 400);
|
|
4611
|
-
const out = await this.change(["brain", "publish", brain.key, ...to ? ["--to", to] : []], brain.folder, this.terminal ??= createTerminalRunner(envWithoutHost(), PUBLISH_TIMEOUT_MS));
|
|
4612
|
-
return { brain: out.brain, status: out.status, remote: out.remote ?? null };
|
|
4613
|
-
}
|
|
4614
|
-
// one viewer at a time; a second call reuses the running one
|
|
4615
|
-
async openViewer() {
|
|
4616
|
-
this.viewer ??= this.startViewer();
|
|
4617
|
-
return (await this.viewer).address;
|
|
4618
|
-
}
|
|
4619
|
-
startViewer() {
|
|
4620
|
-
const started = new Promise((resolve10, reject) => {
|
|
4621
|
-
const child = spawn7(this.bin, ["web", "--json", "--no-open"], { cwd: homedir5(), stdio: ["ignore", "pipe", "pipe"] });
|
|
4622
|
-
const lines2 = createInterface({ input: child.stdout });
|
|
4623
|
-
let stderr = "";
|
|
4624
|
-
let settled = false;
|
|
4625
|
-
const finish = () => {
|
|
4626
|
-
settled = true;
|
|
4627
|
-
clearTimeout(timer);
|
|
4628
|
-
lines2.close();
|
|
4629
|
-
child.stdout?.resume();
|
|
4630
|
-
};
|
|
4631
|
-
const fail = (err) => {
|
|
4632
|
-
if (settled)
|
|
4633
|
-
return;
|
|
4634
|
-
finish();
|
|
4635
|
-
child.kill();
|
|
4636
|
-
reject(err);
|
|
4637
|
-
};
|
|
4638
|
-
const timer = setTimeout(() => fail(new KiokuError("kioku web did not start in time")), this.startTimeoutMs);
|
|
4639
|
-
child.stderr?.on("data", (chunk) => {
|
|
4640
|
-
stderr = (stderr + chunk.toString()).slice(-4096);
|
|
4641
|
-
});
|
|
4642
|
-
lines2.on("line", (line) => {
|
|
4643
|
-
const event = parseJson(line);
|
|
4644
|
-
if (settled || event?.event !== "listening" || !event.address?.startsWith("http://127.0.0.1:"))
|
|
4645
|
-
return;
|
|
4646
|
-
finish();
|
|
4647
|
-
resolve10({ child, address: event.address });
|
|
4648
|
-
});
|
|
4649
|
-
child.on("error", (err) => {
|
|
4650
|
-
const missing = err.code === "ENOENT";
|
|
4651
|
-
fail(new KiokuError(missing ? NOT_INSTALLED : err.message, missing ? 404 : 502));
|
|
4652
|
-
});
|
|
4653
|
-
child.on("close", (code) => {
|
|
4654
|
-
if (this.viewer === started)
|
|
4655
|
-
this.viewer = null;
|
|
4656
|
-
fail(new KiokuError(tailOutput(stderr, 1) || `kioku web exited with code ${code}`));
|
|
4657
|
-
});
|
|
4658
|
-
});
|
|
4659
|
-
started.catch(() => {
|
|
4660
|
-
if (this.viewer === started)
|
|
4661
|
-
this.viewer = null;
|
|
4662
|
-
});
|
|
4663
|
-
return started;
|
|
4664
|
-
}
|
|
4665
|
-
stopViewer() {
|
|
4666
|
-
void this.viewer?.then((v) => v.child.kill(), () => {
|
|
4667
|
-
});
|
|
4668
|
-
this.viewer = null;
|
|
4669
|
-
}
|
|
4670
|
-
dispose() {
|
|
4671
|
-
this.stopViewer();
|
|
4672
|
-
}
|
|
4673
|
-
};
|
|
4674
|
-
}
|
|
4675
|
-
});
|
|
4676
|
-
|
|
4677
|
-
// ../core/dist/kioku-routes.js
|
|
4678
|
-
import { Hono as Hono4 } from "hono";
|
|
4679
|
-
function kiokuRoutes(kioku = new Kioku(), options = {}) {
|
|
4680
|
-
const app = new Hono4();
|
|
4681
|
-
app.onError((err, c) => {
|
|
4682
|
-
if (err instanceof KiokuError)
|
|
4683
|
-
return c.json({ error: err.message }, err.status);
|
|
4684
|
-
throw err;
|
|
4685
|
-
});
|
|
4686
|
-
app.get("/status", async (c) => c.json(await kioku.status(c.req.query("fresh") === "1")));
|
|
4687
|
-
app.post("/pages", async (c) => {
|
|
4688
|
-
const input = await c.req.json().catch(() => ({}));
|
|
4689
|
-
const brain = input.brain?.trim();
|
|
4690
|
-
const title = input.title?.trim();
|
|
4691
|
-
const summary = input.summary?.trim();
|
|
4692
|
-
if (!brain || !input.type || !title || !summary || !input.body?.trim())
|
|
4693
|
-
return c.json({ error: "brain, type, title, summary and body are required" }, 400);
|
|
4694
|
-
const result2 = await kioku.save({ brain, type: input.type, title, summary, body: input.body, namespace: input.namespace?.trim() || void 0, create: input.create === true });
|
|
4695
|
-
return c.json(result2, result2.status === "done" ? 201 : 200);
|
|
4696
|
-
});
|
|
4697
|
-
app.post("/brains", async (c) => {
|
|
4698
|
-
const { repo, tier, team, language } = await body(c);
|
|
4699
|
-
return c.json(await kioku.createBrain({ repo: trim(repo) ?? "", tier: tier ?? "", team: trim(team), language: trim(language) }), 201);
|
|
4700
|
-
});
|
|
4701
|
-
app.post("/areas", async (c) => {
|
|
4702
|
-
const { brain, area, summary } = await body(c);
|
|
4703
|
-
return c.json(await kioku.addArea(brain ?? "", trim(area) ?? "", trim(summary) ?? ""), 201);
|
|
4704
|
-
});
|
|
4705
|
-
app.post("/link", async (c) => {
|
|
4706
|
-
const { project, brain, team } = await body(c);
|
|
4707
|
-
return c.json(await kioku.linkProject({ project: project ?? "", brain: trim(brain), team: trim(team) }));
|
|
4708
|
-
});
|
|
4709
|
-
app.post("/publish", async (c) => {
|
|
4710
|
-
const { brain, to, understood } = await body(c);
|
|
4711
|
-
if (understood !== true)
|
|
4712
|
-
return c.json({ error: "publishing needs the warning accepted" }, 400);
|
|
4713
|
-
return c.json(await kioku.publish(brain ?? "", trim(to)));
|
|
4714
|
-
});
|
|
4715
|
-
app.post("/remember", async (c) => {
|
|
4716
|
-
const { project, sessionDir, text } = await c.req.json().catch(() => ({}));
|
|
4717
|
-
const line = text?.trim();
|
|
4718
|
-
if (!project || !sessionDir || !line)
|
|
4719
|
-
return c.json({ error: "project, sessionDir and text are required" }, 400);
|
|
4720
|
-
if (line.length > REMEMBER_MAX)
|
|
4721
|
-
return c.json({ error: `keep it under ${REMEMBER_MAX} characters` }, 400);
|
|
4722
|
-
if (options.canRemember && !options.canRemember(project, sessionDir))
|
|
4723
|
-
return c.json({ error: "only Claude Code sessions have kioku's skill" }, 400);
|
|
4724
|
-
if (!options.type?.(project, sessionDir, rememberPrompt(line)))
|
|
4725
|
-
return c.json({ error: "the session has no live terminal" }, 409);
|
|
4726
|
-
return c.json({ ok: true });
|
|
4727
|
-
});
|
|
4728
|
-
app.post("/viewer", async (c) => c.json({ address: await kioku.openViewer() }));
|
|
4729
|
-
app.delete("/viewer", (c) => {
|
|
4730
|
-
kioku.stopViewer();
|
|
4731
|
-
return c.json({ ok: true });
|
|
4732
|
-
});
|
|
4733
|
-
return app;
|
|
4734
|
-
}
|
|
4735
|
-
var trim, REMEMBER_MAX, body;
|
|
4736
|
-
var init_kioku_routes = __esm({
|
|
4737
|
-
"../core/dist/kioku-routes.js"() {
|
|
4738
|
-
"use strict";
|
|
4739
|
-
init_kioku();
|
|
4740
|
-
trim = (value) => value?.trim() || void 0;
|
|
4741
|
-
REMEMBER_MAX = 500;
|
|
4742
|
-
body = (c) => c.req.json().catch(() => ({}));
|
|
4743
|
-
}
|
|
4744
|
-
});
|
|
4745
|
-
|
|
4746
|
-
// ../sdk/dist/define.js
|
|
4747
|
-
function isShellExecutor(run2) {
|
|
4748
|
-
return typeof run2 === "object" && run2 !== null && run2.kind === "shell";
|
|
4749
|
-
}
|
|
4750
|
-
var SDK_VERSION, MODULE_ID_RE;
|
|
4751
|
-
var init_define = __esm({
|
|
4752
|
-
"../sdk/dist/define.js"() {
|
|
4753
|
-
"use strict";
|
|
4754
|
-
SDK_VERSION = "1.0.0";
|
|
4755
|
-
MODULE_ID_RE = /^[a-z][a-z0-9-]{1,31}$/;
|
|
4756
|
-
}
|
|
4757
|
-
});
|
|
4758
|
-
|
|
4759
|
-
// ../sdk/dist/errors.js
|
|
4760
|
-
var PermissionError;
|
|
4761
|
-
var init_errors = __esm({
|
|
4762
|
-
"../sdk/dist/errors.js"() {
|
|
4763
|
-
"use strict";
|
|
4764
|
-
PermissionError = class extends Error {
|
|
4765
|
-
permission;
|
|
4766
|
-
value;
|
|
4767
|
-
constructor(permission, value) {
|
|
4768
|
-
super(`permission ${permission} does not cover ${value}`);
|
|
4769
|
-
this.name = "PermissionError";
|
|
4770
|
-
this.permission = permission;
|
|
4771
|
-
this.value = value;
|
|
4772
|
-
}
|
|
4773
|
-
};
|
|
4774
|
-
}
|
|
4775
|
-
});
|
|
4776
|
-
|
|
4777
|
-
// ../sdk/dist/index.js
|
|
4778
|
-
var init_dist = __esm({
|
|
4779
|
-
"../sdk/dist/index.js"() {
|
|
4780
|
-
"use strict";
|
|
4781
|
-
init_define();
|
|
4782
|
-
init_errors();
|
|
4783
|
-
}
|
|
4784
|
-
});
|
|
4785
|
-
|
|
4786
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
|
|
4787
|
-
var require_constants = __commonJS({
|
|
4788
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js"(exports, module) {
|
|
4789
|
-
"use strict";
|
|
4790
|
-
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
4791
|
-
var MAX_LENGTH = 256;
|
|
4792
|
-
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
4793
|
-
9007199254740991;
|
|
4794
|
-
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
4795
|
-
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
4796
|
-
var RELEASE_TYPES = [
|
|
4797
|
-
"major",
|
|
4798
|
-
"premajor",
|
|
4799
|
-
"minor",
|
|
4800
|
-
"preminor",
|
|
4801
|
-
"patch",
|
|
4802
|
-
"prepatch",
|
|
4803
|
-
"prerelease"
|
|
4804
|
-
];
|
|
4805
|
-
module.exports = {
|
|
4806
|
-
MAX_LENGTH,
|
|
4807
|
-
MAX_SAFE_COMPONENT_LENGTH,
|
|
4808
|
-
MAX_SAFE_BUILD_LENGTH,
|
|
4809
|
-
MAX_SAFE_INTEGER,
|
|
4810
|
-
RELEASE_TYPES,
|
|
4811
|
-
SEMVER_SPEC_VERSION,
|
|
4812
|
-
FLAG_INCLUDE_PRERELEASE: 1,
|
|
4813
|
-
FLAG_LOOSE: 2
|
|
4814
|
-
};
|
|
4815
|
-
}
|
|
4816
|
-
});
|
|
4817
|
-
|
|
4818
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js
|
|
4819
|
-
var require_debug = __commonJS({
|
|
4820
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js"(exports, module) {
|
|
4821
|
-
"use strict";
|
|
4822
|
-
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
|
|
4823
|
-
};
|
|
4824
|
-
module.exports = debug;
|
|
4825
|
-
}
|
|
4826
|
-
});
|
|
4827
|
-
|
|
4828
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js
|
|
4829
|
-
var require_re = __commonJS({
|
|
4830
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js"(exports, module) {
|
|
4831
|
-
"use strict";
|
|
4832
|
-
var {
|
|
4833
|
-
MAX_SAFE_COMPONENT_LENGTH,
|
|
4834
|
-
MAX_SAFE_BUILD_LENGTH,
|
|
4835
|
-
MAX_LENGTH
|
|
4836
|
-
} = require_constants();
|
|
4837
|
-
var debug = require_debug();
|
|
4838
|
-
exports = module.exports = {};
|
|
4839
|
-
var re = exports.re = [];
|
|
4840
|
-
var safeRe = exports.safeRe = [];
|
|
4841
|
-
var src = exports.src = [];
|
|
4842
|
-
var safeSrc = exports.safeSrc = [];
|
|
4843
|
-
var t = exports.t = {};
|
|
4844
|
-
var R = 0;
|
|
4845
|
-
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
4846
|
-
var safeRegexReplacements = [
|
|
4847
|
-
["\\s", 1],
|
|
4848
|
-
["\\d", MAX_LENGTH],
|
|
4849
|
-
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
4850
|
-
];
|
|
4851
|
-
var makeSafeRegex = (value) => {
|
|
4852
|
-
for (const [token, max] of safeRegexReplacements) {
|
|
4853
|
-
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
4854
|
-
}
|
|
4855
|
-
return value;
|
|
4856
|
-
};
|
|
4857
|
-
var createToken = (name, value, isGlobal) => {
|
|
4858
|
-
const safe = makeSafeRegex(value);
|
|
4859
|
-
const index = R++;
|
|
4860
|
-
debug(name, index, value);
|
|
4861
|
-
t[name] = index;
|
|
4862
|
-
src[index] = value;
|
|
4863
|
-
safeSrc[index] = safe;
|
|
4864
|
-
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
4865
|
-
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
4866
|
-
};
|
|
4867
|
-
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
4868
|
-
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
4869
|
-
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
4870
|
-
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
4871
|
-
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
4872
|
-
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
4873
|
-
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
4874
|
-
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
4875
|
-
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
4876
|
-
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
4877
|
-
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
4878
|
-
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
4879
|
-
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
4880
|
-
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
4881
|
-
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
4882
|
-
createToken("GTLT", "((?:<|>)?=?)");
|
|
4883
|
-
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
4884
|
-
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
4885
|
-
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
4886
|
-
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
4887
|
-
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
4888
|
-
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
4889
|
-
createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
4890
|
-
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
4891
|
-
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
4892
|
-
createToken("COERCERTL", src[t.COERCE], true);
|
|
4893
|
-
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
4894
|
-
createToken("LONETILDE", "(?:~>?)");
|
|
4895
|
-
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
4896
|
-
exports.tildeTrimReplace = "$1~";
|
|
4897
|
-
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
4898
|
-
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
4899
|
-
createToken("LONECARET", "(?:\\^)");
|
|
4900
|
-
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
4901
|
-
exports.caretTrimReplace = "$1^";
|
|
4902
|
-
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
4903
|
-
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
4904
|
-
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
4905
|
-
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
4906
|
-
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
4907
|
-
exports.comparatorTrimReplace = "$1$2$3";
|
|
4908
|
-
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
4909
|
-
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
4910
|
-
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
4911
|
-
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
4912
|
-
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
4913
|
-
}
|
|
4914
|
-
});
|
|
4915
|
-
|
|
4916
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js
|
|
4917
|
-
var require_parse_options = __commonJS({
|
|
4918
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js"(exports, module) {
|
|
4919
|
-
"use strict";
|
|
4920
|
-
var looseOption = Object.freeze({ loose: true });
|
|
4921
|
-
var emptyOpts = Object.freeze({});
|
|
4922
|
-
var parseOptions = (options) => {
|
|
4923
|
-
if (!options) {
|
|
4924
|
-
return emptyOpts;
|
|
4925
|
-
}
|
|
4926
|
-
if (typeof options !== "object") {
|
|
4927
|
-
return looseOption;
|
|
4928
|
-
}
|
|
4929
|
-
return options;
|
|
4930
|
-
};
|
|
4931
|
-
module.exports = parseOptions;
|
|
4932
|
-
}
|
|
4933
|
-
});
|
|
4934
|
-
|
|
4935
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js
|
|
4936
|
-
var require_identifiers = __commonJS({
|
|
4937
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js"(exports, module) {
|
|
4938
|
-
"use strict";
|
|
4939
|
-
var numeric2 = /^[0-9]+$/;
|
|
4940
|
-
var compareIdentifiers = (a, b) => {
|
|
4941
|
-
if (typeof a === "number" && typeof b === "number") {
|
|
4942
|
-
return a === b ? 0 : a < b ? -1 : 1;
|
|
4943
|
-
}
|
|
4944
|
-
const anum = numeric2.test(a);
|
|
4945
|
-
const bnum = numeric2.test(b);
|
|
4946
|
-
if (anum && bnum) {
|
|
4947
|
-
a = +a;
|
|
4948
|
-
b = +b;
|
|
4949
|
-
}
|
|
4950
|
-
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
4951
|
-
};
|
|
4952
|
-
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
4953
|
-
module.exports = {
|
|
4954
|
-
compareIdentifiers,
|
|
4955
|
-
rcompareIdentifiers
|
|
4956
|
-
};
|
|
4957
|
-
}
|
|
4958
|
-
});
|
|
4959
|
-
|
|
4960
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js
|
|
4961
|
-
var require_semver = __commonJS({
|
|
4962
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js"(exports, module) {
|
|
4963
|
-
"use strict";
|
|
4964
|
-
var debug = require_debug();
|
|
4965
|
-
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
4966
|
-
var { safeRe: re, t } = require_re();
|
|
4967
|
-
var parseOptions = require_parse_options();
|
|
4968
|
-
var { compareIdentifiers } = require_identifiers();
|
|
4969
|
-
var isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
4970
|
-
const identifiers = identifier.split(".");
|
|
4971
|
-
if (identifiers.length > prerelease.length) {
|
|
4972
|
-
return false;
|
|
4973
|
-
}
|
|
4974
|
-
for (let i = 0; i < identifiers.length; i++) {
|
|
4975
|
-
if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
|
|
4976
|
-
return false;
|
|
4977
|
-
}
|
|
4978
|
-
}
|
|
4979
|
-
return true;
|
|
4980
|
-
};
|
|
4981
|
-
var SemVer = class _SemVer {
|
|
4982
|
-
constructor(version, options) {
|
|
4983
|
-
options = parseOptions(options);
|
|
4984
|
-
if (version instanceof _SemVer) {
|
|
4985
|
-
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
4986
|
-
return version;
|
|
4987
|
-
} else {
|
|
4988
|
-
version = version.version;
|
|
4989
|
-
}
|
|
4990
|
-
} else if (typeof version !== "string") {
|
|
4991
|
-
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
4992
|
-
}
|
|
4993
|
-
if (version.length > MAX_LENGTH) {
|
|
4994
|
-
throw new TypeError(
|
|
4995
|
-
`version is longer than ${MAX_LENGTH} characters`
|
|
4996
|
-
);
|
|
4997
|
-
}
|
|
4998
|
-
debug("SemVer", version, options);
|
|
4999
|
-
this.options = options;
|
|
5000
|
-
this.loose = !!options.loose;
|
|
5001
|
-
this.includePrerelease = !!options.includePrerelease;
|
|
5002
|
-
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
5003
|
-
if (!m) {
|
|
5004
|
-
throw new TypeError(`Invalid Version: ${version}`);
|
|
5005
|
-
}
|
|
5006
|
-
this.raw = version;
|
|
5007
|
-
this.major = +m[1];
|
|
5008
|
-
this.minor = +m[2];
|
|
5009
|
-
this.patch = +m[3];
|
|
5010
|
-
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
5011
|
-
throw new TypeError("Invalid major version");
|
|
5012
|
-
}
|
|
5013
|
-
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
5014
|
-
throw new TypeError("Invalid minor version");
|
|
5015
|
-
}
|
|
5016
|
-
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
5017
|
-
throw new TypeError("Invalid patch version");
|
|
5018
|
-
}
|
|
5019
|
-
if (!m[4]) {
|
|
5020
|
-
this.prerelease = [];
|
|
5021
|
-
} else {
|
|
5022
|
-
this.prerelease = m[4].split(".").map((id) => {
|
|
5023
|
-
if (/^[0-9]+$/.test(id)) {
|
|
5024
|
-
const num2 = +id;
|
|
5025
|
-
if (num2 >= 0 && num2 < MAX_SAFE_INTEGER) {
|
|
5026
|
-
return num2;
|
|
5027
|
-
}
|
|
5028
|
-
}
|
|
5029
|
-
return id;
|
|
5030
|
-
});
|
|
5031
|
-
}
|
|
5032
|
-
this.build = m[5] ? m[5].split(".") : [];
|
|
5033
|
-
this.format();
|
|
5034
|
-
}
|
|
5035
|
-
format() {
|
|
5036
|
-
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
5037
|
-
if (this.prerelease.length) {
|
|
5038
|
-
this.version += `-${this.prerelease.join(".")}`;
|
|
5039
|
-
}
|
|
5040
|
-
return this.version;
|
|
5041
|
-
}
|
|
5042
|
-
toString() {
|
|
5043
|
-
return this.version;
|
|
5044
|
-
}
|
|
5045
|
-
compare(other) {
|
|
5046
|
-
debug("SemVer.compare", this.version, this.options, other);
|
|
5047
|
-
if (!(other instanceof _SemVer)) {
|
|
5048
|
-
if (typeof other === "string" && other === this.version) {
|
|
5049
|
-
return 0;
|
|
5050
|
-
}
|
|
5051
|
-
other = new _SemVer(other, this.options);
|
|
5052
|
-
}
|
|
5053
|
-
if (other.version === this.version) {
|
|
5054
|
-
return 0;
|
|
5055
|
-
}
|
|
5056
|
-
return this.compareMain(other) || this.comparePre(other);
|
|
5057
|
-
}
|
|
5058
|
-
compareMain(other) {
|
|
5059
|
-
if (!(other instanceof _SemVer)) {
|
|
5060
|
-
other = new _SemVer(other, this.options);
|
|
5061
|
-
}
|
|
5062
|
-
if (this.major < other.major) {
|
|
5063
|
-
return -1;
|
|
5064
|
-
}
|
|
5065
|
-
if (this.major > other.major) {
|
|
5066
|
-
return 1;
|
|
5067
|
-
}
|
|
5068
|
-
if (this.minor < other.minor) {
|
|
5069
|
-
return -1;
|
|
5070
|
-
}
|
|
5071
|
-
if (this.minor > other.minor) {
|
|
5072
|
-
return 1;
|
|
5073
|
-
}
|
|
5074
|
-
if (this.patch < other.patch) {
|
|
5075
|
-
return -1;
|
|
5076
|
-
}
|
|
5077
|
-
if (this.patch > other.patch) {
|
|
5078
|
-
return 1;
|
|
5079
|
-
}
|
|
5080
|
-
return 0;
|
|
4589
|
+
compareMain(other) {
|
|
4590
|
+
if (!(other instanceof _SemVer)) {
|
|
4591
|
+
other = new _SemVer(other, this.options);
|
|
4592
|
+
}
|
|
4593
|
+
if (this.major < other.major) {
|
|
4594
|
+
return -1;
|
|
4595
|
+
}
|
|
4596
|
+
if (this.major > other.major) {
|
|
4597
|
+
return 1;
|
|
4598
|
+
}
|
|
4599
|
+
if (this.minor < other.minor) {
|
|
4600
|
+
return -1;
|
|
4601
|
+
}
|
|
4602
|
+
if (this.minor > other.minor) {
|
|
4603
|
+
return 1;
|
|
4604
|
+
}
|
|
4605
|
+
if (this.patch < other.patch) {
|
|
4606
|
+
return -1;
|
|
4607
|
+
}
|
|
4608
|
+
if (this.patch > other.patch) {
|
|
4609
|
+
return 1;
|
|
4610
|
+
}
|
|
4611
|
+
return 0;
|
|
5081
4612
|
}
|
|
5082
4613
|
comparePre(other) {
|
|
5083
4614
|
if (!(other instanceof _SemVer)) {
|
|
@@ -6360,420 +5891,1077 @@ var require_valid2 = __commonJS({
|
|
|
6360
5891
|
} catch (er) {
|
|
6361
5892
|
return null;
|
|
6362
5893
|
}
|
|
6363
|
-
};
|
|
6364
|
-
module.exports = validRange;
|
|
6365
|
-
}
|
|
6366
|
-
});
|
|
6367
|
-
|
|
6368
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js
|
|
6369
|
-
var require_outside = __commonJS({
|
|
6370
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js"(exports, module) {
|
|
6371
|
-
"use strict";
|
|
6372
|
-
var SemVer = require_semver();
|
|
6373
|
-
var Comparator = require_comparator();
|
|
6374
|
-
var { ANY } = Comparator;
|
|
6375
|
-
var Range = require_range();
|
|
6376
|
-
var satisfies = require_satisfies();
|
|
6377
|
-
var gt = require_gt();
|
|
6378
|
-
var lt = require_lt();
|
|
6379
|
-
var lte = require_lte();
|
|
6380
|
-
var gte = require_gte();
|
|
6381
|
-
var outside = (version, range, hilo, options) => {
|
|
6382
|
-
version = new SemVer(version, options);
|
|
6383
|
-
range = new Range(range, options);
|
|
6384
|
-
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
6385
|
-
switch (hilo) {
|
|
6386
|
-
case ">":
|
|
6387
|
-
gtfn = gt;
|
|
6388
|
-
ltefn = lte;
|
|
6389
|
-
ltfn = lt;
|
|
6390
|
-
comp = ">";
|
|
6391
|
-
ecomp = ">=";
|
|
6392
|
-
break;
|
|
6393
|
-
case "<":
|
|
6394
|
-
gtfn = lt;
|
|
6395
|
-
ltefn = gte;
|
|
6396
|
-
ltfn = gt;
|
|
6397
|
-
comp = "<";
|
|
6398
|
-
ecomp = "<=";
|
|
6399
|
-
break;
|
|
6400
|
-
default:
|
|
6401
|
-
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
5894
|
+
};
|
|
5895
|
+
module.exports = validRange;
|
|
5896
|
+
}
|
|
5897
|
+
});
|
|
5898
|
+
|
|
5899
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js
|
|
5900
|
+
var require_outside = __commonJS({
|
|
5901
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js"(exports, module) {
|
|
5902
|
+
"use strict";
|
|
5903
|
+
var SemVer = require_semver();
|
|
5904
|
+
var Comparator = require_comparator();
|
|
5905
|
+
var { ANY } = Comparator;
|
|
5906
|
+
var Range = require_range();
|
|
5907
|
+
var satisfies = require_satisfies();
|
|
5908
|
+
var gt = require_gt();
|
|
5909
|
+
var lt = require_lt();
|
|
5910
|
+
var lte = require_lte();
|
|
5911
|
+
var gte = require_gte();
|
|
5912
|
+
var outside = (version, range, hilo, options) => {
|
|
5913
|
+
version = new SemVer(version, options);
|
|
5914
|
+
range = new Range(range, options);
|
|
5915
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
5916
|
+
switch (hilo) {
|
|
5917
|
+
case ">":
|
|
5918
|
+
gtfn = gt;
|
|
5919
|
+
ltefn = lte;
|
|
5920
|
+
ltfn = lt;
|
|
5921
|
+
comp = ">";
|
|
5922
|
+
ecomp = ">=";
|
|
5923
|
+
break;
|
|
5924
|
+
case "<":
|
|
5925
|
+
gtfn = lt;
|
|
5926
|
+
ltefn = gte;
|
|
5927
|
+
ltfn = gt;
|
|
5928
|
+
comp = "<";
|
|
5929
|
+
ecomp = "<=";
|
|
5930
|
+
break;
|
|
5931
|
+
default:
|
|
5932
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
5933
|
+
}
|
|
5934
|
+
if (satisfies(version, range, options)) {
|
|
5935
|
+
return false;
|
|
5936
|
+
}
|
|
5937
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
5938
|
+
const comparators = range.set[i];
|
|
5939
|
+
let high = null;
|
|
5940
|
+
let low = null;
|
|
5941
|
+
comparators.forEach((comparator) => {
|
|
5942
|
+
if (comparator.semver === ANY) {
|
|
5943
|
+
comparator = new Comparator(">=0.0.0");
|
|
5944
|
+
}
|
|
5945
|
+
high = high || comparator;
|
|
5946
|
+
low = low || comparator;
|
|
5947
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
5948
|
+
high = comparator;
|
|
5949
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
5950
|
+
low = comparator;
|
|
5951
|
+
}
|
|
5952
|
+
});
|
|
5953
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
5954
|
+
return false;
|
|
5955
|
+
}
|
|
5956
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
|
|
5957
|
+
return false;
|
|
5958
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
5959
|
+
return false;
|
|
5960
|
+
}
|
|
5961
|
+
}
|
|
5962
|
+
return true;
|
|
5963
|
+
};
|
|
5964
|
+
module.exports = outside;
|
|
5965
|
+
}
|
|
5966
|
+
});
|
|
5967
|
+
|
|
5968
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/gtr.js
|
|
5969
|
+
var require_gtr = __commonJS({
|
|
5970
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/gtr.js"(exports, module) {
|
|
5971
|
+
"use strict";
|
|
5972
|
+
var outside = require_outside();
|
|
5973
|
+
var gtr = (version, range, options) => outside(version, range, ">", options);
|
|
5974
|
+
module.exports = gtr;
|
|
5975
|
+
}
|
|
5976
|
+
});
|
|
5977
|
+
|
|
5978
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/ltr.js
|
|
5979
|
+
var require_ltr = __commonJS({
|
|
5980
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/ltr.js"(exports, module) {
|
|
5981
|
+
"use strict";
|
|
5982
|
+
var outside = require_outside();
|
|
5983
|
+
var ltr = (version, range, options) => outside(version, range, "<", options);
|
|
5984
|
+
module.exports = ltr;
|
|
5985
|
+
}
|
|
5986
|
+
});
|
|
5987
|
+
|
|
5988
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/intersects.js
|
|
5989
|
+
var require_intersects = __commonJS({
|
|
5990
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/intersects.js"(exports, module) {
|
|
5991
|
+
"use strict";
|
|
5992
|
+
var Range = require_range();
|
|
5993
|
+
var intersects = (r1, r2, options) => {
|
|
5994
|
+
r1 = new Range(r1, options);
|
|
5995
|
+
r2 = new Range(r2, options);
|
|
5996
|
+
return r1.intersects(r2, options);
|
|
5997
|
+
};
|
|
5998
|
+
module.exports = intersects;
|
|
5999
|
+
}
|
|
6000
|
+
});
|
|
6001
|
+
|
|
6002
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/simplify.js
|
|
6003
|
+
var require_simplify = __commonJS({
|
|
6004
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/simplify.js"(exports, module) {
|
|
6005
|
+
"use strict";
|
|
6006
|
+
var satisfies = require_satisfies();
|
|
6007
|
+
var compare = require_compare();
|
|
6008
|
+
module.exports = (versions, range, options) => {
|
|
6009
|
+
const set = [];
|
|
6010
|
+
let first = null;
|
|
6011
|
+
let prev = null;
|
|
6012
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
6013
|
+
for (const version of v) {
|
|
6014
|
+
const included = satisfies(version, range, options);
|
|
6015
|
+
if (included) {
|
|
6016
|
+
prev = version;
|
|
6017
|
+
if (!first) {
|
|
6018
|
+
first = version;
|
|
6019
|
+
}
|
|
6020
|
+
} else {
|
|
6021
|
+
if (prev) {
|
|
6022
|
+
set.push([first, prev]);
|
|
6023
|
+
}
|
|
6024
|
+
prev = null;
|
|
6025
|
+
first = null;
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
6028
|
+
if (first) {
|
|
6029
|
+
set.push([first, null]);
|
|
6030
|
+
}
|
|
6031
|
+
const ranges = [];
|
|
6032
|
+
for (const [min, max] of set) {
|
|
6033
|
+
if (min === max) {
|
|
6034
|
+
ranges.push(min);
|
|
6035
|
+
} else if (!max && min === v[0]) {
|
|
6036
|
+
ranges.push("*");
|
|
6037
|
+
} else if (!max) {
|
|
6038
|
+
ranges.push(`>=${min}`);
|
|
6039
|
+
} else if (min === v[0]) {
|
|
6040
|
+
ranges.push(`<=${max}`);
|
|
6041
|
+
} else {
|
|
6042
|
+
ranges.push(`${min} - ${max}`);
|
|
6043
|
+
}
|
|
6044
|
+
}
|
|
6045
|
+
const simplified = ranges.join(" || ");
|
|
6046
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
6047
|
+
return simplified.length < original.length ? simplified : range;
|
|
6048
|
+
};
|
|
6049
|
+
}
|
|
6050
|
+
});
|
|
6051
|
+
|
|
6052
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js
|
|
6053
|
+
var require_subset = __commonJS({
|
|
6054
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js"(exports, module) {
|
|
6055
|
+
"use strict";
|
|
6056
|
+
var Range = require_range();
|
|
6057
|
+
var Comparator = require_comparator();
|
|
6058
|
+
var { ANY } = Comparator;
|
|
6059
|
+
var satisfies = require_satisfies();
|
|
6060
|
+
var compare = require_compare();
|
|
6061
|
+
var subset = (sub, dom, options = {}) => {
|
|
6062
|
+
if (sub === dom) {
|
|
6063
|
+
return true;
|
|
6064
|
+
}
|
|
6065
|
+
sub = new Range(sub, options);
|
|
6066
|
+
dom = new Range(dom, options);
|
|
6067
|
+
let sawNonNull = false;
|
|
6068
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
6069
|
+
for (const simpleDom of dom.set) {
|
|
6070
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
6071
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
6072
|
+
if (isSub) {
|
|
6073
|
+
continue OUTER;
|
|
6074
|
+
}
|
|
6075
|
+
}
|
|
6076
|
+
if (sawNonNull) {
|
|
6077
|
+
return false;
|
|
6078
|
+
}
|
|
6079
|
+
}
|
|
6080
|
+
return true;
|
|
6081
|
+
};
|
|
6082
|
+
var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
6083
|
+
var minimumVersion = [new Comparator(">=0.0.0")];
|
|
6084
|
+
var simpleSubset = (sub, dom, options) => {
|
|
6085
|
+
if (sub === dom) {
|
|
6086
|
+
return true;
|
|
6087
|
+
}
|
|
6088
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
6089
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
6090
|
+
return true;
|
|
6091
|
+
} else if (options.includePrerelease) {
|
|
6092
|
+
sub = minimumVersionWithPreRelease;
|
|
6093
|
+
} else {
|
|
6094
|
+
sub = minimumVersion;
|
|
6095
|
+
}
|
|
6096
|
+
}
|
|
6097
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
6098
|
+
if (options.includePrerelease) {
|
|
6099
|
+
return true;
|
|
6100
|
+
} else {
|
|
6101
|
+
dom = minimumVersion;
|
|
6102
|
+
}
|
|
6103
|
+
}
|
|
6104
|
+
const eqSet = /* @__PURE__ */ new Set();
|
|
6105
|
+
let gt, lt;
|
|
6106
|
+
for (const c of sub) {
|
|
6107
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
6108
|
+
gt = higherGT(gt, c, options);
|
|
6109
|
+
} else if (c.operator === "<" || c.operator === "<=") {
|
|
6110
|
+
lt = lowerLT(lt, c, options);
|
|
6111
|
+
} else {
|
|
6112
|
+
eqSet.add(c.semver);
|
|
6113
|
+
}
|
|
6114
|
+
}
|
|
6115
|
+
if (eqSet.size > 1) {
|
|
6116
|
+
return null;
|
|
6117
|
+
}
|
|
6118
|
+
let gtltComp;
|
|
6119
|
+
if (gt && lt) {
|
|
6120
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
6121
|
+
if (gtltComp > 0) {
|
|
6122
|
+
return null;
|
|
6123
|
+
} else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
|
|
6124
|
+
return null;
|
|
6125
|
+
}
|
|
6402
6126
|
}
|
|
6403
|
-
|
|
6404
|
-
|
|
6127
|
+
for (const eq of eqSet) {
|
|
6128
|
+
if (gt && !satisfies(eq, String(gt), options)) {
|
|
6129
|
+
return null;
|
|
6130
|
+
}
|
|
6131
|
+
if (lt && !satisfies(eq, String(lt), options)) {
|
|
6132
|
+
return null;
|
|
6133
|
+
}
|
|
6134
|
+
for (const c of dom) {
|
|
6135
|
+
if (!satisfies(eq, String(c), options)) {
|
|
6136
|
+
return false;
|
|
6137
|
+
}
|
|
6138
|
+
}
|
|
6139
|
+
return true;
|
|
6405
6140
|
}
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6141
|
+
let higher, lower;
|
|
6142
|
+
let hasDomLT, hasDomGT;
|
|
6143
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
6144
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
6145
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
|
|
6146
|
+
needDomLTPre = false;
|
|
6147
|
+
}
|
|
6148
|
+
for (const c of dom) {
|
|
6149
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
6150
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
6151
|
+
if (gt) {
|
|
6152
|
+
if (needDomGTPre) {
|
|
6153
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
|
|
6154
|
+
needDomGTPre = false;
|
|
6155
|
+
}
|
|
6413
6156
|
}
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6157
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
6158
|
+
higher = higherGT(gt, c, options);
|
|
6159
|
+
if (higher === c && higher !== gt) {
|
|
6160
|
+
return false;
|
|
6161
|
+
}
|
|
6162
|
+
} else if (gt.operator === ">=" && !c.test(gt.semver)) {
|
|
6163
|
+
return false;
|
|
6420
6164
|
}
|
|
6421
|
-
});
|
|
6422
|
-
if (high.operator === comp || high.operator === ecomp) {
|
|
6423
|
-
return false;
|
|
6424
6165
|
}
|
|
6425
|
-
if (
|
|
6426
|
-
|
|
6427
|
-
|
|
6166
|
+
if (lt) {
|
|
6167
|
+
if (needDomLTPre) {
|
|
6168
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
|
|
6169
|
+
needDomLTPre = false;
|
|
6170
|
+
}
|
|
6171
|
+
}
|
|
6172
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
6173
|
+
lower = lowerLT(lt, c, options);
|
|
6174
|
+
if (lower === c && lower !== lt) {
|
|
6175
|
+
return false;
|
|
6176
|
+
}
|
|
6177
|
+
} else if (lt.operator === "<=" && !c.test(lt.semver)) {
|
|
6178
|
+
return false;
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
6428
6182
|
return false;
|
|
6429
6183
|
}
|
|
6430
6184
|
}
|
|
6185
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
6186
|
+
return false;
|
|
6187
|
+
}
|
|
6188
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
6189
|
+
return false;
|
|
6190
|
+
}
|
|
6191
|
+
if (needDomGTPre || needDomLTPre) {
|
|
6192
|
+
return false;
|
|
6193
|
+
}
|
|
6431
6194
|
return true;
|
|
6432
6195
|
};
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6196
|
+
var higherGT = (a, b, options) => {
|
|
6197
|
+
if (!a) {
|
|
6198
|
+
return b;
|
|
6199
|
+
}
|
|
6200
|
+
const comp = compare(a.semver, b.semver, options);
|
|
6201
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
6202
|
+
};
|
|
6203
|
+
var lowerLT = (a, b, options) => {
|
|
6204
|
+
if (!a) {
|
|
6205
|
+
return b;
|
|
6206
|
+
}
|
|
6207
|
+
const comp = compare(a.semver, b.semver, options);
|
|
6208
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
6209
|
+
};
|
|
6210
|
+
module.exports = subset;
|
|
6444
6211
|
}
|
|
6445
6212
|
});
|
|
6446
6213
|
|
|
6447
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/
|
|
6448
|
-
var
|
|
6449
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/
|
|
6214
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js
|
|
6215
|
+
var require_semver2 = __commonJS({
|
|
6216
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js"(exports, module) {
|
|
6450
6217
|
"use strict";
|
|
6218
|
+
var internalRe = require_re();
|
|
6219
|
+
var constants3 = require_constants();
|
|
6220
|
+
var SemVer = require_semver();
|
|
6221
|
+
var identifiers = require_identifiers();
|
|
6222
|
+
var parse = require_parse();
|
|
6223
|
+
var valid = require_valid();
|
|
6224
|
+
var clean = require_clean();
|
|
6225
|
+
var inc = require_inc();
|
|
6226
|
+
var diff = require_diff();
|
|
6227
|
+
var major = require_major();
|
|
6228
|
+
var minor = require_minor();
|
|
6229
|
+
var patch = require_patch();
|
|
6230
|
+
var prerelease = require_prerelease();
|
|
6231
|
+
var compare = require_compare();
|
|
6232
|
+
var rcompare = require_rcompare();
|
|
6233
|
+
var compareLoose = require_compare_loose();
|
|
6234
|
+
var compareBuild = require_compare_build();
|
|
6235
|
+
var sort = require_sort();
|
|
6236
|
+
var rsort = require_rsort();
|
|
6237
|
+
var gt = require_gt();
|
|
6238
|
+
var lt = require_lt();
|
|
6239
|
+
var eq = require_eq();
|
|
6240
|
+
var neq = require_neq();
|
|
6241
|
+
var gte = require_gte();
|
|
6242
|
+
var lte = require_lte();
|
|
6243
|
+
var cmp = require_cmp();
|
|
6244
|
+
var coerce = require_coerce();
|
|
6245
|
+
var truncate = require_truncate();
|
|
6246
|
+
var Comparator = require_comparator();
|
|
6247
|
+
var Range = require_range();
|
|
6248
|
+
var satisfies = require_satisfies();
|
|
6249
|
+
var toComparators = require_to_comparators();
|
|
6250
|
+
var maxSatisfying = require_max_satisfying();
|
|
6251
|
+
var minSatisfying = require_min_satisfying();
|
|
6252
|
+
var minVersion = require_min_version();
|
|
6253
|
+
var validRange = require_valid2();
|
|
6451
6254
|
var outside = require_outside();
|
|
6452
|
-
var
|
|
6453
|
-
|
|
6255
|
+
var gtr = require_gtr();
|
|
6256
|
+
var ltr = require_ltr();
|
|
6257
|
+
var intersects = require_intersects();
|
|
6258
|
+
var simplifyRange = require_simplify();
|
|
6259
|
+
var subset = require_subset();
|
|
6260
|
+
module.exports = {
|
|
6261
|
+
parse,
|
|
6262
|
+
valid,
|
|
6263
|
+
clean,
|
|
6264
|
+
inc,
|
|
6265
|
+
diff,
|
|
6266
|
+
major,
|
|
6267
|
+
minor,
|
|
6268
|
+
patch,
|
|
6269
|
+
prerelease,
|
|
6270
|
+
compare,
|
|
6271
|
+
rcompare,
|
|
6272
|
+
compareLoose,
|
|
6273
|
+
compareBuild,
|
|
6274
|
+
sort,
|
|
6275
|
+
rsort,
|
|
6276
|
+
gt,
|
|
6277
|
+
lt,
|
|
6278
|
+
eq,
|
|
6279
|
+
neq,
|
|
6280
|
+
gte,
|
|
6281
|
+
lte,
|
|
6282
|
+
cmp,
|
|
6283
|
+
coerce,
|
|
6284
|
+
truncate,
|
|
6285
|
+
Comparator,
|
|
6286
|
+
Range,
|
|
6287
|
+
satisfies,
|
|
6288
|
+
toComparators,
|
|
6289
|
+
maxSatisfying,
|
|
6290
|
+
minSatisfying,
|
|
6291
|
+
minVersion,
|
|
6292
|
+
validRange,
|
|
6293
|
+
outside,
|
|
6294
|
+
gtr,
|
|
6295
|
+
ltr,
|
|
6296
|
+
intersects,
|
|
6297
|
+
simplifyRange,
|
|
6298
|
+
subset,
|
|
6299
|
+
SemVer,
|
|
6300
|
+
re: internalRe.re,
|
|
6301
|
+
src: internalRe.src,
|
|
6302
|
+
tokens: internalRe.t,
|
|
6303
|
+
SEMVER_SPEC_VERSION: constants3.SEMVER_SPEC_VERSION,
|
|
6304
|
+
RELEASE_TYPES: constants3.RELEASE_TYPES,
|
|
6305
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
6306
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
6307
|
+
};
|
|
6454
6308
|
}
|
|
6455
6309
|
});
|
|
6456
6310
|
|
|
6457
|
-
//
|
|
6458
|
-
|
|
6459
|
-
"
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6311
|
+
// ../core/dist/kioku-versions.js
|
|
6312
|
+
function readRelease(r, bin) {
|
|
6313
|
+
const version = String(r["tag_name"]).replace(/^v/, "");
|
|
6314
|
+
return {
|
|
6315
|
+
version,
|
|
6316
|
+
prerelease: r["prerelease"] === true,
|
|
6317
|
+
date: text(r["published_at"]) ?? "",
|
|
6318
|
+
notes: text(r["body"])?.trim() ?? "",
|
|
6319
|
+
notesUrl: text(r["html_url"]) ?? `https://github.com/${KIOKU_REPO}/releases/tag/v${version}`,
|
|
6320
|
+
install: commandLine(bin, ["update", version])
|
|
6321
|
+
};
|
|
6322
|
+
}
|
|
6323
|
+
function mismatches(installed, all, plugins) {
|
|
6324
|
+
const tool = installed ? majorOf(installed) : null;
|
|
6325
|
+
if (tool === null)
|
|
6326
|
+
return [];
|
|
6327
|
+
return plugins.flatMap((p) => {
|
|
6328
|
+
const plugin = majorOf(p.version);
|
|
6329
|
+
if (plugin === null || plugin === tool)
|
|
6330
|
+
return [];
|
|
6331
|
+
const env = p.scope === "global" ? "" : `CLAUDE_CONFIG_DIR=${quote(p.configDir)} `;
|
|
6332
|
+
const release = all.find((r) => majorOf(r.version) === plugin);
|
|
6333
|
+
const fix = plugin < tool ? { kind: "plugin", command: p.update.map((args) => env + commandLine("claude", args)).join(" && ") } : release ? { kind: "release", version: release.version, command: release.install } : null;
|
|
6334
|
+
return [{ scope: p.scope, scopeRef: p.scopeRef, plugin: p.id, version: p.version, fix }];
|
|
6335
|
+
});
|
|
6336
|
+
}
|
|
6337
|
+
function stableActionFor(installed, stable2) {
|
|
6338
|
+
if (!stable2 || !installed || installed === stable2.version)
|
|
6339
|
+
return null;
|
|
6340
|
+
if (import_semver.default.prerelease(installed))
|
|
6341
|
+
return "back";
|
|
6342
|
+
return import_semver.default.gt(stable2.version, installed) ? "update" : null;
|
|
6343
|
+
}
|
|
6344
|
+
function pickReleases(listed, installed, plugins, bin) {
|
|
6345
|
+
const all = (Array.isArray(listed) ? listed : []).filter(isRecord2).filter((r) => r["draft"] !== true && isVersion(String(r["tag_name"] ?? "").replace(/^v/, ""))).map((r) => readRelease(r, bin)).sort((a, b) => import_semver.default.rcompare(a.version, b.version));
|
|
6346
|
+
const stable2 = all.find((r) => !r.prerelease) ?? null;
|
|
6347
|
+
const newer = (v) => (!installed || import_semver.default.gt(v, installed)) && (!stable2 || import_semver.default.gt(v, stable2.version));
|
|
6348
|
+
return {
|
|
6349
|
+
installed,
|
|
6350
|
+
stable: stable2,
|
|
6351
|
+
stableAction: stableActionFor(installed, stable2),
|
|
6352
|
+
prereleases: all.filter((r) => r.prerelease && newer(r.version)),
|
|
6353
|
+
mismatches: mismatches(installed, all, plugins)
|
|
6354
|
+
};
|
|
6355
|
+
}
|
|
6356
|
+
function readUpdate(out, command) {
|
|
6357
|
+
const agents = (Array.isArray(out["agents"]) ? out["agents"] : []).filter(isRecord2).map((a) => ({
|
|
6358
|
+
host: String(a["host"] ?? ""),
|
|
6359
|
+
name: String(a["name"] ?? ""),
|
|
6360
|
+
from: text(a["from"]),
|
|
6361
|
+
to: text(a["to"]),
|
|
6362
|
+
changed: a["changed"] === true,
|
|
6363
|
+
error: message(a["error"])
|
|
6364
|
+
}));
|
|
6365
|
+
return { status: String(out["status"] ?? ""), version: text(out["version"]), was: text(out["was"]), agents, finishError: message(out["finishError"]), command };
|
|
6366
|
+
}
|
|
6367
|
+
function readLabs(out, bin) {
|
|
6368
|
+
const listed = isRecord2(out) && Array.isArray(out["labs"]) ? out["labs"] : [];
|
|
6369
|
+
return listed.filter(isRecord2).filter((l) => LAB_NAME.test(String(l["name"] ?? ""))).map((l) => {
|
|
6370
|
+
const name = String(l["name"]);
|
|
6371
|
+
const enabled = l["enabled"] === true;
|
|
6372
|
+
const settings = isRecord2(l["settings"]) ? l["settings"] : void 0;
|
|
6373
|
+
const set = settings && Object.fromEntries(Object.entries(settings).map(([key, value]) => [key, commandLine(bin, ["config", "set", `labs.${name}.${key}`, typeof value === "string" ? value : JSON.stringify(value)])]));
|
|
6374
|
+
return {
|
|
6375
|
+
name,
|
|
6376
|
+
title: text(l["title"]) ?? name,
|
|
6377
|
+
about: text(l["about"]) ?? "",
|
|
6378
|
+
enabled,
|
|
6379
|
+
...settings ? { settings, set } : {},
|
|
6380
|
+
...text(l["command"]) ? { command: text(l["command"]) } : {},
|
|
6381
|
+
toggle: commandLine(bin, labArgs(name, !enabled))
|
|
6466
6382
|
};
|
|
6467
|
-
|
|
6383
|
+
});
|
|
6384
|
+
}
|
|
6385
|
+
var import_semver, KIOKU_REPO, RELEASES_ARGS, LAB_NAME, isVersion, quote, commandLine, updateArgs, labArgs, LABS_ARGS, majorOf, isRecord2, text, message;
|
|
6386
|
+
var init_kioku_versions = __esm({
|
|
6387
|
+
"../core/dist/kioku-versions.js"() {
|
|
6388
|
+
"use strict";
|
|
6389
|
+
import_semver = __toESM(require_semver2(), 1);
|
|
6390
|
+
KIOKU_REPO = "monoku/kioku";
|
|
6391
|
+
RELEASES_ARGS = ["api", `repos/${KIOKU_REPO}/releases`];
|
|
6392
|
+
LAB_NAME = /^[A-Za-z0-9][\w-]*$/;
|
|
6393
|
+
isVersion = (v) => import_semver.default.valid(v) === v;
|
|
6394
|
+
quote = (arg) => /^[\w./@:=-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
6395
|
+
commandLine = (bin, args) => [bin, ...args].map(quote).join(" ");
|
|
6396
|
+
updateArgs = (version, check = false) => ["update", version, ...check ? ["--check"] : []];
|
|
6397
|
+
labArgs = (name, enabled) => ["config", "set", `labs.${name}.enabled`, String(enabled)];
|
|
6398
|
+
LABS_ARGS = ["labs", "list"];
|
|
6399
|
+
majorOf = (v) => import_semver.default.parse(v)?.major ?? null;
|
|
6400
|
+
isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
6401
|
+
text = (v) => typeof v === "string" ? v : null;
|
|
6402
|
+
message = (v) => text(v) ?? (isRecord2(v) ? text(v["message"]) : null);
|
|
6468
6403
|
}
|
|
6469
6404
|
});
|
|
6470
6405
|
|
|
6471
|
-
//
|
|
6472
|
-
|
|
6473
|
-
|
|
6406
|
+
// ../core/dist/kioku.js
|
|
6407
|
+
import { spawn as spawn7 } from "node:child_process";
|
|
6408
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
6409
|
+
import { homedir as homedir5 } from "node:os";
|
|
6410
|
+
import { join as join13 } from "node:path";
|
|
6411
|
+
import { createInterface } from "node:readline";
|
|
6412
|
+
import * as pty3 from "node-pty";
|
|
6413
|
+
function assertVersion(version) {
|
|
6414
|
+
if (!isVersion(version))
|
|
6415
|
+
throw new KiokuError(`a kioku version reads like 5.0.0 or 5.0.0-rc.1, not "${version}"`, 400);
|
|
6416
|
+
}
|
|
6417
|
+
function assertRepo(repo, what) {
|
|
6418
|
+
if (!REPO.test(repo))
|
|
6419
|
+
throw new KiokuError(`${what} is named as owner/repo, not "${repo}"`, 400);
|
|
6420
|
+
}
|
|
6421
|
+
function resolveKiokuBin(pathVar = process.env.PATH, home = homedir5()) {
|
|
6422
|
+
const fallback = join13(home, ".local", "bin", "kioku");
|
|
6423
|
+
return findOnPath("kioku", pathVar) ?? (existsSync12(fallback) ? fallback : "kioku");
|
|
6424
|
+
}
|
|
6425
|
+
function rememberPrompt(text2) {
|
|
6426
|
+
return `Remember this with kioku: ${text2.replace(/\s+/g, " ").trim()}`;
|
|
6427
|
+
}
|
|
6428
|
+
function createTerminalRunner(env, timeoutMs) {
|
|
6429
|
+
return (bin, args, cwd) => new Promise((resolve10) => {
|
|
6430
|
+
let proc;
|
|
6431
|
+
try {
|
|
6432
|
+
proc = pty3.spawn(bin, args, { name: "xterm-256color", cols: 400, rows: 40, cwd, env });
|
|
6433
|
+
} catch {
|
|
6434
|
+
return resolve10({ code: 127, stdout: "", stderr: "ENOENT" });
|
|
6435
|
+
}
|
|
6436
|
+
let output = "";
|
|
6437
|
+
const timer = setTimeout(() => proc.kill(), timeoutMs);
|
|
6438
|
+
proc.onData((data) => {
|
|
6439
|
+
output = (output + data).slice(-64 * 1024);
|
|
6440
|
+
});
|
|
6441
|
+
proc.onExit(({ exitCode }) => {
|
|
6442
|
+
clearTimeout(timer);
|
|
6443
|
+
const json = stripAnsi(output).split(/\r?\n/).reverse().map((line) => line.slice(line.indexOf("{")).trim()).find((line) => parseJson(line) !== null);
|
|
6444
|
+
resolve10({ code: exitCode, stdout: json ?? "", stderr: output });
|
|
6445
|
+
});
|
|
6446
|
+
});
|
|
6447
|
+
}
|
|
6448
|
+
function parseJson(text2) {
|
|
6449
|
+
try {
|
|
6450
|
+
return JSON.parse(text2);
|
|
6451
|
+
} catch {
|
|
6452
|
+
return null;
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
async function mapLimit(items, limit, fn) {
|
|
6456
|
+
const out = new Array(items.length);
|
|
6457
|
+
let next = 0;
|
|
6458
|
+
const worker = async () => {
|
|
6459
|
+
while (next < items.length) {
|
|
6460
|
+
const i = next++;
|
|
6461
|
+
out[i] = await fn(items[i]);
|
|
6462
|
+
}
|
|
6463
|
+
};
|
|
6464
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
6465
|
+
return out;
|
|
6466
|
+
}
|
|
6467
|
+
var PAGE_TYPES, KiokuError, NOT_INSTALLED, START_TIMEOUT_MS, WRITE_TIMEOUT_MS, TERMINAL_TIMEOUT_MS, CACHE_MS2, RELEASES_CACHE_MS, SHOWN_BIN, ACTIVITY_SINCE, ACTIVITY_LIMIT, PARALLEL, TIERS, REPO, AREA, LANGUAGE, MISSING, brainName, Kioku;
|
|
6468
|
+
var init_kioku = __esm({
|
|
6469
|
+
"../core/dist/kioku.js"() {
|
|
6474
6470
|
"use strict";
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6471
|
+
init_task_review();
|
|
6472
|
+
init_cw_doctor();
|
|
6473
|
+
init_cw_install();
|
|
6474
|
+
init_output();
|
|
6475
|
+
init_kioku_versions();
|
|
6476
|
+
PAGE_TYPES = {
|
|
6477
|
+
memory: { kind: "memory" },
|
|
6478
|
+
instinct: { kind: "memory", sub: "instinct" },
|
|
6479
|
+
decision: { kind: "knowledge", sub: "decision" },
|
|
6480
|
+
playbook: { kind: "knowledge", sub: "playbook" },
|
|
6481
|
+
context: { kind: "knowledge", sub: "context" },
|
|
6482
|
+
rule: { kind: "rule" }
|
|
6483
|
+
};
|
|
6484
|
+
KiokuError = class extends Error {
|
|
6485
|
+
status;
|
|
6486
|
+
constructor(message2, status = 502) {
|
|
6487
|
+
super(message2);
|
|
6488
|
+
this.status = status;
|
|
6489
|
+
}
|
|
6490
|
+
};
|
|
6491
|
+
NOT_INSTALLED = "kioku is not installed on this machine";
|
|
6492
|
+
START_TIMEOUT_MS = 2e4;
|
|
6493
|
+
WRITE_TIMEOUT_MS = 6e4;
|
|
6494
|
+
TERMINAL_TIMEOUT_MS = 3 * 6e4;
|
|
6495
|
+
CACHE_MS2 = 5 * 6e4;
|
|
6496
|
+
RELEASES_CACHE_MS = 10 * 6e4;
|
|
6497
|
+
SHOWN_BIN = "kioku";
|
|
6498
|
+
ACTIVITY_SINCE = "2w";
|
|
6499
|
+
ACTIVITY_LIMIT = 40;
|
|
6500
|
+
PARALLEL = 6;
|
|
6501
|
+
TIERS = ["personal", "project", "team"];
|
|
6502
|
+
REPO = /^[\w.-]+\/[\w.-]+(\/[\w.-]+)?$/;
|
|
6503
|
+
AREA = /^[A-Za-z0-9][\w.-]*(\/[A-Za-z0-9][\w.-]*)*$/;
|
|
6504
|
+
LANGUAGE = /^[A-Za-z]{2,3}(-[A-Za-z0-9]+)*$/;
|
|
6505
|
+
MISSING = { installed: false, version: null, brains: [], projects: {}, activity: [] };
|
|
6506
|
+
brainName = (b) => b.name ?? b.key;
|
|
6507
|
+
Kioku = class {
|
|
6508
|
+
run;
|
|
6509
|
+
write;
|
|
6510
|
+
terminal;
|
|
6511
|
+
startTimeoutMs;
|
|
6512
|
+
projects;
|
|
6513
|
+
pluginInstalls;
|
|
6514
|
+
now;
|
|
6515
|
+
binPath;
|
|
6516
|
+
viewer = null;
|
|
6517
|
+
snapshot = null;
|
|
6518
|
+
releaseList = null;
|
|
6519
|
+
constructor(options = {}) {
|
|
6520
|
+
this.binPath = options.bin;
|
|
6521
|
+
this.run = options.run ?? createRunner();
|
|
6522
|
+
this.write = options.write ?? createRunner(envWithoutHost(), WRITE_TIMEOUT_MS);
|
|
6523
|
+
this.terminal = options.terminal;
|
|
6524
|
+
this.startTimeoutMs = options.startTimeoutMs ?? START_TIMEOUT_MS;
|
|
6525
|
+
this.projects = options.projects ?? (() => ({}));
|
|
6526
|
+
this.pluginInstalls = options.pluginInstalls ?? (() => []);
|
|
6527
|
+
this.now = options.now ?? Date.now;
|
|
6528
|
+
}
|
|
6529
|
+
// resolved on first use, so a Forge that never opens Memory does not search PATH
|
|
6530
|
+
get bin() {
|
|
6531
|
+
return this.binPath ??= resolveKiokuBin();
|
|
6532
|
+
}
|
|
6533
|
+
async status(fresh = false) {
|
|
6534
|
+
const previous = this.snapshot;
|
|
6535
|
+
if (fresh || !previous || this.now() - previous.at > CACHE_MS2) {
|
|
6536
|
+
const value = this.read();
|
|
6537
|
+
this.snapshot = { at: this.now(), value };
|
|
6538
|
+
value.catch(() => {
|
|
6539
|
+
if (this.snapshot?.value === value)
|
|
6540
|
+
this.snapshot = previous;
|
|
6541
|
+
});
|
|
6542
|
+
}
|
|
6543
|
+
const pending = fresh || !previous ? this.snapshot.value : previous.value;
|
|
6544
|
+
const [snapshot, viewer] = await Promise.all([pending, this.viewer?.catch(() => null) ?? null]);
|
|
6545
|
+
return { ...snapshot, viewer: viewer?.address ?? null };
|
|
6546
|
+
}
|
|
6547
|
+
async json(args, cwd) {
|
|
6548
|
+
const result2 = await this.run(this.bin, [...args, "--json"], cwd);
|
|
6549
|
+
return result2.code === 0 ? parseJson(result2.stdout) : null;
|
|
6550
|
+
}
|
|
6551
|
+
async read() {
|
|
6552
|
+
const [version, list] = await Promise.all([
|
|
6553
|
+
this.run(this.bin, ["--version"], homedir5()),
|
|
6554
|
+
this.json(["brain", "list"], homedir5())
|
|
6555
|
+
]);
|
|
6556
|
+
if (version.code !== 0)
|
|
6557
|
+
return MISSING;
|
|
6558
|
+
const listed = list?.brains ?? [];
|
|
6559
|
+
const entries = Object.entries(this.projects()).filter(([, p]) => existsSync12(p.path));
|
|
6560
|
+
const readBrain = async (b) => {
|
|
6561
|
+
if (!b.onDisk)
|
|
6562
|
+
return { kinds: {}, namespaces: [], writes: [] };
|
|
6563
|
+
const [ns, log] = await Promise.all([
|
|
6564
|
+
this.json(["namespace", "list", "--brain", b.key], b.folder),
|
|
6565
|
+
this.json(["brain", "log", "--since", ACTIVITY_SINCE, "--brain", b.key], b.folder)
|
|
6566
|
+
]);
|
|
6567
|
+
const kinds = {};
|
|
6568
|
+
const namespaces = ns?.brains?.find((x) => x.brain === brainName(b))?.namespaces ?? [];
|
|
6569
|
+
for (const n of namespaces) {
|
|
6570
|
+
for (const [kind, count] of Object.entries(n.pages))
|
|
6571
|
+
kinds[kind] = (kinds[kind] ?? 0) + count;
|
|
6492
6572
|
}
|
|
6493
|
-
|
|
6494
|
-
|
|
6573
|
+
return { kinds, namespaces: namespaces.map((n) => n.namespace), writes: log?.writes ?? [] };
|
|
6574
|
+
};
|
|
6575
|
+
const readChain = async (path) => (await this.json(["brain", "list"], path))?.chain ?? [];
|
|
6576
|
+
const [perBrain, chains] = await Promise.all([
|
|
6577
|
+
mapLimit(listed, PARALLEL / 2, readBrain),
|
|
6578
|
+
mapLimit(entries, PARALLEL / 2, ([, p]) => readChain(p.path))
|
|
6579
|
+
]);
|
|
6580
|
+
const activity = perBrain.flatMap((p) => p.writes).sort((x, y) => y.date.localeCompare(x.date));
|
|
6581
|
+
const brains = listed.map((b, i) => {
|
|
6582
|
+
const { kinds, namespaces } = perBrain[i];
|
|
6583
|
+
const name = brainName(b);
|
|
6584
|
+
return {
|
|
6585
|
+
...b,
|
|
6586
|
+
pages: Object.values(kinds).reduce((sum, n) => sum + n, 0),
|
|
6587
|
+
kinds,
|
|
6588
|
+
namespaces,
|
|
6589
|
+
touched: activity.find((w) => w.brain === name)?.date ?? null
|
|
6590
|
+
};
|
|
6591
|
+
});
|
|
6592
|
+
const projects = Object.fromEntries(entries.map(([name], i) => [name, chains[i].map(({ name: name2, tier }) => ({ name: name2, tier }))]));
|
|
6593
|
+
return {
|
|
6594
|
+
installed: true,
|
|
6595
|
+
version: parseJson(version.stdout)?.version ?? null,
|
|
6596
|
+
brains,
|
|
6597
|
+
projects,
|
|
6598
|
+
activity: activity.slice(0, ACTIVITY_LIMIT).map(({ verb, title, path, date, author, brain }) => ({ verb, title, path, date, author, brain }))
|
|
6599
|
+
};
|
|
6600
|
+
}
|
|
6601
|
+
// writes through kioku, which validates, commits and pushes a shared brain; Forge never writes a brain's files
|
|
6602
|
+
async save(input) {
|
|
6603
|
+
const type = PAGE_TYPES[input.type];
|
|
6604
|
+
if (!type)
|
|
6605
|
+
throw new KiokuError(`unknown page type ${input.type}`, 400);
|
|
6606
|
+
const brain = await this.findBrain(input.brain);
|
|
6607
|
+
const args = [
|
|
6608
|
+
"page",
|
|
6609
|
+
"save",
|
|
6610
|
+
"--brain",
|
|
6611
|
+
brain.key,
|
|
6612
|
+
"--kind",
|
|
6613
|
+
type.kind,
|
|
6614
|
+
...type.sub ? ["--sub", type.sub] : [],
|
|
6615
|
+
"--title",
|
|
6616
|
+
input.title,
|
|
6617
|
+
"--summary",
|
|
6618
|
+
input.summary,
|
|
6619
|
+
"--source",
|
|
6620
|
+
"Forge",
|
|
6621
|
+
...input.namespace ? ["--namespace", input.namespace] : [],
|
|
6622
|
+
...input.create ? ["--create"] : [],
|
|
6623
|
+
"--json"
|
|
6624
|
+
];
|
|
6625
|
+
const { out, fail } = await this.invoke(args, brain.folder, this.write, input.body);
|
|
6626
|
+
if (out?.status === "done" && out.path) {
|
|
6627
|
+
this.expire();
|
|
6628
|
+
return { status: "done", brain: brainName(brain), path: out.path, publication: out.publication ?? null };
|
|
6495
6629
|
}
|
|
6630
|
+
if (out?.status === "similar")
|
|
6631
|
+
return { status: "similar", similar: (out.similar ?? []).map(({ brain: brain2, path, title, summary }) => ({ brain: brain2, path, title, summary })) };
|
|
6632
|
+
if (out?.status === "namespace")
|
|
6633
|
+
return { status: "namespace", namespaces: (out.namespaces ?? []).map(({ namespace, summary }) => ({ namespace, summary })) };
|
|
6634
|
+
throw fail("kioku could not save the page");
|
|
6496
6635
|
}
|
|
6497
|
-
|
|
6498
|
-
|
|
6636
|
+
// the cached reading when there is one, else only the list of brains
|
|
6637
|
+
async listBrains() {
|
|
6638
|
+
return this.snapshot ? (await this.snapshot.value).brains : (await this.json(["brain", "list"], homedir5()))?.brains ?? [];
|
|
6499
6639
|
}
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
if (
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
ranges.push("*");
|
|
6506
|
-
} else if (!max) {
|
|
6507
|
-
ranges.push(`>=${min}`);
|
|
6508
|
-
} else if (min === v[0]) {
|
|
6509
|
-
ranges.push(`<=${max}`);
|
|
6510
|
-
} else {
|
|
6511
|
-
ranges.push(`${min} - ${max}`);
|
|
6512
|
-
}
|
|
6640
|
+
async findBrain(key) {
|
|
6641
|
+
const brain = (await this.listBrains()).find((b) => b.key === key);
|
|
6642
|
+
if (!brain?.onDisk)
|
|
6643
|
+
throw new KiokuError(`no brain ${key} on this machine`, 404);
|
|
6644
|
+
return brain;
|
|
6513
6645
|
}
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
}
|
|
6519
|
-
});
|
|
6520
|
-
|
|
6521
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js
|
|
6522
|
-
var require_subset = __commonJS({
|
|
6523
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js"(exports, module) {
|
|
6524
|
-
"use strict";
|
|
6525
|
-
var Range = require_range();
|
|
6526
|
-
var Comparator = require_comparator();
|
|
6527
|
-
var { ANY } = Comparator;
|
|
6528
|
-
var satisfies = require_satisfies();
|
|
6529
|
-
var compare = require_compare();
|
|
6530
|
-
var subset = (sub, dom, options = {}) => {
|
|
6531
|
-
if (sub === dom) {
|
|
6532
|
-
return true;
|
|
6646
|
+
// the next status reads again, while the old reading still answers a poll that is not fresh
|
|
6647
|
+
expire() {
|
|
6648
|
+
if (this.snapshot)
|
|
6649
|
+
this.snapshot.at = -Infinity;
|
|
6533
6650
|
}
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
if (isSub) {
|
|
6542
|
-
continue OUTER;
|
|
6543
|
-
}
|
|
6544
|
-
}
|
|
6545
|
-
if (sawNonNull) {
|
|
6546
|
-
return false;
|
|
6547
|
-
}
|
|
6651
|
+
// runs a verb that writes; fail turns kioku's refusal into a 400 with its message
|
|
6652
|
+
async invoke(args, cwd, run2, input) {
|
|
6653
|
+
const result2 = await run2(this.bin, args, cwd, input);
|
|
6654
|
+
if (result2.code === 127)
|
|
6655
|
+
throw new KiokuError(NOT_INSTALLED, 404);
|
|
6656
|
+
const out = parseJson(result2.stdout);
|
|
6657
|
+
return { out, ok: result2.code === 0 && out !== null && !out.error, fail: (fallback) => new KiokuError(out?.error?.message ?? (tailOutput(result2.stderr, 1) || fallback), 400) };
|
|
6548
6658
|
}
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
return true;
|
|
6659
|
+
async change(args, cwd, run2 = this.write) {
|
|
6660
|
+
const { out, ok, fail } = await this.invoke([...args, "--json"], cwd, run2);
|
|
6661
|
+
if (!ok || !out)
|
|
6662
|
+
throw fail(`kioku ${args.slice(0, 2).join(" ")} failed`);
|
|
6663
|
+
this.expire();
|
|
6664
|
+
return out;
|
|
6556
6665
|
}
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6666
|
+
// makes a brain on this machine only; kioku never makes a repository here
|
|
6667
|
+
async createBrain(input) {
|
|
6668
|
+
assertRepo(input.repo, "the brain");
|
|
6669
|
+
if (!TIERS.includes(input.tier))
|
|
6670
|
+
throw new KiokuError(`the tier is one of ${TIERS.join(", ")}`, 400);
|
|
6671
|
+
if (input.team)
|
|
6672
|
+
assertRepo(input.team, "the team brain");
|
|
6673
|
+
if (input.language && !LANGUAGE.test(input.language))
|
|
6674
|
+
throw new KiokuError("the language is a tag such as en or es", 400);
|
|
6675
|
+
const args = [
|
|
6676
|
+
"brain",
|
|
6677
|
+
"create",
|
|
6678
|
+
input.repo,
|
|
6679
|
+
"--tier",
|
|
6680
|
+
input.tier,
|
|
6681
|
+
...input.team && input.tier === "project" ? ["--team", input.team] : [],
|
|
6682
|
+
...input.language ? ["--language", input.language] : []
|
|
6683
|
+
];
|
|
6684
|
+
const { brain, name, path } = await this.change(args, homedir5());
|
|
6685
|
+
return { brain, name, path };
|
|
6565
6686
|
}
|
|
6566
|
-
|
|
6567
|
-
if (
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6687
|
+
async addArea(key, area, summary) {
|
|
6688
|
+
if (!AREA.test(area))
|
|
6689
|
+
throw new KiokuError("an area is letters, digits, dots, dashes and underscores, with / between parts", 400);
|
|
6690
|
+
if (!summary)
|
|
6691
|
+
throw new KiokuError("say what the area is for", 400);
|
|
6692
|
+
const brain = await this.findBrain(key);
|
|
6693
|
+
const out = await this.change(["namespace", "add", area, `--summary=${summary}`, "--brain", brain.key], brain.folder);
|
|
6694
|
+
return { brain: out.brain, namespace: out.namespace };
|
|
6572
6695
|
}
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6696
|
+
// writes the project's kioku.yaml; a brain the machine does not know is made first, since kioku links only known brains without a terminal
|
|
6697
|
+
async linkProject(input) {
|
|
6698
|
+
if (!input.brain && !input.team)
|
|
6699
|
+
throw new KiokuError("name a project brain, a team brain, or both", 400);
|
|
6700
|
+
const path = this.projects()[input.project]?.path;
|
|
6701
|
+
if (!path || !existsSync12(path))
|
|
6702
|
+
throw new KiokuError(`no CW project ${input.project} on this machine`, 404);
|
|
6703
|
+
if (input.brain)
|
|
6704
|
+
assertRepo(input.brain, "the project brain");
|
|
6705
|
+
if (input.team)
|
|
6706
|
+
assertRepo(input.team, "the team brain");
|
|
6707
|
+
const known = await this.listBrains();
|
|
6708
|
+
const isKnown = (repo) => known.some((b) => b.key === repo || b.key.endsWith(`/${repo}`));
|
|
6709
|
+
const created = [];
|
|
6710
|
+
if (input.team && !isKnown(input.team))
|
|
6711
|
+
created.push((await this.createBrain({ repo: input.team, tier: "team" })).brain);
|
|
6712
|
+
if (input.brain && !isKnown(input.brain))
|
|
6713
|
+
created.push((await this.createBrain({ repo: input.brain, tier: "project", team: input.team })).brain);
|
|
6714
|
+
const args = ["init", ...input.brain ? [input.brain] : [], ...input.team ? ["--team", input.team] : []];
|
|
6715
|
+
const { file } = await this.change(args, path);
|
|
6716
|
+
return { file, created };
|
|
6583
6717
|
}
|
|
6584
|
-
|
|
6585
|
-
|
|
6718
|
+
// the only verb that reaches a git host: without `to`, kioku makes a private GitHub repository with gh
|
|
6719
|
+
async publish(key, to) {
|
|
6720
|
+
if (to?.startsWith("-"))
|
|
6721
|
+
throw new KiokuError("the address cannot start with -", 400);
|
|
6722
|
+
const brain = await this.findBrain(key);
|
|
6723
|
+
if (brain.remote)
|
|
6724
|
+
throw new KiokuError(`${brainName(brain)} already has a repository: ${brain.remote}`, 400);
|
|
6725
|
+
const out = await this.change(["brain", "publish", brain.key, ...to ? ["--to", to] : []], brain.folder, this.terminalRun);
|
|
6726
|
+
return { brain: out.brain, status: out.status, remote: out.remote ?? null };
|
|
6586
6727
|
}
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
gtltComp = compare(gt.semver, lt.semver, options);
|
|
6590
|
-
if (gtltComp > 0) {
|
|
6591
|
-
return null;
|
|
6592
|
-
} else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
|
|
6593
|
-
return null;
|
|
6594
|
-
}
|
|
6728
|
+
get terminalRun() {
|
|
6729
|
+
return this.terminal ??= createTerminalRunner(envWithoutHost(), TERMINAL_TIMEOUT_MS);
|
|
6595
6730
|
}
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6731
|
+
// kioku has no verb that lists releases and its repository is private, so gh reads them; a failed read keeps the last list
|
|
6732
|
+
async releases(fresh = false) {
|
|
6733
|
+
const cached = this.releaseList;
|
|
6734
|
+
const [status, listed] = await Promise.all([
|
|
6735
|
+
// the installed version comes from the status reading, which an update renews
|
|
6736
|
+
this.status(),
|
|
6737
|
+
!fresh && cached && this.now() - cached.at <= RELEASES_CACHE_MS ? null : this.run("gh", RELEASES_ARGS, homedir5())
|
|
6738
|
+
]);
|
|
6739
|
+
let error = null;
|
|
6740
|
+
if (listed) {
|
|
6741
|
+
const raw = listed.code === 0 ? parseJson(listed.stdout) : null;
|
|
6742
|
+
if (Array.isArray(raw))
|
|
6743
|
+
this.releaseList = { at: this.now(), raw };
|
|
6744
|
+
else
|
|
6745
|
+
error = listed.code === 127 ? "gh is not installed, and the releases of monoku/kioku are read with it" : tailOutput(listed.stderr, 1) || "gh could not read the releases of monoku/kioku";
|
|
6607
6746
|
}
|
|
6608
|
-
return
|
|
6747
|
+
return { ...pickReleases(this.releaseList?.raw ?? [], status.version, this.pluginInstalls(), SHOWN_BIN), command: commandLine("gh", RELEASES_ARGS), error };
|
|
6609
6748
|
}
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6749
|
+
// only looks: kioku answers whether it would install, without a terminal
|
|
6750
|
+
async checkUpdate(version) {
|
|
6751
|
+
assertVersion(version);
|
|
6752
|
+
const args = updateArgs(version, true);
|
|
6753
|
+
const { out, ok, fail } = await this.invoke([...args, "--json"], homedir5(), this.run);
|
|
6754
|
+
if (!ok || !out)
|
|
6755
|
+
throw fail(`kioku update ${version} --check failed`);
|
|
6756
|
+
return { ...readUpdate(out, commandLine(SHOWN_BIN, args)), install: commandLine(SHOWN_BIN, updateArgs(version)) };
|
|
6757
|
+
}
|
|
6758
|
+
// kioku installs a named version only for a person at a terminal
|
|
6759
|
+
async update(version) {
|
|
6760
|
+
assertVersion(version);
|
|
6761
|
+
const args = updateArgs(version);
|
|
6762
|
+
const { out, ok, fail } = await this.invoke([...args, "--json"], homedir5(), this.terminalRun);
|
|
6763
|
+
if (!ok || !out)
|
|
6764
|
+
throw fail(`kioku update ${version} failed`);
|
|
6765
|
+
this.status(true).catch(() => {
|
|
6766
|
+
});
|
|
6767
|
+
return readUpdate(out, commandLine(SHOWN_BIN, args));
|
|
6616
6768
|
}
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
if (
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
}
|
|
6634
|
-
}
|
|
6635
|
-
if (lt) {
|
|
6636
|
-
if (needDomLTPre) {
|
|
6637
|
-
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
|
|
6638
|
-
needDomLTPre = false;
|
|
6639
|
-
}
|
|
6640
|
-
}
|
|
6641
|
-
if (c.operator === "<" || c.operator === "<=") {
|
|
6642
|
-
lower = lowerLT(lt, c, options);
|
|
6643
|
-
if (lower === c && lower !== lt) {
|
|
6644
|
-
return false;
|
|
6645
|
-
}
|
|
6646
|
-
} else if (lt.operator === "<=" && !c.test(lt.semver)) {
|
|
6647
|
-
return false;
|
|
6648
|
-
}
|
|
6649
|
-
}
|
|
6650
|
-
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
6651
|
-
return false;
|
|
6652
|
-
}
|
|
6769
|
+
// each version brings its own labs; a kioku without the verb has none
|
|
6770
|
+
async labs() {
|
|
6771
|
+
const result2 = await this.run(this.bin, [...LABS_ARGS, "--json"], homedir5());
|
|
6772
|
+
if (result2.code === 127)
|
|
6773
|
+
throw new KiokuError(NOT_INSTALLED, 404);
|
|
6774
|
+
const out = result2.code === 0 ? parseJson(result2.stdout) : null;
|
|
6775
|
+
return { labs: out ? readLabs(out, SHOWN_BIN) : null, command: commandLine(SHOWN_BIN, LABS_ARGS) };
|
|
6776
|
+
}
|
|
6777
|
+
// only a lab the installed kioku lists, so no other key reaches config set
|
|
6778
|
+
async setLab(name, enabled) {
|
|
6779
|
+
if (!(await this.labs()).labs?.some((l) => l.name === name))
|
|
6780
|
+
throw new KiokuError(`this kioku has no lab ${name}`, 404);
|
|
6781
|
+
const { ok, fail } = await this.invoke([...labArgs(name, enabled), "--json"], homedir5(), this.terminalRun);
|
|
6782
|
+
if (!ok)
|
|
6783
|
+
throw fail(`kioku config set labs.${name}.enabled failed`);
|
|
6784
|
+
return this.labs();
|
|
6653
6785
|
}
|
|
6654
|
-
|
|
6655
|
-
|
|
6786
|
+
// one viewer at a time; a second call reuses the running one
|
|
6787
|
+
async openViewer() {
|
|
6788
|
+
this.viewer ??= this.startViewer();
|
|
6789
|
+
return (await this.viewer).address;
|
|
6656
6790
|
}
|
|
6657
|
-
|
|
6658
|
-
|
|
6791
|
+
startViewer() {
|
|
6792
|
+
const started = new Promise((resolve10, reject) => {
|
|
6793
|
+
const child = spawn7(this.bin, ["web", "--json", "--no-open"], { cwd: homedir5(), stdio: ["ignore", "pipe", "pipe"] });
|
|
6794
|
+
const lines2 = createInterface({ input: child.stdout });
|
|
6795
|
+
let stderr = "";
|
|
6796
|
+
let settled = false;
|
|
6797
|
+
const finish = () => {
|
|
6798
|
+
settled = true;
|
|
6799
|
+
clearTimeout(timer);
|
|
6800
|
+
lines2.close();
|
|
6801
|
+
child.stdout?.resume();
|
|
6802
|
+
};
|
|
6803
|
+
const fail = (err) => {
|
|
6804
|
+
if (settled)
|
|
6805
|
+
return;
|
|
6806
|
+
finish();
|
|
6807
|
+
child.kill();
|
|
6808
|
+
reject(err);
|
|
6809
|
+
};
|
|
6810
|
+
const timer = setTimeout(() => fail(new KiokuError("kioku web did not start in time")), this.startTimeoutMs);
|
|
6811
|
+
child.stderr?.on("data", (chunk) => {
|
|
6812
|
+
stderr = (stderr + chunk.toString()).slice(-4096);
|
|
6813
|
+
});
|
|
6814
|
+
lines2.on("line", (line) => {
|
|
6815
|
+
const event = parseJson(line);
|
|
6816
|
+
if (settled || event?.event !== "listening" || !event.address?.startsWith("http://127.0.0.1:"))
|
|
6817
|
+
return;
|
|
6818
|
+
finish();
|
|
6819
|
+
resolve10({ child, address: event.address });
|
|
6820
|
+
});
|
|
6821
|
+
child.on("error", (err) => {
|
|
6822
|
+
const missing = err.code === "ENOENT";
|
|
6823
|
+
fail(new KiokuError(missing ? NOT_INSTALLED : err.message, missing ? 404 : 502));
|
|
6824
|
+
});
|
|
6825
|
+
child.on("close", (code) => {
|
|
6826
|
+
if (this.viewer === started)
|
|
6827
|
+
this.viewer = null;
|
|
6828
|
+
fail(new KiokuError(tailOutput(stderr, 1) || `kioku web exited with code ${code}`));
|
|
6829
|
+
});
|
|
6830
|
+
});
|
|
6831
|
+
started.catch(() => {
|
|
6832
|
+
if (this.viewer === started)
|
|
6833
|
+
this.viewer = null;
|
|
6834
|
+
});
|
|
6835
|
+
return started;
|
|
6659
6836
|
}
|
|
6660
|
-
|
|
6661
|
-
|
|
6837
|
+
stopViewer() {
|
|
6838
|
+
void this.viewer?.then((v) => v.child.kill(), () => {
|
|
6839
|
+
});
|
|
6840
|
+
this.viewer = null;
|
|
6662
6841
|
}
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
var higherGT = (a, b, options) => {
|
|
6666
|
-
if (!a) {
|
|
6667
|
-
return b;
|
|
6842
|
+
dispose() {
|
|
6843
|
+
this.stopViewer();
|
|
6668
6844
|
}
|
|
6669
|
-
const comp = compare(a.semver, b.semver, options);
|
|
6670
|
-
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
6671
6845
|
};
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6846
|
+
}
|
|
6847
|
+
});
|
|
6848
|
+
|
|
6849
|
+
// ../core/dist/kioku-routes.js
|
|
6850
|
+
import { Hono as Hono4 } from "hono";
|
|
6851
|
+
function kiokuRoutes(kioku = new Kioku(), options = {}) {
|
|
6852
|
+
const app = new Hono4();
|
|
6853
|
+
app.onError((err, c) => {
|
|
6854
|
+
if (err instanceof KiokuError)
|
|
6855
|
+
return c.json({ error: err.message }, err.status);
|
|
6856
|
+
throw err;
|
|
6857
|
+
});
|
|
6858
|
+
app.get("/status", async (c) => c.json(await kioku.status(c.req.query("fresh") === "1")));
|
|
6859
|
+
app.post("/pages", async (c) => {
|
|
6860
|
+
const input = await c.req.json().catch(() => ({}));
|
|
6861
|
+
const brain = input.brain?.trim();
|
|
6862
|
+
const title = input.title?.trim();
|
|
6863
|
+
const summary = input.summary?.trim();
|
|
6864
|
+
if (!brain || !input.type || !title || !summary || !input.body?.trim())
|
|
6865
|
+
return c.json({ error: "brain, type, title, summary and body are required" }, 400);
|
|
6866
|
+
const result2 = await kioku.save({ brain, type: input.type, title, summary, body: input.body, namespace: input.namespace?.trim() || void 0, create: input.create === true });
|
|
6867
|
+
return c.json(result2, result2.status === "done" ? 201 : 200);
|
|
6868
|
+
});
|
|
6869
|
+
app.post("/brains", async (c) => {
|
|
6870
|
+
const { repo, tier, team, language } = await body(c);
|
|
6871
|
+
return c.json(await kioku.createBrain({ repo: trim(repo) ?? "", tier: tier ?? "", team: trim(team), language: trim(language) }), 201);
|
|
6872
|
+
});
|
|
6873
|
+
app.post("/areas", async (c) => {
|
|
6874
|
+
const { brain, area, summary } = await body(c);
|
|
6875
|
+
return c.json(await kioku.addArea(brain ?? "", trim(area) ?? "", trim(summary) ?? ""), 201);
|
|
6876
|
+
});
|
|
6877
|
+
app.post("/link", async (c) => {
|
|
6878
|
+
const { project, brain, team } = await body(c);
|
|
6879
|
+
return c.json(await kioku.linkProject({ project: project ?? "", brain: trim(brain), team: trim(team) }));
|
|
6880
|
+
});
|
|
6881
|
+
app.post("/publish", async (c) => {
|
|
6882
|
+
const { brain, to, understood } = await body(c);
|
|
6883
|
+
if (understood !== true)
|
|
6884
|
+
return c.json({ error: "publishing needs the warning accepted" }, 400);
|
|
6885
|
+
return c.json(await kioku.publish(brain ?? "", trim(to)));
|
|
6886
|
+
});
|
|
6887
|
+
app.get("/releases", async (c) => c.json(await kioku.releases(c.req.query("fresh") === "1")));
|
|
6888
|
+
app.post("/update/check", async (c) => c.json(await kioku.checkUpdate(trim((await body(c)).version) ?? "")));
|
|
6889
|
+
app.post("/update", async (c) => c.json(await kioku.update(trim((await body(c)).version) ?? "")));
|
|
6890
|
+
app.get("/labs", async (c) => c.json(await kioku.labs()));
|
|
6891
|
+
app.post("/labs/:name", async (c) => {
|
|
6892
|
+
const { enabled } = await body(c);
|
|
6893
|
+
if (typeof enabled !== "boolean")
|
|
6894
|
+
return c.json({ error: "enabled is true or false" }, 400);
|
|
6895
|
+
return c.json(await kioku.setLab(c.req.param("name"), enabled));
|
|
6896
|
+
});
|
|
6897
|
+
app.post("/remember", async (c) => {
|
|
6898
|
+
const { project, sessionDir, text: text2 } = await c.req.json().catch(() => ({}));
|
|
6899
|
+
const line = text2?.trim();
|
|
6900
|
+
if (!project || !sessionDir || !line)
|
|
6901
|
+
return c.json({ error: "project, sessionDir and text are required" }, 400);
|
|
6902
|
+
if (line.length > REMEMBER_MAX)
|
|
6903
|
+
return c.json({ error: `keep it under ${REMEMBER_MAX} characters` }, 400);
|
|
6904
|
+
if (options.canRemember && !options.canRemember(project, sessionDir))
|
|
6905
|
+
return c.json({ error: "only Claude Code sessions have kioku's skill" }, 400);
|
|
6906
|
+
if (!options.type?.(project, sessionDir, rememberPrompt(line)))
|
|
6907
|
+
return c.json({ error: "the session has no live terminal" }, 409);
|
|
6908
|
+
return c.json({ ok: true });
|
|
6909
|
+
});
|
|
6910
|
+
app.post("/viewer", async (c) => c.json({ address: await kioku.openViewer() }));
|
|
6911
|
+
app.delete("/viewer", (c) => {
|
|
6912
|
+
kioku.stopViewer();
|
|
6913
|
+
return c.json({ ok: true });
|
|
6914
|
+
});
|
|
6915
|
+
return app;
|
|
6916
|
+
}
|
|
6917
|
+
var trim, REMEMBER_MAX, body;
|
|
6918
|
+
var init_kioku_routes = __esm({
|
|
6919
|
+
"../core/dist/kioku-routes.js"() {
|
|
6920
|
+
"use strict";
|
|
6921
|
+
init_kioku();
|
|
6922
|
+
trim = (value) => value?.trim() || void 0;
|
|
6923
|
+
REMEMBER_MAX = 500;
|
|
6924
|
+
body = (c) => c.req.json().catch(() => ({}));
|
|
6925
|
+
}
|
|
6926
|
+
});
|
|
6927
|
+
|
|
6928
|
+
// ../sdk/dist/define.js
|
|
6929
|
+
function isShellExecutor(run2) {
|
|
6930
|
+
return typeof run2 === "object" && run2 !== null && run2.kind === "shell";
|
|
6931
|
+
}
|
|
6932
|
+
var SDK_VERSION, MODULE_ID_RE;
|
|
6933
|
+
var init_define = __esm({
|
|
6934
|
+
"../sdk/dist/define.js"() {
|
|
6935
|
+
"use strict";
|
|
6936
|
+
SDK_VERSION = "1.0.0";
|
|
6937
|
+
MODULE_ID_RE = /^[a-z][a-z0-9-]{1,31}$/;
|
|
6938
|
+
}
|
|
6939
|
+
});
|
|
6940
|
+
|
|
6941
|
+
// ../sdk/dist/errors.js
|
|
6942
|
+
var PermissionError;
|
|
6943
|
+
var init_errors = __esm({
|
|
6944
|
+
"../sdk/dist/errors.js"() {
|
|
6945
|
+
"use strict";
|
|
6946
|
+
PermissionError = class extends Error {
|
|
6947
|
+
permission;
|
|
6948
|
+
value;
|
|
6949
|
+
constructor(permission, value) {
|
|
6950
|
+
super(`permission ${permission} does not cover ${value}`);
|
|
6951
|
+
this.name = "PermissionError";
|
|
6952
|
+
this.permission = permission;
|
|
6953
|
+
this.value = value;
|
|
6675
6954
|
}
|
|
6676
|
-
const comp = compare(a.semver, b.semver, options);
|
|
6677
|
-
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
6678
6955
|
};
|
|
6679
|
-
module.exports = subset;
|
|
6680
6956
|
}
|
|
6681
6957
|
});
|
|
6682
6958
|
|
|
6683
|
-
//
|
|
6684
|
-
var
|
|
6685
|
-
"
|
|
6959
|
+
// ../sdk/dist/index.js
|
|
6960
|
+
var init_dist = __esm({
|
|
6961
|
+
"../sdk/dist/index.js"() {
|
|
6686
6962
|
"use strict";
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
var SemVer = require_semver();
|
|
6690
|
-
var identifiers = require_identifiers();
|
|
6691
|
-
var parse = require_parse();
|
|
6692
|
-
var valid = require_valid();
|
|
6693
|
-
var clean = require_clean();
|
|
6694
|
-
var inc = require_inc();
|
|
6695
|
-
var diff = require_diff();
|
|
6696
|
-
var major = require_major();
|
|
6697
|
-
var minor = require_minor();
|
|
6698
|
-
var patch = require_patch();
|
|
6699
|
-
var prerelease = require_prerelease();
|
|
6700
|
-
var compare = require_compare();
|
|
6701
|
-
var rcompare = require_rcompare();
|
|
6702
|
-
var compareLoose = require_compare_loose();
|
|
6703
|
-
var compareBuild = require_compare_build();
|
|
6704
|
-
var sort = require_sort();
|
|
6705
|
-
var rsort = require_rsort();
|
|
6706
|
-
var gt = require_gt();
|
|
6707
|
-
var lt = require_lt();
|
|
6708
|
-
var eq = require_eq();
|
|
6709
|
-
var neq = require_neq();
|
|
6710
|
-
var gte = require_gte();
|
|
6711
|
-
var lte = require_lte();
|
|
6712
|
-
var cmp = require_cmp();
|
|
6713
|
-
var coerce = require_coerce();
|
|
6714
|
-
var truncate = require_truncate();
|
|
6715
|
-
var Comparator = require_comparator();
|
|
6716
|
-
var Range = require_range();
|
|
6717
|
-
var satisfies = require_satisfies();
|
|
6718
|
-
var toComparators = require_to_comparators();
|
|
6719
|
-
var maxSatisfying = require_max_satisfying();
|
|
6720
|
-
var minSatisfying = require_min_satisfying();
|
|
6721
|
-
var minVersion = require_min_version();
|
|
6722
|
-
var validRange = require_valid2();
|
|
6723
|
-
var outside = require_outside();
|
|
6724
|
-
var gtr = require_gtr();
|
|
6725
|
-
var ltr = require_ltr();
|
|
6726
|
-
var intersects = require_intersects();
|
|
6727
|
-
var simplifyRange = require_simplify();
|
|
6728
|
-
var subset = require_subset();
|
|
6729
|
-
module.exports = {
|
|
6730
|
-
parse,
|
|
6731
|
-
valid,
|
|
6732
|
-
clean,
|
|
6733
|
-
inc,
|
|
6734
|
-
diff,
|
|
6735
|
-
major,
|
|
6736
|
-
minor,
|
|
6737
|
-
patch,
|
|
6738
|
-
prerelease,
|
|
6739
|
-
compare,
|
|
6740
|
-
rcompare,
|
|
6741
|
-
compareLoose,
|
|
6742
|
-
compareBuild,
|
|
6743
|
-
sort,
|
|
6744
|
-
rsort,
|
|
6745
|
-
gt,
|
|
6746
|
-
lt,
|
|
6747
|
-
eq,
|
|
6748
|
-
neq,
|
|
6749
|
-
gte,
|
|
6750
|
-
lte,
|
|
6751
|
-
cmp,
|
|
6752
|
-
coerce,
|
|
6753
|
-
truncate,
|
|
6754
|
-
Comparator,
|
|
6755
|
-
Range,
|
|
6756
|
-
satisfies,
|
|
6757
|
-
toComparators,
|
|
6758
|
-
maxSatisfying,
|
|
6759
|
-
minSatisfying,
|
|
6760
|
-
minVersion,
|
|
6761
|
-
validRange,
|
|
6762
|
-
outside,
|
|
6763
|
-
gtr,
|
|
6764
|
-
ltr,
|
|
6765
|
-
intersects,
|
|
6766
|
-
simplifyRange,
|
|
6767
|
-
subset,
|
|
6768
|
-
SemVer,
|
|
6769
|
-
re: internalRe.re,
|
|
6770
|
-
src: internalRe.src,
|
|
6771
|
-
tokens: internalRe.t,
|
|
6772
|
-
SEMVER_SPEC_VERSION: constants3.SEMVER_SPEC_VERSION,
|
|
6773
|
-
RELEASE_TYPES: constants3.RELEASE_TYPES,
|
|
6774
|
-
compareIdentifiers: identifiers.compareIdentifiers,
|
|
6775
|
-
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
6776
|
-
};
|
|
6963
|
+
init_define();
|
|
6964
|
+
init_errors();
|
|
6777
6965
|
}
|
|
6778
6966
|
});
|
|
6779
6967
|
|
|
@@ -6810,7 +6998,7 @@ function expandOne(template, settings, kind) {
|
|
|
6810
6998
|
const out = [];
|
|
6811
6999
|
for (const item of items) {
|
|
6812
7000
|
let missing = false;
|
|
6813
|
-
const
|
|
7001
|
+
const text2 = template.replace(TEMPLATE_RE, (_all, key, isList, field, offset) => {
|
|
6814
7002
|
const v = isList ? item?.[field] : settings[key];
|
|
6815
7003
|
const s = typeof v === "string" ? v : typeof v === "number" && Number.isFinite(v) ? String(v) : "";
|
|
6816
7004
|
if (s && safeValue(s, kind, offset === 0))
|
|
@@ -6819,7 +7007,7 @@ function expandOne(template, settings, kind) {
|
|
|
6819
7007
|
return "";
|
|
6820
7008
|
});
|
|
6821
7009
|
if (!missing)
|
|
6822
|
-
out.push(
|
|
7010
|
+
out.push(text2);
|
|
6823
7011
|
}
|
|
6824
7012
|
return out;
|
|
6825
7013
|
}
|
|
@@ -6875,9 +7063,9 @@ var init_module_permissions = __esm({
|
|
|
6875
7063
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
6876
7064
|
import { join as join15, resolve as resolve5, sep as sep3 } from "node:path";
|
|
6877
7065
|
function checkSdk(range, version = SDK_VERSION) {
|
|
6878
|
-
if (!
|
|
7066
|
+
if (!import_semver2.default.validRange(range))
|
|
6879
7067
|
return `sdk range "${range}" is not valid semver`;
|
|
6880
|
-
return
|
|
7068
|
+
return import_semver2.default.satisfies(version, range) ? null : `needs SDK ${range}, Forge has ${version}`;
|
|
6881
7069
|
}
|
|
6882
7070
|
function checkManifest(raw, moduleDir) {
|
|
6883
7071
|
if (!isObject(raw))
|
|
@@ -6888,7 +7076,7 @@ function checkManifest(raw, moduleDir) {
|
|
|
6888
7076
|
return { kind: "legacy", manifest: raw };
|
|
6889
7077
|
}
|
|
6890
7078
|
const errors = [];
|
|
6891
|
-
const err = (path,
|
|
7079
|
+
const err = (path, message2) => errors.push(`${path}: ${message2}`);
|
|
6892
7080
|
for (const key of Object.keys(raw))
|
|
6893
7081
|
if (!TOP_LEVEL.has(key))
|
|
6894
7082
|
err(`/${key}`, "unknown field");
|
|
@@ -7026,8 +7214,8 @@ function scalar(def, raw, path, errors) {
|
|
|
7026
7214
|
errors.push({ path, message: "required" });
|
|
7027
7215
|
return void 0;
|
|
7028
7216
|
}
|
|
7029
|
-
const fail = (
|
|
7030
|
-
errors.push({ path, message });
|
|
7217
|
+
const fail = (message2) => {
|
|
7218
|
+
errors.push({ path, message: message2 });
|
|
7031
7219
|
return void 0;
|
|
7032
7220
|
};
|
|
7033
7221
|
switch (def.type) {
|
|
@@ -7051,11 +7239,11 @@ function scalar(def, raw, path, errors) {
|
|
|
7051
7239
|
return typeof v === "string" && def.values.includes(v) ? v : fail(`must be one of ${def.values.join(", ")}`);
|
|
7052
7240
|
}
|
|
7053
7241
|
}
|
|
7054
|
-
var
|
|
7242
|
+
var import_semver2, V1_FIELDS, TOP_LEVEL, PERMISSIONS, SCALAR_TYPES, FORMATS, isObject, isStringArray;
|
|
7055
7243
|
var init_module_manifest = __esm({
|
|
7056
7244
|
"../core/dist/module-manifest.js"() {
|
|
7057
7245
|
"use strict";
|
|
7058
|
-
|
|
7246
|
+
import_semver2 = __toESM(require_semver2(), 1);
|
|
7059
7247
|
init_dist();
|
|
7060
7248
|
init_module_permissions();
|
|
7061
7249
|
V1_FIELDS = ["server", "view", "permissions", "id"];
|
|
@@ -7216,8 +7404,8 @@ import { existsSync as existsSync13, readdirSync as readdirSync7, readFileSync a
|
|
|
7216
7404
|
import { basename as basename4, dirname as dirname7, join as join16, resolve as resolve6, sep as sep4 } from "node:path";
|
|
7217
7405
|
import { pathToFileURL } from "node:url";
|
|
7218
7406
|
function disabled(id, c, reason, m) {
|
|
7219
|
-
const
|
|
7220
|
-
return { id, name:
|
|
7407
|
+
const text2 = (v, fallback) => typeof v === "string" && v ? v : fallback;
|
|
7408
|
+
return { id, name: text2(m?.name, id), version: text2(m?.version, ""), displayName: text2(m?.displayName, id), source: c.source, state: "disabled", reason };
|
|
7221
7409
|
}
|
|
7222
7410
|
function packages(root, source, packaged) {
|
|
7223
7411
|
if (!existsSync13(root))
|
|
@@ -7679,8 +7867,8 @@ var init_module_install = __esm({
|
|
|
7679
7867
|
expand = (spec, cwd) => resolve7(cwd, expandHome(spec));
|
|
7680
7868
|
InstallError = class extends Error {
|
|
7681
7869
|
code;
|
|
7682
|
-
constructor(code,
|
|
7683
|
-
super(
|
|
7870
|
+
constructor(code, message2) {
|
|
7871
|
+
super(message2);
|
|
7684
7872
|
this.code = code;
|
|
7685
7873
|
}
|
|
7686
7874
|
};
|
|
@@ -8011,11 +8199,11 @@ async function run(found, confirmation, output, requestSignal) {
|
|
|
8011
8199
|
return action.run(input, ctx);
|
|
8012
8200
|
}
|
|
8013
8201
|
async function readJson3(c) {
|
|
8014
|
-
const
|
|
8015
|
-
if (!
|
|
8202
|
+
const text2 = await c.req.text();
|
|
8203
|
+
if (!text2)
|
|
8016
8204
|
return void 0;
|
|
8017
8205
|
try {
|
|
8018
|
-
return JSON.parse(
|
|
8206
|
+
return JSON.parse(text2);
|
|
8019
8207
|
} catch {
|
|
8020
8208
|
return void 0;
|
|
8021
8209
|
}
|
|
@@ -8027,10 +8215,10 @@ function describe(err) {
|
|
|
8027
8215
|
if (err instanceof PermissionError)
|
|
8028
8216
|
return { code: "permission", message: err.message, permission: err.permission, value: err.value };
|
|
8029
8217
|
const e = err;
|
|
8030
|
-
const
|
|
8218
|
+
const message2 = typeof e?.message === "string" ? e.message : String(err);
|
|
8031
8219
|
if (e?.name === "ModuleError" && typeof e.code === "string")
|
|
8032
|
-
return { code: e.code, message };
|
|
8033
|
-
return { code: "module_error", message };
|
|
8220
|
+
return { code: e.code, message: message2 };
|
|
8221
|
+
return { code: "module_error", message: message2 };
|
|
8034
8222
|
}
|
|
8035
8223
|
function errorResponse(c, mod, err) {
|
|
8036
8224
|
const body2 = describe(err);
|
|
@@ -8084,8 +8272,8 @@ var init_module_routes = __esm({
|
|
|
8084
8272
|
});
|
|
8085
8273
|
|
|
8086
8274
|
// ../core/dist/module-jobs.js
|
|
8087
|
-
function parseEvery(
|
|
8088
|
-
const m = /^(\d+)(s|m|h)$/.exec(
|
|
8275
|
+
function parseEvery(text2) {
|
|
8276
|
+
const m = /^(\d+)(s|m|h)$/.exec(text2.trim());
|
|
8089
8277
|
if (!m)
|
|
8090
8278
|
throw new Error("every must look like 30s, 2m or 1h");
|
|
8091
8279
|
const ms = Number(m[1]) * UNITS[m[2]];
|
|
@@ -8257,9 +8445,9 @@ function createForgeServer(options) {
|
|
|
8257
8445
|
const generalSessions = new GeneralSessions(join18(dataDir, "general-sessions.json"));
|
|
8258
8446
|
const terminalWss = createTerminalWss(ptyManager, cwReader, { localOnly, general: generalSessions });
|
|
8259
8447
|
app.route("/api/liveframe", liveframeRoutes());
|
|
8260
|
-
const kioku = new Kioku({ projects: () => cwReader.getProjects() });
|
|
8448
|
+
const kioku = new Kioku({ projects: () => cwReader.getProjects(), pluginInstalls: () => installsOf(cwReader, "kioku") });
|
|
8261
8449
|
app.route("/api/kioku", kiokuRoutes(kioku, {
|
|
8262
|
-
type: (project, sessionDir,
|
|
8450
|
+
type: (project, sessionDir, text2) => ptyManager.typeLine(project, sessionDir, text2),
|
|
8263
8451
|
// kioku's plugin, and so its skill, exists only for Claude Code
|
|
8264
8452
|
canRemember: (project, sessionDir) => cwReader.getSession(project, sessionDir)?.harness === "claude"
|
|
8265
8453
|
}));
|
|
@@ -8273,11 +8461,11 @@ function createForgeServer(options) {
|
|
|
8273
8461
|
}
|
|
8274
8462
|
});
|
|
8275
8463
|
const moduleEvents = new ModuleEvents({
|
|
8276
|
-
onError: (id,
|
|
8464
|
+
onError: (id, message2) => {
|
|
8277
8465
|
const status = moduleHost.get(id)?.status;
|
|
8278
8466
|
if (status)
|
|
8279
|
-
status.lastEventError =
|
|
8280
|
-
console.warn(`[module ${id}] ${
|
|
8467
|
+
status.lastEventError = message2;
|
|
8468
|
+
console.warn(`[module ${id}] ${message2}`);
|
|
8281
8469
|
}
|
|
8282
8470
|
});
|
|
8283
8471
|
const startModule = (mod) => {
|
|
@@ -8522,6 +8710,7 @@ var init_server = __esm({
|
|
|
8522
8710
|
init_module_jobs();
|
|
8523
8711
|
init_module_events();
|
|
8524
8712
|
init_kioku();
|
|
8713
|
+
init_plugins();
|
|
8525
8714
|
}
|
|
8526
8715
|
});
|
|
8527
8716
|
|