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,88 @@
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+ import { EventEmitter } from 'events';
4
+ import { log } from '../lib/logger.js';
5
+ export class FileWatcher extends EventEmitter {
6
+ constructor(watchDir, options = {}) {
7
+ super();
8
+ this.watcher = null;
9
+ this.pendingChanges = new Map();
10
+ this.watchDir = path.resolve(watchDir);
11
+ this.options = {
12
+ recursive: false,
13
+ debounceMs: 100,
14
+ fileFilter: () => true,
15
+ ...options,
16
+ };
17
+ }
18
+ start() {
19
+ if (this.watcher) {
20
+ return;
21
+ }
22
+ // Check if directory exists
23
+ if (!fs.existsSync(this.watchDir)) {
24
+ const error = new Error(`Watch directory does not exist: ${this.watchDir}`);
25
+ log.error('FileWatcher start failed', error, 'file-watcher');
26
+ this.emit('error', error);
27
+ return;
28
+ }
29
+ this.watcher = fs.watch(this.watchDir, { recursive: this.options.recursive }, (eventType, filename) => {
30
+ if (filename && this.options.fileFilter(filename)) {
31
+ this.debounceFileChange(filename);
32
+ }
33
+ });
34
+ log.debug('FileWatcher started', { watchDir: this.watchDir }, 'file-watcher');
35
+ }
36
+ stop() {
37
+ if (this.watcher) {
38
+ this.watcher.close();
39
+ this.watcher = null;
40
+ // Clear all pending timeouts
41
+ for (const timeout of this.pendingChanges.values()) {
42
+ clearTimeout(timeout);
43
+ }
44
+ this.pendingChanges.clear();
45
+ log.info('FileWatcher stopped', { watchDir: this.watchDir }, 'file-watcher');
46
+ }
47
+ }
48
+ debounceFileChange(filename) {
49
+ // Clear any existing timeout for this file
50
+ const existingTimeout = this.pendingChanges.get(filename);
51
+ if (existingTimeout) {
52
+ clearTimeout(existingTimeout);
53
+ }
54
+ // Set a new timeout to handle the change after a short delay
55
+ const timeout = setTimeout(() => {
56
+ this.handleFileChange(filename);
57
+ this.pendingChanges.delete(filename);
58
+ }, this.options.debounceMs);
59
+ this.pendingChanges.set(filename, timeout);
60
+ }
61
+ async handleFileChange(filename) {
62
+ const fullPath = path.join(this.watchDir, filename);
63
+ try {
64
+ const fileExists = await this.fileExists(fullPath);
65
+ const changeType = fileExists ? 'updated' : 'deleted';
66
+ const event = {
67
+ type: changeType,
68
+ filename,
69
+ fullPath,
70
+ };
71
+ this.emit('fileChanged', event);
72
+ log.debug(`File ${changeType}: ${filename}`, { filename, fullPath, type: changeType }, 'file-watcher');
73
+ }
74
+ catch (error) {
75
+ log.error(`Error processing file change for ${filename}`, error, 'file-watcher');
76
+ this.emit('error', error);
77
+ }
78
+ }
79
+ async fileExists(filePath) {
80
+ try {
81
+ await fs.promises.access(filePath);
82
+ return true;
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,13 @@
1
+ import { Task } from '../types/index.js';
2
+ export declare class TaskFileParser {
3
+ private baseDir;
4
+ constructor(baseDir: string);
5
+ parseFile(filePath: string): Promise<Task | null>;
6
+ parseDirectory(dirPath?: string): Promise<Task[]>;
7
+ parseContent(content: string, filePath?: string): Promise<Task | null>;
8
+ private getFileStats;
9
+ writeTask(task: Task): Promise<void>;
10
+ deleteTask(taskId: string): Promise<void>;
11
+ generateFilePath(task: Task): string;
12
+ generateFilePathFromId(taskId: string): string;
13
+ }
@@ -0,0 +1,161 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import matter from 'gray-matter';
4
+ import { log } from '../lib/logger.js';
5
+ export class TaskFileParser {
6
+ constructor(baseDir) {
7
+ this.baseDir = baseDir;
8
+ }
9
+ async parseFile(filePath) {
10
+ try {
11
+ const content = await fs.readFile(filePath, 'utf-8');
12
+ return await this.parseContent(content, filePath);
13
+ }
14
+ catch (error) {
15
+ log.error(`Error reading file ${filePath}`, error, 'task-file-parser:parseFile');
16
+ return null;
17
+ }
18
+ }
19
+ async parseDirectory(dirPath) {
20
+ const targetDir = dirPath || this.baseDir;
21
+ try {
22
+ const files = await fs.readdir(targetDir);
23
+ const markdownFiles = files.filter((file) => file.endsWith('.md'));
24
+ const tasks = [];
25
+ for (const file of markdownFiles) {
26
+ const filePath = path.join(targetDir, file);
27
+ const task = await this.parseFile(filePath);
28
+ if (task) {
29
+ tasks.push(task);
30
+ }
31
+ }
32
+ // Sort by ID for consistent ordering
33
+ return tasks.sort((a, b) => a.id.localeCompare(b.id));
34
+ }
35
+ catch (error) {
36
+ log.error(`Error reading directory ${targetDir}`, error, 'task-file-parser:parseDirectory');
37
+ return [];
38
+ }
39
+ }
40
+ async parseContent(content, filePath) {
41
+ try {
42
+ const parsed = matter(content);
43
+ const metadata = parsed.data;
44
+ // Validate required fields
45
+ if (!metadata.id || !metadata.title || !metadata.type || !metadata.status) {
46
+ log.error(`Invalid task metadata in ${filePath}`, { metadata, filePath }, 'task-file-parser:parseContent');
47
+ return null;
48
+ }
49
+ // Validate enum values
50
+ const validTypes = ['feature', 'bug', 'chore', 'refactor', 'test', 'doc'];
51
+ const validStatuses = ['backlog', 'in-progress', 'review', 'done'];
52
+ const validPriorities = ['low', 'medium', 'high'];
53
+ if (!validTypes.includes(metadata.type)) {
54
+ log.error(`Invalid task type '${metadata.type}' in ${filePath}`, { type: metadata.type, filePath, validTypes }, 'task-file-parser:parseContent');
55
+ return null;
56
+ }
57
+ if (!validStatuses.includes(metadata.status)) {
58
+ log.error(`Invalid task status '${metadata.status}' in ${filePath}`, { status: metadata.status, filePath, validStatuses }, 'task-file-parser:parseContent');
59
+ return null;
60
+ }
61
+ if (metadata.priority && !validPriorities.includes(metadata.priority)) {
62
+ log.error(`Invalid task priority '${metadata.priority}' in ${filePath}`, { priority: metadata.priority, filePath, validPriorities }, 'task-file-parser:parseContent');
63
+ return null;
64
+ }
65
+ const now = new Date().toISOString();
66
+ const stats = filePath ? await this.getFileStats(filePath) : null;
67
+ const task = {
68
+ id: metadata.id,
69
+ title: metadata.title,
70
+ type: metadata.type,
71
+ status: metadata.status,
72
+ tags: Array.isArray(metadata.tags) ? metadata.tags : [],
73
+ due_date: metadata.due_date
74
+ ? metadata.due_date instanceof Date
75
+ ? metadata.due_date.toISOString().split('T')[0]
76
+ : String(metadata.due_date)
77
+ : undefined,
78
+ assignee: Array.isArray(metadata.assignee)
79
+ ? metadata.assignee
80
+ : metadata.assignee
81
+ ? [metadata.assignee]
82
+ : [],
83
+ priority: metadata.priority || 'medium',
84
+ comments: Array.isArray(metadata.comments)
85
+ ? metadata.comments
86
+ : metadata.comments
87
+ ? [metadata.comments]
88
+ : [],
89
+ deleted_at: metadata.deleted_at ? String(metadata.deleted_at) : undefined,
90
+ content: parsed.content.trim(),
91
+ created_at: stats?.birthtime && !isNaN(stats.birthtime.getTime())
92
+ ? stats.birthtime.toISOString()
93
+ : now,
94
+ updated_at: stats?.mtime && !isNaN(stats.mtime.getTime()) ? stats.mtime.toISOString() : now,
95
+ };
96
+ return task;
97
+ }
98
+ catch (error) {
99
+ log.error(`Error parsing task content from ${filePath}`, error, 'task-file-parser:parseContent');
100
+ return null;
101
+ }
102
+ }
103
+ async getFileStats(filePath) {
104
+ try {
105
+ return await fs.stat(filePath);
106
+ }
107
+ catch {
108
+ return null;
109
+ }
110
+ }
111
+ async writeTask(task) {
112
+ const filePath = this.generateFilePath(task);
113
+ const frontMatter = {
114
+ id: task.id,
115
+ title: task.title,
116
+ type: task.type,
117
+ status: task.status,
118
+ tags: task.tags.join(', ') || '',
119
+ due_date: task.due_date || '',
120
+ assignee: task.assignee?.join(', ') || '',
121
+ priority: task.priority,
122
+ comments: task.comments?.join(', ') || '',
123
+ deleted_at: task.deleted_at || '',
124
+ };
125
+ // Compose the file so there is always exactly one blank line
126
+ // between the front matter and the content body.
127
+ // 1) Build only front matter
128
+ let fmOnly = matter.stringify('', frontMatter);
129
+ // 2) Normalize trailing newlines on FM to exactly one
130
+ fmOnly = fmOnly.replace(/\n*$/, '\n');
131
+ // 3) Normalize leading newlines on body
132
+ const body = (task.content || '').replace(/^[\r\n]+/, '');
133
+ // 4) Join with exactly one extra newline to create a single blank line
134
+ const fileContent = body ? fmOnly + '\n' + body : fmOnly;
135
+ try {
136
+ await fs.writeFile(filePath, fileContent, 'utf-8');
137
+ }
138
+ catch (error) {
139
+ log.error(`Error writing task file ${filePath}`, error, 'task-file-parser:writeTask');
140
+ throw error;
141
+ }
142
+ }
143
+ async deleteTask(taskId) {
144
+ const filePath = this.generateFilePathFromId(taskId);
145
+ try {
146
+ await fs.unlink(filePath);
147
+ }
148
+ catch (error) {
149
+ log.error(`Error deleting task file ${filePath}`, error, 'task-file-parser:deleteTask');
150
+ throw error;
151
+ }
152
+ }
153
+ generateFilePath(task) {
154
+ const fileName = `${task.id}.md`;
155
+ return path.join(this.baseDir, fileName);
156
+ }
157
+ generateFilePathFromId(taskId) {
158
+ const fileName = `${taskId}.md`;
159
+ return path.join(this.baseDir, fileName);
160
+ }
161
+ }
@@ -0,0 +1,36 @@
1
+ import { EventEmitter } from 'events';
2
+ import { Task } from '../types/index.js';
3
+ export declare class TaskService extends EventEmitter {
4
+ private tasks;
5
+ private fileWatcher;
6
+ private taskParser;
7
+ private tasksDir;
8
+ private initialized;
9
+ constructor(vibeDir: string);
10
+ private handleFileChange;
11
+ private extractTaskIdFromFilename;
12
+ initialize(): Promise<void>;
13
+ ensureInitialized(): Promise<void>;
14
+ stop(): void;
15
+ getAllTasks(): Task[];
16
+ getActiveTasks(): Task[];
17
+ getTask(id: string): Task | undefined;
18
+ getTasksByStatus(status: Task['status']): Task[];
19
+ getTasksByType(type: Task['type']): Task[];
20
+ searchTasks(query: string): Task[];
21
+ createTask(taskData: Omit<Task, 'id' | 'created_at' | 'updated_at'> & {
22
+ id?: string;
23
+ }): Promise<Task>;
24
+ updateTask(id: string, updates: Partial<Task>): Promise<Task>;
25
+ deleteTask(id: string): Promise<void>;
26
+ moveTask(id: string, newStatus: Task['status']): Promise<Task>;
27
+ getTaskStats(): {
28
+ total: number;
29
+ backlog: number;
30
+ 'in-progress': number;
31
+ review: number;
32
+ done: number;
33
+ byType: Record<Task["type"], number>;
34
+ byPriority: Record<Task["priority"], number>;
35
+ };
36
+ }
@@ -0,0 +1,173 @@
1
+ import { EventEmitter } from 'events';
2
+ import { FileWatcher } from './file-watcher.js';
3
+ import { TaskFileParser } from './task-file-parser.js';
4
+ import { generateHumanTaskId } from '../utils/title-slug.js';
5
+ import { log } from '../lib/logger.js';
6
+ import fs from 'fs/promises';
7
+ export class TaskService extends EventEmitter {
8
+ constructor(vibeDir) {
9
+ super();
10
+ this.tasks = new Map();
11
+ this.initialized = false;
12
+ this.tasksDir = `${vibeDir}/tasks`;
13
+ this.fileWatcher = new FileWatcher(this.tasksDir, {
14
+ fileFilter: (filename) => filename.endsWith('.md'),
15
+ });
16
+ this.taskParser = new TaskFileParser(this.tasksDir);
17
+ this.fileWatcher.on('fileChanged', async (event) => {
18
+ try {
19
+ await this.handleFileChange(event);
20
+ }
21
+ catch (error) {
22
+ log.error('Error handling file change', error, 'task-service');
23
+ this.emit('error', error);
24
+ }
25
+ });
26
+ this.fileWatcher.on('error', (error) => {
27
+ log.error('FileWatcher error', error, 'task-service');
28
+ this.emit('error', error);
29
+ });
30
+ }
31
+ async handleFileChange(event) {
32
+ const { type, filename, fullPath } = event;
33
+ if (type === 'deleted') {
34
+ const taskId = this.extractTaskIdFromFilename(filename);
35
+ if (taskId && this.tasks.has(taskId)) {
36
+ this.tasks.delete(taskId);
37
+ this.emit('taskDeleted', taskId);
38
+ log.info('Task deleted', { taskId }, 'task-service');
39
+ }
40
+ }
41
+ else {
42
+ // File exists, parse and update
43
+ const task = await this.taskParser.parseFile(fullPath);
44
+ if (task) {
45
+ this.tasks.set(task.id, task);
46
+ this.emit('taskUpdated', task);
47
+ log.info(`Task updated from file change: ${task.id}`, { taskId: task.id, filename }, 'task-service');
48
+ }
49
+ else {
50
+ log.warn(`Failed to parse task from ${filename}`, { filename }, 'task-service');
51
+ }
52
+ }
53
+ }
54
+ extractTaskIdFromFilename(filename) {
55
+ // Use the basename (without extension) as ID, supports multi-hyphen IDs
56
+ return filename.endsWith('.md') ? filename.slice(0, -3) : null;
57
+ }
58
+ async initialize() {
59
+ if (this.initialized) {
60
+ return;
61
+ }
62
+ // Ensure directories exist
63
+ await fs.mkdir(this.tasksDir, { recursive: true });
64
+ // Load existing tasks
65
+ const tasks = await this.taskParser.parseDirectory();
66
+ for (const task of tasks) {
67
+ this.tasks.set(task.id, task);
68
+ }
69
+ // Start file watcher
70
+ this.fileWatcher.start();
71
+ this.initialized = true;
72
+ }
73
+ async ensureInitialized() {
74
+ if (!this.initialized) {
75
+ await this.initialize();
76
+ }
77
+ }
78
+ stop() {
79
+ this.fileWatcher.stop();
80
+ this.tasks.clear();
81
+ this.initialized = false;
82
+ log.info('Task Service stopped', undefined, 'task-service');
83
+ }
84
+ // Task CRUD operations
85
+ getAllTasks() {
86
+ return Array.from(this.tasks.values());
87
+ }
88
+ // Get all non-deleted tasks (excludes soft-deleted tasks)
89
+ getActiveTasks() {
90
+ return Array.from(this.tasks.values()).filter((task) => !task.deleted_at);
91
+ }
92
+ getTask(id) {
93
+ return this.tasks.get(id);
94
+ }
95
+ getTasksByStatus(status) {
96
+ return this.getAllTasks().filter((task) => task.status === status);
97
+ }
98
+ getTasksByType(type) {
99
+ return this.getAllTasks().filter((task) => task.type === type);
100
+ }
101
+ searchTasks(query) {
102
+ const searchTerm = query.toLowerCase();
103
+ return this.getAllTasks().filter((task) => task.title.toLowerCase().includes(searchTerm) ||
104
+ task.content.toLowerCase().includes(searchTerm) ||
105
+ task.tags.some((tag) => tag.toLowerCase().includes(searchTerm)));
106
+ }
107
+ async createTask(taskData) {
108
+ const now = new Date().toISOString();
109
+ // Generate human-readable ID if not provided
110
+ const id = taskData.id ||
111
+ generateHumanTaskId(taskData.type, taskData.title, Array.from(this.tasks.keys()));
112
+ const task = {
113
+ ...taskData,
114
+ id,
115
+ created_at: now,
116
+ updated_at: now,
117
+ };
118
+ // Write to file system (watcher will update memory)
119
+ await this.taskParser.writeTask(task);
120
+ return task;
121
+ }
122
+ async updateTask(id, updates) {
123
+ const existingTask = this.tasks.get(id);
124
+ if (!existingTask) {
125
+ throw new Error(`Task ${id} not found`);
126
+ }
127
+ const updatedTask = {
128
+ ...existingTask,
129
+ ...updates,
130
+ id, // Ensure ID cannot be changed
131
+ updated_at: new Date().toISOString(),
132
+ };
133
+ // Write to file system (watcher will update memory)
134
+ await this.taskParser.writeTask(updatedTask);
135
+ return updatedTask;
136
+ }
137
+ async deleteTask(id) {
138
+ const existingTask = this.tasks.get(id);
139
+ if (!existingTask) {
140
+ throw new Error(`Task ${id} not found`);
141
+ }
142
+ // Soft delete: mark deleted_at and write file
143
+ const softDeleted = {
144
+ ...existingTask,
145
+ deleted_at: new Date().toISOString(),
146
+ };
147
+ await this.taskParser.writeTask(softDeleted);
148
+ // Update in-memory map and emit update event for subscribers
149
+ this.tasks.set(id, softDeleted);
150
+ this.emit('taskUpdated', softDeleted);
151
+ }
152
+ async moveTask(id, newStatus) {
153
+ return this.updateTask(id, { status: newStatus });
154
+ }
155
+ getTaskStats() {
156
+ const tasks = this.getAllTasks();
157
+ const stats = {
158
+ total: tasks.length,
159
+ backlog: 0,
160
+ 'in-progress': 0,
161
+ review: 0,
162
+ done: 0,
163
+ byType: {},
164
+ byPriority: {},
165
+ };
166
+ for (const task of tasks) {
167
+ stats[task.status]++;
168
+ stats.byType[task.type] = (stats.byType[task.type] || 0) + 1;
169
+ stats.byPriority[task.priority] = (stats.byPriority[task.priority] || 0) + 1;
170
+ }
171
+ return stats;
172
+ }
173
+ }
@@ -0,0 +1,179 @@
1
+ import type { VibingStatus, VibingStage } from '@vibeman/types';
2
+ export interface Task {
3
+ id: string;
4
+ title: string;
5
+ type: 'feature' | 'bug' | 'chore' | 'refactor' | 'test' | 'doc';
6
+ status: 'backlog' | 'in-progress' | 'review' | 'done';
7
+ tags: string[];
8
+ due_date?: string;
9
+ assignee?: string[];
10
+ priority: 'low' | 'medium' | 'high';
11
+ comments?: string[];
12
+ content: string;
13
+ created_at: string;
14
+ updated_at: string;
15
+ deleted_at?: string;
16
+ }
17
+ export interface TaskMetadata {
18
+ id: string;
19
+ title: string;
20
+ type: Task['type'];
21
+ status: Task['status'];
22
+ tags: string[];
23
+ due_date?: string | Date;
24
+ assignee?: string[];
25
+ priority: Task['priority'];
26
+ comments?: string[];
27
+ deleted_at?: string;
28
+ }
29
+ export interface ServerConfig {
30
+ port: number;
31
+ host: string;
32
+ vibeDir: string;
33
+ tasksDir: string;
34
+ }
35
+ export interface ExecutionLog {
36
+ id: string;
37
+ taskId: string;
38
+ timestamp: string;
39
+ level: 'info' | 'warn' | 'error';
40
+ message: string;
41
+ data?: Record<string, unknown>;
42
+ }
43
+ export interface AgentExecution {
44
+ id: string;
45
+ taskId: string;
46
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
47
+ startTime: string;
48
+ endTime?: string;
49
+ logs: string[];
50
+ error?: string;
51
+ provider?: string;
52
+ usage?: {
53
+ promptTokens: number;
54
+ completionTokens: number;
55
+ totalTokens: number;
56
+ cost?: number;
57
+ };
58
+ worktree?: WorktreeInfo;
59
+ workingDirectory: string;
60
+ }
61
+ export interface WorktreeInfo {
62
+ taskId: string;
63
+ path: string;
64
+ branchName: string;
65
+ }
66
+ export interface WorktreeConfig {
67
+ worktreePath: string;
68
+ }
69
+ export interface TaskImprovementRequest {
70
+ taskId: string;
71
+ title: string;
72
+ type: Task['type'];
73
+ priority: Task['priority'];
74
+ content: string;
75
+ }
76
+ export interface TaskImprovementResponse {
77
+ type: Task['type'];
78
+ priority: Task['priority'];
79
+ content: string;
80
+ executionId: string;
81
+ }
82
+ export type VibingPhase = VibingStatus | VibingStage;
83
+ export interface VibingExecution {
84
+ id: string;
85
+ taskId: string;
86
+ phase: VibingPhase;
87
+ startTime: string;
88
+ endTime?: string;
89
+ status?: VibingStatus;
90
+ lastPhase?: VibingPhase;
91
+ phaseHistory?: Array<{
92
+ from: VibingPhase;
93
+ to: VibingPhase;
94
+ at: string;
95
+ reason?: string;
96
+ }>;
97
+ failureContext?: {
98
+ atPhase: VibingPhase;
99
+ error?: string;
100
+ timestamp: string;
101
+ };
102
+ executionIds?: Partial<Record<VibingPhase, string[]>>;
103
+ attempts?: Partial<Record<VibingPhase, number>>;
104
+ rerunContextHistory?: Array<{
105
+ at: string;
106
+ phase: VibingPhase;
107
+ reason: string;
108
+ attempt: number;
109
+ previousExecutionId?: string;
110
+ }>;
111
+ qualityResults?: QualityResults;
112
+ links?: {
113
+ prUrl?: string;
114
+ prNumber?: number;
115
+ branchName?: string;
116
+ baseBranch?: string;
117
+ };
118
+ error?: string;
119
+ metrics?: {
120
+ durationsMs: Partial<Record<VibingPhase, number>>;
121
+ totalDurationMs?: number;
122
+ lastPhaseStartedAt?: string;
123
+ };
124
+ lastUpdatedAt?: string;
125
+ metadata: VibingConfig;
126
+ timeline?: Array<{
127
+ id: string;
128
+ label: string;
129
+ phase: VibingPhase;
130
+ attempt?: number;
131
+ executionId?: string;
132
+ startTime: string;
133
+ endTime?: string;
134
+ reason?: string;
135
+ usage?: {
136
+ promptTokens: number;
137
+ completionTokens: number;
138
+ totalTokens: number;
139
+ cost?: number;
140
+ };
141
+ }>;
142
+ }
143
+ export interface QualityResults {
144
+ overall: boolean;
145
+ timestamp: string;
146
+ details: Record<string, boolean>;
147
+ outputs: Record<string, string>;
148
+ }
149
+ export interface VibingConfig {
150
+ autoQualityChecks: boolean;
151
+ requireHumanApproval: boolean;
152
+ stepByStepMode?: boolean;
153
+ retryPolicy?: {
154
+ maxImplementationAttempts: number;
155
+ };
156
+ autoCommit?: boolean;
157
+ createPR?: boolean;
158
+ autoMerge?: boolean;
159
+ aiCodeReview?: boolean;
160
+ qualityChecks?: Array<{
161
+ name: string;
162
+ command: string;
163
+ args?: string[];
164
+ timeout?: number;
165
+ enabled?: boolean;
166
+ }>;
167
+ aiRoutingOverrides?: Partial<Record<'execute_task' | 'improve_task' | 'ai_codereview' | 'ai_merge', {
168
+ provider?: string;
169
+ model?: string;
170
+ }>>;
171
+ aiReviewResult?: {
172
+ executionId: string;
173
+ reviewSummary: string;
174
+ recommendations: string[];
175
+ qualityScore: number;
176
+ timestamp?: string;
177
+ };
178
+ }
179
+ export type { VibingStage, VibingStatus, LegacyVibingPhase, VibingWorkflowV2, StageToStatusMapping, } from '@vibeman/types';
@@ -0,0 +1 @@
1
+ export {};