@psnext/s-subagents 0.1.20260522-1
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/.slingshot/agentHooks.json +24 -0
- package/.slingshot/code-tagging/51adc022-context.json +15 -0
- package/.slingshot/code-tagging/51adc022-lock.json +101 -0
- package/.slingshot/code-tagging/5a95fab8-lock.json +87 -0
- package/.slingshot/prompts/sample.prompt.md +118 -0
- package/.slingshot/prompts_cache.json +1 -0
- package/.slingshot/skills_cache.json +1 -0
- package/.vscode/settings.json +3 -0
- package/README.md +164 -0
- package/agents/researcher.md +47 -0
- package/agents/scout.md +36 -0
- package/agents/worker.md +71 -0
- package/index.ts +932 -0
- package/package.json +10 -0
- package/tools/safe-bash.ts +60 -0
- package/tsconfig.json +13 -0
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe bash extension for worker subagent.
|
|
3
|
+
* Wraps the built-in bash tool with dangerous command blocking.
|
|
4
|
+
*/
|
|
5
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { createBashTool } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { Type } from "@sinclair/typebox";
|
|
8
|
+
|
|
9
|
+
const DANGEROUS_PATTERNS = [
|
|
10
|
+
/\brm\s+(-[a-zA-Z]*f[a-zA-Z]*\s+)?(-[a-zA-Z]*r[a-zA-Z]*\s+)?(\/|~\/?\s|~\/?\b)/,
|
|
11
|
+
/\brm\s+(-[a-zA-Z]*r[a-zA-Z]*\s+)?(-[a-zA-Z]*f[a-zA-Z]*\s+)?(\/|~\/?\s|~\/?\b)/,
|
|
12
|
+
/\bsudo\b/,
|
|
13
|
+
/\bmkfs\b/,
|
|
14
|
+
/\bdd\s+if=/,
|
|
15
|
+
/:\(\)\s*\{\s*:\|:&\s*\}\s*;:/,
|
|
16
|
+
/>\s*\/dev\/[sh]d[a-z]/,
|
|
17
|
+
/\bchmod\s+(-[a-zA-Z]+\s+)?777\s+\//,
|
|
18
|
+
/\bchown\s+(-[a-zA-Z]+\s+)?root/,
|
|
19
|
+
/\bcurl\s.*\|\s*(ba)?sh/,
|
|
20
|
+
/\bwget\s.*\|\s*(ba)?sh/,
|
|
21
|
+
/\bshutdown\b/,
|
|
22
|
+
/\breboot\b/,
|
|
23
|
+
/\binit\s+0\b/,
|
|
24
|
+
/\bkill\s+-9\s+1\b/,
|
|
25
|
+
/\bkillall\b/,
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
function isDangerous(command: string): string | null {
|
|
29
|
+
const normalized = command.replace(/\\\n/g, " ");
|
|
30
|
+
for (const pattern of DANGEROUS_PATTERNS) {
|
|
31
|
+
if (pattern.test(normalized)) {
|
|
32
|
+
return `Command blocked by safe_bash: matches dangerous pattern ${pattern}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default function (pi: ExtensionAPI) {
|
|
39
|
+
const bashTool = createBashTool(process.cwd());
|
|
40
|
+
|
|
41
|
+
pi.registerTool({
|
|
42
|
+
name: "safe_bash",
|
|
43
|
+
label: "Safe Bash",
|
|
44
|
+
description:
|
|
45
|
+
"Execute a bash command. Blocks dangerous commands (rm -rf /, sudo, mkfs, etc.).",
|
|
46
|
+
parameters: Type.Object({
|
|
47
|
+
command: Type.String({ description: "Bash command to execute" }),
|
|
48
|
+
timeout: Type.Optional(
|
|
49
|
+
Type.Number({ description: "Timeout in seconds (optional)" }),
|
|
50
|
+
),
|
|
51
|
+
}),
|
|
52
|
+
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
53
|
+
const danger = isDangerous(params.command);
|
|
54
|
+
if (danger) {
|
|
55
|
+
throw new Error(danger);
|
|
56
|
+
}
|
|
57
|
+
return bashTool.execute(toolCallId, params, signal, onUpdate);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"types": ["node"],
|
|
4
|
+
"moduleResolution": "nodenext",
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"target": "ES2020",
|
|
8
|
+
"module": "NodeNext",
|
|
9
|
+
"lib": ["ES2022"]
|
|
10
|
+
},
|
|
11
|
+
"include": ["**/*.ts"],
|
|
12
|
+
"exclude": ["node_modules"]
|
|
13
|
+
}
|