Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .deepwork/jobs/deepwork_rules/rules/skill-md-validation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: SKILL.md Validation
trigger: "**/SKILL.md"
compare_to: base
---
A SKILL.md file has been created or modified. Please validate that it follows the required format:

Expand Down
1 change: 1 addition & 0 deletions .deepwork/rules/architecture-documentation-accuracy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: Architecture Documentation Accuracy
trigger: src/**/*
safety: doc/architecture.md
compare_to: base
---
Source code in src/ has been modified. Please review doc/architecture.md for accuracy:
1. Verify the documented architecture matches the current implementation
Expand Down
1 change: 1 addition & 0 deletions .deepwork/rules/readme-accuracy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: README Accuracy
trigger: src/**/*
safety: README.md
compare_to: base
---
Source code in src/ has been modified. Please review README.md for accuracy:
1. Verify project overview still reflects current functionality
Expand Down
1 change: 1 addition & 0 deletions .deepwork/rules/standard-jobs-source-of-truth.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ trigger:
safety:
- src/deepwork/standard_jobs/deepwork_jobs/**/*
- src/deepwork/standard_jobs/deepwork_rules/**/*
compare_to: base
---
You modified files in `.deepwork/jobs/deepwork_jobs/` or `.deepwork/jobs/deepwork_rules/`.

Expand Down
1 change: 1 addition & 0 deletions .deepwork/rules/version-and-changelog-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ trigger: src/**/*
safety:
- pyproject.toml
- CHANGELOG.md
compare_to: base
---
Source code in src/ has been modified. **You MUST evaluate whether version and changelog updates are needed.**

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ name: Source/Test Pairing
set:
- src/{path}.py
- tests/{path}_test.py
compare_to: base
---
When source files change, corresponding test files should also change.
Please create or update tests for the modified source files.
Expand All @@ -275,6 +276,7 @@ trigger: "**/*.py"
action:
command: "ruff format {file}"
run_for: each_match
compare_to: prompt
---
```

Expand Down
6 changes: 6 additions & 0 deletions doc/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ name: Source/Test Pairing
set:
- src/{path}.py
- tests/{path}_test.py
compare_to: base
---
When source files change, corresponding test files should also change.
Please create or update tests for the modified source files.
Expand All @@ -1043,6 +1044,7 @@ Rules support three detection modes:
name: Update install guide
trigger: "app/config/**/*"
safety: "docs/install_guide.md"
compare_to: base
---
```

Expand All @@ -1053,6 +1055,7 @@ name: Source/Test Pairing
set:
- src/{path}.py
- tests/{path}_test.py
compare_to: base
---
```
Uses variable patterns like `{path}` (multi-segment) and `{name}` (single-segment) for matching.
Expand All @@ -1064,6 +1067,7 @@ name: API Documentation
pair:
trigger: src/api/{name}.py
expects: docs/api/{name}.md
compare_to: base
---
```

Expand All @@ -1074,6 +1078,7 @@ pair:
---
name: Security Review
trigger: "src/auth/**/*"
compare_to: base
---
Please check for hardcoded credentials and validate input.
```
Expand All @@ -1086,6 +1091,7 @@ trigger: "**/*.py"
action:
command: "ruff format {file}"
run_for: each_match # or "all_matches"
compare_to: prompt
---
```

Expand Down
20 changes: 17 additions & 3 deletions doc/rules_syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AuthService:
name: README Accuracy
trigger: src/**/*
safety: README.md
compare_to: base
---
Source code changed. Please verify README.md is accurate.

Expand All @@ -54,6 +55,7 @@ name: Source/Test Pairing
set:
- src/{path}.py
- tests/{path}_test.py
compare_to: base
---
Source and test files should change together.

Expand All @@ -70,6 +72,7 @@ name: API Documentation
pair:
trigger: api/{path}.py
expects: docs/api/{path}.md
compare_to: base
---
API changes require documentation updates.

Expand All @@ -88,6 +91,7 @@ name: Python Formatting
trigger: "**/*.py"
action:
command: ruff format {file}
compare_to: prompt
---
Automatically formats Python files using ruff.

Expand Down Expand Up @@ -145,6 +149,7 @@ name: Source/Test Pairing
set:
- src/{path}.py
- tests/{path}_test.py
compare_to: base
---
```

Expand Down Expand Up @@ -176,18 +181,21 @@ name: API Documentation
pair:
trigger: api/{module}/{name}.py
expects: docs/api/{module}/{name}.md
compare_to: base
---
```

Can specify multiple expected patterns:

```yaml
---
name: API Documentation
pair:
trigger: api/{path}.py
expects:
- docs/api/{path}.md
- schemas/{path}.json
compare_to: base
---
```

Expand Down Expand Up @@ -224,6 +232,7 @@ safety: "*.pyi"
action:
command: ruff format {file}
run_for: each_match
compare_to: prompt
---
```

Expand Down Expand Up @@ -385,19 +394,19 @@ action:
---
```

### compare_to (optional)
### compare_to (required)

Determines the baseline for detecting file changes.

| Value | Description |
|-------|-------------|
| `base` (default) | Compare to merge-base with default branch |
| `base` | Compare to merge-base with default branch |
| `default_tip` | Compare to current tip of default branch |
| `prompt` | Compare to state at last prompt submission |

```yaml
---
compare_to: prompt
compare_to: base
---
```

Expand All @@ -412,6 +421,7 @@ name: Test Coverage
set:
- src/{path}.py
- tests/{path}_test.py
compare_to: base
---
Source code was modified without corresponding test updates.

Expand All @@ -434,6 +444,7 @@ pair:
expects:
- docs/api/{module}/{endpoint}.md
- openapi/{module}.yaml
compare_to: base
---
API endpoint changed. Please update:
- Documentation: {expected_files}
Expand All @@ -453,6 +464,7 @@ safety:
action:
command: black {file}
run_for: each_match
compare_to: prompt
---
Formats Python files using Black.

Expand All @@ -472,6 +484,7 @@ set:
- backend/api/{feature}/models.py
- frontend/src/api/{feature}.ts
- frontend/src/components/{feature}/**/*
compare_to: base
---
Feature files should be updated together across the stack.

Expand All @@ -494,6 +507,7 @@ trigger:
safety:
- pyproject.toml
- CHANGELOG.md
compare_to: base
---
Code changes detected. Before merging, ensure:
- Version is bumped in pyproject.toml (if needed)
Expand Down
13 changes: 7 additions & 6 deletions src/deepwork/core/rules_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class ActionType(Enum):

# Valid compare_to values
COMPARE_TO_VALUES = frozenset({"base", "default_tip", "prompt"})
DEFAULT_COMPARE_TO = "base"


@dataclass
Expand Down Expand Up @@ -69,6 +68,11 @@ class Rule:

# Detection mode (exactly one must be set)
detection_mode: DetectionMode

# Common options (required)
compare_to: str # Required: "base", "default_tip", or "prompt"

# Detection mode details (optional, depends on mode)
triggers: list[str] = field(default_factory=list) # For TRIGGER_SAFETY mode
safety: list[str] = field(default_factory=list) # For TRIGGER_SAFETY mode
set_patterns: list[str] = field(default_factory=list) # For SET mode
Expand All @@ -79,9 +83,6 @@ class Rule:
instructions: str = "" # For PROMPT action (markdown body)
command_action: CommandAction | None = None # For COMMAND action

# Common options
compare_to: str = DEFAULT_COMPARE_TO

@classmethod
def from_frontmatter(
cls,
Expand Down Expand Up @@ -166,8 +167,8 @@ def from_frontmatter(
if not markdown_body.strip():
raise RulesParseError(f"Rule '{name}' with prompt action requires markdown body")

# Get compare_to
compare_to = frontmatter.get("compare_to", DEFAULT_COMPARE_TO)
# Get compare_to (required field)
compare_to = frontmatter["compare_to"]

return cls(
name=name,
Expand Down
3 changes: 1 addition & 2 deletions src/deepwork/schemas/rules_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
RULES_FRONTMATTER_SCHEMA: dict[str, Any] = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["name"],
"required": ["name", "compare_to"],
"properties": {
"name": {
"type": "string",
Expand Down Expand Up @@ -80,7 +80,6 @@
"compare_to": {
"type": "string",
"enum": ["base", "default_tip", "prompt"],
"default": "base",
"description": "Baseline for detecting file changes",
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: SKILL.md Validation
trigger: "**/SKILL.md"
compare_to: base
---
A SKILL.md file has been created or modified. Please validate that it follows the required format:

Expand Down
Loading