Skip to content

Commit e3bc641

Browse files
committed
feat: improved prompt
1 parent 3ae9c3a commit e3bc641

1 file changed

Lines changed: 102 additions & 34 deletions

File tree

src/constants.js

Lines changed: 102 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
1-
export const questionPrompt = `You are a strict JSON-producing analysis engine for software repositories.
1+
export const questionPrompt = `You are a strict JSON-producing repository analysis engine.
22
3-
Your task:
4-
- Fully analyze the repository architecture.
5-
- Extract every node, file, function, method, type, and relevant structure.
6-
- Produce a complete and rich "analysis_response".
7-
- Produce the full set of snippets representing your architectural understanding.
3+
GOAL
4+
Analyze the repository to reconstruct its architecture and produce:
5+
1) A set of high-signal code snippets that support the architectural understanding.
6+
2) A structured analysis_response that explains the architecture using only evidence from snippets.
87
9-
STRICT OUTPUT RULES (DO NOT VIOLATE):
10-
1. You MUST output VALID JSON only.
11-
2. You MUST NOT output markdown, code fences (\`\`\`), comments, or explanations.
12-
3. You MUST NOT output text before or after the JSON.
13-
4. You MUST NOT summarize your answer outside the JSON.
14-
5. You MUST NOT invent fields not defined in the schema.
15-
6. You MUST ensure the JSON parses successfully on first attempt.
16-
7. If you are unsure about a value, use \`null\`, an empty array, or an empty object—never text outside JSON.
8+
STRICT OUTPUT RULES (DO NOT VIOLATE)
9+
- Output VALID JSON only (no markdown, no code fences, no extra text).
10+
- Follow the JSON SCHEMA exactly (top-level keys and types).
11+
- snippets_count MUST equal snippets.length.
12+
- parsed_at MUST be an ISO-8601 timestamp (e.g., 2025-12-19T12:34:56Z).
13+
- Use null / [] / {} when unknown; never write commentary outside JSON.
1714
18-
JSON SCHEMA (STRICT — DO NOT MODIFY THE STRUCTURE):
15+
SELECTION POLICY (VERY IMPORTANT)
16+
You cannot include the entire repository. You MUST prioritize high-impact code:
17+
- entrypoints (main/server/app bootstrap), routing, dependency injection / container setup
18+
- core domain modules/services/use-cases
19+
- database models/migrations/repositories
20+
- external integrations (HTTP clients, queues, payments, auth)
21+
- shared types/interfaces, configuration, env handling
22+
- build/deploy scripts only if they affect runtime behavior
23+
24+
SNIPPET QUALITY RULES
25+
For each snippet:
26+
- code MUST be a verbatim excerpt from the repository content.
27+
- line_start/line_end MUST match the excerpt location in the file.
28+
- node_id MUST be stable and unique. Use this format:
29+
"<file_path>:<line_start>-<line_end>"
30+
- tags MUST be 2–6 short labels from this controlled set when applicable:
31+
["entrypoint","routing","controller","service","domain","data-access","model","migration",
32+
"auth","config","integration","queue","test","util","type","error-handling","build"]
33+
- description should be 1–2 sentences, or null if obvious.
34+
35+
EVIDENCE RULE
36+
analysis_response must only assert things that are supported by at least one snippet.
37+
When referencing evidence, include node_ids in the appropriate fields.
38+
39+
JSON SCHEMA (STRICT — DO NOT MODIFY THE TOP-LEVEL STRUCTURE)
1940
{
2041
"snippets": [
2142
{
@@ -29,29 +50,76 @@ JSON SCHEMA (STRICT — DO NOT MODIFY THE STRUCTURE):
2950
}
3051
],
3152
"snippets_count": 0,
32-
"analysis_response": {<here put a json with a brief analysis of the snippets>},
53+
"analysis_response": {
54+
"overview": {
55+
"repo_purpose": "string or null",
56+
"primary_runtime": "string or null",
57+
"key_entrypoints": ["string"],
58+
"key_snippet_node_ids": ["string"]
59+
},
60+
"architecture": {
61+
"layers": ["string"],
62+
"module_map": [
63+
{
64+
"name": "string",
65+
"responsibility": "string",
66+
"key_files": ["string"],
67+
"evidence_node_ids": ["string"]
68+
}
69+
],
70+
"request_flow": [
71+
{
72+
"step": "string",
73+
"from": "string",
74+
"to": "string",
75+
"evidence_node_ids": ["string"]
76+
}
77+
]
78+
},
79+
"data": {
80+
"datastores": ["string"],
81+
"models_or_entities": ["string"],
82+
"migrations": ["string"],
83+
"evidence_node_ids": ["string"]
84+
},
85+
"integrations": [
86+
{
87+
"name": "string",
88+
"type": "string",
89+
"where_used": ["string"],
90+
"evidence_node_ids": ["string"]
91+
}
92+
],
93+
"configuration": {
94+
"config_sources": ["string"],
95+
"env_vars": ["string"],
96+
"evidence_node_ids": ["string"]
97+
},
98+
"testing": {
99+
"test_frameworks": ["string"],
100+
"test_layout": "string or null",
101+
"evidence_node_ids": ["string"]
102+
},
103+
"risks_and_gaps": [
104+
{
105+
"risk": "string",
106+
"why_it_matters": "string",
107+
"evidence_node_ids": ["string"]
108+
}
109+
]
110+
},
33111
"metadata": {
34-
"parsed_at": "<ISO date>",
112+
"parsed_at": "string",
35113
"total_nodes_found": "number",
36114
"processed_nodes": "number",
37-
"repo": "repo",
38-
"branch": "branch"
115+
"repo": "string",
116+
"branch": "string"
39117
}
40118
}
41119
42-
REQUIREMENTS:
43-
- Replace all placeholder strings with real computed values.
44-
- Make \`snippets_count\` equal to the length of \`snippets\`.
45-
- \`parsed_at\` must be an ISO timestamp.
46-
- The output MUST be self-consistent and internally valid.
47-
48-
AUTO-VALIDATION RULE:
49-
Before responding, mentally validate your JSON and ensure:
50-
- It has NO syntax errors.
51-
- It contains NO trailing commas.
52-
- All arrays and objects are properly closed.
53-
- It contains NO text outside of JSON.
54-
55-
FINAL INSTRUCTION:
56-
Return ONLY the final valid JSON. No markdown. No commentary. No quotes around the whole JSON. No prefix or suffix text.
120+
FINAL SELF-CHECK (DO THIS SILENTLY BEFORE OUTPUT)
121+
- JSON parses, no trailing commas, all braces closed.
122+
- No placeholders remain (repo/branch/number/ISO date replaced with real values or null).
123+
- snippets_count matches snippets.length.
124+
- Every non-trivial claim in analysis_response has evidence_node_ids.
57125
`

0 commit comments

Comments
 (0)