vibeman 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +116 -0
  3. package/dist/runtime/api/.tsbuildinfo +1 -0
  4. package/dist/runtime/api/agent/agent-service.d.ts +226 -0
  5. package/dist/runtime/api/agent/agent-service.js +901 -0
  6. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.d.ts +61 -0
  7. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.js +373 -0
  8. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.d.ts +34 -0
  9. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.js +281 -0
  10. package/dist/runtime/api/agent/ai-providers/index.d.ts +9 -0
  11. package/dist/runtime/api/agent/ai-providers/index.js +7 -0
  12. package/dist/runtime/api/agent/ai-providers/types.d.ts +180 -0
  13. package/dist/runtime/api/agent/ai-providers/types.js +5 -0
  14. package/dist/runtime/api/agent/codex-cli-provider.test.d.ts +1 -0
  15. package/dist/runtime/api/agent/codex-cli-provider.test.js +88 -0
  16. package/dist/runtime/api/agent/core-agent-service.d.ts +119 -0
  17. package/dist/runtime/api/agent/core-agent-service.js +267 -0
  18. package/dist/runtime/api/agent/parsers.d.ts +15 -0
  19. package/dist/runtime/api/agent/parsers.js +241 -0
  20. package/dist/runtime/api/agent/prompt-service.d.ts +17 -0
  21. package/dist/runtime/api/agent/prompt-service.js +340 -0
  22. package/dist/runtime/api/agent/routing-policy.d.ts +188 -0
  23. package/dist/runtime/api/agent/routing-policy.js +246 -0
  24. package/dist/runtime/api/api/router-helpers.d.ts +32 -0
  25. package/dist/runtime/api/api/router-helpers.js +31 -0
  26. package/dist/runtime/api/api/routers/ai.d.ts +188 -0
  27. package/dist/runtime/api/api/routers/ai.js +410 -0
  28. package/dist/runtime/api/api/routers/executions.d.ts +98 -0
  29. package/dist/runtime/api/api/routers/executions.js +103 -0
  30. package/dist/runtime/api/api/routers/git.d.ts +45 -0
  31. package/dist/runtime/api/api/routers/git.js +35 -0
  32. package/dist/runtime/api/api/routers/settings.d.ts +139 -0
  33. package/dist/runtime/api/api/routers/settings.js +113 -0
  34. package/dist/runtime/api/api/routers/tasks.d.ts +141 -0
  35. package/dist/runtime/api/api/routers/tasks.js +238 -0
  36. package/dist/runtime/api/api/routers/workflows.d.ts +268 -0
  37. package/dist/runtime/api/api/routers/workflows.js +308 -0
  38. package/dist/runtime/api/api/routers/worktrees.d.ts +102 -0
  39. package/dist/runtime/api/api/routers/worktrees.js +80 -0
  40. package/dist/runtime/api/api/trpc.d.ts +118 -0
  41. package/dist/runtime/api/api/trpc.js +34 -0
  42. package/dist/runtime/api/index.d.ts +9 -0
  43. package/dist/runtime/api/index.js +125 -0
  44. package/dist/runtime/api/lib/id-generator.d.ts +70 -0
  45. package/dist/runtime/api/lib/id-generator.js +123 -0
  46. package/dist/runtime/api/lib/image-paste-drop-extension.d.ts +26 -0
  47. package/dist/runtime/api/lib/image-paste-drop-extension.js +125 -0
  48. package/dist/runtime/api/lib/logger.d.ts +11 -0
  49. package/dist/runtime/api/lib/logger.js +188 -0
  50. package/dist/runtime/api/lib/markdown-utils.d.ts +8 -0
  51. package/dist/runtime/api/lib/markdown-utils.js +282 -0
  52. package/dist/runtime/api/lib/markdown-utils.test.d.ts +1 -0
  53. package/dist/runtime/api/lib/markdown-utils.test.js +348 -0
  54. package/dist/runtime/api/lib/server/agent-service-singleton.d.ts +6 -0
  55. package/dist/runtime/api/lib/server/agent-service-singleton.js +27 -0
  56. package/dist/runtime/api/lib/server/git-service-singleton.d.ts +6 -0
  57. package/dist/runtime/api/lib/server/git-service-singleton.js +47 -0
  58. package/dist/runtime/api/lib/server/project-root.d.ts +2 -0
  59. package/dist/runtime/api/lib/server/project-root.js +38 -0
  60. package/dist/runtime/api/lib/server/task-service-singleton.d.ts +7 -0
  61. package/dist/runtime/api/lib/server/task-service-singleton.js +58 -0
  62. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.d.ts +7 -0
  63. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.js +57 -0
  64. package/dist/runtime/api/lib/tiptap-utils.clamp-selection.test.d.ts +1 -0
  65. package/dist/runtime/api/lib/tiptap-utils.clamp-selection.test.js +27 -0
  66. package/dist/runtime/api/lib/tiptap-utils.d.ts +130 -0
  67. package/dist/runtime/api/lib/tiptap-utils.js +327 -0
  68. package/dist/runtime/api/lib/trpc/client.d.ts +1 -0
  69. package/dist/runtime/api/lib/trpc/client.js +5 -0
  70. package/dist/runtime/api/lib/trpc/server.d.ts +822 -0
  71. package/dist/runtime/api/lib/trpc/server.js +11 -0
  72. package/dist/runtime/api/lib/trpc/ws-server.d.ts +8 -0
  73. package/dist/runtime/api/lib/trpc/ws-server.js +33 -0
  74. package/dist/runtime/api/persistence/database-service.d.ts +14 -0
  75. package/dist/runtime/api/persistence/database-service.js +74 -0
  76. package/dist/runtime/api/persistence/execution-log-persistence.d.ts +90 -0
  77. package/dist/runtime/api/persistence/execution-log-persistence.js +410 -0
  78. package/dist/runtime/api/persistence/execution-log-persistence.test.d.ts +1 -0
  79. package/dist/runtime/api/persistence/execution-log-persistence.test.js +170 -0
  80. package/dist/runtime/api/router.d.ts +825 -0
  81. package/dist/runtime/api/router.js +56 -0
  82. package/dist/runtime/api/settings-service.d.ts +110 -0
  83. package/dist/runtime/api/settings-service.js +611 -0
  84. package/dist/runtime/api/tasks/file-watcher.d.ts +23 -0
  85. package/dist/runtime/api/tasks/file-watcher.js +88 -0
  86. package/dist/runtime/api/tasks/task-file-parser.d.ts +13 -0
  87. package/dist/runtime/api/tasks/task-file-parser.js +161 -0
  88. package/dist/runtime/api/tasks/task-service.d.ts +36 -0
  89. package/dist/runtime/api/tasks/task-service.js +173 -0
  90. package/dist/runtime/api/types/index.d.ts +179 -0
  91. package/dist/runtime/api/types/index.js +1 -0
  92. package/dist/runtime/api/types/settings.d.ts +81 -0
  93. package/dist/runtime/api/types/settings.js +2 -0
  94. package/dist/runtime/api/types.d.ts +2 -0
  95. package/dist/runtime/api/types.js +1 -0
  96. package/dist/runtime/api/utils/env.d.ts +6 -0
  97. package/dist/runtime/api/utils/env.js +12 -0
  98. package/dist/runtime/api/utils/stripNextEnv.d.ts +7 -0
  99. package/dist/runtime/api/utils/stripNextEnv.js +22 -0
  100. package/dist/runtime/api/utils/title-slug.d.ts +6 -0
  101. package/dist/runtime/api/utils/title-slug.js +77 -0
  102. package/dist/runtime/api/utils/url.d.ts +2 -0
  103. package/dist/runtime/api/utils/url.js +19 -0
  104. package/dist/runtime/api/vcs/git-history-service.d.ts +57 -0
  105. package/dist/runtime/api/vcs/git-history-service.js +228 -0
  106. package/dist/runtime/api/vcs/git-service.d.ts +127 -0
  107. package/dist/runtime/api/vcs/git-service.js +284 -0
  108. package/dist/runtime/api/vcs/worktree-service.d.ts +93 -0
  109. package/dist/runtime/api/vcs/worktree-service.js +506 -0
  110. package/dist/runtime/api/vcs/worktree-service.test.d.ts +1 -0
  111. package/dist/runtime/api/vcs/worktree-service.test.js +20 -0
  112. package/dist/runtime/api/workflows/quality-pipeline.d.ts +58 -0
  113. package/dist/runtime/api/workflows/quality-pipeline.js +400 -0
  114. package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +313 -0
  115. package/dist/runtime/api/workflows/vibing-orchestrator.js +1861 -0
  116. package/dist/runtime/web/.next/BUILD_ID +1 -0
  117. package/dist/runtime/web/.next/app-build-manifest.json +59 -0
  118. package/dist/runtime/web/.next/app-path-routes-manifest.json +7 -0
  119. package/dist/runtime/web/.next/build-manifest.json +33 -0
  120. package/dist/runtime/web/.next/package.json +1 -0
  121. package/dist/runtime/web/.next/prerender-manifest.json +61 -0
  122. package/dist/runtime/web/.next/react-loadable-manifest.json +39 -0
  123. package/dist/runtime/web/.next/required-server-files.json +334 -0
  124. package/dist/runtime/web/.next/routes-manifest.json +62 -0
  125. package/dist/runtime/web/.next/server/app/_not-found/page.js +2 -0
  126. package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +1 -0
  127. package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
  128. package/dist/runtime/web/.next/server/app/_not-found.html +7 -0
  129. package/dist/runtime/web/.next/server/app/_not-found.meta +8 -0
  130. package/dist/runtime/web/.next/server/app/_not-found.rsc +22 -0
  131. package/dist/runtime/web/.next/server/app/api/health/route.js +1 -0
  132. package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +1 -0
  133. package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +1 -0
  134. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +1 -0
  135. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +1 -0
  136. package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +1 -0
  137. package/dist/runtime/web/.next/server/app/api/upload/route.js +1 -0
  138. package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +1 -0
  139. package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +1 -0
  140. package/dist/runtime/web/.next/server/app/index.html +7 -0
  141. package/dist/runtime/web/.next/server/app/index.meta +7 -0
  142. package/dist/runtime/web/.next/server/app/index.rsc +27 -0
  143. package/dist/runtime/web/.next/server/app/page.js +147 -0
  144. package/dist/runtime/web/.next/server/app/page.js.nft.json +1 -0
  145. package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +1 -0
  146. package/dist/runtime/web/.next/server/app-paths-manifest.json +7 -0
  147. package/dist/runtime/web/.next/server/chunks/217.js +1 -0
  148. package/dist/runtime/web/.next/server/chunks/383.js +6 -0
  149. package/dist/runtime/web/.next/server/chunks/458.js +1 -0
  150. package/dist/runtime/web/.next/server/chunks/576.js +18 -0
  151. package/dist/runtime/web/.next/server/chunks/635.js +22 -0
  152. package/dist/runtime/web/.next/server/chunks/761.js +1 -0
  153. package/dist/runtime/web/.next/server/chunks/777.js +3 -0
  154. package/dist/runtime/web/.next/server/chunks/825.js +1 -0
  155. package/dist/runtime/web/.next/server/chunks/838.js +1 -0
  156. package/dist/runtime/web/.next/server/chunks/973.js +15 -0
  157. package/dist/runtime/web/.next/server/functions-config-manifest.json +4 -0
  158. package/dist/runtime/web/.next/server/middleware-build-manifest.js +1 -0
  159. package/dist/runtime/web/.next/server/middleware-manifest.json +6 -0
  160. package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +1 -0
  161. package/dist/runtime/web/.next/server/next-font-manifest.js +1 -0
  162. package/dist/runtime/web/.next/server/next-font-manifest.json +1 -0
  163. package/dist/runtime/web/.next/server/pages/404.html +7 -0
  164. package/dist/runtime/web/.next/server/pages/500.html +1 -0
  165. package/dist/runtime/web/.next/server/pages/_app.js +1 -0
  166. package/dist/runtime/web/.next/server/pages/_app.js.nft.json +1 -0
  167. package/dist/runtime/web/.next/server/pages/_document.js +1 -0
  168. package/dist/runtime/web/.next/server/pages/_document.js.nft.json +1 -0
  169. package/dist/runtime/web/.next/server/pages/_error.js +19 -0
  170. package/dist/runtime/web/.next/server/pages/_error.js.nft.json +1 -0
  171. package/dist/runtime/web/.next/server/pages-manifest.json +6 -0
  172. package/dist/runtime/web/.next/server/server-reference-manifest.js +1 -0
  173. package/dist/runtime/web/.next/server/server-reference-manifest.json +1 -0
  174. package/dist/runtime/web/.next/server/webpack-runtime.js +1 -0
  175. package/dist/runtime/web/.next/static/1HR8N0rJkCvFRtbTPJMyH/_buildManifest.js +1 -0
  176. package/dist/runtime/web/.next/static/1HR8N0rJkCvFRtbTPJMyH/_ssgManifest.js +1 -0
  177. package/dist/runtime/web/.next/static/chunks/18-15c10d3288afef2e.js +1 -0
  178. package/dist/runtime/web/.next/static/chunks/1c0ca389.537bbe362e3ffbd9.js +3 -0
  179. package/dist/runtime/web/.next/static/chunks/22747d63-ad5da0c19f4cfe41.js +71 -0
  180. package/dist/runtime/web/.next/static/chunks/277-0142a939f08738c3.js +63 -0
  181. package/dist/runtime/web/.next/static/chunks/355.056c2645878a799a.js +1 -0
  182. package/dist/runtime/web/.next/static/chunks/420.a5ccf151c9e2b2f1.js +1 -0
  183. package/dist/runtime/web/.next/static/chunks/439.1be0c6242fd248d5.js +15 -0
  184. package/dist/runtime/web/.next/static/chunks/440.c52e7c0f797e22b2.js +1 -0
  185. package/dist/runtime/web/.next/static/chunks/575-e2478287c27da87b.js +1 -0
  186. package/dist/runtime/web/.next/static/chunks/691.920d88c115087314.js +1 -0
  187. package/dist/runtime/web/.next/static/chunks/765-e838910065b50c3d.js +1 -0
  188. package/dist/runtime/web/.next/static/chunks/87c73c54-09e1ba5c70e60a51.js +1 -0
  189. package/dist/runtime/web/.next/static/chunks/891cff7f.0f71fc028f87e683.js +1 -0
  190. package/dist/runtime/web/.next/static/chunks/8bb4d8db-3e2aa02b0a2384b9.js +1 -0
  191. package/dist/runtime/web/.next/static/chunks/9af238c7-271a911d4e99ab18.js +1 -0
  192. package/dist/runtime/web/.next/static/chunks/app/_not-found/page-1cb74d1cba27d0ab.js +1 -0
  193. package/dist/runtime/web/.next/static/chunks/app/api/health/route-105a61ae865ba536.js +1 -0
  194. package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-105a61ae865ba536.js +1 -0
  195. package/dist/runtime/web/.next/static/chunks/app/api/upload/route-105a61ae865ba536.js +1 -0
  196. package/dist/runtime/web/.next/static/chunks/app/layout-dc0cfd29075b2160.js +1 -0
  197. package/dist/runtime/web/.next/static/chunks/app/page-f34a8b196b18850b.js +1 -0
  198. package/dist/runtime/web/.next/static/chunks/cac567b0-5b77dd12911823cd.js +1 -0
  199. package/dist/runtime/web/.next/static/chunks/framework-2518f1345b5b2806.js +1 -0
  200. package/dist/runtime/web/.next/static/chunks/main-17665e5e39de9a8a.js +1 -0
  201. package/dist/runtime/web/.next/static/chunks/main-app-c0b0f5ba4f7f9d75.js +1 -0
  202. package/dist/runtime/web/.next/static/chunks/pages/_app-d6f6b3bbc3d81ee1.js +1 -0
  203. package/dist/runtime/web/.next/static/chunks/pages/_error-75a96cf1997cc3b9.js +1 -0
  204. package/dist/runtime/web/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  205. package/dist/runtime/web/.next/static/chunks/webpack-c8de37305b4635cf.js +1 -0
  206. package/dist/runtime/web/.next/static/css/08c950681f1a9a92.css +1 -0
  207. package/dist/runtime/web/.next/static/css/2728291c68f99cb1.css +3 -0
  208. package/dist/runtime/web/.next/static/css/521bd69cc298cd1a.css +1 -0
  209. package/dist/runtime/web/.next/static/css/537e22821e101b87.css +1 -0
  210. package/dist/runtime/web/.next/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
  211. package/dist/runtime/web/.next/static/media/21350d82a1f187e9-s.woff2 +0 -0
  212. package/dist/runtime/web/.next/static/media/8e9860b6e62d6359-s.woff2 +0 -0
  213. package/dist/runtime/web/.next/static/media/ba9851c3c22cd980-s.woff2 +0 -0
  214. package/dist/runtime/web/.next/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
  215. package/dist/runtime/web/.next/static/media/df0a9ae256c0569c-s.woff2 +0 -0
  216. package/dist/runtime/web/.next/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
  217. package/dist/runtime/web/package.json +65 -0
  218. package/dist/runtime/web/server.js +44 -0
  219. package/dist/tsconfig.tsbuildinfo +1 -0
  220. package/package.json +80 -7
@@ -0,0 +1,80 @@
1
+ import { z } from 'zod';
2
+ import { publicProcedure } from '../trpc.js';
3
+ import { TaskIdSchema, WorktreePathSchema, withErrors } from '../router-helpers.js';
4
+ import { log } from '../../lib/logger.js';
5
+ export function buildWorktreeRoutes({ requireOrchestrator, requireOrchestratorSync }) {
6
+ return {
7
+ listWorktrees: publicProcedure.query(withErrors('list worktrees', 'router:listWorktrees', async () => {
8
+ const orchestrator = await requireOrchestrator();
9
+ return await orchestrator.listWorktrees();
10
+ })),
11
+ syncWorktreeState: publicProcedure.mutation(withErrors('sync worktree state', 'router:syncWorktreeState', async () => {
12
+ const orchestrator = await requireOrchestrator();
13
+ await orchestrator.syncWorktreeState();
14
+ return { success: true, message: 'Worktree state synchronized' };
15
+ })),
16
+ getWorktreeInfo: publicProcedure.input(TaskIdSchema).query(async ({ input }) => {
17
+ const orchestrator = await requireOrchestrator();
18
+ const worktree = orchestrator.getWorktreeInfo(input.taskId);
19
+ if (!worktree)
20
+ return null;
21
+ const { git, ...serializableWorktree } = worktree;
22
+ return serializableWorktree;
23
+ }),
24
+ createWorktree: publicProcedure.input(TaskIdSchema).mutation(async ({ input }) => {
25
+ const orchestrator = await requireOrchestrator();
26
+ const worktree = await orchestrator.createWorktree(input.taskId);
27
+ const { git, ...serializableWorktree } = worktree;
28
+ return serializableWorktree;
29
+ }),
30
+ deleteWorktree: publicProcedure
31
+ .input(z.object({ taskId: z.string(), force: z.coerce.boolean().optional() }))
32
+ .mutation(async ({ input }) => {
33
+ const orchestrator = await requireOrchestrator();
34
+ await orchestrator.deleteWorktree(input.taskId, input.force || false);
35
+ if (orchestrator) {
36
+ await orchestrator.removeWorkflowsByTask(input.taskId);
37
+ }
38
+ return { success: true };
39
+ }),
40
+ openInEditor: publicProcedure.input(WorktreePathSchema).mutation(withErrors('open in editor', 'router:openInEditor', async ({ input }) => {
41
+ const orchestrator = requireOrchestratorSync();
42
+ await orchestrator.openInEditor(input.worktreePath);
43
+ // Ensure we return a clean, serializable object
44
+ return { success: true };
45
+ })),
46
+ openInTerminal: publicProcedure.input(WorktreePathSchema).mutation(withErrors('open in terminal', 'router:openInTerminal', async ({ input }) => {
47
+ const orchestrator = requireOrchestratorSync();
48
+ await orchestrator.openInTerminal(input.worktreePath);
49
+ // Ensure we return a clean, serializable object
50
+ return { success: true };
51
+ })),
52
+ // TODO: Deprecated alias; prefer createPullRequest
53
+ createWorktreePR: publicProcedure
54
+ .input(z.object({ taskId: z.string(), baseBranch: z.string().optional().default('main') }))
55
+ .mutation(async ({ input }) => {
56
+ const orchestrator = await requireOrchestrator();
57
+ log.warn('Deprecated route used: createWorktreePR; prefer createPullRequest', { taskId: input.taskId }, 'router:createWorktreePR');
58
+ return await orchestrator.createPullRequest(input.taskId, input.baseBranch);
59
+ }),
60
+ createPullRequest: publicProcedure
61
+ .input(z.object({ taskId: z.string(), baseBranch: z.string().optional().default('main') }))
62
+ .mutation(withErrors('create pull request', 'router:createPullRequest', async ({ input }) => {
63
+ const orchestrator = await requireOrchestrator();
64
+ return await orchestrator.createPullRequest(input.taskId, input.baseBranch);
65
+ })),
66
+ cleanupWorktree: publicProcedure
67
+ .input(z.object({
68
+ taskId: z.string().optional(),
69
+ worktreePath: z.string().optional(),
70
+ branchName: z.string().optional(),
71
+ isConnectedToTask: z.boolean(),
72
+ force: z.coerce.boolean().optional().default(false),
73
+ }))
74
+ .mutation(async ({ input }) => {
75
+ const orchestrator = await requireOrchestrator();
76
+ await orchestrator.cleanupWorktree(input);
77
+ return { success: true };
78
+ }),
79
+ };
80
+ }
@@ -0,0 +1,118 @@
1
+ import { z } from 'zod';
2
+ import superjson from 'superjson';
3
+ import type { TaskService } from '../tasks/task-service.js';
4
+ export interface Context {
5
+ taskService?: TaskService;
6
+ }
7
+ export declare const t: import("@trpc/server").TRPCRootObject<Context, object, {
8
+ transformer: typeof superjson;
9
+ }, {
10
+ ctx: Context;
11
+ meta: object;
12
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape;
13
+ transformer: true;
14
+ }>;
15
+ export declare const router: import("@trpc/server").TRPCRouterBuilder<{
16
+ ctx: Context;
17
+ meta: object;
18
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape;
19
+ transformer: true;
20
+ }>;
21
+ export declare const publicProcedure: import("@trpc/server").TRPCProcedureBuilder<Context, object, object, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
22
+ export declare const TaskCreateSchema: z.ZodObject<{
23
+ id: z.ZodOptional<z.ZodString>;
24
+ title: z.ZodString;
25
+ type: z.ZodEnum<["feature", "bug", "chore", "refactor", "test", "doc"]>;
26
+ status: z.ZodDefault<z.ZodEnum<["backlog", "in-progress", "review", "done"]>>;
27
+ tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
28
+ due_date: z.ZodOptional<z.ZodString>;
29
+ assignee: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
30
+ priority: z.ZodDefault<z.ZodEnum<["low", "medium", "high"]>>;
31
+ comments: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
32
+ content: z.ZodString;
33
+ }, "strip", z.ZodTypeAny, {
34
+ type: "feature" | "bug" | "chore" | "refactor" | "test" | "doc";
35
+ status: "backlog" | "in-progress" | "review" | "done";
36
+ priority: "low" | "medium" | "high";
37
+ title: string;
38
+ tags: string[];
39
+ assignee: string[];
40
+ comments: string[];
41
+ content: string;
42
+ id?: string | undefined;
43
+ due_date?: string | undefined;
44
+ }, {
45
+ type: "feature" | "bug" | "chore" | "refactor" | "test" | "doc";
46
+ title: string;
47
+ content: string;
48
+ status?: "backlog" | "in-progress" | "review" | "done" | undefined;
49
+ priority?: "low" | "medium" | "high" | undefined;
50
+ id?: string | undefined;
51
+ tags?: string[] | undefined;
52
+ due_date?: string | undefined;
53
+ assignee?: string[] | undefined;
54
+ comments?: string[] | undefined;
55
+ }>;
56
+ export declare const TaskUpdateSchema: z.ZodObject<{
57
+ title: z.ZodOptional<z.ZodString>;
58
+ type: z.ZodOptional<z.ZodEnum<["feature", "bug", "chore", "refactor", "test", "doc"]>>;
59
+ status: z.ZodOptional<z.ZodDefault<z.ZodEnum<["backlog", "in-progress", "review", "done"]>>>;
60
+ tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
61
+ due_date: z.ZodOptional<z.ZodOptional<z.ZodString>>;
62
+ assignee: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
63
+ priority: z.ZodOptional<z.ZodDefault<z.ZodEnum<["low", "medium", "high"]>>>;
64
+ comments: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
65
+ content: z.ZodOptional<z.ZodString>;
66
+ } & {
67
+ id: z.ZodString;
68
+ deleted_at: z.ZodOptional<z.ZodString>;
69
+ }, "strip", z.ZodTypeAny, {
70
+ id: string;
71
+ type?: "feature" | "bug" | "chore" | "refactor" | "test" | "doc" | undefined;
72
+ status?: "backlog" | "in-progress" | "review" | "done" | undefined;
73
+ priority?: "low" | "medium" | "high" | undefined;
74
+ title?: string | undefined;
75
+ tags?: string[] | undefined;
76
+ due_date?: string | undefined;
77
+ assignee?: string[] | undefined;
78
+ comments?: string[] | undefined;
79
+ content?: string | undefined;
80
+ deleted_at?: string | undefined;
81
+ }, {
82
+ id: string;
83
+ type?: "feature" | "bug" | "chore" | "refactor" | "test" | "doc" | undefined;
84
+ status?: "backlog" | "in-progress" | "review" | "done" | undefined;
85
+ priority?: "low" | "medium" | "high" | undefined;
86
+ title?: string | undefined;
87
+ tags?: string[] | undefined;
88
+ due_date?: string | undefined;
89
+ assignee?: string[] | undefined;
90
+ comments?: string[] | undefined;
91
+ content?: string | undefined;
92
+ deleted_at?: string | undefined;
93
+ }>;
94
+ export declare const TaskFilterSchema: z.ZodObject<{
95
+ status: z.ZodOptional<z.ZodEnum<["backlog", "in-progress", "review", "done"]>>;
96
+ type: z.ZodOptional<z.ZodEnum<["feature", "bug", "chore", "refactor", "test", "doc"]>>;
97
+ priority: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
98
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
99
+ search: z.ZodOptional<z.ZodString>;
100
+ includeDeleted: z.ZodOptional<z.ZodBoolean>;
101
+ onlyDeleted: z.ZodOptional<z.ZodBoolean>;
102
+ }, "strip", z.ZodTypeAny, {
103
+ type?: "feature" | "bug" | "chore" | "refactor" | "test" | "doc" | undefined;
104
+ status?: "backlog" | "in-progress" | "review" | "done" | undefined;
105
+ priority?: "low" | "medium" | "high" | undefined;
106
+ search?: string | undefined;
107
+ tags?: string[] | undefined;
108
+ includeDeleted?: boolean | undefined;
109
+ onlyDeleted?: boolean | undefined;
110
+ }, {
111
+ type?: "feature" | "bug" | "chore" | "refactor" | "test" | "doc" | undefined;
112
+ status?: "backlog" | "in-progress" | "review" | "done" | undefined;
113
+ priority?: "low" | "medium" | "high" | undefined;
114
+ search?: string | undefined;
115
+ tags?: string[] | undefined;
116
+ includeDeleted?: boolean | undefined;
117
+ onlyDeleted?: boolean | undefined;
118
+ }>;
@@ -0,0 +1,34 @@
1
+ import { initTRPC } from '@trpc/server';
2
+ import { z } from 'zod';
3
+ import superjson from 'superjson';
4
+ export const t = initTRPC.context().create({
5
+ transformer: superjson,
6
+ });
7
+ export const router = t.router;
8
+ export const publicProcedure = t.procedure;
9
+ // Input validation schemas
10
+ export const TaskCreateSchema = z.object({
11
+ id: z.string().optional(), // Made optional - will be auto-generated if not provided
12
+ title: z.string(),
13
+ type: z.enum(['feature', 'bug', 'chore', 'refactor', 'test', 'doc']),
14
+ status: z.enum(['backlog', 'in-progress', 'review', 'done']).default('backlog'),
15
+ tags: z.array(z.string()).default([]),
16
+ due_date: z.string().optional(),
17
+ assignee: z.array(z.string()).default([]),
18
+ priority: z.enum(['low', 'medium', 'high']).default('medium'),
19
+ comments: z.array(z.string()).default([]),
20
+ content: z.string(),
21
+ });
22
+ export const TaskUpdateSchema = TaskCreateSchema.partial().extend({
23
+ id: z.string(),
24
+ deleted_at: z.string().optional(),
25
+ });
26
+ export const TaskFilterSchema = z.object({
27
+ status: z.enum(['backlog', 'in-progress', 'review', 'done']).optional(),
28
+ type: z.enum(['feature', 'bug', 'chore', 'refactor', 'test', 'doc']).optional(),
29
+ priority: z.enum(['low', 'medium', 'high']).optional(),
30
+ tags: z.array(z.string()).optional(),
31
+ search: z.string().optional(),
32
+ includeDeleted: z.boolean().optional(),
33
+ onlyDeleted: z.boolean().optional(),
34
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Starts a standalone HTTP server that serves tRPC over HTTP and WebSocket on the same port.
3
+ * HTTP endpoint: /trpc
4
+ * WebSocket path: /trpc
5
+ */
6
+ export declare function startApiServer({ port, host }: {
7
+ port: number;
8
+ host: string;
9
+ }): Promise<void>;
@@ -0,0 +1,125 @@
1
+ import { createServer } from 'http';
2
+ import { nodeHTTPRequestHandler } from '@trpc/server/adapters/node-http';
3
+ import { applyWSSHandler } from '@trpc/server/adapters/ws';
4
+ import { WebSocketServer } from 'ws';
5
+ import { appRouter } from './lib/trpc/server.js';
6
+ import { getTaskService } from './lib/server/task-service-singleton.js';
7
+ import { log } from './lib/logger.js';
8
+ import { pathToFileURL } from 'url';
9
+ function getNumberEnv(name, fallback) {
10
+ const raw = process.env[name];
11
+ const n = raw ? Number(raw) : NaN;
12
+ return Number.isFinite(n) ? n : fallback;
13
+ }
14
+ /**
15
+ * Starts a standalone HTTP server that serves tRPC over HTTP and WebSocket on the same port.
16
+ * HTTP endpoint: /trpc
17
+ * WebSocket path: /trpc
18
+ */
19
+ export async function startApiServer({ port, host }) {
20
+ const httpServer = createServer((req, res) => {
21
+ // Basic CORS for local dev
22
+ res.setHeader('Access-Control-Allow-Origin', '*');
23
+ res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS');
24
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization');
25
+ if (req.method === 'OPTIONS') {
26
+ res.writeHead(200);
27
+ res.end();
28
+ return;
29
+ }
30
+ if (req.url?.startsWith('/trpc')) {
31
+ const host = req.headers.host || 'localhost';
32
+ const url = new URL(req.url, `http://${host}`);
33
+ // Strip the /trpc prefix and any leading slash; omit query string
34
+ const rawPath = url.pathname.replace(/^\/trpc\/?/, '');
35
+ const trpcPath = rawPath.replace(/^\/+/, '');
36
+ return nodeHTTPRequestHandler({
37
+ router: appRouter,
38
+ createContext: () => ({ taskService: getTaskService() }),
39
+ req: req,
40
+ res: res,
41
+ path: trpcPath,
42
+ });
43
+ }
44
+ if (req.url === '/api/health') {
45
+ res.writeHead(200, { 'Content-Type': 'application/json' });
46
+ res.end(JSON.stringify({ status: 'ok', timestamp: new Date().toISOString() }));
47
+ return;
48
+ }
49
+ res.writeHead(404, { 'Content-Type': 'application/json' });
50
+ res.end(JSON.stringify({ error: 'Not Found' }));
51
+ });
52
+ // Share same HTTP server for WS, listening on /trpc
53
+ const wss = new WebSocketServer({ noServer: true });
54
+ // Upgrade handler for WebSocket path filtering
55
+ httpServer.on('upgrade', (request, socket, head) => {
56
+ const { url } = request;
57
+ if (!url || !url.startsWith('/trpc')) {
58
+ socket.destroy();
59
+ return;
60
+ }
61
+ wss.handleUpgrade(request, socket, head, (ws) => {
62
+ wss.emit('connection', ws, request);
63
+ });
64
+ });
65
+ // Hook tRPC WS handler
66
+ applyWSSHandler({
67
+ wss,
68
+ router: appRouter,
69
+ createContext: () => ({ taskService: getTaskService() }),
70
+ });
71
+ await new Promise((resolve) => {
72
+ httpServer.listen(port, host, () => resolve());
73
+ });
74
+ const addr = httpServer.address();
75
+ const actualPort = typeof addr === 'object' && addr && 'port' in addr ? addr.port : port;
76
+ log.info('API server listening', { port: actualPort, host, path: '/trpc' }, 'api-server');
77
+ console.log(`📡 API ready at http://${host}:${actualPort}/trpc (HTTP & WS)`);
78
+ // Graceful shutdown
79
+ const shutdown = () => {
80
+ try {
81
+ wss.close();
82
+ }
83
+ catch (error) {
84
+ log.error('Failed to close WebSocket server', error, 'api-server');
85
+ }
86
+ try {
87
+ httpServer.close();
88
+ }
89
+ catch (error) {
90
+ log.error('Failed to close HTTP server', error, 'api-server');
91
+ }
92
+ process.exit(0);
93
+ };
94
+ process.on('SIGINT', shutdown);
95
+ process.on('SIGTERM', shutdown);
96
+ }
97
+ // Self-executing entry when run directly under ESM (e.g., tsx src/index.ts or node dist/index.js)
98
+ try {
99
+ const isMain = process.argv[1] ? pathToFileURL(process.argv[1]).href === import.meta.url : false;
100
+ if (isMain) {
101
+ const host = process.env.HOST || 'localhost';
102
+ const resolveApiPort = async () => {
103
+ // Highest precedence: explicit API port
104
+ const explicit = getNumberEnv('VIBEMAN_API_PORT', NaN);
105
+ if (Number.isFinite(explicit) && explicit > 0)
106
+ return explicit;
107
+ // If PORT (web) is set, use web+1
108
+ const webPort = getNumberEnv('PORT', 0);
109
+ if (webPort > 0)
110
+ return webPort + 1;
111
+ // Default dev behavior: assume web on 3000, so API on 3001
112
+ return 3001;
113
+ };
114
+ (async () => {
115
+ const port = await resolveApiPort();
116
+ startApiServer({ port, host }).catch((err) => {
117
+ console.error('Failed to start API server:', err);
118
+ process.exit(1);
119
+ });
120
+ })();
121
+ }
122
+ }
123
+ catch {
124
+ // ignore
125
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Unified ID generation utility for consistent ID creation across the application
3
+ */
4
+ export type IdPrefix = 'workflow' | 'exec' | 'improve' | 'merge' | 'review' | 'claude' | 'task' | 'session';
5
+ interface IdGeneratorOptions {
6
+ /**
7
+ * Use UUID v4 for guaranteed uniqueness (default: true)
8
+ */
9
+ useUuid?: boolean;
10
+ /**
11
+ * Include timestamp for sortability (default: false)
12
+ */
13
+ includeTimestamp?: boolean;
14
+ /**
15
+ * Custom separator between parts (default: '_')
16
+ */
17
+ separator?: string;
18
+ }
19
+ /**
20
+ * Generate a unique ID with consistent format
21
+ *
22
+ * @param prefix - The prefix to identify the ID type
23
+ * @param options - Configuration options for ID generation
24
+ * @returns A unique identifier string
25
+ *
26
+ * @example
27
+ * generateId('workflow') // 'workflow_550e8400-e29b-41d4-a716-446655440000'
28
+ * generateId('exec', { includeTimestamp: true }) // 'exec_1703123456789_550e8400-e29b-41d4'
29
+ */
30
+ export declare function generateId(prefix: IdPrefix | string, options?: IdGeneratorOptions): string;
31
+ /**
32
+ * Generate a short, human-readable ID (less secure, for display purposes)
33
+ *
34
+ * @param prefix - The prefix to identify the ID type
35
+ * @returns A shorter identifier string
36
+ *
37
+ * @example
38
+ * generateShortId('task') // 'task_a1b2c3d4'
39
+ */
40
+ export declare function generateShortId(prefix: IdPrefix | string): string;
41
+ /**
42
+ * Parse an ID to extract its components
43
+ *
44
+ * @param id - The ID to parse
45
+ * @param separator - The separator used in the ID
46
+ * @returns Parsed components of the ID
47
+ */
48
+ export declare function parseId(id: string, separator?: string): {
49
+ prefix: string;
50
+ timestamp?: number;
51
+ uuid?: string;
52
+ full: string;
53
+ };
54
+ /**
55
+ * Validate if a string is a valid UUID v4
56
+ */
57
+ export declare function isValidUuid(id: string): boolean;
58
+ /**
59
+ * Extract the UUID portion from a prefixed ID
60
+ */
61
+ export declare function extractUuid(id: string): string | null;
62
+ /**
63
+ * Create a batch of IDs efficiently
64
+ */
65
+ export declare function generateBatchIds(prefix: IdPrefix | string, count: number, options?: IdGeneratorOptions): string[];
66
+ /**
67
+ * Generate a deterministic ID based on input (useful for idempotency)
68
+ */
69
+ export declare function generateDeterministicId(prefix: IdPrefix | string, input: string): Promise<string>;
70
+ export {};
@@ -0,0 +1,123 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ /**
3
+ * Generate a unique ID with consistent format
4
+ *
5
+ * @param prefix - The prefix to identify the ID type
6
+ * @param options - Configuration options for ID generation
7
+ * @returns A unique identifier string
8
+ *
9
+ * @example
10
+ * generateId('workflow') // 'workflow_550e8400-e29b-41d4-a716-446655440000'
11
+ * generateId('exec', { includeTimestamp: true }) // 'exec_1703123456789_550e8400-e29b-41d4'
12
+ */
13
+ export function generateId(prefix, options = {}) {
14
+ const { useUuid = true, includeTimestamp = false, separator = '_' } = options;
15
+ const parts = [prefix];
16
+ if (includeTimestamp) {
17
+ // Use high-resolution timestamp for better uniqueness
18
+ parts.push(Date.now().toString());
19
+ }
20
+ if (useUuid) {
21
+ parts.push(uuidv4());
22
+ }
23
+ else {
24
+ // Fallback to crypto.randomUUID if available (browser/Node 19+)
25
+ if (typeof crypto !== 'undefined' && crypto.randomUUID) {
26
+ parts.push(crypto.randomUUID());
27
+ }
28
+ else {
29
+ // Legacy fallback with better entropy
30
+ const timestamp = Date.now();
31
+ const random1 = Math.random().toString(36).substring(2, 11);
32
+ const random2 = Math.random().toString(36).substring(2, 7);
33
+ const counter = getCounter();
34
+ parts.push(`${timestamp.toString(36)}${random1}${random2}${counter.toString(36)}`);
35
+ }
36
+ }
37
+ return parts.join(separator);
38
+ }
39
+ /**
40
+ * Generate a short, human-readable ID (less secure, for display purposes)
41
+ *
42
+ * @param prefix - The prefix to identify the ID type
43
+ * @returns A shorter identifier string
44
+ *
45
+ * @example
46
+ * generateShortId('task') // 'task_a1b2c3d4'
47
+ */
48
+ export function generateShortId(prefix) {
49
+ const timestamp = Date.now().toString(36).slice(-4);
50
+ const random = Math.random().toString(36).substring(2, 6);
51
+ return `${prefix}_${timestamp}${random}`;
52
+ }
53
+ /**
54
+ * Parse an ID to extract its components
55
+ *
56
+ * @param id - The ID to parse
57
+ * @param separator - The separator used in the ID
58
+ * @returns Parsed components of the ID
59
+ */
60
+ export function parseId(id, separator = '_') {
61
+ const parts = id.split(separator);
62
+ const result = {
63
+ prefix: parts[0] || '',
64
+ full: id,
65
+ };
66
+ // Check if second part is a timestamp (13+ digit number for millisecond timestamps)
67
+ // This avoids treating short numbers like "123" as timestamps
68
+ if (parts[1] && /^\d{13,}$/.test(parts[1])) {
69
+ result.timestamp = parseInt(parts[1], 10);
70
+ // When timestamp is present, UUID is the third part onward
71
+ result.uuid = parts.slice(2).join(separator);
72
+ }
73
+ else {
74
+ // No timestamp, so UUID is everything after the prefix
75
+ result.uuid = parts.slice(1).join(separator);
76
+ }
77
+ return result;
78
+ }
79
+ /**
80
+ * Validate if a string is a valid UUID v4
81
+ */
82
+ export function isValidUuid(id) {
83
+ const uuidV4Regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
84
+ return uuidV4Regex.test(id);
85
+ }
86
+ /**
87
+ * Extract the UUID portion from a prefixed ID
88
+ */
89
+ export function extractUuid(id) {
90
+ const parts = id.split('_');
91
+ const lastPart = parts[parts.length - 1];
92
+ return isValidUuid(lastPart) ? lastPart : null;
93
+ }
94
+ // Counter for additional entropy in fallback ID generation
95
+ let counter = 0;
96
+ function getCounter() {
97
+ counter = (counter + 1) % 10000;
98
+ return counter;
99
+ }
100
+ /**
101
+ * Create a batch of IDs efficiently
102
+ */
103
+ export function generateBatchIds(prefix, count, options) {
104
+ return Array.from({ length: count }, () => generateId(prefix, options));
105
+ }
106
+ /**
107
+ * Generate a deterministic ID based on input (useful for idempotency)
108
+ */
109
+ export async function generateDeterministicId(prefix, input) {
110
+ // Use Web Crypto API if available
111
+ if (typeof crypto !== 'undefined' && crypto.subtle) {
112
+ const encoder = new TextEncoder();
113
+ const data = encoder.encode(input);
114
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data);
115
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
116
+ const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
117
+ return `${prefix}_${hashHex.substring(0, 32)}`;
118
+ }
119
+ // Fallback for Node.js
120
+ const cryptoModule = await import('crypto');
121
+ const hash = cryptoModule.createHash('sha256').update(input).digest('hex');
122
+ return `${prefix}_${hash.substring(0, 32)}`;
123
+ }
@@ -0,0 +1,26 @@
1
+ import { Extension } from '@tiptap/core';
2
+ export interface ImagePasteDropOptions {
3
+ /**
4
+ * Function that handles the image upload process
5
+ */
6
+ upload?: (file: File, onProgress?: (event: {
7
+ progress: number;
8
+ }) => void, abortSignal?: AbortSignal) => Promise<string>;
9
+ /**
10
+ * Callback for upload errors
11
+ */
12
+ onError?: (error: Error) => void;
13
+ /**
14
+ * Callback for successful uploads
15
+ */
16
+ onSuccess?: (url: string) => void;
17
+ /**
18
+ * Maximum file size in bytes
19
+ */
20
+ maxSize?: number;
21
+ /**
22
+ * Allowed MIME types
23
+ */
24
+ allowedTypes?: string[];
25
+ }
26
+ export declare const ImagePasteDrop: Extension<ImagePasteDropOptions, any>;