thoth-plugin 1.2.3 → 1.2.5

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 (102) hide show
  1. package/README.md +17 -1
  2. package/defaults/skill/cal-grid/SKILL.md +168 -0
  3. package/defaults/skill/cal-grid/cal-grid-template.md +106 -0
  4. package/defaults/skill/context-discovery/SKILL.md +253 -0
  5. package/defaults/skill/context-discovery/discovery.prose +143 -0
  6. package/defaults/skill/context-onboarding/SKILL.md +370 -0
  7. package/{dist/defaults/skill/_legacy/email-draft/skill.md → defaults/skill/email-draft/SKILL.md} +33 -30
  8. package/defaults/skill/evening-close/SKILL.md +93 -61
  9. package/defaults/skill/evening-close/evening-close-template.md +42 -0
  10. package/{dist/defaults/skill/_legacy → defaults/skill}/gardener/SKILL.md +3 -3
  11. package/{dist/defaults/skill/_legacy → defaults/skill}/google-chat-scan/SKILL.md +7 -0
  12. package/{dist/defaults/skill/_legacy → defaults/skill}/leadership-coach/SKILL.md +9 -8
  13. package/defaults/skill/mail-triage/SKILL.md +272 -15
  14. package/defaults/skill/mail-triage/mail-triage-template.md +90 -0
  15. package/defaults/skill/morning-boot/SKILL.md +214 -25
  16. package/defaults/skill/morning-boot/daily-log-template.md +98 -0
  17. package/defaults/skill/morning-boot/morning-boot.prose +98 -0
  18. package/defaults/skill/{_legacy/onboarding → onboarding}/SKILL.md +7 -6
  19. package/defaults/skill/open-prose/SKILL.md +373 -0
  20. package/defaults/skill/open-prose/antipatterns.md +852 -0
  21. package/defaults/skill/open-prose/docs.md +2676 -0
  22. package/defaults/skill/open-prose/patterns.md +610 -0
  23. package/defaults/skill/open-prose/prose.md +950 -0
  24. package/{dist/defaults/skill/_legacy → defaults/skill}/post-meeting-drill/SKILL.md +90 -95
  25. package/defaults/skill/post-meeting-drill/examples.md +130 -0
  26. package/defaults/skill/post-meeting-drill/post-meeting-drill-template.md +111 -0
  27. package/defaults/skill/skill-generator/SKILL.md +217 -0
  28. package/defaults/skill/skill-generator/skill-template.md +163 -0
  29. package/defaults/skill/slack-pulse/SKILL.md +211 -14
  30. package/defaults/skill/slack-pulse/slack-pulse-template.md +98 -0
  31. package/defaults/skill/slack-write/skill.md +184 -0
  32. package/defaults/skill/thought-router/SKILL.md +7 -8
  33. package/dist/cli.js +137 -3
  34. package/dist/config/schema.d.ts +0 -2
  35. package/dist/defaults/skill/cal-grid/SKILL.md +168 -0
  36. package/dist/defaults/skill/cal-grid/cal-grid-template.md +106 -0
  37. package/dist/defaults/skill/context-discovery/SKILL.md +253 -0
  38. package/dist/defaults/skill/context-discovery/discovery.prose +143 -0
  39. package/dist/defaults/skill/context-onboarding/SKILL.md +370 -0
  40. package/{defaults/skill/_legacy/email-draft/skill.md → dist/defaults/skill/email-draft/SKILL.md} +33 -30
  41. package/dist/defaults/skill/evening-close/SKILL.md +93 -61
  42. package/dist/defaults/skill/evening-close/evening-close-template.md +42 -0
  43. package/{defaults/skill/_legacy → dist/defaults/skill}/gardener/SKILL.md +3 -3
  44. package/{defaults/skill/_legacy → dist/defaults/skill}/google-chat-scan/SKILL.md +7 -0
  45. package/{defaults/skill/_legacy → dist/defaults/skill}/leadership-coach/SKILL.md +9 -8
  46. package/dist/defaults/skill/mail-triage/SKILL.md +272 -15
  47. package/dist/defaults/skill/mail-triage/mail-triage-template.md +90 -0
  48. package/dist/defaults/skill/morning-boot/SKILL.md +214 -25
  49. package/dist/defaults/skill/morning-boot/daily-log-template.md +98 -0
  50. package/dist/defaults/skill/morning-boot/morning-boot.prose +98 -0
  51. package/dist/defaults/skill/{_legacy/onboarding → onboarding}/SKILL.md +7 -6
  52. package/dist/defaults/skill/open-prose/SKILL.md +373 -0
  53. package/dist/defaults/skill/open-prose/antipatterns.md +852 -0
  54. package/dist/defaults/skill/open-prose/docs.md +2676 -0
  55. package/dist/defaults/skill/open-prose/patterns.md +610 -0
  56. package/dist/defaults/skill/open-prose/prose.md +950 -0
  57. package/{defaults/skill/_legacy → dist/defaults/skill}/post-meeting-drill/SKILL.md +90 -95
  58. package/dist/defaults/skill/post-meeting-drill/examples.md +130 -0
  59. package/dist/defaults/skill/post-meeting-drill/post-meeting-drill-template.md +111 -0
  60. package/dist/defaults/skill/skill-generator/SKILL.md +217 -0
  61. package/dist/defaults/skill/skill-generator/skill-template.md +163 -0
  62. package/dist/defaults/skill/slack-pulse/SKILL.md +211 -14
  63. package/dist/defaults/skill/slack-pulse/slack-pulse-template.md +98 -0
  64. package/dist/defaults/skill/slack-write/skill.md +184 -0
  65. package/dist/defaults/skill/thought-router/SKILL.md +7 -8
  66. package/dist/hooks/index.d.ts +0 -1
  67. package/dist/index.js +26 -189
  68. package/dist/sdk/index.d.ts +1 -1
  69. package/dist/sdk/sentinel-service.d.ts +0 -1
  70. package/dist/sdk/test-harness.d.ts +90 -0
  71. package/dist/sdk/thoth-client.d.ts +1 -0
  72. package/dist/shared/index.d.ts +0 -1
  73. package/dist/specialization/prompt-sections.d.ts +1 -1
  74. package/package.json +1 -1
  75. package/defaults/skill/_legacy/cal-grid/SKILL.md +0 -16
  76. package/defaults/skill/_legacy/skill-generator/SKILL.md +0 -362
  77. package/dist/defaults/skill/_legacy/cal-grid/SKILL.md +0 -16
  78. package/dist/defaults/skill/_legacy/skill-generator/SKILL.md +0 -362
  79. package/dist/hooks/temporal-awareness.d.ts +0 -31
  80. package/dist/hooks/temporal-awareness.test.d.ts +0 -1
  81. /package/defaults/skill/{_legacy/capsule-init → capsule-init}/SKILL.md +0 -0
  82. /package/defaults/skill/{_legacy/cross-linker → cross-linker}/SKILL.md +0 -0
  83. /package/defaults/skill/{_legacy/gardener → gardener}/confidence-tiers.md +0 -0
  84. /package/defaults/skill/{_legacy/gardener → gardener}/repair-workflow.md +0 -0
  85. /package/defaults/skill/{_legacy/handover → handover}/SKILL.md +0 -0
  86. /package/defaults/skill/{_legacy/interview-prep → interview-prep}/SKILL.md +0 -0
  87. /package/defaults/skill/{_legacy/link-retrofit → link-retrofit}/SKILL.md +0 -0
  88. /package/defaults/skill/{_legacy/restore-environment → restore-environment}/SKILL.md +0 -0
  89. /package/defaults/skill/{_legacy/scorecard-synthesis → scorecard-synthesis}/SKILL.md +0 -0
  90. /package/defaults/skill/{_legacy/skill-generator → skill-generator}/testing-protocol.md +0 -0
  91. /package/defaults/skill/{_legacy/system-init → system-init}/SKILL.md +0 -0
  92. /package/dist/defaults/skill/{_legacy/capsule-init → capsule-init}/SKILL.md +0 -0
  93. /package/dist/defaults/skill/{_legacy/cross-linker → cross-linker}/SKILL.md +0 -0
  94. /package/dist/defaults/skill/{_legacy/gardener → gardener}/confidence-tiers.md +0 -0
  95. /package/dist/defaults/skill/{_legacy/gardener → gardener}/repair-workflow.md +0 -0
  96. /package/dist/defaults/skill/{_legacy/handover → handover}/SKILL.md +0 -0
  97. /package/dist/defaults/skill/{_legacy/interview-prep → interview-prep}/SKILL.md +0 -0
  98. /package/dist/defaults/skill/{_legacy/link-retrofit → link-retrofit}/SKILL.md +0 -0
  99. /package/dist/defaults/skill/{_legacy/restore-environment → restore-environment}/SKILL.md +0 -0
  100. /package/dist/defaults/skill/{_legacy/scorecard-synthesis → scorecard-synthesis}/SKILL.md +0 -0
  101. /package/dist/defaults/skill/{_legacy/skill-generator → skill-generator}/testing-protocol.md +0 -0
  102. /package/dist/defaults/skill/{_legacy/system-init → system-init}/SKILL.md +0 -0
package/README.md CHANGED
@@ -151,8 +151,10 @@ Thoth includes built-in skills that trigger automatically based on your intent:
151
151
  | "start my day", "morning routine", "prepare me for the day" | morning-boot |
152
152
  | "end of day", "wrap up", "evening summary" | evening-close |
153
153
  | "check my email", "email triage" | mail-triage |
154
+ | "process meeting notes", "drill meeting" | post-meeting-drill |
154
155
  | "check slack", "slack mentions" | slack-pulse |
155
156
  | "brain dump", "capture this" | thought-router |
157
+ | "draft an email", "write email to" | email-draft |
156
158
 
157
159
  ### Managing Skills
158
160
 
@@ -201,7 +203,16 @@ Use the `skill-generator` skill:
201
203
  /skill-generator
202
204
  ```
203
205
 
204
- Skills are defined in `.opencode/skill/` with YAML frontmatter:
206
+ Skills follow a modular architecture with three components:
207
+
208
+ ```
209
+ skill-name/
210
+ ├── SKILL.md # Workflow logic (required)
211
+ ├── skill-name-template.md # Output template (optional)
212
+ └── skill-name.prose # OpenProse orchestration (optional)
213
+ ```
214
+
215
+ Skills are defined with YAML frontmatter:
205
216
 
206
217
  ```yaml
207
218
  ---
@@ -210,6 +221,9 @@ description: Use when [specific triggers]. Third person.
210
221
  triggers:
211
222
  - phrase that activates this skill
212
223
  - another trigger phrase
224
+ template: my-skill-template.md # Optional output template
225
+ created: 2026-01-01
226
+ updated: 2026-01-01
213
227
  ---
214
228
 
215
229
  # My Skill
@@ -231,6 +245,8 @@ triggers:
231
245
 
232
246
  The `triggers` field enables automatic skill invocation when the user's message matches.
233
247
 
248
+ See `docs/concepts/skill-architecture.md` for the full architecture specification.
249
+
234
250
  ## Sub-Agents
235
251
 
236
252
  Thoth delegates to specialized agents:
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: cal-grid
3
+ description: Map the daily calendar grid identifying meetings, deep work slots, and preparation needs.
4
+ triggers:
5
+ template: cal-grid-template.md
6
+ created: 2026-01-09
7
+ updated: 2026-01-09
8
+ ---
9
+
10
+ <!--
11
+ ARCHITECTURE REFERENCE: docs/concepts/skill-architecture.md
12
+ This skill can be invoked standalone OR as a subagent context template.
13
+ -->
14
+
15
+ # Calendar Grid Skill
16
+
17
+ You are the Daily Grid Architect. Your mission is to scan today's calendar and produce a high-resolution grid of the day.
18
+
19
+ ---
20
+
21
+ ## Context Requirements (EXECUTE FIRST)
22
+
23
+ This skill requires the user's email address for API calls.
24
+
25
+ **Step 0 — Get Identity:**
26
+
27
+ 1. **Check if passed in context**: If you received `context.identity.email`, use it directly.
28
+
29
+ 2. **If not passed, invoke context-discovery skill**: Call `skill({ name: "context-discovery" })` and use the returned `email` value.
30
+
31
+ 3. **Store as `EMAIL`** for use in all API calls below.
32
+
33
+ **If discovery fails**: Stop and report the error from context-discovery.
34
+
35
+ ---
36
+
37
+ ## When to Use
38
+
39
+ - Morning boot calendar scan
40
+ - "What's on my calendar today?"
41
+ - "Any meetings I need to prepare for?"
42
+ - Before planning focus time
43
+
44
+ ---
45
+
46
+ ## Tools Required
47
+
48
+ | Action | Tool | Parameters |
49
+ | ------------ | --------------------------- | ---------------------------------------------------------------------- |
50
+ | Get events | google-workspace_get_events | `user_google_email: {EMAIL}`, `time_min`, `time_max`, `detailed: true` |
51
+ | Write output | write | `work/operations/daily-log/YYYY-MM-DD/cal-grid.md` |
52
+
53
+ ---
54
+
55
+ ## Execution Protocol
56
+
57
+ ### Phase 1: Scan Calendar
58
+
59
+ ```
60
+ google-workspace_get_events(
61
+ user_google_email={EMAIL},
62
+ time_min="YYYY-MM-DDT00:00:00Z", # Today start
63
+ time_max="YYYY-MM-DDT23:59:59Z", # Today end
64
+ detailed=true
65
+ )
66
+ ```
67
+
68
+ Also scan tomorrow for preparation awareness:
69
+ ```
70
+ google-workspace_get_events(
71
+ user_google_email={EMAIL},
72
+ time_min="YYYY-MM-DD+1T00:00:00Z", # Tomorrow start
73
+ time_max="YYYY-MM-DD+1T23:59:59Z", # Tomorrow end
74
+ detailed=true
75
+ )
76
+ ```
77
+
78
+ ### Phase 2: Analyze Each Meeting
79
+
80
+ For each event, determine:
81
+
82
+ | Field | Analysis |
83
+ |-------|----------|
84
+ | **Time** | Start-end in local time |
85
+ | **Event** | Title (clean up noise) |
86
+ | **Attendees** | Who's attending, any VIPs? |
87
+ | **Prep Needed** | What preparation is required? |
88
+ | **Classification** | 1:1, Team, External, Focus, Admin |
89
+
90
+ **Classification Guide:**
91
+
92
+ | Type | Signal |
93
+ |------|--------|
94
+ | 1:1 | Two attendees, recurring |
95
+ | Team | 3+ internal attendees |
96
+ | External | External domain attendees |
97
+ | Focus | Blocked time, no attendees |
98
+ | Admin | Recurring admin tasks |
99
+
100
+ ### Phase 3: Identify Focus Blocks
101
+
102
+ Find gaps between meetings that could be used for deep work:
103
+
104
+ | Block Quality | Duration |
105
+ |---------------|----------|
106
+ | Deep Work | 90+ minutes |
107
+ | Shallow Work | 30-90 minutes |
108
+ | Buffer | <30 minutes |
109
+
110
+ ### Phase 4: Flag Preparation Needs
111
+
112
+ For each meeting, assess:
113
+ - Do I need to review anything beforehand?
114
+ - Are there action items I committed to?
115
+ - Is this a high-stakes meeting (skip-level, external)?
116
+
117
+ ---
118
+
119
+ ## Output Format
120
+
121
+ **Template:** Read `cal-grid-template.md` from this skill folder.
122
+
123
+ **Output path:** `work/operations/daily-log/YYYY-MM-DD/cal-grid.md`
124
+
125
+ Fill the template placeholders with scan results:
126
+
127
+ | Placeholder | Value |
128
+ |-------------|-------|
129
+ | `{{DATE}}` | Today's date (YYYY-MM-DD) |
130
+ | `{{TIME}}` | Scan completion time (HH:MM) |
131
+ | `{{CALENDAR_ID}}` | Calendar scanned (usually "primary") |
132
+ | `{{MEETING_COUNT}}` | Total meetings today |
133
+ | `{{MEETING_HOURS}}` | Total hours in meetings |
134
+ | `{{FOCUS_HOURS}}` | Available focus time |
135
+ | `{{COMPLEXITY}}` | Light/Medium/Heavy |
136
+ | `{{TODAY_MEETINGS_TABLE}}` | Table rows for today's meetings |
137
+ | `{{FOCUS_BLOCKS_TABLE}}` | Table rows for focus blocks |
138
+ | `{{PREP_REQUIRED_TABLE}}` | Table rows for meetings needing prep |
139
+ | `{{CONFLICTS_TABLE}}` | Table rows for conflicts (if any) |
140
+ | `{{TOMORROW_TABLE}}` | Table rows for tomorrow preview |
141
+ | `{{HIGH_PRIORITY_PREP}}` | Urgent prep items |
142
+ | `{{STANDARD_PREP}}` | Standard prep items |
143
+ | `{{DEEP_WORK_STRATEGY}}` | Recommended focus block usage |
144
+
145
+ **Critical:** Output MUST include `## SCAN_DATA_START` and `## SCAN_DATA_END` markers for parsing.
146
+
147
+ ---
148
+
149
+ ## Completion Checklist
150
+
151
+ - [ ] Context discovery completed (have EMAIL)
152
+ - [ ] Today's events scanned
153
+ - [ ] Tomorrow's events scanned for prep
154
+ - [ ] Each meeting classified
155
+ - [ ] Focus blocks identified
156
+ - [ ] Preparation needs flagged
157
+ - [ ] Output written to `work/operations/daily-log/YYYY-MM-DD/cal-grid.md`
158
+ - [ ] SCAN_DATA markers included
159
+
160
+ ---
161
+
162
+ ## Error Handling
163
+
164
+ | Error | Action |
165
+ |-------|--------|
166
+ | No calendar access | Report OAuth needed, stop |
167
+ | Empty calendar | Report "No meetings scheduled", still output focus blocks |
168
+ | API rate limit | Wait and retry once |
@@ -0,0 +1,106 @@
1
+ ---
2
+ type: operations
3
+ hemisphere: work
4
+ created: {{DATE}}
5
+ updated: 2026-01-09
6
+ tags: [cal-grid, daily-log]
7
+ summary: Calendar Grid — {{DATE}}
8
+ ---
9
+
10
+ # Calendar Grid — {{DATE}}
11
+
12
+ **Scan Time:** {{TIME}}
13
+ **Calendar:** {{CALENDAR_ID}}
14
+
15
+ ---
16
+
17
+ ## Day Summary
18
+
19
+ | Metric | Value |
20
+ |--------|-------|
21
+ | **Total meetings** | {{MEETING_COUNT}} |
22
+ | **Meeting hours** | {{MEETING_HOURS}} |
23
+ | **Focus time available** | {{FOCUS_HOURS}} hours |
24
+ | **Complexity** | {{COMPLEXITY}} |
25
+
26
+ ---
27
+
28
+ ## SCAN_DATA_START
29
+
30
+ ### TODAY_MEETINGS
31
+
32
+ | Time | Event | Attendees | Prep | Type |
33
+ |------|-------|-----------|------|------|
34
+ {{TODAY_MEETINGS_TABLE}}
35
+
36
+ ### FOCUS_BLOCKS
37
+
38
+ | Block | Duration | Quality |
39
+ |-------|----------|---------|
40
+ {{FOCUS_BLOCKS_TABLE}}
41
+
42
+ ### PREP_REQUIRED
43
+
44
+ | Time | Meeting | Preparation Needed |
45
+ |------|---------|-------------------|
46
+ {{PREP_REQUIRED_TABLE}}
47
+
48
+ ### CONFLICTS
49
+
50
+ | Issue | Meetings Affected | Recommendation |
51
+ |-------|-------------------|----------------|
52
+ {{CONFLICTS_TABLE}}
53
+
54
+ ### TOMORROW_PREVIEW
55
+
56
+ | Time | Event | Prep Needed |
57
+ |------|-------|-------------|
58
+ {{TOMORROW_TABLE}}
59
+
60
+ ## SCAN_DATA_END
61
+
62
+ ---
63
+
64
+ ## Complexity Budget
65
+
66
+ **Meeting Load: {{COMPLEXITY}}**
67
+
68
+ {{#if COMPLEXITY == "Light"}}
69
+ - 0-2 meetings scheduled
70
+ - Capacity: 2-3 Heavy tasks, multiple Light tasks
71
+ - Recommendation: Use today for deep work
72
+ {{/if}}
73
+
74
+ {{#if COMPLEXITY == "Medium"}}
75
+ - 3-4 meetings scheduled
76
+ - Capacity: 1-2 Heavy tasks, few Light tasks
77
+ - Recommendation: Protect focus blocks aggressively
78
+ {{/if}}
79
+
80
+ {{#if COMPLEXITY == "Heavy"}}
81
+ - 5+ meetings scheduled
82
+ - Capacity: 1 Light task maximum
83
+ - Recommendation: Focus on meetings, defer other work
84
+ {{/if}}
85
+
86
+ ---
87
+
88
+ ## Preparation Alerts
89
+
90
+ ### High Priority
91
+
92
+ {{HIGH_PRIORITY_PREP}}
93
+
94
+ ### Standard
95
+
96
+ {{STANDARD_PREP}}
97
+
98
+ ---
99
+
100
+ ## Deep Work Strategy
101
+
102
+ {{DEEP_WORK_STRATEGY}}
103
+
104
+ ---
105
+
106
+ *Generated by cal-grid skill at {{TIME}}*
@@ -0,0 +1,253 @@
1
+ ---
2
+ name: context-discovery
3
+ description: Use when a skill needs Thoth KB context (identity, stakeholders, projects) and it hasn't been discovered yet this session. Called automatically by morning-boot and other context-dependent skills.
4
+ triggers:
5
+ created: 2026-01-09
6
+ updated: 2026-01-10
7
+ ---
8
+
9
+ <!--
10
+ ARCHITECTURE REFERENCE: docs/concepts/skill-architecture.md
11
+ This skill is typically invoked by other skills, not directly by user.
12
+ -->
13
+
14
+ # Context Discovery
15
+
16
+ **Core principle:** Find the Thoth KB and extract context needed for skills to operate, adapting to the actual file structure rather than assuming an ideal one.
17
+
18
+ ---
19
+
20
+ ## When to Use
21
+
22
+ - Morning-boot or other skills need user context (email, stakeholders)
23
+ - Running from unknown directory and need to find KB root
24
+ - Context hasn't been discovered yet this session
25
+ - User asks "where is my knowledge base"
26
+
27
+ **Do NOT use when:**
28
+ - Context is already cached in session
29
+ - User explicitly provides context (email, etc.)
30
+ - Running a skill that doesn't need KB context
31
+
32
+ ---
33
+
34
+ ## Quick Reference
35
+
36
+ | Task | How |
37
+ |------|-----|
38
+ | Find KB root | Check config → walk up for markers → check siblings |
39
+ | Determine hemisphere | Parse CWD path for `/work/`, `/life/`, `/coding/` |
40
+ | Find email | Read `{hemisphere}/AGENTS.md`, extract from MCP config table |
41
+ | Find stakeholders | Check `{hemisphere}/Stakeholders/_index.md` or `{hemisphere}/people/_index.md` |
42
+ | Cache results | Store in `.thoth-state/context.json` for session reuse |
43
+
44
+ ---
45
+
46
+ ## Discovery Algorithm
47
+
48
+ ### Step 1: Check Explicit Config (Fastest)
49
+
50
+ ```
51
+ Check: ~/.config/opencode/thoth.json
52
+ Look for: { "kb_root": "/path/to/thoth-kb" }
53
+ ```
54
+
55
+ If found, use this path directly. Skip walk-up.
56
+
57
+ ### Step 2: Walk Up for Markers
58
+
59
+ Starting from CWD, check each parent directory for:
60
+
61
+ | Marker | Priority | Indicates |
62
+ |--------|----------|-----------|
63
+ | `.opencode/thoth.json` with `"type": "thoth-kb"` | 1 (best) | Explicit KB marker |
64
+ | `.thoth-root` file | 2 | Simple marker file |
65
+ | `kernel/` + `work/` + `life/` directories | 3 | Structure-based detection |
66
+
67
+ Stop at first match. That's the KB root.
68
+
69
+ ### Step 3: Check Siblings (If Walk-Up Fails)
70
+
71
+ If in a development directory (like `thoth-core`), check sibling directories:
72
+
73
+ ```bash
74
+ ls .. | grep -E "(thoth-kb|kb)"
75
+ ```
76
+
77
+ Look for directories containing `kernel/` or `.opencode/thoth.json`.
78
+
79
+ ### Step 4: Determine Hemisphere
80
+
81
+ Analyze CWD path:
82
+
83
+ | Path Contains | Hemisphere |
84
+ |---------------|------------|
85
+ | `/work/` | work |
86
+ | `/life/` | life |
87
+ | `/coding/` | coding |
88
+ | `/kernel/` | kernel |
89
+ | None of above | unknown |
90
+
91
+ If hemisphere is `unknown` and KB root was found, default based on context:
92
+ - Morning boot → default to `work`
93
+ - Or ask user which hemisphere
94
+
95
+ ### Step 5: Extract Identity
96
+
97
+ Read `{kb_root}/{hemisphere}/AGENTS.md` and find the MCP configuration table:
98
+
99
+ ```markdown
100
+ ## MCP Tool Configuration
101
+
102
+ | MCP Server | Required Parameter | Value |
103
+ |------------|-------------------|-------|
104
+ | google-workspace | user_google_email | user@example.com |
105
+ ```
106
+
107
+ Extract `user_google_email` value.
108
+
109
+ **Fallback locations:**
110
+ 1. `{hemisphere}/AGENTS.md` MCP table (preferred)
111
+ 2. `{hemisphere}/digital-identity.md`
112
+ 3. `{hemisphere}/_identity.md`
113
+ 4. `kernel/config/identity.md`
114
+
115
+ ### Step 6: Locate Stakeholders
116
+
117
+ Check in order (use first that exists):
118
+ 1. `{kb_root}/{hemisphere}/Stakeholders/_index.md`
119
+ 2. `{kb_root}/{hemisphere}/people/_index.md`
120
+ 3. `{kb_root}/{hemisphere}/Team/_index.md` (for direct reports)
121
+
122
+ ### Step 7: Build Context Object
123
+
124
+ ```json
125
+ {
126
+ "kb_root": "/path/to/thoth-kb",
127
+ "hemisphere": "work",
128
+ "identity": {
129
+ "email": "user@example.com",
130
+ "source": "work/AGENTS.md"
131
+ },
132
+ "stakeholders": {
133
+ "path": "work/Stakeholders/_index.md",
134
+ "count": 32
135
+ },
136
+ "projects": {
137
+ "path": "work/projects/_index.md"
138
+ },
139
+ "ready": true,
140
+ "missing": []
141
+ }
142
+ ```
143
+
144
+ ### Step 8: Cache Results
145
+
146
+ Write to `.thoth-state/context.json` in KB root for session reuse.
147
+
148
+ ---
149
+
150
+ ## Output Format
151
+
152
+ Return a structured context object:
153
+
154
+ ```
155
+ CONTEXT DISCOVERY RESULT
156
+ ========================
157
+
158
+ KB Root: /path/to/thoth-kb
159
+ Hemisphere: work
160
+ Source: ~/.config/opencode/thoth.json (or walk-up, or sibling)
161
+
162
+ Identity:
163
+ Email: user@example.com
164
+ Timezone: Europa/Berlin (if found)
165
+ Source: work/AGENTS.md
166
+
167
+ Stakeholders:
168
+ Path: work/Stakeholders/_index.md
169
+ Count: 32 files
170
+
171
+ Projects:
172
+ Path: work/projects/_index.md
173
+
174
+ Ready: YES
175
+ Missing Required: (none)
176
+ Missing Optional: [timezone]
177
+ ```
178
+
179
+ If discovery fails:
180
+
181
+ ```
182
+ CONTEXT DISCOVERY FAILED
183
+ ========================
184
+
185
+ KB Root: NOT FOUND
186
+ Searched:
187
+ - ~/.config/opencode/thoth.json: not found
188
+ - Walk-up from /current/path: no markers found
189
+ - Siblings: no thoth-kb found
190
+
191
+ Action Required: Run context-onboarding to set up KB
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Common Mistakes
197
+
198
+ | Mistake | Prevention |
199
+ |---------|------------|
200
+ | Assuming fixed file paths | Always use discovery algorithm, never hardcode |
201
+ | Not checking config file first | Config is fastest path, always check first |
202
+ | Stopping at first `kernel/` found | Verify it's a real KB (has work/ or life/ too) |
203
+ | Parsing AGENTS.md wrong | Look for MCP table specifically, not general content |
204
+ | Not caching results | Always cache to `.thoth-state/context.json` |
205
+
206
+ ---
207
+
208
+ ## Red Flags - STOP
209
+
210
+ - Hardcoding `/Users/username/...` paths
211
+ - Assuming `_identity.md` exists (it often doesn't)
212
+ - Not handling "hemisphere unknown" case
213
+ - Returning partial results without `ready: false` flag
214
+ - Not reporting what's missing when discovery fails
215
+
216
+ ---
217
+
218
+ ## Verification Checklist
219
+
220
+ - [ ] Can find KB when running from KB root
221
+ - [ ] Can find KB when running from hemisphere subdirectory
222
+ - [ ] Can find KB when running from sibling directory (e.g., thoth-core)
223
+ - [ ] Correctly extracts email from AGENTS.md MCP table
224
+ - [ ] Reports missing files clearly when KB incomplete
225
+ - [ ] Caches results for session reuse
226
+ - [ ] Works for new user with no KB (reports failure, suggests onboarding)
227
+
228
+ ---
229
+
230
+ ## Integration
231
+
232
+ Other skills call discovery like this:
233
+
234
+ ```prose
235
+ # In morning-boot.prose
236
+
237
+ # Check for cached context
238
+ let cached = session "Read .thoth-state/context.json if exists and fresh"
239
+
240
+ if **no cached context or stale**:
241
+ let context = do context-discovery
242
+
243
+ if **context.ready is false**:
244
+ do context-onboarding
245
+ let context = do context-discovery # retry
246
+
247
+ # Use context
248
+ let email = context.identity.email
249
+ ```
250
+
251
+ ---
252
+
253
+ *Context Discovery v1.0 | Part of Thoth Skill System*
@@ -0,0 +1,143 @@
1
+ # Context Discovery Test
2
+ # Validates that AI-driven context discovery works reliably
3
+
4
+ # Phase 1: Environment Discovery
5
+ let discovery = session "Discover Thoth KB environment"
6
+ prompt: """
7
+ You are testing context discovery for Thoth skills.
8
+
9
+ Execute these steps and report findings:
10
+
11
+ ## Step 1: Get Current Location
12
+ Run `pwd` to get the current working directory.
13
+
14
+ ## Step 2: Find KB Root
15
+ Walk up the directory tree looking for markers:
16
+ - `.thoth-root` file (preferred marker)
17
+ - `.opencode/` directory with thoth configuration
18
+ - `kernel/` directory (thoth-kb convention)
19
+
20
+ For each parent directory up to filesystem root, check if these exist.
21
+ Stop when you find a marker.
22
+
23
+ ## Step 3: Determine Hemisphere
24
+ Look at the CWD path:
25
+ - If path contains `/work/` → hemisphere is "work"
26
+ - If path contains `/life/` → hemisphere is "life"
27
+ - If path contains `/coding/` → hemisphere is "coding"
28
+ - Otherwise → hemisphere is "unknown"
29
+
30
+ ## Step 4: Locate Identity Files
31
+ If KB root was found, check for these files (report exists: true/false):
32
+ - `{root}/work/_identity.md`
33
+ - `{root}/life/_identity.md`
34
+ - `{root}/kernel/config/identity.md` (fallback)
35
+
36
+ ## Step 5: Locate Stakeholder Files
37
+ Check for:
38
+ - `{root}/work/people/_index.md`
39
+ - `{root}/life/people/_index.md`
40
+
41
+ ## Report Format
42
+
43
+ Return a structured report:
44
+
45
+ ```
46
+ DISCOVERY REPORT
47
+ ================
48
+
49
+ Current Directory: /path/to/cwd
50
+
51
+ KB Root Search:
52
+ - Checked: /path/to/cwd → no markers
53
+ - Checked: /path/to/parent → found .thoth-root
54
+ - KB Root: /path/to/thoth-kb (or NOT FOUND)
55
+
56
+ Hemisphere Detection:
57
+ - Path analysis: contains "/work/"
58
+ - Detected: work (or life, coding, unknown)
59
+
60
+ Identity Files:
61
+ - work/_identity.md: EXISTS / MISSING
62
+ - life/_identity.md: EXISTS / MISSING
63
+ - kernel/config/identity.md: EXISTS / MISSING
64
+ - Recommended: {path to use}
65
+
66
+ Stakeholder Files:
67
+ - work/people/_index.md: EXISTS / MISSING
68
+ - life/people/_index.md: EXISTS / MISSING
69
+
70
+ Ready Status:
71
+ - Can run morning boot: YES / NO
72
+ - Missing required: [list of missing files]
73
+ - Missing optional: [list of missing files]
74
+ ```
75
+ """
76
+
77
+ # Phase 2: Validate Discovery
78
+ session "Analyze discovery results"
79
+ prompt: """
80
+ Based on the discovery results above, answer:
81
+
82
+ 1. **Discovery Reliability**: Did the walk-up algorithm successfully
83
+ find the KB root? Was the hemisphere correctly inferred?
84
+
85
+ 2. **File Resolution**: Were identity and stakeholder files found
86
+ where expected? Any surprises?
87
+
88
+ 3. **Readiness Assessment**: Could the morning boot skill run with
89
+ the discovered context? What's missing?
90
+
91
+ 4. **Edge Cases Identified**: Any issues with the discovery approach
92
+ that would need handling?
93
+
94
+ 5. **Recommendations**: Suggestions to improve the discovery pattern.
95
+
96
+ Be specific and actionable.
97
+ """
98
+ context: discovery
99
+
100
+ # Phase 3: Simulate Morning Boot Context Loading
101
+ if **KB root was found and identity file exists**:
102
+ let identity = session "Load identity file"
103
+ prompt: """
104
+ Read the identity file that was discovered (the recommended one
105
+ from the discovery report).
106
+
107
+ Extract:
108
+ - Email address
109
+ - Timezone
110
+ - Any other identity context
111
+
112
+ Report what you found.
113
+ """
114
+ context: discovery
115
+
116
+ session "Validate identity is usable"
117
+ prompt: """
118
+ The identity file was loaded. Validate:
119
+
120
+ 1. Is there an email address we can use for Gmail/Calendar APIs?
121
+ 2. Is there a timezone for scheduling context?
122
+ 3. Is the format parseable and consistent?
123
+
124
+ Report whether this identity context is sufficient for morning boot.
125
+ """
126
+ context: identity
127
+
128
+ else:
129
+ session "Guide user to set up identity"
130
+ prompt: """
131
+ No usable KB root or identity file was found.
132
+
133
+ Guide the user to set this up:
134
+
135
+ 1. Explain what's needed (a thoth-kb with identity file)
136
+ 2. Show them the expected structure
137
+ 3. Offer to create a starter identity file if they provide:
138
+ - Their email address
139
+ - Their timezone
140
+
141
+ Be helpful and specific about file locations.
142
+ """
143
+ context: discovery