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,216 @@
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_CONTEXT_CUSTOM_TYPE = void 0;
37
+ exports.normalizePiTranscript = normalizePiTranscript;
38
+ exports.isPiTranscriptEmpty = isPiTranscriptEmpty;
39
+ exports.piLaunchFromArgv = piLaunchFromArgv;
40
+ exports.piExtensionPath = piExtensionPath;
41
+ exports.inspectPiExtension = inspectPiExtension;
42
+ const fs = __importStar(require("fs"));
43
+ const path = __importStar(require("path"));
44
+ const harnessDirs_1 = require("./harnessDirs");
45
+ exports.PI_CONTEXT_CUSTOM_TYPE = "codiedev";
46
+ const SKILL_EXPANSION = /^<skill name="([^"]{1,200})" location="[^"]*">/;
47
+ const num = (n) => (typeof n === "number" && Number.isFinite(n) ? Math.max(0, n) : 0);
48
+ function textOf(content) {
49
+ if (typeof content === "string")
50
+ return content;
51
+ if (!Array.isArray(content))
52
+ return "";
53
+ return content
54
+ .map((block) => (block?.type === "text" && typeof block.text === "string" ? block.text : ""))
55
+ .filter(Boolean)
56
+ .join("\n");
57
+ }
58
+ function userBlocks(content) {
59
+ if (typeof content === "string")
60
+ return [{ type: "text", text: content }];
61
+ if (!Array.isArray(content))
62
+ return [];
63
+ return content.flatMap((block) => block?.type === "text" && typeof block.text === "string"
64
+ ? [{ type: "text", text: block.text }]
65
+ : block?.type === "image" ? [{ type: "text", text: "[image]" }] : []);
66
+ }
67
+ function skillFromPath(value) {
68
+ if (typeof value !== "string")
69
+ return null;
70
+ const m = value.replace(/\\/g, "/").match(/\/([^/]+)\/SKILL\.md$/);
71
+ return m ? m[1] : null;
72
+ }
73
+ function errorCode(message) {
74
+ return message.match(/^\s*(\d{3})\b/)?.[1] ?? "";
75
+ }
76
+ function normalizePiTranscript(content) {
77
+ const out = [];
78
+ const skillReads = new Map();
79
+ let errorStreakAt;
80
+ const push = (record) => out.push(JSON.stringify(record));
81
+ for (const line of content.split("\n")) {
82
+ if (!line.trim())
83
+ continue;
84
+ let entry;
85
+ try {
86
+ entry = JSON.parse(line);
87
+ }
88
+ catch {
89
+ continue;
90
+ }
91
+ if (!entry || typeof entry !== "object")
92
+ continue;
93
+ const timestamp = typeof entry.timestamp === "string" ? entry.timestamp : undefined;
94
+ const uuid = typeof entry.id === "string" ? entry.id : undefined;
95
+ if (entry.type !== "message" || !entry.message || typeof entry.message !== "object")
96
+ continue;
97
+ const message = entry.message;
98
+ if (!(message.role === "assistant" && message.stopReason === "error"))
99
+ errorStreakAt = undefined;
100
+ if (message.role === "user") {
101
+ const text = textOf(message.content);
102
+ const skill = text.match(SKILL_EXPANSION)?.[1];
103
+ if (skill)
104
+ push({ type: "pi.skill_invoked", timestamp, skill });
105
+ push({ type: "user", uuid, timestamp, message: { role: "user", content: userBlocks(message.content) } });
106
+ continue;
107
+ }
108
+ if (message.role === "assistant") {
109
+ const blocks = [];
110
+ for (const block of Array.isArray(message.content) ? message.content : []) {
111
+ if (block?.type === "text" && typeof block.text === "string")
112
+ blocks.push({ type: "text", text: block.text });
113
+ else if (block?.type === "thinking" && typeof block.thinking === "string")
114
+ blocks.push({ type: "thinking", thinking: block.thinking });
115
+ else if (block?.type === "toolCall") {
116
+ const input = block.arguments && typeof block.arguments === "object" ? block.arguments : {};
117
+ blocks.push({ type: "tool_use", id: block.id, name: block.name ?? "tool", input });
118
+ const skill = block.name === "read" ? skillFromPath(input.path) : null;
119
+ if (skill && typeof block.id === "string")
120
+ skillReads.set(block.id, skill);
121
+ }
122
+ }
123
+ const usage = message.usage ?? {};
124
+ const tokens = num(usage.input) + num(usage.output) + num(usage.cacheRead) + num(usage.cacheWrite);
125
+ const measured = tokens > 0 || message.stopReason !== "error";
126
+ push({
127
+ type: "assistant",
128
+ uuid,
129
+ timestamp,
130
+ message: {
131
+ id: typeof message.responseId === "string" ? message.responseId : uuid,
132
+ role: "assistant",
133
+ model: typeof message.model === "string" ? message.model : undefined,
134
+ ...(measured ? {
135
+ usage: {
136
+ input_tokens: num(usage.input),
137
+ output_tokens: num(usage.output),
138
+ cache_read_input_tokens: num(usage.cacheRead),
139
+ cache_creation_input_tokens: num(usage.cacheWrite),
140
+ },
141
+ } : {}),
142
+ content: blocks,
143
+ },
144
+ });
145
+ if (message.stopReason === "aborted") {
146
+ push({ type: "user", timestamp, message: { role: "user", content: [{ type: "text", text: "[Request interrupted by user]" }] } });
147
+ }
148
+ if (message.stopReason === "error" && typeof message.errorMessage === "string") {
149
+ errorStreakAt ??= typeof message.timestamp === "number" ? new Date(message.timestamp).toISOString() : timestamp;
150
+ push({
151
+ type: "agent.error",
152
+ timestamp: errorStreakAt,
153
+ data: { errorContext: "model_call", error: { code: errorCode(message.errorMessage), message: message.errorMessage } },
154
+ });
155
+ }
156
+ continue;
157
+ }
158
+ if (message.role === "toolResult") {
159
+ const id = typeof message.toolCallId === "string" ? message.toolCallId : undefined;
160
+ const skill = id ? skillReads.get(id) : undefined;
161
+ if (skill && message.isError !== true)
162
+ push({ type: "pi.skill_invoked", timestamp, skill });
163
+ push({
164
+ type: "user",
165
+ uuid,
166
+ timestamp,
167
+ message: {
168
+ role: "user",
169
+ content: [{ type: "tool_result", tool_use_id: id, content: textOf(message.content), is_error: message.isError === true }],
170
+ },
171
+ });
172
+ continue;
173
+ }
174
+ if (message.role === "bashExecution" && typeof message.command === "string") {
175
+ push({ type: "user", uuid, timestamp, message: { role: "user", content: [{ type: "text", text: `<bash-input>${message.command}</bash-input>` }] } });
176
+ }
177
+ }
178
+ return out.join("\n") + (out.length ? "\n" : "");
179
+ }
180
+ function isPiTranscriptEmpty(content) {
181
+ return !content.split("\n").some((line) => line.includes('"type":"message"'));
182
+ }
183
+ function piLaunchFromArgv(argv) {
184
+ for (let i = 0; i < argv.length; i++) {
185
+ const a = argv[i];
186
+ if (a === "-p" || a === "--print")
187
+ return "pi:print";
188
+ if (a === "--mode") {
189
+ const mode = argv[i + 1];
190
+ if (mode === "json" || mode === "rpc")
191
+ return `pi:${mode}`;
192
+ }
193
+ if (a === "--mode=json" || a === "--mode=rpc")
194
+ return `pi:${a.slice(7)}`;
195
+ }
196
+ return "pi:tui";
197
+ }
198
+ function piExtensionPath(agentDir = (0, harnessDirs_1.piAgentDir)()) {
199
+ return path.join(agentDir, "extensions", "codiedev.ts");
200
+ }
201
+ function inspectPiExtension(file = piExtensionPath()) {
202
+ if (!fs.existsSync(file))
203
+ return { status: "not-installed", detail: `${file} not found` };
204
+ let source;
205
+ try {
206
+ source = fs.readFileSync(file, "utf8");
207
+ }
208
+ catch {
209
+ return { status: "fail", detail: `${file} unreadable` };
210
+ }
211
+ const expected = ["session-start-pi", "backup-pi", "capture-pi-final"];
212
+ const missing = expected.filter((subcommand) => !source.includes(JSON.stringify(subcommand)));
213
+ if (missing.length)
214
+ return { status: "fail", detail: `missing ${missing.join(", ")} — re-run \`codiedev connect\`` };
215
+ return { status: "pass", detail: `session start, capture and backup events (${(0, harnessDirs_1.displayPath)(file)})` };
216
+ }
@@ -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
+ }
@@ -1,12 +1,4 @@
1
1
  "use strict";
2
- // Pure resolver — given a captured remoteUrl, an optional client-cached
3
- // repoId, and the company's current repo list, decide which repoId (if any)
4
- // the session belongs to. Used both inline by the CLI hook and (mirrored
5
- // in convex/repoResolver.ts) by the /api/captureSession endpoint so that
6
- // repos added after the user's last `connect` still get matched.
7
- //
8
- // "unmatched" is intentional — the backend will accept the session anyway
9
- // and surface it for triage rather than silently dropping it.
10
2
  Object.defineProperty(exports, "__esModule", { value: true });
11
3
  exports.resolveRepoForCapture = resolveRepoForCapture;
12
4
  function parseRemoteUrl(url) {
@@ -17,12 +9,6 @@ function parseRemoteUrl(url) {
17
9
  if (https) {
18
10
  return { host: https[1].toLowerCase(), ownerName: https[2].toLowerCase() };
19
11
  }
20
- // Codie strips SSH userinfo before putting a remote in the gateway header,
21
- // so `git@gitlab.com:owner/repo.git` arrives here as
22
- // `gitlab.com:owner/repo.git`. Accept both forms; otherwise every SSH-cloned
23
- // Harness checkout loses its repoId even though transcript capture can
24
- // resolve the same raw remote correctly. Check this after URL forms so the
25
- // colon in `https://` is never mistaken for an SCP separator.
26
12
  const scp = s.match(/^(?:[^@\s]+@)?([^:/\s]+):([^/]+\/.+)$/);
27
13
  if (scp) {
28
14
  return { host: scp[1].toLowerCase(), ownerName: scp[2].toLowerCase() };
@@ -31,11 +17,6 @@ function parseRemoteUrl(url) {
31
17
  }
32
18
  function resolveRepoForCapture(input) {
33
19
  const { remoteUrl, providedRepoId, companyRepos } = input;
34
- // The remoteUrl is the ground truth of where the work happened — resolve it
35
- // FIRST. A buggy client can send a wrong-but-valid providedRepoId (the Sonifi
36
- // case: client matchRepo stamped every session with the org's first repo), so
37
- // we must not blindly trust it over the URL. Keep providedRepoId only when it
38
- // AGREES with the URL match, or when the URL can't be resolved at all.
39
20
  const parsed = remoteUrl ? parseRemoteUrl(remoteUrl) : null;
40
21
  const urlMatch = parsed
41
22
  ? companyRepos.find((r) => `${r.owner}/${r.name}`.toLowerCase() === parsed.ownerName)
package/dist/secret.js CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- // Display helpers for credential-shaped strings. Use anywhere a token /
3
- // secret might end up in user-visible output (logs, success lines, error
4
- // messages) so a stray `console.log` can't leak the full value.
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.maskToken = maskToken;
7
4
  const PREFIX_LEN = 12;