@inkeep/open-knowledge 0.50.0-beta.0 → 0.50.0-beta.1

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.
Files changed (38) hide show
  1. package/dist/{acp-harness-probe-LTFljjjT.mjs → acp-harness-probe-DwJF1QrM.mjs} +2 -2
  2. package/dist/cli.mjs +62 -62
  3. package/dist/constants-C9EGLQ-u.mjs +2 -0
  4. package/dist/index.d.mts +36 -5
  5. package/dist/index.mjs +1 -1
  6. package/dist/{init-DoE9fKH8.mjs → init-8_iXriiz.mjs} +3 -3
  7. package/dist/init-D5SAyEIp.mjs +1 -0
  8. package/dist/{launch-json-removal--afgb0jV.mjs → launch-json-removal-CXPn5A7N.mjs} +2 -2
  9. package/dist/{loader-C00kGDZz.mjs → loader-CJqV3lQK.mjs} +2 -2
  10. package/dist/loader-CU-Nz3ee.mjs +1 -0
  11. package/dist/{open-browser-BuOrhXvS.mjs → open-browser-Bu1KY-5f.mjs} +2 -2
  12. package/dist/{preview-CMjft0ek.mjs → preview-CXrbuj-R.mjs} +2 -2
  13. package/dist/preview-CjwSh-52.mjs +1 -0
  14. package/dist/{repair-launch-json-DWyYbCft.mjs → repair-launch-json-V-un1HwF.mjs} +2 -2
  15. package/dist/{repair-mcp-configs-IqhFyLaP.mjs → repair-mcp-configs-CgS2qBwI.mjs} +2 -2
  16. package/dist/repair-skills-KPpoS1oT.mjs +1 -0
  17. package/dist/{repair-skills-DwcUYwoH.mjs → repair-skills-cQdbD3lz.mjs} +2 -2
  18. package/dist/server-lock-CMPaDe7b.mjs +1 -0
  19. package/dist/server-lock-CVlhIOaP.mjs +2 -0
  20. package/dist/{skill-teardown-DzuNnHSF.mjs → skill-teardown-BVQqx1VE.mjs} +2 -2
  21. package/dist/src-C1NIOm2S.mjs +1 -0
  22. package/dist/src-Dn98dNdR.mjs +1 -0
  23. package/dist/{src-BmsPBIN0.mjs → src-Mfncsy21.mjs} +4 -4
  24. package/dist/{src-BPPzfDas.mjs → src-q9JjDIHN.mjs} +305 -305
  25. package/dist/{start-CB1ruR88.mjs → start-BSLZXd-A.mjs} +3 -3
  26. package/dist/start-CJ3wdpkC.mjs +1 -0
  27. package/dist/{write-project-skill-DfjjNq9T.mjs → write-project-skill-DPVCl9Kv.mjs} +2 -2
  28. package/package.json +4 -4
  29. package/dist/constants-DKkdtsrQ.mjs +0 -2
  30. package/dist/init-CUlzbSqG.mjs +0 -1
  31. package/dist/loader-Dd0F_wFU.mjs +0 -1
  32. package/dist/preview-D-x1bfxi.mjs +0 -1
  33. package/dist/repair-skills-Cl53MdUh.mjs +0 -1
  34. package/dist/server-lock-C5RpbiEy.mjs +0 -1
  35. package/dist/server-lock-DQ_whZyH.mjs +0 -2
  36. package/dist/src-CWRDxPCK.mjs +0 -1
  37. package/dist/src-DpX6KBvU.mjs +0 -1
  38. package/dist/start-BhtWVSU0.mjs +0 -1
@@ -0,0 +1,2 @@
1
+ import"./src-Cb3i1kcm.mjs";var e=`0.50.0-beta.1`;const t=`config.yml`,n=e;export{n,t};
2
+ //# sourceMappingURL=constants-C9EGLQ-u.mjs.map
package/dist/index.d.mts CHANGED
@@ -10405,8 +10405,26 @@ interface ProcessLockMetadata {
10405
10405
  * written by binaries that predate `machineId`.
10406
10406
  */
10407
10407
  hostname: string;
10408
- /** HTTP/WebSocket port. 0 means "starting — port not yet bound". */
10408
+ /**
10409
+ * HTTP/WebSocket port. 0 means "starting — port not yet bound".
10410
+ *
10411
+ * DEPRECATED as a dial target in favor of `url` — kept written through the
10412
+ * ui.lock-retirement compatibility window so binaries predating `url` keep
10413
+ * discovering. New readers go through `lockBaseUrl` (prefer `url`, fall
10414
+ * back to `port`). Retirement rides the `protocolVersion` 1→2 bump at the
10415
+ * ui.lock-removal wave, NOT before.
10416
+ */
10409
10417
  port: number;
10418
+ /**
10419
+ * One-origin contract: the base URL every surface of this process is
10420
+ * reachable at (`/`, `/api`, `/mcp`, `/collab` — whichever of those
10421
+ * `capabilities` advertises). Loopback origin, no trailing slash, e.g.
10422
+ * `http://127.0.0.1:61023`. Written by `updateProcessLockPort` once the
10423
+ * listener binds; absent while `port` is 0 and on locks written by
10424
+ * binaries predating the field. Readers prefer this over `port` via
10425
+ * `lockBaseUrl`.
10426
+ */
10427
+ url?: string;
10410
10428
  startedAt: string;
10411
10429
  worktreeRoot: string;
10412
10430
  /**
@@ -10419,8 +10437,14 @@ interface ProcessLockMetadata {
10419
10437
  /**
10420
10438
  * Set when the holder has begun teardown. The holder still OWNS the lock —
10421
10439
  * the file is unlinked only when the process actually exits — but the
10422
- * advertised port is no longer safe to dial and supervisors should wait
10440
+ * advertised origin is no longer safe to dial and supervisors should wait
10423
10441
  * for pid death rather than lock disappearance. Absent means "serving".
10442
+ *
10443
+ * Deliberate two-signal design, not a wart: the flag stops discovery
10444
+ * dialing immediately, while deferring the unlink to exit keeps
10445
+ * crash-vs-clean-exit distinguishable on disk (crashed holder =
10446
+ * non-draining lock + dead pid; clean teardown = draining lock until
10447
+ * exit). "Fixing" the deferred unlink deletes the crash-detection signal.
10424
10448
  */
10425
10449
  draining?: boolean;
10426
10450
  /**
@@ -10437,9 +10461,16 @@ interface ProcessLockMetadata {
10437
10461
  */
10438
10462
  parentPid?: number;
10439
10463
  /**
10440
- * Protocol/feature surfaces this server exposes. v1: `["http", "ws"]`
10441
- * for any server booted via `bootServer`. Forward-compat for variants
10442
- * that lack one or the other.
10464
+ * Protocol/feature surfaces this server exposes. On server.lock, writers
10465
+ * that also emit `url` MUST list mounted surfaces accurately — in
10466
+ * particular `"ui"` is present iff the process itself serves the React
10467
+ * shell, so `preview_url` can distinguish "no UI mounted" from "UI served
10468
+ * elsewhere". Baseline for any `bootServer` boot is `["http", "ws"]`. On
10469
+ * server.locks without `url` (older writers) the array is best-effort
10470
+ * hints only: absence of `"ui"` is indeterminate and readers keep the
10471
+ * ui.lock fallback. On ui.lock the accuracy requirement does not apply —
10472
+ * that file's very existence is the UI signal, no reader consults its
10473
+ * `capabilities`, and the sibling retires with the ui.lock-removal wave.
10443
10474
  */
10444
10475
  capabilities?: string[];
10445
10476
  /**
package/dist/index.mjs CHANGED
@@ -1516,6 +1516,6 @@ export default function okBridge(pi: {
1516
1516
  `))}function j9(e,t){let n=S(e,`utf-8`);if(n.trim().length!==0)try{let r=k9(JSON.parse(n),t),i=n.endsWith(`
1517
1517
  `)?`
1518
1518
  `:``;ne(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=O9(n,t.contentDir);r!==n&&ne(e,r)}}function M9(e,t){let n=S(e,`utf-8`),r=O9(n,t.contentDir);r!==n&&ne(e,r)}function N9(e){try{return C(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>M(e,t.name))}catch{return[]}}const fSe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function P9(e){return/\.log\.\d+$/.test(e)}function pSe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||P9(e)}function mSe(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of N9(M(e.stagingDir,n)))pSe(r)?A9(r,t):r.endsWith(`.json`)?j9(r,t):M9(r,t);for(let n of N9(M(e.stagingDir,`state`))){let e=pe(n);n.endsWith(`.jsonl`)?A9(n,t):fSe.has(e)?j9(n,t):M9(n,t)}}const F9=[`.ok`,`local`,`telemetry`],I9=[`.ok`,`local`,`logs`],L9=[`.ok`,`local`,`loss-capture`],R9=`spans-current.jsonl`,z9=`spans-prev.jsonl`,B9=`server-current.jsonl`,V9=`server-prev.jsonl`,H9=`loss-current.jsonl`,U9=`loss-prev.jsonl`;function hSe(e){return M(e,...F9,R9)}function gSe(e){return M(e,...F9,z9)}function _Se(e){return M(e,...I9,B9)}function vSe(e){return M(e,...I9,V9)}function ySe(e){return M(e,...L9,H9)}function bSe(e){return M(e,...L9,U9)}const W9=1e3;async function xSe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function SSe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function CSe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}function wSe(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
1519
- `)}\n`:null}catch{return null}}function TSe(e){let t=M(e,`.git`,`ok`);if(!g(t))return null;let n=u(`git`,[`-C`,t,`log`,`--oneline`,`-50`],B3({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ESe(e){let t=M(e,`.git`,`ok`);if(!g(t))return null;let n=u(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],B3({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function G9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function DSe(){return{nodeVersion:process.version,platform:O(),arch:ie()}}function OSe(){return process.env.OTEL_SDK_DISABLED===`false`}function K9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q9(e){if(!g(e))return{};let t;try{t=(0,Zt.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!K9(t))return{};let n=t.telemetry;if(!K9(n))return{};let r=n.localSink;return K9(r)?r:{}}function J9(e){return typeof e==`boolean`?e:void 0}function kSe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y9(e){if(K9(e))return kSe(e.maxBytes)}function ASe(e){let t=q9(g$(`project`,e)),n=q9(g$(`project-local`,e));return{enabled:J9(n.enabled)??J9(t.enabled)??!0,spansMaxBytes:Y9(n.spans)??Y9(t.spans)??52428800,logsMaxBytes:Y9(n.logs)??Y9(t.logs)??26214400}}function jSe(e){return je(`sha256`).update(e).digest(`hex`)}function MSe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function NSe(e){let t=S(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X9(e,t){if(!g(e))return!1;try{return v(me(t),{recursive:!0}),m(e,t),!0}catch{return!1}}function Z9(e){let t=[],n=e=>{let r=C(e,{withFileTypes:!0});for(let i of r){let r=M(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const PSe=new Set([`.jsonl`]);function Q9(e){let t=e.lastIndexOf(`.`);return t===-1?!1:PSe.has(e.slice(t))}const FSe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function ISe(e){if(P9(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:FSe.has(e.slice(t))}function LSe(e){let t=[];for(let n of Z9(e)){let r=$9(e,n);if(!ISe(r))continue;let{redacted:i,patterns:a,lineCount:o}=zo(S(n,`utf-8`));a.length!==0&&(ne(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return ve(e,t).split(be).join(`/`)}async function RSe(e){let t=ye(e.contentDir),n=ye(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??xSe,a=r.fetchAgentEffects??SSe,o=r.fetchWatcherRecent??CSe,s=r.readShadowHead??TSe,c=r.readCheckpointRefs??ESe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.50.0-beta.0`),d=r.readDesktopEnv??G9,f=r.readRuntime??DSe,p=r.isOtlpPushEnabled??OSe,h=y(M(ue(),`ok-bundle-`));try{v(M(h,`telemetry`),{recursive:!0}),v(M(h,`logs`),{recursive:!0}),v(M(h,`state`),{recursive:!0}),X9(hSe(n),M(h,`telemetry`,R9)),X9(gSe(n),M(h,`telemetry`,z9)),X9(_Se(n),M(h,`logs`,B9)),X9(vSe(n),M(h,`logs`,V9));for(let t of e.userLogFiles??[])X9(t,M(h,`logs`,pe(t)));let _=M(n,`.ok`,`local`),y=M(_,`server.lock`),b=`not-running`,x=`no server.lock`,C=null;if(g(y)){X9(y,M(h,`state`,`server.lock`));try{let e=S(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(C!==null){let e=await i(C);e===null?x=`agent-presence endpoint at :${C} unreachable`:(ne(M(h,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await a(C);t!==null&&ne(M(h,`state`,`agent-effects.json`),t);let n=await o(C);if(n!==null){let e=wSe(n);e!==null&&ne(M(h,`state`,`watcher-recent.jsonl`),e)}}let w=s(t);w!==null&&ne(M(h,`state`,`shadow-head.txt`),w);let T=c(t);T!==null&&ne(M(h,`state`,`checkpoint-refs.txt`),T),X9(ySe(n),M(h,`state`,H9)),X9(bSe(n),M(h,`state`,U9)),X9(M(_,`last-spawn-error.log`),M(h,`state`,`last-spawn-error.log`)),X9(M(_,lY),M(h,`state`,lY)),X9(M(_,uY),M(h,`state`,uY));let E=f(),te=d(),re={ok:{version:u(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:te}};ne(M(h,`state`,`runtime.json`),`${JSON.stringify(re,null,2)}\n`);let ie=b===`running`?`running
1519
+ `)}\n`:null}catch{return null}}function TSe(e){let t=M(e,`.git`,`ok`);if(!g(t))return null;let n=u(`git`,[`-C`,t,`log`,`--oneline`,`-50`],B3({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ESe(e){let t=M(e,`.git`,`ok`);if(!g(t))return null;let n=u(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],B3({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function G9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function DSe(){return{nodeVersion:process.version,platform:O(),arch:ie()}}function OSe(){return process.env.OTEL_SDK_DISABLED===`false`}function K9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q9(e){if(!g(e))return{};let t;try{t=(0,Zt.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!K9(t))return{};let n=t.telemetry;if(!K9(n))return{};let r=n.localSink;return K9(r)?r:{}}function J9(e){return typeof e==`boolean`?e:void 0}function kSe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y9(e){if(K9(e))return kSe(e.maxBytes)}function ASe(e){let t=q9(g$(`project`,e)),n=q9(g$(`project-local`,e));return{enabled:J9(n.enabled)??J9(t.enabled)??!0,spansMaxBytes:Y9(n.spans)??Y9(t.spans)??52428800,logsMaxBytes:Y9(n.logs)??Y9(t.logs)??26214400}}function jSe(e){return je(`sha256`).update(e).digest(`hex`)}function MSe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function NSe(e){let t=S(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X9(e,t){if(!g(e))return!1;try{return v(me(t),{recursive:!0}),m(e,t),!0}catch{return!1}}function Z9(e){let t=[],n=e=>{let r=C(e,{withFileTypes:!0});for(let i of r){let r=M(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const PSe=new Set([`.jsonl`]);function Q9(e){let t=e.lastIndexOf(`.`);return t===-1?!1:PSe.has(e.slice(t))}const FSe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function ISe(e){if(P9(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:FSe.has(e.slice(t))}function LSe(e){let t=[];for(let n of Z9(e)){let r=$9(e,n);if(!ISe(r))continue;let{redacted:i,patterns:a,lineCount:o}=zo(S(n,`utf-8`));a.length!==0&&(ne(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return ve(e,t).split(be).join(`/`)}async function RSe(e){let t=ye(e.contentDir),n=ye(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??xSe,a=r.fetchAgentEffects??SSe,o=r.fetchWatcherRecent??CSe,s=r.readShadowHead??TSe,c=r.readCheckpointRefs??ESe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.50.0-beta.1`),d=r.readDesktopEnv??G9,f=r.readRuntime??DSe,p=r.isOtlpPushEnabled??OSe,h=y(M(ue(),`ok-bundle-`));try{v(M(h,`telemetry`),{recursive:!0}),v(M(h,`logs`),{recursive:!0}),v(M(h,`state`),{recursive:!0}),X9(hSe(n),M(h,`telemetry`,R9)),X9(gSe(n),M(h,`telemetry`,z9)),X9(_Se(n),M(h,`logs`,B9)),X9(vSe(n),M(h,`logs`,V9));for(let t of e.userLogFiles??[])X9(t,M(h,`logs`,pe(t)));let _=M(n,`.ok`,`local`),y=M(_,`server.lock`),b=`not-running`,x=`no server.lock`,C=null;if(g(y)){X9(y,M(h,`state`,`server.lock`));try{let e=S(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(C!==null){let e=await i(C);e===null?x=`agent-presence endpoint at :${C} unreachable`:(ne(M(h,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await a(C);t!==null&&ne(M(h,`state`,`agent-effects.json`),t);let n=await o(C);if(n!==null){let e=wSe(n);e!==null&&ne(M(h,`state`,`watcher-recent.jsonl`),e)}}let w=s(t);w!==null&&ne(M(h,`state`,`shadow-head.txt`),w);let T=c(t);T!==null&&ne(M(h,`state`,`checkpoint-refs.txt`),T),X9(ySe(n),M(h,`state`,H9)),X9(bSe(n),M(h,`state`,U9)),X9(M(_,`last-spawn-error.log`),M(h,`state`,`last-spawn-error.log`)),X9(M(_,lY),M(h,`state`,lY)),X9(M(_,uY),M(h,`state`,uY));let E=f(),te=d(),re={ok:{version:u(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:te}};ne(M(h,`state`,`runtime.json`),`${JSON.stringify(re,null,2)}\n`);let ie=b===`running`?`running
1520
1520
  `:`not-running (${x})\n`;if(ne(M(h,`state`,`server-status.txt`),ie),e.processDir&&g(e.processDir)){let t=M(h,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let ae=e.redact===!0;ae&&mSe({stagingDir:h,contentDir:t}),e.note&&ne(M(h,`note.txt`),e.note);let oe=null;e.scrubSecrets===!0&&(oe=LSe(h));for(let t of e.extraFiles??[])X9(t.sourcePath,M(h,`extra`,t.zipName??pe(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let se=ASe(n),ce=Z9(h),O=[],le=0,ue=0;for(let e of ce){let t=$9(h,e),n=ee(e).size,r=Q9(t)?MSe(e):0;O.push({path:t,bytes:n,lines:r}),le+=n,t.startsWith(`telemetry/`)&&Q9(t)&&(ue+=NSe(e))}let de={applied:ae};oe!==null&&(de.secretScrub=oe);let k={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:te},contentDir:{pathSha256:jSe(t),absolutePath:ae?`<CONTENT_DIR>`:t},telemetry:{localSink:se,otlpPushEnabled:p()},redaction:de,serverStatus:b,files:O};ne(M(h,`manifest.json`),`${JSON.stringify(k,null,2)}\n`);let A=ce.some(e=>{try{return S(e,`utf-8`).includes(t)}catch{return!1}}),fe={totalBytes:le,fileCount:O.length,docNameCount:ue,contentDirVisible:A,redacted:ae},me=!1;return{stagingDir:h,manifest:k,summary:fe,cleanup:()=>{me||(me=!0,D(h,{recursive:!0,force:!0}))}}}catch(e){throw D(h,{recursive:!0,force:!0}),e}}async function zSe(e){let{collected:t,outputPath:n}=e,r=me(n);if(!g(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new S_e.ZipFile,a=Z9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=h(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function BSe(e,t){let n=M(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,Zt.parse)(S(n,`utf-8`)),r=R7(t)?t.content:void 0,i=R7(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return ye(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return ye(e)}async function VSe(e,t,n){let r=m9(t,e.logger),i=await RSe({contentDir:BSe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:Lxe(r,e.userLogsDir??M(se(),`.ok`,`logs`)),deps:{readDesktopEnv:n,logger:e.logger}});try{v(me(e.outputPath),{recursive:!0}),await zSe({collected:i,outputPath:e.outputPath});let t=i.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:r,files:i.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:i.manifest.createdAt}}}finally{i.cleanup()}}async function HSe(e){let{projectDir:t}=e,n=e.readDesktopEnv??G9;if(e.level===`full`&&t!==void 0)return VSe(e,t,n);let{zipPath:r,summary:i}=await Bxe({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n()});return{zipPath:r,summary:{level:e.level,systemWide:t===void 0,projectSlug:i.projectSlug,files:i.files,redactions:i.redactions,redactedLineCount:i.redactedLineCount,generatedAt:i.generatedAt}}}export{U5 as ALL_EDITOR_IDS,W5 as EDITOR_LABELS,d7 as EDITOR_TARGETS,G5 as HOSTS_WITH_USER_SKILL_DIR,Oxe as LAUNCH_CONFIG_NAME,nSe as PATH_SHIM_BEGIN,iSe as PATH_SHIM_BLOCK_RE,rSe as PATH_SHIM_END,uxe as addOkPathsToGitExclude,A7 as assertProjectPathSafe,e7 as buildManagedServerEntry,Kxe as buildMcpConfigDeclineEvent,qxe as buildMcpConfigMigrateEvent,f9 as classifyExistingMcpEntry,HSe as collectReportBundle,tn as createTokenStore,Pxe as defaultBugReportZipPath,Ve as detectGh,Mxe as detectInstalledEditors,sbe as editorConfigPathDisplay,obe as editorEntryLocator,q7 as formatTrackedRemediation,pxe as getExcludedOkPaths,G7 as getOkArtifactPaths,Q5 as isEntryUpToDate,t7 as isOwnManagedEntry,$xe as loadConfig,dee as makeLazyProbeTokenStore,p9 as okBugReportsDir,w9 as parseGitHubBlobUrl,eSe as parseGitHubShareUrl,T9 as parseGitHubTreeUrl,C9 as parseGitUrl,aSe as pathInstallMarkerPath,Vbe as previewContent,Nxe as probeOwnManagedEditorMcpEntry,K7 as probeTrackedOkPaths,u9 as readExistingMcpEntry,fxe as readSharingMode,mxe as readSkillsShared,zo as redactContent,dxe as removeOkPathsFromGitExclude,Hxe as removeOwnMcpEntry,$be as removeProjectSkill,sSe as removeUserGlobalSkillBundle,Ybe as resolveProjectRoot,Xxe as runStop,hxe as setSkillsShared,b9 as truncatePriorEntry,D9 as userGlobalSkillBundleTargets,tSe as validateLocalFolderForShare,l9 as writeEditorMcpConfig,uSe as writeProjectAiIntegrations,N7 as writeProjectSkill,jxe as writeUserMcpConfigs};
1521
1521
  //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Y as r}from"./sleep-DVOInM4H.mjs";import{Go as i,K as a,U as o,os as s,wo as c}from"./src-Cb3i1kcm.mjs";import{$t as l,Ca as u,En as d,Fr as f,Jr as p,Lr as m,Nr as h,Pr as g,_n as _,br as v,c as y,en as b,fr as x,hn as S,l as C,mn as ee,nr as te,rr as ne,tr as re,u as ie,ur as ae,xr as oe}from"./src-BPPzfDas.mjs";import{M as w,P as T}from"./fs-traced-DVpoNaQJ.mjs";import{_ as se,a as ce,b as E,c as le,d as ue,i as de,l as fe,o as D,r as pe,t as me,u as he,v as ge}from"./write-project-skill-DfjjNq9T.mjs";import{i as O,n as k,o as A,r as _e,s as j,t as M}from"./colors-BsmVIwfM.mjs";import{t as ve}from"./constants-DKkdtsrQ.mjs";import{t as N}from"./is-object-ByG7RnjH.mjs";import{t as ye}from"./preview-CMjft0ek.mjs";import{createRequire as be}from"node:module";import{execFileSync as xe}from"node:child_process";import Se,{dirname as P,isAbsolute as F,join as I,relative as L,resolve as Ce,sep as we}from"node:path";import R from"node:process";import{fileURLToPath as Te}from"node:url";import{existsSync as z,lstatSync as Ee,mkdirSync as De,readFileSync as B,readlinkSync as Oe,realpathSync as ke,statSync as Ae,writeFileSync as je}from"node:fs";import{homedir as Me}from"node:os";import*as Ne from"node:readline";import{inspect as Pe,stripVTControlCharacters as Fe,styleText as V}from"node:util";import{AsyncLocalStorage as Ie,AsyncResource as Le}from"node:async_hooks";const Re=new Set([`emacs`,`vim`]);function ze(e){return Re.has(e)}function Be(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(ze))):[]}const H=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Ve=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,He=e=>e.name===`space`,Ue=e=>e.name===`backspace`,We=e=>`1234567890`.includes(e.name),Ge=e=>e.name===`enter`||e.name===`return`;var Ke=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},qe=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Je=class extends Error{name=`ExitPromptError`},Ye=class extends Error{name=`HookError`},Xe=class extends Error{name=`ValidationError`};const Ze=new Ie;function Qe(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function $e(e,t){let n=Qe(e);return Ze.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function U(){let e=Ze.getStore();if(!e)throw new Ye(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function et(){return U().rl}function tt(e){return Le.bind((...t)=>{let n=U(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function nt(e){let t=U(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function rt(){U().handleChange()}const W={queue(e){let t=U(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(et());if(r!=null&&typeof r!=`function`)throw new Xe(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=U();tt(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=U();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function it(e){return typeof e==`function`}function G(e){return nt(t=>{let n=Le.bind(function(e){t.get()!==e&&(t.set(e),rt())});if(t.initialized)return[t.get(),n];let r=it(e)?e():e;return t.set(r),[r,n]})}function at(e,t){nt(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&W.queue(e),n.set(t)})}function ot(){return R.platform.startsWith(`win`)?!!R.env.CI||!!R.env.WT_SESSION||!!R.env.TERMINUS_SUBLIME||R.env.ConEmuTask===`{cmd::Cmder}`||R.env.TERM_PROGRAM===`Terminus-Sublime`||R.env.TERM_PROGRAM===`vscode`||R.env.TERM===`xterm-256color`||R.env.TERM===`alacritty`||R.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:R.env.TERM!==`linux`}const st={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},ct={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},lt={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},ut={...st,...ct},dt={...st,...lt},K=ot()?ut:dt;Object.entries(ct);const ft={prefix:{idle:V(`blue`,`?`),done:V(`green`,K.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>V(`yellow`,e))},keybindings:[],style:{answer:e=>V(`cyan`,e),message:e=>V(`bold`,e),error:e=>V(`red`,`> ${e}`),defaultAnswer:e=>V(`dim`,`(${e})`),help:e=>V(`dim`,e),highlight:e=>V(`cyan`,e),key:e=>V(`cyan`,V(`bold`,`<${e}>`))}};function pt(){return{...ft,keybindings:Be()}}function mt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ht(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mt(n)&&mt(r)?ht(n,r):r}return t}function gt(...e){return ht(pt(),...e.filter(e=>e!=null))}function _t({status:e=`idle`,theme:t}){let[n,r]=G(!1),[i,a]=G(0),{prefix:o,spinner:s}=gt(t);return at(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function vt(e,t){return nt(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function yt(e){return G({current:e})[0]}function bt(e){let t=yt(e);t.current=e,at(e=>{let n=!1,r=tt((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var xt=t(n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}))(),1);const St=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Ct=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,wt=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Tt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Et=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Dt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Ot=/\t{1,1000}/y,kt=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,At=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,jt=/\p{M}+/gu,Mt={limit:1/0,ellipsis:``},Nt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Nt(i,Mt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[At,l],[Tt,0],[Et,o],[Ot,s],[kt,c],[Dt,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(jt,``)){let t=e.codePointAt(0)||0;if(S=Ct(t)?2:wt(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Dt?St(e.slice(p,n.lastIndex)):n===kt?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Pt={limit:1/0,ellipsis:``,ellipsisWidth:0},q=(e,t={})=>Nt(e,Pt,t).width,Ft=`]8;;`,It=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ft}(?<uri>.*))`,`y`),Lt=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Rt=e=>`[${e}m`,zt=e=>`${Ft}${e}`,Bt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:q(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=q(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ft,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Vt=e=>{let t=e.split(` `),n=t.length;for(;n&&!q(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ht=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=q(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=q(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Bt(s,r,t),c=q(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Bt(s,r,t),c=q(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Bt(s,r,t),c=q(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Vt(e)));let l=s.join(`
1
+ import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Y as r}from"./sleep-DVOInM4H.mjs";import{Go as i,K as a,U as o,os as s,wo as c}from"./src-Cb3i1kcm.mjs";import{$t as l,Ca as u,En as d,Fr as f,Jr as p,Lr as m,Nr as h,Pr as g,_n as _,br as v,c as y,en as b,fr as x,hn as S,l as C,mn as ee,nr as te,rr as ne,tr as re,u as ie,ur as ae,xr as oe}from"./src-q9JjDIHN.mjs";import{M as w,P as T}from"./fs-traced-DVpoNaQJ.mjs";import{_ as se,a as ce,b as E,c as le,d as ue,i as de,l as fe,o as D,r as pe,t as me,u as he,v as ge}from"./write-project-skill-DPVCl9Kv.mjs";import{i as O,n as k,o as A,r as _e,s as j,t as M}from"./colors-BsmVIwfM.mjs";import{t as ve}from"./constants-C9EGLQ-u.mjs";import{t as N}from"./is-object-ByG7RnjH.mjs";import{t as ye}from"./preview-CXrbuj-R.mjs";import{createRequire as be}from"node:module";import{execFileSync as xe}from"node:child_process";import Se,{dirname as P,isAbsolute as F,join as I,relative as L,resolve as Ce,sep as we}from"node:path";import R from"node:process";import{fileURLToPath as Te}from"node:url";import{existsSync as z,lstatSync as Ee,mkdirSync as De,readFileSync as B,readlinkSync as Oe,realpathSync as ke,statSync as Ae,writeFileSync as je}from"node:fs";import{homedir as Me}from"node:os";import*as Ne from"node:readline";import{inspect as Pe,stripVTControlCharacters as Fe,styleText as V}from"node:util";import{AsyncLocalStorage as Ie,AsyncResource as Le}from"node:async_hooks";const Re=new Set([`emacs`,`vim`]);function ze(e){return Re.has(e)}function Be(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(ze))):[]}const H=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Ve=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,He=e=>e.name===`space`,Ue=e=>e.name===`backspace`,We=e=>`1234567890`.includes(e.name),Ge=e=>e.name===`enter`||e.name===`return`;var Ke=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},qe=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Je=class extends Error{name=`ExitPromptError`},Ye=class extends Error{name=`HookError`},Xe=class extends Error{name=`ValidationError`};const Ze=new Ie;function Qe(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function $e(e,t){let n=Qe(e);return Ze.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function U(){let e=Ze.getStore();if(!e)throw new Ye(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function et(){return U().rl}function tt(e){return Le.bind((...t)=>{let n=U(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function nt(e){let t=U(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function rt(){U().handleChange()}const W={queue(e){let t=U(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(et());if(r!=null&&typeof r!=`function`)throw new Xe(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=U();tt(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=U();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function it(e){return typeof e==`function`}function G(e){return nt(t=>{let n=Le.bind(function(e){t.get()!==e&&(t.set(e),rt())});if(t.initialized)return[t.get(),n];let r=it(e)?e():e;return t.set(r),[r,n]})}function at(e,t){nt(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&W.queue(e),n.set(t)})}function ot(){return R.platform.startsWith(`win`)?!!R.env.CI||!!R.env.WT_SESSION||!!R.env.TERMINUS_SUBLIME||R.env.ConEmuTask===`{cmd::Cmder}`||R.env.TERM_PROGRAM===`Terminus-Sublime`||R.env.TERM_PROGRAM===`vscode`||R.env.TERM===`xterm-256color`||R.env.TERM===`alacritty`||R.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:R.env.TERM!==`linux`}const st={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},ct={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},lt={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},ut={...st,...ct},dt={...st,...lt},K=ot()?ut:dt;Object.entries(ct);const ft={prefix:{idle:V(`blue`,`?`),done:V(`green`,K.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>V(`yellow`,e))},keybindings:[],style:{answer:e=>V(`cyan`,e),message:e=>V(`bold`,e),error:e=>V(`red`,`> ${e}`),defaultAnswer:e=>V(`dim`,`(${e})`),help:e=>V(`dim`,e),highlight:e=>V(`cyan`,e),key:e=>V(`cyan`,V(`bold`,`<${e}>`))}};function pt(){return{...ft,keybindings:Be()}}function mt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ht(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mt(n)&&mt(r)?ht(n,r):r}return t}function gt(...e){return ht(pt(),...e.filter(e=>e!=null))}function _t({status:e=`idle`,theme:t}){let[n,r]=G(!1),[i,a]=G(0),{prefix:o,spinner:s}=gt(t);return at(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function vt(e,t){return nt(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function yt(e){return G({current:e})[0]}function bt(e){let t=yt(e);t.current=e,at(e=>{let n=!1,r=tt((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var xt=t(n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}))(),1);const St=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Ct=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,wt=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Tt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Et=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Dt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Ot=/\t{1,1000}/y,kt=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,At=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,jt=/\p{M}+/gu,Mt={limit:1/0,ellipsis:``},Nt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Nt(i,Mt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[At,l],[Tt,0],[Et,o],[Ot,s],[kt,c],[Dt,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(jt,``)){let t=e.codePointAt(0)||0;if(S=Ct(t)?2:wt(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Dt?St(e.slice(p,n.lastIndex)):n===kt?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Pt={limit:1/0,ellipsis:``,ellipsisWidth:0},q=(e,t={})=>Nt(e,Pt,t).width,Ft=`]8;;`,It=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ft}(?<uri>.*))`,`y`),Lt=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Rt=e=>`[${e}m`,zt=e=>`${Ft}${e}`,Bt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:q(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=q(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ft,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Vt=e=>{let t=e.split(` `),n=t.length;for(;n&&!q(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ht=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=q(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=q(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Bt(s,r,t),c=q(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Bt(s,r,t),c=q(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Bt(s,r,t),c=q(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Vt(e)));let l=s.join(`
2
2
  `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){It.lastIndex=e+1;let t=It.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
3
3
  `){a&&(r+=zt(``));let e=i?Lt(i):void 0;i&&e&&(r+=Rt(e))}else t===`
4
4
  `&&(i&&Lt(i)&&(r+=Rt(i)),a&&(r+=zt(a)))}return r},Ut=/\r?\n/;function Wt(e,t,n){return String(e).normalize().split(Ut).map(e=>Ht(e,t,n)).join(`
@@ -633,6 +633,6 @@ export default function okBridge(pi: {
633
633
  `));let f=`${a?``:``}${u}`;return f!==i&&T(e,f,{mode:Hn(e)}),{kind:l?`overwritten`:`written`}}const bi=e=>e!==`project`,xi=e=>e!==`user`;async function Si(){let e=await Zn({message:`Where should the MCP server be configured?
634
634
  `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Ci(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Si)():`both`}async function wi(e){return nr({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json, project skills)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function Ti(e){if(e.sharing!==void 0)return e.sharing;let t=kn(e.projectRoot)===`local-only`?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??wi)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Ei(e){if(e===void 0||e===!0)return new Set(oe);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(oe.filter(e=>t.includes(e)))}function Di(e,t,n){let r=Ce(n,e),i;try{i=Ae(r)}catch(e){let t=e.code;throw t===`ENOENT`?new $(`--content-dir path does not exist: ${r}`):new $(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new $(`--content-dir must be a directory: ${r}`);let a=L(Oi(t),Oi(r));if(a.startsWith(`..`)||F(a))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return a===``?`.`:a}function Oi(e){try{return ke(e)}catch{return e}}const ki=`open-knowledge-ui`;function Ai(e,t,n){try{return z(e.detectPath?.(t,n)??P(e.configPath(t,n)))}catch{return!1}}function ji(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0;if(!i&&s&&!Ai(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{me(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return Ni(e,o,a,n,{isProjectScope:i!==void 0});let c;try{c=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{De(P(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let l={action:`written`},u;try{w(`${o}.lock`,()=>{let t=Yr(o).writePath;if(De(P(t),{recursive:!0}),e.format===`toml`){let n=vi(ri(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=yi(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=_i(t,e.topLevelKey,a,c,e.serverMapSubKey);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){u=e instanceof Error?e:Error(String(e))}return u?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:u.message,...i===void 0?{}:{configScope:`project`}}:l.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:l.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:l.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Mi={pi:Lr};function Ni(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Mi[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{De(P(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{w(`${t}.lock`,()=>{let e=null;try{e=B(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Hn(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function Pi(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!z(n)))return{editorId:e.id,label:e.label,path:n}}function Fi(e,t,n,r){let i=Li(e,t,n,r);return i.kind===`present`?i.entry:null}function Ii(e,t,n,r){let i=gi(e,t,r);if(!N(i))return{kind:`no-entry`};let a=i[n];return N(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Li(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!z(i))return{kind:`absent`};try{if(Ae(i).size>di)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=B(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Ir(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ri().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Ii(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Cn.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Ii(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=oi(a);return s?si(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Ii(g(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ri(e={}){let t=Ce(e.cwd??process.cwd()),n=Vr(t,{homeDir:e.home}),r=n.projectRoot,i=!z(I(r,`.ok`)),a=n.gitRootPromoted?L(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:Di(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${j(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},l=await ie(r),u;try{u=S(r,{contentDir:o})}catch(t){let i=D.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let d=u.created.includes(ve),f=!1;if(l.didInit)try{f=_(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{ee(r)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore entry at ${r}: ${e instanceof Error?e.message:String(e)}`)}let p=await y(r);p.kind===`untracked`&&console.warn(`[ok] Untracked the OpenKnowledge project skill (${p.dirs.join(`, `)}) — it is now local-only. Teammates will see this as a deletion on their next pull.`);let m=await Ci({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),h=e.editors??Wi(r,e.home),g=e.editors??de.filter(e=>D[e].projectConfigPath!==void 0||D[e].projectSkillPath!==void 0),b=se(h),C=se(g),w=e.mcp===!1||m===null,T=Array.from(new Map([...b,...w?[]:C].map(e=>[e.id,e])).values()),ce=b.filter(t=>Ai(t,r,e.home)),E=[],le=[],ue=new Set;for(let t of T){if(w){let n=``;try{n=t.configPath(r,e.home)}catch{}E.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(bi(m)&&b.includes(t)&&t.scope===`global`&&E.push(ji(t,r,s,e.home)),xi(m)&&C.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=ji(t,r,s,e.home,n);E.push(i),(i.action===`written`||i.action===`overwritten`)&&ue.add(n)}}let fe=new Set;for(let t of C){let n=t.projectSkillPath?.(r);!n||fe.has(n)||(fe.add(n),le.push(pe(t,r,{home:e.home})))}let me=le.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(me.length>0){let t=e.home??Me();ne({source:c,skills:[v.project],agents:me,scope:r},{home:t,enabled:x(t).enabled})}let he=!w&&m!==null&&xi(m)?C.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ge=w?[]:ce.map(e=>Pi(e,r)).filter(e=>e!==void 0).filter(e=>!ue.has(e.path)),O=e.installUserSkill??te,k=e.home??Me(),A=Ei(e.skills),_e=!1,M=!1,N=!1,ye=!1,be=!1;for(let t of oe){if(!A.has(t))continue;await ae(k,v[t],!0).catch(()=>{}),_e=!0;let n=await O({home:e.home,bundleId:t,force:!0});n===`installed`?M=!0:n===`failed`?N=!0:n===`no-hosts`?be=!0:ye=!0}let xe=N?`failed`:M?`installed`:_e&&ye?`skip-current`:_e&&be?`no-hosts`:`declined`,Se=M?re(k).map(e=>e.editorId):[],P=w?`skipped-flag`:`skipped-missing`,F=E.find(e=>e.editorId===`claude`)??E[0]??{action:P,configPath:D.claude.configPath(r,e.home)},we=await zi({projectRoot:r,desiredMode:await Ti({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:E,projectSkills:le,legacyProjectConfigs:ge,skillInstall:xe,skillHosts:Se,didGitInit:l.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:F.action,mcpPath:F.configPath,mcpError:`error`in F?F.error:void 0,projectScopeUnsupportedLabels:he,sharing:we}}async function zi(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=kn(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=En(t);if(n===`local-only`){let e=Dn(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:Bi(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=On(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Bi(t,o,`remove`)}function Bi(e,t,n){let r=kn(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:[]}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function Vi(e){switch(e){case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;default:return`config not readable`}}function Hi(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let s=I(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(M(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(M(`Content already present at ${s}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(M(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(M(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(M(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?L(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`open-knowledge`?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${A(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${A(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${_e(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Vi(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(M(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?L(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${A(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${A(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${_e(`FAILED`)}: ${r.error}`);break}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${L(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(M(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>ce[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${A(`installed for ${r}`)}`),n.push(` ${k(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${k(`Opt out: DO_NOT_TRACK=1, or Settings → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${A(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${k(`skipped for this run (--no-skills)`)}`),n.push(` ${k(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${k(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${k(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${k(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${j(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${j(` ok repair-skills`)}`);break}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(j(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(j(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(ye(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...qi(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${A(`✓`)} ${M(`Next steps:`)}`),n.push(` 1. Open your editor (${O(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${O(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${O(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
635
635
  `)}function Ui(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function Wi(e,t){let n=[];for(let r of de)Ai(D[r],e,t)&&n.push(r);return n}function Gi(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Pe(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Ki(){return new ge(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new E(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new E(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new E(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?Gi():null;try{let r;try{r=await Ri({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof $){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof l||e instanceof b){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof C){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
636
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-Dd0F_wFU.mjs`),{resolveContentDir:s}=await import(`./src-DpX6KBvU.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-D-x1bfxi.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Ui(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Hi(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function qi(e,t){let n=[];switch(e.kind){case`applied`:return n.push(M(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${A(`local-only`)} — appended ${e.appended.length} path(s) to ${M(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${A(`local-only`)} — already excluded; nothing to do.`):n.push(` ${A(`local-only`)}`):e.action===`removed`?n.push(` ${A(`shared`)} — removed OK paths from ${M(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${A(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(j(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
636
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-CU-Nz3ee.mjs`),{resolveContentDir:s}=await import(`./src-Dn98dNdR.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-CjwSh-52.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Ui(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Hi(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function qi(e,t){let n=[];switch(e.kind){case`applied`:return n.push(M(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${A(`local-only`)} — appended ${e.appended.length} path(s) to ${M(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${A(`local-only`)} — already excluded; nothing to do.`):n.push(` ${A(`local-only`)}`):e.action===`removed`?n.push(` ${A(`shared`)} — removed OK paths from ${M(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${A(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(j(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
637
637
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${O(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(j(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${O(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${O(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(j(`Sharing mode unavailable: ${e.reason}.`));return n}}export{En as A,G as B,Zn as C,Dn as D,Un as E,Sn as F,un as I,bt as L,kn as M,jn as N,Nn as O,On as P,_t as R,nr as S,Vn as T,Ge as V,mi as _,Ui as a,Vr as b,Hi as c,Fi as d,Ei as f,Ri as g,Ti as h,zi as i,Mn as j,An as k,qi as l,Di as m,ki as n,Li as o,Ci as p,Mi as r,Wi as s,$ as t,Ki as u,ji as v,Hn as w,Fr as x,ri as y,gt as z};
638
- //# sourceMappingURL=init-DoE9fKH8.mjs.map
638
+ //# sourceMappingURL=init-8_iXriiz.mjs.map
@@ -0,0 +1 @@
1
+ import{g as e}from"./init-8_iXriiz.mjs";export{e as runInit};
@@ -1,2 +1,2 @@
1
- import{Lr as e,Pr as t}from"./src-BPPzfDas.mjs";import{P as n}from"./fs-traced-DVpoNaQJ.mjs";import{E as r,w as i}from"./init-DoE9fKH8.mjs";import{t as a}from"./is-object-ByG7RnjH.mjs";import{join as o}from"node:path";import{existsSync as s,readFileSync as c,rmSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(f){let p=o(f,`.claude`,`launch.json`);if(!s(p))return{kind:`not-present`};let m;try{m=c(p,`utf-8`)}catch{return{kind:`declined`}}let h=[],g=e(m,h,u)??void 0;if(h.some(e=>!d(e,m))||!g||g.type!==`object`)return{kind:`declined`};let _=t(g).configurations;if(!Array.isArray(_))return{kind:`not-present`};let v=_.findIndex(e=>a(e)&&e.name===`open-knowledge-ui`);if(v===-1)return{kind:`not-present`};if(_.length===1)return l(p,{force:!0}),{kind:`removed-file`};let{text:y,changed:b}=r(m,[`configurations`,v]);return b?(n(p,y,{mode:i(p)}),{kind:`removed`}):{kind:`not-present`}}export{f as t};
2
- //# sourceMappingURL=launch-json-removal--afgb0jV.mjs.map
1
+ import{Lr as e,Pr as t}from"./src-q9JjDIHN.mjs";import{P as n}from"./fs-traced-DVpoNaQJ.mjs";import{E as r,w as i}from"./init-8_iXriiz.mjs";import{t as a}from"./is-object-ByG7RnjH.mjs";import{join as o}from"node:path";import{existsSync as s,readFileSync as c,rmSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(f){let p=o(f,`.claude`,`launch.json`);if(!s(p))return{kind:`not-present`};let m;try{m=c(p,`utf-8`)}catch{return{kind:`declined`}}let h=[],g=e(m,h,u)??void 0;if(h.some(e=>!d(e,m))||!g||g.type!==`object`)return{kind:`declined`};let _=t(g).configurations;if(!Array.isArray(_))return{kind:`not-present`};let v=_.findIndex(e=>a(e)&&e.name===`open-knowledge-ui`);if(v===-1)return{kind:`not-present`};if(_.length===1)return l(p,{force:!0}),{kind:`removed-file`};let{text:y,changed:b}=r(m,[`configurations`,v]);return b?(n(p,y,{mode:i(p)}),{kind:`removed`}):{kind:`not-present`}}export{f as t};
2
+ //# sourceMappingURL=launch-json-removal-CXPn5A7N.mjs.map
@@ -1,2 +1,2 @@
1
- import{Y as e,c as t,d as n,o as r,s as i}from"./sleep-DVOInM4H.mjs";import"./src-Cb3i1kcm.mjs";import{_ as a}from"./src-BPPzfDas.mjs";import{F as o,O as s}from"./fs-traced-DVpoNaQJ.mjs";import{t as c}from"./constants-DKkdtsrQ.mjs";import{t as l}from"./is-object-ByG7RnjH.mjs";import{resolve as u}from"node:path";import{existsSync as d,readFileSync as f}from"node:fs";import{realpath as p}from"node:fs/promises";var m=e();async function h(e){let t=u(e);try{return await p(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function g(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];l(a)&&l(i)?n[r]=g(i,a):a!==void 0&&(n[r]=a)}return n}function _(e){if(!d(e))return{value:null,path:e,source:null,doc:null};let t;try{t=f(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,m.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return l(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function v(e,n){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(n.doc!==null&&n.source!==null){let e=t({file:n.path,source:n.source,doc:n.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function y(e){let t=e??process.cwd(),l=[],d=[],f=[],p=s(`user`,t),m=o({absPath:p});d.push(...m.diagnostics),!m.valid&&m.sidelinedTo!==void 0&&f.push({from:p,to:m.sidelinedTo});let h={};m.valid&&m.source!==void 0?(h=g(h,m.value),l.push(p)):m.valid;let y=u(t,`.ok`,c),b=_(y);if(b.diagnostic!==void 0&&d.push(b.diagnostic),b.value!==null){let e=r({value:b.value,file:b.path,source:b.source,doc:b.doc});d.push(...e);let t=e.length>0?i(b.value):b.value;h=g(h,t),l.push(y)}let x=a.safeParse(h);if(!x.success){let e={code:`SCHEMA_INVALID`,issues:v(x.error.issues,b)};throw Error(n(e))}return{config:x.data,sources:l,diagnostics:d,sidelined:f}}function b(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??y,r=new Map,i=new Map,a=h(e.startupCwd);return async o=>{let s=await h(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{y as n,b as t};
2
- //# sourceMappingURL=loader-C00kGDZz.mjs.map
1
+ import{Y as e,c as t,d as n,o as r,s as i}from"./sleep-DVOInM4H.mjs";import"./src-Cb3i1kcm.mjs";import{_ as a}from"./src-q9JjDIHN.mjs";import{F as o,O as s}from"./fs-traced-DVpoNaQJ.mjs";import{t as c}from"./constants-C9EGLQ-u.mjs";import{t as l}from"./is-object-ByG7RnjH.mjs";import{resolve as u}from"node:path";import{existsSync as d,readFileSync as f}from"node:fs";import{realpath as p}from"node:fs/promises";var m=e();async function h(e){let t=u(e);try{return await p(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function g(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];l(a)&&l(i)?n[r]=g(i,a):a!==void 0&&(n[r]=a)}return n}function _(e){if(!d(e))return{value:null,path:e,source:null,doc:null};let t;try{t=f(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,m.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return l(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function v(e,n){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(n.doc!==null&&n.source!==null){let e=t({file:n.path,source:n.source,doc:n.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function y(e){let t=e??process.cwd(),l=[],d=[],f=[],p=s(`user`,t),m=o({absPath:p});d.push(...m.diagnostics),!m.valid&&m.sidelinedTo!==void 0&&f.push({from:p,to:m.sidelinedTo});let h={};m.valid&&m.source!==void 0?(h=g(h,m.value),l.push(p)):m.valid;let y=u(t,`.ok`,c),b=_(y);if(b.diagnostic!==void 0&&d.push(b.diagnostic),b.value!==null){let e=r({value:b.value,file:b.path,source:b.source,doc:b.doc});d.push(...e);let t=e.length>0?i(b.value):b.value;h=g(h,t),l.push(y)}let x=a.safeParse(h);if(!x.success){let e={code:`SCHEMA_INVALID`,issues:v(x.error.issues,b)};throw Error(n(e))}return{config:x.data,sources:l,diagnostics:d,sidelined:f}}function b(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??y,r=new Map,i=new Map,a=h(e.startupCwd);return async o=>{let s=await h(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{y as n,b as t};
2
+ //# sourceMappingURL=loader-CJqV3lQK.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-CJqV3lQK.mjs";export{e as loadConfig};
@@ -1,2 +1,2 @@
1
- import{Jr as e}from"./src-BPPzfDas.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}t(process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,process.platform===`win32`?[`/c`,`start`,``,a]:[a],e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
2
- //# sourceMappingURL=open-browser-BuOrhXvS.mjs.map
1
+ import{Jr as e}from"./src-q9JjDIHN.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}t(process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,process.platform===`win32`?[`/c`,`start`,``,a]:[a],e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
2
+ //# sourceMappingURL=open-browser-Bu1KY-5f.mjs.map
@@ -1,3 +1,3 @@
1
- import{Rr as e}from"./src-BPPzfDas.mjs";import"./constants-DKkdtsrQ.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
1
+ import{Rr as e}from"./src-q9JjDIHN.mjs";import"./constants-C9EGLQ-u.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
2
2
  `)}export{c as n,l as t};
3
- //# sourceMappingURL=preview-CMjft0ek.mjs.map
3
+ //# sourceMappingURL=preview-CXrbuj-R.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-CXrbuj-R.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1,2 +1,2 @@
1
- import{t as e}from"./launch-json-removal--afgb0jV.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=e(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`||o.kind===`removed-file`;return s&&i({event:`launch-json-repair-removed`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
2
- //# sourceMappingURL=repair-launch-json-DWyYbCft.mjs.map
1
+ import{t as e}from"./launch-json-removal-CXPn5A7N.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=e(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`||o.kind===`removed-file`;return s&&i({event:`launch-json-repair-removed`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
2
+ //# sourceMappingURL=repair-launch-json-V-un1HwF.mjs.map
@@ -1,2 +1,2 @@
1
- import{i as e,o as t,p as n}from"./write-project-skill-DfjjNq9T.mjs";import{d as r,v as i}from"./init-DoE9fKH8.mjs";import{t as a}from"./mcp-migrate-event-B1gJf6bG.mjs";import{homedir as o}from"node:os";function s(n){let r=n.logger??u,i=n.home??o(),a=[];if(n.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of e){let e=t[o],s=c(()=>e.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:e,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),e.projectConfigPath){let t=e.projectConfigPath,i=c(()=>t(n.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:e,home:void 0,cwd:n.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(e){let t={scope:e.scope,editorId:e.editorId,configPath:e.configPath},o=r(e.target,e.cwd,e.home,e.configPathOverride);if(o===null)return{...t,outcome:`no-entry`};if(n(o))return{...t,outcome:`canonical`};e.logger(a({scope:e.scope,surface:`cli-repair`,editorId:e.editorId,configPath:e.configPath,priorEntry:o}));let s=i(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(s.action===`failed`){let n=s.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:n}),{...t,outcome:`write-failed`,error:n}}return s.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:s.declineReason}),{...t,outcome:`declined`}):{...t,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
- //# sourceMappingURL=repair-mcp-configs-IqhFyLaP.mjs.map
1
+ import{i as e,o as t,p as n}from"./write-project-skill-DPVCl9Kv.mjs";import{d as r,v as i}from"./init-8_iXriiz.mjs";import{t as a}from"./mcp-migrate-event-B1gJf6bG.mjs";import{homedir as o}from"node:os";function s(n){let r=n.logger??u,i=n.home??o(),a=[];if(n.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of e){let e=t[o],s=c(()=>e.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:e,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),e.projectConfigPath){let t=e.projectConfigPath,i=c(()=>t(n.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:e,home:void 0,cwd:n.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(e){let t={scope:e.scope,editorId:e.editorId,configPath:e.configPath},o=r(e.target,e.cwd,e.home,e.configPathOverride);if(o===null)return{...t,outcome:`no-entry`};if(n(o))return{...t,outcome:`canonical`};e.logger(a({scope:e.scope,surface:`cli-repair`,editorId:e.editorId,configPath:e.configPath,priorEntry:o}));let s=i(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(s.action===`failed`){let n=s.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:n}),{...t,outcome:`write-failed`,error:n}}return s.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:s.declineReason}),{...t,outcome:`declined`}):{...t,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
+ //# sourceMappingURL=repair-mcp-configs-CgS2qBwI.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./repair-skills-cQdbD3lz.mjs";export{e as repairSkills};
@@ -1,4 +1,4 @@
1
- import{R as e}from"./src-Cb3i1kcm.mjs";import{ar as t,br as n,dr as r,gr as i,lr as a,mr as o,or as s,ur as c,xr as l}from"./src-BPPzfDas.mjs";import{o as u,s as d,t as f,v as p}from"./write-project-skill-DfjjNq9T.mjs";import{n as m,s as h,t as g}from"./colors-BsmVIwfM.mjs";import{n as _,r as v,t as y}from"./skill-teardown-DzuNnHSF.mjs";import{dirname as b,join as x,relative as S,resolve as C}from"node:path";import{existsSync as w,mkdirSync as T,readFileSync as E,readdirSync as D,rmSync as O,statSync as k,writeFileSync as A}from"node:fs";import{homedir as j}from"node:os";import{createInterface as M}from"node:readline/promises";const N={existsSync:e=>w(e),isDirectory:e=>{try{return k(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>D(e),readFileSync:e=>E(e),writeFileSync:(e,t)=>{A(e,t)},mkdirSync:(e,t)=>{T(e,t)},rmSync:(e,t)=>{O(e,t)}},P={resolveProjectBundledSkillDir:()=>i(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>i(e,{checkDesktop:!1}),readBundledVersion:()=>s(),readRecordedVersion:e=>a(e,`cli-hosts`),writeRecordedVersion:(e,t)=>r(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>o(e),readBundleDecision:(e,n)=>t(e,n),writeBundleDecision:(e,t,n)=>c(e,t,n),removeBundleFromDisk:(e,t)=>v(e,t)};function F(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function I(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(b(t),{recursive:!0}),L(e,t,n)}function L(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=x(e,r),a=x(t,r);n.isDirectory(i)?L(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function R(e,t,n,r,i,a){let o=[],s=x(e,`.agents`,`skills`,t),c=!1;if(r.existsSync(s))o.push({kind:`central`,path:s,outcome:`skipped-present`});else try{I(n,s,r),c=!0,o.push({kind:`central`,path:s,outcome:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let c of d){let l=x(e,c.hostDir),u=x(l,`skills`,t);if(u===s){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(l)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(r.existsSync(u)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-present`});continue}try{I(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,error:t})}}return{entries:o,centralWritten:c}}function z(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function B(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of d){let o=x(e,t.hostDir,`skills`,`open-knowledge`),s=x(o,`SKILL.md`);if(n.existsSync(s)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`present`});continue}let c=u[t.editorId]?.projectConfigPath?.(e);if(!z(c,n)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{f(o,e),I(i,o,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`created`}),r({event:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function V(t,r,i,a){let o=e=>{r.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),c;try{c=await r.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await r.readRecordedVersion(t)}catch(e){a({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of l)try{d.push({id:e,sourceDir:r.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return a({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let o of d){let s=n[o.id],c=i.existsSync(x(t,`.agents`,`skills`,s)),l=await r.readBundleDecision(t,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{r.removeBundleFromDisk(t,o.id),a({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){a({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await r.writeBundleDecision(t,s,!0)}catch(e){a({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}p.push(o)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>i.existsSync(x(t,`.agents`,`skills`,n[e.id])));if(u!==null&&u===c&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:c}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===l.length,_=[];for(let{id:e,sourceDir:r}of p){let o=R(t,n[e],r,i,a,c);h.push(...o.entries),_.push({id:e,centralWritten:o.centralWritten})}let v=h.some(e=>e.kind===`central`&&e.outcome===`failed`);if(g&&!v){let e=null;try{await r.writeRecordedVersion(t,c),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:c})}catch(t){e=t instanceof Error?t.message:String(t),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:c,error:e})}for(let{id:t,centralWritten:n}of _)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?n?`installed`:`skip-current`:`failed`,version:c,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{let e=h.some(e=>e.kind===`host`&&e.outcome===`failed`);o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:c,reason:g?e?`all-writes-failed`:`central-write-failed`:`bundle-unresolved`})}return{outcome:`done`,version:c,entries:h}}async function H(e){let t=e.logger??F,n=e.fs??N,r=e.home??j(),i={...P,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=B(e.projectDir,i,n,t),o=await V(r,i,n,t),s=_(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=y(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function U(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function W(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
1
+ import{R as e}from"./src-Cb3i1kcm.mjs";import{ar as t,br as n,dr as r,gr as i,lr as a,mr as o,or as s,ur as c,xr as l}from"./src-q9JjDIHN.mjs";import{o as u,s as d,t as f,v as p}from"./write-project-skill-DPVCl9Kv.mjs";import{n as m,s as h,t as g}from"./colors-BsmVIwfM.mjs";import{n as _,r as v,t as y}from"./skill-teardown-BVQqx1VE.mjs";import{dirname as b,join as x,relative as S,resolve as C}from"node:path";import{existsSync as w,mkdirSync as T,readFileSync as E,readdirSync as D,rmSync as O,statSync as k,writeFileSync as A}from"node:fs";import{homedir as j}from"node:os";import{createInterface as M}from"node:readline/promises";const N={existsSync:e=>w(e),isDirectory:e=>{try{return k(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>D(e),readFileSync:e=>E(e),writeFileSync:(e,t)=>{A(e,t)},mkdirSync:(e,t)=>{T(e,t)},rmSync:(e,t)=>{O(e,t)}},P={resolveProjectBundledSkillDir:()=>i(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>i(e,{checkDesktop:!1}),readBundledVersion:()=>s(),readRecordedVersion:e=>a(e,`cli-hosts`),writeRecordedVersion:(e,t)=>r(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>o(e),readBundleDecision:(e,n)=>t(e,n),writeBundleDecision:(e,t,n)=>c(e,t,n),removeBundleFromDisk:(e,t)=>v(e,t)};function F(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function I(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(b(t),{recursive:!0}),L(e,t,n)}function L(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=x(e,r),a=x(t,r);n.isDirectory(i)?L(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function R(e,t,n,r,i,a){let o=[],s=x(e,`.agents`,`skills`,t),c=!1;if(r.existsSync(s))o.push({kind:`central`,path:s,outcome:`skipped-present`});else try{I(n,s,r),c=!0,o.push({kind:`central`,path:s,outcome:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let c of d){let l=x(e,c.hostDir),u=x(l,`skills`,t);if(u===s){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(l)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(r.existsSync(u)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-present`});continue}try{I(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,error:t})}}return{entries:o,centralWritten:c}}function z(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function B(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of d){let o=x(e,t.hostDir,`skills`,`open-knowledge`),s=x(o,`SKILL.md`);if(n.existsSync(s)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`present`});continue}let c=u[t.editorId]?.projectConfigPath?.(e);if(!z(c,n)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{f(o,e),I(i,o,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`created`}),r({event:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function V(t,r,i,a){let o=e=>{r.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),c;try{c=await r.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await r.readRecordedVersion(t)}catch(e){a({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of l)try{d.push({id:e,sourceDir:r.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return a({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let o of d){let s=n[o.id],c=i.existsSync(x(t,`.agents`,`skills`,s)),l=await r.readBundleDecision(t,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{r.removeBundleFromDisk(t,o.id),a({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){a({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await r.writeBundleDecision(t,s,!0)}catch(e){a({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}p.push(o)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>i.existsSync(x(t,`.agents`,`skills`,n[e.id])));if(u!==null&&u===c&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:c}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===l.length,_=[];for(let{id:e,sourceDir:r}of p){let o=R(t,n[e],r,i,a,c);h.push(...o.entries),_.push({id:e,centralWritten:o.centralWritten})}let v=h.some(e=>e.kind===`central`&&e.outcome===`failed`);if(g&&!v){let e=null;try{await r.writeRecordedVersion(t,c),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:c})}catch(t){e=t instanceof Error?t.message:String(t),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:c,error:e})}for(let{id:t,centralWritten:n}of _)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?n?`installed`:`skip-current`:`failed`,version:c,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{let e=h.some(e=>e.kind===`host`&&e.outcome===`failed`);o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:c,reason:g?e?`all-writes-failed`:`central-write-failed`:`bundle-unresolved`})}return{outcome:`done`,version:c,entries:h}}async function H(e){let t=e.logger??F,n=e.fs??N,r=e.home??j(),i={...P,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=B(e.projectDir,i,n,t),o=await V(r,i,n,t),s=_(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=y(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function U(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function W(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
2
2
  `)}function G(){return new p(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").option(`-y, --yes`,`Skip the confirmation prompt for removing directories left by a pre-0.42 install.`).action(async e=>{let t=await H({projectDir:C(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null,confirmLegacyCleanup:t=>K(t,{yes:e.yes===!0})});process.stdout.write(`${W(t)}\n`),process.exitCode=U(t)})}async function K(e,t){let n=j(),r=e=>`~/${S(n,e)}`,i=t.input??process.stdin,a=[``,g(`A previous version of OpenKnowledge installed its skill into agent tools you may never have used.`),m(`(Versions before 0.42 wrote to every host a third-party installer knew about — see issue #820.)`)];if(e.skillDirs.length>0&&a.push(``,`${g(`Remove OpenKnowledge skills:`)} ${e.skillDirs.length}`,...e.skillDirs.map(e=>` ${r(e)}`)),e.emptyDirs.length>0){let t=e.skillDirs.length>0?`Then remove these, which hold nothing else once the above are gone:`:`Remove these empty directories, left behind by that install:`;a.push(``,`${g(t)} ${e.emptyDirs.length}`,...e.emptyDirs.map(e=>` ${r(e)}`))}if(a.push(``,m(`Nothing outside these paths is touched. A directory that still holds anything is kept.`)),process.stdout.write(`${a.join(`
3
3
  `)}\n`),t.yes)return!0;if(!i.isTTY)return process.stdout.write(`${h("Not a terminal — skipping cleanup. Re-run with `ok repair-skills --yes` to remove these.")}\n`),!1;let o=M({input:i,output:process.stdout});try{let e=(await o.question(`\n${g(`Remove them?`)} ${m(`[y/N] `)}`)).trim().toLowerCase();return e===`y`||e===`yes`}finally{o.close()}}export{G as n,H as t};
4
- //# sourceMappingURL=repair-skills-DwcUYwoH.mjs.map
4
+ //# sourceMappingURL=repair-skills-cQdbD3lz.mjs.map
@@ -0,0 +1 @@
1
+ import{a as e,o as t,r as n}from"./server-lock-CVlhIOaP.mjs";export{n as markServerLockDraining,e as releaseServerLock,t as updateServerLockPort};
@@ -0,0 +1,2 @@
1
+ import"./src-Cb3i1kcm.mjs";import{r as e}from"./logger-DFxEUjvj.mjs";import{dirname as t,join as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d,writeSync as f}from"node:fs";import{homedir as p,hostname as m}from"node:os";import{randomUUID as h}from"node:crypto";function g(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function _(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function v(e){return new URL(e.url??``,`http://localhost`).searchParams}function y(e){let t=e?.code;return typeof t==`string`?t:void 0}const b=/^[A-Za-z0-9-]{8,64}$/;let x=null;function S(e){return n(e??p(),`.ok`,`machine-id`)}function C(n){if(n===void 0&&x!==null)return x;let r=S(n),i=null;try{let e=l(r,`utf-8`).trim();b.test(e)&&(i=e)}catch{}if(i===null){i=h();try{s(t(r),{recursive:!0}),d(r,`${i}\n`,{encoding:`utf-8`,mode:384})}catch(t){e(`machine-id`).warn({path:r,err:t},`Failed to persist ${r} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${t instanceof Error?t.message:String(t)}`)}}return n===void 0&&(x=i),i}function w(){try{let e=r(t(i(import.meta.url)),`..`,`package.json`),n=JSON.parse(l(e,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}const T=w(),E=1,D=e(`process-lock`);var O=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running at ${e.url??`port ${e.port}`} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function k(e,t){return r(e,`${t}.lock`)}const A=new Map;function j(e){A.set(e,(A.get(e)??0)+1)}function M(e){let t=A.get(e);return t===void 0||t<=1?(A.delete(e),!0):(A.set(e,t-1),!1)}function N(e){return typeof e.machineId==`string`?e.machineId===C():e.hostname===m()}const P=new Set;let F=!1;function I(e){P.add(e),!F&&(F=!0,process.on(`exit`,()=>{for(let e of P)try{let t=JSON.parse(l(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==C()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==m())continue;u(e)}catch{}}))}function L(e,t){try{let n=JSON.parse(l(e,`utf-8`));return n&&typeof n==`object`&&_(n.pid)?n:(D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null}}function R(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;s(n,{recursive:!0});let l=k(n,t),p={pid:process.pid,hostname:m(),port:r.port,...r.url!==void 0&&{url:r.url},startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:C(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??T},h=JSON.stringify(p,null,2);for(let e=0;e<3;e++){if(!o(l))try{let e=c(l,`wx`,384);try{f(e,h)}finally{a(e)}return j(l),I(l),z({lockName:t,lockDir:n,lockPath:l})}catch(e){if(y(e)!==`EEXIST`)throw e}let e=L(l,i);if(e){if(N(e)&&e.pid===process.pid)return d(l,h,{encoding:`utf-8`,mode:384}),j(l),I(l),z({lockName:t,lockDir:n,lockPath:l});if(g(e.pid))throw new O(e,l,t);D.warn({pid:e.pid,host:e.hostname},`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{u(l)}catch{}}throw Error(`${i} Failed to acquire ${l} after 3 attempts (concurrent acquire contention).`)}function z(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>q({lockName:t,lockDir:n}),updatePort:(e,r)=>H({lockName:t,lockDir:n,port:e,url:r})}}function B(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function V(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=B(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}function H(e){let{lockName:t,lockDir:n,port:r,url:i}=e,a=`[${t}-lock]`,s=k(n,t);if(!o(s)){D.warn({lockPath:s},`${a} Lock file missing at ${s} during port update — skipping`);return}let c;try{let e=JSON.parse(l(s,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:s},`${a} Corrupt lock at ${s} during port update — skipping`);return}c=e}catch{D.warn({lockPath:s},`${a} Unreadable lock at ${s} during port update — skipping`);return}if(c.pid===process.pid&&N(c)){c.port=r,i===void 0?delete c.url:c.url=i;try{d(s,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:s,err:e},`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function U(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k(n,t);if((A.get(i)??0)>1)return;let a;try{let e=JSON.parse(l(i,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:i},`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){y(e)!==`ENOENT`&&D.warn({lockPath:i,err:e},`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N(a)&&a.draining!==!0){a.draining=!0;try{d(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:i,err:e},`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function W(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return null;let i;try{let e=JSON.parse(l(r,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid))return null;i=e}catch{return null}if(!N(i))return null;if(!g(i.pid)){try{u(r)}catch{}return null}return i}function G(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return{status:`absent`};let i;try{i=JSON.parse(l(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!_(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let s={pid:a.pid,hostname:a.hostname,port:a.port,url:typeof a.url==`string`?a.url:void 0,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,capabilities:Array.isArray(a.capabilities)&&a.capabilities.every(e=>typeof e==`string`)?a.capabilities:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N(s))return{status:`stale`,lock:s};if(!g(s.pid)){try{u(r)}catch{}return{status:`stale`,lock:s}}return s.protocolVersion===void 0||s.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:s}}async function K(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>W({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function q(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){U({lockName:t,lockDir:n});return}if(o(a))try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N(e))return;u(a),P.delete(a)}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var J=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Y(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new J(e.existing,e.lockPath):e}}function X(e,t,n){H({lockName:`server`,lockDir:e,port:t,url:n})}function Z(e){return W({lockName:`server`,lockDir:e})}function Q(e,t){q({lockName:`server`,lockDir:e,...t})}function $(e){U({lockName:`server`,lockDir:e})}function ee(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,T as _,Q as a,y as b,O as c,k as d,U as f,H as g,q as h,Z as i,R as l,G as m,Y as n,X as o,W as p,$ as r,ee as s,J as t,V as u,E as v,v as x,C as y};
2
+ //# sourceMappingURL=server-lock-CVlhIOaP.mjs.map
@@ -1,2 +1,2 @@
1
- import{br as e,xr as t}from"./src-BPPzfDas.mjs";import{s as n}from"./write-project-skill-DfjjNq9T.mjs";import{dirname as r,isAbsolute as i,join as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,lstatSync as u,readdirSync as d,rmSync as f,rmdirSync as p}from"node:fs";const m=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],h=[...t.map(t=>e[t]),`open-knowledge`];function g(e){if(!i(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=s(e);if(t===c||r(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function _(e,t){let n=o(e,t);if(n.startsWith(`..`)||i(n))return!1;let r=e;for(let e of n.split(c)){r=a(r,e);try{if(!u(r).isDirectory())return!1}catch{return!1}}return!0}function v(e,t){try{return d(e).every(n=>t.has(a(e,n)))}catch{return!1}}function y(e){let t=g(e),n=[],i=[],o=new Set;for(let e of m){let s=a(t,e.hostDir,`skills`);if(!_(t,s))continue;let u=h.map(e=>a(s,e)).filter(e=>l(e));n.push(...u);for(let e of u)o.add(e);let d=a(t,e.pruneRoot),f=s;for(;v(f,o)&&(i.push(f),o.add(f),f!==d);){let e=r(f);if(e===f||e===t||!e.startsWith(t+c))break;f=e}}return{skillDirs:n,emptyDirs:i}}function b(e){try{if(!u(e).isDirectory())return!1;let t=d(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function x(e){let t=new Set,n=new Set;for(let i of m){let o=a(e,i.hostDir,`skills`);for(let e of h)t.add(a(o,e));let s=a(e,i.pruneRoot),l=o;for(;n.add(l),l!==s;){let t=r(l);if(t===l||t===e||!t.startsWith(e+c))break;l=t}}return{skillDirs:t,emptyDirs:n}}function S(e,t){let n=g(e),r=x(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(_(n,e)&&b(e))try{f(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(_(n,e))try{p(e),a.push(e)}catch{}return a}function C(r){let i=g(r),o=[];for(let r of t){let t=e[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let e of n)o.push({path:a(i,e.hostDir,`skills`,t),bundleId:r,scope:`host`,hostDir:e.hostDir})}return o}function w(e,t){let n=[];for(let r of C(e))if(r.bundleId===t)try{f(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}export{C as i,y as n,w as r,S as t};
2
- //# sourceMappingURL=skill-teardown-DzuNnHSF.mjs.map
1
+ import{br as e,xr as t}from"./src-q9JjDIHN.mjs";import{s as n}from"./write-project-skill-DPVCl9Kv.mjs";import{dirname as r,isAbsolute as i,join as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,lstatSync as u,readdirSync as d,rmSync as f,rmdirSync as p}from"node:fs";const m=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],h=[...t.map(t=>e[t]),`open-knowledge`];function g(e){if(!i(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=s(e);if(t===c||r(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function _(e,t){let n=o(e,t);if(n.startsWith(`..`)||i(n))return!1;let r=e;for(let e of n.split(c)){r=a(r,e);try{if(!u(r).isDirectory())return!1}catch{return!1}}return!0}function v(e,t){try{return d(e).every(n=>t.has(a(e,n)))}catch{return!1}}function y(e){let t=g(e),n=[],i=[],o=new Set;for(let e of m){let s=a(t,e.hostDir,`skills`);if(!_(t,s))continue;let u=h.map(e=>a(s,e)).filter(e=>l(e));n.push(...u);for(let e of u)o.add(e);let d=a(t,e.pruneRoot),f=s;for(;v(f,o)&&(i.push(f),o.add(f),f!==d);){let e=r(f);if(e===f||e===t||!e.startsWith(t+c))break;f=e}}return{skillDirs:n,emptyDirs:i}}function b(e){try{if(!u(e).isDirectory())return!1;let t=d(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function x(e){let t=new Set,n=new Set;for(let i of m){let o=a(e,i.hostDir,`skills`);for(let e of h)t.add(a(o,e));let s=a(e,i.pruneRoot),l=o;for(;n.add(l),l!==s;){let t=r(l);if(t===l||t===e||!t.startsWith(e+c))break;l=t}}return{skillDirs:t,emptyDirs:n}}function S(e,t){let n=g(e),r=x(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(_(n,e)&&b(e))try{f(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(_(n,e))try{p(e),a.push(e)}catch{}return a}function C(r){let i=g(r),o=[];for(let r of t){let t=e[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let e of n)o.push({path:a(i,e.hostDir,`skills`,t),bundleId:r,scope:`host`,hostDir:e.hostDir})}return o}function w(e,t){let n=[];for(let r of C(e))if(r.bundleId===t)try{f(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}export{C as i,y as n,w as r,S as t};
2
+ //# sourceMappingURL=skill-teardown-BVQqx1VE.mjs.map
@@ -0,0 +1 @@
1
+ import"./src-Cb3i1kcm.mjs";import"./write-project-skill-DPVCl9Kv.mjs";import"./src-Mfncsy21.mjs";import"./acp-harness-probe-DwJF1QrM.mjs";import"./init-8_iXriiz.mjs";import{n as e}from"./loader-CJqV3lQK.mjs";import"./skill-teardown-BVQqx1VE.mjs";import"./preview-CXrbuj-R.mjs";import"./mcp-migrate-event-B1gJf6bG.mjs";export{e as loadConfig};
@@ -0,0 +1 @@
1
+ import{Lo as e,P as t,Po as n,Qo as r,R as i,Ro as a,d as o,es as s,ks as c,l,us as u}from"./src-Cb3i1kcm.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Ft as W,G,Gi as K,Gn as q,Gr as J,Gt as Y,H as X,Hi as Z,Hn as Q,Hr as $,Ht as ee,I as te,Ii as ne,In as re,It as ie,J as ae,Ji as oe,Jn as se,Jr as ce,Jt as le,K as ue,Ki as de,Kn as fe,Kr as pe,Kt as me,L as he,Li as ge,Ln as _e,Lt as ve,M as ye,Mi as be,Mn as xe,Mr as Se,Mt as Ce,N as we,Ni as Te,Nn as Ee,Nt as De,O as Oe,Oi as ke,On as Ae,Or as je,Ot as Me,P as Ne,Pi as Pe,Pn as Fe,Pt as Ie,Q as Le,Qi as Re,Qn as ze,Qr as Be,Qt as Ve,R as He,Ri as Ue,Rn as We,Rr as Ge,Rt as Ke,S as qe,Si as Je,Sn as Ye,Sr as Xe,St as Ze,T as Qe,Ti as $e,Tn as et,Tr as tt,Tt as nt,U as rt,Ui as it,Un as at,Ur as ot,Ut as st,V as ct,Vi as lt,Vn as ut,Vr as dt,Vt as ft,W as pt,Wi as mt,Wn as ht,Wr as gt,Wt as _t,X as vt,Xi as yt,Xn as bt,Xr as xt,Xt as St,Y as Ct,Yi as wt,Yn as Tt,Yr as Et,Yt as Dt,Z as Ot,Zi as kt,Zn as At,Zr as jt,Zt as Mt,_ as Nt,_a as Pt,_i as Ft,_n as It,_r as Lt,_t as Rt,a as zt,aa as Bt,ai as Vt,an as Ht,ar as Ut,at as Wt,b as Gt,ba as Kt,bi as qt,bn as Jt,br as Yt,bt as Xt,c as Zt,ca as Qt,ci as $t,cn as en,cr as tn,d as nn,da as rn,di as an,dn as on,dr as sn,ea as cn,ei as ln,en as un,er as dn,et as fn,f as pn,fa as mn,fi as hn,fn as gn,fr as _n,g as vn,ga as yn,gi as bn,gn as xn,gr as Sn,gt as Cn,h as wn,ha as Tn,hi as En,hn as Dn,hr as On,ht as kn,i as An,ia as jn,ii as Mn,in as Nn,ir as Pn,it as Fn,j as In,ji as Ln,jn as Rn,jr as zn,jt as Bn,k as Vn,ki as Hn,kn as Un,kr as Wn,kt as Gn,l as Kn,la as qn,li as Jn,ln as Yn,lr as Xn,m as Zn,ma as Qn,mi as $n,mn as er,mr as tr,mt as nr,n as rr,na as ir,ni as ar,nn as or,nr as sr,nt as cr,o as lr,oa as ur,oi as dr,on as fr,or as pr,ot as mr,p as hr,pa as gr,pi as _r,pn as vr,pr as yr,q as br,qi as xr,qn as Sr,qr as Cr,qt as wr,r as Tr,ra as Er,ri as Dr,rn as Or,rr as kr,rt as Ar,s as jr,sa as Mr,si as Nr,sn as Pr,sr as Fr,st as Ir,t as Lr,ta as Rr,ti as zr,tn as Br,tr as Vr,tt as Hr,u as Ur,ua as Wr,ui as Gr,un as Kr,ur as qr,v as Jr,va as Yr,vn as Xr,vr as Zr,vt as Qr,w as $r,wi as ei,wn as ti,wr as ni,wt as ri,x as ii,xi as ai,xn as oi,xr as si,xt as ci,y as li,ya as ui,yi as di,yn as fi,yr as pi,yt as mi,z as hi,zi as gi,zn as _i,zr as vi,zt as yi}from"./src-q9JjDIHN.mjs";import{C as bi,E as xi,T as Si,_ as Ci,b as wi,c as Ti,d as Ei,g as Di,i as Oi,l as ki,m as Ai,n as ji,p as Mi,s as Ni,t as Pi,u as Fi,v as Ii,w as Li,x as Ri,y as zi}from"./fs-traced-DVpoNaQJ.mjs";import{a as Bi,d as Vi,f as Hi,i as Ui,l as Wi,n as Gi,r as Ki,t as qi,u as Ji}from"./logger-DFxEUjvj.mjs";import{C as Yi,S as Xi,_ as Zi,a as Qi,c as $i,d as ea,g as ta,h as na,i as ra,l as ia,m as aa,n as oa,o as sa,p as ca,r as la,s as ua,t as da,u as fa,v as pa,y as ma}from"./server-lock-CVlhIOaP.mjs";export{rn as AGENT_ID_MAX_LEN,mn as AGENT_ID_RE,M as AGENT_WRITE_ORIGIN,Yr as AcpPermissionStore,Tn as AcpRegistry,Je as AcpThreadManager,qt as AgentFocusBroadcaster,di as AgentPresenceBroadcaster,ke as AgentSessionCapacityError,Hn as AgentSessionManager,kn as AutoStartDisabledError,Zr as BUNDLE_IDS,pi as BUNDLE_SCOPE,Yt as BUNDLE_SKILL_NAME,Sr as BacklinkIndex,gi as CC1Broadcaster,s as CC1_CONTRACT_VERSION,Kr as CONFIG_FILENAME,ut as CONFLICT_MARKER_RE,w as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Nt as ConfigSchema,K as DEFAULT_CHECKPOINT_RETENTION,Vt as DEFAULT_EMBEDDINGS_DIMENSIONS,W as DEFAULT_PACK_ID,ct as DocumentDurabilityState,dr as EMBEDDINGS_API_KEY_ENV,yn as FEATURED_AGENT_IDS,de as FILE_SYSTEM_WRITER,q as FILE_WATCHER_ORIGIN,m as FileEmbeddingsBackend,Mt as GIT_PREFLIGHT_FAIL_SPAN_NAME,xr as GIT_UPSTREAM_WRITER,ui as GitDirAccessError,h as GitNotAvailableError,un as GitTooOldError,Cn as HOCUSPOCUS_AUTH_REJECTION_REASONS,Rt as HocuspocusAuthRejection,Qr as HocuspocusAuthTokenSchema,pe as INSTALLED_AGENTS_SCHEMES,r as LINEAGE_EPOCH_KEY,He as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ie as LOG_MD_TEMPLATE,nt as MANAGED_RENAME_ORIGIN,D as MAX_ACP_THREADS,_ as MAX_AGENT_SESSIONS,$e as MCP_CONNECTION_ID_HEADER,n as MCP_SERVER_NAME,Ln as MIN_EVICTABLE_IDLE_MS,Br as MIN_GIT_VERSION,X as MISSING_OK_CONFIG_MESSAGE,Kt as MalformedGitPointerError,fn as McpLogger,rt as MissingOkConfigError,Te as OBSERVER_SYNC_ORIGIN,on as OK_OKIGNORE_TEMPLATE,e as ORPHAN_MODES,c as PROTOCOL_VERSION,qi as PinoLogger,$i as ProcessLockCollisionError,Kn as ProjectGitInitError,B as ROLLBACK_ORIGIN,gn as ROOT_GITIGNORE_TEMPLATE,Zi as RUNTIME_VERSION,fi as RemoteConfigError,oe as SERVICE_WRITER,yr as SKILL_INSTALL_EVENTS_FILE_REL,t as SKILL_STATE_TARGETS,ve as STARTER_FOLDERS,Ke as STARTER_FOLDER_FRONTMATTER_FILENAME,yi as STARTER_PACKS,T as STARTER_PACK_IDS,ft as STARTER_TEMPLATES,Qe as STATE_MANIFEST_FILENAME,pa as STATE_SCHEMA_VERSION,u as SYSTEM_DOC_NAME,wr as SeedPrerequisiteError,le as SeedRootDirError,da as ServerLockCollisionError,Lr as SingleFileNotAFileError,rr as SingleFileNotFoundError,Tr as SingleFileNotMarkdownError,I as StateManifestError,fe as TagIndex,si as USER_GLOBAL_BUNDLE_IDS,Tt as UiLockCollisionError,F as __getShowAllWalkStatsForTesting,Me as __resetShowAllWalkStatsForTesting,ia as acquireProcessLock,oa as acquireServerLock,bt as acquireUiLock,be as applyAgentMarkdownWrite,_i as applyExternalChange,Ie as applySeed,j as assertCompatibleStateManifest,or as assertGitAvailable,N as assertNeverDiskEvent,ai as attachAcpThreadSocket,nr as attachIdleShutdown,Jr as bootServer,dn as buildAndOpenSkill,vr as buildConfigYmlContent,Ct as buildExecResult,ei as buildOkMcpStdioCommand,On as buildSkillZip,ee as buildStarterFolderFrontmatterYaml,wt as buildWipTree,Xe as bundleSkillMdPath,ln as canonicalProjectKey,Ae as classifyEvents,Pi as classifyFsPath,zr as clearAllEmbeddingsKeys,$t as clearContributors,st as coercePackId,l as colorFromSeed,yt as commitUpstreamImport,kt as commitWip,Re as commitWipFromTree,Or as compareSemver,tt as composeEffectiveLinterConfig,z as composeFrontmatterSchemasConfig,Q as containsConflictMarkers,Un as contentHash,Jn as contributorCount,Ne as countShadowObjects,V as countStaleAgentWipRefs,te as countWipRefs,Gn as createApiExtension,ri as createAssetServeMiddleware,G as createCollaborationHost,Ge as createContentFilter,vi as createContentFilterAsync,ar as createEmbeddingsSecretStore,An as createEphemeralProjectDir,C as createExternalChangeHandler,pn as createFileLogger,hi as createLiveDerivedIndexExtension,br as createMcpHttpHandler,Cr as createOsProbe,we as createPersistenceExtension,E as createServer,In as createServerObserverExtension,ne as createStreamingErrorWriter,Gi as createTestLogger,Dr as describeStoredEmbeddingsKey,vn as detectClaudeDesktopPresence,Nn as detectGit,Oe as detectProjectShape,Vr as detectUserSkillHosts,Ar as discoverLockDirs,Wn as discoverMarkdownlintConfig,Ve as emitPreflightFailureSpan,vt as encodeDocName,Ot as encodeFolderRoute,Le as encodeSkillRoute,Ur as ensureProjectGit,er as ensureProjectSkillGitignore,ge as errorResponse,v as evictStaleTrackerEntries,b as extractHeadings,Fn as extractOkBinaryPath,se as extractWikiLinksFromMarkdown,Ht as fallbackPaths,nn as findEnclosingGitRoot,et as findEnclosingProjectRoot,y as findNativeMarkdownlintFile,hr as flushFileLogger,mi as formatAuthRejectionWire,Gr as formatContributors,an as formatContributorsFrom,Ce as formatPackRationale,f as gcCheckpointRefs,Hr as getCurrentMcpLogger,En as getLocalDir,Zn as getLogFilePath,Ki as getLogger,wn as getLogsDir,ma as getMachineId,zi as getMeter,ur as getMetrics,wi as getTracer,Mr as handleCollabSocketError,dt as handleSpawnCursor,Jt as hasForwardingHeaders,he as hasGcLogLatch,o as iconFromClientName,Qt as incrementCollabSocketFilteredError,qn as incrementServerObserverFire,Dn as initContent,cn as initShadowRepo,Ri as initTelemetry,Gt as initToleranceTelemetryWriter,Ir as installPrettyZodErrors,Ui as installTestLoggers,sr as installUserSkill,Xr as isAllowedApiOrigin,O as isAllowedWorkspaceHostHeader,S as isConfigDoc,Xt as isHocuspocusAuthRejectionReason,_t as isKnownPackId,lt as isLinkIndexExcludedDoc,ti as isLoopbackAddress,Z as isManagedArtifactDoc,a as isOrphanMode,Pe as isPairedWriteOrigin,$ as isPathWithinDir,Xi as isProcessAlive,R as isProjectRoot,oi as isRemoteAdmitted,it as isReservedForUserTree,Rn as isSelfWrite,mt as isSystemDoc,ii as isToleranceTelemetryEnabled,Yi as isValidLockPid,xe as lastKnownHash,Rr as listRescueCheckpoints,Y as listStarterPacks,Pt as loadCustomAgents,ye as loadPrincipal,fa as lockBaseUrl,ea as lockFilePath,Bi as loggerFactory,Wi as logsCurrentPath,Ji as logsPreviousPath,Mn as makeLazyEmbeddingsKeyStore,la as markServerLockDraining,pt as mountMcpAndApi,ji as normalizeFsPath,k as originGitHubHost,xn as packageVersionMajorMinor,ci as parseAuthRejectionWire,fr as parseGitVersion,Ze as parseHocuspocusAuthToken,ue as parseKeepaliveConnectionId,Ee as pathToDocName,De as planSeed,zt as prepareSingleFileOpen,Wt as processCommand,mr as processUsage,Pn as readAllTargets,Ut as readBundleDecision,zn as readOwnNativeRules,ca as readProcessLock,aa as readProcessLockDetailed,x as readProjectHeadState,Be as readProjectLocalSemanticConfig,ra as readServerLock,pr as readServerPackageVersion,Fr as readSkillInstallStateSnapshot,Vn as readStateManifest,tn as readTargetRecordedAt,Xn as readTargetVersion,At as readUiLock,at as reconcile,hn as recordContributor,tr as recordSkillInstallEvent,ae as registerAllTools,Fe as registerWrite,na as releaseProcessLock,Qi as releaseServerLock,ze as releaseUiLock,U as removeLastKnownHash,kr as reportSkillInstall,Wr as resetMetrics,i as resolveBundleEnabled,Sn as resolveBundledSkillDir,bn as resolveContentDir,ot as resolveCursorBinaryDefault,gt as resolveCursorSpawnInvocation,P as resolveEffectiveLinterConfig,Nr as resolveEmbeddingsCredential,Ft as resolveLockDir,je as resolveNativeConfigForDoc,Se as resolveNativeMarkdownlintConfig,me as resolvePack,jr as resolvePackageVersion,Ye as resolveRemoteAccess,_n as resolveSkillInstallReportSettings,d as resolveUiInfo,_r as restoreContributors,li as restoreLifecycleFromConflictsJson,xt as rewriteMarkdownLinksForDocumentRename,jt as rewriteWikiLinksForDocumentRename,Pr as runAuthReposSubprocess,en as runAuthStatusSubprocess,Dt as runCloneSubprocess,Yn as runDeviceFlowSubprocess,cr as runWithMcpLogger,Et as safeContentPath,Bn as safeSubdir,ir as safetyCheckpoint,L as sanitizeClientName,Er as saveInMemoryCheckpoint,jn as saveVersion,A as seedBasenameIndex,lr as serializeError,bi as setActiveSpanAttributes,H as setupServerObservers,Bt as shadowGit,Li as shutdownTelemetry,Vi as spansCurrentPath,Hi as spansPreviousPath,J as spawnDetached,ht as splitMarkdownBlocks,re as startWatcher,Ue as streamingProblemEvent,$n as swapContributors,qe as teardownToleranceTelemetryWriter,gr as toBroadcasterKey,Oi as tracedAppendFileSync,Ni as tracedLinkSync,Ti as tracedMkdir,ki as tracedMkdirSync,Fi as tracedRename,Ei as tracedRenameSync,Mi as tracedRmSync,Ai as tracedRmdirSync,Di as tracedUnlinkSync,Ci as tracedWriteFile,Ii as tracedWriteFileSync,$r as trustSystemCertificates,Zt as untrackTrackedProjectSkillProjection,_e as updateLastKnownHash,ta as updateProcessLockPort,sa as updateServerLockPort,p as updateUiLockPort,Qn as validateAgentId,St as validateCloneInputs,Lt as validateSkillZip,ua as waitForServerLockDrain,ce as withHiddenWindowsConsole,Si as withSpan,xi as withSpanSync,qr as writeBundleDecision,ni as writeMarkdownlintRule,It as writeRootGitignoreForNewRepo,g as writeStateManifest,sn as writeTargetVersion,We as writeTracker};