task-o-matic 0.0.6 → 0.0.8
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/README.md +86 -23
- package/dist/commands/benchmark.d.ts +3 -0
- package/dist/commands/benchmark.d.ts.map +1 -0
- package/dist/commands/benchmark.js +227 -0
- package/dist/commands/prd.d.ts.map +1 -1
- package/dist/commands/prd.js +203 -9
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +464 -286
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/lib/ai-service/ai-operations.d.ts +5 -0
- package/dist/lib/ai-service/ai-operations.d.ts.map +1 -1
- package/dist/lib/ai-service/ai-operations.js +167 -0
- package/dist/lib/benchmark/registry.d.ts +11 -0
- package/dist/lib/benchmark/registry.d.ts.map +1 -0
- package/dist/lib/benchmark/registry.js +78 -0
- package/dist/lib/benchmark/runner.d.ts +6 -0
- package/dist/lib/benchmark/runner.d.ts.map +1 -0
- package/dist/lib/benchmark/runner.js +150 -0
- package/dist/lib/benchmark/storage.d.ts +13 -0
- package/dist/lib/benchmark/storage.d.ts.map +1 -0
- package/dist/lib/benchmark/storage.js +99 -0
- package/dist/lib/benchmark/types.d.ts +54 -0
- package/dist/lib/benchmark/types.d.ts.map +1 -0
- package/dist/lib/benchmark/types.js +2 -0
- package/dist/lib/index.d.ts +9 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +7 -1
- package/dist/lib/prompt-registry.d.ts.map +1 -1
- package/dist/lib/prompt-registry.js +23 -0
- package/dist/prompts/index.d.ts +7 -6
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +1 -0
- package/dist/prompts/prd-question.d.ts +3 -0
- package/dist/prompts/prd-question.d.ts.map +1 -0
- package/dist/prompts/prd-question.js +40 -0
- package/dist/services/benchmark.d.ts +12 -0
- package/dist/services/benchmark.d.ts.map +1 -0
- package/dist/services/benchmark.js +18 -0
- package/dist/services/prd.d.ts +25 -0
- package/dist/services/prd.d.ts.map +1 -1
- package/dist/services/prd.js +188 -28
- package/dist/services/workflow.d.ts +85 -0
- package/dist/services/workflow.d.ts.map +1 -0
- package/dist/services/workflow.js +363 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/options.d.ts +3 -1
- package/dist/types/options.d.ts.map +1 -1
- package/dist/types/options.js +16 -0
- package/dist/types/workflow-options.d.ts +45 -0
- package/dist/types/workflow-options.d.ts.map +1 -0
- package/dist/types/workflow-options.js +2 -0
- package/dist/types/workflow-results.d.ts +55 -0
- package/dist/types/workflow-results.d.ts.map +1 -0
- package/dist/types/workflow-results.js +2 -0
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,QAAA,MAAM,OAAO,SAAgB,CAAC;AA+C9B;;;GAGG;AACH,eAAO,MAAM,MAAM,qBAUlB,CAAC;AAEF;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ const prd_1 = require("./commands/prd");
|
|
|
18
18
|
const init_1 = require("./commands/init");
|
|
19
19
|
const prompt_1 = require("./commands/prompt");
|
|
20
20
|
const workflow_1 = require("./commands/workflow");
|
|
21
|
+
const benchmark_1 = require("./commands/benchmark");
|
|
21
22
|
const config_2 = require("./lib/config");
|
|
22
23
|
const program = new commander_1.Command();
|
|
23
24
|
exports.program = program;
|
|
@@ -33,6 +34,7 @@ program.addCommand(prd_1.prdCommand);
|
|
|
33
34
|
program.addCommand(prompt_1.promptCommand);
|
|
34
35
|
program.addCommand(init_1.initCommand);
|
|
35
36
|
program.addCommand(workflow_1.workflowCommand);
|
|
37
|
+
program.addCommand(benchmark_1.benchmarkCommand);
|
|
36
38
|
// Default action - show help
|
|
37
39
|
program.action(() => {
|
|
38
40
|
console.log(chalk_1.default.blue("🚀 AI-Powered Task Management CLI"));
|
|
@@ -15,6 +15,11 @@ export declare class AIOperations {
|
|
|
15
15
|
enhanceTask(title: string, description?: string, config?: Partial<AIConfig>, promptOverride?: string, userMessage?: string, taskId?: string, streamingOptions?: StreamingOptions, retryConfig?: Partial<RetryConfig>): Promise<string>;
|
|
16
16
|
reworkPRD(prdContent: string, feedback: string, config?: Partial<AIConfig>, promptOverride?: string, userMessage?: string, streamingOptions?: StreamingOptions, retryConfig?: Partial<RetryConfig>, workingDirectory?: string, // Working directory passed from service layer
|
|
17
17
|
enableFilesystemTools?: boolean): Promise<string>;
|
|
18
|
+
generatePRDQuestions(prdContent: string, config?: Partial<AIConfig>, promptOverride?: string, userMessage?: string, streamingOptions?: StreamingOptions, retryConfig?: Partial<RetryConfig>, workingDirectory?: string, enableFilesystemTools?: boolean): Promise<string[]>;
|
|
19
|
+
answerPRDQuestions(prdContent: string, questions: string[], config?: Partial<AIConfig>, contextInfo?: {
|
|
20
|
+
stackInfo?: string;
|
|
21
|
+
projectDescription?: string;
|
|
22
|
+
}, streamingOptions?: StreamingOptions, retryConfig?: Partial<RetryConfig>): Promise<Record<string, string>>;
|
|
18
23
|
enhanceTaskWithDocumentation(taskId: string, taskTitle: string, taskDescription: string, stackInfo?: string, streamingOptions?: StreamingOptions, retryConfig?: Partial<RetryConfig>, config?: Partial<AIConfig>, existingResearch?: Record<string, Array<{
|
|
19
24
|
query: string;
|
|
20
25
|
doc: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-operations.d.ts","sourceRoot":"","sources":["../../../src/lib/ai-service/ai-operations.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EAGX,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ai-operations.d.ts","sourceRoot":"","sources":["../../../src/lib/ai-service/ai-operations.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EAGX,iBAAiB,EAElB,MAAM,aAAa,CAAC;AAkBrB,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,cAAc,CAAwB;IAC9C,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,aAAa,CAAuB;IAGtC,UAAU,CACd,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC1B,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,MAAM,EACpB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GACjC,OAAO,CAAC,MAAM,CAAC;IAiFZ,QAAQ,CACZ,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC1B,cAAc,CAAC,EAAE,MAAM,EACvB,WAAW,CAAC,EAAE,MAAM,EACpB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,EAClC,gBAAgB,CAAC,EAAE,MAAM,EAAE,8CAA8C;IACzE,qBAAqB,CAAC,EAAE,OAAO,GAC9B,OAAO,CAAC,gBAAgB,CAAC;IAkLtB,aAAa,CACjB,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC1B,cAAc,CAAC,EAAE,MAAM,EACvB,WA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C,EAAE,CAAC,iBAAiB,GAAG,SAAS,CAAC,EAAE,GACnD,OAAO,CAAC,sBAAsB,CAAC;IAgN5B,0BAA0B,CAC9B,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,EACtE,gBAAgB,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,EAC7D,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GACjC,OAAO,CAAC,MAAM,CAAC;IA+BZ,QAAQ,CACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC1B,cAAc,CAAC,EAAE,MAAM,EACvB,WAAW,CAAC,EAAE,MAAM,EACpB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GACjC,OAAO,CAAC,GAAG,CAAC;CA8EhB"}
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.AIOperations = void 0;
|
|
4
37
|
const ai_1 = require("ai");
|
|
@@ -464,6 +497,140 @@ Use these tools to understand the current project structure, existing code patte
|
|
|
464
497
|
}
|
|
465
498
|
}, retryConfig, "PRD rework");
|
|
466
499
|
}
|
|
500
|
+
async generatePRDQuestions(prdContent, config, promptOverride, userMessage, streamingOptions, retryConfig, workingDirectory, enableFilesystemTools) {
|
|
501
|
+
return this.retryHandler.executeWithRetry(async () => {
|
|
502
|
+
let stackInfo = "";
|
|
503
|
+
try {
|
|
504
|
+
stackInfo = await prompt_builder_1.PromptBuilder.detectStackInfo(workingDirectory);
|
|
505
|
+
if (stackInfo === "Not detected") {
|
|
506
|
+
stackInfo = "";
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
// Stack info not available
|
|
511
|
+
}
|
|
512
|
+
let prompt;
|
|
513
|
+
if (promptOverride) {
|
|
514
|
+
prompt = promptOverride;
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
const variables = {
|
|
518
|
+
PRD_CONTENT: prdContent,
|
|
519
|
+
};
|
|
520
|
+
if (stackInfo) {
|
|
521
|
+
variables.STACK_INFO = stackInfo;
|
|
522
|
+
}
|
|
523
|
+
const promptResult = prompt_builder_1.PromptBuilder.buildPrompt({
|
|
524
|
+
name: "prd-question",
|
|
525
|
+
type: "user",
|
|
526
|
+
variables,
|
|
527
|
+
});
|
|
528
|
+
if (!promptResult.success) {
|
|
529
|
+
throw new Error(`Failed to build PRD question prompt: ${promptResult.error}`);
|
|
530
|
+
}
|
|
531
|
+
prompt = promptResult.prompt;
|
|
532
|
+
}
|
|
533
|
+
// Use PRD_QUESTION_SYSTEM_PROMPT import
|
|
534
|
+
const { PRD_QUESTION_SYSTEM_PROMPT } = await Promise.resolve().then(() => __importStar(require("../../prompts")));
|
|
535
|
+
let response;
|
|
536
|
+
if (enableFilesystemTools) {
|
|
537
|
+
const model = this.modelProvider.getModel({
|
|
538
|
+
...this.modelProvider.getAIConfig(),
|
|
539
|
+
...config,
|
|
540
|
+
});
|
|
541
|
+
const allTools = { ...filesystem_tools_1.filesystemTools };
|
|
542
|
+
const result = await (0, ai_1.streamText)({
|
|
543
|
+
model,
|
|
544
|
+
tools: allTools,
|
|
545
|
+
system: PRD_QUESTION_SYSTEM_PROMPT +
|
|
546
|
+
`\n\nYou have access to filesystem tools to check existing code/structure if needed.`,
|
|
547
|
+
messages: [{ role: "user", content: userMessage || prompt }],
|
|
548
|
+
maxRetries: 0,
|
|
549
|
+
onChunk: streamingOptions?.onChunk
|
|
550
|
+
? ({ chunk }) => {
|
|
551
|
+
if (chunk.type === "text-delta") {
|
|
552
|
+
streamingOptions.onChunk(chunk.text);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
: undefined,
|
|
556
|
+
onFinish: streamingOptions?.onFinish
|
|
557
|
+
? ({ text, finishReason, usage }) => {
|
|
558
|
+
streamingOptions.onFinish({
|
|
559
|
+
text,
|
|
560
|
+
finishReason,
|
|
561
|
+
usage,
|
|
562
|
+
isAborted: false,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
: undefined,
|
|
566
|
+
});
|
|
567
|
+
response = await result.text;
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
response = await this.streamText("", config, PRD_QUESTION_SYSTEM_PROMPT, userMessage || prompt, streamingOptions, { maxAttempts: 1 });
|
|
571
|
+
}
|
|
572
|
+
const parseResult = this.jsonParser.parseJSONFromResponse(response);
|
|
573
|
+
if (!parseResult.success) {
|
|
574
|
+
throw new Error(parseResult.error || "Failed to parse PRD questions");
|
|
575
|
+
}
|
|
576
|
+
return parseResult.data?.questions || [];
|
|
577
|
+
}, retryConfig, "PRD questioning");
|
|
578
|
+
}
|
|
579
|
+
async answerPRDQuestions(prdContent, questions, config, contextInfo, streamingOptions, retryConfig) {
|
|
580
|
+
return this.retryHandler.executeWithRetry(async () => {
|
|
581
|
+
// Build prompt for answering questions
|
|
582
|
+
const questionsText = questions
|
|
583
|
+
.map((q, i) => `${i + 1}. ${q}`)
|
|
584
|
+
.join("\n");
|
|
585
|
+
const contextText = contextInfo
|
|
586
|
+
? `\n\nProject Context:\n${contextInfo.stackInfo
|
|
587
|
+
? `Technology Stack: ${contextInfo.stackInfo}\n`
|
|
588
|
+
: ""}${contextInfo.projectDescription
|
|
589
|
+
? `Project Description: ${contextInfo.projectDescription}\n`
|
|
590
|
+
: ""}`
|
|
591
|
+
: "";
|
|
592
|
+
const prompt = `You are a product expert helping to clarify a PRD.
|
|
593
|
+
|
|
594
|
+
PRD Content:
|
|
595
|
+
${prdContent}${contextText}
|
|
596
|
+
|
|
597
|
+
Please answer the following questions based on the PRD and context:
|
|
598
|
+
|
|
599
|
+
${questionsText}
|
|
600
|
+
|
|
601
|
+
Provide thoughtful, specific answers that will help refine the PRD.
|
|
602
|
+
Format your response as JSON with the following structure:
|
|
603
|
+
{
|
|
604
|
+
"answers": {
|
|
605
|
+
"1": "answer to question 1",
|
|
606
|
+
"2": "answer to question 2",
|
|
607
|
+
...
|
|
608
|
+
}
|
|
609
|
+
}`;
|
|
610
|
+
const systemPrompt = `You are a product expert analyzing PRDs and answering clarifying questions.
|
|
611
|
+
Your answers should be:
|
|
612
|
+
- Specific and actionable
|
|
613
|
+
- Based on the PRD content and project context
|
|
614
|
+
- Helpful for refining the PRD
|
|
615
|
+
- Formatted as JSON`;
|
|
616
|
+
const response = await this.streamText("", config, systemPrompt, prompt, streamingOptions, { maxAttempts: 1 });
|
|
617
|
+
// Parse JSON response
|
|
618
|
+
const parseResult = this.jsonParser.parseJSONFromResponse(response);
|
|
619
|
+
if (!parseResult.success) {
|
|
620
|
+
throw new Error(parseResult.error || "Failed to parse PRD answers response");
|
|
621
|
+
}
|
|
622
|
+
// Convert numbered keys to question text keys
|
|
623
|
+
const answers = {};
|
|
624
|
+
const numberedAnswers = parseResult.data?.answers || {};
|
|
625
|
+
questions.forEach((question, index) => {
|
|
626
|
+
const key = String(index + 1);
|
|
627
|
+
if (numberedAnswers[key]) {
|
|
628
|
+
answers[question] = numberedAnswers[key];
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
return answers;
|
|
632
|
+
}, retryConfig, "PRD question answering");
|
|
633
|
+
}
|
|
467
634
|
// Context7 Integration Methods
|
|
468
635
|
async enhanceTaskWithDocumentation(taskId, taskTitle, taskDescription, stackInfo, streamingOptions, retryConfig, config, existingResearch
|
|
469
636
|
// existingResearch?: (TaskDocumentation | undefined)[],
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BenchmarkableOperation } from "./types";
|
|
2
|
+
export declare class BenchmarkRegistry {
|
|
3
|
+
private operations;
|
|
4
|
+
constructor();
|
|
5
|
+
register(op: BenchmarkableOperation): void;
|
|
6
|
+
get(id: string): BenchmarkableOperation | undefined;
|
|
7
|
+
list(): BenchmarkableOperation[];
|
|
8
|
+
private registerDefaults;
|
|
9
|
+
}
|
|
10
|
+
export declare const benchmarkRegistry: BenchmarkRegistry;
|
|
11
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/benchmark/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAMjD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAkD;;IAMpE,QAAQ,CAAC,EAAE,EAAE,sBAAsB;IAInC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAInD,IAAI,IAAI,sBAAsB,EAAE;IAIhC,OAAO,CAAC,gBAAgB;CA+EzB;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.benchmarkRegistry = exports.BenchmarkRegistry = void 0;
|
|
4
|
+
const prd_1 = require("../../services/prd");
|
|
5
|
+
const tasks_1 = require("../../services/tasks"); // We'll need to instantiate this or use a singleton if available
|
|
6
|
+
class BenchmarkRegistry {
|
|
7
|
+
operations = new Map();
|
|
8
|
+
constructor() {
|
|
9
|
+
this.registerDefaults();
|
|
10
|
+
}
|
|
11
|
+
register(op) {
|
|
12
|
+
this.operations.set(op.id, op);
|
|
13
|
+
}
|
|
14
|
+
get(id) {
|
|
15
|
+
return this.operations.get(id);
|
|
16
|
+
}
|
|
17
|
+
list() {
|
|
18
|
+
return Array.from(this.operations.values());
|
|
19
|
+
}
|
|
20
|
+
registerDefaults() {
|
|
21
|
+
// PRD Parsing Adapter
|
|
22
|
+
this.register({
|
|
23
|
+
id: "prd-parse",
|
|
24
|
+
name: "PRD Parsing",
|
|
25
|
+
description: "Parse a PRD file into tasks",
|
|
26
|
+
validateInput: (input) => typeof input.file === "string" && input.file.length > 0,
|
|
27
|
+
execute: async (input, aiOptions, streamingOptions) => {
|
|
28
|
+
return await prd_1.prdService.parsePRD({
|
|
29
|
+
file: input.file,
|
|
30
|
+
workingDirectory: input.workingDirectory,
|
|
31
|
+
enableFilesystemTools: input.tools,
|
|
32
|
+
promptOverride: input.prompt,
|
|
33
|
+
messageOverride: input.message,
|
|
34
|
+
aiOptions,
|
|
35
|
+
streamingOptions,
|
|
36
|
+
callbacks: {},
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
// PRD Rework Adapter
|
|
41
|
+
this.register({
|
|
42
|
+
id: "prd-rework",
|
|
43
|
+
name: "PRD Rework",
|
|
44
|
+
description: "Rework a PRD based on feedback",
|
|
45
|
+
validateInput: (input) => typeof input.file === "string" && typeof input.feedback === "string",
|
|
46
|
+
execute: async (input, aiOptions, streamingOptions) => {
|
|
47
|
+
return await prd_1.prdService.reworkPRD({
|
|
48
|
+
file: input.file,
|
|
49
|
+
feedback: input.feedback,
|
|
50
|
+
workingDirectory: input.workingDirectory,
|
|
51
|
+
enableFilesystemTools: input.tools,
|
|
52
|
+
promptOverride: input.prompt,
|
|
53
|
+
messageOverride: input.message,
|
|
54
|
+
aiOptions,
|
|
55
|
+
streamingOptions,
|
|
56
|
+
callbacks: {},
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
// Task Breakdown Adapter
|
|
61
|
+
// Note: TaskService is a class, we need an instance.
|
|
62
|
+
// In a real app we should use dependency injection or a singleton.
|
|
63
|
+
// For now, we'll create a new instance or assume one is available.
|
|
64
|
+
const taskService = new tasks_1.TaskService();
|
|
65
|
+
this.register({
|
|
66
|
+
id: "task-breakdown",
|
|
67
|
+
name: "Task Breakdown",
|
|
68
|
+
description: "Break down a task into subtasks",
|
|
69
|
+
validateInput: (input) => typeof input.taskId === "string",
|
|
70
|
+
execute: async (input, aiOptions, streamingOptions) => {
|
|
71
|
+
return await taskService.splitTask(input.taskId, aiOptions, input.prompt, input.message, streamingOptions, // streaming options
|
|
72
|
+
input.tools);
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.BenchmarkRegistry = BenchmarkRegistry;
|
|
78
|
+
exports.benchmarkRegistry = new BenchmarkRegistry();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BenchmarkConfig, BenchmarkRun, BenchmarkProgressEvent } from "./types";
|
|
2
|
+
export declare class BenchmarkRunner {
|
|
3
|
+
run(operationId: string, input: any, config: BenchmarkConfig, onProgress?: (event: BenchmarkProgressEvent) => void): Promise<BenchmarkRun>;
|
|
4
|
+
}
|
|
5
|
+
export declare const benchmarkRunner: BenchmarkRunner;
|
|
6
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/lib/benchmark/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,YAAY,EACZ,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAMjB,qBAAa,eAAe;IACpB,GAAG,CACP,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,eAAe,EACvB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,GACnD,OAAO,CAAC,YAAY,CAAC;CA0KzB;AAED,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.benchmarkRunner = exports.BenchmarkRunner = void 0;
|
|
4
|
+
const registry_1 = require("./registry");
|
|
5
|
+
const storage_1 = require("./storage");
|
|
6
|
+
class BenchmarkRunner {
|
|
7
|
+
async run(operationId, input, config, onProgress) {
|
|
8
|
+
const operation = registry_1.benchmarkRegistry.get(operationId);
|
|
9
|
+
if (!operation) {
|
|
10
|
+
throw new Error(`Operation ${operationId} not found`);
|
|
11
|
+
}
|
|
12
|
+
if (!operation.validateInput(input)) {
|
|
13
|
+
throw new Error(`Invalid input for operation ${operationId}`);
|
|
14
|
+
}
|
|
15
|
+
const runId = `run-${Date.now()}`;
|
|
16
|
+
const results = [];
|
|
17
|
+
// Create a queue of models to process
|
|
18
|
+
const queue = [...config.models];
|
|
19
|
+
const activePromises = [];
|
|
20
|
+
// Helper to process a single model
|
|
21
|
+
const processModel = async (modelConfig) => {
|
|
22
|
+
const modelId = `${modelConfig.provider}:${modelConfig.model}${modelConfig.reasoningTokens
|
|
23
|
+
? `:reasoning=${modelConfig.reasoningTokens}`
|
|
24
|
+
: ""}`;
|
|
25
|
+
const startTime = Date.now();
|
|
26
|
+
let output;
|
|
27
|
+
let error;
|
|
28
|
+
let tokenUsage;
|
|
29
|
+
let responseSize = 0;
|
|
30
|
+
let firstTokenTime;
|
|
31
|
+
// Emit start event
|
|
32
|
+
onProgress?.({ type: "start", modelId });
|
|
33
|
+
try {
|
|
34
|
+
// Construct AI options for this specific run
|
|
35
|
+
const aiOptions = {
|
|
36
|
+
aiProvider: modelConfig.provider,
|
|
37
|
+
aiModel: modelConfig.model,
|
|
38
|
+
aiReasoning: modelConfig.reasoningTokens,
|
|
39
|
+
};
|
|
40
|
+
// Setup streaming options to capture metrics
|
|
41
|
+
const streamingOptions = {
|
|
42
|
+
onFinish: async (result) => {
|
|
43
|
+
if (result.usage) {
|
|
44
|
+
tokenUsage = {
|
|
45
|
+
prompt: result.usage.inputTokens || result.usage.promptTokens || 0,
|
|
46
|
+
completion: result.usage.outputTokens ||
|
|
47
|
+
result.usage.completionTokens ||
|
|
48
|
+
0,
|
|
49
|
+
total: result.usage.totalTokens || 0,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// Estimate response size from text length if available, or JSON stringify
|
|
53
|
+
if (result.text) {
|
|
54
|
+
responseSize = Buffer.byteLength(result.text, "utf8");
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
onChunk: (chunk) => {
|
|
58
|
+
if (chunk) {
|
|
59
|
+
if (!firstTokenTime) {
|
|
60
|
+
firstTokenTime = Date.now();
|
|
61
|
+
}
|
|
62
|
+
const chunkSize = Buffer.byteLength(chunk, "utf8");
|
|
63
|
+
responseSize += chunkSize;
|
|
64
|
+
const currentDuration = Date.now() - startTime;
|
|
65
|
+
const currentBps = currentDuration > 0
|
|
66
|
+
? Math.round(responseSize / (currentDuration / 1000))
|
|
67
|
+
: 0;
|
|
68
|
+
onProgress?.({
|
|
69
|
+
type: "progress",
|
|
70
|
+
modelId,
|
|
71
|
+
currentSize: responseSize,
|
|
72
|
+
currentBps,
|
|
73
|
+
chunk: chunk,
|
|
74
|
+
duration: currentDuration,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
// Execute operation
|
|
80
|
+
output = await operation.execute(input, aiOptions, streamingOptions);
|
|
81
|
+
// If responseSize wasn't captured via streaming (e.g. non-streaming response), calculate from output
|
|
82
|
+
if (responseSize === 0 && output) {
|
|
83
|
+
const outputStr = typeof output === "string" ? output : JSON.stringify(output);
|
|
84
|
+
responseSize = Buffer.byteLength(outputStr, "utf8");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
error = e.message || String(e);
|
|
89
|
+
onProgress?.({ type: "error", modelId, error });
|
|
90
|
+
}
|
|
91
|
+
const duration = Date.now() - startTime;
|
|
92
|
+
const bps = duration > 0 && responseSize > 0
|
|
93
|
+
? Math.round(responseSize / (duration / 1000))
|
|
94
|
+
: 0;
|
|
95
|
+
const tps = duration > 0 && tokenUsage?.completion
|
|
96
|
+
? Math.round(tokenUsage.completion / (duration / 1000))
|
|
97
|
+
: 0;
|
|
98
|
+
results.push({
|
|
99
|
+
modelId,
|
|
100
|
+
output,
|
|
101
|
+
duration,
|
|
102
|
+
error,
|
|
103
|
+
timestamp: Date.now(),
|
|
104
|
+
tokenUsage,
|
|
105
|
+
responseSize,
|
|
106
|
+
bps,
|
|
107
|
+
tps,
|
|
108
|
+
timeToFirstToken: firstTokenTime
|
|
109
|
+
? firstTokenTime - startTime
|
|
110
|
+
: undefined,
|
|
111
|
+
});
|
|
112
|
+
// Emit complete event
|
|
113
|
+
onProgress?.({ type: "complete", modelId, duration });
|
|
114
|
+
};
|
|
115
|
+
// Process queue with concurrency limit
|
|
116
|
+
while (queue.length > 0 || activePromises.length > 0) {
|
|
117
|
+
// Fill active promises up to concurrency limit
|
|
118
|
+
while (queue.length > 0 && activePromises.length < config.concurrency) {
|
|
119
|
+
const modelConfig = queue.shift();
|
|
120
|
+
if (modelConfig) {
|
|
121
|
+
const promise = processModel(modelConfig).then(() => {
|
|
122
|
+
// Remove self from active promises
|
|
123
|
+
activePromises.splice(activePromises.indexOf(promise), 1);
|
|
124
|
+
});
|
|
125
|
+
activePromises.push(promise);
|
|
126
|
+
// Add delay if configured and there are more items
|
|
127
|
+
if (config.delay > 0 && queue.length > 0) {
|
|
128
|
+
await new Promise((resolve) => setTimeout(resolve, config.delay));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Wait for at least one promise to complete if we're at capacity or queue is empty
|
|
133
|
+
if (activePromises.length > 0) {
|
|
134
|
+
await Promise.race(activePromises);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const run = {
|
|
138
|
+
id: runId,
|
|
139
|
+
timestamp: Date.now(),
|
|
140
|
+
command: operationId,
|
|
141
|
+
input,
|
|
142
|
+
config,
|
|
143
|
+
results,
|
|
144
|
+
};
|
|
145
|
+
storage_1.benchmarkStorage.saveRun(run);
|
|
146
|
+
return run;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.BenchmarkRunner = BenchmarkRunner;
|
|
150
|
+
exports.benchmarkRunner = new BenchmarkRunner();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BenchmarkRun } from "./types";
|
|
2
|
+
export declare class BenchmarkStorage {
|
|
3
|
+
private getBenchmarkDir;
|
|
4
|
+
saveRun(run: BenchmarkRun): string;
|
|
5
|
+
getRun(id: string): BenchmarkRun | null;
|
|
6
|
+
listRuns(): Array<{
|
|
7
|
+
id: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
command: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export declare const benchmarkStorage: BenchmarkStorage;
|
|
13
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/lib/benchmark/storage.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM;IA+ClC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAyCvC,QAAQ,IAAI,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CA2BtE;AAED,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.benchmarkStorage = exports.BenchmarkStorage = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const config_1 = require("../config");
|
|
7
|
+
class BenchmarkStorage {
|
|
8
|
+
getBenchmarkDir() {
|
|
9
|
+
const taskOMaticDir = config_1.configManager.getTaskOMaticDir();
|
|
10
|
+
const benchmarkDir = (0, path_1.join)(taskOMaticDir, "benchmarks");
|
|
11
|
+
if (!(0, fs_1.existsSync)(benchmarkDir)) {
|
|
12
|
+
(0, fs_1.mkdirSync)(benchmarkDir, { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
return benchmarkDir;
|
|
15
|
+
}
|
|
16
|
+
saveRun(run) {
|
|
17
|
+
const dir = this.getBenchmarkDir();
|
|
18
|
+
const runDir = (0, path_1.join)(dir, run.id);
|
|
19
|
+
if (!(0, fs_1.existsSync)(runDir)) {
|
|
20
|
+
(0, fs_1.mkdirSync)(runDir, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
// Save metadata
|
|
23
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(runDir, "metadata.json"), JSON.stringify({
|
|
24
|
+
id: run.id,
|
|
25
|
+
timestamp: run.timestamp,
|
|
26
|
+
command: run.command,
|
|
27
|
+
config: run.config,
|
|
28
|
+
}, null, 2));
|
|
29
|
+
// Save input
|
|
30
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(runDir, "input.json"), JSON.stringify(run.input, null, 2));
|
|
31
|
+
// Save results
|
|
32
|
+
const resultsDir = (0, path_1.join)(runDir, "results");
|
|
33
|
+
if (!(0, fs_1.existsSync)(resultsDir)) {
|
|
34
|
+
(0, fs_1.mkdirSync)(resultsDir);
|
|
35
|
+
}
|
|
36
|
+
run.results.forEach((result) => {
|
|
37
|
+
// Sanitize filename: replace : and / with -
|
|
38
|
+
const filename = result.modelId.replace(/[:\/]/g, "-") + ".json";
|
|
39
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(resultsDir, filename), JSON.stringify(result, null, 2));
|
|
40
|
+
});
|
|
41
|
+
return runDir;
|
|
42
|
+
}
|
|
43
|
+
getRun(id) {
|
|
44
|
+
const dir = this.getBenchmarkDir();
|
|
45
|
+
const runDir = (0, path_1.join)(dir, id);
|
|
46
|
+
if (!(0, fs_1.existsSync)(runDir)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const metadata = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(runDir, "metadata.json"), "utf-8"));
|
|
51
|
+
const input = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(runDir, "input.json"), "utf-8"));
|
|
52
|
+
const resultsDir = (0, path_1.join)(runDir, "results");
|
|
53
|
+
const results = [];
|
|
54
|
+
if ((0, fs_1.existsSync)(resultsDir)) {
|
|
55
|
+
const files = (0, fs_1.readdirSync)(resultsDir).filter((f) => f.endsWith(".json"));
|
|
56
|
+
for (const file of files) {
|
|
57
|
+
results.push(JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(resultsDir, file), "utf-8")));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
...metadata,
|
|
62
|
+
input,
|
|
63
|
+
results,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error(`Failed to load benchmark run ${id}:`, error);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
listRuns() {
|
|
72
|
+
const dir = this.getBenchmarkDir();
|
|
73
|
+
if (!(0, fs_1.existsSync)(dir))
|
|
74
|
+
return [];
|
|
75
|
+
const runs = [];
|
|
76
|
+
const entries = (0, fs_1.readdirSync)(dir, { withFileTypes: true });
|
|
77
|
+
for (const entry of entries) {
|
|
78
|
+
if (entry.isDirectory()) {
|
|
79
|
+
try {
|
|
80
|
+
const metadataPath = (0, path_1.join)(dir, entry.name, "metadata.json");
|
|
81
|
+
if ((0, fs_1.existsSync)(metadataPath)) {
|
|
82
|
+
const metadata = JSON.parse((0, fs_1.readFileSync)(metadataPath, "utf-8"));
|
|
83
|
+
runs.push({
|
|
84
|
+
id: metadata.id,
|
|
85
|
+
timestamp: metadata.timestamp,
|
|
86
|
+
command: metadata.command,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
// Skip invalid runs
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return runs.sort((a, b) => b.timestamp - a.timestamp);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.BenchmarkStorage = BenchmarkStorage;
|
|
99
|
+
exports.benchmarkStorage = new BenchmarkStorage();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AIOptions } from "../../utils/ai-config-builder";
|
|
2
|
+
export interface BenchmarkModelConfig {
|
|
3
|
+
provider: string;
|
|
4
|
+
model: string;
|
|
5
|
+
reasoningTokens?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface BenchmarkConfig {
|
|
8
|
+
models: BenchmarkModelConfig[];
|
|
9
|
+
concurrency: number;
|
|
10
|
+
delay: number;
|
|
11
|
+
}
|
|
12
|
+
export interface BenchmarkProgressEvent {
|
|
13
|
+
type: "start" | "progress" | "complete" | "error";
|
|
14
|
+
modelId: string;
|
|
15
|
+
duration?: number;
|
|
16
|
+
error?: string;
|
|
17
|
+
currentSize?: number;
|
|
18
|
+
currentBps?: number;
|
|
19
|
+
chunk?: string;
|
|
20
|
+
}
|
|
21
|
+
import { StreamingOptions } from "../../types";
|
|
22
|
+
export interface BenchmarkResult {
|
|
23
|
+
modelId: string;
|
|
24
|
+
output: any;
|
|
25
|
+
duration: number;
|
|
26
|
+
error?: string;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
tokenUsage?: {
|
|
29
|
+
prompt: number;
|
|
30
|
+
completion: number;
|
|
31
|
+
total: number;
|
|
32
|
+
};
|
|
33
|
+
responseSize?: number;
|
|
34
|
+
bps?: number;
|
|
35
|
+
tps?: number;
|
|
36
|
+
timeToFirstToken?: number;
|
|
37
|
+
cost?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface BenchmarkRun {
|
|
40
|
+
id: string;
|
|
41
|
+
timestamp: number;
|
|
42
|
+
command: string;
|
|
43
|
+
input: any;
|
|
44
|
+
config: BenchmarkConfig;
|
|
45
|
+
results: BenchmarkResult[];
|
|
46
|
+
}
|
|
47
|
+
export interface BenchmarkableOperation {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
execute: (input: any, aiOptions: AIOptions, streamingOptions?: StreamingOptions) => Promise<any>;
|
|
52
|
+
validateInput: (input: any) => boolean;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/benchmark/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,GAAG,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,C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