@zosmaai/pi-llm-wiki 0.1.2 → 0.2.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.
- package/.coderabbit.yaml +43 -0
- package/.github/workflows/ci.yml +9 -8
- package/.github/workflows/codeql.yml +39 -0
- package/.github/workflows/release.yml +6 -4
- package/AGENTS.md +57 -0
- package/CHANGELOG.md +30 -0
- package/CONTRIBUTING.md +43 -0
- package/LICENSE +21 -0
- package/README.md +44 -344
- package/assets/README.md +3 -3
- package/assets/architecture.md +1 -1
- package/biome.json +3 -0
- package/docs/api.md +105 -0
- package/docs/architecture.md +65 -0
- package/docs/commands.md +51 -0
- package/docs/configuration.md +38 -0
- package/docs/obsidian.md +21 -0
- package/extensions/llm-wiki/index.ts +53 -0
- package/extensions/llm-wiki/lib/guardrails.ts +69 -0
- package/extensions/llm-wiki/lib/metadata.ts +218 -0
- package/extensions/llm-wiki/lib/source-packet.ts +292 -0
- package/extensions/llm-wiki/lib/tools.ts +932 -0
- package/extensions/llm-wiki/lib/utils.ts +222 -0
- package/package.json +11 -12
- package/prompts/wiki-digest.md +1 -1
- package/prompts/wiki-discover.md +2 -2
- package/prompts/wiki-ingest.md +2 -2
- package/prompts/wiki-init.md +2 -2
- package/prompts/wiki-lint.md +1 -1
- package/prompts/wiki-query.md +2 -2
- package/prompts/wiki-run.md +6 -6
- package/prompts/wiki-status.md +1 -1
- package/scripts/release.js +72 -0
- package/skills/llm-wiki/SKILL.md +95 -369
- package/skills/llm-wiki/templates/DASHBOARD.md +2 -2
- package/skills/llm-wiki/templates/pages/analysis.md +35 -0
- package/test/llm-wiki.test.ts +18 -9
- package/extensions/llm-wiki-tools.ts +0 -705
package/.coderabbit.yaml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# CodeRabbit AI Code Review Configuration
|
|
2
|
+
# Docs: https://docs.coderabbit.ai/guides/configure-coderabbit
|
|
3
|
+
|
|
4
|
+
language: en-US
|
|
5
|
+
early_access: false
|
|
6
|
+
reviews:
|
|
7
|
+
profile: assertive
|
|
8
|
+
request_changes_workflow: true
|
|
9
|
+
high_level_summary: true
|
|
10
|
+
poem: false
|
|
11
|
+
review_status: true
|
|
12
|
+
collapse_walkthrough: false
|
|
13
|
+
auto_review:
|
|
14
|
+
enabled: true
|
|
15
|
+
ignore_title_keywords:
|
|
16
|
+
- "chore"
|
|
17
|
+
- "WIP"
|
|
18
|
+
- "wip"
|
|
19
|
+
drafts: false
|
|
20
|
+
base_branches:
|
|
21
|
+
- main
|
|
22
|
+
path_instructions:
|
|
23
|
+
- path: "extensions/**/*.ts"
|
|
24
|
+
instructions: |
|
|
25
|
+
Review TypeScript extension files for pi coding agent. Check that:
|
|
26
|
+
1. Tools use pi.registerTool() with TypeBox schemas
|
|
27
|
+
2. Error handling uses try/catch with proper messages
|
|
28
|
+
3. Unused parameters use underscore prefix or are removed
|
|
29
|
+
4. File exports a default function receiving ExtensionAPI
|
|
30
|
+
- path: "skills/**/SKILL.md"
|
|
31
|
+
instructions: |
|
|
32
|
+
Review SKILL.md for pi. Verify:
|
|
33
|
+
1. Frontmatter follows Agent Skills spec (name, description)
|
|
34
|
+
2. Workflows are clearly documented with steps
|
|
35
|
+
3. Golden rules and conventions are explicit
|
|
36
|
+
- path: "prompts/**/*.md"
|
|
37
|
+
instructions: |
|
|
38
|
+
Review prompt templates. Verify:
|
|
39
|
+
1. Frontmatter has description, args, section, topLevelCli
|
|
40
|
+
2. Instructions are actionable and clear
|
|
41
|
+
|
|
42
|
+
chat:
|
|
43
|
+
auto_reply: true
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -2,9 +2,9 @@ name: CI
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches: [main
|
|
5
|
+
branches: [main]
|
|
6
6
|
pull_request:
|
|
7
|
-
branches: [main
|
|
7
|
+
branches: [main]
|
|
8
8
|
|
|
9
9
|
concurrency:
|
|
10
10
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
@@ -33,12 +33,13 @@ jobs:
|
|
|
33
33
|
- name: Lint
|
|
34
34
|
run: npm run lint
|
|
35
35
|
|
|
36
|
-
- name: Run Tests
|
|
37
|
-
run: npm test
|
|
36
|
+
- name: Run Tests with Coverage
|
|
37
|
+
run: npm run test:coverage
|
|
38
38
|
|
|
39
|
-
- name: Upload Coverage
|
|
39
|
+
- name: Upload Coverage to Codecov
|
|
40
40
|
if: ${{ matrix.node-version == 22 && github.event_name == 'push' }}
|
|
41
|
-
uses:
|
|
41
|
+
uses: codecov/codecov-action@v5
|
|
42
42
|
with:
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
files: ./coverage/lcov.info
|
|
44
|
+
fail_ci_if_error: false
|
|
45
|
+
verbose: true
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: "CodeQL"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: "0 6 * * 1" # Every Monday at 6 AM
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
analyze:
|
|
13
|
+
name: Analyze (${{ matrix.language }})
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
permissions:
|
|
16
|
+
security-events: write
|
|
17
|
+
packages: read
|
|
18
|
+
actions: read
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
include:
|
|
25
|
+
- language: javascript-typescript
|
|
26
|
+
build-mode: none
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
|
|
31
|
+
- uses: github/codeql-action/init@v3
|
|
32
|
+
with:
|
|
33
|
+
languages: ${{ matrix.language }}
|
|
34
|
+
build-mode: ${{ matrix.build-mode }}
|
|
35
|
+
queries: security-and-quality
|
|
36
|
+
|
|
37
|
+
- uses: github/codeql-action/analyze@v3
|
|
38
|
+
with:
|
|
39
|
+
category: "/language:${{ matrix.language }}"
|
|
@@ -39,7 +39,9 @@ jobs:
|
|
|
39
39
|
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
|
|
40
40
|
|
|
41
41
|
- name: Update package.json version
|
|
42
|
-
run:
|
|
42
|
+
run: |
|
|
43
|
+
node -e "const p=require('./package.json'); p.version='${{ steps.version.outputs.VERSION }}'; require('fs').writeFileSync('./package.json', JSON.stringify(p, null, 2)+'\n')"
|
|
44
|
+
npx biome check --fix package.json 2>&1
|
|
43
45
|
|
|
44
46
|
- name: Generate Release Notes
|
|
45
47
|
id: notes
|
|
@@ -57,7 +59,7 @@ jobs:
|
|
|
57
59
|
- name: Create GitHub Release
|
|
58
60
|
uses: softprops/action-gh-release@v2
|
|
59
61
|
with:
|
|
60
|
-
name: "
|
|
62
|
+
name: "v${{ steps.version.outputs.VERSION }}"
|
|
61
63
|
body: |
|
|
62
64
|
## 📦 @zosmaai/pi-llm-wiki v${{ steps.version.outputs.VERSION }}
|
|
63
65
|
|
|
@@ -70,7 +72,7 @@ jobs:
|
|
|
70
72
|
|
|
71
73
|
### What's Included
|
|
72
74
|
- **Skill**: Self-maintaining wiki schema (SKILL.md)
|
|
73
|
-
- **Extension**:
|
|
75
|
+
- **Extension**: 10 TypeScript tools (wiki_bootstrap, wiki_capture_source, wiki_ingest, wiki_ensure_page, wiki_search, wiki_lint, wiki_status, wiki_rebuild_meta, wiki_log_event, wiki_watch)
|
|
74
76
|
- **Prompt Templates**: 8 slash commands (/wiki:init, :ingest, :query, :lint, :discover, :run, :status, :digest)
|
|
75
|
-
- **Templates**: INDEX.md, LOG.md, DASHBOARD.md, config.yaml,
|
|
77
|
+
- **Templates**: INDEX.md, LOG.md, DASHBOARD.md, config.yaml, 5 page templates
|
|
76
78
|
generate_release_notes: false
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Instructions for AI agents working on this codebase.
|
|
4
|
+
|
|
5
|
+
## Project
|
|
6
|
+
|
|
7
|
+
`@zosmaai/pi-llm-wiki` — A pi package that implements Andrej Karpathy's LLM Wiki pattern as a self-maintaining knowledge base.
|
|
8
|
+
|
|
9
|
+
## Tech Stack
|
|
10
|
+
|
|
11
|
+
- TypeScript (ES2022, ESM)
|
|
12
|
+
- Vitest for testing
|
|
13
|
+
- Biome for linting/formatting
|
|
14
|
+
- GitHub Actions for CI
|
|
15
|
+
- npm for publishing
|
|
16
|
+
|
|
17
|
+
## File Layout
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
├── extensions/llm-wiki/ # TypeScript extension (10 tools + guardrails)
|
|
21
|
+
│ ├── index.ts # Entry point
|
|
22
|
+
│ └── lib/ # tools.ts, metadata.ts, guardrails.ts, utils.ts, source-packet.ts
|
|
23
|
+
├── skills/llm-wiki/ # SKILL.md + templates
|
|
24
|
+
├── prompts/ # 8 slash command templates
|
|
25
|
+
├── test/ # Vitest tests
|
|
26
|
+
├── docs/ # Documentation
|
|
27
|
+
└── scripts/ # release.js
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Conventions
|
|
31
|
+
|
|
32
|
+
- Use `node:fs/promises` for async file I/O, not sync
|
|
33
|
+
- Prefer small, pure functions in `lib/`
|
|
34
|
+
- Extension tools must have: name, label, description, promptSnippet, promptGuidelines, parameters (TypeBox), execute
|
|
35
|
+
- Guardrails block `raw/**` and `meta/**` edits at the tool_call hook level
|
|
36
|
+
- Metadata auto-rebuilds on `turn_end` after `wiki/**` edits
|
|
37
|
+
- Source IDs: `SRC-YYYY-MM-DD-NNN`
|
|
38
|
+
- Page filenames: `kebab-case.md`
|
|
39
|
+
- Wikilinks: folder-qualified, e.g. `[[concepts/retrieval-augmented-generation]]`
|
|
40
|
+
|
|
41
|
+
## Testing
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm test # run tests
|
|
45
|
+
npm run test:coverage # run with coverage
|
|
46
|
+
npm run typecheck # TypeScript check
|
|
47
|
+
npm run lint # biome check
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Release
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm run release:patch # or minor/major
|
|
54
|
+
npm run release:push # push tags
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Never edit `package.json` version manually — use the release script.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [0.2.0] - 2026-04-28
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **4-layer architecture**: raw/, wiki/, meta/, .wiki/ with explicit ownership rules
|
|
10
|
+
- **Source packets**: Structured capture with manifest.json, original/, extracted.md, attachments/
|
|
11
|
+
- **10 custom tools** (up from 5): wiki_bootstrap, wiki_capture_source, wiki_ingest, wiki_ensure_page, wiki_search, wiki_lint, wiki_status, wiki_rebuild_meta, wiki_log_event, wiki_watch
|
|
12
|
+
- **Auto-generated metadata**: registry.json, backlinks.json, index.md, log.md, events.jsonl
|
|
13
|
+
- **Guardrails**: Extension blocks direct edits to raw/** and meta/** via tool_call hook
|
|
14
|
+
- **Auto-rebuild**: Metadata rebuilds automatically after wiki/\*\* edits via turn_end hook
|
|
15
|
+
- **Batch ingest**: wiki_ingest returns source batches with extracted content previews
|
|
16
|
+
- **Improved lint**: Orphans, missing pages, contradictions, knowledge gaps with auto_fix option
|
|
17
|
+
- **Release scripts**: Automated semver bumping, changelog updates, git tagging
|
|
18
|
+
- **Coverage reporting**: v8 coverage in CI with lcov output
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Extension moved from single file to modular directory structure (extensions/llm-wiki/)
|
|
23
|
+
- Skill reduced from ~500 lines to ~150 lines — principles over mechanics
|
|
24
|
+
- Metadata is now machine-owned; LLM never edits INDEX.md or LOG.md manually
|
|
25
|
+
- Source IDs use stable format SRC-YYYY-MM-DD-NNN for rename-safe citations
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
|
|
29
|
+
- Manual INDEX.md/LOG.md maintenance from skill workflows
|
|
30
|
+
- Legacy flat raw/articles/ structure (replaced by structured source packets)
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Local Setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
git clone https://github.com/zosmaai/pi-llm-wiki.git
|
|
7
|
+
cd pi-llm-wiki
|
|
8
|
+
npm install
|
|
9
|
+
pi install ./
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Development
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm run test # run tests
|
|
16
|
+
npm run test:coverage # run tests with coverage report
|
|
17
|
+
npm run typecheck # TypeScript type check
|
|
18
|
+
npm run lint # biome lint check
|
|
19
|
+
npm run lint:fix # auto-fix lint issues
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Release Process
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm run release:patch # bump patch version
|
|
26
|
+
npm run release:minor # bump minor version
|
|
27
|
+
npm run release:major # bump major version
|
|
28
|
+
npm run release:push # push to origin with tags
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The release script:
|
|
32
|
+
|
|
33
|
+
1. Verifies clean git tree and `main` branch
|
|
34
|
+
2. Runs typecheck, lint, and tests
|
|
35
|
+
3. Bumps version in `package.json`
|
|
36
|
+
4. Updates `CHANGELOG.md`
|
|
37
|
+
5. Commits and tags
|
|
38
|
+
|
|
39
|
+
CI handles npm publish on tag push.
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zosmaai
|
|
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.
|