@inkeep/open-knowledge 0.12.0 → 0.13.0-beta.0
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 +3 -2
- package/dist/cli.mjs +51 -50
- package/dist/constants-BYIeZQM3.mjs +2 -0
- package/dist/dist-CNZsMl-V.mjs +1 -0
- package/dist/{dist-D7myPw4s.mjs → dist-C_YxrqyY.mjs} +44 -38
- package/dist/{gh-detect-CNO7EkgF.mjs → gh-detect-CdNj3GJ-.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{init-DjkROmXh.mjs → init-Bt9S7yc7.mjs} +9 -9
- package/dist/init-BxRIBYoQ.mjs +1 -0
- package/dist/{loader-ZHA8qsxF.mjs → loader-CBz-HCpO.mjs} +3 -3
- package/dist/loader-DWoT_ViS.mjs +1 -0
- package/dist/{preview-BI2sVxtF.mjs → preview-BNODnkHd.mjs} +2 -2
- package/dist/preview-UvJSxuyy.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-BWmb9zCZ.js → ActivityModeContent-DI-NbLxJ.js} +1 -1
- package/dist/public/assets/DocumentContext-CPOzFdnn.js +61 -0
- package/dist/public/assets/{GraphPanel-PYMXWVsg.js → GraphPanel-CugGrte3.js} +9 -9
- package/dist/public/assets/{SettingsDialogBody-YOvgrn38.js → SettingsDialogBody-Do5q2G21.js} +2 -2
- package/dist/public/assets/{SourceEditor-D1zhJS8f.js → SourceEditor-CyXGsCrF.js} +1 -1
- package/dist/public/assets/config-validation-events-BH_BmK0r.js +12 -0
- package/dist/public/assets/index-DMG1oK8Y.js +1915 -0
- package/dist/public/assets/{keyboard-shortcuts-CNJfczoS.js → keyboard-shortcuts-bRPd5tp-.js} +1 -1
- package/dist/public/assets/{prop-types-COA7UVY9.js → prop-types-vRN_ulq0.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-Cp-mOxXo.js → target-navigation-intent-CMJZoqSj.js} +1 -1
- package/dist/public/assets/{telemetry-impl-l-VsaBiG.js → telemetry-impl-BrY67z04.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-DWg86xJw.js → typing-burst-detector-Dm58iY7Z.js} +2 -2
- package/dist/public/index.html +7 -7
- package/dist/{repair-launch-json-DCXsAQuF.mjs → repair-launch-json-7O7Lmxus.mjs} +2 -2
- package/dist/{repair-mcp-configs-BV1WJulV.mjs → repair-mcp-configs-2dA34sJP.mjs} +2 -2
- package/dist/{repair-skills-uHQb0hCn.mjs → repair-skills-CeaTntK5.mjs} +2 -2
- package/dist/repair-skills-ulgbNIxw.mjs +1 -0
- package/dist/{server-lock-BpjJj3OD-CUhVvie4.mjs → server-lock-BpjJj3OD-D4ouSX5Q.mjs} +2 -2
- package/dist/server-lock-CyhBidkz-RB9B6fvF.mjs +1 -0
- package/dist/{src-DnynaviS.mjs → src-hFiiM4hG.mjs} +3 -3
- package/dist/{start-NIyRsRSX.mjs → start-BiMFcs6H.mjs} +2 -2
- package/dist/start-xtUzqtGY.mjs +1 -0
- package/dist/{write-project-skill-DnuutHfZ.mjs → write-project-skill-DDU4NRC7.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-iOPbvTyC.mjs +0 -2
- package/dist/dist-GL5zcXSU.mjs +0 -1
- package/dist/init-BCTt64EX.mjs +0 -1
- package/dist/loader-DlfckqdT.mjs +0 -1
- package/dist/preview-1rr7IXHj.mjs +0 -1
- package/dist/public/assets/DocumentContext-9Sn6Kq-o.js +0 -61
- package/dist/public/assets/config-validation-events-BUyp1R_U.js +0 -12
- package/dist/public/assets/index-CEtMQRxi.js +0 -1915
- package/dist/repair-skills-BSA3PyS7.mjs +0 -1
- package/dist/server-lock-CyhBidkz-D41BTXw5.mjs +0 -1
- package/dist/start-DYkSDg3x.mjs +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./esm-BLMtE3s6.mjs";import{
|
|
1
|
+
import{t as e}from"./esm-BLMtE3s6.mjs";import{Hi as t,Nr as n,Tr as r,kr as i,zr as a}from"./dist-C_YxrqyY.mjs";import{t as o}from"./write-project-skill-DDU4NRC7.mjs";import{existsSync as s,mkdirSync as c,readFileSync as l,readdirSync as u,rmSync as d,statSync as f,writeFileSync as p}from"node:fs";import{dirname as m,join as h,resolve as g}from"node:path";import{homedir as _}from"node:os";const v=[{hostDir:`.claude`,editorId:`claude`},{hostDir:`.cursor`,editorId:`cursor`},{hostDir:`.agents`,editorId:`codex`}],y=`open-knowledge-discovery`,b=[`.agents`,`skills`,y],x={existsSync:e=>s(e),isDirectory:e=>{try{return f(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>u(e),readFileSync:e=>l(e),writeFileSync:(e,t)=>{p(e,t)},mkdirSync:(e,t)=>{c(e,t)},rmSync:(e,t)=>{d(e,t)}},S={resolveProjectBundledSkillDir:()=>a(`project`,{checkDesktop:!1}),resolveDiscoveryBundledSkillDir:()=>a(`discovery`,{checkDesktop:!1}),readBundledVersion:()=>r(),readRecordedVersion:e=>i(e,`cli-hosts`),writeRecordedVersion:(e,n)=>t(e,`cli-hosts`,n,`cli-start`),recordEvent:e=>n(e)};function C(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function w(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(m(t),{recursive:!0}),T(e,t,n)}function T(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=h(e,r),a=h(t,r);n.isDirectory(i)?T(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function E(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 v){let s=h(e,t.hostDir,`skills`,`open-knowledge`),c=h(s,`SKILL.md`);if(!n.existsSync(c)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:s,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:s});continue}try{o(s,e),w(i,s,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:s,outcome:`reclaimed`}),r({event:`project-skill-reclaim-reclaimed`,scope:`project`,editorId:t.editorId,path:s})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:s,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:s,error:n})}}return{outcome:`done`,entries:a}}async function D(e,t,n,r){let i=e=>{t.recordEvent(e).catch(()=>{})},a=()=>new Date().toISOString(),o;try{o=await t.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let s;try{s=await t.readRecordedVersion(e)}catch(e){r({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),s=null}if(s!==null&&s===o)return r({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:o}),{outcome:`skipped`,reason:`version-current`};let c;try{c=t.resolveDiscoveryBundledSkillDir()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`bundle-missing:${t}`}),{outcome:`skipped`,reason:`bundle-missing`}}let l=[],u=h(e,...b),d=n.existsSync(u);try{w(c,u,n),l.push({kind:`central`,path:u,outcome:d?`overwritten`:`written`}),r({event:`user-skill-reclaim-central-written`,scope:`user`,path:u,preexisting:d,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);l.push({kind:`central`,path:u,outcome:`failed`,error:t}),r({event:`user-skill-reclaim-central-failed`,scope:`user`,path:u,error:t})}for(let t of v){let i=h(e,t.hostDir),a=h(i,`skills`,y);if(a===u){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-collapsed-with-central`});continue}if(!n.existsSync(i)){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-host-absent`});continue}let s=n.existsSync(a);try{w(c,a,n),l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:s?`overwritten`:`written`}),r({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,preexisting:s,version:o})}catch(e){let n=e instanceof Error?e.message:String(e);l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`failed`,error:n}),r({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,error:n})}}let f=l.find(e=>e.kind===`central`);if(f?.outcome===`written`||f?.outcome===`overwritten`){let n=null;try{await t.writeRecordedVersion(e,o),r({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:o})}catch(e){n=e instanceof Error?e.message:String(e),r({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:o,error:n})}i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:n===null?`installed`:`failed`,version:o,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=l.some(e=>e.kind===`host`&&e.outcome===`failed`);i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,version:o,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:o,entries:l}}async function O(e){let t=e.logger??C,n=e.fs??x,r=e.home??_(),i={...S,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:E(e.projectDir,i,n,t),user:await D(r,i,n,t)}}function k(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 A(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===`no-token`).length,i=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} no-token, ${i} 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 j(){return new e(`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 O({projectDir:g(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${A(e)}\n`),process.exitCode=k(e)})}export{j as n,O as t};
|
|
3
|
-
//# sourceMappingURL=repair-skills-
|
|
3
|
+
//# sourceMappingURL=repair-skills-CeaTntK5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./repair-skills-CeaTntK5.mjs";export{e as repairSkills};
|
|
@@ -442,5 +442,5 @@ $2`).split(`
|
|
|
442
442
|
`)},mdxJsxFlowElement(e,t,n,r){let i=e,a=i.data?.sourceRaw;if(typeof a==`string`)return a;let o=i.data?.htmlBoundary;if(o&&typeof o.opener==`string`&&typeof o.closer==`string`){let e=n.containerFlow({type:`root`,children:i.children??[]},r);return`${o.opener}\n\n${e}\n\n${o.closer}`}let s=i.name??``,c=wQ(i.attributes??[]);if(!i.children||i.children.length===0)return s?c?`<${s} ${c} />`:`<${s} />`:``;let l=c?`<${s} ${c}>`:`<${s}>`,u=`</${s}>`;return`${l}\n\n${n.containerFlow({type:`root`,children:i.children},r)}\n\n${u}`},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),o+=i.move(`==`),a(),o},comment(e,t,n,r){let i=e.data?.sourceForm,a=i===`html`?`<!-- `:`%%`,o=i===`html`?` -->`:`%%`,s=n.createTracker(r),c=n.enter(`comment`),l=s.move(a);return l+=n.containerPhrasing(e,{before:l,after:o,...s.current()}),l+=s.move(o),c(),l},commentBlock(e,t,n,r){let i=n.createTracker(r),a=n.enter(`commentBlock`),o=e.children??[],s=e.data?.sourceForm,c=e.data?.sourceLayout,l=o.length===1&&o[0]?.type===`paragraph`;if(s===`html`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`<!-- `,after:` -->`,...i.current()});return a(),`<!-- ${t} -->`}if(c===`inline`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`%% `,after:` %%`,...i.current()});return a(),`%% ${t} %%`}let u=n.containerFlow(e,i.current());return a(),`%%\n\n${u}\n\n%%`},mdxJsxTextElement(e){let t=e.data?.sourceRaw;if(typeof t==`string`)return t;let n=e.name??``,r=wQ(e.attributes??[]);return r?`<${n} ${r} />`:`<${n}/>`},rawMdxFallback(e){return e.value??``},blockquote(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.containerFlow(e,a.current());i();let s=e.data?.sourceMarkerSpacings,c=0;return n.indentLines(o,(e,t,n)=>{if(n)return`>`;let r=s?.[c++];return r===`none`||r===0?`>${e}`:typeof r==`number`&&r>=2&&!e.startsWith(` `)?`>${` `.repeat(r)}${e}`:`> ${e}`})}};function wQ(e){let t=[];for(let n of e){if(n.type===`mdxJsxExpressionAttribute`){t.push(`{${n.value}}`);continue}let e=n.name;if(n.value===null||n.value===void 0){t.push(e);continue}if(typeof n.value==`string`){if(n.value.includes(`"`)){let r=n.value.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`);t.push(`${e}={"${r}"}`)}else t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function TQ(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function EQ(e){if(!e)return``;let t=0,n=!0;for(let r of e)r===`(`?t++:r===`)`&&(t--,t<0&&(n=!1));return t!==0&&(n=!1),n?e:e.replace(/[\\()]/g,`\\$&`)}function DQ(e){return e.replace(/(?<!\\)&(?=(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z][A-Za-z0-9]*);)/g,(e,t)=>OQ(t)?e:`\\${e}`)}function OQ(e){if(e.charCodeAt(0)!==35)return!1;let t=e[1]===`x`||e[1]===`X`?Number.parseInt(e.slice(2),16):Number.parseInt(e.slice(1),10);return t===9||t===10||t===11||t===12||t===13||t===32}function kQ(e,t,n){let r=e.unsafe;e.unsafe=r.filter(e=>!(e.character===`&`&&e.after===`[#A-Za-z]`||e.character===`<`||e.character===`[`||e.character===`(`||e.character==="`"||(e.character===`*`||e.character===`_`||e.character===`~`)&&e.inConstruct===`phrasing`||e.character===`=`&&e.atBreak===!0));let i;try{i=e.safe(t,n)}finally{e.unsafe=r}return DQ(NQ(i,n))}function AQ(e){if(Number.isNaN(e))return`ws`;let t=lN(e);return t===1?`ws`:t===2?`punct`:`other`}function jQ(e,t,n){let r=AQ(t),i=AQ(n),a=i!==`ws`&&(i===`other`||r!==`other`),o=r!==`ws`&&(r===`other`||i!==`other`);return e===`_`?a&&(!o||r===`punct`)||o&&(!a||i===`punct`):a||o}function MQ(e,t,n){let r=t;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;if(r<e.length)return e[r]===`
|
|
443
443
|
`||e[r]===`\r`;let i=n.after.charCodeAt(0);return Number.isNaN(i)||i===10||i===13}function NQ(e,t){let n=``,r=0;for(;r<e.length;){let i=e.charAt(r);if(i===`\\`){n+=e.slice(r,r+2),r+=2;continue}if(i===`*`||i===`_`||i===`~`||i===`=`){let a=r+1;for(;a<e.length&&e.charAt(a)===i;)a++;let o=r===0?t.before.charCodeAt(t.before.length-1):e.charCodeAt(r-1);if(i===`=`)n+=(Number.isNaN(o)||o===10||o===13)&&MQ(e,a,t)?`\\${e.slice(r,a)}`:e.slice(r,a);else{let s=a<e.length?e.charCodeAt(a):t.after.charCodeAt(0);n+=jQ(i,o,s)?`\\${i}`.repeat(a-r):e.slice(r,a)}r=a;continue}n+=i,r+=1}return n}function PQ(e,t,n){let r=n.startsWith(`_`)?`_`:`*`,i=e,a=i.charCodeAt(0);FQ(t.before.charCodeAt(t.before.length-1),a,r)&&(i=IQ(a)+i.slice(1));let o=i.charCodeAt(i.length-1);return FQ(t.after.charCodeAt(0),o,r)&&(i=i.slice(0,-1)+IQ(o)),i}function FQ(e,t,n){return!(lN(t)!==1||n===`_`&&lN(e)===void 0)}function IQ(e){return`&#x${e.toString(16).toUpperCase()};`}function LQ(e,t,n,r){let i=e.value??``,a=e.data?.sourceDelimiter,o=typeof a==`string`&&/^\$+$/.test(a)?a.length:2;for(o===1&&!zQ(i,r)&&(o=2);RegExp(`(^|[^$])${`\\$`.repeat(o)}([^$]|$)`).test(i);)o++;let s=`$`.repeat(o);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` ${i} `);let c=-1;for(;++c<n.unsafe.length;){let e=n.unsafe[c];if(!e.atBreak)continue;let t=n.compilePattern(e),r;for(;(r=t.exec(i))!==null;){let e=r.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=`${i.slice(0,e)} ${i.slice(r.index+1)}`}}return s+i+s}function RQ(e,t,n,r){let i=e.data?.sourceDelimiter===`~`?`~`:`~~`,a=n.createTracker(r),o=n.enter(`strikethrough`),s=a.move(i);return s+=n.containerPhrasing(e,{...a.current(),before:s,after:`~`}),s+=a.move(i),o(),s}function zQ(e,t){return!(e.length===0||!/^\S/.test(e)||!/\S$/.test(e)||/[$\r\n]/.test(e)||e.endsWith(`\\`)||/\\[!-/:-@[-`{-~]/.test(e)||/^\d/.test(t.after)||t.before.endsWith(`\\`))}function BQ(e){if(!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KiB`,`MiB`,`GiB`,`TiB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(1).replace(/\.0$/,``)} ${t[r]}`}var VQ=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};constructor(e){this.schema=Ly(e.extensions),this.handlers=ZQ(this.schema,this.parseCtx);let{nodeHandlers:t,markHandlers:n}=QQ(this.schema);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=lQ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=uQ({toMarkdownHandlers:CQ})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return gQ(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?_Q(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?TY(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e){let t;try{t=this.schema.nodeFromJSON(e)}catch(t){let n=`MarkdownManager.serialize() failed: schema rejected JSONContent (type=${e.type}, childCount=${e.content?.length??0})`;throw Error(n,{cause:t})}return vQ(t,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}};const HQ=pY();function UQ(e,t){let n=new Map;for(let e of t)n.set(e.name,e);let r={};for(let t of e){if(t.type===`mdxJsxExpressionAttribute`)continue;let e=t.name,i=n.get(e);if(t.value===null||t.value===void 0){r[e]=!0;continue}if(typeof t.value==`string`){if(i?.type===`number`){let n=Number(t.value);r[e]=Number.isNaN(n)?t.value:n}else i?.type===`boolean`?r[e]=t.value===`true`:r[e]=t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function WQ(e){let t=!1;return e.descendants(e=>t||e.type.name===`jsxInline`?!1:e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function GQ(e){return e.attrs.sourceDirty||WQ(e)}function KQ(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0?!0:t.every(e=>e.type===`text`&&e.value===``)}function qQ(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),t.sourcePadded===!0&&(n.sourcePadded=!0),Object.keys(n).length===0?e:{...e,data:n}}function JQ(e,t){if(e.length===0)return qQ({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return qQ({type:`inlineCode`,value:e.map(e=>e.value).join(``)},t);if(e.length===1&&`children`in e[0]){let n=e[0];return{...n,children:[JQ(n.children,t)]}}return qQ({type:`inlineCode`,value:YQ(e)},t)}function YQ(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=YQ(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const XQ=dK;function ZQ(e,t){let n=e.nodes,r=e.marks,i={};n.paragraph&&(i.paragraph=(e,t,r)=>{let i=r.all(e).flat(),a=i.some(e=>e?.isBlock&&!e?.isInline),o=i.some(e=>e?.isInline||e?.isText||e?.isTextblock);if(a&&!o)return i.length===1?i[0]:i;if(a&&o){let e=i.filter(e=>!e?.isBlock||e?.isInline),t=i.filter(e=>e?.isBlock&&!e?.isInline),r=[],a=n.paragraph.createAndFill(null,e.length>0?e:null);return a&&r.push(a),r.push(...t),r.length===1?r[0]:r}return n.paragraph.createAndFill(null,i.length>0?i:null)}),n.blockquote&&(i.blockquote=ZL(n.blockquote,e=>({sourceMarkerSpacings:e.data?.sourceMarkerSpacings??null}))),n.tableCell&&(i.tableCell=(e=>(t,r,i)=>{let a=i.all(t).flat();if(a.length>0&&n.paragraph){let t=n.paragraph.create(null,a);return e.createAndFill(null,[t])}return e.createAndFill(null,null)})(n.tableCell)),n.tableRow&&(i.tableRow=ZL(n.tableRow)),n.table&&n.tableRow&&n.tableCell&&(i.table=(e,t,r)=>{let i=e.align??[],a=e.children??[],o=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type!==`tableRow`)continue;let s=t.children??[],c=[];for(let t=0;t<s.length;t++){let a=s[t];if(a.type!==`tableCell`)continue;let o=r.all(a).flat(),l=o.length>0&&n.paragraph?[n.paragraph.create(null,o)]:null,u=i[t]??null,d=e===0&&n.tableHeader?n.tableHeader:n.tableCell,f=a.data?.sourcePadding??null,p=d.createAndFill({align:u,sourcePadding:f},l);p&&c.push(p)}let l=n.tableRow.createAndFill(null,c.length>0?c:null);l&&o.push(l)}let s=e.data?.sourceDashCounts??null,c=e.data?.sourceOuterPipes??null,l=e.data?.sourceAlignmentPadding??null;return n.table.createAndFill({sourceDashCounts:s,sourceOuterPipes:c,sourceAlignmentPadding:l},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=SQ(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r})},n.imageReference?i.imageReference=e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):i.imageReference=e=>n.image.createAndFill({src:``,alt:e.alt??null,title:null})),r.escapeMark&&(i.text=t=>{let n=t.value??``,i=typeof t.data?.sourceRaw==`string`?t.data.sourceRaw:null;if(!n&&!i)return null;if(i){let t=n.replaceAll(`\xA0`,` `);return r.sourceLiteral?e.text(t,[r.sourceLiteral.create({sourceRaw:i})]):e.text(t)}let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n.replaceAll(`\xA0`,` `));let s=[...(a??[]).map(e=>({kind:`escape`,offset:e.offset,length:1})),...(o??[]).map(e=>({kind:`entity`,offset:e.offset,length:e.length,raw:e.raw}))];s.sort((e,t)=>e.offset-t.offset);let c=[],l=0;for(let t of s){if(t.offset>l){let r=n.slice(l,t.offset).replaceAll(`\xA0`,` `);r&&c.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length).replaceAll(`\xA0`,` `);i&&(t.kind===`escape`?c.push(e.text(i,[r.escapeMark.create()])):r.sourceLiteral?c.push(e.text(i,[r.sourceLiteral.create({sourceRaw:t.raw})])):c.push(e.text(i))),l=t.offset+t.length}}if(l<n.length){let t=n.slice(l).replaceAll(`\xA0`,` `);t&&c.push(e.text(t))}return c.length===1?c[0]:c}),r.code&&(i.inlineCode=t=>e.text(t.value,[r.code.create({sourceFenceChar:t.data?.sourceFenceChar??"`",sourceFenceLength:typeof t.data?.sourceFenceLength==`number`?t.data.sourceFenceLength:1,sourcePadded:t.data?.sourcePadded===!0})]));let a=r.strike??r.delete;if(a&&(i.delete=QL(a,e=>({sourceDelimiter:e.data?.sourceDelimiter===`~`?`~`:`~~`}))),r.highlight&&(i.mark=QL(r.highlight)),r.comment&&(i.comment=QL(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=ZL(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=QL(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=QL(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=ZL(n.heading,e=>({level:e.depth,headingStyle:e.data?.sourceStyle??`atx`,sourceTrailingHashes:e.data?.sourceTrailingHashes??null,sourceUnderlineLength:e.data?.sourceUnderlineLength??null,sourceContiguousNext:e.data?.sourceContiguousNext??!1,sourceLeadingIndent:e.data?.sourceLeadingIndent??null,sourceInteriorSpacing:e.data?.sourceInteriorSpacing??null}))),n.codeBlock&&(i.code=t=>{let r=t.value?[e.text(t.value)]:[];return n.codeBlock.createAndFill({language:t.lang??null,meta:t.meta??null,fenceDelimiter:t.data?.sourceFenceChar??"`",fenceLength:t.data?.sourceFenceLength??3,sourceStyle:t.data?.sourceStyle??`fenced`,sourceClosingFenceLength:t.data?.sourceClosingFenceLength??null,sourceFenceIndent:t.data?.sourceFenceIndent??null,sourceInfoPadding:t.data?.sourceInfoPadding??null,sourceIndents:t.data?.sourceIndents??null},r)}),n.thematicBreak&&(i.thematicBreak=e=>n.thematicBreak.createAndFill({sourceRaw:e.data?.sourceRaw??`---`})),n.hardBreak&&(i.break=e=>n.hardBreak.createAndFill({hardBreakStyle:e.data?.sourceStyle??`spaces`})),n.list&&(i.list=ZL(n.list,e=>({ordered:!!e.ordered,start:e.start??1,spread:!!e.spread,bulletMarker:e.data?.bulletMarker??null,listMarkerDelimiter:e.data?.listMarkerDelimiter??null}))),n.listItem&&(i.listItem=ZL(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread,sourceMarkerSpacing:e.data?.sourceMarkerSpacing??null,sourceOrdinal:e.data?.sourceOrdinal??null,sourceCheckboxChar:e.data?.sourceCheckboxChar??null,sourceContinuationIndent:e.data?.sourceContinuationIndent??null}))),r.link){let t=r.sourceLiteral;i.link=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[](${n.url??``})`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.url??``,title:n.title??null,linkStyle:n.data?.sourceStyle??`inline`,refLabel:null,sourceUrlForm:n.data?.sourceUrlForm??null,sourceTitleMarker:n.data?.sourceTitleMarker??null});return o.map(e=>e.mark(s.addToSet(e.marks)))},i.linkReference=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[${n.label??``}][${n.identifier??``}]`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:``,title:null,linkStyle:n.referenceType??`shortcut`,refLabel:n.label??n.identifier??null});return o.map(e=>e.mark(s.addToSet(e.marks)))}}n.htmlBlock&&(i.html=e=>n.htmlBlock.createAndFill({content:e.value??``}));let o=n.linkDefinition??n.linkRefDef;if(o){let e=!!o.spec.attrs?.url,t=!!o.spec.attrs?.href,n=!!o.spec.attrs?.identifier,r=!!o.spec.attrs?.sourceLayout,a=!!o.spec.attrs?.sourceTitleMarker;i.definition=i=>{let s={title:i.title??null};return n&&(s.identifier=i.identifier??``),s.label=i.label??i.identifier??``,e?s.url=i.url??``:t&&(s.href=i.url??``),r&&(s.sourceLayout=i.data?.sourceLayout??null),a&&(s.sourceTitleMarker=i.data?.sourceTitleMarker??null),o.createAndFill(s)}}if(n.jsxComponent){let r=e=>{if(e&&typeof e==`object`&&`sourceRaw`in e){let t=e.sourceRaw;if(typeof t==`string`)return t}};i.mdxJsxFlowElement=(e,i,a)=>{let o=e.name??``,s=HQ.getOrWildcard(o),c=UQ(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=SQ(e,t.current.sourcePath);n!==e&&(c.src=n,c.sourceUrl=e)}let l=a.all(e).flat();return n.jsxComponent.createAndFill({componentName:o,kind:`element`,attributes:e.attributes,sourceRaw:r(e.data)??``,sourceDirty:!1,props:c},l.length?l:void 0)};let a=(e,t)=>{let n=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return n&&typeof n.value==`string`?n.value:null};i.mdxJsxTextElement=t=>{if(t.name===`InlineMath`&&n.mathInline){let e=a(t,`formula`)??``,r=a(t,`id`);return n.mathInline.create({formula:e,id:r??null})}if(t.name===`Tag`&&n.tag){let e=a(t,`value`)??``;return n.tag.create({value:e})}if(n.jsxInline){let i=r(t.data)??``;return n.jsxInline.createAndFill({},i?[e.text(i)]:null)}return n.jsxComponent.createAndFill({sourceRaw:r(t.data)??``})},i.mdxFlowExpression=e=>{let t=r(e.data)??`{${e.value??``}}`;return n.jsxComponent.createAndFill({kind:`expression`,sourceRaw:t,sourceDirty:!1})},i.mdxTextExpression=t=>{let n=r(t.data)??`{${t.value??``}}`;return e.text(n)}}return n.wikiLink&&(i.wikiLink=e=>n.wikiLink.createAndFill({target:e.data?.target??``,alias:e.data?.alias??null,anchor:e.data?.anchor??null,sourceTarget:e.data?.sourceTarget??null,sourceAnchor:e.data?.sourceAnchor??null,sourceAlias:e.data?.sourceAlias??null})),n.tag&&(i.tag=e=>n.tag.createAndFill({value:e.value})),n.wikiLinkEmbed&&(i.wikiLinkEmbed=(i,a)=>{let o=i.data?.target??``,s=i.data?.alias??null,c=i.data?.anchor??null,l=Nq(o),{resolveEmbed:u,sourcePath:d}=t.current,f=u&&d?u(o,d)??null:null,p=f?`/${f}`:o,m=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(m&&XQ.has(l)&&n.jsxComponent&&HQ.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,alt:s??o,target:o,anchor:c,alias:s}});if(m&&fK.has(l)&&n.jsxComponent&&HQ.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&mK.has(l)&&n.jsxComponent&&HQ.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&hK.has(l)&&n.jsxComponent&&HQ.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&d?e(o,d)??null:null,i=r===null?null:BQ(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,target:o,anchor:c,alias:s,size:i}})}let h=s||(c?`${o}#${c}`:o);if(r.link){let t=r.link.create({href:p,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s});return e.text(h,[t])}throw Error("[wikiLinkEmbed handler] schema lacks `link` mark — cannot dispatch without violating the STOP rule against emitting PM wikiLinkEmbed server-side")}),n.mathInline&&(i.inlineMath=e=>n.mathInline.create({formula:e.value??``,sourceDelimiter:e.data?.sourceDelimiter??null})),i.math||=t=>{let r=t.value==null?`«unknown:${t.type}»`:t.value;return n.rawMdxFallback?(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled block mdast: ${t.type}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled block mdast: ${t.type}`},r?[e.text(r)]:null)):null},i.inlineMath||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled inline mdast: ${t.type}`})),t.value==null?e.text(`«unknown:${t.type}»`):e.text(t.value)),n.footnoteReference?i.footnoteReference=e=>n.footnoteReference.create({identifier:e.identifier,label:e.label??e.identifier}):i.footnoteReference||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteReference`,reason:`FootnoteReference extension missing — recovering [^id] source`})),e.text(`[^${t.label??t.identifier}]`)),n.footnoteDefinition?i.footnoteDefinition=ZL(n.footnoteDefinition,e=>{let t=e;return{identifier:t.identifier,label:t.label??t.identifier}}):i.footnoteDefinition||=t=>{console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteDefinition`,reason:`FootnoteDefinition extension missing — recovering [^id]: marker`}));let r=`[^${t.label??t.identifier}]: `;return n.paragraph?n.paragraph.create(null,e.text(r)):null},i.rawMdxFallbackMdast=t=>{if(!n.rawMdxFallback)return null;let r=t.position?{start:t.position.start?.offset??0,end:t.position.end?.offset??0}:{start:0,end:0};return console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.originalType,reason:`Unhandled mdast: ${t.originalType}`,unresolvedPosition:t.unresolvedPosition??!1})),n.rawMdxFallback.createAndFill({reason:`Unhandled mdast: ${t.originalType}`,originalSpan:r},t.value?[e.text(t.value)]:null)},i}function QQ(e){let t={},n={},r=e.nodes,i=e.marks;r.paragraph&&(t.paragraph=rR(`paragraph`)),r.blockquote&&(t.blockquote=rR(`blockquote`,e=>{let t=e.attrs.sourceMarkerSpacings,n={};return Array.isArray(t)&&t.length>0&&(n.sourceMarkerSpacings=t),Object.keys(n).length>0?{data:n}:{}})),r.heading&&(t.heading=rR(`heading`,e=>({depth:e.attrs.level,data:{sourceStyle:e.attrs.headingStyle,sourceTrailingHashes:e.attrs.sourceTrailingHashes??void 0,sourceUnderlineLength:e.attrs.sourceUnderlineLength??void 0,sourceContiguousNext:e.attrs.sourceContiguousNext===!0?!0:void 0,sourceLeadingIndent:e.attrs.sourceLeadingIndent??void 0,sourceInteriorSpacing:e.attrs.sourceInteriorSpacing??void 0}}))),r.codeBlock&&(t.codeBlock=e=>{let t=e.attrs.sourceStyle===`indented`?`indented`:`fenced`;return{type:`code`,lang:t===`indented`?null:e.attrs.language??null,meta:t===`indented`?null:e.attrs.meta??null,value:e.textContent??``,data:{sourceFenceChar:e.attrs.fenceDelimiter,sourceFenceLength:e.attrs.fenceLength,sourceStyle:t,sourceClosingFenceLength:e.attrs.sourceClosingFenceLength??void 0,sourceFenceIndent:e.attrs.sourceFenceIndent??void 0,sourceInfoPadding:e.attrs.sourceInfoPadding??void 0,sourceIndents:e.attrs.sourceIndents??void 0}}}),r.thematicBreak&&(t.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),r.hardBreak&&(t.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle}})),r.list&&(t.list=rR(`list`,e=>({ordered:e.attrs.ordered??!1,start:e.attrs.ordered?e.attrs.start??1:null,spread:e.attrs.spread??!1,data:{bulletMarker:e.attrs.bulletMarker,listMarkerDelimiter:e.attrs.listMarkerDelimiter}}))),r.listItem&&(t.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&KQ(r[0])?r.slice(1):r,a={};return typeof e.attrs.sourceMarkerSpacing==`number`&&(a.sourceMarkerSpacing=e.attrs.sourceMarkerSpacing),typeof e.attrs.sourceOrdinal==`number`&&(a.sourceOrdinal=e.attrs.sourceOrdinal),e.attrs.sourceCheckboxChar===`X`&&(a.sourceCheckboxChar=`X`),typeof e.attrs.sourceContinuationIndent==`number`&&(a.sourceContinuationIndent=e.attrs.sourceContinuationIndent),{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,...Object.keys(a).length>0?{data:a}:{},children:i}}),r.table&&(t.table=(e,t,n)=>{let r=n.all(e),i=[],a=e.firstChild;a&&a.forEach(e=>{let t=e.attrs.align;i.push(t===`left`||t===`right`||t===`center`?t:null)});let o=r.filter(e=>e.type===`tableRow`),s=e.attrs.sourceDashCounts,c={};Array.isArray(s)&&s.length>0&&(c.sourceDashCounts=s);let l=e.attrs.sourceOuterPipes;typeof l==`object`&&l&&typeof l.leading==`boolean`&&typeof l.trailing==`boolean`&&(c.sourceOuterPipes=l);let u=e.attrs.sourceAlignmentPadding;Array.isArray(u)&&u.length>0&&(c.sourceAlignmentPadding=u);let d=Object.keys(c).length>0?c:void 0,f={type:`table`,align:i,children:o};return d&&(f.data=d),f}),r.tableRow&&(t.tableRow=rR(`tableRow`));let a=e=>{let t=e.attrs.sourcePadding,n={};return typeof t==`object`&&t&&typeof t.left==`number`&&typeof t.right==`number`&&(n.sourcePadding=t),Object.keys(n).length>0?{data:n}:{}};if(r.tableCell&&(t.tableCell=rR(`tableCell`,a)),r.tableHeader&&(t.tableHeader=rR(`tableCell`,a)),r.image&&(t.image=e=>({type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title})),r.imageReference&&(t.imageReference=e=>{let t=e.attrs.label??``,n=e.attrs.identifier??t;return{type:`imageReference`,alt:e.attrs.alt??``,identifier:n,label:t||n,referenceType:e.attrs.referenceType??`shortcut`}}),r.htmlBlock&&(t.htmlBlock=e=>({type:`html`,value:e.attrs.content})),r.linkDefinition??r.linkRefDef){let e=r.linkDefinition?`linkDefinition`:`linkRefDef`;t[e]=e=>{let t={},n=e.attrs.sourceLayout;(n===`multiline`||n===`inline`)&&(t.sourceLayout=n);let r=e.attrs.sourceTitleMarker;(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r);let i={type:`definition`,identifier:e.attrs.identifier??e.attrs.label??``,label:e.attrs.label??e.attrs.identifier??``,url:e.attrs.url??e.attrs.href??``,title:e.attrs.title};return Object.keys(t).length>0&&(i.data=t),i}}if(r.jsxComponent&&(t.jsxComponent=(e,t,n)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let r=e.attrs.componentName||null,i=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!GQ(e)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:r,attributes:i,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:HQ.getOrWildcard(r??`*`).serialize(e,{all:e=>n.all(e),registry:HQ,serializeChildren:()=>{throw Error(`SerializeContext.serializeChildren is not available in the PM→mdast handler. Compat descriptors that need markdown-byte body rendering must emit a marker mdast node and let the to-markdown handler render the body via state.containerFlow.`)}})}),r.rawMdxFallback&&(t.rawMdxFallback=e=>{let t=e.textContent??``,n=typeof e.attrs.reason==`string`?e.attrs.reason:``,r=e.attrs.originalSpan;return{type:`rawMdxFallback`,value:t,data:{reason:n,originalSpan:r&&typeof r==`object`&&`start`in r&&`end`in r?{start:Number(r.start)||0,end:Number(r.end)||0}:{start:0,end:0}}}}),r.jsxInline&&(t.jsxInline=e=>{let t=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:null,attributes:[],children:[],data:{sourceRaw:String(t)}}}),r.mathInline&&(t.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;if(typeof n==`string`&&n.length>0)return{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]};let r=e.attrs.sourceDelimiter;return{type:`inlineMath`,value:t,...typeof r==`string`&&r.length>0?{data:{sourceDelimiter:r}}:{}}}),r.wikiLink&&(t.wikiLink=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLink`,value:i,data:{target:t,anchor:n,alias:r,sourceTarget:typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,sourceAnchor:typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,sourceAlias:typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null},children:[{type:`text`,value:i}]}}),r.tag&&(t.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),r.wikiLinkEmbed&&(t.wikiLinkEmbed=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),i.emphasis&&(n.emphasis=iR(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.strong&&(n.strong=iR(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.code&&(n.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return JQ(n,{sourceFenceChar:r,sourceFenceLength:i,sourcePadded:e.attrs.sourcePadded===!0?!0:void 0})}),i.strike??i.delete){let e=i.strike?`strike`:`delete`;n[e]=iR(`delete`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter===`~`?`~`:`~~`}}))}return i.highlight&&(n.highlight=iR(`mark`)),i.comment&&(n.comment=iR(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),r.commentBlock&&(t.commentBlock=rR(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),r.footnoteReference&&(t.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),r.footnoteDefinition&&(t.footnoteDefinition=rR(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),i.link&&(n.link=(e,t,n)=>{if(e.attrs.sourceForm===`wikiembed`){let t=typeof e.attrs.target==`string`&&e.attrs.target.length>0?e.attrs.target:e.attrs.href??``,r=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,i=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,a=i||(r?`${t}#${r}`:t),o=n.map(e=>`value`in e&&typeof e.value==`string`?e.value:``).join(``);return o!==a&&o.trim().length>0&&!o.includes(`]]`)&&(i=o,a=o),{type:`wikiLinkEmbed`,value:a,data:{target:t,anchor:r,alias:i},children:[{type:`text`,value:a}]}}let r=e.attrs.linkStyle;if(r===`autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`autolink`}};if(r===`gfm-autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`gfm-autolink`}};if(r===`inline`||!r){let t={};e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let r=e.attrs.sourceTitleMarker;return(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),{type:`link`,url:e.attrs.href??``,title:e.attrs.title??null,children:n,...Object.keys(t).length>0?{data:t}:{}}}return{type:`linkReference`,identifier:(e.attrs.refLabel??``).toLowerCase(),label:e.attrs.refLabel,referenceType:r,children:n}}),i.escapeMark&&(n.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data??={},t.data.escapedChars??=[];for(let e=0;e<t.value.length;e++)t.data.escapedChars.push({offset:e,char:t.value[e]})}return n.length===1?n[0]:n}),i.sourceLiteral&&(n.sourceLiteral=(e,t,n)=>{let r=typeof e.attrs.sourceRaw==`string`?e.attrs.sourceRaw:``;if(n.length===1&&n[0]?.type===`text`){let e=n[0],t=r||e.value;return bq(t,e.value)&&(e.data??={},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:t,markHandlers:n}}const $Q=/\p{M}+/gu,e$=/[^\p{L}\p{N}]+/gu,t$=/^-+|-+$/g;function n$(e){return e.trim().normalize(`NFKD`).replace($Q,``).toLowerCase().replace(e$,`-`).replace(t$,``)}function r$(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function i$(e,t){let n=n$(e);return n?r$(n,t):``}const a$=new Set([`img`,`video`,`audio`,`mark`]);new Map(dY.flatMap(e=>e.surface===`compat`&&a$.has(e.rendersAs)?[[e.name,e]]:[])),dF(`<>`);const o$=qB(),s$=dB(),c$=fB();function l$(){return dY.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function u$(){return l$().filter(e=>d$(e)!==`fence`)}function d$(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function f$(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:d$(e)}}function p$(e){if(e.hidden!==!0&&e.type!==`reactnode`){if(`defaultValue`in e&&e.defaultValue!==void 0)return e.defaultValue;if(e.type===`enum`)return e.enumValues[0];if(e.type===`string`)return``;if(e.type===`number`)return 0;if(e.type===`boolean`)return!1}}function m$(e,t){return!(e.omitOnDefault===!0&&`defaultValue`in e&&Object.is(e.defaultValue,t)||e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&t===``)}function h$(e){let t=[];for(let n of e.props){let e=p$(n);e!==void 0&&m$(n,e)&&t.push(wJ(n.name,e))}return t}function g$(e){return yz(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[o$],mdastExtensions:[s$]}).children}function _$(e){let t=d$(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
|
|
444
444
|
A --> B`};else{let r=h$(e),i=t===`jsx-block`?g$(e):[];n={type:`mdxJsxFlowElement`,name:e.name,attributes:r,children:i}}return fP({type:`root`,children:[n]},{extensions:[c$]}).trimEnd()}function v$(e){let t=[];for(let n of e.props){if(n.hidden===!0)continue;let e={name:n.name,type:n.type,required:n.required};n.description!==void 0&&(e.description=n.description),n.advanced===!0&&(e.advanced=!0),n.omitOnDefault===!0&&(e.omitOnDefault=!0),n.type===`enum`&&(e.values=n.enumValues,n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue)),n.type===`string`&&(n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.language!==void 0&&(e.language=n.language),n.accept!==void 0&&(e.accept=n.accept)),n.type===`boolean`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.type===`number`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),t.push(e)}return t}function y$(e){return{...f$(e),example:_$(e),params:v$(e)}}function b$(){return[``,"**Custom canonical components.** OK `.md` / `.mdx` supports the JSX components below — use whichever is semantically useful in any part of the doc. For full source syntax + parameter schemas, call `palette({ components: [ids] })` with the ids you want to use. Fenced code blocks render naturally and don't need a fetch — including ` ```mermaid ` for diagrams (mermaid label text has sharp edges — `palette({ components: [\"Mermaid\"] })` lists them; parse failures come back as `warnings` entries on write/edit) and ` ```html preview ` for interactive HTML/JS/CSS pages (the fence info-string `preview` token renders the block as a live iframe; works for `html` / `htm` / `xml`; optional `h=` / `w=` tokens set size, e.g. ` ```html preview h=400px `). Use ` ```html preview ` whenever you want anything interactive or JS-powered (charts, demos, calculators, animations) — just author the standalone HTML page in the fence. Call `palette` for the markdown-native component forms (write `> [!NOTE]`, not `<Callout>`), copy-ready themed `html preview` starters, and the theme tokens (`var(--chart-1)`, `var(--foreground)`, …) an embed should reference so it tracks the reader's light/dark theme. Arbitrary `<TagName>` JSX falls through as raw MDX when no canonical fits.",``,...u$().map(f$).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
|
|
445
|
-
`)}const x$=N({docName:Uq,summary:Gq,content:k().optional(),...Wq}).loose(),S$=N({docName:Uq,summary:Gq,markdown:k(),position:P([`append`,`prepend`,`replace`]).optional(),extension:P([`.md`,`.mdx`]).optional(),...Wq}).loose(),C$=N({docName:Uq,summary:Gq,find:k().min(1),replace:k(),offset:A().int().nonnegative().optional(),...Wq}).loose(),w$=N({docName:Uq,connectionId:k().min(1),scope:P([`last`,`session`,`file`]).optional(),...Wq}).loose(),T$=N({value:k(),truncatedFrom:A().int().nonnegative().optional(),hint:k().optional()}).loose(),E$=$s(`kind`,[N({kind:F(`inline`),content:k()}),N({kind:F(`truncated`),byteLength:A().int().nonnegative(),hint:k()})]),D$=N({kind:F(`content-divergence`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),divergenceType:k().optional(),currentState:E$.optional(),hint:k().optional()}).loose(),O$=N({type:F(`orphan`),parentCandidates:M(k()),message:k()}).loose(),k$=N({kind:F(`disk-edit-reconciled`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),hint:k().optional()}).loose(),A$=$s(`kind`,[D$,k$]),j$=$s(`kind`,[D$,k$,N({kind:F(`mermaid-parse-error`),fenceIndex:A().int().positive(),fenceFirstLine:k(),message:k(),line:A().int().positive().optional()}).loose()]),M$=M(j$).min(1),N$=N({timestamp:k().min(1),summary:T$.optional(),warning:A$.optional(),warnings:M$.optional()}).loose(),P$=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:M(O$).optional(),summary:T$.optional(),warning:A$.optional(),warnings:M$.optional()}).loose(),F$=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:T$.optional(),warning:A$.optional(),warnings:M$.optional()}).loose(),I$=N({docName:k().min(1),scope:P([`last`,`session`]),undone:j()}).loose(),L$=N({docName:Uq,patch:rc(k(),Zs([zW,Bs()])),types:rc(k(),P(IW)).optional(),summary:Gq,...Wq}).loose(),R$=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:M(k()),summary:T$.optional(),warning:A$.optional(),warnings:M$.optional()}).loose(),z$=N({entries:M(N({level:P([`info`,`warn`,`error`]),message:k().max(8192),event:k().optional(),fields:rc(k(),Ws()).optional(),ts:A().optional(),sourceId:k().optional(),lineNumber:A().optional()}).loose()).max(100)}).loose(),B$=N({accepted:A().int().min(0)}).loose(),V$=N({status:k().min(1),reason:k()}).loose(),H$=N({docName:k().min(1),content:k(),lifecycle:V$.nullable()}).loose(),U$=N({documents:M(N({kind:P([`document`,`asset`,`folder`]).default(`document`),docName:k().min(1).optional(),docExt:k().min(1).default(`.md`),size:A().int().nonnegative(),modified:k().min(1),isSymlink:j().default(!1),canonicalDocName:k().nullable().default(null),targetPath:k().nullable().default(null),path:k().min(1).optional(),assetExt:k().min(1).optional(),mediaKind:P([`image`,`video`,`audio`,`pdf`,`text`]).nullable().optional(),referencedBy:M(k().min(1)).optional(),hasChildren:j().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName)`})),truncated:j().optional()}).loose(),W$=N({source:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),G$=N({docName:k().min(1),backlinks:M(W$)}).loose(),K$=N({counts:rc(k().min(1),A().int().nonnegative())}).loose(),q$=$s(`kind`,[N({kind:F(`doc`),docName:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),N({kind:F(`external`),url:k().min(1),title:k(),snippet:k().nullable()}).loose()]),J$=N({docName:k().min(1),forwardLinks:M(q$)}).loose(),Y$=$s(`kind`,[N({id:k().min(1),kind:F(`doc`),docName:k().min(1),anchor:k().nullable(),label:k(),cluster:k().nullable(),category:k().nullable(),tags:M(k()).nullable()}).loose(),N({id:k().min(1),kind:F(`external`),url:k().min(1),label:k()}).loose()]),X$=N({source:k().min(1),target:k().min(1)}).loose(),Z$=N({nodes:M(Y$),links:M(X$)}).loose(),Q$=N({ts:A().int().min(0),url:k(),method:k(),ua:k().optional(),origin:k().optional(),referer:k().optional(),host:k().optional(),remote:k().optional(),secChUa:k().optional(),secChUaMobile:k().optional(),secChUaPlatform:k().optional(),secFetchSite:k().optional(),secFetchDest:k().optional(),secFetchMode:k().optional(),secFetchUser:k().optional()}).loose(),$$=N({app:Zs([F(`cursor`),F(`codex`),F(`claude`),Bs()]),signals_fired:M(k())}).loose(),e1=N({entries:M(Q$),count:A().int().min(0),detection:$$}).loose(),t1=N({writers:M(N({id:k().min(1),name:k().optional(),email:k().optional()}).loose()).optional(),summary:Gq,...Wq}).loose(),n1=N({checkpointRef:k().min(1)}).loose(),r1=N({v:A().int().optional(),id:k().min(1),name:k().min(1),colorSeed:k().optional(),docs:M(k()),summaries:M(k()).optional()}).loose(),i1=N({entries:M(N({sha:k().min(1),timestamp:k().min(1),author:k(),authorEmail:k(),type:P([`checkpoint`,`wip`,`upstream`,`park`]),message:k(),contributors:M(r1),checkpoint:Ws().nullable()}).loose()),total:A().int().nonnegative().optional(),truncated:j().optional()}).loose(),a1=N({sha:k().regex(/^[0-9a-f]{40}$/i),content:k(),timestamp:k(),author:k()}).loose(),o1=N({contentDir:k().min(1),pathSeparator:P([`/`,`\\`]),symlinkResolved:j()}).loose(),s1=M($s(`source`,[N({docName:k().min(1),timestamp:k().min(1),size:A().int().nonnegative(),source:F(`flat`)}).loose(),N({docName:k().min(1),timestamp:k().min(1),source:F(`timeline`),sha:k().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),c1=N({orphans:M(N({docName:k().min(1),title:k()}).loose())}).loose(),l1=N({hubs:M(N({docName:k().min(1),title:k(),count:A().int().nonnegative()}).loose())}).loose(),u1=N({source:k().min(1),title:k(),snippet:k().nullable()}).loose(),d1=N({deadLinks:M(N({target:k().min(1),sources:M(u1)}).loose())}).loose(),f1=N({target:N({docName:k().min(1),title:k(),aliases:M(k())}).loose(),mentions:M(N({source:k().min(1),excerpt:k(),offset:A().int().nonnegative()}).loose()),truncated:j()}).loose(),p1=N({projectPath:k().min(1)}).loose(),m1=P([`not-a-git-worktree`,`init-failed`]),h1=$s(`ok`,[N({ok:F(!0),projectPath:k().min(1)}).loose(),N({ok:F(!1),reason:m1,message:k().min(1)}).loose()]),g1=N({host:k().min(1).optional()}).loose(),_1=N({key:k().min(1)}).loose(),v1=N({keyPresent:j()}).loose(),y1=N({name:k().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:k().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),b1=N({authenticated:j()}).loose(),x1=N({}).loose(),S1=N({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),C1=N({docName:k().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:M(S1)}).loose(),w1=N({displayName:k().min(1),color:k().min(1),icon:k().optional(),connectionId:k().min(1)}).loose(),T1=N({sessionAlive:j(),agent:w1.nullable(),files:M(C1)}).loose(),E1=N({diff:k(),generatedAt:A().int().min(0)}).loose(),D1=N({}).loose(),O1=N({}).loose(),k1=N({}).loose(),A1=N({}).loose(),j1=N({}).loose(),M1=N({}).loose(),N1=N({displayName:k().min(1),icon:k(),color:k().min(1),currentDoc:k().nullable(),mode:P([`idle`,`writing`]),ts:A().int().min(0)}).loose(),P1=N({presence:rc(k().min(1),N1)}).loose(),F1=rc(k().min(1),j()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});N({path:k().min(1,`path must be non-empty`)}).loose();const I1=N({}).loose(),L1=N({fromDocName:k().min(1),toDocName:k().min(1)}).loose(),R1=N({fromPath:k().min(1),toPath:k().min(1)}).loose(),z1=N({}).loose(),B1=N({path:k().min(1),...Wq,summary:Gq}).loose(),V1=N({docName:k().min(1)}).loose(),H1=N({path:k().min(1),...Wq,summary:Gq}).loose(),U1=N({path:k().min(1)}).loose(),W1=N({kind:P([`file`,`folder`]),path:k().min(1),...Wq,summary:Gq}).loose(),G1=N({kind:P([`file`,`folder`]),path:k().min(1),duplicatedDocNames:M(k().min(1))}).loose(),K1=N({pages:M(N({docName:k().min(1),title:k(),docExt:k().min(1),size:A().int().nonnegative(),modified:k().min(1),icon:k().min(1).max(2048).optional()}).loose())}).loose(),q1=N({level:A().int().min(1).max(6),text:k(),slug:k()}).loose(),J1=N({docName:k().min(1),headings:M(q1)}).loose(),Y1=N({docName:k().min(1),rewrites:A().int().nonnegative()}).loose(),X1=N({kind:P([`file`,`folder`,`asset`]),fromPath:k().min(1),toPath:k().min(1),...Wq,summary:Gq}).loose(),Z1=N({renamed:M(L1),renamedAssets:M(R1),rewrittenDocs:M(Y1).optional(),summary:T$.optional()}).loose(),Q1=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...Wq}).loose(),$1=N({deletedDocNames:M(k().min(1))}).loose(),e0=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...Wq,summary:Gq}).loose(),t0=N({deletedDocNames:M(k().min(1))}).loose(),n0=N({docName:k().min(1),commitSha:k().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:Gq,...Wq}).loose(),r0=N({restoredFrom:k().min(1),timestamp:k().min(1),summary:T$.optional(),warning:D$.optional(),warnings:M$.optional()}).loose(),i0=P([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),a0=N({label:k().min(1),webUrl:ys().nullable()}).loose(),o0=$s(`checkStatus`,[N({checkStatus:F(`allowed`)}).loose(),N({checkStatus:F(`denied`),deniedReason:P([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),N({checkStatus:F(`unknown`),unknownError:P([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),s0=P([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),c0=N({state:i0,lastSyncUtc:k().nullable(),lastFetchUtc:k().nullable(),lastPushedSha:k().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:j(),syncEnabled:j(),identityUnresolved:j(),remote:a0.nullable().optional(),pushError:k().optional(),pushErrorCode:s0.optional(),pullError:k().optional(),pullErrorCode:s0.optional(),pausedReason:k().optional(),pushPermission:o0.optional()}).loose(),l0=N({op:P([`sync`,`push`,`pull`]).optional()}).loose(),u0=N({op:P([`sync`,`push`,`pull`])}).loose(),d0=N({conflicts:M(N({file:k().min(1),detectedAt:k().min(1),oursSha:k().optional(),theirsSha:k().optional(),baseSha:k().optional()}).loose())}).loose(),f0=N({file:k().min(1),strategy:P([`mine`,`theirs`,`content`,`delete`]),content:k().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),p0=N({}).loose(),m0=N({file:k().min(1),base:k(),ours:k(),theirs:k(),kind:P([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:k().nullable()}).loose(),h0=N({plan:kc(e=>e!==void 0,{message:`plan is required`})}).loose(),g0=N({plan:kc(e=>e!==void 0,{message:`plan is required`})}).loose(),_0=N({result:kc(e=>e!==void 0,{message:`result is required`})}).loose(),v0=N({path:k().min(1),summary:k().min(1)}).loose(),y0=N({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),b0=N({packs:M(N({id:k().min(1),name:k().min(1),description:k().min(1),defaultSubfolder:k().optional(),folders:M(v0),entryCounts:y0}).loose())}).loose(),x0=N({noOpen:j().optional(),out:k().min(1).optional()}).loose(),S0=N({reason:P([`unsupported-platform`,`spawn-error`]),message:k()}).loose(),C0=$s(`status`,[N({status:F(`installed`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k()}).loose(),N({status:F(`built`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k(),handoffError:S0.optional()}).loose(),N({status:F(`failed`),buildError:k()}).loose(),N({status:F(`skip-current`),skillVersion:k(),recordedAt:k().optional()}).loose()]),w0=N({tags:M(N({name:k().min(1),count:A().int().nonnegative(),isLeaf:j()}).loose())}).loose(),T0=N({docName:k().min(1),title:k(),matchingTags:M(k().min(1)),snippet:k().nullable()}).loose(),E0=N({name:k().min(1),docs:M(T0)}).loose(),D0=N({folder:Ws(),frontmatter_local:rc(k(),Ws()).nullable()}).loose(),O0=N({path:k(),frontmatter:rc(k(),Ws()).optional()}).loose(),k0=N({applied:Ws()}).loose(),A0=rc(k(),Ws()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),j0=N({template:N({name:k().min(1),folder:k(),scope:P([`local`,`inherited`]),path:k().min(1),frontmatter:A0,body:k()}).strict()}).strict(),M0=N({templates:M(N({name:k().min(1),title:k().optional(),description:k().optional(),path:k().min(1),source_folder:k()}).strict()),truncated:j()}).strict(),N0=N({folder:k(),name:k(),body:k().optional(),frontmatter:A0.optional(),...Wq,summary:Gq}).strict(),P0=N({path:k().min(1),created:j(),warnings:M(k())}).strict(),F0=N({existed:j(),path:k().min(1)}).strict(),I0=N({fromFolder:k(),fromName:k(),toFolder:k(),toName:k(),body:k().optional(),frontmatter:A0.optional(),...Wq,summary:Gq}).strict(),L0=N({from:k().min(1),to:k().min(1),committed:j()}).strict(),R0=N({query:k().optional(),intent:P([`autocomplete`,`full_text`,`omnibar`]).optional(),scopes:M(P([`page`,`folder`,`content`])).optional(),scope:k().optional(),limit:A().int().nonnegative().optional(),semantic:j().optional(),source:P([`omnibar`,`mcp`,`http`]).optional()}).loose(),z0=N({kind:P([`page`,`folder`,`content`]),path:k().min(1),title:k(),score:A(),signals:rc(k(),Ws()),snippet:k().optional()}).loose(),B0=N({capable:j(),applied:j(),coverage:N({embedded:A().int().nonnegative(),total:A().int().nonnegative()})}).loose(),V0=N({enabled:j(),keyPresent:j(),keySource:P([`file`,`env`]).nullable(),keyHint:k().nullable(),ready:j(),capable:j(),embedded:A().int().nonnegative(),total:A().int().nonnegative()}).loose(),H0=N({query:k(),intent:P([`autocomplete`,`full_text`,`omnibar`]),results:M(z0),elapsedMs:A().nonnegative(),semantic:B0.optional()}).loose(),U0=N({version:k().min(1),recordedAt:k().min(1)}).loose(),W0=N({currentVersion:k().min(1),targets:rc(k(),U0.nullable())}).loose(),G0=`server-info`,K0=`branch-switched`,q0=`disk-ack`,J0=`config-validation-rejected`,Y0=`config-ignore-nested-error`,X0=P([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),Z0=N({v:F(1),ch:F(G0),seq:A(),serverInstanceId:k().min(1),currentBranch:k().min(1).optional()}).loose(),Q0=N({v:F(1),ch:F(K0),seq:A(),branch:k().min(1)}).loose(),$0=N({v:F(1),ch:X0,seq:A()}).loose(),e2=N({v:F(1),ch:F(q0),seq:A(),docName:k().min(1),sv:k().min(1)}).loose(),t2=N({v:F(1),ch:F(J0),seq:A(),docName:k().min(1),error:ll}).loose(),n2=N({v:F(1),ch:F(Y0),seq:A(),path:k().min(1),error:k().min(1)}).loose(),r2={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},i2=new WeakMap;function a2(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function o2(e){return e.trim().toLowerCase()}function s2(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function c2(e){return e.split(`/`).filter(Boolean).join(` `)}function l2(e){let t=s2(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0;return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:c2(e.path),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function u2(e){let t=LU({schema:r2});return e.length>0&&JU(t,e),t}function d2(e){let t={documents:e};return i2.set(t,u2(e)),t}function f2(e){let t=i2.get(e);if(t)return t;let n=u2(e.documents);return i2.set(e,n),n}function p2(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`]:[`page`,`folder`]}function m2(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function h2(e,t){let n=o2(t);if(!n)return 0;let r=o2(e.title),i=o2(e.name),a=o2(e.path),o=a.split(`/`);return r===n||i===n?700:a===n?650:r.startsWith(n)||i.startsWith(n)?600:o.some(e=>e.startsWith(n))?550:r.includes(n)||i.includes(n)?500:a.includes(n)?450:-1}function g2(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 _2(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function v2(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 y2(e,t){return o2(t).length<4?0:e===`full_text`?1:0}function b2(e,t,n={}){let r=n.intent??`omnibar`,i=a2(n.limit),a=new Set(n.scopes??p2(r)),o=e.documents.filter(e=>m2(e,a)),s=o2(t);if(!s)return o.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,i).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let c=wW(f2(e),{term:s,properties:_2(r),boost:v2(r),tolerance:y2(r,s),limit:Math.max(i*4,40)}),l=new Map(c.hits.filter(e=>m2(e.document,a)).map(e=>[e.document.id,e.score])),u=g2(o),d=new Map;for(let e of o)h2(e,s)>=0&&d.set(e.id,e);for(let e of c.hits)m2(e.document,a)&&d.set(e.document.id,e.document);return n.semantic?S2({scopedDocuments:o,candidates:d,fullTextScores:l,recency:u,normalizedQuery:s,semantic:n.semantic,limit:i}):[...d.values()].map(e=>{let t=Math.max(0,h2(e,s)),n=l.get(e.id)??0,r=u.get(e.id)??0;return{document:e,score:t+n*20+r,signals:{lexical:t,fullText:n,recency:r}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score).slice(0,i)}function x2(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function S2(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,semantic:o,limit:s}=e,c=o.rrfK??60,l=o.candidateLimit??64,u=o.similarityFloor??0,d=o.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=[...n.values()].map(e=>{let t=Math.max(0,h2(e,a)),n=r.get(e.id)??0,o=i.get(e.id)??0,s=d.get(e.id),c=s!==void 0&&s>=u;return{document:e,score:t+n*20+o,signals:c?{lexical:t,fullText:n,recency:o,vector:s}:{lexical:t,fullText:n,recency:o},lexical:t,fullText:n,recency:o,cosine:s}}),h=x2(m.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),g=x2(m.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)),_=e=>{let t=0,n=h.get(e);n!==void 0&&(t+=1/(c+n));let r=g.get(e);return r!==void 0&&(t+=1/(c+r)),t};return m.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=_(e.document.id),a=_(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})).slice(0,s)}function C2(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),w2(n)}function w2(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 T2=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),E2=globalThis;E2[T2]===void 0&&(E2[T2]=Ii());const D2=E2[T2],O2=[`.ok`,`skill-state.yml`],k2=[`claude-cowork`,`cli-hosts`],A2=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],j2=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,M2=Ys({version:k().regex(j2,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(D2,{description:`Recorded skill version for this target.`}),recordedAt:Uo().register(D2,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:P(A2).register(D2,{description:`Install-source surface that recorded this entry.`}).optional()}),N2=Ys({schema:F(1).register(D2,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Ys({"claude-cowork":M2.optional(),"cli-hosts":M2.optional()}).register(D2,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function P2(){return{schema:1,targets:{}}}function F2(){let e=!1,t=``,n=0;return r=>{let i=I2(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 I2(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 L2=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],R2={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function z2(e,t=L2){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const B2={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function V2(e){return e?B2[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const H2={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function U2(e){let t=e?.trim();return t?H2[V2(t)]??t:`Agent`}function W2(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 G2=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function K2(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function q2(e){let t=e.trim();return G2.test(t)||t.startsWith(`//`)}function J2(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(q2(n))return{kind:`external`,url:n};let r=W2(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=K2(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function Y2(e,t){let n=e.trim();if(!n)return null;if(q2(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=K2(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function X2(e,t){let n=e.trim();if(!n||G2.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 Z2(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function Q2(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function $2(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function e4(e){return e.split(`/`).filter(e=>e!==``)}function t4(e,t){let n=$2(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function n4(e,t){let n=$2(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:e4(r).length}function r4(e,t){let n=e4(e),r=e4(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function i4(){let e=new Map;function t(t){let n=Z2(t);if(n===``)return;let r=Q2(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=Z2(t),r=Q2(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=$2(Z2(n)),o=[],s=[];for(let e of i)t4(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=n4(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=n4(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=r4(a,$2(t));for(let r=1;r<e.length;r++){let i=e[r],o=r4(a,$2(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 a4(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 o4(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 s4(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function c4(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function l4(){try{let e=_(g(b(import.meta.url)),`..`,`package.json`),t=JSON.parse(d(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const u4=l4(),d4=1;var f4=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${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 p4(e,t){return _(e,`${t}.lock`)}const m4=new Map;function h4(e){m4.set(e,(m4.get(e)??0)+1)}function g4(e){let t=m4.get(e);return t===void 0||t<=1?(m4.delete(e),!0):(m4.set(e,t-1),!1)}function _4(e,t){try{let n=JSON.parse(d(e,`utf-8`));return n&&typeof n==`object`&&c4(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 v4(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;l(n,{recursive:!0});let a=p4(n,t),o={pid:process.pid,hostname:y(),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??u4},d=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!c(a))try{let e=u(a,`wx`,384);try{m(e,d)}finally{s(e)}return h4(a),y4({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=_4(a,i);if(e){let r=e.hostname===y();if(r&&e.pid===process.pid)return p(a,d,{encoding:`utf-8`,mode:384}),h4(a),y4({lockName:t,lockDir:n,lockPath:a});if(r&&s4(e.pid))throw new f4(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{f(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function y4(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>C4({lockName:t,lockDir:n}),updatePort:e=>b4({lockName:t,lockDir:n,port:e})}}function b4(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=p4(n,t);if(!c(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(d(a,`utf-8`));if(!e||typeof e!=`object`||!c4(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!==y())){o.port=r;try{p(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 x4(e){let{lockName:t,lockDir:n}=e,r=p4(n,t);if(!c(r))return null;let i;try{let e=JSON.parse(d(r,`utf-8`));if(!e||typeof e!=`object`||!c4(e.pid))return null;i=e}catch{return null}if(i.hostname!==y())return null;if(!s4(i.pid)){try{f(r)}catch{}return null}return i}function S4(e){let{lockName:t,lockDir:n}=e,r=p4(n,t);if(!c(r))return{status:`absent`};let i;try{i=JSON.parse(d(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(!c4(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!==y())return{status:`stale`,lock:o};if(!s4(o.pid)){try{f(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 C4(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=p4(n,t);if(g4(i)&&c(i))try{let e=JSON.parse(d(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==y())return;f(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var w4=class extends f4{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function T4(e,t){try{return v4({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof f4&&e.lockName===`server`?new w4(e.existing,e.lockPath):e}}function E4(e,t){b4({lockName:`server`,lockDir:e,port:t})}function D4(e){return x4({lockName:`server`,lockDir:e})}function O4(e){C4({lockName:`server`,lockDir:e})}export{WG as $,Mc as $i,j0 as $n,WW as $r,M1 as $t,N$ as A,Sl as Ai,V0 as An,ZW as Ar,R$ as At,$0 as B,P as Bi,I1 as Bn,i$ as Br,FK as Bt,C$ as C,Bc as Ci,n1 as Cn,i4 as Cr,e1 as Ct,S$ as D,yl as Di,_0 as Dn,l2 as Dr,k0 as Dt,I$ as E,wl as Ei,g0 as En,d2 as Er,O0 as Et,cG as F,$c as Fi,$q as Fn,a4 as Fr,bK as Ft,J0 as G,kc as Gi,f0 as Gn,VW as Gr,b1 as Gt,Z0 as H,Hs as Hi,f1 as Hn,jq as Hr,x1 as Ht,pG as I,Kc as Ii,nJ as In,zq as Ir,x0 as It,VG as J,F as Ji,l0 as Jn,aJ as Jr,_1 as Jt,q0 as K,$s as Ki,p0 as Kn,Vq as Kr,xJ as Kt,Q0 as L,qc as Li,iJ as Ln,oG as Lr,C0 as Lt,K$ as M,ul as Mi,qq as Mn,IG as Mr,i1 as Mt,G$ as N,_l as Ni,Yq as Nn,P2 as Nr,a1 as Nt,P$ as O,Jc as Oi,b0 as On,AG as Or,J$ as Ot,lJ as P,nl as Pi,eJ as Pn,C2 as Pr,l1 as Pt,HG as Q,lc as Qi,F0 as Qn,qW as Qr,P1 as Qt,n2 as R,Fs as Ri,W0 as Rn,BQ as Rr,F1 as Rt,E1 as S,ft as Sa,Vc as Si,t1 as Sn,z2 as Sr,gK as St,w$ as T,Tl as Ti,H0 as Tn,CZ as Tr,D0 as Tt,K0 as U,M as Ui,m0 as Un,V2 as Ur,g1 as Ut,e2 as V,Bs as Vi,SJ as Vn,yY as Vr,Z$ as Vt,Y0 as W,j as Wi,d0 as Wn,sJ as Wr,y1 as Wt,KG as X,A as Xi,E0 as Xn,uG as Xr,h1 as Xt,RG as Y,Ys as Yi,u0 as Yn,IK as Yr,p1 as Yt,GG as Z,N as Zi,w0 as Zn,OG as Zr,VQ as Zt,R2 as _,Lt as _a,I as _i,O2 as _n,aG as _r,U$ as _t,v4 as a,Uo as aa,W2 as ai,LG as an,A1 as ar,H1 as at,j$ as b,D as ba,Hc as bi,nK as bn,Y2 as br,G1 as bt,c4 as c,Wa as ca,Fq as ci,mJ as cn,D1 as cr,V1 as ct,S4 as d,vr as da,sG as di,Z1 as dn,ZG as dr,oK as dt,rc as ea,iK as ei,j1 as en,I0 as er,UG as et,D4 as f,cn as fa,n$ as fi,s1 as fn,bJ as fr,tK as ft,E4 as g,on as ga,Df as gi,vK as gn,MW as gr,$1 as gt,b4 as h,mn as ha,Ly as hi,yK as hn,NW as hr,Q1 as ht,w4 as i,ys as ia,X2 as ii,aK as in,M0 as ir,B$ as it,hJ as j,pl as ji,pJ as jn,U2 as jr,zW as jt,x$ as k,tl as ki,h0 as kn,kG as kr,L$ as kt,p4 as l,Ga as la,UW as li,vJ as ln,e0 as lr,xK as lt,O4 as m,fn as ma,Bq as mi,r0 as mn,o1 as mr,d1 as mt,u4 as n,Zs as na,eG as ni,c1 as nn,N0 as nr,fJ as nt,T4 as o,Vo as oa,b2 as oi,J1 as on,O1 as or,U1 as ot,C4 as p,un as pa,GW as pi,n0 as pn,yJ as pr,JG as pt,G0 as q,tc as qi,c0 as qn,eK as qr,v1 as qt,d4 as r,Ws as ra,b$ as ri,rK as rn,P0 as rr,z$ as rt,s4 as s,fa as sa,FG as si,K1 as sn,k1 as sr,B1 as st,f4 as t,k as ta,y$ as ti,$G as tn,L0 as tr,uJ as tt,x4 as u,ai as ua,o4 as ui,X1 as un,t0 as ur,QG as ut,YG as v,Tt as va,Cl as vi,k2 as vn,_J as vr,H$ as vt,F$ as w,zc as wi,R0 as wn,F2 as wr,z1 as wt,T1 as x,pt as xa,Uc as xi,BG as xn,zG as xr,XG as xt,_K as y,O as ya,Wc as yi,j2 as yn,J2 as yr,W1 as yt,t2 as z,cc as zi,N2 as zn,u$ as zr,qG as zt};
|
|
446
|
-
//# sourceMappingURL=server-lock-BpjJj3OD-
|
|
445
|
+
`)}const x$=N({docName:Uq,summary:Gq,content:k().optional(),...Wq}).loose(),S$=N({docName:Uq,summary:Gq,markdown:k(),position:P([`append`,`prepend`,`replace`]).optional(),extension:P([`.md`,`.mdx`]).optional(),...Wq}).loose(),C$=N({docName:Uq,summary:Gq,find:k().min(1),replace:k(),offset:A().int().nonnegative().optional(),...Wq}).loose(),w$=N({docName:Uq,connectionId:k().min(1),scope:P([`last`,`session`,`file`]).optional(),...Wq}).loose(),T$=N({value:k(),truncatedFrom:A().int().nonnegative().optional(),hint:k().optional()}).loose(),E$=$s(`kind`,[N({kind:F(`inline`),content:k()}),N({kind:F(`truncated`),byteLength:A().int().nonnegative(),hint:k()})]),D$=N({kind:F(`content-divergence`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),divergenceType:k().optional(),currentState:E$.optional(),hint:k().optional()}).loose(),O$=N({type:F(`orphan`),parentCandidates:M(k()),message:k()}).loose(),k$=N({kind:F(`disk-edit-reconciled`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),hint:k().optional()}).loose(),A$=$s(`kind`,[D$,k$]),j$=$s(`kind`,[D$,k$,N({kind:F(`mermaid-parse-error`),fenceIndex:A().int().positive(),fenceFirstLine:k(),message:k(),line:A().int().positive().optional()}).loose()]),M$=M(j$).min(1),N$=N({timestamp:k().min(1),summary:T$.optional(),warning:A$.optional(),warnings:M$.optional()}).loose(),P$=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:M(O$).optional(),summary:T$.optional(),warning:A$.optional(),warnings:M$.optional()}).loose(),F$=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:T$.optional(),warning:A$.optional(),warnings:M$.optional()}).loose(),I$=N({docName:k().min(1),scope:P([`last`,`session`]),undone:j()}).loose(),L$=N({docName:Uq,patch:rc(k(),Zs([zW,Bs()])),types:rc(k(),P(IW)).optional(),summary:Gq,...Wq}).loose(),R$=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:M(k()),summary:T$.optional(),warning:A$.optional(),warnings:M$.optional()}).loose(),z$=N({entries:M(N({level:P([`info`,`warn`,`error`]),message:k().max(8192),event:k().optional(),fields:rc(k(),Ws()).optional(),ts:A().optional(),sourceId:k().optional(),lineNumber:A().optional()}).loose()).max(100)}).loose(),B$=N({accepted:A().int().min(0)}).loose(),V$=N({status:k().min(1),reason:k()}).loose(),H$=N({docName:k().min(1),content:k(),lifecycle:V$.nullable()}).loose(),U$=N({documents:M(N({kind:P([`document`,`asset`,`folder`]).default(`document`),docName:k().min(1).optional(),docExt:k().min(1).default(`.md`),size:A().int().nonnegative(),modified:k().min(1),isSymlink:j().default(!1),canonicalDocName:k().nullable().default(null),targetPath:k().nullable().default(null),path:k().min(1).optional(),assetExt:k().min(1).optional(),mediaKind:P([`image`,`video`,`audio`,`pdf`,`text`]).nullable().optional(),referencedBy:M(k().min(1)).optional(),hasChildren:j().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName)`})),truncated:j().optional()}).loose(),W$=N({source:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),G$=N({docName:k().min(1),backlinks:M(W$)}).loose(),K$=N({counts:rc(k().min(1),A().int().nonnegative())}).loose(),q$=$s(`kind`,[N({kind:F(`doc`),docName:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),N({kind:F(`external`),url:k().min(1),title:k(),snippet:k().nullable()}).loose()]),J$=N({docName:k().min(1),forwardLinks:M(q$)}).loose(),Y$=$s(`kind`,[N({id:k().min(1),kind:F(`doc`),docName:k().min(1),anchor:k().nullable(),label:k(),cluster:k().nullable(),category:k().nullable(),tags:M(k()).nullable()}).loose(),N({id:k().min(1),kind:F(`external`),url:k().min(1),label:k()}).loose()]),X$=N({source:k().min(1),target:k().min(1)}).loose(),Z$=N({nodes:M(Y$),links:M(X$)}).loose(),Q$=N({ts:A().int().min(0),url:k(),method:k(),ua:k().optional(),origin:k().optional(),referer:k().optional(),host:k().optional(),remote:k().optional(),secChUa:k().optional(),secChUaMobile:k().optional(),secChUaPlatform:k().optional(),secFetchSite:k().optional(),secFetchDest:k().optional(),secFetchMode:k().optional(),secFetchUser:k().optional()}).loose(),$$=N({app:Zs([F(`cursor`),F(`codex`),F(`claude`),Bs()]),signals_fired:M(k())}).loose(),e1=N({entries:M(Q$),count:A().int().min(0),detection:$$}).loose(),t1=N({writers:M(N({id:k().min(1),name:k().optional(),email:k().optional()}).loose()).optional(),summary:Gq,...Wq}).loose(),n1=N({checkpointRef:k().min(1)}).loose(),r1=N({v:A().int().optional(),id:k().min(1),name:k().min(1),colorSeed:k().optional(),docs:M(k()),summaries:M(k()).optional()}).loose(),i1=N({entries:M(N({sha:k().min(1),timestamp:k().min(1),author:k(),authorEmail:k(),type:P([`checkpoint`,`wip`,`upstream`,`park`]),message:k(),contributors:M(r1),checkpoint:Ws().nullable()}).loose()),total:A().int().nonnegative().optional(),truncated:j().optional(),hasMore:j().optional()}).loose(),a1=N({sha:k().regex(/^[0-9a-f]{40}$/i),content:k(),timestamp:k(),author:k()}).loose(),o1=N({contentDir:k().min(1),pathSeparator:P([`/`,`\\`]),symlinkResolved:j()}).loose(),s1=M($s(`source`,[N({docName:k().min(1),timestamp:k().min(1),size:A().int().nonnegative(),source:F(`flat`)}).loose(),N({docName:k().min(1),timestamp:k().min(1),source:F(`timeline`),sha:k().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),c1=N({orphans:M(N({docName:k().min(1),title:k()}).loose())}).loose(),l1=N({hubs:M(N({docName:k().min(1),title:k(),count:A().int().nonnegative()}).loose())}).loose(),u1=N({source:k().min(1),title:k(),snippet:k().nullable()}).loose(),d1=N({deadLinks:M(N({target:k().min(1),sources:M(u1)}).loose())}).loose(),f1=N({target:N({docName:k().min(1),title:k(),aliases:M(k())}).loose(),mentions:M(N({source:k().min(1),excerpt:k(),offset:A().int().nonnegative()}).loose()),truncated:j()}).loose(),p1=N({projectPath:k().min(1)}).loose(),m1=P([`not-a-git-worktree`,`init-failed`]),h1=$s(`ok`,[N({ok:F(!0),projectPath:k().min(1)}).loose(),N({ok:F(!1),reason:m1,message:k().min(1)}).loose()]),g1=N({host:k().min(1).optional()}).loose(),_1=N({key:k().min(1)}).loose(),v1=N({keyPresent:j()}).loose(),y1=N({name:k().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:k().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),b1=N({authenticated:j()}).loose(),x1=N({}).loose(),S1=N({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),C1=N({docName:k().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:M(S1)}).loose(),w1=N({displayName:k().min(1),color:k().min(1),icon:k().optional(),connectionId:k().min(1)}).loose(),T1=N({sessionAlive:j(),agent:w1.nullable(),files:M(C1)}).loose(),E1=N({diff:k(),generatedAt:A().int().min(0)}).loose(),D1=N({}).loose(),O1=N({}).loose(),k1=N({}).loose(),A1=N({}).loose(),j1=N({}).loose(),M1=N({}).loose(),N1=N({displayName:k().min(1),icon:k(),color:k().min(1),currentDoc:k().nullable(),mode:P([`idle`,`writing`]),ts:A().int().min(0)}).loose(),P1=N({presence:rc(k().min(1),N1)}).loose(),F1=rc(k().min(1),j()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});N({path:k().min(1,`path must be non-empty`)}).loose();const I1=N({}).loose(),L1=N({fromDocName:k().min(1),toDocName:k().min(1)}).loose(),R1=N({fromPath:k().min(1),toPath:k().min(1)}).loose(),z1=N({}).loose(),B1=N({path:k().min(1),...Wq,summary:Gq}).loose(),V1=N({docName:k().min(1)}).loose(),H1=N({path:k().min(1),...Wq,summary:Gq}).loose(),U1=N({path:k().min(1)}).loose(),W1=N({kind:P([`file`,`folder`]),path:k().min(1),...Wq,summary:Gq}).loose(),G1=N({kind:P([`file`,`folder`]),path:k().min(1),duplicatedDocNames:M(k().min(1))}).loose(),K1=N({pages:M(N({docName:k().min(1),title:k(),docExt:k().min(1),size:A().int().nonnegative(),modified:k().min(1),icon:k().min(1).max(2048).optional()}).loose())}).loose(),q1=N({level:A().int().min(1).max(6),text:k(),slug:k()}).loose(),J1=N({docName:k().min(1),headings:M(q1)}).loose(),Y1=N({docName:k().min(1),rewrites:A().int().nonnegative()}).loose(),X1=N({kind:P([`file`,`folder`,`asset`]),fromPath:k().min(1),toPath:k().min(1),...Wq,summary:Gq}).loose(),Z1=N({renamed:M(L1),renamedAssets:M(R1),rewrittenDocs:M(Y1).optional(),summary:T$.optional()}).loose(),Q1=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...Wq}).loose(),$1=N({deletedDocNames:M(k().min(1))}).loose(),e0=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...Wq,summary:Gq}).loose(),t0=N({deletedDocNames:M(k().min(1))}).loose(),n0=N({docName:k().min(1),commitSha:k().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:Gq,...Wq}).loose(),r0=N({restoredFrom:k().min(1),timestamp:k().min(1),summary:T$.optional(),warning:D$.optional(),warnings:M$.optional()}).loose(),i0=P([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),a0=N({label:k().min(1),webUrl:ys().nullable()}).loose(),o0=$s(`checkStatus`,[N({checkStatus:F(`allowed`)}).loose(),N({checkStatus:F(`denied`),deniedReason:P([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),N({checkStatus:F(`unknown`),unknownError:P([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),s0=P([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),c0=N({state:i0,lastSyncUtc:k().nullable(),lastFetchUtc:k().nullable(),lastPushedSha:k().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:j(),syncEnabled:j(),identityUnresolved:j(),remote:a0.nullable().optional(),pushError:k().optional(),pushErrorCode:s0.optional(),pullError:k().optional(),pullErrorCode:s0.optional(),pausedReason:k().optional(),pushPermission:o0.optional()}).loose(),l0=N({op:P([`sync`,`push`,`pull`]).optional()}).loose(),u0=N({op:P([`sync`,`push`,`pull`])}).loose(),d0=N({conflicts:M(N({file:k().min(1),detectedAt:k().min(1),oursSha:k().optional(),theirsSha:k().optional(),baseSha:k().optional()}).loose())}).loose(),f0=N({file:k().min(1),strategy:P([`mine`,`theirs`,`content`,`delete`]),content:k().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),p0=N({}).loose(),m0=N({file:k().min(1),base:k(),ours:k(),theirs:k(),kind:P([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:k().nullable()}).loose(),h0=N({plan:kc(e=>e!==void 0,{message:`plan is required`})}).loose(),g0=N({plan:kc(e=>e!==void 0,{message:`plan is required`})}).loose(),_0=N({result:kc(e=>e!==void 0,{message:`result is required`})}).loose(),v0=N({path:k().min(1),summary:k().min(1)}).loose(),y0=N({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),b0=N({packs:M(N({id:k().min(1),name:k().min(1),description:k().min(1),defaultSubfolder:k().optional(),folders:M(v0),entryCounts:y0}).loose())}).loose(),x0=N({noOpen:j().optional(),out:k().min(1).optional()}).loose(),S0=N({reason:P([`unsupported-platform`,`spawn-error`]),message:k()}).loose(),C0=$s(`status`,[N({status:F(`installed`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k()}).loose(),N({status:F(`built`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k(),handoffError:S0.optional()}).loose(),N({status:F(`failed`),buildError:k()}).loose(),N({status:F(`skip-current`),skillVersion:k(),recordedAt:k().optional()}).loose()]),w0=N({tags:M(N({name:k().min(1),count:A().int().nonnegative(),isLeaf:j()}).loose())}).loose(),T0=N({docName:k().min(1),title:k(),matchingTags:M(k().min(1)),snippet:k().nullable()}).loose(),E0=N({name:k().min(1),docs:M(T0)}).loose(),D0=N({folder:Ws(),frontmatter_local:rc(k(),Ws()).nullable()}).loose(),O0=N({path:k(),frontmatter:rc(k(),Ws()).optional()}).loose(),k0=N({applied:Ws()}).loose(),A0=rc(k(),Ws()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),j0=N({template:N({name:k().min(1),folder:k(),scope:P([`local`,`inherited`]),path:k().min(1),frontmatter:A0,body:k()}).strict()}).strict(),M0=N({templates:M(N({name:k().min(1),title:k().optional(),description:k().optional(),path:k().min(1),source_folder:k()}).strict()),truncated:j()}).strict(),N0=N({folder:k(),name:k(),body:k().optional(),frontmatter:A0.optional(),...Wq,summary:Gq}).strict(),P0=N({path:k().min(1),created:j(),warnings:M(k())}).strict(),F0=N({existed:j(),path:k().min(1)}).strict(),I0=N({fromFolder:k(),fromName:k(),toFolder:k(),toName:k(),body:k().optional(),frontmatter:A0.optional(),...Wq,summary:Gq}).strict(),L0=N({from:k().min(1),to:k().min(1),committed:j()}).strict(),R0=N({query:k().optional(),intent:P([`autocomplete`,`full_text`,`omnibar`]).optional(),scopes:M(P([`page`,`folder`,`content`])).optional(),scope:k().optional(),limit:A().int().nonnegative().optional(),semantic:j().optional(),source:P([`omnibar`,`mcp`,`http`]).optional()}).loose(),z0=N({kind:P([`page`,`folder`,`content`]),path:k().min(1),title:k(),score:A(),signals:rc(k(),Ws()),snippet:k().optional()}).loose(),B0=N({capable:j(),applied:j(),coverage:N({embedded:A().int().nonnegative(),total:A().int().nonnegative()})}).loose(),V0=N({enabled:j(),keyPresent:j(),keySource:P([`file`,`env`]).nullable(),keyHint:k().nullable(),ready:j(),capable:j(),embedded:A().int().nonnegative(),total:A().int().nonnegative()}).loose(),H0=N({query:k(),intent:P([`autocomplete`,`full_text`,`omnibar`]),results:M(z0),elapsedMs:A().nonnegative(),semantic:B0.optional()}).loose(),U0=N({version:k().min(1),recordedAt:k().min(1)}).loose(),W0=N({currentVersion:k().min(1),targets:rc(k(),U0.nullable())}).loose(),G0=`server-info`,K0=`branch-switched`,q0=`disk-ack`,J0=`config-validation-rejected`,Y0=`config-ignore-nested-error`,X0=P([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),Z0=N({v:F(1),ch:F(G0),seq:A(),serverInstanceId:k().min(1),currentBranch:k().min(1).optional()}).loose(),Q0=N({v:F(1),ch:F(K0),seq:A(),branch:k().min(1)}).loose(),$0=N({v:F(1),ch:X0,seq:A()}).loose(),e2=N({v:F(1),ch:F(q0),seq:A(),docName:k().min(1),sv:k().min(1)}).loose(),t2=N({v:F(1),ch:F(J0),seq:A(),docName:k().min(1),error:ll}).loose(),n2=N({v:F(1),ch:F(Y0),seq:A(),path:k().min(1),error:k().min(1)}).loose(),r2={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},i2=new WeakMap;function a2(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function o2(e){return e.trim().toLowerCase()}function s2(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function c2(e){return e.split(`/`).filter(Boolean).join(` `)}function l2(e){let t=s2(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0;return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:c2(e.path),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function u2(e){let t=LU({schema:r2});return e.length>0&&JU(t,e),t}function d2(e){let t={documents:e};return i2.set(t,u2(e)),t}function f2(e){let t=i2.get(e);if(t)return t;let n=u2(e.documents);return i2.set(e,n),n}function p2(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`]:[`page`,`folder`]}function m2(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function h2(e,t){let n=o2(t);if(!n)return 0;let r=o2(e.title),i=o2(e.name),a=o2(e.path),o=a.split(`/`);return r===n||i===n?700:a===n?650:r.startsWith(n)||i.startsWith(n)?600:o.some(e=>e.startsWith(n))?550:r.includes(n)||i.includes(n)?500:a.includes(n)?450:-1}function g2(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 _2(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function v2(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 y2(e,t){return o2(t).length<4?0:e===`full_text`?1:0}function b2(e,t,n={}){let r=n.intent??`omnibar`,i=a2(n.limit),a=new Set(n.scopes??p2(r)),o=e.documents.filter(e=>m2(e,a)),s=o2(t);if(!s)return o.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,i).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let c=wW(f2(e),{term:s,properties:_2(r),boost:v2(r),tolerance:y2(r,s),limit:Math.max(i*4,40)}),l=new Map(c.hits.filter(e=>m2(e.document,a)).map(e=>[e.document.id,e.score])),u=g2(o),d=new Map;for(let e of o)h2(e,s)>=0&&d.set(e.id,e);for(let e of c.hits)m2(e.document,a)&&d.set(e.document.id,e.document);return n.semantic?S2({scopedDocuments:o,candidates:d,fullTextScores:l,recency:u,normalizedQuery:s,semantic:n.semantic,limit:i}):[...d.values()].map(e=>{let t=Math.max(0,h2(e,s)),n=l.get(e.id)??0,r=u.get(e.id)??0;return{document:e,score:t+n*20+r,signals:{lexical:t,fullText:n,recency:r}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score).slice(0,i)}function x2(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function S2(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,semantic:o,limit:s}=e,c=o.rrfK??60,l=o.candidateLimit??64,u=o.similarityFloor??0,d=o.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=[...n.values()].map(e=>{let t=Math.max(0,h2(e,a)),n=r.get(e.id)??0,o=i.get(e.id)??0,s=d.get(e.id),c=s!==void 0&&s>=u;return{document:e,score:t+n*20+o,signals:c?{lexical:t,fullText:n,recency:o,vector:s}:{lexical:t,fullText:n,recency:o},lexical:t,fullText:n,recency:o,cosine:s}}),h=x2(m.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),g=x2(m.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)),_=e=>{let t=0,n=h.get(e);n!==void 0&&(t+=1/(c+n));let r=g.get(e);return r!==void 0&&(t+=1/(c+r)),t};return m.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=_(e.document.id),a=_(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})).slice(0,s)}function C2(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),w2(n)}function w2(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 T2=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),E2=globalThis;E2[T2]===void 0&&(E2[T2]=Ii());const D2=E2[T2],O2=[`.ok`,`skill-state.yml`],k2=[`claude-cowork`,`cli-hosts`],A2=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],j2=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,M2=Ys({version:k().regex(j2,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(D2,{description:`Recorded skill version for this target.`}),recordedAt:Uo().register(D2,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:P(A2).register(D2,{description:`Install-source surface that recorded this entry.`}).optional()}),N2=Ys({schema:F(1).register(D2,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Ys({"claude-cowork":M2.optional(),"cli-hosts":M2.optional()}).register(D2,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function P2(){return{schema:1,targets:{}}}function F2(){let e=!1,t=``,n=0;return r=>{let i=I2(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 I2(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 L2=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],R2={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function z2(e,t=L2){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const B2={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function V2(e){return e?B2[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const H2={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function U2(e){let t=e?.trim();return t?H2[V2(t)]??t:`Agent`}function W2(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 G2=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function K2(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function q2(e){let t=e.trim();return G2.test(t)||t.startsWith(`//`)}function J2(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(q2(n))return{kind:`external`,url:n};let r=W2(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=K2(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function Y2(e,t){let n=e.trim();if(!n)return null;if(q2(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=K2(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function X2(e,t){let n=e.trim();if(!n||G2.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 Z2(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function Q2(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function $2(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function e4(e){return e.split(`/`).filter(e=>e!==``)}function t4(e,t){let n=$2(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function n4(e,t){let n=$2(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:e4(r).length}function r4(e,t){let n=e4(e),r=e4(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function i4(){let e=new Map;function t(t){let n=Z2(t);if(n===``)return;let r=Q2(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=Z2(t),r=Q2(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=$2(Z2(n)),o=[],s=[];for(let e of i)t4(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=n4(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=n4(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=r4(a,$2(t));for(let r=1;r<e.length;r++){let i=e[r],o=r4(a,$2(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 a4(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 o4(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 s4(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function c4(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function l4(){try{let e=_(g(b(import.meta.url)),`..`,`package.json`),t=JSON.parse(d(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const u4=l4(),d4=1;var f4=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${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 p4(e,t){return _(e,`${t}.lock`)}const m4=new Map;function h4(e){m4.set(e,(m4.get(e)??0)+1)}function g4(e){let t=m4.get(e);return t===void 0||t<=1?(m4.delete(e),!0):(m4.set(e,t-1),!1)}function _4(e,t){try{let n=JSON.parse(d(e,`utf-8`));return n&&typeof n==`object`&&c4(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 v4(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;l(n,{recursive:!0});let a=p4(n,t),o={pid:process.pid,hostname:y(),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??u4},d=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!c(a))try{let e=u(a,`wx`,384);try{m(e,d)}finally{s(e)}return h4(a),y4({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=_4(a,i);if(e){let r=e.hostname===y();if(r&&e.pid===process.pid)return p(a,d,{encoding:`utf-8`,mode:384}),h4(a),y4({lockName:t,lockDir:n,lockPath:a});if(r&&s4(e.pid))throw new f4(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{f(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function y4(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>C4({lockName:t,lockDir:n}),updatePort:e=>b4({lockName:t,lockDir:n,port:e})}}function b4(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=p4(n,t);if(!c(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(d(a,`utf-8`));if(!e||typeof e!=`object`||!c4(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!==y())){o.port=r;try{p(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 x4(e){let{lockName:t,lockDir:n}=e,r=p4(n,t);if(!c(r))return null;let i;try{let e=JSON.parse(d(r,`utf-8`));if(!e||typeof e!=`object`||!c4(e.pid))return null;i=e}catch{return null}if(i.hostname!==y())return null;if(!s4(i.pid)){try{f(r)}catch{}return null}return i}function S4(e){let{lockName:t,lockDir:n}=e,r=p4(n,t);if(!c(r))return{status:`absent`};let i;try{i=JSON.parse(d(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(!c4(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!==y())return{status:`stale`,lock:o};if(!s4(o.pid)){try{f(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 C4(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=p4(n,t);if(g4(i)&&c(i))try{let e=JSON.parse(d(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==y())return;f(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var w4=class extends f4{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function T4(e,t){try{return v4({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof f4&&e.lockName===`server`?new w4(e.existing,e.lockPath):e}}function E4(e,t){b4({lockName:`server`,lockDir:e,port:t})}function D4(e){return x4({lockName:`server`,lockDir:e})}function O4(e){C4({lockName:`server`,lockDir:e})}export{WG as $,Mc as $i,j0 as $n,WW as $r,M1 as $t,N$ as A,Sl as Ai,V0 as An,ZW as Ar,R$ as At,$0 as B,P as Bi,I1 as Bn,i$ as Br,FK as Bt,C$ as C,Bc as Ci,n1 as Cn,i4 as Cr,e1 as Ct,S$ as D,yl as Di,_0 as Dn,l2 as Dr,k0 as Dt,I$ as E,wl as Ei,g0 as En,d2 as Er,O0 as Et,cG as F,$c as Fi,$q as Fn,a4 as Fr,bK as Ft,J0 as G,kc as Gi,f0 as Gn,VW as Gr,b1 as Gt,Z0 as H,Hs as Hi,f1 as Hn,jq as Hr,x1 as Ht,pG as I,Kc as Ii,nJ as In,zq as Ir,x0 as It,VG as J,F as Ji,l0 as Jn,aJ as Jr,_1 as Jt,q0 as K,$s as Ki,p0 as Kn,Vq as Kr,xJ as Kt,Q0 as L,qc as Li,iJ as Ln,oG as Lr,C0 as Lt,K$ as M,ul as Mi,qq as Mn,IG as Mr,i1 as Mt,G$ as N,_l as Ni,Yq as Nn,P2 as Nr,a1 as Nt,P$ as O,Jc as Oi,b0 as On,AG as Or,J$ as Ot,lJ as P,nl as Pi,eJ as Pn,C2 as Pr,l1 as Pt,HG as Q,lc as Qi,F0 as Qn,qW as Qr,P1 as Qt,n2 as R,Fs as Ri,W0 as Rn,BQ as Rr,F1 as Rt,E1 as S,ft as Sa,Vc as Si,t1 as Sn,z2 as Sr,gK as St,w$ as T,Tl as Ti,H0 as Tn,CZ as Tr,D0 as Tt,K0 as U,M as Ui,m0 as Un,V2 as Ur,g1 as Ut,e2 as V,Bs as Vi,SJ as Vn,yY as Vr,Z$ as Vt,Y0 as W,j as Wi,d0 as Wn,sJ as Wr,y1 as Wt,KG as X,A as Xi,E0 as Xn,uG as Xr,h1 as Xt,RG as Y,Ys as Yi,u0 as Yn,IK as Yr,p1 as Yt,GG as Z,N as Zi,w0 as Zn,OG as Zr,VQ as Zt,R2 as _,Lt as _a,I as _i,O2 as _n,aG as _r,U$ as _t,v4 as a,Uo as aa,W2 as ai,LG as an,A1 as ar,H1 as at,j$ as b,D as ba,Hc as bi,nK as bn,Y2 as br,G1 as bt,c4 as c,Wa as ca,Fq as ci,mJ as cn,D1 as cr,V1 as ct,S4 as d,vr as da,sG as di,Z1 as dn,ZG as dr,oK as dt,rc as ea,iK as ei,j1 as en,I0 as er,UG as et,D4 as f,cn as fa,n$ as fi,s1 as fn,bJ as fr,tK as ft,E4 as g,on as ga,Df as gi,vK as gn,MW as gr,$1 as gt,b4 as h,mn as ha,Ly as hi,yK as hn,NW as hr,Q1 as ht,w4 as i,ys as ia,X2 as ii,aK as in,M0 as ir,B$ as it,hJ as j,pl as ji,pJ as jn,U2 as jr,zW as jt,x$ as k,tl as ki,h0 as kn,kG as kr,L$ as kt,p4 as l,Ga as la,UW as li,vJ as ln,e0 as lr,xK as lt,O4 as m,fn as ma,Bq as mi,r0 as mn,o1 as mr,d1 as mt,u4 as n,Zs as na,eG as ni,c1 as nn,N0 as nr,fJ as nt,T4 as o,Vo as oa,b2 as oi,J1 as on,O1 as or,U1 as ot,C4 as p,un as pa,GW as pi,n0 as pn,yJ as pr,JG as pt,G0 as q,tc as qi,c0 as qn,eK as qr,v1 as qt,d4 as r,Ws as ra,b$ as ri,rK as rn,P0 as rr,z$ as rt,s4 as s,fa as sa,FG as si,K1 as sn,k1 as sr,B1 as st,f4 as t,k as ta,y$ as ti,$G as tn,L0 as tr,uJ as tt,x4 as u,ai as ua,o4 as ui,X1 as un,t0 as ur,QG as ut,YG as v,Tt as va,Cl as vi,k2 as vn,_J as vr,H$ as vt,F$ as w,zc as wi,R0 as wn,F2 as wr,z1 as wt,T1 as x,pt as xa,Uc as xi,BG as xn,zG as xr,XG as xt,_K as y,O as ya,Wc as yi,j2 as yn,J2 as yr,W1 as yt,t2 as z,cc as zi,N2 as zn,u$ as zr,qG as zt};
|
|
446
|
+
//# sourceMappingURL=server-lock-BpjJj3OD-D4ouSX5Q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./server-lock-BpjJj3OD-D4ouSX5Q.mjs";export{e as updateServerLockPort};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{s as e}from"./chunk-C94x7I9S.mjs";import{t}from"./esm-BLMtE3s6.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-
|
|
1
|
+
import{s as e}from"./chunk-C94x7I9S.mjs";import{t}from"./esm-BLMtE3s6.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-D4ouSX5Q.mjs";import"./gh-detect-CdNj3GJ-.mjs";import{Ur as a,yn as o}from"./dist-C_YxrqyY.mjs";import{g as s,h as c,k as l}from"./init-Bt9S7yc7.mjs";import"./loader-CBz-HCpO.mjs";import{c as u}from"./colors-8SzMRIVy.mjs";import"./preview-BNODnkHd.mjs";import{n as d}from"./write-project-skill-DDU4NRC7.mjs";import{spawnSync as f}from"node:child_process";import{existsSync as p,lstatSync as m,readFileSync as h,readdirSync as g,statSync as ee}from"node:fs";import{basename as te,dirname as _,isAbsolute as v,join as y,relative as b,resolve as x}from"node:path";import{hostname as ne}from"node:os";import{readFile as S,realpath as C}from"node:fs/promises";function w(e,t,a={}){let o=r(e,t);if(!p(o))return{status:`missing`,lockPath:o};let s;try{s=JSON.parse(h(o,`utf-8`))}catch{return{status:`corrupt`,lockPath:o}}if(!s||typeof s!=`object`||!n(s.pid))return{status:`corrupt`,lockPath:o};let c=s;if(!(a.isAlive??i)(c.pid))return{status:`dead-pid`,lockPath:o,lock:c};let l=a.host??ne();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 k(e){let t=D(e);if(t)return{kind:`doc`,...t};let n=O(e);return n?{kind:`folder`,...n}:null}const A=2e3,j=2e3,re=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/Open Knowledge(?:\.app| Helper)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/,/(^|\s)--ok-project-path=/];function M(e){return re.some(t=>t.test(e))}function ie(e){let t=e.trim().split(/\s+/).find(e=>e.startsWith(`--ok-lock-dir-b64=`));if(t==null)return null;let n=t.slice(18);if(!n)return null;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);return v(e)?e:null}catch{return null}}function ae(e){let t=e.indexOf(`--ok-project-path=`);if(t===-1)return null;let n=t+18,r=e.slice(n),i=r.search(/\s--/),a=(i===-1?r:r.slice(0,i)).trim();return a&&v(a)?a:null}function oe(e){let t=[];for(let n of e.split(`
|
|
2
2
|
`)){let e=n.trim();if(!e)continue;let r=e.indexOf(` `);if(r===-1)continue;let i=e.slice(0,r),a=e.slice(r+1),o=Number.parseInt(i,10);!Number.isNaN(o)&&M(a)&&t.push({pid:o,command:a})}return t}function se(e){let t=[],n=e.split(`
|
|
3
3
|
`);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.indexOf(` `);if(i===-1)continue;let a=r.slice(0,i),o=r.slice(i+1).trim(),s=Number.parseInt(a,10);!Number.isNaN(s)&&M(o)&&t.push({pid:s,command:o})}return t}async function ce(){let e=f(`pgrep`,[`-a`,`-f`,`cli\\.mjs|open-knowledge|Open Knowledge(\\.app| Helper)|--ok-lock-dir-b64=|--ok-project-path=|(^|[ /])ok[ ]+(start|mcp|ui)([ ]|$)|packages/(cli|app)|hocuspocus|vite`],{encoding:`utf-8`,timeout:A});if(!(e.error!=null&&e.error.code===`ENOENT`)){let t=e.stdout??``,n=oe(t);if(n.length>0||t.trim()===``)return n}let t=f(`ps`,[`-axo`,`pid,command`],{encoding:`utf-8`,timeout:A});return t.error!=null||!t.stdout?[]:se(t.stdout)}function le(e){let t=e.trim().split(/\s+/).filter(Boolean);for(let e of t){if(e.startsWith(`@`))continue;let t=te(e);if(t===`open-knowledge`||t===`ok`||e.endsWith(`/packages/cli/src/cli.ts`)||e.endsWith(`/packages/cli/dist/cli.mjs`)||t===`cli.mjs`||t===`cli.ts`)return e}return null}function N(e){let t=f(`ps`,[`-p`,String(e),`-o`,`command=`],{encoding:`utf-8`,timeout:A});return t.error!=null||!t.stdout?null:t.stdout.trim()||null}function P(e){let t=f(`ps`,[`-p`,String(e),`-o`,`%cpu=,%mem=`],{encoding:`utf-8`,timeout:A});if(t.error!=null||!t.stdout)return null;let[n,r]=t.stdout.trim().split(/\s+/),i=Number.parseFloat(n??``),a=Number.parseFloat(r??``);return Number.isNaN(i)||Number.isNaN(a)?null:{cpuPercent:i,memPercent:a}}async function F(e){let t=f(`lsof`,[`-p`,String(e),`-a`,`-d`,`cwd`,`-Fn`],{encoding:`utf-8`,timeout:A});if(t.error!=null)return null;let n=t.stdout??``;for(let e of n.split(`
|
|
4
4
|
`))if(e.startsWith(`n`)&&e.length>1)return e.slice(1);return null}function I(e){let t=[],n=e.split(`
|
|
5
5
|
`);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.split(/\s+/);if(i.length<2)continue;let a=Number.parseInt(i[1]??``,10);Number.isNaN(a)||t.push(a)}return[...new Set(t)]}function L(e){return p(y(e,`server.lock`))||p(y(e,`ui.lock`))}function R(e,t){for(let n of[y(t,`.ok`,`local`),y(t,`.ok`)])p(n)&&L(n)&&e.add(n)}function z(e,t){let n=0,r=(t,i)=>{if(n>=j||(n++,R(e,t),i>=3))return;let a;try{a=g(t)}catch{return}for(let e of a){if(n>=j)return;if(e===`node_modules`||e===`.git`||e===`Library`||e.startsWith(`.`)&&e!==`.ok`)continue;let a=y(t,e),o=!1;try{o=m(a).isDirectory()}catch{continue}o&&r(a,i+1)}};r(t,0)}async function B(){let e=new Set,t=await ce(),n=t.map(e=>F(e.pid)),r=await Promise.all(n);for(let n of t){let t=ie(n.command);t!=null&&p(t)&&e.add(t);let r=ae(n.command);r!=null&&R(e,r)}for(let t of r)t!=null&&R(e,t);let i=f(`lsof`,[`-iTCP`,`-sTCP:LISTEN`,`-nP`],{encoding:`utf-8`,timeout:A});if(i.error==null&&i.stdout){let n=I(i.stdout),r=new Set(t.map(e=>e.pid)),a=n.filter(e=>!r.has(e)).map(e=>F(e)),o=await Promise.all(a);for(let t of o)t!=null&&R(e,t)}(e.size===0||r.some(e=>e===`/`))&&z(e,process.cwd());let a=new Map;for(let t of e)try{let e=await C(t);a.set(e,e)}catch{a.set(t,t)}return[...a.values()]}var V=e(u(),1);function H(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function U(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 W(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:le(r),command:r,isDesktop:H(r)}}function ue(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`&&ue(e)?`ui-orphan`:`stale`}const de=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function fe(e){switch(e){case`running`:return V.default.green(e);case`desktop`:return V.default.blue(e);case`foreign`:return V.default.cyan(e);case`ui-orphan`:return V.default.magenta(e);case`stale`:return V.default.yellow(e)}}function K(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function pe(e){return`${K(e.server.usage)} | ${K(e.ui?.usage??null)}`}function me(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function he(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,me(e),pe(e),t,String(n),U(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=fe(G(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=V.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
6
|
-
`)}async function q(e={}){let t=e.discover??B,n=e.inspect??w,r=e.log??(e=>console.log(e)),i=e.resolveCommand??N,a=e.resolveUsage??P,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=W(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:G(e)}));r(JSON.stringify(e,null,2));return}r(he(e.all?s:s.filter(e=>de.has(G(e)))))}function ge(){return new t(`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 q({all:t.all===!0||e===`all`,json:t.json===!0})})}const _e=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`]);function ve(e,t,n=
|
|
7
|
-
//# sourceMappingURL=src-
|
|
6
|
+
`)}async function q(e={}){let t=e.discover??B,n=e.inspect??w,r=e.log??(e=>console.log(e)),i=e.resolveCommand??N,a=e.resolveUsage??P,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=W(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:G(e)}));r(JSON.stringify(e,null,2));return}r(he(e.all?s:s.filter(e=>de.has(G(e)))))}function ge(){return new t(`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 q({all:t.all===!0||e===`all`,json:t.json===!0})})}const _e=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`]);function ve(e,t,n=o){if(e!==void 0&&!_e.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let J=null;function ye(e){J=e}function be(){return J??process.cwd()}function xe(e,t,n={}){let r=n.isAlive??i,a=[];for(let[n,i]of[[`server`,e],[`ui`,t]])(i.status===`alive`||i.status===`foreign-host`&&r(i.lock.pid))&&a.push({name:n,pid:i.lock.pid,port:i.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=xe(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 Se(e,t=i){let n=await B(),r=null;for(let i of n){let n=w(i,`server`),a=w(i,`ui`);if(X(n,t)&&n.lock.port===e||X(a,t)&&a.lock.port===e)return i;r===null&&(X(n,t)&&n.lock.pid===e||X(a,t)&&a.lock.pid===e)&&(r=i)}return r}function Z(e){let t=Y({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Ce(e){return new t(`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:a(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 q({});return}if(n===`all`){let e=await B();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`),r=w(n,`ui`);!X(e,i)&&!X(r,i)||(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 Se(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Z(t);return}Z(a(x(be(),n)))})}async function we(e,t){let n,r;try{n=await C(x(e)),r=await C(x(_(e)))}catch{return{kind:`not-git`}}if(!$(n,r))return{kind:`symlink-escape`};let i=y(n,`.git`),a;try{a=ee(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=v(r)?r:x(n,r);try{o=await C(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=y(await Q(o),`config`),c;try{c=await S(s,`utf-8`)}catch{return{kind:`not-git`}}let l=Ee(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(y(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=v(t)?t:x(e,t);try{return await C(n)}catch{return n}}function $(e,t){if(e===t)return!0;let n=b(t,e);return n.length>0&&!n.startsWith(`..`)&&!v(n)}function Te(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 Ee(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=Te(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 De(r[1])}return null}function De(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const Oe=[{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=s(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`}:{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=d(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 ke(e,t,n={},r=Oe){let i=[];for(let a of t){let t=l[a];for(let a of r)i.push(a.write(t,e,n))}return i}function Ae(e,t,n={}){return{integrations:ke(e,t,n),claudeLaunchJson:t.includes(`claude`)?c(e,n):void 0}}export{ye as a,B as c,D as d,k as f,w as h,Ce as i,N as l,E as m,we as n,ve as o,O as p,Y as r,ge as s,Ae as t,P as u};
|
|
7
|
+
//# sourceMappingURL=src-hFiiM4hG.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{n as e,t}from"./esm-BLMtE3s6.mjs";import{bn as n,ft as r}from"./server-lock-BpjJj3OD-CUhVvie4.mjs";import{i,t as a}from"./gh-detect-CNO7EkgF.mjs";import{Yn as o,gr as s,or as c}from"./dist-D7myPw4s.mjs";import{n as l}from"./constants-iOPbvTyC.mjs";import{spawn as u}from"node:child_process";import{closeSync as d,existsSync as f,mkdirSync as p,openSync as m,statSync as h}from"node:fs";import{basename as g,dirname as _,join as v}from"node:path";import{homedir as y}from"node:os";import{setTimeout as b}from"node:timers/promises";const x=`Open Knowledge.app`,S=`/Applications/${x}`;function C(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return h(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function w(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(T(e,S))return S;let t=v(e.homeDir??y(),`Applications`,x);return T(e,t)?t:null}function T(e,t){try{let n=v(t,`Contents`,`MacOS`,`Open Knowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function E(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=w(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 D(e){(e.log??(e=>console.error(e)))("Launching Open Knowledge 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 O(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${S}. 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 ${S} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${S} but launch dispatch did not fire (caller bug).`}}function k(e){return v(_(e),`..`,`Frameworks`,`Open Knowledge Server.app`,`Contents`,`MacOS`,`Open Knowledge Helper`)}const A=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function j(e){if(e.platform!==`darwin`||!A.test(e.execPath))return null;let t=k(e.execPath);return e.exists(t)?t:null}function M(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??f,a=r[1];return a?{command:j({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 N(e,t){return e.host??t.HOST??`localhost`}function P(e){let t=g(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var F=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 I(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 L(e){f(e.lockDir)||p(e.lockDir,{recursive:!0});let t=m(v(e.lockDir,n),`w`),r=e.spawn??u,{PORT:i,...a}=process.env,o=M();try{let n=r(o.command,[...o.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return n.unref(),n}finally{try{d(t)}catch{}}}function R(e,t,n){return e??(n===void 0?t:void 0)}function z(e,t){return e!==void 0&&t!==null&&t.port>0}function B(e,t,n){return e??(t!=null&&!n?1:0)}async function V(e){let t=e.spawn??u,n=M(),{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=B(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 H(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 U=r;function W(e){let t=e.sigtermGraceMs??U,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>b(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 G(e){let{config:t,cwd:n,host:r}=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:x}=await import(`./dist-GL5zcXSU.mjs`),S=e.log??_(`start`),C=e.singleFile!==void 0,w=e.projectDir??n,T=C?s(e.singleFile).canonicalFilePath:void 0,E=T?h(T):void 0,D=T?m(T):void 0;if(!C){if(!l&&!o(n))throw new F(n);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-BV1WJulV.mjs`)).repairMcpConfigs)({projectDir:n,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-DCXsAQuF.mjs`)).repairLaunchJson)({projectDir:n,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-BSA3PyS7.mjs`)).repairSkills)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let O=E??x(t,n);!C&&!f(O)&&(p(O,{recursive:!0}),S.info({contentDir:O},`Created content directory`));let k=null,A=async({lockDir:t})=>{if(k=I({uiLock:y(t),isAlive:v}),k.action===`spawn`&&!u)try{let r=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];L({lockDir:t,cwd:n,spawn:e.spawn,args:r}),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=i(),N=c(),P=await g({config:t,contentDir:O,projectDir:C?w:n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:a,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=>W({readUiLock:()=>y(P.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:S}),log:S,...e.serveContentAssets?{serveContentAssets:!0}:{},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});k||={action:`skip`,reason:`alive`,pid:0,port:0};let R=k,z=null;if(R.action===`skip`)z=R.port>0?R.port:null;else if(!u){let t=e.uiBindTimeoutMs??3e3;z=await H({readUiLock:()=>y(P.lockDir),now:Date.now,sleep:e=>b(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 K(t){if(t===`browser`||t===`app`)return t;throw new e(`--mode must be 'browser' or 'app'`)}function q(t){let n=Number.parseInt(t,10);if(Number.isNaN(n)||n<1||n>65535)throw new e(`--ui-port must be a port number between 1 and 65535`);return n}function J(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Y(e){let t=[`Stopping Open Knowledge…`,`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 X(e,t){let n=J(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-CkPULM8m.mjs`),c=process.cwd(),u=e;process.title=P(c);let d=N(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=R(f,p,m);if(m!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./dist-GL5zcXSU.mjs`);if(z(m,e(t(c)))){await V({cwd:c,uiPort:m});return}}let g;try{g=await G({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 F&&(console.error(o(e.message)),process.exit(1));let t=await import(`./dist-GL5zcXSU.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&&Z(e,t)){await V({cwd:c,uiPort:m});return}let n=Q(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]=Y(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 Z(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function Q(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=v(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`Open Knowledge 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`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function $(e){return new t(`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`,q).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,K).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{n as e,t}from"./esm-BLMtE3s6.mjs";import{bn as n,ft as r}from"./server-lock-BpjJj3OD-D4ouSX5Q.mjs";import{i,t as a}from"./gh-detect-CdNj3GJ-.mjs";import{$n as o,br as s,ur as c}from"./dist-C_YxrqyY.mjs";import{n as l}from"./constants-BYIeZQM3.mjs";import{spawn as u}from"node:child_process";import{closeSync as d,existsSync as f,mkdirSync as p,openSync as m,statSync as h}from"node:fs";import{basename as g,dirname as _,join as v}from"node:path";import{homedir as y}from"node:os";import{setTimeout as b}from"node:timers/promises";const x=`Open Knowledge.app`,S=`/Applications/${x}`;function C(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return h(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function w(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(T(e,S))return S;let t=v(e.homeDir??y(),`Applications`,x);return T(e,t)?t:null}function T(e,t){try{let n=v(t,`Contents`,`MacOS`,`Open Knowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function E(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=w(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 D(e){(e.log??(e=>console.error(e)))("Launching Open Knowledge 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 O(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${S}. 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 ${S} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${S} but launch dispatch did not fire (caller bug).`}}function k(e){return v(_(e),`..`,`Frameworks`,`Open Knowledge Server.app`,`Contents`,`MacOS`,`Open Knowledge Helper`)}const A=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function j(e){if(e.platform!==`darwin`||!A.test(e.execPath))return null;let t=k(e.execPath);return e.exists(t)?t:null}function M(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??f,a=r[1];return a?{command:j({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 N(e,t){return e.host??t.HOST??`localhost`}function P(e){let t=g(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var F=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 I(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 L(e){f(e.lockDir)||p(e.lockDir,{recursive:!0});let t=m(v(e.lockDir,n),`w`),r=e.spawn??u,{PORT:i,...a}=process.env,o=M();try{let n=r(o.command,[...o.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return n.unref(),n}finally{try{d(t)}catch{}}}function R(e,t,n){return e??(n===void 0?t:void 0)}function z(e,t){return e!==void 0&&t!==null&&t.port>0}function B(e,t,n){return e??(t!=null&&!n?1:0)}async function V(e){let t=e.spawn??u,n=M(),{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=B(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 H(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 U=r;function W(e){let t=e.sigtermGraceMs??U,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>b(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 G(e){let{config:t,cwd:n,host:r}=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:x}=await import(`./dist-CNZsMl-V.mjs`),S=e.log??_(`start`),C=e.singleFile!==void 0,w=e.projectDir??n,T=C?s(e.singleFile).canonicalFilePath:void 0,E=T?h(T):void 0,D=T?m(T):void 0;if(!C){if(!l&&!o(n))throw new F(n);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-2dA34sJP.mjs`)).repairMcpConfigs)({projectDir:n,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-7O7Lmxus.mjs`)).repairLaunchJson)({projectDir:n,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-ulgbNIxw.mjs`)).repairSkills)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let O=E??x(t,n);!C&&!f(O)&&(p(O,{recursive:!0}),S.info({contentDir:O},`Created content directory`));let k=null,A=async({lockDir:t})=>{if(k=I({uiLock:y(t),isAlive:v}),k.action===`spawn`&&!u)try{let r=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];L({lockDir:t,cwd:n,spawn:e.spawn,args:r}),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=i(),N=c(),P=await g({config:t,contentDir:O,projectDir:C?w:n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:a,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=>W({readUiLock:()=>y(P.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:S}),log:S,...e.serveContentAssets?{serveContentAssets:!0}:{},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});k||={action:`skip`,reason:`alive`,pid:0,port:0};let R=k,z=null;if(R.action===`skip`)z=R.port>0?R.port:null;else if(!u){let t=e.uiBindTimeoutMs??3e3;z=await H({readUiLock:()=>y(P.lockDir),now:Date.now,sleep:e=>b(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 K(t){if(t===`browser`||t===`app`)return t;throw new e(`--mode must be 'browser' or 'app'`)}function q(t){let n=Number.parseInt(t,10);if(Number.isNaN(n)||n<1||n>65535)throw new e(`--ui-port must be a port number between 1 and 65535`);return n}function J(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Y(e){let t=[`Stopping Open Knowledge…`,`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 X(e,t){let n=J(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-CkPULM8m.mjs`),c=process.cwd(),u=e;process.title=P(c);let d=N(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=R(f,p,m);if(m!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./dist-CNZsMl-V.mjs`);if(z(m,e(t(c)))){await V({cwd:c,uiPort:m});return}}let g;try{g=await G({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 F&&(console.error(o(e.message)),process.exit(1));let t=await import(`./dist-CNZsMl-V.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&&Z(e,t)){await V({cwd:c,uiPort:m});return}let n=Q(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]=Y(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 Z(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function Q(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=v(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`Open Knowledge 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`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function $(e){return new t(`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`,q).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,K).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=E(C());if(n.available){D({spawn:u});return}console.error(O(n.reason)),process.exit(1)}await X(n,t)})}export{D as S,$ as _,B as a,C as b,P as c,R as d,N as f,L as g,z as h,W as i,Y as l,X as m,H as n,V as o,J as p,G as r,I as s,F as t,Z as u,Q as v,E as x,M as y};
|
|
3
|
-
//# sourceMappingURL=start-
|
|
3
|
+
//# sourceMappingURL=start-BiMFcs6H.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,f as t,r as n}from"./start-BiMFcs6H.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=write-project-skill-
|
|
1
|
+
import{zr as e}from"./dist-C_YxrqyY.mjs";import{cpSync as t,existsSync as n,lstatSync as r,mkdirSync as i,realpathSync as a,rmSync as o}from"node:fs";import{dirname as s,isAbsolute as c,relative as l,resolve as u,sep as d}from"node:path";function f(e,t){let n;try{n=a(t)}catch{n=u(t)}let i;try{i=r(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(i?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);let o=s(e);for(;o.length>1&&o!==d;){let t;try{t=a(o)}catch(e){if(e.code===`ENOENT`){o=s(o);continue}throw e}let r=l(n,t);if(r===``||!r.startsWith(`..`)&&!c(r))return;throw Error(`Refusing to write at ${e}: ancestor ${o} 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 p(r,a){let c=r.projectSkillPath?.(a);if(!c)return{editorId:r.id,label:r.label,action:`skipped-unsupported`,path:``};try{let l=e(`project`,{checkDesktop:!0}),u=s(c);f(u,a);let d=n(c)?`overwritten`:`written`;return o(u,{recursive:!0,force:!0}),i(s(u),{recursive:!0}),t(l,u,{recursive:!0}),{editorId:r.id,label:r.label,action:d,path:c}}catch(e){return{editorId:r.id,label:r.label,action:`failed`,path:c,error:e instanceof Error?e.message:String(e)}}}export{p as n,f as t};
|
|
2
|
+
//# sourceMappingURL=write-project-skill-DDU4NRC7.mjs.map
|
package/package.json
CHANGED
package/dist/dist-GL5zcXSU.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{J as e,Sr as t,Ur as n,a as r,an as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,qr as g,r as _,s as v,t as y,tn as b,u as x,vn as S,xn as C,zt as w}from"./server-lock-BpjJj3OD-CUhVvie4.mjs";import{$ as T,$n as E,$r as D,$t as O,A as k,Ai as A,An as j,Ar as M,At as N,B as P,Bn as F,Br as I,Bt as L,C as R,Ci as z,Cn as B,Cr as V,Ct as H,D as U,Di as W,Dn as G,Dr as K,Dt as q,E as J,Ei as Y,En as X,Er as Z,Et as Q,F as $,Fi as ee,Fn as te,Fr as ne,Ft as re,G as ie,Gn as ae,Gr as oe,Gt as se,H as ce,Hn as le,Hr as ue,Ht as de,I as fe,Ii as pe,In as me,Ir as he,It as ge,J as _e,Jn as ve,Jr as ye,Jt as be,K as xe,Kn as Se,Kr as Ce,Kt as we,L as Te,Li as Ee,Ln as De,Lr as Oe,Lt as ke,M as Ae,Mi as je,Mn as Me,Mr as Ne,Mt as Pe,N as Fe,Ni as Ie,Nn as Le,Nr as Re,Nt as ze,O as Be,Oi as Ve,On as He,Or as Ue,Ot as We,P as Ge,Pi as Ke,Pn as qe,Pr as Je,Pt as Ye,Q as Xe,Qi as Ze,Qn as Qe,Qr as $e,Qt as et,R as tt,Ri as nt,Rn as rt,Rr as it,Rt as at,S as ot,Si as st,Sn as ct,Sr as lt,St as ut,T as dt,Ti as ft,Tn as pt,Tr as mt,Tt as ht,U as gt,Un as _t,Ur as vt,Ut as yt,V as bt,Vn as xt,Vr as St,Vt as Ct,W as wt,Wn as Tt,Wr as Et,Wt as Dt,X as Ot,Xn as kt,Xr as At,Xt as jt,Y as Mt,Yn as Nt,Yr as Pt,Yt as Ft,Z as It,Zi as Lt,Zn as Rt,Zr as zt,Zt as Bt,_ as Vt,_i as Ht,_n as Ut,_r as Wt,_t as Gt,a as Kt,ai as qt,an as Jt,ar as Yt,at as Xt,b as Zt,bi as Qt,bn as $t,br as en,bt as tn,c as nn,ci as rn,cn as an,cr as on,ct as sn,d as cn,di as ln,dn as un,dr as dn,dt as fn,ei as pn,en as mn,er as hn,et as gn,f as _n,fi as vn,fn as yn,fr as bn,ft as xn,g as Sn,gi as Cn,gn as wn,gr as Tn,gt as En,h as Dn,hi as On,hn as kn,hr as An,ht as jn,i as Mn,ii as Nn,in as Pn,ir as Fn,it as In,j as Ln,ji as Rn,jn as zn,jr as Bn,jt as Vn,k as Hn,ki as Un,kn as Wn,kr as Gn,kt as Kn,l as qn,li as Jn,ln as Yn,lr as Xn,lt as Zn,m as Qn,mi as $n,mn as er,mr as tr,mt as nr,n as rr,ni as ir,nn as ar,nr as or,nt as sr,o as cr,oi as lr,on as ur,or as dr,ot as fr,p as pr,pi as mr,pn as hr,pr as gr,pt as _r,q as vr,qn as yr,qr as br,qt as xr,r as Sr,ri as Cr,rn as wr,rr as Tr,rt as Er,s as Dr,si as Or,sn as kr,sr as Ar,st as jr,t as Mr,ti as Nr,tn as Pr,tr as Fr,tt as Ir,u as Lr,ui as Rr,un as zr,ur as Br,ut as Vr,v as Hr,vi as Ur,vn as Wr,vr as Gr,vt as Kr,w as qr,wi as Jr,wn as Yr,wr as Xr,wt as Zr,x as Qr,xi as $r,xn as ei,xr as ti,xt as ni,y as ri,yi as ii,yn as ai,yr as oi,yt as si,z as ci,zi as li,zn as ui,zr as di,zt as fi}from"./dist-D7myPw4s.mjs";export{Mr as AGENT_ID_MAX_LEN,rr as AGENT_ID_RE,Sr as AGENT_WRITE_ORIGIN,Mn as AgentFocusBroadcaster,Kt as AgentPresenceBroadcaster,cr as AgentSessionCapacityError,Dr as AgentSessionManager,nn as AutoStartDisabledError,qn as BacklinkIndex,Lr as CC1Broadcaster,e as CC1_CONTRACT_VERSION,cn as CONFIG_FILENAME,_n as CONFLICT_MARKER_RE,pr as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Qn as ConfigSchema,Dn as DEFAULT_CHECKPOINT_RETENTION,Sn as DEFAULT_EMBEDDINGS_DIMENSIONS,Vt as DEFAULT_PACK_ID,Hr as EMBEDDINGS_API_KEY_ENV,ri as FILE_SYSTEM_WRITER,Zt as FILE_WATCHER_ORIGIN,Qr as FileEmbeddingsBackend,ot as GIT_PREFLIGHT_FAIL_SPAN_NAME,R as GIT_UPSTREAM_WRITER,Lt as GitDirAccessError,qr as GitNotAvailableError,dt as GitTooOldError,J as HOCUSPOCUS_AUTH_REJECTION_REASONS,U as HocuspocusAuthRejection,Be as HocuspocusAuthTokenSchema,Hn as INSTALLED_AGENTS_SCHEMES,w as LINEAGE_EPOCH_KEY,k as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Ln as LOG_MD_TEMPLATE,Ae as MANAGED_RENAME_ORIGIN,Fe as MAX_AGENT_SESSIONS,Ge as MCP_CONNECTION_ID_HEADER,$ as MCP_SERVER_NAME,fe as MIN_GIT_VERSION,Te as MISSING_OK_CONFIG_MESSAGE,Ze as MalformedGitPointerError,tt as McpLogger,ci as MissingOkConfigError,P as OBSERVER_SYNC_ORIGIN,bt as OK_OKIGNORE_TEMPLATE,b as ORPHAN_MODES,ce as PANE_TARGET_TTL_MS,i as PROTOCOL_VERSION,gt as PinoLogger,y as ProcessLockCollisionError,wt as ProjectGitInitError,ie as ROLLBACK_ORIGIN,xe as ROOT_GITIGNORE_TEMPLATE,p as RUNTIME_VERSION,vr as SERVICE_WRITER,_e as SKILL_INSTALL_EVENTS_FILE_REL,S as SKILL_STATE_TARGETS,Mt as STARTER_FOLDERS,Ot as STARTER_FOLDER_FRONTMATTER_FILENAME,It as STARTER_PACKS,Xe as STARTER_PACK_IDS,T as STARTER_TEMPLATES,gn as STATE_MANIFEST_FILENAME,_ as STATE_SCHEMA_VERSION,C as SYSTEM_DOC_NAME,Ir as SeedPrerequisiteError,sr as SeedRootDirError,u as ServerLockCollisionError,Er as SingleFileNotAFileError,In as SingleFileNotFoundError,Xt as SingleFileNotMarkdownError,fr as StateManifestError,jr as TagIndex,sn as UiLockCollisionError,Zn as __getShowAllWalkStatsForTesting,Vr as __resetShowAllWalkStatsForTesting,r as acquireProcessLock,m as acquireServerLock,fn as acquireUiLock,xn as applyAgentMarkdownWrite,_r as applyExternalChange,nr as applySeed,jn as armPaneTarget,En as assertCompatibleStateManifest,Gt as assertGitAvailable,Kr as assertNeverDiskEvent,si as attachIdleShutdown,tn as bootServer,ni as buildAndOpenSkill,ut as buildConfigYmlContent,H as buildExecResult,Zr as buildInstructions,ht as buildSkillZip,Q as buildStarterFolderFrontmatterYaml,q as buildWipTree,We as classifyEvents,Kn as classifyFsPath,N as clearArmedPaneTarget,Vn as clearContributors,Pe as clearEmbeddingsKeyFromAllBackends,ze as coercePackId,t as colorFromSeed,Ye as commitUpstreamImport,re as commitWip,ge as commitWipFromTree,ke as compareSemver,at as containsConflictMarkers,fi as contentHash,L as contributorCount,Ct as createApiExtension,de as createAssetServeMiddleware,yt as createContentFilter,Dt as createContentFilterAsync,se as createEmbeddingsSecretStore,we as createEphemeralProjectDir,xr as createExternalChangeHandler,be as createFileLogger,Ft as createLiveDerivedIndexExtension,jt as createMcpHttpHandler,Bt as createOsProbe,et as createPersistenceExtension,O as createServer,mn as createServerObserverExtension,Pr as createStreamingErrorWriter,ar as createTestLogger,wr as describeStoredEmbeddingsKey,Pn as detectClaudeDesktopPresence,Jt as detectGit,ur as detectProjectShape,kr as emitPreflightFailureSpan,an as encodeDocName,Yn as encodeFolderRoute,zr as ensureProjectGit,un as errorResponse,yn as evictStaleTrackerEntries,hr as extractWikiLinksFromMarkdown,er as fallbackPaths,kn as findEnclosingGitRoot,wn as findEnclosingProjectRoot,Ut as flushFileLogger,Wr as formatAuthRejectionWire,ai as formatContributors,$t as formatContributorsFrom,ei as gcCheckpointRefs,ct as getCurrentMcpLogger,B as getLocalDir,Yr as getLogFilePath,pt as getLogger,X as getLogsDir,G as getMeter,He as getMetrics,Wn as getTracer,j as handleCollabSocketError,zn as handleSpawnCursor,n as iconFromClientName,Me as incrementCollabSocketFilteredError,Le as incrementServerObserverFire,qe as initContent,te as initShadowRepo,me as initTelemetry,De as initToleranceTelemetryWriter,rt as installPrettyZodErrors,ui as installTestLoggers,F as installUserSkill,xt as isAllowedApiOrigin,le as isAllowedWorkspaceHostHeader,_t as isConfigDoc,Tt as isHocuspocusAuthRejectionReason,ae as isKnownPackId,Se as isLoopbackAddress,g as isOrphanMode,yr as isPairedWriteOrigin,ve as isPathWithinDir,v as isProcessAlive,Nt as isProjectRoot,kt as isSelfWrite,Rt as isSystemDoc,Qe as isToleranceTelemetryEnabled,a as isValidLockPid,E as lastKnownHash,hn as listRescueCheckpoints,Fr as listStarterPacks,or as loadPrincipal,d as lockFilePath,Tr as loggerFactory,Fn as logsCurrentPath,Yt as logsPreviousPath,dr as makeLazyEmbeddingsKeyStore,Ar as mountMcpAndApi,on as normalizeFsPath,Xn as packageVersionMajorMinor,Br as parseAuthRejectionWire,dn as parseGitVersion,bn as parseHocuspocusAuthToken,gr as parseKeepaliveConnectionId,tr as pathToDocName,An as planSeed,Tn as prepareSingleFileOpen,Wt as readAllTargets,Gr as readArmedPaneTarget,oi as readBranchFromHead,x as readProcessLock,o as readProcessLockDetailed,en as readProjectLocalSemanticConfig,s as readServerLock,ti as readServerPackageVersion,lt as readSkillInstallStateSnapshot,V as readStateManifest,Xr as readTargetRecordedAt,mt as readTargetVersion,Z as readUiLock,K as reconcile,Ue as recordContributor,Gn as recordSkillInstallEvent,M as registerAllTools,Bn as registerWrite,h as releaseProcessLock,f as releaseServerLock,Ne as releaseUiLock,Re as removeLastKnownHash,Je as resetMetrics,ne as resolveBundledSkillDir,he as resolveContentDir,Oe as resolveCursorBinaryDefault,it as resolveCursorSpawnInvocation,di as resolveLockDir,I as resolvePack,St as resolvePackageVersion,ue as resolveUiInfo,vt as restoreContributors,Et as restoreLifecycleFromConflictsJson,oe as rewriteMarkdownLinksForDocumentRename,Ce as rewriteWikiLinksForDocumentRename,br as runAuthReposSubprocess,ye as runAuthStatusSubprocess,Pt as runCloneSubprocess,At as runDeviceFlowSubprocess,zt as runWithMcpLogger,$e as safeContentPath,D as safeSubdir,pn as safetyCheckpoint,Nr as sanitizeClientName,ir as saveInMemoryCheckpoint,Cr as saveVersion,Nn as seedBasenameIndex,qt as serializeError,lr as setActiveSpanAttributes,Or as shadowGit,rn as shutdownTelemetry,Jn as spansCurrentPath,Rr as spansPreviousPath,ln as spawnDetached,vn as splitMarkdownBlocks,mr as startWatcher,$n as streamingProblemEvent,On as swapContributors,Cn as teardownToleranceTelemetryWriter,Ht as toBroadcasterKey,Ur as tracedAppendFileSync,ii as tracedLinkSync,Qt as tracedMkdir,$r as tracedMkdirSync,st as tracedRename,z as tracedRenameSync,Jr as tracedRmSync,ft as tracedRmdirSync,Y as tracedUnlinkSync,W as tracedWriteFile,Ve as tracedWriteFileSync,Un as updateLastKnownHash,l as updateProcessLockPort,c as updateServerLockPort,A as updateUiLockPort,Rn as validateAgentId,je as validateCloneInputs,Ie as validateSkillZip,Ke as withSpan,ee as withSpanSync,pe as writeRootGitignoreForNewRepo,Ee as writeStateManifest,nt as writeTargetVersion,li as writeTracker};
|
package/dist/init-BCTt64EX.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m as e}from"./init-DjkROmXh.mjs";export{e as runInit};
|
package/dist/loader-DlfckqdT.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-ZHA8qsxF.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-BI2sVxtF.mjs";export{t as formatPreviewBlock,e as previewContent};
|