solvdex 2.0.0-alpha.8 → 3.1.0-alpha.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 (59) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/README.md +102 -56
  4. package/agents/capture.md +122 -43
  5. package/agents/duplicate-checker.md +9 -11
  6. package/agents/graph.md +26 -25
  7. package/agents/health.md +84 -21
  8. package/agents/scanner.md +125 -26
  9. package/agents/searcher.md +46 -17
  10. package/agents/stats.md +31 -10
  11. package/agents/validator.md +26 -11
  12. package/docs/README.md +28 -10
  13. package/docs/architecture.md +64 -39
  14. package/docs/diagrams/architecture-overview.md +8 -11
  15. package/docs/diagrams/data-structures.md +2 -2
  16. package/docs/diagrams/knowledge-retrieval-flow.md +1 -1
  17. package/docs/diagrams/session-workflow.md +1 -1
  18. package/docs/diagrams/system-overview.md +4 -8
  19. package/docs/getting-started.md +15 -18
  20. package/docs/plans/2025-01-22-marketplace-distribution.md +2 -0
  21. package/docs/plans/2025-01-22-solvdex-design.md +2 -0
  22. package/docs/plans/2025-02-02-agent-first-architecture.md +16 -0
  23. package/docs/plans/2025-02-02-generic-wiki-v3.md +747 -0
  24. package/docs/plans/2026-02-03-index-scaling-design.md +145 -0
  25. package/docs/plans/2026-02-03-v3.1-index-implementation.md +856 -0
  26. package/docs/schema.md +140 -29
  27. package/docs/templates/problems.md +141 -0
  28. package/docs/templates/references.md +171 -0
  29. package/docs/templates/solutions.md +156 -0
  30. package/docs/use-cases.md +40 -93
  31. package/docs/workflows.md +19 -21
  32. package/hooks/hooks.json +7 -7
  33. package/package.json +2 -2
  34. package/skills/wiki/SKILL.md +17 -29
  35. package/skills/wiki-add/SKILL.md +27 -27
  36. package/skills/wiki-export/SKILL.md +6 -6
  37. package/skills/wiki-fix/SKILL.md +1 -1
  38. package/skills/wiki-flag/SKILL.md +1 -1
  39. package/skills/wiki-graph/SKILL.md +14 -15
  40. package/skills/wiki-health/SKILL.md +29 -12
  41. package/skills/wiki-import/SKILL.md +1 -1
  42. package/skills/wiki-init/SKILL.md +15 -26
  43. package/skills/wiki-scan/SKILL.md +4 -5
  44. package/skills/wiki-search/SKILL.md +49 -23
  45. package/skills/wiki-stats/SKILL.md +26 -30
  46. package/agents/templates/docs.md +0 -35
  47. package/agents/templates/gotchas.md +0 -31
  48. package/agents/templates/issues.md +0 -36
  49. package/agents/templates/patterns.md +0 -35
  50. package/agents/templates/performance.md +0 -36
  51. package/agents/templates/security.md +0 -36
  52. package/agents/templates/testing.md +0 -39
  53. package/docs/plans/2025-02-02-implementation-tasks.md +0 -1211
  54. package/skills/wiki-browse/SKILL.md +0 -74
  55. package/skills/wiki-capture/SKILL.md +0 -121
  56. package/skills/wiki-explorer/SKILL.md +0 -93
  57. package/skills/wiki-status/SKILL.md +0 -53
  58. package/skills/wiki-test-trigger/SKILL.md +0 -97
  59. package/skills/wiki-validate/SKILL.md +0 -61
package/agents/graph.md CHANGED
@@ -1,8 +1,7 @@
1
1
  ---
2
+ name: graph
2
3
  description: Generate Mermaid diagrams showing entry relationships.
3
- tools:
4
- - Glob
5
- - Read
4
+ tools: Glob, Read
6
5
  ---
7
6
 
8
7
  # Wiki Graph Agent
@@ -12,17 +11,17 @@ Generate visual relationship diagrams for wiki entries.
12
11
  ## Input
13
12
 
14
13
  - `{ "full": true }` - All entries
15
- - `{ "category": "issues" }` - Single category
16
- - `{ "entry": "issues/db-timeout.md" }` - Single entry and its relations
14
+ - `{ "folder": "problems" }` - Single folder
15
+ - `{ "entry": "problems/db-timeout.md" }` - Single entry and its relations
17
16
 
18
17
  ## Process
19
18
 
20
19
  1. Load entries (all or filtered)
21
20
  2. Extract relationships:
22
21
  - **Explicit**: `related_entries` field
23
- - **Wiki links**: `[[category/entry]]` in content
22
+ - **Wiki links**: `[[folder/entry]]` in content
24
23
  - **Tag overlap**: 2+ shared tags
25
- - **Same category**: Weak connection
24
+ - **Same folder**: Weak connection
26
25
  3. Generate Mermaid diagram
27
26
 
28
27
  ## Output Format
@@ -30,32 +29,34 @@ Generate visual relationship diagrams for wiki entries.
30
29
  ### Full Graph
31
30
  ```mermaid
32
31
  graph LR
33
- subgraph issues
34
- I1[DB Timeout]
35
- I2[Auth Error]
36
- I3[API Failure]
32
+ subgraph problems
33
+ P1[DB Timeout]
34
+ P2[Auth Error]
35
+ P3[Connection Pool Gotcha]
37
36
  end
38
37
 
39
- subgraph patterns
40
- P1[Retry Pattern]
41
- P2[Circuit Breaker]
38
+ subgraph solutions
39
+ S1[Retry Pattern]
40
+ S2[Circuit Breaker]
41
+ S3[Pool Config]
42
42
  end
43
43
 
44
- subgraph gotchas
45
- G1[Connection Pool]
44
+ subgraph references
45
+ R1[API Docs]
46
+ R2[Config Guide]
46
47
  end
47
48
 
48
- I1 -->|related| P1
49
- I1 -->|related| G1
50
- I2 -->|same-tag: auth| P2
51
- I3 -->|wiki-link| P1
52
- P1 -.->|same-category| P2
49
+ P1 -->|related| S1
50
+ P1 -->|related| P3
51
+ P2 -->|same-tag: auth| S2
52
+ S1 -.->|same-folder| S2
53
+ P3 -->|wiki-link| S3
53
54
  ```
54
55
 
55
- ### Category Graph
56
+ ### Folder Graph
56
57
  ```mermaid
57
58
  graph TD
58
- subgraph issues
59
+ subgraph problems
59
60
  A[DB Timeout]
60
61
  B[Auth Error]
61
62
  C[API Failure]
@@ -84,7 +85,7 @@ graph TD
84
85
  | related | `-->` solid | Explicit related_entries |
85
86
  | wiki-link | `-->` solid | [[link]] in content |
86
87
  | same-tag | `-->` labeled | 2+ shared tags |
87
- | same-category | `-.->` dashed | Same category |
88
+ | same-folder | `-.->` dashed | Same folder |
88
89
 
89
90
  ## Node Styling
90
91
 
@@ -101,5 +102,5 @@ Based on confidence:
101
102
  ## Graph Limits
102
103
 
103
104
  - Full graph: Max 50 entries (summarize if more)
104
- - Category: Max 20 entries
105
+ - Folder: Max 20 entries
105
106
  - Entry focus: Max 2 levels deep
package/agents/health.md CHANGED
@@ -1,9 +1,7 @@
1
1
  ---
2
- description: Analyze wiki health - find stale entries,
3
- coverage gaps, and maintenance needs.
4
- tools:
5
- - Glob
6
- - Read
2
+ name: health
3
+ description: Analyze wiki health - find stale entries, coverage gaps, and maintenance needs.
4
+ tools: Glob, Read, Write
7
5
  ---
8
6
 
9
7
  # Wiki Health Agent
@@ -16,7 +14,7 @@ Key references:
16
14
  - Entry frontmatter fields: `docs/schema.md#entry-frontmatter`
17
15
  - Maturity rules: `docs/schema.md#maturity-rules`
18
16
  - Confidence levels: `docs/schema.md#confidence-levels`
19
- - Categories: `docs/schema.md#default-categories`
17
+ - Folders: `docs/schema.md#default-folders`
20
18
 
21
19
  Comprehensive wiki health analysis and recommendations.
22
20
 
@@ -31,10 +29,71 @@ Comprehensive wiki health analysis and recommendations.
31
29
  - Orphaned: No tags, no related entries
32
30
  - Broken links: [[link]] to non-existent entry
33
31
  3. **Find coverage gaps**:
34
- - Categories with < 3 entries
32
+ - Folders with < 3 entries
35
33
  - Common error patterns without entries
36
34
  4. **Generate recommendations**
37
35
 
36
+ ## Index Operations
37
+
38
+ ### Validate Index (default with /wiki health)
39
+
40
+ 1. **Read index** from `.wiki/index.json` (if exists)
41
+ 2. **Glob all entries** from `.wiki/**/*.md`
42
+ 3. **Compare**:
43
+ - Entry in index but file missing → report orphan
44
+ - File exists but not in index → report missing
45
+ - Frontmatter differs from index → report stale
46
+ - Stats don't match counts → report mismatch
47
+ 4. **Output validation report**
48
+
49
+ ### Rebuild Index (with --reindex flag)
50
+
51
+ 1. **Glob all entries** from `.wiki/**/*.md` (excluding README.md)
52
+ 2. **For each entry**, Read frontmatter and extract:
53
+ - path (relative, e.g., `problems/db-timeout.md`)
54
+ - title
55
+ - folder (from path)
56
+ - tags
57
+ - trigger (if present)
58
+ - confidence
59
+ - maturity
60
+ - status
61
+ - use_count
62
+ 3. **Calculate stats**:
63
+ - total: count of entries
64
+ - by_folder: count per folder
65
+ - by_maturity: count per maturity level
66
+ 4. **Write index** to `.wiki/index.json`:
67
+ ```json
68
+ {
69
+ "version": 1,
70
+ "updated": "<ISO timestamp>",
71
+ "stats": { ... },
72
+ "entries": [ ... ]
73
+ }
74
+ ```
75
+ 5. **Output**: "Index rebuilt: X entries"
76
+
77
+ ### Index Validation Output
78
+
79
+ ```
80
+ ## Index Health
81
+
82
+ ✓ Index exists: .wiki/index.json
83
+ ✓ 48 entries in sync
84
+
85
+ Issues:
86
+ ✗ 2 files not in index:
87
+ - problems/new-error.md
88
+ - solutions/quick-fix.md
89
+ ✗ 1 orphan in index (file deleted):
90
+ - references/old-doc.md
91
+ ✗ 1 stale entry (frontmatter changed):
92
+ - problems/db-timeout.md
93
+
94
+ Run /wiki health --reindex to fix.
95
+ ```
96
+
38
97
  ## Output Format
39
98
 
40
99
  ```
@@ -45,29 +104,28 @@ Comprehensive wiki health analysis and recommendations.
45
104
  ## Issues Found
46
105
 
47
106
  ### Stale Entries (5)
48
- - patterns/old-api.md (120 days)
49
- - issues/legacy-auth.md (95 days)
107
+ - solutions/old-api.md (120 days)
108
+ - problems/legacy-auth.md (95 days)
50
109
  → Consider reviewing or deprecating
51
110
 
52
111
  ### Stub Entries (3)
53
- - issues/api-timeout.md - Missing Solution
54
- - gotchas/edge-case.md - Missing Problem
112
+ - problems/api-timeout.md - Missing Solution
113
+ - problems/edge-case.md - Missing Problem
55
114
  → Run /wiki fix <entry> to complete
56
115
 
57
116
  ### Low Confidence (4)
58
- - patterns/untested.md (confidence: 30)
117
+ - solutions/untested.md (confidence: 30)
59
118
  → Verify and increase confidence
60
119
 
61
120
  ### Missing Triggers (2)
62
- - issues/db-error.md
63
- - issues/auth-fail.md
121
+ - problems/db-error.md
122
+ - problems/auth-fail.md
64
123
  → Add trigger patterns for auto-matching
65
124
 
66
125
  ## Coverage Gaps
67
126
 
68
- ### Underserved Categories
69
- - security: 1 entry (recommend: 3+)
70
- - performance: 2 entries (recommend: 3+)
127
+ ### Underserved Folders
128
+ - references: 1 entry (recommend: 2+)
71
129
 
72
130
  ### Suggested Entries
73
131
  Based on common errors, consider adding:
@@ -79,8 +137,8 @@ Based on common errors, consider adding:
79
137
 
80
138
  1. Review 5 stale entries
81
139
  2. Complete 3 stub entries
82
- 3. Add triggers to 2 issues
83
- 4. Expand security category
140
+ 3. Add triggers to 2 problems
141
+ 4. Expand references folder
84
142
  ```
85
143
 
86
144
  ## Health Indicators
@@ -102,12 +160,17 @@ Based on common errors, consider adding:
102
160
 
103
161
  ## Coverage Analysis
104
162
 
105
- For each category:
163
+ For each folder:
106
164
  1. Count entries
107
165
  2. Compare to minimum (3)
108
166
  3. Flag if under-served
109
167
 
110
- Recommend expanding categories with:
168
+ Recommend expanding folders with:
111
169
  - High error rates in project
112
170
  - Recent user questions
113
171
  - Common patterns in codebase
172
+
173
+ ### Minimum Recommendations
174
+ - problems: 3+ entries
175
+ - solutions: 3+ entries
176
+ - references: 2+ entries
package/agents/scanner.md CHANGED
@@ -1,11 +1,7 @@
1
1
  ---
2
+ name: scanner
2
3
  description: Scan any project type and create wiki entries. Auto-detects Go, Node.js, Python, etc.
3
- tools:
4
- - Bash
5
- - Read
6
- - Write
7
- - Grep
8
- - Glob
4
+ tools: Bash, Read, Write, Grep, Glob
9
5
  ---
10
6
 
11
7
  # Universal Wiki Scanner
@@ -44,20 +40,53 @@ Check for these files to determine project type:
44
40
 
45
41
  ## Step 3: Create Entries
46
42
 
47
- For each finding, create entry in appropriate category:
48
- - `.wiki/issues/` - Bug fixes, errors
49
- - `.wiki/patterns/` - Reusable patterns
50
- - `.wiki/gotchas/` - Pitfalls, warnings
51
- - `.wiki/testing/` - Test strategies
52
- - `.wiki/docs/` - Documentation
53
- - `.wiki/security/` - Security items
54
- - `.wiki/performance/` - Optimizations
43
+ For each finding, create entry in appropriate folder:
44
+ - `.wiki/problems/` - Bug fixes, errors, gotchas, security issues
45
+ - `.wiki/solutions/` - Patterns, optimizations, test strategies, how-tos
46
+ - `.wiki/references/` - Documentation, guides, configs
55
47
 
56
- ### Using Templates
48
+ ### Folder Selection
57
49
 
58
- 1. Read template: `Read agents/templates/<category>.md`
59
- 2. Fill placeholders with scanned data
60
- 3. Write to `.wiki/<category>/<slug>.md`
50
+ | Source Type | Folder |
51
+ |-------------|--------|
52
+ | Error logs, bug fixes, git fix commits | problems/ |
53
+ | TODO/HACK comments about pitfalls | problems/ |
54
+ | Reusable code patterns | solutions/ |
55
+ | Test files, test strategies | solutions/ |
56
+ | README, docs/, guides | references/ |
57
+ | Config files, .env.example | references/ |
58
+
59
+ ### Generate Entry
60
+
61
+ Use the fixed template for the target folder. See `docs/templates/`.
62
+
63
+ | Folder | Template Sections |
64
+ |--------|-------------------|
65
+ | `problems/` | Problem, Cause, Solution, Prevention, Related |
66
+ | `solutions/` | Overview, Prerequisites, Steps, Example, Related |
67
+ | `references/` | Summary, Details, Links, Related |
68
+
69
+ ### Related Section Rules
70
+
71
+ **IMPORTANT:** Always use relative paths from project root, NOT absolute paths.
72
+
73
+ ```markdown
74
+ ## Related
75
+
76
+ - `CLAUDE.md` ✅ Correct (relative)
77
+ - `docs/specs/errors.md` ✅ Correct (relative)
78
+ - `/Users/foo/project/README.md` ❌ Wrong (absolute)
79
+ ```
80
+
81
+ Cross-link to other wiki entries when relevant:
82
+ ```markdown
83
+ ## Related
84
+
85
+ - `internal/auth/` (source code)
86
+ - [Error Handling Pattern](../solutions/error-handling.md) (wiki entry)
87
+ ```
88
+
89
+ Write to `.wiki/<folder>/<slug>.md`
61
90
 
62
91
  ### Frontmatter Reference
63
92
 
@@ -71,6 +100,7 @@ status: active
71
100
  confidence: 40-100
72
101
  maturity: captured
73
102
  tags: [relevant, tags]
103
+ trigger: "error pattern regex" # ONLY for problems/ - optional
74
104
  source: where-found
75
105
  use_count: 0
76
106
  audit:
@@ -80,19 +110,88 @@ audit:
80
110
  ---
81
111
  ```
82
112
 
83
- ## Step 4: Return Summary ONLY
113
+ **Trigger field (problems/ only):** If the problem has an identifiable error message or pattern, add a `trigger` field with a regex that matches it. This enables automatic error matching.
114
+
115
+ Examples:
116
+ - `trigger: "json: unsupported type"` for JSON encoding errors
117
+ - `trigger: "undefined is not a function"` for JS runtime errors
118
+ - `trigger: "connection refused"` for network errors
119
+
120
+ ## Step 4: Create Wiki Index and Performance Index
121
+
122
+ After creating entries, generate both indexes:
123
+
124
+ ### Generate README Index (human-readable)
125
+
126
+ Write `.wiki/README.md`:
127
+
128
+ ```markdown
129
+ # Project Wiki
130
+
131
+ Auto-generated knowledge base for this project.
132
+
133
+ ## Entries
134
+
135
+ ### Problems (N)
136
+ - [Entry Title](problems/slug.md) - Brief description
137
+
138
+ ### Solutions (N)
139
+ - [Entry Title](solutions/slug.md) - Brief description
140
+
141
+ ### References (N)
142
+ - [Entry Title](references/slug.md) - Brief description
143
+
144
+ ---
145
+ *Generated by Solvdex scanner on YYYY-MM-DD*
146
+ ```
147
+
148
+ ### Generate Performance Index (v3.1+)
149
+
150
+ Build and write `.wiki/index.json`:
151
+
152
+ 1. **Collect all created entries** into index format:
153
+ ```json
154
+ {
155
+ "path": "<folder>/<slug>.md",
156
+ "title": "<title>",
157
+ "folder": "<folder>",
158
+ "tags": ["<tags>"],
159
+ "trigger": "<regex if problems>",
160
+ "confidence": 40,
161
+ "maturity": "captured",
162
+ "status": "active",
163
+ "use_count": 0
164
+ }
165
+ ```
166
+
167
+ 2. **Calculate stats**:
168
+ ```json
169
+ {
170
+ "total": N,
171
+ "by_folder": { "problems": X, "solutions": Y, "references": Z },
172
+ "by_maturity": { "captured": N, "verified": 0, "validated": 0 }
173
+ }
174
+ ```
175
+
176
+ 3. **Write index**:
177
+ ```json
178
+ {
179
+ "version": 1,
180
+ "updated": "<ISO timestamp>",
181
+ "stats": { ... },
182
+ "entries": [ ... ]
183
+ }
184
+ ```
185
+
186
+ ## Step 5: Return Summary ONLY
84
187
 
85
188
  Do NOT output progress. Return ONLY:
86
189
 
87
190
  ```
88
191
  Scan complete: X entries created
89
- - issues: N
90
- - patterns: N
91
- - gotchas: N
92
- - testing: N
93
- - docs: N
94
- - security: N
95
- - performance: N
192
+ - problems: N
193
+ - solutions: N
194
+ - references: N
96
195
  ```
97
196
 
98
197
  ## Important Rules
@@ -1,11 +1,7 @@
1
1
  ---
2
- description: Search wiki entries using semantic understanding.
3
- Finds entries by meaning, not just keywords. Handles typos,
4
- synonyms, and related concepts. Also provides recommendations
5
- and error matching.
6
- tools:
7
- - Glob
8
- - Read
2
+ name: searcher
3
+ description: Search wiki entries using semantic understanding. Finds entries by meaning, not just keywords. Handles typos, synonyms, and related concepts. Also provides recommendations and error matching.
4
+ tools: Glob, Read
9
5
  ---
10
6
 
11
7
  # Wiki Searcher Agent
@@ -14,31 +10,62 @@ Search wiki entries semantically and provide intelligent recommendations.
14
10
 
15
11
  ## Modes
16
12
 
13
+ ## Index-First Search (v3.1+)
14
+
15
+ **Always try index first, fall back to Glob+Read if index missing.**
16
+
17
+ ### Check for Index
18
+
19
+ 1. Attempt to Read `.wiki/index.json`
20
+ 2. If exists and valid JSON:
21
+ - Use index for search (fast path)
22
+ - Only Read full entries for top matches
23
+ 3. If missing or invalid:
24
+ - Fall back to Glob+Read pattern (backward compatible)
25
+ - Log: "Index not found, using file scan"
26
+
27
+ ### Search with Index
28
+
29
+ 1. **Parse index.json** into memory
30
+ 2. **Filter/rank entries** using index metadata:
31
+ - Match query against title, tags, trigger
32
+ - Apply maturity/confidence ranking
33
+ 3. **Get top 5 matches** from index
34
+ 4. **Read only matched entries** for full content
35
+ 5. **Return results** with snippets
36
+
37
+ This reduces reads from N (all entries) to 1 (index) + 5 (top matches).
38
+
17
39
  ### 1. Search Mode
18
40
  Input: `{ "mode": "search", "query": "<search query>" }`
19
41
 
20
42
  Process:
21
- 1. Glob .wiki/**/*.md to find all entries
22
- 2. Read frontmatter (title, tags, category, status, confidence, trigger)
23
- 3. Understand query intent, handle typos/synonyms
24
- 4. Rank by semantic relevance + confidence + maturity
43
+ 1. **Try index first**: Read `.wiki/index.json`
44
+ - If exists: search using index entries
45
+ - If missing: fall back to Glob `.wiki/**/*.md` and Read each
46
+ 2. **Understand query intent**, handle typos/synonyms
47
+ 3. **Rank by**: semantic relevance + confidence + maturity
48
+ 4. **Read top 5 full entries** for content snippets
25
49
  5. Return top 5 results with explanations
26
50
 
27
51
  ### 2. Error Lookup Mode
28
52
  Input: `{ "mode": "error-lookup", "errorText": "<error message>" }`
29
53
 
30
54
  Process:
31
- 1. Load all entries with trigger patterns
55
+ 1. **Try index first**: Read `.wiki/index.json`
56
+ - If exists: filter entries with trigger patterns from index
57
+ - If missing: fall back to Glob+Read
32
58
  2. Match error text against triggers (regex)
33
59
  3. Prioritize high-confidence matches
34
- 4. Return best match with solution snippet
60
+ 4. **Read best match entry** for solution snippet
61
+ 5. Return best match with solution snippet
35
62
 
36
63
  ### 3. Session Context Mode
37
64
  Input: `{ "mode": "session-context", "taskDescription": "<task>", "filePaths": ["..."] }`
38
65
 
39
66
  Process:
40
67
  1. Analyze task description for keywords
41
- 2. Detect relevant categories from file paths
68
+ 2. Detect relevant folders from file paths
42
69
  3. Search for related entries
43
70
  4. Return top 3 recommendations
44
71
 
@@ -48,8 +75,9 @@ Process:
48
75
  ```
49
76
  Found X relevant entries:
50
77
 
51
- 1. **{title}** ({category}, confidence: {n})
78
+ 1. **{title}** ({folder}, confidence: {n})
52
79
  Path: {path}
80
+ Tags: {tags}
53
81
  Why: {explanation}
54
82
 
55
83
  2. ...
@@ -68,8 +96,9 @@ Found X relevant entries:
68
96
  ### Session Context
69
97
  ```
70
98
  📚 Solvdex: {n} relevant entries
71
- - {title} ({category})
72
- - ...
99
+ - {title} (problems/)
100
+ - {title} (solutions/)
101
+ - {title} (references/)
73
102
  ```
74
103
 
75
104
  ## Ranking Criteria
package/agents/stats.md CHANGED
@@ -1,10 +1,7 @@
1
1
  ---
2
- description: Calculate wiki statistics, track maturity,
3
- and generate analytics reports.
4
- tools:
5
- - Glob
6
- - Read
7
- - Write
2
+ name: stats
3
+ description: Calculate wiki statistics, track maturity, and generate analytics reports.
4
+ tools: Glob, Read, Write
8
5
  ---
9
6
 
10
7
  # Wiki Stats Agent
@@ -17,7 +14,7 @@ Key references:
17
14
  - Entry frontmatter fields: `docs/schema.md#entry-frontmatter`
18
15
  - Maturity rules: `docs/schema.md#maturity-rules`
19
16
  - Confidence levels: `docs/schema.md#confidence-levels`
20
- - Categories: `docs/schema.md#default-categories`
17
+ - Folders: `docs/schema.md#default-folders`
21
18
 
22
19
  Calculate comprehensive wiki statistics and manage maturity tracking.
23
20
 
@@ -30,10 +27,13 @@ Calculate comprehensive wiki statistics and manage maturity tracking.
30
27
  ## Process
31
28
 
32
29
  ### Stats Report
30
+
31
+ **Optimization**: If `.wiki/index.json` exists, read stats directly from index instead of scanning all files. Fall back to Glob+Read if index missing.
32
+
33
33
  1. Glob .wiki/**/*.md
34
34
  2. Read all entries
35
35
  3. Calculate:
36
- - Entry counts by category, status, maturity
36
+ - Entry counts by folder, status, maturity
37
37
  - Confidence distribution (high/medium/low)
38
38
  - Usage stats (total uses, most used, never used)
39
39
  - Staleness (entries not updated in 90+ days)
@@ -47,6 +47,28 @@ Calculate comprehensive wiki statistics and manage maturity tracking.
47
47
  2. Update frontmatter if promotion needed
48
48
  3. Log promotions
49
49
 
50
+ ### Update Index After Changes
51
+
52
+ When maturity or use_count changes:
53
+
54
+ 1. **Read index**: Try Read `.wiki/index.json`
55
+ - If missing: skip index update (will be rebuilt by health agent)
56
+
57
+ 2. **Find entry** by path in `entries` array
58
+
59
+ 3. **Update fields**:
60
+ - `use_count`: new value
61
+ - `maturity`: new value if promoted
62
+ - `confidence`: new value if changed
63
+
64
+ 4. **Recalculate stats** if maturity changed:
65
+ - Decrement old maturity count
66
+ - Increment new maturity count
67
+
68
+ 5. **Update timestamp**: Set `updated` to current ISO timestamp
69
+
70
+ 6. **Write index**: Write `.wiki/index.json`
71
+
50
72
  ### Confidence Decay
51
73
  1. Find entries not used in 90+ days
52
74
  2. Reduce confidence by 10 (minimum 20)
@@ -61,8 +83,7 @@ Calculate comprehensive wiki statistics and manage maturity tracking.
61
83
 
62
84
  ## Entries
63
85
  Total: 24
64
- issues: 8 | patterns: 6 | gotchas: 4
65
- testing: 3 | docs: 2 | security: 1
86
+ problems: 12 | solutions: 8 | references: 4
66
87
 
67
88
  ## By Status
68
89
  Active: 20 | Flagged: 3 | Deprecated: 1