codiedev 0.10.0-beta.5 → 0.10.0-beta.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 +4 -4
- package/dist/captureSignals.js +2 -0
- package/dist/cli.js +38 -50
- package/dist/codexHookTrust.js +67 -4
- package/dist/codie.js +23 -74
- package/dist/codieLauncher.js +18 -22
- package/dist/commands/agentTemplates.generated.js +136 -0
- package/dist/commands/agents.js +1068 -0
- package/dist/commands/agentsSdk.generated.js +7 -0
- package/dist/commands/doctor.js +12 -38
- package/dist/commands/evals.js +187 -0
- package/dist/commands/pack.js +1 -1
- package/dist/commands/traces.js +79 -15
- package/dist/commands/tracesLabel.js +348 -0
- package/dist/connect.js +11 -52
- package/dist/copilotHooks.js +0 -4
- package/dist/cursorHooks.js +0 -15
- package/dist/harnessDirs.js +4 -0
- package/dist/hook.js +33 -197
- package/dist/limitEventReporter.js +1 -1
- package/dist/managedPi.js +240 -0
- package/dist/mcp.js +0 -307
- package/dist/packs/harnesses.js +40 -3
- package/dist/packs/install.js +2 -1
- package/dist/piHooks.js +216 -0
- package/dist/piRuntime.js +120 -0
- package/dist/selfUpdate.js +47 -2
- package/dist/utils.js +232 -115
- package/package.json +5 -7
- package/dist/codieStartup.js +0 -27
- package/dist/commands/promote.js +0 -53
- package/dist/commands/react.js +0 -38
- package/dist/commands/reverseTicket.js +0 -444
- package/dist/commands/security.js +0 -156
- package/dist/prUrl.js +0 -28
- package/dist/security.js +0 -417
- package/dist/securityDeepScan.js +0 -235
- package/dist/securityDoctor.js +0 -61
- package/dist/securityFeature.js +0 -6
- package/dist/securityInstall.js +0 -232
- package/dist/securityInventory.js +0 -566
- package/dist/securityPilot.js +0 -59
- package/dist/securityPolicy.js +0 -181
- package/dist/securitySession.js +0 -72
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const child_process_1 = require("child_process");
|
|
43
|
+
const codieRuntimeInstall_1 = require("./codieRuntimeInstall");
|
|
44
|
+
exports.PI_PACKAGE = "@mariozechner/pi-coding-agent";
|
|
45
|
+
exports.PI_VERSION = "0.73.1";
|
|
46
|
+
exports.PI_RUNTIME_SPEC = `${exports.PI_PACKAGE}@${exports.PI_VERSION}`;
|
|
47
|
+
function piRuntimeDir(stateDir) {
|
|
48
|
+
return path.join(stateDir, "runtime-pi");
|
|
49
|
+
}
|
|
50
|
+
function packageDir(installDir) {
|
|
51
|
+
return path.join(installDir, "node_modules", ...exports.PI_PACKAGE.split("/"));
|
|
52
|
+
}
|
|
53
|
+
function installedPiEntry(installDir, readFile = (f) => fs.readFileSync(f, "utf8")) {
|
|
54
|
+
try {
|
|
55
|
+
const pkg = JSON.parse(readFile(path.join(packageDir(installDir), "package.json")));
|
|
56
|
+
if (pkg.version !== exports.PI_VERSION)
|
|
57
|
+
return null;
|
|
58
|
+
const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.pi;
|
|
59
|
+
return typeof bin === "string" ? path.join(packageDir(installDir), bin) : null;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const INSTALL_ATTEMPTS = 2;
|
|
66
|
+
const INSTALL_RETRY_DELAY_MS = 5_000;
|
|
67
|
+
function ensurePiRuntime(deps) {
|
|
68
|
+
const installDir = piRuntimeDir(deps.stateDir);
|
|
69
|
+
const exists = deps.exists ?? fs.existsSync;
|
|
70
|
+
const readFile = deps.readFile ?? ((f) => fs.readFileSync(f, "utf8"));
|
|
71
|
+
const ready = installedPiEntry(installDir, readFile);
|
|
72
|
+
if (ready && exists(ready))
|
|
73
|
+
return ready;
|
|
74
|
+
const remove = deps.remove ?? ((target) => fs.rmSync(target, { recursive: true, force: true }));
|
|
75
|
+
const rename = deps.rename ?? fs.renameSync;
|
|
76
|
+
const log = deps.log ?? ((message) => console.error(message));
|
|
77
|
+
const makeStagingDir = deps.makeStagingDir ?? (() => {
|
|
78
|
+
fs.mkdirSync(deps.stateDir, { recursive: true });
|
|
79
|
+
return fs.mkdtempSync(path.join(deps.stateDir, ".runtime-pi-"));
|
|
80
|
+
});
|
|
81
|
+
const run = deps.run ?? ((args) => {
|
|
82
|
+
const result = (0, child_process_1.spawnSync)(process.platform === "win32" ? "npm.cmd" : "npm", args, {
|
|
83
|
+
encoding: "utf8", stdio: ["ignore", "ignore", "pipe"], shell: process.platform === "win32",
|
|
84
|
+
});
|
|
85
|
+
if (result.error)
|
|
86
|
+
throw result.error;
|
|
87
|
+
return { status: result.status, stderr: result.stderr ?? "" };
|
|
88
|
+
});
|
|
89
|
+
const sleep = deps.sleep ?? ((ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms));
|
|
90
|
+
log(`Installing pi (${exports.PI_RUNTIME_SPEC}). This runs once, and only for \`codie --pi\`.`);
|
|
91
|
+
for (let attempt = 1;; attempt++) {
|
|
92
|
+
const staging = makeStagingDir();
|
|
93
|
+
try {
|
|
94
|
+
const result = run((0, codieRuntimeInstall_1.buildRuntimeInstallArgs)(staging, exports.PI_RUNTIME_SPEC));
|
|
95
|
+
if (result.status !== 0)
|
|
96
|
+
throw new Error(result.stderr?.trim() || `npm exited with ${result.status}`);
|
|
97
|
+
const staged = installedPiEntry(staging, readFile);
|
|
98
|
+
if (!staged || !exists(staged)) {
|
|
99
|
+
throw new Error(`the install did not produce pi. Check that ${exports.PI_RUNTIME_SPEC} is available from your npm registry.`);
|
|
100
|
+
}
|
|
101
|
+
remove(installDir);
|
|
102
|
+
rename(staging, installDir);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
107
|
+
if (attempt >= INSTALL_ATTEMPTS)
|
|
108
|
+
throw new Error(`Couldn't install pi: ${message}`);
|
|
109
|
+
log(`pi install failed (${message.split("\n")[0]}); retrying.`);
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
remove(staging);
|
|
113
|
+
}
|
|
114
|
+
sleep(INSTALL_RETRY_DELAY_MS);
|
|
115
|
+
}
|
|
116
|
+
const entry = installedPiEntry(installDir, readFile);
|
|
117
|
+
if (!entry)
|
|
118
|
+
throw new Error("Couldn't install pi: the installed package has no CLI entry.");
|
|
119
|
+
return entry;
|
|
120
|
+
}
|
package/dist/selfUpdate.js
CHANGED
|
@@ -33,10 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.BIN_NAMES = void 0;
|
|
36
37
|
exports.planSelfUpdate = planSelfUpdate;
|
|
37
38
|
exports.isSelfUpdateDue = isSelfUpdateDue;
|
|
38
39
|
exports.readSelfUpdateState = readSelfUpdateState;
|
|
39
40
|
exports.maybeSpawnSelfUpdate = maybeSpawnSelfUpdate;
|
|
41
|
+
exports.maybeRefreshInstructions = maybeRefreshInstructions;
|
|
42
|
+
exports.missingPs1Shims = missingPs1Shims;
|
|
40
43
|
exports.findInstalledHookScript = findInstalledHookScript;
|
|
41
44
|
exports.runSelfUpdate = runSelfUpdate;
|
|
42
45
|
const fs = __importStar(require("fs"));
|
|
@@ -47,8 +50,9 @@ const versionCheck_1 = require("./versionCheck");
|
|
|
47
50
|
const configDir_1 = require("./configDir");
|
|
48
51
|
const captureLog_1 = require("./captureLog");
|
|
49
52
|
const launcher_1 = require("./launcher");
|
|
53
|
+
const utils_1 = require("./utils");
|
|
50
54
|
const PKG = "codiedev";
|
|
51
|
-
const
|
|
55
|
+
const SELF_UPDATE_INTERVAL_MS = 2 * 60 * 60 * 1000;
|
|
52
56
|
const LOCK_STALE_MS = 10 * 60 * 1000;
|
|
53
57
|
const INSTALL_TIMEOUT_MS = 5 * 60 * 1000;
|
|
54
58
|
const FETCH_TIMEOUT_MS = 5_000;
|
|
@@ -82,7 +86,7 @@ function planSelfUpdate(deps) {
|
|
|
82
86
|
return { kind: "skip", reason: "unmanaged" };
|
|
83
87
|
}
|
|
84
88
|
function isSelfUpdateDue(state, nowMs) {
|
|
85
|
-
return !state || nowMs - state.lastAttemptAt >
|
|
89
|
+
return !state || nowMs - state.lastAttemptAt > SELF_UPDATE_INTERVAL_MS;
|
|
86
90
|
}
|
|
87
91
|
function statePath() {
|
|
88
92
|
return path.join((0, configDir_1.codiedevStateDir)(), ".self-update.json");
|
|
@@ -128,6 +132,35 @@ function maybeSpawnSelfUpdate(hookEntry) {
|
|
|
128
132
|
catch {
|
|
129
133
|
}
|
|
130
134
|
}
|
|
135
|
+
function instructionsVersionPath() {
|
|
136
|
+
return path.join((0, configDir_1.codiedevStateDir)(), ".instructions-version");
|
|
137
|
+
}
|
|
138
|
+
function maybeRefreshInstructions(refresh = utils_1.refreshInstalledInstructions) {
|
|
139
|
+
if (process.env.CODIEDEV_NO_AUTO_UPDATE || process.env.CODIEDEV_NO_UPDATE_CHECK)
|
|
140
|
+
return;
|
|
141
|
+
try {
|
|
142
|
+
const marker = instructionsVersionPath();
|
|
143
|
+
try {
|
|
144
|
+
if (fs.readFileSync(marker, "utf8").trim() === version_1.CLI_VERSION)
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
}
|
|
149
|
+
const refreshed = refresh();
|
|
150
|
+
fs.mkdirSync((0, configDir_1.codiedevStateDir)(), { recursive: true });
|
|
151
|
+
fs.writeFileSync(marker, version_1.CLI_VERSION, "utf8");
|
|
152
|
+
if (refreshed.length > 0) {
|
|
153
|
+
(0, captureLog_1.appendCaptureLog)({
|
|
154
|
+
stage: "self-update",
|
|
155
|
+
sessionId: undefined,
|
|
156
|
+
outcome: "ok",
|
|
157
|
+
detail: `result=instructions-refreshed version=${version_1.CLI_VERSION} files=${refreshed.length}`,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
}
|
|
163
|
+
}
|
|
131
164
|
function acquireLock() {
|
|
132
165
|
const lock = lockPath();
|
|
133
166
|
try {
|
|
@@ -207,6 +240,10 @@ function installCommand(plan, version, env) {
|
|
|
207
240
|
return null;
|
|
208
241
|
}
|
|
209
242
|
}
|
|
243
|
+
exports.BIN_NAMES = ["codiedev", "codiedev-hook", "codie"];
|
|
244
|
+
function missingPs1Shims(prefix, exists = fs.existsSync) {
|
|
245
|
+
return exports.BIN_NAMES.map((name) => path.join(prefix, `${name}.ps1`)).filter((p) => !exists(p));
|
|
246
|
+
}
|
|
210
247
|
function readVersionAt(hookScript) {
|
|
211
248
|
try {
|
|
212
249
|
const pkg = JSON.parse(fs.readFileSync(path.join(path.dirname(path.dirname(hookScript)), "package.json"), "utf8"));
|
|
@@ -303,6 +340,7 @@ async function runSelfUpdate(hookEntry) {
|
|
|
303
340
|
const install = installCommand(plan, latest, env);
|
|
304
341
|
if (!install)
|
|
305
342
|
return finish("skip:no-installer");
|
|
343
|
+
const droppedShims = plan.kind === "npm" && process.platform === "win32" ? missingPs1Shims(plan.prefix) : [];
|
|
306
344
|
const result = (0, child_process_1.spawnSync)(install.cmd, install.args, {
|
|
307
345
|
stdio: "ignore",
|
|
308
346
|
timeout: INSTALL_TIMEOUT_MS,
|
|
@@ -313,6 +351,13 @@ async function runSelfUpdate(hookEntry) {
|
|
|
313
351
|
if (result.error || result.status !== 0) {
|
|
314
352
|
return finish(`error:install-exit-${result.status ?? "spawn"}`, { toVersion: latest });
|
|
315
353
|
}
|
|
354
|
+
for (const shim of droppedShims) {
|
|
355
|
+
try {
|
|
356
|
+
fs.rmSync(shim, { force: true });
|
|
357
|
+
}
|
|
358
|
+
catch {
|
|
359
|
+
}
|
|
360
|
+
}
|
|
316
361
|
const installed = findInstalledHookScript(plan, hookScriptReal, latest);
|
|
317
362
|
if (!installed) {
|
|
318
363
|
return finish("error:not-found-after-install", { toVersion: latest });
|