pi-usereq 0.71.0 → 0.73.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/README.md +1 -1
- package/package.json +1 -1
- package/src/core/prompts.ts +18 -5
package/README.md
CHANGED
package/package.json
CHANGED
package/src/core/prompts.ts
CHANGED
|
@@ -195,6 +195,23 @@ function buildContextFilesBlock(projectBase: string, config: UseReqConfig): stri
|
|
|
195
195
|
return sections.join("\n\n");
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
/**
|
|
199
|
+
* @brief Injects the context-files block in place of the dedicated trailing `%%CONTEXT_FILES%%` placeholder.
|
|
200
|
+
* @details Replaces only the last occurrence of the `%%CONTEXT_FILES%%` token, which every bundled prompt places as the dedicated injection point at the end of its `## Context Files` section, so inline backticked references to the token inside prompt prose stay verbatim and no prompt content is overwritten by the injected block. Returns the input unchanged when the token is absent. Runs after every other prompt replacement so literal `%%...%%` tokens inside context-file content are never substituted. Time complexity O(n) in prompt length. No external state is mutated.
|
|
201
|
+
* @param[in] text {string} Prompt markdown after every other replacement, block injection, and tool-reference rewrite.
|
|
202
|
+
* @param[in] block {string} Rendered context-files markdown block, or the empty string when no enabled context file exists.
|
|
203
|
+
* @return {string} Prompt markdown whose dedicated trailing placeholder is replaced by the supplied block while all earlier occurrences of the token remain untouched.
|
|
204
|
+
* @satisfies REQ-329, REQ-331, REQ-332
|
|
205
|
+
*/
|
|
206
|
+
function injectContextFilesBlock(text: string, block: string): string {
|
|
207
|
+
const token = "%%CONTEXT_FILES%%";
|
|
208
|
+
const lastIndex = text.lastIndexOf(token);
|
|
209
|
+
if (lastIndex === -1) {
|
|
210
|
+
return text;
|
|
211
|
+
}
|
|
212
|
+
return text.slice(0, lastIndex) + block + text.slice(lastIndex + token.length);
|
|
213
|
+
}
|
|
214
|
+
|
|
198
215
|
/**
|
|
199
216
|
* @brief Rewrites bundled prompt tool references from legacy `req --...` syntax to internal tool names.
|
|
200
217
|
* @details Applies deterministic global regex replacements so prompt text matches the extension-registered tool surface instead of the standalone CLI spelling. Time complexity O(p*r) where p is pattern count and r is prompt length.
|
|
@@ -371,11 +388,7 @@ export function renderPrompt(
|
|
|
371
388
|
projectBase,
|
|
372
389
|
);
|
|
373
390
|
const adapted = adaptPromptForInternalTools(withPiDevConformance);
|
|
374
|
-
|
|
375
|
-
if (contextFilesBlock) {
|
|
376
|
-
return adapted.split("%%CONTEXT_FILES%%").join(contextFilesBlock);
|
|
377
|
-
}
|
|
378
|
-
return adapted.split("%%CONTEXT_FILES%%").join("");
|
|
391
|
+
return injectContextFilesBlock(adapted, buildContextFilesBlock(projectBase, config));
|
|
379
392
|
}
|
|
380
393
|
|
|
381
394
|
/**
|