codebase-wiki 0.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 (41) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/LICENSE +17 -0
  3. package/README.md +130 -0
  4. package/dist/CHANGELOG.md +34 -0
  5. package/dist/LICENSE +17 -0
  6. package/dist/README.md +130 -0
  7. package/dist/chunks/build.mjs +1976 -0
  8. package/dist/chunks/config.mjs +174 -0
  9. package/dist/chunks/llm.mjs +214 -0
  10. package/dist/code-wiki-mcp.mjs +367 -0
  11. package/dist/code-wiki.mjs +11 -0
  12. package/dist/codewiki.mjs +2002 -0
  13. package/dist/grammars/c.wasm +0 -0
  14. package/dist/grammars/cpp.wasm +0 -0
  15. package/dist/grammars/go.wasm +0 -0
  16. package/dist/grammars/java.wasm +0 -0
  17. package/dist/grammars/javascript.wasm +0 -0
  18. package/dist/grammars/python.wasm +0 -0
  19. package/dist/grammars/ruby.wasm +0 -0
  20. package/dist/grammars/rust.wasm +0 -0
  21. package/dist/grammars/tsx.wasm +0 -0
  22. package/dist/grammars/typescript.wasm +0 -0
  23. package/dist/plugin/.mcp.json +11 -0
  24. package/dist/plugin/CLAUDE.md +28 -0
  25. package/dist/plugin/commands/wiki-architecture.md +10 -0
  26. package/dist/plugin/commands/wiki-build.md +23 -0
  27. package/dist/plugin/commands/wiki-enrich.md +22 -0
  28. package/dist/plugin/commands/wiki-graph.md +16 -0
  29. package/dist/plugin/commands/wiki-help.md +49 -0
  30. package/dist/plugin/commands/wiki-refresh.md +13 -0
  31. package/dist/plugin/commands/wiki-search.md +18 -0
  32. package/dist/plugin/commands/wiki-symbol.md +21 -0
  33. package/dist/plugin/hooks/hooks.json +74 -0
  34. package/dist/plugin/hooks/nudge.mjs +197 -0
  35. package/dist/plugin/hooks/post-read-reminder.mjs +56 -0
  36. package/dist/plugin/hooks/post-tool-use.mjs +60 -0
  37. package/dist/plugin/hooks/pre-compact.mjs +25 -0
  38. package/dist/plugin/hooks/session-start.mjs +38 -0
  39. package/dist/plugin/hooks/user-prompt-submit.mjs +28 -0
  40. package/dist/plugin/manifest.json +54 -0
  41. package/package.json +100 -0
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ // SessionStart hook: emit a banner that the model sees as a system reminder.
3
+ // Output format: JSON to stdout; Claude Code parses the hookSpecificOutput.
4
+ // Falls back to plain stdout text when JSON is not supported.
5
+
6
+ import { promises as fs } from 'node:fs'
7
+ import path from 'node:path'
8
+
9
+ async function main() {
10
+ const cwd = process.env.CODEWIKI_CWD || process.cwd()
11
+ const metaPath = path.join(cwd, '.codewiki', '.meta.json')
12
+ const reminders = []
13
+
14
+ try {
15
+ const meta = JSON.parse(await fs.readFile(metaPath, 'utf8'))
16
+ reminders.push(
17
+ `<system-reminder>\n` +
18
+ `code-wiki is enabled for this repo. A .codewiki/ index exists (built ${meta.updatedAt ?? 'recently'}, modules=${meta.moduleCount ?? '?'} files=${meta.fileCount ?? '?'} symbols=${meta.symbolCount ?? '?'}).\n` +
19
+ `Prefer reading .codewiki/INDEX.md and .codewiki/files/**/*.md over grepping source. Use the \`wiki_search\` MCP tool before grep.\n` +
20
+ `Commands: /wiki-build /wiki-refresh /wiki-search /wiki-symbol /wiki-architecture /wiki-graph /wiki-enrich /wiki-help.\n` +
21
+ `</system-reminder>`,
22
+ )
23
+ } catch {
24
+ reminders.push(
25
+ `<system-reminder>\n` +
26
+ `code-wiki is enabled but no .codewiki/ index yet. Run /wiki-build to create one before expecting wiki-aware behavior.\n` +
27
+ `</system-reminder>`,
28
+ )
29
+ }
30
+
31
+ // Output to stdout. Claude Code picks this up as additional context.
32
+ process.stdout.write(reminders.join('\n'))
33
+ }
34
+
35
+ main().catch(() => {
36
+ // never block session start on hook failure
37
+ process.exit(0)
38
+ })
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ // UserPromptSubmit hook: emit a brief reminder after every user prompt.
3
+ // Only fires when .codewiki/ exists.
4
+
5
+ import { promises as fs } from 'node:fs'
6
+ import path from 'node:path'
7
+
8
+ async function main() {
9
+ const cwd = process.env.CODEWIKI_CWD || process.cwd()
10
+ const metaPath = path.join(cwd, '.codewiki', '.meta.json')
11
+
12
+ let exists = false
13
+ try {
14
+ await fs.stat(metaPath)
15
+ exists = true
16
+ } catch {
17
+ /* ignore */
18
+ }
19
+ if (!exists) return
20
+
21
+ process.stdout.write(
22
+ `<system-reminder>\n` +
23
+ `Reminder: prefer .codewiki/ pages (or the wiki_search MCP tool) over reading source files directly. If you edit files since the last index, run /wiki-refresh.\n` +
24
+ `</system-reminder>\n`,
25
+ )
26
+ }
27
+
28
+ main().catch(() => process.exit(0))
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "codebase-wiki",
3
+ "version": "0.1.0",
4
+ "description": "Token-efficient code wiki: builds a browsable .codewiki/ index and nudges the model toward reading summaries instead of raw source files.",
5
+ "author": {
6
+ "name": "code-wiki contributors"
7
+ },
8
+ "license": "Apache-2.0",
9
+ "homepage": "https://github.com/<your-github-username>/code-wiki",
10
+ "repository": "https://github.com/<your-github-username>/code-wiki.git",
11
+ "keywords": [
12
+ "claude-code",
13
+ "plugin",
14
+ "code-search",
15
+ "wiki",
16
+ "tree-sitter",
17
+ "tokens",
18
+ "mcp"
19
+ ],
20
+ "mcpServers": {
21
+ "code-wiki": {
22
+ "command": "node",
23
+ "args": [
24
+ "${CLAUDE_PLUGIN_ROOT}/dist/code-wiki-mcp.mjs"
25
+ ],
26
+ "env": {
27
+ "CODEWIKI_CWD": "${workspaceFolder}"
28
+ }
29
+ }
30
+ },
31
+ "commands": "./commands",
32
+ "permissions": {
33
+ "allow": [
34
+ "Bash(codewiki build:*)",
35
+ "Bash(codewiki refresh:*)",
36
+ "Bash(codewiki search:*)",
37
+ "Bash(codewiki show:*)",
38
+ "Bash(codewiki enrich:*)",
39
+ "Bash(codewiki invalidate:*)",
40
+ "Bash(codewiki validate:*)",
41
+ "Read(./.codewiki/**)"
42
+ ],
43
+ "deny": [
44
+ "Write(./.codewiki/modules/**)",
45
+ "Write(./.codewiki/files/**)",
46
+ "Write(./.codewiki/symbols/**)",
47
+ "Write(./.codewiki/architecture.md)",
48
+ "Write(./.codewiki/INDEX.md)"
49
+ ],
50
+ "ask": [
51
+ "Bash(codewiki clean:*)"
52
+ ]
53
+ }
54
+ }
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "codebase-wiki",
3
+ "version": "0.1.0",
4
+ "description": "Token-efficient code wiki for Claude Code. Generates a browsable .codewiki/ index so models read summaries on-demand.",
5
+ "homepage": "https://github.com/harrycjs/code-wiki",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/harrycjs/code-wiki.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/harrycjs/code-wiki/issues"
12
+ },
13
+ "funding": "https://github.com/harrycjs",
14
+ "license": "Apache-2.0",
15
+ "type": "module",
16
+ "bin": {
17
+ "codewiki": "./dist/codewiki.mjs"
18
+ },
19
+ "main": "./dist/code-wiki.mjs",
20
+ "exports": {
21
+ ".": {
22
+ "import": "./dist/code-wiki.mjs"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "CHANGELOG.md",
29
+ "LICENSE"
30
+ ],
31
+ "engines": {
32
+ "node": ">=20"
33
+ },
34
+ "scripts": {
35
+ "build": "unbuild && node scripts/postbuild.mjs",
36
+ "dev": "unbuild --watch",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "biome check src tests examples",
39
+ "lint:fix": "biome check --write src tests examples",
40
+ "format": "biome format --write src tests examples",
41
+ "test": "vitest run",
42
+ "test:watch": "vitest",
43
+ "verify:grammars": "node scripts/verify-grammars.mjs",
44
+ "changeset": "changeset",
45
+ "version": "changeset version",
46
+ "release": "changeset publish"
47
+ },
48
+ "dependencies": {
49
+ "@anthropic-ai/sdk": "^0.110.0",
50
+ "@modelcontextprotocol/sdk": "^1.29.0",
51
+ "commander": "^15.0.0",
52
+ "globby": "^16.0.0",
53
+ "gpt-tokenizer": "^3.4.0",
54
+ "ignore": "^7.0.0",
55
+ "p-queue": "^9.3.0",
56
+ "p-retry": "^8.0.0",
57
+ "pino": "^10.0.0",
58
+ "simple-git": "^3.36.0",
59
+ "tree-sitter-c": "^0.24.1",
60
+ "tree-sitter-cpp": "^0.23.4",
61
+ "tree-sitter-go": "^0.25.0",
62
+ "tree-sitter-java": "^0.23.5",
63
+ "tree-sitter-javascript": "^0.25.0",
64
+ "tree-sitter-python": "^0.25.0",
65
+ "tree-sitter-ruby": "^0.23.1",
66
+ "tree-sitter-rust": "^0.24.0",
67
+ "tree-sitter-typescript": "^0.23.2",
68
+ "web-tree-sitter": "^0.26.10"
69
+ },
70
+ "optionalDependencies": {
71
+ "tree-sitter-cli": "^0.26.10"
72
+ },
73
+ "devDependencies": {
74
+ "@biomejs/biome": "^2.5.0",
75
+ "@changesets/cli": "^2.31.0",
76
+ "@types/node": "^22.10.0",
77
+ "chokidar": "^5.0.0",
78
+ "happy-dom": "^20.0.0",
79
+ "tsx": "^4.23.0",
80
+ "typescript": "^5.7.0",
81
+ "unbuild": "^3.6.0",
82
+ "vitest": "^4.0.0"
83
+ },
84
+ "keywords": [
85
+ "claude-code",
86
+ "plugin",
87
+ "code-search",
88
+ "wiki",
89
+ "tree-sitter",
90
+ "mcp",
91
+ "context",
92
+ "tokens",
93
+ "anthropic",
94
+ "ai",
95
+ "llm"
96
+ ],
97
+ "publishConfig": {
98
+ "access": "public"
99
+ }
100
+ }