orchestr8 2.6.0 → 2.7.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 (46) hide show
  1. package/.blueprint/agents/AGENT_BA_CASS.md +2 -112
  2. package/.blueprint/agents/AGENT_DEVELOPER_CODEY.md +1 -40
  3. package/.blueprint/agents/AGENT_SPECIFICATION_ALEX.md +1 -40
  4. package/.blueprint/agents/AGENT_TESTER_NIGEL.md +3 -51
  5. package/.blueprint/agents/GUARDRAILS.md +42 -0
  6. package/.blueprint/features/feature_compressed-feedback/FEATURE_SPEC.md +136 -0
  7. package/.blueprint/features/feature_compressed-feedback/IMPLEMENTATION_PLAN.md +40 -0
  8. package/.blueprint/features/feature_lazy-business-context/FEATURE_SPEC.md +140 -0
  9. package/.blueprint/features/feature_lazy-business-context/IMPLEMENTATION_PLAN.md +54 -0
  10. package/.blueprint/features/feature_model-native-features/FEATURE_SPEC.md +174 -0
  11. package/.blueprint/features/feature_model-native-features/IMPLEMENTATION_PLAN.md +45 -0
  12. package/.blueprint/features/feature_shared-guardrails/FEATURE_SPEC.md +119 -0
  13. package/.blueprint/features/feature_shared-guardrails/IMPLEMENTATION_PLAN.md +34 -0
  14. package/.blueprint/features/feature_shared-guardrails/story-extract-guardrails.md +60 -0
  15. package/.blueprint/features/feature_shared-guardrails/story-update-init-commands.md +63 -0
  16. package/.blueprint/features/feature_slim-agent-prompts/FEATURE_SPEC.md +145 -0
  17. package/.blueprint/features/feature_slim-agent-prompts/IMPLEMENTATION_PLAN.md +87 -0
  18. package/.blueprint/features/feature_slim-agent-prompts/story-create-runtime-prompt-template.md +59 -0
  19. package/.blueprint/features/feature_slim-agent-prompts/story-create-slim-agent-prompts.md +65 -0
  20. package/.blueprint/features/feature_slim-agent-prompts/story-skill-integration.md +53 -0
  21. package/.blueprint/features/feature_smart-story-routing/FEATURE_SPEC.md +147 -0
  22. package/.blueprint/features/feature_smart-story-routing/IMPLEMENTATION_PLAN.md +73 -0
  23. package/.blueprint/features/feature_template-extraction/FEATURE_SPEC.md +134 -0
  24. package/.blueprint/features/feature_template-extraction/IMPLEMENTATION_PLAN.md +46 -0
  25. package/.blueprint/features/feature_upstream-summaries/FEATURE_SPEC.md +150 -0
  26. package/.blueprint/features/feature_upstream-summaries/IMPLEMENTATION_PLAN.md +70 -0
  27. package/.blueprint/prompts/TEMPLATE.md +65 -0
  28. package/.blueprint/prompts/alex-runtime.md +48 -0
  29. package/.blueprint/prompts/cass-runtime.md +45 -0
  30. package/.blueprint/prompts/codey-implement-runtime.md +50 -0
  31. package/.blueprint/prompts/codey-plan-runtime.md +46 -0
  32. package/.blueprint/prompts/nigel-runtime.md +46 -0
  33. package/.blueprint/templates/STORY_TEMPLATE.md +96 -0
  34. package/.blueprint/templates/TEST_TEMPLATE.md +76 -0
  35. package/README.md +94 -18
  36. package/SKILL.md +180 -80
  37. package/package.json +2 -2
  38. package/src/business-context.js +91 -0
  39. package/src/classifier.js +173 -0
  40. package/src/feedback.js +47 -17
  41. package/src/handoff.js +148 -0
  42. package/src/index.js +51 -1
  43. package/src/tools/index.js +27 -0
  44. package/src/tools/prompts.js +45 -0
  45. package/src/tools/schemas.js +38 -0
  46. package/src/tools/validation.js +83 -0
package/SKILL.md CHANGED
@@ -21,6 +21,9 @@ description: Run the Alex → Cass → Nigel → Codey pipeline using Task tool
21
21
  | `{HISTORY}` | `.claude/pipeline-history.json` |
22
22
  | `{RETRY_CONFIG}` | `.claude/retry-config.json` |
23
23
  | `{FEEDBACK_CONFIG}` | `.claude/feedback-config.json` |
24
+ | `{HANDOFF_ALEX}` | `{FEAT_DIR}/handoff-alex.md` |
25
+ | `{HANDOFF_CASS}` | `{FEAT_DIR}/handoff-cass.md` |
26
+ | `{HANDOFF_NIGEL}` | `{FEAT_DIR}/handoff-nigel.md` |
24
27
 
25
28
  ## Invocation
26
29
 
@@ -154,37 +157,64 @@ historyEntry = {
154
157
 
155
158
  **History:** Record `stages.alex.startedAt` before spawning.
156
159
 
160
+ **Runtime prompt:** `.blueprint/prompts/alex-runtime.md`
161
+
157
162
  Use the Task tool with `subagent_type="general-purpose"`:
158
163
 
159
164
  **Prompt:**
160
165
  ```
161
- You are Alex, the System Specification & Chief-of-Staff Agent.
166
+ You are Alex, the System Specification Agent.
162
167
 
163
- Read your full specification from: .blueprint/agents/AGENT_SPECIFICATION_ALEX.md
168
+ ## Task
164
169
 
165
- ## Your Task
166
- Create a feature specification for "{slug}".
170
+ Create a feature specification for "{slug}" that translates system intent into a bounded, reviewable unit.
167
171
 
168
172
  ## Inputs (read these files)
169
173
  - System Spec: .blueprint/system_specification/SYSTEM_SPEC.md
170
174
  - Template: .blueprint/templates/FEATURE_SPEC.md
171
175
  - Business Context: .business_context/
172
176
 
173
- ## Output (write this file)
174
- Write the feature spec to: {FEAT_DIR}/FEATURE_SPEC.md
177
+ ## Outputs (write these files)
178
+ 1. Write the feature spec to: {FEAT_DIR}/FEATURE_SPEC.md
179
+ 2. Write handoff summary to: {FEAT_DIR}/handoff-alex.md
180
+
181
+ ## Handoff Summary Format
182
+ ```markdown
183
+ ## Handoff Summary
184
+ **For:** Cass
185
+ **Feature:** {slug}
186
+
187
+ ### Key Decisions
188
+ - (1-5 bullets: key architectural/scope decisions)
189
+
190
+ ### Files Created
191
+ - {FEAT_DIR}/FEATURE_SPEC.md
192
+
193
+ ### Open Questions
194
+ - (List any unresolved questions, or "None")
175
195
 
176
- ## Output Rules
177
- - Write file incrementally (section by section if large)
178
- - Only include sections relevant to this feature (skip empty/N/A sections)
179
- - Reference system spec by path, don't repeat its content
196
+ ### Critical Context
197
+ (Brief context Cass needs to write stories effectively)
198
+ ```
199
+
200
+ ## Rules
201
+ - Write feature spec FIRST, then write handoff summary
202
+ - Reference system spec by path, do not repeat its content
180
203
  - Keep Change Log to 1-2 entries max
204
+ - Flag ambiguities explicitly rather than guessing
205
+ - Ensure feature aligns with system boundaries
206
+ - Make inferred interpretations explicit
207
+ - Handoff summary must be under 30 lines
181
208
 
182
209
  ## Completion
183
210
  Brief summary (5 bullets max): intent, key behaviours, scope, story themes, tensions
211
+
212
+ ## Reference
213
+ For detailed guidance, see: .blueprint/agents/AGENT_SPECIFICATION_ALEX.md
184
214
  ```
185
215
 
186
216
  **On completion:**
187
- 1. Verify `{FEAT_SPEC}` exists
217
+ 1. Verify `{FEAT_SPEC}` and `{FEAT_DIR}/handoff-alex.md` exist
188
218
  2. **Record history:** `stages.alex = { completedAt, durationMs, status: "success" }`
189
219
  3. Update queue: move feature to `cassQueue`
190
220
  4. If `--pause-after=alex`: Show output path, ask user to continue
@@ -201,13 +231,9 @@ Unless `--no-feedback` flag is set, collect feedback before Cass writes stories:
201
231
 
202
232
  **Prompt addition to Cass:**
203
233
  ```
204
- FIRST, before writing stories, evaluate Alex's feature spec:
205
- - Rating (1-5): How clear and complete is the spec?
206
- - Issues: List any problems (e.g., "missing-error-handling", "unclear-scope")
207
- - Recommendation: "proceed" | "pause" | "revise"
208
-
209
- Output your feedback as:
210
- FEEDBACK: { "rating": N, "issues": [...], "recommendation": "..." }
234
+ FEEDBACK FIRST: Rate Alex's spec 1-5, list issues (e.g., unclear-scope), recommend proceed|pause|revise.
235
+ Format: FEEDBACK: {"rating":N,"issues":["..."],"rec":"proceed|pause|revise"}
236
+ Then continue with your task.
211
237
  ```
212
238
 
213
239
  **Quality Gate Check:**
@@ -223,42 +249,73 @@ FEEDBACK: { "rating": N, "issues": [...], "recommendation": "..." }
223
249
 
224
250
  **History:** Record `stages.cass.startedAt` before spawning.
225
251
 
252
+ **Runtime prompt:** `.blueprint/prompts/cass-runtime.md`
253
+
226
254
  Use the Task tool with `subagent_type="general-purpose"`:
227
255
 
228
256
  **Prompt:**
229
257
  ```
230
258
  You are Cass, the Story Writer Agent.
231
259
 
232
- Read your full specification from: .blueprint/agents/AGENT_BA_CASS.md
260
+ ## Task
233
261
 
234
- ## Your Task
235
- Create user stories for feature "{slug}".
262
+ Create user stories for feature "{slug}" with explicit, testable acceptance criteria.
236
263
 
237
264
  ## Inputs (read these files)
238
- - Feature Spec: {FEAT_DIR}/FEATURE_SPEC.md
265
+ - Handoff Summary: {FEAT_DIR}/handoff-alex.md (read FIRST for quick context)
266
+ - Feature Spec: {FEAT_DIR}/FEATURE_SPEC.md (full details if needed)
239
267
  - System Spec: .blueprint/system_specification/SYSTEM_SPEC.md
240
268
 
241
- ## Output (write these files)
242
- Create one markdown file per user story in {FEAT_DIR}/:
243
- - story-{story-slug}.md (e.g., story-login.md, story-logout.md)
269
+ ## Outputs (write these files)
270
+ 1. Create one markdown file per user story in {FEAT_DIR}/:
271
+ - story-{story-slug}.md (e.g., story-login.md, story-logout.md)
272
+ 2. Write handoff summary to: {FEAT_DIR}/handoff-cass.md
244
273
 
245
274
  Each story must include:
246
- - User story in standard format
275
+ - User story in standard format (As a... I want... so that...)
247
276
  - Acceptance criteria (Given/When/Then) - max 5-7 per story
248
277
  - Out of scope items (brief list)
249
278
 
250
- ## Output Rules
279
+ ## Handoff Summary Format
280
+ ```markdown
281
+ ## Handoff Summary
282
+ **For:** Nigel
283
+ **Feature:** {slug}
284
+
285
+ ### Key Decisions
286
+ - (1-5 bullets: story structure decisions, AC approach)
287
+
288
+ ### Files Created
289
+ - {FEAT_DIR}/story-*.md (list each file)
290
+
291
+ ### Open Questions
292
+ - (List any unresolved questions, or "None")
293
+
294
+ ### Critical Context
295
+ (Brief context Nigel needs to write tests effectively)
296
+ ```
297
+
298
+ ## Rules
299
+ - Read Alex's handoff summary FIRST for quick orientation
251
300
  - Write ONE story file at a time, then move to next
301
+ - Write handoff summary LAST after all stories complete
252
302
  - Keep each story focused - split large stories into multiple files
303
+ - Make routing explicit (Previous, Continue, conditional paths)
253
304
  - Reference feature spec by path for shared context
254
- - Skip boilerplate sections (session shape only if non-obvious)
305
+ - Do not guess policy detail without flagging assumptions
306
+ - Avoid implicit behaviour - all routes must be explicit
307
+ - Handoff summary must be under 30 lines
255
308
 
256
309
  ## Completion
257
310
  Brief summary: story count, filenames, behaviours covered (5 bullets max)
311
+
312
+ ## Reference
313
+ For detailed guidance, see: .blueprint/agents/AGENT_BA_CASS.md
258
314
  ```
259
315
 
260
316
  **On completion:**
261
317
  1. Verify at least one `story-*.md` exists in `{FEAT_DIR}`
318
+ 2. Verify `{FEAT_DIR}/handoff-cass.md` exists
262
319
  2. **Record history:** `stages.cass = { completedAt, durationMs, status: "success" }`
263
320
  3. Update queue: move feature to `nigelQueue`
264
321
  4. If `--pause-after=cass`: Show story paths, ask user to continue
@@ -275,13 +332,9 @@ Unless `--no-feedback` flag is set:
275
332
 
276
333
  **Prompt addition to Nigel:**
277
334
  ```
278
- FIRST, before writing tests, evaluate Cass's user stories:
279
- - Rating (1-5): How testable are the stories?
280
- - Issues: List any problems (e.g., "ambiguous-ac", "missing-edge-cases")
281
- - Recommendation: "proceed" | "pause" | "revise"
282
-
283
- Output your feedback as:
284
- FEEDBACK: { "rating": N, "issues": [...], "recommendation": "..." }
335
+ FEEDBACK FIRST: Rate Cass's stories 1-5, list issues (e.g., ambiguous-ac), recommend proceed|pause|revise.
336
+ Format: FEEDBACK: {"rating":N,"issues":["..."],"rec":"proceed|pause|revise"}
337
+ Then continue with your task.
285
338
  ```
286
339
 
287
340
  **Quality Gate Check:** Same as Step 6.5
@@ -294,45 +347,76 @@ FEEDBACK: { "rating": N, "issues": [...], "recommendation": "..." }
294
347
 
295
348
  **History:** Record `stages.nigel.startedAt` before spawning.
296
349
 
350
+ **Runtime prompt:** `.blueprint/prompts/nigel-runtime.md`
351
+
297
352
  Use the Task tool with `subagent_type="general-purpose"`:
298
353
 
299
354
  **Prompt:**
300
355
  ```
301
356
  You are Nigel, the Tester Agent.
302
357
 
303
- Read your full specification from: .blueprint/agents/AGENT_TESTER_NIGEL.md
358
+ ## Task
304
359
 
305
- ## Your Task
306
- Create tests for feature "{slug}".
360
+ Create tests for feature "{slug}" that expose ambiguities and provide a stable contract for implementation.
307
361
 
308
362
  ## Inputs (read these files)
309
- - Stories: {FEAT_DIR}/story-*.md
310
- - Feature Spec: {FEAT_DIR}/FEATURE_SPEC.md
363
+ - Handoff Summary: {FEAT_DIR}/handoff-cass.md (read FIRST for quick context)
364
+ - Stories: {FEAT_DIR}/story-*.md (full details)
365
+ - Feature Spec: {FEAT_DIR}/FEATURE_SPEC.md (if additional context needed)
311
366
 
312
- ## Outputs (write these files IN ORDER, one at a time)
367
+ ## Outputs (write these files IN ORDER)
313
368
 
314
369
  Step 1: Write {TEST_DIR}/test-spec.md containing:
315
370
  - Brief understanding (5-10 lines)
316
- - AC Test ID mapping table (compact)
371
+ - AC to Test ID mapping table (compact)
317
372
  - Key assumptions (bullet list)
318
373
 
319
374
  Step 2: Write {TEST_FILE} containing:
320
- - Executable tests (Jest/Node test runner)
321
- - Group by user story
322
- - One describe block per story, one test per AC
323
-
324
- ## Output Rules
325
- - Write test-spec.md FIRST, then write test file
326
- - Keep test-spec.md under 100 lines (table format, no prose)
327
- - Tests should be self-documenting - minimal comments
375
+ - Executable tests (Jest or Node test runner)
376
+ - One describe block per story
377
+ - One test per acceptance criterion
378
+
379
+ Step 3: Write handoff summary to: {FEAT_DIR}/handoff-nigel.md
380
+
381
+ ## Handoff Summary Format
382
+ ```markdown
383
+ ## Handoff Summary
384
+ **For:** Codey
385
+ **Feature:** {slug}
386
+
387
+ ### Key Decisions
388
+ - (1-5 bullets: test approach, mocking strategy, coverage focus)
389
+
390
+ ### Files Created
391
+ - {TEST_DIR}/test-spec.md
392
+ - {TEST_FILE}
393
+
394
+ ### Open Questions
395
+ - (List any unresolved questions, or "None")
396
+
397
+ ### Critical Context
398
+ (Brief context Codey needs to implement effectively)
399
+ ```
400
+
401
+ ## Rules
402
+ - Read Cass's handoff summary FIRST for quick orientation
403
+ - Write test-spec.md FIRST, then write test file, then handoff summary LAST
404
+ - Keep test-spec.md under 100 lines using table format
405
+ - Tests should be self-documenting with minimal comments
328
406
  - Reference story files by path in test descriptions
407
+ - Make failure states meaningful
408
+ - Focus on externally observable behaviour
409
+ - Handoff summary must be under 30 lines
329
410
 
330
411
  ## Completion
331
412
  Brief summary: test count, AC coverage %, assumptions (5 bullets max)
413
+
414
+ ## Reference
415
+ For detailed guidance, see: .blueprint/agents/AGENT_TESTER_NIGEL.md
332
416
  ```
333
417
 
334
418
  **On completion:**
335
- 1. Verify `{TEST_SPEC}` and `{TEST_FILE}` exist
419
+ 1. Verify `{TEST_SPEC}`, `{TEST_FILE}`, and `{FEAT_DIR}/handoff-nigel.md` exist
336
420
  2. **Record history:** `stages.nigel = { completedAt, durationMs, status: "success" }`
337
421
  3. Update queue: move feature to `codeyQueue`
338
422
  4. If `--pause-after=nigel`: Show test paths, ask user to continue
@@ -349,13 +433,9 @@ Unless `--no-feedback` flag is set:
349
433
 
350
434
  **Prompt addition to Codey (Plan phase):**
351
435
  ```
352
- FIRST, before creating the plan, evaluate Nigel's tests:
353
- - Rating (1-5): How implementable are the tests?
354
- - Issues: List any problems (e.g., "over-mocked", "missing-setup")
355
- - Recommendation: "proceed" | "pause" | "revise"
356
-
357
- Output your feedback as:
358
- FEEDBACK: { "rating": N, "issues": [...], "recommendation": "..." }
436
+ FEEDBACK FIRST: Rate Nigel's tests 1-5, list issues (e.g., over-mocked), recommend proceed|pause|revise.
437
+ Format: FEEDBACK: {"rating":N,"issues":["..."],"rec":"proceed|pause|revise"}
438
+ Then continue with your task.
359
439
  ```
360
440
 
361
441
  **Quality Gate Check:** Same as Step 6.5
@@ -368,31 +448,47 @@ FEEDBACK: { "rating": N, "issues": [...], "recommendation": "..." }
368
448
 
369
449
  **History:** Record `stages.codeyPlan.startedAt` before spawning.
370
450
 
451
+ **Runtime prompt:** `.blueprint/prompts/codey-plan-runtime.md`
452
+
371
453
  Use the Task tool with `subagent_type="general-purpose"`:
372
454
 
373
455
  **Prompt:**
374
456
  ```
375
457
  You are Codey, the Developer Agent.
376
458
 
377
- Read your full specification from: .blueprint/agents/AGENT_DEVELOPER_CODEY.md
459
+ ## Task
378
460
 
379
- ## Your Task
380
- Create an implementation plan for feature "{slug}". Do NOT implement yet.
461
+ Create an implementation plan for feature "{slug}". Do NOT implement yet - planning only.
381
462
 
382
463
  ## Inputs (read these files)
383
- - Feature Spec: {FEAT_DIR}/FEATURE_SPEC.md
384
- - Stories: {FEAT_DIR}/story-*.md
464
+ - Handoff Summary: {FEAT_DIR}/handoff-nigel.md (read FIRST for quick context)
385
465
  - Test Spec: {TEST_DIR}/test-spec.md
386
466
  - Tests: {TEST_FILE}
467
+ - Feature Spec: {FEAT_DIR}/FEATURE_SPEC.md (if additional context needed)
468
+ - Stories: {FEAT_DIR}/story-*.md (if additional context needed)
387
469
 
388
- ## Output (write this file)
470
+ ## Outputs (write this file)
389
471
  Write implementation plan to: {FEAT_DIR}/IMPLEMENTATION_PLAN.md
390
472
 
391
- Plan structure (keep concise - aim for <80 lines total):
392
- ## Summary (2-3 sentences)
393
- ## Files to Create/Modify (table: path | action | purpose)
394
- ## Implementation Steps (numbered, max 10 steps)
395
- ## Risks/Questions (bullet list, only if non-obvious)
473
+ Plan structure (aim for under 80 lines total):
474
+ - Summary (2-3 sentences)
475
+ - Files to Create/Modify (table: path | action | purpose)
476
+ - Implementation Steps (numbered, max 10 steps)
477
+ - Risks/Questions (bullet list, only if non-obvious)
478
+
479
+ ## Rules
480
+ - Read Nigel's handoff summary FIRST for quick orientation
481
+ - Do NOT write implementation code in this phase
482
+ - Keep plan concise and actionable
483
+ - Order steps to make tests pass incrementally
484
+ - Identify which tests each step addresses
485
+ - Prefer editing existing files over creating new ones
486
+
487
+ ## Completion
488
+ Brief summary: files planned, step count, identified risks
489
+
490
+ ## Reference
491
+ For detailed guidance, see: .blueprint/agents/AGENT_DEVELOPER_CODEY.md
396
492
  ```
397
493
 
398
494
  **On completion:**
@@ -408,42 +504,46 @@ Plan structure (keep concise - aim for <80 lines total):
408
504
 
409
505
  **History:** Record `stages.codeyImplement.startedAt` before spawning.
410
506
 
507
+ **Runtime prompt:** `.blueprint/prompts/codey-implement-runtime.md`
508
+
411
509
  Use the Task tool with `subagent_type="general-purpose"`:
412
510
 
413
511
  **Prompt:**
414
512
  ```
415
513
  You are Codey, the Developer Agent.
416
514
 
417
- Read your full specification from: .blueprint/agents/AGENT_DEVELOPER_CODEY.md
515
+ ## Task
418
516
 
419
- ## Your Task
420
- Implement feature "{slug}" according to the plan.
517
+ Implement feature "{slug}" according to the plan. Work incrementally, making tests pass one group at a time.
421
518
 
422
519
  ## Inputs (read these files)
520
+ - Handoff Summary: {FEAT_DIR}/handoff-nigel.md (read FIRST for quick context)
423
521
  - Implementation Plan: {FEAT_DIR}/IMPLEMENTATION_PLAN.md
424
522
  - Tests: {TEST_FILE}
425
523
 
426
524
  ## Process (INCREMENTAL - one file at a time)
427
- 1. Run tests: node --test {TEST_FILE}
428
- 2. For each failing test group:
525
+ 1. Read Nigel's handoff summary for orientation
526
+ 2. Run tests first: node --test {TEST_FILE}
527
+ 3. For each failing test group:
429
528
  a. Identify the minimal code needed
430
- b. Write/edit ONE file
529
+ b. Write or edit ONE file
431
530
  c. Run tests again
432
531
  d. Repeat until group passes
433
532
  3. Move to next test group
434
533
 
435
- ## Output Rules
534
+ ## Rules
436
535
  - Write ONE source file at a time
437
536
  - Run tests after each file write
438
- - Keep functions small (<30 lines)
439
- - No explanatory comments in code - code should be self-documenting
440
-
441
- ## Important
537
+ - Keep functions small (under 30 lines)
538
+ - Code should be self-documenting, minimal comments
442
539
  - Do NOT commit changes
443
540
  - Do NOT modify test assertions unless they contain bugs
444
541
 
445
542
  ## Completion
446
543
  Brief summary: files changed (list), test status (X/Y passing), blockers if any
544
+
545
+ ## Reference
546
+ For detailed guidance, see: .blueprint/agents/AGENT_DEVELOPER_CODEY.md
447
547
  ```
448
548
 
449
549
  **On completion:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orchestr8",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Multi-agent workflow framework for automated feature development",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  "author": "NewmanJustice",
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "git+https://github.com/NewmanJustice/agent-workflow.git"
23
+ "url": "git+https://github.com/NewmanJustice/orchestr8.git"
24
24
  },
25
25
  "license": "MIT",
26
26
  "engines": {
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Business context detection and conditional inclusion module.
3
+ *
4
+ * Implements lazy loading of business context by detecting references
5
+ * in feature specs and conditionally including the context directive
6
+ * based on agent name and detection results.
7
+ */
8
+
9
+ /**
10
+ * Detects if a feature spec content references business context.
11
+ * Matches '.business_context' or 'business_context/' patterns.
12
+ *
13
+ * @param {string} featureSpecContent - The content of the feature spec
14
+ * @returns {boolean} True if business context references are found
15
+ */
16
+ function needsBusinessContext(featureSpecContent) {
17
+ return featureSpecContent.includes('.business_context')
18
+ || featureSpecContent.includes('business_context/');
19
+ }
20
+
21
+ /**
22
+ * Parses command arguments for the --include-business-context flag.
23
+ *
24
+ * @param {string[]} args - Array of command line arguments
25
+ * @returns {boolean} True if the flag is present
26
+ */
27
+ function parseIncludeBusinessContextFlag(args) {
28
+ return args.includes('--include-business-context');
29
+ }
30
+
31
+ /**
32
+ * Determines if an agent should receive business context.
33
+ * Alex always gets business context (exception).
34
+ * Override flag forces inclusion for all agents.
35
+ * Otherwise, uses detection result.
36
+ *
37
+ * @param {string} agentName - Name of the agent (alex, cass, nigel, codey)
38
+ * @param {boolean} detected - Whether business context was detected in spec
39
+ * @param {boolean} overrideFlag - Whether --include-business-context flag is set
40
+ * @returns {boolean} True if agent should receive business context
41
+ */
42
+ function shouldIncludeBusinessContext(agentName, detected, overrideFlag) {
43
+ // Alex always gets business context
44
+ if (agentName.toLowerCase() === 'alex') {
45
+ return true;
46
+ }
47
+ // Override flag forces inclusion
48
+ if (overrideFlag) {
49
+ return true;
50
+ }
51
+ // Otherwise use detection result
52
+ return detected;
53
+ }
54
+
55
+ /**
56
+ * Builds queue state object with business context detection result.
57
+ *
58
+ * @param {string} featureSlug - The feature slug identifier
59
+ * @param {boolean} needsContext - Whether business context is needed
60
+ * @returns {object} Queue state object
61
+ */
62
+ function buildQueueState(featureSlug, needsContext) {
63
+ return {
64
+ feature: featureSlug,
65
+ current: {
66
+ stage: 'pending',
67
+ needsBusinessContext: needsContext
68
+ }
69
+ };
70
+ }
71
+
72
+ /**
73
+ * Generates the business context directive for agent prompts.
74
+ *
75
+ * @param {boolean} includeContext - Whether to include the directive
76
+ * @returns {string} The directive string or empty string
77
+ */
78
+ function generateBusinessContextDirective(includeContext) {
79
+ if (includeContext) {
80
+ return 'Business Context: .business_context/';
81
+ }
82
+ return '';
83
+ }
84
+
85
+ module.exports = {
86
+ needsBusinessContext,
87
+ parseIncludeBusinessContextFlag,
88
+ shouldIncludeBusinessContext,
89
+ buildQueueState,
90
+ generateBusinessContextDirective
91
+ };