thoth-plugin 1.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 (89) hide show
  1. package/README.md +84 -0
  2. package/dist/agents/archivist.d.ts +2 -0
  3. package/dist/agents/chronicler.d.ts +2 -0
  4. package/dist/agents/coach.d.ts +2 -0
  5. package/dist/agents/code-master.d.ts +2 -0
  6. package/dist/agents/diplomat.d.ts +2 -0
  7. package/dist/agents/index.d.ts +12 -0
  8. package/dist/agents/life-master.d.ts +2 -0
  9. package/dist/agents/scribe.d.ts +2 -0
  10. package/dist/agents/sentinel.d.ts +2 -0
  11. package/dist/agents/thoth.d.ts +37 -0
  12. package/dist/agents/work-master.d.ts +2 -0
  13. package/dist/cli.d.ts +9 -0
  14. package/dist/cli.js +220 -0
  15. package/dist/config/index.d.ts +1 -0
  16. package/dist/config/schema.d.ts +99 -0
  17. package/dist/defaults/AGENTS.md +53 -0
  18. package/dist/defaults/skill/cal-grid/SKILL.md +16 -0
  19. package/dist/defaults/skill/capsule-init/SKILL.md +102 -0
  20. package/dist/defaults/skill/cross-linker/SKILL.md +357 -0
  21. package/dist/defaults/skill/evening-close/SKILL.md +91 -0
  22. package/dist/defaults/skill/gardener/SKILL.md +248 -0
  23. package/dist/defaults/skill/gardener/confidence-tiers.md +142 -0
  24. package/dist/defaults/skill/gardener/repair-workflow.md +170 -0
  25. package/dist/defaults/skill/google-chat-scan/SKILL.md +135 -0
  26. package/dist/defaults/skill/handover/SKILL.md +18 -0
  27. package/dist/defaults/skill/interview-prep/SKILL.md +23 -0
  28. package/dist/defaults/skill/leadership-coach/SKILL.md +160 -0
  29. package/dist/defaults/skill/link-retrofit/SKILL.md +345 -0
  30. package/dist/defaults/skill/mail-triage/SKILL.md +16 -0
  31. package/dist/defaults/skill/morning-boot/SKILL.md +98 -0
  32. package/dist/defaults/skill/post-meeting-drill/SKILL.md +479 -0
  33. package/dist/defaults/skill/restore-environment/SKILL.md +30 -0
  34. package/dist/defaults/skill/scorecard-synthesis/SKILL.md +26 -0
  35. package/dist/defaults/skill/skill-generator/SKILL.md +240 -0
  36. package/dist/defaults/skill/skill-generator/testing-protocol.md +158 -0
  37. package/dist/defaults/skill/slack-pulse/SKILL.md +16 -0
  38. package/dist/defaults/skill/system-init/SKILL.md +103 -0
  39. package/dist/defaults/skill/thought-router/SKILL.md +80 -0
  40. package/dist/hooks/context-aperture.d.ts +37 -0
  41. package/dist/hooks/context-aperture.test.d.ts +1 -0
  42. package/dist/hooks/directory-agents-injector/constants.d.ts +6 -0
  43. package/dist/hooks/directory-agents-injector/index.d.ts +21 -0
  44. package/dist/hooks/directory-agents-injector/storage.d.ts +8 -0
  45. package/dist/hooks/directory-agents-injector/types.d.ts +24 -0
  46. package/dist/hooks/index.d.ts +4 -0
  47. package/dist/hooks/permission-enforcer.d.ts +15 -0
  48. package/dist/hooks/permission-enforcer.test.d.ts +1 -0
  49. package/dist/hooks/temporal-awareness.d.ts +31 -0
  50. package/dist/hooks/temporal-awareness.test.d.ts +1 -0
  51. package/dist/hooks/trust-level-tracker.d.ts +58 -0
  52. package/dist/hooks/trust-level-tracker.test.d.ts +1 -0
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.js +31196 -0
  55. package/dist/shared/index.d.ts +21 -0
  56. package/dist/shared-hooks/background-agent/index.d.ts +2 -0
  57. package/dist/shared-hooks/background-agent/manager.d.ts +39 -0
  58. package/dist/shared-hooks/background-agent/types.d.ts +30 -0
  59. package/dist/shared-hooks/background-notification/index.d.ts +12 -0
  60. package/dist/shared-hooks/background-notification/types.d.ts +4 -0
  61. package/dist/shared-hooks/context-window-monitor.d.ts +18 -0
  62. package/dist/shared-hooks/index.d.ts +7 -0
  63. package/dist/shared-hooks/session-recovery/constants.d.ts +6 -0
  64. package/dist/shared-hooks/session-recovery/index.d.ts +21 -0
  65. package/dist/shared-hooks/session-recovery/storage.d.ts +19 -0
  66. package/dist/shared-hooks/session-recovery/types.d.ts +90 -0
  67. package/dist/shared-hooks/todo-continuation-enforcer.d.ts +12 -0
  68. package/dist/shared-hooks/utils/constants.d.ts +6 -0
  69. package/dist/shared-hooks/utils/index.d.ts +5 -0
  70. package/dist/shared-hooks/utils/logger.d.ts +2 -0
  71. package/dist/shared-hooks/utils/message-storage.d.ts +6 -0
  72. package/dist/shared-hooks/utils/session-state.d.ts +4 -0
  73. package/dist/shared-hooks/utils/types.d.ts +141 -0
  74. package/dist/specialization/boot-sequences.d.ts +19 -0
  75. package/dist/specialization/detector.d.ts +20 -0
  76. package/dist/specialization/index.d.ts +10 -0
  77. package/dist/specialization/prompt-builder.d.ts +30 -0
  78. package/dist/specialization/prompt-sections.d.ts +19 -0
  79. package/dist/specialization/types.d.ts +86 -0
  80. package/dist/thoth-plugin.schema.json +7 -0
  81. package/dist/tools/background-task/constants.d.ts +3 -0
  82. package/dist/tools/background-task/index.d.ts +2 -0
  83. package/dist/tools/background-task/tools.d.ts +7 -0
  84. package/dist/tools/background-task/types.d.ts +14 -0
  85. package/dist/tools/index.d.ts +2 -0
  86. package/dist/tools/skill/index.d.ts +2 -0
  87. package/dist/tools/skill/tools.d.ts +2 -0
  88. package/dist/tools/skill/types.d.ts +37 -0
  89. package/package.json +54 -0
@@ -0,0 +1,357 @@
1
+ ---
2
+ name: cross-linker
3
+ description: Proactive cross-reference discovery. Scans knowledge base for missing [[wikilinks]] using rule-based confidence tiers. Suggests and applies bidirectional links with approval gates.
4
+ ---
5
+
6
+ # Cross-Linker Skill
7
+
8
+ You are the **Knowledge Base Cross-Linker**. Your role is to discover and create meaningful connections between files that should be linked but aren't.
9
+
10
+ Unlike the Gardener (which fixes broken links), you **proactively find missing links** based on content analysis.
11
+
12
+ ## Philosophy
13
+
14
+ > "A link should exist if a reader of file A would benefit from knowing about file B."
15
+
16
+ **Key Principle**: Don't guess. Use evidence. More evidence = higher confidence.
17
+
18
+ ---
19
+
20
+ ## Operating Modes
21
+
22
+ | Mode | Command | Action | Writes |
23
+ |------|---------|--------|--------|
24
+ | **Scan** | `/cross-linker` or `/cross-linker scan` | Discover and report suggestions | No |
25
+ | **Scan Subset** | `/cross-linker scan <path>` | Scan specific folder only | No |
26
+ | **Apply** | `/cross-linker apply` | Apply approved suggestions | Yes |
27
+ | **Single File** | `/cross-linker file <path>` | Find links for one file | No |
28
+
29
+ ---
30
+
31
+ ## Confidence Tiers
32
+
33
+ **DO NOT estimate confidence as a number.** Instead, count evidence signals.
34
+
35
+ | Tier | Evidence Required | Action |
36
+ |------|-------------------|--------|
37
+ | **CERTAIN** (99%) | Explicit name match in content | Auto-suggest, recommend apply |
38
+ | **STRONG** (90%) | 2+ signals from the checklist | Suggest with review |
39
+ | **MEDIUM** (70%) | 1 signal from the checklist | List for consideration |
40
+ | **WEAK** (<50%) | Semantic similarity only | Ignore (too risky) |
41
+
42
+ ### Evidence Checklist
43
+
44
+ For each potential link from File A → File B, check these boxes:
45
+
46
+ ```
47
+ □ EXPLICIT_MENTION: File A contains the exact title/name of File B
48
+ □ RELATED_FRONTMATTER: File A's `related:` field mentions File B (but no [[link]])
49
+ □ SHARED_TAGS: Files share ≥2 tags in frontmatter
50
+ □ SAME_PROJECT: Files are in the same project folder
51
+ □ RECIPROCAL_MISSING: File B links to A, but A doesn't link to B
52
+ □ PERSON_MENTION: File A mentions a person name that matches a person file
53
+ □ PROJECT_MENTION: File A mentions a project name that matches a project file
54
+ ```
55
+
56
+ **Scoring:**
57
+ - EXPLICIT_MENTION alone = CERTAIN
58
+ - RECIPROCAL_MISSING alone = CERTAIN
59
+ - RELATED_FRONTMATTER alone = STRONG
60
+ - 2+ other signals = STRONG
61
+ - 1 signal = MEDIUM
62
+ - 0 signals = WEAK (ignore)
63
+
64
+ ---
65
+
66
+ ## Mode 1: Full Scan
67
+
68
+ ### Step 1: Build File Index
69
+
70
+ For each `.md` file in the knowledge base, extract:
71
+
72
+ ```yaml
73
+ file: "work/people/john-smith.md"
74
+ title: "John Smith" # From H1 or filename
75
+ aliases: ["John", "JS"] # Common variations
76
+ tags: ["engineering", "team-lead"] # From frontmatter
77
+ related: ["work/projects/apollo.md"] # From frontmatter
78
+ existing_links: ["[[jane-doe]]", ...] # Already linked
79
+ parent_folder: "work/people/" # Context
80
+ summary: "Engineering lead for..." # First 100 chars or frontmatter summary
81
+ ```
82
+
83
+ **Skip these files:**
84
+ - Files in `Archive/`, `templates/`, `tmp/`
85
+ - Files matching `TEMPLATE-*`
86
+ - Non-hemisphere files (root level)
87
+
88
+ ### Step 2: Build Entity Registry
89
+
90
+ Create lookup tables for fast matching:
91
+
92
+ ```
93
+ PEOPLE: {
94
+ "john smith" → "work/people/john-smith.md",
95
+ "john" → "work/people/john-smith.md", // if unambiguous
96
+ "jane doe" → "work/people/jane-doe.md",
97
+ ...
98
+ }
99
+
100
+ PROJECTS: {
101
+ "apollo" → "work/projects/apollo/",
102
+ "project apollo" → "work/projects/apollo/",
103
+ ...
104
+ }
105
+
106
+ TAGS: {
107
+ "hiring" → ["work/people/john.md", "work/projects/recruiting.md", ...],
108
+ ...
109
+ }
110
+ ```
111
+
112
+ ### Step 3: Scan for Missing Links
113
+
114
+ For each file, check:
115
+
116
+ 1. **Explicit Mentions**: Does the content contain any entity from the registry that isn't already linked?
117
+ 2. **Related Field**: Does `related:` reference files without `[[wikilinks]]` in the body?
118
+ 3. **Reciprocal Links**: Do any files link TO this file without a return link?
119
+ 4. **Tag Clusters**: Are there files with 2+ shared tags that aren't linked?
120
+ 5. **Folder Siblings**: Are there unlinked files in the same project folder?
121
+
122
+ ### Step 4: Score and Tier
123
+
124
+ For each candidate link, count evidence signals and assign tier.
125
+
126
+ ### Step 5: Generate Report
127
+
128
+ Output a structured report:
129
+
130
+ ```markdown
131
+ ## Cross-Reference Scan Report
132
+
133
+ **Scanned**: {timestamp}
134
+ **Files Analyzed**: {count}
135
+ **Suggestions Found**: {count}
136
+
137
+ ---
138
+
139
+ ### CERTAIN (Auto-Apply Recommended)
140
+
141
+ These have explicit evidence and are safe to apply:
142
+
143
+ | Source | Target | Evidence |
144
+ |--------|--------|----------|
145
+ | `work/notes/meeting-2024-01.md` | `[[john-smith]]` | Name "John Smith" appears on line 12 |
146
+ | `work/projects/apollo/status.md` | `[[jane-doe]]` | Reciprocal: jane-doe.md links here |
147
+
148
+ **Apply all CERTAIN links?** (12 links) [Awaiting approval]
149
+
150
+ ---
151
+
152
+ ### STRONG (Review Recommended)
153
+
154
+ These have multiple signals but should be verified:
155
+
156
+ | Source | Target | Evidence |
157
+ |--------|--------|----------|
158
+ | `work/projects/hiring.md` | `[[recruiting-process]]` | Shared tags: hiring, process; Same folder |
159
+
160
+ **Review STRONG links?** (8 links) [Awaiting approval]
161
+
162
+ ---
163
+
164
+ ### MEDIUM (Optional)
165
+
166
+ Single-signal matches. Apply only if you recognize the connection:
167
+
168
+ | Source | Target | Evidence |
169
+ |--------|--------|----------|
170
+ | `life/health/fitness.md` | `[[nutrition]]` | Shared tag: health |
171
+
172
+ **Show MEDIUM links?** (23 links) [Default: skip]
173
+
174
+ ---
175
+
176
+ ### Statistics
177
+
178
+ | Tier | Count | Recommended Action |
179
+ |------|-------|-------------------|
180
+ | CERTAIN | 12 | Apply |
181
+ | STRONG | 8 | Review |
182
+ | MEDIUM | 23 | Skip |
183
+ | WEAK | 47 | Ignored |
184
+
185
+ ### Files with Most Missing Links
186
+ 1. `work/notes/meeting-2024-01.md` - 5 suggestions
187
+ 2. `work/projects/apollo/readme.md` - 4 suggestions
188
+ 3. ...
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Mode 2: Scan Subset
194
+
195
+ Same as Mode 1, but scoped to a specific path:
196
+
197
+ ```
198
+ /cross-linker scan work/people/
199
+ /cross-linker scan work/projects/apollo/
200
+ ```
201
+
202
+ Useful for:
203
+ - Testing the skill on a small set first
204
+ - Focusing on a specific area after adding new files
205
+
206
+ ---
207
+
208
+ ## Mode 3: Apply Links
209
+
210
+ ### Pre-Requisites
211
+
212
+ 1. A scan must have been run in this session
213
+ 2. User must approve which tiers to apply
214
+
215
+ ### Approval Flow
216
+
217
+ ```
218
+ You: "Apply all CERTAIN links? (12 links)"
219
+ User: "yes"
220
+ You: [Apply 12 links]
221
+
222
+ You: "Review STRONG links? (8 links)"
223
+ User: "show me"
224
+ You: [Show detailed list with context]
225
+ User: "apply 1, 3, 5, skip rest"
226
+ You: [Apply selected links]
227
+ ```
228
+
229
+ ### Link Insertion Protocol
230
+
231
+ When adding a `[[wikilink]]`:
232
+
233
+ 1. **Find the right location** in the source file:
234
+ - If mentioning a person/project by name → replace the name with `[[link|name]]`
235
+ - If no natural location → add to a "Related" section at the bottom
236
+
237
+ 2. **Make it bidirectional** (if not already):
238
+ - Check if target file links back
239
+ - If not, add a "Referenced by" or "Related" section to target
240
+
241
+ 3. **Preserve formatting**:
242
+ - Don't break existing sentences
243
+ - Use aliases when the link text differs from filename: `[[john-smith|John]]`
244
+
245
+ ### Example Transformations
246
+
247
+ **Before (source file):**
248
+ ```markdown
249
+ Met with John Smith to discuss the Apollo project timeline.
250
+ ```
251
+
252
+ **After:**
253
+ ```markdown
254
+ Met with [[john-smith|John Smith]] to discuss the [[apollo|Apollo]] project timeline.
255
+ ```
256
+
257
+ **Target file (john-smith.md) - add if missing:**
258
+ ```markdown
259
+ ## Referenced By
260
+ - [[meeting-2024-01]] - Meeting notes mentioning this person
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Mode 4: Single File
266
+
267
+ Analyze one file and suggest links:
268
+
269
+ ```
270
+ /cross-linker file work/notes/new-meeting.md
271
+ ```
272
+
273
+ Useful for:
274
+ - Just created a new file, want to connect it
275
+ - Checking a specific file's link coverage
276
+
277
+ ### Output
278
+
279
+ ```markdown
280
+ ## Link Suggestions for: work/notes/new-meeting.md
281
+
282
+ ### Found Entities
283
+ - "John Smith" (line 5) → [[john-smith]] ✓ CERTAIN
284
+ - "Apollo" (line 8) → [[apollo]] ✓ CERTAIN
285
+ - "hiring" (tag) → [[recruiting-process]] ? MEDIUM
286
+
287
+ ### Missing Reciprocal Links
288
+ - [[jane-doe]] links to this file's folder but not this file
289
+
290
+ ### Suggested Actions
291
+ 1. Add [[john-smith|John Smith]] on line 5
292
+ 2. Add [[apollo|Apollo]] on line 8
293
+ 3. Consider linking to [[recruiting-process]] (shared tag)
294
+
295
+ **Apply suggestions?** [Awaiting approval]
296
+ ```
297
+
298
+ ---
299
+
300
+ ## Technical Constraints
301
+
302
+ ### Safety Rules
303
+
304
+ 1. **NEVER create links without evidence** - No "vibes-based" linking
305
+ 2. **NEVER modify content meaning** - Only add links, don't rewrite sentences
306
+ 3. **ALWAYS preserve existing links** - Don't duplicate or override
307
+ 4. **ALWAYS use aliases** when link text differs from filename
308
+ 5. **BATCH operations require approval** - No silent mass changes
309
+
310
+ ### Entity Matching Rules
311
+
312
+ **Person names:**
313
+ - Match full name: "John Smith" → `john-smith.md`
314
+ - Match first name ONLY if unambiguous (only one John in KB)
315
+ - Case-insensitive matching
316
+ - Handle common variations: "John" / "John Smith" / "J. Smith"
317
+
318
+ **Project names:**
319
+ - Match folder name or title
320
+ - Match common abbreviations if defined in frontmatter aliases
321
+
322
+ **Avoid false positives:**
323
+ - Common words that happen to match file names (e.g., "life" matching `life/`)
324
+ - Partial matches (e.g., "Apollo 11" shouldn't match `apollo/` if it's about space)
325
+
326
+ ### Performance
327
+
328
+ For large knowledge bases (500+ files):
329
+ - Process in batches by hemisphere
330
+ - Cache the entity registry between runs
331
+ - Skip unchanged files (check mtime)
332
+
333
+ ---
334
+
335
+ ## Integration with Gardener
336
+
337
+ The Cross-Linker complements the Gardener:
338
+
339
+ | Gardener | Cross-Linker |
340
+ |----------|--------------|
341
+ | Fixes broken links | Creates missing links |
342
+ | Reactive (finds problems) | Proactive (finds opportunities) |
343
+ | Deterministic rules | Evidence-based suggestions |
344
+ | Run after migrations | Run after adding content |
345
+
346
+ **Recommended workflow:**
347
+ 1. Create new content
348
+ 2. Run `/cross-linker file <new-file>` to connect it
349
+ 3. Periodically run `/cross-linker scan` for full coverage
350
+ 4. Run `/gardener check` to verify no broken links
351
+
352
+ ---
353
+
354
+ ## Example Session
355
+
356
+ ```
357
+ User: /cross-linker scan work/
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: evening-close
3
+ description: Summarize the day, extract incomplete tasks into tomorrow's overflow, and persist daily learnings to the Knowledge Base.
4
+ ---
5
+
6
+ # Evening Close Skill
7
+
8
+ You are the **Integrity & Persistence Lead**. Your goal is to ensure that every win, decision, and observation from the day is properly archived and that tomorrow begins with total clarity.
9
+
10
+ ## Protocol Execution
11
+
12
+ ### Step 1: Audit
13
+
14
+ 1. **Read Daily Log**: Load today's `work/logs/YYYY-MM-DD-daily-log.md`.
15
+ 2. **Verify Progress**:
16
+ - Compare **Top 3 Priorities** against the **Action Log**.
17
+ - Identify any items marked incomplete or not mentioned in the Action Log.
18
+
19
+ ### Step 2: Summarize
20
+
21
+ 1. **Generate Executive Recap**:
22
+ - **Completed**: Count of actions taken.
23
+ - **Key Wins**: 2-3 most impactful accomplishments.
24
+ - **Blockers Surfaced**: Any items preventing progress.
25
+ - **Decisions Logged**: Summary of strategic choices.
26
+
27
+ 2. **Update Log**: Fill in the `## Evening Summary` section of the `daily-log.md`:
28
+ - Completed items
29
+ - Blocked items
30
+ - Deferred items
31
+ - Key Wins
32
+ - Key Decisions
33
+ - Observations
34
+
35
+ ### Step 3: Extract Overflow
36
+
37
+ 1. **Identify Incomplete Tasks**: Collect all P0/P1 items from Priorities and Pending Responses that were NOT completed.
38
+
39
+ 2. **Create Overflow File**: Write to `work/inbox/overflow-YYYY-MM-DD.md`:
40
+ ```yaml
41
+ ---
42
+ type: overflow
43
+ from_date: YYYY-MM-DD
44
+ for_date: YYYY-MM-DD (tomorrow)
45
+ ---
46
+
47
+ # Overflow Tasks
48
+
49
+ ## From [Date]
50
+
51
+ - [ ] [P0] Task description - Reason: [why not completed]
52
+ - [ ] [P1] Task description - Reason: [why not completed]
53
+ ```
54
+
55
+ ### Step 4: Knowledge Persistence (The Save)
56
+
57
+ Using **Smart Merge** (append-only, never overwrite), update the permanent Knowledge base:
58
+
59
+ 1. **People Profiles**: Extract notes about specific people and append to their `work/people/[person].md` in the `## Interaction Log` section with date stamp.
60
+
61
+ 2. **Project Files**: Extract decisions and append to relevant `work/projects/[project].md` in the `## Decisions` section with date stamp.
62
+
63
+ 3. **Chronicle Entry**: Write a single, high-fidelity sentence summarizing the day's primary outcome to `work/chronicle.md`:
64
+ ```
65
+ ## YYYY-MM-DD
66
+ [One sentence summary of day's state and primary outcome]
67
+ ```
68
+
69
+ ### Step 5: Weekly Maintenance (Friday Only)
70
+
71
+ 1. **Check Date**: Calculate `DayOfWeek` from `<omo-env>`.
72
+ 2. **If Friday**:
73
+ - Run system hygiene checks
74
+ - Review week's chronicle entries
75
+ - Identify patterns or recurring blockers
76
+ - Suggest focus areas for next week
77
+
78
+ ### Step 6: Finalize
79
+
80
+ 1. Verify all file writes were successful.
81
+ 2. Present the summary and overflow list to user in chat for final sign-off.
82
+ 3. Suggest any preparation needed for tomorrow.
83
+
84
+ ---
85
+
86
+ ## Technical Constraints
87
+
88
+ - **Smart Merge**: NEVER overwrite existing context. Only append to specific sections with a date stamp.
89
+ - **Accuracy**: Do not hallucinate outcomes. If an item status is unclear, mark it as "UNCLEAR" and ask user.
90
+ - **Trust Level**: This skill requires Trust Level 2+ for file writes to knowledge base.
91
+ - **Privacy**: Summarize sensitive information, don't copy verbatim.
@@ -0,0 +1,248 @@
1
+ ---
2
+ name: gardener
3
+ description: Use when knowledge base health needs checking, broken links need fixing, orphan files need registering, or cross-references between related files are missing
4
+ ---
5
+
6
+ # Gardener Skill
7
+
8
+ You are the **Knowledge Base Gardener**. Your role is to maintain the structural integrity and connectivity of the Thoth knowledge base.
9
+
10
+ **Core principle:** A healthy knowledge base has no broken links, no orphan files, and rich cross-references between related content.
11
+
12
+ ---
13
+
14
+ ## Operating Modes
15
+
16
+ | Mode | Command | Action | Writes |
17
+ |------|---------|--------|--------|
18
+ | **Health Check** | `/gardener` or `/gardener check` | Scan and report | No |
19
+ | **Repair Plan** | `/gardener plan` | Generate repair-plan.md | Plan only |
20
+ | **Execute Repairs** | `/gardener fix` | Apply fixes with approval | Yes |
21
+ | **Cross-Reference** | `/gardener link [path]` | Suggest missing links | No (suggest only) |
22
+ | **Cross-Reference Apply** | `/gardener link [path] --apply` | Add approved links | Yes |
23
+
24
+ ---
25
+
26
+ ## Mode 1: Health Check
27
+
28
+ ### Step 1: Run Scan
29
+
30
+ ```bash
31
+ npx tsx scripts/gardener-scan.ts --verbose
32
+ ```
33
+
34
+ ### Step 2: Synthesize Report
35
+
36
+ ```markdown
37
+ ## Knowledge Base Health Report
38
+
39
+ **Scanned**: {timestamp}
40
+ **Total Files**: {count}
41
+ **Overall Health**: {healthy|needs-attention|critical}
42
+
43
+ ### Summary
44
+ | Category | Count | Severity |
45
+ |----------|-------|----------|
46
+ | Frontmatter Issues | X | warning |
47
+ | Broken Links | X | error |
48
+ | Orphan Files | X | warning |
49
+ | Registry Ghosts | X | error |
50
+
51
+ ### Critical Issues (Top 10)
52
+ {List with file path and issue}
53
+
54
+ ### Recommendations
55
+ {3-5 prioritized actions}
56
+ ```
57
+
58
+ ---
59
+
60
+ ## Mode 2: Repair Plan
61
+
62
+ See [repair-workflow.md](repair-workflow.md) for detailed repair plan generation and execution protocol.
63
+
64
+ ---
65
+
66
+ ## Mode 3: Execute Repairs
67
+
68
+ **CRITICAL: Require explicit approval for each phase.**
69
+
70
+ See [repair-workflow.md](repair-workflow.md) for execution protocol.
71
+
72
+ ---
73
+
74
+ ## Mode 4: Cross-Reference Analysis
75
+
76
+ This mode finds missing links between related files.
77
+
78
+ ### Step 1: Build Entity Index
79
+
80
+ For the target scope (single file or directory), extract:
81
+
82
+ ```
83
+ For each .md file:
84
+ - filename (normalized: haardik-tarneja.md → "haardik tarneja")
85
+ - H1 title
86
+ - summary from frontmatter
87
+ - tags from frontmatter
88
+ - related from frontmatter
89
+ - existing [[wikilinks]]
90
+ - parent folder (context: work/projects/, work/Stakeholders/)
91
+ ```
92
+
93
+ ### Step 2: Find Candidates
94
+
95
+ For each file, search for mentions of OTHER files' entities:
96
+
97
+ | Signal | Detection | Confidence Tier |
98
+ |--------|-----------|-----------------|
99
+ | Exact name match | "Tom Jansson" in text, `tom-jansson.md` exists | CERTAIN |
100
+ | Title match | "Golden Ticket" in text, file titled "Golden Ticket" exists | CERTAIN |
101
+ | Filename stem match | "haardik" in text, `haardik-tarneja.md` exists | STRONG |
102
+ | In `related:` but no link | `related: [golden-ticket.md]` but no `[[golden-ticket]]` in body | CERTAIN |
103
+ | Same project folder | Both in `work/projects/golden-ticket/` | MEDIUM |
104
+ | Shared tags (2+) | Both have `tags: [iam, automation]` | MEDIUM |
105
+ | Missing bidirectional | A→B exists, B→A missing | STRONG |
106
+
107
+ ### Step 3: Apply Confidence Tiers
108
+
109
+ See [confidence-tiers.md](confidence-tiers.md) for detailed tier definitions.
110
+
111
+ **Quick Reference:**
112
+
113
+ | Tier | Evidence Required | Action |
114
+ |------|-------------------|--------|
115
+ | **CERTAIN** | Exact name/title match OR in `related:` without link | Auto-suggest, recommend apply |
116
+ | **STRONG** | 2+ signals OR missing bidirectional | Suggest with explanation |
117
+ | **MEDIUM** | 1 signal (shared tags, same folder) | List for review |
118
+ | **WEAK** | Semantic similarity only | Ignore |
119
+
120
+ ### Step 4: Output Suggestions
121
+
122
+ ```markdown
123
+ ## Cross-Reference Suggestions for {file}
124
+
125
+ ### CERTAIN (auto-apply recommended)
126
+ | Target | Evidence | Suggested Link |
127
+ |--------|----------|----------------|
128
+ | tom-jansson.md | "Tom Jansson" mentioned line 45 | `[[work/Stakeholders/tom-jansson.md|Tom Jansson]]` |
129
+
130
+ ### STRONG (review recommended)
131
+ | Target | Evidence | Suggested Link |
132
+ |--------|----------|----------------|
133
+ | golden-ticket.md | Missing bidirectional (target links here) | `[[work/projects/golden-ticket.md|Golden Ticket]]` |
134
+
135
+ ### MEDIUM (optional)
136
+ | Target | Evidence |
137
+ |--------|----------|
138
+ | meteor.md | Shared tags: [iam] |
139
+
140
+ **Apply CERTAIN links?** (yes/no/review-each)
141
+ ```
142
+
143
+ ### Step 5: Apply Links (if approved)
144
+
145
+ For each approved link:
146
+ 1. Find appropriate location in file (near first mention, or in Related section)
147
+ 2. Insert `[[path|Display Name]]` format
148
+ 3. If bidirectional, also add reverse link to target file
149
+ 4. Update `related:` frontmatter if not already present
150
+
151
+ ---
152
+
153
+ ## Technical Constraints
154
+
155
+ ### File Safety Rules
156
+
157
+ 1. **NEVER** delete files without explicit confirmation
158
+ 2. **NEVER** modify content sections - only frontmatter and links
159
+ 3. **ALWAYS** preserve existing frontmatter fields
160
+ 4. **ALWAYS** log changes to `kernel/memory/repairs.md`
161
+
162
+ ### Link Format Standards
163
+
164
+ ```markdown
165
+ # Preferred formats:
166
+ [[work/Stakeholders/tom-jansson.md|Tom Jansson]] # Full path with alias
167
+ [[tom-jansson]] # Short form (same folder)
168
+
169
+ # Avoid:
170
+ [[../Stakeholders/tom-jansson|Tom]] # Relative paths
171
+ [Tom Jansson](../Stakeholders/tom-jansson.md) # Markdown links for internal
172
+ ```
173
+
174
+ ### Entity Matching Rules
175
+
176
+ 1. **Case-insensitive** matching for names
177
+ 2. **Normalize** filenames: `haardik-tarneja.md` → "haardik tarneja"
178
+ 3. **Handle aliases**: `@haardik.tarneja` should match `haardik-tarneja.md`
179
+ 4. **Ignore common words**: "the", "a", "project", "team"
180
+ 5. **Match partial names carefully**: "Tom" alone is MEDIUM, "Tom Jansson" is CERTAIN
181
+
182
+ ---
183
+
184
+ ## Common Mistakes
185
+
186
+ | Mistake | Prevention |
187
+ |---------|------------|
188
+ | Linking every name mention | Only link first meaningful mention per section |
189
+ | Creating circular link spam | Check if link already exists before suggesting |
190
+ | Linking to self | Never suggest `[[file]]` within `file.md` |
191
+ | Over-linking common terms | "IT", "HR", "Q1" are not entities |
192
+ | Ignoring context | "Tom" in "Tom's idea" ≠ "Tom" as standalone reference |
193
+
194
+ ---
195
+
196
+ ## Red Flags - STOP
197
+
198
+ - About to add 50+ links without review
199
+ - Confidence tier unclear for a suggestion
200
+ - Target file doesn't exist (that's a broken link, not cross-ref)
201
+ - Modifying files outside the knowledge base
202
+ - Bulk applying without user seeing the list first
203
+
204
+ ---
205
+
206
+ ## Rationalization Table
207
+
208
+ | Excuse | Reality |
209
+ |--------|---------|
210
+ | "I'll check cross-references later" | Later never comes. Check during file creation. |
211
+ | "Just a few files, I'll do it manually" | Manual = inconsistent. Use the systematic process. |
212
+ | "This name is too common to link" | If a file exists for them, link it. Let confidence tiers decide. |
213
+ | "I already know these are related" | Your knowledge isn't in the file. Make it explicit. |
214
+ | "Linking everything is overkill" | Link CERTAIN matches. That's not overkill, that's hygiene. |
215
+ | "The file is already long enough" | Links don't add length. They add navigability. |
216
+ | "I'll batch this with other cleanup" | Batching = forgetting. Do it now. |
217
+ | "First names are ambiguous" | That's why they're MEDIUM tier, not ignored. Surface them. |
218
+
219
+ ---
220
+
221
+ ## Verification Checklist
222
+
223
+ Before completing cross-reference mode:
224
+
225
+ - [ ] Entity index built for scope
226
+ - [ ] All CERTAIN matches have exact evidence
227
+ - [ ] No self-links suggested
228
+ - [ ] No duplicate links suggested (already exists)
229
+ - [ ] Bidirectional links checked
230
+ - [ ] User approved before any writes
231
+ - [ ] Changes logged to repairs.md
232
+
233
+ ---
234
+
235
+ ## Quick Reference
236
+
237
+ | Task | Command |
238
+ |------|---------|
239
+ | Full health check | `/gardener check` |
240
+ | Generate repair plan | `/gardener plan` |
241
+ | Execute repairs | `/gardener fix` |
242
+ | Analyze one file's links | `/gardener link work/projects/golden-ticket.md` |
243
+ | Analyze a folder | `/gardener link work/Stakeholders/` |
244
+ | Full KB cross-reference audit | `/gardener link --all` |
245
+
246
+ ---
247
+
248
+ *Gardener v3.0 | Part of Thoth Knowledge Management System*