@inkeep/open-knowledge 0.0.0-dev-20260421174000 → 0.0.0-dev-20260421192027

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 (51) hide show
  1. package/dist/{banner-BxlLKtcG.mjs → banner-sRCRfb7A.mjs} +2 -2
  2. package/dist/{chokidar-7l0uFWrj.mjs → chokidar-BlUsUYh_.mjs} +1 -1
  3. package/dist/chunk-tuRmWmEN.mjs +1 -0
  4. package/dist/cli.mjs +73 -73
  5. package/dist/colors-BNRrOlZZ.mjs +1 -0
  6. package/dist/{colors-eCHTjaBL.mjs → colors-CoV_NlQL.mjs} +1 -1
  7. package/dist/constants-BLW6shM6.mjs +2 -0
  8. package/dist/git-handle-BIUIUt1r.mjs +1 -0
  9. package/dist/{git-handle-CQtGq94I.mjs → git-handle-C_GYoScT.mjs} +1 -1
  10. package/dist/index.d.mts +1 -1
  11. package/dist/index.mjs +1 -1
  12. package/dist/init-B6g8iwyX.mjs +1 -0
  13. package/dist/init-CyxGRu4t.mjs +1 -0
  14. package/dist/{init-CV-T5iq6.mjs → init-DeoOI04P.mjs} +14 -14
  15. package/dist/init-WENor_lZ.mjs +5 -0
  16. package/dist/{is-object-DVVYT5oa.mjs → is-object-B4GcZahG.mjs} +1 -1
  17. package/dist/keepalive-BI3oBFIq.mjs +2 -0
  18. package/dist/loader-BNuhNFOT.mjs +3 -0
  19. package/dist/loader-bM_eCxHL.mjs +1 -0
  20. package/dist/{open-browser-DhlJOpN3.mjs → open-browser-CfwaLBtR.mjs} +1 -1
  21. package/dist/paths-DxI4FHOZ.mjs +2 -0
  22. package/dist/paths-xS3o7pK2.mjs +1 -0
  23. package/dist/preview-BGOwfgOL.mjs +1 -0
  24. package/dist/{preview-C8ZwiJ2u.mjs → preview-oS_HbHIz.mjs} +2 -2
  25. package/dist/{server-lock-ChItwD14.mjs → server-lock-B4frNnOB.mjs} +1 -1
  26. package/dist/server-lock-CPmOhzSz.mjs +1 -0
  27. package/dist/src-D9A_jCdV.mjs +1 -0
  28. package/dist/src-DcVg7_6f.mjs +93 -0
  29. package/dist/src-NsJfsnSl.mjs +1 -0
  30. package/dist/{src-Ds19hvLH.mjs → src-ViJPkmPW.mjs} +68 -68
  31. package/dist/start-BPpXybFr.mjs +1 -0
  32. package/dist/{start-BHq36XyK.mjs → start-CNULXoun.mjs} +2 -2
  33. package/dist/wrapper-BK_jpkDm.mjs +7 -0
  34. package/package.json +3 -5
  35. package/dist/colors-BNvy_pwG.mjs +0 -1
  36. package/dist/constants-DsvJ_8Q_.mjs +0 -2
  37. package/dist/git-handle-B3_Ztqi2.mjs +0 -1
  38. package/dist/init-B-yAf4yl.mjs +0 -5
  39. package/dist/init-BQCoz0GQ.mjs +0 -1
  40. package/dist/init-C3daLp5H.mjs +0 -1
  41. package/dist/keepalive-D-FSaNO6.mjs +0 -2
  42. package/dist/loader-B89NhS3Q.mjs +0 -1
  43. package/dist/loader-BnSnxsbb.mjs +0 -3
  44. package/dist/paths-CKjRRQXN.mjs +0 -2
  45. package/dist/paths-CNT8tWW1.mjs +0 -1
  46. package/dist/preview-BMI7LYiA.mjs +0 -1
  47. package/dist/server-lock-nls6eoZ5.mjs +0 -1
  48. package/dist/src-9qc50QcN.mjs +0 -93
  49. package/dist/src-Bq7299o2.mjs +0 -1
  50. package/dist/src-ByMiIIub.mjs +0 -1
  51. package/dist/start-CVqWWbuw.mjs +0 -1
@@ -0,0 +1 @@
1
+ import{i as e,n as t,o as n,r}from"./colors-CoV_NlQL.mjs";export{t as dim,r as error,e as info,n as warning};
@@ -1,2 +1,2 @@
1
1
  import e from"picocolors";const t=t=>e.red(t),n=t=>e.yellow(t),r=t=>e.cyan(t),i=t=>e.gray(t),a=t=>e.bold(t);function o(t,n){return e.isColorSupported?`\u001B]8;;${n}\u0007${t}\u001B]8;;\u0007`:t}export{o as a,r as i,i as n,n as o,t as r,a as t};
2
- //# sourceMappingURL=colors-eCHTjaBL.mjs.map
2
+ //# sourceMappingURL=colors-CoV_NlQL.mjs.map
@@ -0,0 +1,2 @@
1
+ import"./src-ViJPkmPW.mjs";var e=`0.0.0-dev-20260421192027`;const t=`AGENTS.md`,n=`config.yml`,r=`cache`,i=e,a=`open-knowledge`;export{i as a,a as i,r as n,n as r,t};
2
+ //# sourceMappingURL=constants-BLW6shM6.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./git-handle-C_GYoScT.mjs";export{e as createGitInstance};
@@ -1,2 +1,2 @@
1
1
  import{resolve as e}from"node:path";import t from"simple-git";const n=new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}};function r(e){return n.enqueue(e)}function i(n,r={}){let{credentialArgs:i=[],gitIndexFile:a}=r,o={};return a&&(o.GIT_INDEX_FILE=e(n,a)),{git:t({baseDir:n,config:i.length>=2?[i[1]]:[],unsafe:{allowUnsafeCredentialHelper:!0}}).env(o),projectDir:n,credentialArgs:i}}export{r as n,i as t};
2
- //# sourceMappingURL=git-handle-CQtGq94I.mjs.map
2
+ //# sourceMappingURL=git-handle-C_GYoScT.mjs.map
package/dist/index.d.mts CHANGED
@@ -74,7 +74,7 @@ interface AgentIdentity {
74
74
  name: string;
75
75
  version: string;
76
76
  };
77
- /** User-provided via AGENT_LABEL env var in .mcp.json */
77
+ /** User-provided via AGENT_LABEL env var in the editor MCP config */
78
78
  label?: string;
79
79
  /** Derived: label || clientInfo.name || "Agent" */
80
80
  displayName: string;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{n as e,t}from"./loader-BnSnxsbb.mjs";import"./src-Bq7299o2.mjs";export{e as ConfigSchema,t as loadConfig};
1
+ import{n as e,r as t}from"./loader-BNuhNFOT.mjs";import"./src-D9A_jCdV.mjs";export{t as ConfigSchema,e as loadConfig};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,r,t as i}from"./init-WENor_lZ.mjs";export{i as detectInstalledEditors,n as formatInitResult,r as initCommand,t as parseEditorFlag,e as runInit};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./init-DeoOI04P.mjs";export{o as CLAUDE_MD_SECTION,n as OK_MARKER_BEGIN,i as OK_MARKER_END,t as PREVIEW_GUIDANCE,e as ensureOkGitignoredAtRoot,r as initContent,a as upsertRootInstructions};
@@ -1,4 +1,4 @@
1
- import{E as e}from"./src-Ds19hvLH.mjs";import{n as t,r as n,t as r}from"./constants-DsvJ_8Q_.mjs";import{existsSync as i,mkdirSync as a,readFileSync as o,realpathSync as s,writeFileSync as c}from"node:fs";import{join as l,resolve as u}from"node:path";const d=`<!-- open-knowledge:begin -->`,f=`<!-- open-knowledge:end -->`,p=/<!-- open-knowledge:begin -->[\s\S]*?<!-- open-knowledge:end -->/,m=`# ${e}/ — Open Knowledge config
1
+ import{n as e,r as t,t as n}from"./constants-BLW6shM6.mjs";import{D as r}from"./src-ViJPkmPW.mjs";import{existsSync as i,mkdirSync as a,readFileSync as o,realpathSync as s,writeFileSync as c}from"node:fs";import{join as l,resolve as u}from"node:path";const d=`<!-- open-knowledge:begin -->`,f=`<!-- open-knowledge:end -->`,p=/<!-- open-knowledge:begin -->[\s\S]*?<!-- open-knowledge:end -->/,m=`# ${r}/ — Open Knowledge config
2
2
 
3
3
  This directory holds Open Knowledge's configuration for this project. It's **not** where content lives — content lives wherever \`content.dir\` + \`content.include\` in \`config.yml\` point. The default is the repo root with \`**/*.md\`, so any markdown file in the project is fair game. Inspect \`config.yml\` for the actual setting.
4
4
 
@@ -69,11 +69,11 @@ Folder metadata lives in \`config.yml\`, **not** in content files — this is in
69
69
 
70
70
  This directory was scaffolded by running \`open-knowledge init\` (or \`npx @inkeep/open-knowledge init\`) in the project root. That command:
71
71
 
72
- 1. Creates \`${e}/\` (config-only — no content subdirs)
72
+ 1. Creates \`${r}/\` (config-only — no content subdirs)
73
73
  2. Writes \`AGENTS.md\`, \`.gitignore\`, and \`config.yml\`
74
- 3. Registers the Open Knowledge MCP server in \`.mcp.json\` at the repo root
74
+ 3. Registers the Open Knowledge MCP server in your selected editors' MCP config files (user-scoped by default)
75
75
 
76
- If you're onboarding a new project and \`${e}/\` doesn't exist yet, run \`open-knowledge init\` from a terminal.
76
+ If you're onboarding a new project and \`${r}/\` doesn't exist yet, run \`open-knowledge init\` from a terminal.
77
77
 
78
78
  ## Tools
79
79
 
@@ -85,7 +85,7 @@ If you're onboarding a new project and \`${e}/\` doesn't exist yet, run \`open-k
85
85
  - **Writes** via \`write_document\` / \`edit_document\` — route through the server so shadow-repo attribution (agent vs human) is captured
86
86
  - **Graph queries** via \`get_backlinks\`, \`get_forward_links\`, \`get_orphans\`, \`get_hubs\`
87
87
 
88
- These tools are discovered via the standard MCP \`tools/list\` handshake and work in any MCP client (Claude Code, Claude Desktop, Cursor, VS Code, Windsurf, Codex, etc.). \`open-knowledge init\` registers the MCP server in every editor's config for you — Claude Desktop and Windsurf use project-qualified keys like \`open-knowledge-<project>\` so one config file can serve multiple projects on the same machine. Claude Desktop requires a full quit + relaunch to pick up new MCP servers; Windsurf hot-reloads.
88
+ These tools are discovered via the standard MCP \`tools/list\` handshake and work in any MCP client (Claude Code, Claude Desktop, Cursor, VS Code, Windsurf, Codex, etc.). \`open-knowledge init\` registers a single global \`open-knowledge\` entry in each selected editor's config, and the server resolves the active project per tool call from explicit \`cwd\` values or client-reported workspace roots. Claude Desktop requires a full quit + relaunch to pick up new MCP servers; other clients may need a new session or editor restart if they are already open.
89
89
  `,h=`# Open Knowledge — workspace configuration
90
90
  #
91
91
  # This file overrides built-in defaults for this workspace. Every key below
@@ -94,15 +94,15 @@ These tools are discovered via the standard MCP \`tools/list\` handshake and wor
94
94
  #
95
95
  # Precedence (lowest -> highest):
96
96
  # Built-in defaults
97
- # -> ~/${e}/config.yml (user defaults)
98
- # -> ./${e}/config.yml (this file)
97
+ # -> ~/${r}/config.yml (user defaults)
98
+ # -> ./${r}/config.yml (this file)
99
99
  #
100
100
  # Schema reference: packages/cli/src/config/schema.ts
101
101
 
102
102
 
103
103
  # --- Content ---------------------------------------------------------------
104
104
  # dir: where the CRDT editor reads/writes documents. Relative to the project
105
- # root (the directory containing ${e}/), NOT to this file.
105
+ # root (the directory containing ${r}/), NOT to this file.
106
106
  #
107
107
  # include/exclude: glob patterns for tracked content files. Relative to the
108
108
  # content directory (content.dir).
@@ -172,11 +172,11 @@ These tools are discovered via the standard MCP \`tools/list\` handshake and wor
172
172
  `,g="**Preview before edit (REQUIRED).** You MUST follow this sequence every time you call `write_document` or `edit_document`:\n1. Call `get_preview_url` to obtain the browser URL for the target doc.\n - If it returns `null`, the UI isn't running yet. Start it with `open-knowledge ui` from a terminal — or in Claude Code, call `preview_start(\"open-knowledge-ui\")` (the `open-knowledge init` command scaffolds this `.claude/launch.json` entry, so it's ready to go). `open-knowledge ui` auto-spawns the collab server in the background; you don't need to run `open-knowledge start` separately. Then call `get_preview_url` again — the UI writes a lock file that this tool reads.\n - NEVER guess or manually construct the preview URL — always use the URL returned by `get_preview_url`.\n2. Open that URL in your preview browser so the user can see the document.\n3. Only then call `write_document` / `edit_document` — the CRDT edit will stream live into the already-open editor.\n\nNEVER call `write_document` or `edit_document` without first navigating the preview browser to the doc. The user expects to watch every edit land in real time. Write-tool responses include `previewUrl` (when resolvable) and a `warning` when no client is currently attached to the doc.",_=`${d}
173
173
  ## Open Knowledge
174
174
 
175
- This repo uses Open Knowledge — collaborative markdown via MCP. **\`${e}/config.yml\`** (with optional \`~/${e}/config.yml\`; CLI/env may override) is the **path contract**: \`content.dir\` is the root for relative paths; \`content.include\` lists globs that **add** markdown; \`content.exclude\` lists globs that **remove** paths. Nothing else defines scope — not folder names, not "docs vs code." \`.gitignore\` still applies. When MCP is connected, the server's instructions echo the **resolved** \`dir\` / \`include\` / \`exclude\` for this session — treat that table and the YAML as two views of the same rules.
175
+ This repo uses Open Knowledge — collaborative markdown via MCP. **\`${r}/config.yml\`** (with optional \`~/${r}/config.yml\`; CLI/env may override) is the **path contract**: \`content.dir\` is the root for relative paths; \`content.include\` lists globs that **add** markdown; \`content.exclude\` lists globs that **remove** paths. Nothing else defines scope — not folder names, not "docs vs code." \`.gitignore\` still applies. When MCP is connected, the server's instructions echo the **resolved** \`dir\` / \`include\` / \`exclude\` for this session — treat that table and the YAML as two views of the same rules.
176
176
 
177
177
  **Default mental model (no jargon):** unless this project narrowed \`content.include\`, **every \`.md\` and \`.mdx\` under \`content.dir\`** is an Open Knowledge document — including under \`specs/\`, \`reports/\`, \`docs/\`, etc. If \`content.include\` is non-default, read \`config.yml\` once per turn so you do not mis-classify paths.
178
178
 
179
- **STOP — your host's built-in file tools on in-scope \`.md\` / \`.mdx\`.** When this workspace has Open Knowledge MCP configured (for example via root \`.mcp.json\`), you **must not** reach for native tools on in-scope markdown. Same failure mode as native \`Edit\` on them: no frontmatter, no backlinks, no shadow-repo activity, no recent-edit signal. The ban is broader than just \`Read\` / \`Grep\` / \`Glob\` — it names every common rationalization:
179
+ **STOP — your host's built-in file tools on in-scope \`.md\` / \`.mdx\`.** When this workspace has Open Knowledge MCP configured (for example via a user-scoped editor config such as \`~/.claude.json\` or \`~/.cursor/mcp.json\`), you **must not** reach for native tools on in-scope markdown. Same failure mode as native \`Edit\` on them: no frontmatter, no backlinks, no shadow-repo activity, no recent-edit signal. The ban is broader than just \`Read\` / \`Grep\` / \`Glob\` — it names every common rationalization:
180
180
 
181
181
  - **Native \`Read\` / \`Grep\` / \`Glob\` on in-scope \`.md\` / \`.mdx\`** — the original case.
182
182
  - **\`Bash ls\` / \`Bash find\` / \`Bash cat\` on dirs containing in-scope markdown** — use \`exec("ls …")\` / \`exec("find … -name '*.md'")\` / \`exec("cat …")\` instead. Native returns bare names; \`exec\` returns frontmatter, backlink counts, and recent-activity per child.
@@ -220,11 +220,11 @@ ${g}
220
220
  **Server must be running.** If \`write_document\` or \`edit_document\` returns a "Hocuspocus server is not running" error, start it with \`open-knowledge start\` (via Bash) and retry. NEVER fall back to native \`Edit\` / \`Write\` for in-scope markdown — always use the MCP write tools so edits go through the CRDT layer with proper attribution.
221
221
 
222
222
  **Non-markdown files.** Use native \`Read\` / \`Edit\` / \`Grep\` / \`Bash\` for source code, configs, and anything outside the path contract in \`config.yml\`: under \`content.dir\`, matching \`content.include\`, not removed by \`content.exclude\` or \`.gitignore\`.
223
- ${f}`;function v(e,t,n){let a=[r,...n??[]],u=new Set,d=[];for(let n of a){let r=l(e,n),a=i(r),f=a?s(r):r;if(u.has(f)){d.push({file:n,path:r,action:`skipped-symlink`});continue}if(u.add(f),!a){c(r,`${_}\n`,`utf-8`),d.push({file:n,path:r,action:`created`});continue}let m=o(r,`utf-8`),h=p.test(m);if(h&&!t){d.push({file:n,path:r,action:`skipped-existing`});continue}if(h){c(r,m.replace(p,_),`utf-8`),d.push({file:n,path:r,action:`replaced`});continue}c(r,`${m.replace(/\n*$/,``)}\n\n${_}\n`,`utf-8`),d.push({file:n,path:r,action:`appended`})}return d}function y(e,t){return i(e)?!1:(c(e,t,`utf-8`),!0)}function b(t){let n=l(t,`.gitignore`),r=`# Open Knowledge — local editor config (not tracked upstream)\n${e}/\n`;if(!i(n))return c(n,r,`utf-8`),`created`;let a=o(n,`utf-8`),s=new Set([e,`${e}/`,`/${e}`,`/${e}/`]);return a.split(`
224
- `).map(e=>e.trim()).some(e=>s.has(e))?`already-present`:(c(n,`${a}${a.length===0||a.endsWith(`
223
+ ${f}`;function v(e,t,r){let a=[n,...r??[]],u=new Set,d=[];for(let n of a){let r=l(e,n),a=i(r),f=a?s(r):r;if(u.has(f)){d.push({file:n,path:r,action:`skipped-symlink`});continue}if(u.add(f),!a){c(r,`${_}\n`,`utf-8`),d.push({file:n,path:r,action:`created`});continue}let m=o(r,`utf-8`),h=p.test(m);if(h&&!t){d.push({file:n,path:r,action:`skipped-existing`});continue}if(h){c(r,m.replace(p,_),`utf-8`),d.push({file:n,path:r,action:`replaced`});continue}c(r,`${m.replace(/\n*$/,``)}\n\n${_}\n`,`utf-8`),d.push({file:n,path:r,action:`appended`})}return d}function y(e,t){return i(e)?!1:(c(e,t,`utf-8`),!0)}function b(e){let t=l(e,`.gitignore`),n=`# Open Knowledge — local editor config (not tracked upstream)\n${r}/\n`;if(!i(t))return c(t,n,`utf-8`),`created`;let a=o(t,`utf-8`),s=new Set([r,`${r}/`,`/${r}`,`/${r}/`]);return a.split(`
224
+ `).map(e=>e.trim()).some(e=>s.has(e))?`already-present`:(c(t,`${a}${a.length===0||a.endsWith(`
225
225
  `)?``:`
226
226
  `}${a.length>0&&!a.endsWith(`
227
227
 
228
228
  `)?`
229
- `:``}${r}`,`utf-8`),`appended`)}const x=[{name:r,content:m},{name:`.gitignore`,content:`${t}/\nserver.lock\nui.lock\nsync-state.json\n`},{name:n,content:h}];function S(n){let r=u(n,e),i=[],o=[];a(r,{recursive:!0}),a(l(r,t),{recursive:!0});for(let e of x)y(l(r,e.name),e.content)?i.push(e.name):o.push(e.name);return{created:i,skipped:o}}export{b as a,g as i,d as n,S as o,f as r,v as s,_ as t};
230
- //# sourceMappingURL=init-CV-T5iq6.mjs.map
229
+ `:``}${n}`,`utf-8`),`appended`)}const x=[{name:n,content:m},{name:`.gitignore`,content:`${e}/\nserver.lock\nui.lock\nsync-state.json\n`},{name:t,content:h}];function S(t){let n=u(t,r),i=[],o=[];a(n,{recursive:!0}),a(l(n,e),{recursive:!0});for(let e of x)y(l(n,e.name),e.content)?i.push(e.name):o.push(e.name);return{created:i,skipped:o}}export{b as a,g as i,d as n,S as o,f as r,v as s,_ as t};
230
+ //# sourceMappingURL=init-DeoOI04P.mjs.map
@@ -0,0 +1,5 @@
1
+ import{i as e}from"./constants-BLW6shM6.mjs";import{D as t}from"./src-ViJPkmPW.mjs";import{o as n,s as r}from"./init-DeoOI04P.mjs";import{t as i}from"./preview-oS_HbHIz.mjs";import{o as a}from"./colors-CoV_NlQL.mjs";import{t as o}from"./is-object-B4GcZahG.mjs";import{Command as s}from"commander";import{existsSync as c,mkdirSync as l,readFileSync as u,writeFileSync as d}from"node:fs";import{homedir as f}from"node:os";import{basename as p,dirname as m,isAbsolute as h,join as g,posix as _,relative as v,resolve as y,sep as b,win32 as x}from"node:path";import{parse as ee,stringify as S}from"smol-toml";const C=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],w=[`@inkeep/open-knowledge`,`mcp`],T={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function E(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=y(e);if(p(t)===`cli.mjs`&&p(m(t))===`dist`)return t;let n=t.split(b),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return g(i.length===0?b:i.join(b),`packages`,`cli`,`dist`,`cli.mjs`)}function D(e={}){return e.mode===`dev`?{command:`node`,args:[E(e.cliEntryPath),`mcp`],env:{...T}}:{command:`npx`,args:[...w]}}function O(e){return e===`win32`?x:_}function k(e={}){let t=e.platformName??process.platform,n=e.home??f(),r=e.env??process.env,i=O(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function te(e={}){let t=e.platformName??process.platform,n=e.home??f();return O(t).join(n,`.claude.json`)}function A(e={}){let t=e.platformName??process.platform,n=e.home??f(),r=e.env??process.env;if(t===`darwin`)return _.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??x.join(n,`AppData`,`Roaming`);return x.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function j(e={}){let t=e.platformName??process.platform,n=e.home??f();return O(t).join(n,`.cursor`,`mcp.json`)}function M(e={}){return O(e.platformName??process.platform).join(k(e),`Code`,`User`,`mcp.json`)}function N(e={}){let t=e.platformName??process.platform,n=e.home??f();return O(t).join(n,`.codeium`,`windsurf`,`mcp_config.json`)}function P(e={}){let t=e.platformName??process.platform,n=e.home??f();return(e.env??process.env).CODEX_HOME??O(t).join(n,`.codex`)}function F(e={}){return O(e.platformName??process.platform).join(P(e),`config.toml`)}function I(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>I(e,t[n]));if(o(e)&&o(t)){let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((e,t)=>e===r[t])&&n.every(n=>I(e[n],t[n]))}return!1}function ne(e,t){return Object.entries(t).every(([t,n])=>I(e[t],n))}function re(e,t){return{...e,...t}}function L(e){return{...e,isCompatible(t,n,r){return ne(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return re(t,e.buildEntry(n,r))}}}const R={claude:L({id:`claude`,label:`Claude Code`,configPath:(e,t)=>te({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>e,buildEntry:(e,t)=>D(t),scope:`global`,detectPath:(e,t)=>g(t??f(),`.claude`),legacyProjectConfigPath:e=>g(e,`.mcp.json`),instructionsPath:e=>g(e,`CLAUDE.md`)}),"claude-desktop":L({id:`claude-desktop`,label:`Claude Desktop`,configPath:(e,t)=>A({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>e,buildEntry:(e,t)=>D(t),scope:`global`,detectPath:(e,t)=>m(A({home:t}))}),cursor:L({id:`cursor`,label:`Cursor`,configPath:(e,t)=>j({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>e,buildEntry:(e,t)=>D(t),scope:`global`,detectPath:(e,t)=>m(j({home:t})),legacyProjectConfigPath:e=>g(e,`.cursor`,`mcp.json`)}),vscode:L({id:`vscode`,label:`VS Code`,configPath:(e,t)=>M({home:t}),format:`json`,topLevelKey:`servers`,serverName:()=>e,buildEntry:(e,t)=>({type:`stdio`,...D(t)}),scope:`global`,detectPath:(e,t)=>m(M({home:t})),legacyProjectConfigPath:e=>g(e,`.vscode`,`mcp.json`)}),windsurf:L({id:`windsurf`,label:`Windsurf`,configPath:(e,t)=>N({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>e,buildEntry:(e,t)=>D(t),scope:`global`,detectPath:(e,t)=>m(N({home:t}))}),codex:L({id:`codex`,label:`Codex`,configPath:(e,t)=>F({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>e,buildEntry:(e,t)=>D(t),scope:`global`,detectPath:(e,t)=>m(F({home:t})),legacyProjectConfigPath:e=>g(e,`.codex`,`config.toml`)})};function z(e){let t=e.filter(e=>!(e in R));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${C.join(`, `)}`);return e.map(e=>R[e])}function B(e){if(!c(e))return{};let t=u(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(o(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function V(e){if(!c(e))return{};let t=u(e,`utf-8`).trim();if(t===``)return{};try{let n=ee(t);if(o(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function H(e,t){l(m(e),{recursive:!0}),d(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function U(e,t){l(m(e),{recursive:!0});let n=S(t);d(e,n.endsWith(`
2
+ `)?n:`${n}\n`,`utf-8`)}const W=`0.0.1`,G=`open-knowledge-ui`;function K(e,t){let n=[];e.runtimeExecutable!==t.runtimeExecutable&&n.push(`runtimeExecutable`);let r=e.runtimeArgs;return Array.isArray(r)&&r.length===t.runtimeArgs.length&&r.every((e,n)=>e===t.runtimeArgs[n])||n.push(`runtimeArgs`),e.port!==t.port&&n.push(`port`),n}function q(e,t,n={}){let r=g(e,`.claude`,`launch.json`),i=n.mode===`dev`,a=n.mode===`dev`?{name:G,runtimeExecutable:`node`,runtimeArgs:[E(n.cliEntryPath),`ui`],port:3e3}:{name:G,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!c(r))return l(m(r),{recursive:!0}),d(r,`${JSON.stringify({version:W,configurations:[a]},null,2)}\n`,`utf-8`),{action:`created`,configPath:r};let e=u(r,`utf-8`).trim(),n=e?JSON.parse(e):{};if(!o(n))return{action:`failed`,configPath:r,error:`launch.json root is not an object`};let s=Array.isArray(n.configurations)?n.configurations:[],f=s.findIndex(e=>o(e)&&e.name===G);if(f>=0&&!t){let e=s[f],t=K(e,a);if(t.length>0){if(!i)return{action:`skipped-stale`,configPath:r,staleFields:t}}else return{action:`skipped-existing`,configPath:r}}f>=0?s[f]=a:s.push(a);let p={...n,version:n.version??W,configurations:s};return d(r,`${JSON.stringify(p,null,2)}\n`,`utf-8`),{action:`merged`,configPath:r}}catch(e){return{action:`failed`,configPath:r,error:e instanceof Error?e.message:String(e)}}}function J(e,t,n,r,i){let a=e.serverName(t),s;try{s=e.configPath(t,i)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let c;try{c=e.format===`toml`?V(s):B(s)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:s,serverName:a,error:t instanceof Error?t.message:String(t)}}let l=c[e.topLevelKey]??{},u=l[a],d=r.mode===`dev`,f;try{if(u!==void 0&&!n){if(o(u)&&e.isCompatible(u,t,r))return{editorId:e.id,label:e.label,action:`skipped-existing`,configPath:s,serverName:a};if(!d)return{editorId:e.id,label:e.label,action:`skipped-conflict`,configPath:s,serverName:a}}f=o(u)&&(n||d)?e.mergeManagedFields(u,t,r):e.buildEntry(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:s,serverName:a,error:t instanceof Error?t.message:String(t)}}let p={...c,[e.topLevelKey]:{...l,[a]:f}};try{e.format===`toml`?U(s,p):H(s,p)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:s,serverName:a,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:u===void 0?`written`:`overwritten`,configPath:s,serverName:a}}function Y(e,t){let n=e.legacyProjectConfigPath?.(t);if(!(!n||!c(n)))return{editorId:e.id,label:e.label,path:n}}function X(e={}){let t=y(e.cwd??process.cwd()),i={mode:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},a;try{a=n(t)}catch(n){return{contentCreated:[],contentSkipped:[],editors:[],legacyProjectConfigs:[],rootInstructions:[],mcpAction:`failed`,mcpPath:R.claude.configPath(t,e.home),mcpError:`Content scaffolding failed: ${n instanceof Error?n.message:String(n)}`}}let o=e.editors??[`claude`],s=z(o),c=[];for(let n of s){if(e.mcp===!1){let r=``;try{r=n.configPath(t,e.home)}catch{}c.push({editorId:n.id,label:n.label,action:`skipped-flag`,configPath:r,serverName:n.serverName(t)});continue}c.push(J(n,t,e.force??!1,i,e.home))}let l=e.mcp===!1?[]:s.map(e=>Y(e,t)).filter(e=>e!==void 0),u=o.includes(`claude`)&&e.mcp!==!1?q(t,e.force??!1,i):void 0,d=s.map(e=>e.instructionsPath?.(t)).filter(e=>e!==void 0).map(e=>h(e)?v(t,e):e),f=e.rootInstructions===!1?[]:r(t,e.force??!1,d),p=c.find(e=>e.editorId===`claude`)??c[0]??{action:`skipped-flag`,configPath:R.claude.configPath(t,e.home)};return{contentCreated:a.created,contentSkipped:a.skipped,editors:c,legacyProjectConfigs:l,rootInstructions:f,launchJson:u,mcpAction:p.action,mcpPath:p.configPath,mcpError:`error`in p?p.error:void 0}}function Z(e,n){let r=[],o=g(n,t);if(e.contentCreated.length>0?(r.push(`Content scaffolded at ${o}/`),r.push(` Created: ${e.contentCreated.join(`, `)}`)):r.push(`Content already present at ${o}/`),e.contentSkipped.length>0&&r.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),r.push(``),e.editors.length===0)e.mcpError&&r.push(`Warning: ${e.mcpError}`);else{let t=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),o=e.editors.some(e=>e.action===`failed`);if(e.editors.every(e=>e.action===`skipped-flag`))r.push(`MCP config not written — use without --no-mcp to configure editors`);else{r.push(`MCP server configuration:`);for(let t of e.editors){let e=t.configPath.startsWith(n)?v(n,t.configPath):t.configPath.replace(/^\/Users\/[^/]+/,`~`),i=t.serverName===`open-knowledge`?``:` (${t.serverName})`,a=` `.repeat(Math.max(1,14-t.label.length)),o=t.editorId===`claude-desktop`&&(t.action===`written`||t.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(t.action){case`written`:r.push(` ${t.label}${a}${e} registered${i}${o}`);break;case`overwritten`:r.push(` ${t.label}${a}${e} updated${i}${o}`);break;case`skipped-existing`:r.push(` ${t.label}${a}${e} already configured${i}`);break;case`skipped-conflict`:r.push(` ${t.label}${a}${e} managed MCP fields differ from current defaults${i}; re-run with --force to update`);break;case`failed`:r.push(` ${t.label}${a}${e} FAILED: ${t.error}`);break;case`skipped-flag`:break}}}if(o&&(r.push(``),r.push(`For failed editors, add the MCP server entry manually. See:`),r.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){r.push(``),r.push(`Legacy project MCP configs detected:`);for(let t of e.legacyProjectConfigs)r.push(` ${t.label} ${v(n,t.path)}`);r.push(` These project-local files may override the new global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.launchJson){let t=e.launchJson,i=t.configPath.startsWith(n)?v(n,t.configPath):t.configPath;switch(t.action){case`created`:r.push(` launch.json ${i} created (preview_start("${G}") ready)`);break;case`merged`:r.push(` launch.json ${i} merged open-knowledge entry`);break;case`skipped-existing`:r.push(` launch.json ${i} already has open-knowledge entry`);break;case`skipped-stale`:r.push(` launch.json ${i} ${a(`⚠ existing open-knowledge entry is out of date`)}`),t.staleFields&&t.staleFields.length>0&&r.push(` ${a(`${t.staleFields.join(`, `)} differ from current defaults`)}`),r.push(` ${a(`re-run with --force to update`)}`);break;case`failed`:r.push(` launch.json ${i} FAILED: ${t.error}`);break}}if(e.rootInstructions.length>0){let t=e.rootInstructions.filter(e=>e.action!==`skipped-symlink`);if(t.length>0){r.push(``),r.push(`Root instructions:`);for(let e of t){let t=e.path.startsWith(n)?v(n,e.path):e.path,i=` `.repeat(Math.max(1,14-e.file.length));switch(e.action){case`created`:r.push(` ${e.file}${i}${t} created`);break;case`appended`:r.push(` ${e.file}${i}${t} appended Open Knowledge section`);break;case`replaced`:r.push(` ${e.file}${i}${t} replaced Open Knowledge section (--force)`);break;case`skipped-existing`:r.push(` ${e.file}${i}${t} already has Open Knowledge section`);break}}}}if(e.preview?(r.push(``),r.push(i(e.preview,n))):e.previewWarning&&(r.push(``),r.push(`Content preview unavailable: ${e.previewWarning}`)),t){let t=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.label);r.push(``),r.push(`Next steps:`),r.push(` 1. Open your editor (${t.join(` / `)})`),r.push(` 2. Approve the MCP server when prompted`),r.push(` 3. The knowledge base is ready — use the three workflow tools:`),r.push(` - mcp__open-knowledge__init-content — bootstrap articles from the codebase`),r.push(` - mcp__open-knowledge__ingest — capture an external source`),r.push(` - mcp__open-knowledge__research — gather sources and write findings`)}}return r.join(`
3
+ `)}function ie(e){switch(e){case`claude_desktop`:return`claude-desktop`;default:return e}}function Q(e){if(e===`all`)return[...C];let t=e.split(`,`).map(e=>e.trim()).map(ie);return z(t),t}function $(e,t){let n=[];for(let r of C){let i=R[r],a;try{a=i.detectPath?.(e,t)??m(i.configPath(e,t))}catch{continue}c(a)&&n.push(r)}return n}function ae(){return new s(`init`).description(`Scaffold ${t}/ 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 ${t}/ directory but do not touch MCP config`).option(`--force`,`Overwrite existing open-knowledge MCP entries (default: skip)`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--editor <editors>`,`Target editor(s): ${C.join(`, `)}, all (comma-separated) — default: all detected editors (non-TTY) / preselects detected editors (TTY)`).action(async e=>{let t=process.cwd(),n;if(e.editor)try{n=Q(e.editor)}catch(e){process.stderr.write(`${e instanceof Error?e.message:String(e)}\n`),process.exitCode=1;return}else if(e.mcp!==!1&&process.stdin.isTTY){let{multiselect:e,isCancel:r}=await import(`@clack/prompts`),i=new Set($(t));i.size===0&&process.stdout.write(`No MCP-capable editors detected — select manually, or cancel and use --editor <all|${C.join(`|`)}>.\n`);let a=await e({message:`Which tools do you use? (space to toggle, enter to confirm)`,options:C.flatMap(e=>{let n=R[e];try{let r=n.configPath(t),a=n.scope===`global`?r.replace(/^\/Users\/[^/]+/,`~`):v(t,r);return[{value:e,label:n.label,hint:a,initialValue:i.has(e)}]}catch{return[]}}),required:!0});if(r(a)){process.stdout.write(`Init cancelled.
4
+ `);return}n=a}else if(n=$(t),n.length===0){process.stderr.write(`No MCP-capable editors detected. Use --editor <all|${C.join(`|`)}> to force.\n`),process.exitCode=1;return}let r=X({cwd:t,mcp:e.mcp,force:e.force,devMcp:e.devMcp,editors:n});try{let{previewContent:e}=await import(`./preview-BGOwfgOL.mjs`),{loadConfig:n}=await import(`./loader-bM_eCxHL.mjs`),{resolveContentDir:i}=await import(`./paths-xS3o7pK2.mjs`),{config:a}=n(t);r.preview=e({projectDir:t,contentDir:i(a,t),include:a.content.include,exclude:a.content.exclude})}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${Z(r,t)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)})}export{X as a,Q as i,Z as n,ae as r,$ as t};
5
+ //# sourceMappingURL=init-WENor_lZ.mjs.map
@@ -1,2 +1,2 @@
1
1
  function e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{e as t};
2
- //# sourceMappingURL=is-object-DVVYT5oa.mjs.map
2
+ //# sourceMappingURL=is-object-B4GcZahG.mjs.map
@@ -0,0 +1,2 @@
1
+ function e(e){let t=e.scheduler??{setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e)},n=e.initialBackoffMs??1e3,r=e.maxBackoffMs??3e4,i=e.createWebSocket??(e=>new WebSocket(e)),a=e.logger??null,o=e.log,s=null,c=null,l=!1,u=n;function d(e,t,n){try{a?a[e](t,n):o?.(t)}catch{}}function f(){if(l)return;c!==null&&t.clearTimeout(c);let e=u;u=Math.min(u*2,r),d(`debug`,`scheduling reconnect`,{backoffMs:e}),c=t.setTimeout(()=>{c=null,p().catch(e=>d(`warn`,`reconnect failed`,{error:String(e)}))},e)}async function p(){if(l)return;let t;try{t=await e.resolveWsUrl()}catch(e){d(`warn`,`resolveWsUrl threw`,{error:String(e)}),f();return}if(!t){f();return}let r=`${t}/collab/keepalive?pid=${process.pid}`;try{s=i(r)}catch(e){d(`warn`,`WebSocket constructor failed`,{url:r,error:String(e)}),s=null,f();return}s.addEventListener(`open`,()=>{d(`info`,`connected`,{url:t}),u=n}),s.addEventListener(`close`,()=>{l||(d(`info`,`disconnected`,{url:t}),s=null,f())}),s.addEventListener(`error`,()=>{d(`debug`,`websocket error observed`,{url:t,readyState:s?.readyState,reason:`error-event`})})}return queueMicrotask(()=>{p().catch(e=>d(`warn`,`initial connect failed`,{error:String(e)}))}),{close:()=>{if(!l&&(l=!0,c!==null&&(t.clearTimeout(c),c=null),s)){try{s.close()}catch{}s=null}},isConnected:()=>s!==null&&s.readyState===1}}export{e as startKeepalive};
2
+ //# sourceMappingURL=keepalive-BI3oBFIq.mjs.map
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./constants-BLW6shM6.mjs";import{D as t}from"./src-ViJPkmPW.mjs";import{t as n}from"./is-object-B4GcZahG.mjs";import{existsSync as r,readFileSync as i}from"node:fs";import{homedir as a}from"node:os";import{resolve as o}from"node:path";import{parse as s}from"yaml";import{realpath as c}from"node:fs/promises";import{z as l}from"zod";async function u(e){let t=o(e);try{return await c(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}}const d=l.object({title:l.string().optional(),description:l.string().optional(),tags:l.array(l.string()).optional()}).strict(),f=l.object({match:l.string().min(1,"`match` must be a non-empty glob pattern (e.g. 'specs/**' or 'reports/*/**')"),frontmatter:d}).strict(),p=l.object({content:l.object({dir:l.string().default(`.`),include:l.array(l.string()).min(1).default([`**/*.md`,`**/*.mdx`]),exclude:l.array(l.string()).default([])}).default({dir:`.`,include:[`**/*.md`,`**/*.mdx`],exclude:[]}),github:l.object({oauthAppClientId:l.string().default(`Ov23liqlSd0V1MwR6rhI`)}).default({oauthAppClientId:`Ov23liqlSd0V1MwR6rhI`}),sync:l.object({enabled:l.boolean().optional(),pushIntervalSeconds:l.number().int().min(1).default(60),pullIntervalSeconds:l.number().int().min(1).default(30),autoCommit:l.boolean().default(!0),autoPush:l.boolean().default(!0),autoPull:l.boolean().default(!0),commitMessage:l.string().default(`auto`)}).default({pushIntervalSeconds:60,pullIntervalSeconds:30,autoCommit:!0,autoPush:!0,autoPull:!0,commitMessage:`auto`}),server:l.object({port:l.number().int().min(0).max(65535).default(0),host:l.string().regex(/^[\w.\-:]+$/,`Invalid hostname`).default(`localhost`),openOnAgentEdit:l.boolean().default(!1)}).default({port:0,host:`localhost`,openOnAgentEdit:!1}),persistence:l.object({debounceMs:l.number().int().min(0).default(2e3),maxDebounceMs:l.number().int().min(0).default(1e4)}).default({debounceMs:2e3,maxDebounceMs:1e4}),preview:l.object({baseUrl:l.url().optional()}).default({}),folders:l.array(f).default([]),mcp:l.object({autoStart:l.boolean().default(!0),tools:l.object({read_document:l.object({historyDepth:l.number().int().min(0).default(5)}).default({historyDepth:5}),search:l.object({maxResults:l.number().int().min(1).default(50)}).default({maxResults:50})}).default({read_document:{historyDepth:5},search:{maxResults:50}})}).default({autoStart:!0,tools:{read_document:{historyDepth:5},search:{maxResults:50}}})});function m(e,t){let r={...e};for(let i of Object.keys(t)){let a=e[i],o=t[i];n(o)&&n(a)?r[i]=m(a,o):o!==void 0&&(r[i]=o)}return r}function h(e){if(!r(e))return null;try{let t=s(i(e,`utf-8`));return n(t)?t:null}catch(t){return console.warn(`[config] Failed to parse ${e}: ${t instanceof Error?t.message:t}`),null}}function g(n){let r=n??process.cwd(),i=[],s=o(a(),t,e),c={},l=h(s);l&&(c=m(c,l),i.push(s));let u=o(r,t,e),d=h(u);d&&(c=m(c,d),i.push(u));let f=p.safeParse(c);if(!f.success){let e=f.error.issues.map(e=>` ${e.path.join(`.`)}: ${e.message}`);throw Error(`Invalid configuration:\n${e.join(`
2
+ `)}`)}return{config:f.data,sources:i}}function _(e,t=process.env){let n=e;return t.PORT&&(n={...n,server:{...n.server,port:Number(t.PORT)}}),t.HOST&&(n={...n,server:{...n.server,host:t.HOST}}),n}function v(e){let t=e.env??process.env,n=e.cacheMs??1e3,r=e.loadConfigFn??g,i=new Map,a=new Map,o=u(e.startupCwd);return async s=>{let c=await u(s??e.startupCwd),l=Date.now(),d=i.get(c);if(d&&d.expiresAt>l)return d.config;let f=a.get(c);if(f)return await f;let p=(async()=>{if(c===await o){let r=_(e.startupConfig,t);return i.set(c,{config:r,expiresAt:Date.now()+n}),r}let a=_(r(c).config,t);return i.set(c,{config:a,expiresAt:Date.now()+n}),a})();a.set(c,p);try{return await p}finally{a.delete(c)}}}export{u as i,g as n,p as r,v as t};
3
+ //# sourceMappingURL=loader-BNuhNFOT.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-BNuhNFOT.mjs";export{e as loadConfig};
@@ -1,2 +1,2 @@
1
1
  import{execFile as e}from"node:child_process";function t(t){e(process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,process.platform===`win32`?[`/c`,`start`,``,t]:[t],e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${t} manually`)})}export{t as openBrowser};
2
- //# sourceMappingURL=open-browser-DhlJOpN3.mjs.map
2
+ //# sourceMappingURL=open-browser-CfwaLBtR.mjs.map
@@ -0,0 +1,2 @@
1
+ import"./constants-BLW6shM6.mjs";import{D as e}from"./src-ViJPkmPW.mjs";import{resolve as t}from"node:path";function n(e,n){return t(n,e.content.dir)}function r(n){return t(n,e)}export{r as n,n as t};
2
+ //# sourceMappingURL=paths-DxI4FHOZ.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./paths-DxI4FHOZ.mjs";export{t as resolveContentDir,e as resolveLockDir};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-oS_HbHIz.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1,3 +1,3 @@
1
- import{E as e}from"./src-Ds19hvLH.mjs";import"./constants-DsvJ_8Q_.mjs";import{l as t}from"./src-9qc50QcN.mjs";import{existsSync as n,lstatSync as r,readdirSync as i,realpathSync as a,statSync as o}from"node:fs";import{join as s,relative as c}from"node:path";function l(e){let{projectDir:n,contentDir:l,include:u,exclude:d,sampleCap:f=5}=e,p=[],m=[];try{r(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,include:u,exclude:d,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let h;try{h=t({projectDir:n,contentDir:l,includePatterns:u,excludePatterns:d})}catch(e){return{totalCount:0,sample:[],contentDir:l,include:u,exclude:d,warnings:[e instanceof Error?e.message:String(e)]}}function g(e){let t;try{t=i(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);p.push(`could not read directory ${c(l,e)||`.`}: ${n}`);return}for(let n of t){let t=s(e,n.name);if(n.isSymbolicLink()){let e;try{e=a(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?p.push(`broken or cyclic symlink: ${c(l,t)}`):p.push(`cannot resolve symlink ${c(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=o(e)}catch{continue}if(n.isDirectory()){let e=c(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(n.isFile()){let e=c(l,t);if(h.isExcluded(e))continue;m.push(e)}}else if(n.isDirectory()){let e=c(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(n.isFile()){let e=c(l,t);if(h.isExcluded(e))continue;m.push(e)}}}return g(l),{totalCount:m.length,sample:m.slice(0,f),contentDir:l,include:u,exclude:d,warnings:p}}function u(t,r){let i=[],a=c(r,t.contentDir),o=a===``?`./`:`./${a}`;i.push(`Content:`),i.push(` Found ${t.totalCount} markdown files in ${o}`);let l=t.include.join(`, `),u=t.exclude.length>0?t.exclude.join(`, `):`(none)`;if(i.push(` Scope: include=${l} exclude=${u}`),t.sample.length>0){let e=t.sample.join(`, `),n=t.totalCount>t.sample.length?`, …`:``;i.push(` Sample: ${e}${n}`)}if(t.warnings.length>0)for(let e of t.warnings)i.push(` Warning: ${e}`);return i.push(``),n(s(r,`.open-knowledge`,`config.yml`))?(i.push(` To adjust, edit ${e}/config.yml:`),i.push(` content:`),i.push(` include: ${JSON.stringify(t.include)}`),i.push(` exclude: ${JSON.stringify(t.exclude)}`)):(i.push(" Run `open-knowledge init` to scaffold config, then adjust:"),i.push(` ${e}/config.yml → content.include / content.exclude`)),i.push(``),i.push(` Re-check anytime: open-knowledge preview`),i.join(`
1
+ import"./constants-BLW6shM6.mjs";import{D as e}from"./src-ViJPkmPW.mjs";import{l as t}from"./src-DcVg7_6f.mjs";import{existsSync as n,lstatSync as r,readdirSync as i,realpathSync as a,statSync as o}from"node:fs";import{join as s,relative as c}from"node:path";function l(e){let{projectDir:n,contentDir:l,include:u,exclude:d,sampleCap:f=5}=e,p=[],m=[];try{r(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,include:u,exclude:d,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let h;try{h=t({projectDir:n,contentDir:l,includePatterns:u,excludePatterns:d})}catch(e){return{totalCount:0,sample:[],contentDir:l,include:u,exclude:d,warnings:[e instanceof Error?e.message:String(e)]}}function g(e){let t;try{t=i(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);p.push(`could not read directory ${c(l,e)||`.`}: ${n}`);return}for(let n of t){let t=s(e,n.name);if(n.isSymbolicLink()){let e;try{e=a(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?p.push(`broken or cyclic symlink: ${c(l,t)}`):p.push(`cannot resolve symlink ${c(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=o(e)}catch{continue}if(n.isDirectory()){let e=c(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(n.isFile()){let e=c(l,t);if(h.isExcluded(e))continue;m.push(e)}}else if(n.isDirectory()){let e=c(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(n.isFile()){let e=c(l,t);if(h.isExcluded(e))continue;m.push(e)}}}return g(l),{totalCount:m.length,sample:m.slice(0,f),contentDir:l,include:u,exclude:d,warnings:p}}function u(t,r){let i=[],a=c(r,t.contentDir),o=a===``?`./`:`./${a}`;i.push(`Content:`),i.push(` Found ${t.totalCount} markdown files in ${o}`);let l=t.include.join(`, `),u=t.exclude.length>0?t.exclude.join(`, `):`(none)`;if(i.push(` Scope: include=${l} exclude=${u}`),t.sample.length>0){let e=t.sample.join(`, `),n=t.totalCount>t.sample.length?`, …`:``;i.push(` Sample: ${e}${n}`)}if(t.warnings.length>0)for(let e of t.warnings)i.push(` Warning: ${e}`);return i.push(``),n(s(r,`.open-knowledge`,`config.yml`))?(i.push(` To adjust, edit ${e}/config.yml:`),i.push(` content:`),i.push(` include: ${JSON.stringify(t.include)}`),i.push(` exclude: ${JSON.stringify(t.exclude)}`)):(i.push(" Run `open-knowledge init` to scaffold config, then adjust:"),i.push(` ${e}/config.yml → content.include / content.exclude`)),i.push(``),i.push(` Re-check anytime: open-knowledge preview`),i.join(`
2
2
  `)}export{l as n,u as t};
3
- //# sourceMappingURL=preview-C8ZwiJ2u.mjs.map
3
+ //# sourceMappingURL=preview-oS_HbHIz.mjs.map
@@ -1,2 +1,2 @@
1
1
  import{closeSync as e,existsSync as t,mkdirSync as n,openSync as r,readFileSync as i,unlinkSync as a,writeFileSync as o,writeSync as s}from"node:fs";import{hostname as c}from"node:os";import{resolve as l}from"node:path";function u(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}var d=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function f(e,t){return l(e,`${t}.lock`)}function p(e,t){try{let n=JSON.parse(i(e,`utf-8`));return n&&typeof n==`object`&&typeof n.pid==`number`?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function m(i){let{lockName:l,lockDir:m,metadata:g}=i,_=`[${l}-lock]`;n(m,{recursive:!0});let v=f(m,l),y={pid:process.pid,hostname:c(),port:g.port,startedAt:new Date().toISOString(),worktreeRoot:g.worktreeRoot},b=JSON.stringify(y,null,2);for(let n=0;n<3;n++){if(!t(v))try{let t=r(v,`wx`,384);try{s(t,b)}finally{e(t)}return h({lockName:l,lockDir:m,lockPath:v})}catch(e){if(e.code!==`EEXIST`)throw e}let n=p(v,_);if(n){let e=n.hostname===c();if(e&&n.pid===process.pid)return o(v,b,{encoding:`utf-8`,mode:384}),h({lockName:l,lockDir:m,lockPath:v});if(e&&u(n.pid))throw new d(n,v,l);console.warn(`${_} Stale lock detected (pid=${n.pid}, host=${n.hostname}) — replacing`)}try{a(v)}catch{}}throw Error(`${_} Failed to acquire ${v} after 3 attempts (concurrent acquire contention).`)}function h(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>v({lockName:t,lockDir:n}),updatePort:e=>g({lockName:t,lockDir:n,port:e})}}function g(e){let{lockName:n,lockDir:r,port:a}=e,s=`[${n}-lock]`,l=f(r,n);if(!t(l)){console.warn(`${s} Lock file missing at ${l} during port update — skipping`);return}let u;try{let e=JSON.parse(i(l,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`){console.warn(`${s} Corrupt lock at ${l} during port update — skipping`);return}u=e}catch{console.warn(`${s} Unreadable lock at ${l} during port update — skipping`);return}if(u.pid===process.pid&&!(typeof u.hostname==`string`&&u.hostname!==c())){u.port=a;try{o(l,JSON.stringify(u,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${s} Failed to update port in ${l}: ${e instanceof Error?e.message:String(e)}`)}}}function _(e){let{lockName:n,lockDir:r}=e,o=f(r,n);if(!t(o))return null;let s;try{let e=JSON.parse(i(o,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`)return null;s=e}catch{return null}if(s.hostname!==c())return null;if(!u(s.pid)){try{a(o)}catch{}return null}return s}function v(e){let{lockName:n,lockDir:r}=e,o=`[${n}-lock]`,s=f(r,n);if(t(s))try{let e=JSON.parse(i(s,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==c())return;a(s)}catch(e){console.warn(`${o} Failed to release ${s}: ${e instanceof Error?e.message:String(e)}`)}}var y=class extends d{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function b(e,t){try{return m({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof d&&e.lockName===`server`?new y(e.existing,e.lockPath):e}}function x(e,t){g({lockName:`server`,lockDir:e,port:t})}function S(e){return _({lockName:`server`,lockDir:e})}function C(e){v({lockName:`server`,lockDir:e})}export{x as a,f as c,g as d,u as f,C as i,_ as l,b as n,d as o,S as r,m as s,y as t,v as u};
2
- //# sourceMappingURL=server-lock-ChItwD14.mjs.map
2
+ //# sourceMappingURL=server-lock-B4frNnOB.mjs.map
@@ -0,0 +1 @@
1
+ import{a as e}from"./server-lock-B4frNnOB.mjs";export{e as updateServerLockPort};
@@ -0,0 +1 @@
1
+ import"./loader-BNuhNFOT.mjs";export{};