vibeman 0.0.5 → 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.
Files changed (241) hide show
  1. package/dist/api.js +49 -0
  2. package/dist/cli.js +135 -0
  3. package/dist/ui/index-gnk6rhxs.js +9 -0
  4. package/dist/ui/index.html +10 -0
  5. package/dist/ui/index.js +2 -0
  6. package/package.json +10 -46
  7. package/README.md +0 -12
  8. package/dist/index.js +0 -114
  9. package/dist/runtime/api/.tsbuildinfo +0 -1
  10. package/dist/runtime/api/agent/agent-service.d.ts +0 -229
  11. package/dist/runtime/api/agent/agent-service.js +0 -963
  12. package/dist/runtime/api/agent/ai-providers/amp-cli-provider.d.ts +0 -38
  13. package/dist/runtime/api/agent/ai-providers/amp-cli-provider.js +0 -268
  14. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.d.ts +0 -61
  15. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.js +0 -362
  16. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.d.ts +0 -36
  17. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.js +0 -375
  18. package/dist/runtime/api/agent/ai-providers/gemini-cli-provider.d.ts +0 -24
  19. package/dist/runtime/api/agent/ai-providers/gemini-cli-provider.js +0 -291
  20. package/dist/runtime/api/agent/ai-providers/index.d.ts +0 -9
  21. package/dist/runtime/api/agent/ai-providers/index.js +0 -9
  22. package/dist/runtime/api/agent/ai-providers/types.d.ts +0 -185
  23. package/dist/runtime/api/agent/ai-providers/types.js +0 -5
  24. package/dist/runtime/api/agent/amp-cli-provider.test.d.ts +0 -1
  25. package/dist/runtime/api/agent/amp-cli-provider.test.js +0 -99
  26. package/dist/runtime/api/agent/codex-cli-provider.test.d.ts +0 -1
  27. package/dist/runtime/api/agent/codex-cli-provider.test.js +0 -172
  28. package/dist/runtime/api/agent/core-agent-service.d.ts +0 -119
  29. package/dist/runtime/api/agent/core-agent-service.js +0 -267
  30. package/dist/runtime/api/agent/parsers.d.ts +0 -16
  31. package/dist/runtime/api/agent/parsers.js +0 -308
  32. package/dist/runtime/api/agent/prompt-service.d.ts +0 -30
  33. package/dist/runtime/api/agent/prompt-service.js +0 -452
  34. package/dist/runtime/api/agent/prompt-service.test.d.ts +0 -1
  35. package/dist/runtime/api/agent/prompt-service.test.js +0 -265
  36. package/dist/runtime/api/agent/routing-policy.d.ts +0 -171
  37. package/dist/runtime/api/agent/routing-policy.js +0 -196
  38. package/dist/runtime/api/agent/routing-policy.test.d.ts +0 -1
  39. package/dist/runtime/api/agent/routing-policy.test.js +0 -63
  40. package/dist/runtime/api/api/router-helpers.d.ts +0 -32
  41. package/dist/runtime/api/api/router-helpers.js +0 -31
  42. package/dist/runtime/api/api/routers/ai.d.ts +0 -200
  43. package/dist/runtime/api/api/routers/ai.js +0 -396
  44. package/dist/runtime/api/api/routers/executions.d.ts +0 -93
  45. package/dist/runtime/api/api/routers/executions.js +0 -94
  46. package/dist/runtime/api/api/routers/git.d.ts +0 -45
  47. package/dist/runtime/api/api/routers/git.js +0 -35
  48. package/dist/runtime/api/api/routers/provider-config.d.ts +0 -199
  49. package/dist/runtime/api/api/routers/provider-config.js +0 -252
  50. package/dist/runtime/api/api/routers/settings.d.ts +0 -158
  51. package/dist/runtime/api/api/routers/settings.js +0 -129
  52. package/dist/runtime/api/api/routers/tasks.d.ts +0 -141
  53. package/dist/runtime/api/api/routers/tasks.js +0 -238
  54. package/dist/runtime/api/api/routers/workflows.d.ts +0 -275
  55. package/dist/runtime/api/api/routers/workflows.js +0 -311
  56. package/dist/runtime/api/api/routers/worktrees.d.ts +0 -101
  57. package/dist/runtime/api/api/routers/worktrees.js +0 -80
  58. package/dist/runtime/api/api/trpc.d.ts +0 -118
  59. package/dist/runtime/api/api/trpc.js +0 -34
  60. package/dist/runtime/api/index.d.ts +0 -9
  61. package/dist/runtime/api/index.js +0 -117
  62. package/dist/runtime/api/lib/id-generator.d.ts +0 -70
  63. package/dist/runtime/api/lib/id-generator.js +0 -123
  64. package/dist/runtime/api/lib/local-config.d.ts +0 -335
  65. package/dist/runtime/api/lib/local-config.js +0 -304
  66. package/dist/runtime/api/lib/logger.d.ts +0 -11
  67. package/dist/runtime/api/lib/logger.js +0 -188
  68. package/dist/runtime/api/lib/provider-detection.d.ts +0 -61
  69. package/dist/runtime/api/lib/provider-detection.js +0 -326
  70. package/dist/runtime/api/lib/server/agent-service-singleton.d.ts +0 -6
  71. package/dist/runtime/api/lib/server/agent-service-singleton.js +0 -27
  72. package/dist/runtime/api/lib/server/bootstrap.d.ts +0 -38
  73. package/dist/runtime/api/lib/server/bootstrap.js +0 -197
  74. package/dist/runtime/api/lib/server/git-service-singleton.d.ts +0 -6
  75. package/dist/runtime/api/lib/server/git-service-singleton.js +0 -47
  76. package/dist/runtime/api/lib/server/project-root.d.ts +0 -2
  77. package/dist/runtime/api/lib/server/project-root.js +0 -61
  78. package/dist/runtime/api/lib/server/task-service-singleton.d.ts +0 -7
  79. package/dist/runtime/api/lib/server/task-service-singleton.js +0 -58
  80. package/dist/runtime/api/lib/server/vibeman-info.d.ts +0 -5
  81. package/dist/runtime/api/lib/server/vibeman-info.js +0 -85
  82. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.d.ts +0 -7
  83. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.js +0 -57
  84. package/dist/runtime/api/lib/trpc/server.d.ts +0 -965
  85. package/dist/runtime/api/lib/trpc/server.js +0 -11
  86. package/dist/runtime/api/lib/trpc/ws-server.d.ts +0 -8
  87. package/dist/runtime/api/lib/trpc/ws-server.js +0 -33
  88. package/dist/runtime/api/persistence/database-service.d.ts +0 -14
  89. package/dist/runtime/api/persistence/database-service.js +0 -74
  90. package/dist/runtime/api/persistence/execution-log-persistence.d.ts +0 -90
  91. package/dist/runtime/api/persistence/execution-log-persistence.js +0 -426
  92. package/dist/runtime/api/persistence/execution-log-persistence.test.d.ts +0 -1
  93. package/dist/runtime/api/persistence/execution-log-persistence.test.js +0 -170
  94. package/dist/runtime/api/router.d.ts +0 -968
  95. package/dist/runtime/api/router.js +0 -34
  96. package/dist/runtime/api/settings-service.d.ts +0 -110
  97. package/dist/runtime/api/settings-service.js +0 -678
  98. package/dist/runtime/api/tasks/file-watcher.d.ts +0 -23
  99. package/dist/runtime/api/tasks/file-watcher.js +0 -88
  100. package/dist/runtime/api/tasks/task-file-parser.d.ts +0 -14
  101. package/dist/runtime/api/tasks/task-file-parser.js +0 -180
  102. package/dist/runtime/api/tasks/task-service.d.ts +0 -36
  103. package/dist/runtime/api/tasks/task-service.js +0 -173
  104. package/dist/runtime/api/tasks/task-updater.d.ts +0 -62
  105. package/dist/runtime/api/tasks/task-updater.js +0 -260
  106. package/dist/runtime/api/tasks/task-updater.test.d.ts +0 -1
  107. package/dist/runtime/api/tasks/task-updater.test.js +0 -303
  108. package/dist/runtime/api/types/index.d.ts +0 -186
  109. package/dist/runtime/api/types/index.js +0 -1
  110. package/dist/runtime/api/types/settings.d.ts +0 -105
  111. package/dist/runtime/api/types/settings.js +0 -2
  112. package/dist/runtime/api/types.d.ts +0 -2
  113. package/dist/runtime/api/types.js +0 -1
  114. package/dist/runtime/api/utils/env.d.ts +0 -6
  115. package/dist/runtime/api/utils/env.js +0 -12
  116. package/dist/runtime/api/utils/stripNextEnv.d.ts +0 -7
  117. package/dist/runtime/api/utils/stripNextEnv.js +0 -22
  118. package/dist/runtime/api/utils/title-slug.d.ts +0 -6
  119. package/dist/runtime/api/utils/title-slug.js +0 -77
  120. package/dist/runtime/api/utils/url.d.ts +0 -2
  121. package/dist/runtime/api/utils/url.js +0 -19
  122. package/dist/runtime/api/vcs/git-history-service.d.ts +0 -57
  123. package/dist/runtime/api/vcs/git-history-service.js +0 -228
  124. package/dist/runtime/api/vcs/git-service.d.ts +0 -136
  125. package/dist/runtime/api/vcs/git-service.js +0 -307
  126. package/dist/runtime/api/vcs/worktree-service.d.ts +0 -93
  127. package/dist/runtime/api/vcs/worktree-service.js +0 -518
  128. package/dist/runtime/api/vcs/worktree-service.test.d.ts +0 -1
  129. package/dist/runtime/api/vcs/worktree-service.test.js +0 -20
  130. package/dist/runtime/api/workflows/quality-pipeline.d.ts +0 -58
  131. package/dist/runtime/api/workflows/quality-pipeline.js +0 -401
  132. package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +0 -406
  133. package/dist/runtime/api/workflows/vibing-orchestrator.js +0 -2462
  134. package/dist/runtime/api/workflows/workflow-effects.d.ts +0 -45
  135. package/dist/runtime/api/workflows/workflow-effects.js +0 -49
  136. package/dist/runtime/api/workflows/workflow-reconciler.d.ts +0 -65
  137. package/dist/runtime/api/workflows/workflow-reconciler.js +0 -226
  138. package/dist/runtime/api/workflows/workflow-reducer.d.ts +0 -26
  139. package/dist/runtime/api/workflows/workflow-reducer.js +0 -288
  140. package/dist/runtime/api/workflows/workflow-reducer.test.d.ts +0 -1
  141. package/dist/runtime/api/workflows/workflow-reducer.test.js +0 -247
  142. package/dist/runtime/api/workflows/workflow-schema.d.ts +0 -546
  143. package/dist/runtime/api/workflows/workflow-schema.js +0 -256
  144. package/dist/runtime/web/.next/BUILD_ID +0 -1
  145. package/dist/runtime/web/.next/app-build-manifest.json +0 -66
  146. package/dist/runtime/web/.next/app-path-routes-manifest.json +0 -8
  147. package/dist/runtime/web/.next/build-manifest.json +0 -33
  148. package/dist/runtime/web/.next/package.json +0 -1
  149. package/dist/runtime/web/.next/prerender-manifest.json +0 -61
  150. package/dist/runtime/web/.next/react-loadable-manifest.json +0 -8
  151. package/dist/runtime/web/.next/required-server-files.json +0 -334
  152. package/dist/runtime/web/.next/routes-manifest.json +0 -70
  153. package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js +0 -1
  154. package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js.nft.json +0 -1
  155. package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route_client-reference-manifest.js +0 -1
  156. package/dist/runtime/web/.next/server/app/_not-found/page.js +0 -2
  157. package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +0 -1
  158. package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
  159. package/dist/runtime/web/.next/server/app/_not-found.html +0 -7
  160. package/dist/runtime/web/.next/server/app/_not-found.meta +0 -8
  161. package/dist/runtime/web/.next/server/app/_not-found.rsc +0 -22
  162. package/dist/runtime/web/.next/server/app/api/health/route.js +0 -1
  163. package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +0 -1
  164. package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +0 -1
  165. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +0 -1
  166. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +0 -1
  167. package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +0 -1
  168. package/dist/runtime/web/.next/server/app/api/upload/route.js +0 -1
  169. package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +0 -1
  170. package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +0 -1
  171. package/dist/runtime/web/.next/server/app/index.html +0 -7
  172. package/dist/runtime/web/.next/server/app/index.meta +0 -7
  173. package/dist/runtime/web/.next/server/app/index.rsc +0 -27
  174. package/dist/runtime/web/.next/server/app/page.js +0 -112
  175. package/dist/runtime/web/.next/server/app/page.js.nft.json +0 -1
  176. package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +0 -1
  177. package/dist/runtime/web/.next/server/app-paths-manifest.json +0 -8
  178. package/dist/runtime/web/.next/server/chunks/210.js +0 -1
  179. package/dist/runtime/web/.next/server/chunks/291.js +0 -18
  180. package/dist/runtime/web/.next/server/chunks/552.js +0 -22
  181. package/dist/runtime/web/.next/server/chunks/780.js +0 -1
  182. package/dist/runtime/web/.next/server/chunks/905.js +0 -6
  183. package/dist/runtime/web/.next/server/chunks/98.js +0 -1
  184. package/dist/runtime/web/.next/server/functions-config-manifest.json +0 -4
  185. package/dist/runtime/web/.next/server/middleware-build-manifest.js +0 -1
  186. package/dist/runtime/web/.next/server/middleware-manifest.json +0 -6
  187. package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +0 -1
  188. package/dist/runtime/web/.next/server/next-font-manifest.js +0 -1
  189. package/dist/runtime/web/.next/server/next-font-manifest.json +0 -1
  190. package/dist/runtime/web/.next/server/pages/404.html +0 -7
  191. package/dist/runtime/web/.next/server/pages/500.html +0 -1
  192. package/dist/runtime/web/.next/server/pages/_app.js +0 -1
  193. package/dist/runtime/web/.next/server/pages/_app.js.nft.json +0 -1
  194. package/dist/runtime/web/.next/server/pages/_document.js +0 -1
  195. package/dist/runtime/web/.next/server/pages/_document.js.nft.json +0 -1
  196. package/dist/runtime/web/.next/server/pages/_error.js +0 -19
  197. package/dist/runtime/web/.next/server/pages/_error.js.nft.json +0 -1
  198. package/dist/runtime/web/.next/server/pages-manifest.json +0 -6
  199. package/dist/runtime/web/.next/server/server-reference-manifest.js +0 -1
  200. package/dist/runtime/web/.next/server/server-reference-manifest.json +0 -1
  201. package/dist/runtime/web/.next/server/webpack-runtime.js +0 -1
  202. package/dist/runtime/web/.next/static/LJFZk_8tvKFN_Ee4HqUuM/_buildManifest.js +0 -1
  203. package/dist/runtime/web/.next/static/LJFZk_8tvKFN_Ee4HqUuM/_ssgManifest.js +0 -1
  204. package/dist/runtime/web/.next/static/chunks/05c91ade-7d09b2b280adffd1.js +0 -1
  205. package/dist/runtime/web/.next/static/chunks/201-51bef3fa8c832e2e.js +0 -1
  206. package/dist/runtime/web/.next/static/chunks/524-89747ed9b0294f8a.js +0 -1
  207. package/dist/runtime/web/.next/static/chunks/554-8bec6e9cca6acc67.js +0 -1
  208. package/dist/runtime/web/.next/static/chunks/764.86e9503a69d45a85.js +0 -1
  209. package/dist/runtime/web/.next/static/chunks/7ab4dc20-239138e0ae7af24a.js +0 -1
  210. package/dist/runtime/web/.next/static/chunks/905-342391e3d3a3678f.js +0 -20
  211. package/dist/runtime/web/.next/static/chunks/a8a5ce16-4edea7df2d9b544a.js +0 -79
  212. package/dist/runtime/web/.next/static/chunks/ad74d572-4c1b162e2c15acaa.js +0 -1
  213. package/dist/runtime/web/.next/static/chunks/app/.vibeman/assets/images/[...path]/route-7b752a8641f96c1f.js +0 -1
  214. package/dist/runtime/web/.next/static/chunks/app/_not-found/page-34e66b251c2b5044.js +0 -1
  215. package/dist/runtime/web/.next/static/chunks/app/api/health/route-7b752a8641f96c1f.js +0 -1
  216. package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-7b752a8641f96c1f.js +0 -1
  217. package/dist/runtime/web/.next/static/chunks/app/api/upload/route-7b752a8641f96c1f.js +0 -1
  218. package/dist/runtime/web/.next/static/chunks/app/layout-df9ac93cb02b2385.js +0 -1
  219. package/dist/runtime/web/.next/static/chunks/app/page-6610743f7de5f92a.js +0 -1
  220. package/dist/runtime/web/.next/static/chunks/c25e0690-e9b798b8de667da1.js +0 -1
  221. package/dist/runtime/web/.next/static/chunks/framework-57157ec4d37f64aa.js +0 -1
  222. package/dist/runtime/web/.next/static/chunks/main-app-156cc0c60371bd78.js +0 -1
  223. package/dist/runtime/web/.next/static/chunks/main-df25d367c47b1fec.js +0 -1
  224. package/dist/runtime/web/.next/static/chunks/pages/_app-9f629a5e1131d19f.js +0 -1
  225. package/dist/runtime/web/.next/static/chunks/pages/_error-9238238274c7efcd.js +0 -1
  226. package/dist/runtime/web/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
  227. package/dist/runtime/web/.next/static/chunks/webpack-cd50e39b423d1808.js +0 -1
  228. package/dist/runtime/web/.next/static/css/2728291c68f99cb1.css +0 -3
  229. package/dist/runtime/web/.next/static/css/4fbf378a264bd4ea.css +0 -1
  230. package/dist/runtime/web/.next/static/css/521bd69cc298cd1a.css +0 -1
  231. package/dist/runtime/web/.next/static/css/537e22821e101b87.css +0 -1
  232. package/dist/runtime/web/.next/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
  233. package/dist/runtime/web/.next/static/media/21350d82a1f187e9-s.woff2 +0 -0
  234. package/dist/runtime/web/.next/static/media/8e9860b6e62d6359-s.woff2 +0 -0
  235. package/dist/runtime/web/.next/static/media/ba9851c3c22cd980-s.woff2 +0 -0
  236. package/dist/runtime/web/.next/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
  237. package/dist/runtime/web/.next/static/media/df0a9ae256c0569c-s.woff2 +0 -0
  238. package/dist/runtime/web/.next/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
  239. package/dist/runtime/web/package.json +0 -65
  240. package/dist/runtime/web/server.js +0 -44
  241. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,267 +0,0 @@
1
- /**
2
- * Core Agent Service - Pure AI Execution Engine
3
- * Provider-agnostic AI execution service
4
- */
5
- import { EventEmitter } from 'events';
6
- import { log } from '../lib/logger.js';
7
- import { generateId } from '../lib/id-generator.js';
8
- /**
9
- * Pure AI Execution Service
10
- * Manages AI providers and executions without business logic
11
- */
12
- export class CoreAgentService extends EventEmitter {
13
- constructor(config = {}) {
14
- super();
15
- this.providers = new Map();
16
- this.defaultProvider = null;
17
- this.executions = new Map();
18
- this.config = {
19
- executionTimeout: config.executionTimeout || 30 * 60 * 1000, // 30 minutes
20
- ...config,
21
- };
22
- }
23
- /**
24
- * Register an AI provider
25
- */
26
- registerProvider(name, provider) {
27
- this.providers.set(name, provider);
28
- log.debug(`Registered AI provider: ${name}`, undefined, 'core-agent-service');
29
- // Set as default if it's the first provider or matches config
30
- if (!this.defaultProvider || name === this.config.defaultProvider) {
31
- this.defaultProvider = name;
32
- log.debug(`Set default provider: ${name}`, undefined, 'core-agent-service');
33
- }
34
- }
35
- /**
36
- * Set default provider
37
- */
38
- setDefaultProvider(name) {
39
- if (!this.providers.has(name)) {
40
- throw new Error(`Provider ${name} not registered`);
41
- }
42
- this.defaultProvider = name;
43
- log.debug(`Changed default provider to: ${name}`, undefined, 'core-agent-service');
44
- }
45
- /**
46
- * Get default provider name
47
- */
48
- getDefaultProvider() {
49
- return this.defaultProvider;
50
- }
51
- /**
52
- * Get provider by name
53
- */
54
- getProvider(name) {
55
- return this.providers.get(name) || null;
56
- }
57
- /**
58
- * Get all registered providers
59
- */
60
- getProviders() {
61
- return new Map(this.providers);
62
- }
63
- /**
64
- * Execute a prompt with streaming
65
- */
66
- async execute(request) {
67
- // Determine which provider to use
68
- const providerName = request.provider || this.defaultProvider;
69
- if (!providerName) {
70
- throw new Error('No provider specified and no default provider set');
71
- }
72
- const provider = this.providers.get(providerName);
73
- if (!provider) {
74
- throw new Error(`Provider ${providerName} not found`);
75
- }
76
- const executionId = request.executionId || this.generateExecutionId();
77
- const abortController = new AbortController();
78
- // Set timeout
79
- const timeoutId = setTimeout(() => {
80
- abortController.abort();
81
- }, this.config.executionTimeout);
82
- const execution = {
83
- id: executionId,
84
- provider: provider.name,
85
- status: 'pending',
86
- startTime: new Date().toISOString(),
87
- messages: [],
88
- abortController,
89
- };
90
- this.executions.set(executionId, execution);
91
- // Emit execution created event
92
- this.emit('executionCreated', { executionId, provider: execution.provider });
93
- try {
94
- execution.status = 'running';
95
- this.emit('executionStarted', { executionId });
96
- const options = {
97
- ...request.options,
98
- abortSignal: abortController.signal,
99
- };
100
- let result = '';
101
- const messages = [];
102
- // Execute with streaming
103
- for await (const message of provider.execute(request.prompt, options)) {
104
- execution.messages.push(message);
105
- // Emit message events
106
- this.emit('executionMessage', {
107
- executionId,
108
- message,
109
- });
110
- // Collect assistant messages
111
- if (message.type === 'assistant') {
112
- const content = message.content;
113
- messages.push(content);
114
- // Emit update for UI streaming
115
- this.emit('executionUpdate', {
116
- executionId,
117
- status: execution.status,
118
- message,
119
- });
120
- }
121
- // Handle result
122
- if (message.type === 'result') {
123
- const resultMsg = message;
124
- if (resultMsg.success) {
125
- result = resultMsg.result || messages.join('\n');
126
- execution.result = result;
127
- execution.usage = resultMsg.usage;
128
- }
129
- else {
130
- throw new Error(resultMsg.error || 'Execution failed');
131
- }
132
- }
133
- }
134
- // Mark as completed
135
- execution.status = 'completed';
136
- execution.endTime = new Date().toISOString();
137
- clearTimeout(timeoutId);
138
- // Emit completion event
139
- this.emit('executionCompleted', {
140
- executionId,
141
- result,
142
- usage: execution.usage,
143
- });
144
- return result;
145
- }
146
- catch (error) {
147
- clearTimeout(timeoutId);
148
- // Handle cancellation
149
- if (abortController.signal.aborted) {
150
- execution.status = 'cancelled';
151
- execution.error = 'Execution cancelled';
152
- this.emit('executionCancelled', { executionId });
153
- }
154
- else {
155
- execution.status = 'failed';
156
- execution.error = error instanceof Error ? error.message : String(error);
157
- this.emit('executionFailed', {
158
- executionId,
159
- error: execution.error,
160
- });
161
- }
162
- execution.endTime = new Date().toISOString();
163
- throw error;
164
- }
165
- }
166
- /**
167
- * Get execution status
168
- */
169
- getExecutionStatus(executionId) {
170
- const execution = this.executions.get(executionId);
171
- if (!execution)
172
- return null;
173
- // Return copy without internal fields
174
- const { abortController, ...publicState } = execution;
175
- return publicState;
176
- }
177
- /**
178
- * Get execution messages
179
- */
180
- getExecutionMessages(executionId) {
181
- const execution = this.executions.get(executionId);
182
- return execution ? [...execution.messages] : [];
183
- }
184
- /**
185
- * Stop an execution
186
- */
187
- async stopExecution(executionId) {
188
- const execution = this.executions.get(executionId);
189
- if (!execution) {
190
- throw new Error(`Execution ${executionId} not found`);
191
- }
192
- if (execution.status !== 'running') {
193
- throw new Error(`Execution ${executionId} is not running`);
194
- }
195
- if (execution.abortController) {
196
- execution.abortController.abort();
197
- execution.status = 'cancelled';
198
- execution.endTime = new Date().toISOString();
199
- this.emit('executionCancelled', { executionId });
200
- }
201
- }
202
- /**
203
- * Get all executions
204
- */
205
- getAllExecutions() {
206
- return Array.from(this.executions.values()).map((e) => {
207
- const { abortController, ...publicState } = e;
208
- return publicState;
209
- });
210
- }
211
- /**
212
- * Clear completed executions
213
- */
214
- clearCompletedExecutions() {
215
- let cleared = 0;
216
- for (const [id, execution] of this.executions) {
217
- if (['completed', 'failed', 'cancelled'].includes(execution.status)) {
218
- this.executions.delete(id);
219
- cleared++;
220
- }
221
- }
222
- return cleared;
223
- }
224
- /**
225
- * Validate all providers
226
- */
227
- async validateProviders() {
228
- const results = new Map();
229
- for (const [name, provider] of this.providers) {
230
- try {
231
- const status = await provider.validateSetup();
232
- results.set(name, status);
233
- }
234
- catch (error) {
235
- results.set(name, {
236
- available: false,
237
- error: error instanceof Error ? error.message : String(error),
238
- models: [],
239
- capabilities: provider.getCapabilities(),
240
- });
241
- }
242
- }
243
- return results;
244
- }
245
- /**
246
- * Get available models from all providers
247
- */
248
- async getAvailableModels() {
249
- const models = [];
250
- for (const [name, provider] of this.providers) {
251
- try {
252
- const providerModels = await provider.detectAvailableModels();
253
- models.push(...providerModels);
254
- }
255
- catch (error) {
256
- log.warn(`Failed to get models from provider ${name}`, error, 'core-agent-service');
257
- }
258
- }
259
- return models;
260
- }
261
- /**
262
- * Generate execution ID
263
- */
264
- generateExecutionId() {
265
- return generateId('exec');
266
- }
267
- }
@@ -1,16 +0,0 @@
1
- export declare function parseImprovementResult(result: string, originalData: {
2
- title: string;
3
- type: string;
4
- priority: string;
5
- content: string;
6
- }): {
7
- type: string;
8
- priority: string;
9
- content: string;
10
- title?: string;
11
- };
12
- export declare function parseReviewResult(result: string): {
13
- reviewSummary: string;
14
- recommendations: string[];
15
- qualityScore: number;
16
- };
@@ -1,308 +0,0 @@
1
- import { log } from '../lib/logger.js';
2
- // Extract the last valid JSON object from mixed text.
3
- // It scans for fenced ```json blocks and balanced-brace objects, then returns the last one that parses.
4
- function extractLastValidJson(text) {
5
- if (!text)
6
- return null;
7
- const candidates = [];
8
- // 1) Fenced JSON blocks
9
- const fencedRe = /```json\s*([\s\S]*?)\s*```/gi;
10
- let m;
11
- while ((m = fencedRe.exec(text)) !== null) {
12
- if (m[1])
13
- candidates.push(m[1]);
14
- }
15
- // 2) Balanced brace objects
16
- let depth = 0;
17
- let inStr = false;
18
- let start = -1;
19
- let prev = '';
20
- for (let i = 0; i < text.length; i++) {
21
- const ch = text[i];
22
- if (inStr) {
23
- if (ch === '"' && prev !== '\\')
24
- inStr = false;
25
- }
26
- else {
27
- if (ch === '"')
28
- inStr = true;
29
- else if (ch === '{') {
30
- if (depth === 0)
31
- start = i;
32
- depth++;
33
- }
34
- else if (ch === '}') {
35
- if (depth > 0)
36
- depth--;
37
- if (depth === 0 && start >= 0) {
38
- candidates.push(text.slice(start, i + 1));
39
- start = -1;
40
- }
41
- }
42
- }
43
- prev = ch;
44
- }
45
- for (let i = candidates.length - 1; i >= 0; i--) {
46
- const c = candidates[i].trim();
47
- try {
48
- JSON.parse(c);
49
- return c;
50
- }
51
- catch {
52
- // ignore
53
- }
54
- }
55
- return null;
56
- }
57
- /**
58
- * Manually parse a JSON-like structure that may have unescaped strings
59
- * This is a fallback for when JSON.parse fails due to unescaped content
60
- */
61
- function parseJsonManually(jsonStr) {
62
- try {
63
- // Extract type, priority and title with simple regex (these are usually well-formed)
64
- const typeMatch = jsonStr.match(/"type":\s*"([^"]+)"/);
65
- const priorityMatch = jsonStr.match(/"priority":\s*"([^"]+)"/);
66
- const titleMatch = jsonStr.match(/"title":\s*"([^"]+)"/);
67
- // For content, find the start and extract everything until the closing brace
68
- const contentStart = jsonStr.indexOf('"content":');
69
- if (contentStart === -1)
70
- return null;
71
- const contentValueStart = jsonStr.indexOf('"', contentStart + 10);
72
- if (contentValueStart === -1)
73
- return null;
74
- // Find the last occurrence of "}` at the end - this marks the end of our JSON
75
- const jsonEnd = jsonStr.lastIndexOf('}');
76
- if (jsonEnd === -1)
77
- return null;
78
- // Find the quote that comes before the closing brace
79
- // Work backwards from the closing brace to find the last quote
80
- let contentEnd = -1;
81
- for (let i = jsonEnd - 1; i > contentValueStart; i--) {
82
- if (jsonStr[i] === '"') {
83
- // Check if this quote is escaped
84
- let backslashCount = 0;
85
- for (let j = i - 1; j >= 0 && jsonStr[j] === '\\'; j--) {
86
- backslashCount++;
87
- }
88
- // If even number of backslashes (including 0), quote is not escaped
89
- if (backslashCount % 2 === 0) {
90
- contentEnd = i;
91
- break;
92
- }
93
- }
94
- }
95
- if (contentEnd === -1)
96
- return null;
97
- // Extract the raw content
98
- const rawContent = jsonStr.substring(contentValueStart + 1, contentEnd);
99
- if (typeMatch && priorityMatch && rawContent) {
100
- // Clean up the content - unescape common escape sequences
101
- const content = rawContent
102
- .replace(/\\n/g, '\n')
103
- .replace(/\\r/g, '\r')
104
- .replace(/\\t/g, '\t')
105
- .replace(/\\"/g, '"')
106
- .replace(/\\\\/g, '\\');
107
- const result = {
108
- type: typeMatch[1],
109
- priority: priorityMatch[1],
110
- content: content,
111
- };
112
- // Add title if found
113
- if (titleMatch) {
114
- result.title = titleMatch[1];
115
- }
116
- return result;
117
- }
118
- return null;
119
- }
120
- catch (error) {
121
- const errMsg = error instanceof Error ? error.message : String(error);
122
- log.warn('Manual JSON parsing failed', { error: errMsg }, 'result-parsers');
123
- return null;
124
- }
125
- }
126
- /**
127
- * Extract title from markdown content and remove it from content
128
- * Returns { title: string | null, cleanedContent: string }
129
- */
130
- function extractTitleFromContent(content) {
131
- if (!content || typeof content !== 'string') {
132
- return { title: null, cleanedContent: content };
133
- }
134
- // Look for H1 heading at the start of content (with optional whitespace)
135
- const h1Match = content.match(/^\s*#\s+([^\n\r]+)/);
136
- if (h1Match) {
137
- const title = h1Match[1].trim();
138
- // Remove the H1 heading from content
139
- const cleanedContent = content.replace(/^\s*#\s+[^\n\r]+\s*\n?/, '').trim();
140
- return { title, cleanedContent };
141
- }
142
- return { title: null, cleanedContent: content };
143
- }
144
- export function parseImprovementResult(result, originalData) {
145
- try {
146
- const jsonBlock = extractLastValidJson(result);
147
- if (jsonBlock) {
148
- // Try parsing as-is first
149
- try {
150
- const parsed = JSON.parse(jsonBlock);
151
- if (parsed.type && parsed.priority && parsed.content) {
152
- // Validate type and priority values
153
- const validTypes = ['feature', 'bug', 'chore', 'refactor', 'test', 'doc'];
154
- const validPriorities = ['high', 'medium', 'low'];
155
- const normalizedType = String(parsed.type).toLowerCase();
156
- const normalizedPriority = String(parsed.priority).toLowerCase();
157
- // Extract title from JSON if present, otherwise from content
158
- let finalTitle;
159
- let finalContent = String(parsed.content).trim();
160
- if (parsed.title && typeof parsed.title === 'string' && parsed.title.trim()) {
161
- finalTitle = parsed.title.trim();
162
- }
163
- else {
164
- // Try to extract title from content
165
- const { title, cleanedContent } = extractTitleFromContent(finalContent);
166
- if (title) {
167
- finalTitle = title;
168
- finalContent = cleanedContent;
169
- }
170
- }
171
- const result = {
172
- type: validTypes.includes(normalizedType) ? normalizedType : originalData.type,
173
- priority: validPriorities.includes(normalizedPriority)
174
- ? normalizedPriority
175
- : originalData.priority,
176
- content: finalContent,
177
- };
178
- if (finalTitle) {
179
- result.title = finalTitle;
180
- }
181
- return result;
182
- }
183
- }
184
- catch (parseError) {
185
- // If JSON parsing fails, try to fix common issues
186
- const parseErrMsg = parseError instanceof Error ? parseError.message : String(parseError);
187
- log.warn('Initial JSON parse failed, attempting to clean JSON', { error: parseErrMsg }, 'result-parsers');
188
- try {
189
- // Attempt to manually parse the JSON structure
190
- const parsed = parseJsonManually(jsonBlock);
191
- if (parsed && parsed.type && parsed.priority && parsed.content) {
192
- const validTypes = ['feature', 'bug', 'chore', 'refactor', 'test', 'doc'];
193
- const validPriorities = ['high', 'medium', 'low'];
194
- const normalizedType = String(parsed.type).toLowerCase();
195
- const normalizedPriority = String(parsed.priority).toLowerCase();
196
- // Extract title from parsed JSON if present, otherwise from content
197
- let finalTitle;
198
- let finalContent = String(parsed.content).trim();
199
- if (parsed.title && typeof parsed.title === 'string' && parsed.title.trim()) {
200
- finalTitle = parsed.title.trim();
201
- }
202
- else {
203
- // Try to extract title from content
204
- const { title, cleanedContent } = extractTitleFromContent(finalContent);
205
- if (title) {
206
- finalTitle = title;
207
- finalContent = cleanedContent;
208
- }
209
- }
210
- const result = {
211
- type: validTypes.includes(normalizedType) ? normalizedType : originalData.type,
212
- priority: validPriorities.includes(normalizedPriority)
213
- ? normalizedPriority
214
- : originalData.priority,
215
- content: finalContent,
216
- };
217
- if (finalTitle) {
218
- result.title = finalTitle;
219
- }
220
- return result;
221
- }
222
- }
223
- catch (secondError) {
224
- const secondErrMsg = secondError instanceof Error ? secondError.message : String(secondError);
225
- log.error('JSON cleaning also failed', { error: secondErrMsg }, 'result-parsers');
226
- }
227
- }
228
- }
229
- }
230
- catch (error) {
231
- const errMsg = error instanceof Error ? error.message : String(error);
232
- log.error('Failed to parse improvement result', { error: errMsg, result }, 'result-parsers');
233
- }
234
- // Fallback: try to extract title from the raw result content
235
- const fallbackContent = result.trim() || originalData.content;
236
- const { title: extractedTitle, cleanedContent } = extractTitleFromContent(fallbackContent);
237
- const fallbackResult = {
238
- type: originalData.type,
239
- priority: originalData.priority,
240
- content: cleanedContent,
241
- };
242
- if (extractedTitle) {
243
- fallbackResult.title = extractedTitle;
244
- }
245
- return fallbackResult;
246
- }
247
- export function parseReviewResult(result) {
248
- try {
249
- const jsonBlock = extractLastValidJson(result);
250
- if (jsonBlock) {
251
- const parsed = JSON.parse(jsonBlock);
252
- if (parsed.reviewSummary &&
253
- parsed.recommendations &&
254
- (typeof parsed.qualityScore === 'number' || typeof parsed.score === 'number')) {
255
- const score = typeof parsed.qualityScore === 'number' ? parsed.qualityScore : parsed.score;
256
- return {
257
- reviewSummary: String(parsed.reviewSummary),
258
- recommendations: Array.isArray(parsed.recommendations)
259
- ? parsed.recommendations.map((r) => String(r))
260
- : [String(parsed.recommendations)],
261
- qualityScore: Math.max(0, Math.min(100, Number(score))),
262
- };
263
- }
264
- }
265
- }
266
- catch (error) {
267
- log.error('Failed to parse review result', error, 'result-parsers');
268
- }
269
- // Fallback: parse simple plaintext format like
270
- // Score: 75/100\nSummary: ...\nRecommendations:\n- item
271
- try {
272
- const scoreMatch = result.match(/Score\s*:\s*(\d{1,3})(?:\s*\/\s*100)?/i);
273
- const summaryMatch = result.match(/Summary\s*:\s*([\s\S]*?)(?:\n\s*Recommendations\s*:|$)/i);
274
- const recBlockMatch = result.match(/Recommendations\s*:\s*([\s\S]*)$/i);
275
- const score = scoreMatch ? Math.max(0, Math.min(100, Number(scoreMatch[1]))) : 75;
276
- const reviewSummary = summaryMatch
277
- ? summaryMatch[1].trim()
278
- : result.length > 200
279
- ? result.substring(0, 200) + '...'
280
- : result;
281
- let recommendations = [];
282
- if (recBlockMatch) {
283
- const lines = recBlockMatch[1]
284
- .split(/\r?\n/)
285
- .map((l) => l.trim())
286
- .filter(Boolean);
287
- // Take bullet-like lines or fallback to one-liner
288
- const bullets = lines
289
- .filter((l) => /^[-*•\d]/.test(l))
290
- .map((l) => l.replace(/^[-*•\d.)\s]+/, '').trim());
291
- recommendations = bullets.length ? bullets : lines.slice(0, 5);
292
- if (!recommendations.length)
293
- recommendations = ['Review completed - see output for details'];
294
- }
295
- else {
296
- recommendations = ['Review completed - see output for details'];
297
- }
298
- return { reviewSummary, recommendations, qualityScore: score };
299
- }
300
- catch {
301
- // fall back to generic
302
- }
303
- return {
304
- reviewSummary: result.length > 200 ? result.substring(0, 200) + '...' : result,
305
- recommendations: ['Review completed - see output for details'],
306
- qualityScore: 75,
307
- };
308
- }
@@ -1,30 +0,0 @@
1
- import type { Task, WorktreeInfo } from '../types/index.js';
2
- import type { TaskService } from '../tasks/task-service.js';
3
- export declare class PromptService {
4
- private projectRoot;
5
- private taskService;
6
- constructor(projectRoot: string, taskService: TaskService);
7
- /**
8
- * Generate absolute path to task file
9
- */
10
- private generateTaskFilePath;
11
- /**
12
- * Validate that task file exists at the given path
13
- */
14
- private validateTaskFile;
15
- generateImprovementPrompt(task: Task, taskData: {
16
- title: string;
17
- type: string;
18
- priority: string;
19
- content: string;
20
- }): Promise<string>;
21
- generateTaskPrompt(task: Task, workflowConfig?: import('../types/index.js').VibingConfig): Promise<string>;
22
- /**
23
- * Build a prominent, clearly formatted instruction section derived from workflow options.
24
- * If no options are provided or none apply, returns a minimal guidance line.
25
- */
26
- private buildWorkflowInstructions;
27
- generateAIMergePrompt(task: Task, worktree: WorktreeInfo, baseBranch?: string): Promise<string>;
28
- generateReviewPrompt(task: Task, worktree: WorktreeInfo, reviewContext?: string): Promise<string>;
29
- }
30
- export declare function getQualityChecksDetectionPrompt(): string;