From feaa7731e296fe994cf7deaed71568151eea2a73 Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Mon, 6 Apr 2026 22:40:39 -0700 Subject: [PATCH 1/2] fix(cli): Use correct CLI command for auth login references Replace bare `taskless auth login` with the proper package-manager-aware invocation. CLI error messages now dynamically detect the invoking package manager via npm_config_user_agent. Skills default to npx with a note to prefer the project's package manager. Closes #12 Co-Authored-By: Claude Opus 4.6 (1M context) --- .changeset/fix-auth-login-command.md | 8 ++++++++ commands/tskl/check.md | 8 +++++--- commands/tskl/improve.md | 18 ++++++++++-------- commands/tskl/info.md | 8 +++++--- commands/tskl/login.md | 4 +++- commands/tskl/logout.md | 4 +++- commands/tskl/rule.md | 12 +++++++----- packages/cli/src/api/rules.ts | 7 ++++--- packages/cli/src/auth/identity.ts | 5 +++-- packages/cli/src/auth/token.ts | 4 ++-- packages/cli/src/help/rules-create.txt | 2 +- packages/cli/src/help/rules-improve.txt | 2 +- packages/cli/src/util/package-manager.ts | 14 ++++++++++++++ skills/taskless-check/SKILL.md | 8 +++++--- skills/taskless-create-rule-anonymous/SKILL.md | 6 ++++-- skills/taskless-create-rule/SKILL.md | 12 +++++++----- skills/taskless-delete-rule/SKILL.md | 6 ++++-- .../taskless-improve-rule-anonymous/SKILL.md | 8 +++++--- skills/taskless-improve-rule/SKILL.md | 18 ++++++++++-------- skills/taskless-info/SKILL.md | 8 +++++--- skills/taskless-login/SKILL.md | 4 +++- skills/taskless-logout/SKILL.md | 4 +++- 22 files changed, 112 insertions(+), 58 deletions(-) create mode 100644 .changeset/fix-auth-login-command.md create mode 100644 packages/cli/src/util/package-manager.ts diff --git a/.changeset/fix-auth-login-command.md b/.changeset/fix-auth-login-command.md new file mode 100644 index 00000000..58cd9611 --- /dev/null +++ b/.changeset/fix-auth-login-command.md @@ -0,0 +1,8 @@ +--- +"@taskless/cli": patch +"@taskless/skills": patch +--- + +Fix "auth login" to use the correct CLI command + +Replaced bare `taskless auth login` references with the proper `npx @taskless/cli@latest auth login` invocation across all skills, commands, CLI error messages, and help text. CLI error messages now dynamically detect the invoking package manager (pnpm, yarn, bun, or npx) via `npm_config_user_agent`. Skills default to `npx` with a note to prefer the project's package manager. diff --git a/commands/tskl/check.md b/commands/tskl/check.md index 8c560226..615c1e64 100644 --- a/commands/tskl/check.md +++ b/commands/tskl/check.md @@ -16,10 +16,12 @@ When this skill is invoked, perform a check of the codebase using the Taskless C ## Instructions -1. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help check` and read the output. Use this to understand the command's options, output format, and exit codes. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. -2. **Invoke the CLI with JSON output.** Run `pnpm dlx @taskless/cli@latest check --json` and capture stdout. +1. **Read current command documentation.** Run `npx @taskless/cli@latest help check` and read the output. Use this to understand the command's options, output format, and exit codes. + +2. **Invoke the CLI with JSON output.** Run `npx @taskless/cli@latest check --json` and capture stdout. 3. **Parse the response.** Parse the JSON output with `JSON.parse()`. Use the fields described in the help output to determine success or failure and report any issues found to the user. -4. **Handle errors.** If the command exits with a non-zero code or the output is not valid JSON, report the error and suggest running `pnpm dlx @taskless/cli@latest init` if configuration is missing. +4. **Handle errors.** If the command exits with a non-zero code or the output is not valid JSON, report the error and suggest running `npx @taskless/cli@latest init` if configuration is missing. diff --git a/commands/tskl/improve.md b/commands/tskl/improve.md index bd01bc66..3dd656b5 100644 --- a/commands/tskl/improve.md +++ b/commands/tskl/improve.md @@ -18,11 +18,13 @@ This is a decision-making skill. You must evaluate the situation and choose the ## Instructions -1. **Check authentication status.** Run `pnpm dlx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Check authentication status.** Run `npx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: - If `loggedIn` is `true`: continue with step 2 below (API-backed flow). - If `loggedIn` is `false`: **stop here** and invoke the `taskless-improve-rule-anonymous` skill instead. Pass along any context the user has already provided about which rule to improve and what changes they want. -2. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help rules improve` and read the output. Use this to understand the improve command's `--from` JSON fields, options, and examples. +2. **Read current command documentation.** Run `npx @taskless/cli@latest help rules improve` and read the output. Use this to understand the improve command's `--from` JSON fields, options, and examples. 3. **Inventory existing rules.** If the user has already named a specific rule, skip to that rule directly. Otherwise, scan the `.taskless/rules/` directory for `.yml` files and present a summary. For each rule, note: - The rule ID (filename without `.yml`) @@ -30,7 +32,7 @@ This is a decision-making skill. You must evaluate the situation and choose the - The pattern it detects (from the `message`, `note`, or `rule` fields) - Any associated test files in `.taskless/rule-tests/` - Once a rule is selected, check for its sidecar metadata by running `pnpm dlx @taskless/cli@latest rules meta --json`. If metadata exists, note the `ticketId` — this is required for the iterate API. + Once a rule is selected, check for its sidecar metadata by running `npx @taskless/cli@latest rules meta --json`. If metadata exists, note the `ticketId` — this is required for the iterate API. 4. **Understand the improvement request.** Ask the user what they want to improve. Gather specifics: - Which rule(s) are problematic? @@ -77,7 +79,7 @@ This is a decision-making skill. You must evaluate the situation and choose the ### For Option A (iterate): a. **Build the JSON payload.** Create a JSON object with: - - `ruleId`: The ticket ID from the rule's sidecar metadata. Retrieve it by running `pnpm dlx @taskless/cli@latest rules meta --json` and reading the `ticketId` field. If no metadata file exists (rule was created before metadata support), fall back to using the rule filename as the identifier. Providing the ticket ID allows the API to understand the existing rule's logic and how to adjust it based on your guidance. + - `ruleId`: The ticket ID from the rule's sidecar metadata. Retrieve it by running `npx @taskless/cli@latest rules meta --json` and reading the `ticketId` field. If no metadata file exists (rule was created before metadata support), fall back to using the rule filename as the identifier. Providing the ticket ID allows the API to understand the existing rule's logic and how to adjust it based on your guidance. - `guidance`: A clear, specific description of what should change. Include: - What the rule is doing wrong - What it should do instead @@ -106,7 +108,7 @@ This is a decision-making skill. You must evaluate the situation and choose the b. **Write the JSON to a temp file.** Write to `.taskless/.tmp-improve-request.json`. - c. **Invoke the CLI.** Run `pnpm dlx @taskless/cli@latest rules improve --from .taskless/.tmp-improve-request.json --json`. The command may take 30-60 seconds as it polls the API. + c. **Invoke the CLI.** Run `npx @taskless/cli@latest rules improve --from .taskless/.tmp-improve-request.json --json`. The command may take 30-60 seconds as it polls the API. d. **Clean up.** After the command completes (success or failure), delete `.taskless/.tmp-improve-request.json`. @@ -116,19 +118,19 @@ This is a decision-making skill. You must evaluate the situation and choose the a. Note the old rule ID for deletion. b. Invoke the `taskless-create-rule` skill (command name `tskl:rule`) to create the replacement rule. This ensures the full enrichment workflow (examples, exclusions, confirmation) is followed. - c. After the new rule is generated, delete the old rule: `pnpm dlx @taskless/cli@latest rules delete `. + c. After the new rule is generated, delete the old rule: `npx @taskless/cli@latest rules delete `. d. Report results. ### For Option C (expand): a. For each new rule needed, invoke the `taskless-create-rule` skill (command name `tskl:rule`). - b. If any old rules are being superseded, delete them after the new rules are created: `pnpm dlx @taskless/cli@latest rules delete `. + b. If any old rules are being superseded, delete them after the new rules are created: `npx @taskless/cli@latest rules delete `. c. Report all changes. 8. **Suggest testing.** After any approach, suggest running `taskless-check` to test the updated rules against the codebase. 9. **Handle errors.** If the CLI fails: - **Authentication required**: Suggest the `taskless-login` skill. - - **Missing organization info**: Suggest running `taskless auth login` to re-authenticate. + - **Missing organization info**: Suggest running `npx @taskless/cli@latest auth login` to re-authenticate. - **Rule not found**: The ruleId may be incorrect. Check the rule's metadata or suggest creating a new rule instead. - **API errors**: Report the error message and suggest trying again. diff --git a/commands/tskl/info.md b/commands/tskl/info.md index 5ad05d63..35053322 100644 --- a/commands/tskl/info.md +++ b/commands/tskl/info.md @@ -16,9 +16,11 @@ When this skill is invoked, verify that the Taskless CLI is reachable and report ## Instructions -1. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help info` and read the output. Use this to understand the command's output format and available options. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. -2. **Invoke the CLI.** Run `pnpm dlx @taskless/cli@latest info` and capture stdout. +1. **Read current command documentation.** Run `npx @taskless/cli@latest help info` and read the output. Use this to understand the command's output format and available options. + +2. **Invoke the CLI.** Run `npx @taskless/cli@latest info` and capture stdout. 3. **Parse the response.** The CLI outputs JSON to stdout. Parse it with `JSON.parse()` and extract the fields described in the help output. Key fields to report: - `version`: The version of the Taskless CLI. @@ -42,7 +44,7 @@ When this skill is invoked, verify that the Taskless CLI is reachable and report - Suggest checking network connectivity and that npm/pnpm is available. - Show the raw error output if available. -6. **Report if Upgrade is Required** If any installed skill is not current, include a note that an upgrade is recommended. Offer to run `pnpm dlx @taskless/cli@latest init` for them to reinitialize with the latest skills. +6. **Report if Upgrade is Required** If any installed skill is not current, include a note that an upgrade is recommended. Offer to run `npx @taskless/cli@latest init` for them to reinitialize with the latest skills. ## Example Output diff --git a/commands/tskl/login.md b/commands/tskl/login.md index 515c92b5..6cac96b3 100644 --- a/commands/tskl/login.md +++ b/commands/tskl/login.md @@ -18,6 +18,8 @@ When this skill is invoked, explain the authentication process and provide the C ## Instructions -1. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help auth login` and read the output. Use this to understand the login flow, credential storage, and alternatives. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Read current command documentation.** Run `npx @taskless/cli@latest help auth login` and read the output. Use this to understand the login flow, credential storage, and alternatives. 2. **Present the login command and explain the process.** Using the information from the help output, display the command the user should run in their terminal and explain what will happen (device flow, credential storage, environment variable alternative). diff --git a/commands/tskl/logout.md b/commands/tskl/logout.md index 9b5fecf5..ee5d669c 100644 --- a/commands/tskl/logout.md +++ b/commands/tskl/logout.md @@ -18,6 +18,8 @@ When this skill is invoked, explain how to remove saved authentication and provi ## Instructions -1. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help auth logout` and read the output. Use this to understand what the command does, credential storage location, and any caveats. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Read current command documentation.** Run `npx @taskless/cli@latest help auth logout` and read the output. Use this to understand what the command does, credential storage location, and any caveats. 2. **Present the logout command and explain what it does.** Using the information from the help output, display the command the user should run and explain the effects (credential removal, environment variable note). diff --git a/commands/tskl/rule.md b/commands/tskl/rule.md index b7c0671c..bf909cbe 100644 --- a/commands/tskl/rule.md +++ b/commands/tskl/rule.md @@ -18,11 +18,13 @@ Your goal is to produce the best possible rule by enriching the user's initial d ## Instructions -1. **Check authentication status.** Run `pnpm dlx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Check authentication status.** Run `npx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: - If `loggedIn` is `true`: continue with step 2 below (API-backed flow). - If `loggedIn` is `false`: **stop here** and invoke the `taskless-create-rule-anonymous` skill instead. Pass along any context the user has already provided about the rule they want to create. -2. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help rules create` and read the output. Use this to understand the command's `--from` JSON fields, options, and examples. +2. **Read current command documentation.** Run `npx @taskless/cli@latest help rules create` and read the output. Use this to understand the command's `--from` JSON fields, options, and examples. 3. **Gather the rule description.** Even if the user provided a description with their command, you MUST ask clarifying questions before proceeding. Do NOT skip to rule generation. Ask what specific code pattern should be flagged, with concrete examples. This becomes the `prompt` field (required). @@ -82,13 +84,13 @@ Your goal is to produce the best possible rule by enriching the user's initial d } ``` -8. **Invoke the CLI.** Run `pnpm dlx @taskless/cli@latest rules create --from .taskless/.tmp-rule-request.json --json`. The command may take 30-60 seconds as it polls the API. +8. **Invoke the CLI.** Run `npx @taskless/cli@latest rules create --from .taskless/.tmp-rule-request.json --json`. The command may take 30-60 seconds as it polls the API. 9. **Clean up.** After the command completes (success or failure), delete the `.taskless/.tmp-rule-request.json` file. -10. **Report the results.** When the CLI completes, show the generated file paths and suggest running `taskless-check` to test the new rule. The CLI also writes sidecar metadata to `.taskless/rule-metadata/.yml` containing the `ticketId` used for future iterations. You can retrieve this with `pnpm dlx @taskless/cli@latest rules meta --json`. +10. **Report the results.** When the CLI completes, show the generated file paths and suggest running `taskless-check` to test the new rule. The CLI also writes sidecar metadata to `.taskless/rule-metadata/.yml` containing the `ticketId` used for future iterations. You can retrieve this with `npx @taskless/cli@latest rules meta --json`. 11. **Handle errors.** If the CLI fails: - **Authentication required**: Suggest the `taskless-login` skill. - - **Missing organization info**: Suggest running `taskless auth login` to re-authenticate. + - **Missing organization info**: Suggest running `npx @taskless/cli@latest auth login` to re-authenticate. - **API errors**: Report the error message and suggest trying again. diff --git a/packages/cli/src/api/rules.ts b/packages/cli/src/api/rules.ts index 677aae11..0237b052 100644 --- a/packages/cli/src/api/rules.ts +++ b/packages/cli/src/api/rules.ts @@ -1,5 +1,6 @@ import type { paths } from "../generated/api"; import { createApiClient } from "./client"; +import { getCliPrefix } from "../util/package-manager"; // --- Types extracted from the generated schema --- @@ -56,7 +57,7 @@ export async function submitRule( "", "- Verify that your local `origin` remote points to the intended GitHub repository.", "- Confirm that your GitHub user/organization has access to that repository.", - "- If you recently changed access or remotes, try re-authenticating with `taskless auth login`.", + `- If you recently changed access or remotes, try re-authenticating with \`${getCliPrefix()} auth login\`.`, ].join("\n") ); } @@ -65,7 +66,7 @@ export async function submitRule( errorData.error === "organization_not_found" ) { throw new Error( - "Organization not found. Try running `taskless auth login` to re-authenticate." + `Organization not found. Try running \`${getCliPrefix()} auth login\` to re-authenticate.` ); } throw new Error( @@ -133,7 +134,7 @@ export async function iterateRule( errorData.error === "organization_not_found" ) { throw new Error( - "Organization not found. Try running `taskless auth login` to re-authenticate." + `Organization not found. Try running \`${getCliPrefix()} auth login\` to re-authenticate.` ); } throw new Error(`Iterate request failed (HTTP ${String(response.status)})`); diff --git a/packages/cli/src/auth/identity.ts b/packages/cli/src/auth/identity.ts index 79b8441b..39c3a0d6 100644 --- a/packages/cli/src/auth/identity.ts +++ b/packages/cli/src/auth/identity.ts @@ -1,6 +1,7 @@ import { getToken } from "./token"; import { decodeOrgId } from "./jwt"; import { resolveRepositoryUrl } from "../util/git-remote"; +import { getCliPrefix } from "../util/package-manager"; export interface Identity { token: string; @@ -19,14 +20,14 @@ export async function resolveIdentity(cwd: string): Promise { const token = await getToken(cwd); if (!token) { throw new Error( - "Authentication required. Run `taskless auth login` to authenticate." + `Authentication required. Run \`${getCliPrefix()} auth login\` to authenticate.` ); } const orgId = decodeOrgId(token); if (orgId === undefined) { throw new Error( - "Your auth token is missing organization info. Run `taskless auth login` to re-authenticate." + `Your auth token is missing organization info. Run \`${getCliPrefix()} auth login\` to re-authenticate.` ); } diff --git a/packages/cli/src/auth/token.ts b/packages/cli/src/auth/token.ts index be6f48d6..38fdabf2 100644 --- a/packages/cli/src/auth/token.ts +++ b/packages/cli/src/auth/token.ts @@ -5,6 +5,7 @@ import { join } from "node:path"; import { mkdir, readFile, rm, writeFile } from "node:fs/promises"; import { addToGitignore } from "../filesystem/gitignore"; +import { getCliPrefix } from "../util/package-manager"; const PER_REPO_AUTH_FILE = ".env.local.json"; @@ -117,8 +118,7 @@ function warnIfLegacyToken(): void { if (existsSync(legacyPath)) { legacyWarningShown = true; console.error( - "Notice: Found legacy global auth at %s. Global tokens are no longer used. Run `taskless auth login` to authenticate for this repository.", - legacyPath + `Notice: Found legacy global auth at ${legacyPath}. Global tokens are no longer used. Run \`${getCliPrefix()} auth login\` to authenticate for this repository.` ); } } diff --git a/packages/cli/src/help/rules-create.txt b/packages/cli/src/help/rules-create.txt index 2cfc2499..08ab7cff 100644 --- a/packages/cli/src/help/rules-create.txt +++ b/packages/cli/src/help/rules-create.txt @@ -5,7 +5,7 @@ API for generation, and writes the resulting rule and test files to .taskless/rules/ and .taskless/rule-tests/. Prerequisites: - Run `taskless auth login` to authenticate first. + Run `npx @taskless/cli@latest auth login` to authenticate first. Your repository must have a GitHub origin remote. Usage: diff --git a/packages/cli/src/help/rules-improve.txt b/packages/cli/src/help/rules-improve.txt index 675d0112..39272953 100644 --- a/packages/cli/src/help/rules-improve.txt +++ b/packages/cli/src/help/rules-improve.txt @@ -5,7 +5,7 @@ it to the Taskless API, and writes the updated rule and test files to .taskless/rules/ and .taskless/rule-tests/. Prerequisites: - Run `taskless auth login` to authenticate first. + Run `npx @taskless/cli@latest auth login` to authenticate first. Your repository must have a GitHub origin remote. Usage: diff --git a/packages/cli/src/util/package-manager.ts b/packages/cli/src/util/package-manager.ts new file mode 100644 index 00000000..fda88d36 --- /dev/null +++ b/packages/cli/src/util/package-manager.ts @@ -0,0 +1,14 @@ +/** + * Detect the package manager that invoked the CLI from the + * npm_config_user_agent environment variable and return the + * appropriate `dlx`-style prefix for error messages. + * + * Falls back to `npx` when detection is not possible. + */ +export function getCliPrefix(): string { + const ua = process.env.npm_config_user_agent ?? ""; + if (ua.startsWith("pnpm/")) return "pnpm dlx @taskless/cli@latest"; + if (ua.startsWith("yarn/")) return "yarn dlx @taskless/cli@latest"; + if (ua.startsWith("bun/")) return "bunx @taskless/cli@latest"; + return "npx @taskless/cli@latest"; +} diff --git a/skills/taskless-check/SKILL.md b/skills/taskless-check/SKILL.md index 6cce3e18..f269cc24 100644 --- a/skills/taskless-check/SKILL.md +++ b/skills/taskless-check/SKILL.md @@ -14,10 +14,12 @@ When this skill is invoked, perform a check of the codebase using the Taskless C ## Instructions -1. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help check` and read the output. Use this to understand the command's options, output format, and exit codes. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. -2. **Invoke the CLI with JSON output.** Run `pnpm dlx @taskless/cli@latest check --json` and capture stdout. +1. **Read current command documentation.** Run `npx @taskless/cli@latest help check` and read the output. Use this to understand the command's options, output format, and exit codes. + +2. **Invoke the CLI with JSON output.** Run `npx @taskless/cli@latest check --json` and capture stdout. 3. **Parse the response.** Parse the JSON output with `JSON.parse()`. Use the fields described in the help output to determine success or failure and report any issues found to the user. -4. **Handle errors.** If the command exits with a non-zero code or the output is not valid JSON, report the error and suggest running `pnpm dlx @taskless/cli@latest init` if configuration is missing. +4. **Handle errors.** If the command exits with a non-zero code or the output is not valid JSON, report the error and suggest running `npx @taskless/cli@latest init` if configuration is missing. diff --git a/skills/taskless-create-rule-anonymous/SKILL.md b/skills/taskless-create-rule-anonymous/SKILL.md index 90fccf58..405ad7ff 100644 --- a/skills/taskless-create-rule-anonymous/SKILL.md +++ b/skills/taskless-create-rule-anonymous/SKILL.md @@ -13,7 +13,9 @@ This skill creates ast-grep rules locally without requiring Taskless authenticat ## Instructions -1. **Learn the ast-grep rule format.** Run `pnpm dlx @taskless/cli@latest rules verify --schema --json` and read the output. This gives you: +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Learn the ast-grep rule format.** Run `npx @taskless/cli@latest rules verify --schema --json` and read the output. This gives you: - `astGrepSchema`: The official ast-grep rule JSON Schema — the full reference for what fields are valid. - `tasklessRequirements`: Fields Taskless requires beyond ast-grep defaults (`id`, `language`, `severity`, `message`, `rule`) and additional rules (e.g., `regex` requires `kind`). - `examples`: Annotated rule examples showing common patterns (simple match, regex with kind, composite rules). @@ -54,7 +56,7 @@ This skill creates ast-grep rules locally without requiring Taskless authenticat Include at least 2 valid and 2 invalid cases. Use real patterns from the codebase where possible. -7. **Verify the rule.** Run `pnpm dlx @taskless/cli@latest rules verify --json` and check the result: +7. **Verify the rule.** Run `npx @taskless/cli@latest rules verify --json` and check the result: - If `success` is `true`: the rule passes all checks. Report success to the user. - If `success` is `false`: read the error details from each layer (`schema`, `requirements`, `tests`) and fix the issues. Then re-run verify. Repeat until it passes or you've made 3 attempts. diff --git a/skills/taskless-create-rule/SKILL.md b/skills/taskless-create-rule/SKILL.md index ec6dcaad..a8fbb498 100644 --- a/skills/taskless-create-rule/SKILL.md +++ b/skills/taskless-create-rule/SKILL.md @@ -16,11 +16,13 @@ Your goal is to produce the best possible rule by enriching the user's initial d ## Instructions -1. **Check authentication status.** Run `pnpm dlx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Check authentication status.** Run `npx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: - If `loggedIn` is `true`: continue with step 2 below (API-backed flow). - If `loggedIn` is `false`: **stop here** and invoke the `taskless-create-rule-anonymous` skill instead. Pass along any context the user has already provided about the rule they want to create. -2. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help rules create` and read the output. Use this to understand the command's `--from` JSON fields, options, and examples. +2. **Read current command documentation.** Run `npx @taskless/cli@latest help rules create` and read the output. Use this to understand the command's `--from` JSON fields, options, and examples. 3. **Gather the rule description.** Even if the user provided a description with their command, you MUST ask clarifying questions before proceeding. Do NOT skip to rule generation. Ask what specific code pattern should be flagged, with concrete examples. This becomes the `prompt` field (required). @@ -80,13 +82,13 @@ Your goal is to produce the best possible rule by enriching the user's initial d } ``` -8. **Invoke the CLI.** Run `pnpm dlx @taskless/cli@latest rules create --from .taskless/.tmp-rule-request.json --json`. The command may take 30-60 seconds as it polls the API. +8. **Invoke the CLI.** Run `npx @taskless/cli@latest rules create --from .taskless/.tmp-rule-request.json --json`. The command may take 30-60 seconds as it polls the API. 9. **Clean up.** After the command completes (success or failure), delete the `.taskless/.tmp-rule-request.json` file. -10. **Report the results.** When the CLI completes, show the generated file paths and suggest running `taskless-check` to test the new rule. The CLI also writes sidecar metadata to `.taskless/rule-metadata/.yml` containing the `ticketId` used for future iterations. You can retrieve this with `pnpm dlx @taskless/cli@latest rules meta --json`. +10. **Report the results.** When the CLI completes, show the generated file paths and suggest running `taskless-check` to test the new rule. The CLI also writes sidecar metadata to `.taskless/rule-metadata/.yml` containing the `ticketId` used for future iterations. You can retrieve this with `npx @taskless/cli@latest rules meta --json`. 11. **Handle errors.** If the CLI fails: - **Authentication required**: Suggest the `taskless-login` skill. - - **Missing organization info**: Suggest running `taskless auth login` to re-authenticate. + - **Missing organization info**: Suggest running `npx @taskless/cli@latest auth login` to re-authenticate. - **API errors**: Report the error message and suggest trying again. diff --git a/skills/taskless-delete-rule/SKILL.md b/skills/taskless-delete-rule/SKILL.md index 8c7959f8..08092d8a 100644 --- a/skills/taskless-delete-rule/SKILL.md +++ b/skills/taskless-delete-rule/SKILL.md @@ -14,7 +14,9 @@ When this skill is invoked, help the user identify which rule to delete, confirm ## Instructions -1. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help rules delete` and read the output. Use this to understand the command's arguments, options, and exit codes. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Read current command documentation.** Run `npx @taskless/cli@latest help rules delete` and read the output. Use this to understand the command's arguments, options, and exit codes. 2. **List available rules.** Scan the `.taskless/rules/` directory for `.yml` files. Present the rule IDs (filenames without the `.yml` extension) to the user. @@ -28,7 +30,7 @@ When this skill is invoked, help the user identify which rule to delete, confirm 4. **Confirm before deleting.** Show the user the rule ID and ask for confirmation before proceeding. -5. **Invoke the CLI.** Run the delete command using the syntax shown in the help output (e.g., `pnpm dlx @taskless/cli@latest rules delete `). +5. **Invoke the CLI.** Run the delete command using the syntax shown in the help output (e.g., `npx @taskless/cli@latest rules delete `). 6. **Report the result.** Confirm which files were deleted. diff --git a/skills/taskless-improve-rule-anonymous/SKILL.md b/skills/taskless-improve-rule-anonymous/SKILL.md index 259bd136..1e906f7a 100644 --- a/skills/taskless-improve-rule-anonymous/SKILL.md +++ b/skills/taskless-improve-rule-anonymous/SKILL.md @@ -13,7 +13,9 @@ This skill improves existing ast-grep rules locally without requiring Taskless a ## Instructions -1. **Learn the ast-grep rule format.** Run `pnpm dlx @taskless/cli@latest rules verify --schema --json` and read the output. Study the `astGrepSchema`, `tasklessRequirements`, and `examples` to understand valid rule structure and patterns. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Learn the ast-grep rule format.** Run `npx @taskless/cli@latest rules verify --schema --json` and read the output. Study the `astGrepSchema`, `tasklessRequirements`, and `examples` to understand valid rule structure and patterns. 2. **Inventory existing rules.** If the user has named a specific rule, go directly to it. Otherwise, scan `.taskless/rules/` for `.yml` files and present a summary: - Rule ID (filename without `.yml`) @@ -44,7 +46,7 @@ This skill improves existing ast-grep rules locally without requiring Taskless a Use when the rule is fundamentally wrong and needs a different approach. - Invoke the `taskless-create-rule-anonymous` skill to create the replacement - - Delete the old rule: `pnpm dlx @taskless/cli@latest rules delete ` + - Delete the old rule: `npx @taskless/cli@latest rules delete ` ### Option C — Expand with additional rules @@ -60,7 +62,7 @@ This skill improves existing ast-grep rules locally without requiring Taskless a - Write updated test cases that exercise the improved behavior - Include test cases for the specific issues the user reported -8. **Verify the changes.** Run `pnpm dlx @taskless/cli@latest rules verify --json` and check the result: +8. **Verify the changes.** Run `npx @taskless/cli@latest rules verify --json` and check the result: - If `success` is `true`: report success to the user. - If `success` is `false`: read the error details, fix the issues, and re-run verify. Repeat until it passes or you've made 3 attempts. diff --git a/skills/taskless-improve-rule/SKILL.md b/skills/taskless-improve-rule/SKILL.md index 9e7e4258..ae16ef5c 100644 --- a/skills/taskless-improve-rule/SKILL.md +++ b/skills/taskless-improve-rule/SKILL.md @@ -16,11 +16,13 @@ This is a decision-making skill. You must evaluate the situation and choose the ## Instructions -1. **Check authentication status.** Run `pnpm dlx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Check authentication status.** Run `npx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: - If `loggedIn` is `true`: continue with step 2 below (API-backed flow). - If `loggedIn` is `false`: **stop here** and invoke the `taskless-improve-rule-anonymous` skill instead. Pass along any context the user has already provided about which rule to improve and what changes they want. -2. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help rules improve` and read the output. Use this to understand the improve command's `--from` JSON fields, options, and examples. +2. **Read current command documentation.** Run `npx @taskless/cli@latest help rules improve` and read the output. Use this to understand the improve command's `--from` JSON fields, options, and examples. 3. **Inventory existing rules.** If the user has already named a specific rule, skip to that rule directly. Otherwise, scan the `.taskless/rules/` directory for `.yml` files and present a summary. For each rule, note: - The rule ID (filename without `.yml`) @@ -28,7 +30,7 @@ This is a decision-making skill. You must evaluate the situation and choose the - The pattern it detects (from the `message`, `note`, or `rule` fields) - Any associated test files in `.taskless/rule-tests/` - Once a rule is selected, check for its sidecar metadata by running `pnpm dlx @taskless/cli@latest rules meta --json`. If metadata exists, note the `ticketId` — this is required for the iterate API. + Once a rule is selected, check for its sidecar metadata by running `npx @taskless/cli@latest rules meta --json`. If metadata exists, note the `ticketId` — this is required for the iterate API. 4. **Understand the improvement request.** Ask the user what they want to improve. Gather specifics: - Which rule(s) are problematic? @@ -75,7 +77,7 @@ This is a decision-making skill. You must evaluate the situation and choose the ### For Option A (iterate): a. **Build the JSON payload.** Create a JSON object with: - - `ruleId`: The ticket ID from the rule's sidecar metadata. Retrieve it by running `pnpm dlx @taskless/cli@latest rules meta --json` and reading the `ticketId` field. If no metadata file exists (rule was created before metadata support), fall back to using the rule filename as the identifier. Providing the ticket ID allows the API to understand the existing rule's logic and how to adjust it based on your guidance. + - `ruleId`: The ticket ID from the rule's sidecar metadata. Retrieve it by running `npx @taskless/cli@latest rules meta --json` and reading the `ticketId` field. If no metadata file exists (rule was created before metadata support), fall back to using the rule filename as the identifier. Providing the ticket ID allows the API to understand the existing rule's logic and how to adjust it based on your guidance. - `guidance`: A clear, specific description of what should change. Include: - What the rule is doing wrong - What it should do instead @@ -104,7 +106,7 @@ This is a decision-making skill. You must evaluate the situation and choose the b. **Write the JSON to a temp file.** Write to `.taskless/.tmp-improve-request.json`. - c. **Invoke the CLI.** Run `pnpm dlx @taskless/cli@latest rules improve --from .taskless/.tmp-improve-request.json --json`. The command may take 30-60 seconds as it polls the API. + c. **Invoke the CLI.** Run `npx @taskless/cli@latest rules improve --from .taskless/.tmp-improve-request.json --json`. The command may take 30-60 seconds as it polls the API. d. **Clean up.** After the command completes (success or failure), delete `.taskless/.tmp-improve-request.json`. @@ -114,19 +116,19 @@ This is a decision-making skill. You must evaluate the situation and choose the a. Note the old rule ID for deletion. b. Invoke the `taskless-create-rule` skill (command name `tskl:rule`) to create the replacement rule. This ensures the full enrichment workflow (examples, exclusions, confirmation) is followed. - c. After the new rule is generated, delete the old rule: `pnpm dlx @taskless/cli@latest rules delete `. + c. After the new rule is generated, delete the old rule: `npx @taskless/cli@latest rules delete `. d. Report results. ### For Option C (expand): a. For each new rule needed, invoke the `taskless-create-rule` skill (command name `tskl:rule`). - b. If any old rules are being superseded, delete them after the new rules are created: `pnpm dlx @taskless/cli@latest rules delete `. + b. If any old rules are being superseded, delete them after the new rules are created: `npx @taskless/cli@latest rules delete `. c. Report all changes. 8. **Suggest testing.** After any approach, suggest running `taskless-check` to test the updated rules against the codebase. 9. **Handle errors.** If the CLI fails: - **Authentication required**: Suggest the `taskless-login` skill. - - **Missing organization info**: Suggest running `taskless auth login` to re-authenticate. + - **Missing organization info**: Suggest running `npx @taskless/cli@latest auth login` to re-authenticate. - **Rule not found**: The ruleId may be incorrect. Check the rule's metadata or suggest creating a new rule instead. - **API errors**: Report the error message and suggest trying again. diff --git a/skills/taskless-info/SKILL.md b/skills/taskless-info/SKILL.md index 073463be..646665f7 100644 --- a/skills/taskless-info/SKILL.md +++ b/skills/taskless-info/SKILL.md @@ -14,9 +14,11 @@ When this skill is invoked, verify that the Taskless CLI is reachable and report ## Instructions -1. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help info` and read the output. Use this to understand the command's output format and available options. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. -2. **Invoke the CLI.** Run `pnpm dlx @taskless/cli@latest info` and capture stdout. +1. **Read current command documentation.** Run `npx @taskless/cli@latest help info` and read the output. Use this to understand the command's output format and available options. + +2. **Invoke the CLI.** Run `npx @taskless/cli@latest info` and capture stdout. 3. **Parse the response.** The CLI outputs JSON to stdout. Parse it with `JSON.parse()` and extract the fields described in the help output. Key fields to report: - `version`: The version of the Taskless CLI. @@ -40,7 +42,7 @@ When this skill is invoked, verify that the Taskless CLI is reachable and report - Suggest checking network connectivity and that npm/pnpm is available. - Show the raw error output if available. -6. **Report if Upgrade is Required** If any installed skill is not current, include a note that an upgrade is recommended. Offer to run `pnpm dlx @taskless/cli@latest init` for them to reinitialize with the latest skills. +6. **Report if Upgrade is Required** If any installed skill is not current, include a note that an upgrade is recommended. Offer to run `npx @taskless/cli@latest init` for them to reinitialize with the latest skills. ## Example Output diff --git a/skills/taskless-login/SKILL.md b/skills/taskless-login/SKILL.md index 19c8b8b8..d6f0e225 100644 --- a/skills/taskless-login/SKILL.md +++ b/skills/taskless-login/SKILL.md @@ -16,6 +16,8 @@ When this skill is invoked, explain the authentication process and provide the C ## Instructions -1. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help auth login` and read the output. Use this to understand the login flow, credential storage, and alternatives. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Read current command documentation.** Run `npx @taskless/cli@latest help auth login` and read the output. Use this to understand the login flow, credential storage, and alternatives. 2. **Present the login command and explain the process.** Using the information from the help output, display the command the user should run in their terminal and explain what will happen (device flow, credential storage, environment variable alternative). diff --git a/skills/taskless-logout/SKILL.md b/skills/taskless-logout/SKILL.md index fd8116fa..5468c6a9 100644 --- a/skills/taskless-logout/SKILL.md +++ b/skills/taskless-logout/SKILL.md @@ -16,6 +16,8 @@ When this skill is invoked, explain how to remove saved authentication and provi ## Instructions -1. **Read current command documentation.** Run `pnpm dlx @taskless/cli@latest help auth logout` and read the output. Use this to understand what the command does, credential storage location, and any caveats. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. + +1. **Read current command documentation.** Run `npx @taskless/cli@latest help auth logout` and read the output. Use this to understand what the command does, credential storage location, and any caveats. 2. **Present the logout command and explain what it does.** Using the information from the help output, display the command the user should run and explain the effects (credential removal, environment variable note). From bca4337b04a22f829ea69ed9a4bc359fe9da17a0 Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Mon, 6 Apr 2026 22:52:31 -0700 Subject: [PATCH 2/2] fix: Address review feedback for Yarn Classic and changeset wording - Fall back to npx for Yarn Classic (v1.x) since it lacks yarn dlx - Clarify skill package manager notes with "(Yarn Berry/2+ only)" - Narrow changeset description to match actual scope - Add unit tests for getCliPrefix() Co-Authored-By: Claude Opus 4.6 (1M context) --- .changeset/fix-auth-login-command.md | 2 +- commands/tskl/check.md | 2 +- commands/tskl/improve.md | 2 +- commands/tskl/info.md | 2 +- commands/tskl/login.md | 2 +- commands/tskl/logout.md | 2 +- commands/tskl/rule.md | 2 +- packages/cli/src/util/package-manager.ts | 8 +++- packages/cli/test/package-manager.test.ts | 44 +++++++++++++++++++ skills/taskless-check/SKILL.md | 2 +- .../taskless-create-rule-anonymous/SKILL.md | 2 +- skills/taskless-create-rule/SKILL.md | 2 +- skills/taskless-delete-rule/SKILL.md | 2 +- .../taskless-improve-rule-anonymous/SKILL.md | 2 +- skills/taskless-improve-rule/SKILL.md | 2 +- skills/taskless-info/SKILL.md | 2 +- skills/taskless-login/SKILL.md | 2 +- skills/taskless-logout/SKILL.md | 2 +- 18 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 packages/cli/test/package-manager.test.ts diff --git a/.changeset/fix-auth-login-command.md b/.changeset/fix-auth-login-command.md index 58cd9611..0d93fc00 100644 --- a/.changeset/fix-auth-login-command.md +++ b/.changeset/fix-auth-login-command.md @@ -5,4 +5,4 @@ Fix "auth login" to use the correct CLI command -Replaced bare `taskless auth login` references with the proper `npx @taskless/cli@latest auth login` invocation across all skills, commands, CLI error messages, and help text. CLI error messages now dynamically detect the invoking package manager (pnpm, yarn, bun, or npx) via `npm_config_user_agent`. Skills default to `npx` with a note to prefer the project's package manager. +Replaced bare `taskless auth login` references with the proper `npx @taskless/cli@latest auth login` invocation in skills, generated commands, CLI error messages, and rules help text. CLI error messages now dynamically detect the invoking package manager via `npm_config_user_agent`. Skills default to `npx` with a note to prefer the project's package manager. diff --git a/commands/tskl/check.md b/commands/tskl/check.md index 615c1e64..622f2bff 100644 --- a/commands/tskl/check.md +++ b/commands/tskl/check.md @@ -16,7 +16,7 @@ When this skill is invoked, perform a check of the codebase using the Taskless C ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Read current command documentation.** Run `npx @taskless/cli@latest help check` and read the output. Use this to understand the command's options, output format, and exit codes. diff --git a/commands/tskl/improve.md b/commands/tskl/improve.md index 3dd656b5..6d98b8dd 100644 --- a/commands/tskl/improve.md +++ b/commands/tskl/improve.md @@ -18,7 +18,7 @@ This is a decision-making skill. You must evaluate the situation and choose the ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Check authentication status.** Run `npx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: - If `loggedIn` is `true`: continue with step 2 below (API-backed flow). diff --git a/commands/tskl/info.md b/commands/tskl/info.md index 35053322..b4e6794a 100644 --- a/commands/tskl/info.md +++ b/commands/tskl/info.md @@ -16,7 +16,7 @@ When this skill is invoked, verify that the Taskless CLI is reachable and report ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Read current command documentation.** Run `npx @taskless/cli@latest help info` and read the output. Use this to understand the command's output format and available options. diff --git a/commands/tskl/login.md b/commands/tskl/login.md index 6cac96b3..71aba59c 100644 --- a/commands/tskl/login.md +++ b/commands/tskl/login.md @@ -18,7 +18,7 @@ When this skill is invoked, explain the authentication process and provide the C ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Read current command documentation.** Run `npx @taskless/cli@latest help auth login` and read the output. Use this to understand the login flow, credential storage, and alternatives. diff --git a/commands/tskl/logout.md b/commands/tskl/logout.md index ee5d669c..ecb29af6 100644 --- a/commands/tskl/logout.md +++ b/commands/tskl/logout.md @@ -18,7 +18,7 @@ When this skill is invoked, explain how to remove saved authentication and provi ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Read current command documentation.** Run `npx @taskless/cli@latest help auth logout` and read the output. Use this to understand what the command does, credential storage location, and any caveats. diff --git a/commands/tskl/rule.md b/commands/tskl/rule.md index bf909cbe..d2c4d68f 100644 --- a/commands/tskl/rule.md +++ b/commands/tskl/rule.md @@ -18,7 +18,7 @@ Your goal is to produce the best possible rule by enriching the user's initial d ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Check authentication status.** Run `npx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: - If `loggedIn` is `true`: continue with step 2 below (API-backed flow). diff --git a/packages/cli/src/util/package-manager.ts b/packages/cli/src/util/package-manager.ts index fda88d36..218ebafd 100644 --- a/packages/cli/src/util/package-manager.ts +++ b/packages/cli/src/util/package-manager.ts @@ -8,7 +8,13 @@ export function getCliPrefix(): string { const ua = process.env.npm_config_user_agent ?? ""; if (ua.startsWith("pnpm/")) return "pnpm dlx @taskless/cli@latest"; - if (ua.startsWith("yarn/")) return "yarn dlx @taskless/cli@latest"; + if (ua.startsWith("yarn/")) { + const major = Number.parseInt(ua.slice("yarn/".length), 10); + if (Number.isFinite(major) && major >= 2) { + return "yarn dlx @taskless/cli@latest"; + } + return "npx @taskless/cli@latest"; + } if (ua.startsWith("bun/")) return "bunx @taskless/cli@latest"; return "npx @taskless/cli@latest"; } diff --git a/packages/cli/test/package-manager.test.ts b/packages/cli/test/package-manager.test.ts new file mode 100644 index 00000000..5a0eeb09 --- /dev/null +++ b/packages/cli/test/package-manager.test.ts @@ -0,0 +1,44 @@ +import { describe, expect, it, afterEach } from "vitest"; +import { getCliPrefix } from "../src/util/package-manager"; + +describe("getCliPrefix", () => { + const originalUa = process.env.npm_config_user_agent; + + afterEach(() => { + if (originalUa === undefined) { + delete process.env.npm_config_user_agent; + } else { + process.env.npm_config_user_agent = originalUa; + } + }); + + it("returns pnpm dlx for pnpm", () => { + process.env.npm_config_user_agent = "pnpm/9.1.0 node/v22.0.0"; + expect(getCliPrefix()).toBe("pnpm dlx @taskless/cli@latest"); + }); + + it("returns yarn dlx for Yarn Berry (v2+)", () => { + process.env.npm_config_user_agent = "yarn/4.1.0 node/v22.0.0"; + expect(getCliPrefix()).toBe("yarn dlx @taskless/cli@latest"); + }); + + it("falls back to npx for Yarn Classic (v1)", () => { + process.env.npm_config_user_agent = "yarn/1.22.19 node/v20.0.0"; + expect(getCliPrefix()).toBe("npx @taskless/cli@latest"); + }); + + it("returns bunx for bun", () => { + process.env.npm_config_user_agent = "bun/1.0.0 node/v22.0.0"; + expect(getCliPrefix()).toBe("bunx @taskless/cli@latest"); + }); + + it("returns npx for npm", () => { + process.env.npm_config_user_agent = "npm/10.0.0 node/v22.0.0"; + expect(getCliPrefix()).toBe("npx @taskless/cli@latest"); + }); + + it("returns npx when user agent is unset", () => { + delete process.env.npm_config_user_agent; + expect(getCliPrefix()).toBe("npx @taskless/cli@latest"); + }); +}); diff --git a/skills/taskless-check/SKILL.md b/skills/taskless-check/SKILL.md index f269cc24..b4d2c11e 100644 --- a/skills/taskless-check/SKILL.md +++ b/skills/taskless-check/SKILL.md @@ -14,7 +14,7 @@ When this skill is invoked, perform a check of the codebase using the Taskless C ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Read current command documentation.** Run `npx @taskless/cli@latest help check` and read the output. Use this to understand the command's options, output format, and exit codes. diff --git a/skills/taskless-create-rule-anonymous/SKILL.md b/skills/taskless-create-rule-anonymous/SKILL.md index 405ad7ff..16585d70 100644 --- a/skills/taskless-create-rule-anonymous/SKILL.md +++ b/skills/taskless-create-rule-anonymous/SKILL.md @@ -13,7 +13,7 @@ This skill creates ast-grep rules locally without requiring Taskless authenticat ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Learn the ast-grep rule format.** Run `npx @taskless/cli@latest rules verify --schema --json` and read the output. This gives you: - `astGrepSchema`: The official ast-grep rule JSON Schema — the full reference for what fields are valid. diff --git a/skills/taskless-create-rule/SKILL.md b/skills/taskless-create-rule/SKILL.md index a8fbb498..e541533b 100644 --- a/skills/taskless-create-rule/SKILL.md +++ b/skills/taskless-create-rule/SKILL.md @@ -16,7 +16,7 @@ Your goal is to produce the best possible rule by enriching the user's initial d ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Check authentication status.** Run `npx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: - If `loggedIn` is `true`: continue with step 2 below (API-backed flow). diff --git a/skills/taskless-delete-rule/SKILL.md b/skills/taskless-delete-rule/SKILL.md index 08092d8a..f47baae3 100644 --- a/skills/taskless-delete-rule/SKILL.md +++ b/skills/taskless-delete-rule/SKILL.md @@ -14,7 +14,7 @@ When this skill is invoked, help the user identify which rule to delete, confirm ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Read current command documentation.** Run `npx @taskless/cli@latest help rules delete` and read the output. Use this to understand the command's arguments, options, and exit codes. diff --git a/skills/taskless-improve-rule-anonymous/SKILL.md b/skills/taskless-improve-rule-anonymous/SKILL.md index 1e906f7a..2b66f4ab 100644 --- a/skills/taskless-improve-rule-anonymous/SKILL.md +++ b/skills/taskless-improve-rule-anonymous/SKILL.md @@ -13,7 +13,7 @@ This skill improves existing ast-grep rules locally without requiring Taskless a ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Learn the ast-grep rule format.** Run `npx @taskless/cli@latest rules verify --schema --json` and read the output. Study the `astGrepSchema`, `tasklessRequirements`, and `examples` to understand valid rule structure and patterns. diff --git a/skills/taskless-improve-rule/SKILL.md b/skills/taskless-improve-rule/SKILL.md index ae16ef5c..4288fdcc 100644 --- a/skills/taskless-improve-rule/SKILL.md +++ b/skills/taskless-improve-rule/SKILL.md @@ -16,7 +16,7 @@ This is a decision-making skill. You must evaluate the situation and choose the ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Check authentication status.** Run `npx @taskless/cli@latest info --json` and parse the JSON output. Check the `loggedIn` field: - If `loggedIn` is `true`: continue with step 2 below (API-backed flow). diff --git a/skills/taskless-info/SKILL.md b/skills/taskless-info/SKILL.md index 646665f7..41031703 100644 --- a/skills/taskless-info/SKILL.md +++ b/skills/taskless-info/SKILL.md @@ -14,7 +14,7 @@ When this skill is invoked, verify that the Taskless CLI is reachable and report ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Read current command documentation.** Run `npx @taskless/cli@latest help info` and read the output. Use this to understand the command's output format and available options. diff --git a/skills/taskless-login/SKILL.md b/skills/taskless-login/SKILL.md index d6f0e225..69fffcc5 100644 --- a/skills/taskless-login/SKILL.md +++ b/skills/taskless-login/SKILL.md @@ -16,7 +16,7 @@ When this skill is invoked, explain the authentication process and provide the C ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Read current command documentation.** Run `npx @taskless/cli@latest help auth login` and read the output. Use this to understand the login flow, credential storage, and alternatives. diff --git a/skills/taskless-logout/SKILL.md b/skills/taskless-logout/SKILL.md index 5468c6a9..7ad1cab1 100644 --- a/skills/taskless-logout/SKILL.md +++ b/skills/taskless-logout/SKILL.md @@ -16,7 +16,7 @@ When this skill is invoked, explain how to remove saved authentication and provi ## Instructions -**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx`, or `bunx`. +**Package manager:** All commands below use `npx` as the default. If the project uses a different package manager (check for `pnpm-lock.yaml`, `yarn.lock`, or `bun.lockb`), prefer its equivalent: `pnpm dlx`, `yarn dlx` (Yarn Berry/2+ only), or `bunx`. 1. **Read current command documentation.** Run `npx @taskless/cli@latest help auth logout` and read the output. Use this to understand what the command does, credential storage location, and any caveats.