@vzlentin/harness 0.2.0 → 0.2.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/README.md +0 -5
- package/dist/setup.d.ts +4 -5
- package/dist/setup.js +7 -39
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -24,11 +24,6 @@ pi install "$(realpath "$(npm root -g)/@vzlentin/harness/pi")"
|
|
|
24
24
|
|
|
25
25
|
When you install with `--prefix`, give the same `--prefix` to `npm root -g`.
|
|
26
26
|
|
|
27
|
-
### Move from 0.1.0
|
|
28
|
-
|
|
29
|
-
0.1.0 had the extension in the separate Pi package `@vzlentin/pi-subagent`. Update as below: the setup removes that
|
|
30
|
-
package from Pi (`pi remove npm:@vzlentin/pi-subagent`), since it conflicts with the new extension.
|
|
31
|
-
|
|
32
27
|
### Update and remove
|
|
33
28
|
|
|
34
29
|
```sh
|
package/dist/setup.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Registers `<packageDir>/pi` in Pi when `packageDir` is a top-level global npm install.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* on PATH it writes the stamp, so a user without Pi gets the hint once per version.
|
|
2
|
+
* Registers `<packageDir>/pi` in Pi when `packageDir` is a top-level global npm install. It writes its messages to
|
|
3
|
+
* stderr, and it does not throw for a Pi failure: it writes a warning with the command to run. It writes the stamp
|
|
4
|
+
* that `setupOnce` reads unless `pi` failed, so the next run tries again. Without `pi` on PATH it writes the stamp, so
|
|
5
|
+
* a user without Pi gets the hint once per version.
|
|
7
6
|
*/
|
|
8
7
|
export declare function setup(packageDir: string): void;
|
|
9
8
|
/**
|
package/dist/setup.js
CHANGED
|
@@ -9,20 +9,12 @@ import { homedir } from "node:os";
|
|
|
9
9
|
import { basename, delimiter, dirname, join, sep } from "node:path";
|
|
10
10
|
import { Type } from "typebox";
|
|
11
11
|
import { Value } from "typebox/value";
|
|
12
|
-
const PackageJson = Type.Object({
|
|
13
|
-
name: Type.String(),
|
|
14
|
-
version: Type.String(),
|
|
15
|
-
retiredPiPackages: Type.Optional(Type.Array(Type.String())),
|
|
16
|
-
});
|
|
17
|
-
const PiSettings = Type.Object({
|
|
18
|
-
packages: Type.Optional(Type.Array(Type.Union([Type.String(), Type.Object({ source: Type.String() })]))),
|
|
19
|
-
});
|
|
12
|
+
const PackageJson = Type.Object({ name: Type.String(), version: Type.String() });
|
|
20
13
|
/**
|
|
21
|
-
* Registers `<packageDir>/pi` in Pi when `packageDir` is a top-level global npm install.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* on PATH it writes the stamp, so a user without Pi gets the hint once per version.
|
|
14
|
+
* Registers `<packageDir>/pi` in Pi when `packageDir` is a top-level global npm install. It writes its messages to
|
|
15
|
+
* stderr, and it does not throw for a Pi failure: it writes a warning with the command to run. It writes the stamp
|
|
16
|
+
* that `setupOnce` reads unless `pi` failed, so the next run tries again. Without `pi` on PATH it writes the stamp, so
|
|
17
|
+
* a user without Pi gets the hint once per version.
|
|
26
18
|
*/
|
|
27
19
|
export function setup(packageDir) {
|
|
28
20
|
const installed = readInstalled(packageDir);
|
|
@@ -76,20 +68,11 @@ function writeStamp(installed) {
|
|
|
76
68
|
mkdirSync(dirname(path), { recursive: true });
|
|
77
69
|
writeFileSync(path, `${installed.dir}\n${installed.json.version}\n`);
|
|
78
70
|
}
|
|
79
|
-
/** False when
|
|
71
|
+
/** False when `pi install` failed. */
|
|
80
72
|
function registerExtension({ dir, json }) {
|
|
81
73
|
const label = basename(json.name);
|
|
82
74
|
const extension = join(dir, "pi");
|
|
83
|
-
|
|
84
|
-
const listed = piPackages();
|
|
85
|
-
for (const retired of json.retiredPiPackages ?? []) {
|
|
86
|
-
for (const source of listed.filter((item) => item === retired || item.startsWith(`${retired}@`))) {
|
|
87
|
-
process.stderr.write(`${label}: removing ${source} from Pi, which ${json.name} replaces\n`);
|
|
88
|
-
if (!runPi(label, ["remove", source], `To remove it, run: pi remove ${source}`))
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return runPi(label, ["install", extension], later);
|
|
75
|
+
return runPi(label, ["install", extension], `To add the Pi extension of ${label}, run: pi install ${extension}`);
|
|
93
76
|
}
|
|
94
77
|
/** Runs `pi`, with a warning when it is missing or fails. False when it failed; true when it worked or is missing. */
|
|
95
78
|
function runPi(label, args, later) {
|
|
@@ -116,18 +99,3 @@ function userPath() {
|
|
|
116
99
|
.filter((entry) => !entry.endsWith(join("node_modules", ".bin")))
|
|
117
100
|
.join(delimiter);
|
|
118
101
|
}
|
|
119
|
-
/** The sources of the packages in Pi's global settings, or none when the file is missing or not valid. */
|
|
120
|
-
function piPackages() {
|
|
121
|
-
const env = process.env.PI_CODING_AGENT_DIR;
|
|
122
|
-
const agentDir = env ? env.replace(/^~(?=$|\/)/, homedir()) : join(homedir(), ".pi", "agent");
|
|
123
|
-
let settings;
|
|
124
|
-
try {
|
|
125
|
-
settings = JSON.parse(readFileSync(join(agentDir, "settings.json"), "utf8"));
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
return [];
|
|
129
|
-
}
|
|
130
|
-
if (!Value.Check(PiSettings, settings))
|
|
131
|
-
return [];
|
|
132
|
-
return (settings.packages ?? []).map((item) => (Value.Check(Type.String(), item) ? item : item.source));
|
|
133
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vzlentin/harness",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A durable agent harness on Pi, starting with observable, persistent subagents",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,9 +49,6 @@
|
|
|
49
49
|
"typescript": "7.0.2",
|
|
50
50
|
"vitest": "5.0.3"
|
|
51
51
|
},
|
|
52
|
-
"retiredPiPackages": [
|
|
53
|
-
"npm:@vzlentin/pi-subagent"
|
|
54
|
-
],
|
|
55
52
|
"publishConfig": {
|
|
56
53
|
"access": "public"
|
|
57
54
|
}
|