@hasna/skills 0.10.75 → 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/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.75",
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 { execFileSync } from "child_process";
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 acquireCodexCorpusWrite(roots, options) {
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 withCodexCorpusWrite(roots, run, options = {}) {
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("CODEX_CORPUS_ADMISSION_REQUIRED: verified native admission and its existing shared lock are required");
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 readdirSync5, readFileSync as readFileSync11, readlinkSync as readlinkSync3, realpathSync as realpathSync5 } from "fs";
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 && readdirSync5(directory).every((name) => {
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 = readdirSync5(parent);
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 readdirSync6, readFileSync as readFileSync12 } from "fs";
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 = readdirSync6(path);
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 = readdirSync6(join22(root, ".codex-plugin"));
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 readdirSync6(path)) {
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) => readdirSync6(path).some((name) => OTHER_PLUGIN_CONTROLS.includes(name.toLowerCase())), MAX_TRAILING_VENDOR_ROWS = 16, MAX_VENDOR_TABLES = 8, MAX_CONFIG_CANDIDATES = 128, HEADER;
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 spawnSync2 } from "child_process";
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 = spawnSync2(KEYCHAIN_SECURITY_BIN, [...argv], {
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 mkdirSync5, openSync as openSync10, readFileSync as readFileSync14, readdirSync as readdirSync7, rmdirSync as rmdirSync2, unlinkSync as unlinkSync3, ftruncateSync, writeSync as writeSync2 } from "fs";
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
- mkdirSync5(marker, { mode: 448 });
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 (readdirSync7(marker).some((name) => name !== "state.json"))
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
- mkdirSync5(active, { mode: 448 });
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 mkdirSync6, 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";
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
- mkdirSync6(directory2, { mode: 448 });
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
- mkdirSync6(directory2, { recursive: true, mode: 448 });
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 readdirSync8, realpathSync as realpathSync8 } from "fs";
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 = readdirSync8(path).sort();
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 = readdirSync8(parent.pluginParent).filter((name) => name !== ".codex-remote-plugin-install.json");
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 = readdirSync8(parent.pluginParent).filter((name) => name !== ".codex-remote-plugin-install.json").map((version) => {
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 = readdirSync8(cacheRoot);
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 readdirSync8(marketPath)) {
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 = readdirSync8(parent);
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 readdirSync9 } from "fs";
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(readdirSync9(path).sort()) !== JSON.stringify(Object.keys(CLI_BRIDGE_FILES).sort()))
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 spawnSync3 } from "child_process";
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 = spawnSync3(executable2, ["--json", "--home", resolve21(home), "--cwd", resolve21(cwd2)], {
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 probe = Bun.spawnSync(["/bin/sh", "-p", "-c", "exit 0"], { env: {}, stdin: "ignore", stdout: "ignore", stderr: "ignore" });
57300
- if (probe.exitCode !== 0)
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 mkdirSync7, openSync as openSync16, readSync as readSync12, writeSync as writeSync4 } from "fs";
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
- mkdirSync7(parent, { mode: 448 });
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 mkdirSync8, readFileSync as readFileSync19, readdirSync as readdirSync10, 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";
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 readdirSync10(path).sort())
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
- mkdirSync8(dirname22(path), { recursive: true, mode: 448 });
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 = readdirSync10(parent).filter((name) => name !== ".codex-remote-plugin-install.json");
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
- mkdirSync8(backupRoot, { recursive: true, mode: 448 });
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
- mkdirSync8(archiveRoot, { recursive: true, mode: 448 });
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 mkdirSync9, readdirSync as readdirSync11, renameSync as renameSync5, rmSync as rmSync2, statSync as statSync12, writeFileSync as writeFileSync7 } from "fs";
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 = readdirSync11(appDir);
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
- mkdirSync9(dir, { recursive: true });
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 = readdirSync11(cache3);
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 readdirSync11(dir))
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
- rmSync2(cache3, { recursive: true, force: true });
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
- mkdirSync9(cache3, { recursive: true });
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 mkdirSync10,
59717
- mkdtempSync,
59986
+ mkdirSync as mkdirSync11,
59987
+ mkdtempSync as mkdtempSync2,
59718
59988
  readFileSync as readFileSync20,
59719
- readdirSync as readdirSync12,
59989
+ readdirSync as readdirSync13,
59720
59990
  renameSync as renameSync6,
59721
- rmSync as rmSync3,
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 = readdirSync12(path);
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) => writeManagedSkillDirUnlocked(dir, skillMd, options, assertCurrent), options);
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
- mkdirSync10(parentDir, { recursive: true });
59968
- const transactionDir = mkdtempSync(join36(parentDir, `.hasna-skills-write-${basename13(dir)}-`));
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
- mkdirSync10(candidateDir, { recursive: true });
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
- rmSync3(dir, { recursive: true, force: true });
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
- rmSync3(transactionDir, { recursive: true, force: true });
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 mkdirSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
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
- mkdirSync11(dir, { recursive: true });
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 rmSync4 } from "fs";
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] : [], () => removeSkillForAgentUnlocked(name, options), options);
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
- rmSync4(dir, { recursive: true, force: true });
60756
+ rmSync5(dir, { recursive: true, force: true });
60478
60757
  return true;
60479
60758
  }
60480
60759
  function resolveAgentSkillMd(name, generateSkillMd) {
@@ -62322,7 +62601,7 @@ var init_codex_hook_discovery_recovery = __esm(() => {
62322
62601
 
62323
62602
  // src/lib/agent-discovery.ts
62324
62603
  import { createHash as createHash29 } from "crypto";
62325
- import { lstatSync as lstatSync32, readFileSync as readFileSync26, readdirSync as readdirSync13, realpathSync as realpathSync12 } from "fs";
62604
+ import { lstatSync as lstatSync32, readFileSync as readFileSync26, readdirSync as readdirSync14, realpathSync as realpathSync12 } from "fs";
62326
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";
62327
62606
  import { isDeepStrictEqual as isDeepStrictEqual13 } from "util";
62328
62607
  function discoveryRootUnresolved(agent, command, detail) {
@@ -63073,13 +63352,13 @@ function assertProjectDiscovery(agent, directories, home, canonical9 = resolve28
63073
63352
  for (const name of ["plugin", "plugins"]) {
63074
63353
  const path = canonical9(join42(directory2, ".sumi", name));
63075
63354
  safe6(path);
63076
- if (lstatSync32(path, { throwIfNoEntry: false })?.isDirectory() && readdirSync13(path).length)
63355
+ if (lstatSync32(path, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(path).length)
63077
63356
  throw new Error(`NATIVE_SKILL_DRIFT: project Sumi plugins require a dedicated discovery review: ${path}`);
63078
63357
  }
63079
63358
  if (agent === "claude") {
63080
63359
  const commands = canonical9(join42(directory2, ".claude/commands"));
63081
63360
  safe6(commands);
63082
- if (lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync13(commands).length)
63361
+ if (lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(commands).length)
63083
63362
  throw new Error("NATIVE_SKILL_DRIFT: legacy project command discovery requires a dedicated format adapter");
63084
63363
  }
63085
63364
  }
@@ -63228,7 +63507,7 @@ function resolveAgentDiscovery(options) {
63228
63507
  for (const path of plugins) {
63229
63508
  safe6(path);
63230
63509
  if (lstatSync32(path, { throwIfNoEntry: false })?.isDirectory())
63231
- for (const name of readdirSync13(path).sort()) {
63510
+ for (const name of readdirSync14(path).sort()) {
63232
63511
  if (name === "skills-cli.js" && path === plugins[1])
63233
63512
  continue;
63234
63513
  const target = join42(path, name);
@@ -63239,7 +63518,7 @@ function resolveAgentDiscovery(options) {
63239
63518
  }
63240
63519
  for (const root2 of roots) {
63241
63520
  safe6(root2);
63242
- if (lstatSync32(root2, { throwIfNoEntry: false })?.isDirectory() && readdirSync13(root2).some((name) => name.endsWith(".md")))
63521
+ if (lstatSync32(root2, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(root2).some((name) => name.endsWith(".md")))
63243
63522
  unresolved("flat markdown skills require a dedicated native migration adapter");
63244
63523
  }
63245
63524
  }
@@ -63283,7 +63562,7 @@ function resolveAgentDiscovery(options) {
63283
63562
  safe6(builtinRoot);
63284
63563
  if (!lstatSync32(builtinRoot, { throwIfNoEntry: false })?.isDirectory())
63285
63564
  unresolved("installed Gemini builtin root is missing");
63286
- for (const name of readdirSync13(builtinRoot).sort()) {
63565
+ for (const name of readdirSync14(builtinRoot).sort()) {
63287
63566
  const text3 = witness(join42(builtinRoot, name, "SKILL.md"));
63288
63567
  const match = text3?.match(/^---\r?\n[\s\S]*?^name:\s*([a-z0-9][a-z0-9-]*)\s*$/m);
63289
63568
  if (!match?.[1] || builtinNames.includes(match[1]))
@@ -63381,7 +63660,7 @@ function resolveAgentDiscovery(options) {
63381
63660
  unresolved("plugin hooks require a separate no-skill-injection review");
63382
63661
  const commands = join42(root2, "commands");
63383
63662
  safe6(commands);
63384
- if (agent === "claude" && (manifest.commands !== undefined || lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync13(commands).length))
63663
+ if (agent === "claude" && (manifest.commands !== undefined || lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(commands).length))
63385
63664
  unresolved("legacy command discovery requires retirement or a dedicated format adapter");
63386
63665
  const rootSkill = witness(join42(root2, "SKILL.md"));
63387
63666
  if (rootSkill !== null)
@@ -63403,7 +63682,7 @@ function resolveAgentDiscovery(options) {
63403
63682
  const installed = registrations === null ? {} : parseConfig(registrations, join42(home, ".claude/plugins/installed_plugins.json")).plugins;
63404
63683
  const commands = canonical9(join42(home, ".claude/commands"));
63405
63684
  safe6(commands);
63406
- if (lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync13(commands).length)
63685
+ if (lstatSync32(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync14(commands).length)
63407
63686
  unresolved("legacy home command discovery requires a dedicated format adapter");
63408
63687
  for (const [id, enabled] of Object.entries(config.enabledPlugins ?? {})) {
63409
63688
  if (enabled === false)
@@ -63445,7 +63724,7 @@ function resolveAgentDiscovery(options) {
63445
63724
  }
63446
63725
  const localPlugins = join42(home, ".config/opencode/plugins");
63447
63726
  safe6(localPlugins);
63448
- if (lstatSync32(localPlugins, { throwIfNoEntry: false }) && readdirSync13(localPlugins).some((name) => name !== "skills-cli.js"))
63727
+ if (lstatSync32(localPlugins, { throwIfNoEntry: false }) && readdirSync14(localPlugins).some((name) => name !== "skills-cli.js"))
63449
63728
  unresolved("additional local plugin hooks require review");
63450
63729
  } else if (agent === "sumi") {
63451
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))
@@ -63464,7 +63743,7 @@ function resolveAgentDiscovery(options) {
63464
63743
  const directory2 = join42(home, ".gemini/extensions");
63465
63744
  safe6(directory2);
63466
63745
  if (lstatSync32(directory2, { throwIfNoEntry: false }))
63467
- for (const name of readdirSync13(directory2)) {
63746
+ for (const name of readdirSync14(directory2)) {
63468
63747
  const root2 = join42(directory2, name);
63469
63748
  safe6(root2);
63470
63749
  if (!lstatSync32(root2)?.isDirectory())
@@ -63552,7 +63831,7 @@ function physicalPath(path) {
63552
63831
  }
63553
63832
  return resolve29(realpathSync13(cursor), ...suffix);
63554
63833
  }
63555
- function contains(root2, path) {
63834
+ function contains2(root2, path) {
63556
63835
  return path === root2 || path.startsWith(root2 + sep15);
63557
63836
  }
63558
63837
  function configuredRoots(home, explicitHome) {
@@ -63605,14 +63884,14 @@ function assertPortableAuthoringPath(path, options = {}) {
63605
63884
  const defaults2 = NATIVE_DISCOVERY_ROOTS.map((parts) => join43(home, ...parts));
63606
63885
  defaults2.push(join43(home, ".codex/plugins/cache"), join43(home, ".claude/plugins/cache"), join43(home, ".claude/plugins/synced"), join43(home, ".gemini/extensions"));
63607
63886
  for (const root2 of defaults2) {
63608
- if (candidates.some((candidate2) => contains(resolve29(root2), candidate2) || contains(physicalPath(root2), candidate2)))
63887
+ if (candidates.some((candidate2) => contains2(resolve29(root2), candidate2) || contains2(physicalPath(root2), candidate2)))
63609
63888
  native ??= root2;
63610
63889
  }
63611
63890
  if (native) {
63612
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.`);
63613
63892
  }
63614
63893
  for (const root2 of configuredRoots(home, options.homeDir !== undefined)) {
63615
- if (candidates.some((candidate2) => contains(resolve29(root2), candidate2) || contains(physicalPath(root2), candidate2))) {
63894
+ if (candidates.some((candidate2) => contains2(resolve29(root2), candidate2) || contains2(physicalPath(root2), candidate2))) {
63616
63895
  throw new Error(`Refusing portable Skills authoring below configured native discovery root: ${lexical}`);
63617
63896
  }
63618
63897
  }
@@ -63630,12 +63909,12 @@ var init_authoring_path = __esm(() => {
63630
63909
  // src/lib/portable-skills.ts
63631
63910
  import {
63632
63911
  existsSync as existsSync19,
63633
- mkdirSync as mkdirSync12,
63634
- mkdtempSync as mkdtempSync2,
63635
- readdirSync as readdirSync14,
63912
+ mkdirSync as mkdirSync13,
63913
+ mkdtempSync as mkdtempSync3,
63914
+ readdirSync as readdirSync15,
63636
63915
  realpathSync as realpathSync14,
63637
63916
  renameSync as renameSync7,
63638
- rmSync as rmSync5,
63917
+ rmSync as rmSync6,
63639
63918
  statSync as statSync14,
63640
63919
  writeFileSync as writeFileSync10
63641
63920
  } from "fs";
@@ -63680,7 +63959,7 @@ function listPortableSkills(options = {}) {
63680
63959
  if (!safeIsDirectory(root2))
63681
63960
  return [];
63682
63961
  const skills = [];
63683
- for (const entry of readdirSync14(root2).sort()) {
63962
+ for (const entry of readdirSync15(root2).sort()) {
63684
63963
  if (entry.startsWith("."))
63685
63964
  continue;
63686
63965
  const path = join44(root2, entry);
@@ -63723,7 +64002,7 @@ function scaffoldPortableSkill(name, options = {}) {
63723
64002
  if (existsSync19(skillPath)) {
63724
64003
  if (!options.overwrite)
63725
64004
  throw new Error(`Skill '${skillName}' already exists at ${skillPath}`);
63726
- rmSync5(skillPath, { recursive: true, force: true });
64005
+ rmSync6(skillPath, { recursive: true, force: true });
63727
64006
  }
63728
64007
  const kind = options.kind ?? "executable";
63729
64008
  const description = options.description ?? `${displayName(skillName)} skill`;
@@ -63750,7 +64029,7 @@ function portPortableSkillDirectory(sourceDir, options = {}) {
63750
64029
  };
63751
64030
  const imported = [];
63752
64031
  const skipped = [];
63753
- const entries = readdirSync14(absoluteSource, { withFileTypes: true }).map((entry) => entry.name).filter((entryName) => !entryName.startsWith(".")).sort();
64032
+ const entries = readdirSync15(absoluteSource, { withFileTypes: true }).map((entry) => entry.name).filter((entryName) => !entryName.startsWith(".")).sort();
63754
64033
  for (const entryName of entries) {
63755
64034
  const childPath = join44(absoluteSource, entryName);
63756
64035
  if (!safeIsDirectory(childPath))
@@ -63795,11 +64074,11 @@ function physicalImportPath(path) {
63795
64074
  function assertDisjointImportPaths(source, destination) {
63796
64075
  const sourcePath = realpathSync14(source);
63797
64076
  const destinationPath = physicalImportPath(destination);
63798
- const contains2 = (parent, child2) => {
64077
+ const contains3 = (parent, child2) => {
63799
64078
  const path = relative10(parent, child2);
63800
64079
  return path === "" || !isAbsolute31(path) && path !== ".." && !path.startsWith(`..${sep16}`);
63801
64080
  };
63802
- if (contains2(sourcePath, destinationPath) || contains2(destinationPath, sourcePath)) {
64081
+ if (contains3(sourcePath, destinationPath) || contains3(destinationPath, sourcePath)) {
63803
64082
  throw new Error("Source and destination skill directories must not overlap");
63804
64083
  }
63805
64084
  }
@@ -63826,9 +64105,9 @@ function portPortableSkill(sourcePath, options = {}) {
63826
64105
  if (existsSync19(destination)) {
63827
64106
  if (!options.overwrite)
63828
64107
  throw new Error(`Skill '${skillName}' already exists at ${destination}`);
63829
- rmSync5(destination, { recursive: true, force: true });
64108
+ rmSync6(destination, { recursive: true, force: true });
63830
64109
  }
63831
- mkdirSync12(dirname28(destination), { recursive: true });
64110
+ mkdirSync13(dirname28(destination), { recursive: true });
63832
64111
  copySkillDirectory(absoluteSource, destination);
63833
64112
  const base2 = {
63834
64113
  ...inferred,
@@ -63870,8 +64149,8 @@ function installCorpusSkillAtomically(input, options = {}) {
63870
64149
  const target = join44(root2, name);
63871
64150
  assertPortableAuthoringPath(target, options);
63872
64151
  const created = !existsSync19(target);
63873
- mkdirSync12(root2, { recursive: true });
63874
- const staging = mkdtempSync2(join44(root2, `.pull-${name}-`));
64152
+ mkdirSync13(root2, { recursive: true });
64153
+ const staging = mkdtempSync3(join44(root2, `.pull-${name}-`));
63875
64154
  let moved = false;
63876
64155
  let backup = null;
63877
64156
  try {
@@ -63879,16 +64158,16 @@ function installCorpusSkillAtomically(input, options = {}) {
63879
64158
  const manifest = buildCorpusManifest(input, name);
63880
64159
  writeSkillJsonWithHash(staging, manifest);
63881
64160
  if (existsSync19(target)) {
63882
- backup = mkdtempSync2(join44(root2, `.pull-backup-${name}-`));
64161
+ backup = mkdtempSync3(join44(root2, `.pull-backup-${name}-`));
63883
64162
  renameSync7(target, join44(backup, name));
63884
64163
  moved = true;
63885
64164
  }
63886
64165
  renameSync7(staging, target);
63887
64166
  if (moved && backup)
63888
- rmSync5(backup, { recursive: true, force: true });
64167
+ rmSync6(backup, { recursive: true, force: true });
63889
64168
  return { name, path: target, manifest, created };
63890
64169
  } catch (error) {
63891
- rmSync5(staging, { recursive: true, force: true });
64170
+ rmSync6(staging, { recursive: true, force: true });
63892
64171
  if (moved && backup && existsSync19(join44(backup, name))) {
63893
64172
  try {
63894
64173
  renameSync7(join44(backup, name), target);
@@ -64133,7 +64412,7 @@ __export(exports_registry, {
64133
64412
  CATEGORIES: () => CATEGORIES,
64134
64413
  BASIC_SKILL_NAMES: () => BASIC_SKILL_NAMES
64135
64414
  });
64136
- import { existsSync as existsSync20, readFileSync as readFileSync27, readdirSync as readdirSync15 } from "fs";
64415
+ import { existsSync as existsSync20, readFileSync as readFileSync27, readdirSync as readdirSync16 } from "fs";
64137
64416
  import { join as join45 } from "path";
64138
64417
  function isBasicSkillName(name) {
64139
64418
  return BASIC_SKILL_NAMES.includes(name);
@@ -64174,7 +64453,7 @@ function discoverSkillsInDir(dir, source = "custom") {
64174
64453
  return [];
64175
64454
  const result2 = [];
64176
64455
  try {
64177
- const entries = readdirSync15(dir, { withFileTypes: true });
64456
+ const entries = readdirSync16(dir, { withFileTypes: true });
64178
64457
  for (const entry of entries) {
64179
64458
  if (!entry.isDirectory())
64180
64459
  continue;
@@ -64210,7 +64489,7 @@ function findExtensionSkillPath(name) {
64210
64489
  if (!config.extensionsDir || !existsSync20(config.extensionsDir))
64211
64490
  return null;
64212
64491
  try {
64213
- const entries = readdirSync15(config.extensionsDir, { withFileTypes: true });
64492
+ const entries = readdirSync16(config.extensionsDir, { withFileTypes: true });
64214
64493
  for (const entry of entries) {
64215
64494
  if (!entry.isDirectory())
64216
64495
  continue;
@@ -65932,7 +66211,7 @@ var require_cli_spinners = __commonJS((exports, module) => {
65932
66211
  });
65933
66212
 
65934
66213
  // src/lib/auth-store.ts
65935
- import { chmodSync as chmodSync2, existsSync as existsSync21, mkdirSync as mkdirSync13, readFileSync as readFileSync28, renameSync as renameSync8, statSync as statSync15, unlinkSync as unlinkSync6, writeFileSync as writeFileSync11 } from "fs";
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";
65936
66215
  import { basename as basename19, dirname as dirname29, join as join46 } from "path";
65937
66216
  function getAuthFilePath(env3 = process.env) {
65938
66217
  return skillsCredentialFilePath(env3);
@@ -65973,7 +66252,7 @@ function getAuthConfig(env3 = process.env, options = {}) {
65973
66252
  }
65974
66253
  function writeCredentialValues(values2, env3 = process.env) {
65975
66254
  const file = skillsCredentialFilePath(env3);
65976
- mkdirSync13(dirname29(file), { recursive: true, mode: 448 });
66255
+ mkdirSync14(dirname29(file), { recursive: true, mode: 448 });
65977
66256
  const lines = [];
65978
66257
  const written = new Set;
65979
66258
  if (existsSync21(file)) {
@@ -87962,7 +88241,7 @@ var init_remote_auth = __esm(() => {
87962
88241
 
87963
88242
  // src/lib/sign-in.ts
87964
88243
  import { createHash as createHash32 } from "crypto";
87965
- import { chmodSync as chmodSync3, mkdirSync as mkdirSync14, readFileSync as readFileSync29, readdirSync as readdirSync16, renameSync as renameSync9, unlinkSync as unlinkSync7, writeFileSync as writeFileSync12 } from "fs";
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";
87966
88245
  import { basename as basename20, dirname as dirname30, join as join47 } from "path";
87967
88246
  function isRecord7(value) {
87968
88247
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
@@ -88116,7 +88395,7 @@ function pendingDeviceSignInPath(origin, env3 = process.env) {
88116
88395
  }
88117
88396
  function savePendingDeviceSignIn(origin, start, env3 = process.env, now3 = Date.now()) {
88118
88397
  const path = pendingDeviceSignInPath(origin, env3);
88119
- mkdirSync14(dirname30(path), { recursive: true, mode: 448 });
88398
+ mkdirSync15(dirname30(path), { recursive: true, mode: 448 });
88120
88399
  const pending = {
88121
88400
  origin,
88122
88401
  deviceCode: start.deviceCode,
@@ -88174,7 +88453,7 @@ function pendingDeviceSignInOrigins(env3 = process.env, now3 = Date.now()) {
88174
88453
  }
88175
88454
  let entries;
88176
88455
  try {
88177
- entries = readdirSync16(location.dir);
88456
+ entries = readdirSync17(location.dir);
88178
88457
  } catch {
88179
88458
  return [];
88180
88459
  }
@@ -88205,7 +88484,7 @@ function clearPendingDeviceSignIn(env3 = process.env, origin) {
88205
88484
  }
88206
88485
  let entries;
88207
88486
  try {
88208
- entries = readdirSync16(location.dir);
88487
+ entries = readdirSync17(location.dir);
88209
88488
  } catch {
88210
88489
  return;
88211
88490
  }
@@ -88884,7 +89163,7 @@ var init_skill_bundles = __esm(() => {
88884
89163
  });
88885
89164
 
88886
89165
  // src/lib/pull.ts
88887
- import { existsSync as existsSync22, mkdirSync as mkdirSync15, mkdtempSync as mkdtempSync3, readFileSync as readFileSync30, renameSync as renameSync10, rmSync as rmSync6, writeFileSync as writeFileSync13 } from "fs";
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";
88888
89167
  import { dirname as dirname31, join as join48 } from "path";
88889
89168
  async function pullSkills(options = {}) {
88890
89169
  const client2 = options.client !== undefined ? options.client : await createRemoteSkillsClient();
@@ -89041,7 +89320,7 @@ function reconcileTombstone(slug2, corpusOptions) {
89041
89320
  if (!hasSkillsOwnershipMarker(target)) {
89042
89321
  return { name: slug2, success: true, tombstoned: true, removed: false, leftInPlace: true };
89043
89322
  }
89044
- rmSync6(target, { recursive: true, force: true });
89323
+ rmSync7(target, { recursive: true, force: true });
89045
89324
  return { name: slug2, success: true, tombstoned: true, removed: true };
89046
89325
  }
89047
89326
  function readPullMarker(dir) {
@@ -89180,16 +89459,16 @@ function verifyBundleResponseBytes(buffer, response, verify = {}) {
89180
89459
  }
89181
89460
  function installBundleAtomically(name, entries, options = {}, marker = {}) {
89182
89461
  const root2 = getPortableSkillsRoot(options);
89183
- mkdirSync15(root2, { recursive: true });
89462
+ mkdirSync16(root2, { recursive: true });
89184
89463
  const target = join48(root2, name);
89185
89464
  const created = !existsSync22(target);
89186
- const staging = mkdtempSync3(join48(root2, `.pull-${name}-`));
89465
+ const staging = mkdtempSync4(join48(root2, `.pull-${name}-`));
89187
89466
  let moved = false;
89188
89467
  let backup = null;
89189
89468
  try {
89190
89469
  for (const entry of entries) {
89191
89470
  const destination = join48(staging, entry.path);
89192
- mkdirSync15(dirname31(destination), { recursive: true });
89471
+ mkdirSync16(dirname31(destination), { recursive: true });
89193
89472
  writeFileSync13(destination, entry.bytes, { mode: entry.mode });
89194
89473
  }
89195
89474
  writePullMarker(staging, {
@@ -89201,15 +89480,15 @@ function installBundleAtomically(name, entries, options = {}, marker = {}) {
89201
89480
  ...marker.revisionId ? { revisionId: marker.revisionId } : {}
89202
89481
  });
89203
89482
  if (existsSync22(target)) {
89204
- backup = mkdtempSync3(join48(root2, `.pull-backup-${name}-`));
89483
+ backup = mkdtempSync4(join48(root2, `.pull-backup-${name}-`));
89205
89484
  renameSync10(target, join48(backup, name));
89206
89485
  moved = true;
89207
89486
  }
89208
89487
  renameSync10(staging, target);
89209
89488
  if (moved && backup)
89210
- rmSync6(backup, { recursive: true, force: true });
89489
+ rmSync7(backup, { recursive: true, force: true });
89211
89490
  } catch (error61) {
89212
- rmSync6(staging, { recursive: true, force: true });
89491
+ rmSync7(staging, { recursive: true, force: true });
89213
89492
  if (moved && backup && existsSync22(join48(backup, name))) {
89214
89493
  try {
89215
89494
  renameSync10(join48(backup, name), target);
@@ -91889,7 +92168,7 @@ var init_init = __esm(() => {
91889
92168
  });
91890
92169
 
91891
92170
  // src/lib/home-adoption.ts
91892
- import { constants as constants22, closeSync as closeSync20, fstatSync as fstatSync20, lstatSync as lstatSync34, openSync as openSync20, readSync as readSync17, existsSync as existsSync25, mkdirSync as mkdirSync16, readdirSync as readdirSync17, readFileSync as readFileSync33, rmSync as rmSync7, statSync as statSync16, writeFileSync as writeFileSync15 } from "fs";
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";
91893
92172
  import { homedir as homedir8 } from "os";
91894
92173
  import { join as join52 } from "path";
91895
92174
  function indexCanonicalCorpus(corpusRoot) {
@@ -91898,7 +92177,7 @@ function indexCanonicalCorpus(corpusRoot) {
91898
92177
  return byName;
91899
92178
  let entries = [];
91900
92179
  try {
91901
- entries = readdirSync17(corpusRoot);
92180
+ entries = readdirSync18(corpusRoot);
91902
92181
  } catch {
91903
92182
  return byName;
91904
92183
  }
@@ -91948,7 +92227,7 @@ function scanUnmarkedHomes(options = {}) {
91948
92227
  continue;
91949
92228
  let entries = [];
91950
92229
  try {
91951
- entries = readdirSync17(home);
92230
+ entries = readdirSync18(home);
91952
92231
  } catch {
91953
92232
  continue;
91954
92233
  }
@@ -92008,11 +92287,11 @@ function appendConflictsLedger(appDir, conflicts) {
92008
92287
  writeFileSync15(ledgerPath, `${JSON.stringify(ledger, null, 2)}
92009
92288
  `);
92010
92289
  }
92011
- function writeRollbackRecord(mode, entries, appDir = getDataDir()) {
92290
+ function writeRollbackRecord(mode, entries, appDir = getDataDir(), admission = {}) {
92012
92291
  const dir = join52(appDir, ROLLBACK_DIRNAME);
92013
- mkdirSync16(dir, { recursive: true });
92292
+ mkdirSync17(dir, { recursive: true });
92014
92293
  const file2 = join52(dir, `${mode}-${Date.now()}.json`);
92015
- const record12 = { version: 1, mode, timestamp: new Date().toISOString(), entries };
92294
+ const record12 = { version: 1, mode, timestamp: new Date().toISOString(), entries, ...admission };
92016
92295
  writeFileSync15(file2, `${JSON.stringify(record12, null, 2)}
92017
92296
  `);
92018
92297
  return file2;
@@ -92024,8 +92303,9 @@ function adoptUnmarkedHomes(options = {}) {
92024
92303
  }
92025
92304
  const appDir = options.homeDir ? join52(options.homeDir, ".hasna", "skills") : getDataDir();
92026
92305
  const roots = scan.adoptable.map((entry) => codexCorpusRootForPath(entry.path)).filter((root2) => !!root2);
92027
- return withCodexCorpusWrite(roots, (assertCurrent) => {
92306
+ return withCodexCorpusWrite(roots, (assertCurrent, admission) => {
92028
92307
  assertCurrent();
92308
+ const fallback = codexAdmissionReceipt(admission);
92029
92309
  const canonical9 = indexCanonicalCorpus(resolveCorpusRoot(options));
92030
92310
  const markers = scan.adoptable.map((entry) => {
92031
92311
  const root2 = codexCorpusRootForPath(entry.path);
@@ -92042,7 +92322,7 @@ function adoptUnmarkedHomes(options = {}) {
92042
92322
  assertCurrent();
92043
92323
  let rollbackFile;
92044
92324
  if (markers.length > 0) {
92045
- rollbackFile = writeRollbackRecord("adopt", markers, appDir);
92325
+ rollbackFile = writeRollbackRecord("adopt", markers, appDir, fallback);
92046
92326
  }
92047
92327
  for (const entry of markers) {
92048
92328
  assertCurrent();
@@ -92055,7 +92335,7 @@ function adoptUnmarkedHomes(options = {}) {
92055
92335
  }
92056
92336
  assertCurrent();
92057
92337
  appendConflictsLedger(appDir, scan.conflicts);
92058
- return { ...scan, applied: true, rollbackFile };
92338
+ return { ...scan, applied: true, rollbackFile, ...fallback };
92059
92339
  }, options);
92060
92340
  }
92061
92341
  function pruneOwnership(dir) {
@@ -92107,7 +92387,7 @@ function pruneStrayHomes(options = {}) {
92107
92387
  continue;
92108
92388
  let entries = [];
92109
92389
  try {
92110
- entries = readdirSync17(home);
92390
+ entries = readdirSync18(home);
92111
92391
  } catch {
92112
92392
  continue;
92113
92393
  }
@@ -92140,9 +92420,10 @@ function pruneStrayHomes(options = {}) {
92140
92420
  }
92141
92421
  const appDir = options.homeDir ? join52(options.homeDir, ".hasna", "skills") : getDataDir();
92142
92422
  const roots = candidates.map((candidate2) => codexCorpusRootForPath(candidate2.path)).filter((root2) => !!root2);
92143
- return withCodexCorpusWrite(roots, (assertCurrent) => {
92423
+ return withCodexCorpusWrite(roots, (assertCurrent, admission) => {
92144
92424
  assertCurrent();
92145
- const rollbackFile = writeRollbackRecord("prune", candidates.map(({ agent, skill, path, hash: hash6, marker }) => ({ agent, skill, path, hash: hash6, marker })), appDir);
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);
92146
92427
  let pruned = 0;
92147
92428
  for (const candidate2 of candidates) {
92148
92429
  assertCurrent();
@@ -92156,13 +92437,13 @@ function pruneStrayHomes(options = {}) {
92156
92437
  const skillMd = join52(candidate2.path, "SKILL.md");
92157
92438
  if ((existsSync25(skillMd) ? hashSkillMarkdownFile(skillMd) : "") !== candidate2.hash)
92158
92439
  continue;
92159
- rmSync7(candidate2.path, { recursive: true, force: true });
92440
+ rmSync8(candidate2.path, { recursive: true, force: true });
92160
92441
  assertCurrent();
92161
92442
  if (existsSync25(candidate2.path))
92162
92443
  throw new Error("Skill prune readback failed");
92163
92444
  pruned++;
92164
92445
  }
92165
- return { candidates, pruned, dryRun: false, rollbackFile };
92446
+ return { candidates, pruned, dryRun: false, rollbackFile, ...fallback };
92166
92447
  }, options);
92167
92448
  }
92168
92449
  var CONFLICTS_LEDGER_FILE = "conflicts.json", ROLLBACK_DIRNAME = "rollback";
@@ -92176,7 +92457,7 @@ var init_home_adoption = __esm(() => {
92176
92457
  });
92177
92458
 
92178
92459
  // src/lib/home-census.ts
92179
- import { existsSync as existsSync26, readFileSync as readFileSync34, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
92460
+ import { existsSync as existsSync26, readFileSync as readFileSync34, readdirSync as readdirSync19, statSync as statSync17 } from "fs";
92180
92461
  import { homedir as homedir9 } from "os";
92181
92462
  import { join as join53 } from "path";
92182
92463
  function sortEntries(entries) {
@@ -92210,7 +92491,7 @@ function censusHomeDrift(options = {}) {
92210
92491
  const present2 = new Set;
92211
92492
  let dirEntries = [];
92212
92493
  try {
92213
- dirEntries = readdirSync18(home);
92494
+ dirEntries = readdirSync19(home);
92214
92495
  } catch {
92215
92496
  continue;
92216
92497
  }
@@ -92474,7 +92755,7 @@ var exports_diagnostic = {};
92474
92755
  __export(exports_diagnostic, {
92475
92756
  registerDiagnostic: () => registerDiagnostic
92476
92757
  });
92477
- import { existsSync as existsSync27, readFileSync as readFileSync36, readdirSync as readdirSync19, statSync as statSync18 } from "fs";
92758
+ import { existsSync as existsSync27, readFileSync as readFileSync36, readdirSync as readdirSync20, statSync as statSync18 } from "fs";
92478
92759
  import { join as join54 } from "path";
92479
92760
  import { execSync as execSync2 } from "child_process";
92480
92761
  function registerDiagnostic(parent) {
@@ -92667,7 +92948,7 @@ function handleWhoami(options) {
92667
92948
  let skillCount = 0;
92668
92949
  if (exists)
92669
92950
  try {
92670
- skillCount = readdirSync19(agentSkillsPath).filter((f) => !f.startsWith(".") && statSync18(join54(agentSkillsPath, f)).isDirectory()).length;
92951
+ skillCount = readdirSync20(agentSkillsPath).filter((f) => !f.startsWith(".") && statSync18(join54(agentSkillsPath, f)).isDirectory()).length;
92671
92952
  } catch {}
92672
92953
  agentConfigs.push({ agent, label: AGENT_LABELS[agent], path: agentSkillsPath, exists, skillCount });
92673
92954
  }
@@ -92925,7 +93206,7 @@ var init_cloud_executions = __esm(() => {
92925
93206
 
92926
93207
  // node_modules/@hasna/secrets/dist/sdk.js
92927
93208
  import { isIP as isIP3 } from "net";
92928
- import { spawnSync as spawnSync4 } from "child_process";
93209
+ import { spawnSync as spawnSync5 } from "child_process";
92929
93210
  import { closeSync as closeSync23, fstatSync as fstatSync23, openSync as openSync23, readFileSync as readFileSync37 } from "fs";
92930
93211
  import { O_NOFOLLOW as O_NOFOLLOW3, O_NONBLOCK as O_NONBLOCK3, O_RDONLY as O_RDONLY3 } from "constants";
92931
93212
  import { createRequire as createRequire2 } from "module";
@@ -93200,7 +93481,7 @@ function isAmbientEnvironment2(env3) {
93200
93481
  return env3 === process.env || env3[AMBIENT_ENVIRONMENT2] === true;
93201
93482
  }
93202
93483
  function defaultKeychainRunner2(argv) {
93203
- const result2 = spawnSync4(KEYCHAIN_SECURITY_BIN2, [...argv], {
93484
+ const result2 = spawnSync5(KEYCHAIN_SECURITY_BIN2, [...argv], {
93204
93485
  encoding: "utf8",
93205
93486
  stdio: ["ignore", "pipe", "pipe"],
93206
93487
  timeout: KEYCHAIN_SPAWN_TIMEOUT_MS2
@@ -94581,7 +94862,7 @@ __export(exports_selected_run, {
94581
94862
  });
94582
94863
  import { createHash as createHash36 } from "crypto";
94583
94864
  import { spawn as spawn3 } from "child_process";
94584
- import { mkdirSync as mkdirSync17, mkdtempSync as mkdtempSync4, writeFileSync as writeFileSync16, realpathSync as realpathSync16 } from "fs";
94865
+ import { mkdirSync as mkdirSync18, mkdtempSync as mkdtempSync5, writeFileSync as writeFileSync16, realpathSync as realpathSync16 } from "fs";
94585
94866
  import { dirname as dirname33, join as join56, resolve as resolve33 } from "path";
94586
94867
  import { tmpdir, hostname as stationHostname2 } from "os";
94587
94868
  async function resolveSelectedRun(spec, profileId, options = {}) {
@@ -94705,7 +94986,7 @@ async function executeSelectedLocal(selected, options = {}) {
94705
94986
  throw new SkillSelectionError("INVALID_SECRET_BINDINGS", "Explicit environment values must be bounded strings without NUL bytes.");
94706
94987
  secretEnv[name] = value;
94707
94988
  }
94708
- const runDirectory = mkdtempSync4(join56(tmpdir(), "skills-execution-"));
94989
+ const runDirectory = mkdtempSync5(join56(tmpdir(), "skills-execution-"));
94709
94990
  const paths = new SkillEntryPaths;
94710
94991
  for (const entry of entries) {
94711
94992
  paths.add(entry.path, 100, () => {
@@ -94714,7 +94995,7 @@ async function executeSelectedLocal(selected, options = {}) {
94714
94995
  throw new SkillSelectionError("INVALID_BUNDLE_PATH", "The execution bundle path exceeds its limit.");
94715
94996
  });
94716
94997
  const destination = join56(runDirectory, entry.path);
94717
- mkdirSync17(dirname33(destination), { recursive: true, mode: 448 });
94998
+ mkdirSync18(dirname33(destination), { recursive: true, mode: 448 });
94718
94999
  writeFileSync16(destination, entry.bytes, { flag: "wx", mode: entry.mode & 511 });
94719
95000
  }
94720
95001
  env3.SKILLS_INPUT_JSON = input2;
@@ -98967,7 +99248,7 @@ var init_runs = __esm(() => {
98967
99248
 
98968
99249
  // src/lib/run-state.ts
98969
99250
  import { createHash as createHash37, randomBytes } from "crypto";
98970
- import { existsSync as existsSync28, mkdirSync as mkdirSync18, readFileSync as readFileSync38, readdirSync as readdirSync20, statSync as statSync19, writeFileSync as writeFileSync17 } from "fs";
99251
+ import { existsSync as existsSync28, mkdirSync as mkdirSync19, readFileSync as readFileSync38, readdirSync as readdirSync21, statSync as statSync19, writeFileSync as writeFileSync17 } from "fs";
98971
99252
  import { extname, join as join57, relative as relative11 } from "path";
98972
99253
  function createSkillRun(params, targetDir = process.cwd()) {
98973
99254
  const now3 = new Date;
@@ -98978,9 +99259,9 @@ function createSkillRun(params, targetDir = process.cwd()) {
98978
99259
  const runDir = join57(root2, "runs", day, id2);
98979
99260
  const logsDir = join57(runDir, "logs");
98980
99261
  const exportDir = join57(root2, "exports", skillName, id2);
98981
- mkdirSync18(logsDir, { recursive: true });
98982
- mkdirSync18(exportDir, { recursive: true });
98983
- mkdirSync18(join57(root2, "tmp"), { recursive: true });
99262
+ mkdirSync19(logsDir, { recursive: true });
99263
+ mkdirSync19(exportDir, { recursive: true });
99264
+ mkdirSync19(join57(root2, "tmp"), { recursive: true });
98984
99265
  const record13 = {
98985
99266
  id: id2,
98986
99267
  skill: skillName,
@@ -99047,11 +99328,11 @@ function listSkillRuns(targetDir = process.cwd(), limit = 50) {
99047
99328
  if (!existsSync28(runsRoot))
99048
99329
  return [];
99049
99330
  const records = [];
99050
- for (const day of readdirSync20(runsRoot).sort().reverse()) {
99331
+ for (const day of readdirSync21(runsRoot).sort().reverse()) {
99051
99332
  const dayDir = join57(runsRoot, day);
99052
99333
  if (!statSync19(dayDir).isDirectory())
99053
99334
  continue;
99054
- for (const runId2 of readdirSync20(dayDir).sort().reverse()) {
99335
+ for (const runId2 of readdirSync21(dayDir).sort().reverse()) {
99055
99336
  const record13 = readRunRecord(join57(dayDir, runId2));
99056
99337
  if (record13)
99057
99338
  records.push(record13);
@@ -99065,7 +99346,7 @@ function findSkillRun(runId2, targetDir = process.cwd()) {
99065
99346
  const runsRoot = join57(getProjectStateDir(targetDir), "runs");
99066
99347
  if (!existsSync28(runsRoot))
99067
99348
  return null;
99068
- for (const day of readdirSync20(runsRoot)) {
99349
+ for (const day of readdirSync21(runsRoot)) {
99069
99350
  const record13 = readRunRecord(join57(runsRoot, day, runId2));
99070
99351
  if (record13)
99071
99352
  return record13;
@@ -99121,7 +99402,7 @@ function readRunRecord(runDir) {
99121
99402
  }
99122
99403
  function walkFiles(dir) {
99123
99404
  const files = [];
99124
- for (const entry of readdirSync20(dir)) {
99405
+ for (const entry of readdirSync21(dir)) {
99125
99406
  const full = join57(dir, entry);
99126
99407
  if (statSync19(full).isDirectory())
99127
99408
  files.push(...walkFiles(full));
@@ -111139,7 +111420,7 @@ var init_remote_customer_operations = __esm(() => {
111139
111420
  });
111140
111421
 
111141
111422
  // src/lib/workspace-profile.ts
111142
- import { constants as constants25, closeSync as closeSync26, fstatSync as fstatSync26, lstatSync as lstatSync36, mkdirSync as mkdirSync19, mkdtempSync as mkdtempSync5, openSync as openSync26, readFileSync as readFileSync39, renameSync as renameSync11, rmSync as rmSync8, writeFileSync as writeFileSync18 } from "fs";
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";
111143
111424
  import { dirname as dirname34, join as join58 } from "path";
111144
111425
  function stat2(path) {
111145
111426
  try {
@@ -111290,8 +111571,8 @@ async function prepareWorkspaceEnrollment(membershipId, source = process.env) {
111290
111571
  return fail4("The new profile exceeds the credential reader size limit.");
111291
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) + `
111292
111573
  `;
111293
- mkdirSync19(dirname34(file2), { recursive: true, mode: 448 });
111294
- const temp = mkdtempSync5(join58(dirname34(file2), ".workspace-login-"));
111574
+ mkdirSync20(dirname34(file2), { recursive: true, mode: 448 });
111575
+ const temp = mkdtempSync6(join58(dirname34(file2), ".workspace-login-"));
111295
111576
  let identityInstalled = false;
111296
111577
  try {
111297
111578
  writeFileSync18(join58(temp, "credentials"), body, { mode: 384, flag: "wx" });
@@ -111310,7 +111591,7 @@ async function prepareWorkspaceEnrollment(membershipId, source = process.env) {
111310
111591
  } catch (error61) {
111311
111592
  if (identityInstalled) {
111312
111593
  if (oldIdentity === null)
111313
- rmSync8(identityFile, { force: true });
111594
+ rmSync9(identityFile, { force: true });
111314
111595
  else {
111315
111596
  writeFileSync18(join58(temp, "restore"), oldIdentity, { mode: 384, flag: "wx" });
111316
111597
  renameSync11(join58(temp, "restore"), identityFile);
@@ -111318,7 +111599,7 @@ async function prepareWorkspaceEnrollment(membershipId, source = process.env) {
111318
111599
  }
111319
111600
  throw error61;
111320
111601
  } finally {
111321
- rmSync8(temp, { recursive: true, force: true });
111602
+ rmSync9(temp, { recursive: true, force: true });
111322
111603
  }
111323
111604
  return {
111324
111605
  status: "authenticated",
@@ -111507,7 +111788,7 @@ var init_recurring_customer = __esm(() => {
111507
111788
  });
111508
111789
 
111509
111790
  // src/lib/recurring-recovery.ts
111510
- import { constants as constants26, closeSync as closeSync27, fsyncSync as fsyncSync8, fstatSync as fstatSync27, lstatSync as lstatSync37, mkdirSync as mkdirSync20, openSync as openSync27, readSync as readSync19, realpathSync as realpathSync17, renameSync as renameSync12, unlinkSync as unlinkSync8, writeFileSync as writeFileSync19 } from "fs";
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";
111511
111792
  import { dirname as dirname35, isAbsolute as isAbsolute33, join as join59, resolve as resolve34 } from "path";
111512
111793
  import { randomUUID as randomUUID8 } from "crypto";
111513
111794
 
@@ -111653,7 +111934,7 @@ function base2(customer, organizationId) {
111653
111934
  function create3(directory2, intent) {
111654
111935
  if (!isAbsolute33(directory2) || resolve34(directory2) !== directory2 || realpathSync17(dirname35(directory2)) !== dirname35(directory2))
111655
111936
  invalid6();
111656
- mkdirSync20(directory2, { mode: 448 });
111937
+ mkdirSync21(directory2, { mode: 448 });
111657
111938
  const owner2 = new RecoveryOwner(directory2), checked = intentSchema.parse(intent), intentSha256 = canonicalJsonSha256(checked);
111658
111939
  owner2.write(`intent-${intentSha256}.json`, checked);
111659
111940
  owner2.write("state.json", { contractVersion: 1, intentSha256, phase: "prepared", consentId: null });
@@ -113291,7 +113572,7 @@ var init_run_routing = __esm(() => {
113291
113572
  });
113292
113573
 
113293
113574
  // src/mcp/operation-tools.ts
113294
- import { existsSync as existsSync29, readdirSync as readdirSync21, statSync as statSync20 } from "fs";
113575
+ import { existsSync as existsSync29, readdirSync as readdirSync22, statSync as statSync20 } from "fs";
113295
113576
  import { join as join60 } from "path";
113296
113577
  function registerOperationTools(server) {
113297
113578
  server.registerTool("cloud_skill_eligibility", {
@@ -113773,7 +114054,7 @@ function registerOperationTools(server) {
113773
114054
  let skillCount = 0;
113774
114055
  if (exists) {
113775
114056
  try {
113776
- skillCount = readdirSync21(agentSkillsPath).filter((f) => {
114057
+ skillCount = readdirSync22(agentSkillsPath).filter((f) => {
113777
114058
  const full = join60(agentSkillsPath, f);
113778
114059
  return !f.startsWith(".") && statSync20(full).isDirectory();
113779
114060
  }).length;
@@ -113841,7 +114122,7 @@ var init_operation_tools = __esm(() => {
113841
114122
  });
113842
114123
 
113843
114124
  // src/lib/feedback.ts
113844
- import { appendFileSync as appendFileSync2, existsSync as existsSync30, mkdirSync as mkdirSync21 } from "fs";
114125
+ import { appendFileSync as appendFileSync2, existsSync as existsSync30, mkdirSync as mkdirSync22 } from "fs";
113845
114126
  import { dirname as dirname36, join as join61 } from "path";
113846
114127
  import { Database } from "bun:sqlite";
113847
114128
  function getFeedbackDbPath() {
@@ -113851,7 +114132,7 @@ function getFeedbackDb() {
113851
114132
  const dbPath = getFeedbackDbPath();
113852
114133
  const dir = dirname36(dbPath);
113853
114134
  if (!existsSync30(dir))
113854
- mkdirSync21(dir, { recursive: true });
114135
+ mkdirSync22(dir, { recursive: true });
113855
114136
  const db = new Database(dbPath);
113856
114137
  db.exec("PRAGMA journal_mode = WAL");
113857
114138
  db.exec([
@@ -113880,7 +114161,7 @@ function saveFeedback(input2) {
113880
114161
  const path = join61(getDataDir(), "feedback.jsonl");
113881
114162
  const dir = dirname36(path);
113882
114163
  if (!existsSync30(dir))
113883
- mkdirSync21(dir, { recursive: true });
114164
+ mkdirSync22(dir, { recursive: true });
113884
114165
  appendFileSync2(path, JSON.stringify({ message, category, email: input2.email ?? null, agent: input2.agent ?? null, version: input2.version ?? null, createdAt: new Date().toISOString() }) + `
113885
114166
  `);
113886
114167
  return { saved: true, category, path };
@@ -114041,7 +114322,7 @@ var init_resource_meta_tools = __esm(() => {
114041
114322
  });
114042
114323
 
114043
114324
  // src/lib/scheduler.ts
114044
- import { existsSync as existsSync31, readFileSync as readFileSync40, writeFileSync as writeFileSync20, mkdirSync as mkdirSync22 } from "fs";
114325
+ import { existsSync as existsSync31, readFileSync as readFileSync40, writeFileSync as writeFileSync20, mkdirSync as mkdirSync23 } from "fs";
114045
114326
  import { join as join62 } from "path";
114046
114327
  function getSchedulesPath(targetDir = process.cwd()) {
114047
114328
  return join62(targetDir, ".skills", "schedules.json");
@@ -114059,7 +114340,7 @@ function saveSchedules(data, targetDir = process.cwd()) {
114059
114340
  const path = getSchedulesPath(targetDir);
114060
114341
  const dir = join62(targetDir, ".skills");
114061
114342
  if (!existsSync31(dir))
114062
- mkdirSync22(dir, { recursive: true });
114343
+ mkdirSync23(dir, { recursive: true });
114063
114344
  writeFileSync20(path, JSON.stringify(data, null, 2));
114064
114345
  }
114065
114346
  function validateCronField(expr, min2, max2, label) {
@@ -114359,9 +114640,9 @@ var init_schedule_tools = __esm(() => {
114359
114640
  import { createHash as createHash38, createHmac as createHmac3 } from "crypto";
114360
114641
  import {
114361
114642
  existsSync as existsSync32,
114362
- mkdirSync as mkdirSync23,
114643
+ mkdirSync as mkdirSync24,
114363
114644
  readFileSync as readFileSync41,
114364
- readdirSync as readdirSync22,
114645
+ readdirSync as readdirSync23,
114365
114646
  statSync as statSync21,
114366
114647
  writeFileSync as writeFileSync21
114367
114648
  } from "fs";
@@ -114486,7 +114767,7 @@ function parsePositiveInteger(value) {
114486
114767
  }
114487
114768
  function walkFiles2(dir) {
114488
114769
  const files = [];
114489
- for (const entry of readdirSync22(dir)) {
114770
+ for (const entry of readdirSync23(dir)) {
114490
114771
  const full = join63(dir, entry);
114491
114772
  const stats = statSync21(full);
114492
114773
  if (stats.isDirectory())
@@ -114725,7 +115006,7 @@ var init_private_publication_customer = __esm(() => {
114725
115006
  });
114726
115007
 
114727
115008
  // src/lib/private-publication-recovery.ts
114728
- import { constants as constants27, closeSync as closeSync28, fsyncSync as fsyncSync9, fstatSync as fstatSync28, lstatSync as lstatSync38, mkdirSync as mkdirSync24, openSync as openSync28, readSync as readSync20, realpathSync as realpathSync18, renameSync as renameSync13, unlinkSync as unlinkSync9, writeFileSync as writeFileSync22 } from "fs";
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";
114729
115010
  import { dirname as dirname38, isAbsolute as isAbsolute35, join as join64, resolve as resolve35 } from "path";
114730
115011
  import { randomUUID as randomUUID9 } from "crypto";
114731
115012
  function safeDirectory(directory3) {
@@ -114869,7 +115150,7 @@ async function preparePrivatePublication(client2, sourceDirectory, recoveryDirec
114869
115150
  };
114870
115151
  if (!isAbsolute35(recoveryDirectory) || resolve35(recoveryDirectory) !== recoveryDirectory || realpathSync18(dirname38(recoveryDirectory)) !== dirname38(recoveryDirectory))
114871
115152
  return fail5();
114872
- mkdirSync24(recoveryDirectory, { mode: 448 });
115153
+ mkdirSync25(recoveryDirectory, { mode: 448 });
114873
115154
  safeDirectory(recoveryDirectory);
114874
115155
  const parent = openSync28(dirname38(recoveryDirectory), constants27.O_RDONLY | constants27.O_NOFOLLOW);
114875
115156
  try {
@@ -115432,7 +115713,7 @@ var exports_runtime_mcp = {};
115432
115713
  __export(exports_runtime_mcp, {
115433
115714
  handleMcp: () => handleMcp
115434
115715
  });
115435
- import { existsSync as existsSync33, mkdirSync as mkdirSync25, readFileSync as readFileSync42, writeFileSync as writeFileSync23 } from "fs";
115716
+ import { existsSync as existsSync33, mkdirSync as mkdirSync26, readFileSync as readFileSync42, writeFileSync as writeFileSync23 } from "fs";
115436
115717
  import { homedir as homedir10 } from "os";
115437
115718
  import { dirname as dirname39, join as join65 } from "path";
115438
115719
  async function handleMcp(options) {
@@ -115608,7 +115889,7 @@ function writeJsonObject(path, data) {
115608
115889
  `);
115609
115890
  }
115610
115891
  function writeTextFile(path, content) {
115611
- mkdirSync25(dirname39(path), { recursive: true });
115892
+ mkdirSync26(dirname39(path), { recursive: true });
115612
115893
  writeFileSync23(path, content.endsWith(`
115613
115894
  `) ? content : `${content}
115614
115895
  `);
@@ -115803,7 +116084,7 @@ async function validateReviewedRuntimeLock(bytes, sha2563, context2) {
115803
116084
  throw new Error("REVIEWED_LOCK_LOCATION_INVALID");
115804
116085
  if (location === `node_modules/${PACKAGE2}`)
115805
116086
  continue;
115806
- if (typeof entry.version !== "string" || !VERSION.test(entry.version) || typeof entry.resolved !== "string" || typeof entry.integrity !== "string" || !INTEGRITY.test(entry.integrity))
116087
+ if (typeof entry.version !== "string" || !VERSION2.test(entry.version) || typeof entry.resolved !== "string" || typeof entry.integrity !== "string" || !INTEGRITY.test(entry.integrity))
115807
116088
  throw new Error("REVIEWED_LOCK_PACKAGE_INVALID");
115808
116089
  let url2;
115809
116090
  try {
@@ -115835,10 +116116,10 @@ async function validateReviewedRuntimeLock(bytes, sha2563, context2) {
115835
116116
  }));
115836
116117
  }
115837
116118
  }
115838
- var PACKAGE2 = "@hasna/skills", NAME2, VERSION, INTEGRITY, MAX_LOCK_BYTES, MAX_METADATA_BYTES;
116119
+ var PACKAGE2 = "@hasna/skills", NAME2, VERSION2, INTEGRITY, MAX_LOCK_BYTES, MAX_METADATA_BYTES;
115839
116120
  var init_reviewed_runtime_lock = __esm(() => {
115840
116121
  NAME2 = /^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/;
115841
- VERSION = /^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?(?:\+[a-zA-Z0-9.-]+)?$/;
116122
+ VERSION2 = /^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?(?:\+[a-zA-Z0-9.-]+)?$/;
115842
116123
  INTEGRITY = /^sha512-[A-Za-z0-9+/]{86}==$/;
115843
116124
  MAX_LOCK_BYTES = 8 * 1024 * 1024;
115844
116125
  MAX_METADATA_BYTES = 32 * 1024 * 1024;
@@ -115848,15 +116129,15 @@ var init_reviewed_runtime_lock = __esm(() => {
115848
116129
  import { createHash as createHash40, randomUUID as randomUUID10 } from "crypto";
115849
116130
  import { Readable } from "stream";
115850
116131
  import { createGunzip as createGunzip2 } from "zlib";
115851
- import { spawnSync as spawnSync5 } from "child_process";
116132
+ import { spawnSync as spawnSync6 } from "child_process";
115852
116133
  import {
115853
116134
  chmodSync as chmodSync4,
115854
116135
  copyFileSync,
115855
116136
  existsSync as existsSync34,
115856
116137
  lstatSync as lstatSync39,
115857
- mkdirSync as mkdirSync26,
116138
+ mkdirSync as mkdirSync27,
115858
116139
  readFileSync as readFileSync43,
115859
- readdirSync as readdirSync23,
116140
+ readdirSync as readdirSync24,
115860
116141
  readlinkSync as readlinkSync8,
115861
116142
  realpathSync as realpathSync19,
115862
116143
  renameSync as renameSync14,
@@ -115927,7 +116208,7 @@ function verifyTargetPrerequisites(manifest, packageRoot, home, cwd2, pathValue)
115927
116208
  for (const key2 of ["SUMI_CONFIG", "SUMI_CONFIG_CONTENT"])
115928
116209
  if (process.env[key2] !== undefined)
115929
116210
  env3[key2] = "";
115930
- const child2 = spawnSync5(pinnedLauncherRuntime(), [...PINNED_LAUNCHER_BUN_FLAGS2, entry, home, cwd2], {
116211
+ const child2 = spawnSync6(pinnedLauncherRuntime(), [...PINNED_LAUNCHER_BUN_FLAGS2, entry, home, cwd2], {
115931
116212
  cwd: dirname40(packageRoot),
115932
116213
  env: env3,
115933
116214
  encoding: "buffer",
@@ -116001,7 +116282,7 @@ function assertNoSymlinkAncestors(path) {
116001
116282
  function acquireRuntimeLock(runtimeRoot) {
116002
116283
  const lockPath = join66(runtimeRoot, ".copyfile-update-lock");
116003
116284
  try {
116004
- mkdirSync26(lockPath, { mode: 448 });
116285
+ mkdirSync27(lockPath, { mode: 448 });
116005
116286
  } catch {
116006
116287
  throw new Error("RUNTIME_UPDATE_LOCKED");
116007
116288
  }
@@ -116270,7 +116551,7 @@ async function downloadPackage(version2, stagingRoot, registryOrigin, fetcher) {
116270
116551
  throw new Error("TARBALL_PACKAGE_IDENTITY_MISMATCH");
116271
116552
  const bins = packageBins(unpacked);
116272
116553
  const archiveRoot = join66(stagingRoot, "verified-archive");
116273
- mkdirSync26(archiveRoot, { mode: 448 });
116554
+ mkdirSync27(archiveRoot, { mode: 448 });
116274
116555
  await archive.extract(archiveRoot);
116275
116556
  const extractedPackage = join66(archiveRoot, "package");
116276
116557
  const extracted = readTree(extractedPackage, false);
@@ -116321,7 +116602,7 @@ function readTree(root2, includeModes, excludeNpmDependencies = false) {
116321
116602
  const base3 = realpathSync19(root2);
116322
116603
  const entries = [];
116323
116604
  const walk2 = (dir, prefix = "") => {
116324
- for (const item of readdirSync23(dir).sort()) {
116605
+ for (const item of readdirSync24(dir).sort()) {
116325
116606
  const path = join66(dir, item);
116326
116607
  const rel = prefix ? `${prefix}/${item}` : item;
116327
116608
  const stat3 = lstatSync39(path);
@@ -116365,7 +116646,7 @@ function normalizeModes(root2) {
116365
116646
  throw new Error("RUNTIME_ENTRY_TYPE_UNSUPPORTED");
116366
116647
  chmodSync4(root2, rootStat.mode & 493);
116367
116648
  const walk2 = (dir) => {
116368
- for (const item of readdirSync23(dir)) {
116649
+ for (const item of readdirSync24(dir)) {
116369
116650
  const path = join66(dir, item);
116370
116651
  const stat3 = lstatSync39(path);
116371
116652
  if (stat3.isSymbolicLink())
@@ -116426,7 +116707,7 @@ function verifyPreimageManifest(runtimePath, receipt, home) {
116426
116707
  }
116427
116708
  function captureConfigPreimages(home, stage) {
116428
116709
  const root2 = join66(stage, "preimage", "configs");
116429
- mkdirSync26(root2, { recursive: true, mode: 448 });
116710
+ mkdirSync27(root2, { recursive: true, mode: 448 });
116430
116711
  return CONFIG_PREIMAGE_PATHS.map((relativePath) => {
116431
116712
  const sourcePath = join66(home, relativePath);
116432
116713
  if (!entryExists(sourcePath))
@@ -116436,7 +116717,7 @@ function captureConfigPreimages(home, stage) {
116436
116717
  throw new Error("CONFIG_PREIMAGE_NOT_REGULAR_FILE");
116437
116718
  const bytes = readFileSync43(sourcePath);
116438
116719
  const backupPath = join66(root2, relativePath);
116439
- mkdirSync26(dirname40(backupPath), { recursive: true, mode: 448 });
116720
+ mkdirSync27(dirname40(backupPath), { recursive: true, mode: 448 });
116440
116721
  writeFileSync24(backupPath, bytes, { flag: "wx", mode: 384 });
116441
116722
  chmodSync4(backupPath, 384);
116442
116723
  const readback = readFileSync43(backupPath);
@@ -116589,7 +116870,7 @@ function persistReceipt(path, value) {
116589
116870
  return;
116590
116871
  const historyRoot = join66(dirname40(path), "receipt-history");
116591
116872
  if (!entryExists(historyRoot))
116592
- mkdirSync26(historyRoot, { mode: 448 });
116873
+ mkdirSync27(historyRoot, { mode: 448 });
116593
116874
  const historyStat = lstatSync39(historyRoot);
116594
116875
  if (!historyStat.isDirectory() || historyStat.isSymbolicLink() || (historyStat.mode & 63) !== 0)
116595
116876
  throw new Error("RECEIPT_HISTORY_NOT_PRIVATE");
@@ -116613,7 +116894,7 @@ function persistAliasReceipt(path, value) {
116613
116894
  return;
116614
116895
  const history = join66(dirname40(path), "history");
116615
116896
  if (!entryExists(history))
116616
- mkdirSync26(history, { mode: 448 });
116897
+ mkdirSync27(history, { mode: 448 });
116617
116898
  const historyStat = lstatSync39(history);
116618
116899
  if (!historyStat.isDirectory() || historyStat.isSymbolicLink() || (historyStat.mode & 63) !== 0)
116619
116900
  throw new Error("ALIAS_RECEIPT_HISTORY_UNSAFE");
@@ -116770,7 +117051,7 @@ function adoptCopyfileAliases(options = {}) {
116770
117051
  }
116771
117052
  if (!aliases.length)
116772
117053
  return { adopted: true, version: layout.currentVersion, aliasCount: 0 };
116773
- mkdirSync26(receiptDir, { recursive: true, mode: 448 });
117054
+ mkdirSync27(receiptDir, { recursive: true, mode: 448 });
116774
117055
  const receiptDirStat = lstatSync39(receiptDir);
116775
117056
  if (!receiptDirStat.isDirectory() || receiptDirStat.isSymbolicLink() || receiptDirStat.mode & 63)
116776
117057
  throw new Error("ALIAS_RECEIPT_DIRECTORY_UNSAFE");
@@ -116996,7 +117277,7 @@ async function updateCopyfileRuntime(version2, options = {}) {
116996
117277
  try {
116997
117278
  if (entryExists(finalPath))
116998
117279
  throw new Error("TARGET_RUNTIME_ALREADY_EXISTS");
116999
- mkdirSync26(stagePath, { mode: 448 });
117280
+ mkdirSync27(stagePath, { mode: 448 });
117000
117281
  chmodSync4(stagePath, 448);
117001
117282
  const configPreimages = captureConfigPreimages(home, stagePath);
117002
117283
  const fetcher = options.fetcher ?? fetch;
@@ -117005,7 +117286,7 @@ async function updateCopyfileRuntime(version2, options = {}) {
117005
117286
  throw new Error("PACKAGE_BIN_SET_CHANGED");
117006
117287
  }
117007
117288
  const stagePackage = join66(stagePath, "install");
117008
- mkdirSync26(stagePackage, { mode: 448 });
117289
+ mkdirSync27(stagePackage, { mode: 448 });
117009
117290
  copyFileSync(artifact.tarballPath, join66(stagePackage, "verified.tgz"));
117010
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" });
117011
117292
  let npmVersion;
@@ -117175,7 +117456,7 @@ function rollbackCopyfileRuntime(receiptId, options = {}) {
117175
117456
  throw new Error("RUNTIME_ROOT_NOT_PRIVATE");
117176
117457
  const releaseLock = acquireRuntimeLock(runtimeRoot);
117177
117458
  try {
117178
- const matches2 = readdirSync23(runtimeRoot).filter((name) => {
117459
+ const matches2 = readdirSync24(runtimeRoot).filter((name) => {
117179
117460
  if (!/^\d+\.\d+\.\d+-copyfile$/.test(name))
117180
117461
  return false;
117181
117462
  const receipt2 = join66(runtimeRoot, name, "rollout-receipt.json");
@@ -117279,7 +117560,7 @@ __export(exports_runtime, {
117279
117560
  registerRuntime: () => registerRuntime
117280
117561
  });
117281
117562
  import { createHash as createHash41, randomUUID as randomUUID11 } from "crypto";
117282
- import { lstatSync as lstatSync40, mkdirSync as mkdirSync27, readFileSync as readFileSync44, writeFileSync as writeFileSync25 } from "fs";
117563
+ import { lstatSync as lstatSync40, mkdirSync as mkdirSync28, readFileSync as readFileSync44, writeFileSync as writeFileSync25 } from "fs";
117283
117564
  import { basename as basename22, isAbsolute as isAbsolute38, join as join67 } from "path";
117284
117565
  import { createInterface } from "readline";
117285
117566
  function registerRuntime(parent) {
@@ -118196,7 +118477,7 @@ async function handleExportsDownload(runId2, options) {
118196
118477
  const canonicalSkill = typeof remoteRun.skill === "string" ? remoteRun.skill : "remote";
118197
118478
  const requestedSkill = typeof remoteRun.requestedSlug === "string" && remoteRun.requestedSlug.trim() ? remoteRun.requestedSlug : canonicalSkill;
118198
118479
  const exportDir = getRunExportDir(runId2, requestedSkill);
118199
- mkdirSync27(exportDir, { recursive: true });
118480
+ mkdirSync28(exportDir, { recursive: true });
118200
118481
  const downloaded = [];
118201
118482
  for (const artifact of artifacts) {
118202
118483
  const artifactId = String(artifact.id || "");
@@ -118250,7 +118531,7 @@ function ensureSafeExportParent(root2, relativePath) {
118250
118531
  } catch (error61) {
118251
118532
  if (error61.code !== "ENOENT")
118252
118533
  throw error61;
118253
- mkdirSync27(parent, { mode: 448 });
118534
+ mkdirSync28(parent, { mode: 448 });
118254
118535
  }
118255
118536
  }
118256
118537
  }
@@ -118840,7 +119121,7 @@ var init_completion = __esm(() => {
118840
119121
  });
118841
119122
 
118842
119123
  // src/lib/portable-snapshot-filter.ts
118843
- import { readdirSync as readdirSync24, statSync as statSync22 } from "fs";
119124
+ import { readdirSync as readdirSync25, statSync as statSync22 } from "fs";
118844
119125
  import { homedir as homedir11 } from "os";
118845
119126
  import { join as join68, sep as sep19 } from "path";
118846
119127
  function isExcludedSkillFileName(fileName) {
@@ -118879,7 +119160,7 @@ function destinationFor(definition, stationId, relativePath) {
118879
119160
  function walkEntries(absoluteRoot) {
118880
119161
  let entries;
118881
119162
  try {
118882
- entries = readdirSync24(absoluteRoot, { withFileTypes: true });
119163
+ entries = readdirSync25(absoluteRoot, { withFileTypes: true });
118883
119164
  } catch {
118884
119165
  return [];
118885
119166
  }
@@ -118992,7 +119273,7 @@ var init_portable_snapshot_filter = __esm(() => {
118992
119273
  import { createHash as createHash42 } from "crypto";
118993
119274
  import {
118994
119275
  copyFileSync as copyFileSync2,
118995
- mkdirSync as mkdirSync28,
119276
+ mkdirSync as mkdirSync29,
118996
119277
  readFileSync as readFileSync45,
118997
119278
  statSync as statSync23,
118998
119279
  writeFileSync as writeFileSync26
@@ -119125,7 +119406,7 @@ function writeStationSnapshot(options) {
119125
119406
  let written = 0;
119126
119407
  for (const plan of untouched) {
119127
119408
  const destination = resolve37(repoRoot, plan.destination);
119128
- mkdirSync28(dirname42(destination), { recursive: true });
119409
+ mkdirSync29(dirname42(destination), { recursive: true });
119129
119410
  copyFileSync2(plan.source.fullPath, destination);
119130
119411
  written += 1;
119131
119412
  }
@@ -119144,7 +119425,7 @@ function writeStationSnapshot(options) {
119144
119425
  files: manifestFiles
119145
119426
  };
119146
119427
  const manifestPath = resolve37(repoRoot, "resources", options.stationId, "skills", "sync-manifest.json");
119147
- mkdirSync28(dirname42(manifestPath), { recursive: true });
119428
+ mkdirSync29(dirname42(manifestPath), { recursive: true });
119148
119429
  writeFileSync26(manifestPath, `${JSON.stringify(manifest, null, 2)}
119149
119430
  `);
119150
119431
  return {
@@ -119826,7 +120107,7 @@ var init_codex_hook_policy_recovery = __esm(() => {
119826
120107
  });
119827
120108
 
119828
120109
  // src/lib/agent-codex-trust.ts
119829
- import { lstatSync as lstatSync44, mkdirSync as mkdirSync29, readdirSync as readdirSync25, readFileSync as readFileSync46, realpathSync as realpathSync21, statSync as statSync24 } from "fs";
120110
+ import { lstatSync as lstatSync44, mkdirSync as mkdirSync30, readdirSync as readdirSync26, readFileSync as readFileSync46, realpathSync as realpathSync21, statSync as statSync24 } from "fs";
119830
120111
  import { createHash as createHash43, randomUUID as randomUUID12 } from "crypto";
119831
120112
  import { execFileSync as execFileSync2 } from "child_process";
119832
120113
  import { dirname as dirname45, isAbsolute as isAbsolute41, join as join72, resolve as resolve40 } from "path";
@@ -120012,7 +120293,7 @@ async function reconcileCodexNativeHooks(options, connect = connectCodexHookRpc)
120012
120293
  if (recovery?.reviewedPlanDigest !== undefined)
120013
120294
  need8(recovery.reviewedPlanDigest === recoveryPlanDigest, "RECONCILE_RECOVERY_PLAN_CHANGED");
120014
120295
  const preview2 = !!recovery && recovery.reviewedPlanDigest === undefined;
120015
- 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) };
120016
120297
  if (preview2)
120017
120298
  return receipt;
120018
120299
  save(join72(journal, "receipt.json"), json2(receipt));
@@ -120026,9 +120307,9 @@ async function reconcileCodexNativeHooks(options, connect = connectCodexHookRpc)
120026
120307
  }
120027
120308
  async function enrollCodexNativeHooks(options = {}, connect = connectCodexHookRpc) {
120028
120309
  const home = resolve40(options.home ?? homedir13());
120029
- return withCodexCorpusWriteAsync([join72(home, ".codex")], () => enrollCodexNativeHooksUnlocked(options, connect), options);
120310
+ return withCodexCorpusWriteAsync([join72(home, ".codex")], (_assertCurrent, admission) => enrollCodexNativeHooksUnlocked(options, connect, admission), options);
120030
120311
  }
120031
- async function enrollCodexNativeHooksUnlocked(options, connect) {
120312
+ async function enrollCodexNativeHooksUnlocked(options, connect, admission) {
120032
120313
  let rpc, journal;
120033
120314
  try {
120034
120315
  const home = resolve40(options.home ?? homedir13()), dataDir3 = resolve40(options.dataDir ?? getDataDirReadOnly());
@@ -120089,14 +120370,14 @@ async function enrollCodexNativeHooksUnlocked(options, connect) {
120089
120370
  checkInputs();
120090
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 };
120091
120372
  const planDigest = makePlanDigest(digestInput);
120092
- 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) };
120093
120374
  if (options.apply)
120094
120375
  need8(options.reviewedPlanDigest === planDigest, "PLAN_CHANGED: run the dry-run again and pass its reviewed --plan-digest with --apply");
120095
120376
  const parent = join72(dataDir3, "native-hook-trust");
120096
120377
  const st = lstatSync44(parent, { throwIfNoEntry: false });
120097
120378
  if (st) {
120098
120379
  need8(st.isDirectory() && !st.isSymbolicLink() && st.uid === process.getuid() && (st.mode & 511) === 448, "UNSAFE_JOURNAL");
120099
- const priorJournals = readdirSync25(parent);
120380
+ const priorJournals = readdirSync26(parent);
120100
120381
  need8(priorJournals.length < 1000, "JOURNAL_BOUND");
120101
120382
  for (const name of priorJournals) {
120102
120383
  need8(/^[a-f0-9-]{36}$/.test(name), "UNSAFE_JOURNAL");
@@ -120106,13 +120387,13 @@ async function enrollCodexNativeHooksUnlocked(options, connect) {
120106
120387
  if (!options.apply || !planned.length)
120107
120388
  return baseReceipt;
120108
120389
  if (!st)
120109
- mkdirSync29(parent, { mode: 448 });
120390
+ mkdirSync30(parent, { mode: 448 });
120110
120391
  journal = join72(parent, randomUUID12());
120111
- mkdirSync29(journal, { mode: 448 });
120392
+ mkdirSync30(journal, { mode: 448 });
120112
120393
  save(join72(journal, "config.before.toml"), configFile.bytes);
120113
120394
  save(join72(journal, "hooks.before.json"), hooksFile.bytes);
120114
120395
  save(join72(journal, "policy.before.json"), policyFile.bytes);
120115
- 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) }));
120116
120397
  need8(isDeepStrictEqual19(admit(await list2()), admitted), "NATIVE_DISCOVERY_CHANGED");
120117
120398
  checkInputs();
120118
120399
  let result2;
@@ -120150,7 +120431,7 @@ async function enrollCodexNativeHooksUnlocked(options, connect) {
120150
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";
120151
120432
  if (journal) {
120152
120433
  try {
120153
- 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) }));
120154
120435
  } catch {}
120155
120436
  }
120156
120437
  throw new Error(message);
@@ -120269,7 +120550,7 @@ var init_codex_native_trust = __esm(() => {
120269
120550
 
120270
120551
  // src/lib/claude-prospective-review.ts
120271
120552
  import { createHash as createHash45 } from "crypto";
120272
- import { lstatSync as lstatSync45, readFileSync as readFileSync48, readdirSync as readdirSync26, realpathSync as realpathSync22 } from "fs";
120553
+ import { lstatSync as lstatSync45, readFileSync as readFileSync48, readdirSync as readdirSync27, realpathSync as realpathSync22 } from "fs";
120273
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";
120274
120555
  import { isDeepStrictEqual as isDeepStrictEqual20 } from "util";
120275
120556
  function hashClaudeDiscoveryBinding(binding) {
@@ -120359,7 +120640,7 @@ function captureClaudeProspectiveCandidateClosure(root2) {
120359
120640
  let bytes = 0;
120360
120641
  const walk2 = (directory3) => {
120361
120642
  const beforeDirectory = lstatSync45(directory3);
120362
- const names = readdirSync26(directory3).sort();
120643
+ const names = readdirSync27(directory3).sort();
120363
120644
  if (new Set(names).size !== names.length)
120364
120645
  refuse8("candidate contains ambiguous directory entries");
120365
120646
  for (const name of names) {
@@ -120514,7 +120795,7 @@ function assertNoUnprojectedSkillPayload(root2, catalogPath, marketplace, plugin
120514
120795
  if (entries[0].skills !== undefined || entries[0].commands !== undefined)
120515
120796
  refuse8("candidate marketplace entry declares native skill or command payloads");
120516
120797
  const walk2 = (directory3) => {
120517
- for (const name of readdirSync26(directory3).sort()) {
120798
+ for (const name of readdirSync27(directory3).sort()) {
120518
120799
  const path = join74(directory3, name), rel = relative15(root2, path).split(sep21).join("/");
120519
120800
  const stat3 = lstatSync45(path);
120520
120801
  if (stat3.isDirectory())
@@ -121468,11 +121749,16 @@ function registerAgentIntegration(parent) {
121468
121749
  throw new Error("CODEX_NATIVE_SKILL_CATALOG_ABSOLUTE_PATH_REQUIRED");
121469
121750
  if (existsSync36(options.output))
121470
121751
  throw new Error("CODEX_NATIVE_SKILL_CATALOG_OUTPUT_EXISTS");
121752
+ let admission;
121471
121753
  const catalog = await captureCodexNativeSkillCatalog({
121472
121754
  command: options.codexCommand,
121473
121755
  home: homedir14(),
121474
121756
  ...process.env.CODEX_HOME === undefined ? {} : { codexHome: process.env.CODEX_HOME },
121475
121757
  cwd: options.cwd
121758
+ }, async (connection) => {
121759
+ const rpc = await connectCodexHookRpc(connection);
121760
+ admission = rpc.admission;
121761
+ return rpc;
121476
121762
  });
121477
121763
  const bytes = JSON.stringify(catalog, null, 2) + `
121478
121764
  `;
@@ -121492,7 +121778,8 @@ function registerAgentIntegration(parent) {
121492
121778
  skillCount: catalog.skills.length,
121493
121779
  output: options.output,
121494
121780
  bytes: Buffer.byteLength(bytes),
121495
- sha256: createHash47("sha256").update(bytes).digest("hex")
121781
+ sha256: createHash47("sha256").update(bytes).digest("hex"),
121782
+ ...codexAdmissionReceipt(admission)
121496
121783
  };
121497
121784
  await writeCliOutput(options.json ? JSON.stringify(receipt) : `Captured ${receipt.skillCount} native Codex skill(s) in ${receipt.output}.`);
121498
121785
  } catch (error61) {
@@ -121836,6 +122123,8 @@ var init_agent_integration2 = __esm(() => {
121836
122123
  init_claude_marketplace_entry_witness();
121837
122124
  init_claude_prospective_review();
121838
122125
  init_codex_native_skill_catalog();
122126
+ init_codex_hook_rpc();
122127
+ init_codex_corpus_write();
121839
122128
  init_self_spawn();
121840
122129
  init_config();
121841
122130
  init_claude_installer_capture();
@@ -122478,8 +122767,8 @@ var init_grants = __esm(() => {
122478
122767
  import { createHash as createHash48 } from "crypto";
122479
122768
  import {
122480
122769
  copyFileSync as copyFileSync3,
122481
- mkdirSync as mkdirSync30,
122482
- readdirSync as readdirSync27,
122770
+ mkdirSync as mkdirSync31,
122771
+ readdirSync as readdirSync28,
122483
122772
  readFileSync as readFileSync50,
122484
122773
  statSync as statSync25,
122485
122774
  writeFileSync as writeFileSync30
@@ -122523,7 +122812,7 @@ function planStationHydration(stationId, repoRoot) {
122523
122812
  const agentRoot = join76(snapshotRoot, "agent-homes", agent);
122524
122813
  let identEntries;
122525
122814
  try {
122526
- identEntries = readdirSync27(agentRoot, { withFileTypes: true });
122815
+ identEntries = readdirSync28(agentRoot, { withFileTypes: true });
122527
122816
  } catch {
122528
122817
  continue;
122529
122818
  }
@@ -122737,7 +123026,7 @@ function writeStationHydration(options) {
122737
123026
  }
122738
123027
  let written = 0;
122739
123028
  for (const entry of toWrite) {
122740
- mkdirSync30(dirname48(entry.destination), { recursive: true });
123029
+ mkdirSync31(dirname48(entry.destination), { recursive: true });
122741
123030
  copyFileSync3(entry.fullPath, entry.destination);
122742
123031
  written += 1;
122743
123032
  }
@@ -122759,7 +123048,7 @@ function writeStationHydration(options) {
122759
123048
  skills: resultSkills
122760
123049
  };
122761
123050
  const hydrationManifestPath = join76(dirname48(cacheRoot), `hydration-${options.stationId}.json`);
122762
- mkdirSync30(dirname48(hydrationManifestPath), { recursive: true });
123051
+ mkdirSync31(dirname48(hydrationManifestPath), { recursive: true });
122763
123052
  writeFileSync30(hydrationManifestPath, `${JSON.stringify(hydration, null, 2)}
122764
123053
  `);
122765
123054
  return {
@@ -122836,7 +123125,7 @@ var init_hydrate = __esm(() => {
122836
123125
 
122837
123126
  // src/lib/prepare-skill.ts
122838
123127
  import { createHash as createHash49, randomUUID as randomUUID13 } from "crypto";
122839
- import { chmodSync as chmodSync5, existsSync as existsSync37, lstatSync as lstatSync48, mkdirSync as mkdirSync31, mkdtempSync as mkdtempSync6, readFileSync as readFileSync51, readdirSync as readdirSync28, renameSync as renameSync15, rmSync as rmSync9, writeFileSync as writeFileSync31 } from "fs";
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";
122840
123129
  import { tmpdir as tmpdir2 } from "os";
122841
123130
  import { dirname as dirname49, isAbsolute as isAbsolute46, join as join77, relative as relative16, resolve as resolve46, sep as sep24 } from "path";
122842
123131
  function prepareSkill(name, options) {
@@ -122878,13 +123167,13 @@ function prepareSkill(name, options) {
122878
123167
  throw new Error("skill.json provenance must be an object.");
122879
123168
  const provenance = manifest.provenance;
122880
123169
  const candidate2 = { ...manifest, version: options.version, kind, provenance: { ...provenance } };
122881
- const staging = mkdtempSync6(join77(tmpdir2(), "skills-prepare-"));
123170
+ const staging = mkdtempSync7(join77(tmpdir2(), "skills-prepare-"));
122882
123171
  try {
122883
123172
  for (const directory3 of before2.directories)
122884
- mkdirSync31(join77(staging, directory3), { recursive: true });
123173
+ mkdirSync32(join77(staging, directory3), { recursive: true });
122885
123174
  for (const file2 of before2.files) {
122886
123175
  const destination = join77(staging, file2.path);
122887
- mkdirSync31(dirname49(destination), { recursive: true });
123176
+ mkdirSync32(dirname49(destination), { recursive: true });
122888
123177
  writeFileSync31(destination, file2.bytes, { mode: file2.mode });
122889
123178
  }
122890
123179
  const stagedManifest = join77(staging, "skill.json");
@@ -122916,12 +123205,12 @@ ${validation.issues.map((issue2) => `${issue2.code}: ${issue2.message}`).join(`
122916
123205
  chmodSync5(temporary, manifestFile.mode);
122917
123206
  renameSync15(temporary, join77(path, "skill.json"));
122918
123207
  } finally {
122919
- rmSync9(temporary, { force: true });
123208
+ rmSync10(temporary, { force: true });
122920
123209
  }
122921
123210
  }
122922
123211
  return { name: normalized2, path, previousVersion, version: options.version, kind, contentHash, changed: changed3, written: changed3 && !options.dryRun, warnings: validation.warnings };
122923
123212
  } finally {
122924
- rmSync9(staging, { recursive: true, force: true });
123213
+ rmSync10(staging, { recursive: true, force: true });
122925
123214
  }
122926
123215
  }
122927
123216
  function assertPackedCanonicalCoverage(root2) {
@@ -123037,7 +123326,7 @@ function snapshot2(root2) {
123037
123326
  const hash7 = createHash49("sha256").update(`${rootStat.dev}:${rootStat.ino}\x00`);
123038
123327
  let count = 0, bytes = 0;
123039
123328
  const walk2 = (relative17) => {
123040
- for (const name of readdirSync28(join77(root2, relative17)).sort()) {
123329
+ for (const name of readdirSync29(join77(root2, relative17)).sort()) {
123041
123330
  if (IGNORED.has(name.toLowerCase()) || !relative17 && ROOT_IGNORED.has(name.toLowerCase()))
123042
123331
  continue;
123043
123332
  const path = relative17 ? `${relative17}/${name}` : name;
@@ -123458,7 +123747,7 @@ var init_schedule = __esm(() => {
123458
123747
  });
123459
123748
 
123460
123749
  // src/lib/registry-sync.ts
123461
- import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync32 } from "fs";
123750
+ import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync32 } from "fs";
123462
123751
  import { dirname as dirname50, relative as relative17 } from "path";
123463
123752
  function createRegistrySyncArtifact(options = {}) {
123464
123753
  const profile = options.profile ?? "all";
@@ -123516,7 +123805,7 @@ function createRegistrySyncArtifact(options = {}) {
123516
123805
  };
123517
123806
  }
123518
123807
  function writeRegistrySyncArtifact(path, artifact) {
123519
- mkdirSync32(dirname50(path), { recursive: true });
123808
+ mkdirSync33(dirname50(path), { recursive: true });
123520
123809
  writeFileSync32(path, `${JSON.stringify(artifact, null, 2)}
123521
123810
  `);
123522
123811
  }