vibeman 0.0.3 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +49 -0
- package/dist/cli.js +135 -0
- package/dist/ui/index-gnk6rhxs.js +9 -0
- package/dist/ui/index.html +10 -0
- package/dist/ui/index.js +2 -0
- package/package.json +10 -80
- package/README.md +0 -12
- package/dist/index.js +0 -114
- package/dist/runtime/api/.tsbuildinfo +0 -1
- package/dist/runtime/api/agent/agent-service.d.ts +0 -225
- package/dist/runtime/api/agent/agent-service.js +0 -904
- package/dist/runtime/api/agent/ai-providers/claude-code-adapter.d.ts +0 -61
- package/dist/runtime/api/agent/ai-providers/claude-code-adapter.js +0 -362
- package/dist/runtime/api/agent/ai-providers/codex-cli-provider.d.ts +0 -36
- package/dist/runtime/api/agent/ai-providers/codex-cli-provider.js +0 -347
- package/dist/runtime/api/agent/ai-providers/index.d.ts +0 -9
- package/dist/runtime/api/agent/ai-providers/index.js +0 -7
- package/dist/runtime/api/agent/ai-providers/types.d.ts +0 -182
- package/dist/runtime/api/agent/ai-providers/types.js +0 -5
- package/dist/runtime/api/agent/codex-cli-provider.test.d.ts +0 -1
- package/dist/runtime/api/agent/codex-cli-provider.test.js +0 -170
- package/dist/runtime/api/agent/core-agent-service.d.ts +0 -119
- package/dist/runtime/api/agent/core-agent-service.js +0 -267
- package/dist/runtime/api/agent/parsers.d.ts +0 -16
- package/dist/runtime/api/agent/parsers.js +0 -308
- package/dist/runtime/api/agent/prompt-service.d.ts +0 -30
- package/dist/runtime/api/agent/prompt-service.js +0 -449
- package/dist/runtime/api/agent/prompt-service.test.d.ts +0 -1
- package/dist/runtime/api/agent/prompt-service.test.js +0 -230
- package/dist/runtime/api/agent/routing-policy.d.ts +0 -171
- package/dist/runtime/api/agent/routing-policy.js +0 -196
- package/dist/runtime/api/agent/routing-policy.test.d.ts +0 -1
- package/dist/runtime/api/agent/routing-policy.test.js +0 -63
- package/dist/runtime/api/api/router-helpers.d.ts +0 -32
- package/dist/runtime/api/api/router-helpers.js +0 -31
- package/dist/runtime/api/api/routers/ai.d.ts +0 -200
- package/dist/runtime/api/api/routers/ai.js +0 -396
- package/dist/runtime/api/api/routers/executions.d.ts +0 -98
- package/dist/runtime/api/api/routers/executions.js +0 -94
- package/dist/runtime/api/api/routers/git.d.ts +0 -45
- package/dist/runtime/api/api/routers/git.js +0 -35
- package/dist/runtime/api/api/routers/provider-config.d.ts +0 -165
- package/dist/runtime/api/api/routers/provider-config.js +0 -252
- package/dist/runtime/api/api/routers/settings.d.ts +0 -139
- package/dist/runtime/api/api/routers/settings.js +0 -113
- package/dist/runtime/api/api/routers/tasks.d.ts +0 -141
- package/dist/runtime/api/api/routers/tasks.js +0 -238
- package/dist/runtime/api/api/routers/workflows.d.ts +0 -275
- package/dist/runtime/api/api/routers/workflows.js +0 -311
- package/dist/runtime/api/api/routers/worktrees.d.ts +0 -101
- package/dist/runtime/api/api/routers/worktrees.js +0 -80
- package/dist/runtime/api/api/trpc.d.ts +0 -118
- package/dist/runtime/api/api/trpc.js +0 -34
- package/dist/runtime/api/index.d.ts +0 -9
- package/dist/runtime/api/index.js +0 -117
- package/dist/runtime/api/lib/id-generator.d.ts +0 -70
- package/dist/runtime/api/lib/id-generator.js +0 -123
- package/dist/runtime/api/lib/local-config.d.ts +0 -245
- package/dist/runtime/api/lib/local-config.js +0 -288
- package/dist/runtime/api/lib/logger.d.ts +0 -11
- package/dist/runtime/api/lib/logger.js +0 -188
- package/dist/runtime/api/lib/provider-detection.d.ts +0 -59
- package/dist/runtime/api/lib/provider-detection.js +0 -244
- package/dist/runtime/api/lib/server/agent-service-singleton.d.ts +0 -6
- package/dist/runtime/api/lib/server/agent-service-singleton.js +0 -27
- package/dist/runtime/api/lib/server/bootstrap.d.ts +0 -38
- package/dist/runtime/api/lib/server/bootstrap.js +0 -197
- package/dist/runtime/api/lib/server/git-service-singleton.d.ts +0 -6
- package/dist/runtime/api/lib/server/git-service-singleton.js +0 -47
- package/dist/runtime/api/lib/server/project-root.d.ts +0 -2
- package/dist/runtime/api/lib/server/project-root.js +0 -61
- package/dist/runtime/api/lib/server/task-service-singleton.d.ts +0 -7
- package/dist/runtime/api/lib/server/task-service-singleton.js +0 -58
- package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.d.ts +0 -7
- package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.js +0 -57
- package/dist/runtime/api/lib/trpc/client.d.ts +0 -1
- package/dist/runtime/api/lib/trpc/client.js +0 -5
- package/dist/runtime/api/lib/trpc/server.d.ts +0 -935
- package/dist/runtime/api/lib/trpc/server.js +0 -11
- package/dist/runtime/api/lib/trpc/ws-server.d.ts +0 -8
- package/dist/runtime/api/lib/trpc/ws-server.js +0 -33
- package/dist/runtime/api/persistence/database-service.d.ts +0 -14
- package/dist/runtime/api/persistence/database-service.js +0 -74
- package/dist/runtime/api/persistence/execution-log-persistence.d.ts +0 -90
- package/dist/runtime/api/persistence/execution-log-persistence.js +0 -410
- package/dist/runtime/api/persistence/execution-log-persistence.test.d.ts +0 -1
- package/dist/runtime/api/persistence/execution-log-persistence.test.js +0 -170
- package/dist/runtime/api/router.d.ts +0 -938
- package/dist/runtime/api/router.js +0 -34
- package/dist/runtime/api/settings-service.d.ts +0 -110
- package/dist/runtime/api/settings-service.js +0 -661
- package/dist/runtime/api/tasks/file-watcher.d.ts +0 -23
- package/dist/runtime/api/tasks/file-watcher.js +0 -88
- package/dist/runtime/api/tasks/task-file-parser.d.ts +0 -13
- package/dist/runtime/api/tasks/task-file-parser.js +0 -161
- package/dist/runtime/api/tasks/task-service.d.ts +0 -36
- package/dist/runtime/api/tasks/task-service.js +0 -173
- package/dist/runtime/api/types/index.d.ts +0 -186
- package/dist/runtime/api/types/index.js +0 -1
- package/dist/runtime/api/types/settings.d.ts +0 -94
- package/dist/runtime/api/types/settings.js +0 -2
- package/dist/runtime/api/types.d.ts +0 -2
- package/dist/runtime/api/types.js +0 -1
- package/dist/runtime/api/utils/env.d.ts +0 -6
- package/dist/runtime/api/utils/env.js +0 -12
- package/dist/runtime/api/utils/stripNextEnv.d.ts +0 -7
- package/dist/runtime/api/utils/stripNextEnv.js +0 -22
- package/dist/runtime/api/utils/title-slug.d.ts +0 -6
- package/dist/runtime/api/utils/title-slug.js +0 -77
- package/dist/runtime/api/utils/url.d.ts +0 -2
- package/dist/runtime/api/utils/url.js +0 -19
- package/dist/runtime/api/vcs/git-history-service.d.ts +0 -57
- package/dist/runtime/api/vcs/git-history-service.js +0 -228
- package/dist/runtime/api/vcs/git-service.d.ts +0 -127
- package/dist/runtime/api/vcs/git-service.js +0 -284
- package/dist/runtime/api/vcs/worktree-service.d.ts +0 -93
- package/dist/runtime/api/vcs/worktree-service.js +0 -506
- package/dist/runtime/api/vcs/worktree-service.test.d.ts +0 -1
- package/dist/runtime/api/vcs/worktree-service.test.js +0 -20
- package/dist/runtime/api/workflows/quality-pipeline.d.ts +0 -58
- package/dist/runtime/api/workflows/quality-pipeline.js +0 -400
- package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +0 -318
- package/dist/runtime/api/workflows/vibing-orchestrator.js +0 -1891
- package/dist/runtime/web/.next/BUILD_ID +0 -1
- package/dist/runtime/web/.next/app-build-manifest.json +0 -66
- package/dist/runtime/web/.next/app-path-routes-manifest.json +0 -8
- package/dist/runtime/web/.next/build-manifest.json +0 -33
- package/dist/runtime/web/.next/package.json +0 -1
- package/dist/runtime/web/.next/prerender-manifest.json +0 -61
- package/dist/runtime/web/.next/react-loadable-manifest.json +0 -39
- package/dist/runtime/web/.next/required-server-files.json +0 -334
- package/dist/runtime/web/.next/routes-manifest.json +0 -70
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js +0 -1
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/_not-found/page.js +0 -2
- package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/_not-found.html +0 -7
- package/dist/runtime/web/.next/server/app/_not-found.meta +0 -8
- package/dist/runtime/web/.next/server/app/_not-found.rsc +0 -22
- package/dist/runtime/web/.next/server/app/api/health/route.js +0 -1
- package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +0 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/api/upload/route.js +0 -1
- package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app/index.html +0 -7
- package/dist/runtime/web/.next/server/app/index.meta +0 -7
- package/dist/runtime/web/.next/server/app/index.rsc +0 -27
- package/dist/runtime/web/.next/server/app/page.js +0 -147
- package/dist/runtime/web/.next/server/app/page.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/app-paths-manifest.json +0 -8
- package/dist/runtime/web/.next/server/chunks/217.js +0 -1
- package/dist/runtime/web/.next/server/chunks/383.js +0 -6
- package/dist/runtime/web/.next/server/chunks/458.js +0 -1
- package/dist/runtime/web/.next/server/chunks/576.js +0 -18
- package/dist/runtime/web/.next/server/chunks/635.js +0 -22
- package/dist/runtime/web/.next/server/chunks/761.js +0 -1
- package/dist/runtime/web/.next/server/chunks/777.js +0 -3
- package/dist/runtime/web/.next/server/chunks/825.js +0 -1
- package/dist/runtime/web/.next/server/chunks/838.js +0 -1
- package/dist/runtime/web/.next/server/chunks/973.js +0 -15
- package/dist/runtime/web/.next/server/functions-config-manifest.json +0 -4
- package/dist/runtime/web/.next/server/middleware-build-manifest.js +0 -1
- package/dist/runtime/web/.next/server/middleware-manifest.json +0 -6
- package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/dist/runtime/web/.next/server/next-font-manifest.js +0 -1
- package/dist/runtime/web/.next/server/next-font-manifest.json +0 -1
- package/dist/runtime/web/.next/server/pages/404.html +0 -7
- package/dist/runtime/web/.next/server/pages/500.html +0 -1
- package/dist/runtime/web/.next/server/pages/_app.js +0 -1
- package/dist/runtime/web/.next/server/pages/_app.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/pages/_document.js +0 -1
- package/dist/runtime/web/.next/server/pages/_document.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/pages/_error.js +0 -19
- package/dist/runtime/web/.next/server/pages/_error.js.nft.json +0 -1
- package/dist/runtime/web/.next/server/pages-manifest.json +0 -6
- package/dist/runtime/web/.next/server/server-reference-manifest.js +0 -1
- package/dist/runtime/web/.next/server/server-reference-manifest.json +0 -1
- package/dist/runtime/web/.next/server/webpack-runtime.js +0 -1
- package/dist/runtime/web/.next/static/5_15u1WQCxN1_eHZpldCv/_buildManifest.js +0 -1
- package/dist/runtime/web/.next/static/5_15u1WQCxN1_eHZpldCv/_ssgManifest.js +0 -1
- package/dist/runtime/web/.next/static/chunks/18-15c10d3288afef2e.js +0 -1
- package/dist/runtime/web/.next/static/chunks/1c0ca389.537bbe362e3ffbd9.js +0 -3
- package/dist/runtime/web/.next/static/chunks/22747d63-ad5da0c19f4cfe41.js +0 -71
- package/dist/runtime/web/.next/static/chunks/355.056c2645878a799a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/420.a5ccf151c9e2b2f1.js +0 -1
- package/dist/runtime/web/.next/static/chunks/439.1be0c6242fd248d5.js +0 -15
- package/dist/runtime/web/.next/static/chunks/440.c52e7c0f797e22b2.js +0 -1
- package/dist/runtime/web/.next/static/chunks/575-e2478287c27da87b.js +0 -1
- package/dist/runtime/web/.next/static/chunks/691.920d88c115087314.js +0 -1
- package/dist/runtime/web/.next/static/chunks/765-e838910065b50c3d.js +0 -1
- package/dist/runtime/web/.next/static/chunks/823-6f371a6e829adbba.js +0 -63
- package/dist/runtime/web/.next/static/chunks/87c73c54-09e1ba5c70e60a51.js +0 -1
- package/dist/runtime/web/.next/static/chunks/891cff7f.0f71fc028f87e683.js +0 -1
- package/dist/runtime/web/.next/static/chunks/8bb4d8db-3e2aa02b0a2384b9.js +0 -1
- package/dist/runtime/web/.next/static/chunks/9af238c7-271a911d4e99ab18.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/.vibeman/assets/images/[...path]/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/_not-found/page-1cb74d1cba27d0ab.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/health/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/api/upload/route-751c9265a65409e5.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/layout-8435322f09fd0975.js +0 -1
- package/dist/runtime/web/.next/static/chunks/app/page-9fe7d75095b4ccec.js +0 -1
- package/dist/runtime/web/.next/static/chunks/cac567b0-5b77dd12911823cd.js +0 -1
- package/dist/runtime/web/.next/static/chunks/framework-2518f1345b5b2806.js +0 -1
- package/dist/runtime/web/.next/static/chunks/main-17665e5e39de9a8a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/main-app-c0b0f5ba4f7f9d75.js +0 -1
- package/dist/runtime/web/.next/static/chunks/pages/_app-d6f6b3bbc3d81ee1.js +0 -1
- package/dist/runtime/web/.next/static/chunks/pages/_error-75a96cf1997cc3b9.js +0 -1
- package/dist/runtime/web/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/dist/runtime/web/.next/static/chunks/webpack-c8de37305b4635cf.js +0 -1
- package/dist/runtime/web/.next/static/css/08c950681f1a9a92.css +0 -1
- package/dist/runtime/web/.next/static/css/2728291c68f99cb1.css +0 -3
- package/dist/runtime/web/.next/static/css/521bd69cc298cd1a.css +0 -1
- package/dist/runtime/web/.next/static/css/537e22821e101b87.css +0 -1
- package/dist/runtime/web/.next/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/21350d82a1f187e9-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/8e9860b6e62d6359-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/ba9851c3c22cd980-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/df0a9ae256c0569c-s.woff2 +0 -0
- package/dist/runtime/web/.next/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
- package/dist/runtime/web/package.json +0 -65
- package/dist/runtime/web/server.js +0 -44
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
import { log } from '../lib/logger.js';
|
|
2
|
-
// Extract the last valid JSON object from mixed text.
|
|
3
|
-
// It scans for fenced ```json blocks and balanced-brace objects, then returns the last one that parses.
|
|
4
|
-
function extractLastValidJson(text) {
|
|
5
|
-
if (!text)
|
|
6
|
-
return null;
|
|
7
|
-
const candidates = [];
|
|
8
|
-
// 1) Fenced JSON blocks
|
|
9
|
-
const fencedRe = /```json\s*([\s\S]*?)\s*```/gi;
|
|
10
|
-
let m;
|
|
11
|
-
while ((m = fencedRe.exec(text)) !== null) {
|
|
12
|
-
if (m[1])
|
|
13
|
-
candidates.push(m[1]);
|
|
14
|
-
}
|
|
15
|
-
// 2) Balanced brace objects
|
|
16
|
-
let depth = 0;
|
|
17
|
-
let inStr = false;
|
|
18
|
-
let start = -1;
|
|
19
|
-
let prev = '';
|
|
20
|
-
for (let i = 0; i < text.length; i++) {
|
|
21
|
-
const ch = text[i];
|
|
22
|
-
if (inStr) {
|
|
23
|
-
if (ch === '"' && prev !== '\\')
|
|
24
|
-
inStr = false;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
if (ch === '"')
|
|
28
|
-
inStr = true;
|
|
29
|
-
else if (ch === '{') {
|
|
30
|
-
if (depth === 0)
|
|
31
|
-
start = i;
|
|
32
|
-
depth++;
|
|
33
|
-
}
|
|
34
|
-
else if (ch === '}') {
|
|
35
|
-
if (depth > 0)
|
|
36
|
-
depth--;
|
|
37
|
-
if (depth === 0 && start >= 0) {
|
|
38
|
-
candidates.push(text.slice(start, i + 1));
|
|
39
|
-
start = -1;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
prev = ch;
|
|
44
|
-
}
|
|
45
|
-
for (let i = candidates.length - 1; i >= 0; i--) {
|
|
46
|
-
const c = candidates[i].trim();
|
|
47
|
-
try {
|
|
48
|
-
JSON.parse(c);
|
|
49
|
-
return c;
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
// ignore
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Manually parse a JSON-like structure that may have unescaped strings
|
|
59
|
-
* This is a fallback for when JSON.parse fails due to unescaped content
|
|
60
|
-
*/
|
|
61
|
-
function parseJsonManually(jsonStr) {
|
|
62
|
-
try {
|
|
63
|
-
// Extract type, priority and title with simple regex (these are usually well-formed)
|
|
64
|
-
const typeMatch = jsonStr.match(/"type":\s*"([^"]+)"/);
|
|
65
|
-
const priorityMatch = jsonStr.match(/"priority":\s*"([^"]+)"/);
|
|
66
|
-
const titleMatch = jsonStr.match(/"title":\s*"([^"]+)"/);
|
|
67
|
-
// For content, find the start and extract everything until the closing brace
|
|
68
|
-
const contentStart = jsonStr.indexOf('"content":');
|
|
69
|
-
if (contentStart === -1)
|
|
70
|
-
return null;
|
|
71
|
-
const contentValueStart = jsonStr.indexOf('"', contentStart + 10);
|
|
72
|
-
if (contentValueStart === -1)
|
|
73
|
-
return null;
|
|
74
|
-
// Find the last occurrence of "}` at the end - this marks the end of our JSON
|
|
75
|
-
const jsonEnd = jsonStr.lastIndexOf('}');
|
|
76
|
-
if (jsonEnd === -1)
|
|
77
|
-
return null;
|
|
78
|
-
// Find the quote that comes before the closing brace
|
|
79
|
-
// Work backwards from the closing brace to find the last quote
|
|
80
|
-
let contentEnd = -1;
|
|
81
|
-
for (let i = jsonEnd - 1; i > contentValueStart; i--) {
|
|
82
|
-
if (jsonStr[i] === '"') {
|
|
83
|
-
// Check if this quote is escaped
|
|
84
|
-
let backslashCount = 0;
|
|
85
|
-
for (let j = i - 1; j >= 0 && jsonStr[j] === '\\'; j--) {
|
|
86
|
-
backslashCount++;
|
|
87
|
-
}
|
|
88
|
-
// If even number of backslashes (including 0), quote is not escaped
|
|
89
|
-
if (backslashCount % 2 === 0) {
|
|
90
|
-
contentEnd = i;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (contentEnd === -1)
|
|
96
|
-
return null;
|
|
97
|
-
// Extract the raw content
|
|
98
|
-
const rawContent = jsonStr.substring(contentValueStart + 1, contentEnd);
|
|
99
|
-
if (typeMatch && priorityMatch && rawContent) {
|
|
100
|
-
// Clean up the content - unescape common escape sequences
|
|
101
|
-
const content = rawContent
|
|
102
|
-
.replace(/\\n/g, '\n')
|
|
103
|
-
.replace(/\\r/g, '\r')
|
|
104
|
-
.replace(/\\t/g, '\t')
|
|
105
|
-
.replace(/\\"/g, '"')
|
|
106
|
-
.replace(/\\\\/g, '\\');
|
|
107
|
-
const result = {
|
|
108
|
-
type: typeMatch[1],
|
|
109
|
-
priority: priorityMatch[1],
|
|
110
|
-
content: content,
|
|
111
|
-
};
|
|
112
|
-
// Add title if found
|
|
113
|
-
if (titleMatch) {
|
|
114
|
-
result.title = titleMatch[1];
|
|
115
|
-
}
|
|
116
|
-
return result;
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
122
|
-
log.warn('Manual JSON parsing failed', { error: errMsg }, 'result-parsers');
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Extract title from markdown content and remove it from content
|
|
128
|
-
* Returns { title: string | null, cleanedContent: string }
|
|
129
|
-
*/
|
|
130
|
-
function extractTitleFromContent(content) {
|
|
131
|
-
if (!content || typeof content !== 'string') {
|
|
132
|
-
return { title: null, cleanedContent: content };
|
|
133
|
-
}
|
|
134
|
-
// Look for H1 heading at the start of content (with optional whitespace)
|
|
135
|
-
const h1Match = content.match(/^\s*#\s+([^\n\r]+)/);
|
|
136
|
-
if (h1Match) {
|
|
137
|
-
const title = h1Match[1].trim();
|
|
138
|
-
// Remove the H1 heading from content
|
|
139
|
-
const cleanedContent = content.replace(/^\s*#\s+[^\n\r]+\s*\n?/, '').trim();
|
|
140
|
-
return { title, cleanedContent };
|
|
141
|
-
}
|
|
142
|
-
return { title: null, cleanedContent: content };
|
|
143
|
-
}
|
|
144
|
-
export function parseImprovementResult(result, originalData) {
|
|
145
|
-
try {
|
|
146
|
-
const jsonBlock = extractLastValidJson(result);
|
|
147
|
-
if (jsonBlock) {
|
|
148
|
-
// Try parsing as-is first
|
|
149
|
-
try {
|
|
150
|
-
const parsed = JSON.parse(jsonBlock);
|
|
151
|
-
if (parsed.type && parsed.priority && parsed.content) {
|
|
152
|
-
// Validate type and priority values
|
|
153
|
-
const validTypes = ['feature', 'bug', 'chore', 'refactor', 'test', 'doc'];
|
|
154
|
-
const validPriorities = ['high', 'medium', 'low'];
|
|
155
|
-
const normalizedType = String(parsed.type).toLowerCase();
|
|
156
|
-
const normalizedPriority = String(parsed.priority).toLowerCase();
|
|
157
|
-
// Extract title from JSON if present, otherwise from content
|
|
158
|
-
let finalTitle;
|
|
159
|
-
let finalContent = String(parsed.content).trim();
|
|
160
|
-
if (parsed.title && typeof parsed.title === 'string' && parsed.title.trim()) {
|
|
161
|
-
finalTitle = parsed.title.trim();
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
// Try to extract title from content
|
|
165
|
-
const { title, cleanedContent } = extractTitleFromContent(finalContent);
|
|
166
|
-
if (title) {
|
|
167
|
-
finalTitle = title;
|
|
168
|
-
finalContent = cleanedContent;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const result = {
|
|
172
|
-
type: validTypes.includes(normalizedType) ? normalizedType : originalData.type,
|
|
173
|
-
priority: validPriorities.includes(normalizedPriority)
|
|
174
|
-
? normalizedPriority
|
|
175
|
-
: originalData.priority,
|
|
176
|
-
content: finalContent,
|
|
177
|
-
};
|
|
178
|
-
if (finalTitle) {
|
|
179
|
-
result.title = finalTitle;
|
|
180
|
-
}
|
|
181
|
-
return result;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
catch (parseError) {
|
|
185
|
-
// If JSON parsing fails, try to fix common issues
|
|
186
|
-
const parseErrMsg = parseError instanceof Error ? parseError.message : String(parseError);
|
|
187
|
-
log.warn('Initial JSON parse failed, attempting to clean JSON', { error: parseErrMsg }, 'result-parsers');
|
|
188
|
-
try {
|
|
189
|
-
// Attempt to manually parse the JSON structure
|
|
190
|
-
const parsed = parseJsonManually(jsonBlock);
|
|
191
|
-
if (parsed && parsed.type && parsed.priority && parsed.content) {
|
|
192
|
-
const validTypes = ['feature', 'bug', 'chore', 'refactor', 'test', 'doc'];
|
|
193
|
-
const validPriorities = ['high', 'medium', 'low'];
|
|
194
|
-
const normalizedType = String(parsed.type).toLowerCase();
|
|
195
|
-
const normalizedPriority = String(parsed.priority).toLowerCase();
|
|
196
|
-
// Extract title from parsed JSON if present, otherwise from content
|
|
197
|
-
let finalTitle;
|
|
198
|
-
let finalContent = String(parsed.content).trim();
|
|
199
|
-
if (parsed.title && typeof parsed.title === 'string' && parsed.title.trim()) {
|
|
200
|
-
finalTitle = parsed.title.trim();
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
// Try to extract title from content
|
|
204
|
-
const { title, cleanedContent } = extractTitleFromContent(finalContent);
|
|
205
|
-
if (title) {
|
|
206
|
-
finalTitle = title;
|
|
207
|
-
finalContent = cleanedContent;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
const result = {
|
|
211
|
-
type: validTypes.includes(normalizedType) ? normalizedType : originalData.type,
|
|
212
|
-
priority: validPriorities.includes(normalizedPriority)
|
|
213
|
-
? normalizedPriority
|
|
214
|
-
: originalData.priority,
|
|
215
|
-
content: finalContent,
|
|
216
|
-
};
|
|
217
|
-
if (finalTitle) {
|
|
218
|
-
result.title = finalTitle;
|
|
219
|
-
}
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
catch (secondError) {
|
|
224
|
-
const secondErrMsg = secondError instanceof Error ? secondError.message : String(secondError);
|
|
225
|
-
log.error('JSON cleaning also failed', { error: secondErrMsg }, 'result-parsers');
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
catch (error) {
|
|
231
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
232
|
-
log.error('Failed to parse improvement result', { error: errMsg, result }, 'result-parsers');
|
|
233
|
-
}
|
|
234
|
-
// Fallback: try to extract title from the raw result content
|
|
235
|
-
const fallbackContent = result.trim() || originalData.content;
|
|
236
|
-
const { title: extractedTitle, cleanedContent } = extractTitleFromContent(fallbackContent);
|
|
237
|
-
const fallbackResult = {
|
|
238
|
-
type: originalData.type,
|
|
239
|
-
priority: originalData.priority,
|
|
240
|
-
content: cleanedContent,
|
|
241
|
-
};
|
|
242
|
-
if (extractedTitle) {
|
|
243
|
-
fallbackResult.title = extractedTitle;
|
|
244
|
-
}
|
|
245
|
-
return fallbackResult;
|
|
246
|
-
}
|
|
247
|
-
export function parseReviewResult(result) {
|
|
248
|
-
try {
|
|
249
|
-
const jsonBlock = extractLastValidJson(result);
|
|
250
|
-
if (jsonBlock) {
|
|
251
|
-
const parsed = JSON.parse(jsonBlock);
|
|
252
|
-
if (parsed.reviewSummary &&
|
|
253
|
-
parsed.recommendations &&
|
|
254
|
-
(typeof parsed.qualityScore === 'number' || typeof parsed.score === 'number')) {
|
|
255
|
-
const score = typeof parsed.qualityScore === 'number' ? parsed.qualityScore : parsed.score;
|
|
256
|
-
return {
|
|
257
|
-
reviewSummary: String(parsed.reviewSummary),
|
|
258
|
-
recommendations: Array.isArray(parsed.recommendations)
|
|
259
|
-
? parsed.recommendations.map((r) => String(r))
|
|
260
|
-
: [String(parsed.recommendations)],
|
|
261
|
-
qualityScore: Math.max(0, Math.min(100, Number(score))),
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
catch (error) {
|
|
267
|
-
log.error('Failed to parse review result', error, 'result-parsers');
|
|
268
|
-
}
|
|
269
|
-
// Fallback: parse simple plaintext format like
|
|
270
|
-
// Score: 75/100\nSummary: ...\nRecommendations:\n- item
|
|
271
|
-
try {
|
|
272
|
-
const scoreMatch = result.match(/Score\s*:\s*(\d{1,3})(?:\s*\/\s*100)?/i);
|
|
273
|
-
const summaryMatch = result.match(/Summary\s*:\s*([\s\S]*?)(?:\n\s*Recommendations\s*:|$)/i);
|
|
274
|
-
const recBlockMatch = result.match(/Recommendations\s*:\s*([\s\S]*)$/i);
|
|
275
|
-
const score = scoreMatch ? Math.max(0, Math.min(100, Number(scoreMatch[1]))) : 75;
|
|
276
|
-
const reviewSummary = summaryMatch
|
|
277
|
-
? summaryMatch[1].trim()
|
|
278
|
-
: result.length > 200
|
|
279
|
-
? result.substring(0, 200) + '...'
|
|
280
|
-
: result;
|
|
281
|
-
let recommendations = [];
|
|
282
|
-
if (recBlockMatch) {
|
|
283
|
-
const lines = recBlockMatch[1]
|
|
284
|
-
.split(/\r?\n/)
|
|
285
|
-
.map((l) => l.trim())
|
|
286
|
-
.filter(Boolean);
|
|
287
|
-
// Take bullet-like lines or fallback to one-liner
|
|
288
|
-
const bullets = lines
|
|
289
|
-
.filter((l) => /^[-*•\d]/.test(l))
|
|
290
|
-
.map((l) => l.replace(/^[-*•\d.)\s]+/, '').trim());
|
|
291
|
-
recommendations = bullets.length ? bullets : lines.slice(0, 5);
|
|
292
|
-
if (!recommendations.length)
|
|
293
|
-
recommendations = ['Review completed - see output for details'];
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
recommendations = ['Review completed - see output for details'];
|
|
297
|
-
}
|
|
298
|
-
return { reviewSummary, recommendations, qualityScore: score };
|
|
299
|
-
}
|
|
300
|
-
catch {
|
|
301
|
-
// fall back to generic
|
|
302
|
-
}
|
|
303
|
-
return {
|
|
304
|
-
reviewSummary: result.length > 200 ? result.substring(0, 200) + '...' : result,
|
|
305
|
-
recommendations: ['Review completed - see output for details'],
|
|
306
|
-
qualityScore: 75,
|
|
307
|
-
};
|
|
308
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Task, WorktreeInfo } from '../types/index.js';
|
|
2
|
-
import type { TaskService } from '../tasks/task-service.js';
|
|
3
|
-
export declare class PromptService {
|
|
4
|
-
private projectRoot;
|
|
5
|
-
private taskService;
|
|
6
|
-
constructor(projectRoot: string, taskService: TaskService);
|
|
7
|
-
/**
|
|
8
|
-
* Generate absolute path to task file
|
|
9
|
-
*/
|
|
10
|
-
private generateTaskFilePath;
|
|
11
|
-
/**
|
|
12
|
-
* Validate that task file exists at the given path
|
|
13
|
-
*/
|
|
14
|
-
private validateTaskFile;
|
|
15
|
-
generateImprovementPrompt(task: Task, taskData: {
|
|
16
|
-
title: string;
|
|
17
|
-
type: string;
|
|
18
|
-
priority: string;
|
|
19
|
-
content: string;
|
|
20
|
-
}): Promise<string>;
|
|
21
|
-
generateTaskPrompt(task: Task, workflowConfig?: import('../types/index.js').VibingConfig): Promise<string>;
|
|
22
|
-
/**
|
|
23
|
-
* Build a prominent, clearly formatted instruction section derived from workflow options.
|
|
24
|
-
* If no options are provided or none apply, returns a minimal guidance line.
|
|
25
|
-
*/
|
|
26
|
-
private buildWorkflowInstructions;
|
|
27
|
-
generateAIMergePrompt(task: Task, worktree: WorktreeInfo, baseBranch?: string): Promise<string>;
|
|
28
|
-
generateReviewPrompt(task: Task, worktree: WorktreeInfo, reviewContext?: string): Promise<string>;
|
|
29
|
-
}
|
|
30
|
-
export declare function getQualityChecksDetectionPrompt(): string;
|