@inkeep/open-knowledge 0.72.0-beta.5 → 0.72.0-beta.7

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 (95) hide show
  1. package/dist/cli.mjs +6 -6
  2. package/dist/constants-CWW8AXUs.mjs +1 -0
  3. package/dist/{dist-DJSvIyoE.mjs → dist-CQFFmkEE.mjs} +1 -1
  4. package/dist/{dist-CIcphNQy.mjs → dist-CVs8BCwZ.mjs} +465 -465
  5. package/dist/index.d.mts +1 -1
  6. package/dist/index.mjs +4 -4
  7. package/dist/{init-CpWmzBSx.mjs → init-CH3pTYUX.mjs} +2 -2
  8. package/dist/init-CVn6YFNi.mjs +1 -0
  9. package/dist/{launch-json-removal-DHoIXMAW.mjs → launch-json-removal-Bi5IeUUF.mjs} +1 -1
  10. package/dist/{loader-BGm6eeZp.mjs → loader-CB4bM4Vr.mjs} +1 -1
  11. package/dist/loader-Cxge_ign.mjs +1 -0
  12. package/dist/{open-browser-Bq5FSdgJ.mjs → open-browser-C5MWfuW0.mjs} +1 -1
  13. package/dist/{preview-BJFciD0a.mjs → preview-Ba7L_87z.mjs} +1 -1
  14. package/dist/preview-DU00Ukqf.mjs +1 -0
  15. package/dist/public/assets/{ActivityModeContent-DuV-Wxoa.js → ActivityModeContent-Bh-aOINO.js} +1 -1
  16. package/dist/public/assets/{AddPropertiesButton-DPmktRPG.js → AddPropertiesButton-CKvbln-l.js} +1 -1
  17. package/dist/public/assets/{AgentDiffPane-CxU1PJrg.js → AgentDiffPane-h0k7R2PC.js} +1 -1
  18. package/dist/public/assets/{CodeMirrorPropInput-D97WOcle.js → CodeMirrorPropInput-CsU-AE2e.js} +1 -1
  19. package/dist/public/assets/{DocumentContext-DX4_PUWv.js → DocumentContext-CaB8wd1_.js} +1 -1
  20. package/dist/public/assets/{EditorModeToggle-CvJLZD0M.js → EditorModeToggle-CmusAWSZ.js} +1 -1
  21. package/dist/public/assets/{EnableSyncConfirmDialog-czS5nsXI.js → EnableSyncConfirmDialog-DmhIDAV-.js} +1 -1
  22. package/dist/public/assets/{ExcalidrawDocEditor-Cz-kIZcN.js → ExcalidrawDocEditor-CCrqGTpz.js} +1 -1
  23. package/dist/public/assets/FeedbackForm-CDCCOd52.js +1 -0
  24. package/dist/public/assets/{ImportSkillDialog-d_yMgunZ.js → ImportSkillDialog-DU5H3G2e.js} +1 -1
  25. package/dist/public/assets/{LintConfigEditor-Cql11JCw.js → LintConfigEditor-BFpjLGZ_.js} +1 -1
  26. package/dist/public/assets/{ManagedArtifactProperties-DVOVMN78.js → ManagedArtifactProperties-DPLTTAuN.js} +1 -1
  27. package/dist/public/assets/ManagedArtifactProperties-j9ihkOtM.js +1 -0
  28. package/dist/public/assets/{MermaidDocEditor-BzvUKrvv.js → MermaidDocEditor-DFksLDPw.js} +1 -1
  29. package/dist/public/assets/{PropertyDisplayRow-EAikSGib.js → PropertyDisplayRow-rtfso48w.js} +1 -1
  30. package/dist/public/assets/{SchemaConfigEditor-q_ojTlU-.js → SchemaConfigEditor-BKnKFgWH.js} +1 -1
  31. package/dist/public/assets/{SessionsHost-Bype_V2w.js → SessionsHost-DuBW7e2j.js} +2 -2
  32. package/dist/public/assets/{SettingsDialogBody-ClOXAL7Y.js → SettingsDialogBody-CLyWK9_-.js} +1 -1
  33. package/dist/public/assets/{ShareReceiveMissDialog-DikJivBp.js → ShareReceiveMissDialog-Dt5uoAmv.js} +1 -1
  34. package/dist/public/assets/{SkillToolbarControls-BaE_PtLx.js → SkillToolbarControls-BdthwmpX.js} +1 -1
  35. package/dist/public/assets/SlidesToolbarControls-8RmRXuaP.js +1 -0
  36. package/dist/public/assets/{SourceEditor-DdIDVFJy.js → SourceEditor-BiO9HLmi.js} +1 -1
  37. package/dist/public/assets/{TerminalPanel-Dg4Odd7P.js → TerminalPanel-Bxt1nIhY.js} +1 -1
  38. package/dist/public/assets/{TerminalWindowApp-CuHu-kBD.js → TerminalWindowApp-DEMYVkAB.js} +1 -1
  39. package/dist/public/assets/{TextDocEditor-aXrm23PN.js → TextDocEditor-B8DepRN7.js} +1 -1
  40. package/dist/public/assets/{ThreadView-DwpDF29Z.js → ThreadView-BoQYnWvN.js} +1 -1
  41. package/dist/public/assets/{TimelineDiffPane-COILPEZH.js → TimelineDiffPane-DtoYKVQR.js} +1 -1
  42. package/dist/public/assets/agent-connection-status-CgdIUJFO.js +1 -0
  43. package/dist/public/assets/{auth-state-cache-D93mj765.js → auth-state-cache-g0tpeNul.js} +1 -1
  44. package/dist/public/assets/client-version-CH6DzlkY.js +1 -0
  45. package/dist/public/assets/{comment-chips-DaPmziL-.js → comment-chips-DSoCMI7Q.js} +1 -1
  46. package/dist/public/assets/{config-provider-xvx1bLbF.js → config-provider-CI1IgVHl.js} +1 -1
  47. package/dist/public/assets/{doc-undo-manager-Cp9RgUJD.js → doc-undo-manager-b7w4Wb9M.js} +1 -1
  48. package/dist/public/assets/{index-0EMkZ_HU.js → index-DWjHCX39.js} +8 -8
  49. package/dist/public/assets/{messages-DKTKP9pT.js → messages-BOC9mOzO.js} +1 -1
  50. package/dist/public/assets/{messages-BVMprXL3.js → messages-BhYfldC5.js} +1 -1
  51. package/dist/public/assets/{messages-CzlIjFg6.js → messages-BoCdYQSk.js} +1 -1
  52. package/dist/public/assets/{messages-D9axSU6Y.js → messages-BqTuEu2G.js} +1 -1
  53. package/dist/public/assets/{messages-Bqfd7jkb.js → messages-C0RTwTFq.js} +1 -1
  54. package/dist/public/assets/{messages-DSA8fzIO.js → messages-C8BAfoNQ.js} +1 -1
  55. package/dist/public/assets/{messages-DMFl2kw9.js → messages-D3e2EYtP.js} +1 -1
  56. package/dist/public/assets/{messages-bATdY7jB.js → messages-DIaB-As6.js} +1 -1
  57. package/dist/public/assets/{messages-dbMtQLBB.js → messages-DKzsGETG.js} +1 -1
  58. package/dist/public/assets/{messages-CH72i-bO.js → messages-DYwug_Cl.js} +1 -1
  59. package/dist/public/assets/{messages-knxD2r8o.js → messages-DvW7r91G.js} +1 -1
  60. package/dist/public/assets/{messages-D8dZFF9f.js → messages-aNdi0uM6.js} +1 -1
  61. package/dist/public/assets/{pending-receive-nav-store-DsL1PcWo.js → pending-receive-nav-store-C-oPT_Kg.js} +1 -1
  62. package/dist/public/assets/{progress-CqeKUHyJ.js → progress-CzvNMH_z.js} +1 -1
  63. package/dist/public/assets/{selection-context-BzpZfjkH.js → selection-context-BUgPXj5h.js} +1 -1
  64. package/dist/public/assets/{src-Bew9jsBg.js → src-79HN8GE9.js} +1 -1
  65. package/dist/public/assets/{telemetry-impl-Ccp0NCP8.js → telemetry-impl-G9GQmQGJ.js} +1 -1
  66. package/dist/public/assets/{telemetry-startup-BTPhdwGS.js → telemetry-startup-C_vDSOkT.js} +1 -1
  67. package/dist/public/assets/{typing-burst-detector-BbwwSUxU.js → typing-burst-detector-BQKKqosX.js} +1 -1
  68. package/dist/public/assets/{uninstall-DxyqZMFJ.js → uninstall-Bb6vCccP.js} +1 -1
  69. package/dist/public/assets/{use-activity-panel-CXRjvVsk.js → use-activity-panel-pDb7IY6s.js} +1 -1
  70. package/dist/public/assets/{use-apply-config-language-CJPbOFtI.js → use-apply-config-language-48pLGsax.js} +2 -2
  71. package/dist/public/assets/{use-open-skill-DDuaC258.js → use-open-skill-C4iRLb07.js} +1 -1
  72. package/dist/public/assets/{use-terminal-enabled-CHN--3NP.js → use-terminal-enabled-b0w6NCxQ.js} +1 -1
  73. package/dist/public/assets/{use-timeline-entry-diff-C_2xolry.js → use-timeline-entry-diff-Cv356cHC.js} +1 -1
  74. package/dist/public/index.html +19 -19
  75. package/dist/public/uninstall.html +3 -3
  76. package/dist/{registry-probes-C3ywQM6a.mjs → registry-probes-BvtvRW2N.mjs} +1 -1
  77. package/dist/{removal-file-path-BH9TBBEA.mjs → removal-file-path-RVB0vSi1.mjs} +1 -1
  78. package/dist/{repair-launch-json-B2dn8CrD.mjs → repair-launch-json-BnlV_psu.mjs} +1 -1
  79. package/dist/{repair-mcp-configs-DgYY6svQ.mjs → repair-mcp-configs-CVnSDcwe.mjs} +1 -1
  80. package/dist/{src-DC0SGbZ5.mjs → src-BinCag7Z.mjs} +1 -1
  81. package/dist/src-DZbeDCEs.mjs +1 -0
  82. package/dist/start-DApOX8So.mjs +1 -0
  83. package/dist/{start-beQe9K3u.mjs → start-DrsgK-zS.mjs} +3 -3
  84. package/package.json +5 -5
  85. package/dist/constants-DEplBBeL.mjs +0 -1
  86. package/dist/init-BGrCTWN-.mjs +0 -1
  87. package/dist/loader-CSqioEBS.mjs +0 -1
  88. package/dist/preview-Bkrg2o4g.mjs +0 -1
  89. package/dist/public/assets/FeedbackForm-C1whS86p.js +0 -1
  90. package/dist/public/assets/ManagedArtifactProperties-BG4Fy3XQ.js +0 -1
  91. package/dist/public/assets/SlidesToolbarControls-BYkwABPX.js +0 -1
  92. package/dist/public/assets/agent-connection-status-CORLBJuD.js +0 -1
  93. package/dist/public/assets/client-version-C8sAZlzC.js +0 -1
  94. package/dist/src-R3Q_wbFF.mjs +0 -1
  95. package/dist/start-BteyuLah.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -11099,7 +11099,7 @@ type OkSlidesStatusResult = {
11099
11099
  readonly kind: 'status';
11100
11100
  readonly available: false;
11101
11101
  };
11102
- type SlidevOpenFailureReason = 'not-available' | 'invalid-path' | 'spawn-error' | 'exited-early' | 'cancelled' | 'load-failed' | 'renderer-failed' | 'timeout' | 'unsupported-server';
11102
+ type SlidevOpenFailureReason = 'not-available' | 'invalid-path' | 'spawn-error' | 'port-error' | 'exited-early' | 'cancelled' | 'load-failed' | 'renderer-failed' | 'timeout' | 'unsupported-server';
11103
11103
  type OkSlidesOpenResult = {
11104
11104
  readonly kind: 'open';
11105
11105
  readonly ok: true;
package/dist/index.mjs CHANGED
@@ -809,12 +809,12 @@ 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)}}));aTe(),R6(),z6(),V6(),sTe(),kc();const cTe=new Set;function H6(e){cTe.add(e)}function lTe(){return Dc.getTracer(`open-knowledge-server`)}async function uTe(e,t,n){return lTe().startActiveSpan(e,t??{},async e=>{try{let t=await n(e);return e.isRecording(),t}catch(t){throw e.recordException(t),e.setStatus({code:bc.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}jX(`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()}),jX(`checkpoint-chain`);function U6(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function dTe(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}jX(`shadow-lock`),jX(`shadow-op-gate`),jX(`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})(),MY.fileSystem,MY.gitUpstream,MY.service,MY.generator,jX(`bridge-loss-detector`),jX(`checkpoint`);function W6(e){let t=he(e).toLowerCase();return bR.includes(t)}function fTe(e){let t=e.toLowerCase();for(let n of bR)if(t.endsWith(n))return e.slice(0,-n.length);return e}function pTe(e){return e===`__system__`}const mTe=new Set(Nre);function hTe(e){return mTe.has(e)}function gTe(e){return Pre(e)}function _Te(e){return pTe(e)||hTe(e)||gTe(e)}jX(`parse-pool`),Math.max(1,Math.min(4,oe()-1)),H6(()=>{}),jX(`bridge-watchdog`),H6(()=>{}),jX(`server-observers`),jX(`server-observers`),jX(`agent-sessions`);function G6(e){return{...e,windowsHide:!0}}function vTe(){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`}vTe(),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 K6(e){return e.replace(/\\/g,`/`)}jX(`external-change-attribution`),jX(`mermaid-validator`),jX(`rename-log`),jX(`history`),RegExp(`<(${VJ.map(e=>e.tagName).join(`|`)})\\b([^>]*)\\/>`,`y`);const yTe=String.raw`\[\[([^\n#[\]|]+)(?:#([^\n[\]|]+))?(?:\|([^\n[\]]+))?\]\]`,bTe=String.raw`\((<[^>\n]+>|[^)\s\n]+)((?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)\)`,q6=String.raw`([^\]\n]*)`,J6=String.raw`([^\]\n]*(?:\][^[\]\n]*)?)`,Y6=e=>RegExp(`(!?)${yTe}`,e),X6=(e,t)=>RegExp(`(!?)\\[${e}\\]${bTe}`,t);Y6(`y`),Y6(`g`),X6(q6,`y`),X6(J6,`y`),X6(q6,`g`),X6(J6,`g`);const xTe=String.raw`(!?)\[([^\]\n]*)\](?:\[([^\]\n]*)\])?`;new RegExp(xTe,`y`),jX(`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),xR.cursor,xR.codex,xR[`claude-desktop`],H6(()=>{});const Z6={discovery:`open-knowledge-discovery`,project:`open-knowledge`,"write-skill":`open-knowledge-write-skill`};new Set(Object.values(Z6));const STe=Object.keys(Z6),CTe={discovery:`user`,project:`project`,"write-skill":`user`},Q6=STe.filter(e=>CTe[e]===`user`);new Set(Q6.map(e=>Z6[e])),Re(x),jX(`agent-registry-apply`);const $6=`OpenKnowledge.app/Contents/Resources/cli/dist/assets/skills`;function e8(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`,$6,e)),(!o||t.home!==void 0)&&a.push(N(i,`Applications`,$6,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.`)}jX(`local-op-security`);function t8(e){return mn.filter(t=>g(N(e,t.hostDir)))}function n8(e,t){return[...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({editor:e,root:t})),{editor:`agents`,root:t}]}n8(ln,vs),[...n8(un,vs)].sort((e,t)=>{let n=a4.indexOf(e.editor),r=a4.indexOf(t.editor);return(n===-1?a4.length:n)-(r===-1?a4.length:r)||e.editor.localeCompare(t.editor)}),jX(`installed-skills-marker`),jX(`skill-import`);function r8(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 i8=jX(`content-filter`);Re(o);const a8=[`.claude`,`.cursor`,`.codex`,`.agents`,`.opencode`,`.pi`],o8=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`,...a8,`Library`,`Applications`,`.Trash`]),wTe=new Set([`.git`,`node_modules`,`.ok`,`.open-knowledge`,`.openknowledge`,...a8]),s8=new Set([`worktrees`,`local`]);function c8(e){let t=eu(e);if(!tu(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 TTe(e){throw Error(`[AttachmentFolderShape] unhandled variant: ${JSON.stringify(e)}`)}function ETe(e,t,n){let r=he(e).slice(1).toLowerCase();if(!il.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 TTe(t)}function l8(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(wTe.has(i)&&!(t&&i===`.ok`&&!s8.has((n[e+1]??``).toLowerCase())))return!0}return!1}function u8(e){return e.startsWith(`${_s}/`)}function DTe(e){return e===`.ok`||e===`.ok/skills`||e.startsWith(`.ok/skills/`)}const d8=new Set([`.ok`,...a8]),OTe=new Set([...o8].filter(e=>!d8.has(e))),kTe=[`.git`,`node_modules`,`.ok/local`,`.ok/worktrees`].flatMap(e=>[e,`${e}/**`,`**/${e}`,`**/${e}/**`]);function ATe(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);return t.includes(`..`)?!1:t.some(e=>OTe.has(e))?!0:t.some((e,n)=>e.toLowerCase()===`.ok`&&s8.has((t[n+1]??``).toLowerCase()))}const jTe=[`.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`,...a8.flatMap(e=>[e,`${e}/skills/example/SKILL.md`])];function MTe(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(ATe(t))return!1;if(n.some(e=>d8.has(e)))return!0;try{let e=(0,c4.default)().add(t);return jTe.some(t=>e.ignores(t))}catch{return!0}}function NTe(e){let t=e.filter(e=>e.length>0&&!e.startsWith(`!`)&&!e.startsWith(`#`)&&!MTe(e));return[...new Set([...t,...kTe])]}function f8(e,t){for(let n=0;n<t;n++)if(o8.has(e[n])||e[n].toLowerCase()===`.ok`)return!0;return!1}function p8(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:!f8(t,n-3)}function m8(e){let t=e.split(`/`),n=t.length;return t[n-1]===`.ok`?!f8(t,n-1):n>=2&&t[n-1]===`templates`&&t[n-2]===`.ok`&&!f8(t,n-2)}function PTe(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`))||p8(e)?!0:n>=2&&t[n-1]===`frontmatter.yml`&&t[n-2]===`.ok`&&!f8(t,n-2)}function FTe(e){return e===`.ok`||e===`.ok/schemas`||m8(e)}function ITe(e,t){for(let n of t)if(e===n||e.startsWith(`${n}/`))return!0;return!1}function h8(e,t){if(t.size===0)return!1;for(let n of t)if(e.startsWith(`${n}/`))return!0;return!1}function LTe(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 RTe=new Set([`.ds_store`,`.localized`,`thumbs.db`,`desktop.ini`,`.directory`]);function g8(e){return RTe.has(e.slice(e.lastIndexOf(`/`)+1).toLowerCase())}const zTe=new Set([`.ssh`,`.aws`,`.gnupg`,`.kube`,`.docker`]);function _8(e){for(let t of e.split(`/`))if(zTe.has(t.toLowerCase()))return!0;return!1}const BTe=new Set([`credentials`,`.netrc`,`.npmrc`,`.pgpass`,`.git-credentials`]),VTe=[`.pem`,`.key`,`.p12`,`.pfx`,`.keystore`,`.jks`,`.ppk`];function v8(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(t===`.env`||t.startsWith(`.env.`)||BTe.has(t)||t.startsWith(`id_rsa`)||t.startsWith(`id_ed25519`)||t.startsWith(`id_ecdsa`)||t.startsWith(`id_dsa`))return!0;for(let e of VTe)if(t.endsWith(e))return!0;return!1}function HTe(e,t){return t===e||t.startsWith(`${e}/`)}function UTe(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=r8(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 y8=[`.gitignore`,`.okignore`];function WTe(e,t){let n=GTe(e);if(n===null)return[];let r=[];b8(N(n,`info`,`exclude`),t,r,`info/exclude`);let i=KTe(e);return i&&b8(i,t,r,`global excludesfile`),r}function GTe(e){let t=l(`git`,[`rev-parse`,`--git-common-dir`],G6({cwd:e,encoding:`utf-8`,timeout:5e3}));return t.status!==0||!t.stdout?null:be(e,t.stdout.trim())}function KTe(e){let t=l(`git`,[`config`,`--get`,`--type=path`,`core.excludesfile`],G6({cwd:e,encoding:`utf-8`,timeout:5e3}));if(t.status===0&&t.stdout){let e=t.stdout.trim();if(e)return e}return qTe()}function qTe(){let e=process.env.XDG_CONFIG_HOME?.trim(),t=e&&e.length>0?e:N(k(),`.config`);return N(t,`git`,`ignore`)}function b8(e,t,n,r){if(g(e))try{let r=S(e,`utf-8`);t.value+=r.length,n.push(...S8(r))}catch(t){i8.warn({path:e,err:t},`Failed to read ${r} at ${e}`)}}function JTe(e){let{projectDir:t,contentDir:n,onAfterRebuild:r,singleDocRelPath:i}=e,a=e.inPlaceSkillDirs??new Set,o=c8(e.attachmentFolderPath??`./`),s=e.skillRootPaths??new Set,c=UTe(t,n,i),l=K6(ye(t,n)),u=l.startsWith(`..`),d,f,p,m,h=0,_=0,v=0;function y(){let e=(0,c4.default)(),r=(0,c4.default)();e.add(`.git`);let i=[],a=0,o=0;for(let n of y8){let o=N(t,n);if(g(o))try{let t=S(o,`utf-8`);a+=t.length;let s=S8(t);i.push(...s),e.add(s),n===`.okignore`&&r.add(s)}catch(e){i8.warn({path:o,err:e},`Failed to read ${n} at ${o}`)}}if(l&&!u)for(let t of y8){let i=N(n,t);if(g(i))try{let n=S(i,`utf-8`);a+=n.length,o++;let s=S8(n).map(e=>C8(e,l));e.add(s),t===`.okignore`&&r.add(s)}catch(e){i8.warn({path:i,err:e},`Failed to read ${t} at ${i}`)}}let s={value:a};o+=w8(n,t,e,r,s),a=s.value;let c=WTe(t,s);a=s.value,c.length>0&&(i.push(...c),e.add(c));let y=NTe(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&&x8(n,``,x,b)};T();function E(e){return _Te(fTe(e))}function D(e){for(let t of e.split(`/`))if(o8.has(t))return!0;return!u&&x(e)}let O=null,ee=null;return{isExcluded(e,t){if(E(e)||v8(e)||_8(e)||c.isInside(e,t?.syncScope)||!t?.bypassFilters&&ITe(e,s)&&!h8(e,a))return!0;if(!t?.bypassFilters&&(u8(e)||h8(e,a)&&!x(e))){if(i!==void 0)return e!==i;if(W6(e))return!1;let t=he(e).slice(1).toLowerCase();return!il.has(t)}if(!t?.bypassFilters&&p8(e)||!t?.bypassFilters&&t?.syncScope!==void 0&&PTe(C(e,t.syncScope))&&!x(e,t.syncScope))return i!==void 0&&e!==i;if(l8(e,t?.showOk)||g8(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(W6(e)||ETe(e,o,e=>(b.get(e)??0)>0))return!1;let n=he(e).slice(1).toLowerCase();if(il.has(n)){let t=M(e),n=t===`.`?``:t;if((b.get(n)??0)>0)return!1}return!0},isDirExcluded(e,t){if(_8(e)||c.isInside(e,t?.syncScope))return!0;if(!t?.bypassFilters&&(DTe(e)||m8(e)||t?.syncScope!==void 0&&FTe(C(e,t.syncScope))||LTe(e,a)))return!1;if(l8(e,t?.showOk))return!0;if(i!==void 0)return!HTe(e,i);if(t?.bypassFilters)return t.respectOkignore===!0&&(w(e)||w(`${e}/`));for(let t of e.split(`/`))if(o8.has(t))return!0;return u?!1:x(e,t?.syncScope)||x(`${e}/`,t?.syncScope)},isPathIgnored(e,t){return E(e)||v8(e)||_8(e)?!0:u8(e)||h8(e,a)&&!x(e)||p8(e)?!1:l8(e)||g8(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);i8.warn({err:t instanceof Error?t:Error(String(t))},`content-filter rebuildDirCount walk failed — retaining previous counts`)}},setAttachmentFolderPath(e){o=c8(e)},refreshInPlaceSkillDirs(){if(e.rescanInPlaceSkillDirs)try{a=e.rescanInPlaceSkillDirs()}catch(e){i8.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)}}));aTe(),R6(),z6(),V6(),sTe(),kc();const cTe=new Set;function H6(e){cTe.add(e)}function lTe(){return Dc.getTracer(`open-knowledge-server`)}async function uTe(e,t,n){return lTe().startActiveSpan(e,t??{},async e=>{try{let t=await n(e);return e.isRecording(),t}catch(t){throw e.recordException(t),e.setStatus({code:bc.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}jX(`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()}),jX(`checkpoint-chain`);function U6(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function dTe(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}jX(`shadow-lock`),jX(`shadow-op-gate`),jX(`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})(),MY.fileSystem,MY.gitUpstream,MY.service,MY.generator,jX(`bridge-loss-detector`),jX(`checkpoint`);function W6(e){let t=he(e).toLowerCase();return bR.includes(t)}function fTe(e){let t=e.toLowerCase();for(let n of bR)if(t.endsWith(n))return e.slice(0,-n.length);return e}function pTe(e){return e===`__system__`}const mTe=new Set(Nre);function hTe(e){return mTe.has(e)}function gTe(e){return Pre(e)}function _Te(e){return pTe(e)||hTe(e)||gTe(e)}jX(`parse-pool`),Math.max(1,Math.min(4,oe()-1)),H6(()=>{}),jX(`bridge-watchdog`),H6(()=>{}),jX(`server-observers`),jX(`server-observers`),jX(`agent-sessions`);function G6(e){return{...e,windowsHide:!0}}function vTe(){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`}vTe(),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`);const K6={discovery:`open-knowledge-discovery`,project:`open-knowledge`,"write-skill":`open-knowledge-write-skill`};new Set(Object.values(K6));const yTe=Object.keys(K6),bTe={discovery:`user`,project:`project`,"write-skill":`user`},q6=yTe.filter(e=>bTe[e]===`user`);new Set(q6.map(e=>K6[e])),Re(x),jX(`agent-registry-apply`),jX(`local-op-security`),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),xR.cursor,xR.codex,xR[`claude-desktop`],H6(()=>{}),Object.freeze({source:`local`,skipStoreHooks:!0,context:Object.freeze({origin:`effect-capture`,paired:!1})});function J6(e){return e.replace(/\\/g,`/`)}jX(`external-change-attribution`),jX(`mermaid-validator`),jX(`rename-log`),jX(`history`),RegExp(`<(${VJ.map(e=>e.tagName).join(`|`)})\\b([^>]*)\\/>`,`y`);const xTe=String.raw`\[\[([^\n#[\]|]+)(?:#([^\n[\]|]+))?(?:\|([^\n[\]]+))?\]\]`,STe=String.raw`\((<[^>\n]+>|[^)\s\n]+)((?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)\)`,Y6=String.raw`([^\]\n]*)`,X6=String.raw`([^\]\n]*(?:\][^[\]\n]*)?)`,Z6=e=>RegExp(`(!?)${xTe}`,e),Q6=(e,t)=>RegExp(`(!?)\\[${e}\\]${STe}`,t);Z6(`y`),Z6(`g`),Q6(Y6,`y`),Q6(X6,`y`),Q6(Y6,`g`),Q6(X6,`g`);const CTe=String.raw`(!?)\[([^\]\n]*)\](?:\[([^\]\n]*)\])?`;new RegExp(CTe,`y`),jX(`backlinks`);const $6=`OpenKnowledge.app/Contents/Resources/cli/dist/assets/skills`;function e8(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`,$6,e)),(!o||t.home!==void 0)&&a.push(N(i,`Applications`,$6,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 t8(e){return mn.filter(t=>g(N(e,t.hostDir)))}function n8(e,t){return[...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({editor:e,root:t})),{editor:`agents`,root:t}]}n8(ln,vs),[...n8(un,vs)].sort((e,t)=>{let n=a4.indexOf(e.editor),r=a4.indexOf(t.editor);return(n===-1?a4.length:n)-(r===-1?a4.length:r)||e.editor.localeCompare(t.editor)}),jX(`installed-skills-marker`),jX(`skill-import`);function r8(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 i8=jX(`content-filter`);Re(o);const a8=[`.claude`,`.cursor`,`.codex`,`.agents`,`.opencode`,`.pi`],o8=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`,...a8,`Library`,`Applications`,`.Trash`]),wTe=new Set([`.git`,`node_modules`,`.ok`,`.open-knowledge`,`.openknowledge`,...a8]),s8=new Set([`worktrees`,`local`]);function c8(e){let t=eu(e);if(!tu(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 TTe(e){throw Error(`[AttachmentFolderShape] unhandled variant: ${JSON.stringify(e)}`)}function ETe(e,t,n){let r=he(e).slice(1).toLowerCase();if(!il.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 TTe(t)}function l8(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(wTe.has(i)&&!(t&&i===`.ok`&&!s8.has((n[e+1]??``).toLowerCase())))return!0}return!1}function u8(e){return e.startsWith(`${_s}/`)}function DTe(e){return e===`.ok`||e===`.ok/skills`||e.startsWith(`.ok/skills/`)}const d8=new Set([`.ok`,...a8]),OTe=new Set([...o8].filter(e=>!d8.has(e))),kTe=[`.git`,`node_modules`,`.ok/local`,`.ok/worktrees`].flatMap(e=>[e,`${e}/**`,`**/${e}`,`**/${e}/**`]);function ATe(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);return t.includes(`..`)?!1:t.some(e=>OTe.has(e))?!0:t.some((e,n)=>e.toLowerCase()===`.ok`&&s8.has((t[n+1]??``).toLowerCase()))}const jTe=[`.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`,...a8.flatMap(e=>[e,`${e}/skills/example/SKILL.md`])];function MTe(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(ATe(t))return!1;if(n.some(e=>d8.has(e)))return!0;try{let e=(0,c4.default)().add(t);return jTe.some(t=>e.ignores(t))}catch{return!0}}function NTe(e){let t=e.filter(e=>e.length>0&&!e.startsWith(`!`)&&!e.startsWith(`#`)&&!MTe(e));return[...new Set([...t,...kTe])]}function f8(e,t){for(let n=0;n<t;n++)if(o8.has(e[n])||e[n].toLowerCase()===`.ok`)return!0;return!1}function p8(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:!f8(t,n-3)}function m8(e){let t=e.split(`/`),n=t.length;return t[n-1]===`.ok`?!f8(t,n-1):n>=2&&t[n-1]===`templates`&&t[n-2]===`.ok`&&!f8(t,n-2)}function PTe(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`))||p8(e)?!0:n>=2&&t[n-1]===`frontmatter.yml`&&t[n-2]===`.ok`&&!f8(t,n-2)}function FTe(e){return e===`.ok`||e===`.ok/schemas`||m8(e)}function ITe(e,t){for(let n of t)if(e===n||e.startsWith(`${n}/`))return!0;return!1}function h8(e,t){if(t.size===0)return!1;for(let n of t)if(e.startsWith(`${n}/`))return!0;return!1}function LTe(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 RTe=new Set([`.ds_store`,`.localized`,`thumbs.db`,`desktop.ini`,`.directory`]);function g8(e){return RTe.has(e.slice(e.lastIndexOf(`/`)+1).toLowerCase())}const zTe=new Set([`.ssh`,`.aws`,`.gnupg`,`.kube`,`.docker`]);function _8(e){for(let t of e.split(`/`))if(zTe.has(t.toLowerCase()))return!0;return!1}const BTe=new Set([`credentials`,`.netrc`,`.npmrc`,`.pgpass`,`.git-credentials`]),VTe=[`.pem`,`.key`,`.p12`,`.pfx`,`.keystore`,`.jks`,`.ppk`];function v8(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(t===`.env`||t.startsWith(`.env.`)||BTe.has(t)||t.startsWith(`id_rsa`)||t.startsWith(`id_ed25519`)||t.startsWith(`id_ecdsa`)||t.startsWith(`id_dsa`))return!0;for(let e of VTe)if(t.endsWith(e))return!0;return!1}function HTe(e,t){return t===e||t.startsWith(`${e}/`)}function UTe(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=r8(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 y8=[`.gitignore`,`.okignore`];function WTe(e,t){let n=GTe(e);if(n===null)return[];let r=[];b8(N(n,`info`,`exclude`),t,r,`info/exclude`);let i=KTe(e);return i&&b8(i,t,r,`global excludesfile`),r}function GTe(e){let t=l(`git`,[`rev-parse`,`--git-common-dir`],G6({cwd:e,encoding:`utf-8`,timeout:5e3}));return t.status!==0||!t.stdout?null:be(e,t.stdout.trim())}function KTe(e){let t=l(`git`,[`config`,`--get`,`--type=path`,`core.excludesfile`],G6({cwd:e,encoding:`utf-8`,timeout:5e3}));if(t.status===0&&t.stdout){let e=t.stdout.trim();if(e)return e}return qTe()}function qTe(){let e=process.env.XDG_CONFIG_HOME?.trim(),t=e&&e.length>0?e:N(k(),`.config`);return N(t,`git`,`ignore`)}function b8(e,t,n,r){if(g(e))try{let r=S(e,`utf-8`);t.value+=r.length,n.push(...S8(r))}catch(t){i8.warn({path:e,err:t},`Failed to read ${r} at ${e}`)}}function JTe(e){let{projectDir:t,contentDir:n,onAfterRebuild:r,singleDocRelPath:i}=e,a=e.inPlaceSkillDirs??new Set,o=c8(e.attachmentFolderPath??`./`),s=e.skillRootPaths??new Set,c=UTe(t,n,i),l=J6(ye(t,n)),u=l.startsWith(`..`),d,f,p,m,h=0,_=0,v=0;function y(){let e=(0,c4.default)(),r=(0,c4.default)();e.add(`.git`);let i=[],a=0,o=0;for(let n of y8){let o=N(t,n);if(g(o))try{let t=S(o,`utf-8`);a+=t.length;let s=S8(t);i.push(...s),e.add(s),n===`.okignore`&&r.add(s)}catch(e){i8.warn({path:o,err:e},`Failed to read ${n} at ${o}`)}}if(l&&!u)for(let t of y8){let i=N(n,t);if(g(i))try{let n=S(i,`utf-8`);a+=n.length,o++;let s=S8(n).map(e=>C8(e,l));e.add(s),t===`.okignore`&&r.add(s)}catch(e){i8.warn({path:i,err:e},`Failed to read ${t} at ${i}`)}}let s={value:a};o+=w8(n,t,e,r,s),a=s.value;let c=WTe(t,s);a=s.value,c.length>0&&(i.push(...c),e.add(c));let y=NTe(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&&x8(n,``,x,b)};T();function E(e){return _Te(fTe(e))}function D(e){for(let t of e.split(`/`))if(o8.has(t))return!0;return!u&&x(e)}let O=null,ee=null;return{isExcluded(e,t){if(E(e)||v8(e)||_8(e)||c.isInside(e,t?.syncScope)||!t?.bypassFilters&&ITe(e,s)&&!h8(e,a))return!0;if(!t?.bypassFilters&&(u8(e)||h8(e,a)&&!x(e))){if(i!==void 0)return e!==i;if(W6(e))return!1;let t=he(e).slice(1).toLowerCase();return!il.has(t)}if(!t?.bypassFilters&&p8(e)||!t?.bypassFilters&&t?.syncScope!==void 0&&PTe(C(e,t.syncScope))&&!x(e,t.syncScope))return i!==void 0&&e!==i;if(l8(e,t?.showOk)||g8(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(W6(e)||ETe(e,o,e=>(b.get(e)??0)>0))return!1;let n=he(e).slice(1).toLowerCase();if(il.has(n)){let t=M(e),n=t===`.`?``:t;if((b.get(n)??0)>0)return!1}return!0},isDirExcluded(e,t){if(_8(e)||c.isInside(e,t?.syncScope))return!0;if(!t?.bypassFilters&&(DTe(e)||m8(e)||t?.syncScope!==void 0&&FTe(C(e,t.syncScope))||LTe(e,a)))return!1;if(l8(e,t?.showOk))return!0;if(i!==void 0)return!HTe(e,i);if(t?.bypassFilters)return t.respectOkignore===!0&&(w(e)||w(`${e}/`));for(let t of e.split(`/`))if(o8.has(t))return!0;return u?!1:x(e,t?.syncScope)||x(`${e}/`,t?.syncScope)},isPathIgnored(e,t){return E(e)||v8(e)||_8(e)?!0:u8(e)||h8(e,a)&&!x(e)||p8(e)?!1:l8(e)||g8(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);i8.warn({err:t instanceof Error?t:Error(String(t))},`content-filter rebuildDirCount walk failed — retaining previous counts`)}},setAttachmentFolderPath(e){o=c8(e)},refreshInPlaceSkillDirs(){if(e.rescanInPlaceSkillDirs)try{a=e.rescanInPlaceSkillDirs()}catch(e){i8.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){i8.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 uTe(`config.ignore.rebuild`,{attributes:{}},async e=>{try{let t=y();b.clear(),i===void 0&&await YTe(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}),i8.info({patternCount:t.patternCount,nestedFileCount:t.nestedFileCount,bytes:t.bytes,durationMs:a},`content-filter rebuild succeeded`),r)try{r()}catch(e){i8.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){i8.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 i8.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 YTe(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){i8.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(o8.has(i.name)||t(o)||t(`${o}/`))continue;r.push({dir:N(e,i.name),relPath:o})}else i.isFile()&&W6(i.name)&&!t(o)&&n.set(a,(n.get(a)??0)+1)}}}function x8(e,t,n,r){let i;try{i=w(e,{withFileTypes:!0})}catch(t){i8.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(o8.has(a.name)||n(i)||n(`${i}/`))continue;x8(N(e,a.name),i,n,r)}else a.isFile()&&W6(a.name)&&!n(i)&&r.set(t,(r.get(t)??0)+1)}}function S8(e){return e.split(`
817
- `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`))}function C8(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 w8(e,t,n,r,i){let a;try{a=w(e,{withFileTypes:!0})}catch(t){return i8.warn({dir:e,err:t},`Failed to read directory ${e}`),0}let o=0;for(let s of a){if(!s.isDirectory()||o8.has(s.name))continue;let a=N(e,s.name),c=K6(ye(t,a));if(!c.startsWith(`..`)&&!(n.ignores(c)||n.ignores(`${c}/`))){for(let e of y8){let t=N(a,e);if(g(t))try{let a=S(t,`utf-8`);i.value+=a.length;let s=S8(a).map(e=>C8(e,c));n.add(s),e===`.okignore`&&r.add(s),o++}catch(n){i8.warn({path:t,err:n},`Failed to read nested ${e} at ${t}`)}}o+=w8(a,t,n,r,i)}}return o}jX(`tag-index`),jX(`derived-document-index`),jX(`file-watcher`),new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}};const T8={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),...T8,propertyKey:F().min(1).optional(),propertyPath:z(V([F(),I().int().nonnegative()])).optional(),body:F(),queue:L().optional(),summary:F().optional()});const E8=Sne();uo(`action`,[B({action:W(`edit`),id:E8,body:F(),summary:F().optional()}),B({action:W(`resolve`),id:E8,summary:F().optional()}),B({action:W(`reopen`),id:E8,summary:F().optional()}),B({action:W(`replace`),id:E8,...T8,summary:F().optional()}),B({action:W(`queue`),id:E8,summary:F().optional()}),B({action:W(`unqueue`),id:E8,summary:F().optional()}),B({action:W(`dispatch-prepare`),id:E8,summary:F().optional()}),B({action:W(`dispatch-complete`),id:E8,summary:F().optional()}),B({action:W(`dispatch-prepare-batch`),ids:z(E8).min(1).max(200),summary:F().optional()}),B({action:W(`dispatch-complete-batch`),ids:z(E8).min(1).max(200),summary:F().optional()})]),jX(`embeddings`),jX(`embeddings`);function XTe(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return`${t.protocol}//${t.host.toLowerCase()}${n}`}catch{return e.trim().replace(/\/+$/,``)}}XTe(Wl),jX(`embeddings`),jX(`embeddings`);const ZTe=/^[A-Za-z0-9-]{8,64}$/;let D8=null;function QTe(e){return N(e??k(),`.ok`,`machine-id`)}function $Te(e){if(e===void 0&&D8!==null)return D8;let t=QTe(e),n=null;try{let e=S(t,`utf-8`).trim();ZTe.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){jX(`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&&(D8=n),n}jX(`process-lock`);function eEe(e,t){return be(e,`${t}.lock`)}function tEe(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 nEe(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=tEe(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}jX(`asset-references`),jX(`file-ops`),jX(`upload-streaming`);const O8="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 rEe=B({value:F(),truncatedFrom:I().optional(),hint:F().optional()}).describe(`Normalized change-note summary, when one was recorded.`),iEe=z(H(F(),R()));H(F(),R()).optional().describe("Preview-attach hint (`{ action, previewUrl?, message? }`) when relevant."),z(TJ).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.'),DJ.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.'),rEe.optional(),z(CJ).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 aEe=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 k8(e){return{text:aEe,...e}}function oEe(e){return`Machine-readable codes aligned 1:1 with \`warnings\` (\`warnings[i]\` is the display text for \`warningCodes[i]\`) — switch on these, never on the English. Absent when ${e} sent warning text it did not pair with codes, or paired one with a code this build does not recognise; \`warnings\` still carries the full text either way, so treat a missing field as unknown rather than as an all-clear.`}oEe(`the server`);function sEe(e){return`Always emitted, \`[]\` when there were none. \`warningCodes\` accompanies this list 1:1 whenever ${e} paired every warning it sent with a code this build recognises; otherwise \`warningCodes\` is absent and this list still carries the full text. \`content[0].text\` lists every warning either way. A \`warnings\` payload in a shape this build cannot read at all becomes one entry saying so, with \`warningCodes\` absent — \`[]\` never means "unreadable".`}sEe(`the server`),jX(`git-checkout`),jX(`git-worktree-status`),jX(`git-context`),jX(`managed-artifact-persistence`),jX(`timeline`),jX(`suggest-links`);function A8(e){try{return E.native(e)}catch{return e}}jX(`clone-flow`),Re(o),Z6.project,Object.fromEntries(Object.entries(ys).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(`
817
+ `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`))}function C8(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 w8(e,t,n,r,i){let a;try{a=w(e,{withFileTypes:!0})}catch(t){return i8.warn({dir:e,err:t},`Failed to read directory ${e}`),0}let o=0;for(let s of a){if(!s.isDirectory()||o8.has(s.name))continue;let a=N(e,s.name),c=J6(ye(t,a));if(!c.startsWith(`..`)&&!(n.ignores(c)||n.ignores(`${c}/`))){for(let e of y8){let t=N(a,e);if(g(t))try{let a=S(t,`utf-8`);i.value+=a.length;let s=S8(a).map(e=>C8(e,c));n.add(s),e===`.okignore`&&r.add(s),o++}catch(n){i8.warn({path:t,err:n},`Failed to read nested ${e} at ${t}`)}}o+=w8(a,t,n,r,i)}}return o}jX(`tag-index`),jX(`derived-document-index`),jX(`file-watcher`),new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}};const T8={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),...T8,propertyKey:F().min(1).optional(),propertyPath:z(V([F(),I().int().nonnegative()])).optional(),body:F(),queue:L().optional(),summary:F().optional()});const E8=Sne();uo(`action`,[B({action:W(`edit`),id:E8,body:F(),summary:F().optional()}),B({action:W(`resolve`),id:E8,summary:F().optional()}),B({action:W(`reopen`),id:E8,summary:F().optional()}),B({action:W(`replace`),id:E8,...T8,summary:F().optional()}),B({action:W(`queue`),id:E8,summary:F().optional()}),B({action:W(`unqueue`),id:E8,summary:F().optional()}),B({action:W(`dispatch-prepare`),id:E8,summary:F().optional()}),B({action:W(`dispatch-complete`),id:E8,summary:F().optional()}),B({action:W(`dispatch-prepare-batch`),ids:z(E8).min(1).max(200),summary:F().optional()}),B({action:W(`dispatch-complete-batch`),ids:z(E8).min(1).max(200),summary:F().optional()})]),jX(`embeddings`),jX(`embeddings`);function XTe(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return`${t.protocol}//${t.host.toLowerCase()}${n}`}catch{return e.trim().replace(/\/+$/,``)}}XTe(Wl),jX(`embeddings`),jX(`embeddings`);const ZTe=/^[A-Za-z0-9-]{8,64}$/;let D8=null;function QTe(e){return N(e??k(),`.ok`,`machine-id`)}function $Te(e){if(e===void 0&&D8!==null)return D8;let t=QTe(e),n=null;try{let e=S(t,`utf-8`).trim();ZTe.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){jX(`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&&(D8=n),n}jX(`process-lock`);function eEe(e,t){return be(e,`${t}.lock`)}function tEe(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 nEe(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=tEe(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}jX(`asset-references`),jX(`file-ops`),jX(`upload-streaming`);const O8="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 rEe=B({value:F(),truncatedFrom:I().optional(),hint:F().optional()}).describe(`Normalized change-note summary, when one was recorded.`),iEe=z(H(F(),R()));H(F(),R()).optional().describe("Preview-attach hint (`{ action, previewUrl?, message? }`) when relevant."),z(TJ).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.'),DJ.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.'),rEe.optional(),z(CJ).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 aEe=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 k8(e){return{text:aEe,...e}}function oEe(e){return`Machine-readable codes aligned 1:1 with \`warnings\` (\`warnings[i]\` is the display text for \`warningCodes[i]\`) — switch on these, never on the English. Absent when ${e} sent warning text it did not pair with codes, or paired one with a code this build does not recognise; \`warnings\` still carries the full text either way, so treat a missing field as unknown rather than as an all-clear.`}oEe(`the server`);function sEe(e){return`Always emitted, \`[]\` when there were none. \`warningCodes\` accompanies this list 1:1 whenever ${e} paired every warning it sent with a code this build recognises; otherwise \`warningCodes\` is absent and this list still carries the full text. \`content[0].text\` lists every warning either way. A \`warnings\` payload in a shape this build cannot read at all becomes one entry saying so, with \`warningCodes\` absent — \`[]\` never means "unreadable".`}sEe(`the server`),jX(`git-checkout`),jX(`git-worktree-status`),jX(`git-context`),jX(`managed-artifact-persistence`),jX(`timeline`),jX(`suggest-links`);function A8(e){try{return E.native(e)}catch{return e}}jX(`clone-flow`),Re(o),K6.project,Object.fromEntries(Object.entries(ys).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
818
  `),jX(`skills-leaderboard`),jX(`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(),jX(`link-preview.guarded-fetch`),jX(`link-preview.cache`),jX(`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(),jX(`managed-rename`),Object.assign(uCe,{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`}),jX(`search`),jX(`skill-install`),jX(`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(),jX(`conflict-storage`),new Ve,H6(()=>{}),[...bJ],[`[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(`
@@ -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&&IQ(e,u,{mode:o7(e)}),{kind:`removed`}}function uke(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}function dke(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=eEe(e,t),i;try{i=S(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??$Te()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??ce());if(!a||typeof a!=`object`||!dTe(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??U6)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}async function fke(e,t=void 0){let n=g9(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=nEe(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 pke(e,t={}){return{targets:hke(e,t.isAlive??U6)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function mke(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??fke,o=e.logger??void 0,s=pke(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 hke(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,nn.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 q8(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function gke(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=lu({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function _ke(e){let t=e??process.cwd(),n=[],r=[],i=[],a=[],o=BQ(`user`,t),s=FQ({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=ju({value:i.value,file:i.path,source:i.source,doc:i.doc});r.push(...o),n.push(e);let s=o.length>0?Nu(i.value):i.value;return t&&a.push(...mR({value:s,file:i.path,source:i.source,doc:i.doc})),s},l=be(t,`.ok`,`config.yml`),u=c(l,!0),d=c(BQ(`project-local`,t)),f=hR(s.value,u,d),p=hEe.safeParse(f);if(!p.success){let e=_9(l),t={code:`SCHEMA_INVALID`,issues:gke(p.error.issues,e)};throw Error(Eu(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=CR(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=CR(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 vke(e){let t=b9(e);if(t)return{kind:`doc`,...t};let n=x9(e);return n?{kind:`folder`,...n}:null}async function yke(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=jge(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=CR(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 bke=`# >>> open-knowledge cli >>>`,xke=`# <<< open-knowledge cli <<<`,Ske=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Cke(e){return N(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}function C9(e,t,n=[]){let r=g(N(e,Z6[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function wke(e,t){let n=e5.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),r=dn.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:vs}));return[...n,...r]}function w9(e,t,n,r){let i=lCe(e,wke(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 Tke(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 Eke(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?Tke(o,r):void 0,c=b7(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&Eke(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];d5(r)&&i.push(`reclaim-permissive`),m5(r)&&i.push(`pre-approval-exact`),x7(e)(r)&&i.push(`injection-functional`);let o=XEe(a,n);return i.length>0&&(o!==null&&ZEe(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}:GEe(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function Dke(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let r=Bo(e.pathId);if(r===null)return null;if(r.kind===`central-skill-store`)return n===void 0?null:C9(N(n,vs),`discovery`,w9(n,un,e.agent,`global`));let i=r.editor;switch(r.kind){case`editor-user-skill-root`:{let e=un[i];return e===null||n===void 0?null:t8(n).some(e=>e.editorId===i)?C9(N(n,e),`discovery`,w9(n,un,i,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=ln[i];return e===null?null:C9(N(t,e),`project`,w9(t,ln,i,`project`))}case`editor-user-config`:return T9(i,e.strictness,t,n);case`editor-project-config`:{let r=gn[i];return r===null?null:T9(i,e.strictness,t,n,N(t,r))}}}}[...Q6.map(e=>Z6[e])];function Oke(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=Oke(e),n=[];for(let e of Q6){let r=Z6[e];n.push({path:N(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of mn)n.push({path:N(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function kke(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 Ake=[{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 jke(e,t,n={},r=Ake){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=FDe(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 Mke(e,t,n={}){return{integrations:jke(e,t,n)}}function D9(e,t){let n=un[e];return n===null?null:N(t,...n.split(`/`),Z6.discovery,`SKILL.md`)}function Nke(e,t){let n=D9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!t8(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=e8(`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 Pke(e){return g(N(e,...`.agents/skills`.split(`/`),Z6.discovery))?!0:cn.some(t=>{let n=D9(t,e);return n!==null&&g(M(n))})}function Fke(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 Ike(e){return FQ({absPath:BQ(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function O9({home:e=k(),env:t=process.env}={}){let n=Ike(e),{override:r,preferenceList:i}=Sye(t),{locale:a,source:o}=hB({override:r,storedPreference:n,supportedLocales:al,preferenceList:i,autoDetectableLocales:sl});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 Lke(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(!Lke(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&&IQ(e,u,{mode:o7(e)}),{kind:`removed`}}function uke(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}function dke(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=eEe(e,t),i;try{i=S(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??$Te()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??ce());if(!a||typeof a!=`object`||!dTe(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??U6)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}async function fke(e,t=void 0){let n=g9(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=nEe(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 pke(e,t={}){return{targets:hke(e,t.isAlive??U6)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function mke(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??fke,o=e.logger??void 0,s=pke(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 hke(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,nn.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 q8(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function gke(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=lu({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function _ke(e){let t=e??process.cwd(),n=[],r=[],i=[],a=[],o=BQ(`user`,t),s=FQ({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=ju({value:i.value,file:i.path,source:i.source,doc:i.doc});r.push(...o),n.push(e);let s=o.length>0?Nu(i.value):i.value;return t&&a.push(...mR({value:s,file:i.path,source:i.source,doc:i.doc})),s},l=be(t,`.ok`,`config.yml`),u=c(l,!0),d=c(BQ(`project-local`,t)),f=hR(s.value,u,d),p=hEe.safeParse(f);if(!p.success){let e=_9(l),t={code:`SCHEMA_INVALID`,issues:gke(p.error.issues,e)};throw Error(Eu(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=CR(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=CR(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 vke(e){let t=b9(e);if(t)return{kind:`doc`,...t};let n=x9(e);return n?{kind:`folder`,...n}:null}async function yke(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=jge(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=CR(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 bke=`# >>> open-knowledge cli >>>`,xke=`# <<< open-knowledge cli <<<`,Ske=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Cke(e){return N(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}function C9(e,t,n=[]){let r=g(N(e,K6[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function wke(e,t){let n=e5.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),r=dn.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:vs}));return[...n,...r]}function w9(e,t,n,r){let i=lCe(e,wke(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 Tke(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 Eke(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?Tke(o,r):void 0,c=b7(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&Eke(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];d5(r)&&i.push(`reclaim-permissive`),m5(r)&&i.push(`pre-approval-exact`),x7(e)(r)&&i.push(`injection-functional`);let o=XEe(a,n);return i.length>0&&(o!==null&&ZEe(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}:GEe(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function Dke(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let r=Bo(e.pathId);if(r===null)return null;if(r.kind===`central-skill-store`)return n===void 0?null:C9(N(n,vs),`discovery`,w9(n,un,e.agent,`global`));let i=r.editor;switch(r.kind){case`editor-user-skill-root`:{let e=un[i];return e===null||n===void 0?null:t8(n).some(e=>e.editorId===i)?C9(N(n,e),`discovery`,w9(n,un,i,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=ln[i];return e===null?null:C9(N(t,e),`project`,w9(t,ln,i,`project`))}case`editor-user-config`:return T9(i,e.strictness,t,n);case`editor-project-config`:{let r=gn[i];return r===null?null:T9(i,e.strictness,t,n,N(t,r))}}}}[...q6.map(e=>K6[e])];function Oke(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=Oke(e),n=[];for(let e of q6){let r=K6[e];n.push({path:N(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of mn)n.push({path:N(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function kke(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 Ake=[{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 jke(e,t,n={},r=Ake){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=FDe(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 Mke(e,t,n={}){return{integrations:jke(e,t,n)}}function D9(e,t){let n=un[e];return n===null?null:N(t,...n.split(`/`),K6.discovery,`SKILL.md`)}function Nke(e,t){let n=D9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!t8(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=e8(`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 Pke(e){return g(N(e,...`.agents/skills`.split(`/`),K6.discovery))?!0:cn.some(t=>{let n=D9(t,e);return n!==null&&g(M(n))})}function Fke(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 Ike(e){return FQ({absPath:BQ(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function O9({home:e=k(),env:t=process.env}={}){let n=Ike(e),{override:r,preferenceList:i}=Sye(t),{locale:a,source:o}=hB({override:r,storedPreference:n,supportedLocales:al,preferenceList:i,autoDetectableLocales:sl});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 Lke(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(!Lke(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 Rke=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function F9(e){return/\.log\.\d+$/.test(e)}function zke(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||F9(e)}const Bke=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Vke(e){let t={contentDir:e.contentDir};for(let n of Bke)for(let r of P9(N(e.stagingDir,n)))zke(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):Rke.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 Hke(e){return N(e,...I9,z9)}function Uke(e){return N(e,...I9,B9)}function Wke(e){return N(e,...L9,V9)}function Gke(e){return N(e,...L9,H9)}function Kke(e){return N(e,...R9,U9)}function qke(e){return N(e,...R9,W9)}const G9=1e3;async function Jke(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 Yke(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 Xke(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 Qke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],G6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function $ke(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/`],G6({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 eAe(){return{nodeVersion:process.version,platform:le(),arch:ae()}}function tAe(){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,nn.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 nAe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return nAe(e.maxBytes)}function rAe(e){let t=J9(BQ(`project`,e)),n=J9(BQ(`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 iAe(e){return Ne(`sha256`).update(e).digest(`hex`)}function aAe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const oAe=[`"doc.name"`,`"docName"`];function sAe(e){let t=S(e,`utf-8`),n=0;for(let e of oAe){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 cAe=new Set([`.jsonl`]);function lAe(e){let t=e.lastIndexOf(`.`);return t!==-1&&cAe.has(e.slice(t))}const uAe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function dAe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&uAe.has(e.slice(t))}function fAe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!dAe(r))continue;let{redacted:i,patterns:a,lineCount:o}=CB(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 pAe(e){let t=be(e.contentDir),n=be(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Jke,a=r.fetchAgentEffects??Yke,o=r.fetchWatcherRecent??Xke,s=r.readShadowHead??Qke,c=r.readCheckpointRefs??$ke,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.72.0-beta.5`),d=r.readDesktopEnv??K9,f=r.readLanguage??O9,p=r.readRuntime??eAe,h=r.isOtlpPushEnabled??tAe,_=y(N(A(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),Z9(Hke(n),N(_,`telemetry`,z9)),Z9(Uke(n),N(_,`telemetry`,B9)),Z9(Wke(n),N(_,`logs`,V9)),Z9(Gke(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(_,tR,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(Kke(n),N(_,`state`,U9)),Z9(qke(n),N(_,`state`,W9)),Z9(N(b,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),Z9(N(b,Pu),N(_,`state`,Pu)),Z9(N(b,Fu),N(_,`state`,Fu));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 Qke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],G6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function $ke(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/`],G6({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 eAe(){return{nodeVersion:process.version,platform:le(),arch:ae()}}function tAe(){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,nn.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 nAe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return nAe(e.maxBytes)}function rAe(e){let t=J9(BQ(`project`,e)),n=J9(BQ(`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 iAe(e){return Ne(`sha256`).update(e).digest(`hex`)}function aAe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const oAe=[`"doc.name"`,`"docName"`];function sAe(e){let t=S(e,`utf-8`),n=0;for(let e of oAe){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 cAe=new Set([`.jsonl`]);function lAe(e){let t=e.lastIndexOf(`.`);return t!==-1&&cAe.has(e.slice(t))}const uAe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function dAe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&uAe.has(e.slice(t))}function fAe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!dAe(r))continue;let{redacted:i,patterns:a,lineCount:o}=CB(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 pAe(e){let t=be(e.contentDir),n=be(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Jke,a=r.fetchAgentEffects??Yke,o=r.fetchWatcherRecent??Xke,s=r.readShadowHead??Qke,c=r.readCheckpointRefs??$ke,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.72.0-beta.7`),d=r.readDesktopEnv??K9,f=r.readLanguage??O9,p=r.readRuntime??eAe,h=r.isOtlpPushEnabled??tAe,_=y(N(A(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),Z9(Hke(n),N(_,`telemetry`,z9)),Z9(Uke(n),N(_,`telemetry`,B9)),Z9(Wke(n),N(_,`logs`,V9)),Z9(Gke(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(_,tR,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(Kke(n),N(_,`state`,U9)),Z9(qke(n),N(_,`state`,W9)),Z9(N(b,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),Z9(N(b,Pu),N(_,`state`,Pu)),Z9(N(b,Fu),N(_,`state`,Fu));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&&Vke({stagingDir:_,contentDir:t}),e.note&&re(N(_,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=fAe(_));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=rAe(n),ue=Q9(_),A=[],j=0,de=0;for(let e of ue){let t=$9(_,e),n=te(e).size,r=lAe(t)?aAe(e):0;A.push({path:t,bytes:n,lines:r}),j+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(de+=sAe(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:iAe(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 mAe(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 jSe.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 hAe(e,t){let n=N(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,nn.parse)(S(n,`utf-8`)),r=q8(t)?t.content:void 0,i=q8(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 gAe(e,t,n,r,i){let a=E7(t,e.logger),o=await pAe({contentDir:hAe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...EOe(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 mAe({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 _Ae(e){let{projectDir:t}=e,n=e.readDesktopEnv??K9,r=e.readLanguage??O9,i=()=>SOe(e.diagnosticReportsDir??N(k(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return gAe(e,t,n,r,i());let{zipPath:a,summary:o}=await jOe({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{e5 as ALL_EDITOR_IDS,t5 as EDITOR_LABELS,j5 as EDITOR_TARGETS,HEe as HOSTS_WITH_USER_SKILL_DIR,cOe as LAUNCH_CONFIG_NAME,bke as PATH_SHIM_BEGIN,Ske as PATH_SHIM_BLOCK_RE,xke as PATH_SHIM_END,BDe as addOkPathsToGitExclude,R5 as assertProjectPathSafe,p5 as buildManagedServerEntry,uke as buildMcpConfigDeclineEvent,dke as buildMcpConfigMigrateEvent,b7 as classifyExistingMcpEntry,_Ae as collectReportBundle,Dke as createCliProbeResolver,sn as createTokenStore,COe as defaultBugReportZipPath,We as detectGh,qe as detectGhAccounts,fOe as detectInstalledEditors,S5 as droppedManagedKeys,lDe as editorConfigPathDisplay,cDe as editorEntryLocator,$Oe as ensurePiBridge,Q5 as formatTrackedRemediation,UDe as getExcludedOkPaths,X5 as getInstalledSkillProjectionPaths,VEe as getNativeTomlMcpEditor,Y5 as getOkArtifactPaths,d5 as isEntryUpToDate,m5 as isOwnManagedEntry,_ke as loadConfig,yee as makeLazyProbeTokenStore,T7 as okBugReportsDir,b9 as parseGitHubBlobUrl,vke as parseGitHubShareUrl,x9 as parseGitHubTreeUrl,y9 as parseGitUrl,Cke as pathInstallMarkerPath,wDe as previewContent,pOe as probeOwnManagedEditorMcpEntry,ZOe as probePiBridgeState,Z5 as probeTrackedOkPaths,v7 as readExistingMcpEntry,HDe as readSharingMode,CB as redactContent,VDe as removeOkPathsFromGitExclude,oke as removeOwnMcpEntry,IDe as removeProjectSkill,kke as removeUserGlobalSkillBundle,Fke as removeUserSkill,ADe as resolveProjectRoot,mke as runStop,h9 as truncatePriorEntry,E9 as userGlobalSkillBundleTargets,Pke as userSkillPresentAnywhere,yke as validateLocalFolderForShare,_7 as writeEditorMcpConfig,Mke as writeProjectAiIntegrations,W5 as writeProjectSkill,dOe as writeUserMcpConfigs,Nke as writeUserSkill};
1536
1536
  //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Cu as r,Nl as i,Ou as a,Qs as o,Td as s,bd as c,ds as l,gd as u,hd as d,jt as f,kl as p,ps as m,vd as h,wd as g,wu as _,xd as v,xl as y,yu as b}from"./md-manager-BGnqyqi1-Bo-Rq5FL.mjs";import{$a as x,B as S,Bi as ee,Br as te,Ct as ne,F as re,I as ie,Oo as ae,Pn as oe,Po as se,So as C,Ui as ce,Vn as le,Yt as ue,_o as de,go as fe,ho as w,io as pe,kr as me,m as he,no as ge,rt as _e,ta as ve,tt as ye,vo as be,vr as xe,wr as Se,yo as Ce,zi as we}from"./dist-CIcphNQy.mjs";import{i as T,n as E,o as D,r as Te,s as O,t as k}from"./colors-r_owlCuY.mjs";import{t as A}from"./is-object-BGze3w87.mjs";import{t as Ee}from"./constants-DEplBBeL.mjs";import{t as De}from"./preview-BJFciD0a.mjs";import{createRequire as Oe}from"node:module";import{execFileSync as ke}from"node:child_process";import Ae,{basename as je,dirname as j,isAbsolute as Me,join as M,posix as Ne,relative as N,resolve as P,sep as F,win32 as Pe}from"node:path";import I from"node:process";import{fileURLToPath as Fe}from"node:url";import{cpSync as Ie,existsSync as L,lstatSync as Le,mkdirSync as Re,readFileSync as R,readdirSync as ze,readlinkSync as Be,realpathSync as Ve,rmSync as He,statSync as Ue,writeFileSync as We}from"node:fs";import{homedir as z}from"node:os";import*as Ge from"node:readline";import{inspect as Ke,stripVTControlCharacters as qe,styleText as B}from"node:util";import{AsyncLocalStorage as Je,AsyncResource as Ye}from"node:async_hooks";var Xe=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),Ze=n((e=>{let{InvalidArgumentError:t}=Xe();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),Qe=n((e=>{let{humanReadableArgName:t}=Ze();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
1
+ import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Cu as r,Nl as i,Ou as a,Qs as o,Td as s,bd as c,ds as l,gd as u,hd as d,jt as f,kl as p,ps as m,vd as h,wd as g,wu as _,xd as v,xl as y,yu as b}from"./md-manager-BGnqyqi1-Bo-Rq5FL.mjs";import{$a as x,B as S,Bi as ee,Br as te,Ct as ne,F as re,I as ie,Oo as ae,Pn as oe,Po as se,So as C,Ui as ce,Vn as le,Yt as ue,_o as de,go as fe,ho as w,io as pe,kr as me,m as he,no as ge,rt as _e,ta as ve,tt as ye,vo as be,vr as xe,wr as Se,yo as Ce,zi as we}from"./dist-CVs8BCwZ.mjs";import{i as T,n as E,o as D,r as Te,s as O,t as k}from"./colors-r_owlCuY.mjs";import{t as A}from"./is-object-BGze3w87.mjs";import{t as Ee}from"./constants-CWW8AXUs.mjs";import{t as De}from"./preview-Ba7L_87z.mjs";import{createRequire as Oe}from"node:module";import{execFileSync as ke}from"node:child_process";import Ae,{basename as je,dirname as j,isAbsolute as Me,join as M,posix as Ne,relative as N,resolve as P,sep as F,win32 as Pe}from"node:path";import I from"node:process";import{fileURLToPath as Fe}from"node:url";import{cpSync as Ie,existsSync as L,lstatSync as Le,mkdirSync as Re,readFileSync as R,readdirSync as ze,readlinkSync as Be,realpathSync as Ve,rmSync as He,statSync as Ue,writeFileSync as We}from"node:fs";import{homedir as z}from"node:os";import*as Ge from"node:readline";import{inspect as Ke,stripVTControlCharacters as qe,styleText as B}from"node:util";import{AsyncLocalStorage as Je,AsyncResource as Ye}from"node:async_hooks";var Xe=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),Ze=n((e=>{let{InvalidArgumentError:t}=Xe();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),Qe=n((e=>{let{humanReadableArgName:t}=Ze();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
2
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
3
3
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
4
4
  `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),$e=n((e=>{let{InvalidArgumentError:t}=Xe();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -689,5 +689,5 @@ export default function okBridge(pi: {
689
689
  `));let g=`${s?``:``}${m}`;return g!==o&&C(e,g,{mode:ba(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const mo=e=>e!==`project`,ho=e=>e!==`user`;async function go(){let e=await ka({message:`Where should the MCP server be configured?
690
690
  `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function _o(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??go)():`both`}async function vo(e){return Pa({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function yo(e){if(e.sharing!==void 0)return e.sharing;let t=Wi(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??vo)(t):t}var bo=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function xo(e){if(e===void 0||e===!0)return new Set(ye);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(ne.filter(e=>t.includes(e)))}function So(e,t,n){let r=P(n,e),i;try{i=Ue(r)}catch(e){let t=e.code;throw t===`ENOENT`?new bo(`--content-dir path does not exist: ${r}`):new bo(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new bo(`--content-dir must be a directory: ${r}`);let a=Co(t),o=Co(r),s=N(a,o);if(s.startsWith(`..`)||Me(s))throw new bo(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Co(e){try{return Ve(e)}catch{return e}}const wo=`open-knowledge-ui`;function To(e,t,n){try{let r=e.detectPath?.(t,n)??j(e.configPath(t,n));return L(r)}catch{return!1}}function Eo(e,t,n){try{let r=P(j(e.configPath(t,n))),i=P(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+F)}catch{return!1}}function Do(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!L(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||Eo(e,t,r);if(!i&&c&&!To(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{ra(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return ko(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||Re(j(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{ae(`${o}.lock`,()=>{let t=qa(o).writePath;if(s||Re(j(t),{recursive:!0}),e.format===`toml`){let r=lo(Br(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=po(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=co(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Oo={pi:za};function ko(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Oo[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{Re(j(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{ae(`${t}.lock`,()=>{let e=null;try{e=R(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}C(t,c,e===null?void 0:{mode:ba(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function Ao(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!L(n)))return{editorId:e.id,label:e.label,path:n}}async function jo(e){let t=Li(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>Do(t,``,n,e.home))}function Mo(e,t,n,r){let i=Po(e,t,n,r);return i.kind===`present`?i.entry:null}function No(e,t,n,r){let i=so(e,t,r);if(!A(i))return{kind:`no-entry`};let a=i[n];return A(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Po(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!L(i))return{kind:`absent`};try{if(Ue(i).size>to)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:ga(e)}}let a;try{a=R(i,`utf-8`)}catch(e){return{kind:`decline`,reason:ga(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Ra(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Br().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return No(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,kr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:No(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=Xa(a);return s?Za(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:No(fe(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Fo(e={}){let t=P(e.cwd??process.cwd()),n=Ha(t,{homeDir:e.home}),r=n.projectRoot;if(me(r,e.home??z()))throw new S(r);let a=!L(M(r,`.ok`)),o=n.gitRootPromoted?N(r,t):void 0,s=e.contentDir===void 0?n.defaultContentDir:So(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&a&&s===`.`&&process.stderr.write(`${O(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${o}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${o} in .ok/config.yml.\n`);let c={mode:e.devMcp?`dev`:`published`},l=await le(r),u;try{u=xe(r,{contentDir:s})}catch(t){let i=$.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let d=u.created.includes(Ee),f=!1;if(l.didInit)try{f=pe(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{we(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let p=await _o({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??Vo(r,e.home),h=e.editors??m,g=Li(m),_=Li(h),v=e.mcp===!1||p===null,y=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),b=g.filter(t=>To(t,r,e.home)),x=[],te=[],re=new Set;for(let t of y){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}x.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(mo(p)&&g.includes(t)&&t.scope===`global`&&x.push(Do(t,r,c,e.home)),ho(p)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Do(t,r,c,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&re.add(n)}}let ie=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||ie.has(n)||(ie.add(n),te.push(ma(t,r,{home:e.home})))}let ae=pa(r,_.map(e=>e.id));ae&&te.push(ae);let se=te.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(se.length>0){let t=e.home??z();ee({source:i,skills:[he.project],agents:se,scope:r},{home:t,enabled:ve(t).enabled})}let C=!v&&p!==null&&ho(p)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ce=v?[]:b.map(e=>Ao(e,r)).filter(e=>e!==void 0).filter(e=>!re.has(e.path)),ue=e.installUserSkill??Se,de=e.home??z(),fe=xo(e.skills),w=!1,_e=!1,ye=!1,be=!1,Ce=!1;for(let t of ne){if(!fe.has(t))continue;await ge(de,he[t],!0).catch(()=>{}),w=!0;let n=await ue({home:e.home,bundleId:t,force:!0});n===`installed`?_e=!0:n===`failed`?ye=!0:n===`no-hosts`?Ce=!0:be=!0}let T=ye?`failed`:_e?`installed`:w&&be?`skip-current`:w&&Ce?`no-hosts`:`declined`,E=_e?oe(de).map(e=>e.editorId):[],D=v?`skipped-flag`:`skipped-missing`,Te=x.find(e=>e.editorId===`claude`)??x[0]??{action:D,configPath:$.claude.configPath(r,e.home)},k=await Io({projectRoot:r,desiredMode:await yo({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:a,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:x,projectSkills:te,legacyProjectConfigs:ce,skillInstall:T,skillHosts:E,didGitInit:l.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:o,contentDir:d?s:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Te.action,mcpPath:Te.configPath,mcpError:`error`in Te?Te.error:void 0,projectScopeUnsupportedLabels:C,sharing:k}}async function Io(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=Wi(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=Bi(t);if(n===`local-only`){let e=Hi(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:Lo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Ui(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Lo(t,o,`remove`)}function Lo(e,t,n){let r=Wi(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function Ro(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function zo(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let s=M(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(k(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(k(`Content already present at ${s}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(k(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(k(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(k(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?N(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`open-knowledge`?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${D(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${D(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${Te(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Ro(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(k(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?N(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${D(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${D(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${Te(`FAILED`)}: ${r.error}`)}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${N(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(k(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>X[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${D(`installed for ${r}`)}`),n.push(` ${E(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${E(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${D(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${E(`skipped for this run (--no-skills)`)}`),n.push(` ${E(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${E(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${E(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${E(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${O(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${O(` ok repair-skills`)}`)}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(O(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(O(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(De(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...Wo(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${D(`✓`)} ${k(`Next steps:`)}`),n.push(` 1. Open your editor (${T(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${T(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${T(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
691
691
  `)}function Bo(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function Vo(e,t){let n=[];for(let r of Hr)r!==`claude-desktop`&&To($[r],e,t)&&n.push(r);return n}function Ho(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Ke(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Uo(){return new lt(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new dt(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new dt(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new dt(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?Ho():null;try{let r;try{r=await Fo({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof bo||e instanceof S){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof re||e instanceof ie){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof _e){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
692
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-CSqioEBS.mjs`),{resolveContentDir:s}=await import(`./dist-DJSvIyoE.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-Bkrg2o4g.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Bo(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${zo(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Wo(e,t){let n=[];switch(e.kind){case`applied`:return n.push(k(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${D(`local-only`)} — appended ${e.appended.length} path(s) to ${k(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${D(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${D(`local-only`)} — already excluded; nothing to do.`):n.push(` ${D(`local-only`)}`):e.action===`removed`?n.push(` ${D(`shared`)} — removed OK paths from ${k(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${D(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(O(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
692
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-Cxge_ign.mjs`),{resolveContentDir:s}=await import(`./dist-CQFFmkEE.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-DU00Ukqf.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Bo(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${zo(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Wo(e,t){let n=[];switch(e.kind){case`applied`:return n.push(k(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${D(`local-only`)} — appended ${e.appended.length} path(s) to ${k(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${D(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${D(`local-only`)} — already excluded; nothing to do.`):n.push(` ${D(`local-only`)}`):e.action===`removed`?n.push(` ${D(`shared`)} — removed OK paths from ${k(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${D(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(O(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
693
693
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${T(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(O(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${T(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${T(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(O(`Sharing mode unavailable: ${e.reason}.`));return n}}export{gi as $,xa as A,Xi as B,Ha as C,ka as D,Pa as E,ia as F,Wi as G,Vi as H,ha as I,X as J,Ui as K,sa as L,ga as M,oa as N,ba as O,ra as P,_i as Q,ma as R,qa as S,La as T,Bi as U,Gi as V,Ki as W,Ur as X,$ as Y,Z,Fo as _,bt as _t,Bo as a,Q as at,jo as b,dt as bt,zo as c,oi as ct,To as d,Qn as dt,vi as et,Mo as f,Vn as ft,yo as g,U as gt,So as h,Kt as ht,Io as i,bi as it,_a as j,ya as k,Wo as l,Vr as lt,_o as m,qt as mt,wo as n,$r as nt,Po as o,xi as ot,xo as p,Xt as pt,Hr as q,Oo as r,ni as rt,Vo as s,Mi as st,bo as t,yi as tt,Uo as u,Br as ut,ao as v,lt as vt,za as w,Eo as x,Do as y,st as yt,Hi as z};
@@ -0,0 +1 @@
1
+ import"./dist-CVs8BCwZ.mjs";import{_ as e}from"./init-CH3pTYUX.mjs";export{e as runInit};
@@ -1 +1 @@
1
- import{So as e,go as t,yo as n}from"./dist-CIcphNQy.mjs";import{A as r,M as i,O as a}from"./init-CpWmzBSx.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-BH9TBBEA.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:i(e)}}let g=[],_=n(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=t(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=r(h,[`configurations`,y]);return x?(e(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
1
+ import{So as e,go as t,yo as n}from"./dist-CVs8BCwZ.mjs";import{A as r,M as i,O as a}from"./init-CH3pTYUX.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-RVB0vSi1.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:i(e)}}let g=[],_=n(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=t(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=r(h,[`configurations`,y]);return x?(e(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
@@ -1 +1 @@
1
- import{Gc as e,Qa as t,Qc as n,Uc as r,ll as i,ns as a,yu as o}from"./md-manager-BGnqyqi1-Bo-Rq5FL.mjs";import{Eo as s,b as c,wo as l}from"./dist-CIcphNQy.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-DEplBBeL.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=o();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(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,g.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 u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=n({file:t.path,source:t.source,doc:t.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function b(n){let o=n??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,o),_=l({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,n=!1)=>{let a=v(e);if(a.diagnostic!==void 0&&p.push(a.diagnostic),a.value===null)return{};let o=r({value:a.value,file:a.path,source:a.source,doc:a.doc});p.push(...o),u.push(e);let s=o.length>0?i(a.value):a.value;return n&&h.push(...t({value:s,file:a.path,source:a.source,doc:a.doc})),s},x=f(o,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,o)),w=a(_.value,S,C),T=c.safeParse(w);if(!T.success){let t=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,t)};throw Error(e(n))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
1
+ import{Gc as e,Qa as t,Qc as n,Uc as r,ll as i,ns as a,yu as o}from"./md-manager-BGnqyqi1-Bo-Rq5FL.mjs";import{Eo as s,b as c,wo as l}from"./dist-CVs8BCwZ.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-CWW8AXUs.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=o();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(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,g.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 u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=n({file:t.path,source:t.source,doc:t.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function b(n){let o=n??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,o),_=l({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,n=!1)=>{let a=v(e);if(a.diagnostic!==void 0&&p.push(a.diagnostic),a.value===null)return{};let o=r({value:a.value,file:a.path,source:a.source,doc:a.doc});p.push(...o),u.push(e);let s=o.length>0?i(a.value):a.value;return n&&h.push(...t({value:s,file:a.path,source:a.source,doc:a.doc})),s},x=f(o,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,o)),w=a(_.value,S,C),T=c.safeParse(w);if(!T.success){let t=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,t)};throw Error(e(n))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-CB4bM4Vr.mjs";export{e as loadConfig};
@@ -1 +1 @@
1
- import{$a as e}from"./dist-CIcphNQy.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}let s=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,c=process.platform===`win32`?[`/c`,`start`,``,a]:[a];t(s,c,e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
1
+ import{$a as e}from"./dist-CVs8BCwZ.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}let s=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,c=process.platform===`win32`?[`/c`,`start`,``,a]:[a];t(s,c,e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
@@ -1,2 +1,2 @@
1
- import{gn as e}from"./dist-CIcphNQy.mjs";import"./constants-DEplBBeL.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);a.push(``);let c=t(i,`.ok`,`config.yml`);return r(c)?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
1
+ import{gn as e}from"./dist-CVs8BCwZ.mjs";import"./constants-CWW8AXUs.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);a.push(``);let c=t(i,`.ok`,`config.yml`);return r(c)?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
2
2
  `)}export{c as n,l as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-Ba7L_87z.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{a as n,i as r}from"./DocumentContext-DX4_PUWv.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{t as c}from"./button-Cym3gapE.js";import{i as l,n as u,t as d}from"./tooltip-BnyyQDRs.js";import{a as f,c as p,i as m,o as h,s as g,t as _}from"./dialog-DgIQr9zS.js";import{n as v}from"./dist-CJhtNlOm2.js";import{t as y}from"./dist-Cr4-nBVI.js";import{m as b}from"./Mermaid-C8EPNkJP.js";import{n as x}from"./upload-DGQJhdiQ.js";import{i as S}from"./prop-types-Cu1KjM7N.js";import{t as C}from"./spinner-Bp2_BYkl.js";import{t as w}from"./undo-2-BQ-ulCEU.js";import{l as T}from"./doc-hash-BP0Io59r.js";import{s as E}from"./navigation-targets-DBLYH48Z.js";import{a as D,i as O,n as k,o as A,t as ee}from"./agent-diff-store-DkuxiJNK.js";import{t as j}from"./timeline-diff-store-B803XeuZ.js";import{n as M}from"./use-activity-panel-CXRjvVsk.js";var N=s(),P=e(i(),1),F=t();function te(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function I(e){let t=(0,N.c)(86),{burst:n,docName:r,editCount:i,sessionAlive:s,inFlight:v,onOpenDiff:y,onRestore:b}=e,{_:x}=o(),[S,T]=(0,P.useState)(ne),E,O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{let e=setInterval(()=>T(Date.now()),3e4);return()=>clearInterval(e)},O=[],t[0]=E,t[1]=O):(E=t[0],O=t[1]),(0,P.useEffect)(E,O);let[k,A]=(0,P.useState)(!1),ee=D(),j=n.stackIndex+1,M=ee?.docName===r&&ee.keptCount===j,I=i-j,re=!s||v||I<=0,ie;t[2]!==I||t[3]!==b?(ie=function(){A(!1),b(I)},t[2]=I,t[3]=b,t[4]=ie):ie=t[4];let ae=ie,L;t[5]!==n||t[6]!==y?(L=()=>y(n),t[5]=n,t[6]=y,t[7]=L):L=t[7];let R;t[8]!==x||t[9]!==j||t[10]!==r?(R=x({id:`Z79bnE`,values:{burstNumber:j,docName:r}}),t[8]=x,t[9]=j,t[10]=r,t[11]=R):R=t[11];let oe=M?`bg-muted`:`hover:bg-muted/40`,se;t[12]===oe?se=t[13]:(se=[`flex min-w-0 flex-1 items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground transition-colors`,oe],t[12]=oe,t[13]=se);let ce=se.join(` `),z;t[14]!==n.ts||t[15]!==S?(z=te(n.ts,S),t[14]=n.ts,t[15]=S,t[16]=z):z=t[16];let B;t[17]===z?B=t[18]:(B=(0,F.jsx)(`span`,{className:`font-mono`,children:z}),t[17]=z,t[18]=B);let V;t[19]===n.additions?V=t[20]:(V=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[19]=n.additions,t[20]=V);let H;t[21]===n.deletions?H=t[22]:(H=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[21]=n.deletions,t[22]=H);let U;t[23]!==V||t[24]!==H?(U=(0,F.jsxs)(`span`,{className:`ml-auto font-mono`,children:[V,` `,H]}),t[23]=V,t[24]=H,t[25]=U):U=t[25];let W;t[26]!==M||t[27]!==B||t[28]!==U||t[29]!==L||t[30]!==R||t[31]!==ce?(W=(0,F.jsxs)(`button`,{type:`button`,onClick:L,"aria-pressed":M,"aria-label":R,"data-testid":`activity-panel-burst-open`,className:ce,children:[B,U]}),t[26]=M,t[27]=B,t[28]=U,t[29]=L,t[30]=R,t[31]=ce,t[32]=W):W=t[32];let le;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-3 w-px shrink-0 bg-border`}),t[33]=le):le=t[33];let G;t[34]!==x||t[35]!==j||t[36]!==r?(G=x({id:`Zhe80e`,values:{burstNumber:j,docName:r}}),t[34]=x,t[35]=j,t[36]=r,t[37]=G):G=t[37];let ue;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>A(!0),t[38]=ue):ue=t[38];let K;t[39]===v?K=t[40]:(K=v?(0,F.jsx)(C,{className:`size-3`,"aria-hidden":`true`}):(0,F.jsx)(w,{className:`size-3`,"aria-hidden":`true`}),t[39]=v,t[40]=K);let q;t[41]!==re||t[42]!==G||t[43]!==K?(q=(0,F.jsx)(l,{asChild:!0,children:(0,F.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`activity-panel-burst-restore`,"aria-label":G,disabled:re,onClick:ue,children:K})}),t[41]=re,t[42]=G,t[43]=K,t[44]=q):q=t[44];let J;t[45]!==x||t[46]!==I||t[47]!==s?(J=x(s?I>0?{id:`SOPwPh`}:{id:`62bOuM`}:{id:`NzFvyK`}),t[45]=x,t[46]=I,t[47]=s,t[48]=J):J=t[48];let Y;t[49]===J?Y=t[50]:(Y=(0,F.jsx)(u,{side:`left`,children:J}),t[49]=J,t[50]=Y);let X;t[51]!==q||t[52]!==Y?(X=(0,F.jsxs)(d,{children:[q,Y]}),t[51]=q,t[52]=Y,t[53]=X):X=t[53];let Z;t[54]!==W||t[55]!==X?(Z=(0,F.jsxs)(`div`,{className:`flex items-center border-t border-border/50 pr-3`,children:[W,le,X]}),t[54]=W,t[55]=X,t[56]=Z):Z=t[56];let Q;t[57]===v?Q=t[58]:(Q=e=>{!e&&!v?A(!1):e&&A(!0)},t[57]=v,t[58]=Q);let de;t[59]===x?de=t[60]:(de=x({id:`a4FRQv`}),t[59]=x,t[60]=de);let fe;t[61]===de?fe=t[62]:(fe=(0,F.jsx)(p,{children:de}),t[61]=de,t[62]=fe);let pe;t[63]===I?pe=t[64]:(pe=(0,F.jsx)(f,{children:(0,F.jsx)(a,{id:`LKIPzv`,values:{laterEdits:I}})}),t[63]=I,t[64]=pe);let $;t[65]!==fe||t[66]!==pe?($=(0,F.jsxs)(g,{children:[fe,pe]}),t[65]=fe,t[66]=pe,t[67]=$):$=t[67];let me;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,F.jsx)(c,{variant:`outline`,"data-testid":`activity-panel-burst-restore-cancel`,onClick:()=>A(!1),children:(0,F.jsx)(a,{id:`dEgA5A`})}),t[68]=me):me=t[68];let he;t[69]===v?he=t[70]:(he=v?(0,F.jsx)(C,{className:`mr-2 size-4`,"aria-hidden":`true`}):null,t[69]=v,t[70]=he);let ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,F.jsx)(a,{id:`9uI_rE`}),t[71]=ge):ge=t[71];let _e;t[72]!==ae||t[73]!==v||t[74]!==he?(_e=(0,F.jsxs)(h,{children:[me,(0,F.jsxs)(c,{variant:`destructive`,"data-testid":`activity-panel-burst-restore-confirm`,disabled:v,onClick:ae,children:[he,ge]})]}),t[72]=ae,t[73]=v,t[74]=he,t[75]=_e):_e=t[75];let ve;t[76]!==$||t[77]!==_e?(ve=(0,F.jsxs)(m,{children:[$,_e]}),t[76]=$,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==k||t[80]!==Q||t[81]!==ve?(ye=(0,F.jsx)(_,{open:k,onOpenChange:Q,children:ve}),t[79]=k,t[80]=Q,t[81]=ve,t[82]=ye):ye=t[82];let be;return t[83]!==Z||t[84]!==ye?(be=(0,F.jsxs)(F.Fragment,{children:[Z,ye]}),t[83]=Z,t[84]=ye,t[85]=be):be=t[85],be}function ne(){return Date.now()}function re(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return y._({id:`nYeBmY`,values:{hours:r}})}function ie(e){let t=(0,N.c)(56),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoDrop:c,onSetVersion:l}=e,{_:u}=o(),{docName:d}=n,[f,p]=(0,P.useState)(!1),[m,h]=(0,P.useState)(ae),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(e)},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,P.useEffect)(g,_);let v=n.bursts.length,y;t[2]!==n.docName||t[3]!==c||t[4]!==r||t[5]!==f?(y=e=>{e<=0||!r||f||(p(!0),Promise.resolve(c(n.docName,e)).finally(()=>{p(!1),ee()}))},t[2]=n.docName,t[3]=c,t[4]=r,t[5]=f,t[6]=y):y=t[6];let b=y;if(n.bursts.length===0)return null;let x;t[7]!==n.docName||t[8]!==s?(x=()=>s(n.docName),t[7]=n.docName,t[8]=s,t[9]=x):x=t[9];let S;t[10]!==u||t[11]!==d?(S=u({id:`QcpeeE`,values:{docName:d}}),t[10]=u,t[11]=d,t[12]=S):S=t[12];let C;t[13]!==n.docName||t[14]!==x||t[15]!==S?(C=(0,F.jsx)(`button`,{type:`button`,onClick:x,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":S,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[13]=n.docName,t[14]=x,t[15]=S,t[16]=C):C=t[16];let w;t[17]===n.additionsTotal?w=t[18]:(w=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[17]=n.additionsTotal,t[18]=w);let T;t[19]===n.deletionsTotal?T=t[20]:(T=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[19]=n.deletionsTotal,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[w,` `,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==n.lastTs||t[25]!==m?(D=re(n.lastTs,m),t[24]=n.lastTs,t[25]=m,t[26]=D):D=t[26];let O;t[27]===D?O=t[28]:(O=(0,F.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k;t[29]===i?k=t[30]:(k=i?(0,F.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,F.jsx)(a,{id:`6q0rnH`})}):null,t[29]=i,t[30]=k);let A;t[31]!==O||t[32]!==k||t[33]!==C||t[34]!==E?(A=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[C,E,O,k]}),t[31]=O,t[32]=k,t[33]=C,t[34]=E,t[35]=A):A=t[35];let j;if(t[36]!==b||t[37]!==v||t[38]!==n.bursts||t[39]!==n.docName||t[40]!==l||t[41]!==r||t[42]!==f){let e;t[44]!==b||t[45]!==v||t[46]!==n.docName||t[47]!==l||t[48]!==r||t[49]!==f?(e=e=>(0,F.jsx)(I,{burst:e,docName:n.docName,editCount:v,sessionAlive:r,inFlight:f,onOpenDiff:e=>l(e.stackIndex+1),onRestore:b},`${n.docName}:${e.stackIndex}`),t[44]=b,t[45]=v,t[46]=n.docName,t[47]=l,t[48]=r,t[49]=f,t[50]=e):e=t[50],j=n.bursts.map(e),t[36]=b,t[37]=v,t[38]=n.bursts,t[39]=n.docName,t[40]=l,t[41]=r,t[42]=f,t[43]=j}else j=t[43];let M;t[51]===j?M=t[52]:(M=(0,F.jsx)(`div`,{children:j}),t[51]=j,t[52]=M);let te;return t[53]!==A||t[54]!==M?(te=(0,F.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[A,M]}),t[53]=A,t[54]=M,t[55]=te):te=t[55],te}function ae(){return Date.now()}async function L(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function R(e){typeof window>`u`||(window.location.hash=T(e))}function oe(){let e=(0,N.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(C,{className:`mr-2 size-4`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,F.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,F.jsx)(`span`,{className:`text-sm`,children:(0,F.jsx)(a,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function se(e){let t=(0,N.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,F.jsx)(x,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:(0,F.jsx)(a,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,F.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(a,{id:`6gRgw8`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,F.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:l}),t[5]=r,t[6]=u);let d;return t[7]!==s||t[8]!==u?(d=(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,u]}),t[7]=s,t[8]=u,t[9]=d):d=t[9],d}function ce(){let e=(0,N.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,F.jsx)(`p`,{className:`text-sm italic`,children:(0,F.jsx)(a,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function z(e){let t=(0,N.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=o(),s;t[0]===i?s=t[1]:(s=i({id:`kYL1lH`}),t[0]=i,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=r?(0,F.jsx)(B,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[c,l]}),t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,F.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,F.jsx)(a,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==s||t[10]!==u?(f=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":s,children:[u,d]}),t[9]=s,t[10]=u,t[11]=f):f=t[11],f}function B(e){let t=(0,N.c)(9),{onClick:n}=e,{_:r}=o(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(b,{}),t[2]=s):s=t[2];let f;t[3]!==n||t[4]!==i?(f=(0,F.jsx)(l,{asChild:!0,children:(0,F.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:s})}),t[3]=n,t[4]=i,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,F.jsx)(u,{side:`bottom`,children:(0,F.jsx)(a,{id:`ogAuyr`})}),t[6]=p):p=t[6];let m;return t[7]===f?m=t[8]:(m=(0,F.jsxs)(d,{children:[f,p]}),t[7]=f,t[8]=m),m}function V(e){let t=(0,N.c)(9),{lastTs:n}=e,[r]=(0,P.useState)(H),i;t[0]!==n||t[1]!==r?(i=n?U(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let o=i,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(`span`,{className:`font-medium`,children:(0,F.jsx)(a,{id:`LCUy_N`})}),t[3]=s):s=t[3];let c;t[4]===o?c=t[5]:(c=o?(0,F.jsxs)(`span`,{children:[` · `,o]}):null,t[4]=o,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,F.jsx)(a,{id:`GK-IRZ`})}),t[6]=l):l=t[6];let u;return t[7]===c?u=t[8]:(u=(0,F.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[s,c,l]}),t[7]=c,t[8]=u),u}function H(){return Date.now()}function U(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return y._({id:`nYeBmY`,values:{hours:n}})}function W(e){let t=(0,N.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,F.jsx)(A,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function le(e){let t=(0,N.c)(25),{data:n,status:r,error:i,reload:s,onExit:c,onNavigate:l,onUndoDrop:u,onSetVersion:d,showBackButton:f}=e,{_:p}=o(),m=n?.files?.[0]?.lastTs??null,h=n?.files?.length??0,g;t[0]===p?g=t[1]:(g=p({id:`kYL1lH`}),t[0]=p,t[1]=g);let _;t[2]!==c||t[3]!==f?(_=f?(0,F.jsx)(B,{onClick:c}):null,t[2]=c,t[3]=f,t[4]=_):_=t[4];let v;t[5]!==n||t[6]!==h||t[7]!==m?(v=n?.agent?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(W,{agent:n.agent}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,F.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,F.jsx)(a,{id:`F6pfE9`}):m===null?(0,F.jsx)(a,{id:`PMyJ9C`}):(0,F.jsx)(a,{id:`237hSL`}),n.files.length>0?(0,F.jsxs)(F.Fragment,{children:[` · `,(0,F.jsx)(a,{id:`u3BOHd`,values:{fileCount:h}})]}):null]})]})]}):(0,F.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})})}),t[5]=n,t[6]=h,t[7]=m,t[8]=v):v=t[8];let y;t[9]!==_||t[10]!==v?(y=(0,F.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]!==n||t[13]!==i||t[14]!==m||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==r?(b=(0,F.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,F.jsx)(oe,{}):r===`error`&&i?(0,F.jsx)(se,{error:i,onRetry:s}):n===null?(0,F.jsx)(ce,{}):(0,F.jsxs)(F.Fragment,{children:[!n.sessionAlive&&m!==null?(0,F.jsx)(V,{lastTs:m}):null,n.files.length===0?(0,F.jsx)(ce,{}):n.files.map(e=>(0,F.jsx)(ie,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:l,onUndoDrop:u,onSetVersion:t=>d(e,t)},e.docName))]})}),t[12]=n,t[13]=i,t[14]=m,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=r,t[20]=b):b=t[20];let x;return t[21]!==g||t[22]!==y||t[23]!==b?(x=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":g,children:[y,b]}),t[21]=g,t[22]=y,t[23]=b,t[24]=x):x=t[24],x}function G(e){let t=(0,N.c)(30),i;t[0]===e?i=t[1]:(i=e===void 0?{}:e,t[0]=e,t[1]=i);let{showBackButton:a}=i,s=a===void 0?!0:a,{_:c}=o(),{docPanelAgentId:l,closeActivityPanel:u}=r(),{openTargetTransition:d}=n(),{pageMeta:f}=S(),{data:p,status:m,error:h,reload:g}=M(l),_,y;if(t[2]!==p||t[3]!==l?(_=()=>{if(!(!p||l===null))for(let e of p.files)O(l,e.docName,e.bursts.length)},y=[p,l],t[2]=p,t[3]=l,t[4]=_,t[5]=y):(_=t[4],y=t[5]),(0,P.useEffect)(_,y),l===null){let e;return t[6]!==u||t[7]!==s?(e=(0,F.jsx)(z,{onExit:u,showBackButton:s}),t[6]=u,t[7]=s,t[8]=e):e=t[8],e}let b;t[9]!==d||t[10]!==f?(b=e=>{d(E({kind:`doc`,target:e,docName:e},f),{disposition:`permanent`,consumeActiveNewTab:!0}),R(e)},t[9]=d,t[10]=f,t[11]=b):b=t[11];let x=b,C;t[12]!==p||t[13]!==l?(C=(e,t)=>{if(!p?.agent||l===null)return;j();let n=e.bursts.length;k({agentId:l,agentName:p.agent.displayName,agentColor:p.agent.color,agentIcon:p.agent.icon,docName:e.docName,keptCount:Math.max(0,Math.min(t,n)),maxVersions:n})},t[12]=p,t[13]=l,t[14]=C):C=t[14];let w=C,T;t[15]!==c||t[16]!==p||t[17]!==l||t[18]!==g?(T=async(e,t)=>{if(!(t<=0))try{await L({connectionId:l,docName:e,scope:`count`,count:t,agentName:p?.agent?.displayName}),v.success(c(t===1?{id:`-dNlfM`,values:{docName:e}}:{id:`ApeA0n`,values:{dropCount:t,docName:e}})),g()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);v.error(c({id:`EqrC_R`,values:{message:n}})),g()}},t[15]=c,t[16]=p,t[17]=l,t[18]=g,t[19]=T):T=t[19];let D=T,A;return t[20]!==u||t[21]!==p||t[22]!==h||t[23]!==x||t[24]!==w||t[25]!==D||t[26]!==g||t[27]!==s||t[28]!==m?(A=(0,F.jsx)(le,{data:p,status:m,error:h,reload:g,onExit:u,onNavigate:x,onUndoDrop:D,onSetVersion:w,showBackButton:s}),t[20]=u,t[21]=p,t[22]=h,t[23]=x,t[24]=w,t[25]=D,t[26]=g,t[27]=s,t[28]=m,t[29]=A):A=t[29],A}export{G as ActivityModeContent};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{a as n,i as r}from"./DocumentContext-CaB8wd1_.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{t as c}from"./button-Cym3gapE.js";import{i as l,n as u,t as d}from"./tooltip-BnyyQDRs.js";import{a as f,c as p,i as m,o as h,s as g,t as _}from"./dialog-DgIQr9zS.js";import{n as v}from"./dist-CJhtNlOm2.js";import{t as y}from"./dist-Cr4-nBVI.js";import{m as b}from"./Mermaid-C8EPNkJP.js";import{n as x}from"./upload-DGQJhdiQ.js";import{i as S}from"./prop-types-Cu1KjM7N.js";import{t as C}from"./spinner-Bp2_BYkl.js";import{t as w}from"./undo-2-BQ-ulCEU.js";import{l as T}from"./doc-hash-BP0Io59r.js";import{s as E}from"./navigation-targets-DBLYH48Z.js";import{a as D,i as O,n as k,o as A,t as ee}from"./agent-diff-store-DkuxiJNK.js";import{t as j}from"./timeline-diff-store-B803XeuZ.js";import{n as M}from"./use-activity-panel-pDb7IY6s.js";var N=s(),P=e(i(),1),F=t();function te(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function I(e){let t=(0,N.c)(86),{burst:n,docName:r,editCount:i,sessionAlive:s,inFlight:v,onOpenDiff:y,onRestore:b}=e,{_:x}=o(),[S,T]=(0,P.useState)(ne),E,O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{let e=setInterval(()=>T(Date.now()),3e4);return()=>clearInterval(e)},O=[],t[0]=E,t[1]=O):(E=t[0],O=t[1]),(0,P.useEffect)(E,O);let[k,A]=(0,P.useState)(!1),ee=D(),j=n.stackIndex+1,M=ee?.docName===r&&ee.keptCount===j,I=i-j,re=!s||v||I<=0,ie;t[2]!==I||t[3]!==b?(ie=function(){A(!1),b(I)},t[2]=I,t[3]=b,t[4]=ie):ie=t[4];let ae=ie,L;t[5]!==n||t[6]!==y?(L=()=>y(n),t[5]=n,t[6]=y,t[7]=L):L=t[7];let R;t[8]!==x||t[9]!==j||t[10]!==r?(R=x({id:`Z79bnE`,values:{burstNumber:j,docName:r}}),t[8]=x,t[9]=j,t[10]=r,t[11]=R):R=t[11];let oe=M?`bg-muted`:`hover:bg-muted/40`,se;t[12]===oe?se=t[13]:(se=[`flex min-w-0 flex-1 items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground transition-colors`,oe],t[12]=oe,t[13]=se);let ce=se.join(` `),z;t[14]!==n.ts||t[15]!==S?(z=te(n.ts,S),t[14]=n.ts,t[15]=S,t[16]=z):z=t[16];let B;t[17]===z?B=t[18]:(B=(0,F.jsx)(`span`,{className:`font-mono`,children:z}),t[17]=z,t[18]=B);let V;t[19]===n.additions?V=t[20]:(V=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[19]=n.additions,t[20]=V);let H;t[21]===n.deletions?H=t[22]:(H=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[21]=n.deletions,t[22]=H);let U;t[23]!==V||t[24]!==H?(U=(0,F.jsxs)(`span`,{className:`ml-auto font-mono`,children:[V,` `,H]}),t[23]=V,t[24]=H,t[25]=U):U=t[25];let W;t[26]!==M||t[27]!==B||t[28]!==U||t[29]!==L||t[30]!==R||t[31]!==ce?(W=(0,F.jsxs)(`button`,{type:`button`,onClick:L,"aria-pressed":M,"aria-label":R,"data-testid":`activity-panel-burst-open`,className:ce,children:[B,U]}),t[26]=M,t[27]=B,t[28]=U,t[29]=L,t[30]=R,t[31]=ce,t[32]=W):W=t[32];let le;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-3 w-px shrink-0 bg-border`}),t[33]=le):le=t[33];let G;t[34]!==x||t[35]!==j||t[36]!==r?(G=x({id:`Zhe80e`,values:{burstNumber:j,docName:r}}),t[34]=x,t[35]=j,t[36]=r,t[37]=G):G=t[37];let ue;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>A(!0),t[38]=ue):ue=t[38];let K;t[39]===v?K=t[40]:(K=v?(0,F.jsx)(C,{className:`size-3`,"aria-hidden":`true`}):(0,F.jsx)(w,{className:`size-3`,"aria-hidden":`true`}),t[39]=v,t[40]=K);let q;t[41]!==re||t[42]!==G||t[43]!==K?(q=(0,F.jsx)(l,{asChild:!0,children:(0,F.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`activity-panel-burst-restore`,"aria-label":G,disabled:re,onClick:ue,children:K})}),t[41]=re,t[42]=G,t[43]=K,t[44]=q):q=t[44];let J;t[45]!==x||t[46]!==I||t[47]!==s?(J=x(s?I>0?{id:`SOPwPh`}:{id:`62bOuM`}:{id:`NzFvyK`}),t[45]=x,t[46]=I,t[47]=s,t[48]=J):J=t[48];let Y;t[49]===J?Y=t[50]:(Y=(0,F.jsx)(u,{side:`left`,children:J}),t[49]=J,t[50]=Y);let X;t[51]!==q||t[52]!==Y?(X=(0,F.jsxs)(d,{children:[q,Y]}),t[51]=q,t[52]=Y,t[53]=X):X=t[53];let Z;t[54]!==W||t[55]!==X?(Z=(0,F.jsxs)(`div`,{className:`flex items-center border-t border-border/50 pr-3`,children:[W,le,X]}),t[54]=W,t[55]=X,t[56]=Z):Z=t[56];let Q;t[57]===v?Q=t[58]:(Q=e=>{!e&&!v?A(!1):e&&A(!0)},t[57]=v,t[58]=Q);let de;t[59]===x?de=t[60]:(de=x({id:`a4FRQv`}),t[59]=x,t[60]=de);let fe;t[61]===de?fe=t[62]:(fe=(0,F.jsx)(p,{children:de}),t[61]=de,t[62]=fe);let pe;t[63]===I?pe=t[64]:(pe=(0,F.jsx)(f,{children:(0,F.jsx)(a,{id:`LKIPzv`,values:{laterEdits:I}})}),t[63]=I,t[64]=pe);let $;t[65]!==fe||t[66]!==pe?($=(0,F.jsxs)(g,{children:[fe,pe]}),t[65]=fe,t[66]=pe,t[67]=$):$=t[67];let me;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,F.jsx)(c,{variant:`outline`,"data-testid":`activity-panel-burst-restore-cancel`,onClick:()=>A(!1),children:(0,F.jsx)(a,{id:`dEgA5A`})}),t[68]=me):me=t[68];let he;t[69]===v?he=t[70]:(he=v?(0,F.jsx)(C,{className:`mr-2 size-4`,"aria-hidden":`true`}):null,t[69]=v,t[70]=he);let ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,F.jsx)(a,{id:`9uI_rE`}),t[71]=ge):ge=t[71];let _e;t[72]!==ae||t[73]!==v||t[74]!==he?(_e=(0,F.jsxs)(h,{children:[me,(0,F.jsxs)(c,{variant:`destructive`,"data-testid":`activity-panel-burst-restore-confirm`,disabled:v,onClick:ae,children:[he,ge]})]}),t[72]=ae,t[73]=v,t[74]=he,t[75]=_e):_e=t[75];let ve;t[76]!==$||t[77]!==_e?(ve=(0,F.jsxs)(m,{children:[$,_e]}),t[76]=$,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==k||t[80]!==Q||t[81]!==ve?(ye=(0,F.jsx)(_,{open:k,onOpenChange:Q,children:ve}),t[79]=k,t[80]=Q,t[81]=ve,t[82]=ye):ye=t[82];let be;return t[83]!==Z||t[84]!==ye?(be=(0,F.jsxs)(F.Fragment,{children:[Z,ye]}),t[83]=Z,t[84]=ye,t[85]=be):be=t[85],be}function ne(){return Date.now()}function re(e,t){let n=Math.max(0,t-e);if(n<6e4){let e=Math.round(n/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(n<36e5){let e=Math.round(n/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}let r=Math.round(n/36e5);return y._({id:`nYeBmY`,values:{hours:r}})}function ie(e){let t=(0,N.c)(56),{file:n,sessionAlive:r,isWriting:i,onNavigate:s,onUndoDrop:c,onSetVersion:l}=e,{_:u}=o(),{docName:d}=n,[f,p]=(0,P.useState)(!1),[m,h]=(0,P.useState)(ae),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(e)},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,P.useEffect)(g,_);let v=n.bursts.length,y;t[2]!==n.docName||t[3]!==c||t[4]!==r||t[5]!==f?(y=e=>{e<=0||!r||f||(p(!0),Promise.resolve(c(n.docName,e)).finally(()=>{p(!1),ee()}))},t[2]=n.docName,t[3]=c,t[4]=r,t[5]=f,t[6]=y):y=t[6];let b=y;if(n.bursts.length===0)return null;let x;t[7]!==n.docName||t[8]!==s?(x=()=>s(n.docName),t[7]=n.docName,t[8]=s,t[9]=x):x=t[9];let S;t[10]!==u||t[11]!==d?(S=u({id:`QcpeeE`,values:{docName:d}}),t[10]=u,t[11]=d,t[12]=S):S=t[12];let C;t[13]!==n.docName||t[14]!==x||t[15]!==S?(C=(0,F.jsx)(`button`,{type:`button`,onClick:x,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":S,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[13]=n.docName,t[14]=x,t[15]=S,t[16]=C):C=t[16];let w;t[17]===n.additionsTotal?w=t[18]:(w=(0,F.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[17]=n.additionsTotal,t[18]=w);let T;t[19]===n.deletionsTotal?T=t[20]:(T=(0,F.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[19]=n.deletionsTotal,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[w,` `,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==n.lastTs||t[25]!==m?(D=re(n.lastTs,m),t[24]=n.lastTs,t[25]=m,t[26]=D):D=t[26];let O;t[27]===D?O=t[28]:(O=(0,F.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:D}),t[27]=D,t[28]=O);let k;t[29]===i?k=t[30]:(k=i?(0,F.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:(0,F.jsx)(a,{id:`6q0rnH`})}):null,t[29]=i,t[30]=k);let A;t[31]!==O||t[32]!==k||t[33]!==C||t[34]!==E?(A=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[C,E,O,k]}),t[31]=O,t[32]=k,t[33]=C,t[34]=E,t[35]=A):A=t[35];let j;if(t[36]!==b||t[37]!==v||t[38]!==n.bursts||t[39]!==n.docName||t[40]!==l||t[41]!==r||t[42]!==f){let e;t[44]!==b||t[45]!==v||t[46]!==n.docName||t[47]!==l||t[48]!==r||t[49]!==f?(e=e=>(0,F.jsx)(I,{burst:e,docName:n.docName,editCount:v,sessionAlive:r,inFlight:f,onOpenDiff:e=>l(e.stackIndex+1),onRestore:b},`${n.docName}:${e.stackIndex}`),t[44]=b,t[45]=v,t[46]=n.docName,t[47]=l,t[48]=r,t[49]=f,t[50]=e):e=t[50],j=n.bursts.map(e),t[36]=b,t[37]=v,t[38]=n.bursts,t[39]=n.docName,t[40]=l,t[41]=r,t[42]=f,t[43]=j}else j=t[43];let M;t[51]===j?M=t[52]:(M=(0,F.jsx)(`div`,{children:j}),t[51]=j,t[52]=M);let te;return t[53]!==A||t[54]!==M?(te=(0,F.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[A,M]}),t[53]=A,t[54]=M,t[55]=te):te=t[55],te}function ae(){return Date.now()}async function L(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function R(e){typeof window>`u`||(window.location.hash=T(e))}function oe(){let e=(0,N.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(C,{className:`mr-2 size-4`,"aria-hidden":`true`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,F.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[t,(0,F.jsx)(`span`,{className:`text-sm`,children:(0,F.jsx)(a,{id:`ONPvOb`})})]}),e[1]=n):n=e[1],n}function se(e){let t=(0,N.c)(10),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,F.jsx)(x,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:(0,F.jsx)(a,{id:`DhLHEb`})}),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=(0,F.jsxs)(`div`,{className:`space-y-1`,children:[o,(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(a,{id:`6gRgw8`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,F.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:l}),t[5]=r,t[6]=u);let d;return t[7]!==s||t[8]!==u?(d=(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,u]}),t[7]=s,t[8]=u,t[9]=d):d=t[9],d}function ce(){let e=(0,N.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,F.jsx)(`p`,{className:`text-sm italic`,children:(0,F.jsx)(a,{id:`iuTKci`})})}),e[0]=t):t=e[0],t}function z(e){let t=(0,N.c)(12),{onExit:n,showBackButton:r}=e,{_:i}=o(),s;t[0]===i?s=t[1]:(s=i({id:`kYL1lH`}),t[0]=i,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=r?(0,F.jsx)(B,{onClick:n}):null,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[c,l]}),t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,F.jsx)(`p`,{className:`text-center text-sm italic`,children:(0,F.jsx)(a,{id:`D_WKe_`})})}),t[8]=d):d=t[8];let f;return t[9]!==s||t[10]!==u?(f=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":s,children:[u,d]}),t[9]=s,t[10]=u,t[11]=f):f=t[11],f}function B(e){let t=(0,N.c)(9),{onClick:n}=e,{_:r}=o(),i;t[0]===r?i=t[1]:(i=r({id:`ogAuyr`}),t[0]=r,t[1]=i);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(b,{}),t[2]=s):s=t[2];let f;t[3]!==n||t[4]!==i?(f=(0,F.jsx)(l,{asChild:!0,children:(0,F.jsx)(c,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":i,"data-testid":`docpanel-exit-agent-mode`,children:s})}),t[3]=n,t[4]=i,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,F.jsx)(u,{side:`bottom`,children:(0,F.jsx)(a,{id:`ogAuyr`})}),t[6]=p):p=t[6];let m;return t[7]===f?m=t[8]:(m=(0,F.jsxs)(d,{children:[f,p]}),t[7]=f,t[8]=m),m}function V(e){let t=(0,N.c)(9),{lastTs:n}=e,[r]=(0,P.useState)(H),i;t[0]!==n||t[1]!==r?(i=n?U(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let o=i,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(`span`,{className:`font-medium`,children:(0,F.jsx)(a,{id:`LCUy_N`})}),t[3]=s):s=t[3];let c;t[4]===o?c=t[5]:(c=o?(0,F.jsxs)(`span`,{children:[` · `,o]}):null,t[4]=o,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,F.jsx)(`div`,{className:`mt-1 opacity-80`,children:(0,F.jsx)(a,{id:`GK-IRZ`})}),t[6]=l):l=t[6];let u;return t[7]===c?u=t[8]:(u=(0,F.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[s,c,l]}),t[7]=c,t[8]=u),u}function H(){return Date.now()}function U(e){let t=Math.max(0,e);if(t<6e4){let e=Math.round(t/1e3);return y._({id:`pbwTg6`,values:{seconds:e}})}if(t<36e5){let e=Math.round(t/6e4);return y._({id:`_rP3HI`,values:{minutes:e}})}let n=Math.round(t/36e5);return y._({id:`nYeBmY`,values:{hours:n}})}function W(e){let t=(0,N.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,F.jsx)(A,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function le(e){let t=(0,N.c)(25),{data:n,status:r,error:i,reload:s,onExit:c,onNavigate:l,onUndoDrop:u,onSetVersion:d,showBackButton:f}=e,{_:p}=o(),m=n?.files?.[0]?.lastTs??null,h=n?.files?.length??0,g;t[0]===p?g=t[1]:(g=p({id:`kYL1lH`}),t[0]=p,t[1]=g);let _;t[2]!==c||t[3]!==f?(_=f?(0,F.jsx)(B,{onClick:c}):null,t[2]=c,t[3]=f,t[4]=_):_=t[4];let v;t[5]!==n||t[6]!==h||t[7]!==m?(v=n?.agent?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(W,{agent:n.agent}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,F.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?(0,F.jsx)(a,{id:`F6pfE9`}):m===null?(0,F.jsx)(a,{id:`PMyJ9C`}):(0,F.jsx)(a,{id:`237hSL`}),n.files.length>0?(0,F.jsxs)(F.Fragment,{children:[` · `,(0,F.jsx)(a,{id:`u3BOHd`,values:{fileCount:h}})]}):null]})]})]}):(0,F.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,F.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:(0,F.jsx)(a,{id:`kYL1lH`})})}),t[5]=n,t[6]=h,t[7]=m,t[8]=v):v=t[8];let y;t[9]!==_||t[10]!==v?(y=(0,F.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]!==n||t[13]!==i||t[14]!==m||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==r?(b=(0,F.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,F.jsx)(oe,{}):r===`error`&&i?(0,F.jsx)(se,{error:i,onRetry:s}):n===null?(0,F.jsx)(ce,{}):(0,F.jsxs)(F.Fragment,{children:[!n.sessionAlive&&m!==null?(0,F.jsx)(V,{lastTs:m}):null,n.files.length===0?(0,F.jsx)(ce,{}):n.files.map(e=>(0,F.jsx)(ie,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:l,onUndoDrop:u,onSetVersion:t=>d(e,t)},e.docName))]})}),t[12]=n,t[13]=i,t[14]=m,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=r,t[20]=b):b=t[20];let x;return t[21]!==g||t[22]!==y||t[23]!==b?(x=(0,F.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":g,children:[y,b]}),t[21]=g,t[22]=y,t[23]=b,t[24]=x):x=t[24],x}function G(e){let t=(0,N.c)(30),i;t[0]===e?i=t[1]:(i=e===void 0?{}:e,t[0]=e,t[1]=i);let{showBackButton:a}=i,s=a===void 0?!0:a,{_:c}=o(),{docPanelAgentId:l,closeActivityPanel:u}=r(),{openTargetTransition:d}=n(),{pageMeta:f}=S(),{data:p,status:m,error:h,reload:g}=M(l),_,y;if(t[2]!==p||t[3]!==l?(_=()=>{if(!(!p||l===null))for(let e of p.files)O(l,e.docName,e.bursts.length)},y=[p,l],t[2]=p,t[3]=l,t[4]=_,t[5]=y):(_=t[4],y=t[5]),(0,P.useEffect)(_,y),l===null){let e;return t[6]!==u||t[7]!==s?(e=(0,F.jsx)(z,{onExit:u,showBackButton:s}),t[6]=u,t[7]=s,t[8]=e):e=t[8],e}let b;t[9]!==d||t[10]!==f?(b=e=>{d(E({kind:`doc`,target:e,docName:e},f),{disposition:`permanent`,consumeActiveNewTab:!0}),R(e)},t[9]=d,t[10]=f,t[11]=b):b=t[11];let x=b,C;t[12]!==p||t[13]!==l?(C=(e,t)=>{if(!p?.agent||l===null)return;j();let n=e.bursts.length;k({agentId:l,agentName:p.agent.displayName,agentColor:p.agent.color,agentIcon:p.agent.icon,docName:e.docName,keptCount:Math.max(0,Math.min(t,n)),maxVersions:n})},t[12]=p,t[13]=l,t[14]=C):C=t[14];let w=C,T;t[15]!==c||t[16]!==p||t[17]!==l||t[18]!==g?(T=async(e,t)=>{if(!(t<=0))try{await L({connectionId:l,docName:e,scope:`count`,count:t,agentName:p?.agent?.displayName}),v.success(c(t===1?{id:`-dNlfM`,values:{docName:e}}:{id:`ApeA0n`,values:{dropCount:t,docName:e}})),g()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);v.error(c({id:`EqrC_R`,values:{message:n}})),g()}},t[15]=c,t[16]=p,t[17]=l,t[18]=g,t[19]=T):T=t[19];let D=T,A;return t[20]!==u||t[21]!==p||t[22]!==h||t[23]!==x||t[24]!==w||t[25]!==D||t[26]!==g||t[27]!==s||t[28]!==m?(A=(0,F.jsx)(le,{data:p,status:m,error:h,reload:g,onExit:u,onNavigate:x,onUndoDrop:D,onSetVersion:w,showBackButton:s}),t[20]=u,t[21]=p,t[22]=h,t[23]=x,t[24]=w,t[25]=D,t[26]=g,t[27]=s,t[28]=m,t[29]=A):A=t[29],A}export{G as ActivityModeContent};