-
Notifications
You must be signed in to change notification settings - Fork 0
feat(check): give git steps instead of rule restore on a plan that does not serve it #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
theCodeDrift
merged 3 commits into
plan-aware-recovery/1-entitlement
from
plan-aware-recovery/2-check
Oct 1, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
f966ca5
docs(openspec): record the measured any-engine pathspec, and tick the…
theCodeDrift 5d25a38
feat(check): give git steps instead of rule restore on a plan that do…
theCodeDrift 8ab694e
test(check): cover a rename whose source engine is unknown
theCodeDrift File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@taskless/cli": patch | ||
| --- | ||
|
|
||
| `taskless check` stops suggesting `taskless rule restore` to an organization whose plan does not include restoring rules. For an edited or missing rule, and for a renamed one, it gives the `git log` and `git restore` steps for the rule's directory instead, so a user is no longer sent to run a command the service will refuse. The plan is read from the `whoami` call the CLI already makes, so no request is added. When the plan is unknown, the suggestion is `rule restore` as before, and `rule restore` still asks the service on every plan. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import type { EngineName } from "./layout"; | ||
|
|
||
| /** | ||
| * How a notice tells the user to put back an issued rule. | ||
| * | ||
| * The plan decides which answer is honest. When the acting organization's | ||
| * `restoreRules` entitlement is exactly `false`, the service will refuse | ||
| * `rule restore`, so suggesting it only sends the user to be told to use git. | ||
| * They get the git steps directly instead. Unknown (whoami failed, no | ||
| * entitlement sent, or no organization matched) keeps suggesting | ||
| * `rule restore`, word for word as before: the service answers a restore on | ||
| * its own, so a wrong guess costs one refused call, never a lost capability. | ||
| * | ||
| * This decides only what is suggested. Nothing here stops a user running | ||
| * `rule restore`, which always asks the service. | ||
| */ | ||
|
|
||
| /** A rule a notice points at, and what putting it back is for. */ | ||
| export interface RecoveryTarget { | ||
| ruleId: string; | ||
| /** The rule's engine, when known. Unknown widens the git pathspec. */ | ||
| engine?: EngineName; | ||
| /** Completes "Run `…` to <purpose>", e.g. "put back the issued version". */ | ||
| purpose: string; | ||
| /** A step after recovering, e.g. "delete .taskless/rules/vale/bar-2/". */ | ||
| afterwards?: string; | ||
| /** What to do instead of recovering, e.g. "ignore this if …". */ | ||
| otherwise?: string; | ||
| } | ||
|
|
||
| /** Renders the sentence a notice ends with. */ | ||
| export type Recovery = (target: RecoveryTarget) => string; | ||
|
|
||
| /** | ||
| * The directory `git` should look at. Quoted when the engine is unknown, so | ||
| * the shell passes the glob to git as a pathspec rather than expanding it. | ||
| * The glob matches the rule's files, not its directory, because git matches | ||
| * a glob against file paths: measured, a glob ending in the directory's slash | ||
| * finds no commits in `git log`, while one ending in a file wildcard finds | ||
| * them and works for `restore` too. An exact directory needs no glob. | ||
| */ | ||
| function ruleDirectory(ruleId: string, engine?: EngineName): string { | ||
| return engine === undefined | ||
| ? `'.taskless/rules/*/${ruleId}/*'` | ||
| : `.taskless/rules/${engine}/${ruleId}/`; | ||
| } | ||
|
|
||
| /** The sentence for a plan known not to include rule recovery. */ | ||
| function gitSteps({ ruleId, engine, afterwards, otherwise }: RecoveryTarget) { | ||
| const directory = ruleDirectory(ruleId, engine); | ||
| return ( | ||
| `Restoring rules is not included in your organization's plan, so recover ${ruleId} from git: ` + | ||
| `\`git log -- ${directory}\` lists the commits that changed it, and ` + | ||
| `\`git restore --source=<commit> -- ${directory}\` puts it back as of one of them.` + | ||
| (afterwards === undefined ? "" : ` Then ${afterwards}.`) + | ||
| (otherwise === undefined ? "" : ` Or ${otherwise}.`) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Build the recovery sentence for a plan. `restoreCommand` renders the | ||
| * `rule restore` invocation, so this stays free of how the CLI was invoked. | ||
| */ | ||
| export function recoveryAdvice( | ||
| restoreRules: boolean | undefined, | ||
| restoreCommand: (ruleId: string) => string | ||
| ): Recovery { | ||
| if (restoreRules === false) return gitSteps; | ||
| return ({ ruleId, purpose, afterwards, otherwise }) => | ||
| `Run \`${restoreCommand(ruleId)}\` to ${purpose}` + | ||
| (afterwards === undefined ? "" : `, then ${afterwards}`) + | ||
| (otherwise === undefined ? "" : `, or ${otherwise}`) + | ||
| "."; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.