Skip to content

Commit b5157d6

Browse files
authored
Merge pull request #20 from continuedev/nate/create-update
fix: rules create should create file in current directory
2 parents 1067616 + 9c73982 commit b5157d6

3 files changed

Lines changed: 8 additions & 16 deletions

File tree

cmd/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var (
2424
var createCmd = &cobra.Command{
2525
Use: "create [rule-name] [rule-body]",
2626
Short: "Create a new rule using Continue format",
27-
Long: `Create a new rule in the .continue/rules directory using Continue format specification.
27+
Long: `Create a new rule in the current directory using Continue format specification.
2828
If rule parameters are not provided, they will be prompted for interactively.
2929
This command does not modify the rules.json file.`,
3030
Example: ` rules create my-rule "This is the body of the rule"

internal/ruleset/ruleset.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,8 @@ func CreateRule(rule Rule, format, name string) (string, error) {
121121

122122
content += "---\n\n" + rule.Body
123123

124-
// Determine directory based on format (use Continue format)
125-
ruleDir := ".continue/rules"
126-
127-
// Ensure the directory exists
128-
if err := os.MkdirAll(ruleDir, 0755); err != nil {
129-
return "", err
130-
}
131-
132-
// Create the rule file
133-
fileName := filepath.Join(ruleDir, name+".md")
124+
// Create the rule file in the current directory
125+
fileName := name + ".md"
134126
err := os.WriteFile(fileName, []byte(content), 0644)
135127
if err != nil {
136128
return "", err

spec/commands/create.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rules create --alwaysApply "Always apply this rule" # Body not supplied, so will
1414
## Flags
1515

1616
- `--tags`: Comma-separated list of tags
17-
- `--globs`: Glob patterns to match files (defaults to "**/*" if not specified)
17+
- `--globs`: Glob patterns to match files (defaults to "\*\*/\*" if not specified)
1818
- `--description`: Short description
1919
- `--alwaysApply`: Flag to always apply rule (creates `alwaysApply: true` in frontmatter)
2020

@@ -27,10 +27,9 @@ rules create --alwaysApply "Always apply this rule" # Body not supplied, so will
2727

2828
- Prompts for missing fields if not provided
2929
- Allows for stdin/editor input for rule body
30-
- Creates a new rule (.md) file in `.continue/rules/` directory following Continue format
30+
- Creates a new rule (.md) file in the current directory following Continue format
3131
- Uses Continue frontmatter format with `alwaysApply`, `description`, and `globs` fields
3232
- Does not modify the rules.json file
33-
- Automatically creates `.continue/rules/` directory if it doesn't exist
3433

3534
## Continue Format Output
3635

@@ -47,8 +46,9 @@ globs: "**/*.tsx"
4746
```
4847

4948
### Frontmatter Fields:
49+
5050
- `alwaysApply`: boolean - Whether to always apply the rule (set via `--alwaysApply` flag)
5151
- `description`: string - Short description of the rule (set via `--description` flag)
52-
- `globs`: string - Glob patterns to match files (set via `--globs` flag, defaults to "**/*")
52+
- `globs`: string - Glob patterns to match files (set via `--globs` flag, defaults to "\*\*/\*")
5353

54-
Note: Tags are not part of the Continue format specification and will be omitted from the frontmatter.
54+
Note: Tags are not part of the Continue format specification and will be omitted from the frontmatter.

0 commit comments

Comments
 (0)