@inkeep/open-knowledge 0.25.0-beta.14 → 0.25.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/constants-DLfnk8-s.mjs +2 -0
- package/dist/{dist-BNI6AO8O.mjs → dist-B923c31q.mjs} +5 -5
- package/dist/{dist-s-76L6SV.mjs → dist-C1MZNyof.mjs} +1 -1
- package/dist/{gh-detect-B3B56f-Q.mjs → gh-detect-C_0kt1kp.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/init-DqGkmmfN.mjs +1 -0
- package/dist/{init-DW54iATK.mjs → init-ICH9ja53.mjs} +4 -4
- package/dist/{loader-DCv2w8Aa.mjs → loader-Dv5atXyy.mjs} +2 -2
- package/dist/loader-SibEgXZ1.mjs +1 -0
- package/dist/preview-BIIOpGNN.mjs +1 -0
- package/dist/{preview-DHCoeutH.mjs → preview-CQG9jtTU.mjs} +2 -2
- package/dist/public/assets/{SettingsDialogBody-BagQLg1o.js → SettingsDialogBody-DV-JvdHK.js} +1 -1
- package/dist/public/assets/{config-validation-events-BMpd0Mq3.js → config-validation-events-r0o3-Vnb.js} +8 -8
- package/dist/public/assets/{index-B_1w9TH9.js → index-D3I_UcNL.js} +4 -4
- package/dist/public/index.html +2 -2
- package/dist/{repair-launch-json-BSrN60F8.mjs → repair-launch-json-BmK9QMNQ.mjs} +2 -2
- package/dist/{repair-mcp-configs-DRjvCSZ3.mjs → repair-mcp-configs-BDNpoQWE.mjs} +2 -2
- package/dist/{repair-skills-D5s7VIc5.mjs → repair-skills-Bu_8HPr_.mjs} +2 -2
- package/dist/repair-skills-DHq977uN.mjs +1 -0
- package/dist/server-lock-LsXsWtim-DBIg_FmA.mjs +1 -0
- package/dist/{server-lock-ltHt39S2-CPmTXbVG.mjs → server-lock-ltHt39S2-BMGVBKsW.mjs} +6 -6
- package/dist/{src-Cs-D4krs.mjs → src-DnmgOJh8.mjs} +2 -2
- package/dist/start-CC5yeIBq.mjs +1 -0
- package/dist/{start-BbPOKGqQ.mjs → start-S_2D11FR.mjs} +2 -2
- package/dist/{write-project-skill-DUum3kyh.mjs → write-project-skill-C02OzQla.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-CIwHmMqA.mjs +0 -2
- package/dist/init-Dl10lTfW.mjs +0 -1
- package/dist/loader-D-u-zijB.mjs +0 -1
- package/dist/preview-D2DgJKcy.mjs +0 -1
- package/dist/repair-skills-BUsNTNSG.mjs +0 -1
- package/dist/server-lock-LsXsWtim-lsqjSV5C.mjs +0 -1
- package/dist/start-DXXGeKFB.mjs +0 -1
package/dist/public/index.html
CHANGED
|
@@ -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-
|
|
51
|
+
<script type="module" crossorigin src="./assets/index-D3I_UcNL.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-beU76Hfb.js">
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
<link rel="modulepreload" crossorigin href="./assets/textarea-BQFFQ9_l.js">
|
|
101
101
|
<link rel="modulepreload" crossorigin href="./assets/external-link-Bc6KvE1i.js">
|
|
102
102
|
<link rel="modulepreload" crossorigin href="./assets/keyboard-shortcuts-MXDWcMuC.js">
|
|
103
|
-
<link rel="modulepreload" crossorigin href="./assets/config-validation-events-
|
|
103
|
+
<link rel="modulepreload" crossorigin href="./assets/config-validation-events-r0o3-Vnb.js">
|
|
104
104
|
<link rel="modulepreload" crossorigin href="./assets/format-Fsxus_sZ.js">
|
|
105
105
|
<link rel="modulepreload" crossorigin href="./assets/selection-context-BXIaKU4B.js">
|
|
106
106
|
<link rel="modulepreload" crossorigin href="./assets/PropertyPanel-BxwXftk5.js">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e,v as t}from"./init-
|
|
2
|
-
//# sourceMappingURL=repair-launch-json-
|
|
1
|
+
import{r as e,v as t}from"./init-ICH9ja53.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`],e];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===`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(e){let o=e.logger??u,c=r(e.projectDir,`.claude`,`launch.json`);if(e.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=t(e.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-BmK9QMNQ.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e,p as t}from"./init-
|
|
2
|
-
//# sourceMappingURL=repair-mcp-configs-
|
|
1
|
+
import{b as e,p as t}from"./init-ICH9ja53.mjs";import{r as n,s as r,u as i}from"./write-project-skill-C02OzQla.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,i=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 n){let n=r[o],s=c(()=>n.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:n,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),n.projectConfigPath){let r=n.projectConfigPath,i=c(()=>r(e.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:n,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(n){let r={scope:n.scope,editorId:n.editorId,configPath:n.configPath},o=t(n.target,n.cwd,n.home,n.configPathOverride);if(o===null)return{...r,outcome:`no-entry`};if(i(o))return{...r,outcome:`canonical`};n.logger(a({scope:n.scope,surface:`cli-repair`,editorId:n.editorId,configPath:n.configPath,priorEntry:o}));let s=e(n.target,n.cwd,{mode:`published`,skipAvailabilityCheck:!0},n.home,n.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return n.logger({event:`mcp-config-repair-write-failed`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,error:e}),{...r,outcome:`write-failed`,error:e}}return s.action===`declined`?(n.logger({event:`mcp-config-repair-declined`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,reason:s.declineReason}),{...r,outcome:`declined`}):{...r,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
|
|
2
|
+
//# sourceMappingURL=repair-mcp-configs-BDNpoQWE.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{$r as e,Rr as t,Ur as n,d as r,ia as i,qr as a,ut as o}from"./dist-
|
|
1
|
+
import{$r as e,Rr as t,Ur as n,d as r,ia as i,qr as a,ut as o}from"./dist-B923c31q.mjs";import{t as s}from"./esm-CsQUg9js.mjs";import{c,s as l,t as u}from"./write-project-skill-C02OzQla.mjs";import{dirname as d,join as f,resolve as p}from"node:path";import{homedir as m}from"node:os";import{existsSync as h,mkdirSync as g,readFileSync as _,readdirSync as v,rmSync as y,statSync as b,writeFileSync as x}from"node:fs";const S={existsSync:e=>h(e),isDirectory:e=>{try{return b(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>v(e),readFileSync:e=>_(e),writeFileSync:(e,t)=>{x(e,t)},mkdirSync:(e,t)=>{g(e,t)},rmSync:(e,t)=>{y(e,t)}},C={resolveProjectBundledSkillDir:()=>e(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:t=>e(t,{checkDesktop:!1}),readBundledVersion:()=>t(),readRecordedVersion:e=>n(e,`cli-hosts`),writeRecordedVersion:(e,t)=>i(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>a(e)};function w(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function T(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(d(t),{recursive:!0}),E(e,t,n)}function E(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=f(e,r),a=f(t,r);n.isDirectory(i)?E(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function D(e,t,n,r,i,a){let o=[],s=f(e,`.agents`,`skills`,t),l=r.existsSync(s),u=!1;try{T(n,s,r),u=!0,o.push({kind:`central`,path:s,outcome:l?`overwritten`:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:l,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 l of c){let c=f(e,l.hostDir),u=f(c,`skills`,t);if(u===s){o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(c)){o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-host-absent`});continue}let d=r.existsSync(u);try{T(n,u,r),o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:d?`overwritten`:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,preexisting:d,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,error:t})}}return{entries:o,centralWritten:u}}function O(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 k(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 c){let o=f(e,t.hostDir,`skills`,`open-knowledge`),s=f(o,`SKILL.md`),c=n.existsSync(s),d=l[t.editorId]?.projectConfigPath?.(e),p=!c&&O(d,n);if(!c&&!p){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{u(o,e),T(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 A(e,t,n,i){let a=e=>{t.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),c;try{c=await t.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}),a({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let l;try{l=await t.readRecordedVersion(e)}catch(e){i({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),l=null}if(l!==null&&l===c)return i({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:c}),{outcome:`skipped`,reason:`version-current`};let u=[],d=null;for(let e of o)try{u.push({id:e,sourceDir:t.resolveUserBundledSkillDir(e)})}catch(e){d=e instanceof Error?e.message:String(e)}if(u.length===0)return i({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:d??`no user-global bundles`}),a({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${d}`}),{outcome:`skipped`,reason:`bundle-missing`};let f=[],p=u.length===o.length;for(let{id:t,sourceDir:a}of u){let o=D(e,r[t],a,n,i,c);f.push(...o.entries),o.centralWritten||(p=!1)}let m=f.some(e=>e.kind===`central`&&(e.outcome===`written`||e.outcome===`overwritten`));if(p&&m){let n=null;try{await t.writeRecordedVersion(e,c),i({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:c})}catch(e){n=e instanceof Error?e.message:String(e),i({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:c,error:n})}for(let{id:e}of u)a({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:e,outcome:n===null?`installed`:`failed`,version:c,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=f.some(e=>e.kind===`host`&&e.outcome===`failed`);a({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:c,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:c,entries:f}}async function j(e){let t=e.logger??w,n=e.fs??S,r=e.home??m(),i={...C,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:k(e.projectDir,i,n,t),user:await A(r,i,n,t)}}function M(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.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function N(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 P(){return new s(`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 j({projectDir:p(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${N(e)}\n`),process.exitCode=M(e)})}export{P as n,j as t};
|
|
3
|
-
//# sourceMappingURL=repair-skills-
|
|
3
|
+
//# sourceMappingURL=repair-skills-Bu_8HPr_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./repair-skills-Bu_8HPr_.mjs";export{e as repairSkills};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./server-lock-ltHt39S2-BMGVBKsW.mjs";export{e as updateServerLockPort};
|
|
@@ -445,9 +445,9 @@ $2`).split(`
|
|
|
445
445
|
`),w=v.split(`
|
|
446
446
|
`),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&N4.test(n),a=n===``&&r!==``&&N4.test(r);if(i||a)return!0}return!1};(T(C)||T(w))&&n.push(`jsx-container-boundary-blank`);let E=e=>e.replace(/^[ \t]+/,``).replace(E4,`1$1`),ee=Math.min(C.length,w.length);for(let e=0;e<ee;e++){let t=C[e]??``,r=w[e]??``;if(t!==r&&E(t)===E(r)&&/^[ \t]*\d+[.)]\s/.test(t)){n.push(`ordered-list-marker-number`);break}}return(/[ \t]\n/.test(_)||/[ \t]\n/.test(v))&&n.push(`trailing-whitespace`),(/[ \t]$/.test(_)||/[ \t]$/.test(v))&&(n.includes(`trailing-whitespace`)||n.push(`trailing-whitespace`)),(/\n{3,}/.test(_)||/\n{3,}/.test(v))&&n.push(`blank-line-collapse`),_.endsWith(`
|
|
447
447
|
`)!==v.endsWith(`
|
|
448
|
-
`)&&n.push(`trailing-newline`),n}const B4=`parse-equivalence`;function V4(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}const
|
|
449
|
-
`).map(e=>e.replace(
|
|
450
|
-
`);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=
|
|
451
|
-
`))[
|
|
452
|
-
`).replace(/\n+$/,``)}}function o6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=aK(t);if(n===``)return{identity:{},starterContent:t};let i=sK(n),a=a6(i);if(a)return{identity:a.identity,starterContent:r6(a.docFrontmatterText,r)};let{frontmatter:o}=aK(r);if(o!==``)return{identity:n6(i),starterContent:r};let s=n6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:r6(i,r)}}function s6(e,t){let{docFrontmatterText:n,markdown:r}=i6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Nc.stringify)({[t6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function c6(e){return o6(e).starterContent}function l6(){let e=!1,t=``,n=0;return r=>{let i=u6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function u6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const d6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],f6={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function p6(e,t=d6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const m6={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function h6(e){return e?m6[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const g6={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function _6(e){let t=e?.trim();return t?g6[h6(t)]??t:`Agent`}function v6(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const y6=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function b6(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function x6(e){let t=e.trim();return y6.test(t)||t.startsWith(`//`)}function S6(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(x6(n))return{kind:`external`,url:n};let r=v6(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=b6(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function C6(e,t){let n=e.trim();if(!n)return null;if(x6(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=b6(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function w6(e,t){let n=e.trim();if(!n||y6.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function T6(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function E6(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function D6(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function O6(e){return e.split(`/`).filter(e=>e!==``)}function k6(e,t){let n=D6(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function A6(e,t){let n=D6(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:O6(r).length}function j6(e,t){let n=O6(e),r=O6(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function M6(){let e=new Map;function t(t){let n=T6(t);if(n===``)return;let r=E6(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=T6(t),r=E6(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=D6(T6(n)),o=[],s=[];for(let e of i)k6(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=A6(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=A6(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=j6(a,D6(t));for(let r=1;r<e.length;r++){let i=e[r],o=j6(a,D6(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function N6(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function P6(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function F6(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function I6(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function L6(){try{let e=l(c(d(import.meta.url)),`..`,`package.json`),t=JSON.parse(v(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const R6=L6(),z6=1;var B6=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running on 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 V6(e,t){return l(e,`${t}.lock`)}const H6=new Map;function U6(e){H6.set(e,(H6.get(e)??0)+1)}function W6(e){let t=H6.get(e);return t===void 0||t<=1?(H6.delete(e),!0):(H6.set(e,t-1),!1)}function G6(e,t){try{let n=JSON.parse(v(e,`utf-8`));return n&&typeof n==`object`&&I6(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function K6(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;g(n,{recursive:!0});let a=V6(n,t),o={pid:process.pid,hostname:p(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...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??R6},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!h(a))try{let e=_(a,`wx`,384);try{x(e,s)}finally{m(e)}return U6(a),q6({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=G6(a,i);if(e){let r=e.hostname===p();if(r&&e.pid===process.pid)return b(a,s,{encoding:`utf-8`,mode:384}),U6(a),q6({lockName:t,lockDir:n,lockPath:a});if(r&&F6(e.pid))throw new B6(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{y(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function q6(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>Z6({lockName:t,lockDir:n}),updatePort:e=>J6({lockName:t,lockDir:n,port:e})}}function J6(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=V6(n,t);if(!h(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(v(a,`utf-8`));if(!e||typeof e!=`object`||!I6(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==p())){o.port=r;try{b(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function Y6(e){let{lockName:t,lockDir:n}=e,r=V6(n,t);if(!h(r))return null;let i;try{let e=JSON.parse(v(r,`utf-8`));if(!e||typeof e!=`object`||!I6(e.pid))return null;i=e}catch{return null}if(i.hostname!==p())return null;if(!F6(i.pid)){try{y(r)}catch{}return null}return i}function X6(e){let{lockName:t,lockDir:n}=e,r=V6(n,t);if(!h(r))return{status:`absent`};let i;try{i=JSON.parse(v(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(!I6(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 o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==p())return{status:`stale`,lock:o};if(!F6(o.pid)){try{y(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function Z6(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=V6(n,t);if(W6(i)&&h(i))try{let e=JSON.parse(v(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==p())return;y(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var Q6=class extends B6{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function $6(e,t){try{return K6({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof B6&&e.lockName===`server`?new Q6(e.existing,e.lockPath):e}}function e8(e,t){J6({lockName:`server`,lockDir:e,port:t})}function t8(e){return Y6({lockName:`server`,lockDir:e})}function n8(e){Z6({lockName:`server`,lockDir:e})}export{mG as $,Fs as $a,SG as $i,u2 as $n,o4 as $r,vG as $t,qq as A,_l as Aa,c6 as Ai,uG as An,mn as Ao,t6 as Ar,B$ as At,P2 as B,Dl as Ba,h4 as Bi,Gq as Bn,R0 as Br,l3 as Bt,L$ as C,Gc as Ca,s4 as Ci,G0 as Cn,Wa as Co,g0 as Cr,n1 as Ct,I$ as D,yl as Da,$J as Di,E0 as Dn,cn as Do,u0 as Dr,F0 as Dt,S$ as E,Yc as Ea,ZQ as Ei,Z3 as En,vr as Eo,h0 as Er,P0 as Et,v4 as F,iu as Fa,bG as Fi,v0 as Fn,D as Fo,L0 as Fr,d1 as Ft,k2 as G,Sl as Ga,jG as Gi,Eq as Gn,n0 as Gr,x1 as Gt,M2 as H,tu as Ha,q2 as Hi,yq as Hn,A1 as Hr,$$ as Ht,N$ as I,ru as Ia,KG as Ii,y0 as In,pt as Io,H0 as Ir,o3 as It,dG as J,xl as Ja,o6 as Ji,l2 as Jn,Qq as Jr,b1 as Jt,O2 as K,Xl as Ka,EG as Ki,Oq as Kn,r0 as Kr,S1 as Kt,N2 as L,Ql as La,K4 as Li,S0 as Ln,ft as Lo,U0 as Lr,C0 as Lt,q$ as M,Wc as Ma,b$ as Mi,i1 as Mn,Lt as Mo,M0 as Mr,VG as Mt,Bq as N,Jc as Na,dq as Ni,y2 as Nn,Tt as No,A0 as Nr,o1 as Nt,x$ as O,bl as Oa,nq as Oi,t3 as On,un as Oo,d0 as Or,X$ as Ot,l4 as P,ll as Pa,Rq as Pi,C2 as Pn,O as Po,V0 as Pr,s1 as Pt,fG as Q,El as Qa,p4 as Qi,X0 as Qn,H2 as Qr,_G as Qt,L2 as R,qc as Ra,kq as Ri,_0 as Rn,z0 as Rr,T0 as Rt,C$ as S,I as Sa,a3 as Si,xG as Sn,fa as So,m1 as Sr,zG as St,R$ as T,Cl as Ta,r$ as Ti,Y3 as Tn,ai as To,m0 as Tr,N0 as Tt,D2 as U,Kl as Ua,OG as Ui,wq as Un,j1 as Ur,C1 as Ut,F2 as V,Pl as Va,R4 as Vi,_q as Vn,M1 as Vr,FG as Vt,A2 as W,Ul as Wa,d3 as Wi,Cq as Wn,k1 as Wr,v1 as Wt,gG as X,Ml as Xa,YG as Xi,o2 as Xn,c1 as Xr,h1 as Xt,cG as Y,Fl as Ya,oK as Yi,c2 as Yn,Zq as Yr,y1 as Yt,hG as Z,Tl as Za,f$ as Zi,s2 as Zn,U2 as Zr,_1 as Zt,f6 as _,sK as _a,$4 as _i,Q1 as _n,Zs as _o,e2 as _r,W$ as _t,K6 as a,wG as aa,p6 as ai,N1 as an,j as ao,$0 as ar,W1 as at,D1 as b,db as ba,U3 as bi,i0 as bn,Uo as bo,R1 as br,RG as bt,I6 as c,Q4 as ca,M6 as ci,B4 as cn,tc as co,W0 as cr,U1 as ct,X6 as d,kG as da,x3 as di,BG as dn,A as do,m2 as dr,e3 as dt,t4 as ea,Yq as ei,yG as en,cc as eo,T2 as er,pG as et,t8 as f,d4 as fa,y3 as fi,sG as fn,N as fo,h2 as fr,IG as ft,e8 as g,YQ as ga,_6 as gi,Xq as gn,k as go,p2 as gr,G$ as gt,J6 as h,c4 as ha,Q2 as hi,Kq as hn,rc as ho,f2 as hr,t0 as ht,Q6 as i,v6 as ia,lG as ii,P1 as in,M as io,Q0 as ir,H$ as it,J$ as j,gl as ja,jq as ji,r1 as jn,on as jo,J0 as jr,_$ as jt,F$ as k,vl as ka,h6 as ki,PG as kn,fn as ko,f0 as kr,z$ as kt,V6 as l,oq as la,l6 as li,JG as ln,F as lo,$3 as lr,WG as lt,n8 as m,P6 as ma,z4 as mi,J1 as mn,Mc as mo,O0 as mr,e0 as mt,R6 as n,p$ as na,S6 as ni,PQ as nn,Bs as no,r2 as nr,Uq as nt,$6 as o,B3 as oa,s6 as oi,GG as on,kc as oo,_2 as or,G1 as ot,Z6 as p,aK as pa,q4 as pi,X1 as pn,lc as po,g2 as pr,p1 as pt,E2 as q,ul as qa,k0 as qi,n2 as qn,UG as qr,$q as qt,z6 as r,w6 as ra,C6 as ri,I1 as rn,Hs as ro,i2 as rr,V$ as rt,F6 as s,J2 as sa,q0 as si,u1 as sn,$s as so,v2 as sr,H1 as st,B6 as t,f4 as ta,Lq as ti,qG as tn,P as to,d2 as tr,Vq as tt,Y6 as u,cq as ua,sZ as ui,XG as un,Ys as uo,D0 as ur,ZG as ut,LG as v,lq as va,u3 as vi,$1 as vn,Ws as vo,t2 as vr,K1 as vt,w$ as w,nu as wa,NQ as wi,J3 as wn,Ga as wo,p0 as wr,V1 as wt,O1 as x,tp as xa,N6 as xi,a0 as xn,Vo as xo,eJ as xr,HG as xt,j$ as y,Z2 as ya,e6 as yi,l1 as yn,ys as yo,Z0 as yr,q1 as yt,I2 as z,Kc as za,NG as zi,S2 as zn,B0 as zr,L1 as zt};
|
|
453
|
-
//# sourceMappingURL=server-lock-ltHt39S2-
|
|
448
|
+
`)&&n.push(`trailing-newline`),n}const B4=`parse-equivalence`;function V4(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function H4(e){return e.replace(/[ \t]+$/gm,``)}const U4=/^([ \t]*)\d+([.)])(?=[ \t])/;function W4(e){return e.split(`
|
|
449
|
+
`).map(e=>e.replace(U4,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const G4=new Set;function K4(e,t){let n=0;for(let r=0;r<t.length&&n<e.length;r++)e[n]===t[r]&&n++;return n===e.length}function q4(e,t,n){let r=aK(e),i=aK(t);if(r.frontmatter!==i.frontmatter)return!1;if(r.body===i.body)return!0;let a;try{a=n(r.body)}catch(e){let t=e instanceof Error?e.message:String(e);return G4.size<8&&!G4.has(t)&&(G4.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return V4(H4(a))===V4(H4(i.body))?K4(W4(r.body),W4(a)):!1}const J4={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},Y4={"emphasis-around-code":`pm-model-caused`,bom:`parser-caused`,crlf:`parser-caused`,"commonmark-escape":`parser-caused`,"leading-newline":`parser-caused`,"paragraph-continuation-indent":`parser-caused`,"doc-start-thematic":`parser-caused`,"block-separator-collapse":`serializer-caused`,"table-align-row-spacing":`serializer-caused`,"row-no-trailing-pipe":`serializer-caused`,"ordered-list-marker-number":`serializer-caused`,"list-indent-canonical":`serializer-caused`,"jsx-container-boundary-blank":`serializer-caused`,"trailing-whitespace":`serializer-caused`,"blank-line-collapse":`serializer-caused`,"trailing-newline":`serializer-caused`,"parse-equivalence":`parser-caused`};function X4(e){return Y4[e]}function Z4(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return e.length===t.length?-1:n}let Q4=null;function $4(e){Q4=e}function e3(e,t,n,r){if(!Q4||e.length===0)return;let i=Z4(t,n),a=new Date().toISOString();for(let t of e)Q4({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:X4(t)})}const t3=1e4,n3=`last-spawn-error.log`,r3=/^[a-zA-Z0-9][\w/-]*$/;function i3(e){return e.startsWith(`#`)?e.slice(1):e}function a3(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function o3(e){if(!e||e.trim()===``)return[];let{map:t}=q2(e);if(!t)return[];let n=a3(t.tags),r=[];for(let e of n){let t=i3(e);r3.test(t)&&r.push(t)}return r}const s3=[`.ok`,`local`,`installed-skills.json`],c3=P(yG),l3=Ys({hosts:M(k()),scope:c3,scripts:j(),installedAt:Uo()}),u3=Ys({schema:F(1),skills:rc(k(),l3).default({})});function d3(){return{schema:1,skills:{}}}function f3(e){let t;try{t=JSON.parse(e)}catch{return null}let n=u3.safeParse(t);return n.success?n.data:null}const p3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},m3=new WeakMap;function h3(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function g3(e){return e.trim().toLowerCase()}const _3=/\.(?:md|mdx)$/;function v3(e,t){if(t!==`page`)return e;let n=e.replace(_3,``);return n.length>0?n:e}function y3(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function b3(e){let t=y3(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function x3(e){let t=gW({schema:p3});return e.length>0&&DW(t,e),t}function S3(e){let t={documents:e};return m3.set(t,x3(e)),t}function C3(e){let t=m3.get(e);if(t)return t;let n=x3(e.documents);return m3.set(e,n),n}function w3(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function T3(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function E3(e,t){let n=g3(t);if(!n)return 0;let r=v3(n,e.kind),i=g3(e.title),a=g3(e.name),o=g3(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function D3(e,t){let n=E3(e,t);return n<=0?n:dq(e.path)?n*.5:n}function O3(e){return e===`file`?-60:0}function k3(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function A3(e,t,n,r){return e+t*20+n+O3(r)}function j3(e,t,n,r,i,a){return e===`relevance`?A3(t,n,r,i):k3(t,n,r,i,a)}function M3(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function N3(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function P3(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function F3(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function I3(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function L3(e,t){return g3(t).length<4?0:e===`full_text`?1:0}function R3(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function z3(e){let t=[],n=[],r=[];for(let i of e){let e=R3(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function B3(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=z3(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function V3(e,t,n={}){let r=n.intent??`omnibar`,i=M3(r,n.ranking),a=h3(n.limit),o=new Set(n.scopes??w3(r)),s=e.documents.filter(e=>T3(e,o)),c=g3(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=rG(C3(e),{term:c,properties:F3(r),boost:I3(r),tolerance:L3(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>T3(e.document,o)).map(e=>[e.document.id,e.score])),d=P3(s),f=new Map;for(let e of s)D3(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)T3(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=N3(f.values(),u);return B3([...f.values()].map(t=>{let n=Math.max(0,D3(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:j3(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return B3(U3({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function H3(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function U3(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=N3(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,D3(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?j3(o,t,n,s,e.kind,m):A3(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=H3(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=H3(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function W3(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),G3(n)}function G3(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const K3=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),q3=globalThis;q3[K3]===void 0&&(q3[K3]=Ii());const J3=q3[K3],Y3=[`.ok`,`skill-state.yml`],X3=[`claude-cowork`,`cli-hosts`],Z3=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],Q3=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,$3=Ys({version:k().regex(Q3,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(J3,{description:`Recorded skill version for this target.`}),recordedAt:Uo().register(J3,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:P(Z3).register(J3,{description:`Install-source surface that recorded this entry.`}).optional()}),e6=Ys({schema:F(1).register(J3,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Ys({"claude-cowork":$3.optional(),"cli-hosts":$3.optional()}).register(J3,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function t6(){return{schema:1,targets:{}}}const n6=`template`;function r6(e){if(e.trim()===``)return{};let t;try{t=(0,Nc.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function i6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function a6(e){let{frontmatter:t,body:n}=aK(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:sK(t),markdown:n}}function o6(e){let t=e.split(`
|
|
450
|
+
`);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=r6(n.join(`
|
|
451
|
+
`))[n6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
|
|
452
|
+
`).replace(/\n+$/,``)}}function s6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=aK(t);if(n===``)return{identity:{},starterContent:t};let i=sK(n),a=o6(i);if(a)return{identity:a.identity,starterContent:i6(a.docFrontmatterText,r)};let{frontmatter:o}=aK(r);if(o!==``)return{identity:r6(i),starterContent:r};let s=r6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:i6(i,r)}}function c6(e,t){let{docFrontmatterText:n,markdown:r}=a6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Nc.stringify)({[n6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function l6(e){return s6(e).starterContent}function u6(){let e=!1,t=``,n=0;return r=>{let i=d6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function d6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const f6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],p6={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function m6(e,t=f6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const h6={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function g6(e){return e?h6[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const _6={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function v6(e){let t=e?.trim();return t?_6[g6(t)]??t:`Agent`}function y6(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const b6=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function x6(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function S6(e){let t=e.trim();return b6.test(t)||t.startsWith(`//`)}function C6(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(S6(n))return{kind:`external`,url:n};let r=y6(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=x6(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function w6(e,t){let n=e.trim();if(!n)return null;if(S6(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=x6(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function T6(e,t){let n=e.trim();if(!n||b6.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function E6(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function D6(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function O6(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function k6(e){return e.split(`/`).filter(e=>e!==``)}function A6(e,t){let n=O6(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function j6(e,t){let n=O6(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:k6(r).length}function M6(e,t){let n=k6(e),r=k6(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function N6(){let e=new Map;function t(t){let n=E6(t);if(n===``)return;let r=D6(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=E6(t),r=D6(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=O6(E6(n)),o=[],s=[];for(let e of i)A6(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=j6(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=j6(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=M6(a,O6(t));for(let r=1;r<e.length;r++){let i=e[r],o=M6(a,O6(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function P6(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function F6(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function I6(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function L6(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function R6(){try{let e=l(c(d(import.meta.url)),`..`,`package.json`),t=JSON.parse(v(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const z6=R6(),B6=1;var V6=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running on 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 H6(e,t){return l(e,`${t}.lock`)}const U6=new Map;function W6(e){U6.set(e,(U6.get(e)??0)+1)}function G6(e){let t=U6.get(e);return t===void 0||t<=1?(U6.delete(e),!0):(U6.set(e,t-1),!1)}function K6(e,t){try{let n=JSON.parse(v(e,`utf-8`));return n&&typeof n==`object`&&L6(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function q6(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;g(n,{recursive:!0});let a=H6(n,t),o={pid:process.pid,hostname:p(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...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??z6},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!h(a))try{let e=_(a,`wx`,384);try{x(e,s)}finally{m(e)}return W6(a),J6({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=K6(a,i);if(e){let r=e.hostname===p();if(r&&e.pid===process.pid)return b(a,s,{encoding:`utf-8`,mode:384}),W6(a),J6({lockName:t,lockDir:n,lockPath:a});if(r&&I6(e.pid))throw new V6(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{y(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function J6(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>Q6({lockName:t,lockDir:n}),updatePort:e=>Y6({lockName:t,lockDir:n,port:e})}}function Y6(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=H6(n,t);if(!h(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(v(a,`utf-8`));if(!e||typeof e!=`object`||!L6(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==p())){o.port=r;try{b(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function X6(e){let{lockName:t,lockDir:n}=e,r=H6(n,t);if(!h(r))return null;let i;try{let e=JSON.parse(v(r,`utf-8`));if(!e||typeof e!=`object`||!L6(e.pid))return null;i=e}catch{return null}if(i.hostname!==p())return null;if(!I6(i.pid)){try{y(r)}catch{}return null}return i}function Z6(e){let{lockName:t,lockDir:n}=e,r=H6(n,t);if(!h(r))return{status:`absent`};let i;try{i=JSON.parse(v(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(!L6(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 o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==p())return{status:`stale`,lock:o};if(!I6(o.pid)){try{y(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function Q6(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=H6(n,t);if(G6(i)&&h(i))try{let e=JSON.parse(v(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==p())return;y(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var $6=class extends V6{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function e8(e,t){try{return q6({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof V6&&e.lockName===`server`?new $6(e.existing,e.lockPath):e}}function t8(e,t){Y6({lockName:`server`,lockDir:e,port:t})}function n8(e){return X6({lockName:`server`,lockDir:e})}function r8(e){Q6({lockName:`server`,lockDir:e})}export{mG as $,Fs as $a,SG as $i,u2 as $n,o4 as $r,vG as $t,qq as A,_l as Aa,l6 as Ai,uG as An,mn as Ao,n6 as Ar,B$ as At,P2 as B,Dl as Ba,h4 as Bi,Gq as Bn,R0 as Br,u3 as Bt,L$ as C,Gc as Ca,s4 as Ci,G0 as Cn,Wa as Co,g0 as Cr,n1 as Ct,I$ as D,yl as Da,$J as Di,E0 as Dn,cn as Do,u0 as Dr,F0 as Dt,S$ as E,Yc as Ea,ZQ as Ei,Q3 as En,vr as Eo,h0 as Er,P0 as Et,v4 as F,iu as Fa,bG as Fi,v0 as Fn,D as Fo,L0 as Fr,d1 as Ft,k2 as G,Sl as Ga,jG as Gi,Eq as Gn,n0 as Gr,x1 as Gt,M2 as H,tu as Ha,q2 as Hi,yq as Hn,A1 as Hr,$$ as Ht,N$ as I,ru as Ia,KG as Ii,y0 as In,pt as Io,H0 as Ir,s3 as It,dG as J,xl as Ja,s6 as Ji,l2 as Jn,Qq as Jr,b1 as Jt,O2 as K,Xl as Ka,EG as Ki,Oq as Kn,r0 as Kr,S1 as Kt,N2 as L,Ql as La,q4 as Li,S0 as Ln,ft as Lo,U0 as Lr,C0 as Lt,q$ as M,Wc as Ma,b$ as Mi,i1 as Mn,Lt as Mo,M0 as Mr,VG as Mt,Bq as N,Jc as Na,dq as Ni,y2 as Nn,Tt as No,A0 as Nr,o1 as Nt,x$ as O,bl as Oa,nq as Oi,n3 as On,un as Oo,d0 as Or,X$ as Ot,l4 as P,ll as Pa,Rq as Pi,C2 as Pn,O as Po,V0 as Pr,s1 as Pt,fG as Q,El as Qa,p4 as Qi,X0 as Qn,H2 as Qr,_G as Qt,L2 as R,qc as Ra,kq as Ri,_0 as Rn,z0 as Rr,T0 as Rt,C$ as S,I as Sa,o3 as Si,xG as Sn,fa as So,m1 as Sr,zG as St,R$ as T,Cl as Ta,r$ as Ti,X3 as Tn,ai as To,m0 as Tr,N0 as Tt,D2 as U,Kl as Ua,OG as Ui,wq as Un,j1 as Ur,C1 as Ut,F2 as V,Pl as Va,R4 as Vi,_q as Vn,M1 as Vr,FG as Vt,A2 as W,Ul as Wa,f3 as Wi,Cq as Wn,k1 as Wr,v1 as Wt,gG as X,Ml as Xa,YG as Xi,o2 as Xn,c1 as Xr,h1 as Xt,cG as Y,Fl as Ya,oK as Yi,c2 as Yn,Zq as Yr,y1 as Yt,hG as Z,Tl as Za,f$ as Zi,s2 as Zn,U2 as Zr,_1 as Zt,p6 as _,sK as _a,e3 as _i,Q1 as _n,Zs as _o,e2 as _r,W$ as _t,q6 as a,wG as aa,m6 as ai,N1 as an,j as ao,$0 as ar,W1 as at,D1 as b,db as ba,W3 as bi,i0 as bn,Uo as bo,R1 as br,RG as bt,L6 as c,$4 as ca,N6 as ci,B4 as cn,tc as co,W0 as cr,U1 as ct,Z6 as d,kG as da,S3 as di,BG as dn,A as do,m2 as dr,t3 as dt,t4 as ea,Yq as ei,yG as en,cc as eo,T2 as er,pG as et,n8 as f,d4 as fa,b3 as fi,sG as fn,N as fo,h2 as fr,IG as ft,t8 as g,YQ as ga,v6 as gi,Xq as gn,k as go,p2 as gr,G$ as gt,Y6 as h,c4 as ha,Q2 as hi,Kq as hn,rc as ho,f2 as hr,t0 as ht,$6 as i,y6 as ia,lG as ii,P1 as in,M as io,Q0 as ir,H$ as it,J$ as j,gl as ja,jq as ji,r1 as jn,on as jo,J0 as jr,_$ as jt,F$ as k,vl as ka,g6 as ki,PG as kn,fn as ko,f0 as kr,z$ as kt,H6 as l,oq as la,u6 as li,JG as ln,F as lo,e6 as lr,WG as lt,r8 as m,F6 as ma,z4 as mi,J1 as mn,Mc as mo,O0 as mr,e0 as mt,z6 as n,p$ as na,C6 as ni,PQ as nn,Bs as no,r2 as nr,Uq as nt,e8 as o,V3 as oa,c6 as oi,GG as on,kc as oo,_2 as or,G1 as ot,Q6 as p,aK as pa,J4 as pi,X1 as pn,lc as po,g2 as pr,p1 as pt,E2 as q,ul as qa,k0 as qi,n2 as qn,UG as qr,$q as qt,B6 as r,T6 as ra,w6 as ri,I1 as rn,Hs as ro,i2 as rr,V$ as rt,I6 as s,J2 as sa,q0 as si,u1 as sn,$s as so,v2 as sr,H1 as st,V6 as t,f4 as ta,Lq as ti,qG as tn,P as to,d2 as tr,Vq as tt,X6 as u,cq as ua,sZ as ui,XG as un,Ys as uo,D0 as ur,ZG as ut,LG as v,lq as va,d3 as vi,$1 as vn,Ws as vo,t2 as vr,K1 as vt,w$ as w,nu as wa,NQ as wi,Y3 as wn,Ga as wo,p0 as wr,V1 as wt,O1 as x,tp as xa,P6 as xi,a0 as xn,Vo as xo,eJ as xr,HG as xt,j$ as y,Z2 as ya,t6 as yi,l1 as yn,ys as yo,Z0 as yr,q1 as yt,I2 as z,Kc as za,NG as zi,S2 as zn,B0 as zr,L1 as zt};
|
|
453
|
+
//# sourceMappingURL=server-lock-ltHt39S2-BMGVBKsW.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{s as e}from"./chunk-C94x7I9S.mjs";import{c as t,l as n,s as r}from"./server-lock-ltHt39S2-
|
|
1
|
+
import{s as e}from"./chunk-C94x7I9S.mjs";import{c as t,l as n,s as r}from"./server-lock-ltHt39S2-BMGVBKsW.mjs";import{Mr as i,Nr as a,Tn as o,pn as s,ri as c,xn as l}from"./dist-B923c31q.mjs";import{t as u}from"./esm-CsQUg9js.mjs";import"./gh-detect-C_0kt1kp.mjs";import{b as d,v as f}from"./init-ICH9ja53.mjs";import{n as ee,s as p}from"./write-project-skill-C02OzQla.mjs";import"./loader-Dv5atXyy.mjs";import{c as m}from"./colors-8SzMRIVy.mjs";import"./preview-CQG9jtTU.mjs";import{dirname as te,isAbsolute as h,join as g,relative as _,resolve as v}from"node:path";import{hostname as y}from"node:os";import{existsSync as b,lstatSync as ne,readFileSync as x,readlinkSync as re,statSync as ie}from"node:fs";import{readFile as S,realpath as C}from"node:fs/promises";function w(e,i,a={}){let o=n(e,i);if(!b(o))return{status:`missing`,lockPath:o};let s;try{s=JSON.parse(x(o,`utf-8`))}catch{return{status:`corrupt`,lockPath:o}}if(!s||typeof s!=`object`||!t(s.pid))return{status:`corrupt`,lockPath:o};let c=s;if(!(a.isAlive??r)(c.pid))return{status:`dead-pid`,lockPath:o,lock:c};let l=a.host??y();return c.hostname===l?{status:`alive`,lockPath:o,lock:c}:{status:`foreign-host`,lockPath:o,lock:c}}function T(e){return e.replace(/:\d+$/,``)}function E(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:T(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 D(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 O(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 ae(e){let t=D(e);if(t)return{kind:`doc`,...t};let n=O(e);return n?{kind:`folder`,...n}:null}const oe=`# >>> open-knowledge cli >>>`,se=`# <<< open-knowledge cli <<<`,k=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function A(e){return g(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const j={existsSync:e=>b(e),readFileSync:(e,t)=>x(e,t),lstatSync:e=>ne(e),readlinkSync:e=>re(e)};function M(e,t=j){let n=A(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 N(e){let t=e.replace(k,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function P(e,t,n=j){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const F=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`deinit`]);function I(e,t,n=o){if(e!==void 0&&!F.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let L=null;function R(e){L=e}function z(){return L??process.cwd()}var B=e(m(),1);function V(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function H(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 U(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:l(r),command:r,isDesktop:V(r)}}function W(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function G(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&W(e)?`ui-orphan`:`stale`}const K=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function ce(e){switch(e){case`running`:return B.default.green(e);case`desktop`:return B.default.blue(e);case`foreign`:return B.default.cyan(e);case`ui-orphan`:return B.default.magenta(e);case`stale`:return B.default.yellow(e)}}function q(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function le(e){return`${q(e.server.usage)} | ${q(e.ui?.usage??null)}`}function ue(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function de(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=G(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,ue(e),le(e),t,String(n),H(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(G(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=B.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
2
2
|
`)}async function J(e={}){let t=e.discover??s,n=e.inspect??w,r=e.log??(e=>console.log(e)),o=e.resolveCommand??i,c=e.resolveUsage??a,l=await t(),u=[];for(let e of l){let t=n(e,`server`),r=n(e,`ui`),i=U(e,t,r,t.status===`missing`||t.status===`corrupt`?null:o(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:c(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:c(r.lock.pid));i!=null&&u.push(i)}if(e.json){let e=u.map(e=>({...e,displayStatus:G(e)}));r(JSON.stringify(e,null,2));return}r(de(e.all?u:u.filter(e=>K.has(G(e)))))}function fe(){return new u(`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 J({all:t.all===!0||e===`all`,json:t.json===!0})})}function pe(e,t,n={}){let i=n.isAlive??r,a=[];for(let[n,r]of[[`server`,e],[`ui`,t]])(r.status===`alive`||r.status===`foreign-host`&&i(r.lock.pid))&&a.push({name:n,pid:r.lock.pid,port:r.lock.port});return{targets:a}}function Y(e){let t=e.inspect??(t=>w(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=pe(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 X(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function me(e,t=r){let n=await s(),i=null;for(let r of n){let n=w(r,`server`),a=w(r,`ui`);if(X(n,t)&&n.lock.port===e||X(a,t)&&a.lock.port===e)return r;i===null&&(X(n,t)&&n.lock.pid===e||X(a,t)&&a.lock.pid===e)&&(i=r)}return i}function Z(e){let t=Y({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function he(e){return new u(`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 t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=Y({lockDir:c(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 J({});return}if(n===`all`){let e=await s();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=w(n,`server`),i=w(n,`ui`);!X(e,r)&&!X(i,r)||(Z(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await me(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Z(t);return}Z(c(v(z(),n)))})}function ge(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function _e(e,t){let n,r;try{n=await C(v(e)),r=await C(v(te(e)))}catch{return{kind:`not-git`}}if(!$(n,r))return{kind:`symlink-escape`};let i=g(n,`.git`),a;try{a=ie(i)}catch{return{kind:`not-git`}}let o;if(a.isDirectory()){let e;try{e=await C(i)}catch{return{kind:`not-git`}}if(!$(e,n))return{kind:`symlink-escape`};o=e}else if(a.isFile()){let e;try{e=await S(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=h(r)?r:v(n,r);try{o=await C(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=g(await Q(o),`config`),c;try{c=await S(s,`utf-8`)}catch{return{kind:`not-git`}}let l=ye(c);if(l===null)return{kind:`no-origin`};let u=E(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 Q(e){let t;try{t=(await S(g(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=h(t)?t:v(e,t);try{return await C(n)}catch{return n}}function $(e,t){if(e===t)return!0;let n=_(t,e);return n.length>0&&!n.startsWith(`..`)&&!h(n)}function ve(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 ye(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=ve(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 be(r[1])}return null}function be(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const xe=[{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=d(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=ee(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 Se(e,t,n={},r=xe){let i=[];for(let a of t){let t=p[a];for(let a of r)i.push(a.write(t,e,n))}return i}function Ce(e,t,n={}){return{integrations:Se(e,t,n),claudeLaunchJson:t.includes(`claude`)?f(e,n):void 0}}export{ae as _,he as a,w as b,I as c,se as d,P as f,D as g,N as h,Y as i,oe as l,M as m,_e as n,fe as o,A as p,ge as r,R as s,Ce as t,k as u,O as v,E as y};
|
|
3
|
-
//# sourceMappingURL=src-
|
|
3
|
+
//# sourceMappingURL=src-DnmgOJh8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,f as t,r as n}from"./start-S_2D11FR.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{On as e,dt as t}from"./server-lock-ltHt39S2-CPmTXbVG.mjs";import{cr as n,jr as r,xr as i}from"./dist-BNI6AO8O.mjs";import{n as a,t as o}from"./esm-CsQUg9js.mjs";import{i as s,t as c}from"./gh-detect-B3B56f-Q.mjs";import{n as l}from"./constants-CIwHmMqA.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],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}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`,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){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 q(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}=await import(`./dist-s-76L6SV.mjs`),S=e.log??_(`start`),C=e.singleFile!==void 0,w=e.projectDir??a,T=C?r(e.singleFile).canonicalFilePath:void 0,E=T?h(T):void 0,D=T?m(T):void 0;if(!C){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`))&&S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-DRjvCSZ3.mjs`)).repairMcpConfigs)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-BSrN60F8.mjs`)).repairLaunchJson)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-BUsNTNSG.mjs`)).repairSkills)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let O=E??b(t,a);!C&&!f(O)&&(p(O,{recursive:!0}),S.info({contentDir:O},`Created content directory`));let k=null,A=async({lockDir:t})=>{if(k=L({uiLock:y(t),isAlive:v}),k.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}),S.info({reason:k.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 k.action===`skip`&&S.info({port:k.port,pid:k.pid},`UI already running at port ${k.port}`)},j=e.reactShellDistDir===void 0,M=s(),N=i(),P=await g({config:t,contentDir:O,projectDir:C?w:a,contentRoot:C?void 0:t.content.dir,port:e.port,host:o,quiet:!1,detectGh:c,tokenStore:M,embeddingsKeyStore:N,...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:j,idleShutdownMs:d,skipAutoInit:!0,...j?{spawnUiSiblingFn:A}:{},idleShutdownHandler:e=>{let t=K({readUiLock:()=>y(P.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:S});return C?G(t,w):t},log:S,...e.serveContentAssets?{serveContentAssets:!0}:{},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});k||={action:`skip`,reason:`alive`,pid:0,port:0};let F=k,z=null;if(F.action===`skip`)z=F.port>0?F.port:null;else if(!u){let t=e.uiBindTimeoutMs??3e3;z=await U({readUiLock:()=>y(P.lockDir),now:Date.now,sleep:e=>x(e),timeoutMs:t,pollIntervalMs:50}),z===null&&S.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:P.httpServer,destroy:P.destroy,lockDir:P.lockDir,contentDir:O,port:P.port,ready:P.ready,degraded:P.degraded,uiSpawnDecision:k,resolvedUiPort:z}}function J(e){if(e===`browser`||e===`app`)return e;throw new a(`--mode must be 'browser' or 'app'`)}function ee(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-s-76L6SV.mjs`);if(B(m,e(t(c)))){await H({cwd:c,uiPort:m});return}}let g;try{g=await q({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-s-76L6SV.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-DHTbHSqx.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 te(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`,ee).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,J).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)
|
|
1
|
+
import{On as e,dt as t}from"./server-lock-ltHt39S2-BMGVBKsW.mjs";import{cr as n,jr as r,xr as i}from"./dist-B923c31q.mjs";import{n as a,t as o}from"./esm-CsQUg9js.mjs";import{i as s,t as c}from"./gh-detect-C_0kt1kp.mjs";import{n as l}from"./constants-DLfnk8-s.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],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}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`,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){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 q(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}=await import(`./dist-C1MZNyof.mjs`),S=e.log??_(`start`),C=e.singleFile!==void 0,w=e.projectDir??a,T=C?r(e.singleFile).canonicalFilePath:void 0,E=T?h(T):void 0,D=T?m(T):void 0;if(!C){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`))&&S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-BDNpoQWE.mjs`)).repairMcpConfigs)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-BmK9QMNQ.mjs`)).repairLaunchJson)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-DHq977uN.mjs`)).repairSkills)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let O=E??b(t,a);!C&&!f(O)&&(p(O,{recursive:!0}),S.info({contentDir:O},`Created content directory`));let k=null,A=async({lockDir:t})=>{if(k=L({uiLock:y(t),isAlive:v}),k.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}),S.info({reason:k.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 k.action===`skip`&&S.info({port:k.port,pid:k.pid},`UI already running at port ${k.port}`)},j=e.reactShellDistDir===void 0,M=s(),N=i(),P=await g({config:t,contentDir:O,projectDir:C?w:a,contentRoot:C?void 0:t.content.dir,port:e.port,host:o,quiet:!1,detectGh:c,tokenStore:M,embeddingsKeyStore:N,...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:j,idleShutdownMs:d,skipAutoInit:!0,...j?{spawnUiSiblingFn:A}:{},idleShutdownHandler:e=>{let t=K({readUiLock:()=>y(P.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:S});return C?G(t,w):t},log:S,...e.serveContentAssets?{serveContentAssets:!0}:{},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});k||={action:`skip`,reason:`alive`,pid:0,port:0};let F=k,z=null;if(F.action===`skip`)z=F.port>0?F.port:null;else if(!u){let t=e.uiBindTimeoutMs??3e3;z=await U({readUiLock:()=>y(P.lockDir),now:Date.now,sleep:e=>x(e),timeoutMs:t,pollIntervalMs:50}),z===null&&S.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:P.httpServer,destroy:P.destroy,lockDir:P.lockDir,contentDir:O,port:P.port,ready:P.ready,degraded:P.degraded,uiSpawnDecision:k,resolvedUiPort:z}}function J(e){if(e===`browser`||e===`app`)return e;throw new a(`--mode must be 'browser' or 'app'`)}function ee(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-C1MZNyof.mjs`);if(B(m,e(t(c)))){await H({cwd:c,uiPort:m});return}}let g;try{g=await q({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-C1MZNyof.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-DHTbHSqx.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 te(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`,ee).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,J).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
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{O as C,D as S,te as _,V as a,N as b,F as c,z as d,P as f,R as g,B as h,K as i,X as l,Z as m,U as n,H as o,Y as p,q as r,L as s,I as t,Q as u,$ as v,w as x,G as y};
|
|
3
|
-
//# sourceMappingURL=start-
|
|
3
|
+
//# sourceMappingURL=start-S_2D11FR.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Mt as e,bt as t,tn as n,v as r}from"./server-lock-ltHt39S2-
|
|
1
|
+
import{Mt as e,bt as t,tn as n,v as r}from"./server-lock-ltHt39S2-BMGVBKsW.mjs";import{$r as i}from"./dist-B923c31q.mjs";import{basename as a,dirname as o,isAbsolute as s,join as c,posix as l,relative as u,resolve as d,sep as f,win32 as p}from"node:path";import{homedir as m}from"node:os";import{cpSync as h,existsSync as g,lstatSync as _,mkdirSync as v,realpathSync as y,rmSync as b}from"node:fs";const x=r,S=t,C=e,w=`node`,T={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},E=`# ok-mcp-v1`,D=`# 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`;function A(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}return!1}function j(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=d(e);if(a(t)===`cli.mjs`&&a(o(t))===`dist`)return t;let n=t.split(f),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 c(i.length===0?f:i.join(f),`packages`,`cli`,`dist`,`cli.mjs`)}function M(e={}){return e.mode===`dev`?{command:w,args:[j(),`mcp`],env:{...T}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,k]}:{command:`/bin/sh`,args:[`-l`,`-c`,D]}}function N(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[w,j(),`mcp`],environment:{...T}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,k]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,D]}}function P(e){if(typeof e!=`object`||!e)return!1;let t=e;return F(t,M({mode:`published`,platformName:`darwin`}))||F(t,M({mode:`published`,platformName:`win32`}))}function F(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 I(e){return e===`win32`?p:l}function L(e={}){let t=e.platformName??process.platform,n=e.home??m(),r=e.env??process.env,i=I(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 R(e={}){let t=e.platformName??process.platform,n=e.home??m();return I(t).join(n,`.claude.json`)}function z(e={}){let t=e.platformName??process.platform,n=e.home??m(),r=e.env??process.env;if(t===`darwin`)return l.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??p.join(n,`AppData`,`Roaming`);return p.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function B(e={}){let t=e.platformName??process.platform,n=e.home??m();return I(t).join(n,`.cursor`,`mcp.json`)}function V(e={}){let t=e.platformName??process.platform,n=e.home??m();return(e.env??process.env).CODEX_HOME??I(t).join(n,`.codex`)}function H(e={}){return I(e.platformName??process.platform).join(V(e),`config.toml`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??m(),r=e.env??process.env,i=I(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 W(e={}){return I(e.platformName??process.platform).join(U(e),`opencode.json`)}function G(e={}){let t=e.platformName??process.platform,n=e.home??m();return I(t).join(n,`.openclaw`,`openclaw.json`)}const K={claude:{id:`claude`,label:S.claude,configPath:(e,t)=>R({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>M(t),scope:`global`,detectPath:(e,t)=>c(t??m(),`.claude`),projectConfigPath:e=>c(e,`.mcp.json`),projectSkillPath:e=>c(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:S[`claude-desktop`],configPath:(e,t)=>z({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>M(t),scope:`global`,detectPath:(e,t)=>o(z({home:t}))},cursor:{id:`cursor`,label:S.cursor,configPath:(e,t)=>B({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>M(t),scope:`global`,detectPath:(e,t)=>o(B({home:t})),projectConfigPath:e=>c(e,`.cursor`,`mcp.json`),projectSkillPath:e=>c(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:S.codex,configPath:(e,t)=>H({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>n,buildEntry:(e,t)=>M(t),scope:`global`,detectPath:(e,t)=>o(H({home:t})),projectConfigPath:e=>c(e,`.codex`,`config.toml`),projectSkillPath:e=>c(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:S.opencode,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>n,buildEntry:(e,t)=>N(t),scope:`global`,detectPath:(e,t)=>o(W({home:t})),projectConfigPath:e=>c(e,`opencode.json`),projectSkillPath:e=>c(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:S.openclaw,configPath:(e,t)=>G({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>n,buildEntry:(e,t)=>M(t),scope:`global`,detectPath:(e,t)=>c(t??m(),`.openclaw`),offerOnlyWhenDetected:!0}};function q(e){let t=e.filter(e=>!Object.hasOwn(K,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${x.join(`, `)}`);return e.map(e=>K[e])}function J(e,t){let n;try{n=y(t)}catch{n=d(t)}let r;try{r=_(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(r?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);let i=o(e);for(;i.length>1&&i!==f;){let t;try{t=y(i)}catch(e){if(e.code===`ENOENT`){i=o(i);continue}throw e}let r=u(n,t);if(r===``||!r.startsWith(`..`)&&!s(r))return;throw Error(`Refusing to write at ${e}: ancestor ${i} 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 Y(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=i(`project`,{checkDesktop:!0}),a=o(n);J(a,t);let s=g(n)?`overwritten`:`written`;return b(a,{recursive:!0,force:!0}),v(o(a),{recursive:!0}),h(r,a,{recursive:!0}),{editorId:e.id,label:e.label,action:s,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}export{O as a,C as c,P as d,L as f,E as i,M as l,q as m,Y as n,S as o,j as p,x as r,K as s,J as t,A as u};
|
|
36
|
-
//# sourceMappingURL=write-project-skill-
|
|
36
|
+
//# sourceMappingURL=write-project-skill-C02OzQla.mjs.map
|
package/package.json
CHANGED
package/dist/init-Dl10lTfW.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e}from"./init-DW54iATK.mjs";export{e as runInit};
|
package/dist/loader-D-u-zijB.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-DCv2w8Aa.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-DHCoeutH.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./repair-skills-D5s7VIc5.mjs";export{e as repairSkills};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as e}from"./server-lock-ltHt39S2-CPmTXbVG.mjs";export{e as updateServerLockPort};
|
package/dist/start-DXXGeKFB.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,f as t,r as n}from"./start-BbPOKGqQ.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};
|