diff --git a/.changeset/stub-recovery-launchers.md b/.changeset/stub-recovery-launchers.md new file mode 100644 index 000000000..7dc4006fc --- /dev/null +++ b/.changeset/stub-recovery-launchers.md @@ -0,0 +1,5 @@ +--- +"@taskless/cli": patch +--- + +The reference stubs Taskless installs into each tool directory now say that `pnpm dlx`, `yarn dlx` and `bunx` work in place of `npx` when restoring a missing `.taskless/skills/` file. An agent whose harness denies `npx` used to be pointed at a command it couldn't run. The restore command itself is unchanged and still version-free, so stubs don't move between releases. Your next `init` or `update` rewrites existing stubs once to add the sentence, so expect a one-line change in each tool directory's `SKILL.md`. diff --git a/openspec/changes/archive/2026-11-29-stub-recovery-launchers/.openspec.yaml b/openspec/changes/archive/2026-11-29-stub-recovery-launchers/.openspec.yaml new file mode 100644 index 000000000..992733754 --- /dev/null +++ b/openspec/changes/archive/2026-11-29-stub-recovery-launchers/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-11-29 diff --git a/openspec/changes/archive/2026-11-29-stub-recovery-launchers/proposal.md b/openspec/changes/archive/2026-11-29-stub-recovery-launchers/proposal.md new file mode 100644 index 000000000..d193b837d --- /dev/null +++ b/openspec/changes/archive/2026-11-29-stub-recovery-launchers/proposal.md @@ -0,0 +1,15 @@ +## Why + +Issue #717. Every reference stub ends with a recovery sentence naming `npx @taskless/cli init`. The command is fixed to `npx` on purpose: stubs are committed, and a pinned version or a per-machine launcher would rewrite them on every release or every teammate's install (#200, #227). In a repository whose agent settings deny `npx`, that leaves the agent at a command it cannot run. A CLI PMF survey run on 0.13.8 in a pnpm repo hit this. The agent recovered with `pnpm dlx`, but the stub never said that was an option. + +## What Changes + +- The recovery line gains a second sentence: `Use the same launcher you installed Taskless with: \`pnpm dlx\`, \`yarn dlx\` and \`bunx\` work in place of \`npx\`.`The first sentence is unchanged, so the recorded invocation is still read back from between "run`" and "` from the project root". +- The new sentence names no version and no machine, and is the same in every build, so it does not make stubs move per release or make builds rewrite one another's stubs. +- One-time migration: a stub whose recovery line lacks the new sentence is rewritten once by the next install, through the same check that already rewrites a stub with no recovery line. + +Not breaking. The bump is `patch`. + +## Delivery shape + +**Single PR.** One sentence, its migration and tests; the spec, implementation, and archive land together. diff --git a/openspec/changes/archive/2026-11-29-stub-recovery-launchers/specs/cli-init/spec.md b/openspec/changes/archive/2026-11-29-stub-recovery-launchers/specs/cli-init/spec.md new file mode 100644 index 000000000..2d96eb2bf --- /dev/null +++ b/openspec/changes/archive/2026-11-29-stub-recovery-launchers/specs/cli-init/spec.md @@ -0,0 +1,18 @@ +## ADDED Requirements + +### Requirement: A reference stub's recovery line says any launcher works + +A reference stub's recovery instruction SHALL follow the sentence naming the restore command with a second sentence saying that the launcher the user installed Taskless with works in place of `npx`, naming `pnpm dlx`, `yarn dlx` and `bunx`. The sentence SHALL be the same in every build and SHALL name no version and no machine, so that it does not vary per release or per installer. The sentence naming the restore command SHALL be unchanged by it. + +An install that finds a stub whose recovery instruction lacks this sentence SHALL rewrite that stub once. Detection SHALL NOT depend on the build that wrote the stub. + +#### Scenario: A new stub names the launchers + +- **WHEN** the CLI writes a skill stub +- **THEN** its recovery instruction SHALL say that `pnpm dlx`, `yarn dlx` and `bunx` work in place of `npx` + +#### Scenario: A stub with the one-sentence recovery line is rewritten once + +- **WHEN** an install finds a stub whose recovery instruction names a restore command but not the launchers +- **THEN** the install SHALL rewrite that stub +- **AND** a subsequent install SHALL leave it untouched diff --git a/openspec/changes/archive/2026-11-29-stub-recovery-launchers/tasks.md b/openspec/changes/archive/2026-11-29-stub-recovery-launchers/tasks.md new file mode 100644 index 000000000..4cb9c5466 --- /dev/null +++ b/openspec/changes/archive/2026-11-29-stub-recovery-launchers/tasks.md @@ -0,0 +1,9 @@ +## 1. Stub + +- [x] 1.1 Add `RECOVERY_LAUNCHERS` to `packages/cli/src/install/canonical.ts` and append it to the recovery line. +- [x] 1.2 Extend `stubPredatesRecovery` to treat a stub without that sentence as predating the current instruction. + +## 2. Tests and checks + +- [x] 2.1 Assert a new stub carries the sentence, and that a one-sentence stub is rewritten once and then left alone. +- [x] 2.2 Run `pnpm typecheck`, `pnpm lint`, and the test suite, including the nightly stub-recovery tests; add a patch changeset. diff --git a/openspec/specs/cli-init/spec.md b/openspec/specs/cli-init/spec.md index 5c125e890..fa9ce1145 100644 --- a/openspec/specs/cli-init/spec.md +++ b/openspec/specs/cli-init/spec.md @@ -1435,3 +1435,20 @@ When a bare invocation does not launch the wizard, the first line of its preambl - **WHEN** `taskless` is invoked with no subcommand, stdout not a TTY, and `CI` unset - **THEN** the preamble SHALL say to run from a terminal for an interactive install + +### Requirement: A reference stub's recovery line says any launcher works + +A reference stub's recovery instruction SHALL follow the sentence naming the restore command with a second sentence saying that the launcher the user installed Taskless with works in place of `npx`, naming `pnpm dlx`, `yarn dlx` and `bunx`. The sentence SHALL be the same in every build and SHALL name no version and no machine, so that it does not vary per release or per installer. The sentence naming the restore command SHALL be unchanged by it. + +An install that finds a stub whose recovery instruction lacks this sentence SHALL rewrite that stub once. Detection SHALL NOT depend on the build that wrote the stub. + +#### Scenario: A new stub names the launchers + +- **WHEN** the CLI writes a skill stub +- **THEN** its recovery instruction SHALL say that `pnpm dlx`, `yarn dlx` and `bunx` work in place of `npx` + +#### Scenario: A stub with the one-sentence recovery line is rewritten once + +- **WHEN** an install finds a stub whose recovery instruction names a restore command but not the launchers +- **THEN** the install SHALL rewrite that stub +- **AND** a subsequent install SHALL leave it untouched diff --git a/packages/cli/src/install/canonical.ts b/packages/cli/src/install/canonical.ts index e5dca9ad2..4100c9853 100644 --- a/packages/cli/src/install/canonical.ts +++ b/packages/cli/src/install/canonical.ts @@ -154,6 +154,17 @@ function restoreCommand(): string { */ const RECOVERY_TAIL = "to restore it, then read it."; +/** + * The sentence after the recovery command: any launcher works in place of + * `npx`. A harness can deny `npx` while allowing `pnpm dlx`, and the command + * above stays fixed to `npx` because the stub is committed (see + * {@link restoreCommand}). It names no version and no machine, so it is the + * same in every build and never moves a stub's bytes on its own. See + * taskless/cli#717. + */ +const RECOVERY_LAUNCHERS = + "Use the same launcher you installed Taskless with: `pnpm dlx`, `yarn dlx` and `bunx` work in place of `npx`."; + /** The literal that opens the recovery sentence's backtick-quoted command. */ const RECOVERY_RUN = "run `"; @@ -170,18 +181,22 @@ const RECOVERY_AFTER_COMMAND = "` from the project root "; function recoveryInstruction(canonical: string): string { return ( `If \`${canonical}\` does not exist, ${RECOVERY_RUN}${restoreCommand()}` + - `${RECOVERY_AFTER_COMMAND}${RECOVERY_TAIL}\n` + `${RECOVERY_AFTER_COMMAND}${RECOVERY_TAIL} ${RECOVERY_LAUNCHERS}\n` ); } /** - * Whether an existing stub was written before stubs carried a recovery - * instruction. Used by install as a one-time migration, in the same spirit as - * the `metadata.version` strip in {@link stubFrontmatterDrifted}: such a stub - * is rewritten once, after which its body is stable again. + * Whether an existing stub was written before stubs carried the current + * recovery instruction: none at all, or the one-sentence form without + * {@link RECOVERY_LAUNCHERS}. Used by install as a one-time migration, in the + * same spirit as the `metadata.version` strip in {@link stubFrontmatterDrifted}: + * such a stub is rewritten once, after which its body is stable again. Both + * fragments are the same in every build, so this never makes one build + * rewrite another's stub. */ export function stubPredatesRecovery(content: string): boolean { - return !parseFrontmatter(content).content.includes(RECOVERY_TAIL); + const body = parseFrontmatter(content).content; + return !body.includes(RECOVERY_TAIL) || !body.includes(RECOVERY_LAUNCHERS); } /** diff --git a/packages/cli/test/canonical-store.test.ts b/packages/cli/test/canonical-store.test.ts index b921c0d56..b3a1c551b 100644 --- a/packages/cli/test/canonical-store.test.ts +++ b/packages/cli/test/canonical-store.test.ts @@ -101,6 +101,17 @@ describe("buildSkillStub", () => { expect(content).toContain(`\`${PROD_INVOCATION} init\``); }); + it("says any launcher works in place of npx", () => { + // taskless/cli#717: a harness that denies npx left the agent at a command + // it could not run, with nothing saying pnpm dlx would do. + const { content } = parseFrontmatter( + buildSkillStub({ name: "taskless", description: "d" }) + ); + expect(content).toContain( + "to restore it, then read it. Use the same launcher you installed Taskless with: `pnpm dlx`, `yarn dlx` and `bunx` work in place of `npx`.\n" + ); + }); + it("embeds nothing that varies per release", () => { const stub = buildSkillStub({ name: "taskless", description: "d" }); // The stub lives outside `.taskless`, so its bytes must not move when only @@ -219,6 +230,18 @@ describe("stubPredatesRecovery", () => { ].join("\n"); expect(stubPredatesRecovery(legacyStub)).toBe(true); }); + + it("returns true once for a stub with the one-sentence recovery line", () => { + const current = buildSkillStub({ name: "taskless", description: "d" }); + const oneSentence = current.replace( + / Use the same launcher you installed Taskless with:[^\n]*/, + "" + ); + expect(oneSentence).not.toBe(current); + expect(stubPredatesRecovery(oneSentence)).toBe(true); + // The rewrite produces `current`, which is then left alone. + expect(stubPredatesRecovery(current)).toBe(false); + }); }); /** A copy of `stub` whose recovery line names `invocation` instead. */