deepwork 0.5.1__py3-none-any.whl → 0.7.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. deepwork/__init__.py +1 -1
  2. deepwork/cli/hook.py +3 -4
  3. deepwork/cli/install.py +70 -117
  4. deepwork/cli/main.py +2 -2
  5. deepwork/cli/serve.py +133 -0
  6. deepwork/cli/sync.py +93 -58
  7. deepwork/core/adapters.py +91 -102
  8. deepwork/core/generator.py +19 -386
  9. deepwork/core/hooks_syncer.py +1 -1
  10. deepwork/core/parser.py +270 -1
  11. deepwork/hooks/README.md +0 -44
  12. deepwork/hooks/__init__.py +3 -6
  13. deepwork/hooks/check_version.sh +54 -21
  14. deepwork/mcp/__init__.py +23 -0
  15. deepwork/mcp/quality_gate.py +347 -0
  16. deepwork/mcp/schemas.py +263 -0
  17. deepwork/mcp/server.py +253 -0
  18. deepwork/mcp/state.py +422 -0
  19. deepwork/mcp/tools.py +394 -0
  20. deepwork/schemas/job.schema.json +347 -0
  21. deepwork/schemas/job_schema.py +27 -239
  22. deepwork/standard_jobs/deepwork_jobs/doc_specs/job_spec.md +9 -15
  23. deepwork/standard_jobs/deepwork_jobs/job.yml +146 -46
  24. deepwork/standard_jobs/deepwork_jobs/steps/define.md +100 -33
  25. deepwork/standard_jobs/deepwork_jobs/steps/errata.md +154 -0
  26. deepwork/standard_jobs/deepwork_jobs/steps/fix_jobs.md +207 -0
  27. deepwork/standard_jobs/deepwork_jobs/steps/fix_settings.md +177 -0
  28. deepwork/standard_jobs/deepwork_jobs/steps/implement.md +22 -138
  29. deepwork/standard_jobs/deepwork_jobs/steps/iterate.md +221 -0
  30. deepwork/standard_jobs/deepwork_jobs/steps/learn.md +2 -26
  31. deepwork/standard_jobs/deepwork_jobs/steps/test.md +154 -0
  32. deepwork/standard_jobs/deepwork_jobs/templates/job.yml.template +2 -0
  33. deepwork/templates/claude/settings.json +16 -0
  34. deepwork/templates/claude/skill-deepwork.md.jinja +37 -0
  35. deepwork/templates/gemini/skill-deepwork.md.jinja +37 -0
  36. deepwork-0.7.0a1.dist-info/METADATA +317 -0
  37. deepwork-0.7.0a1.dist-info/RECORD +64 -0
  38. deepwork/cli/rules.py +0 -32
  39. deepwork/core/command_executor.py +0 -190
  40. deepwork/core/pattern_matcher.py +0 -271
  41. deepwork/core/rules_parser.py +0 -559
  42. deepwork/core/rules_queue.py +0 -321
  43. deepwork/hooks/rules_check.py +0 -759
  44. deepwork/schemas/rules_schema.py +0 -135
  45. deepwork/standard_jobs/deepwork_jobs/steps/review_job_spec.md +0 -208
  46. deepwork/standard_jobs/deepwork_jobs/templates/doc_spec.md.example +0 -86
  47. deepwork/standard_jobs/deepwork_rules/hooks/capture_prompt_work_tree.sh +0 -38
  48. deepwork/standard_jobs/deepwork_rules/hooks/global_hooks.yml +0 -8
  49. deepwork/standard_jobs/deepwork_rules/hooks/user_prompt_submit.sh +0 -16
  50. deepwork/standard_jobs/deepwork_rules/job.yml +0 -49
  51. deepwork/standard_jobs/deepwork_rules/rules/.gitkeep +0 -13
  52. deepwork/standard_jobs/deepwork_rules/rules/api-documentation-sync.md.example +0 -10
  53. deepwork/standard_jobs/deepwork_rules/rules/readme-documentation.md.example +0 -10
  54. deepwork/standard_jobs/deepwork_rules/rules/security-review.md.example +0 -11
  55. deepwork/standard_jobs/deepwork_rules/rules/skill-md-validation.md +0 -46
  56. deepwork/standard_jobs/deepwork_rules/rules/source-test-pairing.md.example +0 -13
  57. deepwork/standard_jobs/deepwork_rules/steps/define.md +0 -249
  58. deepwork/templates/claude/skill-job-meta.md.jinja +0 -77
  59. deepwork/templates/claude/skill-job-step.md.jinja +0 -235
  60. deepwork/templates/gemini/skill-job-meta.toml.jinja +0 -76
  61. deepwork/templates/gemini/skill-job-step.toml.jinja +0 -162
  62. deepwork-0.5.1.dist-info/METADATA +0 -381
  63. deepwork-0.5.1.dist-info/RECORD +0 -72
  64. {deepwork-0.5.1.dist-info → deepwork-0.7.0a1.dist-info}/WHEEL +0 -0
  65. {deepwork-0.5.1.dist-info → deepwork-0.7.0a1.dist-info}/entry_points.txt +0 -0
  66. {deepwork-0.5.1.dist-info → deepwork-0.7.0a1.dist-info}/licenses/LICENSE.md +0 -0
@@ -1,135 +0,0 @@
1
- """JSON Schema definition for rule definitions (v2 - frontmatter format)."""
2
-
3
- from typing import Any
4
-
5
- # Pattern for string or array of strings
6
- STRING_OR_ARRAY: dict[str, Any] = {
7
- "oneOf": [
8
- {"type": "string", "minLength": 1},
9
- {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
10
- ]
11
- }
12
-
13
- # JSON Schema for rule frontmatter (YAML between --- delimiters)
14
- # Rules are stored as individual .md files in .deepwork/rules/
15
- RULES_FRONTMATTER_SCHEMA: dict[str, Any] = {
16
- "$schema": "http://json-schema.org/draft-07/schema#",
17
- "type": "object",
18
- "required": ["name", "compare_to"],
19
- "properties": {
20
- "name": {
21
- "type": "string",
22
- "minLength": 1,
23
- "description": "Human-friendly name for the rule (displayed in promise tags)",
24
- },
25
- # Detection mode: trigger/safety (mutually exclusive with set/pair)
26
- "trigger": {
27
- **STRING_OR_ARRAY,
28
- "description": "Glob pattern(s) for files that trigger this rule",
29
- },
30
- "safety": {
31
- **STRING_OR_ARRAY,
32
- "description": "Glob pattern(s) that suppress the rule if changed",
33
- },
34
- # Detection mode: set (bidirectional correspondence)
35
- "set": {
36
- "type": "array",
37
- "items": {"type": "string", "minLength": 1},
38
- "minItems": 2,
39
- "description": "Patterns defining bidirectional file correspondence",
40
- },
41
- # Detection mode: pair (directional correspondence)
42
- "pair": {
43
- "type": "object",
44
- "required": ["trigger", "expects"],
45
- "properties": {
46
- "trigger": {
47
- "type": "string",
48
- "minLength": 1,
49
- "description": "Pattern that triggers the rule",
50
- },
51
- "expects": {
52
- **STRING_OR_ARRAY,
53
- "description": "Pattern(s) for expected corresponding files",
54
- },
55
- },
56
- "additionalProperties": False,
57
- "description": "Directional file correspondence (trigger -> expects)",
58
- },
59
- # Detection mode: created (fire when files are created matching patterns)
60
- "created": {
61
- **STRING_OR_ARRAY,
62
- "description": "Glob pattern(s) for newly created files that trigger this rule",
63
- },
64
- # Action type: command (default is prompt using markdown body)
65
- "action": {
66
- "type": "object",
67
- "required": ["command"],
68
- "properties": {
69
- "command": {
70
- "type": "string",
71
- "minLength": 1,
72
- "description": "Command to run (supports {file}, {files}, {repo_root})",
73
- },
74
- "run_for": {
75
- "type": "string",
76
- "enum": ["each_match", "all_matches"],
77
- "default": "each_match",
78
- "description": "Run command for each file or all files at once",
79
- },
80
- },
81
- "additionalProperties": False,
82
- "description": "Command action to run instead of prompting",
83
- },
84
- # Common options
85
- "compare_to": {
86
- "type": "string",
87
- "enum": ["base", "default_tip", "prompt"],
88
- "description": "Baseline for detecting file changes",
89
- },
90
- },
91
- "additionalProperties": False,
92
- # Detection mode must be exactly one of: trigger, set, pair, or created
93
- "oneOf": [
94
- {
95
- "required": ["trigger"],
96
- "not": {
97
- "anyOf": [
98
- {"required": ["set"]},
99
- {"required": ["pair"]},
100
- {"required": ["created"]},
101
- ]
102
- },
103
- },
104
- {
105
- "required": ["set"],
106
- "not": {
107
- "anyOf": [
108
- {"required": ["trigger"]},
109
- {"required": ["pair"]},
110
- {"required": ["created"]},
111
- ]
112
- },
113
- },
114
- {
115
- "required": ["pair"],
116
- "not": {
117
- "anyOf": [
118
- {"required": ["trigger"]},
119
- {"required": ["set"]},
120
- {"required": ["created"]},
121
- ]
122
- },
123
- },
124
- {
125
- "required": ["created"],
126
- "not": {
127
- "anyOf": [
128
- {"required": ["trigger"]},
129
- {"required": ["set"]},
130
- {"required": ["pair"]},
131
- ]
132
- },
133
- },
134
- ],
135
- }
@@ -1,208 +0,0 @@
1
- # Review Job Specification
2
-
3
- ## Objective
4
-
5
- Review the `job.yml` created in the define step against the doc spec quality criteria using a sub-agent for unbiased evaluation, then iterate on fixes until all criteria pass.
6
-
7
- ## Why This Step Exists
8
-
9
- The define step focuses on understanding user requirements and creating a job specification. This review step ensures the specification meets quality standards before implementation. Using a sub-agent provides an unbiased "fresh eyes" review that catches issues the main agent might miss after being deeply involved in the definition process.
10
-
11
- ## Task
12
-
13
- Use a sub-agent to review the job.yml against all 9 doc spec quality criteria, then fix any failed criteria. Repeat until all criteria pass.
14
-
15
- ### Step 1: Read the Job Specification
16
-
17
- Read the `job.yml` file created in the define step:
18
-
19
- ```
20
- .deepwork/jobs/[job_name]/job.yml
21
- ```
22
-
23
- Also read the doc spec for reference:
24
-
25
- ```
26
- .deepwork/doc_specs/job_spec.md
27
- ```
28
-
29
- ### Step 2: Spawn Review Sub-Agent
30
-
31
- Use the Task tool to spawn a sub-agent that will provide an unbiased review:
32
-
33
- ```
34
- Task tool parameters:
35
- - subagent_type: "general-purpose"
36
- - model: "haiku"
37
- - description: "Review job.yml against doc spec"
38
- - prompt: [see below]
39
- ```
40
-
41
- **Sub-agent prompt template:**
42
-
43
- ```
44
- Review this job.yml against the following 9 quality criteria from the doc spec.
45
-
46
- For each criterion, respond with:
47
- - PASS or FAIL
48
- - If FAIL: specific issue and suggested fix
49
-
50
- ## job.yml Content
51
-
52
- [paste the full job.yml content here]
53
-
54
- ## Quality Criteria
55
-
56
- 1. **Valid Identifier**: Job name must be lowercase with underscores, no spaces or special characters (e.g., `competitive_research`, `monthly_report`)
57
-
58
- 2. **Semantic Version**: Version must follow semantic versioning format X.Y.Z (e.g., `1.0.0`, `2.1.3`)
59
-
60
- 3. **Concise Summary**: Summary must be under 200 characters and clearly describe what the job accomplishes
61
-
62
- 4. **Rich Description**: Description must be multi-line and explain: the problem solved, the process, expected outcomes, and target users
63
-
64
- 5. **Changelog Present**: Must include a changelog array with at least the initial version entry
65
-
66
- 6. **Complete Steps**: Each step must have: id (lowercase_underscores), name, description, instructions_file, outputs (at least one), and dependencies array
67
-
68
- 7. **Valid Dependencies**: Dependencies must reference existing step IDs with no circular references
69
-
70
- 8. **Input Consistency**: File inputs with `from_step` must reference a step that is in the dependencies array
71
-
72
- 9. **Output Paths**: Outputs must be valid filenames or paths (e.g., `report.md` or `reports/analysis.md`)
73
-
74
- ## Response Format
75
-
76
- Respond with a structured evaluation:
77
-
78
- ### Overall: [X/9 PASS]
79
-
80
- ### Criterion Results
81
-
82
- 1. Valid Identifier: [PASS/FAIL]
83
- [If FAIL: Issue and fix]
84
-
85
- 2. Semantic Version: [PASS/FAIL]
86
- [If FAIL: Issue and fix]
87
-
88
- [... continue for all 9 criteria ...]
89
-
90
- ### Summary of Required Fixes
91
-
92
- [List any fixes needed, or "No fixes required - all criteria pass"]
93
- ```
94
-
95
- ### Step 3: Review Sub-Agent Findings
96
-
97
- Parse the sub-agent's response:
98
-
99
- 1. **Count passing criteria** - How many of the 9 criteria passed?
100
- 2. **Identify failures** - List specific criteria that failed
101
- 3. **Note suggested fixes** - What changes does the sub-agent recommend?
102
-
103
- ### Step 4: Fix Failed Criteria
104
-
105
- For each failed criterion, edit the job.yml to address the issue:
106
-
107
- **Common fixes by criterion:**
108
-
109
- | Criterion | Common Issue | Fix |
110
- |-----------|-------------|-----|
111
- | Valid Identifier | Spaces or uppercase | Convert to lowercase_underscores |
112
- | Semantic Version | Missing or invalid format | Set to `"1.0.0"` or fix format |
113
- | Concise Summary | Too long or vague | Shorten to <200 chars, be specific |
114
- | Rich Description | Single line or missing context | Add multi-line explanation with problem/process/outcome/users |
115
- | Changelog Present | Missing changelog | Add `changelog:` with initial version entry |
116
- | Complete Steps | Missing required fields | Add id, name, description, instructions_file, outputs, dependencies |
117
- | Valid Dependencies | Non-existent step or circular | Fix step ID reference or reorder dependencies |
118
- | Input Consistency | from_step not in dependencies | Add the referenced step to dependencies array |
119
- | Output Paths | Invalid characters or format | Use valid filename/path format |
120
-
121
- ### Step 5: Re-Run Review (If Needed)
122
-
123
- If any criteria failed:
124
-
125
- 1. **Spawn a new sub-agent** with the updated job.yml content
126
- 2. **Review the new findings**
127
- 3. **Fix any remaining issues**
128
- 4. **Repeat until all 9 criteria pass**
129
-
130
- ### Step 6: Confirm Completion
131
-
132
- When all 9 criteria pass:
133
-
134
- 1. **Announce success**: "All 9 doc spec quality criteria pass."
135
- 2. **List what was validated**:
136
- - Valid Identifier
137
- - Semantic Version
138
- - Concise Summary
139
- - Rich Description
140
- - Changelog Present
141
- - Complete Steps
142
- - Valid Dependencies
143
- - Input Consistency
144
- - Output Paths
145
- 3. **Include the promise**: `<promise>Quality Criteria Met</promise>`
146
- 4. **Guide to next step**: "Run `/deepwork_jobs.implement` to generate the step instruction files."
147
-
148
- ## Example Review Cycle
149
-
150
- ```
151
- Claude: Let me review the job.yml against the doc spec quality criteria.
152
-
153
- [Spawns sub-agent with haiku model]
154
-
155
- Sub-agent response:
156
- ### Overall: 7/9 PASS
157
-
158
- ### Criterion Results
159
- 1. Valid Identifier: PASS
160
- 2. Semantic Version: PASS
161
- 3. Concise Summary: FAIL
162
- Issue: Summary is 245 characters, exceeds 200 char limit
163
- Fix: Shorten to "Competitive analysis workflow for product positioning"
164
- 4. Rich Description: PASS
165
- 5. Changelog Present: FAIL
166
- Issue: No changelog array present
167
- Fix: Add changelog with initial version entry
168
- 6. Complete Steps: PASS
169
- 7. Valid Dependencies: PASS
170
- 8. Input Consistency: PASS
171
- 9. Output Paths: PASS
172
-
173
- ### Summary of Required Fixes
174
- 1. Shorten summary to under 200 characters
175
- 2. Add changelog array with initial version
176
-
177
- Claude: I found 2 issues. Let me fix them.
178
-
179
- [Edits job.yml to shorten summary and add changelog]
180
-
181
- Claude: Let me verify the fixes with another review.
182
-
183
- [Spawns new sub-agent]
184
-
185
- Sub-agent response:
186
- ### Overall: 9/9 PASS
187
-
188
- ### Summary of Required Fixes
189
- No fixes required - all criteria pass
190
-
191
- Claude: All 9 doc spec quality criteria pass.
192
-
193
- <promise>Quality Criteria Met</promise>
194
-
195
- **Next step:** Run `/deepwork_jobs.implement` to generate the step instruction files.
196
- ```
197
-
198
- ## Quality Criteria
199
-
200
- - **Sub-Agent Used**: A sub-agent was spawned to provide unbiased review (not just self-review)
201
- - **All doc spec Criteria Evaluated**: The sub-agent assessed all 9 quality criteria from the doc spec
202
- - **Findings Addressed**: All failed criteria were fixed by the main agent
203
- - **Validation Loop Complete**: The review-fix cycle continued until all criteria passed
204
- - **Promise Included**: The response includes `<promise>Quality Criteria Met</promise>` when complete
205
-
206
- ## Output
207
-
208
- The validated `job.yml` file at `.deepwork/jobs/[job_name]/job.yml` that passes all 9 doc spec quality criteria.
@@ -1,86 +0,0 @@
1
- ---
2
- name: "Monthly AWS Spending Report"
3
- description: "A Markdown summary of AWS spend across accounts for finance and engineering leadership"
4
- path_patterns:
5
- - "finance/aws-reports/*.md"
6
- - "reports/aws/*.md"
7
- target_audience: "Finance team and Engineering leadership"
8
- frequency: "Monthly, following AWS invoice arrival"
9
- quality_criteria:
10
- - name: Executive Summary
11
- description: Must include a 2-3 sentence summary of total spend, month-over-month change percentage, and top cost driver
12
- - name: Visualization
13
- description: Must include at least one Mermaid.js chart showing spend breakdown by service (pie chart) or trend over time (line chart)
14
- - name: Variance Analysis
15
- description: Must compare current month against previous month with percentage changes for top 5 services
16
- - name: Cost Attribution
17
- description: Must break down costs by team/project using AWS tags where available
18
- - name: Action Items
19
- description: Must include 2-3 specific, actionable recommendations for cost optimization
20
- ---
21
-
22
- # Monthly AWS Spending Report: [Month, Year]
23
-
24
- ## Executive Summary
25
-
26
- [2-3 sentences summarizing:
27
- - Total spend this month
28
- - Percentage change from last month
29
- - The primary cost driver]
30
-
31
- ## Spend Overview
32
-
33
- ### Total Spend by Service
34
-
35
- ```mermaid
36
- pie title AWS Spend by Service
37
- "EC2" : 45
38
- "RDS" : 25
39
- "S3" : 15
40
- "Lambda" : 10
41
- "Other" : 5
42
- ```
43
-
44
- ### Month-over-Month Trend
45
-
46
- ```mermaid
47
- xychart-beta
48
- title "Monthly AWS Spend Trend"
49
- x-axis [Jan, Feb, Mar, Apr, May, Jun]
50
- y-axis "Spend ($K)" 0 --> 100
51
- line [45, 48, 52, 49, 55, 58]
52
- ```
53
-
54
- ## Variance Analysis
55
-
56
- | Service | Last Month | This Month | Change | % Change |
57
- |---------|-----------|------------|--------|----------|
58
- | EC2 | $X,XXX | $X,XXX | +$XXX | +X.X% |
59
- | RDS | $X,XXX | $X,XXX | -$XXX | -X.X% |
60
- | S3 | $X,XXX | $X,XXX | +$XXX | +X.X% |
61
- | Lambda | $X,XXX | $X,XXX | +$XXX | +X.X% |
62
- | Other | $X,XXX | $X,XXX | +$XXX | +X.X% |
63
-
64
- ## Cost Attribution by Team
65
-
66
- | Team/Project | Spend | % of Total |
67
- |--------------|-------|------------|
68
- | Platform | $X,XXX | XX% |
69
- | Data | $X,XXX | XX% |
70
- | Product | $X,XXX | XX% |
71
- | Shared | $X,XXX | XX% |
72
-
73
- ## Recommendations
74
-
75
- 1. **[Action Item 1]**: [Specific recommendation with expected savings]
76
- 2. **[Action Item 2]**: [Specific recommendation with expected savings]
77
- 3. **[Action Item 3]**: [Specific recommendation with expected savings]
78
-
79
- ## Appendix
80
-
81
- ### Data Sources
82
- - AWS Cost Explorer
83
- - AWS Tags: team, project, environment
84
-
85
- ### Report Methodology
86
- [Brief explanation of how costs are calculated and attributed]
@@ -1,38 +0,0 @@
1
- #!/bin/bash
2
- # capture_prompt_work_tree.sh - Captures the git work tree state at prompt submission
3
- #
4
- # This script creates a snapshot of ALL tracked files at the time the prompt
5
- # is submitted. This baseline is used for rules with compare_to: prompt and
6
- # created: mode to detect truly NEW files (not modifications to existing ones).
7
- #
8
- # The baseline contains ALL tracked files (not just changed files) so that
9
- # the rules_check hook can determine which files are genuinely new vs which
10
- # files existed before and were just modified.
11
- #
12
- # It also captures the HEAD commit ref so that committed changes can be detected
13
- # by comparing HEAD at Stop time to the captured ref.
14
-
15
- set -e
16
-
17
- # Ensure .deepwork directory exists
18
- mkdir -p .deepwork
19
-
20
- # Save the current HEAD commit ref for detecting committed changes
21
- # This is used by get_changed_files_prompt() to detect files changed since prompt,
22
- # even if those changes were committed during the agent response.
23
- git rev-parse HEAD > .deepwork/.last_head_ref 2>/dev/null || echo "" > .deepwork/.last_head_ref
24
-
25
- # Save ALL tracked files (not just changed files)
26
- # This is critical for created: mode rules to distinguish between:
27
- # - Newly created files (not in baseline) -> should trigger created: rules
28
- # - Modified existing files (in baseline) -> should NOT trigger created: rules
29
- git ls-files > .deepwork/.last_work_tree 2>/dev/null || true
30
-
31
- # Also include untracked files that exist at prompt time
32
- # These are files the user may have created before submitting the prompt
33
- git ls-files --others --exclude-standard >> .deepwork/.last_work_tree 2>/dev/null || true
34
-
35
- # Sort and deduplicate
36
- if [ -f .deepwork/.last_work_tree ]; then
37
- sort -u .deepwork/.last_work_tree -o .deepwork/.last_work_tree
38
- fi
@@ -1,8 +0,0 @@
1
- # DeepWork Rules Hooks Configuration
2
- # Maps lifecycle events to hook scripts or Python modules
3
-
4
- UserPromptSubmit:
5
- - user_prompt_submit.sh
6
-
7
- Stop:
8
- - module: deepwork.hooks.rules_check
@@ -1,16 +0,0 @@
1
- #!/bin/bash
2
- # user_prompt_submit.sh - Runs on every user prompt submission
3
- #
4
- # This script captures the work tree state at each prompt submission.
5
- # This baseline is used for policies with compare_to: prompt to detect
6
- # what changed during an agent response.
7
-
8
- set -e
9
-
10
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
-
12
- # Capture work tree state at each prompt for compare_to: prompt policies
13
- "${SCRIPT_DIR}/capture_prompt_work_tree.sh"
14
-
15
- # Exit successfully - don't block the prompt
16
- exit 0
@@ -1,49 +0,0 @@
1
- name: deepwork_rules
2
- version: "0.4.0"
3
- summary: "Creates file-change rules that enforce guidelines during AI sessions. Use when automating documentation sync or code review triggers."
4
- description: |
5
- Manages rules that automatically trigger when certain files change during an AI agent session.
6
- Rules help ensure that code changes follow team guidelines, documentation is updated,
7
- and architectural decisions are respected.
8
-
9
- IMPORTANT: Rules are evaluated at the "Stop" hook, which fires when an agent finishes its turn.
10
- This includes when sub-agents complete their work. Rules are NOT evaluated immediately after
11
- each file edit - they batch up and run once at the end of the agent's response cycle.
12
- - Command action rules: Execute their command (e.g., `uv sync`) when the agent stops
13
- - Prompt action rules: Display instructions to the agent, blocking until addressed
14
-
15
- Rules are stored as individual markdown files with YAML frontmatter in the `.deepwork/rules/`
16
- directory. Each rule file specifies:
17
- - Detection mode: trigger/safety, set (bidirectional), or pair (directional)
18
- - Patterns: Glob patterns for matching files, with optional variable capture
19
- - Action type: prompt (default) to show instructions, or command to run a shell command
20
- - Instructions: Markdown content describing what the agent should do
21
-
22
- Example use cases:
23
- - Update installation docs when configuration files change
24
- - Require security review when authentication code is modified
25
- - Ensure API documentation stays in sync with API code
26
- - Enforce source/test file pairing
27
- - Auto-run `uv sync` when pyproject.toml changes (command action)
28
-
29
- changelog:
30
- - version: "0.1.0"
31
- changes: "Initial version"
32
- - version: "0.2.0"
33
- changes: "Standardized on 'ask structured questions' phrasing for user input"
34
- - version: "0.3.0"
35
- changes: "Migrated to v2 format - individual markdown files in .deepwork/rules/"
36
- - version: "0.4.0"
37
- changes: "Improved skill descriptions with third-person voice and 'Use when...' triggers for better discoverability"
38
-
39
- steps:
40
- - id: define
41
- name: "Define Rule"
42
- description: "Creates a rule file that triggers when specified files change. Use when setting up documentation sync, code review requirements, or automated commands."
43
- instructions_file: steps/define.md
44
- inputs:
45
- - name: rule_purpose
46
- description: "What guideline or constraint should this rule enforce?"
47
- outputs:
48
- - .deepwork/rules/{rule-name}.md
49
- dependencies: []
@@ -1,13 +0,0 @@
1
- # This directory contains example rule templates.
2
- # Copy and customize these files to create your own rules.
3
- #
4
- # Rule files use YAML frontmatter in markdown format:
5
- #
6
- # ---
7
- # name: Rule Name
8
- # trigger: "pattern/**/*"
9
- # safety: "optional/pattern"
10
- # ---
11
- # Instructions in markdown here.
12
- #
13
- # See doc/rules_syntax.md for full documentation.
@@ -1,10 +0,0 @@
1
- ---
2
- name: API Documentation Sync
3
- trigger: src/api/**/*
4
- safety: docs/api/**/*.md
5
- ---
6
- API code has changed. Please verify that API documentation is up to date:
7
-
8
- - New or changed endpoints
9
- - Modified request/response schemas
10
- - Updated authentication requirements
@@ -1,10 +0,0 @@
1
- ---
2
- name: README Documentation
3
- trigger: src/**/*
4
- safety: README.md
5
- ---
6
- Source code has been modified. Please review README.md for accuracy:
7
-
8
- 1. Verify the project overview reflects current functionality
9
- 2. Check that usage examples are still correct
10
- 3. Ensure installation/setup instructions remain valid
@@ -1,11 +0,0 @@
1
- ---
2
- name: Security Review for Auth Changes
3
- trigger:
4
- - src/auth/**/*
5
- - src/security/**/*
6
- ---
7
- Authentication or security code has been changed. Please:
8
-
9
- 1. Review for hardcoded credentials or secrets
10
- 2. Check input validation on user inputs
11
- 3. Verify access control logic is correct
@@ -1,46 +0,0 @@
1
- ---
2
- name: SKILL.md Validation
3
- trigger: "**/SKILL.md"
4
- compare_to: base
5
- ---
6
- A SKILL.md file has been created or modified. Please validate that it follows the required format:
7
-
8
- ## Required Structure
9
-
10
- The file MUST have valid YAML frontmatter at the start, enclosed between `---` markers:
11
-
12
- ```markdown
13
- ---
14
- name: my-skill-name
15
- description: A description of what this skill does
16
- ---
17
-
18
- # Rest of the skill documentation...
19
- ```
20
-
21
- ## Validation Checklist
22
-
23
- 1. **YAML Frontmatter**: Verify the file starts with `---` followed by valid YAML and ends with `---`
24
-
25
- 2. **`name` field** (required):
26
- - Must be present in the frontmatter
27
- - Must contain only lowercase letters, numbers, and hyphens (`a-z`, `0-9`, `-`)
28
- - Must be 64 characters or fewer
29
- - Example valid names: `my-skill`, `code-review-2`, `lint`
30
- - Example invalid names: `My Skill` (uppercase/spaces), `skill_name` (underscores), `SKILL` (uppercase)
31
-
32
- 3. **`description` field** (required):
33
- - Must be present in the frontmatter
34
- - Must be 1024 characters or fewer
35
- - Should clearly describe what the skill does
36
-
37
- ## What to Check
38
-
39
- For the modified file: {trigger_files}
40
-
41
- 1. Parse the YAML frontmatter and verify it is valid YAML
42
- 2. Check that `name` exists and matches the pattern `^[a-z0-9-]+$` with max length 64
43
- 3. Check that `description` exists and is at most 1024 characters
44
- 4. Report any validation errors to the user
45
-
46
- If the file does not pass validation, help the user fix the issues.
@@ -1,13 +0,0 @@
1
- ---
2
- name: Source/Test Pairing
3
- set:
4
- - src/{path}.py
5
- - tests/{path}_test.py
6
- ---
7
- Source and test files should change together.
8
-
9
- When modifying source code, ensure corresponding tests are updated.
10
- When adding tests, ensure they test actual source code.
11
-
12
- Modified source: {trigger_files}
13
- Expected tests: {expected_files}