|
1
|
# Architecture |
|
2
|
|
|
3
|
## Pipeline |
|
4
|
|
|
5
|
```mermaid |
|
6
|
flowchart TD |
|
7
|
A[Input path] --> B{Hugo theme?} |
|
8
|
B -- Yes --> C[find_hugo_theme] |
|
9
|
B -- No --> D[find_raw_html_files] |
|
10
|
|
|
11
|
C --> E[Copy theme → themes/name/] |
|
12
|
E --> F[Copy exampleSite content/data/static] |
|
13
|
F --> G[Write hugo.toml] |
|
14
|
G --> H[patch_theme + patch_config] |
|
15
|
H --> I[decapify] |
|
16
|
|
|
17
|
D --> J[hugoify_html via AI] |
|
18
|
J --> K[Write layouts/] |
|
19
|
K --> L[Copy CSS/JS/images] |
|
20
|
L --> M[Write minimal hugo.toml] |
|
21
|
M --> I |
|
22
|
|
|
23
|
I --> N[output/theme-name/] |
|
24
|
``` |
|
25
|
|
|
26
|
## Module Map |
|
27
|
|
|
28
|
| Module | Responsibility | |
|
29
|
|--------|---------------| |
|
30
|
| `src/cli.py` | Argument parsing, logging setup, error handling | |
|
31
|
| `src/config.py` | Multi-backend AI routing (`call_ai`) | |
|
32
|
| `src/utils/complete.py` | Full pipeline orchestration | |
|
33
|
| `src/utils/theme_finder.py` | Locate Hugo theme + exampleSite within messy extracted directories | |
|
34
|
| `src/utils/hugoify.py` | AI-powered HTML → Hugo layout conversion | |
|
35
|
| `src/utils/decapify.py` | Generate Decap CMS `index.html` + `config.yml` | |
|
36
|
| `src/utils/theme_patcher.py` | Patch deprecated Hugo APIs in layout files and config | |
|
37
|
| `src/utils/analyze.py` | Theme structure reporting + AI-powered HTML analysis | |
|
38
|
| `src/utils/translate.py` | AI content translation | |
|
39
|
| `src/utils/deploy.py` | Cloudflare deployment _(stub)_ | |
|
40
|
| `src/utils/cloudflare.py` | Cloudflare configuration _(stub)_ | |
|
41
|
| `src/utils/parser.py` | HTML/CSS linting _(stub)_ | |
|
42
|
|
|
43
|
## AI Backends |
|
44
|
|
|
45
|
All AI calls route through a single `call_ai(prompt, system)` function in `src/config.py`. Switch backends via `HUGOIFIER_BACKEND`: |
|
46
|
|
|
47
|
| Backend | Default Model | Env Var | |
|
48
|
|---------|--------------|---------| |
|
49
|
| `anthropic` (default) | `claude-sonnet-4-6` | `ANTHROPIC_API_KEY` | |
|
50
|
| `openai` | `gpt-4-turbo` | `OPENAI_API_KEY` | |
|
51
|
| `google` | `gemini-1.5-pro` | `GOOGLE_API_KEY` | |
|
52
|
|
|
53
|
## Hugo API Patching |
|
54
|
|
|
55
|
`theme_patcher.py` handles breaking changes in Hugo ≥ v0.128: |
|
56
|
|
|
57
|
**Template patches:** |
|
58
|
|
|
59
|
| Old | New | |
|
60
|
|-----|-----| |
|
61
|
| `.Site.DisqusShortname` | `.Site.Config.Services.Disqus.Shortname` | |
|
62
|
| `.Site.GoogleAnalytics` | `.Site.Config.Services.GoogleAnalytics.ID` | |
|
63
|
|
|
64
|
**Config patches (`hugo.toml`):** |
|
65
|
|
|
66
|
| Old | New | |
|
67
|
|-----|-----| |
|
68
|
| `paginate = N` | `[pagination] pagerSize = N` | |
|
69
|
| `googleAnalytics = "UA-..."` | `[services.googleAnalytics] id = "UA-..."` | |
|
70
|
| `disqusShortname = "..."` | `[services.disqus] shortname = "..."` | |
|
71
|
|
|
72
|
## Decap CMS Generation |
|
73
|
|
|
74
|
`decapify.py` introspects `content/` to build Decap collections: |
|
75
|
|
|
76
|
- **Folder collection** — subdirectory with `.md` files at any depth (blog, posts, etc.) |
|
77
|
- **File collection** — subdirectory with only `_index.md` (about, contact, etc.) |
|
78
|
|
|
79
|
Field types are inferred from YAML frontmatter values: `string`, `text`, `datetime`, `image`, `list`, `boolean`, `number`, `markdown`. |
|
80
|
|
|
81
|
## Output Structure |
|
82
|
|
|
83
|
``` |
|
84
|
output/{theme-name}/ |
|
85
|
├── hugo.toml # Site config (modernized) |
|
86
|
├── content/ # From exampleSite or minimal stub |
|
87
|
├── data/ # From exampleSite (if present) |
|
88
|
├── static/ |
|
89
|
│ └── admin/ |
|
90
|
│ ├── index.html # Decap CMS UI |
|
91
|
│ └── config.yml # Decap collections config |
|
92
|
└── themes/ |
|
93
|
└── {theme-name}/ # Patched Hugo theme |
|
94
|
├── layouts/ |
|
95
|
├── static/ |
|
96
|
└── archetypes/ |
|
97
|
``` |
|
98
|
|