feat(baoyu-article-illustrator): add configurable output directory support

This commit is contained in:
Jim Liu 宝玉 2026-03-14 23:06:25 -05:00
parent 3c5c3e006d
commit 339990e87e
3 changed files with 46 additions and 13 deletions

View File

@ -133,7 +133,7 @@ Full procedures: [references/workflow.md](references/workflow.md#step-5-generate
### Step 6: Finalize ### Step 6: Finalize
Insert `![description](path/NN-{type}-{slug}.png)` after paragraphs. Insert `![description]({relative-path}/NN-{type}-{slug}.png)` after paragraphs. Path computed relative to article file based on output directory setting.
``` ```
Article Illustration Complete! Article Illustration Complete!
@ -143,15 +143,27 @@ Images: X/N generated
## Output Directory ## Output Directory
Output directory is determined by `default_output_dir` in EXTEND.md (set during first-time setup):
| `default_output_dir` | Output Path | Markdown Insert Path |
|----------------------|-------------|----------------------|
| `imgs-subdir` (default) | `{article-dir}/imgs/` | `imgs/NN-{type}-{slug}.png` |
| `same-dir` | `{article-dir}/` | `NN-{type}-{slug}.png` |
| `illustrations-subdir` | `{article-dir}/illustrations/` | `illustrations/NN-{type}-{slug}.png` |
| `independent` | `illustrations/{topic-slug}/` | `illustrations/{topic-slug}/NN-{type}-{slug}.png` (relative to cwd) |
All auxiliary files (outline, prompts) are saved inside the output directory:
``` ```
illustrations/{topic-slug}/ {output-dir}/
├── source-{slug}.{ext}
├── references/ # if provided
├── outline.md ├── outline.md
├── prompts/ ├── prompts/
│ └── NN-{type}-{slug}.md
└── NN-{type}-{slug}.png └── NN-{type}-{slug}.png
``` ```
When input is **pasted content** (no file path), always uses `illustrations/{topic-slug}/` with `source-{slug}.{ext}` saved alongside.
**Slug**: 2-4 words, kebab-case. **Conflict**: append `-YYYYMMDD-HHMMSS`. **Slug**: 2-4 words, kebab-case. **Conflict**: append `-YYYYMMDD-HHMMSS`.
## Modification ## Modification

View File

@ -69,7 +69,23 @@ options:
description: "Friendly, approachable, personal" description: "Friendly, approachable, personal"
``` ```
### Question 3: Save Location ### Question 3: Output Directory
```
header: "Output Directory"
question: "Where to save generated illustrations when illustrating a file?"
options:
- label: "imgs-subdir (Recommended)"
description: "{article-dir}/imgs/ — images in a subdirectory next to the article"
- label: "same-dir"
description: "{article-dir}/ — images alongside the article file"
- label: "illustrations-subdir"
description: "{article-dir}/illustrations/ — separate illustrations subdirectory"
- label: "independent"
description: "illustrations/{topic-slug}/ — standalone directory in cwd"
```
### Question 4: Save Location
``` ```
header: "Save" header: "Save"
@ -108,6 +124,7 @@ watermark:
preferred_style: preferred_style:
name: [selected style or null] name: [selected style or null]
description: "" description: ""
default_output_dir: imgs-subdir # same-dir | imgs-subdir | illustrations-subdir | independent
language: null language: null
custom_styles: [] custom_styles: []
--- ---

View File

@ -55,7 +55,7 @@ Reference Style Extracted (no file):
| Input | Output Directory | Next | | Input | Output Directory | Next |
|-------|------------------|------| |-------|------------------|------|
| File path | Ask user (1.2) | → 1.2 | | File path | EXTEND.md `default_output_dir` (default: `imgs-subdir`). If not configured, confirm in 1.2. | → 1.2 |
| Pasted content | `illustrations/{topic-slug}/` | → 1.4 | | Pasted content | `illustrations/{topic-slug}/` | → 1.4 |
**Backup rule for pasted content**: If `source.md` exists in target directory, rename to `source-backup-YYYYMMDD-HHMMSS.md` before saving. **Backup rule for pasted content**: If `source.md` exists in target directory, rename to `source-backup-YYYYMMDD-HHMMSS.md` before saving.
@ -68,7 +68,7 @@ Check preferences and existing state, then ask ALL needed questions in ONE AskUs
| Question | When to Ask | Options | | Question | When to Ask | Options |
|----------|-------------|---------| |----------|-------------|---------|
| Output directory | No `default_output_dir` in EXTEND.md | `{article-dir}/`, `{article-dir}/imgs/` (Recommended), `{article-dir}/illustrations/`, `illustrations/{topic-slug}/` | | Output directory | No `default_output_dir` in EXTEND.md | `{article-dir}/imgs/` (Recommended), `{article-dir}/`, `{article-dir}/illustrations/`, `illustrations/{topic-slug}/` |
| Existing images | Target dir has `.png/.jpg/.webp` files | `supplement`, `overwrite`, `regenerate` | | Existing images | Target dir has `.png/.jpg/.webp` files | `supplement`, `overwrite`, `regenerate` |
| Article update | Always (file path input) | `update`, `copy` | | Article update | Always (file path input) | `update`, `copy` |
@ -237,7 +237,7 @@ Reference Images:
## Step 4: Generate Outline ## Step 4: Generate Outline
Save as `outline.md`: Save as `{output-dir}/outline.md` (all paths below are relative to the output directory determined in Step 1.1/1.2):
```yaml ```yaml
--- ---
@ -285,7 +285,7 @@ references: # Only if references provided
For each illustration in the outline: For each illustration in the outline:
1. **Create prompt file**: `prompts/NN-{type}-{slug}.md` 1. **Create prompt file**: `{output-dir}/prompts/NN-{type}-{slug}.md`
2. **Include YAML frontmatter**: 2. **Include YAML frontmatter**:
```yaml ```yaml
--- ---
@ -381,10 +381,14 @@ Add: `Include a subtle watermark "[content]" at [position].`
### 6.1 Update Article ### 6.1 Update Article
Insert after corresponding paragraph: Insert after corresponding paragraph, using path relative to article file:
```markdown
![description](illustrations/{slug}/NN-{type}-{slug}.png) | `default_output_dir` | Insert Path |
``` |----------------------|-------------|
| `imgs-subdir` | `![description](imgs/NN-{type}-{slug}.png)` |
| `same-dir` | `![description](NN-{type}-{slug}.png)` |
| `illustrations-subdir` | `![description](illustrations/NN-{type}-{slug}.png)` |
| `independent` | `![description](illustrations/{topic-slug}/NN-{type}-{slug}.png)` (relative to cwd) |
Alt text: concise description in article's language. Alt text: concise description in article's language.