codiedev 0.10.0-beta.1 → 0.10.0-beta.11

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 (155) hide show
  1. package/README.md +11 -5
  2. package/assets/opencode-plugin.mjs +6 -0
  3. package/assets/session-key.mjs +48 -0
  4. package/assets/tui-brand-plugin.tsx +73 -0
  5. package/dist/backup/cache.js +1 -5
  6. package/dist/backup/match.js +0 -6
  7. package/dist/backup/run.js +3 -35
  8. package/dist/captureExclusions.js +0 -12
  9. package/dist/captureLog.js +0 -28
  10. package/dist/captureReadiness.js +0 -58
  11. package/dist/captureSignals.js +184 -0
  12. package/dist/cli.js +135 -72
  13. package/dist/cliSession.js +456 -0
  14. package/dist/codexHookTrust.js +125 -6
  15. package/dist/codexLimitScan.js +359 -0
  16. package/dist/codie.js +77 -130
  17. package/dist/codieBrandInstall.js +80 -0
  18. package/dist/codieLauncher.js +76 -79
  19. package/dist/codieRuntime.js +19 -23
  20. package/dist/codieRuntimeInstall.js +108 -23
  21. package/dist/codieUsage.js +181 -0
  22. package/dist/commands/agentTemplates.generated.js +136 -0
  23. package/dist/commands/agents.js +1101 -0
  24. package/dist/commands/agentsSdk.generated.js +7 -0
  25. package/dist/commands/ask.js +0 -3
  26. package/dist/commands/capture.js +0 -2
  27. package/dist/commands/createTicket.js +0 -10
  28. package/dist/commands/doctor.js +53 -120
  29. package/dist/commands/evals.js +187 -0
  30. package/dist/commands/inbox.js +0 -2
  31. package/dist/commands/library.js +0 -3
  32. package/dist/commands/pack.js +573 -0
  33. package/dist/commands/ping.js +0 -2
  34. package/dist/commands/pull.js +6 -10
  35. package/dist/commands/push.js +2 -12
  36. package/dist/commands/search.js +0 -4
  37. package/dist/commands/send.js +0 -5
  38. package/dist/commands/share.js +0 -4
  39. package/dist/commands/shared.js +0 -35
  40. package/dist/commands/traces.js +344 -0
  41. package/dist/commands/tracesLabel.js +348 -0
  42. package/dist/configDir.js +18 -11
  43. package/dist/connect.js +55 -118
  44. package/dist/connectFlow.js +35 -9
  45. package/dist/copilotHooks.js +391 -0
  46. package/dist/copilotInstallation.js +64 -0
  47. package/dist/cursorHooks.js +38 -30
  48. package/dist/cursorLifecycle.js +109 -0
  49. package/dist/detection.js +0 -30
  50. package/dist/harnessDirs.js +77 -0
  51. package/dist/hook.js +256 -445
  52. package/dist/inboxFormat.js +0 -24
  53. package/dist/launchContext.js +150 -0
  54. package/dist/launcher.js +168 -0
  55. package/dist/limitEvent.js +44 -13
  56. package/dist/limitEventReporter.js +1 -1
  57. package/dist/managedPi.js +256 -0
  58. package/dist/mcp.js +5 -384
  59. package/dist/nativeSteering.js +24 -0
  60. package/dist/packs/codie.js +182 -0
  61. package/dist/packs/harnesses.js +411 -0
  62. package/dist/packs/hookGate.js +256 -0
  63. package/dist/packs/install.js +286 -0
  64. package/dist/packs/manifest.js +126 -0
  65. package/dist/packs/paths.js +81 -0
  66. package/dist/packs/shim.js +214 -0
  67. package/dist/packs/store.js +155 -0
  68. package/dist/packs/sync.js +170 -0
  69. package/dist/piHooks.js +216 -0
  70. package/dist/piRuntime.js +120 -0
  71. package/dist/repoResolver.js +0 -19
  72. package/dist/secret.js +0 -3
  73. package/dist/selfUpdate.js +376 -0
  74. package/dist/skillMarker.js +23 -0
  75. package/dist/subagents.js +135 -0
  76. package/dist/teamSkillContext.js +10 -0
  77. package/dist/transcriptModels.js +205 -0
  78. package/dist/upgradeNudge.js +0 -30
  79. package/dist/utils.js +502 -828
  80. package/dist/version.js +0 -10
  81. package/dist/versionCheck.js +0 -33
  82. package/package.json +8 -9
  83. package/dist/backup/cache.d.ts +0 -14
  84. package/dist/backup/match.d.ts +0 -2
  85. package/dist/backup/run.d.ts +0 -25
  86. package/dist/captureExclusions.d.ts +0 -30
  87. package/dist/captureLog.d.ts +0 -20
  88. package/dist/captureReadiness.d.ts +0 -65
  89. package/dist/cli.d.ts +0 -16
  90. package/dist/codexHookTrust.d.ts +0 -34
  91. package/dist/codie.d.ts +0 -2
  92. package/dist/codieLauncher.d.ts +0 -53
  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/commands/ask.d.ts +0 -1
  98. package/dist/commands/capture.d.ts +0 -14
  99. package/dist/commands/createTicket.d.ts +0 -27
  100. package/dist/commands/delete.d.ts +0 -1
  101. package/dist/commands/doctor.d.ts +0 -1
  102. package/dist/commands/inbox.d.ts +0 -3
  103. package/dist/commands/library.d.ts +0 -2
  104. package/dist/commands/note.d.ts +0 -1
  105. package/dist/commands/ping.d.ts +0 -1
  106. package/dist/commands/promote.d.ts +0 -1
  107. package/dist/commands/promote.js +0 -53
  108. package/dist/commands/pull.d.ts +0 -2
  109. package/dist/commands/push.d.ts +0 -33
  110. package/dist/commands/react.d.ts +0 -2
  111. package/dist/commands/react.js +0 -40
  112. package/dist/commands/reverseTicket.d.ts +0 -2
  113. package/dist/commands/reverseTicket.js +0 -477
  114. package/dist/commands/search.d.ts +0 -2
  115. package/dist/commands/security.d.ts +0 -1
  116. package/dist/commands/security.js +0 -156
  117. package/dist/commands/send.d.ts +0 -2
  118. package/dist/commands/share.d.ts +0 -2
  119. package/dist/commands/shared.d.ts +0 -64
  120. package/dist/configDir.d.ts +0 -1
  121. package/dist/connect.d.ts +0 -1
  122. package/dist/connectFlow.d.ts +0 -13
  123. package/dist/cursorHooks.d.ts +0 -23
  124. package/dist/detection.d.ts +0 -30
  125. package/dist/hook.d.ts +0 -6
  126. package/dist/inboxFormat.d.ts +0 -38
  127. package/dist/limitEvent.d.ts +0 -16
  128. package/dist/limitEventReporter.d.ts +0 -21
  129. package/dist/mcp.d.ts +0 -12
  130. package/dist/prUrl.d.ts +0 -9
  131. package/dist/prUrl.js +0 -33
  132. package/dist/repoResolver.d.ts +0 -17
  133. package/dist/secret.d.ts +0 -1
  134. package/dist/security.d.ts +0 -102
  135. package/dist/security.js +0 -437
  136. package/dist/securityDeepScan.d.ts +0 -41
  137. package/dist/securityDeepScan.js +0 -248
  138. package/dist/securityDoctor.d.ts +0 -32
  139. package/dist/securityDoctor.js +0 -63
  140. package/dist/securityFeature.d.ts +0 -5
  141. package/dist/securityFeature.js +0 -7
  142. package/dist/securityInstall.d.ts +0 -63
  143. package/dist/securityInstall.js +0 -239
  144. package/dist/securityInventory.d.ts +0 -54
  145. package/dist/securityInventory.js +0 -556
  146. package/dist/securityPilot.d.ts +0 -19
  147. package/dist/securityPilot.js +0 -61
  148. package/dist/securityPolicy.d.ts +0 -33
  149. package/dist/securityPolicy.js +0 -188
  150. package/dist/securitySession.d.ts +0 -6
  151. package/dist/securitySession.js +0 -72
  152. package/dist/upgradeNudge.d.ts +0 -25
  153. package/dist/utils.d.ts +0 -342
  154. package/dist/version.d.ts +0 -1
  155. package/dist/versionCheck.d.ts +0 -68
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transcriptRecords = transcriptRecords;
4
+ exports.parseTranscriptModels = parseTranscriptModels;
5
+ exports.totalModelTokens = totalModelTokens;
6
+ const positive = (n) => typeof n === "number" && Number.isFinite(n) ? Math.max(0, n) : 0;
7
+ const empty = (model) => ({
8
+ model,
9
+ requests: 0,
10
+ inputTokens: 0,
11
+ outputTokens: 0,
12
+ cacheReadTokens: 0,
13
+ cacheCreationTokens: 0,
14
+ });
15
+ function* transcriptRecords(content, source) {
16
+ if (content.trimStart().startsWith("[") ||
17
+ ((source === "opencode" || source === "desktop") &&
18
+ content.trimStart().startsWith("{"))) {
19
+ try {
20
+ const parsed = JSON.parse(content);
21
+ const list = Array.isArray(parsed) ? parsed : parsed?.data;
22
+ if (Array.isArray(list)) {
23
+ yield* list;
24
+ return;
25
+ }
26
+ }
27
+ catch {
28
+ }
29
+ }
30
+ let start = 0;
31
+ while (start < content.length) {
32
+ const newline = content.indexOf("\n", start);
33
+ const end = newline < 0 ? content.length : newline;
34
+ try {
35
+ yield JSON.parse(content.slice(start, end));
36
+ }
37
+ catch {
38
+ }
39
+ start = end + 1;
40
+ }
41
+ }
42
+ function parseTranscriptModels(content, source) {
43
+ const buckets = new Map();
44
+ const messages = new Map();
45
+ const tokenEvidence = new Set();
46
+ let model = "Unattributed";
47
+ let previous = {
48
+ inputTokens: 0,
49
+ outputTokens: 0,
50
+ cacheReadTokens: 0,
51
+ cacheCreationTokens: 0,
52
+ };
53
+ let previousReasoning = 0;
54
+ let index = 0;
55
+ for (const record of transcriptRecords(content, source)) {
56
+ const event = record;
57
+ index++;
58
+ if (!event || typeof event !== "object")
59
+ continue;
60
+ let usage = null;
61
+ let messageId = String(index);
62
+ if (source === "codex") {
63
+ if (event.type === "turn_context" &&
64
+ typeof event.payload?.model === "string")
65
+ model = event.payload.model;
66
+ if (event.type !== "event_msg" || event.payload?.type !== "token_count")
67
+ continue;
68
+ const raw = event.payload?.info?.total_token_usage;
69
+ if (!raw)
70
+ continue;
71
+ const total = {
72
+ inputTokens: Math.max(0, positive(raw.input_tokens) - positive(raw.cached_input_tokens)),
73
+ outputTokens: positive(raw.output_tokens),
74
+ cacheReadTokens: positive(raw.cached_input_tokens),
75
+ cacheCreationTokens: 0,
76
+ };
77
+ usage = { ...empty(model), requests: 1 };
78
+ const reset = positive(raw.input_tokens) <
79
+ previous.inputTokens + previous.cacheReadTokens ||
80
+ total.outputTokens < previous.outputTokens;
81
+ for (const key of [
82
+ "inputTokens",
83
+ "outputTokens",
84
+ "cacheReadTokens",
85
+ "cacheCreationTokens",
86
+ ])
87
+ usage[key] = reset
88
+ ? total[key]
89
+ : Math.max(0, total[key] - previous[key]);
90
+ const reasoning = typeof raw.reasoning_output_tokens === "number" &&
91
+ raw.reasoning_output_tokens >= 0 &&
92
+ raw.reasoning_output_tokens <= total.outputTokens
93
+ ? raw.reasoning_output_tokens
94
+ : undefined;
95
+ if (reasoning !== undefined &&
96
+ (reset || previousReasoning !== undefined)) {
97
+ const delta = reset
98
+ ? reasoning
99
+ : Math.max(0, reasoning - previousReasoning);
100
+ if (delta <= usage.outputTokens)
101
+ usage.reasoningTokens = delta;
102
+ }
103
+ previousReasoning = reasoning;
104
+ previous = total;
105
+ if (!totalModelTokens(usage))
106
+ continue;
107
+ }
108
+ else if (event.info?.role === "assistant") {
109
+ const info = event.info, tokens = info.tokens;
110
+ if (!tokens)
111
+ continue;
112
+ const id = typeof info.modelID === "string" ? info.modelID : "Unattributed";
113
+ model =
114
+ info.providerID && id !== "Unattributed"
115
+ ? `${info.providerID}/${id}`
116
+ : id;
117
+ usage = {
118
+ ...empty(model),
119
+ requests: 1,
120
+ inputTokens: positive(tokens.input),
121
+ outputTokens: positive(tokens.output) + positive(tokens.reasoning),
122
+ ...(typeof tokens.reasoning === "number"
123
+ ? { reasoningTokens: positive(tokens.reasoning) }
124
+ : {}),
125
+ cacheReadTokens: positive(tokens.cache?.read),
126
+ cacheCreationTokens: positive(tokens.cache?.write),
127
+ ...(typeof info.cost === "number"
128
+ ? {
129
+ reportedCostUsd: positive(info.cost),
130
+ ...(source === "desktop" ? { costUsd: positive(info.cost) } : {}),
131
+ }
132
+ : {}),
133
+ };
134
+ messageId = info.id ?? messageId;
135
+ }
136
+ else {
137
+ const message = event.message;
138
+ if (!message?.usage)
139
+ continue;
140
+ model =
141
+ typeof message.model === "string" ? message.model : "Unattributed";
142
+ const raw = message.usage;
143
+ const requests = event.requests;
144
+ usage = {
145
+ ...empty(model),
146
+ requests: typeof requests === "number" && Number.isFinite(requests) ? Math.max(0, requests) : 1,
147
+ inputTokens: positive(raw.input_tokens),
148
+ outputTokens: positive(raw.output_tokens),
149
+ cacheReadTokens: positive(raw.cache_read_input_tokens),
150
+ cacheCreationTokens: positive(raw.cache_creation_input_tokens),
151
+ };
152
+ messageId = message.id ?? event.uuid ?? messageId;
153
+ }
154
+ if (source === "copilot" && event.type === "copilot.usage")
155
+ tokenEvidence.add(usage.model);
156
+ if (!usage.model.trim() || usage.model.startsWith("<"))
157
+ continue;
158
+ messages.set(messageId, usage);
159
+ }
160
+ const incompleteCosts = new Set();
161
+ const incompleteReasoning = new Set();
162
+ const incompleteReportedCosts = new Set();
163
+ for (const usage of messages.values()) {
164
+ const key = buckets.has(usage.model) || buckets.size < 63
165
+ ? usage.model
166
+ : "Unattributed";
167
+ const bucket = buckets.get(key) ?? empty(key);
168
+ for (const field of [
169
+ "requests",
170
+ "inputTokens",
171
+ "outputTokens",
172
+ "cacheReadTokens",
173
+ "cacheCreationTokens",
174
+ ])
175
+ bucket[field] += usage[field];
176
+ if (usage.reasoningTokens !== undefined)
177
+ bucket.reasoningTokens =
178
+ (bucket.reasoningTokens ?? 0) + usage.reasoningTokens;
179
+ else
180
+ incompleteReasoning.add(key);
181
+ if (usage.reportedCostUsd !== undefined)
182
+ bucket.reportedCostUsd =
183
+ (bucket.reportedCostUsd ?? 0) + usage.reportedCostUsd;
184
+ else
185
+ incompleteReportedCosts.add(key);
186
+ if (usage.costUsd !== undefined)
187
+ bucket.costUsd = (bucket.costUsd ?? 0) + usage.costUsd;
188
+ else
189
+ incompleteCosts.add(key);
190
+ buckets.set(key, bucket);
191
+ }
192
+ for (const key of incompleteReportedCosts)
193
+ delete buckets.get(key).reportedCostUsd;
194
+ for (const key of incompleteCosts)
195
+ delete buckets.get(key).costUsd;
196
+ for (const key of incompleteReasoning)
197
+ delete buckets.get(key).reasoningTokens;
198
+ return [...buckets.values()].map(row => source === "copilot" && !tokenEvidence.has(row.model) ? { ...row, tokensAvailable: false } : row);
199
+ }
200
+ function totalModelTokens(row) {
201
+ return (row.inputTokens +
202
+ row.outputTokens +
203
+ row.cacheReadTokens +
204
+ row.cacheCreationTokens);
205
+ }
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- // Client-side "you're outdated" warning. Prints at the top of connect/doctor
3
- // when there's a newer `codiedev` published on npm. Pure helpers tested in
4
- // __tests__/versionCheck.test.ts; this module does the IO (registry fetch +
5
- // disk cache) and is exercised by manual smoke.
6
- //
7
- // Cache lives at <codiedevStateDir()>/.update-cache.json (~/.codiedev by
8
- // default; ~/.codiedev-desktop under CODIEDEV_CONFIG_DIR). 24h TTL — long
9
- // enough that the registry isn't hit on every command, short enough that
10
- // newly-published versions surface the day after release.
11
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
3
  if (k2 === undefined) k2 = k;
13
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -75,7 +66,6 @@ function writeCache(entry) {
75
66
  fs.writeFileSync(CACHE_PATH, JSON.stringify(entry), "utf8");
76
67
  }
77
68
  catch {
78
- // ignore — cache is best-effort
79
69
  }
80
70
  }
81
71
  async function fetchLatestFromNpm() {
@@ -96,12 +86,6 @@ async function fetchLatestFromNpm() {
96
86
  return null;
97
87
  }
98
88
  }
99
- /**
100
- * Fail-silent — never throws, never blocks on network. If the registry is
101
- * unreachable or the cache is corrupt, the warning just doesn't print. The
102
- * worst outcome is "user keeps running an old version" — same as before
103
- * this feature existed.
104
- */
105
89
  async function maybePrintUpgradeNudge() {
106
90
  const now = Date.now();
107
91
  const cache = readCache();
@@ -126,9 +110,6 @@ async function maybePrintUpgradeNudge() {
126
110
  }
127
111
  }
128
112
  const OFFER_CACHE_NAME = ".update-offer-cache.json";
129
- // This runs before the harness paints, so the timeout is startup latency the
130
- // user feels. A missed check costs nothing; the next stale-cache launch tries
131
- // again.
132
113
  const OFFER_FETCH_TIMEOUT_MS = 1500;
133
114
  const UPGRADE_TIMEOUT_MS = 120_000;
134
115
  function offerCachePath(env) {
@@ -152,8 +133,6 @@ function readOfferCache(env) {
152
133
  return null;
153
134
  }
154
135
  }
155
- // If this cannot be persisted, the whole feature stays off. Without memory,
156
- // every launch would refetch and re-nag on ephemeral or read-only filesystems.
157
136
  function writeOfferCache(entry, env) {
158
137
  try {
159
138
  const target = offerCachePath(env);
@@ -190,8 +169,6 @@ async function fetchLatest(fetchImpl) {
190
169
  return null;
191
170
  }
192
171
  }
193
- // Single-keypress y/n prompt. EOF, Ctrl-C, lost raw mode, and tty errors all
194
- // default to no so update handling can never strand the launcher.
195
172
  function promptYesNo(question) {
196
173
  return new Promise((resolve) => {
197
174
  const stdin = process.stdin;
@@ -218,7 +195,6 @@ function promptYesNo(question) {
218
195
  stdin.setRawMode(Boolean(wasRaw));
219
196
  }
220
197
  catch {
221
- // Best-effort; the engine resets the tty when it starts.
222
198
  }
223
199
  stdin.pause();
224
200
  process.stdout.write(`${yes ? "y" : "n"}\n`);
@@ -239,11 +215,6 @@ function runUpgrade() {
239
215
  });
240
216
  return !result.error && result.status === 0;
241
217
  }
242
- /**
243
- * Prompt-capable sibling of maybePrintUpgradeNudge. Call this before handing
244
- * the terminal to a TUI. A successful upgrade relaunches the fresh CLI and
245
- * tells the stale caller to stop rather than continuing with old modules.
246
- */
247
218
  async function maybeOfferUpgrade(opts = {}) {
248
219
  const env = opts.env ?? process.env;
249
220
  const argv = opts.argv ?? process.argv;
@@ -257,7 +228,6 @@ async function maybeOfferUpgrade(opts = {}) {
257
228
  let fetchedAt = cache?.fetchedAt ?? 0;
258
229
  const promptedAt = cache?.promptedAt ?? 0;
259
230
  if (!cache || nowMs - cache.fetchedAt > CACHE_TTL_MS) {
260
- // Probe writability before paying the network cost.
261
231
  if (!writeOfferCache(cache ?? { latest: null, fetchedAt: 0, promptedAt: 0 }, env)) {
262
232
  return { relaunched: false };
263
233
  }