vibeman 0.0.3 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +49 -0
- package/dist/cli.js +135 -0
- package/dist/ui/index-gnk6rhxs.js +9 -0
- package/dist/ui/index.html +10 -0
- package/dist/ui/index.js +2 -0
- package/package.json +10 -80
- package/README.md +0 -12
- package/dist/index.js +0 -114
- package/dist/runtime/api/.tsbuildinfo +0 -1
- package/dist/runtime/api/agent/agent-service.d.ts +0 -225
- package/dist/runtime/api/agent/agent-service.js +0 -904
- package/dist/runtime/api/agent/ai-providers/claude-code-adapter.d.ts +0 -61
- package/dist/runtime/api/agent/ai-providers/claude-code-adapter.js +0 -362
- package/dist/runtime/api/agent/ai-providers/codex-cli-provider.d.ts +0 -36
- package/dist/runtime/api/agent/ai-providers/codex-cli-provider.js +0 -347
- package/dist/runtime/api/agent/ai-providers/index.d.ts +0 -9
- package/dist/runtime/api/agent/ai-providers/index.js +0 -7
- package/dist/runtime/api/agent/ai-providers/types.d.ts +0 -182
- package/dist/runtime/api/agent/ai-providers/types.js +0 -5
- package/dist/runtime/api/agent/codex-cli-provider.test.d.ts +0 -1
- package/dist/runtime/api/agent/codex-cli-provider.test.js +0 -170
- package/dist/runtime/api/agent/core-agent-service.d.ts +0 -119
- package/dist/runtime/api/agent/core-agent-service.js +0 -267
- package/dist/runtime/api/agent/parsers.d.ts +0 -16
- package/dist/runtime/api/agent/parsers.js +0 -308
- package/dist/runtime/api/agent/prompt-service.d.ts +0 -30
- package/dist/runtime/api/agent/prompt-service.js +0 -449
- package/dist/runtime/api/agent/prompt-service.test.d.ts +0 -1
- package/dist/runtime/api/agent/prompt-service.test.js +0 -230
- package/dist/runtime/api/agent/routing-policy.d.ts +0 -171
- package/dist/runtime/api/agent/routing-policy.js +0 -196
- package/dist/runtime/api/agent/routing-policy.test.d.ts +0 -1
- package/dist/runtime/api/agent/routing-policy.test.js +0 -63
- package/dist/runtime/api/api/router-helpers.d.ts +0 -32
- package/dist/runtime/api/api/router-helpers.js +0 -31
- package/dist/runtime/api/api/routers/ai.d.ts +0 -200
- package/dist/runtime/api/api/routers/ai.js +0 -396
- package/dist/runtime/api/api/routers/executions.d.ts +0 -98
- package/dist/runtime/api/api/routers/executions.js +0 -94
- package/dist/runtime/api/api/routers/git.d.ts +0 -45
- package/dist/runtime/api/api/routers/git.js +0 -35
- package/dist/runtime/api/api/routers/provider-config.d.ts +0 -165
- package/dist/runtime/api/api/routers/provider-config.js +0 -252
- package/dist/runtime/api/api/routers/settings.d.ts +0 -139
- package/dist/runtime/api/api/routers/settings.js +0 -113
- package/dist/runtime/api/api/routers/tasks.d.ts +0 -141
- package/dist/runtime/api/api/routers/tasks.js +0 -238
- package/dist/runtime/api/api/routers/workflows.d.ts +0 -275
- package/dist/runtime/api/api/routers/workflows.js +0 -311
- package/dist/runtime/api/api/routers/worktrees.d.ts +0 -101
- package/dist/runtime/api/api/routers/worktrees.js +0 -80
- package/dist/runtime/api/api/trpc.d.ts +0 -118
- package/dist/runtime/api/api/trpc.js +0 -34
- package/dist/runtime/api/index.d.ts +0 -9
- package/dist/runtime/api/index.js +0 -117
- package/dist/runtime/api/lib/id-generator.d.ts +0 -70
- package/dist/runtime/api/lib/id-generator.js +0 -123
- package/dist/runtime/api/lib/local-config.d.ts +0 -245
- package/dist/runtime/api/lib/local-config.js +0 -288
- package/dist/runtime/api/lib/logger.d.ts +0 -11
- package/dist/runtime/api/lib/logger.js +0 -188
- package/dist/runtime/api/lib/provider-detection.d.ts +0 -59
- package/dist/runtime/api/lib/provider-detection.js +0 -244
- package/dist/runtime/api/lib/server/agent-service-singleton.d.ts +0 -6
- package/dist/runtime/api/lib/server/agent-service-singleton.js +0 -27
- package/dist/runtime/api/lib/server/bootstrap.d.ts +0 -38
- package/dist/runtime/api/lib/server/bootstrap.js +0 -197
- package/dist/runtime/api/lib/server/git-service-singleton.d.ts +0 -6
- package/dist/runtime/api/lib/server/git-service-singleton.js +0 -47
- package/dist/runtime/api/lib/server/project-root.d.ts +0 -2
- package/dist/runtime/api/lib/server/project-root.js +0 -61
- package/dist/runtime/api/lib/server/task-service-singleton.d.ts +0 -7
- package/dist/runtime/api/lib/server/task-service-singleton.js +0 -58
- package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.d.ts +0 -7
- package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.js +0 -57
- package/dist/runtime/api/lib/trpc/client.d.ts +0 -1
- package/dist/runtime/api/lib/trpc/client.js +0 -5
- package/dist/runtime/api/lib/trpc/server.d.ts +0 -935
- package/dist/runtime/api/lib/trpc/server.js +0 -11
- package/dist/runtime/api/lib/trpc/ws-server.d.ts +0 -8
- package/dist/runtime/api/lib/trpc/ws-server.js +0 -33
- package/dist/runtime/api/persistence/database-service.d.ts +0 -14
- package/dist/runtime/api/persistence/database-service.js +0 -74
- package/dist/runtime/api/persistence/execution-log-persistence.d.ts +0 -90
- package/dist/runtime/api/persistence/execution-log-persistence.js +0 -410
- package/dist/runtime/api/persistence/execution-log-persistence.test.d.ts +0 -1
- package/dist/runtime/api/persistence/execution-log-persistence.test.js +0 -170
- package/dist/runtime/api/router.d.ts +0 -938
- package/dist/runtime/api/router.js +0 -34
- package/dist/runtime/api/settings-service.d.ts +0 -110
- package/dist/runtime/api/settings-service.js +0 -661
- package/dist/runtime/api/tasks/file-watcher.d.ts +0 -23
- package/dist/runtime/api/tasks/file-watcher.js +0 -88
- package/dist/runtime/api/tasks/task-file-parser.d.ts +0 -13
- package/dist/runtime/api/tasks/task-file-parser.js +0 -161
- package/dist/runtime/api/tasks/task-service.d.ts +0 -36
- package/dist/runtime/api/tasks/task-service.js +0 -173
- package/dist/runtime/api/types/index.d.ts +0 -186
- package/dist/runtime/api/types/index.js +0 -1
- package/dist/runtime/api/types/settings.d.ts +0 -94
- package/dist/runtime/api/types/settings.js +0 -2
- package/dist/runtime/api/types.d.ts +0 -2
- package/dist/runtime/api/types.js +0 -1
- package/dist/runtime/api/utils/env.d.ts +0 -6
- package/dist/runtime/api/utils/env.js +0 -12
- package/dist/runtime/api/utils/stripNextEnv.d.ts +0 -7
- package/dist/runtime/api/utils/stripNextEnv.js +0 -22
- package/dist/runtime/api/utils/title-slug.d.ts +0 -6
- package/dist/runtime/api/utils/title-slug.js +0 -77
- package/dist/runtime/api/utils/url.d.ts +0 -2
- package/dist/runtime/api/utils/url.js +0 -19
- package/dist/runtime/api/vcs/git-history-service.d.ts +0 -57
- package/dist/runtime/api/vcs/git-history-service.js +0 -228
- package/dist/runtime/api/vcs/git-service.d.ts +0 -127
- package/dist/runtime/api/vcs/git-service.js +0 -284
- package/dist/runtime/api/vcs/worktree-service.d.ts +0 -93
- package/dist/runtime/api/vcs/worktree-service.js +0 -506
- package/dist/runtime/api/vcs/worktree-service.test.d.ts +0 -1
- package/dist/runtime/api/vcs/worktree-service.test.js +0 -20
- package/dist/runtime/api/workflows/quality-pipeline.d.ts +0 -58
- package/dist/runtime/api/workflows/quality-pipeline.js +0 -400
- package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +0 -318
- package/dist/runtime/api/workflows/vibing-orchestrator.js +0 -1891
- package/dist/runtime/web/.next/BUILD_ID +0 -1
- package/dist/runtime/web/.next/app-build-manifest.json +0 -66
- package/dist/runtime/web/.next/app-path-routes-manifest.json +0 -8
- package/dist/runtime/web/.next/build-manifest.json +0 -33
- package/dist/runtime/web/.next/package.json +0 -1
- package/dist/runtime/web/.next/prerender-manifest.json +0 -61
- package/dist/runtime/web/.next/react-loadable-manifest.json +0 -39
- package/dist/runtime/web/.next/required-server-files.json +0 -334
- package/dist/runtime/web/.next/routes-manifest.json +0 -70
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js +0 -1
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/_not-found/page.js +0 -2
- package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/_not-found.html +0 -7
- package/dist/runtime/web/.next/server/app/_not-found.meta +0 -8
- package/dist/runtime/web/.next/server/app/_not-found.rsc +0 -22
- package/dist/runtime/web/.next/server/app/api/health/route.js +0 -1
- package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +0 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/api/upload/route.js +0 -1
- package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/index.html +0 -7
- package/dist/runtime/web/.next/server/app/index.meta +0 -7
- package/dist/runtime/web/.next/server/app/index.rsc +0 -27
- package/dist/runtime/web/.next/server/app/page.js +0 -147
- package/dist/runtime/web/.next/server/app/page.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app-paths-manifest.json +0 -8
- package/dist/runtime/web/.next/server/chunks/217.js +0 -1
- package/dist/runtime/web/.next/server/chunks/383.js +0 -6
- package/dist/runtime/web/.next/server/chunks/458.js +0 -1
- package/dist/runtime/web/.next/server/chunks/576.js +0 -18
- package/dist/runtime/web/.next/server/chunks/635.js +0 -22
- package/dist/runtime/web/.next/server/chunks/761.js +0 -1
- package/dist/runtime/web/.next/server/chunks/777.js +0 -3
- package/dist/runtime/web/.next/server/chunks/825.js +0 -1
- package/dist/runtime/web/.next/server/chunks/838.js +0 -1
- package/dist/runtime/web/.next/server/chunks/973.js +0 -15
- package/dist/runtime/web/.next/server/functions-config-manifest.json +0 -4
- package/dist/runtime/web/.next/server/middleware-build-manifest.js +0 -1
- package/dist/runtime/web/.next/server/middleware-manifest.json +0 -6
- package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/dist/runtime/web/.next/server/next-font-manifest.js +0 -1
- package/dist/runtime/web/.next/server/next-font-manifest.json +0 -1
- package/dist/runtime/web/.next/server/pages/404.html +0 -7
- package/dist/runtime/web/.next/server/pages/500.html +0 -1
- package/dist/runtime/web/.next/server/pages/_app.js +0 -1
- package/dist/runtime/web/.next/server/pages/_app.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/pages/_document.js +0 -1
- package/dist/runtime/web/.next/server/pages/_document.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/pages/_error.js +0 -19
- package/dist/runtime/web/.next/server/pages/_error.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/pages-manifest.json +0 -6
- package/dist/runtime/web/.next/server/server-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/server-reference-manifest.json +0 -1
- package/dist/runtime/web/.next/server/webpack-runtime.js +0 -1
- package/dist/runtime/web/.next/static/5_15u1WQCxN1_eHZpldCv/_buildManifest.js +0 -1
- package/dist/runtime/web/.next/static/5_15u1WQCxN1_eHZpldCv/_ssgManifest.js +0 -1
- package/dist/runtime/web/.next/static/chunks/18-15c10d3288afef2e.js +0 -1
- package/dist/runtime/web/.next/static/chunks/1c0ca389.537bbe362e3ffbd9.js +0 -3
- package/dist/runtime/web/.next/static/chunks/22747d63-ad5da0c19f4cfe41.js +0 -71
- package/dist/runtime/web/.next/static/chunks/355.056c2645878a799a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/420.a5ccf151c9e2b2f1.js +0 -1
- package/dist/runtime/web/.next/static/chunks/439.1be0c6242fd248d5.js +0 -15
- package/dist/runtime/web/.next/static/chunks/440.c52e7c0f797e22b2.js +0 -1
- package/dist/runtime/web/.next/static/chunks/575-e2478287c27da87b.js +0 -1
- package/dist/runtime/web/.next/static/chunks/691.920d88c115087314.js +0 -1
- package/dist/runtime/web/.next/static/chunks/765-e838910065b50c3d.js +0 -1
- package/dist/runtime/web/.next/static/chunks/823-6f371a6e829adbba.js +0 -63
- package/dist/runtime/web/.next/static/chunks/87c73c54-09e1ba5c70e60a51.js +0 -1
- package/dist/runtime/web/.next/static/chunks/891cff7f.0f71fc028f87e683.js +0 -1
- package/dist/runtime/web/.next/static/chunks/8bb4d8db-3e2aa02b0a2384b9.js +0 -1
- package/dist/runtime/web/.next/static/chunks/9af238c7-271a911d4e99ab18.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/.vibeman/assets/images/[...path]/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/_not-found/page-1cb74d1cba27d0ab.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/health/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/upload/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/layout-8435322f09fd0975.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/page-9fe7d75095b4ccec.js +0 -1
- package/dist/runtime/web/.next/static/chunks/cac567b0-5b77dd12911823cd.js +0 -1
- package/dist/runtime/web/.next/static/chunks/framework-2518f1345b5b2806.js +0 -1
- package/dist/runtime/web/.next/static/chunks/main-17665e5e39de9a8a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/main-app-c0b0f5ba4f7f9d75.js +0 -1
- package/dist/runtime/web/.next/static/chunks/pages/_app-d6f6b3bbc3d81ee1.js +0 -1
- package/dist/runtime/web/.next/static/chunks/pages/_error-75a96cf1997cc3b9.js +0 -1
- package/dist/runtime/web/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/webpack-c8de37305b4635cf.js +0 -1
- package/dist/runtime/web/.next/static/css/08c950681f1a9a92.css +0 -1
- package/dist/runtime/web/.next/static/css/2728291c68f99cb1.css +0 -3
- package/dist/runtime/web/.next/static/css/521bd69cc298cd1a.css +0 -1
- package/dist/runtime/web/.next/static/css/537e22821e101b87.css +0 -1
- package/dist/runtime/web/.next/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/21350d82a1f187e9-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/8e9860b6e62d6359-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/ba9851c3c22cd980-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/df0a9ae256c0569c-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
- package/dist/runtime/web/package.json +0 -65
- package/dist/runtime/web/server.js +0 -44
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,449 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs/promises';
|
|
3
|
-
import { log } from '../lib/logger.js';
|
|
4
|
-
import { getVibeDir } from '../lib/server/project-root.js';
|
|
5
|
-
// -----------------------------
|
|
6
|
-
// Prompt templates (hard-coded)
|
|
7
|
-
// -----------------------------
|
|
8
|
-
const IMPROVEMENT_TEMPLATE = `The current content might be a brief description or incomplete specification. Transform it into a comprehensive, well-structured task specification using advanced reasoning.
|
|
9
|
-
|
|
10
|
-
## Analysis Framework
|
|
11
|
-
|
|
12
|
-
First, conduct a thorough analysis:
|
|
13
|
-
|
|
14
|
-
1. **Current State Assessment**: Analyze the existing task content for clarity, completeness, and specificity
|
|
15
|
-
2. **Type Classification**: Evaluate if the current type ({{taskType}}) aligns with the actual work required:
|
|
16
|
-
- **feature**: New functionality or capabilities
|
|
17
|
-
- **bug**: Fixing defects or issues
|
|
18
|
-
- **chore**: Maintenance, dependencies, tooling
|
|
19
|
-
- **refactor**: Code improvement without behavior change
|
|
20
|
-
- **test**: Adding or improving tests
|
|
21
|
-
- **doc**: Documentation updates
|
|
22
|
-
|
|
23
|
-
3. **Priority Assessment**: Evaluate if the current priority ({{taskPriority}}) reflects the business impact and urgency:
|
|
24
|
-
- **high**: Critical, blocking, or high business value
|
|
25
|
-
- **medium**: Important but not urgent, moderate impact
|
|
26
|
-
- **low**: Nice to have, minor improvements
|
|
27
|
-
|
|
28
|
-
4. **Scope and Complexity Analysis**: Determine if the task is appropriately sized and scoped
|
|
29
|
-
|
|
30
|
-
If you recommend changes to type or priority, include them at the top of your response:
|
|
31
|
-
**Type**: [recommended type with brief reasoning]
|
|
32
|
-
**Priority**: [recommended priority with brief reasoning]
|
|
33
|
-
|
|
34
|
-
### Expected Content Format:
|
|
35
|
-
|
|
36
|
-
#### Description
|
|
37
|
-
[Provide a clear, detailed description of what needs to be accomplished]
|
|
38
|
-
|
|
39
|
-
#### Acceptance Criteria
|
|
40
|
-
- [ ] [Specific, testable criterion 1]
|
|
41
|
-
- [ ] [Specific, testable criterion 2]
|
|
42
|
-
- [ ] [Specific, testable criterion 3]
|
|
43
|
-
[Add more as needed]
|
|
44
|
-
|
|
45
|
-
#### Technical Details
|
|
46
|
-
[Include implementation considerations, architecture notes, dependencies, etc.]
|
|
47
|
-
|
|
48
|
-
#### Implementation Notes
|
|
49
|
-
[Any specific guidance, patterns to follow, potential challenges, etc.]
|
|
50
|
-
[Split into smaller tasks and todo items if needed]
|
|
51
|
-
|
|
52
|
-
## Advanced Improvement Guidelines:
|
|
53
|
-
|
|
54
|
-
1. **Precision & Clarity**: Transform vague requirements into concrete, measurable, actionable items with clear success criteria
|
|
55
|
-
2. **Technical Depth**: Consider implementation complexity, architecture implications, and technical dependencies
|
|
56
|
-
3. **Project Alignment**: Ensure the task fits within the existing codebase architecture and follows established patterns
|
|
57
|
-
4. **Quality Assurance**: Include comprehensive testing strategies, edge cases, and validation approaches
|
|
58
|
-
5. **Risk Assessment**: Identify potential challenges, blockers, and mitigation strategies
|
|
59
|
-
6. **Cross-functional Impact**: Consider effects on other systems, teams, or user experiences
|
|
60
|
-
7. **Scalability & Performance**: Include considerations for performance, scalability, and maintainability
|
|
61
|
-
8. **Documentation**: Ensure adequate documentation and knowledge transfer requirements
|
|
62
|
-
9. **Scope Optimization**: Balance completeness with manageable task size for effective execution
|
|
63
|
-
10. **Context Preservation**: Maintain original intent while significantly enhancing detail and clarity
|
|
64
|
-
11. **Standards Compliance**: Follow GitHub Flavored Markdown specification and project conventions
|
|
65
|
-
12. **Asset Preservation**: Retain any images, diagrams, or other media from the original content
|
|
66
|
-
13. **Simple and focus**: Keep the task simple, don't make it too complex and over design, focus on the core functionality and core business logic
|
|
67
|
-
|
|
68
|
-
## Expected Output Structure
|
|
69
|
-
|
|
70
|
-
Return a JSON object with:
|
|
71
|
-
- "type": one of [feature, bug, chore, refactor, test, doc]
|
|
72
|
-
- "priority": one of [high, medium, low]
|
|
73
|
-
- "title": a concise, descriptive title for the task (optional, but preferred)
|
|
74
|
-
- "content": the improved task specification in markdown format with proper JSON escaping
|
|
75
|
-
|
|
76
|
-
If you include a title in the JSON response, do NOT include an H1 heading at the beginning of the content field to avoid duplication.
|
|
77
|
-
|
|
78
|
-
## Project Context
|
|
79
|
-
|
|
80
|
-
<ProjectContext>
|
|
81
|
-
{{projectContext}}
|
|
82
|
-
</ProjectContext>
|
|
83
|
-
|
|
84
|
-
## Current Task Details
|
|
85
|
-
- **ID:** {{taskId}}
|
|
86
|
-
- **Title:** {{taskTitle}}
|
|
87
|
-
- **Type:** {{taskType}}
|
|
88
|
-
- **Priority:** {{taskPriority}}
|
|
89
|
-
- **Status:** {{taskStatus}}
|
|
90
|
-
|
|
91
|
-
## Content to Improve
|
|
92
|
-
|
|
93
|
-
<CurrentTaskContent>
|
|
94
|
-
{{taskContent}}
|
|
95
|
-
</CurrentTaskContent>
|
|
96
|
-
`;
|
|
97
|
-
const TASK_TEMPLATE = `## Task Assignment
|
|
98
|
-
|
|
99
|
-
Deliver the following task.
|
|
100
|
-
|
|
101
|
-
## Workflow Instructions
|
|
102
|
-
|
|
103
|
-
{{workflowInstructions}}
|
|
104
|
-
|
|
105
|
-
## Responsibilities
|
|
106
|
-
|
|
107
|
-
1. **Analyze requirements** — study the acceptance criteria to clarify what must be delivered.
|
|
108
|
-
2. **Review the codebase** — understand the current implementation, architecture, and coding patterns.
|
|
109
|
-
3. **Implement changes** — add or modify code according to project conventions.
|
|
110
|
-
4. **Test thoroughly** — write/run tests and verify that all builds succeed.
|
|
111
|
-
5. **Update the task file** — tick off each acceptance criterion that you have completed.
|
|
112
|
-
|
|
113
|
-
## Development Guidelines
|
|
114
|
-
|
|
115
|
-
- Respect existing architecture and style conventions.
|
|
116
|
-
- Add robust error handling.
|
|
117
|
-
- Update documentation when necessary.
|
|
118
|
-
- Ensure all tests pass and the project builds cleanly.
|
|
119
|
-
- Commit with a clear, descriptive message.
|
|
120
|
-
- Create todo list to track the progress.
|
|
121
|
-
|
|
122
|
-
## Expected Deliverables
|
|
123
|
-
|
|
124
|
-
- A working implementation that satisfies every requirement.
|
|
125
|
-
- An updated task file showing completed acceptance criteria.
|
|
126
|
-
- Clean, well-documented code.
|
|
127
|
-
- Passing build and test results.
|
|
128
|
-
|
|
129
|
-
Begin by examining the codebase; then proceed with the implementation.
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
### Task Snapshot
|
|
134
|
-
|
|
135
|
-
- **ID:** {{taskId}}
|
|
136
|
-
- **Title:** {{taskTitle}}
|
|
137
|
-
- **Type:** {{taskType}}
|
|
138
|
-
- **Priority:** {{taskPriority}}
|
|
139
|
-
- **Status:** {{taskStatus}}
|
|
140
|
-
- **Tags:** {{tagsList}}
|
|
141
|
-
|
|
142
|
-
{{taskFilePathInfo}}
|
|
143
|
-
|
|
144
|
-
#### Description
|
|
145
|
-
|
|
146
|
-
{{taskContent}}
|
|
147
|
-
|
|
148
|
-
`;
|
|
149
|
-
const MERGE_TEMPLATE = `Goal: Merge feature branch into base without pushing to remote. Resolve conflicts safely.
|
|
150
|
-
|
|
151
|
-
Context:
|
|
152
|
-
|
|
153
|
-
- Repo: {{repoPath}}
|
|
154
|
-
- Worktree: {{worktreePath}}
|
|
155
|
-
- Feature branch: {{featureBranch}}
|
|
156
|
-
- Base branch: {{baseBranch}}
|
|
157
|
-
|
|
158
|
-
If conflicts:
|
|
159
|
-
|
|
160
|
-
- Prefer {{featureBranch}} when changes are clearly additive or isolated.
|
|
161
|
-
- Keep {{baseBranch}} when it contains newer logic that would be overwritten.
|
|
162
|
-
- Integrate both sides when needed.
|
|
163
|
-
- After each file: git add <file>
|
|
164
|
-
`;
|
|
165
|
-
const REVIEW_TEMPLATE = `## Code Review Task
|
|
166
|
-
|
|
167
|
-
Review the changes made for this task comprehensively. Return a JSON string with Fenced JSON.
|
|
168
|
-
|
|
169
|
-
1. **Analyze the implemented changes** by examining the modified files, some of them might be committed in the recent commits
|
|
170
|
-
2. **Evaluate code quality** including:
|
|
171
|
-
- Code structure and organization
|
|
172
|
-
- Adherence to coding standards and conventions
|
|
173
|
-
- Error handling and edge cases
|
|
174
|
-
- Performance considerations
|
|
175
|
-
- Security implications
|
|
176
|
-
- Test coverage and quality
|
|
177
|
-
|
|
178
|
-
3. **Verify task completion** by checking that:
|
|
179
|
-
- All acceptance criteria are met
|
|
180
|
-
- Implementation matches the task requirements
|
|
181
|
-
- No unrelated changes were introduced
|
|
182
|
-
|
|
183
|
-
4. **Provide structured feedback** using this JSON structure with following fields:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
"reviewSummary": "Brief overview of the implementation and overall assessment",
|
|
187
|
-
"recommendations": [
|
|
188
|
-
"Specific recommendation 1",
|
|
189
|
-
"Specific recommendation 2",
|
|
190
|
-
"Specific recommendation 3"
|
|
191
|
-
],
|
|
192
|
-
"qualityScore": 85
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
## Review Guidelines
|
|
196
|
-
|
|
197
|
-
- Quality Score: Provide a score from 0-100 (higher is better), below 70 will trigger a re-implementation with your advice.
|
|
198
|
-
- Recommendations: Provide actionable, specific improvements
|
|
199
|
-
- Focus Areas: Security, performance, maintainability, testing, documentation
|
|
200
|
-
- Scoring Rubric (0-100):
|
|
201
|
-
- Correctness & completeness: 0-35
|
|
202
|
-
- Code quality & maintainability: 0-30
|
|
203
|
-
- Testing & coverage: 0-20
|
|
204
|
-
- Security & performance considerations: 0-15
|
|
205
|
-
|
|
206
|
-
If you identify any critical bugs or potential improvements, provide detailed notes, acceptance criteria, implementation details, todo list, etc. in the Recommendations section and return a score below 70. This will trigger a reimplementation based on your feedback.
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## Task Context
|
|
211
|
-
|
|
212
|
-
- **ID:** {{taskId}}
|
|
213
|
-
- **Title:** {{taskTitle}}
|
|
214
|
-
- **Type:** {{taskType}}
|
|
215
|
-
- **Priority:** {{taskPriority}}
|
|
216
|
-
|
|
217
|
-
## Task Description
|
|
218
|
-
|
|
219
|
-
{{taskContent}}
|
|
220
|
-
|
|
221
|
-
## Review Context
|
|
222
|
-
|
|
223
|
-
- **Worktree Path:** {{worktreePath}}
|
|
224
|
-
- **Branch:** {{worktreeBranch}}
|
|
225
|
-
- **Status:** active
|
|
226
|
-
|
|
227
|
-
{{additionalContext}}
|
|
228
|
-
`;
|
|
229
|
-
// Quality checks detection prompt (AI-only, JSON strict)
|
|
230
|
-
const DETECT_QUALITY_CHECKS_TEMPLATE = `You are analyzing a code repository to determine fast, local quality checks.
|
|
231
|
-
|
|
232
|
-
Constraints:
|
|
233
|
-
- Prefer fast checks suitable for local iteration.
|
|
234
|
-
- Only output valid JSON. No prose. No markdown. Do not include comments.
|
|
235
|
-
- Schema: { "checks": [ { "name": string, "command": string, "args": string[], "timeout": number, "enabled": boolean } ] }
|
|
236
|
-
- The unit of timeout is milliseconds.
|
|
237
|
-
- Defaults: enable tests/lint/typecheck if present; set build enabled=false unless explicitly required.
|
|
238
|
-
- Use the working directory tools (glob/grep/read) to discover project configuration.
|
|
239
|
-
|
|
240
|
-
Examples by ecosystem:
|
|
241
|
-
- Node: scripts in package.json (test, lint, typecheck). Use package manager scripts (npm run, pnpm, yarn) if detectable.
|
|
242
|
-
- Python: pytest, ruff, mypy if config present.
|
|
243
|
-
- Rust: cargo check/test/fmt/clippy if available.
|
|
244
|
-
- Go: go test, go vet, golangci-lint if configured.
|
|
245
|
-
- Others: propose similar fast checks when clear; otherwise return an empty list.
|
|
246
|
-
|
|
247
|
-
Return strictly the JSON with the schema above.`;
|
|
248
|
-
// -----------------------------
|
|
249
|
-
// Simple string template engine
|
|
250
|
-
// -----------------------------
|
|
251
|
-
function escapeRegExp(s) {
|
|
252
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
253
|
-
}
|
|
254
|
-
function render(template, vars) {
|
|
255
|
-
let out = template;
|
|
256
|
-
for (const [key, value] of Object.entries(vars)) {
|
|
257
|
-
const re = new RegExp(`{{\\s*${escapeRegExp(key)}\\s*}}`, 'g');
|
|
258
|
-
out = out.replace(re, value ?? '');
|
|
259
|
-
}
|
|
260
|
-
// Remove any unreplaced placeholders
|
|
261
|
-
return out.replace(/{{\s*[^}]+\s*}}/g, '');
|
|
262
|
-
}
|
|
263
|
-
// PromptService centralizes prompt generation logic used by AgentService.
|
|
264
|
-
// Prompts are hard-coded templates for now, with light project context reads.
|
|
265
|
-
export class PromptService {
|
|
266
|
-
constructor(projectRoot, taskService) {
|
|
267
|
-
this.projectRoot = projectRoot;
|
|
268
|
-
this.taskService = taskService;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Generate absolute path to task file
|
|
272
|
-
*/
|
|
273
|
-
generateTaskFilePath(taskId) {
|
|
274
|
-
try {
|
|
275
|
-
const vibeDir = getVibeDir();
|
|
276
|
-
const taskFilePath = path.resolve(vibeDir, 'tasks', `${taskId}.md`);
|
|
277
|
-
return taskFilePath;
|
|
278
|
-
}
|
|
279
|
-
catch (error) {
|
|
280
|
-
log.error(`Failed to generate task file path for ${taskId}`, error, 'prompt-service');
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Validate that task file exists at the given path
|
|
286
|
-
*/
|
|
287
|
-
async validateTaskFile(filePath) {
|
|
288
|
-
try {
|
|
289
|
-
await fs.access(filePath, fs.constants.F_OK);
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
292
|
-
catch {
|
|
293
|
-
return false;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
async generateImprovementPrompt(task, taskData) {
|
|
297
|
-
// Read project context
|
|
298
|
-
const productOverviewPath = path.join(getVibeDir(), 'product_overview.md');
|
|
299
|
-
let productContext = '';
|
|
300
|
-
try {
|
|
301
|
-
productContext = await fs.readFile(productOverviewPath, 'utf-8');
|
|
302
|
-
}
|
|
303
|
-
catch {
|
|
304
|
-
log.warn('Could not read product_overview.md for improvement prompt', undefined, 'prompt-service');
|
|
305
|
-
}
|
|
306
|
-
// Add task file path to project context for improvement prompts
|
|
307
|
-
const taskFilePath = this.generateTaskFilePath(task.id);
|
|
308
|
-
if (taskFilePath && (await this.validateTaskFile(taskFilePath))) {
|
|
309
|
-
productContext += `\n\n**Current task file location:** ${taskFilePath}`;
|
|
310
|
-
log.info(`Task file path included in improvement prompt`, { taskId: task.id, path: taskFilePath }, 'prompt-service');
|
|
311
|
-
}
|
|
312
|
-
return render(IMPROVEMENT_TEMPLATE, {
|
|
313
|
-
projectContext: productContext,
|
|
314
|
-
taskId: task.id,
|
|
315
|
-
taskTitle: taskData.title,
|
|
316
|
-
taskType: taskData.type,
|
|
317
|
-
taskPriority: taskData.priority,
|
|
318
|
-
taskStatus: task.status,
|
|
319
|
-
taskContent: taskData.content,
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
async generateTaskPrompt(task, workflowConfig) {
|
|
323
|
-
const tagsList = task.tags.join(', ');
|
|
324
|
-
// Generate and validate task file path
|
|
325
|
-
const taskFilePath = this.generateTaskFilePath(task.id);
|
|
326
|
-
let taskFilePathInfo = '';
|
|
327
|
-
if (taskFilePath) {
|
|
328
|
-
const isValid = await this.validateTaskFile(taskFilePath);
|
|
329
|
-
if (isValid) {
|
|
330
|
-
taskFilePathInfo = `- **Current task file:** ${taskFilePath}`;
|
|
331
|
-
log.info(`Task file path included in prompt`, { taskId: task.id, path: taskFilePath }, 'prompt-service');
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
taskFilePathInfo = `- **Task file:** (not accessible at expected path: ${taskFilePath})`;
|
|
335
|
-
log.warn(`Task file not accessible`, { taskId: task.id, path: taskFilePath }, 'prompt-service');
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
else {
|
|
339
|
-
taskFilePathInfo = `- **Task file:** (path could not be resolved)`;
|
|
340
|
-
log.error(`Could not generate task file path`, { taskId: task.id }, 'prompt-service');
|
|
341
|
-
}
|
|
342
|
-
// Build workflow instruction prompts based on workflow configuration
|
|
343
|
-
const workflowInstructions = this.buildWorkflowInstructions(workflowConfig);
|
|
344
|
-
return render(TASK_TEMPLATE, {
|
|
345
|
-
taskId: task.id,
|
|
346
|
-
taskTitle: task.title,
|
|
347
|
-
taskType: task.type,
|
|
348
|
-
taskPriority: task.priority,
|
|
349
|
-
taskStatus: task.status,
|
|
350
|
-
taskContent: task.content,
|
|
351
|
-
tagsList,
|
|
352
|
-
taskFilePathInfo,
|
|
353
|
-
workflowInstructions,
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Build a prominent, clearly formatted instruction section derived from workflow options.
|
|
358
|
-
* If no options are provided or none apply, returns a minimal guidance line.
|
|
359
|
-
*/
|
|
360
|
-
buildWorkflowInstructions(cfg) {
|
|
361
|
-
const lines = [];
|
|
362
|
-
if (!cfg) {
|
|
363
|
-
// Default lightweight guidance when workflow config is unavailable
|
|
364
|
-
return '- Follow project conventions and ask before destructive actions.';
|
|
365
|
-
}
|
|
366
|
-
// Auto Commit disabled prompt
|
|
367
|
-
if (cfg.autoCommit === false) {
|
|
368
|
-
lines.push('IMPORTANT: AUTO COMMIT IS DISABLED');
|
|
369
|
-
lines.push('- DO NOT commit any changes');
|
|
370
|
-
lines.push('- DO NOT run git commit commands');
|
|
371
|
-
lines.push('- Leave all changes staged for manual review');
|
|
372
|
-
lines.push('');
|
|
373
|
-
}
|
|
374
|
-
// PR creation disabled prompt
|
|
375
|
-
if (cfg.createPR === false) {
|
|
376
|
-
lines.push('IMPORTANT: PR CREATION IS DISABLED');
|
|
377
|
-
lines.push('- DO NOT create pull requests');
|
|
378
|
-
lines.push('- DO NOT run gh pr create commands');
|
|
379
|
-
lines.push('- Prepare changes for manual PR creation');
|
|
380
|
-
lines.push('');
|
|
381
|
-
}
|
|
382
|
-
// Auto merge disabled prompt
|
|
383
|
-
if (cfg.autoMerge === false) {
|
|
384
|
-
lines.push('IMPORTANT: AUTO MERGE IS DISABLED');
|
|
385
|
-
lines.push('- DO NOT merge pull requests automatically');
|
|
386
|
-
lines.push('- DO NOT run git merge commands');
|
|
387
|
-
lines.push('- Prepare changes for manual merge approval');
|
|
388
|
-
lines.push('');
|
|
389
|
-
}
|
|
390
|
-
// If nothing matched, provide a simple fallback
|
|
391
|
-
if (lines.length === 0) {
|
|
392
|
-
return '- No special workflow constraints. Proceed with standard process.';
|
|
393
|
-
}
|
|
394
|
-
return lines.join('\n');
|
|
395
|
-
}
|
|
396
|
-
async generateAIMergePrompt(task, worktree, baseBranch) {
|
|
397
|
-
const repoPath = this.projectRoot;
|
|
398
|
-
const featureBr = worktree.branchName;
|
|
399
|
-
// Determine base branch: prefer provided, otherwise current branch in repo root, fallback to 'main'
|
|
400
|
-
let baseBr = baseBranch?.trim();
|
|
401
|
-
if (!baseBr) {
|
|
402
|
-
try {
|
|
403
|
-
const { spawn } = await import('child_process');
|
|
404
|
-
baseBr = await new Promise((resolve, reject) => {
|
|
405
|
-
const child = spawn('git', ['branch', '--show-current'], {
|
|
406
|
-
cwd: repoPath,
|
|
407
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
408
|
-
});
|
|
409
|
-
let out = '';
|
|
410
|
-
child.stdout?.on('data', (d) => (out += d.toString()));
|
|
411
|
-
child.on('close', () => resolve(out.trim() || 'main'));
|
|
412
|
-
child.on('error', reject);
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
catch {
|
|
416
|
-
baseBr = 'main';
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
return render(MERGE_TEMPLATE, {
|
|
420
|
-
repoPath,
|
|
421
|
-
worktreePath: worktree.path,
|
|
422
|
-
featureBranch: featureBr,
|
|
423
|
-
baseBranch: baseBr,
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
async generateReviewPrompt(task, worktree, reviewContext) {
|
|
427
|
-
let additionalContext = reviewContext ? `\n**Additional Context:** ${reviewContext}` : '';
|
|
428
|
-
// Add task file path to additional context
|
|
429
|
-
const taskFilePath = this.generateTaskFilePath(task.id);
|
|
430
|
-
if (taskFilePath && (await this.validateTaskFile(taskFilePath))) {
|
|
431
|
-
additionalContext += `\n**Current task file:** ${taskFilePath}`;
|
|
432
|
-
log.info(`Task file path included in review prompt`, { taskId: task.id, path: taskFilePath }, 'prompt-service');
|
|
433
|
-
}
|
|
434
|
-
return render(REVIEW_TEMPLATE, {
|
|
435
|
-
taskId: task.id,
|
|
436
|
-
taskTitle: task.title,
|
|
437
|
-
taskType: task.type,
|
|
438
|
-
taskPriority: task.priority,
|
|
439
|
-
taskContent: task.content,
|
|
440
|
-
worktreePath: worktree.path,
|
|
441
|
-
worktreeBranch: worktree.branchName,
|
|
442
|
-
additionalContext,
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
// Utility export for building the quality checks detection prompt
|
|
447
|
-
export function getQualityChecksDetectionPrompt() {
|
|
448
|
-
return DETECT_QUALITY_CHECKS_TEMPLATE;
|
|
449
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
2
|
-
import { promises as fs } from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { PromptService } from './prompt-service.js';
|
|
5
|
-
const TEST_DATA_DIR = path.resolve(process.cwd(), '.test-prompt-service');
|
|
6
|
-
const TEST_TASKS_DIR = path.join(TEST_DATA_DIR, 'tasks');
|
|
7
|
-
// Mock getVibeDir to return test directory
|
|
8
|
-
vi.mock('../lib/server/project-root', () => ({
|
|
9
|
-
getVibeDir: () => TEST_DATA_DIR,
|
|
10
|
-
getProjectRoot: () => TEST_DATA_DIR,
|
|
11
|
-
}));
|
|
12
|
-
// Mock TaskService
|
|
13
|
-
const mockTaskService = {
|
|
14
|
-
getTask: vi.fn(),
|
|
15
|
-
getAllTasks: vi.fn(),
|
|
16
|
-
};
|
|
17
|
-
describe('PromptService Task File Path Integration', () => {
|
|
18
|
-
let promptService;
|
|
19
|
-
beforeEach(async () => {
|
|
20
|
-
promptService = new PromptService(TEST_DATA_DIR, mockTaskService);
|
|
21
|
-
// Create test directories
|
|
22
|
-
await fs.mkdir(TEST_TASKS_DIR, { recursive: true });
|
|
23
|
-
});
|
|
24
|
-
afterEach(async () => {
|
|
25
|
-
// Clean up test data
|
|
26
|
-
try {
|
|
27
|
-
await fs.rm(TEST_DATA_DIR, { recursive: true, force: true });
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
// Ignore cleanup errors
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
describe('generateTaskPrompt', () => {
|
|
34
|
-
it('should include absolute path when task file exists', async () => {
|
|
35
|
-
const mockTask = {
|
|
36
|
-
id: 'TEST-TASK-001',
|
|
37
|
-
title: 'Test Task',
|
|
38
|
-
type: 'feature',
|
|
39
|
-
status: 'in-progress',
|
|
40
|
-
priority: 'high',
|
|
41
|
-
tags: ['test'],
|
|
42
|
-
content: 'Test task content',
|
|
43
|
-
created_at: '2024-09-04T12:00:00.000Z',
|
|
44
|
-
updated_at: '2024-09-04T12:00:00.000Z',
|
|
45
|
-
assignee: [],
|
|
46
|
-
comments: [],
|
|
47
|
-
};
|
|
48
|
-
// Create task file
|
|
49
|
-
const taskFilePath = path.join(TEST_TASKS_DIR, 'TEST-TASK-001.md');
|
|
50
|
-
const taskFileContent = `---
|
|
51
|
-
id: TEST-TASK-001
|
|
52
|
-
title: Test Task
|
|
53
|
-
type: feature
|
|
54
|
-
status: in-progress
|
|
55
|
-
priority: high
|
|
56
|
-
tags: test
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
Test task content`;
|
|
60
|
-
await fs.writeFile(taskFilePath, taskFileContent, 'utf-8');
|
|
61
|
-
const prompt = await promptService.generateTaskPrompt(mockTask);
|
|
62
|
-
expect(prompt).toContain('Current task file:');
|
|
63
|
-
expect(prompt).toContain(taskFilePath);
|
|
64
|
-
expect(prompt).toContain('TEST-TASK-001');
|
|
65
|
-
expect(prompt).toContain('Test Task');
|
|
66
|
-
expect(prompt).toContain('Test task content');
|
|
67
|
-
});
|
|
68
|
-
it('should handle missing task file gracefully', async () => {
|
|
69
|
-
const mockTask = {
|
|
70
|
-
id: 'NONEXISTENT-TASK',
|
|
71
|
-
title: 'Nonexistent Task',
|
|
72
|
-
type: 'bug',
|
|
73
|
-
status: 'backlog',
|
|
74
|
-
priority: 'medium',
|
|
75
|
-
tags: [],
|
|
76
|
-
content: 'This task file does not exist',
|
|
77
|
-
created_at: '2024-09-04T12:00:00.000Z',
|
|
78
|
-
updated_at: '2024-09-04T12:00:00.000Z',
|
|
79
|
-
assignee: [],
|
|
80
|
-
comments: [],
|
|
81
|
-
};
|
|
82
|
-
const prompt = await promptService.generateTaskPrompt(mockTask);
|
|
83
|
-
expect(prompt).toContain('not accessible at expected path');
|
|
84
|
-
expect(prompt).toContain('NONEXISTENT-TASK.md');
|
|
85
|
-
expect(prompt).toContain('Nonexistent Task');
|
|
86
|
-
expect(prompt).toContain('This task file does not exist');
|
|
87
|
-
});
|
|
88
|
-
it('should handle path resolution errors', async () => {
|
|
89
|
-
// Mock generateTaskFilePath to return null (simulating path resolution error)
|
|
90
|
-
const originalGenerateTaskFilePath = promptService.generateTaskFilePath;
|
|
91
|
-
promptService.generateTaskFilePath = vi.fn().mockReturnValue(null);
|
|
92
|
-
const mockTask = {
|
|
93
|
-
id: 'ERROR-TASK',
|
|
94
|
-
title: 'Error Task',
|
|
95
|
-
type: 'chore',
|
|
96
|
-
status: 'review',
|
|
97
|
-
priority: 'low',
|
|
98
|
-
tags: ['error'],
|
|
99
|
-
content: 'Task with path resolution error',
|
|
100
|
-
created_at: '2024-09-04T12:00:00.000Z',
|
|
101
|
-
updated_at: '2024-09-04T12:00:00.000Z',
|
|
102
|
-
assignee: [],
|
|
103
|
-
comments: [],
|
|
104
|
-
};
|
|
105
|
-
const prompt = await promptService.generateTaskPrompt(mockTask);
|
|
106
|
-
expect(prompt).toContain('path could not be resolved');
|
|
107
|
-
expect(prompt).toContain('ERROR-TASK');
|
|
108
|
-
expect(prompt).toContain('Task with path resolution error');
|
|
109
|
-
// Restore original method
|
|
110
|
-
promptService.generateTaskFilePath = originalGenerateTaskFilePath;
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
describe('generateImprovementPrompt', () => {
|
|
114
|
-
it('should include task file path in project context', async () => {
|
|
115
|
-
const mockTask = {
|
|
116
|
-
id: 'IMPROVE-TASK-001',
|
|
117
|
-
title: 'Improvement Task',
|
|
118
|
-
type: 'feature',
|
|
119
|
-
status: 'backlog',
|
|
120
|
-
priority: 'medium',
|
|
121
|
-
tags: [],
|
|
122
|
-
content: 'Original content',
|
|
123
|
-
created_at: '2024-09-04T12:00:00.000Z',
|
|
124
|
-
updated_at: '2024-09-04T12:00:00.000Z',
|
|
125
|
-
assignee: [],
|
|
126
|
-
comments: [],
|
|
127
|
-
};
|
|
128
|
-
const taskData = {
|
|
129
|
-
title: 'Improved Task',
|
|
130
|
-
type: 'feature',
|
|
131
|
-
priority: 'high',
|
|
132
|
-
content: 'Improved content',
|
|
133
|
-
};
|
|
134
|
-
// Create task file
|
|
135
|
-
const taskFilePath = path.join(TEST_TASKS_DIR, 'IMPROVE-TASK-001.md');
|
|
136
|
-
await fs.writeFile(taskFilePath, 'Task file content', 'utf-8');
|
|
137
|
-
const prompt = await promptService.generateImprovementPrompt(mockTask, taskData);
|
|
138
|
-
expect(prompt).toContain('Current task file location:');
|
|
139
|
-
expect(prompt).toContain(taskFilePath);
|
|
140
|
-
expect(prompt).toContain('IMPROVE-TASK-001');
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
describe('generateReviewPrompt', () => {
|
|
144
|
-
it('should include task file path in additional context', async () => {
|
|
145
|
-
const mockTask = {
|
|
146
|
-
id: 'REVIEW-TASK-001',
|
|
147
|
-
title: 'Review Task',
|
|
148
|
-
type: 'bug',
|
|
149
|
-
status: 'review',
|
|
150
|
-
priority: 'high',
|
|
151
|
-
tags: [],
|
|
152
|
-
content: 'Task under review',
|
|
153
|
-
created_at: '2024-09-04T12:00:00.000Z',
|
|
154
|
-
updated_at: '2024-09-04T12:00:00.000Z',
|
|
155
|
-
assignee: [],
|
|
156
|
-
comments: [],
|
|
157
|
-
};
|
|
158
|
-
const mockWorktree = {
|
|
159
|
-
taskId: 'REVIEW-TASK-001',
|
|
160
|
-
path: '/test/worktree',
|
|
161
|
-
branchName: 'feature/review-task-001',
|
|
162
|
-
};
|
|
163
|
-
// Create task file
|
|
164
|
-
const taskFilePath = path.join(TEST_TASKS_DIR, 'REVIEW-TASK-001.md');
|
|
165
|
-
await fs.writeFile(taskFilePath, 'Review task content', 'utf-8');
|
|
166
|
-
const prompt = await promptService.generateReviewPrompt(mockTask, mockWorktree, 'Custom review context');
|
|
167
|
-
expect(prompt).toContain('Current task file:');
|
|
168
|
-
expect(prompt).toContain(taskFilePath);
|
|
169
|
-
expect(prompt).toContain('Custom review context');
|
|
170
|
-
expect(prompt).toContain('REVIEW-TASK-001');
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
describe('cross-platform path resolution', () => {
|
|
174
|
-
it('should generate valid absolute paths on different platforms', async () => {
|
|
175
|
-
const taskId = 'CROSS-PLATFORM-TEST';
|
|
176
|
-
// Test the private method through a task prompt generation
|
|
177
|
-
const mockTask = {
|
|
178
|
-
id: taskId,
|
|
179
|
-
title: 'Cross Platform Test',
|
|
180
|
-
type: 'test',
|
|
181
|
-
status: 'in-progress',
|
|
182
|
-
priority: 'medium',
|
|
183
|
-
tags: [],
|
|
184
|
-
content: 'Cross platform path test',
|
|
185
|
-
created_at: '2024-09-04T12:00:00.000Z',
|
|
186
|
-
updated_at: '2024-09-04T12:00:00.000Z',
|
|
187
|
-
assignee: [],
|
|
188
|
-
comments: [],
|
|
189
|
-
};
|
|
190
|
-
// Create task file
|
|
191
|
-
const taskFilePath = path.join(TEST_TASKS_DIR, `${taskId}.md`);
|
|
192
|
-
await fs.writeFile(taskFilePath, 'Cross platform test content', 'utf-8');
|
|
193
|
-
const prompt = await promptService.generateTaskPrompt(mockTask);
|
|
194
|
-
// Verify the path is absolute and uses correct separators
|
|
195
|
-
const pathMatch = prompt.match(/- \*\*Current task file:\*\* (.+)/);
|
|
196
|
-
expect(pathMatch).toBeTruthy();
|
|
197
|
-
if (pathMatch) {
|
|
198
|
-
const extractedPath = pathMatch[1];
|
|
199
|
-
expect(path.isAbsolute(extractedPath)).toBe(true);
|
|
200
|
-
expect(extractedPath).toContain(taskId);
|
|
201
|
-
expect(extractedPath.endsWith('.md')).toBe(true);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
describe('error handling', () => {
|
|
206
|
-
it('should handle file system permission errors gracefully', async () => {
|
|
207
|
-
const mockTask = {
|
|
208
|
-
id: 'PERMISSION-TEST',
|
|
209
|
-
title: 'Permission Test',
|
|
210
|
-
type: 'chore',
|
|
211
|
-
status: 'backlog',
|
|
212
|
-
priority: 'low',
|
|
213
|
-
tags: [],
|
|
214
|
-
content: 'Permission test content',
|
|
215
|
-
created_at: '2024-09-04T12:00:00.000Z',
|
|
216
|
-
updated_at: '2024-09-04T12:00:00.000Z',
|
|
217
|
-
assignee: [],
|
|
218
|
-
comments: [],
|
|
219
|
-
};
|
|
220
|
-
// Mock validateTaskFile to simulate permission error
|
|
221
|
-
const originalValidateTaskFile = promptService.validateTaskFile;
|
|
222
|
-
promptService.validateTaskFile = vi.fn().mockResolvedValueOnce(false);
|
|
223
|
-
const prompt = await promptService.generateTaskPrompt(mockTask);
|
|
224
|
-
expect(prompt).toContain('not accessible at expected path');
|
|
225
|
-
expect(prompt).toContain('PERMISSION-TEST');
|
|
226
|
-
// Restore original function
|
|
227
|
-
promptService.validateTaskFile = originalValidateTaskFile;
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|