Skip to content

Commit cc303bc

Browse files
nhortonclaude
andcommitted
Add Document Type Definitions (DTD) support for job outputs
Implement DTDs as a first-class feature for formalizing document specifications with quality criteria, enabling consistent document structure across job outputs. Key changes: - Add DTD schema and parser for frontmatter markdown format - Extend job.yml output schema to support DTD references - Update skill generators to inject DTD context into templates - Add document detection workflow to deepwork_jobs.define - Add DTD improvement workflow to deepwork_jobs.learn - Update Claude and Gemini templates for DTD-aware rendering - Bump version to 0.4.0 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent dd91b52 commit cc303bc

30 files changed

Lines changed: 1609 additions & 36 deletions

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ All notable changes to DeepWork will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.4.0] - 2026-01-20
9+
10+
### Added
11+
- Document Type Definitions (DTDs) as a first-class feature for formalizing document specifications
12+
- New `src/deepwork/schemas/dtd_schema.py` with JSON schema validation
13+
- New `src/deepwork/core/dtd_parser.py` with parser for frontmatter markdown DTD files
14+
- DTD files stored in `.deepwork/dtds/` directory with quality criteria and example documents
15+
- Auto-creates `.deepwork/dtds/` directory during `deepwork install`
16+
- Extended job.yml output schema to support DTD references
17+
- Outputs can now be strings (backward compatible) or objects with `file` and optional `dtd` fields
18+
- Example: `outputs: [{file: "report.md", dtd: "monthly_report"}]`
19+
- DTD-aware skill generation
20+
- Step skills now include DTD quality criteria, target audience, and example documents
21+
- Both Claude and Gemini templates updated for DTD rendering
22+
- Document detection workflow in `deepwork_jobs.define`
23+
- Steps 1.5, 1.6, 1.7 guide users through creating DTDs for document-oriented jobs
24+
- Pattern indicators: "report", "summary", "create", "monthly", "for stakeholders"
25+
- DTD improvement workflow in `deepwork_jobs.learn`
26+
- Steps 3.5, 4.5 capture DTD-related learnings and update DTD files
27+
- New `OutputSpec` dataclass in parser for structured output handling
28+
- Comprehensive DTD documentation in `doc/document-type-definitions.md`
29+
- New test fixtures for DTD validation and parsing
30+
31+
### Changed
32+
- `Step.outputs` changed from `list[str]` to `list[OutputSpec]` for richer output metadata
33+
- `SkillGenerator.generate_all_skills()` now accepts `project_root` parameter for DTD loading
34+
- Updated `deepwork_jobs` to v0.6.0 with DTD-related quality criteria
35+
836
## [0.3.0] - 2026-01-18
937

1038
### Added
@@ -100,6 +128,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
100128

101129
Initial version.
102130

131+
[0.4.0]: https://github.com/anthropics/deepwork/releases/tag/0.4.0
103132
[0.3.0]: https://github.com/anthropics/deepwork/releases/tag/0.3.0
104133
[0.1.1]: https://github.com/anthropics/deepwork/releases/tag/0.1.1
105134
[0.1.0]: https://github.com/anthropics/deepwork/releases/tag/0.1.0

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ your-project/
200200
## Documentation
201201

202202
- **[Architecture](doc/architecture.md)**: Complete design specification
203+
- **[Document Type Definitions](doc/document-type-definitions.md)**: DTD format for output quality criteria
203204
- **[Contributing](CONTRIBUTING.md)**: Setup development environment and contribute
204205

205206
## Project Structure
@@ -241,6 +242,7 @@ Define structured, multi-step workflows where each step has clear requirements a
241242
- **Artifact Passing**: Seamlessly use file outputs from one step as inputs for future steps.
242243
- **Dynamic Inputs**: Support for both fixed file references and interactive user parameters.
243244
- **Human-Readable YAML**: Simple, declarative job definitions that are easy to version and maintain.
245+
- **Document Type Definitions**: Reference DTDs to enforce quality criteria on document outputs (see [DTD documentation](doc/document-type-definitions.md)).
244246

245247
### Git-Native Workflow
246248
Maintain a clean repository with automatic branch management and isolation.

doc/architecture.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ deepwork/ # DeepWork tool repository
4646
│ │ ├── detector.py # AI platform detection
4747
│ │ ├── generator.py # Command file generation
4848
│ │ ├── parser.py # Job definition parsing
49+
│ │ ├── dtd_parser.py # Document Type Definition parsing
4950
│ │ ├── rules_parser.py # Rule definition parsing
5051
│ │ ├── pattern_matcher.py # Variable pattern matching for rules
5152
│ │ ├── rules_queue.py # Rule state queue system
@@ -65,7 +66,10 @@ deepwork/ # DeepWork tool repository
6566
│ ├── standard_jobs/ # Built-in job definitions
6667
│ │ ├── deepwork_jobs/
6768
│ │ │ ├── job.yml
68-
│ │ │ └── steps/
69+
│ │ │ ├── steps/
70+
│ │ │ └── templates/
71+
│ │ │ ├── dtd.md.template
72+
│ │ │ └── dtd.md.example
6973
│ │ └── deepwork_rules/ # Rule management job
7074
│ │ ├── job.yml
7175
│ │ ├── steps/
@@ -76,6 +80,7 @@ deepwork/ # DeepWork tool repository
7680
│ │ └── capture_prompt_work_tree.sh
7781
│ ├── schemas/ # Definition schemas
7882
│ │ ├── job_schema.py
83+
│ │ ├── dtd_schema.py # DTD schema definition
7984
│ │ └── rules_schema.py
8085
│ └── utils/
8186
│ ├── fs.py
@@ -290,6 +295,8 @@ my-project/ # User's project (target)
290295
├── .deepwork/ # DeepWork configuration
291296
│ ├── config.yml # Platform config
292297
│ ├── .gitignore # Ignores tmp/ directory
298+
│ ├── dtds/ # Document Type Definitions
299+
│ │ └── monthly_aws_report.md
293300
│ ├── rules/ # Rule definitions (v2 format)
294301
│ │ ├── source-test-pairing.md
295302
│ │ ├── format-python.md
@@ -1190,6 +1197,90 @@ def my_hook(input: HookInput) -> HookOutput:
11901197

11911198
See `doc/platforms/` for detailed platform-specific hook documentation.
11921199

1200+
---
1201+
1202+
## Document Type Definitions (DTDs)
1203+
1204+
Document Type Definitions (DTDs) formalize document specifications for job outputs. They enable consistent document structure and automated quality validation.
1205+
1206+
### Purpose
1207+
1208+
DTDs solve a common problem with AI-generated documents: inconsistent quality and structure. By defining:
1209+
- Required quality criteria
1210+
- Target audience
1211+
- Document structure (via example)
1212+
1213+
DTDs ensure that documents produced by job steps meet consistent standards.
1214+
1215+
### DTD File Format
1216+
1217+
DTDs are stored in `.deepwork/dtds/[dtd_name].md` using frontmatter markdown:
1218+
1219+
```markdown
1220+
---
1221+
name: "Monthly AWS Spending Report"
1222+
description: "A Markdown summary of AWS spend across accounts"
1223+
path_patterns:
1224+
- "finance/aws-reports/*.md"
1225+
target_audience: "Finance team and Engineering leadership"
1226+
frequency: "Monthly, following AWS invoice arrival"
1227+
quality_criteria:
1228+
- name: Visualization
1229+
description: Must include Mermaid.js charts showing spend per service
1230+
- name: Variance Analysis
1231+
description: Must compare current month against previous with percentages
1232+
---
1233+
1234+
# Monthly AWS Spending Report: [Month, Year]
1235+
1236+
## Executive Summary
1237+
[Example content...]
1238+
```
1239+
1240+
### Using DTDs in Jobs
1241+
1242+
Reference DTDs in job.yml outputs:
1243+
1244+
```yaml
1245+
outputs:
1246+
- file: reports/monthly_spending.md
1247+
dtd: monthly_aws_report # References .deepwork/dtds/monthly_aws_report.md
1248+
```
1249+
1250+
### Generated Skills
1251+
1252+
When `deepwork sync` runs, skills with DTD-referenced outputs include:
1253+
- Document name and description
1254+
- Target audience
1255+
- All quality criteria with descriptions
1256+
- Example document structure (collapsible)
1257+
1258+
### DTD Schema
1259+
1260+
| Field | Required | Description |
1261+
|-------|----------|-------------|
1262+
| `name` | Yes | Human-readable document name |
1263+
| `description` | Yes | Purpose of the document |
1264+
| `quality_criteria` | Yes | Array of `{name, description}` quality requirements |
1265+
| `path_patterns` | No | Where documents should be stored |
1266+
| `target_audience` | No | Who reads the document |
1267+
| `frequency` | No | How often produced |
1268+
1269+
### Workflow Integration
1270+
1271+
The `/deepwork_jobs.define` command:
1272+
1. Detects document-oriented workflows (keywords: "report", "summary", "monthly")
1273+
2. Guides users through DTD creation
1274+
3. Links DTDs to job outputs
1275+
1276+
The `/deepwork_jobs.learn` command:
1277+
1. Identifies DTD-related learnings (quality criteria issues, structure changes)
1278+
2. Updates DTD files with improvements
1279+
1280+
See `doc/document-type-definitions.md` for complete documentation.
1281+
1282+
---
1283+
11931284
### Rule Schema
11941285

11951286
Rules are validated against a JSON Schema:

0 commit comments

Comments
 (0)