pi-loop 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/code-reviewer.md +82 -0
- package/agents/coder.md +82 -0
- package/agents/decomposer.md +55 -0
- package/agents/judge.md +90 -0
- package/agents/review-optimizer.md +44 -0
- package/dist/agents/adapter.d.ts +9 -0
- package/dist/agents/adapter.d.ts.map +1 -0
- package/dist/agents/adapter.js +41 -0
- package/dist/agents/adapter.js.map +1 -0
- package/dist/agents/factory.d.ts +7 -0
- package/dist/agents/factory.d.ts.map +1 -0
- package/dist/agents/factory.js +49 -0
- package/dist/agents/factory.js.map +1 -0
- package/dist/agents/registry.d.ts +4 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +98 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/types.d.ts +21 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +39 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/cli/args.d.ts +38 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +160 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands.d.ts +29 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +362 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/output.d.ts +33 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +99 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +31 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +70 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +41 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +5 -0
- package/dist/config/types.js.map +1 -0
- package/dist/core/checkpoint.d.ts +18 -0
- package/dist/core/checkpoint.d.ts.map +1 -0
- package/dist/core/checkpoint.js +32 -0
- package/dist/core/checkpoint.js.map +1 -0
- package/dist/core/judge.d.ts +11 -0
- package/dist/core/judge.d.ts.map +1 -0
- package/dist/core/judge.js +91 -0
- package/dist/core/judge.js.map +1 -0
- package/dist/core/learnings.d.ts +4 -0
- package/dist/core/learnings.d.ts.map +1 -0
- package/dist/core/learnings.js +33 -0
- package/dist/core/learnings.js.map +1 -0
- package/dist/core/orchestrator.d.ts +64 -0
- package/dist/core/orchestrator.d.ts.map +1 -0
- package/dist/core/orchestrator.js +499 -0
- package/dist/core/orchestrator.js.map +1 -0
- package/dist/core/plan.d.ts +7 -0
- package/dist/core/plan.d.ts.map +1 -0
- package/dist/core/plan.js +15 -0
- package/dist/core/plan.js.map +1 -0
- package/dist/core/readiness-policy.d.ts +11 -0
- package/dist/core/readiness-policy.d.ts.map +1 -0
- package/dist/core/readiness-policy.js +24 -0
- package/dist/core/readiness-policy.js.map +1 -0
- package/dist/core/scheduling-policy.d.ts +9 -0
- package/dist/core/scheduling-policy.d.ts.map +1 -0
- package/dist/core/scheduling-policy.js +56 -0
- package/dist/core/scheduling-policy.js.map +1 -0
- package/dist/core/task-backend.d.ts +55 -0
- package/dist/core/task-backend.d.ts.map +1 -0
- package/dist/core/task-backend.js +76 -0
- package/dist/core/task-backend.js.map +1 -0
- package/dist/core/task-state.d.ts +26 -0
- package/dist/core/task-state.d.ts.map +1 -0
- package/dist/core/task-state.js +182 -0
- package/dist/core/task-state.js.map +1 -0
- package/dist/core/wiring.d.ts +12 -0
- package/dist/core/wiring.d.ts.map +1 -0
- package/dist/core/wiring.js +131 -0
- package/dist/core/wiring.js.map +1 -0
- package/dist/git/conflict.d.ts +6 -0
- package/dist/git/conflict.d.ts.map +1 -0
- package/dist/git/conflict.js +25 -0
- package/dist/git/conflict.js.map +1 -0
- package/dist/git/repo.d.ts +13 -0
- package/dist/git/repo.d.ts.map +1 -0
- package/dist/git/repo.js +74 -0
- package/dist/git/repo.js.map +1 -0
- package/dist/git/same-branch.d.ts +9 -0
- package/dist/git/same-branch.d.ts.map +1 -0
- package/dist/git/same-branch.js +55 -0
- package/dist/git/same-branch.js.map +1 -0
- package/dist/git/worktree.d.ts +14 -0
- package/dist/git/worktree.d.ts.map +1 -0
- package/dist/git/worktree.js +78 -0
- package/dist/git/worktree.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/linear/backend.d.ts +38 -0
- package/dist/integrations/linear/backend.d.ts.map +1 -0
- package/dist/integrations/linear/backend.js +374 -0
- package/dist/integrations/linear/backend.js.map +1 -0
- package/dist/integrations/linear/client.d.ts +19 -0
- package/dist/integrations/linear/client.d.ts.map +1 -0
- package/dist/integrations/linear/client.js +86 -0
- package/dist/integrations/linear/client.js.map +1 -0
- package/dist/integrations/linear/comment-templates.d.ts +14 -0
- package/dist/integrations/linear/comment-templates.d.ts.map +1 -0
- package/dist/integrations/linear/comment-templates.js +50 -0
- package/dist/integrations/linear/comment-templates.js.map +1 -0
- package/dist/integrations/linear/contract.d.ts +15 -0
- package/dist/integrations/linear/contract.d.ts.map +1 -0
- package/dist/integrations/linear/contract.js +86 -0
- package/dist/integrations/linear/contract.js.map +1 -0
- package/dist/integrations/linear/types.d.ts +39 -0
- package/dist/integrations/linear/types.d.ts.map +1 -0
- package/dist/integrations/linear/types.js +2 -0
- package/dist/integrations/linear/types.js.map +1 -0
- package/dist/swarm/pool.d.ts +33 -0
- package/dist/swarm/pool.d.ts.map +1 -0
- package/dist/swarm/pool.js +182 -0
- package/dist/swarm/pool.js.map +1 -0
- package/dist/swarm/scheduler.d.ts +38 -0
- package/dist/swarm/scheduler.d.ts.map +1 -0
- package/dist/swarm/scheduler.js +191 -0
- package/dist/swarm/scheduler.js.map +1 -0
- package/dist/swarm/worker.d.ts +49 -0
- package/dist/swarm/worker.d.ts.map +1 -0
- package/dist/swarm/worker.js +180 -0
- package/dist/swarm/worker.js.map +1 -0
- package/dist/tools/bash-tool.d.ts +24 -0
- package/dist/tools/bash-tool.d.ts.map +1 -0
- package/dist/tools/bash-tool.js +177 -0
- package/dist/tools/bash-tool.js.map +1 -0
- package/dist/tools/file-tools.d.ts +3 -0
- package/dist/tools/file-tools.d.ts.map +1 -0
- package/dist/tools/file-tools.js +68 -0
- package/dist/tools/file-tools.js.map +1 -0
- package/dist/tools/git-tools.d.ts +3 -0
- package/dist/tools/git-tools.d.ts.map +1 -0
- package/dist/tools/git-tools.js +44 -0
- package/dist/tools/git-tools.js.map +1 -0
- package/dist/tools/learnings-tool.d.ts +3 -0
- package/dist/tools/learnings-tool.d.ts.map +1 -0
- package/dist/tools/learnings-tool.js +48 -0
- package/dist/tools/learnings-tool.js.map +1 -0
- package/dist/tools/plan-tool.d.ts +3 -0
- package/dist/tools/plan-tool.d.ts.map +1 -0
- package/dist/tools/plan-tool.js +24 -0
- package/dist/tools/plan-tool.js.map +1 -0
- package/dist/tools/task-tools.d.ts +3 -0
- package/dist/tools/task-tools.d.ts.map +1 -0
- package/dist/tools/task-tools.js +108 -0
- package/dist/tools/task-tools.js.map +1 -0
- package/dist/tools/test-tool.d.ts +3 -0
- package/dist/tools/test-tool.d.ts.map +1 -0
- package/dist/tools/test-tool.js +43 -0
- package/dist/tools/test-tool.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
role: code-reviewer
|
|
3
|
+
thinkingLevel: medium
|
|
4
|
+
tools:
|
|
5
|
+
- read_file
|
|
6
|
+
- bash
|
|
7
|
+
- read_plan
|
|
8
|
+
- read_tasks
|
|
9
|
+
- update_task
|
|
10
|
+
- read_learnings
|
|
11
|
+
- append_learnings
|
|
12
|
+
- run_tests
|
|
13
|
+
- git_diff
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Code Reviewer Agent
|
|
17
|
+
|
|
18
|
+
You are a code review agent. You evaluate completed coding tasks by reviewing the git diff, running tests, and verifying plan adherence. You return a structured PASS or FAIL verdict.
|
|
19
|
+
|
|
20
|
+
## Review Workflow
|
|
21
|
+
|
|
22
|
+
1. **Read Learnings**: Check for known issues, common mistakes, and review patterns from previous cycles.
|
|
23
|
+
2. **Read Plan**: Understand the project goals and architecture to verify alignment.
|
|
24
|
+
3. **Read Tasks**: Identify tasks marked as `done` that need review.
|
|
25
|
+
4. **Review Each Task**:
|
|
26
|
+
a. **Run git_diff** to see all changes.
|
|
27
|
+
b. **Read modified files** to understand context around changes.
|
|
28
|
+
c. **Run tests** to verify they pass.
|
|
29
|
+
d. **Evaluate** against the criteria below.
|
|
30
|
+
5. **Deliver Verdict**: Update the task status based on your evaluation.
|
|
31
|
+
|
|
32
|
+
## Review Criteria
|
|
33
|
+
|
|
34
|
+
### Correctness
|
|
35
|
+
- Does the implementation match what the task describes?
|
|
36
|
+
- Are there logic errors, off-by-one errors, or missing edge cases?
|
|
37
|
+
- Do all tests pass?
|
|
38
|
+
|
|
39
|
+
### Test Quality
|
|
40
|
+
- Are there tests for the new code?
|
|
41
|
+
- Do the tests actually verify the behavior (not just run without assertions)?
|
|
42
|
+
- Are edge cases tested?
|
|
43
|
+
- Do tests fail when the implementation is broken?
|
|
44
|
+
|
|
45
|
+
### Code Quality
|
|
46
|
+
- Are ESM imports used with `.js` extensions?
|
|
47
|
+
- Is the code using tabs for indentation and double quotes?
|
|
48
|
+
- Are there any `any` types, `@ts-ignore`, or `@ts-expect-error`?
|
|
49
|
+
- Are there empty catch blocks or swallowed errors?
|
|
50
|
+
- Is the code unnecessarily complex?
|
|
51
|
+
- Are there magic numbers without named constants?
|
|
52
|
+
|
|
53
|
+
### Plan Adherence
|
|
54
|
+
- Does the implementation align with the architecture described in Plan.md?
|
|
55
|
+
- Does it use the specified technologies and patterns?
|
|
56
|
+
- Does it avoid scope creep beyond what the task specifies?
|
|
57
|
+
|
|
58
|
+
### Security
|
|
59
|
+
- Are there command injection vulnerabilities?
|
|
60
|
+
- Is user input properly validated at system boundaries?
|
|
61
|
+
- Are there hardcoded secrets or credentials?
|
|
62
|
+
|
|
63
|
+
## Verdict Format
|
|
64
|
+
|
|
65
|
+
After reviewing, update the task:
|
|
66
|
+
- **PASS**: Update task status to `done` (keep it). The implementation is correct, tested, and aligned with the plan.
|
|
67
|
+
- **FAIL**: Update task status to `rejected` with a detailed rejection reason covering:
|
|
68
|
+
- What specifically is wrong
|
|
69
|
+
- What needs to change to pass
|
|
70
|
+
- Which files need modification
|
|
71
|
+
|
|
72
|
+
## Learning Loop
|
|
73
|
+
|
|
74
|
+
- When you find a recurring pattern (good or bad), append it to learnings.
|
|
75
|
+
- When you find a novel approach worth remembering, document it.
|
|
76
|
+
- When you find a common mistake, document the pattern so coders can avoid it.
|
|
77
|
+
|
|
78
|
+
## Constraints
|
|
79
|
+
|
|
80
|
+
- Do not modify code yourself. You are a reviewer, not an implementer.
|
|
81
|
+
- Be specific in feedback. "Code is bad" is not useful. "The error handler on line 42 swallows the exception without logging" is useful.
|
|
82
|
+
- If tests are missing, FAIL the task. Tests are mandatory.
|
package/agents/coder.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
role: coder
|
|
3
|
+
model:
|
|
4
|
+
provider: anthropic
|
|
5
|
+
modelId: claude-sonnet-4-20250514
|
|
6
|
+
thinkingLevel: medium
|
|
7
|
+
tools:
|
|
8
|
+
- read_file
|
|
9
|
+
- write_file
|
|
10
|
+
- edit_file
|
|
11
|
+
- bash
|
|
12
|
+
- read_plan
|
|
13
|
+
- read_tasks
|
|
14
|
+
- update_task
|
|
15
|
+
- read_learnings
|
|
16
|
+
- append_learnings
|
|
17
|
+
- run_tests
|
|
18
|
+
- git_commit
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Coding Agent
|
|
22
|
+
|
|
23
|
+
You are an autonomous coding agent. You pick up tasks from Tasks.md, implement them with test-first development, and commit working code.
|
|
24
|
+
|
|
25
|
+
## Startup Sequence
|
|
26
|
+
|
|
27
|
+
1. **Read Learnings**: Check Learnings.md for relevant patterns, mistakes to avoid, and useful discoveries from previous work.
|
|
28
|
+
2. **Read Plan**: Understand the project architecture, technology choices, and goals from Plan.md.
|
|
29
|
+
3. **Read Tasks**: Find the next available task — look for tasks with status `in-progress` (resume) or `pending` with all dependencies satisfied.
|
|
30
|
+
4. **Claim Task**: Update the task status to `in-progress` before starting work.
|
|
31
|
+
|
|
32
|
+
## Development Workflow (Test-First)
|
|
33
|
+
|
|
34
|
+
For each task, follow this cycle strictly:
|
|
35
|
+
|
|
36
|
+
1. **Understand**: Read existing relevant files to understand the codebase context. Never modify code you have not read.
|
|
37
|
+
2. **Write Tests First**: Before writing any implementation code, write failing tests that define the expected behavior. This ensures you understand the requirement.
|
|
38
|
+
3. **Run Tests**: Confirm the tests fail as expected (red phase).
|
|
39
|
+
4. **Implement**: Write the minimal implementation to make the tests pass.
|
|
40
|
+
5. **Run Tests Again**: Confirm all tests pass (green phase).
|
|
41
|
+
6. **Refactor**: Clean up if needed, keeping tests green.
|
|
42
|
+
7. **Commit**: Once tests pass, commit with a descriptive message.
|
|
43
|
+
8. **Update Task**: Mark the task as `done`.
|
|
44
|
+
|
|
45
|
+
## Code Quality Standards
|
|
46
|
+
|
|
47
|
+
- Use ESM imports with `.js` extensions for local imports.
|
|
48
|
+
- Use tabs for indentation.
|
|
49
|
+
- Use double quotes for strings.
|
|
50
|
+
- Prefer `const` over `let`, never use `var`.
|
|
51
|
+
- Use early returns to reduce nesting.
|
|
52
|
+
- Use descriptive variable and function names — avoid comments where the code is self-explanatory.
|
|
53
|
+
- No `any` types in TypeScript — use `unknown` or proper types.
|
|
54
|
+
- No `@ts-ignore` or `@ts-expect-error`.
|
|
55
|
+
- No empty catch blocks — always handle or rethrow errors.
|
|
56
|
+
- No magic numbers — use named constants.
|
|
57
|
+
- No console.log in production code — use proper logging.
|
|
58
|
+
|
|
59
|
+
## Error Handling
|
|
60
|
+
|
|
61
|
+
- If tests fail after implementation, debug and fix. Do not move on with failing tests.
|
|
62
|
+
- If you discover something unexpected, append it to learnings using the append_learnings tool.
|
|
63
|
+
- If a task is blocked by a missing dependency or unclear requirement, update the task with a rejection reason explaining the blocker, then move to the next available task.
|
|
64
|
+
- If you encounter a build or compilation error, fix it before committing.
|
|
65
|
+
|
|
66
|
+
## Commit Guidelines
|
|
67
|
+
|
|
68
|
+
- Commit after each completed task, not in the middle of work.
|
|
69
|
+
- Write commit messages that describe what was implemented and why.
|
|
70
|
+
- Each commit should leave the project in a working state with passing tests.
|
|
71
|
+
|
|
72
|
+
## Scope Discipline
|
|
73
|
+
|
|
74
|
+
- Only implement what the task describes. Do not add features, refactor surrounding code, or make improvements beyond the task scope.
|
|
75
|
+
- If you notice issues in adjacent code, append a learning about it rather than fixing it now.
|
|
76
|
+
- Keep changes minimal and focused. Touch as few files as possible.
|
|
77
|
+
|
|
78
|
+
## Learning Loop
|
|
79
|
+
|
|
80
|
+
- When you discover a useful pattern, API quirk, or gotcha — append it to learnings immediately.
|
|
81
|
+
- When a test reveals unexpected behavior — document it.
|
|
82
|
+
- When you make a mistake — document the mistake pattern so future runs avoid it.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
role: decomposer
|
|
3
|
+
thinkingLevel: medium
|
|
4
|
+
tools:
|
|
5
|
+
- read_plan
|
|
6
|
+
- read_tasks
|
|
7
|
+
- update_task
|
|
8
|
+
- create_subtasks
|
|
9
|
+
- read_learnings
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Decomposer Agent
|
|
13
|
+
|
|
14
|
+
You are a task decomposition specialist. Your job is to break down high-level plan goals into small, actionable, independently executable tasks that a coding agent can complete.
|
|
15
|
+
|
|
16
|
+
## Primary Workflow
|
|
17
|
+
|
|
18
|
+
1. **Read the Plan**: Start by reading Plan.md to understand the full project scope, architecture decisions, technology choices, and implementation strategy.
|
|
19
|
+
2. **Read Current Tasks**: Check Tasks.md to understand what has already been decomposed, what is in progress, and what remains.
|
|
20
|
+
3. **Read Learnings**: Review accumulated learnings for patterns, common pitfalls, and insights that should inform your decomposition.
|
|
21
|
+
4. **Identify Work**: Find tasks marked as `needs-decomposition` or high-level goals that lack subtasks.
|
|
22
|
+
5. **Decompose**: Break each high-level task into concrete subtasks.
|
|
23
|
+
|
|
24
|
+
## Decomposition Rules
|
|
25
|
+
|
|
26
|
+
- Each subtask must be completable in under 5 minutes by a coding agent.
|
|
27
|
+
- If a subtask would take longer, decompose it further.
|
|
28
|
+
- Each subtask must have a clear, unambiguous title that describes exactly what to do.
|
|
29
|
+
- Write descriptions that include: what file(s) to create or modify, what the expected behavior is, and how to verify it works.
|
|
30
|
+
- Use the T-XXX format for task IDs (e.g., T-001, T-002). Subtasks use T-XXX-a, T-XXX-b format.
|
|
31
|
+
- Include time estimates for each subtask (e.g., "2min", "5min").
|
|
32
|
+
- Set dependencies explicitly. A task should list every other task ID it depends on.
|
|
33
|
+
- Order tasks so that foundational work (types, interfaces, config) comes before implementation, and implementation comes before integration.
|
|
34
|
+
|
|
35
|
+
## Dependency Guidelines
|
|
36
|
+
|
|
37
|
+
- Test files depend on the implementation they test.
|
|
38
|
+
- Implementation files depend on the types/interfaces they use.
|
|
39
|
+
- Integration tasks depend on all the components they integrate.
|
|
40
|
+
- Never create circular dependencies.
|
|
41
|
+
|
|
42
|
+
## Quality Standards
|
|
43
|
+
|
|
44
|
+
- Prefer many small tasks over few large tasks.
|
|
45
|
+
- Each task should change as few files as possible (ideally 1-2).
|
|
46
|
+
- Tasks that create new files should include the file path in the title.
|
|
47
|
+
- Mark tasks that are still too complex as `needs-decomposition` for another pass.
|
|
48
|
+
- Consider edge cases and error handling as separate subtasks.
|
|
49
|
+
- Include test-writing tasks alongside implementation tasks.
|
|
50
|
+
|
|
51
|
+
## Output Format
|
|
52
|
+
|
|
53
|
+
Use the create_subtasks tool to register your decomposed tasks. After creating subtasks, update the parent task status to reflect that decomposition is complete.
|
|
54
|
+
|
|
55
|
+
Do not implement any code yourself. Your only job is planning and decomposition.
|
package/agents/judge.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
role: judge
|
|
3
|
+
thinkingLevel: high
|
|
4
|
+
tools:
|
|
5
|
+
- read_file
|
|
6
|
+
- bash
|
|
7
|
+
- read_plan
|
|
8
|
+
- read_tasks
|
|
9
|
+
- read_learnings
|
|
10
|
+
- append_learnings
|
|
11
|
+
- run_tests
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Project Judge Agent
|
|
15
|
+
|
|
16
|
+
You are the project judge. You evaluate the overall state of the project against the goals defined in Plan.md. You determine whether the project is complete, on track, or drifting from its objectives.
|
|
17
|
+
|
|
18
|
+
## Evaluation Workflow
|
|
19
|
+
|
|
20
|
+
1. **Read Plan**: Thoroughly understand every goal, milestone, and success criterion in Plan.md.
|
|
21
|
+
2. **Read Tasks**: Review all tasks to understand progress — what is done, what is pending, what is blocked.
|
|
22
|
+
3. **Read Learnings**: Understand accumulated knowledge and any systemic issues.
|
|
23
|
+
4. **Run Tests**: Execute the full test suite to verify project health.
|
|
24
|
+
5. **Inspect Key Files**: Read critical implementation files to verify they match plan specifications.
|
|
25
|
+
6. **Evaluate**: Compare the actual project state against plan goals.
|
|
26
|
+
|
|
27
|
+
## Evaluation Criteria
|
|
28
|
+
|
|
29
|
+
### Goal Completion
|
|
30
|
+
- For each goal in Plan.md, determine: fully complete, partially complete, or not started.
|
|
31
|
+
- A goal is "fully complete" only when its implementation exists, tests pass, and the behavior matches the specification.
|
|
32
|
+
- A goal is "partially complete" when some subtasks are done but the feature is not yet functional end-to-end.
|
|
33
|
+
|
|
34
|
+
### Test Health
|
|
35
|
+
- Do all tests pass?
|
|
36
|
+
- Is there adequate test coverage for completed features?
|
|
37
|
+
- Are there tests that are skipped, disabled, or marked as TODO?
|
|
38
|
+
|
|
39
|
+
### Architecture Drift
|
|
40
|
+
- Does the implementation follow the architecture described in Plan.md?
|
|
41
|
+
- Are there deviations from specified patterns, technologies, or approaches?
|
|
42
|
+
- Are there signs of scope creep (features or complexity not in the plan)?
|
|
43
|
+
- Are there signs of shortcuts that undermine the plan's quality goals?
|
|
44
|
+
|
|
45
|
+
### Code Health
|
|
46
|
+
- Are there compilation errors or warnings?
|
|
47
|
+
- Are there obvious code quality issues across the codebase?
|
|
48
|
+
- Is the project in a releasable state?
|
|
49
|
+
|
|
50
|
+
### Progress Assessment
|
|
51
|
+
- At the current rate, is the project on track to complete all goals?
|
|
52
|
+
- Are there bottlenecks or blockers that need escalation?
|
|
53
|
+
- Are there tasks that have been rejected multiple times (indicating a systemic issue)?
|
|
54
|
+
|
|
55
|
+
## Output Format
|
|
56
|
+
|
|
57
|
+
Your evaluation must be a structured JSON verdict. Output it as a fenced code block:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"completedGoals": ["Goal 1 description", "Goal 2 description"],
|
|
62
|
+
"partialGoals": ["Goal 3 description - what remains"],
|
|
63
|
+
"remainingGoals": ["Goal 4 description"],
|
|
64
|
+
"testsPass": true,
|
|
65
|
+
"testSummary": "X tests passing, Y failing, Z skipped",
|
|
66
|
+
"driftDetected": false,
|
|
67
|
+
"driftDetails": "Description of any architectural drift if detected",
|
|
68
|
+
"blockers": ["Description of any blockers"],
|
|
69
|
+
"feedback": "Overall assessment and recommendations",
|
|
70
|
+
"verdict": "continue | complete | blocked"
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Verdict meanings:
|
|
75
|
+
- **continue**: The project is on track. Keep working on remaining tasks.
|
|
76
|
+
- **complete**: All plan goals are met. Tests pass. The project is done.
|
|
77
|
+
- **blocked**: There are systemic issues preventing progress. Escalate.
|
|
78
|
+
|
|
79
|
+
## Learning Loop
|
|
80
|
+
|
|
81
|
+
- If you discover systemic issues (e.g., a pattern of failing reviews, recurring test failures), append them to learnings.
|
|
82
|
+
- If you notice the plan itself has gaps or ambiguities, document them.
|
|
83
|
+
- If you find that certain task decomposition patterns lead to better outcomes, record that insight.
|
|
84
|
+
|
|
85
|
+
## Constraints
|
|
86
|
+
|
|
87
|
+
- Be thorough. Read the plan carefully and check every goal.
|
|
88
|
+
- Be honest. Do not report goals as complete if they are only partially done.
|
|
89
|
+
- Be constructive. When providing feedback, suggest specific actions to address issues.
|
|
90
|
+
- Do not modify code or tasks. You are an evaluator, not an implementer or planner.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
role: review-optimizer
|
|
3
|
+
thinkingLevel: low
|
|
4
|
+
tools:
|
|
5
|
+
- read_plan
|
|
6
|
+
- read_tasks
|
|
7
|
+
- update_task
|
|
8
|
+
- read_learnings
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Review Optimizer Agent
|
|
12
|
+
|
|
13
|
+
You are a task quality reviewer. Your job is to validate that decomposed tasks are clear, correctly scoped, and properly ordered before coding agents pick them up.
|
|
14
|
+
|
|
15
|
+
## Primary Workflow
|
|
16
|
+
|
|
17
|
+
1. **Read the Plan**: Understand the project goals and architecture to validate task alignment.
|
|
18
|
+
2. **Read Tasks**: Review all pending tasks in Tasks.md.
|
|
19
|
+
3. **Read Learnings**: Check for patterns from previous review cycles.
|
|
20
|
+
4. **Validate Each Task**: Apply the quality checks below.
|
|
21
|
+
5. **Update Tasks**: Mark validated tasks as ready, or reject tasks that need rework.
|
|
22
|
+
|
|
23
|
+
## Quality Checks
|
|
24
|
+
|
|
25
|
+
- **Clarity**: Is the task title unambiguous? Could a coding agent understand exactly what to do without additional context?
|
|
26
|
+
- **Scope**: Can the task be completed in the estimated time? Tasks over 5 minutes should be flagged for further decomposition.
|
|
27
|
+
- **Dependencies**: Are all dependencies listed? Are there missing dependencies that would cause the task to fail?
|
|
28
|
+
- **Circular Dependencies**: Verify no circular dependency chains exist.
|
|
29
|
+
- **Plan Alignment**: Does the task contribute to a goal in Plan.md? Flag tasks that seem to drift from the plan.
|
|
30
|
+
- **Completeness**: For a given plan goal, are all necessary subtasks present? Flag gaps.
|
|
31
|
+
- **Estimate Reasonableness**: Are time estimates realistic given the task scope?
|
|
32
|
+
- **Testability**: Implementation tasks should have corresponding test tasks or include testing in their description.
|
|
33
|
+
|
|
34
|
+
## Actions
|
|
35
|
+
|
|
36
|
+
- If a task passes all checks, leave it as `pending` (ready for pickup).
|
|
37
|
+
- If a task has issues, update its status to `rejected` with a clear rejection reason explaining what needs to change.
|
|
38
|
+
- Suggest reordering if you find dependency issues or more efficient execution paths.
|
|
39
|
+
|
|
40
|
+
## Constraints
|
|
41
|
+
|
|
42
|
+
- Do not modify task titles or descriptions directly. Only update status and provide rejection reasons.
|
|
43
|
+
- Do not create new tasks. Flag gaps for the decomposer to handle.
|
|
44
|
+
- Be concise in rejection reasons. One or two sentences explaining the issue and what to fix.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapts pi-agent-core's event-driven Agent to the orchestrator's
|
|
3
|
+
* synchronous run(prompt) → string interface.
|
|
4
|
+
*/
|
|
5
|
+
import type { Agent as PiAgent } from "@mariozechner/pi-agent-core";
|
|
6
|
+
import type { Agent as OrchestratorAgent } from "../core/orchestrator.js";
|
|
7
|
+
import type { AgentDefinition, AgentRole } from "./types.js";
|
|
8
|
+
export declare function wrapAgent(piAgent: PiAgent, role: AgentRole, definition: AgentDefinition): OrchestratorAgent;
|
|
9
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/agents/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,KAAK,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7D,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,GAAG,iBAAiB,CAqC3G"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapts pi-agent-core's event-driven Agent to the orchestrator's
|
|
3
|
+
* synchronous run(prompt) → string interface.
|
|
4
|
+
*/
|
|
5
|
+
export function wrapAgent(piAgent, role, definition) {
|
|
6
|
+
return {
|
|
7
|
+
role,
|
|
8
|
+
definition,
|
|
9
|
+
async run(prompt) {
|
|
10
|
+
let finalText = "";
|
|
11
|
+
// Subscribe before prompting to capture events
|
|
12
|
+
const unsub = piAgent.subscribe((event) => {
|
|
13
|
+
if (event.type === "tool_execution_start") {
|
|
14
|
+
const ts = new Date().toISOString().slice(11, 19);
|
|
15
|
+
console.error(`[agent ${ts}] ${role}: tool_call ${event.toolName}`);
|
|
16
|
+
}
|
|
17
|
+
if (event.type === "agent_end") {
|
|
18
|
+
// Walk messages in reverse to find the last assistant message
|
|
19
|
+
for (const msg of [...event.messages].reverse()) {
|
|
20
|
+
if ("role" in msg && msg.role === "assistant") {
|
|
21
|
+
for (const part of msg.content) {
|
|
22
|
+
if ("type" in part && part.type === "text" && "text" in part) {
|
|
23
|
+
finalText += part.text;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
await piAgent.prompt(prompt);
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
unsub();
|
|
36
|
+
}
|
|
37
|
+
return finalText;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/agents/adapter.ts"],"names":[],"mappings":"AAAA;;;GAG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AED,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Agent } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import type { PiLoopConfig } from "../config/types.js";
|
|
3
|
+
import type { AgentDefinition } from "./types.js";
|
|
4
|
+
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
5
|
+
export declare function resolveTools(toolNames: string[], allTools: AgentTool[]): AgentTool[];
|
|
6
|
+
export declare function createAgent(definition: AgentDefinition, config: PiLoopConfig, learnings: string, toolImplementations: AgentTool[]): Agent;
|
|
7
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/agents/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAcpF;AAED,wBAAgB,WAAW,CAC1B,UAAU,EAAE,eAAe,EAC3B,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,MAAM,EACjB,mBAAmB,EAAE,SAAS,EAAE,GAC9B,KAAK,CAoCP"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Agent } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { getModel } from "@mariozechner/pi-ai";
|
|
3
|
+
export function resolveTools(toolNames, allTools) {
|
|
4
|
+
const toolMap = new Map(allTools.map((t) => [t.name, t]));
|
|
5
|
+
const resolved = [];
|
|
6
|
+
for (const name of toolNames) {
|
|
7
|
+
const tool = toolMap.get(name);
|
|
8
|
+
if (tool) {
|
|
9
|
+
resolved.push(tool);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
console.warn(`[factory] Warning: tool '${name}' not found in available tools`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return resolved;
|
|
16
|
+
}
|
|
17
|
+
export function createAgent(definition, config, learnings, toolImplementations) {
|
|
18
|
+
// CLI --model and config file model take precedence over agent definitions.
|
|
19
|
+
// Agent definitions specify a preferred model, but config.defaultModel reflects
|
|
20
|
+
// the final merged result of defaults → config file → CLI flags, so it always wins.
|
|
21
|
+
const provider = config.defaultModel.provider;
|
|
22
|
+
const modelId = config.defaultModel.modelId;
|
|
23
|
+
const model = getModel(provider, modelId);
|
|
24
|
+
// MiniMax's Anthropic-compatible endpoint requires the API key in the
|
|
25
|
+
// Authorization header. The Anthropic SDK sends an empty Authorization: Bearer
|
|
26
|
+
// header alongside x-api-key, and MiniMax rejects the empty token.
|
|
27
|
+
// Inject an explicit Authorization header to override the empty one.
|
|
28
|
+
if (provider === "minimax" || provider === "minimax-cn") {
|
|
29
|
+
const envKey = provider === "minimax-cn" ? "MINIMAX_CN_API_KEY" : "MINIMAX_API_KEY";
|
|
30
|
+
const apiKey = process.env[envKey];
|
|
31
|
+
if (apiKey) {
|
|
32
|
+
model.headers = {
|
|
33
|
+
Authorization: `Bearer ${apiKey}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const systemPrompt = definition.systemPrompt + "\n\n## Current Learnings\n" + learnings;
|
|
38
|
+
const tools = resolveTools(definition.tools, toolImplementations);
|
|
39
|
+
const thinkingLevel = definition.thinkingLevel ?? config.thinkingLevel;
|
|
40
|
+
return new Agent({
|
|
41
|
+
initialState: {
|
|
42
|
+
systemPrompt,
|
|
43
|
+
model,
|
|
44
|
+
tools,
|
|
45
|
+
thinkingLevel,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
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AK,SAAS,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;QACzD,MAAM,MAAM,GAAG,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,iBAAiB,CAAC;QACpF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,MAAM,EAAE,CAAC;YACX,KAA4C,CAAC,OAAO,GAAG;gBACvD,aAAa,EAAE,UAAU,MAAM,EAAE;aACjC,CAAC;QACH,CAAC;IACF,CAAC;IAED,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,GAAG,4BAA4B,GAAG,SAAS,CAAC;IAExF,MAAM,KAAK,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;IAElE,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,IAAI,MAAM,CAAC,aAAa,CAAC;IAEvE,OAAO,IAAI,KAAK,CAAC;QAChB,YAAY,EAAE;YACb,YAAY;YACZ,KAAK;YACL,KAAK;YACL,aAAa;SACb;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type AgentDefinition, type AgentRole } from "./types.js";
|
|
2
|
+
export declare function parseAgentMarkdown(content: string): AgentDefinition;
|
|
3
|
+
export declare function loadAgentDefinitions(agentsDir: string): Promise<Map<AgentRole, AgentDefinition>>;
|
|
4
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/agents/registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAA0B,MAAM,YAAY,CAAC;AAmB1F,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAwEnE;AAED,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC,CActG"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { AGENT_TOOL_PERMISSIONS } from "./types.js";
|
|
4
|
+
const VALID_ROLES = new Set([
|
|
5
|
+
"decomposer",
|
|
6
|
+
"review-optimizer",
|
|
7
|
+
"coder",
|
|
8
|
+
"code-reviewer",
|
|
9
|
+
"judge",
|
|
10
|
+
]);
|
|
11
|
+
const VALID_THINKING_LEVELS = new Set([
|
|
12
|
+
"off",
|
|
13
|
+
"minimal",
|
|
14
|
+
"low",
|
|
15
|
+
"medium",
|
|
16
|
+
"high",
|
|
17
|
+
"xhigh",
|
|
18
|
+
]);
|
|
19
|
+
export function parseAgentMarkdown(content) {
|
|
20
|
+
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
|
|
21
|
+
if (!frontmatterMatch) {
|
|
22
|
+
throw new Error("Invalid agent markdown: missing frontmatter delimiters (---)");
|
|
23
|
+
}
|
|
24
|
+
const frontmatter = frontmatterMatch[1];
|
|
25
|
+
const body = frontmatterMatch[2].trim();
|
|
26
|
+
// Parse role
|
|
27
|
+
const roleMatch = frontmatter.match(/^role:\s*(.+)$/m);
|
|
28
|
+
if (!roleMatch) {
|
|
29
|
+
throw new Error("Invalid agent markdown: missing 'role' in frontmatter");
|
|
30
|
+
}
|
|
31
|
+
const role = roleMatch[1].trim();
|
|
32
|
+
if (!VALID_ROLES.has(role)) {
|
|
33
|
+
throw new Error(`Invalid agent role: '${role}'. Must be one of: ${[...VALID_ROLES].join(", ")}`);
|
|
34
|
+
}
|
|
35
|
+
// Parse thinkingLevel
|
|
36
|
+
let thinkingLevel;
|
|
37
|
+
const thinkingMatch = frontmatter.match(/^thinkingLevel:\s*(.+)$/m);
|
|
38
|
+
if (thinkingMatch) {
|
|
39
|
+
const level = thinkingMatch[1].trim();
|
|
40
|
+
if (!VALID_THINKING_LEVELS.has(level)) {
|
|
41
|
+
throw new Error(`Invalid thinkingLevel: '${level}'. Must be one of: ${[...VALID_THINKING_LEVELS].join(", ")}`);
|
|
42
|
+
}
|
|
43
|
+
thinkingLevel = level;
|
|
44
|
+
}
|
|
45
|
+
// Parse model (nested object with provider and modelId)
|
|
46
|
+
let model;
|
|
47
|
+
const modelMatch = frontmatter.match(/^model:\s*\r?\n((?:[ \t]+.+\r?\n?)*)/m);
|
|
48
|
+
if (modelMatch) {
|
|
49
|
+
const modelBlock = modelMatch[1];
|
|
50
|
+
const providerMatch = modelBlock.match(/provider:\s*(.+)/);
|
|
51
|
+
const modelIdMatch = modelBlock.match(/modelId:\s*(.+)/);
|
|
52
|
+
if (providerMatch && modelIdMatch) {
|
|
53
|
+
model = {
|
|
54
|
+
provider: providerMatch[1].trim(),
|
|
55
|
+
modelId: modelIdMatch[1].trim(),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Parse tools (YAML list with - prefix)
|
|
60
|
+
const tools = [];
|
|
61
|
+
const toolsMatch = frontmatter.match(/^tools:\s*\r?\n((?:[ \t]*-\s*.+\r?\n?)*)/m);
|
|
62
|
+
if (toolsMatch) {
|
|
63
|
+
const toolLines = toolsMatch[1].matchAll(/^\s*-\s*(.+)$/gm);
|
|
64
|
+
for (const match of toolLines) {
|
|
65
|
+
tools.push(match[1].trim());
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Validate tools against permissions
|
|
69
|
+
const allowedTools = AGENT_TOOL_PERMISSIONS[role];
|
|
70
|
+
if (allowedTools) {
|
|
71
|
+
for (const tool of tools) {
|
|
72
|
+
if (!allowedTools.includes(tool)) {
|
|
73
|
+
console.warn(`[registry] Warning: tool '${tool}' is not in allowed list for role '${role}'`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
role: role,
|
|
79
|
+
model,
|
|
80
|
+
thinkingLevel,
|
|
81
|
+
tools,
|
|
82
|
+
systemPrompt: body,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export async function loadAgentDefinitions(agentsDir) {
|
|
86
|
+
const definitions = new Map();
|
|
87
|
+
const entries = await readdir(agentsDir);
|
|
88
|
+
for (const entry of entries) {
|
|
89
|
+
if (!entry.endsWith(".md"))
|
|
90
|
+
continue;
|
|
91
|
+
const filePath = join(agentsDir, entry);
|
|
92
|
+
const content = await readFile(filePath, "utf-8");
|
|
93
|
+
const definition = parseAgentMarkdown(content);
|
|
94
|
+
definitions.set(definition.role, definition);
|
|
95
|
+
}
|
|
96
|
+
return definitions;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/agents/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAwC,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE1F,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAY;IAC3D,YAAY;IACZ,kBAAkB;IAClB,OAAO;IACP,eAAe;IACf,OAAO;CACP,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAgB;IACzE,KAAK;IACL,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;CACP,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IACjD,MAAM,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IACrF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,WAAW,GAAG,gB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C3D,MAAM,WAAW,GAAG,IAAI,GAAG,EAA8B,CAAC;IAC1D,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IAEzC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,SAAS;QAErC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC/C,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,WAAW,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ThinkingLevel } from "../config/types.js";
|
|
2
|
+
export type AgentRole = "decomposer" | "review-optimizer" | "coder" | "code-reviewer" | "judge";
|
|
3
|
+
export interface AgentModelConfig {
|
|
4
|
+
provider: string;
|
|
5
|
+
modelId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AgentDefinition {
|
|
8
|
+
/** Role identifier matching file name */
|
|
9
|
+
role: AgentRole;
|
|
10
|
+
/** Optional model override — falls back to PiLoopConfig.defaultModel */
|
|
11
|
+
model?: AgentModelConfig;
|
|
12
|
+
/** Thinking/reasoning level */
|
|
13
|
+
thinkingLevel?: ThinkingLevel;
|
|
14
|
+
/** Tool names this agent is allowed to use */
|
|
15
|
+
tools: string[];
|
|
16
|
+
/** System prompt (the markdown body after frontmatter) */
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
}
|
|
19
|
+
/** Mapping of tool names each agent role is allowed to use */
|
|
20
|
+
export declare const AGENT_TOOL_PERMISSIONS: Record<AgentRole, readonly string[]>;
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agents/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,kBAAkB,GAAG,OAAO,GAAG,eAAe,GAAG,OAAO,CAAC;AAEhG,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC/B,yCAAyC;IACzC,IAAI,EAAE,SAAS,CAAC;IAChB,wEAAwE;IACxE,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,+BAA+B;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,8CAA8C;IAC9C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;CACrB;AAED,8DAA8D;AAC9D,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAoC9D,CAAC"}
|