codiedev 0.9.71 → 0.9.72
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/dist/managedPi.d.ts +2 -1
- package/dist/managedPi.js +11 -7
- package/dist/piRuntime.d.ts +25 -0
- package/dist/piRuntime.js +125 -0
- package/package.json +1 -1
package/dist/managedPi.d.ts
CHANGED
package/dist/managedPi.js
CHANGED
|
@@ -66,6 +66,7 @@ const child_process_1 = require("child_process");
|
|
|
66
66
|
const fs = __importStar(require("fs"));
|
|
67
67
|
const path = __importStar(require("path"));
|
|
68
68
|
const codieLauncher_1 = require("./codieLauncher");
|
|
69
|
+
const piRuntime_1 = require("./piRuntime");
|
|
69
70
|
const utils_1 = require("./utils");
|
|
70
71
|
exports.PI_PROVIDER_ID = "codiedev";
|
|
71
72
|
/** Env vars pi reads provider credentials from (`pi --help`, pi 0.73). */
|
|
@@ -268,16 +269,19 @@ function runManagedPi(opts) {
|
|
|
268
269
|
skillPaths: opts.skillPaths, agentSecurityEnabled: opts.agentSecurityEnabled,
|
|
269
270
|
});
|
|
270
271
|
const args = managedPiArgs(opts.args, extensions);
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
// CODIEDEV_PI_BIN runs a specific pi binary (tests, canaries pinned to a
|
|
273
|
+
// version). Otherwise pi is Codiedev's own pinned install, fetched on first
|
|
274
|
+
// use like the Codie engine and run on this Node.
|
|
275
|
+
const bin = env.CODIEDEV_PI_BIN?.trim();
|
|
276
|
+
const [command, commandArgs] = bin
|
|
277
|
+
? [bin, args]
|
|
278
|
+
: [process.execPath, [(opts.resolvePi ?? (() => (0, piRuntime_1.ensurePiRuntime)({ stateDir: opts.stateDir })))(), ...args]];
|
|
279
|
+
const result = (0, child_process_1.spawnSync)(command, commandArgs, {
|
|
273
280
|
stdio: "inherit",
|
|
274
281
|
env: managedPiEnv(env, agentDir, opts.key),
|
|
275
|
-
// pi
|
|
276
|
-
shell: process.platform === "win32",
|
|
282
|
+
// A pi binary given as an npm launcher is a .cmd shim on Windows.
|
|
283
|
+
shell: Boolean(bin) && process.platform === "win32",
|
|
277
284
|
});
|
|
278
|
-
if (result.error && result.error.code === "ENOENT") {
|
|
279
|
-
throw new Error("pi isn't installed. Install it with `npm install -g @mariozechner/pi-coding-agent`, then run `codie --pi` again.");
|
|
280
|
-
}
|
|
281
285
|
if (result.error)
|
|
282
286
|
throw result.error;
|
|
283
287
|
return result.status === null ? 1 : result.status;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const PI_PACKAGE = "@mariozechner/pi-coding-agent";
|
|
2
|
+
export declare const PI_VERSION = "0.73.1";
|
|
3
|
+
export declare const PI_RUNTIME_SPEC = "@mariozechner/pi-coding-agent@0.73.1";
|
|
4
|
+
export declare function piRuntimeDir(stateDir: string): string;
|
|
5
|
+
/** The installed pi's CLI entry, when it is the pinned version. */
|
|
6
|
+
export declare function installedPiEntry(installDir: string, readFile?: (file: string) => string): string | null;
|
|
7
|
+
export interface PiRuntimeDeps {
|
|
8
|
+
stateDir: string;
|
|
9
|
+
exists?: (file: string) => boolean;
|
|
10
|
+
readFile?: (file: string) => string;
|
|
11
|
+
makeStagingDir?: () => string;
|
|
12
|
+
run?: (args: string[]) => {
|
|
13
|
+
status: number | null;
|
|
14
|
+
stderr: string;
|
|
15
|
+
};
|
|
16
|
+
rename?: (from: string, to: string) => void;
|
|
17
|
+
remove?: (target: string) => void;
|
|
18
|
+
log?: (message: string) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The pi CLI entry to run, installing the pinned version first if it is
|
|
22
|
+
* missing or a different version. Staged then renamed, so an interrupted
|
|
23
|
+
* download never leaves a half-installed pi that looks ready.
|
|
24
|
+
*/
|
|
25
|
+
export declare function ensurePiRuntime(deps: PiRuntimeDeps): string;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PI_RUNTIME_SPEC = exports.PI_VERSION = exports.PI_PACKAGE = void 0;
|
|
37
|
+
exports.piRuntimeDir = piRuntimeDir;
|
|
38
|
+
exports.installedPiEntry = installedPiEntry;
|
|
39
|
+
exports.ensurePiRuntime = ensurePiRuntime;
|
|
40
|
+
// pi for `codie --pi`, installed on first use like the Codie engine
|
|
41
|
+
// (codieRuntimeInstall.ts): developers never run a second npm install, and
|
|
42
|
+
// every machine runs the version Codiedev tested its capture against.
|
|
43
|
+
//
|
|
44
|
+
// pi is plain JavaScript, so it runs on the same Node as `codie` from its
|
|
45
|
+
// package entry: no PATH lookup, no Windows .cmd shim, and no dependency on
|
|
46
|
+
// whatever `pi` (if any) the developer installed globally.
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const child_process_1 = require("child_process");
|
|
50
|
+
const codieRuntimeInstall_1 = require("./codieRuntimeInstall");
|
|
51
|
+
exports.PI_PACKAGE = "@mariozechner/pi-coding-agent";
|
|
52
|
+
exports.PI_VERSION = "0.73.1";
|
|
53
|
+
exports.PI_RUNTIME_SPEC = `${exports.PI_PACKAGE}@${exports.PI_VERSION}`;
|
|
54
|
+
function piRuntimeDir(stateDir) {
|
|
55
|
+
return path.join(stateDir, "runtime-pi");
|
|
56
|
+
}
|
|
57
|
+
function packageDir(installDir) {
|
|
58
|
+
return path.join(installDir, "node_modules", ...exports.PI_PACKAGE.split("/"));
|
|
59
|
+
}
|
|
60
|
+
/** The installed pi's CLI entry, when it is the pinned version. */
|
|
61
|
+
function installedPiEntry(installDir, readFile = (f) => fs.readFileSync(f, "utf8")) {
|
|
62
|
+
try {
|
|
63
|
+
const pkg = JSON.parse(readFile(path.join(packageDir(installDir), "package.json")));
|
|
64
|
+
if (pkg.version !== exports.PI_VERSION)
|
|
65
|
+
return null;
|
|
66
|
+
const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.pi;
|
|
67
|
+
return typeof bin === "string" ? path.join(packageDir(installDir), bin) : null;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The pi CLI entry to run, installing the pinned version first if it is
|
|
75
|
+
* missing or a different version. Staged then renamed, so an interrupted
|
|
76
|
+
* download never leaves a half-installed pi that looks ready.
|
|
77
|
+
*/
|
|
78
|
+
function ensurePiRuntime(deps) {
|
|
79
|
+
const installDir = piRuntimeDir(deps.stateDir);
|
|
80
|
+
const exists = deps.exists ?? fs.existsSync;
|
|
81
|
+
const readFile = deps.readFile ?? ((f) => fs.readFileSync(f, "utf8"));
|
|
82
|
+
const ready = installedPiEntry(installDir, readFile);
|
|
83
|
+
if (ready && exists(ready))
|
|
84
|
+
return ready;
|
|
85
|
+
const remove = deps.remove ?? ((target) => fs.rmSync(target, { recursive: true, force: true }));
|
|
86
|
+
const rename = deps.rename ?? fs.renameSync;
|
|
87
|
+
const log = deps.log ?? ((message) => console.error(message));
|
|
88
|
+
const staging = (deps.makeStagingDir ?? (() => {
|
|
89
|
+
fs.mkdirSync(deps.stateDir, { recursive: true });
|
|
90
|
+
return fs.mkdtempSync(path.join(deps.stateDir, ".runtime-pi-"));
|
|
91
|
+
}))();
|
|
92
|
+
const run = deps.run ?? ((args) => {
|
|
93
|
+
const result = (0, child_process_1.spawnSync)(process.platform === "win32" ? "npm.cmd" : "npm", args, {
|
|
94
|
+
encoding: "utf8", stdio: ["ignore", "ignore", "pipe"], shell: process.platform === "win32",
|
|
95
|
+
});
|
|
96
|
+
if (result.error)
|
|
97
|
+
throw result.error;
|
|
98
|
+
return { status: result.status, stderr: result.stderr ?? "" };
|
|
99
|
+
});
|
|
100
|
+
log(`Installing pi (${exports.PI_RUNTIME_SPEC}). This runs once, and only for \`codie --pi\`.`);
|
|
101
|
+
try {
|
|
102
|
+
const result = run((0, codieRuntimeInstall_1.buildRuntimeInstallArgs)(staging, exports.PI_RUNTIME_SPEC));
|
|
103
|
+
if (result.status !== 0)
|
|
104
|
+
throw new Error(result.stderr?.trim() || `npm exited with ${result.status}`);
|
|
105
|
+
// Trust the artifact, not the exit code.
|
|
106
|
+
const staged = installedPiEntry(staging, readFile);
|
|
107
|
+
if (!staged || !exists(staged)) {
|
|
108
|
+
throw new Error(`the install did not produce pi. Check that ${exports.PI_RUNTIME_SPEC} is available from your npm registry.`);
|
|
109
|
+
}
|
|
110
|
+
remove(installDir);
|
|
111
|
+
rename(staging, installDir);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
throw new Error(`Couldn't install pi: ${error instanceof Error ? error.message : String(error)}`);
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
// No-op after a successful promote; otherwise it keeps a ~200MB staging
|
|
118
|
+
// dir from being orphaned.
|
|
119
|
+
remove(staging);
|
|
120
|
+
}
|
|
121
|
+
const entry = installedPiEntry(installDir, readFile);
|
|
122
|
+
if (!entry)
|
|
123
|
+
throw new Error("Couldn't install pi: the installed package has no CLI entry.");
|
|
124
|
+
return entry;
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codiedev",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.72",
|
|
4
4
|
"description": "Connect Claude Code, Codex, Cursor, OpenCode, or VS Code Copilot to Codiedev for team session capture and artifact collaboration — and run the governed Codie harness",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codiedev": "dist/cli.js",
|