@exaudeus/workrail 3.66.0 → 3.68.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 (150) hide show
  1. package/dist/application/services/compiler/template-registry.js +10 -1
  2. package/dist/application/validation.js +1 -1
  3. package/dist/cli/commands/worktrain-init.js +1 -1
  4. package/dist/console/standalone-console.js +4 -1
  5. package/dist/console-ui/assets/{index-BynU38Vu.js → index-CyzltI6D.js} +1 -1
  6. package/dist/console-ui/index.html +1 -1
  7. package/dist/coordinators/modes/full-pipeline.js +4 -4
  8. package/dist/coordinators/modes/implement-shared.js +5 -5
  9. package/dist/coordinators/modes/implement.js +4 -4
  10. package/dist/coordinators/pr-review.js +4 -4
  11. package/dist/daemon/workflow-runner.d.ts +1 -0
  12. package/dist/daemon/workflow-runner.js +1 -0
  13. package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts +21 -2
  14. package/dist/infrastructure/storage/schema-validating-workflow-storage.js +48 -0
  15. package/dist/manifest.json +41 -41
  16. package/dist/mcp/handlers/v2-workflow.js +24 -7
  17. package/dist/mcp/output-schemas.d.ts +36 -0
  18. package/dist/mcp/output-schemas.js +11 -1
  19. package/dist/mcp/workflow-protocol-contracts.js +2 -2
  20. package/dist/v2/projections/session-metrics.d.ts +1 -1
  21. package/dist/v2/projections/session-metrics.js +16 -35
  22. package/dist/v2/usecases/console-routes.d.ts +2 -2
  23. package/docs/authoring-v2.md +4 -4
  24. package/docs/changelog-recent.md +3 -3
  25. package/docs/configuration.md +1 -1
  26. package/docs/design/adaptive-coordinator-context-candidates.md +1 -1
  27. package/docs/design/adaptive-coordinator-context.md +1 -1
  28. package/docs/design/adaptive-coordinator-routing-candidates.md +18 -18
  29. package/docs/design/adaptive-coordinator-routing-review.md +1 -1
  30. package/docs/design/adaptive-coordinator-routing.md +34 -34
  31. package/docs/design/agent-cascade-protocol.md +2 -2
  32. package/docs/design/console-daemon-separation-discovery.md +323 -0
  33. package/docs/design/context-assembly-design-candidates.md +1 -1
  34. package/docs/design/context-assembly-implementation-plan.md +1 -1
  35. package/docs/design/context-assembly-layer.md +2 -2
  36. package/docs/design/context-assembly-review-findings.md +1 -1
  37. package/docs/design/coordinator-access-audit.md +293 -0
  38. package/docs/design/coordinator-architecture-audit.md +62 -0
  39. package/docs/design/coordinator-error-handling-audit.md +240 -0
  40. package/docs/design/coordinator-testability-audit.md +426 -0
  41. package/docs/design/daemon-architecture-discovery.md +1 -1
  42. package/docs/design/daemon-console-separation-discovery.md +242 -0
  43. package/docs/design/daemon-memory-audit.md +203 -0
  44. package/docs/design/design-candidates-console-daemon-separation.md +256 -0
  45. package/docs/design/design-candidates-discovery-loop-fix.md +141 -0
  46. package/docs/design/design-review-findings-console-daemon-separation.md +106 -0
  47. package/docs/design/design-review-findings-discovery-loop-fix.md +81 -0
  48. package/docs/design/discovery-loop-fix-candidates.md +161 -0
  49. package/docs/design/discovery-loop-fix-design-review.md +106 -0
  50. package/docs/design/discovery-loop-fix-validation.md +258 -0
  51. package/docs/design/discovery-loop-investigation-A.md +188 -0
  52. package/docs/design/discovery-loop-investigation-B.md +287 -0
  53. package/docs/design/exploration-workflow-candidates.md +205 -0
  54. package/docs/design/exploration-workflow-design-review.md +166 -0
  55. package/docs/design/exploration-workflow-discovery.md +443 -0
  56. package/docs/design/ide-context-files-candidates.md +231 -0
  57. package/docs/design/ide-context-files-design-review.md +85 -0
  58. package/docs/design/ide-context-files.md +615 -0
  59. package/docs/design/implementation-plan-discovery-loop-fix.md +199 -0
  60. package/docs/design/implementation-plan-queue-poll-rotation.md +102 -0
  61. package/docs/design/in-process-http-audit.md +190 -0
  62. package/docs/design/layer3b-ghost-nodes-design-candidates.md +2 -2
  63. package/docs/design/loadSessionNotes-candidates.md +108 -0
  64. package/docs/design/loadSessionNotes-test-coverage-discovery.md +297 -0
  65. package/docs/design/loadSessionNotes-test-coverage-session4.md +209 -0
  66. package/docs/design/loadSessionNotes-test-coverage-v3.md +321 -0
  67. package/docs/design/probe-session-design-candidates.md +261 -0
  68. package/docs/design/probe-session-phase0.md +490 -0
  69. package/docs/design/routines-guide.md +7 -7
  70. package/docs/design/session-metrics-attribution-candidates.md +250 -0
  71. package/docs/design/session-metrics-attribution-design-review.md +115 -0
  72. package/docs/design/session-metrics-attribution-discovery.md +319 -0
  73. package/docs/design/session-metrics-candidates.md +227 -0
  74. package/docs/design/session-metrics-design-review.md +104 -0
  75. package/docs/design/session-metrics-discovery.md +454 -0
  76. package/docs/design/spawn-session-debug.md +202 -0
  77. package/docs/design/trigger-validator-candidates.md +214 -0
  78. package/docs/design/trigger-validator-review.md +109 -0
  79. package/docs/design/trigger-validator-shaping-phase0.md +239 -0
  80. package/docs/design/trigger-validator.md +454 -0
  81. package/docs/design/v2-core-design-locks.md +2 -2
  82. package/docs/design/workflow-extension-points.md +15 -15
  83. package/docs/design/workflow-id-validation-at-startup.md +1 -1
  84. package/docs/design/workflow-id-validation-implementation-plan.md +2 -2
  85. package/docs/design/workflow-trigger-lifecycle-audit.md +175 -0
  86. package/docs/design/worktrain-task-queue-candidates.md +5 -5
  87. package/docs/design/worktrain-task-queue.md +4 -4
  88. package/docs/discovery/coordinator-script-design.md +1 -1
  89. package/docs/discovery/coordinator-ux-discovery.md +3 -3
  90. package/docs/discovery/simulation-report.md +1 -1
  91. package/docs/discovery/workflow-modernization-discovery.md +326 -0
  92. package/docs/discovery/workflow-selection-for-discovery-tasks.md +33 -33
  93. package/docs/discovery/worktrain-status-briefing.md +1 -1
  94. package/docs/discovery/wr-discovery-goal-reframing.md +1 -1
  95. package/docs/docker.md +1 -1
  96. package/docs/ideas/backlog.md +227 -0
  97. package/docs/ideas/third-party-workflow-setup-design-thinking.md +1 -1
  98. package/docs/integrations/claude-code.md +5 -5
  99. package/docs/integrations/firebender.md +1 -1
  100. package/docs/plans/agentic-orchestration-roadmap.md +2 -2
  101. package/docs/plans/mr-review-workflow-redesign.md +9 -9
  102. package/docs/plans/ui-ux-workflow-design-candidates.md +4 -4
  103. package/docs/plans/ui-ux-workflow-discovery.md +2 -2
  104. package/docs/plans/workflow-categories-candidates.md +8 -8
  105. package/docs/plans/workflow-categories-discovery.md +4 -4
  106. package/docs/plans/workflow-modernization-design.md +430 -0
  107. package/docs/plans/workflow-staleness-detection-candidates.md +11 -11
  108. package/docs/plans/workflow-staleness-detection-review.md +4 -4
  109. package/docs/plans/workflow-staleness-detection.md +9 -9
  110. package/docs/plans/workrail-platform-vision.md +3 -3
  111. package/docs/reference/agent-context-cleaner-snippet.md +1 -1
  112. package/docs/reference/agent-context-guidance.md +4 -4
  113. package/docs/reference/context-optimization.md +2 -2
  114. package/docs/roadmap/now-next-later.md +2 -2
  115. package/docs/roadmap/open-work-inventory.md +16 -16
  116. package/docs/workflows.md +31 -31
  117. package/package.json +1 -1
  118. package/spec/workflow-tags.json +47 -47
  119. package/workflows/adaptive-ticket-creation.json +16 -16
  120. package/workflows/architecture-scalability-audit.json +22 -22
  121. package/workflows/bug-investigation.agentic.v2.json +3 -3
  122. package/workflows/classify-task-workflow.json +1 -1
  123. package/workflows/coding-task-workflow-agentic.json +6 -6
  124. package/workflows/cross-platform-code-conversion.v2.json +8 -8
  125. package/workflows/document-creation-workflow.json +8 -8
  126. package/workflows/documentation-update-workflow.json +8 -8
  127. package/workflows/intelligent-test-case-generation.json +2 -2
  128. package/workflows/learner-centered-course-workflow.json +2 -2
  129. package/workflows/mr-review-workflow.agentic.v2.json +4 -4
  130. package/workflows/personal-learning-materials-creation-branched.json +8 -8
  131. package/workflows/presentation-creation.json +5 -5
  132. package/workflows/production-readiness-audit.json +1 -1
  133. package/workflows/relocation-workflow-us.json +31 -31
  134. package/workflows/routines/context-gathering.json +1 -1
  135. package/workflows/routines/design-review.json +1 -1
  136. package/workflows/routines/execution-simulation.json +1 -1
  137. package/workflows/routines/feature-implementation.json +3 -3
  138. package/workflows/routines/final-verification.json +1 -1
  139. package/workflows/routines/hypothesis-challenge.json +1 -1
  140. package/workflows/routines/ideation.json +1 -1
  141. package/workflows/routines/parallel-work-partitioning.json +3 -3
  142. package/workflows/routines/philosophy-alignment.json +2 -2
  143. package/workflows/routines/plan-analysis.json +1 -1
  144. package/workflows/routines/plan-generation.json +1 -1
  145. package/workflows/routines/tension-driven-design.json +6 -6
  146. package/workflows/scoped-documentation-workflow.json +26 -26
  147. package/workflows/ui-ux-design-workflow.json +14 -14
  148. package/workflows/workflow-diagnose-environment.json +1 -1
  149. package/workflows/workflow-for-workflows.json +32 -77
  150. package/workflows/workflow-for-workflows.v2.json +0 -788
@@ -0,0 +1,615 @@
1
+ # IDE Context Files Discovery
2
+
3
+ **Status:** Complete -- ready for implementation
4
+ **Workflow:** wr.discovery
5
+ **Confidence:** HIGH
6
+
7
+ ---
8
+
9
+ ## Artifact Strategy
10
+
11
+ This document is a **human-readable record** of research findings and decisions. It is NOT the execution truth for the workflow -- that lives in WorkRail's step notes and context variables. If a chat rewind occurs, this file may not reflect the latest state; refer to the WorkRail session for canonical progress.
12
+
13
+ Use this doc to: review findings, understand tradeoffs, reference the final TypeScript array.
14
+ Do NOT use this doc as: the authoritative source of what the workflow has or hasn't done.
15
+
16
+ ---
17
+
18
+ ## Context / Ask
19
+
20
+ **Stated Goal (solution-statement):** Discover every file path where agentic IDEs, AI coding tools, and autonomous agent frameworks store project-level and user-level context/rules/instructions files so WorkTrain can load all of them into the session system prompt.
21
+
22
+ **Scope:** `src/daemon/workflow-runner.ts` (`WORKSPACE_CONTEXT_CANDIDATE_PATHS`). Do NOT touch `src/mcp/`.
23
+
24
+ **Reframed Problem:** WorkTrain generates code inconsistent with team conventions when developers use AI tools other than Claude Code, because their project-specific rules live in tool-specific config files that WorkTrain never reads.
25
+
26
+ ---
27
+
28
+ ## Path Recommendation
29
+
30
+ **Chosen path:** `landscape_first`
31
+
32
+ **Rationale:** The solution direction (auto-discover known file paths) is correct for WorkTrain's zero-config philosophy. The dominant need is an accurate landscape of what files each tool actually uses -- not a fundamental reframing of the approach. The design risk is low; the research risk is high (paths change between versions, some tools have multiple formats).
33
+
34
+ **Why not `design_first`:** The stated solution is independently the right answer. The alternatives (manual paste, user-configured paths) shift burden to the user in ways incompatible with WorkTrain's zero-config design.
35
+
36
+ ---
37
+
38
+ ## Constraints / Anti-goals
39
+
40
+ **Constraints:**
41
+ - Scope limited to `src/daemon/workflow-runner.ts` -- do not touch `src/mcp/`
42
+ - Must not break existing behavior for Claude Code users
43
+ - Must handle file format differences (YAML, frontmatter, plain markdown)
44
+ - Context window budget: existing cap is 32KB combined (`WORKSPACE_CONTEXT_MAX_BYTES`)
45
+
46
+ **Anti-goals:**
47
+ - Do NOT implement a plugin system or user-configurable path list (YAGNI)
48
+ - Do NOT parse/execute structured config files (e.g., Aider's YAML) as code
49
+ - Do NOT load binary or non-text files
50
+ - Do NOT change the priority order for the currently-supported Claude Code files
51
+
52
+ ---
53
+
54
+ ## Challenged Assumptions
55
+
56
+ 1. **Files are plain text injectable directly into the system prompt**
57
+ - Why it might be wrong: Cursor `.mdc` files have YAML frontmatter metadata; Aider `.aider.conf.yml` is YAML config not freeform prose; mixing structured config keys with instructions would pollute the prompt
58
+ - Evidence needed: Inspect actual format of each file type before deciding injection strategy
59
+
60
+ 2. **Loading more context files always improves output quality**
61
+ - Why it might be wrong: Conflicting rules from multiple tools could confuse the model; large injections consume context window that may be better used for code
62
+ - Evidence needed: Empirical comparison of curated vs. exhaustive injection (not yet available)
63
+
64
+ 3. **The set of tools and their config file paths is stable enough to hardcode**
65
+ - Why it might be wrong: Cursor already migrated from `.cursorrules` to `.cursor/rules/*.mdc` between versions; tools iterate quickly
66
+ - Evidence needed: Check changelogs for Cursor/Windsurf for path changes in the past 12 months
67
+
68
+ ---
69
+
70
+ ## Landscape Packet
71
+
72
+ ### Claude Code -- Official Documentation
73
+
74
+ Source: https://code.claude.com/docs/en/memory (confirmed, April 2026)
75
+
76
+ **Workspace/project paths (searched up the directory tree from CWD):**
77
+ - `CLAUDE.md` -- project instructions (root)
78
+ - `.claude/CLAUDE.md` -- project instructions (hidden dir)
79
+ - `CLAUDE.local.md` -- personal project prefs, gitignored
80
+ - `.claude/rules/*.md` -- modular rules, optional YAML frontmatter with `paths:` for path-scoping
81
+
82
+ **User-level paths:**
83
+ - `~/.claude/CLAUDE.md` -- personal preferences, all projects
84
+ - `~/.claude/rules/*.md` -- personal rules, all projects
85
+
86
+ **Org-level managed policy:**
87
+ - macOS: `/Library/Application Support/ClaudeCode/CLAUDE.md`
88
+ - Linux/WSL: `/etc/claude-code/CLAUDE.md`
89
+
90
+ **Format:** Plain markdown. `.claude/rules/*.md` files may have YAML frontmatter with `paths:` globs.
91
+
92
+ **Note on AGENTS.md:** Claude Code reads `CLAUDE.md`, not `AGENTS.md`. Teams using both tools should have `CLAUDE.md` import `AGENTS.md` via `@AGENTS.md`.
93
+
94
+ ---
95
+
96
+ ### Cursor -- Empirical Evidence
97
+
98
+ Source: Direct filesystem inspection of `/Users/etienneb/git/zillow/zillow-android-2/.cursor/rules/` (April 2026) + community knowledge. Official docs (cursor.com) are JavaScript SPA -- not fetchable with curl/WebFetch.
99
+
100
+ **Workspace/project paths:**
101
+ - `.cursorrules` -- legacy single file, still works (plain markdown)
102
+ - `.cursor/rules/*.mdc` -- current recommended approach (YAML frontmatter + markdown body)
103
+
104
+ **User-level paths:**
105
+ - `~/.cursor/rules/` -- user-level rules directory (no files found in this env)
106
+
107
+ **Format:**
108
+ - `.cursorrules`: plain markdown, injected verbatim
109
+ - `.mdc` files: YAML frontmatter (has `alwaysApply:`, `description:`, `_cg_managed:`, etc.) + markdown body. **Requires frontmatter stripping before injection.**
110
+
111
+ **Example frontmatter observed:**
112
+ ```yaml
113
+ ---
114
+ _cg_managed: "true"
115
+ alwaysApply: true
116
+ description: "Team-wide context from common-ground. Always applied."
117
+ ---
118
+ ```
119
+
120
+ **Status:** `.cursorrules` is legacy but still functional. `.cursor/rules/*.mdc` is the current format.
121
+
122
+ ---
123
+
124
+ ### Windsurf (Codeium) -- Official Documentation
125
+
126
+ Source: https://docs.windsurf.com/windsurf/cascade/memories (confirmed, April 2026)
127
+
128
+ **Workspace/project paths:**
129
+ - `.windsurf/rules/*.md` -- project rules (YAML frontmatter + markdown, individual files per rule)
130
+ - `AGENTS.md` or `agents.md` anywhere in workspace (auto-scoped by directory)
131
+
132
+ **User-level paths:**
133
+ - `~/.codeium/windsurf/memories/global_rules.md` -- global rules, all workspaces (6,000 char limit)
134
+
135
+ **Org/system-level (enterprise):**
136
+ - macOS: `/Library/Application Support/Windsurf/rules/*.md`
137
+ - Linux/WSL: `/etc/windsurf/rules/*.md`
138
+
139
+ **Format:** Markdown with YAML frontmatter. Frontmatter includes `trigger:` (always-on vs. conditional). **Requires frontmatter stripping.**
140
+
141
+ **Note:** `.windsurfrules` is NOT documented -- confirmed not in use.
142
+
143
+ ---
144
+
145
+ ### GitHub Copilot -- Official Documentation
146
+
147
+ Source: https://docs.github.com/en/copilot/customizing-copilot/adding-custom-instructions-for-github-copilot (confirmed, April 2026)
148
+
149
+ **Workspace/project paths:**
150
+ - `.github/copilot-instructions.md` -- repository-wide instructions (plain markdown)
151
+ - `.github/instructions/*.instructions.md` -- path-scoped instructions (YAML frontmatter with glob patterns)
152
+
153
+ **User-level paths (JetBrains):**
154
+ - macOS: `~/.config/github-copilot/intellij/global-copilot-instructions.md`
155
+
156
+ **Format:**
157
+ - `copilot-instructions.md`: plain markdown, injected verbatim
158
+ - `*.instructions.md`: YAML frontmatter with `applyTo:` glob patterns + markdown body
159
+
160
+ **Priority:** Personal instructions > repository instructions > organization instructions
161
+
162
+ ---
163
+
164
+ ### Aider -- Official Documentation
165
+
166
+ Source: https://aider.chat/docs/usage/conventions.html (confirmed, April 2026)
167
+
168
+ **Workspace/project paths:** NONE auto-discovered.
169
+
170
+ Aider does NOT auto-discover any context files. Users must explicitly configure:
171
+ - `--read CONVENTIONS.md` flag (any filename)
172
+ - Or `read: CONVENTIONS.md` in `.aider.conf.yml`
173
+
174
+ **Format:** Not applicable -- no auto-discovered files.
175
+
176
+ **Verdict:** Aider has no fixed path to add to WorkTrain's candidate list.
177
+
178
+ ---
179
+
180
+ ### Continue.dev -- Official Documentation
181
+
182
+ Source: https://docs.continue.dev/customize/deep-dives/rules (confirmed, April 2026)
183
+
184
+ **Workspace/project paths:**
185
+ - `.continue/rules/*.md` -- individual markdown files (one rule per file)
186
+
187
+ **User-level paths:**
188
+ - `~/.continue/rules/*.md` -- global rules, all workspaces
189
+
190
+ **Format:** Plain markdown. No frontmatter requirement noted.
191
+
192
+ ---
193
+
194
+ ### Devin (Cognition) -- Official Documentation
195
+
196
+ Source: https://docs.devin.ai/llms.txt (confirmed, April 2026)
197
+
198
+ **Workspace/project paths:**
199
+ - `AGENTS.md` -- project root or anywhere in repo (already covered)
200
+
201
+ **Format:** Plain markdown.
202
+
203
+ ---
204
+
205
+ ### Firebender -- Empirical Evidence
206
+
207
+ Source: Direct filesystem inspection of `/Users/etienneb/git/zillow/zillow-android-2/.firebender/` (April 2026) + `docs/integrations/firebender.md` in this repo.
208
+
209
+ **Workspace/project paths:**
210
+ - `.firebender/AGENTS.md` -- project-level agent instructions (plain markdown)
211
+ - `.firebender/rules/*.mdc` -- project rules (YAML frontmatter + markdown body)
212
+
213
+ **User-level paths:**
214
+ - `~/.firebender/rules/` -- global rules (no files found in this env, directory present)
215
+ - `~/.firebender/firebender.json` -- global config (subagents, commands -- not a context file)
216
+
217
+ **Format:** Same `.mdc` format as Cursor -- YAML frontmatter + markdown. **Requires frontmatter stripping.**
218
+
219
+ ---
220
+
221
+ ### Cody (Sourcegraph) -- Research Result
222
+
223
+ No project-level context files found in official docs. Configuration is managed through Sourcegraph Enterprise instance settings. No fixed path for WorkTrain to read.
224
+
225
+ ---
226
+
227
+ ### Gemini Code Assist (Google) -- Research Result
228
+
229
+ No project-level context/rules files documented. Mentions `.aiexclude` for file exclusion (like `.gitignore`), not instructions. No path to add.
230
+
231
+ ---
232
+
233
+ ### OpenAI Codex / o3 -- Knowledge
234
+
235
+ `AGENTS.md` is the specified file (already covered). No other auto-discovered paths documented.
236
+
237
+ ---
238
+
239
+ ## What Exists Locally (This Environment)
240
+
241
+ Confirmed via filesystem scan (April 2026):
242
+
243
+ | File pattern | Present? | Where |
244
+ |---|---|---|
245
+ | `.cursorrules` | YES | Firebender worktrees + zillow-android repos |
246
+ | `.cursor/rules/*.mdc` | YES | Multiple zillow repos + worktrees |
247
+ | `.windsurf/rules/*.md` | YES | Multiple zillow repos |
248
+ | `.github/copilot-instructions.md` | YES | zillow-android-2 + worktrees |
249
+ | `CLAUDE.md` | YES | workrail, zillow-android-2, many repos |
250
+ | `AGENTS.md` | YES | workrail, zillow-android-2, many repos |
251
+ | `.firebender/AGENTS.md` | YES | zillow-android-2 + worktrees |
252
+ | `.firebender/rules/*.mdc` | YES | Multiple zillow repos |
253
+ | `~/.claude/CLAUDE.md` | NO | Not present |
254
+ | `~/.continue/rules/` | NO | Not present |
255
+ | `.windsurfrules` | NO | Not found anywhere |
256
+ | `.aider.conf.yml` | NO | Not found |
257
+
258
+ ---
259
+
260
+ ## Problem Frame Packet
261
+
262
+ **Core tension:** Three categories of files exist:
263
+
264
+ 1. **Literal paths** -- single stable files like `.github/copilot-instructions.md` that can be added to `WORKSPACE_CONTEXT_CANDIDATE_PATHS` as-is
265
+ 2. **Glob patterns** -- directories like `.cursor/rules/*.mdc` that require scanning + concatenation, not supported by current literal-path implementation
266
+ 3. **Format stripping required** -- `.mdc` files and `.windsurf/rules/*.md` files have YAML frontmatter that must be stripped before injection
267
+
268
+ **Implication:** The current `WORKSPACE_CONTEXT_CANDIDATE_PATHS` literal-path approach handles category 1 only. Supporting categories 2 and 3 requires a code change to `workflow-runner.ts` -- either:
269
+ - Extend the path entry type to support glob patterns
270
+ - Strip YAML frontmatter from files before injection
271
+
272
+ **Contradictions found (1):**
273
+ - `.windsurfrules` is widely referenced in community resources and other tools' docs but is NOT in Windsurf's own official documentation. The actual Windsurf convention is `.windsurf/rules/*.md`. This contradicts the assumption in the original goal statement.
274
+
275
+ **Evidence gaps (2):**
276
+ - Cursor's official docs are not accessible (JavaScript SPA). File format confirmed empirically but version history unknown.
277
+ - `.cursor/rules/` user-level path (`~/.cursor/rules/`) is present as an empty directory -- documented but not in use locally.
278
+
279
+ ---
280
+
281
+ ## Problem Frame Packet
282
+
283
+ ### Primary Users
284
+
285
+ Developers using WorkTrain alongside other AI coding tools (Cursor, Windsurf, Firebender, GitHub Copilot) in the same repository. Their team's coding conventions are distributed via tool-specific config files that WorkTrain never reads, causing generated code to miss team standards.
286
+
287
+ ### Jobs / Desired Outcomes
288
+
289
+ - "I want to set up coding conventions once and have all my AI tools follow them automatically"
290
+ - "When WorkTrain generates code in my monorepo, it should follow the same rules as Cursor does"
291
+
292
+ ### Core Tensions
293
+
294
+ 1. **Literal paths vs. glob patterns:** The existing `WORKSPACE_CONTEXT_CANDIDATE_PATHS` is a `string[]` of literal relative paths. The most important new conventions (`.cursor/rules/*.mdc`, `.windsurf/rules/*.md`, `.firebender/rules/*.mdc`) require glob scanning. This is a scope expansion.
295
+
296
+ 2. **More context vs. context quality:** Injecting raw `.mdc` files adds YAML frontmatter (`alwaysApply: true`, `description: "..."`) into the system prompt. This metadata is noise for WorkTrain. Injecting without stripping is worse than not injecting.
297
+
298
+ 3. **Stability vs. completeness:** Some tools (Cursor) already migrated conventions once. A hardcoded list requires maintenance. But a plugin/discovery system is over-engineering for now (YAGNI).
299
+
300
+ ### Success Criteria
301
+
302
+ 1. A developer's `.cursorrules` or `.cursor/rules/*.mdc` rules appear in WorkTrain sessions without manual config
303
+ 2. The frontmatter in `.mdc` / `.windsurf/rules/*.md` files is stripped before injection
304
+ 3. The `WORKSPACE_CONTEXT_CANDIDATE_PATHS` entry type is expanded to support `{ pattern: string, stripFrontmatter?: boolean }` (or equivalent)
305
+ 4. All added paths have cited sources
306
+ 5. User-level global context paths are documented separately from workspace paths
307
+ 6. Priority order is deterministic and documented
308
+
309
+ ### HMW Questions
310
+
311
+ - "How might we support glob patterns in `WORKSPACE_CONTEXT_CANDIDATE_PATHS` without breaking the existing literal-path contract?"
312
+ - "How might we strip YAML frontmatter without risking stripping legitimate content from plain markdown files?"
313
+
314
+ ### Framing Risks
315
+
316
+ 1. **Scope creep risk:** The code change to support glob patterns touches more of `workflow-runner.ts` than "just adding strings to an array." This might be better as a separate PR.
317
+ 2. **False assumption in original goal:** `.windsurfrules` does NOT exist -- Windsurf uses `.windsurf/rules/*.md`. If implemented based on the original assumption, the Windsurf path would be wrong.
318
+ 3. **Frontmatter stripping could be lossy:** Some `.mdc` files might have content above the `---` delimiter that isn't frontmatter. The stripping logic must handle edge cases.
319
+
320
+ ---
321
+
322
+ ## Candidate Generation Expectations
323
+
324
+ **Path:** `landscape_first` + `THOROUGH`
325
+
326
+ **What the candidate set must cover:**
327
+ 1. Reflect the Phase A / Phase B distinction discovered in landscape research -- not all candidates need both phases
328
+ 2. Must include a minimalist option (literal paths only, zero code change to resolution logic)
329
+ 3. Must include an option that separates glob-pattern scanning from the existing literal-path array (parallel structures)
330
+ 4. Must include at least one option that considers frontmatter metadata as useful signal (e.g., skip `alwaysApply: false` rules)
331
+ 5. Must NOT cluster -- all 4 candidates should differ on scope, implementation approach, or frontmatter handling
332
+
333
+ **Candidates must not do:**
334
+ - Touch `src/mcp/`
335
+ - Break existing 4 paths
336
+ - Exceed WORKSPACE_CONTEXT_MAX_BYTES
337
+ - Add files without cited sources
338
+
339
+ ---
340
+
341
+ ## Candidate Directions
342
+
343
+ ### Candidate 1 -- Minimal literal path expansion (Phase A only)
344
+
345
+ **One-sentence summary:** Add 3 literal paths to the existing `string[]` array with zero code changes.
346
+
347
+ **New paths added:**
348
+ - `CLAUDE.local.md` -- Claude Code personal project prefs (official docs, high confidence)
349
+ - `.cursorrules` -- Cursor legacy rules, plain markdown (empirically confirmed)
350
+ - `.github/copilot-instructions.md` -- GitHub Copilot (official docs, high confidence)
351
+
352
+ **Tensions resolved:** None of the structural ones.
353
+ **Tensions accepted:** No glob support (misses `.cursor/rules/*.mdc`), no frontmatter handling.
354
+ **Failure mode:** `.cursorrules` often has the same content as `.cursor/rules/*.mdc` in the Zillow setup -- double-injection possible. Not harmful but wastes budget.
355
+ **Scope judgment:** Too narrow -- misses the most actively-used paths in this environment.
356
+ **Philosophy:** Honors YAGNI, immutability. Conflicts with Explicit Domain Types.
357
+
358
+ ---
359
+
360
+ ### Candidate 2 -- Literal paths + unconditional frontmatter stripper (Phase A + stripping)
361
+
362
+ **One-sentence summary:** Add the same 3 literal paths AND a `stripFrontmatter(content: string): string` pure function called on every file before injection (safe no-op if no frontmatter present).
363
+
364
+ **New function shape:**
365
+ ```typescript
366
+ function stripFrontmatter(content: string): string {
367
+ if (!content.startsWith('---\n') && !content.startsWith('---\r\n')) return content;
368
+ const end = content.indexOf('\n---', 4);
369
+ if (end === -1) return content; // malformed -- don't strip
370
+ return content.slice(end + 4).trimStart();
371
+ }
372
+ ```
373
+
374
+ **Tensions resolved:** Frontmatter pollution (safe, starts-with-`---` guard).
375
+ **Tensions accepted:** No glob support, string[] type stays primitive.
376
+ **Failure mode:** A file that legitimately starts with `---` on line 1 (extremely unlikely for instruction files) gets incorrectly stripped.
377
+ **Scope judgment:** Best-fit incremental -- clean injection without full type expansion.
378
+ **Philosophy:** Honors Compose with small pure functions. Conflicts with Make illegal states unrepresentable (stripping not in type).
379
+
380
+ ---
381
+
382
+ ### Candidate 3 -- Discriminated union type + glob expansion + frontmatter stripping (Phase A + B)
383
+
384
+ **One-sentence summary:** Replace `string[]` with `readonly WorkspaceContextCandidate[]` (discriminated union), expand `loadWorkspaceContext()` to handle glob entries with alpha-sorted expansion and per-entry frontmatter stripping.
385
+
386
+ **New type:**
387
+ ```typescript
388
+ type LiteralCandidatePath = {
389
+ readonly kind: 'literal';
390
+ readonly relativePath: string;
391
+ readonly stripFrontmatter?: boolean;
392
+ };
393
+ type GlobCandidatePath = {
394
+ readonly kind: 'glob';
395
+ readonly pattern: string;
396
+ readonly stripFrontmatter: boolean;
397
+ readonly sort: 'alpha';
398
+ };
399
+ type WorkspaceContextCandidate = LiteralCandidatePath | GlobCandidatePath;
400
+ ```
401
+
402
+ **Full candidate array includes:** `.claude/CLAUDE.md`, `CLAUDE.md`, `CLAUDE.local.md`, `AGENTS.md`, `.github/AGENTS.md`, `.cursorrules`, `.cursor/rules/*.mdc` (glob, strip), `.windsurf/rules/*.md` (glob, strip), `.firebender/rules/*.mdc` (glob, strip), `.firebender/AGENTS.md`, `.github/copilot-instructions.md`, `.continue/rules/*.md` (glob, no strip).
403
+
404
+ **Tensions resolved:** All 4 -- expressive type, glob support, frontmatter in contract, deterministic ordering.
405
+ **Failure mode:** (1) Per-glob file count cap needed (e.g. max 20 files). (2) Glob dependency -- check if `fast-glob` already in package.json or use Node 22+ `fs.glob`.
406
+ **Scope judgment:** Best-fit -- broader than Candidate 1/2 but fully contained in `workflow-runner.ts`.
407
+ **Philosophy:** Honors Explicit domain types, Unrepresentable illegal states, Exhaustiveness. Moderate YAGNI tension for Continue.dev (unused locally).
408
+
409
+ ---
410
+
411
+ ### Candidate 4 -- Parallel Set for strip flags (NOT recommended)
412
+
413
+ **One-sentence summary:** Keep `string[]` unchanged and add a parallel `Set<string>` of paths that need frontmatter stripping.
414
+
415
+ **Tensions resolved:** Backward compatibility only.
416
+ **Failure mode:** Maintenance trap -- easy to add a path and forget to update the Set.
417
+ **Scope judgment:** Too narrow in design quality (patch, not fix).
418
+ **Philosophy:** Conflicts with Architectural fixes over patches, Unrepresentable illegal states. **NOT recommended.**
419
+
420
+ ---
421
+
422
+ ## Decision Log
423
+
424
+ | Date | Decision | Rationale |
425
+ |------|----------|-----------|
426
+ | 2026-04-19 | Path: landscape_first | Solution direction is correct; dominant need is accurate file path data |
427
+ | 2026-04-19 | Scope: workflow-runner.ts only | MCP layer should not be touched per stated constraint |
428
+ | 2026-04-19 | Selected: Candidate 3 (discriminated union + glob + stripping) | tinyglobby already in package.json, Node v25.2.1, no external callers of WORKSPACE_CONTEXT_CANDIDATE_PATHS, glob paths empirically confirmed present in user's repos |
429
+ | 2026-04-19 | Runner-up: Candidate 2 (literal + stripping) | Would be the choice if tinyglobby were unavailable or if glob paths were speculative |
430
+ | 2026-04-19 | Priority order: .cursor/rules/*.mdc before .cursorrules | Glob format first, legacy fallback second -- reduces duplicate injection when both exist |
431
+ | 2026-04-19 | .windsurfrules does NOT exist | Confirmed: Windsurf uses .windsurf/rules/*.md directory per official docs + local scan |
432
+
433
+ ---
434
+
435
+ ## Final Summary
436
+
437
+ ### Recommendation
438
+
439
+ **Selected direction:** Candidate 3 -- Discriminated union type + glob expansion + frontmatter stripping.
440
+
441
+ **Confidence band:** HIGH. All factual preconditions verified empirically.
442
+
443
+ ### Implementation Contract
444
+
445
+ **New type (add to `workflow-runner.ts`):**
446
+ ```typescript
447
+ /**
448
+ * A literal path entry: a single file at a known relative path.
449
+ * WHY: Claude Code paths are stable single-file conventions.
450
+ */
451
+ type LiteralCandidatePath = {
452
+ readonly kind: 'literal';
453
+ readonly relativePath: string;
454
+ // WHY: even literal paths may have YAML frontmatter (e.g., CLAUDE.md imported
455
+ // from tools that inject frontmatter). stripFrontmatter defaults false for
456
+ // existing Claude Code paths to preserve backward compatibility.
457
+ readonly stripFrontmatter?: boolean;
458
+ };
459
+
460
+ /**
461
+ * A glob pattern entry: zero or more files matching a pattern in a directory.
462
+ * WHY: Cursor, Windsurf, and Firebender all use directory-based conventions
463
+ * where teams add multiple rule files. A glob pattern discovers them all.
464
+ */
465
+ type GlobCandidatePath = {
466
+ readonly kind: 'glob';
467
+ // Relative to workspacePath, e.g. '.cursor/rules/*.mdc'
468
+ readonly pattern: string;
469
+ // WHY: .mdc (Cursor/Firebender) and .windsurf/rules/*.md files have YAML
470
+ // frontmatter with metadata (alwaysApply, description, etc.) that is not
471
+ // meant for LLM consumption. Must be stripped before injection.
472
+ readonly stripFrontmatter: boolean;
473
+ // WHY: tinyglobby order is filesystem-dependent. Alpha sort ensures the same
474
+ // workspace produces the same context on every WorkTrain session.
475
+ readonly sort: 'alpha';
476
+ };
477
+
478
+ type WorkspaceContextCandidate = LiteralCandidatePath | GlobCandidatePath;
479
+ ```
480
+
481
+ **New constant (replace existing `WORKSPACE_CONTEXT_CANDIDATE_PATHS`):**
482
+ ```typescript
483
+ /**
484
+ * WHY priority order: More specific (tool-specific, project-specific) before
485
+ * more general. User-written Claude Code config takes top priority. Glob
486
+ * formats (newer) come before legacy single-file formats (older) for each tool
487
+ * to reduce duplicate injection when both coexist.
488
+ *
489
+ * Sources:
490
+ * Claude Code: https://code.claude.com/docs/en/memory (April 2026)
491
+ * Cursor .cursorrules: empirical (zillow-android-2/.cursorrules)
492
+ * Cursor .cursor/rules/*.mdc: empirical (zillow-android-2/.cursor/rules/)
493
+ * Windsurf .windsurf/rules/*.md: https://docs.windsurf.com/windsurf/cascade/memories (April 2026)
494
+ * Firebender .firebender/rules/*.mdc: empirical (zillow-android-2/.firebender/rules/)
495
+ * Firebender AGENTS.md: docs/integrations/firebender.md + empirical
496
+ * GitHub Copilot: https://docs.github.com/en/copilot/customizing-copilot/adding-custom-instructions-for-github-copilot (April 2026)
497
+ * Continue.dev: https://docs.continue.dev/customize/deep-dives/rules (April 2026)
498
+ *
499
+ * NOTE: .windsurfrules does NOT exist -- Windsurf uses .windsurf/rules/ directory.
500
+ * NOTE: alwaysApply: false rules in .mdc files are injected unconditionally in
501
+ * Phase 1. Phase 2 will add filtering based on the alwaysApply frontmatter field.
502
+ */
503
+ const WORKSPACE_CONTEXT_CANDIDATE_PATHS: readonly WorkspaceContextCandidate[] = [
504
+ { kind: 'literal', relativePath: '.claude/CLAUDE.md' },
505
+ { kind: 'literal', relativePath: 'CLAUDE.md' },
506
+ { kind: 'literal', relativePath: 'CLAUDE.local.md' },
507
+ { kind: 'literal', relativePath: 'AGENTS.md' },
508
+ { kind: 'literal', relativePath: '.github/AGENTS.md' },
509
+ // Cursor: newer directory format before legacy single-file format
510
+ { kind: 'glob', pattern: '.cursor/rules/*.mdc', stripFrontmatter: true, sort: 'alpha' },
511
+ { kind: 'literal', relativePath: '.cursorrules' },
512
+ // Windsurf: directory format only (.windsurfrules does NOT exist per official docs)
513
+ { kind: 'glob', pattern: '.windsurf/rules/*.md', stripFrontmatter: true, sort: 'alpha' },
514
+ // Firebender: both AGENTS.md convention and rules directory
515
+ { kind: 'glob', pattern: '.firebender/rules/*.mdc', stripFrontmatter: true, sort: 'alpha' },
516
+ { kind: 'literal', relativePath: '.firebender/AGENTS.md' },
517
+ // GitHub Copilot
518
+ { kind: 'literal', relativePath: '.github/copilot-instructions.md' },
519
+ // Continue.dev
520
+ { kind: 'glob', pattern: '.continue/rules/*.md', stripFrontmatter: false, sort: 'alpha' },
521
+ ] as const;
522
+
523
+ /**
524
+ * Maximum files to read per glob pattern.
525
+ * WHY: Prevents I/O cost and context budget waste in repos where .cursor/rules/
526
+ * or similar directories contain many files (generated artifacts, etc.).
527
+ */
528
+ const MAX_GLOB_FILES_PER_PATTERN = 20;
529
+ ```
530
+
531
+ **New helper function:**
532
+ ```typescript
533
+ /**
534
+ * Strip YAML frontmatter from file content before injection into the system prompt.
535
+ *
536
+ * WHY: .mdc files (Cursor, Firebender) and .windsurf/rules/*.md files include
537
+ * YAML metadata (alwaysApply, description, trigger) that is tool-specific and
538
+ * not meaningful in a WorkTrain system prompt context.
539
+ *
540
+ * Safety: Only strips if the file starts with '---' (YAML frontmatter is always
541
+ * at the start of the file). Returns original content unchanged if:
542
+ * - File does not start with '---\n' (no frontmatter present -- safe no-op)
543
+ * - No closing '---' delimiter found (malformed frontmatter -- preserve as-is)
544
+ *
545
+ * Called unconditionally on all injected content regardless of the
546
+ * stripFrontmatter flag (the flag documents which files are EXPECTED to have
547
+ * frontmatter; the implementation is unconditionally defensive).
548
+ */
549
+ function stripFrontmatter(content: string): string {
550
+ if (!content.startsWith('---\n') && !content.startsWith('---\r\n')) return content;
551
+ const endIdx = content.indexOf('\n---', 4);
552
+ if (endIdx === -1) return content;
553
+ return content.slice(endIdx + 4).trimStart();
554
+ }
555
+ ```
556
+
557
+ **Updated `loadWorkspaceContext()` loop (pseudocode):**
558
+ ```typescript
559
+ for (const entry of WORKSPACE_CONTEXT_CANDIDATE_PATHS) {
560
+ if (truncated) break;
561
+
562
+ if (entry.kind === 'literal') {
563
+ // existing behavior: read single file, skip ENOENT silently
564
+ const content = await tryReadFile(path.join(workspacePath, entry.relativePath));
565
+ if (content === null) continue;
566
+ accumulateWithBudget(entry.relativePath, stripFrontmatter(content));
567
+ } else {
568
+ // glob: expand pattern, sort, cap, read each
569
+ const matches = await glob(entry.pattern, { cwd: workspacePath });
570
+ const sorted = matches.sort().slice(0, MAX_GLOB_FILES_PER_PATTERN);
571
+ if (matches.length > MAX_GLOB_FILES_PER_PATTERN) {
572
+ console.warn(`[WorkflowRunner] ${entry.pattern}: ${matches.length} files found, capped at ${MAX_GLOB_FILES_PER_PATTERN}`);
573
+ }
574
+ for (const relativePath of sorted) {
575
+ if (truncated) break;
576
+ const content = await tryReadFile(path.join(workspacePath, relativePath));
577
+ if (content === null) continue;
578
+ accumulateWithBudget(relativePath, stripFrontmatter(content));
579
+ }
580
+ }
581
+ }
582
+ ```
583
+
584
+ ### User-Level Global Context Paths
585
+
586
+ These are NOT added to `WORKSPACE_CONTEXT_CANDIDATE_PATHS` (workspace-relative only). Document here for future consideration:
587
+
588
+ | Tool | User-level path | Format |
589
+ |---|---|---|
590
+ | Claude Code | `~/.claude/CLAUDE.md` | Plain markdown |
591
+ | Claude Code | `~/.claude/rules/*.md` | Markdown with optional frontmatter |
592
+ | Windsurf | `~/.codeium/windsurf/memories/global_rules.md` | Plain markdown |
593
+ | GitHub Copilot (JetBrains) | `~/.config/github-copilot/intellij/global-copilot-instructions.md` | Plain markdown |
594
+ | Continue.dev | `~/.continue/rules/*.md` | Plain markdown |
595
+
596
+ Loading user-level paths is a potential Phase 3 enhancement. It requires knowing the user's home directory and handling OS-level paths correctly.
597
+
598
+ ### Strongest Alternative
599
+
600
+ **Candidate 2** (literal paths + unconditional stripping, no glob support) would be the choice if:
601
+ - `tinyglobby` were not already a dependency, OR
602
+ - The glob paths were speculative (not found locally)
603
+
604
+ Neither condition holds.
605
+
606
+ ### Residual Risks
607
+
608
+ 1. **`alwaysApply: false` rules injected unconditionally** -- accepted for Phase 1, deferred to follow-up issue. Content is over-broad but not incorrect.
609
+ 2. **Cursor official docs inaccessible** -- format confirmed empirically. If Cursor changes `.mdc` format, the design doc will need re-research.
610
+ 3. **Duplicate content** -- `.cursorrules` and `.cursor/rules/*.mdc` may contain identical content. Priority order (glob first) naturally limits duplication. Not harmful.
611
+
612
+ ### Follow-up Work
613
+
614
+ - GitHub issue: `feat(engine): filter alwaysApply: false rules from .mdc context injection`
615
+ - Consider loading user-level global context paths (Phase 3)