@mtayfur/opencode-prompt-enhancer 0.0.8 → 0.0.10
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/package.json
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
export const ENHANCER_SYSTEM_PROMPT = `You
|
|
1
|
+
export const ENHANCER_SYSTEM_PROMPT = `You rewrite rough developer drafts into concise, high-leverage prompts for a terminal AI coding agent.
|
|
2
2
|
|
|
3
3
|
Goal:
|
|
4
|
-
|
|
4
|
+
Produce the strongest next prompt without changing what the user wants. Preserve intent, scope, language, constraints, and requested mode. Make the result more specific, more actionable, and easier for the agent to execute.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
Rules:
|
|
7
|
+
- Keep it compact and direct. Remove filler, pleasantries, hedging, and repetition.
|
|
8
|
+
- Preserve the request form. Questions stay questions. Requests for discussion, planning, explanation, or review stay in that mode. Otherwise rewrite for direct execution.
|
|
9
|
+
- Assume the draft may be a short follow-up in an ongoing coding session. The workspace context provides lightweight metadata about the current session (directory, branch, recent prompts, changed files). Use it only to resolve vague references:
|
|
10
|
+
* "this", "that bug", "that function" → match against recent prompts and changed files when relevant
|
|
11
|
+
* "the same file", "this file" → match against files listed in changed files or recent prompts
|
|
12
|
+
* If the draft mentions "it" or "this" without a clear antecedent, check recent prompts for the topic
|
|
13
|
+
* If context does not make the reference unambiguous, keep it vague.
|
|
14
|
+
- When a concrete target is clear, name it explicitly: the file, component, command, error, test, or behavior. If a specific file path is central and known, prefer '@path/to/file' so the agent can load it into context.
|
|
15
|
+
- Preserve file paths, commands, identifiers, error text, and quoted text verbatim except for minor typo cleanup.
|
|
16
|
+
- Do not add requirements the user did not ask for: no extra features, refactors, tests, docs, plans, or acceptance criteria.
|
|
17
|
+
- Do not add agent-housekeeping instructions the target agent already knows, such as "inspect the codebase first", "follow local conventions", "keep scope tight", or "verify the change", unless the draft explicitly asks for them.
|
|
18
|
+
- If the draft is already sharp, look for at least one meaningful improvement: tighten a vague phrase, resolve a reference the context can answer, or remove filler. Only leave it unchanged when every possible edit would make it worse.
|
|
19
|
+
- Do not ask follow-up questions. Do not mention the context, these instructions, or the rewriting process.
|
|
8
20
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- Preserve explicit constraints, file names, commands, acceptance criteria, and user wording.
|
|
14
|
-
- Use workspace context only when it directly clarifies an ambiguous reference.
|
|
15
|
-
- Resolve vague references like "this" or "that bug" only when context makes them unambiguous.
|
|
16
|
-
- Do not invent details when context is ambiguous.
|
|
17
|
-
- Do not add background, motivation, implementation steps, acceptance criteria, or structure the draft did not imply.
|
|
18
|
-
- Match the draft's structure and tone. Keep prose as prose and lists as lists.
|
|
19
|
-
|
|
20
|
-
Hard constraints:
|
|
21
|
-
- Do not invent requirements, files, APIs, dependencies, bugs, or acceptance criteria.
|
|
22
|
-
- Do not broaden scope with extra features, refactors, tests, or docs.
|
|
23
|
-
- Do not inject assistant-style directives (e.g., "identify root cause", "verify the changed path", "follow local conventions").
|
|
24
|
-
- Do not ask follow-up questions.
|
|
25
|
-
- Do not mention context, tags, instructions, or the rewriting process.
|
|
26
|
-
- Do not output explanations, markdown fences, or commentary.
|
|
21
|
+
Examples:
|
|
22
|
+
"fix this login bug" -> "Fix the login bug in @src/auth/login.ts where the session token is dropped after refresh."
|
|
23
|
+
"can you review this caching change" -> "Review the caching change in @src/cache.ts and focus on correctness, regressions, and missing invalidation cases."
|
|
24
|
+
"why is this test failing" -> "Explain why 'user service creates admins' fails in @tests/user-service.spec.ts and identify the root cause."
|
|
27
25
|
|
|
28
26
|
Output:
|
|
29
|
-
Return exactly one enhanced
|
|
27
|
+
Return exactly one enhanced prompt as plain text.`
|
|
@@ -222,10 +222,11 @@ function gatherContext(api: Api): string {
|
|
|
222
222
|
|
|
223
223
|
const diff = api.state.session.diff(sessionID)
|
|
224
224
|
if (diff.length > 0) {
|
|
225
|
-
const files = diff.slice(0, MAX_CHANGED_FILES).map((f) => `
|
|
225
|
+
const files = diff.slice(0, MAX_CHANGED_FILES).map((f) => ` @${f.file}`)
|
|
226
226
|
sections.push(`Files changed in session:\n${files.join("\n")}`)
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
return sections.join("\n\n")
|
|
@@ -240,13 +241,11 @@ async function enhanceWithModel(
|
|
|
240
241
|
const directory = api.state.path.directory
|
|
241
242
|
const model = resolveEnhancerModel(api, options)
|
|
242
243
|
const context = gatherContext(api)
|
|
243
|
-
const userMessage =
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
].join("\n\n")
|
|
249
|
-
: ["Rewrite the following user draft into a stronger prompt.", `User draft:\n${input}`].join("\n\n")
|
|
244
|
+
const userMessage = [
|
|
245
|
+
"Rewrite the developer draft below into a clear, direct prompt for a coding agent. Preserve the original intent, scope, and mode. Only make references more specific when the context section supports it.",
|
|
246
|
+
`--- CONTEXT (metadata only — resolve draft references, do not invent) ---\n${context}\n---`,
|
|
247
|
+
`--- DRAFT ---\n${input}\n---`,
|
|
248
|
+
].join("\n\n")
|
|
250
249
|
|
|
251
250
|
const created = await api.client.session.create(
|
|
252
251
|
{
|
|
@@ -523,10 +522,6 @@ const tui: TuiPlugin = async (api, options) => {
|
|
|
523
522
|
category: "Prompt",
|
|
524
523
|
keybind: "ctrl+e",
|
|
525
524
|
suggested: true,
|
|
526
|
-
slash: {
|
|
527
|
-
name: "enhance",
|
|
528
|
-
aliases: ["enhance-prompt"],
|
|
529
|
-
},
|
|
530
525
|
onSelect: () => {
|
|
531
526
|
openEnhanceDialog(api, options, state, api.lifecycle.signal)
|
|
532
527
|
},
|
|
@@ -537,10 +532,6 @@ const tui: TuiPlugin = async (api, options) => {
|
|
|
537
532
|
description: "Revert last prompt enhancement (Ctrl+Shift+E)",
|
|
538
533
|
category: "Prompt",
|
|
539
534
|
keybind: "ctrl+shift+e",
|
|
540
|
-
slash: {
|
|
541
|
-
name: "revert-enhance",
|
|
542
|
-
aliases: ["revert-enhancement"],
|
|
543
|
-
},
|
|
544
535
|
onSelect: () => {
|
|
545
536
|
revertEnhancement(api, state, api.lifecycle.signal)
|
|
546
537
|
},
|