oira666_pi-subagent 0.7.6 → 0.7.7
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 +8 -2
- package/package.json +13 -6
- package/scripts/build-startup.mjs +66 -0
- package/startup.js +12589 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Launches return immediately. Completion and worker messages arrive as steering t
|
|
|
6
6
|
|
|
7
7
|
Requires Pi 1.4.0 or newer, using the `@earendil-works` SDK packages. Only the latest npm Pi release is tested.
|
|
8
8
|
|
|
9
|
-
Tested against Pi 1.4.0
|
|
9
|
+
Tested against Pi 1.4.0 on Linux.
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -176,9 +176,15 @@ The single-line dim `WITH SUBS` widget below the editor includes recursive worke
|
|
|
176
176
|
|
|
177
177
|
```bash
|
|
178
178
|
npm ci
|
|
179
|
+
npm run build
|
|
179
180
|
npm run check
|
|
181
|
+
npm run test:package
|
|
180
182
|
```
|
|
181
183
|
|
|
184
|
+
Pi loads `startup.js`, an ESM bundle built from the current TypeScript source with esbuild. Pi SDK, TypeBox, and Node imports stay external so Pi supplies its own host modules. The generated bundle is committed for direct Git installs, and `npm pack` and `npm publish` rebuild it through `prepack`. Run `npm run build` after source changes; do not edit the bundle. Its generated size is exempt from the source-file line limit.
|
|
185
|
+
|
|
186
|
+
The package tests unpack a fresh npm tarball, rebuild it without the existing bundle, compare source and packaged declarations through the latest Pi CLI, and exercise the packaged child runner without model requests. Build tests also check relocated module-relative assets and child entry URLs. Temporary work stays under `tmp/`.
|
|
187
|
+
|
|
182
188
|
`npm test` first installs the four declared Pi SDK packages at `@latest` with `--save-dev --ignore-scripts`, then typechecks before running tests. `npm run check` uses that same path and also checks formatting and file size. Network access is required, and a newer Pi release can update `package.json` and `package-lock.json`. Keep those changes together.
|
|
183
189
|
|
|
184
190
|
`npm run test:evergreen` typechecks and runs all unit/integration tests in an isolated temporary workspace, then runs real-Pi delegation and saved-worker resume e2e tests. Set `EVERGREEN_E2E_MODEL` to an authenticated `provider/model[:thinking]`; `EVERGREEN_PI_BIN` selects the globally installed Pi executable (defaults to `pi` on PATH). E2E keeps sessions enabled, ignores stdin, and uses a disposable agent directory with copies of your auth/model configuration. It makes real model calls and requires network access. See [EVERGREEN.md](EVERGREEN.md) for intent coverage and Pi upgrade risks.
|
|
@@ -195,7 +201,7 @@ Source organization:
|
|
|
195
201
|
| `types/` | Runtime contracts, transcript parsing, outcomes, usage aggregation |
|
|
196
202
|
| `ui/` | Transcript views, trees, navigation and overlays |
|
|
197
203
|
|
|
198
|
-
Root entry points preserve existing imports.
|
|
204
|
+
Root source entry points preserve existing imports. Both `index.ts` and the generated package entry `startup.js` keep the default extension registration export and the named exports `selectParentModelForSubagent`, `getSubagentsToolDescription`, `collectCombinedUsageStatusLine`, and `collectLiveUsageSummary`. `config.ts` and `agents.ts` discover configuration and definitions. Runtime and test files stay below 350 lines; the name list is static data.
|
|
199
205
|
|
|
200
206
|
See [async performance and memory](docs/async-performance.md) for cache behavior, test evidence, and remaining limits.
|
|
201
207
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oira666_pi-subagent",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"description": "Subagent extension for Pi coding agent. Delegate tasks to specialized agents.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "startup.js",
|
|
7
|
+
"types": "index.ts",
|
|
7
8
|
"files": [
|
|
9
|
+
"startup.js",
|
|
10
|
+
"scripts/build-startup.mjs",
|
|
8
11
|
"index.ts",
|
|
9
12
|
"agents.ts",
|
|
10
13
|
"budget.ts",
|
|
@@ -33,7 +36,7 @@
|
|
|
33
36
|
],
|
|
34
37
|
"pi": {
|
|
35
38
|
"extensions": [
|
|
36
|
-
"./
|
|
39
|
+
"./startup.js"
|
|
37
40
|
]
|
|
38
41
|
},
|
|
39
42
|
"keywords": [
|
|
@@ -55,12 +58,15 @@
|
|
|
55
58
|
},
|
|
56
59
|
"license": "MIT",
|
|
57
60
|
"scripts": {
|
|
61
|
+
"build": "node scripts/build-startup.mjs",
|
|
62
|
+
"prepack": "npm run build",
|
|
58
63
|
"pretest": "npm install --save-dev --ignore-scripts @earendil-works/pi-agent-core@latest @earendil-works/pi-ai@latest @earendil-works/pi-coding-agent@latest @earendil-works/pi-tui@latest && npm run typecheck",
|
|
59
|
-
"test": "node --import tsx/esm --test test/*.test.ts",
|
|
64
|
+
"test": "node --import tsx/esm --test test/*.test.ts test/*.test.mjs",
|
|
65
|
+
"test:package": "node --test test/startup-*.test.mjs",
|
|
60
66
|
"test:evergreen": "npm run pretest && node scripts/evergreen.mjs",
|
|
61
67
|
"typecheck": "tsc --noEmit",
|
|
62
|
-
"format": "prettier --write \"*.ts\" \"{extension,runner,storage,types,ui,test}/**/*.ts\" \"scripts
|
|
63
|
-
"format:check": "prettier --check \"*.ts\" \"{extension,runner,storage,types,ui,test}/**/*.ts\" \"scripts
|
|
68
|
+
"format": "prettier --write \"*.ts\" \"{extension,runner,storage,types,ui,test}/**/*.ts\" \"{scripts,test}/**/*.mjs\" package.json tsconfig.json .prettierrc.json",
|
|
69
|
+
"format:check": "prettier --check \"*.ts\" \"{extension,runner,storage,types,ui,test}/**/*.ts\" \"{scripts,test}/**/*.mjs\" package.json tsconfig.json .prettierrc.json",
|
|
64
70
|
"check:size": "node scripts/check-size.mjs",
|
|
65
71
|
"check": "npm test && npm run format:check && npm run check:size"
|
|
66
72
|
},
|
|
@@ -71,6 +77,7 @@
|
|
|
71
77
|
"@earendil-works/pi-tui": "^1.4.0",
|
|
72
78
|
"@sinclair/typebox": ">=0.34.0",
|
|
73
79
|
"@types/node": "^25.2.3",
|
|
80
|
+
"esbuild": "^0.28.2",
|
|
74
81
|
"prettier": "^3.9.6",
|
|
75
82
|
"tsx": "^4.23.13",
|
|
76
83
|
"typescript": "^5.9.3"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { build, transform } from "esbuild";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const packageRoot = fileURLToPath(new URL("../", import.meta.url));
|
|
7
|
+
|
|
8
|
+
/** Keep module-relative assets and child entry URLs relative to the original source file. */
|
|
9
|
+
function sourceUrls(root) {
|
|
10
|
+
return {
|
|
11
|
+
name: "source-module-urls",
|
|
12
|
+
setup(builder) {
|
|
13
|
+
builder.onLoad({ filter: /\.[cm]?[jt]s$/ }, async ({ path: file }) => {
|
|
14
|
+
const contents = await readFile(file, "utf8");
|
|
15
|
+
if (!/\bimport\s*\.\s*meta\b/.test(contents)) return;
|
|
16
|
+
const relative = "./" + path.relative(root, file).split(path.sep).map(encodeURIComponent).join("/");
|
|
17
|
+
const result = await transform(contents, {
|
|
18
|
+
loader: file.endsWith("ts") ? "ts" : "js",
|
|
19
|
+
format: "esm",
|
|
20
|
+
target: "node22",
|
|
21
|
+
define: { "import.meta.url": "__subagentSourceUrl" },
|
|
22
|
+
banner: `const __subagentSourceUrl = new URL(${JSON.stringify(relative)}, import.meta.url).href;`,
|
|
23
|
+
});
|
|
24
|
+
return { contents: result.code, loader: "js", resolveDir: path.dirname(file) };
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Bundle only local modules. Host SDK packages must be resolved by Pi's loader. */
|
|
31
|
+
export async function buildStartup({ root = packageRoot } = {}) {
|
|
32
|
+
root = path.resolve(root);
|
|
33
|
+
const result = await build({
|
|
34
|
+
absWorkingDir: root,
|
|
35
|
+
entryPoints: ["index.ts"],
|
|
36
|
+
outfile: "startup.js",
|
|
37
|
+
bundle: true,
|
|
38
|
+
packages: "external",
|
|
39
|
+
platform: "node",
|
|
40
|
+
format: "esm",
|
|
41
|
+
target: "node22",
|
|
42
|
+
metafile: true,
|
|
43
|
+
write: false,
|
|
44
|
+
plugins: [sourceUrls(root)],
|
|
45
|
+
banner: { js: "// Generated by npm run build. Edit the TypeScript sources, not this file." },
|
|
46
|
+
});
|
|
47
|
+
for (const input of Object.keys(result.metafile.inputs)) {
|
|
48
|
+
const relative = path.relative(root, path.resolve(root, input));
|
|
49
|
+
if (
|
|
50
|
+
relative.startsWith(".." + path.sep) ||
|
|
51
|
+
path.isAbsolute(relative) ||
|
|
52
|
+
relative.split(path.sep).includes("node_modules")
|
|
53
|
+
) {
|
|
54
|
+
throw new Error(`Startup bundles must contain only this package's source: ${input}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
await writeFile(path.join(root, "startup.js"), result.outputFiles[0].contents);
|
|
58
|
+
return result.metafile;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
62
|
+
const metadata = await buildStartup();
|
|
63
|
+
console.error(
|
|
64
|
+
`Built startup.js from ${Object.keys(metadata.inputs).length} local modules; package imports remain external.`,
|
|
65
|
+
);
|
|
66
|
+
}
|