@inkeep/open-knowledge 0.6.0-beta.12 → 0.6.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD_PARTY_NOTICES.md +35 -0
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +22 -20
- package/dist/cli.mjs +4 -4
- package/dist/constants-D5d7eVsY.mjs +2 -0
- package/dist/{dist-n1_faV8H.mjs → dist-B94c-P-G.mjs} +1 -1
- package/dist/{dist-BFYM3eBv.mjs → dist-DviTRTbb.mjs} +29 -28
- package/dist/index.mjs +1 -1
- package/dist/init-BSRUkYPY.mjs +1 -0
- package/dist/{init-eKqMOdsK.mjs → init-xf7nob8y.mjs} +4 -4
- package/dist/{loader-DZfiF-xk.mjs → loader-BvXfD2lW.mjs} +2 -2
- package/dist/loader-IMXoxYG8.mjs +1 -0
- package/dist/{preview-DU_WuUIO.mjs → preview-DCeNyUeh.mjs} +2 -2
- package/dist/preview-SplPcGG3.mjs +1 -0
- package/dist/public/assets/ActivityModeContent-BTDXmmcF.js +2 -0
- package/dist/public/assets/{ConsentDialogBody-BB9hO7dl.js → ConsentDialogBody-CImrdpFX.js} +1 -1
- package/dist/public/assets/DocumentContext-BLVVzPxk.js +52 -0
- package/dist/public/assets/GraphPanel-MDxyn9iQ.js +46 -0
- package/dist/public/assets/{McpConsentDialogBody-BuE8FaKs.js → McpConsentDialogBody-Bh3i0mQ8.js} +1 -1
- package/dist/public/assets/SettingsDialogBody-DcjK_PiT.js +7 -0
- package/dist/public/assets/{SourceEditor-C2zRNx9p.js → SourceEditor-wRLdKlEx.js} +1 -1
- package/dist/public/assets/config-validation-events-2g5Tn60q.js +11 -0
- package/dist/public/assets/{dist-DQ1oWohr.js → dist-CadHdAvi.js} +1 -1
- package/dist/public/assets/{dist-By89CQBy.js → dist-CdAufVHw.js} +1 -1
- package/dist/public/assets/{dist-DllAuqQQ.js → dist-Cwt7KtW7.js} +1 -1
- package/dist/public/assets/{dist-DpEGxZ9h.js → dist-DRBAXDc3.js} +1 -1
- package/dist/public/assets/{dist-D-oqC0-R.js → dist-DkR43q3h.js} +1 -1
- package/dist/public/assets/{dist-DXgyWuz5.js → dist-y5PvfJVO.js} +1 -1
- package/dist/public/assets/index-BG8pn9At.js +1915 -0
- package/dist/public/assets/index-Cr48lc4Y.css +1 -0
- package/dist/public/assets/{doc-hash-Boyf1aFv.js → prop-types-DgXoNo88.js} +45 -45
- package/dist/public/assets/target-navigation-intent-4pvac8Xe.js +1 -0
- package/dist/public/assets/toggle-group-KLnzY88z.js +1 -0
- package/dist/public/assets/{typing-burst-detector-DtROfmtk.js → typing-burst-detector-YLtKpRD8.js} +2 -2
- package/dist/public/index.html +17 -17
- package/dist/{repair-launch-json-B_vLwTyJ.mjs → repair-launch-json-CaI8X8Xi.mjs} +2 -2
- package/dist/{repair-mcp-configs-DCS4Vnyo.mjs → repair-mcp-configs-CEUwN5Rf.mjs} +2 -2
- package/dist/{src-PPuu2g0W.mjs → src-DywZNuWB.mjs} +2 -2
- package/dist/start-CE8LQ1MY.mjs +1 -0
- package/dist/{start-c_izpvAl.mjs → start-qB7qGHyG.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-CEMFB8Qg.mjs +0 -2
- package/dist/init-DeUleM-p.mjs +0 -1
- package/dist/loader-TXZJ7l3J.mjs +0 -1
- package/dist/preview-CjzNpDPT.mjs +0 -1
- package/dist/public/assets/ActivityModeContent-HgjxWnE6.js +0 -2
- package/dist/public/assets/DocumentContext-DDeOywW4.js +0 -52
- package/dist/public/assets/GraphPanel-CW-AecTP.js +0 -46
- package/dist/public/assets/SettingsDialogBody-whvgDiVL.js +0 -7
- package/dist/public/assets/config-validation-events-KtrCfkDN.js +0 -10
- package/dist/public/assets/index-CXzfIokG.css +0 -1
- package/dist/public/assets/index-Dp8XXRqU.js +0 -1916
- package/dist/public/assets/target-navigation-intent-DkKQt1k3.js +0 -1
- package/dist/public/assets/toggle-group-DfSkpOSV.js +0 -1
- package/dist/start-CyasRtdN.mjs +0 -1
- /package/dist/public/assets/{dist-D3YXABda.js → dist-sw9fzKjM.js} +0 -0
- /package/dist/public/assets/{label-BGXy6Okv.js → label-DCMZaJ38.js} +0 -0
- /package/dist/public/assets/{mcp-consent-store-BPw6Zd40.js → mcp-consent-store-19Boxoxe.js} +0 -0
- /package/dist/public/assets/{project-paths-DKT5BePl.js → project-paths-eyh51nmQ.js} +0 -0
- /package/dist/public/assets/{stex-ChE_gMQ6.js → stex-DxnLy7rA.js} +0 -0
|
@@ -2459,6 +2459,11 @@ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/p
|
|
|
2459
2459
|
|
|
2460
2460
|
Copyright (c) Microsoft Corporation.
|
|
2461
2461
|
|
|
2462
|
+
### `@types/react@19.2.14`
|
|
2463
|
+
Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react
|
|
2464
|
+
|
|
2465
|
+
Copyright (c) Microsoft Corporation.
|
|
2466
|
+
|
|
2462
2467
|
### `@types/statuses@2.0.6`
|
|
2463
2468
|
Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/statuses
|
|
2464
2469
|
|
|
@@ -2489,6 +2494,11 @@ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/v
|
|
|
2489
2494
|
|
|
2490
2495
|
Copyright (c) Microsoft Corporation.
|
|
2491
2496
|
|
|
2497
|
+
### `@types/vimeo__player@2.18.3`
|
|
2498
|
+
Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/vimeo__player
|
|
2499
|
+
|
|
2500
|
+
Copyright (c) Microsoft Corporation.
|
|
2501
|
+
|
|
2492
2502
|
### `@types/yargs@17.0.35`
|
|
2493
2503
|
Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs
|
|
2494
2504
|
|
|
@@ -2499,6 +2509,11 @@ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/y
|
|
|
2499
2509
|
|
|
2500
2510
|
Copyright (c) Microsoft Corporation.
|
|
2501
2511
|
|
|
2512
|
+
### `@u-wave/react-vimeo@0.9.12`
|
|
2513
|
+
Homepage: https://github.com/u-wave/react-vimeo#readme
|
|
2514
|
+
|
|
2515
|
+
Copyright (c) 2016 Renée Kooi
|
|
2516
|
+
|
|
2502
2517
|
### `@uiw/codemirror-theme-basic@4.25.9`
|
|
2503
2518
|
Homepage: https://uiwjs.github.io/react-codemirror/#/theme/data/basic/light
|
|
2504
2519
|
|
|
@@ -2514,6 +2529,11 @@ Homepage: https://github.com/upsetjs/venn.js
|
|
|
2514
2529
|
|
|
2515
2530
|
Copyright (c) 2013 Ben Frederickson Copyright (c) 2021 Samuel Gratzl
|
|
2516
2531
|
|
|
2532
|
+
### `@vimeo/player@2.30.4`
|
|
2533
|
+
Homepage: https://github.com/vimeo/player.js
|
|
2534
|
+
|
|
2535
|
+
Copyright (c) 2016 [Vimeo](https://vimeo.com)
|
|
2536
|
+
|
|
2517
2537
|
### `accepts@2.0.0`
|
|
2518
2538
|
Homepage: https://github.com/jshttp/accepts
|
|
2519
2539
|
|
|
@@ -2913,6 +2933,11 @@ Homepage: https://mths.be/cssesc
|
|
|
2913
2933
|
|
|
2914
2934
|
_(No LICENSE file in package; SPDX identifier in `package.json` is the sole declared grant.)_
|
|
2915
2935
|
|
|
2936
|
+
### `csstype@3.2.3`
|
|
2937
|
+
Homepage: https://github.com/frenic/csstype
|
|
2938
|
+
|
|
2939
|
+
Copyright (c) 2017-2018 Fredrik Nicol
|
|
2940
|
+
|
|
2916
2941
|
### `cytoscape@3.33.2`
|
|
2917
2942
|
Homepage: http://js.cytoscape.org
|
|
2918
2943
|
|
|
@@ -4265,6 +4290,11 @@ Homepage: https://github.com/inspiredware/napi-build-utils#readme
|
|
|
4265
4290
|
|
|
4266
4291
|
Copyright (c) 2018 inspiredware
|
|
4267
4292
|
|
|
4293
|
+
### `native-promise-only@0.8.1`
|
|
4294
|
+
Homepage: http://github.com/getify/native-promise-only
|
|
4295
|
+
|
|
4296
|
+
_(No LICENSE file in package; SPDX identifier in `package.json` is the sole declared grant.)_
|
|
4297
|
+
|
|
4268
4298
|
### `negotiator@1.0.0`
|
|
4269
4299
|
Homepage: https://github.com/jshttp/negotiator
|
|
4270
4300
|
|
|
@@ -5501,6 +5531,11 @@ Homepage: https://github.com/BerkeleyTrue/warning
|
|
|
5501
5531
|
|
|
5502
5532
|
Copyright (c) 2013-present, Facebook, Inc.
|
|
5503
5533
|
|
|
5534
|
+
### `weakmap-polyfill@2.0.4`
|
|
5535
|
+
Homepage: https://github.com/polygonplanet/weakmap-polyfill
|
|
5536
|
+
|
|
5537
|
+
Copyright (c) 2015-2021 polygonplanet
|
|
5538
|
+
|
|
5504
5539
|
### `web-namespaces@2.0.1`
|
|
5505
5540
|
Homepage: https://github.com/wooorm/web-namespaces
|
|
5506
5541
|
|
|
@@ -3,7 +3,7 @@ name: open-knowledge-discovery
|
|
|
3
3
|
description: "Read when the user asks what Open Knowledge is, wants to install it on a repository, wants to share an Open Knowledge project with collaborators, or asks how `ok init` / `ok install-skill` / OK Desktop set up a project. Do NOT load to perform Open Knowledge reads/writes — the runtime guidance for editing markdown inside an initialized OK project ships as a separate project-local skill at `.claude/skills/open-knowledge/` whenever `ok init` runs. If the user appears to be editing markdown inside a `.ok/` project and this is the only OK skill loaded, advise them to re-run `ok init` to install the project-local skill."
|
|
4
4
|
compatibility: "Any agent host — no MCP server required. Pure discovery + install guidance."
|
|
5
5
|
metadata:
|
|
6
|
-
version: "0.6.0-beta.
|
|
6
|
+
version: "0.6.0-beta.14"
|
|
7
7
|
author: "Inkeep"
|
|
8
8
|
repository: "https://github.com/inkeep/open-knowledge"
|
|
9
9
|
---
|
|
@@ -3,7 +3,7 @@ name: open-knowledge
|
|
|
3
3
|
description: "MUST invoke before reading or editing any `.md` / `.mdx` file, and before any `mcp__open-knowledge__*` tool call (`exec`, `search`, `write_document`, `edit_document`, and the rest). This skill is installed into the repository by `ok init`, so its presence alone means this is an Open Knowledge project — its runtime contract governs every markdown file here, with no need to probe for a `.ok/` directory. Authoritative agent-runtime contract; supersedes the overlapping MCP server `instructions` echo."
|
|
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.6.0-beta.
|
|
6
|
+
version: "0.6.0-beta.14"
|
|
7
7
|
author: "Inkeep"
|
|
8
8
|
repository: "https://github.com/inkeep/open-knowledge"
|
|
9
9
|
---
|
|
@@ -19,16 +19,16 @@ Open Knowledge (OK) is a markdown-CRDT collaboration platform exposed via MCP. T
|
|
|
19
19
|
|
|
20
20
|
1. **Reads:** `exec("cat …")` for a single doc, `exec("ls -A …")` for a directory (with folder defaults + template menu), `exec("grep …")` for literal, `search` for ranked retrieval. Native `Read` / `Grep` only on source code (`.ts` / `.py` / …), never on in-scope `.md` / `.mdx`.
|
|
21
21
|
2. **Writes:** `write_document` for new or full-replace, `edit_document` for body-only find/replace, `edit_frontmatter` for 1-2 frontmatter keys (JSON Merge Patch — preferred). Full frontmatter rewrites use `write_document({ position: "replace" })`. `edit_document` rejects frontmatter (HTTP 400).
|
|
22
|
-
3. **Preview:** every OK
|
|
22
|
+
3. **Preview:** every OK read/write response carries a route-only `previewUrl` (`/#/<doc>`, no host:port). If you have a `preview_*` tool, call `preview_start("open-knowledge-ui")`; otherwise call `get_preview_url` once for the full browser URL and open it in your own in-app browser. Surface to the user on a `start-ui` warning (no UI running). Don't `preview_screenshot` to confirm edits — the CRDT tool response is the confirmation.
|
|
23
23
|
4. **Workflow tools** (`ingest` / `research` / `consolidate` / `discover`) return procedural guides, not data. Use them when the work fits the layer; follow their numbered steps.
|
|
24
24
|
|
|
25
25
|
Everything below is depth. Read on demand.
|
|
26
26
|
|
|
27
|
-
## Tool index —
|
|
27
|
+
## Tool index — 18 tools
|
|
28
28
|
|
|
29
29
|
The full MCP surface, grouped by risk-level. Every tool's `kind` / `action` set is single-risk-level (never a read and a write behind one discriminator).
|
|
30
30
|
|
|
31
|
-
- **Reads** — `exec` (primary; shell-style `cat`/`ls`/`grep`/`find` with frontmatter + backlink + history enrichment), `search` (ranked, BM25 + recency), `get_history` (versions for a doc), `links` (`kind: 'backlinks'|'forward'|'dead'|'orphans'|'hubs'|'suggest'`), `get_config` (resolved config), `get_components` (canonical component schemas).
|
|
31
|
+
- **Reads** — `exec` (primary; shell-style `cat`/`ls`/`grep`/`find` with frontmatter + backlink + history enrichment), `search` (ranked, BM25 + recency), `get_history` (versions for a doc), `links` (`kind: 'backlinks'|'forward'|'dead'|'orphans'|'hubs'|'suggest'`), `get_config` (resolved config), `get_components` (canonical component schemas), `get_preview_url` (browser-reachable preview URL on demand).
|
|
32
32
|
- **Writes** — `write_document` (new or full-replace; supports `template:` instantiation), `edit_document` (body-only find/replace), `edit_frontmatter` (1-2 keys via RFC 7396 JSON Merge Patch — preferred), `delete_document`, `rename` (probes file vs folder; rewrites referrers), `version` (`action: 'save'|'rollback'`), `folder_config` (`action: 'set-rule'|'write-template'|'delete-template'`).
|
|
33
33
|
- **Workflow** — `ingest`, `research`, `consolidate`, `discover` (return procedural guides, not data).
|
|
34
34
|
|
|
@@ -61,34 +61,36 @@ Why: native tools skip frontmatter, backlinks, shadow-repo activity, and project
|
|
|
61
61
|
|
|
62
62
|
## Preview — open the browser at session start
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
The user watches your edits land in a live browser preview. Open it once at session start, then keep working. Re-navigate only when the user asks to open a different doc, not to re-check your own edits.
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
**`previewUrl` is a route, not a URL to open.** Every read response (per-doc, on `exec` / `search` / `links` rows) and every write response carries a `previewUrl` — a route fragment like `/#/specs/foo/SPEC`, with **no scheme, host, or port**. It identifies *which doc* to preview, not a URL to hand a browser by itself. Never construct or guess preview URLs.
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
- **Claude Code Desktop**: call `preview_start("open-knowledge-ui")` (host tool, not OK MCP) — and nothing else. Do NOT read, diagnose, or edit `.claude/launch.json`; that file is host-managed config, and the OK ui lock-collision proxy handles the UI-already-running case automatically. If `preview_start` fails, surface the `previewUrl` from any recent OK tool response and report the issue to the user — do not try to "fix" `launch.json`.
|
|
70
|
-
- **Stdio-only hosts**: surface the URL in chat; `open <url>` (macOS) if the host can shell out.
|
|
68
|
+
**Pick how to open the preview by tool capability — not by host name.** Look at the tools actually available to you this session:
|
|
71
69
|
|
|
72
|
-
**
|
|
70
|
+
- **You have a `preview_*` tool** (e.g. `preview_start`) → call `preview_start("open-knowledge-ui")` and nothing else. The pane supplies its own origin; you never need a URL. Do NOT also call `get_preview_url`. Do NOT read, diagnose, or edit `.claude/launch.json` — that file is host-managed, and the OK lock-collision proxy handles the UI-already-running case automatically. If `preview_start` fails, report it to the user; do not try to "fix" `launch.json`.
|
|
71
|
+
- **No `preview_*` tool, but you have an in-app / built-in browser tool** → call `get_preview_url` once to get the full browser URL (`{ url, baseUrl, running }`), then navigate your **in-app browser** to `url`. Pass a `docName` to `get_preview_url` to jump straight to a doc, or omit it for the UI root.
|
|
72
|
+
- **No browser tool at all** (a stdio host such as the Codex CLI, which has no embedded browser) → call `get_preview_url`, then `open <url>` in the system browser as a last resort, and say so plainly to the user ("opening the preview in your system browser — this host has no in-app browser"). The system browser is the fallback, never the default.
|
|
73
|
+
|
|
74
|
+
**Opening or reading a file IS a preview navigation.** On any "open `<file>`" / "read `<file>`" request, navigate the browser to that doc's `previewUrl` route from the tool response — not a separate fetch, not a fresh system-browser launch.
|
|
75
|
+
|
|
76
|
+
**Four signals to check if the preview is already attached** (read these from each write response):
|
|
73
77
|
|
|
74
78
|
1. You opened/navigated earlier this session → don't reopen.
|
|
75
|
-
2. Write response has `previewUrl` (non-null) and NO `warning` → a browser is attached somewhere; do nothing.
|
|
76
|
-
3. `warning: { action: "attach-preview-once", previewUrl, message }` → UI reachable, no browser attached; navigate one-shot.
|
|
79
|
+
2. Write response has `previewUrl` (non-null route) and NO `warning` → a browser is attached somewhere; do nothing.
|
|
80
|
+
3. `warning: { action: "attach-preview-once", previewUrl, message }` → UI reachable, no browser attached; navigate one-shot (`preview_start`, or `get_preview_url` → in-app browser).
|
|
77
81
|
4. `warning: { action: "start-ui", previewUrl: null, message }` → no UI running anywhere. Surface the message verbatim — recovery options are in the in-band copy. Don't loop on retries.
|
|
78
82
|
|
|
79
83
|
Warnings fire at most once per session in the fresh-start case.
|
|
80
84
|
|
|
81
|
-
**`previewUrl: null` only means "no UI reachable" on the three attach-warning tools: `write_document` / `edit_document` / `edit_frontmatter`.** Workflow tools return prose and don't carry `previewUrl`. `delete_document` / `rename` emit `previousPreviewUrl` (different field, for closing stale tabs) and don't fire attach warnings.
|
|
82
|
-
|
|
83
|
-
**Always read `previewUrl` from the latest write response.** Don't cache the session-start value — Electron quit/reopen (or `ok ui` restart) can change the port; the resolver picks up the new port automatically.
|
|
85
|
+
**`previewUrl: null` only means "no UI reachable" on the three attach-warning tools: `write_document` / `edit_document` / `edit_frontmatter`.** Workflow tools return prose and don't carry `previewUrl`. `delete_document` / `rename` emit `previousPreviewUrl` (different field, for closing stale tabs) and don't fire attach warnings. `get_preview_url` reports `running: false` + `url: null` when no UI is running.
|
|
84
86
|
|
|
85
|
-
If you see `"Hocuspocus server is not running"`, run `ok start` and retry.
|
|
87
|
+
If you see `"Hocuspocus server is not running"`, run `ok start` and retry.
|
|
86
88
|
|
|
87
|
-
OK Electron and `ok ui` share `ui.lock
|
|
89
|
+
OK Electron and `ok ui` share `ui.lock`; when a second UI binds a different port, the OK lock-collision proxy bridges it to the live server transparently. That is exactly why `previewUrl` is route-only — the port behind the proxy is not the agent's to use. **Do not nudge the user to quit OK Electron to free a port** — the proxy handles it, and quitting tears down a UI in active use.
|
|
88
90
|
|
|
89
|
-
**The preview is read-only for the agent
|
|
91
|
+
**The preview is read-only for the agent — it is the user's view, not a surface you read back.** You cannot click or type to drive edits — the CRDT flow is one-way (agent → MCP → CRDT → preview).
|
|
90
92
|
|
|
91
|
-
**No screenshots
|
|
93
|
+
**No screenshots to confirm edits, no generic verification loop.** Do NOT take `preview_screenshot` (host tool, not OK MCP) after a write, and do not run a generic snapshot/eval/screenshot verification loop — OK's preview is a read-only, one-way mirror, so the CRDT tool response *is* the confirmation that an edit landed. Screenshot only when debugging a visual rendering issue or when the user explicitly asks to see the preview — never to confirm an edit landed.
|
|
92
94
|
|
|
93
95
|
## Writing
|
|
94
96
|
|
|
@@ -324,7 +326,7 @@ The skill carries the trigger ("KB content changed this turn — go look"). The
|
|
|
324
326
|
| Read an individual doc | `Read: specs/foo/SPEC.md` | `exec("cat specs/foo/SPEC.md")` |
|
|
325
327
|
| Explore a markdown-heavy dir | `Agent(Explore): "..."` | Do `exec`-based exploration yourself |
|
|
326
328
|
| Wait for the server to tell you to open preview | Skip the session-start preview open and wait for the `attach-preview-once` hint | Open the preview browser at session start; the hint is a fallback when you didn't |
|
|
327
|
-
| Ignore the attach hint | Skip the `warning: { action: "attach-preview-once" }` hint in write-tool responses | Open the
|
|
329
|
+
| Ignore the attach hint | Skip the `warning: { action: "attach-preview-once" }` hint in write-tool responses | Open the preview when the hint fires (`preview_start`, or `get_preview_url`); otherwise do nothing |
|
|
328
330
|
| Make the Claude Code Desktop preview work | Read / diagnose / edit `.claude/launch.json` (host-managed config) | Call `preview_start("open-knowledge-ui")` and nothing else; the OK lock-collision proxy bridges any port mismatch transparently |
|
|
329
331
|
| Reference another doc | `` `[text](./page.md)` `` (backticked) or HTML `<a>` | `[text](./page.md)` (raw markdown) |
|
|
330
332
|
| Embed an image | `<img src="...">` (HTML) or hot-linked external URL | Fetch + save locally + `` |
|
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,E as s,Ei as c,En as l,Gr as u,Hr as d,Jr as f,Kr as p,Oi as m,Rn as h,Si as g,Ti as _,U as v,Ur as ee,Vr as te,Wn as y,Wr as b,Wt as ne,Yr as re,Z as ie,_i as ae,bi as oe,fi as se,fn as ce,it as le,ji as ue,ki as de,m as fe,nt as pe,qn as me,sr as he,tn as ge,wi as _e,xi as x,yi as ve,z as ye}from"./dist-
|
|
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,E as s,Ei as c,En as l,Gr as u,Hr as d,Jr as f,Kr as p,Oi as m,Rn as h,Si as g,Ti as _,U as v,Ur as ee,Vr as te,Wn as y,Wr as b,Wt as ne,Yr as re,Z as ie,_i as ae,bi as oe,fi as se,fn as ce,it as le,ji as ue,ki as de,m as fe,nt as pe,qn as me,sr as he,tn as ge,wi as _e,xi as x,yi as ve,z as ye}from"./dist-DviTRTbb.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,j as Ae,k as je,o as Me,p as Ne,w as Pe,x as Fe}from"./init-xf7nob8y.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-D5d7eVsY.mjs";import{i as He}from"./src-DywZNuWB.mjs";import{n as Ue,t as We}from"./loader-BvXfD2lW.mjs";import{d as Ge,f as Ke,l as qe,m as Je,p as Ye,s as Xe}from"./start-qB7qGHyG.mjs";import{c as Ze,i as Qe,n as w,o as T,r as E,s as D,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,lstatSync as ct,mkdirSync as lt,mkdtempSync as ut,openSync as dt,readFileSync as N,readdirSync as ft,realpathSync as pt,rmSync as mt,statSync as ht,unlinkSync as gt,writeFileSync as _t}from"node:fs";import vt from"node:process";import{homedir as yt,hostname as bt,tmpdir as xt}from"node:os";import{fileURLToPath as St}from"node:url";import{AsyncLocalStorage as Ct,AsyncResource as wt}from"node:async_hooks";import{stripVTControlCharacters as Tt,styleText as P}from"node:util";import*as Et from"node:readline";import{randomUUID as Dt}from"node:crypto";import{realpath as Ot}from"node:fs/promises";import{setTimeout as kt}from"node:timers/promises";import{createInterface as At}from"node:readline/promises";var jt=ue();const Mt=`open-knowledge`;var Nt=class{backend=`keyring`;async get(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{let n=new t(Mt,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(Mt,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(Mt,e).deletePassword()}catch{}}},Pt=class{backend=`file`;authFile;constructor(e){this.authFile=e??A(yt(),`.ok`,`auth.yml`)}read(){if(!M(this.authFile))return{};try{return(0,jt.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)||lt(t,{recursive:!0,mode:448}),_t(this.authFile,(0,jt.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 Ft(e){try{let{Entry:e}=await import(`@napi-rs/keyring`);return new e(Mt,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
3
3
|
`),new Nt}catch{return process.stderr.write(`[auth] token storage: file (~/.ok/auth.yml)
|
|
4
4
|
`),new Pt(e)}}async function It(e,t){let n=[],r=new Pt(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(Mt,`__probe__`);let r=new Nt;await r.get(e)!=null&&(await r.clear(e),n.push(`keychain`))}catch{}return{touched:n}}async function Lt(e,t,n){let r=Rt(await zt(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 Rt(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 zt(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 Bt(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 Lt(process.stdin,process.stdout,t);process.exit(n)}),n}function Vt(e){let t=e.endpoint.DEFAULTS;return/^https:\/\/(api\.)?github\.com$/.test(t.baseUrl)?`https://github.com`:t.baseUrl.replace(`/api/v3`,``)}async function Ht(e,t,n){let r={baseUrl:Vt(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 Ut(e){let t=e.request||S,n={client_id:e.clientId};return`scopes`in e&&Array.isArray(e.scopes)&&(n.scope=e.scopes.join(` `)),Ht(t,`POST /login/device/code`,n)}async function Wt(e){let t=await Ht(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=Gt(e,t.data.expires_in),n.refreshTokenExpiresAt=Gt(e,t.data.refresh_token_expires_in)}delete n.scopes}return{...t,authentication:n}}function Gt(e,t){return new Date(e+t*1e3).toISOString()}async function Kt(e,t){let n=qt(e,t.auth);if(n)return n;let{data:r}=await Ut({clientType:e.clientType,clientId:e.clientId,request:t.request||e.request,scopes:t.auth.scopes||e.scopes});await e.onVerification(r);let i=await Yt(t.request||e.request,e.clientId,e.clientType,r);return e.authentication=i,i}function qt(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 Jt(e){await new Promise(t=>setTimeout(t,e*1e3))}async function Yt(e,t,n,r){try{let i={clientId:t,request:e,code:r.device_code},{authentication:a}=n===`oauth-app`?await Wt({...i,clientType:`oauth-app`}):await Wt({...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 Jt(r.interval),Yt(e,t,n,r);if(a===`slow_down`)return await Jt(r.interval+7),Yt(e,t,n,r);throw i}}async function Xt(e,t){return Kt(e,{auth:t})}async function Zt(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 Kt(e,{request:t,auth:{type:`oauth`}});return i.headers.authorization=`token ${a}`,t(i)}var Qt=`0.0.0-development`;function $t(e){let t=e.request||S.defaults({headers:{"user-agent":`octokit-auth-oauth-device.js/${Qt} ${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(Xt.bind(null,i),{hook:Zt.bind(null,i)})}async function en(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=$t({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 tn={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 nn;(function(e){})(nn||={});function rn(e){return de(ve,e)}function an(){return process.env.OPEN_KNOWLEDGE_GITHUB_CLIENT_ID??`Ov23liqlSd0V1MwR6rhI`}const on=new Set([`gitlab.com`,`bitbucket.org`,`codeberg.org`,`gitea.com`,`sr.ht`,`sourcehut.org`]);function F(e){let t=e.toLowerCase().replace(/:\d+$/,``);on.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 sn(e,t){e&&process.stdout.write(`${JSON.stringify(t)}\n`)}async function cn(e,t,n=en){let r=an(),{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?sn(!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?sn(!0,{type:`complete`,host:i,login:s}):process.stderr.write(`✓ Logged in as ${s} on ${i}\n`)}function ln(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 cn(t,await e())})}const un=e=>e.name===`enter`||e.name===`return`;var dn=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},fn=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},pn=class extends Error{name=`ExitPromptError`},mn=class extends Error{name=`HookError`},hn=class extends Error{name=`ValidationError`};const gn=new Ct;function _n(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function vn(e,t){let n=_n(e);return gn.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function I(){let e=gn.getStore();if(!e)throw new mn(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function yn(){return I().rl}function bn(e){return wt.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 xn(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 Sn(){I().handleChange()}const L={queue(e){let t=I(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(yn());if(r!=null&&typeof r!=`function`)throw new hn(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=I();bn(()=>{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 Cn(e){return typeof e==`function`}function R(e){return xn(t=>{let n=wt.bind(function(e){t.get()!==e&&(t.set(e),Sn())});if(t.initialized)return[t.get(),n];let r=Cn(e)?e():e;return t.set(r),[r,n]})}function wn(e,t){xn(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&L.queue(e),n.set(t)})}const Tn={prefix:{idle:P(`blue`,`?`),done:P(`green`,Ae.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 En(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 Dn(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=En(n)&&En(r)?Dn(n,r):r}return t}function On(...e){return Dn(Tn,...e.filter(e=>e!=null))}function kn({status:e=`idle`,theme:t}){let[n,r]=R(!1),[i,a]=R(0),{prefix:o,spinner:s}=On(t);return wn(()=>{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 An(e){return R({current:e})[0]}function jn(e){let t=An(e);t.current=e,wn(e=>{let n=!1,r=bn((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var Mn=e(Se(),1);function Nn(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 Kr(){return new t(`signout`).description(`Remove stored credentials`).option(`--host <host>`,`GitHub hostname`,`github.com`).action(async e=>{await Gr(e)})}async function qr(e,t,n=Vr){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 Jr(e,t){let{host:n,json:r}=e;F(n);let i=await qr(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 Yr(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 Jr(t,await e())})}function Xr(){let e=new t(`auth`);e.description(`GitHub authentication management`);let n=()=>Ft();return e.addCommand(ln(n)),e.addCommand(Yr(n)),e.addCommand(Wr(n)),e.addCommand(Kr()),e.addCommand(zr(n)),e.addCommand(Bt(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??bt();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function Zr(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 Qr(e){let t=e.inspect??(t=>V(e.lockDir,t)),n=e.unlink??(e=>gt(e)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=Zr(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 $r(e){return new t(`clean`).description(`Prune stale / corrupt open-knowledge lock files (never touches live locks)`).action(()=>{e(),Qr({lockDir:me(process.cwd())}).failed.length>0&&(process.exitCode=1)})}async function ei(e,t,n={},r=Vr){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 ti(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 ni=[[`count`,0,10],[`compress`,10,20],[`receiv`,20,60],[`resolv`,60,100]];function ri(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 ni)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 ii(e,t,n){return e===`https`&&t===`github.com`&&n}async function ai(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)&&ft(a).length>0)throw Error(`Target directory is not empty: ${a}`);let o=await Ft(),s=i.protocol===`https`&&i.hostname===`github.com`?await ti(i.owner,i.name):!1,c=ii(i.protocol,i.hostname,s)?{tier:`none`,credentialArgs:[]}:await ei(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=ri(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-
|
|
22
|
+
`);try{let{runInit:e}=await import(`./init-BSRUkYPY.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{oi(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 oi(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`:(_t(t,`${n}${n.length===0||n.endsWith(`
|
|
24
24
|
`)?``:`
|
|
25
|
-
`}.ok/\n`,`utf-8`),`appended`)}function si(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 ai(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-
|
|
25
|
+
`}.ok/\n`,`utf-8`),`appended`)}function si(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 ai(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-CE8LQ1MY.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 ci=[[`sync`],[`persistence`,`debounceMs`],[`persistence`,`maxDebounceMs`],[`server`,`port`],[`content`,`include`],[`content`,`exclude`]];function li(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 ui(e){let t=(0,jt.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 ci)t.hasIn(e)&&n.push(e.join(`.`));return n}function di(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fi(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=di(i)?i:{};e[r]=a,e=a}e[n[n.length-1]]=null}return t}async function pi(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??re,s=[];(r===`project`||r===`both`)&&s.push({scope:`project`,absPath:f(`project`,a,e.homedirOverride)}),(r===`user`||r===`both`)&&s.push({scope:`user`,absPath:f(`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=ui(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:fi(ci.filter(e=>r.includes(e.join(`.`)))),homedirOverride:e.homedirOverride});if(!s.ok){c.push({path:n,scope:t,found:r,removed:[],error:se(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 mi(){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(()=>{li({}).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 pi({scope:t,dryRun:e.dryRun})).ok||(process.exitCode=1)}),e}var U=e(Ze(),1);const W=2e3,hi=2e3,gi=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/Open Knowledge(?:\.app| Helper)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/,/(^|\s)--ok-project-path=/];function _i(e){return gi.some(t=>t.test(e))}function vi(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 yi(e){let t=e.indexOf(`--ok-project-path=`);if(t===-1)return null;let n=t+18,r=e.slice(n),i=r.search(/\s--/),a=(i===-1?r:r.slice(0,i)).trim();return a&&at(a)?a:null}function bi(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)&&_i(a)&&t.push({pid:o,command:a})}return t}function xi(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)&&_i(o)&&t.push({pid:s,command:o})}return t}async function Si(){let e=k(`pgrep`,[`-a`,`-f`,`cli\\.mjs|open-knowledge|Open Knowledge(\\.app| Helper)|--ok-lock-dir-b64=|--ok-project-path=|(^|[ /])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=bi(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?[]:xi(t.stdout)}function Ci(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 wi(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 Ti(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 Ei(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 Di(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 xo=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=yo({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 So={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}},Co=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=aa(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??So}async _authThenStart(){if(!this._authProvider)throw new J(`No auth provider`);let e;try{e=await Ya(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=ia(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 xo({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=d.parse(JSON.parse(e.data));p(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 Ya(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:u(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}=$a(o);if(this._resourceMetadataUrl=t,this._scope=n,await Ya(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}=$a(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 Ya(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(),b(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=>d.parse(e)):[d.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 wo(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 To(e){if(e===void 0||e===``)return;let t=Number.parseInt(e,10);if(!(Number.isNaN(t)||t<=0))return t}function Eo(e){return e===`0.0.0.0`||e===`::`?`localhost`:e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function Do(e,t){return`http://${Eo(e)}:${t}/mcp`}function Oo(e,t){return`ws://${Eo(e)}:${t}`}function ko(e){let t=new URL(e);return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.pathname=``,t.search=``,t.hash=``,t.toString().replace(/\/$/,``)}function Ao(e,t){if(!(!e||e.port<=0)&&t(e.pid))return e.port}function jo(e){return M(e)?N(e,`utf-8`).trim():``}function Mo(e,t){return`server did not start within ${e}ms${t?` stderr:\n${t}`:``}`}function No(e){if(e&&typeof e==`object`&&`method`in e&&`id`in e)return e.id}function Po(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 Fo(e,t){return{jsonrpc:`2.0`,id:e,error:{code:-32e3,message:t instanceof Error?t.message:String(t)}}}async function Io(e){let t=e.readLock??(()=>Le(e.lockDir)),n=e.isAlive??C,r=e.sleep??(e=>kt(e)),i=e.spawn??tt,a=e.readErrorLog??jo,o=e.openErrorLog??(e=>dt(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 Do(`localhost`,t)}let u=Ao(t(),n);if(u!==void 0)return Do(`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)||lt(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 g=Date.now()+c;for(;Date.now()<g;){if(m){let e=a(d),t=e?` stderr:\n${e}`:``;throw Error(`spawn failed: ${m}${t}`)}await r(l);let e=Ao(t(),n);if(e!==void 0)return Do(`localhost`,e)}if(m){let e=a(d),t=e?` stderr:\n${e}`:``;throw Error(`spawn failed: ${m}${t}`)}throw Error(Mo(c,a(d)))}function Lo(e,t){if(e.portOverride!==void 0)return ko(t);let n=e.readLock??(()=>Le(e.lockDir)),r=e.isAlive??C,i=Ao(n(),r);if(i!==void 0)return Oo(`localhost`,i)}async function Ro(e,t={}){let n=t.stderr??process.stderr,r=t.requestTimeoutMs??12e4,i=t.createStdioTransport?t.createStdioTransport(t.stdin,t.stdout):new Qi(t.stdin,t.stdout),a=t.createHttpTransport?t.createHttpTransport(new URL(e)):new Co(new URL(e),{fetch:wo(r),...t.connectionId===void 0?{}:{requestInit:{headers:{[s]:t.connectionId}}}}),o=!1,c=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=()=>{c()},a.onclose=()=>{c()};let l=Promise.resolve();i.onmessage=e=>{l=l.then(async()=>{try{await a.send(e)}catch(t){let r=No(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(Fo(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=Po(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 c(),e}return{close:c}}async function zo(e){let t=e.stderr??process.stderr,n=e.bridgeFn??Ro,r=await Io(e),i=e.createConnectionId?.()??Dt(),a=!1,o=(e.startKeepalive??na)({connectionId:i,resolveWsUrl:async()=>Lo(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 Bo=St(import.meta.url);function Vo(e){let t=j(e);for(;;){if(ce(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 \`${ae}\`).`);t=n}}function Ho(e){try{let t=new URL(e);return t.protocol===`file:`?St(t):void 0}catch{return}}async function Uo(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=Ho(n[0].uri);return r===void 0&&e.log?.(`single root URI not usable as fs path: ${n[0].uri}`),r}async function Wo(e,t){if(e!==void 0)return Vo(e);let n=await t();if(n!==void 0)return Vo(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 Go(e){let t=process.stderr,n=e.spawnTimeoutMs??To(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 te({name:a,version:ze},{instructions:le({dir:`.`})});ge(o);let s=Dt(),c={current:{connectionId:s,displayName:s,colorSeed:s}},l=new Map,u=e=>{if(l.has(e))return;let n=ne(e),r=c.current,i=na({connectionId:s,displayName:r.displayName,clientName:r.clientInfo?.name??r.displayName,colorSeed:r.colorSeed,resolveWsUrl:async()=>Lo({lockDir:n,contentDir:e},``),log:n=>t.write(`[mcp] keepalive[${e}]: ${n}\n`)});l.set(e,i)},d=()=>Uo({getClientCapabilities:()=>o.server.getClientCapabilities(),listRoots:()=>o.server.listRoots(),log:e=>t.write(`[mcp] ${e}\n`)}),f=e=>Wo(e,d),p=async e=>{let t;if(e===void 0){let e=await d();if(e===void 0)return;t=Vo(e)}else t=Vo(e);let a=await i(t),o=await Io({lockDir:ne(t),contentDir:y(a,t),envAutoStart:r,...n===void 0?{}:{timeoutMs:n}});return u(t),o.replace(/\/mcp$/,``)};o.server.oninitialized=()=>{let e=o.server.getClientVersion(),t=he(e?.name,s);c.current={connectionId:s,clientInfo:e?{name:t,version:e.version}:void 0,displayName:t,colorSeed:t}},h(o,{serverUrl:p,resolveCwd:f,config:i,identityRef:c});let m=new Qi,g=!1,_,v=async()=>{if(g)return;g=!0,_?.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(),m.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(m),t.write(`[mcp] global stdio server ready (per-call project routing)
|
|
61
61
|
`);let ee=!1,b=()=>{ee||(ee=!0,setTimeout(()=>{t.write(`[mcp] shutdown deadline (5s) reached — forcing exit(1)
|
|
62
|
-
`),process.exit(1)},5e3).unref(),v().finally(()=>{process.exit(0)}))};if(process.once(`SIGINT`,b),process.once(`SIGTERM`,b),ra({log:e=>t.write(`${e}\n`),transport:m,process,stdin:process.stdin}),process.platform===`darwin`){let e=ta(Bo,{realpathSync:pt,statInoSync:e=>ht(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;_=ea({detect:()=>$i({bundleAnchorPath:Bo,currentInode:r,platform:process.platform,realpath:pt,statInode:e=>ht(e).ino}),onReplaced:e=>{t.write(`[mcp] bundle replaced anchor=${n} bootInode=${e.currentInode} onDiskInode=${e.onDiskInode} version=${ze} — exiting for host respawn\n`),b()},log:e=>t.write(`[mcp] ${e}\n`)})}}return{close:v}}function Ko(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=To(process.env.OK_MCP_SPAWN_TIMEOUT_MS);await zo({lockDir:``,contentDir:``,portOverride:t.port,envAutoStart:process.env.OK_MCP_AUTOSTART,timeoutMs:e});return}await Go({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 qo(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-
|
|
62
|
+
`),process.exit(1)},5e3).unref(),v().finally(()=>{process.exit(0)}))};if(process.once(`SIGINT`,b),process.once(`SIGTERM`,b),ra({log:e=>t.write(`${e}\n`),transport:m,process,stdin:process.stdin}),process.platform===`darwin`){let e=ta(Bo,{realpathSync:pt,statInoSync:e=>ht(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;_=ea({detect:()=>$i({bundleAnchorPath:Bo,currentInode:r,platform:process.platform,realpath:pt,statInode:e=>ht(e).ino}),onReplaced:e=>{t.write(`[mcp] bundle replaced anchor=${n} bootInode=${e.currentInode} onDiskInode=${e.onDiskInode} version=${ze} — exiting for host respawn\n`),b()},log:e=>t.write(`[mcp] ${e}\n`)})}}return{close:v}}function Ko(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=To(process.env.OK_MCP_SPAWN_TIMEOUT_MS);await zo({lockDir:``,contentDir:``,portOverride:t.port,envAutoStart:process.env.OK_MCP_AUTOSTART,timeoutMs:e});return}await Go({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 qo(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-SplPcGG3.mjs`),r=e(),i=process.cwd(),a=y(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 Jo(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Yo(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 Xo(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:Ci(r),command:r,isDesktop:Jo(r)}}function Zo(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Qo(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&Zo(e)?`ui-orphan`:`stale`}const $o=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function es(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 ts(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ns(e){return`${ts(e.server.usage)} | ${ts(e.ui?.usage??null)}`}function rs(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function is(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=Qo(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,rs(e),ns(e),t,String(n),Yo(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=es(Qo(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 as(e={}){let t=e.discover??ji,n=e.inspect??V,r=e.log??(e=>console.log(e)),i=e.resolveCommand??wi,a=e.resolveUsage??Ti,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=Xo(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:Qo(e)}));r(JSON.stringify(e,null,2));return}r(is(e.all?s:s.filter(e=>$o.has(Qo(e)))))}function os(){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 as({all:t.all===!0||e===`all`,json:t.json===!0})})}function X(e,t){e&&process.stdout.write(`${JSON.stringify(t)}\n`)}async function ss(e,t,n=process.cwd()){let r=e.op??`sync`,i=Le(me(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 cs(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 ss({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 ls(e){return new t(`pull`).description(`Pull changes from the remote`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{try{await ss({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 us(e){return new t(`push`).description(`Push commits to the remote`).option(`--json`,`Output JSONL progress events`,!1).action(async t=>{try{await ss({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 ds(e){return typeof e==`string`&&r.includes(e)}async function fs(e={}){let t=j(e.cwd??process.cwd()),n=e.pack??`knowledge-base`;if(!ye[n])return{status:`failed`,message:`${E(`Error:`)} Unknown pack "${n}". Available: ${r.join(`, `)}`,exitCode:1};let i;try{i=await l({projectDir:t,rootDir:e.root,packId:n})}catch(e){return e instanceof v?{status:`prerequisite-missing`,message:`${E(`Error:`)} ${e.message}`,exitCode:1}:{status:`failed`,message:`${E(`Error:`)} ${e instanceof Error?e.message:String(e)}`,exitCode:1}}if(i.created.length===0){let e=ye[n].name;return{status:`no-op`,message:`${T(`Your ${e} pack is already seeded.`)}\n${w(`Nothing to do.`)}`,plan:i,exitCode:0}}if(e.dryRun)return{status:`dry-run`,message:`${O(`Plan (dry-run — no changes made):`)}\n\n${ms(i,t)}`,plan:i,exitCode:0};if(!e.yes&&!await hs(`${O(`Plan:`)}\n\n${ms(i,t)}\n\n${O(`Apply?`)} ${w(`[Y/n] `)}`,e.confirmStream))return{status:`cancelled`,message:w(`Cancelled.`),plan:i,exitCode:0};let a=await ie(i,{projectDir:t,packId:n});if(a.errors.length>0){let e=a.errors.map(e=>` ${E(`✗`)} ${e.path}: ${e.error}`);return{status:`failed`,message:[`${D(`Applied`)} ${a.applied} entries, ${D(String(a.errors.length))} error(s):`,...e].join(`
|
|
65
65
|
`),plan:i,exitCode:1}}let o=ye[n].name;return{status:`applied`,message:`${T(`✓ Seeded ${o}`)} ${w(`(${a.applied} entries, ${a.durationMs}ms)`)}`,plan:i,exitCode:0}}function ps(){let e=[O(`Available packs:`)];for(let t of r){let n=ye[t];e.push(` ${T(t)} ${w(`—`)} ${n.name}: ${n.description}`)}return e.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,$n as t,$t as n,A as r,An as i,Ar as a,At as o,B as s,Bn as c,Br as l,Bt as u,C as d,Cn as f,Cr as p,Ct as m,D as h,Dn as g,Dr as _,Dt as v,E as y,En as b,Er as x,Et as S,F as C,Fn as w,Fr as T,Ft as E,G as D,Gn as O,Gt as k,H as A,Hn as j,Ht as M,I as N,In as P,Ir as F,It as I,J as L,Jn as R,Jt as z,K as B,Kn as V,Kt as H,L as U,Ln as W,Lr as G,Lt as K,M as q,Mn as J,Mr as Y,Mt as X,N as Z,Nn as Q,Nr as $,Nt as ee,O as te,On as ne,Or as re,Ot as ie,P as ae,Pn as oe,Pr as se,Pt as ce,Q as le,Qn as ue,Qt as de,R as fe,Rn as pe,Rr as me,Rt as he,S as ge,Sn as _e,Sr as ve,St as ye,T as be,Tn as xe,Tr as Se,Tt as Ce,U as we,Un as Te,Ut as Ee,V as De,Vn as Oe,Vt as ke,W as Ae,Wn as je,Wt as Me,X as Ne,Xn as Pe,Xr as Fe,Xt as Ie,Y as Le,Yn as Re,Yt as ze,Z as Be,Zn as Ve,Zr as He,Zt as Ue,_ as We,_n as Ge,_r as Ke,_t as qe,a as Je,an as Ye,ar as Xe,at as Ze,b as Qe,bn as $e,br as et,bt as tt,c as nt,ci as rt,cn as it,cr as at,ct as ot,d as st,dn as ct,dr as lt,dt as ut,ei as dt,en as ft,er as pt,et as mt,f as ht,fn as gt,fr as _t,ft as vt,g as yt,gn as bt,gr as xt,gt as St,h as Ct,hn as wt,hr as Tt,ht as Et,i as Dt,in as Ot,ir as kt,it as At,j as jt,jn as Mt,jr as Nt,jt as Pt,k as Ft,kn as It,kr as Lt,kt as Rt,l as zt,li as Bt,ln as Vt,lr as Ht,lt as Ut,m as Wt,mi as Gt,mn as Kt,mr as qt,mt as Jt,n as Yt,nn as Xt,nr as Zt,nt as Qt,o as $t,oi as en,on as tn,or as nn,ot as rn,p as an,pi as on,pn as sn,pr as cn,pt as ln,q as un,qn as dn,qt as fn,r as pn,rn as mn,rr as hn,rt as gn,s as _n,sn as vn,sr as yn,st as bn,t as xn,tn as Sn,tr as Cn,tt as wn,u as Tn,ui as En,un as Dn,ur as On,ut as kn,v as An,vn as jn,vr as Mn,vt as Nn,w as Pn,wn as Fn,wr as In,wt as Ln,x as Rn,xn as zn,xr as Bn,xt as Vn,y as Hn,yn as Un,yr as Wn,yt as Gn,z as Kn,zn as qn,zr as Jn,zt as Yn}from"./dist-
|
|
1
|
+
import{$ as e,$n as t,$t as n,A as r,An as i,Ar as a,At as o,B as s,Bn as c,Br as l,Bt as u,C as d,Cn as f,Cr as p,Ct as m,D as h,Dn as g,Dr as _,Dt as v,E as y,En as b,Er as x,Et as S,F as C,Fn as w,Fr as T,Ft as E,G as D,Gn as O,Gt as k,H as A,Hn as j,Ht as M,I as N,In as P,Ir as F,It as I,J as L,Jn as R,Jt as z,K as B,Kn as V,Kt as H,L as U,Ln as W,Lr as G,Lt as K,M as q,Mn as J,Mr as Y,Mt as X,N as Z,Nn as Q,Nr as $,Nt as ee,O as te,On as ne,Or as re,Ot as ie,P as ae,Pn as oe,Pr as se,Pt as ce,Q as le,Qn as ue,Qt as de,R as fe,Rn as pe,Rr as me,Rt as he,S as ge,Sn as _e,Sr as ve,St as ye,T as be,Tn as xe,Tr as Se,Tt as Ce,U as we,Un as Te,Ut as Ee,V as De,Vn as Oe,Vt as ke,W as Ae,Wn as je,Wt as Me,X as Ne,Xn as Pe,Xr as Fe,Xt as Ie,Y as Le,Yn as Re,Yt as ze,Z as Be,Zn as Ve,Zr as He,Zt as Ue,_ as We,_n as Ge,_r as Ke,_t as qe,a as Je,an as Ye,ar as Xe,at as Ze,b as Qe,bn as $e,br as et,bt as tt,c as nt,ci as rt,cn as it,cr as at,ct as ot,d as st,dn as ct,dr as lt,dt as ut,ei as dt,en as ft,er as pt,et as mt,f as ht,fn as gt,fr as _t,ft as vt,g as yt,gn as bt,gr as xt,gt as St,h as Ct,hn as wt,hr as Tt,ht as Et,i as Dt,in as Ot,ir as kt,it as At,j as jt,jn as Mt,jr as Nt,jt as Pt,k as Ft,kn as It,kr as Lt,kt as Rt,l as zt,li as Bt,ln as Vt,lr as Ht,lt as Ut,m as Wt,mi as Gt,mn as Kt,mr as qt,mt as Jt,n as Yt,nn as Xt,nr as Zt,nt as Qt,o as $t,oi as en,on as tn,or as nn,ot as rn,p as an,pi as on,pn as sn,pr as cn,pt as ln,q as un,qn as dn,qt as fn,r as pn,rn as mn,rr as hn,rt as gn,s as _n,sn as vn,sr as yn,st as bn,t as xn,tn as Sn,tr as Cn,tt as wn,u as Tn,ui as En,un as Dn,ur as On,ut as kn,v as An,vn as jn,vr as Mn,vt as Nn,w as Pn,wn as Fn,wr as In,wt as Ln,x as Rn,xn as zn,xr as Bn,xt as Vn,y as Hn,yn as Un,yr as Wn,yt as Gn,z as Kn,zn as qn,zr as Jn,zt as Yn}from"./dist-DviTRTbb.mjs";import{_ as Xn,a as Zn,c as Qn,d as $n,f as er,g as tr,i as nr,l as rr,m as ir,n as ar,o as or,p as sr,r as cr,s as lr,t as ur,u as dr}from"./server-lock-D7DXNVql-BRVVzA6T.mjs";export{xn as AGENT_ID_MAX_LEN,Yt as AGENT_ID_RE,pn as AGENT_WRITE_ORIGIN,Dt as AgentFocusBroadcaster,Je as AgentPresenceBroadcaster,$t as AgentSessionCapacityError,_n as AgentSessionManager,nt as BacklinkIndex,zt as CC1Broadcaster,dt as CC1_CONTRACT_VERSION,Tn as CONFLICT_MARKER_RE,st as CURSOR_BUNDLE_PATHS_BY_PLATFORM,ht as ConfigSchema,an as DEFAULT_CHECKPOINT_RETENTION,Wt as DEFAULT_PACK_ID,Ct as FILE_SYSTEM_WRITER,yt as FILE_WATCHER_ORIGIN,We as GIT_UPSTREAM_WRITER,Fe as GitDirAccessError,An as HOCUSPOCUS_AUTH_REJECTION_REASONS,Hn as HocuspocusAuthRejection,Qe as HocuspocusAuthTokenSchema,Rn as INSTALLED_AGENTS_SCHEMES,ge as LIVE_DERIVED_INDEX_DEBOUNCE_MS,d as LOG_MD_TEMPLATE,Pn as MANAGED_RENAME_ORIGIN,be as MAX_AGENT_SESSIONS,y as MCP_CONNECTION_ID_HEADER,h as MCP_SERVER_NAME,te as MISSING_OK_CONFIG_MESSAGE,He as MalformedGitPointerError,Ft as McpLogger,r as MissingOkConfigError,jt as OBSERVER_SYNC_ORIGIN,en as ORPHAN_MODES,q as PinoLogger,ur as ProcessLockCollisionError,Z as ProjectGitInitError,ae as ROLLBACK_ORIGIN,ar as RUNTIME_VERSION,C as SERVICE_WRITER,N as SKILL_INSTALL_EVENTS_FILE_REL,rt as SKILL_STATE_TARGETS,U as STARTER_FOLDERS,fe as STARTER_FOLDER_FRONTMATTER_FILENAME,Kn as STARTER_PACKS,s as STARTER_PACK_IDS,De as STARTER_TEMPLATES,A as STATE_MANIFEST_FILENAME,cr as STATE_SCHEMA_VERSION,Bt as SYSTEM_DOC_NAME,we as SeedPrerequisiteError,Ae as SeedRootDirError,nr as ServerLockCollisionError,D as StateManifestError,B as TagIndex,un as UiLockCollisionError,Zn as acquireProcessLock,or as acquireServerLock,L as acquireUiLock,Le as applyAgentMarkdownWrite,Ne as applyExternalChange,Be as applySeed,le as assertCompatibleStateManifest,e as assertNeverDiskEvent,mt as attachIdleShutdown,wn as bootServer,Qt as buildAndOpenSkill,gn as buildExecResult,At as buildInstructions,Ze as buildSkillZip,rn as buildStarterFolderFrontmatterYaml,bn as buildWipTree,ot as classifyEvents,Ut as classifyFsPath,kn as clearContributors,ut as coercePackId,En as colorFromSeed,vt as commitUpstreamImport,ln as commitWip,Jt as commitWipFromTree,Et as containsConflictMarkers,St as contentHash,qe as contributorCount,Nn as createApiExtension,Gn as createAssetServeMiddleware,tt as createContentFilter,Vn as createContentFilterAsync,ye as createExternalChangeHandler,m as createLiveDerivedIndexExtension,Ln as createMcpHttpHandler,Ce as createOsProbe,S as createPersistenceExtension,v as createServer,ie as createServerObserverExtension,Rt as createStreamingErrorWriter,o as createTestLogger,Pt as detectClaudeDesktopPresence,X as detectProjectShape,ee as ensureProjectGit,ce as errorResponse,E as evictStaleTrackerEntries,I as extractWikiLinksFromMarkdown,K as findEnclosingGitRoot,he as findEnclosingProjectRoot,Yn as formatAuthRejectionWire,u as formatContributors,ke as formatContributorsFrom,M as gcCheckpointRefs,Ee as getCurrentMcpLogger,Me as getLocalDir,k as getLogger,H as getMeter,fn as getMetrics,z as getTracer,ze as handleCollabSocketError,Ie as handleSpawnCursor,on as iconFromClientName,Ue as incrementCollabSocketFilteredError,de as incrementServerObserverFire,n as initShadowRepo,ft as initTelemetry,Sn as installPrettyZodErrors,Xt as installTestLoggers,mn as installUserSkill,Ot as isAllowedApiOrigin,Ye as isAllowedWorkspaceHostHeader,tn as isConfigDoc,vn as isHocuspocusAuthRejectionReason,it as isKnownPackId,Vt as isLoopbackAddress,Gt as isOrphanMode,Dn as isPairedWriteOrigin,ct as isPathWithinDir,lr as isProcessAlive,gt as isProjectRoot,sn as isSelfWrite,Kt as isSystemDoc,Qn as isValidLockPid,wt as lastKnownHash,bt as listRescueCheckpoints,Ge as listStarterPacks,jn as loadPrincipal,rr as lockFilePath,Un as loggerFactory,$e as mountMcpAndApi,zn as normalizeFsPath,_e as parseAuthRejectionWire,f as parseHocuspocusAuthToken,Fn as parseKeepaliveConnectionId,xe as pathToDocName,b as planSeed,g as readAllTargets,ne as readBranchFromHead,dr as readProcessLock,$n as readProcessLockDetailed,er as readServerLock,It as readServerPackageVersion,i as readSkillInstallStateSnapshot,Mt as readStateManifest,J as readTargetRecordedAt,Q as readTargetVersion,oe as readUiLock,w as reconcile,P as recordContributor,W as recordSkillInstallEvent,pe as registerAllTools,qn as registerWrite,sr as releaseProcessLock,ir as releaseServerLock,c as releaseUiLock,Oe as removeLastKnownHash,j as resetMetrics,Te as resolveBundledSkillDir,je as resolveContentDir,O as resolveCursorBinaryDefault,V as resolveCursorSpawnInvocation,dn as resolveLockDir,R as resolvePack,Re as resolvePackageVersion,Pe as restoreContributors,Ve as rewriteMarkdownLinksForDocumentRename,ue as rewriteWikiLinksForDocumentRename,t as runAuthReposSubprocess,pt as runAuthStatusSubprocess,Cn as runCloneSubprocess,Zt as runDeviceFlowSubprocess,hn as runWithMcpLogger,kt as safeContentPath,Xe as safeSubdir,nn as safetyCheckpoint,yn as sanitizeClientName,at as saveInMemoryCheckpoint,Ht as saveVersion,On as seedBasenameIndex,lt as setActiveSpanAttributes,_t as shadowGit,cn as shutdownTelemetry,qt as spawnDetached,Tt as splitMarkdownBlocks,xt as startWatcher,Ke as streamingProblemEvent,Mn as swapContributors,Wn as toBroadcasterKey,et as tracedAppendFileSync,Bn as tracedLinkSync,ve as tracedMkdir,p as tracedMkdirSync,In as tracedRename,Se as tracedRenameSync,x as tracedRmSync,_ as tracedRmdirSync,re as tracedUnlinkSync,Lt as tracedWriteFile,a as tracedWriteFileSync,Nt as updateLastKnownHash,tr as updateProcessLockPort,Xn as updateServerLockPort,Y as updateUiLockPort,$ as validateAgentId,se as validateCloneInputs,T as validateSkillZip,F as withSpan,G as withSpanSync,me as writeStateManifest,Jn as writeTargetVersion,l as writeTracker};
|