opencode-orchestrator 0.9.63 → 0.9.66
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 +5 -15
- package/bin/orchestrator +0 -0
- package/bin/orchestrator-linux-arm64 +0 -0
- package/bin/orchestrator-linux-x64 +0 -0
- package/bin/orchestrator-macos-arm64 +0 -0
- package/bin/orchestrator-macos-x64 +0 -0
- package/bin/orchestrator-windows-x64.exe +0 -0
- package/dist/agents/prompts/common/ast.d.ts +4 -0
- package/dist/agents/prompts/common/index.d.ts +2 -0
- package/dist/agents/prompts/common/lsp.d.ts +4 -0
- package/dist/agents/prompts/reviewer/index.d.ts +1 -0
- package/dist/agents/prompts/reviewer/lsp-tools.d.ts +1 -0
- package/dist/agents/prompts/worker/index.d.ts +1 -0
- package/dist/agents/prompts/worker/lsp-tools.d.ts +1 -0
- package/dist/core/commands/types/background-task-status.d.ts +13 -1
- package/dist/core/context/context-window-monitor.d.ts +59 -0
- package/dist/core/context/index.d.ts +6 -0
- package/dist/core/loop/mission-seal.d.ts +1 -1
- package/dist/index.js +954 -595
- package/dist/shared/agent/constants/index.d.ts +0 -2
- package/dist/shared/agent/constants/names.d.ts +1 -0
- package/dist/shared/agent/index.d.ts +2 -1
- package/dist/shared/agent/types/index.d.ts +1 -0
- package/dist/shared/agent/types/status-types.d.ts +5 -0
- package/dist/shared/agent/utils/index.d.ts +7 -0
- package/dist/shared/core/constants/cli.d.ts +26 -0
- package/dist/shared/core/constants/index.d.ts +3 -0
- package/dist/shared/core/constants/limits.d.ts +19 -0
- package/dist/shared/core/constants/status-labels.d.ts +32 -0
- package/dist/shared/errors/constants/error-patterns.d.ts +13 -0
- package/dist/shared/errors/constants/error-type.d.ts +13 -0
- package/dist/shared/errors/constants/index.d.ts +5 -0
- package/dist/shared/errors/detection.d.ts +1 -1
- package/dist/shared/errors/index.d.ts +2 -2
- package/dist/shared/errors/retry.d.ts +1 -1
- package/dist/shared/errors/types/error-pattern-type.d.ts +5 -0
- package/dist/shared/errors/types/index.d.ts +4 -0
- package/dist/shared/loop/constants/mission-seal.d.ts +2 -2
- package/dist/shared/prompt/constants/status.d.ts +17 -16
- package/dist/shared/prompt/constants/tags.d.ts +4 -0
- package/dist/shared/session/constants/events/document-events.d.ts +7 -0
- package/dist/shared/session/constants/events/index.d.ts +28 -0
- package/dist/shared/session/constants/events/message-events.d.ts +6 -0
- package/dist/shared/session/constants/events/mission-events.d.ts +8 -0
- package/dist/shared/session/constants/events/session-events.d.ts +10 -0
- package/dist/shared/session/constants/events/special-events.d.ts +6 -0
- package/dist/shared/session/constants/events/task-events.d.ts +9 -0
- package/dist/shared/session/constants/events/todo-events.d.ts +8 -0
- package/dist/shared/session/constants/index.d.ts +1 -4
- package/dist/shared/tool/constants/common/index.d.ts +7 -0
- package/dist/shared/tool/constants/common/labels.d.ts +16 -0
- package/dist/shared/tool/constants/common/languages.d.ts +9 -0
- package/dist/shared/tool/constants/common/output-labels.d.ts +20 -0
- package/dist/shared/tool/constants/common/sources.d.ts +8 -0
- package/dist/shared/tool/constants/index.d.ts +3 -0
- package/dist/shared/tool/constants/lsp/index.d.ts +5 -0
- package/dist/shared/tool/constants/lsp/lsp-severity-labels.d.ts +9 -0
- package/dist/shared/tool/constants/lsp/lsp-severity.d.ts +9 -0
- package/dist/shared/tool/constants/parallel/index.d.ts +4 -0
- package/dist/shared/tool/constants/parallel/logging.d.ts +6 -0
- package/dist/shared/tool/constants/tool-names.d.ts +3 -0
- package/dist/shared/tool/index.d.ts +1 -0
- package/dist/shared/tool/interfaces/ast/ast-replace-result.d.ts +8 -0
- package/dist/shared/tool/interfaces/ast/ast-search-result.d.ts +13 -0
- package/dist/shared/tool/interfaces/ast/index.d.ts +5 -0
- package/dist/shared/tool/interfaces/index.d.ts +6 -0
- package/dist/shared/tool/interfaces/lsp/index.d.ts +7 -0
- package/dist/shared/tool/interfaces/lsp/lsp-command-result.d.ts +8 -0
- package/dist/shared/tool/interfaces/lsp/lsp-diagnostic.d.ts +11 -0
- package/dist/shared/tool/interfaces/lsp/lsp-rename-location.d.ts +9 -0
- package/dist/shared/tool/interfaces/lsp/lsp-rename-result.d.ts +9 -0
- package/dist/shared/tool/interfaces/parallel/index.d.ts +5 -0
- package/dist/shared/tool/interfaces/parallel/poll-result.d.ts +10 -0
- package/dist/shared/tool/interfaces/parallel/session-client.d.ts +47 -0
- package/dist/tools/ast/index.d.ts +41 -0
- package/dist/tools/lsp/index.d.ts +20 -0
- package/dist/tools/search.d.ts +10 -0
- package/dist/utils/sanity/checker.d.ts +8 -0
- package/dist/utils/sanity/constants/escalation-prompt.d.ts +4 -0
- package/dist/utils/sanity/constants/index.d.ts +6 -0
- package/dist/utils/sanity/constants/recovery-prompt.d.ts +4 -0
- package/dist/utils/sanity/constants/severity.d.ts +8 -0
- package/dist/utils/sanity/index.d.ts +7 -0
- package/dist/utils/sanity/interfaces/index.d.ts +4 -0
- package/dist/utils/sanity/interfaces/sanity-result.d.ts +9 -0
- package/dist/utils/sanity/types/index.d.ts +4 -0
- package/dist/utils/sanity/types/severity.d.ts +5 -0
- package/package.json +17 -6
- package/dist/shared/agent/constants/status.d.ts +0 -15
- package/dist/shared/errors/patterns.d.ts +0 -27
- package/dist/shared/session/constants/event-types.d.ts +0 -77
- package/dist/shared/session/constants/session-events.d.ts +0 -17
- package/dist/utils/sanity.d.ts +0 -33
package/dist/index.js
CHANGED
|
@@ -25,24 +25,19 @@ var AGENT_TOKENS = {
|
|
|
25
25
|
SUBAGENT_MAX_TOKENS: 32e3
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
// src/shared/agent/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
timeout: "TIM",
|
|
42
|
-
cancelled: "CAN"
|
|
43
|
-
};
|
|
44
|
-
function getStatusEmoji(status) {
|
|
45
|
-
return STATUS_EMOJI[status] ?? "?";
|
|
28
|
+
// src/shared/agent/utils/index.ts
|
|
29
|
+
function getStatusIndicator(status) {
|
|
30
|
+
const statusMap = {
|
|
31
|
+
pending: "[P]",
|
|
32
|
+
running: "[R]",
|
|
33
|
+
done: "[D]",
|
|
34
|
+
completed: "[D]",
|
|
35
|
+
success: "[+]",
|
|
36
|
+
failed: "[-]",
|
|
37
|
+
error: "[-]",
|
|
38
|
+
cancelled: "[X]"
|
|
39
|
+
};
|
|
40
|
+
return statusMap[status.toLowerCase()] ?? "[?]";
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
// src/shared/core/constants/time.ts
|
|
@@ -93,6 +88,71 @@ var MEMORY_LIMITS = {
|
|
|
93
88
|
ERROR_CLEANUP_AGE_MS: 10 * TIME.MINUTE
|
|
94
89
|
};
|
|
95
90
|
|
|
91
|
+
// src/shared/core/constants/status-labels.ts
|
|
92
|
+
var STATUS_LABEL = {
|
|
93
|
+
// Basic States
|
|
94
|
+
PENDING: "pending",
|
|
95
|
+
RUNNING: "running",
|
|
96
|
+
IN_PROGRESS: "in_progress",
|
|
97
|
+
COMPLETED: "completed",
|
|
98
|
+
DONE: "done",
|
|
99
|
+
SUCCESS: "success",
|
|
100
|
+
// Failure States
|
|
101
|
+
FAILED: "failed",
|
|
102
|
+
ERROR: "error",
|
|
103
|
+
TIMEOUT: "timeout",
|
|
104
|
+
CANCELLED: "cancelled",
|
|
105
|
+
BLOCKED: "blocked",
|
|
106
|
+
// Test/Audit Results
|
|
107
|
+
PASS: "pass",
|
|
108
|
+
FAIL: "fail",
|
|
109
|
+
SKIP: "skip",
|
|
110
|
+
// Quality/Cleanliness
|
|
111
|
+
CLEAN: "clean",
|
|
112
|
+
OK: "ok",
|
|
113
|
+
VERIFIED: "verified",
|
|
114
|
+
// Analysis/Diagnostic
|
|
115
|
+
WARNING: "warning",
|
|
116
|
+
INFO: "info",
|
|
117
|
+
HINT: "hint",
|
|
118
|
+
ALL: "all",
|
|
119
|
+
HIGH: "high",
|
|
120
|
+
MEDIUM: "medium",
|
|
121
|
+
LOW: "low"
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// src/shared/core/constants/limits.ts
|
|
125
|
+
var LIMITS = {
|
|
126
|
+
/** Maximum mission loop iterations */
|
|
127
|
+
MAX_ITERATIONS: 1e3,
|
|
128
|
+
/** Default scan limit for file listing */
|
|
129
|
+
DEFAULT_SCAN_LIMIT: 20,
|
|
130
|
+
/** Max message history to check for seal */
|
|
131
|
+
SEAL_CHECK_HISTORY: 3,
|
|
132
|
+
/** Max concurrent tasks per agent */
|
|
133
|
+
MAX_TASKS_PER_AGENT: 10,
|
|
134
|
+
/** Default history/list limit for UI */
|
|
135
|
+
DEFAULT_LIST_LIMIT: 20,
|
|
136
|
+
/** Default progress bar width */
|
|
137
|
+
DEFAULT_PROGRESS_WIDTH: 20,
|
|
138
|
+
/** Maximum time for atomic task (minutes) */
|
|
139
|
+
TASK_TIME_LIMIT_MIN: 10
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// src/shared/core/constants/cli.ts
|
|
143
|
+
var CLI_NAME = {
|
|
144
|
+
NPX: "npx",
|
|
145
|
+
TSC: "tsc",
|
|
146
|
+
ESLINT: "eslint",
|
|
147
|
+
RG: "rg",
|
|
148
|
+
SED: "sed",
|
|
149
|
+
AST_GREP: "ast-grep",
|
|
150
|
+
GIT: "git",
|
|
151
|
+
JQ: "jq",
|
|
152
|
+
NODE: "node",
|
|
153
|
+
SH: "sh"
|
|
154
|
+
};
|
|
155
|
+
|
|
96
156
|
// src/shared/task/constants/parallel-task.ts
|
|
97
157
|
var PARALLEL_LABEL = "parallel";
|
|
98
158
|
var PARALLEL_TASK = {
|
|
@@ -145,7 +205,7 @@ var LOOP = {
|
|
|
145
205
|
/** Window to consider abort as recent */
|
|
146
206
|
ABORT_WINDOW_MS: 3 * TIME.SECOND,
|
|
147
207
|
/** Maximum iterations for mission loop */
|
|
148
|
-
DEFAULT_MAX_ITERATIONS:
|
|
208
|
+
DEFAULT_MAX_ITERATIONS: LIMITS.MAX_ITERATIONS,
|
|
149
209
|
/** Rust tool timeout */
|
|
150
210
|
RUST_TOOL_TIMEOUT_MS: 60 * TIME.SECOND
|
|
151
211
|
};
|
|
@@ -155,7 +215,7 @@ var MISSION_SEAL = {
|
|
|
155
215
|
TAG: "mission_seal",
|
|
156
216
|
CONFIRMATION: "SEALED",
|
|
157
217
|
PATTERN: "<mission_seal>SEALED</mission_seal>",
|
|
158
|
-
DEFAULT_MAX_ITERATIONS:
|
|
218
|
+
DEFAULT_MAX_ITERATIONS: LIMITS.MAX_ITERATIONS,
|
|
159
219
|
DEFAULT_COUNTDOWN_SECONDS: 3,
|
|
160
220
|
STATE_FILE: "loop-state.json",
|
|
161
221
|
STOP_COMMAND: "/stop",
|
|
@@ -242,53 +302,61 @@ var FILTER_STATUS = {
|
|
|
242
302
|
PENDING: "pending"
|
|
243
303
|
};
|
|
244
304
|
|
|
245
|
-
// src/shared/session/constants/
|
|
246
|
-
var SESSION_EVENTS = {
|
|
247
|
-
IDLE: "session.idle",
|
|
248
|
-
DELETED: "session.deleted",
|
|
249
|
-
CREATED: "session.created",
|
|
250
|
-
ERROR: "session.error"
|
|
251
|
-
};
|
|
252
|
-
var MESSAGE_EVENTS = {
|
|
253
|
-
UPDATED: "message.updated"
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
// src/shared/session/constants/event-types.ts
|
|
305
|
+
// src/shared/session/constants/events/task-events.ts
|
|
257
306
|
var TASK_EVENTS = {
|
|
258
307
|
STARTED: "task.started",
|
|
259
308
|
COMPLETED: "task.completed",
|
|
260
309
|
FAILED: "task.failed",
|
|
261
310
|
CANCELLED: "task.cancelled"
|
|
262
311
|
};
|
|
312
|
+
|
|
313
|
+
// src/shared/session/constants/events/todo-events.ts
|
|
263
314
|
var TODO_EVENTS = {
|
|
264
315
|
CREATED: "todo.created",
|
|
265
316
|
UPDATED: "todo.updated",
|
|
266
317
|
COMPLETED: "todo.completed"
|
|
267
318
|
};
|
|
268
|
-
|
|
319
|
+
|
|
320
|
+
// src/shared/session/constants/events/session-events.ts
|
|
321
|
+
var SESSION_EVENTS = {
|
|
269
322
|
IDLE: "session.idle",
|
|
270
323
|
BUSY: "session.busy",
|
|
271
324
|
ERROR: "session.error",
|
|
272
|
-
DELETED: "session.deleted"
|
|
325
|
+
DELETED: "session.deleted",
|
|
326
|
+
CREATED: "session.created"
|
|
273
327
|
};
|
|
328
|
+
|
|
329
|
+
// src/shared/session/constants/events/document-events.ts
|
|
274
330
|
var DOCUMENT_EVENTS = {
|
|
275
331
|
CACHED: "document.cached",
|
|
276
332
|
EXPIRED: "document.expired"
|
|
277
333
|
};
|
|
334
|
+
|
|
335
|
+
// src/shared/session/constants/events/mission-events.ts
|
|
278
336
|
var MISSION_EVENTS = {
|
|
279
337
|
COMPLETE: "mission.complete",
|
|
280
338
|
FAILED: "mission.failed",
|
|
281
339
|
ALL_TASKS_COMPLETE: "all_tasks.complete"
|
|
282
340
|
};
|
|
341
|
+
|
|
342
|
+
// src/shared/session/constants/events/message-events.ts
|
|
343
|
+
var MESSAGE_EVENTS = {
|
|
344
|
+
UPDATED: "message.updated"
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
// src/shared/session/constants/events/special-events.ts
|
|
283
348
|
var SPECIAL_EVENTS = {
|
|
284
349
|
WILDCARD: "*"
|
|
285
350
|
};
|
|
351
|
+
|
|
352
|
+
// src/shared/session/constants/events/index.ts
|
|
286
353
|
var EVENT_TYPES = {
|
|
287
354
|
...TASK_EVENTS,
|
|
288
355
|
...TODO_EVENTS,
|
|
289
|
-
...
|
|
356
|
+
...SESSION_EVENTS,
|
|
290
357
|
...DOCUMENT_EVENTS,
|
|
291
358
|
...MISSION_EVENTS,
|
|
359
|
+
...MESSAGE_EVENTS,
|
|
292
360
|
...SPECIAL_EVENTS
|
|
293
361
|
};
|
|
294
362
|
|
|
@@ -325,6 +393,11 @@ var TOOL_NAMES = {
|
|
|
325
393
|
WEBSEARCH: "websearch",
|
|
326
394
|
CODESEARCH: "codesearch",
|
|
327
395
|
CACHE_DOCS: "cache_docs",
|
|
396
|
+
// LSP tools
|
|
397
|
+
LSP_DIAGNOSTICS: "lsp_diagnostics",
|
|
398
|
+
// AST tools
|
|
399
|
+
AST_SEARCH: "ast_search",
|
|
400
|
+
AST_REPLACE: "ast_replace",
|
|
328
401
|
// Other tools
|
|
329
402
|
CALL_AGENT: "call_agent",
|
|
330
403
|
SLASHCOMMAND: "slashcommand"
|
|
@@ -338,6 +411,61 @@ var TOOL_OUTPUT = {
|
|
|
338
411
|
SMALL_OUTPUT_THRESHOLD: 5e3
|
|
339
412
|
};
|
|
340
413
|
|
|
414
|
+
// src/shared/tool/constants/lsp/lsp-severity.ts
|
|
415
|
+
var LSP_SEVERITY = {
|
|
416
|
+
ERROR: 1,
|
|
417
|
+
WARNING: 2,
|
|
418
|
+
INFO: 3,
|
|
419
|
+
HINT: 4
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// src/shared/tool/constants/common/labels.ts
|
|
423
|
+
var TOOL_LABEL = {
|
|
424
|
+
ERROR: STATUS_LABEL.ERROR,
|
|
425
|
+
WARNING: STATUS_LABEL.WARNING,
|
|
426
|
+
INFO: STATUS_LABEL.INFO,
|
|
427
|
+
HINT: STATUS_LABEL.HINT,
|
|
428
|
+
SUCCESS: STATUS_LABEL.SUCCESS,
|
|
429
|
+
FAILED: STATUS_LABEL.FAILED,
|
|
430
|
+
CLEAN: STATUS_LABEL.CLEAN,
|
|
431
|
+
TIMEOUT: STATUS_LABEL.TIMEOUT,
|
|
432
|
+
DONE: STATUS_LABEL.DONE,
|
|
433
|
+
PENDING: STATUS_LABEL.PENDING,
|
|
434
|
+
RUNNING: STATUS_LABEL.RUNNING
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
// src/shared/tool/constants/lsp/lsp-severity-labels.ts
|
|
438
|
+
var LSP_SEVERITY_LABELS = {
|
|
439
|
+
[LSP_SEVERITY.ERROR]: TOOL_LABEL.ERROR,
|
|
440
|
+
[LSP_SEVERITY.WARNING]: TOOL_LABEL.WARNING,
|
|
441
|
+
[LSP_SEVERITY.INFO]: TOOL_LABEL.INFO,
|
|
442
|
+
[LSP_SEVERITY.HINT]: TOOL_LABEL.HINT
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
// src/shared/tool/constants/parallel/logging.ts
|
|
446
|
+
var PARALLEL_LOG = {
|
|
447
|
+
DELEGATE_TASK: "[delegate-task]"
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
// src/shared/tool/constants/common/output-labels.ts
|
|
451
|
+
var OUTPUT_LABEL = {
|
|
452
|
+
ERROR: "[ERROR]",
|
|
453
|
+
WARNING: "[WARNING]",
|
|
454
|
+
INFO: "[INFO]",
|
|
455
|
+
DONE: "[DONE]",
|
|
456
|
+
OK: "[OK]",
|
|
457
|
+
SPAWNED: "[SPAWNED]",
|
|
458
|
+
RESUME: "[RESUME]",
|
|
459
|
+
TIMEOUT: "[TIMEOUT]",
|
|
460
|
+
RUNNING: "[RUNNING]",
|
|
461
|
+
CANCELLED: "[CANCELLED]",
|
|
462
|
+
RESUMED_DONE: "[RESUMED & DONE]",
|
|
463
|
+
SYNC_START: "[SYNC START]",
|
|
464
|
+
CACHED: "[CACHED]",
|
|
465
|
+
JSON_FETCHED: "[JSON FETCHED]",
|
|
466
|
+
TEXT_FETCHED: "[TEXT FETCHED]"
|
|
467
|
+
};
|
|
468
|
+
|
|
341
469
|
// src/shared/message/constants/part-types.ts
|
|
342
470
|
var PART_TYPES = {
|
|
343
471
|
TEXT: "text",
|
|
@@ -380,7 +508,7 @@ var SESSION_STATUS = {
|
|
|
380
508
|
BUSY: "busy"
|
|
381
509
|
};
|
|
382
510
|
|
|
383
|
-
// src/shared/errors/patterns.ts
|
|
511
|
+
// src/shared/errors/constants/error-patterns.ts
|
|
384
512
|
var ERROR_PATTERNS = {
|
|
385
513
|
TOOL_RESULT_MISSING: /tool_result_missing|tool result.*missing/i,
|
|
386
514
|
THINKING_BLOCK_ORDER: /thinking.*block.*order|thinking_block_order/i,
|
|
@@ -391,6 +519,8 @@ var ERROR_PATTERNS = {
|
|
|
391
519
|
NETWORK_ERROR: /network|ECONNREFUSED|ETIMEDOUT|fetch failed/i,
|
|
392
520
|
AUTH_ERROR: /unauthorized|401|403|invalid.*token/i
|
|
393
521
|
};
|
|
522
|
+
|
|
523
|
+
// src/shared/errors/constants/error-type.ts
|
|
394
524
|
var ERROR_TYPE = {
|
|
395
525
|
TOOL_RESULT_MISSING: "TOOL_RESULT_MISSING",
|
|
396
526
|
THINKING_BLOCK_ORDER: "THINKING_BLOCK_ORDER",
|
|
@@ -455,7 +585,8 @@ var PROMPT_TAGS = {
|
|
|
455
585
|
TODO_MANAGEMENT: { open: "<todo_management>", close: "</todo_management>" },
|
|
456
586
|
OUTPUT_FORMAT: { open: "<output_format>", close: "</output_format>" },
|
|
457
587
|
// === Mission Loop ===
|
|
458
|
-
MISSION_LOOP: { open: "<mission_loop>", close: "</mission_loop>" }
|
|
588
|
+
MISSION_LOOP: { open: "<mission_loop>", close: "</mission_loop>" },
|
|
589
|
+
AUTONOMOUS_MODE: { open: "<autonomous_mode>", close: "</autonomous_mode>" }
|
|
459
590
|
};
|
|
460
591
|
|
|
461
592
|
// src/shared/prompt/constants/status.ts
|
|
@@ -467,25 +598,25 @@ var WORK_STATUS = {
|
|
|
467
598
|
DELETE: "DELETE",
|
|
468
599
|
FIX: "FIX"
|
|
469
600
|
},
|
|
470
|
-
// Task/file status
|
|
601
|
+
// Task/file status (Internal state)
|
|
471
602
|
STATUS: {
|
|
472
|
-
PENDING:
|
|
473
|
-
IN_PROGRESS:
|
|
474
|
-
DONE:
|
|
475
|
-
FAILED:
|
|
603
|
+
PENDING: STATUS_LABEL.PENDING,
|
|
604
|
+
IN_PROGRESS: STATUS_LABEL.IN_PROGRESS,
|
|
605
|
+
DONE: STATUS_LABEL.DONE,
|
|
606
|
+
FAILED: STATUS_LABEL.FAILED
|
|
476
607
|
},
|
|
477
608
|
// Test result
|
|
478
609
|
TEST_RESULT: {
|
|
479
|
-
PASS:
|
|
480
|
-
FAIL:
|
|
481
|
-
SKIP:
|
|
610
|
+
PASS: STATUS_LABEL.PASS,
|
|
611
|
+
FAIL: STATUS_LABEL.FAIL,
|
|
612
|
+
SKIP: STATUS_LABEL.SKIP
|
|
482
613
|
},
|
|
483
614
|
// E2E integration test status
|
|
484
615
|
E2E_STATUS: {
|
|
485
616
|
NOT_STARTED: "NOT_STARTED",
|
|
486
|
-
RUNNING:
|
|
487
|
-
PASS:
|
|
488
|
-
FAIL:
|
|
617
|
+
RUNNING: STATUS_LABEL.RUNNING,
|
|
618
|
+
PASS: STATUS_LABEL.PASS,
|
|
619
|
+
FAIL: STATUS_LABEL.FAIL
|
|
489
620
|
},
|
|
490
621
|
// Mission phase
|
|
491
622
|
PHASE: {
|
|
@@ -512,9 +643,10 @@ var WORK_STATUS = {
|
|
|
512
643
|
},
|
|
513
644
|
// Session state
|
|
514
645
|
SESSION: {
|
|
515
|
-
STARTED:
|
|
516
|
-
|
|
517
|
-
|
|
646
|
+
STARTED: STATUS_LABEL.PENDING,
|
|
647
|
+
// Standardized mapping
|
|
648
|
+
COMPLETED: STATUS_LABEL.DONE,
|
|
649
|
+
CANCELLED: STATUS_LABEL.CANCELLED
|
|
518
650
|
},
|
|
519
651
|
// Task triage - complexity classification
|
|
520
652
|
TRIAGE: {
|
|
@@ -536,22 +668,23 @@ var WORK_STATUS = {
|
|
|
536
668
|
},
|
|
537
669
|
// TODO.md status values (for Epic/Task display)
|
|
538
670
|
TODO_STATUS: {
|
|
539
|
-
PENDING:
|
|
540
|
-
IN_PROGRESS:
|
|
541
|
-
COMPLETE:
|
|
542
|
-
BLOCKED:
|
|
543
|
-
DONE:
|
|
671
|
+
PENDING: STATUS_LABEL.PENDING,
|
|
672
|
+
IN_PROGRESS: STATUS_LABEL.IN_PROGRESS,
|
|
673
|
+
COMPLETE: STATUS_LABEL.COMPLETED,
|
|
674
|
+
BLOCKED: STATUS_LABEL.BLOCKED,
|
|
675
|
+
DONE: STATUS_LABEL.DONE,
|
|
676
|
+
VERIFIED: STATUS_LABEL.VERIFIED
|
|
544
677
|
},
|
|
545
678
|
// Task size estimation
|
|
546
679
|
TASK_SIZE: {
|
|
547
680
|
XS: "XS",
|
|
548
|
-
// <
|
|
681
|
+
// <10min
|
|
549
682
|
S: "S",
|
|
550
|
-
//
|
|
683
|
+
// 10-20min
|
|
551
684
|
M: "M",
|
|
552
|
-
//
|
|
685
|
+
// 20-40min
|
|
553
686
|
L: "L"
|
|
554
|
-
//
|
|
687
|
+
// 40-60min
|
|
555
688
|
}
|
|
556
689
|
};
|
|
557
690
|
|
|
@@ -578,19 +711,19 @@ var PHILOSOPHY_LEARN_PRINCIPLE = "LEARN = DOCUMENT: What you discover, you recor
|
|
|
578
711
|
|
|
579
712
|
// src/core/agents/consts/task-status.const.ts
|
|
580
713
|
var TASK_STATUS = {
|
|
581
|
-
PENDING:
|
|
582
|
-
RUNNING:
|
|
583
|
-
COMPLETED:
|
|
584
|
-
FAILED:
|
|
585
|
-
ERROR:
|
|
586
|
-
TIMEOUT:
|
|
587
|
-
CANCELLED:
|
|
714
|
+
PENDING: STATUS_LABEL.PENDING,
|
|
715
|
+
RUNNING: STATUS_LABEL.RUNNING,
|
|
716
|
+
COMPLETED: STATUS_LABEL.COMPLETED,
|
|
717
|
+
FAILED: STATUS_LABEL.FAILED,
|
|
718
|
+
ERROR: STATUS_LABEL.ERROR,
|
|
719
|
+
TIMEOUT: STATUS_LABEL.TIMEOUT,
|
|
720
|
+
CANCELLED: STATUS_LABEL.CANCELLED
|
|
588
721
|
};
|
|
589
722
|
var TODO_STATUS = {
|
|
590
|
-
PENDING:
|
|
591
|
-
IN_PROGRESS:
|
|
592
|
-
COMPLETED:
|
|
593
|
-
CANCELLED:
|
|
723
|
+
PENDING: STATUS_LABEL.PENDING,
|
|
724
|
+
IN_PROGRESS: STATUS_LABEL.IN_PROGRESS,
|
|
725
|
+
COMPLETED: STATUS_LABEL.COMPLETED,
|
|
726
|
+
CANCELLED: STATUS_LABEL.CANCELLED
|
|
594
727
|
};
|
|
595
728
|
|
|
596
729
|
// src/core/orchestrator/state.ts
|
|
@@ -13025,16 +13158,17 @@ tool.schema = external_exports;
|
|
|
13025
13158
|
|
|
13026
13159
|
// src/agents/prompts/common/environment-discovery.ts
|
|
13027
13160
|
var ENVIRONMENT_DISCOVERY = `${PROMPT_TAGS.ENVIRONMENT_DISCOVERY.open}
|
|
13028
|
-
|
|
13161
|
+
**MANDATORY FIRST STEP** - Before any planning or coding:
|
|
13029
13162
|
|
|
13030
13163
|
## 1. Project Structure Discovery
|
|
13031
13164
|
Explore the project root to understand its organization:
|
|
13032
13165
|
\`\`\`bash
|
|
13033
13166
|
ls -la # Root contents
|
|
13034
|
-
find . -maxdepth 2 -type d | head
|
|
13167
|
+
find . -maxdepth 2 -type d | head -${LIMITS.DEFAULT_SCAN_LIMIT} # Directory structure
|
|
13035
13168
|
find . -maxdepth 1 -type f # Root files
|
|
13036
13169
|
\`\`\`
|
|
13037
13170
|
|
|
13171
|
+
|
|
13038
13172
|
**Look for patterns, NOT specific files:**
|
|
13039
13173
|
- Source directories (src/, lib/, app/, pkg/, internal/, cmd/)
|
|
13040
13174
|
- Test directories (tests/, test/, spec/, __tests__/, *_test/)
|
|
@@ -13125,7 +13259,7 @@ ls -la ${PATHS.OPENCODE}/ 2>/dev/null || echo "No existing context"
|
|
|
13125
13259
|
- [Any unique patterns or requirements observed]
|
|
13126
13260
|
\`\`\`
|
|
13127
13261
|
|
|
13128
|
-
##
|
|
13262
|
+
## CRITICAL RULES:
|
|
13129
13263
|
1. NEVER assume - always VERIFY by reading files
|
|
13130
13264
|
2. ADAPT to what you find, don't force expectations
|
|
13131
13265
|
3. If uncertain, ASK the user for clarification
|
|
@@ -13134,7 +13268,7 @@ ${PROMPT_TAGS.ENVIRONMENT_DISCOVERY.close}`;
|
|
|
13134
13268
|
|
|
13135
13269
|
// src/agents/prompts/common/anti-hallucination.ts
|
|
13136
13270
|
var ANTI_HALLUCINATION_CORE = `${PROMPT_TAGS.ANTI_HALLUCINATION.open}
|
|
13137
|
-
|
|
13271
|
+
ZERO TOLERANCE FOR GUESSING
|
|
13138
13272
|
|
|
13139
13273
|
## The Golden Rule
|
|
13140
13274
|
> If you're not 100% sure, **SEARCH** before you claim.
|
|
@@ -13147,7 +13281,7 @@ var ANTI_HALLUCINATION_CORE = `${PROMPT_TAGS.ANTI_HALLUCINATION.open}
|
|
|
13147
13281
|
ls ${PATHS.DOCS}/ # What do we already have?
|
|
13148
13282
|
\`\`\`
|
|
13149
13283
|
|
|
13150
|
-
### Step 2: If Not Found
|
|
13284
|
+
### Step 2: If Not Found -> Research
|
|
13151
13285
|
- Search for OFFICIAL documentation
|
|
13152
13286
|
- Prefer version-specific docs matching project
|
|
13153
13287
|
- Cache findings to ${PATHS.DOCS}/
|
|
@@ -13158,20 +13292,20 @@ ls ${PATHS.DOCS}/ # What do we already have?
|
|
|
13158
13292
|
- Are there breaking changes to consider?
|
|
13159
13293
|
|
|
13160
13294
|
## Source Hierarchy (Most to Least Trusted):
|
|
13161
|
-
1.
|
|
13162
|
-
2.
|
|
13163
|
-
3.
|
|
13164
|
-
4.
|
|
13165
|
-
5.
|
|
13295
|
+
1. [Trusted] **Official docs** - docs.*, *.dev, readthedocs
|
|
13296
|
+
2. [Trusted] **GitHub source** - actual source code, README
|
|
13297
|
+
3. [Neutral] **Package registries** - npm, PyPI, crates.io, Maven
|
|
13298
|
+
4. [Neutral] **GitHub issues** - real-world usage patterns
|
|
13299
|
+
5. [Caution] **Blogs/tutorials** - may be outdated, verify independently
|
|
13166
13300
|
|
|
13167
|
-
##
|
|
13301
|
+
## FORBIDDEN:
|
|
13168
13302
|
- Inventing function signatures from memory
|
|
13169
13303
|
- Assuming API compatibility between versions
|
|
13170
13304
|
- Guessing version-specific syntax
|
|
13171
13305
|
- Using knowledge without verification
|
|
13172
13306
|
- Mixing syntax from different versions
|
|
13173
13307
|
|
|
13174
|
-
##
|
|
13308
|
+
## REQUIRED:
|
|
13175
13309
|
- Source URL for every technical claim
|
|
13176
13310
|
- Confidence level: ${WORK_STATUS.CONFIDENCE.HIGH} (official) / ${WORK_STATUS.CONFIDENCE.MEDIUM} (github) / ${WORK_STATUS.CONFIDENCE.LOW} (blog)
|
|
13177
13311
|
- Say "I need to research this" if unsure
|
|
@@ -13185,82 +13319,84 @@ ${PROMPT_TAGS.ANTI_HALLUCINATION.close}`;
|
|
|
13185
13319
|
|
|
13186
13320
|
// src/agents/prompts/common/todo-rules.ts
|
|
13187
13321
|
var TODO_RULES = `${PROMPT_TAGS.TODO_RULES.open}
|
|
13188
|
-
|
|
13322
|
+
TODO MANAGEMENT - ADAPTIVE HIERARCHICAL STRUCTURE
|
|
13189
13323
|
|
|
13190
13324
|
## Before Creating TODOs: EXPLORE
|
|
13191
13325
|
1. Read ${PATHS.CONTEXT} to understand project structure
|
|
13192
13326
|
2. Study existing code organization
|
|
13193
13327
|
3. Plan parallel execution groups based on actual dependencies
|
|
13194
13328
|
|
|
13195
|
-
##
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13329
|
+
## Recursive Hierarchy (Adapt to Project)
|
|
13330
|
+
Break down work into as many nested levels as necessary.
|
|
13331
|
+
- **Root**: The main Mission/Goal.
|
|
13332
|
+
- **Branch**: Parent tasks representing modules, features, or epics.
|
|
13333
|
+
- **Leaf**: Atomic work units (15-60 min) with checkboxes \`[ ]\`.
|
|
13199
13334
|
|
|
13200
|
-
## Completion Rules
|
|
13201
|
-
-
|
|
13202
|
-
-
|
|
13203
|
-
-
|
|
13335
|
+
## Completion & Propagation Rules
|
|
13336
|
+
- **Leaf Tasks**: Mark \`[x]\` ONLY when verified by ${AGENT_NAMES.REVIEWER} with evidence (build/test/lsp).
|
|
13337
|
+
- **Parent Tasks**: Automatically considered ${WORK_STATUS.TODO_STATUS.COMPLETE} ONLY when ALL their direct children (subtasks or sub-groups) are marked \`[x]\` or \`COMPLETE\`.
|
|
13338
|
+
- **Mission**: Fully resolved ONLY when the entire hierarchy is marked \`[x]\`.
|
|
13204
13339
|
|
|
13205
|
-
|
|
13340
|
+
[CRITICAL]: Parent NEVER marked complete before ALL children are verified!
|
|
13206
13341
|
|
|
13207
|
-
## Format (
|
|
13342
|
+
## Format (Nested Indentation)
|
|
13208
13343
|
\`\`\`markdown
|
|
13209
13344
|
# Mission: [goal]
|
|
13210
13345
|
|
|
13211
|
-
##
|
|
13212
|
-
###
|
|
13213
|
-
- [ ]
|
|
13214
|
-
- [ ]
|
|
13215
|
-
### T1.2: [Task Name] | agent:${AGENT_NAMES.WORKER} | depends:T1.1
|
|
13216
|
-
- [ ] S1.2.1: [subtask] | size:M
|
|
13346
|
+
## G1: [Goal Name] | status: ${WORK_STATUS.TODO_STATUS.IN_PROGRESS}
|
|
13347
|
+
### P1.1: [Project Name] | agent:${AGENT_NAMES.WORKER}
|
|
13348
|
+
- [ ] T1.1.1: [subtask] | size:S
|
|
13349
|
+
- [ ] T1.1.2: [subtask] | size:S
|
|
13217
13350
|
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13351
|
+
#### P1.1.3: [Sub-component]
|
|
13352
|
+
- [ ] T1.1.3.1: [Nested task] | size:M
|
|
13353
|
+
|
|
13354
|
+
### P1.2: [Review Block] | agent:${AGENT_NAMES.REVIEWER} | depends:P1.1
|
|
13355
|
+
- [ ] T1.2.1: [Final Verification] | size:S
|
|
13221
13356
|
\`\`\`
|
|
13222
13357
|
|
|
13223
13358
|
## Status Indicators
|
|
13224
|
-
- [ ] = Not started
|
|
13225
|
-
- [x] = VERIFIED complete (
|
|
13226
|
-
- status: ${WORK_STATUS.TODO_STATUS.IN_PROGRESS} = Currently working
|
|
13227
|
-
- status: ${WORK_STATUS.TODO_STATUS.BLOCKED}:[reason] = Cannot proceed
|
|
13228
|
-
-
|
|
13359
|
+
- \`[ ]\` = Not started
|
|
13360
|
+
- \`[x]\` = VERIFIED complete (by ${AGENT_NAMES.REVIEWER})
|
|
13361
|
+
- \`status: ${WORK_STATUS.TODO_STATUS.IN_PROGRESS}\` = Currently working
|
|
13362
|
+
- \`status: ${WORK_STATUS.TODO_STATUS.BLOCKED}:[reason]\` = Cannot proceed
|
|
13363
|
+
- \`status: ${WORK_STATUS.TODO_STATUS.COMPLETE}\` = All children verified
|
|
13364
|
+
- \`depends:[id]\` = Dependency on another task
|
|
13229
13365
|
|
|
13230
13366
|
## Verification Flow (Evidence-Based)
|
|
13231
|
-
1. ${AGENT_NAMES.WORKER} completes subtask, reports with evidence
|
|
13232
|
-
2. ${AGENT_NAMES.REVIEWER} runs project's build/test commands from ${PATHS.CONTEXT}
|
|
13233
|
-
3. ${AGENT_NAMES.REVIEWER} verifies and marks subtask [x]
|
|
13234
|
-
4.
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
|
|
13238
|
-
-
|
|
13239
|
-
-
|
|
13240
|
-
- Skipping verification step
|
|
13241
|
-
- Marking [x] without evidence
|
|
13367
|
+
1. ${AGENT_NAMES.WORKER} completes subtask, reports with evidence.
|
|
13368
|
+
2. ${AGENT_NAMES.REVIEWER} runs project's build/test commands from ${PATHS.CONTEXT}.
|
|
13369
|
+
3. ${AGENT_NAMES.REVIEWER} verifies and marks leaf subtask \`[x]\`.
|
|
13370
|
+
4. ${AGENT_NAMES.REVIEWER} propagates completion to Parent if ALL sibling tasks are also \`[x]\`.
|
|
13371
|
+
|
|
13372
|
+
## FORBIDDEN
|
|
13373
|
+
- Marking parent \`[x]\` or \`${WORK_STATUS.TODO_STATUS.COMPLETE}\` before all children \`[x]\`.
|
|
13374
|
+
- Creating items with \`[x]\` already marked.
|
|
13375
|
+
- Marking \`[x]\` without tool-based evidence.
|
|
13242
13376
|
${PROMPT_TAGS.TODO_RULES.close}`;
|
|
13243
13377
|
|
|
13244
13378
|
// src/agents/prompts/common/shared-workspace.ts
|
|
13245
13379
|
var SHARED_WORKSPACE = `${PROMPT_TAGS.SHARED_WORKSPACE.open}
|
|
13246
|
-
|
|
13380
|
+
${PATHS.OPENCODE}/ - Shared Context Directory (Real-time State)
|
|
13247
13381
|
|
|
13248
13382
|
\`\`\`
|
|
13249
13383
|
${PATHS.OPENCODE}/
|
|
13250
|
-
\u251C\u2500\u2500
|
|
13251
|
-
\u251C\u2500\u2500
|
|
13252
|
-
\u251C\u2500\u2500
|
|
13384
|
+
\u251C\u2500\u2500 ${PATHS.TODO.split("/").pop()} - Master task list (single source of truth)
|
|
13385
|
+
\u251C\u2500\u2500 ${PATHS.CONTEXT.split("/").pop()} - Project context summary (<150 lines)
|
|
13386
|
+
\u251C\u2500\u2500 ${PATHS.WORK_LOG.split("/").pop()} - REAL-TIME work status (ALL agents read/write)
|
|
13253
13387
|
\u2502 # - Active sessions & assigned files
|
|
13254
13388
|
\u2502 # - Unit test completion records
|
|
13255
13389
|
\u2502 # - Pending integration items
|
|
13256
|
-
\u251C\u2500\u2500
|
|
13390
|
+
\u251C\u2500\u2500 ${PATHS.UNIT_TESTS.split("/").pop()}/ - Unit test records (preserved after deletion)
|
|
13257
13391
|
\u2502 \u2514\u2500\u2500 [timestamp]-[file].md # Test content, results, deleted test code
|
|
13258
|
-
\u251C\u2500\u2500
|
|
13259
|
-
\u251C\u2500\u2500
|
|
13260
|
-
\u251C\u2500\u2500
|
|
13261
|
-
\u2514\u2500\u2500
|
|
13392
|
+
\u251C\u2500\u2500 ${PATHS.SYNC_ISSUES.split("/").pop()} - File sync issues (Reviewer writes)
|
|
13393
|
+
\u251C\u2500\u2500 ${PATHS.INTEGRATION_STATUS.split("/").pop()} - Integration test results & sync status
|
|
13394
|
+
\u251C\u2500\u2500 ${PATHS.DOCS.split("/").pop()}/ - Cached documentation
|
|
13395
|
+
\u2514\u2500\u2500 ${PATHS.ARCHIVE.split("/").pop()}/ - Old context
|
|
13262
13396
|
\`\`\`
|
|
13263
13397
|
|
|
13398
|
+
|
|
13399
|
+
|
|
13264
13400
|
## ID Formats (no digit limit):
|
|
13265
13401
|
- Session: ${ID_PREFIX.SESSION}N (e.g., ${ID_PREFIX.SESSION}1, ${ID_PREFIX.SESSION}42)
|
|
13266
13402
|
- Sync Issue: ${ID_PREFIX.SYNC_ISSUE}N (e.g., ${ID_PREFIX.SYNC_ISSUE}1, ${ID_PREFIX.SYNC_ISSUE}100)
|
|
@@ -13276,8 +13412,8 @@ ${PATHS.OPENCODE}/
|
|
|
13276
13412
|
# Work Log
|
|
13277
13413
|
|
|
13278
13414
|
## Active Sessions
|
|
13279
|
-
- [ ] ${ID_PREFIX.SESSION}1 (
|
|
13280
|
-
- [x] ${ID_PREFIX.SESSION}2 (
|
|
13415
|
+
- [ ] ${ID_PREFIX.SESSION}1 (${AGENT_NAMES.WORKER}): \`src/auth/login.ts\` - ${WORK_STATUS.STATUS.IN_PROGRESS}
|
|
13416
|
+
- [x] ${ID_PREFIX.SESSION}2 (${AGENT_NAMES.WORKER}): \`src/utils/hash.ts\` - ${WORK_STATUS.SESSION.COMPLETED}
|
|
13281
13417
|
|
|
13282
13418
|
## Completed Units (Ready for Integration)
|
|
13283
13419
|
| File | Session | Unit Test | Timestamp |
|
|
@@ -13295,22 +13431,23 @@ ${PATHS.OPENCODE}/
|
|
|
13295
13431
|
|
|
13296
13432
|
RULES:
|
|
13297
13433
|
- ALL agents MUST read ${PATHS.WORK_LOG} before starting
|
|
13298
|
-
-
|
|
13299
|
-
-
|
|
13300
|
-
-
|
|
13301
|
-
- ${PATHS.SYNC_ISSUES} =
|
|
13302
|
-
${PROMPT_TAGS.SHARED_WORKSPACE.close}
|
|
13434
|
+
- ${AGENT_NAMES.WORKER} updates ${PATHS.WORK_LOG} when starting/completing file work
|
|
13435
|
+
- ${AGENT_NAMES.REVIEWER} monitors ${PATHS.WORK_LOG} for completed units
|
|
13436
|
+
- ${AGENT_NAMES.COMMANDER} reads ${PATHS.WORK_LOG} in each loop iteration
|
|
13437
|
+
- ${PATHS.SYNC_ISSUES} = ${AGENT_NAMES.REVIEWER} writes issues for next iteration
|
|
13438
|
+
${PROMPT_TAGS.SHARED_WORKSPACE.close}
|
|
13439
|
+
`;
|
|
13303
13440
|
|
|
13304
13441
|
// src/agents/prompts/common/mission-seal.ts
|
|
13305
13442
|
var MISSION_SEAL_RULES = `${PROMPT_TAGS.MISSION_SEAL.open}
|
|
13306
13443
|
MISSION COMPLETION SEAL
|
|
13307
13444
|
|
|
13308
13445
|
## Seal Requirements - ALL must be true:
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13446
|
+
- [ ] All items in ${PATHS.TODO} are [x]
|
|
13447
|
+
- [ ] Build passes (npm run build or equivalent)
|
|
13448
|
+
- [ ] Tests pass (npm test or equivalent)
|
|
13449
|
+
- [ ] ${AGENT_NAMES.REVIEWER} verification ${STATUS_LABEL.PASS.toUpperCase()} confirmed
|
|
13450
|
+
- [ ] No pending background tasks
|
|
13314
13451
|
|
|
13315
13452
|
## Seal Output Format:
|
|
13316
13453
|
\`\`\`
|
|
@@ -13322,54 +13459,81 @@ Evidence: [test/build results]
|
|
|
13322
13459
|
|
|
13323
13460
|
If ANY checkbox is unchecked, DO NOT seal - continue working!
|
|
13324
13461
|
NEVER output seal before requirements met!
|
|
13325
|
-
${PROMPT_TAGS.MISSION_SEAL.close}
|
|
13462
|
+
${PROMPT_TAGS.MISSION_SEAL.close}
|
|
13463
|
+
`;
|
|
13326
13464
|
|
|
13327
13465
|
// src/agents/prompts/common/verification.ts
|
|
13328
13466
|
var VERIFICATION_REQUIREMENTS = `${PROMPT_TAGS.VERIFICATION.open}
|
|
13329
13467
|
VERIFICATION CHECKLIST
|
|
13330
13468
|
|
|
13331
13469
|
## Code Verification
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13470
|
+
- [ ] lsp_diagnostics clean (no errors/warnings)
|
|
13471
|
+
- [ ] Build passes (use project's build command from ${PATHS.CONTEXT})
|
|
13472
|
+
- [ ] Tests pass (use project's test command from ${PATHS.CONTEXT})
|
|
13473
|
+
- [ ] No untyped variables (language-appropriate)
|
|
13474
|
+
- [ ] No debug logging left (console.log, print, etc.)
|
|
13337
13475
|
|
|
13338
13476
|
## Documentation Verification
|
|
13339
|
-
|
|
13340
|
-
|
|
13341
|
-
|
|
13477
|
+
- [ ] Implementation matches ${PATHS.DOCS}/
|
|
13478
|
+
- [ ] API usage matches official docs
|
|
13479
|
+
- [ ] Version compatibility confirmed
|
|
13342
13480
|
|
|
13343
13481
|
## Security Verification
|
|
13344
|
-
|
|
13345
|
-
|
|
13346
|
-
|
|
13482
|
+
- [ ] No hardcoded secrets/passwords/API keys
|
|
13483
|
+
- [ ] Input validation present
|
|
13484
|
+
- [ ] Error messages don't leak sensitive info
|
|
13347
13485
|
|
|
13348
13486
|
ONLY mark complete after ALL checks pass!
|
|
13349
|
-
${PROMPT_TAGS.VERIFICATION.close}
|
|
13487
|
+
${PROMPT_TAGS.VERIFICATION.close}
|
|
13488
|
+
`;
|
|
13350
13489
|
|
|
13351
13490
|
// src/agents/prompts/common/core-philosophy.ts
|
|
13352
13491
|
var CORE_PHILOSOPHY = `${PROMPT_TAGS.CORE_PHILOSOPHY.open}
|
|
13353
|
-
##
|
|
13492
|
+
## Core Philosophy: ${PHILOSOPHY_TAGLINE}
|
|
13354
13493
|
|
|
13355
13494
|
> ${PHILOSOPHY_QUOTE}
|
|
13356
13495
|
|
|
13357
13496
|
| Phase | Action | Key Behavior |
|
|
13358
13497
|
|:-----:|:-------|:-------------|
|
|
13359
|
-
|
|
|
13360
|
-
|
|
|
13361
|
-
|
|
|
13362
|
-
|
|
|
13498
|
+
| [EXPLORE] **${PHILOSOPHY_PHASES.EXPLORE}** | Scan unknown territory | Detect environment, never assume |
|
|
13499
|
+
| [LEARN] **${PHILOSOPHY_PHASES.LEARN}** | Document discoveries | Record patterns for future use |
|
|
13500
|
+
| [ADAPT] **${PHILOSOPHY_PHASES.ADAPT}** | Adjust to findings | Match project's style and context |
|
|
13501
|
+
| [ACT] **${PHILOSOPHY_PHASES.ACT}** | Execute with confidence | Build, test, seal |
|
|
13363
13502
|
|
|
13364
13503
|
**${PHILOSOPHY_LEARN_PRINCIPLE}**
|
|
13365
13504
|
|
|
13366
13505
|
### Agent Focus:
|
|
13367
|
-
-
|
|
13368
|
-
-
|
|
13369
|
-
-
|
|
13370
|
-
-
|
|
13506
|
+
- [COMMANDER] **${AGENT_NAMES.COMMANDER}**: All phases (orchestrate the full cycle)
|
|
13507
|
+
- [PLANNER] **${AGENT_NAMES.PLANNER}**: ${PHILOSOPHY_PHASES.EXPLORE} \u2192 ${PHILOSOPHY_PHASES.LEARN} (research and document)
|
|
13508
|
+
- [WORKER] **${AGENT_NAMES.WORKER}**: ${PHILOSOPHY_PHASES.ADAPT} \u2192 ${PHILOSOPHY_PHASES.ACT} (implement with fit)
|
|
13509
|
+
- [REVIEWER] **${AGENT_NAMES.REVIEWER}**: ${PHILOSOPHY_PHASES.EXPLORE} \u2192 ${PHILOSOPHY_PHASES.LEARN} \u2192 ${PHILOSOPHY_PHASES.ACT} (verify with evidence)
|
|
13371
13510
|
${PROMPT_TAGS.CORE_PHILOSOPHY.close}`;
|
|
13372
13511
|
|
|
13512
|
+
// src/agents/prompts/common/lsp.ts
|
|
13513
|
+
var SHARED_LSP_TOOLS = `<lsp_tools>
|
|
13514
|
+
### LSP (Language Server Protocol) Tools
|
|
13515
|
+
- \`${TOOL_NAMES.LSP_DIAGNOSTICS}\`: Find type errors, syntax issues, and lint warnings.
|
|
13516
|
+
|
|
13517
|
+
**Rules**:
|
|
13518
|
+
- **Verification**: ALWAYS run \`${TOOL_NAMES.LSP_DIAGNOSTICS}({ file: "*" })\` before marking a task or TODO as complete.
|
|
13519
|
+
</lsp_tools>`;
|
|
13520
|
+
|
|
13521
|
+
// src/agents/prompts/common/ast.ts
|
|
13522
|
+
var SHARED_AST_TOOLS = `<ast_tools>
|
|
13523
|
+
### AST (Structural) Tools
|
|
13524
|
+
- \`${TOOL_NAMES.AST_SEARCH}\`: Find code by syntax patterns (e.g., finding all function calls with specific arguments).
|
|
13525
|
+
- \`${TOOL_NAMES.AST_REPLACE}\`: Perform structural refactoring using syntax patterns.
|
|
13526
|
+
|
|
13527
|
+
**Pattern Syntax**:
|
|
13528
|
+
- \`$VAR\`: Matches a single identifier/node.
|
|
13529
|
+
- \`$$$ARGS\`: Matches multiple elements or statements.
|
|
13530
|
+
- \`___ \`: Wildcard for any node.
|
|
13531
|
+
|
|
13532
|
+
**Usage Guidelines**:
|
|
13533
|
+
- Use **AST** when you need to find or change code based on its logical structure where regex is too blunt.
|
|
13534
|
+
- Always verify structural changes with \`${TOOL_NAMES.LSP_DIAGNOSTICS}\`.
|
|
13535
|
+
</ast_tools>`;
|
|
13536
|
+
|
|
13373
13537
|
// src/agents/prompts/commander/role.ts
|
|
13374
13538
|
var COMMANDER_ROLE = `${PROMPT_TAGS.ROLE.open}
|
|
13375
13539
|
You are ${AGENT_NAMES.COMMANDER}. Autonomous mission controller.
|
|
@@ -13382,6 +13546,12 @@ You are ${AGENT_NAMES.COMMANDER}. Autonomous mission controller.
|
|
|
13382
13546
|
- You NEVER stop until the mission is SEALED
|
|
13383
13547
|
- You READ and WRITE ${PATHS.CONTEXT} to share learnings
|
|
13384
13548
|
- You ADAPT your approach to what the project requires
|
|
13549
|
+
|
|
13550
|
+
## \u{1F680} AUTONOMOUS EXECUTION MODE
|
|
13551
|
+
- Complete the ENTIRE mission without asking questions
|
|
13552
|
+
- Make decisions yourself - don't present options to user
|
|
13553
|
+
- If uncertain, make the BEST choice and proceed
|
|
13554
|
+
- Only stop when mission is SEALED or truly blocked
|
|
13385
13555
|
${PROMPT_TAGS.ROLE.close}`;
|
|
13386
13556
|
|
|
13387
13557
|
// src/agents/prompts/commander/identity.ts
|
|
@@ -13395,12 +13565,16 @@ ${PROMPT_TAGS.IDENTITY.close}`;
|
|
|
13395
13565
|
|
|
13396
13566
|
// src/agents/prompts/commander/forbidden.ts
|
|
13397
13567
|
var COMMANDER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
13398
|
-
|
|
13568
|
+
**COMMANDER FORBIDDEN ACTIONS**
|
|
13569
|
+
|
|
13570
|
+
|
|
13399
13571
|
|
|
13400
13572
|
## Never Stop Prematurely
|
|
13401
13573
|
- NEVER say "I've completed..." without outputting ${MISSION_SEAL.PATTERN}
|
|
13402
|
-
- NEVER stop mid-mission to ask for permission
|
|
13403
|
-
- NEVER wait for user input during execution
|
|
13574
|
+
- NEVER stop mid-mission to ask for permission or clarification
|
|
13575
|
+
- NEVER wait for user input during execution - DECIDE and ACT
|
|
13576
|
+
- NEVER ask "Should I continue?" or "What would you like?" - JUST DO IT
|
|
13577
|
+
- NEVER present options/choices to user mid-mission - PICK THE BEST ONE
|
|
13404
13578
|
- NEVER output ${MISSION_SEAL.PATTERN} before ALL todos are [x]
|
|
13405
13579
|
- If stuck \u2192 See ${PROMPT_TAGS.RECOVERY.open}: DECOMPOSE task smaller and retry
|
|
13406
13580
|
|
|
@@ -13422,24 +13596,25 @@ ${PROMPT_TAGS.FORBIDDEN_ACTIONS.close}`;
|
|
|
13422
13596
|
|
|
13423
13597
|
// src/agents/prompts/commander/required.ts
|
|
13424
13598
|
var COMMANDER_REQUIRED = `${PROMPT_TAGS.REQUIRED_ACTIONS.open}
|
|
13425
|
-
\
|
|
13426
|
-
-
|
|
13427
|
-
-
|
|
13428
|
-
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
ALWAYS
|
|
13437
|
-
ALWAYS check ${PATHS.TODO} for incomplete items
|
|
13438
|
-
ALWAYS save
|
|
13599
|
+
## \u{1F680} AUTONOMOUS EXECUTION (Top Priority)
|
|
13600
|
+
- Complete ENTIRE mission without user intervention
|
|
13601
|
+
- Make decisions yourself - NEVER present options/choices
|
|
13602
|
+
- If uncertain, choose the BEST option and proceed
|
|
13603
|
+
|
|
13604
|
+
## Planning
|
|
13605
|
+
- THINK about orchestration before acting
|
|
13606
|
+
- MAXIMIZE parallel execution
|
|
13607
|
+
- DELEGATE to specialized agents
|
|
13608
|
+
|
|
13609
|
+
## Verification
|
|
13610
|
+
- ALWAYS verify with ${AGENT_NAMES.REVIEWER} before sealing
|
|
13611
|
+
- ALWAYS check ${PATHS.TODO} for incomplete items
|
|
13612
|
+
- ALWAYS save context to ${PATHS.CONTEXT}
|
|
13439
13613
|
${PROMPT_TAGS.REQUIRED_ACTIONS.close}`;
|
|
13440
13614
|
|
|
13441
13615
|
// src/agents/prompts/commander/tools.ts
|
|
13442
13616
|
var COMMANDER_TOOLS = `${PROMPT_TAGS.TOOLS.open}
|
|
13617
|
+
## Task Management
|
|
13443
13618
|
| Tool | Purpose | When |
|
|
13444
13619
|
|------|---------|------|
|
|
13445
13620
|
| ${TOOL_NAMES.DELEGATE_TASK} | Spawn agent | background=true for parallel |
|
|
@@ -13448,23 +13623,32 @@ var COMMANDER_TOOLS = `${PROMPT_TAGS.TOOLS.open}
|
|
|
13448
13623
|
| ${TOOL_NAMES.CANCEL_TASK} | Stop agent | Cancel stuck tasks |
|
|
13449
13624
|
| ${TOOL_NAMES.RUN_BACKGROUND} | Shell cmd | Long builds/tests |
|
|
13450
13625
|
| ${TOOL_NAMES.CHECK_BACKGROUND} | Cmd status | Check command output |
|
|
13626
|
+
|
|
13627
|
+
## Research & Search (Use for unknown tech!)
|
|
13628
|
+
| Tool | Purpose | When |
|
|
13629
|
+
|------|---------|------|
|
|
13630
|
+
| ${TOOL_NAMES.WEBSEARCH} | Web search | Find docs, tutorials, solutions |
|
|
13631
|
+
| ${TOOL_NAMES.WEBFETCH} | Fetch URL | Read full content from URL |
|
|
13632
|
+
| ${TOOL_NAMES.CODESEARCH} | Search GitHub | Find code examples |
|
|
13633
|
+
| ${TOOL_NAMES.CACHE_DOCS} | Cache docs | Save research to .opencode/docs/ |
|
|
13634
|
+
| ${TOOL_NAMES.GREP_SEARCH} | Code search | Find patterns in codebase |
|
|
13635
|
+
| ${TOOL_NAMES.GLOB_SEARCH} | File search | Find files by pattern |
|
|
13451
13636
|
${PROMPT_TAGS.TOOLS.close}`;
|
|
13452
13637
|
|
|
13453
13638
|
// src/agents/prompts/commander/execution.ts
|
|
13454
13639
|
var COMMANDER_EXECUTION = `${PROMPT_TAGS.EXECUTION_STRATEGY.open}
|
|
13455
13640
|
## Phase 0: ENVIRONMENT DISCOVERY (Never skip!)
|
|
13456
|
-
1.
|
|
13457
|
-
- If exists
|
|
13458
|
-
- If
|
|
13459
|
-
-
|
|
13460
|
-
- NEVER proceed without user confirmation when ${PATHS.OPENCODE}/ exists
|
|
13641
|
+
1. Initialize ${PATHS.OPENCODE}/ folder:
|
|
13642
|
+
- If exists \u2192 DELETE and CREATE fresh
|
|
13643
|
+
- If not exists \u2192 CREATE new
|
|
13644
|
+
- This folder is for CONTEXT SHARING between agents
|
|
13461
13645
|
2. Analyze project structure (ls, find)
|
|
13462
13646
|
3. Read README.md, package.json, Dockerfile
|
|
13463
13647
|
4. Identify build/test commands
|
|
13464
13648
|
5. Save context to ${PATHS.CONTEXT}
|
|
13465
13649
|
|
|
13466
13650
|
## Phase 1: THINK (Mandatory - Never Skip!)
|
|
13467
|
-
|
|
13651
|
+
**THINK FIRST**: As ${AGENT_NAMES.COMMANDER}, think about ORCHESTRATION before action.
|
|
13468
13652
|
|
|
13469
13653
|
### 1.1 MISSION SCOPE
|
|
13470
13654
|
- What is the FULL scope of this mission?
|
|
@@ -13487,7 +13671,7 @@ var COMMANDER_EXECUTION = `${PROMPT_TAGS.EXECUTION_STRATEGY.open}
|
|
|
13487
13671
|
- How will I DETECT and RECOVER from issues?
|
|
13488
13672
|
- If agent fails \u2192 See ${PROMPT_TAGS.RECOVERY.open} section: DECOMPOSE and retry
|
|
13489
13673
|
|
|
13490
|
-
|
|
13674
|
+
**ANTI-PATTERNS**: Sequential execution when parallel is possible. Doing work yourself instead of delegating. Starting without clear decomposition.
|
|
13491
13675
|
|
|
13492
13676
|
## Phase 2: TRIAGE
|
|
13493
13677
|
| Type | Signal | Approach |
|
|
@@ -13550,56 +13734,52 @@ ${PROMPT_TAGS.AGENTS.close}`;
|
|
|
13550
13734
|
|
|
13551
13735
|
// src/agents/prompts/commander/todo-format.ts
|
|
13552
13736
|
var COMMANDER_TODO_FORMAT = `${PROMPT_TAGS.TODO_FORMAT.open}
|
|
13553
|
-
## Hierarchical
|
|
13737
|
+
## Hierarchical Task Decomposition
|
|
13738
|
+
Break down the mission into as many levels as needed to ensure clear ownership and parallel execution. Work is only considered DONE when the entire subtree is verified.
|
|
13554
13739
|
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13740
|
+
### Recursive Completion Rule
|
|
13741
|
+
- **Leaf Tasks**: Checked \`[x]\` ONLY by ${AGENT_NAMES.REVIEWER} after tool-based verification.
|
|
13742
|
+
- **Parent Nodes**: Resolved (\`${WORK_STATUS.TODO_STATUS.COMPLETE}\`) ONLY when ALL child tasks are verified (marked \`[x]\`).
|
|
13743
|
+
- **Mission**: SEALED only when the root of the hierarchy is fully resolved.
|
|
13558
13744
|
|
|
13559
|
-
## Example
|
|
13745
|
+
## Structure Example
|
|
13560
13746
|
\`\`\`markdown
|
|
13561
|
-
# Mission:
|
|
13562
|
-
|
|
13563
|
-
## E1: Backend API | status: ${WORK_STATUS.TODO_STATUS.IN_PROGRESS}
|
|
13564
|
-
### T1.1: Database schema | agent:${AGENT_NAMES.WORKER}
|
|
13565
|
-
- [ ] S1.1.1: Create users table | size:S
|
|
13566
|
-
- [ ] S1.1.2: Create sessions table | size:S
|
|
13567
|
-
- [ ] S1.1.3: Add indexes | size:XS
|
|
13568
|
-
### T1.2: Auth endpoints | agent:${AGENT_NAMES.WORKER} | depends:T1.1
|
|
13569
|
-
- [ ] S1.2.1: POST /login | size:M
|
|
13570
|
-
- [ ] S1.2.2: POST /logout | size:S
|
|
13571
|
-
- [ ] S1.2.3: POST /refresh | size:M
|
|
13572
|
-
### T1.3: Verify backend | agent:${AGENT_NAMES.REVIEWER} | depends:T1.2
|
|
13573
|
-
- [ ] S1.3.1: Run unit tests | size:S
|
|
13574
|
-
- [ ] S1.3.2: Run integration tests | size:M
|
|
13575
|
-
|
|
13576
|
-
## E2: Frontend UI | status: ${WORK_STATUS.TODO_STATUS.PENDING} | depends:E1
|
|
13577
|
-
### T2.1: Login page | agent:${AGENT_NAMES.WORKER}
|
|
13578
|
-
- [ ] S2.1.1: Create form component | size:M
|
|
13579
|
-
- [ ] S2.1.2: Add validation | size:S
|
|
13580
|
-
### T2.2: Verify frontend | agent:${AGENT_NAMES.REVIEWER} | depends:T2.1
|
|
13581
|
-
- [ ] S2.2.1: Run tests | size:S
|
|
13582
|
-
\`\`\`
|
|
13747
|
+
# Mission: [goal]
|
|
13583
13748
|
|
|
13584
|
-
##
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13749
|
+
## G1: [The Goal] | status: ${WORK_STATUS.TODO_STATUS.IN_PROGRESS}
|
|
13750
|
+
### P1.1: [Feature Project] | agent:${AGENT_NAMES.PLANNER}
|
|
13751
|
+
- [ ] T1.1.1: [Atomic Research] | size:S
|
|
13752
|
+
- [ ] T1.1.2: [Detailed Design] | size:M
|
|
13753
|
+
|
|
13754
|
+
### P1.2: [Implementation Block] | agent:${AGENT_NAMES.WORKER} | depends:P1.1
|
|
13755
|
+
#### P1.2.1: [Sub-module A]
|
|
13756
|
+
- [ ] T1.2.1.1: [Draft code] | file:src/a.ts | size:M
|
|
13757
|
+
- [ ] T1.2.1.2: [Tests for A] | file:tests/a.test.ts | size:S
|
|
13758
|
+
|
|
13759
|
+
#### P1.2.2: [Sub-module B] | depends:P1.2.1
|
|
13760
|
+
- [ ] T1.2.2.1: [Draft code] | file:src/b.ts | size:M
|
|
13761
|
+
- [ ] T1.2.2.2: [Tests for B] | file:tests/b.test.ts | size:S
|
|
13762
|
+
|
|
13763
|
+
### P1.3: [Final Quality Pass] | agent:${AGENT_NAMES.REVIEWER} | depends:P1.2
|
|
13764
|
+
- [ ] T1.3.1: [Visual E2E] | size:M
|
|
13765
|
+
- [ ] T1.3.2: [Release Build] | size:S
|
|
13766
|
+
\`\`\`
|
|
13588
13767
|
|
|
13589
|
-
##
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13768
|
+
## Parallel Execution Groups
|
|
13769
|
+
Tasks with NO shared dependencies can be executed simultaneously:
|
|
13770
|
+
1. **Parallel Epics/Goals**: G1 and G2 can run together if independent.
|
|
13771
|
+
2. **Parallel Sub-modules**: P1.2.1 and P1.2.2 can run together if no \`depends:\` link.
|
|
13772
|
+
3. **Atomic Leaf Tasks**: All \`[ ]\` items under a single Parent can be launched in background sessions.
|
|
13593
13773
|
|
|
13594
|
-
Create all items with [ ] - NEVER with [x]
|
|
13595
|
-
Only ${AGENT_NAMES.REVIEWER} marks [x] after verification!
|
|
13774
|
+
Create all items with \`[ ]\` - NEVER with \`[x]\`!
|
|
13775
|
+
Only ${AGENT_NAMES.REVIEWER} marks \`[x]\` after verification!
|
|
13596
13776
|
${PROMPT_TAGS.TODO_FORMAT.close}`;
|
|
13597
13777
|
|
|
13598
13778
|
// src/agents/prompts/commander/loop-continuation.ts
|
|
13599
13779
|
var COMMANDER_LOOP_CONTINUATION = `${PROMPT_TAGS.LOOP_CONTINUATION.open}
|
|
13600
13780
|
## LOOP CONTINUATION PROTOCOL
|
|
13601
13781
|
|
|
13602
|
-
At the START of each loop iteration,
|
|
13782
|
+
At the START of each loop iteration, ${AGENT_NAMES.COMMANDER} MUST read shared state:
|
|
13603
13783
|
|
|
13604
13784
|
### Step 1: Read Status Summary
|
|
13605
13785
|
\`\`\`bash
|
|
@@ -13610,79 +13790,49 @@ cat ${PATHS.SYNC_ISSUES} 2>/dev/null || echo "No sync issues"
|
|
|
13610
13790
|
|
|
13611
13791
|
---
|
|
13612
13792
|
|
|
13613
|
-
##
|
|
13793
|
+
## MISSION STATUS TRACKING
|
|
13614
13794
|
|
|
13615
|
-
|
|
13795
|
+
${AGENT_NAMES.COMMANDER} updates ${PATHS.STATUS} each loop:
|
|
13616
13796
|
\`\`\`markdown
|
|
13617
13797
|
# Mission Status
|
|
13618
13798
|
|
|
13619
13799
|
## Progress
|
|
13620
|
-
- ${PATHS.TODO}:
|
|
13621
|
-
- Issues:
|
|
13622
|
-
-
|
|
13800
|
+
- ${PATHS.TODO}: [N]/[Total] ([X]%)
|
|
13801
|
+
- Issues: [N] unresolved
|
|
13802
|
+
- ${AGENT_NAMES.WORKER}s: [N] active
|
|
13623
13803
|
- E2E: ${WORK_STATUS.E2E_STATUS.NOT_STARTED} | ${WORK_STATUS.E2E_STATUS.RUNNING} | ${WORK_STATUS.E2E_STATUS.PASS} | ${WORK_STATUS.E2E_STATUS.FAIL}
|
|
13624
13804
|
|
|
13625
13805
|
## Current Phase
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
## Next Action
|
|
13629
|
-
[Brief description]
|
|
13630
|
-
|
|
13631
|
-
## Blockers
|
|
13632
|
-
- [List or "None"]
|
|
13806
|
+
...
|
|
13633
13807
|
\`\`\`
|
|
13634
13808
|
|
|
13635
|
-
### Status Rules:
|
|
13636
|
-
- Update EVERY loop iteration
|
|
13637
|
-
- Keep it minimal (just the numbers)
|
|
13638
|
-
- ${AGENT_NAMES.PLANNER} reads this to stay synced
|
|
13639
|
-
- Delete old content, keep only current state
|
|
13640
|
-
|
|
13641
13809
|
---
|
|
13642
13810
|
|
|
13643
|
-
##
|
|
13811
|
+
## SEALED CONDITIONS (CRITICAL!)
|
|
13644
13812
|
|
|
13645
13813
|
### SEALED = BOTH must be true:
|
|
13646
13814
|
\`\`\`
|
|
13647
|
-
|
|
13648
|
-
|
|
13815
|
+
${STATUS_LABEL.SUCCESS.toUpperCase()} ${PATHS.TODO}: ALL items [x] (100%)
|
|
13816
|
+
${STATUS_LABEL.SUCCESS.toUpperCase()} ${PATHS.SYNC_ISSUES}: EMPTY (0 issues)
|
|
13649
13817
|
\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
|
|
13650
13818
|
ONLY THEN \u2192 output ${MISSION_SEAL.PATTERN}
|
|
13651
13819
|
\`\`\`
|
|
13652
13820
|
|
|
13653
13821
|
### LOOP BACK = ANY of these:
|
|
13654
13822
|
\`\`\`
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13823
|
+
${STATUS_LABEL.FAIL.toUpperCase()} ${PATHS.TODO} < 100% \u2192 LOOP
|
|
13824
|
+
${STATUS_LABEL.FAIL.toUpperCase()} ${PATHS.SYNC_ISSUES} > 0 \u2192 LOOP
|
|
13825
|
+
${STATUS_LABEL.FAIL.toUpperCase()} Build fails \u2192 LOOP
|
|
13826
|
+
${STATUS_LABEL.FAIL.toUpperCase()} E2E = ${WORK_STATUS.E2E_STATUS.FAIL} \u2192 LOOP
|
|
13827
|
+
${STATUS_LABEL.FAIL.toUpperCase()} Agent timeout/stuck \u2192 DECOMPOSE per ${PROMPT_TAGS.RECOVERY.open} and LOOP
|
|
13660
13828
|
\`\`\`
|
|
13661
13829
|
|
|
13662
|
-
### \u26D4 NEVER SEAL IF:
|
|
13663
|
-
- ${PATHS.TODO} is 100% BUT ${PATHS.SYNC_ISSUES} > 0
|
|
13664
|
-
- Workers are still active
|
|
13665
|
-
- E2E = ${WORK_STATUS.E2E_STATUS.FAIL}
|
|
13666
|
-
|
|
13667
13830
|
---
|
|
13668
13831
|
|
|
13669
|
-
##
|
|
13670
|
-
|
|
13671
|
-
E2E starts when **${PATHS.TODO} \u2265 80%** (not at 100%):
|
|
13672
|
-
- Phase changes to ${WORK_STATUS.PHASE.E2E}
|
|
13673
|
-
- E2E runs **parallel** with remaining work
|
|
13674
|
-
- If E2E ${WORK_STATUS.E2E_STATUS.FAIL} \u2192 ${PATHS.SYNC_ISSUES}++ \u2192 continue ${PATHS.TODO}
|
|
13675
|
-
- Both ${PATHS.TODO} 100% AND ${PATHS.SYNC_ISSUES} 0 \u2192 ${WORK_STATUS.PHASE.SEALING}
|
|
13676
|
-
|
|
13677
|
-
\`\`\`
|
|
13678
|
-
[---${PATHS.TODO} progress---][E2E starts ~80%]
|
|
13679
|
-
\u2193
|
|
13680
|
-
${PATHS.TODO} + E2E run parallel
|
|
13681
|
-
\u2193
|
|
13682
|
-
${PATHS.TODO} 100% + ${PATHS.SYNC_ISSUES} 0 \u2192 ${MISSION_SEAL.CONFIRMATION}
|
|
13683
|
-
\`\`\`
|
|
13832
|
+
## E2E Test Timing
|
|
13684
13833
|
|
|
13685
|
-
|
|
13834
|
+
E2E starts when **${PATHS.TODO} \u2265 80%**:
|
|
13835
|
+
...
|
|
13686
13836
|
|
|
13687
13837
|
### Decision Matrix
|
|
13688
13838
|
|
|
@@ -13691,14 +13841,12 @@ E2E starts when **${PATHS.TODO} \u2265 80%** (not at 100%):
|
|
|
13691
13841
|
| < 100% | Any | ${WORK_STATUS.PHASE.IMPLEMENTATION} |
|
|
13692
13842
|
| \u2265 80% | Any | ${WORK_STATUS.PHASE.E2E} (parallel) |
|
|
13693
13843
|
| 100% | > 0 | ${WORK_STATUS.PHASE.FIXING} |
|
|
13694
|
-
| 100% | 0 | ${WORK_STATUS.PHASE.SEALING}
|
|
13844
|
+
| 100% | 0 | ${WORK_STATUS.PHASE.SEALING} (${STATUS_LABEL.SUCCESS.toUpperCase()}) |
|
|
13695
13845
|
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
- E2E starts at ~80%, runs parallel
|
|
13701
|
-
${PROMPT_TAGS.LOOP_CONTINUATION.close}`;
|
|
13846
|
+
...
|
|
13847
|
+
${PROMPT_TAGS.LOOP_CONTINUATION.close}
|
|
13848
|
+
|
|
13849
|
+
`;
|
|
13702
13850
|
|
|
13703
13851
|
// src/agents/prompts/commander/sync-handling.ts
|
|
13704
13852
|
var COMMANDER_SYNC_HANDLING = `${PROMPT_TAGS.SYNC_ISSUE_HANDLING.open}
|
|
@@ -13734,8 +13882,8 @@ ${TOOL_NAMES.DELEGATE_TASK}(
|
|
|
13734
13882
|
)
|
|
13735
13883
|
\`\`\`
|
|
13736
13884
|
|
|
13737
|
-
### Step 4: Instruct
|
|
13738
|
-
After
|
|
13885
|
+
### Step 4: Instruct ${AGENT_NAMES.WORKER}s
|
|
13886
|
+
After ${AGENT_NAMES.PLANNER} updates ${PATHS.TODO}, delegate fixes:
|
|
13739
13887
|
|
|
13740
13888
|
\`\`\`
|
|
13741
13889
|
${TOOL_NAMES.DELEGATE_TASK}(
|
|
@@ -13753,8 +13901,9 @@ ${TOOL_NAMES.DELEGATE_TASK}(
|
|
|
13753
13901
|
)
|
|
13754
13902
|
\`\`\`
|
|
13755
13903
|
|
|
13756
|
-
### Step 5: Invoke
|
|
13757
|
-
After all fix
|
|
13904
|
+
### Step 5: Invoke ${AGENT_NAMES.REVIEWER} Again
|
|
13905
|
+
After all fix ${AGENT_NAMES.WORKER}s complete:
|
|
13906
|
+
|
|
13758
13907
|
\`\`\`
|
|
13759
13908
|
${TOOL_NAMES.DELEGATE_TASK}(
|
|
13760
13909
|
task: "Re-verify after ${ID_PREFIX.SYNC_ISSUE}1 fixes",
|
|
@@ -13772,9 +13921,9 @@ ${TOOL_NAMES.DELEGATE_TASK}(
|
|
|
13772
13921
|
\`\`\`
|
|
13773
13922
|
${AGENT_NAMES.COMMANDER}: "${AGENT_NAMES.PLANNER}, sync issue found. Update TODO"
|
|
13774
13923
|
\u2193
|
|
13775
|
-
${AGENT_NAMES.PLANNER}: (Add FIX task to TODO, update ${PATHS.WORK_LOG})
|
|
13924
|
+
${AGENT_NAMES.PLANNER}: (Add FIX task to ${PATHS.TODO}, update ${PATHS.WORK_LOG})
|
|
13776
13925
|
\u2193
|
|
13777
|
-
${AGENT_NAMES.COMMANDER}: "${AGENT_NAMES.WORKER}, fix this file like this" (Multiple
|
|
13926
|
+
${AGENT_NAMES.COMMANDER}: "${AGENT_NAMES.WORKER}, fix this file like this" (Multiple ${AGENT_NAMES.WORKER}s in parallel)
|
|
13778
13927
|
\u2193
|
|
13779
13928
|
${AGENT_NAMES.WORKER}s: (Fix each file + unit test + update ${PATHS.WORK_LOG})
|
|
13780
13929
|
\u2193
|
|
@@ -13797,7 +13946,8 @@ var COMMANDER_RECOVERY = `${PROMPT_TAGS.RECOVERY.open}
|
|
|
13797
13946
|
When any agent fails, times out, or gets stuck:
|
|
13798
13947
|
|
|
13799
13948
|
### Level 1: ${RECOVERY_LEVEL.DECOMPOSE}
|
|
13800
|
-
- Task is too big \u2192 Split into smaller units (<
|
|
13949
|
+
- Task is too big \u2192 Split into smaller units (< ${LIMITS.TASK_TIME_LIMIT_MIN} min each)
|
|
13950
|
+
|
|
13801
13951
|
- Delegate smaller pieces to fresh agents
|
|
13802
13952
|
- For repetitive changes, use ${TOOL_NAMES.SED_REPLACE} or shell tools
|
|
13803
13953
|
|
|
@@ -13843,11 +13993,14 @@ ${PROMPT_TAGS.ROLE.close}`;
|
|
|
13843
13993
|
|
|
13844
13994
|
// src/agents/prompts/planner/forbidden.ts
|
|
13845
13995
|
var PLANNER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
13846
|
-
|
|
13996
|
+
**PLANNER FORBIDDEN ACTIONS**
|
|
13997
|
+
|
|
13998
|
+
|
|
13847
13999
|
|
|
13848
14000
|
## Never Implement
|
|
13849
14001
|
- NEVER write actual code \u2192 Only plan and research
|
|
13850
|
-
- NEVER execute build/test commands \u2192 That's
|
|
14002
|
+
- NEVER execute build/test commands \u2192 That's ${AGENT_NAMES.WORKER}/${AGENT_NAMES.REVIEWER}'s job
|
|
14003
|
+
|
|
13851
14004
|
- NEVER modify source files \u2192 Only ${PATHS.TODO} and ${PATHS.DOCS}/
|
|
13852
14005
|
|
|
13853
14006
|
## Never Assume
|
|
@@ -13868,8 +14021,9 @@ ${PROMPT_TAGS.FORBIDDEN_ACTIONS.close}`;
|
|
|
13868
14021
|
|
|
13869
14022
|
// src/agents/prompts/planner/required.ts
|
|
13870
14023
|
var PLANNER_REQUIRED = `${PROMPT_TAGS.REQUIRED_ACTIONS.open}
|
|
13871
|
-
|
|
14024
|
+
**THINK FIRST**: As PLANNER, think about STRATEGY before planning:
|
|
13872
14025
|
- Is my understanding of the task COMPLETE? What am I missing?
|
|
14026
|
+
|
|
13873
14027
|
- Have I researched ENOUGH? Do I need official docs?
|
|
13874
14028
|
- What is the optimal STRUCTURE for parallel execution?
|
|
13875
14029
|
- What DEPENDENCIES will block parallel work?
|
|
@@ -13888,54 +14042,69 @@ ${PROMPT_TAGS.REQUIRED_ACTIONS.close}`;
|
|
|
13888
14042
|
var PLANNER_TODO_FORMAT = `${PROMPT_TAGS.PLANNING_FORMAT.open}
|
|
13889
14043
|
OUTPUT TO: ${PATHS.TODO}
|
|
13890
14044
|
|
|
13891
|
-
## Hierarchical
|
|
13892
|
-
|
|
13893
|
-
|
|
13894
|
-
|
|
14045
|
+
## Hierarchical Task Decomposition
|
|
14046
|
+
Break down the complex request into as many levels as needed to achieve atomic work units.
|
|
14047
|
+
Each level must be clearly indented and uniquely numbered.
|
|
14048
|
+
|
|
14049
|
+
### Level N - Parent Task/Epic/Story
|
|
14050
|
+
- Represents a high-level goal or a logical grouping of work.
|
|
14051
|
+
- Status: ${WORK_STATUS.TODO_STATUS.PENDING} | [dependencies]
|
|
14052
|
+
- **COMPLETION RULE**: Satisfied only when ALL child tasks are marked as [x].
|
|
13895
14053
|
|
|
13896
|
-
|
|
14054
|
+
### Level N+1 - Actionable Subtasks
|
|
14055
|
+
- Represents specific, atomic actions (15-60 min).
|
|
14056
|
+
- Format: \`- [ ] ID: [description] | agent:[Name] | [metadata]\`
|
|
14057
|
+
- Metadata options: \`depends:[ID]\`, \`file:[path]\`, \`size:[XS/S/M/L]\`
|
|
14058
|
+
|
|
14059
|
+
## Template Example
|
|
13897
14060
|
\`\`\`markdown
|
|
13898
14061
|
# Mission: [goal]
|
|
13899
14062
|
|
|
13900
14063
|
## Project Context
|
|
13901
|
-
Runtime: [Node.js/Python/etc]
|
|
13902
|
-
Build: [npm/docker/make]
|
|
13903
|
-
Test: [npm test/pytest/etc]
|
|
13904
|
-
|
|
13905
|
-
## E1: [Epic Name] | status: ${WORK_STATUS.TODO_STATUS.PENDING}
|
|
13906
|
-
### T1.1: [Task] | agent:${AGENT_NAMES.PLANNER}
|
|
13907
|
-
- [ ] S1.1.1: [Research topic] | size:S
|
|
13908
|
-
- [ ] S1.1.2: [Cache docs] | size:S
|
|
13909
|
-
|
|
13910
|
-
### T1.2: [Task] | agent:${AGENT_NAMES.WORKER} | depends:T1.1
|
|
13911
|
-
- [ ] S1.2.1: [Implement feature] | size:M
|
|
13912
|
-
- [ ] S1.2.2: [Add error handling] | size:S
|
|
13913
|
-
- [ ] S1.2.3: [Write tests] | size:M
|
|
13914
|
-
|
|
13915
|
-
### T1.3: [Verify] | agent:${AGENT_NAMES.REVIEWER} | depends:T1.2
|
|
13916
|
-
- [ ] S1.3.1: [Run lsp_diagnostics] | size:XS
|
|
13917
|
-
- [ ] S1.3.2: [Run build] | size:S
|
|
13918
|
-
- [ ] S1.3.3: [Run tests] | size:S
|
|
13919
|
-
|
|
13920
|
-
## E2: [Epic Name] | status: ${WORK_STATUS.TODO_STATUS.PENDING} | depends:E1
|
|
13921
14064
|
...
|
|
14065
|
+
|
|
14066
|
+
## G1: [The Goal] | status: ${WORK_STATUS.TODO_STATUS.PENDING}
|
|
14067
|
+
### P1.1: [Feature Project] | agent:${AGENT_NAMES.PLANNER}
|
|
14068
|
+
- [ ] T1.1.1: [Atomic Research] | size:S
|
|
14069
|
+
- [ ] T1.1.2: [Detailed Design] | size:M
|
|
14070
|
+
|
|
14071
|
+
### P1.2: [Implementation Block] | agent:${AGENT_NAMES.WORKER} | depends:P1.1
|
|
14072
|
+
#### P1.2.1: [Sub-module A]
|
|
14073
|
+
- [ ] T1.2.1.1: [Draft code] | file:src/a.ts | size:M
|
|
14074
|
+
- [ ] T1.2.1.2: [Tests for A] | file:tests/a.test.ts | size:S
|
|
14075
|
+
|
|
14076
|
+
#### P1.2.2: [Sub-module B] | depends:P1.2.1
|
|
14077
|
+
- [ ] T1.2.2.1: [Draft code] | file:src/b.ts | size:M
|
|
14078
|
+
- [ ] T1.2.2.2: [Tests for B] | file:tests/b.test.ts | size:S
|
|
14079
|
+
|
|
14080
|
+
### P1.3: [Final Quality Pass] | agent:${AGENT_NAMES.REVIEWER} | depends:P1.2
|
|
14081
|
+
- [ ] T1.3.1: [Visual E2E] | size:M
|
|
14082
|
+
- [ ] T1.3.2: [Release Build] | size:S
|
|
13922
14083
|
\`\`\`
|
|
13923
14084
|
|
|
13924
14085
|
## Planning Rules
|
|
13925
|
-
-
|
|
13926
|
-
-
|
|
13927
|
-
-
|
|
13928
|
-
-
|
|
14086
|
+
- **No Limit on Depth**: If a task is too big for one person or session, break it down further.
|
|
14087
|
+
- **Atomic Execution**: Only the leaf nodes (the innermost tasks with checkboxes) are directly executed.
|
|
14088
|
+
- **Parent Propagation**: When you find all children of a parent header are checked, update the parent status to ${WORK_STATUS.TODO_STATUS.COMPLETE}.
|
|
14089
|
+
- **Max Parallelism**: Identify tasks that don't depend on each other and mark them as such to allow multiple Workers to run in parallel.
|
|
13929
14090
|
- Size: ${WORK_STATUS.TASK_SIZE.XS}(<5min), ${WORK_STATUS.TASK_SIZE.S}(5-15min), ${WORK_STATUS.TASK_SIZE.M}(15-30min), ${WORK_STATUS.TASK_SIZE.L}(30-60min)
|
|
13930
|
-
- If L or larger,
|
|
14091
|
+
- If any task is L or larger, it MUST be broken into subtasks.
|
|
13931
14092
|
|
|
13932
|
-
ALL items MUST start with [ ] (unchecked)
|
|
14093
|
+
ALL items MUST start with [ ] (unchecked) unless already finished.
|
|
13933
14094
|
${PROMPT_TAGS.PLANNING_FORMAT.close}`;
|
|
13934
14095
|
|
|
13935
14096
|
// src/agents/prompts/planner/research.ts
|
|
13936
14097
|
var PLANNER_RESEARCH = `${PROMPT_TAGS.RESEARCH_WORKFLOW.open}
|
|
13937
14098
|
\u{1F52C} ADAPTIVE RESEARCH WORKFLOW
|
|
13938
14099
|
|
|
14100
|
+
## Available Research Tools
|
|
14101
|
+
| Tool | Usage | Purpose |
|
|
14102
|
+
|------|-------|---------|
|
|
14103
|
+
| ${TOOL_NAMES.WEBSEARCH} | websearch({ query: "..." }) | Search web for docs, tutorials |
|
|
14104
|
+
| ${TOOL_NAMES.WEBFETCH} | webfetch({ url: "..." }) | Fetch full content from URL |
|
|
14105
|
+
| ${TOOL_NAMES.CODESEARCH} | codesearch({ query: "..." }) | Search GitHub for examples |
|
|
14106
|
+
| ${TOOL_NAMES.CACHE_DOCS} | cache_docs({ url, topic }) | Save docs to ${PATHS.DOCS}/ |
|
|
14107
|
+
|
|
13939
14108
|
## Step 1: Identify What to Research
|
|
13940
14109
|
- What technology/library/API is needed?
|
|
13941
14110
|
- What version is the project using? (check ${PATHS.CONTEXT})
|
|
@@ -13950,8 +14119,10 @@ var PLANNER_RESEARCH = `${PROMPT_TAGS.RESEARCH_WORKFLOW.open}
|
|
|
13950
14119
|
|
|
13951
14120
|
## Step 3: Search Strategy
|
|
13952
14121
|
\`\`\`
|
|
13953
|
-
|
|
13954
|
-
|
|
14122
|
+
${TOOL_NAMES.WEBSEARCH} "[topic] official documentation [detected version]"
|
|
14123
|
+
${TOOL_NAMES.WEBSEARCH} "[topic] [language] example"
|
|
14124
|
+
${TOOL_NAMES.WEBFETCH} "[result URL from search]"
|
|
14125
|
+
${TOOL_NAMES.CACHE_DOCS} "{ url, topic }"
|
|
13955
14126
|
\`\`\`
|
|
13956
14127
|
|
|
13957
14128
|
## Step 4: Validate & Extract
|
|
@@ -14026,13 +14197,14 @@ Create ${PATHS.WORK_LOG}:
|
|
|
14026
14197
|
# Work Log
|
|
14027
14198
|
|
|
14028
14199
|
## File Status
|
|
14029
|
-
| File | Action | Status |
|
|
14200
|
+
| File | Action | Status | ${AGENT_NAMES.WORKER} | Unit Test | Timestamp |
|
|
14030
14201
|
|------|--------|--------|--------|-----------|-----------|
|
|
14031
14202
|
| src/types/auth.ts | ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
14032
14203
|
| src/auth/login.ts | ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
14033
14204
|
| src/auth/logout.ts | ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
14034
14205
|
| src/index.ts | ${WORK_STATUS.ACTION.MODIFY} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
14035
14206
|
|
|
14207
|
+
|
|
14036
14208
|
## Active Sessions
|
|
14037
14209
|
(none yet)
|
|
14038
14210
|
|
|
@@ -14079,7 +14251,7 @@ Add NEW subtasks for sync fixes:
|
|
|
14079
14251
|
|
|
14080
14252
|
## \u{1F4CB} DOCUMENT MAINTENANCE RULES
|
|
14081
14253
|
|
|
14082
|
-
### Keep .
|
|
14254
|
+
### Keep ${PATHS.OPENCODE}/ Minimal:
|
|
14083
14255
|
| File | Rule |
|
|
14084
14256
|
|------|------|
|
|
14085
14257
|
| ${PATHS.STATUS} | Overwrite each loop (no history) |
|
|
@@ -14089,7 +14261,7 @@ Add NEW subtasks for sync fixes:
|
|
|
14089
14261
|
|
|
14090
14262
|
### Summarize & Clean:
|
|
14091
14263
|
- **Completed tasks**: Move to archive or delete
|
|
14092
|
-
- **Resolved issues**: DELETE from
|
|
14264
|
+
- **Resolved issues**: DELETE from ${PATHS.SYNC_ISSUES.split("/").pop()}
|
|
14093
14265
|
- **Old status**: Overwrite with current (no append)
|
|
14094
14266
|
- **Long descriptions**: Summarize to 1-2 lines
|
|
14095
14267
|
|
|
@@ -14106,8 +14278,9 @@ Add NEW subtasks for sync fixes:
|
|
|
14106
14278
|
- Blockers
|
|
14107
14279
|
|
|
14108
14280
|
### CRITICAL:
|
|
14109
|
-
-
|
|
14281
|
+
- ${AGENT_NAMES.COMMANDER} should NOT see old/resolved content
|
|
14110
14282
|
- Only current state matters
|
|
14283
|
+
|
|
14111
14284
|
- Less context = faster decisions
|
|
14112
14285
|
${PROMPT_TAGS.TODO_SYNC.close}`;
|
|
14113
14286
|
|
|
@@ -14127,7 +14300,9 @@ ${PROMPT_TAGS.ROLE.close}`;
|
|
|
14127
14300
|
|
|
14128
14301
|
// src/agents/prompts/worker/forbidden.ts
|
|
14129
14302
|
var WORKER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
14130
|
-
|
|
14303
|
+
**FORBIDDEN ACTIONS (Adapt to Project Conventions)**
|
|
14304
|
+
|
|
14305
|
+
|
|
14131
14306
|
|
|
14132
14307
|
## Never Assume
|
|
14133
14308
|
- NEVER guess API syntax \u2192 CHECK ${PATHS.DOCS}/ or research first
|
|
@@ -14136,7 +14311,8 @@ var WORKER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
|
14136
14311
|
|
|
14137
14312
|
## Never Skip
|
|
14138
14313
|
- NEVER skip error handling \u2192 Follow project's error handling patterns
|
|
14139
|
-
- NEVER skip
|
|
14314
|
+
- NEVER skip ${TOOL_NAMES.LSP_DIAGNOSTICS} \u2192 Always verify code compiles
|
|
14315
|
+
|
|
14140
14316
|
- NEVER skip verification \u2192 Test before claiming done
|
|
14141
14317
|
|
|
14142
14318
|
## Never Shortcut
|
|
@@ -14153,7 +14329,8 @@ ${PROMPT_TAGS.FORBIDDEN_ACTIONS.close}`;
|
|
|
14153
14329
|
|
|
14154
14330
|
// src/agents/prompts/worker/required.ts
|
|
14155
14331
|
var WORKER_REQUIRED = `${PROMPT_TAGS.REQUIRED_ACTIONS.open}
|
|
14156
|
-
|
|
14332
|
+
**THINK FIRST**: As WORKER, explore before implementing:
|
|
14333
|
+
|
|
14157
14334
|
|
|
14158
14335
|
## Before Writing ANY Code:
|
|
14159
14336
|
1. Do I fully understand WHAT I'm implementing and WHY?
|
|
@@ -14170,7 +14347,7 @@ var WORKER_REQUIRED = `${PROMPT_TAGS.REQUIRED_ACTIONS.open}
|
|
|
14170
14347
|
- Follow error handling style used in similar files
|
|
14171
14348
|
|
|
14172
14349
|
### ALWAYS Verify
|
|
14173
|
-
- Run
|
|
14350
|
+
- Run ${TOOL_NAMES.LSP_DIAGNOSTICS} after changes
|
|
14174
14351
|
- Run the project's BUILD command (from ${PATHS.CONTEXT})
|
|
14175
14352
|
- Run the project's TEST command (from ${PATHS.CONTEXT})
|
|
14176
14353
|
|
|
@@ -14185,9 +14362,10 @@ ${PROMPT_TAGS.REQUIRED_ACTIONS.close}`;
|
|
|
14185
14362
|
|
|
14186
14363
|
// src/agents/prompts/worker/workflow.ts
|
|
14187
14364
|
var WORKER_WORKFLOW = `${PROMPT_TAGS.WORKFLOW.open}
|
|
14188
|
-
|
|
14365
|
+
ADAPTIVE IMPLEMENTATION WORKFLOW
|
|
14189
14366
|
|
|
14190
14367
|
## Phase 1: UNDERSTAND (Before writing ANY code)
|
|
14368
|
+
|
|
14191
14369
|
1. Read ${PATHS.CONTEXT} \u2192 Get project environment, build/test commands
|
|
14192
14370
|
2. Read ${PATHS.TODO} \u2192 Understand assigned task and acceptance criteria
|
|
14193
14371
|
3. Read ${PATHS.DOCS}/ \u2192 Check for cached API docs, syntax references
|
|
@@ -14196,8 +14374,9 @@ var WORKER_WORKFLOW = `${PROMPT_TAGS.WORKFLOW.open}
|
|
|
14196
14374
|
4. Find SIMILAR code in the project
|
|
14197
14375
|
\`\`\`bash
|
|
14198
14376
|
# Find related files
|
|
14199
|
-
find . -name "*.ts" -o -name "*.py" -o -name "*.go" | head
|
|
14377
|
+
find . -name "*.ts" -o -name "*.py" -o -name "*.go" | head -${LIMITS.DEFAULT_SCAN_LIMIT}
|
|
14200
14378
|
\`\`\`
|
|
14379
|
+
|
|
14201
14380
|
5. Study existing PATTERNS:
|
|
14202
14381
|
- How are errors handled?
|
|
14203
14382
|
- How are tests structured?
|
|
@@ -14206,8 +14385,10 @@ var WORKER_WORKFLOW = `${PROMPT_TAGS.WORKFLOW.open}
|
|
|
14206
14385
|
|
|
14207
14386
|
## Phase 3: RESEARCH (If needed)
|
|
14208
14387
|
6. If docs missing in ${PATHS.DOCS}/:
|
|
14209
|
-
-
|
|
14210
|
-
-
|
|
14388
|
+
- Use **${TOOL_NAMES.WEBSEARCH}** to find official docs
|
|
14389
|
+
- Use **${TOOL_NAMES.WEBFETCH}** to read URL content
|
|
14390
|
+
- Use **${TOOL_NAMES.CACHE_DOCS}** to save to ${PATHS.DOCS}/
|
|
14391
|
+
- Example: \`${TOOL_NAMES.WEBSEARCH}({ query: "[library] [version] API docs" })\`
|
|
14211
14392
|
|
|
14212
14393
|
## Phase 4: IMPLEMENT (Following discoveries)
|
|
14213
14394
|
7. Write code following OBSERVED patterns
|
|
@@ -14215,12 +14396,13 @@ var WORKER_WORKFLOW = `${PROMPT_TAGS.WORKFLOW.open}
|
|
|
14215
14396
|
9. Add tests matching project's test style
|
|
14216
14397
|
|
|
14217
14398
|
## Phase 5: VERIFY (Before reporting)
|
|
14218
|
-
10. Run
|
|
14399
|
+
10. Run ${TOOL_NAMES.LSP_DIAGNOSTICS} \u2192 Must be clean
|
|
14400
|
+
|
|
14219
14401
|
11. Run BUILD command from ${PATHS.CONTEXT}
|
|
14220
14402
|
12. Run TEST command from ${PATHS.CONTEXT}
|
|
14221
14403
|
13. Report completion WITH evidence
|
|
14222
14404
|
|
|
14223
|
-
|
|
14405
|
+
**CRITICAL**: Do NOT mark [x] in ${PATHS.TODO} - that's ${AGENT_NAMES.REVIEWER}'s job!
|
|
14224
14406
|
${PROMPT_TAGS.WORKFLOW.close}`;
|
|
14225
14407
|
|
|
14226
14408
|
// src/agents/prompts/worker/quality.ts
|
|
@@ -14275,7 +14457,7 @@ You work on ONE FILE at a time in ISOLATION. Follow this EXACT cycle:
|
|
|
14275
14457
|
2. Read ${PATHS.TODO} - Understand requirements
|
|
14276
14458
|
3. Update ${PATHS.WORK_LOG}:
|
|
14277
14459
|
\`\`\`markdown
|
|
14278
|
-
- [ ] ${ID_PREFIX.SESSION}N (
|
|
14460
|
+
- [ ] ${ID_PREFIX.SESSION}N (${AGENT_NAMES.WORKER}): \`[target-file]\` - ${WORK_STATUS.SESSION.STARTED}
|
|
14279
14461
|
\`\`\`
|
|
14280
14462
|
|
|
14281
14463
|
### Phase 2: TEST FIRST (Red)
|
|
@@ -14327,12 +14509,13 @@ You work on ONE FILE at a time in ISOLATION. Follow this EXACT cycle:
|
|
|
14327
14509
|
- Communication/interaction needed \u2192 Assume dummy response
|
|
14328
14510
|
- Real I/O strictly forbidden
|
|
14329
14511
|
3. **Delete after pass** - Remove isolated test file
|
|
14330
|
-
4. **Record in .
|
|
14512
|
+
4. **Record in ${PATHS.OPENCODE}** - Preserve test code and results
|
|
14331
14513
|
|
|
14332
14514
|
### CRITICAL RULES:
|
|
14333
14515
|
- NEVER skip the test file deletion step
|
|
14334
14516
|
- ALWAYS preserve test code in ${PATHS.UNIT_TESTS}/
|
|
14335
|
-
- NEVER mark [x] in
|
|
14517
|
+
- NEVER mark [x] in ${PATHS.TODO} - ${AGENT_NAMES.REVIEWER}'s job!
|
|
14518
|
+
|
|
14336
14519
|
- ONE file per session - complete isolation
|
|
14337
14520
|
${PROMPT_TAGS.TDD_WORKFLOW.close}`;
|
|
14338
14521
|
|
|
@@ -14340,6 +14523,7 @@ ${PROMPT_TAGS.TDD_WORKFLOW.close}`;
|
|
|
14340
14523
|
var WORKER_ISOLATION_TESTING = `${PROMPT_TAGS.ISOLATION_TESTING.open}
|
|
14341
14524
|
## ISOLATED UNIT TEST RULES
|
|
14342
14525
|
|
|
14526
|
+
|
|
14343
14527
|
### File Naming Convention
|
|
14344
14528
|
\`[original-dir]/__tests__/[filename].isolated.test.ts\`
|
|
14345
14529
|
|
|
@@ -14379,10 +14563,11 @@ Example:
|
|
|
14379
14563
|
* Target: [full-path]
|
|
14380
14564
|
* Session: [session_id]
|
|
14381
14565
|
*
|
|
14382
|
-
*
|
|
14383
|
-
* Test code preserved in: .
|
|
14566
|
+
* **WARNING**: THIS FILE WILL BE DELETED AFTER TEST PASSES
|
|
14567
|
+
* Test code preserved in: ${PATHS.UNIT_TESTS}/
|
|
14384
14568
|
*/
|
|
14385
14569
|
|
|
14570
|
+
|
|
14386
14571
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
14387
14572
|
|
|
14388
14573
|
// Mock all external dependencies BEFORE importing target
|
|
@@ -14424,6 +14609,7 @@ ${PROMPT_TAGS.ISOLATION_TESTING.close}`;
|
|
|
14424
14609
|
var WORKER_FILE_ASSIGNMENT = `${PROMPT_TAGS.FILE_ASSIGNMENT.open}
|
|
14425
14610
|
## FILE ASSIGNMENT PROTOCOL
|
|
14426
14611
|
|
|
14612
|
+
|
|
14427
14613
|
You are assigned ONE FILE per session. Follow this protocol:
|
|
14428
14614
|
|
|
14429
14615
|
### Step 1: Read Shared State
|
|
@@ -14435,7 +14621,7 @@ cat ${PATHS.SYNC_ISSUES} 2>/dev/null || echo "No sync issues"
|
|
|
14435
14621
|
\`\`\`
|
|
14436
14622
|
|
|
14437
14623
|
### Step 2: Identify Your Assignment
|
|
14438
|
-
|
|
14624
|
+
${AGENT_NAMES.COMMANDER} gives you:
|
|
14439
14625
|
- \`file: src/path/to/file.ts\` - Your target file
|
|
14440
14626
|
- \`action: ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.ACTION.MODIFY} | ${WORK_STATUS.ACTION.FIX}\` - What to do
|
|
14441
14627
|
- \`issue: ${ID_PREFIX.SYNC_ISSUE}N\` (optional) - If fixing a sync issue
|
|
@@ -14443,7 +14629,7 @@ Commander gives you:
|
|
|
14443
14629
|
### Step 3: Update Work Log (Start)
|
|
14444
14630
|
\`\`\`markdown
|
|
14445
14631
|
## Active Sessions
|
|
14446
|
-
- [ ] ${ID_PREFIX.SESSION}N (
|
|
14632
|
+
- [ ] ${ID_PREFIX.SESSION}N (${AGENT_NAMES.WORKER}): \`[file]\` - [action] ${WORK_STATUS.SESSION.STARTED}
|
|
14447
14633
|
\`\`\`
|
|
14448
14634
|
|
|
14449
14635
|
### Step 4: Read Context
|
|
@@ -14455,23 +14641,23 @@ Commander gives you:
|
|
|
14455
14641
|
1. Create isolated test
|
|
14456
14642
|
2. Implement
|
|
14457
14643
|
3. Pass test
|
|
14458
|
-
4. Delete test (record in
|
|
14644
|
+
4. Delete test (record in ${PATHS.UNIT_TESTS}/)
|
|
14459
14645
|
|
|
14460
14646
|
### Step 6: Update Work Log (Complete)
|
|
14461
14647
|
\`\`\`markdown
|
|
14462
14648
|
## Active Sessions
|
|
14463
|
-
- [x] ${ID_PREFIX.SESSION}N (
|
|
14649
|
+
- [x] ${ID_PREFIX.SESSION}N (${AGENT_NAMES.WORKER}): \`[file]\` - [action] ${WORK_STATUS.SESSION.COMPLETED}
|
|
14464
14650
|
|
|
14465
14651
|
## File Status (update row)
|
|
14466
14652
|
| [file] | [action] | ${WORK_STATUS.STATUS.DONE} | ${ID_PREFIX.SESSION}N | ${WORK_STATUS.TEST_RESULT.PASS} | [timestamp] |
|
|
14467
14653
|
\`\`\`
|
|
14468
14654
|
|
|
14469
14655
|
### Step 7: Report
|
|
14470
|
-
Report to
|
|
14656
|
+
Report to ${AGENT_NAMES.COMMANDER} via tool result:
|
|
14471
14657
|
\`\`\`
|
|
14472
|
-
|
|
14658
|
+
SUCCESS File: [path]
|
|
14473
14659
|
Action: [${WORK_STATUS.ACTION.CREATE}/${WORK_STATUS.ACTION.MODIFY}/${WORK_STATUS.ACTION.FIX}]
|
|
14474
|
-
Unit Test: ${WORK_STATUS.TEST_RESULT.PASS}
|
|
14660
|
+
Unit Test: ${WORK_STATUS.TEST_RESULT.PASS.toUpperCase()}
|
|
14475
14661
|
Isolated test deleted, recorded in ${PATHS.UNIT_TESTS}/
|
|
14476
14662
|
Ready for integration.
|
|
14477
14663
|
\`\`\`
|
|
@@ -14495,9 +14681,29 @@ Ready for integration.
|
|
|
14495
14681
|
- ONE file only - never touch other files
|
|
14496
14682
|
- ALWAYS update ${PATHS.WORK_LOG} at start and end
|
|
14497
14683
|
- READ ${PATHS.SYNC_ISSUES} if issue: tag is present
|
|
14498
|
-
- Follow
|
|
14684
|
+
- Follow ${AGENT_NAMES.COMMANDER}'s specific instructions
|
|
14499
14685
|
${PROMPT_TAGS.FILE_ASSIGNMENT.close}`;
|
|
14500
14686
|
|
|
14687
|
+
// src/agents/prompts/worker/lsp-tools.ts
|
|
14688
|
+
var WORKER_LSP_TOOLS = `<lsp_tools>
|
|
14689
|
+
## LSP Tools for Code Verification
|
|
14690
|
+
|
|
14691
|
+
**AVAILABLE TOOLS**:
|
|
14692
|
+
- \`${TOOL_NAMES.LSP_DIAGNOSTICS}\`: Get errors/warnings BEFORE marking work complete
|
|
14693
|
+
- \`${TOOL_NAMES.AST_SEARCH}\`: Structural code search for pattern matching
|
|
14694
|
+
- \`${TOOL_NAMES.AST_REPLACE}\`: Safe structural code refactoring
|
|
14695
|
+
|
|
14696
|
+
**WHEN TO USE**:
|
|
14697
|
+
1. After completing file edits \u2192 \`${TOOL_NAMES.LSP_DIAGNOSTICS}({ file: "your-file.ts" })\`
|
|
14698
|
+
2. Before marking TODO complete \u2192 \`${TOOL_NAMES.LSP_DIAGNOSTICS}({ file: "*" })\`
|
|
14699
|
+
3. For safe refactoring \u2192 \`${TOOL_NAMES.AST_REPLACE}\`
|
|
14700
|
+
|
|
14701
|
+
**VERIFICATION RULE**:
|
|
14702
|
+
- NEVER claim "done" without running \`${TOOL_NAMES.LSP_DIAGNOSTICS}\`
|
|
14703
|
+
- Zero errors required before completion
|
|
14704
|
+
- Warnings acceptable but should be noted
|
|
14705
|
+
</lsp_tools>`;
|
|
14706
|
+
|
|
14501
14707
|
// src/agents/prompts/reviewer/role.ts
|
|
14502
14708
|
var REVIEWER_ROLE = `${PROMPT_TAGS.ROLE.open}
|
|
14503
14709
|
You are ${AGENT_NAMES.REVIEWER}. Verification specialist.
|
|
@@ -14514,22 +14720,25 @@ ${PROMPT_TAGS.ROLE.close}`;
|
|
|
14514
14720
|
|
|
14515
14721
|
// src/agents/prompts/reviewer/forbidden.ts
|
|
14516
14722
|
var REVIEWER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
14517
|
-
|
|
14723
|
+
**FORBIDDEN ACTIONS**
|
|
14724
|
+
|
|
14725
|
+
|
|
14518
14726
|
|
|
14519
14727
|
## Never Approve Without Verification
|
|
14520
14728
|
- NEVER approve without actually running the project's test command
|
|
14521
|
-
- NEVER skip
|
|
14729
|
+
- NEVER skip ${TOOL_NAMES.LSP_DIAGNOSTICS} check
|
|
14522
14730
|
- NEVER mark [x] without concrete evidence (command outputs)
|
|
14523
14731
|
- NEVER trust "task complete" claims \u2192 Always verify yourself
|
|
14524
14732
|
|
|
14525
14733
|
## Never Assume Quality
|
|
14526
14734
|
- NEVER approve code that doesn't match ${PATHS.DOCS}/
|
|
14527
14735
|
- NEVER approve code that violates project's observed patterns
|
|
14528
|
-
- NEVER mark [x] before task was actually executed by
|
|
14736
|
+
- NEVER mark [x] before task was actually executed by ${AGENT_NAMES.WORKER}
|
|
14529
14737
|
|
|
14530
14738
|
## Never Overstep
|
|
14531
14739
|
- NEVER make architecture changes \u2192 Escalate to ${AGENT_NAMES.COMMANDER}
|
|
14532
|
-
- NEVER implement fixes yourself \u2192 Send back to
|
|
14740
|
+
- NEVER implement fixes yourself \u2192 Send back to ${AGENT_NAMES.WORKER} with clear feedback
|
|
14741
|
+
|
|
14533
14742
|
|
|
14534
14743
|
## Adaptive Verification
|
|
14535
14744
|
- READ ${PATHS.CONTEXT} to know the correct build/test commands
|
|
@@ -14539,14 +14748,14 @@ ${PROMPT_TAGS.FORBIDDEN_ACTIONS.close}`;
|
|
|
14539
14748
|
|
|
14540
14749
|
// src/agents/prompts/reviewer/required.ts
|
|
14541
14750
|
var REVIEWER_REQUIRED = `${PROMPT_TAGS.REQUIRED_ACTIONS.open}
|
|
14542
|
-
|
|
14751
|
+
**THINK FIRST**: As REVIEWER, think about VERIFICATION before checking:
|
|
14543
14752
|
- What are the EXACT acceptance criteria for this task?
|
|
14544
14753
|
- What could APPEAR to work but actually be broken?
|
|
14545
14754
|
- Are there INTEGRATION issues between components?
|
|
14546
14755
|
- What security/performance issues might be HIDDEN?
|
|
14547
14756
|
- Am I verifying THOROUGHLY or just going through motions?
|
|
14548
14757
|
|
|
14549
|
-
ALWAYS run
|
|
14758
|
+
ALWAYS run ${TOOL_NAMES.LSP_DIAGNOSTICS}
|
|
14550
14759
|
ALWAYS run project's BUILD command (from ${PATHS.CONTEXT})
|
|
14551
14760
|
ALWAYS run project's TEST command (from ${PATHS.CONTEXT})
|
|
14552
14761
|
ALWAYS check implementation matches ${PATHS.DOCS}/
|
|
@@ -14554,11 +14763,13 @@ ALWAYS update ${PATHS.TODO} checkboxes ONLY after verification
|
|
|
14554
14763
|
ALWAYS provide ${WORK_STATUS.TEST_RESULT.PASS}/${WORK_STATUS.TEST_RESULT.FAIL} with evidence
|
|
14555
14764
|
ALWAYS check for security issues
|
|
14556
14765
|
ALWAYS verify tests exist for new code
|
|
14557
|
-
${PROMPT_TAGS.REQUIRED_ACTIONS.close}
|
|
14766
|
+
${PROMPT_TAGS.REQUIRED_ACTIONS.close}
|
|
14767
|
+
`;
|
|
14558
14768
|
|
|
14559
14769
|
// src/agents/prompts/reviewer/verification.ts
|
|
14560
14770
|
var REVIEWER_VERIFICATION = `${PROMPT_TAGS.VERIFICATION_PROCESS.open}
|
|
14561
|
-
|
|
14771
|
+
**ADAPTIVE VERIFICATION PROCESS**
|
|
14772
|
+
|
|
14562
14773
|
|
|
14563
14774
|
## Step 1: Read Project Context
|
|
14564
14775
|
\`\`\`bash
|
|
@@ -14569,7 +14780,7 @@ cat ${PATHS.CONTEXT} # Get build/test commands
|
|
|
14569
14780
|
- Note any project-specific verification requirements
|
|
14570
14781
|
|
|
14571
14782
|
## Step 2: Static Analysis
|
|
14572
|
-
|
|
14783
|
+
${TOOL_NAMES.LSP_DIAGNOSTICS} - Must show NO errors or warnings
|
|
14573
14784
|
|
|
14574
14785
|
## Step 3: Build Verification
|
|
14575
14786
|
- Run the project's BUILD command (from ${PATHS.CONTEXT})
|
|
@@ -14595,56 +14806,50 @@ lsp_diagnostics - Must show NO errors or warnings
|
|
|
14595
14806
|
In ${PATHS.TODO}:
|
|
14596
14807
|
- [x] T1: [task] | verified | evidence: [build/test results]
|
|
14597
14808
|
|
|
14598
|
-
|
|
14809
|
+
**CRITICAL**: NEVER mark [x] without running ACTUAL verification commands!
|
|
14599
14810
|
${PROMPT_TAGS.VERIFICATION_PROCESS.close}`;
|
|
14600
14811
|
|
|
14601
14812
|
// src/agents/prompts/reviewer/todo-update.ts
|
|
14602
14813
|
var REVIEWER_TODO_UPDATE = `${PROMPT_TAGS.TODO_MANAGEMENT.open}
|
|
14603
|
-
YOU are the ONLY agent who can mark [x]!
|
|
14814
|
+
YOU are the ONLY agent who can mark leaf tasks as [x]!
|
|
14815
|
+
|
|
14604
14816
|
|
|
14605
|
-
## Hierarchical
|
|
14606
|
-
|
|
14607
|
-
|
|
14608
|
-
|
|
14817
|
+
## Hierarchical Resolution Rules
|
|
14818
|
+
The completion state MUST propagate from the innermost subtasks up to the root goal.
|
|
14819
|
+
|
|
14820
|
+
1. **Leaf Tasks (Inner-most)**: Mark \`[x]\` ONLY when verified via tools (build, test, lsp).
|
|
14821
|
+
2. **Intermediate Parent Tasks**: Mark \`[x]\` (or update status to ${WORK_STATUS.TODO_STATUS.COMPLETE}) ONLY when ALL its direct children are marked \`[x]\`.
|
|
14822
|
+
3. **Primary Goal (Epic)**: Mark \`[x]\` (or status ${WORK_STATUS.TODO_STATUS.COMPLETE}) ONLY when ALL underlying tasks are verified and complete.
|
|
14609
14823
|
|
|
14610
14824
|
## Verification Flow
|
|
14611
|
-
1. ${AGENT_NAMES.WORKER}
|
|
14612
|
-
2.
|
|
14613
|
-
3.
|
|
14614
|
-
4.
|
|
14615
|
-
5.
|
|
14616
|
-
6.
|
|
14617
|
-
|
|
14618
|
-
## Update
|
|
14825
|
+
1. ${AGENT_NAMES.WORKER} claims completion of an atomic subtask (leaf node).
|
|
14826
|
+
2. YOU verify the claim using: \`${TOOL_NAMES.LSP_DIAGNOSTICS}\`, \`build\`, \`test\`.
|
|
14827
|
+
3. If verified, you mark the leaf node \`[x]\`.
|
|
14828
|
+
4. Check if this leaves the Parent node with ALL children complete.
|
|
14829
|
+
5. If so, update the Parent node to \`[x]\` or status: ${WORK_STATUS.TODO_STATUS.COMPLETE}.
|
|
14830
|
+
6. Repeat until the entire hierarchy is resolved.
|
|
14831
|
+
|
|
14832
|
+
## Update Example (Recursive Resolution)
|
|
14619
14833
|
BEFORE:
|
|
14620
14834
|
\`\`\`markdown
|
|
14621
|
-
##
|
|
14622
|
-
|
|
14623
|
-
- [ ]
|
|
14624
|
-
- [
|
|
14835
|
+
## P1.2: [Implementation Block] | status: ${WORK_STATUS.TODO_STATUS.IN_PROGRESS}
|
|
14836
|
+
#### P1.2.1: [Sub-module A]
|
|
14837
|
+
- [ ] T1.2.1.1: [Draft code] | size:M
|
|
14838
|
+
- [x] T1.2.1.2: [Tests for A] | ${WORK_STATUS.TODO_STATUS.VERIFIED}
|
|
14625
14839
|
\`\`\`
|
|
14626
14840
|
|
|
14627
|
-
AFTER (
|
|
14841
|
+
AFTER (T1.2.1.1 verified):
|
|
14628
14842
|
\`\`\`markdown
|
|
14629
|
-
##
|
|
14630
|
-
|
|
14631
|
-
- [x]
|
|
14632
|
-
- [x]
|
|
14633
|
-
\`\`\`
|
|
14634
|
-
|
|
14635
|
-
AFTER (all tasks in epic verified):
|
|
14636
|
-
\`\`\`markdown
|
|
14637
|
-
## E1: Backend API | status: ${WORK_STATUS.TODO_STATUS.COMPLETE}
|
|
14638
|
-
### T1.1: Database schema | ${WORK_STATUS.TODO_STATUS.DONE}
|
|
14639
|
-
...
|
|
14640
|
-
### T1.2: Auth endpoints | ${WORK_STATUS.TODO_STATUS.DONE}
|
|
14641
|
-
...
|
|
14843
|
+
## P1.2: [Implementation Block] | status: ${WORK_STATUS.TODO_STATUS.IN_PROGRESS}
|
|
14844
|
+
#### P1.2.1: [Sub-module A] | status: ${WORK_STATUS.TODO_STATUS.COMPLETE}
|
|
14845
|
+
- [x] T1.2.1.1: [Draft code] | ${WORK_STATUS.TODO_STATUS.VERIFIED}
|
|
14846
|
+
- [x] T1.2.1.2: [Tests for A] | ${WORK_STATUS.TODO_STATUS.VERIFIED}
|
|
14642
14847
|
\`\`\`
|
|
14643
14848
|
|
|
14644
14849
|
## FORBIDDEN
|
|
14645
|
-
- Marking parent
|
|
14646
|
-
- Marking [x] without verification
|
|
14647
|
-
-
|
|
14850
|
+
- Marking a parent complete before all children are exactly \`[x]\`.
|
|
14851
|
+
- Marking any task \`[x]\` without running verification tools.
|
|
14852
|
+
- Removing "depends:" tags before they are fully resolved.
|
|
14648
14853
|
${PROMPT_TAGS.TODO_MANAGEMENT.close}`;
|
|
14649
14854
|
|
|
14650
14855
|
// src/agents/prompts/reviewer/output.ts
|
|
@@ -14707,15 +14912,15 @@ Do NOT block - check status asynchronously and wait for completion.
|
|
|
14707
14912
|
1. If workers still running:
|
|
14708
14913
|
- Report current status
|
|
14709
14914
|
- DO NOT block or wait indefinitely
|
|
14710
|
-
- Schedule next check (
|
|
14915
|
+
- Schedule next check (${AGENT_NAMES.COMMANDER} will re-invoke)
|
|
14711
14916
|
|
|
14712
14917
|
2. If all workers complete:
|
|
14713
14918
|
- Proceed to integration testing
|
|
14714
14919
|
- Update ${PATHS.INTEGRATION_STATUS}
|
|
14715
14920
|
|
|
14716
|
-
###
|
|
14921
|
+
### ${PATHS.WORK_LOG.split("/").pop()} Interpretation
|
|
14717
14922
|
\`\`\`markdown
|
|
14718
|
-
# Reading
|
|
14923
|
+
# Reading ${PATHS.WORK_LOG.split("/").pop()}:
|
|
14719
14924
|
- [ ] = Still in progress, DO NOT verify yet
|
|
14720
14925
|
- [x] = Unit complete, READY for verification
|
|
14721
14926
|
\`\`\`
|
|
@@ -14724,27 +14929,25 @@ Do NOT block - check status asynchronously and wait for completion.
|
|
|
14724
14929
|
- NEVER verify a file before worker marks [x]
|
|
14725
14930
|
- NEVER block waiting for workers
|
|
14726
14931
|
- Always update ${PATHS.WORK_LOG} with your monitoring status
|
|
14932
|
+
|
|
14727
14933
|
${PROMPT_TAGS.ASYNC_MONITORING.close}`;
|
|
14728
14934
|
|
|
14729
14935
|
// src/agents/prompts/reviewer/integration-testing.ts
|
|
14730
14936
|
var REVIEWER_INTEGRATION_TESTING = `${PROMPT_TAGS.INTEGRATION_TESTING.open}
|
|
14731
|
-
## E2E INTEGRATION TESTING
|
|
14937
|
+
## E2E INTEGRATION TESTING RULES
|
|
14732
14938
|
|
|
14733
|
-
###
|
|
14734
|
-
|
|
14735
|
-
1. **TODO is almost complete** - Most tasks checked [x]
|
|
14736
|
-
2. **All Workers done** - No active sessions in work-log.md
|
|
14737
|
-
3. **Or final verification** - Right before SEALED
|
|
14939
|
+
### 1. Timing
|
|
14940
|
+
Start when **${PATHS.TODO} \u2265 80%** (some Workers still active).
|
|
14738
14941
|
|
|
14739
|
-
### Pre-
|
|
14740
|
-
|
|
14741
|
-
- [ ]
|
|
14742
|
-
- [ ]
|
|
14743
|
-
- [ ]
|
|
14942
|
+
### 2. Pre-integration Checklist
|
|
14943
|
+
Before running integration tests, all merged files must:
|
|
14944
|
+
- [ ] Have clean lsp_diagnostics
|
|
14945
|
+
- [ ] Have unit test passing records in ${PATHS.UNIT_TESTS}/
|
|
14946
|
+
- [ ] Be listed in ${PATHS.WORK_LOG} "Pending Integration"
|
|
14744
14947
|
|
|
14745
14948
|
### Integration Workflow
|
|
14746
14949
|
|
|
14747
|
-
#### Step 1: Check TODO Status
|
|
14950
|
+
#### Step 1: Check ${PATHS.TODO} Status
|
|
14748
14951
|
\`\`\`bash
|
|
14749
14952
|
cat ${PATHS.TODO}
|
|
14750
14953
|
# If incomplete items exist, wait for E2E
|
|
@@ -14753,7 +14956,7 @@ cat ${PATHS.TODO}
|
|
|
14753
14956
|
#### Step 2: Run Build (language-appropriate)
|
|
14754
14957
|
\`\`\`bash
|
|
14755
14958
|
# Run project build command
|
|
14756
|
-
# If failed, record in
|
|
14959
|
+
# If failed, record in ${PATHS.SYNC_ISSUES}
|
|
14757
14960
|
\`\`\`
|
|
14758
14961
|
|
|
14759
14962
|
#### Step 3: Run Full Tests
|
|
@@ -14778,8 +14981,8 @@ Write to ${PATHS.INTEGRATION_STATUS}:
|
|
|
14778
14981
|
- Timestamp: [ISO timestamp]
|
|
14779
14982
|
|
|
14780
14983
|
## Result
|
|
14781
|
-
- Build: ${
|
|
14782
|
-
- E2E Test: ${
|
|
14984
|
+
- Build: ${STATUS_LABEL.PASS}/${WORK_STATUS.TEST_RESULT.FAIL}
|
|
14985
|
+
- E2E Test: ${STATUS_LABEL.PASS}/${WORK_STATUS.TEST_RESULT.FAIL}
|
|
14783
14986
|
|
|
14784
14987
|
## Sync Issues Found
|
|
14785
14988
|
- (omit if none)
|
|
@@ -14796,15 +14999,16 @@ Write to ${PATHS.INTEGRATION_STATUS}:
|
|
|
14796
14999
|
- [ ] E2E test passes
|
|
14797
15000
|
|
|
14798
15001
|
### LOOP BACK Conditions
|
|
14799
|
-
- ${PATHS.TODO} has incomplete items \u2192
|
|
14800
|
-
- ${PATHS.SYNC_ISSUES} has unresolved issues \u2192
|
|
14801
|
-
- Build/test fails \u2192 record in
|
|
15002
|
+
- ${PATHS.TODO} has incomplete items \u2192 LOOP
|
|
15003
|
+
- ${PATHS.SYNC_ISSUES} has unresolved issues \u2192 LOOP
|
|
15004
|
+
- Build/test fails \u2192 record in ${PATHS.SYNC_ISSUES} \u2192 LOOP
|
|
15005
|
+
|
|
14802
15006
|
|
|
14803
15007
|
### CRITICAL:
|
|
14804
|
-
- E2E only at TODO completion time!
|
|
14805
|
-
- Record build/test failures minimally in
|
|
15008
|
+
- E2E only at ${PATHS.TODO} completion time!
|
|
15009
|
+
- Record build/test failures minimally in ${PATHS.SYNC_ISSUES}
|
|
14806
15010
|
- Delete resolved issues, keep only unresolved
|
|
14807
|
-
- All TODO [x] + no issues = SEALED!
|
|
15011
|
+
- All ${PATHS.TODO} [x] + no issues = SEALED!
|
|
14808
15012
|
${PROMPT_TAGS.INTEGRATION_TESTING.close}`;
|
|
14809
15013
|
|
|
14810
15014
|
// src/agents/prompts/reviewer/sync-verification.ts
|
|
@@ -14838,11 +15042,11 @@ npx tsc --noEmit 2>&1 | grep -i "type"
|
|
|
14838
15042
|
|
|
14839
15043
|
---
|
|
14840
15044
|
|
|
14841
|
-
## ISSUE MANAGEMENT RULES
|
|
15045
|
+
## ISSUE MANAGEMENT RULES (CRITICAL)
|
|
14842
15046
|
|
|
14843
|
-
###
|
|
15047
|
+
### ${PATHS.SYNC_ISSUES} Contains UNRESOLVED ONLY
|
|
14844
15048
|
- **Delete resolved issues immediately** (keep file clean)
|
|
14845
|
-
- **Keep only unresolved** (only what
|
|
15049
|
+
- **Keep only unresolved** (only what ${AGENT_NAMES.COMMANDER} needs to read)
|
|
14846
15050
|
- **Summarize if too long** (archive old issues)
|
|
14847
15051
|
|
|
14848
15052
|
### Issue Format (Minimal)
|
|
@@ -14860,7 +15064,7 @@ npx tsc --noEmit 2>&1 | grep -i "type"
|
|
|
14860
15064
|
### After Fix Verification
|
|
14861
15065
|
When re-verifying after fixes:
|
|
14862
15066
|
1. Check if issue is resolved
|
|
14863
|
-
2. If resolved: **DELETE the issue from
|
|
15067
|
+
2. If resolved: **DELETE the issue from ${PATHS.SYNC_ISSUES}**
|
|
14864
15068
|
3. If not resolved: Update issue status, add notes
|
|
14865
15069
|
4. Keep file minimal
|
|
14866
15070
|
|
|
@@ -14885,10 +15089,32 @@ Output SEALED only when:
|
|
|
14885
15089
|
### CRITICAL:
|
|
14886
15090
|
- Always check sync AFTER integration tests
|
|
14887
15091
|
- DELETE resolved issues immediately
|
|
14888
|
-
- Keep
|
|
15092
|
+
- Keep ${PATHS.SYNC_ISSUES} as short as possible
|
|
14889
15093
|
- Ensure ${AGENT_NAMES.COMMANDER} only sees what needs fixing
|
|
15094
|
+
|
|
14890
15095
|
${PROMPT_TAGS.SYNC_VERIFICATION.close}`;
|
|
14891
15096
|
|
|
15097
|
+
// src/agents/prompts/reviewer/lsp-tools.ts
|
|
15098
|
+
var REVIEWER_LSP_TOOLS = `<lsp_tools>
|
|
15099
|
+
## LSP Tools for Verification
|
|
15100
|
+
|
|
15101
|
+
**MANDATORY VERIFICATION TOOL**:
|
|
15102
|
+
Use \`${TOOL_NAMES.LSP_DIAGNOSTICS}\` when verifying ${AGENT_NAMES.WORKER} output.
|
|
15103
|
+
|
|
15104
|
+
**VERIFICATION WORKFLOW**:
|
|
15105
|
+
1. ${AGENT_NAMES.WORKER} claims completion
|
|
15106
|
+
2. Run \`${TOOL_NAMES.LSP_DIAGNOSTICS}({ file: "*" })\` on affected files
|
|
15107
|
+
3. Zero errors = ${STATUS_LABEL.PASS.toUpperCase()}, Errors = ${STATUS_LABEL.FAIL.toUpperCase()} + return to ${AGENT_NAMES.WORKER}
|
|
15108
|
+
|
|
15109
|
+
**OUTPUT INTERPRETATION**:
|
|
15110
|
+
- ${OUTPUT_LABEL.ERROR} = ${STATUS_LABEL.ERROR.toUpperCase()} (blocking)
|
|
15111
|
+
- ${OUTPUT_LABEL.WARNING} = ${STATUS_LABEL.WARNING.toUpperCase()} (note but proceed)
|
|
15112
|
+
- Clean = ${STATUS_LABEL.CLEAN.toUpperCase()} (approve)
|
|
15113
|
+
|
|
15114
|
+
**GATEKEEPER RULE**:
|
|
15115
|
+
Do NOT mark [x] in ${PATHS.TODO} without clean ${TOOL_NAMES.LSP_DIAGNOSTICS}.
|
|
15116
|
+
</lsp_tools>`;
|
|
15117
|
+
|
|
14892
15118
|
// src/agents/commander.ts
|
|
14893
15119
|
var systemPrompt = [
|
|
14894
15120
|
CORE_PHILOSOPHY,
|
|
@@ -14907,6 +15133,8 @@ var systemPrompt = [
|
|
|
14907
15133
|
COMMANDER_LOOP_CONTINUATION,
|
|
14908
15134
|
COMMANDER_SYNC_HANDLING,
|
|
14909
15135
|
COMMANDER_RECOVERY,
|
|
15136
|
+
SHARED_LSP_TOOLS,
|
|
15137
|
+
SHARED_AST_TOOLS,
|
|
14910
15138
|
SHARED_WORKSPACE,
|
|
14911
15139
|
ANTI_HALLUCINATION_CORE,
|
|
14912
15140
|
MISSION_SEAL_RULES
|
|
@@ -14921,7 +15149,6 @@ var commander = {
|
|
|
14921
15149
|
|
|
14922
15150
|
// src/agents/subagents/planner.ts
|
|
14923
15151
|
var systemPrompt2 = [
|
|
14924
|
-
CORE_PHILOSOPHY,
|
|
14925
15152
|
PLANNER_ROLE,
|
|
14926
15153
|
PLANNER_FORBIDDEN,
|
|
14927
15154
|
PLANNER_REQUIRED,
|
|
@@ -14933,6 +15160,8 @@ var systemPrompt2 = [
|
|
|
14933
15160
|
PLANNER_FILE_PLANNING,
|
|
14934
15161
|
PLANNER_TODO_SYNC,
|
|
14935
15162
|
PLANNER_RESEARCH,
|
|
15163
|
+
SHARED_LSP_TOOLS,
|
|
15164
|
+
SHARED_AST_TOOLS,
|
|
14936
15165
|
SHARED_WORKSPACE
|
|
14937
15166
|
].join("\n\n");
|
|
14938
15167
|
var planner = {
|
|
@@ -14945,7 +15174,6 @@ var planner = {
|
|
|
14945
15174
|
|
|
14946
15175
|
// src/agents/subagents/worker.ts
|
|
14947
15176
|
var systemPrompt3 = [
|
|
14948
|
-
CORE_PHILOSOPHY,
|
|
14949
15177
|
WORKER_ROLE,
|
|
14950
15178
|
WORKER_FORBIDDEN,
|
|
14951
15179
|
WORKER_REQUIRED,
|
|
@@ -14957,6 +15185,9 @@ var systemPrompt3 = [
|
|
|
14957
15185
|
// TDD-based isolated work
|
|
14958
15186
|
WORKER_TDD_WORKFLOW,
|
|
14959
15187
|
WORKER_ISOLATION_TESTING,
|
|
15188
|
+
WORKER_LSP_TOOLS,
|
|
15189
|
+
SHARED_LSP_TOOLS,
|
|
15190
|
+
SHARED_AST_TOOLS,
|
|
14960
15191
|
VERIFICATION_REQUIREMENTS,
|
|
14961
15192
|
SHARED_WORKSPACE
|
|
14962
15193
|
].join("\n\n");
|
|
@@ -14970,7 +15201,6 @@ var worker = {
|
|
|
14970
15201
|
|
|
14971
15202
|
// src/agents/subagents/reviewer.ts
|
|
14972
15203
|
var systemPrompt4 = [
|
|
14973
|
-
CORE_PHILOSOPHY,
|
|
14974
15204
|
REVIEWER_ROLE,
|
|
14975
15205
|
REVIEWER_FORBIDDEN,
|
|
14976
15206
|
REVIEWER_REQUIRED,
|
|
@@ -14981,6 +15211,9 @@ var systemPrompt4 = [
|
|
|
14981
15211
|
REVIEWER_ASYNC_MONITORING,
|
|
14982
15212
|
REVIEWER_INTEGRATION_TESTING,
|
|
14983
15213
|
REVIEWER_SYNC_VERIFICATION,
|
|
15214
|
+
REVIEWER_LSP_TOOLS,
|
|
15215
|
+
SHARED_LSP_TOOLS,
|
|
15216
|
+
SHARED_AST_TOOLS,
|
|
14984
15217
|
REVIEWER_OUTPUT,
|
|
14985
15218
|
SHARED_WORKSPACE
|
|
14986
15219
|
].join("\n\n");
|
|
@@ -15007,11 +15240,12 @@ var callAgentTool = tool({
|
|
|
15007
15240
|
<agents>
|
|
15008
15241
|
| Agent | Role | When to Use |
|
|
15009
15242
|
|-------|------|-------------|
|
|
15010
|
-
| ${AGENT_NAMES.PLANNER}
|
|
15011
|
-
| ${AGENT_NAMES.WORKER}
|
|
15012
|
-
| ${AGENT_NAMES.REVIEWER}
|
|
15243
|
+
| ${AGENT_NAMES.PLANNER} | Planner + Researcher | Complex task -> plan, OR need research first |
|
|
15244
|
+
| ${AGENT_NAMES.WORKER} | Developer + Docs | Any code implementation, documentation |
|
|
15245
|
+
| ${AGENT_NAMES.REVIEWER} | Verifier + Context | Before completion, verify, update TODO |
|
|
15013
15246
|
</agents>
|
|
15014
15247
|
|
|
15248
|
+
|
|
15015
15249
|
<execution_rules>
|
|
15016
15250
|
1. Tasks with same parallel_group run CONCURRENTLY
|
|
15017
15251
|
2. Always call Reviewer before marking complete
|
|
@@ -15029,13 +15263,12 @@ var callAgentTool = tool({
|
|
|
15029
15263
|
async execute(args) {
|
|
15030
15264
|
const agentDef = AGENTS[args.agent];
|
|
15031
15265
|
if (!agentDef) {
|
|
15032
|
-
return
|
|
15266
|
+
return `Error: Unknown agent: ${args.agent}`;
|
|
15033
15267
|
}
|
|
15034
|
-
const
|
|
15268
|
+
const label = args.agent[0].toUpperCase();
|
|
15035
15269
|
const prompt = `
|
|
15036
|
-
|
|
15037
|
-
|
|
15038
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
15270
|
+
[ ${label} ] ${agentDef.id.toUpperCase()} :: ${agentDef.description}
|
|
15271
|
+
|
|
15039
15272
|
|
|
15040
15273
|
<system>
|
|
15041
15274
|
${agentDef.systemPrompt}
|
|
@@ -15078,7 +15311,7 @@ $ARGUMENTS
|
|
|
15078
15311
|
</mission>`;
|
|
15079
15312
|
var COMMANDS = {
|
|
15080
15313
|
"task": {
|
|
15081
|
-
description: "
|
|
15314
|
+
description: "MISSION MODE - Execute task autonomously until complete",
|
|
15082
15315
|
template: MISSION_MODE_TEMPLATE,
|
|
15083
15316
|
argumentHint: '"mission goal"'
|
|
15084
15317
|
},
|
|
@@ -15107,23 +15340,23 @@ var COMMANDS = {
|
|
|
15107
15340
|
},
|
|
15108
15341
|
"agents": {
|
|
15109
15342
|
description: "Show the 4-agent architecture",
|
|
15110
|
-
template: `##
|
|
15343
|
+
template: `## OpenCode Orchestrator - 4-Agent Architecture
|
|
15111
15344
|
|
|
15112
15345
|
| Agent | Role | Capabilities |
|
|
15113
15346
|
|-------|------|--------------|
|
|
15114
|
-
| **${AGENT_NAMES.COMMANDER}**
|
|
15115
|
-
| **${AGENT_NAMES.PLANNER}**
|
|
15116
|
-
| **${AGENT_NAMES.WORKER}**
|
|
15117
|
-
| **${AGENT_NAMES.REVIEWER}**
|
|
15347
|
+
| **${AGENT_NAMES.COMMANDER}** | [MASTER] | Master Orchestrator: mission control, parallel coordination |
|
|
15348
|
+
| **${AGENT_NAMES.PLANNER}** | [STRATEGIST] | Planning, research, documentation analysis |
|
|
15349
|
+
| **${AGENT_NAMES.WORKER}** | [EXECUTOR] | Implementation, coding, terminal tasks |
|
|
15350
|
+
| **${AGENT_NAMES.REVIEWER}** | [VERIFIER] | Verification, testing, context sanity checks |
|
|
15118
15351
|
|
|
15119
|
-
##
|
|
15352
|
+
## Parallel Execution System
|
|
15120
15353
|
\`\`\`
|
|
15121
15354
|
Up to 50 Worker Sessions running simultaneously
|
|
15122
15355
|
Max 10 per agent type (auto-queues excess)
|
|
15123
15356
|
Auto-timeout: 60 min | Auto-cleanup: 30 min
|
|
15124
15357
|
\`\`\`
|
|
15125
15358
|
|
|
15126
|
-
##
|
|
15359
|
+
## Execution Flow
|
|
15127
15360
|
\`\`\`
|
|
15128
15361
|
THINK \u2192 PLAN \u2192 DELEGATE \u2192 EXECUTE \u2192 VERIFY \u2192 COMPLETE
|
|
15129
15362
|
L1: Fast Track (simple fixes)
|
|
@@ -15131,12 +15364,12 @@ THINK \u2192 PLAN \u2192 DELEGATE \u2192 EXECUTE \u2192 VERIFY \u2192 COMPLETE
|
|
|
15131
15364
|
L3: Deep Track (complex refactoring)
|
|
15132
15365
|
\`\`\`
|
|
15133
15366
|
|
|
15134
|
-
##
|
|
15367
|
+
## Anti-Hallucination
|
|
15135
15368
|
- ${AGENT_NAMES.PLANNER} researches BEFORE implementation
|
|
15136
15369
|
- ${AGENT_NAMES.WORKER} caches official documentation
|
|
15137
15370
|
- Never assumes - always verifies from sources
|
|
15138
15371
|
|
|
15139
|
-
##
|
|
15372
|
+
## Usage
|
|
15140
15373
|
- Select **${AGENT_NAMES.COMMANDER}** and type your request
|
|
15141
15374
|
- Or use \`/task "your mission"\` explicitly
|
|
15142
15375
|
- ${AGENT_NAMES.COMMANDER} automatically coordinates all agents`
|
|
@@ -15208,9 +15441,13 @@ async function callRustTool(name, args) {
|
|
|
15208
15441
|
proc.stdout.on("data", (data) => {
|
|
15209
15442
|
stdout += data.toString();
|
|
15210
15443
|
});
|
|
15444
|
+
proc.stderr.on("data", (data) => {
|
|
15445
|
+
const msg = data.toString().trim();
|
|
15446
|
+
if (msg) console.error(`[rust-stderr] ${msg}`);
|
|
15447
|
+
});
|
|
15211
15448
|
const request = JSON.stringify({
|
|
15212
15449
|
jsonrpc: "2.0",
|
|
15213
|
-
id:
|
|
15450
|
+
id: Date.now(),
|
|
15214
15451
|
method: "tools/call",
|
|
15215
15452
|
params: { name, arguments: args }
|
|
15216
15453
|
});
|
|
@@ -15220,13 +15457,25 @@ async function callRustTool(name, args) {
|
|
|
15220
15457
|
proc.kill();
|
|
15221
15458
|
resolve(JSON.stringify({ error: "Timeout" }));
|
|
15222
15459
|
}, 6e4);
|
|
15223
|
-
proc.on("close", () => {
|
|
15460
|
+
proc.on("close", (code) => {
|
|
15224
15461
|
clearTimeout(timeout);
|
|
15462
|
+
if (code !== 0 && code !== null) {
|
|
15463
|
+
console.error(`Rust process exited with code ${code}`);
|
|
15464
|
+
}
|
|
15225
15465
|
try {
|
|
15226
15466
|
const lines = stdout.trim().split("\n");
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15467
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
15468
|
+
try {
|
|
15469
|
+
const response = JSON.parse(lines[i]);
|
|
15470
|
+
if (response.result || response.error) {
|
|
15471
|
+
const text = response?.result?.content?.[0]?.text;
|
|
15472
|
+
return resolve(text || JSON.stringify(response.result));
|
|
15473
|
+
}
|
|
15474
|
+
} catch {
|
|
15475
|
+
continue;
|
|
15476
|
+
}
|
|
15477
|
+
}
|
|
15478
|
+
resolve(stdout || "No output");
|
|
15230
15479
|
} catch {
|
|
15231
15480
|
resolve(stdout || "No output");
|
|
15232
15481
|
}
|
|
@@ -15239,12 +15488,16 @@ var grepSearchTool = (directory) => tool({
|
|
|
15239
15488
|
description: "Search code patterns using regex. Returns matching lines with file paths and line numbers.",
|
|
15240
15489
|
args: {
|
|
15241
15490
|
pattern: tool.schema.string().describe("Regex pattern to search for"),
|
|
15242
|
-
dir: tool.schema.string().optional().describe("Directory to search (defaults to project root)")
|
|
15491
|
+
dir: tool.schema.string().optional().describe("Directory to search (defaults to project root)"),
|
|
15492
|
+
max_results: tool.schema.number().optional().describe("Max results (default: 100)"),
|
|
15493
|
+
timeout_ms: tool.schema.number().optional().describe("Timeout in milliseconds (default: 30000)")
|
|
15243
15494
|
},
|
|
15244
15495
|
async execute(args) {
|
|
15245
15496
|
return callRustTool("grep_search", {
|
|
15246
15497
|
pattern: args.pattern,
|
|
15247
|
-
directory: args.dir || directory
|
|
15498
|
+
directory: args.dir || directory,
|
|
15499
|
+
max_results: args.max_results,
|
|
15500
|
+
timeout_ms: args.timeout_ms
|
|
15248
15501
|
});
|
|
15249
15502
|
}
|
|
15250
15503
|
});
|
|
@@ -15265,16 +15518,17 @@ var mgrepTool = (directory) => tool({
|
|
|
15265
15518
|
description: `Search multiple patterns (runs grep for each pattern).`,
|
|
15266
15519
|
args: {
|
|
15267
15520
|
patterns: tool.schema.array(tool.schema.string()).describe("Array of regex patterns"),
|
|
15268
|
-
dir: tool.schema.string().optional().describe("Directory (defaults to project root)")
|
|
15521
|
+
dir: tool.schema.string().optional().describe("Directory (defaults to project root)"),
|
|
15522
|
+
max_results_per_pattern: tool.schema.number().optional().describe("Max results per pattern (default: 50)"),
|
|
15523
|
+
timeout_ms: tool.schema.number().optional().describe("Timeout in milliseconds (default: 60000)")
|
|
15269
15524
|
},
|
|
15270
15525
|
async execute(args) {
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
}
|
|
15277
|
-
return JSON.stringify(results, null, 2);
|
|
15526
|
+
return callRustTool("mgrep", {
|
|
15527
|
+
patterns: args.patterns,
|
|
15528
|
+
directory: args.dir || directory,
|
|
15529
|
+
max_results_per_pattern: args.max_results_per_pattern,
|
|
15530
|
+
timeout_ms: args.timeout_ms
|
|
15531
|
+
});
|
|
15278
15532
|
}
|
|
15279
15533
|
});
|
|
15280
15534
|
var sedReplaceTool = (directory) => tool({
|
|
@@ -15285,7 +15539,8 @@ var sedReplaceTool = (directory) => tool({
|
|
|
15285
15539
|
file: tool.schema.string().optional().describe("Single file to modify"),
|
|
15286
15540
|
dir: tool.schema.string().optional().describe("Directory to search (modifies all matching files)"),
|
|
15287
15541
|
dry_run: tool.schema.boolean().optional().describe("Preview changes without modifying files (default: false)"),
|
|
15288
|
-
backup: tool.schema.boolean().optional().describe("Create .bak backup before modifying (default: false)")
|
|
15542
|
+
backup: tool.schema.boolean().optional().describe("Create .bak backup before modifying (default: false)"),
|
|
15543
|
+
timeout_ms: tool.schema.number().optional().describe("Timeout in milliseconds")
|
|
15289
15544
|
},
|
|
15290
15545
|
async execute(args) {
|
|
15291
15546
|
return callRustTool("sed_replace", {
|
|
@@ -15294,7 +15549,8 @@ var sedReplaceTool = (directory) => tool({
|
|
|
15294
15549
|
file: args.file,
|
|
15295
15550
|
directory: args.dir || (args.file ? void 0 : directory),
|
|
15296
15551
|
dry_run: args.dry_run,
|
|
15297
|
-
backup: args.backup
|
|
15552
|
+
backup: args.backup,
|
|
15553
|
+
timeout_ms: args.timeout_ms
|
|
15298
15554
|
});
|
|
15299
15555
|
}
|
|
15300
15556
|
});
|
|
@@ -15374,9 +15630,18 @@ var gitStatusTool = (directory) => tool({
|
|
|
15374
15630
|
}
|
|
15375
15631
|
});
|
|
15376
15632
|
|
|
15633
|
+
// src/core/commands/types/background-task-status.ts
|
|
15634
|
+
var BACKGROUND_TASK_STATUS = {
|
|
15635
|
+
PENDING: STATUS_LABEL.PENDING,
|
|
15636
|
+
RUNNING: STATUS_LABEL.RUNNING,
|
|
15637
|
+
DONE: STATUS_LABEL.DONE,
|
|
15638
|
+
ERROR: STATUS_LABEL.ERROR,
|
|
15639
|
+
TIMEOUT: STATUS_LABEL.TIMEOUT
|
|
15640
|
+
};
|
|
15641
|
+
|
|
15377
15642
|
// src/core/commands/manager.ts
|
|
15378
|
-
import { spawn as spawn2 } from "child_process";
|
|
15379
|
-
import { randomBytes } from "crypto";
|
|
15643
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
15644
|
+
import { randomBytes } from "node:crypto";
|
|
15380
15645
|
var BackgroundTaskManager = class _BackgroundTaskManager {
|
|
15381
15646
|
static _instance;
|
|
15382
15647
|
tasks = /* @__PURE__ */ new Map();
|
|
@@ -15403,7 +15668,7 @@ var BackgroundTaskManager = class _BackgroundTaskManager {
|
|
|
15403
15668
|
const id = this.generateId();
|
|
15404
15669
|
const { command, cwd = process.cwd(), timeout = 3e5, label } = options;
|
|
15405
15670
|
const isWindows = process.platform === "win32";
|
|
15406
|
-
const shell = isWindows ? "cmd.exe" :
|
|
15671
|
+
const shell = isWindows ? "cmd.exe" : CLI_NAME.SH;
|
|
15407
15672
|
const shellFlag = isWindows ? "/c" : "-c";
|
|
15408
15673
|
const task = {
|
|
15409
15674
|
id,
|
|
@@ -15411,7 +15676,7 @@ var BackgroundTaskManager = class _BackgroundTaskManager {
|
|
|
15411
15676
|
args: [shellFlag, command],
|
|
15412
15677
|
cwd,
|
|
15413
15678
|
label,
|
|
15414
|
-
status:
|
|
15679
|
+
status: STATUS_LABEL.RUNNING,
|
|
15415
15680
|
output: "",
|
|
15416
15681
|
errorOutput: "",
|
|
15417
15682
|
exitCode: null,
|
|
@@ -15436,27 +15701,27 @@ var BackgroundTaskManager = class _BackgroundTaskManager {
|
|
|
15436
15701
|
proc.on("close", (code) => {
|
|
15437
15702
|
task.exitCode = code;
|
|
15438
15703
|
task.endTime = Date.now();
|
|
15439
|
-
task.status = code === 0 ?
|
|
15704
|
+
task.status = code === 0 ? STATUS_LABEL.DONE : STATUS_LABEL.ERROR;
|
|
15440
15705
|
task.process = void 0;
|
|
15441
15706
|
this.debug(id, `Done (code=${code})`);
|
|
15442
15707
|
});
|
|
15443
15708
|
proc.on("error", (err) => {
|
|
15444
|
-
task.status =
|
|
15709
|
+
task.status = STATUS_LABEL.ERROR;
|
|
15445
15710
|
task.errorOutput += `
|
|
15446
15711
|
Process error: ${err.message}`;
|
|
15447
15712
|
task.endTime = Date.now();
|
|
15448
15713
|
task.process = void 0;
|
|
15449
15714
|
});
|
|
15450
15715
|
setTimeout(() => {
|
|
15451
|
-
if (task.status ===
|
|
15716
|
+
if (task.status === STATUS_LABEL.RUNNING && task.process) {
|
|
15452
15717
|
task.process.kill("SIGKILL");
|
|
15453
|
-
task.status =
|
|
15718
|
+
task.status = STATUS_LABEL.TIMEOUT;
|
|
15454
15719
|
task.endTime = Date.now();
|
|
15455
15720
|
this.debug(id, "Timeout");
|
|
15456
15721
|
}
|
|
15457
15722
|
}, timeout);
|
|
15458
15723
|
} catch (err) {
|
|
15459
|
-
task.status =
|
|
15724
|
+
task.status = STATUS_LABEL.ERROR;
|
|
15460
15725
|
task.errorOutput = `Spawn failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
15461
15726
|
task.endTime = Date.now();
|
|
15462
15727
|
}
|
|
@@ -15474,7 +15739,7 @@ Process error: ${err.message}`;
|
|
|
15474
15739
|
clearCompleted() {
|
|
15475
15740
|
let count = 0;
|
|
15476
15741
|
for (const [id, task] of this.tasks) {
|
|
15477
|
-
if (task.status !==
|
|
15742
|
+
if (task.status !== STATUS_LABEL.RUNNING && task.status !== STATUS_LABEL.PENDING) {
|
|
15478
15743
|
this.tasks.delete(id);
|
|
15479
15744
|
count++;
|
|
15480
15745
|
}
|
|
@@ -15485,7 +15750,7 @@ Process error: ${err.message}`;
|
|
|
15485
15750
|
const task = this.tasks.get(taskId);
|
|
15486
15751
|
if (task?.process) {
|
|
15487
15752
|
task.process.kill("SIGKILL");
|
|
15488
|
-
task.status =
|
|
15753
|
+
task.status = STATUS_LABEL.ERROR;
|
|
15489
15754
|
task.errorOutput += "\nKilled by user";
|
|
15490
15755
|
task.endTime = Date.now();
|
|
15491
15756
|
return true;
|
|
@@ -15499,7 +15764,7 @@ Process error: ${err.message}`;
|
|
|
15499
15764
|
return `${Math.floor(seconds / 60)}m ${(seconds % 60).toFixed(0)}s`;
|
|
15500
15765
|
}
|
|
15501
15766
|
getStatusEmoji(status) {
|
|
15502
|
-
return
|
|
15767
|
+
return getStatusIndicator(status);
|
|
15503
15768
|
}
|
|
15504
15769
|
};
|
|
15505
15770
|
var backgroundTaskManager = BackgroundTaskManager.instance;
|
|
@@ -16261,17 +16526,17 @@ var TaskToastManager = class {
|
|
|
16261
16526
|
lines.push(`Running (${running.length}):${concurrencyInfo}`);
|
|
16262
16527
|
for (const task of running) {
|
|
16263
16528
|
const duration3 = this.formatDuration(task.startedAt);
|
|
16264
|
-
const
|
|
16265
|
-
const isNew = newTask && task.id === newTask.id ? "
|
|
16266
|
-
lines.push(`${
|
|
16529
|
+
const bgTag = task.isBackground ? "[B]" : "[F]";
|
|
16530
|
+
const isNew = newTask && task.id === newTask.id ? " <- NEW" : "";
|
|
16531
|
+
lines.push(`${bgTag} ${task.description} (${task.agent}) - ${duration3}${isNew}`);
|
|
16267
16532
|
}
|
|
16268
16533
|
}
|
|
16269
16534
|
if (queued.length > 0) {
|
|
16270
16535
|
if (lines.length > 0) lines.push("");
|
|
16271
16536
|
lines.push(`Queued (${queued.length}):`);
|
|
16272
16537
|
for (const task of queued) {
|
|
16273
|
-
const
|
|
16274
|
-
lines.push(`${
|
|
16538
|
+
const bgTag = task.isBackground ? "[W]" : "[P]";
|
|
16539
|
+
lines.push(`${bgTag} ${task.description} (${task.agent})`);
|
|
16275
16540
|
}
|
|
16276
16541
|
}
|
|
16277
16542
|
return lines.join("\n");
|
|
@@ -16286,7 +16551,7 @@ var TaskToastManager = class {
|
|
|
16286
16551
|
const message = this.buildTaskListMessage(newTask);
|
|
16287
16552
|
const running = this.getRunningTasks();
|
|
16288
16553
|
const queued = this.getQueuedTasks();
|
|
16289
|
-
const title = newTask.isBackground ?
|
|
16554
|
+
const title = newTask.isBackground ? `Background Task Started` : `Task Started`;
|
|
16290
16555
|
tuiClient2.tui.showToast({
|
|
16291
16556
|
body: {
|
|
16292
16557
|
title,
|
|
@@ -16312,12 +16577,12 @@ var TaskToastManager = class {
|
|
|
16312
16577
|
let variant;
|
|
16313
16578
|
if (info.status === "error" || info.status === "cancelled") {
|
|
16314
16579
|
title = info.status === "error" ? "Task Failed" : "Task Cancelled";
|
|
16315
|
-
message =
|
|
16580
|
+
message = `[FAIL] "${info.description}" ${info.status}
|
|
16316
16581
|
${info.error || ""}`;
|
|
16317
16582
|
variant = "error";
|
|
16318
16583
|
} else {
|
|
16319
16584
|
title = "Task Completed";
|
|
16320
|
-
message =
|
|
16585
|
+
message = `[DONE] "${info.description}" finished in ${info.duration}`;
|
|
16321
16586
|
variant = "success";
|
|
16322
16587
|
}
|
|
16323
16588
|
if (remaining.length > 0 || queued.length > 0) {
|
|
@@ -16344,10 +16609,10 @@ Still running: ${remaining.length} | Queued: ${queued.length}`;
|
|
|
16344
16609
|
if (!tuiClient2.tui?.showToast) return;
|
|
16345
16610
|
const successCount = completedTasks.filter((t) => t.status === TASK_STATUS.COMPLETED).length;
|
|
16346
16611
|
const failCount = completedTasks.filter((t) => t.status === TASK_STATUS.ERROR || t.status === TASK_STATUS.CANCELLED).length;
|
|
16347
|
-
const taskList = completedTasks.map((t) => `- ${t.status === TASK_STATUS.COMPLETED ? "
|
|
16612
|
+
const taskList = completedTasks.map((t) => `- [${t.status === TASK_STATUS.COMPLETED ? "OK" : "FAIL"}] ${t.description} (${t.duration})`).join("\n");
|
|
16348
16613
|
tuiClient2.tui.showToast({
|
|
16349
16614
|
body: {
|
|
16350
|
-
title: "
|
|
16615
|
+
title: "All Tasks Completed",
|
|
16351
16616
|
message: `${successCount} succeeded, ${failCount} failed
|
|
16352
16617
|
|
|
16353
16618
|
${taskList}`,
|
|
@@ -16367,10 +16632,10 @@ ${taskList}`,
|
|
|
16367
16632
|
const task = this.tasks.get(taskId);
|
|
16368
16633
|
if (!task) return;
|
|
16369
16634
|
const percentage = Math.round(progress.current / progress.total * 100);
|
|
16370
|
-
const progressBar = `[${"
|
|
16635
|
+
const progressBar = `[${"#".repeat(Math.floor(percentage / 10))}${"-".repeat(10 - Math.floor(percentage / 10))}]`;
|
|
16371
16636
|
tuiClient2.tui.showToast({
|
|
16372
16637
|
body: {
|
|
16373
|
-
title:
|
|
16638
|
+
title: `Task Progress: ${task.description}`,
|
|
16374
16639
|
message: `${progressBar} ${percentage}%
|
|
16375
16640
|
${progress.message || ""}`,
|
|
16376
16641
|
variant: "info",
|
|
@@ -17036,7 +17301,7 @@ async function validateSessionHasOutput(session, sessionID) {
|
|
|
17036
17301
|
});
|
|
17037
17302
|
return hasContent;
|
|
17038
17303
|
} catch (error45) {
|
|
17039
|
-
log2(
|
|
17304
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Error validating session output:`, error45);
|
|
17040
17305
|
return true;
|
|
17041
17306
|
}
|
|
17042
17307
|
}
|
|
@@ -17050,11 +17315,11 @@ async function pollWithSafetyLimits(session, sessionID, startTime) {
|
|
|
17050
17315
|
pollCount++;
|
|
17051
17316
|
const elapsed = Date.now() - startTime;
|
|
17052
17317
|
if (elapsed >= SYNC_TIMEOUT_MS) {
|
|
17053
|
-
log2(
|
|
17318
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Hard timeout reached`, { pollCount, elapsed });
|
|
17054
17319
|
return { success: false, timedOut: true, pollCount, elapsedMs: elapsed };
|
|
17055
17320
|
}
|
|
17056
17321
|
if (Date.now() - lastLogTime > 1e4) {
|
|
17057
|
-
log2(
|
|
17322
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Polling...`, {
|
|
17058
17323
|
pollCount,
|
|
17059
17324
|
elapsed: Math.floor(elapsed / 1e3) + "s",
|
|
17060
17325
|
stablePolls,
|
|
@@ -17082,14 +17347,14 @@ async function pollWithSafetyLimits(session, sessionID, startTime) {
|
|
|
17082
17347
|
if (!hasValidOutput) {
|
|
17083
17348
|
continue;
|
|
17084
17349
|
}
|
|
17085
|
-
log2(
|
|
17350
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Valid output detected`, { pollCount, elapsed });
|
|
17086
17351
|
}
|
|
17087
17352
|
const msgs = await session.messages({ path: { id: sessionID } });
|
|
17088
17353
|
const count = (msgs.data ?? []).length;
|
|
17089
17354
|
if (count === lastMsgCount) {
|
|
17090
17355
|
stablePolls++;
|
|
17091
17356
|
if (stablePolls >= STABLE_POLLS_REQUIRED) {
|
|
17092
|
-
log2(
|
|
17357
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Stable completion`, { pollCount, stablePolls, elapsed });
|
|
17093
17358
|
return { success: true, timedOut: false, pollCount, elapsedMs: elapsed };
|
|
17094
17359
|
}
|
|
17095
17360
|
} else {
|
|
@@ -17097,10 +17362,10 @@ async function pollWithSafetyLimits(session, sessionID, startTime) {
|
|
|
17097
17362
|
lastMsgCount = count;
|
|
17098
17363
|
}
|
|
17099
17364
|
} catch (error45) {
|
|
17100
|
-
log2(
|
|
17365
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Poll error (continuing):`, error45);
|
|
17101
17366
|
}
|
|
17102
17367
|
}
|
|
17103
|
-
log2(
|
|
17368
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Max poll count reached`, { pollCount, elapsed: Date.now() - startTime });
|
|
17104
17369
|
return {
|
|
17105
17370
|
success: false,
|
|
17106
17371
|
timedOut: true,
|
|
@@ -17117,7 +17382,7 @@ async function extractSessionResult(session, sessionID) {
|
|
|
17117
17382
|
const text = lastMsg?.parts?.filter((p) => p.type === PART_TYPES.TEXT || p.type === PART_TYPES.REASONING).map((p) => p.text ?? "").join("\n") || "";
|
|
17118
17383
|
return text;
|
|
17119
17384
|
} catch (error45) {
|
|
17120
|
-
log2(
|
|
17385
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Error extracting result:`, error45);
|
|
17121
17386
|
return "(Error extracting result)";
|
|
17122
17387
|
}
|
|
17123
17388
|
}
|
|
@@ -17150,10 +17415,10 @@ var createDelegateTaskTool = (manager, client) => tool({
|
|
|
17150
17415
|
async execute(args, context) {
|
|
17151
17416
|
const { agent, description, prompt, background, resume } = args;
|
|
17152
17417
|
const ctx = context;
|
|
17153
|
-
log2(
|
|
17418
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} execute() called`, { agent, description, background, resume, parentSession: ctx.sessionID });
|
|
17154
17419
|
const sessionClient = client;
|
|
17155
17420
|
if (background === void 0) {
|
|
17156
|
-
return
|
|
17421
|
+
return `${OUTPUT_LABEL.ERROR} 'background' parameter is REQUIRED.`;
|
|
17157
17422
|
}
|
|
17158
17423
|
if (resume) {
|
|
17159
17424
|
try {
|
|
@@ -17163,24 +17428,24 @@ var createDelegateTaskTool = (manager, client) => tool({
|
|
|
17163
17428
|
parentSessionID: ctx.sessionID
|
|
17164
17429
|
});
|
|
17165
17430
|
if (background === true) {
|
|
17166
|
-
return
|
|
17431
|
+
return `${OUTPUT_LABEL.RESUME} task: \`${task.id}\` (${task.agent}) in session \`${task.sessionID}\`
|
|
17167
17432
|
|
|
17168
17433
|
Previous context preserved. Use \`get_task_result({ taskId: "${task.id}" })\` when complete.`;
|
|
17169
17434
|
}
|
|
17170
17435
|
const startTime = Date.now();
|
|
17171
17436
|
const session = sessionClient.session;
|
|
17172
|
-
log2(
|
|
17437
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Resume: starting sync wait`, { taskId: task.id, sessionID: task.sessionID });
|
|
17173
17438
|
const pollResult = await pollWithSafetyLimits(session, task.sessionID, startTime);
|
|
17174
17439
|
if (pollResult.timedOut) {
|
|
17175
|
-
return
|
|
17440
|
+
return `${OUTPUT_LABEL.TIMEOUT} after ${Math.floor(pollResult.elapsedMs / 1e3)}s (${pollResult.pollCount} polls)
|
|
17176
17441
|
Session: \`${task.sessionID}\` - Use get_task_result or resume later.`;
|
|
17177
17442
|
}
|
|
17178
17443
|
const text = await extractSessionResult(session, task.sessionID);
|
|
17179
|
-
return
|
|
17444
|
+
return `${OUTPUT_LABEL.RESUMED_DONE} (${Math.floor(pollResult.elapsedMs / 1e3)}s)
|
|
17180
17445
|
|
|
17181
17446
|
${text || "(No output)"}`;
|
|
17182
17447
|
} catch (error45) {
|
|
17183
|
-
return
|
|
17448
|
+
return `${OUTPUT_LABEL.ERROR} Resume failed: ${error45 instanceof Error ? error45.message : String(error45)}`;
|
|
17184
17449
|
}
|
|
17185
17450
|
}
|
|
17186
17451
|
if (background === true) {
|
|
@@ -17192,10 +17457,10 @@ ${text || "(No output)"}`;
|
|
|
17192
17457
|
parentSessionID: ctx.sessionID
|
|
17193
17458
|
});
|
|
17194
17459
|
presets.taskStarted(task.id, agent);
|
|
17195
|
-
return
|
|
17460
|
+
return `${OUTPUT_LABEL.SPAWNED} task: \`${task.id}\` (${agent})
|
|
17196
17461
|
Session: \`${task.sessionID}\` (save for resume)`;
|
|
17197
17462
|
} catch (error45) {
|
|
17198
|
-
return
|
|
17463
|
+
return `${OUTPUT_LABEL.ERROR} Failed: ${error45 instanceof Error ? error45.message : String(error45)}`;
|
|
17199
17464
|
}
|
|
17200
17465
|
}
|
|
17201
17466
|
try {
|
|
@@ -17205,11 +17470,11 @@ Session: \`${task.sessionID}\` (save for resume)`;
|
|
|
17205
17470
|
query: { directory: "." }
|
|
17206
17471
|
});
|
|
17207
17472
|
if (createResult.error || !createResult.data?.id) {
|
|
17208
|
-
return
|
|
17473
|
+
return `${OUTPUT_LABEL.ERROR} Failed to create session: ${createResult.error || "No session ID returned"}`;
|
|
17209
17474
|
}
|
|
17210
17475
|
const sessionID = createResult.data.id;
|
|
17211
17476
|
const startTime = Date.now();
|
|
17212
|
-
log2(
|
|
17477
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Sync: starting`, { agent, sessionID });
|
|
17213
17478
|
await session.prompt({
|
|
17214
17479
|
path: { id: sessionID },
|
|
17215
17480
|
body: {
|
|
@@ -17225,19 +17490,19 @@ Session: \`${task.sessionID}\` (save for resume)`;
|
|
|
17225
17490
|
});
|
|
17226
17491
|
const pollResult = await pollWithSafetyLimits(session, sessionID, startTime);
|
|
17227
17492
|
if (pollResult.timedOut) {
|
|
17228
|
-
log2(
|
|
17229
|
-
return
|
|
17493
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Sync: timed out`, pollResult);
|
|
17494
|
+
return `${OUTPUT_LABEL.TIMEOUT} after ${Math.floor(pollResult.elapsedMs / 1e3)}s (${pollResult.pollCount} polls)
|
|
17230
17495
|
Session: \`${sessionID}\` - Use get_task_result or resume later.`;
|
|
17231
17496
|
}
|
|
17232
17497
|
const text = await extractSessionResult(session, sessionID);
|
|
17233
|
-
log2(
|
|
17234
|
-
return
|
|
17498
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Sync: completed`, { sessionID, elapsedMs: pollResult.elapsedMs });
|
|
17499
|
+
return `${OUTPUT_LABEL.DONE} (${Math.floor(pollResult.elapsedMs / 1e3)}s)
|
|
17235
17500
|
Session: \`${sessionID}\` (save for resume)
|
|
17236
17501
|
|
|
17237
17502
|
${text || "(No output)"}`;
|
|
17238
17503
|
} catch (error45) {
|
|
17239
|
-
log2(
|
|
17240
|
-
return
|
|
17504
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Sync: error`, error45);
|
|
17505
|
+
return `${OUTPUT_LABEL.ERROR} Failed: ${error45 instanceof Error ? error45.message : String(error45)}`;
|
|
17241
17506
|
}
|
|
17242
17507
|
}
|
|
17243
17508
|
});
|
|
@@ -17250,14 +17515,14 @@ var createGetTaskResultTool = (manager) => tool({
|
|
|
17250
17515
|
},
|
|
17251
17516
|
async execute(args) {
|
|
17252
17517
|
const task = manager.getTask(args.taskId);
|
|
17253
|
-
if (!task) return
|
|
17254
|
-
if (task.status ===
|
|
17518
|
+
if (!task) return `${OUTPUT_LABEL.ERROR} Task not found: \`${args.taskId}\``;
|
|
17519
|
+
if (task.status === STATUS_LABEL.RUNNING) return `${OUTPUT_LABEL.RUNNING} Still working...`;
|
|
17255
17520
|
const result = await manager.getResult(args.taskId);
|
|
17256
17521
|
const duration3 = manager.formatDuration(task.startedAt, task.completedAt);
|
|
17257
|
-
if (task.status ===
|
|
17258
|
-
return
|
|
17522
|
+
if (task.status === STATUS_LABEL.ERROR || task.status === STATUS_LABEL.TIMEOUT) {
|
|
17523
|
+
return `[${task.status.toUpperCase()}] ${task.error}`;
|
|
17259
17524
|
}
|
|
17260
|
-
return
|
|
17525
|
+
return `${OUTPUT_LABEL.DONE} Completed in ${duration3}
|
|
17261
17526
|
|
|
17262
17527
|
${result || "(No output)"}`;
|
|
17263
17528
|
}
|
|
@@ -17270,27 +17535,27 @@ var createListTasksTool = (manager) => tool({
|
|
|
17270
17535
|
status: tool.schema.string().optional().describe("Filter: all, running, completed, error")
|
|
17271
17536
|
},
|
|
17272
17537
|
async execute(args) {
|
|
17273
|
-
const { status =
|
|
17538
|
+
const { status = STATUS_LABEL.ALL } = args;
|
|
17274
17539
|
let tasks;
|
|
17275
17540
|
switch (status) {
|
|
17276
|
-
case
|
|
17541
|
+
case STATUS_LABEL.RUNNING:
|
|
17277
17542
|
tasks = manager.getRunningTasks();
|
|
17278
17543
|
break;
|
|
17279
|
-
case
|
|
17544
|
+
case STATUS_LABEL.COMPLETED:
|
|
17280
17545
|
tasks = manager.getAllTasks().filter((t) => t.status === TASK_STATUS.COMPLETED);
|
|
17281
17546
|
break;
|
|
17282
|
-
case
|
|
17547
|
+
case STATUS_LABEL.ERROR:
|
|
17283
17548
|
tasks = manager.getAllTasks().filter((t) => t.status === TASK_STATUS.ERROR || t.status === TASK_STATUS.TIMEOUT);
|
|
17284
17549
|
break;
|
|
17285
17550
|
default:
|
|
17286
17551
|
tasks = manager.getAllTasks();
|
|
17287
17552
|
}
|
|
17288
|
-
if (tasks.length === 0) return
|
|
17553
|
+
if (tasks.length === 0) return `No tasks found.`;
|
|
17289
17554
|
const rows = tasks.map((t) => {
|
|
17290
17555
|
const elapsed = Math.floor((Date.now() - t.startedAt.getTime()) / 1e3);
|
|
17291
|
-
return `| \`${t.id}\` | ${
|
|
17556
|
+
return `| \`${t.id}\` | [${t.status.toUpperCase()}] | ${t.agent} | ${elapsed}s |`;
|
|
17292
17557
|
}).join("\n");
|
|
17293
|
-
return
|
|
17558
|
+
return `**Tasks List**
|
|
17294
17559
|
|
|
17295
17560
|
| ID | Status | Agent | Time |
|
|
17296
17561
|
|----|--------|-------|------|
|
|
@@ -17306,23 +17571,67 @@ var createCancelTaskTool = (manager) => tool({
|
|
|
17306
17571
|
},
|
|
17307
17572
|
async execute(args) {
|
|
17308
17573
|
const cancelled = await manager.cancelTask(args.taskId);
|
|
17309
|
-
if (cancelled) return
|
|
17574
|
+
if (cancelled) return `${OUTPUT_LABEL.CANCELLED} task: \`${args.taskId}\``;
|
|
17310
17575
|
const task = manager.getTask(args.taskId);
|
|
17311
|
-
if (task) return
|
|
17312
|
-
return
|
|
17576
|
+
if (task) return `${OUTPUT_LABEL.WARNING} Cannot cancel: Task is ${task.status}`;
|
|
17577
|
+
return `${OUTPUT_LABEL.ERROR} Not found: \`${args.taskId}\``;
|
|
17313
17578
|
}
|
|
17314
17579
|
});
|
|
17315
17580
|
|
|
17316
17581
|
// src/tools/parallel/index.ts
|
|
17317
17582
|
function createAsyncAgentTools(manager, client) {
|
|
17318
17583
|
return {
|
|
17319
|
-
|
|
17320
|
-
|
|
17321
|
-
|
|
17322
|
-
|
|
17584
|
+
[TOOL_NAMES.DELEGATE_TASK]: createDelegateTaskTool(manager, client),
|
|
17585
|
+
[TOOL_NAMES.GET_TASK_RESULT]: createGetTaskResultTool(manager),
|
|
17586
|
+
[TOOL_NAMES.LIST_TASKS]: createListTasksTool(manager),
|
|
17587
|
+
[TOOL_NAMES.CANCEL_TASK]: createCancelTaskTool(manager)
|
|
17323
17588
|
};
|
|
17324
17589
|
}
|
|
17325
17590
|
|
|
17591
|
+
// src/tools/ast/index.ts
|
|
17592
|
+
var astSearchTool = (directory) => tool({
|
|
17593
|
+
description: `Perform structural search using ast-grep.
|
|
17594
|
+
Find code patterns based on syntax (e.g., 'function $NAME($$$ARGS) { $$$BODY }').
|
|
17595
|
+
|
|
17596
|
+
<patterns>
|
|
17597
|
+
- $NAME: Matches a single identifier
|
|
17598
|
+
- $$$ARGS: Matches multiple arguments/elements
|
|
17599
|
+
- Use '___' for wildcards
|
|
17600
|
+
</patterns>`,
|
|
17601
|
+
args: {
|
|
17602
|
+
pattern: tool.schema.string().describe("Structural pattern to search for"),
|
|
17603
|
+
lang: tool.schema.string().optional().describe("Language (typescript, javascript, json, etc. default: typescript)"),
|
|
17604
|
+
include: tool.schema.string().optional().describe("Glob pattern for files to include")
|
|
17605
|
+
},
|
|
17606
|
+
async execute(args) {
|
|
17607
|
+
return callRustTool("ast_search", {
|
|
17608
|
+
pattern: args.pattern,
|
|
17609
|
+
directory,
|
|
17610
|
+
lang: args.lang,
|
|
17611
|
+
include: args.include
|
|
17612
|
+
});
|
|
17613
|
+
}
|
|
17614
|
+
});
|
|
17615
|
+
var astReplaceTool = (directory) => tool({
|
|
17616
|
+
description: `Perform structural search and replace using ast-grep.
|
|
17617
|
+
Safely refactor code across files using syntax patterns.`,
|
|
17618
|
+
args: {
|
|
17619
|
+
pattern: tool.schema.string().describe("Pattern to find"),
|
|
17620
|
+
rewrite: tool.schema.string().describe("Replacement pattern (use $ placeholders)"),
|
|
17621
|
+
lang: tool.schema.string().optional().describe("Language (typescript, javascript, etc. default: typescript)"),
|
|
17622
|
+
include: tool.schema.string().optional().describe("Glob pattern for files")
|
|
17623
|
+
},
|
|
17624
|
+
async execute(args) {
|
|
17625
|
+
return callRustTool("ast_replace", {
|
|
17626
|
+
pattern: args.pattern,
|
|
17627
|
+
rewrite: args.rewrite,
|
|
17628
|
+
directory,
|
|
17629
|
+
lang: args.lang,
|
|
17630
|
+
include: args.include
|
|
17631
|
+
});
|
|
17632
|
+
}
|
|
17633
|
+
});
|
|
17634
|
+
|
|
17326
17635
|
// src/core/cache/constants.ts
|
|
17327
17636
|
var CACHE_DIR = PATHS.DOCS;
|
|
17328
17637
|
var METADATA_FILE = PATHS.DOC_METADATA;
|
|
@@ -17526,7 +17835,7 @@ webfetch({ url: "https://react.dev/reference/react/useEffect", cache: true })
|
|
|
17526
17835
|
if (cache) {
|
|
17527
17836
|
const cached2 = await get(url2);
|
|
17528
17837
|
if (cached2) {
|
|
17529
|
-
return
|
|
17838
|
+
return `${OUTPUT_LABEL.CACHED} (fetched: ${cached2.fetchedAt})
|
|
17530
17839
|
|
|
17531
17840
|
${cached2.content}`;
|
|
17532
17841
|
}
|
|
@@ -17541,7 +17850,7 @@ ${cached2.content}`;
|
|
|
17541
17850
|
// 30 second timeout
|
|
17542
17851
|
});
|
|
17543
17852
|
if (!response.ok) {
|
|
17544
|
-
return
|
|
17853
|
+
return `Failed to fetch: HTTP ${response.status} ${response.statusText}`;
|
|
17545
17854
|
}
|
|
17546
17855
|
const contentType = response.headers.get("content-type") || "";
|
|
17547
17856
|
const html = await response.text();
|
|
@@ -17549,13 +17858,13 @@ ${cached2.content}`;
|
|
|
17549
17858
|
const content = JSON.stringify(JSON.parse(html), null, 2);
|
|
17550
17859
|
if (cache) {
|
|
17551
17860
|
const filename = await set2(url2, content, "JSON Response");
|
|
17552
|
-
return
|
|
17861
|
+
return `${OUTPUT_LABEL.JSON_FETCHED} (cached: ${PATHS.DOCS}/${filename})
|
|
17553
17862
|
|
|
17554
17863
|
\`\`\`json
|
|
17555
17864
|
${content.slice(0, 5e3)}
|
|
17556
17865
|
\`\`\``;
|
|
17557
17866
|
}
|
|
17558
|
-
return
|
|
17867
|
+
return `${OUTPUT_LABEL.JSON_FETCHED}
|
|
17559
17868
|
|
|
17560
17869
|
\`\`\`json
|
|
17561
17870
|
${content.slice(0, 5e3)}
|
|
@@ -17564,11 +17873,11 @@ ${content.slice(0, 5e3)}
|
|
|
17564
17873
|
if (contentType.includes("text/plain")) {
|
|
17565
17874
|
if (cache) {
|
|
17566
17875
|
const filename = await set2(url2, html, "Plain Text");
|
|
17567
|
-
return
|
|
17876
|
+
return `${OUTPUT_LABEL.TEXT_FETCHED} (cached: ${PATHS.DOCS}/${filename})
|
|
17568
17877
|
|
|
17569
17878
|
${html.slice(0, 1e4)}`;
|
|
17570
17879
|
}
|
|
17571
|
-
return
|
|
17880
|
+
return `${OUTPUT_LABEL.TEXT_FETCHED}
|
|
17572
17881
|
|
|
17573
17882
|
${html.slice(0, 1e4)}`;
|
|
17574
17883
|
}
|
|
@@ -17578,7 +17887,7 @@ ${html.slice(0, 1e4)}`;
|
|
|
17578
17887
|
const truncated = markdown.length > 15e3 ? markdown.slice(0, 15e3) + "\n\n... [Content truncated]" : markdown;
|
|
17579
17888
|
if (cache) {
|
|
17580
17889
|
const filename = await set2(url2, truncated, title);
|
|
17581
|
-
return
|
|
17890
|
+
return `[${title}]
|
|
17582
17891
|
Source: ${url2}
|
|
17583
17892
|
Cached: ${PATHS.DOCS}/${filename}
|
|
17584
17893
|
|
|
@@ -17586,7 +17895,7 @@ Cached: ${PATHS.DOCS}/${filename}
|
|
|
17586
17895
|
|
|
17587
17896
|
${truncated}`;
|
|
17588
17897
|
}
|
|
17589
|
-
return
|
|
17898
|
+
return `[${title}]
|
|
17590
17899
|
Source: ${url2}
|
|
17591
17900
|
|
|
17592
17901
|
---
|
|
@@ -17595,11 +17904,11 @@ ${truncated}`;
|
|
|
17595
17904
|
} catch (error45) {
|
|
17596
17905
|
if (error45 instanceof Error) {
|
|
17597
17906
|
if (error45.name === "TimeoutError") {
|
|
17598
|
-
return
|
|
17907
|
+
return `${OUTPUT_LABEL.TIMEOUT} Request timed out after 30 seconds`;
|
|
17599
17908
|
}
|
|
17600
|
-
return
|
|
17909
|
+
return `${OUTPUT_LABEL.ERROR} Fetch error: ${error45.message}`;
|
|
17601
17910
|
}
|
|
17602
|
-
return
|
|
17911
|
+
return `${OUTPUT_LABEL.ERROR} Unknown error occurred`;
|
|
17603
17912
|
}
|
|
17604
17913
|
}
|
|
17605
17914
|
});
|
|
@@ -17817,7 +18126,7 @@ websearch({ query: "TypeScript generic constraints site:typescriptlang.org" })
|
|
|
17817
18126
|
}
|
|
17818
18127
|
}
|
|
17819
18128
|
if (results.length === 0) {
|
|
17820
|
-
return
|
|
18129
|
+
return `No results found for: "${query}"
|
|
17821
18130
|
|
|
17822
18131
|
Try:
|
|
17823
18132
|
- Different keywords
|
|
@@ -17826,10 +18135,10 @@ Try:
|
|
|
17826
18135
|
- Add "docs" or "official" for documentation`;
|
|
17827
18136
|
}
|
|
17828
18137
|
const limitedResults = results.slice(0, maxResults);
|
|
17829
|
-
let output =
|
|
18138
|
+
let output = `[Web Search Results for]: "${query}"
|
|
17830
18139
|
|
|
17831
18140
|
`;
|
|
17832
|
-
output +=
|
|
18141
|
+
output += `Provider: ${provider} | Found ${results.length} results (showing ${limitedResults.length})
|
|
17833
18142
|
|
|
17834
18143
|
---
|
|
17835
18144
|
|
|
@@ -17838,7 +18147,7 @@ Try:
|
|
|
17838
18147
|
const result = limitedResults[i];
|
|
17839
18148
|
output += `### ${i + 1}. ${result.title}
|
|
17840
18149
|
`;
|
|
17841
|
-
output +=
|
|
18150
|
+
output += `URL: ${result.url}
|
|
17842
18151
|
|
|
17843
18152
|
`;
|
|
17844
18153
|
if (result.snippet) {
|
|
@@ -17850,7 +18159,7 @@ Try:
|
|
|
17850
18159
|
output += `---
|
|
17851
18160
|
|
|
17852
18161
|
`;
|
|
17853
|
-
output +=
|
|
18162
|
+
output += `Tip: Use \`webfetch\` to get full content from any of these URLs.`;
|
|
17854
18163
|
return output;
|
|
17855
18164
|
}
|
|
17856
18165
|
});
|
|
@@ -18066,14 +18375,14 @@ codesearch({ query: "next.js middleware redirect", repo: "vercel/next.js" })
|
|
|
18066
18375
|
results = await searchGitHub(query, { language });
|
|
18067
18376
|
}
|
|
18068
18377
|
if (results.length === 0) {
|
|
18069
|
-
return
|
|
18378
|
+
return `No code results found for: "${query}"
|
|
18070
18379
|
|
|
18071
18380
|
Try:
|
|
18072
18381
|
- Different search terms
|
|
18073
18382
|
- Broader language filter
|
|
18074
18383
|
- Check spelling`;
|
|
18075
18384
|
}
|
|
18076
|
-
let output =
|
|
18385
|
+
let output = `[Code Search Results for]: "${query}"
|
|
18077
18386
|
|
|
18078
18387
|
`;
|
|
18079
18388
|
output += `Found ${results.length} results${language ? ` (${language})` : ""}
|
|
@@ -18085,9 +18394,9 @@ Try:
|
|
|
18085
18394
|
const r = results[i];
|
|
18086
18395
|
output += `### ${i + 1}. ${r.repo}
|
|
18087
18396
|
`;
|
|
18088
|
-
output +=
|
|
18397
|
+
output += `Path: \`${r.file}\`${r.line ? `:${r.line}` : ""}
|
|
18089
18398
|
`;
|
|
18090
|
-
output +=
|
|
18399
|
+
output += `URL: ${r.url}
|
|
18091
18400
|
|
|
18092
18401
|
`;
|
|
18093
18402
|
if (r.content && r.content !== "(Use webfetch for full content)") {
|
|
@@ -18101,11 +18410,36 @@ ${r.content}
|
|
|
18101
18410
|
output += `---
|
|
18102
18411
|
|
|
18103
18412
|
`;
|
|
18104
|
-
output +=
|
|
18413
|
+
output += `Tip: Use \`webfetch\` to get the full file content from any of these URLs.`;
|
|
18105
18414
|
return output;
|
|
18106
18415
|
}
|
|
18107
18416
|
});
|
|
18108
18417
|
|
|
18418
|
+
// src/tools/lsp/index.ts
|
|
18419
|
+
var lspDiagnosticsTool = (directory) => tool({
|
|
18420
|
+
description: `Get LSP diagnostics (errors/warnings) for files.
|
|
18421
|
+
|
|
18422
|
+
Use this BEFORE marking a task complete to verify code quality.
|
|
18423
|
+
Runs TypeScript compiler and/or ESLint to find issues.
|
|
18424
|
+
|
|
18425
|
+
<when_to_use>
|
|
18426
|
+
- After editing files, before claiming "done"
|
|
18427
|
+
- Before marking todo items complete
|
|
18428
|
+
- To check for type errors without full build
|
|
18429
|
+
</when_to_use>`,
|
|
18430
|
+
args: {
|
|
18431
|
+
file: tool.schema.string().optional().describe("File path to check (or '*' for all files)"),
|
|
18432
|
+
include_warnings: tool.schema.boolean().optional().describe("Include warnings (default: true)")
|
|
18433
|
+
},
|
|
18434
|
+
async execute(args) {
|
|
18435
|
+
return callRustTool("lsp_diagnostics", {
|
|
18436
|
+
directory,
|
|
18437
|
+
file: args.file,
|
|
18438
|
+
include_warnings: args.include_warnings
|
|
18439
|
+
});
|
|
18440
|
+
}
|
|
18441
|
+
});
|
|
18442
|
+
|
|
18109
18443
|
// src/core/progress/store.ts
|
|
18110
18444
|
var progressHistory = /* @__PURE__ */ new Map();
|
|
18111
18445
|
var sessionStartTimes = /* @__PURE__ */ new Map();
|
|
@@ -18472,14 +18806,14 @@ function generateContinuationPrompt(todos) {
|
|
|
18472
18806
|
const pendingTasks = incomplete.filter((t) => t.status === TODO_STATUS.PENDING);
|
|
18473
18807
|
const pendingCount = pendingTasks.length;
|
|
18474
18808
|
let prompt = `<todo_continuation>
|
|
18475
|
-
|
|
18809
|
+
[TODO Progress]: ${formatProgress(todos)}
|
|
18476
18810
|
|
|
18477
18811
|
**Incomplete Tasks** (${incomplete.length} remaining):
|
|
18478
18812
|
`;
|
|
18479
18813
|
for (const todo of incomplete.slice(0, 5)) {
|
|
18480
|
-
const
|
|
18481
|
-
const
|
|
18482
|
-
prompt += `${
|
|
18814
|
+
const statusLabel = todo.status === TODO_STATUS.IN_PROGRESS ? "[RUN]" : "[WAIT]";
|
|
18815
|
+
const priorityLabel = todo.priority === STATUS_LABEL.HIGH ? "[H]" : todo.priority === STATUS_LABEL.MEDIUM ? "[M]" : "[L]";
|
|
18816
|
+
prompt += `${statusLabel} ${priorityLabel} [${todo.id}] ${todo.content}
|
|
18483
18817
|
`;
|
|
18484
18818
|
}
|
|
18485
18819
|
if (incomplete.length > 5) {
|
|
@@ -18488,19 +18822,19 @@ function generateContinuationPrompt(todos) {
|
|
|
18488
18822
|
}
|
|
18489
18823
|
if (pendingCount >= 2) {
|
|
18490
18824
|
prompt += `
|
|
18491
|
-
|
|
18825
|
+
[PARALLEL DISPATCH REQUIRED]
|
|
18492
18826
|
You have ${pendingCount} pending tasks. Launch them ALL IN PARALLEL for maximum efficiency:
|
|
18493
18827
|
|
|
18494
18828
|
\`\`\`
|
|
18495
18829
|
// EXECUTE NOW - Launch all ${pendingCount} tasks simultaneously:
|
|
18496
18830
|
`;
|
|
18497
18831
|
for (const todo of pendingTasks.slice(0, 6)) {
|
|
18498
|
-
prompt += `delegate_task({ agent: "
|
|
18832
|
+
prompt += `delegate_task({ agent: "${AGENT_NAMES.WORKER}", prompt: "${todo.content}", background: true })
|
|
18499
18833
|
`;
|
|
18500
18834
|
}
|
|
18501
18835
|
prompt += `\`\`\`
|
|
18502
18836
|
|
|
18503
|
-
|
|
18837
|
+
NOTICE: Do NOT run these sequentially. Use background=true for ALL.
|
|
18504
18838
|
After launching, use list_tasks to monitor progress.
|
|
18505
18839
|
|
|
18506
18840
|
`;
|
|
@@ -19066,6 +19400,17 @@ function cleanupSession2(sessionID) {
|
|
|
19066
19400
|
sessionStates2.delete(sessionID);
|
|
19067
19401
|
}
|
|
19068
19402
|
|
|
19403
|
+
// src/core/context/context-window-monitor.ts
|
|
19404
|
+
var sessionStates3 = /* @__PURE__ */ new Map();
|
|
19405
|
+
function cleanupSession3(sessionID) {
|
|
19406
|
+
const state2 = sessionStates3.get(sessionID);
|
|
19407
|
+
if (state2?.intervalId) {
|
|
19408
|
+
clearInterval(state2.intervalId);
|
|
19409
|
+
}
|
|
19410
|
+
sessionStates3.delete(sessionID);
|
|
19411
|
+
log2("[context-window-monitor] Session cleaned up", { sessionID });
|
|
19412
|
+
}
|
|
19413
|
+
|
|
19069
19414
|
// src/plugin-handlers/event-handler.ts
|
|
19070
19415
|
function createEventHandler(ctx) {
|
|
19071
19416
|
const { client, directory, sessions, state: state2 } = ctx;
|
|
@@ -19094,6 +19439,7 @@ function createEventHandler(ctx) {
|
|
|
19094
19439
|
cleanupSessionRecovery(sessionID);
|
|
19095
19440
|
cleanupSession(sessionID);
|
|
19096
19441
|
cleanupSession2(sessionID);
|
|
19442
|
+
cleanupSession3(sessionID);
|
|
19097
19443
|
presets.sessionCompleted(sessionID, duration3);
|
|
19098
19444
|
}
|
|
19099
19445
|
}
|
|
@@ -19345,12 +19691,56 @@ function createChatMessageHandler(ctx) {
|
|
|
19345
19691
|
};
|
|
19346
19692
|
}
|
|
19347
19693
|
|
|
19348
|
-
// src/utils/sanity.ts
|
|
19694
|
+
// src/utils/sanity/constants/severity.ts
|
|
19349
19695
|
var SEVERITY = {
|
|
19350
19696
|
OK: "ok",
|
|
19351
19697
|
WARNING: "warning",
|
|
19352
19698
|
CRITICAL: "critical"
|
|
19353
19699
|
};
|
|
19700
|
+
|
|
19701
|
+
// src/utils/sanity/constants/recovery-prompt.ts
|
|
19702
|
+
var RECOVERY_PROMPT = `<anomaly_recovery>
|
|
19703
|
+
SYSTEM NOTICE: Previous output was malformed (gibberish/loop detected).
|
|
19704
|
+
|
|
19705
|
+
|
|
19706
|
+
<recovery_protocol>
|
|
19707
|
+
1. DISCARD the corrupted output completely - do not reference it
|
|
19708
|
+
2. RECALL the original mission objective
|
|
19709
|
+
3. IDENTIFY the last confirmed successful step
|
|
19710
|
+
4. RESTART with a simpler, more focused approach
|
|
19711
|
+
</recovery_protocol>
|
|
19712
|
+
|
|
19713
|
+
<instructions>
|
|
19714
|
+
- If a sub-agent produced bad output: try a different agent or simpler task
|
|
19715
|
+
- If stuck in a loop: break down the task into smaller pieces
|
|
19716
|
+
- If context seems corrupted: call Reviewer to restore context
|
|
19717
|
+
- THINK in English for maximum stability
|
|
19718
|
+
</instructions>
|
|
19719
|
+
|
|
19720
|
+
What was the original task? Proceed from the last known good state.
|
|
19721
|
+
</anomaly_recovery>`;
|
|
19722
|
+
|
|
19723
|
+
// src/utils/sanity/constants/escalation-prompt.ts
|
|
19724
|
+
var ESCALATION_PROMPT = `<critical_anomaly>
|
|
19725
|
+
CRITICAL: Multiple consecutive malformed outputs detected.
|
|
19726
|
+
|
|
19727
|
+
|
|
19728
|
+
<emergency_protocol>
|
|
19729
|
+
1. STOP current execution path immediately
|
|
19730
|
+
2. DO NOT continue with the same approach - it is failing
|
|
19731
|
+
3. CALL Planner for a completely new strategy
|
|
19732
|
+
4. If Planner also fails: report status to user and await guidance
|
|
19733
|
+
</emergency_protocol>
|
|
19734
|
+
|
|
19735
|
+
<diagnosis>
|
|
19736
|
+
The current approach is producing corrupted output.
|
|
19737
|
+
This may indicate: context overload, model instability, or task complexity.
|
|
19738
|
+
</diagnosis>
|
|
19739
|
+
|
|
19740
|
+
Request a fresh plan from Planner with reduced scope.
|
|
19741
|
+
</critical_anomaly>`;
|
|
19742
|
+
|
|
19743
|
+
// src/utils/sanity/checker.ts
|
|
19354
19744
|
function checkOutputSanity(text) {
|
|
19355
19745
|
if (!text || text.length < 50) {
|
|
19356
19746
|
return { isHealthy: true, severity: SEVERITY.OK };
|
|
@@ -19417,42 +19807,6 @@ function checkOutputSanity(text) {
|
|
|
19417
19807
|
}
|
|
19418
19808
|
return { isHealthy: true, severity: SEVERITY.OK };
|
|
19419
19809
|
}
|
|
19420
|
-
var RECOVERY_PROMPT = `<anomaly_recovery>
|
|
19421
|
-
\u26A0\uFE0F SYSTEM NOTICE: Previous output was malformed (gibberish/loop detected).
|
|
19422
|
-
|
|
19423
|
-
<recovery_protocol>
|
|
19424
|
-
1. DISCARD the corrupted output completely - do not reference it
|
|
19425
|
-
2. RECALL the original mission objective
|
|
19426
|
-
3. IDENTIFY the last confirmed successful step
|
|
19427
|
-
4. RESTART with a simpler, more focused approach
|
|
19428
|
-
</recovery_protocol>
|
|
19429
|
-
|
|
19430
|
-
<instructions>
|
|
19431
|
-
- If a sub-agent produced bad output: try a different agent or simpler task
|
|
19432
|
-
- If stuck in a loop: break down the task into smaller pieces
|
|
19433
|
-
- If context seems corrupted: call Reviewer to restore context
|
|
19434
|
-
- THINK in English for maximum stability
|
|
19435
|
-
</instructions>
|
|
19436
|
-
|
|
19437
|
-
What was the original task? Proceed from the last known good state.
|
|
19438
|
-
</anomaly_recovery>`;
|
|
19439
|
-
var ESCALATION_PROMPT = `<critical_anomaly>
|
|
19440
|
-
\u{1F6A8} CRITICAL: Multiple consecutive malformed outputs detected.
|
|
19441
|
-
|
|
19442
|
-
<emergency_protocol>
|
|
19443
|
-
1. STOP current execution path immediately
|
|
19444
|
-
2. DO NOT continue with the same approach - it is failing
|
|
19445
|
-
3. CALL Planner for a completely new strategy
|
|
19446
|
-
4. If Planner also fails: report status to user and await guidance
|
|
19447
|
-
</emergency_protocol>
|
|
19448
|
-
|
|
19449
|
-
<diagnosis>
|
|
19450
|
-
The current approach is producing corrupted output.
|
|
19451
|
-
This may indicate: context overload, model instability, or task complexity.
|
|
19452
|
-
</diagnosis>
|
|
19453
|
-
|
|
19454
|
-
Request a fresh plan from Planner with reduced scope.
|
|
19455
|
-
</critical_anomaly>`;
|
|
19456
19810
|
|
|
19457
19811
|
// src/plugin-handlers/tool-execute-handler.ts
|
|
19458
19812
|
function createToolExecuteAfterHandler(ctx) {
|
|
@@ -19494,7 +19848,7 @@ Anomaly count: ${stateSession.anomalyCount}
|
|
|
19494
19848
|
stateSession.currentTask = taskIdMatch[1].toUpperCase();
|
|
19495
19849
|
}
|
|
19496
19850
|
const agentName = toolInput.arguments.agent;
|
|
19497
|
-
const indicator =
|
|
19851
|
+
const indicator = agentName[0].toUpperCase();
|
|
19498
19852
|
toolOutput.output = `[${indicator}] [${agentName.toUpperCase()}] Working...
|
|
19499
19853
|
|
|
19500
19854
|
` + toolOutput.output;
|
|
@@ -19603,7 +19957,7 @@ function createAssistantDoneHandler(ctx) {
|
|
|
19603
19957
|
session.active = false;
|
|
19604
19958
|
state.missionActive = false;
|
|
19605
19959
|
clearLoopState(directory);
|
|
19606
|
-
presets.missionComplete("
|
|
19960
|
+
presets.missionComplete("Mission Sealed - Explicit completion confirmed");
|
|
19607
19961
|
log2("[assistant-done-handler] Mission sealed detected", { sessionID });
|
|
19608
19962
|
clearSession(sessionID);
|
|
19609
19963
|
sessions.delete(sessionID);
|
|
@@ -19639,7 +19993,7 @@ function createAssistantDoneHandler(ctx) {
|
|
|
19639
19993
|
type: PART_TYPES.TEXT,
|
|
19640
19994
|
text: CONTINUE_INSTRUCTION + `
|
|
19641
19995
|
|
|
19642
|
-
|
|
19996
|
+
[${currentTime}] Step ${session.step} | ${progressInfo} | This step: ${stepDuration} | Total: ${totalElapsed}`
|
|
19643
19997
|
}]
|
|
19644
19998
|
}
|
|
19645
19999
|
});
|
|
@@ -19724,6 +20078,11 @@ var OrchestratorPlugin = async (input) => {
|
|
|
19724
20078
|
[TOOL_NAMES.WEBSEARCH]: websearchTool,
|
|
19725
20079
|
[TOOL_NAMES.CACHE_DOCS]: cacheDocsTool,
|
|
19726
20080
|
[TOOL_NAMES.CODESEARCH]: codesearchTool,
|
|
20081
|
+
// LSP tools
|
|
20082
|
+
[TOOL_NAMES.LSP_DIAGNOSTICS]: lspDiagnosticsTool(directory),
|
|
20083
|
+
// AST tools
|
|
20084
|
+
[TOOL_NAMES.AST_SEARCH]: astSearchTool(directory),
|
|
20085
|
+
[TOOL_NAMES.AST_REPLACE]: astReplaceTool(directory),
|
|
19727
20086
|
// Async agent tools
|
|
19728
20087
|
...asyncAgentTools
|
|
19729
20088
|
},
|