intention-coding 0.3.3 → 0.3.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.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +6458 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/server/index.d.ts +2 -0
  5. package/dist/services/bug-fix-agent/index.d.ts +10 -24
  6. package/dist/services/change-summarizer/index.d.ts +10 -24
  7. package/dist/services/code-generator/index.d.ts +33 -94
  8. package/dist/services/code-generator/stages/execution-stage.d.ts +95 -0
  9. package/dist/services/code-generator/stages/ideation-stage.d.ts +33 -0
  10. package/dist/services/code-generator/stages/optimization-stage.d.ts +46 -0
  11. package/dist/services/code-generator/stages/planning-stage.d.ts +33 -0
  12. package/dist/services/code-generator/stages/research-stage.d.ts +35 -0
  13. package/dist/services/code-generator/stages/review-stage.d.ts +33 -0
  14. package/dist/services/code-generator/types.d.ts +232 -0
  15. package/dist/services/code-generator/utils/instruction-executor.d.ts +69 -0
  16. package/dist/services/code-generator/workflow-manager.d.ts +46 -0
  17. package/dist/services/image-analysis/analyzer.d.ts +62 -0
  18. package/dist/services/image-analysis/index.d.ts +54 -27
  19. package/dist/services/image-analysis/types.d.ts +175 -143
  20. package/dist/services/image-converter/converter.d.ts +20 -65
  21. package/dist/services/image-converter/index.d.ts +36 -118
  22. package/dist/services/image-converter/types.d.ts +61 -0
  23. package/dist/services/integrated-generator/index.d.ts +28 -66
  24. package/dist/services/pdf2md/index.d.ts +4 -48
  25. package/dist/services/project-template/index.d.ts +2 -18
  26. package/dist/services/requirement-analyzer/core/document-generator.d.ts +36 -0
  27. package/dist/services/requirement-analyzer/core/intelligent-analyzer.d.ts +35 -0
  28. package/dist/services/requirement-analyzer/core/project-analyzer.d.ts +36 -0
  29. package/dist/services/requirement-analyzer/core/requirement-analyzer-service.d.ts +30 -0
  30. package/dist/services/requirement-analyzer/core/template-selector.d.ts +35 -0
  31. package/dist/services/requirement-analyzer/core/types.d.ts +83 -0
  32. package/dist/services/requirement-analyzer/index.d.ts +44 -260
  33. package/dist/services/requirement-analyzer/prompt/intelligent-requirement-analysis.d.ts +1 -0
  34. package/dist/services/requirement-analyzer/utils/file-reader.d.ts +8 -0
  35. package/dist/services/world2md/index.d.ts +14 -50
  36. package/dist/types/index.d.ts +8 -0
  37. package/dist/{config.d.ts → utils/config.d.ts} +1 -0
  38. package/package.json +48 -28
  39. package/dist/cli/analyze-image.d.ts +0 -2
  40. package/dist/index.js +0 -12720
  41. package/dist/services/api-test/add-tasks-to-plan.d.ts +0 -97
  42. package/dist/services/api-test/api-test.d.ts +0 -86
  43. package/dist/services/api-test/batch-update-task-summaries.d.ts +0 -61
  44. package/dist/services/api-test/execute-test-plan.d.ts +0 -21
  45. package/dist/services/api-test/export-test-results.d.ts +0 -21
  46. package/dist/services/api-test/get-test-plans.d.ts +0 -21
  47. package/dist/services/api-test/index.d.ts +0 -285
  48. package/dist/services/api-test/test-plan.d.ts +0 -119
  49. package/dist/services/api-test/update-task.d.ts +0 -147
  50. package/dist/services/claude-code/index.d.ts +0 -200
  51. package/dist/services/code-generator/database-manager.d.ts +0 -65
  52. package/dist/services/code-generator/enhanced-tools.d.ts +0 -392
  53. package/dist/services/code-generator/export-excel.d.ts +0 -21
  54. package/dist/services/code-generator/task-queue.d.ts +0 -114
  55. package/dist/services/image-analysis/config.d.ts +0 -14
  56. package/dist/services/image-analysis/factory.d.ts +0 -33
  57. package/dist/services/image-analysis/image-analysis.d.ts +0 -36
  58. package/dist/services/image-analysis/image-encoder.d.ts +0 -20
  59. package/dist/services/image-analysis/image-validator.d.ts +0 -30
  60. package/dist/services/image-analysis/tools.d.ts +0 -55
  61. package/dist/services/index.d.ts +0 -0
  62. package/dist/services/requirement-analyzer/prompt/enhanced-feature-extraction.d.ts +0 -1
  63. package/dist/services/requirement-analyzer/prompt/fallback-document.d.ts +0 -1
  64. package/dist/services/requirement-analyzer/prompt/feature-dependency-analysis.d.ts +0 -1
  65. package/dist/services/requirement-analyzer/prompt/feature-extraction.d.ts +0 -2
  66. package/dist/utils/requirements-utils.d.ts +0 -38
  67. package/dist/utils/storage.d.ts +0 -14
@@ -0,0 +1,232 @@
1
+ export interface WorkflowTask {
2
+ id: string;
3
+ description: string;
4
+ currentStage: WorkflowStage;
5
+ context: TaskContext;
6
+ stages: StageResult[];
7
+ createdAt: Date;
8
+ updatedAt: Date;
9
+ }
10
+ export declare enum WorkflowStage {
11
+ RESEARCH = "research",// 研究
12
+ IDEATION = "ideation",// 构思
13
+ PLANNING = "planning",// 计划
14
+ EXECUTION = "execution",// 执行
15
+ OPTIMIZATION = "optimization",// 优化
16
+ REVIEW = "review"
17
+ }
18
+ export interface TaskContext {
19
+ taskDescription: string;
20
+ projectInfo?: ProjectInfo;
21
+ requirements: RequirementAnalysis;
22
+ constraints: Constraint[];
23
+ successCriteria: string[];
24
+ }
25
+ export interface ProjectInfo {
26
+ name: string;
27
+ path: string;
28
+ techStack: string[];
29
+ frameworks: string[];
30
+ language: string;
31
+ structure: FileStructure;
32
+ devCommands: DevCommand[];
33
+ }
34
+ export interface FileStructure {
35
+ [path: string]: {
36
+ type: 'file' | 'directory';
37
+ content?: string;
38
+ children?: FileStructure;
39
+ };
40
+ }
41
+ export interface DevCommand {
42
+ name: string;
43
+ command: string;
44
+ description: string;
45
+ }
46
+ export interface RequirementAnalysis {
47
+ completenessScore: number;
48
+ targetClarity: number;
49
+ expectedResults: number;
50
+ scopeBoundary: number;
51
+ constraints: number;
52
+ missingInfo: string[];
53
+ clarificationQuestions: string[];
54
+ }
55
+ export interface Constraint {
56
+ type: 'time' | 'performance' | 'business' | 'technical';
57
+ description: string;
58
+ priority: 'high' | 'medium' | 'low';
59
+ }
60
+ export interface StageResult {
61
+ stage: WorkflowStage;
62
+ status: 'pending' | 'in_progress' | 'completed' | 'failed';
63
+ input: any;
64
+ output: any;
65
+ feedback?: string;
66
+ timestamp: Date;
67
+ duration?: number;
68
+ }
69
+ export interface Solution {
70
+ id: string;
71
+ name: string;
72
+ description: string;
73
+ pros: string[];
74
+ cons: string[];
75
+ complexity: 'low' | 'medium' | 'high';
76
+ estimatedTime: string;
77
+ techRequirements: string[];
78
+ riskLevel: 'low' | 'medium' | 'high';
79
+ score: number;
80
+ }
81
+ export interface ExecutionPlan {
82
+ id: string;
83
+ solutionId: string;
84
+ steps: ExecutionStep[];
85
+ estimatedDuration: string;
86
+ dependencies: string[];
87
+ riskAssessment: string;
88
+ rollbackPlan: string;
89
+ }
90
+ export interface ExecutionStep {
91
+ id: string;
92
+ name: string;
93
+ description: string;
94
+ type: 'file_creation' | 'file_modification' | 'function_implementation' | 'class_implementation' | 'test_creation' | 'configuration';
95
+ targetFiles: string[];
96
+ atomicOperations: AtomicOperation[];
97
+ expectedResult: string;
98
+ dependencies: string[];
99
+ estimatedTime: string;
100
+ }
101
+ export interface AtomicOperation {
102
+ type: 'create_file' | 'modify_file' | 'create_function' | 'create_class' | 'add_import' | 'install_dependency';
103
+ target: string;
104
+ content?: string;
105
+ parameters?: Record<string, any>;
106
+ }
107
+ export interface OptimizationSuggestion {
108
+ id: string;
109
+ type: 'redundancy' | 'performance' | 'maintainability' | 'security' | 'best_practice';
110
+ description: string;
111
+ currentCode: string;
112
+ optimizedCode: string;
113
+ reason: string;
114
+ expectedBenefit: string;
115
+ impact: 'low' | 'medium' | 'high';
116
+ effort: 'low' | 'medium' | 'high';
117
+ }
118
+ export interface ReviewResult {
119
+ overallScore: number;
120
+ planAdherence: number;
121
+ codeQuality: number;
122
+ testCoverage: number;
123
+ documentation: number;
124
+ issues: Issue[];
125
+ recommendations: string[];
126
+ nextSteps: string[];
127
+ }
128
+ export interface Issue {
129
+ type: 'bug' | 'performance' | 'security' | 'maintainability' | 'documentation';
130
+ severity: 'low' | 'medium' | 'high' | 'critical';
131
+ description: string;
132
+ location: string;
133
+ suggestion: string;
134
+ }
135
+ export interface WorkflowResponse {
136
+ stage: WorkflowStage;
137
+ status: 'success' | 'error' | 'pending_approval' | 'needs_clarification';
138
+ message: string;
139
+ data?: any;
140
+ nextActions: string[];
141
+ requiresUserConfirmation: boolean;
142
+ clarificationQuestions?: string[];
143
+ executionInstructions?: AnyExecutionInstruction[];
144
+ }
145
+ export interface ExecutionInstruction {
146
+ id: string;
147
+ type: 'file_operation' | 'shell_command' | 'dependency_install' | 'configuration' | 'workflow_guidance';
148
+ description: string;
149
+ priority: number;
150
+ }
151
+ export interface FileOperationInstruction extends ExecutionInstruction {
152
+ type: 'file_operation';
153
+ operation: 'create' | 'modify' | 'delete' | 'move' | 'copy';
154
+ targetPath: string;
155
+ content?: string;
156
+ sourceContent?: string;
157
+ newContent?: string;
158
+ sourcePath?: string;
159
+ }
160
+ export interface ShellCommandInstruction extends ExecutionInstruction {
161
+ type: 'shell_command';
162
+ command: string;
163
+ workingDirectory?: string;
164
+ environment?: Record<string, string>;
165
+ expectedOutput?: string;
166
+ }
167
+ export interface DependencyInstallInstruction extends ExecutionInstruction {
168
+ type: 'dependency_install';
169
+ packageManager: 'npm' | 'yarn' | 'pnpm' | 'pip' | 'cargo';
170
+ packages: string[];
171
+ isDev?: boolean;
172
+ }
173
+ export interface ConfigurationInstruction extends ExecutionInstruction {
174
+ type: 'configuration';
175
+ configType: 'package.json' | 'tsconfig.json' | 'eslint' | 'prettier' | 'custom';
176
+ configPath: string;
177
+ changes: Record<string, any>;
178
+ }
179
+ export interface WorkflowInstruction extends ExecutionInstruction {
180
+ type: 'workflow_guidance';
181
+ stage: WorkflowStage;
182
+ mode: string;
183
+ guidance: {
184
+ description: string;
185
+ steps: string[];
186
+ expectedOutput: string;
187
+ userPrompt?: string;
188
+ requiresUserInput: boolean;
189
+ completenessCheck?: {
190
+ minScore: number;
191
+ scoringCriteria: string[];
192
+ };
193
+ };
194
+ }
195
+ export type AnyExecutionInstruction = FileOperationInstruction | ShellCommandInstruction | DependencyInstallInstruction | ConfigurationInstruction | WorkflowInstruction;
196
+ export interface ExecutionResult {
197
+ instructionId: string;
198
+ status: 'success' | 'failed' | 'skipped';
199
+ output?: string;
200
+ error?: string;
201
+ executedAt: Date;
202
+ }
203
+ export interface ExecutionSummary {
204
+ totalInstructions: number;
205
+ completedInstructions: number;
206
+ failedInstructions: number;
207
+ skippedInstructions: number;
208
+ results: ExecutionResult[];
209
+ errors: Array<{
210
+ instructionId: string;
211
+ description: string;
212
+ error: string;
213
+ }>;
214
+ }
215
+ export declare class CodeGeneratorError extends Error {
216
+ readonly code: string;
217
+ readonly stage: WorkflowStage;
218
+ readonly context?: any | undefined;
219
+ constructor(message: string, code: string, stage: WorkflowStage, context?: any | undefined);
220
+ }
221
+ export declare enum ErrorCodes {
222
+ INVALID_TASK_DESCRIPTION = "INVALID_TASK_DESCRIPTION",
223
+ INCOMPLETE_REQUIREMENTS = "INCOMPLETE_REQUIREMENTS",
224
+ PROJECT_ANALYSIS_FAILED = "PROJECT_ANALYSIS_FAILED",
225
+ SOLUTION_GENERATION_FAILED = "SOLUTION_GENERATION_FAILED",
226
+ PLAN_CREATION_FAILED = "PLAN_CREATION_FAILED",
227
+ EXECUTION_FAILED = "EXECUTION_FAILED",
228
+ OPTIMIZATION_FAILED = "OPTIMIZATION_FAILED",
229
+ REVIEW_FAILED = "REVIEW_FAILED",
230
+ USER_APPROVAL_REQUIRED = "USER_APPROVAL_REQUIRED",
231
+ STAGE_TRANSITION_FAILED = "STAGE_TRANSITION_FAILED"
232
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * 执行指令处理工具
3
+ * 为 MCP 客户端提供指令执行的辅助方法
4
+ */
5
+ import { AnyExecutionInstruction, FileOperationInstruction, ShellCommandInstruction, DependencyInstallInstruction, ConfigurationInstruction, ExecutionResult, ExecutionSummary } from '../types';
6
+ export declare class InstructionExecutor {
7
+ /**
8
+ * 验证执行指令的有效性
9
+ */
10
+ static validateInstructions(instructions: AnyExecutionInstruction[]): {
11
+ valid: boolean;
12
+ errors: string[];
13
+ };
14
+ /**
15
+ * 按优先级排序指令
16
+ */
17
+ static sortInstructionsByPriority(instructions: AnyExecutionInstruction[]): AnyExecutionInstruction[];
18
+ /**
19
+ * 按类型分组指令
20
+ */
21
+ static groupInstructionsByType(instructions: AnyExecutionInstruction[]): {
22
+ fileOperations: FileOperationInstruction[];
23
+ shellCommands: ShellCommandInstruction[];
24
+ dependencyInstalls: DependencyInstallInstruction[];
25
+ configurations: ConfigurationInstruction[];
26
+ };
27
+ /**
28
+ * 生成执行摘要
29
+ */
30
+ static generateExecutionSummary(results: ExecutionResult[]): ExecutionSummary;
31
+ /**
32
+ * 生成执行报告
33
+ */
34
+ static generateExecutionReport(summary: ExecutionSummary): string;
35
+ private static validateFileOperation;
36
+ private static validateShellCommand;
37
+ private static validateDependencyInstall;
38
+ private static validateConfiguration;
39
+ }
40
+ /**
41
+ * 指令执行状态跟踪器
42
+ */
43
+ export declare class InstructionTracker {
44
+ private results;
45
+ /**
46
+ * 记录指令执行结果
47
+ */
48
+ recordResult(result: ExecutionResult): void;
49
+ /**
50
+ * 获取所有结果
51
+ */
52
+ getAllResults(): ExecutionResult[];
53
+ /**
54
+ * 获取执行摘要
55
+ */
56
+ getSummary(): ExecutionSummary;
57
+ /**
58
+ * 清空结果
59
+ */
60
+ clear(): void;
61
+ /**
62
+ * 检查是否有失败的指令
63
+ */
64
+ hasFailures(): boolean;
65
+ /**
66
+ * 获取失败的指令
67
+ */
68
+ getFailures(): ExecutionResult[];
69
+ }
@@ -0,0 +1,46 @@
1
+ import { WorkflowTask, WorkflowStage, WorkflowResponse } from './types';
2
+ /**
3
+ * 工作流程管理器
4
+ * 职责:管理六阶段开发工作流的执行和状态转换
5
+ */
6
+ export declare class WorkflowManager {
7
+ private tasks;
8
+ private stages;
9
+ constructor();
10
+ /**
11
+ * 初始化各个阶段的处理器
12
+ */
13
+ private initializeStages;
14
+ /**
15
+ * 创建新的工作流任务
16
+ */
17
+ createTask(taskDescription: string): Promise<WorkflowResponse>;
18
+ /**
19
+ * 执行指定阶段
20
+ */
21
+ executeStage(taskId: string, stage: WorkflowStage, input?: any): Promise<WorkflowResponse>;
22
+ /**
23
+ * 继续到下一个阶段
24
+ */
25
+ proceedToNextStage(taskId: string, feedback?: any): Promise<WorkflowResponse>;
26
+ /**
27
+ * 跳转到指定阶段
28
+ */
29
+ jumpToStage(taskId: string, targetStage: WorkflowStage): Promise<WorkflowResponse>;
30
+ /**
31
+ * 获取任务状态
32
+ */
33
+ getTaskStatus(taskId: string): WorkflowTask;
34
+ /**
35
+ * 获取所有任务
36
+ */
37
+ getAllTasks(): WorkflowTask[];
38
+ /**
39
+ * 删除任务
40
+ */
41
+ deleteTask(taskId: string): boolean;
42
+ private getTask;
43
+ private generateTaskId;
44
+ private validateStageTransition;
45
+ private getNextStage;
46
+ }
@@ -0,0 +1,62 @@
1
+ import { ImageAnalysisParams, AnalysisResult } from './types';
2
+ /**
3
+ * 图片内容理解核心服务
4
+ * 职责:分析图片内容并提供智能理解
5
+ */
6
+ export declare class ImageAnalyzer {
7
+ /**
8
+ * 分析图片内容
9
+ */
10
+ analyzeImage(params: ImageAnalysisParams): Promise<AnalysisResult>;
11
+ /**
12
+ * 执行AI分析
13
+ */
14
+ private performAIAnalysis;
15
+ /**
16
+ * 构建分析prompt
17
+ */
18
+ private buildAnalysisPrompt;
19
+ /**
20
+ * 获取详细程度指令
21
+ */
22
+ private getDetailInstruction;
23
+ /**
24
+ * 解析AI响应
25
+ */
26
+ private parseAIResponse;
27
+ /**
28
+ * 获取图片基本信息
29
+ */
30
+ private getImageBasicInfo;
31
+ /**
32
+ * 将图片转换为base64 data URL
33
+ */
34
+ private imageToBase64;
35
+ /**
36
+ * 验证参数
37
+ */
38
+ private validateParams;
39
+ /**
40
+ * 计算置信度分数
41
+ */
42
+ private calculateConfidenceScore;
43
+ private extractTags;
44
+ private extractObjects;
45
+ private extractTextContent;
46
+ private extractSceneInfo;
47
+ private extractPeopleInfo;
48
+ private extractTechnicalInfo;
49
+ private extractUIDesignInfo;
50
+ private extractRequirementInfo;
51
+ private extractValue;
52
+ private extractBoolean;
53
+ private extractList;
54
+ private extractUIComponents;
55
+ private extractColorScheme;
56
+ private extractTypography;
57
+ private extractNavigation;
58
+ private extractFunctionalRequirements;
59
+ private extractNonFunctionalRequirements;
60
+ private extractUserStories;
61
+ private formatFileSize;
62
+ }
@@ -1,29 +1,56 @@
1
- import { ImageAnalysisService } from "./image-analysis";
2
- import { ImageValidator } from "./image-validator";
3
- import { ImageEncoder } from "./image-encoder";
4
- import { ImageAnalysisParams, ImageAnalysisResult, ImageFileInfo, ErrorCodes, ImageAnalysisError } from "./types";
5
- import { createImageAnalysisService, imageAnalysisService } from "./factory";
1
+ import { z } from "zod";
2
+ declare const ImageAnalysisParamsSchema: z.ZodObject<{
3
+ image_path: z.ZodString;
4
+ analysis_type: z.ZodEnum<{
5
+ text: "text";
6
+ general: "general";
7
+ objects: "objects";
8
+ scene: "scene";
9
+ people: "people";
10
+ technical: "technical";
11
+ ui_design: "ui_design";
12
+ requirement: "requirement";
13
+ custom: "custom";
14
+ }>;
15
+ custom_prompt: z.ZodOptional<z.ZodString>;
16
+ detail_level: z.ZodDefault<z.ZodEnum<{
17
+ detailed: "detailed";
18
+ comprehensive: "comprehensive";
19
+ brief: "brief";
20
+ }>>;
21
+ language: z.ZodDefault<z.ZodString>;
22
+ }, z.core.$strip>;
23
+ export type ImageAnalysisToolParams = z.infer<typeof ImageAnalysisParamsSchema>;
6
24
  /**
7
- * @module ImageAnalysis
8
- *
9
- * A service for analyzing images using the Moonshot Vision API.
10
- * This service allows you to analyze local images with custom prompts
11
- * using the moonshot-vision model.
12
- *
13
- * @example
14
- * ```typescript
15
- * import { imageAnalysisService } from 'src/services/image-analysis';
16
- *
17
- * const result = await imageAnalysisService.analyzeImage({
18
- * imagePath: '/path/to/image.jpg',
19
- * prompt: 'Describe this image',
20
- * maxTokens: 4000,
21
- * temperature: 0.7
22
- * });
23
- *
24
- * console.log(result.content);
25
- * ```
25
+ * 图片内容理解智能体
26
+ * 提供多种类型的图片内容分析和理解
26
27
  */
27
- export { ImageAnalysisService, ImageValidator, ImageEncoder, createImageAnalysisService, imageAnalysisService, };
28
- export { analyzeImageTool, imageAnalysisTools } from "./tools";
29
- export type { ImageAnalysisParams, ImageAnalysisResult, ImageFileInfo, ErrorCodes, ImageAnalysisError, };
28
+ export declare const imageAnalysisTool: {
29
+ name: string;
30
+ description: string;
31
+ parameters: z.ZodObject<{
32
+ image_path: z.ZodString;
33
+ analysis_type: z.ZodEnum<{
34
+ text: "text";
35
+ general: "general";
36
+ objects: "objects";
37
+ scene: "scene";
38
+ people: "people";
39
+ technical: "technical";
40
+ ui_design: "ui_design";
41
+ requirement: "requirement";
42
+ custom: "custom";
43
+ }>;
44
+ custom_prompt: z.ZodOptional<z.ZodString>;
45
+ detail_level: z.ZodDefault<z.ZodEnum<{
46
+ detailed: "detailed";
47
+ comprehensive: "comprehensive";
48
+ brief: "brief";
49
+ }>>;
50
+ language: z.ZodDefault<z.ZodString>;
51
+ }, z.core.$strip>;
52
+ execute: (args: ImageAnalysisToolParams) => Promise<string>;
53
+ };
54
+ export { ImageAnalyzer } from "./analyzer";
55
+ export type { ImageAnalysisParams, AnalysisResult, AnalysisContent, ImageBasicInfo, } from "./types";
56
+ export { ImageAnalysisError, AnalysisErrorCodes, AnalysisType, DetailLevel, } from "./types";