dotfiles
bugabingas dorkfiles
owned by bugabinga
remove inline extension
2799ffbcd8915ff78ef0ed7e08a6fcc7fadf5f68
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (5)
pi/agent/extensions/inline/CHANGELOG.md
Deleteddeleted file mode 1006445 -- a40a427 prepare extensions for npm release
6 -- 133cb7d chore(pi): migrate extensions to earendil packages
7 -- 5ca1296 Rework Pi agent extensions
8 -- b87a61a feat(pi): monorepo workspace — all extensions are proper packages
pi/agent/extensions/inline/README.md
Deleteddeleted file mode 100644 3 -Inline shell expansion for Pi prompts.
5 -Expands !{...} snippets before prompts reach the model.
10 -
pi/agent/extensions/inline/assets/shell_suite.gif
Deleteddeleted file mode 100644Previous version contains binary or non-UTF-8 data.
pi/agent/extensions/inline/index.ts
Deleteddeleted file mode 10064417 -import type { ExtensionAPI }
from "@earendil-works/pi-coding-agent";
19 -export default function (pi
: ExtensionAPI) {
20 - const PATTERN
= /!\{([^}]+)\}/g;
21 - const TIMEOUT_MS
= 30000;
23 - pi.
on(
"input",
async (event, ctx)
=> {
24 - const text
= event.
text;
28 - if (text.
trimStart().
startsWith(
"!")
&& !text.
trimStart().
startsWith(
"!{")) {
29 - return { action:
"continue" };
33 - if (
!PATTERN.
test(text)) {
34 - return { action:
"continue" };
38 - PATTERN.
lastIndex = 0;
41 - const expansions
: Array<{ command
: string; output
: string; error
?: string }>
= [];
44 - const matches
: Array<{ full
: string; command
: string }>
= [];
45 - let match
= PATTERN.
exec(text);
47 - matches.
push({ full: match[
0], command: match[
1] });
48 - match
= PATTERN.
exec(text);
52 - for (
const { full, command }
of matches) {
54 - const bashResult
= await pi.
exec(
"bash", [
"-c", command], {
55 - timeout: TIMEOUT_MS,
58 - const output
= bashResult.stdout
|| bashResult.stderr
|| "";
59 - const trimmed
= output.
trim();
61 - if (bashResult.
code !== 0 && bashResult.stderr) {
65 - error:
`exit code ${bashResult.code}`,
68 - expansions.
push({ command, output: trimmed });
71 - result
= result.
replace(full, trimmed);
73 - const errorMsg
= err
instanceof Error ? err.message
: String(err);
74 - expansions.
push({ command, output:
"", error: errorMsg });
75 - result
= result.
replace(full,
`[error: ${errorMsg}]`);
80 - if (ctx.hasUI
&& expansions.
length > 0) {
81 - const summary
= expansions
83 - const status
= e.error
? ` (${e.error})` : "";
84 - const preview
= e.output.
length > 50 ? `${e.output.slice(0, 50)}...` : e.output;
85 - return `!{${e.command}}${status} -> "${preview}"`;
89 - ctx.ui.
notify(
`Expanded ${expansions.length} inline command(s):\n${summary}`,
"info");
92 - return { action:
"transform", text: result, images:
event.
images };
pi/agent/extensions/inline/package.json
Deleteddeleted file mode 100644 2 - "name":
"@bugabinga/pi-ext-inline",
6 - "peerDependencies": {
7 - "@earendil-works/pi-coding-agent":
"*" 10 - "description":
"Inline shell expansion for Pi prompts.",