devlyn-cli 0.5.5 → 0.5.7
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.
- package/bin/devlyn.js +160 -4
- package/config/agents/evaluator.md +40 -0
- package/config/commands/devlyn.evaluate.md +467 -0
- package/optional-skills/dokkit/ANALYSIS.md +32 -1
- package/optional-skills/dokkit/COMMANDS.md +20 -13
- package/optional-skills/dokkit/FILLING.md +19 -0
- package/optional-skills/dokkit/IMAGE-SOURCING.md +2 -2
- package/optional-skills/dokkit/PIPELINE.md +348 -0
- package/optional-skills/dokkit/SKILL.md +169 -111
- package/optional-skills/dokkit/references/docx-section-range-detection.md +147 -0
- package/optional-skills/dokkit/references/image-opportunity-heuristics.md +1 -1
- package/optional-skills/dokkit/scripts/fill_docx.py +819 -0
- package/optional-skills/dokkit/scripts/parse_image_with_gemini.py +3 -3
- package/optional-skills/dokkit/scripts/source_images.py +40 -2
- package/package.json +1 -1
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
# Dokkit Pipeline Reference
|
|
2
|
+
|
|
3
|
+
Detailed step-by-step procedure for the one-command document filling pipeline.
|
|
4
|
+
Auto-loaded when `/dokkit` is invoked.
|
|
5
|
+
|
|
6
|
+
## Table of Contents
|
|
7
|
+
|
|
8
|
+
- [Command Parsing](#command-parsing)
|
|
9
|
+
- [Full Pipeline](#full-pipeline) (Phases 1-6)
|
|
10
|
+
- [Improve Mode](#improve-mode)
|
|
11
|
+
- [Error Handling](#error-handling)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Command Parsing
|
|
16
|
+
|
|
17
|
+
Parse `$ARGUMENTS`:
|
|
18
|
+
|
|
19
|
+
1. If `$1` is `improve` → [Improve Mode](#improve-mode) with remaining args as instruction
|
|
20
|
+
2. If `$1` is a file path (ends in .docx or .hwpx) AND `$2` is a directory → [Full Pipeline](#full-pipeline)
|
|
21
|
+
3. If `$1` is a file path but `$2` is missing → Show error:
|
|
22
|
+
```
|
|
23
|
+
Error: sources 폴더를 지정해주세요.
|
|
24
|
+
Usage: /dokkit <template.docx|hwpx> <sources_folder>
|
|
25
|
+
```
|
|
26
|
+
4. If empty → Show error:
|
|
27
|
+
```
|
|
28
|
+
Error: template과 sources 폴더를 모두 지정해주세요.
|
|
29
|
+
Usage: /dokkit <template.docx|hwpx> <sources_folder>
|
|
30
|
+
Example: /dokkit docs/사업계획서_양식.docx docs/sources/김철수/
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Full Pipeline
|
|
36
|
+
|
|
37
|
+
### Phase 1: Prepare Sources
|
|
38
|
+
|
|
39
|
+
**Goal**: Parse all source files into structured data the filler can use.
|
|
40
|
+
|
|
41
|
+
1. Validate template file (`$1`) exists and is DOCX or HWPX
|
|
42
|
+
2. Validate sources folder (`$2`) exists and contains files
|
|
43
|
+
- If folder is empty: show error "소스 폴더에 파일이 없습니다: `<folder>`"
|
|
44
|
+
- If folder doesn't exist: show error "소스 폴더를 찾을 수 없습니다: `<folder>`"
|
|
45
|
+
3. If `.dokkit/` doesn't exist, create workspace:
|
|
46
|
+
```
|
|
47
|
+
.dokkit/
|
|
48
|
+
├── sources/
|
|
49
|
+
├── template_work/
|
|
50
|
+
├── output/
|
|
51
|
+
├── images/
|
|
52
|
+
└── state.json (initialized)
|
|
53
|
+
```
|
|
54
|
+
4. List all files in sources folder (recursively)
|
|
55
|
+
5. For each source file, spawn **dokkit-ingestor** agent:
|
|
56
|
+
> "Ingest the source document at `<file_path>`. Follow dokkit-ingestor agent instructions. Write to `.dokkit/sources/`."
|
|
57
|
+
|
|
58
|
+
Supported formats: PDF, DOCX, XLSX, CSV, PPTX, HWPX, HWP, PNG, JPG, TXT, MD, JSON, HTML
|
|
59
|
+
6. Report: `Phase 1/6: Prepared N source files from <folder>`
|
|
60
|
+
|
|
61
|
+
### Phase 2: Analyze Template
|
|
62
|
+
|
|
63
|
+
**Goal**: Detect all fillable fields, map template structure, prepare content plans for sections.
|
|
64
|
+
|
|
65
|
+
Spawn **dokkit-analyzer** agent with these modified instructions:
|
|
66
|
+
|
|
67
|
+
> "Analyze template at `<path>`. Detect ALL fillable fields including images, Korean placeholders (OO, 00.00), section content areas, and tip boxes.
|
|
68
|
+
>
|
|
69
|
+
> **IMPORTANT — Changed approach for section_content fields:**
|
|
70
|
+
> For `section_content` fields, do NOT generate the full content (mapped_value). Instead:
|
|
71
|
+
> - Set `mapped_value: null`
|
|
72
|
+
> - Add a `content_plan` object with:
|
|
73
|
+
> - `section_heading`: The section's title/heading from the template
|
|
74
|
+
> - `template_tips`: Writing guidance from the template (작성 팁, ※ instructions)
|
|
75
|
+
> - `relevant_sources`: List of source filenames most relevant to this section
|
|
76
|
+
> - `key_data_points`: Specific statistics, names, dates found in sources
|
|
77
|
+
> - `target_structure`: Expected sub-headings and outline (◦, -, 1. patterns)
|
|
78
|
+
> - `min_chars`: Minimum character target (500-1200 depending on section size)
|
|
79
|
+
>
|
|
80
|
+
> For all OTHER field types (placeholder_text, empty_cell, table_content, image, etc.): map values normally.
|
|
81
|
+
>
|
|
82
|
+
> Write `analysis.json`."
|
|
83
|
+
|
|
84
|
+
Report: `Phase 2/6: Found N fields (X sections, Y tables, Z images)`
|
|
85
|
+
|
|
86
|
+
### Phase 3: Generate Content (Section by Section)
|
|
87
|
+
|
|
88
|
+
**Goal**: Generate high-quality content for every field and save to `fill_content.json`.
|
|
89
|
+
|
|
90
|
+
This is the critical quality phase. The filler generates content with dedicated attention for each section, then saves it to a JSON file. A separate python-docx script handles formatting and insertion.
|
|
91
|
+
|
|
92
|
+
Spawn **dokkit-filler** agent in **content-generation** mode:
|
|
93
|
+
|
|
94
|
+
> "Generate content for ALL fields. Read ALL source files from `.dokkit/sources/*.md` and `analysis.json`.
|
|
95
|
+
>
|
|
96
|
+
> For each `section_content` field:
|
|
97
|
+
> 1. Read the `content_plan` from analysis.json
|
|
98
|
+
> 2. Generate the BEST possible content for this section:
|
|
99
|
+
> - Write like a professional 사업계획서 consultant
|
|
100
|
+
> - Include specific statistics with exact numbers from source data
|
|
101
|
+
> - Name real organizations, partners, competitors
|
|
102
|
+
> - Use persuasive language backed by evidence
|
|
103
|
+
> - Use `[Bold Heading]` for sub-section titles, `- ` for bullets
|
|
104
|
+
> - Meet min_chars target (800-1200 chars for substantial sections)
|
|
105
|
+
>
|
|
106
|
+
> For overview table fields: generate concise values.
|
|
107
|
+
>
|
|
108
|
+
> Save ALL content to `.dokkit/fill_content.json`:
|
|
109
|
+
> ```json
|
|
110
|
+
> { "field_001": "사업명 값", "field_017": "섹션 내용...", ... }
|
|
111
|
+
> ```
|
|
112
|
+
|
|
113
|
+
Report: `Phase 3/6: Generated content for N fields`
|
|
114
|
+
|
|
115
|
+
### Phase 3b: Assemble Document (python-docx)
|
|
116
|
+
|
|
117
|
+
**Goal**: Apply content to template with perfect formatting using `fill_docx.py`.
|
|
118
|
+
|
|
119
|
+
Run the python-docx assembly script (NOT raw XML surgery):
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
python .claude/skills/dokkit/scripts/fill_docx.py \
|
|
123
|
+
<template.docx> \
|
|
124
|
+
.dokkit/analysis.json \
|
|
125
|
+
.dokkit/fill_content.json \
|
|
126
|
+
.dokkit/output/<output_name>.docx
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The script handles:
|
|
130
|
+
- Tip box removal (작성요령 tables + nested tables in cells)
|
|
131
|
+
- Instruction text removal (※ paragraphs + blue text)
|
|
132
|
+
- Overview table filling (label-matching)
|
|
133
|
+
- Section content insertion (with proper pPr/rPr from template)
|
|
134
|
+
- Page breaks between chapters
|
|
135
|
+
- Color sanitization (all text → black)
|
|
136
|
+
- Data table filling (budget, schedule, employee count)
|
|
137
|
+
|
|
138
|
+
Report: `Phase 3b/6: Document assembled — N sections, M tables, K tip boxes removed`
|
|
139
|
+
|
|
140
|
+
### Phase 4: Generate & Insert Images
|
|
141
|
+
|
|
142
|
+
**Goal**: Generate AI images via Gemini and insert into the assembled document using python-docx.
|
|
143
|
+
|
|
144
|
+
#### Step 4a: Generate Images (parallel)
|
|
145
|
+
|
|
146
|
+
**YOU MUST use `source_images.py` for ALL image generation.** Do NOT write inline Gemini API calls — the script handles model selection (`gemini-3-pro-image-preview`), Korean text enforcement, aspect ratios, and error handling. Bypassing it will produce wrong-model, wrong-language, wrong-aspect images.
|
|
147
|
+
|
|
148
|
+
For each image field and image opportunity in `analysis.json`, run in parallel.
|
|
149
|
+
|
|
150
|
+
**CRITICAL: Always pass `--field-id` and `--purpose`** so the image manifest tracks which image was generated for which slot. Without this, images get randomly assigned to the wrong slots.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
python .claude/skills/dokkit/scripts/source_images.py generate \
|
|
154
|
+
--prompt "<prompt>" \
|
|
155
|
+
--preset <preset> \
|
|
156
|
+
--output-dir .dokkit/images/ \
|
|
157
|
+
--project-dir . \
|
|
158
|
+
--lang ko \
|
|
159
|
+
--field-id <field_id> \
|
|
160
|
+
--purpose "<caption or purpose description>"
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The script writes each result to `.dokkit/image_manifest.json` — an array of `{image_id, file_path, field_id, purpose, prompt, ...}`. This manifest is the source of truth for which image goes where during insertion.
|
|
164
|
+
|
|
165
|
+
**Preset selection guide:**
|
|
166
|
+
- `infographic` (16:9) — data visualization, market charts, process flows
|
|
167
|
+
- `technical_illustration` (16:9) — system architecture, tech diagrams
|
|
168
|
+
- `photorealistic` (4:3) — product photos, office scenes
|
|
169
|
+
- `concept` (1:1) — abstract business concepts
|
|
170
|
+
- `chart` (16:9) — charts and graphs
|
|
171
|
+
|
|
172
|
+
**Prompt quality rules:**
|
|
173
|
+
- Include company/product-specific details in every prompt (not generic descriptions)
|
|
174
|
+
- For org charts: use actual team members' names and roles from source data
|
|
175
|
+
- For market charts: mention specific numbers from source data
|
|
176
|
+
- Korean language by default (`--lang ko`), use `--lang ko+en` only when mixing is intentional
|
|
177
|
+
- Skip photo/signature types (require user-provided files)
|
|
178
|
+
- On failure: log warning, continue with other images
|
|
179
|
+
|
|
180
|
+
#### Step 4b: Insert Images (python-docx)
|
|
181
|
+
|
|
182
|
+
Read `.dokkit/image_manifest.json` to determine which image goes where. Match images to slots by `field_id` and `purpose`.
|
|
183
|
+
|
|
184
|
+
Insert generated images into the assembled DOCX using python-docx's `run.add_picture()`:
|
|
185
|
+
|
|
186
|
+
- **Overview table images**: Match by `field_id` (e.g., field_014, field_015). Find the image row, insert the specific image for each field into the correct cell using `cell.paragraphs[0].add_run().add_picture(path, width=Cm(7))`
|
|
187
|
+
- **Section content images**: Match by `purpose` keyword to the section heading. Use `doc.add_picture()` then move the paragraph to the correct position (after the section's last content paragraph)
|
|
188
|
+
- All images are centered and sized proportionally
|
|
189
|
+
- **Never assign images by filename sort order** — always use the manifest mapping
|
|
190
|
+
- **Aspect ratio**: Always measure actual dimensions with PIL, scale to fit while preserving ratio
|
|
191
|
+
|
|
192
|
+
Report: `Phase 4/6: Generated X images, inserted Y`
|
|
193
|
+
|
|
194
|
+
### Phase 5: Quality Review & Auto-Fix
|
|
195
|
+
|
|
196
|
+
**Goal**: Verify document quality and automatically fix issues.
|
|
197
|
+
|
|
198
|
+
#### Step 5a: Run Quality Gates
|
|
199
|
+
|
|
200
|
+
Check the filled document XML in `.dokkit/template_work/`:
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
QG1: Total text character count ≥ 7,500
|
|
204
|
+
QG2: Each section_content field ≥ 500 chars with specific data
|
|
205
|
+
QG3: Zero remaining "00.00" date placeholders
|
|
206
|
+
QG4: Zero remaining "OO" name placeholders (OO학, OO기업, OO전자, etc.)
|
|
207
|
+
QG5: Zero remaining "이미지 영역" text
|
|
208
|
+
QG6: All images sized correctly (aspect ratio within 5% tolerance)
|
|
209
|
+
QG7: No red (#FF0000) or italic text in filled cells
|
|
210
|
+
QG8: ≥ 10 images in document
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### Step 5b: Auto-Fix Failures
|
|
214
|
+
|
|
215
|
+
For each failed gate, spawn **dokkit-filler** in modify mode with specific fix instructions:
|
|
216
|
+
|
|
217
|
+
| Failed Gate | Fix Instruction |
|
|
218
|
+
|-------------|-----------------|
|
|
219
|
+
| QG1/QG2 | "Enrich these sections with more specific data: [list sections with char counts]. Add statistics, market analysis, named competitors, financial projections." |
|
|
220
|
+
| QG3 | "Replace these date placeholders with appropriate dates: [list locations]. Derive from project timeline in sources." |
|
|
221
|
+
| QG4 | "Replace these name placeholders with real names: [list locations]. Derive from source data context." |
|
|
222
|
+
| QG5 | "Remove '이미지 영역' placeholder text at: [list locations]." |
|
|
223
|
+
| QG6 | "Re-size these images to preserve aspect ratio: [list images with current vs. correct dimensions]." |
|
|
224
|
+
| QG7 | "Sanitize text styles at: [list locations]. Change red to black, remove italic." |
|
|
225
|
+
| QG8 | "Generate additional images for sections: [list sections without images]." |
|
|
226
|
+
|
|
227
|
+
#### Step 5c: Re-Check
|
|
228
|
+
|
|
229
|
+
After auto-fix, re-run ALL quality gates. Maximum 3 total iterations.
|
|
230
|
+
|
|
231
|
+
Report: `Phase 5/6: Quality gates — X/8 passed (iteration N/3)`
|
|
232
|
+
|
|
233
|
+
If all gates pass OR max iterations reached:
|
|
234
|
+
- All passed → proceed to export
|
|
235
|
+
- Some failed after 3 iterations → proceed to export with warnings about remaining issues
|
|
236
|
+
|
|
237
|
+
### Phase 6: Export
|
|
238
|
+
|
|
239
|
+
**Goal**: Produce final document and PDF preview.
|
|
240
|
+
|
|
241
|
+
1. Spawn **dokkit-exporter** agent:
|
|
242
|
+
> "Export filled document. Format: `<same as input template>`. Compile from `.dokkit/template_work/`, save to `.dokkit/output/`."
|
|
243
|
+
|
|
244
|
+
2. Generate PDF preview (if LibreOffice available):
|
|
245
|
+
```bash
|
|
246
|
+
soffice --headless --convert-to pdf --outdir .dokkit/output/ <output_file>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
3. Report final results:
|
|
250
|
+
```
|
|
251
|
+
✓ Phase 6/6: Complete
|
|
252
|
+
|
|
253
|
+
Output: .dokkit/output/<filename>.<ext>
|
|
254
|
+
Preview: .dokkit/output/<filename>.pdf
|
|
255
|
+
Size: XX MB
|
|
256
|
+
|
|
257
|
+
Quality: X/8 gates passed
|
|
258
|
+
Sections: N filled (avg Y chars each)
|
|
259
|
+
Images: M inserted
|
|
260
|
+
Iterations: K
|
|
261
|
+
|
|
262
|
+
Next: /dokkit improve to enhance quality further
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Improve Mode
|
|
268
|
+
|
|
269
|
+
For enhancing the filled document after initial generation: `/dokkit improve ["instruction"]`
|
|
270
|
+
|
|
271
|
+
The improve command makes the document **better** — richer content, more images, better formatting, stronger persuasiveness. It's not just "modify a field" — it's "make this document more compelling."
|
|
272
|
+
|
|
273
|
+
1. Check `.dokkit/state.json` for an active filled document
|
|
274
|
+
2. If none exists: show error "완성된 문서가 없습니다. 먼저 `/dokkit <template> <sources>` 를 실행하세요."
|
|
275
|
+
3. Determine improvement scope:
|
|
276
|
+
- **No instruction**: Full document improvement — enrich all sections, add more images, strengthen weak areas
|
|
277
|
+
- **With instruction**: Targeted improvement in the specified direction
|
|
278
|
+
4. Spawn **dokkit-filler** in improve mode:
|
|
279
|
+
|
|
280
|
+
**No instruction (full improvement):**
|
|
281
|
+
> "Improve the filled document. Mode: improve.
|
|
282
|
+
> Read ALL source data and the current filled XML. Find areas to strengthen:
|
|
283
|
+
> - Sections with fewer than 800 chars → add more specific data and analysis
|
|
284
|
+
> - Sections without images → identify image opportunities and generate
|
|
285
|
+
> - Weak arguments → add supporting evidence from sources
|
|
286
|
+
> - Generic language → replace with specific statistics, names, organizations
|
|
287
|
+
> - Missing market data → add competitive landscape, market size, growth rates
|
|
288
|
+
> Make the document more persuasive, data-rich, and visually compelling."
|
|
289
|
+
|
|
290
|
+
**With instruction (targeted improvement):**
|
|
291
|
+
> "Improve the filled document. Mode: improve. Direction: `<instruction>`.
|
|
292
|
+
> Focus on making the document better in the specified direction.
|
|
293
|
+
> Read source data for additional supporting evidence."
|
|
294
|
+
|
|
295
|
+
5. Re-run quality gates and auto-fix if needed (max 2 iterations)
|
|
296
|
+
6. Re-export the improved document
|
|
297
|
+
7. Report what was improved:
|
|
298
|
+
```
|
|
299
|
+
✓ Improvement complete
|
|
300
|
+
|
|
301
|
+
Changes:
|
|
302
|
+
- 시장분석 섹션: 450자 → 920자 (통계 5개 추가)
|
|
303
|
+
- 이미지 3개 추가 (서비스 구조도, 시장 규모 차트, 팀 조직도)
|
|
304
|
+
- 기술 섹션: 경쟁사 비교 테이블 보강
|
|
305
|
+
|
|
306
|
+
Output: .dokkit/output/<filename>.<ext>
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
<example>
|
|
310
|
+
/dokkit improve # 전체적으로 품질 향상
|
|
311
|
+
/dokkit improve "이미지를 더 넣어줘" # 이미지 보강
|
|
312
|
+
/dokkit improve "시장분석 섹션을 더 풍부하게" # 특정 섹션 강화
|
|
313
|
+
/dokkit improve "더 설득력 있게" # 전체 논조 강화
|
|
314
|
+
/dokkit improve "예산 테이블을 더 상세하게" # 특정 테이블 보강
|
|
315
|
+
</example>
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Error Handling
|
|
320
|
+
|
|
321
|
+
| Scenario | Action |
|
|
322
|
+
|----------|--------|
|
|
323
|
+
| Template path missing | Show error with usage: "template과 sources 폴더를 모두 지정해주세요." |
|
|
324
|
+
| Sources folder missing | Show error with usage: "sources 폴더를 지정해주세요." |
|
|
325
|
+
| Sources folder empty | Show error: "소스 폴더에 파일이 없습니다: `<folder>`" |
|
|
326
|
+
| Source file not found | Skip with warning, continue with valid files |
|
|
327
|
+
| Template not DOCX/HWPX | Show error: "지원 형식: .docx, .hwpx" |
|
|
328
|
+
| Gemini API not configured | Warn, skip image generation, fill text only |
|
|
329
|
+
| LibreOffice not available | Skip PDF preview, export in template format only |
|
|
330
|
+
| Quality gate stuck after 3 iterations | Export with warnings about remaining issues |
|
|
331
|
+
| Agent spawn failure | Show error with agent name and context |
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## State Management
|
|
336
|
+
|
|
337
|
+
Read `.dokkit/state.json` before any operation. Update atomically after each phase:
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
Phase 1 → sources[] populated
|
|
341
|
+
Phase 2 → template set, analysis created
|
|
342
|
+
Phase 3 → filled_document created, sections_filled, fields_filled counts
|
|
343
|
+
Phase 4 → images_generated, images_inserted counts
|
|
344
|
+
Phase 5 → quality_gates results, iterations_count
|
|
345
|
+
Phase 6 → exports[] entry added
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Validate after every write: `python ${CLAUDE_SKILL_DIR}/scripts/validate_state.py .dokkit/state.json`
|