deepwork 0.3.1__py3-none-any.whl → 0.4.0__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 (39) hide show
  1. deepwork/cli/hook.py +70 -0
  2. deepwork/cli/install.py +58 -14
  3. deepwork/cli/main.py +4 -0
  4. deepwork/cli/rules.py +32 -0
  5. deepwork/cli/sync.py +27 -1
  6. deepwork/core/adapters.py +209 -0
  7. deepwork/core/command_executor.py +26 -9
  8. deepwork/core/doc_spec_parser.py +205 -0
  9. deepwork/core/generator.py +79 -4
  10. deepwork/core/hooks_syncer.py +15 -2
  11. deepwork/core/parser.py +64 -2
  12. deepwork/hooks/__init__.py +9 -3
  13. deepwork/hooks/check_version.sh +230 -0
  14. deepwork/hooks/claude_hook.sh +13 -17
  15. deepwork/hooks/gemini_hook.sh +13 -17
  16. deepwork/hooks/rules_check.py +71 -12
  17. deepwork/hooks/wrapper.py +66 -16
  18. deepwork/schemas/doc_spec_schema.py +64 -0
  19. deepwork/schemas/job_schema.py +25 -3
  20. deepwork/standard_jobs/deepwork_jobs/doc_specs/job_spec.md +190 -0
  21. deepwork/standard_jobs/deepwork_jobs/job.yml +41 -8
  22. deepwork/standard_jobs/deepwork_jobs/steps/define.md +68 -2
  23. deepwork/standard_jobs/deepwork_jobs/steps/implement.md +3 -3
  24. deepwork/standard_jobs/deepwork_jobs/steps/learn.md +74 -5
  25. deepwork/standard_jobs/deepwork_jobs/steps/review_job_spec.md +208 -0
  26. deepwork/standard_jobs/deepwork_jobs/templates/doc_spec.md.example +86 -0
  27. deepwork/standard_jobs/deepwork_jobs/templates/doc_spec.md.template +26 -0
  28. deepwork/standard_jobs/deepwork_rules/hooks/capture_prompt_work_tree.sh +8 -0
  29. deepwork/standard_jobs/deepwork_rules/job.yml +5 -3
  30. deepwork/templates/claude/skill-job-meta.md.jinja +7 -0
  31. deepwork/templates/claude/skill-job-step.md.jinja +60 -7
  32. deepwork/templates/gemini/skill-job-step.toml.jinja +18 -3
  33. deepwork/utils/fs.py +36 -0
  34. deepwork/utils/yaml_utils.py +24 -0
  35. {deepwork-0.3.1.dist-info → deepwork-0.4.0.dist-info}/METADATA +39 -2
  36. {deepwork-0.3.1.dist-info → deepwork-0.4.0.dist-info}/RECORD +39 -30
  37. {deepwork-0.3.1.dist-info → deepwork-0.4.0.dist-info}/WHEEL +0 -0
  38. {deepwork-0.3.1.dist-info → deepwork-0.4.0.dist-info}/entry_points.txt +0 -0
  39. {deepwork-0.3.1.dist-info → deepwork-0.4.0.dist-info}/licenses/LICENSE.md +0 -0
@@ -0,0 +1,190 @@
1
+ ---
2
+ name: "DeepWork Job Specification"
3
+ description: "YAML specification file that defines a multi-step workflow job for AI agents"
4
+ path_patterns:
5
+ - ".deepwork/jobs/*/job.yml"
6
+ target_audience: "AI agents executing jobs and developers defining workflows"
7
+ frequency: "Created once per job, updated as workflow evolves"
8
+ quality_criteria:
9
+ - name: Valid Identifier
10
+ description: "Job name must be lowercase with underscores, no spaces or special characters (e.g., `competitive_research`, `monthly_report`)"
11
+ - name: Semantic Version
12
+ description: "Version must follow semantic versioning format X.Y.Z (e.g., `1.0.0`, `2.1.3`)"
13
+ - name: Concise Summary
14
+ description: "Summary must be under 200 characters and clearly describe what the job accomplishes"
15
+ - name: Rich Description
16
+ description: "Description must be multi-line and explain: the problem solved, the process, expected outcomes, and target users"
17
+ - name: Changelog Present
18
+ description: "Must include a changelog array with at least the initial version entry. Changelog should only include one entry per branch at most"
19
+ - name: Complete Steps
20
+ description: "Each step must have: id (lowercase_underscores), name, description, instructions_file, outputs (at least one), and dependencies array"
21
+ - name: Valid Dependencies
22
+ description: "Dependencies must reference existing step IDs with no circular references"
23
+ - name: Input Consistency
24
+ description: "File inputs with `from_step` must reference a step that is in the dependencies array"
25
+ - name: Output Paths
26
+ description: "Outputs must be valid filenames or paths within the main repo (not in dot-directories). Use specific, descriptive paths that lend themselves to glob patterns, e.g., `competitive_research/competitors_list.md` or `competitive_research/[competitor_name]/research.md`. Avoid generic names like `output.md`."
27
+ - name: Concise Instructions
28
+ description: "The content of the file, particularly the description, must not have excessively redundant information. It should be concise and to the point given that extra tokens will confuse the AI."
29
+ ---
30
+
31
+ # DeepWork Job Specification: [job_name]
32
+
33
+ A `job.yml` file defines a complete multi-step workflow that AI agents can execute. Each job breaks down a complex task into reviewable steps with clear inputs and outputs.
34
+
35
+ ## Required Fields
36
+
37
+ ### Top-Level Metadata
38
+
39
+ ```yaml
40
+ name: job_name # lowercase, underscores only
41
+ version: "1.0.0" # semantic versioning
42
+ summary: "Brief description" # max 200 characters
43
+ description: | # detailed multi-line explanation
44
+ [Explain what this workflow does, why it exists,
45
+ what outputs it produces, and who should use it]
46
+ ```
47
+
48
+ ### Changelog
49
+
50
+ ```yaml
51
+ changelog:
52
+ - version: "1.0.0"
53
+ changes: "Initial job creation"
54
+ - version: "1.1.0"
55
+ changes: "Added quality validation hooks"
56
+ ```
57
+
58
+ ### Steps Array
59
+
60
+ ```yaml
61
+ steps:
62
+ - id: step_id # unique, lowercase_underscores
63
+ name: "Human Readable Name"
64
+ description: "What this step accomplishes"
65
+ instructions_file: steps/step_id.md
66
+ inputs:
67
+ # User-provided inputs:
68
+ - name: param_name
69
+ description: "What the user provides"
70
+ # File inputs from previous steps:
71
+ - file: output.md
72
+ from_step: previous_step_id
73
+ outputs:
74
+ - competitive_research/competitors_list.md # descriptive path
75
+ - competitive_research/[competitor_name]/research.md # parameterized path
76
+ # With doc spec reference:
77
+ - file: competitive_research/final_report.md
78
+ doc_spec: .deepwork/doc_specs/report_type.md
79
+ dependencies:
80
+ - previous_step_id # steps that must complete first
81
+ ```
82
+
83
+ ## Optional Fields
84
+
85
+ ### Exposed Steps
86
+
87
+ ```yaml
88
+ steps:
89
+ - id: learn
90
+ exposed: true # Makes step available without running dependencies
91
+ ```
92
+
93
+ ### Quality Hooks
94
+
95
+ ```yaml
96
+ steps:
97
+ - id: step_id
98
+ hooks:
99
+ after_agent:
100
+ # Inline prompt for quality validation:
101
+ - prompt: |
102
+ Verify the output meets criteria:
103
+ 1. [Criterion 1]
104
+ 2. [Criterion 2]
105
+ If ALL criteria are met, include `<promise>...</promise>`.
106
+ # External prompt file:
107
+ - prompt_file: hooks/quality_check.md
108
+ # Script for programmatic validation:
109
+ - script: hooks/run_tests.sh
110
+ ```
111
+
112
+ ### Stop Hooks (Legacy)
113
+
114
+ ```yaml
115
+ steps:
116
+ - id: step_id
117
+ stop_hooks:
118
+ - prompt: "Validation prompt..."
119
+ - prompt_file: hooks/check.md
120
+ - script: hooks/validate.sh
121
+ ```
122
+
123
+ ## Validation Rules
124
+
125
+ 1. **No circular dependencies**: Step A cannot depend on Step B if Step B depends on Step A
126
+ 2. **File inputs require dependencies**: If a step uses `from_step: X`, then X must be in its dependencies
127
+ 3. **Unique step IDs**: No two steps can have the same id
128
+ 4. **Valid file paths**: Output paths must not contain invalid characters and should be in the main repo (not dot-directories)
129
+ 5. **Instructions files exist**: Each `instructions_file` path should have a corresponding file created
130
+
131
+ ## Example: Complete Job Specification
132
+
133
+ ```yaml
134
+ name: competitive_research
135
+ version: "1.0.0"
136
+ summary: "Systematic competitive analysis workflow"
137
+ description: |
138
+ A comprehensive workflow for analyzing competitors in your market segment.
139
+ Helps product teams understand the competitive landscape through systematic
140
+ identification, research, comparison, and positioning recommendations.
141
+
142
+ Produces:
143
+ - Vetted competitor list
144
+ - Research notes per competitor
145
+ - Comparison matrix
146
+ - Strategic positioning report
147
+
148
+ changelog:
149
+ - version: "1.0.0"
150
+ changes: "Initial job creation"
151
+
152
+ steps:
153
+ - id: identify_competitors
154
+ name: "Identify Competitors"
155
+ description: "Identify 5-7 key competitors in the target market"
156
+ instructions_file: steps/identify_competitors.md
157
+ inputs:
158
+ - name: market_segment
159
+ description: "The market segment to analyze"
160
+ - name: product_category
161
+ description: "The product category"
162
+ outputs:
163
+ - competitive_research/competitors_list.md
164
+ dependencies: []
165
+
166
+ - id: research_competitors
167
+ name: "Research Competitors"
168
+ description: "Deep dive research on each identified competitor"
169
+ instructions_file: steps/research_competitors.md
170
+ inputs:
171
+ - file: competitive_research/competitors_list.md
172
+ from_step: identify_competitors
173
+ outputs:
174
+ - competitive_research/[competitor_name]/research.md
175
+ dependencies:
176
+ - identify_competitors
177
+
178
+ - id: positioning_report
179
+ name: "Positioning Report"
180
+ description: "Strategic positioning recommendations"
181
+ instructions_file: steps/positioning_report.md
182
+ inputs:
183
+ - file: competitive_research/[competitor_name]/research.md
184
+ from_step: research_competitors
185
+ outputs:
186
+ - file: competitive_research/positioning_report.md
187
+ doc_spec: .deepwork/doc_specs/positioning_report.md
188
+ dependencies:
189
+ - research_competitors
190
+ ```
@@ -1,6 +1,6 @@
1
1
  name: deepwork_jobs
2
- version: "0.5.0"
3
- summary: "DeepWork job management commands"
2
+ version: "0.9.0"
3
+ summary: "Creates and manages multi-step AI workflows. Use when defining, implementing, or improving DeepWork jobs."
4
4
  description: |
5
5
  Core commands for managing DeepWork jobs. These commands help you define new multi-step
6
6
  workflows and learn from running them.
@@ -24,21 +24,34 @@ changelog:
24
24
  changes: "Removed implementation_summary and learning_summary outputs; simplified step outputs"
25
25
  - version: "0.5.0"
26
26
  changes: "Standardized on 'ask structured questions' phrasing for user input; Updated quality criteria hooks to verify phrase usage; Added guidance in implement.md to use phrase in generated instructions"
27
+ - version: "0.6.0"
28
+ changes: "Added doc spec support; define.md now detects document-oriented workflows and guides doc spec creation; learn.md now identifies and applies doc spec-related improvements"
29
+ - version: "0.7.0"
30
+ changes: "Added job.yml doc spec; define step now outputs job.yml with doc_spec reference for quality validation"
31
+ - version: "0.8.0"
32
+ changes: "Added review_job_spec step between define and implement for doc spec-based quality validation using sub-agent review"
33
+ - version: "0.9.0"
34
+ changes: "Improved skill descriptions with third-person voice and 'Use when...' triggers for better discoverability"
27
35
 
28
36
  steps:
29
37
  - id: define
30
38
  name: "Define Job Specification"
31
- description: "Create the job.yml specification file by understanding workflow requirements"
39
+ description: "Creates a job.yml specification by gathering workflow requirements through structured questions. Use when starting a new multi-step workflow."
32
40
  instructions_file: steps/define.md
33
41
  inputs:
34
42
  - name: job_purpose
35
43
  description: "What complex task or workflow are you trying to accomplish?"
36
44
  outputs:
37
- - job.yml
45
+ - file: job.yml
46
+ doc_spec: .deepwork/doc_specs/job_spec.md
38
47
  dependencies: []
39
48
  quality_criteria:
40
49
  - "**User Understanding**: Did the agent fully understand the user's workflow by asking structured questions?"
41
50
  - "**Structured Questions Used**: Did the agent ask structured questions (using the AskUserQuestion tool) to gather user input?"
51
+ - "**Document Detection**: For document-oriented workflows, did the agent detect patterns and offer doc spec creation?"
52
+ - "**doc spec Created (if applicable)**: If a doc spec was needed, was it created in `.deepwork/doc_specs/[doc_spec_name].md` with proper quality criteria?"
53
+ - "**doc spec References**: Are document outputs properly linked to their doc specs using `{file, doc_spec}` format?"
54
+ - "**Valid Against doc spec**: Does the job.yml conform to the job.yml doc spec quality criteria (valid identifier, semantic version, concise summary, rich description, complete steps, valid dependencies)?"
42
55
  - "**Clear Inputs/Outputs**: Does every step have clearly defined inputs and outputs?"
43
56
  - "**Logical Dependencies**: Do step dependencies make sense and avoid circular references?"
44
57
  - "**Concise Summary**: Is the summary under 200 characters and descriptive?"
@@ -46,17 +59,35 @@ steps:
46
59
  - "**Valid Schema**: Does the job.yml follow the required schema (name, version, summary, steps)?"
47
60
  - "**File Created**: Has the job.yml file been created in `.deepwork/jobs/[job_name]/job.yml`?"
48
61
 
62
+ - id: review_job_spec
63
+ name: "Review Job Specification"
64
+ description: "Reviews job.yml against quality criteria using a sub-agent for unbiased validation. Use after defining a job specification."
65
+ instructions_file: steps/review_job_spec.md
66
+ inputs:
67
+ - file: job.yml
68
+ from_step: define
69
+ outputs:
70
+ - file: job.yml
71
+ doc_spec: .deepwork/doc_specs/job_spec.md
72
+ dependencies:
73
+ - define
74
+ quality_criteria:
75
+ - "**Sub-Agent Used**: Was a sub-agent spawned to provide unbiased review?"
76
+ - "**All doc spec Criteria Evaluated**: Did the sub-agent assess all 9 quality criteria?"
77
+ - "**Findings Addressed**: Were all failed criteria addressed by the main agent?"
78
+ - "**Validation Loop Complete**: Did the review-fix cycle continue until all criteria passed?"
79
+
49
80
  - id: implement
50
81
  name: "Implement Job Steps"
51
- description: "Generate instruction files for each step based on the job.yml specification"
82
+ description: "Generates step instruction files and syncs slash commands from the job.yml specification. Use after job spec review passes."
52
83
  instructions_file: steps/implement.md
53
84
  inputs:
54
85
  - file: job.yml
55
- from_step: define
86
+ from_step: review_job_spec
56
87
  outputs:
57
88
  - steps/
58
89
  dependencies:
59
- - define
90
+ - review_job_spec
60
91
  quality_criteria:
61
92
  - "**Directory Structure**: Is `.deepwork/jobs/[job_name]/` created correctly?"
62
93
  - "**Complete Instructions**: Are ALL step instruction files complete (not stubs or placeholders)?"
@@ -70,7 +101,7 @@ steps:
70
101
 
71
102
  - id: learn
72
103
  name: "Learn from Job Execution"
73
- description: "Reflect on conversation to improve job instructions and capture learnings"
104
+ description: "Analyzes conversation history to improve job instructions and capture learnings. Use after running a job to refine it."
74
105
  instructions_file: steps/learn.md
75
106
  exposed: true
76
107
  inputs:
@@ -85,6 +116,8 @@ steps:
85
116
  - "**Instructions Improved**: Were job instructions updated to address identified issues?"
86
117
  - "**Instructions Concise**: Are instructions free of redundancy and unnecessary verbosity?"
87
118
  - "**Shared Content Extracted**: Is lengthy/duplicated content extracted into referenced files?"
119
+ - "**doc spec Reviewed (if applicable)**: For jobs with doc spec outputs, were doc spec-related learnings identified?"
120
+ - "**doc spec Updated (if applicable)**: Were doc spec files updated with improved quality criteria or structure?"
88
121
  - "**Bespoke Learnings Captured**: Were run-specific learnings added to AGENTS.md?"
89
122
  - "**File References Used**: Do AGENTS.md entries reference other files where appropriate?"
90
123
  - "**Working Folder Correct**: Is AGENTS.md in the correct working folder for the job?"
@@ -31,6 +31,55 @@ Start by asking structured questions to understand what the user wants to accomp
31
31
  - What are the distinct stages from start to finish?
32
32
  - Are there any dependencies between phases?
33
33
 
34
+ ### Step 1.5: Detect Document-Oriented Workflows
35
+
36
+ **Check for document-focused patterns** in the user's description:
37
+ - Keywords: "report", "summary", "document", "create", "monthly", "quarterly", "for stakeholders", "for leadership"
38
+ - Final deliverable is a specific document (e.g., "AWS spending report", "competitive analysis", "sprint summary")
39
+ - Recurring documents with consistent structure
40
+
41
+ **If a document-oriented workflow is detected:**
42
+
43
+ 1. Inform the user: "This workflow produces a specific document type. I recommend defining a doc spec first to ensure consistent quality."
44
+
45
+ 2. Ask structured questions to understand if they want to:
46
+ - Create a doc spec for this document
47
+ - Use an existing doc spec (if any exist in `.deepwork/doc_specs/`)
48
+ - Skip doc spec and proceed with simple outputs
49
+
50
+ ### Step 1.6: Define the Doc Spec (if needed)
51
+
52
+ When creating a doc spec, gather the following information:
53
+
54
+ 1. **Document Identity**
55
+ - What is the document called? (e.g., "Monthly AWS Spending Report")
56
+ - Brief description of its purpose
57
+ - Where should these documents be stored? (path patterns like `finance/aws-reports/*.md`)
58
+
59
+ 2. **Audience and Context**
60
+ - Who reads this document? (target audience)
61
+ - How often is it produced? (frequency)
62
+
63
+ 3. **Quality Criteria** (3-5 criteria, each with name and description)
64
+ Examples for a spending report:
65
+ - **Visualization**: Must include charts showing spend breakdown by service
66
+ - **Variance Analysis**: Must compare current month against previous with percentages
67
+ - **Action Items**: Must include recommended cost optimization actions
68
+
69
+ 4. **Document Structure**
70
+ - What sections should it have?
71
+ - Any required elements (tables, charts, summaries)?
72
+
73
+ ### Step 1.7: Create the doc spec File (if needed)
74
+
75
+ Create the doc spec file at `.deepwork/doc_specs/[doc_spec_name].md`:
76
+
77
+ **Template reference**: See `.deepwork/jobs/deepwork_jobs/templates/doc_spec.md.template` for the standard structure.
78
+
79
+ **Complete example**: See `.deepwork/jobs/deepwork_jobs/templates/doc_spec.md.example` for a fully worked example.
80
+
81
+ After creating the doc spec, proceed to Step 2 with the doc spec reference for the final step's output.
82
+
34
83
  ### Step 2: Define Each Step
35
84
 
36
85
  For each major phase they mentioned, ask structured questions to gather details:
@@ -53,6 +102,9 @@ For each major phase they mentioned, ask structured questions to gather details:
53
102
  - Should outputs be organized in subdirectories? (e.g., `reports/`, `data/`, `drafts/`)
54
103
  - Will other steps need this output?
55
104
 
105
+ **Important**: Output paths should always be within the main repository directory structure, not in dot-directories like `.deepwork/`. Dot-directories are for configuration and job definitions, not for job outputs. Use paths like `research/competitors/report.md` rather than `.deepwork/outputs/report.md`.
106
+ - **Does this output have a doc spec?** If a doc spec was created in Step 1.6/1.7, reference it for the appropriate output
107
+
56
108
  4. **Step Dependencies**
57
109
  - Which previous steps must complete before this one?
58
110
  - Are there any ordering constraints?
@@ -64,6 +116,18 @@ For each major phase they mentioned, ask structured questions to gather details:
64
116
 
65
117
  **Note**: You're gathering this information to understand what instructions will be needed, but you won't create the instruction files yet - that happens in the `implement` step.
66
118
 
119
+ #### Doc Spec-Aware Output Format
120
+
121
+ When a step produces a document with a doc spec reference, use this format in job.yml:
122
+
123
+ ```yaml
124
+ outputs:
125
+ - file: reports/monthly_spending.md
126
+ doc_spec: .deepwork/doc_specs/monthly_aws_report.md
127
+ ```
128
+
129
+ The doc spec's quality criteria will automatically be included in the generated skill, ensuring consistent document quality.
130
+
67
131
  ### Capability Considerations
68
132
 
69
133
  When defining steps, identify any that require specialized tools:
@@ -158,6 +222,8 @@ This creates:
158
222
 
159
223
  (Where `[job_name]` is the name of the NEW job you're creating, e.g., `competitive_research`)
160
224
 
225
+ **Doc Spec**: See `.deepwork/doc_specs/job_spec.md` for the complete specification with quality criteria.
226
+
161
227
  **Template reference**: See `.deepwork/jobs/deepwork_jobs/templates/job.yml.template` for the standard structure.
162
228
 
163
229
  **Complete example**: See `.deepwork/jobs/deepwork_jobs/templates/job.yml.example` for a fully worked example.
@@ -277,7 +343,7 @@ Claude: Great! Creating the job.yml specification now...
277
343
  - .deepwork/jobs/competitive_research/job.yml
278
344
 
279
345
  **Next step:**
280
- Run `/deepwork_jobs.implement` to generate the instruction files for each step based on this specification.
346
+ Run `/deepwork_jobs.review_job_spec` to validate the specification against quality criteria.
281
347
  ```
282
348
 
283
349
  ## Important Guidelines
@@ -317,7 +383,7 @@ The complete YAML specification file (example shown in Step 5 above).
317
383
  After creating the file:
318
384
  1. Inform the user that the specification is complete
319
385
  2. Recommend that they review the job.yml file
320
- 3. Tell them to run `/deepwork_jobs.implement` next
386
+ 3. Tell them to run `/deepwork_jobs.review_job_spec` next
321
387
 
322
388
  ## Quality Criteria
323
389
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Objective
4
4
 
5
- Generate the DeepWork job directory structure and instruction files for each step based on the `job.yml` specification created in the previous step.
5
+ Generate the DeepWork job directory structure and instruction files for each step based on the validated `job.yml` specification from the review_job_spec step.
6
6
 
7
7
  ## Task
8
8
 
@@ -32,7 +32,7 @@ touch .deepwork/jobs/[job_name]/hooks/.gitkeep .deepwork/jobs/[job_name]/templat
32
32
  ### Step 2: Read and Validate the Specification
33
33
 
34
34
  1. **Locate the job.yml file**
35
- - Read `.deepwork/jobs/[job_name]/job.yml` from the define step
35
+ - Read `.deepwork/jobs/[job_name]/job.yml` from the review_job_spec step
36
36
  - Parse the YAML content
37
37
 
38
38
  2. **Validate the specification**
@@ -111,7 +111,7 @@ See `.deepwork/jobs/deepwork_jobs/steps/supplemental_file_references.md` for det
111
111
 
112
112
  ### Step 4: Verify job.yml Location
113
113
 
114
- Verify that `job.yml` is in the correct location at `.deepwork/jobs/[job_name]/job.yml`. The define step should have created it there. If for some reason it's not there, you may need to create or move it.
114
+ Verify that `job.yml` is in the correct location at `.deepwork/jobs/[job_name]/job.yml`. The define and review_job_spec steps should have created and validated it. If for some reason it's not there, you may need to create or move it.
115
115
 
116
116
  ### Step 5: Sync Skills
117
117
 
@@ -2,13 +2,13 @@
2
2
 
3
3
  ## Objective
4
4
 
5
- Think deeply about this task. Reflect on the current conversation to identify learnings from DeepWork job executions, improve job instructions with generalizable insights, and capture bespoke (run-specific) learnings in AGENTS.md files in the appropriate working folder.
5
+ Think deeply about this task. Reflect on the current conversation to identify learnings from DeepWork job executions, improve job instructions with generalizable insights, and capture bespoke (run-specific) learnings in AGENTS.md files in the deepest common folder that would contain all work on the topic in the future.
6
6
 
7
7
  ## Task
8
8
 
9
9
  Analyze the conversation history to extract learnings and improvements, then apply them appropriately:
10
10
  - **Generalizable learnings** → Update job instruction files
11
- - **Bespoke learnings** (specific to this run) → Add to AGENTS.md in working folder
11
+ - **Bespoke learnings** (specific to this run) → Add to AGENTS.md in the deepest common folder for the topic
12
12
 
13
13
  ### Step 1: Analyze Conversation for Job Executions
14
14
 
@@ -17,7 +17,8 @@ Analyze the conversation history to extract learnings and improvements, then app
17
17
  - Identify which jobs and steps were executed
18
18
  - Note the order of execution
19
19
 
20
- 2. **Identify the working folder**
20
+ 2. **Identify the target folder**
21
+ - This should be the deepest common folder that would contain all work on the topic in the future
21
22
  - Should be clear from conversation history where work was done
22
23
  - If unclear, run `git diff` to see where changes were made on the branch
23
24
 
@@ -65,6 +66,15 @@ For each learning identified, determine if it is:
65
66
  - "Quality criteria should include checking for Y"
66
67
  - "Add example of correct output format"
67
68
 
69
+ **doc spec-Related** (should improve doc spec files):
70
+ - Improvements to document quality criteria
71
+ - Changes to document structure or format
72
+ - Updated audience or frequency information
73
+ - Examples:
74
+ - "The report should include a summary table"
75
+ - "Quality criterion 'Visualization' needs clearer requirements"
76
+ - "Documents need a section for action items"
77
+
68
78
  **Bespoke** (should go in AGENTS.md):
69
79
  - Specific to THIS project/codebase/run
70
80
  - Depends on local conventions or structure
@@ -75,6 +85,30 @@ For each learning identified, determine if it is:
75
85
  - "This project uses camelCase for function names"
76
86
  - "The main config file is at `config/settings.yml`"
77
87
 
88
+ ### Step 3.5: Identify doc spec-Related Learnings
89
+
90
+ Review the conversation for doc spec-related improvements:
91
+
92
+ 1. **Quality Criteria Changes**
93
+ - Were any quality criteria unclear or insufficient?
94
+ - Did the agent repeatedly fail certain criteria?
95
+ - Are there new criteria that should be added?
96
+
97
+ 2. **Document Structure Changes**
98
+ - Did the user request different sections?
99
+ - Were parts of the document format confusing?
100
+ - Should the example document be updated?
101
+
102
+ 3. **Metadata Updates**
103
+ - Has the target audience changed?
104
+ - Should frequency or path patterns be updated?
105
+
106
+ **Signals for doc spec improvements:**
107
+ - User asked for changes to document format
108
+ - Repeated validation failures on specific criteria
109
+ - Feedback about missing sections or information
110
+ - Changes to how documents are organized/stored
111
+
78
112
  ### Step 4: Update Job Instructions (Generalizable Learnings)
79
113
 
80
114
  For each generalizable learning:
@@ -128,12 +162,47 @@ Review all instruction files for the job and identify content that:
128
162
  - Shorter instruction files - easier to read and maintain
129
163
  - Consistent guidance across steps
130
164
 
165
+ ### Step 4.5: Update doc spec Files (doc spec-Related Learnings)
166
+
167
+ If doc spec-related learnings were identified:
168
+
169
+ 1. **Locate the doc spec file**
170
+ - Find doc spec references in job.yml outputs (look for `doc_spec: .deepwork/doc_specs/[doc_spec_name].md`)
171
+ - doc spec files are at `.deepwork/doc_specs/[doc_spec_name].md`
172
+
173
+ 2. **Update quality_criteria array**
174
+ - Add new criteria with name and description
175
+ - Modify existing criteria descriptions for clarity
176
+ - Remove criteria that are no longer relevant
177
+
178
+ 3. **Update example document**
179
+ - Modify the markdown body to reflect structure changes
180
+ - Ensure the example matches updated criteria
181
+
182
+ 4. **Update metadata as needed**
183
+ - target_audience: If audience has changed
184
+ - frequency: If production cadence has changed
185
+ - path_patterns: If storage location has changed
186
+
187
+ **Example doc spec update:**
188
+ ```yaml
189
+ # Before
190
+ quality_criteria:
191
+ - name: Visualization
192
+ description: Include charts
193
+
194
+ # After
195
+ quality_criteria:
196
+ - name: Visualization
197
+ description: Include Mermaid.js charts showing spend breakdown by service and month-over-month trend
198
+ ```
199
+
131
200
  ### Step 5: Create/Update AGENTS.md (Bespoke Learnings)
132
201
 
133
202
  The AGENTS.md file captures project-specific knowledge that helps future agent runs.
134
203
 
135
204
  1. **Determine the correct location**
136
- - Place AGENTS.md in the working folder where job outputs live
205
+ - Place AGENTS.md in the deepest common folder that would contain all work on the topic in the future
137
206
  - This ensures the knowledge is available when working in that context
138
207
  - If uncertain, place at the project root
139
208
 
@@ -201,7 +270,7 @@ When adding entries to AGENTS.md, prefer these patterns:
201
270
  - Shared/lengthy content extracted into referenced files where appropriate
202
271
  - AGENTS.md created/updated with bespoke learnings
203
272
  - File references used instead of duplicating content
204
- - AGENTS.md is in the correct working folder
273
+ - AGENTS.md is in the correct folder (the deepest common folder for the topic)
205
274
  - When all criteria are met, include `<promise>✓ Quality Criteria Met</promise>`
206
275
 
207
276
  ## Example Dialog