From f8ffd2728ab40dea5623ffcdb3eaed3be8e01263 Mon Sep 17 00:00:00 2001 From: zaynram Date: Mon, 1 Jun 2026 21:08:57 -0500 Subject: [PATCH 01/19] checkpoint: WIP win32-target / build-simplification work in progress MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preserves the working state before the install-script + non-vendored-pdf refactor. Captures the commands→skills migration, nu module moved to bin/scholar.nu, build-plugin/tsconfig/package.json edits, and gitignores the compiled binaries (bin/mcp-scholar*), win32/ staging, and the stray home/ nested copy so they stay out of history. Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude-plugin/plugin.json | 48 ++-- .gitignore | 9 + bin/scholar.nu | 113 +++++++++ commands/digest.md | 29 --- commands/ingest.md | 31 --- commands/status.md | 28 --- nu/scholar.nu | 117 --------- nu/scholar.test.ts | 88 ------- package.json | 96 ++++---- scripts/build-plugin.ts | 417 ++++++++++++++++---------------- scripts/build-ui.ts | 34 +-- scripts/util/index.ts | 64 ++--- skills/digest/SKILL.md | 29 +++ skills/ingest/SKILL.md | 34 +++ skills/status/SKILL.md | 21 ++ src/server/db/sqlite-vec.ts | 36 +-- tests/build-plugin.test.ts | 469 ------------------------------------ tests/manifests.test.ts | 33 ++- tests/scholar.test.ts | 102 ++++++++ tsconfig.json | 78 +++--- 20 files changed, 698 insertions(+), 1178 deletions(-) create mode 100755 bin/scholar.nu delete mode 100644 commands/digest.md delete mode 100644 commands/ingest.md delete mode 100644 commands/status.md delete mode 100644 nu/scholar.nu delete mode 100644 nu/scholar.test.ts create mode 100644 skills/digest/SKILL.md create mode 100644 skills/ingest/SKILL.md create mode 100644 skills/status/SKILL.md delete mode 100644 tests/build-plugin.test.ts create mode 100644 tests/scholar.test.ts diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 4373f2a..4296273 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,27 +1,25 @@ { - "name": "scholar", - "description": "Literature review workspace. Multi-corpus reading, annotation, semantic search, Ollama-powered syntheses, and a vendored pdf MCP. Inspired by but independent of the Daisy Lit Review artifact.", - "author": { - "name": "zayn" - }, - "keywords": [ - "literature-review", - "research", - "mcp-apps", - "annotations", - "ollama", - "sqlite-vec" - ], - "license": "MIT", - "mcpServers": { - "scholar": { - "command": "${CLAUDE_PLUGIN_ROOT}/build/scholar", - "env": { - "SCHOLAR_RUNTIME_ROOT": "${HOME}/mcp-data/scholar/runtime", - "SCHOLAR_OLLAMA_URL": "http://127.0.0.1:11434", - "SCHOLAR_OLLAMA_EMBED_MODEL": "nomic-embed-text:v1.5", - "SCHOLAR_OLLAMA_CHAT_MODEL": "qwen3:8b" - } + "name": "scholar", + "description": "Literature review workspace. Multi-corpus reading, annotation, semantic search, Ollama-powered syntheses, and a vendored pdf MCP. Inspired by but independent of the Daisy Lit Review artifact.", + "author": { "name": "zayn" }, + "keywords": [ + "literature-review", + "research", + "mcp-apps", + "annotations", + "ollama", + "sqlite-vec" + ], + "license": "MIT", + "mcpServers": { + "scholar": { + "command": "${CLAUDE_PLUGIN_ROOT}/bin/mcp-scholar", + "env": { + "SCHOLAR_RUNTIME_ROOT": "${HOME}/mcp-data/scholar/runtime", + "SCHOLAR_OLLAMA_URL": "http://127.0.0.1:11434", + "SCHOLAR_OLLAMA_EMBED_MODEL": "nomic-embed-text:v1.5", + "SCHOLAR_OLLAMA_CHAT_MODEL": "qwen3:8b" + } + } } - } -} \ No newline at end of file +} diff --git a/.gitignore b/.gitignore index 0a1d550..998fc33 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,12 @@ runtime/ .claude/scheduled_tasks.lock .claude/worktrees/** + +# Compiled server binaries + platform staging dirs — build outputs, never commit. +bin/mcp-scholar +bin/mcp-scholar.exe +win32/ +# Stray nested copy from a build script writing to a literal "home/" path. +home/ +# Backup of the deleted build-plugin.test.ts, kept locally during the refactor. +build-plugin-test-old.ts diff --git a/bin/scholar.nu b/bin/scholar.nu new file mode 100755 index 0000000..56ce1b8 --- /dev/null +++ b/bin/scholar.nu @@ -0,0 +1,113 @@ +#!/usr/bin/env -S nu --stdin +# Usage: nu scholar.nu +const SELF = path self + +def --wrapped "safe extract" [ + ...rest: string + --select # Use `select` over `get`, i.e. to return a table instead of a list +]: oneof -> oneof { + let value = $in + if ($value | describe) == string { + $value + } else if $select { + $value | select --optional ...$rest + } else { + $value | get --optional $rest.0 ...($rest | skip 1) + } +} + +# Wrapper for the `scholar` binary executable. +def main [ + tool?: string # The name of the tool to call on the server + --json: oneof # Parameters to pass through to the tool call +]: oneof -> oneof { + if $tool == null { print --stderr 'tool name is required' | return } + let args = $in | default $json | default {} + let output = mcp-scholar --call $tool $args + | complete + | default 0 exit_code + | default '{}' stdout stderr + let text = if ($output.exit_code) == 0 { $output.stdout } else { $output.stderr } + try { $text | str trim | to json --raw } catch { $text } +} + +# List papers in the active corpus (uses ctx.db snapshot — no corpus_id arg). +def "main list" [ + --limit: int = 50 # Maximum number of results to return + --query: string = '' # Filter string to query results with +]: nothing -> oneof { + let res = {q: $query limit: $limit} | main papers.search + if ($res | describe) == string { return $res } + if ($res.still_indexing? | default false) { + print "note: semantic index still building; results are lexical only" + } + $res.hits? | default [] | select id title score +} + +# Show corpus status. +def "main status" [ + corpus?: string # The identifier of a corpus to target (defaults to active ) +]: nothing -> oneof { + if ($corpus | is-empty) { {} } else { {corpus_id: $corpus} } + | main scholar.corpus.status +} + +# Ingest papers from BibTeX/RIS/DOI/arXiv. +# Routes to scholar.ingest.{bibtex,ris,doi,arxiv}. +def "main ingest" [ + corpus: string # The identifier of the corpus to ingest papers into + --bibtex: string # Path to a BibTeX paper to ingest + --ris: string # Path to a RIS paper to ingest + --doi: string # Direct DOI of a paper to ingest + --arxiv: string # arXiv identifier of a paper to ingest +]: nothing -> oneof { + if ($bibtex | is-not-empty) { + {file_path: $bibtex corpus_id: $corpus} + | main scholar.ingest.bibtex + | safe extract imported + } else if ($ris | is-not-empty) { + {file_path: $ris corpus_id: $corpus} + | main scholar.ingest.ris + | safe extract imported + } else if ($doi | is-not-empty) { + {doi: $doi corpus_id: $corpus} + | main scholar.ingest.doi + } else if ($arxiv | is-not-empty) { + {arxiv_id: $arxiv corpus_id: $corpus} + | main scholar.ingest.arxiv + } else { + error make "one of `--bibtex`, `--ris`, `--doi`, `--arxiv` is required" + } +} + +# Search papers (hybrid lexical + semantic via RRF — mode always-on, no mode arg). +# still_indexing=true signals semantic is building; lexical results are returned in the interim. +def "main query" [ + q: string # The query string to match results to + --limit: int = 50 # Maximum number of entries to return +]: nothing -> oneof { + # args: { q: string; limit?: number } — corpus_id and mode DROPPED per extraction-003 contract + main list --limit $limit --query $q +} + +# Generate digest on a scoped set of papers. +def "main digest" [ + --all # Include all papers (default) + --stale # Include only stale papers + --label: string # Include papers by section label + --hash: string # Include papers by selection hash + --claude # Use Claude for running the inference instead of Ollama +]: nothing -> string { + let scope = match {all: $all stale: $stale section: $label selection: $hash} { + {all: true} => 'all' + {stale: true} => 'stale' + {section: $s} if $s != null => $'section:($s)' + {selection: $h} if $h != null => $'selection:($h)' + } | default all + let res = {scope_key: $scope use_claude: $claude} | main scholar.digest.generate + if ($res | describe) =~ table and $res.askClaude? == null { + $res | get --optional body_md | default "(empty body)" + } else { + "digest requires claude opt-in; run with `--claude` or use the Cowork host UI." + } +} diff --git a/commands/digest.md b/commands/digest.md deleted file mode 100644 index ccd76c9..0000000 --- a/commands/digest.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: scholar:digest -description: Generate a synthesis digest for the active corpus scope (Ollama default; --claude opt-in). ---- - -# /scholar:digest - -## Usage - -``` -/scholar:digest -/scholar:digest --scope section:methods -/scholar:digest --scope stale -/scholar:digest --claude -``` - -## Arguments - -| Argument | Type | Default | Description | -|---|---|---|---| -| `--scope` | string | `all` | One of `all`, `stale`, `section: