@inkeep/open-knowledge 0.8.1-beta.0 → 0.8.2-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.
Files changed (42) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +4 -4
  4. package/dist/constants-Dfx0JjpK.mjs +2 -0
  5. package/dist/{dist-D_gfC1Ni.mjs → dist-DC2tx33E.mjs} +1 -1
  6. package/dist/{dist-xB__nIDC.mjs → dist-ON5FDO_b.mjs} +14 -14
  7. package/dist/{gh-detect-Bh4D_lOI.mjs → gh-detect-C6XwLMEi.mjs} +2 -2
  8. package/dist/index.mjs +1 -1
  9. package/dist/init-aIylwWdF.mjs +1 -0
  10. package/dist/{init-7HcTIh5Y.mjs → init-fr_jOyuF.mjs} +4 -4
  11. package/dist/loader-C4wrjt04.mjs +1 -0
  12. package/dist/{loader-ctqWm4xx.mjs → loader-C9R7TB-p.mjs} +2 -2
  13. package/dist/{preview-lsOKH_Ea.mjs → preview-CG_Ww7f9.mjs} +2 -2
  14. package/dist/preview-z7bX_BMs.mjs +1 -0
  15. package/dist/public/assets/{ActivityModeContent-74fud2PX.js → ActivityModeContent-Cx6CbLSt.js} +1 -1
  16. package/dist/public/assets/{DocumentContext-D0hMZvqt.js → DocumentContext-Cr33tjJS.js} +21 -21
  17. package/dist/public/assets/{GraphPanel-CAKYBrh_.js → GraphPanel-Dmlbdo1u.js} +1 -1
  18. package/dist/public/assets/{SettingsDialogBody-CA5IZw_a.js → SettingsDialogBody-Dvybh9En.js} +2 -2
  19. package/dist/public/assets/{SourceEditor-Y1rYp83q.js → SourceEditor-BiT2vEI_.js} +2 -2
  20. package/dist/public/assets/{config-validation-events-CpTwSaaY.js → config-validation-events-CRmwXb5F.js} +5 -5
  21. package/dist/public/assets/index-DkifPd37.js +1914 -0
  22. package/dist/public/assets/{prop-types-vr6qWjMf.js → prop-types-BLfKJYBj.js} +1 -1
  23. package/dist/public/assets/{target-navigation-intent-BTTe7RwN.js → target-navigation-intent-DINFA28Q.js} +1 -1
  24. package/dist/public/assets/{toggle-group-BKjtvTFY.js → toggle-group-D4mjbvqQ.js} +1 -1
  25. package/dist/public/assets/{typing-burst-detector-RJxLgd3M.js → typing-burst-detector-DcMiqTtE.js} +2 -2
  26. package/dist/public/index.html +7 -7
  27. package/dist/{repair-launch-json-D5-eIzRz.mjs → repair-launch-json-DLEdDKoD.mjs} +2 -2
  28. package/dist/{repair-mcp-configs-CNfL2apH.mjs → repair-mcp-configs-ziIFi7z-.mjs} +2 -2
  29. package/dist/{repair-skills-DoA5FfyG.mjs → repair-skills-BVLn0Rlf.mjs} +2 -2
  30. package/dist/repair-skills-R77pTaUK.mjs +1 -0
  31. package/dist/{src-BS2LaApt.mjs → src-BawITI5a.mjs} +2 -2
  32. package/dist/start-BBgW41iZ.mjs +1 -0
  33. package/dist/{start-D_X5IFLP.mjs → start-BCWfuBoE.mjs} +2 -2
  34. package/dist/{write-project-skill-tdvNPxGJ.mjs → write-project-skill-ClozZcPj.mjs} +2 -2
  35. package/package.json +1 -1
  36. package/dist/constants-D8Tr-U92.mjs +0 -2
  37. package/dist/init-CAOR4stQ.mjs +0 -1
  38. package/dist/loader-C-xXW6Bu.mjs +0 -1
  39. package/dist/preview-pw30ZVMT.mjs +0 -1
  40. package/dist/public/assets/index-DC8kiUXp.js +0 -1914
  41. package/dist/repair-skills-DPnST7TD.mjs +0 -1
  42. package/dist/start-D--yk5mZ.mjs +0 -1
@@ -3,7 +3,7 @@ name: open-knowledge-discovery
3
3
  description: "Read when the user asks what Open Knowledge is, wants to install it on a repository, wants to share an Open Knowledge project with collaborators, or asks how `ok init` / `ok install-skill` / OK Desktop set up a project. Do NOT load to perform Open Knowledge reads/writes — the runtime guidance for editing markdown inside an initialized OK project ships as a separate project-local skill at `.claude/skills/open-knowledge/` whenever `ok init` runs. If the user appears to be editing markdown inside a `.ok/` project and this is the only OK skill loaded, advise them to re-run `ok init` to install the project-local skill."
4
4
  compatibility: "Any agent host — no MCP server required. Pure discovery + install guidance."
5
5
  metadata:
6
- version: "0.8.1-beta.0"
6
+ version: "0.8.2-beta.0"
7
7
  author: "Inkeep"
8
8
  repository: "https://github.com/inkeep/open-knowledge"
9
9
  ---
@@ -3,7 +3,7 @@ name: open-knowledge
3
3
  description: "MUST invoke before reading or editing any `.md` / `.mdx` file, and before any `mcp__open-knowledge__*` tool call (`exec`, `search`, `write_document`, `edit_document`, and the rest). This skill is installed into the repository by `ok init`, so its presence alone means this is an Open Knowledge project — its runtime contract governs every markdown file here, with no need to probe for a `.ok/` directory. Authoritative agent-runtime contract; supersedes the overlapping MCP server `instructions` echo."
4
4
  compatibility: "Claude Code, Claude Desktop, Claude Cowork, Claude.ai web. Requires Open Knowledge MCP server + code execution."
5
5
  metadata:
6
- version: "0.8.1-beta.0"
6
+ version: "0.8.2-beta.0"
7
7
  author: "Inkeep"
8
8
  repository: "https://github.com/inkeep/open-knowledge"
9
9
  ---
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{$i as n,A as r,Er as i,G as a,Gi as o,Ji as s,K as c,Ki as l,Li as u,Mt as d,Ni as f,On as p,Qi as m,Ui as h,Vi as g,Wi as _,Wn as v,Xi as y,Y as ee,Yi as b,Zi as x,_i as te,_n as ne,at as re,b as ie,bi as ae,ci as oe,cr as se,di as ce,dr as S,ea as le,fi as ue,ft as de,h as fe,hi as pe,j as me,li as he,lt as ge,mn as _e,nr as ve,qi as ye,rn as be,rt as xe,si as Se,ta as Ce,ui as we,vi as Te,x as Ee,yi as De,zi as Oe}from"./dist-xB__nIDC.mjs";import{a as ke,n as Ae,r as je,t as Me}from"./gh-detect-Bh4D_lOI.mjs";import{n as Ne,r as Pe,t as C}from"./dist-bundle-BK4P1EQn.mjs";import{A as Fe,C as Ie,D as Le,E as Re,O as ze,S as Be,T as Ve,b as He,k as Ue,o as We,p as Ge,w as Ke,x as qe}from"./init-7HcTIh5Y.mjs";import{c as Je,f as Ye,l as Xe,n as Ze,s as w}from"./server-lock-BIY3RMaC-CfCHCMTe.mjs";import{r as Qe}from"./git-handle-uz8TUFSi-BRV63-ar.mjs";import{n as $e,t as et}from"./constants-D8Tr-U92.mjs";import{i as tt}from"./src-BS2LaApt.mjs";import{n as nt,t as rt}from"./loader-ctqWm4xx.mjs";import{c as it,f as at,h as ot,m as st,p as ct,u as lt}from"./start-D_X5IFLP.mjs";import{c as ut,i as T,n as E,o as D,r as O,s as dt,t as k}from"./colors-BtKMHmBX.mjs";import{n as ft}from"./repair-skills-DoA5FfyG.mjs";import{execSync as pt,spawn as mt,spawnSync as A}from"node:child_process";import ht,{basename as gt,dirname as _t,isAbsolute as vt,join as j,relative as yt,resolve as M}from"node:path";import{accessSync as bt,closeSync as xt,constants as St,createWriteStream as Ct,existsSync as N,lstatSync as wt,mkdirSync as Tt,mkdtempSync as Et,openSync as Dt,readFileSync as P,readdirSync as Ot,realpathSync as kt,rmSync as At,statSync as jt,unlinkSync as Mt,writeFileSync as Nt}from"node:fs";import Pt from"node:process";import{freemem as Ft,homedir as It,hostname as Lt,platform as Rt,release as zt,tmpdir as Bt,totalmem as Vt,type as Ht,uptime as Ut}from"node:os";import{fileURLToPath as Wt}from"node:url";import{AsyncLocalStorage as Gt,AsyncResource as Kt}from"node:async_hooks";import{stripVTControlCharacters as qt,styleText as F}from"node:util";import*as Jt from"node:readline";import{createHash as Yt,randomUUID as Xt}from"node:crypto";import{realpath as Zt}from"node:fs/promises";import{setTimeout as Qt}from"node:timers/promises";import{createInterface as $t}from"node:readline/promises";async function en(e,t,n){let r=tn(await nn(e)).host??``;if(!r)return 1;let i=await n.get(r);if(i==null)return 1;let a=e=>e.replace(/[\r\n]/g,``);return t.write(`username=${a(i.login)}\npassword=${a(i.token)}\n`),0}function tn(e){let t={};for(let n of e.split(`
2
+ import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{$i as n,A as r,Er as i,G as a,Gi as o,Ji as s,K as c,Ki as l,Li as u,Mt as d,Ni as f,On as p,Qi as m,Ui as h,Vi as g,Wi as _,Wn as v,Xi as y,Y as ee,Yi as b,Zi as x,_i as te,_n as ne,at as re,b as ie,bi as ae,ci as oe,cr as se,di as ce,dr as S,ea as le,fi as ue,ft as de,h as fe,hi as pe,j as me,li as he,lt as ge,mn as _e,nr as ve,qi as ye,rn as be,rt as xe,si as Se,ta as Ce,ui as we,vi as Te,x as Ee,yi as De,zi as Oe}from"./dist-ON5FDO_b.mjs";import{a as ke,n as Ae,r as je,t as Me}from"./gh-detect-C6XwLMEi.mjs";import{n as Ne,r as Pe,t as C}from"./dist-bundle-BK4P1EQn.mjs";import{A as Fe,C as Ie,D as Le,E as Re,O as ze,S as Be,T as Ve,b as He,k as Ue,o as We,p as Ge,w as Ke,x as qe}from"./init-fr_jOyuF.mjs";import{c as Je,f as Ye,l as Xe,n as Ze,s as w}from"./server-lock-BIY3RMaC-CfCHCMTe.mjs";import{r as Qe}from"./git-handle-uz8TUFSi-BRV63-ar.mjs";import{n as $e,t as et}from"./constants-Dfx0JjpK.mjs";import{i as tt}from"./src-BawITI5a.mjs";import{n as nt,t as rt}from"./loader-C9R7TB-p.mjs";import{c as it,f as at,h as ot,m as st,p as ct,u as lt}from"./start-BCWfuBoE.mjs";import{c as ut,i as T,n as E,o as D,r as O,s as dt,t as k}from"./colors-BtKMHmBX.mjs";import{n as ft}from"./repair-skills-BVLn0Rlf.mjs";import{execSync as pt,spawn as mt,spawnSync as A}from"node:child_process";import ht,{basename as gt,dirname as _t,isAbsolute as vt,join as j,relative as yt,resolve as M}from"node:path";import{accessSync as bt,closeSync as xt,constants as St,createWriteStream as Ct,existsSync as N,lstatSync as wt,mkdirSync as Tt,mkdtempSync as Et,openSync as Dt,readFileSync as P,readdirSync as Ot,realpathSync as kt,rmSync as At,statSync as jt,unlinkSync as Mt,writeFileSync as Nt}from"node:fs";import Pt from"node:process";import{freemem as Ft,homedir as It,hostname as Lt,platform as Rt,release as zt,tmpdir as Bt,totalmem as Vt,type as Ht,uptime as Ut}from"node:os";import{fileURLToPath as Wt}from"node:url";import{AsyncLocalStorage as Gt,AsyncResource as Kt}from"node:async_hooks";import{stripVTControlCharacters as qt,styleText as F}from"node:util";import*as Jt from"node:readline";import{createHash as Yt,randomUUID as Xt}from"node:crypto";import{realpath as Zt}from"node:fs/promises";import{setTimeout as Qt}from"node:timers/promises";import{createInterface as $t}from"node:readline/promises";async function en(e,t,n){let r=tn(await nn(e)).host??``;if(!r)return 1;let i=await n.get(r);if(i==null)return 1;let a=e=>e.replace(/[\r\n]/g,``);return t.write(`username=${a(i.login)}\npassword=${a(i.token)}\n`),0}function tn(e){let t={};for(let n of e.split(`
3
3
  `)){let e=n.trim();if(e===``)continue;let r=e.indexOf(`=`);r!==-1&&(t[e.slice(0,r)]=e.slice(r+1))}return t}function nn(e){return new Promise((t,n)=>{let r=[];e.on(`data`,e=>r.push(e)),e.on(`end`,()=>t(Buffer.concat(r).toString(`utf-8`))),e.on(`error`,n)})}function rn(e){let n=new t(`git-credential`);return n.description(`Git credential helper (git credential-helper protocol)`),n.command(`get`).description(`Lookup credentials from TokenStore (called by git)`).action(async()=>{let t=await e(),n=await en(process.stdin,process.stdout,t);process.exit(n)}),n}function an(e){let t=e.endpoint.DEFAULTS;return/^https:\/\/(api\.)?github\.com$/.test(t.baseUrl)?`https://github.com`:t.baseUrl.replace(`/api/v3`,``)}async function on(e,t,n){let r={baseUrl:an(e),headers:{accept:`application/json`},...n},i=await e(t,r);if(`error`in i.data){let n=new Ne(`${i.data.error_description} (${i.data.error}, ${i.data.error_uri})`,400,{request:e.endpoint.merge(t,r)});throw n.response=i,n}return i}async function sn(e){let t=e.request||C,n={client_id:e.clientId};return`scopes`in e&&Array.isArray(e.scopes)&&(n.scope=e.scopes.join(` `)),on(t,`POST /login/device/code`,n)}async function cn(e){let t=await on(e.request||C,`POST /login/oauth/access_token`,{client_id:e.clientId,device_code:e.code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`}),n={clientType:e.clientType,clientId:e.clientId,token:t.data.access_token,scopes:t.data.scope.split(/\s+/).filter(Boolean)};if(`clientSecret`in e&&(n.clientSecret=e.clientSecret),e.clientType===`github-app`){if(`refresh_token`in t.data){let e=new Date(t.headers.date).getTime();n.refreshToken=t.data.refresh_token,n.expiresAt=ln(e,t.data.expires_in),n.refreshTokenExpiresAt=ln(e,t.data.refresh_token_expires_in)}delete n.scopes}return{...t,authentication:n}}function ln(e,t){return new Date(e+t*1e3).toISOString()}async function un(e,t){let n=dn(e,t.auth);if(n)return n;let{data:r}=await sn({clientType:e.clientType,clientId:e.clientId,request:t.request||e.request,scopes:t.auth.scopes||e.scopes});await e.onVerification(r);let i=await pn(t.request||e.request,e.clientId,e.clientType,r);return e.authentication=i,i}function dn(e,t){if(t.refresh===!0||!e.authentication)return!1;if(e.clientType===`github-app`)return e.authentication;let n=e.authentication;return(`scopes`in t&&t.scopes||e.scopes).join(` `)===n.scopes.join(` `)?n:!1}async function fn(e){await new Promise(t=>setTimeout(t,e*1e3))}async function pn(e,t,n,r){try{let i={clientId:t,request:e,code:r.device_code},{authentication:a}=n===`oauth-app`?await cn({...i,clientType:`oauth-app`}):await cn({...i,clientType:`github-app`});return{type:`token`,tokenType:`oauth`,...a}}catch(i){if(!i.response)throw i;let a=i.response.data.error;if(a===`authorization_pending`)return await fn(r.interval),pn(e,t,n,r);if(a===`slow_down`)return await fn(r.interval+7),pn(e,t,n,r);throw i}}async function mn(e,t){return un(e,{auth:t})}async function hn(e,t,n,r){let i=t.endpoint.merge(n,r);if(/\/login\/(oauth\/access_token|device\/code)$/.test(i.url))return t(i);let{token:a}=await un(e,{request:t,auth:{type:`oauth`}});return i.headers.authorization=`token ${a}`,t(i)}var gn=`0.0.0-development`;function _n(e){let t=e.request||C.defaults({headers:{"user-agent":`octokit-auth-oauth-device.js/${gn} ${Pe()}`}}),{request:n=t,...r}=e,i=e.clientType===`github-app`?{...r,clientType:`github-app`,request:n}:{...r,clientType:`oauth-app`,request:n,scopes:e.scopes||[]};if(!e.clientId)throw Error(`[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)`);if(!e.onVerification)throw Error(`[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)`);return Object.assign(mn.bind(null,i),{hook:hn.bind(null,i)})}async function vn(e){let{clientId:t,scopes:n=[`repo`,`read:user`,`user:email`],onVerification:r,host:i}=e,a=i&&i!==`github.com`?`https://${i}/api/v3`:`https://api.github.com`,o=_n({clientType:`oauth-app`,clientId:t,scopes:n,onVerification:async e=>{await r({verificationUri:e.verification_uri,userCode:e.user_code,expiresIn:e.expires_in,interval:e.interval})},request:a===`https://api.github.com`?void 0:(await import(`./dist-bundle-CjV1Pdeo.mjs`)).request.defaults({baseUrl:a})}),s;try{s=await o({type:`oauth`})}catch(e){if(e instanceof Error){let t=e.message.toLowerCase();throw t.includes(`access_denied`)?Error(`Device-flow authorization was denied.`):t.includes(`expired_token`)||t.includes(`timeout`)||t.includes(`timed out`)?Error(`Device-flow code expired before authorization — please try again.`):Error(`GitHub sign-in failed: ${e.message}`)}throw e}return{token:s.token,tokenType:s.tokenType,scopes:s.scopes??[]}}const yn={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var bn;(function(e){})(bn||={});function xn(e){return n(h,e)}function Sn(){return process.env.OPEN_KNOWLEDGE_GITHUB_CLIENT_ID??`Ov23liqlSd0V1MwR6rhI`}const Cn=new Set([`gitlab.com`,`bitbucket.org`,`codeberg.org`,`gitea.com`,`sr.ht`,`sourcehut.org`]);function I(e){let t=e.toLowerCase().replace(/:\d+$/,``);Cn.has(t)&&(process.stderr.write(`Error: ${e} is not a GitHub host. Only GitHub and GitHub Enterprise Server are supported.\n`),process.exit(1))}function wn(e,t){e&&process.stdout.write(`${JSON.stringify(t)}\n`)}async function Tn(e,t,n=vn){let r=Sn(),{host:i,json:a}=e;I(i),a||process.stderr.write(`Logging in to ${i}\n`);let o=await n({clientId:r,host:i===`github.com`?void 0:i,onVerification:e=>{e.userCode,e.verificationUri,a?wn(!0,{type:`verification`,user_code:e.userCode,verification_uri:e.verificationUri,expires_in:e.expiresIn}):process.stderr.write(`Open: ${e.verificationUri}\nEnter code: ${e.userCode}\n`)}}),s=`unknown`,c,l;try{let e=i===`github.com`?`https://api.github.com`:`https://${i}/api/v3`,t=await fetch(`${e}/user`,{headers:{Authorization:`Bearer ${o.token}`,"User-Agent":`open-knowledge-cli`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();s=e.login??s,c=e.name??void 0,l=e.email??void 0}}catch{}await t.set(i,s,o.token,{gitProtocol:`https`,name:c,email:l}),a?wn(!0,{type:`complete`,host:i,login:s}):process.stderr.write(`✓ Logged in as ${s} on ${i}\n`)}function En(e){return new t(`login`).description(`Authenticate with GitHub via Device Flow`).option(`--host <host>`,`GitHub or GitHub Enterprise hostname`,`github.com`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{await Tn(t,await e())})}const Dn=e=>e.name===`enter`||e.name===`return`;var On=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},kn=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},An=class extends Error{name=`ExitPromptError`},jn=class extends Error{name=`HookError`},Mn=class extends Error{name=`ValidationError`};const Nn=new Gt;function Pn(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Fn(e,t){let n=Pn(e);return Nn.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function L(){let e=Nn.getStore();if(!e)throw new jn(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function In(){return L().rl}function Ln(e){return Kt.bind((...t)=>{let n=L(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function Rn(e){let t=L(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function zn(){L().handleChange()}const Bn={queue(e){let t=L(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(In());if(r!=null&&typeof r!=`function`)throw new Mn(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=L();Ln(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=L();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function Vn(e){return typeof e==`function`}function R(e){return Rn(t=>{let n=Kt.bind(function(e){t.get()!==e&&(t.set(e),zn())});if(t.initialized)return[t.get(),n];let r=Vn(e)?e():e;return t.set(r),[r,n]})}function Hn(e,t){Rn(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&Bn.queue(e),n.set(t)})}const Un={prefix:{idle:F(`blue`,`?`),done:F(`green`,Fe.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>F(`yellow`,e))},style:{answer:e=>F(`cyan`,e),message:e=>F(`bold`,e),error:e=>F(`red`,`> ${e}`),defaultAnswer:e=>F(`dim`,`(${e})`),help:e=>F(`dim`,e),highlight:e=>F(`cyan`,e),key:e=>F(`cyan`,F(`bold`,`<${e}>`))}};function Wn(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Gn(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=Wn(n)&&Wn(r)?Gn(n,r):r}return t}function Kn(...e){return Gn(Un,...e.filter(e=>e!=null))}function qn({status:e=`idle`,theme:t}){let[n,r]=R(!1),[i,a]=R(0),{prefix:o,spinner:s}=Kn(t);return Hn(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function Jn(e){return R({current:e})[0]}function Yn(e){let t=Jn(e);t.current=e,Hn(e=>{let n=!1,r=Ln((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var Xn=e(Ue(),1);function Zn(e,t){return e.split(`
4
4
  `).flatMap(e=>ze(e,t,{trim:!1,hard:!0}).split(`
5
5
  `).map(e=>e.trimEnd())).join(`
@@ -20,10 +20,10 @@ import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";impor
20
20
  `),patterns:[...t],lineCount:n}}function _i(e){let t=j(e,`.ok`,`config.yml`);if(N(t))try{let e=P(t,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch{}return N(j(e,`.ok`))?Yt(`sha256`).update(M(e)).digest(`hex`).slice(0,12):null}function vi(){let e={timestamp:new Date().toISOString(),platform:Rt(),osType:Ht(),osRelease:zt(),hostname:`[redacted]`,uptime:Ut(),freeMem:Ft(),totalMem:Vt(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=pt(`sw_vers -productVersion 2>/dev/null`,{encoding:`utf8`}).trim()}catch{}try{let t=j(__dirname,`..`,`..`,`package.json`);N(t)&&(e.okVersion=JSON.parse(P(t,`utf8`)).version)}catch{}return e}function yi(e){if(!N(pi))return{files:[],dir:pi};let t=Ot(pi).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>j(pi,e));if(e&&t.length>0){let n=t.filter(t=>{try{return P(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});n.length>0&&(t=n)}return{files:t,dir:pi}}function bi(e){let t=j(e,`.ok`,`local`);return N(t)?{files:[`server.lock`,`last-spawn-error.log`].map(e=>j(t,e)).filter(e=>N(e)),dir:t}:{files:[],dir:null}}async function xi(t){let n=Yc();Tt(mi,{recursive:!0});let r=j(mi,`${new Date().toISOString().replace(/[:.]/g,`-`)}-bugreport.zip`);n?.info({projectSlug:t.projectSlug},`gathering diagnostic data`);let i=vi(),{files:a}=yi(t.projectSlug),{files:o}=bi(t.cwd);n?.info({logFileCount:a.length,lockFileCount:o.length},`files collected`);let s=[],c=[],{ZipFile:l}=await import(`./yazl-CJayzk0b.mjs`).then(t=>e(t.default,1)),u=new l;for(let e of a)try{let{redacted:t,patterns:n,lineCount:r}=gi(P(e,`utf8`)),i=`logs/${gt(e)}`;u.addBuffer(Buffer.from(t,`utf8`),i),c.push(i),n.length>0&&s.push({file:i,lineCount:r,patterns:n})}catch{}for(let e of o)try{let{redacted:t,patterns:n,lineCount:r}=gi(P(e,`utf8`)),i=`lockdir/${gt(e)}`;u.addBuffer(Buffer.from(t,`utf8`),i),c.push(i),n.length>0&&s.push({file:i,lineCount:r,patterns:n})}catch{}let d=JSON.stringify(i,null,2);u.addBuffer(Buffer.from(d,`utf8`),`sysinfo.json`),c.push(`sysinfo.json`);let f={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:t.projectSlug,files:c,redactions:s,sysinfo:i};u.addBuffer(Buffer.from(JSON.stringify(f,null,2),`utf8`),`MANIFEST.json`);let p=s.reduce((e,t)=>e+t.lineCount,0),m=[`# Bug Report Bundle`,``,`Generated: ${f.generatedAt}`,`Project: ${t.projectSlug??`(unscoped)`}`,`Discipline version: ${f.disciplineVersion}`,``,`## Contents`,``,...c.map(e=>`- ${e}`),``,`## Privacy`,``,`This bundle was auto-redacted before packaging.`,`Patterns checked: ${hi.map(e=>e.name).join(`, `)}`,p>0?`${p} line(s) were scrubbed across ${s.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`].join(`
21
21
  `);u.addBuffer(Buffer.from(m,`utf8`),`README.md`),u.end();let h=Ct(r);if(u.outputStream.pipe(h),await new Promise((e,t)=>{h.on(`close`,e),h.on(`error`,t)}),n?.info({bundlePath:r,fileCount:c.length,redactionCount:p},`bundle written`),process.stdout.write(`${r}\n`),p>0&&process.stderr.write(`ok bug-report: ${p} line(s) auto-redacted across ${s.length} file(s)\n`),!t.noReveal&&Rt()===`darwin`)try{mt(`/usr/bin/open`,[`-R`,r],{detached:!0,stdio:`ignore`}).unref()}catch{}return r}function Si(){return new t(`bug-report`).description(`Generate a diagnostic bundle for bug reporting`).option(`--reveal`,`Reveal the bundle in Finder (default: true)`,!0).option(`--no-reveal`,`Do not reveal the bundle in Finder`).action(async e=>{let t=process.cwd(),n=_i(t);try{await xi({projectSlug:n,cwd:t,noReveal:!e.reveal})}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`ok bug-report: failed — ${t}\n`),process.exitCode=1}})}function V(e,t,n={}){let r=Xe(e,t);if(!N(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(P(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!Je(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??w)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};let o=n.host??Lt();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Ci(e,t){let n=[];for(let[r,i]of[[`server`,e],[`ui`,t]])(i.status===`dead-pid`||i.status===`corrupt`)&&n.push({name:r,lockPath:i.lockPath,reason:i.status});return{prune:n}}function wi(e){let t=e.inspect??(t=>V(e.lockDir,t)),n=e.unlink??(e=>Mt(e)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=Ci(t(`server`),t(`ui`));if(a.prune.length===0)return r(`No stale locks.`),{pruned:[],failed:[]};let o=[],s=[];for(let e of a.prune)try{n(e.lockPath),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}if(o.length>0){let e=o.map(e=>`${e.name} (${e.reason})`).join(`, `);r(`Pruned ${o.length} stale lock${o.length===1?``:`s`}: ${e}`)}return s.length>0&&i(`Failed to prune: ${s.map(({target:e,error:t})=>`${e.name} (${e.lockPath}): ${t}`).join(`; `)}`),{pruned:o,failed:s}}function Ti(e){return new t(`clean`).description(`Prune stale / corrupt open-knowledge lock files (never touches live locks)`).action(()=>{e(),wi({lockDir:S(process.cwd())}).failed.length>0&&(process.exitCode=1)})}async function Ei(e,t,n={},r=Me){if(!n.skipGhDetect&&r().available)return{tier:`A`,credentialArgs:[`-c`,`credential.helper=!gh auth git-credential`]};let i=await t.get(e);return i==null?{tier:`none`,credentialArgs:[]}:{tier:i.gitProtocol===`ssh`?`C`:`B`,credentialArgs:[`-c`,`credential.helper=!open-knowledge auth git-credential`]}}async function Di(e,t,n=fetch){let r=new AbortController,i=setTimeout(()=>r.abort(),5e3);try{return(await n(`https://api.github.com/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{signal:r.signal,headers:{"User-Agent":`open-knowledge-cli`,Accept:`application/vnd.github+json`}})).status===200}catch{return!1}finally{clearTimeout(i)}}const Oi=[[`count`,0,10],[`compress`,10,20],[`receiv`,20,60],[`resolv`,60,100]];function ki(e){let t=/^([\w ]+):\s+(\d+)%/.exec(e.trim());if(!t)return null;let n=t[1].toLowerCase(),r=Number(t[2]);for(let[e,i,a]of Oi)if(n.includes(e))return{stage:t[1],pct:Math.round(i+r/100*(a-i))};return null}function H(e,t){e&&process.stdout.write(`${JSON.stringify(t)}\n`)}function Ai(e){return typeof e!=`string`||e.length===0?[`--progress`]:[`--progress`,`-b`,e]}const ji=Oe;async function Mi(e){try{return await e.clone(Ai(e.branch)),{fellBack:!1}}catch(t){if(e.branch!==null&&ji(t))return e.onFallback(e.branch),await e.clone(Ai(null)),{fellBack:!0};throw t}}function Ni(e,t,n){return e===`https`&&t===`github.com`&&n}async function Pi(e,t,n,r=process.cwd()){let i=tt(e);if(!i)throw Error(`Invalid git URL: ${e}`);let a=t.dir?M(r,t.dir):M(r,i.name);if(N(a)&&Ot(a).length>0)throw Error(`Target directory is not empty: ${a}`);let o=ke(),s=i.protocol===`https`&&i.hostname===`github.com`?await Di(i.owner,i.name):!1,c=Ni(i.protocol,i.hostname,s)?{tier:`none`,credentialArgs:[]}:await Ei(i.hostname,o,{}),l=Qe({baseDir:r,config:c.credentialArgs.length>=2?[c.credentialArgs[1]]:[],unsafe:{allowUnsafeCredentialHelper:!0}}).env({GIT_TERMINAL_PROMPT:`0`}),u=-1;l.outputHandler((e,n,r)=>{r.on(`data`,e=>{let n=e.toString(`utf-8`);for(let e of n.split(`
22
22
  `)){let n=ki(e);n&&n.pct!==u&&(u=n.pct,H(t.json,{type:`progress`,pct:n.pct,stage:n.stage}),t.json||process.stderr.write(`\r Cloning ${n.pct}%`))}})}),await Mi({branch:typeof t.branch==`string`&&t.branch.length>0?t.branch:null,clone:t=>l.clone(e,a,t),onFallback:e=>{H(t.json,{type:`branch-fallback`,branch:e}),t.json||process.stderr.write(`\n Branch '${e}' not found upstream — cloning default branch instead.\n`)}}),t.json||process.stderr.write(`
23
- `);try{let{runInit:e}=await import(`./init-CAOR4stQ.mjs`),n=await e({cwd:a,mcp:!1});if(n.contentUpdated.length>0){let e=`auto-init: updated ${n.contentUpdated.join(`, `)}`;t.json?H(!0,{type:`warning`,message:e}):process.stderr.write(` ${e}\n`)}}catch(e){let n=e instanceof Error?e.message:String(e);t.json?H(!0,{type:`warning`,message:`auto-init: ${n}`}):process.stderr.write(` auto-init: ${n}\n`)}try{Fi(a)}catch(e){let n=e instanceof Error?e.message:String(e);t.json?H(!0,{type:`warning`,message:`git-exclude: ${n}`}):process.stderr.write(` git-exclude: ${n}\n`)}return a}function Fi(e){let t=j(e,`.git`,`info`,`exclude`);if(!N(t))return`no-exclude`;let n=P(t,`utf-8`),r=new Set([`.ok`,`.ok/`,`/.ok`,`/.ok/`]);return n.split(`
23
+ `);try{let{runInit:e}=await import(`./init-aIylwWdF.mjs`),n=await e({cwd:a,mcp:!1});if(n.contentUpdated.length>0){let e=`auto-init: updated ${n.contentUpdated.join(`, `)}`;t.json?H(!0,{type:`warning`,message:e}):process.stderr.write(` ${e}\n`)}}catch(e){let n=e instanceof Error?e.message:String(e);t.json?H(!0,{type:`warning`,message:`auto-init: ${n}`}):process.stderr.write(` auto-init: ${n}\n`)}try{Fi(a)}catch(e){let n=e instanceof Error?e.message:String(e);t.json?H(!0,{type:`warning`,message:`git-exclude: ${n}`}):process.stderr.write(` git-exclude: ${n}\n`)}return a}function Fi(e){let t=j(e,`.git`,`info`,`exclude`);if(!N(t))return`no-exclude`;let n=P(t,`utf-8`),r=new Set([`.ok`,`.ok/`,`/.ok`,`/.ok/`]);return n.split(`
24
24
  `).map(e=>e.trim()).some(e=>r.has(e))?`already-present`:(Nt(t,`${n}${n.length===0||n.endsWith(`
25
25
  `)?``:`
26
- `}.ok/\n`,`utf-8`),`appended`)}function Ii(e){return new t(`clone`).description(`Clone a git repository and open it`).argument(`<url>`,`Repository URL or owner/repo shorthand`).argument(`[dir]`,`Target directory (default: ./<repo-name>)`).option(`--json`,`Output JSONL progress events`,!1).option(`-b, --branch <branch>`,`Branch to check out (falls back to default if missing)`).action(async(t,n,r)=>{let i=e();try{let a=await Pi(t,{json:r.json,dir:n,branch:r.branch??null},i);if(r.json)H(!0,{type:`complete`,dir:a});else{process.stderr.write(`✓ Cloned to ${a}\n`),process.chdir(a);let{startCommand:t}=await import(`./start-D--yk5mZ.mjs`);await t(e).parseAsync([],{from:`user`})}}catch(e){let t=e instanceof Error?e.message:String(e);r.json?H(!0,{type:`error`,message:t}):process.stderr.write(`✗ ${t}\n`),process.exitCode=1}})}var Li=Ce();const Ri=[[`sync`],[`persistence`,`debounceMs`],[`persistence`,`maxDebounceMs`],[`server`,`port`],[`content`,`include`],[`content`,`exclude`]];function zi(e={}){let t=e.log??(e=>console.error(e)),n=e.error??(e=>console.error(e)),r=e.loadConfigFn??nt;try{let{sources:n}=r(e.cwd);return t(`✓ Configuration valid (sources: ${n.length===0?`defaults only`:n.join(`, `)})`),{ok:!0}}catch(e){return n(e instanceof Error?e.message:String(e)),{ok:!1}}}function Bi(e){let t=(0,Li.parseDocument)(P(e,`utf-8`));if(t.errors.length>0)throw Error(`Could not parse ${e}: ${t.errors.map(e=>e.message).join(`; `)}`);let n=[];for(let e of Ri)t.hasIn(e)&&n.push(e.join(`.`));return n}function Vi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hi(e){let t={};for(let n of e){let e=t;for(let t=0;t<n.length-1;t++){let r=n[t],i=e[r],a=Vi(i)?i:{};e[r]=a,e=a}e[n[n.length-1]]=null}return t}async function Ui(e={}){let t=e.log??(e=>console.log(e)),n=e.error??(e=>console.error(e)),r=e.scope??`both`,i=e.dryRun??!1,a=e.cwd??process.cwd(),o=e.writeConfigPatchFn??te,s=[];(r===`project`||r===`both`)&&s.push({scope:`project`,absPath:pe(`project`,a,e.homedirOverride)}),(r===`user`||r===`both`)&&s.push({scope:`user`,absPath:pe(`user`,a,e.homedirOverride)});let c=[],l=!0;for(let{scope:t,absPath:n}of s){if(!N(n)){c.push({path:n,scope:t,found:[],removed:[]});continue}let r;try{r=Bi(n)}catch(e){let r=e instanceof Error?e.message:String(e);c.push({path:n,scope:t,found:[],removed:[],error:r}),l=!1;continue}if(r.length===0||i){c.push({path:n,scope:t,found:r,removed:[]});continue}let s=await o({cwd:a,scope:t,patch:Hi(Ri.filter(e=>r.includes(e.join(`.`)))),homedirOverride:e.homedirOverride});if(!s.ok){c.push({path:n,scope:t,found:r,removed:[],error:u(s.error)}),l=!1;continue}c.push({path:n,scope:t,found:r,removed:r})}for(let e of c)e.error&&n(`✗ ${e.path}: ${e.error}`);let d=c.some(e=>e.error!==void 0),f=c.reduce((e,t)=>e+t.found.length,0);if(f===0&&!d)t(`No deprecated fields found.`);else if(f>0)for(let e of c)e.error||(e.found.length===0?t(` ${e.path}: no deprecated fields`):t(i?`[dry-run] ${e.path}: would remove ${e.found.length} field(s): ${e.found.join(`, `)}`:`✓ ${e.path}: removed ${e.removed.length} field(s): ${e.removed.join(`, `)}`));return{outcomes:c,ok:l}}function Wi(){let e=new t(`config`).description(`Inspect and maintain Open Knowledge configuration files`);return e.command(`validate`).description(`Validate the merged config (defaults → user → project)`).action(()=>{zi({}).ok||(process.exitCode=1)}),e.command(`migrate`).description(`Remove deprecated config fields (sync.*, persistence.{debounceMs,maxDebounceMs}, server.port, content.{include,exclude}) idempotently`).option(`--scope <scope>`,`Which scope to migrate: project | user | both`,`both`).option(`--dry-run`,`Preview without writing`,!1).action(async e=>{let t=e.scope;if(t!==`project`&&t!==`user`&&t!==`both`){console.error(`Invalid --scope: ${t}. Expected: project | user | both`),process.exitCode=2;return}(await Ui({scope:t,dryRun:e.dryRun})).ok||(process.exitCode=1)}),e}var U=e(ut(),1);const W=2e3,Gi=2e3,Ki=[/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 qi(e){return Ki.some(t=>t.test(e))}function Ji(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 vt(e)?e:null}catch{return null}}function Yi(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&&vt(a)?a:null}function Xi(e){let t=[];for(let n of e.split(`
26
+ `}.ok/\n`,`utf-8`),`appended`)}function Ii(e){return new t(`clone`).description(`Clone a git repository and open it`).argument(`<url>`,`Repository URL or owner/repo shorthand`).argument(`[dir]`,`Target directory (default: ./<repo-name>)`).option(`--json`,`Output JSONL progress events`,!1).option(`-b, --branch <branch>`,`Branch to check out (falls back to default if missing)`).action(async(t,n,r)=>{let i=e();try{let a=await Pi(t,{json:r.json,dir:n,branch:r.branch??null},i);if(r.json)H(!0,{type:`complete`,dir:a});else{process.stderr.write(`✓ Cloned to ${a}\n`),process.chdir(a);let{startCommand:t}=await import(`./start-BBgW41iZ.mjs`);await t(e).parseAsync([],{from:`user`})}}catch(e){let t=e instanceof Error?e.message:String(e);r.json?H(!0,{type:`error`,message:t}):process.stderr.write(`✗ ${t}\n`),process.exitCode=1}})}var Li=Ce();const Ri=[[`sync`],[`persistence`,`debounceMs`],[`persistence`,`maxDebounceMs`],[`server`,`port`],[`content`,`include`],[`content`,`exclude`]];function zi(e={}){let t=e.log??(e=>console.error(e)),n=e.error??(e=>console.error(e)),r=e.loadConfigFn??nt;try{let{sources:n}=r(e.cwd);return t(`✓ Configuration valid (sources: ${n.length===0?`defaults only`:n.join(`, `)})`),{ok:!0}}catch(e){return n(e instanceof Error?e.message:String(e)),{ok:!1}}}function Bi(e){let t=(0,Li.parseDocument)(P(e,`utf-8`));if(t.errors.length>0)throw Error(`Could not parse ${e}: ${t.errors.map(e=>e.message).join(`; `)}`);let n=[];for(let e of Ri)t.hasIn(e)&&n.push(e.join(`.`));return n}function Vi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hi(e){let t={};for(let n of e){let e=t;for(let t=0;t<n.length-1;t++){let r=n[t],i=e[r],a=Vi(i)?i:{};e[r]=a,e=a}e[n[n.length-1]]=null}return t}async function Ui(e={}){let t=e.log??(e=>console.log(e)),n=e.error??(e=>console.error(e)),r=e.scope??`both`,i=e.dryRun??!1,a=e.cwd??process.cwd(),o=e.writeConfigPatchFn??te,s=[];(r===`project`||r===`both`)&&s.push({scope:`project`,absPath:pe(`project`,a,e.homedirOverride)}),(r===`user`||r===`both`)&&s.push({scope:`user`,absPath:pe(`user`,a,e.homedirOverride)});let c=[],l=!0;for(let{scope:t,absPath:n}of s){if(!N(n)){c.push({path:n,scope:t,found:[],removed:[]});continue}let r;try{r=Bi(n)}catch(e){let r=e instanceof Error?e.message:String(e);c.push({path:n,scope:t,found:[],removed:[],error:r}),l=!1;continue}if(r.length===0||i){c.push({path:n,scope:t,found:r,removed:[]});continue}let s=await o({cwd:a,scope:t,patch:Hi(Ri.filter(e=>r.includes(e.join(`.`)))),homedirOverride:e.homedirOverride});if(!s.ok){c.push({path:n,scope:t,found:r,removed:[],error:u(s.error)}),l=!1;continue}c.push({path:n,scope:t,found:r,removed:r})}for(let e of c)e.error&&n(`✗ ${e.path}: ${e.error}`);let d=c.some(e=>e.error!==void 0),f=c.reduce((e,t)=>e+t.found.length,0);if(f===0&&!d)t(`No deprecated fields found.`);else if(f>0)for(let e of c)e.error||(e.found.length===0?t(` ${e.path}: no deprecated fields`):t(i?`[dry-run] ${e.path}: would remove ${e.found.length} field(s): ${e.found.join(`, `)}`:`✓ ${e.path}: removed ${e.removed.length} field(s): ${e.removed.join(`, `)}`));return{outcomes:c,ok:l}}function Wi(){let e=new t(`config`).description(`Inspect and maintain Open Knowledge configuration files`);return e.command(`validate`).description(`Validate the merged config (defaults → user → project)`).action(()=>{zi({}).ok||(process.exitCode=1)}),e.command(`migrate`).description(`Remove deprecated config fields (sync.*, persistence.{debounceMs,maxDebounceMs}, server.port, content.{include,exclude}) idempotently`).option(`--scope <scope>`,`Which scope to migrate: project | user | both`,`both`).option(`--dry-run`,`Preview without writing`,!1).action(async e=>{let t=e.scope;if(t!==`project`&&t!==`user`&&t!==`both`){console.error(`Invalid --scope: ${t}. Expected: project | user | both`),process.exitCode=2;return}(await Ui({scope:t,dryRun:e.dryRun})).ok||(process.exitCode=1)}),e}var U=e(ut(),1);const W=2e3,Gi=2e3,Ki=[/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 qi(e){return Ki.some(t=>t.test(e))}function Ji(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 vt(e)?e:null}catch{return null}}function Yi(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&&vt(a)?a:null}function Xi(e){let t=[];for(let n of e.split(`
27
27
  `)){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)&&qi(a)&&t.push({pid:o,command:a})}return t}function Zi(e){let t=[],n=e.split(`
28
28
  `);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)&&qi(o)&&t.push({pid:s,command:o})}return t}async function Qi(){let e=A(`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:W});if(!(e.error!=null&&e.error.code===`ENOENT`)){let t=e.stdout??``,n=Xi(t);if(n.length>0||t.trim()===``)return n}let t=A(`ps`,[`-axo`,`pid,command`],{encoding:`utf-8`,timeout:W});return t.error!=null||!t.stdout?[]:Zi(t.stdout)}function $i(e){let t=e.trim().split(/\s+/).filter(Boolean);for(let e of t){if(e.startsWith(`@`))continue;let t=gt(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 ea(e){let t=A(`ps`,[`-p`,String(e),`-o`,`command=`],{encoding:`utf-8`,timeout:W});return t.error!=null||!t.stdout?null:t.stdout.trim()||null}function ta(e){let t=A(`ps`,[`-p`,String(e),`-o`,`%cpu=,%mem=`],{encoding:`utf-8`,timeout:W});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 na(e){let t=A(`lsof`,[`-p`,String(e),`-a`,`-d`,`cwd`,`-Fn`],{encoding:`utf-8`,timeout:W});if(t.error!=null)return null;let n=t.stdout??``;for(let e of n.split(`
29
29
  `))if(e.startsWith(`n`)&&e.length>1)return e.slice(1);return null}function ra(e){let t=[],n=e.split(`
@@ -61,7 +61,7 @@ setTimeout(() => process.exit(2), ${t+1e4});
61
61
  `,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}else{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
62
62
  `&&r++}}return[t,n]}var Cs=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=xs({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};const ws={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};var Y=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},Ts=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=so(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??ws}async _authThenStart(){if(!this._authProvider)throw new J(`No auth provider`);let e;try{e=await Qo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new J;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=oo(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:n,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new Y(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new Cs({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=oe.parse(JSON.parse(e.data));ue(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new J(`No auth provider`);if(await Qo(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new J(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:ce(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Y(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=ns(o);if(this._resourceMetadataUrl=t,this._scope=n,await Qo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new J;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=ns(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new Y(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await Qo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new J;return this.send(e)}}throw new Y(o.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),we(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`);if(c)if(l?.includes(`text/event-stream`))this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(l?.includes(`application/json`)){let e=await o.json(),t=Array.isArray(e)?e.map(e=>oe.parse(e)):[oe.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new Y(-1,`Unexpected content type: ${l}`);else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Y(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};function Es(e){return(t,n)=>{if((n?.method??`GET`).toUpperCase()===`GET`)return globalThis.fetch(t,n);let r=new AbortController,i=setTimeout(()=>r.abort(Error(`MCP request timed out after ${e}ms`)),e),a=n?.signal instanceof AbortSignal?AbortSignal.any([n.signal,r.signal]):r.signal;return globalThis.fetch(t,{...n,signal:a}).finally(()=>clearTimeout(i))}}function Ds(e){if(e===void 0||e===``)return;let t=Number.parseInt(e,10);if(!(Number.isNaN(t)||t<=0))return t}function Os(e){return e===`0.0.0.0`||e===`::`?`localhost`:e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function ks(e,t){return`http://${Os(e)}:${t}/mcp`}function As(e,t){return`ws://${Os(e)}:${t}`}function js(e){let t=new URL(e);return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.pathname=``,t.search=``,t.hash=``,t.toString().replace(/\/$/,``)}function Ms(e,t){if(!(!e||e.port<=0)&&t(e.pid))return e.port}function Ns(e){return N(e)?P(e,`utf-8`).trim():``}function Ps(e,t){return`server did not start within ${e}ms${t?` stderr:\n${t}`:``}`}function Fs(e){if(e&&typeof e==`object`&&`method`in e&&`id`in e)return e.id}function Is(e){if(!e||typeof e!=`object`||!(`result`in e))return;let t=e.result;if(!t||typeof t!=`object`||!(`protocolVersion`in t))return;let n=t.protocolVersion;return typeof n==`string`?n:void 0}function Ls(e,t){return{jsonrpc:`2.0`,id:e,error:{code:-32e3,message:t instanceof Error?t.message:String(t)}}}async function Rs(e){let t=e.readLock??(()=>Ye(e.lockDir)),n=e.isAlive??w,r=e.sleep??(e=>Qt(e)),i=e.spawn??mt,a=e.readErrorLog??Ns,o=e.openErrorLog??(e=>Dt(e,`w`)),s=e.closeFd??xt,c=e.timeoutMs??5e3,l=e.pollIntervalMs??100;if(e.portOverride!==void 0){let t=Number.parseInt(e.portOverride,10);if(Number.isNaN(t)||t<=0)throw Error(`invalid --port value '${e.portOverride}' — HTTP MCP shim requires a positive port`);return ks(`localhost`,t)}let u=Ms(t(),n);if(u!==void 0)return ks(`localhost`,u);if(e.envAutoStart===`0`)throw Error(`Open Knowledge server is not running and OK_MCP_AUTOSTART=0 disables auto-start.`);N(e.lockDir)||Tt(e.lockDir,{recursive:!0});let d=j(e.lockDir,f),p=o(d),m,h,g=at();try{try{m=i(g.command,[...g.prefixArgs,`start`],{detached:!0,stdio:[`ignore`,`ignore`,p],cwd:e.contentDir,env:{...process.env,OK_LOCK_KIND:`mcp-spawned`}}),m.on(`error`,e=>{h=e instanceof Error?e.message:String(e)}),m.unref()}catch(e){h=e instanceof Error?e.message:String(e)}}finally{try{s(p)}catch{}}let _=Date.now()+c;for(;Date.now()<_;){if(h){let e=a(d),t=e?` stderr:\n${e}`:``;throw Error(`spawn failed: ${h}${t}`)}await r(l);let e=Ms(t(),n);if(e!==void 0)return ks(`localhost`,e)}if(h){let e=a(d),t=e?` stderr:\n${e}`:``;throw Error(`spawn failed: ${h}${t}`)}throw Error(Ps(c,a(d)))}function zs(e,t){if(e.portOverride!==void 0)return js(t);let n=e.readLock??(()=>Ye(e.lockDir)),r=e.isAlive??w,i=Ms(n(),r);if(i!==void 0)return As(`localhost`,i)}async function Bs(e,t={}){let n=t.stderr??process.stderr,i=t.requestTimeoutMs??12e4,a=t.createStdioTransport?t.createStdioTransport(t.stdin,t.stdout):new to(t.stdin,t.stdout),o=t.createHttpTransport?t.createHttpTransport(new URL(e)):new Ts(new URL(e),{fetch:Es(i),...t.connectionId===void 0?{}:{requestInit:{headers:{[r]:t.connectionId}}}}),s=!1,c=async()=>{s||(s=!0,t.onclose?.(),await Promise.allSettled([a.close(),o.close()]))};a.onerror=e=>{n.write(`[mcp-shim] stdio error: ${e.message}\n`)},o.onerror=e=>{n.write(`[mcp-shim] HTTP transport error: ${e.message}\n`)},a.onclose=()=>{c()},o.onclose=()=>{c()};let l=Promise.resolve();a.onmessage=e=>{l=l.then(async()=>{try{await o.send(e)}catch(t){let r=Fs(e);if(r===void 0){n.write(`[mcp-shim] failed to forward stdio notification: ${t instanceof Error?t.message:String(t)}\n`);return}await a.send(Ls(r,t)).catch(e=>{n.write(`[mcp-shim] failed to write stdio error response: ${e instanceof Error?e.message:String(e)}\n`)})}}).catch(e=>{n.write(`[mcp-shim] unexpected stdio forwarding failure: ${e instanceof Error?e.message:String(e)}\n`)})},o.onmessage=e=>{let t=Is(e);t&&o.setProtocolVersion?.(t),a.send(e).catch(e=>{n.write(`[mcp-shim] failed to write stdio response: ${e instanceof Error?e.message:String(e)}\n`)})};try{await o.start(),await a.start()}catch(e){throw await c(),e}return{close:c}}async function Vs(e){let t=e.stderr??process.stderr,n=e.bridgeFn??Bs,r=await Rs(e),i=e.createConnectionId?.()??Xt(),a=!1,o=(e.startKeepalive??Za)({connectionId:i,resolveWsUrl:async()=>zs(e,r),log:e=>t.write(`[mcp-shim] keepalive: ${e}\n`)});t.write(`[mcp-shim] proxying stdio to ${r}\n`);let s;try{s=await n(r,{stderr:t,connectionId:i,onclose:()=>{a||(o.close(),process.exit(0))}})}catch(e){throw o.close(),e}let c=()=>{a=!0,o.close(),s.close().finally(()=>{process.exit(0)})};process.once(`SIGINT`,c),process.once(`SIGTERM`,c)}const Hs=Wt(import.meta.url);function Us(e){let t=M(e);for(;;){if(p(t))return t;let n=_t(t);if(n===t)throw Error(`No Open Knowledge project found at or above ${e}. Pass an explicit \`cwd\` argument that points inside an OK project (a directory with a \`${g}\`).`);t=n}}function Ws(e){try{let t=new URL(e);return t.protocol===`file:`?Wt(t):void 0}catch{return}}async function Gs(e){if(!e.getClientCapabilities()?.roots)return;let t;try{t=await e.listRoots()}catch(t){e.log?.(`listRoots fallback failed: ${t instanceof Error?t.message:String(t)}`);return}let n=t.roots??[];if(n.length!==1)return;let r=Ws(n[0].uri);return r===void 0&&e.log?.(`single root URI not usable as fs path: ${n[0].uri}`),r}async function Ks(e,t){if(e!==void 0)return Us(e);let n=await t();if(n!==void 0)return Us(n);throw Error("`cwd` is required for tool calls against the global MCP server. Pass an absolute path inside an Open Knowledge project, or have the MCP client advertise a single root.")}async function qs(e){let t=process.stderr,n=e.spawnTimeoutMs??Ds(process.env.OK_MCP_SPAWN_TIMEOUT_MS),r=e.envAutoStart??process.env.OK_MCP_AUTOSTART,a=rt({startupCwd:e.startupCwd,startupConfig:e.startupConfig}),o=new Se({name:me,version:Ze},{instructions:de({dir:`.`})});ne(o);let s=Xt(),c={current:{connectionId:s,displayName:s,colorSeed:s}},l=new Map,u=e=>{if(l.has(e))return;let n=be(e),r=c.current,i=Za({connectionId:s,displayName:r.displayName,clientName:r.clientInfo?.name??r.displayName,colorSeed:r.colorSeed,resolveWsUrl:async()=>zs({lockDir:n,contentDir:e},``),log:n=>t.write(`[mcp] keepalive[${e}]: ${n}\n`)});l.set(e,i)},d=()=>Gs({getClientCapabilities:()=>o.server.getClientCapabilities(),listRoots:()=>o.server.listRoots(),log:e=>t.write(`[mcp] ${e}\n`)}),f=e=>Ks(e,d),p=async e=>{let t;if(e===void 0){let e=await d();if(e===void 0)return;t=Us(e)}else t=Us(e);let i=await a(t),o=await Rs({lockDir:be(t),contentDir:se(i,t),envAutoStart:r,...n===void 0?{}:{timeoutMs:n}});return u(t),o.replace(/\/mcp$/,``)};o.server.oninitialized=()=>{let e=o.server.getClientVersion(),t=i(e?.name,s);c.current={connectionId:s,clientInfo:e?{name:t,version:e.version}:void 0,displayName:t,colorSeed:t}},ve(o,{serverUrl:p,resolveCwd:f,config:a,identityRef:c});let m=new to,h=!1,g,_=async()=>{if(h)return;h=!0,g?.stop();for(let e of l.values())try{e.close()}catch(e){t.write(`[mcp] keepalive close error: ${e instanceof Error?e.message:String(e)}\n`)}l.clear();let e=await Promise.allSettled([o.close(),m.close()]);for(let n of e)if(n.status===`rejected`){let e=n.reason;t.write(`[mcp] shutdown close error: ${e instanceof Error?e.message:String(e)}\n`)}};await o.connect(m),t.write(`[mcp] global stdio server ready (per-call project routing)
63
63
  `);let v=!1,y=()=>{v||(v=!0,setTimeout(()=>{t.write(`[mcp] shutdown deadline (5s) reached — forcing exit(1)
64
- `),process.exit(1)},5e3).unref(),_().finally(()=>{process.exit(0)}))};if(process.once(`SIGINT`,y),process.once(`SIGTERM`,y),ao({log:e=>t.write(`${e}\n`),transport:m,process,stdin:process.stdin}),process.platform===`darwin`){let e=io(Hs,{realpathSync:kt,statInoSync:e=>jt(e).ino,log:e=>t.write(`${e}\n`)});if(e!==void 0){t.write(`[mcp] bundle identity anchor=${e.resolvedPath} inode=${e.inode} version=${Ze}\n`);let{resolvedPath:n,inode:r}=e;g=ro({detect:()=>no({bundleAnchorPath:Hs,currentInode:r,platform:process.platform,realpath:kt,statInode:e=>jt(e).ino}),onReplaced:e=>{t.write(`[mcp] bundle replaced anchor=${n} bootInode=${e.currentInode} onDiskInode=${e.onDiskInode} version=${Ze} — exiting for host respawn\n`),y()},log:e=>t.write(`[mcp] ${e}\n`)})}}return{close:_}}function Js(e){return new t(`mcp`).description(`Start MCP stdio server for project knowledge base`).option(`-p, --port <port>`,`Override per-call routing and proxy stdio to this HTTP MCP port (skips bundle proxy)`,void 0).option(`--no-bundle-proxy`,`Run the npm-fetched MCP server in-process instead of proxying to the macOS Desktop bundle (equivalent: OK_BUNDLE_PROXY=0)`).action(async t=>{try{let n=e(),r=process.cwd();if(t.port!==void 0){let e=Ds(process.env.OK_MCP_SPAWN_TIMEOUT_MS);await Vs({lockDir:``,contentDir:``,portOverride:t.port,envAutoStart:process.env.OK_MCP_AUTOSTART,timeoutMs:e});return}let i=t.bundleProxy===!1?[...process.argv,`--no-bundle-proxy`]:process.argv,a=Ja(process.env,i,process.platform);if(a.proxy){let e=qa(process.platform,It(),{existsSync:N});if(e===null)Ya({stderr:process.stderr,mode:`fallback-absent`,bundlePath:null,reason:`no installed Open Knowledge.app bundle found`});else try{await Xa({bundlePath:e,argv:process.argv.slice(2),env:process.env,stderr:process.stderr});return}catch(t){Ya({stderr:process.stderr,mode:`fallback-exec-failed`,bundlePath:e,reason:t instanceof Error?t.message:String(t)})}}else{let e=a.suppressedBy===`env`?`suppressed-env`:a.suppressedBy===`flag`?`suppressed-flag`:a.suppressedBy===`self`?`suppressed-self`:`suppressed-platform`;Ya({stderr:process.stderr,mode:e,bundlePath:null,reason:null})}await qs({startupCwd:r,startupConfig:n})}catch(e){process.stderr.write(`MCP server failed to start: ${e instanceof Error?e.message:String(e)}\n`),process.exitCode=1}})}function Ys(e){return new t(`preview`).description(`Show what content the watcher will track (read-only)`).action(async()=>{let{previewContent:t,formatPreviewBlock:n}=await import(`./preview-pw30ZVMT.mjs`),r=e(),i=process.cwd(),a=se(r,i),o;try{o=t({projectDir:i,contentDir:a})}catch(e){console.error(`Content preview failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}process.stdout.write(`${n(o,i)}\n`),o.totalCount===0&&o.warnings.length>0&&(process.exitCode=1)})}function Xs(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Zs(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 Qs(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:$i(r),command:r,isDesktop:Xs(r)}}function $s(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function ec(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&$s(e)?`ui-orphan`:`stale`}const tc=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function nc(e){switch(e){case`running`:return U.default.green(e);case`desktop`:return U.default.blue(e);case`foreign`:return U.default.cyan(e);case`ui-orphan`:return U.default.magenta(e);case`stale`:return U.default.yellow(e)}}function rc(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ic(e){return`${rc(e.server.usage)} | ${rc(e.ui?.usage??null)}`}function ac(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function oc(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=ec(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,ac(e),ic(e),t,String(n),Zs(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=nc(ec(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=U.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
64
+ `),process.exit(1)},5e3).unref(),_().finally(()=>{process.exit(0)}))};if(process.once(`SIGINT`,y),process.once(`SIGTERM`,y),ao({log:e=>t.write(`${e}\n`),transport:m,process,stdin:process.stdin}),process.platform===`darwin`){let e=io(Hs,{realpathSync:kt,statInoSync:e=>jt(e).ino,log:e=>t.write(`${e}\n`)});if(e!==void 0){t.write(`[mcp] bundle identity anchor=${e.resolvedPath} inode=${e.inode} version=${Ze}\n`);let{resolvedPath:n,inode:r}=e;g=ro({detect:()=>no({bundleAnchorPath:Hs,currentInode:r,platform:process.platform,realpath:kt,statInode:e=>jt(e).ino}),onReplaced:e=>{t.write(`[mcp] bundle replaced anchor=${n} bootInode=${e.currentInode} onDiskInode=${e.onDiskInode} version=${Ze} — exiting for host respawn\n`),y()},log:e=>t.write(`[mcp] ${e}\n`)})}}return{close:_}}function Js(e){return new t(`mcp`).description(`Start MCP stdio server for project knowledge base`).option(`-p, --port <port>`,`Override per-call routing and proxy stdio to this HTTP MCP port (skips bundle proxy)`,void 0).option(`--no-bundle-proxy`,`Run the npm-fetched MCP server in-process instead of proxying to the macOS Desktop bundle (equivalent: OK_BUNDLE_PROXY=0)`).action(async t=>{try{let n=e(),r=process.cwd();if(t.port!==void 0){let e=Ds(process.env.OK_MCP_SPAWN_TIMEOUT_MS);await Vs({lockDir:``,contentDir:``,portOverride:t.port,envAutoStart:process.env.OK_MCP_AUTOSTART,timeoutMs:e});return}let i=t.bundleProxy===!1?[...process.argv,`--no-bundle-proxy`]:process.argv,a=Ja(process.env,i,process.platform);if(a.proxy){let e=qa(process.platform,It(),{existsSync:N});if(e===null)Ya({stderr:process.stderr,mode:`fallback-absent`,bundlePath:null,reason:`no installed Open Knowledge.app bundle found`});else try{await Xa({bundlePath:e,argv:process.argv.slice(2),env:process.env,stderr:process.stderr});return}catch(t){Ya({stderr:process.stderr,mode:`fallback-exec-failed`,bundlePath:e,reason:t instanceof Error?t.message:String(t)})}}else{let e=a.suppressedBy===`env`?`suppressed-env`:a.suppressedBy===`flag`?`suppressed-flag`:a.suppressedBy===`self`?`suppressed-self`:`suppressed-platform`;Ya({stderr:process.stderr,mode:e,bundlePath:null,reason:null})}await qs({startupCwd:r,startupConfig:n})}catch(e){process.stderr.write(`MCP server failed to start: ${e instanceof Error?e.message:String(e)}\n`),process.exitCode=1}})}function Ys(e){return new t(`preview`).description(`Show what content the watcher will track (read-only)`).action(async()=>{let{previewContent:t,formatPreviewBlock:n}=await import(`./preview-z7bX_BMs.mjs`),r=e(),i=process.cwd(),a=se(r,i),o;try{o=t({projectDir:i,contentDir:a})}catch(e){console.error(`Content preview failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}process.stdout.write(`${n(o,i)}\n`),o.totalCount===0&&o.warnings.length>0&&(process.exitCode=1)})}function Xs(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Zs(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 Qs(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:$i(r),command:r,isDesktop:Xs(r)}}function $s(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function ec(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&$s(e)?`ui-orphan`:`stale`}const tc=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function nc(e){switch(e){case`running`:return U.default.green(e);case`desktop`:return U.default.blue(e);case`foreign`:return U.default.cyan(e);case`ui-orphan`:return U.default.magenta(e);case`stale`:return U.default.yellow(e)}}function rc(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ic(e){return`${rc(e.server.usage)} | ${rc(e.ui?.usage??null)}`}function ac(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function oc(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=ec(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,ac(e),ic(e),t,String(n),Zs(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=nc(ec(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=U.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
65
65
  `)}async function sc(e={}){let t=e.discover??sa,n=e.inspect??V,r=e.log??(e=>console.log(e)),i=e.resolveCommand??ea,a=e.resolveUsage??ta,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=Qs(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:ec(e)}));r(JSON.stringify(e,null,2));return}r(oc(e.all?s:s.filter(e=>tc.has(ec(e)))))}function cc(){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 sc({all:t.all===!0||e===`all`,json:t.json===!0})})}function X(e,t){e&&process.stdout.write(`${JSON.stringify(t)}\n`)}async function lc(e,t,n=process.cwd()){let r=e.op??`sync`,i=Ye(S(n));if(i&&i.port>0){let t=`http://127.0.0.1:${i.port}/api/sync/trigger`;e.json||process.stderr.write(`Triggering ${r} via running server (port ${i.port})\n`);try{let n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:r})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.title??e.error??e.message??`Server responded with ${n.status}`)}X(e.json,{type:`triggered`,op:r,port:i.port}),e.json||process.stderr.write(`✓ ${r} triggered\n`);return}catch(t){let n=t instanceof Error?t.message:String(t);e.json||process.stderr.write(`Server trigger failed (${n}), running directly\n`)}}e.json||process.stderr.write(`Running ${r} directly (no live server)\n`);let a=Qe({baseDir:n});if(r===`sync`||r===`pull`){X(e.json,{type:`step`,step:`pull`});let t=await a.pull();X(e.json,{type:`pull`,summary:t.summary}),e.json||process.stderr.write(` pull: ${t.summary.changes} changes\n`)}(r===`sync`||r===`push`)&&(X(e.json,{type:`step`,step:`push`}),await a.push(),X(e.json,{type:`push`,ok:!0}),e.json||process.stderr.write(` push: ok
66
66
  `)),X(e.json,{type:`complete`,op:r}),e.json||process.stderr.write(`✓ ${r} complete\n`)}function uc(e){return new t(`sync`).description(`Commit, pull, and push to the remote`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{try{await lc({json:t.json,op:`sync`},e())}catch(e){let n=e instanceof Error?e.message:String(e);t.json?process.stdout.write(`${JSON.stringify({type:`error`,message:n})}\n`):process.stderr.write(`✗ sync failed: ${n}\n`),process.exit(1)}})}function dc(e){return new t(`pull`).description(`Pull changes from the remote`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{try{await lc({json:t.json,op:`pull`},e())}catch(e){let n=e instanceof Error?e.message:String(e);t.json?process.stdout.write(`${JSON.stringify({type:`error`,message:n})}\n`):process.stderr.write(`✗ pull failed: ${n}\n`),process.exit(1)}})}function fc(e){return new t(`push`).description(`Push commits to the remote`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{try{await lc({json:t.json,op:`push`},e())}catch(e){let n=e instanceof Error?e.message:String(e);t.json?process.stdout.write(`${JSON.stringify({type:`error`,message:n})}\n`):process.stderr.write(`✗ push failed: ${n}\n`),process.exit(1)}})}function pc(e){return typeof e==`string`&&c.includes(e)}async function mc(e={}){let t=M(e.cwd??process.cwd()),n=e.pack??`knowledge-base`;if(!a[n])return{status:`failed`,message:`${O(`Error:`)} Unknown pack "${n}". Available: ${c.join(`, `)}`,exitCode:1};let r;try{r=await v({projectDir:t,rootDir:e.root,packId:n})}catch(e){return e instanceof ee?{status:`prerequisite-missing`,message:`${O(`Error:`)} ${e.message}`,exitCode:1}:{status:`failed`,message:`${O(`Error:`)} ${e instanceof Error?e.message:String(e)}`,exitCode:1}}if(r.created.length===0){let e=a[n].name;return{status:`no-op`,message:`${D(`Your ${e} pack is already seeded.`)}\n${E(`Nothing to do.`)}`,plan:r,exitCode:0}}if(e.dryRun)return{status:`dry-run`,message:`${k(`Plan (dry-run — no changes made):`)}\n\n${gc(r,t)}`,plan:r,exitCode:0};if(!e.yes&&!await _c(`${k(`Plan:`)}\n\n${gc(r,t)}\n\n${k(`Apply?`)} ${E(`[Y/n] `)}`,e.confirmStream))return{status:`cancelled`,message:E(`Cancelled.`),plan:r,exitCode:0};let i=await xe(r,{projectDir:t,packId:n});if(i.errors.length>0){let e=i.errors.map(e=>` ${O(`✗`)} ${e.path}: ${e.error}`);return{status:`failed`,message:[`${dt(`Applied`)} ${i.applied} entries, ${dt(String(i.errors.length))} error(s):`,...e].join(`
67
67
  `),plan:r,exitCode:1}}let o=a[n].name;return{status:`applied`,message:`${D(`✓ Seeded ${o}`)} ${E(`(${i.applied} entries, ${i.durationMs}ms)`)}`,plan:r,exitCode:0}}function hc(){let e=[k(`Available packs:`)];for(let t of c){let n=a[t];e.push(` ${D(t)} ${E(`—`)} ${n.name}: ${n.description}`)}return e.join(`
@@ -0,0 +1,2 @@
1
+ import"./dist-ON5FDO_b.mjs";var e=`0.8.2-beta.0`;const t=`config.yml`,n=e;export{n,t};
2
+ //# sourceMappingURL=constants-Dfx0JjpK.mjs.map
@@ -1 +1 @@
1
- import{$ as e,$n as t,$r as n,$t as r,A as i,Ai as a,An as o,Ar as s,At as c,B as l,Bi as u,Bn as d,Br as f,Bt as p,C as m,Ci as h,Cn as g,Cr as _,Ct as v,D as y,Dn as b,Dr as x,Dt as S,E as C,En as w,Er as T,Et as E,F as D,Fi as O,Fn as k,Fr as A,Ft as j,G as M,Gn as N,Gr as P,Gt as F,H as I,Hn as L,Hr as R,Ht as z,I as B,In as V,Ir as H,It as U,J as W,Jn as G,Jr as K,Jt as q,K as J,Kn as Y,Kr as X,Kt as Z,L as Q,Ln as $,Lr as ee,Lt as te,M as ne,Mi as re,Mn as ie,Mr as ae,Mt as oe,N as se,Nn as ce,Nr as le,Nt as ue,O as de,On as fe,Or as pe,Ot as me,P as he,Pi as ge,Pn as _e,Pr as ve,Pt as ye,Q as be,Qn as xe,Qr as Se,Qt as Ce,R as we,Ri as Te,Rn as Ee,Rr as De,Rt as Oe,S as ke,Sn as Ae,Sr as je,St as Me,T as Ne,Tn as Pe,Tr as Fe,Tt as Ie,U as Le,Un as Re,Ur as ze,Ut as Be,V as Ve,Vn as He,Vr as Ue,Vt as We,W as Ge,Wn as Ke,Wr as qe,Wt as Je,X as Ye,Xn as Xe,Xr as Ze,Xt as Qe,Y as $e,Yn as et,Yr as tt,Yt as nt,Z as rt,Zn as it,Zr as at,Zt as ot,_ as st,_n as ct,_r as lt,_t as ut,a as dt,ai as ft,an as pt,ar as mt,at as ht,b as gt,bn as _t,br as vt,bt as yt,c as bt,cn as xt,cr as St,ct as Ct,d as wt,dn as Tt,dr as Et,dt as Dt,ei as Ot,en as kt,er as At,et as jt,f as Mt,fn as Nt,fr as Pt,ft as Ft,g as It,gn as Lt,gr as Rt,gt as zt,h as Bt,hn as Vt,hr as Ht,ht as Ut,i as Wt,ii as Gt,in as Kt,ir as qt,it as Jt,j as Yt,jn as Xt,jr as Zt,jt as Qt,k as $t,kn as en,kr as tn,kt as nn,l as rn,ln as an,lr as on,lt as sn,m as cn,mn as ln,mr as un,mt as dn,n as fn,ni as pn,nn as mn,nr as hn,nt as gn,o as _n,oi as vn,on as yn,or as bn,ot as xn,p as Sn,pn as Cn,pr as wn,pt as Tn,q as En,qn as Dn,qr as On,qt as kn,r as An,ri as jn,rn as Mn,rr as Nn,rt as Pn,s as Fn,sn as In,sr as Ln,st as Rn,t as zn,ti as Bn,tn as Vn,tr as Hn,tt as Un,u as Wn,un as Gn,ur as Kn,ut as qn,v as Jn,vi as Yn,vn as Xn,vr as Zn,vt as Qn,w as $n,wn as er,wr as tr,wt as nr,x as rr,xn as ir,xr as ar,xt as or,y as sr,yi as cr,yn as lr,yr as ur,yt as dr,z as fr,zn as pr,zr as mr,zt as hr}from"./dist-xB__nIDC.mjs";import{a as gr,c as _r,d as vr,f as yr,g as br,h as xr,i as Sr,l as Cr,m as wr,n as Tr,o as Er,p as Dr,r as Or,s as kr,t as Ar,u as jr}from"./server-lock-BIY3RMaC-CfCHCMTe.mjs";export{zn as AGENT_ID_MAX_LEN,fn as AGENT_ID_RE,An as AGENT_WRITE_ORIGIN,Wt as AgentFocusBroadcaster,dt as AgentPresenceBroadcaster,_n as AgentSessionCapacityError,Fn as AgentSessionManager,bt as BacklinkIndex,rn as CC1Broadcaster,h as CC1_CONTRACT_VERSION,Wn as CONFIG_FILENAME,wt as CONFLICT_MARKER_RE,Mt as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Sn as ConfigSchema,cn as DEFAULT_CHECKPOINT_RETENTION,Bt as DEFAULT_PACK_ID,It as FILE_SYSTEM_WRITER,st as FILE_WATCHER_ORIGIN,Jn as GIT_PREFLIGHT_FAIL_SPAN_NAME,sr as GIT_UPSTREAM_WRITER,Yn as GitDirAccessError,gt as GitNotAvailableError,rr as GitTooOldError,ke as HOCUSPOCUS_AUTH_REJECTION_REASONS,m as HocuspocusAuthRejection,$n as HocuspocusAuthTokenSchema,Ne as INSTALLED_AGENTS_SCHEMES,C as LIVE_DERIVED_INDEX_DEBOUNCE_MS,y as LOG_MD_TEMPLATE,de as MANAGED_RENAME_ORIGIN,$t as MAX_AGENT_SESSIONS,i as MCP_CONNECTION_ID_HEADER,Yt as MCP_SERVER_NAME,ne as MIN_GIT_VERSION,se as MISSING_OK_CONFIG_MESSAGE,cr as MalformedGitPointerError,he as McpLogger,D as MissingOkConfigError,B as OBSERVER_SYNC_ORIGIN,Q as OK_OKIGNORE_TEMPLATE,a as ORPHAN_MODES,we as PinoLogger,Ar as ProcessLockCollisionError,fr as ProjectGitInitError,l as ROLLBACK_ORIGIN,Tr as RUNTIME_VERSION,Ve as SERVICE_WRITER,I as SKILL_INSTALL_EVENTS_FILE_REL,re as SKILL_STATE_TARGETS,Le as STARTER_FOLDERS,Ge as STARTER_FOLDER_FRONTMATTER_FILENAME,M as STARTER_PACKS,J as STARTER_PACK_IDS,En as STARTER_TEMPLATES,W as STATE_MANIFEST_FILENAME,Or as STATE_SCHEMA_VERSION,ge as SYSTEM_DOC_NAME,$e as SeedPrerequisiteError,Ye as SeedRootDirError,Sr as ServerLockCollisionError,rt as StateManifestError,be as TagIndex,e as UiLockCollisionError,gr as acquireProcessLock,Er as acquireServerLock,jt as acquireUiLock,Un as applyAgentMarkdownWrite,gn as applyExternalChange,Pn as applySeed,Jt as assertCompatibleStateManifest,ht as assertGitAvailable,xn as assertNeverDiskEvent,Rn as attachIdleShutdown,Ct as bootServer,sn as buildAndOpenSkill,qn as buildConfigYmlContent,Dt as buildExecResult,Ft as buildInstructions,Tn as buildSkillZip,dn as buildStarterFolderFrontmatterYaml,Ut as buildWipTree,zt as classifyEvents,ut as classifyFsPath,Qn as clearContributors,dr as coercePackId,O as colorFromSeed,yt as commitUpstreamImport,or as commitWip,Me as commitWipFromTree,v as compareSemver,nr as containsConflictMarkers,Ie as contentHash,E as contributorCount,S as createApiExtension,me as createAssetServeMiddleware,nn as createContentFilter,c as createContentFilterAsync,Qt as createExternalChangeHandler,oe as createFileLogger,ue as createLiveDerivedIndexExtension,ye as createMcpHttpHandler,j as createOsProbe,U as createPersistenceExtension,te as createServer,Oe as createServerObserverExtension,hr as createStreamingErrorWriter,p as createTestLogger,We as detectClaudeDesktopPresence,z as detectGit,Be as detectProjectShape,Je as emitPreflightFailureSpan,F as ensureProjectGit,Z as errorResponse,kn as evictStaleTrackerEntries,q as extractWikiLinksFromMarkdown,nt as fallbackPaths,Qe as findEnclosingGitRoot,ot as findEnclosingProjectRoot,Ce as formatAuthRejectionWire,r as formatContributors,kt as formatContributorsFrom,Vn as gcCheckpointRefs,mn as getCurrentMcpLogger,Mn as getLocalDir,Kt as getLogFilePath,pt as getLogger,yn as getLogsDir,In as getMeter,xt as getMetrics,an as getTracer,Gn as handleCollabSocketError,Tt as handleSpawnCursor,Te as iconFromClientName,Nt as incrementCollabSocketFilteredError,Cn as incrementServerObserverFire,ln as initContent,Vt as initShadowRepo,Lt as initTelemetry,ct as installPrettyZodErrors,Xn as installTestLoggers,lr as installUserSkill,_t as isAllowedApiOrigin,ir as isAllowedWorkspaceHostHeader,Ae as isConfigDoc,g as isHocuspocusAuthRejectionReason,er as isKnownPackId,Pe as isLoopbackAddress,u as isOrphanMode,w as isPairedWriteOrigin,b as isPathWithinDir,kr as isProcessAlive,fe as isProjectRoot,en as isSelfWrite,o as isSystemDoc,_r as isValidLockPid,Xt as lastKnownHash,ie as listRescueCheckpoints,ce as listStarterPacks,_e as loadPrincipal,Cr as lockFilePath,k as loggerFactory,V as mountMcpAndApi,$ as normalizeFsPath,Ee as packageVersionMajorMinor,pr as parseAuthRejectionWire,d as parseGitVersion,He as parseHocuspocusAuthToken,L as parseKeepaliveConnectionId,Re as pathToDocName,Ke as planSeed,N as readAllTargets,Y as readBranchFromHead,jr as readProcessLock,vr as readProcessLockDetailed,yr as readServerLock,Dn as readServerPackageVersion,G as readSkillInstallStateSnapshot,et as readStateManifest,Xe as readTargetRecordedAt,it as readTargetVersion,xe as readUiLock,t as reconcile,At as recordContributor,Hn as recordSkillInstallEvent,hn as registerAllTools,Nn as registerWrite,Dr as releaseProcessLock,wr as releaseServerLock,qt as releaseUiLock,mt as removeLastKnownHash,bn as resetMetrics,Ln as resolveBundledSkillDir,St as resolveContentDir,on as resolveCursorBinaryDefault,Kn as resolveCursorSpawnInvocation,Et as resolveLockDir,Pt as resolvePack,wn as resolvePackageVersion,un as restoreContributors,Ht as restoreLifecycleFromConflictsJson,Rt as rewriteMarkdownLinksForDocumentRename,lt as rewriteWikiLinksForDocumentRename,Zn as runAuthReposSubprocess,ur as runAuthStatusSubprocess,vt as runCloneSubprocess,ar as runDeviceFlowSubprocess,je as runWithMcpLogger,_ as safeContentPath,tr as safeSubdir,Fe as safetyCheckpoint,T as sanitizeClientName,x as saveInMemoryCheckpoint,pe as saveVersion,tn as seedBasenameIndex,s as serializeError,Zt as setActiveSpanAttributes,ae as shadowGit,le as shutdownTelemetry,ve as spawnDetached,A as splitMarkdownBlocks,H as startWatcher,ee as streamingProblemEvent,De as swapContributors,mr as toBroadcasterKey,f as tracedAppendFileSync,Ue as tracedLinkSync,R as tracedMkdir,ze as tracedMkdirSync,qe as tracedRename,P as tracedRenameSync,X as tracedRmSync,On as tracedRmdirSync,K as tracedUnlinkSync,tt as tracedWriteFile,Ze as tracedWriteFileSync,at as updateLastKnownHash,xr as updateProcessLockPort,br as updateServerLockPort,Se as updateUiLockPort,n as validateAgentId,Ot as validateCloneInputs,Bn as validateSkillZip,pn as withSpan,jn as withSpanSync,Gt as writeStateManifest,ft as writeTargetVersion,vn as writeTracker};
1
+ import{$ as e,$n as t,$r as n,$t as r,A as i,Ai as a,An as o,Ar as s,At as c,B as l,Bi as u,Bn as d,Br as f,Bt as p,C as m,Ci as h,Cn as g,Cr as _,Ct as v,D as y,Dn as b,Dr as x,Dt as S,E as C,En as w,Er as T,Et as E,F as D,Fi as O,Fn as k,Fr as A,Ft as j,G as M,Gn as N,Gr as P,Gt as F,H as I,Hn as L,Hr as R,Ht as z,I as B,In as V,Ir as H,It as U,J as W,Jn as G,Jr as K,Jt as q,K as J,Kn as Y,Kr as X,Kt as Z,L as Q,Ln as $,Lr as ee,Lt as te,M as ne,Mi as re,Mn as ie,Mr as ae,Mt as oe,N as se,Nn as ce,Nr as le,Nt as ue,O as de,On as fe,Or as pe,Ot as me,P as he,Pi as ge,Pn as _e,Pr as ve,Pt as ye,Q as be,Qn as xe,Qr as Se,Qt as Ce,R as we,Ri as Te,Rn as Ee,Rr as De,Rt as Oe,S as ke,Sn as Ae,Sr as je,St as Me,T as Ne,Tn as Pe,Tr as Fe,Tt as Ie,U as Le,Un as Re,Ur as ze,Ut as Be,V as Ve,Vn as He,Vr as Ue,Vt as We,W as Ge,Wn as Ke,Wr as qe,Wt as Je,X as Ye,Xn as Xe,Xr as Ze,Xt as Qe,Y as $e,Yn as et,Yr as tt,Yt as nt,Z as rt,Zn as it,Zr as at,Zt as ot,_ as st,_n as ct,_r as lt,_t as ut,a as dt,ai as ft,an as pt,ar as mt,at as ht,b as gt,bn as _t,br as vt,bt as yt,c as bt,cn as xt,cr as St,ct as Ct,d as wt,dn as Tt,dr as Et,dt as Dt,ei as Ot,en as kt,er as At,et as jt,f as Mt,fn as Nt,fr as Pt,ft as Ft,g as It,gn as Lt,gr as Rt,gt as zt,h as Bt,hn as Vt,hr as Ht,ht as Ut,i as Wt,ii as Gt,in as Kt,ir as qt,it as Jt,j as Yt,jn as Xt,jr as Zt,jt as Qt,k as $t,kn as en,kr as tn,kt as nn,l as rn,ln as an,lr as on,lt as sn,m as cn,mn as ln,mr as un,mt as dn,n as fn,ni as pn,nn as mn,nr as hn,nt as gn,o as _n,oi as vn,on as yn,or as bn,ot as xn,p as Sn,pn as Cn,pr as wn,pt as Tn,q as En,qn as Dn,qr as On,qt as kn,r as An,ri as jn,rn as Mn,rr as Nn,rt as Pn,s as Fn,sn as In,sr as Ln,st as Rn,t as zn,ti as Bn,tn as Vn,tr as Hn,tt as Un,u as Wn,un as Gn,ur as Kn,ut as qn,v as Jn,vi as Yn,vn as Xn,vr as Zn,vt as Qn,w as $n,wn as er,wr as tr,wt as nr,x as rr,xn as ir,xr as ar,xt as or,y as sr,yi as cr,yn as lr,yr as ur,yt as dr,z as fr,zn as pr,zr as mr,zt as hr}from"./dist-ON5FDO_b.mjs";import{a as gr,c as _r,d as vr,f as yr,g as br,h as xr,i as Sr,l as Cr,m as wr,n as Tr,o as Er,p as Dr,r as Or,s as kr,t as Ar,u as jr}from"./server-lock-BIY3RMaC-CfCHCMTe.mjs";export{zn as AGENT_ID_MAX_LEN,fn as AGENT_ID_RE,An as AGENT_WRITE_ORIGIN,Wt as AgentFocusBroadcaster,dt as AgentPresenceBroadcaster,_n as AgentSessionCapacityError,Fn as AgentSessionManager,bt as BacklinkIndex,rn as CC1Broadcaster,h as CC1_CONTRACT_VERSION,Wn as CONFIG_FILENAME,wt as CONFLICT_MARKER_RE,Mt as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Sn as ConfigSchema,cn as DEFAULT_CHECKPOINT_RETENTION,Bt as DEFAULT_PACK_ID,It as FILE_SYSTEM_WRITER,st as FILE_WATCHER_ORIGIN,Jn as GIT_PREFLIGHT_FAIL_SPAN_NAME,sr as GIT_UPSTREAM_WRITER,Yn as GitDirAccessError,gt as GitNotAvailableError,rr as GitTooOldError,ke as HOCUSPOCUS_AUTH_REJECTION_REASONS,m as HocuspocusAuthRejection,$n as HocuspocusAuthTokenSchema,Ne as INSTALLED_AGENTS_SCHEMES,C as LIVE_DERIVED_INDEX_DEBOUNCE_MS,y as LOG_MD_TEMPLATE,de as MANAGED_RENAME_ORIGIN,$t as MAX_AGENT_SESSIONS,i as MCP_CONNECTION_ID_HEADER,Yt as MCP_SERVER_NAME,ne as MIN_GIT_VERSION,se as MISSING_OK_CONFIG_MESSAGE,cr as MalformedGitPointerError,he as McpLogger,D as MissingOkConfigError,B as OBSERVER_SYNC_ORIGIN,Q as OK_OKIGNORE_TEMPLATE,a as ORPHAN_MODES,we as PinoLogger,Ar as ProcessLockCollisionError,fr as ProjectGitInitError,l as ROLLBACK_ORIGIN,Tr as RUNTIME_VERSION,Ve as SERVICE_WRITER,I as SKILL_INSTALL_EVENTS_FILE_REL,re as SKILL_STATE_TARGETS,Le as STARTER_FOLDERS,Ge as STARTER_FOLDER_FRONTMATTER_FILENAME,M as STARTER_PACKS,J as STARTER_PACK_IDS,En as STARTER_TEMPLATES,W as STATE_MANIFEST_FILENAME,Or as STATE_SCHEMA_VERSION,ge as SYSTEM_DOC_NAME,$e as SeedPrerequisiteError,Ye as SeedRootDirError,Sr as ServerLockCollisionError,rt as StateManifestError,be as TagIndex,e as UiLockCollisionError,gr as acquireProcessLock,Er as acquireServerLock,jt as acquireUiLock,Un as applyAgentMarkdownWrite,gn as applyExternalChange,Pn as applySeed,Jt as assertCompatibleStateManifest,ht as assertGitAvailable,xn as assertNeverDiskEvent,Rn as attachIdleShutdown,Ct as bootServer,sn as buildAndOpenSkill,qn as buildConfigYmlContent,Dt as buildExecResult,Ft as buildInstructions,Tn as buildSkillZip,dn as buildStarterFolderFrontmatterYaml,Ut as buildWipTree,zt as classifyEvents,ut as classifyFsPath,Qn as clearContributors,dr as coercePackId,O as colorFromSeed,yt as commitUpstreamImport,or as commitWip,Me as commitWipFromTree,v as compareSemver,nr as containsConflictMarkers,Ie as contentHash,E as contributorCount,S as createApiExtension,me as createAssetServeMiddleware,nn as createContentFilter,c as createContentFilterAsync,Qt as createExternalChangeHandler,oe as createFileLogger,ue as createLiveDerivedIndexExtension,ye as createMcpHttpHandler,j as createOsProbe,U as createPersistenceExtension,te as createServer,Oe as createServerObserverExtension,hr as createStreamingErrorWriter,p as createTestLogger,We as detectClaudeDesktopPresence,z as detectGit,Be as detectProjectShape,Je as emitPreflightFailureSpan,F as ensureProjectGit,Z as errorResponse,kn as evictStaleTrackerEntries,q as extractWikiLinksFromMarkdown,nt as fallbackPaths,Qe as findEnclosingGitRoot,ot as findEnclosingProjectRoot,Ce as formatAuthRejectionWire,r as formatContributors,kt as formatContributorsFrom,Vn as gcCheckpointRefs,mn as getCurrentMcpLogger,Mn as getLocalDir,Kt as getLogFilePath,pt as getLogger,yn as getLogsDir,In as getMeter,xt as getMetrics,an as getTracer,Gn as handleCollabSocketError,Tt as handleSpawnCursor,Te as iconFromClientName,Nt as incrementCollabSocketFilteredError,Cn as incrementServerObserverFire,ln as initContent,Vt as initShadowRepo,Lt as initTelemetry,ct as installPrettyZodErrors,Xn as installTestLoggers,lr as installUserSkill,_t as isAllowedApiOrigin,ir as isAllowedWorkspaceHostHeader,Ae as isConfigDoc,g as isHocuspocusAuthRejectionReason,er as isKnownPackId,Pe as isLoopbackAddress,u as isOrphanMode,w as isPairedWriteOrigin,b as isPathWithinDir,kr as isProcessAlive,fe as isProjectRoot,en as isSelfWrite,o as isSystemDoc,_r as isValidLockPid,Xt as lastKnownHash,ie as listRescueCheckpoints,ce as listStarterPacks,_e as loadPrincipal,Cr as lockFilePath,k as loggerFactory,V as mountMcpAndApi,$ as normalizeFsPath,Ee as packageVersionMajorMinor,pr as parseAuthRejectionWire,d as parseGitVersion,He as parseHocuspocusAuthToken,L as parseKeepaliveConnectionId,Re as pathToDocName,Ke as planSeed,N as readAllTargets,Y as readBranchFromHead,jr as readProcessLock,vr as readProcessLockDetailed,yr as readServerLock,Dn as readServerPackageVersion,G as readSkillInstallStateSnapshot,et as readStateManifest,Xe as readTargetRecordedAt,it as readTargetVersion,xe as readUiLock,t as reconcile,At as recordContributor,Hn as recordSkillInstallEvent,hn as registerAllTools,Nn as registerWrite,Dr as releaseProcessLock,wr as releaseServerLock,qt as releaseUiLock,mt as removeLastKnownHash,bn as resetMetrics,Ln as resolveBundledSkillDir,St as resolveContentDir,on as resolveCursorBinaryDefault,Kn as resolveCursorSpawnInvocation,Et as resolveLockDir,Pt as resolvePack,wn as resolvePackageVersion,un as restoreContributors,Ht as restoreLifecycleFromConflictsJson,Rt as rewriteMarkdownLinksForDocumentRename,lt as rewriteWikiLinksForDocumentRename,Zn as runAuthReposSubprocess,ur as runAuthStatusSubprocess,vt as runCloneSubprocess,ar as runDeviceFlowSubprocess,je as runWithMcpLogger,_ as safeContentPath,tr as safeSubdir,Fe as safetyCheckpoint,T as sanitizeClientName,x as saveInMemoryCheckpoint,pe as saveVersion,tn as seedBasenameIndex,s as serializeError,Zt as setActiveSpanAttributes,ae as shadowGit,le as shutdownTelemetry,ve as spawnDetached,A as splitMarkdownBlocks,H as startWatcher,ee as streamingProblemEvent,De as swapContributors,mr as toBroadcasterKey,f as tracedAppendFileSync,Ue as tracedLinkSync,R as tracedMkdir,ze as tracedMkdirSync,qe as tracedRename,P as tracedRenameSync,X as tracedRmSync,On as tracedRmdirSync,K as tracedUnlinkSync,tt as tracedWriteFile,Ze as tracedWriteFileSync,at as updateLastKnownHash,xr as updateProcessLockPort,br as updateServerLockPort,Se as updateUiLockPort,n as validateAgentId,Ot as validateCloneInputs,Bn as validateSkillZip,pn as withSpan,jn as withSpanSync,Gt as writeStateManifest,ft as writeTargetVersion,vn as writeTracker};