opencastle 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +215 -0
  3. package/bin/cli.mjs +69 -0
  4. package/dist/cli/adapters/claude-code.d.ts +22 -0
  5. package/dist/cli/adapters/claude-code.d.ts.map +1 -0
  6. package/dist/cli/adapters/claude-code.js +237 -0
  7. package/dist/cli/adapters/claude-code.js.map +1 -0
  8. package/dist/cli/adapters/cursor.d.ts +20 -0
  9. package/dist/cli/adapters/cursor.d.ts.map +1 -0
  10. package/dist/cli/adapters/cursor.js +231 -0
  11. package/dist/cli/adapters/cursor.js.map +1 -0
  12. package/dist/cli/adapters/vscode.d.ts +20 -0
  13. package/dist/cli/adapters/vscode.d.ts.map +1 -0
  14. package/dist/cli/adapters/vscode.js +132 -0
  15. package/dist/cli/adapters/vscode.js.map +1 -0
  16. package/dist/cli/copy.d.ts +14 -0
  17. package/dist/cli/copy.d.ts.map +1 -0
  18. package/dist/cli/copy.js +62 -0
  19. package/dist/cli/copy.js.map +1 -0
  20. package/dist/cli/dashboard.d.ts +3 -0
  21. package/dist/cli/dashboard.d.ts.map +1 -0
  22. package/dist/cli/dashboard.js +183 -0
  23. package/dist/cli/dashboard.js.map +1 -0
  24. package/dist/cli/diff.d.ts +3 -0
  25. package/dist/cli/diff.d.ts.map +1 -0
  26. package/dist/cli/diff.js +27 -0
  27. package/dist/cli/diff.js.map +1 -0
  28. package/dist/cli/eject.d.ts +3 -0
  29. package/dist/cli/eject.d.ts.map +1 -0
  30. package/dist/cli/eject.js +27 -0
  31. package/dist/cli/eject.js.map +1 -0
  32. package/dist/cli/init.d.ts +3 -0
  33. package/dist/cli/init.d.ts.map +1 -0
  34. package/dist/cli/init.js +92 -0
  35. package/dist/cli/init.js.map +1 -0
  36. package/dist/cli/manifest.d.ts +14 -0
  37. package/dist/cli/manifest.d.ts.map +1 -0
  38. package/dist/cli/manifest.js +34 -0
  39. package/dist/cli/manifest.js.map +1 -0
  40. package/dist/cli/mcp.d.ts +14 -0
  41. package/dist/cli/mcp.d.ts.map +1 -0
  42. package/dist/cli/mcp.js +35 -0
  43. package/dist/cli/mcp.js.map +1 -0
  44. package/dist/cli/prompt.d.ts +12 -0
  45. package/dist/cli/prompt.d.ts.map +1 -0
  46. package/dist/cli/prompt.js +104 -0
  47. package/dist/cli/prompt.js.map +1 -0
  48. package/dist/cli/run/adapters/claude-code.d.ts +16 -0
  49. package/dist/cli/run/adapters/claude-code.d.ts.map +1 -0
  50. package/dist/cli/run/adapters/claude-code.js +82 -0
  51. package/dist/cli/run/adapters/claude-code.js.map +1 -0
  52. package/dist/cli/run/adapters/copilot.d.ts +16 -0
  53. package/dist/cli/run/adapters/copilot.d.ts.map +1 -0
  54. package/dist/cli/run/adapters/copilot.js +84 -0
  55. package/dist/cli/run/adapters/copilot.js.map +1 -0
  56. package/dist/cli/run/adapters/cursor.d.ts +16 -0
  57. package/dist/cli/run/adapters/cursor.d.ts.map +1 -0
  58. package/dist/cli/run/adapters/cursor.js +81 -0
  59. package/dist/cli/run/adapters/cursor.js.map +1 -0
  60. package/dist/cli/run/adapters/index.d.ts +14 -0
  61. package/dist/cli/run/adapters/index.d.ts.map +1 -0
  62. package/dist/cli/run/adapters/index.js +35 -0
  63. package/dist/cli/run/adapters/index.js.map +1 -0
  64. package/dist/cli/run/executor.d.ts +15 -0
  65. package/dist/cli/run/executor.d.ts.map +1 -0
  66. package/dist/cli/run/executor.js +249 -0
  67. package/dist/cli/run/executor.js.map +1 -0
  68. package/dist/cli/run/reporter.d.ts +10 -0
  69. package/dist/cli/run/reporter.d.ts.map +1 -0
  70. package/dist/cli/run/reporter.js +112 -0
  71. package/dist/cli/run/reporter.js.map +1 -0
  72. package/dist/cli/run/schema.d.ts +28 -0
  73. package/dist/cli/run/schema.d.ts.map +1 -0
  74. package/dist/cli/run/schema.js +511 -0
  75. package/dist/cli/run/schema.js.map +1 -0
  76. package/dist/cli/run.d.ts +6 -0
  77. package/dist/cli/run.d.ts.map +1 -0
  78. package/dist/cli/run.js +123 -0
  79. package/dist/cli/run.js.map +1 -0
  80. package/dist/cli/stack-config.d.ts +12 -0
  81. package/dist/cli/stack-config.d.ts.map +1 -0
  82. package/dist/cli/stack-config.js +146 -0
  83. package/dist/cli/stack-config.js.map +1 -0
  84. package/dist/cli/types.d.ts +169 -0
  85. package/dist/cli/types.d.ts.map +1 -0
  86. package/dist/cli/types.js +2 -0
  87. package/dist/cli/types.js.map +1 -0
  88. package/dist/cli/update.d.ts +3 -0
  89. package/dist/cli/update.d.ts.map +1 -0
  90. package/dist/cli/update.js +50 -0
  91. package/dist/cli/update.js.map +1 -0
  92. package/package.json +48 -0
  93. package/src/cli/adapters/claude-code.ts +287 -0
  94. package/src/cli/adapters/cursor.ts +377 -0
  95. package/src/cli/adapters/vscode.ts +168 -0
  96. package/src/cli/copy.ts +79 -0
  97. package/src/cli/dashboard.ts +225 -0
  98. package/src/cli/diff.ts +44 -0
  99. package/src/cli/eject.ts +39 -0
  100. package/src/cli/init.ts +120 -0
  101. package/src/cli/manifest.ts +45 -0
  102. package/src/cli/mcp.ts +49 -0
  103. package/src/cli/prompt.ts +115 -0
  104. package/src/cli/run/adapters/claude-code.ts +95 -0
  105. package/src/cli/run/adapters/copilot.ts +97 -0
  106. package/src/cli/run/adapters/cursor.ts +94 -0
  107. package/src/cli/run/adapters/index.ts +40 -0
  108. package/src/cli/run/executor.ts +292 -0
  109. package/src/cli/run/reporter.ts +129 -0
  110. package/src/cli/run/schema.ts +595 -0
  111. package/src/cli/run.ts +137 -0
  112. package/src/cli/stack-config.ts +180 -0
  113. package/src/cli/types.ts +207 -0
  114. package/src/cli/update.ts +75 -0
  115. package/src/dashboard/astro.config.mjs +6 -0
  116. package/src/dashboard/package-lock.json +5455 -0
  117. package/src/dashboard/package.json +14 -0
  118. package/src/dashboard/public/data/delegations.ndjson +35 -0
  119. package/src/dashboard/public/data/panels.ndjson +13 -0
  120. package/src/dashboard/public/data/sessions.ndjson +50 -0
  121. package/src/dashboard/public/icon-192.png +0 -0
  122. package/src/dashboard/scripts/generate-seed-data.ts +355 -0
  123. package/src/dashboard/src/layouts/Layout.astro +25 -0
  124. package/src/dashboard/src/pages/index.astro +1070 -0
  125. package/src/dashboard/src/styles/dashboard.css +1078 -0
  126. package/src/dashboard/tsconfig.json +6 -0
  127. package/src/orchestrator/agent-workflows/README.md +22 -0
  128. package/src/orchestrator/agent-workflows/bug-fix.md +128 -0
  129. package/src/orchestrator/agent-workflows/data-pipeline.md +145 -0
  130. package/src/orchestrator/agent-workflows/database-migration.md +159 -0
  131. package/src/orchestrator/agent-workflows/feature-implementation.md +223 -0
  132. package/src/orchestrator/agent-workflows/performance-optimization.md +125 -0
  133. package/src/orchestrator/agent-workflows/refactoring.md +142 -0
  134. package/src/orchestrator/agent-workflows/schema-changes.md +164 -0
  135. package/src/orchestrator/agent-workflows/security-audit.md +148 -0
  136. package/src/orchestrator/agent-workflows/shared-delivery-phase.md +33 -0
  137. package/src/orchestrator/agents/api-designer.agent.md +68 -0
  138. package/src/orchestrator/agents/architect.agent.md +129 -0
  139. package/src/orchestrator/agents/content-engineer.agent.md +57 -0
  140. package/src/orchestrator/agents/copywriter.agent.md +95 -0
  141. package/src/orchestrator/agents/data-expert.agent.md +63 -0
  142. package/src/orchestrator/agents/database-engineer.agent.md +62 -0
  143. package/src/orchestrator/agents/developer.agent.md +66 -0
  144. package/src/orchestrator/agents/devops-expert.agent.md +57 -0
  145. package/src/orchestrator/agents/documentation-writer.agent.md +60 -0
  146. package/src/orchestrator/agents/performance-expert.agent.md +58 -0
  147. package/src/orchestrator/agents/release-manager.agent.md +72 -0
  148. package/src/orchestrator/agents/researcher.agent.md +145 -0
  149. package/src/orchestrator/agents/reviewer.agent.md +62 -0
  150. package/src/orchestrator/agents/security-expert.agent.md +64 -0
  151. package/src/orchestrator/agents/seo-specialist.agent.md +67 -0
  152. package/src/orchestrator/agents/team-lead.agent.md +644 -0
  153. package/src/orchestrator/agents/testing-expert.agent.md +85 -0
  154. package/src/orchestrator/agents/ui-ux-expert.agent.md +63 -0
  155. package/src/orchestrator/copilot-instructions.md +3 -0
  156. package/src/orchestrator/customizations/AGENT-EXPERTISE.md +325 -0
  157. package/src/orchestrator/customizations/AGENT-FAILURES.md +69 -0
  158. package/src/orchestrator/customizations/AGENT-PERFORMANCE.md +58 -0
  159. package/src/orchestrator/customizations/DISPUTES.md +162 -0
  160. package/src/orchestrator/customizations/KNOWLEDGE-GRAPH.md +10 -0
  161. package/src/orchestrator/customizations/LESSONS-LEARNED.md +70 -0
  162. package/src/orchestrator/customizations/README.md +59 -0
  163. package/src/orchestrator/customizations/agents/agent-registry.md +46 -0
  164. package/src/orchestrator/customizations/agents/skill-matrix.md +142 -0
  165. package/src/orchestrator/customizations/logs/README.md +181 -0
  166. package/src/orchestrator/customizations/logs/delegations.ndjson +1 -0
  167. package/src/orchestrator/customizations/logs/panels.ndjson +1 -0
  168. package/src/orchestrator/customizations/logs/sessions.ndjson +1 -0
  169. package/src/orchestrator/customizations/project/docs-structure.md +23 -0
  170. package/src/orchestrator/customizations/project/tracker-config.md +45 -0
  171. package/src/orchestrator/customizations/project.instructions.md +64 -0
  172. package/src/orchestrator/customizations/stack/api-config.md +37 -0
  173. package/src/orchestrator/customizations/stack/cms-config.md +26 -0
  174. package/src/orchestrator/customizations/stack/data-pipeline-config.md +41 -0
  175. package/src/orchestrator/customizations/stack/database-config.md +44 -0
  176. package/src/orchestrator/customizations/stack/deployment-config.md +45 -0
  177. package/src/orchestrator/customizations/stack/testing-config.md +56 -0
  178. package/src/orchestrator/instructions/ai-optimization.instructions.md +143 -0
  179. package/src/orchestrator/instructions/general.instructions.md +194 -0
  180. package/src/orchestrator/mcp.json +55 -0
  181. package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +235 -0
  182. package/src/orchestrator/prompts/brainstorm.prompt.md +115 -0
  183. package/src/orchestrator/prompts/bug-fix.prompt.md +141 -0
  184. package/src/orchestrator/prompts/create-skill.prompt.md +103 -0
  185. package/src/orchestrator/prompts/generate-task-spec.prompt.md +154 -0
  186. package/src/orchestrator/prompts/implement-feature.prompt.md +124 -0
  187. package/src/orchestrator/prompts/metrics-report.prompt.md +142 -0
  188. package/src/orchestrator/prompts/quick-refinement.prompt.md +137 -0
  189. package/src/orchestrator/prompts/resolve-pr-comments.prompt.md +100 -0
  190. package/src/orchestrator/skills/accessibility-standards/SKILL.md +164 -0
  191. package/src/orchestrator/skills/agent-hooks/SKILL.md +147 -0
  192. package/src/orchestrator/skills/agent-memory/SKILL.md +144 -0
  193. package/src/orchestrator/skills/api-patterns/SKILL.md +106 -0
  194. package/src/orchestrator/skills/browser-testing/SKILL.md +203 -0
  195. package/src/orchestrator/skills/code-commenting/SKILL.md +133 -0
  196. package/src/orchestrator/skills/contentful-cms/SKILL.md +43 -0
  197. package/src/orchestrator/skills/context-map/SKILL.md +135 -0
  198. package/src/orchestrator/skills/convex-database/SKILL.md +80 -0
  199. package/src/orchestrator/skills/data-engineering/SKILL.md +99 -0
  200. package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +49 -0
  201. package/src/orchestrator/skills/documentation-standards/SKILL.md +85 -0
  202. package/src/orchestrator/skills/fast-review/SKILL.md +327 -0
  203. package/src/orchestrator/skills/frontend-design/SKILL.md +42 -0
  204. package/src/orchestrator/skills/jira-management/SKILL.md +168 -0
  205. package/src/orchestrator/skills/memory-merger/SKILL.md +123 -0
  206. package/src/orchestrator/skills/nextjs-patterns/SKILL.md +75 -0
  207. package/src/orchestrator/skills/nx-workspace/SKILL.md +192 -0
  208. package/src/orchestrator/skills/panel-majority-vote/SKILL.md +184 -0
  209. package/src/orchestrator/skills/panel-majority-vote/panel-report.template.md +38 -0
  210. package/src/orchestrator/skills/performance-optimization/SKILL.md +101 -0
  211. package/src/orchestrator/skills/react-development/SKILL.md +117 -0
  212. package/src/orchestrator/skills/sanity-cms/SKILL.md +18 -0
  213. package/src/orchestrator/skills/security-hardening/SKILL.md +118 -0
  214. package/src/orchestrator/skills/self-improvement/SKILL.md +137 -0
  215. package/src/orchestrator/skills/seo-patterns/SKILL.md +40 -0
  216. package/src/orchestrator/skills/session-checkpoints/SKILL.md +205 -0
  217. package/src/orchestrator/skills/slack-notifications/SKILL.md +211 -0
  218. package/src/orchestrator/skills/strapi-cms/SKILL.md +43 -0
  219. package/src/orchestrator/skills/supabase-database/SKILL.md +24 -0
  220. package/src/orchestrator/skills/task-management/SKILL.md +143 -0
  221. package/src/orchestrator/skills/team-lead-reference/SKILL.md +317 -0
  222. package/src/orchestrator/skills/teams-notifications/SKILL.md +249 -0
  223. package/src/orchestrator/skills/testing-workflow/SKILL.md +134 -0
  224. package/src/orchestrator/skills/validation-gates/SKILL.md +100 -0
@@ -0,0 +1,317 @@
1
+ ---
2
+ name: team-lead-reference
3
+ description: "Reference data for Team Lead orchestration — model routing, pre-delegation checks, cost tracking template, and DLQ format. Load when starting a delegation session."
4
+ ---
5
+
6
+ # Team Lead Reference
7
+
8
+ For the specialist agent registry and model assignments, see [agent-registry.md](../../customizations/agents/agent-registry.md).
9
+
10
+ ## Cost-Aware Model Routing
11
+
12
+ Choose models deliberately based on task complexity. Not every task needs the most expensive model.
13
+
14
+ ### Model Cost Tiers
15
+
16
+ | Tier | Cost | Use For |
17
+ |------|------|---------|
18
+ | **Premium** | $$$ | Architecture decisions, security audits, complex reasoning, panel reviews |
19
+ | **Standard** | $$ | Feature implementation, schema design, component building |
20
+ | **Utility** | $$ | Terminal-heavy tasks, E2E tests, data pipelines, scripted workflows |
21
+ | **Economy** | $ | Documentation, simple config changes, formatting, boilerplate |
22
+
23
+ ### Selection Rules
24
+
25
+ 1. **Default to the agent's assigned model** — the registry maps tasks to appropriate tiers
26
+ 2. **Downgrade when possible** — If a task is pure docs/config with no reasoning needed, prefer Economy tier
27
+ 3. **Upgrade for ambiguity** — If the task involves security, architecture decisions, or complex tradeoffs, use Premium
28
+ 4. **Never use Premium for boilerplate** — Writing test scaffolding, updating docs, or config changes should use Economy/Standard
29
+ 5. **Parallel sub-agents are cost multipliers** — When firing 3+ parallel sub-agents, prefer Standard/Economy unless precision is critical
30
+
31
+ ## Complexity-Based Task Scoring
32
+
33
+ During decomposition, assign a **complexity score** (Fibonacci: 1, 2, 3, 5, 8, 13) to each subtask. The score determines which model tier handles the task.
34
+
35
+ ### Scoring Criteria
36
+
37
+ | Factor | Low (1-2) | Medium (3-5) | High (8-13) |
38
+ |--------|-----------|--------------|-------------|
39
+ | **Files touched** | 1-2 files | 3-5 files | 6+ files or cross-library |
40
+ | **Reasoning depth** | Mechanical / boilerplate | Pattern matching, moderate logic | Architecture decisions, security, tradeoffs |
41
+ | **Ambiguity** | Clear spec, obvious approach | Some judgment calls | Multiple valid approaches, needs exploration |
42
+ | **Risk** | No data loss, easily reversible | Moderate impact, testable | DB migrations, auth changes, breaking changes |
43
+ | **Dependencies** | None | 1-2 upstream tasks | Complex dependency chain |
44
+
45
+ ### Score to Model Tier Mapping
46
+
47
+ | Score | Tier | Examples |
48
+ |-------|------|----------|
49
+ | **1-2** | Economy/Utility | Docs update, config tweak, rename, simple test |
50
+ | **3-5** | Standard | Component build, GROQ query, API route, migration |
51
+ | **8** | Premium | Architecture decision, security audit, complex refactor |
52
+ | **13** | Premium + Panel | DB migration with data transform, auth flow redesign |
53
+
54
+ ### Override Rules
55
+
56
+ - **Blocker tasks** (blocking 2+ downstream tasks): Upgrade one tier regardless of score
57
+ - **Security-touching tasks**: Always Premium, regardless of score
58
+ - **Pure documentation**: Always Economy, regardless of estimated scope
59
+ - The agent registry default model takes precedence unless the task complexity clearly warrants an upgrade/downgrade
60
+
61
+ ## Deepen-Plan Protocol
62
+
63
+ After initial decomposition, **enrich the plan** with concrete codebase evidence before delegating. This prevents agents from wasting time on discovery that the Team Lead can do upfront.
64
+
65
+ ### When to Deepen
66
+
67
+ | Plan Complexity | Action |
68
+ |----------------|--------|
69
+ | 1-2 subtasks, familiar area | Skip — proceed directly to delegation |
70
+ | 3-5 subtasks, mixed familiarity | Quick deepen — single Researcher sub-agent |
71
+ | 6+ subtasks, unfamiliar area | Full deepen — parallel Researcher sub-agents |
72
+
73
+ ### Quick Deepen (Single Researcher)
74
+
75
+ Fire one **Researcher** sub-agent with this prompt:
76
+
77
+ ```
78
+ Research the following planned subtasks and enrich each with:
79
+ 1. Exact file paths and line numbers for code that will change
80
+ 2. Existing patterns to follow (with file:line examples)
81
+ 3. Related lessons from .github/customizations/LESSONS-LEARNED.md
82
+ 4. Risks or blockers (missing dependencies, known issues)
83
+
84
+ Subtasks:
85
+ - [Subtask 1 description]
86
+ - [Subtask 2 description]
87
+ - ...
88
+
89
+ Return a structured report per subtask.
90
+ ```
91
+
92
+ ### Full Deepen (Parallel Researchers)
93
+
94
+ For large plans, split research by domain and fire parallel Researcher sub-agents. See [agent-registry.md](../../customizations/agents/agent-registry.md) for project-specific scope examples.
95
+
96
+ ### What Deepening Produces
97
+
98
+ After deepening, each subtask in the plan should have:
99
+
100
+ | Field | Before Deepen | After Deepen |
101
+ |-------|--------------|--------------|
102
+ | **Files** | "some component" | Exact file path with line range |
103
+ | **Pattern** | "follow existing style" | Specific file:line reference to follow |
104
+ | **Risks** | unknown | Known issues identified |
105
+ | **Lessons** | unchecked | Relevant lessons applied |
106
+ | **Dependencies** | assumed | Verified with exact imports |
107
+
108
+ ### Integrating Results
109
+
110
+ Take the Researcher output and update delegation prompts with concrete file paths, patterns, and lessons. This transforms vague prompts into precise instructions that agents can execute without discovery overhead.
111
+
112
+ ## Pre-Delegation Policy Checks
113
+
114
+ Run these validation checks **before** delegating any subtask. Non-negotiable gates.
115
+
116
+ ### Mandatory Checks (before every delegation)
117
+
118
+ 1. **Linear issue exists** — The subtask has a tracked issue with acceptance criteria
119
+ 2. **File partition is clean** — No overlap with other active/parallel agents
120
+ 3. **Dependencies are met** — All prerequisite tasks are verified Done (not just claimed done)
121
+ 4. **Prompt is specific** — Contains: objective, file paths, acceptance criteria, patterns to follow
122
+ 5. **Lessons file referenced** — Prompt includes self-improvement reminder
123
+
124
+ ### Context Checks (before feature work)
125
+
126
+ 6. **Known issues reviewed** — known issues doc checked for blockers
127
+ 7. **Architecture docs read** — architecture and decision docs consulted
128
+ 8. **Existing code searched** — Confirmed no duplicate implementation exists
129
+
130
+ ### Safety Checks (before high-risk delegations)
131
+
132
+ 9. **Panel review planned** — Security, auth, DB migration, or architecture changes have panel review scheduled
133
+ 10. **Rollback path identified** — For DB migrations or data changes, rollback strategy is documented
134
+
135
+ ### Enforcement
136
+
137
+ Before calling `runSubagent` or handing off to a background agent, mentally walk through checks 1-5. If any fail, fix the gap first. Checks 6-8 apply at feature start. Checks 9-10 apply only to high-risk work.
138
+
139
+ ## Cost Tracking Convention
140
+
141
+ After completing a feature (all Linear issues Done), add a cost summary to the roadmap update:
142
+
143
+ ```markdown
144
+ **Cost Summary:**
145
+ | Metric | Value |
146
+ |--------|-------|
147
+ | Sub-agent delegations | X |
148
+ | Background agent delegations | X |
149
+ | Panel reviews | X |
150
+ | Model tiers used | Premium: X, Standard: X, Utility: X, Economy: X |
151
+ | Upgrades/downgrades | [reason if any] |
152
+ | Est. total tokens | ~XXK |
153
+ ```
154
+
155
+ This data helps optimize future model assignments. If no meaningful data was collected, skip the summary.
156
+
157
+ During execution, maintain a running delegation log in the session checkpoint (see the **session-checkpoints** skill § Delegation Cost Log). Update it after each delegation completes or fails.
158
+
159
+ ## Context Source Tagging
160
+
161
+ When collecting results from multiple sub-agents or background agents, **tag each result by its source** to prevent context confusion:
162
+
163
+ ```markdown
164
+ ### [Content Engineer] TAS-42 Schema
165
+ - Created `schemas/review.ts` with star rating field
166
+ - Deployed to Sanity Studio
167
+ - Verification: lint ✅, type-check ✅
168
+
169
+ ### [DB Engineer] TAS-43 Migration
170
+ - Created `supabase/migrations/20260227_add_reviews.sql`
171
+ - RLS policies for authenticated users
172
+ - Verification: migration applied ✅, tests ✅
173
+ ```
174
+
175
+ **Rules:**
176
+ - Prefix each agent's output summary with `### [Agent Name] TAS-XX Description`
177
+ - Never merge outputs from different agents into a single undifferentiated block
178
+ - When referencing prior agent output in a delegation prompt, cite the source: *"The Content Engineer created `schemas/review.ts` — follow that pattern"*
179
+ - In the session checkpoint "Completed Work" table, always include the Agent column
180
+
181
+ This prevents the Team Lead from confusing which agent produced what, especially after 5+ delegations when context is dense.
182
+
183
+ ## Dead Letter Queue Format
184
+
185
+ Log to `.github/customizations/AGENT-FAILURES.md` when:
186
+ - A delegated agent fails to complete its task after 2+ attempts
187
+ - A background agent produces output that fails all verification gates
188
+ - An agent encounters an unrecoverable error (e.g., MCP server down, tool unavailable)
189
+
190
+ > **Note:** When a panel review BLOCKs 3 times, create a **dispute record** instead of a DLQ entry. See § Dispute Protocol below.
191
+
192
+ ### Failure Entry Format
193
+
194
+ ```markdown
195
+ ### DLQ-XXX: Short description
196
+
197
+ | Field | Value |
198
+ |-------|-------|
199
+ | **Date** | YYYY-MM-DD |
200
+ | **Agent** | Agent name |
201
+ | **Linear Issue** | TAS-XX (if applicable) |
202
+ | **Failure Type** | `verification-fail` / `tool-error` / `panel-block` / `timeout` / `scope-creep` |
203
+ | **Attempts** | Number of attempts before logging |
204
+ | **Est. Tokens Spent** | ~XXK across all attempts |
205
+ | **Model Tier** | Economy / Utility / Standard / Premium |
206
+
207
+ **Task:** What was the agent supposed to do?
208
+
209
+ **Failure Details:** What went wrong? Include error messages, failed checks, or panel BLOCK reasons.
210
+
211
+ **Root Cause:** Why did it fail? (if known)
212
+
213
+ **Resolution:** How was it eventually resolved? (or "pending" if unresolved)
214
+ ```
215
+
216
+ ### Review Cadence
217
+
218
+ At the start of each session, scan the agent failures doc for:
219
+ - **Pending failures** that need retry
220
+ - **Patterns** — same agent failing repeatedly may indicate a prompt or skill issue
221
+ - **Tool issues** — MCP servers or external dependencies that need attention
222
+
223
+ ## Batch Review Strategy
224
+
225
+ When multiple agents complete work simultaneously, **batch similar reviews together**:
226
+ - Review all API/query changes in one session, then all UI changes in another
227
+ - Context-switches less and you spot inconsistencies more easily
228
+
229
+ ## Error Recovery Playbook
230
+
231
+ Common failure modes and how to recover:
232
+
233
+ ### Agent Stuck in Retry Loop
234
+
235
+ **Symptom:** Agent retries the same failing command 3+ times without changing approach.
236
+ **Recovery:** Intervene immediately. Read the error output, identify the root cause, and re-delegate with explicit fix instructions. Add a lesson to lessons learned.
237
+
238
+ ### MCP Tool Unavailable
239
+
240
+ **Symptom:** Tool calls fail with connection or timeout errors.
241
+ **Recovery:** (1) Check if the MCP server is running. (2) If transient, retry once. (3) If persistent, work around: use CLI tools as alternatives. Log to DLQ if critical.
242
+
243
+ ### Background Agent Produces Broken Output
244
+
245
+ **Symptom:** Background agent returns, but files have lint/type/test errors.
246
+ **Recovery:** (1) Review the diff to understand intent. (2) If fixable with small edits, fix inline. (3) If fundamentally wrong, discard the worktree changes and re-delegate with a more specific prompt. (4) Log to DLQ after 2 failed attempts.
247
+
248
+ ### Merge Conflict from Parallel Agents
249
+
250
+ **Symptom:** Two background agents modified overlapping files.
251
+ **Recovery:** (1) This should never happen if file partitioning was followed. (2) Accept one agent's changes first (the one with more complex work). (3) Re-delegate the simpler changes to adapt to the new state. (4) Add the conflict to your lessons learned.
252
+
253
+ ### Context Window Exhausted
254
+
255
+ **Symptom:** Agent responses become confused, repetitive, or lose track of earlier instructions.
256
+ **Recovery:** (1) Save a session checkpoint immediately. (2) End the current session. (3) Resume in a new session, loading the checkpoint. (4) Reduce parallel work in the next session.
257
+
258
+ ### Test Failures After Merge
259
+
260
+ **Symptom:** Tests pass individually but fail when multiple agent outputs are merged.
261
+ **Recovery:** (1) Run affected tests to identify which projects break. (2) Check for import conflicts, duplicate definitions, or state pollution. (3) Delegate fix to the agent whose changes are most likely the cause.
262
+
263
+ ## Dispute Protocol
264
+
265
+ When automated resolution is exhausted (panel 3x BLOCK, approach conflicts, or criteria contradictions), create a **formal dispute record** in `.github/customizations/DISPUTES.md`. Inspired by the [Steroids CLI](https://github.com/UnlikeOtherAI/steroids-cli) dispute/escalation pattern.
266
+
267
+ ### When to Create a Dispute (vs. DLQ Entry)
268
+
269
+ | Scenario | Action |
270
+ |----------|--------|
271
+ | Tool error, timeout, MCP failure | DLQ entry |
272
+ | Scope creep | DLQ entry + redirect |
273
+ | Agent fails 2+ times (simple) | DLQ entry |
274
+ | Panel BLOCKs 3 times | **Dispute record** |
275
+ | Agent and reviewer fundamentally disagree | **Dispute record** |
276
+ | Acceptance criteria contradict each other | **Dispute record** |
277
+ | Multiple valid approaches, agents can't converge | **Dispute record** |
278
+ | Fix requires external/human action | **Dispute record** |
279
+
280
+ ### Dispute Creation Procedure
281
+
282
+ 1. **Number the dispute** — Increment from the last `DSP-XXX` ID in the Index table
283
+ 2. **Set priority** — Use the priority guidelines in DISPUTES.md (critical/high/medium/low)
284
+ 3. **Document both perspectives** — Agent's position AND reviewer's position with specific file/code references
285
+ 4. **Build attempt history** — List every fast review and panel attempt with one-line verdict summaries
286
+ 5. **Present resolution options** — At least 2 concrete options with rationale and risk for each
287
+ 6. **Recommend an action** — Which option the Team Lead thinks is best, with specific next steps
288
+ 7. **Link artifacts** — Panel reports, review logs, changed files, DLQ entries
289
+ 8. **Log to disputes.ndjson** — Append a machine-readable record (see logs README)
290
+ 9. **Update the Linear issue** — Add the dispute ID and link to the dispute record
291
+ 10. **Update the Index table** — Add the new dispute to the bottom of the Index
292
+
293
+ ### After Human Resolution
294
+
295
+ When a human resolves a dispute:
296
+ 1. Update the dispute `Status` → `resolved` or `deferred`
297
+ 2. Record which option was chosen and any additional instructions
298
+ 3. If `resolved` → re-delegate the task with the human's decision as an explicit constraint
299
+ 4. If `deferred` → create a follow-up Linear issue and continue with other work
300
+ 5. Log the resolution in `disputes.ndjson` (update the existing record or append a resolution event)
301
+
302
+ ### Session Start: Check Disputes
303
+
304
+ At the start of each session, after checking the DLQ, also check `DISPUTES.md` for:
305
+ - **Pending disputes** that a human has resolved since the last session → act on the resolution
306
+ - **Critical/high disputes** that are still pending → flag to the user before proceeding
307
+ - **Patterns** — recurring disputes may indicate a skill gap, ambiguous instructions, or a need for a new validation gate
308
+
309
+ ## Background Agent Git Merge Strategy
310
+
311
+ Background agents work in isolated Git worktrees. When merging their output:
312
+
313
+ 1. **Merge order matters:** Merge the most foundational changes first (DB migrations -> queries -> components -> pages -> tests -> docs)
314
+ 2. **Test after each merge:** Run affected tests after merging each agent's work
315
+ 3. **Resolve conflicts immediately:** Don't accumulate multiple agent outputs before merging
316
+ 4. **Discard stale worktrees:** If an agent's output is no longer compatible with the main branch (due to other agents' changes merging first), re-delegate rather than force-merge
317
+ 5. **Atomic merge preference:** Use `git merge --no-ff` to keep agent work traceable in history
@@ -0,0 +1,249 @@
1
+ ---
2
+ name: teams-notifications
3
+ description: "Microsoft Teams MCP integration for agent-to-human notifications and bi-directional communication. Use when agents need to post progress updates, request approvals, or read user responses via Teams channels and chats."
4
+ ---
5
+
6
+ # Teams Notifications
7
+
8
+ Agent communication patterns via the Microsoft Teams MCP server (Microsoft Agent 365). Enables agents to post progress updates, request human approvals, and read responses — all through Teams channels and chats.
9
+
10
+ ## MCP Server
11
+
12
+ | Field | Value |
13
+ |-------|-------|
14
+ | **URL** | `https://mcp.microsoft365.com/mcp` |
15
+ | **Type** | Remote MCP server (HTTP) |
16
+ | **Auth** | Microsoft Graph API — OAuth 2.0 with `McpServers.Teams.All` scope |
17
+ | **Platform** | Microsoft Agent 365 (Frontier preview) |
18
+ | **Status** | Preview — requires Microsoft Agent 365 Frontier preview access |
19
+
20
+ ### Prerequisites
21
+
22
+ 1. **Microsoft Agent 365 Frontier preview** enrollment
23
+ 2. **App registration** in Microsoft Entra ID (Azure AD)
24
+ 3. **Graph API permissions:** `McpServers.Teams.All` (delegated or application)
25
+ 4. **Admin consent** for the registered app
26
+
27
+ > **Note:** The Teams MCP server is in preview and not yet generally available as a standalone endpoint. Features and availability may change.
28
+
29
+ ## Available MCP Tools
30
+
31
+ The Teams MCP server exposes tools for:
32
+
33
+ - **Chats** — Create, list, read, update, delete chats
34
+ - **Messages** — Send, read, edit, delete messages in chats and channels
35
+ - **Channels** — List, create, manage channel settings
36
+ - **Members** — List, add, remove members from chats and channels
37
+ - **Teams** — List teams, get team details, manage team settings
38
+
39
+ Tool names follow the pattern `teams_<resource>_<action>`. Use tool discovery to list available tools at runtime.
40
+
41
+ ## Agent Notification Patterns
42
+
43
+ ### Progress Updates
44
+
45
+ Post structured progress updates to a designated channel:
46
+
47
+ ```
48
+ Channel: Agent Updates (or project-specific channel)
49
+ Format:
50
+ 🔄 **Task:** TAS-42 — Add price filter component
51
+ **Status:** In progress — implementing unit tests
52
+ **Files changed:** 3 (PriceFilter.tsx, PriceFilter.test.tsx, index.ts)
53
+ **ETA:** ~5 minutes
54
+ ```
55
+
56
+ ### Completion Notifications
57
+
58
+ ```
59
+ ✅ **Task:** TAS-42 — Add price filter component
60
+ **Status:** Complete — PR opened
61
+ **PR:** https://github.com/org/repo/pull/123
62
+ **Summary:** Added PriceRangeFilter with 4 range options, 12 unit tests passing
63
+ ```
64
+
65
+ ### Error / Blocking Notifications
66
+
67
+ ```
68
+ 🚨 **Task:** TAS-42 — Add price filter component
69
+ **Status:** Blocked — needs human input
70
+ **Issue:** Cannot determine correct price ranges for the market
71
+ **Action needed:** Reply in this thread with the desired price range values
72
+ ```
73
+
74
+ ## Bi-Directional Communication
75
+
76
+ ### Human-in-the-Loop Approval
77
+
78
+ When an agent needs approval before proceeding:
79
+
80
+ 1. **Post approval request** to the channel with clear instructions:
81
+ ```
82
+ ⏳ **Approval Required**
83
+ Task: TAS-42 — Database migration adds `price_range` column
84
+ Action: Run migration on production database
85
+
86
+ Reply with:
87
+ ✅ Approve — to proceed
88
+ ❌ Reject — to stop
89
+ Or reply with questions/comments
90
+ ```
91
+
92
+ 2. **Poll for response** — Read replies to determine the decision
93
+ 3. **Acknowledge** — Post confirmation of the action taken
94
+
95
+ ### Reading User Responses
96
+
97
+ To check for approvals or instructions:
98
+
99
+ 1. Read message replies in the channel or chat thread
100
+ 2. Parse reply content for approval keywords (`approve`, `approved`, `yes`, `proceed`, `reject`, `no`, `stop`)
101
+ 3. Check for reactions on messages (Teams supports reactions via Graph API)
102
+
103
+ ### Parsing Conventions
104
+
105
+ | Signal | Meaning |
106
+ |--------|---------|
107
+ | `✅` or "approve"/"yes" reply | Approved — proceed |
108
+ | `❌` or "reject"/"no" reply | Rejected — stop and report |
109
+ | `👀` reaction or "looking" reply | Acknowledged — user is reviewing |
110
+ | Detailed reply | Instructions or questions for the agent |
111
+ | `@mention` of agent | Direct command or question |
112
+
113
+ ## Channel & Chat Conventions
114
+
115
+ ### Channel Structure
116
+
117
+ | Channel | Purpose |
118
+ |---------|---------|
119
+ | Agent Updates | General agent activity feed |
120
+ | Agent Approvals | Approval requests requiring human action |
121
+ | Agent Errors | Error reports and blocked tasks |
122
+ | Project-specific channel | All activity for a specific project |
123
+
124
+ ### Threading Rules
125
+
126
+ - **Always reply in threads** — use message replies, not top-level posts for follow-ups
127
+ - **One thread per task** — keep all updates for a single task in one conversation thread
128
+ - **Include task ID** — every message references the Linear/Jira issue ID
129
+ - **Mark important messages** — use importance flags for approval requests
130
+
131
+ ### Chat vs Channel
132
+
133
+ | Use Case | Preferred |
134
+ |----------|-----------|
135
+ | Team-wide updates | Channel |
136
+ | Approval requests | Channel (for visibility) |
137
+ | Direct questions | 1:1 or group chat |
138
+ | Sensitive discussions | 1:1 chat |
139
+
140
+ ## Message Formatting
141
+
142
+ Teams messages support HTML and a subset of Markdown:
143
+
144
+ | Format | Syntax |
145
+ |--------|--------|
146
+ | Bold | `**bold**` or `<strong>bold</strong>` |
147
+ | Italic | `*italic*` or `<em>italic</em>` |
148
+ | Code | `` `inline code` `` |
149
+ | Code block | ` ```code block``` ` |
150
+ | Link | `[Display Text](https://example.com)` |
151
+ | User mention | `<at>User Name</at>` (requires user ID in adaptive card) |
152
+ | List | `- item` or `1. item` |
153
+ | Heading | `### Heading` |
154
+
155
+ ### Adaptive Cards
156
+
157
+ For richer formatting, Teams supports Adaptive Cards (JSON-based card format):
158
+
159
+ ```json
160
+ {
161
+ "type": "AdaptiveCard",
162
+ "body": [
163
+ { "type": "TextBlock", "text": "Approval Required", "weight": "Bolder", "size": "Medium" },
164
+ { "type": "TextBlock", "text": "Task: TAS-42 — Database migration", "wrap": true }
165
+ ],
166
+ "actions": [
167
+ { "type": "Action.Submit", "title": "Approve", "data": { "action": "approve" } },
168
+ { "type": "Action.Submit", "title": "Reject", "data": { "action": "reject" } }
169
+ ],
170
+ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
171
+ "version": "1.4"
172
+ }
173
+ ```
174
+
175
+ Use Adaptive Cards for approval workflows when available — they provide structured input.
176
+
177
+ ## Rate Limits
178
+
179
+ Microsoft Graph API rate limits for Teams:
180
+
181
+ | Resource | Limit |
182
+ |----------|-------|
183
+ | Messages (per app per tenant) | 50 per second |
184
+ | Channel messages | 50 per second |
185
+ | Chat creation | 50 per second |
186
+ | Individual API calls | 10,000 per 10 minutes |
187
+
188
+ **Best practices:**
189
+ - Batch updates into single messages rather than posting many small messages
190
+ - Use threads to consolidate related updates
191
+ - Cache team/channel/user IDs — don't look them up repeatedly
192
+ - Respect 429 (Too Many Requests) responses with retry-after headers
193
+
194
+ ## Security Considerations
195
+
196
+ - **OAuth tokens** are managed by the MCP server — agents never see raw tokens
197
+ - **Scope minimization** — request only the Graph API permissions agents actually need
198
+ - **Tenant restrictions** — configure the app for single-tenant or specific tenant access
199
+ - **Conditional Access** — Microsoft Entra Conditional Access policies apply to API calls
200
+ - **Audit logging** — Microsoft 365 audit logs capture all Graph API activity
201
+ - **No secrets in messages** — never post tokens, passwords, or credentials in Teams messages (per Constitution #1)
202
+ - **Data residency** — Teams data is stored in the tenant's Microsoft 365 region
203
+
204
+ ## Integration with Agent Workflows
205
+
206
+ ### Session Start
207
+
208
+ At the beginning of a work session, post a brief status message:
209
+ ```
210
+ 🏁 **Session started**
211
+ Agent: Frontend Engineer
212
+ Task: TAS-42 — Add price filter component
213
+ Mode: Autonomous (will request approval for destructive actions)
214
+ ```
215
+
216
+ ### Session End
217
+
218
+ At the end of a work session, post a summary:
219
+ ```
220
+ 🏁 **Session complete**
221
+ Agent: Frontend Engineer
222
+ Task: TAS-42 — Add price filter component
223
+ Result: ✅ PR opened (#123)
224
+ Duration: 12 minutes
225
+ Files changed: 5
226
+ Tests: 12 passing, 0 failing
227
+ ```
228
+
229
+ ### Error Recovery
230
+
231
+ If an agent encounters an unrecoverable error, notify before stopping:
232
+ ```
233
+ 💥 **Session failed**
234
+ Agent: Frontend Engineer
235
+ Task: TAS-42 — Add price filter component
236
+ Error: TypeScript compilation failed — 3 type errors in PriceFilter.tsx
237
+ Action: Posted details in thread. Needs manual fix or re-delegation.
238
+ ```
239
+
240
+ ## Preview Limitations
241
+
242
+ Since the Teams MCP server is in Frontier preview:
243
+
244
+ - **Availability** may change without notice
245
+ - **Tool surface** may be incomplete compared to the full Graph API
246
+ - **Performance** may vary during preview
247
+ - **Breaking changes** are possible between preview versions
248
+
249
+ Check [Microsoft Agent 365 documentation](https://learn.microsoft.com/en-us/microsoft-365-copilot/extensibility/) for the latest status.