@inkeep/open-knowledge 0.0.0-dev-20260501054734 → 0.0.0-dev-20260501071238
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/open-knowledge/SKILL.md +12 -12
- package/dist/cli.mjs +345 -346
- package/dist/config-schema.json +1 -30
- package/dist/config.project.schema.json +1 -30
- package/dist/constants-Ccx0q5EO.mjs +2 -0
- package/dist/dist-B-uWyCj3.mjs +1 -0
- package/dist/{dist-Bk22-nn7.mjs → dist-CUghvkAf.mjs} +72 -70
- package/dist/{dist-BKxD-v-w.mjs → dist-WQbZIrx7.mjs} +36 -36
- package/dist/index.d.mts +1 -3
- package/dist/index.mjs +1 -1
- package/dist/{init-DEHyWHMa.mjs → init-DMUmlRUV.mjs} +29 -29
- package/dist/{init-DVZtt6e-.mjs → init-DQVmtI8h.mjs} +25 -16
- package/dist/init-Dd-ypqWc.mjs +1 -0
- package/dist/init-jnyR2hTf.mjs +1 -0
- package/dist/loader-IVNXMdm0.mjs +4 -0
- package/dist/loader-dh9DEQFy.mjs +1 -0
- package/dist/paths-Bp5ooOJg.mjs +2 -0
- package/dist/paths-CcnZRq8W.mjs +1 -0
- package/dist/preview-SUAZQ5h2.mjs +1 -0
- package/dist/preview-tSq0pzNL.mjs +3 -0
- package/dist/public/assets/{ActivityModeContent-BSkmKRy4.js → ActivityModeContent-Bj0kOgDy.js} +1 -1
- package/dist/public/assets/{DocumentContext-D3zjM2ax.js → DocumentContext-CDvFNgd7.js} +1 -1
- package/dist/public/assets/{GraphPanel-jbwIk-JX.js → GraphPanel-YIuSwj1X.js} +1 -1
- package/dist/public/assets/{SettingsPane-Bj0EiYda.js → SettingsPane-BYRRZ2yt.js} +1 -1
- package/dist/public/assets/{SourceEditor-Dz2Lc5LE.js → SourceEditor-BkBM9oYb.js} +1 -1
- package/dist/public/assets/{clipboard-i7TzBQ01.js → clipboard-BTbzStNo.js} +1 -1
- package/dist/public/assets/{config-validation-events-DpHbVC_H.js → config-validation-events-gPU2C30Q.js} +1 -1
- package/dist/public/assets/{index-joGKm2Br.js → index-C0JKXDVX.js} +71 -71
- package/dist/public/assets/{target-navigation-intent-CK4Ee17H.js → target-navigation-intent-BeUCdVKa.js} +1 -1
- package/dist/public/assets/{toggle-group-n36XMgMC.js → toggle-group-CyBGhndP.js} +6 -4
- package/dist/public/assets/{tooltip-BM5o_T0o.js → tooltip-FdwzzIbl.js} +1 -1
- package/dist/public/index.html +7 -7
- package/dist/schemas/v0/config.project.schema.json +1 -30
- package/dist/server-Bc0tGxRk.mjs +3 -0
- package/dist/{server-lock-n3Y5JWNv-3o7br8XE.mjs → server-lock-BAi_a4NX-CRPhQdIH.mjs} +1 -1
- package/dist/server-lock-BAi_a4NX-uRxotxS6.mjs +1 -0
- package/dist/src-B-NdiXlJ.mjs +1 -0
- package/dist/start-CUBxPqPc.mjs +2 -0
- package/dist/start-GoM45WVd.mjs +1 -0
- package/package.json +1 -1
- package/scripts/build-config-schema.mjs +2 -2
- package/dist/constants-C_Xn28oM.mjs +0 -2
- package/dist/dist-BuWOuGGO.mjs +0 -1
- package/dist/init-BrZlKzcx.mjs +0 -1
- package/dist/init-gZdio8Wt.mjs +0 -1
- package/dist/loader-CEV6AVlU.mjs +0 -1
- package/dist/loader-DD2NITvw.mjs +0 -2
- package/dist/paths-Dwr32i3p.mjs +0 -1
- package/dist/paths-ajeOK0uP.mjs +0 -2
- package/dist/preview-C86aCB1t.mjs +0 -3
- package/dist/preview-D6fWJCDu.mjs +0 -1
- package/dist/server-CYax-BjV.mjs +0 -3
- package/dist/server-lock-n3Y5JWNv-DXpg9_eU.mjs +0 -1
- package/dist/src-D6R3jg-t.mjs +0 -1
- package/dist/start-D5tAdx92.mjs +0 -2
- package/dist/start-DG0Lr5vX.mjs +0 -1
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*
|
|
26
26
|
* `ok init`'s scaffolded project `config.yml` magic-comment points at the
|
|
27
27
|
* versioned project schema; `writeConfigPatch`'s lazy first-write of
|
|
28
|
-
* `~/.
|
|
28
|
+
* `~/.ok/config.yml` points at the versioned user schema.
|
|
29
29
|
* Each file's autocomplete then surfaces only the fields that are valid
|
|
30
30
|
* AT that scope — an `appearance.theme` typed in project YAML squiggles,
|
|
31
31
|
* a `content.dir` typed in user YAML squiggles.
|
|
@@ -123,7 +123,7 @@ writeSchema(resolve(versionedDir, 'config.project.schema.json'), projectSchema);
|
|
|
123
123
|
writeSchema(resolve(versionedDir, 'config.user.schema.json'), userSchema);
|
|
124
124
|
|
|
125
125
|
// Back-compat aliases at dist root — pre-versioning magic comments
|
|
126
|
-
// point here. Removing these would break existing `~/.
|
|
126
|
+
// point here. Removing these would break existing `~/.ok/
|
|
127
127
|
// config.yml` files that never re-pinned to a versioned URL.
|
|
128
128
|
writeSchema(resolve(distDir, 'config-schema.json'), fullSchema);
|
|
129
129
|
writeSchema(resolve(distDir, 'config.project.schema.json'), projectSchema);
|
package/dist/dist-BuWOuGGO.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-Bk22-nn7.mjs";import{l as e,o as t}from"./server-lock-n3Y5JWNv-3o7br8XE.mjs";import{$ as n,At as r,D as i,E as a,Et as o,G as s,K as c,P as l,Yt as u,_ as d,nt as f}from"./dist-BKxD-v-w.mjs";export{d as ProjectGitInitError,a as UiLockCollisionError,i as acquireUiLock,l as bootServer,s as createAssetServeMiddleware,c as createContentFilter,n as ensureProjectGit,f as getLogger,t as isProcessAlive,e as readServerLock,o as readUiLock,r as releaseUiLock,u as updateUiLockPort};
|
package/dist/init-BrZlKzcx.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./init-DEHyWHMa.mjs";export{e as runInit};
|
package/dist/init-gZdio8Wt.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./init-DVZtt6e-.mjs";export{e as initContent};
|
package/dist/loader-CEV6AVlU.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-DD2NITvw.mjs";export{e as loadConfig};
|
package/dist/loader-DD2NITvw.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{$ as e,F as t,Rt as n,Z as r,nt as i}from"./dist-Bk22-nn7.mjs";import{n as a}from"./constants-C_Xn28oM.mjs";import{r as o}from"./server-CYax-BjV.mjs";import{t as s}from"./is-object-CEU0BgQ5.mjs";import{resolve as c}from"node:path";import{existsSync as l,readFileSync as u}from"node:fs";import{homedir as d}from"node:os";import{realpath as f}from"node:fs/promises";async function p(e){let t=c(e);try{return await f(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 m=r;var h=n();function g(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];s(a)&&s(i)?n[r]=g(i,a):a!==void 0&&(n[r]=a)}return n}function _(e){if(!l(e))return{value:null,path:e,source:null,doc:null};let t;try{t=u(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,h.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return s(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function v(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=i({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function y(n){let r=n??process.cwd(),i=[],l=c(d(),e,a),u=o({absPath:l}),f={};u.valid&&u.source!==void 0?(f=g(f,u.value),i.push(l)):u.valid;let p=c(r,e,a),h=_(p);h.value!==null&&(f=g(f,h.value),i.push(p));let y=f.upload;s(y)&&y.maxBytes!==void 0&&console.warn(`[config] upload.maxBytes is deprecated and ignored — streaming uploads have no user-facing cap. Remove the key to silence this warning.`);let b=m.safeParse(f);if(!b.success){let e={code:`SCHEMA_INVALID`,issues:v(b.error.issues,h)};throw Error(t(e))}return{config:b.data,sources:i}}function b(e,t=process.env){let n=e;return t.HOST&&(n={...n,server:{...n.server,host:t.HOST}}),n}function x(e){let t=e.env??process.env,n=e.cacheMs??1e3,r=e.loadConfigFn??y,i=new Map,a=new Map,o=p(e.startupCwd);return async s=>{let c=await p(s??e.startupCwd),l=Date.now(),u=i.get(c);if(u&&u.expiresAt>l)return u.config;let d=a.get(c);if(d)return await d;let f=(async()=>{if(c===await o){let r=b(e.startupConfig,t);return i.set(c,{config:r,expiresAt:Date.now()+n}),r}let a=b(r(c).config,t);return i.set(c,{config:a,expiresAt:Date.now()+n}),a})();a.set(c,f);try{return await f}finally{a.delete(c)}}}export{p as i,y as n,m as r,x as t};
|
|
2
|
-
//# sourceMappingURL=loader-DD2NITvw.mjs.map
|
package/dist/paths-Dwr32i3p.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./paths-ajeOK0uP.mjs";export{t as resolveContentDir,e as resolveLockDir};
|
package/dist/paths-ajeOK0uP.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{$ as e}from"./dist-Bk22-nn7.mjs";import"./constants-C_Xn28oM.mjs";import{K as t}from"./dist-BKxD-v-w.mjs";import{join as n,relative as r}from"node:path";import{existsSync as i,lstatSync as a,readdirSync as o,realpathSync as s,statSync as c}from"node:fs";function l(e){let{projectDir:i,contentDir:l,include:u,exclude:d,sampleCap:f=5}=e,p=[],m=[];try{a(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:i,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=o(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);p.push(`could not read directory ${r(l,e)||`.`}: ${n}`);return}for(let i of t){let t=n(e,i.name);if(i.isSymbolicLink()){let e;try{e=s(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?p.push(`broken or cyclic symlink: ${r(l,t)}`):p.push(`cannot resolve symlink ${r(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=c(e)}catch{continue}if(n.isDirectory()){let e=r(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(n.isFile()){let e=r(l,t);if(h.isExcluded(e))continue;m.push(e)}}else if(i.isDirectory()){let e=r(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(i.isFile()){let e=r(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,a){let o=[],s=r(a,t.contentDir),c=s===``?`./`:`./${s}`;o.push(`Content:`),o.push(` Found ${t.totalCount} markdown files in ${c}`);let l=t.include.join(`, `),u=t.exclude.length>0?t.exclude.join(`, `):`(none)`;if(o.push(` Scope: include=${l} exclude=${u}`),t.sample.length>0){let e=t.sample.join(`, `),n=t.totalCount>t.sample.length?`, …`:``;o.push(` Sample: ${e}${n}`)}if(t.warnings.length>0)for(let e of t.warnings)o.push(` Warning: ${e}`);return o.push(``),i(n(a,`.open-knowledge`,`config.yml`))?(o.push(` To adjust, edit ${e}/config.yml:`),o.push(` content:`),o.push(` include: ${JSON.stringify(t.include)}`),o.push(` exclude: ${JSON.stringify(t.exclude)}`)):(o.push(" Run `open-knowledge init` to scaffold config, then adjust:"),o.push(` ${e}/config.yml → content.include / content.exclude`)),o.push(``),o.push(` Re-check anytime: open-knowledge preview`),o.join(`
|
|
2
|
-
`)}export{l as n,u as t};
|
|
3
|
-
//# sourceMappingURL=preview-C86aCB1t.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-C86aCB1t.mjs";export{t as formatPreviewBlock,e as previewContent};
|
package/dist/server-CYax-BjV.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{$ as e,Rt as t,X as n,Z as r,at as i,et as a,it as o,nt as s,rt as c,tt as l}from"./dist-Bk22-nn7.mjs";import{dirname as u,isAbsolute as d,resolve as f}from"node:path";import{existsSync as p,readFileSync as m,renameSync as h,unlinkSync as g}from"node:fs";import{homedir as _}from"node:os";import{mkdir as v,rename as y,writeFile as b}from"node:fs/promises";var x=t();function S(e){return`https://unpkg.com/@inkeep/open-knowledge@latest/dist/schemas/${n}/${e===`user`?`config.user.schema.json`:`config.project.schema.json`}`}function C(e){return`# yaml-language-server: $schema=${S(e)}\n`}function w(t,n,r){return f(t===`user`?r??_():d(n)?n:f(n),e,`config.yml`)}function T(e){return{ok:!1,error:e}}function E(e){return{ok:!0,...e}}async function D(e,t){let n=`${e}.tmp.${crypto.randomUUID()}`;try{await b(n,t,{encoding:`utf-8`,mode:420}),await y(n,e)}catch(e){try{g(n)}catch{}throw e}}async function O(e){return o(`config.patch`,{"config.scope":e.scope,"config.transport":`fs`},async t=>{let n=await k(e);return t.setAttribute(`config.outcome`,n.ok?`success`:`rejected`),n.ok||t.setAttribute(`config.error.code`,n.error.code),n})}async function k(e){let{cwd:t,scope:n,patch:o,homedirOverride:s,firstWriteHeader:d}=e,f=w(n,t,s),h=``,g=!1;if(p(f)){g=!0;try{h=m(f,`utf-8`)}catch(e){return T({code:`WRITE_ERROR`,detail:`Could not read existing config: ${e instanceof Error?e.message:String(e)}`})}}let _=(0,x.parseDocument)(h);if(_.errors.length>0)return T({code:`YAML_PARSE`,detail:_.errors.map(e=>e.message).join(`; `)});if(_.contents===null)_.contents=_.createNode({});else if(!(0,x.isMap)(_.contents))return T({code:`YAML_PARSE`,detail:`Top-level YAML value must be a mapping (object), got ${(0,x.isSeq)(_.contents)?`sequence`:`scalar`}`});let y=l(_,o),b=_.toJSON(),S=i(`config.validate`,{"config.scope":n,"config.validation.layer":`L2`},e=>{let t=r.safeParse(b);if(e.setAttribute(`config.outcome`,t.success?`success`:`rejected`),!t.success)for(let e of t.error.issues)a(`config.validation.issue`,{"issue.path":e.path.map(e=>String(e)).join(`.`),"issue.message":e.message});return t});if(!S.success)return T({code:`SCHEMA_INVALID`,issues:S.error.issues.map(c)});let O=_.toString();if(!g){let e=d===void 0?C(n):d??``;e.length>0&&(O=`${e.endsWith(`
|
|
2
|
-
`)?e:`${e}\n`}${O}`)}try{await v(u(f),{recursive:!0})}catch(e){return T({code:`WRITE_ERROR`,detail:`Could not create parent directory for ${f}: ${e instanceof Error?e.message:String(e)}`})}try{await D(f,O)}catch(e){return T({code:`WRITE_ERROR`,detail:`Could not write ${f}: ${e instanceof Error?e.message:String(e)}`})}return E({effective:S.data,appliedPaths:y,path:f,created:!g})}function A(e){if(!p(e))return[];let t=(0,x.parseDocument)(m(e,`utf-8`));if(t.errors.length>0)return[];let n=t.toJSON();if(!n||typeof n!=`object`||Array.isArray(n))return[];let r=n.folders;return Array.isArray(r)?r:[]}function j(e){return{ok:!1,error:e}}function M(e){return{ok:!0,...e}}async function N(e){let t=e.scope??`project`,n=w(t,e.cwd,e.homedirOverride),r;try{r=A(n)}catch(e){return j({code:`WRITE_ERROR`,detail:`Could not read current folders: ${e instanceof Error?e.message:String(e)}`})}let i=r.map(e=>({match:e.match,frontmatter:{...e.frontmatter}}));for(let t of e.rules){let e=t.new_match??t.match,n=i.findIndex(e=>e.match===t.match);if(t.new_match!==void 0&&t.new_match!==t.match){if(n>=0){let e=i.findIndex((e,r)=>r!==n&&e.match===t.new_match);e>=0&&i.splice(e,1);let r=e>=0&&e<n?n-1:n;i[r]={match:t.new_match,frontmatter:{...t.frontmatter}}}else{let n=i.findIndex(t=>t.match===e);n>=0?i[n]={match:e,frontmatter:{...t.frontmatter}}:i.push({match:e,frontmatter:{...t.frontmatter}})}continue}n>=0?i[n]={match:t.match,frontmatter:{...t.frontmatter}}:i.push({match:t.match,frontmatter:{...t.frontmatter}})}let a=await O({cwd:e.cwd,scope:t,patch:{folders:i},homedirOverride:e.homedirOverride});return a.ok?M({effective:a.effective,appliedPaths:a.appliedPaths,path:a.path,created:a.created}):j(a.error)}function P(e,t){let n=F(`user`,t),r=F(`project`,t),i=new Map;for(let t of e){let e=t.join(`.`);i.set(e,{user:I(n,t),project:I(r,t)})}return i}function F(e,t){let n=w(e,t.cwd,t.homedirOverride);if(!p(n))return null;let r;try{r=m(n,`utf-8`)}catch(t){return t.code!==`ENOENT`&&console.warn(`[inspectConfigPaths] could not read ${e} config at ${n}: ${t.message??t}`),null}let i=(0,x.parseDocument)(r);return i.errors.length>0?(console.warn(`[inspectConfigPaths] ${e} config at ${n} has YAML parse errors; treating as absent for scope inference`),null):i.toJSON()}function I(e,t){if(t.length===0)return e!=null;let n=e;for(let e of t){if(n==null)return!1;if(Array.isArray(n)&&typeof e==`number`){n=n[e];continue}if(typeof n==`object`){let t=String(e);if(!(t in n))return!1;n=n[t];continue}return!1}return n!==void 0}function L(e,t,n,r){return e.success?{code:`UNKNOWN`,message:`unexpected success in error path`}:{code:`SCHEMA_INVALID`,issues:e.error.issues.map(e=>{let i=e.path.map(e=>typeof e==`symbol`?String(e):e),a=s({file:r,source:n,doc:t,path:i});return{path:i,message:e.message,issueCode:e.code,...a===void 0?{}:{source:a}}})}}function R(e,t,n){let r=`${e}.invalid-${t.replace(/[:.]/g,`-`)}`;try{return h(e,r),r}catch(t){n(`[config] Could not sideline invalid config file ${e} → ${r}: ${t instanceof Error?t.message:String(t)}. File left in place; using schema defaults.`);return}}function z(e){let{absPath:t,sideline:n=!0,timestamp:i=new Date().toISOString()}=e,a=e.warn??(e=>console.warn(e)),o=r.parse({});if(!p(t))return{valid:!0,value:o,source:void 0};let s;try{s=m(t,`utf-8`)}catch(e){let n=e instanceof Error?e.message:String(e);return a(`[config] Could not read ${t}: ${n}. Using schema defaults.`),{valid:!1,value:o,error:{code:`UNKNOWN`,message:`Read failed: ${n}`}}}let c=(0,x.parseDocument)(s);if(c.errors.length>0){let e=c.errors.map(e=>e.message).join(`; `);a(`[config] ${t} contains invalid YAML (${e}). Using schema defaults.`+(n?``:` Pass-through mode: file left in place.`));let r=n?R(t,i,a):void 0;return{valid:!1,value:o,error:{code:`YAML_PARSE`,detail:e},...r===void 0?{}:{sidelinedTo:r}}}let l=c.toJSON()??{},u=r.safeParse(l);if(!u.success){let e=L(u,c,s,t);a(`[config] ${t} fails schema validation (${u.error.issues.length} issue(s)). Using schema defaults.`+(n?``:` Pass-through mode: file left in place.`));let r=n?R(t,i,a):void 0;return{valid:!1,value:o,error:e,...r===void 0?{}:{sidelinedTo:r}}}return{valid:!0,value:u.data,source:t}}export{O as a,w as i,P as n,z as r,N as t};
|
|
3
|
-
//# sourceMappingURL=server-CYax-BjV.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as e}from"./server-lock-n3Y5JWNv-3o7br8XE.mjs";export{e as a};
|
package/dist/src-D6R3jg-t.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./loader-DD2NITvw.mjs";import"./init-DEHyWHMa.mjs";export{};
|
package/dist/start-D5tAdx92.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./esm-wByiX8MO.mjs";import{$ as t}from"./dist-Bk22-nn7.mjs";import{i as n}from"./constants-C_Xn28oM.mjs";import{spawn as r}from"node:child_process";import{join as i}from"node:path";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c}from"node:fs";import{setTimeout as l}from"node:timers/promises";function u(){let e=process.execPath,t=process.argv[1];return t?{command:e,prefixArgs:[t]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx @inkeep/open-knowledge\`. This re-introduces the version-drift surface that re-exec was fixing. Observed argv: ${JSON.stringify(process.argv)}`),{command:`npx`,prefixArgs:[`@inkeep/open-knowledge`]})}function d(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function f(e){o(e.lockDir)||s(e.lockDir,{recursive:!0});let t=c(i(e.lockDir,`last-spawn-error.log`),`w`),n=e.spawn??r,{PORT:l,...d}=process.env,f=u();try{let r=n(f.command,[...f.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:d});return r.unref(),r}finally{try{a(t)}catch{}}}async function p(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}function m(e){let t=e.sigtermGraceMs??1e4,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>l(e));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function h(e){let{config:n,cwd:r}=e,i=e.skipAutoInit??!1,a=e.skipUiAutoSpawn??!1,o=e.idleThresholdMs??18e5,{existsSync:s,mkdirSync:c}=await import(`node:fs`),{resolve:u}=await import(`node:path`),{bootServer:h,ensureProjectGit:g,getLogger:_,isProcessAlive:v,readUiLock:y}=await import(`./dist-BuWOuGGO.mjs`),{resolveContentDir:b}=await import(`./paths-Dwr32i3p.mjs`),x=e.log??_(`start`),S=b(n,r);s(S)||(c(S,{recursive:!0}),x.info({contentDir:S},`Created content directory`));let C=!s(u(r,t)),w=i?void 0:async()=>{try{let{initContent:e}=await import(`./init-gZdio8Wt.mjs`),t=e(r);return C||t.created.length>0||t.updated.length>0}catch(e){return console.warn(`Auto-init failed:`,e instanceof Error?e.message:e),!1}},T=!1,E=u(S,t),D=n.server.openOnAgentEdit?()=>{if(T)return;let e=y(E);if(!e||e.port<=0||!v(e.pid))return;T=!0;let t=`http://localhost:${e.port}`;import(`./open-browser-hvFa-TeR.mjs`).then(({openBrowser:e})=>e(t)).catch(()=>{})}:void 0,O=null,k=await h({contentDir:S,projectDir:r,contentRoot:n.content.dir,port:e.port,host:n.server.host,quiet:!1,includePatterns:n.content.include,excludePatterns:n.content.exclude,onAgentWrite:D,localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:!0,idleShutdownMs:o,skipAutoInit:i,autoInitFn:w,ensureProjectGitFn:i?void 0:()=>g(r),spawnUiSiblingFn:async({lockDir:t})=>{if(O=d({uiLock:y(t),isAlive:v}),O.action===`spawn`&&!a)try{f({lockDir:t,cwd:r,spawn:e.spawn}),x.info({reason:O.reason},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else O.action===`skip`&&x.info({port:O.port,pid:O.pid},`UI already running at port ${O.port}`)},idleShutdownHandler:e=>m({readUiLock:()=>y(k.lockDir),isAlive:v,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:x}),log:x});O||={action:`skip`,reason:`alive`,pid:0,port:0};let A=O,j=null;if(A.action===`skip`)j=A.port>0?A.port:null;else if(!a){let t=e.uiBindTimeoutMs??3e3;j=await p({readUiLock:()=>y(k.lockDir),now:Date.now,sleep:e=>l(e),timeoutMs:t,pollIntervalMs:50}),j===null&&x.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:k.httpServer,destroy:k.destroy,lockDir:k.lockDir,contentDir:S,port:k.port,ready:k.ready,degraded:k.degraded,uiSpawnDecision:O,resolvedUiPort:j,didAutoInit:k.didAutoInit,didGitInit:k.didGitInit}}function g(r){return new e(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--no-init`,`Skip auto-scaffolding of ${t}/`).action(async e=>{let{renderBanner:i}=await import(`./banner-DoFNyNUH.mjs`),{dim:a,error:o,info:s,warning:c}=await import(`./colors-CswooXAS.mjs`),l=r(),u=process.cwd();e.host!==void 0&&(l.server.host=e.host);let d=e.port===void 0?void 0:Number(e.port),f=process.env.PORT?Number(process.env.PORT):void 0,p=d??f,m;try{m=await h({config:l,cwd:u,port:p,skipAutoInit:e.init===!1})}catch(e){let{ProjectGitInitError:t}=await import(`./dist-BuWOuGGO.mjs`);e instanceof t&&(console.error(o(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.`)),e.stderr&&console.error(a(e.stderr.trim())),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let g=!1,_=async e=>{if(!g){g=!0,console.log(a(`\nShutting down (${e})...`));try{await m.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)}};process.once(`SIGINT`,()=>{_(`SIGINT`)}),process.once(`SIGTERM`,()=>{_(`SIGTERM`)});let v=`http://${l.server.host}:${m.port}`,y=l.server.host===`0.0.0.0`||l.server.host===`::`?`http://0.0.0.0:${m.port}`:void 0,b=m.resolvedUiPort,x=b!==null&&b>0?`http://${l.server.host}:${b}`:v;console.log(i({name:`open-knowledge`,version:n,localUrl:x,apiUrl:x===v?void 0:v,networkUrl:y})),m.didAutoInit&&(console.log(` ${s(`✓`)} Scaffolded ${t}/ (first run)`),console.log(` ${a("Tip: Run `open-knowledge init` to register MCP tools for Claude Code")}\n`));let S={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};m.ready.then(async()=>{if(m.degraded.length>0){console.log();for(let e of m.degraded){let t=S[e]??`${e} (check server logs for details)`;console.warn(` ${c(`⚠`)} ${c(e)}: ${a(t)}`)}console.log()}if(m.didAutoInit||m.didGitInit)if(m.didGitInit&&console.log(`\n ${s(`✓`)} Initialized git repo at ${u}/.git/ (default branch: main)`),m.didAutoInit)try{let{previewContent:e,formatPreviewBlock:t}=await import(`./preview-D6fWJCDu.mjs`),n=e({projectDir:u,contentDir:m.contentDir,include:l.content.include,exclude:l.content.exclude});console.log(`\n${t(n,u)}\n`)}catch(e){console.warn(`Content preview unavailable: ${e instanceof Error?e.message:String(e)}`)}else console.log();if(e.open){let{openBrowser:e}=await import(`./open-browser-hvFa-TeR.mjs`);e(x)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})})}export{f as a,d as i,h as n,g as o,m as r,u as s,p as t};
|
|
2
|
-
//# sourceMappingURL=start-D5tAdx92.mjs.map
|
package/dist/start-DG0Lr5vX.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./start-D5tAdx92.mjs";export{e as startCommand};
|