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,376 @@
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.BIN_NAMES = void 0;
37
+ exports.planSelfUpdate = planSelfUpdate;
38
+ exports.isSelfUpdateDue = isSelfUpdateDue;
39
+ exports.readSelfUpdateState = readSelfUpdateState;
40
+ exports.maybeSpawnSelfUpdate = maybeSpawnSelfUpdate;
41
+ exports.maybeRefreshInstructions = maybeRefreshInstructions;
42
+ exports.missingPs1Shims = missingPs1Shims;
43
+ exports.findInstalledHookScript = findInstalledHookScript;
44
+ exports.runSelfUpdate = runSelfUpdate;
45
+ const fs = __importStar(require("fs"));
46
+ const path = __importStar(require("path"));
47
+ const child_process_1 = require("child_process");
48
+ const version_1 = require("./version");
49
+ const versionCheck_1 = require("./versionCheck");
50
+ const configDir_1 = require("./configDir");
51
+ const captureLog_1 = require("./captureLog");
52
+ const launcher_1 = require("./launcher");
53
+ const utils_1 = require("./utils");
54
+ const PKG = "codiedev";
55
+ const SELF_UPDATE_INTERVAL_MS = 2 * 60 * 60 * 1000;
56
+ const LOCK_STALE_MS = 10 * 60 * 1000;
57
+ const INSTALL_TIMEOUT_MS = 5 * 60 * 1000;
58
+ const FETCH_TIMEOUT_MS = 5_000;
59
+ function planSelfUpdate(deps) {
60
+ const { env } = deps;
61
+ if (env.CODIEDEV_NO_UPDATE_CHECK || env.CODIEDEV_NO_AUTO_UPDATE) {
62
+ return { kind: "skip", reason: "disabled" };
63
+ }
64
+ if (env.CI || env.CONTINUOUS_INTEGRATION || env.GITHUB_ACTIONS || env.BUILD_NUMBER) {
65
+ return { kind: "skip", reason: "ci" };
66
+ }
67
+ if (deps.isContainer)
68
+ return { kind: "skip", reason: "container" };
69
+ const p = deps.hookScriptReal.replace(/\\/g, "/");
70
+ if (/\/(?:_npx|\.npm\/_npx)\//.test(p))
71
+ return { kind: "skip", reason: "npx" };
72
+ const pkgDir = path.dirname(path.dirname(deps.hookScriptReal));
73
+ if (!deps.isWritable(pkgDir))
74
+ return { kind: "skip", reason: "readonly" };
75
+ if (/\/\.pnpm\/|\/pnpm\/global\/|\/global\/v\d+\/[^/]+\/node_modules\/codiedev\/|\/store\/v\d+\/links\//.test(p)) {
76
+ return deps.viaLauncher ? { kind: "pnpm" } : { kind: "skip", reason: "pnpm-direct" };
77
+ }
78
+ if (/\/install\/global\/node_modules\/codiedev\/dist\/hook\.js$/.test(p))
79
+ return { kind: "bun" };
80
+ const unix = p.match(/^(.*)\/lib\/node_modules\/codiedev\/dist\/hook\.js$/);
81
+ if (unix && deps.platform !== "win32")
82
+ return { kind: "npm", prefix: unix[1] };
83
+ const win = p.match(/^(.*)\/node_modules\/codiedev\/dist\/hook\.js$/);
84
+ if (win && deps.platform === "win32")
85
+ return { kind: "npm", prefix: win[1] };
86
+ return { kind: "skip", reason: "unmanaged" };
87
+ }
88
+ function isSelfUpdateDue(state, nowMs) {
89
+ return !state || nowMs - state.lastAttemptAt > SELF_UPDATE_INTERVAL_MS;
90
+ }
91
+ function statePath() {
92
+ return path.join((0, configDir_1.codiedevStateDir)(), ".self-update.json");
93
+ }
94
+ function lockPath() {
95
+ return path.join((0, configDir_1.codiedevStateDir)(), ".self-update.lock");
96
+ }
97
+ function readSelfUpdateState() {
98
+ try {
99
+ const parsed = JSON.parse(fs.readFileSync(statePath(), "utf8"));
100
+ return typeof parsed.lastAttemptAt === "number" ? parsed : null;
101
+ }
102
+ catch {
103
+ return null;
104
+ }
105
+ }
106
+ function writeState(state) {
107
+ try {
108
+ fs.mkdirSync((0, configDir_1.codiedevStateDir)(), { recursive: true });
109
+ fs.writeFileSync(statePath(), JSON.stringify(state), "utf8");
110
+ return true;
111
+ }
112
+ catch {
113
+ return false;
114
+ }
115
+ }
116
+ function maybeSpawnSelfUpdate(hookEntry) {
117
+ try {
118
+ if (!hookEntry || process.env.CODIEDEV_NO_AUTO_UPDATE || process.env.CODIEDEV_NO_UPDATE_CHECK)
119
+ return;
120
+ const now = Date.now();
121
+ if (!isSelfUpdateDue(readSelfUpdateState(), now))
122
+ return;
123
+ if (!writeState({ lastAttemptAt: now, lastResult: "spawned" }))
124
+ return;
125
+ const child = (0, child_process_1.spawn)(process.execPath, [hookEntry, "self-update"], {
126
+ detached: true,
127
+ stdio: "ignore",
128
+ windowsHide: true,
129
+ });
130
+ child.unref();
131
+ }
132
+ catch {
133
+ }
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
+ }
164
+ function acquireLock() {
165
+ const lock = lockPath();
166
+ try {
167
+ fs.mkdirSync(lock);
168
+ return true;
169
+ }
170
+ catch {
171
+ try {
172
+ if (Date.now() - fs.statSync(lock).mtimeMs > LOCK_STALE_MS) {
173
+ fs.rmSync(lock, { recursive: true, force: true });
174
+ fs.mkdirSync(lock);
175
+ return true;
176
+ }
177
+ }
178
+ catch {
179
+ }
180
+ return false;
181
+ }
182
+ }
183
+ function detectContainer(env) {
184
+ if (env.KUBERNETES_SERVICE_HOST)
185
+ return true;
186
+ if (fs.existsSync("/.dockerenv") || fs.existsSync("/run/.containerenv"))
187
+ return true;
188
+ try {
189
+ return /docker|containerd|kubepods|lxc/.test(fs.readFileSync("/proc/1/cgroup", "utf8"));
190
+ }
191
+ catch {
192
+ return false;
193
+ }
194
+ }
195
+ function registryBase(env) {
196
+ const configured = env.npm_config_registry || env.NPM_CONFIG_REGISTRY;
197
+ return (configured || "https://registry.npmjs.org").replace(/\/+$/, "");
198
+ }
199
+ async function fetchLatest(env) {
200
+ const controller = new AbortController();
201
+ const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
202
+ try {
203
+ const res = await fetch(`${registryBase(env)}/${PKG}/latest`, {
204
+ headers: { Accept: "application/json" },
205
+ signal: controller.signal,
206
+ });
207
+ if (!res.ok)
208
+ return null;
209
+ const json = (await res.json());
210
+ return typeof json.version === "string" ? json.version : null;
211
+ }
212
+ catch {
213
+ return null;
214
+ }
215
+ finally {
216
+ clearTimeout(timer);
217
+ }
218
+ }
219
+ function installCommand(plan, version, env) {
220
+ const spec = `${PKG}@${version}`;
221
+ const configured = env.npm_config_registry || env.NPM_CONFIG_REGISTRY;
222
+ const registry = configured ? ["--registry", registryBase(env)] : [];
223
+ switch (plan.kind) {
224
+ case "npm": {
225
+ const args = ["i", "-g", "--prefix", plan.prefix, "--no-fund", "--no-audit", ...registry, spec];
226
+ const execDir = path.dirname(process.execPath);
227
+ const npmCli = [
228
+ path.join(execDir, "node_modules", "npm", "bin", "npm-cli.js"),
229
+ path.join(execDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
230
+ ].find((p) => fs.existsSync(p));
231
+ if (npmCli)
232
+ return { cmd: process.execPath, args: [npmCli, ...args] };
233
+ return { cmd: process.platform === "win32" ? "npm.cmd" : "npm", args, shell: process.platform === "win32" };
234
+ }
235
+ case "pnpm":
236
+ return { cmd: "pnpm", args: ["add", "-g", ...registry, spec], shell: process.platform === "win32" };
237
+ case "bun":
238
+ return { cmd: "bun", args: ["add", "-g", ...registry, spec] };
239
+ default:
240
+ return null;
241
+ }
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
+ }
247
+ function readVersionAt(hookScript) {
248
+ try {
249
+ const pkg = JSON.parse(fs.readFileSync(path.join(path.dirname(path.dirname(hookScript)), "package.json"), "utf8"));
250
+ return typeof pkg.version === "string" ? pkg.version : null;
251
+ }
252
+ catch {
253
+ return null;
254
+ }
255
+ }
256
+ function findInstalledHookScript(plan, hookEntry, version, pnpmRoot = pnpmGlobalRoot) {
257
+ if (plan.kind !== "pnpm")
258
+ return readVersionAt(hookEntry) === version ? hookEntry : null;
259
+ const root = pnpmRoot();
260
+ if (!root)
261
+ return null;
262
+ const candidates = [path.join(root, PKG, "dist", "hook.js")];
263
+ try {
264
+ for (const entry of fs.readdirSync(root)) {
265
+ candidates.push(path.join(root, entry, "node_modules", PKG, "dist", "hook.js"));
266
+ }
267
+ }
268
+ catch {
269
+ }
270
+ for (const candidate of candidates) {
271
+ if (readVersionAt(candidate) !== version)
272
+ continue;
273
+ try {
274
+ return fs.realpathSync(candidate);
275
+ }
276
+ catch {
277
+ }
278
+ }
279
+ return null;
280
+ }
281
+ function pnpmGlobalRoot() {
282
+ const root = (0, child_process_1.spawnSync)("pnpm", ["root", "-g"], {
283
+ encoding: "utf8",
284
+ timeout: 30_000,
285
+ shell: process.platform === "win32",
286
+ windowsHide: true,
287
+ });
288
+ const dir = root.status === 0 ? root.stdout.trim() : "";
289
+ return dir || null;
290
+ }
291
+ async function runSelfUpdate(hookEntry) {
292
+ const env = process.env;
293
+ const now = Date.now();
294
+ const finish = (lastResult, extra = {}) => {
295
+ const state = { lastAttemptAt: now, lastResult, fromVersion: version_1.CLI_VERSION, ...extra };
296
+ writeState(state);
297
+ (0, captureLog_1.appendCaptureLog)({
298
+ stage: "self-update",
299
+ sessionId: undefined,
300
+ outcome: lastResult.startsWith("error") ? "ERROR" : "ok",
301
+ detail: `result=${lastResult} from=${version_1.CLI_VERSION} to=${extra.toVersion ?? "-"} elapsedMs=${Date.now() - now}`,
302
+ });
303
+ return state;
304
+ };
305
+ let hookScriptReal;
306
+ try {
307
+ hookScriptReal = fs.realpathSync(hookEntry);
308
+ }
309
+ catch {
310
+ return finish("skip:unresolved");
311
+ }
312
+ const plan = planSelfUpdate({
313
+ hookScriptReal,
314
+ env,
315
+ platform: process.platform,
316
+ isContainer: detectContainer(env),
317
+ viaLauncher: Boolean(env.CODIEDEV_VIA_LAUNCHER),
318
+ isWritable: (dir) => {
319
+ try {
320
+ fs.accessSync(dir, fs.constants.W_OK);
321
+ return true;
322
+ }
323
+ catch {
324
+ return false;
325
+ }
326
+ },
327
+ });
328
+ if (plan.kind === "skip")
329
+ return finish(`skip:${plan.reason}`);
330
+ if (!acquireLock()) {
331
+ (0, captureLog_1.appendCaptureLog)({ stage: "self-update", sessionId: undefined, outcome: "ok", detail: "result=skip:locked" });
332
+ return { lastAttemptAt: now, lastResult: "skip:locked" };
333
+ }
334
+ try {
335
+ const latest = await fetchLatest(env);
336
+ if (!latest)
337
+ return finish("error:registry");
338
+ if ((0, versionCheck_1.compareSemver)(version_1.CLI_VERSION, latest) !== -1)
339
+ return finish("current", { toVersion: latest });
340
+ const install = installCommand(plan, latest, env);
341
+ if (!install)
342
+ return finish("skip:no-installer");
343
+ const droppedShims = plan.kind === "npm" && process.platform === "win32" ? missingPs1Shims(plan.prefix) : [];
344
+ const result = (0, child_process_1.spawnSync)(install.cmd, install.args, {
345
+ stdio: "ignore",
346
+ timeout: INSTALL_TIMEOUT_MS,
347
+ env: { ...env, CODIEDEV_NO_AUTO_UPDATE: "1" },
348
+ shell: install.shell ?? false,
349
+ windowsHide: true,
350
+ });
351
+ if (result.error || result.status !== 0) {
352
+ return finish(`error:install-exit-${result.status ?? "spawn"}`, { toVersion: latest });
353
+ }
354
+ for (const shim of droppedShims) {
355
+ try {
356
+ fs.rmSync(shim, { force: true });
357
+ }
358
+ catch {
359
+ }
360
+ }
361
+ const installed = findInstalledHookScript(plan, hookScriptReal, latest);
362
+ if (!installed) {
363
+ return finish("error:not-found-after-install", { toVersion: latest });
364
+ }
365
+ if (!(0, launcher_1.recordCurrentInstall)(installed))
366
+ return finish("error:record", { toVersion: latest });
367
+ return finish("updated", { toVersion: latest });
368
+ }
369
+ finally {
370
+ try {
371
+ fs.rmSync(lockPath(), { recursive: true, force: true });
372
+ }
373
+ catch {
374
+ }
375
+ }
376
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.looksLikeSkill = looksLikeSkill;
4
+ exports.stripSkillMarker = stripSkillMarker;
5
+ exports.stampSkillMarker = stampSkillMarker;
6
+ const ID = /^[a-z0-9]{16,64}$/i;
7
+ const LINE = /^[ \t]*<!--\s*codiedev:artifact=[a-z0-9]+\s*-->[ \t]*(?:\r?\n|$)/gim;
8
+ function looksLikeSkill(markdown) {
9
+ const fm = markdown.match(/^?---\r?\n([\s\S]*?)\r?\n---/);
10
+ if (!fm)
11
+ return false;
12
+ return /^name\s*:/im.test(fm[1]) && /^description\s*:/im.test(fm[1]);
13
+ }
14
+ function stripSkillMarker(markdown) {
15
+ return markdown.replace(LINE, "");
16
+ }
17
+ function stampSkillMarker(markdown, artifactId) {
18
+ if (!artifactId || !ID.test(artifactId))
19
+ return markdown;
20
+ const body = stripSkillMarker(markdown);
21
+ const sep = body.endsWith("\n") ? "" : "\n";
22
+ return `${body}${sep}<!-- codiedev:artifact=${artifactId} -->\n`;
23
+ }
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SUBAGENT_LIMITS = void 0;
7
+ exports.subagentDir = subagentDir;
8
+ exports.readSubagentTranscripts = readSubagentTranscripts;
9
+ exports.foldSubagentSignals = foldSubagentSignals;
10
+ exports.foldSubagentModelUsage = foldSubagentModelUsage;
11
+ const node_fs_1 = __importDefault(require("node:fs"));
12
+ const node_path_1 = __importDefault(require("node:path"));
13
+ const captureSignals_1 = require("./captureSignals");
14
+ const transcriptModels_1 = require("./transcriptModels");
15
+ exports.SUBAGENT_LIMITS = { files: 20, bytes: 20 * 1024 * 1024 };
16
+ function subagentDir(transcriptPath, sessionId) {
17
+ const dir = node_path_1.default.dirname(transcriptPath);
18
+ const id = sessionId || node_path_1.default.basename(transcriptPath).replace(/\.jsonl$/i, "");
19
+ return node_path_1.default.join(dir, id, "subagents");
20
+ }
21
+ function readSubagentTranscripts(transcriptPath, sessionId, limits = exports.SUBAGENT_LIMITS) {
22
+ const dir = subagentDir(transcriptPath, sessionId);
23
+ let names;
24
+ try {
25
+ names = node_fs_1.default.readdirSync(dir).filter((n) => /^agent-[^/]+\.jsonl$/.test(n));
26
+ }
27
+ catch {
28
+ return { contents: [], count: 0, truncated: false };
29
+ }
30
+ const files = names
31
+ .map((n) => {
32
+ const full = node_path_1.default.join(dir, n);
33
+ try {
34
+ const st = node_fs_1.default.statSync(full);
35
+ return st.isFile() ? { full, size: st.size, mtime: st.mtimeMs } : null;
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ })
41
+ .filter((f) => f !== null)
42
+ .sort((a, b) => a.mtime - b.mtime || a.full.localeCompare(b.full));
43
+ const contents = [];
44
+ let bytes = 0;
45
+ let truncated = false;
46
+ for (const f of files) {
47
+ if (contents.length >= limits.files || bytes + f.size > limits.bytes) {
48
+ truncated = true;
49
+ break;
50
+ }
51
+ try {
52
+ contents.push(node_fs_1.default.readFileSync(f.full, "utf8"));
53
+ bytes += f.size;
54
+ }
55
+ catch {
56
+ truncated = true;
57
+ }
58
+ }
59
+ return { contents, count: files.length, truncated };
60
+ }
61
+ function foldSubagentSignals(parent, subs, source) {
62
+ if (subs.count === 0)
63
+ return parent;
64
+ const counts = new Map();
65
+ const add = (list, fallback) => {
66
+ for (const c of list ?? fallback.map((skill) => ({ skill, count: 1 })))
67
+ counts.set(c.skill, (counts.get(c.skill) ?? 0) + c.count);
68
+ };
69
+ add(parent.skillInvocationCounts, parent.skillInvocations);
70
+ const invocations = new Set(parent.skillInvocations);
71
+ const pulls = new Set(parent.skillPulls);
72
+ const tools = new Map(parent.toolCalls.map((t) => [t.name, t.calls]));
73
+ const artifacts = new Map((parent.skillInvocationArtifacts ?? []).map((a) => [a.skill, a.artifactId]));
74
+ let truncated = parent.truncated;
75
+ for (const content of subs.contents) {
76
+ const s = (0, captureSignals_1.parseCaptureSignals)(content, source);
77
+ add(s.skillInvocationCounts, s.skillInvocations);
78
+ for (const a of s.skillInvocationArtifacts ?? [])
79
+ if (!artifacts.has(a.skill))
80
+ artifacts.set(a.skill, a.artifactId);
81
+ for (const k of s.skillInvocations)
82
+ invocations.add(k);
83
+ for (const k of s.skillPulls)
84
+ pulls.add(k);
85
+ for (const t of s.toolCalls)
86
+ tools.set(t.name, (tools.get(t.name) ?? 0) + t.calls);
87
+ truncated ||= s.truncated;
88
+ }
89
+ const cap = (xs) => {
90
+ if (xs.length > 100)
91
+ truncated = true;
92
+ return xs.slice(0, 100);
93
+ };
94
+ return {
95
+ ...parent,
96
+ skillInvocations: cap([...invocations].sort()),
97
+ skillInvocationCounts: cap([...counts].map(([skill, count]) => ({ skill, count: Math.min(count, 10_000) })).sort((a, b) => a.skill.localeCompare(b.skill))),
98
+ ...(artifacts.size
99
+ ? { skillInvocationArtifacts: cap([...artifacts].map(([skill, artifactId]) => ({ skill, artifactId })).sort((a, b) => a.skill.localeCompare(b.skill))) }
100
+ : {}),
101
+ skillPulls: cap([...pulls].sort()),
102
+ toolCalls: cap([...tools].map(([name, calls]) => ({ name, calls })).sort((a, b) => a.name.localeCompare(b.name))),
103
+ subagents: { count: subs.count, truncated: subs.truncated },
104
+ truncated,
105
+ };
106
+ }
107
+ function foldSubagentModelUsage(parent, subs, source) {
108
+ if (subs.contents.length === 0)
109
+ return parent;
110
+ const byModel = new Map();
111
+ const add = (u) => {
112
+ const cur = byModel.get(u.model);
113
+ if (!cur) {
114
+ byModel.set(u.model, { ...u });
115
+ return;
116
+ }
117
+ cur.requests += u.requests;
118
+ cur.inputTokens += u.inputTokens;
119
+ cur.outputTokens += u.outputTokens;
120
+ cur.cacheReadTokens += u.cacheReadTokens;
121
+ cur.cacheCreationTokens += u.cacheCreationTokens;
122
+ if (u.costUsd !== undefined)
123
+ cur.costUsd = (cur.costUsd ?? 0) + u.costUsd;
124
+ if (u.reportedCostUsd !== undefined)
125
+ cur.reportedCostUsd = (cur.reportedCostUsd ?? 0) + u.reportedCostUsd;
126
+ if (u.reasoningTokens !== undefined)
127
+ cur.reasoningTokens = (cur.reasoningTokens ?? 0) + u.reasoningTokens;
128
+ };
129
+ for (const u of parent)
130
+ add(u);
131
+ for (const content of subs.contents)
132
+ for (const u of (0, transcriptModels_1.parseTranscriptModels)(content, source))
133
+ add(u);
134
+ return [...byModel.values()].slice(0, 64);
135
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEAM_SKILL_CONTEXT = void 0;
4
+ exports.teamSkillSessionOutput = teamSkillSessionOutput;
5
+ exports.TEAM_SKILL_CONTEXT = `This machine is connected to Codiedev, the team's artifact and skill library.
6
+ Before a substantial coding task, run codiedev search "<brief task description>" and reuse a relevant team skill by running codiedev pull <exact-key> and following its instructions. If no skill fits, continue the task.
7
+ Use codiedev push <file.md> to share an artifact when asked, codiedev ask "<question>" for team knowledge, and codiedev inbox to check messages. Use codiedev --help for other commands. If codiedev is unavailable, use npx codiedev@latest.`;
8
+ function teamSkillSessionOutput(source, context = exports.TEAM_SKILL_CONTEXT) {
9
+ return source === "cursor" ? { additional_context: context } : { additionalContext: context };
10
+ }
@@ -25,7 +25,6 @@ function* transcriptRecords(content, source) {
25
25
  }
26
26
  }
27
27
  catch {
28
- /* Fall through to JSONL for partial captures. */
29
28
  }
30
29
  }
31
30
  let start = 0;
@@ -36,7 +35,6 @@ function* transcriptRecords(content, source) {
36
35
  yield JSON.parse(content.slice(start, end));
37
36
  }
38
37
  catch {
39
- /* partial or non-JSON line */
40
38
  }
41
39
  start = end + 1;
42
40
  }
@@ -44,6 +42,7 @@ function* transcriptRecords(content, source) {
44
42
  function parseTranscriptModels(content, source) {
45
43
  const buckets = new Map();
46
44
  const messages = new Map();
45
+ const tokenEvidence = new Set();
47
46
  let model = "Unattributed";
48
47
  let previous = {
49
48
  inputTokens: 0,
@@ -75,8 +74,6 @@ function parseTranscriptModels(content, source) {
75
74
  cacheReadTokens: positive(raw.cached_input_tokens),
76
75
  cacheCreationTokens: 0,
77
76
  };
78
- // Codex reasoning_output_tokens is a subset of output_tokens. Cumulative
79
- // snapshots must be differenced, including across a model switch.
80
77
  usage = { ...empty(model), requests: 1 };
81
78
  const reset = positive(raw.input_tokens) <
82
79
  previous.inputTokens + previous.cacheReadTokens ||
@@ -143,9 +140,10 @@ function parseTranscriptModels(content, source) {
143
140
  model =
144
141
  typeof message.model === "string" ? message.model : "Unattributed";
145
142
  const raw = message.usage;
143
+ const requests = event.requests;
146
144
  usage = {
147
145
  ...empty(model),
148
- requests: 1,
146
+ requests: typeof requests === "number" && Number.isFinite(requests) ? Math.max(0, requests) : 1,
149
147
  inputTokens: positive(raw.input_tokens),
150
148
  outputTokens: positive(raw.output_tokens),
151
149
  cacheReadTokens: positive(raw.cache_read_input_tokens),
@@ -153,10 +151,10 @@ function parseTranscriptModels(content, source) {
153
151
  };
154
152
  messageId = message.id ?? event.uuid ?? messageId;
155
153
  }
156
- // Client placeholders are not model executions.
154
+ if (source === "copilot" && event.type === "copilot.usage")
155
+ tokenEvidence.add(usage.model);
157
156
  if (!usage.model.trim() || usage.model.startsWith("<"))
158
157
  continue;
159
- // Streaming snapshots repeat message ids; retain the latest snapshot once.
160
158
  messages.set(messageId, usage);
161
159
  }
162
160
  const incompleteCosts = new Set();
@@ -197,7 +195,7 @@ function parseTranscriptModels(content, source) {
197
195
  delete buckets.get(key).costUsd;
198
196
  for (const key of incompleteReasoning)
199
197
  delete buckets.get(key).reasoningTokens;
200
- return [...buckets.values()];
198
+ return [...buckets.values()].map(row => source === "copilot" && !tokenEvidence.has(row.model) ? { ...row, tokensAvailable: false } : row);
201
199
  }
202
200
  function totalModelTokens(row) {
203
201
  return (row.inputTokens +