task-o-matic-core 0.1.1-beta.8 → 0.1.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.
- package/dist/lib/better-t-stack-cli.d.ts.map +1 -1
- package/dist/lib/better-t-stack-cli.js +5 -3
- package/dist/lib/config-validation.d.ts +6 -6
- package/dist/utils/metadata-utils.d.ts +1 -1
- package/package.json +7 -2
- package/src/index.ts +0 -36
- package/src/lib/ai-service/ai-operations.ts +0 -310
- package/src/lib/ai-service/base-operations.ts +0 -139
- package/src/lib/ai-service/documentation-operations.ts +0 -438
- package/src/lib/ai-service/filesystem-tools.ts +0 -73
- package/src/lib/ai-service/gemini-proxy.ts.bak +0 -52
- package/src/lib/ai-service/json-parser.ts +0 -203
- package/src/lib/ai-service/mcp-client.ts +0 -54
- package/src/lib/ai-service/model-provider.ts +0 -192
- package/src/lib/ai-service/prd-operations.ts +0 -854
- package/src/lib/ai-service/research-tools.ts +0 -207
- package/src/lib/ai-service/retry-handler.ts +0 -89
- package/src/lib/ai-service/task-operations.ts +0 -342
- package/src/lib/benchmark/registry.ts +0 -307
- package/src/lib/benchmark/runner.ts +0 -190
- package/src/lib/benchmark/storage.ts +0 -140
- package/src/lib/benchmark/types.ts +0 -121
- package/src/lib/better-t-stack-cli.ts +0 -526
- package/src/lib/bootstrap/cli-bootstrap.ts +0 -397
- package/src/lib/bootstrap/index.ts +0 -2
- package/src/lib/bootstrap/medusa-bootstrap.ts +0 -261
- package/src/lib/config-validation.ts +0 -278
- package/src/lib/config.ts +0 -435
- package/src/lib/context-builder.ts +0 -383
- package/src/lib/executors/claude-code-executor.ts +0 -83
- package/src/lib/executors/codex-executor.ts +0 -85
- package/src/lib/executors/executor-factory.ts +0 -28
- package/src/lib/executors/gemini-executor.ts +0 -80
- package/src/lib/executors/kilo-executor.ts +0 -83
- package/src/lib/executors/opencode-executor.ts +0 -81
- package/src/lib/git-utils.ts +0 -334
- package/src/lib/hooks.ts +0 -121
- package/src/lib/index.ts +0 -166
- package/src/lib/logger.ts +0 -43
- package/src/lib/notifications.ts +0 -103
- package/src/lib/prompt-builder.ts +0 -471
- package/src/lib/prompt-registry.ts +0 -491
- package/src/lib/provider-defaults.json +0 -32
- package/src/lib/storage/file-system.ts +0 -864
- package/src/lib/storage/storage-callbacks.ts +0 -120
- package/src/lib/storage/types.ts +0 -58
- package/src/lib/task-execution-core.ts +0 -591
- package/src/lib/task-execution.ts +0 -59
- package/src/lib/task-loop-execution.ts +0 -214
- package/src/lib/task-planning.ts +0 -157
- package/src/lib/task-review.ts +0 -138
- package/src/lib/validation.ts +0 -140
- package/src/prompts/documentation-detection.ts +0 -21
- package/src/prompts/documentation-recap.ts +0 -11
- package/src/prompts/index.ts +0 -14
- package/src/prompts/prd-combination.ts +0 -32
- package/src/prompts/prd-generation.ts +0 -46
- package/src/prompts/prd-parsing.ts +0 -170
- package/src/prompts/prd-question-answer.ts +0 -25
- package/src/prompts/prd-question.ts +0 -38
- package/src/prompts/prd-rework.ts +0 -79
- package/src/prompts/prd-suggest-stack.ts +0 -97
- package/src/prompts/task-breakdown.ts +0 -149
- package/src/prompts/task-enhancement.ts +0 -138
- package/src/prompts/task-execution.ts +0 -22
- package/src/prompts/task-planning.ts +0 -64
- package/src/prompts/workflow-assistance.ts +0 -151
- package/src/prompts/workflow-prompts.ts +0 -97
- package/src/services/benchmark.ts +0 -433
- package/src/services/prd.ts +0 -845
- package/src/services/tasks.ts +0 -1515
- package/src/services/workflow-ai-assistant.ts +0 -298
- package/src/services/workflow-benchmark.ts +0 -339
- package/src/services/workflow.ts +0 -779
- package/src/test/hooks.test.ts +0 -77
- package/src/test/integration/callbacks.test.ts +0 -39
- package/src/test/lib/ai-service/task-operations.test.ts +0 -430
- package/src/test/lib/config.test.ts +0 -150
- package/src/test/lib/git-utils.test.ts +0 -198
- package/src/test/mocks/mock-ai-operations.ts +0 -205
- package/src/test/mocks/mock-context-builder.ts +0 -84
- package/src/test/mocks/mock-model-provider.ts +0 -21
- package/src/test/mocks/mock-service-factory.ts +0 -64
- package/src/test/mocks/mock-storage.ts +0 -204
- package/src/test/model-parsing.test.ts +0 -78
- package/src/test/services/task-service.test.ts +0 -551
- package/src/test/storage.test.ts +0 -206
- package/src/test/task-loop-git.test.ts +0 -142
- package/src/test/test-mock-setup.ts +0 -46
- package/src/test/test-setup.ts +0 -48
- package/src/test/test-utils.ts +0 -45
- package/src/test/utils/ai-operation-utility.test.ts +0 -306
- package/src/test/utils/error-handling.test.ts +0 -241
- package/src/test/utils/file-utils.test.ts +0 -80
- package/src/test/utils/id-generator.test.ts +0 -44
- package/src/test/utils/model-parser.test.ts +0 -67
- package/src/test/validation.test.ts +0 -19
- package/src/types/callbacks.ts +0 -14
- package/src/types/index.ts +0 -628
- package/src/types/mcp.ts +0 -5
- package/src/types/options.ts +0 -165
- package/src/types/results.ts +0 -216
- package/src/types/workflow-options.ts +0 -118
- package/src/types/workflow-results.ts +0 -87
- package/src/utils/ai-config-builder.ts +0 -33
- package/src/utils/ai-operation-utility.ts +0 -380
- package/src/utils/ai-service-factory.ts +0 -125
- package/src/utils/error-utils.ts +0 -124
- package/src/utils/file-utils.ts +0 -197
- package/src/utils/id-generator.ts +0 -168
- package/src/utils/metadata-utils.ts +0 -48
- package/src/utils/model-executor-parser.ts +0 -80
- package/src/utils/model-parser.ts +0 -58
- package/src/utils/stack-formatter.ts +0 -53
- package/src/utils/storage-utils.ts +0 -94
- package/src/utils/streaming-utils.ts +0 -91
- package/src/utils/task-o-matic-error.ts +0 -393
- package/tsconfig.json +0 -20
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"better-t-stack-cli.d.ts","sourceRoot":"","sources":["../../src/lib/better-t-stack-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,WAAW,EAAE,MAAM,UAAU,CAAC;AAO/D,qBAAa,mBAAmB;IACxB,aAAa,CACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,EACjB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;QACT,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;
|
|
1
|
+
{"version":3,"file":"better-t-stack-cli.d.ts","sourceRoot":"","sources":["../../src/lib/better-t-stack-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,WAAW,EAAE,MAAM,UAAU,CAAC;AAO/D,qBAAa,mBAAmB;IACxB,aAAa,CACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,EACjB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;QACT,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IA2FF,OAAO,CAAC,kBAAkB;YAqCZ,aAAa;YAiCb,mBAAmB;YAiCnB,iBAAiB;CA+ChC;AAGD,qBAAa,uBAAuB;IAClC,OAAO,CAAC,UAAU,CAAsB;;IAMxC;;OAEG;IACH,OAAO,CAAC,cAAc;IAoBtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACG,aAAa,CACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,EACpB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAuEvE;;OAEG;YACW,4BAA4B;IA0D1C;;OAEG;YACW,eAAe;IAiC7B;;OAEG;YACW,kBAAkB;CAkCjC;AAGD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,WAAW,EACpB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAOtE"}
|
|
@@ -339,16 +339,18 @@ class BetterTStackIntegration {
|
|
|
339
339
|
database: isConvex
|
|
340
340
|
? "none"
|
|
341
341
|
: options.database || "sqlite",
|
|
342
|
-
auth: options.noAuth
|
|
342
|
+
auth: (options.noAuth || options.backend === "none"
|
|
343
343
|
? "none"
|
|
344
|
-
: options.auth || "better-auth",
|
|
344
|
+
: options.auth || "better-auth"),
|
|
345
345
|
addons: options.addons || ["turborepo"],
|
|
346
346
|
runtime: (isConvex || backend === "self"
|
|
347
347
|
? "none"
|
|
348
348
|
: options.runtime || "node"),
|
|
349
349
|
api: options.api || "none",
|
|
350
350
|
payments: options.payment || "none",
|
|
351
|
-
orm: (isConvex
|
|
351
|
+
orm: (isConvex || options.database === "none"
|
|
352
|
+
? "none"
|
|
353
|
+
: options.orm || "drizzle"),
|
|
352
354
|
dbSetup: (isConvex
|
|
353
355
|
? "none"
|
|
354
356
|
: options.dbSetup || "none"),
|
|
@@ -22,7 +22,7 @@ export declare const AIConfigSchema: z.ZodObject<{
|
|
|
22
22
|
maxTokens?: number | undefined;
|
|
23
23
|
}>>;
|
|
24
24
|
}, "strip", z.ZodTypeAny, {
|
|
25
|
-
provider: "
|
|
25
|
+
provider: "custom" | "openai" | "anthropic" | "openrouter" | "gemini" | "zai";
|
|
26
26
|
model: string;
|
|
27
27
|
apiKey?: string | undefined;
|
|
28
28
|
baseURL?: string | undefined;
|
|
@@ -33,7 +33,7 @@ export declare const AIConfigSchema: z.ZodObject<{
|
|
|
33
33
|
maxTokens?: number | undefined;
|
|
34
34
|
} | undefined;
|
|
35
35
|
}, {
|
|
36
|
-
provider: "
|
|
36
|
+
provider: "custom" | "openai" | "anthropic" | "openrouter" | "gemini" | "zai";
|
|
37
37
|
model: string;
|
|
38
38
|
apiKey?: string | undefined;
|
|
39
39
|
baseURL?: string | undefined;
|
|
@@ -64,7 +64,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
64
64
|
maxTokens?: number | undefined;
|
|
65
65
|
}>>;
|
|
66
66
|
}, "strip", z.ZodTypeAny, {
|
|
67
|
-
provider: "
|
|
67
|
+
provider: "custom" | "openai" | "anthropic" | "openrouter" | "gemini" | "zai";
|
|
68
68
|
model: string;
|
|
69
69
|
apiKey?: string | undefined;
|
|
70
70
|
baseURL?: string | undefined;
|
|
@@ -75,7 +75,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
75
75
|
maxTokens?: number | undefined;
|
|
76
76
|
} | undefined;
|
|
77
77
|
}, {
|
|
78
|
-
provider: "
|
|
78
|
+
provider: "custom" | "openai" | "anthropic" | "openrouter" | "gemini" | "zai";
|
|
79
79
|
model: string;
|
|
80
80
|
apiKey?: string | undefined;
|
|
81
81
|
baseURL?: string | undefined;
|
|
@@ -89,7 +89,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
89
89
|
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
90
90
|
}, "strip", z.ZodTypeAny, {
|
|
91
91
|
ai: {
|
|
92
|
-
provider: "
|
|
92
|
+
provider: "custom" | "openai" | "anthropic" | "openrouter" | "gemini" | "zai";
|
|
93
93
|
model: string;
|
|
94
94
|
apiKey?: string | undefined;
|
|
95
95
|
baseURL?: string | undefined;
|
|
@@ -103,7 +103,7 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
103
103
|
workingDirectory?: string | undefined;
|
|
104
104
|
}, {
|
|
105
105
|
ai: {
|
|
106
|
-
provider: "
|
|
106
|
+
provider: "custom" | "openai" | "anthropic" | "openrouter" | "gemini" | "zai";
|
|
107
107
|
model: string;
|
|
108
108
|
apiKey?: string | undefined;
|
|
109
109
|
baseURL?: string | undefined;
|
|
@@ -33,7 +33,7 @@ export declare function createBaseAIMetadata(taskId: string, aiConfig: Partial<A
|
|
|
33
33
|
aiGenerated: boolean;
|
|
34
34
|
aiPrompt: string;
|
|
35
35
|
confidence: number;
|
|
36
|
-
aiProvider: "
|
|
36
|
+
aiProvider: "custom" | "openai" | "anthropic" | "openrouter" | "gemini" | "zai" | undefined;
|
|
37
37
|
aiModel: string | undefined;
|
|
38
38
|
generatedAt: number;
|
|
39
39
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "task-o-matic-core",
|
|
3
|
-
"version": "0.1.1
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Core logic for Task-O-Matic",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
7
12
|
"exports": {
|
|
8
13
|
".": {
|
|
9
14
|
"types": "./dist/index.d.ts",
|
|
@@ -37,4 +42,4 @@
|
|
|
37
42
|
"tsx": "^4.19.2",
|
|
38
43
|
"typescript": "^5"
|
|
39
44
|
}
|
|
40
|
-
}
|
|
45
|
+
}
|
package/src/index.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
|
-
export * from "./lib/config";
|
|
3
|
-
export * from "./lib/logger";
|
|
4
|
-
export * from "./lib/better-t-stack-cli";
|
|
5
|
-
export * from "./lib/validation";
|
|
6
|
-
export * from "./lib/context-builder";
|
|
7
|
-
export * from "./lib/ai-service/ai-operations";
|
|
8
|
-
export * from "./lib/ai-service/task-operations";
|
|
9
|
-
export * from "./lib/ai-service/prd-operations";
|
|
10
|
-
export * from "./lib/ai-service/documentation-operations";
|
|
11
|
-
export * from "./lib/executors/executor-factory";
|
|
12
|
-
export * from "./lib/prompt-builder";
|
|
13
|
-
export * from "./lib/task-execution";
|
|
14
|
-
export * from "./lib/task-loop-execution";
|
|
15
|
-
|
|
16
|
-
export * from "./services/tasks";
|
|
17
|
-
export * from "./services/workflow";
|
|
18
|
-
export * from "./services/prd";
|
|
19
|
-
export * from "./services/benchmark";
|
|
20
|
-
export * from "./lib/benchmark/registry";
|
|
21
|
-
export * from "./lib/benchmark/types";
|
|
22
|
-
|
|
23
|
-
export * from "./utils/ai-service-factory";
|
|
24
|
-
export * from "./utils/task-o-matic-error";
|
|
25
|
-
|
|
26
|
-
export * from "./lib/hooks";
|
|
27
|
-
|
|
28
|
-
// Moved to CLI:
|
|
29
|
-
// - ./utils/streaming-options
|
|
30
|
-
// - ./utils/display-helpers
|
|
31
|
-
// - ./lib/hooks/logger
|
|
32
|
-
|
|
33
|
-
export * from "./utils/model-executor-parser";
|
|
34
|
-
export * from "./utils/model-parser";
|
|
35
|
-
|
|
36
|
-
export * from "./prompts";
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AIConfig,
|
|
3
|
-
Task,
|
|
4
|
-
AIPRDParseResult,
|
|
5
|
-
DocumentationDetection,
|
|
6
|
-
StreamingOptions,
|
|
7
|
-
RetryConfig,
|
|
8
|
-
TaskDocumentation,
|
|
9
|
-
} from "../../types";
|
|
10
|
-
import { BaseOperations } from "./base-operations";
|
|
11
|
-
import { PRDOperations } from "./prd-operations";
|
|
12
|
-
import { TaskOperations } from "./task-operations";
|
|
13
|
-
import { DocumentationOperations } from "./documentation-operations";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Main AIOperations class that delegates to specialized operation classes.
|
|
17
|
-
* This provides a unified API for all AI operations while keeping the implementation modular.
|
|
18
|
-
*/
|
|
19
|
-
export class AIOperations extends BaseOperations {
|
|
20
|
-
private prdOps = new PRDOperations();
|
|
21
|
-
private taskOps = new TaskOperations();
|
|
22
|
-
private docOps = new DocumentationOperations();
|
|
23
|
-
|
|
24
|
-
// PRD Operations - Delegated to PRDOperations
|
|
25
|
-
|
|
26
|
-
async parsePRD(
|
|
27
|
-
prdContent: string,
|
|
28
|
-
config?: Partial<AIConfig>,
|
|
29
|
-
promptOverride?: string,
|
|
30
|
-
userMessage?: string,
|
|
31
|
-
streamingOptions?: StreamingOptions,
|
|
32
|
-
retryConfig?: Partial<RetryConfig>,
|
|
33
|
-
workingDirectory?: string,
|
|
34
|
-
enableFilesystemTools?: boolean
|
|
35
|
-
): Promise<AIPRDParseResult> {
|
|
36
|
-
return this.prdOps.parsePRD(
|
|
37
|
-
prdContent,
|
|
38
|
-
config,
|
|
39
|
-
promptOverride,
|
|
40
|
-
userMessage,
|
|
41
|
-
streamingOptions,
|
|
42
|
-
retryConfig,
|
|
43
|
-
workingDirectory,
|
|
44
|
-
enableFilesystemTools
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Task Operations - Delegated to TaskOperations
|
|
49
|
-
|
|
50
|
-
async breakdownTask(
|
|
51
|
-
task: Task,
|
|
52
|
-
config?: Partial<AIConfig>,
|
|
53
|
-
promptOverride?: string,
|
|
54
|
-
userMessage?: string,
|
|
55
|
-
streamingOptions?: StreamingOptions,
|
|
56
|
-
retryConfig?: Partial<RetryConfig>,
|
|
57
|
-
fullContent?: string,
|
|
58
|
-
stackInfo?: string,
|
|
59
|
-
existingSubtasks?: Task[],
|
|
60
|
-
enableFilesystemTools?: boolean
|
|
61
|
-
): Promise<
|
|
62
|
-
Array<{ title: string; content: string; estimatedEffort?: string }>
|
|
63
|
-
> {
|
|
64
|
-
return this.taskOps.breakdownTask(
|
|
65
|
-
task,
|
|
66
|
-
config,
|
|
67
|
-
promptOverride,
|
|
68
|
-
userMessage,
|
|
69
|
-
streamingOptions,
|
|
70
|
-
retryConfig,
|
|
71
|
-
fullContent,
|
|
72
|
-
stackInfo,
|
|
73
|
-
existingSubtasks,
|
|
74
|
-
enableFilesystemTools
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async enhanceTask(
|
|
79
|
-
title: string,
|
|
80
|
-
description?: string,
|
|
81
|
-
config?: Partial<AIConfig>,
|
|
82
|
-
promptOverride?: string,
|
|
83
|
-
userMessage?: string,
|
|
84
|
-
taskId?: string,
|
|
85
|
-
streamingOptions?: StreamingOptions,
|
|
86
|
-
retryConfig?: Partial<RetryConfig>
|
|
87
|
-
): Promise<string> {
|
|
88
|
-
return this.taskOps.enhanceTask(
|
|
89
|
-
title,
|
|
90
|
-
description,
|
|
91
|
-
config,
|
|
92
|
-
promptOverride,
|
|
93
|
-
userMessage,
|
|
94
|
-
taskId,
|
|
95
|
-
streamingOptions,
|
|
96
|
-
retryConfig
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async reworkPRD(
|
|
101
|
-
prdContent: string,
|
|
102
|
-
feedback: string,
|
|
103
|
-
config?: Partial<AIConfig>,
|
|
104
|
-
promptOverride?: string,
|
|
105
|
-
userMessage?: string,
|
|
106
|
-
streamingOptions?: StreamingOptions,
|
|
107
|
-
retryConfig?: Partial<RetryConfig>,
|
|
108
|
-
workingDirectory?: string,
|
|
109
|
-
enableFilesystemTools?: boolean
|
|
110
|
-
): Promise<string> {
|
|
111
|
-
return this.prdOps.reworkPRD(
|
|
112
|
-
prdContent,
|
|
113
|
-
feedback,
|
|
114
|
-
config,
|
|
115
|
-
promptOverride,
|
|
116
|
-
userMessage,
|
|
117
|
-
streamingOptions,
|
|
118
|
-
retryConfig,
|
|
119
|
-
workingDirectory,
|
|
120
|
-
enableFilesystemTools
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async generatePRDQuestions(
|
|
125
|
-
prdContent: string,
|
|
126
|
-
config?: Partial<AIConfig>,
|
|
127
|
-
promptOverride?: string,
|
|
128
|
-
userMessage?: string,
|
|
129
|
-
streamingOptions?: StreamingOptions,
|
|
130
|
-
retryConfig?: Partial<RetryConfig>,
|
|
131
|
-
workingDirectory?: string,
|
|
132
|
-
enableFilesystemTools?: boolean
|
|
133
|
-
): Promise<string[]> {
|
|
134
|
-
return this.prdOps.generatePRDQuestions(
|
|
135
|
-
prdContent,
|
|
136
|
-
config,
|
|
137
|
-
promptOverride,
|
|
138
|
-
userMessage,
|
|
139
|
-
streamingOptions,
|
|
140
|
-
retryConfig,
|
|
141
|
-
workingDirectory,
|
|
142
|
-
enableFilesystemTools
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async answerPRDQuestions(
|
|
147
|
-
prdContent: string,
|
|
148
|
-
questions: string[],
|
|
149
|
-
config?: Partial<AIConfig>,
|
|
150
|
-
contextInfo?: {
|
|
151
|
-
stackInfo?: string;
|
|
152
|
-
projectDescription?: string;
|
|
153
|
-
},
|
|
154
|
-
streamingOptions?: StreamingOptions,
|
|
155
|
-
retryConfig?: Partial<RetryConfig>
|
|
156
|
-
): Promise<Record<string, string>> {
|
|
157
|
-
return this.prdOps.answerPRDQuestions(
|
|
158
|
-
prdContent,
|
|
159
|
-
questions,
|
|
160
|
-
config,
|
|
161
|
-
contextInfo,
|
|
162
|
-
streamingOptions,
|
|
163
|
-
retryConfig
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async generatePRD(
|
|
168
|
-
description: string,
|
|
169
|
-
config?: Partial<AIConfig>,
|
|
170
|
-
promptOverride?: string,
|
|
171
|
-
userMessage?: string,
|
|
172
|
-
streamingOptions?: StreamingOptions,
|
|
173
|
-
retryConfig?: Partial<RetryConfig>
|
|
174
|
-
): Promise<string> {
|
|
175
|
-
return this.prdOps.generatePRD(
|
|
176
|
-
description,
|
|
177
|
-
config,
|
|
178
|
-
promptOverride,
|
|
179
|
-
userMessage,
|
|
180
|
-
streamingOptions,
|
|
181
|
-
retryConfig
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async combinePRDs(
|
|
186
|
-
prds: string[],
|
|
187
|
-
originalDescription: string,
|
|
188
|
-
config?: Partial<AIConfig>,
|
|
189
|
-
promptOverride?: string,
|
|
190
|
-
userMessage?: string,
|
|
191
|
-
streamingOptions?: StreamingOptions,
|
|
192
|
-
retryConfig?: Partial<RetryConfig>
|
|
193
|
-
): Promise<string> {
|
|
194
|
-
return this.prdOps.combinePRDs(
|
|
195
|
-
prds,
|
|
196
|
-
originalDescription,
|
|
197
|
-
config,
|
|
198
|
-
promptOverride,
|
|
199
|
-
userMessage,
|
|
200
|
-
streamingOptions,
|
|
201
|
-
retryConfig
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Documentation Operations - Delegated to DocumentationOperations
|
|
206
|
-
|
|
207
|
-
async enhanceTaskWithDocumentation(
|
|
208
|
-
taskId: string,
|
|
209
|
-
taskTitle: string,
|
|
210
|
-
taskDescription: string,
|
|
211
|
-
stackInfo?: string,
|
|
212
|
-
streamingOptions?: StreamingOptions,
|
|
213
|
-
retryConfig?: Partial<RetryConfig>,
|
|
214
|
-
config?: Partial<AIConfig>,
|
|
215
|
-
existingResearch?: Record<string, Array<{ query: string; doc: string }>>
|
|
216
|
-
): Promise<string> {
|
|
217
|
-
return this.docOps.enhanceTaskWithDocumentation(
|
|
218
|
-
taskId,
|
|
219
|
-
taskTitle,
|
|
220
|
-
taskDescription,
|
|
221
|
-
stackInfo,
|
|
222
|
-
streamingOptions,
|
|
223
|
-
retryConfig,
|
|
224
|
-
config,
|
|
225
|
-
existingResearch
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
async analyzeDocumentationNeeds(
|
|
230
|
-
taskId: string,
|
|
231
|
-
taskTitle: string,
|
|
232
|
-
taskDescription: string,
|
|
233
|
-
stackInfo?: string,
|
|
234
|
-
streamingOptions?: StreamingOptions,
|
|
235
|
-
retryConfig?: Partial<RetryConfig>,
|
|
236
|
-
config?: Partial<AIConfig>,
|
|
237
|
-
existingResearch?: (TaskDocumentation | undefined)[]
|
|
238
|
-
): Promise<DocumentationDetection> {
|
|
239
|
-
return this.docOps.analyzeDocumentationNeeds(
|
|
240
|
-
taskId,
|
|
241
|
-
taskTitle,
|
|
242
|
-
taskDescription,
|
|
243
|
-
stackInfo,
|
|
244
|
-
streamingOptions,
|
|
245
|
-
retryConfig,
|
|
246
|
-
config,
|
|
247
|
-
existingResearch
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
async generateDocumentationRecap(
|
|
252
|
-
libraries: Array<{ name: string; context7Id: string; reason: string }>,
|
|
253
|
-
documentContents: Array<{ library: string; content: string }>,
|
|
254
|
-
streamingOptions?: StreamingOptions,
|
|
255
|
-
retryConfig?: Partial<RetryConfig>
|
|
256
|
-
): Promise<string> {
|
|
257
|
-
return this.docOps.generateDocumentationRecap(
|
|
258
|
-
libraries,
|
|
259
|
-
documentContents,
|
|
260
|
-
streamingOptions,
|
|
261
|
-
retryConfig
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
async planTask(
|
|
266
|
-
taskContext: string,
|
|
267
|
-
taskDetails: string,
|
|
268
|
-
config?: Partial<AIConfig>,
|
|
269
|
-
promptOverride?: string,
|
|
270
|
-
userMessage?: string,
|
|
271
|
-
streamingOptions?: StreamingOptions,
|
|
272
|
-
retryConfig?: Partial<RetryConfig>
|
|
273
|
-
): Promise<string> {
|
|
274
|
-
return this.taskOps.planTask(
|
|
275
|
-
taskContext,
|
|
276
|
-
taskDetails,
|
|
277
|
-
config,
|
|
278
|
-
promptOverride,
|
|
279
|
-
userMessage,
|
|
280
|
-
streamingOptions,
|
|
281
|
-
retryConfig
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Stack suggestion - Delegated to PRDOperations
|
|
286
|
-
|
|
287
|
-
async suggestStack(
|
|
288
|
-
prdContent: string,
|
|
289
|
-
projectName?: string,
|
|
290
|
-
config?: Partial<AIConfig>,
|
|
291
|
-
promptOverride?: string,
|
|
292
|
-
userMessage?: string,
|
|
293
|
-
streamingOptions?: StreamingOptions,
|
|
294
|
-
retryConfig?: Partial<RetryConfig>,
|
|
295
|
-
workingDirectory?: string,
|
|
296
|
-
enableFilesystemTools?: boolean
|
|
297
|
-
): Promise<{ config: import("../../types").BTSConfig; reasoning: string }> {
|
|
298
|
-
return this.prdOps.suggestStack(
|
|
299
|
-
prdContent,
|
|
300
|
-
projectName,
|
|
301
|
-
config,
|
|
302
|
-
promptOverride,
|
|
303
|
-
userMessage,
|
|
304
|
-
streamingOptions,
|
|
305
|
-
retryConfig,
|
|
306
|
-
workingDirectory,
|
|
307
|
-
enableFilesystemTools
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { streamText, type LanguageModel } from "ai";
|
|
2
|
-
import { AIConfig, StreamingOptions, RetryConfig } from "../../types";
|
|
3
|
-
import { JSONParser } from "./json-parser";
|
|
4
|
-
import { Context7Client } from "./mcp-client";
|
|
5
|
-
import { RetryHandler } from "./retry-handler";
|
|
6
|
-
import { ModelProvider } from "./model-provider";
|
|
7
|
-
|
|
8
|
-
export class BaseOperations {
|
|
9
|
-
protected jsonParser = new JSONParser();
|
|
10
|
-
protected context7Client = new Context7Client();
|
|
11
|
-
protected retryHandler = new RetryHandler();
|
|
12
|
-
protected modelProvider = new ModelProvider();
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Merges AI configuration with proper precedence.
|
|
16
|
-
*
|
|
17
|
-
* Configuration precedence (highest to lowest):
|
|
18
|
-
* 1. Method parameter `config` (operation-specific overrides)
|
|
19
|
-
* 2. ConfigManager global config (project-level settings)
|
|
20
|
-
* 3. Environment variables (OPENAI_API_KEY, etc.)
|
|
21
|
-
* 4. Provider defaults (defined in config.ts)
|
|
22
|
-
*
|
|
23
|
-
* @param config - Optional operation-specific config overrides
|
|
24
|
-
* @returns Merged AIConfig with all precedence levels applied
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* // Override just the model for this operation
|
|
29
|
-
* const finalConfig = this.mergeAIConfig({ model: "gpt-4o" });
|
|
30
|
-
*
|
|
31
|
-
* // Use default config (from ConfigManager + env vars)
|
|
32
|
-
* const finalConfig = this.mergeAIConfig();
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
protected mergeAIConfig(config?: Partial<AIConfig>): AIConfig {
|
|
36
|
-
// Get base config (includes ConfigManager + env vars + defaults)
|
|
37
|
-
const baseConfig = this.modelProvider.getAIConfig();
|
|
38
|
-
|
|
39
|
-
// Apply operation-specific overrides (highest priority)
|
|
40
|
-
return { ...baseConfig, ...config };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Handles Context7 tool results by caching documentation.
|
|
45
|
-
* Extracts and saves documentation from get-library-docs tool results.
|
|
46
|
-
*
|
|
47
|
-
* @param chunk - The chunk to check for Context7 tool results
|
|
48
|
-
* @protected
|
|
49
|
-
*/
|
|
50
|
-
protected handleContext7ToolResult(chunk: any): void {
|
|
51
|
-
if (chunk.type === "tool-result" && chunk.toolName === "get-library-docs") {
|
|
52
|
-
const docs = chunk.output;
|
|
53
|
-
const libraryID = chunk.input?.context7CompatibleLibraryID || "unknown";
|
|
54
|
-
const topic = chunk.input?.topic || "general";
|
|
55
|
-
|
|
56
|
-
if (docs && typeof docs === "object" && "content" in docs) {
|
|
57
|
-
this.context7Client.saveContext7Documentation(
|
|
58
|
-
libraryID,
|
|
59
|
-
docs.content,
|
|
60
|
-
topic
|
|
61
|
-
);
|
|
62
|
-
} else if (docs && typeof docs === "string") {
|
|
63
|
-
this.context7Client.saveContext7Documentation(libraryID, docs, topic);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async streamText(
|
|
69
|
-
prompt: string,
|
|
70
|
-
config?: Partial<AIConfig>,
|
|
71
|
-
systemPrompt?: string,
|
|
72
|
-
userMessage?: string,
|
|
73
|
-
streamingOptions?: StreamingOptions,
|
|
74
|
-
retryConfig?: Partial<RetryConfig>
|
|
75
|
-
): Promise<string> {
|
|
76
|
-
// Merge config with proper precedence (Bug fix 2.9)
|
|
77
|
-
const aiConfig = this.mergeAIConfig(config);
|
|
78
|
-
|
|
79
|
-
return this.retryHandler.executeWithRetry(
|
|
80
|
-
async () => {
|
|
81
|
-
const model = this.modelProvider.getModel(aiConfig);
|
|
82
|
-
|
|
83
|
-
const result = streamText({
|
|
84
|
-
model,
|
|
85
|
-
system: systemPrompt,
|
|
86
|
-
messages: [{ role: "user", content: userMessage || prompt }],
|
|
87
|
-
maxRetries: 0,
|
|
88
|
-
onError: ({ error }) => {
|
|
89
|
-
streamingOptions?.onError?.(error);
|
|
90
|
-
throw error;
|
|
91
|
-
},
|
|
92
|
-
onChunk: streamingOptions?.onChunk
|
|
93
|
-
? ({ chunk }) => {
|
|
94
|
-
if (chunk.type === "text-delta") {
|
|
95
|
-
streamingOptions.onChunk!(chunk.text);
|
|
96
|
-
} else if (chunk.type === "reasoning-delta") {
|
|
97
|
-
streamingOptions.onReasoning?.(chunk.text);
|
|
98
|
-
}
|
|
99
|
-
// Handle Context7 tool result caching
|
|
100
|
-
this.handleContext7ToolResult(chunk);
|
|
101
|
-
}
|
|
102
|
-
: undefined,
|
|
103
|
-
onFinish: streamingOptions?.onFinish
|
|
104
|
-
? ({ text, finishReason, usage }) => {
|
|
105
|
-
streamingOptions.onFinish!({
|
|
106
|
-
text,
|
|
107
|
-
finishReason,
|
|
108
|
-
usage,
|
|
109
|
-
isAborted: false,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
: undefined,
|
|
113
|
-
...(aiConfig.provider === "openrouter" &&
|
|
114
|
-
aiConfig.reasoning &&
|
|
115
|
-
aiConfig.reasoning.maxTokens
|
|
116
|
-
? {
|
|
117
|
-
providerOptions: {
|
|
118
|
-
openrouter: {
|
|
119
|
-
reasoning: {
|
|
120
|
-
max_tokens: aiConfig.reasoning.maxTokens,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
}
|
|
125
|
-
: {}),
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
let fullText = "";
|
|
129
|
-
for await (const textPart of result.textStream) {
|
|
130
|
-
fullText += textPart;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return fullText;
|
|
134
|
-
},
|
|
135
|
-
retryConfig,
|
|
136
|
-
"AI streaming"
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
}
|