deepwork 0.1.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 (41) hide show
  1. deepwork/__init__.py +25 -0
  2. deepwork/cli/__init__.py +1 -0
  3. deepwork/cli/install.py +290 -0
  4. deepwork/cli/main.py +25 -0
  5. deepwork/cli/sync.py +176 -0
  6. deepwork/core/__init__.py +1 -0
  7. deepwork/core/adapters.py +373 -0
  8. deepwork/core/detector.py +93 -0
  9. deepwork/core/generator.py +290 -0
  10. deepwork/core/hooks_syncer.py +206 -0
  11. deepwork/core/parser.py +310 -0
  12. deepwork/core/policy_parser.py +285 -0
  13. deepwork/hooks/__init__.py +1 -0
  14. deepwork/hooks/evaluate_policies.py +159 -0
  15. deepwork/schemas/__init__.py +1 -0
  16. deepwork/schemas/job_schema.py +212 -0
  17. deepwork/schemas/policy_schema.py +68 -0
  18. deepwork/standard_jobs/deepwork_jobs/job.yml +102 -0
  19. deepwork/standard_jobs/deepwork_jobs/steps/define.md +359 -0
  20. deepwork/standard_jobs/deepwork_jobs/steps/implement.md +435 -0
  21. deepwork/standard_jobs/deepwork_jobs/steps/refine.md +447 -0
  22. deepwork/standard_jobs/deepwork_policy/hooks/capture_work_tree.sh +26 -0
  23. deepwork/standard_jobs/deepwork_policy/hooks/get_changed_files.sh +30 -0
  24. deepwork/standard_jobs/deepwork_policy/hooks/global_hooks.yml +8 -0
  25. deepwork/standard_jobs/deepwork_policy/hooks/policy_stop_hook.sh +72 -0
  26. deepwork/standard_jobs/deepwork_policy/hooks/user_prompt_submit.sh +17 -0
  27. deepwork/standard_jobs/deepwork_policy/job.yml +35 -0
  28. deepwork/standard_jobs/deepwork_policy/steps/define.md +174 -0
  29. deepwork/templates/__init__.py +1 -0
  30. deepwork/templates/claude/command-job-step.md.jinja +210 -0
  31. deepwork/templates/gemini/command-job-step.toml.jinja +169 -0
  32. deepwork/utils/__init__.py +1 -0
  33. deepwork/utils/fs.py +128 -0
  34. deepwork/utils/git.py +164 -0
  35. deepwork/utils/validation.py +31 -0
  36. deepwork/utils/yaml_utils.py +89 -0
  37. deepwork-0.1.0.dist-info/METADATA +389 -0
  38. deepwork-0.1.0.dist-info/RECORD +41 -0
  39. deepwork-0.1.0.dist-info/WHEEL +4 -0
  40. deepwork-0.1.0.dist-info/entry_points.txt +2 -0
  41. deepwork-0.1.0.dist-info/licenses/LICENSE.md +60 -0
@@ -0,0 +1,435 @@
1
+ # Implement Job Steps
2
+
3
+ ## Objective
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.
6
+
7
+ ## Task
8
+
9
+ Read the `job.yml` specification file and create all the necessary files to make the job functional, including directory structure and step instruction files. Then sync the commands to make them available.
10
+
11
+ ### Step 1: Read and Validate the Specification
12
+
13
+ 1. **Locate the job.yml file**
14
+ - Read `.deepwork/jobs/[job_name]/job.yml` from the define step (Where `[job_name]` is the name of the new job that was created in the define step)
15
+ - Parse the YAML content
16
+
17
+ 2. **Validate the specification**
18
+ - Ensure it follows the schema (name, version, summary, description, steps)
19
+ - Check that all dependencies reference existing steps
20
+ - Verify no circular dependencies
21
+ - Confirm file inputs match dependencies
22
+
23
+ 3. **Extract key information**
24
+ - Job name, version, summary, description
25
+ - List of all steps with their details
26
+ - Understand the workflow structure
27
+
28
+ ### Step 2: Create Directory Structure
29
+
30
+ Create the job directory in `.deepwork/jobs/[job_name]/`:
31
+
32
+ ```bash
33
+ mkdir -p .deepwork/jobs/[job_name]/steps
34
+ ```
35
+
36
+ Files to create:
37
+ - `.deepwork/jobs/[job_name]/job.yml`
38
+ - `.deepwork/jobs/[job_name]/steps/[step_id].md` - One for each step
39
+
40
+ ### Step 3: Generate Step Instruction Files
41
+
42
+ For each step in the job.yml, create a comprehensive instruction file at `.deepwork/jobs/[job_name]/steps/[step_id].md`.
43
+
44
+ Each instruction file should follow this structure:
45
+
46
+ ```markdown
47
+ # [Step Name]
48
+
49
+ ## Objective
50
+
51
+ [Clear statement of what this step accomplishes, derived from the step's description]
52
+
53
+ ## Task
54
+
55
+ [Detailed instructions for completing this step, based on:
56
+ - The step's purpose
57
+ - Expected inputs and outputs
58
+ - The job's overall context
59
+ ]
60
+
61
+ ### Process
62
+
63
+ [Break down the step into substeps. Use the information gathered during define about:
64
+ - What needs to be done
65
+ - What makes a good output
66
+ - Any quality criteria
67
+ ]
68
+
69
+ 1. [Substep 1]
70
+ 2. [Substep 2]
71
+ 3. [Substep 3]
72
+
73
+ [If this step has user inputs, explain how to gather them]
74
+ [If this step has file inputs, explain how to use them]
75
+
76
+ ## Output Format
77
+
78
+ ### [output_filename_1]
79
+
80
+ [Description of what should be in this output file]
81
+
82
+ **Structure**:
83
+ ```[file format]
84
+ [Example or template of what the output should look like]
85
+ ```
86
+
87
+ [Repeat for each output file]
88
+
89
+ ## Quality Criteria
90
+
91
+ [List what makes this step's output high quality:
92
+ - Completeness checks
93
+ - Format requirements
94
+ - Content requirements
95
+ ]
96
+
97
+ - [Quality criterion 1]
98
+ - [Quality criterion 2]
99
+ - [Quality criterion 3]
100
+
101
+ ## Context
102
+
103
+ [Provide context from the job's overall description to help understand why this step matters and how it fits into the bigger picture]
104
+ ```
105
+
106
+ **Guidelines for generating instructions:**
107
+
108
+ 1. **Use the job description** - The detailed description from job.yml provides crucial context
109
+ 2. **Be specific** - Don't write generic instructions; tailor them to the step's purpose
110
+ 3. **Provide examples** - Show what good output looks like
111
+ 4. **Explain the "why"** - Help the user understand the step's role in the workflow
112
+ 5. **Quality over quantity** - Detailed, actionable instructions are better than vague ones
113
+ 6. **Align with stop hooks** - If the step has `stop_hooks` defined, ensure the quality criteria in the instruction file match the validation criteria in the hooks
114
+
115
+ ### Handling Stop Hooks
116
+
117
+ If a step in the job.yml has `stop_hooks` defined, the generated instruction file should:
118
+
119
+ 1. **Mirror the quality criteria** - The "Quality Criteria" section should match what the stop hooks will validate
120
+ 2. **Be explicit about success** - Help the agent understand when the step is truly complete
121
+ 3. **Include the promise pattern** - Mention that `<promise>✓ Quality Criteria Met</promise>` should be included when criteria are met
122
+
123
+ **Example: If the job.yml has:**
124
+ ```yaml
125
+ - id: research_competitors
126
+ name: "Research Competitors"
127
+ stop_hooks:
128
+ - prompt: |
129
+ Verify the research meets criteria:
130
+ 1. Each competitor has at least 3 data points
131
+ 2. Sources are cited
132
+ 3. Information is current (within last year)
133
+ ```
134
+
135
+ **The instruction file should include:**
136
+ ```markdown
137
+ ## Quality Criteria
138
+
139
+ - Each competitor has at least 3 distinct data points
140
+ - All information is sourced with citations
141
+ - Data is current (from within the last year)
142
+ - When all criteria are met, include `<promise>✓ Quality Criteria Met</promise>` in your response
143
+ ```
144
+
145
+ This alignment ensures the AI agent knows exactly what will be validated and can self-check before completing.
146
+
147
+ ### Step 4: Verify job.yml Location
148
+
149
+ 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.
150
+
151
+ ### Step 5: Sync Commands
152
+
153
+ Run `deepwork sync` to generate the slash-commands for this job:
154
+
155
+ ```bash
156
+ deepwork sync
157
+ ```
158
+
159
+ This will:
160
+ - Parse the job definition
161
+ - Generate slash-commands for each step
162
+ - Make the commands available in `.claude/commands/` (or appropriate platform directory)
163
+
164
+ ### Step 6: Reload Commands
165
+
166
+ Instruct the user to reload commands in their current session:
167
+ - Run `/reload` command (if available)
168
+ - Or restart the Claude session
169
+
170
+ ### Step 7: Consider Policies for the New Job
171
+
172
+ After implementing the job, consider whether there are **policies** that would help enforce quality or consistency when working with this job's domain.
173
+
174
+ **What are policies?**
175
+
176
+ Policies are automated guardrails defined in `.deepwork.policy.yml` that trigger when certain files change during an AI session. They help ensure:
177
+ - Documentation stays in sync with code
178
+ - Team guidelines are followed
179
+ - Architectural decisions are respected
180
+ - Quality standards are maintained
181
+
182
+ **When to suggest policies:**
183
+
184
+ Think about the job you just implemented and ask:
185
+ - Does this job produce outputs that other files depend on?
186
+ - Are there documentation files that should be updated when this job's outputs change?
187
+ - Are there quality checks or reviews that should happen when certain files in this domain change?
188
+ - Could changes to the job's output files impact other parts of the project?
189
+
190
+ **Examples of policies that might make sense:**
191
+
192
+ | Job Type | Potential Policy |
193
+ |----------|------------------|
194
+ | API Design | "Update API docs when endpoint definitions change" |
195
+ | Database Schema | "Review migrations when schema files change" |
196
+ | Competitive Research | "Update strategy docs when competitor analysis changes" |
197
+ | Feature Development | "Update changelog when feature files change" |
198
+ | Configuration Management | "Update install guide when config files change" |
199
+
200
+ **How to offer policy creation:**
201
+
202
+ If you identify one or more policies that would benefit the user, explain:
203
+ 1. **What the policy would do** - What triggers it and what action it prompts
204
+ 2. **Why it would help** - How it prevents common mistakes or keeps things in sync
205
+ 3. **What files it would watch** - The trigger patterns
206
+
207
+ Then ask the user:
208
+
209
+ > "Would you like me to create this policy for you? I can run `/deepwork_policy.define` to set it up."
210
+
211
+ If the user agrees, invoke the `/deepwork_policy.define` command to guide them through creating the policy.
212
+
213
+ **Example dialogue:**
214
+
215
+ ```
216
+ Based on the competitive_research job you just created, I noticed that when
217
+ competitor analysis files change, it would be helpful to remind you to update
218
+ your strategy documentation.
219
+
220
+ I'd suggest a policy like:
221
+ - **Name**: "Update strategy when competitor analysis changes"
222
+ - **Trigger**: `**/positioning_report.md`
223
+ - **Action**: Prompt to review and update `docs/strategy.md`
224
+
225
+ Would you like me to create this policy? I can run `/deepwork_policy.define` to set it up.
226
+ ```
227
+
228
+ **Note:** Not every job needs policies. Only suggest them when they would genuinely help maintain consistency or quality. Don't force policies where they don't make sense.
229
+
230
+ ## Example Implementation
231
+
232
+ **Given this job.yml:**
233
+ ```yaml
234
+ name: competitive_research
235
+ version: "1.0.0"
236
+ summary: "Systematic competitive analysis workflow"
237
+ description: |
238
+ A comprehensive workflow for analyzing competitors in your market segment.
239
+ Helps product teams understand the competitive landscape through systematic
240
+ identification, research, comparison, and positioning recommendations.
241
+
242
+ steps:
243
+ - id: identify_competitors
244
+ name: "Identify Competitors"
245
+ description: "Identify 5-7 key competitors in the target market"
246
+ instructions_file: steps/identify_competitors.md
247
+ inputs:
248
+ - name: market_segment
249
+ description: "The market segment to analyze"
250
+ - name: product_category
251
+ description: "The product category"
252
+ outputs:
253
+ - competitors_list.md
254
+ dependencies: []
255
+ ```
256
+
257
+ **Generate this instruction file** (`.deepwork/jobs/competitive_research/steps/identify_competitors.md`):
258
+
259
+ ```markdown
260
+ # Identify Competitors
261
+
262
+ ## Objective
263
+
264
+ Identify 5-7 key competitors in the target market segment to analyze for competitive positioning.
265
+
266
+ ## Task
267
+
268
+ Research and identify the most relevant competitors in the specified market segment and product category. Focus on companies that directly compete for the same customer base and solve similar problems.
269
+
270
+ ### Process
271
+
272
+ 1. **Understand the market context**
273
+ - Review the market segment provided by the user
274
+ - Understand the product category boundaries
275
+ - Consider direct and indirect competitors
276
+
277
+ 2. **Research competitors**
278
+ - Search for companies in this space
279
+ - Look for market leaders and emerging players
280
+ - Consider different competitive dimensions (features, price, target market)
281
+
282
+ 3. **Select 5-7 key competitors**
283
+ - Prioritize direct competitors
284
+ - Include at least one market leader
285
+ - Include 1-2 emerging/innovative players
286
+ - Ensure diversity in the competitive set
287
+
288
+ 4. **Document each competitor**
289
+ - Company name
290
+ - Brief description (2-3 sentences)
291
+ - Why they're a relevant competitor
292
+ - Primary competitive dimension
293
+
294
+ ## Output Format
295
+
296
+ ### competitors_list.md
297
+
298
+ A markdown document listing each competitor with context.
299
+
300
+ **Structure**:
301
+ ```markdown
302
+ # Competitor Analysis: [Market Segment]
303
+
304
+ ## Market Context
305
+ - **Segment**: [market segment]
306
+ - **Category**: [product category]
307
+ - **Analysis Date**: [current date]
308
+
309
+ ## Identified Competitors
310
+
311
+ ### 1. [Competitor Name]
312
+ **Description**: [2-3 sentence description of what they do]
313
+
314
+ **Why Relevant**: [Why they're a key competitor in this space]
315
+
316
+ **Competitive Dimension**: [What they compete on - e.g., price, features, market segment]
317
+
318
+ [Repeat for each competitor, 5-7 total]
319
+
320
+ ## Selection Rationale
321
+
322
+ [Brief paragraph explaining why these specific competitors were chosen and what dimensions of competition they represent]
323
+ ```
324
+
325
+ ## Quality Criteria
326
+
327
+ - 5-7 competitors identified (not too few, not too many)
328
+ - Mix of established and emerging players
329
+ - All competitors are genuinely relevant to the market segment
330
+ - Each competitor has clear, specific description
331
+ - Selection rationale explains the competitive landscape
332
+ - Output is well-formatted and ready for use by next step
333
+
334
+ ## Context
335
+
336
+ This is the foundation step for competitive analysis. The competitors identified here will be deeply researched in subsequent steps, so it's important to choose the right set. Focus on competitors that will provide strategic insights for positioning decisions.
337
+ ```
338
+
339
+ ## Important Guidelines
340
+
341
+ 1. **Read the spec carefully** - Understand the job's intent from the description
342
+ 2. **Generate complete instructions** - Don't create placeholder or stub files
343
+ 3. **Maintain consistency** - Use the same structure for all step instruction files
344
+ 4. **Provide examples** - Show what good output looks like
345
+ 5. **Use context** - The job description provides valuable context for each step
346
+ 6. **Be specific** - Tailor instructions to the specific step, not generic advice
347
+
348
+ ## Validation Before Sync
349
+
350
+ Before running `deepwork sync`, verify:
351
+ - All directories exist
352
+ - `job.yml` is in place
353
+ - All step instruction files exist (one per step)
354
+ - No file system errors
355
+
356
+ ## Output Format
357
+
358
+ ### implementation_summary.md
359
+
360
+ After successful implementation, create a summary:
361
+
362
+ ```markdown
363
+ # Job Implementation Complete: [job_name]
364
+
365
+ ## Overview
366
+
367
+ Successfully implemented the **[job_name]** workflow with [N] steps.
368
+
369
+ **Summary**: [job summary]
370
+
371
+ **Version**: [version]
372
+
373
+ ## Files Created
374
+
375
+ ### Job Definition
376
+ - `.deepwork/jobs/[job_name]/job.yml`
377
+
378
+ ### Step Instructions
379
+ - `.deepwork/jobs/[job_name]/steps/[step1_id].md`
380
+ - `.deepwork/jobs/[job_name]/steps/[step2_id].md`
381
+ [... list all step files ...]
382
+
383
+
384
+ ## Generated Commands
385
+
386
+ After running `deepwork sync`, the following slash-commands are now available:
387
+
388
+ - `/[job_name].[step1_id]` - [step description]
389
+ - `/[job_name].[step2_id]` - [step description]
390
+ [... list all commands ...]
391
+
392
+ ## Next Steps
393
+
394
+ 1. **Reload commands**: Run `/reload` or restart your Claude session
395
+ 2. **Start the workflow**: Run `/[job_name].[first_step_id]` to begin
396
+ 3. **Test the job**: Try executing the first step to ensure everything works
397
+
398
+ ## Job Structure
399
+
400
+ [Show the workflow diagram with step names and dependencies]
401
+
402
+ Step 1: [step_name]
403
+
404
+ Step 2: [step_name]
405
+
406
+ Step 3: [step_name]
407
+
408
+ [Final output]
409
+
410
+ The job is now ready for use!
411
+ ```
412
+
413
+ ## Completion Checklist
414
+
415
+ Before marking this step complete, ensure:
416
+ - [ ] job.yml validated and copied to job directory
417
+ - [ ] All step instruction files created
418
+ - [ ] Each instruction file is complete and actionable
419
+ - [ ] `deepwork sync` executed successfully
420
+ - [ ] Commands generated in platform directory
421
+ - [ ] User informed of next steps (reload commands)
422
+ - [ ] implementation_summary.md created
423
+ - [ ] Considered whether policies would benefit this job (Step 7)
424
+ - [ ] If policies suggested, offered to run `/deepwork_policy.define`
425
+
426
+ ## Quality Criteria
427
+
428
+ - Job directory structure is correct
429
+ - All instruction files are complete (not stubs)
430
+ - Instructions are specific and actionable
431
+ - Output examples are provided in each instruction file
432
+ - Quality criteria defined for each step
433
+ - Sync completed successfully
434
+ - Commands available for use
435
+ - Thoughtfully considered relevant policies for the job domain