Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/wizard-pointer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@taskless/cli": patch
---

`taskless init` run from a terminal now says it installs without asking and names the command that opens the setup wizard (`npx @taskless/cli` with no arguments), so running `init` to get the wizard back no longer leaves you guessing. Agents, scripts, CI, and `--json` don't see the line. A bare `npx @taskless/cli` in a terminal with `CI` set now says `CI` is why the wizard didn't start, where it used to tell you to run from a terminal you were already in.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-29
9 changes: 9 additions & 0 deletions openspec/changes/archive/2026-11-29-wizard-pointer/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Decisions

**One guard, read once.** `shouldLaunchWizard` becomes `wizardBlocker(...) === undefined`, and the preamble and `init` both read the same context (`stdout.isTTY`, `stdin.isTTY`, `CI`). `CI` is checked first, matching the launch guard, so a pseudo-terminal with `CI` set is reported as CI.

**The preamble keeps its first line.** `Taskless CLI — non-interactive context detected.` stays the same in every case, so anything matching it still matches; only the second line varies with the reason.

**The `init` hint sits above the telemetry notice.** The uncommitted-files notice must stay directly above the onboarding trailer, and the trailer must stay last, so the hint goes before both.

**The pure functions carry the text.** A spawned CLI is never on a TTY, so the TTY half of the `init` hint cannot be exercised end to end in a test. The text is unit-tested, a spawned `init` asserts the hint is absent, and a spawned bare run with `CI=true` asserts the CI wording.
21 changes: 21 additions & 0 deletions openspec/changes/archive/2026-11-29-wizard-pointer/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Why

Issue #708: a design partner ran `npx @taskless/cli` in a second project, saw what looked like nothing, then ran `npx @taskless/cli init` expecting the wizard back. `init` never prompts, so it did not bring the wizard back, and nothing said which command would.

On 0.13.8 a bare run starts the wizard in a fresh directory, a fresh git repository, and an already-initialized project, and a cancelled wizard already names the bare command, so the "nothing happened" report does not reproduce. Two gaps remain:

- `init` run from a terminal installs without saying the wizard exists or how to reach it.
- A bare run in a terminal with `CI` set skips the wizard and tells the person to "run from a terminal", which they already did.

The reporter's other question, whether `init` and then the onboarding prompt reach the same place, already has an answer in the output: `init` ends with the onboarding prompt, the same one the wizard ends with.

## What Changes

- `init`, when it runs where the wizard could have run (both streams a TTY, `CI` not set) and without `--json`, prints one line naming the bare command that opens the wizard. Agents, scripts, and CI never see it.
- The non-interactive preamble of a bare run says when `CI` is the reason the wizard did not start, naming the value, instead of telling the person to use a terminal.

Not breaking. The bump is `patch`.

## Delivery shape

**Single PR.** The change is two messages and their tests; the spec, implementation, and archive land together.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## ADDED Requirements

### Requirement: Init in a terminal names the command that opens the wizard

When `taskless init` completes without `--json` and both stdout and stdin are TTYs and `CI` is not `true` or `1`, the output SHALL include one line saying that `init` installs without asking and naming the bare invocation, with the CLI's launcher-aware prefix, as the command that opens the interactive wizard. The line SHALL be printed before the telemetry notice, so that the uncommitted-install notice and the onboarding trailer keep their places at the end of the output. When any of those conditions fails, the line SHALL NOT be printed.

#### Scenario: Init from a terminal points at the wizard

- **WHEN** a user runs `taskless init` with both streams on a TTY and `CI` unset
- **THEN** the output SHALL include a line naming the bare invocation as the way to open the wizard
- **AND** the onboarding trailer SHALL still end the output

#### Scenario: Init from an agent or script does not

- **WHEN** `taskless init` runs with stdout or stdin not a TTY, or with `CI` set to `true` or `1`, or with `--json`
- **THEN** the output SHALL NOT include the wizard line

### Requirement: The non-interactive preamble says why the wizard did not start

When a bare invocation does not launch the wizard, the first line of its preamble SHALL be `Taskless CLI — non-interactive context detected.` in every case. When `CI` is `true` or `1`, the preamble SHALL say that the wizard does not start while `CI` is set, naming its value, and SHALL NOT tell the user to run from a terminal. Otherwise the preamble SHALL tell the user to run from a terminal for an interactive install.

#### Scenario: CI set in a terminal

- **WHEN** `taskless` is invoked with no subcommand, both streams on a TTY, and `CI=true`
- **THEN** the preamble SHALL say the wizard does not start while `CI=true` is set
- **AND** SHALL NOT say to run from a terminal

#### Scenario: Piped without CI

- **WHEN** `taskless` is invoked with no subcommand, stdout not a TTY, and `CI` unset
- **THEN** the preamble SHALL say to run from a terminal for an interactive install
10 changes: 10 additions & 0 deletions openspec/changes/archive/2026-11-29-wizard-pointer/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## 1. Messages

- [x] 1.1 Add `wizardBlocker`, `nonInteractivePreamble`, and `getWizardHint` to `packages/cli/src/util/interactive.ts`, and express `shouldLaunchWizard` through `wizardBlocker`.
- [x] 1.2 Print the preamble from `nonInteractivePreamble` in the bare invocation path of `packages/cli/src/index.ts`.
- [x] 1.3 Print `getWizardHint` from `init` when the wizard could have run, above the telemetry notice.

## 2. Tests and checks

- [x] 2.1 Unit-test the blocker, preamble, and hint; assert a spawned bare run under `CI=true` names CI; assert a spawned `init` prints no hint.
- [x] 2.2 Run `pnpm typecheck`, `pnpm lint`, and the test suite; add a patch changeset.
30 changes: 30 additions & 0 deletions openspec/specs/cli-init/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1405,3 +1405,33 @@ The manifest SHALL record, under `install.permissions`, each file Taskless wrote
- **WHEN** the manifest records `Bash(./.taskless/bin/cli-nightly.mjs *)` in `.claude/settings.json` and the nightly's `init` runs with `.claude/` no longer selected
- **THEN** that rule SHALL be removed with the nightly's other Taskless rules
- **AND** `Bash(./.taskless/bin/cli.mjs *)` SHALL remain

### Requirement: Init in a terminal names the command that opens the wizard

When `taskless init` completes without `--json` and both stdout and stdin are TTYs and `CI` is not `true` or `1`, the output SHALL include one line saying that `init` installs without asking and naming the bare invocation, with the CLI's launcher-aware prefix, as the command that opens the interactive wizard. The line SHALL be printed before the telemetry notice, so that the uncommitted-install notice and the onboarding trailer keep their places at the end of the output. When any of those conditions fails, the line SHALL NOT be printed.

#### Scenario: Init from a terminal points at the wizard

- **WHEN** a user runs `taskless init` with both streams on a TTY and `CI` unset
- **THEN** the output SHALL include a line naming the bare invocation as the way to open the wizard
- **AND** the onboarding trailer SHALL still end the output

#### Scenario: Init from an agent or script does not

- **WHEN** `taskless init` runs with stdout or stdin not a TTY, or with `CI` set to `true` or `1`, or with `--json`
- **THEN** the output SHALL NOT include the wizard line

### Requirement: The non-interactive preamble says why the wizard did not start

When a bare invocation does not launch the wizard, the first line of its preamble SHALL be `Taskless CLI — non-interactive context detected.` in every case. When `CI` is `true` or `1`, the preamble SHALL say that the wizard does not start while `CI` is set, naming its value, and SHALL NOT tell the user to run from a terminal. Otherwise the preamble SHALL tell the user to run from a terminal for an interactive install.

#### Scenario: CI set in a terminal

- **WHEN** `taskless` is invoked with no subcommand, both streams on a TTY, and `CI=true`
- **THEN** the preamble SHALL say the wizard does not start while `CI=true` is set
- **AND** SHALL NOT say to run from a terminal

#### Scenario: Piped without CI

- **WHEN** `taskless` is invoked with no subcommand, stdout not a TTY, and `CI` unset
- **THEN** the preamble SHALL say to run from a terminal for an interactive install
12 changes: 12 additions & 0 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import {
} from "../rules/reconcile-status";
import { TASKLESS_DIRECTORY } from "../rules/vale/formats";
import { CLIError } from "../util/cli-error";
import { getWizardHint, shouldLaunchWizard } from "../util/interactive";
import { buildInvocation } from "../util/invocation";
import { makeErrorEnvelope } from "../types/errors";

Expand Down Expand Up @@ -230,6 +231,17 @@ export const initCommand = defineCommand({
if (result.reloadNotice !== undefined) {
console.log(result.reloadNotice);
}
// Only where the wizard could have run: `init` never prompts, and a
// person who ran it from a terminal may have wanted the wizard back.
if (
shouldLaunchWizard({
stdoutIsTTY: process.stdout.isTTY,
stdinIsTTY: process.stdin.isTTY,
ci: process.env.CI,
})
) {
console.log(getWizardHint(getCliPrefix()));
}
if (telemetryEnabled) {
console.log(TELEMETRY_NOTICE);
}
Expand Down
29 changes: 17 additions & 12 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import {
joinDirectoryValues,
splitRawArguments,
} from "./util/argv";
import { shouldLaunchWizard } from "./util/interactive";
import {
nonInteractivePreamble,
shouldLaunchWizard,
wizardBlocker,
} from "./util/interactive";
import { showResolvedUsage } from "./util/help";
import { getCliPrefix } from "./util/package-manager";
import { CLIError } from "./util/cli-error";
Expand Down Expand Up @@ -141,13 +145,12 @@ const main = defineCommand({
// prompts, and it calls the wizard rather than `init`. The guard carries
// the `CI` check `init` used to apply, since a pseudo-terminal in CI is
// still nobody to answer a prompt.
if (
shouldLaunchWizard({
stdoutIsTTY: process.stdout.isTTY,
stdinIsTTY: process.stdin.isTTY,
ci: process.env.CI,
})
) {
const context = {
stdoutIsTTY: process.stdout.isTTY,
stdinIsTTY: process.stdin.isTTY,
ci: process.env.CI,
};
if (shouldLaunchWizard(context)) {
const result = await runWizard({ cwd: resolveCwd(rawArgs) });
if (result.status === "cancelled") {
process.exitCode = 1;
Expand All @@ -164,10 +167,12 @@ const main = defineCommand({
? launcher
: prefix;
console.error(
"Taskless CLI — non-interactive context detected.\n" +
" For interactive install, run from a terminal.\n" +
` For scripted install, run \`${prefix} init\`.\n` +
` For agent recipes, run \`${recipes} agent\` (no args) for the topic index.\n`
nonInteractivePreamble({
blocker: wizardBlocker(context) ?? "no-tty",
ci: context.ci,
prefix,
recipes,
})
);
// Forward the parent's rawArgs (e.g. `-d <path>`) so the agent command
// doesn't mis-parse them as positional topic names.
Expand Down
56 changes: 52 additions & 4 deletions packages/cli/src/util/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,61 @@
* Pure so it can be tested: a spawned CLI is never on a TTY, which is exactly
* the case this guard does not decide.
*/
export function shouldLaunchWizard(input: {
export function shouldLaunchWizard(input: WizardContext): boolean {
return wizardBlocker(input) === undefined;
}

export interface WizardContext {
stdoutIsTTY: boolean | undefined;
stdinIsTTY: boolean | undefined;
ci: string | undefined;
}): boolean {
if (isCiEnvironment(input.ci)) return false;
return input.stdoutIsTTY === true && input.stdinIsTTY === true;
}

/**
* Why a bare invocation will not launch the wizard, or `undefined` when it
* will. `ci` is checked first, matching the order `shouldLaunchWizard` gives
* it, so a terminal with `CI` set is told about `CI` rather than told to "run
* from a terminal" it is already in.
*/
export function wizardBlocker(
input: WizardContext
): "ci" | "no-tty" | undefined {
if (isCiEnvironment(input.ci)) return "ci";
if (input.stdoutIsTTY !== true || input.stdinIsTTY !== true) return "no-tty";
return undefined;
}

/**
* The preamble a bare invocation prints when it does not launch the wizard,
* before the agent topic index. The first line is the same in every case;
* the second says why the wizard did not start, so a person who expected it
* is not left guessing.
*/
export function nonInteractivePreamble(options: {
blocker: "ci" | "no-tty";
ci: string | undefined;
prefix: string;
recipes: string;
}): string {
const why =
options.blocker === "ci"
? ` The setup wizard does not start while \`CI=${options.ci ?? ""}\` is set. Unset it to use the wizard from a terminal.\n`
: " For interactive install, run from a terminal.\n";
return (
"Taskless CLI — non-interactive context detected.\n" +
why +
` For scripted install, run \`${options.prefix} init\`.\n` +
` For agent recipes, run \`${options.recipes} agent\` (no args) for the topic index.\n`
);
}

/**
* The line `init` prints when it ran where the wizard could have: `init`
* never prompts, so a person who ran it hoping to get the wizard back is
* told which command opens it.
*/
export function getWizardHint(prefix: string): string {
return `\`init\` installs without asking. To choose which tools to install for and review settings edits before they are written, run \`${prefix}\` with no arguments.`;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions packages/cli/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ describe("cli", () => {
}
);

it("says CI is why a bare run skipped the wizard", async () => {
const { stderr } = await execFileAsync(
"node",
[binPath, "-d", temporaryDirectory],
{ env: { ...process.env, CI: "true" } }
);
expect(stderr).toContain("non-interactive context detected");
expect(stderr).toContain("`CI=true`");
expect(stderr).not.toContain("run from a terminal");
});

it("sends recipes to the project launcher when the project has one", async () => {
await mkdir(join(temporaryDirectory, ".taskless", "bin"), {
recursive: true,
Expand Down
13 changes: 13 additions & 0 deletions packages/cli/test/init-no-interactive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,19 @@ describe("taskless init (the batch install)", () => {
expect(stdout).not.toMatch(/@taskless\/cli@latest onboard/);
});

it("does not point at the wizard when it could not have run", async () => {
// A spawned CLI is never on a TTY, so this is the agent and script case:
// the wizard hint is for a person at a terminal only.
const { stdout } = await execFileAsync("node", [
binPath,
"init",
"-d",
cwd,
]);

expect(stdout).not.toContain("with no arguments");
});

it("prints the same skill-only trailer when no commands were installed", async () => {
// .agents/ fallback receives no commands; the trailer is the same.
const { stdout } = await execFileAsync("node", [
Expand Down
59 changes: 58 additions & 1 deletion packages/cli/test/interactive.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { describe, expect, it } from "vitest";

import { shouldLaunchWizard } from "../src/util/interactive";
import {
getWizardHint,
nonInteractivePreamble,
shouldLaunchWizard,
wizardBlocker,
} from "../src/util/interactive";

describe("shouldLaunchWizard", () => {
const tty = { stdoutIsTTY: true, stdinIsTTY: true };
Expand Down Expand Up @@ -34,3 +39,55 @@ describe("shouldLaunchWizard", () => {
expect(shouldLaunchWizard({ ...tty, ci })).toBe(true);
});
});

describe("wizardBlocker", () => {
it("names CI before the TTYs, so a terminal with CI set is told about CI", () => {
expect(
wizardBlocker({ stdoutIsTTY: true, stdinIsTTY: true, ci: "true" })
).toBe("ci");
expect(
wizardBlocker({ stdoutIsTTY: false, stdinIsTTY: false, ci: "1" })
).toBe("ci");
});

it("names a missing TTY when CI is not set", () => {
expect(
wizardBlocker({ stdoutIsTTY: true, stdinIsTTY: false, ci: undefined })
).toBe("no-tty");
});

it("is undefined exactly when the wizard launches", () => {
expect(
wizardBlocker({ stdoutIsTTY: true, stdinIsTTY: true, ci: undefined })
).toBeUndefined();
});
});

describe("nonInteractivePreamble", () => {
const base = { prefix: "npx @taskless/cli", recipes: "npx @taskless/cli" };

it("tells a CI run that CI is why the wizard did not start", () => {
const text = nonInteractivePreamble({ ...base, blocker: "ci", ci: "1" });
expect(text).toContain("non-interactive context detected");
expect(text).toContain("`CI=1`");
expect(text).not.toContain("run from a terminal");
});

it("tells a piped run to use a terminal", () => {
const text = nonInteractivePreamble({
...base,
blocker: "no-tty",
ci: undefined,
});
expect(text).toContain("For interactive install, run from a terminal.");
expect(text).toContain("`npx @taskless/cli init`");
});
});

describe("getWizardHint", () => {
it("names the bare command that opens the wizard", () => {
expect(getWizardHint("npx @taskless/cli")).toContain(
"run `npx @taskless/cli` with no arguments"
);
});
});