vibeman 0.0.0 → 0.0.1

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.
Files changed (220) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +116 -0
  3. package/dist/runtime/api/.tsbuildinfo +1 -0
  4. package/dist/runtime/api/agent/agent-service.d.ts +226 -0
  5. package/dist/runtime/api/agent/agent-service.js +901 -0
  6. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.d.ts +61 -0
  7. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.js +373 -0
  8. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.d.ts +34 -0
  9. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.js +281 -0
  10. package/dist/runtime/api/agent/ai-providers/index.d.ts +9 -0
  11. package/dist/runtime/api/agent/ai-providers/index.js +7 -0
  12. package/dist/runtime/api/agent/ai-providers/types.d.ts +180 -0
  13. package/dist/runtime/api/agent/ai-providers/types.js +5 -0
  14. package/dist/runtime/api/agent/codex-cli-provider.test.d.ts +1 -0
  15. package/dist/runtime/api/agent/codex-cli-provider.test.js +88 -0
  16. package/dist/runtime/api/agent/core-agent-service.d.ts +119 -0
  17. package/dist/runtime/api/agent/core-agent-service.js +267 -0
  18. package/dist/runtime/api/agent/parsers.d.ts +15 -0
  19. package/dist/runtime/api/agent/parsers.js +241 -0
  20. package/dist/runtime/api/agent/prompt-service.d.ts +17 -0
  21. package/dist/runtime/api/agent/prompt-service.js +340 -0
  22. package/dist/runtime/api/agent/routing-policy.d.ts +188 -0
  23. package/dist/runtime/api/agent/routing-policy.js +246 -0
  24. package/dist/runtime/api/api/router-helpers.d.ts +32 -0
  25. package/dist/runtime/api/api/router-helpers.js +31 -0
  26. package/dist/runtime/api/api/routers/ai.d.ts +188 -0
  27. package/dist/runtime/api/api/routers/ai.js +410 -0
  28. package/dist/runtime/api/api/routers/executions.d.ts +98 -0
  29. package/dist/runtime/api/api/routers/executions.js +103 -0
  30. package/dist/runtime/api/api/routers/git.d.ts +45 -0
  31. package/dist/runtime/api/api/routers/git.js +35 -0
  32. package/dist/runtime/api/api/routers/settings.d.ts +139 -0
  33. package/dist/runtime/api/api/routers/settings.js +113 -0
  34. package/dist/runtime/api/api/routers/tasks.d.ts +141 -0
  35. package/dist/runtime/api/api/routers/tasks.js +238 -0
  36. package/dist/runtime/api/api/routers/workflows.d.ts +268 -0
  37. package/dist/runtime/api/api/routers/workflows.js +308 -0
  38. package/dist/runtime/api/api/routers/worktrees.d.ts +102 -0
  39. package/dist/runtime/api/api/routers/worktrees.js +80 -0
  40. package/dist/runtime/api/api/trpc.d.ts +118 -0
  41. package/dist/runtime/api/api/trpc.js +34 -0
  42. package/dist/runtime/api/index.d.ts +9 -0
  43. package/dist/runtime/api/index.js +125 -0
  44. package/dist/runtime/api/lib/id-generator.d.ts +70 -0
  45. package/dist/runtime/api/lib/id-generator.js +123 -0
  46. package/dist/runtime/api/lib/image-paste-drop-extension.d.ts +26 -0
  47. package/dist/runtime/api/lib/image-paste-drop-extension.js +125 -0
  48. package/dist/runtime/api/lib/logger.d.ts +11 -0
  49. package/dist/runtime/api/lib/logger.js +188 -0
  50. package/dist/runtime/api/lib/markdown-utils.d.ts +8 -0
  51. package/dist/runtime/api/lib/markdown-utils.js +282 -0
  52. package/dist/runtime/api/lib/markdown-utils.test.d.ts +1 -0
  53. package/dist/runtime/api/lib/markdown-utils.test.js +348 -0
  54. package/dist/runtime/api/lib/server/agent-service-singleton.d.ts +6 -0
  55. package/dist/runtime/api/lib/server/agent-service-singleton.js +27 -0
  56. package/dist/runtime/api/lib/server/git-service-singleton.d.ts +6 -0
  57. package/dist/runtime/api/lib/server/git-service-singleton.js +47 -0
  58. package/dist/runtime/api/lib/server/project-root.d.ts +2 -0
  59. package/dist/runtime/api/lib/server/project-root.js +38 -0
  60. package/dist/runtime/api/lib/server/task-service-singleton.d.ts +7 -0
  61. package/dist/runtime/api/lib/server/task-service-singleton.js +58 -0
  62. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.d.ts +7 -0
  63. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.js +57 -0
  64. package/dist/runtime/api/lib/tiptap-utils.clamp-selection.test.d.ts +1 -0
  65. package/dist/runtime/api/lib/tiptap-utils.clamp-selection.test.js +27 -0
  66. package/dist/runtime/api/lib/tiptap-utils.d.ts +130 -0
  67. package/dist/runtime/api/lib/tiptap-utils.js +327 -0
  68. package/dist/runtime/api/lib/trpc/client.d.ts +1 -0
  69. package/dist/runtime/api/lib/trpc/client.js +5 -0
  70. package/dist/runtime/api/lib/trpc/server.d.ts +822 -0
  71. package/dist/runtime/api/lib/trpc/server.js +11 -0
  72. package/dist/runtime/api/lib/trpc/ws-server.d.ts +8 -0
  73. package/dist/runtime/api/lib/trpc/ws-server.js +33 -0
  74. package/dist/runtime/api/persistence/database-service.d.ts +14 -0
  75. package/dist/runtime/api/persistence/database-service.js +74 -0
  76. package/dist/runtime/api/persistence/execution-log-persistence.d.ts +90 -0
  77. package/dist/runtime/api/persistence/execution-log-persistence.js +410 -0
  78. package/dist/runtime/api/persistence/execution-log-persistence.test.d.ts +1 -0
  79. package/dist/runtime/api/persistence/execution-log-persistence.test.js +170 -0
  80. package/dist/runtime/api/router.d.ts +825 -0
  81. package/dist/runtime/api/router.js +56 -0
  82. package/dist/runtime/api/settings-service.d.ts +110 -0
  83. package/dist/runtime/api/settings-service.js +611 -0
  84. package/dist/runtime/api/tasks/file-watcher.d.ts +23 -0
  85. package/dist/runtime/api/tasks/file-watcher.js +88 -0
  86. package/dist/runtime/api/tasks/task-file-parser.d.ts +13 -0
  87. package/dist/runtime/api/tasks/task-file-parser.js +161 -0
  88. package/dist/runtime/api/tasks/task-service.d.ts +36 -0
  89. package/dist/runtime/api/tasks/task-service.js +173 -0
  90. package/dist/runtime/api/types/index.d.ts +179 -0
  91. package/dist/runtime/api/types/index.js +1 -0
  92. package/dist/runtime/api/types/settings.d.ts +81 -0
  93. package/dist/runtime/api/types/settings.js +2 -0
  94. package/dist/runtime/api/types.d.ts +2 -0
  95. package/dist/runtime/api/types.js +1 -0
  96. package/dist/runtime/api/utils/env.d.ts +6 -0
  97. package/dist/runtime/api/utils/env.js +12 -0
  98. package/dist/runtime/api/utils/stripNextEnv.d.ts +7 -0
  99. package/dist/runtime/api/utils/stripNextEnv.js +22 -0
  100. package/dist/runtime/api/utils/title-slug.d.ts +6 -0
  101. package/dist/runtime/api/utils/title-slug.js +77 -0
  102. package/dist/runtime/api/utils/url.d.ts +2 -0
  103. package/dist/runtime/api/utils/url.js +19 -0
  104. package/dist/runtime/api/vcs/git-history-service.d.ts +57 -0
  105. package/dist/runtime/api/vcs/git-history-service.js +228 -0
  106. package/dist/runtime/api/vcs/git-service.d.ts +127 -0
  107. package/dist/runtime/api/vcs/git-service.js +284 -0
  108. package/dist/runtime/api/vcs/worktree-service.d.ts +93 -0
  109. package/dist/runtime/api/vcs/worktree-service.js +506 -0
  110. package/dist/runtime/api/vcs/worktree-service.test.d.ts +1 -0
  111. package/dist/runtime/api/vcs/worktree-service.test.js +20 -0
  112. package/dist/runtime/api/workflows/quality-pipeline.d.ts +58 -0
  113. package/dist/runtime/api/workflows/quality-pipeline.js +400 -0
  114. package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +313 -0
  115. package/dist/runtime/api/workflows/vibing-orchestrator.js +1861 -0
  116. package/dist/runtime/web/.next/BUILD_ID +1 -0
  117. package/dist/runtime/web/.next/app-build-manifest.json +59 -0
  118. package/dist/runtime/web/.next/app-path-routes-manifest.json +7 -0
  119. package/dist/runtime/web/.next/build-manifest.json +33 -0
  120. package/dist/runtime/web/.next/package.json +1 -0
  121. package/dist/runtime/web/.next/prerender-manifest.json +61 -0
  122. package/dist/runtime/web/.next/react-loadable-manifest.json +39 -0
  123. package/dist/runtime/web/.next/required-server-files.json +334 -0
  124. package/dist/runtime/web/.next/routes-manifest.json +62 -0
  125. package/dist/runtime/web/.next/server/app/_not-found/page.js +2 -0
  126. package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +1 -0
  127. package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
  128. package/dist/runtime/web/.next/server/app/_not-found.html +7 -0
  129. package/dist/runtime/web/.next/server/app/_not-found.meta +8 -0
  130. package/dist/runtime/web/.next/server/app/_not-found.rsc +22 -0
  131. package/dist/runtime/web/.next/server/app/api/health/route.js +1 -0
  132. package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +1 -0
  133. package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +1 -0
  134. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +1 -0
  135. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +1 -0
  136. package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +1 -0
  137. package/dist/runtime/web/.next/server/app/api/upload/route.js +1 -0
  138. package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +1 -0
  139. package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +1 -0
  140. package/dist/runtime/web/.next/server/app/index.html +7 -0
  141. package/dist/runtime/web/.next/server/app/index.meta +7 -0
  142. package/dist/runtime/web/.next/server/app/index.rsc +27 -0
  143. package/dist/runtime/web/.next/server/app/page.js +147 -0
  144. package/dist/runtime/web/.next/server/app/page.js.nft.json +1 -0
  145. package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +1 -0
  146. package/dist/runtime/web/.next/server/app-paths-manifest.json +7 -0
  147. package/dist/runtime/web/.next/server/chunks/217.js +1 -0
  148. package/dist/runtime/web/.next/server/chunks/383.js +6 -0
  149. package/dist/runtime/web/.next/server/chunks/458.js +1 -0
  150. package/dist/runtime/web/.next/server/chunks/576.js +18 -0
  151. package/dist/runtime/web/.next/server/chunks/635.js +22 -0
  152. package/dist/runtime/web/.next/server/chunks/761.js +1 -0
  153. package/dist/runtime/web/.next/server/chunks/777.js +3 -0
  154. package/dist/runtime/web/.next/server/chunks/825.js +1 -0
  155. package/dist/runtime/web/.next/server/chunks/838.js +1 -0
  156. package/dist/runtime/web/.next/server/chunks/973.js +15 -0
  157. package/dist/runtime/web/.next/server/functions-config-manifest.json +4 -0
  158. package/dist/runtime/web/.next/server/middleware-build-manifest.js +1 -0
  159. package/dist/runtime/web/.next/server/middleware-manifest.json +6 -0
  160. package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +1 -0
  161. package/dist/runtime/web/.next/server/next-font-manifest.js +1 -0
  162. package/dist/runtime/web/.next/server/next-font-manifest.json +1 -0
  163. package/dist/runtime/web/.next/server/pages/404.html +7 -0
  164. package/dist/runtime/web/.next/server/pages/500.html +1 -0
  165. package/dist/runtime/web/.next/server/pages/_app.js +1 -0
  166. package/dist/runtime/web/.next/server/pages/_app.js.nft.json +1 -0
  167. package/dist/runtime/web/.next/server/pages/_document.js +1 -0
  168. package/dist/runtime/web/.next/server/pages/_document.js.nft.json +1 -0
  169. package/dist/runtime/web/.next/server/pages/_error.js +19 -0
  170. package/dist/runtime/web/.next/server/pages/_error.js.nft.json +1 -0
  171. package/dist/runtime/web/.next/server/pages-manifest.json +6 -0
  172. package/dist/runtime/web/.next/server/server-reference-manifest.js +1 -0
  173. package/dist/runtime/web/.next/server/server-reference-manifest.json +1 -0
  174. package/dist/runtime/web/.next/server/webpack-runtime.js +1 -0
  175. package/dist/runtime/web/.next/static/1HR8N0rJkCvFRtbTPJMyH/_buildManifest.js +1 -0
  176. package/dist/runtime/web/.next/static/1HR8N0rJkCvFRtbTPJMyH/_ssgManifest.js +1 -0
  177. package/dist/runtime/web/.next/static/chunks/18-15c10d3288afef2e.js +1 -0
  178. package/dist/runtime/web/.next/static/chunks/1c0ca389.537bbe362e3ffbd9.js +3 -0
  179. package/dist/runtime/web/.next/static/chunks/22747d63-ad5da0c19f4cfe41.js +71 -0
  180. package/dist/runtime/web/.next/static/chunks/277-0142a939f08738c3.js +63 -0
  181. package/dist/runtime/web/.next/static/chunks/355.056c2645878a799a.js +1 -0
  182. package/dist/runtime/web/.next/static/chunks/420.a5ccf151c9e2b2f1.js +1 -0
  183. package/dist/runtime/web/.next/static/chunks/439.1be0c6242fd248d5.js +15 -0
  184. package/dist/runtime/web/.next/static/chunks/440.c52e7c0f797e22b2.js +1 -0
  185. package/dist/runtime/web/.next/static/chunks/575-e2478287c27da87b.js +1 -0
  186. package/dist/runtime/web/.next/static/chunks/691.920d88c115087314.js +1 -0
  187. package/dist/runtime/web/.next/static/chunks/765-e838910065b50c3d.js +1 -0
  188. package/dist/runtime/web/.next/static/chunks/87c73c54-09e1ba5c70e60a51.js +1 -0
  189. package/dist/runtime/web/.next/static/chunks/891cff7f.0f71fc028f87e683.js +1 -0
  190. package/dist/runtime/web/.next/static/chunks/8bb4d8db-3e2aa02b0a2384b9.js +1 -0
  191. package/dist/runtime/web/.next/static/chunks/9af238c7-271a911d4e99ab18.js +1 -0
  192. package/dist/runtime/web/.next/static/chunks/app/_not-found/page-1cb74d1cba27d0ab.js +1 -0
  193. package/dist/runtime/web/.next/static/chunks/app/api/health/route-105a61ae865ba536.js +1 -0
  194. package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-105a61ae865ba536.js +1 -0
  195. package/dist/runtime/web/.next/static/chunks/app/api/upload/route-105a61ae865ba536.js +1 -0
  196. package/dist/runtime/web/.next/static/chunks/app/layout-dc0cfd29075b2160.js +1 -0
  197. package/dist/runtime/web/.next/static/chunks/app/page-f34a8b196b18850b.js +1 -0
  198. package/dist/runtime/web/.next/static/chunks/cac567b0-5b77dd12911823cd.js +1 -0
  199. package/dist/runtime/web/.next/static/chunks/framework-2518f1345b5b2806.js +1 -0
  200. package/dist/runtime/web/.next/static/chunks/main-17665e5e39de9a8a.js +1 -0
  201. package/dist/runtime/web/.next/static/chunks/main-app-c0b0f5ba4f7f9d75.js +1 -0
  202. package/dist/runtime/web/.next/static/chunks/pages/_app-d6f6b3bbc3d81ee1.js +1 -0
  203. package/dist/runtime/web/.next/static/chunks/pages/_error-75a96cf1997cc3b9.js +1 -0
  204. package/dist/runtime/web/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  205. package/dist/runtime/web/.next/static/chunks/webpack-c8de37305b4635cf.js +1 -0
  206. package/dist/runtime/web/.next/static/css/08c950681f1a9a92.css +1 -0
  207. package/dist/runtime/web/.next/static/css/2728291c68f99cb1.css +3 -0
  208. package/dist/runtime/web/.next/static/css/521bd69cc298cd1a.css +1 -0
  209. package/dist/runtime/web/.next/static/css/537e22821e101b87.css +1 -0
  210. package/dist/runtime/web/.next/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
  211. package/dist/runtime/web/.next/static/media/21350d82a1f187e9-s.woff2 +0 -0
  212. package/dist/runtime/web/.next/static/media/8e9860b6e62d6359-s.woff2 +0 -0
  213. package/dist/runtime/web/.next/static/media/ba9851c3c22cd980-s.woff2 +0 -0
  214. package/dist/runtime/web/.next/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
  215. package/dist/runtime/web/.next/static/media/df0a9ae256c0569c-s.woff2 +0 -0
  216. package/dist/runtime/web/.next/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
  217. package/dist/runtime/web/package.json +65 -0
  218. package/dist/runtime/web/server.js +44 -0
  219. package/dist/tsconfig.tsbuildinfo +1 -0
  220. package/package.json +80 -7
@@ -0,0 +1,340 @@
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
+ - "content": the improved task specification in markdown format with proper JSON escaping
74
+
75
+ ## Project Context
76
+
77
+ <ProjectContext>
78
+ {{projectContext}}
79
+ </ProjectContext>
80
+
81
+ ## Current Task Details
82
+ - **ID:** {{taskId}}
83
+ - **Title:** {{taskTitle}}
84
+ - **Type:** {{taskType}}
85
+ - **Priority:** {{taskPriority}}
86
+ - **Status:** {{taskStatus}}
87
+
88
+ ## Content to Improve
89
+
90
+ <CurrentTaskContent>
91
+ {{taskContent}}
92
+ </CurrentTaskContent>
93
+ `;
94
+ const TASK_TEMPLATE = `## Task Assignment
95
+
96
+ Deliver the following task.
97
+
98
+ ## Responsibilities
99
+
100
+ 1. **Analyze requirements** — study the acceptance criteria to clarify what must be delivered.
101
+ 2. **Review the codebase** — understand the current implementation, architecture, and coding patterns.
102
+ 3. **Implement changes** — add or modify code according to project conventions.
103
+ 4. **Test thoroughly** — write/run tests and verify that all builds succeed.
104
+ 5. **Update the task file** — tick off each acceptance criterion that you have completed.
105
+
106
+ ## Development Guidelines
107
+
108
+ - Respect existing architecture and style conventions.
109
+ - Add robust error handling.
110
+ - Update documentation when necessary.
111
+ - Ensure all tests pass and the project builds cleanly.
112
+ - Commit with a clear, descriptive message.
113
+ - Create todo list to track the progress.
114
+
115
+ ## Expected Deliverables
116
+
117
+ - A working implementation that satisfies every requirement.
118
+ - An updated task file showing completed acceptance criteria.
119
+ - Clean, well-documented code.
120
+ - Passing build and test results.
121
+
122
+ Begin by examining the codebase; then proceed with the implementation.
123
+
124
+ ---
125
+
126
+ ### Task Snapshot
127
+
128
+ - **ID:** {{taskId}}
129
+ - **Title:** {{taskTitle}}
130
+ - **Type:** {{taskType}}
131
+ - **Priority:** {{taskPriority}}
132
+ - **Status:** {{taskStatus}}
133
+ - **Tags:** {{tagsList}}
134
+
135
+ #### Description
136
+
137
+ {{taskContent}}
138
+
139
+ `;
140
+ const MERGE_TEMPLATE = `Goal: Merge feature branch into base without pushing to remote. Resolve conflicts safely.
141
+
142
+ Context:
143
+
144
+ - Repo: {{repoPath}}
145
+ - Worktree: {{worktreePath}}
146
+ - Feature branch: {{featureBranch}}
147
+ - Base branch: {{baseBranch}}
148
+
149
+ If conflicts:
150
+
151
+ - Prefer {{featureBranch}} when changes are clearly additive or isolated.
152
+ - Keep {{baseBranch}} when it contains newer logic that would be overwritten.
153
+ - Integrate both sides when needed.
154
+ - After each file: git add <file>
155
+ `;
156
+ const REVIEW_TEMPLATE = `## Code Review Task
157
+
158
+ Review the changes made for this task comprehensively.
159
+
160
+ 1. **Analyze the implemented changes** by examining the modified files, some of them might be committed in the recent commits
161
+ 2. **Evaluate code quality** including:
162
+ - Code structure and organization
163
+ - Adherence to coding standards and conventions
164
+ - Error handling and edge cases
165
+ - Performance considerations
166
+ - Security implications
167
+ - Test coverage and quality
168
+
169
+ 3. **Verify task completion** by checking that:
170
+ - All acceptance criteria are met
171
+ - Implementation matches the task requirements
172
+ - No unrelated changes were introduced
173
+
174
+ 4. **Provide structured feedback** using this JSON structure:
175
+
176
+ {
177
+ "reviewSummary": "Brief overview of the implementation and overall assessment",
178
+ "recommendations": [
179
+ "Specific recommendation 1",
180
+ "Specific recommendation 2",
181
+ "Specific recommendation 3"
182
+ ],
183
+ "qualityScore": 85
184
+ }
185
+
186
+ ## Review Guidelines
187
+
188
+ - Quality Score: Provide a score from 0-100 (higher is better), below 70 will trigger a re-implementation with your advice.
189
+ - Recommendations: Provide actionable, specific improvements
190
+ - Focus Areas: Security, performance, maintainability, testing, documentation
191
+ - Scoring Rubric (0-100):
192
+ - Correctness & completeness: 0-35
193
+ - Code quality & maintainability: 0-30
194
+ - Testing & coverage: 0-20
195
+ - Security & performance considerations: 0-15
196
+
197
+ If you identify any critical bugs or potential improvements, provide detailed notes, accpetance 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.
198
+
199
+ ---
200
+
201
+ ## Task Context
202
+
203
+ - **ID:** {{taskId}}
204
+ - **Title:** {{taskTitle}}
205
+ - **Type:** {{taskType}}
206
+ - **Priority:** {{taskPriority}}
207
+
208
+ ## Task Description
209
+
210
+ {{taskContent}}
211
+
212
+ ## Review Context
213
+
214
+ - **Worktree Path:** {{worktreePath}}
215
+ - **Branch:** {{worktreeBranch}}
216
+ - **Status:** active
217
+
218
+ {{additionalContext}}
219
+ `;
220
+ // Quality checks detection prompt (AI-only, JSON strict)
221
+ const DETECT_QUALITY_CHECKS_TEMPLATE = `You are analyzing a code repository to determine fast, local quality checks.
222
+
223
+ Constraints:
224
+ - Prefer fast checks suitable for local iteration.
225
+ - Only output valid JSON. No prose. No markdown. Do not include comments.
226
+ - Schema: { "checks": [ { "name": string, "command": string, "args": string[], "timeout": number, "enabled": boolean } ] }
227
+ - The unit of timeout is milliseconds.
228
+ - Defaults: enable tests/lint/typecheck if present; set build enabled=false unless explicitly required.
229
+ - Use the working directory tools (glob/grep/read) to discover project configuration.
230
+
231
+ Examples by ecosystem:
232
+ - Node: scripts in package.json (test, lint, typecheck). Use package manager scripts (npm run, pnpm, yarn) if detectable.
233
+ - Python: pytest, ruff, mypy if config present.
234
+ - Rust: cargo check/test/fmt/clippy if available.
235
+ - Go: go test, go vet, golangci-lint if configured.
236
+ - Others: propose similar fast checks when clear; otherwise return an empty list.
237
+
238
+ Return strictly the JSON with the schema above.`;
239
+ // -----------------------------
240
+ // Simple string template engine
241
+ // -----------------------------
242
+ function escapeRegExp(s) {
243
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
244
+ }
245
+ function render(template, vars) {
246
+ let out = template;
247
+ for (const [key, value] of Object.entries(vars)) {
248
+ const re = new RegExp(`{{\\s*${escapeRegExp(key)}\\s*}}`, 'g');
249
+ out = out.replace(re, value ?? '');
250
+ }
251
+ // Remove any unreplaced placeholders
252
+ return out.replace(/{{\s*[^}]+\s*}}/g, '');
253
+ }
254
+ // PromptService centralizes prompt generation logic used by AgentService.
255
+ // Prompts are hard-coded templates for now, with light project context reads.
256
+ export class PromptService {
257
+ constructor(projectRoot, taskService) {
258
+ this.projectRoot = projectRoot;
259
+ this.taskService = taskService;
260
+ }
261
+ async generateImprovementPrompt(task, taskData) {
262
+ // Read project context
263
+ const productOverviewPath = path.join(getVibeDir(), 'product_overview.md');
264
+ let productContext = '';
265
+ try {
266
+ productContext = await fs.readFile(productOverviewPath, 'utf-8');
267
+ }
268
+ catch {
269
+ log.warn('Could not read product_overview.md for improvement prompt', undefined, 'prompt-service');
270
+ }
271
+ return render(IMPROVEMENT_TEMPLATE, {
272
+ projectContext: productContext,
273
+ taskId: task.id,
274
+ taskTitle: taskData.title,
275
+ taskType: taskData.type,
276
+ taskPriority: taskData.priority,
277
+ taskStatus: task.status,
278
+ taskContent: taskData.content,
279
+ });
280
+ }
281
+ async generateTaskPrompt(task) {
282
+ const tagsList = task.tags.join(', ');
283
+ return render(TASK_TEMPLATE, {
284
+ taskId: task.id,
285
+ taskTitle: task.title,
286
+ taskType: task.type,
287
+ taskPriority: task.priority,
288
+ taskStatus: task.status,
289
+ taskContent: task.content,
290
+ tagsList,
291
+ });
292
+ }
293
+ async generateAIMergePrompt(task, worktree, baseBranch) {
294
+ const repoPath = this.projectRoot;
295
+ const featureBr = worktree.branchName;
296
+ // Determine base branch: prefer provided, otherwise current branch in repo root, fallback to 'main'
297
+ let baseBr = baseBranch?.trim();
298
+ if (!baseBr) {
299
+ try {
300
+ const { spawn } = await import('child_process');
301
+ baseBr = await new Promise((resolve, reject) => {
302
+ const child = spawn('git', ['branch', '--show-current'], {
303
+ cwd: repoPath,
304
+ stdio: ['ignore', 'pipe', 'pipe'],
305
+ });
306
+ let out = '';
307
+ child.stdout?.on('data', (d) => (out += d.toString()));
308
+ child.on('close', () => resolve(out.trim() || 'main'));
309
+ child.on('error', reject);
310
+ });
311
+ }
312
+ catch {
313
+ baseBr = 'main';
314
+ }
315
+ }
316
+ return render(MERGE_TEMPLATE, {
317
+ repoPath,
318
+ worktreePath: worktree.path,
319
+ featureBranch: featureBr,
320
+ baseBranch: baseBr,
321
+ });
322
+ }
323
+ async generateReviewPrompt(task, worktree, reviewContext) {
324
+ const additionalContext = reviewContext ? `\n**Additional Context:** ${reviewContext}` : '';
325
+ return render(REVIEW_TEMPLATE, {
326
+ taskId: task.id,
327
+ taskTitle: task.title,
328
+ taskType: task.type,
329
+ taskPriority: task.priority,
330
+ taskContent: task.content,
331
+ worktreePath: worktree.path,
332
+ worktreeBranch: worktree.branchName,
333
+ additionalContext,
334
+ });
335
+ }
336
+ }
337
+ // Utility export for building the quality checks detection prompt
338
+ export function getQualityChecksDetectionPrompt() {
339
+ return DETECT_QUALITY_CHECKS_TEMPLATE;
340
+ }
@@ -0,0 +1,188 @@
1
+ /**
2
+ * AI Routing Policy Management
3
+ * Handles provider selection per operation with fallbacks and configuration
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Operation types that support AI routing
8
+ */
9
+ export type RoutableOperation = 'execute_task' | 'improve_task' | 'ai_codereview' | 'ai_merge';
10
+ /**
11
+ * Generation options for AI execution
12
+ */
13
+ export declare const GenerationOptionsSchema: z.ZodObject<{
14
+ temperature: z.ZodOptional<z.ZodNumber>;
15
+ maxTokens: z.ZodOptional<z.ZodNumber>;
16
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
17
+ }, "strip", z.ZodTypeAny, {
18
+ maxTokens?: number | undefined;
19
+ tools?: string[] | undefined;
20
+ temperature?: number | undefined;
21
+ }, {
22
+ maxTokens?: number | undefined;
23
+ tools?: string[] | undefined;
24
+ temperature?: number | undefined;
25
+ }>;
26
+ export type GenerationOptions = z.infer<typeof GenerationOptionsSchema>;
27
+ /**
28
+ * Per-operation routing configuration
29
+ */
30
+ export declare const OperationConfigSchema: z.ZodObject<{
31
+ provider: z.ZodString;
32
+ model: z.ZodOptional<z.ZodString>;
33
+ options: z.ZodOptional<z.ZodObject<{
34
+ temperature: z.ZodOptional<z.ZodNumber>;
35
+ maxTokens: z.ZodOptional<z.ZodNumber>;
36
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
37
+ }, "strip", z.ZodTypeAny, {
38
+ maxTokens?: number | undefined;
39
+ tools?: string[] | undefined;
40
+ temperature?: number | undefined;
41
+ }, {
42
+ maxTokens?: number | undefined;
43
+ tools?: string[] | undefined;
44
+ temperature?: number | undefined;
45
+ }>>;
46
+ fallback: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
47
+ }, "strip", z.ZodTypeAny, {
48
+ provider: string;
49
+ options?: {
50
+ maxTokens?: number | undefined;
51
+ tools?: string[] | undefined;
52
+ temperature?: number | undefined;
53
+ } | undefined;
54
+ model?: string | undefined;
55
+ fallback?: string[] | undefined;
56
+ }, {
57
+ provider: string;
58
+ options?: {
59
+ maxTokens?: number | undefined;
60
+ tools?: string[] | undefined;
61
+ temperature?: number | undefined;
62
+ } | undefined;
63
+ model?: string | undefined;
64
+ fallback?: string[] | undefined;
65
+ }>;
66
+ export type OperationConfig = z.infer<typeof OperationConfigSchema>;
67
+ /**
68
+ * Complete routing policy schema
69
+ */
70
+ export declare const RoutingPolicySchema: z.ZodObject<{
71
+ defaultProvider: z.ZodString;
72
+ operations: z.ZodOptional<z.ZodRecord<z.ZodEnum<["execute_task", "improve_task", "ai_codereview", "ai_merge"]>, z.ZodObject<{
73
+ provider: z.ZodString;
74
+ model: z.ZodOptional<z.ZodString>;
75
+ options: z.ZodOptional<z.ZodObject<{
76
+ temperature: z.ZodOptional<z.ZodNumber>;
77
+ maxTokens: z.ZodOptional<z.ZodNumber>;
78
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
79
+ }, "strip", z.ZodTypeAny, {
80
+ maxTokens?: number | undefined;
81
+ tools?: string[] | undefined;
82
+ temperature?: number | undefined;
83
+ }, {
84
+ maxTokens?: number | undefined;
85
+ tools?: string[] | undefined;
86
+ temperature?: number | undefined;
87
+ }>>;
88
+ fallback: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ provider: string;
91
+ options?: {
92
+ maxTokens?: number | undefined;
93
+ tools?: string[] | undefined;
94
+ temperature?: number | undefined;
95
+ } | undefined;
96
+ model?: string | undefined;
97
+ fallback?: string[] | undefined;
98
+ }, {
99
+ provider: string;
100
+ options?: {
101
+ maxTokens?: number | undefined;
102
+ tools?: string[] | undefined;
103
+ temperature?: number | undefined;
104
+ } | undefined;
105
+ model?: string | undefined;
106
+ fallback?: string[] | undefined;
107
+ }>>>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ defaultProvider: string;
110
+ operations?: Partial<Record<"execute_task" | "improve_task" | "ai_codereview" | "ai_merge", {
111
+ provider: string;
112
+ options?: {
113
+ maxTokens?: number | undefined;
114
+ tools?: string[] | undefined;
115
+ temperature?: number | undefined;
116
+ } | undefined;
117
+ model?: string | undefined;
118
+ fallback?: string[] | undefined;
119
+ }>> | undefined;
120
+ }, {
121
+ defaultProvider: string;
122
+ operations?: Partial<Record<"execute_task" | "improve_task" | "ai_codereview" | "ai_merge", {
123
+ provider: string;
124
+ options?: {
125
+ maxTokens?: number | undefined;
126
+ tools?: string[] | undefined;
127
+ temperature?: number | undefined;
128
+ } | undefined;
129
+ model?: string | undefined;
130
+ fallback?: string[] | undefined;
131
+ }>> | undefined;
132
+ }>;
133
+ export type RoutingPolicy = z.infer<typeof RoutingPolicySchema>;
134
+ /**
135
+ * Resolved provider configuration for execution
136
+ */
137
+ export interface ResolvedProvider {
138
+ provider: string;
139
+ model?: string;
140
+ options?: GenerationOptions;
141
+ fallbacks?: string[];
142
+ }
143
+ /**
144
+ * Routing Policy Manager
145
+ * Manages AI provider routing policies with hot-reload capability
146
+ */
147
+ export declare class RoutingPolicyManager {
148
+ private policy;
149
+ private policyFilePath;
150
+ private lastModified;
151
+ constructor();
152
+ /**
153
+ * Get current effective policy with hot-reload
154
+ */
155
+ getPolicy(): Promise<RoutingPolicy>;
156
+ /**
157
+ * Update routing policy and persist to disk
158
+ */
159
+ updatePolicy(updates: Partial<RoutingPolicy>): Promise<void>;
160
+ /**
161
+ * Resolve provider for a specific operation
162
+ */
163
+ resolveProviderForOperation(operation: RoutableOperation, overrides?: Partial<ResolvedProvider>): Promise<ResolvedProvider>;
164
+ /**
165
+ * Set default provider
166
+ */
167
+ setDefaultProvider(provider: string): Promise<void>;
168
+ /**
169
+ * Set operation-specific routing
170
+ */
171
+ setOperationConfig(operation: RoutableOperation, config: OperationConfig): Promise<void>;
172
+ /**
173
+ * Validate policy against available providers
174
+ */
175
+ validatePolicy(policy: RoutingPolicy, availableProviders: Set<string>): string[];
176
+ /**
177
+ * Load policy from file if it has changed
178
+ */
179
+ private loadPolicyIfChanged;
180
+ /**
181
+ * Create example policy file if it doesn't exist
182
+ */
183
+ createExamplePolicy(): Promise<void>;
184
+ /**
185
+ * Get policy file path for external access
186
+ */
187
+ getPolicyFilePath(): string;
188
+ }