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.
Files changed (231) 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 -80
  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 -225
  11. package/dist/runtime/api/agent/agent-service.js +0 -904
  12. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.d.ts +0 -61
  13. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.js +0 -362
  14. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.d.ts +0 -36
  15. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.js +0 -347
  16. package/dist/runtime/api/agent/ai-providers/index.d.ts +0 -9
  17. package/dist/runtime/api/agent/ai-providers/index.js +0 -7
  18. package/dist/runtime/api/agent/ai-providers/types.d.ts +0 -182
  19. package/dist/runtime/api/agent/ai-providers/types.js +0 -5
  20. package/dist/runtime/api/agent/codex-cli-provider.test.d.ts +0 -1
  21. package/dist/runtime/api/agent/codex-cli-provider.test.js +0 -170
  22. package/dist/runtime/api/agent/core-agent-service.d.ts +0 -119
  23. package/dist/runtime/api/agent/core-agent-service.js +0 -267
  24. package/dist/runtime/api/agent/parsers.d.ts +0 -16
  25. package/dist/runtime/api/agent/parsers.js +0 -308
  26. package/dist/runtime/api/agent/prompt-service.d.ts +0 -30
  27. package/dist/runtime/api/agent/prompt-service.js +0 -449
  28. package/dist/runtime/api/agent/prompt-service.test.d.ts +0 -1
  29. package/dist/runtime/api/agent/prompt-service.test.js +0 -230
  30. package/dist/runtime/api/agent/routing-policy.d.ts +0 -171
  31. package/dist/runtime/api/agent/routing-policy.js +0 -196
  32. package/dist/runtime/api/agent/routing-policy.test.d.ts +0 -1
  33. package/dist/runtime/api/agent/routing-policy.test.js +0 -63
  34. package/dist/runtime/api/api/router-helpers.d.ts +0 -32
  35. package/dist/runtime/api/api/router-helpers.js +0 -31
  36. package/dist/runtime/api/api/routers/ai.d.ts +0 -200
  37. package/dist/runtime/api/api/routers/ai.js +0 -396
  38. package/dist/runtime/api/api/routers/executions.d.ts +0 -98
  39. package/dist/runtime/api/api/routers/executions.js +0 -94
  40. package/dist/runtime/api/api/routers/git.d.ts +0 -45
  41. package/dist/runtime/api/api/routers/git.js +0 -35
  42. package/dist/runtime/api/api/routers/provider-config.d.ts +0 -165
  43. package/dist/runtime/api/api/routers/provider-config.js +0 -252
  44. package/dist/runtime/api/api/routers/settings.d.ts +0 -139
  45. package/dist/runtime/api/api/routers/settings.js +0 -113
  46. package/dist/runtime/api/api/routers/tasks.d.ts +0 -141
  47. package/dist/runtime/api/api/routers/tasks.js +0 -238
  48. package/dist/runtime/api/api/routers/workflows.d.ts +0 -275
  49. package/dist/runtime/api/api/routers/workflows.js +0 -311
  50. package/dist/runtime/api/api/routers/worktrees.d.ts +0 -101
  51. package/dist/runtime/api/api/routers/worktrees.js +0 -80
  52. package/dist/runtime/api/api/trpc.d.ts +0 -118
  53. package/dist/runtime/api/api/trpc.js +0 -34
  54. package/dist/runtime/api/index.d.ts +0 -9
  55. package/dist/runtime/api/index.js +0 -117
  56. package/dist/runtime/api/lib/id-generator.d.ts +0 -70
  57. package/dist/runtime/api/lib/id-generator.js +0 -123
  58. package/dist/runtime/api/lib/local-config.d.ts +0 -245
  59. package/dist/runtime/api/lib/local-config.js +0 -288
  60. package/dist/runtime/api/lib/logger.d.ts +0 -11
  61. package/dist/runtime/api/lib/logger.js +0 -188
  62. package/dist/runtime/api/lib/provider-detection.d.ts +0 -59
  63. package/dist/runtime/api/lib/provider-detection.js +0 -244
  64. package/dist/runtime/api/lib/server/agent-service-singleton.d.ts +0 -6
  65. package/dist/runtime/api/lib/server/agent-service-singleton.js +0 -27
  66. package/dist/runtime/api/lib/server/bootstrap.d.ts +0 -38
  67. package/dist/runtime/api/lib/server/bootstrap.js +0 -197
  68. package/dist/runtime/api/lib/server/git-service-singleton.d.ts +0 -6
  69. package/dist/runtime/api/lib/server/git-service-singleton.js +0 -47
  70. package/dist/runtime/api/lib/server/project-root.d.ts +0 -2
  71. package/dist/runtime/api/lib/server/project-root.js +0 -61
  72. package/dist/runtime/api/lib/server/task-service-singleton.d.ts +0 -7
  73. package/dist/runtime/api/lib/server/task-service-singleton.js +0 -58
  74. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.d.ts +0 -7
  75. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.js +0 -57
  76. package/dist/runtime/api/lib/trpc/client.d.ts +0 -1
  77. package/dist/runtime/api/lib/trpc/client.js +0 -5
  78. package/dist/runtime/api/lib/trpc/server.d.ts +0 -935
  79. package/dist/runtime/api/lib/trpc/server.js +0 -11
  80. package/dist/runtime/api/lib/trpc/ws-server.d.ts +0 -8
  81. package/dist/runtime/api/lib/trpc/ws-server.js +0 -33
  82. package/dist/runtime/api/persistence/database-service.d.ts +0 -14
  83. package/dist/runtime/api/persistence/database-service.js +0 -74
  84. package/dist/runtime/api/persistence/execution-log-persistence.d.ts +0 -90
  85. package/dist/runtime/api/persistence/execution-log-persistence.js +0 -410
  86. package/dist/runtime/api/persistence/execution-log-persistence.test.d.ts +0 -1
  87. package/dist/runtime/api/persistence/execution-log-persistence.test.js +0 -170
  88. package/dist/runtime/api/router.d.ts +0 -938
  89. package/dist/runtime/api/router.js +0 -34
  90. package/dist/runtime/api/settings-service.d.ts +0 -110
  91. package/dist/runtime/api/settings-service.js +0 -661
  92. package/dist/runtime/api/tasks/file-watcher.d.ts +0 -23
  93. package/dist/runtime/api/tasks/file-watcher.js +0 -88
  94. package/dist/runtime/api/tasks/task-file-parser.d.ts +0 -13
  95. package/dist/runtime/api/tasks/task-file-parser.js +0 -161
  96. package/dist/runtime/api/tasks/task-service.d.ts +0 -36
  97. package/dist/runtime/api/tasks/task-service.js +0 -173
  98. package/dist/runtime/api/types/index.d.ts +0 -186
  99. package/dist/runtime/api/types/index.js +0 -1
  100. package/dist/runtime/api/types/settings.d.ts +0 -94
  101. package/dist/runtime/api/types/settings.js +0 -2
  102. package/dist/runtime/api/types.d.ts +0 -2
  103. package/dist/runtime/api/types.js +0 -1
  104. package/dist/runtime/api/utils/env.d.ts +0 -6
  105. package/dist/runtime/api/utils/env.js +0 -12
  106. package/dist/runtime/api/utils/stripNextEnv.d.ts +0 -7
  107. package/dist/runtime/api/utils/stripNextEnv.js +0 -22
  108. package/dist/runtime/api/utils/title-slug.d.ts +0 -6
  109. package/dist/runtime/api/utils/title-slug.js +0 -77
  110. package/dist/runtime/api/utils/url.d.ts +0 -2
  111. package/dist/runtime/api/utils/url.js +0 -19
  112. package/dist/runtime/api/vcs/git-history-service.d.ts +0 -57
  113. package/dist/runtime/api/vcs/git-history-service.js +0 -228
  114. package/dist/runtime/api/vcs/git-service.d.ts +0 -127
  115. package/dist/runtime/api/vcs/git-service.js +0 -284
  116. package/dist/runtime/api/vcs/worktree-service.d.ts +0 -93
  117. package/dist/runtime/api/vcs/worktree-service.js +0 -506
  118. package/dist/runtime/api/vcs/worktree-service.test.d.ts +0 -1
  119. package/dist/runtime/api/vcs/worktree-service.test.js +0 -20
  120. package/dist/runtime/api/workflows/quality-pipeline.d.ts +0 -58
  121. package/dist/runtime/api/workflows/quality-pipeline.js +0 -400
  122. package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +0 -318
  123. package/dist/runtime/api/workflows/vibing-orchestrator.js +0 -1891
  124. package/dist/runtime/web/.next/BUILD_ID +0 -1
  125. package/dist/runtime/web/.next/app-build-manifest.json +0 -66
  126. package/dist/runtime/web/.next/app-path-routes-manifest.json +0 -8
  127. package/dist/runtime/web/.next/build-manifest.json +0 -33
  128. package/dist/runtime/web/.next/package.json +0 -1
  129. package/dist/runtime/web/.next/prerender-manifest.json +0 -61
  130. package/dist/runtime/web/.next/react-loadable-manifest.json +0 -39
  131. package/dist/runtime/web/.next/required-server-files.json +0 -334
  132. package/dist/runtime/web/.next/routes-manifest.json +0 -70
  133. package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js +0 -1
  134. package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js.nft.json +0 -1
  135. package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route_client-reference-manifest.js +0 -1
  136. package/dist/runtime/web/.next/server/app/_not-found/page.js +0 -2
  137. package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +0 -1
  138. package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
  139. package/dist/runtime/web/.next/server/app/_not-found.html +0 -7
  140. package/dist/runtime/web/.next/server/app/_not-found.meta +0 -8
  141. package/dist/runtime/web/.next/server/app/_not-found.rsc +0 -22
  142. package/dist/runtime/web/.next/server/app/api/health/route.js +0 -1
  143. package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +0 -1
  144. package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +0 -1
  145. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +0 -1
  146. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +0 -1
  147. package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +0 -1
  148. package/dist/runtime/web/.next/server/app/api/upload/route.js +0 -1
  149. package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +0 -1
  150. package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +0 -1
  151. package/dist/runtime/web/.next/server/app/index.html +0 -7
  152. package/dist/runtime/web/.next/server/app/index.meta +0 -7
  153. package/dist/runtime/web/.next/server/app/index.rsc +0 -27
  154. package/dist/runtime/web/.next/server/app/page.js +0 -147
  155. package/dist/runtime/web/.next/server/app/page.js.nft.json +0 -1
  156. package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +0 -1
  157. package/dist/runtime/web/.next/server/app-paths-manifest.json +0 -8
  158. package/dist/runtime/web/.next/server/chunks/217.js +0 -1
  159. package/dist/runtime/web/.next/server/chunks/383.js +0 -6
  160. package/dist/runtime/web/.next/server/chunks/458.js +0 -1
  161. package/dist/runtime/web/.next/server/chunks/576.js +0 -18
  162. package/dist/runtime/web/.next/server/chunks/635.js +0 -22
  163. package/dist/runtime/web/.next/server/chunks/761.js +0 -1
  164. package/dist/runtime/web/.next/server/chunks/777.js +0 -3
  165. package/dist/runtime/web/.next/server/chunks/825.js +0 -1
  166. package/dist/runtime/web/.next/server/chunks/838.js +0 -1
  167. package/dist/runtime/web/.next/server/chunks/973.js +0 -15
  168. package/dist/runtime/web/.next/server/functions-config-manifest.json +0 -4
  169. package/dist/runtime/web/.next/server/middleware-build-manifest.js +0 -1
  170. package/dist/runtime/web/.next/server/middleware-manifest.json +0 -6
  171. package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +0 -1
  172. package/dist/runtime/web/.next/server/next-font-manifest.js +0 -1
  173. package/dist/runtime/web/.next/server/next-font-manifest.json +0 -1
  174. package/dist/runtime/web/.next/server/pages/404.html +0 -7
  175. package/dist/runtime/web/.next/server/pages/500.html +0 -1
  176. package/dist/runtime/web/.next/server/pages/_app.js +0 -1
  177. package/dist/runtime/web/.next/server/pages/_app.js.nft.json +0 -1
  178. package/dist/runtime/web/.next/server/pages/_document.js +0 -1
  179. package/dist/runtime/web/.next/server/pages/_document.js.nft.json +0 -1
  180. package/dist/runtime/web/.next/server/pages/_error.js +0 -19
  181. package/dist/runtime/web/.next/server/pages/_error.js.nft.json +0 -1
  182. package/dist/runtime/web/.next/server/pages-manifest.json +0 -6
  183. package/dist/runtime/web/.next/server/server-reference-manifest.js +0 -1
  184. package/dist/runtime/web/.next/server/server-reference-manifest.json +0 -1
  185. package/dist/runtime/web/.next/server/webpack-runtime.js +0 -1
  186. package/dist/runtime/web/.next/static/5_15u1WQCxN1_eHZpldCv/_buildManifest.js +0 -1
  187. package/dist/runtime/web/.next/static/5_15u1WQCxN1_eHZpldCv/_ssgManifest.js +0 -1
  188. package/dist/runtime/web/.next/static/chunks/18-15c10d3288afef2e.js +0 -1
  189. package/dist/runtime/web/.next/static/chunks/1c0ca389.537bbe362e3ffbd9.js +0 -3
  190. package/dist/runtime/web/.next/static/chunks/22747d63-ad5da0c19f4cfe41.js +0 -71
  191. package/dist/runtime/web/.next/static/chunks/355.056c2645878a799a.js +0 -1
  192. package/dist/runtime/web/.next/static/chunks/420.a5ccf151c9e2b2f1.js +0 -1
  193. package/dist/runtime/web/.next/static/chunks/439.1be0c6242fd248d5.js +0 -15
  194. package/dist/runtime/web/.next/static/chunks/440.c52e7c0f797e22b2.js +0 -1
  195. package/dist/runtime/web/.next/static/chunks/575-e2478287c27da87b.js +0 -1
  196. package/dist/runtime/web/.next/static/chunks/691.920d88c115087314.js +0 -1
  197. package/dist/runtime/web/.next/static/chunks/765-e838910065b50c3d.js +0 -1
  198. package/dist/runtime/web/.next/static/chunks/823-6f371a6e829adbba.js +0 -63
  199. package/dist/runtime/web/.next/static/chunks/87c73c54-09e1ba5c70e60a51.js +0 -1
  200. package/dist/runtime/web/.next/static/chunks/891cff7f.0f71fc028f87e683.js +0 -1
  201. package/dist/runtime/web/.next/static/chunks/8bb4d8db-3e2aa02b0a2384b9.js +0 -1
  202. package/dist/runtime/web/.next/static/chunks/9af238c7-271a911d4e99ab18.js +0 -1
  203. package/dist/runtime/web/.next/static/chunks/app/.vibeman/assets/images/[...path]/route-751c9265a65409e5.js +0 -1
  204. package/dist/runtime/web/.next/static/chunks/app/_not-found/page-1cb74d1cba27d0ab.js +0 -1
  205. package/dist/runtime/web/.next/static/chunks/app/api/health/route-751c9265a65409e5.js +0 -1
  206. package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-751c9265a65409e5.js +0 -1
  207. package/dist/runtime/web/.next/static/chunks/app/api/upload/route-751c9265a65409e5.js +0 -1
  208. package/dist/runtime/web/.next/static/chunks/app/layout-8435322f09fd0975.js +0 -1
  209. package/dist/runtime/web/.next/static/chunks/app/page-9fe7d75095b4ccec.js +0 -1
  210. package/dist/runtime/web/.next/static/chunks/cac567b0-5b77dd12911823cd.js +0 -1
  211. package/dist/runtime/web/.next/static/chunks/framework-2518f1345b5b2806.js +0 -1
  212. package/dist/runtime/web/.next/static/chunks/main-17665e5e39de9a8a.js +0 -1
  213. package/dist/runtime/web/.next/static/chunks/main-app-c0b0f5ba4f7f9d75.js +0 -1
  214. package/dist/runtime/web/.next/static/chunks/pages/_app-d6f6b3bbc3d81ee1.js +0 -1
  215. package/dist/runtime/web/.next/static/chunks/pages/_error-75a96cf1997cc3b9.js +0 -1
  216. package/dist/runtime/web/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
  217. package/dist/runtime/web/.next/static/chunks/webpack-c8de37305b4635cf.js +0 -1
  218. package/dist/runtime/web/.next/static/css/08c950681f1a9a92.css +0 -1
  219. package/dist/runtime/web/.next/static/css/2728291c68f99cb1.css +0 -3
  220. package/dist/runtime/web/.next/static/css/521bd69cc298cd1a.css +0 -1
  221. package/dist/runtime/web/.next/static/css/537e22821e101b87.css +0 -1
  222. package/dist/runtime/web/.next/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
  223. package/dist/runtime/web/.next/static/media/21350d82a1f187e9-s.woff2 +0 -0
  224. package/dist/runtime/web/.next/static/media/8e9860b6e62d6359-s.woff2 +0 -0
  225. package/dist/runtime/web/.next/static/media/ba9851c3c22cd980-s.woff2 +0 -0
  226. package/dist/runtime/web/.next/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
  227. package/dist/runtime/web/.next/static/media/df0a9ae256c0569c-s.woff2 +0 -0
  228. package/dist/runtime/web/.next/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
  229. package/dist/runtime/web/package.json +0 -65
  230. package/dist/runtime/web/server.js +0 -44
  231. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,661 +0,0 @@
1
- /**
2
- * Settings Service - Centralized configuration management
3
- *
4
- * Provides persistent storage and validation for application settings
5
- * with atomic write operations and schema validation using Zod.
6
- */
7
- import { EventEmitter } from 'events';
8
- import fs from 'fs/promises';
9
- import path from 'path';
10
- import { z } from 'zod';
11
- import { log } from './lib/logger.js';
12
- import { getProjectRoot } from './lib/server/project-root.js';
13
- // Zod schema for validation
14
- const CLAUDE_ALLOWED_MODELS = [
15
- 'claude-sonnet-4-20250514',
16
- 'claude-opus-4-1-20250805',
17
- 'claude-3-5-haiku-20241022',
18
- ];
19
- const CODEX_ALLOWED_MODELS = [
20
- 'gpt-5',
21
- 'gpt-5-low',
22
- 'gpt-5-medium',
23
- 'gpt-5-high',
24
- 'gpt-5-codex',
25
- 'gpt-5-codex-low',
26
- 'gpt-5-codex-medium',
27
- 'gpt-5-codex-high',
28
- ];
29
- const MODEL_ENUM = [...CLAUDE_ALLOWED_MODELS, ...CODEX_ALLOWED_MODELS];
30
- const ROUTABLE_OPERATIONS = [
31
- 'execute_task',
32
- 'quality_checks',
33
- 'ai_codereview',
34
- 'ai_merge',
35
- 'improve_task',
36
- ];
37
- const RoutingOperationSchema = z.object({
38
- provider: z.string(),
39
- model: z.string().optional(),
40
- options: z
41
- .object({
42
- temperature: z.number().min(0).max(2).optional(),
43
- maxTokens: z.number().positive().optional(),
44
- tools: z.array(z.string()).optional(),
45
- })
46
- .optional(),
47
- fallback: z.array(z.string()).optional(),
48
- });
49
- const RoutingPolicySettingsSchema = z
50
- .object({
51
- defaultProvider: z.enum(['claude-code', 'codex']).optional(),
52
- operations: z.record(z.enum(ROUTABLE_OPERATIONS), RoutingOperationSchema).optional(),
53
- })
54
- .optional();
55
- const VibemanSettingsSchema = z.object({
56
- agents: z.object({
57
- defaultProvider: z.enum(['claude-code', 'codex']),
58
- codingAgent: z.object({
59
- provider: z.enum(['claude-code', 'codex']),
60
- model: z.enum(MODEL_ENUM),
61
- maxTokens: z.number().min(256).max(10000000000000).optional(),
62
- }),
63
- judgeAgent: z.object({
64
- provider: z.enum(['claude-code', 'codex']),
65
- model: z.enum(MODEL_ENUM),
66
- maxTokens: z.number().min(256).max(10000000000000).optional(),
67
- reviewThresholdScore: z.number().min(0).max(100),
68
- }),
69
- defaultPrompts: z.object({
70
- systemPrompt: z.string().min(10),
71
- taskPrompt: z.string().min(10),
72
- }),
73
- // Note: Provider binary paths are now stored in local config (.vibeman/.local/)
74
- // This field is kept for backwards compatibility but deprecated
75
- providers: z
76
- .object({
77
- claudeCode: z.object({ binPath: z.string().min(1).optional() }).optional(),
78
- codex: z.object({ binPath: z.string().min(1).optional() }).optional(),
79
- })
80
- .optional(),
81
- routingPolicy: RoutingPolicySettingsSchema,
82
- }),
83
- defaultWorkflow: z.object({
84
- autoQualityChecks: z.boolean(),
85
- requireHumanApproval: z.boolean(),
86
- aiCodeReview: z.boolean(),
87
- maxImplementationAttempts: z.number().min(1).max(10),
88
- autoCommit: z.boolean(),
89
- }),
90
- quality: z
91
- .object({
92
- checks: z.array(z.object({
93
- name: z.string().min(1),
94
- command: z.string().min(1),
95
- args: z.array(z.string()).optional(),
96
- timeout: z
97
- .number()
98
- .min(1000)
99
- .max(10 * 60 * 1000)
100
- .optional(),
101
- enabled: z.boolean().optional(),
102
- })),
103
- })
104
- .optional(),
105
- development: z.object({
106
- vibeDir: z.string().min(1).optional(),
107
- git: z.object({
108
- defaultBranch: z.string().min(1),
109
- worktreePath: z.string().min(1).optional(),
110
- }),
111
- editor: z
112
- .object({
113
- type: z.enum(['vscode', 'cursor', 'vim', 'custom']).optional(),
114
- command: z.string().min(1).optional(),
115
- args: z.array(z.string()).optional(),
116
- name: z.string().min(1).optional(),
117
- openFileCommand: z.array(z.string()).optional(),
118
- openFolderCommand: z.array(z.string()).optional(),
119
- })
120
- .optional(),
121
- terminal: z
122
- .object({
123
- type: z.enum(['system', 'iterm2', 'warp', 'custom']).optional(),
124
- command: z.string().min(1).optional(),
125
- args: z.array(z.string()).optional(),
126
- name: z.string().min(1).optional(),
127
- openCommand: z.array(z.string()).optional(),
128
- })
129
- .optional(),
130
- }),
131
- server: z.object({
132
- port: z.number().min(3000).max(65535),
133
- host: z.string().min(1),
134
- autoOpenBrowser: z.boolean(),
135
- }),
136
- });
137
- // Default settings
138
- const DEFAULT_SETTINGS = {
139
- agents: {
140
- defaultProvider: 'claude-code',
141
- codingAgent: {
142
- provider: 'claude-code',
143
- model: 'claude-sonnet-4-20250514',
144
- },
145
- judgeAgent: {
146
- provider: 'claude-code',
147
- model: 'claude-sonnet-4-20250514',
148
- reviewThresholdScore: 70,
149
- },
150
- defaultPrompts: {
151
- systemPrompt: 'You are a senior software engineer assistant. Follow best practices and write clean, maintainable code.',
152
- taskPrompt: 'Please implement the following task with attention to quality and testing.',
153
- },
154
- providers: {},
155
- routingPolicy: {
156
- defaultProvider: 'claude-code',
157
- operations: {},
158
- },
159
- },
160
- defaultWorkflow: {
161
- autoQualityChecks: true,
162
- requireHumanApproval: true,
163
- aiCodeReview: true,
164
- maxImplementationAttempts: 3,
165
- autoCommit: false,
166
- },
167
- quality: {
168
- checks: [],
169
- },
170
- development: {
171
- git: {
172
- defaultBranch: 'main',
173
- },
174
- editor: {
175
- type: 'vscode',
176
- command: 'code',
177
- args: [],
178
- name: 'Visual Studio Code',
179
- openFileCommand: ['code', '${file}'],
180
- openFolderCommand: ['code', '${folder}'],
181
- },
182
- terminal: {
183
- type: 'system',
184
- command: process.platform === 'darwin'
185
- ? 'open'
186
- : process.platform === 'win32'
187
- ? 'cmd'
188
- : 'gnome-terminal',
189
- args: process.platform === 'darwin' ? ['-a', 'Terminal'] : [],
190
- name: process.platform === 'darwin'
191
- ? 'Terminal'
192
- : process.platform === 'win32'
193
- ? 'Command Prompt'
194
- : 'Terminal',
195
- openCommand: process.platform === 'darwin'
196
- ? ['open', '-a', 'Terminal', '${cwd}']
197
- : process.platform === 'win32'
198
- ? ['cmd', '/c', 'start', 'cmd', '/k', 'cd', '/d', '${cwd}']
199
- : ['gnome-terminal', '--working-directory=${cwd}'],
200
- },
201
- },
202
- server: {
203
- port: 6969,
204
- host: 'localhost',
205
- autoOpenBrowser: true,
206
- },
207
- };
208
- export class SettingsService extends EventEmitter {
209
- constructor(config = {}) {
210
- super();
211
- this.settings = { ...DEFAULT_SETTINGS };
212
- this.initialized = false;
213
- const settingsDir = config.settingsDir ?? '.vibeman';
214
- const settingsFileName = config.settingsFileName ?? 'settings.json';
215
- // Resolve settings path relative to the repo project root (not package CWD)
216
- const projectRoot = getProjectRoot();
217
- this.settingsPath = path.join(projectRoot, settingsDir, settingsFileName);
218
- }
219
- /**
220
- * Initialize the settings service
221
- */
222
- async initialize() {
223
- if (this.initialized)
224
- return;
225
- try {
226
- await this.ensureSettingsDirectory();
227
- await this.loadSettings();
228
- this.initialized = true;
229
- log.info('Settings service initialized', { settingsPath: this.settingsPath }, 'settings-service');
230
- }
231
- catch (error) {
232
- log.error('Failed to initialize settings service', error, 'settings-service');
233
- throw error;
234
- }
235
- }
236
- /**
237
- * Get all current settings
238
- */
239
- getSettings() {
240
- return { ...this.settings };
241
- }
242
- /**
243
- * Get a specific setting by path
244
- */
245
- getSetting(path) {
246
- let current = this.settings;
247
- for (const key of path) {
248
- if (current && typeof current === 'object' && key in current) {
249
- current = current[key];
250
- }
251
- else {
252
- return undefined;
253
- }
254
- }
255
- return current;
256
- }
257
- /**
258
- * Update settings with validation
259
- */
260
- async updateSettings(updates) {
261
- // Create a copy to test updates
262
- const testSettings = JSON.parse(JSON.stringify(this.settings));
263
- const errors = [];
264
- // Apply all updates to test copy
265
- for (const update of updates) {
266
- try {
267
- this.applySingleUpdate(testSettings, update.path, update.value);
268
- }
269
- catch (error) {
270
- errors.push({
271
- path: update.path,
272
- message: error instanceof Error ? error.message : 'Invalid update',
273
- });
274
- }
275
- }
276
- // Validate the entire updated settings object
277
- try {
278
- const validated = VibemanSettingsSchema.parse(testSettings);
279
- if (errors.length === 0) {
280
- // Apply updates to actual settings
281
- this.settings = validated;
282
- await this.saveSettings();
283
- // Emit change events
284
- for (const update of updates) {
285
- this.emit('settingChanged', {
286
- path: update.path,
287
- oldValue: this.getSetting(update.path),
288
- newValue: update.value,
289
- });
290
- }
291
- this.emit('settingsUpdated', this.settings);
292
- return { success: true, errors: [] };
293
- }
294
- }
295
- catch (validationError) {
296
- if (validationError instanceof z.ZodError) {
297
- for (const issue of validationError.issues) {
298
- errors.push({
299
- path: issue.path.map(String),
300
- message: issue.message,
301
- expected: 'Valid value according to schema',
302
- });
303
- }
304
- }
305
- else {
306
- errors.push({
307
- path: [],
308
- message: validationError instanceof Error ? validationError.message : 'Validation failed',
309
- });
310
- }
311
- }
312
- return { success: false, errors };
313
- }
314
- /**
315
- * Reset settings to defaults
316
- */
317
- async resetToDefaults() {
318
- this.settings = { ...DEFAULT_SETTINGS };
319
- await this.saveSettings();
320
- this.emit('settingsReset', this.settings);
321
- log.info('Settings reset to defaults', undefined, 'settings-service');
322
- }
323
- /**
324
- * Validate settings schema
325
- */
326
- validateSettings(settings) {
327
- try {
328
- VibemanSettingsSchema.parse(settings);
329
- return { valid: true, errors: [] };
330
- }
331
- catch (error) {
332
- const errors = [];
333
- if (error instanceof z.ZodError) {
334
- for (const issue of error.issues) {
335
- errors.push({
336
- path: issue.path.map(String),
337
- message: issue.message,
338
- expected: 'Valid value according to schema',
339
- });
340
- }
341
- }
342
- else {
343
- errors.push({
344
- path: [],
345
- message: error instanceof Error ? error.message : 'Validation failed',
346
- });
347
- }
348
- return { valid: false, errors };
349
- }
350
- }
351
- /**
352
- * Get settings file information
353
- */
354
- async getSettingsInfo() {
355
- return {
356
- path: this.settingsPath,
357
- exists: await this.fileExists(this.settingsPath),
358
- };
359
- }
360
- /**
361
- * Get predefined editor configurations
362
- */
363
- getEditorPresets() {
364
- return {
365
- vscode: {
366
- type: 'vscode',
367
- command: 'code',
368
- name: 'Visual Studio Code',
369
- openFileCommand: ['code', '${file}'],
370
- openFolderCommand: ['code', '${folder}'],
371
- },
372
- cursor: {
373
- type: 'cursor',
374
- command: 'cursor',
375
- name: 'Cursor',
376
- openFileCommand: ['cursor', '${file}'],
377
- openFolderCommand: ['cursor', '${folder}'],
378
- },
379
- vim: {
380
- type: 'vim',
381
- command: 'vim',
382
- name: 'Vim',
383
- openFileCommand: ['vim', '${file}'],
384
- openFolderCommand: ['vim', '${folder}'],
385
- },
386
- };
387
- }
388
- /**
389
- * Get predefined terminal configurations
390
- */
391
- getTerminalPresets() {
392
- const platform = process.platform;
393
- return {
394
- system: {
395
- type: 'system',
396
- command: platform === 'darwin' ? 'open' : platform === 'win32' ? 'cmd' : 'gnome-terminal',
397
- args: platform === 'darwin' ? ['-a', 'Terminal'] : [],
398
- name: platform === 'darwin' ? 'Terminal' : platform === 'win32' ? 'Command Prompt' : 'Terminal',
399
- openCommand: platform === 'darwin'
400
- ? ['open', '-a', 'Terminal', '${cwd}']
401
- : platform === 'win32'
402
- ? ['cmd', '/c', 'start', 'cmd', '/k', 'cd', '/d', '${cwd}']
403
- : ['gnome-terminal', '--working-directory=${cwd}'],
404
- },
405
- iterm2: {
406
- type: 'iterm2',
407
- command: 'open',
408
- args: ['-a', 'iTerm'],
409
- name: 'iTerm2',
410
- openCommand: ['open', '-a', 'iTerm', '${cwd}'],
411
- },
412
- warp: {
413
- type: 'warp',
414
- command: 'open',
415
- args: ['-a', 'Warp'],
416
- name: 'Warp',
417
- openCommand: ['open', '-a', 'Warp', '${cwd}'],
418
- },
419
- };
420
- }
421
- /**
422
- * Apply editor preset configuration
423
- */
424
- async applyEditorPreset(presetName) {
425
- const presets = this.getEditorPresets();
426
- const preset = presets[presetName];
427
- if (!preset) {
428
- return {
429
- success: false,
430
- errors: [
431
- { path: ['development', 'editor'], message: `Unknown editor preset: ${presetName}` },
432
- ],
433
- };
434
- }
435
- return this.updateSettings([
436
- {
437
- path: ['development', 'editor'],
438
- value: preset,
439
- },
440
- ]);
441
- }
442
- /**
443
- * Apply terminal preset configuration
444
- */
445
- async applyTerminalPreset(presetName) {
446
- const presets = this.getTerminalPresets();
447
- const preset = presets[presetName];
448
- if (!preset) {
449
- return {
450
- success: false,
451
- errors: [
452
- { path: ['development', 'terminal'], message: `Unknown terminal preset: ${presetName}` },
453
- ],
454
- };
455
- }
456
- return this.updateSettings([
457
- {
458
- path: ['development', 'terminal'],
459
- value: preset,
460
- },
461
- ]);
462
- }
463
- /**
464
- * Generate command to open a file with the configured editor
465
- */
466
- getOpenFileCommand(filePath) {
467
- const editor = this.settings.development?.editor;
468
- if (!editor?.openFileCommand)
469
- return null;
470
- return editor.openFileCommand.map((arg) => arg.replace('${file}', filePath));
471
- }
472
- /**
473
- * Generate command to open a folder with the configured editor
474
- */
475
- getOpenFolderCommand(folderPath) {
476
- const editor = this.settings.development?.editor;
477
- if (!editor?.openFolderCommand)
478
- return null;
479
- return editor.openFolderCommand.map((arg) => arg.replace('${folder}', folderPath));
480
- }
481
- /**
482
- * Generate command to open terminal in specific directory
483
- */
484
- getOpenTerminalCommand(cwd) {
485
- const terminal = this.settings.development?.terminal;
486
- if (!terminal?.openCommand)
487
- return null;
488
- return terminal.openCommand.map((arg) => arg.replace('${cwd}', cwd));
489
- }
490
- /**
491
- * Validate if editor is available on system
492
- */
493
- async validateEditorAvailability() {
494
- const editor = this.settings.development?.editor;
495
- if (!editor?.command) {
496
- return { available: false, error: 'No editor command configured' };
497
- }
498
- try {
499
- const { exec } = await import('child_process');
500
- const { promisify } = await import('util');
501
- const execAsync = promisify(exec);
502
- // Try to get version or check if command exists
503
- await execAsync(`which ${editor.command}`, { timeout: 5000 });
504
- return { available: true };
505
- }
506
- catch {
507
- return {
508
- available: false,
509
- error: `Editor command '${editor.command}' not found in PATH`,
510
- };
511
- }
512
- }
513
- /**
514
- * Validate if terminal is available on system
515
- */
516
- async validateTerminalAvailability() {
517
- const terminal = this.settings.development?.terminal;
518
- if (!terminal?.command) {
519
- return { available: false, error: 'No terminal command configured' };
520
- }
521
- try {
522
- const { exec } = await import('child_process');
523
- const { promisify } = await import('util');
524
- const execAsync = promisify(exec);
525
- // Try to check if command exists
526
- await execAsync(`which ${terminal.command}`, { timeout: 5000 });
527
- return { available: true };
528
- }
529
- catch {
530
- return {
531
- available: false,
532
- error: `Terminal command '${terminal.command}' not found in PATH`,
533
- };
534
- }
535
- }
536
- // Private methods
537
- async ensureSettingsDirectory() {
538
- const settingsDir = path.dirname(this.settingsPath);
539
- try {
540
- await fs.access(settingsDir);
541
- }
542
- catch {
543
- await fs.mkdir(settingsDir, { recursive: true });
544
- log.info('Created settings directory', { settingsDir }, 'settings-service');
545
- }
546
- }
547
- async loadSettings() {
548
- try {
549
- await fs.access(this.settingsPath);
550
- const data = await fs.readFile(this.settingsPath, 'utf-8');
551
- const parsed = JSON.parse(data);
552
- // Validate and merge with defaults
553
- const validated = VibemanSettingsSchema.parse(parsed);
554
- this.settings = this.mergeWithDefaults(validated);
555
- log.info('Settings loaded from file', { settingsPath: this.settingsPath }, 'settings-service');
556
- }
557
- catch (error) {
558
- log.info('Settings file not found or invalid, using defaults', { error: String(error) }, 'settings-service');
559
- this.settings = { ...DEFAULT_SETTINGS };
560
- await this.saveSettings();
561
- }
562
- }
563
- async saveSettings() {
564
- const data = JSON.stringify(this.settings, null, 2);
565
- await fs.writeFile(this.settingsPath, data, 'utf-8');
566
- log.debug('Settings saved to file', { settingsPath: this.settingsPath }, 'settings-service');
567
- }
568
- async fileExists(filePath) {
569
- try {
570
- await fs.access(filePath);
571
- return true;
572
- }
573
- catch {
574
- return false;
575
- }
576
- }
577
- mergeWithDefaults(settings) {
578
- // Deep merge settings with defaults to handle missing properties
579
- return {
580
- ...DEFAULT_SETTINGS,
581
- ...settings,
582
- agents: {
583
- ...DEFAULT_SETTINGS.agents,
584
- ...settings.agents,
585
- codingAgent: {
586
- ...DEFAULT_SETTINGS.agents.codingAgent,
587
- ...settings.agents?.codingAgent,
588
- },
589
- judgeAgent: {
590
- ...DEFAULT_SETTINGS.agents.judgeAgent,
591
- ...settings.agents?.judgeAgent,
592
- },
593
- providers: {
594
- ...(DEFAULT_SETTINGS.agents.providers ?? {}),
595
- ...(settings.agents?.providers ?? {}),
596
- },
597
- defaultPrompts: {
598
- ...DEFAULT_SETTINGS.agents.defaultPrompts,
599
- ...settings.agents?.defaultPrompts,
600
- },
601
- routingPolicy: {
602
- ...DEFAULT_SETTINGS.agents.routingPolicy,
603
- ...settings.agents?.routingPolicy,
604
- operations: {
605
- ...(DEFAULT_SETTINGS.agents.routingPolicy?.operations ?? {}),
606
- ...(settings.agents?.routingPolicy?.operations ?? {}),
607
- },
608
- },
609
- },
610
- defaultWorkflow: {
611
- ...DEFAULT_SETTINGS.defaultWorkflow,
612
- ...settings.defaultWorkflow,
613
- },
614
- quality: {
615
- ...DEFAULT_SETTINGS.quality,
616
- ...settings.quality,
617
- checks: (settings.quality?.checks ?? DEFAULT_SETTINGS.quality?.checks),
618
- },
619
- development: {
620
- ...DEFAULT_SETTINGS.development,
621
- ...settings.development,
622
- git: {
623
- ...DEFAULT_SETTINGS.development.git,
624
- ...settings.development?.git,
625
- },
626
- editor: {
627
- ...DEFAULT_SETTINGS.development.editor,
628
- ...settings.development?.editor,
629
- },
630
- terminal: {
631
- ...DEFAULT_SETTINGS.development.terminal,
632
- ...settings.development?.terminal,
633
- },
634
- },
635
- server: {
636
- ...DEFAULT_SETTINGS.server,
637
- ...settings.server,
638
- },
639
- };
640
- }
641
- applySingleUpdate(target, path, value) {
642
- if (path.length === 0) {
643
- throw new Error('Empty path not allowed');
644
- }
645
- if (path.length === 1) {
646
- target[path[0]] = value;
647
- return;
648
- }
649
- const [head, ...tail] = path;
650
- if (!target[head] || typeof target[head] !== 'object') {
651
- target[head] = {};
652
- }
653
- this.applySingleUpdate(target[head], tail, value);
654
- }
655
- }
656
- // Singleton instance
657
- let settingsService = null;
658
- export function getSettingsService(config) {
659
- settingsService ?? (settingsService = new SettingsService(config));
660
- return settingsService;
661
- }
@@ -1,23 +0,0 @@
1
- import { EventEmitter } from 'events';
2
- export interface FileWatcherOptions {
3
- recursive?: boolean;
4
- debounceMs?: number;
5
- fileFilter?: (filename: string) => boolean;
6
- }
7
- export interface FileChangeEvent {
8
- type: 'created' | 'updated' | 'deleted';
9
- filename: string;
10
- fullPath: string;
11
- }
12
- export declare class FileWatcher extends EventEmitter {
13
- private watcher;
14
- private watchDir;
15
- private options;
16
- private pendingChanges;
17
- constructor(watchDir: string, options?: FileWatcherOptions);
18
- start(): void;
19
- stop(): void;
20
- private debounceFileChange;
21
- private handleFileChange;
22
- private fileExists;
23
- }