@evegoodevening/dsh-llmwiki 0.0.0-stage → 0.0.1

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 (40) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +172 -2
  4. package/THIRD_PARTY_NOTICES.md +40 -0
  5. package/cordis.patch.yml +1 -0
  6. package/lib/index.js +3281 -0
  7. package/lib/index.js.map +1 -0
  8. package/lib/types/atomic.d.ts +19 -0
  9. package/lib/types/atomic.d.ts.map +1 -0
  10. package/lib/types/command.d.ts +4 -0
  11. package/lib/types/command.d.ts.map +1 -0
  12. package/lib/types/config.d.ts +22 -0
  13. package/lib/types/config.d.ts.map +1 -0
  14. package/lib/types/errors.d.ts +16 -0
  15. package/lib/types/errors.d.ts.map +1 -0
  16. package/lib/types/ids.d.ts +8 -0
  17. package/lib/types/ids.d.ts.map +1 -0
  18. package/lib/types/index.d.ts +14 -0
  19. package/lib/types/index.d.ts.map +1 -0
  20. package/lib/types/indexer.d.ts +69 -0
  21. package/lib/types/indexer.d.ts.map +1 -0
  22. package/lib/types/lint.d.ts +8 -0
  23. package/lib/types/lint.d.ts.map +1 -0
  24. package/lib/types/markdown.d.ts +17 -0
  25. package/lib/types/markdown.d.ts.map +1 -0
  26. package/lib/types/paths.d.ts +92 -0
  27. package/lib/types/paths.d.ts.map +1 -0
  28. package/lib/types/presentation.d.ts +5 -0
  29. package/lib/types/presentation.d.ts.map +1 -0
  30. package/lib/types/prompt.d.ts +6 -0
  31. package/lib/types/prompt.d.ts.map +1 -0
  32. package/lib/types/service.d.ts +39 -0
  33. package/lib/types/service.d.ts.map +1 -0
  34. package/lib/types/tokenizer.d.ts +9 -0
  35. package/lib/types/tokenizer.d.ts.map +1 -0
  36. package/lib/types/tools.d.ts +3 -0
  37. package/lib/types/tools.d.ts.map +1 -0
  38. package/lib/types/types.d.ts +123 -0
  39. package/lib/types/types.d.ts.map +1 -0
  40. package/package.json +96 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ ## [0.0.1]
4
+
5
+ Initial release of `@evegoodevening/dsh-llmwiki`.
6
+
7
+ ### Added
8
+
9
+ - Local-first Markdown wiki storage and retrieval as a DeepSeek Harness profile bundle, disabled by default and enabled through an operator-owned patch.
10
+ - Nine agent tools for status, immutable source capture and reads, paginated source/page catalogs, page reads and conditional writes, section search, and structural lint; `/wiki status`, `/wiki lint`, and `/wiki reindex` commands.
11
+ - SHA-256-addressed UTF-8 source records with preserved provenance, same-content deduplication, and narrow recovery of interrupted, uncommitted source writes.
12
+ - Source-linked Markdown pages with required `expectedSha256` write preconditions: `null` for creation or the current raw-Markdown hash for updates. Stale writes return `PAGE_CONFLICT`.
13
+ - Deterministic section-level lexical search with NFKC/lowercase tokenization, BM25 field weighting, bounded query-centered snippets, and automatic rebuilding of stale or semantically inconsistent indexes.
14
+ - Non-mutating status, catalogs, and structural lint covering storage integrity, links, and index freshness. Source/page reads and search may initialize storage; search may rebuild the index.
15
+ - Linux/procfs descriptor-contained filesystem operations with fail-closed capability checks and no pathname fallback. Concurrent writers across activations/processes and hostile root modification remain unsupported.
16
+ - Human-owned schema guidance and an agent workflow prompt separating structural lint from model-driven synthesis and semantic review. The plugin itself makes no model or network calls.
17
+ - Declared support for DSH `0.1.0-rc.6`, `0.1.1-rc.2`, `0.1.7-rc.2`, and `0.2.0-rc.2`, with the coherent service and Cordis families documented in the README.
18
+ - Packed-profile lifecycle and strict-consumer checks, deterministic filesystem race coverage, ordinary smoke, and a separately opted-in credentialed real-agent smoke harness.
19
+ - GitHub Actions workflows for npm Trusted Publishing, upstream compatibility monitoring, and an install-free dependency audit; a seven-day minimum dependency release age policy.
20
+ - Scoped third-party attribution and the complete retained upstream MIT notice for adapted workflow guidance, included in package artifacts.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 EveGoodEvening
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,173 @@
1
- # Temporary Holding Version
1
+ # dsh-llmwiki
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Third-party, local-first, source-linked Markdown wiki storage and retrieval plugin for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH), inspired by [Karpathy's LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f).
4
+
5
+ Maintained by EveGoodEvening, this is not an official DeepSeek or DeepSeek Harness project. References to DeepSeek Harness and Andrej Karpathy describe compatibility and inspiration only; they do not imply affiliation, sponsorship, or endorsement.
6
+
7
+ - Preserve immutable sources by SHA-256 and write Markdown pages that cite them.
8
+ - Search page sections with a deterministic lexical index; rebuild it when stale.
9
+ - Check structure, links, and integrity with model-free lint.
10
+
11
+ The plugin makes no model or network calls. The calling agent handles synthesis and semantic review; a source citation proves record existence, not claim support.
12
+
13
+ ## Requirements
14
+
15
+ | DSH (`@deepseek-ai/dsh`) | Cordis (`@deepseek-ai/cordis`) | Status |
16
+ | --- | --- | --- |
17
+ | **`0.2.0-rc.2`** | **`4.0.4`** | **Recommended** |
18
+ | `0.1.7-rc.2` | `4.0.4` | Supported |
19
+ | `0.1.1-rc.2` | `4.0.1` | Supported legacy |
20
+ | `0.1.0-rc.6` | `4.0.1` | Supported legacy |
21
+
22
+ - **Node.js:** `^22.19.0 || >=24`.
23
+ - **pnpm:** `11.7.0`, on `PATH` for `dsh plugin` and development.
24
+ - Use a coherent DSH service family, not mixed release candidates. The `0.1.0-rc.6` host resolves its five DSH service peers to `0.1.0-rc.8`; the other rows use same-version services.
25
+ - Direct Cordis loading also needs DSH `tools`, `commands`, and `systemPrompt` services and one shared `@deepseek-ai/schemastery@^3.18.1` installation. See [exact peer ranges](package.json) and the [standalone example](examples/README.md).
26
+
27
+ The plugin's version in [package.json](package.json) is independent of the DSH and dependency versions above.
28
+
29
+ ## Install
30
+
31
+ Use **`@evegoodevening/dsh-llmwiki`**. The unscoped `dsh-llmwiki` package belongs to a different project.
32
+
33
+ From this checkout, pack and install `0.0.1` with a supported DSH host on `PATH` (`web` is the example profile):
34
+
35
+ ```sh
36
+ pnpm install --frozen-lockfile
37
+ pnpm pack
38
+ dsh plugin --profile web add ./evegoodevening-dsh-llmwiki-0.0.1.tgz
39
+ ```
40
+
41
+ When the package is available on npm, the equivalent registry command is `dsh plugin --profile web add @evegoodevening/dsh-llmwiki@latest`.
42
+
43
+ Installation leaves the plugin **disabled**. Enable it with an operator-owned patch and an explicit, writable wiki root:
44
+
45
+ ```sh
46
+ mkdir -p "$HOME/.config/dsh"
47
+ cat > "$HOME/.config/dsh/llmwiki-web.patch.yml" <<YAML
48
+ - insert:
49
+ - id: llmwiki
50
+ name: '@evegoodevening/dsh-llmwiki'
51
+ config:
52
+ root: '$HOME/.local/share/dsh/llmwiki/web'
53
+ YAML
54
+ dsh --profile web --patch "$HOME/.config/dsh/llmwiki-web.patch.yml" --dump-config
55
+ dsh --profile web --patch "$HOME/.config/dsh/llmwiki-web.patch.yml"
56
+ ```
57
+
58
+ Keep the patch on every start; restart a running profile after changes. Use `/wiki status` to inspect the repository. Before changing the installed package, stop all writers and back up the root. Retain the same explicit root to reuse existing wiki data, and check the filesystem requirements below before enabling it.
59
+
60
+ To uninstall without deleting wiki data:
61
+
62
+ ```sh
63
+ dsh plugin --profile web remove @evegoodevening/dsh-llmwiki
64
+ ```
65
+
66
+ For local-tarball installation or standalone Cordis loading, use the [runnable example](examples/README.md).
67
+
68
+ ## Usage
69
+
70
+ ### Commands
71
+
72
+ | Command | Purpose |
73
+ | --- | --- |
74
+ | `/wiki status` | Report initialization, source/page counts, and index state; also the default `/wiki` action |
75
+ | `/wiki lint` | Report structural errors and warnings without repairing anything |
76
+ | `/wiki reindex` | Rebuild the derived search index |
77
+
78
+ ### Agent tools
79
+
80
+ | Tool | Purpose |
81
+ | --- | --- |
82
+ | `llmwiki_status` | Inspect storage and read the human-owned schema |
83
+ | `llmwiki_add_source` | Preserve exact UTF-8 content; return its source ID |
84
+ | `llmwiki_list_sources` | Browse source metadata with pagination |
85
+ | `llmwiki_read_source` | Read preserved content and provenance |
86
+ | `llmwiki_search` | Find ranked page-section matches |
87
+ | `llmwiki_list_pages` | Browse page metadata and hashes with pagination |
88
+ | `llmwiki_read_page` | Read exact page Markdown and its SHA-256 by logical ID |
89
+ | `llmwiki_upsert_page` | Create or conditionally update a page citing existing source IDs |
90
+ | `llmwiki_lint` | Check structure, integrity, links, and index freshness |
91
+
92
+ Start with status and the schema. Preserve sources and maintain affected pages only with user authorization. Run structural lint **before semantic review**, even without writes, and again after any updates. Semantic findings are agent judgments, not lint results. Full workflow: [runtime prompt](src/prompt.ts); parameters: [tool schemas](src/tools.ts).
93
+
94
+ Search uses deterministic NFKC/lowercase tokens and BM25 field weighting; ties sort by page ID and section start line. Snippets show contiguous normalized body context around the earliest fitting scored query token (whole letter/number run or existing CJK two-code-point gram), with same-position ties resolved by UTF-16 lexical token order. They stay within `maxSnippetBytes` without splitting UTF-8 code points; no omission markers are added. Dispersed query terms need not all appear. Title/heading-only matches and body tokens too large for the cap use a bounded body prefix instead.
95
+
96
+ ### Page-write preconditions
97
+
98
+ Every page write requires `expectedSha256`: use `null` to create an absent page, or the exact raw-Markdown `sha256` returned by a page read or catalog to update an existing page. On `PAGE_CONFLICT`, reread and reconcile the page before retrying; do not overwrite with a stale hash or blindly retry.
99
+
100
+ ## Configuration
101
+
102
+ All keys are optional. Numeric values are integers; unknown keys are rejected.
103
+
104
+ | Key | Default | Meaning / limits |
105
+ | --- | --- | --- |
106
+ | `root` | `.llmwiki` | Non-empty path, resolved once from the host process cwd |
107
+ | `maxSourceBytes` | `2097152` | Source content limit: 2 MiB; minimum 1 byte |
108
+ | `maxPageBytes` | `524288` | Rendered page body limit: 512 KiB; minimum 1 byte |
109
+ | `maxResults` | `20` | Search and catalog page-size cap; `1..100` |
110
+ | `maxSnippetBytes` | `1200` | Search snippet limit; `64..16384` bytes |
111
+ | `commandDiagnosticLimit` | `20` | Diagnostics printed by `/wiki lint`; `1..100` |
112
+
113
+ ## Storage and safety
114
+
115
+ ```text
116
+ <root>/
117
+ schema.md # human-owned guidance; created only if absent
118
+ sources/<sha256>/
119
+ content # immutable UTF-8 source
120
+ metadata.json # provenance and capture metadata
121
+ pages/<page-id>.md # Markdown with title, summary, and source IDs
122
+ .index/{search,state}.json # derived, rebuildable search data
123
+ ```
124
+
125
+ - **Host storage, not a DSH sandbox.** Direct Node filesystem I/O bypasses `ctx.fs`, DSH permission modes, approval, read-before-edit, and remote/workspace providers. Do not enable this plugin where those controls are required; enforce boundaries with OS permissions and process isolation.
126
+ - **One fixed root per activation.** Session/workspace cwd changes do not switch storage. Use distinct roots for isolation; mutually untrusted tenants must not share a root or activation. Concurrent writers across activations/processes are unsupported. Do not let untrusted processes modify the root.
127
+ - **Filesystem backend.** Descriptor-contained storage requires Linux, numeric nofollow/directory-open flags, and a mounted, usable `/proc/self/fd`. Unsupported or unavailable capabilities fail closed with `UNSAFE_FILESYSTEM`; there is no pathname fallback. Non-Linux descriptor backends are not supported or claimed proven. Root and child directories are pinned per operation, final files are opened without following symlinks, and an initialized root's device/inode identity must remain unchanged.
128
+ - **Adversary limits.** Pinned traversal prevents symlink substitution from redirecting filesystem operations into an outside symlink target. It is not a whole-tree transaction or a compare-and-rename guarantee. An already-authorized directory can remain accessible after being renamed outside its former lexical root. Ordinary file/hardlink injection, privileged mount or process access, and hostile replacement of procfs are outside this guarantee; OS isolation and the no-untrusted-writers requirement still apply.
129
+ - **Some reads can write.** Status, catalog listings, and lint never write. Source/page reads and search may initialize storage; search may also rebuild the index. Read-only deployments need an initialized repository and a fresh index.
130
+ - Sources are never edited or deleted by the plugin. Existing `schema.md` is preserved; there is no schema-editing API.
131
+
132
+ ### Interrupted source writes
133
+
134
+ Retry `llmwiki_add_source` (or `ctx.llmwiki.addSource`) with identical content after an interrupted source write. Recovery is limited to the final source directory with **no committed `metadata.json`**, containing only an empty state, matching durable `content`, and/or recognized regular writer temporary files. Matching durable content is preserved; metadata commits last using the retry's provenance. The recovered receipt has `deduplicated: false`; the next identical-content retry deduplicates.
135
+
136
+ A valid complete record always deduplicates without changing its first committed metadata/provenance bytes. Corrupt content or metadata, unknown children, and symlink/nonregular children are refused without changing the rejected record. Reads, catalogs, and lint do not repair partial records or treat them as valid; source/page reads can still initialize the storage layout as described above. This is narrow crash retry, not a generic repair/quarantine facility or a multi-page transaction.
137
+
138
+ ## Development
139
+
140
+ ```sh
141
+ pnpm install --frozen-lockfile
142
+ pnpm run build
143
+ pnpm run typecheck
144
+ pnpm run lint
145
+ pnpm test
146
+ pnpm run test:e2e
147
+ pnpm run check:determinism
148
+ pnpm run smoke
149
+ ```
150
+
151
+ The Linux unit suite's read-only tmpfs test requires root and mount-namespace capability. E2E builds first and exercises packed packages across the supported host matrix; run it separately from other builds because it temporarily hides shared checkout paths. Ordinary smoke uses the pinned legacy development dependencies, not the recommended host.
152
+
153
+ - **Upstream compatibility:** `pnpm run check:compatibility` probes latest DSH with native dependencies and, separately, forced latest Cordis. Networked, model-free; probes do not automatically extend the support table. See the [scheduled workflow](.github/workflows/compatibility.yml).
154
+ - **Real-agent smoke:** set `DEEPSEEK_API_KEY`, `LLMWIKI_AGENT_SMOKE_MODEL`, and `LLMWIKI_AGENT_SMOKE_NETWORK=allow`, then run `pnpm run smoke:agent`. This separate, credentialed check uses a pinned DSH `0.1.1-rc.2` runner; offline checks do not prove model behavior.
155
+ - **Publishing:** the [release workflow](.github/workflows/publish.yml) uses npm Trusted Publishing for a `v*` tag matching `package.json`.
156
+
157
+ ## References / Acknowledgements
158
+
159
+ The design and integration work consulted these sources:
160
+
161
+ - [Andrej Karpathy's LLM Wiki idea file](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) — the primary conceptual inspiration: immutable raw sources, a persistent LLM-maintained Markdown wiki, schema guidance, and ingest/query/lint workflows. It describes a pattern, not a required implementation or API.
162
+ - [Astro-Han/karpathy-llm-wiki](https://github.com/Astro-Han/karpathy-llm-wiki) — the raw/wiki/schema separation, evidence requirements, and explicit ingest/query/lint workflows in its agent skill. The specific triage and cascade-update guidance is covered by the scoped attribution and retained MIT license in [Third-party notices](THIRD_PARTY_NOTICES.md).
163
+ - [ddsyasas/llm-wiki](https://github.com/ddsyasas/llm-wiki) — persisted source/page records, index-first navigation, and the separation of deterministic lint from model judgment. Its Next.js/SQLite/FTS application architecture is not adopted here.
164
+ - [Praney Behl's llm-wiki-plugin](https://github.com/praneybehl/llm-wiki-plugin) — section-level lexical retrieval and stable evidence output in its search tooling, plus surgical page updates, citations, and user-review boundaries in its ingest workflow. Its Python/uv/FastEmbed/sqlite-vec runtime is not adopted here.
165
+ - [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness/tree/fa7e9f5a) — Cordis plugin and service conventions, lifecycle ownership, tool/command/system-prompt registration, and profile bundle integration. The initial integration research used revision `fa7e9f5a`; supported runtime versions are listed above.
166
+
167
+ These acknowledgements identify design influences and integration references; they do not imply endorsement by the referenced authors or projects. This package's MIT license does not relicense the referenced works, which remain subject to their own copyright and licensing terms.
168
+
169
+ ## License
170
+
171
+ [MIT](LICENSE) © EveGoodEvening.
172
+
173
+ See [Third-party notices](THIRD_PARTY_NOTICES.md) for the scope and complete upstream license retained for workflow guidance. The project's MIT license does not replace that notice.
@@ -0,0 +1,40 @@
1
+ # Third-party notices
2
+
3
+ This file preserves the upstream notice for the workflow guidance identified below. The project's own material remains licensed under [LICENSE](LICENSE). Referenced projects and separately installed dependencies retain their own copyrights and licenses; inclusion here does not imply endorsement.
4
+
5
+ ## Astro-Han / karpathy-llm-wiki — workflow guidance
6
+
7
+ - Upstream project: https://github.com/Astro-Han/karpathy-llm-wiki
8
+ - Audited source: [`SKILL.md` at `eafcc77001e496cc43499e4923b663aec722c813`](https://github.com/Astro-Han/karpathy-llm-wiki/blob/eafcc77001e496cc43499e4923b663aec722c813/SKILL.md), particularly **Ingest / Triage** and **Cascade Updates**.
9
+ - Upstream license: [`LICENSE` at the same revision](https://github.com/Astro-Han/karpathy-llm-wiki/blob/eafcc77001e496cc43499e4923b663aec722c813/LICENSE).
10
+ - Local scope: the source-disposition, affected-page maintenance, and conflict/supersession guidance in `LLMWIKI_SYSTEM_PROMPT` (`src/prompt.ts`) and `DEFAULT_SCHEMA` (`src/service.ts`), their compiled representations, and corresponding workflow descriptions in the examples, maintenance fixtures, and planning/handoff documents.
11
+
12
+ The relevant guidance combines new/update/disputed/no-material source triage, maintenance of materially affected pages, and preservation of conflicting or superseded claims. This project reorganizes the guidance around its own APIs, retains some similar terminology and phrasing, calls the disputed case `contradiction`, and adds authorization and concurrency rules. The textual and procedural correspondences suggest a probable adaptation of this workflow guidance, although the original development-time use of the upstream material has not been confirmed. The upstream copyright and license notice is retained conservatively on that basis. This attribution does not extend to the plugin's storage, parser, search, or DSH integration implementation, and makes no determination about the copyrightability of an abstract workflow.
13
+
14
+ The audited revision identifies the material compared during the provenance review, not a recorded exact checkout used during the original development. Karpathy's separate LLM Wiki idea file remains a conceptual reference: no MIT license is asserted for that gist, and this notice does not relicense it.
15
+
16
+ ### Upstream license text
17
+
18
+ ```text
19
+ MIT License
20
+
21
+ Copyright (c) 2026 Yuhan Lei
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in all
31
+ copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
+ SOFTWARE.
40
+ ```
@@ -0,0 +1 @@
1
+ []