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/init-tool-ignores.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@taskless/cli": patch
---

`init` now tells you which ignore entries your formatter and linters need for Taskless's files. A formatter used to rewrite the files `init` owns (`.taskless/bin/cli.mjs`, `taskless.json`, the skill file), and a type-aware linter failed on rule fixtures, until each was excluded by hand. For each of prettier, eslint, biome, oxlint, ruff and black that it detects, `init` prints the file to edit and a snippet in that tool's syntax, and `init --json` carries the same list as `ignores`. It never edits those files itself, and a tool whose config already mentions `.taskless` is not named again.
17 changes: 17 additions & 0 deletions openspec/changes/archive/2026-12-01-init-tool-ignores/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Why

Issue #732, the first of its "two smaller things". After `taskless init`, a project's formatter (prettier) and type-aware linter (typescript-eslint) failed on files Taskless installed: `.taskless/bin/cli.mjs`, `cli.lock.json`, `taskless.json`, the skill file, and the rule fixtures under `.taskless/rules`. The person had to find and exclude each one by hand. A formatter that rewrites an installer-owned file also churns, because the next `init` writes it back; a fixture is code meant to trip a rule, outside any `tsconfig`, so a type-aware linter cannot parse it at all.

## What Changes

- `init` (batch and wizard) names, for each formatter or linter `detect` already recognises that walks the whole tree (prettier, eslint, biome, oxlint, ruff, black), the ignore entries it needs: `.taskless/` for every one, plus each tool directory's Taskless skill stub for prettier, which formats markdown. Each entry carries the file it goes in and a snippet in that tool's syntax.
- A tool is left out once its root config or ignore file mentions `.taskless` (for black, the escaped `\.taskless` its regex needs), so the notice disappears once the project has dealt with it and is not a permanent line in every `init`.
- `init --json` carries the same list as `ignores`, always present. The `init` recipe tells an agent to offer the edit, in the same commit as the install, and to make it only when the user agrees.
- `init` prints and never writes. These are the person's configs; several are code (`eslint.config.js`, `oxlint.config.ts`) or JSON with comments, none is a file `init` owns, and `init`'s only writes outside `.taskless/` are its own skill stubs and permission rules.
- `detect` is unchanged: it runs before anything is installed, so there is nothing yet to ignore and no stub paths to name.

Not breaking. The bump is `patch`.

## Delivery shape

**Single PR.** One module, its call sites in `init` and the wizard, the recipe text and tests; the spec, implementation, and archive land together.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## ADDED Requirements

### Requirement: Init names the ignore entries a project's formatter and linters need

After a successful install, `init` and the wizard SHALL report, for each of prettier, eslint, biome, oxlint, ruff and black that repository detection finds, the ignore entries that keep that tool off Taskless's files. Every such tool SHALL be given `.taskless/`; prettier SHALL also be given each reference target's Taskless skill directory. Each entry SHALL name the file the entries go in and SHALL render them in that tool's own syntax.

For eslint, the entries SHALL be a flat-config `ignores` object when the project has a flat config, or has no ESLint config file at all, and SHALL be `.eslintignore` lines when it has only a legacy `.eslintrc*` or `.eslintignore`.

A tool SHALL be left out when any of its root config or ignore files already contains `.taskless` as a path, or for black the escaped form `\.taskless`. Black's escaped entry SHALL NOT count as another tool's. `init` SHALL NOT write any of these files.

The batch install SHALL print the entries above the uncommitted-install notice, and the onboarding trailer SHALL stay the final line. Under `--json` the envelope SHALL carry them as `ignores`, always present and empty when none is needed, and stdout SHALL remain the envelope alone.

#### Scenario: A detected formatter and linter are named

- **WHEN** a user runs `taskless init` with `.claude/` selected in a project that has a `.prettierrc` and an `eslint.config.js`
- **THEN** `init` SHALL print `.taskless/` and `.claude/skills/taskless/` for `.prettierignore`
- **AND** SHALL print `{ ignores: [".taskless/"] }` for `eslint.config.js`

#### Scenario: A tool that already ignores Taskless is left out

- **WHEN** the project's `.prettierignore` already contains `.taskless/`
- **THEN** `init` SHALL NOT name prettier

#### Scenario: Another tool's entry in a shared file does not count

- **WHEN** `pyproject.toml` excludes `.taskless` under `[tool.ruff]` and configures `[tool.black]` without it
- **THEN** `init` SHALL name black and SHALL NOT name ruff

#### Scenario: Black's entry does not count as ruff's

- **WHEN** `pyproject.toml` excludes `\.taskless` under `[tool.black]` and configures `[tool.ruff]` without it
- **THEN** `init` SHALL name ruff and SHALL NOT name black

#### Scenario: A legacy ESLint config is pointed at .eslintignore

- **WHEN** the project's only ESLint config is `.eslintrc.json`
- **THEN** `init` SHALL print `.taskless/` for `.eslintignore`

#### Scenario: The envelope carries the entries

- **WHEN** a user runs `taskless init --json` in a project with a detected prettier
- **THEN** the envelope's `ignores` SHALL hold a `prettier` entry with the patterns to add

#### Scenario: No detected tool is silent

- **WHEN** a user runs `taskless init` in a project with no detected formatter or linter
- **THEN** no ignore entries SHALL be printed
- **AND** the envelope's `ignores` SHALL be empty
10 changes: 10 additions & 0 deletions openspec/changes/archive/2026-12-01-init-tool-ignores/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## 1. Ignore entries

- [x] 1.1 Add `packages/cli/src/install/tool-ignores.ts`: the entries each detected formatter and linter still needs, and their human rendering.
- [x] 1.2 Print them from batch `init` above the commit notice and from the wizard before its commit offer; add `ignores` to the `init --json` envelope.
- [x] 1.3 Describe `ignores` and the offer to apply it in `packages/cli/src/agent/init.md`.

## 2. Tests and checks

- [x] 2.1 Test detection, the already-handled skip (including ruff's entry not counting for black), the printed notice, and the envelope field.
- [x] 2.2 Run `pnpm typecheck`, `pnpm lint`, and the test suite; add a patch changeset.
47 changes: 47 additions & 0 deletions openspec/specs/cli-init/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1452,3 +1452,50 @@ An install that finds a stub whose recovery instruction lacks this sentence SHAL
- **WHEN** an install finds a stub whose recovery instruction names a restore command but not the launchers
- **THEN** the install SHALL rewrite that stub
- **AND** a subsequent install SHALL leave it untouched

### Requirement: Init names the ignore entries a project's formatter and linters need

After a successful install, `init` and the wizard SHALL report, for each of prettier, eslint, biome, oxlint, ruff and black that repository detection finds, the ignore entries that keep that tool off Taskless's files. Every such tool SHALL be given `.taskless/`; prettier SHALL also be given each reference target's Taskless skill directory. Each entry SHALL name the file the entries go in and SHALL render them in that tool's own syntax.

For eslint, the entries SHALL be a flat-config `ignores` object when the project has a flat config, or has no ESLint config file at all, and SHALL be `.eslintignore` lines when it has only a legacy `.eslintrc*` or `.eslintignore`.

A tool SHALL be left out when any of its root config or ignore files already contains `.taskless` as a path, or for black the escaped form `\.taskless`. Black's escaped entry SHALL NOT count as another tool's. `init` SHALL NOT write any of these files.

The batch install SHALL print the entries above the uncommitted-install notice, and the onboarding trailer SHALL stay the final line. Under `--json` the envelope SHALL carry them as `ignores`, always present and empty when none is needed, and stdout SHALL remain the envelope alone.

#### Scenario: A detected formatter and linter are named

- **WHEN** a user runs `taskless init` with `.claude/` selected in a project that has a `.prettierrc` and an `eslint.config.js`
- **THEN** `init` SHALL print `.taskless/` and `.claude/skills/taskless/` for `.prettierignore`
- **AND** SHALL print `{ ignores: [".taskless/"] }` for `eslint.config.js`

#### Scenario: A tool that already ignores Taskless is left out

- **WHEN** the project's `.prettierignore` already contains `.taskless/`
- **THEN** `init` SHALL NOT name prettier

#### Scenario: Another tool's entry in a shared file does not count

- **WHEN** `pyproject.toml` excludes `.taskless` under `[tool.ruff]` and configures `[tool.black]` without it
- **THEN** `init` SHALL name black and SHALL NOT name ruff

#### Scenario: Black's entry does not count as ruff's

- **WHEN** `pyproject.toml` excludes `\.taskless` under `[tool.black]` and configures `[tool.ruff]` without it
- **THEN** `init` SHALL name ruff and SHALL NOT name black

#### Scenario: A legacy ESLint config is pointed at .eslintignore

- **WHEN** the project's only ESLint config is `.eslintrc.json`
- **THEN** `init` SHALL print `.taskless/` for `.eslintignore`

#### Scenario: The envelope carries the entries

- **WHEN** a user runs `taskless init --json` in a project with a detected prettier
- **THEN** the envelope's `ignores` SHALL hold a `prettier` entry with the patterns to add

#### Scenario: No detected tool is silent

- **WHEN** a user runs `taskless init` in a project with no detected formatter or linter
- **THEN** no ignore entries SHALL be printed
- **AND** the envelope's `ignores` SHALL be empty
22 changes: 21 additions & 1 deletion packages/cli/src/agent/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ first step, not the whole job.
so the user can include them in the commit they choose. Do not stage
or commit on your own; the git operations are theirs.

When `ignores` is non-empty, the project's formatter or linters will
reach Taskless's files: a formatter rewrites what `init` owns, and a
type-aware linter fails on rule fixtures. Offer to add each entry's
`patterns` to its `file`, so the change can go in the same commit.
These are the user's configs: edit them only when they agree, and
keep every entry already there.

3. **Offer the `pinnedCli` changes.** Go by each entry's `reason`:
- `dependency`: Taskless runs through the project launcher, not as a
project dependency. Offer to remove the dependency, point anything
Expand Down Expand Up @@ -142,6 +149,11 @@ first step, not the whole job.
"launcher": { "path": ".taskless/bin/cli.mjs", "state": "unchanged" },
"lockfile": { "path": ".taskless/bin/cli.lock.json", "state": "unchanged" },
"retired": [],
"ignores": [
{ "tool": "prettier", "file": ".prettierignore",
"patterns": [".taskless/", ".claude/skills/taskless/"],
"snippet": ".taskless/\n.claude/skills/taskless/" }
],
"telemetry": { "enabled": true }
}
```
Expand All @@ -152,7 +164,8 @@ lines (or `SKIPPED:` with the reason), a `SKIPPED (global):` line for
each missing or stale global trust entry, then a trailer naming the
directories that changed and, after a version move, pointing at
`update`, then a notice naming each
`pinnedCli` entry and what to do with it, and, when telemetry is on, a
`pinnedCli` entry and what to do with it, a notice naming each
`ignores` entry with the snippet to add, and, when telemetry is on, a
notice naming its opt-outs.

<!-- on-demand -->
Expand Down Expand Up @@ -229,6 +242,13 @@ notice naming its opt-outs.
here, along with the nightly's recorded version (its cached build is
pruned) and its rules in `permissions[].removed`. The deletions are
changes to commit.
- `ignores` is always present, empty when none is needed. Each entry is
a formatter or linter `detect` found (prettier, eslint, biome, oxlint,
ruff, black) whose root config does not mention `.taskless` yet:
`file` is where the entries go, `patterns` the entries in that tool's
syntax, and `snippet` the same as text to paste. Every tool gets
`.taskless/`; prettier, which formats markdown, also gets each tool
directory's Taskless skill stub. `init` never writes these files.

<!-- on-demand -->
## For a person at a terminal
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ import {
} from "../install/global-trust";
import { readInstallState } from "../install/state";
import { getUncommittedInstallNotice } from "../install/uncommitted";
import {
describeToolIgnores,
findToolIgnores,
type ToolIgnore,
} from "../install/tool-ignores";
import {
getTelemetry,
isTelemetryEnabled,
Expand Down Expand Up @@ -171,6 +176,9 @@ export const initCommand = defineCommand({
// Another package's launcher files this run removed: a release
// install retires the nightly's. Always present, empty when none.
retired: result.retired,
// The ignore entries each detected formatter and linter still needs
// for Taskless's files. Always present, empty when none.
ignores: result.ignores,
// Always present, so the agent can tell the user telemetry is on
// and how to turn it off; the human path prints the notice instead.
telemetry: { enabled: telemetryEnabled },
Expand Down Expand Up @@ -242,6 +250,12 @@ export const initCommand = defineCommand({
) {
console.log(getWizardHint(getCliPrefix()));
}
// Above the commit notice: an ignore entry added now goes in the same
// commit as the install.
const ignoreNotice = describeToolIgnores(result.ignores);
if (ignoreNotice !== undefined) {
console.log(ignoreNotice);
}
if (telemetryEnabled) {
console.log(TELEMETRY_NOTICE);
}
Expand Down Expand Up @@ -477,6 +491,8 @@ async function runNonInteractive(
globalTrust: GlobalTrustOutcome[];
/** Whether the rules need `update --rules`, read after any stamp. */
rules: ReconcileStatus;
/** Ignore entries the project's formatter and linters still need. */
ignores: ToolIgnore[];
}> {
// Under `--json`, stdout carries only the envelope printed by the caller.
// This per-target summary is not on that envelope (it is finer-grained than
Expand Down Expand Up @@ -653,6 +669,7 @@ async function runNonInteractive(
versionMoved({ previousCliVersion, cliVersion }),
pinnedCli: await findCliPins(cwd, cliVersion, { migrated }),
rules,
ignores: await findToolIgnores(cwd, plan),
};
}

Expand Down
Loading