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,359 @@
1
+ # Define Job Specification
2
+
3
+ ## Objective
4
+
5
+ Create a `job.yml` specification file that defines the structure of a new DeepWork job by thoroughly understanding the user's workflow requirements through an interactive question-and-answer process.
6
+
7
+ ## Task
8
+
9
+ Guide the user through defining a job specification by asking clarifying questions. **Do not attempt to create the specification without first fully understanding the user's needs.**
10
+
11
+ The output of this step is **only** the `job.yml` file - a complete specification of the workflow. The actual step instruction files will be created in the next step (`implement`).
12
+
13
+ ### Step 1: Understand the Job Purpose
14
+
15
+ Start by asking questions to understand what the user wants to accomplish:
16
+
17
+ 1. **What is the overall goal of this workflow?**
18
+ - What complex task are they trying to accomplish?
19
+ - What domain is this in? (e.g., research, marketing, development, reporting)
20
+ - How often will they run this workflow?
21
+
22
+ 2. **What does success look like?**
23
+ - What's the final deliverable or outcome?
24
+ - Who is the audience for the output?
25
+ - What quality criteria matter most?
26
+
27
+ 3. **What are the major phases?**
28
+ - Ask them to describe the workflow at a high level
29
+ - What are the distinct stages from start to finish?
30
+ - Are there any dependencies between phases?
31
+
32
+ ### Step 2: Define Each Step
33
+
34
+ For each major phase they mentioned, ask detailed questions:
35
+
36
+ 1. **Step Purpose**
37
+ - What exactly does this step accomplish?
38
+ - What is the input to this step?
39
+ - What is the output from this step?
40
+
41
+ 2. **Step Inputs**
42
+ - What information is needed to start this step?
43
+ - Does it need user-provided parameters? (e.g., topic, target audience)
44
+ - Does it need files from previous steps?
45
+ - What format should inputs be in?
46
+
47
+ 3. **Step Outputs**
48
+ - What files or artifacts does this step produce?
49
+ - What format should the output be in? (markdown, YAML, JSON, etc.)
50
+ - Where should each output be saved? (filename/path)
51
+ - Should outputs be organized in subdirectories? (e.g., `reports/`, `data/`, `drafts/`)
52
+ - Will other steps need this output?
53
+
54
+ 4. **Step Dependencies**
55
+ - Which previous steps must complete before this one?
56
+ - Are there any ordering constraints?
57
+
58
+ 5. **Step Process** (high-level understanding)
59
+ - What are the key activities in this step?
60
+ - Are there any quality checks or validation needed?
61
+ - What makes a good vs. bad output for this step?
62
+
63
+ **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.
64
+
65
+ ### Step 3: Validate the Workflow
66
+
67
+ After gathering information about all steps:
68
+
69
+ 1. **Review the flow**
70
+ - Summarize the complete workflow
71
+ - Show how outputs from one step feed into the next
72
+ - Ask if anything is missing
73
+
74
+ 2. **Check for gaps**
75
+ - Are there any steps where the input isn't clearly defined?
76
+ - Are there any outputs that aren't used by later steps?
77
+ - Are there circular dependencies?
78
+
79
+ 3. **Confirm details**
80
+ - Job name (lowercase, underscores, descriptive)
81
+ - Job summary (one clear sentence, max 200 chars)
82
+ - Job description (detailed multi-line explanation)
83
+ - Version number (start with 1.0.0)
84
+
85
+ ### Step 4: Define Quality Validation (Stop Hooks)
86
+
87
+ For each step, consider whether it would benefit from **quality validation loops**. Stop hooks allow the AI agent to iteratively refine its work until quality criteria are met.
88
+
89
+ **Ask the user about quality validation:**
90
+ - "Are there specific quality criteria that must be met for this step?"
91
+ - "Would you like the agent to validate its work before completing?"
92
+ - "What would make you send the work back for revision?"
93
+
94
+ **Stop hooks are particularly valuable for:**
95
+ - Steps with complex outputs that need multiple checks
96
+ - Steps where quality is critical (final deliverables)
97
+ - Steps with subjective quality criteria that benefit from AI self-review
98
+
99
+ **Three types of stop hooks are supported:**
100
+
101
+ 1. **Inline Prompt** (`prompt`) - Best for simple quality criteria
102
+ ```yaml
103
+ stop_hooks:
104
+ - prompt: |
105
+ Verify the output meets these criteria:
106
+ 1. Contains at least 5 competitors
107
+ 2. Each competitor has a description
108
+ 3. Selection rationale is clear
109
+ ```
110
+
111
+ 2. **Prompt File** (`prompt_file`) - For detailed/reusable criteria
112
+ ```yaml
113
+ stop_hooks:
114
+ - prompt_file: hooks/quality_check.md
115
+ ```
116
+
117
+ 3. **Script** (`script`) - For programmatic validation (tests, linting)
118
+ ```yaml
119
+ stop_hooks:
120
+ - script: hooks/run_tests.sh
121
+ ```
122
+
123
+ **Multiple hooks can be combined:**
124
+ ```yaml
125
+ stop_hooks:
126
+ - script: hooks/lint_output.sh
127
+ - prompt: "Verify the content is comprehensive and well-organized"
128
+ ```
129
+
130
+ **Encourage prompt-based hooks** - They leverage the AI's ability to understand context and make nuanced quality judgments. Script hooks are best for objective checks (syntax, format, tests).
131
+
132
+ ### Step 5: Create the job.yml Specification
133
+
134
+ Only after you have complete understanding, create the `job.yml` file:
135
+
136
+ **File Location**: `.deepwork/jobs/[job_name]/job.yml`
137
+
138
+ (Where `[job_name]` is the name of the NEW job you're creating, e.g., `.deepwork/jobs/competitive_research/job.yml`)
139
+
140
+ **Format**:
141
+ ```yaml
142
+ name: [job_name]
143
+ version: "1.0.0"
144
+ summary: "[Brief one-line summary of what this job accomplishes]"
145
+ description: |
146
+ [Detailed multi-line description of the job's purpose, process, and goals.
147
+
148
+ This should explain:
149
+ - What problem this workflow solves
150
+ - What the overall process looks like
151
+ - What the end result will be
152
+ - Who the intended users are
153
+ - Any important context about the workflow]
154
+
155
+ changelog:
156
+ - version: "1.0.0"
157
+ changes: "Initial job creation"
158
+
159
+ steps:
160
+ - id: [step_id]
161
+ name: "[Step Name]"
162
+ description: "[What this step does]"
163
+ instructions_file: steps/[step_id].md
164
+ inputs:
165
+ - name: [param_name]
166
+ description: "[What user needs to provide]"
167
+ # OR for file inputs from previous steps:
168
+ # - file: [filename_or_path]
169
+ # from_step: [previous_step_id]
170
+ outputs:
171
+ - [output_filename_or_path] # e.g., "report.md" or "reports/analysis.md"
172
+ dependencies: [] # List of step IDs that must complete first
173
+ # Optional: Quality validation hooks
174
+ stop_hooks:
175
+ - prompt: |
176
+ Verify this step's output meets quality criteria:
177
+ 1. [Criterion 1]
178
+ 2. [Criterion 2]
179
+ If ALL criteria are met, include `<promise>✓ Quality Criteria Met</promise>`.
180
+
181
+ - id: [another_step]
182
+ name: "[Another Step]"
183
+ description: "[What this step does]"
184
+ instructions_file: steps/[another_step].md
185
+ inputs:
186
+ - file: [output_filename_or_path]
187
+ from_step: [step_id]
188
+ outputs:
189
+ - [another_output_path]
190
+ dependencies:
191
+ - [step_id] # This step requires the previous step
192
+ ```
193
+
194
+ **Important**:
195
+ - Use lowercase with underscores for job name and step IDs
196
+ - Ensure file inputs reference steps in dependencies
197
+ - No circular dependencies
198
+ - At least one output per step
199
+ - The `summary` should be concise (max 200 chars)
200
+ - The `description` should provide rich context for future refinement
201
+ - Include a `changelog` section with an initial entry for version 1.0.0
202
+
203
+ ## Example Dialog
204
+
205
+ ```
206
+ Claude: I'll help you define a new DeepWork job. Let's start by understanding what you're trying to accomplish.
207
+
208
+ What complex task or workflow are you trying to create? What's the overall goal?
209
+
210
+ User: I want to create competitive research reports for my company
211
+
212
+ Claude: Great! Let's dig into that. A few questions:
213
+
214
+ 1. What's the final deliverable? Is it a written report, a presentation, or something else?
215
+ 2. Who is the audience? Your team, executives, clients?
216
+ 3. How comprehensive should these reports be?
217
+
218
+ User: It's a written report for our product team. Should be comprehensive - analyzing 3-5 competitors.
219
+
220
+ Claude: Perfect. Now let's think about the major phases of creating this report. What are the main stages you go through? For example:
221
+ - Identifying which competitors to analyze?
222
+ - Gathering information about them?
223
+ - Analyzing the data?
224
+ - Writing the report?
225
+
226
+ Or is your process different?
227
+
228
+ User: Yes, that's close. I would say:
229
+ 1. Identify competitors
230
+ 2. Research each one
231
+ 3. Create comparison analysis
232
+ 4. Write positioning recommendations
233
+
234
+ Claude: Excellent! Now let's define each step in detail. Starting with "Identify competitors":
235
+
236
+ 1. What inputs do you need to start? Do you already have a market segment in mind, or do you need to specify that?
237
+ 2. What should the output look like? A list of competitor names? More detailed?
238
+ 3. How many competitors should be identified?
239
+
240
+ User: I need to specify the market segment and product category as inputs. The output should be a markdown file with 5-7 competitors and brief descriptions of each.
241
+
242
+ Claude: Perfect. A few more questions about that output:
243
+ 1. What should the file be called? Something like `competitors_list.md`?
244
+ 2. Should it go in the project root, or in a subdirectory like `research/` or `data/`?
245
+
246
+ User: Just call it `competitors_list.md` in the project root.
247
+
248
+ Claude: Great. Now for the "Research each one" step:
249
+ 1. Does it use the competitor list from the first step as input?
250
+ 2. What kind of research - product features, pricing, marketing, all of the above?
251
+ 3. What format should the research output be in?
252
+ 4. Where should that research be saved?
253
+
254
+ [continues for each step...]
255
+
256
+ [After gathering all information:]
257
+
258
+ Claude: Let me summarize the workflow I've designed based on our conversation:
259
+
260
+ **Job: competitive_research**
261
+ Summary: Systematic competitive analysis workflow for product positioning
262
+
263
+ Description:
264
+ A comprehensive workflow for analyzing competitors in your market segment. This job helps product teams understand the competitive landscape by systematically identifying competitors, researching their offerings, creating comparison matrices, and developing strategic positioning recommendations.
265
+
266
+ The workflow produces:
267
+ - A vetted list of key competitors
268
+ - Detailed research notes on each competitor
269
+ - A comparison matrix highlighting key differentiators
270
+ - Strategic positioning recommendations
271
+
272
+ Designed for product teams conducting quarterly competitive analysis.
273
+
274
+ **Steps:**
275
+
276
+ Step 1: identify_competitors
277
+ - Input: market_segment (user), product_category (user)
278
+ - Output: competitors_list.md (5-7 competitors with descriptions)
279
+
280
+ Step 2: research_competitors
281
+ - Input: competitors_list.md (from step 1)
282
+ - Output: research_notes.md (detailed findings for each competitor)
283
+ - Depends on: identify_competitors
284
+
285
+ Step 3: comparative_analysis
286
+ - Input: research_notes.md (from step 2)
287
+ - Output: comparison_matrix.md (side-by-side analysis)
288
+ - Depends on: research_competitors
289
+
290
+ Step 4: positioning_recommendations
291
+ - Input: comparison_matrix.md (from step 3)
292
+ - Output: positioning_report.md (strategic recommendations)
293
+ - Depends on: comparative_analysis
294
+
295
+ Does this accurately capture your workflow? Any changes needed?
296
+
297
+ User: Yes, that's perfect!
298
+
299
+ Claude: Great! Creating the job.yml specification now...
300
+
301
+ [Creates .deepwork/jobs/competitive_research/job.yml with the complete spec]
302
+
303
+ ✓ Job specification created!
304
+
305
+ **File created:**
306
+ - .deepwork/jobs/competitive_research/job.yml
307
+
308
+ **Next step:**
309
+ Run `/deepwork_jobs.implement` to generate the instruction files for each step based on this specification.
310
+ ```
311
+
312
+ ## Important Guidelines
313
+
314
+ 1. **Focus on specification only** - Don't create instruction files yet
315
+ 2. **Ask clarifying questions** - Never skip the discovery phase
316
+ 3. **Rich context in description** - This helps with future refinement
317
+ 4. **Validate understanding** - Summarize and confirm before creating
318
+ 5. **Use examples** - Help users understand what good specifications look like
319
+ 6. **Understand file organization** - Always ask where outputs should be saved and if subdirectories are needed
320
+
321
+ ## Validation Rules
322
+
323
+ Before creating the job.yml, ensure:
324
+ - Job name: lowercase, underscores, no spaces
325
+ - Version: semantic versioning (1.0.0)
326
+ - Summary: concise, under 200 characters
327
+ - Description: detailed, provides context
328
+ - Step IDs: unique, descriptive, lowercase with underscores
329
+ - Dependencies: must reference existing step IDs
330
+ - File inputs: `from_step` must be in dependencies
331
+ - At least one output per step
332
+ - Outputs can be filenames (e.g., `report.md`) or paths (e.g., `reports/analysis.md`)
333
+ - File paths in outputs should match where files will actually be created
334
+ - No circular dependencies
335
+
336
+ ## Output Format
337
+
338
+ ### job.yml
339
+
340
+ The complete YAML specification file (example shown in Step 5 above).
341
+
342
+ **Location**: `.deepwork/jobs/[job_name]/job.yml`
343
+
344
+ (Where `[job_name]` is the name of the new job being created)
345
+
346
+ After creating the file:
347
+ 1. Inform the user that the specification is complete
348
+ 2. Recommend that they review the job.yml file
349
+ 3. Tell them to run `/deepwork_jobs.implement` next
350
+
351
+ ## Quality Criteria
352
+
353
+ - User fully understands what job they're creating
354
+ - All steps have clear inputs and outputs
355
+ - Dependencies make logical sense
356
+ - Summary is concise and descriptive
357
+ - Description provides rich context for future refinement
358
+ - Specification is valid YAML and follows the schema
359
+ - Ready for implementation step