@mfittko/repo-wiki 0.2.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 (190) hide show
  1. package/.llmwiki/schema.md +107 -0
  2. package/AGENTS.md +42 -0
  3. package/CHANGELOG.md +91 -0
  4. package/LICENSE +21 -0
  5. package/README.md +254 -0
  6. package/dist/bin/repo-wiki.d.ts +2 -0
  7. package/dist/bin/repo-wiki.js +7 -0
  8. package/dist/bin/repo-wiki.js.map +1 -0
  9. package/dist/src/cli.d.ts +1 -0
  10. package/dist/src/cli.js +404 -0
  11. package/dist/src/cli.js.map +1 -0
  12. package/dist/src/compiler.d.ts +55 -0
  13. package/dist/src/compiler.js +2046 -0
  14. package/dist/src/compiler.js.map +1 -0
  15. package/dist/src/config.d.ts +63 -0
  16. package/dist/src/config.js +86 -0
  17. package/dist/src/config.js.map +1 -0
  18. package/dist/src/context-assembler.d.ts +68 -0
  19. package/dist/src/context-assembler.js +378 -0
  20. package/dist/src/context-assembler.js.map +1 -0
  21. package/dist/src/data-model-signals.d.ts +1 -0
  22. package/dist/src/data-model-signals.js +13 -0
  23. package/dist/src/data-model-signals.js.map +1 -0
  24. package/dist/src/docs-ingestor.d.ts +138 -0
  25. package/dist/src/docs-ingestor.js +844 -0
  26. package/dist/src/docs-ingestor.js.map +1 -0
  27. package/dist/src/docs-linter.d.ts +14 -0
  28. package/dist/src/docs-linter.js +164 -0
  29. package/dist/src/docs-linter.js.map +1 -0
  30. package/dist/src/docs-validation.d.ts +36 -0
  31. package/dist/src/docs-validation.js +297 -0
  32. package/dist/src/docs-validation.js.map +1 -0
  33. package/dist/src/extractors.d.ts +50 -0
  34. package/dist/src/extractors.js +2275 -0
  35. package/dist/src/extractors.js.map +1 -0
  36. package/dist/src/frontmatter.d.ts +46 -0
  37. package/dist/src/frontmatter.js +377 -0
  38. package/dist/src/frontmatter.js.map +1 -0
  39. package/dist/src/index.d.ts +26 -0
  40. package/dist/src/index.js +18 -0
  41. package/dist/src/index.js.map +1 -0
  42. package/dist/src/init.d.ts +12 -0
  43. package/dist/src/init.js +121 -0
  44. package/dist/src/init.js.map +1 -0
  45. package/dist/src/language.d.ts +2 -0
  46. package/dist/src/language.js +62 -0
  47. package/dist/src/language.js.map +1 -0
  48. package/dist/src/linter.d.ts +33 -0
  49. package/dist/src/linter.js +398 -0
  50. package/dist/src/linter.js.map +1 -0
  51. package/dist/src/llm-provider.d.ts +267 -0
  52. package/dist/src/llm-provider.js +474 -0
  53. package/dist/src/llm-provider.js.map +1 -0
  54. package/dist/src/page-ownership.d.ts +38 -0
  55. package/dist/src/page-ownership.js +96 -0
  56. package/dist/src/page-ownership.js.map +1 -0
  57. package/dist/src/planner.d.ts +55 -0
  58. package/dist/src/planner.js +422 -0
  59. package/dist/src/planner.js.map +1 -0
  60. package/dist/src/prompts.d.ts +103 -0
  61. package/dist/src/prompts.js +344 -0
  62. package/dist/src/prompts.js.map +1 -0
  63. package/dist/src/publisher.d.ts +68 -0
  64. package/dist/src/publisher.js +662 -0
  65. package/dist/src/publisher.js.map +1 -0
  66. package/dist/src/repository-analysis.d.ts +88 -0
  67. package/dist/src/repository-analysis.js +485 -0
  68. package/dist/src/repository-analysis.js.map +1 -0
  69. package/dist/src/scanner.d.ts +122 -0
  70. package/dist/src/scanner.js +309 -0
  71. package/dist/src/scanner.js.map +1 -0
  72. package/dist/src/search.d.ts +71 -0
  73. package/dist/src/search.js +410 -0
  74. package/dist/src/search.js.map +1 -0
  75. package/dist/src/secret-patterns.d.ts +3 -0
  76. package/dist/src/secret-patterns.js +14 -0
  77. package/dist/src/secret-patterns.js.map +1 -0
  78. package/dist/src/utils/args.d.ts +2 -0
  79. package/dist/src/utils/args.js +19 -0
  80. package/dist/src/utils/args.js.map +1 -0
  81. package/dist/src/utils/dotenv.d.ts +7 -0
  82. package/dist/src/utils/dotenv.js +73 -0
  83. package/dist/src/utils/dotenv.js.map +1 -0
  84. package/dist/src/utils/fs.d.ts +22 -0
  85. package/dist/src/utils/fs.js +83 -0
  86. package/dist/src/utils/fs.js.map +1 -0
  87. package/dist/src/utils/git.d.ts +13 -0
  88. package/dist/src/utils/git.js +39 -0
  89. package/dist/src/utils/git.js.map +1 -0
  90. package/dist/src/wiki-graph.d.ts +74 -0
  91. package/dist/src/wiki-graph.js +335 -0
  92. package/dist/src/wiki-graph.js.map +1 -0
  93. package/dist/src/wiki-patch.d.ts +152 -0
  94. package/dist/src/wiki-patch.js +489 -0
  95. package/dist/src/wiki-patch.js.map +1 -0
  96. package/dist/src/wiki-query.d.ts +63 -0
  97. package/dist/src/wiki-query.js +255 -0
  98. package/dist/src/wiki-query.js.map +1 -0
  99. package/dist/test/cli.test.d.ts +1 -0
  100. package/dist/test/cli.test.js +514 -0
  101. package/dist/test/cli.test.js.map +1 -0
  102. package/dist/test/compiler-eval.test.d.ts +1 -0
  103. package/dist/test/compiler-eval.test.js +234 -0
  104. package/dist/test/compiler-eval.test.js.map +1 -0
  105. package/dist/test/compiler.test.d.ts +1 -0
  106. package/dist/test/compiler.test.js +2537 -0
  107. package/dist/test/compiler.test.js.map +1 -0
  108. package/dist/test/context-assembler.test.d.ts +1 -0
  109. package/dist/test/context-assembler.test.js +379 -0
  110. package/dist/test/context-assembler.test.js.map +1 -0
  111. package/dist/test/docs-linter.test.d.ts +1 -0
  112. package/dist/test/docs-linter.test.js +900 -0
  113. package/dist/test/docs-linter.test.js.map +1 -0
  114. package/dist/test/dotenv.test.d.ts +1 -0
  115. package/dist/test/dotenv.test.js +77 -0
  116. package/dist/test/dotenv.test.js.map +1 -0
  117. package/dist/test/extractors-go.test.d.ts +1 -0
  118. package/dist/test/extractors-go.test.js +393 -0
  119. package/dist/test/extractors-go.test.js.map +1 -0
  120. package/dist/test/extractors-rust.test.d.ts +1 -0
  121. package/dist/test/extractors-rust.test.js +219 -0
  122. package/dist/test/extractors-rust.test.js.map +1 -0
  123. package/dist/test/extractors-utils.test.d.ts +1 -0
  124. package/dist/test/extractors-utils.test.js +786 -0
  125. package/dist/test/extractors-utils.test.js.map +1 -0
  126. package/dist/test/fixtures/compiler-e2e/basic-node-service/repo/infra/deploy.d.ts +1 -0
  127. package/dist/test/fixtures/compiler-e2e/basic-node-service/repo/infra/deploy.js +4 -0
  128. package/dist/test/fixtures/compiler-e2e/basic-node-service/repo/infra/deploy.js.map +1 -0
  129. package/dist/test/frontmatter.test.d.ts +1 -0
  130. package/dist/test/frontmatter.test.js +287 -0
  131. package/dist/test/frontmatter.test.js.map +1 -0
  132. package/dist/test/init-planner.test.d.ts +1 -0
  133. package/dist/test/init-planner.test.js +688 -0
  134. package/dist/test/init-planner.test.js.map +1 -0
  135. package/dist/test/linter.test.d.ts +1 -0
  136. package/dist/test/linter.test.js +426 -0
  137. package/dist/test/linter.test.js.map +1 -0
  138. package/dist/test/llm-provider.test.d.ts +1 -0
  139. package/dist/test/llm-provider.test.js +783 -0
  140. package/dist/test/llm-provider.test.js.map +1 -0
  141. package/dist/test/page-ownership.test.d.ts +1 -0
  142. package/dist/test/page-ownership.test.js +247 -0
  143. package/dist/test/page-ownership.test.js.map +1 -0
  144. package/dist/test/publisher.test.d.ts +1 -0
  145. package/dist/test/publisher.test.js +1297 -0
  146. package/dist/test/publisher.test.js.map +1 -0
  147. package/dist/test/repository-analysis.test.d.ts +1 -0
  148. package/dist/test/repository-analysis.test.js +182 -0
  149. package/dist/test/repository-analysis.test.js.map +1 -0
  150. package/dist/test/run-compiled-tests.d.ts +1 -0
  151. package/dist/test/run-compiled-tests.js +48 -0
  152. package/dist/test/run-compiled-tests.js.map +1 -0
  153. package/dist/test/scanner.test.d.ts +1 -0
  154. package/dist/test/scanner.test.js +551 -0
  155. package/dist/test/scanner.test.js.map +1 -0
  156. package/dist/test/search.test.d.ts +1 -0
  157. package/dist/test/search.test.js +92 -0
  158. package/dist/test/search.test.js.map +1 -0
  159. package/dist/test/update-changelog.test.d.ts +1 -0
  160. package/dist/test/update-changelog.test.js +125 -0
  161. package/dist/test/update-changelog.test.js.map +1 -0
  162. package/dist/test/wiki-graph.test.d.ts +1 -0
  163. package/dist/test/wiki-graph.test.js +164 -0
  164. package/dist/test/wiki-graph.test.js.map +1 -0
  165. package/dist/test/wiki-patch.test.d.ts +1 -0
  166. package/dist/test/wiki-patch.test.js +610 -0
  167. package/dist/test/wiki-patch.test.js.map +1 -0
  168. package/dist/test/wiki-query.test.d.ts +1 -0
  169. package/dist/test/wiki-query.test.js +163 -0
  170. package/dist/test/wiki-query.test.js.map +1 -0
  171. package/docs/PLAN.md +993 -0
  172. package/docs/WHY.md +61 -0
  173. package/docs/plans/agent-integration.md +85 -0
  174. package/docs/plans/ci-publishing.md +111 -0
  175. package/docs/plans/doc-validation.md +92 -0
  176. package/docs/plans/github-action.md +113 -0
  177. package/docs/plans/incremental-mode.md +98 -0
  178. package/docs/plans/karpathy-llm-wiki-alignment.md +84 -0
  179. package/docs/plans/llm-compiler.md +160 -0
  180. package/docs/plans/production-scanner.md +104 -0
  181. package/docs/plans/query-and-file-back.md +103 -0
  182. package/docs/plans/search-index.md +118 -0
  183. package/docs/plans/trust-hardening.md +74 -0
  184. package/docs/plans/wiki-graph.md +183 -0
  185. package/docs/plans/wiki-health.md +76 -0
  186. package/package.json +83 -0
  187. package/prompts/compiler.md +16 -0
  188. package/prompts/lint.md +18 -0
  189. package/prompts/page-templates.md +25 -0
  190. package/skills/repo-wiki-cli/SKILL.md +139 -0
package/docs/WHY.md ADDED
@@ -0,0 +1,61 @@
1
+ # Why repo-wiki exists
2
+
3
+ `repo-wiki` applies the LLM Wiki pattern to software repositories: compile repository knowledge into a durable, interlinked wiki instead of asking an LLM to reconstruct the same context from raw files on every question.
4
+
5
+ This project is inspired by Andrej Karpathy's LLM Wiki concept note. This page is a repo-wiki-specific summary written in this project's own words, not a copy of the external note. For the original source, see:
6
+
7
+ - Andrej Karpathy, "LLM Wiki": <https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f>
8
+
9
+ ## The product lens
10
+
11
+ Many repository-assistance workflows are ephemeral. A developer or coding agent searches code, reads scattered docs, reconstructs architecture, answers one question, and then loses most of that synthesis to chat history or local context. The next person or agent repeats much of the work.
12
+
13
+ `repo-wiki` turns repeated investigation into a maintained artifact:
14
+
15
+ - the Git repository at a pinned commit remains the source of truth;
16
+ - generated wiki pages become the compiled knowledge layer;
17
+ - `.llmwiki/schema.md`, `.llmwiki/config.json`, prompts, and agent pointers define how the wiki should be maintained;
18
+ - `Index.md` routes humans and agents to relevant pages;
19
+ - `Log.md` records ingests, compiles, lint passes, publication events, and future query/file-back events.
20
+
21
+ The generated wiki does not replace source-level investigation. It is a first navigation layer that helps humans and coding agents start with repository-shaped context, then verify material claims against code, tests, configuration, and validated documentation.
22
+
23
+ ## Why a maintained wiki instead of only search or RAG
24
+
25
+ Search and retrieval-augmented generation are useful for finding relevant fragments, but they usually perform synthesis at query time. That makes important context easy to lose:
26
+
27
+ - architecture summaries are rebuilt repeatedly;
28
+ - contradictions between documentation and code may be noticed once and forgotten;
29
+ - useful answers remain in chat instead of becoming repository knowledge;
30
+ - new agents begin from raw files rather than accumulated understanding.
31
+
32
+ A maintained wiki lets synthesis compound. Module pages, architecture pages, documentation-debt reports, open questions, and future filed-back investigations can be updated as the repository changes. The result is a durable knowledge base that remains inspectable in ordinary markdown and publishable through GitHub Wiki.
33
+
34
+ ## What repo-wiki adds
35
+
36
+ `repo-wiki` narrows the general LLM Wiki idea to the software-repository domain:
37
+
38
+ - deterministic scanning and planning over repository files;
39
+ - documentation ingestion with validation and debt reporting;
40
+ - generated GitHub Wiki pages under `.llmwiki/wiki`;
41
+ - lint gates for required pages, links, source metadata, and secret-like content;
42
+ - a publish path to `OWNER/REPO.wiki.git`;
43
+ - a package and CLI intended to work for this repository and for external repositories.
44
+
45
+ The long-term goal is repository memory infrastructure: developers understand unfamiliar code faster, agents use the wiki before diving into source, maintainers can see documentation drift, and high-value repository answers can become durable wiki pages with provenance.
46
+
47
+ ## Authority model
48
+
49
+ The generated wiki is derived. When evidence conflicts, `repo-wiki` treats source authority in this order:
50
+
51
+ 1. code at the pinned commit;
52
+ 2. tests;
53
+ 3. CI, build, and runtime configuration;
54
+ 4. generated schemas, route maps, and migrations;
55
+ 5. markdown documentation as secondary evidence;
56
+ 6. issues, PRs, and comments as contextual evidence only when explicitly ingested;
57
+ 7. existing generated wiki pages as derived evidence.
58
+
59
+ This is why `repo-wiki` includes linting and documentation-debt reporting: the product should compile useful knowledge without turning stale docs or unsupported LLM output into confident generated fiction.
60
+
61
+ For the full roadmap, layer mapping, and implementation plan, see [PLAN.md](./PLAN.md).
@@ -0,0 +1,85 @@
1
+ # Epic: Agent Integration
2
+
3
+ ## Summary
4
+
5
+ Make the generated wiki maximally useful for coding agents by producing optimized context packs, generating agent pointer files, and optionally exposing a query interface or MCP endpoint.
6
+
7
+ ## Architecture
8
+
9
+ ```mermaid
10
+ flowchart TD
11
+ Wiki[Generated Wiki Pages] --> Pack[Agent-Context-Pack Generator]
12
+ Wiki --> Pointer[Agent Pointer Generator]
13
+ Wiki --> Index[Search Index Builder]
14
+ Pack --> AgentContext[Agent-Context-Pack.md]
15
+ Pointer --> AgentsFile[AGENTS.md / AGENTS.repo-wiki.md]
16
+ Index --> Query[repo-wiki query CLI]
17
+ Index --> MCP[MCP Endpoint]
18
+ AgentContext --> Agent[Coding Agent]
19
+ AgentsFile --> Agent
20
+ Query --> Agent
21
+ MCP --> Agent
22
+ ```
23
+
24
+ ```mermaid
25
+ flowchart LR
26
+ subgraph Context Pack Contents
27
+ Arch[Architecture Summary]
28
+ ModMap[Module Map]
29
+ Conv[Key Conventions]
30
+ Pitfalls[Known Pitfalls]
31
+ Routes[Task Routing Table]
32
+ end
33
+ subgraph Agent Reads
34
+ First[1. Agent-Context-Pack]
35
+ Then[2. Relevant Module Page]
36
+ Finally[3. Cross-cutting Pages]
37
+ end
38
+ Arch --> First
39
+ ModMap --> First
40
+ Conv --> First
41
+ Pitfalls --> First
42
+ Routes --> Then
43
+ ```
44
+
45
+ ```mermaid
46
+ sequenceDiagram
47
+ participant Agent as Coding Agent
48
+ participant MCP as MCP Endpoint
49
+ participant Graph as Wiki Graph
50
+ participant Wiki as Wiki Pages
51
+
52
+ Agent->>MCP: query("how does auth work?")
53
+ MCP->>Graph: find related nodes
54
+ Graph-->>MCP: [Auth-Module, Security-Page, API-Routes]
55
+ MCP->>Wiki: fetch page content
56
+ Wiki-->>MCP: page markdown
57
+ MCP-->>Agent: synthesized answer + sources
58
+ ```
59
+
60
+ ## Key Deliverables
61
+
62
+ - Generate `AGENTS.md` or `AGENTS.repo-wiki.md` pointers in target repos
63
+ - Generate `Agent-Context-Pack.md` optimized for coding agent consumption
64
+ - Context pack includes: architecture summary, module map, key conventions, known pitfalls
65
+ - Optional `repo-wiki query` command for targeted wiki lookups
66
+ - Optional MCP (Model Context Protocol) endpoint for agent tool use
67
+ - Optional local search index over generated wiki
68
+
69
+ ## Success Criteria
70
+
71
+ - A coding agent reading Agent-Context-Pack.md gains actionable project understanding
72
+ - Agent pointer files direct agents to the wiki without manual configuration
73
+ - Query interface (if implemented) returns relevant wiki content for natural-language questions
74
+
75
+ ## Dependencies
76
+
77
+ - Upstream: LLM compiler (quality wiki content), production scanner (rich source data)
78
+ - Downstream: None (terminal epic)
79
+
80
+ ## Open Questions
81
+
82
+ - What format should Agent-Context-Pack.md use for maximum agent utility?
83
+ - Should the MCP endpoint serve raw wiki pages or synthesized answers?
84
+ - How to keep agent pointers in sync with wiki structure changes?
85
+ - Should query use embedding search, keyword search, or both?
@@ -0,0 +1,111 @@
1
+ # Epic: CI & Publishing
2
+
3
+ ## Summary
4
+
5
+ Production-ready GitHub Actions workflows and publishing infrastructure that safely pushes generated wiki content, enforces security policies, and supports bootstrap, reconcile, and incremental post-merge flows.
6
+
7
+ ## Architecture
8
+
9
+ ```mermaid
10
+ flowchart TD
11
+ Trigger{Trigger} --> |push to main| Incremental[Incremental Mode]
12
+ Trigger --> |workflow_dispatch| Bootstrap[Bootstrap Mode]
13
+ Trigger --> |schedule| Refresh[Full Refresh]
14
+
15
+ Incremental --> Checkout[Checkout Source]
16
+ Bootstrap --> Checkout
17
+ Refresh --> Checkout
18
+
19
+ Checkout --> Install[npm ci]
20
+ Install --> Test[npm test]
21
+ Test --> FetchWiki[Fetch Existing Wiki State]
22
+ FetchWiki --> Generate[repo-wiki run]
23
+ Generate --> DiffReport[Generate Reconcile Diff]
24
+ DiffReport --> SecGate{Secret Gate}
25
+ SecGate -->|secrets detected| Block[Block & Alert]
26
+ SecGate -->|clean| LintGate{Lint Gate}
27
+ LintGate -->|fail| Block
28
+ LintGate -->|pass| ReviewGate{Review Required?}
29
+ ReviewGate -->|sensitive pages or merge conflicts| HumanReview[Human Review]
30
+ ReviewGate -->|no| Publish[Push to Wiki]
31
+ HumanReview -->|approved| Publish
32
+ Publish --> Notify[Status Notification]
33
+ ```
34
+
35
+ ```mermaid
36
+ flowchart LR
37
+ subgraph Token Management
38
+ App[GitHub App]
39
+ PAT[Fine-grained PAT]
40
+ OIDC[OIDC Token]
41
+ end
42
+ subgraph Publish Strategies
43
+ Direct[Direct Push]
44
+ PR[Wiki PR]
45
+ Atomic[Atomic All-or-Nothing]
46
+ end
47
+ App --> Direct
48
+ PAT --> Direct
49
+ App --> PR
50
+ OIDC --> Atomic
51
+ ```
52
+
53
+ ```mermaid
54
+ sequenceDiagram
55
+ participant GH as GitHub Actions
56
+ participant Wiki as repo-wiki CLI
57
+ participant Lint as Lint Gates
58
+ participant Remote as REPO.wiki.git
59
+
60
+ GH->>Wiki: repo-wiki run --mode incremental
61
+ Wiki-->>GH: generated pages
62
+ GH->>Lint: validate (secrets, links, structure)
63
+ Lint-->>GH: pass/fail
64
+ alt pass
65
+ GH->>Remote: git push
66
+ Remote-->>GH: success
67
+ else fail
68
+ GH->>GH: upload artifact, notify
69
+ end
70
+ ```
71
+
72
+ ## Key Deliverables
73
+
74
+ - GitHub Actions workflow for wiki generation on push to main
75
+ - GitHub Actions workflow for manual/dispatch wiki bootstrap
76
+ - Pull request and push verification workflow that runs the TypeScript build and test path before publication-oriented jobs
77
+ - Reconcile-mode workflow for repositories with an existing wiki
78
+ - Token management (GitHub App or fine-grained PAT)
79
+ - Security gate: block publish on secret-like content detection
80
+ - Optional human review gate for sensitive pages (auth, billing, deployment, security)
81
+ - PR-based wiki publishing option (wiki PR instead of direct push)
82
+ - Dry-run diff artifact showing created, updated, preserved, and deleted wiki pages
83
+ - Safe deletion policy that only removes pages owned by repo-wiki
84
+ - Artifact retention for unpublished wiki builds
85
+ - Node dependency caching and TypeScript incremental build caching in CI
86
+ - Status checks and notifications
87
+
88
+ ## Success Criteria
89
+
90
+ - Wiki auto-updates on merge to main with no manual intervention
91
+ - Pull requests and protected branches can target a build-and-test status check for the canonical `npm run check` path
92
+ - Secrets never reach published wiki pages
93
+ - Untrusted PRs cannot trigger wiki publication
94
+ - Failed lint gates block publication
95
+ - Existing human-owned wiki content is preserved during reconcile publishes
96
+ - Publish logs make page creation, update, preserve, and delete actions auditable
97
+ - Clear audit trail of what was published and when
98
+
99
+ ## Dependencies
100
+
101
+ - Upstream: Incremental mode (post-merge updates), all lint gates
102
+ - Downstream: None (terminal epic)
103
+
104
+ ## Open Questions
105
+
106
+ - Should the publisher open a PR against the wiki repo instead of pushing directly?
107
+ - How to handle wiki publication failures (retry, alert, rollback)?
108
+ - Should wiki publication be atomic (all pages or nothing) or incremental?
109
+ - How to manage wiki git history (squash or preserve per-page commits)?
110
+ - Should reconcile mode require an explicit opt-in flag before first publish to an existing wiki?
111
+ - How should the workflow surface preserved human sections and blocked deletes in artifacts?
@@ -0,0 +1,92 @@
1
+ # Epic: Documentation Validation
2
+
3
+ ## Summary
4
+
5
+ Implement deep documentation validators that go beyond the current scaffold's conservative checks, enabling reliable detection of stale, contradicted, and unvalidated documentation claims.
6
+
7
+ ## Architecture
8
+
9
+ ```mermaid
10
+ flowchart TD
11
+ Docs[Markdown Documentation] --> Extract[Claim Extraction]
12
+ Extract --> Commands[Commands & Scripts]
13
+ Extract --> EnvVars[Environment Variables]
14
+ Extract --> FilePaths[File References]
15
+ Extract --> Routes[API Routes]
16
+ Extract --> ADRs[ADR Decisions]
17
+
18
+ Commands --> V1[Script Validator]
19
+ EnvVars --> V2[Env Var Validator]
20
+ FilePaths --> V3[File Path Validator]
21
+ Routes --> V4[Route Validator]
22
+ ADRs --> V5[ADR Validator]
23
+
24
+ PkgJson[package.json] --> V1
25
+ CI[CI Workflows] --> V1
26
+ Config[Config/Schema Files] --> V2
27
+ Code[Source Code] --> V2
28
+ Tree[Repo File Tree] --> V3
29
+ Scanner[Route Extractors] --> V4
30
+ GitLog[Git History] --> V5
31
+
32
+ V1 --> Status{Validation Status}
33
+ V2 --> Status
34
+ V3 --> Status
35
+ V4 --> Status
36
+ V5 --> Status
37
+
38
+ Status --> Validated[Validated ✓]
39
+ Status --> Unvalidated[Unvalidated ?]
40
+ Status --> Stale[Stale ⚠]
41
+ Status --> Contradicted[Contradicted ✗]
42
+ ```
43
+
44
+ ```mermaid
45
+ flowchart LR
46
+ subgraph Strictness Levels
47
+ Strict[strict: errors block publish]
48
+ Standard[standard: warnings + errors]
49
+ Lenient[lenient: warnings only]
50
+ Off[off: skip validation]
51
+ end
52
+ subgraph Output
53
+ Report[Documentation-Debt-Report.md]
54
+ OpenQ[Open-Questions.md]
55
+ LintResult[Lint exit code]
56
+ end
57
+ Strict --> LintResult
58
+ Standard --> Report
59
+ Standard --> OpenQ
60
+ Lenient --> Report
61
+ ```
62
+
63
+ ## Key Deliverables
64
+
65
+ - Package script validation against `package.json`
66
+ - Command validation against Makefiles, task runners, and CI workflows
67
+ - Route validation against framework-specific route extractors
68
+ - Environment variable validation against config/schema/code usage
69
+ - File reference validation against the repository tree
70
+ - ADR recency and supersession detection
71
+ - Configurable validation strictness levels
72
+ - Rich Documentation-Debt-Report generation with actionable items
73
+
74
+ ## Success Criteria
75
+
76
+ - Commands mentioned in docs are verified against actual scripts/CI
77
+ - Environment variables in docs are cross-referenced with code usage
78
+ - File paths in docs are validated against the repo tree
79
+ - ADRs are flagged when superseded or older than threshold
80
+ - False positive rate is low enough that teams don't disable validation
81
+
82
+ ## Dependencies
83
+
84
+ - Upstream: Production scanner (source cards with scripts, routes, env vars)
85
+ - Downstream: LLM compiler (validated doc cards influence wiki content)
86
+
87
+ ## Open Questions
88
+
89
+ - How to handle commands that are valid but not in package.json (e.g., global CLIs)?
90
+ - Should validation run against CI workflow definitions or actual CI runs?
91
+ - How to detect ADR supersession without explicit metadata?
92
+ - What false-positive rate is acceptable before teams lose trust?
@@ -0,0 +1,113 @@
1
+ # Epic: GitHub Action
2
+
3
+ ## Summary
4
+
5
+ Provide a reusable GitHub Action that wraps the `repo-wiki` CLI for CI/CD workflows. The action should work without publish credentials (producing local wiki artifacts only), and require explicit credentials and a safe event context for any publish step. Support PR-oriented diff output as a review artifact and enforce the security model that prevents publishing from untrusted pull requests.
6
+
7
+ ## Architecture
8
+
9
+ ```mermaid
10
+ flowchart TD
11
+ Trigger["workflow_dispatch or push to main"] --> Checkout["Checkout source"]
12
+ Checkout --> Install["npm ci / npx repo-wiki"]
13
+ Install --> Run["repo-wiki run --mode bootstrap or incremental"]
14
+ Run --> Artifact["Upload local wiki as workflow artifact"]
15
+ Run --> Policy{"Publish credentials<br/>configured?"}
16
+ Policy -->|no| Done["Keep local wiki / no publish"]
17
+ Policy -->|yes| SafeEvent{"Safe event context?<br/>(push to main, not PR from fork)"}
18
+ SafeEvent -->|no| Skip["Skip publish / warn"]
19
+ SafeEvent -->|yes| Publish["repo-wiki publish --target github-wiki or github-pages"]
20
+ ```
21
+
22
+ ```mermaid
23
+ flowchart LR
24
+ subgraph Action inputs
25
+ Repo["repo (default: .)"]
26
+ Mode["mode (bootstrap or incremental)"]
27
+ Target["publish-target (github-wiki, github-pages, none)"]
28
+ Token["token (GitHub App or PAT)"]
29
+ Remote["wiki-remote"]
30
+ DryRun["dry-run (true/false)"]
31
+ end
32
+ ```
33
+
34
+ ```mermaid
35
+ sequenceDiagram
36
+ participant PR
37
+ participant Action
38
+ participant Wiki
39
+
40
+ PR->>Action: pull_request event (fork)
41
+ Action->>Action: Run scan + compile
42
+ Action->>PR: Post diff comment (pages that would change)
43
+ Action-->>Wiki: No publish (untrusted event)
44
+
45
+ Note over Action, Wiki: Only push to main triggers publish
46
+ ```
47
+
48
+ ## Key Deliverables
49
+
50
+ - Reusable composite or JavaScript GitHub Action published to the Marketplace or usable via `uses: owner/repo-wiki/.github/actions/wiki@main`.
51
+ - Inputs: `repo`, `mode`, `publish-target`, `token`, `wiki-remote`, `pages-branch`, `pages-path`, `dry-run`.
52
+ - Outputs: `wiki-path` (local artifact path), `pages-changed` (count), `lint-errors` (count).
53
+ - Upload local wiki directory as a workflow artifact regardless of publish step.
54
+ - PR diff comment showing wiki pages that would change (uses `repo-wiki diff`).
55
+ - Publish step runs only on safe event contexts (push to main/default branch, not PRs from forks).
56
+ - Token never exposed in logs or generated wiki pages.
57
+ - Documentation: minimal workflow snippet for adopt-in-5-minutes experience.
58
+
59
+ ## Success Criteria
60
+
61
+ - A consumer repo can add `repo-wiki` with a workflow snippet under 20 lines.
62
+ - The action works without publish credentials (dry-run / artifact only).
63
+ - Publishing requires explicit credentials and safe event context (not a fork PR).
64
+ - PR diff comment posts the list of pages that would change without publishing.
65
+ - Action inputs are validated before any state-changing step.
66
+
67
+ ## Acceptance Criteria (from PLAN.md)
68
+
69
+ - A consumer repo can add repo-wiki with a short workflow snippet.
70
+ - The action works without publish credentials.
71
+ - Publishing requires explicit credentials and safe event context.
72
+
73
+ ## Example Workflow
74
+
75
+ ```yaml
76
+ name: Wiki
77
+ on:
78
+ push:
79
+ branches: [main]
80
+ pull_request:
81
+
82
+ jobs:
83
+ wiki:
84
+ runs-on: ubuntu-latest
85
+ permissions:
86
+ contents: write
87
+ pull-requests: write
88
+ steps:
89
+ - uses: actions/checkout@v4
90
+ - uses: owner/repo-wiki/.github/actions/wiki@main
91
+ with:
92
+ mode: bootstrap
93
+ publish-target: ${{ github.event_name == 'push' && 'github-wiki' || 'none' }}
94
+ token: ${{ secrets.GITHUB_TOKEN }}
95
+ ```
96
+
97
+ ## Security Policy
98
+
99
+ - Do not publish from `pull_request` events originating from forks.
100
+ - Use a dedicated GitHub App token or fine-grained PAT for wiki or Pages push.
101
+ - Never expose tokens in generated wiki pages, scan artifacts, logs, or publish summaries.
102
+ - Fail publication on secret-like content (inherits trust-hardening policy).
103
+
104
+ ## Dependencies
105
+
106
+ - Upstream: all CLI commands, trust hardening, publisher.
107
+ - Downstream: adoption and developer experience (this is the primary adoption surface).
108
+
109
+ ## Open Questions
110
+
111
+ - Should the action be a composite action (shell steps) or a JavaScript action?
112
+ - Should PR diff comments be posted as new comments or as a check annotation?
113
+ - Should `repo-wiki diff` be a separate command or an option on `run`?
@@ -0,0 +1,98 @@
1
+ # Epic: Incremental Mode
2
+
3
+ ## Summary
4
+
5
+ Implement diff-based wiki maintenance that scans only changed files, identifies affected wiki pages, reconciles those pages with the current remote wiki state, and produces targeted page patches rather than full regeneration.
6
+
7
+ ## Architecture
8
+
9
+ ```mermaid
10
+ flowchart TD
11
+ PrevCommit[Previous Compiled Commit] --> Diff[git diff base..head]
12
+ HeadCommit[Current Commit] --> Diff
13
+ ExistingWiki[Current Wiki Checkout] --> Ownership[Generated Page Ownership Map]
14
+ Diff --> Changed[Changed Files]
15
+ Changed --> CardMap[Source Card Mapping]
16
+ CardMap --> Hierarchy[Bounded Hierarchy Propagation]
17
+ CardMap --> ImportGraph[Import Graph Lookup]
18
+ ImportGraph --> Semantic[Semantic Propagation]
19
+ Hierarchy --> AffectedCards[Affected Source Cards]
20
+ Semantic --> AffectedCards
21
+ AffectedCards --> PageMap[Page Frontmatter Mapping]
22
+ PageMap --> AffectedPages[Affected Wiki Pages]
23
+ Ownership --> AffectedPages
24
+ AffectedPages --> Patch[Targeted Page Patching]
25
+ Patch --> Reconcile[Merge with Existing Wiki Pages]
26
+ Reconcile --> CrossLink[Cross-link Validation]
27
+ CrossLink --> DebtReport[Debt Report Update]
28
+ DebtReport --> Lint[Lint Gates]
29
+ Lint -->|pass| Publish[Safe Publish]
30
+ Lint -->|fail| Block[Block & Report]
31
+ ```
32
+
33
+ ```mermaid
34
+ flowchart LR
35
+ subgraph Change Propagation
36
+ File[Changed File] --> DirectPage[Direct Page]
37
+ File --> Importer[Importing Modules]
38
+ Importer --> TransitivePage[Transitive Pages]
39
+ File --> Test[Related Tests]
40
+ Test --> TestPage[Testing Strategy Page]
41
+ end
42
+ ```
43
+
44
+ ```mermaid
45
+ stateDiagram-v2
46
+ [*] --> DetectChanges
47
+ DetectChanges --> MapToCards
48
+ MapToCards --> FindAffectedPages
49
+ FindAffectedPages --> PatchPages
50
+ PatchPages --> ValidateCrossLinks
51
+ ValidateCrossLinks --> RunLint
52
+ RunLint --> Publish: pass
53
+ RunLint --> FullBootstrap: too many changes
54
+ Publish --> [*]
55
+ FullBootstrap --> [*]
56
+ ```
57
+
58
+ ## Key Deliverables
59
+
60
+ - Store previous compiled commit reference
61
+ - Git diff computation (base..head changed files)
62
+ - Changed-file to source-card mapping
63
+ - Affected-page identification via import graph and page frontmatter
64
+ - Bounded hierarchy propagation from touched files to parent aggregate pages whose subtree summaries, page membership, public APIs, runtime behavior, or claims are affected
65
+ - Semantic propagation to cross-cutting pages when dependency, test, route, config, security, data-model, documentation, or similar signals change
66
+ - Targeted page patching (update only affected sections)
67
+ - Existing wiki checkout and page ownership manifest loading
68
+ - Safe reconciliation of mixed human/generated pages during incremental runs
69
+ - Safe deletion of obsolete generated pages that are no longer planned
70
+ - Rename handling for generated pages with stable page identities
71
+ - Re-run cross-link validation after patching
72
+ - Re-run documentation debt report for affected docs
73
+ - Safe publish after lint gates pass
74
+
75
+ ## Success Criteria
76
+
77
+ - Incremental run touches only pages affected by the diff, bounded hierarchy propagation, or semantic propagation rules
78
+ - Untouched LLM-enriched pages remain byte-stable and do not incur model calls
79
+ - Cross-links remain valid after partial updates
80
+ - Incremental output matches what a full bootstrap would produce for affected pages
81
+ - Untouched human-owned wiki pages remain byte-stable across incremental runs
82
+ - Obsolete generated pages are removed without deleting human-owned content
83
+ - Runtime scales with change size, not repository size
84
+
85
+ ## Dependencies
86
+
87
+ - Upstream: Production scanner (import graph, affected-page graph), LLM compiler (page patching)
88
+ - Downstream: CI publishing (post-merge incremental runs)
89
+
90
+ ## Open Questions
91
+
92
+ - How to handle renames and moved files?
93
+ - What triggers a full re-bootstrap vs incremental patch?
94
+ - Should incremental mode track page staleness independently?
95
+ - How to handle transitive dependency changes (A imports B, B changes)?
96
+ - What thresholds should escalate from bounded propagation to full bootstrap, such as broad renames, large dependency graph shifts, or many parent aggregate pages changing?
97
+ - Where should generated-page ownership state live: frontmatter, sidecar manifest, or graph store?
98
+ - When should reconcile mode escalate to manual review instead of auto-merging?
@@ -0,0 +1,84 @@
1
+ # Epic: Karpathy LLM Wiki Alignment
2
+
3
+ ## Summary
4
+
5
+ Make `repo-wiki` a faithful software-repository implementation of Karpathy's LLM Wiki pattern: compile repository knowledge once into a durable, source-grounded wiki artifact that compounds over time, treat the LLM as a wiki maintainer rather than a one-shot summarizer, and validate generated content before it can influence the wiki or be published.
6
+
7
+ ## Operating Model
8
+
9
+ ```mermaid
10
+ flowchart LR
11
+ subgraph Layers
12
+ Raw["Raw sources<br/>(Git at pinned commit)"]
13
+ Wiki["Wiki artifact<br/>(.llmwiki/wiki)"]
14
+ Schema["Schema<br/>(config, prompts, ownership)"]
15
+ end
16
+ subgraph Operations
17
+ Ingest["Ingest<br/>scan → plan → lint-docs → compile → lint"]
18
+ Query["Query<br/>read wiki first, verify in source"]
19
+ Lint["Lint<br/>health, orphans, stale, contradictions"]
20
+ end
21
+ Raw --> Ingest
22
+ Schema --> Ingest
23
+ Ingest --> Wiki
24
+ Wiki --> Query
25
+ Query --> FileBack["Filed-back pages"]
26
+ FileBack --> Wiki
27
+ Wiki --> Lint
28
+ Lint --> Wiki
29
+ ```
30
+
31
+ ## Architecture
32
+
33
+ ```mermaid
34
+ flowchart TD
35
+ Source["Source at pinned commit"] --> Scanner
36
+ Docs["Markdown docs"] --> DocsLint["Docs linter"]
37
+ Scanner --> Cards["Source + doc cards"]
38
+ DocsLint --> Cards
39
+ Cards --> Planner
40
+ Planner --> Compiler["LLM or deterministic compiler"]
41
+ Compiler --> PatchGate["Structured patch gate"]
42
+ PatchGate --> WikiPages["Wiki pages<br/>(frontmatter + citations)"]
43
+ WikiPages --> Index["Index.md (agent routing)"]
44
+ WikiPages --> Log["Log.md (operation log)"]
45
+ WikiPages --> HealthLint["Health linter"]
46
+ HealthLint --> Publisher
47
+ ```
48
+
49
+ ## Key Deliverables
50
+
51
+ - `Index.md` and `Log.md` as first-class, parseable operating surfaces.
52
+ - Deterministic log entries for every ingest, compile, lint, query, and publish operation appended to `Log.md`.
53
+ - Wiki page frontmatter with `kind`, `source_commit`, `compiled_at`, `source_paths`, `page_state`, and confidence metadata.
54
+ - Source authority model enforced: code at pinned commit > tests > CI/config > docs > issues.
55
+ - LLM output treated as an untrusted patch that must pass lint and citation gates before writing.
56
+ - Query-and-file-back workflow that allows durable answers to become new wiki pages with provenance.
57
+ - Published wiki as the flagship demo for this repository.
58
+
59
+ ## Success Criteria
60
+
61
+ - Agents can navigate the wiki without source-file inspection for common questions.
62
+ - `grep '^## \[' .llmwiki/wiki/Log.md | tail -5` returns the last five operations with type and commit.
63
+ - Re-running compilation with the same inputs does not produce noisy index or log churn.
64
+ - Every generated page cites source paths for material claims.
65
+ - The published wiki for this repository is publicly inspectable.
66
+
67
+ ## Acceptance Criteria (from PLAN.md)
68
+
69
+ - Agents can read `Index.md` first to route to relevant pages.
70
+ - Generated pages include frontmatter suitable for Obsidian, Dataview, GitHub Wiki navigation, and future search.
71
+ - Graph metadata powers both navigation and incremental maintenance.
72
+ - LLM output treated as untrusted until it passes structured patch validation and lint.
73
+ - This repository's own generated wiki is published as the canonical demo.
74
+
75
+ ## Dependencies
76
+
77
+ - Upstream: deterministic compiler, wiki linter, publisher.
78
+ - Downstream: all epics — this is the product framing that shapes scope decisions across every other plan.
79
+
80
+ ## Open Questions
81
+
82
+ - How should confidence metadata be represented in local frontmatter while published pages hide or strip it?
83
+ - Which query outputs should be eligible for automatic file-back vs requiring human confirmation?
84
+ - How should private path names or environment-variable names be masked in published wikis?