@hasna/skills 0.10.74 → 0.10.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/bin/index.js +701 -341
- package/bin/mcp.js +142 -93
- package/bin/migrate.js +1 -1
- package/bin/server.js +1 -1
- package/bin/worker.js +1 -1
- package/dist/cli/stray-arguments.d.ts +29 -0
- package/dist/index.js +572 -243
- package/dist/lib/agent-codex-trust.d.ts +4 -0
- package/dist/lib/agent-integration.d.ts +3 -3
- package/dist/lib/agent-sync.d.ts +6 -4
- package/dist/lib/codex-corpus-write.d.ts +47 -6
- package/dist/lib/codex-hook-rpc.d.ts +3 -0
- package/dist/lib/home-adoption.d.ts +5 -5
- package/dist/lib/installer.d.ts +5 -3
- package/dist/lib/search.d.ts +18 -0
- package/dist/runtime-prerequisites.js +1 -1
- package/dist/sdk/index.js +630 -301
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -36888,7 +36888,7 @@ var package_default;
|
|
|
36888
36888
|
var init_package = __esm(() => {
|
|
36889
36889
|
package_default = {
|
|
36890
36890
|
name: "@hasna/skills",
|
|
36891
|
-
version: "0.10.
|
|
36891
|
+
version: "0.10.76",
|
|
36892
36892
|
description: "Skills library for AI coding agents",
|
|
36893
36893
|
type: "module",
|
|
36894
36894
|
bin: {
|
|
@@ -51502,10 +51502,31 @@ var init_agent_discovery_path_bytes = __esm(() => {
|
|
|
51502
51502
|
|
|
51503
51503
|
// src/lib/codex-corpus-write.ts
|
|
51504
51504
|
import { KernelLock } from "@hasna/contracts/kernel-lock";
|
|
51505
|
-
import {
|
|
51505
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
51506
|
+
import { execFileSync, spawnSync as spawnSync2 } from "child_process";
|
|
51506
51507
|
import { createHash as createHash16 } from "crypto";
|
|
51507
|
-
import { accessSync, constants as constants8, lstatSync as lstatSync12, readFileSync as readFileSync10, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
|
|
51508
|
+
import { accessSync, constants as constants8, lstatSync as lstatSync12, mkdirSync as mkdirSync5, mkdtempSync, readdirSync as readdirSync5, readFileSync as readFileSync10, realpathSync as realpathSync2, rmSync as rmSync2, statSync as statSync7 } from "fs";
|
|
51508
51509
|
import { basename as basename7, delimiter, dirname as dirname13, isAbsolute as isAbsolute13, join as join19, relative as relative3, resolve as resolve14, sep as sep6 } from "path";
|
|
51510
|
+
function codexAdmissionRecord(options) {
|
|
51511
|
+
const record4 = options.onCodexAdmission;
|
|
51512
|
+
const invalid = () => {
|
|
51513
|
+
throw new Error("CODEX_CORPUS_ADMISSION_RECORD_INVALID: onCodexAdmission must be a synchronous function");
|
|
51514
|
+
};
|
|
51515
|
+
if (record4 !== undefined && typeof record4 !== "function")
|
|
51516
|
+
invalid();
|
|
51517
|
+
return { policy: { fallback: typeof record4 === "function" }, deliver(admission) {
|
|
51518
|
+
if (!admission || typeof record4 !== "function")
|
|
51519
|
+
return;
|
|
51520
|
+
const result2 = record4(admission);
|
|
51521
|
+
if (result2 !== null && (typeof result2 === "object" || typeof result2 === "function") && typeof result2.then === "function") {
|
|
51522
|
+
Promise.resolve(result2).catch(() => {});
|
|
51523
|
+
invalid();
|
|
51524
|
+
}
|
|
51525
|
+
} };
|
|
51526
|
+
}
|
|
51527
|
+
function codexAdmissionReceipt(admission) {
|
|
51528
|
+
return admission?.nativeAdmission === "unavailable" && admission.probe ? { nativeAdmission: "unavailable", nativeAdmissionProbe: { ...admission.probe } } : {};
|
|
51529
|
+
}
|
|
51509
51530
|
function physicalTarget(path) {
|
|
51510
51531
|
const suffix = [];
|
|
51511
51532
|
for (let cursor = path;; cursor = dirname13(cursor)) {
|
|
@@ -51587,13 +51608,224 @@ function executable(options) {
|
|
|
51587
51608
|
const digest = hash2();
|
|
51588
51609
|
if (options.codexSha256 && digest !== options.codexSha256)
|
|
51589
51610
|
return fail2();
|
|
51590
|
-
return { path, assertCurrent() {
|
|
51611
|
+
return { path, sha256: digest, size: Number(initial2.size), assertCurrent() {
|
|
51591
51612
|
const current = statSync7(path, { bigint: true });
|
|
51592
51613
|
if (realpathSync2(found) !== path || ["dev", "ino", "size", "mtimeNs", "ctimeNs", "mode"].some((key2) => initial2[key2] !== current[key2]) || hash2() !== digest)
|
|
51593
51614
|
fail2();
|
|
51594
51615
|
} };
|
|
51595
51616
|
}
|
|
51596
|
-
function
|
|
51617
|
+
function nativeLockAbsent(root) {
|
|
51618
|
+
for (const name of [`${KEY}.flock-v1`, `${KEY}.lock`]) {
|
|
51619
|
+
try {
|
|
51620
|
+
lstatSync12(join19(root, name));
|
|
51621
|
+
return false;
|
|
51622
|
+
} catch (error) {
|
|
51623
|
+
if (error.code !== "ENOENT")
|
|
51624
|
+
throw error;
|
|
51625
|
+
}
|
|
51626
|
+
}
|
|
51627
|
+
return true;
|
|
51628
|
+
}
|
|
51629
|
+
function skillsState(root, leaf, roots) {
|
|
51630
|
+
const chain = [realpathSync2(dirname13(root))];
|
|
51631
|
+
for (const part of [".hasna", "skills", leaf])
|
|
51632
|
+
chain.push(join19(chain.at(-1), part));
|
|
51633
|
+
const path = chain.at(-1);
|
|
51634
|
+
const uid2 = process.getuid();
|
|
51635
|
+
const verify = () => {
|
|
51636
|
+
if (roots.some((item) => contains(item, path)) || codexCorpusRootForPath(path) !== undefined)
|
|
51637
|
+
fail2();
|
|
51638
|
+
for (let ancestor = dirname13(chain[0]);; ancestor = dirname13(ancestor)) {
|
|
51639
|
+
const stat2 = lstatSync12(ancestor), sticky = stat2.uid === 0 && (stat2.mode & 512) !== 0;
|
|
51640
|
+
if (!stat2.isDirectory() || stat2.uid !== uid2 && stat2.uid !== 0 || (stat2.mode & 18) !== 0 && !sticky)
|
|
51641
|
+
fail2();
|
|
51642
|
+
if (dirname13(ancestor) === ancestor)
|
|
51643
|
+
break;
|
|
51644
|
+
}
|
|
51645
|
+
for (const component of chain) {
|
|
51646
|
+
const stat2 = lstatSync12(component, { throwIfNoEntry: false });
|
|
51647
|
+
if (!stat2)
|
|
51648
|
+
return;
|
|
51649
|
+
if (!stat2.isDirectory() || stat2.uid !== uid2 && stat2.uid !== 0 || (stat2.mode & 18) !== 0 || component === path && stat2.uid !== uid2)
|
|
51650
|
+
fail2();
|
|
51651
|
+
}
|
|
51652
|
+
};
|
|
51653
|
+
verify();
|
|
51654
|
+
return { path, ensure() {
|
|
51655
|
+
verify();
|
|
51656
|
+
for (const component of chain.slice(1)) {
|
|
51657
|
+
try {
|
|
51658
|
+
mkdirSync5(component, { mode: 448 });
|
|
51659
|
+
} catch (error) {
|
|
51660
|
+
if (error.code !== "EEXIST")
|
|
51661
|
+
throw error;
|
|
51662
|
+
}
|
|
51663
|
+
}
|
|
51664
|
+
verify();
|
|
51665
|
+
if (realpathSync2(path) !== path)
|
|
51666
|
+
fail2();
|
|
51667
|
+
return path;
|
|
51668
|
+
} };
|
|
51669
|
+
}
|
|
51670
|
+
function probeParent(roots) {
|
|
51671
|
+
const dataRoot = resolve14(getDataDirReadOnly()), path = join19(dataRoot, PROBE_PARENT), uid2 = process.getuid();
|
|
51672
|
+
const chain = [];
|
|
51673
|
+
for (let component = path;; component = dirname13(component)) {
|
|
51674
|
+
chain.unshift(component);
|
|
51675
|
+
if (dirname13(component) === component)
|
|
51676
|
+
break;
|
|
51677
|
+
}
|
|
51678
|
+
const verify = () => {
|
|
51679
|
+
if (roots.some((item) => contains(item, path)) || codexCorpusRootForPath(path) !== undefined)
|
|
51680
|
+
fail2();
|
|
51681
|
+
for (const component of chain) {
|
|
51682
|
+
const stat2 = lstatSync12(component, { throwIfNoEntry: false });
|
|
51683
|
+
if (!stat2)
|
|
51684
|
+
return;
|
|
51685
|
+
const skills = contains(dataRoot, component), sticky = !skills && stat2.uid === 0 && (stat2.mode & 512) !== 0;
|
|
51686
|
+
if (!stat2.isDirectory() || stat2.uid !== uid2 && (skills || stat2.uid !== 0) || (stat2.mode & 18) !== 0 && !sticky)
|
|
51687
|
+
fail2();
|
|
51688
|
+
}
|
|
51689
|
+
};
|
|
51690
|
+
verify();
|
|
51691
|
+
for (const component of chain) {
|
|
51692
|
+
if (lstatSync12(component, { throwIfNoEntry: false }))
|
|
51693
|
+
continue;
|
|
51694
|
+
try {
|
|
51695
|
+
mkdirSync5(component, { mode: 448 });
|
|
51696
|
+
} catch (error) {
|
|
51697
|
+
if (error.code !== "EEXIST")
|
|
51698
|
+
throw error;
|
|
51699
|
+
}
|
|
51700
|
+
}
|
|
51701
|
+
verify();
|
|
51702
|
+
if (realpathSync2(path) !== path)
|
|
51703
|
+
fail2();
|
|
51704
|
+
return path;
|
|
51705
|
+
}
|
|
51706
|
+
function probeHomeIntact(home, empty) {
|
|
51707
|
+
const stat2 = lstatSync12(home.path, { bigint: true, throwIfNoEntry: false });
|
|
51708
|
+
return !!stat2 && stat2.isDirectory() && stat2.dev === home.dev && stat2.ino === home.ino && stat2.uid === BigInt(process.getuid()) && (stat2.mode & 0o777n) === 0o700n && realpathSync2(home.path) === home.path && (!empty || readdirSync5(home.path).length === 0);
|
|
51709
|
+
}
|
|
51710
|
+
function removeProbeHome(home) {
|
|
51711
|
+
try {
|
|
51712
|
+
const stat2 = lstatSync12(home.path, { bigint: true });
|
|
51713
|
+
if (stat2.isDirectory() && stat2.dev === home.dev && stat2.ino === home.ino)
|
|
51714
|
+
rmSync2(home.path, { recursive: true, force: true });
|
|
51715
|
+
} catch {}
|
|
51716
|
+
}
|
|
51717
|
+
function probe(path, args, parent, stdio) {
|
|
51718
|
+
const created = mkdtempSync(join19(parent, "probe-")), stat2 = lstatSync12(created, { bigint: true });
|
|
51719
|
+
const home = { path: created, dev: stat2.dev, ino: stat2.ino };
|
|
51720
|
+
try {
|
|
51721
|
+
if (!probeHomeIntact(home, true))
|
|
51722
|
+
return;
|
|
51723
|
+
const env3 = { CODEX_HOME: home.path };
|
|
51724
|
+
for (const key2 of ["PATH", "HOME"])
|
|
51725
|
+
if (process.env[key2] !== undefined)
|
|
51726
|
+
env3[key2] = process.env[key2];
|
|
51727
|
+
const result2 = spawnSync2(path, args, { ...PROBE, cwd: home.path, env: env3, stdio: ["ignore", stdio, stdio] });
|
|
51728
|
+
return probeHomeIntact(home, false) ? result2 : undefined;
|
|
51729
|
+
} finally {
|
|
51730
|
+
removeProbeHome(home);
|
|
51731
|
+
}
|
|
51732
|
+
}
|
|
51733
|
+
function probeAdmissionCommand(path, parent) {
|
|
51734
|
+
const help = probe(path, ["help", "corpus-admission-inspect"], parent, "pipe");
|
|
51735
|
+
if (!help || help.error || help.signal !== null)
|
|
51736
|
+
return "inconclusive";
|
|
51737
|
+
if (help.status === 0)
|
|
51738
|
+
return "present";
|
|
51739
|
+
if (help.status !== 2 || help.stdout !== "" || typeof help.stderr !== "string" || !UNRECOGNIZED.test(help.stderr))
|
|
51740
|
+
return "inconclusive";
|
|
51741
|
+
const control = probe(path, ["help", "exec"], parent, "ignore");
|
|
51742
|
+
return control && !control.error && control.signal === null && control.status === 0 ? "absent" : "inconclusive";
|
|
51743
|
+
}
|
|
51744
|
+
function strictVersion(path, parent) {
|
|
51745
|
+
const result2 = probe(path, ["--version"], parent, "pipe");
|
|
51746
|
+
if (!result2 || result2.error || result2.signal !== null || result2.status !== 0 || typeof result2.stdout !== "string")
|
|
51747
|
+
return;
|
|
51748
|
+
const line = result2.stdout.replace(/\r?\n$/, "");
|
|
51749
|
+
return VERSION.test(line) ? line : undefined;
|
|
51750
|
+
}
|
|
51751
|
+
function rootLockKey(root, id) {
|
|
51752
|
+
return `codex-corpus-${createHash16("sha256").update(`${root}\x00${id.device}\x00${id.inode}`).digest("hex")}`;
|
|
51753
|
+
}
|
|
51754
|
+
function acquireFallback(inputs, options) {
|
|
51755
|
+
let reason2 = "executable-unverified";
|
|
51756
|
+
const refs = new Map, held = [];
|
|
51757
|
+
const close = () => {
|
|
51758
|
+
for (const ref of [...refs.values()].reverse())
|
|
51759
|
+
release(ref);
|
|
51760
|
+
};
|
|
51761
|
+
try {
|
|
51762
|
+
const native = executable(options);
|
|
51763
|
+
reason2 = "skills-lock-unavailable";
|
|
51764
|
+
const roots = inputs.map((item) => item.root);
|
|
51765
|
+
const locks = new Map(roots.map((root) => [root, skillsState(root, LOCK_DIRECTORY, roots)]));
|
|
51766
|
+
const parent = probeParent(roots);
|
|
51767
|
+
reason2 = "probe-inconclusive";
|
|
51768
|
+
const state = probeAdmissionCommand(native.path, parent);
|
|
51769
|
+
if (state === "present")
|
|
51770
|
+
reason2 = "command-present";
|
|
51771
|
+
if (state !== "absent")
|
|
51772
|
+
fail2();
|
|
51773
|
+
const version = strictVersion(native.path, parent);
|
|
51774
|
+
if (version === undefined)
|
|
51775
|
+
fail2();
|
|
51776
|
+
reason2 = "executable-unverified";
|
|
51777
|
+
native.assertCurrent();
|
|
51778
|
+
reason2 = "skills-lock-unavailable";
|
|
51779
|
+
for (const { input, root } of inputs) {
|
|
51780
|
+
const id = identity4(root), key2 = rootLockKey(root, id);
|
|
51781
|
+
if (!refs.has(key2)) {
|
|
51782
|
+
const owner2 = enclosing.getStore()?.get(key2);
|
|
51783
|
+
if (owner2 && !owner2.released)
|
|
51784
|
+
refs.set(key2, retain(owner2.hold));
|
|
51785
|
+
else {
|
|
51786
|
+
const lock = new KernelLock(locks.get(root).ensure(), key2, { mode: "exclusive" });
|
|
51787
|
+
refs.set(key2, retain({ lock, refs: 0 }));
|
|
51788
|
+
if (!lock.trySync(1000)) {
|
|
51789
|
+
reason2 = "writer-busy";
|
|
51790
|
+
fail2();
|
|
51791
|
+
}
|
|
51792
|
+
}
|
|
51793
|
+
}
|
|
51794
|
+
held.push({ input, root, id, ref: refs.get(key2) });
|
|
51795
|
+
}
|
|
51796
|
+
const assertCurrent = () => {
|
|
51797
|
+
try {
|
|
51798
|
+
for (const item of held) {
|
|
51799
|
+
if (item.ref.released)
|
|
51800
|
+
fail2();
|
|
51801
|
+
item.ref.hold.lock.assertUnchanged();
|
|
51802
|
+
if (realpathSync2(item.input) !== item.root || !sameIdentity(identity4(item.root), item.id) || !nativeLockAbsent(item.root))
|
|
51803
|
+
fail2();
|
|
51804
|
+
}
|
|
51805
|
+
native.assertCurrent();
|
|
51806
|
+
} catch {
|
|
51807
|
+
fail2("lease-changed");
|
|
51808
|
+
}
|
|
51809
|
+
};
|
|
51810
|
+
reason2 = "lease-changed";
|
|
51811
|
+
assertCurrent();
|
|
51812
|
+
const lease = { assertCurrent, close, admission: { nativeAdmission: "unavailable", probe: {
|
|
51813
|
+
kind: "help-unrecognized-subcommand",
|
|
51814
|
+
executable: native.path,
|
|
51815
|
+
sha256: native.sha256,
|
|
51816
|
+
size: native.size,
|
|
51817
|
+
version,
|
|
51818
|
+
probeExitCode: 2,
|
|
51819
|
+
controlExitCode: 0
|
|
51820
|
+
} } };
|
|
51821
|
+
leaseHolds.set(lease, refs);
|
|
51822
|
+
return lease;
|
|
51823
|
+
} catch {
|
|
51824
|
+
close();
|
|
51825
|
+
return fail2(reason2);
|
|
51826
|
+
}
|
|
51827
|
+
}
|
|
51828
|
+
function acquireCodexCorpusWrite(roots, options, policy = {}) {
|
|
51597
51829
|
const held = [];
|
|
51598
51830
|
const close = () => {
|
|
51599
51831
|
for (const item of held.reverse())
|
|
@@ -51606,10 +51838,20 @@ function acquireCodexCorpusWrite(roots, options) {
|
|
|
51606
51838
|
fail2();
|
|
51607
51839
|
}
|
|
51608
51840
|
};
|
|
51841
|
+
let fallback = false, refusal;
|
|
51609
51842
|
try {
|
|
51610
51843
|
if (roots.some((root) => typeof root !== "string" || !isAbsolute13(root) || root.includes("\x00")))
|
|
51611
51844
|
fail2();
|
|
51612
51845
|
const inputs = [...new Set(roots)].map((input) => ({ input, root: realpathSync2(input) })).sort((a, b) => a.root.localeCompare(b.root));
|
|
51846
|
+
const absent = inputs.filter(({ root }) => nativeLockAbsent(root));
|
|
51847
|
+
if (absent.length && absent.length !== inputs.length) {
|
|
51848
|
+
refusal = "native-lock-present";
|
|
51849
|
+
fail2();
|
|
51850
|
+
}
|
|
51851
|
+
if (absent.length && policy.fallback !== false) {
|
|
51852
|
+
fallback = true;
|
|
51853
|
+
return acquireFallback(inputs, options);
|
|
51854
|
+
}
|
|
51613
51855
|
for (const { input, root } of inputs) {
|
|
51614
51856
|
const lock = new KernelLock(root, KEY, { mode: "shared", existingOnly: true });
|
|
51615
51857
|
held.push({ input, root, lock });
|
|
@@ -51637,42 +51879,67 @@ function acquireCodexCorpusWrite(roots, options) {
|
|
|
51637
51879
|
if (Object.keys(row).sort().join(",") !== "lock,root,schema,state" || row.schema !== "codex-corpus-admission-status/v1" || row.state !== "committed-v1" && row.state !== "committed-v2" || !sameIdentity(row.root, rootIdentity) || !sameIdentity(row.lock, lockIdentity))
|
|
51638
51880
|
fail2();
|
|
51639
51881
|
}
|
|
51640
|
-
return { assertCurrent, close };
|
|
51641
|
-
} catch {
|
|
51882
|
+
return { assertCurrent, close, admission: { nativeAdmission: "verified" } };
|
|
51883
|
+
} catch (error) {
|
|
51884
|
+
if (fallback)
|
|
51885
|
+
throw error;
|
|
51642
51886
|
close();
|
|
51643
|
-
return fail2();
|
|
51887
|
+
return fail2(refusal);
|
|
51644
51888
|
}
|
|
51645
51889
|
}
|
|
51646
|
-
function
|
|
51890
|
+
function scoped(lease, run) {
|
|
51891
|
+
const holds = leaseHolds.get(lease);
|
|
51892
|
+
return holds?.size ? enclosing.run(new Map([...enclosing.getStore() ?? [], ...holds]), run) : run();
|
|
51893
|
+
}
|
|
51894
|
+
function withCodexCorpusWrite(roots, run, options = {}, policy = {}) {
|
|
51647
51895
|
if (!roots.length)
|
|
51648
51896
|
return run(() => {});
|
|
51649
|
-
const lease = acquireCodexCorpusWrite(roots, options);
|
|
51897
|
+
const lease = acquireCodexCorpusWrite(roots, options, policy);
|
|
51650
51898
|
try {
|
|
51651
51899
|
lease.assertCurrent();
|
|
51652
|
-
const result2 = run(lease.assertCurrent);
|
|
51900
|
+
const result2 = scoped(lease, () => run(lease.assertCurrent, lease.admission));
|
|
51653
51901
|
lease.assertCurrent();
|
|
51654
51902
|
return result2;
|
|
51655
51903
|
} finally {
|
|
51656
51904
|
lease.close();
|
|
51657
51905
|
}
|
|
51658
51906
|
}
|
|
51659
|
-
async function withCodexCorpusWriteAsync(roots, run, options = {}) {
|
|
51907
|
+
async function withCodexCorpusWriteAsync(roots, run, options = {}, policy = {}) {
|
|
51660
51908
|
if (!roots.length)
|
|
51661
51909
|
return run(() => {});
|
|
51662
|
-
const lease = acquireCodexCorpusWrite(roots, options);
|
|
51910
|
+
const lease = acquireCodexCorpusWrite(roots, options, policy);
|
|
51663
51911
|
try {
|
|
51664
51912
|
lease.assertCurrent();
|
|
51665
|
-
const result2 = await run(lease.assertCurrent);
|
|
51913
|
+
const result2 = await scoped(lease, () => run(lease.assertCurrent, lease.admission));
|
|
51666
51914
|
lease.assertCurrent();
|
|
51667
51915
|
return result2;
|
|
51668
51916
|
} finally {
|
|
51669
51917
|
lease.close();
|
|
51670
51918
|
}
|
|
51671
51919
|
}
|
|
51672
|
-
var KEY = ".native-corpus-admission", fail2 = () => {
|
|
51673
|
-
throw new Error(
|
|
51920
|
+
var KEY = ".native-corpus-admission", fail2 = (reason2) => {
|
|
51921
|
+
throw new Error(`CODEX_CORPUS_ADMISSION_REQUIRED: verified native admission and its existing shared lock are required${reason2 ? ` (${reason2})` : ""}`);
|
|
51922
|
+
}, PROBE, UNRECOGNIZED, VERSION, LOCK_DIRECTORY = "codex-corpus-locks", PROBE_PARENT = "codex-probe-homes", retain = (hold) => {
|
|
51923
|
+
hold.refs++;
|
|
51924
|
+
return { hold, released: false };
|
|
51925
|
+
}, release = (ref) => {
|
|
51926
|
+
if (ref.released)
|
|
51927
|
+
return;
|
|
51928
|
+
ref.released = true;
|
|
51929
|
+
if (--ref.hold.refs === 0)
|
|
51930
|
+
ref.hold.lock.close();
|
|
51931
|
+
}, enclosing, leaseHolds, contains = (base2, path) => {
|
|
51932
|
+
const distance = relative3(base2, path);
|
|
51933
|
+
return distance === "" || !distance.startsWith(`..${sep6}`) && distance !== ".." && !isAbsolute13(distance);
|
|
51674
51934
|
};
|
|
51675
|
-
var init_codex_corpus_write = () => {
|
|
51935
|
+
var init_codex_corpus_write = __esm(() => {
|
|
51936
|
+
init_config();
|
|
51937
|
+
PROBE = { timeout: 5000, maxBuffer: 4096, killSignal: "SIGKILL", encoding: "utf8" };
|
|
51938
|
+
UNRECOGNIZED = /^error: unrecognized subcommand 'corpus-admission-inspect'(?:\r?\n|$)/;
|
|
51939
|
+
VERSION = /^codex-cli (?:0|[1-9][0-9]{0,5})\.(?:0|[1-9][0-9]{0,5})\.(?:0|[1-9][0-9]{0,5})(?:-[0-9A-Za-z-]{1,32}(?:\.[0-9A-Za-z-]{1,32}){0,7})?$/;
|
|
51940
|
+
enclosing = new AsyncLocalStorage;
|
|
51941
|
+
leaseHolds = new WeakMap;
|
|
51942
|
+
});
|
|
51676
51943
|
|
|
51677
51944
|
// src/lib/codex-hook-rpc.ts
|
|
51678
51945
|
import { join as join20 } from "path";
|
|
@@ -51785,6 +52052,7 @@ async function connectCodexHookRpc(options) {
|
|
|
51785
52052
|
const rpc = {
|
|
51786
52053
|
version,
|
|
51787
52054
|
processId: child2.pid,
|
|
52055
|
+
admission: corpusLease.admission,
|
|
51788
52056
|
request(method2, params) {
|
|
51789
52057
|
if (stopped)
|
|
51790
52058
|
return Promise.reject(new Error(configInvalid ? CODEX_CONFIG_INVALID : "CODEX_HOOK_TRUST_NATIVE_RPC_CLOSED"));
|
|
@@ -51992,7 +52260,7 @@ var init_codex_native_skill_catalog = __esm(() => {
|
|
|
51992
52260
|
// src/lib/codex-plugin-skill-controls.ts
|
|
51993
52261
|
import { createHash as createHash17 } from "crypto";
|
|
51994
52262
|
import { basename as basename8, dirname as dirname14, join as join21, relative as relative4, resolve as resolve15, sep as sep7 } from "path";
|
|
51995
|
-
import { lstatSync as lstatSync13, readdirSync as
|
|
52263
|
+
import { lstatSync as lstatSync13, readdirSync as readdirSync6, readFileSync as readFileSync11, readlinkSync as readlinkSync3, realpathSync as realpathSync5 } from "fs";
|
|
51996
52264
|
function refuse2() {
|
|
51997
52265
|
throw new Error("CODEX_NATIVE_SKILL_IDENTITY_UNSUPPORTED: review native plugin names and hook controls");
|
|
51998
52266
|
}
|
|
@@ -52245,7 +52513,7 @@ function reviewedRetiredCodexRoot(cache3, root, controls, rules, read2, allowAbs
|
|
|
52245
52513
|
if (!enrolled.some((control) => control.namespace === parsed.namespace && control.manifestSha256 === parsed.manifestSha256 && !parsed.appSha256 && !parsed.mcpSha256))
|
|
52246
52514
|
return false;
|
|
52247
52515
|
let entries = 0;
|
|
52248
|
-
const emptySkills = (directory, depth) => depth <= 64 &&
|
|
52516
|
+
const emptySkills = (directory, depth) => depth <= 64 && readdirSync6(directory).every((name) => {
|
|
52249
52517
|
if (++entries > 4096 || name === "SKILL.md")
|
|
52250
52518
|
return false;
|
|
52251
52519
|
const path = join21(directory, name), stat2 = lstatSync13(path);
|
|
@@ -52270,7 +52538,7 @@ function reviewedCodexPluginCapabilitiesUnchanged(cache3, controls, read2, rules
|
|
|
52270
52538
|
if (control.remotePluginId !== undefined && !remoteInstallationMatches(parent, control.remotePluginId, read2))
|
|
52271
52539
|
return false;
|
|
52272
52540
|
}
|
|
52273
|
-
const names =
|
|
52541
|
+
const names = readdirSync6(parent);
|
|
52274
52542
|
entries += names.length;
|
|
52275
52543
|
if (entries > 4096)
|
|
52276
52544
|
return false;
|
|
@@ -52465,7 +52733,7 @@ var init_codex_plugin_skill_controls = __esm(() => {
|
|
|
52465
52733
|
});
|
|
52466
52734
|
|
|
52467
52735
|
// src/lib/codex-vendor-refresh.ts
|
|
52468
|
-
import { lstatSync as lstatSync14, readdirSync as
|
|
52736
|
+
import { lstatSync as lstatSync14, readdirSync as readdirSync7, readFileSync as readFileSync12 } from "fs";
|
|
52469
52737
|
import { isAbsolute as isAbsolute16, join as join22, relative as relative5, resolve as resolve16, sep as sep8 } from "path";
|
|
52470
52738
|
import { isDeepStrictEqual as isDeepStrictEqual6 } from "util";
|
|
52471
52739
|
function codexVendorMarketplace(cache3, path) {
|
|
@@ -52482,7 +52750,7 @@ function codexVendorMarketplace(cache3, path) {
|
|
|
52482
52750
|
function pluginTreeVisible(path, hidden, insideSkill, depth, budget2) {
|
|
52483
52751
|
if (depth > MAX_SUBTREE_DEPTH)
|
|
52484
52752
|
return false;
|
|
52485
|
-
const names =
|
|
52753
|
+
const names = readdirSync7(path);
|
|
52486
52754
|
const skill = names.some(isSkillDocument);
|
|
52487
52755
|
if (skill && (hidden || insideSkill))
|
|
52488
52756
|
return false;
|
|
@@ -52506,7 +52774,7 @@ function codexVendorPluginRootRefreshSafe(root, budget2 = { remaining: MAX_SUBTR
|
|
|
52506
52774
|
return false;
|
|
52507
52775
|
if (!directory(join22(root, ".codex-plugin")))
|
|
52508
52776
|
return false;
|
|
52509
|
-
const controls =
|
|
52777
|
+
const controls = readdirSync7(join22(root, ".codex-plugin"));
|
|
52510
52778
|
if (controls.length !== 1 || controls[0] !== "plugin.json")
|
|
52511
52779
|
return false;
|
|
52512
52780
|
const manifest = join22(root, ".codex-plugin", "plugin.json"), stat2 = lstatSync14(manifest, { throwIfNoEntry: false });
|
|
@@ -52529,7 +52797,7 @@ function codexVendorPluginRootRefreshSafe(root, budget2 = { remaining: MAX_SUBTR
|
|
|
52529
52797
|
}
|
|
52530
52798
|
function vendorMembers(path, budget2) {
|
|
52531
52799
|
const directories = [];
|
|
52532
|
-
for (const name of
|
|
52800
|
+
for (const name of readdirSync7(path)) {
|
|
52533
52801
|
if (--budget2.remaining < 0)
|
|
52534
52802
|
return null;
|
|
52535
52803
|
const stat2 = lstatSync14(join22(path, name));
|
|
@@ -52674,7 +52942,7 @@ function codexVendorConfigCandidates(text2, cache3, options = {}) {
|
|
|
52674
52942
|
var CODEX_VENDOR_MARKETPLACES, CODEX_REMOTE_VENDOR_MARKETPLACES, identifier3 = (value) => typeof value === "string" && /^[A-Za-z0-9_-]{1,64}$/.test(value), record4 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value)), directory = (path) => {
|
|
52675
52943
|
const stat2 = lstatSync14(path, { throwIfNoEntry: false });
|
|
52676
52944
|
return Boolean(stat2?.isDirectory() && !stat2.isSymbolicLink());
|
|
52677
|
-
}, OTHER_PLUGIN_CONTROLS, VENDOR_MANIFEST_KEYS, DEFAULT_SKILLS_PATHS, VENDOR_APP_DECLARATION = "./.app.json", MAX_SUBTREE_ENTRIES = 20000, MAX_SUBTREE_DEPTH = 32, hiddenName = (name) => name.startsWith(".") || name === "node_modules", isSkillDocument = (name) => name.toLowerCase() === "skill.md", present = (path) => lstatSync14(path, { throwIfNoEntry: false }) !== undefined, holdsOtherControl = (path) =>
|
|
52945
|
+
}, OTHER_PLUGIN_CONTROLS, VENDOR_MANIFEST_KEYS, DEFAULT_SKILLS_PATHS, VENDOR_APP_DECLARATION = "./.app.json", MAX_SUBTREE_ENTRIES = 20000, MAX_SUBTREE_DEPTH = 32, hiddenName = (name) => name.startsWith(".") || name === "node_modules", isSkillDocument = (name) => name.toLowerCase() === "skill.md", present = (path) => lstatSync14(path, { throwIfNoEntry: false }) !== undefined, holdsOtherControl = (path) => readdirSync7(path).some((name) => OTHER_PLUGIN_CONTROLS.includes(name.toLowerCase())), MAX_TRAILING_VENDOR_ROWS = 16, MAX_VENDOR_TABLES = 8, MAX_CONFIG_CANDIDATES = 128, HEADER;
|
|
52678
52946
|
var init_codex_vendor_refresh = __esm(() => {
|
|
52679
52947
|
init_claude_settings_witness();
|
|
52680
52948
|
init_codex_plugin_skill_controls();
|
|
@@ -52862,7 +53130,7 @@ var init_claude_plugin_manifest_witness = __esm(() => {
|
|
|
52862
53130
|
|
|
52863
53131
|
// node_modules/@hasna/contracts/dist/client/transport.js
|
|
52864
53132
|
import { isIP as isIP2 } from "net";
|
|
52865
|
-
import { spawnSync as
|
|
53133
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
52866
53134
|
import { closeSync as closeSync22, fstatSync as fstatSync22, openSync as openSync22, readFileSync as readFileSync22 } from "fs";
|
|
52867
53135
|
import { O_NOFOLLOW as O_NOFOLLOW2, O_NONBLOCK as O_NONBLOCK2, O_RDONLY as O_RDONLY2 } from "constants";
|
|
52868
53136
|
import { hostname as osHostname } from "os";
|
|
@@ -53220,7 +53488,7 @@ function isAmbientEnvironment(env3) {
|
|
|
53220
53488
|
return env3 === process.env || env3[AMBIENT_ENVIRONMENT] === true;
|
|
53221
53489
|
}
|
|
53222
53490
|
function defaultKeychainRunner(argv) {
|
|
53223
|
-
const result2 =
|
|
53491
|
+
const result2 = spawnSync3(KEYCHAIN_SECURITY_BIN, [...argv], {
|
|
53224
53492
|
encoding: "utf8",
|
|
53225
53493
|
stdio: ["ignore", "pipe", "pipe"],
|
|
53226
53494
|
timeout: KEYCHAIN_SPAWN_TIMEOUT_MS
|
|
@@ -54559,7 +54827,7 @@ function capturePreparationProcess(child2, platform2 = process.platform, signalG
|
|
|
54559
54827
|
}
|
|
54560
54828
|
|
|
54561
54829
|
// src/lib/dependency-preparation.ts
|
|
54562
|
-
import { constants as constants11, closeSync as closeSync10, fstatSync as fstatSync10, lstatSync as lstatSync18, mkdirSync as
|
|
54830
|
+
import { constants as constants11, closeSync as closeSync10, fstatSync as fstatSync10, lstatSync as lstatSync18, mkdirSync as mkdirSync6, openSync as openSync10, readFileSync as readFileSync14, readdirSync as readdirSync8, rmdirSync as rmdirSync2, unlinkSync as unlinkSync3, ftruncateSync, writeSync as writeSync2 } from "fs";
|
|
54563
54831
|
import { join as join26 } from "path";
|
|
54564
54832
|
function hasDependencyPreparationMarker(skillPath) {
|
|
54565
54833
|
try {
|
|
@@ -54574,7 +54842,7 @@ function claimPreparation(skillPath) {
|
|
|
54574
54842
|
const state = join26(marker, "state.json"), active = join26(marker, "active");
|
|
54575
54843
|
let created = false;
|
|
54576
54844
|
try {
|
|
54577
|
-
|
|
54845
|
+
mkdirSync6(marker, { mode: 448 });
|
|
54578
54846
|
created = true;
|
|
54579
54847
|
} catch (error) {
|
|
54580
54848
|
if (error.code !== "EEXIST")
|
|
@@ -54585,7 +54853,7 @@ function claimPreparation(skillPath) {
|
|
|
54585
54853
|
if (!lstatSync18(marker).isDirectory() || lstatSync18(marker).isSymbolicLink())
|
|
54586
54854
|
return;
|
|
54587
54855
|
if (!created) {
|
|
54588
|
-
if (
|
|
54856
|
+
if (readdirSync8(marker).some((name) => name !== "state.json"))
|
|
54589
54857
|
return;
|
|
54590
54858
|
if (!lstatSync18(state).isFile() || lstatSync18(state).isSymbolicLink() || lstatSync18(state).size > 1024)
|
|
54591
54859
|
return;
|
|
@@ -54593,7 +54861,7 @@ function claimPreparation(skillPath) {
|
|
|
54593
54861
|
if (previous.version !== 1 || previous.status !== "failed" || Object.keys(previous).length !== 2)
|
|
54594
54862
|
return;
|
|
54595
54863
|
}
|
|
54596
|
-
|
|
54864
|
+
mkdirSync6(active, { mode: 448 });
|
|
54597
54865
|
fd = openSync10(state, constants11.O_RDWR | constants11.O_NOFOLLOW | (created ? constants11.O_CREAT | constants11.O_EXCL : 0), 384);
|
|
54598
54866
|
if (!fstatSync10(fd).isFile()) {
|
|
54599
54867
|
closeSync10(fd);
|
|
@@ -54724,7 +54992,7 @@ var init_dependency_preparation = () => {};
|
|
|
54724
54992
|
|
|
54725
54993
|
// src/lib/codex-native-skill-policy.ts
|
|
54726
54994
|
import { createHash as createHash20, randomUUID as randomUUID6 } from "crypto";
|
|
54727
|
-
import { closeSync as closeSync11, constants as constants12, fstatSync as fstatSync11, fsyncSync as fsyncSync3, lstatSync as lstatSync19, mkdirSync as
|
|
54995
|
+
import { closeSync as closeSync11, constants as constants12, fstatSync as fstatSync11, fsyncSync as fsyncSync3, lstatSync as lstatSync19, mkdirSync as mkdirSync7, openSync as openSync11, readFileSync as readFileSync15, readSync as readSync8, readlinkSync as readlinkSync4, realpathSync as realpathSync7, renameSync as renameSync3, unlinkSync as unlinkSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
54728
54996
|
import { dirname as dirname17, isAbsolute as isAbsolute19, join as join27, resolve as resolve18 } from "path";
|
|
54729
54997
|
import { isDeepStrictEqual as isDeepStrictEqual7 } from "util";
|
|
54730
54998
|
function codexNativeHookEnvelopeFromInput(input, event, inputBytes, inheritedFd) {
|
|
@@ -54984,7 +55252,7 @@ function writeExecutableCache(dataDir3, entries) {
|
|
|
54984
55252
|
return;
|
|
54985
55253
|
const existing = lstatSync19(directory2, { throwIfNoEntry: false });
|
|
54986
55254
|
if (!existing)
|
|
54987
|
-
|
|
55255
|
+
mkdirSync7(directory2, { mode: 448 });
|
|
54988
55256
|
else if (existing.isSymbolicLink() || !existing.isDirectory())
|
|
54989
55257
|
return;
|
|
54990
55258
|
const holder = lstatSync19(directory2, { throwIfNoEntry: false, bigint: true });
|
|
@@ -55279,7 +55547,7 @@ function recordCodexNativePolicyAcceptance(dataDir3, verification, accepted) {
|
|
|
55279
55547
|
...verification.attestation ? { attestation: { schema: verification.attestation.schema, peerProcessId: verification.attestation.peerProcessId } } : {}
|
|
55280
55548
|
};
|
|
55281
55549
|
try {
|
|
55282
|
-
|
|
55550
|
+
mkdirSync7(directory2, { recursive: true, mode: 448 });
|
|
55283
55551
|
const stat2 = lstatSync19(directory2);
|
|
55284
55552
|
if (stat2.isSymbolicLink() || !stat2.isDirectory())
|
|
55285
55553
|
throw new Error(`the receipt directory is not a real directory: ${directory2}`);
|
|
@@ -55321,7 +55589,7 @@ var init_codex_native_skill_policy = __esm(() => {
|
|
|
55321
55589
|
|
|
55322
55590
|
// src/lib/codex-semantic-cache-witness.ts
|
|
55323
55591
|
import { createHash as createHash21 } from "crypto";
|
|
55324
|
-
import { constants as constants13, closeSync as closeSync12, fstatSync as fstatSync12, lstatSync as lstatSync20, openSync as openSync12, readSync as readSync9, readdirSync as
|
|
55592
|
+
import { constants as constants13, closeSync as closeSync12, fstatSync as fstatSync12, lstatSync as lstatSync20, openSync as openSync12, readSync as readSync9, readdirSync as readdirSync9, realpathSync as realpathSync8 } from "fs";
|
|
55325
55593
|
import { basename as basename11, dirname as dirname18, isAbsolute as isAbsolute20, join as join28, relative as relative7, resolve as resolve19, sep as sep10 } from "path";
|
|
55326
55594
|
function codexLocalMarketplaceMapsPlugin(text2, marketplace, plugin) {
|
|
55327
55595
|
try {
|
|
@@ -55478,7 +55746,7 @@ function assertCanonicalDirectory(path) {
|
|
|
55478
55746
|
function walkSafeTree(path, state, depth = 0, root = path) {
|
|
55479
55747
|
if (depth > 64 || ++state.entries > 16384)
|
|
55480
55748
|
refuse4();
|
|
55481
|
-
const names =
|
|
55749
|
+
const names = readdirSync9(path).sort();
|
|
55482
55750
|
const files = [];
|
|
55483
55751
|
for (const name of names) {
|
|
55484
55752
|
if (!name || name === "." || name === ".." || name.includes(sep10) || ++state.entries > 16384)
|
|
@@ -55624,7 +55892,7 @@ function appOnlyParentProjection(cacheRoot, parents2, read2) {
|
|
|
55624
55892
|
} catch {
|
|
55625
55893
|
refuse4();
|
|
55626
55894
|
}
|
|
55627
|
-
const versions =
|
|
55895
|
+
const versions = readdirSync9(parent.pluginParent).filter((name) => name !== ".codex-remote-plugin-install.json");
|
|
55628
55896
|
if (!versions.length || versions.length > 4096)
|
|
55629
55897
|
refuse4();
|
|
55630
55898
|
const materializations = versions.map((version) => {
|
|
@@ -55750,7 +56018,7 @@ function reviewedHookParentProjection(cacheRoot, parents2, read2) {
|
|
|
55750
56018
|
if (createHash21("sha256").update(marketplaceText).digest("hex") !== parent.marketplaceSha256 || !codexLocalMarketplaceMapsPlugin(marketplaceText, parts[0], parent.namespace))
|
|
55751
56019
|
refuse4();
|
|
55752
56020
|
}
|
|
55753
|
-
const materializations =
|
|
56021
|
+
const materializations = readdirSync9(parent.pluginParent).filter((name) => name !== ".codex-remote-plugin-install.json").map((version) => {
|
|
55754
56022
|
if (!/^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/.test(version))
|
|
55755
56023
|
refuse4();
|
|
55756
56024
|
const root = join28(parent.pluginParent, version), stat2 = lstatSync20(root, { throwIfNoEntry: false });
|
|
@@ -55784,14 +56052,14 @@ function assertParents(cacheRoot, controls, appOnlyParents, hookParents, files,
|
|
|
55784
56052
|
refuse4();
|
|
55785
56053
|
actual.add(join28(cacheRoot, parts[0], parts[1]));
|
|
55786
56054
|
}
|
|
55787
|
-
const actualMarkets =
|
|
56055
|
+
const actualMarkets = readdirSync9(cacheRoot);
|
|
55788
56056
|
if (actualMarkets.length !== expectedMarkets.size || actualMarkets.some((market) => !expectedMarkets.has(market)))
|
|
55789
56057
|
refuse4();
|
|
55790
56058
|
for (const market of actualMarkets) {
|
|
55791
56059
|
const marketPath = join28(cacheRoot, market), marketStat = lstatSync20(marketPath);
|
|
55792
56060
|
if (!identifier5(market) || !marketStat.isDirectory() || marketStat.isSymbolicLink())
|
|
55793
56061
|
refuse4();
|
|
55794
|
-
for (const plugin of
|
|
56062
|
+
for (const plugin of readdirSync9(marketPath)) {
|
|
55795
56063
|
const parent = join28(marketPath, plugin), stat2 = lstatSync20(parent);
|
|
55796
56064
|
if (!identifier5(plugin) || !stat2.isDirectory() || stat2.isSymbolicLink())
|
|
55797
56065
|
refuse4();
|
|
@@ -55843,7 +56111,7 @@ function assertSkillMaterializations(cacheRoot, controls, files, read2) {
|
|
|
55843
56111
|
const expectedNames = new Set(rows.map((row) => row.name));
|
|
55844
56112
|
if (expectedNames.size !== rows.length)
|
|
55845
56113
|
refuse4();
|
|
55846
|
-
const entries =
|
|
56114
|
+
const entries = readdirSync9(parent);
|
|
55847
56115
|
let roots = 0;
|
|
55848
56116
|
for (const entry of entries) {
|
|
55849
56117
|
if (entry === ".codex-remote-plugin-install.json")
|
|
@@ -56198,7 +56466,7 @@ var init_managed_policy = __esm(() => {
|
|
|
56198
56466
|
|
|
56199
56467
|
// src/lib/agent-bridge.ts
|
|
56200
56468
|
import { createHash as createHash22 } from "crypto";
|
|
56201
|
-
import { lstatSync as lstatSync23, readFileSync as readFileSync17, readdirSync as
|
|
56469
|
+
import { lstatSync as lstatSync23, readFileSync as readFileSync17, readdirSync as readdirSync10 } from "fs";
|
|
56202
56470
|
import { join as join31 } from "path";
|
|
56203
56471
|
function isOwnedCliBridge(path, expectedPaths) {
|
|
56204
56472
|
if (!expectedPaths.includes(path))
|
|
@@ -56206,7 +56474,7 @@ function isOwnedCliBridge(path, expectedPaths) {
|
|
|
56206
56474
|
try {
|
|
56207
56475
|
if (!lstatSync23(path).isDirectory())
|
|
56208
56476
|
return false;
|
|
56209
|
-
if (JSON.stringify(
|
|
56477
|
+
if (JSON.stringify(readdirSync10(path).sort()) !== JSON.stringify(Object.keys(CLI_BRIDGE_FILES).sort()))
|
|
56210
56478
|
return false;
|
|
56211
56479
|
return Object.entries(CLI_BRIDGE_FILES).every(([name, content]) => {
|
|
56212
56480
|
const file = join31(path, name), stat2 = lstatSync23(file);
|
|
@@ -56641,7 +56909,7 @@ var init_hook_diagnostics = __esm(() => {
|
|
|
56641
56909
|
});
|
|
56642
56910
|
|
|
56643
56911
|
// src/lib/agent-sumi.ts
|
|
56644
|
-
import { spawnSync as
|
|
56912
|
+
import { spawnSync as spawnSync4 } from "child_process";
|
|
56645
56913
|
import { accessSync as accessSync2, constants as constants15, existsSync as existsSync12, lstatSync as lstatSync24, realpathSync as realpathSync9, statSync as statSync10 } from "fs";
|
|
56646
56914
|
import { delimiter as delimiter2, isAbsolute as isAbsolute21, join as join32, resolve as resolve21 } from "path";
|
|
56647
56915
|
function recordWithKeys(value, keys2) {
|
|
@@ -56715,7 +56983,7 @@ function sumiPathPlan(home, cwd2 = process.cwd(), env3 = process.env) {
|
|
|
56715
56983
|
childEnv[key2] = env3[key2];
|
|
56716
56984
|
let child2;
|
|
56717
56985
|
try {
|
|
56718
|
-
child2 =
|
|
56986
|
+
child2 = spawnSync4(executable2, ["--json", "--home", resolve21(home), "--cwd", resolve21(cwd2)], {
|
|
56719
56987
|
cwd: resolve21(cwd2),
|
|
56720
56988
|
env: childEnv,
|
|
56721
56989
|
encoding: "buffer",
|
|
@@ -57296,8 +57564,8 @@ function assertPinnedLauncherShell() {
|
|
|
57296
57564
|
if (!stat2.isFile() || (stat2.mode & 73) === 0)
|
|
57297
57565
|
throw new Error("LAUNCHER_SHELL_UNSUPPORTED");
|
|
57298
57566
|
}
|
|
57299
|
-
const
|
|
57300
|
-
if (
|
|
57567
|
+
const probe2 = Bun.spawnSync(["/bin/sh", "-p", "-c", "exit 0"], { env: {}, stdin: "ignore", stdout: "ignore", stderr: "ignore" });
|
|
57568
|
+
if (probe2.exitCode !== 0)
|
|
57301
57569
|
throw new Error("LAUNCHER_SHELL_UNSUPPORTED");
|
|
57302
57570
|
}
|
|
57303
57571
|
var PINNED_LAUNCHER_SCHEMA = "hasna-skills-pinned-launcher-v2", LAUNCH_CWD_VARIABLE3 = "HASNA_SKILLS_LAUNCH_CWD", PINNED_LAUNCHER_BUN_FLAGS2, PINNED_LAUNCHER_ENV_NAMES, PINNED_LAUNCHER_ENV_PREFIXES, ENV_NAME, ENV_PREFIX, ENV_EXACT, COMMAND_LINE, PINNED_LAUNCHER_MAX_BYTES;
|
|
@@ -57346,7 +57614,7 @@ var init_runtime_launcher = __esm(() => {
|
|
|
57346
57614
|
|
|
57347
57615
|
// src/lib/retained-review-artifacts.ts
|
|
57348
57616
|
import { createHash as createHash25 } from "crypto";
|
|
57349
|
-
import { constants as constants18, closeSync as closeSync16, fstatSync as fstatSync16, fsyncSync as fsyncSync6, lstatSync as lstatSync27, mkdirSync as
|
|
57617
|
+
import { constants as constants18, closeSync as closeSync16, fstatSync as fstatSync16, fsyncSync as fsyncSync6, lstatSync as lstatSync27, mkdirSync as mkdirSync8, openSync as openSync16, readSync as readSync12, writeSync as writeSync4 } from "fs";
|
|
57350
57618
|
import { dirname as dirname21, isAbsolute as isAbsolute24, join as join33, resolve as resolve23, sep as sep12 } from "path";
|
|
57351
57619
|
function keys2(value, names) {
|
|
57352
57620
|
return Boolean(value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === names.length && names.every((name) => Object.hasOwn(value, name)));
|
|
@@ -57467,7 +57735,7 @@ function writeReviewArtifactExclusive(change) {
|
|
|
57467
57735
|
for (let parent = dirname21(change.path);!lstatSync27(parent, { throwIfNoEntry: false }); parent = dirname21(parent))
|
|
57468
57736
|
missing2.push(parent);
|
|
57469
57737
|
for (const parent of missing2.reverse())
|
|
57470
|
-
|
|
57738
|
+
mkdirSync8(parent, { mode: 448 });
|
|
57471
57739
|
safe4(change.path);
|
|
57472
57740
|
privateStore(change.artifact.storeRoot);
|
|
57473
57741
|
for (let parent = dirname21(change.path);parent !== change.artifact.storeRoot; parent = dirname21(parent)) {
|
|
@@ -57510,7 +57778,7 @@ var init_retained_review_artifacts = __esm(() => {
|
|
|
57510
57778
|
// src/lib/agent-integration.ts
|
|
57511
57779
|
import { createHash as createHash26, randomUUID as randomUUID7 } from "crypto";
|
|
57512
57780
|
import { isDeepStrictEqual as isDeepStrictEqual9 } from "util";
|
|
57513
|
-
import { existsSync as existsSync13, lstatSync as lstatSync28, statSync as statSync11, mkdirSync as
|
|
57781
|
+
import { existsSync as existsSync13, lstatSync as lstatSync28, statSync as statSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync19, readdirSync as readdirSync11, opendirSync as opendirSync4, readlinkSync as readlinkSync7, realpathSync as realpathSync11, renameSync as renameSync4, rmdirSync as rmdirSync3, writeFileSync as writeFileSync6, unlinkSync as unlinkSync5, chmodSync, openSync as openSync17, closeSync as closeSync17, fsyncSync as fsyncSync7, fstatSync as fstatSync17, readSync as readSync13, constants as constants19, linkSync as linkSync3 } from "fs";
|
|
57514
57782
|
import { basename as basename12, dirname as dirname22, join as join34, resolve as resolve24, relative as relative8, isAbsolute as isAbsolute25, sep as sep13 } from "path";
|
|
57515
57783
|
import { homedir as homedir3 } from "os";
|
|
57516
57784
|
function nativeAgentRoot(home, agent, cwd2 = process.cwd()) {
|
|
@@ -57731,7 +57999,7 @@ function treeHash(root) {
|
|
|
57731
57999
|
const rel = relative8(root, path);
|
|
57732
58000
|
if (stat2.isDirectory()) {
|
|
57733
58001
|
hash3.update(`d\x00${rel}\x00`);
|
|
57734
|
-
for (const name of
|
|
58002
|
+
for (const name of readdirSync11(path).sort())
|
|
57735
58003
|
visit2(join34(path, name));
|
|
57736
58004
|
return;
|
|
57737
58005
|
}
|
|
@@ -58592,7 +58860,7 @@ function verifyCoordinatedDiscovery(binding, home, aliases, executable2) {
|
|
|
58592
58860
|
}
|
|
58593
58861
|
function atomicWrite2(path, content) {
|
|
58594
58862
|
assertSafePath(path);
|
|
58595
|
-
|
|
58863
|
+
mkdirSync9(dirname22(path), { recursive: true, mode: 448 });
|
|
58596
58864
|
const temporary = `${path}.skills-${randomUUID7()}`;
|
|
58597
58865
|
try {
|
|
58598
58866
|
writeFileSync6(temporary, content, { mode: 384, flag: "wx" });
|
|
@@ -58760,7 +59028,7 @@ function planCodexSemanticCacheWitnessUpgrade(options) {
|
|
|
58760
59028
|
throw new Error("Local marketplace hook parent is not enabled in the unchanged Codex settings");
|
|
58761
59029
|
identity6 = { role: "reviewed-hook", pluginId: pluginId2, namespace: parts[1], pluginParent: parent, installation: "local-marketplace", marketplaceSourcePath: source.path, marketplaceSha256: source.sha256 };
|
|
58762
59030
|
}
|
|
58763
|
-
const versions =
|
|
59031
|
+
const versions = readdirSync11(parent).filter((name) => name !== ".codex-remote-plugin-install.json");
|
|
58764
59032
|
if (!versions.length || versions.length > 4096)
|
|
58765
59033
|
throw new Error("Reviewed native-hook parent has no bounded materializations");
|
|
58766
59034
|
for (const version of versions) {
|
|
@@ -58854,9 +59122,10 @@ function applyAgentIntegration(plan, options = {}) {
|
|
|
58854
59122
|
const alias = plan.rootAliases?.find((item) => item.agent === "codex" && (change.path === item.target || change.path.startsWith(item.target + "/")));
|
|
58855
59123
|
return lexical ? [lexical] : alias ? [alias.alias] : [];
|
|
58856
59124
|
});
|
|
58857
|
-
return withCodexCorpusWrite(roots, (assertCurrent) => applyAgentIntegrationUnlocked(plan, options, assertCurrent), options);
|
|
59125
|
+
return withCodexCorpusWrite(roots, (assertCurrent, admission) => applyAgentIntegrationUnlocked(plan, options, assertCurrent, admission), options);
|
|
58858
59126
|
}
|
|
58859
|
-
function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
|
|
59127
|
+
function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent, admission) {
|
|
59128
|
+
const fallback = codexAdmissionReceipt(admission);
|
|
58860
59129
|
for (const source of plan.reviewArtifactSources ?? [])
|
|
58861
59130
|
verifyReviewArtifactOriginal(source.path, source.sha256);
|
|
58862
59131
|
for (const source of plan.observedNativeSources ?? [])
|
|
@@ -58920,10 +59189,10 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
|
|
|
58920
59189
|
recheckRootAliases(aliases);
|
|
58921
59190
|
for (const agent of plan.retainedReviewChecks?.agents ?? [])
|
|
58922
59191
|
assertManagedAgentBridge(agent, { ...plan.retainedReviewChecks, dataDir: plan.dataDir });
|
|
58923
|
-
return { changed: [], backups, ...aliases.length ? { rootAliases: aliases } : {} };
|
|
59192
|
+
return { changed: [], backups, ...aliases.length ? { rootAliases: aliases } : {}, ...fallback };
|
|
58924
59193
|
}
|
|
58925
59194
|
assertSafePath(backupRoot);
|
|
58926
|
-
|
|
59195
|
+
mkdirSync9(backupRoot, { recursive: true, mode: 448 });
|
|
58927
59196
|
chmodSync(backupRoot, 448);
|
|
58928
59197
|
for (const [index, change] of plan.changes.entries())
|
|
58929
59198
|
if (change.before !== null) {
|
|
@@ -58971,7 +59240,7 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
|
|
|
58971
59240
|
assertManagedAgentBridge(agent, { home: plan.managedAgentChecks.home, dataDir: plan.dataDir, projectDir: plan.managedAgentChecks.projectDir ?? plan.managedAgentChecks.home });
|
|
58972
59241
|
for (const agent of plan.retainedReviewChecks?.agents ?? [])
|
|
58973
59242
|
assertManagedAgentBridge(agent, { ...plan.retainedReviewChecks, dataDir: plan.dataDir });
|
|
58974
|
-
atomicWrite2(join34(backupRoot, "receipt.json"), JSON.stringify({ version: 1, changes: written.map((change) => ({ path: change.path, beforeHash: change.before === null ? null : sha4(change.before), afterHash: sha4(change.after) })), backups, ...plan.cacheWitnessUpgrade ? { cacheWitnessUpgrade: plan.cacheWitnessUpgrade } : {}, ...plan.retainedReviewArtifacts?.length ? { retainedReviewArtifacts: plan.retainedReviewArtifacts.map((item) => ({ path: item.path, ...item.artifact })) } : {}, ...aliases.length ? { rootAliases: aliases } : {} }) + `
|
|
59243
|
+
atomicWrite2(join34(backupRoot, "receipt.json"), JSON.stringify({ version: 1, changes: written.map((change) => ({ path: change.path, beforeHash: change.before === null ? null : sha4(change.before), afterHash: sha4(change.after) })), backups, ...plan.cacheWitnessUpgrade ? { cacheWitnessUpgrade: plan.cacheWitnessUpgrade } : {}, ...plan.retainedReviewArtifacts?.length ? { retainedReviewArtifacts: plan.retainedReviewArtifacts.map((item) => ({ path: item.path, ...item.artifact })) } : {}, ...aliases.length ? { rootAliases: aliases } : {}, ...fallback }) + `
|
|
58975
59244
|
`);
|
|
58976
59245
|
} catch (error) {
|
|
58977
59246
|
assertCurrent();
|
|
@@ -58999,7 +59268,7 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
|
|
|
58999
59268
|
}
|
|
59000
59269
|
throw error;
|
|
59001
59270
|
}
|
|
59002
|
-
return { changed: plan.changes.map((change) => change.path), backups, ...aliases.length ? { rootAliases: aliases } : {} };
|
|
59271
|
+
return { changed: plan.changes.map((change) => change.path), backups, ...aliases.length ? { rootAliases: aliases } : {}, ...fallback };
|
|
59003
59272
|
}
|
|
59004
59273
|
function syncArchiveDirectory(path) {
|
|
59005
59274
|
assertSafePath(path);
|
|
@@ -59039,9 +59308,10 @@ function archiveNativeSkills(inventory, options) {
|
|
|
59039
59308
|
throw new Error("CODEX_CORPUS_ROOT_UNVERIFIED");
|
|
59040
59309
|
return [...new Set([root, owner2].filter((value) => value !== undefined))];
|
|
59041
59310
|
});
|
|
59042
|
-
return withCodexCorpusWrite(roots, (assertCurrent) => archiveNativeSkillsUnlocked(inventory, options, assertCurrent), options);
|
|
59311
|
+
return withCodexCorpusWrite(roots, (assertCurrent, admission) => archiveNativeSkillsUnlocked(inventory, options, assertCurrent, admission), options);
|
|
59043
59312
|
}
|
|
59044
|
-
function archiveNativeSkillsUnlocked(inventory, options, assertCurrent) {
|
|
59313
|
+
function archiveNativeSkillsUnlocked(inventory, options, assertCurrent, admission) {
|
|
59314
|
+
const fallback = codexAdmissionReceipt(admission);
|
|
59045
59315
|
const aliases = [...new Map(inventory.filter((entry) => entry.rootAlias).map((entry) => [entry.rootAlias.alias, entry.rootAlias])).values()];
|
|
59046
59316
|
if (aliases.length && !options.allowRootAliases)
|
|
59047
59317
|
throw new Error("Native migration requires explicit allowRootAliases for agent root aliases");
|
|
@@ -59059,7 +59329,7 @@ function archiveNativeSkillsUnlocked(inventory, options, assertCurrent) {
|
|
|
59059
59329
|
throw new Error(`Native skill changed after planning: ${entry.path}`);
|
|
59060
59330
|
const targetManifest = options.targetManifest ? { schema: options.targetManifest.schema, digest: options.targetManifest.digest, targetCount: options.targetManifest.targets.length } : undefined;
|
|
59061
59331
|
if (!selected.length)
|
|
59062
|
-
return { entries: [], ...targetManifest ? { targetManifest } : {}, ...aliases.length ? { rootAliases: aliases } : {} };
|
|
59332
|
+
return { entries: [], ...targetManifest ? { targetManifest } : {}, ...aliases.length ? { rootAliases: aliases } : {}, ...fallback };
|
|
59063
59333
|
const operationId = randomUUID7(), archiveRoot = join34(options.dataDir ?? getDataDir(), "migration", operationId, "native"), receiptPath = join34(archiveRoot, "receipt.json");
|
|
59064
59334
|
const entries = selected.map((entry, index) => ({
|
|
59065
59335
|
source: entry.vendor ? join34(entry.path, "SKILL.md") : entry.path,
|
|
@@ -59068,7 +59338,7 @@ function archiveNativeSkillsUnlocked(inventory, options, assertCurrent) {
|
|
|
59068
59338
|
...entry.vendor ? { discoveryOnly: true } : {},
|
|
59069
59339
|
status: "planned"
|
|
59070
59340
|
}));
|
|
59071
|
-
const journal = { version: 2, operationId, status: "planned", entries, ...targetManifest ? { targetManifest } : {}, ...aliases.length ? { rootAliases: aliases } : {} };
|
|
59341
|
+
const journal = { version: 2, operationId, status: "planned", entries, ...targetManifest ? { targetManifest } : {}, ...aliases.length ? { rootAliases: aliases } : {}, ...fallback };
|
|
59072
59342
|
const moved = [];
|
|
59073
59343
|
const verifyArchive = (entry) => {
|
|
59074
59344
|
assertSafePath(entry.archive);
|
|
@@ -59082,7 +59352,7 @@ function archiveNativeSkillsUnlocked(inventory, options, assertCurrent) {
|
|
|
59082
59352
|
const created = [];
|
|
59083
59353
|
for (let path = archiveRoot;!existsSync13(path); path = dirname22(path))
|
|
59084
59354
|
created.push(path);
|
|
59085
|
-
|
|
59355
|
+
mkdirSync9(archiveRoot, { recursive: true, mode: 448 });
|
|
59086
59356
|
try {
|
|
59087
59357
|
for (const directory2 of created)
|
|
59088
59358
|
syncArchiveDirectory(directory2);
|
|
@@ -59165,7 +59435,7 @@ function archiveNativeSkillsUnlocked(inventory, options, assertCurrent) {
|
|
|
59165
59435
|
} catch {}
|
|
59166
59436
|
throw new Error(`Native archive failed; inspect the recovery journal at ${receiptPath} before retrying.`, { cause: error });
|
|
59167
59437
|
}
|
|
59168
|
-
return { entries: entries.map(({ status, conflict, ...entry }) => entry), receiptPath, ...targetManifest ? { targetManifest } : {}, ...aliases.length ? { rootAliases: aliases } : {} };
|
|
59438
|
+
return { entries: entries.map(({ status, conflict, ...entry }) => entry), receiptPath, ...targetManifest ? { targetManifest } : {}, ...aliases.length ? { rootAliases: aliases } : {}, ...fallback };
|
|
59169
59439
|
}
|
|
59170
59440
|
function classifiedCodexPluginCacheCopy(entry, cache3, read2, admit) {
|
|
59171
59441
|
try {
|
|
@@ -59574,7 +59844,7 @@ var init_agent_integration = __esm(() => {
|
|
|
59574
59844
|
});
|
|
59575
59845
|
|
|
59576
59846
|
// src/lib/home-migration.ts
|
|
59577
|
-
import { existsSync as existsSync14, mkdirSync as
|
|
59847
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync10, readdirSync as readdirSync12, renameSync as renameSync5, rmSync as rmSync3, statSync as statSync12, writeFileSync as writeFileSync7 } from "fs";
|
|
59578
59848
|
import { join as join35 } from "path";
|
|
59579
59849
|
function layoutMigrationRecordPath(appDir) {
|
|
59580
59850
|
return join35(appDir, SKILLS_CACHE_DIRNAME, LAYOUT_MIGRATION_RECORD);
|
|
@@ -59600,7 +59870,7 @@ function listLegacyFlatSkillDirs(appDir) {
|
|
|
59600
59870
|
return legacy;
|
|
59601
59871
|
let entries = [];
|
|
59602
59872
|
try {
|
|
59603
|
-
entries =
|
|
59873
|
+
entries = readdirSync12(appDir);
|
|
59604
59874
|
} catch {
|
|
59605
59875
|
return legacy;
|
|
59606
59876
|
}
|
|
@@ -59619,7 +59889,7 @@ function createLazyDirs(appDir, created) {
|
|
|
59619
59889
|
for (const name of [LOGS_DIRNAME, OUTPUTS_DIRNAME]) {
|
|
59620
59890
|
const dir = join35(appDir, name);
|
|
59621
59891
|
if (!existsSync14(dir)) {
|
|
59622
|
-
|
|
59892
|
+
mkdirSync10(dir, { recursive: true });
|
|
59623
59893
|
created.push(dir);
|
|
59624
59894
|
}
|
|
59625
59895
|
}
|
|
@@ -59636,7 +59906,7 @@ function migrateOwnerLayout(options = {}) {
|
|
|
59636
59906
|
if (existsSync14(cache3)) {
|
|
59637
59907
|
let entries = [];
|
|
59638
59908
|
try {
|
|
59639
|
-
entries =
|
|
59909
|
+
entries = readdirSync12(cache3);
|
|
59640
59910
|
} catch {}
|
|
59641
59911
|
if (entries.length > 0) {
|
|
59642
59912
|
return {
|
|
@@ -59663,7 +59933,7 @@ function migrateOwnerLayout(options = {}) {
|
|
|
59663
59933
|
if (!existsSync14(dir))
|
|
59664
59934
|
continue;
|
|
59665
59935
|
try {
|
|
59666
|
-
for (const entry of
|
|
59936
|
+
for (const entry of readdirSync12(dir))
|
|
59667
59937
|
collisionNames.add(entry);
|
|
59668
59938
|
} catch {}
|
|
59669
59939
|
}
|
|
@@ -59678,13 +59948,13 @@ function migrateOwnerLayout(options = {}) {
|
|
|
59678
59948
|
}
|
|
59679
59949
|
}
|
|
59680
59950
|
if (existsSync14(cache3)) {
|
|
59681
|
-
|
|
59951
|
+
rmSync3(cache3, { recursive: true, force: true });
|
|
59682
59952
|
}
|
|
59683
59953
|
if (installedPresent) {
|
|
59684
59954
|
renameSync5(installed, cache3);
|
|
59685
59955
|
moved.push(INSTALLED_SKILLS_DIRNAME);
|
|
59686
59956
|
} else {
|
|
59687
|
-
|
|
59957
|
+
mkdirSync10(cache3, { recursive: true });
|
|
59688
59958
|
}
|
|
59689
59959
|
for (const name of legacy) {
|
|
59690
59960
|
renameSync5(join35(appDir, name), join35(cache3, name));
|
|
@@ -59713,12 +59983,12 @@ import {
|
|
|
59713
59983
|
cpSync as cpSync2,
|
|
59714
59984
|
existsSync as existsSync15,
|
|
59715
59985
|
lstatSync as lstatSync29,
|
|
59716
|
-
mkdirSync as
|
|
59717
|
-
mkdtempSync,
|
|
59986
|
+
mkdirSync as mkdirSync11,
|
|
59987
|
+
mkdtempSync as mkdtempSync2,
|
|
59718
59988
|
readFileSync as readFileSync20,
|
|
59719
|
-
readdirSync as
|
|
59989
|
+
readdirSync as readdirSync13,
|
|
59720
59990
|
renameSync as renameSync6,
|
|
59721
|
-
rmSync as
|
|
59991
|
+
rmSync as rmSync4,
|
|
59722
59992
|
statSync as statSync13,
|
|
59723
59993
|
writeFileSync as writeFileSync8
|
|
59724
59994
|
} from "fs";
|
|
@@ -59823,7 +60093,7 @@ function packageSourceRoots(source) {
|
|
|
59823
60093
|
function containsSkillDirectories(path) {
|
|
59824
60094
|
let entries;
|
|
59825
60095
|
try {
|
|
59826
|
-
entries =
|
|
60096
|
+
entries = readdirSync13(path);
|
|
59827
60097
|
} catch {
|
|
59828
60098
|
return false;
|
|
59829
60099
|
}
|
|
@@ -59918,12 +60188,16 @@ function writeManagedAgentSkill(params) {
|
|
|
59918
60188
|
agent: params.agent,
|
|
59919
60189
|
path: result2.path,
|
|
59920
60190
|
action: result2.action,
|
|
59921
|
-
...result2.reason ? { reason: result2.reason } : {}
|
|
60191
|
+
...result2.reason ? { reason: result2.reason } : {},
|
|
60192
|
+
...result2.nativeAdmission ? { nativeAdmission: result2.nativeAdmission, nativeAdmissionProbe: result2.nativeAdmissionProbe } : {}
|
|
59922
60193
|
};
|
|
59923
60194
|
}
|
|
59924
60195
|
function writeManagedSkillDir(dir, skillMd, options) {
|
|
59925
60196
|
const root = options.dryRun ? undefined : codexCorpusRootForPath(dir);
|
|
59926
|
-
return withCodexCorpusWrite(root ? [root] : [], (assertCurrent) =>
|
|
60197
|
+
return withCodexCorpusWrite(root ? [root] : [], (assertCurrent, admission) => {
|
|
60198
|
+
const result2 = writeManagedSkillDirUnlocked(dir, skillMd, options, assertCurrent);
|
|
60199
|
+
return { ...result2, ...codexAdmissionReceipt(admission) };
|
|
60200
|
+
}, options);
|
|
59927
60201
|
}
|
|
59928
60202
|
function writeManagedSkillDirUnlocked(dir, skillMd, options, assertCurrent) {
|
|
59929
60203
|
const skillMdPath = join36(dir, "SKILL.md");
|
|
@@ -59964,8 +60238,8 @@ function writeManagedSkillDirUnlocked(dir, skillMd, options, assertCurrent) {
|
|
|
59964
60238
|
if (options.dryRun)
|
|
59965
60239
|
return { action, path: skillMdPath };
|
|
59966
60240
|
const parentDir = dirname23(dir);
|
|
59967
|
-
|
|
59968
|
-
const transactionDir =
|
|
60241
|
+
mkdirSync11(parentDir, { recursive: true });
|
|
60242
|
+
const transactionDir = mkdtempSync2(join36(parentDir, `.hasna-skills-write-${basename13(dir)}-`));
|
|
59969
60243
|
const candidateDir = join36(transactionDir, "candidate");
|
|
59970
60244
|
const backupDir = join36(transactionDir, "backup");
|
|
59971
60245
|
const candidateSkillMdPath = join36(candidateDir, "SKILL.md");
|
|
@@ -59983,7 +60257,7 @@ function writeManagedSkillDirUnlocked(dir, skillMd, options, assertCurrent) {
|
|
|
59983
60257
|
if (options.resourceDir) {
|
|
59984
60258
|
cpSync2(options.resourceDir, candidateDir, { recursive: true, force: true });
|
|
59985
60259
|
} else {
|
|
59986
|
-
|
|
60260
|
+
mkdirSync11(candidateDir, { recursive: true });
|
|
59987
60261
|
}
|
|
59988
60262
|
writeFileSync8(candidateSkillMdPath, skillMd.endsWith(`
|
|
59989
60263
|
`) ? skillMd : `${skillMd}
|
|
@@ -60007,7 +60281,7 @@ function writeManagedSkillDirUnlocked(dir, skillMd, options, assertCurrent) {
|
|
|
60007
60281
|
try {
|
|
60008
60282
|
assertCurrent();
|
|
60009
60283
|
if (existsSync15(dir))
|
|
60010
|
-
|
|
60284
|
+
rmSync4(dir, { recursive: true, force: true });
|
|
60011
60285
|
renameDirectory(backupDir, dir);
|
|
60012
60286
|
originalMoved = false;
|
|
60013
60287
|
} catch (rollbackError) {
|
|
@@ -60020,7 +60294,7 @@ function writeManagedSkillDirUnlocked(dir, skillMd, options, assertCurrent) {
|
|
|
60020
60294
|
if (!preserveTransaction) {
|
|
60021
60295
|
try {
|
|
60022
60296
|
assertCurrent();
|
|
60023
|
-
|
|
60297
|
+
rmSync4(transactionDir, { recursive: true, force: true });
|
|
60024
60298
|
} catch {}
|
|
60025
60299
|
}
|
|
60026
60300
|
}
|
|
@@ -60081,7 +60355,7 @@ var init_skill_aliases = __esm(() => {
|
|
|
60081
60355
|
});
|
|
60082
60356
|
|
|
60083
60357
|
// src/lib/project-state.ts
|
|
60084
|
-
import { existsSync as existsSync16, mkdirSync as
|
|
60358
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync12, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
|
|
60085
60359
|
import { join as join37 } from "path";
|
|
60086
60360
|
function getProjectStateDir(targetDir = process.cwd()) {
|
|
60087
60361
|
return join37(targetDir, SKILLS_PROJECT_DIR);
|
|
@@ -60115,7 +60389,7 @@ function ensureProjectConfig(targetDir = process.cwd()) {
|
|
|
60115
60389
|
}
|
|
60116
60390
|
function saveProjectConfig(config, targetDir = process.cwd()) {
|
|
60117
60391
|
const dir = getProjectStateDir(targetDir);
|
|
60118
|
-
|
|
60392
|
+
mkdirSync12(dir, { recursive: true });
|
|
60119
60393
|
const normalized2 = normalizeProjectConfig({ ...config, updatedAt: new Date().toISOString() });
|
|
60120
60394
|
writeFileSync9(getProjectConfigPath(targetDir), JSON.stringify(normalized2, null, 2) + `
|
|
60121
60395
|
`);
|
|
@@ -60248,7 +60522,7 @@ __export(exports_installer, {
|
|
|
60248
60522
|
AGENT_TARGETS: () => AGENT_TARGETS,
|
|
60249
60523
|
AGENT_LABELS: () => AGENT_LABELS
|
|
60250
60524
|
});
|
|
60251
|
-
import { existsSync as existsSync17, readFileSync as readFileSync23, rmSync as
|
|
60525
|
+
import { existsSync as existsSync17, readFileSync as readFileSync23, rmSync as rmSync5 } from "fs";
|
|
60252
60526
|
import { join as join38 } from "path";
|
|
60253
60527
|
import { homedir as homedir5 } from "os";
|
|
60254
60528
|
function getSkillPath(name) {
|
|
@@ -60458,15 +60732,20 @@ function installSkillForAgent(name, options, generateSkillMd) {
|
|
|
60458
60732
|
codexCommand: options.codexCommand,
|
|
60459
60733
|
codexSha256: options.codexSha256
|
|
60460
60734
|
});
|
|
60735
|
+
const fallback = result2.nativeAdmission ? { nativeAdmission: result2.nativeAdmission, nativeAdmissionProbe: result2.nativeAdmissionProbe } : {};
|
|
60461
60736
|
if (result2.action === "skip") {
|
|
60462
|
-
return { skill: canonicalName, success: false, error: result2.reason ?? "skipped", path: result2.path };
|
|
60737
|
+
return { skill: canonicalName, success: false, error: result2.reason ?? "skipped", path: result2.path, ...fallback };
|
|
60463
60738
|
}
|
|
60464
|
-
return { skill: canonicalName, success: true, path: result2.path };
|
|
60739
|
+
return { skill: canonicalName, success: true, path: result2.path, ...fallback };
|
|
60465
60740
|
}
|
|
60466
60741
|
function removeSkillForAgent(name, options) {
|
|
60742
|
+
const record5 = codexAdmissionRecord(options);
|
|
60467
60743
|
const dir = getAgentSkillPath(name, options.agent, options.scope ?? "global", options.projectDir);
|
|
60468
60744
|
const root = codexCorpusRootForPath(dir);
|
|
60469
|
-
return withCodexCorpusWrite(root ? [root] : [], () =>
|
|
60745
|
+
return withCodexCorpusWrite(root ? [root] : [], (_assertCurrent, admission) => {
|
|
60746
|
+
record5.deliver(admission);
|
|
60747
|
+
return removeSkillForAgentUnlocked(name, options);
|
|
60748
|
+
}, options, record5.policy);
|
|
60470
60749
|
}
|
|
60471
60750
|
function removeSkillForAgentUnlocked(name, options) {
|
|
60472
60751
|
const canonicalName = getCanonicalSkillName(name);
|
|
@@ -60474,7 +60753,7 @@ function removeSkillForAgentUnlocked(name, options) {
|
|
|
60474
60753
|
const dir = getAgentSkillPath(canonicalName, options.agent, scope, options.projectDir);
|
|
60475
60754
|
if (!hasSkillsOwnershipMarker(dir))
|
|
60476
60755
|
return false;
|
|
60477
|
-
|
|
60756
|
+
rmSync5(dir, { recursive: true, force: true });
|
|
60478
60757
|
return true;
|
|
60479
60758
|
}
|
|
60480
60759
|
function resolveAgentSkillMd(name, generateSkillMd) {
|
|
@@ -60988,6 +61267,118 @@ var init_skillinfo = __esm(() => {
|
|
|
60988
61267
|
GENERIC_ENV_PATTERN = /\b((?:OPENAI|ANTHROPIC|GEMINI|XAI|ELEVENLABS|DEEPGRAM|REPLICATE|FAL|STABILITY|EXA|FIRECRAWL|TWILIO|SENDGRID|RESEND|SLACK|DISCORD|NOTION|LINEAR|GITHUB|AWS|GOOGLE|CLOUDFLARE|VERCEL|SUPABASE|STRIPE)_[A-Z_]+)\b/g;
|
|
60989
61268
|
});
|
|
60990
61269
|
|
|
61270
|
+
// src/lib/search.ts
|
|
61271
|
+
function editDistance(a, b) {
|
|
61272
|
+
if (a === b)
|
|
61273
|
+
return 0;
|
|
61274
|
+
if (a.length === 0)
|
|
61275
|
+
return b.length;
|
|
61276
|
+
if (b.length === 0)
|
|
61277
|
+
return a.length;
|
|
61278
|
+
const prev = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
61279
|
+
const curr = new Array(b.length + 1);
|
|
61280
|
+
for (let i = 1;i <= a.length; i++) {
|
|
61281
|
+
curr[0] = i;
|
|
61282
|
+
for (let j = 1;j <= b.length; j++) {
|
|
61283
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
61284
|
+
curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
|
|
61285
|
+
}
|
|
61286
|
+
prev.splice(0, prev.length, ...curr);
|
|
61287
|
+
}
|
|
61288
|
+
return prev[b.length];
|
|
61289
|
+
}
|
|
61290
|
+
function fuzzyMatchScore(word, target) {
|
|
61291
|
+
if (target.includes(word))
|
|
61292
|
+
return 1;
|
|
61293
|
+
const tokens = target.split(/[\s\-_]+/).filter(Boolean);
|
|
61294
|
+
for (const token of tokens) {
|
|
61295
|
+
if (token.startsWith(word))
|
|
61296
|
+
return 0.6;
|
|
61297
|
+
}
|
|
61298
|
+
if (word.length >= 3) {
|
|
61299
|
+
const maxDist = word.length <= 3 ? 1 : 2;
|
|
61300
|
+
for (const token of tokens) {
|
|
61301
|
+
if (Math.abs(token.length - word.length) <= maxDist) {
|
|
61302
|
+
const dist = editDistance(word, token);
|
|
61303
|
+
if (dist <= maxDist)
|
|
61304
|
+
return 0.4;
|
|
61305
|
+
}
|
|
61306
|
+
}
|
|
61307
|
+
}
|
|
61308
|
+
return 0;
|
|
61309
|
+
}
|
|
61310
|
+
function searchSkills(query, registry = loadRegistry()) {
|
|
61311
|
+
const words2 = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
61312
|
+
if (words2.length === 0)
|
|
61313
|
+
return [];
|
|
61314
|
+
const scored = [];
|
|
61315
|
+
for (const skill of registry) {
|
|
61316
|
+
const nameLower = skill.name.toLowerCase();
|
|
61317
|
+
const displayNameLower = skill.displayName.toLowerCase();
|
|
61318
|
+
const descriptionLower = skill.description.toLowerCase();
|
|
61319
|
+
const tagsLower = skill.tags.map((t2) => t2.toLowerCase());
|
|
61320
|
+
const tagsCombined = tagsLower.join(" ");
|
|
61321
|
+
let score = 0;
|
|
61322
|
+
let allWordsMatch = true;
|
|
61323
|
+
for (const word of words2) {
|
|
61324
|
+
let wordScore = 0;
|
|
61325
|
+
const nameMatch = fuzzyMatchScore(word, nameLower);
|
|
61326
|
+
if (nameMatch > 0)
|
|
61327
|
+
wordScore += 10 * nameMatch;
|
|
61328
|
+
const displayMatch = fuzzyMatchScore(word, displayNameLower);
|
|
61329
|
+
if (displayMatch > 0)
|
|
61330
|
+
wordScore += 7 * displayMatch;
|
|
61331
|
+
const tagMatch = Math.max(...tagsLower.map((t2) => fuzzyMatchScore(word, t2)), fuzzyMatchScore(word, tagsCombined));
|
|
61332
|
+
if (tagMatch > 0)
|
|
61333
|
+
wordScore += 5 * tagMatch;
|
|
61334
|
+
const descMatch = fuzzyMatchScore(word, descriptionLower);
|
|
61335
|
+
if (descMatch > 0)
|
|
61336
|
+
wordScore += 2 * descMatch;
|
|
61337
|
+
if (wordScore === 0) {
|
|
61338
|
+
allWordsMatch = false;
|
|
61339
|
+
break;
|
|
61340
|
+
}
|
|
61341
|
+
score += wordScore;
|
|
61342
|
+
}
|
|
61343
|
+
if (allWordsMatch && score > 0) {
|
|
61344
|
+
scored.push({ skill, score });
|
|
61345
|
+
}
|
|
61346
|
+
}
|
|
61347
|
+
scored.sort((a, b) => b.score - a.score);
|
|
61348
|
+
return scored.map((s) => s.skill);
|
|
61349
|
+
}
|
|
61350
|
+
function findCloseSkillNames(query, names, maxResults = 3) {
|
|
61351
|
+
if (maxResults <= 0)
|
|
61352
|
+
return [];
|
|
61353
|
+
const q = query.trim().toLowerCase();
|
|
61354
|
+
if (q.length === 0)
|
|
61355
|
+
return [];
|
|
61356
|
+
const tokens = q.split("-").filter(Boolean);
|
|
61357
|
+
const ranked = [];
|
|
61358
|
+
if (q.length >= 3) {
|
|
61359
|
+
for (const name of names) {
|
|
61360
|
+
const candidate = name.toLowerCase();
|
|
61361
|
+
const rank = candidate === q ? 0 : candidate.endsWith(`-${q}`) || candidate.startsWith(`${q}-`) ? 1 : tokens.length > 1 && tokens.every((token) => candidate.split("-").includes(token)) ? 2 : undefined;
|
|
61362
|
+
if (rank !== undefined)
|
|
61363
|
+
ranked.push([name, rank]);
|
|
61364
|
+
}
|
|
61365
|
+
}
|
|
61366
|
+
ranked.sort((a, b) => a[1] - b[1] || a[0].length - b[0].length || a[0].localeCompare(b[0]));
|
|
61367
|
+
const found = ranked.slice(0, maxResults).map(([name]) => name);
|
|
61368
|
+
if (found.length === maxResults)
|
|
61369
|
+
return found;
|
|
61370
|
+
const taken = new Set(found);
|
|
61371
|
+
const threshold = Math.max(3, Math.floor(q.length / 2));
|
|
61372
|
+
const byDistance = names.filter((name) => !taken.has(name)).map((name) => ({ name, distance: editDistance(q, name.toLowerCase()) })).filter((entry) => entry.distance <= threshold).sort((a, b) => a.distance - b.distance || a.name.localeCompare(b.name));
|
|
61373
|
+
return [...found, ...byDistance.slice(0, maxResults - found.length).map((entry) => entry.name)];
|
|
61374
|
+
}
|
|
61375
|
+
function findSimilarSkills(query, maxResults = 3, registry = loadRegistry()) {
|
|
61376
|
+
return findCloseSkillNames(query, registry.map((skill) => skill.name), maxResults);
|
|
61377
|
+
}
|
|
61378
|
+
var init_search = __esm(() => {
|
|
61379
|
+
init_registry();
|
|
61380
|
+
});
|
|
61381
|
+
|
|
60991
61382
|
// src/lib/selected-document.ts
|
|
60992
61383
|
function readSelectedDocument(entries, file) {
|
|
60993
61384
|
const entry = file !== undefined ? entries.find((candidate) => candidate.path === file) : DOCUMENT_PATHS.map((path) => entries.find((candidate) => candidate.path === path && candidate.bytes.length > 0)).find(Boolean);
|
|
@@ -61108,11 +61499,30 @@ function exactProfileSelection(spec, profile) {
|
|
|
61108
61499
|
const at2 = spec.lastIndexOf("@");
|
|
61109
61500
|
const slug = at2 > 0 ? spec.slice(0, at2) : spec;
|
|
61110
61501
|
const version = at2 > 0 ? spec.slice(at2 + 1) : undefined;
|
|
61111
|
-
const
|
|
61112
|
-
if (
|
|
61113
|
-
throw new SkillSelectionError("SKILL_NOT_SELECTED",
|
|
61502
|
+
const named = profile.selections.filter((entry) => entry.slug === slug || entry.aliases?.includes(slug));
|
|
61503
|
+
if (version === "")
|
|
61504
|
+
throw new SkillSelectionError("SKILL_NOT_SELECTED", emptyVersionRefusal(spec));
|
|
61505
|
+
if (named.length === 0)
|
|
61506
|
+
throw new SkillSelectionError("SKILL_NOT_SELECTED", unknownNameRefusal(slug, profile));
|
|
61507
|
+
const selection = version === undefined ? named[0] : named.find((entry) => entry.version === version);
|
|
61508
|
+
if (!selection)
|
|
61509
|
+
throw new SkillSelectionError("SKILL_NOT_SELECTED", wrongVersionRefusal(slug, version, named));
|
|
61114
61510
|
return selection;
|
|
61115
61511
|
}
|
|
61512
|
+
function emptyVersionRefusal(spec) {
|
|
61513
|
+
return `The requested name '${spec}' has an empty version. ${ACCEPTED_FORM}`;
|
|
61514
|
+
}
|
|
61515
|
+
function wrongVersionRefusal(slug, version, named) {
|
|
61516
|
+
const versions = [...new Set(named.map((entry) => entry.version))].sort();
|
|
61517
|
+
const canonical9 = named[0].slug;
|
|
61518
|
+
return `Skill '${slug}' is selected at version '${versions.join("', '")}', but '${version}' was requested. ` + `Accepted form: '${canonical9}@${versions[0]}'.`;
|
|
61519
|
+
}
|
|
61520
|
+
function unknownNameRefusal(slug, profile) {
|
|
61521
|
+
const names = profile.selections.flatMap((entry) => [entry.slug, ...entry.aliases ?? []]);
|
|
61522
|
+
const close = findCloseSkillNames(slug, names);
|
|
61523
|
+
const hint = close.length > 0 ? ` Did you mean: ${close.join(", ")}?` : "";
|
|
61524
|
+
return `Skill '${slug}' is not selected by this Skills profile or project lock.${hint} ` + `Read the accepted names with 'skills search <term>' or 'skills list --all --json'; accept one with 'skills pin <name>'. ${ACCEPTED_FORM}`;
|
|
61525
|
+
}
|
|
61116
61526
|
async function loadSelectedSkill(spec, profileId, options = {}) {
|
|
61117
61527
|
const context = await resolveSelectionContext(profileId, options);
|
|
61118
61528
|
const selection = exactProfileSelection(spec, context.receipt.profile);
|
|
@@ -61157,9 +61567,11 @@ async function selectedSkillRequirements(spec, profileId, options = {}) {
|
|
|
61157
61567
|
}
|
|
61158
61568
|
return { ...getSkillRequirementsFromContent(selection.slug, texts, dependencies), selection };
|
|
61159
61569
|
}
|
|
61570
|
+
var ACCEPTED_FORM = "Accepted form: '<slug>' or '<slug>@<version>'.";
|
|
61160
61571
|
var init_selection_resolver = __esm(() => {
|
|
61161
61572
|
init_profile_client();
|
|
61162
61573
|
init_skillinfo();
|
|
61574
|
+
init_search();
|
|
61163
61575
|
init_selected_document();
|
|
61164
61576
|
init_selection_cache();
|
|
61165
61577
|
});
|
|
@@ -62189,7 +62601,7 @@ var init_codex_hook_discovery_recovery = __esm(() => {
|
|
|
62189
62601
|
|
|
62190
62602
|
// src/lib/agent-discovery.ts
|
|
62191
62603
|
import { createHash as createHash29 } from "crypto";
|
|
62192
|
-
import { lstatSync as lstatSync32, readFileSync as readFileSync26, readdirSync as
|
|
62604
|
+
import { lstatSync as lstatSync32, readFileSync as readFileSync26, readdirSync as readdirSync14, realpathSync as realpathSync12 } from "fs";
|
|
62193
62605
|
import { basename as basename16, dirname as dirname26, isAbsolute as isAbsolute30, join as join42, relative as relative9, resolve as resolve28, sep as sep14 } from "path";
|
|
62194
62606
|
import { isDeepStrictEqual as isDeepStrictEqual13 } from "util";
|
|
62195
62607
|
function discoveryRootUnresolved(agent, command, detail) {
|
|
@@ -62940,13 +63352,13 @@ function assertProjectDiscovery(agent, directories, home, canonical9 = resolve28
|
|
|
62940
63352
|
for (const name of ["plugin", "plugins"]) {
|
|
62941
63353
|
const path = canonical9(join42(directory2, ".sumi", name));
|
|
62942
63354
|
safe6(path);
|
|
62943
|
-
if (lstatSync32(path, { throwIfNoEntry: false })?.isDirectory() &&
|
|
63355
|
+
if (lstatSync32(path, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(path).length)
|
|
62944
63356
|
throw new Error(`NATIVE_SKILL_DRIFT: project Sumi plugins require a dedicated discovery review: ${path}`);
|
|
62945
63357
|
}
|
|
62946
63358
|
if (agent === "claude") {
|
|
62947
63359
|
const commands = canonical9(join42(directory2, ".claude/commands"));
|
|
62948
63360
|
safe6(commands);
|
|
62949
|
-
if (lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() &&
|
|
63361
|
+
if (lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(commands).length)
|
|
62950
63362
|
throw new Error("NATIVE_SKILL_DRIFT: legacy project command discovery requires a dedicated format adapter");
|
|
62951
63363
|
}
|
|
62952
63364
|
}
|
|
@@ -63095,7 +63507,7 @@ function resolveAgentDiscovery(options) {
|
|
|
63095
63507
|
for (const path of plugins) {
|
|
63096
63508
|
safe6(path);
|
|
63097
63509
|
if (lstatSync32(path, { throwIfNoEntry: false })?.isDirectory())
|
|
63098
|
-
for (const name of
|
|
63510
|
+
for (const name of readdirSync14(path).sort()) {
|
|
63099
63511
|
if (name === "skills-cli.js" && path === plugins[1])
|
|
63100
63512
|
continue;
|
|
63101
63513
|
const target = join42(path, name);
|
|
@@ -63106,7 +63518,7 @@ function resolveAgentDiscovery(options) {
|
|
|
63106
63518
|
}
|
|
63107
63519
|
for (const root2 of roots) {
|
|
63108
63520
|
safe6(root2);
|
|
63109
|
-
if (lstatSync32(root2, { throwIfNoEntry: false })?.isDirectory() &&
|
|
63521
|
+
if (lstatSync32(root2, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(root2).some((name) => name.endsWith(".md")))
|
|
63110
63522
|
unresolved("flat markdown skills require a dedicated native migration adapter");
|
|
63111
63523
|
}
|
|
63112
63524
|
}
|
|
@@ -63150,7 +63562,7 @@ function resolveAgentDiscovery(options) {
|
|
|
63150
63562
|
safe6(builtinRoot);
|
|
63151
63563
|
if (!lstatSync32(builtinRoot, { throwIfNoEntry: false })?.isDirectory())
|
|
63152
63564
|
unresolved("installed Gemini builtin root is missing");
|
|
63153
|
-
for (const name of
|
|
63565
|
+
for (const name of readdirSync14(builtinRoot).sort()) {
|
|
63154
63566
|
const text3 = witness(join42(builtinRoot, name, "SKILL.md"));
|
|
63155
63567
|
const match = text3?.match(/^---\r?\n[\s\S]*?^name:\s*([a-z0-9][a-z0-9-]*)\s*$/m);
|
|
63156
63568
|
if (!match?.[1] || builtinNames.includes(match[1]))
|
|
@@ -63248,7 +63660,7 @@ function resolveAgentDiscovery(options) {
|
|
|
63248
63660
|
unresolved("plugin hooks require a separate no-skill-injection review");
|
|
63249
63661
|
const commands = join42(root2, "commands");
|
|
63250
63662
|
safe6(commands);
|
|
63251
|
-
if (agent === "claude" && (manifest.commands !== undefined || lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() &&
|
|
63663
|
+
if (agent === "claude" && (manifest.commands !== undefined || lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(commands).length))
|
|
63252
63664
|
unresolved("legacy command discovery requires retirement or a dedicated format adapter");
|
|
63253
63665
|
const rootSkill = witness(join42(root2, "SKILL.md"));
|
|
63254
63666
|
if (rootSkill !== null)
|
|
@@ -63270,7 +63682,7 @@ function resolveAgentDiscovery(options) {
|
|
|
63270
63682
|
const installed = registrations === null ? {} : parseConfig(registrations, join42(home, ".claude/plugins/installed_plugins.json")).plugins;
|
|
63271
63683
|
const commands = canonical9(join42(home, ".claude/commands"));
|
|
63272
63684
|
safe6(commands);
|
|
63273
|
-
if (lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() &&
|
|
63685
|
+
if (lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(commands).length)
|
|
63274
63686
|
unresolved("legacy home command discovery requires a dedicated format adapter");
|
|
63275
63687
|
for (const [id, enabled] of Object.entries(config.enabledPlugins ?? {})) {
|
|
63276
63688
|
if (enabled === false)
|
|
@@ -63312,7 +63724,7 @@ function resolveAgentDiscovery(options) {
|
|
|
63312
63724
|
}
|
|
63313
63725
|
const localPlugins = join42(home, ".config/opencode/plugins");
|
|
63314
63726
|
safe6(localPlugins);
|
|
63315
|
-
if (lstatSync32(localPlugins, { throwIfNoEntry: false }) &&
|
|
63727
|
+
if (lstatSync32(localPlugins, { throwIfNoEntry: false }) && readdirSync14(localPlugins).some((name) => name !== "skills-cli.js"))
|
|
63316
63728
|
unresolved("additional local plugin hooks require review");
|
|
63317
63729
|
} else if (agent === "sumi") {
|
|
63318
63730
|
if ((config.plugin?.length ?? 0) > 0 || (config.plugins?.length ?? 0) > 0 || sources.some((source) => source.path !== canonical9(configPath) && source.path !== canonical9(join42(sumiConfigDirectory(home), "sumi.jsonc")) && source.sha256 !== null))
|
|
@@ -63331,7 +63743,7 @@ function resolveAgentDiscovery(options) {
|
|
|
63331
63743
|
const directory2 = join42(home, ".gemini/extensions");
|
|
63332
63744
|
safe6(directory2);
|
|
63333
63745
|
if (lstatSync32(directory2, { throwIfNoEntry: false }))
|
|
63334
|
-
for (const name of
|
|
63746
|
+
for (const name of readdirSync14(directory2)) {
|
|
63335
63747
|
const root2 = join42(directory2, name);
|
|
63336
63748
|
safe6(root2);
|
|
63337
63749
|
if (!lstatSync32(root2)?.isDirectory())
|
|
@@ -63419,7 +63831,7 @@ function physicalPath(path) {
|
|
|
63419
63831
|
}
|
|
63420
63832
|
return resolve29(realpathSync13(cursor), ...suffix);
|
|
63421
63833
|
}
|
|
63422
|
-
function
|
|
63834
|
+
function contains2(root2, path) {
|
|
63423
63835
|
return path === root2 || path.startsWith(root2 + sep15);
|
|
63424
63836
|
}
|
|
63425
63837
|
function configuredRoots(home, explicitHome) {
|
|
@@ -63472,14 +63884,14 @@ function assertPortableAuthoringPath(path, options = {}) {
|
|
|
63472
63884
|
const defaults2 = NATIVE_DISCOVERY_ROOTS.map((parts) => join43(home, ...parts));
|
|
63473
63885
|
defaults2.push(join43(home, ".codex/plugins/cache"), join43(home, ".claude/plugins/cache"), join43(home, ".claude/plugins/synced"), join43(home, ".gemini/extensions"));
|
|
63474
63886
|
for (const root2 of defaults2) {
|
|
63475
|
-
if (candidates.some((candidate2) =>
|
|
63887
|
+
if (candidates.some((candidate2) => contains2(resolve29(root2), candidate2) || contains2(physicalPath(root2), candidate2)))
|
|
63476
63888
|
native ??= root2;
|
|
63477
63889
|
}
|
|
63478
63890
|
if (native) {
|
|
63479
63891
|
throw new Error(`Refusing portable Skills authoring below native discovery root '${native}': ${lexical}. Set HASNA_SKILLS_DIR to a private authoring corpus outside native roots.`);
|
|
63480
63892
|
}
|
|
63481
63893
|
for (const root2 of configuredRoots(home, options.homeDir !== undefined)) {
|
|
63482
|
-
if (candidates.some((candidate2) =>
|
|
63894
|
+
if (candidates.some((candidate2) => contains2(resolve29(root2), candidate2) || contains2(physicalPath(root2), candidate2))) {
|
|
63483
63895
|
throw new Error(`Refusing portable Skills authoring below configured native discovery root: ${lexical}`);
|
|
63484
63896
|
}
|
|
63485
63897
|
}
|
|
@@ -63497,12 +63909,12 @@ var init_authoring_path = __esm(() => {
|
|
|
63497
63909
|
// src/lib/portable-skills.ts
|
|
63498
63910
|
import {
|
|
63499
63911
|
existsSync as existsSync19,
|
|
63500
|
-
mkdirSync as
|
|
63501
|
-
mkdtempSync as
|
|
63502
|
-
readdirSync as
|
|
63912
|
+
mkdirSync as mkdirSync13,
|
|
63913
|
+
mkdtempSync as mkdtempSync3,
|
|
63914
|
+
readdirSync as readdirSync15,
|
|
63503
63915
|
realpathSync as realpathSync14,
|
|
63504
63916
|
renameSync as renameSync7,
|
|
63505
|
-
rmSync as
|
|
63917
|
+
rmSync as rmSync6,
|
|
63506
63918
|
statSync as statSync14,
|
|
63507
63919
|
writeFileSync as writeFileSync10
|
|
63508
63920
|
} from "fs";
|
|
@@ -63547,7 +63959,7 @@ function listPortableSkills(options = {}) {
|
|
|
63547
63959
|
if (!safeIsDirectory(root2))
|
|
63548
63960
|
return [];
|
|
63549
63961
|
const skills = [];
|
|
63550
|
-
for (const entry of
|
|
63962
|
+
for (const entry of readdirSync15(root2).sort()) {
|
|
63551
63963
|
if (entry.startsWith("."))
|
|
63552
63964
|
continue;
|
|
63553
63965
|
const path = join44(root2, entry);
|
|
@@ -63590,7 +64002,7 @@ function scaffoldPortableSkill(name, options = {}) {
|
|
|
63590
64002
|
if (existsSync19(skillPath)) {
|
|
63591
64003
|
if (!options.overwrite)
|
|
63592
64004
|
throw new Error(`Skill '${skillName}' already exists at ${skillPath}`);
|
|
63593
|
-
|
|
64005
|
+
rmSync6(skillPath, { recursive: true, force: true });
|
|
63594
64006
|
}
|
|
63595
64007
|
const kind = options.kind ?? "executable";
|
|
63596
64008
|
const description = options.description ?? `${displayName(skillName)} skill`;
|
|
@@ -63617,7 +64029,7 @@ function portPortableSkillDirectory(sourceDir, options = {}) {
|
|
|
63617
64029
|
};
|
|
63618
64030
|
const imported = [];
|
|
63619
64031
|
const skipped = [];
|
|
63620
|
-
const entries =
|
|
64032
|
+
const entries = readdirSync15(absoluteSource, { withFileTypes: true }).map((entry) => entry.name).filter((entryName) => !entryName.startsWith(".")).sort();
|
|
63621
64033
|
for (const entryName of entries) {
|
|
63622
64034
|
const childPath = join44(absoluteSource, entryName);
|
|
63623
64035
|
if (!safeIsDirectory(childPath))
|
|
@@ -63662,11 +64074,11 @@ function physicalImportPath(path) {
|
|
|
63662
64074
|
function assertDisjointImportPaths(source, destination) {
|
|
63663
64075
|
const sourcePath = realpathSync14(source);
|
|
63664
64076
|
const destinationPath = physicalImportPath(destination);
|
|
63665
|
-
const
|
|
64077
|
+
const contains3 = (parent, child2) => {
|
|
63666
64078
|
const path = relative10(parent, child2);
|
|
63667
64079
|
return path === "" || !isAbsolute31(path) && path !== ".." && !path.startsWith(`..${sep16}`);
|
|
63668
64080
|
};
|
|
63669
|
-
if (
|
|
64081
|
+
if (contains3(sourcePath, destinationPath) || contains3(destinationPath, sourcePath)) {
|
|
63670
64082
|
throw new Error("Source and destination skill directories must not overlap");
|
|
63671
64083
|
}
|
|
63672
64084
|
}
|
|
@@ -63693,9 +64105,9 @@ function portPortableSkill(sourcePath, options = {}) {
|
|
|
63693
64105
|
if (existsSync19(destination)) {
|
|
63694
64106
|
if (!options.overwrite)
|
|
63695
64107
|
throw new Error(`Skill '${skillName}' already exists at ${destination}`);
|
|
63696
|
-
|
|
64108
|
+
rmSync6(destination, { recursive: true, force: true });
|
|
63697
64109
|
}
|
|
63698
|
-
|
|
64110
|
+
mkdirSync13(dirname28(destination), { recursive: true });
|
|
63699
64111
|
copySkillDirectory(absoluteSource, destination);
|
|
63700
64112
|
const base2 = {
|
|
63701
64113
|
...inferred,
|
|
@@ -63737,8 +64149,8 @@ function installCorpusSkillAtomically(input, options = {}) {
|
|
|
63737
64149
|
const target = join44(root2, name);
|
|
63738
64150
|
assertPortableAuthoringPath(target, options);
|
|
63739
64151
|
const created = !existsSync19(target);
|
|
63740
|
-
|
|
63741
|
-
const staging =
|
|
64152
|
+
mkdirSync13(root2, { recursive: true });
|
|
64153
|
+
const staging = mkdtempSync3(join44(root2, `.pull-${name}-`));
|
|
63742
64154
|
let moved = false;
|
|
63743
64155
|
let backup = null;
|
|
63744
64156
|
try {
|
|
@@ -63746,16 +64158,16 @@ function installCorpusSkillAtomically(input, options = {}) {
|
|
|
63746
64158
|
const manifest = buildCorpusManifest(input, name);
|
|
63747
64159
|
writeSkillJsonWithHash(staging, manifest);
|
|
63748
64160
|
if (existsSync19(target)) {
|
|
63749
|
-
backup =
|
|
64161
|
+
backup = mkdtempSync3(join44(root2, `.pull-backup-${name}-`));
|
|
63750
64162
|
renameSync7(target, join44(backup, name));
|
|
63751
64163
|
moved = true;
|
|
63752
64164
|
}
|
|
63753
64165
|
renameSync7(staging, target);
|
|
63754
64166
|
if (moved && backup)
|
|
63755
|
-
|
|
64167
|
+
rmSync6(backup, { recursive: true, force: true });
|
|
63756
64168
|
return { name, path: target, manifest, created };
|
|
63757
64169
|
} catch (error) {
|
|
63758
|
-
|
|
64170
|
+
rmSync6(staging, { recursive: true, force: true });
|
|
63759
64171
|
if (moved && backup && existsSync19(join44(backup, name))) {
|
|
63760
64172
|
try {
|
|
63761
64173
|
renameSync7(join44(backup, name), target);
|
|
@@ -63981,95 +64393,6 @@ var init_registry_types = __esm(() => {
|
|
|
63981
64393
|
BASIC_SKILL_NAMES = [];
|
|
63982
64394
|
});
|
|
63983
64395
|
|
|
63984
|
-
// src/lib/search.ts
|
|
63985
|
-
function editDistance(a, b) {
|
|
63986
|
-
if (a === b)
|
|
63987
|
-
return 0;
|
|
63988
|
-
if (a.length === 0)
|
|
63989
|
-
return b.length;
|
|
63990
|
-
if (b.length === 0)
|
|
63991
|
-
return a.length;
|
|
63992
|
-
const prev = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
63993
|
-
const curr = new Array(b.length + 1);
|
|
63994
|
-
for (let i = 1;i <= a.length; i++) {
|
|
63995
|
-
curr[0] = i;
|
|
63996
|
-
for (let j = 1;j <= b.length; j++) {
|
|
63997
|
-
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
63998
|
-
curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
|
|
63999
|
-
}
|
|
64000
|
-
prev.splice(0, prev.length, ...curr);
|
|
64001
|
-
}
|
|
64002
|
-
return prev[b.length];
|
|
64003
|
-
}
|
|
64004
|
-
function fuzzyMatchScore(word, target) {
|
|
64005
|
-
if (target.includes(word))
|
|
64006
|
-
return 1;
|
|
64007
|
-
const tokens = target.split(/[\s\-_]+/).filter(Boolean);
|
|
64008
|
-
for (const token of tokens) {
|
|
64009
|
-
if (token.startsWith(word))
|
|
64010
|
-
return 0.6;
|
|
64011
|
-
}
|
|
64012
|
-
if (word.length >= 3) {
|
|
64013
|
-
const maxDist = word.length <= 3 ? 1 : 2;
|
|
64014
|
-
for (const token of tokens) {
|
|
64015
|
-
if (Math.abs(token.length - word.length) <= maxDist) {
|
|
64016
|
-
const dist = editDistance(word, token);
|
|
64017
|
-
if (dist <= maxDist)
|
|
64018
|
-
return 0.4;
|
|
64019
|
-
}
|
|
64020
|
-
}
|
|
64021
|
-
}
|
|
64022
|
-
return 0;
|
|
64023
|
-
}
|
|
64024
|
-
function searchSkills(query, registry = loadRegistry()) {
|
|
64025
|
-
const words2 = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
64026
|
-
if (words2.length === 0)
|
|
64027
|
-
return [];
|
|
64028
|
-
const scored = [];
|
|
64029
|
-
for (const skill of registry) {
|
|
64030
|
-
const nameLower = skill.name.toLowerCase();
|
|
64031
|
-
const displayNameLower = skill.displayName.toLowerCase();
|
|
64032
|
-
const descriptionLower = skill.description.toLowerCase();
|
|
64033
|
-
const tagsLower = skill.tags.map((t2) => t2.toLowerCase());
|
|
64034
|
-
const tagsCombined = tagsLower.join(" ");
|
|
64035
|
-
let score = 0;
|
|
64036
|
-
let allWordsMatch = true;
|
|
64037
|
-
for (const word of words2) {
|
|
64038
|
-
let wordScore = 0;
|
|
64039
|
-
const nameMatch = fuzzyMatchScore(word, nameLower);
|
|
64040
|
-
if (nameMatch > 0)
|
|
64041
|
-
wordScore += 10 * nameMatch;
|
|
64042
|
-
const displayMatch = fuzzyMatchScore(word, displayNameLower);
|
|
64043
|
-
if (displayMatch > 0)
|
|
64044
|
-
wordScore += 7 * displayMatch;
|
|
64045
|
-
const tagMatch = Math.max(...tagsLower.map((t2) => fuzzyMatchScore(word, t2)), fuzzyMatchScore(word, tagsCombined));
|
|
64046
|
-
if (tagMatch > 0)
|
|
64047
|
-
wordScore += 5 * tagMatch;
|
|
64048
|
-
const descMatch = fuzzyMatchScore(word, descriptionLower);
|
|
64049
|
-
if (descMatch > 0)
|
|
64050
|
-
wordScore += 2 * descMatch;
|
|
64051
|
-
if (wordScore === 0) {
|
|
64052
|
-
allWordsMatch = false;
|
|
64053
|
-
break;
|
|
64054
|
-
}
|
|
64055
|
-
score += wordScore;
|
|
64056
|
-
}
|
|
64057
|
-
if (allWordsMatch && score > 0) {
|
|
64058
|
-
scored.push({ skill, score });
|
|
64059
|
-
}
|
|
64060
|
-
}
|
|
64061
|
-
scored.sort((a, b) => b.score - a.score);
|
|
64062
|
-
return scored.map((s) => s.skill);
|
|
64063
|
-
}
|
|
64064
|
-
function findSimilarSkills(query, maxResults = 3, registry = loadRegistry()) {
|
|
64065
|
-
const q = query.toLowerCase();
|
|
64066
|
-
const scored = registry.map((s) => ({ name: s.name, dist: editDistance(q, s.name.toLowerCase()) })).filter((s) => s.dist <= Math.max(3, Math.floor(q.length / 2))).sort((a, b) => a.dist - b.dist);
|
|
64067
|
-
return scored.slice(0, maxResults).map((s) => s.name);
|
|
64068
|
-
}
|
|
64069
|
-
var init_search = __esm(() => {
|
|
64070
|
-
init_registry();
|
|
64071
|
-
});
|
|
64072
|
-
|
|
64073
64396
|
// src/lib/registry.ts
|
|
64074
64397
|
var exports_registry = {};
|
|
64075
64398
|
__export(exports_registry, {
|
|
@@ -64089,7 +64412,7 @@ __export(exports_registry, {
|
|
|
64089
64412
|
CATEGORIES: () => CATEGORIES,
|
|
64090
64413
|
BASIC_SKILL_NAMES: () => BASIC_SKILL_NAMES
|
|
64091
64414
|
});
|
|
64092
|
-
import { existsSync as existsSync20, readFileSync as readFileSync27, readdirSync as
|
|
64415
|
+
import { existsSync as existsSync20, readFileSync as readFileSync27, readdirSync as readdirSync16 } from "fs";
|
|
64093
64416
|
import { join as join45 } from "path";
|
|
64094
64417
|
function isBasicSkillName(name) {
|
|
64095
64418
|
return BASIC_SKILL_NAMES.includes(name);
|
|
@@ -64130,7 +64453,7 @@ function discoverSkillsInDir(dir, source = "custom") {
|
|
|
64130
64453
|
return [];
|
|
64131
64454
|
const result2 = [];
|
|
64132
64455
|
try {
|
|
64133
|
-
const entries =
|
|
64456
|
+
const entries = readdirSync16(dir, { withFileTypes: true });
|
|
64134
64457
|
for (const entry of entries) {
|
|
64135
64458
|
if (!entry.isDirectory())
|
|
64136
64459
|
continue;
|
|
@@ -64166,7 +64489,7 @@ function findExtensionSkillPath(name) {
|
|
|
64166
64489
|
if (!config.extensionsDir || !existsSync20(config.extensionsDir))
|
|
64167
64490
|
return null;
|
|
64168
64491
|
try {
|
|
64169
|
-
const entries =
|
|
64492
|
+
const entries = readdirSync16(config.extensionsDir, { withFileTypes: true });
|
|
64170
64493
|
for (const entry of entries) {
|
|
64171
64494
|
if (!entry.isDirectory())
|
|
64172
64495
|
continue;
|
|
@@ -65888,7 +66211,7 @@ var require_cli_spinners = __commonJS((exports, module) => {
|
|
|
65888
66211
|
});
|
|
65889
66212
|
|
|
65890
66213
|
// src/lib/auth-store.ts
|
|
65891
|
-
import { chmodSync as chmodSync2, existsSync as existsSync21, mkdirSync as
|
|
66214
|
+
import { chmodSync as chmodSync2, existsSync as existsSync21, mkdirSync as mkdirSync14, readFileSync as readFileSync28, renameSync as renameSync8, statSync as statSync15, unlinkSync as unlinkSync6, writeFileSync as writeFileSync11 } from "fs";
|
|
65892
66215
|
import { basename as basename19, dirname as dirname29, join as join46 } from "path";
|
|
65893
66216
|
function getAuthFilePath(env3 = process.env) {
|
|
65894
66217
|
return skillsCredentialFilePath(env3);
|
|
@@ -65929,7 +66252,7 @@ function getAuthConfig(env3 = process.env, options = {}) {
|
|
|
65929
66252
|
}
|
|
65930
66253
|
function writeCredentialValues(values2, env3 = process.env) {
|
|
65931
66254
|
const file = skillsCredentialFilePath(env3);
|
|
65932
|
-
|
|
66255
|
+
mkdirSync14(dirname29(file), { recursive: true, mode: 448 });
|
|
65933
66256
|
const lines = [];
|
|
65934
66257
|
const written = new Set;
|
|
65935
66258
|
if (existsSync21(file)) {
|
|
@@ -87918,7 +88241,7 @@ var init_remote_auth = __esm(() => {
|
|
|
87918
88241
|
|
|
87919
88242
|
// src/lib/sign-in.ts
|
|
87920
88243
|
import { createHash as createHash32 } from "crypto";
|
|
87921
|
-
import { chmodSync as chmodSync3, mkdirSync as
|
|
88244
|
+
import { chmodSync as chmodSync3, mkdirSync as mkdirSync15, readFileSync as readFileSync29, readdirSync as readdirSync17, renameSync as renameSync9, unlinkSync as unlinkSync7, writeFileSync as writeFileSync12 } from "fs";
|
|
87922
88245
|
import { basename as basename20, dirname as dirname30, join as join47 } from "path";
|
|
87923
88246
|
function isRecord7(value) {
|
|
87924
88247
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
@@ -88072,7 +88395,7 @@ function pendingDeviceSignInPath(origin, env3 = process.env) {
|
|
|
88072
88395
|
}
|
|
88073
88396
|
function savePendingDeviceSignIn(origin, start, env3 = process.env, now3 = Date.now()) {
|
|
88074
88397
|
const path = pendingDeviceSignInPath(origin, env3);
|
|
88075
|
-
|
|
88398
|
+
mkdirSync15(dirname30(path), { recursive: true, mode: 448 });
|
|
88076
88399
|
const pending = {
|
|
88077
88400
|
origin,
|
|
88078
88401
|
deviceCode: start.deviceCode,
|
|
@@ -88130,7 +88453,7 @@ function pendingDeviceSignInOrigins(env3 = process.env, now3 = Date.now()) {
|
|
|
88130
88453
|
}
|
|
88131
88454
|
let entries;
|
|
88132
88455
|
try {
|
|
88133
|
-
entries =
|
|
88456
|
+
entries = readdirSync17(location.dir);
|
|
88134
88457
|
} catch {
|
|
88135
88458
|
return [];
|
|
88136
88459
|
}
|
|
@@ -88161,7 +88484,7 @@ function clearPendingDeviceSignIn(env3 = process.env, origin) {
|
|
|
88161
88484
|
}
|
|
88162
88485
|
let entries;
|
|
88163
88486
|
try {
|
|
88164
|
-
entries =
|
|
88487
|
+
entries = readdirSync17(location.dir);
|
|
88165
88488
|
} catch {
|
|
88166
88489
|
return;
|
|
88167
88490
|
}
|
|
@@ -88771,6 +89094,24 @@ function optionPrefix(program2, args) {
|
|
|
88771
89094
|
return { indices, separator: -1 };
|
|
88772
89095
|
}
|
|
88773
89096
|
|
|
89097
|
+
// src/cli/stray-arguments.ts
|
|
89098
|
+
function permitStrayArguments(command) {
|
|
89099
|
+
selfRefusing.add(command);
|
|
89100
|
+
return command.allowExcessArguments(true);
|
|
89101
|
+
}
|
|
89102
|
+
function rejectStrayArguments(command) {
|
|
89103
|
+
for (const child2 of command.commands) {
|
|
89104
|
+
if (child2.registeredArguments.length === 0 && !selfRefusing.has(child2)) {
|
|
89105
|
+
child2.allowExcessArguments(false);
|
|
89106
|
+
}
|
|
89107
|
+
rejectStrayArguments(child2);
|
|
89108
|
+
}
|
|
89109
|
+
}
|
|
89110
|
+
var selfRefusing;
|
|
89111
|
+
var init_stray_arguments = __esm(() => {
|
|
89112
|
+
selfRefusing = new WeakSet;
|
|
89113
|
+
});
|
|
89114
|
+
|
|
88774
89115
|
// src/lib/revision.ts
|
|
88775
89116
|
import { createHash as createHash33 } from "crypto";
|
|
88776
89117
|
function revisionIdOf(content) {
|
|
@@ -88822,7 +89163,7 @@ var init_skill_bundles = __esm(() => {
|
|
|
88822
89163
|
});
|
|
88823
89164
|
|
|
88824
89165
|
// src/lib/pull.ts
|
|
88825
|
-
import { existsSync as existsSync22, mkdirSync as
|
|
89166
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync4, readFileSync as readFileSync30, renameSync as renameSync10, rmSync as rmSync7, writeFileSync as writeFileSync13 } from "fs";
|
|
88826
89167
|
import { dirname as dirname31, join as join48 } from "path";
|
|
88827
89168
|
async function pullSkills(options = {}) {
|
|
88828
89169
|
const client2 = options.client !== undefined ? options.client : await createRemoteSkillsClient();
|
|
@@ -88979,7 +89320,7 @@ function reconcileTombstone(slug2, corpusOptions) {
|
|
|
88979
89320
|
if (!hasSkillsOwnershipMarker(target)) {
|
|
88980
89321
|
return { name: slug2, success: true, tombstoned: true, removed: false, leftInPlace: true };
|
|
88981
89322
|
}
|
|
88982
|
-
|
|
89323
|
+
rmSync7(target, { recursive: true, force: true });
|
|
88983
89324
|
return { name: slug2, success: true, tombstoned: true, removed: true };
|
|
88984
89325
|
}
|
|
88985
89326
|
function readPullMarker(dir) {
|
|
@@ -89118,16 +89459,16 @@ function verifyBundleResponseBytes(buffer, response, verify = {}) {
|
|
|
89118
89459
|
}
|
|
89119
89460
|
function installBundleAtomically(name, entries, options = {}, marker = {}) {
|
|
89120
89461
|
const root2 = getPortableSkillsRoot(options);
|
|
89121
|
-
|
|
89462
|
+
mkdirSync16(root2, { recursive: true });
|
|
89122
89463
|
const target = join48(root2, name);
|
|
89123
89464
|
const created = !existsSync22(target);
|
|
89124
|
-
const staging =
|
|
89465
|
+
const staging = mkdtempSync4(join48(root2, `.pull-${name}-`));
|
|
89125
89466
|
let moved = false;
|
|
89126
89467
|
let backup = null;
|
|
89127
89468
|
try {
|
|
89128
89469
|
for (const entry of entries) {
|
|
89129
89470
|
const destination = join48(staging, entry.path);
|
|
89130
|
-
|
|
89471
|
+
mkdirSync16(dirname31(destination), { recursive: true });
|
|
89131
89472
|
writeFileSync13(destination, entry.bytes, { mode: entry.mode });
|
|
89132
89473
|
}
|
|
89133
89474
|
writePullMarker(staging, {
|
|
@@ -89139,15 +89480,15 @@ function installBundleAtomically(name, entries, options = {}, marker = {}) {
|
|
|
89139
89480
|
...marker.revisionId ? { revisionId: marker.revisionId } : {}
|
|
89140
89481
|
});
|
|
89141
89482
|
if (existsSync22(target)) {
|
|
89142
|
-
backup =
|
|
89483
|
+
backup = mkdtempSync4(join48(root2, `.pull-backup-${name}-`));
|
|
89143
89484
|
renameSync10(target, join48(backup, name));
|
|
89144
89485
|
moved = true;
|
|
89145
89486
|
}
|
|
89146
89487
|
renameSync10(staging, target);
|
|
89147
89488
|
if (moved && backup)
|
|
89148
|
-
|
|
89489
|
+
rmSync7(backup, { recursive: true, force: true });
|
|
89149
89490
|
} catch (error61) {
|
|
89150
|
-
|
|
89491
|
+
rmSync7(staging, { recursive: true, force: true });
|
|
89151
89492
|
if (moved && backup && existsSync22(join48(backup, name))) {
|
|
89152
89493
|
try {
|
|
89153
89494
|
renameSync10(join48(backup, name), target);
|
|
@@ -90820,7 +91161,13 @@ function handleReadRefusal(error61) {
|
|
|
90820
91161
|
async function handleInfoError(name, options, error61) {
|
|
90821
91162
|
if (isSkillsFleetCredentialError(error61))
|
|
90822
91163
|
return handleReadRefusal(error61);
|
|
90823
|
-
|
|
91164
|
+
let remote = options.remote === true;
|
|
91165
|
+
if (!remote) {
|
|
91166
|
+
try {
|
|
91167
|
+
remote = (await requireSkillsReadAccess()).mode === "hosted";
|
|
91168
|
+
} catch {}
|
|
91169
|
+
}
|
|
91170
|
+
const notFound = await resolveRemoteNotFound(name, remote, error61.message);
|
|
90824
91171
|
if (options.json)
|
|
90825
91172
|
console.log(JSON.stringify(notFound));
|
|
90826
91173
|
else
|
|
@@ -91821,7 +92168,7 @@ var init_init = __esm(() => {
|
|
|
91821
92168
|
});
|
|
91822
92169
|
|
|
91823
92170
|
// src/lib/home-adoption.ts
|
|
91824
|
-
import { constants as constants22, closeSync as closeSync20, fstatSync as fstatSync20, lstatSync as lstatSync34, openSync as openSync20, readSync as readSync17, existsSync as existsSync25, mkdirSync as
|
|
92171
|
+
import { constants as constants22, closeSync as closeSync20, fstatSync as fstatSync20, lstatSync as lstatSync34, openSync as openSync20, readSync as readSync17, existsSync as existsSync25, mkdirSync as mkdirSync17, readdirSync as readdirSync18, readFileSync as readFileSync33, rmSync as rmSync8, statSync as statSync16, writeFileSync as writeFileSync15 } from "fs";
|
|
91825
92172
|
import { homedir as homedir8 } from "os";
|
|
91826
92173
|
import { join as join52 } from "path";
|
|
91827
92174
|
function indexCanonicalCorpus(corpusRoot) {
|
|
@@ -91830,7 +92177,7 @@ function indexCanonicalCorpus(corpusRoot) {
|
|
|
91830
92177
|
return byName;
|
|
91831
92178
|
let entries = [];
|
|
91832
92179
|
try {
|
|
91833
|
-
entries =
|
|
92180
|
+
entries = readdirSync18(corpusRoot);
|
|
91834
92181
|
} catch {
|
|
91835
92182
|
return byName;
|
|
91836
92183
|
}
|
|
@@ -91880,7 +92227,7 @@ function scanUnmarkedHomes(options = {}) {
|
|
|
91880
92227
|
continue;
|
|
91881
92228
|
let entries = [];
|
|
91882
92229
|
try {
|
|
91883
|
-
entries =
|
|
92230
|
+
entries = readdirSync18(home);
|
|
91884
92231
|
} catch {
|
|
91885
92232
|
continue;
|
|
91886
92233
|
}
|
|
@@ -91940,11 +92287,11 @@ function appendConflictsLedger(appDir, conflicts) {
|
|
|
91940
92287
|
writeFileSync15(ledgerPath, `${JSON.stringify(ledger, null, 2)}
|
|
91941
92288
|
`);
|
|
91942
92289
|
}
|
|
91943
|
-
function writeRollbackRecord(mode, entries, appDir = getDataDir()) {
|
|
92290
|
+
function writeRollbackRecord(mode, entries, appDir = getDataDir(), admission = {}) {
|
|
91944
92291
|
const dir = join52(appDir, ROLLBACK_DIRNAME);
|
|
91945
|
-
|
|
92292
|
+
mkdirSync17(dir, { recursive: true });
|
|
91946
92293
|
const file2 = join52(dir, `${mode}-${Date.now()}.json`);
|
|
91947
|
-
const record12 = { version: 1, mode, timestamp: new Date().toISOString(), entries };
|
|
92294
|
+
const record12 = { version: 1, mode, timestamp: new Date().toISOString(), entries, ...admission };
|
|
91948
92295
|
writeFileSync15(file2, `${JSON.stringify(record12, null, 2)}
|
|
91949
92296
|
`);
|
|
91950
92297
|
return file2;
|
|
@@ -91956,8 +92303,9 @@ function adoptUnmarkedHomes(options = {}) {
|
|
|
91956
92303
|
}
|
|
91957
92304
|
const appDir = options.homeDir ? join52(options.homeDir, ".hasna", "skills") : getDataDir();
|
|
91958
92305
|
const roots = scan.adoptable.map((entry) => codexCorpusRootForPath(entry.path)).filter((root2) => !!root2);
|
|
91959
|
-
return withCodexCorpusWrite(roots, (assertCurrent) => {
|
|
92306
|
+
return withCodexCorpusWrite(roots, (assertCurrent, admission) => {
|
|
91960
92307
|
assertCurrent();
|
|
92308
|
+
const fallback = codexAdmissionReceipt(admission);
|
|
91961
92309
|
const canonical9 = indexCanonicalCorpus(resolveCorpusRoot(options));
|
|
91962
92310
|
const markers = scan.adoptable.map((entry) => {
|
|
91963
92311
|
const root2 = codexCorpusRootForPath(entry.path);
|
|
@@ -91974,7 +92322,7 @@ function adoptUnmarkedHomes(options = {}) {
|
|
|
91974
92322
|
assertCurrent();
|
|
91975
92323
|
let rollbackFile;
|
|
91976
92324
|
if (markers.length > 0) {
|
|
91977
|
-
rollbackFile = writeRollbackRecord("adopt", markers, appDir);
|
|
92325
|
+
rollbackFile = writeRollbackRecord("adopt", markers, appDir, fallback);
|
|
91978
92326
|
}
|
|
91979
92327
|
for (const entry of markers) {
|
|
91980
92328
|
assertCurrent();
|
|
@@ -91987,7 +92335,7 @@ function adoptUnmarkedHomes(options = {}) {
|
|
|
91987
92335
|
}
|
|
91988
92336
|
assertCurrent();
|
|
91989
92337
|
appendConflictsLedger(appDir, scan.conflicts);
|
|
91990
|
-
return { ...scan, applied: true, rollbackFile };
|
|
92338
|
+
return { ...scan, applied: true, rollbackFile, ...fallback };
|
|
91991
92339
|
}, options);
|
|
91992
92340
|
}
|
|
91993
92341
|
function pruneOwnership(dir) {
|
|
@@ -92039,7 +92387,7 @@ function pruneStrayHomes(options = {}) {
|
|
|
92039
92387
|
continue;
|
|
92040
92388
|
let entries = [];
|
|
92041
92389
|
try {
|
|
92042
|
-
entries =
|
|
92390
|
+
entries = readdirSync18(home);
|
|
92043
92391
|
} catch {
|
|
92044
92392
|
continue;
|
|
92045
92393
|
}
|
|
@@ -92072,9 +92420,10 @@ function pruneStrayHomes(options = {}) {
|
|
|
92072
92420
|
}
|
|
92073
92421
|
const appDir = options.homeDir ? join52(options.homeDir, ".hasna", "skills") : getDataDir();
|
|
92074
92422
|
const roots = candidates.map((candidate2) => codexCorpusRootForPath(candidate2.path)).filter((root2) => !!root2);
|
|
92075
|
-
return withCodexCorpusWrite(roots, (assertCurrent) => {
|
|
92423
|
+
return withCodexCorpusWrite(roots, (assertCurrent, admission) => {
|
|
92076
92424
|
assertCurrent();
|
|
92077
|
-
const
|
|
92425
|
+
const fallback = codexAdmissionReceipt(admission);
|
|
92426
|
+
const rollbackFile = writeRollbackRecord("prune", candidates.map(({ agent, skill, path, hash: hash6, marker }) => ({ agent, skill, path, hash: hash6, marker })), appDir, fallback);
|
|
92078
92427
|
let pruned = 0;
|
|
92079
92428
|
for (const candidate2 of candidates) {
|
|
92080
92429
|
assertCurrent();
|
|
@@ -92088,13 +92437,13 @@ function pruneStrayHomes(options = {}) {
|
|
|
92088
92437
|
const skillMd = join52(candidate2.path, "SKILL.md");
|
|
92089
92438
|
if ((existsSync25(skillMd) ? hashSkillMarkdownFile(skillMd) : "") !== candidate2.hash)
|
|
92090
92439
|
continue;
|
|
92091
|
-
|
|
92440
|
+
rmSync8(candidate2.path, { recursive: true, force: true });
|
|
92092
92441
|
assertCurrent();
|
|
92093
92442
|
if (existsSync25(candidate2.path))
|
|
92094
92443
|
throw new Error("Skill prune readback failed");
|
|
92095
92444
|
pruned++;
|
|
92096
92445
|
}
|
|
92097
|
-
return { candidates, pruned, dryRun: false, rollbackFile };
|
|
92446
|
+
return { candidates, pruned, dryRun: false, rollbackFile, ...fallback };
|
|
92098
92447
|
}, options);
|
|
92099
92448
|
}
|
|
92100
92449
|
var CONFLICTS_LEDGER_FILE = "conflicts.json", ROLLBACK_DIRNAME = "rollback";
|
|
@@ -92108,7 +92457,7 @@ var init_home_adoption = __esm(() => {
|
|
|
92108
92457
|
});
|
|
92109
92458
|
|
|
92110
92459
|
// src/lib/home-census.ts
|
|
92111
|
-
import { existsSync as existsSync26, readFileSync as readFileSync34, readdirSync as
|
|
92460
|
+
import { existsSync as existsSync26, readFileSync as readFileSync34, readdirSync as readdirSync19, statSync as statSync17 } from "fs";
|
|
92112
92461
|
import { homedir as homedir9 } from "os";
|
|
92113
92462
|
import { join as join53 } from "path";
|
|
92114
92463
|
function sortEntries(entries) {
|
|
@@ -92142,7 +92491,7 @@ function censusHomeDrift(options = {}) {
|
|
|
92142
92491
|
const present2 = new Set;
|
|
92143
92492
|
let dirEntries = [];
|
|
92144
92493
|
try {
|
|
92145
|
-
dirEntries =
|
|
92494
|
+
dirEntries = readdirSync19(home);
|
|
92146
92495
|
} catch {
|
|
92147
92496
|
continue;
|
|
92148
92497
|
}
|
|
@@ -92406,7 +92755,7 @@ var exports_diagnostic = {};
|
|
|
92406
92755
|
__export(exports_diagnostic, {
|
|
92407
92756
|
registerDiagnostic: () => registerDiagnostic
|
|
92408
92757
|
});
|
|
92409
|
-
import { existsSync as existsSync27, readFileSync as readFileSync36, readdirSync as
|
|
92758
|
+
import { existsSync as existsSync27, readFileSync as readFileSync36, readdirSync as readdirSync20, statSync as statSync18 } from "fs";
|
|
92410
92759
|
import { join as join54 } from "path";
|
|
92411
92760
|
import { execSync as execSync2 } from "child_process";
|
|
92412
92761
|
function registerDiagnostic(parent) {
|
|
@@ -92599,7 +92948,7 @@ function handleWhoami(options) {
|
|
|
92599
92948
|
let skillCount = 0;
|
|
92600
92949
|
if (exists)
|
|
92601
92950
|
try {
|
|
92602
|
-
skillCount =
|
|
92951
|
+
skillCount = readdirSync20(agentSkillsPath).filter((f) => !f.startsWith(".") && statSync18(join54(agentSkillsPath, f)).isDirectory()).length;
|
|
92603
92952
|
} catch {}
|
|
92604
92953
|
agentConfigs.push({ agent, label: AGENT_LABELS[agent], path: agentSkillsPath, exists, skillCount });
|
|
92605
92954
|
}
|
|
@@ -92857,7 +93206,7 @@ var init_cloud_executions = __esm(() => {
|
|
|
92857
93206
|
|
|
92858
93207
|
// node_modules/@hasna/secrets/dist/sdk.js
|
|
92859
93208
|
import { isIP as isIP3 } from "net";
|
|
92860
|
-
import { spawnSync as
|
|
93209
|
+
import { spawnSync as spawnSync5 } from "child_process";
|
|
92861
93210
|
import { closeSync as closeSync23, fstatSync as fstatSync23, openSync as openSync23, readFileSync as readFileSync37 } from "fs";
|
|
92862
93211
|
import { O_NOFOLLOW as O_NOFOLLOW3, O_NONBLOCK as O_NONBLOCK3, O_RDONLY as O_RDONLY3 } from "constants";
|
|
92863
93212
|
import { createRequire as createRequire2 } from "module";
|
|
@@ -93132,7 +93481,7 @@ function isAmbientEnvironment2(env3) {
|
|
|
93132
93481
|
return env3 === process.env || env3[AMBIENT_ENVIRONMENT2] === true;
|
|
93133
93482
|
}
|
|
93134
93483
|
function defaultKeychainRunner2(argv) {
|
|
93135
|
-
const result2 =
|
|
93484
|
+
const result2 = spawnSync5(KEYCHAIN_SECURITY_BIN2, [...argv], {
|
|
93136
93485
|
encoding: "utf8",
|
|
93137
93486
|
stdio: ["ignore", "pipe", "pipe"],
|
|
93138
93487
|
timeout: KEYCHAIN_SPAWN_TIMEOUT_MS2
|
|
@@ -94513,7 +94862,7 @@ __export(exports_selected_run, {
|
|
|
94513
94862
|
});
|
|
94514
94863
|
import { createHash as createHash36 } from "crypto";
|
|
94515
94864
|
import { spawn as spawn3 } from "child_process";
|
|
94516
|
-
import { mkdirSync as
|
|
94865
|
+
import { mkdirSync as mkdirSync18, mkdtempSync as mkdtempSync5, writeFileSync as writeFileSync16, realpathSync as realpathSync16 } from "fs";
|
|
94517
94866
|
import { dirname as dirname33, join as join56, resolve as resolve33 } from "path";
|
|
94518
94867
|
import { tmpdir, hostname as stationHostname2 } from "os";
|
|
94519
94868
|
async function resolveSelectedRun(spec, profileId, options = {}) {
|
|
@@ -94637,7 +94986,7 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
94637
94986
|
throw new SkillSelectionError("INVALID_SECRET_BINDINGS", "Explicit environment values must be bounded strings without NUL bytes.");
|
|
94638
94987
|
secretEnv[name] = value;
|
|
94639
94988
|
}
|
|
94640
|
-
const runDirectory =
|
|
94989
|
+
const runDirectory = mkdtempSync5(join56(tmpdir(), "skills-execution-"));
|
|
94641
94990
|
const paths = new SkillEntryPaths;
|
|
94642
94991
|
for (const entry of entries) {
|
|
94643
94992
|
paths.add(entry.path, 100, () => {
|
|
@@ -94646,7 +94995,7 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
94646
94995
|
throw new SkillSelectionError("INVALID_BUNDLE_PATH", "The execution bundle path exceeds its limit.");
|
|
94647
94996
|
});
|
|
94648
94997
|
const destination = join56(runDirectory, entry.path);
|
|
94649
|
-
|
|
94998
|
+
mkdirSync18(dirname33(destination), { recursive: true, mode: 448 });
|
|
94650
94999
|
writeFileSync16(destination, entry.bytes, { flag: "wx", mode: entry.mode & 511 });
|
|
94651
95000
|
}
|
|
94652
95001
|
env3.SKILLS_INPUT_JSON = input2;
|
|
@@ -98899,7 +99248,7 @@ var init_runs = __esm(() => {
|
|
|
98899
99248
|
|
|
98900
99249
|
// src/lib/run-state.ts
|
|
98901
99250
|
import { createHash as createHash37, randomBytes } from "crypto";
|
|
98902
|
-
import { existsSync as existsSync28, mkdirSync as
|
|
99251
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync19, readFileSync as readFileSync38, readdirSync as readdirSync21, statSync as statSync19, writeFileSync as writeFileSync17 } from "fs";
|
|
98903
99252
|
import { extname, join as join57, relative as relative11 } from "path";
|
|
98904
99253
|
function createSkillRun(params, targetDir = process.cwd()) {
|
|
98905
99254
|
const now3 = new Date;
|
|
@@ -98910,9 +99259,9 @@ function createSkillRun(params, targetDir = process.cwd()) {
|
|
|
98910
99259
|
const runDir = join57(root2, "runs", day, id2);
|
|
98911
99260
|
const logsDir = join57(runDir, "logs");
|
|
98912
99261
|
const exportDir = join57(root2, "exports", skillName, id2);
|
|
98913
|
-
|
|
98914
|
-
|
|
98915
|
-
|
|
99262
|
+
mkdirSync19(logsDir, { recursive: true });
|
|
99263
|
+
mkdirSync19(exportDir, { recursive: true });
|
|
99264
|
+
mkdirSync19(join57(root2, "tmp"), { recursive: true });
|
|
98916
99265
|
const record13 = {
|
|
98917
99266
|
id: id2,
|
|
98918
99267
|
skill: skillName,
|
|
@@ -98979,11 +99328,11 @@ function listSkillRuns(targetDir = process.cwd(), limit = 50) {
|
|
|
98979
99328
|
if (!existsSync28(runsRoot))
|
|
98980
99329
|
return [];
|
|
98981
99330
|
const records = [];
|
|
98982
|
-
for (const day of
|
|
99331
|
+
for (const day of readdirSync21(runsRoot).sort().reverse()) {
|
|
98983
99332
|
const dayDir = join57(runsRoot, day);
|
|
98984
99333
|
if (!statSync19(dayDir).isDirectory())
|
|
98985
99334
|
continue;
|
|
98986
|
-
for (const runId2 of
|
|
99335
|
+
for (const runId2 of readdirSync21(dayDir).sort().reverse()) {
|
|
98987
99336
|
const record13 = readRunRecord(join57(dayDir, runId2));
|
|
98988
99337
|
if (record13)
|
|
98989
99338
|
records.push(record13);
|
|
@@ -98997,7 +99346,7 @@ function findSkillRun(runId2, targetDir = process.cwd()) {
|
|
|
98997
99346
|
const runsRoot = join57(getProjectStateDir(targetDir), "runs");
|
|
98998
99347
|
if (!existsSync28(runsRoot))
|
|
98999
99348
|
return null;
|
|
99000
|
-
for (const day of
|
|
99349
|
+
for (const day of readdirSync21(runsRoot)) {
|
|
99001
99350
|
const record13 = readRunRecord(join57(runsRoot, day, runId2));
|
|
99002
99351
|
if (record13)
|
|
99003
99352
|
return record13;
|
|
@@ -99053,7 +99402,7 @@ function readRunRecord(runDir) {
|
|
|
99053
99402
|
}
|
|
99054
99403
|
function walkFiles(dir) {
|
|
99055
99404
|
const files = [];
|
|
99056
|
-
for (const entry of
|
|
99405
|
+
for (const entry of readdirSync21(dir)) {
|
|
99057
99406
|
const full = join57(dir, entry);
|
|
99058
99407
|
if (statSync19(full).isDirectory())
|
|
99059
99408
|
files.push(...walkFiles(full));
|
|
@@ -111071,7 +111420,7 @@ var init_remote_customer_operations = __esm(() => {
|
|
|
111071
111420
|
});
|
|
111072
111421
|
|
|
111073
111422
|
// src/lib/workspace-profile.ts
|
|
111074
|
-
import { constants as constants25, closeSync as closeSync26, fstatSync as fstatSync26, lstatSync as lstatSync36, mkdirSync as
|
|
111423
|
+
import { constants as constants25, closeSync as closeSync26, fstatSync as fstatSync26, lstatSync as lstatSync36, mkdirSync as mkdirSync20, mkdtempSync as mkdtempSync6, openSync as openSync26, readFileSync as readFileSync39, renameSync as renameSync11, rmSync as rmSync9, writeFileSync as writeFileSync18 } from "fs";
|
|
111075
111424
|
import { dirname as dirname34, join as join58 } from "path";
|
|
111076
111425
|
function stat2(path) {
|
|
111077
111426
|
try {
|
|
@@ -111222,8 +111571,8 @@ async function prepareWorkspaceEnrollment(membershipId, source = process.env) {
|
|
|
111222
111571
|
return fail4("The new profile exceeds the credential reader size limit.");
|
|
111223
111572
|
const identity6 = JSON.stringify({ email: verified.user.email, userId: verified.user.id, orgId: verified.organization.id, orgSlug: verified.organization.slug, apiUrl: origin, issuedBy: "sign-in" }, null, 2) + `
|
|
111224
111573
|
`;
|
|
111225
|
-
|
|
111226
|
-
const temp =
|
|
111574
|
+
mkdirSync20(dirname34(file2), { recursive: true, mode: 448 });
|
|
111575
|
+
const temp = mkdtempSync6(join58(dirname34(file2), ".workspace-login-"));
|
|
111227
111576
|
let identityInstalled = false;
|
|
111228
111577
|
try {
|
|
111229
111578
|
writeFileSync18(join58(temp, "credentials"), body, { mode: 384, flag: "wx" });
|
|
@@ -111242,7 +111591,7 @@ async function prepareWorkspaceEnrollment(membershipId, source = process.env) {
|
|
|
111242
111591
|
} catch (error61) {
|
|
111243
111592
|
if (identityInstalled) {
|
|
111244
111593
|
if (oldIdentity === null)
|
|
111245
|
-
|
|
111594
|
+
rmSync9(identityFile, { force: true });
|
|
111246
111595
|
else {
|
|
111247
111596
|
writeFileSync18(join58(temp, "restore"), oldIdentity, { mode: 384, flag: "wx" });
|
|
111248
111597
|
renameSync11(join58(temp, "restore"), identityFile);
|
|
@@ -111250,7 +111599,7 @@ async function prepareWorkspaceEnrollment(membershipId, source = process.env) {
|
|
|
111250
111599
|
}
|
|
111251
111600
|
throw error61;
|
|
111252
111601
|
} finally {
|
|
111253
|
-
|
|
111602
|
+
rmSync9(temp, { recursive: true, force: true });
|
|
111254
111603
|
}
|
|
111255
111604
|
return {
|
|
111256
111605
|
status: "authenticated",
|
|
@@ -111439,7 +111788,7 @@ var init_recurring_customer = __esm(() => {
|
|
|
111439
111788
|
});
|
|
111440
111789
|
|
|
111441
111790
|
// src/lib/recurring-recovery.ts
|
|
111442
|
-
import { constants as constants26, closeSync as closeSync27, fsyncSync as fsyncSync8, fstatSync as fstatSync27, lstatSync as lstatSync37, mkdirSync as
|
|
111791
|
+
import { constants as constants26, closeSync as closeSync27, fsyncSync as fsyncSync8, fstatSync as fstatSync27, lstatSync as lstatSync37, mkdirSync as mkdirSync21, openSync as openSync27, readSync as readSync19, realpathSync as realpathSync17, renameSync as renameSync12, unlinkSync as unlinkSync8, writeFileSync as writeFileSync19 } from "fs";
|
|
111443
111792
|
import { dirname as dirname35, isAbsolute as isAbsolute33, join as join59, resolve as resolve34 } from "path";
|
|
111444
111793
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
111445
111794
|
|
|
@@ -111585,7 +111934,7 @@ function base2(customer, organizationId) {
|
|
|
111585
111934
|
function create3(directory2, intent) {
|
|
111586
111935
|
if (!isAbsolute33(directory2) || resolve34(directory2) !== directory2 || realpathSync17(dirname35(directory2)) !== dirname35(directory2))
|
|
111587
111936
|
invalid6();
|
|
111588
|
-
|
|
111937
|
+
mkdirSync21(directory2, { mode: 448 });
|
|
111589
111938
|
const owner2 = new RecoveryOwner(directory2), checked = intentSchema.parse(intent), intentSha256 = canonicalJsonSha256(checked);
|
|
111590
111939
|
owner2.write(`intent-${intentSha256}.json`, checked);
|
|
111591
111940
|
owner2.write("state.json", { contractVersion: 1, intentSha256, phase: "prepared", consentId: null });
|
|
@@ -113223,7 +113572,7 @@ var init_run_routing = __esm(() => {
|
|
|
113223
113572
|
});
|
|
113224
113573
|
|
|
113225
113574
|
// src/mcp/operation-tools.ts
|
|
113226
|
-
import { existsSync as existsSync29, readdirSync as
|
|
113575
|
+
import { existsSync as existsSync29, readdirSync as readdirSync22, statSync as statSync20 } from "fs";
|
|
113227
113576
|
import { join as join60 } from "path";
|
|
113228
113577
|
function registerOperationTools(server) {
|
|
113229
113578
|
server.registerTool("cloud_skill_eligibility", {
|
|
@@ -113705,7 +114054,7 @@ function registerOperationTools(server) {
|
|
|
113705
114054
|
let skillCount = 0;
|
|
113706
114055
|
if (exists) {
|
|
113707
114056
|
try {
|
|
113708
|
-
skillCount =
|
|
114057
|
+
skillCount = readdirSync22(agentSkillsPath).filter((f) => {
|
|
113709
114058
|
const full = join60(agentSkillsPath, f);
|
|
113710
114059
|
return !f.startsWith(".") && statSync20(full).isDirectory();
|
|
113711
114060
|
}).length;
|
|
@@ -113773,7 +114122,7 @@ var init_operation_tools = __esm(() => {
|
|
|
113773
114122
|
});
|
|
113774
114123
|
|
|
113775
114124
|
// src/lib/feedback.ts
|
|
113776
|
-
import { appendFileSync as appendFileSync2, existsSync as existsSync30, mkdirSync as
|
|
114125
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync30, mkdirSync as mkdirSync22 } from "fs";
|
|
113777
114126
|
import { dirname as dirname36, join as join61 } from "path";
|
|
113778
114127
|
import { Database } from "bun:sqlite";
|
|
113779
114128
|
function getFeedbackDbPath() {
|
|
@@ -113783,7 +114132,7 @@ function getFeedbackDb() {
|
|
|
113783
114132
|
const dbPath = getFeedbackDbPath();
|
|
113784
114133
|
const dir = dirname36(dbPath);
|
|
113785
114134
|
if (!existsSync30(dir))
|
|
113786
|
-
|
|
114135
|
+
mkdirSync22(dir, { recursive: true });
|
|
113787
114136
|
const db = new Database(dbPath);
|
|
113788
114137
|
db.exec("PRAGMA journal_mode = WAL");
|
|
113789
114138
|
db.exec([
|
|
@@ -113812,7 +114161,7 @@ function saveFeedback(input2) {
|
|
|
113812
114161
|
const path = join61(getDataDir(), "feedback.jsonl");
|
|
113813
114162
|
const dir = dirname36(path);
|
|
113814
114163
|
if (!existsSync30(dir))
|
|
113815
|
-
|
|
114164
|
+
mkdirSync22(dir, { recursive: true });
|
|
113816
114165
|
appendFileSync2(path, JSON.stringify({ message, category, email: input2.email ?? null, agent: input2.agent ?? null, version: input2.version ?? null, createdAt: new Date().toISOString() }) + `
|
|
113817
114166
|
`);
|
|
113818
114167
|
return { saved: true, category, path };
|
|
@@ -113973,7 +114322,7 @@ var init_resource_meta_tools = __esm(() => {
|
|
|
113973
114322
|
});
|
|
113974
114323
|
|
|
113975
114324
|
// src/lib/scheduler.ts
|
|
113976
|
-
import { existsSync as existsSync31, readFileSync as readFileSync40, writeFileSync as writeFileSync20, mkdirSync as
|
|
114325
|
+
import { existsSync as existsSync31, readFileSync as readFileSync40, writeFileSync as writeFileSync20, mkdirSync as mkdirSync23 } from "fs";
|
|
113977
114326
|
import { join as join62 } from "path";
|
|
113978
114327
|
function getSchedulesPath(targetDir = process.cwd()) {
|
|
113979
114328
|
return join62(targetDir, ".skills", "schedules.json");
|
|
@@ -113991,7 +114340,7 @@ function saveSchedules(data, targetDir = process.cwd()) {
|
|
|
113991
114340
|
const path = getSchedulesPath(targetDir);
|
|
113992
114341
|
const dir = join62(targetDir, ".skills");
|
|
113993
114342
|
if (!existsSync31(dir))
|
|
113994
|
-
|
|
114343
|
+
mkdirSync23(dir, { recursive: true });
|
|
113995
114344
|
writeFileSync20(path, JSON.stringify(data, null, 2));
|
|
113996
114345
|
}
|
|
113997
114346
|
function validateCronField(expr, min2, max2, label) {
|
|
@@ -114291,9 +114640,9 @@ var init_schedule_tools = __esm(() => {
|
|
|
114291
114640
|
import { createHash as createHash38, createHmac as createHmac3 } from "crypto";
|
|
114292
114641
|
import {
|
|
114293
114642
|
existsSync as existsSync32,
|
|
114294
|
-
mkdirSync as
|
|
114643
|
+
mkdirSync as mkdirSync24,
|
|
114295
114644
|
readFileSync as readFileSync41,
|
|
114296
|
-
readdirSync as
|
|
114645
|
+
readdirSync as readdirSync23,
|
|
114297
114646
|
statSync as statSync21,
|
|
114298
114647
|
writeFileSync as writeFileSync21
|
|
114299
114648
|
} from "fs";
|
|
@@ -114418,7 +114767,7 @@ function parsePositiveInteger(value) {
|
|
|
114418
114767
|
}
|
|
114419
114768
|
function walkFiles2(dir) {
|
|
114420
114769
|
const files = [];
|
|
114421
|
-
for (const entry of
|
|
114770
|
+
for (const entry of readdirSync23(dir)) {
|
|
114422
114771
|
const full = join63(dir, entry);
|
|
114423
114772
|
const stats = statSync21(full);
|
|
114424
114773
|
if (stats.isDirectory())
|
|
@@ -114657,7 +115006,7 @@ var init_private_publication_customer = __esm(() => {
|
|
|
114657
115006
|
});
|
|
114658
115007
|
|
|
114659
115008
|
// src/lib/private-publication-recovery.ts
|
|
114660
|
-
import { constants as constants27, closeSync as closeSync28, fsyncSync as fsyncSync9, fstatSync as fstatSync28, lstatSync as lstatSync38, mkdirSync as
|
|
115009
|
+
import { constants as constants27, closeSync as closeSync28, fsyncSync as fsyncSync9, fstatSync as fstatSync28, lstatSync as lstatSync38, mkdirSync as mkdirSync25, openSync as openSync28, readSync as readSync20, realpathSync as realpathSync18, renameSync as renameSync13, unlinkSync as unlinkSync9, writeFileSync as writeFileSync22 } from "fs";
|
|
114661
115010
|
import { dirname as dirname38, isAbsolute as isAbsolute35, join as join64, resolve as resolve35 } from "path";
|
|
114662
115011
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
114663
115012
|
function safeDirectory(directory3) {
|
|
@@ -114801,7 +115150,7 @@ async function preparePrivatePublication(client2, sourceDirectory, recoveryDirec
|
|
|
114801
115150
|
};
|
|
114802
115151
|
if (!isAbsolute35(recoveryDirectory) || resolve35(recoveryDirectory) !== recoveryDirectory || realpathSync18(dirname38(recoveryDirectory)) !== dirname38(recoveryDirectory))
|
|
114803
115152
|
return fail5();
|
|
114804
|
-
|
|
115153
|
+
mkdirSync25(recoveryDirectory, { mode: 448 });
|
|
114805
115154
|
safeDirectory(recoveryDirectory);
|
|
114806
115155
|
const parent = openSync28(dirname38(recoveryDirectory), constants27.O_RDONLY | constants27.O_NOFOLLOW);
|
|
114807
115156
|
try {
|
|
@@ -115364,7 +115713,7 @@ var exports_runtime_mcp = {};
|
|
|
115364
115713
|
__export(exports_runtime_mcp, {
|
|
115365
115714
|
handleMcp: () => handleMcp
|
|
115366
115715
|
});
|
|
115367
|
-
import { existsSync as existsSync33, mkdirSync as
|
|
115716
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync26, readFileSync as readFileSync42, writeFileSync as writeFileSync23 } from "fs";
|
|
115368
115717
|
import { homedir as homedir10 } from "os";
|
|
115369
115718
|
import { dirname as dirname39, join as join65 } from "path";
|
|
115370
115719
|
async function handleMcp(options) {
|
|
@@ -115540,7 +115889,7 @@ function writeJsonObject(path, data) {
|
|
|
115540
115889
|
`);
|
|
115541
115890
|
}
|
|
115542
115891
|
function writeTextFile(path, content) {
|
|
115543
|
-
|
|
115892
|
+
mkdirSync26(dirname39(path), { recursive: true });
|
|
115544
115893
|
writeFileSync23(path, content.endsWith(`
|
|
115545
115894
|
`) ? content : `${content}
|
|
115546
115895
|
`);
|
|
@@ -115735,7 +116084,7 @@ async function validateReviewedRuntimeLock(bytes, sha2563, context2) {
|
|
|
115735
116084
|
throw new Error("REVIEWED_LOCK_LOCATION_INVALID");
|
|
115736
116085
|
if (location === `node_modules/${PACKAGE2}`)
|
|
115737
116086
|
continue;
|
|
115738
|
-
if (typeof entry.version !== "string" || !
|
|
116087
|
+
if (typeof entry.version !== "string" || !VERSION2.test(entry.version) || typeof entry.resolved !== "string" || typeof entry.integrity !== "string" || !INTEGRITY.test(entry.integrity))
|
|
115739
116088
|
throw new Error("REVIEWED_LOCK_PACKAGE_INVALID");
|
|
115740
116089
|
let url2;
|
|
115741
116090
|
try {
|
|
@@ -115767,10 +116116,10 @@ async function validateReviewedRuntimeLock(bytes, sha2563, context2) {
|
|
|
115767
116116
|
}));
|
|
115768
116117
|
}
|
|
115769
116118
|
}
|
|
115770
|
-
var PACKAGE2 = "@hasna/skills", NAME2,
|
|
116119
|
+
var PACKAGE2 = "@hasna/skills", NAME2, VERSION2, INTEGRITY, MAX_LOCK_BYTES, MAX_METADATA_BYTES;
|
|
115771
116120
|
var init_reviewed_runtime_lock = __esm(() => {
|
|
115772
116121
|
NAME2 = /^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/;
|
|
115773
|
-
|
|
116122
|
+
VERSION2 = /^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?(?:\+[a-zA-Z0-9.-]+)?$/;
|
|
115774
116123
|
INTEGRITY = /^sha512-[A-Za-z0-9+/]{86}==$/;
|
|
115775
116124
|
MAX_LOCK_BYTES = 8 * 1024 * 1024;
|
|
115776
116125
|
MAX_METADATA_BYTES = 32 * 1024 * 1024;
|
|
@@ -115780,15 +116129,15 @@ var init_reviewed_runtime_lock = __esm(() => {
|
|
|
115780
116129
|
import { createHash as createHash40, randomUUID as randomUUID10 } from "crypto";
|
|
115781
116130
|
import { Readable } from "stream";
|
|
115782
116131
|
import { createGunzip as createGunzip2 } from "zlib";
|
|
115783
|
-
import { spawnSync as
|
|
116132
|
+
import { spawnSync as spawnSync6 } from "child_process";
|
|
115784
116133
|
import {
|
|
115785
116134
|
chmodSync as chmodSync4,
|
|
115786
116135
|
copyFileSync,
|
|
115787
116136
|
existsSync as existsSync34,
|
|
115788
116137
|
lstatSync as lstatSync39,
|
|
115789
|
-
mkdirSync as
|
|
116138
|
+
mkdirSync as mkdirSync27,
|
|
115790
116139
|
readFileSync as readFileSync43,
|
|
115791
|
-
readdirSync as
|
|
116140
|
+
readdirSync as readdirSync24,
|
|
115792
116141
|
readlinkSync as readlinkSync8,
|
|
115793
116142
|
realpathSync as realpathSync19,
|
|
115794
116143
|
renameSync as renameSync14,
|
|
@@ -115859,7 +116208,7 @@ function verifyTargetPrerequisites(manifest, packageRoot, home, cwd2, pathValue)
|
|
|
115859
116208
|
for (const key2 of ["SUMI_CONFIG", "SUMI_CONFIG_CONTENT"])
|
|
115860
116209
|
if (process.env[key2] !== undefined)
|
|
115861
116210
|
env3[key2] = "";
|
|
115862
|
-
const child2 =
|
|
116211
|
+
const child2 = spawnSync6(pinnedLauncherRuntime(), [...PINNED_LAUNCHER_BUN_FLAGS2, entry, home, cwd2], {
|
|
115863
116212
|
cwd: dirname40(packageRoot),
|
|
115864
116213
|
env: env3,
|
|
115865
116214
|
encoding: "buffer",
|
|
@@ -115933,7 +116282,7 @@ function assertNoSymlinkAncestors(path) {
|
|
|
115933
116282
|
function acquireRuntimeLock(runtimeRoot) {
|
|
115934
116283
|
const lockPath = join66(runtimeRoot, ".copyfile-update-lock");
|
|
115935
116284
|
try {
|
|
115936
|
-
|
|
116285
|
+
mkdirSync27(lockPath, { mode: 448 });
|
|
115937
116286
|
} catch {
|
|
115938
116287
|
throw new Error("RUNTIME_UPDATE_LOCKED");
|
|
115939
116288
|
}
|
|
@@ -116202,7 +116551,7 @@ async function downloadPackage(version2, stagingRoot, registryOrigin, fetcher) {
|
|
|
116202
116551
|
throw new Error("TARBALL_PACKAGE_IDENTITY_MISMATCH");
|
|
116203
116552
|
const bins = packageBins(unpacked);
|
|
116204
116553
|
const archiveRoot = join66(stagingRoot, "verified-archive");
|
|
116205
|
-
|
|
116554
|
+
mkdirSync27(archiveRoot, { mode: 448 });
|
|
116206
116555
|
await archive.extract(archiveRoot);
|
|
116207
116556
|
const extractedPackage = join66(archiveRoot, "package");
|
|
116208
116557
|
const extracted = readTree(extractedPackage, false);
|
|
@@ -116253,7 +116602,7 @@ function readTree(root2, includeModes, excludeNpmDependencies = false) {
|
|
|
116253
116602
|
const base3 = realpathSync19(root2);
|
|
116254
116603
|
const entries = [];
|
|
116255
116604
|
const walk2 = (dir, prefix = "") => {
|
|
116256
|
-
for (const item of
|
|
116605
|
+
for (const item of readdirSync24(dir).sort()) {
|
|
116257
116606
|
const path = join66(dir, item);
|
|
116258
116607
|
const rel = prefix ? `${prefix}/${item}` : item;
|
|
116259
116608
|
const stat3 = lstatSync39(path);
|
|
@@ -116297,7 +116646,7 @@ function normalizeModes(root2) {
|
|
|
116297
116646
|
throw new Error("RUNTIME_ENTRY_TYPE_UNSUPPORTED");
|
|
116298
116647
|
chmodSync4(root2, rootStat.mode & 493);
|
|
116299
116648
|
const walk2 = (dir) => {
|
|
116300
|
-
for (const item of
|
|
116649
|
+
for (const item of readdirSync24(dir)) {
|
|
116301
116650
|
const path = join66(dir, item);
|
|
116302
116651
|
const stat3 = lstatSync39(path);
|
|
116303
116652
|
if (stat3.isSymbolicLink())
|
|
@@ -116358,7 +116707,7 @@ function verifyPreimageManifest(runtimePath, receipt, home) {
|
|
|
116358
116707
|
}
|
|
116359
116708
|
function captureConfigPreimages(home, stage) {
|
|
116360
116709
|
const root2 = join66(stage, "preimage", "configs");
|
|
116361
|
-
|
|
116710
|
+
mkdirSync27(root2, { recursive: true, mode: 448 });
|
|
116362
116711
|
return CONFIG_PREIMAGE_PATHS.map((relativePath) => {
|
|
116363
116712
|
const sourcePath = join66(home, relativePath);
|
|
116364
116713
|
if (!entryExists(sourcePath))
|
|
@@ -116368,7 +116717,7 @@ function captureConfigPreimages(home, stage) {
|
|
|
116368
116717
|
throw new Error("CONFIG_PREIMAGE_NOT_REGULAR_FILE");
|
|
116369
116718
|
const bytes = readFileSync43(sourcePath);
|
|
116370
116719
|
const backupPath = join66(root2, relativePath);
|
|
116371
|
-
|
|
116720
|
+
mkdirSync27(dirname40(backupPath), { recursive: true, mode: 448 });
|
|
116372
116721
|
writeFileSync24(backupPath, bytes, { flag: "wx", mode: 384 });
|
|
116373
116722
|
chmodSync4(backupPath, 384);
|
|
116374
116723
|
const readback = readFileSync43(backupPath);
|
|
@@ -116521,7 +116870,7 @@ function persistReceipt(path, value) {
|
|
|
116521
116870
|
return;
|
|
116522
116871
|
const historyRoot = join66(dirname40(path), "receipt-history");
|
|
116523
116872
|
if (!entryExists(historyRoot))
|
|
116524
|
-
|
|
116873
|
+
mkdirSync27(historyRoot, { mode: 448 });
|
|
116525
116874
|
const historyStat = lstatSync39(historyRoot);
|
|
116526
116875
|
if (!historyStat.isDirectory() || historyStat.isSymbolicLink() || (historyStat.mode & 63) !== 0)
|
|
116527
116876
|
throw new Error("RECEIPT_HISTORY_NOT_PRIVATE");
|
|
@@ -116545,7 +116894,7 @@ function persistAliasReceipt(path, value) {
|
|
|
116545
116894
|
return;
|
|
116546
116895
|
const history = join66(dirname40(path), "history");
|
|
116547
116896
|
if (!entryExists(history))
|
|
116548
|
-
|
|
116897
|
+
mkdirSync27(history, { mode: 448 });
|
|
116549
116898
|
const historyStat = lstatSync39(history);
|
|
116550
116899
|
if (!historyStat.isDirectory() || historyStat.isSymbolicLink() || (historyStat.mode & 63) !== 0)
|
|
116551
116900
|
throw new Error("ALIAS_RECEIPT_HISTORY_UNSAFE");
|
|
@@ -116702,7 +117051,7 @@ function adoptCopyfileAliases(options = {}) {
|
|
|
116702
117051
|
}
|
|
116703
117052
|
if (!aliases.length)
|
|
116704
117053
|
return { adopted: true, version: layout.currentVersion, aliasCount: 0 };
|
|
116705
|
-
|
|
117054
|
+
mkdirSync27(receiptDir, { recursive: true, mode: 448 });
|
|
116706
117055
|
const receiptDirStat = lstatSync39(receiptDir);
|
|
116707
117056
|
if (!receiptDirStat.isDirectory() || receiptDirStat.isSymbolicLink() || receiptDirStat.mode & 63)
|
|
116708
117057
|
throw new Error("ALIAS_RECEIPT_DIRECTORY_UNSAFE");
|
|
@@ -116928,7 +117277,7 @@ async function updateCopyfileRuntime(version2, options = {}) {
|
|
|
116928
117277
|
try {
|
|
116929
117278
|
if (entryExists(finalPath))
|
|
116930
117279
|
throw new Error("TARGET_RUNTIME_ALREADY_EXISTS");
|
|
116931
|
-
|
|
117280
|
+
mkdirSync27(stagePath, { mode: 448 });
|
|
116932
117281
|
chmodSync4(stagePath, 448);
|
|
116933
117282
|
const configPreimages = captureConfigPreimages(home, stagePath);
|
|
116934
117283
|
const fetcher = options.fetcher ?? fetch;
|
|
@@ -116937,7 +117286,7 @@ async function updateCopyfileRuntime(version2, options = {}) {
|
|
|
116937
117286
|
throw new Error("PACKAGE_BIN_SET_CHANGED");
|
|
116938
117287
|
}
|
|
116939
117288
|
const stagePackage = join66(stagePath, "install");
|
|
116940
|
-
|
|
117289
|
+
mkdirSync27(stagePackage, { mode: 448 });
|
|
116941
117290
|
copyFileSync(artifact.tarballPath, join66(stagePackage, "verified.tgz"));
|
|
116942
117291
|
writeFileSync24(join66(stagePackage, "package.json"), JSON.stringify({ name: "skills-runtime-install", version: "0.0.0", private: true, dependencies: { [PACKAGE_NAME]: "file:./verified.tgz" } }, null, 2), { mode: 384, flag: "wx" });
|
|
116943
117292
|
let npmVersion;
|
|
@@ -117107,7 +117456,7 @@ function rollbackCopyfileRuntime(receiptId, options = {}) {
|
|
|
117107
117456
|
throw new Error("RUNTIME_ROOT_NOT_PRIVATE");
|
|
117108
117457
|
const releaseLock = acquireRuntimeLock(runtimeRoot);
|
|
117109
117458
|
try {
|
|
117110
|
-
const matches2 =
|
|
117459
|
+
const matches2 = readdirSync24(runtimeRoot).filter((name) => {
|
|
117111
117460
|
if (!/^\d+\.\d+\.\d+-copyfile$/.test(name))
|
|
117112
117461
|
return false;
|
|
117113
117462
|
const receipt2 = join66(runtimeRoot, name, "rollout-receipt.json");
|
|
@@ -117211,7 +117560,7 @@ __export(exports_runtime, {
|
|
|
117211
117560
|
registerRuntime: () => registerRuntime
|
|
117212
117561
|
});
|
|
117213
117562
|
import { createHash as createHash41, randomUUID as randomUUID11 } from "crypto";
|
|
117214
|
-
import { lstatSync as lstatSync40, mkdirSync as
|
|
117563
|
+
import { lstatSync as lstatSync40, mkdirSync as mkdirSync28, readFileSync as readFileSync44, writeFileSync as writeFileSync25 } from "fs";
|
|
117215
117564
|
import { basename as basename22, isAbsolute as isAbsolute38, join as join67 } from "path";
|
|
117216
117565
|
import { createInterface } from "readline";
|
|
117217
117566
|
function registerRuntime(parent) {
|
|
@@ -117271,14 +117620,14 @@ function registerRuntime(parent) {
|
|
|
117271
117620
|
const exportsCommand = parent.command("exports").description("Inspect or open skill run exports");
|
|
117272
117621
|
exportsCommand.command("open").argument("<run-id>", "Run id").option("--json", "Output as JSON", false).description("Open the export directory for a run").action((runId2, options) => handleExportsOpen(runId2, options));
|
|
117273
117622
|
exportsCommand.command("download").argument("<run-id>", "Remote run id").option("--json", "Output as JSON", false).description("Download remote run artifacts into .skills/exports").action((runId2, options) => handleExportsDownload(runId2, options));
|
|
117274
|
-
parent.command("mcp").option("--register <agent>", "Register MCP server with agent").option("--json", "Output registration result as JSON", false).
|
|
117623
|
+
permitStrayArguments(parent.command("mcp").option("--register <agent>", "Register MCP server with agent").option("--json", "Output registration result as JSON", false).description("Start MCP server (stdio) or register with an agent").action(async (options, command) => {
|
|
117275
117624
|
const stray = command.args[0];
|
|
117276
117625
|
if (stray !== undefined) {
|
|
117277
117626
|
console.error(source_default.red(`error: unknown argument '${stray}'. 'skills mcp' takes no positional arguments. ` + `Valid forms: 'skills mcp' (start the MCP stdio server), ` + `'skills mcp --register <agent>', 'skills mcp --register all'`));
|
|
117278
117627
|
process.exit(1);
|
|
117279
117628
|
}
|
|
117280
117629
|
await handleMcp(options);
|
|
117281
|
-
});
|
|
117630
|
+
}));
|
|
117282
117631
|
const setup = parent.command("setup").description("Point this CLI at a Skills API server, or register agent integrations").option("--api-url <url>", "Skills API origin to send remote work to").option("--global", "Accepted for compatibility; the API origin is always per-user", false).option("--json", "Output setup result as JSON", false).action(async (options) => handleSetup(options));
|
|
117283
117632
|
setup.command("agents").option("--json", "Output registration result as JSON", false).description("Register the Skills MCP server with all supported agents").action(async (options) => handleMcp({ register: "all", json: options.json }));
|
|
117284
117633
|
parent.command("self-update").description("Update @hasna/skills to the latest version").option("--json", "Output result as JSON", false).option("--version <version>", "Install this exact @hasna/skills version as a staged copyfile runtime").option("--min-release-age <days>", "Require a positive integer dependency release age in days for an exact-version update").option("--min-release-age-exclude <pattern>", "Exclude matching package identities from the release-age policy (repeatable)", (pattern, prior) => [...prior, pattern], []).option("--reviewed-lock <path>", "Install from this private absolute package-lock.json path without resolving dependency ranges").option("--reviewed-lock-sha256 <sha256>", "Exact reviewed SHA-256 of the supplied package-lock.json").option("--rollback <receipt-id>", "Restore launcher links from an exact copyfile rollout receipt").option("--adopt-aliases", "Switch verified legacy @hasna/skills aliases to the active copyfile runtime").option("--rollback-aliases <receipt-id>", "Restore aliases from an exact adoption receipt").action(async (options) => {
|
|
@@ -118128,7 +118477,7 @@ async function handleExportsDownload(runId2, options) {
|
|
|
118128
118477
|
const canonicalSkill = typeof remoteRun.skill === "string" ? remoteRun.skill : "remote";
|
|
118129
118478
|
const requestedSkill = typeof remoteRun.requestedSlug === "string" && remoteRun.requestedSlug.trim() ? remoteRun.requestedSlug : canonicalSkill;
|
|
118130
118479
|
const exportDir = getRunExportDir(runId2, requestedSkill);
|
|
118131
|
-
|
|
118480
|
+
mkdirSync28(exportDir, { recursive: true });
|
|
118132
118481
|
const downloaded = [];
|
|
118133
118482
|
for (const artifact of artifacts) {
|
|
118134
118483
|
const artifactId = String(artifact.id || "");
|
|
@@ -118182,7 +118531,7 @@ function ensureSafeExportParent(root2, relativePath) {
|
|
|
118182
118531
|
} catch (error61) {
|
|
118183
118532
|
if (error61.code !== "ENOENT")
|
|
118184
118533
|
throw error61;
|
|
118185
|
-
|
|
118534
|
+
mkdirSync28(parent, { mode: 448 });
|
|
118186
118535
|
}
|
|
118187
118536
|
}
|
|
118188
118537
|
}
|
|
@@ -118373,6 +118722,7 @@ var init_runtime = __esm(() => {
|
|
|
118373
118722
|
init_execution_secrets();
|
|
118374
118723
|
init_context();
|
|
118375
118724
|
init_registry();
|
|
118725
|
+
init_stray_arguments();
|
|
118376
118726
|
init_skillinfo();
|
|
118377
118727
|
init_skill_contract();
|
|
118378
118728
|
init_blog_article();
|
|
@@ -118771,7 +119121,7 @@ var init_completion = __esm(() => {
|
|
|
118771
119121
|
});
|
|
118772
119122
|
|
|
118773
119123
|
// src/lib/portable-snapshot-filter.ts
|
|
118774
|
-
import { readdirSync as
|
|
119124
|
+
import { readdirSync as readdirSync25, statSync as statSync22 } from "fs";
|
|
118775
119125
|
import { homedir as homedir11 } from "os";
|
|
118776
119126
|
import { join as join68, sep as sep19 } from "path";
|
|
118777
119127
|
function isExcludedSkillFileName(fileName) {
|
|
@@ -118810,7 +119160,7 @@ function destinationFor(definition, stationId, relativePath) {
|
|
|
118810
119160
|
function walkEntries(absoluteRoot) {
|
|
118811
119161
|
let entries;
|
|
118812
119162
|
try {
|
|
118813
|
-
entries =
|
|
119163
|
+
entries = readdirSync25(absoluteRoot, { withFileTypes: true });
|
|
118814
119164
|
} catch {
|
|
118815
119165
|
return [];
|
|
118816
119166
|
}
|
|
@@ -118923,7 +119273,7 @@ var init_portable_snapshot_filter = __esm(() => {
|
|
|
118923
119273
|
import { createHash as createHash42 } from "crypto";
|
|
118924
119274
|
import {
|
|
118925
119275
|
copyFileSync as copyFileSync2,
|
|
118926
|
-
mkdirSync as
|
|
119276
|
+
mkdirSync as mkdirSync29,
|
|
118927
119277
|
readFileSync as readFileSync45,
|
|
118928
119278
|
statSync as statSync23,
|
|
118929
119279
|
writeFileSync as writeFileSync26
|
|
@@ -119056,7 +119406,7 @@ function writeStationSnapshot(options) {
|
|
|
119056
119406
|
let written = 0;
|
|
119057
119407
|
for (const plan of untouched) {
|
|
119058
119408
|
const destination = resolve37(repoRoot, plan.destination);
|
|
119059
|
-
|
|
119409
|
+
mkdirSync29(dirname42(destination), { recursive: true });
|
|
119060
119410
|
copyFileSync2(plan.source.fullPath, destination);
|
|
119061
119411
|
written += 1;
|
|
119062
119412
|
}
|
|
@@ -119075,7 +119425,7 @@ function writeStationSnapshot(options) {
|
|
|
119075
119425
|
files: manifestFiles
|
|
119076
119426
|
};
|
|
119077
119427
|
const manifestPath = resolve37(repoRoot, "resources", options.stationId, "skills", "sync-manifest.json");
|
|
119078
|
-
|
|
119428
|
+
mkdirSync29(dirname42(manifestPath), { recursive: true });
|
|
119079
119429
|
writeFileSync26(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
119080
119430
|
`);
|
|
119081
119431
|
return {
|
|
@@ -119757,7 +120107,7 @@ var init_codex_hook_policy_recovery = __esm(() => {
|
|
|
119757
120107
|
});
|
|
119758
120108
|
|
|
119759
120109
|
// src/lib/agent-codex-trust.ts
|
|
119760
|
-
import { lstatSync as lstatSync44, mkdirSync as
|
|
120110
|
+
import { lstatSync as lstatSync44, mkdirSync as mkdirSync30, readdirSync as readdirSync26, readFileSync as readFileSync46, realpathSync as realpathSync21, statSync as statSync24 } from "fs";
|
|
119761
120111
|
import { createHash as createHash43, randomUUID as randomUUID12 } from "crypto";
|
|
119762
120112
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
119763
120113
|
import { dirname as dirname45, isAbsolute as isAbsolute41, join as join72, resolve as resolve40 } from "path";
|
|
@@ -119943,7 +120293,7 @@ async function reconcileCodexNativeHooks(options, connect = connectCodexHookRpc)
|
|
|
119943
120293
|
if (recovery?.reviewedPlanDigest !== undefined)
|
|
119944
120294
|
need8(recovery.reviewedPlanDigest === recoveryPlanDigest, "RECONCILE_RECOVERY_PLAN_CHANGED");
|
|
119945
120295
|
const preview2 = !!recovery && recovery.reviewedPlanDigest === undefined;
|
|
119946
|
-
const receipt = { version: 1, status: preview2 ? "recovery-review-required" : supersededBinding ? "superseded" : "reconciled", reconciled: !preview2, supersededBinding, automaticRollback: false, journal, planDigest: intent.planDigest, nativeVersion: rpc.version, nativeStateVerified: !nativeTrustPending, nativeTrustPending, bindingRefreshRequired: !!configDiscoveryRecovery, nativeExecutionVerified: false, configSha256: currentConfig.sha256, hooksSha256: hooksCurrent.sha256, policySha256: policyBefore.sha256, policyBeforeSha256: policyBefore.sha256, policyCurrentSha256: policyCurrent.sha256, previousSkillsCli: intent.skillsCli, skillsCli: skillsCli.receipt, releaseProof: options.releaseProof, nativeInventoryScope: recordedNativeHooks ? "complete" : "declared-managed-hooks-only", unrelatedNativeHooksPreserved: !!recordedNativeHooks, unrelatedSettingsAndCommentsPreserved: true, ...recoveryPlan ? { recoveryPlan, recoveryPlanDigest } : {} };
|
|
120296
|
+
const receipt = { version: 1, status: preview2 ? "recovery-review-required" : supersededBinding ? "superseded" : "reconciled", reconciled: !preview2, supersededBinding, automaticRollback: false, journal, planDigest: intent.planDigest, nativeVersion: rpc.version, nativeStateVerified: !nativeTrustPending, nativeTrustPending, bindingRefreshRequired: !!configDiscoveryRecovery, nativeExecutionVerified: false, configSha256: currentConfig.sha256, hooksSha256: hooksCurrent.sha256, policySha256: policyBefore.sha256, policyBeforeSha256: policyBefore.sha256, policyCurrentSha256: policyCurrent.sha256, previousSkillsCli: intent.skillsCli, skillsCli: skillsCli.receipt, releaseProof: options.releaseProof, nativeInventoryScope: recordedNativeHooks ? "complete" : "declared-managed-hooks-only", unrelatedNativeHooksPreserved: !!recordedNativeHooks, unrelatedSettingsAndCommentsPreserved: true, ...recoveryPlan ? { recoveryPlan, recoveryPlanDigest } : {}, ...codexAdmissionReceipt(rpc.admission) };
|
|
119947
120297
|
if (preview2)
|
|
119948
120298
|
return receipt;
|
|
119949
120299
|
save(join72(journal, "receipt.json"), json2(receipt));
|
|
@@ -119957,9 +120307,9 @@ async function reconcileCodexNativeHooks(options, connect = connectCodexHookRpc)
|
|
|
119957
120307
|
}
|
|
119958
120308
|
async function enrollCodexNativeHooks(options = {}, connect = connectCodexHookRpc) {
|
|
119959
120309
|
const home = resolve40(options.home ?? homedir13());
|
|
119960
|
-
return withCodexCorpusWriteAsync([join72(home, ".codex")], () => enrollCodexNativeHooksUnlocked(options, connect), options);
|
|
120310
|
+
return withCodexCorpusWriteAsync([join72(home, ".codex")], (_assertCurrent, admission) => enrollCodexNativeHooksUnlocked(options, connect, admission), options);
|
|
119961
120311
|
}
|
|
119962
|
-
async function enrollCodexNativeHooksUnlocked(options, connect) {
|
|
120312
|
+
async function enrollCodexNativeHooksUnlocked(options, connect, admission) {
|
|
119963
120313
|
let rpc, journal;
|
|
119964
120314
|
try {
|
|
119965
120315
|
const home = resolve40(options.home ?? homedir13()), dataDir3 = resolve40(options.dataDir ?? getDataDirReadOnly());
|
|
@@ -120020,14 +120370,14 @@ async function enrollCodexNativeHooksUnlocked(options, connect) {
|
|
|
120020
120370
|
checkInputs();
|
|
120021
120371
|
const digestInput = { version: 1, home, configPath, ...nativeConfigPath !== configPath ? { nativeConfigPath } : {}, configSha256: configFile.sha256, configVersion: layers[0].version, policySha256: policyFile.sha256, hooksSha256: hooksFile.sha256, skillsCli: skillsCli.receipt, nativeVersion: rpc.version, declarations: expected, admitted };
|
|
120022
120372
|
const planDigest = makePlanDigest(digestInput);
|
|
120023
|
-
const baseReceipt = { planDigest, skillsCli: skillsCli.receipt, nativeVersion: rpc.version, nativeConfigPath, ownedNativeProcessId: rpc.processId, agent: "codex", applied: false, planned, nativeEligible: planned.length === 0, bindingRefreshRequired: false, transport: "owned-stdio-process", existingSessionsReloaded: false, nativeExecutionVerified: false };
|
|
120373
|
+
const baseReceipt = { planDigest, skillsCli: skillsCli.receipt, nativeVersion: rpc.version, nativeConfigPath, ownedNativeProcessId: rpc.processId, agent: "codex", applied: false, planned, nativeEligible: planned.length === 0, bindingRefreshRequired: false, transport: "owned-stdio-process", existingSessionsReloaded: false, nativeExecutionVerified: false, ...codexAdmissionReceipt(admission) };
|
|
120024
120374
|
if (options.apply)
|
|
120025
120375
|
need8(options.reviewedPlanDigest === planDigest, "PLAN_CHANGED: run the dry-run again and pass its reviewed --plan-digest with --apply");
|
|
120026
120376
|
const parent = join72(dataDir3, "native-hook-trust");
|
|
120027
120377
|
const st = lstatSync44(parent, { throwIfNoEntry: false });
|
|
120028
120378
|
if (st) {
|
|
120029
120379
|
need8(st.isDirectory() && !st.isSymbolicLink() && st.uid === process.getuid() && (st.mode & 511) === 448, "UNSAFE_JOURNAL");
|
|
120030
|
-
const priorJournals =
|
|
120380
|
+
const priorJournals = readdirSync26(parent);
|
|
120031
120381
|
need8(priorJournals.length < 1000, "JOURNAL_BOUND");
|
|
120032
120382
|
for (const name of priorJournals) {
|
|
120033
120383
|
need8(/^[a-f0-9-]{36}$/.test(name), "UNSAFE_JOURNAL");
|
|
@@ -120037,13 +120387,13 @@ async function enrollCodexNativeHooksUnlocked(options, connect) {
|
|
|
120037
120387
|
if (!options.apply || !planned.length)
|
|
120038
120388
|
return baseReceipt;
|
|
120039
120389
|
if (!st)
|
|
120040
|
-
|
|
120390
|
+
mkdirSync30(parent, { mode: 448 });
|
|
120041
120391
|
journal = join72(parent, randomUUID12());
|
|
120042
|
-
|
|
120392
|
+
mkdirSync30(journal, { mode: 448 });
|
|
120043
120393
|
save(join72(journal, "config.before.toml"), configFile.bytes);
|
|
120044
120394
|
save(join72(journal, "hooks.before.json"), hooksFile.bytes);
|
|
120045
120395
|
save(join72(journal, "policy.before.json"), policyFile.bytes);
|
|
120046
|
-
save(join72(journal, "intent.json"), json2({ ...digestInput, planDigest, hooks: planned, nativeHooks: discovered.map(safeNativeHook) }));
|
|
120396
|
+
save(join72(journal, "intent.json"), json2({ ...digestInput, planDigest, hooks: planned, nativeHooks: discovered.map(safeNativeHook), ...codexAdmissionReceipt(admission) }));
|
|
120047
120397
|
need8(isDeepStrictEqual19(admit(await list2()), admitted), "NATIVE_DISCOVERY_CHANGED");
|
|
120048
120398
|
checkInputs();
|
|
120049
120399
|
let result2;
|
|
@@ -120081,7 +120431,7 @@ async function enrollCodexNativeHooksUnlocked(options, connect) {
|
|
|
120081
120431
|
const message = error61 instanceof Error && error61.message.startsWith("CODEX_HOOK_TRUST_") ? error61.message : "CODEX_HOOK_TRUST_REFUSED: verify managed bridge installation and native Codex support";
|
|
120082
120432
|
if (journal) {
|
|
120083
120433
|
try {
|
|
120084
|
-
save(join72(journal, "stopped.json"), json2({ error: message.split(":")[0], automaticRollback: false, reconcileBeforeRetry: true }));
|
|
120434
|
+
save(join72(journal, "stopped.json"), json2({ error: message.split(":")[0], automaticRollback: false, reconcileBeforeRetry: true, ...codexAdmissionReceipt(admission) }));
|
|
120085
120435
|
} catch {}
|
|
120086
120436
|
}
|
|
120087
120437
|
throw new Error(message);
|
|
@@ -120200,7 +120550,7 @@ var init_codex_native_trust = __esm(() => {
|
|
|
120200
120550
|
|
|
120201
120551
|
// src/lib/claude-prospective-review.ts
|
|
120202
120552
|
import { createHash as createHash45 } from "crypto";
|
|
120203
|
-
import { lstatSync as lstatSync45, readFileSync as readFileSync48, readdirSync as
|
|
120553
|
+
import { lstatSync as lstatSync45, readFileSync as readFileSync48, readdirSync as readdirSync27, realpathSync as realpathSync22 } from "fs";
|
|
120204
120554
|
import { basename as basename23, dirname as dirname46, isAbsolute as isAbsolute42, join as join74, relative as relative15, resolve as resolve42, sep as sep21 } from "path";
|
|
120205
120555
|
import { isDeepStrictEqual as isDeepStrictEqual20 } from "util";
|
|
120206
120556
|
function hashClaudeDiscoveryBinding(binding) {
|
|
@@ -120290,7 +120640,7 @@ function captureClaudeProspectiveCandidateClosure(root2) {
|
|
|
120290
120640
|
let bytes = 0;
|
|
120291
120641
|
const walk2 = (directory3) => {
|
|
120292
120642
|
const beforeDirectory = lstatSync45(directory3);
|
|
120293
|
-
const names =
|
|
120643
|
+
const names = readdirSync27(directory3).sort();
|
|
120294
120644
|
if (new Set(names).size !== names.length)
|
|
120295
120645
|
refuse8("candidate contains ambiguous directory entries");
|
|
120296
120646
|
for (const name of names) {
|
|
@@ -120445,7 +120795,7 @@ function assertNoUnprojectedSkillPayload(root2, catalogPath, marketplace, plugin
|
|
|
120445
120795
|
if (entries[0].skills !== undefined || entries[0].commands !== undefined)
|
|
120446
120796
|
refuse8("candidate marketplace entry declares native skill or command payloads");
|
|
120447
120797
|
const walk2 = (directory3) => {
|
|
120448
|
-
for (const name of
|
|
120798
|
+
for (const name of readdirSync27(directory3).sort()) {
|
|
120449
120799
|
const path = join74(directory3, name), rel = relative15(root2, path).split(sep21).join("/");
|
|
120450
120800
|
const stat3 = lstatSync45(path);
|
|
120451
120801
|
if (stat3.isDirectory())
|
|
@@ -121399,11 +121749,16 @@ function registerAgentIntegration(parent) {
|
|
|
121399
121749
|
throw new Error("CODEX_NATIVE_SKILL_CATALOG_ABSOLUTE_PATH_REQUIRED");
|
|
121400
121750
|
if (existsSync36(options.output))
|
|
121401
121751
|
throw new Error("CODEX_NATIVE_SKILL_CATALOG_OUTPUT_EXISTS");
|
|
121752
|
+
let admission;
|
|
121402
121753
|
const catalog = await captureCodexNativeSkillCatalog({
|
|
121403
121754
|
command: options.codexCommand,
|
|
121404
121755
|
home: homedir14(),
|
|
121405
121756
|
...process.env.CODEX_HOME === undefined ? {} : { codexHome: process.env.CODEX_HOME },
|
|
121406
121757
|
cwd: options.cwd
|
|
121758
|
+
}, async (connection) => {
|
|
121759
|
+
const rpc = await connectCodexHookRpc(connection);
|
|
121760
|
+
admission = rpc.admission;
|
|
121761
|
+
return rpc;
|
|
121407
121762
|
});
|
|
121408
121763
|
const bytes = JSON.stringify(catalog, null, 2) + `
|
|
121409
121764
|
`;
|
|
@@ -121423,7 +121778,8 @@ function registerAgentIntegration(parent) {
|
|
|
121423
121778
|
skillCount: catalog.skills.length,
|
|
121424
121779
|
output: options.output,
|
|
121425
121780
|
bytes: Buffer.byteLength(bytes),
|
|
121426
|
-
sha256: createHash47("sha256").update(bytes).digest("hex")
|
|
121781
|
+
sha256: createHash47("sha256").update(bytes).digest("hex"),
|
|
121782
|
+
...codexAdmissionReceipt(admission)
|
|
121427
121783
|
};
|
|
121428
121784
|
await writeCliOutput(options.json ? JSON.stringify(receipt) : `Captured ${receipt.skillCount} native Codex skill(s) in ${receipt.output}.`);
|
|
121429
121785
|
} catch (error61) {
|
|
@@ -121767,6 +122123,8 @@ var init_agent_integration2 = __esm(() => {
|
|
|
121767
122123
|
init_claude_marketplace_entry_witness();
|
|
121768
122124
|
init_claude_prospective_review();
|
|
121769
122125
|
init_codex_native_skill_catalog();
|
|
122126
|
+
init_codex_hook_rpc();
|
|
122127
|
+
init_codex_corpus_write();
|
|
121770
122128
|
init_self_spawn();
|
|
121771
122129
|
init_config();
|
|
121772
122130
|
init_claude_installer_capture();
|
|
@@ -122409,8 +122767,8 @@ var init_grants = __esm(() => {
|
|
|
122409
122767
|
import { createHash as createHash48 } from "crypto";
|
|
122410
122768
|
import {
|
|
122411
122769
|
copyFileSync as copyFileSync3,
|
|
122412
|
-
mkdirSync as
|
|
122413
|
-
readdirSync as
|
|
122770
|
+
mkdirSync as mkdirSync31,
|
|
122771
|
+
readdirSync as readdirSync28,
|
|
122414
122772
|
readFileSync as readFileSync50,
|
|
122415
122773
|
statSync as statSync25,
|
|
122416
122774
|
writeFileSync as writeFileSync30
|
|
@@ -122454,7 +122812,7 @@ function planStationHydration(stationId, repoRoot) {
|
|
|
122454
122812
|
const agentRoot = join76(snapshotRoot, "agent-homes", agent);
|
|
122455
122813
|
let identEntries;
|
|
122456
122814
|
try {
|
|
122457
|
-
identEntries =
|
|
122815
|
+
identEntries = readdirSync28(agentRoot, { withFileTypes: true });
|
|
122458
122816
|
} catch {
|
|
122459
122817
|
continue;
|
|
122460
122818
|
}
|
|
@@ -122668,7 +123026,7 @@ function writeStationHydration(options) {
|
|
|
122668
123026
|
}
|
|
122669
123027
|
let written = 0;
|
|
122670
123028
|
for (const entry of toWrite) {
|
|
122671
|
-
|
|
123029
|
+
mkdirSync31(dirname48(entry.destination), { recursive: true });
|
|
122672
123030
|
copyFileSync3(entry.fullPath, entry.destination);
|
|
122673
123031
|
written += 1;
|
|
122674
123032
|
}
|
|
@@ -122690,7 +123048,7 @@ function writeStationHydration(options) {
|
|
|
122690
123048
|
skills: resultSkills
|
|
122691
123049
|
};
|
|
122692
123050
|
const hydrationManifestPath = join76(dirname48(cacheRoot), `hydration-${options.stationId}.json`);
|
|
122693
|
-
|
|
123051
|
+
mkdirSync31(dirname48(hydrationManifestPath), { recursive: true });
|
|
122694
123052
|
writeFileSync30(hydrationManifestPath, `${JSON.stringify(hydration, null, 2)}
|
|
122695
123053
|
`);
|
|
122696
123054
|
return {
|
|
@@ -122767,7 +123125,7 @@ var init_hydrate = __esm(() => {
|
|
|
122767
123125
|
|
|
122768
123126
|
// src/lib/prepare-skill.ts
|
|
122769
123127
|
import { createHash as createHash49, randomUUID as randomUUID13 } from "crypto";
|
|
122770
|
-
import { chmodSync as chmodSync5, existsSync as existsSync37, lstatSync as lstatSync48, mkdirSync as
|
|
123128
|
+
import { chmodSync as chmodSync5, existsSync as existsSync37, lstatSync as lstatSync48, mkdirSync as mkdirSync32, mkdtempSync as mkdtempSync7, readFileSync as readFileSync51, readdirSync as readdirSync29, renameSync as renameSync15, rmSync as rmSync10, writeFileSync as writeFileSync31 } from "fs";
|
|
122771
123129
|
import { tmpdir as tmpdir2 } from "os";
|
|
122772
123130
|
import { dirname as dirname49, isAbsolute as isAbsolute46, join as join77, relative as relative16, resolve as resolve46, sep as sep24 } from "path";
|
|
122773
123131
|
function prepareSkill(name, options) {
|
|
@@ -122809,13 +123167,13 @@ function prepareSkill(name, options) {
|
|
|
122809
123167
|
throw new Error("skill.json provenance must be an object.");
|
|
122810
123168
|
const provenance = manifest.provenance;
|
|
122811
123169
|
const candidate2 = { ...manifest, version: options.version, kind, provenance: { ...provenance } };
|
|
122812
|
-
const staging =
|
|
123170
|
+
const staging = mkdtempSync7(join77(tmpdir2(), "skills-prepare-"));
|
|
122813
123171
|
try {
|
|
122814
123172
|
for (const directory3 of before2.directories)
|
|
122815
|
-
|
|
123173
|
+
mkdirSync32(join77(staging, directory3), { recursive: true });
|
|
122816
123174
|
for (const file2 of before2.files) {
|
|
122817
123175
|
const destination = join77(staging, file2.path);
|
|
122818
|
-
|
|
123176
|
+
mkdirSync32(dirname49(destination), { recursive: true });
|
|
122819
123177
|
writeFileSync31(destination, file2.bytes, { mode: file2.mode });
|
|
122820
123178
|
}
|
|
122821
123179
|
const stagedManifest = join77(staging, "skill.json");
|
|
@@ -122847,12 +123205,12 @@ ${validation.issues.map((issue2) => `${issue2.code}: ${issue2.message}`).join(`
|
|
|
122847
123205
|
chmodSync5(temporary, manifestFile.mode);
|
|
122848
123206
|
renameSync15(temporary, join77(path, "skill.json"));
|
|
122849
123207
|
} finally {
|
|
122850
|
-
|
|
123208
|
+
rmSync10(temporary, { force: true });
|
|
122851
123209
|
}
|
|
122852
123210
|
}
|
|
122853
123211
|
return { name: normalized2, path, previousVersion, version: options.version, kind, contentHash, changed: changed3, written: changed3 && !options.dryRun, warnings: validation.warnings };
|
|
122854
123212
|
} finally {
|
|
122855
|
-
|
|
123213
|
+
rmSync10(staging, { recursive: true, force: true });
|
|
122856
123214
|
}
|
|
122857
123215
|
}
|
|
122858
123216
|
function assertPackedCanonicalCoverage(root2) {
|
|
@@ -122968,7 +123326,7 @@ function snapshot2(root2) {
|
|
|
122968
123326
|
const hash7 = createHash49("sha256").update(`${rootStat.dev}:${rootStat.ino}\x00`);
|
|
122969
123327
|
let count = 0, bytes = 0;
|
|
122970
123328
|
const walk2 = (relative17) => {
|
|
122971
|
-
for (const name of
|
|
123329
|
+
for (const name of readdirSync29(join77(root2, relative17)).sort()) {
|
|
122972
123330
|
if (IGNORED.has(name.toLowerCase()) || !relative17 && ROOT_IGNORED.has(name.toLowerCase()))
|
|
122973
123331
|
continue;
|
|
122974
123332
|
const path = relative17 ? `${relative17}/${name}` : name;
|
|
@@ -123389,7 +123747,7 @@ var init_schedule = __esm(() => {
|
|
|
123389
123747
|
});
|
|
123390
123748
|
|
|
123391
123749
|
// src/lib/registry-sync.ts
|
|
123392
|
-
import { mkdirSync as
|
|
123750
|
+
import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync32 } from "fs";
|
|
123393
123751
|
import { dirname as dirname50, relative as relative17 } from "path";
|
|
123394
123752
|
function createRegistrySyncArtifact(options = {}) {
|
|
123395
123753
|
const profile = options.profile ?? "all";
|
|
@@ -123447,7 +123805,7 @@ function createRegistrySyncArtifact(options = {}) {
|
|
|
123447
123805
|
};
|
|
123448
123806
|
}
|
|
123449
123807
|
function writeRegistrySyncArtifact(path, artifact) {
|
|
123450
|
-
|
|
123808
|
+
mkdirSync33(dirname50(path), { recursive: true });
|
|
123451
123809
|
writeFileSync32(path, `${JSON.stringify(artifact, null, 2)}
|
|
123452
123810
|
`);
|
|
123453
123811
|
}
|
|
@@ -134114,6 +134472,7 @@ init_registry();
|
|
|
134114
134472
|
init_discovery();
|
|
134115
134473
|
init_fleet_credentials();
|
|
134116
134474
|
init_read_access();
|
|
134475
|
+
init_stray_arguments();
|
|
134117
134476
|
var jsx_dev_runtime8 = __toESM(require_jsx_dev_runtime(), 1);
|
|
134118
134477
|
var isTTY2 = (process.stdout.isTTY ?? false) && (process.stdin.isTTY ?? false);
|
|
134119
134478
|
var program2 = new Command;
|
|
@@ -134123,7 +134482,7 @@ program2.hook("preAction", () => {
|
|
|
134123
134482
|
recordEnvironmentProfile(process.env.HASNA_PROFILE);
|
|
134124
134483
|
selectCliSkillsCredentialProfile(profile);
|
|
134125
134484
|
});
|
|
134126
|
-
program2.command("interactive", { isDefault: true }).alias("i").
|
|
134485
|
+
permitStrayArguments(program2.command("interactive", { isDefault: true }).alias("i").description("Interactive skill browser (TUI)").action(async (_options, command) => {
|
|
134127
134486
|
const stray = command.args[0];
|
|
134128
134487
|
if (stray !== undefined) {
|
|
134129
134488
|
const verbs = program2.commands.map((c) => c.name()).filter((n2) => n2 !== "interactive").sort();
|
|
@@ -134150,7 +134509,7 @@ program2.command("interactive", { isDefault: true }).alias("i").allowExcessArgum
|
|
|
134150
134509
|
render_default(/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(App2, {
|
|
134151
134510
|
initialAccess: access
|
|
134152
134511
|
}, undefined, false, undefined, this));
|
|
134153
|
-
});
|
|
134512
|
+
}));
|
|
134154
134513
|
var { registerInstall: registerInstall2 } = await Promise.resolve().then(() => (init_install(), exports_install));
|
|
134155
134514
|
registerInstall2(program2);
|
|
134156
134515
|
var { registerBrowse: registerBrowse2 } = await Promise.resolve().then(() => (init_list(), exports_list));
|
|
@@ -134212,6 +134571,7 @@ registerStorage2(program2);
|
|
|
134212
134571
|
var { registerRegistryReconcile: registerRegistryReconcile2 } = await Promise.resolve().then(() => (init_registry_reconcile2(), exports_registry_reconcile));
|
|
134213
134572
|
registerRegistryReconcile2(program2);
|
|
134214
134573
|
registerEventsCommands(program2, { source: "skills" });
|
|
134574
|
+
rejectStrayArguments(program2);
|
|
134215
134575
|
var cliArgs = process.argv.slice(2);
|
|
134216
134576
|
var colorFlag = optionPrefix(program2, cliArgs).indices.find((index) => cliArgs[index] === "--no-color");
|
|
134217
134577
|
if (colorFlag !== undefined) {
|