codiedev 0.10.0-beta.3 → 0.10.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/assets/tui-brand-plugin.tsx +73 -0
- package/dist/backup/cache.js +1 -5
- package/dist/backup/match.js +0 -6
- package/dist/backup/run.js +3 -35
- package/dist/captureExclusions.js +0 -12
- package/dist/captureLog.js +0 -28
- package/dist/captureReadiness.js +0 -58
- package/dist/captureSignals.js +66 -3
- package/dist/cli.js +41 -18
- package/dist/codexHookTrust.js +61 -5
- package/dist/codexLimitScan.js +2 -109
- package/dist/codie.js +41 -56
- package/dist/codieBrandInstall.js +80 -0
- package/dist/codieLauncher.js +59 -59
- package/dist/codieRuntime.js +19 -23
- package/dist/codieRuntimeInstall.js +108 -23
- package/dist/codieStartup.js +0 -3
- package/dist/codieUsage.js +181 -0
- package/dist/commands/ask.js +0 -3
- package/dist/commands/capture.js +0 -2
- package/dist/commands/createTicket.js +0 -10
- package/dist/commands/doctor.js +41 -82
- package/dist/commands/inbox.js +0 -2
- package/dist/commands/library.js +0 -3
- package/dist/commands/pack.js +573 -0
- package/dist/commands/ping.js +0 -2
- package/dist/commands/pull.js +6 -10
- package/dist/commands/push.js +2 -12
- package/dist/commands/react.js +0 -2
- package/dist/commands/reverseTicket.js +0 -33
- package/dist/commands/search.js +0 -4
- package/dist/commands/send.js +0 -5
- package/dist/commands/share.js +0 -4
- package/dist/commands/shared.js +0 -35
- package/dist/commands/traces.js +280 -0
- package/dist/configDir.js +0 -10
- package/dist/connect.js +21 -77
- package/dist/connectFlow.js +0 -9
- package/dist/copilotHooks.js +395 -0
- package/dist/copilotInstallation.js +64 -0
- package/dist/cursorHooks.js +40 -17
- package/dist/cursorLifecycle.js +109 -0
- package/dist/detection.js +0 -30
- package/dist/harnessDirs.js +73 -0
- package/dist/hook.js +193 -316
- package/dist/inboxFormat.js +0 -24
- package/dist/launchContext.js +150 -0
- package/dist/launcher.js +140 -0
- package/dist/limitEvent.js +41 -35
- package/dist/limitEventReporter.js +1 -1
- package/dist/mcp.js +3 -77
- package/dist/nativeSteering.js +24 -0
- package/dist/packs/codie.js +182 -0
- package/dist/packs/harnesses.js +374 -0
- package/dist/packs/hookGate.js +256 -0
- package/dist/packs/install.js +285 -0
- package/dist/packs/manifest.js +126 -0
- package/dist/packs/paths.js +81 -0
- package/dist/packs/shim.js +214 -0
- package/dist/packs/store.js +155 -0
- package/dist/packs/sync.js +170 -0
- package/dist/prUrl.js +0 -5
- package/dist/repoResolver.js +0 -19
- package/dist/secret.js +0 -3
- package/dist/security.js +0 -20
- package/dist/securityDeepScan.js +1 -14
- package/dist/securityDoctor.js +0 -2
- package/dist/securityFeature.js +0 -1
- package/dist/securityInstall.js +6 -13
- package/dist/securityInventory.js +23 -13
- package/dist/securityPilot.js +0 -2
- package/dist/securityPolicy.js +0 -7
- package/dist/selfUpdate.js +331 -0
- package/dist/skillMarker.js +23 -0
- package/dist/subagents.js +135 -0
- package/dist/teamSkillContext.js +10 -0
- package/dist/transcriptModels.js +6 -8
- package/dist/upgradeNudge.js +0 -30
- package/dist/utils.js +286 -733
- package/dist/version.js +0 -10
- package/dist/versionCheck.js +0 -33
- package/package.json +8 -7
- package/dist/backup/cache.d.ts +0 -14
- package/dist/backup/match.d.ts +0 -2
- package/dist/backup/run.d.ts +0 -25
- package/dist/captureExclusions.d.ts +0 -30
- package/dist/captureLog.d.ts +0 -20
- package/dist/captureReadiness.d.ts +0 -65
- package/dist/captureSignals.d.ts +0 -19
- package/dist/cli.d.ts +0 -16
- package/dist/codexHookTrust.d.ts +0 -34
- package/dist/codexLimitScan.d.ts +0 -64
- package/dist/codie.d.ts +0 -2
- package/dist/codieLauncher.d.ts +0 -53
- package/dist/codieRuntime.d.ts +0 -29
- package/dist/codieRuntimeInstall.d.ts +0 -28
- package/dist/codieStartup.d.ts +0 -26
- package/dist/commands/ask.d.ts +0 -1
- package/dist/commands/capture.d.ts +0 -14
- package/dist/commands/createTicket.d.ts +0 -27
- package/dist/commands/delete.d.ts +0 -1
- package/dist/commands/doctor.d.ts +0 -1
- package/dist/commands/inbox.d.ts +0 -3
- package/dist/commands/library.d.ts +0 -2
- package/dist/commands/note.d.ts +0 -1
- package/dist/commands/ping.d.ts +0 -1
- package/dist/commands/promote.d.ts +0 -1
- package/dist/commands/pull.d.ts +0 -2
- package/dist/commands/push.d.ts +0 -33
- package/dist/commands/react.d.ts +0 -2
- package/dist/commands/reverseTicket.d.ts +0 -2
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/security.d.ts +0 -1
- package/dist/commands/send.d.ts +0 -2
- package/dist/commands/share.d.ts +0 -2
- package/dist/commands/shared.d.ts +0 -64
- package/dist/configDir.d.ts +0 -1
- package/dist/connect.d.ts +0 -1
- package/dist/connectFlow.d.ts +0 -13
- package/dist/cursorHooks.d.ts +0 -23
- package/dist/detection.d.ts +0 -30
- package/dist/hook.d.ts +0 -6
- package/dist/inboxFormat.d.ts +0 -38
- package/dist/limitEvent.d.ts +0 -16
- package/dist/limitEventReporter.d.ts +0 -21
- package/dist/mcp.d.ts +0 -12
- package/dist/prUrl.d.ts +0 -9
- package/dist/repoResolver.d.ts +0 -17
- package/dist/secret.d.ts +0 -1
- package/dist/security.d.ts +0 -102
- package/dist/securityDeepScan.d.ts +0 -41
- package/dist/securityDoctor.d.ts +0 -32
- package/dist/securityFeature.d.ts +0 -5
- package/dist/securityInstall.d.ts +0 -63
- package/dist/securityInventory.d.ts +0 -54
- package/dist/securityPilot.d.ts +0 -19
- package/dist/securityPolicy.d.ts +0 -33
- package/dist/securitySession.d.ts +0 -6
- package/dist/transcriptModels.d.ts +0 -18
- package/dist/upgradeNudge.d.ts +0 -25
- package/dist/utils.d.ts +0 -346
- package/dist/version.d.ts +0 -1
- package/dist/versionCheck.d.ts +0 -68
|
@@ -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
|
+
}
|
package/dist/transcriptModels.js
CHANGED
|
@@ -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
|
-
|
|
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 +
|
package/dist/upgradeNudge.js
CHANGED
|
@@ -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
|
}
|