From 9c7398214b3c8919494d4424a1b2b891aa8b3209 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 24 Jun 2025 19:51:49 -0700 Subject: [PATCH] fix: rules create should create file in current directory --- cmd/create.go | 2 +- internal/ruleset/ruleset.go | 12 ++---------- spec/commands/create.md | 10 +++++----- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/cmd/create.go b/cmd/create.go index a020d9c..d6e49b9 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -24,7 +24,7 @@ var ( var createCmd = &cobra.Command{ Use: "create [rule-name] [rule-body]", Short: "Create a new rule using Continue format", - Long: `Create a new rule in the .continue/rules directory using Continue format specification. + Long: `Create a new rule in the current directory using Continue format specification. If rule parameters are not provided, they will be prompted for interactively. This command does not modify the rules.json file.`, Example: ` rules create my-rule "This is the body of the rule" diff --git a/internal/ruleset/ruleset.go b/internal/ruleset/ruleset.go index 2809ec4..2e58146 100644 --- a/internal/ruleset/ruleset.go +++ b/internal/ruleset/ruleset.go @@ -121,16 +121,8 @@ func CreateRule(rule Rule, format, name string) (string, error) { content += "---\n\n" + rule.Body - // Determine directory based on format (use Continue format) - ruleDir := ".continue/rules" - - // Ensure the directory exists - if err := os.MkdirAll(ruleDir, 0755); err != nil { - return "", err - } - - // Create the rule file - fileName := filepath.Join(ruleDir, name+".md") + // Create the rule file in the current directory + fileName := name + ".md" err := os.WriteFile(fileName, []byte(content), 0644) if err != nil { return "", err diff --git a/spec/commands/create.md b/spec/commands/create.md index 5bda435..255ceb2 100644 --- a/spec/commands/create.md +++ b/spec/commands/create.md @@ -14,7 +14,7 @@ rules create --alwaysApply "Always apply this rule" # Body not supplied, so will ## Flags - `--tags`: Comma-separated list of tags -- `--globs`: Glob patterns to match files (defaults to "**/*" if not specified) +- `--globs`: Glob patterns to match files (defaults to "\*\*/\*" if not specified) - `--description`: Short description - `--alwaysApply`: Flag to always apply rule (creates `alwaysApply: true` in frontmatter) @@ -27,10 +27,9 @@ rules create --alwaysApply "Always apply this rule" # Body not supplied, so will - Prompts for missing fields if not provided - Allows for stdin/editor input for rule body -- Creates a new rule (.md) file in `.continue/rules/` directory following Continue format +- Creates a new rule (.md) file in the current directory following Continue format - Uses Continue frontmatter format with `alwaysApply`, `description`, and `globs` fields - Does not modify the rules.json file -- Automatically creates `.continue/rules/` directory if it doesn't exist ## Continue Format Output @@ -47,8 +46,9 @@ globs: "**/*.tsx" ``` ### Frontmatter Fields: + - `alwaysApply`: boolean - Whether to always apply the rule (set via `--alwaysApply` flag) - `description`: string - Short description of the rule (set via `--description` flag) -- `globs`: string - Glob patterns to match files (set via `--globs` flag, defaults to "**/*") +- `globs`: string - Glob patterns to match files (set via `--globs` flag, defaults to "\*\*/\*") -Note: Tags are not part of the Continue format specification and will be omitted from the frontmatter. \ No newline at end of file +Note: Tags are not part of the Continue format specification and will be omitted from the frontmatter.