zone-ai-agent 0.4.0
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/.gittignore +4 -0
- package/README.md +36 -0
- package/dist/api/server.js +136 -0
- package/dist/api/server.js.map +1 -0
- package/dist/apply/applyPatchPlan.js +17 -0
- package/dist/apply/applyPatchPlan.js.map +1 -0
- package/dist/apply/canApplyDecision.js +26 -0
- package/dist/apply/canApplyDecision.js.map +1 -0
- package/dist/apply/patchPlan.js +3 -0
- package/dist/apply/patchPlan.js.map +1 -0
- package/dist/apply/renderApplyResult.js +18 -0
- package/dist/apply/renderApplyResult.js.map +1 -0
- package/dist/apply/runApplyFlow.js +40 -0
- package/dist/apply/runApplyFlow.js.map +1 -0
- package/dist/apply/types.js +3 -0
- package/dist/apply/types.js.map +1 -0
- package/dist/audit/auditDiffIntelligence.js +3 -0
- package/dist/audit/auditDiffIntelligence.js.map +1 -0
- package/dist/audit/auditSnapshot.js +87 -0
- package/dist/audit/auditSnapshot.js.map +1 -0
- package/dist/audit/renderAuditDiff.js +64 -0
- package/dist/audit/renderAuditDiff.js.map +1 -0
- package/dist/audit/snapshotDiff.js +53 -0
- package/dist/audit/snapshotDiff.js.map +1 -0
- package/dist/audit/snapshotReader.js +31 -0
- package/dist/audit/snapshotReader.js.map +1 -0
- package/dist/audit/snapshotWriter.js +59 -0
- package/dist/audit/snapshotWriter.js.map +1 -0
- package/dist/ci/evaluateCiResult.js +142 -0
- package/dist/ci/evaluateCiResult.js.map +1 -0
- package/dist/cli/buildGeneratedPatchPlanPreview.js +65 -0
- package/dist/cli/buildGeneratedPatchPlanPreview.js.map +1 -0
- package/dist/cli/colors.js +28 -0
- package/dist/cli/colors.js.map +1 -0
- package/dist/cli/diffOutput.js +37 -0
- package/dist/cli/diffOutput.js.map +1 -0
- package/dist/cli/index.js +850 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/loadPatchPlan.js +52 -0
- package/dist/cli/loadPatchPlan.js.map +1 -0
- package/dist/cli/output.js +34 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/parseCliArgs.js +3 -0
- package/dist/cli/parseCliArgs.js.map +1 -0
- package/dist/cli/runGeneratedPatchPlanFlow.js +23 -0
- package/dist/cli/runGeneratedPatchPlanFlow.js.map +1 -0
- package/dist/components/LoginForm.js +64 -0
- package/dist/components/LoginForm.js.map +1 -0
- package/dist/core/analyzeCodePatterns.js +3 -0
- package/dist/core/analyzeCodePatterns.js.map +1 -0
- package/dist/core/applyLlmPatches.js +43 -0
- package/dist/core/applyLlmPatches.js.map +1 -0
- package/dist/core/buildConfidenceBreakdownFromSignals.js +33 -0
- package/dist/core/buildConfidenceBreakdownFromSignals.js.map +1 -0
- package/dist/core/buildDecisionAuditSnapshot.js +18 -0
- package/dist/core/buildDecisionAuditSnapshot.js.map +1 -0
- package/dist/core/buildDecisionTrace.js +113 -0
- package/dist/core/buildDecisionTrace.js.map +1 -0
- package/dist/core/buildFallbackPatchPlan.js +23 -0
- package/dist/core/buildFallbackPatchPlan.js.map +1 -0
- package/dist/core/buildFallbackPlan.js +25 -0
- package/dist/core/buildFallbackPlan.js.map +1 -0
- package/dist/core/buildSchemaAwareContext.js +49 -0
- package/dist/core/buildSchemaAwareContext.js.map +1 -0
- package/dist/core/buildTaskExecutionContext.js +70 -0
- package/dist/core/buildTaskExecutionContext.js.map +1 -0
- package/dist/core/ciEvaluator.js +83 -0
- package/dist/core/ciEvaluator.js.map +1 -0
- package/dist/core/computeRiskScore.js +43 -0
- package/dist/core/computeRiskScore.js.map +1 -0
- package/dist/core/computeRiskScoreDetails.js +106 -0
- package/dist/core/computeRiskScoreDetails.js.map +1 -0
- package/dist/core/confidenceGate.js +83 -0
- package/dist/core/confidenceGate.js.map +1 -0
- package/dist/core/decision/buildDecisionExplanation.js +91 -0
- package/dist/core/decision/buildDecisionExplanation.js.map +1 -0
- package/dist/core/decision/buildDecisionReasonCodes.js +65 -0
- package/dist/core/decision/buildDecisionReasonCodes.js.map +1 -0
- package/dist/core/decision/buildReasonSummaryLine.js +24 -0
- package/dist/core/decision/buildReasonSummaryLine.js.map +1 -0
- package/dist/core/decision/buildRecommendation.js +43 -0
- package/dist/core/decision/buildRecommendation.js.map +1 -0
- package/dist/core/decision/decideExecutionMode.js +125 -0
- package/dist/core/decision/decideExecutionMode.js.map +1 -0
- package/dist/core/decision/decisionReasonCodeMeta.js +91 -0
- package/dist/core/decision/decisionReasonCodeMeta.js.map +1 -0
- package/dist/core/decision/renderDecisionSummary.js +115 -0
- package/dist/core/decision/renderDecisionSummary.js.map +1 -0
- package/dist/core/detectResourceStorage.js +78 -0
- package/dist/core/detectResourceStorage.js.map +1 -0
- package/dist/core/formatOutput.js +53 -0
- package/dist/core/formatOutput.js.map +1 -0
- package/dist/core/intentAwareScore.js +35 -0
- package/dist/core/intentAwareScore.js.map +1 -0
- package/dist/core/loadSavedAgentResult.js +18 -0
- package/dist/core/loadSavedAgentResult.js.map +1 -0
- package/dist/core/normalizeIssues.js +50 -0
- package/dist/core/normalizeIssues.js.map +1 -0
- package/dist/core/normalizeSignals.js +40 -0
- package/dist/core/normalizeSignals.js.map +1 -0
- package/dist/core/output/zoneStageTypes.js +3 -0
- package/dist/core/output/zoneStageTypes.js.map +1 -0
- package/dist/core/patchRiskAnalyzer.js +50 -0
- package/dist/core/patchRiskAnalyzer.js.map +1 -0
- package/dist/core/renderRunAgentResult.js +77 -0
- package/dist/core/renderRunAgentResult.js.map +1 -0
- package/dist/core/result/buildApplyStageResult.js +61 -0
- package/dist/core/result/buildApplyStageResult.js.map +1 -0
- package/dist/core/result/buildCliViewModel.js +79 -0
- package/dist/core/result/buildCliViewModel.js.map +1 -0
- package/dist/core/result/buildConversionStageResult.js +62 -0
- package/dist/core/result/buildConversionStageResult.js.map +1 -0
- package/dist/core/result/buildDecisionStageResult.js +61 -0
- package/dist/core/result/buildDecisionStageResult.js.map +1 -0
- package/dist/core/result/buildExecutionResult.js +148 -0
- package/dist/core/result/buildExecutionResult.js.map +1 -0
- package/dist/core/result/buildPreviewStageResult.js +47 -0
- package/dist/core/result/buildPreviewStageResult.js.map +1 -0
- package/dist/core/result/buildSavedDecisionExplanation.js +52 -0
- package/dist/core/result/buildSavedDecisionExplanation.js.map +1 -0
- package/dist/core/result/buildSavedRecommendation.js +39 -0
- package/dist/core/result/buildSavedRecommendation.js.map +1 -0
- package/dist/core/result/buildStageResultV2.js +52 -0
- package/dist/core/result/buildStageResultV2.js.map +1 -0
- package/dist/core/result/renderBundledResult.js +47 -0
- package/dist/core/result/renderBundledResult.js.map +1 -0
- package/dist/core/result/renderCliResult.js +93 -0
- package/dist/core/result/renderCliResult.js.map +1 -0
- package/dist/core/result/scoreTopRisks.js +205 -0
- package/dist/core/result/scoreTopRisks.js.map +1 -0
- package/dist/core/runAgent.js +210 -0
- package/dist/core/runAgent.js.map +1 -0
- package/dist/core/runFeatureAgent.js +684 -0
- package/dist/core/runFeatureAgent.js.map +1 -0
- package/dist/core/runLlmPatchFlow.js +522 -0
- package/dist/core/runLlmPatchFlow.js.map +1 -0
- package/dist/core/saveAgentResult.js +234 -0
- package/dist/core/saveAgentResult.js.map +1 -0
- package/dist/core/scoring/computeConfidenceBreakdown.js +130 -0
- package/dist/core/scoring/computeConfidenceBreakdown.js.map +1 -0
- package/dist/core/scoring/computeConfidenceScore.js +37 -0
- package/dist/core/scoring/computeConfidenceScore.js.map +1 -0
- package/dist/core/scoring/confidenceRules.js +58 -0
- package/dist/core/scoring/confidenceRules.js.map +1 -0
- package/dist/core/scoring/confidenceScore.js +8 -0
- package/dist/core/scoring/confidenceScore.js.map +1 -0
- package/dist/core/selectRelevantBlocks.js +58 -0
- package/dist/core/selectRelevantBlocks.js.map +1 -0
- package/dist/core/selfHealingLoop.js +209 -0
- package/dist/core/selfHealingLoop.js.map +1 -0
- package/dist/core/taskIntentParser.js +165 -0
- package/dist/core/taskIntentParser.js.map +1 -0
- package/dist/core/types/agentResult.js +3 -0
- package/dist/core/types/agentResult.js.map +1 -0
- package/dist/core/types/risk.js +3 -0
- package/dist/core/types/risk.js.map +1 -0
- package/dist/core/validatePatchAgainstSchema.js +100 -0
- package/dist/core/validatePatchAgainstSchema.js.map +1 -0
- package/dist/core/validateSuggestedArchitecture.js +24 -0
- package/dist/core/validateSuggestedArchitecture.js.map +1 -0
- package/dist/engine/buildDecisionExplanation.js +114 -0
- package/dist/engine/buildDecisionExplanation.js.map +1 -0
- package/dist/engine/contradictionDetector.js +40 -0
- package/dist/engine/contradictionDetector.js.map +1 -0
- package/dist/engine/decisionEngine.js +19 -0
- package/dist/engine/decisionEngine.js.map +1 -0
- package/dist/llm/openaiClient.js +19 -0
- package/dist/llm/openaiClient.js.map +1 -0
- package/dist/llm/planFeature.js +57 -0
- package/dist/llm/planFeature.js.map +1 -0
- package/dist/llm/planFix.js +3 -0
- package/dist/llm/planFix.js.map +1 -0
- package/dist/llm/planFullPatch.js +62 -0
- package/dist/llm/planFullPatch.js.map +1 -0
- package/dist/llm/planPatchPreview.js +60 -0
- package/dist/llm/planPatchPreview.js.map +1 -0
- package/dist/llm/prompts.js +131 -0
- package/dist/llm/prompts.js.map +1 -0
- package/dist/llm/schemas.js +28 -0
- package/dist/llm/schemas.js.map +1 -0
- package/dist/patch/apply/formatApplyFlowResult.js +23 -0
- package/dist/patch/apply/formatApplyFlowResult.js.map +1 -0
- package/dist/patch/apply/renderApplyFlowResult.js +15 -0
- package/dist/patch/apply/renderApplyFlowResult.js.map +1 -0
- package/dist/patch/apply/runApplyFlow.js +88 -0
- package/dist/patch/apply/runApplyFlow.js.map +1 -0
- package/dist/patch/applyFlowTypes.js +3 -0
- package/dist/patch/applyFlowTypes.js.map +1 -0
- package/dist/patch/applyPatchPlan.js +117 -0
- package/dist/patch/applyPatchPlan.js.map +1 -0
- package/dist/patch/backupFile.js +23 -0
- package/dist/patch/backupFile.js.map +1 -0
- package/dist/patch/conversion/canConvertGeneratedPlanToPatchPlan.js +57 -0
- package/dist/patch/conversion/canConvertGeneratedPlanToPatchPlan.js.map +1 -0
- package/dist/patch/conversion/convertGeneratedPlanToPatchPlan.js +38 -0
- package/dist/patch/conversion/convertGeneratedPlanToPatchPlan.js.map +1 -0
- package/dist/patch/conversion/formatGeneratedPlanConversionFailure.js +17 -0
- package/dist/patch/conversion/formatGeneratedPlanConversionFailure.js.map +1 -0
- package/dist/patch/conversion/generatedPlanConversionFailureMeta.js +40 -0
- package/dist/patch/conversion/generatedPlanConversionFailureMeta.js.map +1 -0
- package/dist/patch/conversion/generatedPlanConversionTypes.js +3 -0
- package/dist/patch/conversion/generatedPlanConversionTypes.js.map +1 -0
- package/dist/patch/conversion/renderGeneratedPlanConversionFailure.js +16 -0
- package/dist/patch/conversion/renderGeneratedPlanConversionFailure.js.map +1 -0
- package/dist/patch/generatedPlanConversion.js +96 -0
- package/dist/patch/generatedPlanConversion.js.map +1 -0
- package/dist/patch/patchAnchors.js +3 -0
- package/dist/patch/patchAnchors.js.map +1 -0
- package/dist/patch/patchValidationRules.js +116 -0
- package/dist/patch/patchValidationRules.js.map +1 -0
- package/dist/patch/patchValidationTypes.js +3 -0
- package/dist/patch/patchValidationTypes.js.map +1 -0
- package/dist/patch/renderApplyFlowResult.js +26 -0
- package/dist/patch/renderApplyFlowResult.js.map +1 -0
- package/dist/patch/validatePatchPlan.js +148 -0
- package/dist/patch/validatePatchPlan.js.map +1 -0
- package/dist/patch-generation/buildGeneratedPatchPlan.js +94 -0
- package/dist/patch-generation/buildGeneratedPatchPlan.js.map +1 -0
- package/dist/patch-generation/buildPatchOperations.js +41 -0
- package/dist/patch-generation/buildPatchOperations.js.map +1 -0
- package/dist/patch-generation/classifyPatchIntent.js +62 -0
- package/dist/patch-generation/classifyPatchIntent.js.map +1 -0
- package/dist/patch-generation/formatGeneratedPatchPlanPreview.js +25 -0
- package/dist/patch-generation/formatGeneratedPatchPlanPreview.js.map +1 -0
- package/dist/patch-generation/generatePatchPlan.js +74 -0
- package/dist/patch-generation/generatePatchPlan.js.map +1 -0
- package/dist/patch-generation/generatedPatchPlanTypes.js +3 -0
- package/dist/patch-generation/generatedPatchPlanTypes.js.map +1 -0
- package/dist/patch-generation/isIntentAllowed.js +15 -0
- package/dist/patch-generation/isIntentAllowed.js.map +1 -0
- package/dist/patch-generation/renderGeneratedPatchPlan.js +62 -0
- package/dist/patch-generation/renderGeneratedPatchPlan.js.map +1 -0
- package/dist/prompts/developerPrompt.js +213 -0
- package/dist/prompts/developerPrompt.js.map +1 -0
- package/dist/prompts/fullPatchPrompt.js +82 -0
- package/dist/prompts/fullPatchPrompt.js.map +1 -0
- package/dist/prompts/patchPreviewPrompt.js +83 -0
- package/dist/prompts/patchPreviewPrompt.js.map +1 -0
- package/dist/prompts/planFeaturePrompt.js +73 -0
- package/dist/prompts/planFeaturePrompt.js.map +1 -0
- package/dist/prompts/testEngineerContext.js +184 -0
- package/dist/prompts/testEngineerContext.js.map +1 -0
- package/dist/prompts/testEngineerPrompt.js +135 -0
- package/dist/prompts/testEngineerPrompt.js.map +1 -0
- package/dist/repo/analyzeProjectPatterns.js +46 -0
- package/dist/repo/analyzeProjectPatterns.js.map +1 -0
- package/dist/repo/detectProjectStructure.js +45 -0
- package/dist/repo/detectProjectStructure.js.map +1 -0
- package/dist/repo/getGitChangedFiles.js +96 -0
- package/dist/repo/getGitChangedFiles.js.map +1 -0
- package/dist/repo/loadSchemaSnapshot.js +29 -0
- package/dist/repo/loadSchemaSnapshot.js.map +1 -0
- package/dist/repo/rankRelevantFiles.js +306 -0
- package/dist/repo/rankRelevantFiles.js.map +1 -0
- package/dist/repo/readProjectFiles.js +27 -0
- package/dist/repo/readProjectFiles.js.map +1 -0
- package/dist/repo/scanRepo.js +93 -0
- package/dist/repo/scanRepo.js.map +1 -0
- package/dist/repo/validateSuggestedFiles.js +66 -0
- package/dist/repo/validateSuggestedFiles.js.map +1 -0
- package/dist/roles/dataAnalystContext.js +155 -0
- package/dist/roles/dataAnalystContext.js.map +1 -0
- package/dist/roles/detectDataSchema.js +152 -0
- package/dist/roles/detectDataSchema.js.map +1 -0
- package/dist/roles/detectTestComplexity.js +74 -0
- package/dist/roles/detectTestComplexity.js.map +1 -0
- package/dist/roles/detectTestFramework.js +166 -0
- package/dist/roles/detectTestFramework.js.map +1 -0
- package/dist/roles/runDataAnalystFlow.js +221 -0
- package/dist/roles/runDataAnalystFlow.js.map +1 -0
- package/dist/roles/runTestEngineerFlow.js +266 -0
- package/dist/roles/runTestEngineerFlow.js.map +1 -0
- package/dist/roles/testEngineerContext.js +282 -0
- package/dist/roles/testEngineerContext.js.map +1 -0
- package/dist/roles/testOutputValidator.js +474 -0
- package/dist/roles/testOutputValidator.js.map +1 -0
- package/dist/types/agent.js +3 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/analysis.js +3 -0
- package/dist/types/analysis.js.map +1 -0
- package/dist/types/patch.js +3 -0
- package/dist/types/patch.js.map +1 -0
- package/dist/types/project.js +3 -0
- package/dist/types/project.js.map +1 -0
- package/dist/types/schema.js +3 -0
- package/dist/types/schema.js.map +1 -0
- package/dist/utils/executionTracker.js +33 -0
- package/dist/utils/executionTracker.js.map +1 -0
- package/dist/utils/files.js +35 -0
- package/dist/utils/files.js.map +1 -0
- package/dist/utils/logger.js +179 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/paths.js +14 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/trace.js +10 -0
- package/dist/utils/trace.js.map +1 -0
- package/dist/utils/validation.js +24 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +53 -0
- package/tsconfig.json +17 -0
- package/vitest.config.ts +21 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildDeveloperPrompt = buildDeveloperPrompt;
|
|
4
|
+
function isMicroEditUiTask(task) {
|
|
5
|
+
const normalized = task.toLowerCase();
|
|
6
|
+
return [
|
|
7
|
+
"spacing",
|
|
8
|
+
"margin",
|
|
9
|
+
"padding",
|
|
10
|
+
"font-size",
|
|
11
|
+
"font size",
|
|
12
|
+
"line-height",
|
|
13
|
+
"line height",
|
|
14
|
+
"alignment",
|
|
15
|
+
"align",
|
|
16
|
+
"label",
|
|
17
|
+
"text polish",
|
|
18
|
+
"copy polish",
|
|
19
|
+
"readability",
|
|
20
|
+
"small ui",
|
|
21
|
+
"small style",
|
|
22
|
+
].some((term) => normalized.includes(term));
|
|
23
|
+
}
|
|
24
|
+
function detectDeveloperMode(input) {
|
|
25
|
+
const normalizedTask = input.task.toLowerCase();
|
|
26
|
+
const normalizedPaths = [
|
|
27
|
+
input.targetFilePath ?? "",
|
|
28
|
+
...input.relevantFiles.map((file) => file.path),
|
|
29
|
+
]
|
|
30
|
+
.join(" ")
|
|
31
|
+
.toLowerCase();
|
|
32
|
+
if ([
|
|
33
|
+
"ui",
|
|
34
|
+
"polish",
|
|
35
|
+
"readability",
|
|
36
|
+
"spacing",
|
|
37
|
+
"font",
|
|
38
|
+
"style",
|
|
39
|
+
"layout",
|
|
40
|
+
"badge",
|
|
41
|
+
"theme",
|
|
42
|
+
].some((term) => normalizedTask.includes(term)) ||
|
|
43
|
+
[".html", ".tsx", ".jsx", "/ui/", "/components/", "/pages/"].some((term) => normalizedPaths.includes(term))) {
|
|
44
|
+
return "ui_polish";
|
|
45
|
+
}
|
|
46
|
+
if ([
|
|
47
|
+
"endpoint",
|
|
48
|
+
"route",
|
|
49
|
+
"api",
|
|
50
|
+
"controller",
|
|
51
|
+
"auth",
|
|
52
|
+
"middleware",
|
|
53
|
+
"backend",
|
|
54
|
+
"server",
|
|
55
|
+
].some((term) => normalizedTask.includes(term)) ||
|
|
56
|
+
["/routes/", "/api/", "/controllers/", "/server/"].some((term) => normalizedPaths.includes(term))) {
|
|
57
|
+
return "api_backend";
|
|
58
|
+
}
|
|
59
|
+
if ([
|
|
60
|
+
"config",
|
|
61
|
+
"build",
|
|
62
|
+
"vite",
|
|
63
|
+
"webpack",
|
|
64
|
+
"tsconfig",
|
|
65
|
+
"eslint",
|
|
66
|
+
"package",
|
|
67
|
+
"npm",
|
|
68
|
+
"script",
|
|
69
|
+
].some((term) => normalizedTask.includes(term)) ||
|
|
70
|
+
[
|
|
71
|
+
"package.json",
|
|
72
|
+
"tsconfig",
|
|
73
|
+
"vite.config",
|
|
74
|
+
"webpack",
|
|
75
|
+
"eslint",
|
|
76
|
+
".github/",
|
|
77
|
+
].some((term) => normalizedPaths.includes(term))) {
|
|
78
|
+
return "config_build";
|
|
79
|
+
}
|
|
80
|
+
return "general";
|
|
81
|
+
}
|
|
82
|
+
function buildModeInstructions(mode) {
|
|
83
|
+
switch (mode) {
|
|
84
|
+
case "ui_polish":
|
|
85
|
+
return [
|
|
86
|
+
"This is a UI polish/readability task. Prefer tiny in-place edits to styles, spacing, class names, copy, or existing component props.",
|
|
87
|
+
"Do NOT generate a full HTML page, landing page, dashboard, or demo scaffold.",
|
|
88
|
+
"Preserve the existing structure, IDs, classes, bindings, event handlers, and section ordering.",
|
|
89
|
+
"If the file already exists, do NOT add <html>, <head>, or <body> wrappers unless they already exist in the current file content.",
|
|
90
|
+
"Do NOT replace the page with generic content such as Welcome to My App, Get Started, Features, Application Dashboard, or any demo/marketing layout.",
|
|
91
|
+
];
|
|
92
|
+
case "api_backend":
|
|
93
|
+
return [
|
|
94
|
+
"This is an API/backend task. Preserve route shape, auth, validation, response format, and existing service/controller boundaries.",
|
|
95
|
+
"Prefer modifying existing handlers, services, middleware, or helpers over introducing parallel architecture.",
|
|
96
|
+
];
|
|
97
|
+
case "config_build":
|
|
98
|
+
return [
|
|
99
|
+
"This is a config/build task. Make the smallest possible config change and preserve existing scripts, plugin order, and file conventions.",
|
|
100
|
+
"Do not rewrite config files into a fresh scaffold.",
|
|
101
|
+
];
|
|
102
|
+
default:
|
|
103
|
+
return [
|
|
104
|
+
"Preserve the repository's existing structure and conventions, and prefer the smallest safe change.",
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function formatRelevantFiles(files) {
|
|
109
|
+
if (!files.length)
|
|
110
|
+
return "(no additional relevant repo files provided)";
|
|
111
|
+
return files
|
|
112
|
+
.map((file) => file.content
|
|
113
|
+
? `FILE: ${file.path}\n\`\`\`\n${file.content}\n\`\`\``
|
|
114
|
+
: `FILE: ${file.path}`)
|
|
115
|
+
.join("\n\n");
|
|
116
|
+
}
|
|
117
|
+
function buildDeveloperPrompt(params) {
|
|
118
|
+
const relevantFiles = Array.isArray(params.relevantFiles)
|
|
119
|
+
? params.relevantFiles
|
|
120
|
+
: [];
|
|
121
|
+
const existingTargetFiles = Array.isArray(params.existingTargetFiles)
|
|
122
|
+
? params.existingTargetFiles
|
|
123
|
+
: [];
|
|
124
|
+
const mode = detectDeveloperMode({
|
|
125
|
+
task: typeof params.task === "string" ? params.task : "",
|
|
126
|
+
targetFilePath: params.targetFilePath,
|
|
127
|
+
relevantFiles,
|
|
128
|
+
});
|
|
129
|
+
const microEditMode = mode === "ui_polish" &&
|
|
130
|
+
isMicroEditUiTask(typeof params.task === "string" ? params.task : "");
|
|
131
|
+
const modeInstructions = buildModeInstructions(mode)
|
|
132
|
+
.map((line) => `- ${line}`)
|
|
133
|
+
.join("\n");
|
|
134
|
+
const microEditInstructions = microEditMode
|
|
135
|
+
? `
|
|
136
|
+
MICRO-EDIT MODE
|
|
137
|
+
- This task is a small UI/style edit. You MUST prefer a tiny in-place edit over any structural rewrite.
|
|
138
|
+
- Modify existing style, class, spacing, line-height, font-size, alignment, or label text where it already exists.
|
|
139
|
+
- Do NOT rewrite the page layout, move major sections, rename core anchors, or replace the document structure.
|
|
140
|
+
- Reuse the exact nearby existing block/snippet context when making the change.
|
|
141
|
+
`.trim()
|
|
142
|
+
: "";
|
|
143
|
+
return `
|
|
144
|
+
You are Zone's Developer role working inside a real existing repository.
|
|
145
|
+
|
|
146
|
+
Your job is to produce the smallest safe, grounded update to the target file while preserving the repository's real structure and conventions.
|
|
147
|
+
|
|
148
|
+
TASK
|
|
149
|
+
${params.task}
|
|
150
|
+
|
|
151
|
+
TASK INTENT
|
|
152
|
+
${params.taskIntent || "general"}
|
|
153
|
+
|
|
154
|
+
REPO PATH
|
|
155
|
+
${params.repoPath}
|
|
156
|
+
|
|
157
|
+
REPO SUMMARY
|
|
158
|
+
${params.repoSummary || "No repository summary available."}
|
|
159
|
+
|
|
160
|
+
TARGET FILE
|
|
161
|
+
${params.targetFilePath || "(unknown target file)"}
|
|
162
|
+
|
|
163
|
+
EXISTING TARGET FILES
|
|
164
|
+
${existingTargetFiles.length > 0 ? existingTargetFiles.join("\n") : "(no existing target files provided)"}
|
|
165
|
+
|
|
166
|
+
RELATED CONTEXT
|
|
167
|
+
${params.relatedContext || "(no additional related context provided)"}
|
|
168
|
+
|
|
169
|
+
RELEVANT REPOSITORY FILES
|
|
170
|
+
${formatRelevantFiles(relevantFiles)}
|
|
171
|
+
|
|
172
|
+
CURRENT TARGET FILE CONTENT
|
|
173
|
+
\`\`\`
|
|
174
|
+
${params.targetFileContent || ""}
|
|
175
|
+
\`\`\`
|
|
176
|
+
|
|
177
|
+
STRICT DEVELOPER RULES
|
|
178
|
+
- This is a real existing repository, not a greenfield scaffold.
|
|
179
|
+
- Modify existing files in place whenever possible instead of creating generic replacements.
|
|
180
|
+
- Preserve existing structure, IDs, classes, bindings, imports, exports, naming, and conventions unless the task explicitly requires otherwise.
|
|
181
|
+
- Keep the diff minimal and localized.
|
|
182
|
+
- Do NOT generate generic template/demo content.
|
|
183
|
+
- Do NOT output scaffold phrases such as Welcome to My App, Get Started, Features, Application Dashboard, or generic landing-page/demo output.
|
|
184
|
+
- If the task is small and the existing file is already functional, prefer precise edits over broad rewrites.
|
|
185
|
+
- If no safe grounded change can be made from the provided repository context, return the file unchanged and add a warning.
|
|
186
|
+
|
|
187
|
+
MODE-SPECIFIC INSTRUCTIONS
|
|
188
|
+
${modeInstructions}
|
|
189
|
+
|
|
190
|
+
${microEditInstructions}
|
|
191
|
+
|
|
192
|
+
OUTPUT REQUIREMENTS
|
|
193
|
+
- DO NOT output full file content.
|
|
194
|
+
- ONLY output patch-style edits that target existing lines or blocks.
|
|
195
|
+
- For existing files, use one or more FIND/REPLACE edit blocks against the current file content.
|
|
196
|
+
- If the target file truly does not exist, use a single CREATE block.
|
|
197
|
+
- Do not add markdown fences or explanations outside the JSON response.
|
|
198
|
+
- Preserve all existing code that is unrelated to the task.
|
|
199
|
+
- Preserve unrelated code exactly when possible.
|
|
200
|
+
- Keep existing imports, exports, formatting, and wiring intact.
|
|
201
|
+
- Do not introduce <html>, <head>, or <body> wrappers unless they already exist and the task explicitly requires touching them.
|
|
202
|
+
|
|
203
|
+
OUTPUT FORMAT
|
|
204
|
+
Return JSON only:
|
|
205
|
+
{
|
|
206
|
+
"filePath": "string",
|
|
207
|
+
"patchText": "--- FILE: path ---\\nFIND:\\nexisting block\\nREPLACE:\\nupdated block",
|
|
208
|
+
"summary": "string",
|
|
209
|
+
"warnings": ["string"]
|
|
210
|
+
}
|
|
211
|
+
`.trim();
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=developerPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"developerPrompt.js","sourceRoot":"","sources":["../../src/prompts/developerPrompt.ts"],"names":[],"mappings":";;AA4JA,oDAiGC;AA5OD,SAAS,iBAAiB,CAAC,IAAY;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACtC,OAAO;QACL,SAAS;QACT,QAAQ;QACR,SAAS;QACT,WAAW;QACX,WAAW;QACX,aAAa;QACb,aAAa;QACb,WAAW;QACX,OAAO;QACP,OAAO;QACP,aAAa;QACb,aAAa;QACb,aAAa;QACb,UAAU;QACV,aAAa;KACd,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,mBAAmB,CAAC,KAI5B;IACC,MAAM,cAAc,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M,CAAC,iBAAiB,IAAI,EAAE;;;;;;;;;;;;;;EAc9B,gBAAgB;;EAEhB,qBAAqB;;;;;;;;;;;;;;;;;;;;;CAqBtB,CAAC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildFullPatchPrompt = buildFullPatchPrompt;
|
|
4
|
+
function buildFullPatchPrompt(input) {
|
|
5
|
+
const { task, filePath, fileContent, repoSummary, relatedContext, outputMode = "full_content", } = input;
|
|
6
|
+
if (outputMode === "find_replace_patch") {
|
|
7
|
+
return `
|
|
8
|
+
You are a senior software engineer applying a precise code change to a LARGE existing file.
|
|
9
|
+
|
|
10
|
+
TASK
|
|
11
|
+
${task}
|
|
12
|
+
|
|
13
|
+
TARGET FILE
|
|
14
|
+
${filePath}
|
|
15
|
+
|
|
16
|
+
REPO SUMMARY
|
|
17
|
+
${repoSummary}
|
|
18
|
+
|
|
19
|
+
RELATED CONTEXT
|
|
20
|
+
${relatedContext}
|
|
21
|
+
|
|
22
|
+
CURRENT FILE CONTENT
|
|
23
|
+
\`\`\`
|
|
24
|
+
${fileContent}
|
|
25
|
+
\`\`\`
|
|
26
|
+
|
|
27
|
+
INSTRUCTIONS
|
|
28
|
+
- The target file is large. Return ONLY the specific change as a FIND/REPLACE patch.
|
|
29
|
+
- Do NOT return the full file.
|
|
30
|
+
- Do NOT reconstruct the whole document.
|
|
31
|
+
- Modify only the smallest existing block needed.
|
|
32
|
+
- Your FIND block must be exact existing text from the file, usually 3-10 lines around the change.
|
|
33
|
+
- Your REPLACE block must contain only the updated version of that exact block.
|
|
34
|
+
- Do not add markdown fences or explanations.
|
|
35
|
+
|
|
36
|
+
OUTPUT FORMAT
|
|
37
|
+
Return plain text only in this exact format:
|
|
38
|
+
--- FIND ---
|
|
39
|
+
(exact existing text to find)
|
|
40
|
+
--- REPLACE ---
|
|
41
|
+
(updated text)
|
|
42
|
+
`.trim();
|
|
43
|
+
}
|
|
44
|
+
return `
|
|
45
|
+
You are a senior software engineer applying a precise code change to an existing file.
|
|
46
|
+
|
|
47
|
+
TASK
|
|
48
|
+
${task}
|
|
49
|
+
|
|
50
|
+
TARGET FILE
|
|
51
|
+
${filePath}
|
|
52
|
+
|
|
53
|
+
REPO SUMMARY
|
|
54
|
+
${repoSummary}
|
|
55
|
+
|
|
56
|
+
RELATED CONTEXT
|
|
57
|
+
${relatedContext}
|
|
58
|
+
|
|
59
|
+
CURRENT FILE CONTENT
|
|
60
|
+
\`\`\`
|
|
61
|
+
${fileContent}
|
|
62
|
+
\`\`\`
|
|
63
|
+
|
|
64
|
+
INSTRUCTIONS
|
|
65
|
+
- Apply the task to the file above
|
|
66
|
+
- Return the COMPLETE updated file content
|
|
67
|
+
- Preserve all existing code that is unrelated to the task
|
|
68
|
+
- Keep existing imports, exports, formatting, and naming conventions
|
|
69
|
+
- Do not add markdown fences or explanations
|
|
70
|
+
- If the file does not need changes, return it unchanged
|
|
71
|
+
|
|
72
|
+
OUTPUT FORMAT
|
|
73
|
+
Return JSON only:
|
|
74
|
+
{
|
|
75
|
+
"filePath": "string",
|
|
76
|
+
"fullContent": "string",
|
|
77
|
+
"summary": "string",
|
|
78
|
+
"warnings": ["string"]
|
|
79
|
+
}
|
|
80
|
+
`.trim();
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=fullPatchPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullPatchPrompt.js","sourceRoot":"","sources":["../../src/prompts/fullPatchPrompt.ts"],"names":[],"mappings":";;AAWA,oDAsFC;AAtFD,SAAgB,oBAAoB,CAAC,KAA2B;IAC9D,MAAM,EACJ,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,WAAW,EACX,cAAc,EACd,UAAU,GAAG,cAAc,GAC5B,GAAG,KAAK,CAAC;IAEV,IAAI,UAAU,KAAK,oBAAoB,EAAE,CAAC;QACxC,OAAO;;;;EAIT,IAAI;;;EAGJ,QAAQ;;;EAGR,WAAW;;;EAGX,cAAc;;;;EAId,WAAW;;;;;;;;;;;;;;;;;;CAkBZ,CAAC,IAAI,EAAE,CAAC;IACP,CAAC;IAED,OAAO;;;;EAIP,IAAI;;;EAGJ,QAAQ;;;EAGR,WAAW;;;EAGX,cAAc;;;;EAId,WAAW;;;;;;;;;;;;;;;;;;;CAmBZ,CAAC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildPatchPreviewPrompt = buildPatchPreviewPrompt;
|
|
4
|
+
function buildPatchPreviewPrompt(input) {
|
|
5
|
+
const { task, intent, filePath, fileContent, repoSummary, relatedContext, schemaAwareSummary } = input;
|
|
6
|
+
return `
|
|
7
|
+
You are generating a safe patch preview for a code agent working inside an existing production-style codebase.
|
|
8
|
+
|
|
9
|
+
Your goal is to propose the smallest correct patch for the target file while preserving the current architecture and conventions.
|
|
10
|
+
|
|
11
|
+
TASK
|
|
12
|
+
${task}
|
|
13
|
+
|
|
14
|
+
TASK INTENT
|
|
15
|
+
- action: ${intent.action}
|
|
16
|
+
- resourceKind: ${intent.resourceKind}
|
|
17
|
+
- scope: ${intent.scope}
|
|
18
|
+
- parentResource: ${intent.parentResource ?? "unknown"}
|
|
19
|
+
- nestedResource: ${intent.nestedResource ?? "unknown"}
|
|
20
|
+
- routeHints: ${intent.routeHints.join(", ") || "none"}
|
|
21
|
+
- paramHints: ${intent.paramHints.join(", ") || "none"}
|
|
22
|
+
- mentionsNestedItem: ${intent.mentionsNestedItem ? "yes" : "no"}
|
|
23
|
+
- destructiveRisk: ${intent.destructiveRisk ? "yes" : "no"}
|
|
24
|
+
|
|
25
|
+
REPO SUMMARY
|
|
26
|
+
${repoSummary}
|
|
27
|
+
|
|
28
|
+
SCHEMA-AWARE SUMMARY
|
|
29
|
+
${schemaAwareSummary || "No schema-aware summary available."}
|
|
30
|
+
|
|
31
|
+
TARGET FILE
|
|
32
|
+
${filePath}
|
|
33
|
+
|
|
34
|
+
RELATED CONTEXT
|
|
35
|
+
${relatedContext}
|
|
36
|
+
|
|
37
|
+
CURRENT FILE CONTENT
|
|
38
|
+
\`\`\`
|
|
39
|
+
${fileContent}
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
STRICT PATCH RULES
|
|
43
|
+
1. Do not rewrite unrelated parts of the file.
|
|
44
|
+
2. Keep the patch as small and localized as possible.
|
|
45
|
+
3. If task intent is nested_resource, do not replace, delete, or redesign parent resource logic unless explicitly required.
|
|
46
|
+
4. For nested delete/update operations, target only the nested item and preserve the parent record.
|
|
47
|
+
5. Use exact identifiers when relevant, such as treatmentId + timelineId, patientId + noteId, or parent-child scoped filters.
|
|
48
|
+
6. If schema-aware summary identifies known tables, columns, storage kind, auth middleware, or response shape, you MUST follow them.
|
|
49
|
+
7. If storage kind is "separate_table", do not switch to json_field logic.
|
|
50
|
+
8. If storage kind is "json_field", do not invent a new table.
|
|
51
|
+
9. Do not invent new tables, columns, or route patterns if the schema-aware summary contradicts them.
|
|
52
|
+
10. Prefer existing naming patterns, controller patterns, route patterns, and service conventions already used in the repo.
|
|
53
|
+
11. Preserve multi-tenant or clinic/org scoping if present in the file or related context.
|
|
54
|
+
12. If confidence is low, add a warning instead of inventing architecture.
|
|
55
|
+
13. Return patch previews in the existing agent format.
|
|
56
|
+
14. Do not include markdown fences in the JSON response.
|
|
57
|
+
|
|
58
|
+
PATCH THINKING GUIDELINES
|
|
59
|
+
- First determine whether this file should be modified at all.
|
|
60
|
+
- If this file is not the right target, return a warning and keep the patch minimal.
|
|
61
|
+
- Reuse existing helpers/imports if they already exist.
|
|
62
|
+
- Avoid duplicate imports, duplicate routes, and duplicate handlers.
|
|
63
|
+
- For backend files, preserve auth and response conventions.
|
|
64
|
+
- For frontend files, preserve current service call patterns and payload shape.
|
|
65
|
+
|
|
66
|
+
OUTPUT FORMAT
|
|
67
|
+
Return JSON only:
|
|
68
|
+
{
|
|
69
|
+
"summary": "string",
|
|
70
|
+
"patches": [
|
|
71
|
+
{
|
|
72
|
+
"path": "string",
|
|
73
|
+
"operation": "create" | "modify",
|
|
74
|
+
"summary": "string",
|
|
75
|
+
"targetHint": "string",
|
|
76
|
+
"contentPreview": "string"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"warnings": ["string"]
|
|
80
|
+
}
|
|
81
|
+
`.trim();
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=patchPreviewPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patchPreviewPrompt.js","sourceRoot":"","sources":["../../src/prompts/patchPreviewPrompt.ts"],"names":[],"mappings":";;AAYA,0DAuFC;AAvFD,SAAgB,uBAAuB,CAAC,KAA8B;IACpE,MAAM,EACJ,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,WAAW,EACX,WAAW,EACX,cAAc,EACd,kBAAkB,EACnB,GAAG,KAAK,CAAC;IAEV,OAAO;;;;;;EAMP,IAAI;;;YAGM,MAAM,CAAC,MAAM;kBACP,MAAM,CAAC,YAAY;WAC1B,MAAM,CAAC,KAAK;oBACH,MAAM,CAAC,cAAc,IAAI,SAAS;oBAClC,MAAM,CAAC,cAAc,IAAI,SAAS;gBACtC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM;gBACtC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM;wBAC9B,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;qBAC3C,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;EAGxD,WAAW;;;EAGX,kBAAkB,IAAI,oCAAoC;;;EAG1D,QAAQ;;;EAGR,cAAc;;;;EAId,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CZ,CAAC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildPlanFeaturePrompt = buildPlanFeaturePrompt;
|
|
4
|
+
function buildPlanFeaturePrompt(input) {
|
|
5
|
+
return `
|
|
6
|
+
You are an expert software engineering agent working inside an existing production-style codebase.
|
|
7
|
+
|
|
8
|
+
Your job is to analyze the requested feature and return a STRICT JSON object only.
|
|
9
|
+
|
|
10
|
+
You must respect the existing architecture, detected storage model, detected auth patterns, and detected response conventions.
|
|
11
|
+
|
|
12
|
+
=== TASK ===
|
|
13
|
+
${input.task}
|
|
14
|
+
|
|
15
|
+
=== INTENT ===
|
|
16
|
+
- action: ${input.intent.action}
|
|
17
|
+
- resourceKind: ${input.intent.resourceKind}
|
|
18
|
+
- scope: ${input.intent.scope}
|
|
19
|
+
- parentResource: ${input.intent.parentResource ?? "unknown"}
|
|
20
|
+
- nestedResource: ${input.intent.nestedResource ?? "none"}
|
|
21
|
+
- mentionsNestedItem: ${input.intent.mentionsNestedItem ? "yes" : "no"}
|
|
22
|
+
- destructiveRisk: ${input.intent.destructiveRisk ? "yes" : "no"}
|
|
23
|
+
|
|
24
|
+
=== PROJECT SUMMARY ===
|
|
25
|
+
${input.repoSummary}
|
|
26
|
+
|
|
27
|
+
=== EXISTING FILES (target ONLY these) ===
|
|
28
|
+
${input.existingFilesSummary || "(none)"}
|
|
29
|
+
|
|
30
|
+
=== RELEVANT FILES ===
|
|
31
|
+
${input.relevantFilesSummary || "(none)"}
|
|
32
|
+
|
|
33
|
+
=== SCHEMA-AWARE SUMMARY ===
|
|
34
|
+
${input.schemaAwareSummary || "No schema-aware summary available."}
|
|
35
|
+
|
|
36
|
+
STRICT RULES:
|
|
37
|
+
0. You MUST only suggest files that appear in the EXISTING FILES list above.
|
|
38
|
+
1. Do NOT invent file paths. Do NOT suggest files that do not exist.
|
|
39
|
+
2. If the relevant file is index.html, suggest index.html.
|
|
40
|
+
3. If schema-aware summary indicates known tables or columns, you MUST NOT invent different table names or columns.
|
|
41
|
+
4. If storage kind is "separate_table", prefer nested-resource architecture using that table.
|
|
42
|
+
5. If storage kind is "json_field", prefer updating the parent record field instead of inventing a new table.
|
|
43
|
+
6. If storage kind is unknown, explicitly mention that uncertainty in the risks section.
|
|
44
|
+
7. Reuse detected auth middleware and response conventions when suggesting backend changes.
|
|
45
|
+
8. Keep suggested files focused and minimal. Do not include speculative files unless clearly justified.
|
|
46
|
+
9. For delete/update of nested resources, preserve the parent resource unless the task explicitly requests parent deletion.
|
|
47
|
+
10. Prefer consistency with existing route/controller/service patterns over idealized greenfield architecture.
|
|
48
|
+
11. If a route or handler likely already exists, suggest inspecting it before creating a new one.
|
|
49
|
+
12. Do not output markdown. Do not wrap JSON in code fences. Return raw JSON only.
|
|
50
|
+
|
|
51
|
+
THINKING GUIDELINES:
|
|
52
|
+
- First determine whether the task targets a parent resource or a nested resource.
|
|
53
|
+
- Then determine whether the change belongs in backend, frontend, or both.
|
|
54
|
+
- Then identify the minimum file set needed.
|
|
55
|
+
- Prefer modifying existing files over creating new files unless new files are clearly necessary.
|
|
56
|
+
- For multi-tenant systems, preserve clinic/org scoping if detected in the project summary or schema-aware summary.
|
|
57
|
+
|
|
58
|
+
Return JSON only with this exact shape:
|
|
59
|
+
{
|
|
60
|
+
"implementationSummary": "string",
|
|
61
|
+
"steps": ["string"],
|
|
62
|
+
"suggestedFiles": [
|
|
63
|
+
{
|
|
64
|
+
"path": "string",
|
|
65
|
+
"reason": "string",
|
|
66
|
+
"action": "modify" | "create" | "inspect"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"risks": ["string"]
|
|
70
|
+
}
|
|
71
|
+
`.trim();
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=planFeaturePrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planFeaturePrompt.js","sourceRoot":"","sources":["../../src/prompts/planFeaturePrompt.ts"],"names":[],"mappings":";;AAEA,wDA2EC;AA3ED,SAAgB,sBAAsB,CAAC,KAOtC;IACC,OAAO;;;;;;;;EAQP,KAAK,CAAC,IAAI;;;YAGA,KAAK,CAAC,MAAM,CAAC,MAAM;kBACb,KAAK,CAAC,MAAM,CAAC,YAAY;WAChC,KAAK,CAAC,MAAM,CAAC,KAAK;oBACT,KAAK,CAAC,MAAM,CAAC,cAAc,IAAI,SAAS;oBACxC,KAAK,CAAC,MAAM,CAAC,cAAc,IAAI,MAAM;wBACjC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;qBACjD,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;EAG9D,KAAK,CAAC,WAAW;;;EAGjB,KAAK,CAAC,oBAAoB,IAAI,QAAQ;;;EAGtC,KAAK,CAAC,oBAAoB,IAAI,QAAQ;;;EAGtC,KAAK,CAAC,kBAAkB,IAAI,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCjE,CAAC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/roles/testEngineerContext.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.buildTestEngineerContext = buildTestEngineerContext;
|
|
5
|
+
function findPageObjects(files) {
|
|
6
|
+
return files.filter((f) => f.path.includes("Page") ||
|
|
7
|
+
f.path.includes("page") ||
|
|
8
|
+
f.path.includes("pages/") ||
|
|
9
|
+
f.path.includes("pageobjects/") ||
|
|
10
|
+
f.path.includes("PageObjects/"));
|
|
11
|
+
}
|
|
12
|
+
function findStepDefinitions(files) {
|
|
13
|
+
return files.filter((f) => f.path.includes("steps/") ||
|
|
14
|
+
f.path.includes("stepdefinitions/") ||
|
|
15
|
+
f.path.includes("step_definitions/") ||
|
|
16
|
+
f.path.includes("Steps.java") ||
|
|
17
|
+
f.path.includes("_steps.py"));
|
|
18
|
+
}
|
|
19
|
+
function findFeatureFiles(files) {
|
|
20
|
+
return files.filter((f) => f.path.endsWith(".feature"));
|
|
21
|
+
}
|
|
22
|
+
function findConfigFiles(files) {
|
|
23
|
+
return files.filter((f) => f.path.includes("playwright.config") ||
|
|
24
|
+
f.path.includes("cypress.config") ||
|
|
25
|
+
f.path.includes("pytest.ini") ||
|
|
26
|
+
f.path.includes("conftest.py") ||
|
|
27
|
+
f.path.includes("testng.xml") ||
|
|
28
|
+
f.path.includes("pom.xml") ||
|
|
29
|
+
f.path.includes("build.gradle"));
|
|
30
|
+
}
|
|
31
|
+
function findExistingTestFiles(files, framework) {
|
|
32
|
+
switch (framework.framework) {
|
|
33
|
+
case "playwright_ts":
|
|
34
|
+
return files.filter((f) => f.path.endsWith(".spec.ts") || f.path.endsWith(".test.ts"));
|
|
35
|
+
case "playwright_js":
|
|
36
|
+
return files.filter((f) => f.path.endsWith(".spec.js") || f.path.endsWith(".test.js"));
|
|
37
|
+
case "cypress":
|
|
38
|
+
return files.filter((f) => f.path.endsWith(".cy.ts") || f.path.endsWith(".cy.js"));
|
|
39
|
+
case "cucumber_java":
|
|
40
|
+
return files.filter((f) => f.path.endsWith(".feature"));
|
|
41
|
+
case "selenium_java":
|
|
42
|
+
case "junit":
|
|
43
|
+
case "testng":
|
|
44
|
+
return files.filter((f) => f.path.endsWith("Test.java") || f.path.endsWith("Tests.java"));
|
|
45
|
+
case "pytest":
|
|
46
|
+
case "selenium_python":
|
|
47
|
+
return files.filter((f) => f.path.startsWith("test_") || f.path.includes("/test_"));
|
|
48
|
+
default:
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function buildFrameworkSummary(framework) {
|
|
53
|
+
const lines = [];
|
|
54
|
+
lines.push(`Test Framework: ${framework.framework}`);
|
|
55
|
+
lines.push(`Language: ${framework.language}`);
|
|
56
|
+
lines.push(`Confidence: ${framework.confidence}`);
|
|
57
|
+
lines.push(`Evidence: ${framework.evidence.join(", ")}`);
|
|
58
|
+
if (framework.testDir) {
|
|
59
|
+
lines.push(`Test Directory: ${framework.testDir}`);
|
|
60
|
+
}
|
|
61
|
+
return lines.join("\n");
|
|
62
|
+
}
|
|
63
|
+
function buildPromptHints(framework, pageObjects, stepDefs, existingTests) {
|
|
64
|
+
const hints = [];
|
|
65
|
+
switch (framework.framework) {
|
|
66
|
+
case "playwright_ts":
|
|
67
|
+
hints.push("Use TypeScript with Playwright test library");
|
|
68
|
+
hints.push("Import { test, expect } from '@playwright/test'");
|
|
69
|
+
hints.push("Use page.goto(), page.locator(), page.click() patterns");
|
|
70
|
+
hints.push("Place test files in the existing test directory");
|
|
71
|
+
if (pageObjects.length > 0) {
|
|
72
|
+
hints.push(`Reuse existing page objects: ${pageObjects.map((f) => f.path).join(", ")}`);
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case "playwright_js":
|
|
76
|
+
hints.push("Use JavaScript with Playwright test library");
|
|
77
|
+
hints.push("Import { test, expect } from '@playwright/test'");
|
|
78
|
+
hints.push("Use page.goto(), page.locator(), page.click() patterns");
|
|
79
|
+
break;
|
|
80
|
+
case "cypress":
|
|
81
|
+
hints.push("Use Cypress test syntax with cy.* commands");
|
|
82
|
+
hints.push("Use cy.get(), cy.contains(), cy.visit() patterns");
|
|
83
|
+
hints.push("Place tests in cypress/e2e/ directory");
|
|
84
|
+
break;
|
|
85
|
+
case "cucumber_java":
|
|
86
|
+
hints.push("Write Gherkin feature file with Given/When/Then syntax");
|
|
87
|
+
hints.push("Write Java step definitions with @Given, @When, @Then annotations");
|
|
88
|
+
hints.push("Import io.cucumber.java.en.Given/When/Then");
|
|
89
|
+
hints.push(`Place feature file in: ${framework.testDir ?? "src/test/resources/features/"}`);
|
|
90
|
+
hints.push("Place step definitions in: src/test/java/com/*/stepdefinitions/");
|
|
91
|
+
if (pageObjects.length > 0) {
|
|
92
|
+
hints.push(`Inject existing page objects via constructor: ${pageObjects.map((f) => f.path).join(", ")}`);
|
|
93
|
+
hints.push("NEVER create new WebDriver instances — use existing page objects");
|
|
94
|
+
}
|
|
95
|
+
if (stepDefs.length > 0) {
|
|
96
|
+
hints.push(`Follow existing step definition patterns from: ${stepDefs.map((f) => f.path).join(", ")}`);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case "selenium_java":
|
|
100
|
+
case "junit":
|
|
101
|
+
hints.push("Use JUnit 5 annotations: @Test, @BeforeEach, @AfterEach");
|
|
102
|
+
hints.push("Use Selenium WebDriver for browser interactions");
|
|
103
|
+
if (pageObjects.length > 0) {
|
|
104
|
+
hints.push(`Reuse existing page objects: ${pageObjects.map((f) => f.path).join(", ")}`);
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case "testng":
|
|
108
|
+
hints.push("Use TestNG annotations: @Test, @BeforeMethod, @AfterMethod");
|
|
109
|
+
hints.push("Use Selenium WebDriver for browser interactions");
|
|
110
|
+
if (pageObjects.length > 0) {
|
|
111
|
+
hints.push(`Reuse existing page objects: ${pageObjects.map((f) => f.path).join(", ")}`);
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
case "pytest":
|
|
115
|
+
case "selenium_python":
|
|
116
|
+
hints.push("Use pytest fixtures and test functions starting with test_");
|
|
117
|
+
hints.push("Use selenium.webdriver for browser automation");
|
|
118
|
+
if (pageObjects.length > 0) {
|
|
119
|
+
hints.push(`Reuse existing page objects: ${pageObjects.map((f) => f.path).join(", ")}`);
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (existingTests.length > 0) {
|
|
124
|
+
hints.push(`Follow patterns from existing tests: ${existingTests.slice(0, 3).map((f) => f.path).join(", ")}`);
|
|
125
|
+
}
|
|
126
|
+
return hints;
|
|
127
|
+
}
|
|
128
|
+
function buildOutputPaths(framework, task) {
|
|
129
|
+
const slug = task
|
|
130
|
+
.toLowerCase()
|
|
131
|
+
.replace(/[^a-z0-9]+/g, "_")
|
|
132
|
+
.slice(0, 40);
|
|
133
|
+
const base = framework.testDir ?? "tests";
|
|
134
|
+
switch (framework.framework) {
|
|
135
|
+
case "playwright_ts":
|
|
136
|
+
return { testFile: `${base}/${slug}.spec.ts` };
|
|
137
|
+
case "playwright_js":
|
|
138
|
+
return { testFile: `${base}/${slug}.spec.js` };
|
|
139
|
+
case "cypress":
|
|
140
|
+
return { testFile: `cypress/e2e/${slug}.cy.ts` };
|
|
141
|
+
case "cucumber_java":
|
|
142
|
+
return {
|
|
143
|
+
testFile: `src/test/resources/features/${slug}.feature`,
|
|
144
|
+
featureFile: `src/test/resources/features/${slug}.feature`,
|
|
145
|
+
stepDefinition: `src/test/java/com/stepdefinitions/${toPascalCase(slug)}Steps.java`,
|
|
146
|
+
};
|
|
147
|
+
case "selenium_java":
|
|
148
|
+
case "junit":
|
|
149
|
+
case "testng":
|
|
150
|
+
return {
|
|
151
|
+
testFile: `src/test/java/${toPascalCase(slug)}Test.java`,
|
|
152
|
+
};
|
|
153
|
+
case "pytest":
|
|
154
|
+
case "selenium_python":
|
|
155
|
+
return { testFile: `tests/test_${slug}.py` };
|
|
156
|
+
default:
|
|
157
|
+
return { testFile: `tests/${slug}.test` };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function toPascalCase(str) {
|
|
161
|
+
return str
|
|
162
|
+
.split("_")
|
|
163
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
164
|
+
.join("");
|
|
165
|
+
}
|
|
166
|
+
function buildTestEngineerContext(task, framework, allFiles) {
|
|
167
|
+
const existingTestFiles = findExistingTestFiles(allFiles, framework);
|
|
168
|
+
const pageObjectFiles = findPageObjects(allFiles);
|
|
169
|
+
const stepDefinitionFiles = findStepDefinitions(allFiles);
|
|
170
|
+
const featureFiles = findFeatureFiles(allFiles);
|
|
171
|
+
const configFiles = findConfigFiles(allFiles);
|
|
172
|
+
return {
|
|
173
|
+
framework,
|
|
174
|
+
existingTestFiles,
|
|
175
|
+
pageObjectFiles,
|
|
176
|
+
stepDefinitionFiles,
|
|
177
|
+
featureFiles,
|
|
178
|
+
configFiles,
|
|
179
|
+
frameworkSummary: buildFrameworkSummary(framework),
|
|
180
|
+
promptHints: buildPromptHints(framework, pageObjectFiles, stepDefinitionFiles, existingTestFiles),
|
|
181
|
+
outputPaths: buildOutputPaths(framework, task),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=testEngineerContext.js.map
|