opencode-orchestrator 0.8.22 → 0.9.1
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.
- package/README.md +31 -26
- package/dist/agents/commander.d.ts +2 -1
- package/dist/agents/prompts/commander/index.d.ts +2 -0
- package/dist/agents/prompts/commander/loop-continuation.d.ts +6 -0
- package/dist/agents/prompts/commander/sync-handling.d.ts +6 -0
- package/dist/agents/prompts/common/shared-workspace.d.ts +1 -1
- package/dist/agents/prompts/planner/file-planning.d.ts +6 -0
- package/dist/agents/prompts/planner/index.d.ts +2 -0
- package/dist/agents/prompts/planner/todo-sync.d.ts +6 -0
- package/dist/agents/prompts/reviewer/async-monitoring.d.ts +6 -0
- package/dist/agents/prompts/reviewer/index.d.ts +3 -0
- package/dist/agents/prompts/reviewer/integration-testing.d.ts +7 -0
- package/dist/agents/prompts/reviewer/sync-verification.d.ts +6 -0
- package/dist/agents/prompts/worker/file-assignment.d.ts +6 -0
- package/dist/agents/prompts/worker/index.d.ts +3 -0
- package/dist/agents/prompts/worker/isolation-testing.d.ts +6 -0
- package/dist/agents/prompts/worker/tdd-workflow.d.ts +7 -0
- package/dist/agents/subagents/planner.d.ts +2 -1
- package/dist/agents/subagents/reviewer.d.ts +1 -1
- package/dist/agents/subagents/worker.d.ts +3 -2
- package/dist/index.js +904 -19
- package/dist/shared/core/constants/id-prefix.d.ts +7 -1
- package/dist/shared/core/constants/paths.d.ts +4 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/prompt/constants/index.d.ts +5 -0
- package/dist/shared/prompt/constants/status.d.ts +34 -0
- package/dist/shared/prompt/constants/tags.d.ts +147 -0
- package/dist/shared/prompt/index.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -56,7 +56,10 @@ var TIME = {
|
|
|
56
56
|
var ID_PREFIX = {
|
|
57
57
|
TASK: "task_",
|
|
58
58
|
JOB: "job_",
|
|
59
|
-
SESSION: "
|
|
59
|
+
SESSION: "ses_",
|
|
60
|
+
SYNC_ISSUE: "SYNC-",
|
|
61
|
+
UNIT_TEST: "UT-",
|
|
62
|
+
WORKER: "wrk_"
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
// src/shared/core/constants/paths.ts
|
|
@@ -69,7 +72,12 @@ var PATHS = {
|
|
|
69
72
|
TODO: ".opencode/todo.md",
|
|
70
73
|
CONTEXT: ".opencode/context.md",
|
|
71
74
|
SUMMARY: ".opencode/summary.md",
|
|
72
|
-
DOC_METADATA: ".opencode/docs/_metadata.json"
|
|
75
|
+
DOC_METADATA: ".opencode/docs/_metadata.json",
|
|
76
|
+
// TDD & Parallel Work State
|
|
77
|
+
WORK_LOG: ".opencode/work-log.md",
|
|
78
|
+
UNIT_TESTS: ".opencode/unit-tests",
|
|
79
|
+
SYNC_ISSUES: ".opencode/sync-issues.md",
|
|
80
|
+
INTEGRATION_STATUS: ".opencode/integration-status.md"
|
|
73
81
|
};
|
|
74
82
|
|
|
75
83
|
// src/shared/core/constants/memory-limits.ts
|
|
@@ -344,6 +352,85 @@ function detectErrorType(error45) {
|
|
|
344
352
|
return null;
|
|
345
353
|
}
|
|
346
354
|
|
|
355
|
+
// src/shared/prompt/constants/tags.ts
|
|
356
|
+
var PROMPT_TAGS = {
|
|
357
|
+
// === Common ===
|
|
358
|
+
ROLE: { open: "<role>", close: "</role>" },
|
|
359
|
+
IDENTITY: { open: "<identity>", close: "</identity>" },
|
|
360
|
+
FORBIDDEN_ACTIONS: { open: "<forbidden_actions>", close: "</forbidden_actions>" },
|
|
361
|
+
REQUIRED_ACTIONS: { open: "<required_actions>", close: "</required_actions>" },
|
|
362
|
+
VERIFICATION: { open: "<verification>", close: "</verification>" },
|
|
363
|
+
ENVIRONMENT_DISCOVERY: { open: "<environment_discovery>", close: "</environment_discovery>" },
|
|
364
|
+
ANTI_HALLUCINATION: { open: "<anti_hallucination>", close: "</anti_hallucination>" },
|
|
365
|
+
TODO_RULES: { open: "<todo_rules>", close: "</todo_rules>" },
|
|
366
|
+
MISSION_SEAL: { open: "<mission_seal>", close: "</mission_seal>" },
|
|
367
|
+
SHARED_WORKSPACE: { open: "<shared_workspace>", close: "</shared_workspace>" },
|
|
368
|
+
// === Commander ===
|
|
369
|
+
TOOLS: { open: "<tools>", close: "</tools>" },
|
|
370
|
+
AGENTS: { open: "<agents>", close: "</agents>" },
|
|
371
|
+
EXECUTION_STRATEGY: { open: "<execution_strategy>", close: "</execution_strategy>" },
|
|
372
|
+
PARALLEL_EXECUTION: { open: "<parallel_execution>", close: "</parallel_execution>" },
|
|
373
|
+
TODO_FORMAT: { open: "<todo_format>", close: "</todo_format>" },
|
|
374
|
+
SYNC_ISSUE_HANDLING: { open: "<sync_issue_handling>", close: "</sync_issue_handling>" },
|
|
375
|
+
LOOP_CONTINUATION: { open: "<loop_continuation>", close: "</loop_continuation>" },
|
|
376
|
+
// === Planner ===
|
|
377
|
+
FILE_LEVEL_PLANNING: { open: "<file_level_planning>", close: "</file_level_planning>" },
|
|
378
|
+
TODO_SYNC: { open: "<todo_sync>", close: "</todo_sync>" },
|
|
379
|
+
PLANNING_FORMAT: { open: "<planning_format>", close: "</planning_format>" },
|
|
380
|
+
RESEARCH_WORKFLOW: { open: "<research_workflow>", close: "</research_workflow>" },
|
|
381
|
+
// === Worker ===
|
|
382
|
+
FILE_ASSIGNMENT: { open: "<file_assignment>", close: "</file_assignment>" },
|
|
383
|
+
TDD_WORKFLOW: { open: "<tdd_workflow>", close: "</tdd_workflow>" },
|
|
384
|
+
ISOLATION_TESTING: { open: "<isolation_testing>", close: "</isolation_testing>" },
|
|
385
|
+
WORKFLOW: { open: "<workflow>", close: "</workflow>" },
|
|
386
|
+
QUALITY_CHECKLIST: { open: "<quality_checklist>", close: "</quality_checklist>" },
|
|
387
|
+
// === Reviewer ===
|
|
388
|
+
SYNC_VERIFICATION: { open: "<sync_verification>", close: "</sync_verification>" },
|
|
389
|
+
ASYNC_MONITORING: { open: "<async_monitoring>", close: "</async_monitoring>" },
|
|
390
|
+
INTEGRATION_TESTING: { open: "<integration_testing>", close: "</integration_testing>" },
|
|
391
|
+
VERIFICATION_PROCESS: { open: "<verification_process>", close: "</verification_process>" },
|
|
392
|
+
TODO_MANAGEMENT: { open: "<todo_management>", close: "</todo_management>" },
|
|
393
|
+
OUTPUT_FORMAT: { open: "<output_format>", close: "</output_format>" },
|
|
394
|
+
// === Mission Loop ===
|
|
395
|
+
MISSION_LOOP: { open: "<mission_loop>", close: "</mission_loop>" }
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
// src/shared/prompt/constants/status.ts
|
|
399
|
+
var WORK_STATUS = {
|
|
400
|
+
// File action types
|
|
401
|
+
ACTION: {
|
|
402
|
+
CREATE: "CREATE",
|
|
403
|
+
MODIFY: "MODIFY",
|
|
404
|
+
DELETE: "DELETE",
|
|
405
|
+
FIX: "FIX"
|
|
406
|
+
},
|
|
407
|
+
// Task/file status
|
|
408
|
+
STATUS: {
|
|
409
|
+
PENDING: "PENDING",
|
|
410
|
+
IN_PROGRESS: "IN_PROGRESS",
|
|
411
|
+
DONE: "DONE",
|
|
412
|
+
FAILED: "FAILED"
|
|
413
|
+
},
|
|
414
|
+
// Test result
|
|
415
|
+
TEST_RESULT: {
|
|
416
|
+
PASS: "PASS",
|
|
417
|
+
FAIL: "FAIL",
|
|
418
|
+
SKIP: "SKIP"
|
|
419
|
+
},
|
|
420
|
+
// Issue severity
|
|
421
|
+
SEVERITY: {
|
|
422
|
+
HIGH: "HIGH",
|
|
423
|
+
MEDIUM: "MEDIUM",
|
|
424
|
+
LOW: "LOW"
|
|
425
|
+
},
|
|
426
|
+
// Session state
|
|
427
|
+
SESSION: {
|
|
428
|
+
STARTED: "STARTED",
|
|
429
|
+
COMPLETED: "COMPLETED",
|
|
430
|
+
CANCELLED: "CANCELLED"
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
347
434
|
// src/core/agents/consts/task-status.const.ts
|
|
348
435
|
var TASK_STATUS = {
|
|
349
436
|
PENDING: "pending",
|
|
@@ -12917,25 +13004,64 @@ FORBIDDEN:
|
|
|
12917
13004
|
</todo_rules>`;
|
|
12918
13005
|
|
|
12919
13006
|
// src/agents/prompts/common/shared-workspace.ts
|
|
12920
|
-
var SHARED_WORKSPACE =
|
|
12921
|
-
.opencode/ - Shared Context Directory
|
|
13007
|
+
var SHARED_WORKSPACE = `${PROMPT_TAGS.SHARED_WORKSPACE.open}
|
|
13008
|
+
.opencode/ - Shared Context Directory (Real-time State)
|
|
12922
13009
|
|
|
12923
13010
|
\`\`\`
|
|
12924
13011
|
.opencode/
|
|
12925
|
-
\u251C\u2500\u2500 todo.md
|
|
12926
|
-
\u251C\u2500\u2500 context.md
|
|
12927
|
-
\u251C\u2500\u2500
|
|
12928
|
-
\u2502
|
|
12929
|
-
\u2502
|
|
12930
|
-
\
|
|
13012
|
+
\u251C\u2500\u2500 todo.md - Master task list (single source of truth)
|
|
13013
|
+
\u251C\u2500\u2500 context.md - Project context summary (<150 lines)
|
|
13014
|
+
\u251C\u2500\u2500 work-log.md - \u{1F504} REAL-TIME work status (ALL agents read/write)
|
|
13015
|
+
\u2502 # - Active sessions & assigned files
|
|
13016
|
+
\u2502 # - Unit test completion records
|
|
13017
|
+
\u2502 # - Pending integration items
|
|
13018
|
+
\u251C\u2500\u2500 unit-tests/ - \u{1F4DD} Unit test records (preserved after deletion)
|
|
13019
|
+
\u2502 \u2514\u2500\u2500 [timestamp]-[file].md # Test content, results, deleted test code
|
|
13020
|
+
\u251C\u2500\u2500 sync-issues.md - \u26A0\uFE0F File sync issues (Reviewer writes)
|
|
13021
|
+
\u251C\u2500\u2500 integration-status.md - \u2705 Integration test results & sync status
|
|
13022
|
+
\u251C\u2500\u2500 docs/ - Cached documentation
|
|
13023
|
+
\u2514\u2500\u2500 archive/ - Old context
|
|
13024
|
+
\`\`\`
|
|
13025
|
+
|
|
13026
|
+
## ID Formats (no digit limit):
|
|
13027
|
+
- Session: ${ID_PREFIX.SESSION}N (e.g., ${ID_PREFIX.SESSION}1, ${ID_PREFIX.SESSION}42)
|
|
13028
|
+
- Sync Issue: ${ID_PREFIX.SYNC_ISSUE}N (e.g., ${ID_PREFIX.SYNC_ISSUE}1, ${ID_PREFIX.SYNC_ISSUE}100)
|
|
13029
|
+
- Unit Test: ${ID_PREFIX.UNIT_TEST}N (e.g., ${ID_PREFIX.UNIT_TEST}1, ${ID_PREFIX.UNIT_TEST}50)
|
|
13030
|
+
|
|
13031
|
+
## Status Values:
|
|
13032
|
+
- Action: ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.ACTION.MODIFY} | ${WORK_STATUS.ACTION.DELETE} | ${WORK_STATUS.ACTION.FIX}
|
|
13033
|
+
- Status: ${WORK_STATUS.STATUS.PENDING} | ${WORK_STATUS.STATUS.IN_PROGRESS} | ${WORK_STATUS.STATUS.DONE}
|
|
13034
|
+
- Test: ${WORK_STATUS.TEST_RESULT.PASS} | ${WORK_STATUS.TEST_RESULT.FAIL}
|
|
13035
|
+
|
|
13036
|
+
## work-log.md FORMAT:
|
|
13037
|
+
\`\`\`markdown
|
|
13038
|
+
# Work Log
|
|
13039
|
+
|
|
13040
|
+
## Active Sessions
|
|
13041
|
+
- [ ] ${ID_PREFIX.SESSION}1 (Worker): \`src/auth/login.ts\` - ${WORK_STATUS.STATUS.IN_PROGRESS}
|
|
13042
|
+
- [x] ${ID_PREFIX.SESSION}2 (Worker): \`src/utils/hash.ts\` - ${WORK_STATUS.SESSION.COMPLETED}
|
|
13043
|
+
|
|
13044
|
+
## Completed Units (Ready for Integration)
|
|
13045
|
+
| File | Session | Unit Test | Timestamp |
|
|
13046
|
+
|------|---------|-----------|-----------|
|
|
13047
|
+
| src/utils/hash.ts | ${ID_PREFIX.SESSION}2 | ${WORK_STATUS.TEST_RESULT.PASS} | 2026-01-18T09:00:00 |
|
|
13048
|
+
|
|
13049
|
+
## Pending Integration
|
|
13050
|
+
- src/utils/hash.ts
|
|
12931
13051
|
\`\`\`
|
|
12932
13052
|
|
|
13053
|
+
## PATH NOTES:
|
|
13054
|
+
- File paths use forward slash '/' in examples
|
|
13055
|
+
- On Windows, paths may use backslash '\\\\'
|
|
13056
|
+
- Use path.normalize() or similar when comparing paths programmatically
|
|
13057
|
+
|
|
12933
13058
|
RULES:
|
|
12934
|
-
- ALL agents
|
|
12935
|
-
-
|
|
12936
|
-
-
|
|
12937
|
-
-
|
|
12938
|
-
|
|
13059
|
+
- ALL agents MUST read work-log.md before starting
|
|
13060
|
+
- Worker updates work-log.md when starting/completing file work
|
|
13061
|
+
- Reviewer monitors work-log.md for completed units
|
|
13062
|
+
- Commander reads work-log.md in each loop iteration
|
|
13063
|
+
- sync-issues.md = Reviewer writes issues for next iteration
|
|
13064
|
+
${PROMPT_TAGS.SHARED_WORKSPACE.close}`;
|
|
12939
13065
|
|
|
12940
13066
|
// src/agents/prompts/common/mission-seal.ts
|
|
12941
13067
|
var MISSION_SEAL_RULES = `<mission_seal>
|
|
@@ -13156,6 +13282,181 @@ Create all items with [ ] - NEVER with [x]!
|
|
|
13156
13282
|
Only ${AGENT_NAMES.REVIEWER} marks [x] after verification!
|
|
13157
13283
|
</todo_format>`;
|
|
13158
13284
|
|
|
13285
|
+
// src/agents/prompts/commander/loop-continuation.ts
|
|
13286
|
+
var COMMANDER_LOOP_CONTINUATION = `${PROMPT_TAGS.LOOP_CONTINUATION.open}
|
|
13287
|
+
## LOOP CONTINUATION PROTOCOL
|
|
13288
|
+
|
|
13289
|
+
At the START of each loop iteration, Commander MUST read shared state:
|
|
13290
|
+
|
|
13291
|
+
### Step 1: Read Work Status
|
|
13292
|
+
\`\`\`bash
|
|
13293
|
+
cat ${PATHS.WORK_LOG}
|
|
13294
|
+
cat ${PATHS.TODO}
|
|
13295
|
+
\`\`\`
|
|
13296
|
+
|
|
13297
|
+
### Step 2: Check for Sync Issues
|
|
13298
|
+
\`\`\`bash
|
|
13299
|
+
cat ${PATHS.SYNC_ISSUES} 2>/dev/null || echo "No sync issues"
|
|
13300
|
+
\`\`\`
|
|
13301
|
+
|
|
13302
|
+
---
|
|
13303
|
+
|
|
13304
|
+
## \u26A0\uFE0F SEALED CONDITIONS (CRITICAL!)
|
|
13305
|
+
|
|
13306
|
+
### SEALED = BOTH must be true:
|
|
13307
|
+
\`\`\`
|
|
13308
|
+
\u2705 TODO: ALL items [x] checked
|
|
13309
|
+
\u2705 sync-issues: EMPTY (no unresolved issues)
|
|
13310
|
+
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
13311
|
+
ONLY THEN \u2192 output <mission_seal>SEALED</mission_seal>
|
|
13312
|
+
\`\`\`
|
|
13313
|
+
|
|
13314
|
+
### LOOP BACK = ANY of these:
|
|
13315
|
+
\`\`\`
|
|
13316
|
+
\u274C TODO has unchecked items \u2192 LOOP
|
|
13317
|
+
\u274C sync-issues.md is NOT empty \u2192 LOOP
|
|
13318
|
+
\u274C Build fails \u2192 LOOP
|
|
13319
|
+
\u274C E2E test fails \u2192 LOOP
|
|
13320
|
+
\`\`\`
|
|
13321
|
+
|
|
13322
|
+
### \u26D4 NEVER SEAL IF:
|
|
13323
|
+
- TODO is complete BUT sync-issues has content
|
|
13324
|
+
- Workers are still active
|
|
13325
|
+
- Build or E2E tests failed
|
|
13326
|
+
|
|
13327
|
+
---
|
|
13328
|
+
|
|
13329
|
+
## \u{1F504} E2E Test Timing
|
|
13330
|
+
|
|
13331
|
+
E2E tests start when **TODO is nearly complete** (not at the very end):
|
|
13332
|
+
- Reviewer begins E2E when most tasks are done
|
|
13333
|
+
- E2E runs **parallel** with remaining TODO items
|
|
13334
|
+
- If E2E finds errors \u2192 record in sync-issues.md \u2192 continue with TODO
|
|
13335
|
+
- This allows catching integration issues early
|
|
13336
|
+
|
|
13337
|
+
\`\`\`
|
|
13338
|
+
Timeline:
|
|
13339
|
+
[---TODO progress---] [E2E starts here---]
|
|
13340
|
+
\u2193
|
|
13341
|
+
TODO + E2E run in parallel
|
|
13342
|
+
\u2193
|
|
13343
|
+
Both must complete cleanly \u2192 SEALED
|
|
13344
|
+
\`\`\`
|
|
13345
|
+
|
|
13346
|
+
---
|
|
13347
|
+
|
|
13348
|
+
### Decision Matrix
|
|
13349
|
+
|
|
13350
|
+
| TODO | sync-issues.md | Action |
|
|
13351
|
+
|------|----------------|--------|
|
|
13352
|
+
| Has unchecked | Any | Continue work |
|
|
13353
|
+
| All [x] | NOT empty | \u267B\uFE0F LOOP - fix issues first |
|
|
13354
|
+
| All [x] | Empty | \u2705 SEALED |
|
|
13355
|
+
|
|
13356
|
+
### File-Level Task Assignment
|
|
13357
|
+
Each ${AGENT_NAMES.WORKER} gets ONE file for isolation:
|
|
13358
|
+
\`\`\`
|
|
13359
|
+
delegate_task(file:src/auth/login.ts, ${AGENT_NAMES.WORKER}, background: true)
|
|
13360
|
+
delegate_task(file:src/auth/logout.ts, ${AGENT_NAMES.WORKER}, background: true)
|
|
13361
|
+
\`\`\`
|
|
13362
|
+
|
|
13363
|
+
### CRITICAL RULES:
|
|
13364
|
+
- ALWAYS read ${PATHS.TODO} AND ${PATHS.SYNC_ISSUES} at loop start
|
|
13365
|
+
- NEVER seal with sync-issues content (even if TODO is done!)
|
|
13366
|
+
- NEVER seal with active workers
|
|
13367
|
+
- E2E starts near TODO completion, runs parallel
|
|
13368
|
+
${PROMPT_TAGS.LOOP_CONTINUATION.close}`;
|
|
13369
|
+
|
|
13370
|
+
// src/agents/prompts/commander/sync-handling.ts
|
|
13371
|
+
var COMMANDER_SYNC_HANDLING = `${PROMPT_TAGS.SYNC_ISSUE_HANDLING.open}
|
|
13372
|
+
## SYNC ISSUE HANDLING
|
|
13373
|
+
|
|
13374
|
+
When ${AGENT_NAMES.REVIEWER} reports sync issues, YOU must direct fixes.
|
|
13375
|
+
|
|
13376
|
+
### Step 1: Read Sync Issues
|
|
13377
|
+
\`\`\`bash
|
|
13378
|
+
cat ${PATHS.SYNC_ISSUES}
|
|
13379
|
+
\`\`\`
|
|
13380
|
+
|
|
13381
|
+
### Step 2: Analyze Each Issue
|
|
13382
|
+
For each ${ID_PREFIX.SYNC_ISSUE}N issue:
|
|
13383
|
+
- Which files are involved?
|
|
13384
|
+
- What's the root cause?
|
|
13385
|
+
- What's the fix?
|
|
13386
|
+
|
|
13387
|
+
### Step 3: Instruct Planner
|
|
13388
|
+
Delegate to ${AGENT_NAMES.PLANNER} with SPECIFIC instructions:
|
|
13389
|
+
|
|
13390
|
+
\`\`\`
|
|
13391
|
+
delegate_task(
|
|
13392
|
+
task: "Update TODO for sync fix ${ID_PREFIX.SYNC_ISSUE}1",
|
|
13393
|
+
agent: ${AGENT_NAMES.PLANNER},
|
|
13394
|
+
instructions: "
|
|
13395
|
+
Read ${PATHS.SYNC_ISSUES} for ${ID_PREFIX.SYNC_ISSUE}1.
|
|
13396
|
+
Add FIX tasks for: src/auth/login.ts, src/api/users.ts.
|
|
13397
|
+
Issue: Import mismatch - login.ts exports 'login' but users.ts imports 'authenticate'.
|
|
13398
|
+
Fix: Update users.ts to import 'login' instead of 'authenticate'.
|
|
13399
|
+
Update ${PATHS.WORK_LOG} file status.
|
|
13400
|
+
"
|
|
13401
|
+
)
|
|
13402
|
+
\`\`\`
|
|
13403
|
+
|
|
13404
|
+
### Step 4: Instruct Workers
|
|
13405
|
+
After Planner updates TODO, delegate fixes:
|
|
13406
|
+
|
|
13407
|
+
\`\`\`
|
|
13408
|
+
delegate_task(
|
|
13409
|
+
task: "Fix ${ID_PREFIX.SYNC_ISSUE}1 in src/api/users.ts",
|
|
13410
|
+
agent: ${AGENT_NAMES.WORKER},
|
|
13411
|
+
file: "src/api/users.ts",
|
|
13412
|
+
instructions: "
|
|
13413
|
+
Read ${PATHS.SYNC_ISSUES} ${ID_PREFIX.SYNC_ISSUE}1.
|
|
13414
|
+
Read ${PATHS.WORK_LOG} for context.
|
|
13415
|
+
Fix: Change 'import { authenticate }' to 'import { login }'.
|
|
13416
|
+
Run isolated test.
|
|
13417
|
+
Update ${PATHS.WORK_LOG}.
|
|
13418
|
+
",
|
|
13419
|
+
background: true
|
|
13420
|
+
)
|
|
13421
|
+
\`\`\`
|
|
13422
|
+
|
|
13423
|
+
### Step 5: Invoke Reviewer Again
|
|
13424
|
+
After all fix workers complete:
|
|
13425
|
+
\`\`\`
|
|
13426
|
+
delegate_task(
|
|
13427
|
+
task: "Re-verify after ${ID_PREFIX.SYNC_ISSUE}1 fixes",
|
|
13428
|
+
agent: ${AGENT_NAMES.REVIEWER},
|
|
13429
|
+
instructions: "
|
|
13430
|
+
Verify ${ID_PREFIX.SYNC_ISSUE}1 is resolved.
|
|
13431
|
+
Run integration tests.
|
|
13432
|
+
Clear resolved issues from ${PATHS.SYNC_ISSUES}.
|
|
13433
|
+
Update ${PATHS.INTEGRATION_STATUS}.
|
|
13434
|
+
"
|
|
13435
|
+
)
|
|
13436
|
+
\`\`\`
|
|
13437
|
+
|
|
13438
|
+
### Communication Flow
|
|
13439
|
+
\`\`\`
|
|
13440
|
+
Commander: "Planner, sync issue found. Update TODO"
|
|
13441
|
+
\u2193
|
|
13442
|
+
Planner: (Add FIX task to TODO, update work-log)
|
|
13443
|
+
\u2193
|
|
13444
|
+
Commander: "Worker, fix this file like this" (Multiple Workers in parallel)
|
|
13445
|
+
\u2193
|
|
13446
|
+
Workers: (Fix each file + unit test + update work-log)
|
|
13447
|
+
\u2193
|
|
13448
|
+
Commander: "Reviewer, verify again"
|
|
13449
|
+
\u2193
|
|
13450
|
+
Reviewer: (Integration test + sync check + clear sync-issues)
|
|
13451
|
+
\`\`\`
|
|
13452
|
+
|
|
13453
|
+
### CRITICAL:
|
|
13454
|
+
- ALWAYS read ${PATHS.SYNC_ISSUES} at loop start
|
|
13455
|
+
- NEVER skip Planner when fixing - TODO must be updated
|
|
13456
|
+
- ALWAYS include specific instructions in delegate_task
|
|
13457
|
+
- Workers need: file path + issue ID + exact fix instructions
|
|
13458
|
+
${PROMPT_TAGS.SYNC_ISSUE_HANDLING.close}`;
|
|
13459
|
+
|
|
13159
13460
|
// src/agents/prompts/planner/role.ts
|
|
13160
13461
|
var PLANNER_ROLE = `<role>
|
|
13161
13462
|
You are ${AGENT_NAMES.PLANNER}. Strategic planner and researcher.
|
|
@@ -13254,6 +13555,123 @@ Version: [version]
|
|
|
13254
13555
|
\`\`\`
|
|
13255
13556
|
</research_workflow>`;
|
|
13256
13557
|
|
|
13558
|
+
// src/agents/prompts/planner/file-planning.ts
|
|
13559
|
+
var PLANNER_FILE_PLANNING = `${PROMPT_TAGS.FILE_LEVEL_PLANNING.open}
|
|
13560
|
+
## FILE-LEVEL PLANNING (MANDATORY)
|
|
13561
|
+
|
|
13562
|
+
Before any work begins, you MUST identify ALL files:
|
|
13563
|
+
|
|
13564
|
+
### Step 1: Analyze Requirements
|
|
13565
|
+
- What needs to be built/changed?
|
|
13566
|
+
- What existing files are affected?
|
|
13567
|
+
|
|
13568
|
+
### Step 2: Create File Manifest
|
|
13569
|
+
Write to ${PATHS.TODO}:
|
|
13570
|
+
|
|
13571
|
+
\`\`\`markdown
|
|
13572
|
+
# Mission: [goal]
|
|
13573
|
+
|
|
13574
|
+
## File Manifest
|
|
13575
|
+
| Action | File Path | Description | Dependencies |
|
|
13576
|
+
|--------|-----------|-------------|--------------|
|
|
13577
|
+
| ${WORK_STATUS.ACTION.CREATE} | src/auth/login.ts | Login function | - |
|
|
13578
|
+
| ${WORK_STATUS.ACTION.CREATE} | src/auth/logout.ts | Logout function | login.ts |
|
|
13579
|
+
| ${WORK_STATUS.ACTION.MODIFY} | src/index.ts | Export auth module | login.ts, logout.ts |
|
|
13580
|
+
| ${WORK_STATUS.ACTION.CREATE} | src/types/auth.ts | Auth types | - |
|
|
13581
|
+
| ${WORK_STATUS.ACTION.DELETE} | src/old-auth.ts | Remove deprecated | - |
|
|
13582
|
+
|
|
13583
|
+
## Work Assignments (File-Level)
|
|
13584
|
+
Each ${AGENT_NAMES.WORKER} gets ONE file:
|
|
13585
|
+
|
|
13586
|
+
### T1: Auth Module | parallel-group:1
|
|
13587
|
+
- [ ] S1.1: ${WORK_STATUS.ACTION.CREATE} \`src/types/auth.ts\` | agent:${AGENT_NAMES.WORKER} | file:src/types/auth.ts
|
|
13588
|
+
- [ ] S1.2: ${WORK_STATUS.ACTION.CREATE} \`src/auth/login.ts\` | agent:${AGENT_NAMES.WORKER} | file:src/auth/login.ts
|
|
13589
|
+
- [ ] S1.3: ${WORK_STATUS.ACTION.CREATE} \`src/auth/logout.ts\` | agent:${AGENT_NAMES.WORKER} | file:src/auth/logout.ts
|
|
13590
|
+
|
|
13591
|
+
### T2: Integration | parallel-group:2 | depends:T1
|
|
13592
|
+
- [ ] S2.1: ${WORK_STATUS.ACTION.MODIFY} \`src/index.ts\` | agent:${AGENT_NAMES.WORKER} | file:src/index.ts
|
|
13593
|
+
\`\`\`
|
|
13594
|
+
|
|
13595
|
+
### Step 3: Initialize Work Log
|
|
13596
|
+
Create ${PATHS.WORK_LOG}:
|
|
13597
|
+
|
|
13598
|
+
\`\`\`markdown
|
|
13599
|
+
# Work Log
|
|
13600
|
+
|
|
13601
|
+
## File Status
|
|
13602
|
+
| File | Action | Status | Worker | Unit Test | Timestamp |
|
|
13603
|
+
|------|--------|--------|--------|-----------|-----------|
|
|
13604
|
+
| src/types/auth.ts | ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
13605
|
+
| src/auth/login.ts | ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
13606
|
+
| src/auth/logout.ts | ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
13607
|
+
| src/index.ts | ${WORK_STATUS.ACTION.MODIFY} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
13608
|
+
|
|
13609
|
+
## Active Sessions
|
|
13610
|
+
(none yet)
|
|
13611
|
+
|
|
13612
|
+
## Completed Units
|
|
13613
|
+
(none yet)
|
|
13614
|
+
|
|
13615
|
+
## Sync Issues
|
|
13616
|
+
(none yet)
|
|
13617
|
+
\`\`\`
|
|
13618
|
+
|
|
13619
|
+
### PATH NOTES:
|
|
13620
|
+
- File paths use forward slash '/' in examples
|
|
13621
|
+
- On Windows, paths may use backslash '\\\\'
|
|
13622
|
+
|
|
13623
|
+
### CRITICAL RULES:
|
|
13624
|
+
- Every subtask = exactly ONE file
|
|
13625
|
+
- Include \`file:[path]\` tag for each subtask
|
|
13626
|
+
- Action must be ${WORK_STATUS.ACTION.CREATE}, ${WORK_STATUS.ACTION.MODIFY}, ${WORK_STATUS.ACTION.DELETE}, or ${WORK_STATUS.ACTION.FIX}
|
|
13627
|
+
- List dependencies between files
|
|
13628
|
+
${PROMPT_TAGS.FILE_LEVEL_PLANNING.close}`;
|
|
13629
|
+
|
|
13630
|
+
// src/agents/prompts/planner/todo-sync.ts
|
|
13631
|
+
var PLANNER_TODO_SYNC = `${PROMPT_TAGS.TODO_SYNC.open}
|
|
13632
|
+
## TODO SYNC (After Sync Issues)
|
|
13633
|
+
|
|
13634
|
+
When ${AGENT_NAMES.COMMANDER} detects sync issues, you update the TODO.
|
|
13635
|
+
|
|
13636
|
+
### Step 1: Read Current State
|
|
13637
|
+
\`\`\`bash
|
|
13638
|
+
cat ${PATHS.SYNC_ISSUES}
|
|
13639
|
+
cat ${PATHS.WORK_LOG}
|
|
13640
|
+
cat ${PATHS.TODO}
|
|
13641
|
+
\`\`\`
|
|
13642
|
+
|
|
13643
|
+
### Step 2: Understand Commander's Instructions
|
|
13644
|
+
Commander will tell you:
|
|
13645
|
+
- Which files need rework
|
|
13646
|
+
- What sync issues to fix
|
|
13647
|
+
- New dependencies discovered
|
|
13648
|
+
|
|
13649
|
+
### Step 3: Update TODO
|
|
13650
|
+
Add NEW subtasks for sync fixes:
|
|
13651
|
+
|
|
13652
|
+
\`\`\`markdown
|
|
13653
|
+
### T3: Sync Fixes | parallel-group:3 | depends:T2
|
|
13654
|
+
- [ ] S3.1: ${WORK_STATUS.ACTION.FIX} \`src/auth/login.ts\` | agent:${AGENT_NAMES.WORKER} | file:src/auth/login.ts | issue:${ID_PREFIX.SYNC_ISSUE}1
|
|
13655
|
+
- [ ] S3.2: ${WORK_STATUS.ACTION.FIX} \`src/api/users.ts\` | agent:${AGENT_NAMES.WORKER} | file:src/api/users.ts | issue:${ID_PREFIX.SYNC_ISSUE}1
|
|
13656
|
+
\`\`\`
|
|
13657
|
+
|
|
13658
|
+
### Step 4: Update Work Log File Status
|
|
13659
|
+
\`\`\`markdown
|
|
13660
|
+
| src/auth/login.ts | ${WORK_STATUS.ACTION.FIX} | ${WORK_STATUS.STATUS.PENDING} | - | - | - | ${ID_PREFIX.SYNC_ISSUE}1 |
|
|
13661
|
+
\`\`\`
|
|
13662
|
+
|
|
13663
|
+
### Sync Issue Reference Format
|
|
13664
|
+
Always reference the sync issue ID:
|
|
13665
|
+
- \`issue:${ID_PREFIX.SYNC_ISSUE}N\` in TODO subtask (e.g., ${ID_PREFIX.SYNC_ISSUE}1, ${ID_PREFIX.SYNC_ISSUE}42)
|
|
13666
|
+
- Links back to ${PATHS.SYNC_ISSUES} for context
|
|
13667
|
+
|
|
13668
|
+
### CRITICAL:
|
|
13669
|
+
- DO NOT remove completed tasks (keep for history)
|
|
13670
|
+
- ADD new fix tasks, don't overwrite
|
|
13671
|
+
- Keep file manifest updated
|
|
13672
|
+
- Commander reads your updates in next loop
|
|
13673
|
+
${PROMPT_TAGS.TODO_SYNC.close}`;
|
|
13674
|
+
|
|
13257
13675
|
// src/agents/prompts/worker/role.ts
|
|
13258
13676
|
var WORKER_ROLE = `<role>
|
|
13259
13677
|
You are ${AGENT_NAMES.WORKER}. Implementation specialist.
|
|
@@ -13319,6 +13737,240 @@ DOCS_USED: .opencode/docs/[file]
|
|
|
13319
13737
|
Ready for ${AGENT_NAMES.REVIEWER} verification
|
|
13320
13738
|
</quality_checklist>`;
|
|
13321
13739
|
|
|
13740
|
+
// src/agents/prompts/worker/tdd-workflow.ts
|
|
13741
|
+
var WORKER_TDD_WORKFLOW = `${PROMPT_TAGS.TDD_WORKFLOW.open}
|
|
13742
|
+
## TDD (Test-Driven Development) MANDATORY WORKFLOW
|
|
13743
|
+
|
|
13744
|
+
You work on ONE FILE at a time in ISOLATION. Follow this EXACT cycle:
|
|
13745
|
+
|
|
13746
|
+
### Phase 1: SETUP
|
|
13747
|
+
1. Read ${PATHS.WORK_LOG} - Check assigned file
|
|
13748
|
+
2. Read ${PATHS.TODO} - Understand requirements
|
|
13749
|
+
3. Update ${PATHS.WORK_LOG}:
|
|
13750
|
+
\`\`\`markdown
|
|
13751
|
+
- [ ] ${ID_PREFIX.SESSION}N (Worker): \`[target-file]\` - ${WORK_STATUS.SESSION.STARTED}
|
|
13752
|
+
\`\`\`
|
|
13753
|
+
|
|
13754
|
+
### Phase 2: TEST FIRST (Red)
|
|
13755
|
+
1. Create ISOLATED test file for target file
|
|
13756
|
+
- Naming: \`[filename].isolated.test.[ext]\` (language-appropriate)
|
|
13757
|
+
2. Write tests that ONLY test the target file
|
|
13758
|
+
3. Mock/Dummy ALL external dependencies:
|
|
13759
|
+
- Database \u2192 Return fake data
|
|
13760
|
+
- External API \u2192 Mock response
|
|
13761
|
+
- Filesystem \u2192 Memory or temp
|
|
13762
|
+
- Other modules \u2192 Mock exports
|
|
13763
|
+
4. Run test - MUST FAIL (Red phase)
|
|
13764
|
+
|
|
13765
|
+
### Phase 3: IMPLEMENT (Green)
|
|
13766
|
+
1. Write minimal code to pass tests
|
|
13767
|
+
2. Run test - MUST PASS (Green phase)
|
|
13768
|
+
3. Iterate until all tests pass
|
|
13769
|
+
|
|
13770
|
+
### Phase 4: CLEANUP & RECORD
|
|
13771
|
+
1. Record test in ${PATHS.UNIT_TESTS}/:
|
|
13772
|
+
\`\`\`markdown
|
|
13773
|
+
# Unit Test Record: [filename]
|
|
13774
|
+
|
|
13775
|
+
## Target File
|
|
13776
|
+
\`[full-path]\`
|
|
13777
|
+
|
|
13778
|
+
## Test File (DELETED)
|
|
13779
|
+
\`[test-file-path]\`
|
|
13780
|
+
|
|
13781
|
+
## Test Code (Preserved)
|
|
13782
|
+
\\\`\\\`\\\`[language]
|
|
13783
|
+
[full test code here]
|
|
13784
|
+
\\\`\\\`\\\`
|
|
13785
|
+
|
|
13786
|
+
## Test Result
|
|
13787
|
+
- Status: ${WORK_STATUS.TEST_RESULT.PASS}
|
|
13788
|
+
- Session: ${ID_PREFIX.SESSION}N
|
|
13789
|
+
- Timestamp: [ISO timestamp]
|
|
13790
|
+
\`\`\`
|
|
13791
|
+
|
|
13792
|
+
2. DELETE the isolated test file (code preserved above)
|
|
13793
|
+
3. Update ${PATHS.WORK_LOG} with ${WORK_STATUS.STATUS.DONE} + ${WORK_STATUS.TEST_RESULT.PASS}
|
|
13794
|
+
|
|
13795
|
+
---
|
|
13796
|
+
|
|
13797
|
+
## Isolation Requirements (Language-Agnostic)
|
|
13798
|
+
1. **Import ONLY target file** - Only the file being worked on
|
|
13799
|
+
2. **Mock ALL external dependencies**:
|
|
13800
|
+
- Communication/interaction needed \u2192 Assume dummy response
|
|
13801
|
+
- Real I/O strictly forbidden
|
|
13802
|
+
3. **Delete after pass** - Remove isolated test file
|
|
13803
|
+
4. **Record in .opencode** - Preserve test code and results
|
|
13804
|
+
|
|
13805
|
+
### CRITICAL RULES:
|
|
13806
|
+
- NEVER skip the test file deletion step
|
|
13807
|
+
- ALWAYS preserve test code in ${PATHS.UNIT_TESTS}/
|
|
13808
|
+
- NEVER mark [x] in todo.md - Reviewer's job!
|
|
13809
|
+
- ONE file per session - complete isolation
|
|
13810
|
+
${PROMPT_TAGS.TDD_WORKFLOW.close}`;
|
|
13811
|
+
|
|
13812
|
+
// src/agents/prompts/worker/isolation-testing.ts
|
|
13813
|
+
var WORKER_ISOLATION_TESTING = `${PROMPT_TAGS.ISOLATION_TESTING.open}
|
|
13814
|
+
## ISOLATED UNIT TEST RULES
|
|
13815
|
+
|
|
13816
|
+
### File Naming Convention
|
|
13817
|
+
\`[original-dir]/__tests__/[filename].isolated.test.ts\`
|
|
13818
|
+
|
|
13819
|
+
Example:
|
|
13820
|
+
- Target: \`src/auth/login.ts\`
|
|
13821
|
+
- Test: \`src/auth/__tests__/login.isolated.test.ts\`
|
|
13822
|
+
|
|
13823
|
+
### Isolation Requirements
|
|
13824
|
+
1. **Import ONLY the target file**
|
|
13825
|
+
\`\`\`typescript
|
|
13826
|
+
import { functionToTest } from '../login.js';
|
|
13827
|
+
\`\`\`
|
|
13828
|
+
|
|
13829
|
+
2. **Mock ALL external dependencies**
|
|
13830
|
+
\`\`\`typescript
|
|
13831
|
+
vi.mock('../database.js', () => ({
|
|
13832
|
+
db: { query: vi.fn() }
|
|
13833
|
+
}));
|
|
13834
|
+
vi.mock('../config.js', () => ({
|
|
13835
|
+
config: { secret: 'test-secret' }
|
|
13836
|
+
}));
|
|
13837
|
+
\`\`\`
|
|
13838
|
+
|
|
13839
|
+
3. **Test ONLY public exports of target file**
|
|
13840
|
+
- No testing of internal functions
|
|
13841
|
+
- No accessing private state
|
|
13842
|
+
|
|
13843
|
+
4. **No side effects outside test scope**
|
|
13844
|
+
- No file system writes (mock them)
|
|
13845
|
+
- No network requests (mock them)
|
|
13846
|
+
- No database operations (mock them)
|
|
13847
|
+
|
|
13848
|
+
### Test Structure Template
|
|
13849
|
+
\`\`\`typescript
|
|
13850
|
+
/**
|
|
13851
|
+
* ISOLATED Unit Test for [filename]
|
|
13852
|
+
* Target: [full-path]
|
|
13853
|
+
* Session: [session_id]
|
|
13854
|
+
*
|
|
13855
|
+
* \u26A0\uFE0F THIS FILE WILL BE DELETED AFTER TEST PASSES
|
|
13856
|
+
* Test code preserved in: .opencode/unit-tests/
|
|
13857
|
+
*/
|
|
13858
|
+
|
|
13859
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
13860
|
+
|
|
13861
|
+
// Mock all external dependencies BEFORE importing target
|
|
13862
|
+
vi.mock('../external-dep.js', () => ({}));
|
|
13863
|
+
|
|
13864
|
+
// Import target file
|
|
13865
|
+
import { targetFunction } from '../target.js';
|
|
13866
|
+
|
|
13867
|
+
describe('[filename] - Isolated Tests', () => {
|
|
13868
|
+
beforeEach(() => {
|
|
13869
|
+
vi.clearAllMocks();
|
|
13870
|
+
});
|
|
13871
|
+
|
|
13872
|
+
it('should [expected behavior]', () => {
|
|
13873
|
+
// Arrange
|
|
13874
|
+
// Act
|
|
13875
|
+
// Assert
|
|
13876
|
+
});
|
|
13877
|
+
});
|
|
13878
|
+
\`\`\`
|
|
13879
|
+
|
|
13880
|
+
### Test Execution
|
|
13881
|
+
\`\`\`bash
|
|
13882
|
+
# Run ONLY this isolated test
|
|
13883
|
+
npm test -- src/auth/__tests__/login.isolated.test.ts --run
|
|
13884
|
+
|
|
13885
|
+
# Verify isolation - should not affect other tests
|
|
13886
|
+
npm test -- --run
|
|
13887
|
+
\`\`\`
|
|
13888
|
+
|
|
13889
|
+
### FORBIDDEN:
|
|
13890
|
+
- Importing multiple source files to test together
|
|
13891
|
+
- Running full test suite for validation
|
|
13892
|
+
- Leaving isolated test files after completion
|
|
13893
|
+
- Modifying existing test files in the project
|
|
13894
|
+
${PROMPT_TAGS.ISOLATION_TESTING.close}`;
|
|
13895
|
+
|
|
13896
|
+
// src/agents/prompts/worker/file-assignment.ts
|
|
13897
|
+
var WORKER_FILE_ASSIGNMENT = `${PROMPT_TAGS.FILE_ASSIGNMENT.open}
|
|
13898
|
+
## FILE ASSIGNMENT PROTOCOL
|
|
13899
|
+
|
|
13900
|
+
You are assigned ONE FILE per session. Follow this protocol:
|
|
13901
|
+
|
|
13902
|
+
### Step 1: Read Shared State
|
|
13903
|
+
\`\`\`bash
|
|
13904
|
+
# ALWAYS read these first
|
|
13905
|
+
cat ${PATHS.WORK_LOG}
|
|
13906
|
+
cat ${PATHS.TODO}
|
|
13907
|
+
cat ${PATHS.SYNC_ISSUES} 2>/dev/null || echo "No sync issues"
|
|
13908
|
+
\`\`\`
|
|
13909
|
+
|
|
13910
|
+
### Step 2: Identify Your Assignment
|
|
13911
|
+
Commander gives you:
|
|
13912
|
+
- \`file: src/path/to/file.ts\` - Your target file
|
|
13913
|
+
- \`action: ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.ACTION.MODIFY} | ${WORK_STATUS.ACTION.FIX}\` - What to do
|
|
13914
|
+
- \`issue: ${ID_PREFIX.SYNC_ISSUE}N\` (optional) - If fixing a sync issue
|
|
13915
|
+
|
|
13916
|
+
### Step 3: Update Work Log (Start)
|
|
13917
|
+
\`\`\`markdown
|
|
13918
|
+
## Active Sessions
|
|
13919
|
+
- [ ] ${ID_PREFIX.SESSION}N (Worker): \`[file]\` - [action] ${WORK_STATUS.SESSION.STARTED}
|
|
13920
|
+
\`\`\`
|
|
13921
|
+
|
|
13922
|
+
### Step 4: Read Context
|
|
13923
|
+
- If ${WORK_STATUS.ACTION.FIX}: Read ${PATHS.SYNC_ISSUES} for issue details
|
|
13924
|
+
- If ${WORK_STATUS.ACTION.CREATE}/${WORK_STATUS.ACTION.MODIFY}: Read TODO for requirements
|
|
13925
|
+
- Read other completed files in ${PATHS.WORK_LOG} for context
|
|
13926
|
+
|
|
13927
|
+
### Step 5: TDD Cycle (See tdd-workflow)
|
|
13928
|
+
1. Create isolated test
|
|
13929
|
+
2. Implement
|
|
13930
|
+
3. Pass test
|
|
13931
|
+
4. Delete test (record in unit-tests/)
|
|
13932
|
+
|
|
13933
|
+
### Step 6: Update Work Log (Complete)
|
|
13934
|
+
\`\`\`markdown
|
|
13935
|
+
## Active Sessions
|
|
13936
|
+
- [x] ${ID_PREFIX.SESSION}N (Worker): \`[file]\` - [action] ${WORK_STATUS.SESSION.COMPLETED}
|
|
13937
|
+
|
|
13938
|
+
## File Status (update row)
|
|
13939
|
+
| [file] | [action] | ${WORK_STATUS.STATUS.DONE} | ${ID_PREFIX.SESSION}N | ${WORK_STATUS.TEST_RESULT.PASS} | [timestamp] |
|
|
13940
|
+
\`\`\`
|
|
13941
|
+
|
|
13942
|
+
### Step 7: Report
|
|
13943
|
+
Report to Commander via tool result:
|
|
13944
|
+
\`\`\`
|
|
13945
|
+
\u2705 File: [path]
|
|
13946
|
+
Action: [${WORK_STATUS.ACTION.CREATE}/${WORK_STATUS.ACTION.MODIFY}/${WORK_STATUS.ACTION.FIX}]
|
|
13947
|
+
Unit Test: ${WORK_STATUS.TEST_RESULT.PASS}
|
|
13948
|
+
Isolated test deleted, recorded in ${PATHS.UNIT_TESTS}/
|
|
13949
|
+
Ready for integration.
|
|
13950
|
+
\`\`\`
|
|
13951
|
+
|
|
13952
|
+
### For SYNC FIX Assignments:
|
|
13953
|
+
1. Read ${ID_PREFIX.SYNC_ISSUE}N from ${PATHS.SYNC_ISSUES}
|
|
13954
|
+
2. Understand what's wrong
|
|
13955
|
+
3. Apply ${AGENT_NAMES.COMMANDER}'s suggested fix
|
|
13956
|
+
4. Test the fix in isolation
|
|
13957
|
+
5. Update work-log with issue reference
|
|
13958
|
+
|
|
13959
|
+
\`\`\`markdown
|
|
13960
|
+
| src/file.ts | ${WORK_STATUS.ACTION.FIX} | ${WORK_STATUS.STATUS.DONE} | ${ID_PREFIX.SESSION}1 | ${WORK_STATUS.TEST_RESULT.PASS} | 2026-01-18T10:00:00 | ${ID_PREFIX.SYNC_ISSUE}1 |
|
|
13961
|
+
\`\`\`
|
|
13962
|
+
|
|
13963
|
+
### PATH NOTES:
|
|
13964
|
+
- File paths use forward slash '/' in examples
|
|
13965
|
+
- On Windows, paths may use backslash '\\\\'
|
|
13966
|
+
|
|
13967
|
+
### CRITICAL:
|
|
13968
|
+
- ONE file only - never touch other files
|
|
13969
|
+
- ALWAYS update ${PATHS.WORK_LOG} at start and end
|
|
13970
|
+
- READ ${PATHS.SYNC_ISSUES} if issue: tag is present
|
|
13971
|
+
- Follow Commander's specific instructions
|
|
13972
|
+
${PROMPT_TAGS.FILE_ASSIGNMENT.close}`;
|
|
13973
|
+
|
|
13322
13974
|
// src/agents/prompts/reviewer/role.ts
|
|
13323
13975
|
var REVIEWER_ROLE = `<role>
|
|
13324
13976
|
You are ${AGENT_NAMES.REVIEWER}. Verification specialist.
|
|
@@ -13448,6 +14100,223 @@ TODO STATUS:
|
|
|
13448
14100
|
- [ ] T[N]: [task] | needs fix
|
|
13449
14101
|
</output_format>`;
|
|
13450
14102
|
|
|
14103
|
+
// src/agents/prompts/reviewer/async-monitoring.ts
|
|
14104
|
+
var REVIEWER_ASYNC_MONITORING = `${PROMPT_TAGS.ASYNC_MONITORING.open}
|
|
14105
|
+
## ASYNC PARALLEL WORK MONITORING
|
|
14106
|
+
|
|
14107
|
+
You monitor ${AGENT_NAMES.WORKER} sessions running in PARALLEL.
|
|
14108
|
+
Do NOT block - check status asynchronously and wait for completion.
|
|
14109
|
+
|
|
14110
|
+
### Monitoring Loop
|
|
14111
|
+
1. Read ${PATHS.WORK_LOG} to check active sessions:
|
|
14112
|
+
\`\`\`bash
|
|
14113
|
+
cat ${PATHS.WORK_LOG}
|
|
14114
|
+
\`\`\`
|
|
14115
|
+
|
|
14116
|
+
2. Identify completed units (marked [x] in Active Sessions)
|
|
14117
|
+
|
|
14118
|
+
3. For each completed unit:
|
|
14119
|
+
- Verify unit test record exists in ${PATHS.UNIT_TESTS}/
|
|
14120
|
+
- Check isolated test file was deleted
|
|
14121
|
+
- Verify implementation quality
|
|
14122
|
+
|
|
14123
|
+
4. Wait for ALL parallel workers to complete before integration test
|
|
14124
|
+
|
|
14125
|
+
### Status Check Pattern
|
|
14126
|
+
\`\`\`markdown
|
|
14127
|
+
## Current Status Check
|
|
14128
|
+
- Total active workers: [N]
|
|
14129
|
+
- Completed units: [list]
|
|
14130
|
+
- Still running: [list]
|
|
14131
|
+
- Ready for integration: [YES/NO]
|
|
14132
|
+
\`\`\`
|
|
14133
|
+
|
|
14134
|
+
### Non-Blocking Wait Strategy
|
|
14135
|
+
1. If workers still running:
|
|
14136
|
+
- Report current status
|
|
14137
|
+
- DO NOT block or wait indefinitely
|
|
14138
|
+
- Schedule next check (Commander will re-invoke)
|
|
14139
|
+
|
|
14140
|
+
2. If all workers complete:
|
|
14141
|
+
- Proceed to integration testing
|
|
14142
|
+
- Update ${PATHS.INTEGRATION_STATUS}
|
|
14143
|
+
|
|
14144
|
+
### work-log.md Interpretation
|
|
14145
|
+
\`\`\`markdown
|
|
14146
|
+
# Reading work-log.md:
|
|
14147
|
+
- [ ] = Still in progress, DO NOT verify yet
|
|
14148
|
+
- [x] = Unit complete, READY for verification
|
|
14149
|
+
\`\`\`
|
|
14150
|
+
|
|
14151
|
+
### CRITICAL:
|
|
14152
|
+
- NEVER verify a file before worker marks [x]
|
|
14153
|
+
- NEVER block waiting for workers
|
|
14154
|
+
- Always update ${PATHS.WORK_LOG} with your monitoring status
|
|
14155
|
+
${PROMPT_TAGS.ASYNC_MONITORING.close}`;
|
|
14156
|
+
|
|
14157
|
+
// src/agents/prompts/reviewer/integration-testing.ts
|
|
14158
|
+
var REVIEWER_INTEGRATION_TESTING = `${PROMPT_TAGS.INTEGRATION_TESTING.open}
|
|
14159
|
+
## E2E INTEGRATION TESTING
|
|
14160
|
+
|
|
14161
|
+
### \u26A0\uFE0F E2E Test Timing (CRITICAL)
|
|
14162
|
+
E2E tests should only run when:
|
|
14163
|
+
1. **TODO is almost complete** - Most tasks checked [x]
|
|
14164
|
+
2. **All Workers done** - No active sessions in work-log.md
|
|
14165
|
+
3. **Or final verification** - Right before SEALED
|
|
14166
|
+
|
|
14167
|
+
### Pre-Integration Checklist
|
|
14168
|
+
- [ ] Check ${PATHS.TODO} for incomplete tasks
|
|
14169
|
+
- [ ] Check ${PATHS.WORK_LOG} for all workers [x] complete
|
|
14170
|
+
- [ ] Check ${PATHS.UNIT_TESTS}/ for unit test records
|
|
14171
|
+
- [ ] All isolated test files deleted
|
|
14172
|
+
|
|
14173
|
+
### Integration Workflow
|
|
14174
|
+
|
|
14175
|
+
#### Step 1: Check TODO Status
|
|
14176
|
+
\`\`\`bash
|
|
14177
|
+
cat ${PATHS.TODO}
|
|
14178
|
+
# If incomplete items exist, wait for E2E
|
|
14179
|
+
\`\`\`
|
|
14180
|
+
|
|
14181
|
+
#### Step 2: Run Build (language-appropriate)
|
|
14182
|
+
\`\`\`bash
|
|
14183
|
+
# Run project build command
|
|
14184
|
+
# If failed, record in sync-issues.md
|
|
14185
|
+
\`\`\`
|
|
14186
|
+
|
|
14187
|
+
#### Step 3: Run Full Tests
|
|
14188
|
+
\`\`\`bash
|
|
14189
|
+
# Run project test command
|
|
14190
|
+
# Check for regressions
|
|
14191
|
+
\`\`\`
|
|
14192
|
+
|
|
14193
|
+
#### Step 4: Write E2E Integration Test (if needed)
|
|
14194
|
+
\`\`\`
|
|
14195
|
+
# Write integration test in appropriate format
|
|
14196
|
+
# Verify multiple files work together
|
|
14197
|
+
# Unlike isolated tests, DO NOT delete
|
|
14198
|
+
\`\`\`
|
|
14199
|
+
|
|
14200
|
+
#### Step 5: Record Results
|
|
14201
|
+
Write to ${PATHS.INTEGRATION_STATUS}:
|
|
14202
|
+
\`\`\`markdown
|
|
14203
|
+
# Integration Status
|
|
14204
|
+
|
|
14205
|
+
## Last Integration
|
|
14206
|
+
- Timestamp: [ISO timestamp]
|
|
14207
|
+
|
|
14208
|
+
## Result
|
|
14209
|
+
- Build: ${WORK_STATUS.TEST_RESULT.PASS}/${WORK_STATUS.TEST_RESULT.FAIL}
|
|
14210
|
+
- E2E Test: ${WORK_STATUS.TEST_RESULT.PASS}/${WORK_STATUS.TEST_RESULT.FAIL}
|
|
14211
|
+
|
|
14212
|
+
## Sync Issues Found
|
|
14213
|
+
- (omit if none)
|
|
14214
|
+
\`\`\`
|
|
14215
|
+
|
|
14216
|
+
---
|
|
14217
|
+
|
|
14218
|
+
## Loop Condition Check (Reviewer verifies)
|
|
14219
|
+
|
|
14220
|
+
### SEALED Conditions (all must be true)
|
|
14221
|
+
- [ ] ${PATHS.TODO} all items [x]
|
|
14222
|
+
- [ ] ${PATHS.SYNC_ISSUES} is empty
|
|
14223
|
+
- [ ] Build passes
|
|
14224
|
+
- [ ] E2E test passes
|
|
14225
|
+
|
|
14226
|
+
### LOOP BACK Conditions
|
|
14227
|
+
- ${PATHS.TODO} has incomplete items \u2192 \u267B\uFE0F LOOP
|
|
14228
|
+
- ${PATHS.SYNC_ISSUES} has unresolved issues \u2192 \u267B\uFE0F LOOP
|
|
14229
|
+
- Build/test fails \u2192 record in sync-issues.md \u2192 \u267B\uFE0F LOOP
|
|
14230
|
+
|
|
14231
|
+
### CRITICAL:
|
|
14232
|
+
- E2E only at TODO completion time!
|
|
14233
|
+
- Record build/test failures minimally in sync-issues.md
|
|
14234
|
+
- Delete resolved issues, keep only unresolved
|
|
14235
|
+
- All TODO [x] + no issues = SEALED!
|
|
14236
|
+
${PROMPT_TAGS.INTEGRATION_TESTING.close}`;
|
|
14237
|
+
|
|
14238
|
+
// src/agents/prompts/reviewer/sync-verification.ts
|
|
14239
|
+
var REVIEWER_SYNC_VERIFICATION = `${PROMPT_TAGS.SYNC_VERIFICATION.open}
|
|
14240
|
+
## FILE SYNC VERIFICATION
|
|
14241
|
+
|
|
14242
|
+
After integration, verify all files are properly synchronized.
|
|
14243
|
+
|
|
14244
|
+
### Sync Check Areas
|
|
14245
|
+
|
|
14246
|
+
#### 1. Import/Export Consistency
|
|
14247
|
+
\`\`\`bash
|
|
14248
|
+
# Check for broken imports
|
|
14249
|
+
npm run build 2>&1 | grep -i "cannot find"
|
|
14250
|
+
npm run build 2>&1 | grep -i "not exported"
|
|
14251
|
+
\`\`\`
|
|
14252
|
+
|
|
14253
|
+
#### 2. Type Consistency
|
|
14254
|
+
\`\`\`bash
|
|
14255
|
+
# Check for type mismatches
|
|
14256
|
+
npx tsc --noEmit 2>&1 | grep -i "type"
|
|
14257
|
+
\`\`\`
|
|
14258
|
+
|
|
14259
|
+
#### 3. Interface Implementation
|
|
14260
|
+
- Check implemented interfaces match declarations
|
|
14261
|
+
- Verify function signatures match calls
|
|
14262
|
+
|
|
14263
|
+
#### 4. Shared State Consistency
|
|
14264
|
+
- Check constants used across files
|
|
14265
|
+
- Verify shared types are consistent
|
|
14266
|
+
|
|
14267
|
+
---
|
|
14268
|
+
|
|
14269
|
+
## ISSUE MANAGEMENT RULES \u26A0\uFE0F
|
|
14270
|
+
|
|
14271
|
+
### sync-issues.md Contains UNRESOLVED ONLY
|
|
14272
|
+
- **Delete resolved issues immediately** (keep file clean)
|
|
14273
|
+
- **Keep only unresolved** (only what Commander needs to read)
|
|
14274
|
+
- **Summarize if too long** (archive old issues)
|
|
14275
|
+
|
|
14276
|
+
### Issue Format (Minimal)
|
|
14277
|
+
\`\`\`markdown
|
|
14278
|
+
# Sync Issues (Unresolved Only)
|
|
14279
|
+
|
|
14280
|
+
## ${ID_PREFIX.SYNC_ISSUE}N
|
|
14281
|
+
- Severity: ${WORK_STATUS.SEVERITY.HIGH}
|
|
14282
|
+
- Files: src/file1.ts \u2194 src/file2.ts
|
|
14283
|
+
- Problem: [concise description]
|
|
14284
|
+
- Fix: [specific solution]
|
|
14285
|
+
- Status: ${WORK_STATUS.STATUS.PENDING}
|
|
14286
|
+
\`\`\`
|
|
14287
|
+
|
|
14288
|
+
### After Fix Verification
|
|
14289
|
+
When re-verifying after fixes:
|
|
14290
|
+
1. Check if issue is resolved
|
|
14291
|
+
2. If resolved: **DELETE the issue from sync-issues.md**
|
|
14292
|
+
3. If not resolved: Update issue status, add notes
|
|
14293
|
+
4. Keep file minimal
|
|
14294
|
+
|
|
14295
|
+
---
|
|
14296
|
+
|
|
14297
|
+
### Loop Continuation (NOT SEALED)
|
|
14298
|
+
If sync issues exist:
|
|
14299
|
+
1. Write ONLY unresolved issues to ${PATHS.SYNC_ISSUES}
|
|
14300
|
+
2. Delete resolved issues from file
|
|
14301
|
+
3. Update ${PATHS.WORK_LOG} with required rework
|
|
14302
|
+
4. DO NOT output SEALED
|
|
14303
|
+
5. ${AGENT_NAMES.COMMANDER} will read and dispatch new work
|
|
14304
|
+
|
|
14305
|
+
### Seal Condition
|
|
14306
|
+
Output SEALED only when:
|
|
14307
|
+
- [ ] All TODO items [x]
|
|
14308
|
+
- [ ] Build passes
|
|
14309
|
+
- [ ] All tests pass (${WORK_STATUS.TEST_RESULT.PASS})
|
|
14310
|
+
- [ ] ${PATHS.SYNC_ISSUES} is EMPTY (no unresolved issues)
|
|
14311
|
+
- [ ] ${PATHS.INTEGRATION_STATUS} shows ${WORK_STATUS.TEST_RESULT.PASS}
|
|
14312
|
+
|
|
14313
|
+
### CRITICAL:
|
|
14314
|
+
- Always check sync AFTER integration tests
|
|
14315
|
+
- DELETE resolved issues immediately
|
|
14316
|
+
- Keep sync-issues.md as short as possible
|
|
14317
|
+
- Ensure ${AGENT_NAMES.COMMANDER} only sees what needs fixing
|
|
14318
|
+
${PROMPT_TAGS.SYNC_VERIFICATION.close}`;
|
|
14319
|
+
|
|
13451
14320
|
// src/agents/commander.ts
|
|
13452
14321
|
var systemPrompt = [
|
|
13453
14322
|
COMMANDER_ROLE,
|
|
@@ -13461,12 +14330,16 @@ var systemPrompt = [
|
|
|
13461
14330
|
COMMANDER_AGENTS,
|
|
13462
14331
|
TODO_RULES,
|
|
13463
14332
|
COMMANDER_TODO_FORMAT,
|
|
14333
|
+
// Loop, shared state, sync handling
|
|
14334
|
+
COMMANDER_LOOP_CONTINUATION,
|
|
14335
|
+
COMMANDER_SYNC_HANDLING,
|
|
14336
|
+
SHARED_WORKSPACE,
|
|
13464
14337
|
ANTI_HALLUCINATION_CORE,
|
|
13465
14338
|
MISSION_SEAL_RULES
|
|
13466
14339
|
].join("\n\n");
|
|
13467
14340
|
var commander = {
|
|
13468
14341
|
id: AGENT_NAMES.COMMANDER,
|
|
13469
|
-
description: "Commander -
|
|
14342
|
+
description: "Commander - orchestrator with parallel execution, loop state, and sync issue handling",
|
|
13470
14343
|
systemPrompt,
|
|
13471
14344
|
canWrite: true,
|
|
13472
14345
|
canBash: true
|
|
@@ -13481,12 +14354,15 @@ var systemPrompt2 = [
|
|
|
13481
14354
|
ANTI_HALLUCINATION_CORE,
|
|
13482
14355
|
TODO_RULES,
|
|
13483
14356
|
PLANNER_TODO_FORMAT,
|
|
14357
|
+
// File-level planning
|
|
14358
|
+
PLANNER_FILE_PLANNING,
|
|
14359
|
+
PLANNER_TODO_SYNC,
|
|
13484
14360
|
PLANNER_RESEARCH,
|
|
13485
14361
|
SHARED_WORKSPACE
|
|
13486
14362
|
].join("\n\n");
|
|
13487
14363
|
var planner = {
|
|
13488
14364
|
id: AGENT_NAMES.PLANNER,
|
|
13489
|
-
description: "Planner -
|
|
14365
|
+
description: "Planner - file-level planning, TODO creation and sync",
|
|
13490
14366
|
systemPrompt: systemPrompt2,
|
|
13491
14367
|
canWrite: true,
|
|
13492
14368
|
canBash: true
|
|
@@ -13500,12 +14376,17 @@ var systemPrompt3 = [
|
|
|
13500
14376
|
ANTI_HALLUCINATION_CORE,
|
|
13501
14377
|
WORKER_WORKFLOW,
|
|
13502
14378
|
WORKER_QUALITY,
|
|
14379
|
+
// File assignment from Commander
|
|
14380
|
+
WORKER_FILE_ASSIGNMENT,
|
|
14381
|
+
// TDD-based isolated work
|
|
14382
|
+
WORKER_TDD_WORKFLOW,
|
|
14383
|
+
WORKER_ISOLATION_TESTING,
|
|
13503
14384
|
VERIFICATION_REQUIREMENTS,
|
|
13504
14385
|
SHARED_WORKSPACE
|
|
13505
14386
|
].join("\n\n");
|
|
13506
14387
|
var worker = {
|
|
13507
14388
|
id: AGENT_NAMES.WORKER,
|
|
13508
|
-
description: "Worker - implementation
|
|
14389
|
+
description: "Worker - TDD file-level implementation, reads .opencode, follows Commander",
|
|
13509
14390
|
systemPrompt: systemPrompt3,
|
|
13510
14391
|
canWrite: true,
|
|
13511
14392
|
canBash: true
|
|
@@ -13519,12 +14400,16 @@ var systemPrompt4 = [
|
|
|
13519
14400
|
REVIEWER_VERIFICATION,
|
|
13520
14401
|
REVIEWER_TODO_UPDATE,
|
|
13521
14402
|
VERIFICATION_REQUIREMENTS,
|
|
14403
|
+
// Async parallel work handling
|
|
14404
|
+
REVIEWER_ASYNC_MONITORING,
|
|
14405
|
+
REVIEWER_INTEGRATION_TESTING,
|
|
14406
|
+
REVIEWER_SYNC_VERIFICATION,
|
|
13522
14407
|
REVIEWER_OUTPUT,
|
|
13523
14408
|
SHARED_WORKSPACE
|
|
13524
14409
|
].join("\n\n");
|
|
13525
14410
|
var reviewer = {
|
|
13526
14411
|
id: AGENT_NAMES.REVIEWER,
|
|
13527
|
-
description: "Reviewer - verification
|
|
14412
|
+
description: "Reviewer - async verification, integration testing, sync validation",
|
|
13528
14413
|
systemPrompt: systemPrompt4,
|
|
13529
14414
|
canWrite: true,
|
|
13530
14415
|
canBash: true
|