agent-state-machine 2.0.14 → 2.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/bin/cli.js +1 -1
- package/lib/index.js +33 -0
- package/lib/remote/client.js +7 -2
- package/lib/runtime/agent.js +102 -67
- package/lib/runtime/index.js +13 -0
- package/lib/runtime/interaction.js +304 -0
- package/lib/runtime/prompt.js +39 -12
- package/lib/runtime/runtime.js +11 -10
- package/package.json +2 -1
- package/templates/project-builder/README.md +119 -0
- package/templates/project-builder/agents/assumptions-clarifier.md +65 -0
- package/templates/project-builder/agents/code-reviewer.md +81 -0
- package/templates/project-builder/agents/code-writer.md +74 -0
- package/templates/project-builder/agents/requirements-clarifier.md +55 -0
- package/templates/project-builder/agents/response-interpreter.md +25 -0
- package/templates/project-builder/agents/roadmap-generator.md +73 -0
- package/templates/project-builder/agents/sanity-checker.md +45 -0
- package/templates/project-builder/agents/sanity-runner.js +161 -0
- package/templates/project-builder/agents/scope-clarifier.md +44 -0
- package/templates/project-builder/agents/security-clarifier.md +71 -0
- package/templates/project-builder/agents/security-reviewer.md +71 -0
- package/templates/project-builder/agents/task-planner.md +62 -0
- package/templates/project-builder/agents/test-planner.md +76 -0
- package/templates/project-builder/config.js +13 -0
- package/templates/project-builder/scripts/interaction-helpers.js +33 -0
- package/templates/project-builder/scripts/mac-notification.js +24 -0
- package/templates/project-builder/scripts/text-human.js +92 -0
- package/templates/project-builder/scripts/workflow-helpers.js +122 -0
- package/templates/project-builder/state/current.json +9 -0
- package/templates/project-builder/state/history.jsonl +0 -0
- package/templates/project-builder/steering/config.json +5 -0
- package/templates/project-builder/steering/global.md +19 -0
- package/templates/project-builder/workflow.js +554 -0
- package/templates/starter/README.md +118 -0
- package/templates/starter/agents/example.js +36 -0
- package/templates/starter/agents/yoda-greeter.md +12 -0
- package/templates/starter/agents/yoda-name-collector.md +12 -0
- package/templates/starter/config.js +12 -0
- package/templates/starter/interactions/.gitkeep +0 -0
- package/templates/starter/scripts/mac-notification.js +24 -0
- package/templates/starter/state/current.json +9 -0
- package/templates/starter/state/history.jsonl +0 -0
- package/templates/starter/steering/config.json +5 -0
- package/templates/starter/steering/global.md +19 -0
- package/templates/starter/workflow.js +52 -0
- package/vercel-server/api/session/[token].js +3 -3
- package/vercel-server/api/submit/[token].js +5 -3
- package/vercel-server/local-server.js +33 -6
- package/vercel-server/public/remote/index.html +17 -0
- package/vercel-server/ui/index.html +9 -1012
- package/vercel-server/ui/package-lock.json +2650 -0
- package/vercel-server/ui/package.json +25 -0
- package/vercel-server/ui/postcss.config.js +6 -0
- package/vercel-server/ui/src/App.jsx +236 -0
- package/vercel-server/ui/src/components/ChoiceInteraction.jsx +127 -0
- package/vercel-server/ui/src/components/ConfirmInteraction.jsx +51 -0
- package/vercel-server/ui/src/components/ContentCard.jsx +161 -0
- package/vercel-server/ui/src/components/CopyButton.jsx +27 -0
- package/vercel-server/ui/src/components/EventsLog.jsx +82 -0
- package/vercel-server/ui/src/components/Footer.jsx +66 -0
- package/vercel-server/ui/src/components/Header.jsx +38 -0
- package/vercel-server/ui/src/components/InteractionForm.jsx +42 -0
- package/vercel-server/ui/src/components/TextInteraction.jsx +72 -0
- package/vercel-server/ui/src/index.css +145 -0
- package/vercel-server/ui/src/main.jsx +8 -0
- package/vercel-server/ui/tailwind.config.js +19 -0
- package/vercel-server/ui/vite.config.js +11 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: high
|
|
3
|
+
format: json
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Reviewer Agent
|
|
7
|
+
|
|
8
|
+
You are a senior code reviewer. Review implementations for quality, correctness, and best practices.
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
Task: {{task}}
|
|
12
|
+
Implementation: {{implementation}}
|
|
13
|
+
Test Plan: {{testPlan}}
|
|
14
|
+
{{#if feedback}}
|
|
15
|
+
Previous Feedback: {{feedback}}
|
|
16
|
+
{{/if}}
|
|
17
|
+
|
|
18
|
+
## Instructions
|
|
19
|
+
|
|
20
|
+
Perform a thorough code review covering:
|
|
21
|
+
|
|
22
|
+
**Correctness:**
|
|
23
|
+
- Does the code fulfill the task requirements?
|
|
24
|
+
- Are all test cases addressed?
|
|
25
|
+
- Are edge cases handled?
|
|
26
|
+
|
|
27
|
+
**Code Quality:**
|
|
28
|
+
- Is the code readable and maintainable?
|
|
29
|
+
- Are naming conventions consistent?
|
|
30
|
+
- Is there unnecessary complexity?
|
|
31
|
+
- Is there code duplication?
|
|
32
|
+
|
|
33
|
+
**Best Practices:**
|
|
34
|
+
- Are design patterns used appropriately?
|
|
35
|
+
- Is error handling comprehensive?
|
|
36
|
+
- Are there performance concerns?
|
|
37
|
+
- Is the code properly documented?
|
|
38
|
+
|
|
39
|
+
**Test Coverage:**
|
|
40
|
+
- Do tests cover the implementation adequately?
|
|
41
|
+
- Are tests meaningful (not just coverage padding)?
|
|
42
|
+
- Are edge cases tested?
|
|
43
|
+
|
|
44
|
+
## Output Format
|
|
45
|
+
|
|
46
|
+
Return a valid JSON object:
|
|
47
|
+
|
|
48
|
+
{
|
|
49
|
+
"overallAssessment": "approved",
|
|
50
|
+
"score": {
|
|
51
|
+
"correctness": 9,
|
|
52
|
+
"quality": 8,
|
|
53
|
+
"testCoverage": 8,
|
|
54
|
+
"overall": 8
|
|
55
|
+
},
|
|
56
|
+
"strengths": [
|
|
57
|
+
"Clean separation of concerns",
|
|
58
|
+
"Good error handling",
|
|
59
|
+
"Comprehensive input validation"
|
|
60
|
+
],
|
|
61
|
+
"issues": [
|
|
62
|
+
{
|
|
63
|
+
"severity": "minor",
|
|
64
|
+
"location": "src/feature.js:25",
|
|
65
|
+
"description": "Variable name could be more descriptive",
|
|
66
|
+
"suggestion": "Rename 'x' to 'userCount'"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"requiredChanges": [],
|
|
70
|
+
"suggestions": [
|
|
71
|
+
"Consider adding JSDoc comments for public functions",
|
|
72
|
+
"Could extract validation logic to a separate utility"
|
|
73
|
+
],
|
|
74
|
+
"approved": true
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
**Assessment values:** approved, needs_changes, rejected
|
|
78
|
+
**Severity values:** critical, major, minor, suggestion
|
|
79
|
+
**Scores:** 1-10
|
|
80
|
+
|
|
81
|
+
Be constructive and specific. Critical issues must be fixed; suggestions are optional.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: high
|
|
3
|
+
format: json
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Writer Agent
|
|
7
|
+
|
|
8
|
+
You are a senior software developer. Implement the task according to specifications.
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
Task: {{task}}
|
|
12
|
+
Phase: {{phase}}
|
|
13
|
+
Requirements: {{requirements}}
|
|
14
|
+
Test Plan: {{testPlan}}
|
|
15
|
+
Security Considerations: {{securityConsiderations}}
|
|
16
|
+
{{#if feedback}}
|
|
17
|
+
Previous Feedback (IMPORTANT - address these issues): {{feedback}}
|
|
18
|
+
{{/if}}
|
|
19
|
+
|
|
20
|
+
## Instructions
|
|
21
|
+
|
|
22
|
+
Implement the task following these principles:
|
|
23
|
+
|
|
24
|
+
**Code Quality:**
|
|
25
|
+
- Write clean, readable code
|
|
26
|
+
- Follow established patterns in the codebase
|
|
27
|
+
- Include meaningful comments for complex logic
|
|
28
|
+
- Handle errors appropriately
|
|
29
|
+
|
|
30
|
+
**Security First:**
|
|
31
|
+
- Address all security concerns from the review
|
|
32
|
+
- Validate all inputs
|
|
33
|
+
- Use secure defaults
|
|
34
|
+
- Avoid common vulnerabilities
|
|
35
|
+
|
|
36
|
+
**Test-Driven:**
|
|
37
|
+
- Implement to satisfy the test plan
|
|
38
|
+
- Ensure all test cases can pass
|
|
39
|
+
- Consider edge cases identified in testing
|
|
40
|
+
|
|
41
|
+
## Output Format
|
|
42
|
+
|
|
43
|
+
Return a valid JSON object:
|
|
44
|
+
|
|
45
|
+
{
|
|
46
|
+
"implementation": {
|
|
47
|
+
"summary": "Brief description of what was implemented",
|
|
48
|
+
"files": [
|
|
49
|
+
{
|
|
50
|
+
"path": "src/feature.js",
|
|
51
|
+
"purpose": "Main implementation",
|
|
52
|
+
"code": "// Full code content here\nfunction example() {\n return 'hello';\n}"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"path": "src/feature.test.js",
|
|
56
|
+
"purpose": "Test file",
|
|
57
|
+
"code": "// Test code here\ndescribe('feature', () => {\n it('works', () => {});\n});"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"dependencies": [
|
|
61
|
+
{"name": "lodash", "version": "^4.17.21", "reason": "Utility functions"}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"usage": {
|
|
65
|
+
"example": "// How to use the implemented functionality\nimport { feature } from './feature';\nfeature();",
|
|
66
|
+
"notes": ["Important usage note 1", "Important usage note 2"]
|
|
67
|
+
},
|
|
68
|
+
"securityMeasures": [
|
|
69
|
+
"Input validation implemented for all user data",
|
|
70
|
+
"SQL injection prevented via parameterized queries"
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Write production-quality code. This is not a prototype.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: med
|
|
3
|
+
format: json
|
|
4
|
+
interaction: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Requirements Clarifier Agent
|
|
8
|
+
|
|
9
|
+
You are a requirements analysis specialist. Your job is to gather and clarify functional and non-functional requirements.
|
|
10
|
+
|
|
11
|
+
## Context
|
|
12
|
+
Project Description: {{projectDescription}}
|
|
13
|
+
Scope: {{scope}}
|
|
14
|
+
{{#if previousResponse}}
|
|
15
|
+
User's Previous Response: {{previousResponse}}
|
|
16
|
+
{{/if}}
|
|
17
|
+
|
|
18
|
+
## Instructions
|
|
19
|
+
|
|
20
|
+
Based on the project description and scope, identify requirements that need clarification. Consider:
|
|
21
|
+
|
|
22
|
+
**Functional Requirements:**
|
|
23
|
+
- Core features and user stories
|
|
24
|
+
- Data models and relationships
|
|
25
|
+
- User workflows and interactions
|
|
26
|
+
- Input/output specifications
|
|
27
|
+
|
|
28
|
+
**Non-Functional Requirements:**
|
|
29
|
+
- Performance expectations
|
|
30
|
+
- Scalability needs
|
|
31
|
+
- Reliability/uptime requirements
|
|
32
|
+
- Accessibility requirements
|
|
33
|
+
|
|
34
|
+
If requirements need clarification, ask using the interact format:
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
"interact": "Please clarify the following requirements:\n\n1. Data Storage:\n - A: Local storage only\n - B: Cloud database required\n - C: Hybrid (local + cloud sync)\n\n2. Authentication:\n - A: No authentication needed\n - B: Simple username/password\n - C: OAuth/SSO integration\n - D: Multi-factor authentication\n\n[Add more questions as needed]\n\nPlease respond with your choices and details:"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
If requirements are clear, return:
|
|
41
|
+
|
|
42
|
+
{
|
|
43
|
+
"requirements": {
|
|
44
|
+
"functional": [
|
|
45
|
+
{"id": "F1", "description": "...", "priority": "high"},
|
|
46
|
+
{"id": "F2", "description": "...", "priority": "medium"}
|
|
47
|
+
],
|
|
48
|
+
"nonFunctional": [
|
|
49
|
+
{"id": "NF1", "description": "...", "category": "performance"},
|
|
50
|
+
{"id": "NF2", "description": "...", "category": "security"}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Focus on must-have requirements. Avoid scope creep.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: fast
|
|
3
|
+
format: json
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are interpreting a user's natural language response against a structured interaction schema.
|
|
7
|
+
|
|
8
|
+
Return JSON only with:
|
|
9
|
+
- selectedKey (string or null)
|
|
10
|
+
- selectedKeys (array, optional)
|
|
11
|
+
- isCustom (boolean)
|
|
12
|
+
- customText (string, optional)
|
|
13
|
+
- confidence ("low" | "medium" | "high")
|
|
14
|
+
- reasoning (short string)
|
|
15
|
+
|
|
16
|
+
Rules:
|
|
17
|
+
- Prefer matching to interaction.options by key or label.
|
|
18
|
+
- If no clear match and allowCustom is true, set isCustom=true and include customText.
|
|
19
|
+
- If ambiguous, set confidence="low" and selectedKey=null.
|
|
20
|
+
|
|
21
|
+
Input:
|
|
22
|
+
{{userResponse}}
|
|
23
|
+
|
|
24
|
+
Schema:
|
|
25
|
+
{{interaction}}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: high
|
|
3
|
+
format: json
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Roadmap Generator Agent
|
|
7
|
+
|
|
8
|
+
You are a project planning specialist. Generate a phased development roadmap as structured JSON.
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
Project Description: {{projectDescription}}
|
|
12
|
+
Scope: {{scope}}
|
|
13
|
+
Requirements: {{requirements}}
|
|
14
|
+
Assumptions: {{assumptions}}
|
|
15
|
+
Security: {{security}}
|
|
16
|
+
{{#if feedback}}
|
|
17
|
+
User Feedback: {{feedback}}
|
|
18
|
+
{{/if}}
|
|
19
|
+
|
|
20
|
+
## Instructions
|
|
21
|
+
|
|
22
|
+
Create a phased roadmap as a JSON object. Each phase should:
|
|
23
|
+
- Have clear objectives
|
|
24
|
+
- Include checklist items
|
|
25
|
+
- Build logically on previous phases
|
|
26
|
+
- Be achievable as a coherent unit
|
|
27
|
+
|
|
28
|
+
**Phase Structure Guidelines:**
|
|
29
|
+
|
|
30
|
+
1. **Phase 1: Foundation** - Project setup, core infrastructure
|
|
31
|
+
2. **Phase 2: Core Features** - Essential functionality
|
|
32
|
+
3. **Phase 3: Extended Features** - Additional capabilities
|
|
33
|
+
4. **Phase 4: Polish & Testing** - QA, optimization, documentation
|
|
34
|
+
5. **Phase 5: Deployment** - Release preparation, deployment
|
|
35
|
+
|
|
36
|
+
Adjust phases based on project complexity. Simple projects may have 2-3 phases; complex ones may have more.
|
|
37
|
+
|
|
38
|
+
## Output Format
|
|
39
|
+
|
|
40
|
+
Return a valid JSON object (no markdown code blocks, just raw JSON):
|
|
41
|
+
|
|
42
|
+
{
|
|
43
|
+
"title": "Project Name",
|
|
44
|
+
"phases": [
|
|
45
|
+
{
|
|
46
|
+
"number": 1,
|
|
47
|
+
"title": "Phase Title",
|
|
48
|
+
"objective": "Brief description of what this phase achieves",
|
|
49
|
+
"completed": false,
|
|
50
|
+
"checklist": [
|
|
51
|
+
{ "text": "Task or milestone 1", "completed": false },
|
|
52
|
+
{ "text": "Task or milestone 2", "completed": false },
|
|
53
|
+
{ "text": "Task or milestone 3", "completed": false }
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"number": 2,
|
|
58
|
+
"title": "Phase Title",
|
|
59
|
+
"objective": "Brief description",
|
|
60
|
+
"completed": false,
|
|
61
|
+
"checklist": [
|
|
62
|
+
{ "text": "Task or milestone 1", "completed": false },
|
|
63
|
+
{ "text": "Task or milestone 2", "completed": false }
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"notes": [
|
|
68
|
+
"Any important considerations",
|
|
69
|
+
"Dependencies or risks"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
Keep each phase focused. Include 3-7 checklist items per phase. Ensure tasks are concrete and verifiable.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: fast
|
|
3
|
+
format: json
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You generate executable sanity checks for the implemented task.
|
|
7
|
+
|
|
8
|
+
Input:
|
|
9
|
+
- task: { title, description, doneDefinition, sanityCheck }
|
|
10
|
+
- implementation: code-writer output
|
|
11
|
+
- testPlan: test-planner output
|
|
12
|
+
|
|
13
|
+
Return JSON only in this shape:
|
|
14
|
+
{
|
|
15
|
+
"checks": [
|
|
16
|
+
{
|
|
17
|
+
"id": 1,
|
|
18
|
+
"description": "What this verifies",
|
|
19
|
+
"type": "shell" | "file_exists" | "file_contains" | "test_suite",
|
|
20
|
+
"command": "shell command if type=shell/test_suite",
|
|
21
|
+
"expected": "expected output (optional)",
|
|
22
|
+
"comparison": "equals" | "contains" | "not_empty",
|
|
23
|
+
"path": "file path for file checks",
|
|
24
|
+
"pattern": "string or regex source for file_contains"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"setup": "optional setup command",
|
|
28
|
+
"teardown": "optional teardown command"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Guidelines:
|
|
32
|
+
- Use actual file paths and commands implied by the implementation.
|
|
33
|
+
- Prefer simple, local commands (curl, node, npm, cat, rg).
|
|
34
|
+
- If the task describes a server endpoint, include a curl check.
|
|
35
|
+
- Keep checks short, clear, and runnable.
|
|
36
|
+
- Include at least one file_exists or file_contains check when files are created/modified.
|
|
37
|
+
|
|
38
|
+
Task:
|
|
39
|
+
{{task}}
|
|
40
|
+
|
|
41
|
+
Implementation:
|
|
42
|
+
{{implementation}}
|
|
43
|
+
|
|
44
|
+
Test Plan:
|
|
45
|
+
{{testPlan}}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { exec, spawn } from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
6
|
+
|
|
7
|
+
export default async function sanityRunner(context) {
|
|
8
|
+
const { checks = [], setup, teardown } = context;
|
|
9
|
+
const cwd = context?._config?.workflowDir || process.cwd();
|
|
10
|
+
const results = [];
|
|
11
|
+
|
|
12
|
+
let setupError = null;
|
|
13
|
+
if (setup) {
|
|
14
|
+
try {
|
|
15
|
+
await runSetup(setup, cwd);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
setupError = error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
for (const check of checks) {
|
|
22
|
+
if (setupError) {
|
|
23
|
+
results.push({
|
|
24
|
+
id: check.id,
|
|
25
|
+
status: 'failed',
|
|
26
|
+
error: `Setup failed: ${setupError.message}`
|
|
27
|
+
});
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const result = await runCheck(check, cwd);
|
|
32
|
+
results.push(result);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (teardown) {
|
|
36
|
+
try {
|
|
37
|
+
await execCommand(teardown, cwd, DEFAULT_TIMEOUT_MS);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
results.push({
|
|
40
|
+
id: 'teardown',
|
|
41
|
+
status: 'failed',
|
|
42
|
+
error: `Teardown failed: ${error.message}`
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const summary = results.reduce((acc, item) => {
|
|
48
|
+
if (item.status === 'passed') acc.passed += 1;
|
|
49
|
+
if (item.status === 'failed') acc.failed += 1;
|
|
50
|
+
return acc;
|
|
51
|
+
}, { passed: 0, failed: 0 });
|
|
52
|
+
|
|
53
|
+
return { summary, results };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function runSetup(command, cwd) {
|
|
57
|
+
const trimmed = command.trim();
|
|
58
|
+
if (trimmed.endsWith('&')) {
|
|
59
|
+
const withoutAmp = trimmed.replace(/&\s*$/, '').trim();
|
|
60
|
+
const child = spawn(withoutAmp, {
|
|
61
|
+
cwd,
|
|
62
|
+
shell: true,
|
|
63
|
+
detached: true,
|
|
64
|
+
stdio: 'ignore'
|
|
65
|
+
});
|
|
66
|
+
child.unref();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
await execCommand(command, cwd, DEFAULT_TIMEOUT_MS);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function runCheck(check, cwd) {
|
|
73
|
+
const timeoutMs = check.timeoutMs || DEFAULT_TIMEOUT_MS;
|
|
74
|
+
const type = check.type || 'shell';
|
|
75
|
+
const id = check.id ?? 'unknown';
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
if (type === 'shell') {
|
|
79
|
+
const output = await execCommand(check.command, cwd, timeoutMs);
|
|
80
|
+
return compareOutput(id, output, check);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (type === 'test_suite') {
|
|
84
|
+
await execCommand(check.command || check.testCommand, cwd, timeoutMs);
|
|
85
|
+
return { id, status: 'passed' };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (type === 'file_exists') {
|
|
89
|
+
const filePath = path.resolve(cwd, check.path || '');
|
|
90
|
+
if (fs.existsSync(filePath)) {
|
|
91
|
+
return { id, status: 'passed' };
|
|
92
|
+
}
|
|
93
|
+
return { id, status: 'failed', error: `File not found: ${check.path}` };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (type === 'file_contains') {
|
|
97
|
+
const filePath = path.resolve(cwd, check.path || '');
|
|
98
|
+
if (!fs.existsSync(filePath)) {
|
|
99
|
+
return { id, status: 'failed', error: `File not found: ${check.path}` };
|
|
100
|
+
}
|
|
101
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
102
|
+
const pattern = check.pattern || check.contains || check.text || '';
|
|
103
|
+
if (!pattern) {
|
|
104
|
+
return { id, status: 'failed', error: 'Missing pattern for file_contains' };
|
|
105
|
+
}
|
|
106
|
+
const regex = pattern instanceof RegExp ? pattern : new RegExp(pattern, 'm');
|
|
107
|
+
if (regex.test(content)) {
|
|
108
|
+
return { id, status: 'passed' };
|
|
109
|
+
}
|
|
110
|
+
return { id, status: 'failed', error: `Pattern not found: ${pattern}` };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return { id, status: 'failed', error: `Unsupported check type: ${type}` };
|
|
114
|
+
} catch (error) {
|
|
115
|
+
return {
|
|
116
|
+
id,
|
|
117
|
+
status: 'failed',
|
|
118
|
+
error: error.message,
|
|
119
|
+
output: error.output
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function compareOutput(id, output, check) {
|
|
125
|
+
const expected = check.expected ?? '';
|
|
126
|
+
const comparison = check.comparison || 'equals';
|
|
127
|
+
const trimmed = String(output ?? '').trim();
|
|
128
|
+
|
|
129
|
+
if (comparison === 'not_empty') {
|
|
130
|
+
return trimmed.length > 0
|
|
131
|
+
? { id, status: 'passed', output: trimmed }
|
|
132
|
+
: { id, status: 'failed', error: 'Output was empty', output: trimmed };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (comparison === 'contains') {
|
|
136
|
+
return trimmed.includes(String(expected))
|
|
137
|
+
? { id, status: 'passed', output: trimmed }
|
|
138
|
+
: { id, status: 'failed', error: `Output did not contain: ${expected}`, output: trimmed };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return trimmed === String(expected)
|
|
142
|
+
? { id, status: 'passed', output: trimmed }
|
|
143
|
+
: { id, status: 'failed', error: `Expected "${expected}", got "${trimmed}"`, output: trimmed };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function execCommand(command, cwd, timeoutMs) {
|
|
147
|
+
return new Promise((resolve, reject) => {
|
|
148
|
+
if (!command) {
|
|
149
|
+
reject(new Error('Missing command'));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
exec(command, { cwd, timeout: timeoutMs, maxBuffer: 1024 * 1024 }, (error, stdout, stderr) => {
|
|
153
|
+
if (error) {
|
|
154
|
+
error.output = stderr || stdout;
|
|
155
|
+
reject(error);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
resolve(stdout || stderr || '');
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: med
|
|
3
|
+
format: json
|
|
4
|
+
interaction: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Scope Clarifier Agent
|
|
8
|
+
|
|
9
|
+
You are a project scope clarification specialist. Your job is to ensure the project scope is well-defined before development begins.
|
|
10
|
+
|
|
11
|
+
## Context
|
|
12
|
+
Project Description: {{projectDescription}}
|
|
13
|
+
{{#if previousResponse}}
|
|
14
|
+
User's Previous Response: {{previousResponse}}
|
|
15
|
+
{{/if}}
|
|
16
|
+
|
|
17
|
+
## Instructions
|
|
18
|
+
|
|
19
|
+
Analyze the project description and determine if the scope is clear. Consider:
|
|
20
|
+
- Project boundaries (what's in scope vs out of scope)
|
|
21
|
+
- Target users/audience
|
|
22
|
+
- Core functionality vs nice-to-haves
|
|
23
|
+
- Platform/environment constraints
|
|
24
|
+
- Integration requirements
|
|
25
|
+
|
|
26
|
+
If the scope is unclear or ambiguous, ask clarifying questions using the interact format:
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
"interact": "Please clarify the following scope questions:\n\n1. Target Platform:\n - A: Web application\n - B: Mobile app\n - C: Desktop application\n - D: API/Backend service\n\n2. User Scale:\n - A: Single user / personal project\n - B: Small team (< 10 users)\n - C: Medium scale (10-1000 users)\n - D: Large scale (1000+ users)\n\n[Add more questions as needed]\n\nPlease respond with your choices (e.g., '1A, 2C') and any additional details:"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
If the scope is sufficiently clear, return the scope summary:
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
"scope": {
|
|
36
|
+
"inScope": ["list", "of", "features"],
|
|
37
|
+
"outOfScope": ["explicitly", "excluded", "items"],
|
|
38
|
+
"targetUsers": "description of target users",
|
|
39
|
+
"platform": "target platform(s)",
|
|
40
|
+
"constraints": ["list", "of", "constraints"]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Be concise. Ask only essential questions.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
model: med
|
|
3
|
+
format: json
|
|
4
|
+
interaction: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Security Clarifier Agent
|
|
8
|
+
|
|
9
|
+
You are a security requirements specialist. Your job is to identify security needs and concerns early in the project.
|
|
10
|
+
|
|
11
|
+
## Context
|
|
12
|
+
Project Description: {{projectDescription}}
|
|
13
|
+
Scope: {{scope}}
|
|
14
|
+
Requirements: {{requirements}}
|
|
15
|
+
Assumptions: {{assumptions}}
|
|
16
|
+
{{#if previousResponse}}
|
|
17
|
+
User's Previous Response: {{previousResponse}}
|
|
18
|
+
{{/if}}
|
|
19
|
+
|
|
20
|
+
## Instructions
|
|
21
|
+
|
|
22
|
+
Analyze the project for security implications. Consider:
|
|
23
|
+
|
|
24
|
+
**Data Security:**
|
|
25
|
+
- Sensitive data handling (PII, financial, health)
|
|
26
|
+
- Data encryption requirements
|
|
27
|
+
- Data retention policies
|
|
28
|
+
|
|
29
|
+
**Access Control:**
|
|
30
|
+
- Authentication requirements
|
|
31
|
+
- Authorization model
|
|
32
|
+
- Role-based access needs
|
|
33
|
+
|
|
34
|
+
**Compliance:**
|
|
35
|
+
- Regulatory requirements (GDPR, HIPAA, PCI-DSS)
|
|
36
|
+
- Industry standards
|
|
37
|
+
- Audit requirements
|
|
38
|
+
|
|
39
|
+
**Infrastructure:**
|
|
40
|
+
- Network security
|
|
41
|
+
- API security
|
|
42
|
+
- Deployment security
|
|
43
|
+
|
|
44
|
+
If security requirements need clarification, ask using the interact format:
|
|
45
|
+
|
|
46
|
+
{
|
|
47
|
+
"interact": "Please clarify security requirements:\n\n1. Sensitive Data:\n - A: No sensitive data handled\n - B: Personal information (names, emails)\n - C: Financial data (payments, transactions)\n - D: Health/medical data\n - E: Other regulated data\n\n2. Compliance Requirements:\n - A: No specific compliance needed\n - B: GDPR (EU data protection)\n - C: HIPAA (healthcare)\n - D: PCI-DSS (payment cards)\n - E: SOC2 / enterprise security\n\n3. Authentication Level:\n - A: Basic (username/password)\n - B: Enhanced (MFA, SSO)\n - C: Enterprise (LDAP, SAML)\n\nPlease respond with your choices and details:"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
If security requirements are clear, return:
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
"security": {
|
|
54
|
+
"dataClassification": "public|internal|confidential|restricted",
|
|
55
|
+
"authRequirements": {
|
|
56
|
+
"type": "basic|enhanced|enterprise",
|
|
57
|
+
"mfa": false,
|
|
58
|
+
"sso": false
|
|
59
|
+
},
|
|
60
|
+
"complianceNeeds": ["GDPR", "etc"],
|
|
61
|
+
"securityControls": [
|
|
62
|
+
{"control": "Input validation", "priority": "required"},
|
|
63
|
+
{"control": "HTTPS only", "priority": "required"}
|
|
64
|
+
],
|
|
65
|
+
"threatModel": [
|
|
66
|
+
{"threat": "SQL injection", "mitigation": "Parameterized queries"}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
Prioritize security by default. When in doubt, recommend stronger measures.
|