@inkeep/open-knowledge 0.28.2-beta.0 → 0.28.2-beta.2

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 (35) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +63 -63
  4. package/dist/constants-Ci-kZ4dC.mjs +2 -0
  5. package/dist/dist-72is7jRd.mjs +1 -0
  6. package/dist/{dist-DoDyZNhy.mjs → dist-BVDj7oJZ.mjs} +2 -2
  7. package/dist/index.mjs +1 -1
  8. package/dist/init-CFmo3Akq.mjs +1 -0
  9. package/dist/init-DWNXfQas.mjs +690 -0
  10. package/dist/{loader-CCBLjGdd.mjs → loader-DkWp7bnK.mjs} +2 -2
  11. package/dist/loader-Dnf_1ZEG.mjs +1 -0
  12. package/dist/open-browser-R_RWX931.mjs +2 -0
  13. package/dist/{preview-BlnBnAM8.mjs → preview-9zw2bHty.mjs} +2 -2
  14. package/dist/preview-DKPvMlKb.mjs +1 -0
  15. package/dist/public/assets/{index-kyv4JIfm.js → index-C2Aa_HrU.js} +2 -2
  16. package/dist/public/index.html +1 -1
  17. package/dist/{repair-launch-json-Drx8-mQf.mjs → repair-launch-json-BZa1WVbN.mjs} +2 -2
  18. package/dist/{repair-mcp-configs-D32OvX6A.mjs → repair-mcp-configs-B1R2_B6E.mjs} +2 -2
  19. package/dist/{repair-skills-DE-X6nG_.mjs → repair-skills-B_aLnXpL.mjs} +2 -2
  20. package/dist/repair-skills-D_mTmSrp.mjs +1 -0
  21. package/dist/{src-BJDidJ1C.mjs → src-mUcDJN0F.mjs} +2 -2
  22. package/dist/start-BshFMALS.mjs +1 -0
  23. package/dist/start-Df010qkz.mjs +3 -0
  24. package/dist/{write-project-skill-CrjKr8MO.mjs → write-project-skill-ClrMnKU-.mjs} +2 -2
  25. package/package.json +1 -1
  26. package/dist/constants-BvUE6Mu8.mjs +0 -2
  27. package/dist/dist-Bc_bWnDQ.mjs +0 -1
  28. package/dist/init-C5xydBwk.mjs +0 -686
  29. package/dist/init-COp9NFui.mjs +0 -1
  30. package/dist/loader-DsrSOTpM.mjs +0 -1
  31. package/dist/open-browser-DHTbHSqx.mjs +0 -2
  32. package/dist/preview-BbnP_W-F.mjs +0 -1
  33. package/dist/repair-skills-BQUSwi1N.mjs +0 -1
  34. package/dist/start-Bu74oLD_.mjs +0 -1
  35. package/dist/start-DOCYHCeK.mjs +0 -3
@@ -48,7 +48,7 @@
48
48
  -->
49
49
  <script>(() => { let t = 'system'; try { const r = localStorage.getItem('ok-theme-v1'); if (r === 'light' || r === 'dark' || r === 'system') t = r; } catch {} let dark = t === 'dark'; if (t === 'system') { try { dark = window.matchMedia('(prefers-color-scheme: dark)').matches; } catch {} } if (dark) document.documentElement.classList.add('dark'); if (window.okDesktop) document.documentElement.classList.add('electron-mode'); })();</script>
50
50
  <style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
51
- <script type="module" crossorigin src="./assets/index-kyv4JIfm.js"></script>
51
+ <script type="module" crossorigin src="./assets/index-C2Aa_HrU.js"></script>
52
52
  <link rel="modulepreload" crossorigin href="./assets/chunk-CFjPhJqf.js">
53
53
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-2ej06EnG.js">
54
54
  <link rel="modulepreload" crossorigin href="./assets/w3c-keyname-CHcJEDvG.js">
@@ -1,2 +1,2 @@
1
- import{S as e,r as t}from"./init-C5xydBwk.mjs";import{t as n}from"./is-object-Cg453afR.mjs";import{join as r}from"node:path";import{existsSync as i,readFileSync as a}from"node:fs";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],t];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`powershell`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[3];if(typeof t==`string`){if(t.includes(`# ok-ui-win-v1`))return`canonical`;if(/# ok-ui-win-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))return`legacy-bare`}return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(t){let o=t.logger??u,c=r(t.projectDir,`.claude`,`launch.json`);if(t.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!i(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=a(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=e(t.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
2
- //# sourceMappingURL=repair-launch-json-Drx8-mQf.mjs.map
1
+ import{S as e,r as t}from"./init-DWNXfQas.mjs";import{t as n}from"./is-object-Cg453afR.mjs";import{join as r}from"node:path";import{existsSync as i,readFileSync as a}from"node:fs";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],t];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`powershell`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[3];if(typeof t==`string`){if(t.includes(`# ok-ui-win-v1`))return`canonical`;if(/# ok-ui-win-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))return`legacy-bare`}return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(t){let o=t.logger??u,c=r(t.projectDir,`.claude`,`launch.json`);if(t.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!i(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=a(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=e(t.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
2
+ //# sourceMappingURL=repair-launch-json-BZa1WVbN.mjs.map
@@ -1,2 +1,2 @@
1
- import{g as e,w as t}from"./init-C5xydBwk.mjs";import{_ as n,d as r,s as i}from"./write-project-skill-CrjKr8MO.mjs";import{t as a}from"./mcp-migrate-event-D0NrGjvc.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,n=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of i){let i=r[o],s=c(()=>i.configPath(``,n));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:i,home:n,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),i.projectConfigPath){let n=i.projectConfigPath,r=c(()=>n(e.projectDir));r!==null&&a.push(l({scope:`project`,editorId:o,target:i,home:void 0,cwd:e.projectDir,configPath:r,configPathOverride:r,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(r){let i={scope:r.scope,editorId:r.editorId,configPath:r.configPath},o=e(r.target,r.cwd,r.home,r.configPathOverride);if(o===null)return{...i,outcome:`no-entry`};if(n(o))return{...i,outcome:`canonical`};r.logger(a({scope:r.scope,surface:`cli-repair`,editorId:r.editorId,configPath:r.configPath,priorEntry:o}));let s=t(r.target,r.cwd,{mode:`published`,skipAvailabilityCheck:!0},r.home,r.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return r.logger({event:`mcp-config-repair-write-failed`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,error:e}),{...i,outcome:`write-failed`,error:e}}return s.action===`declined`?(r.logger({event:`mcp-config-repair-declined`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,reason:s.declineReason}),{...i,outcome:`declined`}):{...i,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
- //# sourceMappingURL=repair-mcp-configs-D32OvX6A.mjs.map
1
+ import{g as e,w as t}from"./init-DWNXfQas.mjs";import{_ as n,d as r,s as i}from"./write-project-skill-ClrMnKU-.mjs";import{t as a}from"./mcp-migrate-event-D0NrGjvc.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,n=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of i){let i=r[o],s=c(()=>i.configPath(``,n));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:i,home:n,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),i.projectConfigPath){let n=i.projectConfigPath,r=c(()=>n(e.projectDir));r!==null&&a.push(l({scope:`project`,editorId:o,target:i,home:void 0,cwd:e.projectDir,configPath:r,configPathOverride:r,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(r){let i={scope:r.scope,editorId:r.editorId,configPath:r.configPath},o=e(r.target,r.cwd,r.home,r.configPathOverride);if(o===null)return{...i,outcome:`no-entry`};if(n(o))return{...i,outcome:`canonical`};r.logger(a({scope:r.scope,surface:`cli-repair`,editorId:r.editorId,configPath:r.configPath,priorEntry:o}));let s=t(r.target,r.cwd,{mode:`published`,skipAvailabilityCheck:!0},r.home,r.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return r.logger({event:`mcp-config-repair-write-failed`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,error:e}),{...i,outcome:`write-failed`,error:e}}return s.action===`declined`?(r.logger({event:`mcp-config-repair-declined`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,reason:s.declineReason}),{...i,outcome:`declined`}):{...i,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
+ //# sourceMappingURL=repair-mcp-configs-B1R2_B6E.mjs.map
@@ -1,3 +1,3 @@
1
- import{ua as e}from"./server-lock-iLcBw_q0-pnLGEjec.mjs";import{Jr as t,Lr as n,Wr as r,d as i,ei as a,ra as o,sa as s,ut as c,zr as l}from"./dist-DoDyZNhy.mjs";import{t as u}from"./esm-CsQUg9js.mjs";import{a as d,d as f,f as p,t as m}from"./write-project-skill-CrjKr8MO.mjs";import{dirname as h,join as g,resolve as _}from"node:path";import{homedir as v}from"node:os";import{existsSync as y,mkdirSync as b,readFileSync as x,readdirSync as S,rmSync as C,statSync as w,writeFileSync as T}from"node:fs";const E={existsSync:e=>y(e),isDirectory:e=>{try{return w(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>S(e),readFileSync:e=>x(e),writeFileSync:(e,t)=>{T(e,t)},mkdirSync:(e,t)=>{b(e,t)},rmSync:(e,t)=>{C(e,t)}},D={resolveProjectBundledSkillDir:()=>a(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>a(e,{checkDesktop:!1}),readBundledVersion:()=>l(),readRecordedVersion:e=>r(e,`cli-hosts`),writeRecordedVersion:(e,t)=>s(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>t(e),readBundleDecision:(e,t)=>n(e,t),writeBundleDecision:(e,t,n)=>o(e,t,n),removeBundleFromDisk:(e,t)=>d(e,t)};function O(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function k(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(h(t),{recursive:!0}),A(e,t,n)}function A(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=g(e,r),a=g(t,r);n.isDirectory(i)?A(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function j(e,t,n,r,i,a){let o=[],s=g(e,`.agents`,`skills`,t),c=r.existsSync(s),l=!1;try{k(n,s,r),l=!0,o.push({kind:`central`,path:s,outcome:c?`overwritten`:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:c,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 p){let l=g(e,c.hostDir),u=g(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}let d=r.existsSync(u);try{k(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:d?`overwritten`:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:d,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:l}}function M(e,t){if(!e)return!1;try{if(!t.existsSync(e))return!1;let n=t.readFileSync(e).toString(`utf8`);return n.includes(`# ok-mcp-v1`)||n.includes(`# ok-mcp-win-v1`)}catch{return!1}}function N(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 p){let o=g(e,t.hostDir,`skills`,`open-knowledge`),s=g(o,`SKILL.md`),c=n.existsSync(s),l=f[t.editorId]?.projectConfigPath?.(e),u=!c&&M(l,n);if(!c&&!u){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{m(o,e),k(i,o,n);let s=c?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:c?`project-skill-reclaim-reclaimed`:`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 P(t,n,r,a){let o=e=>{n.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),l;try{l=await n.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 n.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 c)try{d.push({id:e,sourceDir:n.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=i[o.id],c=r.existsSync(g(t,`.agents`,`skills`,s)),l=await n.readBundleDecision(t,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{n.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 n.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=>r.existsSync(g(t,`.agents`,`skills`,i[e.id])));if(u!==null&&u===l&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:l}),{outcome:`skipped`,reason:`version-current`};let h=[],_=d.length===c.length,v=!0;for(let{id:e,sourceDir:n}of p){let o=j(t,i[e],n,r,a,l);h.push(...o.entries),o.centralWritten||(v=!1)}let y=h.some(e=>e.kind===`central`&&(e.outcome===`written`||e.outcome===`overwritten`));if(_&&v&&y){let e=null;try{await n.writeRecordedVersion(t,l),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:l})}catch(t){e=t instanceof Error?t.message:String(t),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:l,error:e})}for(let{id:t}of p)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?`installed`:`failed`,version:l,...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:l,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:l,entries:h}}async function F(e){let t=e.logger??O,n=e.fs??E,r=e.home??v(),i={...D,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:N(e.projectDir,i,n,t),user:await P(r,i,n,t)}}function I(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 L(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===`reclaimed`).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} reclaimed, ${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`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
1
+ import{ua as e}from"./server-lock-iLcBw_q0-pnLGEjec.mjs";import{Jr as t,Lr as n,Wr as r,ca as i,d as a,ei as o,ia as s,ut as c,zr as l}from"./dist-BVDj7oJZ.mjs";import{t as u}from"./esm-CsQUg9js.mjs";import{a as d,d as f,f as p,t as m}from"./write-project-skill-ClrMnKU-.mjs";import{dirname as h,join as g,resolve as _}from"node:path";import{homedir as v}from"node:os";import{existsSync as y,mkdirSync as b,readFileSync as x,readdirSync as S,rmSync as C,statSync as w,writeFileSync as T}from"node:fs";const E={existsSync:e=>y(e),isDirectory:e=>{try{return w(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>S(e),readFileSync:e=>x(e),writeFileSync:(e,t)=>{T(e,t)},mkdirSync:(e,t)=>{b(e,t)},rmSync:(e,t)=>{C(e,t)}},D={resolveProjectBundledSkillDir:()=>o(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>o(e,{checkDesktop:!1}),readBundledVersion:()=>l(),readRecordedVersion:e=>r(e,`cli-hosts`),writeRecordedVersion:(e,t)=>i(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>t(e),readBundleDecision:(e,t)=>n(e,t),writeBundleDecision:(e,t,n)=>s(e,t,n),removeBundleFromDisk:(e,t)=>d(e,t)};function O(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function k(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(h(t),{recursive:!0}),A(e,t,n)}function A(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=g(e,r),a=g(t,r);n.isDirectory(i)?A(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function j(e,t,n,r,i,a){let o=[],s=g(e,`.agents`,`skills`,t),c=r.existsSync(s),l=!1;try{k(n,s,r),l=!0,o.push({kind:`central`,path:s,outcome:c?`overwritten`:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:c,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 p){let l=g(e,c.hostDir),u=g(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}let d=r.existsSync(u);try{k(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:d?`overwritten`:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:d,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:l}}function M(e,t){if(!e)return!1;try{if(!t.existsSync(e))return!1;let n=t.readFileSync(e).toString(`utf8`);return n.includes(`# ok-mcp-v1`)||n.includes(`# ok-mcp-win-v1`)}catch{return!1}}function N(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 p){let o=g(e,t.hostDir,`skills`,`open-knowledge`),s=g(o,`SKILL.md`),c=n.existsSync(s),l=f[t.editorId]?.projectConfigPath?.(e),u=!c&&M(l,n);if(!c&&!u){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{m(o,e),k(i,o,n);let s=c?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:c?`project-skill-reclaim-reclaimed`:`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 P(t,n,r,i){let o=e=>{n.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),l;try{l=await n.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return i({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 n.readRecordedVersion(t)}catch(e){i({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 c)try{d.push({id:e,sourceDir:n.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return i({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=a[o.id],c=r.existsSync(g(t,`.agents`,`skills`,s)),l=await n.readBundleDecision(t,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{n.removeBundleFromDisk(t,o.id),i({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){i({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 n.writeBundleDecision(t,s,!0)}catch(e){i({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=>r.existsSync(g(t,`.agents`,`skills`,a[e.id])));if(u!==null&&u===l&&m)return i({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:l}),{outcome:`skipped`,reason:`version-current`};let h=[],_=d.length===c.length,v=!0;for(let{id:e,sourceDir:n}of p){let o=j(t,a[e],n,r,i,l);h.push(...o.entries),o.centralWritten||(v=!1)}let y=h.some(e=>e.kind===`central`&&(e.outcome===`written`||e.outcome===`overwritten`));if(_&&v&&y){let e=null;try{await n.writeRecordedVersion(t,l),i({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:l})}catch(t){e=t instanceof Error?t.message:String(t),i({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:l,error:e})}for(let{id:t}of p)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?`installed`:`failed`,version:l,...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:l,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:l,entries:h}}async function F(e){let t=e.logger??O,n=e.fs??E,r=e.home??v(),i={...D,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:N(e.projectDir,i,n,t),user:await P(r,i,n,t)}}function I(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 L(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===`reclaimed`).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} reclaimed, ${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`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
2
2
  `)}function R(){return new u(`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.").action(async()=>{let e=await F({projectDir:_(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${L(e)}\n`),process.exitCode=I(e)})}export{R as n,F as t};
3
- //# sourceMappingURL=repair-skills-DE-X6nG_.mjs.map
3
+ //# sourceMappingURL=repair-skills-B_aLnXpL.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./repair-skills-B_aLnXpL.mjs";export{e as repairSkills};
@@ -1,7 +1,7 @@
1
- import{s as e}from"./chunk-C94x7I9S.mjs";import{c as t,l as n,s as r,u as i}from"./server-lock-iLcBw_q0-pnLGEjec.mjs";import{Mr as a,Nr as o,Tn as s,ha as c,ii as l,pn as u,xn as d}from"./dist-DoDyZNhy.mjs";import{t as f}from"./esm-CsQUg9js.mjs";import"./gh-detect-RYp8nY6_.mjs";import{C as ee,D as p,M as m,N as h,S as te,d as g,j as _,k as v,w as y}from"./init-C5xydBwk.mjs";import{_ as ne,d as re,i as ie,v as ae}from"./write-project-skill-CrjKr8MO.mjs";import"./loader-CCBLjGdd.mjs";import{c as oe}from"./colors-8SzMRIVy.mjs";import"./preview-BlnBnAM8.mjs";import{dirname as se,isAbsolute as b,join as x,relative as S,resolve as C}from"node:path";import{hostname as w}from"node:os";import{existsSync as T,lstatSync as E,readFileSync as D,readlinkSync as ce,rmSync as le,statSync as ue}from"node:fs";import{readFile as O,realpath as k}from"node:fs/promises";function A(e,a,o={}){let s=i(e,a);if(!T(s))return{status:`missing`,lockPath:s};let c;try{c=JSON.parse(D(s,`utf-8`))}catch{return{status:`corrupt`,lockPath:s}}if(!c||typeof c!=`object`||!n(c.pid))return{status:`corrupt`,lockPath:s};let l=c;if(!(o.isAlive??t)(l.pid))return{status:`dead-pid`,lockPath:s,lock:l};if(typeof l.machineId==`string`)return l.machineId===(o.machineId??r())?{status:`alive`,lockPath:s,lock:l}:{status:`foreign-host`,lockPath:s,lock:l};let u=o.host??w();return l.hostname===u?{status:`alive`,lockPath:s,lock:l}:{status:`foreign-host`,lockPath:s,lock:l}}function j(e){return e.replace(/:\d+$/,``)}function M(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:j(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:j(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:j(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function N(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function P(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function F(e){let t=N(e);if(t)return{kind:`doc`,...t};let n=P(e);return n?{kind:`folder`,...n}:null}const I=`# >>> open-knowledge cli >>>`,L=`# <<< open-knowledge cli <<<`,R=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function z(e){return x(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const B={existsSync:e=>T(e),readFileSync:(e,t)=>D(e,t),lstatSync:e=>E(e),readlinkSync:e=>ce(e)};function V(e,t=B){let n=z(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function H(e){let t=e.replace(R,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function U(e,t,n=B){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function de(e){return ne(e)||ae(e)||v(e)}function fe(e,t,n,r){let i=g(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!de(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(le(a,{force:!0}),{kind:`removed`}):e.format===`toml`?me(a,o):pe(a,e.topLevelKey,e.serverMapSubKey,o)}function pe(e,t,n,r){let i;try{i=D(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>10485760)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=h(i,ee(t,n,r));return o?(c(e,a,{mode:_(e)}),{kind:`removed`}):{kind:`not-present`}}function me(e,t){let n=p();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=D(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=m(a),s=a.trim()===``||a.endsWith(`
1
+ import{s as e}from"./chunk-C94x7I9S.mjs";import{c as t,l as n,s as r,u as i}from"./server-lock-iLcBw_q0-pnLGEjec.mjs";import{Mr as a,Nr as o,Tn as s,ga as c,ii as l,pn as u,xn as d}from"./dist-BVDj7oJZ.mjs";import{t as f}from"./esm-CsQUg9js.mjs";import"./gh-detect-RYp8nY6_.mjs";import{C as ee,D as p,M as m,N as h,S as te,d as g,j as _,k as v,w as y}from"./init-DWNXfQas.mjs";import{_ as ne,d as re,i as ie,v as ae}from"./write-project-skill-ClrMnKU-.mjs";import"./loader-DkWp7bnK.mjs";import{c as oe}from"./colors-8SzMRIVy.mjs";import"./preview-9zw2bHty.mjs";import{dirname as se,isAbsolute as b,join as x,relative as S,resolve as C}from"node:path";import{hostname as w}from"node:os";import{existsSync as T,lstatSync as E,readFileSync as D,readlinkSync as ce,rmSync as le,statSync as ue}from"node:fs";import{readFile as O,realpath as k}from"node:fs/promises";function A(e,a,o={}){let s=i(e,a);if(!T(s))return{status:`missing`,lockPath:s};let c;try{c=JSON.parse(D(s,`utf-8`))}catch{return{status:`corrupt`,lockPath:s}}if(!c||typeof c!=`object`||!n(c.pid))return{status:`corrupt`,lockPath:s};let l=c;if(!(o.isAlive??t)(l.pid))return{status:`dead-pid`,lockPath:s,lock:l};if(typeof l.machineId==`string`)return l.machineId===(o.machineId??r())?{status:`alive`,lockPath:s,lock:l}:{status:`foreign-host`,lockPath:s,lock:l};let u=o.host??w();return l.hostname===u?{status:`alive`,lockPath:s,lock:l}:{status:`foreign-host`,lockPath:s,lock:l}}function j(e){return e.replace(/:\d+$/,``)}function M(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:j(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:j(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:j(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function N(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function P(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function F(e){let t=N(e);if(t)return{kind:`doc`,...t};let n=P(e);return n?{kind:`folder`,...n}:null}const I=`# >>> open-knowledge cli >>>`,L=`# <<< open-knowledge cli <<<`,R=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function z(e){return x(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const B={existsSync:e=>T(e),readFileSync:(e,t)=>D(e,t),lstatSync:e=>E(e),readlinkSync:e=>ce(e)};function V(e,t=B){let n=z(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function H(e){let t=e.replace(R,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function U(e,t,n=B){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function de(e){return ne(e)||ae(e)||v(e)}function fe(e,t,n,r){let i=g(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!de(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(le(a,{force:!0}),{kind:`removed`}):e.format===`toml`?me(a,o):pe(a,e.topLevelKey,e.serverMapSubKey,o)}function pe(e,t,n,r){let i;try{i=D(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>10485760)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=h(i,ee(t,n,r));return o?(c(e,a,{mode:_(e)}),{kind:`removed`}):{kind:`not-present`}}function me(e,t){let n=p();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=D(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=m(a),s=a.trim()===``||a.endsWith(`
2
2
  `),l;try{l=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!l.existed)return{kind:`not-present`};let u=l.text;s?u.endsWith(`
3
3
  `)||(u=`${u}\n`):u=u.replace(/\n+$/,``),o&&(u=u.replace(/\r\n/g,`
4
4
  `).replace(/\n/g,`\r
5
5
  `));let d=`${i?``:``}${u}`;return d!==r&&c(e,d,{mode:_(e)}),{kind:`removed`}}const he=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`deinit`]);function ge(e,t,n=s){if(e!==void 0&&!he.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let W=null;function _e(e){W=e}function G(){return W??process.cwd()}var K=e(oe(),1);function ve(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function ye(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function be(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:d(r),command:r,isDesktop:ve(r)}}function xe(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&xe(e)?`ui-orphan`:`stale`}const Se=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function Ce(e){switch(e){case`running`:return K.default.green(e);case`desktop`:return K.default.blue(e);case`foreign`:return K.default.cyan(e);case`ui-orphan`:return K.default.magenta(e);case`stale`:return K.default.yellow(e)}}function J(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function we(e){return`${J(e.server.usage)} | ${J(e.ui?.usage??null)}`}function Te(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function Ee(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,Te(e),we(e),t,String(n),ye(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=Ce(q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=K.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
6
6
  `)}async function Y(e={}){let t=e.discover??u,n=e.inspect??A,r=e.log??(e=>console.log(e)),i=e.resolveCommand??a,s=e.resolveUsage??o,c=await t(),l=[];for(let e of c){let t=n(e,`server`),r=n(e,`ui`),a=be(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:s(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:s(r.lock.pid));a!=null&&l.push(a)}if(e.json){let e=l.map(e=>({...e,displayStatus:q(e)}));r(JSON.stringify(e,null,2));return}r(Ee(e.all?l:l.filter(e=>Se.has(q(e)))))}function De(){return new f(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await Y({all:t.all===!0||e===`all`,json:t.json===!0})})}function Oe(e,n,r={}){let i=r.isAlive??t,a=[];for(let[t,r]of[[`server`,e],[`ui`,n]])(r.status===`alive`||r.status===`foreign-host`&&i(r.lock.pid))&&a.push({name:t,pid:r.lock.pid,port:r.lock.port});return{targets:a}}function X(e){let t=e.inspect??(t=>A(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=Oe(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function Z(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function ke(e,n=t){let r=await u(),i=null;for(let t of r){let r=A(t,`server`),a=A(t,`ui`);if(Z(r,n)&&r.lock.port===e||Z(a,n)&&a.lock.port===e)return t;i===null&&(Z(r,n)&&r.lock.pid===e||Z(a,n)&&a.lock.pid===e)&&(i=t)}return i}function Q(e){let t=X({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Ae(e){return new f(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async n=>{let r=n.length===0?void 0:n.join(` `);if(r===void 0){e();let t=X({lockDir:l(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await Y({});return}if(r===`all`){let e=await u();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let n=0;for(let r of e){let e=A(r,`server`),i=A(r,`ui`);!Z(e,t)&&!Z(i,t)||(Q(r),n++)}n===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(r)){let e=Number.parseInt(r,10),t=await ke(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Q(t);return}Q(l(C(G(),r)))})}function je(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Me(e,t){let n,r;try{n=await k(C(e)),r=await k(C(se(e)))}catch{return{kind:`not-git`}}if(!$(n,r))return{kind:`symlink-escape`};let i=x(n,`.git`),a;try{a=ue(i)}catch{return{kind:`not-git`}}let o;if(a.isDirectory()){let e;try{e=await k(i)}catch{return{kind:`not-git`}}if(!$(e,n))return{kind:`symlink-escape`};o=e}else if(a.isFile()){let e;try{e=await O(i,`utf-8`)}catch{return{kind:`not-git`}}let t=/^gitdir:\s*(.+)$/m.exec(e.trim());if(!t)return{kind:`not-git`};let r=t[1].trim(),a=b(r)?r:C(n,r);try{o=await k(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=x(await Ne(o),`config`),c;try{c=await O(s,`utf-8`)}catch{return{kind:`not-git`}}let l=Fe(c);if(l===null)return{kind:`no-origin`};let u=M(l);if(u===null||u.hostname!==`github.com`)return{kind:`non-github`};let d=u.owner.toLowerCase()===t.owner.toLowerCase(),f=u.name.toLowerCase()===t.repo.toLowerCase();return!d||!f?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://github.com/${u.owner}/${u.name}.git`}}async function Ne(e){let t;try{t=(await O(x(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=b(t)?t:C(e,t);try{return await k(n)}catch{return n}}function $(e,t){if(e===t)return!0;let n=S(t,e);return n.length>0&&!n.startsWith(`..`)&&!b(n)}function Pe(e){let t=e.indexOf(`#`),n=e.indexOf(`;`),r=-1;return t>=0&&n>=0?r=Math.min(t,n):t>=0?r=t:n>=0&&(r=n),(r===-1?e:e.slice(0,r)).trim()}function Fe(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=Pe(n);if(e.length===0)continue;if(e.startsWith(`[`)){t=/^\[\s*remote\s+["']origin["']\s*\]$/.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/.exec(e);if(r)return Ie(r[1])}return null}function Ie(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const Le=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=y(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let n=ie(e,t);return{integration:`project-skill`,editorId:e.id,action:n.action,...n.path?{path:n.path}:{},...n.error?{error:n.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function Re(e,t,n={},r=Le){let i=[];for(let a of t){let t=re[a];for(let a of r)i.push(a.write(t,e,n))}return i}function ze(e,t,n={}){return{integrations:Re(e,t,n),claudeLaunchJson:t.includes(`claude`)?te(e,n):void 0}}export{N as _,Ae as a,M as b,ge as c,R as d,L as f,H as g,V as h,X as i,fe as l,z as m,Me as n,De as o,U as p,je as r,_e as s,ze as t,I as u,F as v,A as x,P as y};
7
- //# sourceMappingURL=src-BJDidJ1C.mjs.map
7
+ //# sourceMappingURL=src-mUcDJN0F.mjs.map
@@ -0,0 +1 @@
1
+ import{_ as e,f as t,r as n}from"./start-Df010qkz.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};
@@ -0,0 +1,3 @@
1
+ import{Mn as e,ht as t}from"./server-lock-iLcBw_q0-pnLGEjec.mjs";import{cr as n,jr as r,xr as i}from"./dist-BVDj7oJZ.mjs";import{n as a,t as o}from"./esm-CsQUg9js.mjs";import{i as s,t as c}from"./gh-detect-RYp8nY6_.mjs";import{n as l}from"./constants-Ci-kZ4dC.mjs";import{spawn as u}from"node:child_process";import{basename as d,dirname as f,join as p}from"node:path";import{homedir as m}from"node:os";import{closeSync as h,existsSync as g,mkdirSync as _,openSync as v,statSync as y}from"node:fs";import{rm as b}from"node:fs/promises";import{setTimeout as x}from"node:timers/promises";const S=`OpenKnowledge.app`,C=`/Applications/${S}`;function w(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return y(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function T(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(E(e,C))return C;let t=p(e.homeDir??m(),`Applications`,S);return E(e,t)?t:null}function E(e,t){try{let n=p(t,`Contents`,`MacOS`,`OpenKnowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function D(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`)return{available:!1,reason:`darwin-only`};let t;try{t=T(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:e.isTTY!==!0||e.env.SSH_CONNECTION||e.env.SSH_TTY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function O(e){(e.log??(e=>console.error(e)))("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)");let t={...process.env};delete t.ELECTRON_RUN_AS_NODE,e.spawn(`open`,[`-b`,`com.inkeep.open-knowledge`],{detached:!0,stdio:`ignore`,env:t}).unref()}function k(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${C}. Install via DMG, or omit --mode for browser mode.`;case`darwin-only`:return`Desktop app is macOS-only on this release. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect desktop bundle at ${C} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${C} but launch dispatch did not fire (caller bug).`}}function A(e){return p(f(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const j=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function M(e){if(e.platform!==`darwin`||!j.test(e.execPath))return null;let t=A(e.execPath);return e.exists(t)?t:null}function N(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??g,a=r[1];return a?{command:M({execPath:t,platform:n,exists:i})??t,prefixArgs:[a]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(r)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function P(e,t){return e.host??t.HOST??`127.0.0.1`}function F(e){let t=d(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var I=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function L(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function R(t){g(t.lockDir)||_(t.lockDir,{recursive:!0});let n=v(p(t.lockDir,e),`w`),r=t.spawn??u,{PORT:i,...a}=process.env,o=N();try{let e=r(o.command,[...o.prefixArgs,...t.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:t.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return e.unref(),e}finally{try{h(n)}catch{}}}function z(e,t,n){return e??(n===void 0?t:void 0)}function B(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function V(e,t,n){return e??(t!=null&&!n?1:0)}async function H(e){let t=e.spawn??u,n=N(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=V(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function U(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}const W=t;function G(e,t,n=e=>b(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function K(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:i?1:0,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(i?1:0)}}}function q(e){let t=e.sigtermGraceMs??W,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>x(e));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function J(e){let{config:t,cwd:a,host:o}=e,l=e.skipAutoInit??!1,u=e.skipUiAutoSpawn??!1,d=e.idleThresholdMs??18e5,{existsSync:f,mkdirSync:p}=await import(`node:fs`),{basename:m,dirname:h}=await import(`node:path`),{bootServer:g,getLogger:_,isProcessAlive:v,readUiLock:y,resolveContentDir:b,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./dist-72is7jRd.mjs`),w=e.log??_(`start`),T=e.singleFile!==void 0,E=e.projectDir??a,D=T?r(e.singleFile).canonicalFilePath:void 0,O=D?h(D):void 0,k=D?m(D):void 0;if(!T){if(!l&&!n(a))throw new I(a);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&w.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-B1R2_B6E.mjs`)).repairMcpConfigs)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-BZa1WVbN.mjs`)).repairLaunchJson)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-D_mTmSrp.mjs`)).repairSkills)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let A=O??b(t,a);!T&&!f(A)&&(p(A,{recursive:!0}),w.info({contentDir:A},`Created content directory`));let j=null,M=async({lockDir:t})=>{if(j=L({uiLock:y(t),isAlive:v}),j.action===`spawn`&&!u)try{let n=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];R({lockDir:t,cwd:a,spawn:e.spawn,args:n}),w.info({reason:j.reason,uiPort:e.uiPort},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else j.action===`skip`&&w.info({port:j.port,pid:j.pid},`UI already running at port ${j.port}`)},N=e.reactShellDistDir===void 0,P=s(),F=i();{let e=S(T?E:a),t=Date.now(),n=await C(e);n!==`no-drain`&&w.info({event:`start-waited-for-draining-predecessor`,outcome:n,waitedMs:Date.now()-t,drainLockDir:e},n===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let z=await g({config:t,contentDir:A,projectDir:T?E:a,contentRoot:T?void 0:t.content.dir,port:e.port,host:o,quiet:!1,detectGh:c,tokenStore:P,embeddingsKeyStore:F,...T?{ephemeral:!0,singleDocRelPath:k,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:N,idleShutdownMs:d,skipAutoInit:!0,...N?{spawnUiSiblingFn:M}:{},idleShutdownHandler:t=>{let n=q({readUiLock:()=>y(z.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:w});return K(T?G(n,E):n,{log:w,exit:e.idleExit})},log:w,...e.serveContentAssets?{serveContentAssets:!0}:{},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});j||={action:`skip`,reason:`alive`,pid:0,port:0};let B=j,V=null;if(B.action===`skip`)V=B.port>0?B.port:null;else if(!u){let t=e.uiBindTimeoutMs??3e3;V=await U({readUiLock:()=>y(z.lockDir),now:Date.now,sleep:e=>x(e),timeoutMs:t,pollIntervalMs:50}),V===null&&w.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:z.httpServer,destroy:z.destroy,lockDir:z.lockDir,contentDir:A,port:z.port,ready:z.ready,degraded:z.degraded,uiSpawnDecision:j,resolvedUiPort:V}}function ee(e){if(e===`browser`||e===`app`)return e;throw new a(`--mode must be 'browser' or 'app'`)}function te(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new a(`--ui-port must be a port number between 1 and 65535`);return t}function Y(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function X(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Z(e,t){let n=Y(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner-BxCFCyu8.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-CmkIIbww.mjs`),c=process.cwd(),u=e;process.title=F(c);let d=P(t,process.env),f=t.port===void 0?void 0:Number(t.port),p=process.env.PORT?Number(process.env.PORT):void 0,m=t.uiPort===void 0?void 0:Number(t.uiPort),h=z(f,p,m);if(m!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./dist-72is7jRd.mjs`);if(B(m,e(t(c)))){await H({cwd:c,uiPort:m});return}}let g;try{g=await J({config:u,cwd:c,host:d,port:h,...m===void 0?{}:{uiPort:m},...t.serveContentAssets?{serveContentAssets:!0}:{},...t.reactShellDistDir?{reactShellDistDir:t.reactShellDistDir}:{},...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{}})}catch(e){e instanceof I&&(console.error(o(e.message)),process.exit(1));let t=await import(`./dist-72is7jRd.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(o(e.message)),process.exit(1)),m!==void 0&&Q(e,t)){await H({cwd:c,uiPort:m});return}let n=$(e,c,t);n!==null&&(console.error(o(n)),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let _=!1,v=async e=>{if(_)return;_=!0;let[t,...n]=X(e);console.log(i(`\n${t}`));for(let e of n)console.log(a(` ${e}`));try{await g.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{v(`SIGINT`)}),process.once(`SIGTERM`,()=>{v(`SIGTERM`)});let y=`http://${d}:${g.port}`,b=d===`0.0.0.0`||d===`::`?`http://0.0.0.0:${g.port}`:void 0,x=g.resolvedUiPort,S=x!==null&&x>0?`http://${d}:${x}`:y;console.log(r({name:`open-knowledge`,version:l,localUrl:S,apiUrl:S===y?void 0:y,networkUrl:b,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let C={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};g.ready.then(async()=>{if(g.degraded.length>0){console.log();for(let e of g.degraded){let t=C[e]??`${e} (check server logs for details)`;console.warn(` ${s(`⚠`)} ${s(e)}: ${a(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-R_RWX931.mjs`);e(S)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function Q(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function $(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=p(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`OpenKnowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function ne(e){return new o(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`--ui-port <port>`,`Pin the ok ui sibling to <port> and connect (not exit) if a server already runs here — the worktree-preview recipe path`,te).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ee).option(`--serve-content-assets`,`Serve content assets from this server`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path> (suppresses ok ui sibling)`).option(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).option(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
2
+ `),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.uiPort!==void 0&&e.push(`--ui-port`),t.host!==void 0&&e.push(`--host`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=D(w());if(n.available){O({spawn:u});return}console.error(k(n.reason)),process.exit(1)}await Z(n,t)})}export{D as C,w as S,ne as _,V as a,K as b,F as c,z as d,P as f,R as g,B as h,q as i,X as l,Z as m,U as n,H as o,Y as p,J as r,L as s,I as t,Q as u,$ as v,O as w,N as x,G as y};
3
+ //# sourceMappingURL=start-Df010qkz.mjs.map
@@ -1,4 +1,4 @@
1
- import{It as e,S as t,an as n,wt as r}from"./server-lock-iLcBw_q0-pnLGEjec.mjs";import{d as i,ei as a,ut as o}from"./dist-DoDyZNhy.mjs";import{basename as s,dirname as c,isAbsolute as l,join as u,posix as d,relative as f,resolve as p,sep as m,win32 as h}from"node:path";import{homedir as g}from"node:os";import{cpSync as _,existsSync as v,lstatSync as ee,mkdirSync as y,realpathSync as b,rmSync as x}from"node:fs";const S=t,C=r,w=e,T=`node`,E={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},D=`# ok-mcp-v1`,O=`# ok-mcp-v1
1
+ import{It as e,S as t,an as n,wt as r}from"./server-lock-iLcBw_q0-pnLGEjec.mjs";import{d as i,ei as a,ut as o}from"./dist-BVDj7oJZ.mjs";import{basename as s,dirname as c,isAbsolute as l,join as u,posix as d,relative as f,resolve as p,sep as m,win32 as h}from"node:path";import{homedir as g}from"node:os";import{cpSync as _,existsSync as v,lstatSync as ee,mkdirSync as y,realpathSync as b,rmSync as x}from"node:fs";const S=t,C=r,w=e,T=`node`,E={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},D=`# ok-mcp-v1`,O=`# ok-mcp-v1
2
2
  USER_BUNDLE="$HOME/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
3
3
  [ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
4
4
  BUNDLE="/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
@@ -33,4 +33,4 @@ foreach ($d in $dirs) {
33
33
  }
34
34
  [Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
35
35
  exit 127`,A=`// ok-pi-bridge`,j=`${A}-v1`,M=`ok-pi-managed-extension`;function N(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v1`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v1`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(j)}return!1}function P(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=p(e);if(s(t)===`cli.mjs`&&s(c(t))===`dist`)return t;let n=t.split(m),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return u(i.length===0?m:i.join(m),`packages`,`cli`,`dist`,`cli.mjs`)}function F(e={}){return e.mode===`dev`?{command:T,args:[P(),`mcp`],env:{...E}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,k]}:{command:`/bin/sh`,args:[`-l`,`-c`,O]}}function ne(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[T,P(),`mcp`],environment:{...E}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,k]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,O]}}function re(e){if(typeof e!=`object`||!e)return!1;let t=e;return I(t,F({mode:`published`,platformName:`darwin`}))||I(t,F({mode:`published`,platformName:`win32`}))}function I(e,t){if(Object.keys(e).length!==Object.keys(t).length||e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function L(e){return e===`win32`?h:d}function R(e={}){let t=e.platformName??process.platform,n=e.home??g(),r=e.env??process.env,i=L(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function z(e={}){let t=e.platformName??process.platform,n=e.home??g();return L(t).join(n,`.claude.json`)}function B(e={}){let t=e.platformName??process.platform,n=e.home??g(),r=e.env??process.env;if(t===`darwin`)return d.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??h.join(n,`AppData`,`Roaming`);return h.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function V(e={}){let t=e.platformName??process.platform,n=e.home??g();return L(t).join(n,`.cursor`,`mcp.json`)}function H(e={}){let t=e.platformName??process.platform,n=e.home??g();return(e.env??process.env).CODEX_HOME??L(t).join(n,`.codex`)}function U(e={}){return L(e.platformName??process.platform).join(H(e),`config.toml`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??g(),r=e.env??process.env,i=L(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function G(e={}){return L(e.platformName??process.platform).join(W(e),`opencode.json`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??g();return L(t).join(n,`.openclaw`,`openclaw.json`)}function q(e={}){let t=e.platformName??process.platform,n=e.home??g();return(e.env??process.env).PI_CODING_AGENT_DIR??L(t).join(n,`.pi`,`agent`)}const J={claude:{id:`claude`,label:C.claude,configPath:(e,t)=>z({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>F(t),scope:`global`,detectPath:(e,t)=>u(t??g(),`.claude`),projectConfigPath:e=>u(e,`.mcp.json`),projectSkillPath:e=>u(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:C[`claude-desktop`],configPath:(e,t)=>B({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>F(t),scope:`global`,detectPath:(e,t)=>c(B({home:t}))},cursor:{id:`cursor`,label:C.cursor,configPath:(e,t)=>V({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>F(t),scope:`global`,detectPath:(e,t)=>c(V({home:t})),projectConfigPath:e=>u(e,`.cursor`,`mcp.json`),projectSkillPath:e=>u(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:C.codex,configPath:(e,t)=>U({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>n,buildEntry:(e,t)=>F(t),scope:`global`,detectPath:(e,t)=>c(U({home:t})),projectConfigPath:e=>u(e,`.codex`,`config.toml`),projectSkillPath:e=>u(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:C.opencode,configPath:(e,t)=>G({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>n,buildEntry:(e,t)=>ne(t),scope:`global`,detectPath:(e,t)=>c(G({home:t})),projectConfigPath:e=>u(e,`opencode.json`),projectSkillPath:e=>u(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:C.openclaw,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>n,buildEntry:(e,t)=>F(t),scope:`global`,detectPath:(e,t)=>u(t??g(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:C.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>q({home:t}),projectConfigPath:e=>u(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>u(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)}};function Y(e){let t=e.filter(e=>!Object.hasOwn(J,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${S.join(`, `)}`);return e.map(e=>J[e])}function X(e){let t=[];for(let n of o){let r=i[n];t.push({path:u(e,`.agents`,`skills`,r),bundleId:n,scope:`central`});for(let i of w)t.push({path:u(e,i.hostDir,`skills`,r),bundleId:n,scope:`host`,hostDir:i.hostDir})}return t}function ie(e,t){let n=[];for(let r of X(e))if(r.bundleId===t)try{x(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}`)}function Z(e,t){let n;try{n=ee(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);$(e,t)}function Q(e,t){$(e,t)}function $(e,t){let n;try{n=b(t)}catch{n=p(t)}let r=c(e);for(;r.length>1&&r!==m;){let t;try{t=b(r)}catch(e){if(e.code===`ENOENT`){r=c(r);continue}throw e}let i=f(n,t);if(i===``||!i.startsWith(`..`)&&!l(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function ae(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=a(`project`,{checkDesktop:!0}),i=c(n);Z(i,t);let o=v(n)?`overwritten`:`written`;return x(i,{recursive:!0,force:!0}),y(c(i),{recursive:!0}),_(r,i,{recursive:!0}),{editorId:e.id,label:e.label,action:o,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function oe(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=c(n);return v(n)?(Q(r,t),x(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}export{N as _,ie as a,P as b,D as c,J as d,w as f,F as g,M as h,ae as i,te as l,j as m,Q as n,X as o,A as p,oe as r,S as s,Z as t,C as u,re as v,Y as x,R as y};
36
- //# sourceMappingURL=write-project-skill-CrjKr8MO.mjs.map
36
+ //# sourceMappingURL=write-project-skill-ClrMnKU-.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/open-knowledge",
3
- "version": "0.28.2-beta.0",
3
+ "version": "0.28.2-beta.2",
4
4
  "license": "GPL-3.0-or-later",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- import"./server-lock-iLcBw_q0-pnLGEjec.mjs";var e=`0.28.2-beta.0`;const t=`config.yml`,n=e;export{n,t};
2
- //# sourceMappingURL=constants-BvUE6Mu8.mjs.map
@@ -1 +0,0 @@
1
- import{Fi as e,Gt as t,Hi as n,Pn as r,Q as i,_ as a,a as o,an as s,b as c,c as l,di as u,f as d,g as f,gn as p,h as m,i as h,kn as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,ua as E,un as D,v as O,y as k}from"./server-lock-iLcBw_q0-pnLGEjec.mjs";import{$ as A,$i as j,$n as M,$r as N,$t as P,A as F,Ai as I,An as L,Ar as R,At as z,B,Bi as V,Bn as H,Br as U,Bt as W,C as G,Ci as K,Cn as q,Cr as J,Ct as Y,D as X,Di as Z,Dn as Q,Dr as $,Dt as ee,E as te,Ei as ne,En as re,Er as ie,Et as ae,F as oe,Fi as se,Fn as ce,Fr as le,Ft as ue,G as de,Gi as fe,Gn as pe,Gr as me,Gt as he,H as ge,Hi as _e,Hn as ve,Hr as ye,Ht as be,I as xe,Ii as Se,In as Ce,Ir as we,It as Te,J as Ee,Ji as De,Jn as Oe,Jr as ke,Jt as Ae,K as je,Ki as Me,Kn as Ne,Kr as Pe,Kt as Fe,L as Ie,Li as Le,Ln as Re,Lr as ze,Lt as Be,M as Ve,Mi as He,Mn as Ue,Mr as We,Mt as Ge,N as Ke,Ni as qe,Nn as Je,Nr as Ye,Nt as Xe,O as Ze,Oi as Qe,On as $e,Or as et,Ot as tt,P as nt,Pi as rt,Pn as it,Pr as at,Pt as ot,Q as st,Qi as ct,Qn as lt,Qr as ut,Qt as dt,R as ft,Ri as pt,Rn as mt,Rr as ht,Rt as gt,S as _t,Si as vt,Sn as yt,Sr as bt,St as xt,T as St,Ti as Ct,Tn as wt,Tr as Tt,Tt as Et,U as Dt,Ui as Ot,Un as kt,Ur as At,Ut as jt,V as Mt,Vi as Nt,Vn as Pt,Vr as Ft,Vt as It,W as Lt,Wi as Rt,Wn as zt,Wr as Bt,Wt as Vt,X as Ht,Xi as Ut,Xn as Wt,Xr as Gt,Xt as Kt,Y as qt,Yi as Jt,Yn as Yt,Yr as Xt,Yt as Zt,Z as Qt,Zi as $t,Zn as en,Zr as tn,Zt as nn,_ as rn,_i as an,_n as on,_r as sn,_t as cn,a as ln,aa as un,ai as dn,an as fn,ar as pn,at as mn,b as hn,ba as gn,bi as _n,bn as vn,br as yn,bt as bn,c as xn,ca as Sn,ci as Cn,cn as wn,cr as Tn,ct as En,d as Dn,di as On,dn as kn,dr as An,dt as jn,ea as Mn,ei as Nn,en as Pn,er as Fn,et as In,f as Ln,fi as Rn,fn as zn,fr as Bn,ft as Vn,g as Hn,gi as Un,gn as Wn,gr as Gn,gt as Kn,h as qn,hi as Jn,hn as Yn,hr as Xn,ht as Zn,i as Qn,ia as $n,ii as er,in as tr,ir as nr,it as rr,j as ir,ji as ar,jn as or,jr as sr,jt as cr,k as lr,ki as ur,kn as dr,kr as fr,kt as pr,l as mr,li as hr,ln as gr,lr as _r,lt as vr,m as yr,mi as br,mn as xr,mr as Sr,mt as Cr,n as wr,na as Tr,ni as Er,nn as Dr,nr as Or,nt as kr,o as Ar,oa as jr,oi as Mr,on as Nr,or as Pr,ot as Fr,p as Ir,pi as Lr,pn as Rr,pr as zr,pt as Br,q as Vr,qi as Hr,qn as Ur,qr as Wr,qt as Gr,r as Kr,ra as qr,ri as Jr,rn as Yr,rr as Xr,rt as Zr,s as Qr,sa as $r,si as ei,sn as ti,sr as ni,st as ri,t as ii,ta as ai,ti as oi,tn as si,tr as ci,tt as li,u as ui,ui as di,un as fi,ur as pi,ut as mi,v as hi,vi as gi,vn as _i,vr as vi,vt as yi,w as bi,wi as xi,wn as Si,wr as Ci,wt as wi,x as Ti,xa as Ei,xi as Di,xn as Oi,xr as ki,xt as Ai,y as ji,yi as Mi,yn as Ni,yr as Pi,yt as Fi,z as Ii,zi as Li,zn as Ri,zr as zi,zt as Bi}from"./dist-DoDyZNhy.mjs";export{ii as AGENT_ID_MAX_LEN,wr as AGENT_ID_RE,Kr as AGENT_WRITE_ORIGIN,Qn as AgentFocusBroadcaster,ln as AgentPresenceBroadcaster,Ar as AgentSessionCapacityError,Qr as AgentSessionManager,xn as AutoStartDisabledError,mr as BUNDLE_IDS,ui as BUNDLE_SCOPE,Dn as BUNDLE_SKILL_NAME,Ln as BacklinkIndex,Ir as CC1Broadcaster,i as CC1_CONTRACT_VERSION,yr as CONFIG_FILENAME,qn as CONFLICT_MARKER_RE,Hn as CURSOR_BUNDLE_PATHS_BY_PLATFORM,rn as ConfigSchema,hi as DEFAULT_CHECKPOINT_RETENTION,ji as DEFAULT_EMBEDDINGS_DIMENSIONS,hn as DEFAULT_PACK_ID,Ti as EMBEDDINGS_API_KEY_ENV,_t as FILE_SYSTEM_WRITER,G as FILE_WATCHER_ORIGIN,bi as FileEmbeddingsBackend,St as GIT_PREFLIGHT_FAIL_SPAN_NAME,te as GIT_UPSTREAM_WRITER,gn as GitDirAccessError,X as GitNotAvailableError,Ze as GitTooOldError,lr as HOCUSPOCUS_AUTH_REJECTION_REASONS,F as HocuspocusAuthRejection,ir as HocuspocusAuthTokenSchema,Ve as INSTALLED_AGENTS_SCHEMES,t as LINEAGE_EPOCH_KEY,Ke as LIVE_DERIVED_INDEX_DEBOUNCE_MS,nt as LOG_MD_TEMPLATE,oe as MANAGED_RENAME_ORIGIN,xe as MAX_AGENT_SESSIONS,Ie as MCP_CONNECTION_ID_HEADER,s as MCP_SERVER_NAME,ft as MIN_GIT_VERSION,Ii as MISSING_OK_CONFIG_MESSAGE,Ei as MalformedGitPointerError,B as McpLogger,Mt as MissingOkConfigError,ge as OBSERVER_SYNC_ORIGIN,Dt as OK_OKIGNORE_TEMPLATE,D as ORPHAN_MODES,Lt as PANE_TARGET_TTL_MS,p as PROTOCOL_VERSION,de as PinoLogger,w as ProcessLockCollisionError,je as ProjectGitInitError,Vr as ROLLBACK_ORIGIN,Ee as ROOT_GITIGNORE_TEMPLATE,y as RUNTIME_VERSION,qt as SERVICE_WRITER,Ht as SKILL_INSTALL_EVENTS_FILE_REL,g as SKILL_STATE_TARGETS,Qt as STARTER_FOLDERS,st as STARTER_FOLDER_FRONTMATTER_FILENAME,A as STARTER_PACKS,In as STARTER_PACK_IDS,li as STARTER_TEMPLATES,kr as STATE_MANIFEST_FILENAME,S as STATE_SCHEMA_VERSION,r as SYSTEM_DOC_NAME,Zr as SeedPrerequisiteError,rr as SeedRootDirError,h as ServerLockCollisionError,mn as SingleFileNotAFileError,Fr as SingleFileNotFoundError,ri as SingleFileNotMarkdownError,En as StateManifestError,vr as TagIndex,mi as USER_GLOBAL_BUNDLE_IDS,jn as UiLockCollisionError,Vn as __getShowAllWalkStatsForTesting,Br as __resetShowAllWalkStatsForTesting,o as acquireProcessLock,b as acquireServerLock,Cr as acquireUiLock,Zn as applyAgentMarkdownWrite,Kn as applyExternalChange,cn as applySeed,yi as armPaneTarget,Fi as assertCompatibleStateManifest,bn as assertGitAvailable,Ai as assertNeverDiskEvent,xt as attachIdleShutdown,Y as bootServer,wi as buildAndOpenSkill,Et as buildConfigYmlContent,ae as buildExecResult,ee as buildSkillZip,tt as buildStarterFolderFrontmatterYaml,pr as buildWipTree,z as bundleSkillMdPath,cr as classifyEvents,Ge as classifyFsPath,Xe as clearArmedPaneTarget,ot as clearContributors,ue as clearEmbeddingsKeyFromAllBackends,Te as coercePackId,u as colorFromSeed,Be as commitUpstreamImport,gt as commitWip,Bi as commitWipFromTree,W as compareSemver,It as containsConflictMarkers,be as contentHash,jt as contributorCount,Vt as countShadowObjects,he as countStaleAgentWipRefs,Fe as countWipRefs,Gr as createApiExtension,Ae as createAssetServeMiddleware,Zt as createContentFilter,Kt as createContentFilterAsync,nn as createEmbeddingsSecretStore,dt as createEphemeralProjectDir,P as createExternalChangeHandler,Pn as createFileLogger,si as createLiveDerivedIndexExtension,Dr as createMcpHttpHandler,Yr as createOsProbe,tr as createPersistenceExtension,fn as createServer,Nr as createServerObserverExtension,ti as createStreamingErrorWriter,wn as createTestLogger,gr as describeStoredEmbeddingsKey,fi as detectClaudeDesktopPresence,kn as detectGit,zn as detectProjectShape,Rr as discoverLockDirs,xr as emitPreflightFailureSpan,Yn as encodeDocName,Wn as encodeFolderRoute,on as encodeSkillRoute,_i as ensureProjectGit,Ni as errorResponse,vn as evictStaleTrackerEntries,Oi as extractOkBinaryPath,yt as extractWikiLinksFromMarkdown,q as fallbackPaths,Si as findEnclosingGitRoot,wt as findEnclosingProjectRoot,re as flushFileLogger,Q as formatAuthRejectionWire,$e as formatContributors,dr as formatContributorsFrom,L as formatPackRationale,or as gcCheckpointRefs,Ue as getCurrentMcpLogger,Je as getLocalDir,it as getLogFilePath,ce as getLogger,Ce as getLogsDir,C as getMachineId,Re as getMeter,mt as getMetrics,Ri as getTracer,H as handleCollabSocketError,Pt as handleSpawnCursor,ve as hasGcLogLatch,e as iconFromClientName,kt as incrementCollabSocketFilteredError,zt as incrementServerObserverFire,pe as initContent,Ne as initShadowRepo,Ur as initTelemetry,Oe as initToleranceTelemetryWriter,Yt as installPrettyZodErrors,Wt as installTestLoggers,en as installUserSkill,lt as isAllowedApiOrigin,M as isAllowedWorkspaceHostHeader,Fn as isConfigDoc,ci as isHocuspocusAuthRejectionReason,Or as isKnownPackId,Xr as isLinkIndexExcludedDoc,nr as isLoopbackAddress,pn as isManagedArtifactDoc,n as isOrphanMode,Pr as isPairedWriteOrigin,ni as isPathWithinDir,l as isProcessAlive,Tn as isProjectRoot,_r as isProjectSkillManaged,pi as isReservedForUserTree,An as isSelfWrite,Bn as isSystemDoc,zr as isToleranceTelemetryEnabled,_ as isValidLockPid,Sr as lastKnownHash,Xn as listRescueCheckpoints,Gn as listStarterPacks,sn as loadPrincipal,T as lockFilePath,vi as loggerFactory,Pi as logsCurrentPath,yn as logsPreviousPath,ki as makeLazyEmbeddingsKeyStore,d as markServerLockDraining,bt as mountMcpAndApi,J as normalizeFsPath,Ci as packageVersionMajorMinor,Tt as parseAuthRejectionWire,ie as parseGitVersion,$ as parseHocuspocusAuthToken,et as parseKeepaliveConnectionId,fr as pathToDocName,R as planSeed,sr as prepareSingleFileOpen,We as processCommand,Ye as processUsage,at as readAllTargets,le as readArmedPaneTarget,we as readBranchFromHead,ze as readBundleDecision,x as readProcessLock,v as readProcessLockDetailed,ht as readProjectLocalSemanticConfig,m as readServerLock,zi as readServerPackageVersion,U as readSkillInstallStateSnapshot,Ft as readSkillManagement,ye as readStateManifest,At as readTargetRecordedAt,Bt as readTargetVersion,me as readUiLock,Pe as reconcile,Wr as recordContributor,ke as recordSkillInstallEvent,Xt as registerAllTools,Gt as registerWrite,f as releaseProcessLock,a as releaseServerLock,tn as releaseUiLock,ut as removeLastKnownHash,N as resetMetrics,E as resolveBundleEnabled,Nn as resolveBundledSkillDir,oi as resolveContentDir,Er as resolveCursorBinaryDefault,Jr as resolveCursorSpawnInvocation,er as resolveLockDir,dn as resolvePack,Mr as resolvePackageVersion,ei as resolveUiInfo,Cn as restoreContributors,hr as restoreLifecycleFromConflictsJson,di as rewriteMarkdownLinksForDocumentRename,On as rewriteWikiLinksForDocumentRename,Rn as runAuthReposSubprocess,Lr as runAuthStatusSubprocess,br as runCloneSubprocess,Jn as runDeviceFlowSubprocess,Un as runWithMcpLogger,an as safeContentPath,gi as safeSubdir,Mi as safetyCheckpoint,_n as sanitizeClientName,Di as saveInMemoryCheckpoint,vt as saveVersion,K as seedBasenameIndex,xi as serializeError,Ct as setActiveSpanAttributes,ne as setupServerObservers,Z as shadowGit,Qe as shutdownTelemetry,ur as skillManagementPath,I as spansCurrentPath,ar as spansPreviousPath,He as spawnDetached,qe as splitMarkdownBlocks,rt as startWatcher,se as streamingProblemEvent,Se as swapContributors,Le as teardownToleranceTelemetryWriter,pt as toBroadcasterKey,Li as tracedAppendFileSync,V as tracedLinkSync,Nt as tracedMkdir,_e as tracedMkdirSync,Ot as tracedRename,Rt as tracedRenameSync,fe as tracedRmSync,Me as tracedRmdirSync,Hr as tracedUnlinkSync,De as tracedWriteFile,Jt as tracedWriteFileSync,Ut as updateLastKnownHash,O as updateProcessLockPort,k as updateServerLockPort,$t as updateUiLockPort,ct as validateAgentId,j as validateCloneInputs,Mn as validateSkillZip,c as waitForServerLockDrain,ai as withSpan,Tr as withSpanSync,qr as writeBundleDecision,$n as writeRootGitignoreForNewRepo,un as writeSkillManagement,jr as writeStateManifest,$r as writeTargetVersion,Sn as writeTracker};