@pimzino/sgrep 1.3.21 → 1.3.24
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-parser.d.ts","sourceRoot":"","sources":["../../src/utils/prompt-parser.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQnE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"prompt-parser.d.ts","sourceRoot":"","sources":["../../src/utils/prompt-parser.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQnE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAuE1E"}
|
|
@@ -20,15 +20,36 @@ export function parseEnhancedPrompt(response) {
|
|
|
20
20
|
* The output is formatted as instructions for an AI coding agent.
|
|
21
21
|
*/
|
|
22
22
|
export function buildEnhancementInstruction(originalPrompt) {
|
|
23
|
-
return `You are enhancing a prompt that will be given to an AI coding agent.
|
|
23
|
+
return `You are enhancing a prompt that will be given to an AI coding agent. ONLY add codebase context when it's genuinely relevant.
|
|
24
24
|
|
|
25
|
-
##
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
## STEP 1: ASSESS RELEVANCE (CRITICAL)
|
|
26
|
+
First, determine if codebase context is actually needed. DO NOT add context if the prompt is about:
|
|
27
|
+
- External tool operations (gh, git, npm, docker commands) that don't modify codebase files
|
|
28
|
+
- Fetching/reviewing external information (GitHub issues, PRs, web searches, API docs)
|
|
29
|
+
- Planning or discussion that should happen AFTER reading external information
|
|
30
|
+
- General questions not about implementing/modifying code in THIS codebase
|
|
31
|
+
- Explanations, research, or investigation tasks
|
|
32
|
+
|
|
33
|
+
ONLY add codebase context if the task will directly:
|
|
34
|
+
- Modify, create, or delete files in the codebase
|
|
35
|
+
- Need to follow existing code patterns/conventions
|
|
36
|
+
- Reference specific implementations in the codebase
|
|
37
|
+
|
|
38
|
+
## STEP 2: IF NO CONTEXT NEEDED
|
|
39
|
+
Simply return the original prompt with minimal formatting. No "Codebase Context:" section.
|
|
40
|
+
|
|
41
|
+
Example - Prompt: "use gh cli to review issue #189 and plan a fix"
|
|
42
|
+
Output: Just return the prompt as-is (maybe capitalize first letter). The issue content is on GitHub, not in the codebase. Context would be noise.
|
|
43
|
+
|
|
44
|
+
## STEP 3: IF CONTEXT IS RELEVANT
|
|
45
|
+
Then follow these rules:
|
|
46
|
+
|
|
47
|
+
### ABSOLUTE RULES (VIOLATION = FAILURE):
|
|
48
|
+
1. PRESERVE every explicit instruction verbatim
|
|
49
|
+
2. PRESERVE all user-specified tools, commands, approaches, constraints
|
|
28
50
|
3. PRESERVE any code samples, examples, or references the user provided
|
|
29
|
-
4. The enhanced prompt is FOR AN AI AGENT - write it as actionable instructions, not documentation
|
|
30
51
|
|
|
31
|
-
|
|
52
|
+
### Enhancement Approach:
|
|
32
53
|
1. Start with the user's original request/instruction (preserved exactly)
|
|
33
54
|
2. Add a brief "Codebase Context:" section with:
|
|
34
55
|
- Relevant file paths (e.g., "Implementation is in src/auth/login.ts")
|
|
@@ -36,32 +57,35 @@ export function buildEnhancementInstruction(originalPrompt) {
|
|
|
36
57
|
- Short code snippets (3-10 lines) showing existing patterns to follow
|
|
37
58
|
3. Keep context concise and actionable - snippets over explanations
|
|
38
59
|
|
|
39
|
-
|
|
60
|
+
### Output Style (FOR AI AGENT):
|
|
40
61
|
- Use imperative instructions: "Modify X", "Add Y to Z", "Follow the pattern in A"
|
|
41
62
|
- Reference specific files and line numbers when helpful
|
|
42
63
|
- Include SHORT code snippets showing existing patterns (not full functions)
|
|
43
|
-
- Be direct and actionable, not explanatory
|
|
44
64
|
|
|
45
|
-
## Bad Example (
|
|
46
|
-
"
|
|
65
|
+
## Bad Example (context pollution):
|
|
66
|
+
Prompt: "use gh cli to check issue #42"
|
|
67
|
+
Bad output: Returns prompt with codebase context about issue templates, GitHub workflows, etc.
|
|
68
|
+
Why bad: The task is to READ an external issue. Codebase files are irrelevant.
|
|
47
69
|
|
|
48
|
-
## Good Example (
|
|
49
|
-
"
|
|
70
|
+
## Good Example (context only when needed):
|
|
71
|
+
Prompt: "add password reset functionality to the auth module"
|
|
72
|
+
Good output:
|
|
73
|
+
"Add password reset functionality to the auth module.
|
|
50
74
|
|
|
51
75
|
Codebase Context:
|
|
52
|
-
- Auth
|
|
76
|
+
- Auth module: src/auth/
|
|
53
77
|
- User model: src/models/User.ts
|
|
54
78
|
|
|
55
|
-
Existing
|
|
79
|
+
Existing pattern:
|
|
56
80
|
\`\`\`typescript
|
|
57
81
|
// from src/auth/login.ts
|
|
58
|
-
const hashedPassword = await bcrypt.hash(password, 10);
|
|
59
82
|
const token = jwt.sign({ userId: user.id }, SECRET, { expiresIn: '24h' });
|
|
60
83
|
\`\`\`"
|
|
61
84
|
|
|
62
85
|
## Output Format:
|
|
63
86
|
<enhanced-prompt>
|
|
64
|
-
[
|
|
87
|
+
[If no context needed: just the original instruction, cleaned up]
|
|
88
|
+
[If context needed: original instruction + brief codebase context section]
|
|
65
89
|
</enhanced-prompt>
|
|
66
90
|
|
|
67
91
|
## Original Prompt to Enhance:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-parser.js","sourceRoot":"","sources":["../../src/utils/prompt-parser.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,qBAAqB,GAAG,gDAAgD,CAAC;AAE/E;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAEpD,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACf,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,cAAsB;IAChE,OAAO
|
|
1
|
+
{"version":3,"file":"prompt-parser.js","sourceRoot":"","sources":["../../src/utils/prompt-parser.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,qBAAqB,GAAG,gDAAgD,CAAC;AAE/E;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAEpD,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACf,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,cAAsB;IAChE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqEP,cAAc,EAAE,CAAC;AACnB,CAAC"}
|