@inkeep/open-knowledge 0.0.0-dev-20260428055023 → 0.0.0-dev-20260428063152
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/cli.mjs +9 -9
- package/dist/constants-Dvx0Ir4Z.mjs +2 -0
- package/dist/{dist-DoVDgyml.mjs → dist-6JXIwkTW.mjs} +6 -6
- package/dist/dist-Rkr9VTaR.mjs +1 -0
- package/dist/index.d.mts +17 -1
- package/dist/index.mjs +1 -1
- package/dist/{init-DNs9ffRY.mjs → init-0_AyRou2.mjs} +25 -25
- package/dist/init-6aL4nNLi.mjs +1 -0
- package/dist/{init-DVCAi_du.mjs → init-BrxpN5Ku.mjs} +2 -2
- package/dist/init-DSlKInSe.mjs +1 -0
- package/dist/loader-BKi1CcCu.mjs +1 -0
- package/dist/{loader-C9LBHYiT.mjs → loader-Dt0KH_I_.mjs} +2 -2
- package/dist/{paths-zc2uvZxY.mjs → paths-3Ss4Y-ca.mjs} +2 -2
- package/dist/paths-CUrzOOI7.mjs +1 -0
- package/dist/{preview-CPxqdDCe.mjs → preview-CYJ8l4Py.mjs} +2 -2
- package/dist/preview-yvwsGk-r.mjs +1 -0
- package/dist/server-lock-n3Y5JWNv-3o7br8XE.mjs +2 -0
- package/dist/server-lock-n3Y5JWNv-DXpg9_eU.mjs +1 -0
- package/dist/src-I5zW2G1z.mjs +1 -0
- package/dist/start-5b45Y8cg.mjs +1 -0
- package/dist/{start-BnROvKwD.mjs → start-BPdIGn_L.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-D9m8dzHP.mjs +0 -2
- package/dist/dist-CC_QsyED.mjs +0 -1
- package/dist/init-D-fChIzY.mjs +0 -1
- package/dist/init-D3711KPb.mjs +0 -1
- package/dist/loader-Bc5pJk1m.mjs +0 -1
- package/dist/paths-CDgE-NKk.mjs +0 -1
- package/dist/preview-EfkiZS-n.mjs +0 -1
- package/dist/server-lock-QiPvrcO9-A3jWEIJ6.mjs +0 -2
- package/dist/server-lock-QiPvrcO9-CB330FUa.mjs +0 -1
- package/dist/src-CccGTsc2.mjs +0 -1
- package/dist/start-DdFbQnn0.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./esm-29fM6BBO.mjs";import{r as t}from"./constants-
|
|
1
|
+
import{t as e}from"./esm-29fM6BBO.mjs";import{r as t}from"./constants-Dvx0Ir4Z.mjs";import{p as n}from"./dist-DRC09WNZ.mjs";import{Y as r,Z as i,_ as a,lt as o}from"./dist-6JXIwkTW.mjs";import{n as s}from"./init-BrxpN5Ku.mjs";import{t as c}from"./preview-CYJ8l4Py.mjs";import{s as l,t as u}from"./colors-DoPZvo1q.mjs";import{t as d}from"./is-object-BNVklKxg.mjs";import{basename as f,dirname as p,join as m,posix as h,relative as g,resolve as _,sep as v,win32 as y}from"node:path";import{existsSync as b,mkdirSync as x,readFileSync as S,writeFileSync as C}from"node:fs";import{homedir as w}from"node:os";
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -26,9 +26,9 @@ import{t as e}from"./esm-29fM6BBO.mjs";import{r as t}from"./constants-D9m8dzHP.m
|
|
|
26
26
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
27
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
28
|
*/
|
|
29
|
-
function
|
|
29
|
+
function ee(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function te(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
|
|
30
30
|
`,e===t&&(i+=` `.repeat(a+n+2),i+=`^
|
|
31
|
-
`))}return i}var
|
|
31
|
+
`))}return i}var T=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=ee(t.toml,t.ptr),i=te(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
|
|
32
32
|
/*!
|
|
33
33
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
34
34
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -56,14 +56,14 @@ function te(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop()
|
|
|
56
56
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
57
57
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
58
58
|
*/
|
|
59
|
-
function
|
|
60
|
-
`,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function
|
|
59
|
+
function ne(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}function E(e,t=0,n=e.length){let r=e.indexOf(`
|
|
60
|
+
`,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function D(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
|
|
61
61
|
`)return n;if(r===`\r`&&e[n+1]===`
|
|
62
|
-
`)return n+1;if(r<` `&&r!==` `||r===``)throw new
|
|
62
|
+
`)return n+1;if(r<` `&&r!==` `||r===``)throw new T(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function O(e,t,n,r){let i;for(;;){for(;(i=e[t])===` `||i===` `||!n&&(i===`
|
|
63
63
|
`||i===`\r`&&e[t+1]===`
|
|
64
|
-
`);)t++;if(r||i!==`#`)break;t=
|
|
64
|
+
`);)t++;if(r||i!==`#`)break;t=D(e,t)}return t}function re(e,t,n,r,i=!1){if(!r)return t=E(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=E(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
|
|
65
65
|
`||t===`\r`&&e[a+1]===`
|
|
66
|
-
`))return a}throw new
|
|
66
|
+
`))return a}throw new T(`cannot find end of structure`,{toml:e,ptr:t})}function k(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do t=e.indexOf(r,++t);while(t>-1&&n!==`'`&&ne(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}
|
|
67
67
|
/*!
|
|
68
68
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
69
69
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -91,7 +91,7 @@ function re(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}function T(e,t=0,
|
|
|
91
91
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
92
92
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
93
93
|
*/
|
|
94
|
-
let
|
|
94
|
+
let ie=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var ae=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(ie);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
|
|
95
95
|
/*!
|
|
96
96
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
97
97
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -119,13 +119,13 @@ let ae=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]
|
|
|
119
119
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
120
120
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
121
121
|
*/
|
|
122
|
-
let
|
|
122
|
+
let oe=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,se=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,ce=/^[+-]?0[0-9_]/,le=/^[0-9a-f]{2,8}$/i,ue={b:`\b`,t:` `,n:`
|
|
123
123
|
`,f:`\f`,r:`\r`,e:`\x1B`,'"':`"`,"\\":`\\`};function de(e,t=0,n=e.length){let r=e[t]===`'`,i=e[t++]===e[t]&&e[t]===e[t+1];i&&(n-=2,e[t+=2]===`\r`&&t++,e[t]===`
|
|
124
124
|
`&&t++);let a=0,o,s=``,c=t;for(;t<n-1;){let n=e[t++];if(n===`
|
|
125
125
|
`||n===`\r`&&e[t]===`
|
|
126
|
-
`){if(!i)throw new
|
|
127
|
-
`||n===` `||n===` `||n===`\r`)){if(t=
|
|
128
|
-
`&&e[t]!==`\r`)throw new
|
|
126
|
+
`){if(!i)throw new T(`newlines are not allowed in strings`,{toml:e,ptr:t-1})}else if(n<` `&&n!==` `||n===``)throw new T(`control characters are not allowed in strings`,{toml:e,ptr:t-1});if(o){if(o=!1,n===`x`||n===`u`||n===`U`){let r=e.slice(t,t+=n===`x`?2:n===`u`?4:8);if(!le.test(r))throw new T(`invalid unicode escape`,{toml:e,ptr:a});try{s+=String.fromCodePoint(parseInt(r,16))}catch{throw new T(`invalid unicode escape`,{toml:e,ptr:a})}}else if(i&&(n===`
|
|
127
|
+
`||n===` `||n===` `||n===`\r`)){if(t=O(e,t-1,!0),e[t]!==`
|
|
128
|
+
`&&e[t]!==`\r`)throw new T(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:a});t=O(e,t)}else if(n in ue)s+=ue[n];else throw new T(`unrecognized escape sequence`,{toml:e,ptr:a});c=t}else !r&&n===`\\`&&(a=t-1,o=!0,s+=e.slice(c,a))}return s+e.slice(c,n-1)}function fe(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=oe.test(e);if(i||se.test(e)){if(ce.test(e))throw new T(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new T(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new T(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new ae(e);if(!a.isValid())throw new T(`invalid value`,{toml:t,ptr:n});return a}
|
|
129
129
|
/*!
|
|
130
130
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
131
131
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -153,8 +153,8 @@ let se=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,ce=/^[+-]?
|
|
|
153
153
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
154
154
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
155
155
|
*/
|
|
156
|
-
function pe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(
|
|
157
|
-
`&&e[o]!==`\r`)throw new
|
|
156
|
+
function pe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(D(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function A(e,t,n,r,i){if(r===0)throw new T(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?ge(e,t,r,i):he(e,t,r,i);if(n){if(s=O(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new T(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}let o;if(a===`"`||a===`'`){o=k(e,t);let r=de(e,t,o);if(n){if(o=O(e,o),e[o]&&e[o]!==`,`&&e[o]!==n&&e[o]!==`
|
|
157
|
+
`&&e[o]!==`\r`)throw new T(`unexpected character encountered`,{toml:e,ptr:o});o+=+(e[o]===`,`)}return[r,o]}o=re(e,t,`,`,n);let s=pe(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new T(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=O(e,t+s[1]),o+=+(e[o]===`,`)),[fe(s[0],e,t,i),o]}
|
|
158
158
|
/*!
|
|
159
159
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
160
160
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -182,9 +182,9 @@ function pe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(E(e,i),r=r.
|
|
|
182
182
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
183
183
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
184
184
|
*/
|
|
185
|
-
let me=/^[a-zA-Z0-9-_]+[ \t]*$/;function j(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new
|
|
186
|
-
`&&o!==`\r`){let o,s=i,c=!1,[l,u]=j(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new
|
|
187
|
-
`&&a!==`\r`){let a=A(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new
|
|
185
|
+
let me=/^[a-zA-Z0-9-_]+[ \t]*$/;function j(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new T(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `)if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new T(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let s=k(e,t);if(s<0)throw new T(`unfinished string encountered`,{toml:e,ptr:t});r=e.indexOf(`.`,s);let c=e.slice(s,r<0||r>a?a:r),l=E(c);if(l>-1)throw new T(`newlines are not allowed in keys`,{toml:e,ptr:t+r+l});if(c.trimStart())throw new T(`found extra tokens after the string part`,{toml:e,ptr:s});if(a<s&&(a=e.indexOf(n,s),a<0))throw new T(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(de(e,t,s))}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!me.test(n))throw new T(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}while(r+1&&r<a);return[i,O(e,a+1,!0,!0)]}function he(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new T(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=D(e,t);else if(o!==` `&&o!==` `&&o!==`
|
|
186
|
+
`&&o!==`\r`){let o,s=i,c=!1,[l,u]=j(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new T(`trying to redefine an already defined value`,{toml:e,ptr:t});!c&&o===`__proto__`&&Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new T(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=A(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new T(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function ge(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new T(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=D(e,t);else if(a!==` `&&a!==` `&&a!==`
|
|
187
|
+
`&&a!==`\r`){let a=A(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new T(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}
|
|
188
188
|
/*!
|
|
189
189
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
190
190
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -212,8 +212,8 @@ let me=/^[a-zA-Z0-9-_]+[ \t]*$/;function j(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf
|
|
|
212
212
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
213
213
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
214
214
|
*/
|
|
215
|
-
function M(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function _e(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=
|
|
216
|
-
`&&e[s]!==`\r`)throw new
|
|
215
|
+
function M(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function _e(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=O(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=j(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new T(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=M(n[0],r,i,t?2:1);if(!c)throw new T(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=j(e,s),i=M(r[0],a,o,0);if(!i)throw new T(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=A(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=O(e,s,!0),e[s]&&e[s]!==`
|
|
216
|
+
`&&e[s]!==`\r`)throw new T(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=O(e,s)}return r}
|
|
217
217
|
/*!
|
|
218
218
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
219
219
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -247,8 +247,8 @@ let N=/^[a-z0-9-_]+$/i;function P(e){let t=typeof e;if(t===`object`){if(Array.is
|
|
|
247
247
|
`)+L(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=I(t[c],e,r,i),a+=`
|
|
248
248
|
`}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Se(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(P(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=L(0,e,``,t,n);return r[r.length-1]===`
|
|
249
249
|
`?r:r+`
|
|
250
|
-
`}const R=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],Ce=[`@inkeep/open-knowledge`,`mcp`],we={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function z(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=
|
|
251
|
-
`)?n:`${n}\n`,`utf-8`)}const Fe=`0.0.1`,X=`open-knowledge-ui`;function Ie(e,t={}){let n=m(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[z(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!
|
|
252
|
-
`)}function $(e,t){let n=[];for(let r of R)Z(Y[r],e,t)&&n.push(r);return n}function He(){return new e(`init`).description(`Scaffold ${n}/ 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 ${n}/ 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`).action(async e=>{let t=process.cwd(),n;try{n=await Be({cwd:t,mcp:e.mcp,devMcp:e.devMcp})}catch(e){if(e instanceof
|
|
253
|
-
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-
|
|
254
|
-
//# sourceMappingURL=init-
|
|
250
|
+
`}const R=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],Ce=[`@inkeep/open-knowledge`,`mcp`],we={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function z(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=_(e);if(f(t)===`cli.mjs`&&f(p(t))===`dist`)return t;let n=t.split(v),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 m(i.length===0?v:i.join(v),`packages`,`cli`,`dist`,`cli.mjs`)}function B(e={}){if(e.cliPath)return{command:e.cliPath,args:[`mcp`]};if(e.mode===`pinned`){let t=e.cliEntryPath??process.argv[1];if(!t)throw Error("Cannot pin MCP entry — process.argv[1] is empty. Pass --no-pin to use the default `npx` entry.");return{command:`node`,args:[_(t),`mcp`]}}return e.mode===`dev`?{command:`node`,args:[z(e.cliEntryPath),`mcp`],env:{...we}}:{command:`npx`,args:[...Ce]}}function V(e){return e===`win32`?y:h}function Te(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env,i=V(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 Ee(e={}){let t=e.platformName??process.platform,n=e.home??w();return V(t).join(n,`.claude.json`)}function H(e={}){let t=e.platformName??process.platform,n=e.home??w(),r=e.env??process.env;if(t===`darwin`)return h.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??y.join(n,`AppData`,`Roaming`);return y.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??w();return V(t).join(n,`.cursor`,`mcp.json`)}function W(e={}){return V(e.platformName??process.platform).join(Te(e),`Code`,`User`,`mcp.json`)}function G(e={}){let t=e.platformName??process.platform,n=e.home??w();return V(t).join(n,`.codeium`,`windsurf`,`mcp_config.json`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??w();return(e.env??process.env).CODEX_HOME??V(t).join(n,`.codex`)}function K(e={}){return V(e.platformName??process.platform).join(De(e),`config.toml`)}function q(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>q(e,t[n]));if(d(e)&&d(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=>q(e[n],t[n]))}return!1}function Oe(e,t){return Object.entries(t).every(([t,n])=>q(e[t],n))}function ke(e,t){return{...e,...t}}function J(e){return{...e,isCompatible(t,n,r){return Oe(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return ke(t,e.buildEntry(n,r))}}}const Y={claude:J({id:`claude`,label:`Claude Code`,configPath:(e,t)=>Ee({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>m(t??w(),`.claude`),legacyProjectConfigPath:e=>m(e,`.mcp.json`)}),"claude-desktop":J({id:`claude-desktop`,label:`Claude Desktop`,configPath:(e,t)=>H({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(H({home:t}))}),cursor:J({id:`cursor`,label:`Cursor`,configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(U({home:t})),legacyProjectConfigPath:e=>m(e,`.cursor`,`mcp.json`)}),vscode:J({id:`vscode`,label:`VS Code`,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`servers`,serverName:()=>t,buildEntry:(e,t)=>({type:`stdio`,...B(t)}),scope:`global`,detectPath:(e,t)=>p(W({home:t})),legacyProjectConfigPath:e=>m(e,`.vscode`,`mcp.json`)}),windsurf:J({id:`windsurf`,label:`Windsurf`,configPath:(e,t)=>G({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(G({home:t}))}),codex:J({id:`codex`,label:`Codex`,configPath:(e,t)=>K({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>t,buildEntry:(e,t)=>B(t),scope:`global`,detectPath:(e,t)=>p(K({home:t})),legacyProjectConfigPath:e=>m(e,`.codex`,`config.toml`)})};function Ae(e){let t=e.filter(e=>!(e in Y));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${R.join(`, `)}`);return e.map(e=>Y[e])}function je(e){if(!b(e))return{};let t=S(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(d(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 Me(e){if(!b(e))return{};let t=S(e,`utf-8`).trim();if(t===``)return{};try{let n=_e(t);if(d(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 Ne(e,t){x(p(e),{recursive:!0}),C(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function Pe(e,t){x(p(e),{recursive:!0});let n=Se(t);C(e,n.endsWith(`
|
|
251
|
+
`)?n:`${n}\n`,`utf-8`)}const Fe=`0.0.1`,X=`open-knowledge-ui`;function Ie(e,t={}){let n=m(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[z(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!b(n))return x(p(n),{recursive:!0}),C(n,`${JSON.stringify({version:Fe,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let e=S(n,`utf-8`).trim(),t=e?JSON.parse(e):{};if(!d(t))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let i=Array.isArray(t.configurations)?t.configurations:[],a=i.findIndex(e=>d(e)&&e.name===X);a>=0?i[a]=r:i.push(r);let o={...t,version:t.version??Fe,configurations:i};return C(n,`${JSON.stringify(o,null,2)}\n`,`utf-8`),{action:a>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function Z(e,t,n){try{return b(e.detectPath?.(t,n)??p(e.configPath(t,n)))}catch{return!1}}function Q(e,t,n,r){let i=e.serverName(t),a;try{a=e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:i,error:t instanceof Error?t.message:String(t)}}if(!n.skipAvailabilityCheck&&!Z(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:a,serverName:i};let o;try{o=e.format===`toml`?Me(a):je(a)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}let s=o[e.topLevelKey]??{},c=s[i],l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}let u={...o,[e.topLevelKey]:{...s,[i]:l}};try{e.format===`toml`?Pe(a,u):Ne(a,u)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:c===void 0?`written`:`overwritten`,configPath:a,serverName:i}}function Le(e,t){let n=e.legacyProjectConfigPath?.(t);if(!(!n||!b(n)))return{editorId:e.id,label:e.label,path:n}}async function Re(e){let t=Ae(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Q(t,``,n,e.home))}function ze(e,t,n){let r;try{r=e.configPath(t,n)}catch{return null}let i;try{i=e.format===`toml`?Me(r):je(r)}catch{return null}let a=i[e.topLevelKey];if(!d(a))return null;let o=a[e.serverName(t)];return d(o)?o:null}async function Be(e={}){let t=_(e.cwd??process.cwd()),n={mode:e.pin?`pinned`:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},a=await i(t),c;try{c=s(t)}catch(n){let r=Y.claude.configPath(t,e.home);return{contentCreated:[],contentSkipped:[],editors:[],legacyProjectConfigs:[],didGitInit:a.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:r,mcpError:`Content scaffolding failed: ${n instanceof Error?n.message:String(n)}`}}let l=Ae(e.editors??$(t,e.home)),u=l.filter(n=>Z(n,t,e.home)),d=[];for(let r of l){if(e.mcp===!1){let n=``;try{n=r.configPath(t,e.home)}catch{}d.push({editorId:r.id,label:r.label,action:`skipped-flag`,configPath:n,serverName:r.serverName(t)});continue}d.push(Q(r,t,n,e.home))}let f=e.mcp===!1?[]:u.map(e=>Le(e,t)).filter(e=>e!==void 0),p=u.some(e=>e.id===`claude`)&&e.mcp!==!1?Ie(t,n):void 0,m=await(e.installUserSkill??o)({home:e.home}),h=r({home:e.home}),g=e.mcp===!1?`skipped-flag`:`skipped-missing`,v=d.find(e=>e.editorId===`claude`)??d[0]??{action:g,configPath:Y.claude.configPath(t,e.home)};return{contentCreated:c.created,contentSkipped:c.skipped,editors:d,legacyProjectConfigs:f,launchJson:p,skillInstall:m,didGitInit:a.didInit,claudeDesktopDetected:h,mcpAction:v.action,mcpPath:v.configPath,mcpError:`error`in v?v.error:void 0}}function Ve(e,t){let r=[],i=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),a=e.editors.some(e=>e.action===`failed`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),s=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),d=e=>{let n=e.configPath.startsWith(t)?g(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&r.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let f=m(t,n);if(e.contentCreated.length>0?(r.push(`Content scaffolded at ${f}/`),r.push(` Created: ${e.contentCreated.join(`, `)}`)):r.push(`Content already present at ${f}/`),e.contentSkipped.length>0&&r.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),r.push(``),e.mcpError&&e.editors.length===0)r.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)r.push(`MCP server configuration:`),r.push(e.mcpAction===`skipped-flag`?` MCP config not written — use without --no-mcp to configure editors`:` No supported editor config directories detected; skipped MCP registration`);else if(o)r.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)r.push(`MCP server configuration:`),r.push(` No supported editor config directories detected; skipped MCP registration`);else{r.push(`MCP server configuration:`);for(let n of e.editors){let i=n.configPath.startsWith(t)?g(t,n.configPath):n.configPath.replace(/^\/Users\/[^/]+/,`~`),a=n.serverName===`open-knowledge`?``:` (${n.serverName})`,o=` `.repeat(Math.max(1,14-n.label.length)),s=n.editorId===`claude-desktop`&&(n.action===`written`||n.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(n.action){case`written`:r.push(` ${n.label}${o}${i} registered${a}${s}`);break;case`overwritten`:r.push(` ${n.label}${o}${i} updated${a}${s}`);break;case`skipped-missing`:r.push(` ${n.label}${o}${i} config root missing; skipped`);break;case`failed`:r.push(` ${n.label}${o}${i} FAILED: ${n.error}`);break;case`skipped-flag`:break}n.editorId===`claude`&&e.launchJson&&r.push(d(e.launchJson))}}if(a&&(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 n of e.legacyProjectConfigs)r.push(` ${n.label} ${g(t,n.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.skillInstall)switch(r.push(``),r.push(`User-global skill:`),e.skillInstall){case`installed`:r.push(" open-knowledge installed to detected agent hosts via `npx skills`");break;case`skip-current`:r.push(` open-knowledge already installed at current version`);break;case`failed`:r.push(` ${l(`open-knowledge install failed — MCP still configured; run manually:`)}`),r.push(` ${l(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(r.push(``),r.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${u(`ok install-skill`)}`)),e.preview?(r.push(``),r.push(c(e.preview,t))):e.previewWarning&&(r.push(``),r.push(`Content preview unavailable: ${e.previewWarning}`)),i){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. (Optional) scaffold the starter knowledge-base structure:`),r.push(` - ok seed`),r.push(` 4. Use the three MCP workflow tools as you build the wiki:`),r.push(` - mcp__open-knowledge__ingest — capture an external source`),r.push(` - mcp__open-knowledge__research — gather sources and write findings`),r.push(` - mcp__open-knowledge__consolidate — promote research to canonical articles`)}return r.join(`
|
|
252
|
+
`)}function $(e,t){let n=[];for(let r of R)Z(Y[r],e,t)&&n.push(r);return n}function He(){return new e(`init`).description(`Scaffold ${n}/ 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 ${n}/ 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(`--pin`,"Pin the MCP entry to the absolute path of the current CLI binary instead of `npx`. Use a stable shim like /usr/local/bin/ok for upgrade-safe pinning; npx-cache or worktree paths will go stale on reinstall.").option(`--no-pin`,"Use the default unpinned `npx @inkeep/open-knowledge mcp` MCP entry").action(async e=>{let t=process.cwd(),n;try{n=await Be({cwd:t,mcp:e.mcp,devMcp:e.devMcp,pin:e.pin})}catch(e){if(e instanceof a){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
|
|
253
|
+
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-yvwsGk-r.mjs`),{loadConfig:r}=await import(`./loader-BKi1CcCu.mjs`),{resolveContentDir:i}=await import(`./paths-CUrzOOI7.mjs`),{config:a}=r(t),o=i(a,t);n.preview=e({projectDir:t,contentDir:o,include:a.content.include,exclude:a.content.exclude})}catch(e){n.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${Ve(n,t)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{Be as a,R as c,ze as i,Y as l,Ve as n,Q as o,He as r,Re as s,$ as t};
|
|
254
|
+
//# sourceMappingURL=init-0_AyRou2.mjs.map
|
|
@@ -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-0_AyRou2.mjs";export{o as detectInstalledEditors,n as formatInitResult,i as initCommand,t as readExistingMcpEntry,e as runInit,r as writeEditorMcpConfig,a as writeUserMcpConfigs};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,t}from"./constants-
|
|
1
|
+
import{n as e,t}from"./constants-Dvx0Ir4Z.mjs";import{p as n}from"./dist-DRC09WNZ.mjs";import{join as r,resolve as i}from"node:path";import{existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";const l=`# Open Knowledge — workspace configuration
|
|
2
2
|
#
|
|
3
3
|
# This file overrides built-in defaults for this workspace. Every key below
|
|
4
4
|
# is commented out and shows its current default value. Uncomment any key
|
|
@@ -117,4 +117,4 @@ import{n as e,t}from"./constants-D9m8dzHP.mjs";import{p as n}from"./dist-DRC09WN
|
|
|
117
117
|
|
|
118
118
|
`)?`
|
|
119
119
|
`:``}${i}`,`utf-8`),`appended`)}const f=[{name:`.gitignore`,content:`${t}/\nserver.lock\nui.lock\nsync-state.json\n`},{name:e,content:l}];function p(e){let a=i(e,n),s=[],c=[];o(a,{recursive:!0}),o(r(a,t),{recursive:!0});for(let e of f)u(r(a,e.name),e.content)?s.push(e.name):c.push(e.name);return{created:s,skipped:c}}export{p as n,d as t};
|
|
120
|
-
//# sourceMappingURL=init-
|
|
120
|
+
//# sourceMappingURL=init-BrxpN5Ku.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./init-BrxpN5Ku.mjs";export{t as ensureOkGitignoredAtRoot,e as initContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-Dt0KH_I_.mjs";export{e as loadConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./dist-BCyi1oM7.mjs";import{n as t}from"./constants-
|
|
1
|
+
import{t as e}from"./dist-BCyi1oM7.mjs";import{n as t}from"./constants-Dvx0Ir4Z.mjs";import{B as n,K as r,Z as i,et as a,p as o,q as s,z as c}from"./dist-DRC09WNZ.mjs";import{t as l}from"./is-object-BNVklKxg.mjs";import{resolve as u}from"node:path";import{existsSync as d,readFileSync as f}from"node:fs";import{homedir as p}from"node:os";import{realpath as m}from"node:fs/promises";async function h(e){let t=u(e);try{return await m(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 g=s({title:i().optional(),description:i().optional(),tags:c(i()).optional()}).strict(),_=s({match:i().min(1,"`match` must be a non-empty glob pattern (e.g. 'specs/**' or 'reports/*/**')"),frontmatter:g}).strict(),v=s({content:s({dir:i().default(`.`),include:c(i()).min(1).default([`**/*.md`,`**/*.mdx`]),exclude:c(i()).default([])}).default({dir:`.`,include:[`**/*.md`,`**/*.mdx`],exclude:[]}),github:s({oauthAppClientId:i().default(`Ov23liqlSd0V1MwR6rhI`)}).default({oauthAppClientId:`Ov23liqlSd0V1MwR6rhI`}),sync:s({enabled:n().optional(),pushIntervalSeconds:r().int().min(1).default(60),pullIntervalSeconds:r().int().min(1).default(30),autoCommit:n().default(!0),autoPush:n().default(!0),autoPull:n().default(!0),commitMessage:i().default(`auto`)}).default({pushIntervalSeconds:60,pullIntervalSeconds:30,autoCommit:!0,autoPush:!0,autoPull:!0,commitMessage:`auto`}),server:s({port:r().int().min(0).max(65535).default(0),host:i().regex(/^[\w.\-:]+$/,`Invalid hostname`).default(`localhost`),openOnAgentEdit:n().default(!1)}).default({port:0,host:`localhost`,openOnAgentEdit:!1}),persistence:s({debounceMs:r().int().min(0).default(2e3),maxDebounceMs:r().int().min(0).default(1e4)}).default({debounceMs:2e3,maxDebounceMs:1e4}),preview:s({baseUrl:a().optional()}).default({}),folders:c(_).default([]),mcp:s({autoStart:n().default(!0),tools:s({read_document:s({historyDepth:r().int().min(0).default(5)}).default({historyDepth:5}),search:s({maxResults:r().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}}})});var y=e();function b(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];l(a)&&l(i)?n[r]=b(i,a):a!==void 0&&(n[r]=a)}return n}function x(e){if(!d(e))return null;try{let t=(0,y.parse)(f(e,`utf-8`));return l(t)?t:null}catch(t){return console.warn(`[config] Failed to parse ${e}: ${t instanceof Error?t.message:t}`),null}}function S(e){let n=e??process.cwd(),r=[],i=u(p(),o,t),a={},s=x(i);s&&(a=b(a,s),r.push(i));let c=u(n,o,t),l=x(c);l&&(a=b(a,l),r.push(c));let d=v.safeParse(a);if(!d.success){let e=d.error.issues.map(e=>` ${e.path.join(`.`)}: ${e.message}`);throw Error(`Invalid configuration:\n${e.join(`
|
|
2
2
|
`)}`)}return{config:d.data,sources:r}}function C(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 w(e){let t=e.env??process.env,n=e.cacheMs??1e3,r=e.loadConfigFn??S,i=new Map,a=new Map,o=h(e.startupCwd);return async s=>{let c=await h(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=C(e.startupConfig,t);return i.set(c,{config:r,expiresAt:Date.now()+n}),r}let a=C(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{h as i,S as n,v as r,w as t};
|
|
3
|
-
//# sourceMappingURL=loader-
|
|
3
|
+
//# sourceMappingURL=loader-Dt0KH_I_.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./constants-
|
|
2
|
-
//# sourceMappingURL=paths-
|
|
1
|
+
import"./constants-Dvx0Ir4Z.mjs";import{p as e}from"./dist-DRC09WNZ.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-3Ss4Y-ca.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./paths-3Ss4Y-ca.mjs";export{t as resolveContentDir,e as resolveLockDir};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"./constants-
|
|
1
|
+
import"./constants-Dvx0Ir4Z.mjs";import{p as e}from"./dist-DRC09WNZ.mjs";import{W as t}from"./dist-6JXIwkTW.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
2
|
`)}export{l as n,u as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-CYJ8l4Py.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-CYJ8l4Py.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-wcPFST8Q-BB0WpHs3.mjs";import{dirname as t,resolve as n}from"node:path";import{closeSync as r,existsSync as i,mkdirSync as a,openSync as o,readFileSync as s,unlinkSync as c,writeFileSync as l,writeSync as u}from"node:fs";import{hostname as d}from"node:os";import{fileURLToPath as f}from"node:url";function p(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function m(){try{let e=n(t(f(import.meta.url)),`..`,`package.json`),r=JSON.parse(s(e,`utf-8`));if(typeof r.version==`string`&&r.version.length>0)return r.version}catch{}return`0.0.0-unknown`}const h=m();var g=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 _(e,t){return n(e,`${t}.lock`)}const v=new Map;function y(e){v.set(e,(v.get(e)??0)+1)}function b(e){let t=v.get(e);return t===void 0||t<=1?(v.delete(e),!0):(v.set(e,t-1),!1)}function x(e,t){try{let n=JSON.parse(s(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 S(e){let{lockName:t,lockDir:n,metadata:s}=e,f=`[${t}-lock]`;a(n,{recursive:!0});let m=_(n,t),v={pid:process.pid,hostname:d(),port:s.port,startedAt:new Date().toISOString(),worktreeRoot:s.worktreeRoot,...s.kind!==void 0&&{kind:s.kind},...s.parentPid!==void 0&&{parentPid:s.parentPid},...s.capabilities!==void 0&&{capabilities:s.capabilities},protocolVersion:s.protocolVersion??1,runtimeVersion:s.runtimeVersion??h},b=JSON.stringify(v,null,2);for(let e=0;e<3;e++){if(!i(m))try{let e=o(m,`wx`,384);try{u(e,b)}finally{r(e)}return y(m),C({lockName:t,lockDir:n,lockPath:m})}catch(e){if(e.code!==`EEXIST`)throw e}let e=x(m,f);if(e){let r=e.hostname===d();if(r&&e.pid===process.pid)return l(m,b,{encoding:`utf-8`,mode:384}),y(m),C({lockName:t,lockDir:n,lockPath:m});if(r&&p(e.pid))throw new g(e,m,t);console.warn(`${f} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{c(m)}catch{}}throw Error(`${f} Failed to acquire ${m} after 3 attempts (concurrent acquire contention).`)}function C(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>E({lockName:t,lockDir:n}),updatePort:e=>w({lockName:t,lockDir:n,port:e})}}function w(e){let{lockName:t,lockDir:n,port:r}=e,a=`[${t}-lock]`,o=_(n,t);if(!i(o)){console.warn(`${a} Lock file missing at ${o} during port update — skipping`);return}let c;try{let e=JSON.parse(s(o,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`){console.warn(`${a} Corrupt lock at ${o} during port update — skipping`);return}c=e}catch{console.warn(`${a} Unreadable lock at ${o} during port update — skipping`);return}if(c.pid===process.pid&&!(typeof c.hostname==`string`&&c.hostname!==d())){c.port=r;try{l(o,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${a} Failed to update port in ${o}: ${e instanceof Error?e.message:String(e)}`)}}}function T(e){let{lockName:t,lockDir:n}=e,r=_(n,t);if(!i(r))return null;let a;try{let e=JSON.parse(s(r,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`)return null;a=e}catch{return null}if(a.hostname!==d())return null;if(!p(a.pid)){try{c(r)}catch{}return null}return a}function E(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,a=_(n,t);if(b(a)&&i(a))try{let e=JSON.parse(s(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==d())return;c(a)}catch(e){console.warn(`${r} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}var D=e({ServerLockCollisionError:()=>O,acquireServerLock:()=>k,readServerLock:()=>j,releaseServerLock:()=>M,updateServerLockPort:()=>A}),O=class extends g{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function k(e,t){try{return S({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof g&&e.lockName===`server`?new O(e.existing,e.lockPath):e}}function A(e,t){w({lockName:`server`,lockDir:e,port:t})}function j(e){return T({lockName:`server`,lockDir:e})}function M(e){E({lockName:`server`,lockDir:e})}export{k as a,T as c,M as d,D as f,S as i,j as l,A as m,h as n,p as o,w as p,O as r,_ as s,g as t,E as u};
|
|
2
|
+
//# sourceMappingURL=server-lock-n3Y5JWNv-3o7br8XE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as e}from"./server-lock-n3Y5JWNv-3o7br8XE.mjs";export{e as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./init-0_AyRou2.mjs";import"./loader-Dt0KH_I_.mjs";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./start-BPdIGn_L.mjs";export{e as startCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./esm-29fM6BBO.mjs";import{i as t}from"./constants-
|
|
2
|
-
//# sourceMappingURL=start-
|
|
1
|
+
import{t as e}from"./esm-29fM6BBO.mjs";import{i as t}from"./constants-Dvx0Ir4Z.mjs";import{p as n}from"./dist-DRC09WNZ.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:t,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-Rkr9VTaR.mjs`),{resolveContentDir:b}=await import(`./paths-CUrzOOI7.mjs`),x=e.log??_(`start`),S=b(t,r);s(S)||(c(S,{recursive:!0}),x.info({contentDir:S},`Created content directory`));let C=!s(u(r,n)),w=i?void 0:async()=>{try{let{initContent:e}=await import(`./init-DSlKInSe.mjs`),t=e(r);return C||t.created.length>0}catch(e){return console.warn(`Auto-init failed:`,e instanceof Error?e.message:e),!1}},T=!1,E=u(S,n),D=t.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-BzMQ6cLf.mjs`).then(({openBrowser:e})=>e(t)).catch(()=>{})}:void 0,O=null,k=await h({contentDir:S,projectDir:r,contentRoot:t.content.dir,port:t.server.port,host:t.server.host,quiet:!1,debounce:t.persistence.debounceMs,maxDebounce:t.persistence.maxDebounceMs,includePatterns:t.content.include,excludePatterns:t.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 ${n}/`).action(async e=>{let{renderBanner:i}=await import(`./banner-BxI1wnW9.mjs`),{dim:a,error:o,info:s,warning:c}=await import(`./colors-BnZ-i-vb.mjs`),l=r(),u=process.cwd();e.port!==void 0&&(l.server.port=Number(e.port)),e.host!==void 0&&(l.server.host=e.host);let d;try{d=await h({config:l,cwd:u,skipAutoInit:e.init===!1})}catch(e){let{ProjectGitInitError:t}=await import(`./dist-Rkr9VTaR.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 f=!1,p=async e=>{if(!f){f=!0,console.log(a(`\nShutting down (${e})...`));try{await d.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`,()=>{p(`SIGINT`)}),process.once(`SIGTERM`,()=>{p(`SIGTERM`)});let m=`http://${l.server.host}:${d.port}`,g=l.server.host===`0.0.0.0`||l.server.host===`::`?`http://0.0.0.0:${d.port}`:void 0,_=d.resolvedUiPort,v=_!==null&&_>0?`http://${l.server.host}:${_}`:m;console.log(i({name:`open-knowledge`,version:t,localUrl:v,apiUrl:v===m?void 0:m,networkUrl:g})),d.didAutoInit&&(console.log(` ${s(`✓`)} Scaffolded ${n}/ (first run)`),console.log(` ${a("Tip: Run `open-knowledge init` to register MCP tools for Claude Code")}\n`));let y={"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`};d.ready.then(async()=>{if(d.degraded.length>0){console.log();for(let e of d.degraded){let t=y[e]??`${e} (check server logs for details)`;console.warn(` ${c(`⚠`)} ${c(e)}: ${a(t)}`)}console.log()}if(d.didAutoInit||d.didGitInit)if(d.didGitInit&&console.log(`\n ${s(`✓`)} Initialized git repo at ${u}/.git/ (default branch: main)`),d.didAutoInit)try{let{previewContent:e,formatPreviewBlock:t}=await import(`./preview-yvwsGk-r.mjs`),n=e({projectDir:u,contentDir:d.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-BzMQ6cLf.mjs`);e(v)}}).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-BPdIGn_L.mjs.map
|
package/package.json
CHANGED
package/dist/dist-CC_QsyED.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-DRC09WNZ.mjs";import{a as e,c as t}from"./server-lock-QiPvrcO9-A3jWEIJ6.mjs";import{A as n,Bt as r,St as i,T as a,X as o,_ as s,q as c,vt as l,w as u}from"./dist-DoVDgyml.mjs";export{s as ProjectGitInitError,u as UiLockCollisionError,a as acquireUiLock,n as bootServer,c as ensureProjectGit,o as getLogger,e as isProcessAlive,t as readServerLock,l as readUiLock,i as releaseUiLock,r as updateUiLockPort};
|
package/dist/init-D-fChIzY.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./init-DNs9ffRY.mjs";export{o as detectInstalledEditors,n as formatInitResult,i as initCommand,t as readExistingMcpEntry,e as runInit,r as writeEditorMcpConfig,a as writeUserMcpConfigs};
|
package/dist/init-D3711KPb.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./init-DVCAi_du.mjs";export{t as ensureOkGitignoredAtRoot,e as initContent};
|
package/dist/loader-Bc5pJk1m.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-C9LBHYiT.mjs";export{e as loadConfig};
|
package/dist/paths-CDgE-NKk.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./paths-zc2uvZxY.mjs";export{t as resolveContentDir,e as resolveLockDir};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-CPxqdDCe.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-wcPFST8Q-BB0WpHs3.mjs";import{resolve as t}from"node:path";import{closeSync as n,existsSync as r,mkdirSync as i,openSync as a,readFileSync as o,unlinkSync as s,writeFileSync as c,writeSync as l}from"node:fs";import{hostname as u}from"node:os";function d(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}var f=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 p(e,n){return t(e,`${n}.lock`)}const m=new Map;function h(e){m.set(e,(m.get(e)??0)+1)}function g(e){let t=m.get(e);return t===void 0||t<=1?(m.delete(e),!0):(m.set(e,t-1),!1)}function _(e,t){try{let n=JSON.parse(o(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 v(e){let{lockName:t,lockDir:o,metadata:m}=e,g=`[${t}-lock]`;i(o,{recursive:!0});let v=p(o,t),b={pid:process.pid,hostname:u(),port:m.port,startedAt:new Date().toISOString(),worktreeRoot:m.worktreeRoot,...m.kind!==void 0&&{kind:m.kind},...m.parentPid!==void 0&&{parentPid:m.parentPid},...m.capabilities!==void 0&&{capabilities:m.capabilities}},x=JSON.stringify(b,null,2);for(let e=0;e<3;e++){if(!r(v))try{let e=a(v,`wx`,384);try{l(e,x)}finally{n(e)}return h(v),y({lockName:t,lockDir:o,lockPath:v})}catch(e){if(e.code!==`EEXIST`)throw e}let e=_(v,g);if(e){let n=e.hostname===u();if(n&&e.pid===process.pid)return c(v,x,{encoding:`utf-8`,mode:384}),h(v),y({lockName:t,lockDir:o,lockPath:v});if(n&&d(e.pid))throw new f(e,v,t);console.warn(`${g} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{s(v)}catch{}}throw Error(`${g} Failed to acquire ${v} after 3 attempts (concurrent acquire contention).`)}function y(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>S({lockName:t,lockDir:n}),updatePort:e=>b({lockName:t,lockDir:n,port:e})}}function b(e){let{lockName:t,lockDir:n,port:i}=e,a=`[${t}-lock]`,s=p(n,t);if(!r(s)){console.warn(`${a} Lock file missing at ${s} during port update — skipping`);return}let l;try{let e=JSON.parse(o(s,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`){console.warn(`${a} Corrupt lock at ${s} during port update — skipping`);return}l=e}catch{console.warn(`${a} Unreadable lock at ${s} during port update — skipping`);return}if(l.pid===process.pid&&!(typeof l.hostname==`string`&&l.hostname!==u())){l.port=i;try{c(s,JSON.stringify(l,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function x(e){let{lockName:t,lockDir:n}=e,i=p(n,t);if(!r(i))return null;let a;try{let e=JSON.parse(o(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`)return null;a=e}catch{return null}if(a.hostname!==u())return null;if(!d(a.pid)){try{s(i)}catch{}return null}return a}function S(e){let{lockName:t,lockDir:n}=e,i=`[${t}-lock]`,a=p(n,t);if(g(a)&&r(a))try{let e=JSON.parse(o(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==u())return;s(a)}catch(e){console.warn(`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}var C=e({ServerLockCollisionError:()=>w,acquireServerLock:()=>T,readServerLock:()=>D,releaseServerLock:()=>O,updateServerLockPort:()=>E}),w=class extends f{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function T(e,t){try{return v({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof f&&e.lockName===`server`?new w(e.existing,e.lockPath):e}}function E(e,t){b({lockName:`server`,lockDir:e,port:t})}function D(e){return x({lockName:`server`,lockDir:e})}function O(e){S({lockName:`server`,lockDir:e})}export{d as a,D as c,C as d,b as f,T as i,S as l,w as n,p as o,E as p,v as r,x as s,f as t,O as u};
|
|
2
|
-
//# sourceMappingURL=server-lock-QiPvrcO9-A3jWEIJ6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as e}from"./server-lock-QiPvrcO9-A3jWEIJ6.mjs";export{e as a};
|
package/dist/src-CccGTsc2.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./init-DNs9ffRY.mjs";import"./loader-C9LBHYiT.mjs";export{};
|
package/dist/start-DdFbQnn0.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./start-BnROvKwD.mjs";export{e as startCommand};
|