@pugi/cli 0.1.0-beta.87 → 0.1.0-beta.89
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/CHANGELOG.md +36 -0
- package/LICENSE +1 -1
- package/dist/core/agents/registry.js +1 -1
- package/dist/core/auth/env-provider.js +1 -1
- package/dist/core/checkpoints/shadow-git.js +1 -1
- package/dist/core/context/compaction.js +1 -1
- package/dist/core/context/markdown-traverse.js +1 -1
- package/dist/core/credentials.js +1 -1
- package/dist/core/denial-tracking/state.js +1 -1
- package/dist/core/edits/fuzzy-ladder.js +1 -1
- package/dist/core/edits/layer-a-fuzzy-apply.js +1 -1
- package/dist/core/engine/anvil-client.js +76 -2
- package/dist/core/engine/native-pugi.js +1 -1
- package/dist/core/engine/tool-bridge.js +436 -0
- package/dist/core/hooks/events.js +3 -1
- package/dist/core/hooks/registry.js +3 -0
- package/dist/core/hooks/worktree-events.js +158 -0
- package/dist/core/lsp/client.js +453 -0
- package/dist/core/lsp/server-detect.js +173 -0
- package/dist/core/lsp/symbol-cache.js +162 -0
- package/dist/core/lsp/symbol-tools.js +296 -4
- package/dist/core/mcp/server-tools.js +1 -1
- package/dist/core/mcp/server.js +1 -1
- package/dist/core/memory/secret-scanner.js +6 -6
- package/dist/core/onboarding/ensure-initialized.js +1 -1
- package/dist/core/plans/plan-artifact.js +2 -2
- package/dist/core/repl/ask.js +1 -1
- package/dist/core/repl/cap-warning.js +1 -1
- package/dist/core/repl/session.js +3 -3
- package/dist/core/repl/slash-commands.js +1 -1
- package/dist/core/routing/pre-flight-estimator.js +1 -1
- package/dist/core/settings.js +38 -0
- package/dist/core/worktree/include-parser.js +249 -0
- package/dist/index.js +8 -0
- package/dist/runtime/cli.js +176 -28
- package/dist/runtime/commands/agents.js +1 -1
- package/dist/runtime/commands/config.js +41 -7
- package/dist/runtime/commands/hooks.js +3 -0
- package/dist/runtime/commands/review-consensus.js +1 -1
- package/dist/runtime/sigint-guard.js +272 -0
- package/dist/runtime/version.js +1 -1
- package/dist/runtime/worktree-bootstrap.js +579 -0
- package/dist/skills/bundled/batch.js +2 -2
- package/dist/skills/bundled/index.js +3 -3
- package/dist/skills/bundled/loop.js +2 -2
- package/dist/skills/bundled/remember.js +1 -1
- package/dist/skills/bundled/simplify.js +1 -1
- package/dist/skills/bundled/skillify.js +2 -2
- package/dist/skills/bundled/stuck.js +1 -1
- package/dist/skills/bundled/verify.js +2 -2
- package/dist/testing/vcr.js +2 -2
- package/dist/tools/ask-user-question.js +66 -0
- package/dist/tools/bash.js +2 -2
- package/dist/tools/lsp-tools.js +377 -1
- package/dist/tools/powershell.js +1 -1
- package/dist/tools/registry.js +23 -0
- package/dist/tui/ask-user-question-chips.js +257 -0
- package/dist/tui/input-box.js +1 -1
- package/dist/tui/render.js +1 -1
- package/dist/tui/repl.js +1 -1
- package/dist/tui/status-bar.js +1 -1
- package/dist/tui/update-banner.js +1 -1
- package/dist/tui/welcome-data.js +4 -4
- package/package.json +4 -3
- package/test/scenarios/compact-force.scenario.txt +3 -2
- package/test/scenarios/identity.scenario.txt +6 -5
- package/test/scenarios/persona-handoff.scenario.txt +2 -1
- package/test/scenarios/walkback.scenario.txt +6 -6
|
@@ -39,9 +39,41 @@ const configSchema = z
|
|
|
39
39
|
privacy: z.enum(['local-only', 'metadata', 'full']).optional(),
|
|
40
40
|
model: z.string().nullable().optional(),
|
|
41
41
|
preferredEndpoint: z.string().url().optional(),
|
|
42
|
+
// PUGI-260 — persistent default for the 1M context tier opt-in.
|
|
43
|
+
// `pugi config set contextTier 1m` (or the dotted form
|
|
44
|
+
// `context.tier 1m`) writes this; per-invocation `--context-tier=...`
|
|
45
|
+
// flags override it at request time. Closed enum mirrors the CLI
|
|
46
|
+
// flag и the admin-api DTO so a typo here surfaces as a Zod parse
|
|
47
|
+
// error при load, not a silent fallback. Stored on the flat user-
|
|
48
|
+
// level config (~/.pugi/config.json) so all workspaces inherit the
|
|
49
|
+
// same default — operators с consistent long-context workloads
|
|
50
|
+
// (large monorepos, audits) set it once instead of remembering к
|
|
51
|
+
// pass --context-tier=1m on every dispatch.
|
|
52
|
+
contextTier: z.enum(['1m', 'standard']).optional(),
|
|
42
53
|
})
|
|
43
54
|
.strict();
|
|
44
|
-
const CONFIG_KEYS = [
|
|
55
|
+
const CONFIG_KEYS = [
|
|
56
|
+
'permissionMode',
|
|
57
|
+
'privacy',
|
|
58
|
+
'model',
|
|
59
|
+
'preferredEndpoint',
|
|
60
|
+
// PUGI-260 — exposed на `pugi config list` so operators see the
|
|
61
|
+
// current default. Hidden synonym `context.tier` accepted by
|
|
62
|
+
// runConfigSet / runConfigGet for a dotted-key familiar UX.
|
|
63
|
+
'contextTier',
|
|
64
|
+
];
|
|
65
|
+
/**
|
|
66
|
+
* PUGI-260: legacy / nested key aliasing. `pugi config set context.tier 1m`
|
|
67
|
+
* is the documented form в the feat doc; we normalise it onto the flat
|
|
68
|
+
* `contextTier` key before the strict-schema validation так future
|
|
69
|
+
* settings.json migrations keep one canonical key. Mirrors the
|
|
70
|
+
* legacy privacy-mode aliasing that already lives in the file.
|
|
71
|
+
*/
|
|
72
|
+
function normaliseConfigKey(raw) {
|
|
73
|
+
if (raw === 'context.tier')
|
|
74
|
+
return 'contextTier';
|
|
75
|
+
return raw;
|
|
76
|
+
}
|
|
45
77
|
export async function runConfigCommand(args, ctx) {
|
|
46
78
|
const sub = args[0];
|
|
47
79
|
if (!sub || sub === '--help' || sub === '-h') {
|
|
@@ -178,25 +210,27 @@ function isConfigKey(value) {
|
|
|
178
210
|
return CONFIG_KEYS.includes(value);
|
|
179
211
|
}
|
|
180
212
|
function runConfigGet(args, ctx) {
|
|
181
|
-
const
|
|
182
|
-
if (!
|
|
213
|
+
const rawKey = args[0];
|
|
214
|
+
if (!rawKey)
|
|
183
215
|
throw new Error('pugi config get requires a key.');
|
|
216
|
+
const key = normaliseConfigKey(rawKey);
|
|
184
217
|
if (!isConfigKey(key)) {
|
|
185
|
-
throw new Error(`Unknown config key "${
|
|
218
|
+
throw new Error(`Unknown config key "${rawKey}". Allowed: ${CONFIG_KEYS.join(', ')}.`);
|
|
186
219
|
}
|
|
187
220
|
const config = readConfig();
|
|
188
221
|
const value = config[key] ?? null;
|
|
189
222
|
ctx.writeOutput({ command: 'config.get', key, value }, value === null || value === undefined ? `${key} = (unset)` : `${key} = ${String(value)}`);
|
|
190
223
|
}
|
|
191
224
|
function runConfigSet(args, ctx) {
|
|
192
|
-
const
|
|
225
|
+
const rawKey = args[0];
|
|
193
226
|
const value = args.slice(1).join(' ');
|
|
194
|
-
if (!
|
|
227
|
+
if (!rawKey)
|
|
195
228
|
throw new Error('pugi config set requires a key.');
|
|
196
229
|
if (value.length === 0)
|
|
197
230
|
throw new Error('pugi config set requires a value.');
|
|
231
|
+
const key = normaliseConfigKey(rawKey);
|
|
198
232
|
if (!isConfigKey(key)) {
|
|
199
|
-
throw new Error(`Unknown config key "${
|
|
233
|
+
throw new Error(`Unknown config key "${rawKey}". Allowed: ${CONFIG_KEYS.join(', ')}.`);
|
|
200
234
|
}
|
|
201
235
|
const current = readConfig();
|
|
202
236
|
// Build the candidate and validate via the schema so an invalid value
|
|
@@ -101,6 +101,9 @@ function runList(ctx, flags) {
|
|
|
101
101
|
SubagentStop: [],
|
|
102
102
|
PreCompact: [],
|
|
103
103
|
Notification: [],
|
|
104
|
+
// PUGI-487 - worktree lifecycle events.
|
|
105
|
+
WorktreeCreate: [],
|
|
106
|
+
WorktreeRemove: [],
|
|
104
107
|
};
|
|
105
108
|
for (const event of ALL_HOOK_EVENTS_V2) {
|
|
106
109
|
perEvent[event] = config.list(event).map((entry) => ({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `pugi review --consensus` — customer-facing triple-review .
|
|
3
3
|
*
|
|
4
|
-
* The differentiator: the upstream tool ships single-Claude review,
|
|
4
|
+
* The differentiator: the upstream tool ships single-Claude review, peer CLI
|
|
5
5
|
* ships single-GPT review, Gemini CLI ships single-Gemini review. Pugi
|
|
6
6
|
* ships a 3-model consensus gate as a first-class command so customers
|
|
7
7
|
* get the same production-readiness signal we use internally - without the
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Double-press Ctrl+C exit guard for the Pugi CLI top-level lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* # Problem
|
|
5
|
+
*
|
|
6
|
+
* Operator dogfood reported a single Ctrl+C exits the REPL / headless
|
|
7
|
+
* loop. Operators expect a forgiving "press again to confirm" gesture
|
|
8
|
+
* — the same shell convention `^C ^C` already used by the per-engine
|
|
9
|
+
* task abort path in `runtime/cli.ts` (`runEngineTask`). Without the
|
|
10
|
+
* gesture at the top level, a stray Ctrl+C while typing a slash command
|
|
11
|
+
* or scrolling a transcript kills the session and any in-memory state
|
|
12
|
+
* the operator hasn't synced yet.
|
|
13
|
+
*
|
|
14
|
+
* # Behavior
|
|
15
|
+
*
|
|
16
|
+
* 1. **First Ctrl+C** — emit a one-line stderr prompt
|
|
17
|
+
* "Press Ctrl+C again to exit (within 2s), or any key to continue."
|
|
18
|
+
* Arm a 2-second window timer. Install a one-shot `stdin.once('data', …)`
|
|
19
|
+
* so the FIRST keystroke after the prompt cancels the exit gesture.
|
|
20
|
+
* 2. **Second Ctrl+C inside window** — flush log streams, persist a
|
|
21
|
+
* minimal session-state snapshot to `~/.pugi/session-state.json`,
|
|
22
|
+
* and exit with code 0. The state file is best-effort: any write
|
|
23
|
+
* error is swallowed so the operator's exit is never blocked on
|
|
24
|
+
* a disk hiccup.
|
|
25
|
+
* 3. **Other key inside window** — clear the timer, drop the prompt,
|
|
26
|
+
* emit "Exit cancelled." to stderr, and resume normally.
|
|
27
|
+
* 4. **Window expires** — clear `lastSigintTs`. A subsequent isolated
|
|
28
|
+
* Ctrl+C is treated as a NEW first press, not a confirmation.
|
|
29
|
+
* 5. **Headless mode** — when `process.stdin.isTTY === false`, the
|
|
30
|
+
* guard switches strategy: it closes stdin (so any `for await rl`
|
|
31
|
+
* loop in `headless-repl.ts` unwinds naturally), emits a
|
|
32
|
+
* `session-end` envelope to stdout (single JSON line, matches
|
|
33
|
+
* the envelope schema), and exits 0. Stdin can't deliver "any
|
|
34
|
+
* other key" when it's not a TTY, so the double-press dance is
|
|
35
|
+
* skipped in this mode.
|
|
36
|
+
*
|
|
37
|
+
* # Coexistence with the per-engine-run handler
|
|
38
|
+
*
|
|
39
|
+
* `runEngineTask` in `runtime/cli.ts` installs its OWN
|
|
40
|
+
* `process.on('SIGINT', …)` for the duration of an engine dispatch
|
|
41
|
+
* (lines around 6233). That handler aborts the in-flight turn on the
|
|
42
|
+
* first press and exits 130 on a second press inside its OWN 2s
|
|
43
|
+
* window. Both handlers receive every SIGINT — Node delivers signals
|
|
44
|
+
* to every listener.
|
|
45
|
+
*
|
|
46
|
+
* To avoid a double prompt while an engine turn is running, this
|
|
47
|
+
* guard checks `process.listenerCount('SIGINT')` at the start of its
|
|
48
|
+
* handler: if any other listener is attached (i.e. an engine run owns
|
|
49
|
+
* the foreground), we step aside and let that handler drive the UX.
|
|
50
|
+
* The engine handler's "press again to exit" prompt already covers
|
|
51
|
+
* the abort-then-quit story for that window. When the engine run
|
|
52
|
+
* unwinds, it detaches its listener and the REPL-level guard regains
|
|
53
|
+
* control.
|
|
54
|
+
*
|
|
55
|
+
* # Why module-scope, not per-call closure
|
|
56
|
+
*
|
|
57
|
+
* The press-count state must survive between two distinct SIGINT
|
|
58
|
+
* deliveries. A closure-scoped flag would reset on the second SIGINT
|
|
59
|
+
* because Node invokes the handler in a fresh microtask each time.
|
|
60
|
+
* Module-scope `let` is the simplest store that gives us cross-press
|
|
61
|
+
* persistence without leaking to other files.
|
|
62
|
+
*
|
|
63
|
+
* # Testability
|
|
64
|
+
*
|
|
65
|
+
* `installSigintGuard()` takes an optional `SigintGuardOptions` bag
|
|
66
|
+
* so the spec can inject:
|
|
67
|
+
* - a fake `stdin` (for "any key cancels"),
|
|
68
|
+
* - a fake `stdout` / `stderr` sink,
|
|
69
|
+
* - a `now()` clock seam,
|
|
70
|
+
* - a `setTimeout` / `clearTimeout` pair,
|
|
71
|
+
* - a `exit(code)` seam (the test never lets the real process exit),
|
|
72
|
+
* - and a `persistSessionState(payload)` injection so the spec
|
|
73
|
+
* observes the persisted snapshot without touching `~/`.
|
|
74
|
+
*
|
|
75
|
+
* In production all seams default to the real Node primitives.
|
|
76
|
+
*/
|
|
77
|
+
import { writeFile, mkdir } from 'node:fs/promises';
|
|
78
|
+
import { homedir } from 'node:os';
|
|
79
|
+
import { resolve as resolvePath, dirname } from 'node:path';
|
|
80
|
+
/**
|
|
81
|
+
* Default double-press window. Matches the per-engine-run handler so
|
|
82
|
+
* operators see one consistent timing rule across the CLI.
|
|
83
|
+
*/
|
|
84
|
+
export const SIGINT_DOUBLE_PRESS_WINDOW_MS = 2000;
|
|
85
|
+
/**
|
|
86
|
+
* Default location for the session-state snapshot the guard writes on
|
|
87
|
+
* a confirmed exit. Resolved at call time so `homedir()` is read late
|
|
88
|
+
* enough to honor a test override of the `HOME` env var.
|
|
89
|
+
*/
|
|
90
|
+
export function defaultSessionStatePath(home = homedir()) {
|
|
91
|
+
return resolvePath(home, '.pugi', 'session-state.json');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Default JSON-file persister. Best-effort: a failed write is logged
|
|
95
|
+
* to stderr (so the operator notices in debug runs) and then
|
|
96
|
+
* swallowed — the exit must not block on filesystem health.
|
|
97
|
+
*/
|
|
98
|
+
async function defaultPersist(snapshot) {
|
|
99
|
+
const filePath = defaultSessionStatePath();
|
|
100
|
+
try {
|
|
101
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
102
|
+
await writeFile(filePath, JSON.stringify(snapshot, null, 2), {
|
|
103
|
+
mode: 0o600,
|
|
104
|
+
encoding: 'utf8',
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
process.stderr.write(`pugi: session-state write failed: ${message}\n`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Default SIGINT subscription wires the handler onto `process` and
|
|
114
|
+
* returns an unsubscribe closure that detaches it. We use `.on` (not
|
|
115
|
+
* `.once`) so the handler stays attached across multiple presses
|
|
116
|
+
* within the same process lifetime.
|
|
117
|
+
*/
|
|
118
|
+
function defaultOnSigint(handler) {
|
|
119
|
+
process.on('SIGINT', handler);
|
|
120
|
+
return () => {
|
|
121
|
+
process.off('SIGINT', handler);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Install the double-press Ctrl+C exit guard. Returns a handle whose
|
|
126
|
+
* `uninstall()` detaches the SIGINT listener and clears any pending
|
|
127
|
+
* window timer; production never calls it.
|
|
128
|
+
*
|
|
129
|
+
* This function is idempotent: calling it a second time installs a
|
|
130
|
+
* NEW guard alongside the old one, which would cause duplicate
|
|
131
|
+
* prompts. The caller (cli.ts main entry) MUST call it exactly once,
|
|
132
|
+
* at the very top of the run. Tests that need multiple installs are
|
|
133
|
+
* expected to `uninstall()` between scenarios.
|
|
134
|
+
*/
|
|
135
|
+
export function installSigintGuard(options = {}) {
|
|
136
|
+
const stdin = options.stdin ?? process.stdin;
|
|
137
|
+
const stderr = options.stderr ?? process.stderr;
|
|
138
|
+
const stdout = options.stdout ?? process.stdout;
|
|
139
|
+
const now = options.now ?? Date.now;
|
|
140
|
+
const setTimer = options.setTimer ?? ((fn, ms) => setTimeout(fn, ms));
|
|
141
|
+
const clearTimer = options.clearTimer ?? ((handle) => clearTimeout(handle));
|
|
142
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
143
|
+
const persist = options.persistSessionState ?? defaultPersist;
|
|
144
|
+
const subscribe = options.onSigint ?? defaultOnSigint;
|
|
145
|
+
const isHeadless = options.isHeadless ?? (() => stdin.isTTY !== true);
|
|
146
|
+
const windowMs = options.windowMs ?? SIGINT_DOUBLE_PRESS_WINDOW_MS;
|
|
147
|
+
// State scoped to THIS install. Each call to `installSigintGuard`
|
|
148
|
+
// gets a fresh closure so concurrent tests do not bleed into each
|
|
149
|
+
// other. Production calls the function once at the top of the run.
|
|
150
|
+
let lastSigintTs = null;
|
|
151
|
+
let pendingTimer = null;
|
|
152
|
+
let pendingDataListener = null;
|
|
153
|
+
const resetWindow = () => {
|
|
154
|
+
lastSigintTs = null;
|
|
155
|
+
if (pendingTimer !== null) {
|
|
156
|
+
clearTimer(pendingTimer);
|
|
157
|
+
pendingTimer = null;
|
|
158
|
+
}
|
|
159
|
+
if (pendingDataListener !== null) {
|
|
160
|
+
// Detach via the same instance we attached; never the typed
|
|
161
|
+
// overload that re-binds 'data' to all listeners.
|
|
162
|
+
stdin.removeListener('data', pendingDataListener);
|
|
163
|
+
pendingDataListener = null;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const performExit = (reason) => {
|
|
167
|
+
const snapshot = {
|
|
168
|
+
exitedAt: new Date(now()).toISOString(),
|
|
169
|
+
reason,
|
|
170
|
+
cwd: process.cwd(),
|
|
171
|
+
pid: process.pid,
|
|
172
|
+
};
|
|
173
|
+
// Fire-and-forget persistence: we attempt to flush, but do not
|
|
174
|
+
// block the exit on the result. The promise is observed only to
|
|
175
|
+
// suppress unhandled-rejection noise in the test runner.
|
|
176
|
+
void persist(snapshot).catch(() => {
|
|
177
|
+
/* defaultPersist already logged */
|
|
178
|
+
});
|
|
179
|
+
exit(0);
|
|
180
|
+
};
|
|
181
|
+
const handleHeadless = () => {
|
|
182
|
+
// In headless mode we never prompt — the operator (or harness)
|
|
183
|
+
// has no keyboard to confirm with. We emit one final
|
|
184
|
+
// session-end envelope so any line-buffered consumer sees a
|
|
185
|
+
// clean terminator, close stdin so the `for await rl` loop in
|
|
186
|
+
// headless-repl.ts unwinds, and exit 0.
|
|
187
|
+
const envelope = {
|
|
188
|
+
kind: 'session-end',
|
|
189
|
+
body: JSON.stringify({ reason: 'sigint' }),
|
|
190
|
+
ts: now(),
|
|
191
|
+
};
|
|
192
|
+
stdout.write(`${JSON.stringify(envelope)}\n`);
|
|
193
|
+
// Best-effort stdin close so any in-flight readline loop terminates.
|
|
194
|
+
// Some stream implementations (e.g. test doubles) lack `.destroy`;
|
|
195
|
+
// guard the call so we never throw out of a signal handler.
|
|
196
|
+
const stdinAsAny = stdin;
|
|
197
|
+
try {
|
|
198
|
+
if (typeof stdinAsAny.destroy === 'function') {
|
|
199
|
+
stdinAsAny.destroy();
|
|
200
|
+
}
|
|
201
|
+
else if (typeof stdinAsAny.pause === 'function') {
|
|
202
|
+
stdinAsAny.pause();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
/* ignore — destroy/pause is opportunistic */
|
|
207
|
+
}
|
|
208
|
+
performExit('sigint-headless');
|
|
209
|
+
};
|
|
210
|
+
const handleInteractive = () => {
|
|
211
|
+
const ts = now();
|
|
212
|
+
if (lastSigintTs !== null && ts - lastSigintTs <= windowMs) {
|
|
213
|
+
// Confirmed double-press. Drop the prompt artifacts, persist
|
|
214
|
+
// state, exit clean. resetWindow() handles the listener
|
|
215
|
+
// cleanup so a stray `data` event after exit does not fire.
|
|
216
|
+
resetWindow();
|
|
217
|
+
stderr.write('\npugi: exiting (^C^C confirmed).\n');
|
|
218
|
+
performExit('sigint-double-press');
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
// First press — arm the window.
|
|
222
|
+
lastSigintTs = ts;
|
|
223
|
+
stderr.write('\nPress Ctrl+C again to exit (within 2s), or any key to continue.\n');
|
|
224
|
+
// Schedule a window-expiry reset. When the timer fires the
|
|
225
|
+
// operator's prior press no longer "counts" — the next ^C is
|
|
226
|
+
// treated as a fresh first press.
|
|
227
|
+
pendingTimer = setTimer(() => {
|
|
228
|
+
lastSigintTs = null;
|
|
229
|
+
pendingTimer = null;
|
|
230
|
+
if (pendingDataListener !== null) {
|
|
231
|
+
stdin.removeListener('data', pendingDataListener);
|
|
232
|
+
pendingDataListener = null;
|
|
233
|
+
}
|
|
234
|
+
}, windowMs);
|
|
235
|
+
// Install a one-shot 'data' listener so any keystroke other than
|
|
236
|
+
// a follow-up SIGINT cancels the exit gesture. We use
|
|
237
|
+
// `removeListener` after firing rather than `.once` because we
|
|
238
|
+
// also detach the listener from `resetWindow()` (the timer or
|
|
239
|
+
// a second SIGINT can both kill it).
|
|
240
|
+
const onData = (_chunk) => {
|
|
241
|
+
resetWindow();
|
|
242
|
+
stderr.write('Exit cancelled.\n');
|
|
243
|
+
};
|
|
244
|
+
pendingDataListener = onData;
|
|
245
|
+
stdin.on('data', onData);
|
|
246
|
+
};
|
|
247
|
+
const handler = () => {
|
|
248
|
+
// Coexistence guard: if another SIGINT listener is registered
|
|
249
|
+
// (e.g. the per-engine-run handler in runEngineTask), step aside
|
|
250
|
+
// and let it drive the UX. We count `> 1` because OUR handler
|
|
251
|
+
// is also in the list.
|
|
252
|
+
if (process.listenerCount('SIGINT') > 1 && !options.onSigint) {
|
|
253
|
+
// Drop any state we'd accumulated so an interactive prompt
|
|
254
|
+
// after the engine run starts from a clean slate.
|
|
255
|
+
resetWindow();
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (isHeadless()) {
|
|
259
|
+
handleHeadless();
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
handleInteractive();
|
|
263
|
+
};
|
|
264
|
+
const unsubscribe = subscribe(handler);
|
|
265
|
+
return {
|
|
266
|
+
uninstall: () => {
|
|
267
|
+
resetWindow();
|
|
268
|
+
unsubscribe();
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=sigint-guard.js.map
|
package/dist/runtime/version.js
CHANGED
|
@@ -44,7 +44,7 @@ export function sanitizeSemver(raw) {
|
|
|
44
44
|
* during import). When bumping the CLI version BOTH literals must be
|
|
45
45
|
* updated; the release smoke-test (`pack:smoke`) verifies they agree.
|
|
46
46
|
*/
|
|
47
|
-
export const PUGI_CLI_VERSION = sanitizeSemver('0.1.0-beta.
|
|
47
|
+
export const PUGI_CLI_VERSION = sanitizeSemver('0.1.0-beta.89');
|
|
48
48
|
/**
|
|
49
49
|
* Outbound: the CLI's installed semver. Read at request time by
|
|
50
50
|
* `version-interceptor.ts` and injected on every `fetch` call.
|