@agentuity/opencode 1.0.19 → 1.0.20
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/dist/agents/expert-backend.d.ts +1 -1
- package/dist/agents/expert-backend.d.ts.map +1 -1
- package/dist/agents/expert-backend.js +0 -17
- package/dist/agents/expert-backend.js.map +1 -1
- package/dist/agents/expert.d.ts +1 -1
- package/dist/agents/expert.d.ts.map +1 -1
- package/dist/agents/expert.js +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +0 -2
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/lead.d.ts +1 -1
- package/dist/agents/lead.d.ts.map +1 -1
- package/dist/agents/lead.js +25 -145
- package/dist/agents/lead.js.map +1 -1
- package/dist/agents/scout.d.ts +1 -1
- package/dist/agents/scout.d.ts.map +1 -1
- package/dist/agents/scout.js +16 -0
- package/dist/agents/scout.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +1 -33
- package/dist/config/loader.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/hooks/cadence.d.ts +1 -2
- package/dist/plugin/hooks/cadence.d.ts.map +1 -1
- package/dist/plugin/hooks/cadence.js +7 -33
- package/dist/plugin/hooks/cadence.js.map +1 -1
- package/dist/plugin/hooks/compaction-utils.d.ts.map +1 -1
- package/dist/plugin/hooks/compaction-utils.js +6 -13
- package/dist/plugin/hooks/compaction-utils.js.map +1 -1
- package/dist/plugin/hooks/session-memory.d.ts +1 -2
- package/dist/plugin/hooks/session-memory.d.ts.map +1 -1
- package/dist/plugin/hooks/session-memory.js +6 -29
- package/dist/plugin/hooks/session-memory.js.map +1 -1
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +8 -222
- package/dist/plugin/plugin.js.map +1 -1
- package/dist/sqlite/types.d.ts +0 -6
- package/dist/sqlite/types.d.ts.map +1 -1
- package/dist/tmux/manager.d.ts +4 -4
- package/dist/tmux/manager.js +4 -4
- package/dist/tmux/types.d.ts +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/types.d.ts +2 -20
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -9
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/src/agents/expert-backend.ts +0 -17
- package/src/agents/expert.ts +1 -1
- package/src/agents/index.ts +0 -2
- package/src/agents/lead.ts +25 -145
- package/src/agents/scout.ts +16 -0
- package/src/config/loader.ts +1 -45
- package/src/index.ts +0 -1
- package/src/plugin/hooks/cadence.ts +6 -39
- package/src/plugin/hooks/compaction-utils.ts +6 -12
- package/src/plugin/hooks/session-memory.ts +5 -35
- package/src/plugin/plugin.ts +7 -257
- package/src/sqlite/types.ts +0 -2
- package/src/tmux/manager.ts +4 -4
- package/src/tmux/types.ts +2 -2
- package/src/tools/index.ts +2 -9
- package/src/types.ts +0 -13
- package/dist/agents/monitor.d.ts +0 -4
- package/dist/agents/monitor.d.ts.map +0 -1
- package/dist/agents/monitor.js +0 -159
- package/dist/agents/monitor.js.map +0 -1
- package/dist/background/concurrency.d.ts +0 -36
- package/dist/background/concurrency.d.ts.map +0 -1
- package/dist/background/concurrency.js +0 -92
- package/dist/background/concurrency.js.map +0 -1
- package/dist/background/index.d.ts +0 -5
- package/dist/background/index.d.ts.map +0 -1
- package/dist/background/index.js +0 -4
- package/dist/background/index.js.map +0 -1
- package/dist/background/manager.d.ts +0 -123
- package/dist/background/manager.d.ts.map +0 -1
- package/dist/background/manager.js +0 -1075
- package/dist/background/manager.js.map +0 -1
- package/dist/background/types.d.ts +0 -90
- package/dist/background/types.d.ts.map +0 -1
- package/dist/background/types.js +0 -2
- package/dist/background/types.js.map +0 -1
- package/dist/tools/background.d.ts +0 -67
- package/dist/tools/background.d.ts.map +0 -1
- package/dist/tools/background.js +0 -95
- package/dist/tools/background.js.map +0 -1
- package/src/agents/monitor.ts +0 -161
- package/src/background/concurrency.ts +0 -116
- package/src/background/index.ts +0 -4
- package/src/background/manager.ts +0 -1215
- package/src/background/types.ts +0 -82
- package/src/tools/background.ts +0 -179
package/src/agents/lead.ts
CHANGED
|
@@ -19,7 +19,7 @@ Then proceed with the appropriate action. This prevents misclassifying requests.
|
|
|
19
19
|
- **Quality gatekeeper.** Not: Cloud operator.
|
|
20
20
|
- **Context coordinator.** Not: Test runner.
|
|
21
21
|
|
|
22
|
-
**Golden Rule**: If it involves writing code, editing files, running commands, searching codebases, or gathering information via research — default to delegating it. Your job is to think, plan, coordinate, and decide. You CAN do lightweight research when working solo on simple tasks, but once you've delegated work
|
|
22
|
+
**Golden Rule**: If it involves writing code, editing files, running commands, searching codebases, or gathering information via research — default to delegating it. Your job is to think, plan, coordinate, and decide. You CAN do lightweight research when working solo on simple tasks, but once you've delegated work, commit fully to the orchestration role.
|
|
23
23
|
|
|
24
24
|
## Delegation Decision Guide
|
|
25
25
|
|
|
@@ -464,51 +464,14 @@ Use Open Code's Task tool to delegate work to subagents:
|
|
|
464
464
|
- \`@Agentuity Coder Expert\` — for Agentuity CLI commands and cloud questions
|
|
465
465
|
- \`@Agentuity Coder Runner\` — for running lint/build/test/typecheck/format commands (structured results)
|
|
466
466
|
|
|
467
|
-
##
|
|
467
|
+
## Parallel Delegation
|
|
468
468
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
**CRITICAL: Use \`agentuity_background_task\` instead of \`task\` when:**
|
|
472
|
-
- Launching multiple independent tasks (e.g., reviewing multiple packages)
|
|
473
|
-
- Tasks that can run concurrently without dependencies
|
|
474
|
-
- You want to continue working while agents run in parallel
|
|
475
|
-
- The user asks for "parallel", "background", or "concurrent" execution
|
|
476
|
-
|
|
477
|
-
**How to use \`agentuity_background_task\`:**
|
|
478
|
-
\`\`\`
|
|
479
|
-
agentuity_background_task({
|
|
480
|
-
agent: "scout", // scout, builder, reviewer, memory, expert
|
|
481
|
-
task: "Research security vulnerabilities for package X",
|
|
482
|
-
description: "Security review: package X" // optional short description
|
|
483
|
-
})
|
|
484
|
-
// Returns: { taskId: "bg_xxx", status: "pending" }
|
|
485
|
-
\`\`\`
|
|
486
|
-
|
|
487
|
-
**Checking results:**
|
|
488
|
-
\`\`\`
|
|
489
|
-
agentuity_background_output({ task_id: "bg_xxx" })
|
|
490
|
-
// Returns: { taskId, status, result, error }
|
|
491
|
-
\`\`\`
|
|
492
|
-
|
|
493
|
-
**Cancelling:**
|
|
494
|
-
\`\`\`
|
|
495
|
-
agentuity_background_cancel({ task_id: "bg_xxx" })
|
|
496
|
-
\`\`\`
|
|
497
|
-
|
|
498
|
-
**Session Dashboard (Lead-of-Leads Monitoring):**
|
|
499
|
-
\`\`\`
|
|
500
|
-
agentuity_session_dashboard({ session_id: "ses_xxx" })
|
|
501
|
-
// Returns: hierarchy of child sessions with status, costs, active tools, and health summary
|
|
502
|
-
\`\`\`
|
|
503
|
-
|
|
504
|
-
Use \`agentuity_session_dashboard\` when orchestrating Lead-of-Leads to get a full view of all child sessions, their status, costs, and what they're currently doing — without needing to inspect each task individually.
|
|
469
|
+
Use the \`task\` tool for ALL delegation. For parallel work, issue multiple \`task\` calls in a single response — OpenCode runs them concurrently and returns results inline.
|
|
505
470
|
|
|
506
471
|
**Example - Parallel Security Review:**
|
|
507
472
|
When asked to review multiple packages for security:
|
|
508
|
-
1. Launch \`
|
|
509
|
-
2.
|
|
510
|
-
3. Wait for \`[BACKGROUND TASK COMPLETED]\` notifications (event-driven, no polling)
|
|
511
|
-
4. Synthesize results after all notifications arrive
|
|
473
|
+
1. Launch multiple \`task\` calls for each package with Scout
|
|
474
|
+
2. Synthesize results after all task responses arrive
|
|
512
475
|
|
|
513
476
|
## Orchestration Patterns
|
|
514
477
|
|
|
@@ -519,9 +482,9 @@ Task → Agent → Result
|
|
|
519
482
|
\`\`\`
|
|
520
483
|
|
|
521
484
|
### FanOut (Parallel)
|
|
522
|
-
Launch multiple independent tasks in parallel
|
|
485
|
+
Launch multiple independent tasks in parallel by issuing multiple \`task\` calls in a single response.
|
|
523
486
|
\`\`\`
|
|
524
|
-
|
|
487
|
+
task(A) + task(B) + task(C) → Combine Results
|
|
525
488
|
\`\`\`
|
|
526
489
|
|
|
527
490
|
### Pipeline
|
|
@@ -555,7 +518,7 @@ Task → Agent A → Agent B → Agent C → Final Result
|
|
|
555
518
|
- **Phase 3: Verify** — Agent(s): Reviewer. Action: Verify fix, check for regressions. Decision point: If regressions found → iterate with Builder.
|
|
556
519
|
|
|
557
520
|
### Research Workflow
|
|
558
|
-
- **Phase 1: Explore** — Agent(s): Scout
|
|
521
|
+
- **Phase 1: Explore** — Agent(s): Scout. Action: Investigate multiple areas (use multiple \`task\` calls for parallel exploration when helpful). Decision point: If findings conflict → investigate further.
|
|
559
522
|
- **Phase 2: Synthesize** — Agent(s): Lead. Action: Combine findings, form recommendations. Decision point: If gaps remain → send Scout for targeted follow-up.
|
|
560
523
|
- **Phase 3: Store** — Agent(s): Memory. Action: Preserve key insights. Decision point: Always store actionable insights.
|
|
561
524
|
|
|
@@ -611,7 +574,7 @@ When the user signals they want autonomous, aggressive execution, enter **Ultraw
|
|
|
611
574
|
|
|
612
575
|
**Ultrawork Mode behavior:**
|
|
613
576
|
1. **Micro-plan first** — Create a quick 5-10 bullet plan (don't skip planning entirely)
|
|
614
|
-
2. **Aggressive delegation** — Use FanOut pattern
|
|
577
|
+
2. **Aggressive delegation** — Use FanOut pattern with multiple \`task\` calls when parallel discovery helps
|
|
615
578
|
3. **Auto-continue** — Don't stop to ask permission; keep iterating until truly done
|
|
616
579
|
4. **Verification gates** — Still require Reviewer for non-trivial changes
|
|
617
580
|
5. **Memory checkpoints** — Store progress frequently for recovery
|
|
@@ -633,71 +596,14 @@ When the user signals they want autonomous, aggressive execution, enter **Ultraw
|
|
|
633
596
|
- **Over-parallelizing:** Dependencies cause conflicts and wasted work → Sequence dependent tasks, parallelize only independent.
|
|
634
597
|
- **Skipping Scout:** Acting without understanding leads to wrong solutions → Always gather context before planning.
|
|
635
598
|
- **Running build/test directly:** Wastes context with raw output, misses structured errors → Delegate to Runner for structured results.
|
|
636
|
-
- **Doing background work yourself:** Duplicates work, wastes tokens, confuses results → Wait for [BACKGROUND TASK COMPLETED] notifications.
|
|
637
|
-
- **Cancelling tasks that are slow:** Slow ≠ stuck. Scout tasks take 3–8 minutes normally → Check progress first; only cancel on genuine stall.
|
|
638
|
-
|
|
639
|
-
## CRITICAL: Background Task Patience
|
|
640
|
-
|
|
641
|
-
### Monitor is auto-launched — you do not manage it
|
|
642
|
-
|
|
643
|
-
When you launch background tasks via \`agentuity_background_task\`, **a Monitor agent is automatically started** to watch all tasks for your session. You do not need to spawn it manually. Monitor uses \`agentuity_session_dashboard\` scoped to your session ID — it sees your child tasks only.
|
|
644
|
-
|
|
645
|
-
**Your role while background tasks run:**
|
|
646
|
-
1. **Report what you launched** — List task IDs and descriptions, then STOP
|
|
647
|
-
2. **Wait for Monitor's consolidated report** — Monitor will push \`[ALL BACKGROUND TASKS COMPLETE]\` when all work tasks finish
|
|
648
|
-
3. **Wait for individual \`[BACKGROUND TASK COMPLETED]\` notifications** — These fire event-driven as each task finishes
|
|
649
|
-
4. **Process results** — Use \`agentuity_background_output\` to retrieve full results after notification
|
|
650
|
-
|
|
651
|
-
**You do NOT need to poll.** Monitor is watching. The events are real-time. Polling wastes your context.
|
|
652
|
-
|
|
653
|
-
### Tool restrictions while waiting
|
|
654
|
-
|
|
655
|
-
You are in **orchestration-only mode** after launching background tasks. Do NOT use:
|
|
656
|
-
- \`webfetch\` — do not fetch URLs
|
|
657
|
-
- \`grep\` / \`glob\` — do not search the codebase
|
|
658
|
-
- \`read\` — do not read source files for research
|
|
659
|
-
- \`bash\` — do not run exploratory commands
|
|
660
|
-
|
|
661
|
-
These tools fill your context with content you've already delegated to background agents. One webfetch response can consume 5–15% of your context.
|
|
662
|
-
|
|
663
|
-
**You CAN:**
|
|
664
|
-
- Answer user questions about current progress
|
|
665
|
-
- Update todo list items
|
|
666
|
-
- Use extended thinking (no tool calls) to reason about how you'll combine results when they arrive
|
|
667
|
-
|
|
668
|
-
### If you feel the urge to check on a task
|
|
669
|
-
|
|
670
|
-
Before doing anything, call \`agentuity_background_output\` once and read the \`progress\` field:
|
|
671
|
-
|
|
672
|
-
\`\`\`json
|
|
673
|
-
{
|
|
674
|
-
"status": "running",
|
|
675
|
-
"progress": {
|
|
676
|
-
"toolCalls": 21,
|
|
677
|
-
"lastTool": "read",
|
|
678
|
-
"lastToolSec": 44,
|
|
679
|
-
"activeTools": 1
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
\`\`\`
|
|
683
|
-
|
|
684
|
-
- \`toolCalls > 0\` and \`lastToolSec < 300\` → **STILL WORKING. Do not intervene.**
|
|
685
|
-
- \`lastToolSec > 300\` AND \`activeTools === 0\` → Task may be genuinely stuck. Use \`agentuity_background_inspect\` for a full view, then decide.
|
|
686
|
-
|
|
687
|
-
**A Scout reading a large codebase takes 3–8 minutes. That is completely normal.**
|
|
688
|
-
|
|
689
|
-
### Never cancel based on elapsed time alone
|
|
690
|
-
|
|
691
|
-
Cancelling a nearly-done task wastes all its work and forces you to do it yourself — filling your context with raw tool output instead of a clean Scout report. Always check \`progress\` before cancelling.
|
|
692
599
|
|
|
693
600
|
## Context Budget Awareness
|
|
694
601
|
|
|
695
602
|
Every tool call output consumes context you need later for processing results. A single webfetch can be 5–15% of your window. Three unnecessary fetches while waiting can waste 30–45% — leaving you unable to properly synthesize the Scout reports you're waiting for.
|
|
696
603
|
|
|
697
604
|
**Before using any research tool, ask:**
|
|
698
|
-
1. "
|
|
699
|
-
2. "
|
|
700
|
-
3. "Will this output be large?" → If yes, delegate it.
|
|
605
|
+
1. "Do I need this RIGHT NOW for a decision?" → If no, WAIT.
|
|
606
|
+
2. "Will this output be large?" → If yes, delegate it.
|
|
701
607
|
|
|
702
608
|
## Task Completion: Memorialize the Session
|
|
703
609
|
|
|
@@ -1202,7 +1108,7 @@ When a task is too large or has independent workstreams that can run in parallel
|
|
|
1202
1108
|
- Large tasks with clear sequential order (do step 1, then step 2, then step 3)
|
|
1203
1109
|
- Work that requires tight coordination between parts
|
|
1204
1110
|
|
|
1205
|
-
**Rule of thumb:** Lead-of-Leads is for explicitly large, parallelizable work OR when the user explicitly asks for
|
|
1111
|
+
**Rule of thumb:** Lead-of-Leads is for explicitly large, parallelizable work OR when the user explicitly asks for parallel execution. Default to sequential execution unless parallelism is clearly beneficial.
|
|
1206
1112
|
|
|
1207
1113
|
#### Lead-of-Leads Workflow
|
|
1208
1114
|
|
|
@@ -1222,23 +1128,19 @@ Product will structure the PRD with:
|
|
|
1222
1128
|
]
|
|
1223
1129
|
\`\`\`
|
|
1224
1130
|
|
|
1225
|
-
**2. Spawn Child Leads via
|
|
1131
|
+
**2. Spawn Child Leads via the \`task\` Tool**
|
|
1132
|
+
|
|
1133
|
+
Use the \`task\` tool to spawn child Leads. For parallel work, issue multiple \`task\` calls in a single response:
|
|
1226
1134
|
|
|
1227
|
-
|
|
1135
|
+
\`\`\`
|
|
1136
|
+
@Agentuity Coder Lead
|
|
1228
1137
|
|
|
1229
|
-
|
|
1230
|
-
// Spawn child Lead for auth workstream
|
|
1231
|
-
agentuity_background_task({
|
|
1232
|
-
agent: "lead",
|
|
1233
|
-
task: \`[CADENCE MODE] [CHILD LEAD]
|
|
1138
|
+
[CADENCE MODE] [CHILD LEAD]
|
|
1234
1139
|
Parent Loop: {your loopId}
|
|
1235
1140
|
PRD Key: project:{label}:prd
|
|
1236
1141
|
Workstream: Auth Module
|
|
1237
1142
|
|
|
1238
|
-
Implement the authentication module. Claim your workstream in the PRD,
|
|
1239
|
-
work autonomously, and mark complete when done.\`,
|
|
1240
|
-
description: "Child Lead: Auth Module"
|
|
1241
|
-
})
|
|
1143
|
+
Implement the authentication module. Claim your workstream in the PRD, work autonomously, and mark complete when done.
|
|
1242
1144
|
\`\`\`
|
|
1243
1145
|
|
|
1244
1146
|
**3. Child Lead Behavior**
|
|
@@ -1259,26 +1161,10 @@ agentuity cloud kv get agentuity-opencode-memory "project:{label}:prd" --json --
|
|
|
1259
1161
|
# Ask Product: "Claim workstream 'Auth Module' for session {sessionId}"
|
|
1260
1162
|
\`\`\`
|
|
1261
1163
|
|
|
1262
|
-
**4.
|
|
1263
|
-
|
|
1264
|
-
After spawning child Leads, you will automatically receive notifications as each task completes:
|
|
1265
|
-
|
|
1266
|
-
- \`[BACKGROUND TASK COMPLETED]\` — fires for each task as it finishes
|
|
1267
|
-
- A Monitor agent is auto-launched to provide a consolidated \`[ALL BACKGROUND TASKS COMPLETE]\` report when all tasks are done
|
|
1268
|
-
|
|
1269
|
-
**You do NOT need to spawn a Monitor manually or poll.** The system handles this:
|
|
1270
|
-
- Event-driven notifications arrive in real-time as each child completes
|
|
1271
|
-
- The auto-launched Monitor watches all sibling tasks and sends a final summary
|
|
1272
|
-
- Keeps Lead's context clean (no polling loop exhausting context)
|
|
1273
|
-
- If Lead compacts, task references are preserved in context (injected by hooks)
|
|
1274
|
-
- Use \`agentuity_session_dashboard({ session_id: "<your_session_id>" })\` to check overall progress
|
|
1275
|
-
- Use \`agentuity_background_output({ task_id: "bg_xxx" })\` to retrieve results after a notification arrives
|
|
1276
|
-
- Use \`agentuity_background_inspect\` only if a task appears stuck (no activity for 5+ minutes)
|
|
1277
|
-
|
|
1278
|
-
**5. Completion**
|
|
1164
|
+
**4. Completion**
|
|
1279
1165
|
|
|
1280
1166
|
Parent Lead completes when:
|
|
1281
|
-
- All child task
|
|
1167
|
+
- All child task results have returned
|
|
1282
1168
|
- All workstreams in PRD show status "done"
|
|
1283
1169
|
- Any integration/coordination work is complete
|
|
1284
1170
|
|
|
@@ -1289,15 +1175,10 @@ User: "Build the e-commerce checkout flow with auth, cart, and payments — do t
|
|
|
1289
1175
|
|
|
1290
1176
|
You (Parent Lead):
|
|
1291
1177
|
1. Ask Product to establish PRD with 3 workstreams
|
|
1292
|
-
2. Spawn 3 child Leads
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
3. Wait for [BACKGROUND TASK COMPLETED] notifications (auto-delivered for each)
|
|
1297
|
-
4. Monitor auto-launches to send [ALL BACKGROUND TASKS COMPLETE] when all finish
|
|
1298
|
-
5. Use agentuity_background_output to retrieve results after each notification
|
|
1299
|
-
6. Check PRD status, do integration work if needed
|
|
1300
|
-
7. Output <promise>DONE</promise>
|
|
1178
|
+
2. Spawn 3 child Leads using multiple task calls in one response
|
|
1179
|
+
3. Wait for each task result inline
|
|
1180
|
+
4. Check PRD status, do integration work if needed
|
|
1181
|
+
5. Output <promise>DONE</promise>
|
|
1301
1182
|
\`\`\`
|
|
1302
1183
|
|
|
1303
1184
|
#### Coordination Rules
|
|
@@ -1306,7 +1187,6 @@ You (Parent Lead):
|
|
|
1306
1187
|
- **Product manages workstreams** — Ask Product to claim/update workstream status
|
|
1307
1188
|
- **No direct child-to-child communication** — Coordinate through PRD
|
|
1308
1189
|
- **Parent handles integration** — After children complete, parent does any glue work
|
|
1309
|
-
- **Notifications are automatic** — Each task sends [BACKGROUND TASK COMPLETED] on finish; Monitor auto-launches for consolidated reports
|
|
1310
1190
|
- **Session dashboard** — Use \`agentuity_session_dashboard\` to get a unified view of all child session states, costs, and health without inspecting each task individually
|
|
1311
1191
|
|
|
1312
1192
|
### Context Management
|
package/src/agents/scout.ts
CHANGED
|
@@ -65,6 +65,18 @@ ALWAYS batch independent tool calls together. When you need to read multiple fil
|
|
|
65
65
|
- **External API docs:** Use web fetch — official sources.
|
|
66
66
|
- **Understanding file contents:** Use Read — full context.
|
|
67
67
|
|
|
68
|
+
## Reading Large Files
|
|
69
|
+
|
|
70
|
+
The Read tool returns up to 2000 lines by default. For files longer than that, it will indicate truncation. **Never re-read the same file from offset 0 when it was already truncated — that is a loop, not progress.**
|
|
71
|
+
|
|
72
|
+
Rules for large files:
|
|
73
|
+
1. **Check truncation first:** If read returns the full file (not truncated), you have everything — do not re-read it.
|
|
74
|
+
2. **Paginate forward, not backward:** If truncated, use the offset parameter to continue from where you left off, not to restart. E.g. first call gets lines 1–2000, next call uses offset: 2001.
|
|
75
|
+
3. **Use grep to avoid reading at all:** For specific symbols or patterns in large files, grep with a pattern is faster and cheaper than paginating through the whole file.
|
|
76
|
+
4. **Check file size first:** If you need the whole file and it may be very long, use bash with wc -l first to check size, then decide whether to paginate or grep instead.
|
|
77
|
+
5. **Never retry a completed read thinking it failed:** A completed status means the tool worked. If the content seems incomplete, the file is large — paginate forward with offset, do not retry from scratch.
|
|
78
|
+
6. **Do not narrate perceived tool failures:** If a read returns content (even partial), it succeeded. Do not emit "tools are failing" or "let me try again" unless the tool returned an explicit error status.
|
|
79
|
+
|
|
68
80
|
### Documentation Source Priority
|
|
69
81
|
|
|
70
82
|
**CRITICAL: Never hallucinate URLs.** If you don't know the exact URL path for agentuity.dev, say "check agentuity.dev for [topic]" instead of making up a URL. Use GitHub SDK repo URLs which are predictable and verifiable.
|
|
@@ -322,4 +334,8 @@ export const scoutAgent: AgentDefinition = {
|
|
|
322
334
|
},
|
|
323
335
|
// Scout uses default variant (speed over depth) and low temp for factual exploration
|
|
324
336
|
temperature: 0.0,
|
|
337
|
+
// Cap steps to prevent runaway read-loops on large files. 80 steps is ample for
|
|
338
|
+
// thorough research (parallel batching means 5-10 files per step) while breaking
|
|
339
|
+
// any infinite retry cycle before it burns significant context budget.
|
|
340
|
+
maxSteps: 80,
|
|
325
341
|
};
|
package/src/config/loader.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { homedir } from 'node:os';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { YAML } from 'bun';
|
|
4
4
|
import type { CoderConfig, SkillsConfig } from '../types';
|
|
5
|
-
import type { BackgroundTaskConfig } from '../background/types';
|
|
6
5
|
import { CoderConfigSchema } from '../types';
|
|
7
6
|
import type { TmuxConfig } from '../tmux/types';
|
|
8
7
|
import { MIN_PANE_WIDTH } from '../tmux/types';
|
|
@@ -17,13 +16,6 @@ interface CLICoderConfig {
|
|
|
17
16
|
mainPaneMinWidth?: number;
|
|
18
17
|
agentPaneMinWidth?: number;
|
|
19
18
|
};
|
|
20
|
-
background?: {
|
|
21
|
-
enabled?: boolean;
|
|
22
|
-
defaultConcurrency?: number;
|
|
23
|
-
staleTimeoutMs?: number;
|
|
24
|
-
providerConcurrency?: Record<string, number>;
|
|
25
|
-
modelConcurrency?: Record<string, number>;
|
|
26
|
-
};
|
|
27
19
|
}
|
|
28
20
|
|
|
29
21
|
interface CLIConfig {
|
|
@@ -104,7 +96,7 @@ export async function loadCoderConfig(): Promise<CoderConfig> {
|
|
|
104
96
|
const cliConfig = YAML.parse(content) as CLIConfig;
|
|
105
97
|
|
|
106
98
|
// Extract orgId from CLI config preferences
|
|
107
|
-
// Extract coder settings (tmux
|
|
99
|
+
// Extract coder settings (tmux) from CLI config coder section
|
|
108
100
|
// Agent model overrides should be done via opencode.json
|
|
109
101
|
const coderConfig: CoderConfig = {
|
|
110
102
|
org: cliConfig.preferences?.orgId,
|
|
@@ -114,12 +106,6 @@ export async function loadCoderConfig(): Promise<CoderConfig> {
|
|
|
114
106
|
...cliConfig.coder.tmux,
|
|
115
107
|
}
|
|
116
108
|
: undefined,
|
|
117
|
-
background: cliConfig.coder?.background
|
|
118
|
-
? {
|
|
119
|
-
...DEFAULT_BACKGROUND_CONFIG,
|
|
120
|
-
...cliConfig.coder.background,
|
|
121
|
-
}
|
|
122
|
-
: undefined,
|
|
123
109
|
};
|
|
124
110
|
|
|
125
111
|
const result = CoderConfigSchema.safeParse(coderConfig);
|
|
@@ -144,14 +130,6 @@ const DEFAULT_BLOCKED_COMMANDS = [
|
|
|
144
130
|
'auth token', // Don't leak auth tokens
|
|
145
131
|
];
|
|
146
132
|
|
|
147
|
-
const DEFAULT_BACKGROUND_CONFIG: BackgroundTaskConfig = {
|
|
148
|
-
enabled: true,
|
|
149
|
-
defaultConcurrency: 5,
|
|
150
|
-
staleTimeoutMs: 30 * 60 * 1000,
|
|
151
|
-
providerConcurrency: {},
|
|
152
|
-
modelConcurrency: {},
|
|
153
|
-
};
|
|
154
|
-
|
|
155
133
|
const DEFAULT_SKILLS_CONFIG: SkillsConfig = {
|
|
156
134
|
enabled: true,
|
|
157
135
|
paths: [],
|
|
@@ -175,7 +153,6 @@ export function getDefaultConfig(): CoderConfig {
|
|
|
175
153
|
return {
|
|
176
154
|
disabledMcps: [],
|
|
177
155
|
blockedCommands: DEFAULT_BLOCKED_COMMANDS,
|
|
178
|
-
background: DEFAULT_BACKGROUND_CONFIG,
|
|
179
156
|
skills: DEFAULT_SKILLS_CONFIG,
|
|
180
157
|
tmux: DEFAULT_TMUX_CONFIG,
|
|
181
158
|
};
|
|
@@ -186,32 +163,11 @@ export function mergeConfig(base: CoderConfig, override: CoderConfig): CoderConf
|
|
|
186
163
|
org: override.org ?? base.org,
|
|
187
164
|
disabledMcps: override.disabledMcps ?? base.disabledMcps,
|
|
188
165
|
blockedCommands: override.blockedCommands ?? base.blockedCommands,
|
|
189
|
-
background: mergeBackgroundConfig(base.background, override.background),
|
|
190
166
|
skills: mergeSkillsConfig(base.skills, override.skills),
|
|
191
167
|
tmux: mergeTmuxConfig(base.tmux, override.tmux),
|
|
192
168
|
};
|
|
193
169
|
}
|
|
194
170
|
|
|
195
|
-
function mergeBackgroundConfig(
|
|
196
|
-
base?: BackgroundTaskConfig,
|
|
197
|
-
override?: BackgroundTaskConfig
|
|
198
|
-
): BackgroundTaskConfig | undefined {
|
|
199
|
-
if (!base && !override) return undefined;
|
|
200
|
-
return {
|
|
201
|
-
enabled: override?.enabled ?? base?.enabled ?? true,
|
|
202
|
-
defaultConcurrency: override?.defaultConcurrency ?? base?.defaultConcurrency ?? 5,
|
|
203
|
-
staleTimeoutMs: override?.staleTimeoutMs ?? base?.staleTimeoutMs ?? 30 * 60 * 1000,
|
|
204
|
-
providerConcurrency: {
|
|
205
|
-
...(base?.providerConcurrency ?? {}),
|
|
206
|
-
...(override?.providerConcurrency ?? {}),
|
|
207
|
-
},
|
|
208
|
-
modelConcurrency: {
|
|
209
|
-
...(base?.modelConcurrency ?? {}),
|
|
210
|
-
...(override?.modelConcurrency ?? {}),
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
171
|
function mergeSkillsConfig(base?: SkillsConfig, override?: SkillsConfig): SkillsConfig | undefined {
|
|
216
172
|
if (!base && !override) return undefined;
|
|
217
173
|
const paths = new Set([...(base?.paths ?? []), ...(override?.paths ?? [])]);
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { PluginInput } from '@opencode-ai/plugin';
|
|
2
2
|
import type { CoderConfig } from '../../types';
|
|
3
|
-
import type { BackgroundManager } from '../../background';
|
|
4
3
|
import type { OpenCodeDBReader, SessionTreeNode } from '../../sqlite';
|
|
5
4
|
import type { CompactionStats } from '../../sqlite/types';
|
|
6
5
|
import {
|
|
@@ -68,7 +67,6 @@ interface CadenceSessionState {
|
|
|
68
67
|
export function createCadenceHooks(
|
|
69
68
|
ctx: PluginInput,
|
|
70
69
|
config: CoderConfig,
|
|
71
|
-
backgroundManager?: BackgroundManager,
|
|
72
70
|
dbReader?: OpenCodeDBReader,
|
|
73
71
|
lastUserMessages?: Map<string, string>
|
|
74
72
|
): CadenceHooks {
|
|
@@ -361,47 +359,21 @@ After compaction:
|
|
|
361
359
|
3. Lead will continue the loop from iteration ${state.iteration}
|
|
362
360
|
4. Use 5-Question Reboot to re-orient: Where am I? Where going? Goal? Learned? Done?`;
|
|
363
361
|
|
|
364
|
-
// 4. Build
|
|
365
|
-
const tasks = backgroundManager?.getTasksByParent(sessionId) ?? [];
|
|
366
|
-
let backgroundSection: string | null = null;
|
|
367
|
-
|
|
368
|
-
if (tasks.length > 0) {
|
|
369
|
-
const taskList = tasks
|
|
370
|
-
.map(
|
|
371
|
-
(t) =>
|
|
372
|
-
`- **${t.id}**: ${t.description || 'No description'} (session: ${t.sessionId ?? 'pending'}, status: ${t.status})`
|
|
373
|
-
)
|
|
374
|
-
.join('\n');
|
|
375
|
-
|
|
376
|
-
backgroundSection = `## Active Background Tasks
|
|
377
|
-
|
|
378
|
-
This session has ${tasks.length} background task(s) running in separate sessions:
|
|
379
|
-
${taskList}
|
|
380
|
-
|
|
381
|
-
**CRITICAL:** Task IDs and session IDs persist across compaction - these tasks are still running.
|
|
382
|
-
Use \`agentuity_background_output({ task_id: "..." })\` to check their status.
|
|
383
|
-
Use \`agentuity_session_dashboard({ session_id: "..." })\` to get a full session tree with status, costs, and health summary for Lead-of-Leads monitoring.
|
|
384
|
-
|
|
385
|
-
**Tip:** A Monitor agent is auto-launched to watch these tasks. You will receive \`[BACKGROUND TASK COMPLETED]\` notifications as each task finishes, and \`[ALL BACKGROUND TASKS COMPLETE]\` when all are done. Use \`agentuity_session_dashboard\` for a unified progress view.`;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// 5. Build SQLite dashboard section
|
|
362
|
+
// 4. Build SQLite dashboard section
|
|
389
363
|
const dashboardSection = buildSqliteDashboardSummary(dbReader, sessionId);
|
|
390
364
|
|
|
391
|
-
//
|
|
365
|
+
// 5. Combine everything into the full prompt
|
|
392
366
|
const sections: string[] = [];
|
|
393
367
|
if (instructions) sections.push(instructions);
|
|
394
368
|
sections.push(cadenceStateSection);
|
|
395
|
-
if (backgroundSection) sections.push(backgroundSection);
|
|
396
369
|
if (planningState) sections.push(planningState);
|
|
397
370
|
if (imageDescs) sections.push(imageDescs);
|
|
398
371
|
if (toolSummaries) sections.push(toolSummaries);
|
|
399
372
|
if (dashboardSection) sections.push(dashboardSection);
|
|
400
373
|
|
|
401
|
-
//
|
|
374
|
+
// 6. Add diagnostics
|
|
402
375
|
const stats: CompactionStats = {
|
|
403
376
|
planningPhasesCount: countListItems(planningState),
|
|
404
|
-
backgroundTasksCount: tasks.length,
|
|
405
377
|
imageDescriptionsCount: countListItems(imageDescs),
|
|
406
378
|
toolCallSummariesCount: countListItems(toolSummaries),
|
|
407
379
|
estimatedTokens: Math.ceil(sections.join('\n\n').length / 4),
|
|
@@ -409,7 +381,7 @@ Use \`agentuity_session_dashboard({ session_id: "..." })\` to get a full session
|
|
|
409
381
|
const diagnostics = formatCompactionDiagnostics(stats);
|
|
410
382
|
if (diagnostics) sections.push(diagnostics);
|
|
411
383
|
|
|
412
|
-
//
|
|
384
|
+
// 7. Enforce token budget
|
|
413
385
|
let fullPrompt = sections.join('\n\n');
|
|
414
386
|
const estimatedTokens = Math.ceil(fullPrompt.length / 4);
|
|
415
387
|
if (maxTokens > 0 && estimatedTokens > maxTokens) {
|
|
@@ -425,24 +397,19 @@ Use \`agentuity_session_dashboard({ session_id: "..." })\` to get a full session
|
|
|
425
397
|
fullPrompt = trimmed.join('\n\n');
|
|
426
398
|
}
|
|
427
399
|
|
|
428
|
-
//
|
|
400
|
+
// 8. Set the full prompt or push to context
|
|
429
401
|
if (useCustomPrompt) {
|
|
430
402
|
output.prompt = fullPrompt;
|
|
431
403
|
} else {
|
|
432
404
|
output.context.push(fullPrompt);
|
|
433
405
|
}
|
|
434
406
|
|
|
435
|
-
//
|
|
407
|
+
// 9. Store pre-compaction snapshot to KV (fire-and-forget)
|
|
436
408
|
if (useSnapshotToKV) {
|
|
437
409
|
storePreCompactionSnapshot(sessionId, {
|
|
438
410
|
timestamp: new Date().toISOString(),
|
|
439
411
|
sessionId,
|
|
440
412
|
planningState: planningState ? { raw: planningState } : undefined,
|
|
441
|
-
backgroundTasks: tasks.map((t) => ({
|
|
442
|
-
id: t.id,
|
|
443
|
-
description: t.description || 'No description',
|
|
444
|
-
status: t.status,
|
|
445
|
-
})),
|
|
446
413
|
cadenceState: state ? { ...state } : undefined,
|
|
447
414
|
branch,
|
|
448
415
|
}).catch(() => {}); // Fire and forget
|
|
@@ -70,13 +70,12 @@ export function buildCustomCompactionPrompt(mode: 'cadence' | 'regular'): string
|
|
|
70
70
|
|
|
71
71
|
## CRITICAL — Preserve These Verbatim
|
|
72
72
|
1. The current task/objective (quote the user's original request exactly)
|
|
73
|
-
2.
|
|
74
|
-
3.
|
|
75
|
-
4.
|
|
76
|
-
5.
|
|
77
|
-
6.
|
|
78
|
-
7.
|
|
79
|
-
8. Descriptions of any images or attachments that appeared in conversation${cadenceSection}
|
|
73
|
+
2. Active planning state: current phase, completed phases, next steps, blockers
|
|
74
|
+
3. ALL file paths being actively worked on (with role: created/modified/read)
|
|
75
|
+
4. Key decisions made and their rationale
|
|
76
|
+
5. Any corrections or gotchas discovered during the session
|
|
77
|
+
6. Todo list state (what's done, in progress, pending)
|
|
78
|
+
7. Descriptions of any images or attachments that appeared in conversation${cadenceSection}
|
|
80
79
|
|
|
81
80
|
## Structure Your Summary As:
|
|
82
81
|
|
|
@@ -86,9 +85,6 @@ export function buildCustomCompactionPrompt(mode: 'cadence' | 'regular'): string
|
|
|
86
85
|
### Planning State
|
|
87
86
|
[Phases with status. Include phase notes, not just titles.]
|
|
88
87
|
|
|
89
|
-
### Background Tasks
|
|
90
|
-
[bg_xxx: description → status (running/completed/errored). Include session IDs.]
|
|
91
|
-
|
|
92
88
|
### Key Context
|
|
93
89
|
[Decisions, constraints, user preferences, corrections discovered]
|
|
94
90
|
|
|
@@ -104,7 +100,6 @@ export function buildCustomCompactionPrompt(mode: 'cadence' | 'regular'): string
|
|
|
104
100
|
## Rules
|
|
105
101
|
- Use specific file paths, task IDs, phase names — NOT vague references.
|
|
106
102
|
- State what tools returned, not just that they were called.
|
|
107
|
-
- NEVER drop background task references — the agent MUST know what's still running.
|
|
108
103
|
- Prefer completeness over brevity — this is the agent's entire working memory.`;
|
|
109
104
|
}
|
|
110
105
|
|
|
@@ -267,7 +262,6 @@ export async function restoreCadenceStateFromKV(
|
|
|
267
262
|
export function formatCompactionDiagnostics(stats: CompactionStats): string {
|
|
268
263
|
const parts: string[] = [];
|
|
269
264
|
if (stats.planningPhasesCount > 0) parts.push(`${stats.planningPhasesCount} planning phases`);
|
|
270
|
-
if (stats.backgroundTasksCount > 0) parts.push(`${stats.backgroundTasksCount} background tasks`);
|
|
271
265
|
if (stats.imageDescriptionsCount > 0) parts.push(`${stats.imageDescriptionsCount} image refs`);
|
|
272
266
|
if (stats.toolCallSummariesCount > 0) parts.push(`${stats.toolCallSummariesCount} tool calls`);
|
|
273
267
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { PluginInput } from '@opencode-ai/plugin';
|
|
2
2
|
import type { CoderConfig } from '../../types';
|
|
3
|
-
import type { BackgroundManager } from '../../background';
|
|
4
3
|
import type { OpenCodeDBReader } from '../../sqlite';
|
|
5
4
|
import type { CompactionStats } from '../../sqlite/types';
|
|
6
5
|
import {
|
|
@@ -34,7 +33,6 @@ export interface SessionMemoryHooks {
|
|
|
34
33
|
export function createSessionMemoryHooks(
|
|
35
34
|
ctx: PluginInput,
|
|
36
35
|
config: CoderConfig,
|
|
37
|
-
backgroundManager?: BackgroundManager,
|
|
38
36
|
dbReader?: OpenCodeDBReader
|
|
39
37
|
): SessionMemoryHooks {
|
|
40
38
|
const log = (msg: string) => {
|
|
@@ -188,40 +186,17 @@ After compaction:
|
|
|
188
186
|
2. If planning is active, Memory should update planning.progress with this compaction
|
|
189
187
|
3. Memory will apply inline reasoning if significant patterns/corrections emerged`;
|
|
190
188
|
|
|
191
|
-
// 4.
|
|
192
|
-
const tasks = backgroundManager?.getTasksByParent(sessionId) ?? [];
|
|
193
|
-
let backgroundSection: string | null = null;
|
|
194
|
-
|
|
195
|
-
if (tasks.length > 0) {
|
|
196
|
-
const taskList = tasks
|
|
197
|
-
.map(
|
|
198
|
-
(t) =>
|
|
199
|
-
`- **${t.id}**: ${t.description || 'No description'} (session: ${t.sessionId ?? 'pending'}, status: ${t.status})`
|
|
200
|
-
)
|
|
201
|
-
.join('\n');
|
|
202
|
-
|
|
203
|
-
backgroundSection = `## Active Background Tasks
|
|
204
|
-
|
|
205
|
-
This session has ${tasks.length} background task(s) running in separate sessions:
|
|
206
|
-
${taskList}
|
|
207
|
-
|
|
208
|
-
**CRITICAL:** Task IDs and session IDs persist across compaction - these tasks are still running.
|
|
209
|
-
Use \`agentuity_background_output({ task_id: "..." })\` to check their status.`;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// 5. Combine everything into the full prompt
|
|
189
|
+
// 4. Combine everything into the full prompt
|
|
213
190
|
const sections: string[] = [];
|
|
214
191
|
if (instructions) sections.push(instructions);
|
|
215
192
|
sections.push(sessionStateSection);
|
|
216
|
-
if (backgroundSection) sections.push(backgroundSection);
|
|
217
193
|
if (planningState) sections.push(planningState);
|
|
218
194
|
if (imageDescs) sections.push(imageDescs);
|
|
219
195
|
if (toolSummaries) sections.push(toolSummaries);
|
|
220
196
|
|
|
221
|
-
//
|
|
197
|
+
// 5. Add diagnostics
|
|
222
198
|
const stats: CompactionStats = {
|
|
223
199
|
planningPhasesCount: countListItems(planningState),
|
|
224
|
-
backgroundTasksCount: tasks.length,
|
|
225
200
|
imageDescriptionsCount: countListItems(imageDescs),
|
|
226
201
|
toolCallSummariesCount: countListItems(toolSummaries),
|
|
227
202
|
estimatedTokens: Math.ceil(sections.join('\n\n').length / 4),
|
|
@@ -229,7 +204,7 @@ Use \`agentuity_background_output({ task_id: "..." })\` to check their status.`;
|
|
|
229
204
|
const diagnostics = formatCompactionDiagnostics(stats);
|
|
230
205
|
if (diagnostics) sections.push(diagnostics);
|
|
231
206
|
|
|
232
|
-
//
|
|
207
|
+
// 6. Enforce token budget
|
|
233
208
|
let fullPrompt = sections.join('\n\n');
|
|
234
209
|
const estimatedTokens = Math.ceil(fullPrompt.length / 4);
|
|
235
210
|
if (maxTokens > 0 && estimatedTokens > maxTokens) {
|
|
@@ -245,24 +220,19 @@ Use \`agentuity_background_output({ task_id: "..." })\` to check their status.`;
|
|
|
245
220
|
fullPrompt = trimmed.join('\n\n');
|
|
246
221
|
}
|
|
247
222
|
|
|
248
|
-
//
|
|
223
|
+
// 7. Set the full prompt or push to context
|
|
249
224
|
if (useCustomPrompt) {
|
|
250
225
|
output.prompt = fullPrompt;
|
|
251
226
|
} else {
|
|
252
227
|
output.context.push(fullPrompt);
|
|
253
228
|
}
|
|
254
229
|
|
|
255
|
-
//
|
|
230
|
+
// 8. Store pre-compaction snapshot to KV (fire-and-forget)
|
|
256
231
|
if (useSnapshotToKV) {
|
|
257
232
|
storePreCompactionSnapshot(sessionId, {
|
|
258
233
|
timestamp: new Date().toISOString(),
|
|
259
234
|
sessionId,
|
|
260
235
|
planningState: planningState ? { raw: planningState } : undefined,
|
|
261
|
-
backgroundTasks: tasks.map((t) => ({
|
|
262
|
-
id: t.id,
|
|
263
|
-
description: t.description || 'No description',
|
|
264
|
-
status: t.status,
|
|
265
|
-
})),
|
|
266
236
|
branch,
|
|
267
237
|
}).catch(() => {}); // Fire and forget
|
|
268
238
|
}
|