Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/local-flag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@taskless/cli": patch
---

`--local` is the new name for `--anonymous`. It runs a command in local mode: no Taskless API call, no auth lookup, and only rules that can run without the service. `--anonymous` keeps working as an alias on every command, so existing scripts, CI configs and git hooks need no change, but docs, recipes and the Taskless skill now use `--local`, and messages the CLI prints name it (for example the `check` notice now reads "`--local` was set"). `info --json` still reports `authState: "anonymous"` when the probe is skipped.
2 changes: 2 additions & 0 deletions openspec/changes/archive/2026-12-01-local-flag/.openspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-01
28 changes: 28 additions & 0 deletions openspec/changes/archive/2026-12-01-local-flag/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Why

Issue #732 follow-up. `--anonymous` reads as a statement about identity, but what the flag actually selects is a mode: run on this machine, with no Taskless API call, no auth lookup and no verification. A project that chooses to run only local static rules is not trying to be anonymous, it is running locally. `--local` says that.

## What Changes

- Every subcommand that accepted `--anonymous` now accepts `--local` with the same per-command behavior. `--local` is the documented name.
- `--anonymous` stays as an alias of `--local`, so existing scripts, CI configs, git hooks and recipes installed by earlier versions keep working unchanged. `--help` lists both, the alias described as `--local`'s original name.
- Text the CLI prints names `--local`: the `check` not-verified notice (`` `--local` was set ``, remedy "run `check` without `--local`"), the `auth login` rejection ("auth commands cannot run in local mode (--local)"), the `rule improve` pointer (`agent improve-rule --local`), `info`'s auth line, and the `agent` topic index.
- The recipes and the Taskless skill use `--local`. The skill notes that `--anonymous` still works.

Unchanged: `info --json` still reports `authState: "anonymous"` when the probe was skipped, since that value is a machine contract a consumer may match on. The `@taskless/cli/prompts` option `anonymous` and the `<topic>.anonymous.md` variant filename are likewise unchanged. They are not user-facing and renaming them would break the export for nothing.

Requirements elsewhere in the specs that name `--anonymous` stay as they are. The new `cli` requirement makes the two spellings equivalent everywhere, so those requirements hold for `--local` without restating each of them.

Not breaking: `0.y.z`, nothing is removed. The bump is `patch`.

## Delivery shape

**Single PR.** A shared flag definition, its use in each command, the text and recipe updates, the tests and this spec delta are one reviewable change.

## Impact

- `packages/cli/src/util/local-flag.ts` (new), `packages/cli/src/commands/{agent,auth,check,info,init,rules}.ts`
- `packages/cli/src/rules/plan-check.ts`, `packages/cli/src/prompts/recipes.ts`, `packages/cli/src/schemas/info.ts`
- `packages/cli/src/agent/*.md`, `skills/taskless/SKILL.md`
- Tests: `local-flag.test.ts` (renamed from `anonymous-flag.test.ts`), `agent-extensions`, `error-envelope`, `runtime-check`, `prompts`
- Specs: `cli`, `cli-auth`, `cli-check`
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## MODIFIED Requirements

### Requirement: Auth login initiates Device Flow

`taskless auth login` initiates the device-code flow per the existing requirement. The `--local` flag, and its alias `--anonymous` (per the `cli` capability), SHALL NOT be accepted on this command — invocation with either SHALL exit with code 1 and an error message stating "auth commands cannot run in local mode (--local)".

When a token is already present, `auth login` SHALL decide by where it comes from:

- A token from `TASKLESS_TOKEN` SHALL be kept without contacting the service, since a saved login would not be used while the variable is set. The CLI SHALL name `TASKLESS_TOKEN` and SHALL NOT direct the user to `auth logout`, which cannot remove it.
- A saved token SHALL be checked with the service. If the service rejects it (`401`), the CLI SHALL run the device-code flow and replace the saved token. If the service accepts it, or cannot be reached, the CLI SHALL keep the token and report that the user is already logged in, since an unreachable service says nothing about the token.

Keeping a token SHALL NOT be an error: the command exits 0, and under `--json` prints `{ "ok": true, "status": "already_logged_in", "source": "saved" }`, or `"source": "environment"` for `TASKLESS_TOKEN`.

#### Scenario: Standard login still works

- **WHEN** a user runs `taskless auth login`
- **THEN** the CLI SHALL initiate the device-code flow per the existing behavior

#### Scenario: Login rejects --anonymous

- **WHEN** a user runs `taskless auth login --local` or `taskless auth login --anonymous`
- **THEN** the CLI SHALL exit with code 1
- **AND** SHALL print "auth commands cannot run in local mode" (or similar)

#### Scenario: A rejected saved token is replaced

- **WHEN** `.taskless/.env.local.json` holds a token the service answers with `401`, and `TASKLESS_TOKEN` is not set
- **AND** a user runs `taskless auth login`
- **THEN** the CLI SHALL run the device-code flow
- **AND** on approval SHALL overwrite the saved token with the new one

#### Scenario: An accepted saved token is kept

- **WHEN** the saved token is accepted by the service
- **AND** a user runs `taskless auth login`
- **THEN** the CLI SHALL NOT start the device-code flow
- **AND** SHALL report that the user is already logged in and name `auth logout` as the way to re-authenticate

#### Scenario: An unreachable service keeps the saved token

- **WHEN** the service cannot be reached to check the saved token
- **AND** a user runs `taskless auth login`
- **THEN** the CLI SHALL keep the saved token and SHALL NOT start the device-code flow

#### Scenario: A token from TASKLESS_TOKEN is named

- **WHEN** `TASKLESS_TOKEN` is set
- **AND** a user runs `taskless auth login`
- **THEN** the CLI SHALL NOT contact the service
- **AND** SHALL name `TASKLESS_TOKEN` as the token in use
- **AND** SHALL NOT direct the user to `auth logout`

#### Scenario: Keeping a token under --json is reported

- **WHEN** the saved token is accepted by the service
- **AND** a user runs `taskless auth login --json`
- **THEN** stdout SHALL contain `{ "ok": true, "status": "already_logged_in", "source": "saved" }`
- **AND** the exit code SHALL be 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## MODIFIED Requirements

### Requirement: Check names the remedy when rules run unverified

Whenever `taskless check` runs rules without verifying them, because `--local` (or its alias `--anonymous`) is set,
no token is available, no GitHub repository URL resolves, or reconciliation cannot complete,
it SHALL emit exactly one notice that says the rules were not verified, states the cause, and
names what would let verification happen. The notice SHALL be emitted whether or not the
project has runtime rules, with one exception: when `--local` is set and the project has no
runtime rules, `check` SHALL emit no not-verified notice, because the person asked for an
unverified run and nothing they wrote was skipped. It SHALL NOT change the exit code. It SHALL be a single line, cause
and remedy together, so that under `--json` it is one entry in the `notices` array; in human
output it SHALL be written to stderr marked as a notice. `--dangerously-run-scripts` is excluded: it carries its own warning.

The remedy SHALL be specific to the cause:

- `--local`: run `check` without `--local`. The notice SHALL name `--local` even when the run passed `--anonymous`.
- No token: `taskless auth login`, or a `TASKLESS_TOKEN` where `check` runs in CI.
- No repository URL: which of the three problems applies (not a git repository, no `origin`
remote, or an `origin` that is not GitHub) and the step for that problem.
- A rejected token: re-authenticate with `taskless auth login`, or replace the token.
- `404 organization_not_found`: the same steps `rule create` gives for that code, confirming
the Taskless GitHub App installation covers the repository and re-authenticating with
`taskless auth login`.

#### Scenario: Logged out with no runtime rules still says so

- **WHEN** a user runs `taskless check` with no available token in a project with no runtime rules
- **THEN** the CLI SHALL emit one notice that the rules were not verified
- **AND** the notice SHALL name `auth login`
- **AND** the exit code SHALL NOT change because of the notice

#### Scenario: Anonymous names the flag, not authentication

- **WHEN** a user runs `taskless check --local` or `taskless check --anonymous` in a project with runtime rules
- **THEN** the notice SHALL name `--local` as the cause and running without it as the remedy
- **AND** the notice SHALL say how many runtime rules did not run

#### Scenario: Anonymous with no runtime rules prints no notice

- **WHEN** a user runs `taskless check --local` in a project with no runtime rules
- **THEN** the CLI SHALL emit no not-verified notice, in text output or in the `--json` `notices` array
- **AND** SHALL still scan all local static rules with an unchanged exit code

#### Scenario: A missing origin is named as such

- **WHEN** an authenticated `check` runs in a git repository with no `origin` remote
- **THEN** the notice SHALL say the repository has no `origin` remote and how to add one

#### Scenario: Organization not found carries the installation remedy

- **WHEN** reconciliation returns `404 organization_not_found`
- **THEN** the notice SHALL name confirming the Taskless GitHub App installation and re-authenticating with `auth login`

#### Scenario: The notice is a notices entry under --json

- **WHEN** `taskless check --json` runs unverified
- **THEN** the `notices` array SHALL contain the notice
- **AND** `success`, `results`, and `skipped` SHALL keep their existing meaning
59 changes: 59 additions & 0 deletions openspec/changes/archive/2026-12-01-local-flag/specs/cli/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## REMOVED Requirements

### Requirement: CLI accepts global --anonymous flag with per-command behavior

**Reason**: Renamed to `--local`, which names the mode the flag selects. Replaced by "CLI accepts global --local flag with --anonymous as its alias".

**Migration**: None needed. `--anonymous` keeps working as an alias of `--local`; new scripts and docs should use `--local`.

## ADDED Requirements

### 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`
14 changes: 14 additions & 0 deletions openspec/changes/archive/2026-12-01-local-flag/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## 1. Flag

- [x] 1.1 Add `localModeFlags` / `isLocalMode` in `src/util/local-flag.ts`, declaring `--local` and `--anonymous` as separate citty args (citty renders an `alias` with one dash)
- [x] 1.2 Use them in `agent`, `auth login`, `auth logout`, `check`, `info`, `init`, `update`, `rule create`, `rule improve`, `rule meta`, `rule delete`
- [x] 1.3 Name `--local` in the check notice, the auth rejection, the rule pointers, `info`'s auth line, the agent index and the recipe fetch line

## 2. Docs

- [x] 2.1 Recipes and `skills/taskless/SKILL.md` use `--local`; the skill notes the alias

## 3. Tests

- [x] 3.1 Rename the flag matrix to `local-flag.test.ts` and drive it with `--local`
- [x] 3.2 Cover the `--anonymous` alias for `info`, `auth login`, `rule create`, `rule improve`, `agent`, `check`, and `--help`
6 changes: 3 additions & 3 deletions openspec/specs/cli-auth/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The CLI SHALL register an `auth` subcommand group with `login` and `logout` as n

### Requirement: Auth login initiates Device Flow

`taskless auth login` initiates the device-code flow per the existing requirement. The new `--anonymous` flag (per the `cli` capability) SHALL NOT be accepted on this command — invocation with `--anonymous` SHALL exit with code 1 and an error message stating "auth commands cannot be anonymous".
`taskless auth login` initiates the device-code flow per the existing requirement. The `--local` flag, and its alias `--anonymous` (per the `cli` capability), SHALL NOT be accepted on this command — invocation with either SHALL exit with code 1 and an error message stating "auth commands cannot run in local mode (--local)".

When a token is already present, `auth login` SHALL decide by where it comes from:

Expand All @@ -33,9 +33,9 @@ Keeping a token SHALL NOT be an error: the command exits 0, and under `--json` p

#### Scenario: Login rejects --anonymous

- **WHEN** a user runs `taskless auth login --anonymous`
- **WHEN** a user runs `taskless auth login --local` or `taskless auth login --anonymous`
- **THEN** the CLI SHALL exit with code 1
- **AND** SHALL print "auth commands cannot be anonymous" (or similar)
- **AND** SHALL print "auth commands cannot run in local mode" (or similar)

#### Scenario: A rejected saved token is replaced

Expand Down
12 changes: 6 additions & 6 deletions openspec/specs/cli-check/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,19 +798,19 @@ nothing to report.

### Requirement: Check names the remedy when rules run unverified

Whenever `taskless check` runs rules without verifying them, because `--anonymous` is set,
Whenever `taskless check` runs rules without verifying them, because `--local` (or its alias `--anonymous`) is set,
no token is available, no GitHub repository URL resolves, or reconciliation cannot complete,
it SHALL emit exactly one notice that says the rules were not verified, states the cause, and
names what would let verification happen. The notice SHALL be emitted whether or not the
project has runtime rules, with one exception: when `--anonymous` is set and the project has no
project has runtime rules, with one exception: when `--local` is set and the project has no
runtime rules, `check` SHALL emit no not-verified notice, because the person asked for an
unverified run and nothing they wrote was skipped. It SHALL NOT change the exit code. It SHALL be a single line, cause
and remedy together, so that under `--json` it is one entry in the `notices` array; in human
output it SHALL be written to stderr marked as a notice. `--dangerously-run-scripts` is excluded: it carries its own warning.

The remedy SHALL be specific to the cause:

- `--anonymous`: run `check` without `--anonymous`.
- `--local`: run `check` without `--local`. The notice SHALL name `--local` even when the run passed `--anonymous`.
- No token: `taskless auth login`, or a `TASKLESS_TOKEN` where `check` runs in CI.
- No repository URL: which of the three problems applies (not a git repository, no `origin`
remote, or an `origin` that is not GitHub) and the step for that problem.
Expand All @@ -828,13 +828,13 @@ The remedy SHALL be specific to the cause:

#### Scenario: Anonymous names the flag, not authentication

- **WHEN** a user runs `taskless check --anonymous` in a project with runtime rules
- **THEN** the notice SHALL name `--anonymous` as the cause and running without it as the remedy
- **WHEN** a user runs `taskless check --local` or `taskless check --anonymous` in a project with runtime rules
- **THEN** the notice SHALL name `--local` as the cause and running without it as the remedy
- **AND** the notice SHALL say how many runtime rules did not run

#### Scenario: Anonymous with no runtime rules prints no notice

- **WHEN** a user runs `taskless check --anonymous` in a project with no runtime rules
- **WHEN** a user runs `taskless check --local` in a project with no runtime rules
- **THEN** the CLI SHALL emit no not-verified notice, in text output or in the `--json` `notices` array
- **AND** SHALL still scan all local static rules with an unchanged exit code

Expand Down
Loading