@noesis-brain/mcp-server 2.0.1 → 2.1.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 (45) hide show
  1. package/README.md +91 -3
  2. package/dist/agent/runner.d.ts +25 -0
  3. package/dist/agent/runner.d.ts.map +1 -0
  4. package/dist/agent/runner.js +218 -0
  5. package/dist/agent/runner.js.map +1 -0
  6. package/dist/api/NoesisClient.d.ts +119 -0
  7. package/dist/api/NoesisClient.d.ts.map +1 -1
  8. package/dist/api/NoesisClient.js +130 -6
  9. package/dist/api/NoesisClient.js.map +1 -1
  10. package/dist/cli/setup.d.ts.map +1 -1
  11. package/dist/cli/setup.js +409 -35
  12. package/dist/cli/setup.js.map +1 -1
  13. package/dist/index.js +31 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/resolve/noteRef.d.ts +101 -0
  16. package/dist/resolve/noteRef.d.ts.map +1 -0
  17. package/dist/resolve/noteRef.js +186 -0
  18. package/dist/resolve/noteRef.js.map +1 -0
  19. package/dist/resolve/rootsFormat.d.ts +12 -0
  20. package/dist/resolve/rootsFormat.d.ts.map +1 -0
  21. package/dist/resolve/rootsFormat.js +63 -0
  22. package/dist/resolve/rootsFormat.js.map +1 -0
  23. package/dist/tools/backlog.d.ts +4 -0
  24. package/dist/tools/backlog.d.ts.map +1 -0
  25. package/dist/tools/backlog.js +157 -0
  26. package/dist/tools/backlog.js.map +1 -0
  27. package/dist/tools/index.d.ts +52 -1
  28. package/dist/tools/index.d.ts.map +1 -1
  29. package/dist/tools/index.js +433 -137
  30. package/dist/tools/index.js.map +1 -1
  31. package/dist/tools/navis.d.ts.map +1 -1
  32. package/dist/tools/navis.js +4 -0
  33. package/dist/tools/navis.js.map +1 -1
  34. package/package.json +8 -3
  35. package/scripts/agent-e2e.mjs +69 -0
  36. package/scripts/noesis-capture-session-end.mjs +94 -0
  37. package/scripts/noesis-capture-watcher.mjs +907 -0
  38. package/skill-templates/noesis-capture.md +166 -0
  39. package/skill-templates/noesis-create-study-note.md +149 -0
  40. package/skill-templates/noesis-find-related.md +89 -0
  41. package/skill-templates/noesis-investigate.md +90 -0
  42. package/skill-templates/noesis-manage-news.md +80 -0
  43. package/skill-templates/noesis-skim-read.md +72 -0
  44. package/templates/claude-md-block.md +5 -1
  45. package/templates/claude-md-restructure-on-sync.md +10 -0
@@ -0,0 +1,72 @@
1
+ ---
2
+ description: Generate Skim-Read key parts for a Noesis note YOURSELF (no in-app AI) and persist them as suggested marks — the Gemini-free fallback for the Skim-Read panel. Accepts a note ID or file path.
3
+ argument-hint: <note path or ID> [--style gist|balanced|thorough|structure|keyword] [--intensity light|normal|heavy]
4
+ ---
5
+
6
+ Generate the KEY PARTS a reader should focus on in a Noesis note and persist them, so the note's Skim-Read panel surfaces them. YOU do the extraction (using your own model) and the server only anchors + saves — no in-app Gemini call. This is the fallback to use when the app's built-in Skim-Read is rate-limited / 503, or any time you want to drive it from Claude Code.
7
+
8
+ ## Arguments
9
+
10
+ $ARGUMENTS
11
+
12
+ Accepted forms:
13
+
14
+ - `<path>.md` — a file path (e.g. from the Noesis web UI "Copy File Path" button). Quote paths with spaces.
15
+ - `<id>` — a numeric Note ID.
16
+ - Natural language — e.g. `Create skim-read for the note "/path/to/note.md"`; extract the path/ID from the request.
17
+ - `--style <s>` — reading strategy: `gist` | `balanced` (default) | `thorough` | `structure` | `keyword`.
18
+ - `--intensity <i>` — how many parts: `light` | `normal` (default) | `heavy`.
19
+
20
+ ## Workflow
21
+
22
+ ### Step 1 — Resolve the note
23
+
24
+ From `$ARGUMENTS`, extract the target: an all-digits token is a Note ID; anything else (a path, possibly quoted) is a file path. Capture optional `--style` / `--intensity`. If neither an ID nor a path is present, ask the user which note via `AskUserQuestion`.
25
+
26
+ ### Step 2 — Read the note content
27
+
28
+ Call `mcp__noesis__get_note(id: <id>)` or `mcp__noesis__get_note(path: <path>)`. Use the returned `content` as the source of truth. Do NOT call `mcp__noesis__get_note_skim_read` — that uses the in-app AI, which this skill deliberately bypasses.
29
+
30
+ ### Step 3 — Generate the key parts
31
+
32
+ Pick the spans a reader should focus on to get the gist efficiently — spread across the note's sections, each a DISTINCT idea (don't spend several parts on the same point). For each part produce `{ granularity, quote, headingPath?, importance, reason }`:
33
+
34
+ - **quote** — copied CHARACTER-FOR-CHARACTER (verbatim) from `content`. Do NOT paraphrase, translate, fix typos, summarize, or add ellipses. Make each quote long enough to occur exactly once (add surrounding words if a short phrase repeats).
35
+ - `section` → the heading line text · `sentence` → the full sentence · `paragraph` → its first ~12 words · `keyword` → the exact token(s).
36
+ - **granularity** — `section` | `paragraph` | `sentence` | `keyword`.
37
+ - **importance** — 0..1; reserve > 0.8 for the few genuinely load-bearing parts.
38
+ - **reason** — ≤ 12 words, plainly what the span says (no hype words).
39
+ - Only quote VISIBLE prose. Skip code fences (```), YAML frontmatter, HTML tags, and any COLLAPSED `<details>` block (one without the `open` attribute).
40
+ - `headingPath` — ancestor heading texts (top-most first) to disambiguate a repeated quote; omit or `[]` if unknown.
41
+
42
+ Prefer fewer high-confidence parts over filling a quota; it is correct to return few parts for a short or list-like note.
43
+
44
+ ### Step 4 — Apply
45
+
46
+ Call `mcp__noesis__apply_note_skim_read` with `{ id | path, keyParts: [...], style?, intensity? }`. The server anchors each verbatim quote and persists matches as `suggested` marks (replacing prior un-accepted suggestions; accepted/dismissed marks are preserved).
47
+
48
+ ### Step 5 — Fix unmatched quotes (loop)
49
+
50
+ The result includes `unmatchedQuotes` — quotes that did not occur verbatim in the note. If non-empty:
51
+
52
+ 1. Re-read those spans in `content` and correct each quote to the note's EXACT text.
53
+ 2. Call `mcp__noesis__apply_note_skim_read` again with the corrected full set.
54
+ 3. Repeat until `unmatchedQuotes` is empty (or you've corrected every quote you reasonably can — typically ≤ 3 rounds).
55
+
56
+ ### Step 6 — Report
57
+
58
+ State how many key parts were applied (`keyPartCount`), list any quotes that still didn't anchor, and tell the user to open the note's **Skim-Read** panel to see them.
59
+
60
+ ## Constraints
61
+
62
+ - Quotes MUST be verbatim slices of the note content — never invented or edited. A verbatim quote is what lets the server anchor the mark.
63
+ - This skill never calls the in-app Skim-Read AI; generating the parts yourself is the entire point (it works when Gemini is down).
64
+ - The path must sit under one of the user's registered Noesis roots, and the note must exist in the database the MCP server targets. If the lookup 404s, confirm the path/ID and that the MCP server points at the right backend.
65
+ - Do not edit the note's body — Skim-Read only adds non-destructive `suggested` marks.
66
+
67
+ ## Examples
68
+
69
+ - `/noesis-skim-read "/path/to/note.md"` — skim-read by file path.
70
+ - `/noesis-skim-read 2302 --style gist` — terse gist of note 2302.
71
+ - `/noesis-skim-read 2302 --intensity heavy` — more key parts.
72
+ - `Create skim-read for the note "/path/to/note.md"` — natural-language invocation.
@@ -13,10 +13,14 @@
13
13
  - Use `mcp__noesis__get_note` (read by ID or path), `mcp__noesis__find_similar_notes` (semantic similarity), `mcp__noesis__search_semantic` / `mcp__noesis__search_notes` (meaning / keyword search), `mcp__noesis__update_relations` (read-only when called without the `relations` param).
14
14
 
15
15
  ### Path-as-identifier (cross-machine)
16
- For any path inside a Noesis-watched root (paths containing `/.noesis/`, or any path under a directory listed by `mcp__noesis__list_roots`), the path is a Noesis identifier — the cloud copy is always authoritative, and the local copy on this machine may be **missing** (other machine) or **stale** (the user edited the note via the Noesis web UI's Quick Fix; the web UI surfaces that state with the badge 「在线编辑 · 等待本地同步」). Either way, the local copy is not a trustworthy source of truth — reading it directly silently feeds outdated content into the rest of the turn.
16
+ For any path inside a Noesis-watched root, the path is a Noesis identifier — the cloud copy is always authoritative, and the local copy on this machine may be **missing** (other machine) or **stale** (the user edited the note via the Noesis web UI's Quick Fix; the web UI surfaces that state with the badge 「在线编辑 · 等待本地同步」). Either way, the local copy is not a trustworthy source of truth — reading it directly silently feeds outdated content into the rest of the turn.
17
+
18
+ A path is Noesis-watched if it contains `/.noesis/` **OR sits under a folder named `Noesis`** (the cloud root — e.g. `~/Noesis/…`, `%USERPROFILE%\Noesis\…`, or `C:\Users\<you>\Noesis\…`), **OR** is under any directory listed by `mcp__noesis__list_roots`. The `Noesis`/`.noesis` folder name is the cheap signal; when in doubt, treat a `.md` path that looks like a note as watched and let the MCP tool decide.
17
19
 
18
20
  Trigger: when the user references such a path and you are about to read, edit, or otherwise consume it, sync first — once per path per turn, before the first tool call that touches it. Not before subsequent re-reads of the same path in the same turn.
19
21
 
22
+ **RECOVERY RULE:** if `Read` returns "file does not exist" for a `.md` path that looks like a note — especially one under a `.noesis`/`Noesis` folder — your immediate next action is the MCP tool below with the **same path**. Do NOT conclude the note is missing, on another machine, or that the path was mistyped until the MCP lookup also fails.
23
+
20
24
  - **NORMAL mode (writes allowed):** call `mcp__noesis__sync_notes(files: [<that path>])`. The three-way merge handles every case: in-sync → cheap no-op (`'skip'`); cloud-newer → auto-pulls to local disk; local-newer → pushes to cloud; both diverged → conflict cascade (3-way merge); missing locally → auto-creates from cloud. In all five cases the next `Read`/`Edit`/`Write` sees the right bytes.
21
25
  - **PLAN mode (writes forbidden):** call `mcp__noesis__get_note(path=<that path>)` for a read-only cloud lookup. Compare its `content_hash` / `updated_at` against the local file's hash / mtime; if drift exists, surface it in the plan and propose `sync_notes` as Step 1 of the implementation.
22
26
  - In either mode, do NOT fall back to Glob/Grep to hunt for similar filenames; do NOT ask the user to disambiguate the path. The cloud is authoritative for Noesis-watched paths.
@@ -0,0 +1,10 @@
1
+ ### Restructuring notes that grew by accretion (optional)
2
+ Before syncing a note that shows the **accretion smell** — bolt-on sections (e.g. "a later round of testing exposed a case sections 1–7 didn't cover"), duplicated passages re-explaining the same point under different headings, or a chronological log of patches — do NOT push the sprawl as-is, and do NOT just append another section. Notes that grow by accretion become hard to study.
3
+
4
+ Restructure first:
5
+ 1. Read the FULL current note (`mcp__noesis__get_note` or the local file) so you preserve the substance — diagrams, inventories, code snippets, instrumentation, repro tables.
6
+ 2. Reorganize into ONE coherent narrative led by the **root cause / main finding**, not by chronology: Context & Symptom → Root Cause → supporting detail → inventory/appendix.
7
+ 3. Merge the duplicated sections; fold each bolted-on "later round" addition into the section it belongs to. Revise the existing section rather than adding a new one.
8
+ 4. Then sync, and briefly say which notes you restructured — never rewrite a note body silently.
9
+
10
+ This deliberately permits **body rewrites** on sync — broader than `/noesis-refine-note`, which only touches metadata and headings. You are reorganizing for clarity, not deleting content: preserve every fact, diagram, and snippet.