Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
f3f71c0
fix(core): treat inquirer 12's ExitPromptError as Ctrl-C at a prompt
Harshi-Shah-CS Nov 18, 2026
68f3054
fix(core): cancel with exit 3 when Ctrl-C aborts a search-list prompt
Harshi-Shah-CS Nov 18, 2026
629b918
feat(core): add terminalUx, which prompts through inquirer 12 directly
Harshi-Shah-CS Nov 18, 2026
418812c
fix(core): prompt through terminalUx so Ctrl-C at any prompt exits 3
Harshi-Shah-CS Nov 18, 2026
2ca33a8
test(guards): keep every prompt behind the Ctrl-C wrapper now that it…
Harshi-Shah-CS Nov 18, 2026
114abc4
test: press a real Ctrl-C at every kind of prompt on a pseudo-terminal
Harshi-Shah-CS Nov 18, 2026
e0c1879
docs: describe the terminalUx prompt funnel and how tests stub it
Harshi-Shah-CS Nov 18, 2026
46e86b8
fix(core): cancel at once when a search-list prompt is aborted
Harshi-Shah-CS Nov 18, 2026
6aaee6f
test: bound the pty Ctrl-C test and cover the password prompt
Harshi-Shah-CS Nov 18, 2026
499d2a0
test: simulate Ctrl-C at a search-list picker the way inquirer delive…
Harshi-Shah-CS Nov 18, 2026
cf8866a
test(guards): follow import aliases of terminalUx and promptLibrary
Harshi-Shah-CS Nov 18, 2026
38fdadd
refactor(core): drop the terminalUx comment, per AGENTS.md
Harshi-Shah-CS Nov 18, 2026
b20866a
docs: describe the search-list abort and CTRL_C as they now behave
Harshi-Shah-CS Nov 18, 2026
5159162
chore: refresh Talisman checksums for the files the prompt-seam chang…
Harshi-Shah-CS Nov 18, 2026
276f0c6
chore: refresh the AGENTS.md Talisman checksum after the prompt-funne…
Harshi-Shah-CS Nov 18, 2026
9893fb1
test: address review: end the pty fixture like the CLI, drop the help…
Harshi-Shah-CS Nov 19, 2026
1eb0532
test: address review: exit the pty fixture through process.exit, as o…
Harshi-Shah-CS Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fileignoreconfig:
- filename: src/logs/logs.inputs.test.ts
checksum: 7b4df8790179c7dc4385acd1d380bb91397523bab111593742e2fc53c94da375
- filename: test/integration/logs-get.test.ts
checksum: 89ce4f3864c6316e8075e08fb86fb07d848cbe717f434c3b3e228622b263eed2
checksum: b608797028bb0191d53630d2ff95d096b8a2b83019fed2aa096754dc5c50b1bb
- filename: src/commands/launch/logs/get.test.ts
checksum: d94d390de150956c799f64a84adfe0e02b5b21c66ddcc5cf55a1329aa67ec1a7
- filename: src/core/failure.test.ts
Expand Down Expand Up @@ -236,7 +236,7 @@ fileignoreconfig:
- "a project name passed on argv to the project resolver"
- "expect\\(Object.keys\\(DEPENDENCIES\\)\\).toEqual\\(\\['project', 'env'\\]\\)"
- filename: AGENTS.md
checksum: ecab79e8abbaae85038afe4f9e8e90e310eef5b0c002cee2b014926850be2c56
checksum: c20a023e033c6222c645e94bf9fba4bdf884aa75d6c52f5c74ab185b8c335b01
allowed_patterns:
- "Do not add an exemption to a guard to make a new file pass"
- "passes its own error wording to `client.request\\(req, MESSAGES\\)`"
Expand All @@ -263,15 +263,15 @@ fileignoreconfig:
- filename: src/commands/launch/projects/delete.test.ts
checksum: d67d8a804d14f9b809153d10b0cf9d5e52b70f9e0b65678ebb1663a7d2da22c1
- filename: test/integration/projects-delete.test.ts
checksum: bb59cbe1f4f7b3ac6aa7944067c1ab1214a7c5d20229e9d6577cdaabec56622e
checksum: 19784ba572daac76e6ef0b004c19cdb9c3f9cb22f738b3ab0e22c694e049026c
- filename: src/core/launch-command.ts
checksum: 999468661532665870b81face9086998e543df648175e2417045840dc97cb1dd
checksum: 91ec87522df77d8ed593c95e1a2259d1555acbd1dee95ad8ca4d6c3fa9c61468
- filename: src/core/launch-command.test.ts
checksum: 40c554e420c60e38d738190128588bc43c6f347da2d1e648b65d93419ca9f2c3
checksum: 44f0639fe66598ba2f3ba0ddc7edd68381f7aa36e3be5323ecbe5d101a1953a2
- filename: src/projects/project.inputs.test.ts
checksum: 8242f4d40388f1a7f1d08c11d2571cb45a9294069a8248a5272bc5606807bb60
- filename: test/integration/projects-command-flows.test.ts
checksum: 30858bb3dff8a22406efa4ac82d882d1501797cdda24e09555aecc0bcd8dca0b
checksum: 1731d2350269ae9b6f7c2837db8e14575f94a9a3fa11f8f86c532717378d99ce
- filename: src/core/redact.test.ts
checksum: ae497ea8c3a4c3f12217d2c4c028a1da3d1324e18362d68c355ba8120902bcb3
- filename: src/commands/launch/projects/list.test.ts
Expand Down Expand Up @@ -305,7 +305,7 @@ fileignoreconfig:
- filename: src/transport/cma-client.test.ts
checksum: 85d62ef350b450cb09f1a840db79bdfb212d4f5fd650789d60d722915a892a59
- filename: src/core/search-list.test.ts
checksum: 0c324ecf8de5cc2fc1ccc27223cae555d7db6c8061c4bd7288e0dc7fb28f6b87
checksum: 4e5db3cd6a213db71c51bf5ac8d6a5547ea9ca137d425c00026453e5c3b543b7
- filename: src/core/catalog.test.ts
checksum: 950d5cbb8ebdbe13cf13908b72d5409f7fdf7515c9d93a7c84045efcf4420543
- filename: test/credential-guard.setup.ts
Expand Down Expand Up @@ -445,9 +445,9 @@ fileignoreconfig:
- filename: src/deployments/deployment.create.test.ts
checksum: 6545afa21a23b7e5de18ad8ff417f88a184577e7042713cfda90758ccbcd9869
- filename: test/integration/deployments-rollback.test.ts
checksum: 08400c5435c84cd162fefc585f6c32cddfcaa8909d2369341748b421e7f12073
checksum: 98a9f7001eb5bf01e0e2f46677eeea61ad5d38c595d17ef27d366c93e603f0d5
- filename: test/integration/deployments-cancel.test.ts
checksum: 8972ed5f23e7dee8acf677ae9a26d2d28ef8144d03bc7623c5fd29f096a3aed0
checksum: 2e14190da534dda23176c44618b5f0cc0ef6f5c563b529658e171e509be10f4e
- filename: src/commands/launch/deployments/cancel.test.ts
checksum: da8d09de7f03cfe67df75ebc1636b36feb6688cf85984c357fd5304852d126e5
- filename: src/commands/launch/deployments/rollback.test.ts
Expand Down Expand Up @@ -489,7 +489,7 @@ fileignoreconfig:
- filename: package.json
checksum: ae6f7fdb23fd9476dd4fca5b84d0f3999b578a73b8187af2f94edbb0a2172b16
- filename: test/integration/secrets-set.test.ts
checksum: f01f5673125c48f537c593b9f8f3a728b6b16b42a3253c01f44558176ef48d89
checksum: 2527d5d35198cc08e1859ab79941338392b6d4fcbc87506adef6d7b096089963
- filename: src/secrets/secret.rules.test.ts
checksum: 29f1c5842b7d7c895ccf4c2611af52f824168e264e228b2493bededfdd7a2e8e
- filename: src/commands/launch/secrets/set.ts
Expand All @@ -507,7 +507,7 @@ fileignoreconfig:
- filename: src/secrets/secret.set.test.ts
checksum: 80b6b9c56280b6f5cb4be03fffd05b0421ea558997d9295ddde50b773f22b05f
- filename: test/integration/secrets-unset.test.ts
checksum: ed2f37b50516817ef70e2dc11ed4d801374ade1f3588fa2320f71cac5033448e
checksum: 431d7601ecb9d09d291bd271164da8da1bdd93329b217186db1de75ae185a2bb
- filename: src/secrets/secret.unset.ts
checksum: 597d7797c24716f443092fd40d077232ec1d9b2118707ee3aca453bacf38fa86
- filename: src/commands/launch/secrets/unset.ts
Expand All @@ -520,4 +520,6 @@ fileignoreconfig:
checksum: 22a5aa7d95c6a5113a034d2cc9af4f152f8a366f1c271f86cd317ea2046f5b1d
- filename: src/core/password-argv.test.ts
checksum: df87a19d09ff07b95d8118dd7e6bae5a13a86f0ecb8dce97e6022481d1e11256
- filename: test/integration/prompt-ctrl-c-on-a-terminal.test.ts
checksum: f712885cded1bef4d64a8e1d7532f95b6696e7d7522dfeba55edf211d07fb837
version: "1.0"
10 changes: 6 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ file and line that broke its rule, and each was proven red by reintroducing its

| Guard | Rule it enforces | Found by |
|---|---|---|
| `test/guards/prompt-types.test.ts` | Every prompt call in `src` names a literal `type`, and every such type is registered with the real inquirer `cliux.inquire` uses once `LaunchCommand.init` has run. inquirer silently turns an unregistered type into a plain text box. | D1: `search-list` used, never registered |
| `test/guards/prompt-types.test.ts` | Every prompt call in `src` names a literal `type`, and every such type is registered with the real inquirer `terminalUx` prompts through once `LaunchCommand.init` has run. inquirer silently turns an unregistered type into a plain text box. | D1: `search-list` used, never registered |
| `test/integration/transport-content-type.test.ts` | For every method in `HTTP_METHODS`, a bodyless request carries no content type and a request with a body carries `application/json`, asserted on the wire. `withoutDefaultContentType` suppresses the utility client's default, so a bodyless POST, PUT or PATCH (for example `deployments:cancel`) no longer goes out as `application/x-www-form-urlencoded`. Only `utility-http-client.ts` builds an `HttpClient` and only `rest-client.ts` sets the JSON type. | D5: every DELETE sent `Content-Type: application/json` |
| `test/guards/tty-streams.test.ts` | `stdin.isTTY`, and the `isTTY` it becomes on the service context, are read only to decide whether the CLI may prompt (a read next to a prompt or a refusal to prompt) or on the plumbing lines that carry it there. Anything deciding what to draw reads `outputIsTTY` / `process.stdout.isTTY`. | D6: heartbeat drawn into a redirected file |
| `test/integration/deployments-request-bodies.test.ts` | A deployments mutation puts on the wire only the fields the management service DTO declares - `{commitHash?, uploadUid?}` for a create, `{deployment, reason?}` for a rollback - and never `environment`, which is the URL path. The service validates with `whitelist` and `forbidNonWhitelisted`, so any other key is a bare 400. | Live harness: `deployments:create` and `:rollback` sent `{environment, ...}` and failed with `Bad request` |
| `test/integration/retired-commands.test.ts` (named commands) | Every `launch:…` command named anywhere in `src` - a retirement message, a failure hint, an example - is either a registered command or on `PLANNED_COMMANDS` with the ticket that builds it, and a command drops off that list once it ships. | Review: retirement messages and hints pointed at commands the beta does not have |
| `test/guards/prompt-funnel.test.ts` | Every prompt goes through `LaunchCommand`'s `ux`, built once as `cancelOnInterrupt(cliux)`, so Ctrl-C at any prompt exits 3. The wrapper stays attached to `SIGINT` until the signal has reached every listener (it detaches in a microtask): inquirer's `cli-cursor` loads `signal-exit`, which re-raises `SIGINT` - exit 130 - when it finds itself the only listener, so a `once` listener made every list and checkbox prompt exit 130 (`src/core/interruptible-ux.test.ts` pins it). No source calls `cliux.inquire` / `prompt` / `confirm` under any name, hands `cliux` on as a value, or imports a prompt library; `search-list.ts` may register a type but never prompt. | D2: Ctrl-C exited 130 |
| `test/guards/prompt-funnel.test.ts` | Every prompt goes through `LaunchCommand`'s `ux`, built once as `cancelOnInterrupt(terminalUx)`, so Ctrl-C at any prompt exits 3. `terminalUx` (`src/core/terminal-ux.ts`) asks cli-utilities' own inquirer instance (`promptLibrary()`) directly, because `cliux.inquire` catches inquirer 12's `ExitPromptError` and calls `process.exit(130)` itself. In raw mode Ctrl-C reaches inquirer as typed input, not as a process `SIGINT`: an `@inquirer/core` prompt (input, list, checkbox, confirm) rejects with `ExitPromptError`, which the wrapper turns into `CancelledError`; the legacy `search-list` rejects with `AbortPromptError` and then raises a real `SIGINT`, so the wrapper cancels on the rejection at once and stays attached only to absorb that signal. The wrapper stays attached to `SIGINT` until the signal has reached every listener (it detaches in a microtask): inquirer's `cli-cursor` loads `signal-exit`, which re-raises `SIGINT` - exit 130 - when it finds itself the only listener, so a `once` listener made every list and checkbox prompt exit 130 (`src/core/interruptible-ux.test.ts` pins it). No source calls `cliux.inquire` / `prompt` / `confirm` under any name, hands `cliux` on as a value, imports a prompt library, uses `promptLibrary` outside `search-list.ts` and `terminal-ux.ts`, or uses `terminalUx` anywhere but that one funnel line; `search-list.ts` may register a type but never prompt. `test/integration/prompt-ctrl-c-on-a-terminal.test.ts` types a real Ctrl-C at each kind of prompt on a pseudo-terminal, because a simulated `SIGINT` is what let CL-8790 through. `test/support/pty/press-ctrl-c.py <marker> <command...>` (Python's stdlib `pty`, so `npm test` needs `python3`) runs the command on a pty, types Ctrl-C once `<marker>` is on screen and prints the exit code: negative for a signal death (-2 is SIGINT), 124 if `<marker>` never appeared, 125 if the command was still running 30 s later (it is killed). `ctrl-c-prompt.fixture.ts` calls `process.exit` with the error's exit code, as oclif's `Errors.handle` does for the CLI. | D2: Ctrl-C exited 130; CL-8790: it did again after cli-utilities 2 |

A new prompt, request, render path or command is covered by these guards without being listed in
them. Do not add an exemption to a guard to make a new file pass: if a guard is wrong about a file,
Expand Down Expand Up @@ -110,8 +110,10 @@ stdin is not a terminal and `LaunchCommand` reads it to decide whether prompting
descriptor, not by assignment: once another suite in the same process has turned stdin into a real
stream, `process.stdin.isTTY = true` throws, and jest orders test files by their previous runtime, so
that shows up as an intermittent failure rather than a stable one. `answerPrompts({ message: answer })`
installs the `cliux.inquire` spy, records every prompt's message and payload in order, and throws on a
prompt it was not given an answer for. `projects-create.test.ts` uses the three together to drive all
installs the `terminalUx.inquire` spy, records every prompt's message and payload in order, and throws on a
prompt it was not given an answer for; an answer of `CTRL_C` rejects the way a real Ctrl-C does: `ExitPromptError`, or for a
`search-list` prompt `AbortPromptError` followed by a `SIGINT`. `stubPrompts(handler)` installs the same spy with your own handler, and `test/no-terminal.setup.ts`
uses it to fail any test that reaches a prompt it did not stub. `projects-create.test.ts` uses the three together to drive all
eleven GitHub prompts through `launch:projects:create`, asserting their order, their offered defaults
and the submitted body, and to prove that a flag-supplied value is never asked for.

Expand Down
35 changes: 35 additions & 0 deletions src/core/interruptible-ux.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,41 @@ describe('cancelOnInterrupt', () => {
expect(signals.listenerCount('SIGINT')).toBe(1);
});

it('rejects with CancelledError when the prompt itself reports Ctrl-C, as inquirer 12 does in raw mode, then stops listening', async () => {
const signals = new EventEmitter();
const inner = pendingUx();
const loop = recordingHold();
const ctrlC = Object.assign(new Error('User force closed the prompt with SIGINT'), { name: 'ExitPromptError' });

const answer = cancelOnInterrupt(inner.ux, { signals, hold: loop.hold }).inquire<string>(QUESTION);
inner.settle({ error: ctrlC });

await expect(answer).rejects.toBeInstanceOf(CancelledError);
expect(signals.listenerCount('SIGINT')).toBe(0);
expect(loop.events).toEqual(['held', 'released']);
});

it('cancels as soon as a search-list prompt is aborted, and stays attached only to absorb the SIGINT inquirer raises next', async () => {
const signals = new EventEmitter();
const inner = pendingUx();
const loop = recordingHold();
const aborted = Object.assign(new Error('Prompt was aborted'), { name: 'AbortPromptError' });

const answer = cancelOnInterrupt(inner.ux, { signals, hold: loop.hold }).inquire<string>(QUESTION);
inner.settle({ error: aborted });
const error = await answer.catch((e: unknown) => e);
const listeningBeforeSignal = signals.listenerCount('SIGINT');
const loopBeforeSignal = [...loop.events];
signals.emit('SIGINT');
await new Promise((done) => setImmediate(done));

expect(error).toBeInstanceOf(CancelledError);
expect(listeningBeforeSignal).toBe(1);
expect(loopBeforeSignal).toEqual(['held', 'released']);
expect(signals.listenerCount('SIGINT')).toBe(0);
expect(loop.events).toEqual(['held', 'released']);
});

it('propagates the prompt failure unchanged rather than calling it a cancellation, then stops listening', async () => {
const signals = new EventEmitter();
const inner = pendingUx();
Expand Down
24 changes: 21 additions & 3 deletions src/core/interruptible-ux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ export function onInterrupt(listener: () => void, signals: InterruptSource = pro
return release;
}

function isPromptExit(error: unknown): boolean {
return error instanceof Error && error.name === 'ExitPromptError';
}

function isPromptAbort(error: unknown): boolean {
return error instanceof Error && error.name === 'AbortPromptError';
}

export interface InterruptOptions {
signals?: InterruptSource;
hold?: () => Release;
Expand All @@ -46,9 +54,13 @@ export function cancelOnInterrupt(ux: UxLike, options: InterruptOptions = {}): U
print: (message) => ux.print(message),
inquire: <T>(payload: unknown) =>
new Promise<T>((resolve, reject) => {
const releaseLoop = hold();
let releaseLoop: Release | undefined = hold();
const freeLoop = (): void => {
releaseLoop?.();
releaseLoop = undefined;
};
const release = (): void => {
releaseLoop();
freeLoop();
signals.removeListener('SIGINT', cancel);
};
const cancel = (): void => {
Expand All @@ -57,8 +69,14 @@ export function cancelOnInterrupt(ux: UxLike, options: InterruptOptions = {}): U
};

const fail = (error: unknown): void => {
if (isPromptAbort(error)) {
freeLoop();
reject(new CancelledError());
return;
}

release();
reject(error);
reject(isPromptExit(error) ? new CancelledError() : error);
};

signals.on('SIGINT', cancel);
Expand Down
2 changes: 1 addition & 1 deletion src/core/launch-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ describe('LaunchCommand.init', () => {
restoreTTY();
});

it('registers the searchable picker on the inquirer cliux prompts with before anything can prompt', async () => {
it('registers the searchable picker on the inquirer terminalUx prompts through before anything can prompt', async () => {
const prompts = promptLibrary().prompt.prompts;
delete prompts['search-list'];
const instance = probe();
Expand Down
5 changes: 3 additions & 2 deletions src/core/launch-command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve as resolvePath } from 'node:path';

import { Command } from '@contentstack/cli-command';
import { cliux, configHandler, isAuthenticated } from '@contentstack/cli-utilities';
import { configHandler, isAuthenticated } from '@contentstack/cli-utilities';

import { EXIT_RUNTIME, PROJECT_CONFIG_FILE, STDIN_MAX_LISTENERS } from './constants';
import type { ProjectConfig } from './project-config';
Expand All @@ -18,6 +18,7 @@ import { cancelOnInterrupt } from './interruptible-ux';
import { refusePasswordOnArgv } from './password-argv';
import type { UxLike } from './prompt';
import { registerSearchList } from './search-list';
import { terminalUx } from './terminal-ux';
import type { FailureOutput } from './failure';
import { failWith, failureOutputOf, reportFailure } from './failure';
import type { ServiceContext } from './service-context';
Expand Down Expand Up @@ -109,7 +110,7 @@ export abstract class LaunchCommand<S extends AnyInputs = AnyInputs> extends Com
protected resolved!: Resolved<S>;
protected dataDir!: string;
protected configPath!: string;
protected ux: UxLike = cancelOnInterrupt(cliux);
protected ux: UxLike = cancelOnInterrupt(terminalUx);

protected get launchRegion(): RegionLike | undefined {
return configHandler.get('region') as RegionLike | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/core/search-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ describe('promptLibrary', () => {
});

describe('registerSearchList', () => {
it('registers the launch search list under search-list on the inquirer that cliux prompts with, and nothing else', () => {
it('registers the launch search list under search-list on the inquirer that terminalUx prompts through, and nothing else', () => {
const registered: [string, unknown][] = [];
const loaded: string[] = [];
const fakeLoad = (id: string): unknown => {
Expand Down
4 changes: 2 additions & 2 deletions src/core/search-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type SearchListClass = new (...params: never[]) => SearchListPrompt;
export type ModuleLoader = (id: string) => unknown;

export interface PromptRegistry {
prompt: { prompts: Record<string, unknown> };
prompt: ((question: unknown) => Promise<Record<string, unknown>>) & { prompts: Record<string, unknown> };
registerPrompt(name: string, prompt: unknown): void;
restoreDefaultPrompts(): void;
}
Expand Down Expand Up @@ -144,7 +144,7 @@ export function utilitiesLoader(): ModuleLoader {
return createRequire(require.resolve('@contentstack/cli-utilities'));
}

// cli-utilities 2 ships inquirer 12, which exposes the prompt registry cliux prompts with as its default export.
// cli-utilities 2 ships inquirer 12, whose default export is the prompt registry every Launch prompt goes through.
export function promptLibrary(load: ModuleLoader = utilitiesLoader()): PromptRegistry {
return (load('inquirer') as { default: PromptRegistry }).default;
}
Expand Down
Loading
Loading