@deathbeam/pi-rtk 0.0.2 → 0.0.4
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/index.ts +13 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -2,13 +2,25 @@ import type { BashToolCallEvent, ExecResult, ExtensionAPI, ToolCallEvent } from
|
|
|
2
2
|
|
|
3
3
|
const isBash = (event: ToolCallEvent): event is BashToolCallEvent => event.toolName === "bash";
|
|
4
4
|
|
|
5
|
+
// Text `rtk init` writes to CLAUDE.md (rtk-instructions v2), minus its "# Command output" heading.
|
|
6
|
+
export const RTK_PROMPT = `Command output here is condensed to save tokens, keeping every signal and
|
|
7
|
+
dropping costly noise. Treat it as the complete result: run commands
|
|
8
|
+
normally, and batch related commands into one call to avoid extra turns.
|
|
9
|
+
Truncated results state their recovery path in their own output. Re-run a
|
|
10
|
+
command as \`rtk bypass <cmd>\` only when its result is unusable: empty when
|
|
11
|
+
output was clearly expected, contradicting its exit code, or garbled.`;
|
|
12
|
+
|
|
5
13
|
export function rewrittenCommand(result: ExecResult): string | null {
|
|
6
14
|
if (result.killed || (result.code !== 0 && result.code !== 3)) return null;
|
|
7
15
|
return result.stdout.trim() || null;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
18
|
export default async function (pi: ExtensionAPI) {
|
|
11
|
-
if ((await pi.exec("rtk", ["--
|
|
19
|
+
if ((await pi.exec("rtk", ["gain", "--help"]).catch(() => null))?.code !== 0) return;
|
|
20
|
+
|
|
21
|
+
pi.on("before_agent_start", (event) => {
|
|
22
|
+
event.systemPromptOptions.sections.command_output = RTK_PROMPT;
|
|
23
|
+
});
|
|
12
24
|
|
|
13
25
|
pi.on("tool_call", async (event, ctx) => {
|
|
14
26
|
if (!isBash(event)) return;
|