@fermindi/pwn-cli 0.9.8 → 0.9.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@fermindi/pwn-cli",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "description": "Professional AI Workspace - Inject structured memory and automation into any project for AI-powered development",
5
5
  "type": "module",
6
6
  "bin": {
@@ -534,7 +534,7 @@ export async function runBatch(options = {}, cwd = process.cwd()) {
534
534
  console.log(chalk.yellow(` Retry ${retry}/${MAX_RETRIES}`));
535
535
  }
536
536
 
537
- const prompt = buildPrompt(task.id, batchWorktreePath, mainCwd, errorContext);
537
+ const prompt = buildPrompt(task.id, batchWorktreePath, mainCwd, errorContext, retry);
538
538
  if (!prompt) {
539
539
  console.log(chalk.red(` Cannot build prompt for ${task.id} — skipping`));
540
540
  break;
@@ -926,12 +926,14 @@ async function runGatesWithStatus(taskCwd, mainCwd = taskCwd) {
926
926
 
927
927
  /**
928
928
  * Build the prompt from template, substituting placeholders.
929
+ * On retries, generates a focused "fix" prompt instead of the full template.
929
930
  * @param {string} storyId - Story ID
930
931
  * @param {string} batchWorktreePath - Batch worktree (for prd.json, tracked file)
931
932
  * @param {string} mainCwd - Main repo (for prompt.md, gitignored file)
932
933
  * @param {string} extraContext - Error context from previous attempt
934
+ * @param {number} retry - Retry number (0 = first attempt)
933
935
  */
934
- function buildPrompt(storyId, batchWorktreePath, mainCwd, extraContext) {
936
+ function buildPrompt(storyId, batchWorktreePath, mainCwd, extraContext, retry = 0) {
935
937
  const prdPath = join(batchWorktreePath, '.ai', 'tasks', 'prd.json');
936
938
  const promptPath = join(mainCwd, '.ai', 'batch', 'prompt.md');
937
939
 
@@ -942,9 +944,36 @@ function buildPrompt(storyId, batchWorktreePath, mainCwd, extraContext) {
942
944
  return '';
943
945
  }
944
946
 
945
- const doneIds = prd.stories.filter(s => s.passes).map(s => s.id);
946
947
  const acList = (story.acceptance_criteria || []).map(ac => `- ${ac}`).join('\n') || 'None';
947
948
 
949
+ // --- Retry: focused fix prompt ---
950
+ if (retry > 0 && extraContext) {
951
+ return `You are fixing story ${storyId}: ${story.title}
952
+
953
+ ## Context
954
+ A previous attempt already implemented this story. The working tree contains the implementation.
955
+ Read the modified files to understand what was done.
956
+
957
+ ## Acceptance criteria
958
+ ${acList}
959
+
960
+ ## Quality gate failures
961
+ \`\`\`
962
+ ${extraContext}
963
+ \`\`\`
964
+
965
+ ## Instructions
966
+ 1. Read the existing code in the working tree
967
+ 2. Analyze the quality gate errors above
968
+ 3. Fix ONLY what's needed to make the gates pass
969
+ 4. If the errors indicate a deeper design problem that can't be patched, you may rewrite the implementation — but try fixing first
970
+ 5. Make sure the fix still satisfies all acceptance criteria above
971
+ 6. Commit your changes when done`;
972
+ }
973
+
974
+ // --- First attempt: full template ---
975
+ const doneIds = prd.stories.filter(s => s.passes).map(s => s.id);
976
+
948
977
  let depsList = 'None';
949
978
  if (story.dependencies?.length > 0) {
950
979
  depsList = story.dependencies
@@ -963,10 +992,6 @@ function buildPrompt(storyId, batchWorktreePath, mainCwd, extraContext) {
963
992
  prompt = prompt.replaceAll('{NOTES}', story.notes || '');
964
993
  prompt = prompt.replaceAll('{DEPENDENCIES}', depsList);
965
994
 
966
- if (extraContext) {
967
- prompt += `\n\n## Previous Attempt Failed\nThe previous attempt failed quality gates. Here is the error output:\n\n\`\`\`\n${extraContext}\n\`\`\`\n\nFix these issues before committing.`;
968
- }
969
-
970
995
  return prompt;
971
996
  }
972
997