@inkeep/open-knowledge 0.5.0 → 0.5.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/THIRD_PARTY_NOTICES.md +150 -0
  2. package/dist/assets/skills/open-knowledge/SKILL.md +1 -1
  3. package/dist/cli.mjs +4 -4
  4. package/dist/config-schema.json +16 -0
  5. package/dist/config.user.schema.json +16 -0
  6. package/dist/constants-BqA_tvx_.mjs +2 -0
  7. package/dist/{dist-DHj61EG5.mjs → dist-beLXrhv5.mjs} +10 -10
  8. package/dist/{dist-ChwYnRqt.mjs → dist-siA8b9P_.mjs} +1 -1
  9. package/dist/index.mjs +1 -1
  10. package/dist/{init-gfAUbyai.mjs → init-DqoEL9jU.mjs} +4 -4
  11. package/dist/init-EfEDGvh7.mjs +1 -0
  12. package/dist/{loader-DsGUJOWD.mjs → loader-CbWGi3Dz.mjs} +2 -2
  13. package/dist/loader-x6ROdbQe.mjs +1 -0
  14. package/dist/{preview-DWRrWnuf.mjs → preview-0Rwux1EE.mjs} +2 -2
  15. package/dist/preview-DKH3UaeV.mjs +1 -0
  16. package/dist/public/assets/ActivityModeContent-BA_Hv5zU.js +2 -0
  17. package/dist/public/assets/DocumentContext-DLUOyqhE.js +52 -0
  18. package/dist/public/assets/GraphPanel-8RBGIUIt.js +46 -0
  19. package/dist/public/assets/SettingsDialogBody-WO4dhoz2.js +11 -0
  20. package/dist/public/assets/SourceEditor-DUA4Uo0Z.js +2 -0
  21. package/dist/public/assets/config-validation-events-BDg76Ro_.js +10 -0
  22. package/dist/public/assets/{doc-hash-CMD_NjP8.js → doc-hash-CO_0WoMz.js} +2 -2
  23. package/dist/public/assets/{index-D9afOIIc.css → index-BBU-QASR.css} +1 -1
  24. package/dist/public/assets/index-BCW5lC5r.js +1928 -0
  25. package/dist/public/assets/{target-navigation-intent-DxRtD10o.js → target-navigation-intent-BY2CtClj.js} +1 -1
  26. package/dist/public/assets/{toggle-group-DQWMrY_b.js → toggle-group-CJzcIZ91.js} +1 -1
  27. package/dist/public/assets/{typing-burst-detector-Cm3a_0Rp.js → typing-burst-detector-L-hzCd9t.js} +2 -2
  28. package/dist/public/index.html +8 -8
  29. package/dist/{repair-launch-json-CtMhcU4e.mjs → repair-launch-json-BLt6yeMu.mjs} +2 -2
  30. package/dist/{repair-mcp-configs-DImyCeuT.mjs → repair-mcp-configs-CQeXBdZG.mjs} +2 -2
  31. package/dist/schemas/v0/config.user.schema.json +16 -0
  32. package/dist/{src-7RbS1TeB.mjs → src-CuA35SFT.mjs} +2 -2
  33. package/dist/start-CnfoPWyL.mjs +1 -0
  34. package/dist/{start-fgy_CK47.mjs → start-D1zrxouB.mjs} +2 -2
  35. package/package.json +1 -1
  36. package/dist/constants-BPsrqVcC.mjs +0 -2
  37. package/dist/init-LkHLm5ut.mjs +0 -1
  38. package/dist/loader-dMWGjY_g.mjs +0 -1
  39. package/dist/preview-DXHcHw7y.mjs +0 -1
  40. package/dist/public/assets/ActivityModeContent-B8J4OFHO.js +0 -2
  41. package/dist/public/assets/DocumentContext-fSMev29P.js +0 -52
  42. package/dist/public/assets/GraphPanel-CbVOnaKD.js +0 -46
  43. package/dist/public/assets/SettingsDialogBody-8zs3jwhI.js +0 -11
  44. package/dist/public/assets/SourceEditor-BCHJFeGa.js +0 -2
  45. package/dist/public/assets/config-validation-events-BtPgkHlf.js +0 -10
  46. package/dist/public/assets/index-BZCMU4ot.js +0 -1918
  47. package/dist/start-BYmlQzPZ.mjs +0 -1
@@ -1320,6 +1320,16 @@ Homepage: https://github.com/SBoudrias/Inquirer.js
1320
1320
 
1321
1321
  Copyright (c) 2025 Simon Boudrias
1322
1322
 
1323
+ ### `@jest/schemas@29.6.3`
1324
+ Homepage: https://github.com/jestjs/jest
1325
+
1326
+ Copyright (c) Meta Platforms, Inc. and affiliates.
1327
+
1328
+ ### `@jest/types@29.6.3`
1329
+ Homepage: https://github.com/jestjs/jest
1330
+
1331
+ Copyright (c) Meta Platforms, Inc. and affiliates.
1332
+
1323
1333
  ### `@jitl/quickjs-ffi-types@0.32.0`
1324
1334
  Homepage: https://github.com/justjake/quickjs-emscripten
1325
1335
 
@@ -1440,6 +1450,31 @@ Homepage: https://github.com/lifeomic/attempt#readme
1440
1450
 
1441
1451
  Copyright 2018 LifeOmic
1442
1452
 
1453
+ ### `@lingui/babel-plugin-lingui-macro@6.0.1`
1454
+ Homepage: https://lingui.dev
1455
+
1456
+ Copyright (c) 2017-2022 Tomáš Ehrlich, (c) 2022-2023 Crowdin.
1457
+
1458
+ ### `@lingui/conf@6.0.1`
1459
+ Homepage: https://lingui.dev
1460
+
1461
+ Copyright (c) 2017-2022 Tomáš Ehrlich, (c) 2022-2023 Crowdin.
1462
+
1463
+ ### `@lingui/core@6.0.1`
1464
+ Homepage: https://lingui.dev
1465
+
1466
+ Copyright (c) 2017-2022 Tomáš Ehrlich, (c) 2022-2023 Crowdin.
1467
+
1468
+ ### `@lingui/message-utils@6.0.1`
1469
+ Homepage: https://lingui.dev
1470
+
1471
+ Copyright (c) 2017-2022 Tomáš Ehrlich, (c) 2022-2023 Crowdin.
1472
+
1473
+ ### `@lingui/react@6.0.1`
1474
+ Homepage: https://lingui.dev
1475
+
1476
+ Copyright (c) 2017-2022 Tomáš Ehrlich, (c) 2022-2023 Crowdin.
1477
+
1443
1478
  ### `@marijn/find-cluster-break@1.0.2`
1444
1479
  Homepage: https://github.com/marijnh/find-cluster-break#readme
1445
1480
 
@@ -1450,6 +1485,16 @@ Homepage: https://github.com/mermaid-js/mermaid/tree/develop/packages/mermaid/pa
1450
1485
 
1451
1486
  Copyright (c) 2023 Yokozuna59
1452
1487
 
1488
+ ### `@messageformat/date-skeleton@1.1.0`
1489
+ Homepage: http://messageformat.github.io/messageformat/api/date-skeleton/
1490
+
1491
+ Copyright OpenJS Foundation and contributors, https://openjsf.org/
1492
+
1493
+ ### `@messageformat/parser@5.1.1`
1494
+ Homepage: http://messageformat.github.io/messageformat/api/parser/
1495
+
1496
+ Copyright OpenJS Foundation and contributors, https://openjsf.org/
1497
+
1453
1498
  ### `@modelcontextprotocol/sdk@1.29.0`
1454
1499
  Homepage: https://modelcontextprotocol.io
1455
1500
 
@@ -1925,6 +1970,11 @@ Homepage: https://github.com/steveukx/git-js
1925
1970
 
1926
1971
  _(No LICENSE file in package; SPDX identifier in `package.json` is the sole declared grant.)_
1927
1972
 
1973
+ ### `@sinclair/typebox@0.27.10`
1974
+ Homepage: https://github.com/sinclairzx81/typebox-legacy
1975
+
1976
+ Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
1977
+
1928
1978
  ### `@sindresorhus/merge-streams@4.0.0`
1929
1979
  Homepage: https://github.com/sindresorhus/merge-streams
1930
1980
 
@@ -2349,6 +2399,21 @@ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/h
2349
2399
 
2350
2400
  Copyright (c) Microsoft Corporation.
2351
2401
 
2402
+ ### `@types/istanbul-lib-coverage@2.0.6`
2403
+ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-coverage
2404
+
2405
+ Copyright (c) Microsoft Corporation.
2406
+
2407
+ ### `@types/istanbul-lib-report@3.0.3`
2408
+ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-report
2409
+
2410
+ Copyright (c) Microsoft Corporation.
2411
+
2412
+ ### `@types/istanbul-reports@3.0.4`
2413
+ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-reports
2414
+
2415
+ Copyright (c) Microsoft Corporation.
2416
+
2352
2417
  ### `@types/katex@0.16.8`
2353
2418
  Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/katex
2354
2419
 
@@ -2424,6 +2489,16 @@ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/v
2424
2489
 
2425
2490
  Copyright (c) Microsoft Corporation.
2426
2491
 
2492
+ ### `@types/yargs@17.0.35`
2493
+ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs
2494
+
2495
+ Copyright (c) Microsoft Corporation.
2496
+
2497
+ ### `@types/yargs-parser@21.0.3`
2498
+ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs-parser
2499
+
2500
+ Copyright (c) Microsoft Corporation.
2501
+
2427
2502
  ### `@uiw/codemirror-theme-basic@4.25.9`
2428
2503
  Homepage: https://uiwjs.github.io/react-codemirror/#/theme/data/basic/light
2429
2504
 
@@ -2489,6 +2564,11 @@ Homepage: https://github.com/chalk/ansi-styles
2489
2564
 
2490
2565
  Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
2491
2566
 
2567
+ ### `ansi-styles@5.2.0`
2568
+ Homepage: https://github.com/chalk/ansi-styles
2569
+
2570
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
2571
+
2492
2572
  ### `aria-hidden@1.2.6`
2493
2573
  Homepage: https://github.com/theKashey/aria-hidden#readme
2494
2574
 
@@ -2604,6 +2684,11 @@ Homepage: https://github.com/sindresorhus/callsites
2604
2684
 
2605
2685
  Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
2606
2686
 
2687
+ ### `camelcase@6.3.0`
2688
+ Homepage: https://github.com/sindresorhus/camelcase
2689
+
2690
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
2691
+
2607
2692
  ### `canvas-color-tracker@1.3.2`
2608
2693
  Homepage: https://github.com/vasturiano/canvas-color-tracker
2609
2694
 
@@ -2619,6 +2704,11 @@ Homepage: https://github.com/chalk/chalk
2619
2704
 
2620
2705
  Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
2621
2706
 
2707
+ ### `chalk@4.1.2`
2708
+ Homepage: https://github.com/chalk/chalk
2709
+
2710
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
2711
+
2622
2712
  ### `character-entities@2.0.2`
2623
2713
  Homepage: https://github.com/wooorm/character-entities
2624
2714
 
@@ -3304,6 +3394,11 @@ Homepage: https://github.com/pshihn/hachure-fill#readme
3304
3394
 
3305
3395
  Copyright (c) 2023 Preet Shihn
3306
3396
 
3397
+ ### `has-flag@4.0.0`
3398
+ Homepage: https://github.com/sindresorhus/has-flag
3399
+
3400
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3401
+
3307
3402
  ### `has-symbols@1.1.0`
3308
3403
  Homepage: https://github.com/ljharb/has-symbols#readme
3309
3404
 
@@ -3584,6 +3679,21 @@ Homepage: https://github.com/vasturiano/jerrypick
3584
3679
 
3585
3680
  Copyright (c) 2019 Vasco Asturiano
3586
3681
 
3682
+ ### `jest-get-type@29.6.3`
3683
+ Homepage: https://github.com/jestjs/jest
3684
+
3685
+ Copyright (c) Meta Platforms, Inc. and affiliates.
3686
+
3687
+ ### `jest-validate@29.7.0`
3688
+ Homepage: https://github.com/jestjs/jest
3689
+
3690
+ Copyright (c) Meta Platforms, Inc. and affiliates.
3691
+
3692
+ ### `jiti@2.6.1`
3693
+ Homepage: https://github.com/unjs/jiti
3694
+
3695
+ Copyright (c) Pooya Parsa <pooya@pi0.io>
3696
+
3587
3697
  ### `jose@6.2.2`
3588
3698
  Homepage: https://github.com/panva/jose
3589
3699
 
@@ -3594,6 +3704,11 @@ Homepage: https://github.com/egoist/joycon
3594
3704
 
3595
3705
  _(LICENSE file present but no auto-extractable copyright line; refer to the package source for canonical attribution.)_
3596
3706
 
3707
+ ### `js-sha256@0.10.1`
3708
+ Homepage: https://github.com/emn178/js-sha256
3709
+
3710
+ Copyright (c) 2014-2023 Chen, Yi-Cyuan
3711
+
3597
3712
  ### `js-tokens@4.0.0`
3598
3713
  Homepage: https://github.com/lydell/js-tokens
3599
3714
 
@@ -3679,11 +3794,21 @@ Homepage: https://github.com/develar/lazy-val
3679
3794
 
3680
3795
  _(No LICENSE file in package; SPDX identifier in `package.json` is the sole declared grant.)_
3681
3796
 
3797
+ ### `leven@3.1.0`
3798
+ Homepage: https://github.com/sindresorhus/leven
3799
+
3800
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3801
+
3682
3802
  ### `lib0@0.2.117`
3683
3803
  Homepage: https://github.com/dmonad/lib0#readme
3684
3804
 
3685
3805
  Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
3686
3806
 
3807
+ ### `lilconfig@3.1.3`
3808
+ Homepage: https://github.com/antonk52/lilconfig
3809
+
3810
+ Copyright (c) 2022 Anton Kastritskiy
3811
+
3687
3812
  ### `lines-and-columns@1.2.4`
3688
3813
  Homepage: https://github.com/eventualbuddha/lines-and-columns#readme
3689
3814
 
@@ -4190,6 +4315,11 @@ Homepage: https://github.com/chicoxyzzy/node-releases
4190
4315
 
4191
4316
  Copyright (c) 2017 Sergey Rubanov (https://github.com/chicoxyzzy)
4192
4317
 
4318
+ ### `normalize-path@3.0.0`
4319
+ Homepage: https://github.com/jonschlinkert/normalize-path
4320
+
4321
+ Copyright (c) 2014-2018, Jon Schlinkert.
4322
+
4193
4323
  ### `npm-run-path@6.0.0`
4194
4324
  Homepage: https://github.com/sindresorhus/npm-run-path
4195
4325
 
@@ -4428,6 +4558,11 @@ Homepage: https://github.com/prebuild/prebuild-install
4428
4558
 
4429
4559
  Copyright (c) 2015 Mathias Buus
4430
4560
 
4561
+ ### `pretty-format@29.7.0`
4562
+ Homepage: https://github.com/jestjs/jest
4563
+
4564
+ Copyright (c) Meta Platforms, Inc. and affiliates.
4565
+
4431
4566
  ### `pretty-ms@9.3.0`
4432
4567
  Homepage: https://github.com/sindresorhus/pretty-ms
4433
4568
 
@@ -4643,6 +4778,11 @@ Homepage: https://reactjs.org/
4643
4778
 
4644
4779
  Copyright (c) Facebook, Inc. and its affiliates.
4645
4780
 
4781
+ ### `react-is@18.3.1`
4782
+ Homepage: https://reactjs.org/
4783
+
4784
+ Copyright (c) Facebook, Inc. and its affiliates.
4785
+
4646
4786
  ### `react-kapsule@2.5.7`
4647
4787
  Homepage: https://github.com/vasturiano/react-kapsule
4648
4788
 
@@ -5036,6 +5176,11 @@ Homepage: https://github.com/thysultan/stylis.js
5036
5176
 
5037
5177
  Copyright (c) 2016-present Sultan Tarimo
5038
5178
 
5179
+ ### `supports-color@7.2.0`
5180
+ Homepage: https://github.com/chalk/supports-color
5181
+
5182
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
5183
+
5039
5184
  ### `supports-preserve-symlinks-flag@1.0.0`
5040
5185
  Homepage: https://github.com/inspect-js/node-supports-preserve-symlinks-flag#readme
5041
5186
 
@@ -5942,6 +6087,11 @@ Homepage: https://github.com/feross/ieee754
5942
6087
 
5943
6088
  Copyright 2008 Fair Oaks Labs, Inc.
5944
6089
 
6090
+ ### `moo@0.5.3`
6091
+ Homepage: https://github.com/tjvr/moo
6092
+
6093
+ Copyright (c) 2017, Tim Radvan (tjvr)
6094
+
5945
6095
  ### `protobufjs@7.5.5`
5946
6096
  Homepage: https://protobufjs.github.io/protobuf.js/
5947
6097
 
@@ -3,7 +3,7 @@ name: open-knowledge
3
3
  description: "MUST invoke when the project contains a .ok/ directory — before any read or edit of .md / .mdx files, any mcp__open-knowledge__ tool call, and any write_document / edit_document. Skip if no .ok/ — not an Open Knowledge project. Carries preview-attach (open preview browser at session start; one-shot on `action: attach-preview-once`; surface to user on `action: start-ui` when no UI is running), STOP rules for native Read/Grep/Edit on in-scope markdown, grounding rules (every factual claim needs a source), standard markdown linking with get_dead_links verification, image sourcing + alt-text + source-citation rules, folder-first organization with opt-in nested .ok/ frontmatter + templates, and the anti-pattern table."
4
4
  compatibility: "Claude Code, Claude Desktop, Claude Cowork, Claude.ai web. Requires Open Knowledge MCP server + code execution."
5
5
  metadata:
6
- version: "0.5.0"
6
+ version: "0.5.1-beta.0"
7
7
  author: "Inkeep"
8
8
  repository: "https://github.com/inkeep/open-knowledge"
9
9
  ---
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{Ai as n,B as r,Ci as i,D as a,Di as o,Dn as s,E as c,Ei as l,Gn as u,Gr as d,Gt as f,Hr as p,Jn as m,Kr as h,Mi as ee,Oi as g,Si as _,Ti as v,U as y,Ur as b,Wr as x,Xr as te,Yr as ne,Z as re,bi as ie,cr as ae,it as oe,ji as se,ki as ce,m as le,nn as ue,nt as de,pi as fe,pn as pe,qr as me,vi as he,wi as ge,xi as _e,z as ve,zn as ye}from"./dist-DHj61EG5.mjs";import{n as be,r as xe,t as S}from"./dist-bundle-BSdjl7Rj.mjs";import{A as Se,C as Ce,D as we,E as Te,O as Ee,S as De,T as Oe,b as ke,k as Ae,o as je,p as Me,w as Ne,x as Pe,y as Fe}from"./init-gfAUbyai.mjs";import{c as Ie,f as Le,l as Re,n as ze,s as C}from"./server-lock-D7DXNVql-BRVVzA6T.mjs";import{i as Be}from"./git-handle-DwfYp_z--CfyPz4Dz.mjs";import{n as Ve}from"./constants-BPsrqVcC.mjs";import{i as He}from"./src-7RbS1TeB.mjs";import{n as Ue,t as We}from"./loader-DsGUJOWD.mjs";import{d as Ge,f as Ke,l as qe,m as Je,p as Ye,s as Xe}from"./start-fgy_CK47.mjs";import{c as Ze,i as w,n as T,o as E,r as D,s as Qe,t as O}from"./colors-BtKMHmBX.mjs";import{execFileSync as $e,execSync as et,spawn as tt,spawnSync as k}from"node:child_process";import nt,{basename as rt,dirname as it,isAbsolute as at,join as A,relative as ot,resolve as j}from"node:path";import{closeSync as st,existsSync as M,mkdirSync as ct,mkdtempSync as lt,openSync as ut,readFileSync as N,readdirSync as dt,realpathSync as ft,rmSync as pt,statSync as mt,unlinkSync as ht,writeFileSync as gt}from"node:fs";import _t from"node:process";import{homedir as vt,hostname as yt,tmpdir as bt}from"node:os";import{fileURLToPath as xt}from"node:url";import{AsyncLocalStorage as St,AsyncResource as Ct}from"node:async_hooks";import{stripVTControlCharacters as wt,styleText as P}from"node:util";import*as Tt from"node:readline";import{randomUUID as Et}from"node:crypto";import{realpath as Dt}from"node:fs/promises";import{setTimeout as Ot}from"node:timers/promises";import{createInterface as kt}from"node:readline/promises";var At=ee();const jt=`open-knowledge`;var Mt=class{backend=`keyring`;async get(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{let n=new t(jt,e).getPassword();return n==null?null:JSON.parse(n)}catch{return null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(jt,e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(jt,e).deletePassword()}catch{}}},Nt=class{backend=`file`;authFile;constructor(e){this.authFile=e??A(vt(),`.ok`,`auth.yml`)}read(){if(!M(this.authFile))return{};try{return(0,At.parse)(N(this.authFile,`utf-8`))??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=it(this.authFile);M(t)||ct(t,{recursive:!0,mode:448}),gt(this.authFile,(0,At.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}};async function Pt(e){try{let{Entry:e}=await import(`@napi-rs/keyring`);return new e(jt,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
2
+ import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{Ai as n,B as r,Ci as i,D as a,Di as o,Dn as s,E as c,Ei as l,Gn as u,Gr as d,Gt as f,Hr as p,Jn as m,Kr as h,Mi as ee,Oi as g,Si as _,Ti as v,U as y,Ur as b,Wr as x,Xr as te,Yr as ne,Z as re,bi as ie,cr as ae,it as oe,ji as se,ki as ce,m as le,nn as ue,nt as de,pi as fe,pn as pe,qr as me,vi as he,wi as ge,xi as _e,z as ve,zn as ye}from"./dist-beLXrhv5.mjs";import{n as be,r as xe,t as S}from"./dist-bundle-BSdjl7Rj.mjs";import{A as Se,C as Ce,D as we,E as Te,O as Ee,S as De,T as Oe,b as ke,k as Ae,o as je,p as Me,w as Ne,x as Pe,y as Fe}from"./init-DqoEL9jU.mjs";import{c as Ie,f as Le,l as Re,n as ze,s as C}from"./server-lock-D7DXNVql-BRVVzA6T.mjs";import{i as Be}from"./git-handle-DwfYp_z--CfyPz4Dz.mjs";import{n as Ve}from"./constants-BqA_tvx_.mjs";import{i as He}from"./src-CuA35SFT.mjs";import{n as Ue,t as We}from"./loader-CbWGi3Dz.mjs";import{d as Ge,f as Ke,l as qe,m as Je,p as Ye,s as Xe}from"./start-D1zrxouB.mjs";import{c as Ze,i as w,n as T,o as E,r as D,s as Qe,t as O}from"./colors-BtKMHmBX.mjs";import{execFileSync as $e,execSync as et,spawn as tt,spawnSync as k}from"node:child_process";import nt,{basename as rt,dirname as it,isAbsolute as at,join as A,relative as ot,resolve as j}from"node:path";import{closeSync as st,existsSync as M,mkdirSync as ct,mkdtempSync as lt,openSync as ut,readFileSync as N,readdirSync as dt,realpathSync as ft,rmSync as pt,statSync as mt,unlinkSync as ht,writeFileSync as gt}from"node:fs";import _t from"node:process";import{homedir as vt,hostname as yt,tmpdir as bt}from"node:os";import{fileURLToPath as xt}from"node:url";import{AsyncLocalStorage as St,AsyncResource as Ct}from"node:async_hooks";import{stripVTControlCharacters as wt,styleText as P}from"node:util";import*as Tt from"node:readline";import{randomUUID as Et}from"node:crypto";import{realpath as Dt}from"node:fs/promises";import{setTimeout as Ot}from"node:timers/promises";import{createInterface as kt}from"node:readline/promises";var At=ee();const jt=`open-knowledge`;var Mt=class{backend=`keyring`;async get(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{let n=new t(jt,e).getPassword();return n==null?null:JSON.parse(n)}catch{return null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(jt,e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(jt,e).deletePassword()}catch{}}},Nt=class{backend=`file`;authFile;constructor(e){this.authFile=e??A(vt(),`.ok`,`auth.yml`)}read(){if(!M(this.authFile))return{};try{return(0,At.parse)(N(this.authFile,`utf-8`))??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=it(this.authFile);M(t)||ct(t,{recursive:!0,mode:448}),gt(this.authFile,(0,At.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}};async function Pt(e){try{let{Entry:e}=await import(`@napi-rs/keyring`);return new e(jt,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
3
3
  `),new Mt}catch{return process.stderr.write(`[auth] token storage: file (~/.ok/auth.yml)
4
4
  `),new Nt(e)}}async function Ft(e,t){let n=[],r=new Nt(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(jt,`__probe__`);let r=new Mt;await r.get(e)!=null&&(await r.clear(e),n.push(`keychain`))}catch{}return{touched:n}}async function It(e,t,n){let r=Lt(await Rt(e)).host??``;if(!r)return 1;let i=await n.get(r);if(i==null)return 1;let a=e=>e.replace(/[\r\n]/g,``);return t.write(`username=${a(i.login)}\npassword=${a(i.token)}\n`),0}function Lt(e){let t={};for(let n of e.split(`
5
5
  `)){let e=n.trim();if(e===``)continue;let r=e.indexOf(`=`);r!==-1&&(t[e.slice(0,r)]=e.slice(r+1))}return t}function Rt(e){return new Promise((t,n)=>{let r=[];e.on(`data`,e=>r.push(e)),e.on(`end`,()=>t(Buffer.concat(r).toString(`utf-8`))),e.on(`error`,n)})}function zt(e){let n=new t(`git-credential`);return n.description(`Git credential helper (git credential-helper protocol)`),n.command(`get`).description(`Lookup credentials from TokenStore (called by git)`).action(async()=>{let t=await e(),n=await It(process.stdin,process.stdout,t);process.exit(n)}),n}function Bt(e){let t=e.endpoint.DEFAULTS;return/^https:\/\/(api\.)?github\.com$/.test(t.baseUrl)?`https://github.com`:t.baseUrl.replace(`/api/v3`,``)}async function Vt(e,t,n){let r={baseUrl:Bt(e),headers:{accept:`application/json`},...n},i=await e(t,r);if(`error`in i.data){let n=new be(`${i.data.error_description} (${i.data.error}, ${i.data.error_uri})`,400,{request:e.endpoint.merge(t,r)});throw n.response=i,n}return i}async function Ht(e){let t=e.request||S,n={client_id:e.clientId};return`scopes`in e&&Array.isArray(e.scopes)&&(n.scope=e.scopes.join(` `)),Vt(t,`POST /login/device/code`,n)}async function Ut(e){let t=await Vt(e.request||S,`POST /login/oauth/access_token`,{client_id:e.clientId,device_code:e.code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`}),n={clientType:e.clientType,clientId:e.clientId,token:t.data.access_token,scopes:t.data.scope.split(/\s+/).filter(Boolean)};if(`clientSecret`in e&&(n.clientSecret=e.clientSecret),e.clientType===`github-app`){if(`refresh_token`in t.data){let e=new Date(t.headers.date).getTime();n.refreshToken=t.data.refresh_token,n.expiresAt=Wt(e,t.data.expires_in),n.refreshTokenExpiresAt=Wt(e,t.data.refresh_token_expires_in)}delete n.scopes}return{...t,authentication:n}}function Wt(e,t){return new Date(e+t*1e3).toISOString()}async function Gt(e,t){let n=Kt(e,t.auth);if(n)return n;let{data:r}=await Ht({clientType:e.clientType,clientId:e.clientId,request:t.request||e.request,scopes:t.auth.scopes||e.scopes});await e.onVerification(r);let i=await Jt(t.request||e.request,e.clientId,e.clientType,r);return e.authentication=i,i}function Kt(e,t){if(t.refresh===!0||!e.authentication)return!1;if(e.clientType===`github-app`)return e.authentication;let n=e.authentication;return(`scopes`in t&&t.scopes||e.scopes).join(` `)===n.scopes.join(` `)?n:!1}async function qt(e){await new Promise(t=>setTimeout(t,e*1e3))}async function Jt(e,t,n,r){try{let i={clientId:t,request:e,code:r.device_code},{authentication:a}=n===`oauth-app`?await Ut({...i,clientType:`oauth-app`}):await Ut({...i,clientType:`github-app`});return{type:`token`,tokenType:`oauth`,...a}}catch(i){if(!i.response)throw i;let a=i.response.data.error;if(a===`authorization_pending`)return await qt(r.interval),Jt(e,t,n,r);if(a===`slow_down`)return await qt(r.interval+7),Jt(e,t,n,r);throw i}}async function Yt(e,t){return Gt(e,{auth:t})}async function Xt(e,t,n,r){let i=t.endpoint.merge(n,r);if(/\/login\/(oauth\/access_token|device\/code)$/.test(i.url))return t(i);let{token:a}=await Gt(e,{request:t,auth:{type:`oauth`}});return i.headers.authorization=`token ${a}`,t(i)}var Zt=`0.0.0-development`;function Qt(e){let t=e.request||S.defaults({headers:{"user-agent":`octokit-auth-oauth-device.js/${Zt} ${xe()}`}}),{request:n=t,...r}=e,i=e.clientType===`github-app`?{...r,clientType:`github-app`,request:n}:{...r,clientType:`oauth-app`,request:n,scopes:e.scopes||[]};if(!e.clientId)throw Error(`[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)`);if(!e.onVerification)throw Error(`[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)`);return Object.assign(Yt.bind(null,i),{hook:Xt.bind(null,i)})}async function $t(e){let{clientId:t,scopes:n=[`repo`,`read:user`,`user:email`],onVerification:r,host:i}=e,a=i&&i!==`github.com`?`https://${i}/api/v3`:`https://api.github.com`,o=Qt({clientType:`oauth-app`,clientId:t,scopes:n,onVerification:async e=>{await r({verificationUri:e.verification_uri,userCode:e.user_code,expiresIn:e.expires_in,interval:e.interval})},request:a===`https://api.github.com`?void 0:(await import(`./dist-bundle-BmF5_Mcp.mjs`)).request.defaults({baseUrl:a})}),s;try{s=await o({type:`oauth`})}catch(e){if(e instanceof Error){let t=e.message.toLowerCase();throw t.includes(`access_denied`)?Error(`Device-flow authorization was denied.`):t.includes(`expired_token`)||t.includes(`timeout`)||t.includes(`timed out`)?Error(`Device-flow code expired before authorization — please try again.`):Error(`GitHub sign-in failed: ${e.message}`)}throw e}return{token:s.token,tokenType:s.tokenType,scopes:s.scopes??[]}}const en={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var tn;(function(e){})(tn||={});function nn(e){return n(ie,e)}function rn(){return process.env.OPEN_KNOWLEDGE_GITHUB_CLIENT_ID??`Ov23liqlSd0V1MwR6rhI`}const an=new Set([`gitlab.com`,`bitbucket.org`,`codeberg.org`,`gitea.com`,`sr.ht`,`sourcehut.org`]);function F(e){let t=e.toLowerCase().replace(/:\d+$/,``);an.has(t)&&(process.stderr.write(`Error: ${e} is not a GitHub host. Only GitHub and GitHub Enterprise Server are supported.\n`),process.exit(1))}function on(e,t){e&&process.stdout.write(`${JSON.stringify(t)}\n`)}async function sn(e,t,n=$t){let r=rn(),{host:i,json:a}=e;F(i),a||process.stderr.write(`Logging in to ${i}\n`);let o=await n({clientId:r,host:i===`github.com`?void 0:i,onVerification:e=>{e.userCode,e.verificationUri,a?on(!0,{type:`verification`,user_code:e.userCode,verification_uri:e.verificationUri,expires_in:e.expiresIn}):process.stderr.write(`Open: ${e.verificationUri}\nEnter code: ${e.userCode}\n`)}}),s=`unknown`,c,l;try{let e=i===`github.com`?`https://api.github.com`:`https://${i}/api/v3`,t=await fetch(`${e}/user`,{headers:{Authorization:`Bearer ${o.token}`,"User-Agent":`open-knowledge-cli`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();s=e.login??s,c=e.name??void 0,l=e.email??void 0}}catch{}await t.set(i,s,o.token,{gitProtocol:`https`,name:c,email:l}),a?on(!0,{type:`complete`,host:i,login:s}):process.stderr.write(`✓ Logged in as ${s} on ${i}\n`)}function cn(e){return new t(`login`).description(`Authenticate with GitHub via Device Flow`).option(`--host <host>`,`GitHub or GitHub Enterprise hostname`,`github.com`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{await sn(t,await e())})}const ln=e=>e.name===`enter`||e.name===`return`;var un=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},dn=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},fn=class extends Error{name=`ExitPromptError`},pn=class extends Error{name=`HookError`},mn=class extends Error{name=`ValidationError`};const hn=new St;function gn(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function _n(e,t){let n=gn(e);return hn.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function I(){let e=hn.getStore();if(!e)throw new pn(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function vn(){return I().rl}function yn(e){return Ct.bind((...t)=>{let n=I(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function bn(e){let t=I(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function xn(){I().handleChange()}const L={queue(e){let t=I(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(vn());if(r!=null&&typeof r!=`function`)throw new mn(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=I();yn(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=I();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function Sn(e){return typeof e==`function`}function R(e){return bn(t=>{let n=Ct.bind(function(e){t.get()!==e&&(t.set(e),xn())});if(t.initialized)return[t.get(),n];let r=Sn(e)?e():e;return t.set(r),[r,n]})}function Cn(e,t){bn(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&L.queue(e),n.set(t)})}const wn={prefix:{idle:P(`blue`,`?`),done:P(`green`,Se.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>P(`yellow`,e))},style:{answer:e=>P(`cyan`,e),message:e=>P(`bold`,e),error:e=>P(`red`,`> ${e}`),defaultAnswer:e=>P(`dim`,`(${e})`),help:e=>P(`dim`,e),highlight:e=>P(`cyan`,e),key:e=>P(`cyan`,P(`bold`,`<${e}>`))}};function Tn(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function En(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=Tn(n)&&Tn(r)?En(n,r):r}return t}function Dn(...e){return En(wn,...e.filter(e=>e!=null))}function On({status:e=`idle`,theme:t}){let[n,r]=R(!1),[i,a]=R(0),{prefix:o,spinner:s}=Dn(t);return Cn(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function kn(e){return R({current:e})[0]}function An(e){let t=kn(e);t.current=e,Cn(e=>{let n=!1,r=yn((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var jn=e(Ae(),1);function Mn(e,t){return e.split(`
@@ -19,10 +19,10 @@ import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";impor
19
19
  `)}function Gr(){return new t(`signout`).description(`Remove stored credentials`).option(`--host <host>`,`GitHub hostname`,`github.com`).action(async e=>{await Wr(e)})}async function Kr(e,t,n=Br){let r=n(e);if(r.available&&r.token)return{tier:`A`,token:r.token};let i=await t.get(e);return i==null?{tier:`none`}:{tier:i.gitProtocol===`ssh`?`C`:`B`,token:i.token}}async function qr(e,t){let{host:n,json:r}=e;F(n);let i=await Kr(n,t);i.tier===`none`&&(r?process.stdout.write(`${JSON.stringify({type:`status`,host:n,authenticated:!1})}\n`):process.stderr.write(`Not logged in to ${n}\n`),process.exit(1));let a=n===`github.com`?void 0:`https://${n}/api/v3`,o=new B({auth:i.token,...a?{baseUrl:a}:{}});try{let{data:e}=await o.users.getAuthenticated();r?process.stdout.write(`${JSON.stringify({type:`status`,host:n,authenticated:!0,tier:i.tier,login:e.login,name:e.name,email:e.email})}\n`):process.stderr.write(`✓ Logged in as ${e.login} on ${n}\n`)}catch{r?process.stdout.write(JSON.stringify({type:`status`,host:n,authenticated:!1,error:`token invalid`})+`
20
20
  `):process.stderr.write(`✗ Token invalid for ${n}\n`),process.exit(1)}}function Jr(e){return new t(`status`).description(`Show authentication status`).option(`--host <host>`,`GitHub or GitHub Enterprise hostname`,`github.com`).option(`--json`,`Output JSON`,!1).action(async t=>{await qr(t,await e())})}function Yr(){let e=new t(`auth`);e.description(`GitHub authentication management`);let n=()=>Pt();return e.addCommand(cn(n)),e.addCommand(Jr(n)),e.addCommand(Ur(n)),e.addCommand(Gr()),e.addCommand(Rr(n)),e.addCommand(zt(n)),e}function V(e,t,n={}){let r=Re(e,t);if(!M(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(N(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!Ie(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??C)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};let o=n.host??yt();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Xr(e,t){let n=[];for(let[r,i]of[[`server`,e],[`ui`,t]])(i.status===`dead-pid`||i.status===`corrupt`)&&n.push({name:r,lockPath:i.lockPath,reason:i.status});return{prune:n}}function Zr(e){let t=e.inspect??(t=>V(e.lockDir,t)),n=e.unlink??(e=>ht(e)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=Xr(t(`server`),t(`ui`));if(a.prune.length===0)return r(`No stale locks.`),{pruned:[],failed:[]};let o=[],s=[];for(let e of a.prune)try{n(e.lockPath),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}if(o.length>0){let e=o.map(e=>`${e.name} (${e.reason})`).join(`, `);r(`Pruned ${o.length} stale lock${o.length===1?``:`s`}: ${e}`)}return s.length>0&&i(`Failed to prune: ${s.map(({target:e,error:t})=>`${e.name} (${e.lockPath}): ${t}`).join(`; `)}`),{pruned:o,failed:s}}function Qr(e){return new t(`clean`).description(`Prune stale / corrupt open-knowledge lock files (never touches live locks)`).action(()=>{e(),Zr({lockDir:m(process.cwd())}).failed.length>0&&(process.exitCode=1)})}async function $r(e,t,n={},r=Br){if(!n.skipGhDetect&&r().available)return{tier:`A`,credentialArgs:[`-c`,`credential.helper=!gh auth git-credential`]};let i=await t.get(e);return i==null?{tier:`none`,credentialArgs:[]}:{tier:i.gitProtocol===`ssh`?`C`:`B`,credentialArgs:[`-c`,`credential.helper=!open-knowledge auth git-credential`]}}async function ei(e,t,n=fetch){let r=new AbortController,i=setTimeout(()=>r.abort(),5e3);try{return(await n(`https://api.github.com/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{signal:r.signal,headers:{"User-Agent":`open-knowledge-cli`,Accept:`application/vnd.github+json`}})).status===200}catch{return!1}finally{clearTimeout(i)}}const ti=[[`count`,0,10],[`compress`,10,20],[`receiv`,20,60],[`resolv`,60,100]];function ni(e){let t=/^([\w ]+):\s+(\d+)%/.exec(e.trim());if(!t)return null;let n=t[1].toLowerCase(),r=Number(t[2]);for(let[e,i,a]of ti)if(n.includes(e))return{stage:t[1],pct:Math.round(i+r/100*(a-i))};return null}function H(e,t){e&&process.stdout.write(`${JSON.stringify(t)}\n`)}function ri(e,t,n){return e===`https`&&t===`github.com`&&n}async function ii(e,t,n,r=process.cwd()){let i=He(e);if(!i)throw Error(`Invalid git URL: ${e}`);let a=t.dir?j(r,t.dir):j(r,i.name);if(M(a)&&dt(a).length>0)throw Error(`Target directory is not empty: ${a}`);let o=await Pt(),s=i.protocol===`https`&&i.hostname===`github.com`?await ei(i.owner,i.name):!1,c=ri(i.protocol,i.hostname,s)?{tier:`none`,credentialArgs:[]}:await $r(i.hostname,o,{}),l=Be({baseDir:r,config:c.credentialArgs.length>=2?[c.credentialArgs[1]]:[],unsafe:{allowUnsafeCredentialHelper:!0}}).env({GIT_TERMINAL_PROMPT:`0`}),u=-1;l.outputHandler((e,n,r)=>{r.on(`data`,e=>{let n=e.toString(`utf-8`);for(let e of n.split(`
21
21
  `)){let n=ni(e);n&&n.pct!==u&&(u=n.pct,H(t.json,{type:`progress`,pct:n.pct,stage:n.stage}),t.json||process.stderr.write(`\r Cloning ${n.pct}%`))}})}),await l.clone(e,a,[`--progress`]),t.json||process.stderr.write(`
22
- `);try{let{runInit:e}=await import(`./init-LkHLm5ut.mjs`),n=await e({cwd:a,mcp:!1});if(n.contentUpdated.length>0){let e=`auto-init: updated ${n.contentUpdated.join(`, `)}`;t.json?H(!0,{type:`warning`,message:e}):process.stderr.write(` ${e}\n`)}}catch(e){let n=e instanceof Error?e.message:String(e);t.json?H(!0,{type:`warning`,message:`auto-init: ${n}`}):process.stderr.write(` auto-init: ${n}\n`)}try{ai(a)}catch(e){let n=e instanceof Error?e.message:String(e);t.json?H(!0,{type:`warning`,message:`git-exclude: ${n}`}):process.stderr.write(` git-exclude: ${n}\n`)}return a}function ai(e){let t=A(e,`.git`,`info`,`exclude`);if(!M(t))return`no-exclude`;let n=N(t,`utf-8`),r=new Set([`.ok`,`.ok/`,`/.ok`,`/.ok/`]);return n.split(`
22
+ `);try{let{runInit:e}=await import(`./init-EfEDGvh7.mjs`),n=await e({cwd:a,mcp:!1});if(n.contentUpdated.length>0){let e=`auto-init: updated ${n.contentUpdated.join(`, `)}`;t.json?H(!0,{type:`warning`,message:e}):process.stderr.write(` ${e}\n`)}}catch(e){let n=e instanceof Error?e.message:String(e);t.json?H(!0,{type:`warning`,message:`auto-init: ${n}`}):process.stderr.write(` auto-init: ${n}\n`)}try{ai(a)}catch(e){let n=e instanceof Error?e.message:String(e);t.json?H(!0,{type:`warning`,message:`git-exclude: ${n}`}):process.stderr.write(` git-exclude: ${n}\n`)}return a}function ai(e){let t=A(e,`.git`,`info`,`exclude`);if(!M(t))return`no-exclude`;let n=N(t,`utf-8`),r=new Set([`.ok`,`.ok/`,`/.ok`,`/.ok/`]);return n.split(`
23
23
  `).map(e=>e.trim()).some(e=>r.has(e))?`already-present`:(gt(t,`${n}${n.length===0||n.endsWith(`
24
24
  `)?``:`
25
- `}.ok/\n`,`utf-8`),`appended`)}function oi(e){return new t(`clone`).description(`Clone a git repository and open it`).argument(`<url>`,`Repository URL or owner/repo shorthand`).argument(`[dir]`,`Target directory (default: ./<repo-name>)`).option(`--json`,`Output JSONL progress events`,!1).action(async(t,n,r)=>{let i=e();try{let a=await ii(t,{json:r.json,dir:n},i);if(r.json)H(!0,{type:`complete`,dir:a});else{process.stderr.write(`✓ Cloned to ${a}\n`),process.chdir(a);let{startCommand:t}=await import(`./start-BYmlQzPZ.mjs`);await t(e).parseAsync([],{from:`user`})}}catch(e){let t=e instanceof Error?e.message:String(e);r.json?H(!0,{type:`error`,message:t}):process.stderr.write(`✗ ${t}\n`),process.exitCode=1}})}const si=[[`sync`],[`persistence`,`debounceMs`],[`persistence`,`maxDebounceMs`],[`server`,`port`],[`content`,`include`],[`content`,`exclude`]];function ci(e={}){let t=e.log??(e=>console.error(e)),n=e.error??(e=>console.error(e)),r=e.loadConfigFn??Ue;try{let{sources:n}=r(e.cwd);return t(`✓ Configuration valid (sources: ${n.length===0?`defaults only`:n.join(`, `)})`),{ok:!0}}catch(e){return n(e instanceof Error?e.message:String(e)),{ok:!1}}}function li(e){let t=(0,At.parseDocument)(N(e,`utf-8`));if(t.errors.length>0)throw Error(`Could not parse ${e}: ${t.errors.map(e=>e.message).join(`; `)}`);let n=[];for(let e of si)t.hasIn(e)&&n.push(e.join(`.`));return n}function ui(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function di(e){let t={};for(let n of e){let e=t;for(let t=0;t<n.length-1;t++){let r=n[t],i=e[r],a=ui(i)?i:{};e[r]=a,e=a}e[n[n.length-1]]=null}return t}async function fi(e={}){let t=e.log??(e=>console.log(e)),n=e.error??(e=>console.error(e)),r=e.scope??`both`,i=e.dryRun??!1,a=e.cwd??process.cwd(),o=e.writeConfigPatchFn??te,s=[];(r===`project`||r===`both`)&&s.push({scope:`project`,absPath:ne(`project`,a,e.homedirOverride)}),(r===`user`||r===`both`)&&s.push({scope:`user`,absPath:ne(`user`,a,e.homedirOverride)});let c=[],l=!0;for(let{scope:t,absPath:n}of s){if(!M(n)){c.push({path:n,scope:t,found:[],removed:[]});continue}let r;try{r=li(n)}catch(e){let r=e instanceof Error?e.message:String(e);c.push({path:n,scope:t,found:[],removed:[],error:r}),l=!1;continue}if(r.length===0||i){c.push({path:n,scope:t,found:r,removed:[]});continue}let s=await o({cwd:a,scope:t,patch:di(si.filter(e=>r.includes(e.join(`.`)))),homedirOverride:e.homedirOverride});if(!s.ok){c.push({path:n,scope:t,found:r,removed:[],error:fe(s.error)}),l=!1;continue}c.push({path:n,scope:t,found:r,removed:r})}for(let e of c)e.error&&n(`✗ ${e.path}: ${e.error}`);let u=c.some(e=>e.error!==void 0),d=c.reduce((e,t)=>e+t.found.length,0);if(d===0&&!u)t(`No deprecated fields found.`);else if(d>0)for(let e of c)e.error||(e.found.length===0?t(` ${e.path}: no deprecated fields`):t(i?`[dry-run] ${e.path}: would remove ${e.found.length} field(s): ${e.found.join(`, `)}`:`✓ ${e.path}: removed ${e.removed.length} field(s): ${e.removed.join(`, `)}`));return{outcomes:c,ok:l}}function pi(){let e=new t(`config`).description(`Inspect and maintain Open Knowledge configuration files`);return e.command(`validate`).description(`Validate the merged config (defaults → user → project)`).action(()=>{ci({}).ok||(process.exitCode=1)}),e.command(`migrate`).description(`Remove deprecated config fields (sync.*, persistence.{debounceMs,maxDebounceMs}, server.port, content.{include,exclude}) idempotently`).option(`--scope <scope>`,`Which scope to migrate: project | user | both`,`both`).option(`--dry-run`,`Preview without writing`,!1).action(async e=>{let t=e.scope;if(t!==`project`&&t!==`user`&&t!==`both`){console.error(`Invalid --scope: ${t}. Expected: project | user | both`),process.exitCode=2;return}(await fi({scope:t,dryRun:e.dryRun})).ok||(process.exitCode=1)}),e}var U=e(Ze(),1);const W=2e3,mi=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/];function hi(e){return mi.some(t=>t.test(e))}function gi(e){let t=e.trim().split(/\s+/).find(e=>e.startsWith(`--ok-lock-dir-b64=`));if(t==null)return null;let n=t.slice(18);if(!n)return null;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);return at(e)?e:null}catch{return null}}function _i(e){let t=[];for(let n of e.split(`
25
+ `}.ok/\n`,`utf-8`),`appended`)}function oi(e){return new t(`clone`).description(`Clone a git repository and open it`).argument(`<url>`,`Repository URL or owner/repo shorthand`).argument(`[dir]`,`Target directory (default: ./<repo-name>)`).option(`--json`,`Output JSONL progress events`,!1).action(async(t,n,r)=>{let i=e();try{let a=await ii(t,{json:r.json,dir:n},i);if(r.json)H(!0,{type:`complete`,dir:a});else{process.stderr.write(`✓ Cloned to ${a}\n`),process.chdir(a);let{startCommand:t}=await import(`./start-CnfoPWyL.mjs`);await t(e).parseAsync([],{from:`user`})}}catch(e){let t=e instanceof Error?e.message:String(e);r.json?H(!0,{type:`error`,message:t}):process.stderr.write(`✗ ${t}\n`),process.exitCode=1}})}const si=[[`sync`],[`persistence`,`debounceMs`],[`persistence`,`maxDebounceMs`],[`server`,`port`],[`content`,`include`],[`content`,`exclude`]];function ci(e={}){let t=e.log??(e=>console.error(e)),n=e.error??(e=>console.error(e)),r=e.loadConfigFn??Ue;try{let{sources:n}=r(e.cwd);return t(`✓ Configuration valid (sources: ${n.length===0?`defaults only`:n.join(`, `)})`),{ok:!0}}catch(e){return n(e instanceof Error?e.message:String(e)),{ok:!1}}}function li(e){let t=(0,At.parseDocument)(N(e,`utf-8`));if(t.errors.length>0)throw Error(`Could not parse ${e}: ${t.errors.map(e=>e.message).join(`; `)}`);let n=[];for(let e of si)t.hasIn(e)&&n.push(e.join(`.`));return n}function ui(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function di(e){let t={};for(let n of e){let e=t;for(let t=0;t<n.length-1;t++){let r=n[t],i=e[r],a=ui(i)?i:{};e[r]=a,e=a}e[n[n.length-1]]=null}return t}async function fi(e={}){let t=e.log??(e=>console.log(e)),n=e.error??(e=>console.error(e)),r=e.scope??`both`,i=e.dryRun??!1,a=e.cwd??process.cwd(),o=e.writeConfigPatchFn??te,s=[];(r===`project`||r===`both`)&&s.push({scope:`project`,absPath:ne(`project`,a,e.homedirOverride)}),(r===`user`||r===`both`)&&s.push({scope:`user`,absPath:ne(`user`,a,e.homedirOverride)});let c=[],l=!0;for(let{scope:t,absPath:n}of s){if(!M(n)){c.push({path:n,scope:t,found:[],removed:[]});continue}let r;try{r=li(n)}catch(e){let r=e instanceof Error?e.message:String(e);c.push({path:n,scope:t,found:[],removed:[],error:r}),l=!1;continue}if(r.length===0||i){c.push({path:n,scope:t,found:r,removed:[]});continue}let s=await o({cwd:a,scope:t,patch:di(si.filter(e=>r.includes(e.join(`.`)))),homedirOverride:e.homedirOverride});if(!s.ok){c.push({path:n,scope:t,found:r,removed:[],error:fe(s.error)}),l=!1;continue}c.push({path:n,scope:t,found:r,removed:r})}for(let e of c)e.error&&n(`✗ ${e.path}: ${e.error}`);let u=c.some(e=>e.error!==void 0),d=c.reduce((e,t)=>e+t.found.length,0);if(d===0&&!u)t(`No deprecated fields found.`);else if(d>0)for(let e of c)e.error||(e.found.length===0?t(` ${e.path}: no deprecated fields`):t(i?`[dry-run] ${e.path}: would remove ${e.found.length} field(s): ${e.found.join(`, `)}`:`✓ ${e.path}: removed ${e.removed.length} field(s): ${e.removed.join(`, `)}`));return{outcomes:c,ok:l}}function pi(){let e=new t(`config`).description(`Inspect and maintain Open Knowledge configuration files`);return e.command(`validate`).description(`Validate the merged config (defaults → user → project)`).action(()=>{ci({}).ok||(process.exitCode=1)}),e.command(`migrate`).description(`Remove deprecated config fields (sync.*, persistence.{debounceMs,maxDebounceMs}, server.port, content.{include,exclude}) idempotently`).option(`--scope <scope>`,`Which scope to migrate: project | user | both`,`both`).option(`--dry-run`,`Preview without writing`,!1).action(async e=>{let t=e.scope;if(t!==`project`&&t!==`user`&&t!==`both`){console.error(`Invalid --scope: ${t}. Expected: project | user | both`),process.exitCode=2;return}(await fi({scope:t,dryRun:e.dryRun})).ok||(process.exitCode=1)}),e}var U=e(Ze(),1);const W=2e3,mi=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/];function hi(e){return mi.some(t=>t.test(e))}function gi(e){let t=e.trim().split(/\s+/).find(e=>e.startsWith(`--ok-lock-dir-b64=`));if(t==null)return null;let n=t.slice(18);if(!n)return null;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);return at(e)?e:null}catch{return null}}function _i(e){let t=[];for(let n of e.split(`
26
26
  `)){let e=n.trim();if(!e)continue;let r=e.indexOf(` `);if(r===-1)continue;let i=e.slice(0,r),a=e.slice(r+1),o=Number.parseInt(i,10);!Number.isNaN(o)&&hi(a)&&t.push({pid:o,command:a})}return t}function vi(e){let t=[],n=e.split(`
27
27
  `);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.indexOf(` `);if(i===-1)continue;let a=r.slice(0,i),o=r.slice(i+1).trim(),s=Number.parseInt(a,10);!Number.isNaN(s)&&hi(o)&&t.push({pid:s,command:o})}return t}async function yi(){let e=k(`pgrep`,[`-a`,`-f`,`cli\\.mjs|open-knowledge|--ok-lock-dir-b64=|(^|[ /])ok[ ]+(start|mcp|ui)([ ]|$)|packages/(cli|app)|hocuspocus|vite`],{encoding:`utf-8`,timeout:W});if(!(e.error!=null&&e.error.code===`ENOENT`)){let t=e.stdout??``,n=_i(t);if(n.length>0||t.trim()===``)return n}let t=k(`ps`,[`-axo`,`pid,command`],{encoding:`utf-8`,timeout:W});return t.error!=null||!t.stdout?[]:vi(t.stdout)}function bi(e){let t=e.trim().split(/\s+/).filter(Boolean);for(let e of t){if(e.startsWith(`@`))continue;let t=rt(e);if(t===`open-knowledge`||t===`ok`||e.endsWith(`/packages/cli/src/cli.ts`)||e.endsWith(`/packages/cli/dist/cli.mjs`)||t===`cli.mjs`||t===`cli.ts`)return e}return null}function xi(e){let t=k(`ps`,[`-p`,String(e),`-o`,`command=`],{encoding:`utf-8`,timeout:W});return t.error!=null||!t.stdout?null:t.stdout.trim()||null}function Si(e){let t=k(`ps`,[`-p`,String(e),`-o`,`%cpu=,%mem=`],{encoding:`utf-8`,timeout:W});if(t.error!=null||!t.stdout)return null;let[n,r]=t.stdout.trim().split(/\s+/),i=Number.parseFloat(n??``),a=Number.parseFloat(r??``);return Number.isNaN(i)||Number.isNaN(a)?null:{cpuPercent:i,memPercent:a}}async function Ci(e){let t=k(`lsof`,[`-p`,String(e),`-a`,`-d`,`cwd`,`-Fn`],{encoding:`utf-8`,timeout:W});if(t.error!=null)return null;let n=t.stdout??``;for(let e of n.split(`
28
28
  `))if(e.startsWith(`n`)&&e.length>1)return e.slice(1);return null}function wi(e){let t=[],n=e.split(`
@@ -59,7 +59,7 @@ setTimeout(() => process.exit(2), ${t+1e4});
59
59
  `,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}else{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
60
60
  `&&r++}}return[t,n]}var mo=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=fo({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};const ho={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};var Y=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},go=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=Qi(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??ho}async _authThenStart(){if(!this._authProvider)throw new J(`No auth provider`);let e;try{e=await Ha(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new J;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=Zi(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:n,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new Y(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new mo({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=b.parse(JSON.parse(e.data));me(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new J(`No auth provider`);if(await Ha(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new J(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:h(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Y(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=Ka(o);if(this._resourceMetadataUrl=t,this._scope=n,await Ha(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new J;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=Ka(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new Y(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await Ha(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new J;return this.send(e)}}throw new Y(o.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),d(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`);if(c)if(l?.includes(`text/event-stream`))this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(l?.includes(`application/json`)){let e=await o.json(),t=Array.isArray(e)?e.map(e=>b.parse(e)):[b.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new Y(-1,`Unexpected content type: ${l}`);else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Y(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};function _o(e){return(t,n)=>{if((n?.method??`GET`).toUpperCase()===`GET`)return globalThis.fetch(t,n);let r=new AbortController,i=setTimeout(()=>r.abort(Error(`MCP request timed out after ${e}ms`)),e),a=n?.signal instanceof AbortSignal?AbortSignal.any([n.signal,r.signal]):r.signal;return globalThis.fetch(t,{...n,signal:a}).finally(()=>clearTimeout(i))}}function vo(e){if(e===void 0||e===``)return;let t=Number.parseInt(e,10);if(!(Number.isNaN(t)||t<=0))return t}function yo(e){return e===`0.0.0.0`||e===`::`?`localhost`:e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function bo(e,t){return`http://${yo(e)}:${t}/mcp`}function xo(e,t){return`ws://${yo(e)}:${t}`}function So(e){let t=new URL(e);return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.pathname=``,t.search=``,t.hash=``,t.toString().replace(/\/$/,``)}function Co(e,t){if(!(!e||e.port<=0)&&t(e.pid))return e.port}function wo(e){return M(e)?N(e,`utf-8`).trim():``}function To(e,t){return`server did not start within ${e}ms${t?` stderr:\n${t}`:``}`}function Eo(e){if(e&&typeof e==`object`&&`method`in e&&`id`in e)return e.id}function Do(e){if(!e||typeof e!=`object`||!(`result`in e))return;let t=e.result;if(!t||typeof t!=`object`||!(`protocolVersion`in t))return;let n=t.protocolVersion;return typeof n==`string`?n:void 0}function Oo(e,t){return{jsonrpc:`2.0`,id:e,error:{code:-32e3,message:t instanceof Error?t.message:String(t)}}}async function ko(e){let t=e.readLock??(()=>Le(e.lockDir)),n=e.isAlive??C,r=e.sleep??(e=>Ot(e)),i=e.spawn??tt,a=e.readErrorLog??wo,o=e.openErrorLog??(e=>ut(e,`w`)),s=e.closeFd??st,c=e.timeoutMs??5e3,l=e.pollIntervalMs??100;if(e.portOverride!==void 0){let t=Number.parseInt(e.portOverride,10);if(Number.isNaN(t)||t<=0)throw Error(`invalid --port value '${e.portOverride}' — HTTP MCP shim requires a positive port`);return bo(`localhost`,t)}let u=Co(t(),n);if(u!==void 0)return bo(`localhost`,u);if(e.envAutoStart===`0`)throw Error(`Open Knowledge server is not running and OK_MCP_AUTOSTART=0 disables auto-start.`);M(e.lockDir)||ct(e.lockDir,{recursive:!0});let d=A(e.lockDir,`last-spawn-error.log`),f=o(d),p,m,h=Ge();try{try{p=i(h.command,[...h.prefixArgs,`start`],{detached:!0,stdio:[`ignore`,`ignore`,f],cwd:e.contentDir,env:{...process.env,OK_LOCK_KIND:`mcp-spawned`}}),p.on(`error`,e=>{m=e instanceof Error?e.message:String(e)}),p.unref()}catch(e){m=e instanceof Error?e.message:String(e)}}finally{try{s(f)}catch{}}let ee=Date.now()+c;for(;Date.now()<ee;){if(m){let e=a(d),t=e?` stderr:\n${e}`:``;throw Error(`spawn failed: ${m}${t}`)}await r(l);let e=Co(t(),n);if(e!==void 0)return bo(`localhost`,e)}if(m){let e=a(d),t=e?` stderr:\n${e}`:``;throw Error(`spawn failed: ${m}${t}`)}throw Error(To(c,a(d)))}function Ao(e,t){if(e.portOverride!==void 0)return So(t);let n=e.readLock??(()=>Le(e.lockDir)),r=e.isAlive??C,i=Co(n(),r);if(i!==void 0)return xo(`localhost`,i)}async function jo(e,t={}){let n=t.stderr??process.stderr,r=t.requestTimeoutMs??12e4,i=t.createStdioTransport?t.createStdioTransport(t.stdin,t.stdout):new Ki(t.stdin,t.stdout),a=t.createHttpTransport?t.createHttpTransport(new URL(e)):new go(new URL(e),{fetch:_o(r),...t.connectionId===void 0?{}:{requestInit:{headers:{[c]:t.connectionId}}}}),o=!1,s=async()=>{o||(o=!0,t.onclose?.(),await Promise.allSettled([i.close(),a.close()]))};i.onerror=e=>{n.write(`[mcp-shim] stdio error: ${e.message}\n`)},a.onerror=e=>{n.write(`[mcp-shim] HTTP transport error: ${e.message}\n`)},i.onclose=()=>{s()},a.onclose=()=>{s()};let l=Promise.resolve();i.onmessage=e=>{l=l.then(async()=>{try{await a.send(e)}catch(t){let r=Eo(e);if(r===void 0){n.write(`[mcp-shim] failed to forward stdio notification: ${t instanceof Error?t.message:String(t)}\n`);return}await i.send(Oo(r,t)).catch(e=>{n.write(`[mcp-shim] failed to write stdio error response: ${e instanceof Error?e.message:String(e)}\n`)})}}).catch(e=>{n.write(`[mcp-shim] unexpected stdio forwarding failure: ${e instanceof Error?e.message:String(e)}\n`)})},a.onmessage=e=>{let t=Do(e);t&&a.setProtocolVersion?.(t),i.send(e).catch(e=>{n.write(`[mcp-shim] failed to write stdio response: ${e instanceof Error?e.message:String(e)}\n`)})};try{await a.start(),await i.start()}catch(e){throw await s(),e}return{close:s}}async function Mo(e){let t=e.stderr??process.stderr,n=e.bridgeFn??jo,r=await ko(e),i=e.createConnectionId?.()??Et(),a=!1,o=(e.startKeepalive??Xi)({connectionId:i,resolveWsUrl:async()=>Ao(e,r),log:e=>t.write(`[mcp-shim] keepalive: ${e}\n`)});t.write(`[mcp-shim] proxying stdio to ${r}\n`);let s;try{s=await n(r,{stderr:t,connectionId:i,onclose:()=>{a||(o.close(),process.exit(0))}})}catch(e){throw o.close(),e}let c=()=>{a=!0,o.close(),s.close().finally(()=>{process.exit(0)})};process.once(`SIGINT`,c),process.once(`SIGTERM`,c)}const No=xt(import.meta.url);function Po(e){let t=j(e);for(;;){if(pe(t))return t;let n=it(t);if(n===t)throw Error(`No Open Knowledge project found at or above ${e}. Pass an explicit \`cwd\` argument that points inside an OK project (a directory with a \`${he}\`).`);t=n}}function Fo(e){try{let t=new URL(e);return t.protocol===`file:`?xt(t):void 0}catch{return}}async function Io(e){if(!e.getClientCapabilities()?.roots)return;let t;try{t=await e.listRoots()}catch(t){e.log?.(`listRoots fallback failed: ${t instanceof Error?t.message:String(t)}`);return}let n=t.roots??[];if(n.length!==1)return;let r=Fo(n[0].uri);return r===void 0&&e.log?.(`single root URI not usable as fs path: ${n[0].uri}`),r}async function Lo(e,t){if(e!==void 0)return Po(e);let n=await t();if(n!==void 0)return Po(n);throw Error("`cwd` is required for tool calls against the global MCP server. Pass an absolute path inside an Open Knowledge project, or have the MCP client advertise a single root.")}async function Ro(e){let t=process.stderr,n=e.spawnTimeoutMs??vo(process.env.OK_MCP_SPAWN_TIMEOUT_MS),r=e.envAutoStart??process.env.OK_MCP_AUTOSTART,i=We({startupCwd:e.startupCwd,startupConfig:e.startupConfig}),o=new p({name:a,version:ze},{instructions:oe({dir:`.`})});ue(o);let s=Et(),c={current:{connectionId:s,displayName:s,colorSeed:s}},l=new Map,d=e=>{if(l.has(e))return;let n=f(e),r=c.current,i=Xi({connectionId:s,displayName:r.displayName,clientName:r.clientInfo?.name??r.displayName,colorSeed:r.colorSeed,resolveWsUrl:async()=>Ao({lockDir:n,contentDir:e},``),log:n=>t.write(`[mcp] keepalive[${e}]: ${n}\n`)});l.set(e,i)},m=()=>Io({getClientCapabilities:()=>o.server.getClientCapabilities(),listRoots:()=>o.server.listRoots(),log:e=>t.write(`[mcp] ${e}\n`)}),h=e=>Lo(e,m),ee=async e=>{let t;if(e===void 0){let e=await m();if(e===void 0)return;t=Po(e)}else t=Po(e);let a=await i(t),o=await ko({lockDir:f(t),contentDir:u(a,t),envAutoStart:r,...n===void 0?{}:{timeoutMs:n}});return d(t),o.replace(/\/mcp$/,``)};o.server.oninitialized=()=>{let e=o.server.getClientVersion(),t=ae(e?.name,s);c.current={connectionId:s,clientInfo:e?{name:t,version:e.version}:void 0,displayName:t,colorSeed:t}},ye(o,{serverUrl:ee,resolveCwd:h,config:i,identityRef:c});let g=new Ki,_=!1,v,y=async()=>{if(_)return;_=!0,v?.stop();for(let e of l.values())try{e.close()}catch(e){t.write(`[mcp] keepalive close error: ${e instanceof Error?e.message:String(e)}\n`)}l.clear();let e=await Promise.allSettled([o.close(),g.close()]);for(let n of e)if(n.status===`rejected`){let e=n.reason;t.write(`[mcp] shutdown close error: ${e instanceof Error?e.message:String(e)}\n`)}};await o.connect(g),t.write(`[mcp] global stdio server ready (per-call project routing)
61
61
  `);let b=!1,x=()=>{b||(b=!0,setTimeout(()=>{t.write(`[mcp] shutdown deadline (5s) reached — forcing exit(1)
62
- `),process.exit(1)},5e3).unref(),y().finally(()=>{process.exit(0)}))};if(process.once(`SIGINT`,x),process.once(`SIGTERM`,x),process.platform===`darwin`){let e=Yi(No,{realpathSync:ft,statInoSync:e=>mt(e).ino,log:e=>t.write(`${e}\n`)});if(e!==void 0){t.write(`[mcp] bundle identity anchor=${e.resolvedPath} inode=${e.inode} version=${ze}\n`);let{resolvedPath:n,inode:r}=e;v=Ji({detect:()=>qi({bundleAnchorPath:No,currentInode:r,platform:process.platform,realpath:ft,statInode:e=>mt(e).ino}),onReplaced:e=>{t.write(`[mcp] bundle replaced anchor=${n} bootInode=${e.currentInode} onDiskInode=${e.onDiskInode} version=${ze} — exiting for host respawn\n`),x()},log:e=>t.write(`[mcp] ${e}\n`)})}}return{close:y}}function zo(e){return new t(`mcp`).description(`Start MCP stdio server for project knowledge base`).option(`-p, --port <port>`,`Override per-call routing and proxy stdio to this HTTP MCP port`,void 0).action(async t=>{try{let n=e(),r=process.cwd();if(t.port!==void 0){let e=vo(process.env.OK_MCP_SPAWN_TIMEOUT_MS);await Mo({lockDir:``,contentDir:``,portOverride:t.port,envAutoStart:process.env.OK_MCP_AUTOSTART,timeoutMs:e});return}await Ro({startupCwd:r,startupConfig:n})}catch(e){process.stderr.write(`MCP server failed to start: ${e instanceof Error?e.message:String(e)}\n`),process.exitCode=1}})}function Bo(e){return new t(`preview`).description(`Show what content the watcher will track (read-only)`).action(async()=>{let{previewContent:t,formatPreviewBlock:n}=await import(`./preview-DXHcHw7y.mjs`),r=e(),i=process.cwd(),a=u(r,i),o;try{o=t({projectDir:i,contentDir:a})}catch(e){console.error(`Content preview failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}process.stdout.write(`${n(o,i)}\n`),o.totalCount===0&&o.warnings.length>0&&(process.exitCode=1)})}function Vo(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Ho(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Uo(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:bi(r),command:r,isDesktop:Vo(r)}}function Wo(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Go(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&Wo(e)?`ui-orphan`:`stale`}const Ko=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function qo(e){switch(e){case`running`:return U.default.green(e);case`desktop`:return U.default.blue(e);case`foreign`:return U.default.cyan(e);case`ui-orphan`:return U.default.magenta(e);case`stale`:return U.default.yellow(e)}}function Jo(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Yo(e){return`${Jo(e.server.usage)} | ${Jo(e.ui?.usage??null)}`}function Xo(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function Zo(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Go(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,Xo(e),Yo(e),t,String(n),Ho(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=qo(Go(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=U.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
62
+ `),process.exit(1)},5e3).unref(),y().finally(()=>{process.exit(0)}))};if(process.once(`SIGINT`,x),process.once(`SIGTERM`,x),process.platform===`darwin`){let e=Yi(No,{realpathSync:ft,statInoSync:e=>mt(e).ino,log:e=>t.write(`${e}\n`)});if(e!==void 0){t.write(`[mcp] bundle identity anchor=${e.resolvedPath} inode=${e.inode} version=${ze}\n`);let{resolvedPath:n,inode:r}=e;v=Ji({detect:()=>qi({bundleAnchorPath:No,currentInode:r,platform:process.platform,realpath:ft,statInode:e=>mt(e).ino}),onReplaced:e=>{t.write(`[mcp] bundle replaced anchor=${n} bootInode=${e.currentInode} onDiskInode=${e.onDiskInode} version=${ze} — exiting for host respawn\n`),x()},log:e=>t.write(`[mcp] ${e}\n`)})}}return{close:y}}function zo(e){return new t(`mcp`).description(`Start MCP stdio server for project knowledge base`).option(`-p, --port <port>`,`Override per-call routing and proxy stdio to this HTTP MCP port`,void 0).action(async t=>{try{let n=e(),r=process.cwd();if(t.port!==void 0){let e=vo(process.env.OK_MCP_SPAWN_TIMEOUT_MS);await Mo({lockDir:``,contentDir:``,portOverride:t.port,envAutoStart:process.env.OK_MCP_AUTOSTART,timeoutMs:e});return}await Ro({startupCwd:r,startupConfig:n})}catch(e){process.stderr.write(`MCP server failed to start: ${e instanceof Error?e.message:String(e)}\n`),process.exitCode=1}})}function Bo(e){return new t(`preview`).description(`Show what content the watcher will track (read-only)`).action(async()=>{let{previewContent:t,formatPreviewBlock:n}=await import(`./preview-DKH3UaeV.mjs`),r=e(),i=process.cwd(),a=u(r,i),o;try{o=t({projectDir:i,contentDir:a})}catch(e){console.error(`Content preview failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}process.stdout.write(`${n(o,i)}\n`),o.totalCount===0&&o.warnings.length>0&&(process.exitCode=1)})}function Vo(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Ho(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Uo(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:bi(r),command:r,isDesktop:Vo(r)}}function Wo(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Go(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&Wo(e)?`ui-orphan`:`stale`}const Ko=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function qo(e){switch(e){case`running`:return U.default.green(e);case`desktop`:return U.default.blue(e);case`foreign`:return U.default.cyan(e);case`ui-orphan`:return U.default.magenta(e);case`stale`:return U.default.yellow(e)}}function Jo(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Yo(e){return`${Jo(e.server.usage)} | ${Jo(e.ui?.usage??null)}`}function Xo(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function Zo(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Go(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,Xo(e),Yo(e),t,String(n),Ho(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=qo(Go(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=U.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
63
63
  `)}async function Qo(e={}){let t=e.discover??Ti,n=e.inspect??V,r=e.log??(e=>console.log(e)),i=e.resolveCommand??xi,a=e.resolveUsage??Si,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=Uo(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:Go(e)}));r(JSON.stringify(e,null,2));return}r(Zo(e.all?s:s.filter(e=>Ko.has(Go(e)))))}function $o(){return new t(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await Qo({all:t.all===!0||e===`all`,json:t.json===!0})})}function X(e,t){e&&process.stdout.write(`${JSON.stringify(t)}\n`)}async function es(e,t,n=process.cwd()){let r=e.op??`sync`,i=Le(m(n));if(i&&i.port>0){let t=`http://127.0.0.1:${i.port}/api/sync/trigger`;e.json||process.stderr.write(`Triggering ${r} via running server (port ${i.port})\n`);try{let n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:r})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.title??e.error??e.message??`Server responded with ${n.status}`)}X(e.json,{type:`triggered`,op:r,port:i.port}),e.json||process.stderr.write(`✓ ${r} triggered\n`);return}catch(t){let n=t instanceof Error?t.message:String(t);e.json||process.stderr.write(`Server trigger failed (${n}), running directly\n`)}}e.json||process.stderr.write(`Running ${r} directly (no live server)\n`);let a=Be({baseDir:n});if(r===`sync`||r===`pull`){X(e.json,{type:`step`,step:`pull`});let t=await a.pull();X(e.json,{type:`pull`,summary:t.summary}),e.json||process.stderr.write(` pull: ${t.summary.changes} changes\n`)}(r===`sync`||r===`push`)&&(X(e.json,{type:`step`,step:`push`}),await a.push(),X(e.json,{type:`push`,ok:!0}),e.json||process.stderr.write(` push: ok
64
64
  `)),X(e.json,{type:`complete`,op:r}),e.json||process.stderr.write(`✓ ${r} complete\n`)}function ts(e){return new t(`sync`).description(`Commit, pull, and push to the remote`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{try{await es({json:t.json,op:`sync`},e())}catch(e){let n=e instanceof Error?e.message:String(e);t.json?process.stdout.write(`${JSON.stringify({type:`error`,message:n})}\n`):process.stderr.write(`✗ sync failed: ${n}\n`),process.exit(1)}})}function ns(e){return new t(`pull`).description(`Pull changes from the remote`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{try{await es({json:t.json,op:`pull`},e())}catch(e){let n=e instanceof Error?e.message:String(e);t.json?process.stdout.write(`${JSON.stringify({type:`error`,message:n})}\n`):process.stderr.write(`✗ pull failed: ${n}\n`),process.exit(1)}})}function rs(e){return new t(`push`).description(`Push commits to the remote`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{try{await es({json:t.json,op:`push`},e())}catch(e){let n=e instanceof Error?e.message:String(e);t.json?process.stdout.write(`${JSON.stringify({type:`error`,message:n})}\n`):process.stderr.write(`✗ push failed: ${n}\n`),process.exit(1)}})}function is(e){return typeof e==`string`&&r.includes(e)}async function as(e={}){let t=j(e.cwd??process.cwd()),n=e.pack??`knowledge-base`;if(!ve[n])return{status:`failed`,message:`${D(`Error:`)} Unknown pack "${n}". Available: ${r.join(`, `)}`,exitCode:1};let i;try{i=await s({projectDir:t,rootDir:e.root,packId:n})}catch(e){return e instanceof y?{status:`prerequisite-missing`,message:`${D(`Error:`)} ${e.message}`,exitCode:1}:{status:`failed`,message:`${D(`Error:`)} ${e instanceof Error?e.message:String(e)}`,exitCode:1}}if(i.created.length===0){let e=ve[n].name;return{status:`no-op`,message:`${E(`Your ${e} pack is already seeded.`)}\n${T(`Nothing to do.`)}`,plan:i,exitCode:0}}if(e.dryRun)return{status:`dry-run`,message:`${O(`Plan (dry-run — no changes made):`)}\n\n${ss(i,t)}`,plan:i,exitCode:0};if(!e.yes&&!await cs(`${O(`Plan:`)}\n\n${ss(i,t)}\n\n${O(`Apply?`)} ${T(`[Y/n] `)}`,e.confirmStream))return{status:`cancelled`,message:T(`Cancelled.`),plan:i,exitCode:0};let a=await re(i,{projectDir:t,packId:n});if(a.errors.length>0){let e=a.errors.map(e=>` ${D(`✗`)} ${e.path}: ${e.error}`);return{status:`failed`,message:[`${Qe(`Applied`)} ${a.applied} entries, ${Qe(String(a.errors.length))} error(s):`,...e].join(`
65
65
  `),plan:i,exitCode:1}}let o=ve[n].name;return{status:`applied`,message:`${E(`✓ Seeded ${o}`)} ${T(`(${a.applied} entries, ${a.durationMs}ms)`)}`,plan:i,exitCode:0}}function os(){let e=[O(`Available packs:`)];for(let t of r){let n=ve[t];e.push(` ${E(t)} ${T(`—`)} ${n.name}: ${n.description}`)}return e.join(`
@@ -56,6 +56,22 @@
56
56
  },
57
57
  "additionalProperties": {}
58
58
  },
59
+ "editor": {
60
+ "default": {
61
+ "wordWrap": true
62
+ },
63
+ "type": "object",
64
+ "properties": {
65
+ "wordWrap": {
66
+ "default": true,
67
+ "type": "boolean",
68
+ "scope": "user",
69
+ "agentSettable": false,
70
+ "defaultScope": "user"
71
+ }
72
+ },
73
+ "additionalProperties": {}
74
+ },
59
75
  "autoSync": {
60
76
  "default": {
61
77
  "enabled": null
@@ -20,6 +20,22 @@
20
20
  },
21
21
  "additionalProperties": {}
22
22
  },
23
+ "editor": {
24
+ "default": {
25
+ "wordWrap": true
26
+ },
27
+ "type": "object",
28
+ "properties": {
29
+ "wordWrap": {
30
+ "default": true,
31
+ "type": "boolean",
32
+ "scope": "user",
33
+ "agentSettable": false,
34
+ "defaultScope": "user"
35
+ }
36
+ },
37
+ "additionalProperties": {}
38
+ },
23
39
  "autoSync": {
24
40
  "default": {
25
41
  "enabled": null
@@ -0,0 +1,2 @@
1
+ import"./dist-beLXrhv5.mjs";var e=`0.5.1-beta.0`;const t=`config.yml`,n=e;export{n,t};
2
+ //# sourceMappingURL=constants-BqA_tvx_.mjs.map