From 779c3b1ef300e1e7eb5be9a80b136870ce487375 Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sat, 5 Dec 2026 16:55:10 -0800 Subject: [PATCH 1/6] feat(cli)!: value flags take their value only after =, and -d is removed --- .../value-flags-equals-only/.openspec.yaml | 2 + .../changes/value-flags-equals-only/design.md | 36 +++ .../value-flags-equals-only/proposal.md | 35 +++ .../specs/analytics/spec.md | 86 +++++++ .../specs/cli-agent/spec.md | 164 ++++++++++++++ .../specs/cli-ast/spec.md | 42 ++++ .../specs/cli-check/spec.md | 123 ++++++++++ .../specs/cli-detect/spec.md | 13 ++ .../specs/cli-feedback-survey/spec.md | 53 +++++ .../specs/cli-init/spec.md | 15 ++ .../specs/cli-onboard/spec.md | 46 ++++ .../specs/cli-project-launcher/spec.md | 20 ++ .../specs/cli-report/spec.md | 213 +++++++++++++++++ .../specs/cli-rule-reconciliation/spec.md | 40 ++++ .../specs/cli-rules/spec.md | 208 +++++++++++++++++ .../specs/cli-runtime-rule-execution/spec.md | 20 ++ .../value-flags-equals-only/specs/cli/spec.md | 214 ++++++++++++++++++ .../changes/value-flags-equals-only/tasks.md | 14 ++ packages/cli/src/commands/agent.ts | 1 - packages/cli/src/commands/ast.ts | 1 - packages/cli/src/commands/auth.ts | 3 - packages/cli/src/commands/check.ts | 57 ++--- packages/cli/src/commands/detect.ts | 1 - packages/cli/src/commands/feedback.ts | 2 - packages/cli/src/commands/info.ts | 1 - packages/cli/src/commands/init.ts | 2 - packages/cli/src/commands/onboard.ts | 1 - packages/cli/src/commands/report.ts | 1 - packages/cli/src/commands/rules.ts | 10 +- packages/cli/src/commands/verify.ts | 1 - packages/cli/src/index.ts | 50 ++-- packages/cli/src/telemetry-run.ts | 13 +- packages/cli/src/util/argv.ts | 137 +++-------- packages/cli/src/util/help.ts | 57 +++-- packages/cli/src/util/value-flags.ts | 40 ++++ packages/cli/test/agent-extensions.test.ts | 188 ++++++++------- packages/cli/test/ast-command.test.ts | 12 +- packages/cli/test/auth-login-json.test.ts | 8 +- packages/cli/test/auth-token-source.test.ts | 2 +- packages/cli/test/check-diff.test.ts | 38 ++-- .../cli/test/check-environment-notice.test.ts | 4 +- packages/cli/test/check-gitignore.test.ts | 3 +- packages/cli/test/check-rule-filter.test.ts | 52 ++--- packages/cli/test/check.test.ts | 101 ++++----- packages/cli/test/cli-run.test.ts | 6 +- packages/cli/test/cli.test.ts | 57 +++-- packages/cli/test/detect.test.ts | 2 +- packages/cli/test/engine-dispatch.test.ts | 5 +- packages/cli/test/error-envelope.test.ts | 77 +++---- packages/cli/test/example-project.test.ts | 11 +- packages/cli/test/feedback-recipes.test.ts | 3 +- packages/cli/test/help-flag.test.ts | 110 ++------- packages/cli/test/info-auth-state.test.ts | 6 +- packages/cli/test/info.test.ts | 7 +- packages/cli/test/init-no-interactive.test.ts | 104 ++++----- .../legacy-linter-vendor-contract.test.ts | 15 +- packages/cli/test/local-flag.test.ts | 88 +++++-- packages/cli/test/migrate-round-trip.test.ts | 26 +-- packages/cli/test/migrated-envelope.test.ts | 28 +-- packages/cli/test/mixed-engine-check.test.ts | 46 ++-- .../cli/test/no-implicit-migration.test.ts | 58 ++--- packages/cli/test/onboard.test.ts | 52 +++-- packages/cli/test/prompts.test.ts | 9 +- packages/cli/test/recipe-sections.test.ts | 14 +- packages/cli/test/reconcile-marker.test.ts | 125 ++++++---- packages/cli/test/reference-verify.test.ts | 5 +- packages/cli/test/report.test.ts | 33 ++- .../rule-commands-refuse-migration.test.ts | 10 +- .../cli/test/rule-create-entitlement.test.ts | 6 +- .../cli/test/rule-create-multi-rule.test.ts | 2 +- packages/cli/test/rule-from.test.ts | 21 +- .../cli/test/rule-guard-json-envelope.test.ts | 4 +- packages/cli/test/rule-poll-transient.test.ts | 8 +- packages/cli/test/rule-recovery.test.ts | 10 +- packages/cli/test/run-directory.test.ts | 4 +- packages/cli/test/runtime-check.test.ts | 49 ++-- .../cli/test/runtime-fixture-runner.test.ts | 5 +- packages/cli/test/schemas-export.test.ts | 14 +- packages/cli/test/sg-engine-parse.test.ts | 6 +- packages/cli/test/sg-fixtures.test.ts | 12 +- packages/cli/test/support/current-project.ts | 5 +- packages/cli/test/vale-orchestration.test.ts | 19 +- .../cli/test/validate-verify-commands.test.ts | 88 ++++--- packages/cli/test/value-flags.test.ts | 102 +++++++++ packages/cli/test/verify.test.ts | 44 ++-- packages/cli/test/version-flag.test.ts | 10 +- packages/cli/test/version-gate-cli.test.ts | 14 +- 87 files changed, 2379 insertions(+), 1071 deletions(-) create mode 100644 openspec/changes/value-flags-equals-only/.openspec.yaml create mode 100644 openspec/changes/value-flags-equals-only/design.md create mode 100644 openspec/changes/value-flags-equals-only/proposal.md create mode 100644 openspec/changes/value-flags-equals-only/specs/analytics/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-agent/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-ast/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-check/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-detect/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-feedback-survey/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-init/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-onboard/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-project-launcher/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-report/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-rule-reconciliation/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-rules/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli-runtime-rule-execution/spec.md create mode 100644 openspec/changes/value-flags-equals-only/specs/cli/spec.md create mode 100644 openspec/changes/value-flags-equals-only/tasks.md create mode 100644 packages/cli/src/util/value-flags.ts create mode 100644 packages/cli/test/value-flags.test.ts diff --git a/openspec/changes/value-flags-equals-only/.openspec.yaml b/openspec/changes/value-flags-equals-only/.openspec.yaml new file mode 100644 index 000000000..35a260cfb --- /dev/null +++ b/openspec/changes/value-flags-equals-only/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-12-05 diff --git a/openspec/changes/value-flags-equals-only/design.md b/openspec/changes/value-flags-equals-only/design.md new file mode 100644 index 000000000..b7f6fd96f --- /dev/null +++ b/openspec/changes/value-flags-equals-only/design.md @@ -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 ` into `--dir=` 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 `--` 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=`) 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. diff --git a/openspec/changes/value-flags-equals-only/proposal.md b/openspec/changes/value-flags-equals-only/proposal.md new file mode 100644 index 000000000..6bdb7791d --- /dev/null +++ b/openspec/changes/value-flags-equals-only/proposal.md @@ -0,0 +1,35 @@ +## Why + +`check --diff` (the change below this one in the stack) takes its value only from `--diff=`, 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 ` before a subcommand is rewritten into `--dir=` 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=`. No other short flag takes a value. +- The argv scanner no longer consumes a token after any flag, and the `-d ` 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 `, `--rule `, `--from ` and the like must switch to the `=` spelling. A refusal names the fix, so nothing fails silently. diff --git a/openspec/changes/value-flags-equals-only/specs/analytics/spec.md b/openspec/changes/value-flags-equals-only/specs/analytics/spec.md new file mode 100644 index 000000000..2337212d1 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/analytics/spec.md @@ -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_` start event and `cli__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_`, 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_`, `cli__completed`, `help_index`, `help_`, +`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_` +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__completed`, + `help_index`, `help_`, 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 diff --git a/openspec/changes/value-flags-equals-only/specs/cli-agent/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-agent/spec.md new file mode 100644 index 000000000..593dc1ff3 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-agent/spec.md @@ -0,0 +1,164 @@ +## MODIFIED Requirements + +### Requirement: Agent subcommand serves recipes for commands + +The CLI SHALL support an `agent` subcommand that accepts at most one positional argument identifying a topic, an optional `--anonymous` boolean flag, an optional `--tool=` value flag, an optional `--section=` value flag, AND an optional `--full` boolean flag. Topics SHALL be addressed by a single token; the subcommand SHALL NOT join multiple positionals into a topic key. When a topic is provided, the subcommand SHALL look up a matching recipe file embedded at build time using the following resolution order: + +1. If `--tool` is set AND `..md` exists in the embedded map, return that file. +2. If `--anonymous` is set AND `.anonymous.md` exists in the embedded map, return that file. +3. Otherwise, return `.md`. +4. If none of these exists, exit with code 1 and an error message suggesting `taskless agent` for the topic index. + +On a topic that has tool variants, `--tool` SHALL refuse, with a non-zero exit and a message naming the recipe to use instead, a tool that has its own authoring recipe (`ast-grep`, `vale`) or that cannot hold a rule (`prettier`, `black`). An unrecognized tool name SHALL fall back to `.md`. + +Which part of the resolved recipe is printed is governed by the requirement "Long topics are served as an outline with sections on request": by default its outline, with `--section` one section, with `--full` all of it. A second positional SHALL NOT be read as a section name; the error for it SHALL name `--section=`. + +When no positional argument is provided, the subcommand SHALL print a topic index containing a one-paragraph human slug followed by a topic disambiguation table mapping topic names to their summaries. + +The subcommand is named for its reader. It serves agents fetching a procedure, not humans asking for help, and single-token addressing exists so a topic name is a literal string an agent copies rather than a phrase it can reorder or paraphrase. + +#### Scenario: Agent subcommand for a topic returns the recipe + +- **WHEN** a user runs `taskless agent check` +- **THEN** the CLI SHALL print the outline of `check.md` to stdout + +#### Scenario: Multi-word topic paths are not resolved + +- **WHEN** a user runs `taskless agent rule create` +- **THEN** the CLI SHALL NOT look up `rule-create.md` by joining the positionals +- **AND** it SHALL exit non-zero rather than guessing a topic +- **AND** it SHALL NOT read `create` as a section name + +#### Scenario: Formerly nested topics are addressed by one token + +- **WHEN** a user runs `taskless agent improve-rule` +- **THEN** the CLI SHALL look up `improve-rule.md` and print its contents + +#### Scenario: The former command name is gone + +- **WHEN** a user runs `taskless help check` +- **THEN** the CLI SHALL NOT print recipe text for `check` + +#### Scenario: A tool variant is served + +- **WHEN** a user runs `taskless agent create-legacy-rule --tool=ruff` +- **AND** `create-legacy-rule.ruff.md` exists +- **THEN** the CLI SHALL print that file's contents + +#### Scenario: An unknown tool falls back to the generic recipe + +- **WHEN** a user runs `taskless agent create-legacy-rule --tool=rubocop` +- **AND** no `create-legacy-rule.rubocop.md` exists +- **THEN** the CLI SHALL print `create-legacy-rule.md` + +#### Scenario: A tool with its own recipe is refused + +- **WHEN** a user runs `taskless agent create-legacy-rule --tool=vale` +- **THEN** the CLI SHALL exit non-zero and name `create-vale-rule` as the recipe to use + +#### Scenario: A refused tool name is ignored on a topic without tool variants + +- **WHEN** a user runs `taskless agent route --tool=vale` +- **THEN** the CLI SHALL print `route.md` and exit zero + +#### Scenario: An unknown topic is not masked by a refused tool + +- **WHEN** a user runs `taskless agent no-such-topic --tool=vale` +- **THEN** the CLI SHALL exit non-zero with the unknown-topic error, not the tool refusal + +### Requirement: Recipe files follow a consistent format + +Every recipe file at `packages/cli/src/agent/.md` SHALL follow the canonical recipe template: a single-line header `# Topic: (CLI v%(CLI_VERSION)s / topic v)`, followed by `## Goal`, `## Preconditions`, `## Steps`, optional `## Input schema` (for recipes that take `--from`), `## Errors`, and `## See Also` sections in that order. Recipe templates SHALL use sprintf-js `%(KEY)s` named-argument placeholders for all substitution. The header SHALL embed `%(CLI_VERSION)s` for the CLI version. Topics that document a `--from` input SHALL embed `%(INPUT_SCHEMA)s` inside the `## Input schema` fenced code block. The topic version integer in the header SHALL be a literal value maintained by the recipe author and bumped when the recipe changes meaningfully. + +#### Scenario: Recipe contains all template sections + +- **WHEN** any `.md` file is read +- **THEN** it SHALL begin with a `# Topic:` header containing `%(CLI_VERSION)s` and the topic version integer +- **AND** SHALL contain `## Goal`, `## Preconditions`, `## Steps`, `## Errors`, and `## See Also` sections in that order + +#### Scenario: Recipe with --from input includes JSON schema placeholder + +- **WHEN** a topic recipe documents a CLI invocation that uses `--from=` +- **THEN** the recipe SHALL contain an `## Input schema` section with a code-fenced block containing the `%(INPUT_SCHEMA)s` placeholder +- **AND** the JSON Schema SHALL be derived at render time from the corresponding Zod schema in `packages/cli/src/schemas/` + +#### Scenario: Header version reflects build-time CLI version + +- **WHEN** the CLI bundle is built +- **THEN** the recipe header's `%(CLI_VERSION)s` placeholder SHALL be substituted at render time from `packages/cli/package.json` +- **AND** SHALL match the version reported by `taskless info` + +### Requirement: Embedded JSON schemas are generated via zod-to-json-schema + +For every recipe topic that documents a CLI command accepting `--from=`, the corresponding Zod input schema in `packages/cli/src/schemas/` SHALL be converted to JSON Schema and embedded in the recipe's `## Input schema` section as a fenced code block. Generation MAY happen at runtime (small dep, fast) or at build time; runtime is acceptable. + +#### Scenario: The remote authoring recipe embeds its input schema + +- **WHEN** a user runs `taskless agent create-remote-rule` +- **THEN** the output SHALL contain an `## Input schema` section +- **AND** the section SHALL contain a code-fenced JSON Schema block derived from the `rules-create` Zod schema + +#### Scenario: The improve recipe embeds its input schema + +- **WHEN** a user runs `taskless agent improve-rule` +- **THEN** the output SHALL contain an `## Input schema` section with the rule-improve JSON Schema + +### Requirement: Long topics are served as an outline with sections on request + +A recipe's `## ` headings outside fenced blocks SHALL divide it into sections, and everything before the first is its preamble: the header block and the one-command-per-call paragraph. Each section SHALL be addressable by the slug of its heading: lowercase, every run of characters other than letters and digits collapsed to one hyphen, with none leading or trailing. An author SHALL mark a section to be served on request by writing `` on the line directly above its heading. The marker SHALL be removed from every rendering, and a marker not directly above a `## ` heading SHALL fail when the recipes load. + +`taskless agent ` SHALL print the topic's outline: the preamble and every section not marked on demand, in order, then a `## Sections on request` section naming each section it left out and the command that prints one, ` agent --section=`, spelled with the `--tool` or `--anonymous` flag that selected the recipe. A recipe with no section marked on demand SHALL print unchanged. `taskless onboard` and `taskless update` (without `--rules`) SHALL print the same outline as `agent onboard` and `agent update`. + +`--section=` SHALL print the preamble, that one section, and a closing line naming the command that prints the topic's outline. A name the topic has no section for SHALL exit 1 and list the topic's section names. `--full` SHALL print the whole recipe, identical to what `@taskless/cli/prompts` renders for the same options with the directive requested. The `@taskless/cli/prompts` export SHALL render the whole recipe. + +A cross-reference to another section of the same recipe SHALL be written as a markdown link to its name, `[Quirks](#quirks)`. The whole recipe SHALL keep the link. The outline and a section SHALL rewrite a link to a section they do not print as that section's name. A cross-reference to a section of another topic SHALL be written as the command that prints it. + +Each topic's outline, and each section printed on its own, SHALL fit 8 KiB when rendered with a nightly's invocation, the feedback invite included for a surveyed topic, enforced by a test. Every section link SHALL name a section of the same recipe and every `--section` citation a section of the cited topic, enforced by a test. + +A section fetch SHALL capture `cli_agent` with `topic` and `section`, and SHALL NOT carry the feedback invite. + +#### Scenario: A long topic prints its outline + +- **WHEN** a user runs `taskless agent create-sg-rule` +- **THEN** stdout SHALL contain its steps +- **AND** SHALL NOT contain the sections marked on demand +- **AND** SHALL end with `## Sections on request`, listing `quirks` and the command that prints a section + +#### Scenario: One section is printed + +- **WHEN** a user runs `taskless agent create-sg-rule --section=quirks` +- **THEN** stdout SHALL begin with the recipe's header block and one-command-per-call paragraph +- **AND** SHALL contain the `## Quirks` section and no other section + +#### Scenario: An unknown section is refused + +- **WHEN** a user runs `taskless agent create-sg-rule --section=nope` +- **THEN** the CLI SHALL exit 1 and list the topic's section names on stderr + +#### Scenario: The whole recipe is printed on request + +- **WHEN** a user runs `taskless agent route --full` +- **THEN** stdout SHALL equal the `@taskless/cli/prompts` rendering of `route` with the directive requested + +#### Scenario: A short topic is unchanged + +- **WHEN** a user runs `taskless agent rule` +- **AND** `rule.md` marks no section on demand +- **THEN** stdout SHALL be the whole recipe, with no `## Sections on request` + +#### Scenario: A link to a section left out names it + +- **WHEN** a step links `[Quirks](#quirks)` and the outline does not print `quirks` +- **THEN** the outline SHALL read "section `quirks`" in its place +- **AND** the whole recipe SHALL keep the link + +#### Scenario: Every topic fits the budget + +- **WHEN** the test suite renders every recipe's outline and every section with a nightly's invocation +- **THEN** each SHALL be at most 8192 bytes, the feedback invite counted for a surveyed topic + +#### Scenario: A section fetch is told apart in telemetry + +- **WHEN** a user runs `taskless agent create-sg-rule --section=quirks` +- **THEN** PostHog SHALL receive `cli_agent` with `topic: "create-sg-rule"` and `section: "quirks"` +- **AND** stdout SHALL NOT carry the feedback invite diff --git a/openspec/changes/value-flags-equals-only/specs/cli-ast/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-ast/spec.md new file mode 100644 index 000000000..5056eaccb --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-ast/spec.md @@ -0,0 +1,42 @@ +## MODIFIED Requirements + +### Requirement: The ast command prints a file's named-node AST + +The CLI SHALL provide `taskless ast `, which prints the named-node syntax tree of one file as the ast-grep bundled with the CLI parses it. It SHALL print named nodes only, so that every kind it shows is one a rule's `kind:` accepts. Each node SHALL carry its kind, the field it fills in its parent when the grammar names one, and its start and end as a 1-based line and a 0-based byte column. A node with no named children SHALL carry its source text. The command SHALL read the file and write nothing, and SHALL NOT require `.taskless/` to exist. It SHALL accept `--dir`, against which a relative file path resolves. + +#### Scenario: A file is dumped by its extension + +- **WHEN** `taskless ast src/a.ts` is run on a file holding `const a = 1;` +- **THEN** the output SHALL name the language `TypeScript` +- **AND** it SHALL list `lexical_declaration`, `variable_declarator` and `name: identifier` with their positions +- **AND** it SHALL NOT list the `const` keyword as a node + +#### Scenario: JSON output + +- **WHEN** `taskless ast --json` succeeds +- **THEN** stdout SHALL be one JSON object with `ok: true`, `file`, `language`, `errorNodes` and a nested `root` node +- **AND** `errorNodes` SHALL count the `ERROR` nodes in the whole tree, so a file that did not parse cleanly as that language is visible + +### Requirement: The ast command uses check's language resolution + +Without `--lang`, the command SHALL parse the file as the language the bundled ast-grep assigns its path, asked of the binary rather than of a table in the CLI, and SHALL NOT apply the `languageGlobs` of an `sgconfig.yml` found above the working directory, since `check` does not. `--lang` SHALL take any spelling a rule's `language:` accepts and parse as the language it resolves to. + +#### Scenario: An extension ast-grep does not recognize + +- **WHEN** `taskless ast notes.unknownext --json` is run +- **THEN** stdout SHALL be an `INVALID_INPUT` envelope that says the extension is not recognized and lists the languages `--lang` accepts +- **AND** the exit code SHALL be 1 + +#### Scenario: A language override + +- **WHEN** `taskless ast list.txt --lang=yaml` is run +- **THEN** the file SHALL be parsed as `Yaml` + +### Requirement: The ast command can cut the tree to a line range + +`--range=` or `--range=:`, 1-based and inclusive, SHALL cut the tree to the nodes whose lines overlap the range, keeping the nodes that enclose them. A node that ends at column 0 of a line SHALL NOT count as on that line. A range that no node touches, and a malformed range, SHALL fail with `INVALID_INPUT`. + +#### Scenario: One line of a file + +- **WHEN** a file's third line is `foo(b);` and `taskless ast --range=3` is run +- **THEN** the root SHALL keep only the `expression_statement` on line 3 among its children diff --git a/openspec/changes/value-flags-equals-only/specs/cli-check/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-check/spec.md new file mode 100644 index 000000000..39b65d01e --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-check/spec.md @@ -0,0 +1,123 @@ +## MODIFIED Requirements + +### Requirement: Check subcommand respects global working directory flag + +The `check` subcommand SHALL use the resolved working directory from the global `--dir` flag (or `process.cwd()` if not specified) as the target directory for `.taskless/` validation and scanner execution. + +#### Scenario: Check uses custom directory + +- **WHEN** a user runs `taskless check --dir=/path/to/repo` +- **THEN** `.taskless/` validation and scanning SHALL operate on `/path/to/repo` + +#### Scenario: Check defaults to current directory + +- **WHEN** a user runs `taskless check` without `--dir` +- **THEN** `.taskless/` validation and scanning SHALL operate on `process.cwd()` + +### Requirement: Check accepts positional path arguments + +The `check` subcommand SHALL accept zero or more positional path arguments. When zero paths are passed, the CLI SHALL scan the full project directory (existing behavior). When one or more paths are passed, the CLI SHALL forward those paths to `sg scan` so that only the specified files and directories are scanned. Paths SHALL be treated relative to the resolved working directory (`--dir` / `process.cwd()`). + +Before forwarding, the CLI SHALL silently drop any path that does not exist on disk at invocation time. This lets CI pipelines pipe raw git-diff output directly (e.g. `taskless check $(git diff --name-only main...HEAD)`) without pre-filtering deleted files. If every supplied path is filtered out and the original argument list was non-empty, the CLI SHALL exit with code 0 and print no matches (interpreted as "nothing changed, nothing to scan"). + +#### Scenario: Zero path arguments scans the whole project + +- **WHEN** a user runs `taskless check` +- **THEN** `sg scan` SHALL be invoked without any trailing path arguments +- **AND** the scan SHALL cover the entire resolved working directory + +#### Scenario: Explicit paths limit the scan + +- **WHEN** a user runs `taskless check src/foo.ts src/bar.ts` +- **AND** both files exist on disk +- **THEN** `sg scan` SHALL be invoked with `src/foo.ts` and `src/bar.ts` as trailing arguments +- **AND** the scan SHALL NOT include files outside those two paths + +#### Scenario: Non-existent paths are silently filtered + +- **WHEN** a user runs `taskless check src/present.ts src/deleted.ts` +- **AND** `src/present.ts` exists but `src/deleted.ts` does not +- **THEN** the CLI SHALL forward only `src/present.ts` to `sg scan` +- **AND** SHALL NOT error on the missing path + +#### Scenario: All paths filtered out exits cleanly + +- **WHEN** a user runs `taskless check src/deleted-a.ts src/deleted-b.ts` +- **AND** neither file exists on disk +- **THEN** the CLI SHALL exit with code 0 +- **AND** SHALL NOT invoke `sg scan` +- **AND** SHALL report no results (empty results array in JSON mode) + +#### Scenario: Relative paths resolve against the working directory + +- **WHEN** a user runs `taskless check --dir=/path/to/project src/foo.ts` +- **AND** `/path/to/project/src/foo.ts` exists +- **THEN** the CLI SHALL treat `src/foo.ts` as relative to `/path/to/project` +- **AND** SHALL forward that relative path to `sg scan` with `cwd = /path/to/project` + +#### Scenario: Directory paths are accepted + +- **WHEN** a user runs `taskless check src/` +- **AND** `src/` is a directory +- **THEN** the CLI SHALL forward `src/` to `sg scan` +- **AND** the scan SHALL cover files under that directory + +### Requirement: Check restricts the run to named rules with --rule + +The `check` subcommand SHALL accept a `--rule=` flag, repeatable, naming the rules the run is restricted to. When `--rule` is absent the run SHALL be unchanged. When one or more are given, the CLI SHALL report findings only for the named rules, and for each named rule SHALL report exactly what an unfiltered `check` over the same paths would have reported for it: the same walk, the same exclusions (`.taskless/`, `.git/`, git-ignored paths, converter-dependent formats), and the same per-rule scope. + +A rule id is the name of a rule's directory under `.taskless/rules//`. The filter SHALL apply to every engine. An id whose rule directory exists under more than one engine SHALL select the rule under each of them. An id that names no rule directory under any engine SHALL be refused: the CLI SHALL exit with code 1 and report the error code `RULE_NOT_FOUND` naming the unresolved id, and SHALL NOT run any engine. + +`--rule` SHALL NOT widen what may run. A runtime rule named by `--rule` SHALL remain subject to the signature-validated path, and SHALL be reported as skipped on an unverified path exactly as it would be in an unfiltered run. + +#### Scenario: A single --rule narrows the run to that rule + +- **WHEN** a user runs `taskless check --rule=` in a project with rules beyond `` +- **THEN** the results SHALL contain findings for `` only +- **AND** they SHALL be the findings an unfiltered `taskless check` reports for `` + +#### Scenario: Repeated --rule unions the named rules + +- **WHEN** a user runs `taskless check --rule=a --rule=b` +- **THEN** the results SHALL contain the findings for `a` and the findings for `b`, and no others + +#### Scenario: The filter applies to both static engines + +- **WHEN** a user names an ast-grep rule with `--rule`, and separately names a Vale rule +- **THEN** each run SHALL report that rule's findings over the whole project +- **AND** a Vale rule SHALL be measured under its own config's matchers, not over every file Vale can read + +#### Scenario: Whole-project exclusions still apply under --rule + +- **WHEN** a user runs `taskless check --rule=` with no positional paths in a project with git-ignored directories +- **THEN** the CLI SHALL NOT report findings from `.taskless/`, `.git/`, or git-ignored paths + +#### Scenario: A refused sibling config refuses a filtered run too + +- **WHEN** a user runs `taskless check --rule=` in a project where a DIFFERENT Vale rule's config is rejected by the config schema +- **THEN** the CLI SHALL refuse the Vale engine and exit non-zero, exactly as an unfiltered `taskless check` does +- **AND** the refusal SHALL name the rejected rule even though `--rule` did not select it + +#### Scenario: An unknown rule id is refused + +- **WHEN** a user runs `taskless check --rule=` and no engine directory holds a rule directory named `` +- **THEN** the CLI SHALL exit with code 1 +- **AND** under `--json` stdout SHALL carry the standardized error envelope with code `RULE_NOT_FOUND` and a message naming `` +- **AND** the CLI SHALL NOT run any engine + +#### Scenario: An id held by two engines selects both rules + +- **WHEN** a user runs `taskless check --rule=` and `` names a rule directory under two engines +- **THEN** the CLI SHALL run both rules and SHALL report the findings of each, distinguished by the `source` field + +#### Scenario: --rule does not bypass the runtime signature gate + +- **WHEN** a user runs `taskless check --rule=` where `` is a runtime rule and the run is on an unverified path +- **THEN** the CLI SHALL NOT execute that rule's `check.ts` +- **AND** SHALL report it as skipped exactly as an unfiltered `check` would + +#### Scenario: --rule leaves positional path arguments intact + +- **WHEN** a user runs `taskless check --rule= src/foo.ts` +- **THEN** the CLI SHALL treat `src/foo.ts` as the path to scan and `` as the rule filter +- **AND** SHALL NOT treat `` as a path diff --git a/openspec/changes/value-flags-equals-only/specs/cli-detect/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-detect/spec.md new file mode 100644 index 000000000..651cd8bb1 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-detect/spec.md @@ -0,0 +1,13 @@ +## MODIFIED Requirements + +### Requirement: Detect subcommand exists + +The CLI SHALL provide a `taskless detect` subcommand registered in the top-level +command list, with a `--json` flag and the standard `--dir` working-directory +flag. + +#### Scenario: Detect is registered + +- **WHEN** `taskless detect --help` is run +- **THEN** the command SHALL be recognized and print its usage +- **AND** the command SHALL accept `--json` and `--dir` diff --git a/openspec/changes/value-flags-equals-only/specs/cli-feedback-survey/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-feedback-survey/spec.md new file mode 100644 index 000000000..bdc3bbfcf --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-feedback-survey/spec.md @@ -0,0 +1,53 @@ +## MODIFIED Requirements + +### Requirement: The feedback subcommand records dismissals and sends responses + +The CLI SHALL provide a `feedback` subcommand with two verbs. `feedback dismiss` SHALL capture `survey dismissed` with the rule survey's `$survey_id` and advance that survey's `next_ask`. `feedback send --from=` SHALL read a JSON file, validate it against the feedback payload schema, and capture `survey sent` with the `$survey_id` of the survey the payload's `kind` selects; for a `rule` payload it SHALL also advance `next_ask`. Both verbs SHALL accept `--dir`. Neither SHALL require `.taskless/` to exist, run migrations, or write into the project. `feedback send` SHALL NOT delete its input file. + +When the telemetry client is disabled, `feedback dismiss` SHALL print a single line saying nothing was sent and exit zero. `feedback send` SHALL still validate the payload first, and on a valid payload SHALL send nothing, print that telemetry is disabled so nothing was sent, name `https://github.com/taskless/cli/issues` as the place to report instead, and exit zero. + +The `taskless agent` topic index SHALL list `feedback` and `bug-report` and SHALL NOT list `rule-feedback`. `taskless agent rule-feedback` SHALL still serve the `rule-feedback` recipe. + +#### Scenario: Dismiss + +- **WHEN** an agent runs `taskless feedback dismiss` +- **THEN** PostHog SHALL receive `survey dismissed` with the rule survey's `$survey_id` +- **AND** the command SHALL exit zero + +#### Scenario: Send a valid payload + +- **WHEN** an agent runs `taskless feedback send --from=.taskless/.tmp-feedback.json` with a payload that passes validation +- **THEN** PostHog SHALL receive `survey sent` carrying the `$survey_id` for the payload's `kind` and one `$survey_response_` per answered question, and no other survey-specific property +- **AND** the command SHALL exit zero and leave the input file in place + +#### Scenario: Each kind reaches its own survey + +- **WHEN** valid payloads of kind `rule`, `general`, and `bug` are each sent +- **THEN** their `survey sent` events SHALL carry `$survey_id` `01a0c7b9-dfe4-0000-d05e-ce253e90a68c`, `01a11da4-3948-0000-4ae4-c9da9321801e`, and `01a11da7-27a2-0000-0f4e-6d3e1f89f385` respectively + +#### Scenario: Send an invalid payload + +- **WHEN** the payload is missing a required key, has no `kind` or an unknown `kind`, or `completed` is not one of the allowed values +- **THEN** the command SHALL exit non-zero with `INVALID_INPUT`, naming the failing field +- **AND** no survey event SHALL be captured and `next_ask` SHALL be unchanged + +#### Scenario: Telemetry disabled + +- **WHEN** `DO_NOT_TRACK=1` and an agent runs `feedback dismiss`, or runs `feedback send` with a valid payload of any kind +- **THEN** the command SHALL send nothing and exit zero +- **AND** `feedback send` SHALL print that telemetry is disabled and name `https://github.com/taskless/cli/issues` + +#### Scenario: Telemetry disabled does not excuse an invalid payload + +- **WHEN** `DO_NOT_TRACK=1` and the payload fails validation +- **THEN** the command SHALL exit non-zero with `INVALID_INPUT` + +#### Scenario: Not in the index + +- **WHEN** an agent runs `taskless agent` +- **THEN** the printed index SHALL NOT list `rule-feedback` + +#### Scenario: The user-initiated channels are in the index + +- **WHEN** an agent runs `taskless agent` +- **THEN** the printed index SHALL list `feedback` and `bug-report` diff --git a/openspec/changes/value-flags-equals-only/specs/cli-init/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-init/spec.md new file mode 100644 index 000000000..c4b24ba1d --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-init/spec.md @@ -0,0 +1,15 @@ +## MODIFIED Requirements + +### Requirement: Init respects the global working directory flag + +The `init` subcommand SHALL use the resolved working directory from the global `--dir` flag (or `process.cwd()` if not specified) as the target directory for tool detection and skill installation. + +#### Scenario: Init uses custom directory + +- **WHEN** a user runs `taskless init --dir=/path/to/repo` +- **THEN** tool detection and skill installation SHALL operate on `/path/to/repo` + +#### Scenario: Init defaults to current directory + +- **WHEN** a user runs `taskless init` without `--dir` +- **THEN** tool detection and skill installation SHALL operate on `process.cwd()` diff --git a/openspec/changes/value-flags-equals-only/specs/cli-onboard/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-onboard/spec.md new file mode 100644 index 000000000..0a3faef90 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-onboard/spec.md @@ -0,0 +1,46 @@ +## MODIFIED Requirements + +### Requirement: Onboard subcommand exists with --force and --mark-complete flags + +The CLI SHALL support a `taskless onboard` subcommand. The subcommand SHALL accept the global `--dir` working-directory flag, a `--force` boolean flag (default `false`), and a `--mark-complete` boolean flag (default `false`). `--force` and `--mark-complete` SHALL be mutually exclusive; supplying both SHALL exit with code 1 and a clear error message. The subcommand SHALL bootstrap the `.taskless/` directory via `ensureTasklessDirectory()` before reading or writing manifest state. + +The subcommand SHALL NOT migrate `.taskless/`. In every mode, before bootstrapping, it SHALL refuse a scaffold whose schema version is below the latest migration with `SCAFFOLD_MIGRATION_REQUIRED`, and one whose version is above it with `SCAFFOLD_VERSION_MISMATCH`, exiting with code 1, printing the code on stderr, and naming the command that resolves it. Migrations move and delete tracked files, and `taskless init` is the command that runs them. A `.taskless/` that is absent SHALL still be created, since creating a fresh directory rewrites nothing. + +#### Scenario: Onboard command is registered + +- **WHEN** a user runs `taskless --help` +- **THEN** `onboard` SHALL appear in the list of available subcommands +- **AND** the description SHALL describe it as the post-install discovery flow + +#### Scenario: Onboard accepts --force + +- **WHEN** a user runs `taskless onboard --force` +- **THEN** the command SHALL accept the flag without error + +#### Scenario: Onboard accepts --mark-complete + +- **WHEN** a user (or agent) runs `taskless onboard --mark-complete` +- **THEN** the command SHALL accept the flag without error + +#### Scenario: --force and --mark-complete are mutually exclusive + +- **WHEN** a user runs `taskless onboard --force --mark-complete` +- **THEN** the command SHALL exit with code 1 +- **AND** SHALL print an error message stating that the two flags cannot be combined + +#### Scenario: Onboard respects the global -d flag + +- **WHEN** a user runs `taskless onboard --dir=/path/to/repo` +- **THEN** all manifest reads and writes SHALL operate on `/path/to/repo/.taskless/taskless.json` + +#### Scenario: Onboard refuses a scaffold that is behind the CLI + +- **WHEN** `.taskless/taskless.json` records a schema version below the latest migration and a user runs `taskless onboard`, with or without `--force` or `--mark-complete` +- **THEN** the command SHALL exit with code 1 and print `SCAFFOLD_MIGRATION_REQUIRED` on stderr, naming `taskless init` +- **AND** SHALL NOT print the recipe or write the manifest +- **AND** SHALL leave every file under `.taskless/` as it was + +#### Scenario: Onboard scaffolds a project with no .taskless directory + +- **WHEN** no `.taskless/` exists and a user runs `taskless onboard` +- **THEN** the command SHALL create `.taskless/` at the latest schema version and print the recipe diff --git a/openspec/changes/value-flags-equals-only/specs/cli-project-launcher/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-project-launcher/spec.md new file mode 100644 index 000000000..85cef09a0 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-project-launcher/spec.md @@ -0,0 +1,20 @@ +## MODIFIED Requirements + +### Requirement: Messages a person reads name the launcher that started the CLI + +When a project launcher started the CLI, as its environment variable reports with exactly one of the two launcher paths, every command the CLI prints for a person to run next (a remedy in an error, a hint after a command, the installer named in a `SKIPPED (global):` line) SHALL name that launcher's path. Otherwise it SHALL name the detected `npx` or `pnpm dlx` invocation, as before. A remedy that names the CLI SHALL reach it through this one choice rather than spelling the build's invocation itself. + +#### Scenario: A hint after a launcher run + +- **WHEN** `./.taskless/bin/cli.mjs check` runs in a project with no rules +- **THEN** the hint SHALL tell the reader to run `./.taskless/bin/cli.mjs rule create --from=` + +#### Scenario: A hint after an npx run + +- **WHEN** `npx @taskless/cli@0.13.0 check` runs in a project with no rules and no launcher variable set +- **THEN** the hint SHALL name `npx @taskless/cli@0.13.0` + +#### Scenario: An unexpected variable is ignored + +- **WHEN** the launcher variable is `./evil.sh` +- **THEN** printed commands SHALL NOT name `./evil.sh` diff --git a/openspec/changes/value-flags-equals-only/specs/cli-report/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-report/spec.md new file mode 100644 index 000000000..7b1f65226 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-report/spec.md @@ -0,0 +1,213 @@ +## MODIFIED Requirements + +### Requirement: Report subcommand exists with a draft mode, a publish mode, and delete + +The CLI SHALL provide a `taskless report` subcommand accepting the standard `--dir` working-directory flag. Invoked with no mode flag it SHALL print a draft. Invoked with `--from=` it SHALL publish. `taskless report --delete=` SHALL delete a previously published report. `--from` and `--delete` SHALL be mutually exclusive; supplying both SHALL exit non-zero with `INVALID_INPUT`. The subcommand SHALL require no authentication in any mode, and SHALL bootstrap `.taskless/` before reading or writing under it. + +The subcommand SHALL NOT migrate `.taskless/`. In every mode, before bootstrapping, it SHALL refuse a scaffold whose schema version is below the latest migration with `SCAFFOLD_MIGRATION_REQUIRED`, and one whose version is above it with `SCAFFOLD_VERSION_MISMATCH`, exiting non-zero and reporting the code as it reports any other error: on stderr, or as the `{ ok: false, code, message }` envelope under `--json`. Migrations move and delete tracked files, and `taskless init` is the command that runs them. A `.taskless/` that is absent SHALL still be created, since creating a fresh directory rewrites nothing. + +#### Scenario: Report is registered + +- **WHEN** a user runs `taskless --help` +- **THEN** `report` SHALL appear in the list of subcommands + +#### Scenario: Report works logged out + +- **WHEN** a user who has never logged in runs `taskless report` or `taskless report --from=` +- **THEN** the command SHALL NOT prompt for or require authentication + +#### Scenario: Report refuses a scaffold that is behind the CLI + +- **WHEN** `.taskless/taskless.json` records a schema version below the latest migration and a user runs `taskless report`, `taskless report --from=`, or `taskless report --delete=` +- **THEN** the command SHALL exit non-zero with `SCAFFOLD_MIGRATION_REQUIRED`, naming `taskless init` +- **AND** SHALL NOT print a draft, publish, or delete anything +- **AND** SHALL leave every file under `.taskless/` as it was + +#### Scenario: Report --json carries the refusal code + +- **WHEN** `.taskless/` is behind the CLI and a user runs `taskless report --json` +- **THEN** stdout SHALL be exactly the envelope `{ ok: false, code: "SCAFFOLD_MIGRATION_REQUIRED", message }` + +### Requirement: The agent supplies session facts, not a report + +`taskless report --from=` SHALL read a facts file, not a ReportV1. The facts file SHALL carry only what the agent knows from its session: the history counts and the window they were mined over, per-rule titles, an `explain` for every rule (the agent's take, in one or two sentences, on why the rule is worth holding in this codebase), and `surfaced` counts (the merged pull requests in the window whose review raised the rule's pattern, and the review comments that asked for it), optionally per-rule `sources` (the kinds of source the rule came from) and `evidence` (a count of explicit call-outs per kind), rules authored into an existing linter (`legacy` tier), runtime-shaped candidates the agent did not author (`cloud` tier) each with `estimatedViolations`, the agent's estimate of how many instances of the candidate's pattern are in the code today, the agent's own redaction counts, and the fixtures it elects to withhold. The facts file SHALL NOT accept any value input: no token, call, price, time, or rate estimate. The CLI SHALL merge the facts with what it establishes itself, and SHALL treat its own values as authoritative for every field it can establish. + +Every published rule SHALL carry a `state`. Rules under `.taskless/rules/` and `legacy` rules SHALL be `written`; `cloud` candidates from the facts file SHALL be `candidate`. + +The facts file SHALL be validated against a published facts schema before anything else happens. The `report` recipe SHALL embed that schema. + +Every rule in the facts, in `rules`, `legacy`, or `cloud`, MAY carry `sources` and `evidence` in the shape ReportV1 gives them, and the CLI SHALL take their kinds from the vendored ReportV1 schema rather than from a list of its own. The CLI SHALL carry each rule's `sources` and `evidence` to the published rule unchanged, and SHALL add neither field to a rule whose facts omit it. Before any network call, the CLI SHALL refuse under `REPORT_INVALID`, naming the rule and the field, facts in which: `sources` is given on some rules but not all; a rule lists a kind twice; a rule lists `reviews` without `surfaced.reviewComments` above zero; a rule lists `commits`, `issues`, `docs`, or `tests` without an `evidence` count for that kind; or a rule carries an `evidence` count for a kind its `sources` does not list, or `evidence` without `sources`. A rule MAY list `agent-files` or `conventions` without a count, and MAY carry `surfaced` without listing `reviews`. + +#### Scenario: Facts cannot set what the CLI knows + +- **WHEN** the facts file gives a rule under `.taskless/rules/` an engine, a language, a test status, or a state +- **THEN** the command SHALL refuse the field as unknown under `REPORT_INVALID` +- **AND** a report that publishes SHALL carry the engine, language, test status, and state the CLI established + +#### Scenario: Malformed facts are refused before any other work + +- **WHEN** the facts file is not valid JSON or fails the facts schema +- **THEN** the command SHALL exit non-zero with `REPORT_INVALID` naming each failing field +- **AND** SHALL NOT perform any network call + +#### Scenario: Cloud candidates are carried as cloud tier + +- **WHEN** the facts file lists a runtime-shaped candidate +- **THEN** the published report SHALL include it with `tier: "cloud"`, `engine: "runtime"`, and `state: "candidate"` +- **AND** its tests status SHALL be `not-run` +- **AND** it SHALL carry the agent's `estimatedViolations` + +#### Scenario: A candidate without an estimate is refused + +- **WHEN** the facts file lists a `cloud` candidate with no `estimatedViolations` +- **THEN** the command SHALL exit non-zero with `REPORT_INVALID` + +#### Scenario: Every rule carries the agent's explanation + +- **WHEN** the facts give a local rule, a `legacy` rule, and a `cloud` candidate each an `explain` +- **THEN** the published report SHALL carry each one's `explain` on that rule + +#### Scenario: A rule without an explanation is refused + +- **WHEN** the facts give any rule, in `rules`, `legacy`, or `cloud`, no `explain`, or one that is blank or longer than 1000 characters +- **THEN** the command SHALL exit non-zero with `REPORT_INVALID` + +#### Scenario: Value inputs are not accepted + +- **WHEN** the facts file includes `estimates`, `contextTokens`, `callsPerCatch`, or `complexity` +- **THEN** the command SHALL refuse the field as unknown under `REPORT_INVALID` + +#### Scenario: Fix counts are not accepted + +- **WHEN** the facts file gives a rule `fixed`, `fixedBasis`, or `origin` +- **THEN** the command SHALL refuse the field as unknown under `REPORT_INVALID` + +#### Scenario: Sources and evidence are carried to the report + +- **WHEN** the facts give a local rule `sources: ["commits", "docs"]` and `evidence: { "commits": 4, "docs": 1 }` +- **THEN** the published rule SHALL carry exactly that `sources` and that `evidence` + +#### Scenario: Facts without sources publish as before + +- **WHEN** no rule in the facts carries `sources` or `evidence` +- **THEN** no published rule SHALL carry `sources` or `evidence` +- **AND** the payload SHALL otherwise be the one the same facts produced before this change + +#### Scenario: Sources must be given on every rule or on none + +- **WHEN** the facts give one rule `sources` and another rule none +- **THEN** the command SHALL exit non-zero with `REPORT_INVALID` +- **AND** SHALL NOT perform any network call + +#### Scenario: A counted kind needs its count + +- **WHEN** a rule lists `commits` in `sources` and carries no `evidence.commits` +- **THEN** the command SHALL exit non-zero with `REPORT_INVALID` naming that rule and `evidence.commits` + +#### Scenario: A count needs its kind + +- **WHEN** a rule carries `evidence.tests` and its `sources` does not list `tests` +- **THEN** the command SHALL exit non-zero with `REPORT_INVALID` naming that rule and `evidence.tests` + +#### Scenario: Reviews need a review comment + +- **WHEN** a rule lists `reviews` and its `surfaced.reviewComments` is 0 +- **THEN** the command SHALL exit non-zero with `REPORT_INVALID` naming that rule + +#### Scenario: Original kinds may be listed without a count + +- **WHEN** a rule lists `agent-files` and `conventions` and carries no `evidence` +- **THEN** the command SHALL NOT refuse it for that + +### Requirement: A published report is recorded and summarized + +On a 201 response the CLI SHALL write `.taskless/reports/.json` (UTC) holding the report URL, the delete credential exactly as the service returned it, and the expiry. When a record by that name already exists, the CLI SHALL instead write `_.json`, with the smallest `n` from 2 upward that is free, and SHALL NOT overwrite any existing record. When the record cannot be written at all, the report is live and the record was its only copy of the delete credential, so the CLI SHALL exit non-zero with `REPORT_RECORD_FAILED`, with a message stating that the report is live and giving its URL and its delete credential; with `--json` the error envelope SHALL also carry them as `url` and `deleteUrl`, with the expiry as `expiresAt`. Otherwise it SHALL then print a brief summary rendered from a CLI template: one line per rule giving its title and tier, followed by the rule's evidence counts by kind; when the report carries `findings`, a line stating how many problems the rules found in how many files in the code today; a line stating how many review comments across how many pull requests raised the rules' patterns over the window; the report URL; the expiry; and one sentence stating the report can be deleted after review. A rule's evidence counts SHALL name each kind separately: `"review comment"` / `"review comments"` from `surfaced.reviewComments`, `"fix-up commit"` / `"fix-up commits"` from `evidence.commits`, `"issue"` / `"issues"` from `evidence.issues`, `"agent file"` / `"agent files"` from `evidence["agent-files"]`, `"convention"` / `"conventions"` from `evidence.conventions`, `"doc"` / `"docs"` from `evidence.docs`, and `"test"` / `"tests"` from `evidence.tests`. Each kind SHALL be shown only when above zero, ordered largest count first, with `reviews`-group kinds (`reviews`, `commits`, `issues`) before `conventions`-group kinds (`agent-files`, `conventions`, `docs`, `tests`) on a tie and schema order preserved within each group; a rule with no non-zero evidence counts shows its title and tier alone. The summary SHALL NOT present a monthly rate. With `--json` it SHALL instead print a JSON object carrying the URL, the expiry, the record's path, and the rendered summary. When the record is written, the delete credential SHALL NOT appear on stdout in either form. + +#### Scenario: The record is written + +- **WHEN** a publish succeeds +- **THEN** exactly one new file SHALL exist under `.taskless/reports/` holding the URL, the delete credential, and the expiry + +#### Scenario: A taken record name moves to a suffix + +- **WHEN** a publish succeeds and `.taskless/reports/2026-10-13_142200.json` already exists for the same second +- **THEN** the record SHALL be written as `2026-10-13_142200_2.json` +- **AND** the existing record SHALL be unchanged +- **AND** `taskless report --delete=2026-10-13_142200_2.json` SHALL accept it + +#### Scenario: A record that cannot be written keeps the credential + +- **WHEN** a publish succeeds and `.taskless/reports/` cannot be written +- **THEN** the command SHALL exit non-zero with `REPORT_RECORD_FAILED` +- **AND** its output SHALL contain the report URL and the delete credential, with or without `--json` + +#### Scenario: The summary names the link and the way back + +- **WHEN** a publish succeeds without `--json` +- **THEN** stdout SHALL list each published rule's title and tier +- **AND** SHALL print the report URL +- **AND** SHALL state that the report can be deleted after review + +#### Scenario: The summary leads with what the rules found + +- **WHEN** a publish succeeds and the report carries `findings` of 342 violations in 118 files +- **THEN** the summary SHALL state that the rules found 342 problems in 118 files in the code today + +#### Scenario: The summary omits findings it does not have + +- **WHEN** a publish succeeds and the report carries no `findings` +- **THEN** the summary SHALL NOT state a count of problems found + +#### Scenario: The summary gives each rule its evidence totals + +- **WHEN** a publish succeeds and a rule carries `surfaced.reviewComments` of 2, `evidence.commits` of 4, and `evidence.docs` of 1 +- **THEN** that rule's line SHALL state "4 fix-up commits, 2 review comments, 1 doc" + +#### Scenario: Conventions lead when they are larger + +- **WHEN** a publish succeeds and a rule carries no `surfaced` and `evidence` of `{ "agent-files": 2, "tests": 3 }` +- **THEN** that rule's line SHALL state "3 tests, 2 agent files" and no review comment count + +#### Scenario: Commits-only evidence does not mention reviews + +- **WHEN** a publish succeeds and a rule carries no `surfaced` and `evidence` of `{ "commits": 3 }` +- **THEN** that rule's line SHALL state "3 fix-up commits" and SHALL NOT contain "reviews" + +#### Scenario: A rule without evidence shows no totals + +- **WHEN** a publish succeeds and a rule carries no `evidence` and no review comments +- **THEN** that rule's line SHALL give its title and tier and no totals + +#### Scenario: The delete credential stays on disk + +- **WHEN** a publish succeeds and its record is written, with or without `--json` +- **THEN** stdout SHALL NOT contain the delete credential + +### Requirement: A published report can be deleted from its record + +`taskless report --delete=` SHALL read the named record under `.taskless/reports/`, delete the report by sending an HTTP `DELETE` to the recorded `deleteUrl`, the URL tskl.es returned for that purpose, and on a 204 remove the record and print a one-line confirmation that says cached copies may be served for up to a day, as the tskl.es delete contract states. A 404 (`not_available`: never issued, already deleted, expired, or not yet propagated) SHALL exit non-zero with `REPORT_NOT_AVAILABLE`, SHALL NOT be retried, and SHALL keep the record. A record named outside `.taskless/reports/`, or not a `.json` file, SHALL exit non-zero with `INVALID_INPUT` without reading or removing it. A record that does not exist SHALL exit non-zero with `REPORT_NOT_FOUND`. A failed delete SHALL leave the record in place. + +#### Scenario: Deleting a report + +- **WHEN** a user runs `taskless report --delete=2026-10-13_142200.json` and the service confirms the deletion +- **THEN** the record SHALL be removed +- **AND** the command SHALL print a confirmation and exit 0 + +#### Scenario: A report tskl.es no longer has + +- **WHEN** the service answers the delete with 404 +- **THEN** the command SHALL exit non-zero with `REPORT_NOT_AVAILABLE` +- **AND** SHALL send no second request +- **AND** the record SHALL remain on disk + +#### Scenario: A record outside the records directory is refused + +- **WHEN** a user runs `taskless report --delete=../notes.json` +- **THEN** the command SHALL exit non-zero with `INVALID_INPUT` +- **AND** SHALL send no request and remove no file + +#### Scenario: A failed delete keeps the credential + +- **WHEN** the service refuses or cannot be reached +- **THEN** the record SHALL remain on disk +- **AND** the command SHALL exit non-zero diff --git a/openspec/changes/value-flags-equals-only/specs/cli-rule-reconciliation/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-rule-reconciliation/spec.md new file mode 100644 index 000000000..286a260e8 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-rule-reconciliation/spec.md @@ -0,0 +1,40 @@ +## MODIFIED Requirements + +### Requirement: Reconcile reports every rule directory + +When `check` reconciles, the CLI SHALL send `POST /cli/api/v2/reconcile` with +`{ repositoryUrl, orgId?, rules }`, where `rules` holds exactly one +`{ ruleId, files: [{ path, signature }] }` for **every** rule directory under +`.taskless/rules//`, of every engine, whatever `--rule` selects to run. `ruleId` +SHALL be the directory name. `files` SHALL list every regular file under the directory, +recursively, except files under `tests/` or the legacy `.tests/` and the operating-system metadata files +`.DS_Store`, `Thumbs.db`, and `desktop.ini`. `path` SHALL be relative to the rule directory +with `/` separators on every platform, and `signature` SHALL be the full algoVersion-1 +envelope of the snapshot's bytes for that file. + +#### Scenario: Every engine is reported + +- **WHEN** `.taskless/rules/sg/`, `.taskless/rules/vale/`, and `.taskless/rules/runtime/` each hold rules +- **THEN** the request SHALL carry one entry per rule directory across all three engines + +#### Scenario: A rule's files are reported relative to its directory + +- **WHEN** runtime rule `no-env-leak-3fa9c21b` holds `check.ts` and `captures/env.yml` +- **THEN** its entry SHALL be `{ ruleId: "no-env-leak-3fa9c21b", files: [{ path: "check.ts", … }, { path: "captures/env.yml", … }] }` + +#### Scenario: Fixtures are not reported + +- **WHEN** a rule directory holds files under `tests/` +- **THEN** no reported path SHALL begin with `tests/` + +#### Scenario: Unconverted legacy fixtures are not reported + +- **WHEN** a rule directory still holds files under `.tests/` that migration 12 could not convert +- **THEN** no reported path SHALL begin with `.tests/` +- **AND** the rule SHALL NOT read as edited because of them + +#### Scenario: --rule does not narrow the report + +- **WHEN** a user runs `check --rule=a` in a project holding rules `a` and `b` +- **THEN** the reconcile request SHALL report both `a` and `b` +- **AND** only `a` SHALL run diff --git a/openspec/changes/value-flags-equals-only/specs/cli-rules/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-rules/spec.md new file mode 100644 index 000000000..5903c9c17 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-rules/spec.md @@ -0,0 +1,208 @@ +## MODIFIED Requirements + +### Requirement: Rules subcommand group exists + +The CLI SHALL expose the rule operations under the `rule` (singular) subcommand group. The user-facing surface SHALL be `taskless rule create`, `taskless rule improve`, `taskless rule delete`, and `taskless rule meta`. Rule validation is not part of this group — it is addressed by path through the top-level `validate` and `verify` commands, specified by the `cli-rule-validation` capability. The internal source filename (`packages/cli/src/commands/rules.ts`) MAY remain plural — only the user-visible subcommand name changes. + +The previous plural form `taskless rules ` SHALL NOT work in v0.7.0 — there is no compatibility alias. + +#### Scenario: Singular subcommand registers correctly + +- **WHEN** a user runs `taskless rule create --from=req.json` +- **THEN** the CLI SHALL invoke the rule-create handler + +#### Scenario: Plural subcommand is no longer recognized + +- **WHEN** a user runs `taskless rules create --from=req.json` +- **THEN** the CLI SHALL exit with an error indicating the subcommand is unknown +- **AND** the error message SHOULD suggest `taskless rule create` + +### Requirement: Rules create reads request from stdin + +The `taskless rule create` command SHALL accept a `--from=` flag specifying a JSON file containing the rule request. (Note: previously named `rules create`; renamed to singular.) + +#### Scenario: rule create with --from file + +- **WHEN** a user runs `taskless rule create --from=.taskless/.tmp-rule-request.json --json` +- **THEN** the CLI SHALL read the JSON file and submit it to the API + +### Requirement: Rules create requires authentication + +`taskless rule create` SHALL require authentication unless the new `--anonymous` flag is set. When `--anonymous` is set, the command SHALL invoke the local-only flow (see "Rule create supports anonymous local-only flow" below) instead of submitting to the API. (Renamed to singular; new anonymous branch.) + +#### Scenario: rule create without --anonymous requires auth + +- **WHEN** a user runs `taskless rule create --from=req.json` without being logged in +- **THEN** the CLI SHALL exit with code 1 and an `AUTH_REQUIRED` error + +#### Scenario: rule create --anonymous skips auth + +- **WHEN** a user runs `taskless rule create --from=req.json --anonymous` without being logged in +- **THEN** the CLI SHALL invoke the local-only flow without checking auth + +### Requirement: Rule generation tolerates transient service failures + +While `taskless rule create` or `taskless rule improve` polls a submitted request, and while it +fetches the rules that request produced, an `unavailable` outcome marked `retryable` (a network +failure, `408`, `429`, or a `5xx`) SHALL NOT end the command. The CLI SHALL report the failure as +progress and try again after the poll interval, and SHALL give up only after 8 such outcomes in a +row. Any other answer SHALL reset that count. A non-retryable `unavailable` (an undocumented `4xx` +or a malformed body), a documented `error`, a refusal, or a `401` SHALL still fail on the first +occurrence. When the CLI gives up, the message SHALL name the request id, SHALL say the request +was not cancelled and may still complete, and SHALL name the `--resume` command that picks it up +again. All rules SHALL still be fetched before any is written, so a fetch that gives up writes +nothing. + +#### Scenario: A transient run is ridden out + +- **WHEN** polling answers `503`, `429`, and a network failure before reaching `generated` +- **THEN** the CLI SHALL keep polling and deliver the rules +- **AND** SHALL have submitted exactly one request + +#### Scenario: Persistent failure gives up without implying a resubmit + +- **WHEN** polling answers a retryable failure 8 times in a row +- **THEN** the CLI SHALL fail with `NETWORK_ERROR` +- **AND** the message SHALL name the request id, say it may still complete, and name + `taskless rule --resume=` + +#### Scenario: An answer in between resets the count + +- **WHEN** polling answers 7 retryable failures, then `building`, then 7 more, then `generated` +- **THEN** the CLI SHALL deliver the rules + +#### Scenario: A non-retryable failure fails at once + +- **WHEN** polling answers an undocumented `4xx`, or `401` +- **THEN** the CLI SHALL fail on that answer without polling again + +#### Scenario: Fetching a generated rule is retried the same way + +- **WHEN** `GET /cli/api/v2/rule/{ruleId}` answers a retryable failure 8 times in a row +- **THEN** the CLI SHALL fail with `NETWORK_ERROR`, write no rules, and name the `--resume` command + +### Requirement: Rules create and improve resume a submitted request + +`taskless rule create` and `taskless rule improve` SHALL accept `--resume=`, the request +id a previous run of the same command printed. With it, the CLI SHALL NOT submit anything: it SHALL +poll that request and fetch, verify, and write what it produced exactly as it would have after +submitting it, and SHALL report the same output, with `requestId` set to the resumed id. +`--resume` SHALL NOT be combined with `--from`, and its value SHALL be a UUID; either mistake SHALL +fail with `INVALID_INPUT` before any service call. +A `requestId` the service returns from submit or iterate SHALL also be a UUID, since the CLI prints +it inside a `--resume` command an agent is told to run; any other value SHALL be treated as an +invalid response body and SHALL NOT be printed. + +#### Scenario: A resumed request is not resubmitted + +- **WHEN** a user runs `taskless rule create --resume=` after a run that gave up on it +- **THEN** the CLI SHALL poll `GET /cli/api/v2/request/{requestId}` and write the produced rules +- **AND** SHALL NOT call `POST /cli/api/v2/request` + +#### Scenario: Improve resumes without iterating again + +- **WHEN** a user runs `taskless rule improve --resume=` +- **THEN** the CLI SHALL NOT call `POST /cli/api/v2/rule/{ruleId}/iterate` + +#### Scenario: --resume with --from is refused + +- **WHEN** a user runs `taskless rule create --resume= --from=req.json` +- **THEN** the CLI SHALL fail with `INVALID_INPUT` without calling the service + +#### Scenario: A server-authored request id is never put on a command line + +- **WHEN** submit answers `200` with a `requestId` that is not a UUID, such as `x; rm -rf ~` +- **THEN** the CLI SHALL fail with `NETWORK_ERROR` as an invalid response body +- **AND** SHALL NOT print that value or poll it + +#### Scenario: A rule id is not a request id + +- **WHEN** a user runs `taskless rule improve --resume=no-eval-3fa9c21b` +- **THEN** the CLI SHALL fail with `INVALID_INPUT` without calling the service + +### Requirement: Rules improve reads request from file + +`taskless rule improve` SHALL accept a `--from=` flag specifying a JSON file containing the +iterate request `{ ruleId, guidance, references? }`, where `ruleId` is the rule's directory name +under `.taskless/rules//`, the id v2 addresses a rule by. (Renamed to singular.) + +#### Scenario: The request is read from the named file + +- **WHEN** a user runs `taskless rule improve --from=request.json` +- **THEN** the CLI SHALL read the iterate request from that file + +#### Scenario: The rule id is the directory name + +- **WHEN** the request names `ruleId: "no-eval-3fa9c21b"` +- **THEN** the CLI SHALL iterate the rule at `.taskless/rules//no-eval-3fa9c21b/` + +### Requirement: Rule create supports anonymous local-only flow + +When `taskless rule create --anonymous` is invoked, the CLI SHALL execute the local-only rule-creation flow (previously implemented as the `taskless-create-rule-anonymous` skill body). The flow SHALL: + +1. NOT submit any request to the Taskless API +2. Generate the ast-grep rule using local logic (Claude SDK, agent-driven generation, or whatever the migrated implementation prefers — see design.md) +3. Write the rule file to `.taskless/rules/sg//.yml` +4. Write any generated test files into that rule's own directory, under `.taskless/rules/sg//tests/` +5. NOT write a metadata sidecar (neither does the API-backed branch: the + service never populates the `meta` block a sidecar would be written from, + so no branch of `rule create` has ever written one) +6. Return the same output format as the API-backed branch (paths to created files) + +#### Scenario: rule create --anonymous skips API + +- **WHEN** a user runs `taskless rule create --from=req.json --anonymous` +- **THEN** the CLI SHALL NOT make any HTTP request to the Taskless API +- **AND** SHALL produce a rule file under `.taskless/rules/` + +#### Scenario: rule create --anonymous produces no metadata sidecar + +- **WHEN** `taskless rule create --anonymous` succeeds +- **THEN** no file under `.taskless/rule-metadata/` SHALL be written for the new rule + +### Requirement: Rule improve supports anonymous local-only flow + +When `taskless rule improve --anonymous` is invoked, the CLI SHALL execute the local-only rule-improvement flow (previously implemented as the `taskless-improve-rule-anonymous` skill body). The flow SHALL: + +1. NOT submit any request to the Taskless API iterate endpoint +2. Update the rule file in place using local logic +3. Support the validate feedback loop by exposing the top-level `validate` primitive that the agent invokes between edits +4. Return the same output format as the API-backed branch + +#### Scenario: rule improve --anonymous skips API + +- **WHEN** a user runs `taskless rule improve --from=iterate.json --anonymous` +- **THEN** the CLI SHALL NOT make any HTTP request to the Taskless API +- **AND** SHALL update the target rule file + +**API contract.** The requirements below describe the service endpoints the +`rule` subcommands call. They are grouped by a bold line rather than a +heading: a second `##` inside this section ends it, and everything after it +stops being read as a requirement. + +### Requirement: Rule-writing commands refuse a scaffold that is not current + +`taskless rule create`, `taskless rule improve`, `taskless rule restore` and `taskless rule rollback` SHALL NOT migrate `.taskless/`. Before resolving identity or calling the service, each SHALL refuse a scaffold whose schema version is below the latest migration with `SCAFFOLD_MIGRATION_REQUIRED`, naming `taskless init`, and one whose version is above it with `SCAFFOLD_VERSION_MISMATCH`, unless `--allow-version-mismatches` (or `TASKLESS_ALLOW_VERSION_MISMATCHES`) is set. The refusal SHALL exit non-zero and be reported as the command reports any other error: on stderr, or as the `{ ok: false, code, message }` envelope under `--json`. A `.taskless/` that is absent SHALL still be created when the first rule is written, as before. `rule create --resume` and `rule improve --resume` SHALL refuse the same way. + +#### Scenario: Rule create refuses a scaffold that is behind the CLI + +- **WHEN** `.taskless/taskless.json` records a schema version below the latest migration and a user runs `taskless rule create --from= --json` +- **THEN** stdout SHALL be the envelope `{ ok: false, code: "SCAFFOLD_MIGRATION_REQUIRED", message }`, and the message SHALL name `taskless init` +- **AND** the command SHALL NOT call the service +- **AND** SHALL leave every file under `.taskless/` as it was + +#### Scenario: Rule improve, restore and rollback refuse the same way + +- **WHEN** `.taskless/` is behind the CLI and a user runs `taskless rule improve`, `taskless rule restore `, or `taskless rule rollback ` +- **THEN** the command SHALL exit non-zero with `SCAFFOLD_MIGRATION_REQUIRED` +- **AND** SHALL leave every file under `.taskless/` as it was + +#### Scenario: Rule-writing commands refuse a scaffold newer than the CLI + +- **WHEN** `.taskless/taskless.json` records a schema version above the latest migration and none of the version-mismatch overrides is set +- **THEN** each of these commands SHALL exit non-zero with `SCAFFOLD_VERSION_MISMATCH`, saying to upgrade the CLI + +#### Scenario: An absent scaffold is still created by the write + +- **WHEN** a project has no `.taskless/` directory and `taskless rule create` delivers a rule +- **THEN** the command SHALL create `.taskless/` at the latest schema version and write the rule into it diff --git a/openspec/changes/value-flags-equals-only/specs/cli-runtime-rule-execution/spec.md b/openspec/changes/value-flags-equals-only/specs/cli-runtime-rule-execution/spec.md new file mode 100644 index 000000000..0a1b4c368 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli-runtime-rule-execution/spec.md @@ -0,0 +1,20 @@ +## MODIFIED Requirements + +### Requirement: check.ts execution is bounded by a timeout + +The CLI SHALL bound each `check.ts` invocation with a wall-clock timeout and SHALL accept a +`--timeout=` flag on `check` to override the default. When a `check.ts` exceeds the +timeout the CLI SHALL terminate it, record a single error-severity finding for that rule, and +continue executing the remaining rules — a runaway check SHALL NOT wedge the overall `check` +run. + +#### Scenario: A hanging check is terminated at the timeout + +- **WHEN** a runtime rule's `check.ts` runs longer than the effective timeout +- **THEN** the CLI SHALL terminate it and record a single error-severity finding for that rule +- **AND** SHALL continue executing the remaining rules + +#### Scenario: --timeout overrides the default + +- **WHEN** a user runs `taskless check --timeout=` +- **THEN** the CLI SHALL use that value as the per-check wall-clock bound diff --git a/openspec/changes/value-flags-equals-only/specs/cli/spec.md b/openspec/changes/value-flags-equals-only/specs/cli/spec.md new file mode 100644 index 000000000..d8c4fc775 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/specs/cli/spec.md @@ -0,0 +1,214 @@ +## MODIFIED Requirements + +### Requirement: CLI stub entry point + +The CLI entry point SHALL use citty to define a main command with subcommand support and a global `--dir` argument, given as `--dir=`, that sets the working directory, a global `--json` boolean argument for machine-readable output, and a global `--schema` boolean argument for printing JSON Schema definitions. When invoked with no arguments, the CLI SHALL display help text listing available subcommands. The CLI SHALL externalize Node.js built-in modules and bundle all other dependencies. The `check` subcommand, the `auth` subcommand group, the `rules` subcommand group, and the `agent` subcommand SHALL be registered alongside existing subcommands. The `update-engine` subcommand SHALL NOT be registered. + +#### Scenario: Running the CLI with no arguments shows help + +- **WHEN** the CLI is executed with no arguments +- **THEN** it SHALL print help text to stdout listing available subcommands including `agent` +- **AND** the help text SHALL NOT list `update-engine` + +#### Scenario: Running the CLI with an unknown subcommand shows help + +- **WHEN** the CLI is executed with an unrecognized subcommand +- **THEN** it SHALL print help text to stdout + +#### Scenario: Update-engine subcommand is not registered + +- **WHEN** a user runs `taskless update-engine` +- **THEN** the CLI SHALL print help text (unrecognized subcommand) + +#### Scenario: Init subcommand remains unchanged + +- **WHEN** a user runs `taskless init` +- **THEN** the CLI SHALL route to the init subcommand handler +- **AND** the init handler SHALL NOT perform scaffold updates + +#### Scenario: Update alias is removed + +- **WHEN** a user runs `taskless update` +- **THEN** the CLI SHALL NOT route to the init handler +- **AND** SHALL show help text (unrecognized subcommand) + +#### Scenario: Global -d flag is accepted + +- **WHEN** the CLI is executed with `--dir=/some/path` +- **THEN** the specified path SHALL be available to all subcommands as the resolved working directory + +#### Scenario: Working directory defaults to process.cwd() + +- **WHEN** the CLI is executed without the `--dir` flag +- **THEN** the working directory SHALL default to `process.cwd()` + +#### Scenario: Global --json flag is accepted + +- **WHEN** the CLI is executed with `--json` +- **THEN** the flag SHALL be available to all subcommands as `args.json` + +#### Scenario: --json defaults to false + +- **WHEN** a user runs a subcommand without `--json` +- **THEN** `args.json` SHALL be `false` + +#### Scenario: Global --schema flag is accepted + +- **WHEN** the CLI is executed with `--schema` +- **THEN** the flag SHALL be available to all subcommands as `args.schema` + +#### Scenario: --schema defaults to false + +- **WHEN** a user runs a subcommand without `--schema` +- **THEN** `args.schema` SHALL be `false` + +#### Scenario: --schema is ignored by commands without --json support + +- **WHEN** a user runs `taskless auth login --schema` +- **THEN** the CLI SHALL ignore the `--schema` flag and proceed normally + +#### Scenario: Check subcommand is registered + +- **WHEN** a user runs `taskless check` +- **THEN** the CLI SHALL route to the check subcommand handler + +#### Scenario: Auth subcommand group is registered + +- **WHEN** a user runs `taskless auth` +- **THEN** the CLI SHALL route to the auth subcommand group + +#### Scenario: Rule subcommand group is registered + +- **WHEN** a user runs `taskless rule` +- **THEN** the CLI SHALL route to the rule subcommand group + +#### Scenario: Agent subcommand is registered + +- **WHEN** a user runs `taskless agent` +- **THEN** the CLI SHALL route to the `agent` subcommand handler + +### Requirement: Error output uses stable codes when --json is set + +When any CLI command exits with an error AND `--json` was passed, the command SHALL output a JSON envelope with the shape: + +```json +{ + "ok": false, + "code": "", + "message": "" +} +``` + +The `code` field SHALL be drawn from a stable enum defined in `packages/cli/src/types/errors.ts`. The enum SHALL include at minimum: `AUTH_REQUIRED`, `NO_GITHUB_REMOTE`, `RULE_GENERATION_FAILED`, `RULE_NOT_FOUND`, `INVALID_INPUT`, `NETWORK_ERROR`. New codes MAY be added but existing codes SHALL NOT be renamed without a major version bump. Recipes reference these codes by name in their `## Errors` section, so stability is required. + +#### Scenario: Auth-required error in JSON mode + +- **WHEN** a user runs `taskless rule create --from=req.json --json` while logged out +- **THEN** stdout SHALL contain `{ "ok": false, "code": "AUTH_REQUIRED", "message": "..." }` +- **AND** the exit code SHALL be non-zero + +#### Scenario: Error code stability is enforced by tests + +- **WHEN** the test suite runs +- **THEN** there SHALL be tests verifying the exact `code` strings emitted for each error path +- **AND** renaming a code in the enum without updating both the implementation and the tests SHALL break the build + +### Requirement: CLI accepts global --local flag with --anonymous as its alias + +The CLI SHALL accept a top-level boolean flag `--local` on every subcommand. The flag's behavior SHALL vary by command: + +- `rule create`, `rule improve`: switch to local-only flow (no API calls); SHALL be the only way to reach the local-only path +- `rule delete`, `rule verify`, `rule meta`, `check`, `auth logout`, `init`, `update`: accepted as no-op; SHALL succeed without changing behavior +- `info`: skip the API/auth probe; report local state only (CLI version, skills installed, no auth call) +- `auth login`: SHALL exit with code 1 and an error message stating "auth commands cannot run in local mode" + +The CLI SHALL also accept `--anonymous`, the flag's original name, as an alias of `--local` on every subcommand that accepts `--local`. Passing either spelling, or both, SHALL select exactly the same behavior. Wherever a requirement in any capability names `--anonymous`, it SHALL apply identically when `--local` is passed. + +Text the CLI prints that names the flag (notices, errors, pointers to a recipe, the `agent` topic index) SHALL name `--local`, whichever spelling was passed. `--help` SHALL list both flags, and SHALL NOT render the alias with a single dash. + +The `info --json` `authState` value for a skipped probe SHALL remain `"anonymous"`, since it is a machine contract and not a flag name. + +The flag SHALL be recognized whether placed before or after positional arguments (per `citty` parsing). + +#### Scenario: --local on rule create switches to local flow + +- **WHEN** a user runs `taskless rule create --from=req.json --local` +- **THEN** the CLI SHALL execute the local-only branch (no API calls) +- **AND** SHALL produce the same output shape as the API-backed branch + +#### Scenario: --local on check is a no-op + +- **WHEN** a user runs `taskless check --local` +- **THEN** the CLI SHALL execute identically to `taskless check` (no warning, no error) + +#### Scenario: --local on info skips API probe + +- **WHEN** a user runs `taskless info --local` +- **THEN** the CLI SHALL report local state only (CLI version, installed skills, scaffold version) +- **AND** SHALL NOT make any HTTP request to verify auth state + +#### Scenario: --local on auth login is rejected + +- **WHEN** a user runs `taskless auth login --local` +- **THEN** the CLI SHALL exit with code 1 +- **AND** SHALL print an error message stating "auth commands cannot run in local mode" + +#### Scenario: --anonymous still selects local mode + +- **WHEN** a user runs any subcommand with `--anonymous` in place of `--local` +- **THEN** the CLI SHALL behave exactly as it does with `--local` + +#### Scenario: Printed text names --local + +- **WHEN** a user runs `taskless rule improve --anonymous` +- **THEN** the pointer the CLI prints SHALL name `agent improve-rule --local` + +## ADDED Requirements + +### Requirement: Value flags take their value only after = + +Every flag that takes a value SHALL take it only within its own token, as `--flag=value`. A token that is exactly the name of a value-taking flag of the command being run, or of one of its parent commands, appearing before the `--` end-of-options marker, SHALL be refused with `INVALID_INPUT` before the command runs, with a message naming the `--flag=` spelling. This SHALL hold whether or not a token follows the flag. The set of value-taking flags SHALL be read from the command definitions, so a flag declared later is covered without a separate list. + +No flag SHALL consume the token after it. A token beginning with `-` SHALL be a flag and any other token SHALL be a positional argument, and every token after `--` SHALL be a positional argument. + +The short flag `-d` SHALL NOT exist. A `-d` token before `--` SHALL be refused with `INVALID_INPUT` naming `--dir=`. No other short flag SHALL take a value. + +`--help` and `--version` SHALL be answered before this check, so `taskless check --rule --help` prints usage. + +#### Scenario: The space spelling is refused with the fix + +- **WHEN** a user runs `taskless check --rule no-eval` +- **THEN** the CLI SHALL exit 1 with `INVALID_INPUT` +- **AND** the message SHALL name `--rule=` +- **AND** nothing SHALL be scanned + +#### Scenario: The = spelling runs + +- **WHEN** a user runs `taskless check --rule=no-eval` +- **THEN** the check SHALL run only the rule `no-eval` + +#### Scenario: A parent's value flag is covered + +- **WHEN** a user runs `taskless --dir /tmp/project check` +- **THEN** the CLI SHALL exit 1 with `INVALID_INPUT` naming `--dir=` +- **AND** SHALL NOT try to run a command named `/tmp/project` + +#### Scenario: -d is refused + +- **WHEN** a user runs `taskless check -d .` +- **THEN** the CLI SHALL exit 1 with `INVALID_INPUT` naming `--dir=` + +#### Scenario: A value beginning with - is carried in its token + +- **WHEN** a user runs `taskless check --rule=-odd-id` +- **THEN** `-odd-id` SHALL be read as the value of `--rule` + +#### Scenario: Under --json the refusal is an envelope + +- **WHEN** a user runs `taskless check --json --rule no-eval` +- **THEN** stdout SHALL hold one error envelope with code `INVALID_INPUT` + +#### Scenario: Help still answers + +- **WHEN** a user runs `taskless check --rule --help` +- **THEN** the CLI SHALL print the usage for `check` and exit 0 diff --git a/openspec/changes/value-flags-equals-only/tasks.md b/openspec/changes/value-flags-equals-only/tasks.md new file mode 100644 index 000000000..31f33e448 --- /dev/null +++ b/openspec/changes/value-flags-equals-only/tasks.md @@ -0,0 +1,14 @@ +## 1. Parsing and enforcement + +- [x] 1.1 Simplify `splitRawArguments` so no flag consumes the next token and every `--flag=value` token records a value; delete `joinDirectoryValues` and `DIR_FLAGS`; make `resolveCwd` read only `--dir=`; verify with the argv unit tests rewritten for the new rule +- [x] 1.2 Add the pre-dispatch gate in `src/index.ts`: resolve the command chain from the positionals, collect `type: "string"` args from each command in it, and refuse a bare `--` or `-d` before `--` with `INVALID_INPUT` (envelope under `--json`), after the help/version intercept; verify with tests for each scenario of "Value flags take their value only after =" +- [x] 1.3 Remove `alias: "d"` from every command and drop `check`'s `VALUE_FLAGS`/`OPTIONAL_VALUE_FLAGS`; verify `pnpm typecheck` and that `check --rule=a --rule=b` still runs both rules + +## 2. Callers in this repository + +- [ ] 2.1 Rewrite every value flag in CLI messages, recipes, `skills/taskless/SKILL.md`, both READMEs and `.github/workflows/reference-corpus.yml` to the `=` spelling; verify a grep for a space-form value flag over `packages/cli/src`, `skills/` and the READMEs returns nothing, and the recipe tests pass +- [x] 2.2 Rewrite every test invocation to the `=` spelling, including the fixture helper that reads `-d`; verify the full suite passes + +## 3. Release + +- [ ] 3.1 Grow the stack's changeset to `minor`, stating what callers must change; run `pnpm typecheck`, `pnpm lint` and the full suite, all passing diff --git a/packages/cli/src/commands/agent.ts b/packages/cli/src/commands/agent.ts index 90a856250..d056523fc 100644 --- a/packages/cli/src/commands/agent.ts +++ b/packages/cli/src/commands/agent.ts @@ -140,7 +140,6 @@ export function createAgentCommand(subCommands: SubCommandsDef) { args: { dir: { type: "string", - alias: "d", description: "Working directory", default: process.cwd(), }, diff --git a/packages/cli/src/commands/ast.ts b/packages/cli/src/commands/ast.ts index 10c98e160..672ae138f 100644 --- a/packages/cli/src/commands/ast.ts +++ b/packages/cli/src/commands/ast.ts @@ -126,7 +126,6 @@ export const astCommand = defineCommand({ }, dir: { type: "string", - alias: "d", description: "Working directory", }, json: { diff --git a/packages/cli/src/commands/auth.ts b/packages/cli/src/commands/auth.ts index 7863177ec..cdb826838 100644 --- a/packages/cli/src/commands/auth.ts +++ b/packages/cli/src/commands/auth.ts @@ -93,7 +93,6 @@ const loginCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, ...localModeFlags("Rejected: auth commands cannot run in local mode"), @@ -223,7 +222,6 @@ const logoutCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, ...localModeFlags("Accepted for compatibility; logout is already local"), @@ -281,7 +279,6 @@ export const authCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, json: { diff --git a/packages/cli/src/commands/check.ts b/packages/cli/src/commands/check.ts index 595cadf05..297b2bad5 100644 --- a/packages/cli/src/commands/check.ts +++ b/packages/cli/src/commands/check.ts @@ -157,23 +157,15 @@ function missingPathsNotice(missing: string[]): string { } /** - * Extract positional path arguments from rawArgs. The shared scanner knows the - * global value-taking flags and the POSIX `--` end-of-options marker (which is - * what lets a path beginning with `-` be scanned); `--timeout` is check's own - * value-taking flag, so it is named here rather than in the shared set. + * Extract positional path arguments from rawArgs. Every flag value is inside + * its token (`--rule=`), so a token not starting with `-` is a path, and + * the POSIX `--` end-of-options marker lets a path beginning with `-` be + * scanned. */ function extractPositionalPaths(rawArguments: string[]): string[] { - return splitRawArguments(rawArguments, VALUE_FLAGS, OPTIONAL_VALUE_FLAGS) - .positionals; + return splitRawArguments(rawArguments).positionals; } -/** - * `check`'s flags whose value is optional, and so is read only from the - * `--flag=value` spelling: `--diff` reads stdin, `--diff=` reads a file, - * and the token after a bare `--diff` stays a positional path. - */ -const OPTIONAL_VALUE_FLAGS = ["--diff"] as const; - /** Where `check --diff` reads its diff from. */ type DiffSource = | { kind: "stdin" } @@ -183,14 +175,10 @@ type DiffSource = /** * The diff `check` was asked to read, or `undefined` when `--diff` was not * given. Read through the same scanner as the positionals, so `--diff` after - * `--` is a path and a `--timeout --diff` value is a timeout. + * `--` is a path. */ function extractDiffSource(rawArguments: string[]): DiffSource | undefined { - const { flags, values } = splitRawArguments( - rawArguments, - VALUE_FLAGS, - OPTIONAL_VALUE_FLAGS - ); + const { flags, values } = splitRawArguments(rawArguments); const occurrences = flags.filter( (flag) => flag === "--diff" || flag.startsWith("--diff=") ); @@ -237,42 +225,26 @@ function excludedPathsNotice(excluded: string[]): string { return `Not checked: ${excluded.length} changed ${noun} under .taskless/ or .git/, which \`check --diff\` never checks: ${excluded.join(", ")}`; } -/** - * `check`'s own value-taking flags, for the shared argv scanner. - * - * `--rule` has to be here or its value is scanned as a positional path: - * `check --rule no-eval` would look for a file called `no-eval`, find none, and - * take the "every supplied path was filtered out" branch — a clean exit 0 with - * no findings, which is the same output a rule that fires nowhere produces. - */ -const VALUE_FLAGS = ["--timeout", "--rule"] as const; - /** * Every `--rule` value in argv, in the order given. * * Read from raw argv rather than from citty's parsed `args` because the flag is * REPEATABLE, and a parser that collapses a repeat to a single value turns - * `--rule a --rule b` into a measurement of one rule while the author reads the - * number as covering two. Both spellings are accepted (`--rule a` and - * `--rule=a`), and scanning stops at `--` so a path literally named `--rule` - * after the end-of-options marker is a path. + * `--rule=a --rule=b` into a measurement of one rule while the author reads the + * number as covering two. Scanning stops at `--`, so a path literally named + * `--rule=x` after the end-of-options marker is a path. * * Read through `splitRawArguments`, the same scanner {@link extractPositionalPaths} - * uses, rather than a second scan of its own. A private scan would not know - * which OTHER flags consume a token. For the malformed `check --timeout --rule - * no-eval`, the shared scanner hands `--rule` to `--timeout` as its value and - * `no-eval` to `positionals`; a `--rule`-only scan would instead read `--rule` - * as a flag and claim `no-eval` as a rule id, so the same tokens would be both - * a path and a rule id in one run. One pass cannot disagree with itself. + * uses, so one pass decides both which tokens are paths and which are rule ids. */ export function extractRuleFilters(rawArguments: string[]): string[] { - return splitRawArguments(rawArguments, VALUE_FLAGS) + return splitRawArguments(rawArguments) .values.filter((entry) => entry.flag === "--rule") .map((entry) => entry.value) .filter((id) => id !== ""); } -/** Parse `--timeout ` into milliseconds; invalid/absent → undefined (default). */ +/** Parse `--timeout=` into milliseconds; invalid/absent → undefined (default). */ function parseTimeoutMs(raw: string | undefined): number | undefined { if (raw === undefined) return undefined; const seconds = Number(raw); @@ -310,7 +282,6 @@ export const checkCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, json: { @@ -333,7 +304,7 @@ export const checkCommand = defineCommand({ }, rule: { type: "string", - description: "Run only the named rule; repeatable (--rule a --rule b)", + description: "Run only the named rule; repeatable (--rule=a --rule=b)", }, diff: { type: "boolean", diff --git a/packages/cli/src/commands/detect.ts b/packages/cli/src/commands/detect.ts index 058b06056..c970a9f3b 100644 --- a/packages/cli/src/commands/detect.ts +++ b/packages/cli/src/commands/detect.ts @@ -17,7 +17,6 @@ export const detectCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, json: { diff --git a/packages/cli/src/commands/feedback.ts b/packages/cli/src/commands/feedback.ts index dc8a330e2..8c4743214 100644 --- a/packages/cli/src/commands/feedback.ts +++ b/packages/cli/src/commands/feedback.ts @@ -101,7 +101,6 @@ const dismissCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, }, @@ -127,7 +126,6 @@ const sendCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, from: { diff --git a/packages/cli/src/commands/info.ts b/packages/cli/src/commands/info.ts index 5551a36a7..6a7b67f9c 100644 --- a/packages/cli/src/commands/info.ts +++ b/packages/cli/src/commands/info.ts @@ -60,7 +60,6 @@ export const infoCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, json: { diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index 246493168..2175471a5 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -85,7 +85,6 @@ export const initCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, json: { @@ -293,7 +292,6 @@ export const updateCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, rules: { diff --git a/packages/cli/src/commands/onboard.ts b/packages/cli/src/commands/onboard.ts index 221078c3a..206d182dc 100644 --- a/packages/cli/src/commands/onboard.ts +++ b/packages/cli/src/commands/onboard.ts @@ -58,7 +58,6 @@ export const onboardCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, force: { diff --git a/packages/cli/src/commands/report.ts b/packages/cli/src/commands/report.ts index 8d4ee04bf..b303bc1ab 100644 --- a/packages/cli/src/commands/report.ts +++ b/packages/cli/src/commands/report.ts @@ -38,7 +38,6 @@ export const reportCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, from: { diff --git a/packages/cli/src/commands/rules.ts b/packages/cli/src/commands/rules.ts index 159f8bfdc..f92384854 100644 --- a/packages/cli/src/commands/rules.ts +++ b/packages/cli/src/commands/rules.ts @@ -328,7 +328,6 @@ const createCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, json: { @@ -473,7 +472,6 @@ const improveCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, json: { @@ -619,7 +617,6 @@ const metaCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, json: { @@ -699,7 +696,6 @@ const deleteCommand = defineCommand({ args: { dir: { type: "string", - alias: "d", description: "Working directory", }, ...localModeFlags("Accepted for compatibility; delete is purely local"), @@ -883,7 +879,7 @@ const restoreCommand = defineCommand({ "Put back the version of a rule Taskless issued, after it was edited or deleted", }, args: { - dir: { type: "string", alias: "d", description: "Working directory" }, + dir: { type: "string", description: "Working directory" }, json: { type: "boolean", description: "Output as JSON", default: false }, id: { type: "positional", @@ -908,7 +904,7 @@ const rollbackCommand = defineCommand({ "Make an earlier revision of a rule current, and write it to disk", }, args: { - dir: { type: "string", alias: "d", description: "Working directory" }, + dir: { type: "string", description: "Working directory" }, json: { type: "boolean", description: "Output as JSON", default: false }, id: { type: "positional", @@ -936,7 +932,7 @@ const revisionsCommand = defineCommand({ "List a rule's recent revisions, to choose one for `rule rollback`", }, args: { - dir: { type: "string", alias: "d", description: "Working directory" }, + dir: { type: "string", description: "Working directory" }, json: { type: "boolean", description: "Output as JSON", default: false }, id: { type: "positional", diff --git a/packages/cli/src/commands/verify.ts b/packages/cli/src/commands/verify.ts index 46c6b9f55..de0e0348c 100644 --- a/packages/cli/src/commands/verify.ts +++ b/packages/cli/src/commands/verify.ts @@ -276,7 +276,6 @@ async function runOverPath(options: { const ruleTargetArguments = { dir: { type: "string", - alias: "d", description: "Working directory", }, json: { diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index e686a6ef4..c0aa4c4bf 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -26,18 +26,13 @@ import { } from "./telemetry"; import { emitRunEvents, resolveCommandName, resolveCwd } from "./telemetry-run"; import { runWizard } from "./wizard"; -import { - DIR_FLAGS, - hasHelpFlag, - hasVersionFlag, - joinDirectoryValues, - splitRawArguments, -} from "./util/argv"; +import { hasHelpFlag, hasVersionFlag, splitRawArguments } from "./util/argv"; import { nonInteractivePreamble, shouldLaunchWizard, wizardBlocker, } from "./util/interactive"; +import { spacedValueFlagMessage } from "./util/value-flags"; import { showResolvedUsage } from "./util/help"; import { getCliPrefix } from "./util/package-manager"; import { CLIError } from "./util/cli-error"; @@ -84,8 +79,7 @@ const main = defineCommand({ args: { dir: { type: "string", - alias: "d", - description: "Set the working directory", + description: "Set the working directory (--dir=)", }, json: { type: "boolean", @@ -114,22 +108,21 @@ const main = defineCommand({ async run({ rawArgs, cmd }) { // citty always calls the parent's run handler, even after a subcommand. // Only take action when no positional args (i.e. no subcommand) were - // provided. A value following `-d`/`--dir` is a flag value, not a - // positional, so splitRawArguments skips it. + // provided. A flag's value is inside its token (`--dir=`), so it is + // never mistaken for a positional. const { positionals, flags } = splitRawArguments(rawArgs); if (positionals.length > 0) { return; } // Only delegate to `init` when the only flags present are ones init - // also understands (`-d` / `--dir`). `--json`, a bare `--`, and any + // also understands (`--dir=`). `--json`, a bare `--`, and any // unknown flags should fall through to citty's default help instead of // silently launching the wizard. (`--help`/`-h` and `--version`/`-v` // never reach here — they are intercepted before dispatch below.) - // Compared by name before any `=`: argv arrives with `-d ` already - // joined into `--dir=` (see joinDirectoryValues). - const onlyInitFlags = flags.every((flag) => - DIR_FLAGS.has(flag.split("=", 1)[0]!) + // Compared by name before any `=`. + const onlyInitFlags = flags.every( + (flag) => flag.split("=", 1)[0] === "--dir" ); if (!onlyInitFlags) { await showUsage(cmd); @@ -174,7 +167,7 @@ const main = defineCommand({ recipes, }) ); - // Forward the parent's rawArgs (e.g. `-d `) so the agent command + // Forward the parent's rawArgs (e.g. `--dir=`) so the agent command // doesn't mis-parse them as positional topic names. await runCommand(agentCommand, { rawArgs: ["agent", ...rawArgs] }); }, @@ -209,9 +202,10 @@ async function requireRecordedVersionForRun( } // main loop to run cli and make every attempt to shut down gracefully -// `-d ` is joined into `--dir=` so citty's subcommand resolution -// cannot mistake the path for a command name (see joinDirectoryValues). -const rawArguments = joinDirectoryValues(process.argv.slice(2)); +// Every flag value is inside its token (`--dir=`), so citty's subcommand +// resolution, which takes the first token not starting with `-`, never mistakes +// a value for a command name. The other spelling is refused below. +const rawArguments = process.argv.slice(2); const runCwd = resolveCwd(rawArguments); const startedAt = Date.now(); // Resolve identity at invocation START so cli_run reports who *initiated* the @@ -231,8 +225,20 @@ try { } else if (hasVersionFlag(rawArguments)) { process.stdout.write(`${__VERSION__}\n`); } else { - await requireRecordedVersionForRun(rawArguments); - await runCommand(main, { rawArgs: rawArguments }); + // Refused before the version gate, so a malformed call is turned away + // without reading the project. + const spaced = await spacedValueFlagMessage(main, rawArguments); + if (spaced === undefined) { + await requireRecordedVersionForRun(rawArguments); + await runCommand(main, { rawArgs: rawArguments }); + } else { + if (rawArguments.includes("--json")) { + writeJsonError("INVALID_INPUT", spaced); + } else { + console.error(`Error: ${spaced}`); + } + process.exitCode = 1; + } } } catch (error) { // CLIError = expected failure. Most throw sites (the `fail()` helpers) print diff --git a/packages/cli/src/telemetry-run.ts b/packages/cli/src/telemetry-run.ts index 6d49c3842..6bf8a6bea 100644 --- a/packages/cli/src/telemetry-run.ts +++ b/packages/cli/src/telemetry-run.ts @@ -33,14 +33,11 @@ export function resolveCommandName(rawArguments: string[]): string { /** Resolve the working directory from `-d`/`--dir`, defaulting to cwd. */ export function resolveCwd(rawArguments: string[]): string { - for (let index = 0; index < rawArguments.length; index++) { - const argument = rawArguments[index]!; - if ( - (argument === "-d" || argument === "--dir") && - rawArguments[index + 1] - ) { - return resolve(rawArguments[index + 1]!); - } + // `--dir=` is the only spelling; the entry point refuses `-d` and a + // bare `--dir` before a command runs. Stops at `--`, after which a token + // reading `--dir=x` is a path. + for (const argument of rawArguments) { + if (argument === "--") break; if (argument.startsWith("--dir=")) { return resolve(argument.slice("--dir=".length)); } diff --git a/packages/cli/src/util/argv.ts b/packages/cli/src/util/argv.ts index 28a9a4d03..09dd0d5ab 100644 --- a/packages/cli/src/util/argv.ts +++ b/packages/cli/src/util/argv.ts @@ -1,75 +1,52 @@ /** * Raw-argv scanning shared by everything that has to answer "which tokens are - * positionals?" — subcommand resolution for `--help`, the root command's + * positionals?": subcommand resolution for `--help`, the root command's * no-subcommand check, `check`'s path arguments, and telemetry's command name. - * One copy, because the rules are subtle: * - * - `-d`/`--dir` take a value, so the token after one of them is a flag value - * and NOT a positional (`taskless -d /tmp check` runs `check`, not `/tmp`). - * citty does not know this on its own; see `joinDirectoryValues`. - * - `--` is the POSIX end-of-options marker: every token after it is a - * positional even if it starts with `-`, which is what lets `taskless check - * -- -h` scan a path literally named `-h` instead of asking for help. + * The rule is simple because the CLI made it simple: a flag carries its value + * inside its own token, as `--flag=value`, and no flag ever consumes the token + * after it (`refuseSpacedValueFlags` in `src/index.ts` turns the other spelling + * away before any command runs). So a token beginning with `-` is a flag and + * every other token is a positional, except that `--`, the POSIX end-of-options + * marker, makes every token after it a positional, which is what lets + * `taskless check -- -h` scan a path literally named `-h`. + * + * Before this, the scanner had to be told which flags consumed the next token, + * and a flag left off that list turned its value into a positional path: + * `check --rule no-eval` looked for a file named `no-eval`, found none, and + * exited 0. With no flag consuming anything, there is no list to forget. */ -/** Flags every command takes a value for. */ -export const DIR_FLAGS = new Set(["-d", "--dir"]); - /** The POSIX end-of-options marker. */ -const END_OF_OPTIONS = "--"; +export const END_OF_OPTIONS = "--"; export interface SplitArguments { - /** - * Tokens that are not flags and not the value of a value-taking flag, plus - * everything after `--`. - */ + /** Tokens that are not flags, plus everything after `--`. */ positionals: string[]; /** - * Option tokens, in order, including the `--` marker itself. Values consumed - * by a value-taking flag are not included. + * Option tokens, in order, as written (a `--flag=value` token keeps its + * value), including the `--` marker itself. */ flags: string[]; /** - * Every value a value-taking flag carried, in order, in both spellings - * (`--flag value` and `--flag=value`). + * Every value a flag carried with `=`, in order. * * Here rather than in each caller because a second scanner is a second - * opinion about what the same tokens mean. `check` needs every `--rule` - * value, and a hand-rolled scan of its own would not know that `--timeout` - * consumes the token after it: `check --timeout --rule no-eval` would give - * `no-eval` to `--rule` while this scanner had already handed it to - * `positionals`. Reading both answers off one pass makes that disagreement - * impossible rather than unlikely. + * opinion about what the same tokens mean. Reading positionals and values + * off one pass makes a disagreement between them impossible. */ values: FlagValue[]; } -/** One occurrence of a value-taking flag, with the value it consumed. */ +/** One `--flag=value` occurrence. */ export interface FlagValue { - /** The flag as written, without any `=value` suffix. */ + /** The flag as written, without its `=value` suffix. */ flag: string; value: string; } -/** - * Split raw argv into positionals and flags, skipping flag values and honoring - * `--`. `valueFlags` names flags beyond `-d`/`--dir` that consume the next - * token (e.g. `check`'s `--timeout`). - * - * `optionalValueFlags` names flags whose value is optional and therefore comes - * only from the `--flag=value` spelling, the way git spells them - * (`--color[=]`). Such a flag never consumes the next token: in - * `check --diff src/a.ts`, `src/a.ts` is a positional, because reading it as - * the flag's value would make the same tokens mean two different things - * depending on what the caller intended. - */ -export function splitRawArguments( - rawArguments: string[], - valueFlags: readonly string[] = [], - optionalValueFlags: readonly string[] = [] -): SplitArguments { - const consumesValue = - valueFlags.length > 0 ? new Set([...DIR_FLAGS, ...valueFlags]) : DIR_FLAGS; +/** Split raw argv into positionals, flags, and the values flags carried. */ +export function splitRawArguments(rawArguments: string[]): SplitArguments { const positionals: string[] = []; const flags: string[] = []; const values: FlagValue[] = []; @@ -82,22 +59,12 @@ export function splitRawArguments( } if (argument.startsWith("-")) { flags.push(argument); - // `--dir=` carries its own value; `-d ` eats the next token — - // unless that token is `--`, which ends the options rather than being one. const equals = argument.indexOf("="); if (equals > 0) { - const flag = argument.slice(0, equals); - if (consumesValue.has(flag) || optionalValueFlags.includes(flag)) - values.push({ flag, value: argument.slice(equals + 1) }); - continue; - } - if ( - consumesValue.has(argument) && - rawArguments[index + 1] !== undefined && - rawArguments[index + 1] !== END_OF_OPTIONS - ) { - values.push({ flag: argument, value: rawArguments[index + 1]! }); - index++; + values.push({ + flag: argument.slice(0, equals), + value: argument.slice(equals + 1), + }); } continue; } @@ -106,51 +73,11 @@ export function splitRawArguments( return { positionals, flags, values }; } -/** - * Rewrite `-d ` and `--dir ` into the one-token `--dir=`. - * - * citty picks a subcommand from the first raw token that does not start with - * `-`, at every level that has subcommands, and it does that before parsing - * any flags. In `taskless auth -d .` that token is `.`, the flag's value, so - * citty reports "Unknown command `.`" before `auth` ever runs. The `=` - * spelling keeps the value inside the flag token, where citty's resolution - * skips it and its parser still reads it as `dir`. - * - * Applied once to argv before dispatch rather than per command, because every - * command with subcommands (the root included) has the same exposure. A value - * that itself starts with `-` is left alone: citty already skips it, and - * joining it would change what citty parses. Tokens after `--` are - * positionals and are never touched. - */ -export function joinDirectoryValues(rawArguments: string[]): string[] { - const joined: string[] = []; - for (let index = 0; index < rawArguments.length; index++) { - const argument = rawArguments[index]!; - if (argument === END_OF_OPTIONS) { - joined.push(...rawArguments.slice(index)); - break; - } - const value = rawArguments[index + 1]; - if ( - DIR_FLAGS.has(argument) && - value !== undefined && - !value.startsWith("-") - ) { - joined.push(`--dir=${value}`); - index++; - continue; - } - joined.push(argument); - } - return joined; -} - /** * True when any of `names` appears as a flag token. Scanned through - * `splitRawArguments` so neither a flag value nor a path after `--` that - * happens to read like `-h` or `-v` is mistaken for a request. Matched as - * whole tokens, the same way citty's own `runMain` matches `--help` and - * `--version`. + * `splitRawArguments` so a path after `--` that happens to read like `-h` or + * `-v` is not mistaken for a request. Matched as whole tokens, the same way + * citty's own `runMain` matches `--help` and `--version`. */ function hasFlag(rawArguments: string[], names: readonly string[]): boolean { const { flags } = splitRawArguments(rawArguments); @@ -164,7 +91,7 @@ export function hasHelpFlag(rawArguments: string[]): boolean { /** * True when argv asks for the version. Position is not consulted, so - * `taskless check --version` answers with the version too — the question is + * `taskless check --version` answers with the version too: the question is * about the tool, not the subcommand, and no subcommand defines `-v` or * `--version` itself. */ diff --git a/packages/cli/src/util/help.ts b/packages/cli/src/util/help.ts index 82caac62b..f2e322f2a 100644 --- a/packages/cli/src/util/help.ts +++ b/packages/cli/src/util/help.ts @@ -26,32 +26,61 @@ async function resolveValue( } /** - * Render usage for the deepest command the positionals resolve to, with its - * parent (so nested commands like `auth login` print their own usage under - * their own name). Returns normally — never exits — so the caller's telemetry - * `finally` still runs. + * The commands the positionals name, root first: `taskless auth login` is + * `[main, auth, login]`. The first positional that is not a subcommand of the + * command reached so far ends the walk (it is an argument, or a typo). + * + * Widened to `CommandDef` once: each command has its own args shape, and every + * caller reads meta and args generically. */ -export async function showResolvedUsage( +export async function resolveCommandChain( root: CommandDef, rawArguments: string[] -): Promise { - // Widen once: the walk descends into subcommands, each with its own args - // shape, and only the rendering (which reads meta and args generically) is - // done with the result. +): Promise { let command = root as unknown as CommandDef; - let parent: CommandDef | undefined; - + const chain = [command]; for (const name of splitRawArguments(rawArguments).positionals) { const subCommands = await resolveValue(command.subCommands); const child = subCommands ? await resolveValue(subCommands[name]) : undefined; - // The first token that is not a child of the current command ends the - // walk (it is a positional argument, or a typo) — render what resolved. if (!child) break; - parent = command; command = child; + chain.push(command); + } + return chain; +} + +/** + * The value-taking flags of every command in `chain`, each spelled `--name`. + * Read from the definitions, so a flag is covered the day it is declared. + */ +export async function valueFlagNames( + chain: CommandDef[] +): Promise> { + const names = new Set(); + for (const command of chain) { + const args = await resolveValue(command.args); + for (const [name, definition] of Object.entries(args ?? {})) { + if (definition.type === "string") names.add(`--${name}`); + } } + return names; +} + +/** + * Render usage for the deepest command the positionals resolve to, with its + * parent (so nested commands like `auth login` print their own usage under + * their own name). Returns normally — never exits — so the caller's telemetry + * `finally` still runs. + */ +export async function showResolvedUsage( + root: CommandDef, + rawArguments: string[] +): Promise { + const chain = await resolveCommandChain(root, rawArguments); + const command = chain.at(-1)!; + const parent = chain.at(-2); console.log(getAgentInstallLine()); console.log(""); diff --git a/packages/cli/src/util/value-flags.ts b/packages/cli/src/util/value-flags.ts new file mode 100644 index 000000000..4303d1e68 --- /dev/null +++ b/packages/cli/src/util/value-flags.ts @@ -0,0 +1,40 @@ +import type { ArgsDef, CommandDef } from "citty"; + +import { END_OF_OPTIONS } from "./argv"; +import { resolveCommandChain, valueFlagNames } from "./help"; + +/** + * Why argv was refused for spelling a flag value outside its token, or + * `undefined` when every value flag is written `--flag=value`. + * + * Every value-taking flag takes its value after `=` and nothing else, so no + * flag consumes the token after it and a positional is never a flag's value by + * accident. A bare `--flag` of the command being run (or of a parent) is the + * other spelling, and is refused whether or not a token follows it: `check + * --rule` is the same mistake as `check --rule no-eval`. `-d`, the removed + * short form of `--dir`, is refused by name so a caller learns what replaced + * it rather than meeting an unknown flag and a command named after a path. + */ +export async function spacedValueFlagMessage( + root: CommandDef, + rawArguments: string[] +): Promise { + const names = await valueFlagNames( + await resolveCommandChain(root, rawArguments) + ); + for (let index = 0; index < rawArguments.length; index++) { + const token = rawArguments[index]!; + if (token === END_OF_OPTIONS) return undefined; + if (token === "-d") { + return "`-d` was removed: pass the working directory as `--dir=`."; + } + if (!names.has(token)) continue; + const next = rawArguments[index + 1]; + const rewrite = + next !== undefined && !next.startsWith("-") + ? ` Here, write \`${token}=${next}\`.` + : ""; + return `\`${token}\` takes its value after \`=\`, as \`${token}=\`.${rewrite}`; + } + return undefined; +} diff --git a/packages/cli/test/agent-extensions.test.ts b/packages/cli/test/agent-extensions.test.ts index 30cc75753..33736e284 100644 --- a/packages/cli/test/agent-extensions.test.ts +++ b/packages/cli/test/agent-extensions.test.ts @@ -43,7 +43,7 @@ describe("taskless agent (no args)", () => { }); it("prints the human slug", async () => { - const result = await runCli(["agent", "-d", cwd]); + const result = await runCli(["agent", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("For agents:"); expect(result.stdout).toContain("For humans:"); @@ -54,12 +54,12 @@ describe("taskless agent (no args)", () => { // rather than sending the reader to the released package. A prod build // rewrites to the same string, which is why the sibling ast-grep rule // `no-unrouted-cli-invocation` is what actually guards the routing. - const result = await runCli(["agent", "-d", cwd]); + const result = await runCli(["agent", `--dir=${cwd}`]); expect(result.stdout).toContain(`\`${buildInvocation()}\` (no args)`); }); it("prints the topic table including all expected topics", async () => { - const result = await runCli(["agent", "-d", cwd]); + const result = await runCli(["agent", `--dir=${cwd}`]); expect(result.stdout).toContain("Topics:"); for (const topic of ["init", "info", "check", "auth", "rule"]) { expect(result.stdout).toContain(topic); @@ -67,12 +67,12 @@ describe("taskless agent (no args)", () => { }); it("mentions the --local flag", async () => { - const result = await runCli(["agent", "-d", cwd]); + const result = await runCli(["agent", `--dir=${cwd}`]); expect(result.stdout).toContain("--local"); }); it("lists the routing recipe topics under Authoring recipes", async () => { - const result = await runCli(["agent", "-d", cwd]); + const result = await runCli(["agent", `--dir=${cwd}`]); expect(result.stdout).toContain("Authoring recipes:"); for (const topic of [ "route", @@ -87,7 +87,7 @@ describe("taskless agent (no args)", () => { }); it("no longer advertises the removed topic names", async () => { - const result = await runCli(["agent", "-d", cwd]); + const result = await runCli(["agent", `--dir=${cwd}`]); // `static`/`existing`/`remote` were renamed and `engine-selection` was // merged into `route`. Listing a name that resolves to nothing is worse // than not listing it — the agent spends a fetch to learn it is gone. @@ -116,7 +116,7 @@ describe("taskless agent ", () => { "create-runtime-rule", "create-remote-rule", ])("resolves the %s recipe without an unknown-topic error", async (topic) => { - const result = await runCli(["agent", topic, "-d", cwd]); + const result = await runCli(["agent", topic, `--dir=${cwd}`]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain(`# Topic: ${topic}`); expect(result.stdout).toContain("## Goal"); @@ -128,7 +128,7 @@ describe("taskless agent ", () => { // again next task, stale skill after an install. The recipe files do // not carry it (see prompts.test.ts); the renderer adds it here. for (const args of [["agent", "check"], ["agent", "init"], ["update"]]) { - const result = await runCli([...args, "-d", cwd]); + const result = await runCli([...args, `--dir=${cwd}`]); const lines = result.stdout.split("\n"); expect(lines[0], args.join(" ")).toMatch(/^# Topic:/); expect(lines[1], args.join(" ")).toContain("do not reuse this copy"); @@ -148,7 +148,7 @@ describe("taskless agent ", () => { "create-runtime-rule", "create-remote-rule", ])("opens %s with the orientation banner", async (topic) => { - const result = await runCli(["agent", topic, "-d", cwd]); + const result = await runCli(["agent", topic, `--dir=${cwd}`]); expect(result.stdout).toContain("## You are here"); expect(result.stdout).toContain(`This is \`${topic}\`.`); // Recipes name the CLI through `%(TASKLESS_CLI)s`, which renders as the @@ -160,7 +160,7 @@ describe("taskless agent ", () => { it.each(["existing", "static", "remote", "engine-selection", "rule-create"])( "no longer resolves the removed topic %s", async (topic) => { - const result = await runCli(["agent", topic, "-d", cwd]); + const result = await runCli(["agent", topic, `--dir=${cwd}`]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("Unknown command"); } @@ -179,7 +179,11 @@ describe("taskless agent ", () => { }); it("returns the canonical recipe for a known topic", async () => { - const result = await runCli(["agent", "create-remote-rule", "-d", cwd]); + const result = await runCli([ + "agent", + "create-remote-rule", + `--dir=${cwd}`, + ]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("# Topic: create-remote-rule"); expect(result.stdout).toContain("## Goal"); @@ -187,7 +191,11 @@ describe("taskless agent ", () => { }); it("interpolates %(CLI_VERSION)s in the recipe header", async () => { - const result = await runCli(["agent", "create-remote-rule", "-d", cwd]); + const result = await runCli([ + "agent", + "create-remote-rule", + `--dir=${cwd}`, + ]); // Should contain a version pattern, not the literal placeholder. // Guard against both the legacy mustache syntax and the current // sprintf-js named-arg syntax leaking through. @@ -201,10 +209,8 @@ describe("taskless agent ", () => { const result = await runCli([ "agent", "create-remote-rule", - "--section", - "input-schema", - "-d", - cwd, + "--section=input-schema", + `--dir=${cwd}`, ]); expect(result.stdout).not.toContain("{{INPUT_SCHEMA}}"); expect(result.stdout).not.toContain("%(INPUT_SCHEMA)s"); @@ -215,7 +221,7 @@ describe("taskless agent ", () => { }); it("serves the ci recipe with the launcher command and no placeholders", async () => { - const result = await runCli(["agent", "ci", "-d", cwd]); + const result = await runCli(["agent", "ci", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); expect(result.stdout).not.toContain("%("); expect(result.stdout).not.toContain(""); @@ -223,13 +229,13 @@ describe("taskless agent ", () => { }); it("exits 1 for an unknown topic", async () => { - const result = await runCli(["agent", "totally-unknown", "-d", cwd]); + const result = await runCli(["agent", "totally-unknown", `--dir=${cwd}`]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("Unknown command"); }); it("points an unknown topic at `agent`, not the removed command", async () => { - const result = await runCli(["agent", "totally-unknown", "-d", cwd]); + const result = await runCli(["agent", "totally-unknown", `--dir=${cwd}`]); // Through the launcher, not a bare `taskless` that may not be on PATH. expect(result.stderr).toMatch( /Run `(?:npx|pnpm dlx) @taskless\/cli@\d[^\s`]* agent` for available/ @@ -241,7 +247,7 @@ describe("taskless agent ", () => { // invited an agent to paraphrase a topic name and still get a hit. Extra // positionals are now an error rather than something to guess at. it("rejects a multi-token topic instead of joining the positionals", async () => { - const result = await runCli(["agent", "rule", "create", "-d", cwd]); + const result = await runCli(["agent", "rule", "create", `--dir=${cwd}`]); expect(result.exitCode).not.toBe(0); expect(result.stdout).not.toContain("# Topic:"); expect(result.stderr).toContain("Too many arguments"); @@ -263,7 +269,12 @@ describe("taskless agent --local (variant lookup)", () => { it.each(["--local", "--anonymous"])( "returns the .anonymous variant when one exists (improve-rule, %s)", async (flag) => { - const result = await runCli(["agent", "improve-rule", flag, "-d", cwd]); + const result = await runCli([ + "agent", + "improve-rule", + flag, + `--dir=${cwd}`, + ]); expect(result.exitCode).toBe(0); // The local-mode recipe declares "(local mode)" in its header expect(result.stdout).toContain("(local mode)"); @@ -271,8 +282,13 @@ describe("taskless agent --local (variant lookup)", () => { ); it("falls back to the canonical recipe when no variant exists (check)", async () => { - const canonical = await runCli(["agent", "check", "-d", cwd]); - const anonymous = await runCli(["agent", "check", "--local", "-d", cwd]); + const canonical = await runCli(["agent", "check", `--dir=${cwd}`]); + const anonymous = await runCli([ + "agent", + "check", + "--local", + `--dir=${cwd}`, + ]); expect(anonymous.exitCode).toBe(0); // Same body — falls back to check.md since no check.anonymous.md expect(anonymous.stdout).toBe(canonical.stdout); @@ -284,13 +300,16 @@ describe("taskless agent --local (variant lookup)", () => { // be "the local version of the remote one" — the contradiction `route` // resolves. It falls back to the canonical text instead. it("has no anonymous variant of the service recipe", async () => { - const canonical = await runCli(["agent", "create-remote-rule", "-d", cwd]); + const canonical = await runCli([ + "agent", + "create-remote-rule", + `--dir=${cwd}`, + ]); const anonymous = await runCli([ "agent", "create-remote-rule", "--local", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(anonymous.exitCode).toBe(0); expect(anonymous.stdout).toBe(canonical.stdout); @@ -298,7 +317,7 @@ describe("taskless agent --local (variant lookup)", () => { }); it("returns the canonical recipe when --local is omitted", async () => { - const result = await runCli(["agent", "improve-rule", "-d", cwd]); + const result = await runCli(["agent", "improve-rule", `--dir=${cwd}`]); expect(result.stdout).toContain("# Topic: improve-rule"); expect(result.stdout).not.toContain("(local mode)"); }); @@ -331,7 +350,7 @@ describe("taskless agent route (absorbed engine reasoning)", () => { }); it("puts the evidence before the destination", async () => { - const result = await runCli(["agent", "route", "-d", cwd]); + const result = await runCli(["agent", "route", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("before you name a destination"); }); @@ -341,10 +360,8 @@ describe("taskless agent route (absorbed engine reasoning)", () => { const result = await runCli([ "agent", "route", - "--section", - "engine-boundaries", - "-d", - cwd, + "--section=engine-boundaries", + `--dir=${cwd}`, ]); // Each is a wrong answer someone actually reaches for. expect(result.stdout).toContain("Prose about code is still prose"); @@ -356,10 +373,8 @@ describe("taskless agent route (absorbed engine reasoning)", () => { const result = await runCli([ "agent", "route", - "--section", - "important-notes", - "-d", - cwd, + "--section=important-notes", + `--dir=${cwd}`, ]); // "choose an engine whose availability you can assert" stays correct on an // unsupported arch and server-side alike; naming `sg` outright would be @@ -372,16 +387,14 @@ describe("taskless agent route (absorbed engine reasoning)", () => { const result = await runCli([ "agent", "route", - "--section", - "important-notes", - "-d", - cwd, + "--section=important-notes", + `--dir=${cwd}`, ]); expect(result.stdout).toContain("outranks how the request was"); }); it("names all five destinations", async () => { - const result = await runCli(["agent", "route", "-d", cwd]); + const result = await runCli(["agent", "route", `--dir=${cwd}`]); for (const destination of [ "create-legacy-rule", "create-sg-rule", @@ -394,19 +407,19 @@ describe("taskless agent route (absorbed engine reasoning)", () => { }); it("splits the runtime destination on login state", async () => { - const result = await runCli(["agent", "route", "-d", cwd]); + const result = await runCli(["agent", "route", `--dir=${cwd}`]); // D7: reading login state early is what makes the destination set correct. expect(result.stdout).toContain("info --json"); expect(result.stdout).toContain("logged out"); }); it("sends the reader to a command rather than a category", async () => { - const result = await runCli(["agent", "route", "-d", cwd]); + const result = await runCli(["agent", "route", `--dir=${cwd}`]); expect(result.stdout).toMatch(/agent create-vale-rule/); }); it("follows the recipe header and section convention", async () => { - const result = await runCli(["agent", "route", "-d", cwd]); + const result = await runCli(["agent", "route", `--dir=${cwd}`]); expect(result.stdout).toContain("# Topic: route"); for (const section of ["## Goal", "## Preconditions", "## Steps"]) { expect(result.stdout).toContain(section); @@ -418,7 +431,7 @@ describe("taskless agent route (absorbed engine reasoning)", () => { it("sends the reader to the engine reach before the decision", async () => { // The reach lists decide the destination and were what truncation lost, // so the steps name each section to print (taskless/cli#672). - const result = await runCli(["agent", "route", "-d", cwd]); + const result = await runCli(["agent", "route", `--dir=${cwd}`]); for (const section of ["ast-grep-reach", "vale-reach", "legacy-linters"]) { expect(result.stdout).toContain(`section \`${section}\``); } @@ -443,7 +456,7 @@ describe("the GitHub-owner constraint is guarded twice", () => { }); it("route reads ghOwner from the info call it already makes", async () => { - const result = await runCli(["agent", "route", "-d", cwd]); + const result = await runCli(["agent", "route", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("ghOwner"); // Read from the payload, not re-derived, so the offer matches what the @@ -452,7 +465,7 @@ describe("the GitHub-owner constraint is guarded twice", () => { }); it("route drops remote generation when there is no owner", async () => { - const result = await runCli(["agent", "route", "-d", cwd]); + const result = await runCli(["agent", "route", `--dir=${cwd}`]); expect(result.stdout).toContain("Drop remote generation"); expect(result.stdout).toContain("[unknown]"); }); @@ -460,12 +473,16 @@ describe("the GitHub-owner constraint is guarded twice", () => { it("route says the omission is not fixable by logging in", async () => { // The failure most likely to be misread as an auth problem. An agent that // sends the user to `auth login` wastes a turn and lands back here. - const result = await runCli(["agent", "route", "-d", cwd]); + const result = await runCli(["agent", "route", `--dir=${cwd}`]); expect(result.stdout).toContain("not fixed by `auth login`"); }); it("the remote recipe guards the constraint itself", async () => { - const result = await runCli(["agent", "create-remote-rule", "-d", cwd]); + const result = await runCli([ + "agent", + "create-remote-rule", + `--dir=${cwd}`, + ]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("Check the GitHub owner first"); expect(result.stdout).toContain("ghOwner"); @@ -474,7 +491,11 @@ describe("the GitHub-owner constraint is guarded twice", () => { }); it("the remote recipe does not send the user to auth login for it", async () => { - const result = await runCli(["agent", "create-remote-rule", "-d", cwd]); + const result = await runCli([ + "agent", + "create-remote-rule", + `--dir=${cwd}`, + ]); expect(result.stdout).toContain("`auth login` does not fix it"); }); @@ -486,7 +507,7 @@ describe("the GitHub-owner constraint is guarded twice", () => { "%s documents every code the populations raise", async (topic) => { // `--full`: the Errors table may be served on request (taskless/cli#672). - const result = await runCli(["agent", topic, "--full", "-d", cwd]); + const result = await runCli(["agent", topic, "--full", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); for (const code of [ "NOT_A_GIT_REPOSITORY", @@ -503,7 +524,7 @@ describe("the GitHub-owner constraint is guarded twice", () => { it.each(["create-remote-rule", "improve-rule"])( "%s says auth login does not fix a missing owner", async (topic) => { - const result = await runCli(["agent", topic, "-d", cwd]); + const result = await runCli(["agent", topic, `--dir=${cwd}`]); expect(result.stdout).toMatch(/`auth login` (does not|cannot) fix/); } ); @@ -529,10 +550,8 @@ describe("create-sg-rule warns about silently inert relational rules", () => { const result = await runCli([ "agent", "create-sg-rule", - "--section", - "relational-quirks", - "-d", - cwd, + "--section=relational-quirks", + `--dir=${cwd}`, ]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("stopBy: end` to cross punctuation"); @@ -544,10 +563,8 @@ describe("create-sg-rule warns about silently inert relational rules", () => { const result = await runCli([ "agent", "create-sg-rule", - "--section", - "relational-quirks", - "-d", - cwd, + "--section=relational-quirks", + `--dir=${cwd}`, ]); expect(result.stdout).toContain("excludes everything"); expect(result.stdout).toContain("its own descendant"); @@ -559,10 +576,8 @@ describe("create-sg-rule warns about silently inert relational rules", () => { const result = await runCli([ "agent", "create-sg-rule", - "--section", - "quirks", - "-d", - cwd, + "--section=quirks", + `--dir=${cwd}`, ]); expect(result.stdout).toContain("reads exactly like a clean codebase"); }); @@ -588,10 +603,8 @@ describe("create-sg-rule names the tree-sitter traps under Quirks", () => { const result = await runCli([ "agent", "create-sg-rule", - "--section", - "pattern-quirks", - "-d", - cwd, + "--section=pattern-quirks", + `--dir=${cwd}`, ]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("### A keyword is not a valid `kind`"); @@ -604,10 +617,8 @@ describe("create-sg-rule names the tree-sitter traps under Quirks", () => { const result = await runCli([ "agent", "create-sg-rule", - "--section", - "pattern-quirks", - "-d", - cwd, + "--section=pattern-quirks", + `--dir=${cwd}`, ]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain( @@ -641,8 +652,7 @@ describe("taskless agent --tool (variant lookup)", () => { "agent", "create-legacy-rule", `--tool=${tool}`, - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain(`# Topic: create-legacy-rule (${tool})`); @@ -652,23 +662,24 @@ describe("taskless agent --tool (variant lookup)", () => { const result = await runCli([ "agent", "create-legacy-rule", - "--tool", - "ruff", - "-d", - cwd, + "--tool=ruff", + `--dir=${cwd}`, ]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("# Topic: create-legacy-rule (ruff)"); }); it("falls back to the generic recipe for a tool with no variant", async () => { - const generic = await runCli(["agent", "create-legacy-rule", "-d", cwd]); + const generic = await runCli([ + "agent", + "create-legacy-rule", + `--dir=${cwd}`, + ]); const rubocop = await runCli([ "agent", "create-legacy-rule", "--tool=rubocop", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(rubocop.exitCode).toBe(0); expect(rubocop.stdout).toBe(generic.stdout); @@ -685,8 +696,7 @@ describe("taskless agent --tool (variant lookup)", () => { "agent", "create-legacy-rule", `--tool=${tool}`, - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain(instead); @@ -694,8 +704,13 @@ describe("taskless agent --tool (variant lookup)", () => { }); it("refuses only on a topic that has tool variants", async () => { - const plain = await runCli(["agent", "route", "-d", cwd]); - const vale = await runCli(["agent", "route", "--tool=vale", "-d", cwd]); + const plain = await runCli(["agent", "route", `--dir=${cwd}`]); + const vale = await runCli([ + "agent", + "route", + "--tool=vale", + `--dir=${cwd}`, + ]); expect(vale.exitCode).toBe(0); expect(vale.stdout).toBe(plain.stdout); }); @@ -705,8 +720,7 @@ describe("taskless agent --tool (variant lookup)", () => { "agent", "no-such-topic", "--tool=vale", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("Unknown command: no-such-topic"); diff --git a/packages/cli/test/ast-command.test.ts b/packages/cli/test/ast-command.test.ts index 0038e4684..ee5cef54c 100644 --- a/packages/cli/test/ast-command.test.ts +++ b/packages/cli/test/ast-command.test.ts @@ -302,7 +302,7 @@ describe("taskless ast", () => { it("emits the tree as JSON", async () => { await writeFile(join(cwd, "a.py"), "def f():\n return 1\n"); - const result = await runCli(["ast", "a.py", "--json", "-d", cwd], cwd); + const result = await runCli(["ast", "a.py", "--json", `--dir=${cwd}`], cwd); expect(result.exitCode).toBe(0); const output = JSON.parse(result.stdout) as { ok: boolean; @@ -318,7 +318,7 @@ describe("taskless ast", () => { it("cuts the tree to --range", async () => { await writeFile(join(cwd, "a.js"), "const a = 1;\nconst b = 2;\nfoo(b);\n"); - const result = await runCli(["ast", "a.js", "--range", "3", "--json"], cwd); + const result = await runCli(["ast", "a.js", "--range=3", "--json"], cwd); expect(result.exitCode).toBe(0); const output = JSON.parse(result.stdout) as { range: unknown; @@ -333,7 +333,7 @@ describe("taskless ast", () => { it("parses as --lang when given, and dumps a file starting with -", async () => { await writeFile(join(cwd, "list.txt"), "- a\n- b\n"); const result = await runCli( - ["ast", "list.txt", "--lang", "yaml", "--json"], + ["ast", "list.txt", "--lang=yaml", "--json"], cwd ); expect(result.exitCode).toBe(0); @@ -348,9 +348,9 @@ describe("taskless ast", () => { it.each([ [["ast", "missing.ts"], /No such file/], [["ast", "notes.unknownext"], /does not recognize the extension/], - [["ast", "a.ts", "--lang", "C#"], /has no language "C#"/], - [["ast", "a.ts", "--range", "5:2"], /--range takes/], - [["ast", "a.ts", "--range", "40"], /No node touches --range 40/], + [["ast", "a.ts", "--lang=C#"], /has no language "C#"/], + [["ast", "a.ts", "--range=5:2"], /--range takes/], + [["ast", "a.ts", "--range=40"], /No node touches --range 40/], [["ast", "empty.ts"], /is empty/], [["ast", "latin1.js"], /is not valid UTF-8/], ])("refuses %j with INVALID_INPUT", async (args, message) => { diff --git a/packages/cli/test/auth-login-json.test.ts b/packages/cli/test/auth-login-json.test.ts index b4fc9bea0..958953b68 100644 --- a/packages/cli/test/auth-login-json.test.ts +++ b/packages/cli/test/auth-login-json.test.ts @@ -41,7 +41,7 @@ let previousToken: string | undefined; let logSpy: ReturnType; async function run(...args: string[]): Promise { - await runCommand(authCommand, { rawArgs: [...args, "-d", cwd] }); + await runCommand(authCommand, { rawArgs: [...args, `--dir=${cwd}`] }); const [line] = logSpy.mock.calls.map((call) => String(call[0])); return line === undefined ? undefined : JSON.parse(line); } @@ -200,7 +200,7 @@ describe("auth login (interactive) after auth logout", () => { }; }); try { - await runCommand(authCommand, { rawArgs: ["login", "-d", cwd] }); + await runCommand(authCommand, { rawArgs: ["login", `--dir=${cwd}`] }); expect(process.exitCode).toBe(1); expect(errorSpy).toHaveBeenCalledWith( expect.stringContaining("The login was cancelled") @@ -228,7 +228,7 @@ async function failedLogin(poll: () => Promise): Promise { }); mockedPollForToken.mockImplementation(poll); try { - await runCommand(authCommand, { rawArgs: ["login", "-d", cwd] }); + await runCommand(authCommand, { rawArgs: ["login", `--dir=${cwd}`] }); return errorSpy.mock.calls.map((call) => String(call[0])); } finally { errorSpy.mockRestore(); @@ -278,7 +278,7 @@ describe("auth logout", () => { expiresAt: Date.now() + 600_000, }; await savePendingLogin(cwd, pending); - await runCommand(authCommand, { rawArgs: ["logout", "-d", cwd] }); + await runCommand(authCommand, { rawArgs: ["logout", `--dir=${cwd}`] }); expect(await readPendingLogin(cwd)).toBeUndefined(); }); }); diff --git a/packages/cli/test/auth-token-source.test.ts b/packages/cli/test/auth-token-source.test.ts index e0c293f0f..28ed7c990 100644 --- a/packages/cli/test/auth-token-source.test.ts +++ b/packages/cli/test/auth-token-source.test.ts @@ -27,7 +27,7 @@ describe("auth commands with TASKLESS_TOKEN set", () => { async function runAuth(args: string[]): Promise { const { stdout } = await execFileAsync( "node", - [binPath, "auth", ...args, "-d", cwd], + [binPath, "auth", ...args, `--dir=${cwd}`], { env: { ...process.env, TASKLESS_TOKEN: "env-token" } } ); return stdout; diff --git a/packages/cli/test/check-diff.test.ts b/packages/cli/test/check-diff.test.ts index 9a84d4fef..5178aefc1 100644 --- a/packages/cli/test/check-diff.test.ts +++ b/packages/cli/test/check-diff.test.ts @@ -79,15 +79,15 @@ function modifies(...files: string[]): string { .join(""); } -describe("splitRawArguments with optional-value flags", () => { - it("never takes the token after a bare optional-value flag", () => { - const split = splitRawArguments(["--diff", "src/a.ts"], [], ["--diff"]); +describe("splitRawArguments and --diff", () => { + it("never takes the token after a bare --diff", () => { + const split = splitRawArguments(["--diff", "src/a.ts"]); expect(split.positionals).toEqual(["src/a.ts"]); expect(split.values).toEqual([]); }); it("reads the value from the = spelling", () => { - const split = splitRawArguments(["--diff=change.patch"], [], ["--diff"]); + const split = splitRawArguments(["--diff=change.patch"]); expect(split.positionals).toEqual([]); expect(split.values).toEqual([{ flag: "--diff", value: "change.patch" }]); }); @@ -109,7 +109,7 @@ describe("check --diff", () => { it("checks only the files the diff changes", async () => { const run = await runCli( - ["check", "-d", directory, "--json", "--diff"], + ["check", `--dir=${directory}`, "--json", "--diff"], modifies("sample.js") ); expect(run.exitCode).toBe(1); @@ -120,7 +120,7 @@ describe("check --diff", () => { it("reports a finding on a line the diff did not change", async () => { // The diff changes line 4; `eval` sits on line 2. const run = await runCli( - ["check", "-d", directory, "--json", "--diff"], + ["check", `--dir=${directory}`, "--json", "--diff"], modifies("sample.js") ); const evalFinding = parse(run).results?.find( @@ -139,7 +139,7 @@ describe("check --diff", () => { await writeFile(join(fixture, "handler.js"), 'eval("fixture");\n'); const run = await runCli( - ["check", "-d", directory, "--json", "--diff"], + ["check", `--dir=${directory}`, "--json", "--diff"], modifies( ".taskless/rules/sg/no-eval/no-eval.yml", ".taskless/rules/sg/no-eval/tests/fail/case/handler.js" @@ -157,7 +157,7 @@ describe("check --diff", () => { it("checks nothing, and says so, when the diff is empty", async () => { const run = await runCli( - ["check", "-d", directory, "--json", "--diff"], + ["check", `--dir=${directory}`, "--json", "--diff"], "" ); expect(run.exitCode).toBe(0); @@ -170,7 +170,7 @@ describe("check --diff", () => { it("checks nothing when the diff only deletes files", async () => { const run = await runCli( - ["check", "-d", directory, "--json", "--diff"], + ["check", `--dir=${directory}`, "--json", "--diff"], [ "diff --git a/gone.js b/gone.js", "deleted file mode 100644", @@ -187,7 +187,7 @@ describe("check --diff", () => { it("refuses input that is not a unified diff", async () => { const run = await runCli( - ["check", "-d", directory, "--json", "--diff"], + ["check", `--dir=${directory}`, "--json", "--diff"], "sample.js --- 1/1 --- JavaScript\n2 const result = eval();\n" ); expect(run.exitCode).toBe(1); @@ -196,7 +196,7 @@ describe("check --diff", () => { it("reads the token after a bare --diff as a path, and refuses the pair", async () => { const run = await runCli( - ["check", "-d", directory, "--json", "--diff", "other.js"], + ["check", `--dir=${directory}`, "--json", "--diff", "other.js"], modifies("sample.js") ); expect(run.exitCode).toBe(1); @@ -207,7 +207,7 @@ describe("check --diff", () => { const patch = join(directory, "change.patch"); await writeFile(patch, modifies("sample.js")); const run = await runCli( - ["check", "-d", directory, "--json", `--diff=${patch}`], + ["check", `--dir=${directory}`, "--json", `--diff=${patch}`], "" ); expect(run.exitCode).toBe(1); @@ -231,8 +231,7 @@ describe("check --diff", () => { const run = await runCli( [ "check", - "-d", - directory, + `--dir=${directory}`, "--json", `--diff=${join(directory, "nope.patch")}`, ], @@ -243,7 +242,7 @@ describe("check --diff", () => { }); it("reads what git diff --staged writes, and reports a pre-existing finding", async () => { - await migrateFixture(["-d", directory]); + await migrateFixture([`--dir=${directory}`]); const git = (...args: string[]) => execFileSync("git", args, { cwd: directory, encoding: "utf8" }); git("init", "-q"); @@ -271,7 +270,7 @@ describe("check --diff", () => { ); const run = await runCli( - ["check", "-d", directory, "--json", "--diff"], + ["check", `--dir=${directory}`, "--json", "--diff"], diff ); expect(run.exitCode).toBe(1); @@ -293,7 +292,12 @@ describe("check --diff", () => { await mkdir(fixture, { recursive: true }); await writeFile(join(fixture, "handler.js"), 'eval("fixture");\n'); const run = await runCli( - ["check", "-d", directory, "--json", ".taskless/rules/sg/no-eval/tests"], + [ + "check", + `--dir=${directory}`, + "--json", + ".taskless/rules/sg/no-eval/tests", + ], "" ); expect(run.exitCode).toBe(1); diff --git a/packages/cli/test/check-environment-notice.test.ts b/packages/cli/test/check-environment-notice.test.ts index 0ae21eae6..ba9ff4f0f 100644 --- a/packages/cli/test/check-environment-notice.test.ts +++ b/packages/cli/test/check-environment-notice.test.ts @@ -59,7 +59,7 @@ describe("check out-of-date notice", () => { beforeEach(async () => { project = await mkdtemp(join(tmpdir(), "taskless-check-environment-")); await cp(fixturesDirectory, project, { recursive: true }); - await migrateFixture(["-d", project]); + await migrateFixture([`--dir=${project}`]); measureEnvironment.mockReset(); vi.stubEnv("NO_UPDATE_NOTIFIER", ""); process.exitCode = undefined; @@ -76,7 +76,7 @@ describe("check out-of-date notice", () => { }); async function check(...extra: string[]): Promise { - await runCommand(checkCommand, { rawArgs: ["-d", project, ...extra] }); + await runCommand(checkCommand, { rawArgs: [`--dir=${project}`, ...extra] }); const code = process.exitCode; process.exitCode = undefined; return typeof code === "number" ? code : undefined; diff --git a/packages/cli/test/check-gitignore.test.ts b/packages/cli/test/check-gitignore.test.ts index 9f9d7269b..2b7803c66 100644 --- a/packages/cli/test/check-gitignore.test.ts +++ b/packages/cli/test/check-gitignore.test.ts @@ -75,8 +75,7 @@ async function checkedFiles( ): Promise { const { stdout } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", ...arguments_, ]); diff --git a/packages/cli/test/check-rule-filter.test.ts b/packages/cli/test/check-rule-filter.test.ts index 8dd9f47e2..899f68dbb 100644 --- a/packages/cli/test/check-rule-filter.test.ts +++ b/packages/cli/test/check-rule-filter.test.ts @@ -82,26 +82,23 @@ function triples(results: CheckFinding[]): string[] { const valeAvailable = findValeBinary().path !== undefined; describe("extractRuleFilters", () => { - it("collects every --rule value, in both spellings", () => { + it("collects every --rule value, in order", () => { expect( - extractRuleFilters(["check", "--rule", "a", "--json", "--rule=b"]) + extractRuleFilters(["check", "--rule=a", "--json", "--rule=b"]) ).toEqual(["a", "b"]); }); it("stops at the end-of-options marker", () => { // After `--` every token is a path, including one spelled like this flag. - expect(extractRuleFilters(["check", "--", "--rule", "a"])).toEqual([]); + expect(extractRuleFilters(["check", "--", "--rule=a"])).toEqual([]); }); - it("agrees with the positional scan about a value-taking flag", () => { - // Malformed: `--timeout` was given no value, so it eats `--rule` and - // `no-eval` is a path. Both readings come off one scan, so they cannot - // disagree about whether `no-eval` is a path or a rule id. - const argv = ["check", "--timeout", "--rule", "no-eval"]; - expect(extractRuleFilters(argv)).toEqual([]); - expect( - splitRawArguments(argv, ["--timeout", "--rule"]).positionals - ).toEqual(["check", "no-eval"]); + it("agrees with the positional scan", () => { + // Both readings come off one scan, so they cannot disagree about whether + // a token is a path or a rule id. + const argv = ["check", "--rule=no-eval", "src"]; + expect(extractRuleFilters(argv)).toEqual(["no-eval"]); + expect(splitRawArguments(argv).positionals).toEqual(["check", "src"]); }); }); @@ -127,8 +124,7 @@ describe("check --rule", () => { async function check(...arguments_: string[]): Promise { const { stdout } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", ...arguments_, ]); @@ -145,7 +141,7 @@ describe("check --rule", () => { }); it("narrows an ast-grep run to the named rule", async () => { - const filtered = await check("--rule", "no-eval"); + const filtered = await check("--rule=no-eval"); expect(triples(filtered.results)).toEqual(["ast-grep no-eval sample.js"]); // The flag's value is not a path: were it scanned as one it would not @@ -158,11 +154,9 @@ describe("check --rule", () => { it("errors naming an id no rule directory has", async () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", - "--rule", - "no-such-rule", + "--rule=no-such-rule", ]); const envelope = JSON.parse(stdout.trim()) as { ok: boolean; @@ -180,7 +174,7 @@ describe("check --rule", () => { it("reports exactly what an unfiltered run reports for that rule", async () => { const everything = await check(); - const filtered = await check("--rule", "no-console-warn"); + const filtered = await check("--rule=no-console-warn"); expect(triples(filtered.results)).toEqual( triples( @@ -205,7 +199,7 @@ describe("check --rule", () => { }); it("keeps the exclusions a whole-project run applies", async () => { - const filtered = await check("--rule", "no-eval"); + const filtered = await check("--rule=no-eval"); // Not vacuous: the tracked copy of the same file still fires. expect(triples(filtered.results)).toEqual(["ast-grep no-eval sample.js"]); @@ -244,7 +238,7 @@ describe("check --rule", () => { it("refuses a filtered run exactly as the unfiltered run does", async () => { const everything = await check(); - const filtered = await check("--rule", "no-obviously"); + const filtered = await check("--rule=no-obviously"); // The unfiltered run is the reference: one rejected config refuses the // whole Vale engine, fail-closed, and nothing Vale would have found is @@ -273,7 +267,7 @@ describe("check --rule", () => { it("refuses even when the filter names no Vale rule at all", async () => { // The ast-grep selection is the only non-empty one here, so this is the // path where Vale assembly could most plausibly be skipped outright. - const filtered = await check("--rule", "no-eval"); + const filtered = await check("--rule=no-eval"); expect(filtered.success).toBe(false); expect(filtered.failures?.join("\n")).toContain("bad-rule"); @@ -284,7 +278,7 @@ describe("check --rule", () => { withVale("with the Vale binary available", () => { it("narrows a Vale run to the named rule", async () => { - const filtered = await check("--rule", "no-obviously"); + const filtered = await check("--rule=no-obviously"); expect(triples(filtered.results)).toEqual([ "vale no-obviously README.md", @@ -292,7 +286,7 @@ describe("check --rule", () => { }); it("unions repeated --rule across both engines", async () => { - const filtered = await check("--rule", "no-eval", "--rule", "no-simply"); + const filtered = await check("--rule=no-eval", "--rule=no-simply"); expect(triples(filtered.results)).toEqual([ "ast-grep no-eval sample.js", @@ -302,7 +296,7 @@ describe("check --rule", () => { it("matches the unfiltered run for a Vale rule, scope included", async () => { const everything = await check(); - const filtered = await check("--rule", "no-obviously"); + const filtered = await check("--rule=no-obviously"); // The equality that matters for Vale: each rule's own matchers are kept // verbatim in the filtered config, so removing the other rules cannot @@ -337,7 +331,7 @@ describe("check --rule", () => { // is exactly the case the per-rule check in `validate` exists to catch. // `check` still has to measure both, and `rules/rule-filter.ts` says so. // Do not "simplify" this back into the `beforeEach`. - await migrateFixture(["-d", project]); + await migrateFixture([`--dir=${project}`]); const valeRule = join(project, ".taskless/rules/vale/no-eval"); await mkdir(valeRule, { recursive: true }); @@ -359,7 +353,7 @@ describe("check --rule", () => { ) ); - const filtered = await check("--rule", "no-eval"); + const filtered = await check("--rule=no-eval"); expect(triples(filtered.results)).toEqual([ "ast-grep no-eval sample.js", @@ -373,7 +367,7 @@ describe("check --rule", () => { await writeFile(join(project, ".gitignore"), "ignored/\n"); await execFileAsync("git", ["init", "--quiet"], { cwd: project }); - const filtered = await check("--rule", "no-obviously"); + const filtered = await check("--rule=no-obviously"); expect(triples(filtered.results)).toEqual([ "vale no-obviously README.md", diff --git a/packages/cli/test/check.test.ts b/packages/cli/test/check.test.ts index 1683d5060..58af1626c 100644 --- a/packages/cli/test/check.test.ts +++ b/packages/cli/test/check.test.ts @@ -93,8 +93,7 @@ describe("check", () => { it("exits 0 with friendly message when .taskless/ does not exist", async () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(exitCode).toBe(0); expect(stdout).toContain("No rules configured"); @@ -108,7 +107,7 @@ describe("check", () => { it("does not scaffold .taskless/ in a project that has none", async () => { // `check` reads; it must not write a scaffold as a side effect of looking // for rules — which also keeps it working on a read-only checkout. - await runCli(["check", "-d", temporaryDirectory]); + await runCli(["check", `--dir=${temporaryDirectory}`]); await expect(stat(join(temporaryDirectory, ".taskless"))).rejects.toThrow(); }); @@ -120,8 +119,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(exitCode).toBe(0); expect(stdout).toContain("No rules configured"); @@ -146,7 +144,7 @@ describe("check", () => { ); await writeFile(join(temporaryDirectory, "doc.md"), "Just simply do it.\n"); - const { stdout } = await runCli(["check", "-d", temporaryDirectory]); + const { stdout } = await runCli(["check", `--dir=${temporaryDirectory}`]); expect(stdout).not.toContain("No rules configured"); }); @@ -156,8 +154,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(exitCode).toBe(1); // has error-severity match (no-eval) expect(stdout).toContain("no-eval"); @@ -171,8 +168,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", ]); expect(exitCode).toBe(1); @@ -226,7 +222,7 @@ describe("check", () => { 'console.warn("hello");\n' ); - const { exitCode } = await runCli(["check", "-d", temporaryDirectory]); + const { exitCode } = await runCli(["check", `--dir=${temporaryDirectory}`]); expect(exitCode).toBe(0); // warnings only → exit 0 }); @@ -235,7 +231,7 @@ describe("check", () => { await writeMixedSeverityProject(temporaryDirectory); const { stdout, exitCode } = await runCli( - ["check", "-d", temporaryDirectory], + ["check", `--dir=${temporaryDirectory}`], { CI: "true" } ); expect(exitCode).toBe(1); @@ -254,7 +250,7 @@ describe("check", () => { ); const { stdout, exitCode } = await runCli( - ["check", "-d", temporaryDirectory], + ["check", `--dir=${temporaryDirectory}`], { CI: "1" } ); expect(exitCode).toBe(0); @@ -266,7 +262,7 @@ describe("check", () => { await writeMixedSeverityProject(temporaryDirectory); const { stdout } = await runCli( - ["check", "-d", temporaryDirectory, "--include-warnings"], + ["check", `--dir=${temporaryDirectory}`, "--include-warnings"], { CI: "true" } ); expect(stdout).toContain("no-console-warn"); @@ -277,7 +273,7 @@ describe("check", () => { await writeMixedSeverityProject(temporaryDirectory); const { stdout } = await runCli( - ["check", "-d", temporaryDirectory, "--json"], + ["check", `--dir=${temporaryDirectory}`, "--json"], { CI: "true" } ); const output = JSON.parse(stdout) as { @@ -292,9 +288,12 @@ describe("check", () => { it("hides nothing when CI is not a claim of CI", async () => { await writeMixedSeverityProject(temporaryDirectory); - const { stdout } = await runCli(["check", "-d", temporaryDirectory], { - CI: "false", - }); + const { stdout } = await runCli( + ["check", `--dir=${temporaryDirectory}`], + { + CI: "false", + } + ); expect(stdout).toContain("no-console-warn"); }); }); @@ -305,8 +304,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", ]); expect(exitCode).toBe(1); @@ -343,8 +341,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "--summary", ]); @@ -361,8 +358,7 @@ describe("check", () => { it("carries an empty summary when no rules are configured", async () => { const { stdout } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "--summary", ]); @@ -377,8 +373,7 @@ describe("check", () => { const { stdout } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--summary", ]); expect(stdout).toContain("sg/no-console-error: 1 error across 1 file"); @@ -399,8 +394,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(exitCode).toBe(1); // has error-severity match (no-eval) expect(stdout).toContain("no-eval"); @@ -433,8 +427,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", ]); @@ -486,8 +479,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", ]); @@ -542,8 +534,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", positional, ]); @@ -573,8 +564,7 @@ describe("check", () => { const { stdout } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", ]); @@ -614,8 +604,7 @@ describe("check", () => { const { stdout } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", ".taskless", ]); @@ -638,8 +627,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "sample.js", ]); @@ -662,8 +650,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "sample.js", "deleted-in-diff.js", @@ -689,8 +676,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "missing-a.js", "missing-b.js", @@ -716,8 +702,7 @@ describe("check", () => { const { stderr, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "missing-a.js", ]); @@ -753,8 +738,7 @@ describe("check", () => { const outsidePath = pathOf(); const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", outsidePath, ]); @@ -775,8 +759,7 @@ describe("check", () => { const outsidePath = join(outsideDirectory, "bug.js"); const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "sample.js", outsidePath, @@ -791,8 +774,7 @@ describe("check", () => { const outsidePath = join(outsideDirectory, "bug.js"); const { stderr, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, outsidePath, ]); @@ -810,8 +792,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - realDirectory, + `--dir=${realDirectory}`, "--json", join(temporaryDirectory, "sample.js"), ]); @@ -831,8 +812,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", realSample, ]); @@ -853,8 +833,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", ]); @@ -879,8 +858,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "src", ]); @@ -909,8 +887,7 @@ describe("check", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "--", "-weird.js", diff --git a/packages/cli/test/cli-run.test.ts b/packages/cli/test/cli-run.test.ts index 5be1932a6..f4f42151f 100644 --- a/packages/cli/test/cli-run.test.ts +++ b/packages/cli/test/cli-run.test.ts @@ -9,12 +9,12 @@ describe("resolveCommandName", () => { [["check", "--json"], "check"], [["rule", "create"], "rule create"], [["rule"], "rule"], - [["feedback", "send", "--from", "req.json"], "feedback send"], + [["feedback", "send", "--from=req.json"], "feedback send"], [["feedback", "dismiss"], "feedback dismiss"], [["feedback"], "feedback"], [["agent", "route"], "agent"], - [["-d", "/tmp", "check"], "check"], - [["--dir", "/tmp", "info"], "info"], + [["--dir=/tmp", "check"], "check"], + [["--dir=/tmp", "info"], "info"], [[], "(default)"], ])("resolves %j to %s", (argv, expected) => { expect(resolveCommandName(argv)).toBe(expected); diff --git a/packages/cli/test/cli.test.ts b/packages/cli/test/cli.test.ts index cc2c0b9c1..918cf5f7b 100644 --- a/packages/cli/test/cli.test.ts +++ b/packages/cli/test/cli.test.ts @@ -61,10 +61,10 @@ describe("cli", () => { }); }); - // citty resolves a subcommand from the first token not starting with `-`, - // so before argv was joined, the path after `-d` was read as a command name - // and every parent with subcommands failed with "Unknown command". - describe("-d before a subcommand", () => { + // citty resolves a subcommand from the first token not starting with `-`. + // A directory carried inside `--dir=` is never that token, so every + // parent with subcommands still dispatches. + describe("--dir= before a subcommand", () => { let temporaryDirectory: string; beforeEach(async () => { @@ -80,41 +80,36 @@ describe("cli", () => { delete environment.TASKLESS_TOKEN; const { stdout } = await execFileAsync( "node", - [binPath, "auth", "-d", temporaryDirectory], + [binPath, "auth", `--dir=${temporaryDirectory}`], { env: environment } ); expect(stdout).toContain("Not logged in."); }); - it("dispatches the root's subcommand after -d", async () => { + it("dispatches the root's subcommand after --dir=", async () => { const { stdout } = await execFileAsync("node", [ binPath, - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "info", "--json", ]); expect(JSON.parse(stdout.trim())).toHaveProperty("version"); }); - // With no subcommand, `-d` alone still reaches the wizard / agent-index - // fallback rather than usage, in both spellings, once argv is joined. - it.each([["-d"], ["--dir="]])( - "routes a bare %s to the agent index when not a TTY", - async (flag) => { - const argv = - flag === "-d" - ? ["-d", temporaryDirectory] - : [`--dir=${temporaryDirectory}`]; - const { stderr } = await execFileAsync("node", [binPath, ...argv]); - expect(stderr).toContain("non-interactive context detected"); - } - ); + // With no subcommand, `--dir=` alone still reaches the wizard / + // agent-index fallback rather than usage. + it("routes a bare --dir= to the agent index when not a TTY", async () => { + const { stderr } = await execFileAsync("node", [ + binPath, + `--dir=${temporaryDirectory}`, + ]); + expect(stderr).toContain("non-interactive context detected"); + }); it("says CI is why a bare run skipped the wizard", async () => { const { stderr } = await execFileAsync( "node", - [binPath, "-d", temporaryDirectory], + [binPath, `--dir=${temporaryDirectory}`], { env: { ...process.env, CI: "true" } } ); expect(stderr).toContain("non-interactive context detected"); @@ -132,8 +127,7 @@ describe("cli", () => { ); const { stderr } = await execFileAsync("node", [ binPath, - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(stderr).toContain("run `./.taskless/bin/cli.mjs agent`"); expect(stderr).not.toMatch(/run `(?:npx|pnpm dlx|yarn dlx) \S+ agent`/); @@ -155,8 +149,7 @@ describe("cli", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(stdout).toContain("No tools detected. Using fallback: .agents/"); expect(stdout).toContain("Agent Skills (.agents/)"); @@ -168,8 +161,7 @@ describe("cli", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(stdout).toContain("Claude Code"); @@ -188,15 +180,18 @@ describe("cli", () => { await mkdir(join(temporaryDirectory, ".claude"), { recursive: true }); // Install first - await execFileAsync("node", [binPath, "init", "-d", temporaryDirectory]); + await execFileAsync("node", [ + binPath, + "init", + `--dir=${temporaryDirectory}`, + ]); // Check info const { stdout } = await execFileAsync("node", [ binPath, "info", "--json", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); const parsed = JSON.parse(stdout.trim()) as { version: string; diff --git a/packages/cli/test/detect.test.ts b/packages/cli/test/detect.test.ts index 101febbe3..875d36fc2 100644 --- a/packages/cli/test/detect.test.ts +++ b/packages/cli/test/detect.test.ts @@ -66,7 +66,7 @@ interface DetectJson { async function detect(cwd: string): Promise { const { stdout, exitCode } = await runCli( - ["detect", "--json", "-d", cwd], + ["detect", "--json", `--dir=${cwd}`], cwd ); expect(exitCode).toBe(0); diff --git a/packages/cli/test/engine-dispatch.test.ts b/packages/cli/test/engine-dispatch.test.ts index a8d4cfeb8..3285af084 100644 --- a/packages/cli/test/engine-dispatch.test.ts +++ b/packages/cli/test/engine-dispatch.test.ts @@ -592,8 +592,7 @@ describe("check dispatches by directory end to end", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", ]); const output = parseJson(stdout); @@ -618,7 +617,7 @@ describe("check dispatches by directory end to end", () => { ); await writeFile(join(legacy, "src.ts"), 'eval("danger");\n', "utf8"); - const { stdout } = await runCli(["check", "-d", legacy, "--json"]); + const { stdout } = await runCli(["check", `--dir=${legacy}`, "--json"]); expect(parseJson(stdout).results.map((r) => r.ruleId)).toEqual([ "no-eval", diff --git a/packages/cli/test/error-envelope.test.ts b/packages/cli/test/error-envelope.test.ts index 6052009de..29c0189f1 100644 --- a/packages/cli/test/error-envelope.test.ts +++ b/packages/cli/test/error-envelope.test.ts @@ -71,7 +71,7 @@ describe("standardized error envelope (--json)", () => { describe("rule create", () => { it("emits INVALID_INPUT when --from is missing", async () => { - const result = await runCli(["rule", "create", "--json", "-d", cwd]); + const result = await runCli(["rule", "create", "--json", `--dir=${cwd}`]); expect(result.exitCode).not.toBe(0); const env = parseEnvelope(result.stdout); expect(env.ok).toBe(false); @@ -83,11 +83,9 @@ describe("standardized error envelope (--json)", () => { const result = await runCli([ "rule", "create", - "--from", - "nonexistent.json", + "--from=nonexistent.json", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); const env = parseEnvelope(result.stdout); @@ -100,11 +98,9 @@ describe("standardized error envelope (--json)", () => { const result = await runCli([ "rule", "create", - "--from", - badFile, + `--from=${badFile}`, "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); const env = parseEnvelope(result.stdout); @@ -117,11 +113,9 @@ describe("standardized error envelope (--json)", () => { const result = await runCli([ "rule", "create", - "--from", - file, + `--from=${file}`, "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); const env = parseEnvelope(result.stdout); @@ -131,7 +125,12 @@ describe("standardized error envelope (--json)", () => { describe("rule improve", () => { it("emits INVALID_INPUT when --from is missing", async () => { - const result = await runCli(["rule", "improve", "--json", "-d", cwd]); + const result = await runCli([ + "rule", + "improve", + "--json", + `--dir=${cwd}`, + ]); expect(result.exitCode).not.toBe(0); const env = parseEnvelope(result.stdout); expect(env.code).toBe("INVALID_INPUT"); @@ -149,8 +148,7 @@ describe("standardized error envelope (--json)", () => { "meta", "nonexistent-rule", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); const env = parseEnvelope(result.stdout); @@ -171,8 +169,7 @@ describe("standardized error envelope (--json)", () => { "meta", "on-disk", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); const env = parseEnvelope(result.stdout); @@ -187,8 +184,7 @@ describe("standardized error envelope (--json)", () => { "delete", "nonexistent-rule", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); const env = parseEnvelope(result.stdout); @@ -208,8 +204,7 @@ describe("standardized error envelope (--json)", () => { "delete", "doomed", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).toBe(0); expect(result.stdout.trim()).toBe(""); @@ -233,8 +228,7 @@ describe("standardized error envelope (--json)", () => { "delete", "shared-id", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); @@ -255,8 +249,7 @@ describe("standardized error envelope (--json)", () => { "login", "--local", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); const env = parseEnvelope(result.stdout); @@ -267,7 +260,7 @@ describe("standardized error envelope (--json)", () => { describe("auth logout", () => { it("is silent on stdout in --json mode and exits 0", async () => { - const result = await runCli(["auth", "logout", "--json", "-d", cwd]); + const result = await runCli(["auth", "logout", "--json", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); expect(result.stdout.trim()).toBe(""); }); @@ -275,7 +268,7 @@ describe("standardized error envelope (--json)", () => { describe("envelope shape", () => { it("envelope has exactly the documented fields", async () => { - const result = await runCli(["rule", "create", "--json", "-d", cwd]); + const result = await runCli(["rule", "create", "--json", `--dir=${cwd}`]); const env = parseEnvelope(result.stdout); expect(Object.keys(env).toSorted()).toEqual(["code", "message", "ok"]); expect(env.ok).toBe(false); @@ -345,11 +338,9 @@ describe("resolveIdentity failure codes (--json)", () => { const result = await runCli([ "rule", "create", - "--from", - from, + `--from=${from}`, "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); expect(parseEnvelope(result.stdout).code).toBe("AUTH_REQUIRED"); @@ -360,11 +351,9 @@ describe("resolveIdentity failure codes (--json)", () => { const result = await runCli([ "rule", "improve", - "--from", - from, + `--from=${from}`, "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); expect(parseEnvelope(result.stdout).code).toBe("AUTH_REQUIRED"); @@ -375,7 +364,7 @@ describe("resolveIdentity failure codes (--json)", () => { it("emits NOT_A_GIT_REPOSITORY from rule create", async () => { const from = await writeCreateInput(); const result = await runCli( - ["rule", "create", "--from", from, "--json", "-d", cwd], + ["rule", "create", `--from=${from}`, "--json", `--dir=${cwd}`], withToken ); expect(result.exitCode).not.toBe(0); @@ -385,7 +374,7 @@ describe("resolveIdentity failure codes (--json)", () => { it("emits NOT_A_GIT_REPOSITORY from rule improve", async () => { const from = await writeImproveInput(); const result = await runCli( - ["rule", "improve", "--from", from, "--json", "-d", cwd], + ["rule", "improve", `--from=${from}`, "--json", `--dir=${cwd}`], withToken ); expect(result.exitCode).not.toBe(0); @@ -404,7 +393,7 @@ describe("resolveIdentity failure codes (--json)", () => { it("emits NO_ORIGIN_REMOTE from rule create", async () => { const from = await writeCreateInput(); const result = await runCli( - ["rule", "create", "--from", from, "--json", "-d", cwd], + ["rule", "create", `--from=${from}`, "--json", `--dir=${cwd}`], withToken ); expect(result.exitCode).not.toBe(0); @@ -414,7 +403,7 @@ describe("resolveIdentity failure codes (--json)", () => { it("emits NO_ORIGIN_REMOTE from rule improve", async () => { const from = await writeImproveInput(); const result = await runCli( - ["rule", "improve", "--from", from, "--json", "-d", cwd], + ["rule", "improve", `--from=${from}`, "--json", `--dir=${cwd}`], withToken ); expect(result.exitCode).not.toBe(0); @@ -429,7 +418,7 @@ describe("resolveIdentity failure codes (--json)", () => { ); const from = await writeCreateInput(); const result = await runCli( - ["rule", "create", "--from", from, "--json", "-d", cwd], + ["rule", "create", `--from=${from}`, "--json", `--dir=${cwd}`], withToken ); expect(result.exitCode).not.toBe(0); @@ -442,7 +431,7 @@ describe("resolveIdentity failure codes (--json)", () => { ); const from = await writeImproveInput(); const result = await runCli( - ["rule", "improve", "--from", from, "--json", "-d", cwd], + ["rule", "improve", `--from=${from}`, "--json", `--dir=${cwd}`], withToken ); expect(result.exitCode).not.toBe(0); @@ -456,7 +445,7 @@ describe("resolveIdentity failure codes (--json)", () => { // failure keeps its code even though its message names neither term, and // a no-remote failure keeps its code independently of its wording. const from = await writeCreateInput(); - const args = ["rule", "create", "--from", from, "--json", "-d", cwd]; + const args = ["rule", "create", `--from=${from}`, "--json", `--dir=${cwd}`]; const noTokenRun = await runCli(args); const noToken = parseEnvelope(noTokenRun.stdout); @@ -473,7 +462,7 @@ describe("resolveIdentity failure codes (--json)", () => { // credential problem. An agent that saw AUTH_REQUIRED here would send the // user through `auth login`, which cannot fix any of them. const from = await writeCreateInput(); - const args = ["rule", "create", "--from", from, "--json", "-d", cwd]; + const args = ["rule", "create", `--from=${from}`, "--json", `--dir=${cwd}`]; const notARepoRun = await runCli(args, withToken); const notARepo = parseEnvelope(notARepoRun.stdout); diff --git a/packages/cli/test/example-project.test.ts b/packages/cli/test/example-project.test.ts index 3954e0cdd..9cc4f9b07 100644 --- a/packages/cli/test/example-project.test.ts +++ b/packages/cli/test/example-project.test.ts @@ -75,7 +75,7 @@ interface RuleReport { withVale("the example project", () => { it("reports a finding from each engine", async () => { - const result = await runCli(["check", "-d", cwd, "--json"]); + const result = await runCli(["check", `--dir=${cwd}`, "--json"]); const output = parseJson(result.stdout); const byRule = new Map( @@ -90,7 +90,7 @@ withVale("the example project", () => { }); it("validates every rule in the example", async () => { - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); const report = parseJson(result.stdout); expect(report.rules.map((rule) => `${rule.engine}/${rule.ruleId}`)).toEqual( @@ -99,7 +99,7 @@ withVale("the example project", () => { }); it("passes the rules' own tests", async () => { - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); expect(parseJson(result.stdout).ok).toBe(true); }); @@ -110,8 +110,7 @@ withVale("the example project", () => { const result = await runCli([ "validate", ".taskless/rules/vale", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); expect(result.exitCode).toBe(0); @@ -121,7 +120,7 @@ withVale("the example project", () => { // The two assembled configs are build output. Finding either committed here // would mean the example is teaching people to check in generated files. it("commits no assembled config", async () => { - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); // The pathspec is relative to `cwd`, which is already `/example` — diff --git a/packages/cli/test/feedback-recipes.test.ts b/packages/cli/test/feedback-recipes.test.ts index 241d333b1..fa606b45f 100644 --- a/packages/cli/test/feedback-recipes.test.ts +++ b/packages/cli/test/feedback-recipes.test.ts @@ -49,8 +49,7 @@ describe("the rule-feedback recipe", () => { binPath, "agent", "rule-feedback", - "--section", - "input-schema", + "--section=input-schema", ]); expect(stdout.startsWith("# Topic: rule-feedback ")).toBe(true); // The schema is rendered from the Zod source, so the choices the agent diff --git a/packages/cli/test/help-flag.test.ts b/packages/cli/test/help-flag.test.ts index ea778fcef..6703bf8b4 100644 --- a/packages/cli/test/help-flag.test.ts +++ b/packages/cli/test/help-flag.test.ts @@ -5,11 +5,7 @@ import { join } from "node:path"; import { promisify } from "node:util"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { - hasHelpFlag, - joinDirectoryValues, - splitRawArguments, -} from "../src/util/argv"; +import { hasHelpFlag, splitRawArguments } from "../src/util/argv"; import { builtCli } from "./support/built-cli"; const execFileAsync = promisify(execFile); @@ -36,8 +32,7 @@ describe("--help below the root", () => { binPath, "init", flag, - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(stdout).toContain("USAGE"); @@ -61,11 +56,10 @@ describe("--help below the root", () => { expect(stdout).not.toContain("Remove saved authentication"); }); - it("treats the token after -d as a flag value, not a subcommand", async () => { + it("resolves the subcommand after --dir=", async () => { const { stdout } = await execFileAsync("node", [ binPath, - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "check", "--help", ]); @@ -83,8 +77,7 @@ describe("--help below the root", () => { const { stdout } = await execFileAsync("node", [ binPath, "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "--", "-h", @@ -117,12 +110,14 @@ describe("--help below the root", () => { }); describe("splitRawArguments", () => { - it("treats the token after -d/--dir as a value, not a positional", () => { - expect(splitRawArguments(["-d", "/tmp", "check"])).toEqual({ - positionals: ["check"], - flags: ["-d"], - values: [{ flag: "-d", value: "/tmp" }], - }); + it("never reads the token after a flag as its value", () => { + expect(splitRawArguments(["--dir=/tmp", "check", "--json", "src"])).toEqual( + { + positionals: ["check", "src"], + flags: ["--dir=/tmp", "--json"], + values: [{ flag: "--dir", value: "/tmp" }], + } + ); }); it("treats everything after -- as a positional", () => { @@ -133,29 +128,11 @@ describe("splitRawArguments", () => { }); }); - it("does not swallow -- as the value of -d", () => { - expect(splitRawArguments(["-d", "--", "src"])).toEqual({ - positionals: ["src"], - flags: ["-d", "--"], - values: [], - }); - }); - - it("accepts command-specific value flags", () => { - expect( - splitRawArguments(["check", "--timeout", "5", "src"], ["--timeout"]) - .positionals - ).toEqual(["check", "src"]); - }); - - it("reports a value-taking flag's value in both spellings", () => { + it("reports every value carried with =, in order", () => { // One pass answers both "which tokens are paths" and "what did this flag // get", so a caller that needs the second never writes a second scanner. expect( - splitRawArguments( - ["check", "--rule", "a", "--rule=b", "--dir=/tmp"], - ["--rule"] - ).values + splitRawArguments(["check", "--rule=a", "--rule=b", "--dir=/tmp"]).values ).toEqual([ { flag: "--rule", value: "a" }, { flag: "--rule", value: "b" }, @@ -163,56 +140,9 @@ describe("splitRawArguments", () => { ]); }); - it("does not report a value for a flag that takes none", () => { - expect(splitRawArguments(["check", "--json=yes"]).values).toEqual([]); - }); -}); - -describe("joinDirectoryValues", () => { - it.each([ - [ - ["auth", "-d", "."], - ["auth", "--dir=."], - ], - [ - ["-d", "/tmp", "info"], - ["--dir=/tmp", "info"], - ], - [ - ["auth", "--dir", "/tmp", "login"], - ["auth", "--dir=/tmp", "login"], - ], - [ - ["auth", "--dir=."], - ["auth", "--dir=."], - ], - ])("joins %j into %j", (argv, expected) => { - expect(joinDirectoryValues(argv)).toEqual(expected); - }); - - it("leaves a value that starts with - alone", () => { - expect(joinDirectoryValues(["auth", "-d", "--json"])).toEqual([ - "auth", - "-d", - "--json", - ]); - }); - - it("does not touch anything after --", () => { - expect(joinDirectoryValues(["check", "--", "-d", "src"])).toEqual([ - "check", - "--", - "-d", - "src", - ]); - }); - - it("does not join -- as the value of -d", () => { - expect(joinDirectoryValues(["check", "-d", "--", "src"])).toEqual([ - "check", - "-d", - "--", - "src", + it("keeps a value that begins with - inside its flag", () => { + expect(splitRawArguments(["check", "--rule=-odd-id"]).values).toEqual([ + { flag: "--rule", value: "-odd-id" }, ]); }); }); @@ -221,11 +151,11 @@ describe("hasHelpFlag", () => { it.each([ [["check", "--help"], true], [["auth", "login", "-h"], true], - [["-d", "/tmp", "check", "--help"], true], + [["--dir=/tmp", "check", "--help"], true], [["check"], false], // A path after `--`, and a directory that reads like a flag, are values. [["check", "--", "-h"], false], - [["-d", "-h", "check"], false], + [["--dir=-h", "check"], false], ])("resolves %j to %s", (argv, expected) => { expect(hasHelpFlag(argv)).toBe(expected); }); diff --git a/packages/cli/test/info-auth-state.test.ts b/packages/cli/test/info-auth-state.test.ts index 3bee05999..b681ca885 100644 --- a/packages/cli/test/info-auth-state.test.ts +++ b/packages/cli/test/info-auth-state.test.ts @@ -58,13 +58,13 @@ describe("info: auth state", () => { } async function infoJson(): Promise> { - await runCommand(infoCommand, { rawArgs: ["--json", "-d", cwd] }); + await runCommand(infoCommand, { rawArgs: ["--json", `--dir=${cwd}`] }); const line = logSpy.mock.calls.at(-1)?.[0]; return JSON.parse(String(line)) as Record; } async function infoHuman(): Promise { - await runCommand(infoCommand, { rawArgs: ["-d", cwd] }); + await runCommand(infoCommand, { rawArgs: [`--dir=${cwd}`] }); return logSpy.mock.calls.map((call) => String(call[0])).join("\n"); } @@ -141,7 +141,7 @@ describe("info: auth state", () => { it("reports --anonymous as anonymous, without calling the service", async () => { await runCommand(infoCommand, { - rawArgs: ["--json", "--anonymous", "-d", cwd], + rawArgs: ["--json", "--anonymous", `--dir=${cwd}`], }); const json = JSON.parse(String(logSpy.mock.calls.at(-1)?.[0])) as Record< string, diff --git a/packages/cli/test/info.test.ts b/packages/cli/test/info.test.ts index 8438399ff..6fc75a171 100644 --- a/packages/cli/test/info.test.ts +++ b/packages/cli/test/info.test.ts @@ -56,7 +56,7 @@ interface InfoJson { async function info(cwd: string): Promise { const { stdout, exitCode } = await runCli( - ["info", "--json", "--anonymous", "-d", cwd], + ["info", "--json", "--anonymous", `--dir=${cwd}`], cwd ); expect(exitCode).toBe(0); @@ -190,7 +190,10 @@ describe("taskless info --json", () => { }, ]); - const { stdout } = await runCli(["info", "--anonymous", "-d", cwd], cwd); + const { stdout } = await runCli( + ["info", "--anonymous", `--dir=${cwd}`], + cwd + ); expect(stdout).toContain( "packages/app/package.json devDependencies: @taskless/cli 0.0.1 -> remove the dependency" ); diff --git a/packages/cli/test/init-no-interactive.test.ts b/packages/cli/test/init-no-interactive.test.ts index d24f1d7c5..003dac2bb 100644 --- a/packages/cli/test/init-no-interactive.test.ts +++ b/packages/cli/test/init-no-interactive.test.ts @@ -30,7 +30,7 @@ async function exists(path: string): Promise { /** Run a real install in `cwd`, then rewrite the recorded version. */ async function installAtVersion(cwd: string, version: string): Promise { - await execFileAsync("node", [binPath, "init", "-d", cwd]); + await execFileAsync("node", [binPath, "init", `--dir=${cwd}`]); const manifestPath = join(cwd, ".taskless", "taskless.json"); const manifest = JSON.parse(await readFile(manifestPath, "utf8")) as { install?: { cliVersion?: string }; @@ -85,8 +85,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain("Claude Code (.claude/)"); @@ -100,8 +99,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain("No tools detected. Using fallback: .agents/"); @@ -116,8 +114,7 @@ describe("taskless init (the batch install)", () => { const { stdout, stderr } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); const combined = stdout + stderr; @@ -135,8 +132,7 @@ describe("taskless init (the batch install)", () => { const { stdout, stderr } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stderr).not.toContain("non-interactive"); @@ -152,8 +148,7 @@ describe("taskless init (the batch install)", () => { binPath, "init", "--no-interactive", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stderr).not.toContain("Unknown"); @@ -167,8 +162,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain("No tools detected. Using fallback: .agents/"); @@ -185,7 +179,7 @@ describe("taskless init (the batch install)", () => { // notice: the install would simply start happening again. await mkdir(join(cwd, ".claude"), { recursive: true }); - await execFileAsync("node", [binPath, "update", "-d", cwd]); + await execFileAsync("node", [binPath, "update", `--dir=${cwd}`]); expect( await exists(join(cwd, ".claude", "skills", "taskless", "SKILL.md")) @@ -195,7 +189,7 @@ describe("taskless init (the batch install)", () => { it("writes taskless.json with install state recorded", async () => { await mkdir(join(cwd, ".claude"), { recursive: true }); - await execFileAsync("node", [binPath, "init", "-d", cwd]); + await execFileAsync("node", [binPath, "init", `--dir=${cwd}`]); const manifest = JSON.parse( await readFile(join(cwd, ".taskless", "taskless.json"), "utf8") @@ -213,8 +207,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toMatch(/^Your AI tool has the Taskless skill now\. /m); @@ -229,8 +222,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).not.toContain("with no arguments"); @@ -241,8 +233,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toMatch(/^Your AI tool has the Taskless skill now\. /m); @@ -262,8 +253,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); // Forcing a rewrite: the recorded version moved, so the canonical store @@ -292,14 +282,13 @@ describe("taskless init (the batch install)", () => { await installAtVersion(cwd, "0.0.1-previous"); // Rewrite at the previous version so the next run sees no move but has // to re-write the stubs it finds stale. - await execFileAsync("node", [binPath, "init", "-d", cwd]); + await execFileAsync("node", [binPath, "init", `--dir=${cwd}`]); await mkdir(join(cwd, ".claude"), { recursive: true }); const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain("belong in your next commit"); @@ -311,13 +300,12 @@ describe("taskless init (the batch install)", () => { it("prints no upgrade trailer when a re-install changed nothing", async () => { // A no-op has nothing to commit and nothing to reconcile. A trailer that // said so would teach an agent to skim it. - await execFileAsync("node", [binPath, "init", "-d", cwd]); + await execFileAsync("node", [binPath, "init", `--dir=${cwd}`]); const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).not.toContain("next commit"); @@ -337,8 +325,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); const notice = boxedText(stdout); @@ -382,8 +369,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain( @@ -405,8 +391,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain("scripts.lint: @taskless/cli 0.0.1"); @@ -422,13 +407,12 @@ describe("taskless init (the batch install)", () => { join(cwd, "package.json"), JSON.stringify({ scripts: { lint: "npx @taskless/cli@^0.0.1 check" } }) ); - await execFileAsync("node", [binPath, "init", "-d", cwd]); + await execFileAsync("node", [binPath, "init", `--dir=${cwd}`]); const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).not.toContain("next commit"); @@ -443,8 +427,7 @@ describe("taskless init (the batch install)", () => { binPath, "init", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect( (JSON.parse(bare.stdout) as { pinnedCli: unknown }).pinnedCli @@ -458,8 +441,7 @@ describe("taskless init (the batch install)", () => { binPath, "init", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect( (JSON.parse(pinned.stdout) as { pinnedCli: unknown }).pinnedCli @@ -482,8 +464,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "update", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).not.toContain(ONBOARD_PROMPT); @@ -507,8 +488,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain(ONBOARD_PROMPT); @@ -532,7 +512,7 @@ describe("taskless init (the batch install)", () => { let home: string; // A home of its own, so the run never reads the real user settings. const run = (...args: string[]) => - execFileAsync("node", [binPath, "init", "-d", cwd, ...args], { + execFileAsync("node", [binPath, "init", `--dir=${cwd}`, ...args], { env: { ...process.env, HOME: home, CLAUDE_CONFIG_DIR: "" }, }); const userSettings = () => join(home, ".claude", "settings.json"); @@ -623,8 +603,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain("RESTART YOUR AGENTS"); @@ -637,8 +616,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).not.toContain("RESTART YOUR AGENTS"); @@ -647,13 +625,12 @@ describe("taskless init (the batch install)", () => { it("stays quiet when the recorded version did not move", async () => { // The re-run case. A banner here would appear on every ordinary install // and train people to scroll past it. - await execFileAsync("node", [binPath, "init", "-d", cwd]); + await execFileAsync("node", [binPath, "init", `--dir=${cwd}`]); const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).not.toContain("RESTART YOUR AGENTS"); @@ -670,8 +647,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain("COMMIT BEFORE YOU START YOUR AGENT"); @@ -687,7 +663,7 @@ describe("taskless init (the batch install)", () => { it("prints again when init edits a file that was committed", async () => { await git(cwd, "init", "-q"); - await execFileAsync("node", [binPath, "init", "-d", cwd]); + await execFileAsync("node", [binPath, "init", `--dir=${cwd}`]); await git(cwd, "add", "-A"); await git(cwd, "commit", "-q", "-m", "install"); await installAtVersion(cwd, "0.0.1-planted"); @@ -696,8 +672,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).toContain("COMMIT BEFORE YOU START YOUR AGENT"); @@ -705,15 +680,14 @@ describe("taskless init (the batch install)", () => { it("stays quiet once everything init wrote is committed", async () => { await git(cwd, "init", "-q"); - await execFileAsync("node", [binPath, "init", "-d", cwd]); + await execFileAsync("node", [binPath, "init", `--dir=${cwd}`]); await git(cwd, "add", "-A"); await git(cwd, "commit", "-q", "-m", "install"); const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).not.toContain("COMMIT BEFORE YOU START YOUR AGENT"); @@ -723,8 +697,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(stdout).not.toContain("COMMIT BEFORE YOU START YOUR AGENT"); @@ -736,8 +709,7 @@ describe("taskless init (the batch install)", () => { const { stdout } = await execFileAsync("node", [ binPath, "init", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); diff --git a/packages/cli/test/legacy-linter-vendor-contract.test.ts b/packages/cli/test/legacy-linter-vendor-contract.test.ts index 7d5b7db97..dc77ec0ff 100644 --- a/packages/cli/test/legacy-linter-vendor-contract.test.ts +++ b/packages/cli/test/legacy-linter-vendor-contract.test.ts @@ -105,15 +105,13 @@ describe.skipIf(!ENABLED)("legacy linter vendor contract", () => { describe("pylint", () => { it("does not know an extension's message until the extension is loaded", () => { const without = run("uvx", [ - "--from", - PYLINT, + `--from=${PYLINT}`, "pylint", "--help-msg=bad-builtin", ]); expect(without.output).toContain("No such message id or symbol"); const loaded = run("uvx", [ - "--from", - PYLINT, + `--from=${PYLINT}`, "pylint", "--load-plugins=pylint.extensions.bad_builtin", "--help-msg=bad-builtin", @@ -126,8 +124,7 @@ describe.skipIf(!ENABLED)("legacy linter vendor contract", () => { it("has the catch-all options the recipe names", () => { const { output } = run("uvx", [ - "--from", - PYLINT, + `--from=${PYLINT}`, "pylint", "--load-plugins=pylint.extensions.bad_builtin", "--help", @@ -150,8 +147,7 @@ describe.skipIf(!ENABLED)("legacy linter vendor contract", () => { "[flake8]\nbanned-modules =\n requests = Use the client.\n" ); const { output } = run("uvx", [ - "--from", - FLAKE8, + `--from=${FLAKE8}`, "--with", FLAKE8_TIDY_IMPORTS, "flake8", @@ -163,8 +159,7 @@ describe.skipIf(!ENABLED)("legacy linter vendor contract", () => { it("lists installed plugins as JSON with --bug-report", () => { const { status, stdout } = run("uvx", [ - "--from", - FLAKE8, + `--from=${FLAKE8}`, "flake8", "--bug-report", ]); diff --git a/packages/cli/test/local-flag.test.ts b/packages/cli/test/local-flag.test.ts index 2fb5ffc9f..a47635a04 100644 --- a/packages/cli/test/local-flag.test.ts +++ b/packages/cli/test/local-flag.test.ts @@ -50,7 +50,12 @@ describe("--local flag (per-command behavior matrix)", () => { describe("info --local", () => { it("skips the API/auth probe and reports loggedIn: false", async () => { - const result = await runCli(["info", "--local", "--json", "-d", cwd]); + const result = await runCli([ + "info", + "--local", + "--json", + `--dir=${cwd}`, + ]); expect(result.exitCode).toBe(0); const parsed = JSON.parse(result.stdout) as { loggedIn: boolean; @@ -64,7 +69,7 @@ describe("--local flag (per-command behavior matrix)", () => { describe("auth login --local", () => { it("rejects with exit 1 and 'auth commands cannot run in local mode'", async () => { - const result = await runCli(["auth", "login", "--local", "-d", cwd]); + const result = await runCli(["auth", "login", "--local", `--dir=${cwd}`]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("auth commands cannot run in local mode"); }); @@ -72,7 +77,12 @@ describe("--local flag (per-command behavior matrix)", () => { describe("auth logout --local", () => { it("accepts the flag as no-op (same behavior as plain logout)", async () => { - const result = await runCli(["auth", "logout", "--local", "-d", cwd]); + const result = await runCli([ + "auth", + "logout", + "--local", + `--dir=${cwd}`, + ]); expect(result.exitCode).toBe(0); // Either "Logged out." or "Not logged in." depending on initial state; // both are success. @@ -83,7 +93,7 @@ describe("--local flag (per-command behavior matrix)", () => { describe("check --local", () => { it("accepts the flag as no-op (same behavior as plain check)", async () => { // No .taskless/ directory → friendly "no rules" message, exit 0 - const result = await runCli(["check", "--local", "-d", cwd]); + const result = await runCli(["check", "--local", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("No rules configured"); }); @@ -93,7 +103,12 @@ describe("--local flag (per-command behavior matrix)", () => { it("exits with a pointer to the local-only recipe (does not run generation)", async () => { // No --from needed; the --local branch short-circuits before // file validation. - const result = await runCli(["rule", "create", "--local", "-d", cwd]); + const result = await runCli([ + "rule", + "create", + "--local", + `--dir=${cwd}`, + ]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toMatch( /`(?:npx|pnpm dlx) @taskless\/cli@\d[^\s`]* agent create-sg-rule`/ @@ -106,8 +121,7 @@ describe("--local flag (per-command behavior matrix)", () => { "create", "--local", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); const parsed = JSON.parse(result.stdout) as { ok: boolean; code: string }; @@ -118,7 +132,12 @@ describe("--local flag (per-command behavior matrix)", () => { describe("rule improve --local", () => { it("exits with a pointer to the local-only recipe", async () => { - const result = await runCli(["rule", "improve", "--local", "-d", cwd]); + const result = await runCli([ + "rule", + "improve", + "--local", + `--dir=${cwd}`, + ]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toMatch( /`(?:npx|pnpm dlx) @taskless\/cli@\d[^\s`]* agent improve-rule --local`/ @@ -134,8 +153,7 @@ describe("--local flag (per-command behavior matrix)", () => { "delete", "nonexistent", "--local", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("not found"); @@ -157,8 +175,7 @@ describe("--local flag (per-command behavior matrix)", () => { "nonexistent", "--local", "--json", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(result.exitCode).not.toBe(0); const parsed = JSON.parse(result.stdout) as { code: string }; @@ -168,7 +185,7 @@ describe("--local flag (per-command behavior matrix)", () => { describe("init --local", () => { it("accepts the flag as no-op", async () => { - const result = await runCli(["init", "--local", "-d", cwd]); + const result = await runCli(["init", "--local", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); }); }); @@ -191,7 +208,12 @@ describe("--anonymous stays an alias of --local", () => { }); it("info --anonymous skips the auth probe", async () => { - const result = await runCli(["info", "--anonymous", "--json", "-d", cwd]); + const result = await runCli([ + "info", + "--anonymous", + "--json", + `--dir=${cwd}`, + ]); expect(result.exitCode).toBe(0); const parsed = JSON.parse(result.stdout) as { loggedIn: boolean; @@ -200,19 +222,34 @@ describe("--anonymous stays an alias of --local", () => { }); it("auth login --anonymous is rejected like --local", async () => { - const result = await runCli(["auth", "login", "--anonymous", "-d", cwd]); + const result = await runCli([ + "auth", + "login", + "--anonymous", + `--dir=${cwd}`, + ]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("auth commands cannot run in local mode"); }); it("rule create --anonymous points at the local-only recipe", async () => { - const result = await runCli(["rule", "create", "--anonymous", "-d", cwd]); + const result = await runCli([ + "rule", + "create", + "--anonymous", + `--dir=${cwd}`, + ]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("agent create-sg-rule"); }); it("rule improve --anonymous points at the --local recipe", async () => { - const result = await runCli(["rule", "improve", "--anonymous", "-d", cwd]); + const result = await runCli([ + "rule", + "improve", + "--anonymous", + `--dir=${cwd}`, + ]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("agent improve-rule --local"); }); @@ -300,7 +337,14 @@ describe("local authoring needs no GitHub remote", () => { const from = join(cwd, "create.json"); await writeFile(from, JSON.stringify({ prompt: "no eval" })); const result = await runCli( - ["rule", "create", "--from", from, "--local", "--json", "-d", cwd], + [ + "rule", + "create", + `--from=${from}`, + "--local", + "--json", + `--dir=${cwd}`, + ], withToken ); expect(result.stdout + result.stderr).not.toMatch( @@ -309,14 +353,14 @@ describe("local authoring needs no GitHub remote", () => { }); it("validate runs to completion", async () => { - const result = await runCli(["validate", "-d", cwd], withToken); + const result = await runCli(["validate", `--dir=${cwd}`], withToken); expect(result.stdout + result.stderr).not.toMatch( /NOT_A_GIT_REPOSITORY|NO_ORIGIN_REMOTE|UNSUPPORTED_REMOTE_HOST|NO_GITHUB_REMOTE/ ); }); it("check runs to completion", async () => { - const result = await runCli(["check", "-d", cwd], withToken); + const result = await runCli(["check", `--dir=${cwd}`], withToken); expect(result.exitCode).toBe(0); expect(result.stdout + result.stderr).not.toMatch( /NOT_A_GIT_REPOSITORY|NO_ORIGIN_REMOTE|UNSUPPORTED_REMOTE_HOST|NO_GITHUB_REMOTE/ @@ -347,7 +391,7 @@ describe("info reports the repository context", () => { repositoryUrl: string | null; ghOwner: string; }> { - const result = await runCli(["info", "--json", "-d", cwd]); + const result = await runCli(["info", "--json", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); const parsed = JSON.parse(result.stdout) as { repositoryUrl: string | null; @@ -419,7 +463,7 @@ describe("info reports the repository context", () => { ], { cwd } ); - const result = await runCli(["info", "--local", "--json", "-d", cwd]); + const result = await runCli(["info", "--local", "--json", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); const info = JSON.parse(result.stdout) as { loggedIn: boolean; diff --git a/packages/cli/test/migrate-round-trip.test.ts b/packages/cli/test/migrate-round-trip.test.ts index 92079b460..109c06066 100644 --- a/packages/cli/test/migrate-round-trip.test.ts +++ b/packages/cli/test/migrate-round-trip.test.ts @@ -151,7 +151,7 @@ withVale("a version-4 project upgraded through 0005", () => { it("still reports a finding from each static engine", async () => { await seedVersion4Project(); - const result = await runCli(["check", "-d", cwd, "--json"]); + const result = await runCli(["check", `--dir=${cwd}`, "--json"]); const byRule = new Map( parseJson(result.stdout).results.map((finding) => [ finding.ruleId, @@ -168,7 +168,7 @@ withVale("a version-4 project upgraded through 0005", () => { it("retargets the Vale assignment from rules. to .", async () => { await seedVersion4Project(); - await runCli(["check", "-d", cwd, "--json"]); + await runCli(["check", `--dir=${cwd}`, "--json"]); const config = await readFile( join(tasklessDirectory, "rules", "vale", "no-simply", ".vale.ini"), @@ -184,7 +184,7 @@ withVale("a version-4 project upgraded through 0005", () => { it("still validates every migrated rule", async () => { await seedVersion4Project(); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); const report = parseJson(result.stdout); // Engine order follows the `ENGINES` declaration, not the alphabet. expect(report.rules.map((rule) => `${rule.engine}/${rule.ruleId}`)).toEqual( @@ -199,7 +199,7 @@ withVale("a version-4 project upgraded through 0005", () => { // The seed holds a runtime rule, which does not run without the flag, so // the run as a whole is incomplete (exit 2) rather than failed (exit 1). - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(2); const { rules } = parseJson(result.stdout); const statics = rules.filter((rule) => rule.engine !== "runtime"); @@ -221,7 +221,7 @@ withVale("a version-4 project upgraded through 0005", () => { ), }; - await runCli(["check", "-d", cwd, "--json"]); + await runCli(["check", `--dir=${cwd}`, "--json"]); const moved = join( tasklessDirectory, @@ -237,13 +237,13 @@ withVale("a version-4 project upgraded through 0005", () => { it("is a no-op the second time", async () => { await seedVersion4Project(); - await runCli(["check", "-d", cwd, "--json"]); + await runCli(["check", `--dir=${cwd}`, "--json"]); const first = await readFile( join(tasklessDirectory, "rules", "vale", "no-simply", ".vale.ini"), "utf8" ); - const second = await runCli(["check", "-d", cwd, "--json"]); + const second = await runCli(["check", `--dir=${cwd}`, "--json"]); expect(second.stdout).not.toContain("Migrating"); expect( await readFile( @@ -276,7 +276,7 @@ describe("a current-layout project with no taskless.json", () => { }); await writeFile(join(cwd, "app.ts"), "eval(raw);\n", "utf8"); - const result = await runCli(["check", "-d", cwd, "--json"]); + const result = await runCli(["check", `--dir=${cwd}`, "--json"]); expect( parseJson(result.stdout).results.map( @@ -303,7 +303,7 @@ describe("a current-layout project with no taskless.json", () => { }); await writeFile(join(cwd, "app.ts"), "eval(raw);\n", "utf8"); - const result = await runCli(["check", "-d", cwd, "--json"]); + const result = await runCli(["check", `--dir=${cwd}`, "--json"]); expect( parseJson(result.stdout).results.map( @@ -332,7 +332,7 @@ describe("a current-layout project with no taskless.json", () => { }); await writeFile(join(cwd, "app.ts"), "eval(raw);\ndebugger;\n", "utf8"); - const result = await runCli(["check", "-d", cwd, "--json"]); + const result = await runCli(["check", `--dir=${cwd}`, "--json"]); // Both survive: the already-partitioned rule stays put, the stray one is // relocated into the layout rather than left where 0005 refuses to run. @@ -345,7 +345,7 @@ describe("a current-layout project with no taskless.json", () => { ); expect(result.exitCode).toBe(1); - const verified = await runCli(["validate", "-d", cwd, "--json"]); + const verified = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect( parseJson(verified.stdout) .rules.map((rule) => `${rule.engine}/${rule.ruleId}`) @@ -361,9 +361,9 @@ describe("a current-layout project with no taskless.json", () => { "rules/runtime/.gitkeep": "", }); - await runCli(["check", "-d", cwd, "--json"]); + await runCli(["check", `--dir=${cwd}`, "--json"]); - const verified = await runCli(["validate", "-d", cwd, "--json"]); + const verified = await runCli(["validate", `--dir=${cwd}`, "--json"]); const report = parseJson(verified.stdout); expect(report.rules.map((rule) => `${rule.engine}/${rule.ruleId}`)).toEqual( ["sg/no-eval"] diff --git a/packages/cli/test/migrated-envelope.test.ts b/packages/cli/test/migrated-envelope.test.ts index f2dacec94..0bacbe247 100644 --- a/packages/cli/test/migrated-envelope.test.ts +++ b/packages/cli/test/migrated-envelope.test.ts @@ -120,8 +120,7 @@ describe("who migrates, and who refuses", () => { const { stdout } = await runCli([ "init", "--json", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); const envelope = parseEnvelope(stdout); @@ -141,8 +140,7 @@ describe("who migrates, and who refuses", () => { const { stderr } = await runCli([ "init", "--json", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(stderr).not.toContain("Migrat"); @@ -158,8 +156,7 @@ describe("who migrates, and who refuses", () => { const { stdout } = await runCli([ "init", "--json", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); const envelope = parseEnvelope(stdout) as { @@ -212,13 +209,12 @@ describe("who migrates, and who refuses", () => { it("init --json reports changed:false, a recorded version, and empty lists on a no-op re-install", async () => { await seedVersion3(); - await runCli(["init", "-d", temporaryDirectory]); + await runCli(["init", `--dir=${temporaryDirectory}`]); const { stdout } = await runCli([ "init", "--json", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); const envelope = parseEnvelope(stdout) as { @@ -238,13 +234,12 @@ describe("who migrates, and who refuses", () => { it("init --json omits the field when nothing migrated", async () => { // Absence is the signal, so a consumer never reads empty arrays to decide. await seedVersion3(); - await runCli(["init", "-d", temporaryDirectory]); + await runCli(["init", `--dir=${temporaryDirectory}`]); const { stdout } = await runCli([ "init", "--json", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(parseEnvelope(stdout)).not.toHaveProperty("migrated"); @@ -262,8 +257,7 @@ describe("who migrates, and who refuses", () => { const { stdout, stderr } = await runCli([ command, "--json", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); const output = `${stdout}${stderr}`; @@ -284,7 +278,7 @@ describe("who migrates, and who refuses", () => { it("names the versions and the files on human stderr", async () => { await seedVersion3(); - const { stderr } = await runCli(["init", "-d", temporaryDirectory]); + const { stderr } = await runCli(["init", `--dir=${temporaryDirectory}`]); const span = `from schema version ${String(SEEDED_FROM)} to ${String(LATEST_SCHEMA_VERSION)}`; expect(stderr).toContain(`Migrating .taskless/ ${span}`); @@ -295,9 +289,9 @@ describe("who migrates, and who refuses", () => { it("says nothing on stderr when the scaffold is already current", async () => { await seedVersion3(); - await runCli(["init", "-d", temporaryDirectory]); + await runCli(["init", `--dir=${temporaryDirectory}`]); - const { stderr } = await runCli(["init", "-d", temporaryDirectory]); + const { stderr } = await runCli(["init", `--dir=${temporaryDirectory}`]); expect(stderr).not.toContain("Migrat"); }); diff --git a/packages/cli/test/mixed-engine-check.test.ts b/packages/cli/test/mixed-engine-check.test.ts index adcad5720..57fba04ac 100644 --- a/packages/cli/test/mixed-engine-check.test.ts +++ b/packages/cli/test/mixed-engine-check.test.ts @@ -80,8 +80,7 @@ describe("check over a project with both engines", () => { it("reports findings from both engines in one run", async () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", ]); const output = JSON.parse(stdout.trim()) as CheckOutput; @@ -95,7 +94,7 @@ describe("check over a project with both engines", () => { }); it("attributes each finding to the engine and file it came from", async () => { - const { stdout } = await runCli(["check", "-d", project, "--json"]); + const { stdout } = await runCli(["check", `--dir=${project}`, "--json"]); const output = JSON.parse(stdout.trim()) as CheckOutput; const byRule = new Map(output.results.map((f) => [f.ruleId, f])); @@ -126,7 +125,7 @@ describe("check over a project with both engines", () => { it("strips Vale's styles prefix from the reported rule id", async () => { // Vale reports `rules.no-simply`, named for the styles directory. A user // authored `no-simply`, so that is what a finding has to say. - const { stdout } = await runCli(["check", "-d", project, "--json"]); + const { stdout } = await runCli(["check", `--dir=${project}`, "--json"]); const output = JSON.parse(stdout.trim()) as CheckOutput; const valeRules = output.results .filter((finding) => finding.source === "vale") @@ -139,7 +138,7 @@ describe("check over a project with both engines", () => { }); it("names both engines in human output", async () => { - const { stdout } = await runCli(["check", "-d", project]); + const { stdout } = await runCli(["check", `--dir=${project}`]); expect(stdout).toContain("no-eval"); expect(stdout).toContain("no-simply"); expect(stdout).toContain("sample.js"); @@ -152,8 +151,7 @@ describe("check over a project with both engines", () => { await rm(join(project, "sample.js")); const { stdout, exitCode } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", ]); const output = JSON.parse(stdout.trim()) as CheckOutput; @@ -171,8 +169,7 @@ describe("check over a project with both engines", () => { await rm(join(project, "README.md")); const { stdout, exitCode } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", ]); const output = JSON.parse(stdout.trim()) as CheckOutput; @@ -195,7 +192,7 @@ describe("check over a project with both engines", () => { "This readme simply describes things, and obviously so.\n" ); - const { stdout } = await runCli(["check", "-d", project, "--json"]); + const { stdout } = await runCli(["check", `--dir=${project}`, "--json"]); const output = JSON.parse(stdout.trim()) as CheckOutput; // Vale still ran — otherwise this passes for the wrong reason. @@ -221,8 +218,7 @@ describe("check over a project with both engines", () => { const { stdout } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", ".taskless/notes.md", ]); @@ -251,7 +247,7 @@ describe("check over a project with both engines", () => { // about. const scaffold = await mkdtemp(join(tmpdir(), "taskless-scaffold-")); try { - const init = await runCli(["init", "-d", scaffold]); + const init = await runCli(["init", `--dir=${scaffold}`]); expect(init.exitCode).toBe(0); // Author the rule the way a user would: one directory holding the @@ -274,7 +270,11 @@ describe("check over a project with both engines", () => { ); await writeFile(join(scaffold, "doc.md"), "Just simply do it.\n"); - const { stdout } = await runCli(["check", "-d", scaffold, "--json"]); + const { stdout } = await runCli([ + "check", + `--dir=${scaffold}`, + "--json", + ]); const output = JSON.parse(stdout.trim()) as CheckOutput; expect( @@ -309,7 +309,7 @@ describe("check over a project with both engines", () => { "no-simply.no-simply = YES\n[*.md]\ntskl) rule = no-simply\n" ); - const verified = await runCli(["validate", "-d", project, "--json"]); + const verified = await runCli(["validate", `--dir=${project}`, "--json"]); expect(verified.exitCode).not.toBe(0); const report = JSON.parse(verified.stdout) as { rules: { ruleId: string; violations: { constraintId: string }[] }[]; @@ -323,8 +323,7 @@ describe("check over a project with both engines", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", ]); const output = JSON.parse(stdout.trim()) as CheckOutput & { @@ -365,8 +364,7 @@ describe("check over a project with both engines", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", ]); const output = JSON.parse(stdout.trim()) as CheckOutput & { @@ -394,7 +392,7 @@ describe("check over a project with both engines", () => { "[*.md]\ntskl) rule = no-simply\nno-simply.no-simply = YES\n\n[.taskless/**]\ntskl) rule = no-simply\nno-simply.no-simply = NO\n" ); - const { stdout } = await runCli(["check", "-d", project, "--json"]); + const { stdout } = await runCli(["check", `--dir=${project}`, "--json"]); const output = JSON.parse(stdout.trim()) as CheckOutput & { failures?: string[]; notices?: string[]; @@ -416,7 +414,7 @@ describe("check over a project with both engines", () => { it("still reports every other file's findings, end to end", async () => { const scaffold = await mkdtemp(join(tmpdir(), "taskless-parse-error-")); try { - const init = await runCli(["init", "-d", scaffold]); + const init = await runCli(["init", `--dir=${scaffold}`]); expect(init.exitCode).toBe(0); const rule = join(scaffold, ".taskless", "rules", "vale", "no-simply"); @@ -448,8 +446,7 @@ describe("check over a project with both engines", () => { const { stdout, exitCode } = await runCli([ "check", "content/blog", - "-d", - scaffold, + `--dir=${scaffold}`, "--json", ]); const output = JSON.parse(stdout.trim()) as CheckOutput; @@ -490,8 +487,7 @@ describe("check over a project with both engines", () => { // error-severity code rule either way. const { stdout, exitCode } = await runCli([ "check", - "-d", - project, + `--dir=${project}`, "--json", ]); const output = JSON.parse(stdout.trim()) as CheckOutput; diff --git a/packages/cli/test/no-implicit-migration.test.ts b/packages/cli/test/no-implicit-migration.test.ts index 05fd34d91..18c3fefab 100644 --- a/packages/cli/test/no-implicit-migration.test.ts +++ b/packages/cli/test/no-implicit-migration.test.ts @@ -100,7 +100,7 @@ describe("a reporting command never migrates", () => { "%s leaves the working tree exactly as it found it", async (command) => { // The whole point. Not "it warns" — it must not have MOVED anything. - const { exitCode } = await runCli([command, "-d", directory]); + const { exitCode } = await runCli([command, `--dir=${directory}`]); expect(exitCode).toBe(1); const manifest = JSON.parse( @@ -119,7 +119,7 @@ describe("a reporting command never migrates", () => { "%s names the command that fixes it", async (command) => { // A refusal that does not say what to run is just a wall. - const { stderr } = await runCli([command, "-d", directory]); + const { stderr } = await runCli([command, `--dir=${directory}`]); expect(stderr).toContain("schema version 3"); expect(stderr).toContain(String(LATEST_SCHEMA_VERSION)); expect(stderr).toMatch(/init/); @@ -129,7 +129,11 @@ describe("a reporting command never migrates", () => { it.each(["check", "validate", "verify"] as const)( "%s --json carries the code an agent branches on", async (command) => { - const { stdout } = await runCli([command, "--json", "-d", directory]); + const { stdout } = await runCli([ + command, + "--json", + `--dir=${directory}`, + ]); const envelope = parseEnvelope<{ ok?: boolean; code?: string; @@ -158,8 +162,7 @@ describe("a reporting command never migrates", () => { const { stdout, stderr } = await runCli([ command, "--json", - "-d", - directory, + `--dir=${directory}`, ]); const output = `${stdout}${stderr}`; expect(output).toContain("SCAFFOLD_VERSION_MISMATCH"); @@ -178,8 +181,7 @@ describe("a reporting command never migrates", () => { const { stderr } = await runCli([ "check", - "-d", - directory, + `--dir=${directory}`, "--allow-version-mismatches", ]); expect(stderr).not.toContain("SCAFFOLD_VERSION_MISMATCH"); @@ -187,9 +189,9 @@ describe("a reporting command never migrates", () => { it("still runs against a project that is already current", async () => { // The refusal is about being BEHIND, not about having a scaffold. - await runCli(["init", "-d", directory]); + await runCli(["init", `--dir=${directory}`]); - const { stderr, exitCode } = await runCli(["check", "-d", directory]); + const { stderr, exitCode } = await runCli(["check", `--dir=${directory}`]); expect(stderr).not.toContain("schema version"); expect(exitCode).not.toBe(1); }); @@ -204,7 +206,7 @@ describe("a reporting command never migrates", () => { // this call lost its notice handler. const bare = await mkdtemp(join(tmpdir(), "tskl-bare-json-")); try { - const { stderr } = await runCli([command, "--json", "-d", bare]); + const { stderr } = await runCli([command, "--json", `--dir=${bare}`]); expect(stderr).not.toContain("Migrating .taskless/"); expect(stderr).not.toContain("Migrated .taskless/"); } finally { @@ -217,7 +219,7 @@ describe("a reporting command never migrates", () => { // the only thing telling someone their working tree just changed. const bare = await mkdtemp(join(tmpdir(), "tskl-bare-human-")); try { - const { stderr } = await runCli(["validate", "-d", bare]); + const { stderr } = await runCli(["validate", `--dir=${bare}`]); expect(stderr).toContain("Migrating .taskless/"); } finally { await rm(bare, { recursive: true, force: true }); @@ -229,7 +231,7 @@ describe("a reporting command never migrates", () => { // rules, which is its existing behaviour and not this error. const bare = await mkdtemp(join(tmpdir(), "tskl-bare-")); try { - const { stderr } = await runCli(["check", "-d", bare]); + const { stderr } = await runCli(["check", `--dir=${bare}`]); expect(stderr).not.toContain("schema version"); } finally { await rm(bare, { recursive: true, force: true }); @@ -239,7 +241,7 @@ describe("a reporting command never migrates", () => { it("migrates when asked, and reports what moved", async () => { // The other half of the trade: the migration still happens, on a command // whose job is to change the project. - const { stdout } = await runCli(["init", "--json", "-d", directory]); + const { stdout } = await runCli(["init", "--json", `--dir=${directory}`]); const envelope = parseEnvelope<{ migrated?: { from: number; to: number }; @@ -295,15 +297,14 @@ describe("onboard and report never migrate", () => { ["onboard", "--force"], ["onboard", "--mark-complete"], ["report"], - ["report", "--from", "facts.json"], - ["report", "--delete", "2026-10-13_142200.json"], + ["report", "--from=facts.json"], + ["report", "--delete=2026-10-13_142200.json"], ])( "%s %s refuses and leaves the working tree as it found it", async (...args) => { const { stdout, stderr, exitCode } = await runCli([ ...args, - "-d", - directory, + `--dir=${directory}`, ]); expect(exitCode).toBe(1); // Printed in prose too, so a recipe can branch on it without `--json`. @@ -319,8 +320,7 @@ describe("onboard and report never migrate", () => { const { stdout, exitCode } = await runCli([ "report", "--json", - "-d", - directory, + `--dir=${directory}`, ]); expect(exitCode).toBe(1); const envelope = parseEnvelope<{ ok?: boolean; code?: string }>(stdout); @@ -339,8 +339,7 @@ describe("onboard and report never migrate", () => { ); const { stdout, stderr, exitCode } = await runCli([ ...args, - "-d", - directory, + `--dir=${directory}`, ]); expect(exitCode).toBe(1); expect(`${stdout}${stderr}`).toContain("SCAFFOLD_VERSION_MISMATCH"); @@ -351,7 +350,7 @@ describe("onboard and report never migrate", () => { // Absent is not behind: creating a fresh directory is not a rewrite. const bare = await mkdtemp(join(tmpdir(), "tskl-bare-onboard-")); try { - const { stdout, exitCode } = await runCli(["onboard", "-d", bare]); + const { stdout, exitCode } = await runCli(["onboard", `--dir=${bare}`]); expect(exitCode).toBe(0); expect(stdout).not.toContain("SCAFFOLD_MIGRATION_REQUIRED"); const manifest = JSON.parse( @@ -369,8 +368,7 @@ describe("onboard and report never migrate", () => { const { stdout, stderr, exitCode } = await runCli([ "report", "--json", - "-d", - bare, + `--dir=${bare}`, ]); expect(exitCode).toBe(0); expect(stderr).not.toContain("Migrating .taskless/"); @@ -417,7 +415,11 @@ describe("a manifest that cannot be parsed", () => { it.each(["check", "validate", "verify"] as const)( "%s --json reports the file, not a version it guessed", async (command) => { - const { stdout } = await runCli([command, "--json", "-d", directory]); + const { stdout } = await runCli([ + command, + "--json", + `--dir=${directory}`, + ]); const envelope = parseEnvelope<{ ok?: boolean; code?: string; @@ -436,7 +438,7 @@ describe("a manifest that cannot be parsed", () => { ); it("check does not tell a person to run the command that would overwrite it", async () => { - const { stderr } = await runCli(["check", "-d", directory]); + const { stderr } = await runCli(["check", `--dir=${directory}`]); expect(stderr).toContain("could not be read"); // `init` may be NAMED, since the message explains that it refuses here too. // What it must never be is the remedy, and the remedy is the last line. @@ -444,7 +446,7 @@ describe("a manifest that cannot be parsed", () => { }); it("init refuses rather than rewriting what it could not parse", async () => { - const { exitCode } = await runCli(["init", "-d", directory]); + const { exitCode } = await runCli(["init", `--dir=${directory}`]); expect(exitCode).toBe(1); // Byte-for-byte. Measured before the fix, this file came back as @@ -459,7 +461,7 @@ describe("a manifest that cannot be parsed", () => { const bare = await mkdtemp(join(tmpdir(), "tskl-no-manifest-")); try { await mkdir(join(bare, ".taskless", "rules"), { recursive: true }); - const { stdout } = await runCli(["init", "--json", "-d", bare]); + const { stdout } = await runCli(["init", "--json", `--dir=${bare}`]); const envelope = parseEnvelope<{ migrated?: { from: number; to: number }; }>(stdout); diff --git a/packages/cli/test/onboard.test.ts b/packages/cli/test/onboard.test.ts index 1093267ae..541cca18a 100644 --- a/packages/cli/test/onboard.test.ts +++ b/packages/cli/test/onboard.test.ts @@ -93,7 +93,7 @@ describe("taskless onboard", () => { }); it("bootstraps .taskless/ and prints the recipe on first run", async () => { - const { stdout, exitCode } = await runCli(["onboard", "-d", cwd], cwd); + const { stdout, exitCode } = await runCli(["onboard", `--dir=${cwd}`], cwd); expect(exitCode).toBe(0); expect(stdout).toContain("# Topic: onboard"); @@ -118,7 +118,7 @@ describe("taskless onboard", () => { "utf8" ); - const { stdout, exitCode } = await runCli(["onboard", "-d", cwd], cwd); + const { stdout, exitCode } = await runCli(["onboard", `--dir=${cwd}`], cwd); expect(exitCode).toBe(0); expect(stdout).toContain("already marked complete"); @@ -139,7 +139,7 @@ describe("taskless onboard", () => { "utf8" ); - const { stdout, exitCode } = await runCli(["onboard", "-d", cwd], cwd); + const { stdout, exitCode } = await runCli(["onboard", `--dir=${cwd}`], cwd); expect(exitCode).toBe(0); expect(stdout).toContain("# Topic: onboard"); @@ -158,7 +158,7 @@ describe("taskless onboard", () => { ); const { stdout, exitCode } = await runCli( - ["onboard", "--force", "-d", cwd], + ["onboard", "--force", `--dir=${cwd}`], cwd ); @@ -186,7 +186,7 @@ describe("taskless onboard", () => { ); const { stdout, exitCode } = await runCli( - ["onboard", "--mark-complete", "-d", cwd], + ["onboard", "--mark-complete", `--dir=${cwd}`], cwd ); @@ -208,14 +208,20 @@ describe("taskless onboard", () => { }); it("--mark-complete is idempotent", async () => { - const first = await runCli(["onboard", "--mark-complete", "-d", cwd], cwd); + const first = await runCli( + ["onboard", "--mark-complete", `--dir=${cwd}`], + cwd + ); expect(first.exitCode).toBe(0); const afterFirst = await readFile( join(cwd, ".taskless", "taskless.json"), "utf8" ); - const second = await runCli(["onboard", "--mark-complete", "-d", cwd], cwd); + const second = await runCli( + ["onboard", "--mark-complete", `--dir=${cwd}`], + cwd + ); expect(second.exitCode).toBe(0); const afterSecond = await readFile( join(cwd, ".taskless", "taskless.json"), @@ -227,7 +233,7 @@ describe("taskless onboard", () => { it("rejects --force --mark-complete with exit 1 and a clear error", async () => { const { stderr, exitCode } = await runCli( - ["onboard", "--force", "--mark-complete", "-d", cwd], + ["onboard", "--force", "--mark-complete", `--dir=${cwd}`], cwd ); @@ -249,8 +255,8 @@ describe("taskless onboard", () => { "utf8" ); - const agentRecipe = await runCli(["agent", "onboard", "-d", cwd], cwd); - const onboard = await runCli(["onboard", "--force", "-d", cwd], cwd); + const agentRecipe = await runCli(["agent", "onboard", `--dir=${cwd}`], cwd); + const onboard = await runCli(["onboard", "--force", `--dir=${cwd}`], cwd); expect(agentRecipe.exitCode).toBe(0); expect(onboard.exitCode).toBe(0); @@ -292,7 +298,7 @@ describe("onboard renders a real invocation, not the agent-fill marker", () => { }); it("resolves the invocation when launched through npx", async () => { - const stdout = await runUnderNpx(["onboard", "-d", cwd]); + const stdout = await runUnderNpx(["onboard", `--dir=${cwd}`]); expect(stdout).toContain("npx @taskless/cli"); expect(stdout).not.toContain(""); @@ -301,8 +307,12 @@ describe("onboard renders a real invocation, not the agent-fill marker", () => { it("agrees with `agent onboard` under the same launcher", async () => { // The parity the bare-spawn test intends to assert, under an environment // where the two paths can actually disagree. - const viaOnboard = await runUnderNpx(["onboard", "--force", "-d", cwd]); - const viaAgent = await runUnderNpx(["agent", "onboard", "-d", cwd]); + const viaOnboard = await runUnderNpx([ + "onboard", + "--force", + `--dir=${cwd}`, + ]); + const viaAgent = await runUnderNpx(["agent", "onboard", `--dir=${cwd}`]); expect(viaOnboard.trim()).toBe(viaAgent.trim()); }); @@ -326,7 +336,7 @@ describe("onboard recipe establishes the routing surface first", () => { it("sends the agent to both `route` and `detect` before it proposes", async () => { const { stdout, exitCode } = await runCli( - ["agent", "onboard", "-d", cwd], + ["agent", "onboard", `--dir=${cwd}`], cwd ); @@ -339,7 +349,7 @@ describe("onboard recipe establishes the routing surface first", () => { // The ordering is the whole fix. A recipe that mentions `route` somewhere // is what shipped before; what matters is that it is read while the // candidates are still being decided. - const { stdout } = await runCli(["agent", "onboard", "-d", cwd], cwd); + const { stdout } = await runCli(["agent", "onboard", `--dir=${cwd}`], cwd); const routing = stdout.indexOf("Learn the routing surface"); const writing = stdout.indexOf("Write the rules"); @@ -353,7 +363,7 @@ describe("onboard recipe establishes the routing surface first", () => { // step 7 sends the agent to. it("carries the destination in the bullet format", async () => { const { stdout } = await runCli( - ["agent", "onboard", "--section", "choosing-candidates", "-d", cwd], + ["agent", "onboard", "--section=choosing-candidates", `--dir=${cwd}`], cwd ); @@ -369,7 +379,7 @@ describe("onboard recipe establishes the routing surface first", () => { // The whole recipe, so a destination table added to any section, on // request or not, is noticed. const { stdout } = await runCli( - ["agent", "onboard", "--full", "-d", cwd], + ["agent", "onboard", "--full", `--dir=${cwd}`], cwd ); @@ -395,13 +405,13 @@ describe("onboard recipe asks one question and finishes on its own", () => { beforeEach(async () => { cwd = await mkdtemp(join(tmpdir(), "taskless-onboard-v6-")); - ({ stdout } = await runCli(["agent", "onboard", "-d", cwd], cwd)); + ({ stdout } = await runCli(["agent", "onboard", `--dir=${cwd}`], cwd)); }); /** One section the outline serves on request (#672), without the preamble. */ async function section(name: string): Promise { const { stdout: text, exitCode } = await runCli( - ["agent", "onboard", "--section", name, "-d", cwd], + ["agent", "onboard", `--section=${name}`, `--dir=${cwd}`], cwd ); expect(exitCode).toBe(0); @@ -651,8 +661,8 @@ describe("the two serving paths agree in every host-tool state", () => { return stdout.trim(); }; return [ - await run(["onboard", "--force", "-d", cwd]), - await run(["agent", "onboard", "-d", cwd]), + await run(["onboard", "--force", `--dir=${cwd}`]), + await run(["agent", "onboard", `--dir=${cwd}`]), ]; } diff --git a/packages/cli/test/prompts.test.ts b/packages/cli/test/prompts.test.ts index 8e7b06183..7fe6aca5d 100644 --- a/packages/cli/test/prompts.test.ts +++ b/packages/cli/test/prompts.test.ts @@ -654,8 +654,7 @@ describe("agent command parity", () => { "agent", topic, "--full", - "-d", - emptyDirectory, + `--dir=${emptyDirectory}`, ]); // The command trims trailing whitespace before printing; console.log then // adds the single newline that stdout carries. It also asks for the @@ -762,10 +761,8 @@ describe("route's per-linter passage", () => { binPath, "agent", "route", - "--section", - "legacy-linters", - "-d", - directory, + "--section=legacy-linters", + `--dir=${directory}`, ]); expect(stdout).toContain("The linters `detect` found here"); expect(stdout).toContain("**Ruff**"); diff --git a/packages/cli/test/recipe-sections.test.ts b/packages/cli/test/recipe-sections.test.ts index d3f3e61d7..3976e34c7 100644 --- a/packages/cli/test/recipe-sections.test.ts +++ b/packages/cli/test/recipe-sections.test.ts @@ -343,8 +343,7 @@ describe("taskless agent --section", () => { binPath, "agent", ...args, - "-d", - cwd, + `--dir=${cwd}`, ]); return { stdout, stderr, exitCode: 0 }; } catch (error) { @@ -365,7 +364,7 @@ describe("taskless agent --section", () => { }); it("prints one section", async () => { - const result = await run(["create-sg-rule", "--section", "quirks"]); + const result = await run(["create-sg-rule", "--section=quirks"]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("# Topic: create-sg-rule"); expect(result.stdout).toContain("## Quirks"); @@ -373,19 +372,14 @@ describe("taskless agent --section", () => { }); it("refuses a section the topic does not have, and lists the ones it does", async () => { - const result = await run(["create-sg-rule", "--section", "nope"]); + const result = await run(["create-sg-rule", "--section=nope"]); expect(result.exitCode).toBe(1); expect(result.stderr).toContain("Unknown section for create-sg-rule: nope"); expect(result.stderr).toContain("quirks"); }); it("refuses --section together with --full", async () => { - const result = await run([ - "create-sg-rule", - "--section", - "quirks", - "--full", - ]); + const result = await run(["create-sg-rule", "--section=quirks", "--full"]); expect(result.exitCode).toBe(1); expect(result.stderr).toContain("--section and --full cannot be combined"); }); diff --git a/packages/cli/test/reconcile-marker.test.ts b/packages/cli/test/reconcile-marker.test.ts index 1e5527bba..e47e3ef70 100644 --- a/packages/cli/test/reconcile-marker.test.ts +++ b/packages/cli/test/reconcile-marker.test.ts @@ -43,7 +43,7 @@ async function runJson(args: string[]): Promise { async function ledgerSection( name: string ): Promise<{ stdout: string; stderr: string; exitCode: number }> { - const result = await runCli(["agent", "update", "--section", name]); + const result = await runCli(["agent", "update", `--section=${name}`]); expect(result.exitCode, result.stderr).toBe(0); return result; } @@ -113,13 +113,13 @@ describe("recording a rules reconciliation", () => { } async function installedVersion(): Promise { - const result = await runCli(["info", "--json", "-d", cwd]); + const result = await runCli(["info", "--json", `--dir=${cwd}`]); return (JSON.parse(result.stdout) as { version: string }).version; } it("records the version and the engines the rules are valid against", async () => { const version = await installedVersion(); - const result = await runCli(["update", "--rules", "-d", cwd]); + const result = await runCli(["update", "--rules", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); const rules = await readRules(); @@ -138,9 +138,9 @@ describe("recording a rules reconciliation", () => { it("reports the marker through info", async () => { const version = await installedVersion(); - await runCli(["update", "--rules", "-d", cwd]); + await runCli(["update", "--rules", `--dir=${cwd}`]); - const info = await runCli(["info", "--json", "-d", cwd]); + const info = await runCli(["info", "--json", `--dir=${cwd}`]); const parsed = JSON.parse(info.stdout) as { rules: { reconciledTo: string | null }; }; @@ -168,7 +168,7 @@ describe("recording a rules reconciliation", () => { }); it("check refuses rules behind the bundled engine until --rules runs", async () => { - const refused = await runCli(["check", "--json", "-d", cwd]); + const refused = await runCli(["check", "--json", `--dir=${cwd}`]); expect(refused.exitCode).not.toBe(0); const envelope = JSON.parse(refused.stdout) as { ok: boolean; @@ -189,19 +189,18 @@ describe("recording a rules reconciliation", () => { "check", "--json", "--allow-version-mismatches", - "-d", - cwd, + `--dir=${cwd}`, ]); expect(overridden.stdout).not.toContain("RULES_ENGINE_MISMATCH"); - const reconciled = await runCli(["update", "--rules", "-d", cwd]); + const reconciled = await runCli(["update", "--rules", `--dir=${cwd}`]); expect(reconciled.exitCode).toBe(0); - const after = await runCli(["check", "--json", "-d", cwd]); + const after = await runCli(["check", "--json", `--dir=${cwd}`]); expect(after.stdout).not.toContain("RULES_ENGINE_MISMATCH"); }); it("lists what --rules will rewrite before it runs", async () => { - const result = await runCli(["update", "--json", "-d", cwd]); + const result = await runCli(["update", "--json", `--dir=${cwd}`]); const payload = JSON.parse(result.stdout) as { ruleMigrations: { engine: string; engineVersion: string }[]; }; @@ -211,7 +210,12 @@ describe("recording a rules reconciliation", () => { }); it("rewrites the rules for the engines it crosses, then stamps", async () => { - const result = await runCli(["update", "--rules", "--json", "-d", cwd]); + const result = await runCli([ + "update", + "--rules", + "--json", + `--dir=${cwd}`, + ]); expect(result.exitCode).toBe(0); const payload = JSON.parse(result.stdout) as { migrated: { engineVersion: string; files: string[] }[]; @@ -232,14 +236,19 @@ describe("recording a rules reconciliation", () => { }); // Stamped, so the next run has nothing left to apply. - const again = await runCli(["update", "--rules", "--json", "-d", cwd]); + const again = await runCli([ + "update", + "--rules", + "--json", + `--dir=${cwd}`, + ]); expect( (JSON.parse(again.stdout) as { migrated: unknown[] }).migrated ).toEqual([]); }); it("names the rewritten files on the human path", async () => { - const result = await runCli(["update", "--rules", "-d", cwd]); + const result = await runCli(["update", "--rules", `--dir=${cwd}`]); expect(result.stdout).toContain("`type_synonym`"); expect(result.stdout).toContain(join("sg", "syn", "syn.yml")); }); @@ -253,7 +262,12 @@ describe("recording a rules reconciliation", () => { manifest["version"] = 1; await writeFile(manifestPath, JSON.stringify(manifest, undefined, 2)); - const result = await runCli(["update", "--rules", "--json", "-d", cwd]); + const result = await runCli([ + "update", + "--rules", + "--json", + `--dir=${cwd}`, + ]); expect(result.exitCode).not.toBe(0); expect((JSON.parse(result.stdout) as { code: string }).code).toBe( "SCAFFOLD_MIGRATION_REQUIRED" @@ -286,7 +300,12 @@ describe("recording a rules reconciliation", () => { }; await writeFile(manifestPath, JSON.stringify(manifest, undefined, 2)); - const result = await runCli(["update", "--rules", "--json", "-d", cwd]); + const result = await runCli([ + "update", + "--rules", + "--json", + `--dir=${cwd}`, + ]); expect(result.exitCode).toBe(0); const payload = JSON.parse(result.stdout) as { migrated: { engineVersion: string; files: string[] }[]; @@ -328,7 +347,12 @@ describe("recording a rules reconciliation", () => { // claiming work that could not have happened. const empty = await mkdtemp(join(tmpdir(), "taskless-noscaffold-")); try { - const result = await runCli(["update", "--rules", "--json", "-d", empty]); + const result = await runCli([ + "update", + "--rules", + "--json", + `--dir=${empty}`, + ]); expect(result.exitCode).not.toBe(0); const envelope = JSON.parse(result.stdout) as { code: string; @@ -352,14 +376,14 @@ describe("recording a rules reconciliation", () => { // // Stamping here would mark a project that has walked nothing as fully // reconciled and skip every ledger entry. - const before = await runCli(["update", "--json", "-d", cwd]); + const before = await runCli(["update", "--json", `--dir=${cwd}`]); expect( (JSON.parse(before.stdout) as { walk: unknown }).walk ).not.toBeNull(); - await runCli(["init", "-d", cwd]); + await runCli(["init", `--dir=${cwd}`]); - const after = await runCli(["update", "--json", "-d", cwd]); + const after = await runCli(["update", "--json", `--dir=${cwd}`]); const walk = ( JSON.parse(after.stdout) as { walk: { from: string } | null; @@ -381,7 +405,7 @@ describe("recording a rules reconciliation", () => { // The ledger is about rules already here, so there is nothing to owe. // The wizard left projects in this state, and `agent ok` then told a // person who had just installed that their rules were out of date. - await runCli(["init", "-d", cwd]); + await runCli(["init", `--dir=${cwd}`]); expect(await readRules()).toEqual({ reconciledTo: await installedVersion(), @@ -392,7 +416,7 @@ describe("recording a rules reconciliation", () => { it("moves forward with the CLI", async () => { await setMarker("0.11.0"); - await runCli(["init", "-d", cwd]); + await runCli(["init", `--dir=${cwd}`]); const rules = await readRules(); expect(rules?.["reconciledTo"]).toBe(await installedVersion()); @@ -413,7 +437,7 @@ describe("recording a rules reconciliation", () => { }; await writeFile(path, JSON.stringify(manifest, undefined, 2)); - await runCli(["init", "-d", cwd]); + await runCli(["init", `--dir=${cwd}`]); expect(await readRules()).toEqual({ reconciledTo: await installedVersion(), @@ -424,7 +448,7 @@ describe("recording a rules reconciliation", () => { it("keeps a marker a newer CLI wrote", async () => { await setMarker("999.0.0"); - await runCli(["init", "-d", cwd, "--allow-version-mismatches"]); + await runCli(["init", `--dir=${cwd}`, "--allow-version-mismatches"]); const rules = await readRules(); expect(rules?.["reconciledTo"]).toBe("999.0.0"); @@ -434,7 +458,7 @@ describe("recording a rules reconciliation", () => { const rule = join(cwd, ".taskless", "rules", "runtime", "some-rule"); await mkdir(rule, { recursive: true }); - await runCli(["init", "-d", cwd]); + await runCli(["init", `--dir=${cwd}`]); const rules = await readRules(); expect(rules?.["reconciledTo"]).toBeUndefined(); @@ -445,7 +469,7 @@ describe("recording a rules reconciliation", () => { // The recipe tells an agent to read `rules.walk` from `info --json`. It // has to actually be there, or the guidance sends it looking for a field // that does not exist and back to deriving the boundary by hand. - const result = await runCli(["info", "--json", "-d", cwd]); + const result = await runCli(["info", "--json", `--dir=${cwd}`]); const rules = ( JSON.parse(result.stdout) as { rules: { walk: { from: string } | null }; @@ -457,7 +481,7 @@ describe("recording a rules reconciliation", () => { it("reports a walk from the baseline when no marker is recorded", async () => { // The behaviour that reaches existing projects: absent means "predates // the ledger", so every entry still applies. - const result = await runCli(["update", "--json", "-d", cwd]); + const result = await runCli(["update", "--json", `--dir=${cwd}`]); const payload = JSON.parse(result.stdout) as { reconciledTo: string | null; walk: { from: string; to: string } | null; @@ -467,8 +491,8 @@ describe("recording a rules reconciliation", () => { }); it("has nothing to walk once the rules are stamped", async () => { - await runCli(["update", "--rules", "-d", cwd]); - const result = await runCli(["update", "--json", "-d", cwd]); + await runCli(["update", "--rules", `--dir=${cwd}`]); + const result = await runCli(["update", "--json", `--dir=${cwd}`]); const payload = JSON.parse(result.stdout) as { walk: unknown }; expect(payload.walk).toBeNull(); }); @@ -507,7 +531,7 @@ describe("recording a rules reconciliation", () => { }); it("reports a reconcile as required on info and update, with no walk", async () => { - const info = (await runJson(["info", "--json", "-d", cwd])) as { + const info = (await runJson(["info", "--json", `--dir=${cwd}`])) as { rules: { walk: unknown; reconcile: Reconcile }; }; expect(info.rules.walk).toBeNull(); @@ -516,7 +540,7 @@ describe("recording a rules reconciliation", () => { { engine: "sg", recorded: "0.45.3", bundled: AST_GREP_VERSION }, ]); - const update = (await runJson(["update", "--json", "-d", cwd])) as { + const update = (await runJson(["update", "--json", `--dir=${cwd}`])) as { walk: unknown; reconcile: Reconcile; }; @@ -534,7 +558,7 @@ describe("recording a rules reconciliation", () => { manifest.install["cliVersion"] = "0.0.1-previous"; await writeFile(manifestPath, JSON.stringify(manifest, undefined, 2)); - const human = await runCli(["init", "-d", cwd]); + const human = await runCli(["init", `--dir=${cwd}`]); expect(human.exitCode).toBe(0); expect(human.stdout).toContain("not reconciled to this CLI"); expect(human.stdout).toContain( @@ -548,18 +572,18 @@ describe("recording a rules reconciliation", () => { expect(human.stdout.match(/update`/g)).toHaveLength(1); // A re-run moves no version and still has to say it. - const rerun = await runCli(["init", "-d", cwd]); + const rerun = await runCli(["init", `--dir=${cwd}`]); expect(rerun.stdout).toContain("not reconciled to this CLI"); - const json = (await runJson(["init", "--json", "-d", cwd])) as { + const json = (await runJson(["init", "--json", `--dir=${cwd}`])) as { reconcile: Reconcile; }; expect(json.reconcile.required).toBe(true); // One shape across the three commands that report it. - const info = (await runJson(["info", "--json", "-d", cwd])) as { + const info = (await runJson(["info", "--json", `--dir=${cwd}`])) as { rules: { reconcile: Reconcile }; }; - const update = (await runJson(["update", "--json", "-d", cwd])) as { + const update = (await runJson(["update", "--json", `--dir=${cwd}`])) as { reconcile: Reconcile; }; expect(update.reconcile).toEqual(info.rules.reconcile); @@ -567,16 +591,16 @@ describe("recording a rules reconciliation", () => { }); it("clears once update --rules records the engines", async () => { - const reconciled = await runCli(["update", "--rules", "-d", cwd]); + const reconciled = await runCli(["update", "--rules", `--dir=${cwd}`]); expect(reconciled.exitCode).toBe(0); - const info = (await runJson(["info", "--json", "-d", cwd])) as { + const info = (await runJson(["info", "--json", `--dir=${cwd}`])) as { rules: { reconcile: Reconcile }; }; expect(info.rules.reconcile).toMatchObject({ required: false, engines: [], }); - const human = await runCli(["init", "-d", cwd]); + const human = await runCli(["init", `--dir=${cwd}`]); expect(human.stdout).not.toContain("not reconciled to this CLI"); }); }); @@ -618,7 +642,7 @@ describe("recording a rules reconciliation", () => { const ahead = [ { engine: "sg", recorded: "999.0.0", bundled: AST_GREP_VERSION }, ]; - const info = (await runJson(["info", "--json", "-d", cwd])) as { + const info = (await runJson(["info", "--json", `--dir=${cwd}`])) as { rules: { reconcile: Reconcile }; }; expect(info.rules.reconcile).toMatchObject({ @@ -626,19 +650,24 @@ describe("recording a rules reconciliation", () => { engines: [], enginesAhead: ahead, }); - const update = (await runJson(["update", "--json", "-d", cwd])) as { + const update = (await runJson(["update", "--json", `--dir=${cwd}`])) as { reconcile: Reconcile; }; expect(update.reconcile).toEqual(info.rules.reconcile); - const refused = await runCli(["check", "--json", "-d", cwd]); + const refused = await runCli(["check", "--json", `--dir=${cwd}`]); expect(refused.exitCode).not.toBe(0); expect(refused.stdout).toContain("RULES_ENGINE_MISMATCH"); }); it("refuses update --rules rather than move them backwards", async () => { const before = await readRules(); - const result = await runCli(["update", "--rules", "--json", "-d", cwd]); + const result = await runCli([ + "update", + "--rules", + "--json", + `--dir=${cwd}`, + ]); expect(result.exitCode).toBe(1); const envelope = JSON.parse(result.stdout) as { code: string; @@ -656,12 +685,12 @@ describe("recording a rules reconciliation", () => { recursive: true, force: true, }); - const info = (await runJson(["info", "--json", "-d", cwd])) as { + const info = (await runJson(["info", "--json", `--dir=${cwd}`])) as { rules: { reconcile: Reconcile }; }; expect(info.rules.reconcile.enginesAhead).toEqual([]); - const result = await runCli(["update", "--rules", "-d", cwd]); + const result = await runCli(["update", "--rules", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); }); }); @@ -670,7 +699,7 @@ describe("recording a rules reconciliation", () => { const before = JSON.parse( await readFile(join(cwd, ".taskless", "taskless.json"), "utf8") ) as { install?: unknown }; - await runCli(["update", "--rules", "-d", cwd]); + await runCli(["update", "--rules", `--dir=${cwd}`]); const after = JSON.parse( await readFile(join(cwd, ".taskless", "taskless.json"), "utf8") ) as { install?: unknown }; @@ -714,7 +743,7 @@ describe("taskless update with no flags", () => { join(cwd, ".taskless", "taskless.json"), '<<<<<<< HEAD\n{ "version": 6 }\n' ); - const result = await runCli(["update", "--json", "-d", cwd]); + const result = await runCli(["update", "--json", `--dir=${cwd}`]); expect(result.exitCode).toBe(1); expect(JSON.parse(result.stdout)).toMatchObject({ ok: false, @@ -728,7 +757,7 @@ describe("taskless update with no flags", () => { it("reports nothing due where there is no .taskless/", async () => { const cwd = await mkdtemp(join(tmpdir(), "taskless-empty-")); try { - const result = await runCli(["update", "--json", "-d", cwd]); + const result = await runCli(["update", "--json", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); const payload = JSON.parse(result.stdout) as { ok: boolean; diff --git a/packages/cli/test/reference-verify.test.ts b/packages/cli/test/reference-verify.test.ts index 26300c2e0..76908bc68 100644 --- a/packages/cli/test/reference-verify.test.ts +++ b/packages/cli/test/reference-verify.test.ts @@ -111,7 +111,7 @@ describe("the runtime reference rule", () => { it("fires on every fail case and stays quiet on every pass case", async () => { const rule = await referenceRule("runtime"); const cwd = stage(rule); - await execFileAsync("node", [builtCli(), "init", "-d", cwd]); + await execFileAsync("node", [builtCli(), "init", `--dir=${cwd}`]); // `verify` executes a runtime rule's check only under the flag. A failing // run exits non-zero, which `execFile` rejects with, so read the report @@ -120,8 +120,7 @@ describe("the runtime reference rule", () => { builtCli(), "verify", rule.directory, - "-d", - cwd, + `--dir=${cwd}`, "--json", "--dangerously-run-scripts", ]).catch((error: unknown) => error as { stdout: string }); diff --git a/packages/cli/test/report.test.ts b/packages/cli/test/report.test.ts index 7c341a19b..db8783769 100644 --- a/packages/cli/test/report.test.ts +++ b/packages/cli/test/report.test.ts @@ -1184,7 +1184,7 @@ describe("taskless report", () => { try { const { stdout, stderr } = await execFileAsync( "node", - [binPath, ...args, "-d", cwd], + [binPath, ...args, `--dir=${cwd}`], { env: { ...process.env, @@ -1304,7 +1304,7 @@ describe("taskless report", () => { ); const env = { TASKLESS_REPORT_URL: `${fake.url}/api/v1/reports` }; - const published = await run(["report", "--from", factsPath], env); + const published = await run(["report", `--from=${factsPath}`], env); expect(published.exitCode).toBe(0); expect(published.stdout).toContain("https://tskl.es/r/abc"); expect(published.stdout).toContain("can be deleted after review"); @@ -1324,7 +1324,7 @@ describe("taskless report", () => { ) as { deleteUrl: string }; expect(record.deleteUrl).toBe(deleteUrl); - const deleted = await run(["report", "--delete", records[0]!], env); + const deleted = await run(["report", `--delete=${records[0]!}`], env); expect(deleted.exitCode).toBe(0); expect(fake.requests.at(-1)).toMatchObject({ method: "DELETE", @@ -1375,7 +1375,10 @@ describe("taskless report", () => { await writeFile(join(directory, name), "{}\n", "utf8"); } - const published = await run(["report", "--from", factsPath, "--json"], env); + const published = await run( + ["report", `--from=${factsPath}`, "--json"], + env + ); expect(published.exitCode).toBe(0); const result = JSON.parse(published.stdout) as { record: string }; expect(result.record).toMatch(/_2\.json$/); @@ -1393,13 +1396,13 @@ describe("taskless report", () => { const directory = reportsDirectory(cwd); await chmod(directory, 0o555); try { - const human = await run(["report", "--from", factsPath], env); + const human = await run(["report", `--from=${factsPath}`], env); expect(human.exitCode).not.toBe(0); expect(human.stderr).toContain("REPORT_RECORD_FAILED"); expect(human.stderr).toContain("https://tskl.es/r/abc"); expect(human.stderr).toContain(deleteUrl); - const json = await run(["report", "--from", factsPath, "--json"], env); + const json = await run(["report", `--from=${factsPath}`, "--json"], env); expect(json.exitCode).not.toBe(0); expect(JSON.parse(json.stdout)).toMatchObject({ ok: false, @@ -1423,7 +1426,7 @@ describe("taskless report", () => { JSON.stringify(factsFor(["alpha", "beta"])), "utf8" ); - const { stderr, exitCode } = await run(["report", "--from", factsPath], { + const { stderr, exitCode } = await run(["report", `--from=${factsPath}`], { TASKLESS_REPORT_URL: "http://127.0.0.1:9/unreachable", }); expect(exitCode).not.toBe(0); @@ -1431,7 +1434,7 @@ describe("taskless report", () => { }); it("reports a missing record", async () => { - const { stderr, exitCode } = await run(["report", "--delete", "nope.json"]); + const { stderr, exitCode } = await run(["report", "--delete=nope.json"]); expect(exitCode).not.toBe(0); expect(stderr).toContain("REPORT_NOT_FOUND"); }); @@ -1442,7 +1445,7 @@ describe("taskless report", () => { "/tmp/outside.json", "notes.txt", ]) { - const { stderr, exitCode } = await run(["report", "--delete", record]); + const { stderr, exitCode } = await run(["report", `--delete=${record}`]); expect(exitCode, record).not.toBe(0); expect(stderr, record).toContain("INVALID_INPUT"); } @@ -1485,8 +1488,7 @@ describe("taskless report", () => { const { stdout, exitCode } = await run([ "agent", "report", - "--section", - "counting-evidence", + "--section=counting-evidence", ]); expect(exitCode).toBe(0); for (const kind of RULE_SOURCES) { @@ -1509,8 +1511,7 @@ describe("taskless report", () => { const { stdout, exitCode } = await run([ "agent", "report", - "--section", - "estimating-violations", + "--section=estimating-violations", ]); expect(exitCode).toBe(0); const flat = stdout.replaceAll(/\s+/g, " "); @@ -1548,10 +1549,8 @@ describe("taskless report", () => { it("refuses --from and --delete together", async () => { const { stderr, exitCode } = await run([ "report", - "--from", - "x.json", - "--delete", - "y.json", + "--from=x.json", + "--delete=y.json", ]); expect(exitCode).not.toBe(0); expect(stderr).toContain("INVALID_INPUT"); diff --git a/packages/cli/test/rule-commands-refuse-migration.test.ts b/packages/cli/test/rule-commands-refuse-migration.test.ts index 9e7c9813f..ad6aecbe4 100644 --- a/packages/cli/test/rule-commands-refuse-migration.test.ts +++ b/packages/cli/test/rule-commands-refuse-migration.test.ts @@ -34,8 +34,8 @@ const FLAT_RULE = "id: no-eval\nlanguage: TypeScript\nseverity: error\nmessage: no eval\nrule:\n pattern: eval($A)\n"; const COMMANDS: Record = { - create: ["rule", "create", "--from", "request.json"], - improve: ["rule", "improve", "--from", "request.json"], + create: ["rule", "create", "--from=request.json"], + improve: ["rule", "improve", "--from=request.json"], restore: ["rule", "restore", "no-eval"], rollback: ["rule", "rollback", "no-eval", "some-revision"], }; @@ -103,8 +103,7 @@ describe("rule-writing commands never migrate", () => { const { stdout, exitCode } = await runCli([ ...COMMANDS[name]!, "--json", - "-d", - directory, + `--dir=${directory}`, ]); expect(exitCode).toBe(1); const envelope = JSON.parse(stdout.trim()) as { @@ -133,8 +132,7 @@ describe("rule-writing commands never migrate", () => { await seedVersion(99); const { stdout, stderr, exitCode } = await runCli([ ...COMMANDS[name]!, - "-d", - directory, + `--dir=${directory}`, ]); expect(exitCode).toBe(1); expect(`${stdout}${stderr}`).toMatch(/Upgrade the CLI/); diff --git a/packages/cli/test/rule-create-entitlement.test.ts b/packages/cli/test/rule-create-entitlement.test.ts index ed2ad0410..073bd2ab8 100644 --- a/packages/cli/test/rule-create-entitlement.test.ts +++ b/packages/cli/test/rule-create-entitlement.test.ts @@ -136,7 +136,7 @@ describe("rule create/improve: a runtime rule the plan will not run", () => { const requestFile = join(cwd, "request.json"); await writeFile(requestFile, JSON.stringify({ prompt: "add a rule" })); await runCommand(ruleCommand, { - rawArgs: ["create", "--from", requestFile, "--json", "-d", cwd], + rawArgs: ["create", `--from=${requestFile}`, "--json", `--dir=${cwd}`], }); } @@ -167,7 +167,7 @@ describe("rule create/improve: a runtime rule the plan will not run", () => { JSON.stringify({ ruleId: "plan-runtime-rule", guidance: "tighten" }) ); await runCommand(ruleCommand, { - rawArgs: ["improve", "--from", requestFile, "--json", "-d", cwd], + rawArgs: ["improve", `--from=${requestFile}`, "--json", `--dir=${cwd}`], }); expect(planWarnings()).toHaveLength(1); }); @@ -347,7 +347,7 @@ describe("rule create/improve: a runtime rule the plan will not run", () => { ); await expect( runCommand(ruleCommand, { - rawArgs: ["improve", "--from", requestFile, "--json", "-d", cwd], + rawArgs: ["improve", `--from=${requestFile}`, "--json", `--dir=${cwd}`], }) ).rejects.toThrow(); const envelope = JSON.parse(String(logSpy.mock.calls.at(-1)?.[0])) as { diff --git a/packages/cli/test/rule-create-multi-rule.test.ts b/packages/cli/test/rule-create-multi-rule.test.ts index 7fe8df6eb..08eb46f83 100644 --- a/packages/cli/test/rule-create-multi-rule.test.ts +++ b/packages/cli/test/rule-create-multi-rule.test.ts @@ -174,7 +174,7 @@ describe("rule create: a request with several rules", () => { const requestFile = join(cwd, "request.json"); await writeFile(requestFile, JSON.stringify({ prompt: "add rules" })); await runCommand(ruleCommand, { - rawArgs: ["create", "--from", requestFile, "--json", "-d", cwd], + rawArgs: ["create", `--from=${requestFile}`, "--json", `--dir=${cwd}`], }); } diff --git a/packages/cli/test/rule-from.test.ts b/packages/cli/test/rule-from.test.ts index a9512b5ad..08813be6b 100644 --- a/packages/cli/test/rule-from.test.ts +++ b/packages/cli/test/rule-from.test.ts @@ -40,8 +40,7 @@ describe("rules create --from", () => { binPath, "rule", "create", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect.fail("should have exited with non-zero code"); } catch (error) { @@ -56,10 +55,8 @@ describe("rules create --from", () => { binPath, "rule", "create", - "--from", - "nonexistent.json", - "-d", - temporaryDirectory, + "--from=nonexistent.json", + `--dir=${temporaryDirectory}`, ]); expect.fail("should have exited with non-zero code"); } catch (error) { @@ -77,10 +74,8 @@ describe("rules create --from", () => { binPath, "rule", "create", - "--from", - badFile, - "-d", - temporaryDirectory, + `--from=${badFile}`, + `--dir=${temporaryDirectory}`, ]); expect.fail("should have exited with non-zero code"); } catch (error) { @@ -98,10 +93,8 @@ describe("rules create --from", () => { binPath, "rule", "create", - "--from", - noPromptFile, - "-d", - temporaryDirectory, + `--from=${noPromptFile}`, + `--dir=${temporaryDirectory}`, ]); expect.fail("should have exited with non-zero code"); } catch (error) { diff --git a/packages/cli/test/rule-guard-json-envelope.test.ts b/packages/cli/test/rule-guard-json-envelope.test.ts index 8359ddee9..b588f1308 100644 --- a/packages/cli/test/rule-guard-json-envelope.test.ts +++ b/packages/cli/test/rule-guard-json-envelope.test.ts @@ -131,7 +131,7 @@ describe("rule create/improve --json: a served rule that fails verification", () await writeFile(requestFile, JSON.stringify({ prompt: "add a rule" })); const runPromise = runCommand(ruleCommand, { - rawArgs: ["create", "--from", requestFile, "--json", "-d", cwd], + rawArgs: ["create", `--from=${requestFile}`, "--json", `--dir=${cwd}`], }); await expect(runPromise).rejects.toThrow(); @@ -157,7 +157,7 @@ describe("rule create/improve --json: a served rule that fails verification", () ); const runPromise = runCommand(ruleCommand, { - rawArgs: ["improve", "--from", requestFile, "--json", "-d", cwd], + rawArgs: ["improve", `--from=${requestFile}`, "--json", `--dir=${cwd}`], }); await expect(runPromise).rejects.toThrow(); diff --git a/packages/cli/test/rule-poll-transient.test.ts b/packages/cli/test/rule-poll-transient.test.ts index b31bd5b5f..19594e5bd 100644 --- a/packages/cli/test/rule-poll-transient.test.ts +++ b/packages/cli/test/rule-poll-transient.test.ts @@ -93,7 +93,7 @@ describe("rule create: transient failures while polling and fetching", () => { const requestFile = join(cwd, "request.json"); await writeFile(requestFile, JSON.stringify({ prompt: "add a rule" })); await runCommand(ruleCommand, { - rawArgs: ["create", "--from", requestFile, "--json", "-d", cwd], + rawArgs: ["create", `--from=${requestFile}`, "--json", `--dir=${cwd}`], }); } @@ -105,12 +105,10 @@ describe("rule create: transient failures while polling and fetching", () => { await runCommand(ruleCommand, { rawArgs: [ subcommand, - "--resume", - requestId, + `--resume=${requestId}`, ...extra, "--json", - "-d", - cwd, + `--dir=${cwd}`, ], }); } diff --git a/packages/cli/test/rule-recovery.test.ts b/packages/cli/test/rule-recovery.test.ts index 65bc1ce4a..b67fde823 100644 --- a/packages/cli/test/rule-recovery.test.ts +++ b/packages/cli/test/rule-recovery.test.ts @@ -235,7 +235,9 @@ describe("rule restore / rule rollback", () => { } async function run(argv: string[]): Promise> { - await runCommand(ruleCommand, { rawArgs: [...argv, "--json", "-d", cwd] }); + await runCommand(ruleCommand, { + rawArgs: [...argv, "--json", `--dir=${cwd}`], + }); return JSON.parse(String(logSpy.mock.calls.at(-1)?.[0])) as Record< string, unknown @@ -245,7 +247,7 @@ describe("rule restore / rule rollback", () => { /** Run without `--json`, returning what was printed to stdout. */ async function print(): Promise { await runCommand(ruleCommand, { - rawArgs: ["revisions", RULE_ID, "-d", cwd], + rawArgs: ["revisions", RULE_ID, `--dir=${cwd}`], }); return logSpy.mock.calls.map((call) => String(call[0])).join("\n"); } @@ -663,7 +665,9 @@ describe("rule restore / rule rollback", () => { verdict: { kind: "unsafe", expected: await canonicalHash(ISSUED) }, served: REFUSAL, }); - await runCommand(ruleCommand, { rawArgs: ["restore", RULE_ID, "-d", cwd] }); + await runCommand(ruleCommand, { + rawArgs: ["restore", RULE_ID, `--dir=${cwd}`], + }); const printed = errorSpy.mock.calls .map((call) => String(call[0])) .join("\n"); diff --git a/packages/cli/test/run-directory.test.ts b/packages/cli/test/run-directory.test.ts index 83e3eacf9..e179b2b17 100644 --- a/packages/cli/test/run-directory.test.ts +++ b/packages/cli/test/run-directory.test.ts @@ -386,7 +386,7 @@ describe("check and its run directory", () => { cwd = await mkdtemp(join(tmpdir(), "tskl-run-check-")); await cp(fixture, cwd, { recursive: true }); await execFileAsync("git", ["init", "-q"], { cwd }); - await migrateFixture(["-d", cwd]); + await migrateFixture([`--dir=${cwd}`]); }); afterEach(async () => { @@ -396,7 +396,7 @@ describe("check and its run directory", () => { async function check(...extra: string[]) { const { stdout } = await execFileAsync( "node", - [binPath, "check", "-d", cwd, "--json", ...extra], + [binPath, "check", `--dir=${cwd}`, "--json", ...extra], { env: { ...process.env, TASKLESS_TOKEN: "" } } ).catch((error: { stdout: string }) => ({ stdout: error.stdout })); const line = stdout diff --git a/packages/cli/test/runtime-check.test.ts b/packages/cli/test/runtime-check.test.ts index 67f99653a..c3f4f289d 100644 --- a/packages/cli/test/runtime-check.test.ts +++ b/packages/cli/test/runtime-check.test.ts @@ -316,8 +316,7 @@ describe("check: static vs runtime dispatch", () => { it("logged out: static runs, runtime is skipped and reported in --json", async () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - directory, + `--dir=${directory}`, "--json", ]); const output = parseJson(stdout); @@ -331,13 +330,13 @@ describe("check: static vs runtime dispatch", () => { }); it("logged out: skip notice on stderr, static findings on stdout", async () => { - const { stdout, stderr } = await runCli(["check", "-d", directory]); + const { stdout, stderr } = await runCli(["check", `--dir=${directory}`]); expect(stderr).toContain("was not run"); expect(stdout).toContain("no-console"); }); it("logged out: one notice says rules were not verified and names auth login", async () => { - const { stderr } = await runCli(["check", "-d", directory]); + const { stderr } = await runCli(["check", `--dir=${directory}`]); expect(stderr.split("Rules were not verified")).toHaveLength(2); expect(stderr).toContain( "Notice: Rules were not verified: not authenticated." @@ -353,7 +352,7 @@ describe("check: static vs runtime dispatch", () => { recursive: true, force: true, }); - const human = await runCli(["check", "-d", directory]); + const human = await runCli(["check", `--dir=${directory}`]); expect(human.stderr).toContain( "Notice: Rules were not verified: not authenticated. Static rules ran without verification." ); @@ -362,8 +361,7 @@ describe("check: static vs runtime dispatch", () => { const { stdout, exitCode } = await runCli([ "check", - "-d", - directory, + `--dir=${directory}`, "--json", ]); const output = parseJson(stdout); @@ -377,7 +375,7 @@ describe("check: static vs runtime dispatch", () => { it.each(["--local", "--anonymous"])( "%s: the notice names dropping --local, not auth login", async (flag) => { - const { stderr } = await runCli(["check", "-d", directory, flag]); + const { stderr } = await runCli(["check", `--dir=${directory}`, flag]); expect(stderr).toContain("Rules were not verified: `--local` was set."); expect(stderr).toContain("without `--local`"); expect(stderr).toContain("1 runtime rule(s) did not run"); @@ -390,14 +388,13 @@ describe("check: static vs runtime dispatch", () => { recursive: true, force: true, }); - const human = await runCli(["check", "-d", directory, "--local"]); + const human = await runCli(["check", `--dir=${directory}`, "--local"]); expect(human.stderr).not.toContain("Rules were not verified"); expect(human.stdout).toContain("no-console"); const { stdout, exitCode } = await runCli([ "check", - "-d", - directory, + `--dir=${directory}`, "--local", "--json", ]); @@ -445,11 +442,14 @@ describe("check: static vs runtime dispatch", () => { "authenticated with $name: the notice names that remote problem", async ({ arrange, cause, remedy }) => { await arrange(directory); - const { stderr, exitCode } = await runCli(["check", "-d", directory], { - TASKLESS_TOKEN: "fake.token", - // Never reached: the remote is resolved before any network call. - TASKLESS_API_URL: "http://127.0.0.1:9/cli", - }); + const { stderr, exitCode } = await runCli( + ["check", `--dir=${directory}`], + { + TASKLESS_TOKEN: "fake.token", + // Never reached: the remote is resolved before any network call. + TASKLESS_API_URL: "http://127.0.0.1:9/cli", + } + ); expect(exitCode).toBe(0); expect(stderr).toContain(`Rules were not verified: ${cause}.`); expect(stderr).toContain(remedy); @@ -465,7 +465,7 @@ describe("check: static vs runtime dispatch", () => { const server = await startMockServer(responder, whoami); try { const result = await runCli( - ["check", "-d", directory, ...extraArguments], + ["check", `--dir=${directory}`, ...extraArguments], { TASKLESS_TOKEN: "fake.token", TASKLESS_API_URL: server.apiUrl, @@ -478,7 +478,7 @@ describe("check: static vs runtime dispatch", () => { } it("reports every rule directory of every engine, files relative, fixtures excluded", async () => { - await migrateFixture(["-d", directory]); + await migrateFixture([`--dir=${directory}`]); const fixtures = join( directory, ".taskless", @@ -542,7 +542,7 @@ describe("check: static vs runtime dispatch", () => { }); it("an edited static rule does not run, fails the run, and names restore", async () => { - await migrateFixture(["-d", directory]); + await migrateFixture([`--dir=${directory}`]); const before = await treeDigest(directory); const { stdout, exitCode } = await authedCheck((request) => ({ statusCode: 200, @@ -690,7 +690,7 @@ describe("check: static vs runtime dispatch", () => { }); it("a renamed copy of an issued rule does not run, fails once as a rename, and logs it", async () => { - await migrateFixture(["-d", directory]); + await migrateFixture([`--dir=${directory}`]); const before = await treeDigest(directory); const copyOf = { ruleId: "no-console-3fa9c21b", @@ -783,7 +783,7 @@ describe("check: static vs runtime dispatch", () => { it("an id shared across engines stops the run before reconcile", async () => { const decoy = join(directory, ".taskless", "rules", "sg", "demo"); - await migrateFixture(["-d", directory]); + await migrateFixture([`--dir=${directory}`]); await mkdir(decoy, { recursive: true }); await writeFile( join(decoy, "demo.yml"), @@ -924,8 +924,7 @@ describe("check: static vs runtime dispatch", () => { it("--dangerously-run-scripts: runs runtime offline behind a warning", async () => { const { stdout, stderr } = await runCli([ "check", - "-d", - directory, + `--dir=${directory}`, "--dangerously-run-scripts", ]); const warningLines = stderr @@ -939,7 +938,7 @@ describe("check: static vs runtime dispatch", () => { }); it("a malformed runtime rule is reported and skipped, never fatal", async () => { - await migrateFixture(["-d", directory]); + await migrateFixture([`--dir=${directory}`]); const broken = join(directory, ".taskless", "rules", "runtime", "broken"); await mkdir(join(broken, "captures"), { recursive: true }); await writeFile( @@ -1000,7 +999,7 @@ describe("check: static vs runtime dispatch", () => { }); it("run and withheld together: the run rule executes and the run still fails", async () => { - await migrateFixture(["-d", directory]); + await migrateFixture([`--dir=${directory}`]); const other = join(directory, ".taskless", "rules", "runtime", "other"); await mkdir(join(other, "captures"), { recursive: true }); await writeFile( diff --git a/packages/cli/test/runtime-fixture-runner.test.ts b/packages/cli/test/runtime-fixture-runner.test.ts index ede24d6ed..d606eea70 100644 --- a/packages/cli/test/runtime-fixture-runner.test.ts +++ b/packages/cli/test/runtime-fixture-runner.test.ts @@ -171,8 +171,7 @@ async function testRule(...extra: string[]) { return runCli([ "verify", `.taskless/rules/runtime/${RULE}`, - "-d", - cwd, + `--dir=${cwd}`, ...extra, ]); } @@ -184,7 +183,7 @@ async function testRuleJson(...extra: string[]): Promise { beforeEach(async () => { cwd = await mkdtemp(join(tmpdir(), "tskl-rt-runner-")); - await runCli(["init", "-d", cwd]); + await runCli(["init", `--dir=${cwd}`]); }); afterEach(async () => { diff --git a/packages/cli/test/schemas-export.test.ts b/packages/cli/test/schemas-export.test.ts index 7114db649..5e06e118e 100644 --- a/packages/cli/test/schemas-export.test.ts +++ b/packages/cli/test/schemas-export.test.ts @@ -78,7 +78,7 @@ async function sgProbe(id: string): Promise { beforeEach(async () => { cwd = await mkdtemp(join(tmpdir(), "tskl-schemas-")); - await execFileAsync("node", [binPath, "init", "-d", cwd]); + await execFileAsync("node", [binPath, "init", `--dir=${cwd}`]); }); afterEach(async () => { @@ -102,8 +102,7 @@ describe("the published schemas entry", () => { const { stdout } = await execFileAsync("node", [ binPath, "validate", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); @@ -132,8 +131,7 @@ describe("the published schemas entry", () => { const { stdout } = await execFileAsync("node", [ binPath, "verify", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); @@ -163,15 +161,13 @@ describe("the published schemas entry", () => { const check = await execFileAsync("node", [ binPath, "check", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]).catch((error: unknown) => error as { stdout: string }); const verify = await execFileAsync("node", [ binPath, "verify", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); diff --git a/packages/cli/test/sg-engine-parse.test.ts b/packages/cli/test/sg-engine-parse.test.ts index 798fca2aa..6fd0052bd 100644 --- a/packages/cli/test/sg-engine-parse.test.ts +++ b/packages/cli/test/sg-engine-parse.test.ts @@ -39,7 +39,7 @@ interface Report { beforeEach(async () => { cwd = await mkdtemp(join(tmpdir(), "tskl-sg-parse-")); - await runCli(["init", "-d", cwd]); + await runCli(["init", `--dir=${cwd}`]); }); afterEach(async () => { @@ -85,7 +85,7 @@ const GOOD = const KEYWORD_KIND = "rule:\n kind: readonly\n"; async function report(command: string, path: string): Promise { - const result = await runCli([command, path, "-d", cwd, "--json"]); + const result = await runCli([command, path, `--dir=${cwd}`, "--json"]); return JSON.parse(result.stdout) as Report; } @@ -182,7 +182,7 @@ describe("verify judges an sg rule on its own fixtures", () => { const scratch = await mkdtemp(join(tmpdir(), "tskl-sg-tmp-")); try { const result = await runCli( - ["verify", ".taskless/rules/sg/good", "-d", cwd, "--json"], + ["verify", ".taskless/rules/sg/good", `--dir=${cwd}`, "--json"], { TMPDIR: scratch, TMP: scratch, TEMP: scratch } ); expect(result.exitCode).toBe(0); diff --git a/packages/cli/test/sg-fixtures.test.ts b/packages/cli/test/sg-fixtures.test.ts index 6cd8f450a..5b8910706 100644 --- a/packages/cli/test/sg-fixtures.test.ts +++ b/packages/cli/test/sg-fixtures.test.ts @@ -72,7 +72,7 @@ async function sgRule( beforeEach(async () => { cwd = await mkdtemp(join(tmpdir(), "tskl-sg-fixtures-")); - await runCli(["init", "-d", cwd]); + await runCli(["init", `--dir=${cwd}`]); }); afterEach(async () => { @@ -525,8 +525,7 @@ async function testSg(...extra: string[]) { return runCli([ "verify", `.taskless/rules/sg/${SG_RULE}`, - "-d", - cwd, + `--dir=${cwd}`, ...extra, ]); } @@ -635,8 +634,7 @@ describe("an ast-grep rule's fixture findings", () => { const { stdout } = await runCli([ "verify", ".taskless/rules/sg", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const report = JSON.parse(stdout) as Report; @@ -665,7 +663,7 @@ describe("an ast-grep rule's fixture findings", () => { try { await writeSwapRule(); const passing = await runCli( - ["verify", `.taskless/rules/sg/${SG_RULE}`, "-d", cwd, "--json"], + ["verify", `.taskless/rules/sg/${SG_RULE}`, `--dir=${cwd}`, "--json"], environment ); expect(passing.exitCode).toBe(0); @@ -673,7 +671,7 @@ describe("an ast-grep rule's fixture findings", () => { await writeSwapRule({ passFires: true }); const failing = await runCli( - ["verify", `.taskless/rules/sg/${SG_RULE}`, "-d", cwd, "--json"], + ["verify", `.taskless/rules/sg/${SG_RULE}`, `--dir=${cwd}`, "--json"], environment ); expect(failing.exitCode).toBe(1); diff --git a/packages/cli/test/support/current-project.ts b/packages/cli/test/support/current-project.ts index db66f7527..107a84154 100644 --- a/packages/cli/test/support/current-project.ts +++ b/packages/cli/test/support/current-project.ts @@ -22,8 +22,9 @@ import { ensureTasklessDirectory } from "../../src/filesystem/directory"; * break the several tests whose subject is a project that has none. */ export async function migrateFixture(args: string[]): Promise { - const index = args.indexOf("-d"); - const cwd = index === -1 ? undefined : args[index + 1]; + const cwd = args + .find((argument) => argument.startsWith("--dir=")) + ?.slice("--dir=".length); if (cwd === undefined) return; try { await stat(join(cwd, ".taskless")); diff --git a/packages/cli/test/vale-orchestration.test.ts b/packages/cli/test/vale-orchestration.test.ts index e305f1294..99c6376d0 100644 --- a/packages/cli/test/vale-orchestration.test.ts +++ b/packages/cli/test/vale-orchestration.test.ts @@ -520,7 +520,11 @@ describe("an engine failure under --json", () => { "id: broken\nlanguage: javascript\nrule:\n bogusKey: nope\n" ); - const { stdout, exitCode } = await runCli(["check", "-d", cwd, "--json"]); + const { stdout, exitCode } = await runCli([ + "check", + `--dir=${cwd}`, + "--json", + ]); const output = parseJson(stdout); expect(exitCode).toBe(1); @@ -532,7 +536,12 @@ describe("an engine failure under --json", () => { it("omits failures, and carries no engine notice, when nothing failed", async () => { const cwd = makeMixedProject({ valeRules: false }); - const { stdout } = await runCli(["check", "-d", cwd, "doc.md", "--json"]); + const { stdout } = await runCli([ + "check", + `--dir=${cwd}`, + "doc.md", + "--json", + ]); const output = parseJson(stdout); expect(output.success).toBe(true); @@ -568,7 +577,7 @@ withVale("a repository containing a converter-dependent file", () => { mkdirSync(join(cwd, "docs"), { recursive: true }); writeFileSync(join(cwd, "docs", "api.xml"), "simply\n"); - const { stdout } = await runCli(["check", "-d", cwd, "--json"]); + const { stdout } = await runCli(["check", `--dir=${cwd}`, "--json"]); const output = parseJson(stdout); // The findings survive... @@ -641,7 +650,7 @@ function makeTwoAdvisoryProject(): string { describe("check renders one marker per notice", () => { it("gives each advisory its own Notice: line in text output", async () => { const cwd = makeTwoAdvisoryProject(); - const { stderr } = await runCli(["check", "-d", cwd]); + const { stderr } = await runCli(["check", `--dir=${cwd}`]); const advisoryLines = stderr .split("\n") @@ -659,7 +668,7 @@ describe("check renders one marker per notice", () => { it("publishes them as separate --json elements, none spanning lines", async () => { const cwd = makeTwoAdvisoryProject(); - const { stdout } = await runCli(["check", "-d", cwd, "--json"]); + const { stdout } = await runCli(["check", `--dir=${cwd}`, "--json"]); const notices = parseJson(stdout).notices ?? []; expect(notices.filter((notice) => notice.includes("assigns"))).toHaveLength( diff --git a/packages/cli/test/validate-verify-commands.test.ts b/packages/cli/test/validate-verify-commands.test.ts index 1473fcb83..6932a3ef5 100644 --- a/packages/cli/test/validate-verify-commands.test.ts +++ b/packages/cli/test/validate-verify-commands.test.ts @@ -50,7 +50,7 @@ interface Report { beforeEach(async () => { cwd = await mkdtemp(join(tmpdir(), "tskl-verify-cmd-")); - await runCli(["init", "-d", cwd]); + await runCli(["init", `--dir=${cwd}`]); }); afterEach(async () => { @@ -118,8 +118,7 @@ describe("validate addresses rules by path", () => { const result = await runCli([ "validate", ".taskless/rules/vale/no-simply", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const report = JSON.parse(result.stdout) as Report; @@ -142,15 +141,14 @@ describe("validate addresses rules by path", () => { const valeResult = await runCli([ "validate", ".taskless/rules/vale/shared", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const vale = JSON.parse(valeResult.stdout) as Report; expect(vale.rules).toHaveLength(1); expect(vale.rules[0]?.engine).toBe("vale"); - const bothResult = await runCli(["validate", "-d", cwd, "--json"]); + const bothResult = await runCli(["validate", `--dir=${cwd}`, "--json"]); const both = JSON.parse(bothResult.stdout) as Report; expect(both.rules.map((rule) => rule.engine).toSorted()).toEqual([ "sg", @@ -159,7 +157,7 @@ describe("validate addresses rules by path", () => { }); it("rejects a path outside the rules tree by name", async () => { - const result = await runCli(["validate", "src", "-d", cwd]); + const result = await runCli(["validate", "src", `--dir=${cwd}`]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("not inside .taskless/rules/"); }); @@ -167,7 +165,7 @@ describe("validate addresses rules by path", () => { // A fresh install has no rules. Failing here would make `validate` unusable in // CI until someone writes the first one. it("succeeds with no rules present", async () => { - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); expect((JSON.parse(result.stdout) as Report).rules).toEqual([]); }); @@ -176,7 +174,7 @@ describe("validate addresses rules by path", () => { describe("validate checks components without requiring tests", () => { it("passes a rule that has no fixtures yet", async () => { await valeRule("no-simply", { config: SCOPED }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); }); @@ -184,7 +182,7 @@ describe("validate checks components without requiring tests", () => { // reports nothing. That is the silent disable the layout exists to prevent. it("fails a Vale rule that nothing scopes", async () => { await valeRule("no-simply"); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const report = JSON.parse(result.stdout) as Report; expect(report.rules[0]?.errors.join(" ")).toContain("never run"); @@ -194,7 +192,7 @@ describe("validate checks components without requiring tests", () => { await valeRule("no-simply", { config: "[*.md]\ntskl) rule = no-simply\n", }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const rule = (JSON.parse(result.stdout) as Report).rules[0]; expect(rule?.errors.join(" ")).toContain("present but off"); @@ -211,7 +209,7 @@ describe("validate checks components without requiring tests", () => { await valeRule("no-simply", { config: `${SCOPED}no-hedging.no-hedging = NO\n`, }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const rule = (JSON.parse(result.stdout) as Report).rules[0]; expect(rule?.violations).toHaveLength(1); @@ -231,7 +229,7 @@ describe("validate checks components without requiring tests", () => { "[docs/**]\ntskl) rule = no-simply\nno-simply.no-simply = YES\n\n" + `${SCOPED}no-simply.no-simply = NO\n`, }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); const rule = (JSON.parse(result.stdout) as Report).rules[0]; expect(rule?.ok).toBe(true); @@ -261,7 +259,7 @@ describe("validate checks components without requiring tests", () => { ); await mkdir(grammars, { recursive: true }); if (populated) await writeFile(join(grammars, "go.wasm"), "\0asm"); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const rule = (JSON.parse(result.stdout) as Report).rules.find( (entry) => entry.ruleId === "no-simply" @@ -283,7 +281,7 @@ describe("validate checks components without requiring tests", () => { await mkdir(join(cwd, ".taskless", "rules", "vale", "config", "grammars"), { recursive: true, }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const violations = (JSON.parse(result.stdout) as Report).rules.flatMap( (rule) => rule.violations.map((violation) => violation.constraintId) @@ -302,7 +300,7 @@ describe("validate checks components without requiring tests", () => { 'extends: existence\nmessage: "Avoid the twist"\nlevel: warning\nraw:\n' + ' - "\\\\bstops being\\\\b"\n - "\\\\band becomes\\\\b"\n', }); - const json = await runCli(["validate", "-d", cwd, "--json"]); + const json = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(json.exitCode).toBe(0); const rule = (JSON.parse(json.stdout) as Report).rules[0]; expect(rule?.ok).toBe(true); @@ -311,7 +309,7 @@ describe("validate checks components without requiring tests", () => { "no-twist: raw has 2 entries; Vale joins them into one pattern with no separator, so the second never matches on its own. Write one entry with (a|b) unless the join is intended.", ]); - const text = await runCli(["validate", "-d", cwd]); + const text = await runCli(["validate", `--dir=${cwd}`]); expect(text.exitCode).toBe(0); expect(text.stdout).toContain("notice: no-twist: raw has 2 entries"); }); @@ -323,13 +321,13 @@ describe("validate checks components without requiring tests", () => { 'extends: existence\nmessage: "Avoid the twist"\nlevel: warning\nraw:\n' + ' - "(\\\\bstops being\\\\b|\\\\band becomes\\\\b)"\n', }); - const json = await runCli(["validate", "-d", cwd, "--json"]); + const json = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(json.exitCode).toBe(0); const rule = (JSON.parse(json.stdout) as Report).rules[0]; expect(rule?.ok).toBe(true); expect(rule?.notices).toEqual([]); - const text = await runCli(["validate", "-d", cwd]); + const text = await runCli(["validate", `--dir=${cwd}`]); expect(text.stdout).not.toContain("notice:"); }); @@ -342,7 +340,7 @@ describe("validate checks components without requiring tests", () => { 'extends: existence\nmessage: "Avoid the twist"\nlevel: warning\nraw:\n' + " - a\n - b\n", }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); const rule = (JSON.parse(result.stdout) as Report).rules[0]; // Two elements, not one string a consumer has to split on a separator @@ -358,7 +356,7 @@ describe("validate checks components without requiring tests", () => { // Text mode prefixes every line, so the second advisory is labelled too // rather than trailing the first as an unindented stray. - const text = await runCli(["validate", "-d", cwd]); + const text = await runCli(["validate", `--dir=${cwd}`]); const noticeLines = text.stdout .split("\n") .filter((line) => line.startsWith(" notice: ")); @@ -373,7 +371,7 @@ describe("validate checks components without requiring tests", () => { await valeRule("no-simply", { config: `${SCOPED}no-simply.no-simply = NO\n`, }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const rule = (JSON.parse(result.stdout) as Report).rules[0]; expect(rule?.violations.map((violation) => violation.constraintId)).toEqual( @@ -394,7 +392,7 @@ describe("validate checks components without requiring tests", () => { config: SCOPED.replaceAll("no-simply", "ize-ise"), style: `extends: consistency\nmessage: "Use '%s' consistently"\nlevel: warning\nnonword: true\neither:\n organize: organise\n`, }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); expect( (JSON.parse(result.stdout) as Report).rules[0]?.errors.join(" ") @@ -403,7 +401,7 @@ describe("validate checks components without requiring tests", () => { it("accepts a hyphenated id on every other extension point", async () => { await valeRule("no-simply", { config: SCOPED }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); }); @@ -412,7 +410,7 @@ describe("validate checks components without requiring tests", () => { config: SCOPED, style: `extends: existence\nmessage: "x"\nlevel: catastrophic\ntokens:\n - simply\n`, }); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); expect( (JSON.parse(result.stdout) as Report).rules[0]?.errors.join(" ") @@ -423,7 +421,7 @@ describe("validate checks components without requiring tests", () => { withVale("verify runs validate first", () => { it("passes a rule that fires on fail/ and stays quiet on pass/", async () => { await valeRule("no-simply", { config: SCOPED, fixtures: true }); - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); }); @@ -435,7 +433,7 @@ withVale("verify runs validate first", () => { config: SCOPED, style: `extends: existence\nlevel: warning\ntokens:\n - simply\n`, }); - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const errors = (JSON.parse(result.stdout) as Report).rules[0]?.errors.join(" ") ?? ""; @@ -452,7 +450,7 @@ withVale("verify runs validate first", () => { recursive: true, force: true, }); - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); expect( (JSON.parse(result.stdout) as Report).rules[0]?.errors.join(" ") @@ -474,7 +472,7 @@ describe("verify reports every sg case", () => { "evaluate(x);\n" ); - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const rule = (JSON.parse(result.stdout) as Report).rules[0]; expect(rule?.status).toBe("failed"); @@ -494,7 +492,7 @@ describe("verify reports every sg case", () => { it("reports passing cases on a passing rule", async () => { await sgRule("no-eval", "no-eval"); - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); expect((JSON.parse(result.stdout) as Report).rules[0]?.status).toBe( "passed" @@ -507,13 +505,13 @@ describe("verify reports every sg case", () => { it("carries an empty list from validate, which runs no cases", async () => { await sgRule("no-eval", "no-eval"); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect((JSON.parse(result.stdout) as Report).rules[0]?.cases).toEqual([]); }); it("reports no status from validate, which runs no tests", async () => { await sgRule("no-eval", "no-eval"); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); const rule = (JSON.parse(result.stdout) as Report).rules[0]; expect(rule?.ok).toBe(true); expect(rule).not.toHaveProperty("status"); @@ -523,7 +521,7 @@ describe("verify reports every sg case", () => { // Directory and `id:` disagree, which `validate` refuses, so `verify` // stops before its cases run. await sgRule("no-eval", "something-else"); - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(1); const rule = ( JSON.parse(result.stdout) as { @@ -547,7 +545,7 @@ withVale("verify reports every Vale case", () => { "You simply do it.\n" ); - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const rule = (JSON.parse(result.stdout) as Report).rules[0]; const path = ".taskless/rules/vale/no-simply/tests/pass/plain"; @@ -582,8 +580,7 @@ async function verifyErrors(style: string): Promise { const result = await runCli([ "validate", ".taskless/rules/vale/no-simply", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const report = JSON.parse(result.stdout) as Report; @@ -623,8 +620,7 @@ withVale("validate schema-checks a Vale rule", () => { const result = await runCli([ "validate", ".taskless/rules/vale/no-simply", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); expect((JSON.parse(result.stdout) as Report).ok).toBe(true); @@ -649,8 +645,7 @@ withVale("validate schema-checks a Vale rule", () => { const result = await runCli([ "validate", ".taskless/rules/vale/no-simply", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); expect((JSON.parse(result.stdout) as Report).ok).toBe(true); @@ -681,8 +676,7 @@ withVale("validate schema-checks a Vale rule", () => { const result = await runCli([ "validate", ".taskless/rules/vale", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const report = JSON.parse(result.stdout) as Report; @@ -710,7 +704,7 @@ withVale("a rule Vale would choke on never reaches Vale", () => { fixtures: true, style: `extends: occurrence\nmessage: "x"\nlevel: warning\nscope: sentence\ntoken: very\nmax: 1\ntokens:\n - simply\n`, }); - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const rule = ( JSON.parse(result.stdout) as { @@ -737,7 +731,7 @@ withVale("a rule Vale would choke on never reaches Vale", () => { fixtures: true, style: `extends: nonsense\nmessage: "x"\nlevel: warning\ntokens:\n - simply\n`, }); - const result = await runCli(["verify", "-d", cwd, "--json"]); + const result = await runCli(["verify", `--dir=${cwd}`, "--json"]); const rule = ( JSON.parse(result.stdout) as { rules: { ran: boolean; errors: string[] }[]; @@ -754,7 +748,7 @@ describe("a rejection names the constraint it violated", () => { // another team consumes. A unit test over `validateOneRule` would prove the // field is produced and not that it is published. await sgRule("probe-rule", "mismatched"); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).not.toBe(0); const rule = (JSON.parse(result.stdout) as Report).rules[0]; @@ -772,7 +766,7 @@ describe("a rejection names the constraint it violated", () => { it("reports an empty list on a rule that passed", async () => { await sgRule("probe-rule", "probe-rule"); - const result = await runCli(["validate", "-d", cwd, "--json"]); + const result = await runCli(["validate", `--dir=${cwd}`, "--json"]); expect(result.exitCode).toBe(0); // Empty, never absent. A consumer must be able to tell "no constraint was @@ -819,7 +813,7 @@ async function noticesFor( path: string, passes = true ): Promise { - const result = await runCli(["verify", path, "-d", cwd, "--json"]); + const result = await runCli(["verify", path, `--dir=${cwd}`, "--json"]); const rule = (JSON.parse(result.stdout) as Report).rules[0]; // A notice, never a failure: a narrow glob can be deliberate. expect(result.exitCode === 0).toBe(passes); diff --git a/packages/cli/test/value-flags.test.ts b/packages/cli/test/value-flags.test.ts new file mode 100644 index 000000000..9ae362430 --- /dev/null +++ b/packages/cli/test/value-flags.test.ts @@ -0,0 +1,102 @@ +import { execFile } from "node:child_process"; +import { mkdtemp, rm } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { promisify } from "node:util"; +import { afterEach, beforeEach, describe, expect, it } from "vitest"; + +import { builtCli } from "./support/built-cli"; + +const execFileAsync = promisify(execFile); +const binPath = builtCli(); + +async function runCli( + args: string[], + cwd: string +): Promise<{ stdout: string; stderr: string; exitCode: number }> { + try { + const { stdout, stderr } = await execFileAsync("node", [binPath, ...args], { + cwd, + }); + return { stdout, stderr, exitCode: 0 }; + } catch (error) { + const execError = error as { stdout: string; stderr: string; code: number }; + return { + stdout: execError.stdout ?? "", + stderr: execError.stderr ?? "", + exitCode: execError.code, + }; + } +} + +describe("value flags take their value only after =", () => { + let directory: string; + + beforeEach(async () => { + directory = await mkdtemp(join(tmpdir(), "taskless-value-flags-")); + }); + + afterEach(async () => { + await rm(directory, { recursive: true, force: true }); + }); + + it("refuses the space spelling and names the = spelling", async () => { + const run = await runCli(["check", "--rule", "no-eval"], directory); + expect(run.exitCode).toBe(1); + expect(run.stderr).toContain("`--rule=`"); + expect(run.stderr).toContain("`--rule=no-eval`"); + }); + + it("refuses a bare value flag with nothing after it", async () => { + const run = await runCli(["check", "--rule"], directory); + expect(run.exitCode).toBe(1); + expect(run.stderr).toContain("`--rule=`"); + }); + + it("covers a value flag of a parent command", async () => { + // Without the refusal, `/tmp` would be taken for a command name. + const run = await runCli(["--dir", directory, "check"], directory); + expect(run.exitCode).toBe(1); + expect(run.stderr).toContain("`--dir=`"); + expect(run.stderr).not.toContain("Unknown command"); + }); + + it("refuses -d by name", async () => { + const run = await runCli(["check", "-d", "."], directory); + expect(run.exitCode).toBe(1); + expect(run.stderr).toContain("`--dir=`"); + }); + + it("refuses under --json with one error envelope", async () => { + const run = await runCli( + ["check", "--json", "--rule", "no-eval"], + directory + ); + expect(run.exitCode).toBe(1); + const envelope = JSON.parse(run.stdout.trim()) as { code: string }; + expect(envelope.code).toBe("INVALID_INPUT"); + }); + + it("leaves a token after -- alone", async () => { + // `--rule` after the end-of-options marker is a path, not a flag. + const run = await runCli( + [`--dir=${directory}`, "check", "--json", "--", "--rule"], + directory + ); + expect(run.stdout).not.toContain("INVALID_INPUT"); + }); + + it("still answers --help", async () => { + const run = await runCli(["check", "--rule", "--help"], directory); + expect(run.exitCode).toBe(0); + expect(run.stdout).toContain("USAGE"); + }); + + it("accepts --dir=", async () => { + const run = await runCli( + [`--dir=${directory}`, "check", "--json"], + directory + ); + expect(run.stdout).not.toContain("INVALID_INPUT"); + }); +}); diff --git a/packages/cli/test/verify.test.ts b/packages/cli/test/verify.test.ts index f562ba21b..0edcc58de 100644 --- a/packages/cli/test/verify.test.ts +++ b/packages/cli/test/verify.test.ts @@ -744,7 +744,7 @@ describe("verify: the verified/failed/refused split on a mixed run (#284)", () = beforeEach(async () => { cwd = await mkdtemp(join(tmpdir(), "tskl-verify-mixed-")); - await runVerifyMixedRunCli(["init", "-d", cwd]); + await runVerifyMixedRunCli(["init", `--dir=${cwd}`]); }); afterEach(async () => { @@ -763,8 +763,7 @@ describe("verify: the verified/failed/refused split on a mixed run (#284)", () = const jsonResult = await runVerifyMixedRunCli([ "verify", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const report = JSON.parse(jsonResult.stdout) as { @@ -791,7 +790,7 @@ describe("verify: the verified/failed/refused split on a mixed run (#284)", () = // The human summary is the only place `tested` is rendered at all — it is // not in the `--json` envelope — so this is the only way to pin its value. - const humanResult = await runVerifyMixedRunCli(["verify", "-d", cwd]); + const humanResult = await runVerifyMixedRunCli(["verify", `--dir=${cwd}`]); expect(humanResult.exitCode).not.toBe(0); expect(humanResult.stdout).toContain("1 of 2 rule(s) failed."); expect(humanResult.stdout).toContain("1 rule(s) did not run."); @@ -807,15 +806,14 @@ describe("verify: the verified/failed/refused split on a mixed run (#284)", () = const jsonResult = await runVerifyMixedRunCli([ "verify", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const report = JSON.parse(jsonResult.stdout) as { ok: boolean }; expect(report.ok).toBe(false); expect(jsonResult.exitCode).toBe(2); - const humanResult = await runVerifyMixedRunCli(["verify", "-d", cwd]); + const humanResult = await runVerifyMixedRunCli(["verify", `--dir=${cwd}`]); expect(humanResult.exitCode).toBe(2); expect(humanResult.stdout).toContain("1 rule(s) verified."); expect(humanResult.stdout).toContain("1 rule(s) did not run."); @@ -828,8 +826,7 @@ describe("verify: the verified/failed/refused split on a mixed run (#284)", () = const jsonResult = await runVerifyMixedRunCli([ "verify", join(".taskless", "rules", "runtime", "rt-rule"), - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); expect(jsonResult.exitCode).toBe(2); @@ -840,7 +837,7 @@ describe("verify: the verified/failed/refused split on a mixed run (#284)", () = expect(report.ok).toBe(false); expect(report.rules[0]?.ran).toBe(false); - const humanResult = await runVerifyMixedRunCli(["verify", "-d", cwd]); + const humanResult = await runVerifyMixedRunCli(["verify", `--dir=${cwd}`]); expect(humanResult.exitCode).toBe(2); expect(humanResult.stdout).toContain("0 rule(s) verified."); expect(humanResult.stdout).toContain("1 rule(s) did not run."); @@ -850,7 +847,7 @@ describe("verify: the verified/failed/refused split on a mixed run (#284)", () = await sgRule("fail-rule", { passes: false }); await refusedRuntimeRule("rt-rule"); - const { exitCode } = await runVerifyMixedRunCli(["verify", "-d", cwd]); + const { exitCode } = await runVerifyMixedRunCli(["verify", `--dir=${cwd}`]); expect(exitCode).toBe(1); }); @@ -864,8 +861,7 @@ describe("verify: the verified/failed/refused split on a mixed run (#284)", () = const { exitCode } = await runVerifyMixedRunCli([ "verify", join(".taskless", "rules", engine), - "-d", - cwd, + `--dir=${cwd}`, ]); expect(exitCode, engine).toBe(0); } @@ -944,7 +940,7 @@ describe("verify reports the findings each fixture case produced", () => { beforeEach(async () => { cwd = await mkdtemp(join(tmpdir(), "tskl-findings-")); - await runVerifyMixedRunCli(["init", "-d", cwd]); + await runVerifyMixedRunCli(["init", `--dir=${cwd}`]); }); afterEach(async () => { @@ -1010,8 +1006,7 @@ describe("verify reports the findings each fixture case produced", () => { return runVerifyMixedRunCli([ "verify", `.taskless/rules/vale/${VALE_RULE}`, - "-d", - cwd, + `--dir=${cwd}`, ...extra, ]); } @@ -1195,8 +1190,7 @@ export default async function (root, matches) { return runVerifyMixedRunCli([ "verify", `.taskless/rules/runtime/${RUNTIME_RULE}`, - "-d", - cwd, + `--dir=${cwd}`, "--dangerously-run-scripts", ...extra, ]); @@ -1258,8 +1252,7 @@ export default async function (root, matches) { const { stdout } = await runVerifyMixedRunCli([ "verify", `.taskless/rules/runtime/${RUNTIME_RULE}`, - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const report = JSON.parse(stdout) as FindingsReport; @@ -1298,8 +1291,7 @@ export default async function (root, matches) { const { stdout } = await runVerifyMixedRunCli([ "verify", ".taskless/rules/sg/no-eval-sg", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const report = JSON.parse(stdout) as FindingsReport; @@ -1314,8 +1306,7 @@ export default async function (root, matches) { const { stdout } = await runVerifyMixedRunCli([ "validate", ".taskless/rules/sg/no-eval-sg", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); const report = JSON.parse(stdout) as FindingsReport; @@ -1330,7 +1321,7 @@ describe("validate honors a rule's trap acknowledgement (#713)", () => { beforeEach(async () => { cwd = await mkdtemp(join(tmpdir(), "tskl-acknowledge-")); - await runVerifyMixedRunCli(["init", "-d", cwd]); + await runVerifyMixedRunCli(["init", `--dir=${cwd}`]); }); afterEach(async () => { @@ -1372,8 +1363,7 @@ describe("validate honors a rule's trap acknowledgement (#713)", () => { const { stdout } = await runVerifyMixedRunCli([ "validate", ".taskless/rules/sg/prisma-updatemany-where", - "-d", - cwd, + `--dir=${cwd}`, "--json", ]); return JSON.parse(stdout) as AcknowledgeReport; diff --git a/packages/cli/test/version-flag.test.ts b/packages/cli/test/version-flag.test.ts index ebd51e304..db998e9fc 100644 --- a/packages/cli/test/version-flag.test.ts +++ b/packages/cli/test/version-flag.test.ts @@ -43,8 +43,7 @@ describe("--version", () => { binPath, "check", "--version", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, ]); expect(stdout).toBe(`${__VERSION__}\n`); @@ -55,8 +54,7 @@ describe("--version", () => { const { stdout } = await execFileAsync("node", [ binPath, "check", - "-d", - temporaryDirectory, + `--dir=${temporaryDirectory}`, "--json", "--", "-v", @@ -80,11 +78,11 @@ describe("hasVersionFlag", () => { [["--version"], true], [["-v"], true], [["check", "--version"], true], - [["-d", "/tmp", "check", "-v"], true], + [["--dir=/tmp", "check", "-v"], true], [["check"], false], // A path after `--`, and a directory that reads like a flag, are values. [["check", "--", "-v"], false], - [["-d", "-v", "check"], false], + [["--dir=-v", "check"], false], ])("resolves %j to %s", (argv, expected) => { expect(hasVersionFlag(argv)).toBe(expected); }); diff --git a/packages/cli/test/version-gate-cli.test.ts b/packages/cli/test/version-gate-cli.test.ts index 205f34388..1d4ab2caa 100644 --- a/packages/cli/test/version-gate-cli.test.ts +++ b/packages/cli/test/version-gate-cli.test.ts @@ -69,7 +69,7 @@ describe("the version-pin gate", () => { it("refuses check when the project records another version", async () => { await record("0.0.1"); - const result = await runCli(["check", "--json", "-d", cwd]); + const result = await runCli(["check", "--json", `--dir=${cwd}`]); expect(result.exitCode).not.toBe(0); const envelope = JSON.parse(result.stdout) as { ok: boolean; @@ -86,40 +86,40 @@ describe("the version-pin gate", () => { it("refuses in prose without --json", async () => { await record("0.0.1"); - const result = await runCli(["rule", "list", "-d", cwd]); + const result = await runCli(["rule", "list", `--dir=${cwd}`]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("as recorded in .taskless/taskless.json"); }); it("lets info run, so the refusal can be diagnosed", async () => { await record("0.0.1"); - const result = await runCli(["info", "--json", "-d", cwd]); + const result = await runCli(["info", "--json", `--dir=${cwd}`]); expect(result.exitCode).toBe(0); }); it("lets init run, since init is what moves the record", async () => { await record("0.0.1"); - const result = await runCli(["init", "--json", "-d", cwd]); + const result = await runCli(["init", "--json", `--dir=${cwd}`]); expect(result.stdout).not.toContain("CLI_VERSION_MISMATCH"); expect(result.exitCode).toBe(0); }); it("leaves an unreadable manifest to the command's own refusal", async () => { await writeFile(join(cwd, ".taskless", "taskless.json"), "{ not json"); - const result = await runCli(["check", "--json", "-d", cwd]); + const result = await runCli(["check", "--json", `--dir=${cwd}`]); expect(result.stdout).not.toContain("CLI_VERSION_MISMATCH"); expect(result.stdout).toContain("SCAFFOLD_MANIFEST_UNREADABLE"); }); it("does not refuse the recorded version", async () => { await record(builtCliVersion()); - const result = await runCli(["check", "--json", "-d", cwd]); + const result = await runCli(["check", "--json", `--dir=${cwd}`]); expect(result.stdout).not.toContain("CLI_VERSION_MISMATCH"); }); it("does not refuse under the environment override", async () => { await record("0.0.1"); - const result = await runCli(["check", "--json", "-d", cwd], { + const result = await runCli(["check", "--json", `--dir=${cwd}`], { TASKLESS_ALLOW_VERSION_MISMATCHES: "1", }); expect(result.stdout).not.toContain("CLI_VERSION_MISMATCH"); From c8736abc494f033e8ae5b5b7a4b0881413c5a35e Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sat, 5 Dec 2026 17:00:18 -0800 Subject: [PATCH 2/6] docs: spell every value flag --flag=value in recipes, messages, the skill and READMEs --- .github/workflows/reference-corpus.yml | 6 +++--- README.md | 2 +- openspec/changes/value-flags-equals-only/tasks.md | 2 +- packages/cli/src/agent/bug-report.md | 4 ++-- packages/cli/src/agent/check.md | 6 +++--- packages/cli/src/agent/create-remote-rule.md | 6 +++--- packages/cli/src/agent/create-runtime-rule.md | 6 +++--- packages/cli/src/agent/create-sg-rule.md | 8 ++++---- packages/cli/src/agent/create-vale-rule.md | 4 ++-- packages/cli/src/agent/feedback.md | 4 ++-- packages/cli/src/agent/hooks.md | 2 +- packages/cli/src/agent/improve-rule.md | 6 +++--- packages/cli/src/agent/onboard.md | 4 ++-- packages/cli/src/agent/recover-rule.md | 4 ++-- packages/cli/src/agent/report.md | 6 +++--- packages/cli/src/agent/rule-feedback.md | 4 ++-- packages/cli/src/agent/update.md | 8 ++++---- packages/cli/src/agent/validate-rule.md | 8 ++++---- packages/cli/src/commands/agent.ts | 8 ++++---- packages/cli/src/commands/ast.ts | 2 +- packages/cli/src/commands/auth.ts | 2 +- packages/cli/src/commands/check.ts | 4 ++-- packages/cli/src/commands/feedback.ts | 4 ++-- packages/cli/src/commands/rules.ts | 14 +++++++------- .../migrations/0011-reports-directory.ts | 2 +- packages/cli/src/prompts/recipes.ts | 2 +- packages/cli/src/report/summary.ts | 2 +- packages/cli/src/rules/assemble.ts | 2 +- packages/cli/src/rules/scan.ts | 2 +- packages/cli/src/telemetry-run.ts | 4 ++-- packages/cli/src/util/argv.ts | 2 +- packages/cli/src/util/help.ts | 6 +++--- packages/cli/test/ast-command.test.ts | 2 +- packages/cli/test/check-recipe.test.ts | 4 ++-- packages/cli/test/check.test.ts | 2 +- packages/cli/test/feedback-recipes.test.ts | 4 ++-- packages/cli/test/onboard.test.ts | 4 ++-- packages/cli/test/recipe-sections.test.ts | 10 +++++----- packages/cli/test/report.test.ts | 2 +- packages/cli/test/rule-poll-transient.test.ts | 10 +++++----- skills/taskless/SKILL.md | 2 +- 41 files changed, 93 insertions(+), 93 deletions(-) diff --git a/.github/workflows/reference-corpus.yml b/.github/workflows/reference-corpus.yml index 08e6daeae..c22cc4bae 100644 --- a/.github/workflows/reference-corpus.yml +++ b/.github/workflows/reference-corpus.yml @@ -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 @@ -104,7 +104,7 @@ 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 @@ -112,7 +112,7 @@ jobs: - 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") diff --git a/README.md b/README.md index 65d8338e8..9c53368f4 100644 --- a/README.md +++ b/README.md @@ -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 ` takes the page down, where `` 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=` takes the page down, where `` is its file in `.taskless/reports/`. ### Accounts diff --git a/openspec/changes/value-flags-equals-only/tasks.md b/openspec/changes/value-flags-equals-only/tasks.md index 31f33e448..227282aea 100644 --- a/openspec/changes/value-flags-equals-only/tasks.md +++ b/openspec/changes/value-flags-equals-only/tasks.md @@ -6,7 +6,7 @@ ## 2. Callers in this repository -- [ ] 2.1 Rewrite every value flag in CLI messages, recipes, `skills/taskless/SKILL.md`, both READMEs and `.github/workflows/reference-corpus.yml` to the `=` spelling; verify a grep for a space-form value flag over `packages/cli/src`, `skills/` and the READMEs returns nothing, and the recipe tests pass +- [x] 2.1 Rewrite every value flag in CLI messages, recipes, `skills/taskless/SKILL.md`, both READMEs and `.github/workflows/reference-corpus.yml` to the `=` spelling; verify a grep for a space-form value flag over `packages/cli/src`, `skills/` and the READMEs returns nothing, and the recipe tests pass - [x] 2.2 Rewrite every test invocation to the `=` spelling, including the fixture helper that reads `-d`; verify the full suite passes ## 3. Release diff --git a/packages/cli/src/agent/bug-report.md b/packages/cli/src/agent/bug-report.md index d00f52597..926eac062 100644 --- a/packages/cli/src/agent/bug-report.md +++ b/packages/cli/src/agent/bug-report.md @@ -1,4 +1,4 @@ -# Topic: bug-report (CLI v%(CLI_VERSION)s / topic v2) +# Topic: bug-report (CLI v%(CLI_VERSION)s / topic v3) %(ONE_COMMAND_PER_CALL)s @@ -67,7 +67,7 @@ delete the file. 7. **Send.** Run: ``` - %(TASKLESS_CLI)s feedback send --from .taskless/.tmp-feedback.json --json + %(TASKLESS_CLI)s feedback send --from=.taskless/.tmp-feedback.json --json ``` On success the command prints a thank-you. If it says telemetry is disabled, nothing was sent: tell the user that, and that they can diff --git a/packages/cli/src/agent/check.md b/packages/cli/src/agent/check.md index 686f00ca7..4f8b2a04c 100644 --- a/packages/cli/src/agent/check.md +++ b/packages/cli/src/agent/check.md @@ -22,12 +22,12 @@ in CI (diff-only scan), or after rule create/improve to validate. - `--summary`: per-rule counts instead of every finding. With `--json` it omits `results` and keeps `summary`, so the output stays small on any repository. Use it when the question is "how many", not "where". -- `--rule `: run only the named rule (its directory name); +- `--rule=`: run only the named rule (its directory name); repeatable. Works with `--json` and `--summary`. - `--diff[=]`: scope to a diff ([Diff scope](#diff-scope)). - `--local`: run only static rules; skip runtime rules. - `--dangerously-run-scripts`: run runtime `check.ts` unverified. -- `--timeout `: per-runtime-check wall-clock bound (default 10). +- `--timeout=`: per-runtime-check wall-clock bound (default 10). - `--preserve-logs` / `-l`: keep this run's directory under `.taskless/.run/` (the snapshot that ran, the engine configs, and `engine.log`, `sg.log`, `vale.log`, `runtime.log`) instead of removing it. @@ -112,7 +112,7 @@ in CI (diff-only scan), or after rule create/improve to validate. `ruleId` as `verify` keys `rules[]`. **On a large repository, run `check --json --summary` first** to see - which rules fired, then `check --json --rule ` for one rule's + which rules fired, then `check --json --rule=` for one rule's findings, since `results` can run to hundreds of kilobytes. Do not count `results` yourself, and do not read an absent `results` as clean: read `summary.total`. diff --git a/packages/cli/src/agent/create-remote-rule.md b/packages/cli/src/agent/create-remote-rule.md index 425af1b57..2dd8b933b 100644 --- a/packages/cli/src/agent/create-remote-rule.md +++ b/packages/cli/src/agent/create-remote-rule.md @@ -1,4 +1,4 @@ -# Topic: create-remote-rule (CLI v%(CLI_VERSION)s / topic v11) +# Topic: create-remote-rule (CLI v%(CLI_VERSION)s / topic v12) %(ONE_COMMAND_PER_CALL)s @@ -120,7 +120,7 @@ Two ways to legitimately be here: 7. **Submit.** Run: ``` - %(TASKLESS_CLI)s rule create --from .taskless/.tmp-rule-request.json --json + %(TASKLESS_CLI)s rule create --from=.taskless/.tmp-rule-request.json --json ``` This may take 30-60 seconds while the service generates the rule. On failure, look the `code` up in [Errors](#errors). @@ -190,7 +190,7 @@ the id is the rule's directory name (for example `no-eval-3fa9c21b`). It is what `rule improve`, `rule restore`, and `rule rollback` take, and it is on disk, so nothing needs recording. `requestId` names the generation request only. The one command that -takes it back is `rule create --resume ` (see [Errors](#errors)); +takes it back is `rule create --resume=` (see [Errors](#errors)); passing it to `rule improve` as a rule id fails with `RULE_NOT_FOUND`. **Read `notices` if it is present.** It is an optional array of diff --git a/packages/cli/src/agent/create-runtime-rule.md b/packages/cli/src/agent/create-runtime-rule.md index af29ce31a..c2928a7b0 100644 --- a/packages/cli/src/agent/create-runtime-rule.md +++ b/packages/cli/src/agent/create-runtime-rule.md @@ -1,4 +1,4 @@ -# Topic: create-runtime-rule (CLI v%(CLI_VERSION)s / topic v10) +# Topic: create-runtime-rule (CLI v%(CLI_VERSION)s / topic v11) %(ONE_COMMAND_PER_CALL)s @@ -141,8 +141,8 @@ capture did not match, which is a fact about the fixture. A capture is an ast-grep rule, so the quirks of `create-sg-rule` apply to it as well. Print them with -`%(RECIPE_FETCH)screate-sg-rule --section quirks` and -`%(RECIPE_FETCH)screate-sg-rule --section pattern-quirks`. Four of them catch +`%(RECIPE_FETCH)screate-sg-rule --section=quirks` and +`%(RECIPE_FETCH)screate-sg-rule --section=pattern-quirks`. Four of them catch captures most often. Each was measured against the ast-grep this CLI ships (v%(AST_GREP_VERSION)s). The first two decide what a capture matches; the last two decide where a match says it is. diff --git a/packages/cli/src/agent/create-sg-rule.md b/packages/cli/src/agent/create-sg-rule.md index e56b6e86e..a56b52234 100644 --- a/packages/cli/src/agent/create-sg-rule.md +++ b/packages/cli/src/agent/create-sg-rule.md @@ -1,4 +1,4 @@ -# Topic: create-sg-rule (CLI v%(CLI_VERSION)s / topic v19) +# Topic: create-sg-rule (CLI v%(CLI_VERSION)s / topic v20) %(ONE_COMMAND_PER_CALL)s @@ -188,14 +188,14 @@ of a file the rule targets: ``` %(TASKLESS_CLI)s ast -%(TASKLESS_CLI)s ast --range 40:60 +%(TASKLESS_CLI)s ast --range=40:60 ``` It parses the file with the ast-grep this CLI ships, as the language its extension resolves to, which is the parser `check` uses for it. It prints named nodes only, so every kind it shows is one `kind:` -accepts. `--range ` or `--range :` keeps the nodes on -those lines and the ones enclosing them, `--lang ` parses +accepts. `--range=` or `--range=:` keeps the nodes on +those lines and the ones enclosing them, `--lang=` parses as another language, and `--json` gives the same tree as data. There is no need to locate an ast-grep binary yourself. diff --git a/packages/cli/src/agent/create-vale-rule.md b/packages/cli/src/agent/create-vale-rule.md index 01a3b1df3..409994497 100644 --- a/packages/cli/src/agent/create-vale-rule.md +++ b/packages/cli/src/agent/create-vale-rule.md @@ -1,4 +1,4 @@ -# Topic: create-vale-rule (CLI v%(CLI_VERSION)s / topic v24) +# Topic: create-vale-rule (CLI v%(CLI_VERSION)s / topic v25) %(ONE_COMMAND_PER_CALL)s @@ -1059,7 +1059,7 @@ knows what the branch cost when it was written: over the whole project, run `check` with only that rule: ``` -%(TASKLESS_CLI)s check --json --rule +%(TASKLESS_CLI)s check --json --rule= ``` Count the entries in `results`. A finding carries no record of which diff --git a/packages/cli/src/agent/feedback.md b/packages/cli/src/agent/feedback.md index 731b4a832..df6d8d0f0 100644 --- a/packages/cli/src/agent/feedback.md +++ b/packages/cli/src/agent/feedback.md @@ -1,4 +1,4 @@ -# Topic: feedback (CLI v%(CLI_VERSION)s / topic v2) +# Topic: feedback (CLI v%(CLI_VERSION)s / topic v3) %(ONE_COMMAND_PER_CALL)s @@ -58,7 +58,7 @@ needed. 6. **Send.** Run: ``` - %(TASKLESS_CLI)s feedback send --from .taskless/.tmp-feedback.json --json + %(TASKLESS_CLI)s feedback send --from=.taskless/.tmp-feedback.json --json ``` On success the command prints a thank-you. If it says telemetry is disabled, nothing was sent: tell the user that, and that they can diff --git a/packages/cli/src/agent/hooks.md b/packages/cli/src/agent/hooks.md index 589d8d380..6cb57a6af 100644 --- a/packages/cli/src/agent/hooks.md +++ b/packages/cli/src/agent/hooks.md @@ -193,7 +193,7 @@ For simple-git-hooks, rerun its installer after editing the config ## What the hook runs What the hook runs depends on the developer's login, as for any -`check` (see `%(RECIPE_FETCH)scheck --section what-runs`). +`check` (see `%(RECIPE_FETCH)scheck --section=what-runs`). Logged in, `check` verifies the rules with the Taskless service, a network call on every commit, and runs the runtime rules that pass. Logged out, it runs ast-grep and Vale rules and skips runtime ones. If that diff --git a/packages/cli/src/agent/improve-rule.md b/packages/cli/src/agent/improve-rule.md index 0cb07cfe0..73ccac230 100644 --- a/packages/cli/src/agent/improve-rule.md +++ b/packages/cli/src/agent/improve-rule.md @@ -1,4 +1,4 @@ -# Topic: improve-rule (CLI v%(CLI_VERSION)s / topic v13) +# Topic: improve-rule (CLI v%(CLI_VERSION)s / topic v14) %(ONE_COMMAND_PER_CALL)s @@ -78,7 +78,7 @@ If the user wants the local-only flow (no API call), fetch 8. **Invoke the CLI.** Run: ``` - %(TASKLESS_CLI)s rule improve --from .taskless/.tmp-improve-request.json --json + %(TASKLESS_CLI)s rule improve --from=.taskless/.tmp-improve-request.json --json ``` This may take 30-60 seconds while the API generates the update. @@ -115,7 +115,7 @@ sitting next to a comma before you write that guidance. The comma is itself an AST node that has to match, so `f($A, $$$)` never sees a one-argument call and `f($$$, $A)` sees only one-argument calls, the pattern reads as variadic and is not. -`%(RECIPE_FETCH)screate-sg-rule --section pattern-quirks` carries the arity +`%(RECIPE_FETCH)screate-sg-rule --section=pattern-quirks` carries the arity table and both remedies. Guidance that asks to widen the rule when the fix is `strictness: ast` sends the iterate endpoint after the wrong change, and it will oblige. diff --git a/packages/cli/src/agent/onboard.md b/packages/cli/src/agent/onboard.md index def386b42..ab286c506 100644 --- a/packages/cli/src/agent/onboard.md +++ b/packages/cli/src/agent/onboard.md @@ -1,4 +1,4 @@ -# Topic: onboard (CLI v%(CLI_VERSION)s / topic v16) +# Topic: onboard (CLI v%(CLI_VERSION)s / topic v17) %(ONE_COMMAND_PER_CALL)s @@ -117,7 +117,7 @@ case for running them in CI. `%(TASKLESS_CLI)s agent report` to publish the report, with the runtime candidates from step 8. In parallel, follow `%(TASKLESS_CLI)s agent rule-feedback` as the respondent, reached from onboarding - (`%(RECIPE_FETCH)srule-feedback --section reached-from-onboarding`): + (`%(RECIPE_FETCH)srule-feedback --section=reached-from-onboarding`): answer from your own account of this session, ask the user nothing, and send it. If the report recipe refuses for too few rules, that is step 9's case. diff --git a/packages/cli/src/agent/recover-rule.md b/packages/cli/src/agent/recover-rule.md index 56ba8af8c..de3456a94 100644 --- a/packages/cli/src/agent/recover-rule.md +++ b/packages/cli/src/agent/recover-rule.md @@ -1,4 +1,4 @@ -# Topic: recover-rule (CLI v%(CLI_VERSION)s / topic v7) +# Topic: recover-rule (CLI v%(CLI_VERSION)s / topic v8) %(ONE_COMMAND_PER_CALL)s @@ -122,7 +122,7 @@ below, and the service's answer settles it. If `check` or `rule revisions` already said the plan does not include recovery, use the git steps `check` gave. Choosing the commit is covered -in `%(RECIPE_FETCH)scheck --section when-the-plan-does-not-include-restoring-rules`. +in `%(RECIPE_FETCH)scheck --section=when-the-plan-does-not-include-restoring-rules`. To go back to an earlier revision on such a plan, find the commit in `git log -- `; `rule revisions` still lists when each revision was created and its pull request, which diff --git a/packages/cli/src/agent/report.md b/packages/cli/src/agent/report.md index 62e593cb5..335b97521 100644 --- a/packages/cli/src/agent/report.md +++ b/packages/cli/src/agent/report.md @@ -1,4 +1,4 @@ -# Topic: report (CLI v%(CLI_VERSION)s / topic v11) +# Topic: report (CLI v%(CLI_VERSION)s / topic v12) %(ONE_COMMAND_PER_CALL)s @@ -73,7 +73,7 @@ later and deletes one on request. 3. **Generate.** Run: ``` - %(TASKLESS_CLI)s report --from .taskless/.tmp-report.json + %(TASKLESS_CLI)s report --from=.taskless/.tmp-report.json ``` On failure it prints `Error (): `. Handle the code @@ -110,7 +110,7 @@ later and deletes one on request. 6. **Delete on request.** If the user asks to delete the report, run: ``` - %(TASKLESS_CLI)s report --delete + %(TASKLESS_CLI)s report --delete= ``` `` is the file name the summary named, under diff --git a/packages/cli/src/agent/rule-feedback.md b/packages/cli/src/agent/rule-feedback.md index c9148c243..9fc3ee113 100644 --- a/packages/cli/src/agent/rule-feedback.md +++ b/packages/cli/src/agent/rule-feedback.md @@ -1,4 +1,4 @@ -# Topic: rule-feedback (CLI v%(CLI_VERSION)s / topic v7) +# Topic: rule-feedback (CLI v%(CLI_VERSION)s / topic v8) %(ONE_COMMAND_PER_CALL)s @@ -131,7 +131,7 @@ says so; that is the user's opt-out holding, not a failure. 5. **Send.** Run: ``` - %(TASKLESS_CLI)s feedback send --from .taskless/.tmp-feedback.json --json + %(TASKLESS_CLI)s feedback send --from=.taskless/.tmp-feedback.json --json ``` Under `--json`, a failure is `{ ok: false, code, message }`; see [Errors](#errors). On success the command prints a thank-you. With diff --git a/packages/cli/src/agent/update.md b/packages/cli/src/agent/update.md index e202317e1..08edfdbf1 100644 --- a/packages/cli/src/agent/update.md +++ b/packages/cli/src/agent/update.md @@ -1,4 +1,4 @@ -# Topic: update (CLI v%(CLI_VERSION)s / topic v23) +# Topic: update (CLI v%(CLI_VERSION)s / topic v24) %(ONE_COMMAND_PER_CALL)s @@ -163,7 +163,7 @@ project, oldest first. Each entry is its own section, named the list of sections served on request names them oldest first too. Print one with: ``` -%(RECIPE_FETCH)supdate --section +%(RECIPE_FETCH)supdate --section= ``` An entry applies when its version is above `walk.from` (your @@ -405,7 +405,7 @@ root-metavariable case is: nothing to do unless you see one. which a rule could not do before: `text & doc(section:has(> h2:contains("Decision")))` is the prose of one section, `~doc(...)` is everything outside it, and a `metric` scoped to `doc(...)` puts a word budget on that section -alone. `%(RECIPE_FETCH)screate-vale-rule --section scopes` has the shapes and the +alone. `%(RECIPE_FETCH)screate-vale-rule --section=scopes` has the shapes and the one trap (a leaf element on its own, `doc(h2)`, is inert; chain it). No existing rule changes; this is a reason to revisit one that was narrowed by hand. @@ -486,7 +486,7 @@ inside `no-simply`'s config, which was a cross-rule override); and a overriding. A `.taskless/**` matcher is reported as an advisory rather than rejected: a whole-project `check` excludes that tree anyway, and on a fixture path you name the matcher is what silences the rule. -Delete it. `%(RECIPE_FETCH)screate-vale-rule --section config-schema` lists every +Delete it. `%(RECIPE_FETCH)screate-vale-rule --section=config-schema` lists every rejection and advisory. The Vale 3.22.0 and 3.23.0 changes continue in diff --git a/packages/cli/src/agent/validate-rule.md b/packages/cli/src/agent/validate-rule.md index 1549f1c7a..2612ea115 100644 --- a/packages/cli/src/agent/validate-rule.md +++ b/packages/cli/src/agent/validate-rule.md @@ -1,4 +1,4 @@ -# Topic: validate-rule (CLI v%(CLI_VERSION)s / topic v13) +# Topic: validate-rule (CLI v%(CLI_VERSION)s / topic v14) %(ONE_COMMAND_PER_CALL)s @@ -97,9 +97,9 @@ Both commands answer in the same shape, one entry per rule: rule it names the silent traps the rule's shape matches, such as `$$$` beside a comma. Read it before `ok`, the same as `status`. The traps are described in - `%(RECIPE_FETCH)screate-sg-rule --section quirks`, - `%(RECIPE_FETCH)screate-sg-rule --section pattern-quirks` and - `%(RECIPE_FETCH)screate-sg-rule --section relational-quirks`. + `%(RECIPE_FETCH)screate-sg-rule --section=quirks`, + `%(RECIPE_FETCH)screate-sg-rule --section=pattern-quirks` and + `%(RECIPE_FETCH)screate-sg-rule --section=relational-quirks`. - A trap notice repeats on every run until the rule changes. If you have checked that a trap cannot bite the rule, list its id under `metadata.taskless.acknowledge` in the rule file and it stops; the diff --git a/packages/cli/src/commands/agent.ts b/packages/cli/src/commands/agent.ts index d056523fc..298b24107 100644 --- a/packages/cli/src/commands/agent.ts +++ b/packages/cli/src/commands/agent.ts @@ -165,7 +165,7 @@ export function createAgentCommand(subCommands: SubCommandsDef) { }, async run({ args, rawArgs }) { // Extract positional args from rawArgs, skipping flags and their values. - // --dir/-d/--tool/--section take a value; --json/--local/--anonymous/--full are + // --dir/--tool/--section take a value (as --flag=value); --json/--local/--anonymous/--full are // boolean and do not. const valueFlagSet = new Set(["--dir", "-d", "--tool", "--section"]); const positionals: string[] = []; @@ -247,7 +247,7 @@ export function createAgentCommand(subCommands: SubCommandsDef) { `\nRun \`${prefix} agent \` for the recipe (e.g. \`${prefix} agent create-sg-rule\`).` ); console.log( - `A long recipe ends with the sections it serves on request; print one with \`${prefix} agent --section \`.` + `A long recipe ends with the sections it serves on request; print one with \`${prefix} agent --section=\`.` ); return; } @@ -264,7 +264,7 @@ export function createAgentCommand(subCommands: SubCommandsDef) { `A topic is a single token. Run \`${getCliPrefix()} agent\` for the topic index.` ); console.error( - `To print one section of a topic, pass it as \`--section \`.` + `To print one section of a topic, pass it as \`--section=\`.` ); process.exitCode = 1; return; @@ -276,7 +276,7 @@ export function createAgentCommand(subCommands: SubCommandsDef) { telemetry.capture("cli_agent", { topic: positionals[0] }); console.error("--section and --full cannot be combined."); console.error( - "Pass --section for one section, or --full for the whole topic." + "Pass --section= for one section, or --full for the whole topic." ); process.exitCode = 1; return; diff --git a/packages/cli/src/commands/ast.ts b/packages/cli/src/commands/ast.ts index 672ae138f..8a4c0d903 100644 --- a/packages/cli/src/commands/ast.ts +++ b/packages/cli/src/commands/ast.ts @@ -166,7 +166,7 @@ export const astCommand = defineCommand({ const root = range === undefined ? tree : filterByRange(tree, range); if (root === undefined) { throw new AstCommandError( - `No node touches --range ${args.range ?? ""}: the tree of ${args.file} spans lines ${String(tree.start.line)} to ${String(lastLine(tree))}.`, + `No node touches --range=${args.range ?? ""}: the tree of ${args.file} spans lines ${String(tree.start.line)} to ${String(lastLine(tree))}.`, "INVALID_INPUT" ); } diff --git a/packages/cli/src/commands/auth.ts b/packages/cli/src/commands/auth.ts index cdb826838..238b1fa75 100644 --- a/packages/cli/src/commands/auth.ts +++ b/packages/cli/src/commands/auth.ts @@ -295,7 +295,7 @@ export const authCommand = defineCommand({ async run({ args, rawArgs }) { // citty always calls the parent's run handler, even after a subcommand. // Only show status when no subcommand was provided. The shared scanner - // skips flag values, so the path in `auth -d ` is not read as one. + // skips flag values, so the path in `auth --dir=` is not read as one. if (splitRawArguments(rawArgs).positionals.length > 0) { return; } diff --git a/packages/cli/src/commands/check.ts b/packages/cli/src/commands/check.ts index 297b2bad5..6501e78c0 100644 --- a/packages/cli/src/commands/check.ts +++ b/packages/cli/src/commands/check.ts @@ -602,7 +602,7 @@ export const checkCommand = defineCommand({ : []; // `--rule` narrows WHAT runs; it does not widen what may run. A runtime // rule named here is still subject to the signature gate, so an - // unauthenticated `check --rule ` reports the same skip it + // unauthenticated `check --rule=` reports the same skip it // would have reported inside a whole-project run. const runtimeRules = selection === undefined @@ -635,7 +635,7 @@ export const checkCommand = defineCommand({ ); } else { console.log( - `No rules configured. Create one with \`${getCliPrefix()} rule create --from \`.` + `No rules configured. Create one with \`${getCliPrefix()} rule create --from=\`.` ); } return; diff --git a/packages/cli/src/commands/feedback.ts b/packages/cli/src/commands/feedback.ts index 8c4743214..0ee001b54 100644 --- a/packages/cli/src/commands/feedback.ts +++ b/packages/cli/src/commands/feedback.ts @@ -131,7 +131,7 @@ const sendCommand = defineCommand({ from: { type: "string", description: - "Path to a JSON file containing the feedback payload (required). Example: --from .taskless/.tmp-feedback.json", + "Path to a JSON file containing the feedback payload (required). Example: --from=.taskless/.tmp-feedback.json", }, json: { type: "boolean", @@ -158,7 +158,7 @@ const sendCommand = defineCommand({ // whether or not anything would be sent, and the agent should hear so. if (!args.from) { fail( - `--from is required. Provide a path to a JSON file.\n Example: ${getCliPrefix()} feedback send --from .taskless/.tmp-feedback.json`, + `--from is required. Provide a path to a JSON file.\n Example: ${getCliPrefix()} feedback send --from=.taskless/.tmp-feedback.json`, "INVALID_INPUT" ); } diff --git a/packages/cli/src/commands/rules.ts b/packages/cli/src/commands/rules.ts index f92384854..73f1f4fd3 100644 --- a/packages/cli/src/commands/rules.ts +++ b/packages/cli/src/commands/rules.ts @@ -141,7 +141,7 @@ function resumeRequestId( if (args.resume === undefined) return undefined; if (args.from !== undefined) { fail( - `--resume picks up a request that was already submitted, so it takes no --from file.\n Example: ${getCliPrefix()} rule ${subcommand} --resume `, + `--resume picks up a request that was already submitted, so it takes no --from file.\n Example: ${getCliPrefix()} rule ${subcommand} --resume=`, "INVALID_INPUT" ); } @@ -251,7 +251,7 @@ async function completeRequest( repositoryUrl: identity.repositoryUrl, orgId: identity.orgSubject, onProgress: (message: string) => console.error(message), - resumeCommand: `${getCliPrefix()} rule ${options.subcommand} --resume ${requestId}`, + resumeCommand: `${getCliPrefix()} rule ${options.subcommand} --resume=${requestId}`, }; let delivered: Delivered; @@ -338,7 +338,7 @@ const createCommand = defineCommand({ from: { type: "string", description: - "Path to a JSON file containing the rule request (required unless --resume). Example: --from .taskless/.tmp-rule-request.json", + "Path to a JSON file containing the rule request (required unless --resume). Example: --from=.taskless/.tmp-rule-request.json", }, resume: { type: "string", @@ -416,7 +416,7 @@ const createCommand = defineCommand({ // 1. Read and validate --from file if (!args.from) { fail( - `--from is required. Provide a path to a JSON file.\n Example: ${getCliPrefix()} rule create --from request.json`, + `--from is required. Provide a path to a JSON file.\n Example: ${getCliPrefix()} rule create --from=request.json`, "INVALID_INPUT" ); } @@ -482,7 +482,7 @@ const improveCommand = defineCommand({ from: { type: "string", description: - "Path to a JSON file containing { ruleId, guidance, references? } (required unless --resume). Example: --from .taskless/.tmp-iterate-request.json", + "Path to a JSON file containing { ruleId, guidance, references? } (required unless --resume). Example: --from=.taskless/.tmp-iterate-request.json", }, resume: { type: "string", @@ -556,7 +556,7 @@ const improveCommand = defineCommand({ // 1. Read and validate --from file if (!args.from) { fail( - `--from is required. Provide a path to a JSON file.\n Example: ${getCliPrefix()} rule improve --from request.json`, + `--from is required. Provide a path to a JSON file.\n Example: ${getCliPrefix()} rule improve --from=request.json`, "INVALID_INPUT" ); } @@ -660,7 +660,7 @@ const metaCommand = defineCommand({ `the rule service does not return the metadata block that ` + `.taskless/rule-metadata/ is written from. This is not specific to "${args.id}". ` + `To iterate on a rule, pass its id (the rule's directory name under .taskless/rules//) ` + - `to \`${getCliPrefix()} rule improve --from \`, or use the local-only improve flow.`, + `to \`${getCliPrefix()} rule improve --from=\`, or use the local-only improve flow.`, "RULE_META_UNAVAILABLE" ); } diff --git a/packages/cli/src/filesystem/migrations/0011-reports-directory.ts b/packages/cli/src/filesystem/migrations/0011-reports-directory.ts index 09cc7d2f3..4ffe6505d 100644 --- a/packages/cli/src/filesystem/migrations/0011-reports-directory.ts +++ b/packages/cli/src/filesystem/migrations/0011-reports-directory.ts @@ -27,7 +27,7 @@ its link, when it expires, and the URL that deletes it. This directory is gitignored: the delete URL is the only way to take a report down early, and anyone holding it can. Delete a report with -\`taskless report --delete \`. +\`taskless report --delete=\`. `; const migration: Migration = async (directory) => { diff --git a/packages/cli/src/prompts/recipes.ts b/packages/cli/src/prompts/recipes.ts index e2f913d5e..b3dddec2f 100644 --- a/packages/cli/src/prompts/recipes.ts +++ b/packages/cli/src/prompts/recipes.ts @@ -1448,7 +1448,7 @@ export function getServedRecipe( ? " --local" : ""; const topicFetch = `${resolveInvocation(options)} agent ${topic}${variant}`; - const fetch = (name: string) => `${topicFetch} --section ${name}`; + const fetch = (name: string) => `${topicFetch} --section=${name}`; const split = splitSections(rendered); if (selection.kind === "outline") { diff --git a/packages/cli/src/report/summary.ts b/packages/cli/src/report/summary.ts index caabc84a2..450011849 100644 --- a/packages/cli/src/report/summary.ts +++ b/packages/cli/src/report/summary.ts @@ -101,7 +101,7 @@ export function renderSummary(options: { `Expires: ${expiresAt.slice(0, 10)}`, "", "The report is unlisted: anyone with the link can view it.", - `It can be deleted after review. Ask, or run \`${invocation} report --delete ${record}\`.`, + `It can be deleted after review. Ask, or run \`${invocation} report --delete=${record}\`.`, ]; return lines.join("\n"); } diff --git a/packages/cli/src/rules/assemble.ts b/packages/cli/src/rules/assemble.ts index 61a5131a9..e00adf1d4 100644 --- a/packages/cli/src/rules/assemble.ts +++ b/packages/cli/src/rules/assemble.ts @@ -251,7 +251,7 @@ export interface AssembleOptions { * **This narrows what is WRITTEN, never what is VALIDATED.** Every Vale rule * in the project is still read and put through the config schema, and any * rejection still refuses the whole assembly. Skipping an unselected rule's - * validation would make `--rule good` exit clean in a project where `bad`'s + * validation would make `--rule=good` exit clean in a project where `bad`'s * config is rejected, while an unfiltered `check` in that same project * refuses the Vale engine outright — so the filtered run would report * findings the unfiltered run never produced, which is the one equality this diff --git a/packages/cli/src/rules/scan.ts b/packages/cli/src/rules/scan.ts index 9a9d87bfb..f06cba0e0 100644 --- a/packages/cli/src/rules/scan.ts +++ b/packages/cli/src/rules/scan.ts @@ -197,7 +197,7 @@ export interface ScanOptions { * no restriction. * * Anchored, and the ids escaped, because `--filter` takes a REGEX matched - * against every loaded rule id: unanchored, `--rule no-eval` would also report + * against every loaded rule id: unanchored, `--rule=no-eval` would also report * `no-eval-in-tests`, which is a different rule the author did not ask to * measure. Rule ids are `[a-z0-9-]`, so nothing in one is a regex metacharacter * today; the escape is here so that a later widening of `isValidRuleId` cannot diff --git a/packages/cli/src/telemetry-run.ts b/packages/cli/src/telemetry-run.ts index 6bf8a6bea..621b5c55b 100644 --- a/packages/cli/src/telemetry-run.ts +++ b/packages/cli/src/telemetry-run.ts @@ -15,7 +15,7 @@ const VERB_COMMANDS = new Set(["rule", "feedback"]); /** * Derive the cli_run `command` property from the raw argv. Flags (and the - * value after `-d`/`--dir`) are skipped; the first positional is the command, + * value after `--dir`) are skipped; the first positional is the command, * and `rule` and `feedback` keep their subcommand (e.g. `rule create`, * `feedback send`) since that distinction is meaningful. `agent`'s topic is * recorded separately on cli_agent, so the command for an agent invocation is @@ -31,7 +31,7 @@ export function resolveCommandName(rawArguments: string[]): string { return top; } -/** Resolve the working directory from `-d`/`--dir`, defaulting to cwd. */ +/** Resolve the working directory from `--dir`, defaulting to cwd. */ export function resolveCwd(rawArguments: string[]): string { // `--dir=` is the only spelling; the entry point refuses `-d` and a // bare `--dir` before a command runs. Stops at `--`, after which a token diff --git a/packages/cli/src/util/argv.ts b/packages/cli/src/util/argv.ts index 09dd0d5ab..1e4ea1db7 100644 --- a/packages/cli/src/util/argv.ts +++ b/packages/cli/src/util/argv.ts @@ -5,7 +5,7 @@ * * The rule is simple because the CLI made it simple: a flag carries its value * inside its own token, as `--flag=value`, and no flag ever consumes the token - * after it (`refuseSpacedValueFlags` in `src/index.ts` turns the other spelling + * after it (`spacedValueFlagMessage`, called from `src/index.ts`, turns the other spelling * away before any command runs). So a token beginning with `-` is a flag and * every other token is a positional, except that `--`, the POSIX end-of-options * marker, makes every token after it a positional, which is what lets diff --git a/packages/cli/src/util/help.ts b/packages/cli/src/util/help.ts index f2e322f2a..3a193edca 100644 --- a/packages/cli/src/util/help.ts +++ b/packages/cli/src/util/help.ts @@ -11,9 +11,9 @@ import { getCliPrefix } from "./package-manager"; * keeps `runCommand` and resolves help itself, here, using citty's own * exported `showUsage` so no usage text is hand-written. * - * citty's `resolveSubCommand` is not exported, and its own walk would resolve - * `taskless -d /tmp check --help` to `/tmp` (it takes the first non-`-` token), - * so the walk below uses the shared argv scanner instead. + * citty's `resolveSubCommand` is not exported, so the walk below uses the + * shared argv scanner, the same one every other positional question goes + * through. */ /** Resolve a citty `Resolvable` (value, promise, or factory) to its value. */ diff --git a/packages/cli/test/ast-command.test.ts b/packages/cli/test/ast-command.test.ts index ee5cef54c..7217fa9e2 100644 --- a/packages/cli/test/ast-command.test.ts +++ b/packages/cli/test/ast-command.test.ts @@ -350,7 +350,7 @@ describe("taskless ast", () => { [["ast", "notes.unknownext"], /does not recognize the extension/], [["ast", "a.ts", "--lang=C#"], /has no language "C#"/], [["ast", "a.ts", "--range=5:2"], /--range takes/], - [["ast", "a.ts", "--range=40"], /No node touches --range 40/], + [["ast", "a.ts", "--range=40"], /No node touches --range=40/], [["ast", "empty.ts"], /is empty/], [["ast", "latin1.js"], /is not valid UTF-8/], ])("refuses %j with INVALID_INPUT", async (args, message) => { diff --git a/packages/cli/test/check-recipe.test.ts b/packages/cli/test/check-recipe.test.ts index 142719a44..79a8c60c5 100644 --- a/packages/cli/test/check-recipe.test.ts +++ b/packages/cli/test/check-recipe.test.ts @@ -15,13 +15,13 @@ describe("the check recipe", () => { check.indexOf("## Flags"), check.indexOf("## Steps") ); - expect(flags).toContain("- `--rule `:"); + expect(flags).toContain("- `--rule=`:"); expect(flags).toContain("repeatable"); }); it("orders a large repository as summary first, then one rule", () => { const summary = check.indexOf("run `check --json --summary` first"); - const rule = check.indexOf("`check --json --rule `"); + const rule = check.indexOf("`check --json --rule=`"); expect(summary).toBeGreaterThan(-1); expect(rule).toBeGreaterThan(summary); }); diff --git a/packages/cli/test/check.test.ts b/packages/cli/test/check.test.ts index 58af1626c..99e243517 100644 --- a/packages/cli/test/check.test.ts +++ b/packages/cli/test/check.test.ts @@ -100,7 +100,7 @@ describe("check", () => { // The remedy must run as printed: through the launcher, with the // `--from` that `rule create` refuses to start without. expect(stdout).toMatch( - /`(?:npx|pnpm dlx) @taskless\/cli@\d[^\s`]* rule create --from `/ + /`(?:npx|pnpm dlx) @taskless\/cli@\d[^\s`]* rule create --from=`/ ); }); diff --git a/packages/cli/test/feedback-recipes.test.ts b/packages/cli/test/feedback-recipes.test.ts index fa606b45f..0d73b8747 100644 --- a/packages/cli/test/feedback-recipes.test.ts +++ b/packages/cli/test/feedback-recipes.test.ts @@ -42,7 +42,7 @@ describe("the rule-feedback recipe", () => { expect(outline).toContain( "Show it first, if the user asked for a `review`" ); - expect(outline).toContain("--section "); + expect(outline).toContain("--section="); expect(outline).toContain("- `input-schema`"); const { stdout } = await execFileAsync("node", [ @@ -71,7 +71,7 @@ describe("the rule-feedback recipe", () => { it("names the send and dismiss commands by the rendered invocation", () => { const rendered = getRecipe("rule-feedback", { invocation }); expect(rendered).toContain( - `${invocation} feedback send --from .taskless/.tmp-feedback.json --json` + `${invocation} feedback send --from=.taskless/.tmp-feedback.json --json` ); expect(rendered).toContain(`${invocation} feedback dismiss`); }); diff --git a/packages/cli/test/onboard.test.ts b/packages/cli/test/onboard.test.ts index 541cca18a..4d9cc9e9d 100644 --- a/packages/cli/test/onboard.test.ts +++ b/packages/cli/test/onboard.test.ts @@ -432,8 +432,8 @@ describe("onboard recipe asks one question and finishes on its own", () => { : stdout.slice(start, start + title.length + next); } - it("is topic v16", () => { - expect(stdout).toMatch(/^# Topic: onboard {5}\(CLI v.+ \/ topic v16\)/m); + it("is topic v17", () => { + expect(stdout).toMatch(/^# Topic: onboard {5}\(CLI v.+ \/ topic v17\)/m); }); // v10 (#554): a worktree holds only commits, and `init` commits nothing, so diff --git a/packages/cli/test/recipe-sections.test.ts b/packages/cli/test/recipe-sections.test.ts index 3976e34c7..21acaa8e2 100644 --- a/packages/cli/test/recipe-sections.test.ts +++ b/packages/cli/test/recipe-sections.test.ts @@ -101,7 +101,7 @@ function bytes(text: string): number { } function fetch(name: string): string { - return `cli agent t --section ${name}`; + return `cli agent t --section=${name}`; } describe("sections", () => { @@ -189,7 +189,7 @@ describe("sections", () => { ); expect(outline).not.toContain("detail"); expect(outline).toContain("- `quirks`\n"); - expect(outline).toContain("`cli agent t --section `"); + expect(outline).toContain("`cli agent t --section=`"); // A link to a section left out becomes its command; one to a section // printed here stays a link. expect(outline).toContain("Read section `quirks` and"); @@ -293,10 +293,10 @@ describe("every cross-referenced section is reachable by name", () => { }); it("names only sections that exist when it cites another topic's", async () => { - // `agent [flags] --section `, as a recipe spells a fetch of + // `agent [flags] --section=`, as a recipe spells a fetch of // a section of another topic, or as the outline spells one of its own. const citation = - /agent ([a-z][a-z-]*)((?: --[a-z]+(?:=[\w-]+)?)*) --section ([a-z\d-]+)/g; + /agent ([a-z][a-z-]*)((?: --[a-z]+(?:=[\w-]+)?)*) --section=([a-z\d-]+)/g; const dangling: string[] = []; let cited = 0; for (const { file, topic, options } of await recipeVariants()) { @@ -387,6 +387,6 @@ describe("taskless agent --section", () => { it("still refuses a second positional, and points at --section", async () => { const result = await run(["create-sg-rule", "quirks"]); expect(result.exitCode).toBe(1); - expect(result.stderr).toContain("--section "); + expect(result.stderr).toContain("--section="); }); }); diff --git a/packages/cli/test/report.test.ts b/packages/cli/test/report.test.ts index db8783769..20871bb34 100644 --- a/packages/cli/test/report.test.ts +++ b/packages/cli/test/report.test.ts @@ -1458,7 +1458,7 @@ describe("taskless report", () => { // The counting and estimating guidance is on demand (#672); --full prints it. const { stdout, exitCode } = await run(["agent", "report", "--full"]); expect(exitCode).toBe(0); - expect(stdout).toMatch(/^# Topic: report {5}\(CLI v.+ \/ topic v11\)/m); + expect(stdout).toMatch(/^# Topic: report {5}\(CLI v.+ \/ topic v12\)/m); const flat = stdout.replaceAll(/\s+/g, " "); const counting = flat.slice(flat.indexOf("## Counting evidence")); expect(counting).toContain( diff --git a/packages/cli/test/rule-poll-transient.test.ts b/packages/cli/test/rule-poll-transient.test.ts index 19594e5bd..97be7104a 100644 --- a/packages/cli/test/rule-poll-transient.test.ts +++ b/packages/cli/test/rule-poll-transient.test.ts @@ -202,7 +202,7 @@ describe("rule create: transient failures while polling and fetching", () => { expect(envelope.message).toContain("8 times in a row"); expect(envelope.message).toContain(REQUEST_ID); expect(envelope.message).toContain("may still complete"); - expect(envelope.message).toContain(`rule create --resume ${REQUEST_ID}`); + expect(envelope.message).toContain(`rule create --resume=${REQUEST_ID}`); expect(calls(fetchMock, "GET", "/cli/api/v2/request/")).toBe(8); }); @@ -298,7 +298,7 @@ describe("rule create: transient failures while polling and fetching", () => { expect(envelope.message).toContain(REQUEST_ID); expect(envelope.message).toContain("8 times in a row"); expect(envelope.message).toContain("No rules were written"); - expect(envelope.message).toContain(`rule create --resume ${REQUEST_ID}`); + expect(envelope.message).toContain(`rule create --resume=${REQUEST_ID}`); expect(calls(fetchMock, "GET", "/cli/api/v2/rule/")).toBe(8); expect(existsSync(ruleFile())).toBe(false); }); @@ -336,7 +336,7 @@ describe("rule create: transient failures while polling and fetching", () => { expect(envelope.code).toBe("NETWORK_ERROR"); expect(envelope.message).toContain("did not finish within 30 minutes"); expect(envelope.message).toContain('"archived"'); - expect(envelope.message).toContain(`rule create --resume ${REQUEST_ID}`); + expect(envelope.message).toContain(`rule create --resume=${REQUEST_ID}`); // 30 minutes of 15-second polls, then the deadline. expect(calls(fetchMock, "GET", "/cli/api/v2/request/")).toBe(120); }); @@ -403,7 +403,7 @@ describe("rule create: transient failures while polling and fetching", () => { expect(envelope.message).toContain("did not finish within 30 minutes"); expect(envelope.message).toContain('(last status: "building")'); expect(envelope.message).toContain("may still complete"); - expect(envelope.message).toContain(`rule create --resume ${REQUEST_ID}`); + expect(envelope.message).toContain(`rule create --resume=${REQUEST_ID}`); expect(calls(fetchMock, "GET", "/cli/api/v2/request/")).toBe(120); expect(existsSync(ruleFile())).toBe(false); }); @@ -426,7 +426,7 @@ describe("rule create: transient failures while polling and fetching", () => { token: "test-token", repositoryUrl: "https://github.com/test/test", onProgress: (message) => progress.push(message), - resumeCommand: `taskless rule create --resume ${REQUEST_ID}`, + resumeCommand: `taskless rule create --resume=${REQUEST_ID}`, deadlineMs: 45_000, now, }, diff --git a/skills/taskless/SKILL.md b/skills/taskless/SKILL.md index 823ecde85..8fb09ce6e 100644 --- a/skills/taskless/SKILL.md +++ b/skills/taskless/SKILL.md @@ -181,7 +181,7 @@ and follow the copy it returns. A long recipe prints its steps and ends with a list of sections it serves on request. When a step names one, print it with -`%(TASKLESS_CLI)s agent --section ` before you act on that step. +`%(TASKLESS_CLI)s agent --section=` before you act on that step. It is part of the same recipe, so do not skip it or work from memory instead. ## Run each Taskless command on its own From 2b5679bc397a224cea38e194fba98e96da21b2b8 Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sat, 5 Dec 2026 17:00:30 -0800 Subject: [PATCH 3/6] chore(changeset): minor, for value flags that take their value only after = --- .changeset/check-diff-scope.md | 4 +++- openspec/changes/value-flags-equals-only/tasks.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.changeset/check-diff-scope.md b/.changeset/check-diff-scope.md index bad21a5ce..b4d81bbe9 100644 --- a/.changeset/check-diff-scope.md +++ b/.changeset/check-diff-scope.md @@ -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=`; 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. diff --git a/openspec/changes/value-flags-equals-only/tasks.md b/openspec/changes/value-flags-equals-only/tasks.md index 227282aea..8f0e69d38 100644 --- a/openspec/changes/value-flags-equals-only/tasks.md +++ b/openspec/changes/value-flags-equals-only/tasks.md @@ -11,4 +11,4 @@ ## 3. Release -- [ ] 3.1 Grow the stack's changeset to `minor`, stating what callers must change; run `pnpm typecheck`, `pnpm lint` and the full suite, all passing +- [x] 3.1 Grow the stack's changeset to `minor`, stating what callers must change; run `pnpm typecheck`, `pnpm lint` and the full suite, all passing From 72ac818e885ef3527002ba10c98047c89c6c3c0a Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sat, 5 Dec 2026 17:00:40 -0800 Subject: [PATCH 4/6] docs(openspec): archive value-flags-equals-only --- .../.openspec.yaml | 0 .../design.md | 0 .../proposal.md | 0 .../specs/analytics/spec.md | 0 .../specs/cli-agent/spec.md | 0 .../specs/cli-ast/spec.md | 0 .../specs/cli-check/spec.md | 0 .../specs/cli-detect/spec.md | 0 .../specs/cli-feedback-survey/spec.md | 0 .../specs/cli-init/spec.md | 0 .../specs/cli-onboard/spec.md | 0 .../specs/cli-project-launcher/spec.md | 0 .../specs/cli-report/spec.md | 0 .../specs/cli-rule-reconciliation/spec.md | 0 .../specs/cli-rules/spec.md | 0 .../specs/cli-runtime-rule-execution/spec.md | 0 .../specs/cli/spec.md | 0 .../tasks.md | 0 openspec/specs/analytics/spec.md | 2 +- openspec/specs/cli-agent/spec.md | 18 +++--- openspec/specs/cli-ast/spec.md | 8 +-- openspec/specs/cli-check/spec.md | 28 ++++----- openspec/specs/cli-detect/spec.md | 4 +- openspec/specs/cli-feedback-survey/spec.md | 4 +- openspec/specs/cli-init/spec.md | 6 +- openspec/specs/cli-onboard/spec.md | 4 +- openspec/specs/cli-project-launcher/spec.md | 2 +- openspec/specs/cli-report/spec.md | 16 ++--- .../specs/cli-rule-reconciliation/spec.md | 2 +- openspec/specs/cli-rules/spec.md | 34 +++++------ .../specs/cli-runtime-rule-execution/spec.md | 4 +- openspec/specs/cli/spec.md | 58 +++++++++++++++++-- 32 files changed, 119 insertions(+), 71 deletions(-) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/.openspec.yaml (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/design.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/proposal.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/analytics/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-agent/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-ast/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-check/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-detect/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-feedback-survey/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-init/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-onboard/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-project-launcher/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-report/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-rule-reconciliation/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-rules/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli-runtime-rule-execution/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/specs/cli/spec.md (100%) rename openspec/changes/{value-flags-equals-only => archive/2026-12-05-value-flags-equals-only}/tasks.md (100%) diff --git a/openspec/changes/value-flags-equals-only/.openspec.yaml b/openspec/changes/archive/2026-12-05-value-flags-equals-only/.openspec.yaml similarity index 100% rename from openspec/changes/value-flags-equals-only/.openspec.yaml rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/.openspec.yaml diff --git a/openspec/changes/value-flags-equals-only/design.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/design.md similarity index 100% rename from openspec/changes/value-flags-equals-only/design.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/design.md diff --git a/openspec/changes/value-flags-equals-only/proposal.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/proposal.md similarity index 100% rename from openspec/changes/value-flags-equals-only/proposal.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/proposal.md diff --git a/openspec/changes/value-flags-equals-only/specs/analytics/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/analytics/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/analytics/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/analytics/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-agent/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-agent/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-agent/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-agent/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-ast/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-ast/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-ast/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-ast/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-check/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-check/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-check/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-check/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-detect/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-detect/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-detect/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-detect/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-feedback-survey/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-feedback-survey/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-feedback-survey/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-feedback-survey/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-init/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-init/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-init/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-init/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-onboard/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-onboard/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-onboard/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-onboard/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-project-launcher/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-project-launcher/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-project-launcher/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-project-launcher/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-report/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-report/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-report/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-report/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-rule-reconciliation/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-rule-reconciliation/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-rule-reconciliation/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-rule-reconciliation/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-rules/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-rules/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-rules/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-rules/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli-runtime-rule-execution/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-runtime-rule-execution/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli-runtime-rule-execution/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli-runtime-rule-execution/spec.md diff --git a/openspec/changes/value-flags-equals-only/specs/cli/spec.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli/spec.md similarity index 100% rename from openspec/changes/value-flags-equals-only/specs/cli/spec.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/specs/cli/spec.md diff --git a/openspec/changes/value-flags-equals-only/tasks.md b/openspec/changes/archive/2026-12-05-value-flags-equals-only/tasks.md similarity index 100% rename from openspec/changes/value-flags-equals-only/tasks.md rename to openspec/changes/archive/2026-12-05-value-flags-equals-only/tasks.md diff --git a/openspec/specs/analytics/spec.md b/openspec/specs/analytics/spec.md index a954a825f..c83261059 100644 --- a/openspec/specs/analytics/spec.md +++ b/openspec/specs/analytics/spec.md @@ -189,7 +189,7 @@ 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 +- **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` diff --git a/openspec/specs/cli-agent/spec.md b/openspec/specs/cli-agent/spec.md index 4e047f127..1eb1a3be5 100644 --- a/openspec/specs/cli-agent/spec.md +++ b/openspec/specs/cli-agent/spec.md @@ -8,7 +8,7 @@ Defines the `agent` subcommand for the `@taskless/cli` package, including recipe ### Requirement: Agent subcommand serves recipes for commands -The CLI SHALL support an `agent` subcommand that accepts at most one positional argument identifying a topic, an optional `--anonymous` boolean flag, an optional `--tool ` value flag, an optional `--section ` value flag, AND an optional `--full` boolean flag. Topics SHALL be addressed by a single token; the subcommand SHALL NOT join multiple positionals into a topic key. When a topic is provided, the subcommand SHALL look up a matching recipe file embedded at build time using the following resolution order: +The CLI SHALL support an `agent` subcommand that accepts at most one positional argument identifying a topic, an optional `--anonymous` boolean flag, an optional `--tool=` value flag, an optional `--section=` value flag, AND an optional `--full` boolean flag. Topics SHALL be addressed by a single token; the subcommand SHALL NOT join multiple positionals into a topic key. When a topic is provided, the subcommand SHALL look up a matching recipe file embedded at build time using the following resolution order: 1. If `--tool` is set AND `..md` exists in the embedded map, return that file. 2. If `--anonymous` is set AND `.anonymous.md` exists in the embedded map, return that file. @@ -17,7 +17,7 @@ The CLI SHALL support an `agent` subcommand that accepts at most one positional On a topic that has tool variants, `--tool` SHALL refuse, with a non-zero exit and a message naming the recipe to use instead, a tool that has its own authoring recipe (`ast-grep`, `vale`) or that cannot hold a rule (`prettier`, `black`). An unrecognized tool name SHALL fall back to `.md`. -Which part of the resolved recipe is printed is governed by the requirement "Long topics are served as an outline with sections on request": by default its outline, with `--section` one section, with `--full` all of it. A second positional SHALL NOT be read as a section name; the error for it SHALL name `--section `. +Which part of the resolved recipe is printed is governed by the requirement "Long topics are served as an outline with sections on request": by default its outline, with `--section` one section, with `--full` all of it. A second positional SHALL NOT be read as a section name; the error for it SHALL name `--section=`. When no positional argument is provided, the subcommand SHALL print a topic index containing a one-paragraph human slug followed by a topic disambiguation table mapping topic names to their summaries. @@ -98,7 +98,7 @@ Every recipe file at `packages/cli/src/agent/.md` SHALL follow the canoni #### Scenario: Recipe with --from input includes JSON schema placeholder -- **WHEN** a topic recipe documents a CLI invocation that uses `--from ` +- **WHEN** a topic recipe documents a CLI invocation that uses `--from=` - **THEN** the recipe SHALL contain an `## Input schema` section with a code-fenced block containing the `%(INPUT_SCHEMA)s` placeholder - **AND** the JSON Schema SHALL be derived at render time from the corresponding Zod schema in `packages/cli/src/schemas/` @@ -256,7 +256,7 @@ The `agent` command SHALL construct, at build time, a Set of topic names that ha ### Requirement: Embedded JSON schemas are generated via zod-to-json-schema -For every recipe topic that documents a CLI command accepting `--from `, the corresponding Zod input schema in `packages/cli/src/schemas/` SHALL be converted to JSON Schema and embedded in the recipe's `## Input schema` section as a fenced code block. Generation MAY happen at runtime (small dep, fast) or at build time; runtime is acceptable. +For every recipe topic that documents a CLI command accepting `--from=`, the corresponding Zod input schema in `packages/cli/src/schemas/` SHALL be converted to JSON Schema and embedded in the recipe's `## Input schema` section as a fenced code block. Generation MAY happen at runtime (small dep, fast) or at build time; runtime is acceptable. #### Scenario: The remote authoring recipe embeds its input schema @@ -700,9 +700,9 @@ The `init` recipe SHALL document the `telemetry` field of the `init --json` enve A recipe's `## ` headings outside fenced blocks SHALL divide it into sections, and everything before the first is its preamble: the header block and the one-command-per-call paragraph. Each section SHALL be addressable by the slug of its heading: lowercase, every run of characters other than letters and digits collapsed to one hyphen, with none leading or trailing. An author SHALL mark a section to be served on request by writing `` on the line directly above its heading. The marker SHALL be removed from every rendering, and a marker not directly above a `## ` heading SHALL fail when the recipes load. -`taskless agent ` SHALL print the topic's outline: the preamble and every section not marked on demand, in order, then a `## Sections on request` section naming each section it left out and the command that prints one, ` agent --section `, spelled with the `--tool` or `--anonymous` flag that selected the recipe. A recipe with no section marked on demand SHALL print unchanged. `taskless onboard` and `taskless update` (without `--rules`) SHALL print the same outline as `agent onboard` and `agent update`. +`taskless agent ` SHALL print the topic's outline: the preamble and every section not marked on demand, in order, then a `## Sections on request` section naming each section it left out and the command that prints one, ` agent --section=`, spelled with the `--tool` or `--anonymous` flag that selected the recipe. A recipe with no section marked on demand SHALL print unchanged. `taskless onboard` and `taskless update` (without `--rules`) SHALL print the same outline as `agent onboard` and `agent update`. -`--section ` SHALL print the preamble, that one section, and a closing line naming the command that prints the topic's outline. A name the topic has no section for SHALL exit 1 and list the topic's section names. `--full` SHALL print the whole recipe, identical to what `@taskless/cli/prompts` renders for the same options with the directive requested. The `@taskless/cli/prompts` export SHALL render the whole recipe. +`--section=` SHALL print the preamble, that one section, and a closing line naming the command that prints the topic's outline. A name the topic has no section for SHALL exit 1 and list the topic's section names. `--full` SHALL print the whole recipe, identical to what `@taskless/cli/prompts` renders for the same options with the directive requested. The `@taskless/cli/prompts` export SHALL render the whole recipe. A cross-reference to another section of the same recipe SHALL be written as a markdown link to its name, `[Quirks](#quirks)`. The whole recipe SHALL keep the link. The outline and a section SHALL rewrite a link to a section they do not print as that section's name. A cross-reference to a section of another topic SHALL be written as the command that prints it. @@ -719,13 +719,13 @@ A section fetch SHALL capture `cli_agent` with `topic` and `section`, and SHALL #### Scenario: One section is printed -- **WHEN** a user runs `taskless agent create-sg-rule --section quirks` +- **WHEN** a user runs `taskless agent create-sg-rule --section=quirks` - **THEN** stdout SHALL begin with the recipe's header block and one-command-per-call paragraph - **AND** SHALL contain the `## Quirks` section and no other section #### Scenario: An unknown section is refused -- **WHEN** a user runs `taskless agent create-sg-rule --section nope` +- **WHEN** a user runs `taskless agent create-sg-rule --section=nope` - **THEN** the CLI SHALL exit 1 and list the topic's section names on stderr #### Scenario: The whole recipe is printed on request @@ -752,7 +752,7 @@ A section fetch SHALL capture `cli_agent` with `topic` and `section`, and SHALL #### Scenario: A section fetch is told apart in telemetry -- **WHEN** a user runs `taskless agent create-sg-rule --section quirks` +- **WHEN** a user runs `taskless agent create-sg-rule --section=quirks` - **THEN** PostHog SHALL receive `cli_agent` with `topic: "create-sg-rule"` and `section: "quirks"` - **AND** stdout SHALL NOT carry the feedback invite diff --git a/openspec/specs/cli-ast/spec.md b/openspec/specs/cli-ast/spec.md index f860916f4..644a6b7b3 100644 --- a/openspec/specs/cli-ast/spec.md +++ b/openspec/specs/cli-ast/spec.md @@ -8,7 +8,7 @@ The `taskless ast` subcommand: a read-only dump of one file's named-node syntax ### Requirement: The ast command prints a file's named-node AST -The CLI SHALL provide `taskless ast `, which prints the named-node syntax tree of one file as the ast-grep bundled with the CLI parses it. It SHALL print named nodes only, so that every kind it shows is one a rule's `kind:` accepts. Each node SHALL carry its kind, the field it fills in its parent when the grammar names one, and its start and end as a 1-based line and a 0-based byte column. A node with no named children SHALL carry its source text. The command SHALL read the file and write nothing, and SHALL NOT require `.taskless/` to exist. It SHALL accept `--dir`/`-d`, against which a relative file path resolves. +The CLI SHALL provide `taskless ast `, which prints the named-node syntax tree of one file as the ast-grep bundled with the CLI parses it. It SHALL print named nodes only, so that every kind it shows is one a rule's `kind:` accepts. Each node SHALL carry its kind, the field it fills in its parent when the grammar names one, and its start and end as a 1-based line and a 0-based byte column. A node with no named children SHALL carry its source text. The command SHALL read the file and write nothing, and SHALL NOT require `.taskless/` to exist. It SHALL accept `--dir`, against which a relative file path resolves. #### Scenario: A file is dumped by its extension @@ -35,16 +35,16 @@ Without `--lang`, the command SHALL parse the file as the language the bundled a #### Scenario: A language override -- **WHEN** `taskless ast list.txt --lang yaml` is run +- **WHEN** `taskless ast list.txt --lang=yaml` is run - **THEN** the file SHALL be parsed as `Yaml` ### Requirement: The ast command can cut the tree to a line range -`--range ` or `--range :`, 1-based and inclusive, SHALL cut the tree to the nodes whose lines overlap the range, keeping the nodes that enclose them. A node that ends at column 0 of a line SHALL NOT count as on that line. A range that no node touches, and a malformed range, SHALL fail with `INVALID_INPUT`. +`--range=` or `--range=:`, 1-based and inclusive, SHALL cut the tree to the nodes whose lines overlap the range, keeping the nodes that enclose them. A node that ends at column 0 of a line SHALL NOT count as on that line. A range that no node touches, and a malformed range, SHALL fail with `INVALID_INPUT`. #### Scenario: One line of a file -- **WHEN** a file's third line is `foo(b);` and `taskless ast --range 3` is run +- **WHEN** a file's third line is `foo(b);` and `taskless ast --range=3` is run - **THEN** the root SHALL keep only the `expression_statement` on line 3 among its children ### Requirement: The ast command reports what it cannot dump diff --git a/openspec/specs/cli-check/spec.md b/openspec/specs/cli-check/spec.md index d6ef6ff6a..d4c7a5a5d 100644 --- a/openspec/specs/cli-check/spec.md +++ b/openspec/specs/cli-check/spec.md @@ -209,21 +209,21 @@ On an authenticated run that would reconcile, the CLI SHALL also exit with code ### Requirement: Check subcommand respects global working directory flag -The `check` subcommand SHALL use the resolved working directory from the global `-d` flag (or `process.cwd()` if not specified) as the target directory for `.taskless/` validation and scanner execution. +The `check` subcommand SHALL use the resolved working directory from the global `--dir` flag (or `process.cwd()` if not specified) as the target directory for `.taskless/` validation and scanner execution. #### Scenario: Check uses custom directory -- **WHEN** a user runs `taskless check -d /path/to/repo` +- **WHEN** a user runs `taskless check --dir=/path/to/repo` - **THEN** `.taskless/` validation and scanning SHALL operate on `/path/to/repo` #### Scenario: Check defaults to current directory -- **WHEN** a user runs `taskless check` without `-d` +- **WHEN** a user runs `taskless check` without `--dir` - **THEN** `.taskless/` validation and scanning SHALL operate on `process.cwd()` ### Requirement: Check accepts positional path arguments -The `check` subcommand SHALL accept zero or more positional path arguments. When zero paths are passed, the CLI SHALL scan the full project directory (existing behavior). When one or more paths are passed, the CLI SHALL forward those paths to `sg scan` so that only the specified files and directories are scanned. Paths SHALL be treated relative to the resolved working directory (`-d` / `process.cwd()`). +The `check` subcommand SHALL accept zero or more positional path arguments. When zero paths are passed, the CLI SHALL scan the full project directory (existing behavior). When one or more paths are passed, the CLI SHALL forward those paths to `sg scan` so that only the specified files and directories are scanned. Paths SHALL be treated relative to the resolved working directory (`--dir` / `process.cwd()`). Before forwarding, the CLI SHALL silently drop any path that does not exist on disk at invocation time. This lets CI pipelines pipe raw git-diff output directly (e.g. `taskless check $(git diff --name-only main...HEAD)`) without pre-filtering deleted files. If every supplied path is filtered out and the original argument list was non-empty, the CLI SHALL exit with code 0 and print no matches (interpreted as "nothing changed, nothing to scan"). @@ -257,7 +257,7 @@ Before forwarding, the CLI SHALL silently drop any path that does not exist on d #### Scenario: Relative paths resolve against the working directory -- **WHEN** a user runs `taskless check -d /path/to/project src/foo.ts` +- **WHEN** a user runs `taskless check --dir=/path/to/project src/foo.ts` - **AND** `/path/to/project/src/foo.ts` exists - **THEN** the CLI SHALL treat `src/foo.ts` as relative to `/path/to/project` - **AND** SHALL forward that relative path to `sg scan` with `cwd = /path/to/project` @@ -510,7 +510,7 @@ the only way to execute runtime rules on an unverified path. ### Requirement: Check restricts the run to named rules with --rule -The `check` subcommand SHALL accept a `--rule ` flag, repeatable, naming the rules the run is restricted to. When `--rule` is absent the run SHALL be unchanged. When one or more are given, the CLI SHALL report findings only for the named rules, and for each named rule SHALL report exactly what an unfiltered `check` over the same paths would have reported for it: the same walk, the same exclusions (`.taskless/`, `.git/`, git-ignored paths, converter-dependent formats), and the same per-rule scope. +The `check` subcommand SHALL accept a `--rule=` flag, repeatable, naming the rules the run is restricted to. When `--rule` is absent the run SHALL be unchanged. When one or more are given, the CLI SHALL report findings only for the named rules, and for each named rule SHALL report exactly what an unfiltered `check` over the same paths would have reported for it: the same walk, the same exclusions (`.taskless/`, `.git/`, git-ignored paths, converter-dependent formats), and the same per-rule scope. A rule id is the name of a rule's directory under `.taskless/rules//`. The filter SHALL apply to every engine. An id whose rule directory exists under more than one engine SHALL select the rule under each of them. An id that names no rule directory under any engine SHALL be refused: the CLI SHALL exit with code 1 and report the error code `RULE_NOT_FOUND` naming the unresolved id, and SHALL NOT run any engine. @@ -518,13 +518,13 @@ A rule id is the name of a rule's directory under `.taskless/rules//`. T #### Scenario: A single --rule narrows the run to that rule -- **WHEN** a user runs `taskless check --rule ` in a project with rules beyond `` +- **WHEN** a user runs `taskless check --rule=` in a project with rules beyond `` - **THEN** the results SHALL contain findings for `` only - **AND** they SHALL be the findings an unfiltered `taskless check` reports for `` #### Scenario: Repeated --rule unions the named rules -- **WHEN** a user runs `taskless check --rule a --rule b` +- **WHEN** a user runs `taskless check --rule=a --rule=b` - **THEN** the results SHALL contain the findings for `a` and the findings for `b`, and no others #### Scenario: The filter applies to both static engines @@ -535,36 +535,36 @@ A rule id is the name of a rule's directory under `.taskless/rules//`. T #### Scenario: Whole-project exclusions still apply under --rule -- **WHEN** a user runs `taskless check --rule ` with no positional paths in a project with git-ignored directories +- **WHEN** a user runs `taskless check --rule=` with no positional paths in a project with git-ignored directories - **THEN** the CLI SHALL NOT report findings from `.taskless/`, `.git/`, or git-ignored paths #### Scenario: A refused sibling config refuses a filtered run too -- **WHEN** a user runs `taskless check --rule ` in a project where a DIFFERENT Vale rule's config is rejected by the config schema +- **WHEN** a user runs `taskless check --rule=` in a project where a DIFFERENT Vale rule's config is rejected by the config schema - **THEN** the CLI SHALL refuse the Vale engine and exit non-zero, exactly as an unfiltered `taskless check` does - **AND** the refusal SHALL name the rejected rule even though `--rule` did not select it #### Scenario: An unknown rule id is refused -- **WHEN** a user runs `taskless check --rule ` and no engine directory holds a rule directory named `` +- **WHEN** a user runs `taskless check --rule=` and no engine directory holds a rule directory named `` - **THEN** the CLI SHALL exit with code 1 - **AND** under `--json` stdout SHALL carry the standardized error envelope with code `RULE_NOT_FOUND` and a message naming `` - **AND** the CLI SHALL NOT run any engine #### Scenario: An id held by two engines selects both rules -- **WHEN** a user runs `taskless check --rule ` and `` names a rule directory under two engines +- **WHEN** a user runs `taskless check --rule=` and `` names a rule directory under two engines - **THEN** the CLI SHALL run both rules and SHALL report the findings of each, distinguished by the `source` field #### Scenario: --rule does not bypass the runtime signature gate -- **WHEN** a user runs `taskless check --rule ` where `` is a runtime rule and the run is on an unverified path +- **WHEN** a user runs `taskless check --rule=` where `` is a runtime rule and the run is on an unverified path - **THEN** the CLI SHALL NOT execute that rule's `check.ts` - **AND** SHALL report it as skipped exactly as an unfiltered `check` would #### Scenario: --rule leaves positional path arguments intact -- **WHEN** a user runs `taskless check --rule src/foo.ts` +- **WHEN** a user runs `taskless check --rule= src/foo.ts` - **THEN** the CLI SHALL treat `src/foo.ts` as the path to scan and `` as the rule filter - **AND** SHALL NOT treat `` as a path diff --git a/openspec/specs/cli-detect/spec.md b/openspec/specs/cli-detect/spec.md index 05e0da85a..a4dc1535d 100644 --- a/openspec/specs/cli-detect/spec.md +++ b/openspec/specs/cli-detect/spec.md @@ -9,14 +9,14 @@ The `taskless detect` subcommand: an offline, deterministic read of a repository ### Requirement: Detect subcommand exists The CLI SHALL provide a `taskless detect` subcommand registered in the top-level -command list, with a `--json` flag and the standard `--dir`/`-d` working-directory +command list, with a `--json` flag and the standard `--dir` working-directory flag. #### Scenario: Detect is registered - **WHEN** `taskless detect --help` is run - **THEN** the command SHALL be recognized and print its usage -- **AND** the command SHALL accept `--json` and `--dir`/`-d` +- **AND** the command SHALL accept `--json` and `--dir` ### Requirement: Detect scans deterministic repo signals only diff --git a/openspec/specs/cli-feedback-survey/spec.md b/openspec/specs/cli-feedback-survey/spec.md index f9fee506e..241440400 100644 --- a/openspec/specs/cli-feedback-survey/spec.md +++ b/openspec/specs/cli-feedback-survey/spec.md @@ -33,7 +33,7 @@ The CLI SHALL keep the survey cadence at `/surveys/ ### Requirement: The feedback subcommand records dismissals and sends responses -The CLI SHALL provide a `feedback` subcommand with two verbs. `feedback dismiss` SHALL capture `survey dismissed` with the rule survey's `$survey_id` and advance that survey's `next_ask`. `feedback send --from ` SHALL read a JSON file, validate it against the feedback payload schema, and capture `survey sent` with the `$survey_id` of the survey the payload's `kind` selects; for a `rule` payload it SHALL also advance `next_ask`. Both verbs SHALL accept `--dir`. Neither SHALL require `.taskless/` to exist, run migrations, or write into the project. `feedback send` SHALL NOT delete its input file. +The CLI SHALL provide a `feedback` subcommand with two verbs. `feedback dismiss` SHALL capture `survey dismissed` with the rule survey's `$survey_id` and advance that survey's `next_ask`. `feedback send --from=` SHALL read a JSON file, validate it against the feedback payload schema, and capture `survey sent` with the `$survey_id` of the survey the payload's `kind` selects; for a `rule` payload it SHALL also advance `next_ask`. Both verbs SHALL accept `--dir`. Neither SHALL require `.taskless/` to exist, run migrations, or write into the project. `feedback send` SHALL NOT delete its input file. When the telemetry client is disabled, `feedback dismiss` SHALL print a single line saying nothing was sent and exit zero. `feedback send` SHALL still validate the payload first, and on a valid payload SHALL send nothing, print that telemetry is disabled so nothing was sent, name `https://github.com/taskless/cli/issues` as the place to report instead, and exit zero. @@ -47,7 +47,7 @@ The `taskless agent` topic index SHALL list `feedback` and `bug-report` and SHAL #### Scenario: Send a valid payload -- **WHEN** an agent runs `taskless feedback send --from .taskless/.tmp-feedback.json` with a payload that passes validation +- **WHEN** an agent runs `taskless feedback send --from=.taskless/.tmp-feedback.json` with a payload that passes validation - **THEN** PostHog SHALL receive `survey sent` carrying the `$survey_id` for the payload's `kind` and one `$survey_response_` per answered question, and no other survey-specific property - **AND** the command SHALL exit zero and leave the input file in place diff --git a/openspec/specs/cli-init/spec.md b/openspec/specs/cli-init/spec.md index e1b478197..6a352cd9d 100644 --- a/openspec/specs/cli-init/spec.md +++ b/openspec/specs/cli-init/spec.md @@ -309,16 +309,16 @@ The CLI build SHALL embed all skill file content from `skills/` into the compile ### Requirement: Init respects the global working directory flag -The `init` subcommand SHALL use the resolved working directory from the global `-d` flag (or `process.cwd()` if not specified) as the target directory for tool detection and skill installation. +The `init` subcommand SHALL use the resolved working directory from the global `--dir` flag (or `process.cwd()` if not specified) as the target directory for tool detection and skill installation. #### Scenario: Init uses custom directory -- **WHEN** a user runs `taskless init -d /path/to/repo` +- **WHEN** a user runs `taskless init --dir=/path/to/repo` - **THEN** tool detection and skill installation SHALL operate on `/path/to/repo` #### Scenario: Init defaults to current directory -- **WHEN** a user runs `taskless init` without `-d` +- **WHEN** a user runs `taskless init` without `--dir` - **THEN** tool detection and skill installation SHALL operate on `process.cwd()` ### Requirement: Bare taskless invocation launches the init wizard diff --git a/openspec/specs/cli-onboard/spec.md b/openspec/specs/cli-onboard/spec.md index 274310da1..b4bbb59bf 100644 --- a/openspec/specs/cli-onboard/spec.md +++ b/openspec/specs/cli-onboard/spec.md @@ -15,7 +15,7 @@ This capability covers: ### Requirement: Onboard subcommand exists with --force and --mark-complete flags -The CLI SHALL support a `taskless onboard` subcommand. The subcommand SHALL accept the global `-d` working-directory flag, a `--force` boolean flag (default `false`), and a `--mark-complete` boolean flag (default `false`). `--force` and `--mark-complete` SHALL be mutually exclusive; supplying both SHALL exit with code 1 and a clear error message. The subcommand SHALL bootstrap the `.taskless/` directory via `ensureTasklessDirectory()` before reading or writing manifest state. +The CLI SHALL support a `taskless onboard` subcommand. The subcommand SHALL accept the global `--dir` working-directory flag, a `--force` boolean flag (default `false`), and a `--mark-complete` boolean flag (default `false`). `--force` and `--mark-complete` SHALL be mutually exclusive; supplying both SHALL exit with code 1 and a clear error message. The subcommand SHALL bootstrap the `.taskless/` directory via `ensureTasklessDirectory()` before reading or writing manifest state. The subcommand SHALL NOT migrate `.taskless/`. In every mode, before bootstrapping, it SHALL refuse a scaffold whose schema version is below the latest migration with `SCAFFOLD_MIGRATION_REQUIRED`, and one whose version is above it with `SCAFFOLD_VERSION_MISMATCH`, exiting with code 1, printing the code on stderr, and naming the command that resolves it. Migrations move and delete tracked files, and `taskless init` is the command that runs them. A `.taskless/` that is absent SHALL still be created, since creating a fresh directory rewrites nothing. @@ -43,7 +43,7 @@ The subcommand SHALL NOT migrate `.taskless/`. In every mode, before bootstrappi #### Scenario: Onboard respects the global -d flag -- **WHEN** a user runs `taskless onboard -d /path/to/repo` +- **WHEN** a user runs `taskless onboard --dir=/path/to/repo` - **THEN** all manifest reads and writes SHALL operate on `/path/to/repo/.taskless/taskless.json` #### Scenario: Onboard refuses a scaffold that is behind the CLI diff --git a/openspec/specs/cli-project-launcher/spec.md b/openspec/specs/cli-project-launcher/spec.md index a036f5809..fbbb6908a 100644 --- a/openspec/specs/cli-project-launcher/spec.md +++ b/openspec/specs/cli-project-launcher/spec.md @@ -117,7 +117,7 @@ When a project launcher started the CLI, as its environment variable reports wit #### Scenario: A hint after a launcher run - **WHEN** `./.taskless/bin/cli.mjs check` runs in a project with no rules -- **THEN** the hint SHALL tell the reader to run `./.taskless/bin/cli.mjs rule create --from ` +- **THEN** the hint SHALL tell the reader to run `./.taskless/bin/cli.mjs rule create --from=` #### Scenario: A hint after an npx run diff --git a/openspec/specs/cli-report/spec.md b/openspec/specs/cli-report/spec.md index e695b2d42..59e91acd0 100644 --- a/openspec/specs/cli-report/spec.md +++ b/openspec/specs/cli-report/spec.md @@ -8,7 +8,7 @@ Defines `taskless report`: the command that turns a repository's Taskless rules, ### Requirement: Report subcommand exists with a draft mode, a publish mode, and delete -The CLI SHALL provide a `taskless report` subcommand accepting the standard `--dir`/`-d` working-directory flag. Invoked with no mode flag it SHALL print a draft. Invoked with `--from ` it SHALL publish. `taskless report --delete ` SHALL delete a previously published report. `--from` and `--delete` SHALL be mutually exclusive; supplying both SHALL exit non-zero with `INVALID_INPUT`. The subcommand SHALL require no authentication in any mode, and SHALL bootstrap `.taskless/` before reading or writing under it. +The CLI SHALL provide a `taskless report` subcommand accepting the standard `--dir` working-directory flag. Invoked with no mode flag it SHALL print a draft. Invoked with `--from=` it SHALL publish. `taskless report --delete=` SHALL delete a previously published report. `--from` and `--delete` SHALL be mutually exclusive; supplying both SHALL exit non-zero with `INVALID_INPUT`. The subcommand SHALL require no authentication in any mode, and SHALL bootstrap `.taskless/` before reading or writing under it. The subcommand SHALL NOT migrate `.taskless/`. In every mode, before bootstrapping, it SHALL refuse a scaffold whose schema version is below the latest migration with `SCAFFOLD_MIGRATION_REQUIRED`, and one whose version is above it with `SCAFFOLD_VERSION_MISMATCH`, exiting non-zero and reporting the code as it reports any other error: on stderr, or as the `{ ok: false, code, message }` envelope under `--json`. Migrations move and delete tracked files, and `taskless init` is the command that runs them. A `.taskless/` that is absent SHALL still be created, since creating a fresh directory rewrites nothing. @@ -19,12 +19,12 @@ The subcommand SHALL NOT migrate `.taskless/`. In every mode, before bootstrappi #### Scenario: Report works logged out -- **WHEN** a user who has never logged in runs `taskless report` or `taskless report --from ` +- **WHEN** a user who has never logged in runs `taskless report` or `taskless report --from=` - **THEN** the command SHALL NOT prompt for or require authentication #### Scenario: Report refuses a scaffold that is behind the CLI -- **WHEN** `.taskless/taskless.json` records a schema version below the latest migration and a user runs `taskless report`, `taskless report --from `, or `taskless report --delete ` +- **WHEN** `.taskless/taskless.json` records a schema version below the latest migration and a user runs `taskless report`, `taskless report --from=`, or `taskless report --delete=` - **THEN** the command SHALL exit non-zero with `SCAFFOLD_MIGRATION_REQUIRED`, naming `taskless init` - **AND** SHALL NOT print a draft, publish, or delete anything - **AND** SHALL leave every file under `.taskless/` as it was @@ -65,7 +65,7 @@ The draft SHALL NOT perform any network call. ### Requirement: The agent supplies session facts, not a report -`taskless report --from ` SHALL read a facts file, not a ReportV1. The facts file SHALL carry only what the agent knows from its session: the history counts and the window they were mined over, per-rule titles, an `explain` for every rule (the agent's take, in one or two sentences, on why the rule is worth holding in this codebase), and `surfaced` counts (the merged pull requests in the window whose review raised the rule's pattern, and the review comments that asked for it), optionally per-rule `sources` (the kinds of source the rule came from) and `evidence` (a count of explicit call-outs per kind), rules authored into an existing linter (`legacy` tier), runtime-shaped candidates the agent did not author (`cloud` tier) each with `estimatedViolations`, the agent's estimate of how many instances of the candidate's pattern are in the code today, the agent's own redaction counts, and the fixtures it elects to withhold. The facts file SHALL NOT accept any value input: no token, call, price, time, or rate estimate. The CLI SHALL merge the facts with what it establishes itself, and SHALL treat its own values as authoritative for every field it can establish. +`taskless report --from=` SHALL read a facts file, not a ReportV1. The facts file SHALL carry only what the agent knows from its session: the history counts and the window they were mined over, per-rule titles, an `explain` for every rule (the agent's take, in one or two sentences, on why the rule is worth holding in this codebase), and `surfaced` counts (the merged pull requests in the window whose review raised the rule's pattern, and the review comments that asked for it), optionally per-rule `sources` (the kinds of source the rule came from) and `evidence` (a count of explicit call-outs per kind), rules authored into an existing linter (`legacy` tier), runtime-shaped candidates the agent did not author (`cloud` tier) each with `estimatedViolations`, the agent's estimate of how many instances of the candidate's pattern are in the code today, the agent's own redaction counts, and the fixtures it elects to withhold. The facts file SHALL NOT accept any value input: no token, call, price, time, or rate estimate. The CLI SHALL merge the facts with what it establishes itself, and SHALL treat its own values as authoritative for every field it can establish. Every published rule SHALL carry a `state`. Rules under `.taskless/rules/` and `legacy` rules SHALL be `written`; `cloud` candidates from the facts file SHALL be `candidate`. @@ -233,7 +233,7 @@ On a 201 response the CLI SHALL write `.taskless/reports/.jso - **WHEN** a publish succeeds and `.taskless/reports/2026-10-13_142200.json` already exists for the same second - **THEN** the record SHALL be written as `2026-10-13_142200_2.json` - **AND** the existing record SHALL be unchanged -- **AND** `taskless report --delete 2026-10-13_142200_2.json` SHALL accept it +- **AND** `taskless report --delete=2026-10-13_142200_2.json` SHALL accept it #### Scenario: A record that cannot be written keeps the credential @@ -285,11 +285,11 @@ On a 201 response the CLI SHALL write `.taskless/reports/.jso ### Requirement: A published report can be deleted from its record -`taskless report --delete ` SHALL read the named record under `.taskless/reports/`, delete the report by sending an HTTP `DELETE` to the recorded `deleteUrl`, the URL tskl.es returned for that purpose, and on a 204 remove the record and print a one-line confirmation that says cached copies may be served for up to a day, as the tskl.es delete contract states. A 404 (`not_available`: never issued, already deleted, expired, or not yet propagated) SHALL exit non-zero with `REPORT_NOT_AVAILABLE`, SHALL NOT be retried, and SHALL keep the record. A record named outside `.taskless/reports/`, or not a `.json` file, SHALL exit non-zero with `INVALID_INPUT` without reading or removing it. A record that does not exist SHALL exit non-zero with `REPORT_NOT_FOUND`. A failed delete SHALL leave the record in place. +`taskless report --delete=` SHALL read the named record under `.taskless/reports/`, delete the report by sending an HTTP `DELETE` to the recorded `deleteUrl`, the URL tskl.es returned for that purpose, and on a 204 remove the record and print a one-line confirmation that says cached copies may be served for up to a day, as the tskl.es delete contract states. A 404 (`not_available`: never issued, already deleted, expired, or not yet propagated) SHALL exit non-zero with `REPORT_NOT_AVAILABLE`, SHALL NOT be retried, and SHALL keep the record. A record named outside `.taskless/reports/`, or not a `.json` file, SHALL exit non-zero with `INVALID_INPUT` without reading or removing it. A record that does not exist SHALL exit non-zero with `REPORT_NOT_FOUND`. A failed delete SHALL leave the record in place. #### Scenario: Deleting a report -- **WHEN** a user runs `taskless report --delete 2026-10-13_142200.json` and the service confirms the deletion +- **WHEN** a user runs `taskless report --delete=2026-10-13_142200.json` and the service confirms the deletion - **THEN** the record SHALL be removed - **AND** the command SHALL print a confirmation and exit 0 @@ -302,7 +302,7 @@ On a 201 response the CLI SHALL write `.taskless/reports/.jso #### Scenario: A record outside the records directory is refused -- **WHEN** a user runs `taskless report --delete ../notes.json` +- **WHEN** a user runs `taskless report --delete=../notes.json` - **THEN** the command SHALL exit non-zero with `INVALID_INPUT` - **AND** SHALL send no request and remove no file diff --git a/openspec/specs/cli-rule-reconciliation/spec.md b/openspec/specs/cli-rule-reconciliation/spec.md index cb09a4ef3..e5325ce53 100644 --- a/openspec/specs/cli-rule-reconciliation/spec.md +++ b/openspec/specs/cli-rule-reconciliation/spec.md @@ -216,7 +216,7 @@ envelope of the snapshot's bytes for that file. #### Scenario: --rule does not narrow the report -- **WHEN** a user runs `check --rule a` in a project holding rules `a` and `b` +- **WHEN** a user runs `check --rule=a` in a project holding rules `a` and `b` - **THEN** the reconcile request SHALL report both `a` and `b` - **AND** only `a` SHALL run diff --git a/openspec/specs/cli-rules/spec.md b/openspec/specs/cli-rules/spec.md index 71b84357b..e3dd2828b 100644 --- a/openspec/specs/cli-rules/spec.md +++ b/openspec/specs/cli-rules/spec.md @@ -14,22 +14,22 @@ The previous plural form `taskless rules ` SHALL NOT work in v0.7.0 #### Scenario: Singular subcommand registers correctly -- **WHEN** a user runs `taskless rule create --from req.json` +- **WHEN** a user runs `taskless rule create --from=req.json` - **THEN** the CLI SHALL invoke the rule-create handler #### Scenario: Plural subcommand is no longer recognized -- **WHEN** a user runs `taskless rules create --from req.json` +- **WHEN** a user runs `taskless rules create --from=req.json` - **THEN** the CLI SHALL exit with an error indicating the subcommand is unknown - **AND** the error message SHOULD suggest `taskless rule create` ### Requirement: Rules create reads request from stdin -The `taskless rule create` command SHALL accept a `--from ` flag specifying a JSON file containing the rule request. (Note: previously named `rules create`; renamed to singular.) +The `taskless rule create` command SHALL accept a `--from=` flag specifying a JSON file containing the rule request. (Note: previously named `rules create`; renamed to singular.) #### Scenario: rule create with --from file -- **WHEN** a user runs `taskless rule create --from .taskless/.tmp-rule-request.json --json` +- **WHEN** a user runs `taskless rule create --from=.taskless/.tmp-rule-request.json --json` - **THEN** the CLI SHALL read the JSON file and submit it to the API ### Requirement: Rules create resolves identity from JWT and git remote @@ -73,12 +73,12 @@ When the git remote cannot yield a GitHub repository URL, the command SHALL fail #### Scenario: rule create without --anonymous requires auth -- **WHEN** a user runs `taskless rule create --from req.json` without being logged in +- **WHEN** a user runs `taskless rule create --from=req.json` without being logged in - **THEN** the CLI SHALL exit with code 1 and an `AUTH_REQUIRED` error #### Scenario: rule create --anonymous skips auth -- **WHEN** a user runs `taskless rule create --from req.json --anonymous` without being logged in +- **WHEN** a user runs `taskless rule create --from=req.json --anonymous` without being logged in - **THEN** the CLI SHALL invoke the local-only flow without checking auth ### Requirement: Rules create submits to API and polls for results @@ -179,7 +179,7 @@ nothing. - **WHEN** polling answers a retryable failure 8 times in a row - **THEN** the CLI SHALL fail with `NETWORK_ERROR` - **AND** the message SHALL name the request id, say it may still complete, and name - `taskless rule --resume ` + `taskless rule --resume=` #### Scenario: An answer in between resets the count @@ -198,7 +198,7 @@ nothing. ### Requirement: Rules create and improve resume a submitted request -`taskless rule create` and `taskless rule improve` SHALL accept `--resume `, the request +`taskless rule create` and `taskless rule improve` SHALL accept `--resume=`, the request id a previous run of the same command printed. With it, the CLI SHALL NOT submit anything: it SHALL poll that request and fetch, verify, and write what it produced exactly as it would have after submitting it, and SHALL report the same output, with `requestId` set to the resumed id. @@ -210,18 +210,18 @@ invalid response body and SHALL NOT be printed. #### Scenario: A resumed request is not resubmitted -- **WHEN** a user runs `taskless rule create --resume ` after a run that gave up on it +- **WHEN** a user runs `taskless rule create --resume=` after a run that gave up on it - **THEN** the CLI SHALL poll `GET /cli/api/v2/request/{requestId}` and write the produced rules - **AND** SHALL NOT call `POST /cli/api/v2/request` #### Scenario: Improve resumes without iterating again -- **WHEN** a user runs `taskless rule improve --resume ` +- **WHEN** a user runs `taskless rule improve --resume=` - **THEN** the CLI SHALL NOT call `POST /cli/api/v2/rule/{ruleId}/iterate` #### Scenario: --resume with --from is refused -- **WHEN** a user runs `taskless rule create --resume --from req.json` +- **WHEN** a user runs `taskless rule create --resume= --from=req.json` - **THEN** the CLI SHALL fail with `INVALID_INPUT` without calling the service #### Scenario: A server-authored request id is never put on a command line @@ -232,18 +232,18 @@ invalid response body and SHALL NOT be printed. #### Scenario: A rule id is not a request id -- **WHEN** a user runs `taskless rule improve --resume no-eval-3fa9c21b` +- **WHEN** a user runs `taskless rule improve --resume=no-eval-3fa9c21b` - **THEN** the CLI SHALL fail with `INVALID_INPUT` without calling the service ### Requirement: Rules improve reads request from file -`taskless rule improve` SHALL accept a `--from ` flag specifying a JSON file containing the +`taskless rule improve` SHALL accept a `--from=` flag specifying a JSON file containing the iterate request `{ ruleId, guidance, references? }`, where `ruleId` is the rule's directory name under `.taskless/rules//`, the id v2 addresses a rule by. (Renamed to singular.) #### Scenario: The request is read from the named file -- **WHEN** a user runs `taskless rule improve --from request.json` +- **WHEN** a user runs `taskless rule improve --from=request.json` - **THEN** the CLI SHALL read the iterate request from that file #### Scenario: The rule id is the directory name @@ -422,7 +422,7 @@ When `taskless rule create --anonymous` is invoked, the CLI SHALL execute the lo #### Scenario: rule create --anonymous skips API -- **WHEN** a user runs `taskless rule create --from req.json --anonymous` +- **WHEN** a user runs `taskless rule create --from=req.json --anonymous` - **THEN** the CLI SHALL NOT make any HTTP request to the Taskless API - **AND** SHALL produce a rule file under `.taskless/rules/` @@ -442,7 +442,7 @@ When `taskless rule improve --anonymous` is invoked, the CLI SHALL execute the l #### Scenario: rule improve --anonymous skips API -- **WHEN** a user runs `taskless rule improve --from iterate.json --anonymous` +- **WHEN** a user runs `taskless rule improve --from=iterate.json --anonymous` - **THEN** the CLI SHALL NOT make any HTTP request to the Taskless API - **AND** SHALL update the target rule file @@ -527,7 +527,7 @@ version. The CLI SHALL NOT call any v1 data route. #### Scenario: Rule create refuses a scaffold that is behind the CLI -- **WHEN** `.taskless/taskless.json` records a schema version below the latest migration and a user runs `taskless rule create --from --json` +- **WHEN** `.taskless/taskless.json` records a schema version below the latest migration and a user runs `taskless rule create --from= --json` - **THEN** stdout SHALL be the envelope `{ ok: false, code: "SCAFFOLD_MIGRATION_REQUIRED", message }`, and the message SHALL name `taskless init` - **AND** the command SHALL NOT call the service - **AND** SHALL leave every file under `.taskless/` as it was diff --git a/openspec/specs/cli-runtime-rule-execution/spec.md b/openspec/specs/cli-runtime-rule-execution/spec.md index d3a140a8c..debf21b06 100644 --- a/openspec/specs/cli-runtime-rule-execution/spec.md +++ b/openspec/specs/cli-runtime-rule-execution/spec.md @@ -106,7 +106,7 @@ the overall `check` run. ### Requirement: check.ts execution is bounded by a timeout The CLI SHALL bound each `check.ts` invocation with a wall-clock timeout and SHALL accept a -`--timeout ` flag on `check` to override the default. When a `check.ts` exceeds the +`--timeout=` flag on `check` to override the default. When a `check.ts` exceeds the timeout the CLI SHALL terminate it, record a single error-severity finding for that rule, and continue executing the remaining rules — a runaway check SHALL NOT wedge the overall `check` run. @@ -119,7 +119,7 @@ run. #### Scenario: --timeout overrides the default -- **WHEN** a user runs `taskless check --timeout ` +- **WHEN** a user runs `taskless check --timeout=` - **THEN** the CLI SHALL use that value as the per-check wall-clock bound ### Requirement: check.ts runs via a bundled TypeScript loader diff --git a/openspec/specs/cli/spec.md b/openspec/specs/cli/spec.md index 8f09a37fb..33acef0de 100644 --- a/openspec/specs/cli/spec.md +++ b/openspec/specs/cli/spec.md @@ -69,7 +69,7 @@ The CLI SHALL have a `packages/cli/tsconfig.json` that extends `../../tsconfig.b ### Requirement: CLI stub entry point -The CLI entry point SHALL use citty to define a main command with subcommand support and a global `-d` (alias `--dir`) argument that sets the working directory, a global `--json` boolean argument for machine-readable output, and a global `--schema` boolean argument for printing JSON Schema definitions. When invoked with no arguments, the CLI SHALL display help text listing available subcommands. The CLI SHALL externalize Node.js built-in modules and bundle all other dependencies. The `check` subcommand, the `auth` subcommand group, the `rules` subcommand group, and the `agent` subcommand SHALL be registered alongside existing subcommands. The `update-engine` subcommand SHALL NOT be registered. +The CLI entry point SHALL use citty to define a main command with subcommand support and a global `--dir` argument, given as `--dir=`, that sets the working directory, a global `--json` boolean argument for machine-readable output, and a global `--schema` boolean argument for printing JSON Schema definitions. When invoked with no arguments, the CLI SHALL display help text listing available subcommands. The CLI SHALL externalize Node.js built-in modules and bundle all other dependencies. The `check` subcommand, the `auth` subcommand group, the `rules` subcommand group, and the `agent` subcommand SHALL be registered alongside existing subcommands. The `update-engine` subcommand SHALL NOT be registered. #### Scenario: Running the CLI with no arguments shows help @@ -101,12 +101,12 @@ The CLI entry point SHALL use citty to define a main command with subcommand sup #### Scenario: Global -d flag is accepted -- **WHEN** the CLI is executed with `-d /some/path` or `--dir /some/path` +- **WHEN** the CLI is executed with `--dir=/some/path` - **THEN** the specified path SHALL be available to all subcommands as the resolved working directory #### Scenario: Working directory defaults to process.cwd() -- **WHEN** the CLI is executed without the `-d` flag +- **WHEN** the CLI is executed without the `--dir` flag - **THEN** the working directory SHALL default to `process.cwd()` #### Scenario: Global --json flag is accepted @@ -361,7 +361,7 @@ The `code` field SHALL be drawn from a stable enum defined in `packages/cli/src/ #### Scenario: Auth-required error in JSON mode -- **WHEN** a user runs `taskless rule create --from req.json --json` while logged out +- **WHEN** a user runs `taskless rule create --from=req.json --json` while logged out - **THEN** stdout SHALL contain `{ "ok": false, "code": "AUTH_REQUIRED", "message": "..." }` - **AND** the exit code SHALL be non-zero @@ -699,7 +699,7 @@ The flag SHALL be recognized whether placed before or after positional arguments #### Scenario: --local on rule create switches to local flow -- **WHEN** a user runs `taskless rule create --from req.json --local` +- **WHEN** a user runs `taskless rule create --from=req.json --local` - **THEN** the CLI SHALL execute the local-only branch (no API calls) - **AND** SHALL produce the same output shape as the API-backed branch @@ -729,3 +729,51 @@ The flag SHALL be recognized whether placed before or after positional arguments - **WHEN** a user runs `taskless rule improve --anonymous` - **THEN** the pointer the CLI prints SHALL name `agent improve-rule --local` + +### Requirement: Value flags take their value only after = + +Every flag that takes a value SHALL take it only within its own token, as `--flag=value`. A token that is exactly the name of a value-taking flag of the command being run, or of one of its parent commands, appearing before the `--` end-of-options marker, SHALL be refused with `INVALID_INPUT` before the command runs, with a message naming the `--flag=` spelling. This SHALL hold whether or not a token follows the flag. The set of value-taking flags SHALL be read from the command definitions, so a flag declared later is covered without a separate list. + +No flag SHALL consume the token after it. A token beginning with `-` SHALL be a flag and any other token SHALL be a positional argument, and every token after `--` SHALL be a positional argument. + +The short flag `-d` SHALL NOT exist. A `-d` token before `--` SHALL be refused with `INVALID_INPUT` naming `--dir=`. No other short flag SHALL take a value. + +`--help` and `--version` SHALL be answered before this check, so `taskless check --rule --help` prints usage. + +#### Scenario: The space spelling is refused with the fix + +- **WHEN** a user runs `taskless check --rule no-eval` +- **THEN** the CLI SHALL exit 1 with `INVALID_INPUT` +- **AND** the message SHALL name `--rule=` +- **AND** nothing SHALL be scanned + +#### Scenario: The = spelling runs + +- **WHEN** a user runs `taskless check --rule=no-eval` +- **THEN** the check SHALL run only the rule `no-eval` + +#### Scenario: A parent's value flag is covered + +- **WHEN** a user runs `taskless --dir /tmp/project check` +- **THEN** the CLI SHALL exit 1 with `INVALID_INPUT` naming `--dir=` +- **AND** SHALL NOT try to run a command named `/tmp/project` + +#### Scenario: -d is refused + +- **WHEN** a user runs `taskless check -d .` +- **THEN** the CLI SHALL exit 1 with `INVALID_INPUT` naming `--dir=` + +#### Scenario: A value beginning with - is carried in its token + +- **WHEN** a user runs `taskless check --rule=-odd-id` +- **THEN** `-odd-id` SHALL be read as the value of `--rule` + +#### Scenario: Under --json the refusal is an envelope + +- **WHEN** a user runs `taskless check --json --rule no-eval` +- **THEN** stdout SHALL hold one error envelope with code `INVALID_INPUT` + +#### Scenario: Help still answers + +- **WHEN** a user runs `taskless check --rule --help` +- **THEN** the CLI SHALL print the usage for `check` and exit 0 From 45547131cc442fd3f449af8761418cc9b9a02aa5 Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sat, 5 Dec 2026 17:07:59 -0800 Subject: [PATCH 5/6] fix(cli): read agent's topic positionals with the shared scanner, and pass --dir= in the new diff test --- packages/cli/src/commands/agent.ts | 19 ++++++------------- packages/cli/test/check-diff.test.ts | 4 ++-- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/commands/agent.ts b/packages/cli/src/commands/agent.ts index 298b24107..8dd75d0e8 100644 --- a/packages/cli/src/commands/agent.ts +++ b/packages/cli/src/commands/agent.ts @@ -24,6 +24,7 @@ import { toolVariants, } from "../prompts/recipes"; import { withSurveyInvite } from "../survey/invite"; +import { splitRawArguments } from "../util/argv"; import { applyCliInvocation } from "../util/invocation"; import { detectCliInvocation, @@ -164,19 +165,11 @@ export function createAgentCommand(subCommands: SubCommandsDef) { }, }, async run({ args, rawArgs }) { - // Extract positional args from rawArgs, skipping flags and their values. - // --dir/--tool/--section take a value (as --flag=value); --json/--local/--anonymous/--full are - // boolean and do not. - const valueFlagSet = new Set(["--dir", "-d", "--tool", "--section"]); - const positionals: string[] = []; - for (let index = 0; index < rawArgs.length; index++) { - const argument = rawArgs[index]!; - if (argument.startsWith("-")) { - if (!argument.includes("=") && valueFlagSet.has(argument)) index++; - continue; - } - if (argument !== "agent") positionals.push(argument); - } + // A value flag carries its value after `=`, so every non-flag token is + // a positional; the shared scanner says which those are. + const positionals = splitRawArguments(rawArgs).positionals.filter( + (argument) => argument !== "agent" + ); const cwd = resolve(args.dir); const telemetry = await getTelemetry(cwd); diff --git a/packages/cli/test/check-diff.test.ts b/packages/cli/test/check-diff.test.ts index 5178aefc1..ee3e6280e 100644 --- a/packages/cli/test/check-diff.test.ts +++ b/packages/cli/test/check-diff.test.ts @@ -217,9 +217,9 @@ describe("check --diff", () => { it("resolves a relative --diff= against --dir, as --from does", async () => { await writeFile(join(directory, "change.patch"), modifies("sample.js")); - // Spawned from elsewhere, so only resolving against `-d` finds the file. + // Spawned from elsewhere, so only resolving against `--dir` finds the file. const run = await runCli( - ["check", "-d", directory, "--json", "--diff=change.patch"], + ["check", `--dir=${directory}`, "--json", "--diff=change.patch"], "" ); expect(run.exitCode).toBe(1); From 7367e17b40638deba3c2cdfd84700d8da50c292a Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sat, 5 Dec 2026 17:50:12 -0800 Subject: [PATCH 6/6] test: spell the last --from in rule-poll-transient as --from= --- packages/cli/test/rule-poll-transient.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/test/rule-poll-transient.test.ts b/packages/cli/test/rule-poll-transient.test.ts index 97be7104a..5014b4ffa 100644 --- a/packages/cli/test/rule-poll-transient.test.ts +++ b/packages/cli/test/rule-poll-transient.test.ts @@ -498,7 +498,7 @@ describe("rule create: transient failures while polling and fetching", () => { const fetchMock = await stub({}); await expect( - resume("create", REQUEST_ID, "--from", "request.json") + resume("create", REQUEST_ID, "--from=request.json") ).rejects.toThrow(); expect(lastEnvelope().code).toBe("INVALID_INPUT");