sprag-cli 3.62.0 → 3.64.0

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.
@@ -149,11 +149,12 @@ function readTailLines(path) {
149
149
  * null when the reply is fine (or cannot be judged), otherwise the measured
150
150
  * ratios so a caller can report them. Never throws.
151
151
  */
152
- function checkReplyLanguage(transcriptPath) {
152
+ function checkReplyLanguage(transcriptPath, { parseTurn = lastTurn, reply } = {}) {
153
153
  try {
154
154
  if (!transcriptPath) return null;
155
- const turn = lastTurn(readTailLines(transcriptPath));
155
+ const turn = parseTurn(readTailLines(transcriptPath));
156
156
  if (!turn) return null;
157
+ if (typeof reply === 'string') turn.reply = reply;
157
158
  if (ENGLISH_REQUESTED.test(turn.prompt)) return null;
158
159
  if (!isKoreanPrompt(turn.prompt) || !isEnglishReply(turn.reply)) return null;
159
160
  const u = letterCounts(turn.prompt);
@@ -0,0 +1,37 @@
1
+ import { updateStatus, maybeSpawnUpdateCheck, readUpdateState, updateCheckDisabled, SESSION_START_CHECK_INTERVAL_MS } from './update-check.js';
2
+ import { debug } from './debug.js';
3
+
4
+ /** Shared by terminal renders; registry I/O stays in the detached checker. */
5
+ export function readUpdateChip(version, { refresh = true, ...opts } = {}) {
6
+ try {
7
+ if (refresh) maybeSpawnUpdateCheck(version, opts);
8
+ const status = updateStatus(version, opts);
9
+ const checkedAt = updateCheckDisabled() ? null : (Number(readUpdateState().checkedAt) || null);
10
+ return { ...status, checkedAt };
11
+ } catch (e) {
12
+ debug('update-check:chip', e);
13
+ return null;
14
+ }
15
+ }
16
+
17
+ export function upgradeInstructions(agent = 'claude') {
18
+ return agent === 'codex'
19
+ ? ['npm i -g sprag-cli --ignore-scripts', 'sprag install --agent codex']
20
+ : ['sprag upgrade'];
21
+ }
22
+
23
+ /** The model must obtain consent; a hook never installs a package itself. */
24
+ export function updateOffer(version, { agent = 'claude', lang = 'en', ...opts } = {}) {
25
+ const u = readUpdateChip(version, { intervalMs: SESSION_START_CHECK_INTERVAL_MS, ...opts });
26
+ if (!u?.available || u.dismissed) return null;
27
+ const ko = lang === 'ko';
28
+ return [
29
+ ko ? `[sprag update] 새 버전이 나와 있습니다: v${u.current} → ${u.latest}.`
30
+ : `[sprag update] A newer version is available: v${u.current} → ${u.latest}.`,
31
+ ...(u.highlights || []).slice(0, 3).map((note) => ` - ${note}`),
32
+ ko ? '사용자에게 변경 내용을 알리고 업그레이드할지 물어보십시오. 승낙한 경우에만 아래 명령을 실행하십시오.'
33
+ : 'Show the changes and ask the user whether to upgrade. Run these commands only if they agree; do not install without asking.',
34
+ ...upgradeInstructions(agent).map((command) => ` ${command}`),
35
+ ` sprag update-check --dismiss${agent === 'codex' ? ' --agent codex' : ''}`,
36
+ ].join('\n');
37
+ }