@inkeep/open-knowledge 0.71.2-beta.1 → 0.71.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/cli.mjs +54 -54
  2. package/dist/constants-BirNT126.mjs +1 -0
  3. package/dist/{dist-B4TxkELG.mjs → dist-Bxzi66b7.mjs} +1 -1
  4. package/dist/dist-D1HfouVm.mjs +2097 -0
  5. package/dist/index.d.mts +1 -0
  6. package/dist/index.mjs +7 -7
  7. package/dist/init-Bt-Gd0Of.mjs +1 -0
  8. package/dist/{init-Ex7PlJbP.mjs → init-D_gjDHTf.mjs} +7 -7
  9. package/dist/{launch-json-removal-Dgdu9kcP.mjs → launch-json-removal-IMDkZJTs.mjs} +1 -1
  10. package/dist/loader-CdcKuBwQ.mjs +1 -0
  11. package/dist/{loader-Da_kR2vs.mjs → loader-bj3vZ227.mjs} +1 -1
  12. package/dist/{md-manager-BGnqyqi1-BKxqDqfk.mjs → md-manager-BGnqyqi1-C0-0a_4T.mjs} +92 -92
  13. package/dist/{open-browser-DqgRF6In.mjs → open-browser-D9Sv9-6K.mjs} +1 -1
  14. package/dist/parse-worker.mjs +1 -1
  15. package/dist/preview-CEgkalQZ.mjs +1 -0
  16. package/dist/{preview-BOTcB8PJ.mjs → preview-DdwEHHFb.mjs} +1 -1
  17. package/dist/public/assets/{ActivityModeContent-BbKjbMiA.js → ActivityModeContent-B_Re3sCO.js} +1 -1
  18. package/dist/public/assets/{AddPropertiesButton-DhB8fBpO.js → AddPropertiesButton-DBIbNQMb.js} +1 -1
  19. package/dist/public/assets/{AgentDiffPane-BjhQ5oT2.js → AgentDiffPane-CnwENM87.js} +1 -1
  20. package/dist/public/assets/{CodeMirrorPropInput-DJMpl51W.js → CodeMirrorPropInput-D-iWWvft.js} +1 -1
  21. package/dist/public/assets/{DocumentContext-BdT4QvCj.js → DocumentContext-qHxlPFgu.js} +1 -1
  22. package/dist/public/assets/{EditorModeToggle-SZE7OX5H.js → EditorModeToggle-CL0A-pdT.js} +1 -1
  23. package/dist/public/assets/{EnableSyncConfirmDialog-DZwVI77M.js → EnableSyncConfirmDialog-D0sbHn3C.js} +1 -1
  24. package/dist/public/assets/{ExcalidrawDocEditor-BD82jzXA.js → ExcalidrawDocEditor-4A61s0Od.js} +1 -1
  25. package/dist/public/assets/FeedbackForm-41B5VbyM.js +1 -0
  26. package/dist/public/assets/{ImportSkillDialog-CC7FYOAx.js → ImportSkillDialog-CUgeolEZ.js} +1 -1
  27. package/dist/public/assets/{LintConfigEditor-B7lZsXeL.js → LintConfigEditor-BkHxS4Z2.js} +1 -1
  28. package/dist/public/assets/{ManagedArtifactProperties-DS1dvCFC.js → ManagedArtifactProperties-B8izvHBO.js} +1 -1
  29. package/dist/public/assets/ManagedArtifactProperties-C0k10C6t.js +1 -0
  30. package/dist/public/assets/{MermaidDocEditor-Bt0B02Vg.js → MermaidDocEditor-DCaIz0MV.js} +1 -1
  31. package/dist/public/assets/{PropertyDisplayRow-DT9DybGq.js → PropertyDisplayRow-DONEJphz.js} +1 -1
  32. package/dist/public/assets/{SchemaConfigEditor-DKOJ8BWG.js → SchemaConfigEditor-C6TJAzlP.js} +1 -1
  33. package/dist/public/assets/{SessionsHost-DdgAh7KC.js → SessionsHost-mxsP8VBT.js} +2 -2
  34. package/dist/public/assets/{SettingsDialogBody-CHW54FiV.js → SettingsDialogBody-CBr9NTCP.js} +1 -1
  35. package/dist/public/assets/{ShareReceiveMissDialog-CYTNwQ0R.js → ShareReceiveMissDialog-B3EB6YQR.js} +1 -1
  36. package/dist/public/assets/{SkillInstallMenu-Dt9XoTzF.js → SkillInstallMenu-Ya-6FZjF.js} +1 -1
  37. package/dist/public/assets/{SkillToolbarControls-becH_mip.js → SkillToolbarControls-BvrdkOsH.js} +1 -1
  38. package/dist/public/assets/{SourceEditor-BwY6mSBP.js → SourceEditor-XVY6g4ls.js} +1 -1
  39. package/dist/public/assets/{TerminalWindowApp-BehY2GEl.js → TerminalWindowApp-Xgzsyfd2.js} +1 -1
  40. package/dist/public/assets/{TextDocEditor-CYxCP2r5.js → TextDocEditor-BplISC3q.js} +1 -1
  41. package/dist/public/assets/{ThreadView-h4TWd7hW.js → ThreadView-C3tePmSt.js} +1 -1
  42. package/dist/public/assets/{TimelineDiffPane-DcOGwDoz.js → TimelineDiffPane-BUxav6uZ.js} +1 -1
  43. package/dist/public/assets/{agent-diff-store-Bz1uC7Vg.js → agent-diff-store-CEBg54c-.js} +1 -1
  44. package/dist/public/assets/{auth-state-cache-DDsVxErS.js → auth-state-cache-CBNus4S0.js} +1 -1
  45. package/dist/public/assets/{client-version-BrzB3ZFz.js → client-version-D207g_G2.js} +1 -1
  46. package/dist/public/assets/{comment-chips-CwAPmedw.js → comment-chips-DToBb3F4.js} +1 -1
  47. package/dist/public/assets/{config-provider-CAlJf_RJ.js → config-provider-DFYIVc9V.js} +1 -1
  48. package/dist/public/assets/{doc-undo-manager-DibYDt_n.js → doc-undo-manager-p-u-ggv3.js} +1 -1
  49. package/dist/public/assets/{index-CvLeHMQf.js → index-CS26J6l3.js} +8 -8
  50. package/dist/public/assets/{pending-receive-nav-store-B0WaT5YS.js → pending-receive-nav-store-Cr1LCQbQ.js} +1 -1
  51. package/dist/public/assets/{progress-BGIMEH8l.js → progress-BTAR0ta6.js} +1 -1
  52. package/dist/public/assets/{selection-context-CWFsKNpl.js → selection-context-BYpSRLhW.js} +1 -1
  53. package/dist/public/assets/{src-CqpVBr8K.js → src-CBDDC_H3.js} +1 -1
  54. package/dist/public/assets/{telemetry-impl-k9dxXFAA.js → telemetry-impl-8uUEBUc7.js} +1 -1
  55. package/dist/public/assets/{telemetry-startup-XR9DKXgQ.js → telemetry-startup-BW_bNXmx.js} +1 -1
  56. package/dist/public/assets/{typing-burst-detector-DvNzlvB9.js → typing-burst-detector-DdbPTV6s.js} +1 -1
  57. package/dist/public/assets/{use-activity-panel-BEYTKIoo.js → use-activity-panel-Bj2Xj0ox.js} +1 -1
  58. package/dist/public/assets/{use-open-skill-Q8DHnwW6.js → use-open-skill-B_ahDNz1.js} +1 -1
  59. package/dist/public/assets/{use-terminal-enabled-BdQOqH8G.js → use-terminal-enabled-DYI9ZQgY.js} +1 -1
  60. package/dist/public/assets/{use-timeline-entry-diff-CPG3aGDO.js → use-timeline-entry-diff-D8pEgQ0K.js} +1 -1
  61. package/dist/public/index.html +19 -19
  62. package/dist/{registry-probes-CKT5zpL7.mjs → registry-probes-CSYVvHU1.mjs} +2 -2
  63. package/dist/{removal-file-path-xOV2YbGI.mjs → removal-file-path-9sxva5U4.mjs} +1 -1
  64. package/dist/{repair-launch-json-DCb8j4os.mjs → repair-launch-json-tEgdkgQB.mjs} +1 -1
  65. package/dist/{repair-mcp-configs-Cvxc0PSE.mjs → repair-mcp-configs-DYgybbpP.mjs} +1 -1
  66. package/dist/src-DNTPYKMh.mjs +1 -0
  67. package/dist/src-VCAYQpty.mjs +11 -0
  68. package/dist/{start-C9MnFVTQ.mjs → start-BK63C5S4.mjs} +3 -3
  69. package/dist/start-xHCpCQLR.mjs +1 -0
  70. package/package.json +4 -4
  71. package/dist/constants-CN-OP4lK.mjs +0 -1
  72. package/dist/dist-CjH-Sf5k.mjs +0 -2096
  73. package/dist/init-DkoBLsnN.mjs +0 -1
  74. package/dist/loader-Ciy1lUFM.mjs +0 -1
  75. package/dist/preview-A8NnvAZh.mjs +0 -1
  76. package/dist/public/assets/FeedbackForm-BbB3RMo3.js +0 -1
  77. package/dist/public/assets/ManagedArtifactProperties-DcW-auIg.js +0 -1
  78. package/dist/src--hXB6oPw.mjs +0 -11
  79. package/dist/src-CemYwu_V.mjs +0 -1
  80. package/dist/start-B-ZEfbkW.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -10947,6 +10947,7 @@ type OkLocalOpAuthReposResponse = {
10947
10947
  } | {
10948
10948
  ok: false;
10949
10949
  error: string;
10950
+ authenticated?: false;
10950
10951
  };
10951
10952
  type OkEditorActiveTargetSnapshot = {
10952
10953
  readonly kind: 'doc';
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-DPpTSio4.mjs";import"./libesm-CSMdpGMF.mjs";import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-R6VWJ2ZL-Cu1kOJ3f.mjs";import"./chunk-CWQS3NFK-Dma10iZG.mjs";import"./chunk-DXB73IDG-MLBj3lvC.mjs";import"./chunk-5QMZ5MUS-B37CnsNb.mjs";import"./chunk-A5O5YHGN-2_dxLAd1.mjs";import"./chunk-24IMIIXA-CZ-UxWg_.mjs";import{createRequire as a}from"node:module";import{execFile as o,execFileSync as s,execSync as c,spawnSync as l}from"node:child_process";import{access as u,accessSync as d,closeSync as f,constants as p,cpSync as m,createWriteStream as h,existsSync as g,lstatSync as _,mkdirSync as v,mkdtempSync as y,openSync as b,readFile as x,readFileSync as S,readSync as C,readdirSync as w,readlinkSync as T,realpathSync as E,renameSync as D,rmSync as O,rmdirSync as ee,statSync as te,unlinkSync as ne,writeFileSync as re}from"node:fs";import{EOL as ie,arch as ae,availableParallelism as oe,freemem as se,homedir as k,hostname as ce,platform as le,release as ue,tmpdir as A,totalmem as j,type as de,uptime as fe}from"node:os";import pe,{basename as me,dirname as M,extname as he,isAbsolute as ge,join as N,normalize as _e,posix as ve,relative as ye,resolve as be,sep as xe,win32 as Se}from"node:path";import Ce from"node:process";import{fileURLToPath as we,fileURLToPath as Te}from"node:url";import{mkdir as Ee,realpath as De,rename as Oe,writeFile as ke}from"node:fs/promises";import{Readable as Ae,Writable as je}from"node:stream";import Me from"crypto";import"yjs";import{createHash as Ne,randomUUID as Pe}from"node:crypto";import{Readable as Fe}from"stream";import"node:events";import"node:worker_threads";import{spawn as Ie}from"child_process";import{isDeepStrictEqual as Le,promisify as Re}from"node:util";import{setTimeout as ze}from"node:timers/promises";import"node:stream/promises";import{Http2ServerRequest as Be}from"node:http2";import{AsyncLocalStorage as Ve}from"node:async_hooks";const He=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],Ue={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function We(e,t={}){let{login:n}=t,r=t._exec??s,i=Ge(t._fileExists??g),a=e?[`--hostname`,e]:[];if(n){let e=Ke(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=Ke(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function Ge(e){return[`gh`,...He.filter(e)]}function Ke(e,t,n){for(let r of t)try{let t=e(r,n,Ue).toString().trim();if(t.length>0)return t}catch{}}function qe(e,t={}){let n=t._exec??s,r=Ge(t._fileExists??g),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=Ke(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=Ye(a,e);if(t)return t}let o=Ke(n,r,i);if(o!==void 0){let e=et(o);if(e.length>0)return e}}function Je(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Ye(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=Je(Je(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=Je(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const Xe=/Logged in to \S+ account (\S+) \(/,Ze=/(?:Failed to log in to|Timeout trying to log in to) \S+/,Qe=/^\s*-\s*Active account:\s*true\s*$/,$e=/\u001b\[[0-9;]*m/g;function et(e){let t=[],n;for(let r of e.split(`
1
+ import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-DPpTSio4.mjs";import"./libesm-CSMdpGMF.mjs";import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-R6VWJ2ZL-Cu1kOJ3f.mjs";import"./chunk-CWQS3NFK-Dma10iZG.mjs";import"./chunk-DXB73IDG-MLBj3lvC.mjs";import"./chunk-5QMZ5MUS-B37CnsNb.mjs";import"./chunk-A5O5YHGN-2_dxLAd1.mjs";import"./chunk-24IMIIXA-CZ-UxWg_.mjs";import{createRequire as a}from"node:module";import{execFile as o,execFileSync as s,execSync as c,spawnSync as l}from"node:child_process";import{access as u,accessSync as d,closeSync as f,constants as p,cpSync as m,createWriteStream as h,existsSync as g,lstatSync as _,mkdirSync as v,mkdtempSync as y,openSync as b,readFile as x,readFileSync as S,readSync as C,readdirSync as w,readlinkSync as T,realpathSync as E,renameSync as D,rmSync as O,rmdirSync as ee,statSync as te,unlinkSync as ne,writeFileSync as re}from"node:fs";import{EOL as ie,arch as ae,availableParallelism as oe,freemem as se,homedir as k,hostname as ce,platform as le,release as ue,tmpdir as A,totalmem as j,type as de,uptime as fe}from"node:os";import pe,{basename as me,dirname as M,extname as he,isAbsolute as ge,join as N,normalize as _e,posix as ve,relative as ye,resolve as be,sep as xe,win32 as Se}from"node:path";import Ce from"node:process";import{fileURLToPath as we,fileURLToPath as Te}from"node:url";import{mkdir as Ee,realpath as De,rename as Oe,writeFile as ke}from"node:fs/promises";import{Readable as Ae,Writable as je}from"node:stream";import Me from"crypto";import"yjs";import{createHash as Ne,randomUUID as Pe}from"node:crypto";import{Readable as Fe}from"stream";import"node:events";import"node:worker_threads";import{spawn as Ie}from"child_process";import"node:stream/promises";import{isDeepStrictEqual as Le,promisify as Re}from"node:util";import{setTimeout as ze}from"node:timers/promises";import{Http2ServerRequest as Be}from"node:http2";import{AsyncLocalStorage as Ve}from"node:async_hooks";const He=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],Ue={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function We(e,t={}){let{login:n}=t,r=t._exec??s,i=Ge(t._fileExists??g),a=e?[`--hostname`,e]:[];if(n){let e=Ke(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=Ke(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function Ge(e){return[`gh`,...He.filter(e)]}function Ke(e,t,n){for(let r of t)try{let t=e(r,n,Ue).toString().trim();if(t.length>0)return t}catch{}}function qe(e,t={}){let n=t._exec??s,r=Ge(t._fileExists??g),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=Ke(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=Ye(a,e);if(t)return t}let o=Ke(n,r,i);if(o!==void 0){let e=et(o);if(e.length>0)return e}}function Je(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Ye(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=Je(Je(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=Je(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const Xe=/Logged in to \S+ account (\S+) \(/,Ze=/(?:Failed to log in to|Timeout trying to log in to) \S+/,Qe=/^\s*-\s*Active account:\s*true\s*$/,$e=/\u001b\[[0-9;]*m/g;function et(e){let t=[],n;for(let r of e.split(`
2
2
  `)){let e=r.replace($e,``),i=Xe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(Ze.test(e)){n=void 0;continue}n&&Qe.test(e)&&(n.active=!0)}return t}var tt=i((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),nt=i((e=>{var t=tt();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),rt=i((e=>{var t=tt(),n=nt();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)(t!==`!!`||n!==`tag:yaml.org,2002:`)&&(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
3
3
  `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),it=i((e=>{var t=tt(),n=nt();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),at=i((e=>{function t(e,n,r,i){if(i&&typeof i==`object`){if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}}return e.call(n,r,i)}e.applyReviver=t})),ot=i((e=>{var t=tt();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),st=i((e=>{var t=at(),n=tt(),r=ot();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),ct=i((e=>{var t=it(),n=nt(),r=tt(),i=st(),a=ot(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let a;for(let e of i){if(e===this)break;e.anchor===this.source&&(a=e)}return a}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,o=this.resolve(r,t);if(!o){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let c=n.get(o);if(c||=(a.toJS(o,null,t),n.get(o)),c?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=s(r,o,n)),c.count*c.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return c.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),lt=i((e=>{var t=tt(),n=st(),r=ot();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),ut=i((e=>{var t=ct(),n=tt(),r=lt();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??(f.anchor=c(e)),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),dt=i((e=>{var t=ut(),n=tt(),r=st();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),ft=i((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
4
4
  `)?n(r,t):r.includes(`
@@ -809,13 +809,13 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
809
809
  `)),i.removeListener(`error`,g),p.setSocket(i,c,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(p),p.on(`close`,()=>{this.clients.delete(p),this._shouldEmitClose&&!this.clients.size&&process.nextTick(h,this)})),l(p,r)}};function m(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n])}}function h(e){e._state=2,e.emit(`close`)}function g(){this.destroy()}function _(e,t,n,i){n||=r.STATUS_CODES[t],i={Connection:`close`,"Content-Type":`text/html`,"Content-Length":Buffer.byteLength(n),...i},e.once(`finish`,e.destroy),e.end(`HTTP/1.1 ${t} ${r.STATUS_CODES[t]}\r\n`+Object.keys(i).map(e=>`${e}: ${i[e]}`).join(`\r
810
810
  `)+`\r
811
811
  \r
812
- `+n)}function v(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,v),e.emit(`wsClientError`,r,n,t)}else _(n,r,i,a)}}));Qwe(),L6(),R6(),B6(),eTe(),Mc();const tTe=new Set;function V6(e){tTe.add(e)}function nTe(){return Ac.getTracer(`open-knowledge-server`)}async function rTe(e,t,n){return nTe().startActiveSpan(e,t??{},async e=>{try{let t=await n(e);return e.isRecording(),t}catch(t){throw e.recordException(t),e.setStatus({code:Cc.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}AX(`loss-capture`),B({ts:I(),schemaVersion:I(),seq:I(),event:F(),docName:F(),writerId:F().nullable(),site:F().optional(),direction:F().optional(),lostLen:I().optional(),digest:F().optional(),checkpointSha:F().optional(),which:F().optional(),witnessAvailable:L().optional(),connections:I().optional()}),AX(`checkpoint-chain`);function H6(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function iTe(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}AX(`shadow-lock`),AX(`shadow-op-gate`),AX(`shadow-repo`),(()=>{let e=process.env.OK_GIT_TIMEOUT_MS;if(!e)return 3e4;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e4})(),(()=>{let e=process.env.OK_SHADOW_MAINTENANCE_GC_TIMEOUT_MS;if(!e)return 6e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:6e5})(),(()=>{let e=process.env.OK_SHADOW_STAGE_TIMEOUT_MS;if(!e)return 3e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e5})(),jY.fileSystem,jY.gitUpstream,jY.service,jY.generator,AX(`bridge-loss-detector`),AX(`checkpoint`);function U6(e){let t=he(e).toLowerCase();return ER.includes(t)}function aTe(e){let t=e.toLowerCase();for(let n of ER)if(t.endsWith(n))return e.slice(0,-n.length);return e}function oTe(e){return e===`__system__`}const sTe=new Set(Are);function cTe(e){return sTe.has(e)}function lTe(e){return jre(e)}function uTe(e){return oTe(e)||cTe(e)||lTe(e)}AX(`parse-pool`),Math.max(1,Math.min(4,oe()-1)),V6(()=>{}),AX(`bridge-watchdog`),V6(()=>{}),AX(`server-observers`),AX(`server-observers`),AX(`agent-sessions`);function W6(e){return{...e,windowsHide:!0}}function dTe(){try{let e=M(we(import.meta.url)),t=be(e,`..`,`package.json`),n=JSON.parse(S(t,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}dTe(),RegExp(`^(?:${`do you mind.i would like you to.i'd like you to.i want you to.i need you to.i would like to.i'd like to.i want to.i need to.we need to.we want to.we should.go ahead and.take a look at.have a look at.look into.look at.help me with.help me to.help me.can you.could you.would you.will you.can we.could we.should we.let's.lets.try to.please.kindly.hello.alright.actually.anyway.also.okay.hey.hi.yo.ok.so.pls.plz.just.maybe`.split(`.`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})\\b(?:[\\s,:;!.\\-–—]+|$)`,`i`),Object.freeze({source:`local`,skipStoreHooks:!0,context:Object.freeze({origin:`effect-capture`,paired:!1})});function G6(e){return e.replace(/\\/g,`/`)}AX(`external-change-attribution`),AX(`mermaid-validator`),AX(`rename-log`),AX(`history`),RegExp(`<(${GJ.map(e=>e.tagName).join(`|`)})\\b([^>]*)\\/>`,`y`);const fTe=String.raw`\[\[([^\n#[\]|]+)(?:#([^\n[\]|]+))?(?:\|([^\n[\]]+))?\]\]`,pTe=String.raw`\((<[^>\n]+>|[^)\s\n]+)((?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)\)`,K6=String.raw`([^\]\n]*)`,q6=String.raw`([^\]\n]*(?:\][^[\]\n]*)?)`,J6=e=>RegExp(`(!?)${fTe}`,e),Y6=(e,t)=>RegExp(`(!?)\\[${e}\\]${pTe}`,t);J6(`y`),J6(`g`),Y6(K6,`y`),Y6(q6,`y`),Y6(K6,`g`),Y6(q6,`g`);const mTe=String.raw`(!?)\[([^\]\n]*)\](?:\[([^\]\n]*)\])?`;new RegExp(mTe,`y`),AX(`backlinks`),new class{capacity;store;writeIndex=0;filled=!1;constructor(e){if(!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer, got ${e}`);this.capacity=e,this.store=Array(e)}push(e){this.store[this.writeIndex]=e,this.writeIndex=(this.writeIndex+1)%this.capacity,this.writeIndex===0&&(this.filled=!0)}read(){let e=[],t=this.filled?this.capacity:this.writeIndex;for(let n=1;n<=t;n++){let t=(this.writeIndex-n+this.capacity)%this.capacity,r=this.store[t];r!==void 0&&e.push(r)}return e}get size(){return this.filled?this.capacity:this.writeIndex}}(256),DR.cursor,DR.codex,DR[`claude-desktop`],V6(()=>{});const X6={discovery:`open-knowledge-discovery`,project:`open-knowledge`,"write-skill":`open-knowledge-write-skill`};new Set(Object.values(X6));const hTe=Object.keys(X6),gTe={discovery:`user`,project:`project`,"write-skill":`user`},Z6=hTe.filter(e=>gTe[e]===`user`);new Set(Z6.map(e=>X6[e])),Re(x),AX(`agent-registry-apply`);const Q6=`OpenKnowledge.app/Contents/Resources/cli/dist/assets/skills`;function $6(e,t={}){let n=t.platform??process.platform,r=t.checkDesktop??!1,i=t.home??k(),a=[],o=process.env.NODE_ENV===`test`;r&&n===`darwin`&&(o||a.push(N(`/Applications`,Q6,e)),(!o||t.home!==void 0)&&a.push(N(i,`Applications`,Q6,e))),a.push(we(new URL(`../dist/assets/skills/${e}`,import.meta.url))),a.push(we(new URL(`../assets/skills/${e}`,import.meta.url))),a.push(we(new URL(`./assets/skills/${e}`,import.meta.url)));for(let e of a)if(g(e))return e;throw Error(`Bundled skill asset directory not found for bundle '${e}'. Tried: ${a.join(`, `)}. This usually means the CLI build did not copy packages/server/assets into dist/assets. Run \`cd packages/cli && bun run build\` before publishing.`)}AX(`local-op-security`),AX(`installed-skills-marker`);function e8(e){return hn.filter(t=>g(N(e,t.hostDir)))}function t8(e,t){return[...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({editor:e,root:t})),{editor:`agents`,root:t}]}t8(un,xs),[...t8(dn,xs)].sort((e,t)=>{let n=i4.indexOf(e.editor),r=i4.indexOf(t.editor);return(n===-1?i4.length:n)-(r===-1?i4.length:r)||e.editor.localeCompare(t.editor)}),AX(`skill-import`);function n8(e){try{return te(be(e,`.ok/config.yml`)).isFile()}catch(e){let t=e?.code;if(t===`ENOENT`||t===`ENOTDIR`)return!1;throw e}}const r8=AX(`content-filter`);Re(o);const i8=[`.claude`,`.cursor`,`.codex`,`.agents`,`.opencode`,`.pi`],a8=new Set([`node_modules`,`.venv`,`venv`,`env`,`__pycache__`,`vendor`,`dist`,`build`,`out`,`output`,`.next`,`.nuxt`,`.svelte-kit`,`.astro`,`.turbo`,`.cache`,`.parcel-cache`,`coverage`,`.git`,`.ok`,`.open-knowledge`,`.openknowledge`,...i8,`Library`,`Applications`,`.Trash`]),_Te=new Set([`.git`,`node_modules`,`.ok`,`.open-knowledge`,`.openknowledge`,...i8]),o8=new Set([`worktrees`,`local`]);function s8(e){let t=ru(e);if(!iu(t))throw Error(`Invalid attachment folder path`);if(t===`./`)return{kind:`sibling`};if(t===`/`||t===`.`)return{kind:`content-root`};let n=t.startsWith(`./`),r=(n?t.slice(2):t).split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`);return r===``?n?{kind:`sibling`}:{kind:`content-root`}:{kind:n?`doc-relative`:`fixed`,path:r}}function vTe(e){throw Error(`[AttachmentFolderShape] unhandled variant: ${JSON.stringify(e)}`)}function yTe(e,t,n){let r=he(e).slice(1).toLowerCase();if(!sl.has(r)||t.kind===`sibling`)return!1;let i=e.lastIndexOf(`/`),a=i===-1?``:e.slice(0,i);if(t.kind===`content-root`)return a===``;if(t.kind===`fixed`)return a===t.path||a.startsWith(`${t.path}/`);if(t.kind===`doc-relative`){let e=a===``?[]:a.split(`/`),r=t.path.split(`/`);for(let t=0;t<=e.length-r.length;t++)if(r.every((n,r)=>e[t+r]===n)&&n(e.slice(0,t).join(`/`)))return!0;return!1}return vTe(t)}function c8(e,t){let n=e.split(`/`);for(let e=0;e<n.length;e++){let r=n[e],i=r.toLowerCase()===`.ok`?`.ok`:r;if(_Te.has(i)&&!(t&&i===`.ok`&&!o8.has((n[e+1]??``).toLowerCase())))return!0}return!1}function l8(e){return e.startsWith(`${bs}/`)}function bTe(e){return e===`.ok`||e===`.ok/skills`||e.startsWith(`.ok/skills/`)}const u8=new Set([`.ok`,...i8]),xTe=new Set([...a8].filter(e=>!u8.has(e))),STe=[`.git`,`node_modules`,`.ok/local`,`.ok/worktrees`].flatMap(e=>[e,`${e}/**`,`**/${e}`,`**/${e}/**`]);function CTe(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);return t.includes(`..`)?!1:t.some(e=>xTe.has(e))?!0:t.some((e,n)=>e.toLowerCase()===`.ok`&&o8.has((t[n+1]??``).toLowerCase()))}const wTe=[`.gitignore`,`.ok`,`.ok/config.yml`,`.ok/.gitignore`,`.ok/schemas/frontmatter.json`,`.ok/templates/example.md`,`.ok/skills/example/SKILL.md`,`docs/.ok`,`docs/.ok/frontmatter.yml`,`docs/.ok/templates/example.md`,...i8.flatMap(e=>[e,`${e}/skills/example/SKILL.md`])];function TTe(e){let t=e.trim();if(!t||t.startsWith(`!`)||t.startsWith(`#`))return!1;let n=t.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);if(n.includes(`..`))return!0;if(CTe(t))return!1;if(n.some(e=>u8.has(e)))return!0;try{let e=(0,s4.default)().add(t);return wTe.some(t=>e.ignores(t))}catch{return!0}}function ETe(e){let t=e.filter(e=>e.length>0&&!e.startsWith(`!`)&&!e.startsWith(`#`)&&!TTe(e));return[...new Set([...t,...STe])]}function d8(e,t){for(let n=0;n<t;n++)if(a8.has(e[n])||e[n].toLowerCase()===`.ok`)return!0;return!1}function f8(e){let t=e.split(`/`),n=t.length;return n<3||t[n-3]!==`.ok`||t[n-2]!==`templates`||he(t[n-1])!==`.md`?!1:!d8(t,n-3)}function p8(e){let t=e.split(`/`),n=t.length;return t[n-1]===`.ok`?!d8(t,n-1):n>=2&&t[n-1]===`templates`&&t[n-2]===`.ok`&&!d8(t,n-2)}function DTe(e){let t=e.split(`/`),n=t.length;return t[0]===`.ok`&&(n===2&&(t[1]===`config.yml`||t[1]===`.gitignore`)||n===3&&t[1]===`schemas`&&t[2].toLowerCase().endsWith(`.json`))||f8(e)?!0:n>=2&&t[n-1]===`frontmatter.yml`&&t[n-2]===`.ok`&&!d8(t,n-2)}function OTe(e){return e===`.ok`||e===`.ok/schemas`||p8(e)}function kTe(e,t){for(let n of t)if(e===n||e.startsWith(`${n}/`))return!0;return!1}function m8(e,t){if(t.size===0)return!1;for(let n of t)if(e.startsWith(`${n}/`))return!0;return!1}function ATe(e,t){if(t.size===0)return!1;for(let n of t)if(n===e||n.startsWith(`${e}/`)||e.startsWith(`${n}/`))return!0;return!1}const jTe=new Set([`.ds_store`,`.localized`,`thumbs.db`,`desktop.ini`,`.directory`]);function h8(e){return jTe.has(e.slice(e.lastIndexOf(`/`)+1).toLowerCase())}const MTe=new Set([`.ssh`,`.aws`,`.gnupg`,`.kube`,`.docker`]);function g8(e){for(let t of e.split(`/`))if(MTe.has(t.toLowerCase()))return!0;return!1}const NTe=new Set([`credentials`,`.netrc`,`.npmrc`,`.pgpass`,`.git-credentials`]),PTe=[`.pem`,`.key`,`.p12`,`.pfx`,`.keystore`,`.jks`,`.ppk`];function _8(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(t===`.env`||t.startsWith(`.env.`)||NTe.has(t)||t.startsWith(`id_rsa`)||t.startsWith(`id_ed25519`)||t.startsWith(`id_ecdsa`)||t.startsWith(`id_dsa`))return!0;for(let e of PTe)if(t.endsWith(e))return!0;return!1}function FTe(e,t){return t===e||t.startsWith(`${e}/`)}function ITe(e,t,n){let r=n===void 0,i=new Map;function a(e){let t=i.get(e);if(t!==void 0)return t;let n;try{n=n8(e)}catch{return!1}return i.set(e,n),n}return{isInside(n,i){if(!r||n===``)return!1;let o=i?.pathBase===`project`?e:t;for(let e of n.split(`/`))if(o=N(o,e),a(o))return!0;return!1},reset(){i.clear()}}}const v8=[`.gitignore`,`.okignore`];function LTe(e,t){let n=RTe(e);if(n===null)return[];let r=[];y8(N(n,`info`,`exclude`),t,r,`info/exclude`);let i=zTe(e);return i&&y8(i,t,r,`global excludesfile`),r}function RTe(e){let t=l(`git`,[`rev-parse`,`--git-common-dir`],W6({cwd:e,encoding:`utf-8`,timeout:5e3}));return t.status!==0||!t.stdout?null:be(e,t.stdout.trim())}function zTe(e){let t=l(`git`,[`config`,`--get`,`--type=path`,`core.excludesfile`],W6({cwd:e,encoding:`utf-8`,timeout:5e3}));if(t.status===0&&t.stdout){let e=t.stdout.trim();if(e)return e}return BTe()}function BTe(){let e=process.env.XDG_CONFIG_HOME?.trim(),t=e&&e.length>0?e:N(k(),`.config`);return N(t,`git`,`ignore`)}function y8(e,t,n,r){if(g(e))try{let r=S(e,`utf-8`);t.value+=r.length,n.push(...x8(r))}catch(t){r8.warn({path:e,err:t},`Failed to read ${r} at ${e}`)}}function VTe(e){let{projectDir:t,contentDir:n,onAfterRebuild:r,singleDocRelPath:i}=e,a=e.inPlaceSkillDirs??new Set,o=s8(e.attachmentFolderPath??`./`),s=e.skillRootPaths??new Set,c=ITe(t,n,i),l=G6(ye(t,n)),u=l.startsWith(`..`),d,f,p,m,h=0,_=0,v=0;function y(){let e=(0,s4.default)(),r=(0,s4.default)();e.add(`.git`);let i=[],a=0,o=0;for(let n of v8){let o=N(t,n);if(g(o))try{let t=S(o,`utf-8`);a+=t.length;let s=x8(t);i.push(...s),e.add(s),n===`.okignore`&&r.add(s)}catch(e){r8.warn({path:o,err:e},`Failed to read ${n} at ${o}`)}}if(l&&!u)for(let t of v8){let i=N(n,t);if(g(i))try{let n=S(i,`utf-8`);a+=n.length,o++;let s=x8(n).map(e=>S8(e,l));e.add(s),t===`.okignore`&&r.add(s)}catch(e){r8.warn({path:i,err:e},`Failed to read ${t} at ${i}`)}}let s={value:a};o+=C8(n,t,e,r,s),a=s.value;let c=LTe(t,s);a=s.value,c.length>0&&(i.push(...c),e.add(c));let y=ETe(i);return d=e,f=r,p=i,m=y,h=i.length,_=o,v=a,{patternCount:h,nestedFileCount:_,bytes:v}}y();let b=new Map;function x(e,t){if(u&&t?.pathBase!==`project`)return!1;let n=t?.pathBase===`project`||!l?e:`${l}/${e}`;return!n.startsWith(`..`)&&d.ignores(n)}function C(e,t){return t.pathBase===`project`||!l?e:`${l}/${e}`}function w(e){if(u)return!1;let t=l?`${l}/${e}`:e;return f.ignores(t)}let T=()=>{i===void 0&&b8(n,``,x,b)};T();function E(e){return uTe(aTe(e))}function D(e){for(let t of e.split(`/`))if(a8.has(t))return!0;return!u&&x(e)}let O=null,ee=null;return{isExcluded(e,t){if(E(e)||_8(e)||g8(e)||c.isInside(e,t?.syncScope)||!t?.bypassFilters&&kTe(e,s)&&!m8(e,a))return!0;if(!t?.bypassFilters&&(l8(e)||m8(e,a)&&!x(e))){if(i!==void 0)return e!==i;if(U6(e))return!1;let t=he(e).slice(1).toLowerCase();return!sl.has(t)}if(!t?.bypassFilters&&f8(e)||!t?.bypassFilters&&t?.syncScope!==void 0&&DTe(C(e,t.syncScope))&&!x(e,t.syncScope))return i!==void 0&&e!==i;if(c8(e,t?.showOk)||h8(e))return!0;if(i!==void 0)return e!==i;if(t?.bypassFilters)return t.respectOkignore===!0&&w(e);if(D(e))return!0;if(U6(e)||yTe(e,o,e=>(b.get(e)??0)>0))return!1;let n=he(e).slice(1).toLowerCase();if(sl.has(n)){let t=M(e),n=t===`.`?``:t;if((b.get(n)??0)>0)return!1}return!0},isDirExcluded(e,t){if(g8(e)||c.isInside(e,t?.syncScope))return!0;if(!t?.bypassFilters&&(bTe(e)||p8(e)||t?.syncScope!==void 0&&OTe(C(e,t.syncScope))||ATe(e,a)))return!1;if(c8(e,t?.showOk))return!0;if(i!==void 0)return!FTe(e,i);if(t?.bypassFilters)return t.respectOkignore===!0&&(w(e)||w(`${e}/`));for(let t of e.split(`/`))if(a8.has(t))return!0;return u?!1:x(e,t?.syncScope)||x(`${e}/`,t?.syncScope)},isPathIgnored(e,t){return E(e)||_8(e)||g8(e)?!0:l8(e)||m8(e,a)&&!x(e)||f8(e)?!1:c8(e)||h8(e)?!0:!t?.bypassFilters&&D(e)},getWatcherIgnoreGlobs(){return m},incrementMdDir(e){let t=e===`.`?``:e;b.set(t,(b.get(t)??0)+1)},decrementMdDir(e){let t=e===`.`?``:e,n=b.get(t)??0;n<=1?b.delete(t):b.set(t,n-1)},rebuildDirCount(){let e=new Map(b);b.clear();try{T()}catch(t){for(let[t,n]of e)b.set(t,n);r8.warn({err:t instanceof Error?t:Error(String(t))},`content-filter rebuildDirCount walk failed — retaining previous counts`)}},setAttachmentFolderPath(e){o=s8(e)},refreshInPlaceSkillDirs(){if(e.rescanInPlaceSkillDirs)try{a=e.rescanInPlaceSkillDirs()}catch(e){r8.warn({err:e},`in-place skill re-scan failed — keeping previous allow-list`)}},inPlaceSkillDirsFingerprint(){return[...a].sort().join(`
812
+ `+n)}function v(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,v),e.emit(`wsClientError`,r,n,t)}else _(n,r,i,a)}}));Qwe(),L6(),R6(),B6(),eTe(),Mc();const tTe=new Set;function V6(e){tTe.add(e)}function nTe(){return Ac.getTracer(`open-knowledge-server`)}async function rTe(e,t,n){return nTe().startActiveSpan(e,t??{},async e=>{try{let t=await n(e);return e.isRecording(),t}catch(t){throw e.recordException(t),e.setStatus({code:Cc.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}AX(`loss-capture`),B({ts:I(),schemaVersion:I(),seq:I(),event:F(),docName:F(),writerId:F().nullable(),site:F().optional(),direction:F().optional(),lostLen:I().optional(),digest:F().optional(),checkpointSha:F().optional(),which:F().optional(),witnessAvailable:L().optional(),connections:I().optional()}),AX(`checkpoint-chain`);function H6(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function iTe(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}AX(`shadow-lock`),AX(`shadow-op-gate`),AX(`shadow-repo`),(()=>{let e=process.env.OK_GIT_TIMEOUT_MS;if(!e)return 3e4;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e4})(),(()=>{let e=process.env.OK_SHADOW_MAINTENANCE_GC_TIMEOUT_MS;if(!e)return 6e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:6e5})(),(()=>{let e=process.env.OK_SHADOW_STAGE_TIMEOUT_MS;if(!e)return 3e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e5})(),jY.fileSystem,jY.gitUpstream,jY.service,jY.generator,AX(`bridge-loss-detector`),AX(`checkpoint`);function U6(e){let t=he(e).toLowerCase();return ER.includes(t)}function aTe(e){let t=e.toLowerCase();for(let n of ER)if(t.endsWith(n))return e.slice(0,-n.length);return e}function oTe(e){return e===`__system__`}const sTe=new Set(Are);function cTe(e){return sTe.has(e)}function lTe(e){return jre(e)}function uTe(e){return oTe(e)||cTe(e)||lTe(e)}AX(`parse-pool`),Math.max(1,Math.min(4,oe()-1)),V6(()=>{}),AX(`bridge-watchdog`),V6(()=>{}),AX(`server-observers`),AX(`server-observers`),AX(`agent-sessions`);function W6(e){return{...e,windowsHide:!0}}function dTe(){try{let e=M(we(import.meta.url)),t=be(e,`..`,`package.json`),n=JSON.parse(S(t,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}dTe(),RegExp(`^(?:${`do you mind.i would like you to.i'd like you to.i want you to.i need you to.i would like to.i'd like to.i want to.i need to.we need to.we want to.we should.go ahead and.take a look at.have a look at.look into.look at.help me with.help me to.help me.can you.could you.would you.will you.can we.could we.should we.let's.lets.try to.please.kindly.hello.alright.actually.anyway.also.okay.hey.hi.yo.ok.so.pls.plz.just.maybe`.split(`.`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})\\b(?:[\\s,:;!.\\-–—]+|$)`,`i`),Object.freeze({source:`local`,skipStoreHooks:!0,context:Object.freeze({origin:`effect-capture`,paired:!1})});const G6={discovery:`open-knowledge-discovery`,project:`open-knowledge`,"write-skill":`open-knowledge-write-skill`};new Set(Object.values(G6));const fTe=Object.keys(G6),pTe={discovery:`user`,project:`project`,"write-skill":`user`},K6=fTe.filter(e=>pTe[e]===`user`);new Set(K6.map(e=>G6[e])),Re(x),AX(`agent-registry-apply`);const q6=`OpenKnowledge.app/Contents/Resources/cli/dist/assets/skills`;function J6(e,t={}){let n=t.platform??process.platform,r=t.checkDesktop??!1,i=t.home??k(),a=[],o=process.env.NODE_ENV===`test`;r&&n===`darwin`&&(o||a.push(N(`/Applications`,q6,e)),(!o||t.home!==void 0)&&a.push(N(i,`Applications`,q6,e))),a.push(we(new URL(`../dist/assets/skills/${e}`,import.meta.url))),a.push(we(new URL(`../assets/skills/${e}`,import.meta.url))),a.push(we(new URL(`./assets/skills/${e}`,import.meta.url)));for(let e of a)if(g(e))return e;throw Error(`Bundled skill asset directory not found for bundle '${e}'. Tried: ${a.join(`, `)}. This usually means the CLI build did not copy packages/server/assets into dist/assets. Run \`cd packages/cli && bun run build\` before publishing.`)}function Y6(e){return e.replace(/\\/g,`/`)}AX(`local-op-security`),AX(`installed-skills-marker`);function X6(e){return hn.filter(t=>g(N(e,t.hostDir)))}new class{capacity;store;writeIndex=0;filled=!1;constructor(e){if(!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer, got ${e}`);this.capacity=e,this.store=Array(e)}push(e){this.store[this.writeIndex]=e,this.writeIndex=(this.writeIndex+1)%this.capacity,this.writeIndex===0&&(this.filled=!0)}read(){let e=[],t=this.filled?this.capacity:this.writeIndex;for(let n=1;n<=t;n++){let t=(this.writeIndex-n+this.capacity)%this.capacity,r=this.store[t];r!==void 0&&e.push(r)}return e}get size(){return this.filled?this.capacity:this.writeIndex}}(256),DR.cursor,DR.codex,DR[`claude-desktop`],V6(()=>{});function Z6(e,t){return[...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({editor:e,root:t})),{editor:`agents`,root:t}]}Z6(un,xs),[...Z6(dn,xs)].sort((e,t)=>{let n=i4.indexOf(e.editor),r=i4.indexOf(t.editor);return(n===-1?i4.length:n)-(r===-1?i4.length:r)||e.editor.localeCompare(t.editor)}),AX(`skill-import`),RegExp(`<(${GJ.map(e=>e.tagName).join(`|`)})\\b([^>]*)\\/>`,`y`);const mTe=String.raw`\[\[([^\n#[\]|]+)(?:#([^\n[\]|]+))?(?:\|([^\n[\]]+))?\]\]`,hTe=String.raw`\((<[^>\n]+>|[^)\s\n]+)((?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)\)`,Q6=String.raw`([^\]\n]*)`,$6=String.raw`([^\]\n]*(?:\][^[\]\n]*)?)`,e8=e=>RegExp(`(!?)${mTe}`,e),t8=(e,t)=>RegExp(`(!?)\\[${e}\\]${hTe}`,t);e8(`y`),e8(`g`),t8(Q6,`y`),t8($6,`y`),t8(Q6,`g`),t8($6,`g`);const gTe=String.raw`(!?)\[([^\]\n]*)\](?:\[([^\]\n]*)\])?`;new RegExp(gTe,`y`);function n8(e){try{return te(be(e,`.ok/config.yml`)).isFile()}catch(e){let t=e?.code;if(t===`ENOENT`||t===`ENOTDIR`)return!1;throw e}}const r8=AX(`content-filter`);Re(o);const i8=[`.claude`,`.cursor`,`.codex`,`.agents`,`.opencode`,`.pi`],a8=new Set([`node_modules`,`.venv`,`venv`,`env`,`__pycache__`,`vendor`,`dist`,`build`,`out`,`output`,`.next`,`.nuxt`,`.svelte-kit`,`.astro`,`.turbo`,`.cache`,`.parcel-cache`,`coverage`,`.git`,`.ok`,`.open-knowledge`,`.openknowledge`,...i8,`Library`,`Applications`,`.Trash`]),_Te=new Set([`.git`,`node_modules`,`.ok`,`.open-knowledge`,`.openknowledge`,...i8]),o8=new Set([`worktrees`,`local`]);function s8(e){let t=ru(e);if(!iu(t))throw Error(`Invalid attachment folder path`);if(t===`./`)return{kind:`sibling`};if(t===`/`||t===`.`)return{kind:`content-root`};let n=t.startsWith(`./`),r=(n?t.slice(2):t).split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`);return r===``?n?{kind:`sibling`}:{kind:`content-root`}:{kind:n?`doc-relative`:`fixed`,path:r}}function vTe(e){throw Error(`[AttachmentFolderShape] unhandled variant: ${JSON.stringify(e)}`)}function yTe(e,t,n){let r=he(e).slice(1).toLowerCase();if(!sl.has(r)||t.kind===`sibling`)return!1;let i=e.lastIndexOf(`/`),a=i===-1?``:e.slice(0,i);if(t.kind===`content-root`)return a===``;if(t.kind===`fixed`)return a===t.path||a.startsWith(`${t.path}/`);if(t.kind===`doc-relative`){let e=a===``?[]:a.split(`/`),r=t.path.split(`/`);for(let t=0;t<=e.length-r.length;t++)if(r.every((n,r)=>e[t+r]===n)&&n(e.slice(0,t).join(`/`)))return!0;return!1}return vTe(t)}function c8(e,t){let n=e.split(`/`);for(let e=0;e<n.length;e++){let r=n[e],i=r.toLowerCase()===`.ok`?`.ok`:r;if(_Te.has(i)&&!(t&&i===`.ok`&&!o8.has((n[e+1]??``).toLowerCase())))return!0}return!1}function l8(e){return e.startsWith(`${bs}/`)}function bTe(e){return e===`.ok`||e===`.ok/skills`||e.startsWith(`.ok/skills/`)}const u8=new Set([`.ok`,...i8]),xTe=new Set([...a8].filter(e=>!u8.has(e))),STe=[`.git`,`node_modules`,`.ok/local`,`.ok/worktrees`].flatMap(e=>[e,`${e}/**`,`**/${e}`,`**/${e}/**`]);function CTe(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);return t.includes(`..`)?!1:t.some(e=>xTe.has(e))?!0:t.some((e,n)=>e.toLowerCase()===`.ok`&&o8.has((t[n+1]??``).toLowerCase()))}const wTe=[`.gitignore`,`.ok`,`.ok/config.yml`,`.ok/.gitignore`,`.ok/schemas/frontmatter.json`,`.ok/templates/example.md`,`.ok/skills/example/SKILL.md`,`docs/.ok`,`docs/.ok/frontmatter.yml`,`docs/.ok/templates/example.md`,...i8.flatMap(e=>[e,`${e}/skills/example/SKILL.md`])];function TTe(e){let t=e.trim();if(!t||t.startsWith(`!`)||t.startsWith(`#`))return!1;let n=t.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);if(n.includes(`..`))return!0;if(CTe(t))return!1;if(n.some(e=>u8.has(e)))return!0;try{let e=(0,s4.default)().add(t);return wTe.some(t=>e.ignores(t))}catch{return!0}}function ETe(e){let t=e.filter(e=>e.length>0&&!e.startsWith(`!`)&&!e.startsWith(`#`)&&!TTe(e));return[...new Set([...t,...STe])]}function d8(e,t){for(let n=0;n<t;n++)if(a8.has(e[n])||e[n].toLowerCase()===`.ok`)return!0;return!1}function f8(e){let t=e.split(`/`),n=t.length;return n<3||t[n-3]!==`.ok`||t[n-2]!==`templates`||he(t[n-1])!==`.md`?!1:!d8(t,n-3)}function p8(e){let t=e.split(`/`),n=t.length;return t[n-1]===`.ok`?!d8(t,n-1):n>=2&&t[n-1]===`templates`&&t[n-2]===`.ok`&&!d8(t,n-2)}function DTe(e){let t=e.split(`/`),n=t.length;return t[0]===`.ok`&&(n===2&&(t[1]===`config.yml`||t[1]===`.gitignore`)||n===3&&t[1]===`schemas`&&t[2].toLowerCase().endsWith(`.json`))||f8(e)?!0:n>=2&&t[n-1]===`frontmatter.yml`&&t[n-2]===`.ok`&&!d8(t,n-2)}function OTe(e){return e===`.ok`||e===`.ok/schemas`||p8(e)}function kTe(e,t){for(let n of t)if(e===n||e.startsWith(`${n}/`))return!0;return!1}function m8(e,t){if(t.size===0)return!1;for(let n of t)if(e.startsWith(`${n}/`))return!0;return!1}function ATe(e,t){if(t.size===0)return!1;for(let n of t)if(n===e||n.startsWith(`${e}/`)||e.startsWith(`${n}/`))return!0;return!1}const jTe=new Set([`.ds_store`,`.localized`,`thumbs.db`,`desktop.ini`,`.directory`]);function h8(e){return jTe.has(e.slice(e.lastIndexOf(`/`)+1).toLowerCase())}const MTe=new Set([`.ssh`,`.aws`,`.gnupg`,`.kube`,`.docker`]);function g8(e){for(let t of e.split(`/`))if(MTe.has(t.toLowerCase()))return!0;return!1}const NTe=new Set([`credentials`,`.netrc`,`.npmrc`,`.pgpass`,`.git-credentials`]),PTe=[`.pem`,`.key`,`.p12`,`.pfx`,`.keystore`,`.jks`,`.ppk`];function _8(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(t===`.env`||t.startsWith(`.env.`)||NTe.has(t)||t.startsWith(`id_rsa`)||t.startsWith(`id_ed25519`)||t.startsWith(`id_ecdsa`)||t.startsWith(`id_dsa`))return!0;for(let e of PTe)if(t.endsWith(e))return!0;return!1}function FTe(e,t){return t===e||t.startsWith(`${e}/`)}function ITe(e,t,n){let r=n===void 0,i=new Map;function a(e){let t=i.get(e);if(t!==void 0)return t;let n;try{n=n8(e)}catch{return!1}return i.set(e,n),n}return{isInside(n,i){if(!r||n===``)return!1;let o=i?.pathBase===`project`?e:t;for(let e of n.split(`/`))if(o=N(o,e),a(o))return!0;return!1},reset(){i.clear()}}}const v8=[`.gitignore`,`.okignore`];function LTe(e,t){let n=RTe(e);if(n===null)return[];let r=[];y8(N(n,`info`,`exclude`),t,r,`info/exclude`);let i=zTe(e);return i&&y8(i,t,r,`global excludesfile`),r}function RTe(e){let t=l(`git`,[`rev-parse`,`--git-common-dir`],W6({cwd:e,encoding:`utf-8`,timeout:5e3}));return t.status!==0||!t.stdout?null:be(e,t.stdout.trim())}function zTe(e){let t=l(`git`,[`config`,`--get`,`--type=path`,`core.excludesfile`],W6({cwd:e,encoding:`utf-8`,timeout:5e3}));if(t.status===0&&t.stdout){let e=t.stdout.trim();if(e)return e}return BTe()}function BTe(){let e=process.env.XDG_CONFIG_HOME?.trim(),t=e&&e.length>0?e:N(k(),`.config`);return N(t,`git`,`ignore`)}function y8(e,t,n,r){if(g(e))try{let r=S(e,`utf-8`);t.value+=r.length,n.push(...x8(r))}catch(t){r8.warn({path:e,err:t},`Failed to read ${r} at ${e}`)}}function VTe(e){let{projectDir:t,contentDir:n,onAfterRebuild:r,singleDocRelPath:i}=e,a=e.inPlaceSkillDirs??new Set,o=s8(e.attachmentFolderPath??`./`),s=e.skillRootPaths??new Set,c=ITe(t,n,i),l=Y6(ye(t,n)),u=l.startsWith(`..`),d,f,p,m,h=0,_=0,v=0;function y(){let e=(0,s4.default)(),r=(0,s4.default)();e.add(`.git`);let i=[],a=0,o=0;for(let n of v8){let o=N(t,n);if(g(o))try{let t=S(o,`utf-8`);a+=t.length;let s=x8(t);i.push(...s),e.add(s),n===`.okignore`&&r.add(s)}catch(e){r8.warn({path:o,err:e},`Failed to read ${n} at ${o}`)}}if(l&&!u)for(let t of v8){let i=N(n,t);if(g(i))try{let n=S(i,`utf-8`);a+=n.length,o++;let s=x8(n).map(e=>S8(e,l));e.add(s),t===`.okignore`&&r.add(s)}catch(e){r8.warn({path:i,err:e},`Failed to read ${t} at ${i}`)}}let s={value:a};o+=C8(n,t,e,r,s),a=s.value;let c=LTe(t,s);a=s.value,c.length>0&&(i.push(...c),e.add(c));let y=ETe(i);return d=e,f=r,p=i,m=y,h=i.length,_=o,v=a,{patternCount:h,nestedFileCount:_,bytes:v}}y();let b=new Map;function x(e,t){if(u&&t?.pathBase!==`project`)return!1;let n=t?.pathBase===`project`||!l?e:`${l}/${e}`;return!n.startsWith(`..`)&&d.ignores(n)}function C(e,t){return t.pathBase===`project`||!l?e:`${l}/${e}`}function w(e){if(u)return!1;let t=l?`${l}/${e}`:e;return f.ignores(t)}let T=()=>{i===void 0&&b8(n,``,x,b)};T();function E(e){return uTe(aTe(e))}function D(e){for(let t of e.split(`/`))if(a8.has(t))return!0;return!u&&x(e)}let O=null,ee=null;return{isExcluded(e,t){if(E(e)||_8(e)||g8(e)||c.isInside(e,t?.syncScope)||!t?.bypassFilters&&kTe(e,s)&&!m8(e,a))return!0;if(!t?.bypassFilters&&(l8(e)||m8(e,a)&&!x(e))){if(i!==void 0)return e!==i;if(U6(e))return!1;let t=he(e).slice(1).toLowerCase();return!sl.has(t)}if(!t?.bypassFilters&&f8(e)||!t?.bypassFilters&&t?.syncScope!==void 0&&DTe(C(e,t.syncScope))&&!x(e,t.syncScope))return i!==void 0&&e!==i;if(c8(e,t?.showOk)||h8(e))return!0;if(i!==void 0)return e!==i;if(t?.bypassFilters)return t.respectOkignore===!0&&w(e);if(D(e))return!0;if(U6(e)||yTe(e,o,e=>(b.get(e)??0)>0))return!1;let n=he(e).slice(1).toLowerCase();if(sl.has(n)){let t=M(e),n=t===`.`?``:t;if((b.get(n)??0)>0)return!1}return!0},isDirExcluded(e,t){if(g8(e)||c.isInside(e,t?.syncScope))return!0;if(!t?.bypassFilters&&(bTe(e)||p8(e)||t?.syncScope!==void 0&&OTe(C(e,t.syncScope))||ATe(e,a)))return!1;if(c8(e,t?.showOk))return!0;if(i!==void 0)return!FTe(e,i);if(t?.bypassFilters)return t.respectOkignore===!0&&(w(e)||w(`${e}/`));for(let t of e.split(`/`))if(a8.has(t))return!0;return u?!1:x(e,t?.syncScope)||x(`${e}/`,t?.syncScope)},isPathIgnored(e,t){return E(e)||_8(e)||g8(e)?!0:l8(e)||m8(e,a)&&!x(e)||f8(e)?!1:c8(e)||h8(e)?!0:!t?.bypassFilters&&D(e)},getWatcherIgnoreGlobs(){return m},incrementMdDir(e){let t=e===`.`?``:e;b.set(t,(b.get(t)??0)+1)},decrementMdDir(e){let t=e===`.`?``:e,n=b.get(t)??0;n<=1?b.delete(t):b.set(t,n-1)},rebuildDirCount(){let e=new Map(b);b.clear();try{T()}catch(t){for(let[t,n]of e)b.set(t,n);r8.warn({err:t instanceof Error?t:Error(String(t))},`content-filter rebuildDirCount walk failed — retaining previous counts`)}},setAttachmentFolderPath(e){o=s8(e)},refreshInPlaceSkillDirs(){if(e.rescanInPlaceSkillDirs)try{a=e.rescanInPlaceSkillDirs()}catch(e){r8.warn({err:e},`in-place skill re-scan failed — keeping previous allow-list`)}},inPlaceSkillDirsFingerprint(){return[...a].sort().join(`
813
813
  `)},peekFreshInPlaceSkillDirsFingerprint(){if(!e.rescanInPlaceSkillDirs)return[...a].sort().join(`
814
814
  `);try{return[...e.rescanInPlaceSkillDirs()].sort().join(`
815
815
  `)}catch{return[...a].sort().join(`
816
816
  `)}},async rebuildIgnorePatterns(){let t=e=>(O=e().finally(()=>{O=null}),O),o=async()=>{if(c.reset(),e.rescanInPlaceSkillDirs)try{a=e.rescanInPlaceSkillDirs()}catch(e){r8.warn({err:e},`in-place skill re-scan failed — keeping previous allow-list`)}let t=d,o=f,s=p,l=m,u=h,g=_,S=v,C=Date.now();return rTe(`config.ignore.rebuild`,{attributes:{}},async e=>{try{let t=y();b.clear(),i===void 0&&await HTe(n,x,b);let a=Date.now()-C;if(e.setAttributes({"ok.ignore.pattern_count":t.patternCount,"ok.ignore.nested_file_count":t.nestedFileCount,"ok.ignore.bytes":t.bytes}),r8.info({patternCount:t.patternCount,nestedFileCount:t.nestedFileCount,bytes:t.bytes,durationMs:a},`content-filter rebuild succeeded`),r)try{r()}catch(e){r8.warn({err:e instanceof Error?e:Error(String(e))},`content-filter onAfterRebuild callback threw — derived views may be stale`)}return{ok:!0,patternCount:t.patternCount,nestedFileCount:t.nestedFileCount,bytes:t.bytes,durationMs:a}}catch(e){d=t,f=o,p=s,m=l,h=u,_=g,v=S,b.clear();try{T()}catch(e){r8.warn({err:e instanceof Error?e:Error(String(e))},`content-filter rollback dirCount re-walk failed — sibling-asset counts may be stale until next rebuild`)}let n=e instanceof Error?e.message:String(e);return r8.warn({err:e instanceof Error?e:Error(n)},`content-filter rebuild failed — rolled back to previous state`),{ok:!1,error:{message:n}}}})};return O===null?t(o):(ee===null&&(ee=O.catch(()=>null).then(()=>(ee=null,t(o)))),ee)}}}async function HTe(e,t,n){let r=[{dir:e,relPath:``}],i=0;for(;r.length>0;){let{dir:e,relPath:a}=r.pop();i+=1,i>=50&&(i=0,await new Promise(e=>setImmediate(e)));let o;try{o=w(e,{withFileTypes:!0})}catch(t){r8.warn({dir:e,err:t},`Failed to read directory for dir-count: ${e}`);continue}for(let i of o){let o=a?`${a}/${i.name}`:i.name;if(i.isDirectory()){if(a8.has(i.name)||t(o)||t(`${o}/`))continue;r.push({dir:N(e,i.name),relPath:o})}else i.isFile()&&U6(i.name)&&!t(o)&&n.set(a,(n.get(a)??0)+1)}}}function b8(e,t,n,r){let i;try{i=w(e,{withFileTypes:!0})}catch(t){r8.warn({dir:e,err:t},`Failed to read directory for dir-count: ${e}`);return}for(let a of i){let i=t?`${t}/${a.name}`:a.name;if(a.isDirectory()){if(a8.has(a.name)||n(i)||n(`${i}/`))continue;b8(N(e,a.name),i,n,r)}else a.isFile()&&U6(a.name)&&!n(i)&&r.set(t,(r.get(t)??0)+1)}}function x8(e){return e.split(`
817
- `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`))}function S8(e,t){let n=e.startsWith(`!`),r=n?e.slice(1):e,i=r.startsWith(`/`)?r.slice(1):r,a=i.endsWith(`/`)?i.slice(0,-1):i,o=r.startsWith(`/`)||a.includes(`/`)?`${t}/${i}`:`${t}/**/${i}`;return n?`!${o}`:o}function C8(e,t,n,r,i){let a;try{a=w(e,{withFileTypes:!0})}catch(t){return r8.warn({dir:e,err:t},`Failed to read directory ${e}`),0}let o=0;for(let s of a){if(!s.isDirectory()||a8.has(s.name))continue;let a=N(e,s.name),c=G6(ye(t,a));if(!c.startsWith(`..`)&&!(n.ignores(c)||n.ignores(`${c}/`))){for(let e of v8){let t=N(a,e);if(g(t))try{let a=S(t,`utf-8`);i.value+=a.length;let s=x8(a).map(e=>S8(e,c));n.add(s),e===`.okignore`&&r.add(s),o++}catch(n){r8.warn({path:t,err:n},`Failed to read nested ${e} at ${t}`)}}o+=C8(a,t,n,r,i)}}return o}AX(`tag-index`),AX(`derived-document-index`),AX(`file-watcher`),new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}};const w8={start:I().int().nonnegative().optional(),end:I().int().nonnegative().optional(),quote:F().min(1).optional(),prefix:F().max(1e3).optional(),suffix:F().max(1e3).optional()};B({docName:F().min(1),...w8,propertyKey:F().min(1).optional(),propertyPath:z(V([F(),I().int().nonnegative()])).optional(),body:F(),queue:L().optional(),summary:F().optional()});const T8=yne();mo(`action`,[B({action:W(`edit`),id:T8,body:F(),summary:F().optional()}),B({action:W(`resolve`),id:T8,summary:F().optional()}),B({action:W(`reopen`),id:T8,summary:F().optional()}),B({action:W(`replace`),id:T8,...w8,summary:F().optional()}),B({action:W(`queue`),id:T8,summary:F().optional()}),B({action:W(`unqueue`),id:T8,summary:F().optional()}),B({action:W(`dispatch-prepare`),id:T8,summary:F().optional()}),B({action:W(`dispatch-complete`),id:T8,summary:F().optional()}),B({action:W(`dispatch-prepare-batch`),ids:z(T8).min(1).max(200),summary:F().optional()}),B({action:W(`dispatch-complete-batch`),ids:z(T8).min(1).max(200),summary:F().optional()})]),AX(`embeddings`),AX(`embeddings`);function UTe(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return`${t.protocol}//${t.host.toLowerCase()}${n}`}catch{return e.trim().replace(/\/+$/,``)}}UTe(ql),AX(`embeddings`),AX(`embeddings`);const WTe=/^[A-Za-z0-9-]{8,64}$/;let E8=null;function GTe(e){return N(e??k(),`.ok`,`machine-id`)}function KTe(e){if(e===void 0&&E8!==null)return E8;let t=GTe(e),n=null;try{let e=S(t,`utf-8`).trim();WTe.test(e)&&(n=e)}catch{}if(n===null){n=Pe();try{v(M(t),{recursive:!0}),re(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){AX(`machine-id`).warn({path:t,err:e},`Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(E8=n),n}AX(`process-lock`);function qTe(e,t){return be(e,`${t}.lock`)}function JTe(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function YTe(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=JTe(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}AX(`asset-references`),AX(`file-ops`),AX(`upload-streaming`);const D8="Absolute host path inside the target OpenKnowledge project. Required when the MCP server is registered globally (e.g. `npx @inkeep/open-knowledge mcp` once at the host level, routing per call), unless the MCP client advertises exactly one root via the `roots` capability — that single root is then used as the implicit `cwd`. Optional when the server is anchored to a single project (the per-project HTTP MCP server defaults to its configured project root).";F().max(200).optional().describe(`Optional one-line user-outcome description (≤80 chars). Appears as a bullet in the timeline.`),F().length(40).regex(/^[0-9a-f]+$/i).describe("A 40-character commit SHA identifying a saved version. Produced by `checkpoint`, listed by `history` as `entries[].version`, and consumed here — the same `version` field name across all three."),F().nullable().describe("Route-only preview URL (`/#/<doc>`, no host:port), or null when no UI is running."),F().optional().describe(`How the previewUrl was resolved (e.g. the UI lock).`),F().optional().describe(`Route of the prior/removed path, for closing a stale preview tab.`);const XTe=B({value:F(),truncatedFrom:I().optional(),hint:F().optional()}).describe(`Normalized change-note summary, when one was recorded.`),ZTe=z(H(F(),R()));H(F(),R()).optional().describe("Preview-attach hint (`{ action, previewUrl?, message? }`) when relevant."),z(kJ).describe('Outbound internal links in the just-written doc that do not resolve. Always present — `[]` means every link resolves UNLESS `brokenLinkSuppression` is also present, in which case a project policy withheld findings. A withholding that arrives in a shape this build cannot validate is dropped rather than relayed, so `brokenLinkSuppression` stays absent even though findings were withheld. The `audit` tool is the surface that discloses that case, through its `warnings`. Each: `{ href (as written), resolvedTo (the docName or content-root file path it pointed at, or null), reason: "no-such-doc" | "no-such-file" | "unresolvable" }`. Report-only — the write landed regardless; fix in a follow-up edit.'),jJ.optional().describe('Present ONLY when a project policy omitted detected broken links from `brokenLinks` — so an empty `brokenLinks` beside it does NOT mean every link resolves. `{ reason, count }`; `reason` today is `"reserved-log-policy"` (a reserved `log.md` records history whose links are expected not to resolve) and is an open token, so treat one you do not recognize as a withholding policy all the same. `count` is how many findings were withheld; the hrefs are deliberately not returned, because none of them is yours to repair.'),XTe.optional(),z(DJ).min(1).optional().describe("Advisory entries discriminated by `kind`. Write-integrity kinds — `content-divergence` (converged Y.Text didn't byte-match what you composed) and `disk-edit-reconciled` (an out-of-band disk edit was folded in before your write) — mean re-read the doc. The renderability kind `mermaid-parse-error` means the write landed but that fence will not render — fix it and re-edit."),z(B({name:F(),description:F().optional()})).min(1).optional().describe("Templates the parent folder offers, present only when a create passed no `template`. A nudge — the write already landed; pass `template` next time to match the folder's shape.");const QTe=F().optional().describe("Auto-duplicated body text. `textPlusStructured` mirrors the visible body here as a Claude / Claude Desktop client-quirk workaround (those clients hide `content[]` when `structuredContent` is present). Internal — programmatic consumers should prefer the `content[0].text` channel.");function O8(e){return{text:QTe,...e}}AX(`git-checkout`),AX(`git-worktree-status`),AX(`git-context`),AX(`managed-artifact-persistence`),AX(`timeline`),AX(`suggest-links`);function k8(e){try{return E.native(e)}catch{return e}}AX(`clone-flow`),Re(o),X6.project,Object.fromEntries(Object.entries(Ss).map(([e,t])=>[t,e])),[`These are patterns to adapt to your domain, not a layout to copy verbatim.`,"To build a variant: create your own folders (via `write` or your editor) and reuse only the ideas that fit.","To adopt this pack as-is: re-run without `--dry-run`."].join(`
818
- `),AX(`skills-leaderboard`),AX(`handoff-dispatch`),B({target:U(Object.keys({"claude-cowork":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},"claude-code":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},codex:{type:`app-bundle`,appName:`Codex`,urlScheme:`codex:`,probeScheme:`codex`,quitFirst:!0},cursor:{type:`cli-binary`,binaryName:`cursor`,urlScheme:`cursor:`}})),url:F().min(1).max(4096),workspacePath:F().optional()}),B({}).loose(),AX(`link-preview.guarded-fetch`),AX(`link-preview.cache`),AX(`saved-themes`),B({enabled:L(),active:L(),git:B({state:U([`not-applicable`,`ready`,`missing`,`conflict`,`unavailable`]),ownership:U([`open-knowledge`,`existing`]).optional()}),applied:L().optional(),reason:U([`git-conflict`,`git-unavailable`,`config-write`]).optional()}),B({enabled:L()}).strict(),AX(`managed-rename`),Object.assign(rCe,{m4v:`video/mp4`,mkv:`video/x-matroska`,flac:`audio/flac`,toml:`application/toml`,lock:`text/plain`,"7z":`application/x-7z-compressed`,tar:`application/x-tar`,rar:`application/vnd.rar`,xls:`application/vnd.ms-excel`,ppt:`application/vnd.ms-powerpoint`,odt:`application/vnd.oasis.opendocument.text`,ods:`application/vnd.oasis.opendocument.spreadsheet`,odp:`application/vnd.oasis.opendocument.presentation`,pages:`application/vnd.apple.pages`,numbers:`application/vnd.apple.numbers`,key:`application/vnd.apple.keynote`,mobi:`application/x-mobipocket-ebook`}),AX(`search`),AX(`skill-install`),AX(`api`),B({principalId:F().optional(),tabSessionId:F().optional(),expectedServerInstanceId:F().optional(),expectedBranch:F().optional(),expectedDocLineageEpoch:F().optional(),clientProtocolVersion:I().optional(),clientRuntimeVersion:F().optional(),clientKind:F().optional()}).loose(),AX(`conflict-storage`),new Ve,V6(()=>{}),[...wJ],[`[Requires: Hocuspocus server] Unified validation audit: every content problem — markdown-lint violations AND broken internal links — in one read-only call, grouped by the file to fix.`,``,"- No args → audit every in-scope `.md`/`.mdx` doc; pass `path` to scope to a folder or a single file.","- The result reports `ran`, the source families selected for this run. Project audit can report `markdownlint`, `frontmatter`, `okf`, and `links`. A family absent from `ran` was not checked. `okf` covers both document and project-tree OKF checks here.","- A selected family stays in `ran` if it degrades, with the reason in `warnings`. A partial degradation may still have contributed findings.","- To CHECK whether links resolve, use this tool: each broken link is reported under the SOURCE doc that contains it, at the offending line. (The `links` tool is the navigation/graph reader — backlinks, forward links, orphans, hubs — not the validation surface.)",'- Broken links written INSIDE a lowercase-stemmed `log.md`/`log.mdx` are omitted at any depth while the project\'s default-on `validation.suppressLogLinkAdvisories` setting is enabled. When findings are withheld, `brokenLinkSuppression: { reason: "reserved-log-policy", count: N }` makes the filtered result explicit without exposing paths or hrefs. A log is an append-only history whose entries deliberately reference pages that moved or were never written, so repairing them would rewrite that history. `LOG.md` is an ordinary doc and keeps its findings, and `links({ kind: "dead" })` reads the raw state unconditionally.',``,"Each diagnostic carries a `source` naming the validator ('markdownlint' rule violations; 'links' broken internal links), a `code` (e.g. MD010, dead-link), `message`, a 0-based LSP `range` (for links: line exact, column approximate), and `severity` ('error' | 'warning' — broken links default to warnings; the project's `validation.links` setting can raise them to errors or hide them). Only files with at least one problem are listed, plus `fileCount`/`errorCount`/`warningCount` totals. Output (text and structured) is capped at 10 files × 10 diagnostics per file and project-wide at 10 warnings, with explicit '… and N more' indicators and `omittedWarningCount` when warnings are dropped; the counts always reflect the full scan — re-run with `path` scoped to a folder or file to see what was omitted.",``,"Read-only: nothing is modified. Auto-fix fixable lint findings with `lint({ document, fix: true })`; broken links need content edits via `edit`/`write`."].join(`
817
+ `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`))}function S8(e,t){let n=e.startsWith(`!`),r=n?e.slice(1):e,i=r.startsWith(`/`)?r.slice(1):r,a=i.endsWith(`/`)?i.slice(0,-1):i,o=r.startsWith(`/`)||a.includes(`/`)?`${t}/${i}`:`${t}/**/${i}`;return n?`!${o}`:o}function C8(e,t,n,r,i){let a;try{a=w(e,{withFileTypes:!0})}catch(t){return r8.warn({dir:e,err:t},`Failed to read directory ${e}`),0}let o=0;for(let s of a){if(!s.isDirectory()||a8.has(s.name))continue;let a=N(e,s.name),c=Y6(ye(t,a));if(!c.startsWith(`..`)&&!(n.ignores(c)||n.ignores(`${c}/`))){for(let e of v8){let t=N(a,e);if(g(t))try{let a=S(t,`utf-8`);i.value+=a.length;let s=x8(a).map(e=>S8(e,c));n.add(s),e===`.okignore`&&r.add(s),o++}catch(n){r8.warn({path:t,err:n},`Failed to read nested ${e} at ${t}`)}}o+=C8(a,t,n,r,i)}}return o}AX(`mermaid-validator`),AX(`backlinks`),AX(`tag-index`),AX(`derived-document-index`),AX(`external-change-attribution`),AX(`file-watcher`),new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}};const w8={start:I().int().nonnegative().optional(),end:I().int().nonnegative().optional(),quote:F().min(1).optional(),prefix:F().max(1e3).optional(),suffix:F().max(1e3).optional()};B({docName:F().min(1),...w8,propertyKey:F().min(1).optional(),propertyPath:z(V([F(),I().int().nonnegative()])).optional(),body:F(),queue:L().optional(),summary:F().optional()});const T8=yne();mo(`action`,[B({action:W(`edit`),id:T8,body:F(),summary:F().optional()}),B({action:W(`resolve`),id:T8,summary:F().optional()}),B({action:W(`reopen`),id:T8,summary:F().optional()}),B({action:W(`replace`),id:T8,...w8,summary:F().optional()}),B({action:W(`queue`),id:T8,summary:F().optional()}),B({action:W(`unqueue`),id:T8,summary:F().optional()}),B({action:W(`dispatch-prepare`),id:T8,summary:F().optional()}),B({action:W(`dispatch-complete`),id:T8,summary:F().optional()}),B({action:W(`dispatch-prepare-batch`),ids:z(T8).min(1).max(200),summary:F().optional()}),B({action:W(`dispatch-complete-batch`),ids:z(T8).min(1).max(200),summary:F().optional()})]),AX(`embeddings`),AX(`embeddings`);function UTe(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return`${t.protocol}//${t.host.toLowerCase()}${n}`}catch{return e.trim().replace(/\/+$/,``)}}UTe(ql),AX(`embeddings`),AX(`embeddings`);const WTe=/^[A-Za-z0-9-]{8,64}$/;let E8=null;function GTe(e){return N(e??k(),`.ok`,`machine-id`)}function KTe(e){if(e===void 0&&E8!==null)return E8;let t=GTe(e),n=null;try{let e=S(t,`utf-8`).trim();WTe.test(e)&&(n=e)}catch{}if(n===null){n=Pe();try{v(M(t),{recursive:!0}),re(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){AX(`machine-id`).warn({path:t,err:e},`Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(E8=n),n}AX(`process-lock`);function qTe(e,t){return be(e,`${t}.lock`)}function JTe(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function YTe(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=JTe(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}AX(`asset-references`),AX(`file-ops`),AX(`upload-streaming`);const D8="Absolute host path inside the target OpenKnowledge project. Required when the MCP server is registered globally (e.g. `npx @inkeep/open-knowledge mcp` once at the host level, routing per call), unless the MCP client advertises exactly one root via the `roots` capability — that single root is then used as the implicit `cwd`. Optional when the server is anchored to a single project (the per-project HTTP MCP server defaults to its configured project root).";F().max(200).optional().describe(`Optional one-line user-outcome description (≤80 chars). Appears as a bullet in the timeline.`),F().length(40).regex(/^[0-9a-f]+$/i).describe("A 40-character commit SHA identifying a saved version. Produced by `checkpoint`, listed by `history` as `entries[].version`, and consumed here — the same `version` field name across all three."),F().nullable().describe("Route-only preview URL (`/#/<doc>`, no host:port), or null when no UI is running."),F().optional().describe(`How the previewUrl was resolved (e.g. the UI lock).`),F().optional().describe(`Route of the prior/removed path, for closing a stale preview tab.`);const XTe=B({value:F(),truncatedFrom:I().optional(),hint:F().optional()}).describe(`Normalized change-note summary, when one was recorded.`),ZTe=z(H(F(),R()));H(F(),R()).optional().describe("Preview-attach hint (`{ action, previewUrl?, message? }`) when relevant."),z(kJ).describe('Outbound internal links in the just-written doc that do not resolve. Always present — `[]` means every link resolves UNLESS `brokenLinkSuppression` is also present, in which case a project policy withheld findings. A withholding that arrives in a shape this build cannot validate is dropped rather than relayed, so `brokenLinkSuppression` stays absent even though findings were withheld. The `audit` tool is the surface that discloses that case, through its `warnings`. Each: `{ href (as written), resolvedTo (the docName or content-root file path it pointed at, or null), reason: "no-such-doc" | "no-such-file" | "unresolvable" }`. Report-only — the write landed regardless; fix in a follow-up edit.'),jJ.optional().describe('Present ONLY when a project policy omitted detected broken links from `brokenLinks` — so an empty `brokenLinks` beside it does NOT mean every link resolves. `{ reason, count }`; `reason` today is `"reserved-log-policy"` (a reserved `log.md` records history whose links are expected not to resolve) and is an open token, so treat one you do not recognize as a withholding policy all the same. `count` is how many findings were withheld; the hrefs are deliberately not returned, because none of them is yours to repair.'),XTe.optional(),z(DJ).min(1).optional().describe("Advisory entries discriminated by `kind`. Write-integrity kinds — `content-divergence` (converged Y.Text didn't byte-match what you composed) and `disk-edit-reconciled` (an out-of-band disk edit was folded in before your write) — mean re-read the doc. The renderability kind `mermaid-parse-error` means the write landed but that fence will not render — fix it and re-edit."),z(B({name:F(),description:F().optional()})).min(1).optional().describe("Templates the parent folder offers, present only when a create passed no `template`. A nudge — the write already landed; pass `template` next time to match the folder's shape.");const QTe=F().optional().describe("Auto-duplicated body text. `textPlusStructured` mirrors the visible body here as a Claude / Claude Desktop client-quirk workaround (those clients hide `content[]` when `structuredContent` is present). Internal — programmatic consumers should prefer the `content[0].text` channel.");function O8(e){return{text:QTe,...e}}AX(`git-checkout`),AX(`git-worktree-status`),AX(`git-context`),AX(`rename-log`),AX(`managed-artifact-persistence`),AX(`timeline`),AX(`suggest-links`);function k8(e){try{return E.native(e)}catch{return e}}AX(`clone-flow`),Re(o),G6.project,Object.fromEntries(Object.entries(Ss).map(([e,t])=>[t,e])),[`These are patterns to adapt to your domain, not a layout to copy verbatim.`,"To build a variant: create your own folders (via `write` or your editor) and reuse only the ideas that fit.","To adopt this pack as-is: re-run without `--dry-run`."].join(`
818
+ `),AX(`skills-leaderboard`),AX(`handoff-dispatch`),B({target:U(Object.keys({"claude-cowork":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},"claude-code":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},codex:{type:`app-bundle`,appName:`Codex`,urlScheme:`codex:`,probeScheme:`codex`,quitFirst:!0},cursor:{type:`cli-binary`,binaryName:`cursor`,urlScheme:`cursor:`}})),url:F().min(1).max(4096),workspacePath:F().optional()}),B({}).loose(),AX(`link-preview.guarded-fetch`),AX(`link-preview.cache`),AX(`saved-themes`),B({enabled:L(),active:L(),git:B({state:U([`not-applicable`,`ready`,`missing`,`conflict`,`unavailable`]),ownership:U([`open-knowledge`,`existing`]).optional()}),applied:L().optional(),reason:U([`git-conflict`,`git-unavailable`,`config-write`]).optional()}),B({enabled:L()}).strict(),AX(`managed-rename`),Object.assign(rCe,{m4v:`video/mp4`,mkv:`video/x-matroska`,flac:`audio/flac`,toml:`application/toml`,lock:`text/plain`,"7z":`application/x-7z-compressed`,tar:`application/x-tar`,rar:`application/vnd.rar`,xls:`application/vnd.ms-excel`,ppt:`application/vnd.ms-powerpoint`,odt:`application/vnd.oasis.opendocument.text`,ods:`application/vnd.oasis.opendocument.spreadsheet`,odp:`application/vnd.oasis.opendocument.presentation`,pages:`application/vnd.apple.pages`,numbers:`application/vnd.apple.numbers`,key:`application/vnd.apple.keynote`,mobi:`application/x-mobipocket-ebook`}),AX(`search`),AX(`skill-install`),AX(`history`),AX(`api`),B({principalId:F().optional(),tabSessionId:F().optional(),expectedServerInstanceId:F().optional(),expectedBranch:F().optional(),expectedDocLineageEpoch:F().optional(),clientProtocolVersion:I().optional(),clientRuntimeVersion:F().optional(),clientKind:F().optional()}).loose(),AX(`conflict-storage`),new Ve,V6(()=>{}),[...wJ],[`[Requires: Hocuspocus server] Unified validation audit: every content problem — markdown-lint violations AND broken internal links — in one read-only call, grouped by the file to fix.`,``,"- No args → audit every in-scope `.md`/`.mdx` doc; pass `path` to scope to a folder or a single file.","- The result reports `ran`, the source families selected for this run. Project audit can report `markdownlint`, `frontmatter`, `okf`, and `links`. A family absent from `ran` was not checked. `okf` covers both document and project-tree OKF checks here.","- A selected family stays in `ran` if it degrades, with the reason in `warnings`. A partial degradation may still have contributed findings.","- To CHECK whether links resolve, use this tool: each broken link is reported under the SOURCE doc that contains it, at the offending line. (The `links` tool is the navigation/graph reader — backlinks, forward links, orphans, hubs — not the validation surface.)",'- Broken links written INSIDE a lowercase-stemmed `log.md`/`log.mdx` are omitted at any depth while the project\'s default-on `validation.suppressLogLinkAdvisories` setting is enabled. When findings are withheld, `brokenLinkSuppression: { reason: "reserved-log-policy", count: N }` makes the filtered result explicit without exposing paths or hrefs. A log is an append-only history whose entries deliberately reference pages that moved or were never written, so repairing them would rewrite that history. `LOG.md` is an ordinary doc and keeps its findings, and `links({ kind: "dead" })` reads the raw state unconditionally.',``,"Each diagnostic carries a `source` naming the validator ('markdownlint' rule violations; 'links' broken internal links), a `code` (e.g. MD010, dead-link), `message`, a 0-based LSP `range` (for links: line exact, column approximate), and `severity` ('error' | 'warning' — broken links default to warnings; the project's `validation.links` setting can raise them to errors or hide them). Only files with at least one problem are listed, plus `fileCount`/`errorCount`/`warningCount` totals. Output (text and structured) is capped at 10 files × 10 diagnostics per file and project-wide at 10 warnings, with explicit '… and N more' indicators and `omittedWarningCount` when warnings are dropped; the counts always reflect the full scan — re-run with `path` scoped to a folder or file to see what was omitted.",``,"Read-only: nothing is modified. Auto-fix fixable lint findings with `lint({ document, fix: true })`; broken links need content edits via `edit`/`write`."].join(`
819
819
  `),[`[Requires: Hocuspocus server] Save a project-wide checkpoint of every document — a single restore point you can return to.`,``,`**Parameters:**`,'- `summary` — Optional one-line label for the checkpoint (≤80 chars). Defaults to "Checkpoint version". Appears as the checkpoint subject in `history`. Avoid secrets or PII — persisted to git history.',``,"Returns `{ version }` — the 40-char checkpoint SHA. Find checkpoints later via `history`; restore a single doc with `restore_version({ document, version })`."].join(`
820
820
  `),[`[Operates on disk; no running OK server required] Read the effective merged OpenKnowledge config (defaults → user → project).`,``,`Use this when you need to inspect the config mid-session — e.g., after a write that may have changed disk state, or to re-confirm the value of a field before reading it again.`,``,"Read returns the FULL merged config or a sub-tree when `key` is provided. There is no allowlist on reads — every field is readable.",``,"Note: the `server.*`, `mcp.*`, and `github.*` config sub-trees, plus `preview.baseUrl` and `preview.scriptSrc`, were removed; their values are now built-in constants in `@inkeep/open-knowledge-core` (or, for the preview iframe, a fixed open network policy). Reading those keys returns `exists: false`. (`appearance.preview.autoOpen` is still a live key.)",``,"This tool is a pure READ. Folder-level skill topology (link / unlink / add-root) moved to the `install` tool's `skillFolders` argument, so this one keeps its read-only annotation and stays auto-approvable.",``,`**Parameters:**`,'- `key` (optional) — Dotted config key. `"content"` returns the content sub-tree; `"appearance.theme"` returns just that leaf. Omit for full config.',"- `cwd` (optional) — Project root (see `cwd` description below)."].join(`
821
821
  `),F().optional().describe(`Dotted config key (e.g. "appearance.theme"). Omit to return the full merged config.`),F().optional().describe(D8),O8({value:R().describe(`Resolved config value at the requested path (or full config).`),exists:L().optional().describe('Whether the requested path resolved to a value. `false` distinguishes "path absent" from "path explicitly set to null". Always emitted — `true` on a full-config read.'),key:F().optional().describe(`Echo of the requested dotted key (absent when reading the full config).`)}),["[Requires: Hocuspocus server] Read Git merge conflicts and local stale external-write conflicts. Dispatches on `kind`:",``,'- `kind: "list"` — enumerate every tracked conflict. Returns `{ list: [{ file, detectedAt, conflictKind, ... }] }` (empty when none). The entry point to the resolve flow.','- `kind: "content"` — fetch the versions for one `file`. Returns `{ content: { file, base, ours, theirs, shape, conflictKind, lifecycleStatus } }`. `ours` reflects the live Y.Text (what the human sees) when the doc is loaded server-side.','- `conflictKind: "git"` uses Git versions. `conflictKind: "stale-external-write"` means a known older disk version was refused: `base` is the last reconciled version, `ours` is the protected live or recovered version, and `theirs` is the rejected disk version. Resolving this local conflict does not create a Git commit.','- A Git list entry with `variant: "working-tree"` is a local overlay conflict: resolution changes the working tree without a resolution commit. Other Git entries use index stages and commit only when the last conflict clears. The content response does not distinguish these two Git variants; inspect the list entry.',``,`**Parameters:**`,"- `kind` — `list` | `content`.",'- `file` — Required for `kind: "content"`. Relative path WITH the `.md`/`.mdx` extension (e.g. `notes/sso.md`) — git stages key on the exact path, so do NOT strip the extension.',``,"The `shape` field discriminates the conflict: `both-modified` (both sides edited), `delete-modify` (you deleted, they edited — `ours` empty), or `modify-delete` (you edited, they deleted — `theirs` empty). Use it to pick the `resolve_conflict` strategy."].join(`
@@ -1481,7 +1481,7 @@ export default function okBridge(pi: {
1481
1481
  }
1482
1482
  });
1483
1483
  }
1484
- `}function yDe(e,t){let n=ye(k8(t),k8(e));return n.length>0&&!n.startsWith(`..`)&&!ge(n)}const bDe=e=>{try{let t=s(`git`,[`rev-parse`,`--show-toplevel`],W6({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function xDe(e,t={}){let n=t.homeDir??k(),r=t.gitTopLevel??bDe,i=be(e),a;try{a=E(i)}catch{a=i}let o=a,s=0;for(;s<30&&o!==n&&o!==`/`&&o!==``;){if(n8(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=M(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&yDe(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function R5(e,t){let n;try{n=_(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);z5(e,t)}function SDe(e,t){z5(e,t)}function z5(e,t){B5(e,t)}function B5(e,t){let n=t,r;try{r=E(n)}catch{r=be(n)}let i=M(e);for(;i.length>1&&i!==xe;){let t;try{t=E(i)}catch(e){if(e.code===`ENOENT`){i=M(i);continue}throw e}let n=ye(r,t);if(n===``||!n.startsWith(`..`)&&!ge(n))return;throw Error(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function V5(e,t){let n=M(t),r=g(t)?`overwritten`:`written`;if(r===`written`&&g(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return O(n,{recursive:!0,force:!0}),v(M(n),{recursive:!0}),m(e,n,{recursive:!0}),r}function H5(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function U5(e,t,n){try{if(te(n).size>10485760)return!1}catch{return!1}let r;try{r=S(n,`utf-8`)}catch{return!1}let i=[],a=FSe(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!H5(a))return!1;let o=a[e.topLevelKey];if(!H5(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!H5(s))return!1;let c=s[e.serverName(t)];return H5(c)&&c.enabled===!1?!1:y5(c)||zEe(c)}function CDe(e){let t=us[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:Uo(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:j5[n.editor]??null}function wDe(e,t,n={}){if(!vn.includes(e.id))return!0;let r=CDe(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&U5(r,t,i))return!0;try{return U5(e,t,e.configPath(t,n.home))}catch{return!1}}function TDe(e){let t=new Set(fn.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function EDe(e,t){if(TDe(t).length===0)return null;let n=N(e,xs,mn,`SKILL.md`);try{let t=$6(`project`,{checkDesktop:!0});return R5(M(n),e),{editorId:`agents`,label:`.agents hub`,action:V5(t,n),path:n}}catch(e){return{editorId:`agents`,label:`.agents hub`,action:`failed`,path:n,error:e instanceof Error?e.message:String(e)}}}function W5(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!wDe(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=$6(`project`,{checkDesktop:!0});R5(M(r),t);let i=V5(n,r);return{editorId:e.id,label:e.label,action:i,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function DDe(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=M(n);return g(n)?(SDe(r,t),O(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function ODe(){let e=Y8();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function kDe(e){let t=e,n=new Set;for(;;){let r;try{r=_(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=T(t)}catch(t){return J8(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=ge(i)?i:N(M(t),i)}}let G5;function ADe(){return G5===void 0&&(G5=ODe()),G5}function K5(e,t=ADe){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){J8(`resolveSymlinkWritePath threw`,e)}return kDe(e)}const q5=`**/.ok/*`,J5=`!**/${bs}/`;function Y5(e){let t=[`.ok/`,`.okignore`];for(let n of $8){let r=j5[n];r.projectConfigPath&&t.push(FDe(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function X5(e){let t=N(e,...bB);if(!g(t))return[];try{let e=wB(S(t,`utf-8`));if(!e)return[];let n=[];for(let[t,r]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of r.hosts){let r=un[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function jDe(e,t){let n=Z5(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:Q5(n)};let r=$5(e);if(r.kind!==`ok`)return r.result;let i=g(r.path)?S(r.path,`utf-8`):``,a=new Set(X5(e)),o=[],s=a.size===0?i:i.split(`
1484
+ `}function yDe(e,t){let n=ye(k8(t),k8(e));return n.length>0&&!n.startsWith(`..`)&&!ge(n)}const bDe=e=>{try{let t=s(`git`,[`rev-parse`,`--show-toplevel`],W6({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function xDe(e,t={}){let n=t.homeDir??k(),r=t.gitTopLevel??bDe,i=be(e),a;try{a=E(i)}catch{a=i}let o=a,s=0;for(;s<30&&o!==n&&o!==`/`&&o!==``;){if(n8(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=M(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&yDe(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function R5(e,t){let n;try{n=_(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);z5(e,t)}function SDe(e,t){z5(e,t)}function z5(e,t){B5(e,t)}function B5(e,t){let n=t,r;try{r=E(n)}catch{r=be(n)}let i=M(e);for(;i.length>1&&i!==xe;){let t;try{t=E(i)}catch(e){if(e.code===`ENOENT`){i=M(i);continue}throw e}let n=ye(r,t);if(n===``||!n.startsWith(`..`)&&!ge(n))return;throw Error(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function V5(e,t){let n=M(t),r=g(t)?`overwritten`:`written`;if(r===`written`&&g(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return O(n,{recursive:!0,force:!0}),v(M(n),{recursive:!0}),m(e,n,{recursive:!0}),r}function H5(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function U5(e,t,n){try{if(te(n).size>10485760)return!1}catch{return!1}let r;try{r=S(n,`utf-8`)}catch{return!1}let i=[],a=FSe(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!H5(a))return!1;let o=a[e.topLevelKey];if(!H5(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!H5(s))return!1;let c=s[e.serverName(t)];return H5(c)&&c.enabled===!1?!1:y5(c)||zEe(c)}function CDe(e){let t=us[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:Uo(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:j5[n.editor]??null}function wDe(e,t,n={}){if(!vn.includes(e.id))return!0;let r=CDe(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&U5(r,t,i))return!0;try{return U5(e,t,e.configPath(t,n.home))}catch{return!1}}function TDe(e){let t=new Set(fn.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function EDe(e,t){if(TDe(t).length===0)return null;let n=N(e,xs,mn,`SKILL.md`);try{let t=J6(`project`,{checkDesktop:!0});return R5(M(n),e),{editorId:`agents`,label:`.agents hub`,action:V5(t,n),path:n}}catch(e){return{editorId:`agents`,label:`.agents hub`,action:`failed`,path:n,error:e instanceof Error?e.message:String(e)}}}function W5(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!wDe(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=J6(`project`,{checkDesktop:!0});R5(M(r),t);let i=V5(n,r);return{editorId:e.id,label:e.label,action:i,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function DDe(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=M(n);return g(n)?(SDe(r,t),O(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function ODe(){let e=Y8();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function kDe(e){let t=e,n=new Set;for(;;){let r;try{r=_(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=T(t)}catch(t){return J8(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=ge(i)?i:N(M(t),i)}}let G5;function ADe(){return G5===void 0&&(G5=ODe()),G5}function K5(e,t=ADe){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){J8(`resolveSymlinkWritePath threw`,e)}return kDe(e)}const q5=`**/.ok/*`,J5=`!**/${bs}/`;function Y5(e){let t=[`.ok/`,`.okignore`];for(let n of $8){let r=j5[n];r.projectConfigPath&&t.push(FDe(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function X5(e){let t=N(e,...bB);if(!g(t))return[];try{let e=wB(S(t,`utf-8`));if(!e)return[];let n=[];for(let[t,r]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of r.hosts){let r=un[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function jDe(e,t){let n=Z5(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:Q5(n)};let r=$5(e);if(r.kind!==`ok`)return r.result;let i=g(r.path)?S(r.path,`utf-8`):``,a=new Set(X5(e)),o=[],s=a.size===0?i:i.split(`
1485
1485
  `).filter(e=>{let t=e.trim();return!a.has(t)||(o.push(t),!1)}).join(`
1486
1486
  `),c=n7(s),l=[],u=[];for(let e of t)t7(c,e)?u.push(e):l.push(e);if(l.length===0&&o.length===0)return{kind:`updated`,appended:l,alreadyPresent:u,removed:[]};let d=l.length===0||s.length===0||s.endsWith(`
1487
1487
  `)?``:`
@@ -1524,13 +1524,13 @@ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){funct
1524
1524
  `),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
1525
1525
  `)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
1526
1526
  `).replace(/\n/g,`\r
1527
- `));let u=`${i?``:``}${l}`;return u!==r&&FQ(e,u,{mode:o7(e)}),{kind:`removed`}}function QOe(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}function $Oe(e){let{priorCommand:t,priorArgs:n}=h9(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function h9(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function g9(e,t,n={}){let r=qTe(e,t);if(!g(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(S(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!iTe(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??H6)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??KTe())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??ce();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}async function eke(e,t=void 0){let n=g9(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=YTe(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500)});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function tke(e,t={}){return{targets:rke(e,t.isAlive??H6)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function nke(e){let t=e.inspect??(()=>g9(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??eke,o=e.logger??void 0,s=tke(t(),{isAlive:e.isAlive});if(s.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:s.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let c=[],l=[];for(let e of s.targets)try{n(e.pid,`SIGTERM`),c.push(e)}catch(t){l.push({target:e,error:t instanceof Error?t.message:String(t)})}return c.length>0&&r(`Stopped: ${c.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:c.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:l.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),l.length>0&&i(`Failed to stop: ${l.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:c,failed:l,hadTargets:!0}}function rke(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}function _9(e){if(!g(e))return{value:null,path:e,source:null,doc:null};let t;try{t=S(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,rn.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return K8(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function ike(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=fu({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function ake(e){let t=e??process.cwd(),n=[],r=[],i=[],a=[],o=zQ(`user`,t),s=PQ({absPath:o});r.push(...s.diagnostics),!s.valid&&s.sidelinedTo!==void 0&&i.push({from:o,to:s.sidelinedTo}),s.valid&&s.source!==void 0&&n.push(o);let c=(e,t=!1)=>{let i=_9(e);if(i.diagnostic!==void 0&&r.push(i.diagnostic),i.value===null)return{};let o=Pu({value:i.value,file:i.path,source:i.source,doc:i.doc});r.push(...o),n.push(e);let s=o.length>0?Iu(i.value):i.value;return t&&a.push(...bR({value:s,file:i.path,source:i.source,doc:i.doc})),s},l=be(t,`.ok`,`config.yml`),u=c(l,!0),d=c(zQ(`project-local`,t)),f=xR(s.value,u,d),p=sEe.safeParse(f);if(!p.success){let e=_9(l),t={code:`SCHEMA_INVALID`,issues:ike(p.error.issues,e)};throw Error(ku(t))}return{config:p.data,sources:n,diagnostics:r,sidelined:i,ignoredCommittedKeys:a}}function v9(e){return e.replace(/:\d+$/,``)}function y9(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:v9(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:v9(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:v9(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 b9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=kR(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`).filter(e=>e.length>0);if(r.length<5||r[2]!==`blob`)return null;let i,a,o,s;try{i=decodeURIComponent(r[0]),a=decodeURIComponent(r[1]),o=decodeURIComponent(r[3]),s=r.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.length===0||s.some(e=>e.length===0)?null:{host:n,owner:i,repo:a,branch:o,path:s.join(`/`)}}function x9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=kR(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`);if(r.length<5||r[0]!==``||r[3]!==`tree`)return null;let i=r.slice(5);i.length===1&&i[0]===``&&i.pop();let a,o,s,c;try{a=decodeURIComponent(r[1]),o=decodeURIComponent(r[2]),s=decodeURIComponent(r[4]),c=i.map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function oke(e){let t=b9(e);if(t)return{kind:`doc`,...t};let n=x9(e);return n?{kind:`folder`,...n}:null}async function ske(e,t){let n,r;try{n=await De(be(e)),r=await De(be(M(e)))}catch{return{kind:`not-git`}}if(!S9(n,r))return{kind:`symlink-escape`};let i=N(n,`.git`),a;try{a=te(i)}catch{return{kind:`not-git`}}if(a.isDirectory()){let e;try{e=await De(i)}catch{return{kind:`not-git`}}if(!S9(e,n))return{kind:`symlink-escape`}}else if(!a.isFile())return{kind:`not-git`};let o=wge(n);if(o.kind!==`repository`)return{kind:`not-git`};let s=o.repository.readRemoteUrl(`origin`);if(s.kind===`unreadable`)return{kind:`not-git`};if(s.kind===`absent`)return s.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let c=s.url,l=y9(c);if(l===null)return{kind:`non-github`};let u=kR(l.hostname);if(u===null)return{kind:`non-github`};let d=u===t.host.toLowerCase(),f=l.owner.toLowerCase()===t.owner.toLowerCase(),p=l.name.toLowerCase()===t.repo.toLowerCase();return!d&&f&&p?{kind:`wrong-host`,actualHost:u}:!d||!f||!p?{kind:`wrong-repo`,actualOwner:l.owner,actualRepo:l.name}:{kind:`ok`,gitRemoteUrl:`https://${u}/${l.owner}/${l.name}.git`}}function S9(e,t){if(e===t)return!0;let n=ye(t,e);return n.length>0&&!n.startsWith(`..`)&&!ge(n)}const cke=`# >>> open-knowledge cli >>>`,lke=`# <<< open-knowledge cli <<<`,uke=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function dke(e){return N(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}function C9(e,t,n=[]){let r=g(N(e,X6[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function fke(e,t){let n=$8.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),r=fn.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:xs}));return[...n,...r]}function w9(e,t,n,r){let i=nCe(e,fke(t,r)),a=i.find(e=>e.host===n);if(a===void 0||a.state===`absent`)return[];let o=a.real;return i.filter(e=>e.host!==n&&e.state!==`absent`&&e.real===o).map(e=>e.host)}function pke(e,t){let n=(t??k()).replace(/[\\/]+$/,``);if(!n.includes(`\\`))return e.startsWith(`${n}/`)?`~/${e.slice(n.length+1)}`:e;let r=e=>e.replace(/\\/g,`/`),i=r(n),a=r(e);return a.startsWith(`${i}/`)?`~/${a.slice(i.length+1)}`:e}function mke(e,t){let n=j5[e];return g7(n,``,t)&&!h7(n,``,t)}function T9(e,t,n,r,i){let a=j5[e],o;if(i===void 0)try{o=a.configPath(n,r)}catch{return{state:`structural-na`}}else o=i;let s=i===void 0?pke(o,r):void 0,c=b7(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&mke(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];u5(r)&&i.push(`reclaim-permissive`),p5(r)&&i.push(`pre-approval-exact`),x7(e)(r)&&i.push(`injection-functional`);let o=HEe(a,n);return i.length>0&&(o!==null&&UEe(r,o)||t.includes(`pre-approval-exact`)&&i.includes(`reclaim-permissive`)&&!i.includes(`pre-approval-exact`))?{state:`drifted`,strictness:i,path:s}:i.length>0?{state:`satisfied`,strictness:i,path:s}:LEe(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function hke(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let r=Uo(e.pathId);if(r===null)return null;if(r.kind===`central-skill-store`)return n===void 0?null:C9(N(n,xs),`discovery`,w9(n,dn,e.agent,`global`));let i=r.editor;switch(r.kind){case`editor-user-skill-root`:{let e=dn[i];return e===null||n===void 0?null:e8(n).some(e=>e.editorId===i)?C9(N(n,e),`discovery`,w9(n,dn,i,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=un[i];return e===null?null:C9(N(t,e),`project`,w9(t,un,i,`project`))}case`editor-user-config`:return T9(i,e.strictness,t,n);case`editor-project-config`:{let r=_n[i];return r===null?null:T9(i,e.strictness,t,n,N(t,r))}}}}[...Z6.map(e=>X6[e])];function gke(e){if(!ge(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=be(e);if(t===xe||M(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function E9(e){let t=gke(e),n=[];for(let e of Z6){let r=X6[e];n.push({path:N(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of hn)n.push({path:N(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function _ke(e,t){let n=[];for(let r of E9(e))if(r.bundleId===t)try{O(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}const vke=[{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=_7(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=W5(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function yke(e,t,n={},r=vke){let i=[];for(let a of t){let t=j5[a];for(let a of r)i.push(a.write(t,e,n))}let a=EDe(e,t);return a&&i.push({integration:`project-skill`,editorId:a.editorId,action:a.action,...a.path?{path:a.path}:{},...a.error?{error:a.error}:{}}),i}function bke(e,t,n={}){return{integrations:yke(e,t,n)}}function D9(e,t){let n=dn[e];return n===null?null:N(t,...n.split(`/`),X6.discovery,`SKILL.md`)}function xke(e,t){let n=D9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!e8(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=$6(`discovery`,{checkDesktop:!0});return B5(M(n),t),{editorId:e,label:e,action:V5(r,n),path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function Ske(e){return g(N(e,...`.agents/skills`.split(`/`),X6.discovery))?!0:ln.some(t=>{let n=D9(t,e);return n!==null&&g(M(n))})}function Cke(e,t){let n=D9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};let r=M(n);try{return g(n)?(B5(r,t),O(r,{recursive:!0,force:!0}),{editorId:e,label:e,action:`removed`,path:n}):{editorId:e,label:e,action:`not-present`,path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function wke(e){return PQ({absPath:zQ(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function O9({home:e=k(),env:t=process.env}={}){let n=wke(e),{override:r,preferenceList:i}=hye(t),{locale:a,source:o}=yB({override:r,storedPreference:n,supportedLocales:cl,preferenceList:i,autoDetectableLocales:ul});return{preference:n,locale:a,source:o,systemLanguages:i}}function k9(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Tke(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A9(e,t){if(typeof e==`string`)return k9(e,t.contentDir);if(Array.isArray(e))return e.map(e=>A9(e,t));if(!Tke(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=A9(i,t);return n}function j9(e,t){let n=S(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
1527
+ `));let u=`${i?``:``}${l}`;return u!==r&&FQ(e,u,{mode:o7(e)}),{kind:`removed`}}function QOe(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}function $Oe(e){let{priorCommand:t,priorArgs:n}=h9(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function h9(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function g9(e,t,n={}){let r=qTe(e,t);if(!g(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(S(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!iTe(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??H6)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??KTe())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??ce();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}async function eke(e,t=void 0){let n=g9(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=YTe(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500)});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function tke(e,t={}){return{targets:rke(e,t.isAlive??H6)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function nke(e){let t=e.inspect??(()=>g9(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??eke,o=e.logger??void 0,s=tke(t(),{isAlive:e.isAlive});if(s.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:s.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let c=[],l=[];for(let e of s.targets)try{n(e.pid,`SIGTERM`),c.push(e)}catch(t){l.push({target:e,error:t instanceof Error?t.message:String(t)})}return c.length>0&&r(`Stopped: ${c.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:c.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:l.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),l.length>0&&i(`Failed to stop: ${l.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:c,failed:l,hadTargets:!0}}function rke(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}function _9(e){if(!g(e))return{value:null,path:e,source:null,doc:null};let t;try{t=S(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,rn.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return K8(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function ike(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=fu({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function ake(e){let t=e??process.cwd(),n=[],r=[],i=[],a=[],o=zQ(`user`,t),s=PQ({absPath:o});r.push(...s.diagnostics),!s.valid&&s.sidelinedTo!==void 0&&i.push({from:o,to:s.sidelinedTo}),s.valid&&s.source!==void 0&&n.push(o);let c=(e,t=!1)=>{let i=_9(e);if(i.diagnostic!==void 0&&r.push(i.diagnostic),i.value===null)return{};let o=Pu({value:i.value,file:i.path,source:i.source,doc:i.doc});r.push(...o),n.push(e);let s=o.length>0?Iu(i.value):i.value;return t&&a.push(...bR({value:s,file:i.path,source:i.source,doc:i.doc})),s},l=be(t,`.ok`,`config.yml`),u=c(l,!0),d=c(zQ(`project-local`,t)),f=xR(s.value,u,d),p=sEe.safeParse(f);if(!p.success){let e=_9(l),t={code:`SCHEMA_INVALID`,issues:ike(p.error.issues,e)};throw Error(ku(t))}return{config:p.data,sources:n,diagnostics:r,sidelined:i,ignoredCommittedKeys:a}}function v9(e){return e.replace(/:\d+$/,``)}function y9(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:v9(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:v9(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:v9(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 b9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=kR(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`).filter(e=>e.length>0);if(r.length<5||r[2]!==`blob`)return null;let i,a,o,s;try{i=decodeURIComponent(r[0]),a=decodeURIComponent(r[1]),o=decodeURIComponent(r[3]),s=r.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.length===0||s.some(e=>e.length===0)?null:{host:n,owner:i,repo:a,branch:o,path:s.join(`/`)}}function x9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=kR(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`);if(r.length<5||r[0]!==``||r[3]!==`tree`)return null;let i=r.slice(5);i.length===1&&i[0]===``&&i.pop();let a,o,s,c;try{a=decodeURIComponent(r[1]),o=decodeURIComponent(r[2]),s=decodeURIComponent(r[4]),c=i.map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function oke(e){let t=b9(e);if(t)return{kind:`doc`,...t};let n=x9(e);return n?{kind:`folder`,...n}:null}async function ske(e,t){let n,r;try{n=await De(be(e)),r=await De(be(M(e)))}catch{return{kind:`not-git`}}if(!S9(n,r))return{kind:`symlink-escape`};let i=N(n,`.git`),a;try{a=te(i)}catch{return{kind:`not-git`}}if(a.isDirectory()){let e;try{e=await De(i)}catch{return{kind:`not-git`}}if(!S9(e,n))return{kind:`symlink-escape`}}else if(!a.isFile())return{kind:`not-git`};let o=wge(n);if(o.kind!==`repository`)return{kind:`not-git`};let s=o.repository.readRemoteUrl(`origin`);if(s.kind===`unreadable`)return{kind:`not-git`};if(s.kind===`absent`)return s.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let c=s.url,l=y9(c);if(l===null)return{kind:`non-github`};let u=kR(l.hostname);if(u===null)return{kind:`non-github`};let d=u===t.host.toLowerCase(),f=l.owner.toLowerCase()===t.owner.toLowerCase(),p=l.name.toLowerCase()===t.repo.toLowerCase();return!d&&f&&p?{kind:`wrong-host`,actualHost:u}:!d||!f||!p?{kind:`wrong-repo`,actualOwner:l.owner,actualRepo:l.name}:{kind:`ok`,gitRemoteUrl:`https://${u}/${l.owner}/${l.name}.git`}}function S9(e,t){if(e===t)return!0;let n=ye(t,e);return n.length>0&&!n.startsWith(`..`)&&!ge(n)}const cke=`# >>> open-knowledge cli >>>`,lke=`# <<< open-knowledge cli <<<`,uke=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function dke(e){return N(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}function C9(e,t,n=[]){let r=g(N(e,G6[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function fke(e,t){let n=$8.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),r=fn.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:xs}));return[...n,...r]}function w9(e,t,n,r){let i=nCe(e,fke(t,r)),a=i.find(e=>e.host===n);if(a===void 0||a.state===`absent`)return[];let o=a.real;return i.filter(e=>e.host!==n&&e.state!==`absent`&&e.real===o).map(e=>e.host)}function pke(e,t){let n=(t??k()).replace(/[\\/]+$/,``);if(!n.includes(`\\`))return e.startsWith(`${n}/`)?`~/${e.slice(n.length+1)}`:e;let r=e=>e.replace(/\\/g,`/`),i=r(n),a=r(e);return a.startsWith(`${i}/`)?`~/${a.slice(i.length+1)}`:e}function mke(e,t){let n=j5[e];return g7(n,``,t)&&!h7(n,``,t)}function T9(e,t,n,r,i){let a=j5[e],o;if(i===void 0)try{o=a.configPath(n,r)}catch{return{state:`structural-na`}}else o=i;let s=i===void 0?pke(o,r):void 0,c=b7(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&mke(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];u5(r)&&i.push(`reclaim-permissive`),p5(r)&&i.push(`pre-approval-exact`),x7(e)(r)&&i.push(`injection-functional`);let o=HEe(a,n);return i.length>0&&(o!==null&&UEe(r,o)||t.includes(`pre-approval-exact`)&&i.includes(`reclaim-permissive`)&&!i.includes(`pre-approval-exact`))?{state:`drifted`,strictness:i,path:s}:i.length>0?{state:`satisfied`,strictness:i,path:s}:LEe(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function hke(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let r=Uo(e.pathId);if(r===null)return null;if(r.kind===`central-skill-store`)return n===void 0?null:C9(N(n,xs),`discovery`,w9(n,dn,e.agent,`global`));let i=r.editor;switch(r.kind){case`editor-user-skill-root`:{let e=dn[i];return e===null||n===void 0?null:X6(n).some(e=>e.editorId===i)?C9(N(n,e),`discovery`,w9(n,dn,i,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=un[i];return e===null?null:C9(N(t,e),`project`,w9(t,un,i,`project`))}case`editor-user-config`:return T9(i,e.strictness,t,n);case`editor-project-config`:{let r=_n[i];return r===null?null:T9(i,e.strictness,t,n,N(t,r))}}}}[...K6.map(e=>G6[e])];function gke(e){if(!ge(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=be(e);if(t===xe||M(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function E9(e){let t=gke(e),n=[];for(let e of K6){let r=G6[e];n.push({path:N(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of hn)n.push({path:N(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function _ke(e,t){let n=[];for(let r of E9(e))if(r.bundleId===t)try{O(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}const vke=[{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=_7(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=W5(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function yke(e,t,n={},r=vke){let i=[];for(let a of t){let t=j5[a];for(let a of r)i.push(a.write(t,e,n))}let a=EDe(e,t);return a&&i.push({integration:`project-skill`,editorId:a.editorId,action:a.action,...a.path?{path:a.path}:{},...a.error?{error:a.error}:{}}),i}function bke(e,t,n={}){return{integrations:yke(e,t,n)}}function D9(e,t){let n=dn[e];return n===null?null:N(t,...n.split(`/`),G6.discovery,`SKILL.md`)}function xke(e,t){let n=D9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!X6(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=J6(`discovery`,{checkDesktop:!0});return B5(M(n),t),{editorId:e,label:e,action:V5(r,n),path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function Ske(e){return g(N(e,...`.agents/skills`.split(`/`),G6.discovery))?!0:ln.some(t=>{let n=D9(t,e);return n!==null&&g(M(n))})}function Cke(e,t){let n=D9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};let r=M(n);try{return g(n)?(B5(r,t),O(r,{recursive:!0,force:!0}),{editorId:e,label:e,action:`removed`,path:n}):{editorId:e,label:e,action:`not-present`,path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function wke(e){return PQ({absPath:zQ(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function O9({home:e=k(),env:t=process.env}={}){let n=wke(e),{override:r,preferenceList:i}=hye(t),{locale:a,source:o}=yB({override:r,storedPreference:n,supportedLocales:cl,preferenceList:i,autoDetectableLocales:ul});return{preference:n,locale:a,source:o,systemLanguages:i}}function k9(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Tke(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A9(e,t){if(typeof e==`string`)return k9(e,t.contentDir);if(Array.isArray(e))return e.map(e=>A9(e,t));if(!Tke(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=A9(i,t);return n}function j9(e,t){let n=S(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
1528
1528
  `),i=n.split(`
1529
1529
  `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=A9(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
1530
1530
  `)}\n`:a.join(`
1531
1531
  `);re(e,o)}function M9(e,t){let n=S(e,`utf-8`);if(n.trim().length!==0)try{let r=A9(JSON.parse(n),t),i=n.endsWith(`
1532
1532
  `)?`
1533
1533
  `:``;re(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=k9(n,t.contentDir);r!==n&&re(e,r)}}function N9(e,t){let n=S(e,`utf-8`),r=k9(n,t.contentDir);r!==n&&re(e,r)}function P9(e){try{return w(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>N(e,t.name))}catch{return[]}}const Eke=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function F9(e){return/\.log\.\d+$/.test(e)}function Dke(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||F9(e)}const Oke=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function kke(e){let t={contentDir:e.contentDir};for(let n of Oke)for(let r of P9(N(e.stagingDir,n)))Dke(r)?j9(r,t):r.endsWith(`.json`)?M9(r,t):N9(r,t);for(let n of P9(N(e.stagingDir,`state`))){let e=me(n);n.endsWith(`.jsonl`)?j9(n,t):Eke.has(e)?M9(n,t):N9(n,t)}}const I9=[`.ok`,`local`,`telemetry`],L9=[`.ok`,`local`,`logs`],R9=[`.ok`,`local`,`loss-capture`],z9=`spans-current.jsonl`,B9=`spans-prev.jsonl`,V9=`server-current.jsonl`,H9=`server-prev.jsonl`,U9=`loss-current.jsonl`,W9=`loss-prev.jsonl`;function Ake(e){return N(e,...I9,z9)}function jke(e){return N(e,...I9,B9)}function Mke(e){return N(e,...L9,V9)}function Nke(e){return N(e,...L9,H9)}function Pke(e){return N(e,...R9,U9)}function Fke(e){return N(e,...R9,W9)}const G9=1e3;async function Ike(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function Lke(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function Rke(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}function zke(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
1534
- `)}\n`:null}catch{return null}}function Bke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],W6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Vke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],W6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Hke(){return{nodeVersion:process.version,platform:le(),arch:ae()}}function Uke(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,rn.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function Wke(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return Wke(e.maxBytes)}function Gke(e){let t=J9(zQ(`project`,e)),n=J9(zQ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function Kke(e){return Ne(`sha256`).update(e).digest(`hex`)}function qke(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const Jke=[`"doc.name"`,`"docName"`];function Yke(e){let t=S(e,`utf-8`),n=0;for(let e of Jke){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(M(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,w7(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Xke=new Set([`.jsonl`]);function Zke(e){let t=e.lastIndexOf(`.`);return t!==-1&&Xke.has(e.slice(t))}const Qke=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function $ke(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Qke.has(e.slice(t))}function eAe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!$ke(r))continue;let{redacted:i,patterns:a,lineCount:o}=DB(S(n,`utf-8`));a.length!==0&&(re(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return ye(e,t).split(xe).join(`/`)}async function tAe(e){let t=be(e.contentDir),n=be(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Ike,a=r.fetchAgentEffects??Lke,o=r.fetchWatcherRecent??Rke,s=r.readShadowHead??Bke,c=r.readCheckpointRefs??Vke,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.71.2-beta.1`),d=r.readDesktopEnv??K9,f=r.readLanguage??O9,p=r.readRuntime??Hke,h=r.isOtlpPushEnabled??Uke,_=y(N(A(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),Z9(Ake(n),N(_,`telemetry`,z9)),Z9(jke(n),N(_,`telemetry`,B9)),Z9(Mke(n),N(_,`logs`,V9)),Z9(Nke(n),N(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,N(_,`logs`,me(t)));for(let t of e.userStateFiles??[])Z9(t,N(_,sR,me(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,N(_,`diagnostic-reports`,me(t)))&&(y+=1);let b=N(n,`.ok`,`local`),x=N(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,N(_,`state`,`server.lock`));try{let e=S(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(re(N(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(N(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=zke(n);e!==null&&re(N(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(N(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(N(_,`state`,`checkpoint-refs.txt`),D),Z9(Pke(n),N(_,`state`,U9)),Z9(Fke(n),N(_,`state`,W9)),Z9(N(b,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),Z9(N(b,Lu),N(_,`state`,Lu)),Z9(N(b,Ru),N(_,`state`,Ru));let ee=p(),ne=d(),ie=f(),ae={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};re(N(_,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let oe=C===`running`?`running
1534
+ `)}\n`:null}catch{return null}}function Bke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],W6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Vke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],W6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Hke(){return{nodeVersion:process.version,platform:le(),arch:ae()}}function Uke(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,rn.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function Wke(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return Wke(e.maxBytes)}function Gke(e){let t=J9(zQ(`project`,e)),n=J9(zQ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function Kke(e){return Ne(`sha256`).update(e).digest(`hex`)}function qke(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const Jke=[`"doc.name"`,`"docName"`];function Yke(e){let t=S(e,`utf-8`),n=0;for(let e of Jke){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(M(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,w7(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Xke=new Set([`.jsonl`]);function Zke(e){let t=e.lastIndexOf(`.`);return t!==-1&&Xke.has(e.slice(t))}const Qke=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function $ke(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Qke.has(e.slice(t))}function eAe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!$ke(r))continue;let{redacted:i,patterns:a,lineCount:o}=DB(S(n,`utf-8`));a.length!==0&&(re(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return ye(e,t).split(xe).join(`/`)}async function tAe(e){let t=be(e.contentDir),n=be(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Ike,a=r.fetchAgentEffects??Lke,o=r.fetchWatcherRecent??Rke,s=r.readShadowHead??Bke,c=r.readCheckpointRefs??Vke,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.71.2`),d=r.readDesktopEnv??K9,f=r.readLanguage??O9,p=r.readRuntime??Hke,h=r.isOtlpPushEnabled??Uke,_=y(N(A(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),Z9(Ake(n),N(_,`telemetry`,z9)),Z9(jke(n),N(_,`telemetry`,B9)),Z9(Mke(n),N(_,`logs`,V9)),Z9(Nke(n),N(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,N(_,`logs`,me(t)));for(let t of e.userStateFiles??[])Z9(t,N(_,sR,me(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,N(_,`diagnostic-reports`,me(t)))&&(y+=1);let b=N(n,`.ok`,`local`),x=N(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,N(_,`state`,`server.lock`));try{let e=S(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(re(N(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(N(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=zke(n);e!==null&&re(N(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(N(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(N(_,`state`,`checkpoint-refs.txt`),D),Z9(Pke(n),N(_,`state`,U9)),Z9(Fke(n),N(_,`state`,W9)),Z9(N(b,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),Z9(N(b,Lu),N(_,`state`,Lu)),Z9(N(b,Ru),N(_,`state`,Ru));let ee=p(),ne=d(),ie=f(),ae={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};re(N(_,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let oe=C===`running`?`running
1535
1535
  `:`not-running (${w})\n`;re(N(_,`state`,`server-status.txt`),oe);let se=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:C7(e.diagnosticReports,y);if(re(N(_,`state`,`diagnostic-reports-status.txt`),`${se}\n`),e.processDir&&g(e.processDir)){let t=N(_,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let k=e.redact===!0;k&&kke({stagingDir:_,contentDir:t}),e.note&&re(N(_,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=eAe(_));for(let t of e.extraFiles??[])Z9(t.sourcePath,N(_,`extra`,t.zipName??me(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let le=Gke(n),ue=Q9(_),A=[],j=0,de=0;for(let e of ue){let t=$9(_,e),n=te(e).size,r=Zke(t)?qke(e):0;A.push({path:t,bytes:n,lines:r}),j+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(de+=Yke(e))}let fe={applied:k};ce!==null&&(fe.secretScrub=ce);let pe={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie},contentDir:{pathSha256:Kke(t),absolutePath:k?`<CONTENT_DIR>`:t},telemetry:{localSink:le,otlpPushEnabled:h()},redaction:fe,serverStatus:C,files:A};re(N(_,`manifest.json`),`${JSON.stringify(pe,null,2)}\n`);let M=ue.some(e=>{try{return S(e,`utf-8`).includes(t)}catch{return!1}}),he={stagedDiagnosticReports:y,totalBytes:j,fileCount:A.length,docNameCount:de,contentDirVisible:M,redacted:k},ge=!1;return{stagingDir:_,manifest:pe,summary:he,cleanup:()=>{ge||(ge=!0,O(_,{recursive:!0,force:!0}))}}}catch(e){throw O(_,{recursive:!0,force:!0}),e}}async function nAe(e){let{collected:t,outputPath:n}=e,r=M(n);if(!g(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new wSe.ZipFile,a=Q9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=h(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function rAe(e,t){let n=N(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,rn.parse)(S(n,`utf-8`)),r=K8(t)?t.content:void 0,i=K8(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return be(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return be(e)}async function iAe(e,t,n,r,i){let a=E7(t,e.logger),o=await tAe({contentDir:rAe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...mOe(a,e.userLogsDir??N(k(),`.ok`,`logs`)),...O7(e.cachesDir??N(k(),`Library`,`Caches`))],userStateFiles:k7(e.bugReportsDir??T7()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{v(M(e.outputPath),{recursive:!0}),await nAe({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function aAe(e){let{projectDir:t}=e,n=e.readDesktopEnv??K9,r=e.readLanguage??O9,i=()=>uOe(e.diagnosticReportsDir??N(k(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return iAe(e,t,n,r,i());let{zipPath:a,summary:o}=await yOe({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:O7(e.cachesDir??N(k(),`Library`,`Caches`)),bugReportLedgerFiles:k7(e.bugReportsDir??T7()),diagnosticReports:e.level===`full`?i():void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}export{$8 as ALL_EDITOR_IDS,e5 as EDITOR_LABELS,j5 as EDITOR_TARGETS,PEe as HOSTS_WITH_USER_SKILL_DIR,XDe as LAUNCH_CONFIG_NAME,cke as PATH_SHIM_BEGIN,uke as PATH_SHIM_BLOCK_RE,lke as PATH_SHIM_END,jDe as addOkPathsToGitExclude,R5 as assertProjectPathSafe,f5 as buildManagedServerEntry,QOe as buildMcpConfigDeclineEvent,$Oe as buildMcpConfigMigrateEvent,b7 as classifyExistingMcpEntry,aAe as collectReportBundle,hke as createCliProbeResolver,cn as createTokenStore,dOe as defaultBugReportZipPath,We as detectGh,qe as detectGhAccounts,eOe as detectInstalledEditors,x5 as droppedManagedKeys,eDe as editorConfigPathDisplay,$Ee as editorEntryLocator,VOe as ensurePiBridge,Q5 as formatTrackedRemediation,PDe as getExcludedOkPaths,X5 as getInstalledSkillProjectionPaths,NEe as getNativeTomlMcpEditor,Y5 as getOkArtifactPaths,u5 as isEntryUpToDate,p5 as isOwnManagedEntry,ake as loadConfig,vee as makeLazyProbeTokenStore,T7 as okBugReportsDir,b9 as parseGitHubBlobUrl,oke as parseGitHubShareUrl,x9 as parseGitHubTreeUrl,y9 as parseGitUrl,dke as pathInstallMarkerPath,hDe as previewContent,tOe as probeOwnManagedEditorMcpEntry,zOe as probePiBridgeState,Z5 as probeTrackedOkPaths,v7 as readExistingMcpEntry,NDe as readSharingMode,DB as redactContent,MDe as removeOkPathsFromGitExclude,JOe as removeOwnMcpEntry,DDe as removeProjectSkill,_ke as removeUserGlobalSkillBundle,Cke as removeUserSkill,xDe as resolveProjectRoot,nke as runStop,h9 as truncatePriorEntry,E9 as userGlobalSkillBundleTargets,Ske as userSkillPresentAnywhere,ske as validateLocalFolderForShare,_7 as writeEditorMcpConfig,bke as writeProjectAiIntegrations,W5 as writeProjectSkill,$De as writeUserMcpConfigs,xke as writeUserSkill};
1536
1536
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ import"./dist-D1HfouVm.mjs";import{_ as e}from"./init-D_gjDHTf.mjs";export{e as runInit};