@inkeep/open-knowledge 0.0.0-dev-20260428063152 → 0.0.0-dev-20260428172344

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.
@@ -1,4 +1,4 @@
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";
1
+ import{n as e,t}from"./esm-wByiX8MO.mjs";import{r as n}from"./constants-DBvBsqEJ.mjs";import{p as r}from"./dist-DRC09WNZ.mjs";import{Y as i,Z as a,_ as o,lt as s}from"./dist-6JXIwkTW.mjs";import{n as c}from"./init-Di2sbASA.mjs";import{t as l}from"./preview-VXVGRaUP.mjs";import{s as u,t as d}from"./colors-DoPZvo1q.mjs";import{t as f}from"./is-object-BNVklKxg.mjs";import{basename as p,dirname as m,join as h,posix as g,relative as _,resolve as v,sep as y,win32 as b}from"node:path";import{existsSync as x,mkdirSync as S,readFileSync as C,writeFileSync as w}from"node:fs";import{homedir as T}from"node:os";import E from"@inquirer/checkbox";
2
2
  /*!
3
3
  * Copyright (c) Squirrel Chat et al., All rights reserved.
4
4
  * SPDX-License-Identifier: BSD-3-Clause
@@ -28,7 +28,7 @@ import{t as e}from"./esm-29fM6BBO.mjs";import{r as t}from"./constants-Dvx0Ir4Z.m
28
28
  */
29
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 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}};
31
+ `))}return i}var D=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 ee(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 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===`
59
+ function ne(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}function O(e,t=0,n=e.length){let r=e.indexOf(`
60
+ `,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function k(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 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===`
62
+ `)return n+1;if(r<` `&&r!==` `||r===``)throw new D(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function A(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=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===`
64
+ `);)t++;if(r||i!==`#`)break;t=k(e,t)}return t}function re(e,t,n,r,i=!1){if(!r)return t=O(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=O(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 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}
66
+ `))return a}throw new D(`cannot find end of structure`,{toml:e,ptr:t})}function j(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
@@ -123,9 +123,9 @@ let oe=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,se=/^[+-]?
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 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}
126
+ `){if(!i)throw new D(`newlines are not allowed in strings`,{toml:e,ptr:t-1})}else if(n<` `&&n!==` `||n===``)throw new D(`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 D(`invalid unicode escape`,{toml:e,ptr:a});try{s+=String.fromCodePoint(parseInt(r,16))}catch{throw new D(`invalid unicode escape`,{toml:e,ptr:a})}}else if(i&&(n===`
127
+ `||n===` `||n===` `||n===`\r`)){if(t=A(e,t-1,!0),e[t]!==`
128
+ `&&e[t]!==`\r`)throw new D(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:a});t=A(e,t)}else if(n in ue)s+=ue[n];else throw new D(`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 D(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new D(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new D(`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 D(`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 oe=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,se=/^[+-]?
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&&(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]}
156
+ function pe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(k(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function M(e,t,n,r,i){if(r===0)throw new D(`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=A(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new D(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}let o;if(a===`"`||a===`'`){o=j(e,t);let r=de(e,t,o);if(n){if(o=A(e,o),e[o]&&e[o]!==`,`&&e[o]!==n&&e[o]!==`
157
+ `&&e[o]!==`\r`)throw new D(`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 D(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=A(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&&(D(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 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]}
185
+ let me=/^[a-zA-Z0-9-_]+[ \t]*$/;function N(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new D(`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 D(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let s=j(e,t);if(s<0)throw new D(`unfinished string encountered`,{toml:e,ptr:t});r=e.indexOf(`.`,s);let c=e.slice(s,r<0||r>a?a:r),l=O(c);if(l>-1)throw new D(`newlines are not allowed in keys`,{toml:e,ptr:t+r+l});if(c.trimStart())throw new D(`found extra tokens after the string part`,{toml:e,ptr:s});if(a<s&&(a=e.indexOf(n,s),a<0))throw new D(`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 D(`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,A(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 D(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=k(e,t);else if(o!==` `&&o!==` `&&o!==`
186
+ `&&o!==`\r`){let o,s=i,c=!1,[l,u]=N(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 D(`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 D(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=M(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new D(`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 D(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=k(e,t);else if(a!==` `&&a!==` `&&a!==`
187
+ `&&a!==`\r`){let a=M(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new D(`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=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}
215
+ function P(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=A(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=N(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new D(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=P(n[0],r,i,t?2:1);if(!c)throw new D(`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=N(e,s),i=P(r[0],a,o,0);if(!i)throw new D(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=M(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=A(e,s,!0),e[s]&&e[s]!==`
216
+ `&&e[s]!==`\r`)throw new D(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=A(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
@@ -241,14 +241,15 @@ 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=
241
241
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
242
242
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
243
243
  */
244
- let N=/^[a-z0-9-_]+$/i;function P(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function ve(e){for(let t=0;t<e.length;t++)if(P(e[t])!==`object`)return!1;return e.length!=0}function F(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function I(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:r&&Number.isInteger(e)?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return F(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return ye(e,n,r);if(t===`array`)return be(e,n,r)}function ye(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=N.test(o)?o:F(o),i+=` = `,i+=I(e[o],P(e[o]),t-1,n)}return i+` }`}function be(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=I(e[i],P(e[i]),t-1,n)}return r+` ]`}function xe(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
245
- `}[[${t}]]\n`,i+=L(0,e[a],t,n,r);return i}function L(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=P(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=N.test(c)?c:F(c);if(e===`array`&&ve(t[c]))o+=(o&&`
244
+ let F=/^[a-z0-9-_]+$/i;function I(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function ve(e){for(let t=0;t<e.length;t++)if(I(e[t])!==`object`)return!1;return e.length!=0}function L(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function R(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:r&&Number.isInteger(e)?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return L(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return ye(e,n,r);if(t===`array`)return be(e,n,r)}function ye(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=F.test(o)?o:L(o),i+=` = `,i+=R(e[o],I(e[o]),t-1,n)}return i+` }`}function be(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=R(e[i],I(e[i]),t-1,n)}return r+` ]`}function xe(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
245
+ `}[[${t}]]\n`,i+=z(0,e[a],t,n,r);return i}function z(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=I(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=F.test(c)?c:L(c);if(e===`array`&&ve(t[c]))o+=(o&&`
246
246
  `)+xe(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
247
- `)+L(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=I(t[c],e,r,i),a+=`
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]===`
247
+ `)+z(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=R(t[c],e,r,i),a+=`
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(I(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=z(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=_(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
250
+ `}const B=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],Ce=[`@inkeep/open-knowledge`,`mcp`],we={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function V(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=v(e);if(p(t)===`cli.mjs`&&p(m(t))===`dist`)return t;let n=t.split(y),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 h(i.length===0?y:i.join(y),`packages`,`cli`,`dist`,`cli.mjs`)}function H(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:[v(t),`mcp`]}}return e.mode===`dev`?{command:`node`,args:[V(e.cliEntryPath),`mcp`],env:{...we}}:{command:`npx`,args:[...Ce]}}function U(e){return e===`win32`?b:g}function Te(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env,i=U(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??T();return U(t).join(n,`.claude.json`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??T(),r=e.env??process.env;if(t===`darwin`)return g.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??b.join(n,`AppData`,`Roaming`);return b.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??T();return U(t).join(n,`.cursor`,`mcp.json`)}function Oe(e={}){return U(e.platformName??process.platform).join(Te(e),`Code`,`User`,`mcp.json`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??T();return U(t).join(n,`.codeium`,`windsurf`,`mcp_config.json`)}function Ae(e={}){let t=e.platformName??process.platform,n=e.home??T();return(e.env??process.env).CODEX_HOME??U(t).join(n,`.codex`)}function je(e={}){return U(e.platformName??process.platform).join(Ae(e),`config.toml`)}function G(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>G(e,t[n]));if(f(e)&&f(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=>G(e[n],t[n]))}return!1}function Me(e,t){return Object.entries(t).every(([t,n])=>G(e[t],n))}function Ne(e,t){return{...e,...t}}function K(e){return{...e,isCompatible(t,n,r){return Me(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return Ne(t,e.buildEntry(n,r))}}}const q={claude:K({id:`claude`,label:`Claude Code`,configPath:(e,t)=>Ee({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>h(t??T(),`.claude`),projectConfigPath:e=>h(e,`.mcp.json`)}),"claude-desktop":K({id:`claude-desktop`,label:`Claude Desktop`,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>m(W({home:t}))}),cursor:K({id:`cursor`,label:`Cursor`,configPath:(e,t)=>De({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>m(De({home:t})),projectConfigPath:e=>h(e,`.cursor`,`mcp.json`)}),vscode:K({id:`vscode`,label:`VS Code`,configPath:(e,t)=>Oe({home:t}),format:`json`,topLevelKey:`servers`,serverName:()=>n,buildEntry:(e,t)=>({type:`stdio`,...H(t)}),scope:`global`,detectPath:(e,t)=>m(Oe({home:t})),projectConfigPath:e=>h(e,`.vscode`,`mcp.json`)}),windsurf:K({id:`windsurf`,label:`Windsurf`,configPath:(e,t)=>ke({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>m(ke({home:t}))}),codex:K({id:`codex`,label:`Codex`,configPath:(e,t)=>je({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>n,buildEntry:(e,t)=>H(t),scope:`global`,detectPath:(e,t)=>m(je({home:t})),projectConfigPath:e=>h(e,`.codex`,`config.toml`)})};function J(e){let t=e.filter(e=>!(e in q));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${B.join(`, `)}`);return e.map(e=>q[e])}function Pe(e){if(!x(e))return{};let t=C(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(f(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 Fe(e){if(!x(e))return{};let t=C(e,`utf-8`).trim();if(t===``)return{};try{let n=_e(t);if(f(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 Ie(e,t){S(m(e),{recursive:!0}),w(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function Le(e,t){S(m(e),{recursive:!0});let n=Se(t);w(e,n.endsWith(`
251
+ `)?n:`${n}\n`,`utf-8`)}const Re=e=>e!==`project`,Y=e=>e!==`user`;async function ze(){let e=await E({message:`Where should the MCP server be configured?
252
+ `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Be(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??ze)():`both`}const Ve=`0.0.1`,X=`open-knowledge-ui`;function He(e,t={}){let n=h(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:X,runtimeExecutable:`node`,runtimeArgs:[V(t.cliEntryPath),`ui`],port:3e3}:{name:X,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!x(n))return S(m(n),{recursive:!0}),w(n,`${JSON.stringify({version:Ve,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let e=C(n,`utf-8`).trim(),t=e?JSON.parse(e):{};if(!f(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=>f(e)&&e.name===X);a>=0?i[a]=r:i.push(r);let o={...t,version:t.version??Ve,configurations:i};return w(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 x(e.detectPath?.(t,n)??m(e.configPath(t,n)))}catch{return!1}}function Q(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}if(!i&&!n.skipAvailabilityCheck&&!Z(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};let s;try{s=e.format===`toml`?Fe(o):Pe(o)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let c=s[e.topLevelKey]??{},l=c[a],u;try{u=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let d={...s,[e.topLevelKey]:{...c,[a]:u}};try{e.format===`toml`?Le(o,d):Ie(o,d)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:l===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function Ue(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!x(n)))return{editorId:e.id,label:e.label,path:n}}async function We(e){let t=J(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Q(t,``,n,e.home))}function Ge(e,t,n){let r;try{r=e.configPath(t,n)}catch{return null}let i;try{i=e.format===`toml`?Fe(r):Pe(r)}catch{return null}let a=i[e.topLevelKey];if(!f(a))return null;let o=a[e.serverName(t)];return f(o)?o:null}async function Ke(e={}){let t=v(e.cwd??process.cwd()),n={mode:e.pin?`pinned`:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},r=await a(t),o;try{o=c(t)}catch(n){let i=q.claude.configPath(t,e.home);return{contentCreated:[],contentSkipped:[],editors:[],legacyProjectConfigs:[],didGitInit:r.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${n instanceof Error?n.message:String(n)}`}}let l=await Be({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),u=e.editors??$(t,e.home),d=e.editors??B.filter(e=>q[e].projectConfigPath!==void 0),f=J(u),p=J(d),m=e.mcp===!1||l===null,h=Array.from(new Map([...f,...m?[]:p].map(e=>[e.id,e])).values()),g=f.filter(n=>Z(n,t,e.home)),_=[],y=new Set;for(let r of h){if(m){let n=``;try{n=r.configPath(t,e.home)}catch{}_.push({editorId:r.id,label:r.label,action:`skipped-flag`,configPath:n,serverName:r.serverName(t)});continue}if(Re(l)&&f.includes(r)&&_.push(Q(r,t,n,e.home)),Y(l)&&p.includes(r)&&r.projectConfigPath){let i=r.projectConfigPath(t),a=Q(r,t,n,e.home,i);_.push(a),(a.action===`written`||a.action===`overwritten`)&&y.add(i)}}let b=!m&&l!==null&&Y(l)?p.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,x=m?[]:g.map(e=>Ue(e,t)).filter(e=>e!==void 0).filter(e=>!y.has(e.path)),S=g.some(e=>e.id===`claude`)&&!m?He(t,n):void 0,C=await(e.installUserSkill??s)({home:e.home}),w=i({home:e.home}),T=m?`skipped-flag`:`skipped-missing`,E=_.find(e=>e.editorId===`claude`)??_[0]??{action:T,configPath:q.claude.configPath(t,e.home)};return{contentCreated:o.created,contentSkipped:o.skipped,editors:_,legacyProjectConfigs:x,launchJson:S,skillInstall:C,didGitInit:r.didInit,claudeDesktopDetected:w,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:b}}function qe(e,t){let n=[],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`),c=e=>{let n=e.configPath.startsWith(t)?_(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&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let f=h(t,r);if(e.contentCreated.length>0?(n.push(`Content scaffolded at ${f}/`),n.push(` Created: ${e.contentCreated.join(`, `)}`)):n.push(`Content already present at ${f}/`),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(`MCP server configuration:`),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(o)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)n.push(`MCP server configuration:`),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(`MCP server configuration:`);for(let r of e.editors){let i=r.configPath.startsWith(t)?_(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,s=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-s.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${s}${l}${i} registered${a}${u}`);break;case`overwritten`:n.push(` ${s}${l}${i} updated${a}${u}`);break;case`skipped-missing`:n.push(` ${s}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${s}${l}${i} FAILED: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(c(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(a&&(n.push(``),n.push(`For failed editors, add the MCP server entry manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${_(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(`User-global skill:`),e.skillInstall){case`installed`:n.push(" open-knowledge installed to detected agent hosts via `npx skills`");break;case`skip-current`:n.push(` open-knowledge already installed at current version`);break;case`failed`:n.push(` ${u(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${u(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(n.push(``),n.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${d(`ok install-skill`)}`)),e.preview?(n.push(``),n.push(l(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),i){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`Next steps:`),n.push(` 1. Open your editor (${r.join(` / `)})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ok seed`),n.push(` 4. Use the three MCP workflow tools as you build the wiki:`),n.push(` - mcp__open-knowledge__ingest — capture an external source`),n.push(` - mcp__open-knowledge__research — gather sources and write findings`),n.push(` - mcp__open-knowledge__consolidate — promote research to canonical articles`)}return n.join(`
253
+ `)}function $(e,t){let n=[];for(let r of B)Z(q[r],e,t)&&n.push(r);return n}function Je(){return new t(`init`).description(`Scaffold ${r}/ 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 ${r}/ 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`).addOption(new e(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).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 Ke({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,pin:e.pin})}catch(e){if(e instanceof o){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
254
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-D18jtdLK.mjs`),{loadConfig:r}=await import(`./loader-DvcPWYAi.mjs`),{resolveContentDir:i}=await import(`./paths-DXVpv4hT.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(`${qe(n,t)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{Be as a,We as c,Ge as i,B as l,qe as n,Ke as o,Je as r,Q as s,$ as t,q as u};
255
+ //# sourceMappingURL=init-BbOWk8q3.mjs.map
@@ -0,0 +1 @@
1
+ import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./init-BbOWk8q3.mjs";export{s as detectInstalledEditors,r as formatInitResult,a as initCommand,n as readExistingMcpEntry,e as resolveMcpScope,i as runInit,o as writeEditorMcpConfig,t as writeUserMcpConfigs};
@@ -1,4 +1,4 @@
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
1
+ import{n as e,t}from"./constants-DBvBsqEJ.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-Dvx0Ir4Z.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-BrxpN5Ku.mjs.map
120
+ //# sourceMappingURL=init-Di2sbASA.mjs.map
@@ -1,3 +1,3 @@
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(`
1
+ import{t as e}from"./dist-BCyi1oM7.mjs";import{n as t}from"./constants-DBvBsqEJ.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-Dt0KH_I_.mjs.map
3
+ //# sourceMappingURL=loader-DDxmojUu.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-DDxmojUu.mjs";export{e as loadConfig};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./paths-DaG87qwf.mjs";export{t as resolveContentDir,e as resolveLockDir};
@@ -1,2 +1,2 @@
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
1
+ import"./constants-DBvBsqEJ.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-DaG87qwf.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-VXVGRaUP.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1,3 +1,3 @@
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(`
1
+ import"./constants-DBvBsqEJ.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-CYJ8l4Py.mjs.map
3
+ //# sourceMappingURL=preview-VXVGRaUP.mjs.map
@@ -0,0 +1 @@
1
+ import{i as e,n as t,r as n,t as r}from"./index-BZbSuKIM.js";export{r as McpConsentDialogBody,r as default,t as computeInitialSelection,n as selectedIdsOrdered,e as toggleSelectedId};