@agent-wiki/mcp 0.17.9

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 (217) hide show
  1. package/.claude-plugin/plugin.json +7 -0
  2. package/README.md +171 -0
  3. package/architecture.svg +58 -0
  4. package/dist/atlassian.d.ts +63 -0
  5. package/dist/atlassian.d.ts.map +1 -0
  6. package/dist/atlassian.js +596 -0
  7. package/dist/atlassian.js.map +1 -0
  8. package/dist/cli.d.ts +11 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +391 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/cobol/__tests__/call-boundary-lineage.test.d.ts +2 -0
  13. package/dist/cobol/__tests__/call-boundary-lineage.test.d.ts.map +1 -0
  14. package/dist/cobol/__tests__/call-boundary-lineage.test.js +505 -0
  15. package/dist/cobol/__tests__/call-boundary-lineage.test.js.map +1 -0
  16. package/dist/cobol/__tests__/code-analysis.test.d.ts +2 -0
  17. package/dist/cobol/__tests__/code-analysis.test.d.ts.map +1 -0
  18. package/dist/cobol/__tests__/code-analysis.test.js +465 -0
  19. package/dist/cobol/__tests__/code-analysis.test.js.map +1 -0
  20. package/dist/cobol/__tests__/db2-table-lineage.test.d.ts +2 -0
  21. package/dist/cobol/__tests__/db2-table-lineage.test.d.ts.map +1 -0
  22. package/dist/cobol/__tests__/db2-table-lineage.test.js +182 -0
  23. package/dist/cobol/__tests__/db2-table-lineage.test.js.map +1 -0
  24. package/dist/cobol/__tests__/evidence-mapping.test.d.ts +2 -0
  25. package/dist/cobol/__tests__/evidence-mapping.test.d.ts.map +1 -0
  26. package/dist/cobol/__tests__/evidence-mapping.test.js +49 -0
  27. package/dist/cobol/__tests__/evidence-mapping.test.js.map +1 -0
  28. package/dist/cobol/__tests__/extractors.test.d.ts +2 -0
  29. package/dist/cobol/__tests__/extractors.test.d.ts.map +1 -0
  30. package/dist/cobol/__tests__/extractors.test.js +189 -0
  31. package/dist/cobol/__tests__/extractors.test.js.map +1 -0
  32. package/dist/cobol/__tests__/field-lineage.test.d.ts +2 -0
  33. package/dist/cobol/__tests__/field-lineage.test.d.ts.map +1 -0
  34. package/dist/cobol/__tests__/field-lineage.test.js +329 -0
  35. package/dist/cobol/__tests__/field-lineage.test.js.map +1 -0
  36. package/dist/cobol/__tests__/graph.test.d.ts +2 -0
  37. package/dist/cobol/__tests__/graph.test.d.ts.map +1 -0
  38. package/dist/cobol/__tests__/graph.test.js +456 -0
  39. package/dist/cobol/__tests__/graph.test.js.map +1 -0
  40. package/dist/cobol/__tests__/integration.test.d.ts +2 -0
  41. package/dist/cobol/__tests__/integration.test.d.ts.map +1 -0
  42. package/dist/cobol/__tests__/integration.test.js +971 -0
  43. package/dist/cobol/__tests__/integration.test.js.map +1 -0
  44. package/dist/cobol/__tests__/lexer.test.d.ts +2 -0
  45. package/dist/cobol/__tests__/lexer.test.d.ts.map +1 -0
  46. package/dist/cobol/__tests__/lexer.test.js +111 -0
  47. package/dist/cobol/__tests__/lexer.test.js.map +1 -0
  48. package/dist/cobol/__tests__/parser.test.d.ts +2 -0
  49. package/dist/cobol/__tests__/parser.test.d.ts.map +1 -0
  50. package/dist/cobol/__tests__/parser.test.js +180 -0
  51. package/dist/cobol/__tests__/parser.test.js.map +1 -0
  52. package/dist/cobol/__tests__/variable-tracer.test.d.ts +2 -0
  53. package/dist/cobol/__tests__/variable-tracer.test.d.ts.map +1 -0
  54. package/dist/cobol/__tests__/variable-tracer.test.js +256 -0
  55. package/dist/cobol/__tests__/variable-tracer.test.js.map +1 -0
  56. package/dist/cobol/__tests__/wiki-gen.test.d.ts +2 -0
  57. package/dist/cobol/__tests__/wiki-gen.test.d.ts.map +1 -0
  58. package/dist/cobol/__tests__/wiki-gen.test.js +76 -0
  59. package/dist/cobol/__tests__/wiki-gen.test.js.map +1 -0
  60. package/dist/cobol/call-boundary-lineage.d.ts +49 -0
  61. package/dist/cobol/call-boundary-lineage.d.ts.map +1 -0
  62. package/dist/cobol/call-boundary-lineage.js +159 -0
  63. package/dist/cobol/call-boundary-lineage.js.map +1 -0
  64. package/dist/cobol/db2-table-lineage.d.ts +45 -0
  65. package/dist/cobol/db2-table-lineage.d.ts.map +1 -0
  66. package/dist/cobol/db2-table-lineage.js +127 -0
  67. package/dist/cobol/db2-table-lineage.js.map +1 -0
  68. package/dist/cobol/evidence-mapping.d.ts +31 -0
  69. package/dist/cobol/evidence-mapping.d.ts.map +1 -0
  70. package/dist/cobol/evidence-mapping.js +27 -0
  71. package/dist/cobol/evidence-mapping.js.map +1 -0
  72. package/dist/cobol/extractors.d.ts +88 -0
  73. package/dist/cobol/extractors.d.ts.map +1 -0
  74. package/dist/cobol/extractors.js +297 -0
  75. package/dist/cobol/extractors.js.map +1 -0
  76. package/dist/cobol/field-lineage.d.ts +101 -0
  77. package/dist/cobol/field-lineage.d.ts.map +1 -0
  78. package/dist/cobol/field-lineage.js +603 -0
  79. package/dist/cobol/field-lineage.js.map +1 -0
  80. package/dist/cobol/graph.d.ts +182 -0
  81. package/dist/cobol/graph.d.ts.map +1 -0
  82. package/dist/cobol/graph.js +453 -0
  83. package/dist/cobol/graph.js.map +1 -0
  84. package/dist/cobol/lexer.d.ts +15 -0
  85. package/dist/cobol/lexer.d.ts.map +1 -0
  86. package/dist/cobol/lexer.js +251 -0
  87. package/dist/cobol/lexer.js.map +1 -0
  88. package/dist/cobol/parser.d.ts +13 -0
  89. package/dist/cobol/parser.d.ts.map +1 -0
  90. package/dist/cobol/parser.js +584 -0
  91. package/dist/cobol/parser.js.map +1 -0
  92. package/dist/cobol/plugin.d.ts +23 -0
  93. package/dist/cobol/plugin.d.ts.map +1 -0
  94. package/dist/cobol/plugin.js +507 -0
  95. package/dist/cobol/plugin.js.map +1 -0
  96. package/dist/cobol/types.d.ts +73 -0
  97. package/dist/cobol/types.d.ts.map +1 -0
  98. package/dist/cobol/types.js +9 -0
  99. package/dist/cobol/types.js.map +1 -0
  100. package/dist/cobol/variable-tracer.d.ts +31 -0
  101. package/dist/cobol/variable-tracer.d.ts.map +1 -0
  102. package/dist/cobol/variable-tracer.js +361 -0
  103. package/dist/cobol/variable-tracer.js.map +1 -0
  104. package/dist/cobol/wiki-gen.d.ts +18 -0
  105. package/dist/cobol/wiki-gen.d.ts.map +1 -0
  106. package/dist/cobol/wiki-gen.js +222 -0
  107. package/dist/cobol/wiki-gen.js.map +1 -0
  108. package/dist/code-analysis.d.ts +160 -0
  109. package/dist/code-analysis.d.ts.map +1 -0
  110. package/dist/code-analysis.js +53 -0
  111. package/dist/code-analysis.js.map +1 -0
  112. package/dist/evidence-search.d.ts +43 -0
  113. package/dist/evidence-search.d.ts.map +1 -0
  114. package/dist/evidence-search.js +112 -0
  115. package/dist/evidence-search.js.map +1 -0
  116. package/dist/evidence-search.test.d.ts +2 -0
  117. package/dist/evidence-search.test.d.ts.map +1 -0
  118. package/dist/evidence-search.test.js +98 -0
  119. package/dist/evidence-search.test.js.map +1 -0
  120. package/dist/evidence.d.ts +32 -0
  121. package/dist/evidence.d.ts.map +1 -0
  122. package/dist/evidence.js +16 -0
  123. package/dist/evidence.js.map +1 -0
  124. package/dist/evidence.test.d.ts +2 -0
  125. package/dist/evidence.test.d.ts.map +1 -0
  126. package/dist/evidence.test.js +51 -0
  127. package/dist/evidence.test.js.map +1 -0
  128. package/dist/extraction.d.ts +40 -0
  129. package/dist/extraction.d.ts.map +1 -0
  130. package/dist/extraction.js +283 -0
  131. package/dist/extraction.js.map +1 -0
  132. package/dist/extraction.test.d.ts +5 -0
  133. package/dist/extraction.test.d.ts.map +1 -0
  134. package/dist/extraction.test.js +137 -0
  135. package/dist/extraction.test.js.map +1 -0
  136. package/dist/index.d.ts +38 -0
  137. package/dist/index.d.ts.map +1 -0
  138. package/dist/index.js +35 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/queue.d.ts +52 -0
  141. package/dist/queue.d.ts.map +1 -0
  142. package/dist/queue.js +139 -0
  143. package/dist/queue.js.map +1 -0
  144. package/dist/queue.test.d.ts +2 -0
  145. package/dist/queue.test.d.ts.map +1 -0
  146. package/dist/queue.test.js +161 -0
  147. package/dist/queue.test.js.map +1 -0
  148. package/dist/search.d.ts +163 -0
  149. package/dist/search.d.ts.map +1 -0
  150. package/dist/search.js +653 -0
  151. package/dist/search.js.map +1 -0
  152. package/dist/search.test.d.ts +6 -0
  153. package/dist/search.test.d.ts.map +1 -0
  154. package/dist/search.test.js +551 -0
  155. package/dist/search.test.js.map +1 -0
  156. package/dist/server.d.ts +33 -0
  157. package/dist/server.d.ts.map +1 -0
  158. package/dist/server.js +2530 -0
  159. package/dist/server.js.map +1 -0
  160. package/dist/server.test.d.ts +8 -0
  161. package/dist/server.test.d.ts.map +1 -0
  162. package/dist/server.test.js +2397 -0
  163. package/dist/server.test.js.map +1 -0
  164. package/dist/version.d.ts +2 -0
  165. package/dist/version.d.ts.map +1 -0
  166. package/dist/version.js +5 -0
  167. package/dist/version.js.map +1 -0
  168. package/dist/wiki.d.ts +496 -0
  169. package/dist/wiki.d.ts.map +1 -0
  170. package/dist/wiki.js +2677 -0
  171. package/dist/wiki.js.map +1 -0
  172. package/dist/wiki.test.d.ts +8 -0
  173. package/dist/wiki.test.d.ts.map +1 -0
  174. package/dist/wiki.test.js +1881 -0
  175. package/dist/wiki.test.js.map +1 -0
  176. package/docs/code-analysis-plugins.md +169 -0
  177. package/docs/configuration.md +135 -0
  178. package/docs/diagrams/cobol-analysis-flow.png +0 -0
  179. package/docs/diagrams/cobol-analysis-flow.svg +156 -0
  180. package/docs/evidence-envelope.md +176 -0
  181. package/docs/graph-1.gif +0 -0
  182. package/docs/legacy-code-knowledge-compiler-prd.md +511 -0
  183. package/docs/product-direction.md +120 -0
  184. package/docs/request-optimization.md +201 -0
  185. package/docs/search.md +266 -0
  186. package/docs/tools.md +269 -0
  187. package/graph-viewer/dist/cli.d.ts +3 -0
  188. package/graph-viewer/dist/cli.d.ts.map +1 -0
  189. package/graph-viewer/dist/cli.js +97 -0
  190. package/graph-viewer/dist/cli.js.map +1 -0
  191. package/graph-viewer/dist/graph.d.ts +14 -0
  192. package/graph-viewer/dist/graph.d.ts.map +1 -0
  193. package/graph-viewer/dist/graph.js +96 -0
  194. package/graph-viewer/dist/graph.js.map +1 -0
  195. package/graph-viewer/dist/index.d.ts +6 -0
  196. package/graph-viewer/dist/index.d.ts.map +1 -0
  197. package/graph-viewer/dist/index.js +4 -0
  198. package/graph-viewer/dist/index.js.map +1 -0
  199. package/graph-viewer/dist/parse.d.ts +10 -0
  200. package/graph-viewer/dist/parse.d.ts.map +1 -0
  201. package/graph-viewer/dist/parse.js +62 -0
  202. package/graph-viewer/dist/parse.js.map +1 -0
  203. package/graph-viewer/dist/server.d.ts +15 -0
  204. package/graph-viewer/dist/server.d.ts.map +1 -0
  205. package/graph-viewer/dist/server.js +168 -0
  206. package/graph-viewer/dist/server.js.map +1 -0
  207. package/graph-viewer/dist/types.d.ts +48 -0
  208. package/graph-viewer/dist/types.d.ts.map +1 -0
  209. package/graph-viewer/dist/types.js +2 -0
  210. package/graph-viewer/dist/types.js.map +1 -0
  211. package/graph-viewer/public/app.js +525 -0
  212. package/graph-viewer/public/index.html +68 -0
  213. package/graph-viewer/public/style.css +68 -0
  214. package/package.json +73 -0
  215. package/skills/aceclaw/SKILL.md +173 -0
  216. package/skills/agent-wiki/SKILL.md +184 -0
  217. package/skills/agent-wiki/references/tools-reference.md +368 -0
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@agent-wiki/mcp",
3
+ "version": "0.17.9",
4
+ "description": "Agent-driven knowledge base — immutable raw sources + mutable wiki + self-checking lint. MCP server, no LLM needed.",
5
+ "type": "module",
6
+ "bin": {
7
+ "agent-wiki": "./dist/cli.js",
8
+ "agent-wiki-mcp": "./dist/cli.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "files": [
13
+ "dist",
14
+ "schemas",
15
+ "skills",
16
+ ".claude-plugin",
17
+ "docs",
18
+ "architecture.svg",
19
+ "graph-viewer/dist",
20
+ "graph-viewer/public"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "dev": "tsc --watch",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
27
+ "start": "node dist/cli.js",
28
+ "prepare": "npm run build",
29
+ "release:patch": "gh workflow run release.yml -f bump=patch",
30
+ "release:minor": "gh workflow run release.yml -f bump=minor",
31
+ "release:major": "gh workflow run release.yml -f bump=major",
32
+ "build:graph": "npm ci --prefix graph-viewer && npm run build --prefix graph-viewer"
33
+ },
34
+ "keywords": [
35
+ "mcp",
36
+ "wiki",
37
+ "knowledge-base",
38
+ "agent",
39
+ "markdown",
40
+ "model-context-protocol"
41
+ ],
42
+ "author": "Xinhua Chen",
43
+ "license": "MIT",
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/xinhuagu/agent-wiki.git"
50
+ },
51
+ "engines": {
52
+ "node": ">=20.19.0 || >=22.13.0 || >=24"
53
+ },
54
+ "dependencies": {
55
+ "@modelcontextprotocol/sdk": "^1.12.1",
56
+ "@xenova/transformers": "^2.17.2",
57
+ "adm-zip": "^0.5.16",
58
+ "commander": "^13.1.0",
59
+ "gray-matter": "^4.0.3",
60
+ "js-yaml": "^4.1.0",
61
+ "mammoth": "^1.8.0",
62
+ "pdfjs-dist": "^5.6.205",
63
+ "xlsx": "^0.18.5"
64
+ },
65
+ "devDependencies": {
66
+ "@types/adm-zip": "^0.5.7",
67
+ "@types/js-yaml": "^4.0.9",
68
+ "@types/node": "^22.15.3",
69
+ "@vitest/coverage-v8": "^4.1.2",
70
+ "typescript": "^5.8.3",
71
+ "vitest": "^4.1.2"
72
+ }
73
+ }
@@ -0,0 +1,173 @@
1
+ ---
2
+ name: agent-wiki
3
+ version: "${VERSION}"
4
+ description: Manage project wiki - read/write wiki pages, search knowledge base, import from Confluence/Jira, add raw files, parse COBOL code. Use for project documentation, knowledge lookup, and code analysis. Invoke as /agent-wiki [query or action].
5
+ argument-hint: <action> e.g. "search SAMPLE deployment" or "read page overview" or "import confluence page"
6
+ context: inline
7
+ user-invocable: true
8
+ allowedTools: [bash]
9
+ ---
10
+
11
+ # Agent Wiki — Knowledge Base Skill
12
+
13
+ Manage a structured knowledge base with immutable raw sources and a mutable wiki layer.
14
+
15
+ ## Architecture
16
+
17
+ ```
18
+ raw/ → Immutable source layer (SHA-256 verified, write-once)
19
+ wiki/ → Mutable knowledge layer (Markdown + YAML frontmatter, auto-classified)
20
+ schemas/→ Entity templates (person, concept, event, artifact, ...)
21
+ ```
22
+
23
+ ## How to Call Tools
24
+
25
+ All 18 tools are invoked via `agent-wiki call`:
26
+
27
+ ```bash
28
+ agent-wiki call <tool_name> '<json_args>'
29
+ ```
30
+
31
+ Add `-w <path>` if the knowledge base is not in the current directory.
32
+
33
+ ## Wiki Operations
34
+
35
+ ### Search wiki
36
+ ```bash
37
+ agent-wiki call wiki_search '{"query": "deployment config", "limit": 5}'
38
+ ```
39
+
40
+ ### Read a wiki page
41
+ ```bash
42
+ agent-wiki call wiki_read '{"page": "concept-overview.md"}'
43
+ ```
44
+
45
+ ### Write/update a wiki page
46
+ ```bash
47
+ agent-wiki call wiki_write '{"page": "concept-x.md", "content": "---\ntitle: Concept X\ntype: concept\ntags: [research]\nsources: [raw/paper.pdf]\n---\n\n# Concept X\n\nKey findings..."}'
48
+ ```
49
+
50
+ ### List wiki pages
51
+ ```bash
52
+ agent-wiki call wiki_list
53
+ agent-wiki call wiki_list '{"type": "concept", "tag": "cobol"}'
54
+ ```
55
+
56
+ ### Delete a wiki page
57
+ ```bash
58
+ agent-wiki call wiki_delete '{"page": "old-page.md"}'
59
+ ```
60
+
61
+ ## Raw File Operations
62
+
63
+ ### List raw files
64
+ ```bash
65
+ agent-wiki call raw_list
66
+ ```
67
+
68
+ ### Read a raw file
69
+ ```bash
70
+ agent-wiki call raw_read '{"filename": "notes.pdf"}'
71
+ agent-wiki call raw_read '{"filename": "large.pdf", "pages": "1-5"}'
72
+ ```
73
+
74
+ ### Add a raw file (from content or local path)
75
+ ```bash
76
+ agent-wiki call raw_add '{"filename": "doc.txt", "content": "file content here"}'
77
+ agent-wiki call raw_add '{"filename": "code.cbl", "source_path": "/path/to/file.cbl"}'
78
+ ```
79
+
80
+ **IMPORTANT:** When adding COBOL files (.cbl, .cob, .cpy), ALWAYS follow up with `code_parse` immediately to auto-generate AST, normalized model, and wiki pages:
81
+ ```bash
82
+ agent-wiki call raw_add '{"filename": "PAYROLL.cbl", "source_path": "/path/to/PAYROLL.cbl"}'
83
+ agent-wiki call code_parse '{"path": "PAYROLL.cbl"}'
84
+ ```
85
+
86
+ ### Fetch from URL
87
+ ```bash
88
+ agent-wiki call raw_fetch '{"url": "https://example.com/doc.pdf", "description": "Research paper"}'
89
+ ```
90
+
91
+ ### View file versions
92
+ ```bash
93
+ agent-wiki call raw_versions '{"filename": "report.xlsx"}'
94
+ ```
95
+
96
+ ## Import Operations
97
+
98
+ ### Import from Confluence
99
+ ```bash
100
+ agent-wiki call raw_import_confluence '{"url": "https://company.atlassian.net/wiki/spaces/ENG/pages/123/Title", "recursive": true, "depth": 2}'
101
+ ```
102
+
103
+ ### Import from Jira
104
+ ```bash
105
+ agent-wiki call raw_import_jira '{"url": "https://company.atlassian.net/browse/PROJ-123", "include_comments": true}'
106
+ ```
107
+
108
+ ## Code Analysis
109
+
110
+ ### Import and parse COBOL source
111
+ ```bash
112
+ # Step 1: Add the source file
113
+ agent-wiki call raw_add '{"filename": "PAYROLL.cbl", "source_path": "/path/to/PAYROLL.cbl"}'
114
+ # Step 2: Parse to generate AST + wiki pages
115
+ agent-wiki call code_parse '{"path": "PAYROLL.cbl"}'
116
+ ```
117
+
118
+ ### Trace variable usage
119
+ ```bash
120
+ agent-wiki call code_query '{"query_type": "trace_variable", "path": "PAYROLL.cbl", "variable": "WS-TOTAL-SALARY"}'
121
+ ```
122
+
123
+ ## Admin Operations
124
+
125
+ ```bash
126
+ agent-wiki call wiki_rebuild # Rebuild index.md and timeline.md
127
+ agent-wiki call wiki_lint # Health checks
128
+ agent-wiki call wiki_config # Show workspace config
129
+ ```
130
+
131
+ ## Request Optimization (CRITICAL)
132
+
133
+ **ALWAYS minimize the number of tool calls. Each tool call costs one LLM request.**
134
+
135
+ - **Looking up existing wiki pages?** Use `wiki_search` or `wiki_search_read` — NEVER use multiple `glob` calls to find pages one by one.
136
+ - **Reading multiple pages?** Use `wiki_read` with `pages` array, or `wiki_search_read` with `readTopN` — NEVER read pages one at a time.
137
+ - **Writing multiple pages?** Use `knowledge_digest_write` or `batch` — NEVER write pages one at a time.
138
+ - **Multiple independent operations?** Use `batch` to combine them into one call.
139
+ - **Importing files?** Use `knowledge_ingest_batch` for directories — NEVER import files one at a time.
140
+
141
+ ### Batch Operations
142
+ ```bash
143
+ # Read multiple pages in one call
144
+ agent-wiki call wiki_read '{"pages": ["concept-a.md", "concept-b.md", "concept-c.md"]}'
145
+
146
+ # Search + read top results in one call (replaces search → glob → read loop)
147
+ agent-wiki call wiki_search_read '{"query": "SORDI Bloomberg", "readTopN": 5}'
148
+
149
+ # Write multiple digest pages in one call
150
+ agent-wiki call knowledge_digest_write '{"pages": [{"page": "summary.md", "title": "Summary", "body": "..."}]}'
151
+
152
+ # Combine any operations in one call
153
+ agent-wiki call batch '{"operations": [{"tool": "wiki_search", "args": {"query": "T4"}}, {"tool": "wiki_read", "args": {"page": "concept-x.md"}}]}'
154
+
155
+ # Ingest an entire directory in one call
156
+ agent-wiki call knowledge_ingest_batch '{"source_path": "/path/to/docs", "topic": "sample"}'
157
+ ```
158
+
159
+ ## Instructions
160
+
161
+ Based on $ARGUMENTS:
162
+ 1. If user asks to search or find: use `wiki_search_read` (returns content inline) or `wiki_search`
163
+ 2. If user asks to read a page or document: use `wiki_read` (supports `pages` array for multi-read) or `raw_read`
164
+ 3. If user asks to write or update: use `wiki_write` (single) or `knowledge_digest_write` (multiple with provenance)
165
+ 4. If user asks to list pages or files: use `wiki_list` or `raw_list`
166
+ 5. If user asks to import from Confluence/Jira: use `raw_import_confluence` or `raw_import_jira`
167
+ 6. If user asks to import a directory of files: use `knowledge_ingest_batch`
168
+ 7. **When adding ANY COBOL file (.cbl, .cob, .cpy) via `raw_add`: ALWAYS run `code_parse` immediately after.** This is mandatory — never add a COBOL file without parsing it.
169
+ 8. If user asks about code analysis or variables: use `code_parse`, then `code_query` with the appropriate `query_type` (`trace_variable`, `impact`, `procedure_flow`, `field_lineage`, `dataflow_edges`)
170
+ 9. If user asks to check health: use `wiki_lint`
171
+ 10. **When performing multiple operations, ALWAYS use `batch` to combine them into a single call.**
172
+ 11. Present results in clear, structured format
173
+ 12. Most tool outputs are JSON. Exceptions: `wiki_read` returns raw Markdown; missing-page lookups return plain text errors (non-zero exit code)
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: agent-wiki
3
+ version: "${VERSION}"
4
+ description: >
5
+ Manage a structured knowledge base with immutable raw sources and a mutable wiki layer.
6
+ Use this skill whenever the user mentions knowledge base, wiki, raw documents, importing
7
+ documents (Confluence, Jira, URLs, files), searching knowledge, code parsing (COBOL),
8
+ or asks to add/read/write/search/lint knowledge. Also trigger when the user says
9
+ "agent-wiki", "wiki", "knowledge base", "raw sources", "import from confluence",
10
+ "import from jira", "parse COBOL", "trace variable", or any variation. Even if the user
11
+ just says "add this to the wiki", "search for X", or "check the knowledge base", use this skill.
12
+ allowed-tools: [Bash, Read, Write, Glob, Grep]
13
+ ---
14
+
15
+ # Agent Wiki — Knowledge Base Skill
16
+
17
+ You are operating an **agent-wiki** knowledge base. All operations go through the `agent-wiki` CLI.
18
+
19
+ ## Architecture
20
+
21
+ ```
22
+ raw/ → Immutable source layer (SHA-256 verified, write-once)
23
+ wiki/ → Mutable knowledge layer (Markdown + YAML frontmatter, auto-classified)
24
+ schemas/→ Entity templates (person, concept, event, artifact, ...)
25
+ ```
26
+
27
+ ## How to Call Tools
28
+
29
+ Every tool is invoked via the CLI `call` command. The binary is `agent-wiki` (or `npx @agent-wiki/mcp` if not globally installed).
30
+
31
+ ```bash
32
+ agent-wiki call <tool_name> '<json_args>'
33
+ ```
34
+
35
+ - Arguments are a **JSON string** with snake_case keys.
36
+ - Tools with no required args can omit the JSON: `agent-wiki call wiki_list`
37
+ - Add `-w <path>` if the knowledge base is not in the current directory.
38
+ - Add `--workspace <path>` if data lives in a separate workspace directory.
39
+
40
+ ### Workspace detection
41
+
42
+ Before calling any tool, check if `.agent-wiki.yaml` exists in the current directory. If not, find it:
43
+
44
+ ```bash
45
+ # Check current directory first
46
+ ls .agent-wiki.yaml 2>/dev/null || echo "not found"
47
+ ```
48
+
49
+ If not in CWD, use `-w /path/to/config/root` on every call.
50
+
51
+ ## Available Tools (18)
52
+
53
+ ### RAW LAYER — Immutable Source Documents
54
+
55
+ | Tool | Purpose |
56
+ |------|---------|
57
+ | `raw_add` | Add a file to raw/ (from content string, local path, or directory) |
58
+ | `raw_list` | List all raw documents with metadata |
59
+ | `raw_read` | Read a raw document's content and metadata |
60
+ | `raw_versions` | List all versions of a raw file |
61
+ | `raw_fetch` | Download a file from URL into raw/ |
62
+ | `raw_import_confluence` | Import Confluence page(s) recursively |
63
+ | `raw_import_jira` | Import Jira issue with comments/attachments/links |
64
+
65
+ ### WIKI LAYER — Mutable Knowledge
66
+
67
+ | Tool | Purpose |
68
+ |------|---------|
69
+ | `wiki_read` | Read a wiki page (frontmatter + markdown) |
70
+ | `wiki_write` | Create or update a wiki page (auto-classified, auto-routed) |
71
+ | `wiki_delete` | Delete a wiki page (cannot delete system pages) |
72
+ | `wiki_list` | List wiki pages, optionally filtered by type/tag |
73
+ | `wiki_search` | Full-text BM25 search with snippets |
74
+ | `wiki_lint` | Health checks: contradictions, orphans, broken links, integrity |
75
+ | `wiki_init` | Initialize a new knowledge base |
76
+ | `wiki_config` | Show workspace configuration |
77
+ | `wiki_rebuild` | Rebuild index.md and timeline.md |
78
+
79
+ ### CODE ANALYSIS
80
+
81
+ | Tool | Purpose |
82
+ |------|---------|
83
+ | `code_parse` | Parse source file into AST + normalized model + per-file wiki page; refreshes cross-file lineage and the knowledge graph |
84
+ | `code_query` | Unified query surface for parsed code — pick a `query_type`: `trace_variable`, `impact`, `procedure_flow`, `field_lineage`, or `dataflow_edges` |
85
+
86
+ ## Common Workflows
87
+
88
+ ### 1. Import a document and create wiki knowledge
89
+
90
+ ```bash
91
+ # Download from URL
92
+ agent-wiki call raw_fetch '{"url":"https://example.com/paper.pdf","description":"Research paper on X"}'
93
+
94
+ # Or add from local file
95
+ agent-wiki call raw_add '{"filename":"report.pdf","source_path":"/path/to/report.pdf"}'
96
+
97
+ # Read the imported content
98
+ agent-wiki call raw_read '{"filename":"paper.pdf"}'
99
+
100
+ # Write a wiki page based on it
101
+ agent-wiki call wiki_write '{"page":"concept-x.md","content":"---\ntitle: Concept X\ntype: concept\ntags: [research]\nsources: [raw/paper.pdf]\n---\n\n# Concept X\n\nKey findings..."}'
102
+ ```
103
+
104
+ ### 2. Search and update knowledge
105
+
106
+ ```bash
107
+ # Search
108
+ agent-wiki call wiki_search '{"query":"machine learning"}'
109
+
110
+ # Read a specific page
111
+ agent-wiki call wiki_read '{"page":"concept-x.md"}'
112
+
113
+ # Update it
114
+ agent-wiki call wiki_write '{"page":"concept-x.md","content":"...updated content...","source":"Updated with new findings"}'
115
+ ```
116
+
117
+ ### 3. Health check
118
+
119
+ ```bash
120
+ agent-wiki call wiki_lint
121
+ ```
122
+
123
+ ### 4. Parse COBOL source code
124
+
125
+ ```bash
126
+ # First add the source file
127
+ agent-wiki call raw_add '{"filename":"PAYROLL.cbl","source_path":"/path/to/PAYROLL.cbl"}'
128
+
129
+ # Parse it — generates AST, normalized model, COBOL-specific model,
130
+ # per-file wiki page, and refreshes cross-file lineage / system map.
131
+ agent-wiki call code_parse '{"path":"PAYROLL.cbl"}'
132
+
133
+ # Query parsed code (unified surface — pick a query_type)
134
+ agent-wiki call code_query '{"query_type":"trace_variable","path":"PAYROLL.cbl","variable":"WS-TOTAL-SALARY"}'
135
+ agent-wiki call code_query '{"query_type":"impact","node_id":"copybook:DATE-UTILS"}'
136
+ agent-wiki call code_query '{"query_type":"procedure_flow","path":"PAYROLL.cbl"}'
137
+ agent-wiki call code_query '{"query_type":"field_lineage","field_name":"CUSTOMER-ID"}'
138
+ ```
139
+
140
+ ## Writing Wiki Pages with Long Content
141
+
142
+ For `wiki_write`, the content can be long (full Markdown with frontmatter). Two approaches:
143
+
144
+ **Approach A — Direct JSON (short content):**
145
+ ```bash
146
+ agent-wiki call wiki_write '{"page":"note-x.md","content":"---\ntitle: X\ntype: note\ntags: []\n---\n\nShort note."}'
147
+ ```
148
+
149
+ **Approach B — Write to temp file first (recommended for long content):**
150
+ 1. Use the Write tool to create a temp file (e.g., `/tmp/wiki-page.md`)
151
+ 2. Then use `raw_add` + manual copy, or pass it via JSON with escaped content
152
+
153
+ For multi-line content, use a heredoc to avoid escaping issues:
154
+
155
+ ```bash
156
+ agent-wiki call wiki_write "$(cat <<'ENDJSON'
157
+ {"page":"concept-x.md","content":"---\ntitle: Concept X\ntype: concept\ntags: [research, ml]\nsources: [raw/paper.pdf]\n---\n\n# Concept X\n\nThis is a detailed page about Concept X.\n\n## Key Points\n\n- Point 1\n- Point 2\n"}
158
+ ENDJSON
159
+ )"
160
+ ```
161
+
162
+ ## Important Notes
163
+
164
+ - **COBOL auto-parse**: When adding ANY COBOL file (.cbl, .cob, .cpy) via `raw_add`, you MUST ALWAYS immediately run `code_parse` on it. This is mandatory — never add a COBOL file without parsing it. The parse generates AST, normalized model, and auto-creates wiki pages.
165
+ - **Raw files are immutable** — once added, they cannot be modified. Use `raw_versions` + `auto_version` for updates.
166
+ - **Wiki pages are mutable** — they represent compiled knowledge that improves over time.
167
+ - **Auto-classification**: `wiki_write` automatically infers `type` and `tags` if missing from frontmatter.
168
+ - **Auto-routing**: Root-level pages are automatically routed to matching topic subdirectories.
169
+ - **System pages** (`index.md`, `log.md`, `timeline.md`, `*/index.md`) cannot be deleted.
170
+ - **Lint regularly** — `wiki_lint` catches contradictions, orphans, broken links, and integrity issues.
171
+ - Most tool outputs are **JSON** (e.g. `wiki_list`, `wiki_search`, `raw_add`). Exceptions: `wiki_read` returns raw Markdown content; missing-page lookups return plain text error messages.
172
+
173
+ ## Error Handling
174
+
175
+ If a command fails, it exits with code 1 and prints an error. Always check the exit code:
176
+
177
+ ```bash
178
+ agent-wiki call wiki_read '{"page":"nonexistent.md"}' || echo "Page not found"
179
+ ```
180
+
181
+ ## Full Parameter Reference
182
+
183
+ For detailed parameter schemas of each tool, read the reference file:
184
+ `skills/agent-wiki/references/tools-reference.md`