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
3 changes: 1 addition & 2 deletions .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@
"Skill(manual_tests.run_fire_tests)",
"Skill(deepwork_rules)",
"Skill(deepwork_rules.define)",
"Bash(rm -rf .deepwork/tmp/rules/queue/**)",
"Bash(rm -rf .deepwork/tmp/rules/queue/*.json)"
"Bash(deepwork rules clear_queue)"
]
},
"hooks": {
Expand Down
6 changes: 3 additions & 3 deletions .deepwork/jobs/manual_tests/steps/run_fire_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ For EACH test below, follow this cycle:
6. **Revert changes and clear queue** (MANDATORY after each test):
```bash
git reset HEAD manual_tests/ && git checkout -- manual_tests/ && rm -f manual_tests/test_created_mode/new_config.yml
rm -rf .deepwork/tmp/rules/queue/*.json 2>/dev/null || true
deepwork rules clear_queue
```
**Why this command sequence**:
- `git reset HEAD manual_tests/` - Unstages files from the index (rules_check uses `git add -A` which stages changes)
- `git checkout -- manual_tests/` - Reverts working tree to match HEAD
- `rm -f ...` - Removes any new files created during tests
- The queue clear removes rules that have been shown (status=QUEUED) so they can fire again
- `deepwork rules clear_queue` - Clears the rules queue so rules can fire again
7. **Check for early termination**: If **2 tests have now failed**, immediately:
- Stop running any remaining tests
- Report the results summary showing which tests passed/failed
Expand Down Expand Up @@ -122,7 +122,7 @@ Record the result after each test:

- **Sub-agents spawned**: Tests were run using the Task tool to spawn sub-agents - the main agent did NOT edit files directly
- **Serial execution**: Sub-agents were launched ONE AT A TIME, not in parallel
- **Git reverted and queue cleared between tests**: `git reset HEAD manual_tests/ && git checkout -- manual_tests/` and `rm -rf .deepwork/tmp/rules/queue/*.json` was run after each test
- **Git reverted and queue cleared between tests**: `git reset HEAD manual_tests/ && git checkout -- manual_tests/` and `deepwork rules clear_queue` was run after each test
- **Hooks observed (not triggered)**: The main agent observed hook behavior without manually running rules_check - hooks fired AUTOMATICALLY
- **Blocking behavior verified**: For each test run, the appropriate blocking hook fired automatically when the sub-agent returned
- **Early termination on 2 failures**: If 2 tests failed, testing halted immediately and results were reported
Expand Down
6 changes: 3 additions & 3 deletions .deepwork/jobs/manual_tests/steps/run_not_fire_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,22 @@ Run all 8 "should NOT fire" tests in **parallel** sub-agents, then verify no blo
Run these commands to clean up:
```bash
git reset HEAD manual_tests/ && git checkout -- manual_tests/ && rm -f manual_tests/test_created_mode/new_config.yml
rm -rf .deepwork/tmp/rules/queue/*.json 2>/dev/null || true
deepwork rules clear_queue
```

**Why this command sequence**:
- `git reset HEAD manual_tests/` - Unstages files from the index (rules_check uses `git add -A` which stages changes)
- `git checkout -- manual_tests/` - Reverts working tree to match HEAD
- `rm -f manual_tests/test_created_mode/new_config.yml` - Removes any new files created during tests
- The queue clear removes rules that have been shown (status=QUEUED) so they can fire again
- `deepwork rules clear_queue` - Clears the rules queue so rules can fire again

## Quality Criteria

- **Sub-agents spawned**: All 8 tests were run using the Task tool to spawn sub-agents - the main agent did NOT edit files directly
- **Parallel execution**: All 8 sub-agents were launched in a single message (parallel)
- **Hooks observed (not triggered)**: The main agent observed hook behavior without manually running rules_check
- **Early termination on 2 failures**: If 2 tests failed, testing halted immediately and results were reported
- **Changes reverted and queue cleared**: `git reset HEAD manual_tests/ && git checkout -- manual_tests/` and `rm -rf .deepwork/tmp/rules/queue/*.json` was run after tests completed (regardless of pass/fail)
- **Changes reverted and queue cleared**: `git reset HEAD manual_tests/ && git checkout -- manual_tests/` and `deepwork rules clear_queue` was run after tests completed (regardless of pass/fail)
- When all criteria are met, include `<promise>✓ Quality Criteria Met</promise>` in your response

## Reference
Expand Down
2 changes: 2 additions & 0 deletions src/deepwork/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ def cli() -> None:
# Import commands
from deepwork.cli.hook import hook # noqa: E402
from deepwork.cli.install import install # noqa: E402
from deepwork.cli.rules import rules # noqa: E402
from deepwork.cli.sync import sync # noqa: E402

cli.add_command(install)
cli.add_command(sync)
cli.add_command(hook)
cli.add_command(rules)


if __name__ == "__main__":
Expand Down
32 changes: 32 additions & 0 deletions src/deepwork/cli/rules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Rules command for DeepWork CLI."""

import click
from rich.console import Console

from deepwork.core.rules_queue import RulesQueue

console = Console()


@click.group()
def rules() -> None:
"""Manage DeepWork rules and queue."""
pass


@rules.command(name="clear_queue")
def clear_queue() -> None:
"""
Clear all entries from the rules queue.

Removes all JSON files from .deepwork/tmp/rules/queue/.
This is useful for resetting the queue between tests or after
manual verification of rule states.
"""
queue = RulesQueue()
count = queue.clear()

if count == 0:
console.print("[yellow]Queue is already empty[/yellow]")
else:
console.print(f"[green]Cleared {count} queue entry/entries[/green]")