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
4 changes: 3 additions & 1 deletion .changeset/check-diff-scope.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
"@taskless/cli": patch
"@taskless/cli": minor
---

`check --diff` scopes a check to the files a unified diff changes. Pipe one in (`git diff --staged | taskless check --diff`), or name a file with `--diff=<file>`; the value only ever follows `=`, so `check --diff src/a.ts` reads `src/a.ts` as a path and refuses the pair. Every file the diff adds or modifies is checked whole, including lines it did not change. Deleted files are skipped, and files under `.taskless/` or `.git/` are never checked from a diff, so a change that only adds a rule no longer fails on the rule's own `tests/fail` fixtures. An empty diff exits 0 having checked nothing; input that is not a unified diff, a terminal on stdin, and a diff combined with paths are refused with `INVALID_INPUT`. The CLI runs no git: the `ci` and `hooks` recipes give the command that produces the diff (`git diff --no-ext-diff --no-color --relative ...`), replacing the `$(git diff --name-only ...)` expansion they used before.

**Breaking: every flag that takes a value now takes it only as `--flag=value`, and `-d` is removed.** Update calls such as `--dir /path` to `--dir=/path`, `-d /path` to `--dir=/path`, `--rule no-eval` to `--rule=no-eval`, `--from request.json` to `--from=request.json`, and likewise `--section`, `--resume`, `--timeout`, `--range`, `--lang`, `--delete` and `--tool`. The old spelling is refused with `INVALID_INPUT` before the command runs, and the message names the `=` form, so nothing changes behavior silently. One spelling means no flag ever consumes the token after it, so a positional path can no longer be mistaken for a flag's value, and a value that begins with `-` (`--rule=-x`) is unambiguous. Boolean flags such as `--json` are unchanged. Recipes, the installed skill and the CLI's own messages use the new spelling; CI and hook files the `ci` and `hooks` recipes generated use positional paths, `--json` and `--diff`, and need no change unless a value flag was added to them by hand.
6 changes: 3 additions & 3 deletions .github/workflows/reference-corpus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
PROJECT="$(mktemp -d)"
echo "PROJECT=$PROJECT" >> "$GITHUB_ENV"
git -C "$PROJECT" init -q
node packages/cli/dist/index.js init -d "$PROJECT"
node packages/cli/dist/index.js init --dir="$PROJECT"
# Engine, id and asset directory come from the manifest, so adding a
# fourth sample needs no edit here.
# The script writes the file itself. Redirecting its stdout here
Expand All @@ -104,15 +104,15 @@ jobs:
done < /tmp/manifests.txt

- name: Validate
run: node packages/cli/dist/index.js validate -d "$PROJECT"
run: node packages/cli/dist/index.js validate --dir="$PROJECT"

# `--dangerously-run-scripts` is the whole point of this job: without it
# the fixtures do not run, and `verify` says so rather than reporting a
# pass. A green run here means they executed.
- name: Run every rule's fixtures
run: |
set -euo pipefail
node packages/cli/dist/index.js verify --json --dangerously-run-scripts -d "$PROJECT" | tee /tmp/report.json
node packages/cli/dist/index.js verify --json --dangerously-run-scripts --dir="$PROJECT" | tee /tmp/report.json
node -e '
const report = JSON.parse(require("fs").readFileSync("/tmp/report.json", "utf8"));
const expected = require("fs").readFileSync("/tmp/manifests.txt", "utf8")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Any one of these turns telemetry off:

Onboarding ends by publishing a report: an unlisted page on [tskl.es](https://tskl.es) at a random URL. Anyone with the link can read it. It holds your rules, their fixtures, and what they found. A page is a lot easier to read than terminal output, and easy to share with your team.

Before publishing, the CLI scans everything in the report for anything that looks like a secret or contact detail (API keys, tokens, private keys, email addresses, host names, IP addresses, phone numbers) and withholds whatever matches. `taskless report --delete <record>` takes the page down, where `<record>` is its file in `.taskless/reports/`.
Before publishing, the CLI scans everything in the report for anything that looks like a secret or contact detail (API keys, tokens, private keys, email addresses, host names, IP addresses, phone numbers) and withholds whatever matches. `taskless report --delete=<record>` takes the page down, where `<record>` is its file in `.taskless/reports/`.

### Accounts

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-05
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Context

citty parses each command's args with an mri-style parser that accepts both `--flag value` and `--flag=value`. Three places in this CLI read raw argv themselves and must agree with citty: subcommand resolution for `--help`, the root command's "no subcommand" check, and `check`'s positionals and repeated `--rule`. They share one scanner, `splitRawArguments`, which today is told which flags consume the next token (`-d`/`--dir` always, plus a per-command list), and `joinDirectoryValues` rewrites `-d <path>` into `--dir=<path>` before citty resolves subcommands.

## Goals / Non-Goals

**Goals:**

- One spelling for a flag value, enforced in one place, for every command.
- A refusal that names the exact fix, so a caller migrating from the old spelling is told what to type.
- The argv scanner needs no knowledge of which flags take values.

**Non-Goals:**

- Changing which flags exist or what they mean.
- Boolean flags. `--json` stays `--json`.

## Decisions

**Enforce before dispatch, from the command definitions.** The entry point resolves the command the positionals name (the walk `--help` already uses), collects the `type: "string"` args of that command and its ancestors, and refuses any raw token, before `--`, that is exactly `--<name>` for one of them. Reading the definitions rather than a hand-kept list means a new value flag is covered the day it is declared, and a flag cannot be forgotten the way `--rule` once was. It runs after the `--help`/`--version` intercept, so `taskless check --help` still prints usage, and before the version gate, so a malformed call is refused without reading the project.

The alternative, letting each command validate its own flags, puts the same check in twenty run handlers and leaves the argv scanner still needing to know which tokens are values.

**A bare value flag is refused even when nothing follows it.** `check --rule` with no value is the same mistake as `check --rule no-eval`, and the message is the same.

**`-d` is refused, not ignored.** Removing the alias alone would turn `taskless -d /tmp check` into an unknown flag followed by a command named `/tmp`. A specific refusal (`-d was removed; use --dir=<path>`) tells the caller what changed.

**The scanner stops consuming tokens.** With every value inside its flag's token, a token is a flag if it starts with `-` and a positional otherwise (until `--`). `splitRawArguments` loses its `valueFlags` and `optionalValueFlags` parameters and records a value for every `--flag=value` token. `joinDirectoryValues` and `DIR_FLAGS` are deleted. `resolveCwd` reads only `--dir=`.

**Specs are restated mechanically.** Every standing requirement whose text or scenarios spell a value flag with a space, or name `-d`, is copied whole into a MODIFIED delta with only that spelling changed, keeping its title so the delta applies. The pre-archive scenario count is checked per spec, since a MODIFIED delta that drops a scenario deletes it silently.

## Risks / Trade-offs

- [Callers outside this repository break on upgrade] → Accepted as the upgrade cost of a `minor`. Every refusal names the `=` spelling, and the changeset lists what to change.
- [A value that legitimately starts with `-`] → Now unambiguous: `--rule=-x` carries it in the token. Previously `--rule -x` was read as two flags.
- [Hand-written workflow or hook files in user repositories] → Generated by older recipes, they used positional paths and `--json`, which are unaffected; only those that added a value flag by hand need the edit.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Why

`check --diff` (the change below this one in the stack) takes its value only from `--diff=<file>`, because a flag whose value is optional cannot also take the next token without colliding with positional paths. Every other value flag still accepts both `--flag value` and `--flag=value`, so the CLI now has two spellings for "a flag with a value", and which one a flag accepts depends on whether its value is optional. One rule is easier to teach, to document in recipes, and to parse: a value always follows `=`.

The second spelling also costs real code. `-d <path>` before a subcommand is rewritten into `--dir=<path>` before citty sees it, because citty resolves subcommands from the first token that does not start with `-` and would otherwise run a command named after the path. The shared argv scanner has to be told, per command, which flags consume the next token, and a flag left off that list turns its value into a positional path: `check --rule no-eval` once looked for a file called `no-eval`, found none, and exited 0.

## What Changes

- **BREAKING** Every flag that takes a value takes it only as `--flag=value`. `--flag value` is refused with `INVALID_INPUT` naming the `=` spelling, before the command runs.
- **BREAKING** The `-d` alias for `--dir` is removed. `-d` is refused with `INVALID_INPUT` naming `--dir=<path>`. No other short flag takes a value.
- The argv scanner no longer consumes a token after any flag, and the `-d <path>` rewrite is removed.
- Recipes, the Taskless skill, READMEs, CLI messages, workflows and tests use the `=` spelling throughout.
- The changeset at the bottom of the stack becomes `minor` and says what a caller must change.

## Capabilities

### New Capabilities

(none)

### Modified Capabilities

- `cli`: adds the `=`-only rule for value flags and the removal of `-d`; the entry-point requirement drops the `-d` alias.
- `cli-check`, `cli-init`, `cli-ast`, `cli-detect`, `cli-onboard`, `cli-report`, `cli-rules`, `cli-agent`, `cli-runtime-rule-execution`, `cli-rule-reconciliation`, `cli-feedback-survey`, `cli-project-launcher`, `analytics`: requirements whose text or scenarios spell a value flag with a space, or name `-d`, are restated with the `=` spelling and `--dir`. Behavior is otherwise unchanged.

## Delivery shape

**Stacked, merging forward**, on top of `check-diff-scope` (#741). Both layers are green on their own. This layer depends on the optional-value handling that layer added to the argv scanner, and replaces it with the general rule. The single changeset lives at the bottom and is grown here to `minor`.

## Impact

- `packages/cli/src/util/argv.ts`, `src/index.ts`, `src/telemetry-run.ts`, `src/util/help.ts`, every command's `dir` arg, `src/commands/check.ts`.
- Recipes under `packages/cli/src/agent/`, `skills/taskless/SKILL.md`, both READMEs, `.github/workflows/reference-corpus.yml`.
- Tests: every CLI invocation that passes a value with a space.
- Callers outside this repository: the Taskless service and any user CI or hook configuration that passes `-d`, `--dir <path>`, `--rule <id>`, `--from <file>` and the like must switch to the `=` spelling. A refusal names the fix, so nothing fails silently.
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
## MODIFIED Requirements

### Requirement: CLI events use cli\_ prefix

CLI events SHALL use the `cli_` prefix, with the taxonomy organized as a
`cli_run` denominator plus concrete state-transition events:

- `cli_run` — exactly one per invocation (see the dedicated requirement). This
replaces every previous `cli_<action>` start event and `cli_<action>_completed`
event; the `success`/`durationMs`/`command` signal lives here.
- Concrete state-transition events, each fired at the point the state actually
changes, carrying counts/ids/booleans only (never rule content, prompts, or
matched source):
- `cli_rule_created`, `cli_rule_improved`, `cli_rule_deleted`
- `cli_authenticated`, `cli_logged_out`
- `cli_installed`, `cli_onboarded`
- `cli_check_completed` — error/warning counts and the number of rules the
scan had loaded: `errorCount`, `warningCount`, `findings`, `ruleCount`.
Counts only, never rule content, rule names, or matched source
- `cli_error` — a single failure event with `command` and `code` (a stable
`CLIErrorCode`)
- `cli_agent` — fired when the `agent` command serves a request, with a `topic`
property (the served topic; the exact literal `"(index)"` when invoked with no
topic; the attempted topic for an unknown request). This replaces the previous
`help_index`, `help_<topic>`, and `help_unknown` events.

Commands that carry no concrete state beyond the invocation (e.g. `info`,
`detect`, `update`, `auth status`, `rule verify`, `rule meta`) SHALL rely on
`cli_run` alone and SHALL NOT emit a bespoke event. The previous taxonomy
(`cli_<action>`, `cli_<action>_completed`, `help_index`, `help_<topic>`,
`help_unknown`) SHALL be removed in this release; there is no dual-emit window.

The survey events are the one exception to the prefix. `survey shown`,
`survey dismissed`, and `survey sent` are PostHog's own event literals for a
custom survey, and their `$survey_id` and `$survey_response_<question id>`
keys are PostHog's property contract; the CLI SHALL emit them under those
exact names and SHALL add no survey-specific property of its own. They go
through the same capture path as every other event, so the standard
properties (`cli`, `cliVersion`, `scaffoldVersion`, `ghOwner`, and the
adoption dimensions) ride on them the way they ride on everything else. No
other event SHALL omit the `cli_` prefix.

#### Scenario: Rule creation emits a concrete state event plus cli_run

- **WHEN** a user runs `taskless rule create --from=req.json` and a rule is written
- **THEN** PostHog SHALL receive one `cli_run` event with `command: "rule create"`
- **AND** SHALL receive a `cli_rule_created` event
- **AND** SHALL NOT receive `cli_rule_create` or `cli_rule_create_completed`

#### Scenario: Recipe fetch emits cli_agent with a topic

- **WHEN** an agent runs `taskless agent create-sg-rule`
- **THEN** PostHog SHALL receive a `cli_agent` event with `topic: "create-sg-rule"`
- **AND** SHALL NOT receive a `help_create_sg_rule` event

#### Scenario: Fetch with no topic emits cli_agent with the index marker

- **WHEN** an agent runs `taskless agent`
- **THEN** PostHog SHALL receive a `cli_agent` event with `topic: "(index)"`
- **AND** SHALL NOT receive a `help_index` event

#### Scenario: A command failure emits cli_error

- **WHEN** a command fails with a known `CLIErrorCode`
- **THEN** PostHog SHALL receive a `cli_error` event with `command` and `code`

#### Scenario: Old event names are not emitted

- **WHEN** any CLI command runs in this release
- **THEN** PostHog SHALL NOT receive any event named `cli_<action>_completed`,
`help_index`, `help_<topic>`, or `help_unknown`

#### Scenario: A completed scan reports how many rules were loaded

- **WHEN** a scan completes
- **THEN** the `cli_check_completed` event SHALL include `ruleCount`, the number
of rules the scan had loaded
- **AND** a scan that loaded no rules SHALL be distinguishable from a scan that
loaded rules and found nothing

#### Scenario: Survey events keep PostHog's names and carry the standard properties

- **WHEN** the CLI serves a survey invite, records a dismissal, or sends a response
- **THEN** PostHog SHALL receive `survey shown`, `survey dismissed`, or `survey sent` respectively, under that exact name
- **AND** the event SHALL carry `$survey_id` and the standard properties, and no survey-specific property beyond PostHog's own keys
- **AND** no event named `cli_survey_shown`, `cli_survey_dismissed`, or `cli_survey_sent` SHALL be emitted
Loading
Loading