forge-cw 0.1.14 → 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 +1303 -1074
- package/package.json +3 -3
- package/console/assets/index-DvMplpgv.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;
|
|
@@ -2657,12 +2657,60 @@ function splitPluginId(id) {
|
|
|
2657
2657
|
const at = id.lastIndexOf("@");
|
|
2658
2658
|
return { name: id.slice(0, at), marketplace: id.slice(at + 1) };
|
|
2659
2659
|
}
|
|
2660
|
+
function catalogVersion(configDir, marketplaces, marketplace, name) {
|
|
2661
|
+
const known = marketplaces[marketplace];
|
|
2662
|
+
const location = isRecord(known) && typeof known["installLocation"] === "string" ? known["installLocation"] : join8(configDir, "plugins", "marketplaces", marketplace);
|
|
2663
|
+
const entries = readJson(join8(location, ".claude-plugin", "marketplace.json"))["plugins"];
|
|
2664
|
+
if (!Array.isArray(entries))
|
|
2665
|
+
return void 0;
|
|
2666
|
+
const entry = entries.find((e) => isRecord(e) && e["name"] === name);
|
|
2667
|
+
if (!entry)
|
|
2668
|
+
return void 0;
|
|
2669
|
+
if (typeof entry["version"] === "string")
|
|
2670
|
+
return entry["version"];
|
|
2671
|
+
const source = entry["source"];
|
|
2672
|
+
if (typeof source !== "string")
|
|
2673
|
+
return void 0;
|
|
2674
|
+
const dir = resolve2(location, source);
|
|
2675
|
+
if (!inside(location, dir))
|
|
2676
|
+
return void 0;
|
|
2677
|
+
const version = readJson(join8(dir, ".claude-plugin", "plugin.json"))["version"];
|
|
2678
|
+
return typeof version === "string" ? version : void 0;
|
|
2679
|
+
}
|
|
2680
|
+
function hasUpdate({ latest, version }) {
|
|
2681
|
+
if (!latest || latest === version)
|
|
2682
|
+
return false;
|
|
2683
|
+
const a = numeric(latest);
|
|
2684
|
+
const b = numeric(version);
|
|
2685
|
+
if (!a || !b)
|
|
2686
|
+
return true;
|
|
2687
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
2688
|
+
const d = (a[i] ?? 0) - (b[i] ?? 0);
|
|
2689
|
+
if (d !== 0)
|
|
2690
|
+
return d > 0;
|
|
2691
|
+
}
|
|
2692
|
+
return false;
|
|
2693
|
+
}
|
|
2660
2694
|
function projectSkillNames(projectPath) {
|
|
2661
2695
|
const dir = join8(projectPath, ".claude", "skills");
|
|
2662
2696
|
if (!existsSync6(dir))
|
|
2663
2697
|
return [];
|
|
2664
2698
|
return readdirSync4(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && existsSync6(join8(dir, e.name, "SKILL.md"))).map((e) => e.name).sort();
|
|
2665
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
|
+
}
|
|
2666
2714
|
async function listPlugins(reader, remoteOf) {
|
|
2667
2715
|
const found = /* @__PURE__ */ new Map();
|
|
2668
2716
|
for (const { scope, scopeRef } of pluginScopes(reader)) {
|
|
@@ -2678,16 +2726,21 @@ async function listPlugins(reader, remoteOf) {
|
|
|
2678
2726
|
const user = entries.find((e) => isRecord(e) && e["scope"] === "user" && typeof e["installPath"] === "string");
|
|
2679
2727
|
if (!user)
|
|
2680
2728
|
continue;
|
|
2729
|
+
const { name, marketplace } = splitPluginId(id);
|
|
2730
|
+
const version = String(user["version"] ?? "");
|
|
2731
|
+
const latest = catalogVersion(configDir, marketplaces, marketplace, name);
|
|
2681
2732
|
const install = {
|
|
2682
2733
|
scope,
|
|
2683
2734
|
scopeRef,
|
|
2684
|
-
version
|
|
2735
|
+
version,
|
|
2685
2736
|
enabled: !isRecord(enabledPlugins) || enabledPlugins[id] !== false,
|
|
2686
2737
|
installPath: String(user["installPath"]),
|
|
2687
|
-
lastUpdated: typeof user["lastUpdated"] === "string" ? user["lastUpdated"] : void 0
|
|
2738
|
+
lastUpdated: typeof user["lastUpdated"] === "string" ? user["lastUpdated"] : void 0,
|
|
2739
|
+
latest,
|
|
2740
|
+
update: hasUpdate({ latest, version })
|
|
2688
2741
|
};
|
|
2689
2742
|
const list = found.get(id) ?? [];
|
|
2690
|
-
list.push({ install, repo: marketplaceSource(marketplaces[
|
|
2743
|
+
list.push({ install, repo: marketplaceSource(marketplaces[marketplace]) });
|
|
2691
2744
|
found.set(id, list);
|
|
2692
2745
|
}
|
|
2693
2746
|
}
|
|
@@ -2757,7 +2810,7 @@ function marketplaceSourceOf(reader, marketplace) {
|
|
|
2757
2810
|
}
|
|
2758
2811
|
return void 0;
|
|
2759
2812
|
}
|
|
2760
|
-
var isRecord, inside, pluginScopes, knownMarketplaces, knowsMarketplace;
|
|
2813
|
+
var isRecord, inside, pluginScopes, knownMarketplaces, numeric, pluginUpdateArgs, knowsMarketplace;
|
|
2761
2814
|
var init_plugins = __esm({
|
|
2762
2815
|
"../core/dist/plugins.js"() {
|
|
2763
2816
|
"use strict";
|
|
@@ -2772,6 +2825,8 @@ var init_plugins = __esm({
|
|
|
2772
2825
|
...reader.getAccounts().map((a) => ({ scope: "account", scopeRef: a }))
|
|
2773
2826
|
];
|
|
2774
2827
|
knownMarketplaces = (configDir) => readJson(join8(configDir, "plugins", "known_marketplaces.json"));
|
|
2828
|
+
numeric = (v) => /^\d+(\.\d+)*$/.test(v) ? v.split(".").map(Number) : null;
|
|
2829
|
+
pluginUpdateArgs = (id) => [["plugin", "marketplace", "update", splitPluginId(id).marketplace], ["plugin", "update", id]];
|
|
2775
2830
|
knowsMarketplace = (configDir, marketplace) => isRecord(knownMarketplaces(configDir)[marketplace]);
|
|
2776
2831
|
}
|
|
2777
2832
|
});
|
|
@@ -2864,8 +2919,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2864
2919
|
cpSync(source, target, { recursive: true });
|
|
2865
2920
|
return c.json({ ok: true });
|
|
2866
2921
|
} catch (err) {
|
|
2867
|
-
const
|
|
2868
|
-
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);
|
|
2869
2924
|
}
|
|
2870
2925
|
});
|
|
2871
2926
|
app.get("/global/:name", (c) => {
|
|
@@ -2901,8 +2956,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2901
2956
|
writeFileSync2(join9(dir, "SKILL.md"), content, "utf-8");
|
|
2902
2957
|
return c.json({ ok: true, dir });
|
|
2903
2958
|
} catch (err) {
|
|
2904
|
-
const
|
|
2905
|
-
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);
|
|
2906
2961
|
}
|
|
2907
2962
|
});
|
|
2908
2963
|
const scopePatterns = [
|
|
@@ -2928,8 +2983,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2928
2983
|
writeFileSync2(skillMd, content, "utf-8");
|
|
2929
2984
|
return c.json({ ok: true });
|
|
2930
2985
|
} catch (err) {
|
|
2931
|
-
const
|
|
2932
|
-
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);
|
|
2933
2988
|
}
|
|
2934
2989
|
});
|
|
2935
2990
|
app.put(`${pattern}/references/:filename`, async (c) => {
|
|
@@ -2952,8 +3007,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2952
3007
|
writeFileSync2(join9(refsDir, filename), content, "utf-8");
|
|
2953
3008
|
return c.json({ ok: true });
|
|
2954
3009
|
} catch (err) {
|
|
2955
|
-
const
|
|
2956
|
-
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);
|
|
2957
3012
|
}
|
|
2958
3013
|
});
|
|
2959
3014
|
app.delete(`${pattern}/references/:filename`, (c) => {
|
|
@@ -2973,8 +3028,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2973
3028
|
unlinkSync(refFile);
|
|
2974
3029
|
return c.json({ ok: true });
|
|
2975
3030
|
} catch (err) {
|
|
2976
|
-
const
|
|
2977
|
-
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);
|
|
2978
3033
|
}
|
|
2979
3034
|
});
|
|
2980
3035
|
app.delete(pattern, (c) => {
|
|
@@ -2992,8 +3047,8 @@ function skillRoutes(reader, options = {}) {
|
|
|
2992
3047
|
rmSync2(dir, { recursive: true, force: true });
|
|
2993
3048
|
return c.json({ ok: true });
|
|
2994
3049
|
} catch (err) {
|
|
2995
|
-
const
|
|
2996
|
-
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);
|
|
2997
3052
|
}
|
|
2998
3053
|
});
|
|
2999
3054
|
}
|
|
@@ -3056,7 +3111,7 @@ function skillRoutes(reader, options = {}) {
|
|
|
3056
3111
|
const install = plugin?.installs.find((i) => i.scope === scope && i.scopeRef === ref);
|
|
3057
3112
|
if (!plugin || !install)
|
|
3058
3113
|
return c.json({ error: `${id} is not installed in ${ref || "that scope"}` }, 404);
|
|
3059
|
-
const failed = await runClaude(install.scope, ref,
|
|
3114
|
+
const failed = await runClaude(install.scope, ref, pluginUpdateArgs(plugin.id), `Failed to update ${plugin.name}`);
|
|
3060
3115
|
if (failed)
|
|
3061
3116
|
return c.json({ error: failed.error }, failed.status);
|
|
3062
3117
|
const version = (await find())?.installs.find((i) => i.scope === install.scope && i.scopeRef === ref)?.version ?? install.version;
|
|
@@ -3263,10 +3318,10 @@ var init_pty_manager = __esm({
|
|
|
3263
3318
|
if (ptySession.scrollback.length > SCROLLBACK_LIMIT) {
|
|
3264
3319
|
ptySession.scrollback.splice(0, ptySession.scrollback.length - SCROLLBACK_LIMIT);
|
|
3265
3320
|
}
|
|
3266
|
-
const
|
|
3321
|
+
const message2 = JSON.stringify({ type: "output", data });
|
|
3267
3322
|
for (const client of ptySession.clients) {
|
|
3268
3323
|
try {
|
|
3269
|
-
client.send(
|
|
3324
|
+
client.send(message2);
|
|
3270
3325
|
} catch {
|
|
3271
3326
|
ptySession.clients.delete(client);
|
|
3272
3327
|
}
|
|
@@ -3274,10 +3329,10 @@ var init_pty_manager = __esm({
|
|
|
3274
3329
|
});
|
|
3275
3330
|
ptySession.onExitDisposable = ptyProcess.onExit(({ exitCode }) => {
|
|
3276
3331
|
this.states?.exit(key, exitCode);
|
|
3277
|
-
const
|
|
3332
|
+
const message2 = JSON.stringify({ type: "exit", code: exitCode });
|
|
3278
3333
|
for (const client of ptySession.clients) {
|
|
3279
3334
|
try {
|
|
3280
|
-
client.send(
|
|
3335
|
+
client.send(message2);
|
|
3281
3336
|
} catch {
|
|
3282
3337
|
}
|
|
3283
3338
|
}
|
|
@@ -3331,11 +3386,11 @@ var init_pty_manager = __esm({
|
|
|
3331
3386
|
return this.sessions.get(sessionId);
|
|
3332
3387
|
}
|
|
3333
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
|
|
3334
|
-
typeLine(project, sessionDir,
|
|
3389
|
+
typeLine(project, sessionDir, text2) {
|
|
3335
3390
|
const session = this.sessions.get(this.makeKey(project, sessionDir));
|
|
3336
3391
|
if (!session)
|
|
3337
3392
|
return false;
|
|
3338
|
-
session.pty.write(
|
|
3393
|
+
session.pty.write(text2);
|
|
3339
3394
|
setTimeout(() => session.pty.write("\r"), 150);
|
|
3340
3395
|
return true;
|
|
3341
3396
|
}
|
|
@@ -3372,11 +3427,11 @@ var init_pty_manager = __esm({
|
|
|
3372
3427
|
});
|
|
3373
3428
|
|
|
3374
3429
|
// ../core/dist/state-classifier-local.js
|
|
3375
|
-
function latestMarker(
|
|
3430
|
+
function latestMarker(text2, markers) {
|
|
3376
3431
|
let best = null;
|
|
3377
3432
|
let bestAt = -1;
|
|
3378
3433
|
for (const marker of markers) {
|
|
3379
|
-
const at = lastIndex(
|
|
3434
|
+
const at = lastIndex(text2, marker.re);
|
|
3380
3435
|
if (at > bestAt) {
|
|
3381
3436
|
best = marker;
|
|
3382
3437
|
bestAt = at;
|
|
@@ -3411,9 +3466,9 @@ var init_state_classifier_local = __esm({
|
|
|
3411
3466
|
// a spinner that stopped moving: a stall or a slow redraw, so it is only a guess
|
|
3412
3467
|
{ state: "working", confidence: 0.5, re: new RegExp("\\p{Lu}\\p{Ll}+ing\u2026|\\(\\d+s \xB7 |esc to interrupt", "gu") }
|
|
3413
3468
|
];
|
|
3414
|
-
lastIndex = (
|
|
3469
|
+
lastIndex = (text2, re) => {
|
|
3415
3470
|
let at = -1;
|
|
3416
|
-
for (const m of
|
|
3471
|
+
for (const m of text2.matchAll(re))
|
|
3417
3472
|
at = (m.index ?? 0) + m[0].length;
|
|
3418
3473
|
return at;
|
|
3419
3474
|
};
|
|
@@ -3422,8 +3477,8 @@ var init_state_classifier_local = __esm({
|
|
|
3422
3477
|
});
|
|
3423
3478
|
|
|
3424
3479
|
// ../core/dist/state-classifier-jev.js
|
|
3425
|
-
function jevScreen(
|
|
3426
|
-
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");
|
|
3427
3482
|
return kept.slice(-SCREEN_CHARS);
|
|
3428
3483
|
}
|
|
3429
3484
|
function createJevClassifier({ apiKey, model = "jev-latest", timeoutMs = 3e3, fetch: fetch2 = globalThis.fetch }) {
|
|
@@ -3516,11 +3571,11 @@ var init_terminal_screen = __esm({
|
|
|
3516
3571
|
const line = buffer.getLine(y);
|
|
3517
3572
|
if (!line)
|
|
3518
3573
|
continue;
|
|
3519
|
-
const
|
|
3574
|
+
const text2 = line.translateToString(false);
|
|
3520
3575
|
if (line.isWrapped && rows.length)
|
|
3521
|
-
rows[rows.length - 1] +=
|
|
3576
|
+
rows[rows.length - 1] += text2;
|
|
3522
3577
|
else
|
|
3523
|
-
rows.push(
|
|
3578
|
+
rows.push(text2);
|
|
3524
3579
|
}
|
|
3525
3580
|
const trimmed = rows.map((r) => r.trimEnd());
|
|
3526
3581
|
while (trimmed.length && !trimmed[trimmed.length - 1])
|
|
@@ -3952,8 +4007,8 @@ var init_liveframe = __esm({
|
|
|
3952
4007
|
init_output();
|
|
3953
4008
|
LiveframeError = class extends Error {
|
|
3954
4009
|
status;
|
|
3955
|
-
constructor(
|
|
3956
|
-
super(
|
|
4010
|
+
constructor(message2, status = 502) {
|
|
4011
|
+
super(message2);
|
|
3957
4012
|
this.status = status;
|
|
3958
4013
|
}
|
|
3959
4014
|
};
|
|
@@ -4259,632 +4314,148 @@ var init_cw_install = __esm({
|
|
|
4259
4314
|
}
|
|
4260
4315
|
});
|
|
4261
4316
|
|
|
4262
|
-
//
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
output = (output + data).slice(-64 * 1024);
|
|
4292
|
-
});
|
|
4293
|
-
proc.onExit(({ exitCode }) => {
|
|
4294
|
-
clearTimeout(timer);
|
|
4295
|
-
const json = stripAnsi(output).split(/\r?\n/).reverse().map((line) => line.slice(line.indexOf("{")).trim()).find((line) => parseJson(line) !== null);
|
|
4296
|
-
resolve10({ code: exitCode, stdout: json ?? "", stderr: output });
|
|
4297
|
-
});
|
|
4298
|
-
});
|
|
4299
|
-
}
|
|
4300
|
-
function parseJson(text) {
|
|
4301
|
-
try {
|
|
4302
|
-
return JSON.parse(text);
|
|
4303
|
-
} catch {
|
|
4304
|
-
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
|
+
};
|
|
4305
4346
|
}
|
|
4306
|
-
}
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
while (next < items.length) {
|
|
4312
|
-
const i = next++;
|
|
4313
|
-
out[i] = await fn(items[i]);
|
|
4314
|
-
}
|
|
4315
|
-
};
|
|
4316
|
-
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
4317
|
-
return out;
|
|
4318
|
-
}
|
|
4319
|
-
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;
|
|
4320
|
-
var init_kioku = __esm({
|
|
4321
|
-
"../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) {
|
|
4322
4352
|
"use strict";
|
|
4323
|
-
|
|
4324
|
-
init_cw_doctor();
|
|
4325
|
-
init_cw_install();
|
|
4326
|
-
init_output();
|
|
4327
|
-
PAGE_TYPES = {
|
|
4328
|
-
memory: { kind: "memory" },
|
|
4329
|
-
instinct: { kind: "memory", sub: "instinct" },
|
|
4330
|
-
decision: { kind: "knowledge", sub: "decision" },
|
|
4331
|
-
playbook: { kind: "knowledge", sub: "playbook" },
|
|
4332
|
-
context: { kind: "knowledge", sub: "context" },
|
|
4333
|
-
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) : () => {
|
|
4334
4354
|
};
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
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}}`);
|
|
4340
4385
|
}
|
|
4386
|
+
return value;
|
|
4341
4387
|
};
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
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;
|
|
4374
4456
|
}
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
return this.binPath ??= resolveKiokuBin();
|
|
4378
|
-
}
|
|
4379
|
-
async status(fresh = false) {
|
|
4380
|
-
const previous = this.snapshot;
|
|
4381
|
-
if (fresh || !previous || this.now() - previous.at > CACHE_MS2) {
|
|
4382
|
-
const value = this.read();
|
|
4383
|
-
this.snapshot = { at: this.now(), value };
|
|
4384
|
-
value.catch(() => {
|
|
4385
|
-
if (this.snapshot?.value === value)
|
|
4386
|
-
this.snapshot = previous;
|
|
4387
|
-
});
|
|
4388
|
-
}
|
|
4389
|
-
const pending = fresh || !previous ? this.snapshot.value : previous.value;
|
|
4390
|
-
const [snapshot, viewer] = await Promise.all([pending, this.viewer?.catch(() => null) ?? null]);
|
|
4391
|
-
return { ...snapshot, viewer: viewer?.address ?? null };
|
|
4392
|
-
}
|
|
4393
|
-
async json(args, cwd) {
|
|
4394
|
-
const result2 = await this.run(this.bin, [...args, "--json"], cwd);
|
|
4395
|
-
return result2.code === 0 ? parseJson(result2.stdout) : null;
|
|
4396
|
-
}
|
|
4397
|
-
async read() {
|
|
4398
|
-
const [version, list] = await Promise.all([
|
|
4399
|
-
this.run(this.bin, ["--version"], homedir5()),
|
|
4400
|
-
this.json(["brain", "list"], homedir5())
|
|
4401
|
-
]);
|
|
4402
|
-
if (version.code !== 0)
|
|
4403
|
-
return MISSING;
|
|
4404
|
-
const listed = list?.brains ?? [];
|
|
4405
|
-
const entries = Object.entries(this.projects()).filter(([, p]) => existsSync12(p.path));
|
|
4406
|
-
const readBrain = async (b) => {
|
|
4407
|
-
if (!b.onDisk)
|
|
4408
|
-
return { kinds: {}, namespaces: [], writes: [] };
|
|
4409
|
-
const [ns, log] = await Promise.all([
|
|
4410
|
-
this.json(["namespace", "list", "--brain", b.key], b.folder),
|
|
4411
|
-
this.json(["brain", "log", "--since", ACTIVITY_SINCE, "--brain", b.key], b.folder)
|
|
4412
|
-
]);
|
|
4413
|
-
const kinds = {};
|
|
4414
|
-
const namespaces = ns?.brains?.find((x) => x.brain === brainName(b))?.namespaces ?? [];
|
|
4415
|
-
for (const n of namespaces) {
|
|
4416
|
-
for (const [kind, count] of Object.entries(n.pages))
|
|
4417
|
-
kinds[kind] = (kinds[kind] ?? 0) + count;
|
|
4418
|
-
}
|
|
4419
|
-
return { kinds, namespaces: namespaces.map((n) => n.namespace), writes: log?.writes ?? [] };
|
|
4420
|
-
};
|
|
4421
|
-
const readChain = async (path) => (await this.json(["brain", "list"], path))?.chain ?? [];
|
|
4422
|
-
const [perBrain, chains] = await Promise.all([
|
|
4423
|
-
mapLimit(listed, PARALLEL / 2, readBrain),
|
|
4424
|
-
mapLimit(entries, PARALLEL / 2, ([, p]) => readChain(p.path))
|
|
4425
|
-
]);
|
|
4426
|
-
const activity = perBrain.flatMap((p) => p.writes).sort((x, y) => y.date.localeCompare(x.date));
|
|
4427
|
-
const brains = listed.map((b, i) => {
|
|
4428
|
-
const { kinds, namespaces } = perBrain[i];
|
|
4429
|
-
const name = brainName(b);
|
|
4430
|
-
return {
|
|
4431
|
-
...b,
|
|
4432
|
-
pages: Object.values(kinds).reduce((sum, n) => sum + n, 0),
|
|
4433
|
-
kinds,
|
|
4434
|
-
namespaces,
|
|
4435
|
-
touched: activity.find((w) => w.brain === name)?.date ?? null
|
|
4436
|
-
};
|
|
4437
|
-
});
|
|
4438
|
-
const projects = Object.fromEntries(entries.map(([name], i) => [name, chains[i].map(({ name: name2, tier }) => ({ name: name2, tier }))]));
|
|
4439
|
-
return {
|
|
4440
|
-
installed: true,
|
|
4441
|
-
version: parseJson(version.stdout)?.version ?? null,
|
|
4442
|
-
brains,
|
|
4443
|
-
projects,
|
|
4444
|
-
activity: activity.slice(0, ACTIVITY_LIMIT).map(({ verb, title, path, date, author, brain }) => ({ verb, title, path, date, author, brain }))
|
|
4445
|
-
};
|
|
4446
|
-
}
|
|
4447
|
-
// writes through kioku, which validates, commits and pushes a shared brain; Forge never writes a brain's files
|
|
4448
|
-
async save(input) {
|
|
4449
|
-
const type = PAGE_TYPES[input.type];
|
|
4450
|
-
if (!type)
|
|
4451
|
-
throw new KiokuError(`unknown page type ${input.type}`, 400);
|
|
4452
|
-
const brain = await this.findBrain(input.brain);
|
|
4453
|
-
const args = [
|
|
4454
|
-
"page",
|
|
4455
|
-
"save",
|
|
4456
|
-
"--brain",
|
|
4457
|
-
brain.key,
|
|
4458
|
-
"--kind",
|
|
4459
|
-
type.kind,
|
|
4460
|
-
...type.sub ? ["--sub", type.sub] : [],
|
|
4461
|
-
"--title",
|
|
4462
|
-
input.title,
|
|
4463
|
-
"--summary",
|
|
4464
|
-
input.summary,
|
|
4465
|
-
"--source",
|
|
4466
|
-
"Forge",
|
|
4467
|
-
...input.namespace ? ["--namespace", input.namespace] : [],
|
|
4468
|
-
...input.create ? ["--create"] : [],
|
|
4469
|
-
"--json"
|
|
4470
|
-
];
|
|
4471
|
-
const { out, fail } = await this.invoke(args, brain.folder, this.write, input.body);
|
|
4472
|
-
if (out?.status === "done" && out.path) {
|
|
4473
|
-
this.expire();
|
|
4474
|
-
return { status: "done", brain: brainName(brain), path: out.path, publication: out.publication ?? null };
|
|
4475
|
-
}
|
|
4476
|
-
if (out?.status === "similar")
|
|
4477
|
-
return { status: "similar", similar: (out.similar ?? []).map(({ brain: brain2, path, title, summary }) => ({ brain: brain2, path, title, summary })) };
|
|
4478
|
-
if (out?.status === "namespace")
|
|
4479
|
-
return { status: "namespace", namespaces: (out.namespaces ?? []).map(({ namespace, summary }) => ({ namespace, summary })) };
|
|
4480
|
-
throw fail("kioku could not save the page");
|
|
4481
|
-
}
|
|
4482
|
-
// the cached reading when there is one, else only the list of brains
|
|
4483
|
-
async listBrains() {
|
|
4484
|
-
return this.snapshot ? (await this.snapshot.value).brains : (await this.json(["brain", "list"], homedir5()))?.brains ?? [];
|
|
4485
|
-
}
|
|
4486
|
-
async findBrain(key) {
|
|
4487
|
-
const brain = (await this.listBrains()).find((b) => b.key === key);
|
|
4488
|
-
if (!brain?.onDisk)
|
|
4489
|
-
throw new KiokuError(`no brain ${key} on this machine`, 404);
|
|
4490
|
-
return brain;
|
|
4491
|
-
}
|
|
4492
|
-
// the next status reads again, while the old reading still answers a poll that is not fresh
|
|
4493
|
-
expire() {
|
|
4494
|
-
if (this.snapshot)
|
|
4495
|
-
this.snapshot.at = -Infinity;
|
|
4496
|
-
}
|
|
4497
|
-
// runs a verb that writes; fail turns kioku's refusal into a 400 with its message
|
|
4498
|
-
async invoke(args, cwd, run2, input) {
|
|
4499
|
-
const result2 = await run2(this.bin, args, cwd, input);
|
|
4500
|
-
if (result2.code === 127)
|
|
4501
|
-
throw new KiokuError(NOT_INSTALLED, 404);
|
|
4502
|
-
const out = parseJson(result2.stdout);
|
|
4503
|
-
return { out, ok: result2.code === 0 && out !== null && !out.error, fail: (fallback) => new KiokuError(out?.error?.message ?? (tailOutput(result2.stderr, 1) || fallback), 400) };
|
|
4504
|
-
}
|
|
4505
|
-
async change(args, cwd, run2 = this.write) {
|
|
4506
|
-
const { out, ok, fail } = await this.invoke([...args, "--json"], cwd, run2);
|
|
4507
|
-
if (!ok || !out)
|
|
4508
|
-
throw fail(`kioku ${args.slice(0, 2).join(" ")} failed`);
|
|
4509
|
-
this.expire();
|
|
4510
|
-
return out;
|
|
4511
|
-
}
|
|
4512
|
-
// makes a brain on this machine only; kioku never makes a repository here
|
|
4513
|
-
async createBrain(input) {
|
|
4514
|
-
assertRepo(input.repo, "the brain");
|
|
4515
|
-
if (!TIERS.includes(input.tier))
|
|
4516
|
-
throw new KiokuError(`the tier is one of ${TIERS.join(", ")}`, 400);
|
|
4517
|
-
if (input.team)
|
|
4518
|
-
assertRepo(input.team, "the team brain");
|
|
4519
|
-
if (input.language && !LANGUAGE.test(input.language))
|
|
4520
|
-
throw new KiokuError("the language is a tag such as en or es", 400);
|
|
4521
|
-
const args = [
|
|
4522
|
-
"brain",
|
|
4523
|
-
"create",
|
|
4524
|
-
input.repo,
|
|
4525
|
-
"--tier",
|
|
4526
|
-
input.tier,
|
|
4527
|
-
...input.team && input.tier === "project" ? ["--team", input.team] : [],
|
|
4528
|
-
...input.language ? ["--language", input.language] : []
|
|
4529
|
-
];
|
|
4530
|
-
const { brain, name, path } = await this.change(args, homedir5());
|
|
4531
|
-
return { brain, name, path };
|
|
4532
|
-
}
|
|
4533
|
-
async addArea(key, area, summary) {
|
|
4534
|
-
if (!AREA.test(area))
|
|
4535
|
-
throw new KiokuError("an area is letters, digits, dots, dashes and underscores, with / between parts", 400);
|
|
4536
|
-
if (!summary)
|
|
4537
|
-
throw new KiokuError("say what the area is for", 400);
|
|
4538
|
-
const brain = await this.findBrain(key);
|
|
4539
|
-
const out = await this.change(["namespace", "add", area, `--summary=${summary}`, "--brain", brain.key], brain.folder);
|
|
4540
|
-
return { brain: out.brain, namespace: out.namespace };
|
|
4541
|
-
}
|
|
4542
|
-
// 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
|
|
4543
|
-
async linkProject(input) {
|
|
4544
|
-
if (!input.brain && !input.team)
|
|
4545
|
-
throw new KiokuError("name a project brain, a team brain, or both", 400);
|
|
4546
|
-
const path = this.projects()[input.project]?.path;
|
|
4547
|
-
if (!path || !existsSync12(path))
|
|
4548
|
-
throw new KiokuError(`no CW project ${input.project} on this machine`, 404);
|
|
4549
|
-
if (input.brain)
|
|
4550
|
-
assertRepo(input.brain, "the project brain");
|
|
4551
|
-
if (input.team)
|
|
4552
|
-
assertRepo(input.team, "the team brain");
|
|
4553
|
-
const known = await this.listBrains();
|
|
4554
|
-
const isKnown = (repo) => known.some((b) => b.key === repo || b.key.endsWith(`/${repo}`));
|
|
4555
|
-
const created = [];
|
|
4556
|
-
if (input.team && !isKnown(input.team))
|
|
4557
|
-
created.push((await this.createBrain({ repo: input.team, tier: "team" })).brain);
|
|
4558
|
-
if (input.brain && !isKnown(input.brain))
|
|
4559
|
-
created.push((await this.createBrain({ repo: input.brain, tier: "project", team: input.team })).brain);
|
|
4560
|
-
const args = ["init", ...input.brain ? [input.brain] : [], ...input.team ? ["--team", input.team] : []];
|
|
4561
|
-
const { file } = await this.change(args, path);
|
|
4562
|
-
return { file, created };
|
|
4563
|
-
}
|
|
4564
|
-
// the only verb that reaches a git host: without `to`, kioku makes a private GitHub repository with gh
|
|
4565
|
-
async publish(key, to) {
|
|
4566
|
-
if (to?.startsWith("-"))
|
|
4567
|
-
throw new KiokuError("the address cannot start with -", 400);
|
|
4568
|
-
const brain = await this.findBrain(key);
|
|
4569
|
-
if (brain.remote)
|
|
4570
|
-
throw new KiokuError(`${brainName(brain)} already has a repository: ${brain.remote}`, 400);
|
|
4571
|
-
const out = await this.change(["brain", "publish", brain.key, ...to ? ["--to", to] : []], brain.folder, this.terminal ??= createTerminalRunner(envWithoutHost(), PUBLISH_TIMEOUT_MS));
|
|
4572
|
-
return { brain: out.brain, status: out.status, remote: out.remote ?? null };
|
|
4573
|
-
}
|
|
4574
|
-
// one viewer at a time; a second call reuses the running one
|
|
4575
|
-
async openViewer() {
|
|
4576
|
-
this.viewer ??= this.startViewer();
|
|
4577
|
-
return (await this.viewer).address;
|
|
4578
|
-
}
|
|
4579
|
-
startViewer() {
|
|
4580
|
-
const started = new Promise((resolve10, reject) => {
|
|
4581
|
-
const child = spawn7(this.bin, ["web", "--json", "--no-open"], { cwd: homedir5(), stdio: ["ignore", "pipe", "pipe"] });
|
|
4582
|
-
const lines2 = createInterface({ input: child.stdout });
|
|
4583
|
-
let stderr = "";
|
|
4584
|
-
let settled = false;
|
|
4585
|
-
const finish = () => {
|
|
4586
|
-
settled = true;
|
|
4587
|
-
clearTimeout(timer);
|
|
4588
|
-
lines2.close();
|
|
4589
|
-
child.stdout?.resume();
|
|
4590
|
-
};
|
|
4591
|
-
const fail = (err) => {
|
|
4592
|
-
if (settled)
|
|
4593
|
-
return;
|
|
4594
|
-
finish();
|
|
4595
|
-
child.kill();
|
|
4596
|
-
reject(err);
|
|
4597
|
-
};
|
|
4598
|
-
const timer = setTimeout(() => fail(new KiokuError("kioku web did not start in time")), this.startTimeoutMs);
|
|
4599
|
-
child.stderr?.on("data", (chunk) => {
|
|
4600
|
-
stderr = (stderr + chunk.toString()).slice(-4096);
|
|
4601
|
-
});
|
|
4602
|
-
lines2.on("line", (line) => {
|
|
4603
|
-
const event = parseJson(line);
|
|
4604
|
-
if (settled || event?.event !== "listening" || !event.address?.startsWith("http://127.0.0.1:"))
|
|
4605
|
-
return;
|
|
4606
|
-
finish();
|
|
4607
|
-
resolve10({ child, address: event.address });
|
|
4608
|
-
});
|
|
4609
|
-
child.on("error", (err) => {
|
|
4610
|
-
const missing = err.code === "ENOENT";
|
|
4611
|
-
fail(new KiokuError(missing ? NOT_INSTALLED : err.message, missing ? 404 : 502));
|
|
4612
|
-
});
|
|
4613
|
-
child.on("close", (code) => {
|
|
4614
|
-
if (this.viewer === started)
|
|
4615
|
-
this.viewer = null;
|
|
4616
|
-
fail(new KiokuError(tailOutput(stderr, 1) || `kioku web exited with code ${code}`));
|
|
4617
|
-
});
|
|
4618
|
-
});
|
|
4619
|
-
started.catch(() => {
|
|
4620
|
-
if (this.viewer === started)
|
|
4621
|
-
this.viewer = null;
|
|
4622
|
-
});
|
|
4623
|
-
return started;
|
|
4624
|
-
}
|
|
4625
|
-
stopViewer() {
|
|
4626
|
-
void this.viewer?.then((v) => v.child.kill(), () => {
|
|
4627
|
-
});
|
|
4628
|
-
this.viewer = null;
|
|
4629
|
-
}
|
|
4630
|
-
dispose() {
|
|
4631
|
-
this.stopViewer();
|
|
4632
|
-
}
|
|
4633
|
-
};
|
|
4634
|
-
}
|
|
4635
|
-
});
|
|
4636
|
-
|
|
4637
|
-
// ../core/dist/kioku-routes.js
|
|
4638
|
-
import { Hono as Hono4 } from "hono";
|
|
4639
|
-
function kiokuRoutes(kioku = new Kioku(), options = {}) {
|
|
4640
|
-
const app = new Hono4();
|
|
4641
|
-
app.onError((err, c) => {
|
|
4642
|
-
if (err instanceof KiokuError)
|
|
4643
|
-
return c.json({ error: err.message }, err.status);
|
|
4644
|
-
throw err;
|
|
4645
|
-
});
|
|
4646
|
-
app.get("/status", async (c) => c.json(await kioku.status(c.req.query("fresh") === "1")));
|
|
4647
|
-
app.post("/pages", async (c) => {
|
|
4648
|
-
const input = await c.req.json().catch(() => ({}));
|
|
4649
|
-
const brain = input.brain?.trim();
|
|
4650
|
-
const title = input.title?.trim();
|
|
4651
|
-
const summary = input.summary?.trim();
|
|
4652
|
-
if (!brain || !input.type || !title || !summary || !input.body?.trim())
|
|
4653
|
-
return c.json({ error: "brain, type, title, summary and body are required" }, 400);
|
|
4654
|
-
const result2 = await kioku.save({ brain, type: input.type, title, summary, body: input.body, namespace: input.namespace?.trim() || void 0, create: input.create === true });
|
|
4655
|
-
return c.json(result2, result2.status === "done" ? 201 : 200);
|
|
4656
|
-
});
|
|
4657
|
-
app.post("/brains", async (c) => {
|
|
4658
|
-
const { repo, tier, team, language } = await body(c);
|
|
4659
|
-
return c.json(await kioku.createBrain({ repo: trim(repo) ?? "", tier: tier ?? "", team: trim(team), language: trim(language) }), 201);
|
|
4660
|
-
});
|
|
4661
|
-
app.post("/areas", async (c) => {
|
|
4662
|
-
const { brain, area, summary } = await body(c);
|
|
4663
|
-
return c.json(await kioku.addArea(brain ?? "", trim(area) ?? "", trim(summary) ?? ""), 201);
|
|
4664
|
-
});
|
|
4665
|
-
app.post("/link", async (c) => {
|
|
4666
|
-
const { project, brain, team } = await body(c);
|
|
4667
|
-
return c.json(await kioku.linkProject({ project: project ?? "", brain: trim(brain), team: trim(team) }));
|
|
4668
|
-
});
|
|
4669
|
-
app.post("/publish", async (c) => {
|
|
4670
|
-
const { brain, to, understood } = await body(c);
|
|
4671
|
-
if (understood !== true)
|
|
4672
|
-
return c.json({ error: "publishing needs the warning accepted" }, 400);
|
|
4673
|
-
return c.json(await kioku.publish(brain ?? "", trim(to)));
|
|
4674
|
-
});
|
|
4675
|
-
app.post("/remember", async (c) => {
|
|
4676
|
-
const { project, sessionDir, text } = await c.req.json().catch(() => ({}));
|
|
4677
|
-
const line = text?.trim();
|
|
4678
|
-
if (!project || !sessionDir || !line)
|
|
4679
|
-
return c.json({ error: "project, sessionDir and text are required" }, 400);
|
|
4680
|
-
if (line.length > REMEMBER_MAX)
|
|
4681
|
-
return c.json({ error: `keep it under ${REMEMBER_MAX} characters` }, 400);
|
|
4682
|
-
if (options.canRemember && !options.canRemember(project, sessionDir))
|
|
4683
|
-
return c.json({ error: "only Claude Code sessions have kioku's skill" }, 400);
|
|
4684
|
-
if (!options.type?.(project, sessionDir, rememberPrompt(line)))
|
|
4685
|
-
return c.json({ error: "the session has no live terminal" }, 409);
|
|
4686
|
-
return c.json({ ok: true });
|
|
4687
|
-
});
|
|
4688
|
-
app.post("/viewer", async (c) => c.json({ address: await kioku.openViewer() }));
|
|
4689
|
-
app.delete("/viewer", (c) => {
|
|
4690
|
-
kioku.stopViewer();
|
|
4691
|
-
return c.json({ ok: true });
|
|
4692
|
-
});
|
|
4693
|
-
return app;
|
|
4694
|
-
}
|
|
4695
|
-
var trim, REMEMBER_MAX, body;
|
|
4696
|
-
var init_kioku_routes = __esm({
|
|
4697
|
-
"../core/dist/kioku-routes.js"() {
|
|
4698
|
-
"use strict";
|
|
4699
|
-
init_kioku();
|
|
4700
|
-
trim = (value) => value?.trim() || void 0;
|
|
4701
|
-
REMEMBER_MAX = 500;
|
|
4702
|
-
body = (c) => c.req.json().catch(() => ({}));
|
|
4703
|
-
}
|
|
4704
|
-
});
|
|
4705
|
-
|
|
4706
|
-
// ../sdk/dist/define.js
|
|
4707
|
-
function isShellExecutor(run2) {
|
|
4708
|
-
return typeof run2 === "object" && run2 !== null && run2.kind === "shell";
|
|
4709
|
-
}
|
|
4710
|
-
var SDK_VERSION, MODULE_ID_RE;
|
|
4711
|
-
var init_define = __esm({
|
|
4712
|
-
"../sdk/dist/define.js"() {
|
|
4713
|
-
"use strict";
|
|
4714
|
-
SDK_VERSION = "1.0.0";
|
|
4715
|
-
MODULE_ID_RE = /^[a-z][a-z0-9-]{1,31}$/;
|
|
4716
|
-
}
|
|
4717
|
-
});
|
|
4718
|
-
|
|
4719
|
-
// ../sdk/dist/errors.js
|
|
4720
|
-
var PermissionError;
|
|
4721
|
-
var init_errors = __esm({
|
|
4722
|
-
"../sdk/dist/errors.js"() {
|
|
4723
|
-
"use strict";
|
|
4724
|
-
PermissionError = class extends Error {
|
|
4725
|
-
permission;
|
|
4726
|
-
value;
|
|
4727
|
-
constructor(permission, value) {
|
|
4728
|
-
super(`permission ${permission} does not cover ${value}`);
|
|
4729
|
-
this.name = "PermissionError";
|
|
4730
|
-
this.permission = permission;
|
|
4731
|
-
this.value = value;
|
|
4732
|
-
}
|
|
4733
|
-
};
|
|
4734
|
-
}
|
|
4735
|
-
});
|
|
4736
|
-
|
|
4737
|
-
// ../sdk/dist/index.js
|
|
4738
|
-
var init_dist = __esm({
|
|
4739
|
-
"../sdk/dist/index.js"() {
|
|
4740
|
-
"use strict";
|
|
4741
|
-
init_define();
|
|
4742
|
-
init_errors();
|
|
4743
|
-
}
|
|
4744
|
-
});
|
|
4745
|
-
|
|
4746
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
|
|
4747
|
-
var require_constants = __commonJS({
|
|
4748
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js"(exports, module) {
|
|
4749
|
-
"use strict";
|
|
4750
|
-
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
4751
|
-
var MAX_LENGTH = 256;
|
|
4752
|
-
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
4753
|
-
9007199254740991;
|
|
4754
|
-
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
4755
|
-
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
4756
|
-
var RELEASE_TYPES = [
|
|
4757
|
-
"major",
|
|
4758
|
-
"premajor",
|
|
4759
|
-
"minor",
|
|
4760
|
-
"preminor",
|
|
4761
|
-
"patch",
|
|
4762
|
-
"prepatch",
|
|
4763
|
-
"prerelease"
|
|
4764
|
-
];
|
|
4765
|
-
module.exports = {
|
|
4766
|
-
MAX_LENGTH,
|
|
4767
|
-
MAX_SAFE_COMPONENT_LENGTH,
|
|
4768
|
-
MAX_SAFE_BUILD_LENGTH,
|
|
4769
|
-
MAX_SAFE_INTEGER,
|
|
4770
|
-
RELEASE_TYPES,
|
|
4771
|
-
SEMVER_SPEC_VERSION,
|
|
4772
|
-
FLAG_INCLUDE_PRERELEASE: 1,
|
|
4773
|
-
FLAG_LOOSE: 2
|
|
4774
|
-
};
|
|
4775
|
-
}
|
|
4776
|
-
});
|
|
4777
|
-
|
|
4778
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js
|
|
4779
|
-
var require_debug = __commonJS({
|
|
4780
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js"(exports, module) {
|
|
4781
|
-
"use strict";
|
|
4782
|
-
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
|
|
4783
|
-
};
|
|
4784
|
-
module.exports = debug;
|
|
4785
|
-
}
|
|
4786
|
-
});
|
|
4787
|
-
|
|
4788
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js
|
|
4789
|
-
var require_re = __commonJS({
|
|
4790
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js"(exports, module) {
|
|
4791
|
-
"use strict";
|
|
4792
|
-
var {
|
|
4793
|
-
MAX_SAFE_COMPONENT_LENGTH,
|
|
4794
|
-
MAX_SAFE_BUILD_LENGTH,
|
|
4795
|
-
MAX_LENGTH
|
|
4796
|
-
} = require_constants();
|
|
4797
|
-
var debug = require_debug();
|
|
4798
|
-
exports = module.exports = {};
|
|
4799
|
-
var re = exports.re = [];
|
|
4800
|
-
var safeRe = exports.safeRe = [];
|
|
4801
|
-
var src = exports.src = [];
|
|
4802
|
-
var safeSrc = exports.safeSrc = [];
|
|
4803
|
-
var t = exports.t = {};
|
|
4804
|
-
var R = 0;
|
|
4805
|
-
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
4806
|
-
var safeRegexReplacements = [
|
|
4807
|
-
["\\s", 1],
|
|
4808
|
-
["\\d", MAX_LENGTH],
|
|
4809
|
-
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
4810
|
-
];
|
|
4811
|
-
var makeSafeRegex = (value) => {
|
|
4812
|
-
for (const [token, max] of safeRegexReplacements) {
|
|
4813
|
-
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
4814
|
-
}
|
|
4815
|
-
return value;
|
|
4816
|
-
};
|
|
4817
|
-
var createToken = (name, value, isGlobal) => {
|
|
4818
|
-
const safe = makeSafeRegex(value);
|
|
4819
|
-
const index = R++;
|
|
4820
|
-
debug(name, index, value);
|
|
4821
|
-
t[name] = index;
|
|
4822
|
-
src[index] = value;
|
|
4823
|
-
safeSrc[index] = safe;
|
|
4824
|
-
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
4825
|
-
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
4826
|
-
};
|
|
4827
|
-
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
4828
|
-
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
4829
|
-
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
4830
|
-
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
4831
|
-
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
4832
|
-
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
4833
|
-
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
4834
|
-
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
4835
|
-
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
4836
|
-
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
4837
|
-
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
4838
|
-
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
4839
|
-
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
4840
|
-
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
4841
|
-
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
4842
|
-
createToken("GTLT", "((?:<|>)?=?)");
|
|
4843
|
-
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
4844
|
-
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
4845
|
-
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
4846
|
-
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
4847
|
-
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
4848
|
-
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
4849
|
-
createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
4850
|
-
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
4851
|
-
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
4852
|
-
createToken("COERCERTL", src[t.COERCE], true);
|
|
4853
|
-
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
4854
|
-
createToken("LONETILDE", "(?:~>?)");
|
|
4855
|
-
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
4856
|
-
exports.tildeTrimReplace = "$1~";
|
|
4857
|
-
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
4858
|
-
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
4859
|
-
createToken("LONECARET", "(?:\\^)");
|
|
4860
|
-
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
4861
|
-
exports.caretTrimReplace = "$1^";
|
|
4862
|
-
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
4863
|
-
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
4864
|
-
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
4865
|
-
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
4866
|
-
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
4867
|
-
exports.comparatorTrimReplace = "$1$2$3";
|
|
4868
|
-
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
4869
|
-
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
4870
|
-
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
4871
|
-
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
4872
|
-
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
4873
|
-
}
|
|
4874
|
-
});
|
|
4875
|
-
|
|
4876
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js
|
|
4877
|
-
var require_parse_options = __commonJS({
|
|
4878
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js"(exports, module) {
|
|
4879
|
-
"use strict";
|
|
4880
|
-
var looseOption = Object.freeze({ loose: true });
|
|
4881
|
-
var emptyOpts = Object.freeze({});
|
|
4882
|
-
var parseOptions = (options) => {
|
|
4883
|
-
if (!options) {
|
|
4884
|
-
return emptyOpts;
|
|
4885
|
-
}
|
|
4886
|
-
if (typeof options !== "object") {
|
|
4887
|
-
return looseOption;
|
|
4457
|
+
if (typeof options !== "object") {
|
|
4458
|
+
return looseOption;
|
|
4888
4459
|
}
|
|
4889
4460
|
return options;
|
|
4890
4461
|
};
|
|
@@ -4896,13 +4467,13 @@ var require_parse_options = __commonJS({
|
|
|
4896
4467
|
var require_identifiers = __commonJS({
|
|
4897
4468
|
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js"(exports, module) {
|
|
4898
4469
|
"use strict";
|
|
4899
|
-
var
|
|
4470
|
+
var numeric2 = /^[0-9]+$/;
|
|
4900
4471
|
var compareIdentifiers = (a, b) => {
|
|
4901
4472
|
if (typeof a === "number" && typeof b === "number") {
|
|
4902
4473
|
return a === b ? 0 : a < b ? -1 : 1;
|
|
4903
4474
|
}
|
|
4904
|
-
const anum =
|
|
4905
|
-
const bnum =
|
|
4475
|
+
const anum = numeric2.test(a);
|
|
4476
|
+
const bnum = numeric2.test(b);
|
|
4906
4477
|
if (anum && bnum) {
|
|
4907
4478
|
a = +a;
|
|
4908
4479
|
b = +b;
|
|
@@ -6320,420 +5891,1077 @@ var require_valid2 = __commonJS({
|
|
|
6320
5891
|
} catch (er) {
|
|
6321
5892
|
return null;
|
|
6322
5893
|
}
|
|
6323
|
-
};
|
|
6324
|
-
module.exports = validRange;
|
|
6325
|
-
}
|
|
6326
|
-
});
|
|
6327
|
-
|
|
6328
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js
|
|
6329
|
-
var require_outside = __commonJS({
|
|
6330
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js"(exports, module) {
|
|
6331
|
-
"use strict";
|
|
6332
|
-
var SemVer = require_semver();
|
|
6333
|
-
var Comparator = require_comparator();
|
|
6334
|
-
var { ANY } = Comparator;
|
|
6335
|
-
var Range = require_range();
|
|
6336
|
-
var satisfies = require_satisfies();
|
|
6337
|
-
var gt = require_gt();
|
|
6338
|
-
var lt = require_lt();
|
|
6339
|
-
var lte = require_lte();
|
|
6340
|
-
var gte = require_gte();
|
|
6341
|
-
var outside = (version, range, hilo, options) => {
|
|
6342
|
-
version = new SemVer(version, options);
|
|
6343
|
-
range = new Range(range, options);
|
|
6344
|
-
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
6345
|
-
switch (hilo) {
|
|
6346
|
-
case ">":
|
|
6347
|
-
gtfn = gt;
|
|
6348
|
-
ltefn = lte;
|
|
6349
|
-
ltfn = lt;
|
|
6350
|
-
comp = ">";
|
|
6351
|
-
ecomp = ">=";
|
|
6352
|
-
break;
|
|
6353
|
-
case "<":
|
|
6354
|
-
gtfn = lt;
|
|
6355
|
-
ltefn = gte;
|
|
6356
|
-
ltfn = gt;
|
|
6357
|
-
comp = "<";
|
|
6358
|
-
ecomp = "<=";
|
|
6359
|
-
break;
|
|
6360
|
-
default:
|
|
6361
|
-
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
|
+
}
|
|
6362
6126
|
}
|
|
6363
|
-
|
|
6364
|
-
|
|
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;
|
|
6365
6140
|
}
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
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
|
+
}
|
|
6373
6156
|
}
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
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;
|
|
6380
6164
|
}
|
|
6381
|
-
});
|
|
6382
|
-
if (high.operator === comp || high.operator === ecomp) {
|
|
6383
|
-
return false;
|
|
6384
6165
|
}
|
|
6385
|
-
if (
|
|
6386
|
-
|
|
6387
|
-
|
|
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) {
|
|
6388
6182
|
return false;
|
|
6389
6183
|
}
|
|
6390
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
|
+
}
|
|
6391
6194
|
return true;
|
|
6392
6195
|
};
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
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;
|
|
6404
6211
|
}
|
|
6405
6212
|
});
|
|
6406
6213
|
|
|
6407
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/
|
|
6408
|
-
var
|
|
6409
|
-
"../../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) {
|
|
6410
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();
|
|
6411
6254
|
var outside = require_outside();
|
|
6412
|
-
var
|
|
6413
|
-
|
|
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
|
+
};
|
|
6414
6308
|
}
|
|
6415
6309
|
});
|
|
6416
6310
|
|
|
6417
|
-
//
|
|
6418
|
-
|
|
6419
|
-
"
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
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))
|
|
6426
6382
|
};
|
|
6427
|
-
|
|
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);
|
|
6428
6403
|
}
|
|
6429
6404
|
});
|
|
6430
6405
|
|
|
6431
|
-
//
|
|
6432
|
-
|
|
6433
|
-
|
|
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"() {
|
|
6434
6470
|
"use strict";
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
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;
|
|
6452
6572
|
}
|
|
6453
|
-
|
|
6454
|
-
|
|
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 };
|
|
6455
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");
|
|
6456
6635
|
}
|
|
6457
|
-
|
|
6458
|
-
|
|
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 ?? [];
|
|
6459
6639
|
}
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
if (
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
ranges.push("*");
|
|
6466
|
-
} else if (!max) {
|
|
6467
|
-
ranges.push(`>=${min}`);
|
|
6468
|
-
} else if (min === v[0]) {
|
|
6469
|
-
ranges.push(`<=${max}`);
|
|
6470
|
-
} else {
|
|
6471
|
-
ranges.push(`${min} - ${max}`);
|
|
6472
|
-
}
|
|
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;
|
|
6473
6645
|
}
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
}
|
|
6479
|
-
});
|
|
6480
|
-
|
|
6481
|
-
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js
|
|
6482
|
-
var require_subset = __commonJS({
|
|
6483
|
-
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js"(exports, module) {
|
|
6484
|
-
"use strict";
|
|
6485
|
-
var Range = require_range();
|
|
6486
|
-
var Comparator = require_comparator();
|
|
6487
|
-
var { ANY } = Comparator;
|
|
6488
|
-
var satisfies = require_satisfies();
|
|
6489
|
-
var compare = require_compare();
|
|
6490
|
-
var subset = (sub, dom, options = {}) => {
|
|
6491
|
-
if (sub === dom) {
|
|
6492
|
-
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;
|
|
6493
6650
|
}
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
if (isSub) {
|
|
6502
|
-
continue OUTER;
|
|
6503
|
-
}
|
|
6504
|
-
}
|
|
6505
|
-
if (sawNonNull) {
|
|
6506
|
-
return false;
|
|
6507
|
-
}
|
|
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) };
|
|
6508
6658
|
}
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
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;
|
|
6516
6665
|
}
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
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 };
|
|
6525
6686
|
}
|
|
6526
|
-
|
|
6527
|
-
if (
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
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 };
|
|
6532
6695
|
}
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
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 };
|
|
6543
6717
|
}
|
|
6544
|
-
|
|
6545
|
-
|
|
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 };
|
|
6546
6727
|
}
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
gtltComp = compare(gt.semver, lt.semver, options);
|
|
6550
|
-
if (gtltComp > 0) {
|
|
6551
|
-
return null;
|
|
6552
|
-
} else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
|
|
6553
|
-
return null;
|
|
6554
|
-
}
|
|
6728
|
+
get terminalRun() {
|
|
6729
|
+
return this.terminal ??= createTerminalRunner(envWithoutHost(), TERMINAL_TIMEOUT_MS);
|
|
6555
6730
|
}
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
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";
|
|
6567
6746
|
}
|
|
6568
|
-
return
|
|
6747
|
+
return { ...pickReleases(this.releaseList?.raw ?? [], status.version, this.pluginInstalls(), SHOWN_BIN), command: commandLine("gh", RELEASES_ARGS), error };
|
|
6569
6748
|
}
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
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));
|
|
6576
6768
|
}
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
if (
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
}
|
|
6594
|
-
}
|
|
6595
|
-
if (lt) {
|
|
6596
|
-
if (needDomLTPre) {
|
|
6597
|
-
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
|
|
6598
|
-
needDomLTPre = false;
|
|
6599
|
-
}
|
|
6600
|
-
}
|
|
6601
|
-
if (c.operator === "<" || c.operator === "<=") {
|
|
6602
|
-
lower = lowerLT(lt, c, options);
|
|
6603
|
-
if (lower === c && lower !== lt) {
|
|
6604
|
-
return false;
|
|
6605
|
-
}
|
|
6606
|
-
} else if (lt.operator === "<=" && !c.test(lt.semver)) {
|
|
6607
|
-
return false;
|
|
6608
|
-
}
|
|
6609
|
-
}
|
|
6610
|
-
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
6611
|
-
return false;
|
|
6612
|
-
}
|
|
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();
|
|
6613
6785
|
}
|
|
6614
|
-
|
|
6615
|
-
|
|
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;
|
|
6616
6790
|
}
|
|
6617
|
-
|
|
6618
|
-
|
|
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;
|
|
6619
6836
|
}
|
|
6620
|
-
|
|
6621
|
-
|
|
6837
|
+
stopViewer() {
|
|
6838
|
+
void this.viewer?.then((v) => v.child.kill(), () => {
|
|
6839
|
+
});
|
|
6840
|
+
this.viewer = null;
|
|
6622
6841
|
}
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
var higherGT = (a, b, options) => {
|
|
6626
|
-
if (!a) {
|
|
6627
|
-
return b;
|
|
6842
|
+
dispose() {
|
|
6843
|
+
this.stopViewer();
|
|
6628
6844
|
}
|
|
6629
|
-
const comp = compare(a.semver, b.semver, options);
|
|
6630
|
-
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
6631
6845
|
};
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
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;
|
|
6635
6954
|
}
|
|
6636
|
-
const comp = compare(a.semver, b.semver, options);
|
|
6637
|
-
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
6638
6955
|
};
|
|
6639
|
-
module.exports = subset;
|
|
6640
6956
|
}
|
|
6641
6957
|
});
|
|
6642
6958
|
|
|
6643
|
-
//
|
|
6644
|
-
var
|
|
6645
|
-
"
|
|
6959
|
+
// ../sdk/dist/index.js
|
|
6960
|
+
var init_dist = __esm({
|
|
6961
|
+
"../sdk/dist/index.js"() {
|
|
6646
6962
|
"use strict";
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
var SemVer = require_semver();
|
|
6650
|
-
var identifiers = require_identifiers();
|
|
6651
|
-
var parse = require_parse();
|
|
6652
|
-
var valid = require_valid();
|
|
6653
|
-
var clean = require_clean();
|
|
6654
|
-
var inc = require_inc();
|
|
6655
|
-
var diff = require_diff();
|
|
6656
|
-
var major = require_major();
|
|
6657
|
-
var minor = require_minor();
|
|
6658
|
-
var patch = require_patch();
|
|
6659
|
-
var prerelease = require_prerelease();
|
|
6660
|
-
var compare = require_compare();
|
|
6661
|
-
var rcompare = require_rcompare();
|
|
6662
|
-
var compareLoose = require_compare_loose();
|
|
6663
|
-
var compareBuild = require_compare_build();
|
|
6664
|
-
var sort = require_sort();
|
|
6665
|
-
var rsort = require_rsort();
|
|
6666
|
-
var gt = require_gt();
|
|
6667
|
-
var lt = require_lt();
|
|
6668
|
-
var eq = require_eq();
|
|
6669
|
-
var neq = require_neq();
|
|
6670
|
-
var gte = require_gte();
|
|
6671
|
-
var lte = require_lte();
|
|
6672
|
-
var cmp = require_cmp();
|
|
6673
|
-
var coerce = require_coerce();
|
|
6674
|
-
var truncate = require_truncate();
|
|
6675
|
-
var Comparator = require_comparator();
|
|
6676
|
-
var Range = require_range();
|
|
6677
|
-
var satisfies = require_satisfies();
|
|
6678
|
-
var toComparators = require_to_comparators();
|
|
6679
|
-
var maxSatisfying = require_max_satisfying();
|
|
6680
|
-
var minSatisfying = require_min_satisfying();
|
|
6681
|
-
var minVersion = require_min_version();
|
|
6682
|
-
var validRange = require_valid2();
|
|
6683
|
-
var outside = require_outside();
|
|
6684
|
-
var gtr = require_gtr();
|
|
6685
|
-
var ltr = require_ltr();
|
|
6686
|
-
var intersects = require_intersects();
|
|
6687
|
-
var simplifyRange = require_simplify();
|
|
6688
|
-
var subset = require_subset();
|
|
6689
|
-
module.exports = {
|
|
6690
|
-
parse,
|
|
6691
|
-
valid,
|
|
6692
|
-
clean,
|
|
6693
|
-
inc,
|
|
6694
|
-
diff,
|
|
6695
|
-
major,
|
|
6696
|
-
minor,
|
|
6697
|
-
patch,
|
|
6698
|
-
prerelease,
|
|
6699
|
-
compare,
|
|
6700
|
-
rcompare,
|
|
6701
|
-
compareLoose,
|
|
6702
|
-
compareBuild,
|
|
6703
|
-
sort,
|
|
6704
|
-
rsort,
|
|
6705
|
-
gt,
|
|
6706
|
-
lt,
|
|
6707
|
-
eq,
|
|
6708
|
-
neq,
|
|
6709
|
-
gte,
|
|
6710
|
-
lte,
|
|
6711
|
-
cmp,
|
|
6712
|
-
coerce,
|
|
6713
|
-
truncate,
|
|
6714
|
-
Comparator,
|
|
6715
|
-
Range,
|
|
6716
|
-
satisfies,
|
|
6717
|
-
toComparators,
|
|
6718
|
-
maxSatisfying,
|
|
6719
|
-
minSatisfying,
|
|
6720
|
-
minVersion,
|
|
6721
|
-
validRange,
|
|
6722
|
-
outside,
|
|
6723
|
-
gtr,
|
|
6724
|
-
ltr,
|
|
6725
|
-
intersects,
|
|
6726
|
-
simplifyRange,
|
|
6727
|
-
subset,
|
|
6728
|
-
SemVer,
|
|
6729
|
-
re: internalRe.re,
|
|
6730
|
-
src: internalRe.src,
|
|
6731
|
-
tokens: internalRe.t,
|
|
6732
|
-
SEMVER_SPEC_VERSION: constants3.SEMVER_SPEC_VERSION,
|
|
6733
|
-
RELEASE_TYPES: constants3.RELEASE_TYPES,
|
|
6734
|
-
compareIdentifiers: identifiers.compareIdentifiers,
|
|
6735
|
-
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
6736
|
-
};
|
|
6963
|
+
init_define();
|
|
6964
|
+
init_errors();
|
|
6737
6965
|
}
|
|
6738
6966
|
});
|
|
6739
6967
|
|
|
@@ -6770,7 +6998,7 @@ function expandOne(template, settings, kind) {
|
|
|
6770
6998
|
const out = [];
|
|
6771
6999
|
for (const item of items) {
|
|
6772
7000
|
let missing = false;
|
|
6773
|
-
const
|
|
7001
|
+
const text2 = template.replace(TEMPLATE_RE, (_all, key, isList, field, offset) => {
|
|
6774
7002
|
const v = isList ? item?.[field] : settings[key];
|
|
6775
7003
|
const s = typeof v === "string" ? v : typeof v === "number" && Number.isFinite(v) ? String(v) : "";
|
|
6776
7004
|
if (s && safeValue(s, kind, offset === 0))
|
|
@@ -6779,7 +7007,7 @@ function expandOne(template, settings, kind) {
|
|
|
6779
7007
|
return "";
|
|
6780
7008
|
});
|
|
6781
7009
|
if (!missing)
|
|
6782
|
-
out.push(
|
|
7010
|
+
out.push(text2);
|
|
6783
7011
|
}
|
|
6784
7012
|
return out;
|
|
6785
7013
|
}
|
|
@@ -6835,9 +7063,9 @@ var init_module_permissions = __esm({
|
|
|
6835
7063
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
6836
7064
|
import { join as join15, resolve as resolve5, sep as sep3 } from "node:path";
|
|
6837
7065
|
function checkSdk(range, version = SDK_VERSION) {
|
|
6838
|
-
if (!
|
|
7066
|
+
if (!import_semver2.default.validRange(range))
|
|
6839
7067
|
return `sdk range "${range}" is not valid semver`;
|
|
6840
|
-
return
|
|
7068
|
+
return import_semver2.default.satisfies(version, range) ? null : `needs SDK ${range}, Forge has ${version}`;
|
|
6841
7069
|
}
|
|
6842
7070
|
function checkManifest(raw, moduleDir) {
|
|
6843
7071
|
if (!isObject(raw))
|
|
@@ -6848,7 +7076,7 @@ function checkManifest(raw, moduleDir) {
|
|
|
6848
7076
|
return { kind: "legacy", manifest: raw };
|
|
6849
7077
|
}
|
|
6850
7078
|
const errors = [];
|
|
6851
|
-
const err = (path,
|
|
7079
|
+
const err = (path, message2) => errors.push(`${path}: ${message2}`);
|
|
6852
7080
|
for (const key of Object.keys(raw))
|
|
6853
7081
|
if (!TOP_LEVEL.has(key))
|
|
6854
7082
|
err(`/${key}`, "unknown field");
|
|
@@ -6986,8 +7214,8 @@ function scalar(def, raw, path, errors) {
|
|
|
6986
7214
|
errors.push({ path, message: "required" });
|
|
6987
7215
|
return void 0;
|
|
6988
7216
|
}
|
|
6989
|
-
const fail = (
|
|
6990
|
-
errors.push({ path, message });
|
|
7217
|
+
const fail = (message2) => {
|
|
7218
|
+
errors.push({ path, message: message2 });
|
|
6991
7219
|
return void 0;
|
|
6992
7220
|
};
|
|
6993
7221
|
switch (def.type) {
|
|
@@ -7011,11 +7239,11 @@ function scalar(def, raw, path, errors) {
|
|
|
7011
7239
|
return typeof v === "string" && def.values.includes(v) ? v : fail(`must be one of ${def.values.join(", ")}`);
|
|
7012
7240
|
}
|
|
7013
7241
|
}
|
|
7014
|
-
var
|
|
7242
|
+
var import_semver2, V1_FIELDS, TOP_LEVEL, PERMISSIONS, SCALAR_TYPES, FORMATS, isObject, isStringArray;
|
|
7015
7243
|
var init_module_manifest = __esm({
|
|
7016
7244
|
"../core/dist/module-manifest.js"() {
|
|
7017
7245
|
"use strict";
|
|
7018
|
-
|
|
7246
|
+
import_semver2 = __toESM(require_semver2(), 1);
|
|
7019
7247
|
init_dist();
|
|
7020
7248
|
init_module_permissions();
|
|
7021
7249
|
V1_FIELDS = ["server", "view", "permissions", "id"];
|
|
@@ -7176,8 +7404,8 @@ import { existsSync as existsSync13, readdirSync as readdirSync7, readFileSync a
|
|
|
7176
7404
|
import { basename as basename4, dirname as dirname7, join as join16, resolve as resolve6, sep as sep4 } from "node:path";
|
|
7177
7405
|
import { pathToFileURL } from "node:url";
|
|
7178
7406
|
function disabled(id, c, reason, m) {
|
|
7179
|
-
const
|
|
7180
|
-
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 };
|
|
7181
7409
|
}
|
|
7182
7410
|
function packages(root, source, packaged) {
|
|
7183
7411
|
if (!existsSync13(root))
|
|
@@ -7639,8 +7867,8 @@ var init_module_install = __esm({
|
|
|
7639
7867
|
expand = (spec, cwd) => resolve7(cwd, expandHome(spec));
|
|
7640
7868
|
InstallError = class extends Error {
|
|
7641
7869
|
code;
|
|
7642
|
-
constructor(code,
|
|
7643
|
-
super(
|
|
7870
|
+
constructor(code, message2) {
|
|
7871
|
+
super(message2);
|
|
7644
7872
|
this.code = code;
|
|
7645
7873
|
}
|
|
7646
7874
|
};
|
|
@@ -7971,11 +8199,11 @@ async function run(found, confirmation, output, requestSignal) {
|
|
|
7971
8199
|
return action.run(input, ctx);
|
|
7972
8200
|
}
|
|
7973
8201
|
async function readJson3(c) {
|
|
7974
|
-
const
|
|
7975
|
-
if (!
|
|
8202
|
+
const text2 = await c.req.text();
|
|
8203
|
+
if (!text2)
|
|
7976
8204
|
return void 0;
|
|
7977
8205
|
try {
|
|
7978
|
-
return JSON.parse(
|
|
8206
|
+
return JSON.parse(text2);
|
|
7979
8207
|
} catch {
|
|
7980
8208
|
return void 0;
|
|
7981
8209
|
}
|
|
@@ -7987,10 +8215,10 @@ function describe(err) {
|
|
|
7987
8215
|
if (err instanceof PermissionError)
|
|
7988
8216
|
return { code: "permission", message: err.message, permission: err.permission, value: err.value };
|
|
7989
8217
|
const e = err;
|
|
7990
|
-
const
|
|
8218
|
+
const message2 = typeof e?.message === "string" ? e.message : String(err);
|
|
7991
8219
|
if (e?.name === "ModuleError" && typeof e.code === "string")
|
|
7992
|
-
return { code: e.code, message };
|
|
7993
|
-
return { code: "module_error", message };
|
|
8220
|
+
return { code: e.code, message: message2 };
|
|
8221
|
+
return { code: "module_error", message: message2 };
|
|
7994
8222
|
}
|
|
7995
8223
|
function errorResponse(c, mod, err) {
|
|
7996
8224
|
const body2 = describe(err);
|
|
@@ -8044,8 +8272,8 @@ var init_module_routes = __esm({
|
|
|
8044
8272
|
});
|
|
8045
8273
|
|
|
8046
8274
|
// ../core/dist/module-jobs.js
|
|
8047
|
-
function parseEvery(
|
|
8048
|
-
const m = /^(\d+)(s|m|h)$/.exec(
|
|
8275
|
+
function parseEvery(text2) {
|
|
8276
|
+
const m = /^(\d+)(s|m|h)$/.exec(text2.trim());
|
|
8049
8277
|
if (!m)
|
|
8050
8278
|
throw new Error("every must look like 30s, 2m or 1h");
|
|
8051
8279
|
const ms = Number(m[1]) * UNITS[m[2]];
|
|
@@ -8217,9 +8445,9 @@ function createForgeServer(options) {
|
|
|
8217
8445
|
const generalSessions = new GeneralSessions(join18(dataDir, "general-sessions.json"));
|
|
8218
8446
|
const terminalWss = createTerminalWss(ptyManager, cwReader, { localOnly, general: generalSessions });
|
|
8219
8447
|
app.route("/api/liveframe", liveframeRoutes());
|
|
8220
|
-
const kioku = new Kioku({ projects: () => cwReader.getProjects() });
|
|
8448
|
+
const kioku = new Kioku({ projects: () => cwReader.getProjects(), pluginInstalls: () => installsOf(cwReader, "kioku") });
|
|
8221
8449
|
app.route("/api/kioku", kiokuRoutes(kioku, {
|
|
8222
|
-
type: (project, sessionDir,
|
|
8450
|
+
type: (project, sessionDir, text2) => ptyManager.typeLine(project, sessionDir, text2),
|
|
8223
8451
|
// kioku's plugin, and so its skill, exists only for Claude Code
|
|
8224
8452
|
canRemember: (project, sessionDir) => cwReader.getSession(project, sessionDir)?.harness === "claude"
|
|
8225
8453
|
}));
|
|
@@ -8233,11 +8461,11 @@ function createForgeServer(options) {
|
|
|
8233
8461
|
}
|
|
8234
8462
|
});
|
|
8235
8463
|
const moduleEvents = new ModuleEvents({
|
|
8236
|
-
onError: (id,
|
|
8464
|
+
onError: (id, message2) => {
|
|
8237
8465
|
const status = moduleHost.get(id)?.status;
|
|
8238
8466
|
if (status)
|
|
8239
|
-
status.lastEventError =
|
|
8240
|
-
console.warn(`[module ${id}] ${
|
|
8467
|
+
status.lastEventError = message2;
|
|
8468
|
+
console.warn(`[module ${id}] ${message2}`);
|
|
8241
8469
|
}
|
|
8242
8470
|
});
|
|
8243
8471
|
const startModule = (mod) => {
|
|
@@ -8482,6 +8710,7 @@ var init_server = __esm({
|
|
|
8482
8710
|
init_module_jobs();
|
|
8483
8711
|
init_module_events();
|
|
8484
8712
|
init_kioku();
|
|
8713
|
+
init_plugins();
|
|
8485
8714
|
}
|
|
8486
8715
|
});
|
|
8487
8716
|
|