-
Notifications
You must be signed in to change notification settings - Fork 24
feat(cli): deprecate rules command in favor of skills #1361
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5cc5c76
feat(cli): deprecate rules command in favor of skills
stefanjudis 2f85b68
chore(cli): stop generating checkly.rules.md ai-context artifact
stefanjudis 9869cf0
test(e2e): update help output for deprecated rules command
stefanjudis 48a6d89
Potential fix for pull request finding
stefanjudis 96d7fa3
refactor(cli): present-tense rules deprecation notice; fix GitHub casing
stefanjudis 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
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,31 @@ | ||
| import { describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import Rules from '../rules.js' | ||
|
|
||
| const mockConfig = { | ||
| runHook: vi.fn().mockResolvedValue({ successes: [], failures: [] }), | ||
| } as any | ||
|
|
||
| function createCommand (...args: string[]) { | ||
| const cmd = new Rules(args, mockConfig) | ||
| cmd.log = vi.fn() as any | ||
| return cmd | ||
| } | ||
|
|
||
| function getLogged (cmd: Rules): string[] { | ||
| return (cmd.log as ReturnType<typeof vi.fn>).mock.calls.map( | ||
| (call: string[]) => call[0], | ||
| ) | ||
| } | ||
|
|
||
| describe('rules', () => { | ||
| it('prints the deprecation message pointing to skills', async () => { | ||
| const cmd = createCommand() | ||
|
|
||
| await cmd.run() | ||
|
|
||
| const logged = getLogged(cmd) | ||
| expect(logged.some(m => m.includes('is deprecated'))).toBe(true) | ||
| expect(logged.some(m => m.includes('checkly skills'))).toBe(true) | ||
| }) | ||
| }) |
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 |
|---|---|---|
| @@ -1,147 +1,15 @@ | ||
| import { BaseCommand } from './baseCommand.js' | ||
| import { readFile, writeFile, access, mkdir } from 'fs/promises' | ||
| import path, { join } from 'path' | ||
| import { constants } from 'fs' | ||
| import prompts from 'prompts' | ||
| import { fileURLToPath } from 'node:url' | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
|
||
| const BASE_RULES_FILE_PATH = join(__dirname, '../ai-context/checkly.rules.md') | ||
|
|
||
| // AI IDE configurations mapping | ||
| const AI_IDE_CONFIGS = { | ||
| 'Windsurf': { | ||
| rulesFolder: '.windsurf/rules', | ||
| rulesFileName: 'checkly.md', | ||
| }, | ||
| 'GitHub Copilot': { | ||
| rulesFolder: '.github/instructions', | ||
| rulesFileName: 'checkly.instructions.md', | ||
| }, | ||
| 'Cursor': { | ||
| rulesFolder: '.cursor/rules', | ||
| rulesFileName: 'checkly.mdc', | ||
| }, | ||
| 'Plain Markdown (checkly.md)': { | ||
| rulesFolder: '.', | ||
| rulesFileName: 'checkly.md', | ||
| }, | ||
| } as const | ||
|
|
||
| export default class Rules extends BaseCommand { | ||
| static hidden = false | ||
| static readOnly = true | ||
| static idempotent = true | ||
| static state = 'deprecated' | ||
| static description = | ||
| 'Generate a rules file to use with AI IDEs and Copilots.' | ||
|
|
||
| async run (): Promise<void> { | ||
| // Read the base rules file | ||
| const rulesContent = await this.readBaseRulesFile() | ||
| if (!rulesContent) { | ||
| this.error(`Failed to read rules file at ${BASE_RULES_FILE_PATH}`) | ||
| } | ||
|
|
||
| // In non-interactive mode, print rules to stdout and exit | ||
| const isNonInteractive = !process.stdin.isTTY | ||
| || !process.stdout.isTTY | ||
| || process.env.CI | ||
| || process.env.CHECKLY_NON_INTERACTIVE | ||
| if (isNonInteractive) { | ||
| this.log(rulesContent) | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| // Create options for multiselect - offer all configs from AI_IDE_CONFIGS | ||
| const choices = Object.entries(AI_IDE_CONFIGS).map(([ideName, ideConfig]) => { | ||
| return { | ||
| title: `${ideName} (${path.join(ideConfig.rulesFolder, ideConfig.rulesFileName)})`, | ||
| value: ideConfig, | ||
| selected: false, | ||
| } | ||
| }) | ||
|
|
||
| const isNonInteractive = !process.stdin.isTTY | ||
| || !process.stdout.isTTY | ||
| || process.env.CI | ||
| || process.env.CHECKLY_NON_INTERACTIVE | ||
|
|
||
| // Interactive mode - show multiselect | ||
| const { configs: selectedConfig } = await prompts({ | ||
| type: 'select', | ||
| name: 'configs', | ||
| message: 'Select the AI IDE configurations to generate rules for:', | ||
| choices, | ||
| initial: 0, | ||
| }) | ||
|
|
||
| if (!selectedConfig) { | ||
| this.log('Operation cancelled.') | ||
| return | ||
| } | ||
|
|
||
| this.log(`Generating rules`) | ||
|
|
||
| // Create rules directory if it doesn't exist | ||
| const rulesDir = join(process.cwd(), selectedConfig.rulesFolder) | ||
| try { | ||
| await mkdir(rulesDir, { recursive: true }) | ||
| } catch { | ||
| // Directory might already exist, ignore error | ||
| } | ||
|
|
||
| // Determine the target file path | ||
| const rulesFilePath = join(rulesDir, selectedConfig.rulesFileName) | ||
|
|
||
| // Check if file already exists and ask for confirmation (only in interactive mode) | ||
| let shouldOverwrite = true | ||
| if (!isNonInteractive) { | ||
| shouldOverwrite = await this.confirmOverwrite(rulesFilePath) | ||
| } | ||
|
|
||
| if (!shouldOverwrite) { | ||
| this.log(`Skipped ${rulesFilePath}`) | ||
| return | ||
| } | ||
|
|
||
| // Save the rules file | ||
| await writeFile(rulesFilePath, rulesContent, 'utf8') | ||
|
|
||
| this.log(`✅ Successfully saved Checkly rules file to: ${rulesFilePath}`) | ||
| } catch (error) { | ||
| this.error(`Failed to generate rules file: ${error}`) | ||
| } | ||
| } | ||
|
|
||
| private async readBaseRulesFile (): Promise<string> { | ||
| try { | ||
| return await readFile(BASE_RULES_FILE_PATH, 'utf8') | ||
| } catch (error) { | ||
| throw new Error( | ||
| `Failed to read base rules file at ${BASE_RULES_FILE_PATH}: ${error}`, | ||
| { cause: error }, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private async confirmOverwrite (targetPath: string): Promise<boolean> { | ||
| try { | ||
| await access(targetPath, constants.F_OK) | ||
|
|
||
| // File exists, ask for confirmation | ||
| const { overwrite } = await prompts({ | ||
| type: 'confirm', | ||
| name: 'overwrite', | ||
| message: `Rules file already exists at ${targetPath}. Do you want to overwrite it?`, | ||
| initial: false, | ||
| }) | ||
| 'Deprecated. Use `checkly skills` instead.' | ||
|
|
||
| return overwrite ?? false | ||
| } catch { | ||
| // File doesn't exist, no need to confirm | ||
| return true | ||
| } | ||
| run (): Promise<void> { | ||
| this.log('The `rules` command is deprecated. Use `checkly skills` instead.') | ||
| return Promise.resolve() | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is here to make the rules accessible on the docs via a marketing site redirect. I'll clean that all up.