vibeman 0.0.0 → 0.0.2

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 (230) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +114 -0
  3. package/dist/runtime/api/.tsbuildinfo +1 -0
  4. package/dist/runtime/api/agent/agent-service.d.ts +224 -0
  5. package/dist/runtime/api/agent/agent-service.js +895 -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 +362 -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 +315 -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 +182 -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 +125 -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 +16 -0
  19. package/dist/runtime/api/agent/parsers.js +308 -0
  20. package/dist/runtime/api/agent/prompt-service.d.ts +30 -0
  21. package/dist/runtime/api/agent/prompt-service.js +449 -0
  22. package/dist/runtime/api/agent/prompt-service.test.d.ts +1 -0
  23. package/dist/runtime/api/agent/prompt-service.test.js +230 -0
  24. package/dist/runtime/api/agent/routing-policy.d.ts +188 -0
  25. package/dist/runtime/api/agent/routing-policy.js +246 -0
  26. package/dist/runtime/api/api/router-helpers.d.ts +32 -0
  27. package/dist/runtime/api/api/router-helpers.js +31 -0
  28. package/dist/runtime/api/api/routers/ai.d.ts +188 -0
  29. package/dist/runtime/api/api/routers/ai.js +395 -0
  30. package/dist/runtime/api/api/routers/executions.d.ts +98 -0
  31. package/dist/runtime/api/api/routers/executions.js +94 -0
  32. package/dist/runtime/api/api/routers/git.d.ts +45 -0
  33. package/dist/runtime/api/api/routers/git.js +35 -0
  34. package/dist/runtime/api/api/routers/provider-config.d.ts +165 -0
  35. package/dist/runtime/api/api/routers/provider-config.js +252 -0
  36. package/dist/runtime/api/api/routers/settings.d.ts +139 -0
  37. package/dist/runtime/api/api/routers/settings.js +113 -0
  38. package/dist/runtime/api/api/routers/tasks.d.ts +141 -0
  39. package/dist/runtime/api/api/routers/tasks.js +238 -0
  40. package/dist/runtime/api/api/routers/workflows.d.ts +267 -0
  41. package/dist/runtime/api/api/routers/workflows.js +310 -0
  42. package/dist/runtime/api/api/routers/worktrees.d.ts +101 -0
  43. package/dist/runtime/api/api/routers/worktrees.js +80 -0
  44. package/dist/runtime/api/api/trpc.d.ts +118 -0
  45. package/dist/runtime/api/api/trpc.js +34 -0
  46. package/dist/runtime/api/index.d.ts +9 -0
  47. package/dist/runtime/api/index.js +117 -0
  48. package/dist/runtime/api/lib/id-generator.d.ts +70 -0
  49. package/dist/runtime/api/lib/id-generator.js +123 -0
  50. package/dist/runtime/api/lib/image-paste-drop-extension.d.ts +26 -0
  51. package/dist/runtime/api/lib/image-paste-drop-extension.js +125 -0
  52. package/dist/runtime/api/lib/local-config.d.ts +245 -0
  53. package/dist/runtime/api/lib/local-config.js +288 -0
  54. package/dist/runtime/api/lib/logger.d.ts +11 -0
  55. package/dist/runtime/api/lib/logger.js +188 -0
  56. package/dist/runtime/api/lib/markdown-utils.d.ts +8 -0
  57. package/dist/runtime/api/lib/markdown-utils.js +282 -0
  58. package/dist/runtime/api/lib/markdown-utils.test.d.ts +1 -0
  59. package/dist/runtime/api/lib/markdown-utils.test.js +348 -0
  60. package/dist/runtime/api/lib/provider-detection.d.ts +59 -0
  61. package/dist/runtime/api/lib/provider-detection.js +244 -0
  62. package/dist/runtime/api/lib/server/agent-service-singleton.d.ts +6 -0
  63. package/dist/runtime/api/lib/server/agent-service-singleton.js +27 -0
  64. package/dist/runtime/api/lib/server/bootstrap.d.ts +38 -0
  65. package/dist/runtime/api/lib/server/bootstrap.js +197 -0
  66. package/dist/runtime/api/lib/server/git-service-singleton.d.ts +6 -0
  67. package/dist/runtime/api/lib/server/git-service-singleton.js +47 -0
  68. package/dist/runtime/api/lib/server/project-root.d.ts +2 -0
  69. package/dist/runtime/api/lib/server/project-root.js +61 -0
  70. package/dist/runtime/api/lib/server/task-service-singleton.d.ts +7 -0
  71. package/dist/runtime/api/lib/server/task-service-singleton.js +58 -0
  72. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.d.ts +7 -0
  73. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.js +57 -0
  74. package/dist/runtime/api/lib/tiptap-utils.clamp-selection.test.d.ts +1 -0
  75. package/dist/runtime/api/lib/tiptap-utils.clamp-selection.test.js +27 -0
  76. package/dist/runtime/api/lib/tiptap-utils.d.ts +130 -0
  77. package/dist/runtime/api/lib/tiptap-utils.js +327 -0
  78. package/dist/runtime/api/lib/trpc/client.d.ts +1 -0
  79. package/dist/runtime/api/lib/trpc/client.js +5 -0
  80. package/dist/runtime/api/lib/trpc/server.d.ts +915 -0
  81. package/dist/runtime/api/lib/trpc/server.js +11 -0
  82. package/dist/runtime/api/lib/trpc/ws-server.d.ts +8 -0
  83. package/dist/runtime/api/lib/trpc/ws-server.js +33 -0
  84. package/dist/runtime/api/persistence/database-service.d.ts +14 -0
  85. package/dist/runtime/api/persistence/database-service.js +74 -0
  86. package/dist/runtime/api/persistence/execution-log-persistence.d.ts +90 -0
  87. package/dist/runtime/api/persistence/execution-log-persistence.js +410 -0
  88. package/dist/runtime/api/persistence/execution-log-persistence.test.d.ts +1 -0
  89. package/dist/runtime/api/persistence/execution-log-persistence.test.js +170 -0
  90. package/dist/runtime/api/router.d.ts +918 -0
  91. package/dist/runtime/api/router.js +34 -0
  92. package/dist/runtime/api/settings-service.d.ts +110 -0
  93. package/dist/runtime/api/settings-service.js +613 -0
  94. package/dist/runtime/api/tasks/file-watcher.d.ts +23 -0
  95. package/dist/runtime/api/tasks/file-watcher.js +88 -0
  96. package/dist/runtime/api/tasks/task-file-parser.d.ts +13 -0
  97. package/dist/runtime/api/tasks/task-file-parser.js +161 -0
  98. package/dist/runtime/api/tasks/task-service.d.ts +36 -0
  99. package/dist/runtime/api/tasks/task-service.js +173 -0
  100. package/dist/runtime/api/types/index.d.ts +179 -0
  101. package/dist/runtime/api/types/index.js +1 -0
  102. package/dist/runtime/api/types/settings.d.ts +81 -0
  103. package/dist/runtime/api/types/settings.js +2 -0
  104. package/dist/runtime/api/types.d.ts +2 -0
  105. package/dist/runtime/api/types.js +1 -0
  106. package/dist/runtime/api/utils/env.d.ts +6 -0
  107. package/dist/runtime/api/utils/env.js +12 -0
  108. package/dist/runtime/api/utils/stripNextEnv.d.ts +7 -0
  109. package/dist/runtime/api/utils/stripNextEnv.js +22 -0
  110. package/dist/runtime/api/utils/title-slug.d.ts +6 -0
  111. package/dist/runtime/api/utils/title-slug.js +77 -0
  112. package/dist/runtime/api/utils/url.d.ts +2 -0
  113. package/dist/runtime/api/utils/url.js +19 -0
  114. package/dist/runtime/api/vcs/git-history-service.d.ts +57 -0
  115. package/dist/runtime/api/vcs/git-history-service.js +228 -0
  116. package/dist/runtime/api/vcs/git-service.d.ts +127 -0
  117. package/dist/runtime/api/vcs/git-service.js +284 -0
  118. package/dist/runtime/api/vcs/worktree-service.d.ts +93 -0
  119. package/dist/runtime/api/vcs/worktree-service.js +506 -0
  120. package/dist/runtime/api/vcs/worktree-service.test.d.ts +1 -0
  121. package/dist/runtime/api/vcs/worktree-service.test.js +20 -0
  122. package/dist/runtime/api/workflows/quality-pipeline.d.ts +58 -0
  123. package/dist/runtime/api/workflows/quality-pipeline.js +400 -0
  124. package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +318 -0
  125. package/dist/runtime/api/workflows/vibing-orchestrator.js +1860 -0
  126. package/dist/runtime/web/.next/BUILD_ID +1 -0
  127. package/dist/runtime/web/.next/app-build-manifest.json +59 -0
  128. package/dist/runtime/web/.next/app-path-routes-manifest.json +7 -0
  129. package/dist/runtime/web/.next/build-manifest.json +33 -0
  130. package/dist/runtime/web/.next/package.json +1 -0
  131. package/dist/runtime/web/.next/prerender-manifest.json +61 -0
  132. package/dist/runtime/web/.next/react-loadable-manifest.json +39 -0
  133. package/dist/runtime/web/.next/required-server-files.json +334 -0
  134. package/dist/runtime/web/.next/routes-manifest.json +62 -0
  135. package/dist/runtime/web/.next/server/app/_not-found/page.js +2 -0
  136. package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +1 -0
  137. package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
  138. package/dist/runtime/web/.next/server/app/_not-found.html +7 -0
  139. package/dist/runtime/web/.next/server/app/_not-found.meta +8 -0
  140. package/dist/runtime/web/.next/server/app/_not-found.rsc +22 -0
  141. package/dist/runtime/web/.next/server/app/api/health/route.js +1 -0
  142. package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +1 -0
  143. package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +1 -0
  144. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +1 -0
  145. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +1 -0
  146. package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +1 -0
  147. package/dist/runtime/web/.next/server/app/api/upload/route.js +1 -0
  148. package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +1 -0
  149. package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +1 -0
  150. package/dist/runtime/web/.next/server/app/index.html +7 -0
  151. package/dist/runtime/web/.next/server/app/index.meta +7 -0
  152. package/dist/runtime/web/.next/server/app/index.rsc +27 -0
  153. package/dist/runtime/web/.next/server/app/page.js +147 -0
  154. package/dist/runtime/web/.next/server/app/page.js.nft.json +1 -0
  155. package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +1 -0
  156. package/dist/runtime/web/.next/server/app-paths-manifest.json +7 -0
  157. package/dist/runtime/web/.next/server/chunks/217.js +1 -0
  158. package/dist/runtime/web/.next/server/chunks/383.js +6 -0
  159. package/dist/runtime/web/.next/server/chunks/458.js +1 -0
  160. package/dist/runtime/web/.next/server/chunks/576.js +18 -0
  161. package/dist/runtime/web/.next/server/chunks/635.js +22 -0
  162. package/dist/runtime/web/.next/server/chunks/761.js +1 -0
  163. package/dist/runtime/web/.next/server/chunks/777.js +3 -0
  164. package/dist/runtime/web/.next/server/chunks/825.js +1 -0
  165. package/dist/runtime/web/.next/server/chunks/838.js +1 -0
  166. package/dist/runtime/web/.next/server/chunks/973.js +15 -0
  167. package/dist/runtime/web/.next/server/functions-config-manifest.json +4 -0
  168. package/dist/runtime/web/.next/server/middleware-build-manifest.js +1 -0
  169. package/dist/runtime/web/.next/server/middleware-manifest.json +6 -0
  170. package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +1 -0
  171. package/dist/runtime/web/.next/server/next-font-manifest.js +1 -0
  172. package/dist/runtime/web/.next/server/next-font-manifest.json +1 -0
  173. package/dist/runtime/web/.next/server/pages/404.html +7 -0
  174. package/dist/runtime/web/.next/server/pages/500.html +1 -0
  175. package/dist/runtime/web/.next/server/pages/_app.js +1 -0
  176. package/dist/runtime/web/.next/server/pages/_app.js.nft.json +1 -0
  177. package/dist/runtime/web/.next/server/pages/_document.js +1 -0
  178. package/dist/runtime/web/.next/server/pages/_document.js.nft.json +1 -0
  179. package/dist/runtime/web/.next/server/pages/_error.js +19 -0
  180. package/dist/runtime/web/.next/server/pages/_error.js.nft.json +1 -0
  181. package/dist/runtime/web/.next/server/pages-manifest.json +6 -0
  182. package/dist/runtime/web/.next/server/server-reference-manifest.js +1 -0
  183. package/dist/runtime/web/.next/server/server-reference-manifest.json +1 -0
  184. package/dist/runtime/web/.next/server/webpack-runtime.js +1 -0
  185. package/dist/runtime/web/.next/static/chunks/18-15c10d3288afef2e.js +1 -0
  186. package/dist/runtime/web/.next/static/chunks/1c0ca389.537bbe362e3ffbd9.js +3 -0
  187. package/dist/runtime/web/.next/static/chunks/22747d63-ad5da0c19f4cfe41.js +71 -0
  188. package/dist/runtime/web/.next/static/chunks/277-0142a939f08738c3.js +63 -0
  189. package/dist/runtime/web/.next/static/chunks/355.056c2645878a799a.js +1 -0
  190. package/dist/runtime/web/.next/static/chunks/420.a5ccf151c9e2b2f1.js +1 -0
  191. package/dist/runtime/web/.next/static/chunks/439.1be0c6242fd248d5.js +15 -0
  192. package/dist/runtime/web/.next/static/chunks/440.c52e7c0f797e22b2.js +1 -0
  193. package/dist/runtime/web/.next/static/chunks/575-e2478287c27da87b.js +1 -0
  194. package/dist/runtime/web/.next/static/chunks/691.920d88c115087314.js +1 -0
  195. package/dist/runtime/web/.next/static/chunks/765-e838910065b50c3d.js +1 -0
  196. package/dist/runtime/web/.next/static/chunks/87c73c54-09e1ba5c70e60a51.js +1 -0
  197. package/dist/runtime/web/.next/static/chunks/891cff7f.0f71fc028f87e683.js +1 -0
  198. package/dist/runtime/web/.next/static/chunks/8bb4d8db-3e2aa02b0a2384b9.js +1 -0
  199. package/dist/runtime/web/.next/static/chunks/9af238c7-271a911d4e99ab18.js +1 -0
  200. package/dist/runtime/web/.next/static/chunks/app/_not-found/page-1cb74d1cba27d0ab.js +1 -0
  201. package/dist/runtime/web/.next/static/chunks/app/api/health/route-105a61ae865ba536.js +1 -0
  202. package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-105a61ae865ba536.js +1 -0
  203. package/dist/runtime/web/.next/static/chunks/app/api/upload/route-105a61ae865ba536.js +1 -0
  204. package/dist/runtime/web/.next/static/chunks/app/layout-8435322f09fd0975.js +1 -0
  205. package/dist/runtime/web/.next/static/chunks/app/page-8c3ba579efc6f918.js +1 -0
  206. package/dist/runtime/web/.next/static/chunks/cac567b0-5b77dd12911823cd.js +1 -0
  207. package/dist/runtime/web/.next/static/chunks/framework-2518f1345b5b2806.js +1 -0
  208. package/dist/runtime/web/.next/static/chunks/main-17665e5e39de9a8a.js +1 -0
  209. package/dist/runtime/web/.next/static/chunks/main-app-c0b0f5ba4f7f9d75.js +1 -0
  210. package/dist/runtime/web/.next/static/chunks/pages/_app-d6f6b3bbc3d81ee1.js +1 -0
  211. package/dist/runtime/web/.next/static/chunks/pages/_error-75a96cf1997cc3b9.js +1 -0
  212. package/dist/runtime/web/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  213. package/dist/runtime/web/.next/static/chunks/webpack-c8de37305b4635cf.js +1 -0
  214. package/dist/runtime/web/.next/static/css/08c950681f1a9a92.css +1 -0
  215. package/dist/runtime/web/.next/static/css/2728291c68f99cb1.css +3 -0
  216. package/dist/runtime/web/.next/static/css/521bd69cc298cd1a.css +1 -0
  217. package/dist/runtime/web/.next/static/css/537e22821e101b87.css +1 -0
  218. package/dist/runtime/web/.next/static/mRpNgPfbYR_0wrODzlg_4/_buildManifest.js +1 -0
  219. package/dist/runtime/web/.next/static/mRpNgPfbYR_0wrODzlg_4/_ssgManifest.js +1 -0
  220. package/dist/runtime/web/.next/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
  221. package/dist/runtime/web/.next/static/media/21350d82a1f187e9-s.woff2 +0 -0
  222. package/dist/runtime/web/.next/static/media/8e9860b6e62d6359-s.woff2 +0 -0
  223. package/dist/runtime/web/.next/static/media/ba9851c3c22cd980-s.woff2 +0 -0
  224. package/dist/runtime/web/.next/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
  225. package/dist/runtime/web/.next/static/media/df0a9ae256c0569c-s.woff2 +0 -0
  226. package/dist/runtime/web/.next/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
  227. package/dist/runtime/web/package.json +65 -0
  228. package/dist/runtime/web/server.js +44 -0
  229. package/dist/tsconfig.tsbuildinfo +1 -0
  230. package/package.json +84 -7
@@ -0,0 +1,27 @@
1
+ import { AgentService } from '../../agent/agent-service.js';
2
+ import { getTaskService } from './task-service-singleton.js';
3
+ import { getSettingsService } from '../../settings-service.js';
4
+ import { getProjectRoot, getVibeDir } from './project-root.js';
5
+ export function getAgentService() {
6
+ if (!globalThis.__vibeman_agent_service__) {
7
+ const taskService = getTaskService();
8
+ const settingsVibeDir = (() => {
9
+ try {
10
+ const svc = getSettingsService();
11
+ const s = svc.getSettings();
12
+ return s?.development?.vibeDir;
13
+ }
14
+ catch {
15
+ return undefined;
16
+ }
17
+ })();
18
+ const projectRoot = getProjectRoot();
19
+ const vibeDir = settingsVibeDir || getVibeDir();
20
+ globalThis.__vibeman_agent_service__ = new AgentService(taskService, projectRoot);
21
+ console.log(`🤖 Agent Service initialized (projectRoot=${projectRoot}, vibeDir=${vibeDir})`);
22
+ }
23
+ return globalThis.__vibeman_agent_service__;
24
+ }
25
+ export function resetAgentService() {
26
+ globalThis.__vibeman_agent_service__ = undefined;
27
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Server Bootstrap - Async-first service initialization
3
+ *
4
+ * Provides ordered initialization of core services before router creation,
5
+ * ensuring all dependencies are ready for synchronous access during runtime.
6
+ */
7
+ import { getSettingsService } from '../../settings-service.js';
8
+ import { TaskService } from '../../tasks/task-service.js';
9
+ import { AgentService } from '../../agent/agent-service.js';
10
+ import { GitService } from '../../vcs/git-service.js';
11
+ import { WorktreeService } from '../../vcs/worktree-service.js';
12
+ import { VibingOrchestrator } from '../../workflows/vibing-orchestrator.js';
13
+ /**
14
+ * Initialize core services in proper dependency order.
15
+ * Must be called before any service getters or router creation.
16
+ */
17
+ export declare function bootstrap(): Promise<void>;
18
+ /**
19
+ * Ready-only sync getters - throw if called before bootstrap
20
+ */
21
+ export declare function getBootstrappedSettingsService(): ReturnType<typeof getSettingsService>;
22
+ export declare function getBootstrappedTaskService(): TaskService;
23
+ export declare function getBootstrappedAgentService(): AgentService;
24
+ export declare function getBootstrappedGitService(): GitService;
25
+ export declare function getBootstrappedWorktreeService(): WorktreeService;
26
+ export declare function getBootstrappedVibingOrchestrator(): VibingOrchestrator;
27
+ /**
28
+ * Get bootstrap completion promise for diagnostics/tests
29
+ */
30
+ export declare function getBootstrapReady(): Promise<void> | null;
31
+ /**
32
+ * Check if bootstrap has completed
33
+ */
34
+ export declare function isBootstrapComplete(): boolean;
35
+ /**
36
+ * Test bootstrap function that initializes against a temp workspace
37
+ */
38
+ export declare function testBootstrap(tempWorkspace?: string): Promise<void>;
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Server Bootstrap - Async-first service initialization
3
+ *
4
+ * Provides ordered initialization of core services before router creation,
5
+ * ensuring all dependencies are ready for synchronous access during runtime.
6
+ */
7
+ import { log } from '../logger.js';
8
+ import { getSettingsService } from '../../settings-service.js';
9
+ import { TaskService } from '../../tasks/task-service.js';
10
+ import { AgentService } from '../../agent/agent-service.js';
11
+ import { GitService } from '../../vcs/git-service.js';
12
+ import { VibingOrchestrator } from '../../workflows/vibing-orchestrator.js';
13
+ import { getProjectRoot, getVibeDir } from './project-root.js';
14
+ // Ready-only service instances - throw if accessed before bootstrap
15
+ let settingsService = null;
16
+ let taskService = null;
17
+ let agentService = null;
18
+ let gitService = null;
19
+ let worktreeService = null;
20
+ let vibingOrchestrator = null;
21
+ // Bootstrap completion promise for diagnostics/tests
22
+ let ready = null;
23
+ let isBootstrapped = false;
24
+ // Default config fallback for VibingOrchestrator
25
+ const getDefaultVibingConfig = () => ({
26
+ autoQualityChecks: true,
27
+ requireHumanApproval: true,
28
+ aiCodeReview: true,
29
+ retryPolicy: { maxImplementationAttempts: 3 },
30
+ autoCommit: false,
31
+ });
32
+ /**
33
+ * Initialize core services in proper dependency order.
34
+ * Must be called before any service getters or router creation.
35
+ */
36
+ export async function bootstrap() {
37
+ if (isBootstrapped) {
38
+ log.info('Bootstrap already completed, skipping');
39
+ return;
40
+ }
41
+ if (ready) {
42
+ log.info('Bootstrap already in progress, waiting...');
43
+ return ready;
44
+ }
45
+ const startTime = Date.now();
46
+ log.info('Starting server bootstrap', {}, 'bootstrap');
47
+ ready = (async () => {
48
+ try {
49
+ // Stage 1: Settings Service (foundation)
50
+ const settingsStart = Date.now();
51
+ settingsService = getSettingsService();
52
+ log.info('Settings service initialized', {
53
+ duration: Date.now() - settingsStart,
54
+ }, 'bootstrap');
55
+ // Stage 2: Task Service (depends on settings for vibeDir)
56
+ const taskStart = Date.now();
57
+ const settingsVibeDir = (() => {
58
+ try {
59
+ const s = settingsService.getSettings();
60
+ return s?.development?.vibeDir;
61
+ }
62
+ catch {
63
+ return undefined;
64
+ }
65
+ })();
66
+ const vibeDir = settingsVibeDir ?? getVibeDir();
67
+ taskService = new TaskService(vibeDir);
68
+ await taskService.ensureInitialized();
69
+ log.info('Task service initialized', {
70
+ vibeDir,
71
+ duration: Date.now() - taskStart,
72
+ }, 'bootstrap');
73
+ // Stage 3: Git Service (independent)
74
+ const gitStart = Date.now();
75
+ const projectRoot = getProjectRoot();
76
+ const settingsDefaultBranch = (() => {
77
+ try {
78
+ const s = settingsService.getSettings();
79
+ return s?.development?.git?.defaultBranch;
80
+ }
81
+ catch {
82
+ return undefined;
83
+ }
84
+ })();
85
+ const gitConfig = {
86
+ defaultBranch: settingsDefaultBranch || 'main',
87
+ };
88
+ gitService = new GitService(projectRoot, gitConfig);
89
+ log.info('Git service initialized', {
90
+ projectRoot,
91
+ defaultBranch: gitConfig.defaultBranch,
92
+ duration: Date.now() - gitStart,
93
+ }, 'bootstrap');
94
+ // Stage 4: Agent Service (depends on task service)
95
+ const agentStart = Date.now();
96
+ agentService = new AgentService(taskService, projectRoot);
97
+ log.info('Agent service initialized', {
98
+ duration: Date.now() - agentStart,
99
+ }, 'bootstrap');
100
+ // Stage 5: Worktree Service (depends on git service, settings)
101
+ const worktreeStart = Date.now();
102
+ worktreeService = agentService.getWorktreeService();
103
+ await worktreeService.initialize();
104
+ log.info('Worktree service initialized', {
105
+ duration: Date.now() - worktreeStart,
106
+ }, 'bootstrap');
107
+ // Stage 6: VibingOrchestrator (depends on all previous services)
108
+ const orchestratorStart = Date.now();
109
+ vibingOrchestrator = new VibingOrchestrator(taskService, agentService, worktreeService, getDefaultVibingConfig(), gitService);
110
+ await vibingOrchestrator.initialize();
111
+ log.info('VibingOrchestrator initialized', {
112
+ duration: Date.now() - orchestratorStart,
113
+ }, 'bootstrap');
114
+ isBootstrapped = true;
115
+ const totalDuration = Date.now() - startTime;
116
+ log.info('Server bootstrap completed', {
117
+ totalDuration,
118
+ stages: 6,
119
+ }, 'bootstrap');
120
+ }
121
+ catch (error) {
122
+ log.error('Server bootstrap failed', error, 'bootstrap');
123
+ throw error;
124
+ }
125
+ })();
126
+ return ready;
127
+ }
128
+ /**
129
+ * Ready-only sync getters - throw if called before bootstrap
130
+ */
131
+ export function getBootstrappedSettingsService() {
132
+ if (!settingsService) {
133
+ throw new Error('Settings service not available - bootstrap() must be called first');
134
+ }
135
+ return settingsService;
136
+ }
137
+ export function getBootstrappedTaskService() {
138
+ if (!taskService) {
139
+ throw new Error('Task service not available - bootstrap() must be called first');
140
+ }
141
+ return taskService;
142
+ }
143
+ export function getBootstrappedAgentService() {
144
+ if (!agentService) {
145
+ throw new Error('Agent service not available - bootstrap() must be called first');
146
+ }
147
+ return agentService;
148
+ }
149
+ export function getBootstrappedGitService() {
150
+ if (!gitService) {
151
+ throw new Error('Git service not available - bootstrap() must be called first');
152
+ }
153
+ return gitService;
154
+ }
155
+ export function getBootstrappedWorktreeService() {
156
+ if (!worktreeService) {
157
+ throw new Error('Worktree service not available - bootstrap() must be called first');
158
+ }
159
+ return worktreeService;
160
+ }
161
+ export function getBootstrappedVibingOrchestrator() {
162
+ if (!vibingOrchestrator) {
163
+ throw new Error('VibingOrchestrator not available - bootstrap() must be called first');
164
+ }
165
+ return vibingOrchestrator;
166
+ }
167
+ /**
168
+ * Get bootstrap completion promise for diagnostics/tests
169
+ */
170
+ export function getBootstrapReady() {
171
+ return ready;
172
+ }
173
+ /**
174
+ * Check if bootstrap has completed
175
+ */
176
+ export function isBootstrapComplete() {
177
+ return isBootstrapped;
178
+ }
179
+ /**
180
+ * Test bootstrap function that initializes against a temp workspace
181
+ */
182
+ export async function testBootstrap(tempWorkspace) {
183
+ // Reset bootstrap state for testing
184
+ settingsService = null;
185
+ taskService = null;
186
+ agentService = null;
187
+ gitService = null;
188
+ worktreeService = null;
189
+ vibingOrchestrator = null;
190
+ ready = null;
191
+ isBootstrapped = false;
192
+ // TODO: Implement temp workspace logic if needed
193
+ if (tempWorkspace) {
194
+ log.info('Test bootstrap with temp workspace', { tempWorkspace }, 'bootstrap');
195
+ }
196
+ return bootstrap();
197
+ }
@@ -0,0 +1,6 @@
1
+ import { GitService, GitConfig } from '../../vcs/git-service.js';
2
+ declare global {
3
+ var __vibeman_git_service__: unknown;
4
+ }
5
+ export declare function getGitService(config?: GitConfig): GitService;
6
+ export declare function resetGitService(): void;
@@ -0,0 +1,47 @@
1
+ import { GitService } from '../../vcs/git-service.js';
2
+ import { getSettingsService } from '../../settings-service.js';
3
+ import { getProjectRoot, getVibeDir } from './project-root.js';
4
+ export function getGitService(config) {
5
+ if (!globalThis.__vibeman_git_service__) {
6
+ // Resolve project root robustly (handles being launched from apps/api)
7
+ const projectRoot = getProjectRoot();
8
+ // Get vibeDir from settings, fallback to detected project .vibeman
9
+ const settingsVibeDir = (() => {
10
+ try {
11
+ const svc = getSettingsService();
12
+ const s = svc.getSettings();
13
+ return s?.development?.vibeDir;
14
+ }
15
+ catch {
16
+ return undefined;
17
+ }
18
+ })();
19
+ const vibeDir = settingsVibeDir || getVibeDir();
20
+ // Prefer settings default branch; fall back to 'main'
21
+ const settingsDefaultBranch = (() => {
22
+ try {
23
+ const svc = getSettingsService();
24
+ // Best effort; initialize may not have been awaited here
25
+ // but service returns defaults if not yet loaded from disk
26
+ const s = svc.getSettings();
27
+ return s?.development?.git?.defaultBranch;
28
+ }
29
+ catch {
30
+ return undefined;
31
+ }
32
+ })();
33
+ const envConfig = {
34
+ defaultBranch: settingsDefaultBranch || 'main',
35
+ };
36
+ globalThis.__vibeman_git_service__ = new GitService(projectRoot, {
37
+ ...envConfig,
38
+ ...config,
39
+ });
40
+ const settingsInfo = { defaultBranch: envConfig.defaultBranch };
41
+ console.log(`🔧 Git Service initialized (root=${projectRoot}, vibeDir=${vibeDir}, defaultBranch=${settingsInfo.defaultBranch})`);
42
+ }
43
+ return globalThis.__vibeman_git_service__;
44
+ }
45
+ export function resetGitService() {
46
+ globalThis.__vibeman_git_service__ = undefined;
47
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getProjectRoot(): string;
2
+ export declare function getVibeDir(): string;
@@ -0,0 +1,61 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ // Find the repository project root by walking up from CWD
4
+ // Preference order:
5
+ // - env VIBEMAN_PROJECT_ROOT
6
+ // - nearest directory containing .git or .vibeman
7
+ // - fallback to process.cwd()
8
+ export function getProjectRoot() {
9
+ const envRoot = process.env.VIBEMAN_PROJECT_ROOT;
10
+ if (envRoot && envRoot.trim().length > 0) {
11
+ const trimmedRoot = envRoot.trim();
12
+ if (path.isAbsolute(trimmedRoot)) {
13
+ return path.normalize(trimmedRoot);
14
+ }
15
+ const baseCandidates = [
16
+ process.env.VIBEMAN_PROJECT_ROOT_BASE,
17
+ process.env.INIT_CWD,
18
+ process.env.PWD,
19
+ process.cwd(),
20
+ ].filter((candidate) => !!candidate && candidate.trim().length > 0);
21
+ let fallbackResolved = null;
22
+ for (const base of baseCandidates) {
23
+ const resolved = path.resolve(base, trimmedRoot);
24
+ if (!fallbackResolved) {
25
+ fallbackResolved = resolved;
26
+ }
27
+ if (fs.existsSync(resolved)) {
28
+ return resolved;
29
+ }
30
+ }
31
+ if (fallbackResolved) {
32
+ return fallbackResolved;
33
+ }
34
+ return path.resolve(trimmedRoot);
35
+ }
36
+ // First preference: directory that contains a .git directory/file
37
+ let dir = process.cwd();
38
+ const { root } = path.parse(dir);
39
+ while (true) {
40
+ if (fs.existsSync(path.join(dir, '.git'))) {
41
+ return dir;
42
+ }
43
+ if (dir === root)
44
+ break;
45
+ dir = path.dirname(dir);
46
+ }
47
+ // Fallback: nearest directory with .vibeman (if repo is checked out without .git, e.g. tarball)
48
+ dir = process.cwd();
49
+ while (true) {
50
+ if (fs.existsSync(path.join(dir, '.vibeman'))) {
51
+ return dir;
52
+ }
53
+ if (dir === root)
54
+ break;
55
+ dir = path.dirname(dir);
56
+ }
57
+ return process.cwd();
58
+ }
59
+ export function getVibeDir() {
60
+ return path.join(getProjectRoot(), '.vibeman');
61
+ }
@@ -0,0 +1,7 @@
1
+ import { TaskService } from '../../tasks/task-service.js';
2
+ declare global {
3
+ var __vibeman_task_service__: unknown;
4
+ var __vibeman_task_service_init__: unknown;
5
+ }
6
+ export declare function getTaskService(): TaskService;
7
+ export declare function getTaskServiceAsync(): Promise<TaskService>;
@@ -0,0 +1,58 @@
1
+ import { getSettingsService } from '../../settings-service.js';
2
+ import { TaskService } from '../../tasks/task-service.js';
3
+ import { isProduction } from '../../utils/env.js';
4
+ import { getVibeDir } from './project-root.js';
5
+ export function getTaskService() {
6
+ if (!globalThis.__vibeman_task_service__) {
7
+ const settingsVibeDir = (() => {
8
+ try {
9
+ const svc = getSettingsService();
10
+ const s = svc.getSettings();
11
+ return s?.development?.vibeDir;
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ })();
17
+ // Ensure we use the repo-level .vibeman even when launched from a subpackage
18
+ const vibeDir = settingsVibeDir ?? getVibeDir();
19
+ globalThis.__vibeman_task_service__ = new TaskService(vibeDir);
20
+ console.log(`🗂️ Task Service initialized (vibeDir=${vibeDir})`);
21
+ globalThis.__vibeman_task_service__
22
+ .ensureInitialized()
23
+ .catch((e) => console.error('TaskService init error:', e));
24
+ }
25
+ return globalThis.__vibeman_task_service__;
26
+ }
27
+ export async function getTaskServiceAsync() {
28
+ if (globalThis.__vibeman_task_service__) {
29
+ return globalThis.__vibeman_task_service__;
30
+ }
31
+ if (!globalThis.__vibeman_task_service_init__) {
32
+ const settingsVibeDir = (() => {
33
+ try {
34
+ const svc = getSettingsService();
35
+ const s = svc.getSettings();
36
+ return s?.development?.vibeDir;
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ })();
42
+ const vibeDir = settingsVibeDir ?? getVibeDir();
43
+ globalThis.__vibeman_task_service__ = new TaskService(vibeDir);
44
+ globalThis.__vibeman_task_service_init__ = globalThis.__vibeman_task_service__
45
+ .initialize()
46
+ .then(() => globalThis.__vibeman_task_service__);
47
+ }
48
+ return globalThis.__vibeman_task_service_init__;
49
+ }
50
+ // Cleanup on process exit
51
+ if (isProduction()) {
52
+ process.on('SIGTERM', () => {
53
+ if (globalThis.__vibeman_task_service__) {
54
+ globalThis.__vibeman_task_service__.stop();
55
+ globalThis.__vibeman_task_service__ = undefined;
56
+ }
57
+ });
58
+ }
@@ -0,0 +1,7 @@
1
+ import { VibingOrchestrator } from '../../workflows/vibing-orchestrator.js';
2
+ declare global {
3
+ var __vibeman_vibing_orchestrator__: unknown;
4
+ var __vibeman_vibing_orchestrator_init__: unknown;
5
+ }
6
+ export declare function getVibingOrchestrator(): VibingOrchestrator;
7
+ export declare function getVibingOrchestratorAsync(): Promise<VibingOrchestrator>;
@@ -0,0 +1,57 @@
1
+ import { VibingOrchestrator } from '../../workflows/vibing-orchestrator.js';
2
+ import { getTaskService } from './task-service-singleton.js';
3
+ import { getAgentService } from './agent-service-singleton.js';
4
+ import { getGitService } from './git-service-singleton.js';
5
+ import { isProduction } from '../../utils/env.js';
6
+ // Default config fallback for VibingOrchestrator
7
+ const getDefaultVibingConfig = () => ({
8
+ autoQualityChecks: true,
9
+ requireHumanApproval: true,
10
+ aiCodeReview: true,
11
+ retryPolicy: { maxImplementationAttempts: 3 },
12
+ autoCommit: false,
13
+ });
14
+ export function getVibingOrchestrator() {
15
+ if (!globalThis.__vibeman_vibing_orchestrator__) {
16
+ const taskService = getTaskService();
17
+ const agentService = getAgentService();
18
+ const gitService = getGitService();
19
+ globalThis.__vibeman_vibing_orchestrator__ = new VibingOrchestrator(taskService, agentService, agentService.getWorktreeService(), getDefaultVibingConfig(), gitService);
20
+ }
21
+ // Kick off one-time initialization in background (non-blocking)
22
+ if (!globalThis.__vibeman_vibing_orchestrator_init__) {
23
+ globalThis.__vibeman_vibing_orchestrator_init__ = globalThis.__vibeman_vibing_orchestrator__
24
+ .initialize()
25
+ .catch((e) => console.error('VibingOrchestrator init error:', e))
26
+ .finally(() => {
27
+ globalThis.__vibeman_vibing_orchestrator_init__ = undefined;
28
+ });
29
+ }
30
+ return globalThis.__vibeman_vibing_orchestrator__;
31
+ }
32
+ export async function getVibingOrchestratorAsync() {
33
+ if (globalThis.__vibeman_vibing_orchestrator__) {
34
+ return globalThis.__vibeman_vibing_orchestrator__;
35
+ }
36
+ if (!globalThis.__vibeman_vibing_orchestrator_init__) {
37
+ const taskService = getTaskService();
38
+ const agentService = getAgentService();
39
+ const gitService = getGitService();
40
+ globalThis.__vibeman_vibing_orchestrator__ = new VibingOrchestrator(taskService, agentService, agentService.getWorktreeService(), getDefaultVibingConfig(), gitService);
41
+ globalThis.__vibeman_vibing_orchestrator_init__ = globalThis.__vibeman_vibing_orchestrator__
42
+ .initialize()
43
+ .catch((e) => console.error('VibingOrchestrator init error:', e));
44
+ }
45
+ await globalThis.__vibeman_vibing_orchestrator_init__;
46
+ return globalThis.__vibeman_vibing_orchestrator__;
47
+ }
48
+ // Cleanup on process exit
49
+ if (isProduction()) {
50
+ process.on('SIGTERM', () => {
51
+ if (globalThis.__vibeman_vibing_orchestrator__) {
52
+ // VibingOrchestrator doesn't have a stop method, but we can clean up the reference
53
+ globalThis.__vibeman_vibing_orchestrator__ = undefined;
54
+ globalThis.__vibeman_vibing_orchestrator_init__ = undefined;
55
+ }
56
+ });
57
+ }
@@ -0,0 +1,27 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { clampSelectionPos } from './tiptap-utils.js';
3
+ describe('clampSelectionPos', () => {
4
+ it('keeps positions within valid range', () => {
5
+ const res = clampSelectionPos(5, 8, 20);
6
+ expect(res).toEqual({ from: 5, to: 8 });
7
+ });
8
+ it('clamps underflow to 1', () => {
9
+ const res = clampSelectionPos(-10, 0, 20);
10
+ expect(res).toEqual({ from: 1, to: 1 });
11
+ });
12
+ it('clamps overflow to doc.nodeSize - 2', () => {
13
+ const res = clampSelectionPos(100, 200, 20);
14
+ // maxPos = 18 for nodeSize 20
15
+ expect(res).toEqual({ from: 18, to: 18 });
16
+ });
17
+ it('orders from/to when anchor > head', () => {
18
+ const res = clampSelectionPos(10, 5, 20);
19
+ expect(res).toEqual({ from: 5, to: 10 });
20
+ });
21
+ it('handles tiny documents safely', () => {
22
+ const res0 = clampSelectionPos(5, 6, 0);
23
+ expect(res0).toEqual({ from: 1, to: 1 });
24
+ const res1 = clampSelectionPos(2, 3, 1);
25
+ expect(res1).toEqual({ from: 1, to: 1 });
26
+ });
27
+ });
@@ -0,0 +1,130 @@
1
+ import type { Node as TiptapNode } from '@tiptap/pm/model';
2
+ import type { Editor } from '@tiptap/react';
3
+ export declare const MAX_FILE_SIZE: number;
4
+ export declare const MAC_SYMBOLS: Record<string, string>;
5
+ export declare function cn(...classes: (string | boolean | undefined | null)[]): string;
6
+ /**
7
+ * Determines if the current platform is macOS
8
+ * @returns boolean indicating if the current platform is Mac
9
+ */
10
+ export declare function isMac(): boolean;
11
+ /**
12
+ * Formats a shortcut key based on the platform (Mac or non-Mac)
13
+ * @param key - The key to format (e.g., "ctrl", "alt", "shift")
14
+ * @param isMac - Boolean indicating if the platform is Mac
15
+ * @param capitalize - Whether to capitalize the key (default: true)
16
+ * @returns Formatted shortcut key symbol
17
+ */
18
+ export declare const formatShortcutKey: (key: string, isMac: boolean, capitalize?: boolean) => string;
19
+ /**
20
+ * Parses a shortcut key string into an array of formatted key symbols
21
+ * @param shortcutKeys - The string of shortcut keys (e.g., "ctrl-alt-shift")
22
+ * @param delimiter - The delimiter used to split the keys (default: "-")
23
+ * @param capitalize - Whether to capitalize the keys (default: true)
24
+ * @returns Array of formatted shortcut key symbols
25
+ */
26
+ export declare const parseShortcutKeys: (props: {
27
+ shortcutKeys: string | undefined;
28
+ delimiter?: string;
29
+ capitalize?: boolean;
30
+ }) => string[];
31
+ /**
32
+ * Checks if a mark exists in the editor schema
33
+ * @param markName - The name of the mark to check
34
+ * @param editor - The editor instance
35
+ * @returns boolean indicating if the mark exists in the schema
36
+ */
37
+ export declare const isMarkInSchema: (markName: string, editor: Editor | null) => boolean;
38
+ /**
39
+ * Checks if a node exists in the editor schema
40
+ * @param nodeName - The name of the node to check
41
+ * @param editor - The editor instance
42
+ * @returns boolean indicating if the node exists in the schema
43
+ */
44
+ export declare const isNodeInSchema: (nodeName: string, editor: Editor | null) => boolean;
45
+ /**
46
+ * Moves the focus to the next node in the editor
47
+ * @param editor - The editor instance
48
+ * @returns boolean indicating if the focus was moved
49
+ */
50
+ export declare function focusNextNode(editor: Editor): boolean;
51
+ /**
52
+ * Checks if a value is a valid number (not null, undefined, or NaN)
53
+ * @param value - The value to check
54
+ * @returns boolean indicating if the value is a valid number
55
+ */
56
+ export declare function isValidPosition(pos: number | null | undefined): pos is number;
57
+ /**
58
+ * Checks if one or more extensions are registered in the Tiptap editor.
59
+ * @param editor - The Tiptap editor instance
60
+ * @param extensionNames - A single extension name or an array of names to check
61
+ * @returns True if at least one of the extensions is available, false otherwise
62
+ */
63
+ export declare function isExtensionAvailable(editor: Editor | null, extensionNames: string | string[]): boolean;
64
+ /**
65
+ * Finds a node at the specified position with error handling
66
+ * @param editor The Tiptap editor instance
67
+ * @param position The position in the document to find the node
68
+ * @returns The node at the specified position, or null if not found
69
+ */
70
+ export declare function findNodeAtPosition(editor: Editor, position: number): TiptapNode | null;
71
+ /**
72
+ * Finds the position and instance of a node in the document
73
+ * @param props Object containing editor, node (optional), and nodePos (optional)
74
+ * @param props.editor The Tiptap editor instance
75
+ * @param props.node The node to find (optional if nodePos is provided)
76
+ * @param props.nodePos The position of the node to find (optional if node is provided)
77
+ * @returns An object with the position and node, or null if not found
78
+ */
79
+ export declare function findNodePosition(props: {
80
+ editor: Editor | null;
81
+ node?: TiptapNode | null;
82
+ nodePos?: number | null;
83
+ }): {
84
+ pos: number;
85
+ node: TiptapNode;
86
+ } | null;
87
+ /**
88
+ * Checks if the current selection in the editor is a node selection of specified types
89
+ * @param editor The Tiptap editor instance
90
+ * @param types An array of node type names to check against
91
+ * @returns boolean indicating if the selected node matches any of the specified types
92
+ */
93
+ export declare function isNodeTypeSelected(editor: Editor | null, types?: string[]): boolean;
94
+ /**
95
+ * Handles image upload with progress tracking and abort capability
96
+ * @param file The file to upload
97
+ * @param onProgress Optional callback for tracking upload progress
98
+ * @param abortSignal Optional AbortSignal for cancelling the upload
99
+ * @returns Promise resolving to the URL of the uploaded image
100
+ */
101
+ export declare const handleImageUpload: (file: File, onProgress?: (_event: {
102
+ progress: number;
103
+ }) => void, abortSignal?: AbortSignal) => Promise<string>;
104
+ type ProtocolOptions = {
105
+ /**
106
+ * The protocol scheme to be registered.
107
+ * @default '''
108
+ * @example 'ftp'
109
+ * @example 'git'
110
+ */
111
+ scheme: string;
112
+ /**
113
+ * If enabled, it allows optional slashes after the protocol.
114
+ * @default false
115
+ * @example true
116
+ */
117
+ optionalSlashes?: boolean;
118
+ };
119
+ type ProtocolConfig = Array<ProtocolOptions | string>;
120
+ export declare function isAllowedUri(uri: string | undefined, protocols?: ProtocolConfig): true | RegExpMatchArray | null;
121
+ export declare function sanitizeUrl(inputUrl: string, baseUrl: string, protocols?: ProtocolConfig): string;
122
+ /**
123
+ * Clamps selection anchor/head to valid [1, doc.nodeSize-2] range.
124
+ * Returns an object compatible with TipTap's setTextSelection input.
125
+ */
126
+ export declare function clampSelectionPos(anchor: number, head: number, docNodeSize: number): {
127
+ from: number;
128
+ to: number;
129
+ };
130
+ export {};