@logic-joe/fleek 0.2.18 → 0.2.19
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/dist/fleek.mjs +460 -225
- package/package.json +1 -1
package/dist/fleek.mjs
CHANGED
|
@@ -4679,7 +4679,7 @@ var require_setup_session = __commonJS({
|
|
|
4679
4679
|
exports.SETUP_SESSION_TTL_MINUTES = 30;
|
|
4680
4680
|
exports.SETUP_SESSION_OPEN_MAX = 10;
|
|
4681
4681
|
exports.SETUP_SESSION_CLAIM_LIMIT = 10;
|
|
4682
|
-
exports.FLEEK_CLI_SETUP_VERSION_DEFAULT = "0.2.
|
|
4682
|
+
exports.FLEEK_CLI_SETUP_VERSION_DEFAULT = "0.2.19";
|
|
4683
4683
|
exports.FLEEK_CLI_PACKAGE = "@logic-joe/fleek";
|
|
4684
4684
|
exports.FLEEK_CANONICAL_SERVER = "https://api.onfleek.app";
|
|
4685
4685
|
exports.SETUP_CLIENT_APPS = ["claude-code", "codex", "orca", "cursor", "other"];
|
|
@@ -24695,8 +24695,8 @@ var require_json_schema_processors = __commonJS({
|
|
|
24695
24695
|
bySchema.set(entry.schema, entry);
|
|
24696
24696
|
}
|
|
24697
24697
|
const rewrites = /* @__PURE__ */ new Map();
|
|
24698
|
-
for (const
|
|
24699
|
-
const seen = ctx.seen.get(
|
|
24698
|
+
for (const record2 of pendingRecords.get(ctx) ?? []) {
|
|
24699
|
+
const seen = ctx.seen.get(record2);
|
|
24700
24700
|
const names2 = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
24701
24701
|
if (!names2 || names2 === true || rewrites.has(names2))
|
|
24702
24702
|
continue;
|
|
@@ -25556,7 +25556,7 @@ var require_schemas2 = __commonJS({
|
|
|
25556
25556
|
exports.discriminatedUnion = discriminatedUnion;
|
|
25557
25557
|
exports.intersection = intersection;
|
|
25558
25558
|
exports.tuple = tuple;
|
|
25559
|
-
exports.record =
|
|
25559
|
+
exports.record = record2;
|
|
25560
25560
|
exports.partialRecord = partialRecord;
|
|
25561
25561
|
exports.looseRecord = looseRecord;
|
|
25562
25562
|
exports.map = map;
|
|
@@ -26579,7 +26579,7 @@ var require_schemas2 = __commonJS({
|
|
|
26579
26579
|
inst.keyType = def.keyType;
|
|
26580
26580
|
inst.valueType = def.valueType;
|
|
26581
26581
|
});
|
|
26582
|
-
function
|
|
26582
|
+
function record2(keyType, valueType, params) {
|
|
26583
26583
|
if (!valueType || !valueType._zod) {
|
|
26584
26584
|
return new exports.ZodRecord({
|
|
26585
26585
|
type: "record",
|
|
@@ -27055,7 +27055,7 @@ var require_schemas2 = __commonJS({
|
|
|
27055
27055
|
exports.stringbool = stringbool;
|
|
27056
27056
|
function json2(params) {
|
|
27057
27057
|
const jsonSchema = lazy(() => {
|
|
27058
|
-
return union([string4(params), number(), boolean(), _null(), array(jsonSchema),
|
|
27058
|
+
return union([string4(params), number(), boolean(), _null(), array(jsonSchema), record2(string4(), jsonSchema)]);
|
|
27059
27059
|
});
|
|
27060
27060
|
return jsonSchema;
|
|
27061
27061
|
}
|
|
@@ -29723,7 +29723,7 @@ var require_conditions = __commonJS({
|
|
|
29723
29723
|
}
|
|
29724
29724
|
return field ? { source, key: field } : void 0;
|
|
29725
29725
|
}
|
|
29726
|
-
var ownValue = (
|
|
29726
|
+
var ownValue = (record2, key) => record2 && Object.hasOwn(record2, key) ? record2[key] : void 0;
|
|
29727
29727
|
function evaluateWorkflowCondition(condition2, context, source) {
|
|
29728
29728
|
if (!condition2)
|
|
29729
29729
|
return true;
|
|
@@ -34642,8 +34642,8 @@ var require_project_init2 = __commonJS({
|
|
|
34642
34642
|
}
|
|
34643
34643
|
}
|
|
34644
34644
|
const checks = (agent.statementChecks ?? []).map(({ textDigest: _agentDigest, ...check }) => {
|
|
34645
|
-
const
|
|
34646
|
-
return
|
|
34645
|
+
const digest2 = digests.get(check.statementId.toLowerCase());
|
|
34646
|
+
return digest2 ? { ...check, textDigest: digest2 } : check;
|
|
34647
34647
|
});
|
|
34648
34648
|
const key = (c) => `${c.group ?? ""}\0${c.name}`;
|
|
34649
34649
|
const notes = /* @__PURE__ */ new Map();
|
|
@@ -34785,19 +34785,19 @@ var require_project_init2 = __commonJS({
|
|
|
34785
34785
|
return false;
|
|
34786
34786
|
return (0, secret_shape_js_1.detectSecretShape)(url) === null && (0, secret_shape_js_1.detectSecretShape)(decoded) === null;
|
|
34787
34787
|
}
|
|
34788
|
-
function*
|
|
34788
|
+
function* strings2(value, path) {
|
|
34789
34789
|
if (typeof value === "string") {
|
|
34790
34790
|
yield [path, value];
|
|
34791
34791
|
return;
|
|
34792
34792
|
}
|
|
34793
34793
|
if (Array.isArray(value)) {
|
|
34794
34794
|
for (let i = 0; i < value.length; i++)
|
|
34795
|
-
yield*
|
|
34795
|
+
yield* strings2(value[i], `${path}[${i}]`);
|
|
34796
34796
|
return;
|
|
34797
34797
|
}
|
|
34798
34798
|
if (value && typeof value === "object") {
|
|
34799
34799
|
for (const [key, item2] of Object.entries(value))
|
|
34800
|
-
yield*
|
|
34800
|
+
yield* strings2(item2, path ? `${path}.${key}` : key);
|
|
34801
34801
|
}
|
|
34802
34802
|
}
|
|
34803
34803
|
var EVIDENCE_PATHS = [
|
|
@@ -34812,7 +34812,7 @@ var require_project_init2 = __commonJS({
|
|
|
34812
34812
|
];
|
|
34813
34813
|
function scanProjectInit2(summary) {
|
|
34814
34814
|
const findings = [];
|
|
34815
|
-
for (const [path, value] of
|
|
34815
|
+
for (const [path, value] of strings2(summary, "")) {
|
|
34816
34816
|
if (path === "format" || path === "source.commit" || path === "source.analyzedAt" || path === "facts.factsHash")
|
|
34817
34817
|
continue;
|
|
34818
34818
|
if (path === "application.path") {
|
|
@@ -34925,7 +34925,7 @@ var require_project_init2 = __commonJS({
|
|
|
34925
34925
|
var WARNED_PATHS = /^(?:sections\.\w+|components\[\d+\]\.note|cms\.items\[\d+\]\.note|integrations\[\d+\]\.note|reviewHints\[\d+\]\.(?:question|acceptanceCriterion)|skillSuggestions\[\d+\]\.reason|openQuestions\[\d+\]|statementChecks\[\d+\]\.reason|environments\[\d+\]\.(?:url|name|purpose))$/;
|
|
34926
34926
|
function projectInitWarnings2(summary) {
|
|
34927
34927
|
const out = [];
|
|
34928
|
-
for (const [path, value] of
|
|
34928
|
+
for (const [path, value] of strings2(summary, "")) {
|
|
34929
34929
|
if (!WARNED_PATHS.test(path))
|
|
34930
34930
|
continue;
|
|
34931
34931
|
for (const [kind, pattern] of WARNING_PATTERNS2) {
|
|
@@ -36207,6 +36207,8 @@ var require_agent_error_details = __commonJS({
|
|
|
36207
36207
|
CLAIM_REQUIRED: { issueIds: list2, requiredPurpose: oneOf3(["work"]), providedPurpose: oneOf3(["review"]) },
|
|
36208
36208
|
RENEW_LIMIT: { hardExpiresAt: string4 },
|
|
36209
36209
|
NOT_READY: { readySelector: string4, reason: oneOf3(types_1.NOT_READY_REASONS) },
|
|
36210
|
+
// TES-929 W5: a status name is bounded user text (like TRANSITION_DENIED.reachable names), the role and process flag closed lists
|
|
36211
|
+
NOT_IN_REVIEW: { state: (value) => typeof value === "string" && value.length > 0 && value.length <= 240, requiredRole: oneOf3(["intake_review"]), process: oneOf3(["off"]) },
|
|
36210
36212
|
REVISION_CONFLICT: { currentRevision: integer },
|
|
36211
36213
|
STATE_CONFLICT: { currentStateVersion: integer },
|
|
36212
36214
|
TYPED_COMMENT_IMMUTABLE: { kind: string4 },
|
|
@@ -36526,10 +36528,10 @@ var require_dist2 = __commonJS({
|
|
|
36526
36528
|
// src/cli.ts
|
|
36527
36529
|
var import_types11 = __toESM(require_dist(), 1);
|
|
36528
36530
|
import { spawn as spawn9 } from "node:child_process";
|
|
36529
|
-
import { createHash as
|
|
36531
|
+
import { createHash as createHash11, randomBytes as randomBytes12 } from "node:crypto";
|
|
36530
36532
|
import { rm as rm13, stat as stat17 } from "node:fs/promises";
|
|
36531
36533
|
import { hostname as osHostname2 } from "node:os";
|
|
36532
|
-
import { join as
|
|
36534
|
+
import { join as join34 } from "node:path";
|
|
36533
36535
|
import { parseArgs } from "node:util";
|
|
36534
36536
|
|
|
36535
36537
|
// src/config.ts
|
|
@@ -37873,6 +37875,12 @@ var EN = {
|
|
|
37873
37875
|
"setup.userSkills.ask": "Install the coordinator skill for {app}? [y/N/a=all]",
|
|
37874
37876
|
"setup.userSkills.changed": "file changed meanwhile",
|
|
37875
37877
|
"setup.userSkills.more": "… {count} more changed lines",
|
|
37878
|
+
"setup.userSkills.modified": "changed locally",
|
|
37879
|
+
"setup.userSkills.update": "Update {name} ({apps})? [y/N]",
|
|
37880
|
+
"setup.userSkills.updated": "{name} updated ({apps})",
|
|
37881
|
+
"setup.unchanged": "Setup unchanged: everything required is set up.",
|
|
37882
|
+
"setup.hint": "1 note: {command}",
|
|
37883
|
+
"setup.hints": "{count} notes: {command}",
|
|
37876
37884
|
"setup.plugins.title": "Plugins from kits (vendor packages)",
|
|
37877
37885
|
"setup.plugins.current": "installed ({version})",
|
|
37878
37886
|
"setup.plugins.otherVersion": "version {version} (approved: {approved})",
|
|
@@ -38762,6 +38770,12 @@ var DE = {
|
|
|
38762
38770
|
"setup.userSkills.ask": "Koordinator-Skill für {app} installieren? [j/N/a=alle]",
|
|
38763
38771
|
"setup.userSkills.changed": "Datei inzwischen geändert",
|
|
38764
38772
|
"setup.userSkills.more": "… {count} weitere geänderte Zeilen",
|
|
38773
|
+
"setup.userSkills.modified": "lokal geändert",
|
|
38774
|
+
"setup.userSkills.update": "{name} aktualisieren ({apps})? [j/N]",
|
|
38775
|
+
"setup.userSkills.updated": "{name} aktualisiert ({apps})",
|
|
38776
|
+
"setup.unchanged": "Einrichtung unverändert: Alles Nötige ist eingerichtet.",
|
|
38777
|
+
"setup.hint": "1 Hinweis: {command}",
|
|
38778
|
+
"setup.hints": "{count} Hinweise: {command}",
|
|
38765
38779
|
"setup.plugins.title": "Plugins aus Kits (Hersteller-Pakete)",
|
|
38766
38780
|
"setup.plugins.current": "installiert ({version})",
|
|
38767
38781
|
"setup.plugins.otherVersion": "Version {version} (freigegeben: {approved})",
|
|
@@ -39737,9 +39751,9 @@ async function listen(source, options) {
|
|
|
39737
39751
|
pages2[pages2.length - 1].cursor = page.cursor;
|
|
39738
39752
|
continue;
|
|
39739
39753
|
}
|
|
39740
|
-
const
|
|
39741
|
-
pages2.push(
|
|
39742
|
-
held = page.events.map((event) => ({ event, page:
|
|
39754
|
+
const record2 = { from, cursor: page.cursor, remaining: page.events.length, deadLetters: [] };
|
|
39755
|
+
pages2.push(record2);
|
|
39756
|
+
held = page.events.map((event) => ({ event, page: record2, attempts: 0, lastExit: "" }));
|
|
39743
39757
|
advance();
|
|
39744
39758
|
if (from === null && !page.events.length) await writes;
|
|
39745
39759
|
pump();
|
|
@@ -49220,9 +49234,9 @@ function verifySigned(signed, trust, purpose, parse2) {
|
|
|
49220
49234
|
return parsed;
|
|
49221
49235
|
}
|
|
49222
49236
|
function requireFields(expected, fields) {
|
|
49223
|
-
const
|
|
49237
|
+
const record2 = expected ?? {};
|
|
49224
49238
|
for (const field of fields)
|
|
49225
|
-
if (
|
|
49239
|
+
if (record2[field] === void 0 || record2[field] === null)
|
|
49226
49240
|
invalid5("expectation_missing", field);
|
|
49227
49241
|
}
|
|
49228
49242
|
var ATTESTATION_BINDING = ["issuer", "workspaceId", "kitKey", "version", "contentHash", "baseKitHash", "placement"];
|
|
@@ -51375,8 +51389,8 @@ async function orcaStart(deps, key, values) {
|
|
|
51375
51389
|
}
|
|
51376
51390
|
|
|
51377
51391
|
// src/uninstall.ts
|
|
51378
|
-
import { cp as cp2, lstat as lstat11, mkdir as
|
|
51379
|
-
import { dirname as dirname15, join as
|
|
51392
|
+
import { cp as cp2, lstat as lstat11, mkdir as mkdir6, readFile as readFile18, readdir as readdir10, realpath as realpath13, rm as rm8, rmdir as rmdir2 } from "node:fs/promises";
|
|
51393
|
+
import { dirname as dirname15, join as join23, sep as sep6 } from "node:path";
|
|
51380
51394
|
import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
|
|
51381
51395
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
51382
51396
|
|
|
@@ -52631,6 +52645,7 @@ async function planFleek(system, row, binaries, binding2 = {}) {
|
|
|
52631
52645
|
}
|
|
52632
52646
|
|
|
52633
52647
|
// src/user-skills.ts
|
|
52648
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
52634
52649
|
import { lstat as lstat5, readFile as readFile10, realpath as realpath8, stat as stat8 } from "node:fs/promises";
|
|
52635
52650
|
import { dirname as dirname8, join as join13, sep as sep4 } from "node:path";
|
|
52636
52651
|
|
|
@@ -52689,6 +52704,29 @@ async function writable(home, file) {
|
|
|
52689
52704
|
return false;
|
|
52690
52705
|
}
|
|
52691
52706
|
}
|
|
52707
|
+
var USER_SKILL_SHIPPED = {
|
|
52708
|
+
"fleek-orca-coordinator": [
|
|
52709
|
+
"dbebd679b5cdd87644cc408da803f1b147821bb411a6fca0e6b7360d3d9539da",
|
|
52710
|
+
"fdc6208069027b4dbe6be9a0c970925f6465c85a37873ebdf86703831c04c4a4",
|
|
52711
|
+
"b28af54eb6eab688068d273ec1b7f3f87c46786bce939b7a092b941d17df0807",
|
|
52712
|
+
"4defbaf8528fb31b343eed3c661415183f4cf629ea23cca7e6f58d800b1ec51c",
|
|
52713
|
+
"c03bc35e59a3b20d7cae1ba64114f21555d1b687694695185bd2071d99f7900f",
|
|
52714
|
+
"7182a11083c194f95b98589a73a589af16a48d5ce110a040d3dd5f7cd1f0f05e",
|
|
52715
|
+
"6ec081f07fb27ade572fcf209af73483812bd4c7d439bab0dd4419cf3a8fca72",
|
|
52716
|
+
"f52bdadf883c2bc15b058493684011dffb529488123d3c8764ef7bd0410d742a",
|
|
52717
|
+
"d7896ddfd21ade22af5e30445cb3e8c4bc137da4be4f852ef419323996caf428",
|
|
52718
|
+
"ddbdda2839b41d12115b11375299ee5e653b797093ba796e31b29cd81327dd3f",
|
|
52719
|
+
"672bcc2a133cadd0a62dbb2552cf245f5e48e5e1bd2ab02261590b05cc447279",
|
|
52720
|
+
"00c1a07f8683758b985db5f33078da4bfb3a1a78319db4e81f429ed7e88a2edd",
|
|
52721
|
+
"da9ab30d62945309bb191546ca46dce85cc11c5e586668346f4c2f36666e7940",
|
|
52722
|
+
"f546444e239cc0ce2a752208a0f24ea8728bf670af228a3754ef3e3ebb27bc5b",
|
|
52723
|
+
"8654a79d7c53852bffc9e8467b33a5639c5a926f87338fdf01c60197efdb0812",
|
|
52724
|
+
"a0133e457de20257a76dc0f2835f187817de2dd6e34236b00cb5217baadaad19",
|
|
52725
|
+
"77c45e67d32e75fb0490b1b5394516069f410644a30da7dbb55c5520cea396c6"
|
|
52726
|
+
]
|
|
52727
|
+
};
|
|
52728
|
+
var skillHash = (content3) => createHash6("sha256").update(content3).digest("hex");
|
|
52729
|
+
var shippedOutdated = (row) => row.state === "outdated" && row.before !== null && (USER_SKILL_SHIPPED[row.name] ?? []).includes(skillHash(row.before));
|
|
52692
52730
|
async function inspectUserSkills(home) {
|
|
52693
52731
|
const rows = [];
|
|
52694
52732
|
for (const root of USER_SKILL_ROOTS) {
|
|
@@ -52733,8 +52771,9 @@ async function orcaPresent(system) {
|
|
|
52733
52771
|
if (["ORCA_WORKTREE_ID", "ORCA_TERMINAL_HANDLE", "ORCA_USER_DATA_PATH"].some((key) => system.env[key])) return true;
|
|
52734
52772
|
return stat8(orcaUserData(system)).then((info) => info.isDirectory(), () => false);
|
|
52735
52773
|
}
|
|
52736
|
-
async function userSkillStep(ctx, system, interactive, ask2) {
|
|
52774
|
+
async function userSkillStep(ctx, system, interactive, ask2, options = {}) {
|
|
52737
52775
|
if (ctx.json || !await orcaPresent(system)) return 0;
|
|
52776
|
+
const askMissing = options.askMissing !== false;
|
|
52738
52777
|
const s = ctx.out.style;
|
|
52739
52778
|
const rows = await inspectUserSkills(system.home);
|
|
52740
52779
|
ctx.out.line();
|
|
@@ -52742,13 +52781,13 @@ async function userSkillStep(ctx, system, interactive, ask2) {
|
|
|
52742
52781
|
ctx.out.line(ctx.t("setup.userSkills.purpose"));
|
|
52743
52782
|
for (const line of s.columns(rows.map((row) => [
|
|
52744
52783
|
s.bold(`${row.name} · ${row.app}`),
|
|
52745
|
-
row.state === "current" ? s.state("ok", ctx.t("setup.userSkills.current")) : row.state === "outdated" ? s.state("outdated", ctx.t("setup.userSkills.outdated")) : row.state === "missing" ? s.state("absent", ctx.t("setup.status.missing")) : s.state("muted", ctx.t("setup.userSkills.foreign"))
|
|
52784
|
+
row.state === "current" ? s.state("ok", ctx.t("setup.userSkills.current")) : row.state === "outdated" ? s.state("outdated", ctx.t(shippedOutdated(row) ? "setup.userSkills.outdated" : "setup.userSkills.modified")) : row.state === "missing" ? s.state("absent", ctx.t("setup.status.missing")) : s.state("muted", ctx.t("setup.userSkills.foreign"))
|
|
52746
52785
|
]))) ctx.out.line(line);
|
|
52747
52786
|
if (!interactive) return 0;
|
|
52748
52787
|
let all = false;
|
|
52749
52788
|
let failed2 = 0;
|
|
52750
52789
|
const stamp = new Date(ctx.now()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
52751
|
-
for (const listed of rows.filter((row) => row.state === "missing" || row.state === "outdated")) {
|
|
52790
|
+
for (const listed of rows.filter((row) => row.state === "missing" && askMissing || row.state === "outdated" && !shippedOutdated(row))) {
|
|
52752
52791
|
const [row] = (await inspectUserSkills(system.home)).filter((entry) => entry.file === listed.file);
|
|
52753
52792
|
if (!row || row.state !== "missing" && row.state !== "outdated") continue;
|
|
52754
52793
|
const label = `${row.name} → ${row.app}`;
|
|
@@ -52788,6 +52827,54 @@ async function userSkillStep(ctx, system, interactive, ask2) {
|
|
|
52788
52827
|
}
|
|
52789
52828
|
return failed2;
|
|
52790
52829
|
}
|
|
52830
|
+
function shippedUpdateLines(rows) {
|
|
52831
|
+
return byName(rows).map(([name, apps]) => `~ ${name} (${apps})`);
|
|
52832
|
+
}
|
|
52833
|
+
function byName(rows) {
|
|
52834
|
+
return [...new Set(rows.map((row) => row.name))].map((name) => [name, [...new Set(rows.filter((row) => row.name === name).map((row) => row.app))].join(", ")]);
|
|
52835
|
+
}
|
|
52836
|
+
async function updateShippedSkills(ctx, system, listed, ask2) {
|
|
52837
|
+
if (!listed.length) return 0;
|
|
52838
|
+
const s = ctx.out.style;
|
|
52839
|
+
if (ask2) {
|
|
52840
|
+
const groups = byName(listed);
|
|
52841
|
+
if (await ask2([ctx.t("setup.userSkills.update", { name: groups.map(([name]) => name).join(", "), apps: [...new Set(listed.map((row) => row.app))].join(", ") })]) === "no") return 0;
|
|
52842
|
+
}
|
|
52843
|
+
const stamp = new Date(ctx.now()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
52844
|
+
const undo = [];
|
|
52845
|
+
const done = [];
|
|
52846
|
+
let failed2 = 0;
|
|
52847
|
+
for (const item2 of listed) {
|
|
52848
|
+
const [row] = (await inspectUserSkills(system.home)).filter((entry) => entry.file === item2.file);
|
|
52849
|
+
if (!row || !shippedOutdated(row) || row.before !== item2.before) {
|
|
52850
|
+
if (row?.state !== "current") {
|
|
52851
|
+
failed2++;
|
|
52852
|
+
ctx.out.line(` ${s.fail(ctx.t("setup.failed", { server: item2.name, client: item2.app, reason: ctx.t("setup.userSkills.changed") }))}`);
|
|
52853
|
+
}
|
|
52854
|
+
continue;
|
|
52855
|
+
}
|
|
52856
|
+
let outcome = "failed";
|
|
52857
|
+
let backup = null;
|
|
52858
|
+
if (await writable(system.home, row.file)) {
|
|
52859
|
+
try {
|
|
52860
|
+
backup = await backupFile(ctx.configDir, stamp, row.client, row.file);
|
|
52861
|
+
outcome = await writeIfUnchanged(row.file, row.before, row.content);
|
|
52862
|
+
} catch {
|
|
52863
|
+
outcome = "failed";
|
|
52864
|
+
}
|
|
52865
|
+
}
|
|
52866
|
+
if (outcome !== "ok") {
|
|
52867
|
+
failed2++;
|
|
52868
|
+
ctx.out.line(` ${s.fail(ctx.t("setup.failed", { server: row.name, client: row.app, reason: ctx.t(outcome === "changed" ? "setup.userSkills.changed" : "setup.reason.config") }))}`);
|
|
52869
|
+
continue;
|
|
52870
|
+
}
|
|
52871
|
+
done.push(row);
|
|
52872
|
+
undo.push(backup ? `cp ${shellWord(backup)} ${shellWord(row.file)}` : `rm ${shellWord(row.file)}`);
|
|
52873
|
+
}
|
|
52874
|
+
for (const [name, apps] of byName(done)) ctx.out.line(s.ok(ctx.t("setup.userSkills.updated", { name, apps })));
|
|
52875
|
+
if (undo.length) ctx.out.line(` ${s.note(ctx.t("setup.fleek.undo", { command: neutralizeLine(undo.join(" && ")) }))}`);
|
|
52876
|
+
return failed2;
|
|
52877
|
+
}
|
|
52791
52878
|
|
|
52792
52879
|
// src/uninstall-packages.ts
|
|
52793
52880
|
import { readFile as readFile12, realpath as realpath10 } from "node:fs/promises";
|
|
@@ -53147,17 +53234,56 @@ async function copyStartCommand(system, wrapper) {
|
|
|
53147
53234
|
});
|
|
53148
53235
|
}
|
|
53149
53236
|
|
|
53237
|
+
// src/setup-marker.ts
|
|
53238
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
53239
|
+
import { mkdir as mkdir4, readFile as readFile14 } from "node:fs/promises";
|
|
53240
|
+
import { join as join18 } from "node:path";
|
|
53241
|
+
var FILE = "setup-state.json";
|
|
53242
|
+
var MAX = 64 * 1024;
|
|
53243
|
+
var HEX = /^[0-9a-f]{64}$/;
|
|
53244
|
+
var markerPath = (configDir) => join18(configDir, FILE);
|
|
53245
|
+
function digest(lines) {
|
|
53246
|
+
return createHash7("sha256").update([...lines].sort().join("\n")).digest("hex");
|
|
53247
|
+
}
|
|
53248
|
+
var record = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
53249
|
+
var strings = (value) => record(value) ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string" && entry[1].length < 4096)) : {};
|
|
53250
|
+
async function readSetupMarker(configDir) {
|
|
53251
|
+
try {
|
|
53252
|
+
const text6 = await readFile14(markerPath(configDir), "utf8");
|
|
53253
|
+
if (text6.length > MAX) return null;
|
|
53254
|
+
const value = JSON.parse(text6);
|
|
53255
|
+
if (!record(value) || value.v !== 1) return null;
|
|
53256
|
+
return {
|
|
53257
|
+
v: 1,
|
|
53258
|
+
steps: Object.fromEntries(Object.entries(strings(value.steps)).filter(([, hash]) => HEX.test(hash))),
|
|
53259
|
+
startCommands: strings(value.startCommands),
|
|
53260
|
+
startClients: typeof value.startClients === "string" ? value.startClients : "",
|
|
53261
|
+
warnings: Array.isArray(value.warnings) ? value.warnings.filter((item2) => typeof item2 === "string" && HEX.test(item2)).slice(0, 256) : []
|
|
53262
|
+
};
|
|
53263
|
+
} catch {
|
|
53264
|
+
return null;
|
|
53265
|
+
}
|
|
53266
|
+
}
|
|
53267
|
+
async function writeSetupMarker(configDir, marker2) {
|
|
53268
|
+
try {
|
|
53269
|
+
await mkdir4(configDir, { recursive: true, mode: 448 });
|
|
53270
|
+
await writePrivateFile(markerPath(configDir), `${JSON.stringify(marker2, null, 2)}
|
|
53271
|
+
`);
|
|
53272
|
+
} catch {
|
|
53273
|
+
}
|
|
53274
|
+
}
|
|
53275
|
+
|
|
53150
53276
|
// src/uninstall-checkouts.ts
|
|
53151
|
-
import { cp, lstat as lstat8, readFile as
|
|
53152
|
-
import { dirname as dirname13, join as
|
|
53277
|
+
import { cp, lstat as lstat8, readFile as readFile16, readdir as readdir7 } from "node:fs/promises";
|
|
53278
|
+
import { dirname as dirname13, join as join20 } from "node:path";
|
|
53153
53279
|
|
|
53154
53280
|
// src/kit-checkout.ts
|
|
53155
53281
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
53156
|
-
import { lstat as lstat7, mkdir as
|
|
53157
|
-
import { basename as basename5, dirname as dirname12, join as
|
|
53282
|
+
import { lstat as lstat7, mkdir as mkdir5, open as open4, readFile as readFile15, rename as rename3, rm as rm7, stat as stat10 } from "node:fs/promises";
|
|
53283
|
+
import { basename as basename5, dirname as dirname12, join as join19 } from "node:path";
|
|
53158
53284
|
|
|
53159
53285
|
// src/kit-compose.ts
|
|
53160
|
-
import { createHash as
|
|
53286
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
53161
53287
|
var unsupported = (reason, target) => new CliError("errors.kitTargetUnsupported", EXIT.failed, { reason, target }, "KIT_TARGET_UNSUPPORTED");
|
|
53162
53288
|
var invalid6 = (reason, path = "") => new CliError("errors.kitInvalid", EXIT.failed, { reason, path }, "KIT_INVALID");
|
|
53163
53289
|
var E1_KEY = "work";
|
|
@@ -53314,7 +53440,7 @@ function composeTarget(target, kits, options) {
|
|
|
53314
53440
|
state: { files: [...privateFiles.keys()].sort(), instructions: !!instructions3, mcp: privateMcp.map((s) => s.name).sort(), e1 }
|
|
53315
53441
|
};
|
|
53316
53442
|
}
|
|
53317
|
-
var sha256 = (text6) =>
|
|
53443
|
+
var sha256 = (text6) => createHash8("sha256").update(text6, "utf8").digest("hex");
|
|
53318
53444
|
|
|
53319
53445
|
// src/kit-checkout.ts
|
|
53320
53446
|
var MARKER_LINE = /^<!-- fleek-kit:([a-z][a-z0-9-]{0,40})@([0-9A-Za-z.]{1,16}) ([0-9a-f]{12})(?: (begin|end))? -->$/;
|
|
@@ -53329,7 +53455,7 @@ async function readExisting(path) {
|
|
|
53329
53455
|
}
|
|
53330
53456
|
if (!info.isFile()) throw notRepoSafe("checkout_not_a_file");
|
|
53331
53457
|
if (info.size > 1024 * 1024) throw notRepoSafe("checkout_file_too_large");
|
|
53332
|
-
return
|
|
53458
|
+
return readFile15(path, "utf8");
|
|
53333
53459
|
}
|
|
53334
53460
|
function fileMarkerOf(content3) {
|
|
53335
53461
|
const lines = content3.replace(/\n+$/, "").split("\n");
|
|
@@ -53542,8 +53668,8 @@ ${marker(file.key, file.version, domain)}
|
|
|
53542
53668
|
const untracked = [];
|
|
53543
53669
|
for (const path of created) if (!await isTracked(root, path, input.env)) untracked.push(path);
|
|
53544
53670
|
const common = await commonGitDir(root, input.env);
|
|
53545
|
-
const excludePath =
|
|
53546
|
-
if ((await lstat7(
|
|
53671
|
+
const excludePath = join19(common, "info", "exclude");
|
|
53672
|
+
if ((await lstat7(join19(common, "info")).catch(() => null))?.isSymbolicLink()) throw notRepoSafe("checkout_symlink");
|
|
53547
53673
|
const existingExclude = await readExisting(excludePath);
|
|
53548
53674
|
const section = `${domain}:${sha256(root).slice(0, 8)}`;
|
|
53549
53675
|
const begin = `# fleek-kit ${section} begin`, end = `# fleek-kit ${section} end`;
|
|
@@ -53592,9 +53718,9 @@ async function writeOne(path, content3) {
|
|
|
53592
53718
|
await syncDir(dirname12(path)).catch(() => void 0);
|
|
53593
53719
|
return;
|
|
53594
53720
|
}
|
|
53595
|
-
await
|
|
53721
|
+
await mkdir5(dirname12(path), { recursive: true, mode: 493 });
|
|
53596
53722
|
const mode = await stat10(path).then((info) => info.mode & 511).catch(() => 420);
|
|
53597
|
-
const temp =
|
|
53723
|
+
const temp = join19(dirname12(path), `.${basename5(path)}.fleek-${randomBytes8(6).toString("hex")}.tmp`);
|
|
53598
53724
|
const handle = await open4(temp, "wx", mode);
|
|
53599
53725
|
try {
|
|
53600
53726
|
await handle.writeFile(content3, "utf8");
|
|
@@ -53661,7 +53787,7 @@ async function removalPlan(row, env) {
|
|
|
53661
53787
|
}
|
|
53662
53788
|
async function planCheckoutRemovals(configDir, profileKey2, env) {
|
|
53663
53789
|
const rows = [];
|
|
53664
|
-
const profileDir =
|
|
53790
|
+
const profileDir = join20(configDir, "kits", profileKey2);
|
|
53665
53791
|
const projects = await readdir7(profileDir).catch((error) => {
|
|
53666
53792
|
if (error.code === "ENOENT") return [];
|
|
53667
53793
|
throw error;
|
|
@@ -53680,7 +53806,7 @@ async function planCheckoutRemovals(configDir, profileKey2, env) {
|
|
|
53680
53806
|
const row = { domain, root, entries };
|
|
53681
53807
|
const plan = await removalPlan(row, env).catch(() => null);
|
|
53682
53808
|
if (plan && !plan.writes.length && !plan.entries.length) continue;
|
|
53683
|
-
rows.push({ ...row, paths: plan?.writes.map((write2) => write2.path) ?? entries.map((entry) =>
|
|
53809
|
+
rows.push({ ...row, paths: plan?.writes.map((write2) => write2.path) ?? entries.map((entry) => join20(root, entry.path)), remaining: !plan || plan.handEdited });
|
|
53684
53810
|
}
|
|
53685
53811
|
} catch {
|
|
53686
53812
|
unreadable = true;
|
|
@@ -53704,15 +53830,15 @@ async function removeCheckoutParts(rows, env, backup) {
|
|
|
53704
53830
|
}
|
|
53705
53831
|
const snapshots = /* @__PURE__ */ new Map();
|
|
53706
53832
|
for (const write2 of plan.writes) {
|
|
53707
|
-
const before = await
|
|
53833
|
+
const before = await readFile16(write2.path, "utf8").catch((error) => {
|
|
53708
53834
|
if (error.code === "ENOENT") return null;
|
|
53709
53835
|
throw error;
|
|
53710
53836
|
});
|
|
53711
53837
|
snapshots.set(write2.path, before);
|
|
53712
|
-
if (before !== null) await cp(write2.path,
|
|
53838
|
+
if (before !== null) await cp(write2.path, join20(backup, `checkout-${++index}`), { force: false, errorOnExist: true });
|
|
53713
53839
|
}
|
|
53714
53840
|
for (const [path, before] of snapshots) {
|
|
53715
|
-
if (await
|
|
53841
|
+
if (await readFile16(path, "utf8").catch(() => null) !== before) {
|
|
53716
53842
|
remaining.add(row.root);
|
|
53717
53843
|
return;
|
|
53718
53844
|
}
|
|
@@ -53725,7 +53851,7 @@ async function removeCheckoutParts(rows, env, backup) {
|
|
|
53725
53851
|
|
|
53726
53852
|
// src/codex-skills.ts
|
|
53727
53853
|
import { lstat as lstat9, readdir as readdir8, rmdir } from "node:fs/promises";
|
|
53728
|
-
import { dirname as dirname14, join as
|
|
53854
|
+
import { dirname as dirname14, join as join21 } from "node:path";
|
|
53729
53855
|
var CODEX_SKILLS_ROOT = ".agents/skills";
|
|
53730
53856
|
var MANIFEST = `${CODEX_SKILLS_ROOT}/.fleek-kits.json`;
|
|
53731
53857
|
var SKILL_ID = /^fleek-[a-z0-9][a-z0-9-]{0,57}$/;
|
|
@@ -53736,7 +53862,7 @@ async function codexSkills(domain, gen) {
|
|
|
53736
53862
|
const out = /* @__PURE__ */ new Map();
|
|
53737
53863
|
for (const rel of gen?.state.targets.codex?.files ?? []) {
|
|
53738
53864
|
const id = BUNDLE_SKILL.exec(rel)?.[1];
|
|
53739
|
-
if (id) out.set(id, await domain.readFile(gen,
|
|
53865
|
+
if (id) out.set(id, await domain.readFile(gen, join21("bundle", "codex", rel)));
|
|
53740
53866
|
}
|
|
53741
53867
|
return out;
|
|
53742
53868
|
}
|
|
@@ -53765,8 +53891,8 @@ var exists3 = (path) => lstat9(path).then(() => true, (error) => {
|
|
|
53765
53891
|
throw error;
|
|
53766
53892
|
});
|
|
53767
53893
|
async function writeExclude(common, root, ids) {
|
|
53768
|
-
if ((await lstat9(
|
|
53769
|
-
const path =
|
|
53894
|
+
if ((await lstat9(join21(common, "info")).catch(() => null))?.isSymbolicLink()) throw notRepoSafe("checkout_symlink");
|
|
53895
|
+
const path = join21(common, "info", "exclude");
|
|
53770
53896
|
const text6 = await readExisting(path) ?? "";
|
|
53771
53897
|
const lines = text6.split("\n");
|
|
53772
53898
|
const tag = sha256(root).slice(0, 8);
|
|
@@ -53856,14 +53982,14 @@ async function syncCodexSkills(input) {
|
|
|
53856
53982
|
}
|
|
53857
53983
|
async function hasCodexManifest(cwd) {
|
|
53858
53984
|
const root = await findCheckoutRoot(cwd).catch(() => null);
|
|
53859
|
-
return !!root && await exists3(
|
|
53985
|
+
return !!root && await exists3(join21(root, MANIFEST)).catch(() => false);
|
|
53860
53986
|
}
|
|
53861
53987
|
async function recordedRoots(domain) {
|
|
53862
|
-
const value = await readJsonFile(
|
|
53988
|
+
const value = await readJsonFile(join21(domain.dir, "codex-skill-roots.json")).catch(() => null);
|
|
53863
53989
|
return value?.v === 1 && Array.isArray(value.roots) ? value.roots.filter((root) => typeof root === "string" && root.startsWith("/")).slice(-ROOTS_MAX) : [];
|
|
53864
53990
|
}
|
|
53865
53991
|
async function writeRoots(domain, roots) {
|
|
53866
|
-
await writePrivateFile(
|
|
53992
|
+
await writePrivateFile(join21(domain.dir, "codex-skill-roots.json"), `${JSON.stringify({ v: 1, roots: roots.slice(-ROOTS_MAX) })}
|
|
53867
53993
|
`);
|
|
53868
53994
|
}
|
|
53869
53995
|
async function recordRoot(domain, root) {
|
|
@@ -53889,7 +54015,7 @@ async function resyncRecordedRoots(configDir, domain, gen, env) {
|
|
|
53889
54015
|
return failed2;
|
|
53890
54016
|
}
|
|
53891
54017
|
async function planCodexSkillRemovals(configDir, profileKey2) {
|
|
53892
|
-
const projects = await readdir8(
|
|
54018
|
+
const projects = await readdir8(join21(configDir, "kits", profileKey2)).catch(() => []);
|
|
53893
54019
|
const rows = [];
|
|
53894
54020
|
for (const projectId of projects.filter((name) => /^[0-9a-f-]{36}$/.test(name))) {
|
|
53895
54021
|
const domain = new KitDomain(configDir, profileKey2, projectId);
|
|
@@ -53910,8 +54036,8 @@ async function planCodexSkillRemovals(configDir, profileKey2) {
|
|
|
53910
54036
|
}
|
|
53911
54037
|
|
|
53912
54038
|
// src/plugin-step.ts
|
|
53913
|
-
import { lstat as lstat10, readdir as readdir9, readFile as
|
|
53914
|
-
import { join as
|
|
54039
|
+
import { lstat as lstat10, readdir as readdir9, readFile as readFile17, realpath as realpath12, stat as stat11 } from "node:fs/promises";
|
|
54040
|
+
import { join as join22, sep as sep5 } from "node:path";
|
|
53915
54041
|
var PLUGIN_CLIENTS = ["claude", "codex"];
|
|
53916
54042
|
var LABEL3 = { claude: "Claude Code", codex: "Codex" };
|
|
53917
54043
|
var LIST_TIMEOUT_MS = 2e4;
|
|
@@ -53982,13 +54108,13 @@ async function readSmall(path) {
|
|
|
53982
54108
|
try {
|
|
53983
54109
|
const info = await lstat10(path);
|
|
53984
54110
|
if (!info.isFile() || info.size > STATE_READ_LIMIT) return null;
|
|
53985
|
-
return await
|
|
54111
|
+
return await readFile17(path, "utf8");
|
|
53986
54112
|
} catch {
|
|
53987
54113
|
return null;
|
|
53988
54114
|
}
|
|
53989
54115
|
}
|
|
53990
54116
|
async function claudeInstalledCommit(system, home, id, installPath) {
|
|
53991
|
-
const text6 = await readSmall(
|
|
54117
|
+
const text6 = await readSmall(join22(home.configDir ?? join22(system.home, ".claude"), "plugins", "installed_plugins.json"));
|
|
53992
54118
|
if (text6 === null) return null;
|
|
53993
54119
|
let parsed;
|
|
53994
54120
|
try {
|
|
@@ -54003,14 +54129,14 @@ async function claudeInstalledCommit(system, home, id, installPath) {
|
|
|
54003
54129
|
}
|
|
54004
54130
|
async function checkoutCommit(root) {
|
|
54005
54131
|
if (!root) return null;
|
|
54006
|
-
const git3 =
|
|
54007
|
-
const head = (await readSmall(
|
|
54132
|
+
const git3 = join22(root, ".git");
|
|
54133
|
+
const head = (await readSmall(join22(git3, "HEAD")))?.trim() ?? "";
|
|
54008
54134
|
if (PLUGIN_COMMIT.test(head)) return head;
|
|
54009
54135
|
const ref = /^ref: (refs\/heads\/[A-Za-z0-9._/-]{1,200})$/.exec(head)?.[1];
|
|
54010
54136
|
if (!ref || ref.includes("..")) return null;
|
|
54011
|
-
const loose = (await readSmall(
|
|
54137
|
+
const loose = (await readSmall(join22(git3, ref)))?.trim() ?? "";
|
|
54012
54138
|
if (PLUGIN_COMMIT.test(loose)) return loose;
|
|
54013
|
-
for (const line of (await readSmall(
|
|
54139
|
+
for (const line of (await readSmall(join22(git3, "packed-refs")) ?? "").split("\n")) {
|
|
54014
54140
|
const [sha, name] = line.trim().split(" ");
|
|
54015
54141
|
if (name === ref && sha && PLUGIN_COMMIT.test(sha)) return sha;
|
|
54016
54142
|
}
|
|
@@ -54023,9 +54149,9 @@ var MANIFESTS = {
|
|
|
54023
54149
|
async function localPluginSource(root, client, name) {
|
|
54024
54150
|
let text6 = null;
|
|
54025
54151
|
for (const file of MANIFESTS[client]) {
|
|
54026
|
-
const present = await lstat10(
|
|
54152
|
+
const present = await lstat10(join22(root, file)).then(() => true, () => false);
|
|
54027
54153
|
if (!present) continue;
|
|
54028
|
-
text6 = await readSmall(
|
|
54154
|
+
text6 = await readSmall(join22(root, file));
|
|
54029
54155
|
break;
|
|
54030
54156
|
}
|
|
54031
54157
|
if (text6 === null) return false;
|
|
@@ -54046,7 +54172,7 @@ async function localPluginSource(root, client, name) {
|
|
|
54046
54172
|
if (typeof path !== "string") return false;
|
|
54047
54173
|
const relative3 = path === "." || path === "./" ? "" : path.startsWith("./") ? path.slice(2).replace(/\/$/, "") : null;
|
|
54048
54174
|
if (relative3 === null || relative3.includes("\\") || relative3 && relative3.split("/").some((part) => !part || part === "." || part === "..")) return false;
|
|
54049
|
-
const real = await realpath12(
|
|
54175
|
+
const real = await realpath12(join22(root, relative3)).catch(() => null);
|
|
54050
54176
|
if (!real || real !== realRoot && !real.startsWith(`${realRoot}${sep5}`) || !await stat11(real).then((info) => info.isDirectory(), () => false)) return false;
|
|
54051
54177
|
}
|
|
54052
54178
|
return true;
|
|
@@ -54067,7 +54193,7 @@ async function pluginHomes(system, clients, options = {}) {
|
|
|
54067
54193
|
...options.orca === false ? [] : (await orcaClaudeHomes(system)).map((orca2) => ({ client: "claude", configDir: orca2.home, account: orca2.account, accountLabel: orca2.label }))
|
|
54068
54194
|
];
|
|
54069
54195
|
for (const home of candidates) {
|
|
54070
|
-
const dir = home.configDir ??
|
|
54196
|
+
const dir = home.configDir ?? join22(system.home, ".claude");
|
|
54071
54197
|
const key = await realpath12(dir).catch(() => dir);
|
|
54072
54198
|
if (seen.has(key)) continue;
|
|
54073
54199
|
seen.add(key);
|
|
@@ -54273,7 +54399,7 @@ async function usableSkills(dir) {
|
|
|
54273
54399
|
for (const entry of await readdir9(parent, { withFileTypes: true }).catch(() => [])) {
|
|
54274
54400
|
if (++walked >= 5e3) return false;
|
|
54275
54401
|
if (entry.isFile() && entry.name.endsWith(".md")) return true;
|
|
54276
|
-
if (entry.isDirectory()) queue.push(
|
|
54402
|
+
if (entry.isDirectory()) queue.push(join22(parent, entry.name));
|
|
54277
54403
|
}
|
|
54278
54404
|
}
|
|
54279
54405
|
return false;
|
|
@@ -54293,13 +54419,13 @@ async function approvedPluginDirs(system, plugins) {
|
|
|
54293
54419
|
gap(row.state);
|
|
54294
54420
|
continue;
|
|
54295
54421
|
}
|
|
54296
|
-
const cache2 =
|
|
54422
|
+
const cache2 = join22(row.configDir ?? join22(system.home, ".claude"), "plugins", "cache");
|
|
54297
54423
|
const [realCache, realDir] = await Promise.all([realpath12(cache2).catch(() => null), row.installPath ? realpath12(row.installPath).catch(() => null) : null]);
|
|
54298
54424
|
if (!realCache || !realDir || !realDir.startsWith(`${realCache}${sep5}`) || !await stat11(realDir).then((info) => info.isDirectory(), () => false)) {
|
|
54299
54425
|
gap("outside_cache");
|
|
54300
54426
|
continue;
|
|
54301
54427
|
}
|
|
54302
|
-
if (!await usableSkills(
|
|
54428
|
+
if (!await usableSkills(join22(realDir, "skills"))) {
|
|
54303
54429
|
gap("no_skills");
|
|
54304
54430
|
continue;
|
|
54305
54431
|
}
|
|
@@ -54411,7 +54537,7 @@ async function text4(file) {
|
|
|
54411
54537
|
try {
|
|
54412
54538
|
const info = await lstat11(file);
|
|
54413
54539
|
if (!info.isFile() || info.size > 2 * 1024 * 1024) throw failure();
|
|
54414
|
-
return await
|
|
54540
|
+
return await readFile18(file, "utf8");
|
|
54415
54541
|
} catch (error) {
|
|
54416
54542
|
if (error.code === "ENOENT") return null;
|
|
54417
54543
|
throw error;
|
|
@@ -54429,13 +54555,13 @@ async function planUninstall(system, configDir, profiles, visited = /* @__PURE__
|
|
|
54429
54555
|
const edits = [], removals = [], hints = [];
|
|
54430
54556
|
const checkouts = [], retained = [];
|
|
54431
54557
|
const codexSkills2 = [];
|
|
54432
|
-
const profileIndex = await text4(
|
|
54558
|
+
const profileIndex = await text4(join23(configDir, "profiles.json"));
|
|
54433
54559
|
const jsonFiles = /* @__PURE__ */ new Set([
|
|
54434
|
-
|
|
54560
|
+
join23(system.home, ".claude.json"),
|
|
54435
54561
|
userConfigPath("claude", system),
|
|
54436
54562
|
userConfigPath("cursor", system),
|
|
54437
|
-
...system.env.CLAUDE_CONFIG_DIR?.startsWith("/") ? [
|
|
54438
|
-
...(await orcaClaudeHomes(system)).map((home) =>
|
|
54563
|
+
...system.env.CLAUDE_CONFIG_DIR?.startsWith("/") ? [join23(system.env.CLAUDE_CONFIG_DIR, ".claude.json")] : [],
|
|
54564
|
+
...(await orcaClaudeHomes(system)).map((home) => join23(home.home, ".claude.json")),
|
|
54439
54565
|
...state.configs.filter((row) => row.kind === "json").map((row) => row.file)
|
|
54440
54566
|
]);
|
|
54441
54567
|
for (const target of jsonFiles) {
|
|
@@ -54449,7 +54575,7 @@ async function planUninstall(system, configDir, profiles, visited = /* @__PURE__
|
|
|
54449
54575
|
const after = withoutJsonFleek(before, file);
|
|
54450
54576
|
if (after !== null) edits.push({ file, before, after, kind: "json" });
|
|
54451
54577
|
}
|
|
54452
|
-
for (const target of /* @__PURE__ */ new Set([
|
|
54578
|
+
for (const target of /* @__PURE__ */ new Set([join23(codexHome(system), "config.toml"), ...state.configs.filter((row) => row.kind === "toml").map((row) => row.file)])) {
|
|
54453
54579
|
const codex = await realpath13(target).catch(() => target);
|
|
54454
54580
|
if (!await safePath(codex)) {
|
|
54455
54581
|
retained.push(codex);
|
|
@@ -54466,7 +54592,7 @@ async function planUninstall(system, configDir, profiles, visited = /* @__PURE__
|
|
|
54466
54592
|
}
|
|
54467
54593
|
const orca2 = await inspectOrcaStartCommands(system, configDir);
|
|
54468
54594
|
for (const client of ["claude", "codex"]) {
|
|
54469
|
-
const file =
|
|
54595
|
+
const file = join23(configDir, "bin", `fleek-${client}`);
|
|
54470
54596
|
if (!await safePath(file)) {
|
|
54471
54597
|
retained.push(file);
|
|
54472
54598
|
continue;
|
|
@@ -54480,15 +54606,15 @@ async function planUninstall(system, configDir, profiles, visited = /* @__PURE__
|
|
|
54480
54606
|
}
|
|
54481
54607
|
for (const key of keys) {
|
|
54482
54608
|
if (!/^[0-9a-f]{32}$/.test(key)) throw failure();
|
|
54483
|
-
if (!await containedState(configDir,
|
|
54609
|
+
if (!await containedState(configDir, join23(configDir, "kits", key))) throw failure();
|
|
54484
54610
|
const checkout2 = await planCheckoutRemovals(configDir, key, system.env);
|
|
54485
54611
|
checkouts.push(...checkout2.rows);
|
|
54486
54612
|
codexSkills2.push(...await planCodexSkillRemovals(configDir, key));
|
|
54487
54613
|
const keep = checkout2.unreadable || checkout2.rows.some((row) => row.remaining);
|
|
54488
|
-
if (keep) retained.push(
|
|
54614
|
+
if (keep) retained.push(join23(configDir, "kits", key));
|
|
54489
54615
|
for (const dir of ["kits", "credentials", "listen", "dead-letter"]) {
|
|
54490
54616
|
if (dir === "kits" && keep) continue;
|
|
54491
|
-
const file =
|
|
54617
|
+
const file = join23(configDir, dir, key);
|
|
54492
54618
|
const info = await lstat11(file).catch((error) => {
|
|
54493
54619
|
if (error.code === "ENOENT") return null;
|
|
54494
54620
|
throw error;
|
|
@@ -54499,15 +54625,17 @@ async function planUninstall(system, configDir, profiles, visited = /* @__PURE__
|
|
|
54499
54625
|
}
|
|
54500
54626
|
}
|
|
54501
54627
|
}
|
|
54502
|
-
const update =
|
|
54628
|
+
const update = join23(configDir, "update-check.json"), cache2 = await text4(update);
|
|
54503
54629
|
if (cache2 !== null) removals.push({ file: update, before: cache2 });
|
|
54630
|
+
const marker2 = markerPath(configDir), shown3 = await text4(marker2);
|
|
54631
|
+
if (shown3 !== null) removals.push({ file: marker2, before: shown3 });
|
|
54504
54632
|
for (const entry of await readdir10(configDir, { withFileTypes: true }).catch((error) => {
|
|
54505
54633
|
if (error.code === "ENOENT") return [];
|
|
54506
54634
|
throw error;
|
|
54507
54635
|
})) {
|
|
54508
|
-
if (/^kit-run-[A-Za-z0-9_-]+$/.test(entry.name) && !entry.isSymbolicLink()) removals.push({ file:
|
|
54636
|
+
if (/^kit-run-[A-Za-z0-9_-]+$/.test(entry.name) && !entry.isSymbolicLink()) removals.push({ file: join23(configDir, entry.name) });
|
|
54509
54637
|
}
|
|
54510
|
-
const launcher = await safePath(
|
|
54638
|
+
const launcher = await safePath(join23(configDir, "bin", "fleek-link")) ? await text4(join23(configDir, "bin", "fleek-link")) : null;
|
|
54511
54639
|
const hasHandler = launcher?.startsWith("#!/bin/sh\n# Fleek link handler (fleek-orca://) - written by ") === true;
|
|
54512
54640
|
const packageCommands = await installedCliPackages(system);
|
|
54513
54641
|
const plugins = (await plannedPluginRemovals(system, configDir)).map((row) => ({ ...row, root: configDir }));
|
|
@@ -54551,22 +54679,22 @@ async function planUninstall(system, configDir, profiles, visited = /* @__PURE__
|
|
|
54551
54679
|
}
|
|
54552
54680
|
async function finishRoot(root, preserve, backup) {
|
|
54553
54681
|
for (const name of ["backups", "listen", "dead-letter", "locks"]) {
|
|
54554
|
-
const file =
|
|
54682
|
+
const file = join23(root.configDir, name);
|
|
54555
54683
|
if (!await safePath(file)) continue;
|
|
54556
54684
|
if (name === "backups" && backup?.startsWith(file + sep6)) {
|
|
54557
54685
|
for (const entry of await readdir10(file).catch(() => [])) {
|
|
54558
|
-
const child =
|
|
54686
|
+
const child = join23(file, entry);
|
|
54559
54687
|
if (child !== dirname15(backup)) await rm8(child, { recursive: true, force: true });
|
|
54560
54688
|
}
|
|
54561
54689
|
for (const entry of await readdir10(dirname15(backup)).catch(() => [])) {
|
|
54562
|
-
const child =
|
|
54690
|
+
const child = join23(dirname15(backup), entry);
|
|
54563
54691
|
if (child !== backup) await rm8(child, { recursive: true, force: true });
|
|
54564
54692
|
}
|
|
54565
54693
|
} else await rm8(file, { recursive: true, force: true });
|
|
54566
54694
|
}
|
|
54567
54695
|
if (!preserve) await rm8(statePath(root.configDir), { force: true });
|
|
54568
54696
|
for (const name of ["kits", "credentials", "bin", "link", "backups/uninstall", "backups"]) {
|
|
54569
|
-
const file =
|
|
54697
|
+
const file = join23(root.configDir, name);
|
|
54570
54698
|
if (await safePath(file)) await rmdir2(file).catch((error) => {
|
|
54571
54699
|
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error.code)) throw error;
|
|
54572
54700
|
});
|
|
@@ -54579,7 +54707,7 @@ async function uninstallCommand(input) {
|
|
|
54579
54707
|
const { plan, out, t } = input;
|
|
54580
54708
|
if (input.json && !input.dryRun) throw new CliError("errors.uninstallInteractive", EXIT.accessDenied, {}, "CONFIRMATION_REQUIRED");
|
|
54581
54709
|
const items = [
|
|
54582
|
-
...plan.profileIndex === null ? [] : [
|
|
54710
|
+
...plan.profileIndex === null ? [] : [join23(input.configDir, "profiles.json")],
|
|
54583
54711
|
...plan.edits.map((edit) => edit.file + " · fleek"),
|
|
54584
54712
|
...plan.removals.map((row) => row.file),
|
|
54585
54713
|
...plan.profiles.map((profile) => t("uninstall.profile", { workspace: neutralizeLine(profile.workspace.name) })),
|
|
@@ -54627,14 +54755,14 @@ async function uninstallCommand(input) {
|
|
|
54627
54755
|
await input.deleteSecret?.(account);
|
|
54628
54756
|
}
|
|
54629
54757
|
}
|
|
54630
|
-
const backup =
|
|
54631
|
-
await
|
|
54758
|
+
const backup = join23(plan.roots[0].configDir, "backups", "uninstall", `${input.now}-${randomBytes9(4).toString("hex")}`);
|
|
54759
|
+
await mkdir6(backup, { recursive: true, mode: 448 });
|
|
54632
54760
|
const remaining = await removeCheckoutParts(plan.checkouts, plan.env, backup);
|
|
54633
54761
|
const codexFailed = /* @__PURE__ */ new Set();
|
|
54634
54762
|
for (const row of plan.codexSkills) {
|
|
54635
54763
|
await syncCodexSkills({ configDir: row.domain.configDir, root: row.root, domain: row.domain.hash, skills: /* @__PURE__ */ new Map(), env: plan.env, others: "keep" }).catch(() => {
|
|
54636
54764
|
remaining.add(row.root);
|
|
54637
|
-
codexFailed.add(
|
|
54765
|
+
codexFailed.add(join23(row.domain.configDir, "kits", row.domain.profileKey));
|
|
54638
54766
|
});
|
|
54639
54767
|
}
|
|
54640
54768
|
const keptPlugins = new Map(plan.plugins.map((row) => [row.root, []]));
|
|
@@ -54643,8 +54771,8 @@ async function uninstallCommand(input) {
|
|
|
54643
54771
|
remaining.add(row.label);
|
|
54644
54772
|
}
|
|
54645
54773
|
for (const [root, installs] of keptPlugins) await writeInstalls(root, installs);
|
|
54646
|
-
const preserveKits = /* @__PURE__ */ new Set([...plan.checkouts.filter((row) => remaining.has(row.root)).map((row) =>
|
|
54647
|
-
if (plan.profileIndex !== null) await cp2(
|
|
54774
|
+
const preserveKits = /* @__PURE__ */ new Set([...plan.checkouts.filter((row) => remaining.has(row.root)).map((row) => join23(row.domain.configDir, "kits", row.domain.profileKey)), ...codexFailed]);
|
|
54775
|
+
if (plan.profileIndex !== null) await cp2(join23(plan.roots[0].configDir, "profiles.json"), join23(backup, "profiles.json"), { force: false, errorOnExist: true });
|
|
54648
54776
|
let index = 0;
|
|
54649
54777
|
for (const edit of plan.edits) {
|
|
54650
54778
|
let applied = false;
|
|
@@ -54656,7 +54784,7 @@ async function uninstallCommand(input) {
|
|
|
54656
54784
|
applied = true;
|
|
54657
54785
|
break;
|
|
54658
54786
|
}
|
|
54659
|
-
await cp2(edit.file,
|
|
54787
|
+
await cp2(edit.file, join23(backup, `${++index}-config`), { force: false, errorOnExist: true });
|
|
54660
54788
|
if (await writeIfUnchanged(edit.file, before, after) === "ok") {
|
|
54661
54789
|
applied = true;
|
|
54662
54790
|
break;
|
|
@@ -54668,7 +54796,7 @@ async function uninstallCommand(input) {
|
|
|
54668
54796
|
if (preserveKits.has(row.file)) continue;
|
|
54669
54797
|
if (!await safePath(row.file)) throw failure();
|
|
54670
54798
|
if (row.before !== void 0 && await text4(row.file) !== row.before) throw failure();
|
|
54671
|
-
await cp2(row.file,
|
|
54799
|
+
await cp2(row.file, join23(backup, `${++index}-local`), { recursive: true, force: false, errorOnExist: true });
|
|
54672
54800
|
await rm8(row.file, { recursive: row.before === void 0, force: true });
|
|
54673
54801
|
if (row.file.endsWith("/SKILL.md")) await rmdir2(dirname15(row.file)).catch((error) => {
|
|
54674
54802
|
if (!["ENOTEMPTY", "ENOENT"].includes(error.code ?? "")) throw error;
|
|
@@ -54698,14 +54826,14 @@ function revocationPage(profile) {
|
|
|
54698
54826
|
|
|
54699
54827
|
// src/orca-setup.ts
|
|
54700
54828
|
import { constants as fsConstants3 } from "node:fs";
|
|
54701
|
-
import { access as access4, mkdir as
|
|
54702
|
-
import { delimiter as delimiter3, dirname as dirname16, isAbsolute as isAbsolute10, join as
|
|
54829
|
+
import { access as access4, mkdir as mkdir7, readFile as readFile19, readdir as readdir11, realpath as realpath14, stat as stat12 } from "node:fs/promises";
|
|
54830
|
+
import { delimiter as delimiter3, dirname as dirname16, isAbsolute as isAbsolute10, join as join24, sep as sep7 } from "node:path";
|
|
54703
54831
|
var WRAPPER_CLIENTS = ["claude", "codex"];
|
|
54704
54832
|
async function orcaPresent2(system) {
|
|
54705
54833
|
if (Object.keys(system.env).some((key) => /^ORCA_(WORKTREE_ID|TERMINAL_HANDLE|USER_DATA_PATH)$/.test(key))) return true;
|
|
54706
54834
|
return stat12(orcaUserData(system)).then((info) => info.isDirectory(), () => false);
|
|
54707
54835
|
}
|
|
54708
|
-
var wrapperDir = (configDir) =>
|
|
54836
|
+
var wrapperDir = (configDir) => join24(configDir, "bin");
|
|
54709
54837
|
var quote3 = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
54710
54838
|
function wrapperContent(fleek, client, program) {
|
|
54711
54839
|
return [
|
|
@@ -54727,10 +54855,10 @@ async function realClient(system, client, configDir) {
|
|
|
54727
54855
|
async function wrapperStates(system, configDir, fleek) {
|
|
54728
54856
|
const out = [];
|
|
54729
54857
|
for (const client of WRAPPER_CLIENTS) {
|
|
54730
|
-
const path =
|
|
54858
|
+
const path = join24(wrapperDir(configDir), `fleek-${client}`);
|
|
54731
54859
|
const program = await realClient(system, client, configDir);
|
|
54732
54860
|
const content3 = program && fleek && await isStableFleek(fleek) ? wrapperContent(fleek, client, program) : null;
|
|
54733
|
-
const current2 = await
|
|
54861
|
+
const current2 = await readFile19(path, "utf8").catch(() => null);
|
|
54734
54862
|
const executable = current2 !== null && await access4(path, fsConstants3.X_OK).then(() => true, () => false);
|
|
54735
54863
|
out.push({ client, path, program, content: content3, before: current2, state: !content3 ? "unavailable" : current2 === null ? "missing" : current2 === content3 && executable ? "current" : "outdated" });
|
|
54736
54864
|
}
|
|
@@ -54738,8 +54866,8 @@ async function wrapperStates(system, configDir, fleek) {
|
|
|
54738
54866
|
}
|
|
54739
54867
|
async function writeWrapper(state, configDir) {
|
|
54740
54868
|
if (!state.content || state.state === "current") return false;
|
|
54741
|
-
await
|
|
54742
|
-
const before = await
|
|
54869
|
+
await mkdir7(dirname16(state.path), { recursive: true, mode: 448 });
|
|
54870
|
+
const before = await readFile19(state.path, "utf8").catch((error) => {
|
|
54743
54871
|
if (error.code === "ENOENT") return null;
|
|
54744
54872
|
throw error;
|
|
54745
54873
|
});
|
|
@@ -54771,7 +54899,7 @@ async function clientVersion(system, program) {
|
|
|
54771
54899
|
async function clientsOnPath(system, client, configDir) {
|
|
54772
54900
|
const out = [], seen = /* @__PURE__ */ new Set();
|
|
54773
54901
|
for (const directory2 of (system.env.PATH ?? "").split(delimiter3).filter(isAbsolute10)) {
|
|
54774
|
-
const candidate =
|
|
54902
|
+
const candidate = join24(directory2, client);
|
|
54775
54903
|
if (await programProblem(candidate, configDir) !== null) continue;
|
|
54776
54904
|
const real = await realpath14(candidate).catch(() => candidate);
|
|
54777
54905
|
if (seen.has(real)) continue;
|
|
@@ -54783,8 +54911,8 @@ async function clientsOnPath(system, client, configDir) {
|
|
|
54783
54911
|
async function checkWrappers(system, configDir, compare) {
|
|
54784
54912
|
const out = [];
|
|
54785
54913
|
for (const client of WRAPPER_CLIENTS) {
|
|
54786
|
-
const path =
|
|
54787
|
-
const content3 = await
|
|
54914
|
+
const path = join24(wrapperDir(configDir), `fleek-${client}`);
|
|
54915
|
+
const content3 = await readFile19(path, "utf8").catch(() => null);
|
|
54788
54916
|
if (content3 === null) continue;
|
|
54789
54917
|
const program = wrapperProgram(content3);
|
|
54790
54918
|
const problem = program ? await programProblem(program, configDir) : "missing";
|
|
@@ -54966,19 +55094,19 @@ async function fleekStart(deps, key, values) {
|
|
|
54966
55094
|
}
|
|
54967
55095
|
|
|
54968
55096
|
// src/link-handler.ts
|
|
54969
|
-
import { access as access5, mkdir as
|
|
55097
|
+
import { access as access5, mkdir as mkdir8, readFile as readFile20, rm as rm9, stat as stat14, writeFile as writeFile3 } from "node:fs/promises";
|
|
54970
55098
|
import { constants as constants2 } from "node:fs";
|
|
54971
|
-
import { delimiter as delimiter4, dirname as dirname18, join as
|
|
55099
|
+
import { delimiter as delimiter4, dirname as dirname18, join as join25 } from "node:path";
|
|
54972
55100
|
var LSREGISTER = "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";
|
|
54973
55101
|
var BUNDLE_ID = "app.onfleek.fleek-link";
|
|
54974
55102
|
var DESKTOP = "fleek-link.desktop";
|
|
54975
55103
|
var quote4 = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
54976
55104
|
var failed = (step) => new CliError("errors.linkHandler", EXIT.failed, { step }, "LINK_HANDLER_FAILED");
|
|
54977
|
-
var launcherPath = (configDir) =>
|
|
54978
|
-
var appPath = (configDir) =>
|
|
55105
|
+
var launcherPath = (configDir) => join25(configDir, "bin", "fleek-link");
|
|
55106
|
+
var appPath = (configDir) => join25(configDir, "link", "Fleek Link.app");
|
|
54979
55107
|
var desktopPath = (system) => {
|
|
54980
55108
|
const xdg = system.env.XDG_DATA_HOME;
|
|
54981
|
-
return
|
|
55109
|
+
return join25(xdg && xdg.startsWith("/") ? xdg : join25(system.home, ".local", "share"), "applications", DESKTOP);
|
|
54982
55110
|
};
|
|
54983
55111
|
function launcherContent(fleek, pathDirs, env, configDir) {
|
|
54984
55112
|
const dirs = [.../* @__PURE__ */ new Set([...pathDirs, "/usr/bin", "/bin", "/usr/sbin", "/sbin"])].filter((dir) => dir.startsWith("/") && !dir.includes(delimiter4));
|
|
@@ -55034,15 +55162,15 @@ async function installLinkHandler(system, fleek) {
|
|
|
55034
55162
|
const launcher = launcherPath(system.configDir);
|
|
55035
55163
|
const orca2 = await system.which("orca-ide") ?? await system.which("orca");
|
|
55036
55164
|
const pathDirs = [dirname18(fleek), dirname18(process.execPath), ...orca2 ? [dirname18(orca2)] : []];
|
|
55037
|
-
await
|
|
55165
|
+
await mkdir8(dirname18(launcher), { recursive: true, mode: 448 });
|
|
55038
55166
|
await writeFile3(launcher, launcherContent(fleek, pathDirs, system.env, system.configDir), { mode: 493 });
|
|
55039
55167
|
if (system.platform === "darwin") {
|
|
55040
55168
|
const app = appPath(system.configDir);
|
|
55041
|
-
const source =
|
|
55042
|
-
await
|
|
55169
|
+
const source = join25(dirname18(app), "fleek-link.applescript");
|
|
55170
|
+
await mkdir8(dirname18(app), { recursive: true, mode: 448 });
|
|
55043
55171
|
await rm9(app, { recursive: true, force: true });
|
|
55044
55172
|
await writeFile3(source, appleScriptSource(launcher), { mode: 384 });
|
|
55045
|
-
const plist =
|
|
55173
|
+
const plist = join25(app, "Contents", "Info.plist");
|
|
55046
55174
|
await run(system, "osacompile", "/usr/bin/osacompile", ["-o", app, source]);
|
|
55047
55175
|
await run(system, "plist", "/usr/bin/plutil", ["-replace", "CFBundleIdentifier", "-string", BUNDLE_ID, plist]);
|
|
55048
55176
|
await run(system, "plist", "/usr/bin/plutil", ["-replace", "LSUIElement", "-bool", "YES", plist]);
|
|
@@ -55058,11 +55186,11 @@ async function installLinkHandler(system, fleek) {
|
|
|
55058
55186
|
return { platform: system.platform, paths: [launcher, app] };
|
|
55059
55187
|
}
|
|
55060
55188
|
const desktop = desktopPath(system);
|
|
55061
|
-
const before = await
|
|
55189
|
+
const before = await readFile20(desktop, "utf8").catch(() => null);
|
|
55062
55190
|
if (before !== null && !before.includes(launcher)) throw failed("desktop");
|
|
55063
55191
|
const xdgMime = await system.which("xdg-mime");
|
|
55064
55192
|
if (!xdgMime) throw failed("xdg-mime");
|
|
55065
|
-
await
|
|
55193
|
+
await mkdir8(dirname18(desktop), { recursive: true });
|
|
55066
55194
|
await writeFile3(desktop, desktopEntry(launcher), { mode: 420 });
|
|
55067
55195
|
await run(system, "register", xdgMime, ["default", DESKTOP, `x-scheme-handler/${LINK_SCHEME}`]);
|
|
55068
55196
|
return { platform: system.platform, paths: [launcher, desktop] };
|
|
@@ -55077,12 +55205,12 @@ async function removeLinkHandler(system) {
|
|
|
55077
55205
|
if (await exists4(app)) {
|
|
55078
55206
|
await system.exec(LSREGISTER, ["-u", app]).catch(() => null);
|
|
55079
55207
|
await rm9(app, { recursive: true, force: true });
|
|
55080
|
-
await rm9(
|
|
55208
|
+
await rm9(join25(dirname18(app), "fleek-link.applescript"), { force: true });
|
|
55081
55209
|
removed = true;
|
|
55082
55210
|
}
|
|
55083
55211
|
} else {
|
|
55084
55212
|
const desktop = desktopPath(system);
|
|
55085
|
-
if ((await
|
|
55213
|
+
if ((await readFile20(desktop, "utf8").catch(() => "")).includes(launcher)) {
|
|
55086
55214
|
await rm9(desktop, { force: true });
|
|
55087
55215
|
removed = true;
|
|
55088
55216
|
}
|
|
@@ -55096,11 +55224,11 @@ async function removeLinkHandler(system) {
|
|
|
55096
55224
|
async function linkHandlerInstalled(system) {
|
|
55097
55225
|
if (system.platform === "win32") return false;
|
|
55098
55226
|
const launcher = launcherPath(system.configDir);
|
|
55099
|
-
const content3 = await
|
|
55227
|
+
const content3 = await readFile20(launcher, "utf8").catch(() => "");
|
|
55100
55228
|
if (!content3.startsWith("#!/bin/sh\n# Fleek link handler (fleek-orca://) - written by ") || !await access5(launcher, constants2.X_OK).then(() => true, () => false)) return false;
|
|
55101
55229
|
if (system.platform === "darwin") {
|
|
55102
|
-
const plist =
|
|
55103
|
-
if (!await stat14(
|
|
55230
|
+
const plist = join25(appPath(system.configDir), "Contents", "Info.plist");
|
|
55231
|
+
if (!await stat14(join25(appPath(system.configDir), "Contents", "MacOS", "applet")).then((info) => info.isFile(), () => false)) return false;
|
|
55104
55232
|
const result2 = await system.exec("/usr/bin/plutil", ["-extract", "CFBundleURLTypes", "json", "-o", "-", plist]).catch(() => null);
|
|
55105
55233
|
if (result2?.code !== 0) return false;
|
|
55106
55234
|
try {
|
|
@@ -55110,7 +55238,7 @@ async function linkHandlerInstalled(system) {
|
|
|
55110
55238
|
return false;
|
|
55111
55239
|
}
|
|
55112
55240
|
}
|
|
55113
|
-
if (await
|
|
55241
|
+
if (await readFile20(desktopPath(system), "utf8").catch(() => "") !== desktopEntry(launcher)) return false;
|
|
55114
55242
|
const xdgMime = await system.which("xdg-mime");
|
|
55115
55243
|
if (!xdgMime) return false;
|
|
55116
55244
|
const result = await system.exec(xdgMime, ["query", "default", `x-scheme-handler/${LINK_SCHEME}`]).catch(() => null);
|
|
@@ -55272,8 +55400,8 @@ async function visibleProject(client, ref) {
|
|
|
55272
55400
|
// src/kit.ts
|
|
55273
55401
|
import { spawn as spawn7 } from "node:child_process";
|
|
55274
55402
|
import { randomBytes as randomBytes10 } from "node:crypto";
|
|
55275
|
-
import { readFile as
|
|
55276
|
-
import { isAbsolute as isAbsolute11, join as
|
|
55403
|
+
import { readFile as readFile22, realpath as realpath16 } from "node:fs/promises";
|
|
55404
|
+
import { isAbsolute as isAbsolute11, join as join29, resolve as resolve6, sep as sep8 } from "node:path";
|
|
55277
55405
|
var import_types8 = __toESM(require_dist(), 1);
|
|
55278
55406
|
|
|
55279
55407
|
// src/kit-keys.ts
|
|
@@ -55349,15 +55477,15 @@ async function setupLinkHandler(ctx, interactive, confirm2) {
|
|
|
55349
55477
|
|
|
55350
55478
|
// src/kit-setup.ts
|
|
55351
55479
|
import { readdir as readdir12 } from "node:fs/promises";
|
|
55352
|
-
import { join as
|
|
55480
|
+
import { join as join27, resolve as resolve5 } from "node:path";
|
|
55353
55481
|
|
|
55354
55482
|
// src/init-scan.ts
|
|
55355
55483
|
import { spawn as spawn6 } from "node:child_process";
|
|
55356
55484
|
var import_validation2 = __toESM(require_dist2(), 1);
|
|
55357
|
-
import { createHash as
|
|
55485
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
55358
55486
|
import { constants as fsConstants4 } from "node:fs";
|
|
55359
|
-
import { lstat as lstat12, mkdir as
|
|
55360
|
-
import { basename as basename6, dirname as dirname19, join as
|
|
55487
|
+
import { lstat as lstat12, mkdir as mkdir9, open as open5, realpath as realpath15, writeFile as writeFile4 } from "node:fs/promises";
|
|
55488
|
+
import { basename as basename6, dirname as dirname19, join as join26, posix as posix3 } from "node:path";
|
|
55361
55489
|
var INIT_SCAN_LIMITS = Object.freeze({
|
|
55362
55490
|
depth: 4,
|
|
55363
55491
|
candidates: 20,
|
|
@@ -55449,8 +55577,8 @@ async function readJson(root, path) {
|
|
|
55449
55577
|
async function readSmall2(root, path, max) {
|
|
55450
55578
|
try {
|
|
55451
55579
|
if (!(0, import_validation2.evidencePathAllowed)(path)) return null;
|
|
55452
|
-
const realRoot = await realpath15(root), source =
|
|
55453
|
-
if (await realpath15(source) !==
|
|
55580
|
+
const realRoot = await realpath15(root), source = join26(root, path);
|
|
55581
|
+
if (await realpath15(source) !== join26(realRoot, ...path.split("/"))) return null;
|
|
55454
55582
|
const seen = await lstat12(source);
|
|
55455
55583
|
if (!seen.isFile() || seen.nlink !== 1 || seen.size > max) return null;
|
|
55456
55584
|
const handle = await open5(source, fsConstants4.O_RDONLY | (fsConstants4.O_NOFOLLOW ?? 0) | (fsConstants4.O_NONBLOCK ?? 0));
|
|
@@ -55753,7 +55881,7 @@ async function scanFacts(checkout2, app) {
|
|
|
55753
55881
|
...Object.keys(designSources).length ? { designSources } : {},
|
|
55754
55882
|
...environmentNames.length ? { environmentNames } : {}
|
|
55755
55883
|
};
|
|
55756
|
-
const factsHash =
|
|
55884
|
+
const factsHash = createHash9("sha256").update((0, import_validation2.projectInitCanonical)(base)).digest("hex");
|
|
55757
55885
|
return { facts: { ...base, factsHash }, components };
|
|
55758
55886
|
}
|
|
55759
55887
|
var ENV_EXAMPLE = /^\.env\.(?:example|sample|template)$/;
|
|
@@ -55834,9 +55962,9 @@ function environmentKeys(text6) {
|
|
|
55834
55962
|
}
|
|
55835
55963
|
async function stageApplication(checkout2, app, dir) {
|
|
55836
55964
|
const prefix = app.path ? `${app.path}/` : "";
|
|
55837
|
-
const target =
|
|
55838
|
-
await
|
|
55839
|
-
const hash =
|
|
55965
|
+
const target = join26(dir, "files");
|
|
55966
|
+
await mkdir9(target, { recursive: true, mode: 448 });
|
|
55967
|
+
const hash = createHash9("sha256");
|
|
55840
55968
|
const files = [];
|
|
55841
55969
|
let skipped = 0, total = 0, patternFiles = 0, patternBytes = 0;
|
|
55842
55970
|
const root = await realpath15(checkout2.root);
|
|
@@ -55847,14 +55975,14 @@ async function stageApplication(checkout2, app, dir) {
|
|
|
55847
55975
|
skipped++;
|
|
55848
55976
|
continue;
|
|
55849
55977
|
}
|
|
55850
|
-
const source =
|
|
55978
|
+
const source = join26(checkout2.root, file);
|
|
55851
55979
|
const own4 = file.startsWith(prefix);
|
|
55852
55980
|
const inputPath = own4 ? file.slice(prefix.length) : `_root/${file}`;
|
|
55853
55981
|
const envExample = ENV_EXAMPLE.test(posix3.basename(file));
|
|
55854
55982
|
const relative3 = envExample ? `env-keys/${inputPath}.txt` : inputPath;
|
|
55855
55983
|
try {
|
|
55856
55984
|
const resolved = await realpath15(source);
|
|
55857
|
-
if (resolved !==
|
|
55985
|
+
if (resolved !== join26(root, ...file.split("/"))) {
|
|
55858
55986
|
skipped++;
|
|
55859
55987
|
continue;
|
|
55860
55988
|
}
|
|
@@ -55881,8 +56009,8 @@ async function stageApplication(checkout2, app, dir) {
|
|
|
55881
56009
|
skipped++;
|
|
55882
56010
|
continue;
|
|
55883
56011
|
}
|
|
55884
|
-
const destination =
|
|
55885
|
-
await
|
|
56012
|
+
const destination = join26(target, ...relative3.split("/"));
|
|
56013
|
+
await mkdir9(dirname19(destination), { recursive: true, mode: 448 });
|
|
55886
56014
|
await writeFile4(destination, bytes, { mode: 256, flag: "wx" });
|
|
55887
56015
|
total += sourceBytes;
|
|
55888
56016
|
if (isPattern(file)) {
|
|
@@ -55890,7 +56018,7 @@ async function stageApplication(checkout2, app, dir) {
|
|
|
55890
56018
|
patternBytes += sourceBytes;
|
|
55891
56019
|
}
|
|
55892
56020
|
files.push(relative3);
|
|
55893
|
-
hash.update(relative3).update("\0").update(
|
|
56021
|
+
hash.update(relative3).update("\0").update(createHash9("sha256").update(bytes).digest("hex")).update("\n");
|
|
55894
56022
|
} catch {
|
|
55895
56023
|
skipped++;
|
|
55896
56024
|
}
|
|
@@ -56594,7 +56722,7 @@ function printResult(ctx, input) {
|
|
|
56594
56722
|
].join(s.dim(" · "))]);
|
|
56595
56723
|
}
|
|
56596
56724
|
const backups = [...new Set(applied.map((item2) => item2.backup).filter((path) => !!path))];
|
|
56597
|
-
if (backups.length) labels.push([ctx.t("setup.backups"), neutralizeLine(tilde(
|
|
56725
|
+
if (backups.length) labels.push([ctx.t("setup.backups"), neutralizeLine(tilde(join27(backups[0], ".."), systemOf(ctx).home))]);
|
|
56598
56726
|
if (open8) labels.push([ctx.t("setup.openLabel"), mode === "pull" ? `${open8} - ${s.cmd("fleek kit setup")}` : String(open8)]);
|
|
56599
56727
|
lines.push(...s.labels(labels, ""));
|
|
56600
56728
|
for (const row of applied.filter((item2) => item2.ok)) {
|
|
@@ -56620,9 +56748,28 @@ function fleekState(ctx, row) {
|
|
|
56620
56748
|
if (row.state === "other") return s.state("muted", ctx.t("setup.fleek.other"));
|
|
56621
56749
|
return s.state("error", ctx.t("setup.reason.config"));
|
|
56622
56750
|
}
|
|
56623
|
-
|
|
56624
|
-
const system = systemOf(ctx);
|
|
56751
|
+
function fleekWarnings(ctx, step) {
|
|
56625
56752
|
const s = ctx.out.style;
|
|
56753
|
+
return [
|
|
56754
|
+
...step.rows.filter((entry) => entry.aliases.length).map((row) => ({
|
|
56755
|
+
key: digest(["alias", row.target.file, ...row.aliases]),
|
|
56756
|
+
line: s.warn(ctx.t("setup.fleek.aliases", { client: fleekLabel(row), names: row.aliases.map(neutralizeLine).join(", ") }))
|
|
56757
|
+
})),
|
|
56758
|
+
...step.shadows.map((shadow) => ({
|
|
56759
|
+
key: digest(["shadow", shadow.client, shadow.scope, shadow.file]),
|
|
56760
|
+
line: s.warn(ctx.t("setup.fleek.shadowed", { client: LABEL4[shadow.client], file: neutralizeLine(shadow.file) }))
|
|
56761
|
+
}))
|
|
56762
|
+
];
|
|
56763
|
+
}
|
|
56764
|
+
function printWarnings(ctx, step, known) {
|
|
56765
|
+
const warnings = fleekWarnings(ctx, step);
|
|
56766
|
+
const fresh = known ? warnings.filter((item2) => !known.warnings.has(item2.key)) : warnings;
|
|
56767
|
+
for (const item2 of fresh) ctx.out.line(` ${item2.line}`);
|
|
56768
|
+
const hidden = warnings.length - fresh.length;
|
|
56769
|
+
if (hidden) ctx.out.line(` ${ctx.out.style.note(ctx.t(hidden === 1 ? "setup.hint" : "setup.hints", { count: hidden, command: ctx.out.style.cmd("fleek doctor") }))}`);
|
|
56770
|
+
}
|
|
56771
|
+
async function inspectFleekStep(ctx, report, probe) {
|
|
56772
|
+
const system = systemOf(ctx);
|
|
56626
56773
|
const binaries = { claude: report.clients.find((client) => client.id === "claude")?.binary ?? null, fleek: await system.which("fleek") };
|
|
56627
56774
|
const configDir = ctx.env.FLEEK_CONFIG_DIR ? resolve5(ctx.configDir) : null;
|
|
56628
56775
|
const bindings = /* @__PURE__ */ new Map();
|
|
@@ -56636,7 +56783,7 @@ async function fleekStep(ctx, report, interactive, options = {}) {
|
|
|
56636
56783
|
const userLevel = await Promise.all(rows.filter((row) => row.target.writable).map(async (row) => [row.target.client, await readProxyEntry(row.target).catch(() => null)]));
|
|
56637
56784
|
const effective = async (row) => await readProxyEntry(row.target).catch(() => null) ?? (row.target.writable ? null : userLevel.find(([client]) => client === row.target.client)?.[1] ?? null);
|
|
56638
56785
|
const handshakes = /* @__PURE__ */ new Map();
|
|
56639
|
-
if (
|
|
56786
|
+
if (probe) {
|
|
56640
56787
|
const cache2 = /* @__PURE__ */ new Map();
|
|
56641
56788
|
for (const row of rows) {
|
|
56642
56789
|
const entry = await effective(row);
|
|
@@ -56655,7 +56802,17 @@ async function fleekStep(ctx, report, interactive, options = {}) {
|
|
|
56655
56802
|
if (file.scope !== "user" && file.entries.some((entry) => entry.name === "fleek")) shadows.push({ client, scope: file.scope, file: file.path });
|
|
56656
56803
|
}
|
|
56657
56804
|
}
|
|
56658
|
-
const step = { rows, applied, orca: { present, wrappers, ...present ? { startCommands: await inspectOrcaStartCommands(system, ctx.configDir) } : {} }, handshakes, shadows };
|
|
56805
|
+
const step = { rows, applied, orca: { present, wrappers, ...present ? { startCommands: await inspectOrcaStartCommands(system, ctx.configDir) } : {} }, handshakes, shadows, answered: {} };
|
|
56806
|
+
return { step, binaries, bindings };
|
|
56807
|
+
}
|
|
56808
|
+
async function fleekStep(ctx, report, interactive, options = {}) {
|
|
56809
|
+
const system = systemOf(ctx);
|
|
56810
|
+
const s = ctx.out.style;
|
|
56811
|
+
const { step, binaries, bindings } = options.inspected ?? await inspectFleekStep(ctx, report, options.probe === true);
|
|
56812
|
+
const { rows, applied, handshakes } = step;
|
|
56813
|
+
const { present } = step.orca;
|
|
56814
|
+
const wrappers = step.orca.wrappers;
|
|
56815
|
+
const known = options.known ?? null;
|
|
56659
56816
|
if (!rows.length || ctx.json) return step;
|
|
56660
56817
|
ctx.out.line();
|
|
56661
56818
|
ctx.out.line(s.bold(ctx.t("setup.fleek.title")));
|
|
@@ -56669,8 +56826,7 @@ async function fleekStep(ctx, report, interactive, options = {}) {
|
|
|
56669
56826
|
`${fleekState(ctx, row)}${handshakeText(row)}`,
|
|
56670
56827
|
row.state === "proxy" || row.manual === "orca_merge" ? s.dim("-") : row.manual ? s.dim(ctx.t("setup.action.manual", { reason: reasonText(ctx, row.manual) })) : s.cmd(ctx.t("setup.fleek.switch"))
|
|
56671
56828
|
]))) ctx.out.line(line);
|
|
56672
|
-
|
|
56673
|
-
for (const shadow of shadows) ctx.out.line(` ${s.warn(ctx.t("setup.fleek.shadowed", { client: LABEL4[shadow.client], file: neutralizeLine(shadow.file) }))}`);
|
|
56829
|
+
printWarnings(ctx, step, known);
|
|
56674
56830
|
const printWrappers = () => {
|
|
56675
56831
|
if (!present) return;
|
|
56676
56832
|
ctx.out.line();
|
|
@@ -56728,11 +56884,12 @@ async function fleekStep(ctx, report, interactive, options = {}) {
|
|
|
56728
56884
|
}
|
|
56729
56885
|
}
|
|
56730
56886
|
printWrappers();
|
|
56731
|
-
for (const wrapper of wrappers.filter((row) => row.state === "current" && step.orca.startCommands?.clients[row.client] !== true)) {
|
|
56887
|
+
for (const wrapper of wrappers.filter((row) => row.state === "current" && step.orca.startCommands?.clients[row.client] !== true && known?.startCommands?.[row.client] !== row.path)) {
|
|
56732
56888
|
if (await ask2([ctx.t("setup.orca.copy", { client: LABEL4[wrapper.client] })]) !== "no") {
|
|
56733
56889
|
const copied = await copyStartCommand(system, wrapper);
|
|
56734
56890
|
ctx.out.line(ctx.t(copied ? "setup.orca.copied" : "setup.orca.copyFailed", { client: LABEL4[wrapper.client] }));
|
|
56735
56891
|
}
|
|
56892
|
+
step.answered[wrapper.client] = wrapper.path;
|
|
56736
56893
|
}
|
|
56737
56894
|
return step;
|
|
56738
56895
|
}
|
|
@@ -56762,16 +56919,48 @@ var orcaJson = (step) => ({
|
|
|
56762
56919
|
startCommands: step.orca.startCommands ?? null,
|
|
56763
56920
|
wrappers: step.orca.wrappers.map((wrapper) => ({ client: wrapper.client, path: wrapper.path, state: wrapper.state, program: wrapper.program }))
|
|
56764
56921
|
});
|
|
56922
|
+
function stepLines(report, step) {
|
|
56923
|
+
return [
|
|
56924
|
+
`orca ${step.orca.present}`,
|
|
56925
|
+
...report.clients.map((client) => `client ${client.id}`),
|
|
56926
|
+
...report.rows.map((row) => row.required ? `kit ${row.server} ${row.client} ${row.status === "missing" ? "missing" : "present"}` : `proposal ${row.server} ${row.client} ${row.action ?? "-"} ${row.configured?.scope ?? "-"}`),
|
|
56927
|
+
...step.rows.map((row) => `fleek ${row.target.client} ${row.target.file} ${row.state} ${row.manual ?? "-"}`),
|
|
56928
|
+
...step.orca.wrappers.map((wrapper) => `wrapper ${wrapper.client} ${wrapper.path} ${wrapper.state}`)
|
|
56929
|
+
];
|
|
56930
|
+
}
|
|
56765
56931
|
async function provisionAfterPull(ctx, pulled, options) {
|
|
56766
56932
|
const domain = new KitDomain(ctx.configDir, pulled.profile.key, pulled.projectId);
|
|
56767
56933
|
const gen = await domain.current();
|
|
56768
56934
|
const terminal = isTty(ctx) && !ctx.json && !options.yes;
|
|
56769
56935
|
const report = await inspect(ctx, { gen, projectId: pulled.projectId, session: pulled.session, checkout: pulled.checkout, pulled: true, probe: options.probe === true });
|
|
56770
56936
|
if (!options.setup && report.clients.length === 0) return { exit: EXIT.ok, report: null };
|
|
56937
|
+
const state = options.setup && !ctx.json ? options.state ?? null : null;
|
|
56938
|
+
const key = `${pulled.profile.key}/${pulled.projectId}`;
|
|
56939
|
+
const clients = report.clients.map((client) => client.id).sort().join(",");
|
|
56940
|
+
const marker2 = state && !state.all ? state.marker : null;
|
|
56941
|
+
const known = marker2 ? { warnings: new Set(marker2.warnings), startCommands: marker2.startClients === clients ? marker2.startCommands : null } : null;
|
|
56942
|
+
const inspected = state ? await inspectFleekStep(ctx, report, options.probe === true) : void 0;
|
|
56943
|
+
if (state && inspected) {
|
|
56944
|
+
const step = inspected.step;
|
|
56945
|
+
const lines = stepLines(report, step);
|
|
56946
|
+
const pluginRows = await inspectPlugins(systemOf(ctx), report.clients, await generationPlugins(domain, gen)).catch(() => null);
|
|
56947
|
+
const startsKnown = step.orca.wrappers.every((wrapper) => wrapper.state !== "current" || step.orca.startCommands?.clients[wrapper.client] === true || known?.startCommands?.[wrapper.client] === wrapper.path);
|
|
56948
|
+
const warnings = fleekWarnings(ctx, step).map((item2) => item2.key);
|
|
56949
|
+
if (marker2 && !state.embedded && marker2.steps[key] === digest([...lines, ...state.extra]) && startsKnown && pulled.clean !== false && exitOf(report) === EXIT.ok && fleekReady(step) && pluginRows !== null && !pluginActionNeeded(pluginRows)) {
|
|
56950
|
+
ctx.out.line();
|
|
56951
|
+
ctx.out.line(ctx.out.style.ok(ctx.t("setup.unchanged")));
|
|
56952
|
+
printWarnings(ctx, step, known);
|
|
56953
|
+
return {
|
|
56954
|
+
exit: EXIT.ok,
|
|
56955
|
+
report: { ...reportJson(report), applied: [], fleek: fleekJson(step), fleekApplied: [], orca: orcaJson(step), plugins: pluginJson(pluginRows), pluginsApplied: [] },
|
|
56956
|
+
setup: { quiet: true, key, clients, lines, answered: {}, warnings }
|
|
56957
|
+
};
|
|
56958
|
+
}
|
|
56959
|
+
}
|
|
56771
56960
|
if (!ctx.json) printReport(ctx, report, options.setup ? gen : null, systemOf(ctx).home, options.setup);
|
|
56772
56961
|
const proposals = report.rows.some((row) => row.action === "install" || row.action === "update");
|
|
56773
56962
|
const interactive = terminal && (options.setup || proposals && await chooser(ctx)([ctx.t("setup.askSetupNow")]) !== "no");
|
|
56774
|
-
const fleek = options.setup || interactive ? await fleekStep(ctx, report, interactive, { probe: options.probe === true }) : { rows: [], applied: [], orca: { present: false, wrappers: [] }, handshakes: /* @__PURE__ */ new Map(), shadows: [] };
|
|
56963
|
+
const fleek = options.setup || interactive ? await fleekStep(ctx, report, interactive, { probe: options.probe === true, ...inspected ? { inspected, known } : {} }) : { rows: [], applied: [], orca: { present: false, wrappers: [] }, handshakes: /* @__PURE__ */ new Map(), shadows: [] };
|
|
56775
56964
|
const { applied, skipped } = interactive ? await applyRows(ctx, report, pulled.checkout) : { applied: [], skipped: 0 };
|
|
56776
56965
|
const plugins = options.setup ? await pluginStep(ctx, systemOf(ctx), report.clients, await generationPlugins(domain, gen), interactive, chooser(ctx), { auto: options.servicePlugins !== void 0 && options.servicePlugins === pulled.profile.key }) : { rows: [], failed: 0, applied: [] };
|
|
56777
56966
|
const pluginsOpen = plugins.failed > 0 || pluginActionNeeded(plugins.rows);
|
|
@@ -56800,7 +56989,25 @@ async function provisionAfterPull(ctx, pulled, options) {
|
|
|
56800
56989
|
});
|
|
56801
56990
|
}
|
|
56802
56991
|
const exit2 = exitOf(after) === EXIT.ok && (!fleekReady(fleek) || pluginsOpen) ? PROVISION_ACTION_NEEDED : exitOf(after);
|
|
56803
|
-
|
|
56992
|
+
const setup = state ? {
|
|
56993
|
+
quiet: false,
|
|
56994
|
+
key,
|
|
56995
|
+
clients,
|
|
56996
|
+
lines: stepLines(after, (await inspectFleekStep(ctx, after, false)).step),
|
|
56997
|
+
answered: fleek.answered ?? {},
|
|
56998
|
+
warnings: fleekWarnings(ctx, fleek).map((item2) => item2.key)
|
|
56999
|
+
} : void 0;
|
|
57000
|
+
return {
|
|
57001
|
+
exit: exit2,
|
|
57002
|
+
report: { ...reportJson(after), applied, fleek: fleekJson(fleek), fleekApplied: fleek.applied, orca: orcaJson(fleek), plugins: pluginJson(plugins.rows), pluginsApplied: plugins.applied },
|
|
57003
|
+
...setup ? { setup } : {}
|
|
57004
|
+
};
|
|
57005
|
+
}
|
|
57006
|
+
function setupExtraLines(skills, handler) {
|
|
57007
|
+
return [
|
|
57008
|
+
...skills.map((row) => `skill ${row.client} ${row.name} ${row.state !== "outdated" ? row.state : shippedOutdated(row) ? "current" : `modified ${skillHash(row.before ?? "")}`}`),
|
|
57009
|
+
...handler ? [`handler ${handler.state}`] : []
|
|
57010
|
+
];
|
|
56804
57011
|
}
|
|
56805
57012
|
function afterPull(ctx, values) {
|
|
56806
57013
|
return async (pulled) => {
|
|
@@ -56822,13 +57029,23 @@ function capturing(ctx) {
|
|
|
56822
57029
|
return { ctx: { ...ctx, out }, value: () => value };
|
|
56823
57030
|
}
|
|
56824
57031
|
async function kitSetup(ctx, projectRef, values, pull) {
|
|
56825
|
-
const
|
|
57032
|
+
const system = systemOf(ctx);
|
|
57033
|
+
const detected = await detectClients(system);
|
|
56826
57034
|
const defaultTargets = detected.map((client) => client.id).filter((id) => id === "claude" || id === "codex");
|
|
56827
57035
|
const captured = ctx.json ? capturing(ctx) : null;
|
|
56828
57036
|
const project = projectRef ?? values.project;
|
|
56829
57037
|
let provision = EXIT.ok;
|
|
56830
57038
|
let report = null;
|
|
56831
57039
|
embedded = values.embedded === true;
|
|
57040
|
+
const interactive = isTty(ctx) && values.yes !== true && !ctx.json;
|
|
57041
|
+
const marker2 = ctx.json ? null : await readSetupMarker(ctx.configDir);
|
|
57042
|
+
const all = values.all === true;
|
|
57043
|
+
const orcaHere = !ctx.json && await orcaPresent(system);
|
|
57044
|
+
const skills = orcaHere ? await inspectUserSkills(system.home) : [];
|
|
57045
|
+
const handlerBefore = ctx.json || embedded ? null : await inspectSetupHandler(ctx);
|
|
57046
|
+
const shipped = interactive ? skills.filter(shippedOutdated) : [];
|
|
57047
|
+
let outcome;
|
|
57048
|
+
let shippedFailures = 0;
|
|
56832
57049
|
try {
|
|
56833
57050
|
if (!ctx.json) {
|
|
56834
57051
|
if (!embedded) {
|
|
@@ -56842,20 +57059,35 @@ async function kitSetup(ctx, projectRef, values, pull) {
|
|
|
56842
57059
|
...defaultTargets.length ? { defaultTargets } : {},
|
|
56843
57060
|
// the next step of setup comes once, in its result
|
|
56844
57061
|
nextStep: false,
|
|
57062
|
+
...shipped.length ? { extraChanges: shippedUpdateLines(shipped) } : {},
|
|
56845
57063
|
after: async (pulled) => {
|
|
56846
|
-
(
|
|
57064
|
+
if (shipped.length) shippedFailures = await updateShippedSkills(ctx, system, shipped, pulled.confirmed ? null : chooser(ctx));
|
|
57065
|
+
({ exit: provision, report, setup: outcome } = await provisionAfterPull(captured?.ctx ?? ctx, pulled, {
|
|
56847
57066
|
setup: true,
|
|
56848
57067
|
yes: values.yes === true,
|
|
56849
57068
|
probe: values.probe === true,
|
|
56850
57069
|
...values.servicePlugins ? { servicePlugins: values.servicePlugins } : {},
|
|
56851
|
-
...project !== void 0 ? { project } : {}
|
|
57070
|
+
...project !== void 0 ? { project } : {},
|
|
57071
|
+
...ctx.json ? {} : { state: { marker: marker2, all, embedded, extra: setupExtraLines(skills, handlerBefore) } }
|
|
56852
57072
|
}));
|
|
56853
57073
|
return EXIT.ok;
|
|
56854
57074
|
}
|
|
56855
57075
|
});
|
|
56856
|
-
const
|
|
56857
|
-
const
|
|
57076
|
+
const quiet = outcome?.quiet === true;
|
|
57077
|
+
const skillFailures = shippedFailures + (quiet ? 0 : await userSkillStep(ctx, system, isTty(ctx) && values.yes !== true, chooser(ctx), { askMissing: marker2 === null || all }));
|
|
57078
|
+
const handler = embedded ? null : quiet && handlerBefore ? { ...handlerBefore, status: handlerBefore.state === "installed" ? "ok" : "skipped" } : await setupLinkHandler(ctx, isTty(ctx) && values.yes !== true, async (lines) => await chooser(ctx)(lines) === "yes");
|
|
56858
57079
|
const exit2 = code !== EXIT.ok ? code : handler?.status === "failed" ? EXIT.failed : provision !== EXIT.ok ? provision : skillFailures ? EXIT.failed : EXIT.ok;
|
|
57080
|
+
if (interactive && outcome) {
|
|
57081
|
+
const extra = setupExtraLines(orcaHere ? await inspectUserSkills(system.home) : [], embedded ? null : await inspectSetupHandler(ctx));
|
|
57082
|
+
const starts = marker2 && marker2.startClients === outcome.clients ? marker2.startCommands : {};
|
|
57083
|
+
await writeSetupMarker(ctx.configDir, {
|
|
57084
|
+
v: 1,
|
|
57085
|
+
steps: { ...marker2?.steps, [outcome.key]: digest([...outcome.lines, ...extra]) },
|
|
57086
|
+
startCommands: { ...starts, ...outcome.answered },
|
|
57087
|
+
startClients: outcome.clients,
|
|
57088
|
+
warnings: [.../* @__PURE__ */ new Set([...marker2?.warnings ?? [], ...outcome.warnings])].slice(-256)
|
|
57089
|
+
});
|
|
57090
|
+
}
|
|
56859
57091
|
if (ctx.json) ctx.out.json({ pull: captured.value(), provisioning: report, handler, exit: exit2 });
|
|
56860
57092
|
return exit2;
|
|
56861
57093
|
} finally {
|
|
@@ -56880,7 +57112,7 @@ async function doctorProject(ctx, profile, value, checkout2) {
|
|
|
56880
57112
|
}
|
|
56881
57113
|
async function orphanBinding(configDir, checkout2) {
|
|
56882
57114
|
const known = new Set((await new ProfileStore(configDir).list().catch(() => [])).map((profile) => profile.key));
|
|
56883
|
-
const names2 = await readdir12(
|
|
57115
|
+
const names2 = await readdir12(join27(configDir, "kits"), { withFileTypes: true }).catch(() => []);
|
|
56884
57116
|
for (const entry of names2) {
|
|
56885
57117
|
if (!entry.isDirectory() || !/^[0-9a-f]{32}$/.test(entry.name) || known.has(entry.name)) continue;
|
|
56886
57118
|
const projectId = await new CheckoutIndex(configDir, entry.name).get(checkout2).catch(() => null);
|
|
@@ -57022,21 +57254,21 @@ async function kitDoctor(ctx, values) {
|
|
|
57022
57254
|
}
|
|
57023
57255
|
|
|
57024
57256
|
// src/kit-proxy-launch.ts
|
|
57025
|
-
import { mkdir as
|
|
57026
|
-
import { dirname as dirname20, join as
|
|
57257
|
+
import { mkdir as mkdir10, mkdtemp, readFile as readFile21, rm as rm10, writeFile as writeFile5 } from "node:fs/promises";
|
|
57258
|
+
import { dirname as dirname20, join as join28 } from "node:path";
|
|
57027
57259
|
async function proxyLaunchPlugin(input) {
|
|
57028
57260
|
const unchanged = { pluginDir: input.pluginDir, cleanup: async () => {
|
|
57029
57261
|
} };
|
|
57030
57262
|
if (!input.files.includes("plugin/.mcp.json")) return unchanged;
|
|
57031
57263
|
let config;
|
|
57032
57264
|
try {
|
|
57033
|
-
config = JSON.parse(await
|
|
57265
|
+
config = JSON.parse(await readFile21(join28(input.pluginDir, ".mcp.json"), "utf8"));
|
|
57034
57266
|
} catch {
|
|
57035
57267
|
throw new CliError("errors.kitStateCorrupt", EXIT.failed, { path: input.pluginDir }, "KIT_STATE_CORRUPT");
|
|
57036
57268
|
}
|
|
57037
57269
|
if (!config?.mcpServers || !Object.hasOwn(config.mcpServers, "fleek")) return unchanged;
|
|
57038
|
-
const root = await mkdtemp(
|
|
57039
|
-
const pluginDir =
|
|
57270
|
+
const root = await mkdtemp(join28(input.configDir, "kit-run-"));
|
|
57271
|
+
const pluginDir = join28(root, "plugin");
|
|
57040
57272
|
const cleanup = async () => {
|
|
57041
57273
|
await rm10(root, { recursive: true, force: true });
|
|
57042
57274
|
};
|
|
@@ -57046,9 +57278,9 @@ async function proxyLaunchPlugin(input) {
|
|
|
57046
57278
|
if (!relative3 || relative3.split("/").some((part) => !part || part === ".." || part === ".") || relative3.includes("\\")) {
|
|
57047
57279
|
throw new CliError("errors.kitStateCorrupt", EXIT.failed, { path: input.pluginDir }, "KIT_STATE_CORRUPT");
|
|
57048
57280
|
}
|
|
57049
|
-
const destination =
|
|
57050
|
-
await
|
|
57051
|
-
const bytes = relative3 === ".mcp.json" ? JSON.stringify({ ...config, mcpServers: { ...config.mcpServers, fleek: { type: "stdio", command: input.proxy.command, args: [...input.proxy.args], ...input.proxy.env ? { env: input.proxy.env } : {} } } }, null, 2) + "\n" : await
|
|
57281
|
+
const destination = join28(pluginDir, relative3);
|
|
57282
|
+
await mkdir10(dirname20(destination), { recursive: true, mode: 448 });
|
|
57283
|
+
const bytes = relative3 === ".mcp.json" ? JSON.stringify({ ...config, mcpServers: { ...config.mcpServers, fleek: { type: "stdio", command: input.proxy.command, args: [...input.proxy.args], ...input.proxy.env ? { env: input.proxy.env } : {} } } }, null, 2) + "\n" : await readFile21(join28(input.pluginDir, relative3));
|
|
57052
57284
|
await writeFile5(destination, bytes, { flag: "wx", mode: 384 });
|
|
57053
57285
|
}
|
|
57054
57286
|
return { pluginDir, cleanup };
|
|
@@ -57194,7 +57426,7 @@ async function globalE1(home, target) {
|
|
|
57194
57426
|
const spec = KIT_CAPABILITIES[target].globalE1;
|
|
57195
57427
|
if (!spec) return false;
|
|
57196
57428
|
try {
|
|
57197
|
-
const text6 = await
|
|
57429
|
+
const text6 = await readFile22(join29(home, spec.path), "utf8");
|
|
57198
57430
|
return spec.contains ? text6.includes(spec.contains) : true;
|
|
57199
57431
|
} catch {
|
|
57200
57432
|
return false;
|
|
@@ -57212,7 +57444,7 @@ async function composeAll(kits, targets, checkout2, home, domain) {
|
|
|
57212
57444
|
checkout: checkout2,
|
|
57213
57445
|
globalE1: await globalE1(home, target),
|
|
57214
57446
|
domainHash: domain.hash,
|
|
57215
|
-
pluginDir:
|
|
57447
|
+
pluginDir: join29(domain.dir, "gen-000000000000000000000000", "bundle", target, "plugin")
|
|
57216
57448
|
});
|
|
57217
57449
|
for (const [rel, content3] of composition.privateFiles) files.set(`bundle/${target}/${rel}`, content3);
|
|
57218
57450
|
states[target] = composition.state;
|
|
@@ -57501,7 +57733,7 @@ async function writeComposition(input) {
|
|
|
57501
57733
|
}
|
|
57502
57734
|
const journal = Object.keys(pending).length > 0 || canonicalJson(carry) !== canonicalJson(current2?.state.undecided ?? {});
|
|
57503
57735
|
if (!summary.changed && !journal) return { summary, skippedRoots, listedMcp };
|
|
57504
|
-
const confirmed = summary.changed && !input.unattendedRemoval ? await confirm(ctx, summary, input.yes, input.acceptApproved === true) : false;
|
|
57736
|
+
const confirmed = summary.changed && !input.unattendedRemoval ? await confirm(ctx, input.extraChanges?.length ? { ...summary, lines: [...summary.lines, ...input.extraChanges] } : summary, input.yes, input.acceptApproved === true) : false;
|
|
57505
57737
|
await assertPrivateLocation(ctx.configDir, domain.dir, ctx.env);
|
|
57506
57738
|
if (plans.length) await domain.writePending(journalUnion(pending, Object.fromEntries(plans.map((plan) => [plan.root, plan.entries]))));
|
|
57507
57739
|
await ctx.deps.kitFault?.("journal-written");
|
|
@@ -57668,6 +57900,7 @@ async function kitPull(ctx, projectRef, values, options = {}) {
|
|
|
57668
57900
|
const checkoutRoot = values.acceptApproved ? null : values.checkout !== void 0 ? await resolveCheckout(resolve6(ctx.deps.cwd ?? process.cwd(), values.checkout), ctx.env).then((root) => root ?? Promise.reject(new CliError("errors.kitNoCheckout", EXIT.usage, {}, "USAGE"))) : await resolveCheckout(ctx.deps.cwd ?? process.cwd(), ctx.env).catch(() => null);
|
|
57669
57901
|
const trust = trustFor(ctx.deps.kitTrust ?? PINNED_KIT_TRUST, profile.issuer);
|
|
57670
57902
|
let here = null;
|
|
57903
|
+
let changesConfirmed = false;
|
|
57671
57904
|
const code = await withProfileLock(ctx.configDir, `kit-${domain.hash}`, async () => {
|
|
57672
57905
|
const current2 = await domain.current();
|
|
57673
57906
|
const targets = targetsArg(values.target) ?? (current2 ? Object.keys(current2.state.targets) : null) ?? (options.defaultTargets?.length ? [...options.defaultTargets] : null) ?? ["claude"];
|
|
@@ -57772,8 +58005,10 @@ async function kitPull(ctx, projectRef, values, options = {}) {
|
|
|
57772
58005
|
yes: values.yes === true,
|
|
57773
58006
|
acceptApproved: values.acceptApproved === true,
|
|
57774
58007
|
removals,
|
|
57775
|
-
withdrawnTuples
|
|
58008
|
+
withdrawnTuples,
|
|
58009
|
+
...options.extraChanges?.length ? { extraChanges: options.extraChanges } : {}
|
|
57776
58010
|
});
|
|
58011
|
+
changesConfirmed = confirmed === true;
|
|
57777
58012
|
await domain.markChecked(ctx.now());
|
|
57778
58013
|
await domain.markPulled(ctx.now());
|
|
57779
58014
|
if (skippedRoots.length) await domain.setCleanupPending(skippedRoots, "merge");
|
|
@@ -57819,7 +58054,7 @@ async function kitPull(ctx, projectRef, values, options = {}) {
|
|
|
57819
58054
|
return skippedRoots.length || former.pending.length ? KIT_EXIT.revokedOrNotEntitled : EXIT.ok;
|
|
57820
58055
|
}, ctx.lock);
|
|
57821
58056
|
if (!options.after) return code;
|
|
57822
|
-
const after = await options.after({ profile, session, projectId, checkout: checkoutRoot ?? here, clean: code === EXIT.ok });
|
|
58057
|
+
const after = await options.after({ profile, session, projectId, checkout: checkoutRoot ?? here, clean: code === EXIT.ok, confirmed: changesConfirmed });
|
|
57823
58058
|
return code !== EXIT.ok ? code : after;
|
|
57824
58059
|
}
|
|
57825
58060
|
var DISPLAY = { current: "current", superseded: "update", revoked: "revoked", not_entitled: "not_entitled", unsigned: "unsigned" };
|
|
@@ -58078,18 +58313,18 @@ async function kitRun(ctx, client, values, userArgs) {
|
|
|
58078
58313
|
if (!gen) throw new CliError("errors.kitNotPulled", EXIT.failed, { project: projectId }, "KIT_NOT_PULLED");
|
|
58079
58314
|
const state = gen.state.targets[target];
|
|
58080
58315
|
if (!state) throw new CliError("errors.kitTargetNotPulled", EXIT.failed, { target }, "KIT_NOT_PULLED");
|
|
58081
|
-
const bundleDir =
|
|
58082
|
-
const readOptional = (rel) => state.files.includes(rel) ?
|
|
58316
|
+
const bundleDir = join29(gen.dir, "bundle", target);
|
|
58317
|
+
const readOptional = (rel) => state.files.includes(rel) ? readFile22(join29(bundleDir, rel), "utf8") : Promise.resolve(null);
|
|
58083
58318
|
const instructions3 = await readOptional("instructions.md");
|
|
58084
58319
|
const mcpRaw = await readOptional("mcp.json");
|
|
58085
58320
|
let bundle = {
|
|
58086
|
-
pluginDir: state.files.includes("plugin/.claude-plugin/plugin.json") ?
|
|
58321
|
+
pluginDir: state.files.includes("plugin/.claude-plugin/plugin.json") ? join29(bundleDir, "plugin") : null,
|
|
58087
58322
|
instructions: instructions3,
|
|
58088
58323
|
mcpServers: mcpRaw ? bundleMcp(mcpRaw, gen.dir) : []
|
|
58089
58324
|
};
|
|
58090
58325
|
let runtime;
|
|
58091
58326
|
try {
|
|
58092
|
-
const pluginMcp = state.files.includes("plugin/.mcp.json") ? JSON.parse(await
|
|
58327
|
+
const pluginMcp = state.files.includes("plugin/.mcp.json") ? JSON.parse(await readFile22(join29(bundleDir, "plugin/.mcp.json"), "utf8")) : null;
|
|
58093
58328
|
const reserved = bundle.mcpServers.some((server) => server.name === FLEEK_SERVER) || !!pluginMcp?.mcpServers && Object.hasOwn(pluginMcp.mcpServers, FLEEK_SERVER);
|
|
58094
58329
|
if (reserved) {
|
|
58095
58330
|
const executable = profile.cliPath ?? await resolveExecutable("fleek", ctx.env);
|
|
@@ -58144,12 +58379,12 @@ async function kitRun(ctx, client, values, userArgs) {
|
|
|
58144
58379
|
}
|
|
58145
58380
|
|
|
58146
58381
|
// src/init.ts
|
|
58147
|
-
import { createHash as
|
|
58382
|
+
import { createHash as createHash10, randomUUID as randomUUID4 } from "node:crypto";
|
|
58148
58383
|
var import_validation3 = __toESM(require_dist2(), 1);
|
|
58149
58384
|
import { constants as fsConstants5 } from "node:fs";
|
|
58150
|
-
import { lstat as lstat13, mkdir as
|
|
58385
|
+
import { lstat as lstat13, mkdir as mkdir11, mkdtemp as mkdtemp2, open as open6, readdir as readdir13, realpath as realpath17, rename as rename4, rm as rm11, writeFile as writeFile6 } from "node:fs/promises";
|
|
58151
58386
|
import { tmpdir } from "node:os";
|
|
58152
|
-
import { dirname as dirname21, join as
|
|
58387
|
+
import { dirname as dirname21, join as join30, relative as relative2, resolve as resolve7, sep as sep9 } from "node:path";
|
|
58153
58388
|
|
|
58154
58389
|
// src/terminal-choice.ts
|
|
58155
58390
|
import { emitKeypressEvents } from "node:readline";
|
|
@@ -58310,7 +58545,7 @@ function projectFactLines(de, facts) {
|
|
|
58310
58545
|
function manualInitCommand(stagingDir, outputDir, prompt) {
|
|
58311
58546
|
if ([stagingDir, outputDir].some((path) => /[\u0000-\u001f\u007f]/.test(path))) throw usage3("errors.initWorkDirUnsafe");
|
|
58312
58547
|
const quote5 = (value) => "'" + value.replace(/'/g, "'\\''") + "'";
|
|
58313
|
-
const outputFile =
|
|
58548
|
+
const outputFile = join30(outputDir, "agent-output.json");
|
|
58314
58549
|
return `( set -C; cd -- ${quote5(stagingDir)} && command claude ${initAgentArgs(prompt).map(quote5).join(" ")} > ${quote5(outputFile + ".tmp")} && mv -- ${quote5(outputFile + ".tmp")} ${quote5(outputFile)} )`;
|
|
58315
58550
|
}
|
|
58316
58551
|
function detectedDesignSources(facts) {
|
|
@@ -58571,9 +58806,9 @@ async function initCommand(ctx, values) {
|
|
|
58571
58806
|
}
|
|
58572
58807
|
if (checkout2.dirty && !ctx.json) ctx.info(s.warn(ctx.t("init.dirty")));
|
|
58573
58808
|
const ownBase = !values["work-dir"];
|
|
58574
|
-
const base = values["work-dir"] ? await ownWorkDir(values["work-dir"], checkout2.root) : await mkdtemp2(
|
|
58809
|
+
const base = values["work-dir"] ? await ownWorkDir(values["work-dir"], checkout2.root) : await mkdtemp2(join30(tmpdir(), "fleek-init-"));
|
|
58575
58810
|
if (!ownBase) await assertPrivateAncestors(dirname21(base));
|
|
58576
|
-
if (!ownBase) await
|
|
58811
|
+
if (!ownBase) await mkdir11(base, { mode: 448 }).catch((error) => {
|
|
58577
58812
|
if (error.code !== "EEXIST") throw usage3("errors.initWorkDirUnsafe");
|
|
58578
58813
|
});
|
|
58579
58814
|
await assertPrivateBase(base);
|
|
@@ -58612,7 +58847,7 @@ async function initCommand(ctx, values) {
|
|
|
58612
58847
|
}
|
|
58613
58848
|
if (values.keep && !unknownOutcome) {
|
|
58614
58849
|
for (const saved of summaries) {
|
|
58615
|
-
const path =
|
|
58850
|
+
const path = join30(saved.dir, "summary.json");
|
|
58616
58851
|
await writeFile6(path, `${JSON.stringify(saved.summary, null, 2)}
|
|
58617
58852
|
`, { mode: 384, flag: "wx" });
|
|
58618
58853
|
retained.add(saved.dir);
|
|
@@ -58676,20 +58911,20 @@ async function ownWorkDir(path, checkoutRoot) {
|
|
|
58676
58911
|
} catch (error) {
|
|
58677
58912
|
if (error instanceof CliError) throw error;
|
|
58678
58913
|
if (error.code !== "ENOENT") throw usage3("errors.initWorkDirNotEmpty");
|
|
58679
|
-
real =
|
|
58914
|
+
real = join30(await realpath17(resolve7(absolute, "..")).catch(() => resolve7(absolute, "..")), absolute.split(sep9).pop() ?? "");
|
|
58680
58915
|
}
|
|
58681
58916
|
const inside = relative2(root, real);
|
|
58682
58917
|
if (inside === "" || !inside.startsWith("..") && !inside.startsWith(sep9) && !/^[A-Za-z]:/.test(inside)) throw usage3("errors.initWorkDirInCheckout");
|
|
58683
58918
|
return absolute;
|
|
58684
58919
|
}
|
|
58685
58920
|
async function runApplication(ctx, client, values, checkout2, context, app, application, known, base, runId, timeoutSeconds, created, summaries) {
|
|
58686
|
-
const appDir =
|
|
58687
|
-
await
|
|
58921
|
+
const appDir = join30(base, app.key);
|
|
58922
|
+
await mkdir11(appDir, { mode: 448 });
|
|
58688
58923
|
created.push(await identityOf(appDir));
|
|
58689
|
-
const stagingDir =
|
|
58690
|
-
await
|
|
58924
|
+
const stagingDir = join30(appDir, "staging"), outputDir = join30(appDir, "out");
|
|
58925
|
+
await mkdir11(stagingDir, { mode: 448 });
|
|
58691
58926
|
created.push(await identityOf(stagingDir));
|
|
58692
|
-
await
|
|
58927
|
+
await mkdir11(outputDir, { mode: 448 });
|
|
58693
58928
|
created.push(await identityOf(outputDir));
|
|
58694
58929
|
const { facts, components } = await ctx.out.waiting(ctx.t("progress.prepare", { app: app.name, path: app.path }), () => scanFacts(checkout2, app));
|
|
58695
58930
|
const staged = await stageApplication(checkout2, app, stagingDir);
|
|
@@ -58703,13 +58938,13 @@ async function runApplication(ctx, client, values, checkout2, context, app, appl
|
|
|
58703
58938
|
statements: Array.isArray(known?.statements) ? known.statements.slice(0, 100) : [],
|
|
58704
58939
|
outputFormat: import_validation3.PROJECT_INIT_AGENT_FORMAT
|
|
58705
58940
|
};
|
|
58706
|
-
const inputFile =
|
|
58941
|
+
const inputFile = join30(stagingDir, "fleek-input.json"), instructionsFile = join30(stagingDir, "FLEEK-INIT.md"), outputFile = join30(outputDir, "agent-output.json");
|
|
58707
58942
|
await writeFile6(inputFile, `${JSON.stringify(input, null, 2)}
|
|
58708
58943
|
`, { mode: 256 });
|
|
58709
58944
|
await writeFile6(instructionsFile, `${instructions2(ctx, app, facts)}
|
|
58710
58945
|
`, { mode: 256 });
|
|
58711
|
-
const stagingDigest =
|
|
58712
|
-
const idempotencyKey = values.yes ? `pi-${
|
|
58946
|
+
const stagingDigest = createHash10("sha256").update(JSON.stringify([import_validation3.PROJECT_INIT_FORMAT, INIT_CLI_VERSION, staged.digest, facts.factsHash, input.base, input.statements])).digest("hex");
|
|
58947
|
+
const idempotencyKey = values.yes ? `pi-${createHash10("sha256").update(JSON.stringify([context.project.teamId, applicationKey, checkout2.commit, stagingDigest])).digest("hex")}` : `pi-${createHash10("sha256").update(`${runId}:${app.key}`).digest("hex")}`;
|
|
58713
58948
|
if (values.yes && !values["dry-run"] && (await client.availableTools()).has(ACTION_STATUS_TOOL)) {
|
|
58714
58949
|
const status = await client.callTool(ACTION_STATUS_TOOL, { action: WIRE.projectInitSubmit, idempotencyKey }).then((r) => r.structured).catch(() => null);
|
|
58715
58950
|
if (status?.state === "completed") {
|
|
@@ -58815,7 +59050,7 @@ async function runApplication(ctx, client, values, checkout2, context, app, appl
|
|
|
58815
59050
|
client,
|
|
58816
59051
|
WIRE.projectKnowledgeCheck,
|
|
58817
59052
|
{ teamId: context.project.teamId, summary, locale: ctx.lang },
|
|
58818
|
-
{ idempotencyKey: `km-${
|
|
59053
|
+
{ idempotencyKey: `km-${createHash10("sha256").update(JSON.stringify([context.project.teamId, applicationKey, checkout2.commit, stagingDigest])).digest("hex")}`, backoffMs: ctx.deps.mutationBackoffMs }
|
|
58819
59054
|
);
|
|
58820
59055
|
emit(ctx, { event: "maintenance", app: app.key, result: check.result.result, runId: check.result.runId ?? null });
|
|
58821
59056
|
if (check.result.fundamental !== true) {
|
|
@@ -58849,9 +59084,9 @@ var import_types9 = __toESM(require_dist(), 1);
|
|
|
58849
59084
|
import { spawn as spawn8 } from "node:child_process";
|
|
58850
59085
|
import { randomBytes as randomBytes11, randomUUID as randomUUID5 } from "node:crypto";
|
|
58851
59086
|
import { constants as fsConstants6 } from "node:fs";
|
|
58852
|
-
import { access as access6, chmod as chmod4, chown, lstat as lstat14, open as open7, readFile as
|
|
59087
|
+
import { access as access6, chmod as chmod4, chown, lstat as lstat14, open as open7, readFile as readFile23, rename as rename5, rm as rm12, stat as stat15 } from "node:fs/promises";
|
|
58853
59088
|
import { hostname as osHostname } from "node:os";
|
|
58854
|
-
import { delimiter as delimiter5, dirname as dirname22, join as
|
|
59089
|
+
import { delimiter as delimiter5, dirname as dirname22, join as join31 } from "node:path";
|
|
58855
59090
|
var SERVICE_KIND = "review";
|
|
58856
59091
|
var SERVICE_PATHS = Object.freeze({
|
|
58857
59092
|
releases: "/opt/fleek/releases",
|
|
@@ -59186,10 +59421,10 @@ function kitVersionOf(value) {
|
|
|
59186
59421
|
async function install(ctx, version2) {
|
|
59187
59422
|
const sys = ctx.system, P = SERVICE_PATHS;
|
|
59188
59423
|
await recordServiceOwnership(ctx, version2);
|
|
59189
|
-
const releaseDir =
|
|
59190
|
-
const packageDir =
|
|
59424
|
+
const releaseDir = join31(P.releases, `npm-${version2}`);
|
|
59425
|
+
const packageDir = join31(releaseDir, "node_modules", "@logic-joe", "fleek");
|
|
59191
59426
|
const ok = async (program, args, options) => (await sys.run(program, args, options)).code === 0;
|
|
59192
|
-
const present = await sys.readText(
|
|
59427
|
+
const present = await sys.readText(join31(packageDir, "package.json")).then((text6) => {
|
|
59193
59428
|
try {
|
|
59194
59429
|
return JSON.parse(text6 ?? "").version === version2;
|
|
59195
59430
|
} catch {
|
|
@@ -59206,16 +59441,16 @@ async function install(ctx, version2) {
|
|
|
59206
59441
|
if (await sys.exists(P.bin) && !await sys.exists(P.binBackup)) await ok("cp", ["-p", P.bin, P.binBackup]);
|
|
59207
59442
|
const linked = (await sys.run("readlink", ["-f", P.current])).stdout.trim();
|
|
59208
59443
|
const changed = !present || linked !== packageDir;
|
|
59209
|
-
if (!await ok("ln", ["-sfn", packageDir, P.current]) || !await ok("ln", ["-sfn",
|
|
59444
|
+
if (!await ok("ln", ["-sfn", packageDir, P.current]) || !await ok("ln", ["-sfn", join31(P.current, "dist", "fleek.mjs"), P.bin])) return { ok: false, reason: "error" };
|
|
59210
59445
|
if ((await sys.run("id", ["-u", P.broker])).code !== 0 && !await ok("useradd", ["--create-home", "--home-dir", P.brokerHome, "--shell", "/usr/sbin/nologin", "--user-group", P.broker])) return { ok: false, reason: "error" };
|
|
59211
|
-
const untrusted = await untrustedPath(sys,
|
|
59446
|
+
const untrusted = await untrustedPath(sys, join31(packageDir, "service-agents", "install-system-service"));
|
|
59212
59447
|
if (untrusted) {
|
|
59213
59448
|
ctx.out.error(ctx.out.style.fail(ctx.t("service.untrustedPath", { path: untrusted })));
|
|
59214
59449
|
return { ok: false, reason: "denied" };
|
|
59215
59450
|
}
|
|
59216
|
-
if (!await ok("bash", [
|
|
59451
|
+
if (!await ok("bash", [join31(packageDir, "service-agents", "install-system-service"), SERVICE_KIND])) return { ok: false, reason: "error" };
|
|
59217
59452
|
if (!await sys.exists(P.keyringCredential)) {
|
|
59218
|
-
if (await sys.exists(
|
|
59453
|
+
if (await sys.exists(join31(P.keyring, "login.keyring"))) {
|
|
59219
59454
|
ctx.out.error(ctx.out.style.fail(ctx.t("service.keyringOrphan", { path: P.keyring })));
|
|
59220
59455
|
return { ok: false, reason: "error" };
|
|
59221
59456
|
}
|
|
@@ -59295,9 +59530,9 @@ async function imageDigest(ctx) {
|
|
|
59295
59530
|
"--format",
|
|
59296
59531
|
"{{.Digest}}"
|
|
59297
59532
|
]);
|
|
59298
|
-
const
|
|
59299
|
-
if (result.code !== 0 || !/^sha256:[a-f0-9]{64}$/.test(
|
|
59300
|
-
return `localhost/fleek-agents@${
|
|
59533
|
+
const digest2 = result.stdout.trim();
|
|
59534
|
+
if (result.code !== 0 || !/^sha256:[a-f0-9]{64}$/.test(digest2)) return null;
|
|
59535
|
+
return `localhost/fleek-agents@${digest2}`;
|
|
59301
59536
|
}
|
|
59302
59537
|
async function providerStep(ctx, skip) {
|
|
59303
59538
|
const sys = ctx.system, P = SERVICE_PATHS;
|
|
@@ -59384,7 +59619,7 @@ async function startUnit(ctx, restart) {
|
|
|
59384
59619
|
async function serviceStatus(ctx) {
|
|
59385
59620
|
const sys = ctx.system, P = SERVICE_PATHS;
|
|
59386
59621
|
if (sys.uid() !== 0) throw new CliError("errors.serviceRoot", EXIT.accessDenied, {}, "ROOT_REQUIRED");
|
|
59387
|
-
const release = await sys.readText(
|
|
59622
|
+
const release = await sys.readText(join31(P.current, "package.json")).then((raw) => {
|
|
59388
59623
|
try {
|
|
59389
59624
|
return String(JSON.parse(raw ?? "").version ?? "");
|
|
59390
59625
|
} catch {
|
|
@@ -59460,7 +59695,7 @@ async function recordServiceOwnership(ctx, version2) {
|
|
|
59460
59695
|
};
|
|
59461
59696
|
state.ownedPaths ??= [];
|
|
59462
59697
|
if (!previous2) state.keepLinger = (await sys.run("loginctl", ["show-user", P.broker, "--property=Linger", "--value"])).stdout.trim() === "yes";
|
|
59463
|
-
const candidates = [
|
|
59698
|
+
const candidates = [join31(P.releases, `npm-${version2}`), P.current, P.bin, ...["run-job", "knowledge-poll", "unlock-keyring", "run-service", "kit-setup", "broker-run", "egress-allowlist"].map((name) => join31(P.agents, name))];
|
|
59464
59699
|
for (const path of candidates) if (!state.ownedPaths.includes(path) && !await sys.exists(path)) state.ownedPaths.push(path);
|
|
59465
59700
|
if ((await sys.run("install", ["-d", "-m", "0750", "/etc/fleek-agents"])).code !== 0) throw usage4();
|
|
59466
59701
|
const content3 = JSON.stringify(state) + "\n";
|
|
@@ -59748,7 +59983,7 @@ function realSystem(options = {}) {
|
|
|
59748
59983
|
async which(name) {
|
|
59749
59984
|
for (const dir of (process.env.PATH ?? "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin").split(delimiter5)) {
|
|
59750
59985
|
if (!dir.startsWith("/")) continue;
|
|
59751
|
-
const path =
|
|
59986
|
+
const path = join31(dir, name);
|
|
59752
59987
|
try {
|
|
59753
59988
|
await access6(path, fsConstants6.X_OK);
|
|
59754
59989
|
if ((await stat15(path)).isFile()) return path;
|
|
@@ -59783,9 +60018,9 @@ function realSystem(options = {}) {
|
|
|
59783
60018
|
},
|
|
59784
60019
|
exists: (path) => lstat14(path).then(() => true, () => false),
|
|
59785
60020
|
entry: (path) => lstat14(path).then((info) => ({ uid: info.uid, mode: info.mode & 4095, symlink: info.isSymbolicLink() }), () => null),
|
|
59786
|
-
readText: (path) =>
|
|
60021
|
+
readText: (path) => readFile23(path, "utf8").catch(() => null),
|
|
59787
60022
|
async writeAtomic(path, content3, options2) {
|
|
59788
|
-
const temp =
|
|
60023
|
+
const temp = join31(dirname22(path), `.${randomBytes11(6).toString("hex")}.tmp`);
|
|
59789
60024
|
const handle = await open7(temp, "wx", options2.mode);
|
|
59790
60025
|
try {
|
|
59791
60026
|
await handle.writeFile(content3);
|
|
@@ -59833,13 +60068,13 @@ function realSystem(options = {}) {
|
|
|
59833
60068
|
// src/setup.ts
|
|
59834
60069
|
var import_types10 = __toESM(require_dist(), 1);
|
|
59835
60070
|
import { hostname } from "node:os";
|
|
59836
|
-
import { join as
|
|
60071
|
+
import { join as join33, resolve as resolve8 } from "node:path";
|
|
59837
60072
|
import { realpath as realpath19 } from "node:fs/promises";
|
|
59838
60073
|
import { createInterface } from "node:readline/promises";
|
|
59839
60074
|
|
|
59840
60075
|
// src/setup-install.ts
|
|
59841
60076
|
import { homedir as homedir2 } from "node:os";
|
|
59842
|
-
import { isAbsolute as isAbsolute12, join as
|
|
60077
|
+
import { isAbsolute as isAbsolute12, join as join32 } from "node:path";
|
|
59843
60078
|
import { realpath as realpath18 } from "node:fs/promises";
|
|
59844
60079
|
async function installSetupCli(input) {
|
|
59845
60080
|
if (!/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/.test(input.version) || !input.update && input.version !== input.runningVersion) {
|
|
@@ -59862,29 +60097,29 @@ async function installSetupCli(input) {
|
|
|
59862
60097
|
return null;
|
|
59863
60098
|
}
|
|
59864
60099
|
};
|
|
59865
|
-
const candidates = input.update && input.cliPath ? [input.cliPath] : [...isAbsolute12(prefix) ? [
|
|
60100
|
+
const candidates = input.update && input.cliPath ? [input.cliPath] : [...isAbsolute12(prefix) ? [join32(prefix, "bin", "fleek")] : [], join32(cwd, ".fleek", "cli", "bin", "fleek")];
|
|
59866
60101
|
for (const candidate of candidates) {
|
|
59867
60102
|
const existing = await verify3(candidate);
|
|
59868
60103
|
if (existing) return existing;
|
|
59869
60104
|
}
|
|
59870
60105
|
if (!await input.confirm()) throw new CliError("errors.setupInstallDeclined", EXIT.accessDenied, {}, "CONFIRMATION_REQUIRED");
|
|
59871
60106
|
const spec = `@logic-joe/fleek@${input.version}`;
|
|
59872
|
-
const privatePrefix =
|
|
60107
|
+
const privatePrefix = join32(cwd, ".fleek", "cli");
|
|
59873
60108
|
if (input.update && input.cliPath?.startsWith(privatePrefix + "/")) {
|
|
59874
60109
|
const installed = await run2(npm, ["install", "--global", "--prefix", privatePrefix, "--no-audit", "--no-fund", spec], options);
|
|
59875
|
-
const verified2 = installed.code === 0 ? await verify3(
|
|
60110
|
+
const verified2 = installed.code === 0 ? await verify3(join32(privatePrefix, "bin", "fleek")) : null;
|
|
59876
60111
|
if (verified2) return verified2;
|
|
59877
60112
|
throw new CliError("errors.setupInstall", EXIT.failed, {}, "SETUP_INSTALL_FAILED");
|
|
59878
60113
|
}
|
|
59879
60114
|
const global = await run2(npm, ["install", "--global", "--no-audit", "--no-fund", spec], options);
|
|
59880
60115
|
if (global.code === 0 && isAbsolute12(prefix)) {
|
|
59881
|
-
const installed = await verify3(
|
|
60116
|
+
const installed = await verify3(join32(prefix, "bin", "fleek"));
|
|
59882
60117
|
if (installed) return installed;
|
|
59883
60118
|
}
|
|
59884
60119
|
if (input.update) throw new CliError("errors.setupInstall", EXIT.failed, {}, "SETUP_INSTALL_FAILED");
|
|
59885
|
-
const fallback = await run2(npm, ["install", "--global", "--prefix",
|
|
60120
|
+
const fallback = await run2(npm, ["install", "--global", "--prefix", join32(cwd, ".fleek", "cli"), "--no-audit", "--no-fund", spec], options);
|
|
59886
60121
|
if (fallback.code === 0) {
|
|
59887
|
-
const installed = await verify3(
|
|
60122
|
+
const installed = await verify3(join32(cwd, ".fleek", "cli", "bin", "fleek"));
|
|
59888
60123
|
if (installed) return installed;
|
|
59889
60124
|
}
|
|
59890
60125
|
throw new CliError("errors.setupInstall", EXIT.failed, {}, "SETUP_INSTALL_FAILED");
|
|
@@ -60014,7 +60249,7 @@ async function setupCommand(ctx, code, values) {
|
|
|
60014
60249
|
rl.close();
|
|
60015
60250
|
}
|
|
60016
60251
|
};
|
|
60017
|
-
const folderPath = (value) => value === "~" ? contextHome(ctx) : value.startsWith("~/") ?
|
|
60252
|
+
const folderPath = (value) => value === "~" ? contextHome(ctx) : value.startsWith("~/") ? join33(contextHome(ctx), value.slice(2)) : resolve8(ctx.deps.cwd ?? process.cwd(), value);
|
|
60018
60253
|
let cwd = folderPath(values.checkout ?? ".");
|
|
60019
60254
|
let checkout2 = await readCheckout(cwd);
|
|
60020
60255
|
if (!checkout2) {
|
|
@@ -60486,12 +60721,12 @@ function readableResult(out, t, result) {
|
|
|
60486
60721
|
if (!uuid.test(String(value))) line(text6(value));
|
|
60487
60722
|
return;
|
|
60488
60723
|
}
|
|
60489
|
-
const
|
|
60490
|
-
if (Object.hasOwn(
|
|
60491
|
-
walk(
|
|
60724
|
+
const record2 = value;
|
|
60725
|
+
if (Object.hasOwn(record2, "trust") && typeof record2.text === "string") {
|
|
60726
|
+
walk(record2.text, depth);
|
|
60492
60727
|
return;
|
|
60493
60728
|
}
|
|
60494
|
-
for (const [key, item2] of Object.entries(
|
|
60729
|
+
for (const [key, item2] of Object.entries(record2)) {
|
|
60495
60730
|
if (remaining <= 0) {
|
|
60496
60731
|
truncated = true;
|
|
60497
60732
|
break;
|
|
@@ -60887,7 +61122,7 @@ var COMMAND_USAGE = {
|
|
|
60887
61122
|
"kit list": "[--project <key|id>]",
|
|
60888
61123
|
"kit status": "[--project <key|id>]",
|
|
60889
61124
|
"kit pull": "[<project>] [--target claude|codex|orca|cursor|generic] [--checkout <dir>] [--tracked] [--yes] [--accept-approved]",
|
|
60890
|
-
"kit setup": "[<project>] [--target <client>] [--probe] [--yes]",
|
|
61125
|
+
"kit setup": "[<project>] [--target <client>] [--probe] [--all] [--yes]",
|
|
60891
61126
|
"kit doctor": "[--project <key|id>] [--probe]",
|
|
60892
61127
|
"kit run": "claude|codex|orca [--project <key|id>] [--dry-run] [--auto] [--program <path>] [-- <client args>]",
|
|
60893
61128
|
init: "--project <key> [--app <key>[=<application>]] [--all-apps] [--refresh] [--maintenance] [--agent claude|manual] [--verbose] [--yes] [--dry-run] [--show] [--work-dir <dir>] [--keep]",
|
|
@@ -61301,7 +61536,7 @@ async function login(ctx, values, guided = false) {
|
|
|
61301
61536
|
if (!label || label.length > 80 || /[\u0000-\u001f\u007f]/.test(label)) throw usage5();
|
|
61302
61537
|
const options = { now: ctx.now, signal: ctx.deps.signal, wait: ctx.deps.deviceWait };
|
|
61303
61538
|
const setupCode = ctx.env.FLEEK_SETUP_CODE ? normalizeSetupCode(ctx.env.FLEEK_SETUP_CODE) : void 0;
|
|
61304
|
-
pendingDeviceKey = setupCode ? `setup-device-${
|
|
61539
|
+
pendingDeviceKey = setupCode ? `setup-device-${createHash11("sha256").update(`${info.issuer}\0${info.resource}\0${setupCode}`).digest("hex")}` : void 0;
|
|
61305
61540
|
const pending = pendingDeviceKey ? await store.get(pendingDeviceKey) : null;
|
|
61306
61541
|
let device;
|
|
61307
61542
|
if (pending) {
|
|
@@ -61697,8 +61932,8 @@ async function processTemplate(ctx, sub, args, values) {
|
|
|
61697
61932
|
const { client } = await ctx.session();
|
|
61698
61933
|
const id = () => claimRef(args[0]);
|
|
61699
61934
|
const file = async () => {
|
|
61700
|
-
const { readFile:
|
|
61701
|
-
const raw = await
|
|
61935
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
61936
|
+
const raw = await readFile24(text5(values.file, 1024), "utf8");
|
|
61702
61937
|
if (Buffer.byteLength(raw) > 256 * 1024) throw usage5();
|
|
61703
61938
|
try {
|
|
61704
61939
|
return JSON.parse(raw);
|
|
@@ -61747,8 +61982,8 @@ async function workflow(ctx, sub, args, values) {
|
|
|
61747
61982
|
const id = () => claimRef(args[0]);
|
|
61748
61983
|
const spec = async () => {
|
|
61749
61984
|
const path = text5(values.file, 1024);
|
|
61750
|
-
const { readFile:
|
|
61751
|
-
const raw = await
|
|
61985
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
61986
|
+
const raw = await readFile24(path, "utf8");
|
|
61752
61987
|
if (Buffer.byteLength(raw) > 200 * 1024) throw usage5();
|
|
61753
61988
|
try {
|
|
61754
61989
|
const value = JSON.parse(raw);
|
|
@@ -61839,8 +62074,8 @@ async function listenCommand(ctx, values, exec) {
|
|
|
61839
62074
|
await client.assertAvailable(WIRE.wait);
|
|
61840
62075
|
await client.assertAvailable(WIRE.inbox);
|
|
61841
62076
|
if (session.profile.clientId === SERVICE_CLIENT_ID) serviceExpiry(ctx, await whoamiContext(client));
|
|
61842
|
-
const stateDir =
|
|
61843
|
-
const deadLetterDir =
|
|
62077
|
+
const stateDir = join34(ctx.configDir, "listen", session.profile.key);
|
|
62078
|
+
const deadLetterDir = join34(ctx.configDir, "dead-letter", session.profile.key);
|
|
61844
62079
|
ctx.info(ctx.s.note(ctx.t("listen.started", { program: neutralizeLine(exec.program) })));
|
|
61845
62080
|
const result = await listen(waitSource(client, [1e3, 2e3, 5e3, 1e4, 3e4]), {
|
|
61846
62081
|
program: exec.program,
|
|
@@ -62004,8 +62239,8 @@ async function dispatch(ctx, positionals, values, exec, passthrough) {
|
|
|
62004
62239
|
forget: async (profile, configDir) => {
|
|
62005
62240
|
const profiles = new ProfileStore(configDir);
|
|
62006
62241
|
await profiles.remove(profile.key);
|
|
62007
|
-
await rm13(
|
|
62008
|
-
if (!(await profiles.list()).length) await rm13(
|
|
62242
|
+
await rm13(join34(configDir, "credentials", profile.key), { recursive: true, force: true });
|
|
62243
|
+
if (!(await profiles.list()).length) await rm13(join34(configDir, "profiles.json"), { force: true });
|
|
62009
62244
|
},
|
|
62010
62245
|
clearSecrets: async (key, configDir) => {
|
|
62011
62246
|
await clearCredentialSecrets(configDir, key, await ctx.secrets());
|
|
@@ -62522,7 +62757,7 @@ async function repos(ctx, sub, args, values) {
|
|
|
62522
62757
|
}, values, () => ctx.t("result.ok"));
|
|
62523
62758
|
}
|
|
62524
62759
|
function repositoryCredentialName(ref) {
|
|
62525
|
-
return `FA_GIT_READ_${
|
|
62760
|
+
return `FA_GIT_READ_${createHash11("sha256").update(ref, "utf8").digest("hex").slice(0, 32).toUpperCase()}`;
|
|
62526
62761
|
}
|
|
62527
62762
|
function kitContext(ctx, values, pinned) {
|
|
62528
62763
|
let resolved;
|