@nurix/etna 0.15.6 → 0.15.8

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 (88) hide show
  1. package/bin/etna.js +64 -13
  2. package/data/harness-index.json +7 -5
  3. package/data/harnesses/code/CLAUDE.md +3 -7
  4. package/data/harnesses/code/agents/harness-manager.md +4 -4
  5. package/data/harnesses/code/agents/maintenance.md +1 -1
  6. package/data/harnesses/code/harness.json +4 -3
  7. package/data/harnesses/code/hooks/hooks.json +3 -17
  8. package/data/harnesses/code/hooks/prompt-recall.js +157 -0
  9. package/data/harnesses/code/hooks/session-reflect.js +283 -0
  10. package/data/harnesses/code/skills/distiller/SKILL.md +62 -60
  11. package/data/harnesses/code/skills/distiller/references/docs-mode.md +21 -21
  12. package/data/harnesses/code/skills/distiller/references/method.md +41 -41
  13. package/data/harnesses/code/skills/documentation/references/templates.md +20 -27
  14. package/data/harnesses/code-fable/CLAUDE.md +138 -0
  15. package/data/harnesses/code-fable/agents/brainstorm.md +35 -0
  16. package/data/harnesses/code-fable/agents/change-review.md +249 -0
  17. package/data/harnesses/code-fable/agents/harness-manager.md +193 -0
  18. package/data/harnesses/code-fable/agents/maintenance.md +123 -0
  19. package/data/harnesses/code-fable/agents/performance-review.md +218 -0
  20. package/data/harnesses/code-fable/agents/spec-mode.md +56 -0
  21. package/data/harnesses/code-fable/harness.json +7 -0
  22. package/data/harnesses/code-fable/hooks/hooks.json +27 -0
  23. package/data/harnesses/code-fable/hooks/lib/redact.js +37 -0
  24. package/data/harnesses/code-fable/hooks/prompt-recall.js +157 -0
  25. package/data/harnesses/code-fable/hooks/session-reflect.js +283 -0
  26. package/data/harnesses/code-fable/rules/general.md +96 -0
  27. package/data/harnesses/code-fable/rules/nomenclature.md +34 -0
  28. package/data/harnesses/code-fable/skills/boundary/SKILL.md +262 -0
  29. package/data/harnesses/code-fable/skills/boundary/references/boundary-taxonomy.md +734 -0
  30. package/data/harnesses/code-fable/skills/brainstorm/README.md +136 -0
  31. package/data/harnesses/code-fable/skills/brainstorm/SKILL.md +135 -0
  32. package/data/harnesses/code-fable/skills/brainstorm/harvest.md +26 -0
  33. package/data/harnesses/code-fable/skills/brainstorm/templates/backlog.md +39 -0
  34. package/data/harnesses/code-fable/skills/brainstorm/templates/build.md +37 -0
  35. package/data/harnesses/code-fable/skills/brainstorm/templates/decisions.md +29 -0
  36. package/data/harnesses/code-fable/skills/brainstorm/templates/doctrine.md +31 -0
  37. package/data/harnesses/code-fable/skills/brainstorm/templates/domain-model.md +25 -0
  38. package/data/harnesses/code-fable/skills/brainstorm/templates/glossary.md +19 -0
  39. package/data/harnesses/code-fable/skills/brainstorm/templates/milestones.md +43 -0
  40. package/data/harnesses/code-fable/skills/brainstorm/templates/non-goals.md +21 -0
  41. package/data/harnesses/code-fable/skills/brainstorm/templates/plan-doc.md +61 -0
  42. package/data/harnesses/code-fable/skills/brainstorm/templates/questions.md +35 -0
  43. package/data/harnesses/code-fable/skills/brainstorm/templates/references.md +28 -0
  44. package/data/harnesses/code-fable/skills/brainstorm/templates/rejected.md +29 -0
  45. package/data/harnesses/code-fable/skills/brainstorm/templates/state.md +8 -0
  46. package/data/harnesses/code-fable/skills/brainstorm/templates/tech.md +23 -0
  47. package/data/harnesses/code-fable/skills/brainstorm/templates/thesis.md +21 -0
  48. package/data/harnesses/code-fable/skills/distiller/SKILL.md +219 -0
  49. package/data/harnesses/code-fable/skills/distiller/references/docs-mode.md +526 -0
  50. package/data/harnesses/code-fable/skills/distiller/references/method.md +166 -0
  51. package/data/harnesses/code-fable/skills/documentation/SKILL.md +127 -0
  52. package/data/harnesses/code-fable/skills/documentation/references/examples.md +193 -0
  53. package/data/harnesses/code-fable/skills/documentation/references/style-guide.md +288 -0
  54. package/data/harnesses/code-fable/skills/documentation/references/templates.md +942 -0
  55. package/data/harnesses/code-fable/skills/workflow-mapper/SKILL.md +430 -0
  56. package/data/harnesses/code-fable/skills/workflow-mapper/references/patterns.md +214 -0
  57. package/data/harnesses/discover/CLAUDE.md +180 -0
  58. package/data/harnesses/{re → discover}/agents/api.md +3 -3
  59. package/data/harnesses/{re → discover}/agents/codebase.md +3 -3
  60. package/data/harnesses/{re → discover}/agents/community.md +3 -3
  61. package/data/harnesses/{re → discover}/agents/deployed-client-bundle.md +21 -15
  62. package/data/harnesses/{re → discover}/agents/distribution-artifacts.md +13 -12
  63. package/data/harnesses/{re → discover}/agents/docs.md +3 -3
  64. package/data/harnesses/{re → discover}/agents/infra-backend-fingerprint.md +3 -3
  65. package/data/harnesses/{re → discover}/agents/packages.md +3 -3
  66. package/data/harnesses/{re → discover}/agents/session.md +29 -11
  67. package/data/harnesses/{re → discover}/agents/website.md +3 -3
  68. package/data/harnesses/{re → discover}/agents/wire-capture.md +14 -10
  69. package/data/harnesses/discover/harness.json +7 -0
  70. package/data/harnesses/{re/rules/re-discovery.md → discover/rules/discovery.md} +86 -17
  71. package/data/harnesses/{re/rules/re-evaluation.md → discover/rules/evaluation.md} +40 -4
  72. package/data/harnesses/discover/rules/ingestion.md +551 -0
  73. package/data/harnesses/discover/rules/self-correction.md +177 -0
  74. package/data/harnesses/discover/rules/tradecraft.md +532 -0
  75. package/data/harnesses/hr/CLAUDE.md +91 -0
  76. package/data/harnesses/hr/harness.json +7 -0
  77. package/data/harnesses/hr/skills/interview-eval/SKILL.md +118 -0
  78. package/data/harnesses/hr/skills/interview-eval/TEMPLATE.md +124 -0
  79. package/data/harnesses/hr/skills/interview-eval/extract_session.py +418 -0
  80. package/data/harnesses/hr/skills/interview-eval/rubric.md +219 -0
  81. package/data/harnesses/kb-agi/harness.json +1 -0
  82. package/package.json +1 -1
  83. package/data/harnesses/code/hooks/post-commit.js +0 -136
  84. package/data/harnesses/code/hooks/post-tool-failure.js +0 -136
  85. package/data/harnesses/code/hooks/session-stop.js +0 -207
  86. package/data/harnesses/re/CLAUDE.md +0 -146
  87. package/data/harnesses/re/harness.json +0 -6
  88. package/data/harnesses/re/rules/re-ingestion.md +0 -327
@@ -0,0 +1,430 @@
1
+ ---
2
+ name: workflow-mapper
3
+ description: Discover and document all major workflows in a codebase by tracing call chains from user action to database/external system. Produces mermaid sequence diagrams and markdown documentation. Use when the user asks to map workflows, trace flows, document sequences, understand how features work end-to-end, or generate architecture diagrams. Triggers on "map workflows", "trace workflows", "workflow diagram", "sequence diagram", "how does X work end-to-end", "document flows", "codebase workflows", "how does this feature work", "trace the request flow", "show me the call chain", "what happens when a user does X", "end-to-end flow".
4
+ ---
5
+
6
+ # Workflow Mapper Skill
7
+
8
+ Identify and document every major workflow in a codebase by tracing execution paths from trigger to terminal effect. Output is a single markdown file with mermaid sequence diagrams.
9
+
10
+ ---
11
+
12
+ ## Decision Tree
13
+
14
+ ```
15
+ User request
16
+ │
17
+ ├─ "Map all workflows" ────────────▶ Full Discovery (all phases)
18
+ │
19
+ ├─ "Map workflow for {feature}" ───▶ Targeted Discovery (skip Phase 1 broad scan)
20
+ │
21
+ ├─ "Update workflow map" ──────────▶ Incremental (diff against existing map)
22
+ │
23
+ └─ "How does X work end-to-end" ──▶ Single Workflow Trace (Phase 2-4 only)
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Phase 1: Entry Point Discovery
29
+
30
+ Find all places where a multi-step process begins. Use parallel sub-agents — one per technique.
31
+
32
+ ### Technique 1: Route Harvesting
33
+
34
+ Scan all API route definitions. These are the primary entry points for backend workflows.
35
+
36
+ ```
37
+ Search patterns (adapt to framework):
38
+ Express: router.(get|post|put|patch|delete)\(
39
+ Fastify: fastify.(get|post|put|patch|delete)\(
40
+ Next.js: export (async )?function (GET|POST|PUT|PATCH|DELETE)
41
+ Hono: app.(get|post|put|patch|delete)\(
42
+ tRPC: .query\(|.mutation\(
43
+ ```
44
+
45
+ For each route, record: `{ method, path, handler_function, file }`.
46
+
47
+ Filter out trivial CRUD (single DB call + response). Keep routes that:
48
+ - Call `startWorkflow`, `addJob`, `enqueue`, `emit`, `publish` (async dispatch)
49
+ - Call 2+ service functions sequentially
50
+ - Have transaction blocks (`$transaction`, `BEGIN`, `withTransaction`)
51
+ - Return a job/workflow ID for polling
52
+ - Trigger WebSocket/SSE events
53
+
54
+ ### Technique 2: Background Job Discovery
55
+
56
+ Find all registered background jobs, workflows, and queues.
57
+
58
+ ```
59
+ Search patterns:
60
+ Temporal: export async function .*Workflow|workflowModules|startChild\(
61
+ BullMQ: new Queue\(|new Worker\(|.add\(|.process\(
62
+ Celery: @app.task|@shared_task
63
+ Inngest: createFunction\(|inngest.send\(
64
+ Cron: cron.schedule\(|@Cron\(|node-cron
65
+ EventEmitter: .on\(|.emit\(|EventEmitter
66
+ ```
67
+
68
+ For Temporal specifically, also check:
69
+ - `temporal/config/workflowModules.js` — workflow registry with queues and dependencies
70
+ - `temporal/config/activityModules.js` — activity aggregation
71
+
72
+ ### Technique 3: Frontend Action Tracing
73
+
74
+ Find UI-initiated multi-step flows.
75
+
76
+ ```
77
+ Search patterns:
78
+ Redux thunks: createAsyncThunk\(|dispatch\(
79
+ API calls: api\.(post|put|patch|delete)\(|axios\.(post|put|patch|delete)\(|fetch\(
80
+ Form submits: onSubmit|handleSubmit
81
+ Custom hooks: use[A-Z].*\(\) that contain API calls
82
+ ```
83
+
84
+ Focus on actions that:
85
+ - POST/PUT/PATCH/DELETE to backend (not just GETs)
86
+ - Dispatch multiple Redux actions in sequence
87
+ - Start polling loops (`setInterval`, recursive `setTimeout`, retry patterns)
88
+ - Open WebSocket connections or listen for server-sent events
89
+
90
+ ### Technique 4: Event & Message Tracing
91
+
92
+ Find event-driven workflows (WebSocket, pub/sub, SSE).
93
+
94
+ ```
95
+ Search patterns:
96
+ WebSocket: socket.on\(|io.on\(|ws.on\(
97
+ SSE: EventSource|text/event-stream
98
+ Redis pub: .publish\(|.subscribe\(
99
+ Message: .sendMessage\(|.postMessage\(
100
+ ```
101
+
102
+ ### Technique 5: Scheduled & Lifecycle Workflows
103
+
104
+ ```
105
+ Search patterns:
106
+ App startup: app.listen|bootstrap|onModuleInit|main\(\)
107
+ Shutdown: SIGTERM|SIGINT|gracefulShutdown|onModuleDestroy
108
+ Migrations: migrate|seed|up\(\)|down\(\)
109
+ Health checks: /health|/ping|/ready|/live
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Phase 2: Call Chain Tracing
115
+
116
+ For each discovered entry point, trace the full execution path. Use one sub-agent per workflow for parallelism.
117
+
118
+ ### Tracing Algorithm
119
+
120
+ ```
121
+ 1. Start at the entry point function
122
+ 2. Read the function body
123
+ 3. For each function call or await:
124
+ a. Is it a DB operation? → Record as "Database" participant action
125
+ b. Is it an external API call? → Record as "{ServiceName}" participant action
126
+ c. Is it a queue/workflow dispatch? → Record as "{QueueSystem}" participant, then recurse into the dispatched handler
127
+ d. Is it a Redux dispatch? → Record as "Redux" participant action
128
+ e. Is it an internal function in the same service? → Recurse (but cap depth at 4)
129
+ f. Is it a WebSocket emit? → Record as "WebSocket" participant action
130
+ 4. Record branching (if/else, try/catch, switch) as alt/opt blocks
131
+ 5. Record loops (polling, retry, pagination) as loop blocks
132
+ 6. Stop when you hit: a return to the caller, a terminal DB write, or an external system response
133
+ 7. If a workflow trace exceeds the configured depth cap, stop tracing and note the overflow point with a comment like "→ [continues deeper, capped at depth N]". Do not silently truncate.
134
+ ```
135
+
136
+ ### Participant Identification
137
+
138
+ Map code actors to diagram participants using this hierarchy:
139
+
140
+ | Code Pattern | Participant Name |
141
+ |---|---|
142
+ | React component, hook, event handler | `User` + `Frontend` |
143
+ | Express/API route handler | `API` |
144
+ | Temporal workflow | `Temporal` |
145
+ | BullMQ worker/processor | `Queue` |
146
+ | Prisma/Sequelize/Knex call | `Database` |
147
+ | External HTTP call (axios, fetch to external URL) | `{ServiceName}` (derive from URL or config) |
148
+ | Redis operation | `Cache` |
149
+ | WebSocket emit/broadcast | `WebSocket` |
150
+ | File system / S3 / storage | `Storage` |
151
+ | Git API calls | `Git` |
152
+ | Email/SMS send | `Notifications` |
153
+ | Auth provider (Keycloak, Better Auth, Auth0) | `Auth` |
154
+
155
+ ### Branching Detection
156
+
157
+ Look for conditional logic that represents meaningful workflow forks:
158
+
159
+ ```
160
+ - Version conflicts (optimistic locking) → alt block
161
+ - Permission/auth checks → opt block
162
+ - Feature flags → opt block
163
+ - Error handling with different outcomes → alt block
164
+ - Retry with backoff → loop block
165
+ - Polling for completion → loop block
166
+ - Batch processing → loop block
167
+ ```
168
+
169
+ ---
170
+
171
+ ## Phase 3: Classification & Filtering
172
+
173
+ Not every API route is a "workflow". Classify and filter.
174
+
175
+ ### Workflow Categories
176
+
177
+ | Category | Criteria | Include? |
178
+ |---|---|---|
179
+ | **Orchestration** | Multi-step, multi-service, async handoffs (save, publish, deploy) | Always |
180
+ | **Auth & Session** | Login, logout, token refresh, SSO flows | Always |
181
+ | **Real-time** | WebSocket connections, live updates, presence | Always |
182
+ | **Event-driven** | Pub/sub chains, webhook handlers, event sourcing | Always |
183
+ | **Scheduled** | Cron jobs, recurring workflows, cleanup tasks | Always |
184
+ | **Data Pipeline** | ETL, import/export, migration, sync between systems | Always |
185
+ | **Simple CRUD** | Single DB call + response, no branching | Skip |
186
+ | **Static Serving** | File serving, asset delivery | Skip |
187
+ | **Health/Config** | Health checks, config endpoints | Skip |
188
+
189
+ ### Complexity Scoring
190
+
191
+ Score each workflow to determine diagram detail level:
192
+
193
+ - **Steps**: Count distinct operations (DB calls, API calls, dispatches). 1-2 = simple, 3-5 = moderate, 6+ = complex
194
+ - **Participants**: Count distinct systems involved. 2 = simple, 3-4 = moderate, 5+ = complex
195
+ - **Branching**: Count alt/opt blocks. 0 = linear, 1-2 = moderate, 3+ = complex
196
+ - **Async**: Has polling, callbacks, child workflows? +1 complexity level
197
+
198
+ Simple workflows get a compact diagram. Complex workflows get full detail with alt/opt/loop blocks.
199
+
200
+ ---
201
+
202
+ ## Phase 4: Mermaid Diagram Generation
203
+
204
+ ### Diagram Template
205
+
206
+ ````markdown
207
+ ### {Workflow Name}
208
+
209
+ **Trigger:** {What initiates this — button click, API call, cron schedule, event}
210
+ **Participants:** {List of systems involved}
211
+ **Key files:** {3-5 most important files in the chain}
212
+
213
+ ```mermaid
214
+ sequenceDiagram
215
+ participant User
216
+ participant Frontend
217
+ participant API
218
+ participant Database
219
+
220
+ User->>Frontend: {User action}
221
+ Frontend->>API: {HTTP method} {path}
222
+ API->>Database: {Operation}
223
+ Database-->>API: {Result}
224
+ API-->>Frontend: {Response}
225
+ Frontend-->>User: {UI update}
226
+ ```
227
+
228
+ **Notes:**
229
+ - {Important implementation detail not visible in diagram}
230
+ - {Performance consideration, timeout, retry policy}
231
+ - {Known edge cases or failure modes}
232
+ ````
233
+
234
+ ### Diagram Rules
235
+
236
+ 1. **Arrow types**: Solid (`->>`) for calls/requests, dashed (`-->>`) for returns/responses
237
+ 2. **Activation bars**: Use `activate`/`deactivate` only for long-running operations (Temporal workflows, polling loops)
238
+ 3. **Alt blocks**: Use for real workflow branching (conflict vs success), not for error handling
239
+ 4. **Loop blocks**: Use for polling, retry, batch processing — include the condition
240
+ 5. **Opt blocks**: Use for conditional steps (feature flags, optional integrations)
241
+ 6. **Notes**: Use `Note over` for context that doesn't fit in arrow labels
242
+ 7. **Participant order**: Left-to-right follows the data flow direction (User → Frontend → API → Backend → Database)
243
+ 8. **Label brevity**: Arrow labels should be ≤8 words. Use the action, not the implementation detail
244
+ 9. **Max participants**: 7 per diagram. If more, split into sub-diagrams or collapse internal services
245
+ 10. **Max steps**: 15 visible interactions per diagram. For longer workflows, group related steps or use `rect` blocks
246
+
247
+ ### Grouping Related Steps
248
+
249
+ For workflows with many sequential same-type operations, collapse them:
250
+
251
+ ```mermaid
252
+ sequenceDiagram
253
+ rect rgb(240, 240, 240)
254
+ Note over Temporal,Database: Save all entities (10 types)
255
+ Temporal->>Database: Upsert objects, attributes, pages...
256
+ Database-->>Temporal: Saved
257
+ end
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Phase 5: Output Assembly
263
+
264
+ ### Output File Structure
265
+
266
+ Write to the user-specified path, or default to `docs/architecture/workflows.md`. Before writing output files, ensure the target directory exists. Create it with `mkdir -p` if needed.
267
+
268
+ ````markdown
269
+ ---
270
+ generated: {YYYY-MM-DD}
271
+ scope: {full | feature-name}
272
+ workflows_found: {count}
273
+ ---
274
+
275
+ # Codebase Workflows
276
+
277
+ Auto-generated workflow map. Traces execution paths from user action to terminal effect.
278
+
279
+ ## Table of Contents
280
+
281
+ | Workflow | Category | Trigger | Participants | Complexity |
282
+ |---|---|---|---|---|
283
+ | [{Name}](#{anchor}) | {Category} | {Trigger} | {Count} | {Simple/Moderate/Complex} |
284
+
285
+ ---
286
+
287
+ ## Orchestration Workflows
288
+
289
+ ### {Workflow Name}
290
+ {Diagram + metadata as defined in Phase 4}
291
+
292
+ ---
293
+
294
+ ## Authentication & Session Workflows
295
+
296
+ ### {Workflow Name}
297
+ {...}
298
+
299
+ ---
300
+
301
+ ## Real-time Workflows
302
+
303
+ ### {Workflow Name}
304
+ {...}
305
+
306
+ ---
307
+
308
+ ## Event-driven Workflows
309
+
310
+ ### {Workflow Name}
311
+ {...}
312
+
313
+ ---
314
+
315
+ ## Scheduled Workflows
316
+
317
+ ### {Workflow Name}
318
+ {...}
319
+
320
+ ---
321
+
322
+ ## Data Pipeline Workflows
323
+
324
+ ### {Workflow Name}
325
+ {...}
326
+ ````
327
+
328
+ ### Section Ordering
329
+
330
+ 1. Orchestration (the core business logic — save, publish, deploy)
331
+ 2. Authentication & Session
332
+ 3. Real-time (WebSocket, SSE)
333
+ 4. Event-driven (pub/sub, webhooks)
334
+ 5. Scheduled (cron, recurring)
335
+ 6. Data Pipeline (import/export, sync, migration)
336
+
337
+ Skip empty sections.
338
+
339
+ ---
340
+
341
+ ## Execution Strategy
342
+
343
+ ### Full Discovery (default)
344
+
345
+ Launch 5 parallel sub-agents for Phase 1 (one per technique). Collect results, deduplicate entry points, then launch parallel sub-agents for Phase 2 (one per workflow, max 8 concurrent). Run Phase 3-5 sequentially in the main agent.
346
+
347
+ ### Targeted Discovery
348
+
349
+ User specifies a feature name. Skip broad Phase 1 scan. Instead:
350
+ 1. Find the feature's directory/files (grep for feature name in routes, components, workflows)
351
+ 2. Trace from those entry points only
352
+ 3. Output a single-feature workflow document
353
+
354
+ ### Incremental Update
355
+
356
+ Read the existing workflow map file. For each workflow listed, check if the key files have changed (git diff). Re-trace only changed workflows. Preserve unchanged sections.
357
+
358
+ ---
359
+
360
+ ## Advanced Techniques
361
+
362
+ ### Payload Storage Detection
363
+
364
+ Look for patterns where large payloads are stored separately and referenced by ID:
365
+ ```
366
+ storePayload|savePayload|workflow_payload|jobData
367
+ → then: retrievePayload|fetchPayload|getPayload (in the worker/activity)
368
+ ```
369
+ Note this in the diagram as a "Store payload → reference by ID" pattern.
370
+
371
+ ### Optimistic Locking Detection
372
+
373
+ Look for version comparison patterns:
374
+ ```
375
+ version.*!==|version.*conflict|StaleObjectError|OptimisticLock
376
+ if.*serverVersion.*localVersion|if.*version.*mismatch
377
+ ```
378
+ These indicate conflict branching that should appear as `alt` blocks.
379
+
380
+ ### Polling Loop Detection
381
+
382
+ Look for patterns where the frontend waits for async completion:
383
+ ```
384
+ setInterval|setTimeout.*recursive|poll|retry.*status
385
+ GET.*status\?.*workflowId|GET.*status\?.*jobId
386
+ ```
387
+ Note the polling interval and timeout in the diagram.
388
+
389
+ ### Child Workflow / Sub-job Detection
390
+
391
+ Look for spawned sub-processes:
392
+ ```
393
+ startChild\(|spawnChild|fork\(|.add\(.*queue
394
+ Promise\.all.*map.*startWorkflow
395
+ ```
396
+ These should appear as nested sequences or separate linked diagrams.
397
+
398
+ ### Transaction Boundary Detection
399
+
400
+ Look for explicit transaction markers:
401
+ ```
402
+ \$transaction|\$executeRaw|BEGIN|COMMIT|ROLLBACK
403
+ withTransaction|runInTransaction|atomic
404
+ ```
405
+ Group operations within a transaction using `rect` blocks in the diagram.
406
+
407
+ ### Rate Limiting & Middleware Detection
408
+
409
+ Look for middleware applied to route groups:
410
+ ```
411
+ rateLimit|rateLimiter|throttle
412
+ authenticate|authorize|requireAuth|requireRole
413
+ validate|validateBody|validateParams
414
+ ```
415
+ Note these as guards in the diagram using `opt` blocks or notes.
416
+
417
+ ---
418
+
419
+ ## Quality Checks
420
+
421
+ Before outputting, verify:
422
+
423
+ - [ ] Every diagram has ≥3 participants (otherwise it's probably too simple to document)
424
+ - [ ] Every diagram has both request and response arrows (no dangling calls)
425
+ - [ ] Participant names are consistent across all diagrams (same DB = same name everywhere)
426
+ - [ ] Alt/opt/loop blocks have clear conditions written in the block label
427
+ - [ ] Key files listed actually exist in the codebase (verify with glob)
428
+ - [ ] No workflow is documented twice under different names
429
+ - [ ] Mermaid syntax is valid (no unclosed blocks, balanced activate/deactivate)
430
+ - [ ] Table of contents anchors match actual heading anchors
@@ -0,0 +1,214 @@
1
+ # Search Pattern Reference
2
+
3
+ Concrete grep/glob patterns for each discovery technique. Agents should adapt these to the actual framework detected in the codebase.
4
+
5
+ ---
6
+
7
+ ## Framework Detection (run first)
8
+
9
+ Identify the tech stack to select the right patterns:
10
+
11
+ | Check | Pattern | Means |
12
+ |---|---|---|
13
+ | `package.json` contains `express` | `"express"` | Express backend |
14
+ | `package.json` contains `@temporalio` | `"@temporalio"` | Temporal workflows |
15
+ | `package.json` contains `bullmq` | `"bullmq"` | BullMQ job queues |
16
+ | `package.json` contains `@reduxjs/toolkit` | `"@reduxjs/toolkit"` | Redux state management |
17
+ | `package.json` contains `socket.io` | `"socket.io"` | WebSocket via Socket.IO |
18
+ | `app/workflows/` exists | glob `app/workflows/` | Workflow directory convention |
19
+ | `temporal/config/` exists | glob `temporal/config/` | Temporal config convention |
20
+ | Files matching `*.workflow.ts` | glob `**/*.workflow.*` | Workflow file convention |
21
+ | Files matching `*.queue.ts` | glob `**/*.queue.*` | Queue file convention |
22
+
23
+ ---
24
+
25
+ ## Route Harvesting Patterns
26
+
27
+ ### Express
28
+
29
+ ```
30
+ # Route definitions
31
+ grep: router\.(get|post|put|patch|delete)\(
32
+ glob: **/routes/**/*.{js,ts}, **/router/**/*.{js,ts}
33
+
34
+ # Route mounting
35
+ grep: app\.use\(.*/api
36
+ ```
37
+
38
+ ### Next.js App Router
39
+
40
+ ```
41
+ glob: app/**/route.{js,ts}
42
+ grep: export (async )?function (GET|POST|PUT|PATCH|DELETE)
43
+ ```
44
+
45
+ ### Next.js Pages API
46
+
47
+ ```
48
+ glob: pages/api/**/*.{js,ts}
49
+ grep: export default (async )?function handler
50
+ ```
51
+
52
+ ### Fastify
53
+
54
+ ```
55
+ grep: fastify\.(get|post|put|patch|delete)\(
56
+ grep: (register|plugin).*routes
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Temporal Workflow Patterns
62
+
63
+ ```
64
+ # Workflow definitions
65
+ grep: export async function \w+Workflow
66
+ glob: **/workflow.{js,ts}, **/*.workflow.{js,ts}
67
+
68
+ # Activity definitions
69
+ grep: export async function \w+Activity
70
+ glob: **/activities.{js,ts}, **/*.activities.{js,ts}
71
+
72
+ # Workflow registry
73
+ glob: **/workflowModules.{js,ts}
74
+ grep: workflows\s*=\s*\{
75
+
76
+ # Activity registry
77
+ glob: **/activityModules.{js,ts}
78
+ grep: activities\s*=\s*\{
79
+
80
+ # Workflow dispatch
81
+ grep: startWorkflow\(|startChild\(|executeChild\(
82
+
83
+ # Activity proxy
84
+ grep: proxyActivities\(
85
+
86
+ # Signals and queries
87
+ grep: defineSignal\(|defineQuery\(|setHandler\(
88
+
89
+ # Continue-as-new
90
+ grep: continueAsNew\(
91
+ ```
92
+
93
+ ---
94
+
95
+ ## BullMQ Patterns
96
+
97
+ ```
98
+ # Queue definitions
99
+ grep: new Queue\(|new FlowProducer\(
100
+ glob: **/queue.{js,ts}, **/*.queue.{js,ts}
101
+
102
+ # Worker definitions
103
+ grep: new Worker\(
104
+ glob: **/worker.{js,ts}, **/*.worker.{js,ts}
105
+
106
+ # Job dispatch
107
+ grep: \.add\(|\.addBulk\(|\.addFlow\(
108
+
109
+ # Job processing
110
+ grep: \.process\(|processor:
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Redux / Frontend Action Patterns
116
+
117
+ ```
118
+ # Async thunks (dispatched actions that call APIs)
119
+ grep: createAsyncThunk\(
120
+ glob: **/*Slice.{js,ts}, **/*slice.{js,ts}, **/slices/**/*.{js,ts}
121
+
122
+ # API calls from frontend
123
+ grep: api\.(post|put|patch|delete)\(|axios\.(post|put|patch|delete)\(
124
+ glob: **/hooks/use*.{js,ts,jsx,tsx}, **/services/**/*.{js,ts}
125
+
126
+ # Dispatch sequences
127
+ grep: dispatch\(.*Actions?\.|dispatch\(.*thunk
128
+ ```
129
+
130
+ ---
131
+
132
+ ## WebSocket Patterns
133
+
134
+ ```
135
+ # Socket.IO server
136
+ grep: io\.on\(|socket\.on\(|socket\.emit\(
137
+ glob: **/socket/**/*.{js,ts}, **/ws/**/*.{js,ts}
138
+
139
+ # Socket.IO client
140
+ grep: socket\.on\(|socket\.emit\(|useSocket
141
+ glob: **/hooks/useSocket*.{js,ts,jsx,tsx}
142
+
143
+ # Native WebSocket
144
+ grep: new WebSocket\(|ws\.on\(
145
+ ```
146
+
147
+ ---
148
+
149
+ ## Database Patterns
150
+
151
+ ```
152
+ # Prisma
153
+ grep: prisma\.\w+\.(findMany|findFirst|findUnique|create|update|delete|upsert|aggregate|groupBy)
154
+ grep: \$transaction\(|\$executeRaw\(|\$queryRaw\(
155
+
156
+ # Sequelize
157
+ grep: \.findAll\(|\.findOne\(|\.create\(|\.update\(|\.destroy\(
158
+ grep: sequelize\.transaction\(
159
+
160
+ # Raw SQL
161
+ grep: \.query\(|\.execute\(|BEGIN|COMMIT|ROLLBACK
162
+ ```
163
+
164
+ ---
165
+
166
+ ## External Service Patterns
167
+
168
+ ```
169
+ # Outbound HTTP (to other services)
170
+ grep: axios\.(get|post|put|patch|delete)\(|fetch\(.*https?://
171
+ grep: got\.(get|post|put|patch|delete)\(|request\.(get|post|put|patch|delete)\(
172
+
173
+ # Git operations
174
+ grep: git.*push|git.*commit|createBlob|createTree|createCommit|updateRef
175
+ grep: octokit\.|@octokit/
176
+
177
+ # Email
178
+ grep: sendMail|transporter\.send|sgMail\.send|resend\.send
179
+
180
+ # File storage
181
+ grep: s3\.upload|s3\.putObject|uploadToS3|writeFile.*storage
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Workflow Complexity Indicators
187
+
188
+ Patterns that suggest a route is a real workflow (not simple CRUD):
189
+
190
+ ```
191
+ # Async dispatch (work happens later)
192
+ grep: startWorkflow\(|\.add\(.*queue|emit\(|publish\(
193
+
194
+ # Multi-step (sequential calls)
195
+ # Look for functions with 3+ await statements to different services
196
+
197
+ # Transaction blocks
198
+ grep: \$transaction|\$executeRaw|BEGIN.*COMMIT|withTransaction
199
+
200
+ # Polling/status endpoints
201
+ grep: /status\?|workflowId|jobId|runId
202
+
203
+ # Version/conflict checks
204
+ grep: version.*conflict|optimistic|stale|409
205
+
206
+ # Retry/backoff
207
+ grep: maximumAttempts|retry|backoff|exponential
208
+
209
+ # Child/sub workflows
210
+ grep: startChild\(|spawnChild|fork\(
211
+
212
+ # Feature flags / conditional steps
213
+ grep: featureFlag|isEnabled|canAccess
214
+ ```