opencode-orchestrator 0.9.64 → 0.9.67
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 +901 -570
- 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/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 +20 -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",
|
|
@@ -468,25 +598,25 @@ var WORK_STATUS = {
|
|
|
468
598
|
DELETE: "DELETE",
|
|
469
599
|
FIX: "FIX"
|
|
470
600
|
},
|
|
471
|
-
// Task/file status
|
|
601
|
+
// Task/file status (Internal state)
|
|
472
602
|
STATUS: {
|
|
473
|
-
PENDING:
|
|
474
|
-
IN_PROGRESS:
|
|
475
|
-
DONE:
|
|
476
|
-
FAILED:
|
|
603
|
+
PENDING: STATUS_LABEL.PENDING,
|
|
604
|
+
IN_PROGRESS: STATUS_LABEL.IN_PROGRESS,
|
|
605
|
+
DONE: STATUS_LABEL.DONE,
|
|
606
|
+
FAILED: STATUS_LABEL.FAILED
|
|
477
607
|
},
|
|
478
608
|
// Test result
|
|
479
609
|
TEST_RESULT: {
|
|
480
|
-
PASS:
|
|
481
|
-
FAIL:
|
|
482
|
-
SKIP:
|
|
610
|
+
PASS: STATUS_LABEL.PASS,
|
|
611
|
+
FAIL: STATUS_LABEL.FAIL,
|
|
612
|
+
SKIP: STATUS_LABEL.SKIP
|
|
483
613
|
},
|
|
484
614
|
// E2E integration test status
|
|
485
615
|
E2E_STATUS: {
|
|
486
616
|
NOT_STARTED: "NOT_STARTED",
|
|
487
|
-
RUNNING:
|
|
488
|
-
PASS:
|
|
489
|
-
FAIL:
|
|
617
|
+
RUNNING: STATUS_LABEL.RUNNING,
|
|
618
|
+
PASS: STATUS_LABEL.PASS,
|
|
619
|
+
FAIL: STATUS_LABEL.FAIL
|
|
490
620
|
},
|
|
491
621
|
// Mission phase
|
|
492
622
|
PHASE: {
|
|
@@ -513,9 +643,10 @@ var WORK_STATUS = {
|
|
|
513
643
|
},
|
|
514
644
|
// Session state
|
|
515
645
|
SESSION: {
|
|
516
|
-
STARTED:
|
|
517
|
-
|
|
518
|
-
|
|
646
|
+
STARTED: STATUS_LABEL.PENDING,
|
|
647
|
+
// Standardized mapping
|
|
648
|
+
COMPLETED: STATUS_LABEL.DONE,
|
|
649
|
+
CANCELLED: STATUS_LABEL.CANCELLED
|
|
519
650
|
},
|
|
520
651
|
// Task triage - complexity classification
|
|
521
652
|
TRIAGE: {
|
|
@@ -537,22 +668,23 @@ var WORK_STATUS = {
|
|
|
537
668
|
},
|
|
538
669
|
// TODO.md status values (for Epic/Task display)
|
|
539
670
|
TODO_STATUS: {
|
|
540
|
-
PENDING:
|
|
541
|
-
IN_PROGRESS:
|
|
542
|
-
COMPLETE:
|
|
543
|
-
BLOCKED:
|
|
544
|
-
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
|
|
545
677
|
},
|
|
546
678
|
// Task size estimation
|
|
547
679
|
TASK_SIZE: {
|
|
548
680
|
XS: "XS",
|
|
549
|
-
// <
|
|
681
|
+
// <10min
|
|
550
682
|
S: "S",
|
|
551
|
-
//
|
|
683
|
+
// 10-20min
|
|
552
684
|
M: "M",
|
|
553
|
-
//
|
|
685
|
+
// 20-40min
|
|
554
686
|
L: "L"
|
|
555
|
-
//
|
|
687
|
+
// 40-60min
|
|
556
688
|
}
|
|
557
689
|
};
|
|
558
690
|
|
|
@@ -579,19 +711,19 @@ var PHILOSOPHY_LEARN_PRINCIPLE = "LEARN = DOCUMENT: What you discover, you recor
|
|
|
579
711
|
|
|
580
712
|
// src/core/agents/consts/task-status.const.ts
|
|
581
713
|
var TASK_STATUS = {
|
|
582
|
-
PENDING:
|
|
583
|
-
RUNNING:
|
|
584
|
-
COMPLETED:
|
|
585
|
-
FAILED:
|
|
586
|
-
ERROR:
|
|
587
|
-
TIMEOUT:
|
|
588
|
-
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
|
|
589
721
|
};
|
|
590
722
|
var TODO_STATUS = {
|
|
591
|
-
PENDING:
|
|
592
|
-
IN_PROGRESS:
|
|
593
|
-
COMPLETED:
|
|
594
|
-
CANCELLED:
|
|
723
|
+
PENDING: STATUS_LABEL.PENDING,
|
|
724
|
+
IN_PROGRESS: STATUS_LABEL.IN_PROGRESS,
|
|
725
|
+
COMPLETED: STATUS_LABEL.COMPLETED,
|
|
726
|
+
CANCELLED: STATUS_LABEL.CANCELLED
|
|
595
727
|
};
|
|
596
728
|
|
|
597
729
|
// src/core/orchestrator/state.ts
|
|
@@ -13026,16 +13158,17 @@ tool.schema = external_exports;
|
|
|
13026
13158
|
|
|
13027
13159
|
// src/agents/prompts/common/environment-discovery.ts
|
|
13028
13160
|
var ENVIRONMENT_DISCOVERY = `${PROMPT_TAGS.ENVIRONMENT_DISCOVERY.open}
|
|
13029
|
-
|
|
13161
|
+
**MANDATORY FIRST STEP** - Before any planning or coding:
|
|
13030
13162
|
|
|
13031
13163
|
## 1. Project Structure Discovery
|
|
13032
13164
|
Explore the project root to understand its organization:
|
|
13033
13165
|
\`\`\`bash
|
|
13034
13166
|
ls -la # Root contents
|
|
13035
|
-
find . -maxdepth 2 -type d | head
|
|
13167
|
+
find . -maxdepth 2 -type d | head -${LIMITS.DEFAULT_SCAN_LIMIT} # Directory structure
|
|
13036
13168
|
find . -maxdepth 1 -type f # Root files
|
|
13037
13169
|
\`\`\`
|
|
13038
13170
|
|
|
13171
|
+
|
|
13039
13172
|
**Look for patterns, NOT specific files:**
|
|
13040
13173
|
- Source directories (src/, lib/, app/, pkg/, internal/, cmd/)
|
|
13041
13174
|
- Test directories (tests/, test/, spec/, __tests__/, *_test/)
|
|
@@ -13126,7 +13259,7 @@ ls -la ${PATHS.OPENCODE}/ 2>/dev/null || echo "No existing context"
|
|
|
13126
13259
|
- [Any unique patterns or requirements observed]
|
|
13127
13260
|
\`\`\`
|
|
13128
13261
|
|
|
13129
|
-
##
|
|
13262
|
+
## CRITICAL RULES:
|
|
13130
13263
|
1. NEVER assume - always VERIFY by reading files
|
|
13131
13264
|
2. ADAPT to what you find, don't force expectations
|
|
13132
13265
|
3. If uncertain, ASK the user for clarification
|
|
@@ -13135,7 +13268,7 @@ ${PROMPT_TAGS.ENVIRONMENT_DISCOVERY.close}`;
|
|
|
13135
13268
|
|
|
13136
13269
|
// src/agents/prompts/common/anti-hallucination.ts
|
|
13137
13270
|
var ANTI_HALLUCINATION_CORE = `${PROMPT_TAGS.ANTI_HALLUCINATION.open}
|
|
13138
|
-
|
|
13271
|
+
ZERO TOLERANCE FOR GUESSING
|
|
13139
13272
|
|
|
13140
13273
|
## The Golden Rule
|
|
13141
13274
|
> If you're not 100% sure, **SEARCH** before you claim.
|
|
@@ -13148,7 +13281,7 @@ var ANTI_HALLUCINATION_CORE = `${PROMPT_TAGS.ANTI_HALLUCINATION.open}
|
|
|
13148
13281
|
ls ${PATHS.DOCS}/ # What do we already have?
|
|
13149
13282
|
\`\`\`
|
|
13150
13283
|
|
|
13151
|
-
### Step 2: If Not Found
|
|
13284
|
+
### Step 2: If Not Found -> Research
|
|
13152
13285
|
- Search for OFFICIAL documentation
|
|
13153
13286
|
- Prefer version-specific docs matching project
|
|
13154
13287
|
- Cache findings to ${PATHS.DOCS}/
|
|
@@ -13159,20 +13292,20 @@ ls ${PATHS.DOCS}/ # What do we already have?
|
|
|
13159
13292
|
- Are there breaking changes to consider?
|
|
13160
13293
|
|
|
13161
13294
|
## Source Hierarchy (Most to Least Trusted):
|
|
13162
|
-
1.
|
|
13163
|
-
2.
|
|
13164
|
-
3.
|
|
13165
|
-
4.
|
|
13166
|
-
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
|
|
13167
13300
|
|
|
13168
|
-
##
|
|
13301
|
+
## FORBIDDEN:
|
|
13169
13302
|
- Inventing function signatures from memory
|
|
13170
13303
|
- Assuming API compatibility between versions
|
|
13171
13304
|
- Guessing version-specific syntax
|
|
13172
13305
|
- Using knowledge without verification
|
|
13173
13306
|
- Mixing syntax from different versions
|
|
13174
13307
|
|
|
13175
|
-
##
|
|
13308
|
+
## REQUIRED:
|
|
13176
13309
|
- Source URL for every technical claim
|
|
13177
13310
|
- Confidence level: ${WORK_STATUS.CONFIDENCE.HIGH} (official) / ${WORK_STATUS.CONFIDENCE.MEDIUM} (github) / ${WORK_STATUS.CONFIDENCE.LOW} (blog)
|
|
13178
13311
|
- Say "I need to research this" if unsure
|
|
@@ -13186,82 +13319,84 @@ ${PROMPT_TAGS.ANTI_HALLUCINATION.close}`;
|
|
|
13186
13319
|
|
|
13187
13320
|
// src/agents/prompts/common/todo-rules.ts
|
|
13188
13321
|
var TODO_RULES = `${PROMPT_TAGS.TODO_RULES.open}
|
|
13189
|
-
|
|
13322
|
+
TODO MANAGEMENT - ADAPTIVE HIERARCHICAL STRUCTURE
|
|
13190
13323
|
|
|
13191
13324
|
## Before Creating TODOs: EXPLORE
|
|
13192
13325
|
1. Read ${PATHS.CONTEXT} to understand project structure
|
|
13193
13326
|
2. Study existing code organization
|
|
13194
13327
|
3. Plan parallel execution groups based on actual dependencies
|
|
13195
13328
|
|
|
13196
|
-
##
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
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 \`[ ]\`.
|
|
13200
13334
|
|
|
13201
|
-
## Completion Rules
|
|
13202
|
-
-
|
|
13203
|
-
-
|
|
13204
|
-
-
|
|
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]\`.
|
|
13205
13339
|
|
|
13206
|
-
|
|
13340
|
+
[CRITICAL]: Parent NEVER marked complete before ALL children are verified!
|
|
13207
13341
|
|
|
13208
|
-
## Format (
|
|
13342
|
+
## Format (Nested Indentation)
|
|
13209
13343
|
\`\`\`markdown
|
|
13210
13344
|
# Mission: [goal]
|
|
13211
13345
|
|
|
13212
|
-
##
|
|
13213
|
-
###
|
|
13214
|
-
- [ ]
|
|
13215
|
-
- [ ]
|
|
13216
|
-
### T1.2: [Task Name] | agent:${AGENT_NAMES.WORKER} | depends:T1.1
|
|
13217
|
-
- [ ] 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
|
|
13218
13350
|
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
|
|
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
|
|
13222
13356
|
\`\`\`
|
|
13223
13357
|
|
|
13224
13358
|
## Status Indicators
|
|
13225
|
-
- [ ] = Not started
|
|
13226
|
-
- [x] = VERIFIED complete (
|
|
13227
|
-
- status: ${WORK_STATUS.TODO_STATUS.IN_PROGRESS} = Currently working
|
|
13228
|
-
- status: ${WORK_STATUS.TODO_STATUS.BLOCKED}:[reason] = Cannot proceed
|
|
13229
|
-
-
|
|
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
|
|
13230
13365
|
|
|
13231
13366
|
## Verification Flow (Evidence-Based)
|
|
13232
|
-
1. ${AGENT_NAMES.WORKER} completes subtask, reports with evidence
|
|
13233
|
-
2. ${AGENT_NAMES.REVIEWER} runs project's build/test commands from ${PATHS.CONTEXT}
|
|
13234
|
-
3. ${AGENT_NAMES.REVIEWER} verifies and marks subtask [x]
|
|
13235
|
-
4.
|
|
13236
|
-
|
|
13237
|
-
|
|
13238
|
-
|
|
13239
|
-
-
|
|
13240
|
-
-
|
|
13241
|
-
- Skipping verification step
|
|
13242
|
-
- 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.
|
|
13243
13376
|
${PROMPT_TAGS.TODO_RULES.close}`;
|
|
13244
13377
|
|
|
13245
13378
|
// src/agents/prompts/common/shared-workspace.ts
|
|
13246
13379
|
var SHARED_WORKSPACE = `${PROMPT_TAGS.SHARED_WORKSPACE.open}
|
|
13247
|
-
|
|
13380
|
+
${PATHS.OPENCODE}/ - Shared Context Directory (Real-time State)
|
|
13248
13381
|
|
|
13249
13382
|
\`\`\`
|
|
13250
13383
|
${PATHS.OPENCODE}/
|
|
13251
|
-
\u251C\u2500\u2500
|
|
13252
|
-
\u251C\u2500\u2500
|
|
13253
|
-
\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)
|
|
13254
13387
|
\u2502 # - Active sessions & assigned files
|
|
13255
13388
|
\u2502 # - Unit test completion records
|
|
13256
13389
|
\u2502 # - Pending integration items
|
|
13257
|
-
\u251C\u2500\u2500
|
|
13390
|
+
\u251C\u2500\u2500 ${PATHS.UNIT_TESTS.split("/").pop()}/ - Unit test records (preserved after deletion)
|
|
13258
13391
|
\u2502 \u2514\u2500\u2500 [timestamp]-[file].md # Test content, results, deleted test code
|
|
13259
|
-
\u251C\u2500\u2500
|
|
13260
|
-
\u251C\u2500\u2500
|
|
13261
|
-
\u251C\u2500\u2500
|
|
13262
|
-
\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
|
|
13263
13396
|
\`\`\`
|
|
13264
13397
|
|
|
13398
|
+
|
|
13399
|
+
|
|
13265
13400
|
## ID Formats (no digit limit):
|
|
13266
13401
|
- Session: ${ID_PREFIX.SESSION}N (e.g., ${ID_PREFIX.SESSION}1, ${ID_PREFIX.SESSION}42)
|
|
13267
13402
|
- Sync Issue: ${ID_PREFIX.SYNC_ISSUE}N (e.g., ${ID_PREFIX.SYNC_ISSUE}1, ${ID_PREFIX.SYNC_ISSUE}100)
|
|
@@ -13277,8 +13412,8 @@ ${PATHS.OPENCODE}/
|
|
|
13277
13412
|
# Work Log
|
|
13278
13413
|
|
|
13279
13414
|
## Active Sessions
|
|
13280
|
-
- [ ] ${ID_PREFIX.SESSION}1 (
|
|
13281
|
-
- [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}
|
|
13282
13417
|
|
|
13283
13418
|
## Completed Units (Ready for Integration)
|
|
13284
13419
|
| File | Session | Unit Test | Timestamp |
|
|
@@ -13296,22 +13431,23 @@ ${PATHS.OPENCODE}/
|
|
|
13296
13431
|
|
|
13297
13432
|
RULES:
|
|
13298
13433
|
- ALL agents MUST read ${PATHS.WORK_LOG} before starting
|
|
13299
|
-
-
|
|
13300
|
-
-
|
|
13301
|
-
-
|
|
13302
|
-
- ${PATHS.SYNC_ISSUES} =
|
|
13303
|
-
${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
|
+
`;
|
|
13304
13440
|
|
|
13305
13441
|
// src/agents/prompts/common/mission-seal.ts
|
|
13306
13442
|
var MISSION_SEAL_RULES = `${PROMPT_TAGS.MISSION_SEAL.open}
|
|
13307
13443
|
MISSION COMPLETION SEAL
|
|
13308
13444
|
|
|
13309
13445
|
## Seal Requirements - ALL must be true:
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
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
|
|
13315
13451
|
|
|
13316
13452
|
## Seal Output Format:
|
|
13317
13453
|
\`\`\`
|
|
@@ -13323,54 +13459,81 @@ Evidence: [test/build results]
|
|
|
13323
13459
|
|
|
13324
13460
|
If ANY checkbox is unchecked, DO NOT seal - continue working!
|
|
13325
13461
|
NEVER output seal before requirements met!
|
|
13326
|
-
${PROMPT_TAGS.MISSION_SEAL.close}
|
|
13462
|
+
${PROMPT_TAGS.MISSION_SEAL.close}
|
|
13463
|
+
`;
|
|
13327
13464
|
|
|
13328
13465
|
// src/agents/prompts/common/verification.ts
|
|
13329
13466
|
var VERIFICATION_REQUIREMENTS = `${PROMPT_TAGS.VERIFICATION.open}
|
|
13330
13467
|
VERIFICATION CHECKLIST
|
|
13331
13468
|
|
|
13332
13469
|
## Code Verification
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
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.)
|
|
13338
13475
|
|
|
13339
13476
|
## Documentation Verification
|
|
13340
|
-
|
|
13341
|
-
|
|
13342
|
-
|
|
13477
|
+
- [ ] Implementation matches ${PATHS.DOCS}/
|
|
13478
|
+
- [ ] API usage matches official docs
|
|
13479
|
+
- [ ] Version compatibility confirmed
|
|
13343
13480
|
|
|
13344
13481
|
## Security Verification
|
|
13345
|
-
|
|
13346
|
-
|
|
13347
|
-
|
|
13482
|
+
- [ ] No hardcoded secrets/passwords/API keys
|
|
13483
|
+
- [ ] Input validation present
|
|
13484
|
+
- [ ] Error messages don't leak sensitive info
|
|
13348
13485
|
|
|
13349
13486
|
ONLY mark complete after ALL checks pass!
|
|
13350
|
-
${PROMPT_TAGS.VERIFICATION.close}
|
|
13487
|
+
${PROMPT_TAGS.VERIFICATION.close}
|
|
13488
|
+
`;
|
|
13351
13489
|
|
|
13352
13490
|
// src/agents/prompts/common/core-philosophy.ts
|
|
13353
13491
|
var CORE_PHILOSOPHY = `${PROMPT_TAGS.CORE_PHILOSOPHY.open}
|
|
13354
|
-
##
|
|
13492
|
+
## Core Philosophy: ${PHILOSOPHY_TAGLINE}
|
|
13355
13493
|
|
|
13356
13494
|
> ${PHILOSOPHY_QUOTE}
|
|
13357
13495
|
|
|
13358
13496
|
| Phase | Action | Key Behavior |
|
|
13359
13497
|
|:-----:|:-------|:-------------|
|
|
13360
|
-
|
|
|
13361
|
-
|
|
|
13362
|
-
|
|
|
13363
|
-
|
|
|
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 |
|
|
13364
13502
|
|
|
13365
13503
|
**${PHILOSOPHY_LEARN_PRINCIPLE}**
|
|
13366
13504
|
|
|
13367
13505
|
### Agent Focus:
|
|
13368
|
-
-
|
|
13369
|
-
-
|
|
13370
|
-
-
|
|
13371
|
-
-
|
|
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)
|
|
13372
13510
|
${PROMPT_TAGS.CORE_PHILOSOPHY.close}`;
|
|
13373
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
|
+
|
|
13374
13537
|
// src/agents/prompts/commander/role.ts
|
|
13375
13538
|
var COMMANDER_ROLE = `${PROMPT_TAGS.ROLE.open}
|
|
13376
13539
|
You are ${AGENT_NAMES.COMMANDER}. Autonomous mission controller.
|
|
@@ -13402,7 +13565,9 @@ ${PROMPT_TAGS.IDENTITY.close}`;
|
|
|
13402
13565
|
|
|
13403
13566
|
// src/agents/prompts/commander/forbidden.ts
|
|
13404
13567
|
var COMMANDER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
13405
|
-
|
|
13568
|
+
**COMMANDER FORBIDDEN ACTIONS**
|
|
13569
|
+
|
|
13570
|
+
|
|
13406
13571
|
|
|
13407
13572
|
## Never Stop Prematurely
|
|
13408
13573
|
- NEVER say "I've completed..." without outputting ${MISSION_SEAL.PATTERN}
|
|
@@ -13483,7 +13648,7 @@ var COMMANDER_EXECUTION = `${PROMPT_TAGS.EXECUTION_STRATEGY.open}
|
|
|
13483
13648
|
5. Save context to ${PATHS.CONTEXT}
|
|
13484
13649
|
|
|
13485
13650
|
## Phase 1: THINK (Mandatory - Never Skip!)
|
|
13486
|
-
|
|
13651
|
+
**THINK FIRST**: As ${AGENT_NAMES.COMMANDER}, think about ORCHESTRATION before action.
|
|
13487
13652
|
|
|
13488
13653
|
### 1.1 MISSION SCOPE
|
|
13489
13654
|
- What is the FULL scope of this mission?
|
|
@@ -13506,7 +13671,7 @@ var COMMANDER_EXECUTION = `${PROMPT_TAGS.EXECUTION_STRATEGY.open}
|
|
|
13506
13671
|
- How will I DETECT and RECOVER from issues?
|
|
13507
13672
|
- If agent fails \u2192 See ${PROMPT_TAGS.RECOVERY.open} section: DECOMPOSE and retry
|
|
13508
13673
|
|
|
13509
|
-
|
|
13674
|
+
**ANTI-PATTERNS**: Sequential execution when parallel is possible. Doing work yourself instead of delegating. Starting without clear decomposition.
|
|
13510
13675
|
|
|
13511
13676
|
## Phase 2: TRIAGE
|
|
13512
13677
|
| Type | Signal | Approach |
|
|
@@ -13569,56 +13734,52 @@ ${PROMPT_TAGS.AGENTS.close}`;
|
|
|
13569
13734
|
|
|
13570
13735
|
// src/agents/prompts/commander/todo-format.ts
|
|
13571
13736
|
var COMMANDER_TODO_FORMAT = `${PROMPT_TAGS.TODO_FORMAT.open}
|
|
13572
|
-
## 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.
|
|
13573
13739
|
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
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.
|
|
13577
13744
|
|
|
13578
|
-
## Example
|
|
13745
|
+
## Structure Example
|
|
13579
13746
|
\`\`\`markdown
|
|
13580
|
-
# Mission:
|
|
13581
|
-
|
|
13582
|
-
##
|
|
13583
|
-
###
|
|
13584
|
-
- [ ]
|
|
13585
|
-
- [ ]
|
|
13586
|
-
- [ ] S1.1.3: Add indexes | size:XS
|
|
13587
|
-
### T1.2: Auth endpoints | agent:${AGENT_NAMES.WORKER} | depends:T1.1
|
|
13588
|
-
- [ ] S1.2.1: POST /login | size:M
|
|
13589
|
-
- [ ] S1.2.2: POST /logout | size:S
|
|
13590
|
-
- [ ] S1.2.3: POST /refresh | size:M
|
|
13591
|
-
### T1.3: Verify backend | agent:${AGENT_NAMES.REVIEWER} | depends:T1.2
|
|
13592
|
-
- [ ] S1.3.1: Run unit tests | size:S
|
|
13593
|
-
- [ ] S1.3.2: Run integration tests | size:M
|
|
13594
|
-
|
|
13595
|
-
## E2: Frontend UI | status: ${WORK_STATUS.TODO_STATUS.PENDING} | depends:E1
|
|
13596
|
-
### T2.1: Login page | agent:${AGENT_NAMES.WORKER}
|
|
13597
|
-
- [ ] S2.1.1: Create form component | size:M
|
|
13598
|
-
- [ ] S2.1.2: Add validation | size:S
|
|
13599
|
-
### T2.2: Verify frontend | agent:${AGENT_NAMES.REVIEWER} | depends:T2.1
|
|
13600
|
-
- [ ] S2.2.1: Run tests | size:S
|
|
13601
|
-
\`\`\`
|
|
13747
|
+
# Mission: [goal]
|
|
13748
|
+
|
|
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
|
|
13602
13753
|
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
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
|
|
13607
13758
|
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
E1 [x] + E2 [x] = Mission can be SEALED
|
|
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
|
|
13612
13762
|
|
|
13613
|
-
|
|
13614
|
-
|
|
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
|
+
\`\`\`
|
|
13767
|
+
|
|
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.
|
|
13773
|
+
|
|
13774
|
+
Create all items with \`[ ]\` - NEVER with \`[x]\`!
|
|
13775
|
+
Only ${AGENT_NAMES.REVIEWER} marks \`[x]\` after verification!
|
|
13615
13776
|
${PROMPT_TAGS.TODO_FORMAT.close}`;
|
|
13616
13777
|
|
|
13617
13778
|
// src/agents/prompts/commander/loop-continuation.ts
|
|
13618
13779
|
var COMMANDER_LOOP_CONTINUATION = `${PROMPT_TAGS.LOOP_CONTINUATION.open}
|
|
13619
13780
|
## LOOP CONTINUATION PROTOCOL
|
|
13620
13781
|
|
|
13621
|
-
At the START of each loop iteration,
|
|
13782
|
+
At the START of each loop iteration, ${AGENT_NAMES.COMMANDER} MUST read shared state:
|
|
13622
13783
|
|
|
13623
13784
|
### Step 1: Read Status Summary
|
|
13624
13785
|
\`\`\`bash
|
|
@@ -13629,79 +13790,49 @@ cat ${PATHS.SYNC_ISSUES} 2>/dev/null || echo "No sync issues"
|
|
|
13629
13790
|
|
|
13630
13791
|
---
|
|
13631
13792
|
|
|
13632
|
-
##
|
|
13793
|
+
## MISSION STATUS TRACKING
|
|
13633
13794
|
|
|
13634
|
-
|
|
13795
|
+
${AGENT_NAMES.COMMANDER} updates ${PATHS.STATUS} each loop:
|
|
13635
13796
|
\`\`\`markdown
|
|
13636
13797
|
# Mission Status
|
|
13637
13798
|
|
|
13638
13799
|
## Progress
|
|
13639
|
-
- ${PATHS.TODO}:
|
|
13640
|
-
- Issues:
|
|
13641
|
-
-
|
|
13800
|
+
- ${PATHS.TODO}: [N]/[Total] ([X]%)
|
|
13801
|
+
- Issues: [N] unresolved
|
|
13802
|
+
- ${AGENT_NAMES.WORKER}s: [N] active
|
|
13642
13803
|
- E2E: ${WORK_STATUS.E2E_STATUS.NOT_STARTED} | ${WORK_STATUS.E2E_STATUS.RUNNING} | ${WORK_STATUS.E2E_STATUS.PASS} | ${WORK_STATUS.E2E_STATUS.FAIL}
|
|
13643
13804
|
|
|
13644
13805
|
## Current Phase
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
## Next Action
|
|
13648
|
-
[Brief description]
|
|
13649
|
-
|
|
13650
|
-
## Blockers
|
|
13651
|
-
- [List or "None"]
|
|
13806
|
+
...
|
|
13652
13807
|
\`\`\`
|
|
13653
13808
|
|
|
13654
|
-
### Status Rules:
|
|
13655
|
-
- Update EVERY loop iteration
|
|
13656
|
-
- Keep it minimal (just the numbers)
|
|
13657
|
-
- ${AGENT_NAMES.PLANNER} reads this to stay synced
|
|
13658
|
-
- Delete old content, keep only current state
|
|
13659
|
-
|
|
13660
13809
|
---
|
|
13661
13810
|
|
|
13662
|
-
##
|
|
13811
|
+
## SEALED CONDITIONS (CRITICAL!)
|
|
13663
13812
|
|
|
13664
13813
|
### SEALED = BOTH must be true:
|
|
13665
13814
|
\`\`\`
|
|
13666
|
-
|
|
13667
|
-
|
|
13815
|
+
${STATUS_LABEL.SUCCESS.toUpperCase()} ${PATHS.TODO}: ALL items [x] (100%)
|
|
13816
|
+
${STATUS_LABEL.SUCCESS.toUpperCase()} ${PATHS.SYNC_ISSUES}: EMPTY (0 issues)
|
|
13668
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
|
|
13669
13818
|
ONLY THEN \u2192 output ${MISSION_SEAL.PATTERN}
|
|
13670
13819
|
\`\`\`
|
|
13671
13820
|
|
|
13672
13821
|
### LOOP BACK = ANY of these:
|
|
13673
13822
|
\`\`\`
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
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
|
|
13679
13828
|
\`\`\`
|
|
13680
13829
|
|
|
13681
|
-
### \u26D4 NEVER SEAL IF:
|
|
13682
|
-
- ${PATHS.TODO} is 100% BUT ${PATHS.SYNC_ISSUES} > 0
|
|
13683
|
-
- Workers are still active
|
|
13684
|
-
- E2E = ${WORK_STATUS.E2E_STATUS.FAIL}
|
|
13685
|
-
|
|
13686
13830
|
---
|
|
13687
13831
|
|
|
13688
|
-
##
|
|
13689
|
-
|
|
13690
|
-
E2E starts when **${PATHS.TODO} \u2265 80%** (not at 100%):
|
|
13691
|
-
- Phase changes to ${WORK_STATUS.PHASE.E2E}
|
|
13692
|
-
- E2E runs **parallel** with remaining work
|
|
13693
|
-
- If E2E ${WORK_STATUS.E2E_STATUS.FAIL} \u2192 ${PATHS.SYNC_ISSUES}++ \u2192 continue ${PATHS.TODO}
|
|
13694
|
-
- Both ${PATHS.TODO} 100% AND ${PATHS.SYNC_ISSUES} 0 \u2192 ${WORK_STATUS.PHASE.SEALING}
|
|
13832
|
+
## E2E Test Timing
|
|
13695
13833
|
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
\u2193
|
|
13699
|
-
${PATHS.TODO} + E2E run parallel
|
|
13700
|
-
\u2193
|
|
13701
|
-
${PATHS.TODO} 100% + ${PATHS.SYNC_ISSUES} 0 \u2192 ${MISSION_SEAL.CONFIRMATION}
|
|
13702
|
-
\`\`\`
|
|
13703
|
-
|
|
13704
|
-
---
|
|
13834
|
+
E2E starts when **${PATHS.TODO} \u2265 80%**:
|
|
13835
|
+
...
|
|
13705
13836
|
|
|
13706
13837
|
### Decision Matrix
|
|
13707
13838
|
|
|
@@ -13710,14 +13841,12 @@ E2E starts when **${PATHS.TODO} \u2265 80%** (not at 100%):
|
|
|
13710
13841
|
| < 100% | Any | ${WORK_STATUS.PHASE.IMPLEMENTATION} |
|
|
13711
13842
|
| \u2265 80% | Any | ${WORK_STATUS.PHASE.E2E} (parallel) |
|
|
13712
13843
|
| 100% | > 0 | ${WORK_STATUS.PHASE.FIXING} |
|
|
13713
|
-
| 100% | 0 | ${WORK_STATUS.PHASE.SEALING}
|
|
13844
|
+
| 100% | 0 | ${WORK_STATUS.PHASE.SEALING} (${STATUS_LABEL.SUCCESS.toUpperCase()}) |
|
|
13714
13845
|
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
- E2E starts at ~80%, runs parallel
|
|
13720
|
-
${PROMPT_TAGS.LOOP_CONTINUATION.close}`;
|
|
13846
|
+
...
|
|
13847
|
+
${PROMPT_TAGS.LOOP_CONTINUATION.close}
|
|
13848
|
+
|
|
13849
|
+
`;
|
|
13721
13850
|
|
|
13722
13851
|
// src/agents/prompts/commander/sync-handling.ts
|
|
13723
13852
|
var COMMANDER_SYNC_HANDLING = `${PROMPT_TAGS.SYNC_ISSUE_HANDLING.open}
|
|
@@ -13753,8 +13882,8 @@ ${TOOL_NAMES.DELEGATE_TASK}(
|
|
|
13753
13882
|
)
|
|
13754
13883
|
\`\`\`
|
|
13755
13884
|
|
|
13756
|
-
### Step 4: Instruct
|
|
13757
|
-
After
|
|
13885
|
+
### Step 4: Instruct ${AGENT_NAMES.WORKER}s
|
|
13886
|
+
After ${AGENT_NAMES.PLANNER} updates ${PATHS.TODO}, delegate fixes:
|
|
13758
13887
|
|
|
13759
13888
|
\`\`\`
|
|
13760
13889
|
${TOOL_NAMES.DELEGATE_TASK}(
|
|
@@ -13772,8 +13901,9 @@ ${TOOL_NAMES.DELEGATE_TASK}(
|
|
|
13772
13901
|
)
|
|
13773
13902
|
\`\`\`
|
|
13774
13903
|
|
|
13775
|
-
### Step 5: Invoke
|
|
13776
|
-
After all fix
|
|
13904
|
+
### Step 5: Invoke ${AGENT_NAMES.REVIEWER} Again
|
|
13905
|
+
After all fix ${AGENT_NAMES.WORKER}s complete:
|
|
13906
|
+
|
|
13777
13907
|
\`\`\`
|
|
13778
13908
|
${TOOL_NAMES.DELEGATE_TASK}(
|
|
13779
13909
|
task: "Re-verify after ${ID_PREFIX.SYNC_ISSUE}1 fixes",
|
|
@@ -13791,9 +13921,9 @@ ${TOOL_NAMES.DELEGATE_TASK}(
|
|
|
13791
13921
|
\`\`\`
|
|
13792
13922
|
${AGENT_NAMES.COMMANDER}: "${AGENT_NAMES.PLANNER}, sync issue found. Update TODO"
|
|
13793
13923
|
\u2193
|
|
13794
|
-
${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})
|
|
13795
13925
|
\u2193
|
|
13796
|
-
${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)
|
|
13797
13927
|
\u2193
|
|
13798
13928
|
${AGENT_NAMES.WORKER}s: (Fix each file + unit test + update ${PATHS.WORK_LOG})
|
|
13799
13929
|
\u2193
|
|
@@ -13816,7 +13946,8 @@ var COMMANDER_RECOVERY = `${PROMPT_TAGS.RECOVERY.open}
|
|
|
13816
13946
|
When any agent fails, times out, or gets stuck:
|
|
13817
13947
|
|
|
13818
13948
|
### Level 1: ${RECOVERY_LEVEL.DECOMPOSE}
|
|
13819
|
-
- 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
|
+
|
|
13820
13951
|
- Delegate smaller pieces to fresh agents
|
|
13821
13952
|
- For repetitive changes, use ${TOOL_NAMES.SED_REPLACE} or shell tools
|
|
13822
13953
|
|
|
@@ -13862,11 +13993,14 @@ ${PROMPT_TAGS.ROLE.close}`;
|
|
|
13862
13993
|
|
|
13863
13994
|
// src/agents/prompts/planner/forbidden.ts
|
|
13864
13995
|
var PLANNER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
13865
|
-
|
|
13996
|
+
**PLANNER FORBIDDEN ACTIONS**
|
|
13997
|
+
|
|
13998
|
+
|
|
13866
13999
|
|
|
13867
14000
|
## Never Implement
|
|
13868
14001
|
- NEVER write actual code \u2192 Only plan and research
|
|
13869
|
-
- 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
|
+
|
|
13870
14004
|
- NEVER modify source files \u2192 Only ${PATHS.TODO} and ${PATHS.DOCS}/
|
|
13871
14005
|
|
|
13872
14006
|
## Never Assume
|
|
@@ -13887,8 +14021,9 @@ ${PROMPT_TAGS.FORBIDDEN_ACTIONS.close}`;
|
|
|
13887
14021
|
|
|
13888
14022
|
// src/agents/prompts/planner/required.ts
|
|
13889
14023
|
var PLANNER_REQUIRED = `${PROMPT_TAGS.REQUIRED_ACTIONS.open}
|
|
13890
|
-
|
|
14024
|
+
**THINK FIRST**: As PLANNER, think about STRATEGY before planning:
|
|
13891
14025
|
- Is my understanding of the task COMPLETE? What am I missing?
|
|
14026
|
+
|
|
13892
14027
|
- Have I researched ENOUGH? Do I need official docs?
|
|
13893
14028
|
- What is the optimal STRUCTURE for parallel execution?
|
|
13894
14029
|
- What DEPENDENCIES will block parallel work?
|
|
@@ -13907,48 +14042,55 @@ ${PROMPT_TAGS.REQUIRED_ACTIONS.close}`;
|
|
|
13907
14042
|
var PLANNER_TODO_FORMAT = `${PROMPT_TAGS.PLANNING_FORMAT.open}
|
|
13908
14043
|
OUTPUT TO: ${PATHS.TODO}
|
|
13909
14044
|
|
|
13910
|
-
## Hierarchical
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
|
|
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].
|
|
14053
|
+
|
|
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]\`
|
|
13914
14058
|
|
|
13915
|
-
## Template
|
|
14059
|
+
## Template Example
|
|
13916
14060
|
\`\`\`markdown
|
|
13917
14061
|
# Mission: [goal]
|
|
13918
14062
|
|
|
13919
14063
|
## Project Context
|
|
13920
|
-
Runtime: [Node.js/Python/etc]
|
|
13921
|
-
Build: [npm/docker/make]
|
|
13922
|
-
Test: [npm test/pytest/etc]
|
|
13923
|
-
|
|
13924
|
-
## E1: [Epic Name] | status: ${WORK_STATUS.TODO_STATUS.PENDING}
|
|
13925
|
-
### T1.1: [Task] | agent:${AGENT_NAMES.PLANNER}
|
|
13926
|
-
- [ ] S1.1.1: [Research topic] | size:S
|
|
13927
|
-
- [ ] S1.1.2: [Cache docs] | size:S
|
|
13928
|
-
|
|
13929
|
-
### T1.2: [Task] | agent:${AGENT_NAMES.WORKER} | depends:T1.1
|
|
13930
|
-
- [ ] S1.2.1: [Implement feature] | size:M
|
|
13931
|
-
- [ ] S1.2.2: [Add error handling] | size:S
|
|
13932
|
-
- [ ] S1.2.3: [Write tests] | size:M
|
|
13933
|
-
|
|
13934
|
-
### T1.3: [Verify] | agent:${AGENT_NAMES.REVIEWER} | depends:T1.2
|
|
13935
|
-
- [ ] S1.3.1: [Run lsp_diagnostics] | size:XS
|
|
13936
|
-
- [ ] S1.3.2: [Run build] | size:S
|
|
13937
|
-
- [ ] S1.3.3: [Run tests] | size:S
|
|
13938
|
-
|
|
13939
|
-
## E2: [Epic Name] | status: ${WORK_STATUS.TODO_STATUS.PENDING} | depends:E1
|
|
13940
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
|
|
13941
14083
|
\`\`\`
|
|
13942
14084
|
|
|
13943
14085
|
## Planning Rules
|
|
13944
|
-
-
|
|
13945
|
-
-
|
|
13946
|
-
-
|
|
13947
|
-
-
|
|
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.
|
|
13948
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)
|
|
13949
|
-
- If L or larger,
|
|
14091
|
+
- If any task is L or larger, it MUST be broken into subtasks.
|
|
13950
14092
|
|
|
13951
|
-
ALL items MUST start with [ ] (unchecked)
|
|
14093
|
+
ALL items MUST start with [ ] (unchecked) unless already finished.
|
|
13952
14094
|
${PROMPT_TAGS.PLANNING_FORMAT.close}`;
|
|
13953
14095
|
|
|
13954
14096
|
// src/agents/prompts/planner/research.ts
|
|
@@ -14055,13 +14197,14 @@ Create ${PATHS.WORK_LOG}:
|
|
|
14055
14197
|
# Work Log
|
|
14056
14198
|
|
|
14057
14199
|
## File Status
|
|
14058
|
-
| File | Action | Status |
|
|
14200
|
+
| File | Action | Status | ${AGENT_NAMES.WORKER} | Unit Test | Timestamp |
|
|
14059
14201
|
|------|--------|--------|--------|-----------|-----------|
|
|
14060
14202
|
| src/types/auth.ts | ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
14061
14203
|
| src/auth/login.ts | ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
14062
14204
|
| src/auth/logout.ts | ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
14063
14205
|
| src/index.ts | ${WORK_STATUS.ACTION.MODIFY} | ${WORK_STATUS.STATUS.PENDING} | - | - | - |
|
|
14064
14206
|
|
|
14207
|
+
|
|
14065
14208
|
## Active Sessions
|
|
14066
14209
|
(none yet)
|
|
14067
14210
|
|
|
@@ -14108,7 +14251,7 @@ Add NEW subtasks for sync fixes:
|
|
|
14108
14251
|
|
|
14109
14252
|
## \u{1F4CB} DOCUMENT MAINTENANCE RULES
|
|
14110
14253
|
|
|
14111
|
-
### Keep .
|
|
14254
|
+
### Keep ${PATHS.OPENCODE}/ Minimal:
|
|
14112
14255
|
| File | Rule |
|
|
14113
14256
|
|------|------|
|
|
14114
14257
|
| ${PATHS.STATUS} | Overwrite each loop (no history) |
|
|
@@ -14118,7 +14261,7 @@ Add NEW subtasks for sync fixes:
|
|
|
14118
14261
|
|
|
14119
14262
|
### Summarize & Clean:
|
|
14120
14263
|
- **Completed tasks**: Move to archive or delete
|
|
14121
|
-
- **Resolved issues**: DELETE from
|
|
14264
|
+
- **Resolved issues**: DELETE from ${PATHS.SYNC_ISSUES.split("/").pop()}
|
|
14122
14265
|
- **Old status**: Overwrite with current (no append)
|
|
14123
14266
|
- **Long descriptions**: Summarize to 1-2 lines
|
|
14124
14267
|
|
|
@@ -14135,8 +14278,9 @@ Add NEW subtasks for sync fixes:
|
|
|
14135
14278
|
- Blockers
|
|
14136
14279
|
|
|
14137
14280
|
### CRITICAL:
|
|
14138
|
-
-
|
|
14281
|
+
- ${AGENT_NAMES.COMMANDER} should NOT see old/resolved content
|
|
14139
14282
|
- Only current state matters
|
|
14283
|
+
|
|
14140
14284
|
- Less context = faster decisions
|
|
14141
14285
|
${PROMPT_TAGS.TODO_SYNC.close}`;
|
|
14142
14286
|
|
|
@@ -14156,7 +14300,9 @@ ${PROMPT_TAGS.ROLE.close}`;
|
|
|
14156
14300
|
|
|
14157
14301
|
// src/agents/prompts/worker/forbidden.ts
|
|
14158
14302
|
var WORKER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
14159
|
-
|
|
14303
|
+
**FORBIDDEN ACTIONS (Adapt to Project Conventions)**
|
|
14304
|
+
|
|
14305
|
+
|
|
14160
14306
|
|
|
14161
14307
|
## Never Assume
|
|
14162
14308
|
- NEVER guess API syntax \u2192 CHECK ${PATHS.DOCS}/ or research first
|
|
@@ -14165,7 +14311,8 @@ var WORKER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
|
14165
14311
|
|
|
14166
14312
|
## Never Skip
|
|
14167
14313
|
- NEVER skip error handling \u2192 Follow project's error handling patterns
|
|
14168
|
-
- NEVER skip
|
|
14314
|
+
- NEVER skip ${TOOL_NAMES.LSP_DIAGNOSTICS} \u2192 Always verify code compiles
|
|
14315
|
+
|
|
14169
14316
|
- NEVER skip verification \u2192 Test before claiming done
|
|
14170
14317
|
|
|
14171
14318
|
## Never Shortcut
|
|
@@ -14182,7 +14329,8 @@ ${PROMPT_TAGS.FORBIDDEN_ACTIONS.close}`;
|
|
|
14182
14329
|
|
|
14183
14330
|
// src/agents/prompts/worker/required.ts
|
|
14184
14331
|
var WORKER_REQUIRED = `${PROMPT_TAGS.REQUIRED_ACTIONS.open}
|
|
14185
|
-
|
|
14332
|
+
**THINK FIRST**: As WORKER, explore before implementing:
|
|
14333
|
+
|
|
14186
14334
|
|
|
14187
14335
|
## Before Writing ANY Code:
|
|
14188
14336
|
1. Do I fully understand WHAT I'm implementing and WHY?
|
|
@@ -14199,7 +14347,7 @@ var WORKER_REQUIRED = `${PROMPT_TAGS.REQUIRED_ACTIONS.open}
|
|
|
14199
14347
|
- Follow error handling style used in similar files
|
|
14200
14348
|
|
|
14201
14349
|
### ALWAYS Verify
|
|
14202
|
-
- Run
|
|
14350
|
+
- Run ${TOOL_NAMES.LSP_DIAGNOSTICS} after changes
|
|
14203
14351
|
- Run the project's BUILD command (from ${PATHS.CONTEXT})
|
|
14204
14352
|
- Run the project's TEST command (from ${PATHS.CONTEXT})
|
|
14205
14353
|
|
|
@@ -14214,9 +14362,10 @@ ${PROMPT_TAGS.REQUIRED_ACTIONS.close}`;
|
|
|
14214
14362
|
|
|
14215
14363
|
// src/agents/prompts/worker/workflow.ts
|
|
14216
14364
|
var WORKER_WORKFLOW = `${PROMPT_TAGS.WORKFLOW.open}
|
|
14217
|
-
|
|
14365
|
+
ADAPTIVE IMPLEMENTATION WORKFLOW
|
|
14218
14366
|
|
|
14219
14367
|
## Phase 1: UNDERSTAND (Before writing ANY code)
|
|
14368
|
+
|
|
14220
14369
|
1. Read ${PATHS.CONTEXT} \u2192 Get project environment, build/test commands
|
|
14221
14370
|
2. Read ${PATHS.TODO} \u2192 Understand assigned task and acceptance criteria
|
|
14222
14371
|
3. Read ${PATHS.DOCS}/ \u2192 Check for cached API docs, syntax references
|
|
@@ -14225,8 +14374,9 @@ var WORKER_WORKFLOW = `${PROMPT_TAGS.WORKFLOW.open}
|
|
|
14225
14374
|
4. Find SIMILAR code in the project
|
|
14226
14375
|
\`\`\`bash
|
|
14227
14376
|
# Find related files
|
|
14228
|
-
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}
|
|
14229
14378
|
\`\`\`
|
|
14379
|
+
|
|
14230
14380
|
5. Study existing PATTERNS:
|
|
14231
14381
|
- How are errors handled?
|
|
14232
14382
|
- How are tests structured?
|
|
@@ -14235,10 +14385,10 @@ var WORKER_WORKFLOW = `${PROMPT_TAGS.WORKFLOW.open}
|
|
|
14235
14385
|
|
|
14236
14386
|
## Phase 3: RESEARCH (If needed)
|
|
14237
14387
|
6. If docs missing in ${PATHS.DOCS}/:
|
|
14238
|
-
- Use **
|
|
14239
|
-
- Use **
|
|
14240
|
-
- Use **
|
|
14241
|
-
- Example:
|
|
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" })\`
|
|
14242
14392
|
|
|
14243
14393
|
## Phase 4: IMPLEMENT (Following discoveries)
|
|
14244
14394
|
7. Write code following OBSERVED patterns
|
|
@@ -14246,12 +14396,13 @@ var WORKER_WORKFLOW = `${PROMPT_TAGS.WORKFLOW.open}
|
|
|
14246
14396
|
9. Add tests matching project's test style
|
|
14247
14397
|
|
|
14248
14398
|
## Phase 5: VERIFY (Before reporting)
|
|
14249
|
-
10. Run
|
|
14399
|
+
10. Run ${TOOL_NAMES.LSP_DIAGNOSTICS} \u2192 Must be clean
|
|
14400
|
+
|
|
14250
14401
|
11. Run BUILD command from ${PATHS.CONTEXT}
|
|
14251
14402
|
12. Run TEST command from ${PATHS.CONTEXT}
|
|
14252
14403
|
13. Report completion WITH evidence
|
|
14253
14404
|
|
|
14254
|
-
|
|
14405
|
+
**CRITICAL**: Do NOT mark [x] in ${PATHS.TODO} - that's ${AGENT_NAMES.REVIEWER}'s job!
|
|
14255
14406
|
${PROMPT_TAGS.WORKFLOW.close}`;
|
|
14256
14407
|
|
|
14257
14408
|
// src/agents/prompts/worker/quality.ts
|
|
@@ -14306,7 +14457,7 @@ You work on ONE FILE at a time in ISOLATION. Follow this EXACT cycle:
|
|
|
14306
14457
|
2. Read ${PATHS.TODO} - Understand requirements
|
|
14307
14458
|
3. Update ${PATHS.WORK_LOG}:
|
|
14308
14459
|
\`\`\`markdown
|
|
14309
|
-
- [ ] ${ID_PREFIX.SESSION}N (
|
|
14460
|
+
- [ ] ${ID_PREFIX.SESSION}N (${AGENT_NAMES.WORKER}): \`[target-file]\` - ${WORK_STATUS.SESSION.STARTED}
|
|
14310
14461
|
\`\`\`
|
|
14311
14462
|
|
|
14312
14463
|
### Phase 2: TEST FIRST (Red)
|
|
@@ -14358,12 +14509,13 @@ You work on ONE FILE at a time in ISOLATION. Follow this EXACT cycle:
|
|
|
14358
14509
|
- Communication/interaction needed \u2192 Assume dummy response
|
|
14359
14510
|
- Real I/O strictly forbidden
|
|
14360
14511
|
3. **Delete after pass** - Remove isolated test file
|
|
14361
|
-
4. **Record in .
|
|
14512
|
+
4. **Record in ${PATHS.OPENCODE}** - Preserve test code and results
|
|
14362
14513
|
|
|
14363
14514
|
### CRITICAL RULES:
|
|
14364
14515
|
- NEVER skip the test file deletion step
|
|
14365
14516
|
- ALWAYS preserve test code in ${PATHS.UNIT_TESTS}/
|
|
14366
|
-
- NEVER mark [x] in
|
|
14517
|
+
- NEVER mark [x] in ${PATHS.TODO} - ${AGENT_NAMES.REVIEWER}'s job!
|
|
14518
|
+
|
|
14367
14519
|
- ONE file per session - complete isolation
|
|
14368
14520
|
${PROMPT_TAGS.TDD_WORKFLOW.close}`;
|
|
14369
14521
|
|
|
@@ -14371,6 +14523,7 @@ ${PROMPT_TAGS.TDD_WORKFLOW.close}`;
|
|
|
14371
14523
|
var WORKER_ISOLATION_TESTING = `${PROMPT_TAGS.ISOLATION_TESTING.open}
|
|
14372
14524
|
## ISOLATED UNIT TEST RULES
|
|
14373
14525
|
|
|
14526
|
+
|
|
14374
14527
|
### File Naming Convention
|
|
14375
14528
|
\`[original-dir]/__tests__/[filename].isolated.test.ts\`
|
|
14376
14529
|
|
|
@@ -14410,10 +14563,11 @@ Example:
|
|
|
14410
14563
|
* Target: [full-path]
|
|
14411
14564
|
* Session: [session_id]
|
|
14412
14565
|
*
|
|
14413
|
-
*
|
|
14414
|
-
* Test code preserved in: .
|
|
14566
|
+
* **WARNING**: THIS FILE WILL BE DELETED AFTER TEST PASSES
|
|
14567
|
+
* Test code preserved in: ${PATHS.UNIT_TESTS}/
|
|
14415
14568
|
*/
|
|
14416
14569
|
|
|
14570
|
+
|
|
14417
14571
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
14418
14572
|
|
|
14419
14573
|
// Mock all external dependencies BEFORE importing target
|
|
@@ -14455,6 +14609,7 @@ ${PROMPT_TAGS.ISOLATION_TESTING.close}`;
|
|
|
14455
14609
|
var WORKER_FILE_ASSIGNMENT = `${PROMPT_TAGS.FILE_ASSIGNMENT.open}
|
|
14456
14610
|
## FILE ASSIGNMENT PROTOCOL
|
|
14457
14611
|
|
|
14612
|
+
|
|
14458
14613
|
You are assigned ONE FILE per session. Follow this protocol:
|
|
14459
14614
|
|
|
14460
14615
|
### Step 1: Read Shared State
|
|
@@ -14466,7 +14621,7 @@ cat ${PATHS.SYNC_ISSUES} 2>/dev/null || echo "No sync issues"
|
|
|
14466
14621
|
\`\`\`
|
|
14467
14622
|
|
|
14468
14623
|
### Step 2: Identify Your Assignment
|
|
14469
|
-
|
|
14624
|
+
${AGENT_NAMES.COMMANDER} gives you:
|
|
14470
14625
|
- \`file: src/path/to/file.ts\` - Your target file
|
|
14471
14626
|
- \`action: ${WORK_STATUS.ACTION.CREATE} | ${WORK_STATUS.ACTION.MODIFY} | ${WORK_STATUS.ACTION.FIX}\` - What to do
|
|
14472
14627
|
- \`issue: ${ID_PREFIX.SYNC_ISSUE}N\` (optional) - If fixing a sync issue
|
|
@@ -14474,7 +14629,7 @@ Commander gives you:
|
|
|
14474
14629
|
### Step 3: Update Work Log (Start)
|
|
14475
14630
|
\`\`\`markdown
|
|
14476
14631
|
## Active Sessions
|
|
14477
|
-
- [ ] ${ID_PREFIX.SESSION}N (
|
|
14632
|
+
- [ ] ${ID_PREFIX.SESSION}N (${AGENT_NAMES.WORKER}): \`[file]\` - [action] ${WORK_STATUS.SESSION.STARTED}
|
|
14478
14633
|
\`\`\`
|
|
14479
14634
|
|
|
14480
14635
|
### Step 4: Read Context
|
|
@@ -14486,23 +14641,23 @@ Commander gives you:
|
|
|
14486
14641
|
1. Create isolated test
|
|
14487
14642
|
2. Implement
|
|
14488
14643
|
3. Pass test
|
|
14489
|
-
4. Delete test (record in
|
|
14644
|
+
4. Delete test (record in ${PATHS.UNIT_TESTS}/)
|
|
14490
14645
|
|
|
14491
14646
|
### Step 6: Update Work Log (Complete)
|
|
14492
14647
|
\`\`\`markdown
|
|
14493
14648
|
## Active Sessions
|
|
14494
|
-
- [x] ${ID_PREFIX.SESSION}N (
|
|
14649
|
+
- [x] ${ID_PREFIX.SESSION}N (${AGENT_NAMES.WORKER}): \`[file]\` - [action] ${WORK_STATUS.SESSION.COMPLETED}
|
|
14495
14650
|
|
|
14496
14651
|
## File Status (update row)
|
|
14497
14652
|
| [file] | [action] | ${WORK_STATUS.STATUS.DONE} | ${ID_PREFIX.SESSION}N | ${WORK_STATUS.TEST_RESULT.PASS} | [timestamp] |
|
|
14498
14653
|
\`\`\`
|
|
14499
14654
|
|
|
14500
14655
|
### Step 7: Report
|
|
14501
|
-
Report to
|
|
14656
|
+
Report to ${AGENT_NAMES.COMMANDER} via tool result:
|
|
14502
14657
|
\`\`\`
|
|
14503
|
-
|
|
14658
|
+
SUCCESS File: [path]
|
|
14504
14659
|
Action: [${WORK_STATUS.ACTION.CREATE}/${WORK_STATUS.ACTION.MODIFY}/${WORK_STATUS.ACTION.FIX}]
|
|
14505
|
-
Unit Test: ${WORK_STATUS.TEST_RESULT.PASS}
|
|
14660
|
+
Unit Test: ${WORK_STATUS.TEST_RESULT.PASS.toUpperCase()}
|
|
14506
14661
|
Isolated test deleted, recorded in ${PATHS.UNIT_TESTS}/
|
|
14507
14662
|
Ready for integration.
|
|
14508
14663
|
\`\`\`
|
|
@@ -14526,9 +14681,29 @@ Ready for integration.
|
|
|
14526
14681
|
- ONE file only - never touch other files
|
|
14527
14682
|
- ALWAYS update ${PATHS.WORK_LOG} at start and end
|
|
14528
14683
|
- READ ${PATHS.SYNC_ISSUES} if issue: tag is present
|
|
14529
|
-
- Follow
|
|
14684
|
+
- Follow ${AGENT_NAMES.COMMANDER}'s specific instructions
|
|
14530
14685
|
${PROMPT_TAGS.FILE_ASSIGNMENT.close}`;
|
|
14531
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
|
+
|
|
14532
14707
|
// src/agents/prompts/reviewer/role.ts
|
|
14533
14708
|
var REVIEWER_ROLE = `${PROMPT_TAGS.ROLE.open}
|
|
14534
14709
|
You are ${AGENT_NAMES.REVIEWER}. Verification specialist.
|
|
@@ -14545,22 +14720,25 @@ ${PROMPT_TAGS.ROLE.close}`;
|
|
|
14545
14720
|
|
|
14546
14721
|
// src/agents/prompts/reviewer/forbidden.ts
|
|
14547
14722
|
var REVIEWER_FORBIDDEN = `${PROMPT_TAGS.FORBIDDEN_ACTIONS.open}
|
|
14548
|
-
|
|
14723
|
+
**FORBIDDEN ACTIONS**
|
|
14724
|
+
|
|
14725
|
+
|
|
14549
14726
|
|
|
14550
14727
|
## Never Approve Without Verification
|
|
14551
14728
|
- NEVER approve without actually running the project's test command
|
|
14552
|
-
- NEVER skip
|
|
14729
|
+
- NEVER skip ${TOOL_NAMES.LSP_DIAGNOSTICS} check
|
|
14553
14730
|
- NEVER mark [x] without concrete evidence (command outputs)
|
|
14554
14731
|
- NEVER trust "task complete" claims \u2192 Always verify yourself
|
|
14555
14732
|
|
|
14556
14733
|
## Never Assume Quality
|
|
14557
14734
|
- NEVER approve code that doesn't match ${PATHS.DOCS}/
|
|
14558
14735
|
- NEVER approve code that violates project's observed patterns
|
|
14559
|
-
- NEVER mark [x] before task was actually executed by
|
|
14736
|
+
- NEVER mark [x] before task was actually executed by ${AGENT_NAMES.WORKER}
|
|
14560
14737
|
|
|
14561
14738
|
## Never Overstep
|
|
14562
14739
|
- NEVER make architecture changes \u2192 Escalate to ${AGENT_NAMES.COMMANDER}
|
|
14563
|
-
- NEVER implement fixes yourself \u2192 Send back to
|
|
14740
|
+
- NEVER implement fixes yourself \u2192 Send back to ${AGENT_NAMES.WORKER} with clear feedback
|
|
14741
|
+
|
|
14564
14742
|
|
|
14565
14743
|
## Adaptive Verification
|
|
14566
14744
|
- READ ${PATHS.CONTEXT} to know the correct build/test commands
|
|
@@ -14570,14 +14748,14 @@ ${PROMPT_TAGS.FORBIDDEN_ACTIONS.close}`;
|
|
|
14570
14748
|
|
|
14571
14749
|
// src/agents/prompts/reviewer/required.ts
|
|
14572
14750
|
var REVIEWER_REQUIRED = `${PROMPT_TAGS.REQUIRED_ACTIONS.open}
|
|
14573
|
-
|
|
14751
|
+
**THINK FIRST**: As REVIEWER, think about VERIFICATION before checking:
|
|
14574
14752
|
- What are the EXACT acceptance criteria for this task?
|
|
14575
14753
|
- What could APPEAR to work but actually be broken?
|
|
14576
14754
|
- Are there INTEGRATION issues between components?
|
|
14577
14755
|
- What security/performance issues might be HIDDEN?
|
|
14578
14756
|
- Am I verifying THOROUGHLY or just going through motions?
|
|
14579
14757
|
|
|
14580
|
-
ALWAYS run
|
|
14758
|
+
ALWAYS run ${TOOL_NAMES.LSP_DIAGNOSTICS}
|
|
14581
14759
|
ALWAYS run project's BUILD command (from ${PATHS.CONTEXT})
|
|
14582
14760
|
ALWAYS run project's TEST command (from ${PATHS.CONTEXT})
|
|
14583
14761
|
ALWAYS check implementation matches ${PATHS.DOCS}/
|
|
@@ -14585,11 +14763,13 @@ ALWAYS update ${PATHS.TODO} checkboxes ONLY after verification
|
|
|
14585
14763
|
ALWAYS provide ${WORK_STATUS.TEST_RESULT.PASS}/${WORK_STATUS.TEST_RESULT.FAIL} with evidence
|
|
14586
14764
|
ALWAYS check for security issues
|
|
14587
14765
|
ALWAYS verify tests exist for new code
|
|
14588
|
-
${PROMPT_TAGS.REQUIRED_ACTIONS.close}
|
|
14766
|
+
${PROMPT_TAGS.REQUIRED_ACTIONS.close}
|
|
14767
|
+
`;
|
|
14589
14768
|
|
|
14590
14769
|
// src/agents/prompts/reviewer/verification.ts
|
|
14591
14770
|
var REVIEWER_VERIFICATION = `${PROMPT_TAGS.VERIFICATION_PROCESS.open}
|
|
14592
|
-
|
|
14771
|
+
**ADAPTIVE VERIFICATION PROCESS**
|
|
14772
|
+
|
|
14593
14773
|
|
|
14594
14774
|
## Step 1: Read Project Context
|
|
14595
14775
|
\`\`\`bash
|
|
@@ -14600,7 +14780,7 @@ cat ${PATHS.CONTEXT} # Get build/test commands
|
|
|
14600
14780
|
- Note any project-specific verification requirements
|
|
14601
14781
|
|
|
14602
14782
|
## Step 2: Static Analysis
|
|
14603
|
-
|
|
14783
|
+
${TOOL_NAMES.LSP_DIAGNOSTICS} - Must show NO errors or warnings
|
|
14604
14784
|
|
|
14605
14785
|
## Step 3: Build Verification
|
|
14606
14786
|
- Run the project's BUILD command (from ${PATHS.CONTEXT})
|
|
@@ -14626,56 +14806,50 @@ lsp_diagnostics - Must show NO errors or warnings
|
|
|
14626
14806
|
In ${PATHS.TODO}:
|
|
14627
14807
|
- [x] T1: [task] | verified | evidence: [build/test results]
|
|
14628
14808
|
|
|
14629
|
-
|
|
14809
|
+
**CRITICAL**: NEVER mark [x] without running ACTUAL verification commands!
|
|
14630
14810
|
${PROMPT_TAGS.VERIFICATION_PROCESS.close}`;
|
|
14631
14811
|
|
|
14632
14812
|
// src/agents/prompts/reviewer/todo-update.ts
|
|
14633
14813
|
var REVIEWER_TODO_UPDATE = `${PROMPT_TAGS.TODO_MANAGEMENT.open}
|
|
14634
|
-
YOU are the ONLY agent who can mark [x]!
|
|
14814
|
+
YOU are the ONLY agent who can mark leaf tasks as [x]!
|
|
14815
|
+
|
|
14816
|
+
|
|
14817
|
+
## Hierarchical Resolution Rules
|
|
14818
|
+
The completion state MUST propagate from the innermost subtasks up to the root goal.
|
|
14635
14819
|
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
LEVEL 1 (Epic): Mark [x] ONLY when ALL tasks [x]
|
|
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.
|
|
14640
14823
|
|
|
14641
14824
|
## Verification Flow
|
|
14642
|
-
1. ${AGENT_NAMES.WORKER}
|
|
14643
|
-
2.
|
|
14644
|
-
3.
|
|
14645
|
-
4.
|
|
14646
|
-
5.
|
|
14647
|
-
6.
|
|
14648
|
-
|
|
14649
|
-
## 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)
|
|
14650
14833
|
BEFORE:
|
|
14651
14834
|
\`\`\`markdown
|
|
14652
|
-
##
|
|
14653
|
-
|
|
14654
|
-
- [ ]
|
|
14655
|
-
- [
|
|
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}
|
|
14656
14839
|
\`\`\`
|
|
14657
14840
|
|
|
14658
|
-
AFTER (
|
|
14841
|
+
AFTER (T1.2.1.1 verified):
|
|
14659
14842
|
\`\`\`markdown
|
|
14660
|
-
##
|
|
14661
|
-
|
|
14662
|
-
- [x]
|
|
14663
|
-
- [x]
|
|
14664
|
-
\`\`\`
|
|
14665
|
-
|
|
14666
|
-
AFTER (all tasks in epic verified):
|
|
14667
|
-
\`\`\`markdown
|
|
14668
|
-
## E1: Backend API | status: ${WORK_STATUS.TODO_STATUS.COMPLETE}
|
|
14669
|
-
### T1.1: Database schema | ${WORK_STATUS.TODO_STATUS.DONE}
|
|
14670
|
-
...
|
|
14671
|
-
### T1.2: Auth endpoints | ${WORK_STATUS.TODO_STATUS.DONE}
|
|
14672
|
-
...
|
|
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}
|
|
14673
14847
|
\`\`\`
|
|
14674
14848
|
|
|
14675
14849
|
## FORBIDDEN
|
|
14676
|
-
- Marking parent
|
|
14677
|
-
- Marking [x] without verification
|
|
14678
|
-
-
|
|
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.
|
|
14679
14853
|
${PROMPT_TAGS.TODO_MANAGEMENT.close}`;
|
|
14680
14854
|
|
|
14681
14855
|
// src/agents/prompts/reviewer/output.ts
|
|
@@ -14738,15 +14912,15 @@ Do NOT block - check status asynchronously and wait for completion.
|
|
|
14738
14912
|
1. If workers still running:
|
|
14739
14913
|
- Report current status
|
|
14740
14914
|
- DO NOT block or wait indefinitely
|
|
14741
|
-
- Schedule next check (
|
|
14915
|
+
- Schedule next check (${AGENT_NAMES.COMMANDER} will re-invoke)
|
|
14742
14916
|
|
|
14743
14917
|
2. If all workers complete:
|
|
14744
14918
|
- Proceed to integration testing
|
|
14745
14919
|
- Update ${PATHS.INTEGRATION_STATUS}
|
|
14746
14920
|
|
|
14747
|
-
###
|
|
14921
|
+
### ${PATHS.WORK_LOG.split("/").pop()} Interpretation
|
|
14748
14922
|
\`\`\`markdown
|
|
14749
|
-
# Reading
|
|
14923
|
+
# Reading ${PATHS.WORK_LOG.split("/").pop()}:
|
|
14750
14924
|
- [ ] = Still in progress, DO NOT verify yet
|
|
14751
14925
|
- [x] = Unit complete, READY for verification
|
|
14752
14926
|
\`\`\`
|
|
@@ -14755,27 +14929,25 @@ Do NOT block - check status asynchronously and wait for completion.
|
|
|
14755
14929
|
- NEVER verify a file before worker marks [x]
|
|
14756
14930
|
- NEVER block waiting for workers
|
|
14757
14931
|
- Always update ${PATHS.WORK_LOG} with your monitoring status
|
|
14932
|
+
|
|
14758
14933
|
${PROMPT_TAGS.ASYNC_MONITORING.close}`;
|
|
14759
14934
|
|
|
14760
14935
|
// src/agents/prompts/reviewer/integration-testing.ts
|
|
14761
14936
|
var REVIEWER_INTEGRATION_TESTING = `${PROMPT_TAGS.INTEGRATION_TESTING.open}
|
|
14762
|
-
## E2E INTEGRATION TESTING
|
|
14937
|
+
## E2E INTEGRATION TESTING RULES
|
|
14763
14938
|
|
|
14764
|
-
###
|
|
14765
|
-
|
|
14766
|
-
1. **TODO is almost complete** - Most tasks checked [x]
|
|
14767
|
-
2. **All Workers done** - No active sessions in work-log.md
|
|
14768
|
-
3. **Or final verification** - Right before SEALED
|
|
14939
|
+
### 1. Timing
|
|
14940
|
+
Start when **${PATHS.TODO} \u2265 80%** (some Workers still active).
|
|
14769
14941
|
|
|
14770
|
-
### Pre-
|
|
14771
|
-
|
|
14772
|
-
- [ ]
|
|
14773
|
-
- [ ]
|
|
14774
|
-
- [ ]
|
|
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"
|
|
14775
14947
|
|
|
14776
14948
|
### Integration Workflow
|
|
14777
14949
|
|
|
14778
|
-
#### Step 1: Check TODO Status
|
|
14950
|
+
#### Step 1: Check ${PATHS.TODO} Status
|
|
14779
14951
|
\`\`\`bash
|
|
14780
14952
|
cat ${PATHS.TODO}
|
|
14781
14953
|
# If incomplete items exist, wait for E2E
|
|
@@ -14784,7 +14956,7 @@ cat ${PATHS.TODO}
|
|
|
14784
14956
|
#### Step 2: Run Build (language-appropriate)
|
|
14785
14957
|
\`\`\`bash
|
|
14786
14958
|
# Run project build command
|
|
14787
|
-
# If failed, record in
|
|
14959
|
+
# If failed, record in ${PATHS.SYNC_ISSUES}
|
|
14788
14960
|
\`\`\`
|
|
14789
14961
|
|
|
14790
14962
|
#### Step 3: Run Full Tests
|
|
@@ -14809,8 +14981,8 @@ Write to ${PATHS.INTEGRATION_STATUS}:
|
|
|
14809
14981
|
- Timestamp: [ISO timestamp]
|
|
14810
14982
|
|
|
14811
14983
|
## Result
|
|
14812
|
-
- Build: ${
|
|
14813
|
-
- E2E Test: ${
|
|
14984
|
+
- Build: ${STATUS_LABEL.PASS}/${WORK_STATUS.TEST_RESULT.FAIL}
|
|
14985
|
+
- E2E Test: ${STATUS_LABEL.PASS}/${WORK_STATUS.TEST_RESULT.FAIL}
|
|
14814
14986
|
|
|
14815
14987
|
## Sync Issues Found
|
|
14816
14988
|
- (omit if none)
|
|
@@ -14827,15 +14999,16 @@ Write to ${PATHS.INTEGRATION_STATUS}:
|
|
|
14827
14999
|
- [ ] E2E test passes
|
|
14828
15000
|
|
|
14829
15001
|
### LOOP BACK Conditions
|
|
14830
|
-
- ${PATHS.TODO} has incomplete items \u2192
|
|
14831
|
-
- ${PATHS.SYNC_ISSUES} has unresolved issues \u2192
|
|
14832
|
-
- 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
|
+
|
|
14833
15006
|
|
|
14834
15007
|
### CRITICAL:
|
|
14835
|
-
- E2E only at TODO completion time!
|
|
14836
|
-
- Record build/test failures minimally in
|
|
15008
|
+
- E2E only at ${PATHS.TODO} completion time!
|
|
15009
|
+
- Record build/test failures minimally in ${PATHS.SYNC_ISSUES}
|
|
14837
15010
|
- Delete resolved issues, keep only unresolved
|
|
14838
|
-
- All TODO [x] + no issues = SEALED!
|
|
15011
|
+
- All ${PATHS.TODO} [x] + no issues = SEALED!
|
|
14839
15012
|
${PROMPT_TAGS.INTEGRATION_TESTING.close}`;
|
|
14840
15013
|
|
|
14841
15014
|
// src/agents/prompts/reviewer/sync-verification.ts
|
|
@@ -14869,11 +15042,11 @@ npx tsc --noEmit 2>&1 | grep -i "type"
|
|
|
14869
15042
|
|
|
14870
15043
|
---
|
|
14871
15044
|
|
|
14872
|
-
## ISSUE MANAGEMENT RULES
|
|
15045
|
+
## ISSUE MANAGEMENT RULES (CRITICAL)
|
|
14873
15046
|
|
|
14874
|
-
###
|
|
15047
|
+
### ${PATHS.SYNC_ISSUES} Contains UNRESOLVED ONLY
|
|
14875
15048
|
- **Delete resolved issues immediately** (keep file clean)
|
|
14876
|
-
- **Keep only unresolved** (only what
|
|
15049
|
+
- **Keep only unresolved** (only what ${AGENT_NAMES.COMMANDER} needs to read)
|
|
14877
15050
|
- **Summarize if too long** (archive old issues)
|
|
14878
15051
|
|
|
14879
15052
|
### Issue Format (Minimal)
|
|
@@ -14891,7 +15064,7 @@ npx tsc --noEmit 2>&1 | grep -i "type"
|
|
|
14891
15064
|
### After Fix Verification
|
|
14892
15065
|
When re-verifying after fixes:
|
|
14893
15066
|
1. Check if issue is resolved
|
|
14894
|
-
2. If resolved: **DELETE the issue from
|
|
15067
|
+
2. If resolved: **DELETE the issue from ${PATHS.SYNC_ISSUES}**
|
|
14895
15068
|
3. If not resolved: Update issue status, add notes
|
|
14896
15069
|
4. Keep file minimal
|
|
14897
15070
|
|
|
@@ -14916,10 +15089,32 @@ Output SEALED only when:
|
|
|
14916
15089
|
### CRITICAL:
|
|
14917
15090
|
- Always check sync AFTER integration tests
|
|
14918
15091
|
- DELETE resolved issues immediately
|
|
14919
|
-
- Keep
|
|
15092
|
+
- Keep ${PATHS.SYNC_ISSUES} as short as possible
|
|
14920
15093
|
- Ensure ${AGENT_NAMES.COMMANDER} only sees what needs fixing
|
|
15094
|
+
|
|
14921
15095
|
${PROMPT_TAGS.SYNC_VERIFICATION.close}`;
|
|
14922
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
|
+
|
|
14923
15118
|
// src/agents/commander.ts
|
|
14924
15119
|
var systemPrompt = [
|
|
14925
15120
|
CORE_PHILOSOPHY,
|
|
@@ -14938,6 +15133,8 @@ var systemPrompt = [
|
|
|
14938
15133
|
COMMANDER_LOOP_CONTINUATION,
|
|
14939
15134
|
COMMANDER_SYNC_HANDLING,
|
|
14940
15135
|
COMMANDER_RECOVERY,
|
|
15136
|
+
SHARED_LSP_TOOLS,
|
|
15137
|
+
SHARED_AST_TOOLS,
|
|
14941
15138
|
SHARED_WORKSPACE,
|
|
14942
15139
|
ANTI_HALLUCINATION_CORE,
|
|
14943
15140
|
MISSION_SEAL_RULES
|
|
@@ -14963,6 +15160,8 @@ var systemPrompt2 = [
|
|
|
14963
15160
|
PLANNER_FILE_PLANNING,
|
|
14964
15161
|
PLANNER_TODO_SYNC,
|
|
14965
15162
|
PLANNER_RESEARCH,
|
|
15163
|
+
SHARED_LSP_TOOLS,
|
|
15164
|
+
SHARED_AST_TOOLS,
|
|
14966
15165
|
SHARED_WORKSPACE
|
|
14967
15166
|
].join("\n\n");
|
|
14968
15167
|
var planner = {
|
|
@@ -14986,6 +15185,9 @@ var systemPrompt3 = [
|
|
|
14986
15185
|
// TDD-based isolated work
|
|
14987
15186
|
WORKER_TDD_WORKFLOW,
|
|
14988
15187
|
WORKER_ISOLATION_TESTING,
|
|
15188
|
+
WORKER_LSP_TOOLS,
|
|
15189
|
+
SHARED_LSP_TOOLS,
|
|
15190
|
+
SHARED_AST_TOOLS,
|
|
14989
15191
|
VERIFICATION_REQUIREMENTS,
|
|
14990
15192
|
SHARED_WORKSPACE
|
|
14991
15193
|
].join("\n\n");
|
|
@@ -15009,6 +15211,9 @@ var systemPrompt4 = [
|
|
|
15009
15211
|
REVIEWER_ASYNC_MONITORING,
|
|
15010
15212
|
REVIEWER_INTEGRATION_TESTING,
|
|
15011
15213
|
REVIEWER_SYNC_VERIFICATION,
|
|
15214
|
+
REVIEWER_LSP_TOOLS,
|
|
15215
|
+
SHARED_LSP_TOOLS,
|
|
15216
|
+
SHARED_AST_TOOLS,
|
|
15012
15217
|
REVIEWER_OUTPUT,
|
|
15013
15218
|
SHARED_WORKSPACE
|
|
15014
15219
|
].join("\n\n");
|
|
@@ -15035,11 +15240,12 @@ var callAgentTool = tool({
|
|
|
15035
15240
|
<agents>
|
|
15036
15241
|
| Agent | Role | When to Use |
|
|
15037
15242
|
|-------|------|-------------|
|
|
15038
|
-
| ${AGENT_NAMES.PLANNER}
|
|
15039
|
-
| ${AGENT_NAMES.WORKER}
|
|
15040
|
-
| ${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 |
|
|
15041
15246
|
</agents>
|
|
15042
15247
|
|
|
15248
|
+
|
|
15043
15249
|
<execution_rules>
|
|
15044
15250
|
1. Tasks with same parallel_group run CONCURRENTLY
|
|
15045
15251
|
2. Always call Reviewer before marking complete
|
|
@@ -15057,13 +15263,12 @@ var callAgentTool = tool({
|
|
|
15057
15263
|
async execute(args) {
|
|
15058
15264
|
const agentDef = AGENTS[args.agent];
|
|
15059
15265
|
if (!agentDef) {
|
|
15060
|
-
return
|
|
15266
|
+
return `Error: Unknown agent: ${args.agent}`;
|
|
15061
15267
|
}
|
|
15062
|
-
const
|
|
15268
|
+
const label = args.agent[0].toUpperCase();
|
|
15063
15269
|
const prompt = `
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
\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
|
+
|
|
15067
15272
|
|
|
15068
15273
|
<system>
|
|
15069
15274
|
${agentDef.systemPrompt}
|
|
@@ -15106,7 +15311,7 @@ $ARGUMENTS
|
|
|
15106
15311
|
</mission>`;
|
|
15107
15312
|
var COMMANDS = {
|
|
15108
15313
|
"task": {
|
|
15109
|
-
description: "
|
|
15314
|
+
description: "MISSION MODE - Execute task autonomously until complete",
|
|
15110
15315
|
template: MISSION_MODE_TEMPLATE,
|
|
15111
15316
|
argumentHint: '"mission goal"'
|
|
15112
15317
|
},
|
|
@@ -15135,23 +15340,23 @@ var COMMANDS = {
|
|
|
15135
15340
|
},
|
|
15136
15341
|
"agents": {
|
|
15137
15342
|
description: "Show the 4-agent architecture",
|
|
15138
|
-
template: `##
|
|
15343
|
+
template: `## OpenCode Orchestrator - 4-Agent Architecture
|
|
15139
15344
|
|
|
15140
15345
|
| Agent | Role | Capabilities |
|
|
15141
15346
|
|-------|------|--------------|
|
|
15142
|
-
| **${AGENT_NAMES.COMMANDER}**
|
|
15143
|
-
| **${AGENT_NAMES.PLANNER}**
|
|
15144
|
-
| **${AGENT_NAMES.WORKER}**
|
|
15145
|
-
| **${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 |
|
|
15146
15351
|
|
|
15147
|
-
##
|
|
15352
|
+
## Parallel Execution System
|
|
15148
15353
|
\`\`\`
|
|
15149
15354
|
Up to 50 Worker Sessions running simultaneously
|
|
15150
15355
|
Max 10 per agent type (auto-queues excess)
|
|
15151
15356
|
Auto-timeout: 60 min | Auto-cleanup: 30 min
|
|
15152
15357
|
\`\`\`
|
|
15153
15358
|
|
|
15154
|
-
##
|
|
15359
|
+
## Execution Flow
|
|
15155
15360
|
\`\`\`
|
|
15156
15361
|
THINK \u2192 PLAN \u2192 DELEGATE \u2192 EXECUTE \u2192 VERIFY \u2192 COMPLETE
|
|
15157
15362
|
L1: Fast Track (simple fixes)
|
|
@@ -15159,12 +15364,12 @@ THINK \u2192 PLAN \u2192 DELEGATE \u2192 EXECUTE \u2192 VERIFY \u2192 COMPLETE
|
|
|
15159
15364
|
L3: Deep Track (complex refactoring)
|
|
15160
15365
|
\`\`\`
|
|
15161
15366
|
|
|
15162
|
-
##
|
|
15367
|
+
## Anti-Hallucination
|
|
15163
15368
|
- ${AGENT_NAMES.PLANNER} researches BEFORE implementation
|
|
15164
15369
|
- ${AGENT_NAMES.WORKER} caches official documentation
|
|
15165
15370
|
- Never assumes - always verifies from sources
|
|
15166
15371
|
|
|
15167
|
-
##
|
|
15372
|
+
## Usage
|
|
15168
15373
|
- Select **${AGENT_NAMES.COMMANDER}** and type your request
|
|
15169
15374
|
- Or use \`/task "your mission"\` explicitly
|
|
15170
15375
|
- ${AGENT_NAMES.COMMANDER} automatically coordinates all agents`
|
|
@@ -15236,9 +15441,13 @@ async function callRustTool(name, args) {
|
|
|
15236
15441
|
proc.stdout.on("data", (data) => {
|
|
15237
15442
|
stdout += data.toString();
|
|
15238
15443
|
});
|
|
15444
|
+
proc.stderr.on("data", (data) => {
|
|
15445
|
+
const msg = data.toString().trim();
|
|
15446
|
+
if (msg) console.error(`[rust-stderr] ${msg}`);
|
|
15447
|
+
});
|
|
15239
15448
|
const request = JSON.stringify({
|
|
15240
15449
|
jsonrpc: "2.0",
|
|
15241
|
-
id:
|
|
15450
|
+
id: Date.now(),
|
|
15242
15451
|
method: "tools/call",
|
|
15243
15452
|
params: { name, arguments: args }
|
|
15244
15453
|
});
|
|
@@ -15248,13 +15457,25 @@ async function callRustTool(name, args) {
|
|
|
15248
15457
|
proc.kill();
|
|
15249
15458
|
resolve(JSON.stringify({ error: "Timeout" }));
|
|
15250
15459
|
}, 6e4);
|
|
15251
|
-
proc.on("close", () => {
|
|
15460
|
+
proc.on("close", (code) => {
|
|
15252
15461
|
clearTimeout(timeout);
|
|
15462
|
+
if (code !== 0 && code !== null) {
|
|
15463
|
+
console.error(`Rust process exited with code ${code}`);
|
|
15464
|
+
}
|
|
15253
15465
|
try {
|
|
15254
15466
|
const lines = stdout.trim().split("\n");
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
|
|
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");
|
|
15258
15479
|
} catch {
|
|
15259
15480
|
resolve(stdout || "No output");
|
|
15260
15481
|
}
|
|
@@ -15267,12 +15488,16 @@ var grepSearchTool = (directory) => tool({
|
|
|
15267
15488
|
description: "Search code patterns using regex. Returns matching lines with file paths and line numbers.",
|
|
15268
15489
|
args: {
|
|
15269
15490
|
pattern: tool.schema.string().describe("Regex pattern to search for"),
|
|
15270
|
-
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)")
|
|
15271
15494
|
},
|
|
15272
15495
|
async execute(args) {
|
|
15273
15496
|
return callRustTool("grep_search", {
|
|
15274
15497
|
pattern: args.pattern,
|
|
15275
|
-
directory: args.dir || directory
|
|
15498
|
+
directory: args.dir || directory,
|
|
15499
|
+
max_results: args.max_results,
|
|
15500
|
+
timeout_ms: args.timeout_ms
|
|
15276
15501
|
});
|
|
15277
15502
|
}
|
|
15278
15503
|
});
|
|
@@ -15293,16 +15518,17 @@ var mgrepTool = (directory) => tool({
|
|
|
15293
15518
|
description: `Search multiple patterns (runs grep for each pattern).`,
|
|
15294
15519
|
args: {
|
|
15295
15520
|
patterns: tool.schema.array(tool.schema.string()).describe("Array of regex patterns"),
|
|
15296
|
-
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)")
|
|
15297
15524
|
},
|
|
15298
15525
|
async execute(args) {
|
|
15299
|
-
|
|
15300
|
-
|
|
15301
|
-
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
}
|
|
15305
|
-
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
|
+
});
|
|
15306
15532
|
}
|
|
15307
15533
|
});
|
|
15308
15534
|
var sedReplaceTool = (directory) => tool({
|
|
@@ -15313,7 +15539,8 @@ var sedReplaceTool = (directory) => tool({
|
|
|
15313
15539
|
file: tool.schema.string().optional().describe("Single file to modify"),
|
|
15314
15540
|
dir: tool.schema.string().optional().describe("Directory to search (modifies all matching files)"),
|
|
15315
15541
|
dry_run: tool.schema.boolean().optional().describe("Preview changes without modifying files (default: false)"),
|
|
15316
|
-
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")
|
|
15317
15544
|
},
|
|
15318
15545
|
async execute(args) {
|
|
15319
15546
|
return callRustTool("sed_replace", {
|
|
@@ -15322,7 +15549,8 @@ var sedReplaceTool = (directory) => tool({
|
|
|
15322
15549
|
file: args.file,
|
|
15323
15550
|
directory: args.dir || (args.file ? void 0 : directory),
|
|
15324
15551
|
dry_run: args.dry_run,
|
|
15325
|
-
backup: args.backup
|
|
15552
|
+
backup: args.backup,
|
|
15553
|
+
timeout_ms: args.timeout_ms
|
|
15326
15554
|
});
|
|
15327
15555
|
}
|
|
15328
15556
|
});
|
|
@@ -15402,9 +15630,18 @@ var gitStatusTool = (directory) => tool({
|
|
|
15402
15630
|
}
|
|
15403
15631
|
});
|
|
15404
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
|
+
|
|
15405
15642
|
// src/core/commands/manager.ts
|
|
15406
|
-
import { spawn as spawn2 } from "child_process";
|
|
15407
|
-
import { randomBytes } from "crypto";
|
|
15643
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
15644
|
+
import { randomBytes } from "node:crypto";
|
|
15408
15645
|
var BackgroundTaskManager = class _BackgroundTaskManager {
|
|
15409
15646
|
static _instance;
|
|
15410
15647
|
tasks = /* @__PURE__ */ new Map();
|
|
@@ -15431,7 +15668,7 @@ var BackgroundTaskManager = class _BackgroundTaskManager {
|
|
|
15431
15668
|
const id = this.generateId();
|
|
15432
15669
|
const { command, cwd = process.cwd(), timeout = 3e5, label } = options;
|
|
15433
15670
|
const isWindows = process.platform === "win32";
|
|
15434
|
-
const shell = isWindows ? "cmd.exe" :
|
|
15671
|
+
const shell = isWindows ? "cmd.exe" : CLI_NAME.SH;
|
|
15435
15672
|
const shellFlag = isWindows ? "/c" : "-c";
|
|
15436
15673
|
const task = {
|
|
15437
15674
|
id,
|
|
@@ -15439,7 +15676,7 @@ var BackgroundTaskManager = class _BackgroundTaskManager {
|
|
|
15439
15676
|
args: [shellFlag, command],
|
|
15440
15677
|
cwd,
|
|
15441
15678
|
label,
|
|
15442
|
-
status:
|
|
15679
|
+
status: STATUS_LABEL.RUNNING,
|
|
15443
15680
|
output: "",
|
|
15444
15681
|
errorOutput: "",
|
|
15445
15682
|
exitCode: null,
|
|
@@ -15464,27 +15701,27 @@ var BackgroundTaskManager = class _BackgroundTaskManager {
|
|
|
15464
15701
|
proc.on("close", (code) => {
|
|
15465
15702
|
task.exitCode = code;
|
|
15466
15703
|
task.endTime = Date.now();
|
|
15467
|
-
task.status = code === 0 ?
|
|
15704
|
+
task.status = code === 0 ? STATUS_LABEL.DONE : STATUS_LABEL.ERROR;
|
|
15468
15705
|
task.process = void 0;
|
|
15469
15706
|
this.debug(id, `Done (code=${code})`);
|
|
15470
15707
|
});
|
|
15471
15708
|
proc.on("error", (err) => {
|
|
15472
|
-
task.status =
|
|
15709
|
+
task.status = STATUS_LABEL.ERROR;
|
|
15473
15710
|
task.errorOutput += `
|
|
15474
15711
|
Process error: ${err.message}`;
|
|
15475
15712
|
task.endTime = Date.now();
|
|
15476
15713
|
task.process = void 0;
|
|
15477
15714
|
});
|
|
15478
15715
|
setTimeout(() => {
|
|
15479
|
-
if (task.status ===
|
|
15716
|
+
if (task.status === STATUS_LABEL.RUNNING && task.process) {
|
|
15480
15717
|
task.process.kill("SIGKILL");
|
|
15481
|
-
task.status =
|
|
15718
|
+
task.status = STATUS_LABEL.TIMEOUT;
|
|
15482
15719
|
task.endTime = Date.now();
|
|
15483
15720
|
this.debug(id, "Timeout");
|
|
15484
15721
|
}
|
|
15485
15722
|
}, timeout);
|
|
15486
15723
|
} catch (err) {
|
|
15487
|
-
task.status =
|
|
15724
|
+
task.status = STATUS_LABEL.ERROR;
|
|
15488
15725
|
task.errorOutput = `Spawn failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
15489
15726
|
task.endTime = Date.now();
|
|
15490
15727
|
}
|
|
@@ -15502,7 +15739,7 @@ Process error: ${err.message}`;
|
|
|
15502
15739
|
clearCompleted() {
|
|
15503
15740
|
let count = 0;
|
|
15504
15741
|
for (const [id, task] of this.tasks) {
|
|
15505
|
-
if (task.status !==
|
|
15742
|
+
if (task.status !== STATUS_LABEL.RUNNING && task.status !== STATUS_LABEL.PENDING) {
|
|
15506
15743
|
this.tasks.delete(id);
|
|
15507
15744
|
count++;
|
|
15508
15745
|
}
|
|
@@ -15513,7 +15750,7 @@ Process error: ${err.message}`;
|
|
|
15513
15750
|
const task = this.tasks.get(taskId);
|
|
15514
15751
|
if (task?.process) {
|
|
15515
15752
|
task.process.kill("SIGKILL");
|
|
15516
|
-
task.status =
|
|
15753
|
+
task.status = STATUS_LABEL.ERROR;
|
|
15517
15754
|
task.errorOutput += "\nKilled by user";
|
|
15518
15755
|
task.endTime = Date.now();
|
|
15519
15756
|
return true;
|
|
@@ -15527,7 +15764,7 @@ Process error: ${err.message}`;
|
|
|
15527
15764
|
return `${Math.floor(seconds / 60)}m ${(seconds % 60).toFixed(0)}s`;
|
|
15528
15765
|
}
|
|
15529
15766
|
getStatusEmoji(status) {
|
|
15530
|
-
return
|
|
15767
|
+
return getStatusIndicator(status);
|
|
15531
15768
|
}
|
|
15532
15769
|
};
|
|
15533
15770
|
var backgroundTaskManager = BackgroundTaskManager.instance;
|
|
@@ -16289,17 +16526,17 @@ var TaskToastManager = class {
|
|
|
16289
16526
|
lines.push(`Running (${running.length}):${concurrencyInfo}`);
|
|
16290
16527
|
for (const task of running) {
|
|
16291
16528
|
const duration3 = this.formatDuration(task.startedAt);
|
|
16292
|
-
const
|
|
16293
|
-
const isNew = newTask && task.id === newTask.id ? "
|
|
16294
|
-
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}`);
|
|
16295
16532
|
}
|
|
16296
16533
|
}
|
|
16297
16534
|
if (queued.length > 0) {
|
|
16298
16535
|
if (lines.length > 0) lines.push("");
|
|
16299
16536
|
lines.push(`Queued (${queued.length}):`);
|
|
16300
16537
|
for (const task of queued) {
|
|
16301
|
-
const
|
|
16302
|
-
lines.push(`${
|
|
16538
|
+
const bgTag = task.isBackground ? "[W]" : "[P]";
|
|
16539
|
+
lines.push(`${bgTag} ${task.description} (${task.agent})`);
|
|
16303
16540
|
}
|
|
16304
16541
|
}
|
|
16305
16542
|
return lines.join("\n");
|
|
@@ -16314,7 +16551,7 @@ var TaskToastManager = class {
|
|
|
16314
16551
|
const message = this.buildTaskListMessage(newTask);
|
|
16315
16552
|
const running = this.getRunningTasks();
|
|
16316
16553
|
const queued = this.getQueuedTasks();
|
|
16317
|
-
const title = newTask.isBackground ?
|
|
16554
|
+
const title = newTask.isBackground ? `Background Task Started` : `Task Started`;
|
|
16318
16555
|
tuiClient2.tui.showToast({
|
|
16319
16556
|
body: {
|
|
16320
16557
|
title,
|
|
@@ -16340,12 +16577,12 @@ var TaskToastManager = class {
|
|
|
16340
16577
|
let variant;
|
|
16341
16578
|
if (info.status === "error" || info.status === "cancelled") {
|
|
16342
16579
|
title = info.status === "error" ? "Task Failed" : "Task Cancelled";
|
|
16343
|
-
message =
|
|
16580
|
+
message = `[FAIL] "${info.description}" ${info.status}
|
|
16344
16581
|
${info.error || ""}`;
|
|
16345
16582
|
variant = "error";
|
|
16346
16583
|
} else {
|
|
16347
16584
|
title = "Task Completed";
|
|
16348
|
-
message =
|
|
16585
|
+
message = `[DONE] "${info.description}" finished in ${info.duration}`;
|
|
16349
16586
|
variant = "success";
|
|
16350
16587
|
}
|
|
16351
16588
|
if (remaining.length > 0 || queued.length > 0) {
|
|
@@ -16372,10 +16609,10 @@ Still running: ${remaining.length} | Queued: ${queued.length}`;
|
|
|
16372
16609
|
if (!tuiClient2.tui?.showToast) return;
|
|
16373
16610
|
const successCount = completedTasks.filter((t) => t.status === TASK_STATUS.COMPLETED).length;
|
|
16374
16611
|
const failCount = completedTasks.filter((t) => t.status === TASK_STATUS.ERROR || t.status === TASK_STATUS.CANCELLED).length;
|
|
16375
|
-
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");
|
|
16376
16613
|
tuiClient2.tui.showToast({
|
|
16377
16614
|
body: {
|
|
16378
|
-
title: "
|
|
16615
|
+
title: "All Tasks Completed",
|
|
16379
16616
|
message: `${successCount} succeeded, ${failCount} failed
|
|
16380
16617
|
|
|
16381
16618
|
${taskList}`,
|
|
@@ -16395,10 +16632,10 @@ ${taskList}`,
|
|
|
16395
16632
|
const task = this.tasks.get(taskId);
|
|
16396
16633
|
if (!task) return;
|
|
16397
16634
|
const percentage = Math.round(progress.current / progress.total * 100);
|
|
16398
|
-
const progressBar = `[${"
|
|
16635
|
+
const progressBar = `[${"#".repeat(Math.floor(percentage / 10))}${"-".repeat(10 - Math.floor(percentage / 10))}]`;
|
|
16399
16636
|
tuiClient2.tui.showToast({
|
|
16400
16637
|
body: {
|
|
16401
|
-
title:
|
|
16638
|
+
title: `Task Progress: ${task.description}`,
|
|
16402
16639
|
message: `${progressBar} ${percentage}%
|
|
16403
16640
|
${progress.message || ""}`,
|
|
16404
16641
|
variant: "info",
|
|
@@ -17064,7 +17301,7 @@ async function validateSessionHasOutput(session, sessionID) {
|
|
|
17064
17301
|
});
|
|
17065
17302
|
return hasContent;
|
|
17066
17303
|
} catch (error45) {
|
|
17067
|
-
log2(
|
|
17304
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Error validating session output:`, error45);
|
|
17068
17305
|
return true;
|
|
17069
17306
|
}
|
|
17070
17307
|
}
|
|
@@ -17078,11 +17315,11 @@ async function pollWithSafetyLimits(session, sessionID, startTime) {
|
|
|
17078
17315
|
pollCount++;
|
|
17079
17316
|
const elapsed = Date.now() - startTime;
|
|
17080
17317
|
if (elapsed >= SYNC_TIMEOUT_MS) {
|
|
17081
|
-
log2(
|
|
17318
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Hard timeout reached`, { pollCount, elapsed });
|
|
17082
17319
|
return { success: false, timedOut: true, pollCount, elapsedMs: elapsed };
|
|
17083
17320
|
}
|
|
17084
17321
|
if (Date.now() - lastLogTime > 1e4) {
|
|
17085
|
-
log2(
|
|
17322
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Polling...`, {
|
|
17086
17323
|
pollCount,
|
|
17087
17324
|
elapsed: Math.floor(elapsed / 1e3) + "s",
|
|
17088
17325
|
stablePolls,
|
|
@@ -17110,14 +17347,14 @@ async function pollWithSafetyLimits(session, sessionID, startTime) {
|
|
|
17110
17347
|
if (!hasValidOutput) {
|
|
17111
17348
|
continue;
|
|
17112
17349
|
}
|
|
17113
|
-
log2(
|
|
17350
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Valid output detected`, { pollCount, elapsed });
|
|
17114
17351
|
}
|
|
17115
17352
|
const msgs = await session.messages({ path: { id: sessionID } });
|
|
17116
17353
|
const count = (msgs.data ?? []).length;
|
|
17117
17354
|
if (count === lastMsgCount) {
|
|
17118
17355
|
stablePolls++;
|
|
17119
17356
|
if (stablePolls >= STABLE_POLLS_REQUIRED) {
|
|
17120
|
-
log2(
|
|
17357
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Stable completion`, { pollCount, stablePolls, elapsed });
|
|
17121
17358
|
return { success: true, timedOut: false, pollCount, elapsedMs: elapsed };
|
|
17122
17359
|
}
|
|
17123
17360
|
} else {
|
|
@@ -17125,10 +17362,10 @@ async function pollWithSafetyLimits(session, sessionID, startTime) {
|
|
|
17125
17362
|
lastMsgCount = count;
|
|
17126
17363
|
}
|
|
17127
17364
|
} catch (error45) {
|
|
17128
|
-
log2(
|
|
17365
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Poll error (continuing):`, error45);
|
|
17129
17366
|
}
|
|
17130
17367
|
}
|
|
17131
|
-
log2(
|
|
17368
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Max poll count reached`, { pollCount, elapsed: Date.now() - startTime });
|
|
17132
17369
|
return {
|
|
17133
17370
|
success: false,
|
|
17134
17371
|
timedOut: true,
|
|
@@ -17145,7 +17382,7 @@ async function extractSessionResult(session, sessionID) {
|
|
|
17145
17382
|
const text = lastMsg?.parts?.filter((p) => p.type === PART_TYPES.TEXT || p.type === PART_TYPES.REASONING).map((p) => p.text ?? "").join("\n") || "";
|
|
17146
17383
|
return text;
|
|
17147
17384
|
} catch (error45) {
|
|
17148
|
-
log2(
|
|
17385
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Error extracting result:`, error45);
|
|
17149
17386
|
return "(Error extracting result)";
|
|
17150
17387
|
}
|
|
17151
17388
|
}
|
|
@@ -17178,10 +17415,10 @@ var createDelegateTaskTool = (manager, client) => tool({
|
|
|
17178
17415
|
async execute(args, context) {
|
|
17179
17416
|
const { agent, description, prompt, background, resume } = args;
|
|
17180
17417
|
const ctx = context;
|
|
17181
|
-
log2(
|
|
17418
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} execute() called`, { agent, description, background, resume, parentSession: ctx.sessionID });
|
|
17182
17419
|
const sessionClient = client;
|
|
17183
17420
|
if (background === void 0) {
|
|
17184
|
-
return
|
|
17421
|
+
return `${OUTPUT_LABEL.ERROR} 'background' parameter is REQUIRED.`;
|
|
17185
17422
|
}
|
|
17186
17423
|
if (resume) {
|
|
17187
17424
|
try {
|
|
@@ -17191,24 +17428,24 @@ var createDelegateTaskTool = (manager, client) => tool({
|
|
|
17191
17428
|
parentSessionID: ctx.sessionID
|
|
17192
17429
|
});
|
|
17193
17430
|
if (background === true) {
|
|
17194
|
-
return
|
|
17431
|
+
return `${OUTPUT_LABEL.RESUME} task: \`${task.id}\` (${task.agent}) in session \`${task.sessionID}\`
|
|
17195
17432
|
|
|
17196
17433
|
Previous context preserved. Use \`get_task_result({ taskId: "${task.id}" })\` when complete.`;
|
|
17197
17434
|
}
|
|
17198
17435
|
const startTime = Date.now();
|
|
17199
17436
|
const session = sessionClient.session;
|
|
17200
|
-
log2(
|
|
17437
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Resume: starting sync wait`, { taskId: task.id, sessionID: task.sessionID });
|
|
17201
17438
|
const pollResult = await pollWithSafetyLimits(session, task.sessionID, startTime);
|
|
17202
17439
|
if (pollResult.timedOut) {
|
|
17203
|
-
return
|
|
17440
|
+
return `${OUTPUT_LABEL.TIMEOUT} after ${Math.floor(pollResult.elapsedMs / 1e3)}s (${pollResult.pollCount} polls)
|
|
17204
17441
|
Session: \`${task.sessionID}\` - Use get_task_result or resume later.`;
|
|
17205
17442
|
}
|
|
17206
17443
|
const text = await extractSessionResult(session, task.sessionID);
|
|
17207
|
-
return
|
|
17444
|
+
return `${OUTPUT_LABEL.RESUMED_DONE} (${Math.floor(pollResult.elapsedMs / 1e3)}s)
|
|
17208
17445
|
|
|
17209
17446
|
${text || "(No output)"}`;
|
|
17210
17447
|
} catch (error45) {
|
|
17211
|
-
return
|
|
17448
|
+
return `${OUTPUT_LABEL.ERROR} Resume failed: ${error45 instanceof Error ? error45.message : String(error45)}`;
|
|
17212
17449
|
}
|
|
17213
17450
|
}
|
|
17214
17451
|
if (background === true) {
|
|
@@ -17220,10 +17457,10 @@ ${text || "(No output)"}`;
|
|
|
17220
17457
|
parentSessionID: ctx.sessionID
|
|
17221
17458
|
});
|
|
17222
17459
|
presets.taskStarted(task.id, agent);
|
|
17223
|
-
return
|
|
17460
|
+
return `${OUTPUT_LABEL.SPAWNED} task: \`${task.id}\` (${agent})
|
|
17224
17461
|
Session: \`${task.sessionID}\` (save for resume)`;
|
|
17225
17462
|
} catch (error45) {
|
|
17226
|
-
return
|
|
17463
|
+
return `${OUTPUT_LABEL.ERROR} Failed: ${error45 instanceof Error ? error45.message : String(error45)}`;
|
|
17227
17464
|
}
|
|
17228
17465
|
}
|
|
17229
17466
|
try {
|
|
@@ -17233,11 +17470,11 @@ Session: \`${task.sessionID}\` (save for resume)`;
|
|
|
17233
17470
|
query: { directory: "." }
|
|
17234
17471
|
});
|
|
17235
17472
|
if (createResult.error || !createResult.data?.id) {
|
|
17236
|
-
return
|
|
17473
|
+
return `${OUTPUT_LABEL.ERROR} Failed to create session: ${createResult.error || "No session ID returned"}`;
|
|
17237
17474
|
}
|
|
17238
17475
|
const sessionID = createResult.data.id;
|
|
17239
17476
|
const startTime = Date.now();
|
|
17240
|
-
log2(
|
|
17477
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Sync: starting`, { agent, sessionID });
|
|
17241
17478
|
await session.prompt({
|
|
17242
17479
|
path: { id: sessionID },
|
|
17243
17480
|
body: {
|
|
@@ -17253,19 +17490,19 @@ Session: \`${task.sessionID}\` (save for resume)`;
|
|
|
17253
17490
|
});
|
|
17254
17491
|
const pollResult = await pollWithSafetyLimits(session, sessionID, startTime);
|
|
17255
17492
|
if (pollResult.timedOut) {
|
|
17256
|
-
log2(
|
|
17257
|
-
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)
|
|
17258
17495
|
Session: \`${sessionID}\` - Use get_task_result or resume later.`;
|
|
17259
17496
|
}
|
|
17260
17497
|
const text = await extractSessionResult(session, sessionID);
|
|
17261
|
-
log2(
|
|
17262
|
-
return
|
|
17498
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Sync: completed`, { sessionID, elapsedMs: pollResult.elapsedMs });
|
|
17499
|
+
return `${OUTPUT_LABEL.DONE} (${Math.floor(pollResult.elapsedMs / 1e3)}s)
|
|
17263
17500
|
Session: \`${sessionID}\` (save for resume)
|
|
17264
17501
|
|
|
17265
17502
|
${text || "(No output)"}`;
|
|
17266
17503
|
} catch (error45) {
|
|
17267
|
-
log2(
|
|
17268
|
-
return
|
|
17504
|
+
log2(`${PARALLEL_LOG.DELEGATE_TASK} Sync: error`, error45);
|
|
17505
|
+
return `${OUTPUT_LABEL.ERROR} Failed: ${error45 instanceof Error ? error45.message : String(error45)}`;
|
|
17269
17506
|
}
|
|
17270
17507
|
}
|
|
17271
17508
|
});
|
|
@@ -17278,14 +17515,14 @@ var createGetTaskResultTool = (manager) => tool({
|
|
|
17278
17515
|
},
|
|
17279
17516
|
async execute(args) {
|
|
17280
17517
|
const task = manager.getTask(args.taskId);
|
|
17281
|
-
if (!task) return
|
|
17282
|
-
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...`;
|
|
17283
17520
|
const result = await manager.getResult(args.taskId);
|
|
17284
17521
|
const duration3 = manager.formatDuration(task.startedAt, task.completedAt);
|
|
17285
|
-
if (task.status ===
|
|
17286
|
-
return
|
|
17522
|
+
if (task.status === STATUS_LABEL.ERROR || task.status === STATUS_LABEL.TIMEOUT) {
|
|
17523
|
+
return `[${task.status.toUpperCase()}] ${task.error}`;
|
|
17287
17524
|
}
|
|
17288
|
-
return
|
|
17525
|
+
return `${OUTPUT_LABEL.DONE} Completed in ${duration3}
|
|
17289
17526
|
|
|
17290
17527
|
${result || "(No output)"}`;
|
|
17291
17528
|
}
|
|
@@ -17298,27 +17535,27 @@ var createListTasksTool = (manager) => tool({
|
|
|
17298
17535
|
status: tool.schema.string().optional().describe("Filter: all, running, completed, error")
|
|
17299
17536
|
},
|
|
17300
17537
|
async execute(args) {
|
|
17301
|
-
const { status =
|
|
17538
|
+
const { status = STATUS_LABEL.ALL } = args;
|
|
17302
17539
|
let tasks;
|
|
17303
17540
|
switch (status) {
|
|
17304
|
-
case
|
|
17541
|
+
case STATUS_LABEL.RUNNING:
|
|
17305
17542
|
tasks = manager.getRunningTasks();
|
|
17306
17543
|
break;
|
|
17307
|
-
case
|
|
17544
|
+
case STATUS_LABEL.COMPLETED:
|
|
17308
17545
|
tasks = manager.getAllTasks().filter((t) => t.status === TASK_STATUS.COMPLETED);
|
|
17309
17546
|
break;
|
|
17310
|
-
case
|
|
17547
|
+
case STATUS_LABEL.ERROR:
|
|
17311
17548
|
tasks = manager.getAllTasks().filter((t) => t.status === TASK_STATUS.ERROR || t.status === TASK_STATUS.TIMEOUT);
|
|
17312
17549
|
break;
|
|
17313
17550
|
default:
|
|
17314
17551
|
tasks = manager.getAllTasks();
|
|
17315
17552
|
}
|
|
17316
|
-
if (tasks.length === 0) return
|
|
17553
|
+
if (tasks.length === 0) return `No tasks found.`;
|
|
17317
17554
|
const rows = tasks.map((t) => {
|
|
17318
17555
|
const elapsed = Math.floor((Date.now() - t.startedAt.getTime()) / 1e3);
|
|
17319
|
-
return `| \`${t.id}\` | ${
|
|
17556
|
+
return `| \`${t.id}\` | [${t.status.toUpperCase()}] | ${t.agent} | ${elapsed}s |`;
|
|
17320
17557
|
}).join("\n");
|
|
17321
|
-
return
|
|
17558
|
+
return `**Tasks List**
|
|
17322
17559
|
|
|
17323
17560
|
| ID | Status | Agent | Time |
|
|
17324
17561
|
|----|--------|-------|------|
|
|
@@ -17334,23 +17571,67 @@ var createCancelTaskTool = (manager) => tool({
|
|
|
17334
17571
|
},
|
|
17335
17572
|
async execute(args) {
|
|
17336
17573
|
const cancelled = await manager.cancelTask(args.taskId);
|
|
17337
|
-
if (cancelled) return
|
|
17574
|
+
if (cancelled) return `${OUTPUT_LABEL.CANCELLED} task: \`${args.taskId}\``;
|
|
17338
17575
|
const task = manager.getTask(args.taskId);
|
|
17339
|
-
if (task) return
|
|
17340
|
-
return
|
|
17576
|
+
if (task) return `${OUTPUT_LABEL.WARNING} Cannot cancel: Task is ${task.status}`;
|
|
17577
|
+
return `${OUTPUT_LABEL.ERROR} Not found: \`${args.taskId}\``;
|
|
17341
17578
|
}
|
|
17342
17579
|
});
|
|
17343
17580
|
|
|
17344
17581
|
// src/tools/parallel/index.ts
|
|
17345
17582
|
function createAsyncAgentTools(manager, client) {
|
|
17346
17583
|
return {
|
|
17347
|
-
|
|
17348
|
-
|
|
17349
|
-
|
|
17350
|
-
|
|
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)
|
|
17351
17588
|
};
|
|
17352
17589
|
}
|
|
17353
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
|
+
|
|
17354
17635
|
// src/core/cache/constants.ts
|
|
17355
17636
|
var CACHE_DIR = PATHS.DOCS;
|
|
17356
17637
|
var METADATA_FILE = PATHS.DOC_METADATA;
|
|
@@ -17554,7 +17835,7 @@ webfetch({ url: "https://react.dev/reference/react/useEffect", cache: true })
|
|
|
17554
17835
|
if (cache) {
|
|
17555
17836
|
const cached2 = await get(url2);
|
|
17556
17837
|
if (cached2) {
|
|
17557
|
-
return
|
|
17838
|
+
return `${OUTPUT_LABEL.CACHED} (fetched: ${cached2.fetchedAt})
|
|
17558
17839
|
|
|
17559
17840
|
${cached2.content}`;
|
|
17560
17841
|
}
|
|
@@ -17569,7 +17850,7 @@ ${cached2.content}`;
|
|
|
17569
17850
|
// 30 second timeout
|
|
17570
17851
|
});
|
|
17571
17852
|
if (!response.ok) {
|
|
17572
|
-
return
|
|
17853
|
+
return `Failed to fetch: HTTP ${response.status} ${response.statusText}`;
|
|
17573
17854
|
}
|
|
17574
17855
|
const contentType = response.headers.get("content-type") || "";
|
|
17575
17856
|
const html = await response.text();
|
|
@@ -17577,13 +17858,13 @@ ${cached2.content}`;
|
|
|
17577
17858
|
const content = JSON.stringify(JSON.parse(html), null, 2);
|
|
17578
17859
|
if (cache) {
|
|
17579
17860
|
const filename = await set2(url2, content, "JSON Response");
|
|
17580
|
-
return
|
|
17861
|
+
return `${OUTPUT_LABEL.JSON_FETCHED} (cached: ${PATHS.DOCS}/${filename})
|
|
17581
17862
|
|
|
17582
17863
|
\`\`\`json
|
|
17583
17864
|
${content.slice(0, 5e3)}
|
|
17584
17865
|
\`\`\``;
|
|
17585
17866
|
}
|
|
17586
|
-
return
|
|
17867
|
+
return `${OUTPUT_LABEL.JSON_FETCHED}
|
|
17587
17868
|
|
|
17588
17869
|
\`\`\`json
|
|
17589
17870
|
${content.slice(0, 5e3)}
|
|
@@ -17592,11 +17873,11 @@ ${content.slice(0, 5e3)}
|
|
|
17592
17873
|
if (contentType.includes("text/plain")) {
|
|
17593
17874
|
if (cache) {
|
|
17594
17875
|
const filename = await set2(url2, html, "Plain Text");
|
|
17595
|
-
return
|
|
17876
|
+
return `${OUTPUT_LABEL.TEXT_FETCHED} (cached: ${PATHS.DOCS}/${filename})
|
|
17596
17877
|
|
|
17597
17878
|
${html.slice(0, 1e4)}`;
|
|
17598
17879
|
}
|
|
17599
|
-
return
|
|
17880
|
+
return `${OUTPUT_LABEL.TEXT_FETCHED}
|
|
17600
17881
|
|
|
17601
17882
|
${html.slice(0, 1e4)}`;
|
|
17602
17883
|
}
|
|
@@ -17606,7 +17887,7 @@ ${html.slice(0, 1e4)}`;
|
|
|
17606
17887
|
const truncated = markdown.length > 15e3 ? markdown.slice(0, 15e3) + "\n\n... [Content truncated]" : markdown;
|
|
17607
17888
|
if (cache) {
|
|
17608
17889
|
const filename = await set2(url2, truncated, title);
|
|
17609
|
-
return
|
|
17890
|
+
return `[${title}]
|
|
17610
17891
|
Source: ${url2}
|
|
17611
17892
|
Cached: ${PATHS.DOCS}/${filename}
|
|
17612
17893
|
|
|
@@ -17614,7 +17895,7 @@ Cached: ${PATHS.DOCS}/${filename}
|
|
|
17614
17895
|
|
|
17615
17896
|
${truncated}`;
|
|
17616
17897
|
}
|
|
17617
|
-
return
|
|
17898
|
+
return `[${title}]
|
|
17618
17899
|
Source: ${url2}
|
|
17619
17900
|
|
|
17620
17901
|
---
|
|
@@ -17623,11 +17904,11 @@ ${truncated}`;
|
|
|
17623
17904
|
} catch (error45) {
|
|
17624
17905
|
if (error45 instanceof Error) {
|
|
17625
17906
|
if (error45.name === "TimeoutError") {
|
|
17626
|
-
return
|
|
17907
|
+
return `${OUTPUT_LABEL.TIMEOUT} Request timed out after 30 seconds`;
|
|
17627
17908
|
}
|
|
17628
|
-
return
|
|
17909
|
+
return `${OUTPUT_LABEL.ERROR} Fetch error: ${error45.message}`;
|
|
17629
17910
|
}
|
|
17630
|
-
return
|
|
17911
|
+
return `${OUTPUT_LABEL.ERROR} Unknown error occurred`;
|
|
17631
17912
|
}
|
|
17632
17913
|
}
|
|
17633
17914
|
});
|
|
@@ -17845,7 +18126,7 @@ websearch({ query: "TypeScript generic constraints site:typescriptlang.org" })
|
|
|
17845
18126
|
}
|
|
17846
18127
|
}
|
|
17847
18128
|
if (results.length === 0) {
|
|
17848
|
-
return
|
|
18129
|
+
return `No results found for: "${query}"
|
|
17849
18130
|
|
|
17850
18131
|
Try:
|
|
17851
18132
|
- Different keywords
|
|
@@ -17854,10 +18135,10 @@ Try:
|
|
|
17854
18135
|
- Add "docs" or "official" for documentation`;
|
|
17855
18136
|
}
|
|
17856
18137
|
const limitedResults = results.slice(0, maxResults);
|
|
17857
|
-
let output =
|
|
18138
|
+
let output = `[Web Search Results for]: "${query}"
|
|
17858
18139
|
|
|
17859
18140
|
`;
|
|
17860
|
-
output +=
|
|
18141
|
+
output += `Provider: ${provider} | Found ${results.length} results (showing ${limitedResults.length})
|
|
17861
18142
|
|
|
17862
18143
|
---
|
|
17863
18144
|
|
|
@@ -17866,7 +18147,7 @@ Try:
|
|
|
17866
18147
|
const result = limitedResults[i];
|
|
17867
18148
|
output += `### ${i + 1}. ${result.title}
|
|
17868
18149
|
`;
|
|
17869
|
-
output +=
|
|
18150
|
+
output += `URL: ${result.url}
|
|
17870
18151
|
|
|
17871
18152
|
`;
|
|
17872
18153
|
if (result.snippet) {
|
|
@@ -17878,7 +18159,7 @@ Try:
|
|
|
17878
18159
|
output += `---
|
|
17879
18160
|
|
|
17880
18161
|
`;
|
|
17881
|
-
output +=
|
|
18162
|
+
output += `Tip: Use \`webfetch\` to get full content from any of these URLs.`;
|
|
17882
18163
|
return output;
|
|
17883
18164
|
}
|
|
17884
18165
|
});
|
|
@@ -18094,14 +18375,14 @@ codesearch({ query: "next.js middleware redirect", repo: "vercel/next.js" })
|
|
|
18094
18375
|
results = await searchGitHub(query, { language });
|
|
18095
18376
|
}
|
|
18096
18377
|
if (results.length === 0) {
|
|
18097
|
-
return
|
|
18378
|
+
return `No code results found for: "${query}"
|
|
18098
18379
|
|
|
18099
18380
|
Try:
|
|
18100
18381
|
- Different search terms
|
|
18101
18382
|
- Broader language filter
|
|
18102
18383
|
- Check spelling`;
|
|
18103
18384
|
}
|
|
18104
|
-
let output =
|
|
18385
|
+
let output = `[Code Search Results for]: "${query}"
|
|
18105
18386
|
|
|
18106
18387
|
`;
|
|
18107
18388
|
output += `Found ${results.length} results${language ? ` (${language})` : ""}
|
|
@@ -18113,9 +18394,9 @@ Try:
|
|
|
18113
18394
|
const r = results[i];
|
|
18114
18395
|
output += `### ${i + 1}. ${r.repo}
|
|
18115
18396
|
`;
|
|
18116
|
-
output +=
|
|
18397
|
+
output += `Path: \`${r.file}\`${r.line ? `:${r.line}` : ""}
|
|
18117
18398
|
`;
|
|
18118
|
-
output +=
|
|
18399
|
+
output += `URL: ${r.url}
|
|
18119
18400
|
|
|
18120
18401
|
`;
|
|
18121
18402
|
if (r.content && r.content !== "(Use webfetch for full content)") {
|
|
@@ -18129,11 +18410,36 @@ ${r.content}
|
|
|
18129
18410
|
output += `---
|
|
18130
18411
|
|
|
18131
18412
|
`;
|
|
18132
|
-
output +=
|
|
18413
|
+
output += `Tip: Use \`webfetch\` to get the full file content from any of these URLs.`;
|
|
18133
18414
|
return output;
|
|
18134
18415
|
}
|
|
18135
18416
|
});
|
|
18136
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
|
+
|
|
18137
18443
|
// src/core/progress/store.ts
|
|
18138
18444
|
var progressHistory = /* @__PURE__ */ new Map();
|
|
18139
18445
|
var sessionStartTimes = /* @__PURE__ */ new Map();
|
|
@@ -18500,14 +18806,14 @@ function generateContinuationPrompt(todos) {
|
|
|
18500
18806
|
const pendingTasks = incomplete.filter((t) => t.status === TODO_STATUS.PENDING);
|
|
18501
18807
|
const pendingCount = pendingTasks.length;
|
|
18502
18808
|
let prompt = `<todo_continuation>
|
|
18503
|
-
|
|
18809
|
+
[TODO Progress]: ${formatProgress(todos)}
|
|
18504
18810
|
|
|
18505
18811
|
**Incomplete Tasks** (${incomplete.length} remaining):
|
|
18506
18812
|
`;
|
|
18507
18813
|
for (const todo of incomplete.slice(0, 5)) {
|
|
18508
|
-
const
|
|
18509
|
-
const
|
|
18510
|
-
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}
|
|
18511
18817
|
`;
|
|
18512
18818
|
}
|
|
18513
18819
|
if (incomplete.length > 5) {
|
|
@@ -18516,19 +18822,19 @@ function generateContinuationPrompt(todos) {
|
|
|
18516
18822
|
}
|
|
18517
18823
|
if (pendingCount >= 2) {
|
|
18518
18824
|
prompt += `
|
|
18519
|
-
|
|
18825
|
+
[PARALLEL DISPATCH REQUIRED]
|
|
18520
18826
|
You have ${pendingCount} pending tasks. Launch them ALL IN PARALLEL for maximum efficiency:
|
|
18521
18827
|
|
|
18522
18828
|
\`\`\`
|
|
18523
18829
|
// EXECUTE NOW - Launch all ${pendingCount} tasks simultaneously:
|
|
18524
18830
|
`;
|
|
18525
18831
|
for (const todo of pendingTasks.slice(0, 6)) {
|
|
18526
|
-
prompt += `delegate_task({ agent: "
|
|
18832
|
+
prompt += `delegate_task({ agent: "${AGENT_NAMES.WORKER}", prompt: "${todo.content}", background: true })
|
|
18527
18833
|
`;
|
|
18528
18834
|
}
|
|
18529
18835
|
prompt += `\`\`\`
|
|
18530
18836
|
|
|
18531
|
-
|
|
18837
|
+
NOTICE: Do NOT run these sequentially. Use background=true for ALL.
|
|
18532
18838
|
After launching, use list_tasks to monitor progress.
|
|
18533
18839
|
|
|
18534
18840
|
`;
|
|
@@ -19094,6 +19400,17 @@ function cleanupSession2(sessionID) {
|
|
|
19094
19400
|
sessionStates2.delete(sessionID);
|
|
19095
19401
|
}
|
|
19096
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
|
+
|
|
19097
19414
|
// src/plugin-handlers/event-handler.ts
|
|
19098
19415
|
function createEventHandler(ctx) {
|
|
19099
19416
|
const { client, directory, sessions, state: state2 } = ctx;
|
|
@@ -19122,6 +19439,7 @@ function createEventHandler(ctx) {
|
|
|
19122
19439
|
cleanupSessionRecovery(sessionID);
|
|
19123
19440
|
cleanupSession(sessionID);
|
|
19124
19441
|
cleanupSession2(sessionID);
|
|
19442
|
+
cleanupSession3(sessionID);
|
|
19125
19443
|
presets.sessionCompleted(sessionID, duration3);
|
|
19126
19444
|
}
|
|
19127
19445
|
}
|
|
@@ -19373,12 +19691,56 @@ function createChatMessageHandler(ctx) {
|
|
|
19373
19691
|
};
|
|
19374
19692
|
}
|
|
19375
19693
|
|
|
19376
|
-
// src/utils/sanity.ts
|
|
19694
|
+
// src/utils/sanity/constants/severity.ts
|
|
19377
19695
|
var SEVERITY = {
|
|
19378
19696
|
OK: "ok",
|
|
19379
19697
|
WARNING: "warning",
|
|
19380
19698
|
CRITICAL: "critical"
|
|
19381
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
|
|
19382
19744
|
function checkOutputSanity(text) {
|
|
19383
19745
|
if (!text || text.length < 50) {
|
|
19384
19746
|
return { isHealthy: true, severity: SEVERITY.OK };
|
|
@@ -19445,42 +19807,6 @@ function checkOutputSanity(text) {
|
|
|
19445
19807
|
}
|
|
19446
19808
|
return { isHealthy: true, severity: SEVERITY.OK };
|
|
19447
19809
|
}
|
|
19448
|
-
var RECOVERY_PROMPT = `<anomaly_recovery>
|
|
19449
|
-
\u26A0\uFE0F SYSTEM NOTICE: Previous output was malformed (gibberish/loop detected).
|
|
19450
|
-
|
|
19451
|
-
<recovery_protocol>
|
|
19452
|
-
1. DISCARD the corrupted output completely - do not reference it
|
|
19453
|
-
2. RECALL the original mission objective
|
|
19454
|
-
3. IDENTIFY the last confirmed successful step
|
|
19455
|
-
4. RESTART with a simpler, more focused approach
|
|
19456
|
-
</recovery_protocol>
|
|
19457
|
-
|
|
19458
|
-
<instructions>
|
|
19459
|
-
- If a sub-agent produced bad output: try a different agent or simpler task
|
|
19460
|
-
- If stuck in a loop: break down the task into smaller pieces
|
|
19461
|
-
- If context seems corrupted: call Reviewer to restore context
|
|
19462
|
-
- THINK in English for maximum stability
|
|
19463
|
-
</instructions>
|
|
19464
|
-
|
|
19465
|
-
What was the original task? Proceed from the last known good state.
|
|
19466
|
-
</anomaly_recovery>`;
|
|
19467
|
-
var ESCALATION_PROMPT = `<critical_anomaly>
|
|
19468
|
-
\u{1F6A8} CRITICAL: Multiple consecutive malformed outputs detected.
|
|
19469
|
-
|
|
19470
|
-
<emergency_protocol>
|
|
19471
|
-
1. STOP current execution path immediately
|
|
19472
|
-
2. DO NOT continue with the same approach - it is failing
|
|
19473
|
-
3. CALL Planner for a completely new strategy
|
|
19474
|
-
4. If Planner also fails: report status to user and await guidance
|
|
19475
|
-
</emergency_protocol>
|
|
19476
|
-
|
|
19477
|
-
<diagnosis>
|
|
19478
|
-
The current approach is producing corrupted output.
|
|
19479
|
-
This may indicate: context overload, model instability, or task complexity.
|
|
19480
|
-
</diagnosis>
|
|
19481
|
-
|
|
19482
|
-
Request a fresh plan from Planner with reduced scope.
|
|
19483
|
-
</critical_anomaly>`;
|
|
19484
19810
|
|
|
19485
19811
|
// src/plugin-handlers/tool-execute-handler.ts
|
|
19486
19812
|
function createToolExecuteAfterHandler(ctx) {
|
|
@@ -19522,7 +19848,7 @@ Anomaly count: ${stateSession.anomalyCount}
|
|
|
19522
19848
|
stateSession.currentTask = taskIdMatch[1].toUpperCase();
|
|
19523
19849
|
}
|
|
19524
19850
|
const agentName = toolInput.arguments.agent;
|
|
19525
|
-
const indicator =
|
|
19851
|
+
const indicator = agentName[0].toUpperCase();
|
|
19526
19852
|
toolOutput.output = `[${indicator}] [${agentName.toUpperCase()}] Working...
|
|
19527
19853
|
|
|
19528
19854
|
` + toolOutput.output;
|
|
@@ -19631,7 +19957,7 @@ function createAssistantDoneHandler(ctx) {
|
|
|
19631
19957
|
session.active = false;
|
|
19632
19958
|
state.missionActive = false;
|
|
19633
19959
|
clearLoopState(directory);
|
|
19634
|
-
presets.missionComplete("
|
|
19960
|
+
presets.missionComplete("Mission Sealed - Explicit completion confirmed");
|
|
19635
19961
|
log2("[assistant-done-handler] Mission sealed detected", { sessionID });
|
|
19636
19962
|
clearSession(sessionID);
|
|
19637
19963
|
sessions.delete(sessionID);
|
|
@@ -19667,7 +19993,7 @@ function createAssistantDoneHandler(ctx) {
|
|
|
19667
19993
|
type: PART_TYPES.TEXT,
|
|
19668
19994
|
text: CONTINUE_INSTRUCTION + `
|
|
19669
19995
|
|
|
19670
|
-
|
|
19996
|
+
[${currentTime}] Step ${session.step} | ${progressInfo} | This step: ${stepDuration} | Total: ${totalElapsed}`
|
|
19671
19997
|
}]
|
|
19672
19998
|
}
|
|
19673
19999
|
});
|
|
@@ -19752,6 +20078,11 @@ var OrchestratorPlugin = async (input) => {
|
|
|
19752
20078
|
[TOOL_NAMES.WEBSEARCH]: websearchTool,
|
|
19753
20079
|
[TOOL_NAMES.CACHE_DOCS]: cacheDocsTool,
|
|
19754
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),
|
|
19755
20086
|
// Async agent tools
|
|
19756
20087
|
...asyncAgentTools
|
|
19757
20088
|
},
|