@xynogen/pix-skills 0.10.12 → 0.11.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 CHANGED
@@ -11,7 +11,7 @@ Pi coding agent extension — skill loader tool + skills bundle.
11
11
  | Resource | Type | Description |
12
12
  |---|---|---|
13
13
  | `read_skills` | tool | Browse local skills, search Skills.sh, explicitly fetch/cache a selected public GitHub skill, read references, and copy bundled resources. |
14
- | `skills/` | skills | 36 bundled skills (off-context by default — discovered on demand via `read_skills`) |
14
+ | `skills/` | skills | 37 bundled skills (off-context by default — discovered on demand via `read_skills`) |
15
15
 
16
16
  ## New: Skills.sh search and remote skill cache
17
17
 
@@ -179,6 +179,7 @@ as `/skill:<name>` slash commands.
179
179
  | `search` | Deep code discovery and project context mapping with grep, graph, and LSP |
180
180
  | `subagent` | Decompose work and fan out independent units to parallel `agent` workers |
181
181
  | `suggest` | Ranked optimization and improvement recommendations |
182
+ | `swamp` | Save a repeating task as a `.pi/workflows/` codemode script: code runs it, the agent judges and patches only the failing step |
182
183
  | `task` | Task orchestration and ambiguity resolution |
183
184
  | `tdd` | Test-first development: red, green, refactor |
184
185
  | `test` | Run tests, analyze failures, and fix them |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-skills",
3
- "version": "0.10.12",
3
+ "version": "0.11.0",
4
4
  "description": "Pi extension — agent skill loader (skill tool + skills bundle)",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -46,7 +46,7 @@
46
46
  "@earendil-works/pi-tui": "*"
47
47
  },
48
48
  "dependencies": {
49
- "@xynogen/pix-gate": "^0.4.12",
49
+ "@xynogen/pix-gate": "^0.5.0",
50
50
  "@xynogen/pix-pretty": "^3.0.0",
51
51
  "@xynogen/pix-runtime": "^0.22.0"
52
52
  }
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: swamp
3
+ description: Swamp-style workflows on codemode — turn a task that repeats (review, release check, report, data pull) into a saved script in .pi/workflows/<name>.js that code runs and the agent only judges. Build once, run with the codemode stub, patch only the failing step. Use when the user asks to save, run, list or fix a workflow, or when the same multi-step task comes up again.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Swamp workflows (codemode)
8
+
9
+ Idea from Swamp (swamp-club.com): the agent builds a workflow once, code runs it, the model only does the steps that need judgment. Here the engine is `codemode`; no CLI to install.
10
+
11
+ ## When
12
+
13
+ - Make a workflow when a task repeats with the same steps. Keep one-off or exploratory work as normal tool calls.
14
+ - Before building, `ls .pi/workflows/` — reuse or patch an existing one.
15
+
16
+ ## Layout
17
+
18
+ - `.pi/workflows/<name>.js` — async function body. Gets `tools` (same as codemode) and `args`. Returns the text the agent needs to judge, nothing more.
19
+ - `.pi/workflows/runs.jsonl` — one line per run: `{name, args, ok, error, ms, ts}`. Read it to answer "what happened last run".
20
+ - First two lines of each file: a comment with what it does and its `args` shape.
21
+ - `.pi/` is often gitignored. If the user wants workflows shared or reviewed, ask before un-ignoring or moving them.
22
+
23
+ ## Build
24
+
25
+ 1. Steps with no judgment (git, tests, lint, fetch, parse) are code. Run independent ones with `Promise.all`.
26
+ 2. Validate `args` at the top and `throw` on bad input. Fail loudly; never pass a blank or guessed value on.
27
+ 3. Never put shell-interpolated `args` in a command without an allowlist regex check.
28
+ 4. Cap and trim output in the script (`tail`, `head -c`, pick fields). The return value is what costs tokens.
29
+ 5. Run it once with the stub and check the result before telling the user it works.
30
+
31
+ Helper every workflow needs (`bash` output has a `--- Changes ---` footer and ANSI colors):
32
+
33
+ ```js
34
+ const sh = async (command) => {
35
+ const r = await tools.bash({ command });
36
+ const out = r.output.split("\n--- Changes ---")[0].replace(/\x1b\[[0-9;]*m/g, "");
37
+ return { ok: r.exit_code === 0, out: out.trim() };
38
+ };
39
+ ```
40
+
41
+ ## Run
42
+
43
+ Call `codemode` with this stub. Change only `name` and `args`:
44
+
45
+ ```js
46
+ // @options: {"timeout_ms": 600000}
47
+ const name = "review", args = {};
48
+ const src = (await tools.bash({ command: `cat .pi/workflows/${name}.js` })).output;
49
+ const AF = Object.getPrototypeOf(async function () {}).constructor;
50
+ const t0 = Date.now();
51
+ let out, err;
52
+ try { out = await new AF("tools", "args", src)(tools, args); } catch (e) { err = String(e?.message ?? e); }
53
+ const log = JSON.stringify({ name, args, ok: !err, error: err, ms: Date.now() - t0, ts: new Date().toISOString() });
54
+ await tools.bash({ command: `printf '%s\\n' ${JSON.stringify(log)} >> .pi/workflows/runs.jsonl` });
55
+ if (err) throw new Error(`workflow ${name}: ${err}`);
56
+ return out;
57
+ ```
58
+
59
+ - Load with `bash cat`, not `read`: `read` adds `LINE#HASH|` anchors that break the script.
60
+ - After the run, the agent does the judgment step (review, decide, summarize) on the returned text.
61
+
62
+ ## Fix (patch the delta)
63
+
64
+ 1. Read the error in the result, or the last lines of `runs.jsonl`.
65
+ 2. `read` the workflow file and `edit` only the failing step. Never rewrite the whole file.
66
+ 3. Run the stub again. One fix, one run.
67
+ 4. If the fix changes `args` or output shape, update the header comment.
68
+
69
+ ## Pitfalls
70
+
71
+ - LSP flags `.pi/workflows/*.js` (top-level `await`/`return`, unknown `tools`/`args`). Expected: the file is a function body. Ignore those diagnostics.
72
+ - The sandbox has no file system, network or timers. All I/O goes through `tools`.
73
+ - Tool calls are real. A workflow that edits, pushes or deletes still needs the user's approval for that action.