codiedev 0.10.0-beta.4 → 0.10.0-beta.6

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.
Files changed (157) hide show
  1. package/README.md +11 -5
  2. package/assets/tui-brand-plugin.tsx +14 -2
  3. package/dist/backup/cache.js +1 -5
  4. package/dist/backup/match.js +0 -6
  5. package/dist/backup/run.js +3 -35
  6. package/dist/captureExclusions.js +0 -12
  7. package/dist/captureLog.js +0 -28
  8. package/dist/captureReadiness.js +0 -58
  9. package/dist/captureSignals.js +68 -3
  10. package/dist/cli.js +75 -64
  11. package/dist/codexHookTrust.js +125 -6
  12. package/dist/codexLimitScan.js +2 -109
  13. package/dist/codie.js +50 -114
  14. package/dist/codieBrandInstall.js +0 -18
  15. package/dist/codieLauncher.js +20 -92
  16. package/dist/codieRuntime.js +19 -23
  17. package/dist/codieRuntimeInstall.js +108 -23
  18. package/dist/codieUsage.js +38 -41
  19. package/dist/commands/agentTemplates.generated.js +136 -0
  20. package/dist/commands/agents.js +1066 -0
  21. package/dist/commands/agentsSdk.generated.js +7 -0
  22. package/dist/commands/ask.js +0 -3
  23. package/dist/commands/capture.js +0 -2
  24. package/dist/commands/createTicket.js +0 -10
  25. package/dist/commands/doctor.js +53 -120
  26. package/dist/commands/evals.js +187 -0
  27. package/dist/commands/inbox.js +0 -2
  28. package/dist/commands/library.js +0 -3
  29. package/dist/commands/pack.js +573 -0
  30. package/dist/commands/ping.js +0 -2
  31. package/dist/commands/pull.js +6 -10
  32. package/dist/commands/push.js +2 -12
  33. package/dist/commands/search.js +0 -4
  34. package/dist/commands/send.js +0 -5
  35. package/dist/commands/share.js +0 -4
  36. package/dist/commands/shared.js +0 -35
  37. package/dist/commands/traces.js +344 -0
  38. package/dist/commands/tracesLabel.js +348 -0
  39. package/dist/configDir.js +0 -10
  40. package/dist/connect.js +19 -116
  41. package/dist/connectFlow.js +0 -9
  42. package/dist/copilotHooks.js +391 -0
  43. package/dist/copilotInstallation.js +64 -0
  44. package/dist/cursorHooks.js +38 -30
  45. package/dist/cursorLifecycle.js +109 -0
  46. package/dist/detection.js +0 -30
  47. package/dist/harnessDirs.js +77 -0
  48. package/dist/hook.js +182 -469
  49. package/dist/inboxFormat.js +0 -24
  50. package/dist/launchContext.js +150 -0
  51. package/dist/launcher.js +140 -0
  52. package/dist/limitEvent.js +41 -35
  53. package/dist/limitEventReporter.js +1 -1
  54. package/dist/managedPi.js +240 -0
  55. package/dist/mcp.js +3 -384
  56. package/dist/nativeSteering.js +24 -0
  57. package/dist/packs/codie.js +182 -0
  58. package/dist/packs/harnesses.js +411 -0
  59. package/dist/packs/hookGate.js +256 -0
  60. package/dist/packs/install.js +286 -0
  61. package/dist/packs/manifest.js +126 -0
  62. package/dist/packs/paths.js +81 -0
  63. package/dist/packs/shim.js +214 -0
  64. package/dist/packs/store.js +155 -0
  65. package/dist/packs/sync.js +170 -0
  66. package/dist/piHooks.js +216 -0
  67. package/dist/piRuntime.js +120 -0
  68. package/dist/repoResolver.js +0 -19
  69. package/dist/secret.js +0 -3
  70. package/dist/selfUpdate.js +376 -0
  71. package/dist/skillMarker.js +23 -0
  72. package/dist/subagents.js +135 -0
  73. package/dist/teamSkillContext.js +10 -0
  74. package/dist/transcriptModels.js +6 -8
  75. package/dist/upgradeNudge.js +0 -30
  76. package/dist/utils.js +494 -824
  77. package/dist/version.js +0 -10
  78. package/dist/versionCheck.js +0 -33
  79. package/package.json +8 -9
  80. package/dist/backup/cache.d.ts +0 -14
  81. package/dist/backup/match.d.ts +0 -2
  82. package/dist/backup/run.d.ts +0 -25
  83. package/dist/captureExclusions.d.ts +0 -30
  84. package/dist/captureLog.d.ts +0 -20
  85. package/dist/captureReadiness.d.ts +0 -65
  86. package/dist/captureSignals.d.ts +0 -19
  87. package/dist/cli.d.ts +0 -16
  88. package/dist/codexHookTrust.d.ts +0 -34
  89. package/dist/codexLimitScan.d.ts +0 -64
  90. package/dist/codie.d.ts +0 -2
  91. package/dist/codieBrandInstall.d.ts +0 -11
  92. package/dist/codieLauncher.d.ts +0 -86
  93. package/dist/codieRuntime.d.ts +0 -29
  94. package/dist/codieRuntimeInstall.d.ts +0 -28
  95. package/dist/codieStartup.d.ts +0 -26
  96. package/dist/codieStartup.js +0 -30
  97. package/dist/codieUsage.d.ts +0 -57
  98. package/dist/commands/ask.d.ts +0 -1
  99. package/dist/commands/capture.d.ts +0 -14
  100. package/dist/commands/createTicket.d.ts +0 -27
  101. package/dist/commands/delete.d.ts +0 -1
  102. package/dist/commands/doctor.d.ts +0 -1
  103. package/dist/commands/inbox.d.ts +0 -3
  104. package/dist/commands/library.d.ts +0 -2
  105. package/dist/commands/note.d.ts +0 -1
  106. package/dist/commands/ping.d.ts +0 -1
  107. package/dist/commands/promote.d.ts +0 -1
  108. package/dist/commands/promote.js +0 -53
  109. package/dist/commands/pull.d.ts +0 -2
  110. package/dist/commands/push.d.ts +0 -33
  111. package/dist/commands/react.d.ts +0 -2
  112. package/dist/commands/react.js +0 -40
  113. package/dist/commands/reverseTicket.d.ts +0 -2
  114. package/dist/commands/reverseTicket.js +0 -477
  115. package/dist/commands/search.d.ts +0 -2
  116. package/dist/commands/security.d.ts +0 -1
  117. package/dist/commands/security.js +0 -156
  118. package/dist/commands/send.d.ts +0 -2
  119. package/dist/commands/share.d.ts +0 -2
  120. package/dist/commands/shared.d.ts +0 -64
  121. package/dist/configDir.d.ts +0 -1
  122. package/dist/connect.d.ts +0 -1
  123. package/dist/connectFlow.d.ts +0 -13
  124. package/dist/cursorHooks.d.ts +0 -23
  125. package/dist/detection.d.ts +0 -30
  126. package/dist/hook.d.ts +0 -6
  127. package/dist/inboxFormat.d.ts +0 -38
  128. package/dist/limitEvent.d.ts +0 -16
  129. package/dist/limitEventReporter.d.ts +0 -21
  130. package/dist/mcp.d.ts +0 -12
  131. package/dist/prUrl.d.ts +0 -9
  132. package/dist/prUrl.js +0 -33
  133. package/dist/repoResolver.d.ts +0 -17
  134. package/dist/secret.d.ts +0 -1
  135. package/dist/security.d.ts +0 -102
  136. package/dist/security.js +0 -437
  137. package/dist/securityDeepScan.d.ts +0 -41
  138. package/dist/securityDeepScan.js +0 -248
  139. package/dist/securityDoctor.d.ts +0 -32
  140. package/dist/securityDoctor.js +0 -63
  141. package/dist/securityFeature.d.ts +0 -5
  142. package/dist/securityFeature.js +0 -7
  143. package/dist/securityInstall.d.ts +0 -63
  144. package/dist/securityInstall.js +0 -239
  145. package/dist/securityInventory.d.ts +0 -54
  146. package/dist/securityInventory.js +0 -556
  147. package/dist/securityPilot.d.ts +0 -19
  148. package/dist/securityPilot.js +0 -61
  149. package/dist/securityPolicy.d.ts +0 -33
  150. package/dist/securityPolicy.js +0 -188
  151. package/dist/securitySession.d.ts +0 -6
  152. package/dist/securitySession.js +0 -72
  153. package/dist/transcriptModels.d.ts +0 -18
  154. package/dist/upgradeNudge.d.ts +0 -25
  155. package/dist/utils.d.ts +0 -346
  156. package/dist/version.d.ts +0 -1
  157. package/dist/versionCheck.d.ts +0 -68
@@ -0,0 +1,240 @@
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.ManagedPiArgError = exports.GUARD_SOURCE = exports.BLOCKED_BASE_URL = exports.CAPTURE_FILE = exports.GUARD_FILE = exports.PI_PROVIDER_ENV = exports.PI_PROVIDER_ID = void 0;
37
+ exports.managedPiAgentDir = managedPiAgentDir;
38
+ exports.piProviderConfig = piProviderConfig;
39
+ exports.prepareManagedPiDir = prepareManagedPiDir;
40
+ exports.managedPiEnv = managedPiEnv;
41
+ exports.managedPiArgs = managedPiArgs;
42
+ exports.runManagedPi = runManagedPi;
43
+ const child_process_1 = require("child_process");
44
+ const fs = __importStar(require("fs"));
45
+ const path = __importStar(require("path"));
46
+ const codieLauncher_1 = require("./codieLauncher");
47
+ const piRuntime_1 = require("./piRuntime");
48
+ const utils_1 = require("./utils");
49
+ exports.PI_PROVIDER_ID = "codiedev";
50
+ exports.PI_PROVIDER_ENV = [
51
+ "ANTHROPIC_API_KEY", "ANTHROPIC_OAUTH_TOKEN", "OPENAI_API_KEY", "AZURE_OPENAI_API_KEY",
52
+ "AZURE_OPENAI_BASE_URL", "AZURE_OPENAI_RESOURCE_NAME", "DEEPSEEK_API_KEY", "GEMINI_API_KEY",
53
+ "GROQ_API_KEY", "CEREBRAS_API_KEY", "XAI_API_KEY", "FIREWORKS_API_KEY", "OPENROUTER_API_KEY",
54
+ "AI_GATEWAY_API_KEY", "ZAI_API_KEY", "MISTRAL_API_KEY", "MINIMAX_API_KEY", "MOONSHOT_API_KEY",
55
+ "OPENCODE_API_KEY", "KIMI_API_KEY", "CLOUDFLARE_API_KEY", "XIAOMI_API_KEY",
56
+ "XIAOMI_TOKEN_PLAN_CN_API_KEY", "XIAOMI_TOKEN_PLAN_AMS_API_KEY", "XIAOMI_TOKEN_PLAN_SGP_API_KEY",
57
+ "AWS_PROFILE", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN",
58
+ "AWS_BEARER_TOKEN_BEDROCK", "GOOGLE_APPLICATION_CREDENTIALS", "GOOGLE_CLOUD_API_KEY",
59
+ "COPILOT_GITHUB_TOKEN",
60
+ ];
61
+ const BLOCKED_SUBCOMMANDS = new Set(["install", "remove", "uninstall", "config"]);
62
+ exports.GUARD_FILE = "codie-guard.ts";
63
+ exports.CAPTURE_FILE = "codiedev-capture.ts";
64
+ exports.BLOCKED_BASE_URL = "http://127.0.0.1:9/blocked-by-codiedev";
65
+ exports.GUARD_SOURCE = `// Written by Codiedev on every \`codie --pi\` launch. Edits are overwritten.
66
+ import { execFileSync } from "node:child_process";
67
+ import { getProviders } from "@mariozechner/pi-ai";
68
+
69
+ const PROVIDER = ${JSON.stringify(exports.PI_PROVIDER_ID)};
70
+ const BLOCKED = ${JSON.stringify(exports.BLOCKED_BASE_URL)};
71
+ const ours = (m) => Boolean(m && m.provider === PROVIDER);
72
+ const label = (m) => (m ? m.provider + "/" + m.id : "that model");
73
+ // pi runs a header value starting with "!" as a shell command, so no value
74
+ // may start with one; branch and skill names are user-controlled.
75
+ const clean = (v, max) => String(v ?? "").replace(/[\\r\\n]/g, "").trim().replace(/^!+/, "").slice(0, max);
76
+ const git = (cwd, args) => { try { return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 1500 }).trim(); } catch { return ""; } };
77
+
78
+ export default function (pi) {
79
+ for (const p of getProviders()) if (p !== PROVIDER) pi.registerProvider(p, { baseUrl: BLOCKED });
80
+
81
+ let last;
82
+ const skills = new Set();
83
+ const fallback = (ctx) => last ?? ctx.modelRegistry.getAll().find(ours);
84
+ const pin = async (model, ctx) => {
85
+ const back = fallback(ctx);
86
+ if (back) await pi.setModel(back);
87
+ if (ctx.hasUI) ctx.ui.notify("codie: " + label(model) + " isn't a Codiedev-approved model" + (back ? "; using " + back.id : "") + ".", "warning");
88
+ };
89
+ const tag = (ctx) => {
90
+ const headers = {};
91
+ const session = clean(ctx.sessionManager?.getSessionId?.(), 200);
92
+ if (session) headers["X-Codiedev-Session-Id"] = session;
93
+ const repo = clean(git(ctx.cwd, ["remote", "get-url", "origin"]).replace(/\\/\\/[^/@]*@/, "//"), 2048);
94
+ if (repo) headers["X-Codiedev-Repo-Url"] = repo;
95
+ const branch = clean(git(ctx.cwd, ["branch", "--show-current"]), 200);
96
+ if (branch) headers["X-Codiedev-Branch"] = branch;
97
+ const sha = clean(git(ctx.cwd, ["rev-parse", "HEAD"]), 40);
98
+ if (/^[0-9a-f]{7,40}$/i.test(sha)) headers["X-Codiedev-Head-Sha"] = sha;
99
+ const list = clean([...skills].join(","), 4096);
100
+ if (list) headers["X-Codiedev-Skills-Used"] = list;
101
+ // pi replaces the provider's whole request config here, so the key name
102
+ // goes with the headers every time.
103
+ pi.registerProvider(PROVIDER, { apiKey: "CODIEDEV_GATEWAY_KEY", headers });
104
+ };
105
+
106
+ pi.on("session_start", async (_event, ctx) => {
107
+ skills.clear();
108
+ for (const m of ctx.modelRegistry.getAll()) if (!ours(m)) pi.registerProvider(m.provider, { baseUrl: BLOCKED });
109
+ if (ours(ctx.model)) last = ctx.model;
110
+ else await pin(ctx.model, ctx);
111
+ tag(ctx);
112
+ });
113
+ pi.on("model_select", async (event, ctx) => {
114
+ if (ours(event.model)) last = event.model;
115
+ else await pin(event.model, ctx);
116
+ });
117
+ pi.on("input", async (event) => {
118
+ const m = String(event?.text ?? "").match(/^\\/skill:([a-z0-9][a-z0-9_.:-]{0,119})(?:\\s|$)/i);
119
+ if (m && skills.size < 50) skills.add(m[1]);
120
+ });
121
+ pi.on("tool_result", async (event) => {
122
+ const p = String(event?.input?.path ?? "").replace(/\\\\/g, "/").match(/\\/([a-z0-9][a-z0-9_.:-]{0,119})\\/SKILL\\.md$/i);
123
+ if (event?.toolName === "read" && !event.isError && p && skills.size < 50) skills.add(p[1]);
124
+ });
125
+ // Before every model call in the turn: the agent may have switched branch.
126
+ pi.on("turn_start", async (_event, ctx) => tag(ctx));
127
+ pi.on("before_provider_request", (_event, ctx) => {
128
+ // Belt and braces: the request is already headed for BLOCKED.
129
+ if (!ours(ctx.model)) ctx.abort();
130
+ });
131
+ }
132
+ `;
133
+ function managedPiAgentDir(stateDir) {
134
+ return path.join(stateDir, "managed", "pi", "agent");
135
+ }
136
+ function piProviderConfig(gatewayUrl, catalog) {
137
+ return {
138
+ baseUrl: gatewayUrl.replace(/\/+$/, ""),
139
+ api: "openai-completions",
140
+ apiKey: "CODIEDEV_GATEWAY_KEY",
141
+ compat: { supportsDeveloperRole: false, supportsReasoningEffort: false },
142
+ models: catalog.map((model) => ({
143
+ id: (0, codieLauncher_1.bareModel)(model.id),
144
+ name: model.name || (0, codieLauncher_1.bareModel)(model.id),
145
+ ...(model.limit ? { contextWindow: model.limit.context, maxTokens: model.limit.output } : {}),
146
+ ...(model.cost ? { cost: { input: model.cost.input, output: model.cost.output, cacheRead: 0, cacheWrite: 0 } } : {}),
147
+ })),
148
+ };
149
+ }
150
+ function writeJsonAtomic(file, value) {
151
+ const tmp = `${file}.${process.pid}.tmp`;
152
+ fs.writeFileSync(tmp, JSON.stringify(value, null, 2) + "\n", { mode: 0o600 });
153
+ fs.renameSync(tmp, file);
154
+ }
155
+ function prepareManagedPiDir(opts) {
156
+ const { agentDir, gatewayUrl, catalog } = opts;
157
+ if (!catalog.length)
158
+ throw new Error("No company-approved models were returned by Codiedev");
159
+ const ids = catalog.map((model) => (0, codieLauncher_1.bareModel)(model.id));
160
+ const requested = (0, codieLauncher_1.bareModel)(opts.model ?? "");
161
+ if (requested && !ids.includes(requested)) {
162
+ throw new Error(`Primary agent model is not approved for this Codiedev account: ${requested}`);
163
+ }
164
+ fs.mkdirSync(agentDir, { recursive: true, mode: 0o700 });
165
+ writeJsonAtomic(path.join(agentDir, "models.json"), { providers: { [exports.PI_PROVIDER_ID]: piProviderConfig(gatewayUrl, catalog) } });
166
+ writeJsonAtomic(path.join(agentDir, "settings.json"), {
167
+ defaultProvider: exports.PI_PROVIDER_ID,
168
+ defaultModel: requested || ids[0],
169
+ enabledModels: ids.map((id) => `${exports.PI_PROVIDER_ID}/${id}`),
170
+ packages: [],
171
+ extensions: [],
172
+ skills: opts.skillPaths ?? [],
173
+ enableInstallTelemetry: false,
174
+ });
175
+ fs.rmSync(path.join(agentDir, "auth.json"), { force: true });
176
+ fs.rmSync(path.join(agentDir, "extensions"), { recursive: true, force: true });
177
+ const guard = path.join(agentDir, exports.GUARD_FILE);
178
+ fs.writeFileSync(guard, exports.GUARD_SOURCE, { mode: 0o600 });
179
+ const capture = path.join(agentDir, exports.CAPTURE_FILE);
180
+ fs.writeFileSync(capture, (0, utils_1.piExtensionSource)(), { mode: 0o600 });
181
+ return [guard, capture];
182
+ }
183
+ function managedPiEnv(env, agentDir, key, platform = process.platform) {
184
+ const blocked = new Set([...exports.PI_PROVIDER_ENV, "PI_CODING_AGENT_DIR"]);
185
+ const out = {};
186
+ for (const [k, v] of Object.entries(env)) {
187
+ if (blocked.has(platform === "win32" ? k.toUpperCase() : k))
188
+ continue;
189
+ out[k] = v;
190
+ }
191
+ out.PI_CODING_AGENT_DIR = agentDir;
192
+ out.PI_TELEMETRY = "0";
193
+ out.CODIEDEV_GATEWAY_KEY = key;
194
+ return out;
195
+ }
196
+ class ManagedPiArgError extends Error {
197
+ }
198
+ exports.ManagedPiArgError = ManagedPiArgError;
199
+ function managedPiArgs(args, extensions) {
200
+ if (args.length && BLOCKED_SUBCOMMANDS.has(args[0])) {
201
+ throw new ManagedPiArgError(`\`pi ${args[0]}\` changes extension sources, which codie --pi manages. Ask your Codiedev admin to approve a package instead.`);
202
+ }
203
+ for (let i = 0; i < args.length; i++) {
204
+ const a = args[i];
205
+ if (a === "--")
206
+ break;
207
+ const [flag, inline] = a.startsWith("--") && a.includes("=") ? [a.slice(0, a.indexOf("=")), a.slice(a.indexOf("=") + 1)] : [a, undefined];
208
+ if (flag === "--api-key")
209
+ throw new ManagedPiArgError("--api-key isn't allowed in codie --pi: models come from Codiedev.");
210
+ if (flag === "-e" || flag === "--extension")
211
+ throw new ManagedPiArgError(`${flag} isn't allowed in codie --pi: extensions are managed by Codiedev.`);
212
+ if (flag === "--provider") {
213
+ const value = inline ?? args[i + 1];
214
+ if (value !== exports.PI_PROVIDER_ID)
215
+ throw new ManagedPiArgError(`--provider ${value ?? "(none)"} isn't allowed in codie --pi: only Codiedev-approved models are available.`);
216
+ }
217
+ }
218
+ return ["--no-extensions", ...extensions.flatMap((file) => ["-e", file]), ...args];
219
+ }
220
+ function runManagedPi(opts) {
221
+ const env = opts.env ?? process.env;
222
+ const agentDir = managedPiAgentDir(opts.stateDir);
223
+ const extensions = prepareManagedPiDir({
224
+ agentDir, gatewayUrl: opts.gatewayUrl, catalog: opts.catalog, model: env.CODIEDEV_MODEL,
225
+ skillPaths: opts.skillPaths,
226
+ });
227
+ const args = managedPiArgs(opts.args, extensions);
228
+ const bin = env.CODIEDEV_PI_BIN?.trim();
229
+ const [command, commandArgs] = bin
230
+ ? [bin, args]
231
+ : [process.execPath, [(opts.resolvePi ?? (() => (0, piRuntime_1.ensurePiRuntime)({ stateDir: opts.stateDir })))(), ...args]];
232
+ const result = (0, child_process_1.spawnSync)(command, commandArgs, {
233
+ stdio: "inherit",
234
+ env: managedPiEnv(env, agentDir, opts.key),
235
+ shell: Boolean(bin) && process.platform === "win32",
236
+ });
237
+ if (result.error)
238
+ throw result.error;
239
+ return result.status === null ? 1 : result.status;
240
+ }