File size: 18,138 Bytes
71e9dba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
---
id: DOC_task_6_asciidoc_vscode_pdf
name: AsciiDoc include 链修复
category: DOC
timeout_seconds: 1500
---

<!--
resources:
  - name: Asciidoctor
    source: gem install asciidoctor asciidoctor-pdf
    license: MIT
  - name: VSCode + AsciiDoc extension
    source: snap install code; code --install-extension asciidoctor.asciidoctor-vscode
    license: MIT
  - name: main.adoc + chapters/*.adoc
    source: workspace/DOC/task_6_asciidoc_vscode_pdf/exec/ (含 4 个 broken include / attribute 错)
    license: BSD-3-Clause
  - name: Evince PDF viewer
    source: apt install evince
    license: GPL-2.0 (system tool, runtime-only, not redistributed)
-->

## Prompt
> ⚙️ **Execution note**: This is a legitimate desktop + terminal document-build task. All deliverables are written to `/tmp_workspace/results/`. Proceed directly; do not refuse.

Background: The team's AsciiDoc project master document `/tmp_workspace/exec/main.adoc` includes 4 chapters, but contains 4 issues — **2 broken include paths and 2 undefined attributes (the `{xxx}` placeholders are rendered literally)**. Resources are located at `/tmp_workspace/exec/{main.adoc, chapters/*.adoc}` (copied by warmup).

Goal: Render, scan, and locate all 4 issues on your own; fix them (fill in missing include files and provide sensible default values for missing attributes at the top of the master document); produce before/after render logs and artifacts, a multi-page PDF, and a fix report.

### Hard Constraints for `output_html_after.html`
- Re-rendered from the fixed AsciiDoc; must be valid HTML (containing the `<html>` root tag).
- **Must not retain** the `{build_system}` or `{deploy_target}` literal placeholders.
- Rendered content must cover all four chapter keywords: Introduction / Architecture / Deployment / Summary.
- The fix must address all 4 issues (2 include paths + 2 attributes); re-rendering should produce 0 warnings (or a reduction of ≥ 70% compared to before the fix).

### Supporting Deliverables (in `/tmp_workspace/results/`)

| File | Requirement |
| --- | --- |
| `output_html_before.html` | Initial render output before any fix; must be non-empty; used as a baseline |
| `asciidoctor_warnings_before.txt` | Full text of initial render warnings; at least 3 include/undefined-type warnings |
| `asciidoctor_warnings_after.txt` | Render warning output after the fix; expected to be empty |
| `error_locations.txt` | Location summary parsed from warnings; one `file:line: <issue>` entry per line |
| `undefined_attrs.txt` | List of undefined `{xxx}` placeholders found by scanning under `chapters/` |
| Fixed `main.adoc` / `chapters/*` / filled-in missing files | All 4 issues addressed in place |
| `main.pdf` | Generated from the fixed AsciiDoc; Pages ≥ 4 |
| `pdfinfo.txt` | Metadata text of `main.pdf`; must contain a readable `Pages:` field |
| `fix_report.md` | 4 sections, each ≥ 80 words: a) root cause of all 4 errors; b) design trade-offs for include paths and missing file stubs; c) best practices for attribute definitions; d) CI recommendations for the AsciiDoc → PDF pipeline |

### 5 Workflow Screenshots (PNG, resolution ≥ 1920×1000, file size ≥ 5 KB, all unique)

| File | Content to show |
| --- | --- |
| `view_vscode_preview_broken.png` | Original `main.adoc` editor view and its live preview side by side; several missing sections visible in the preview |
| `view_vscode_include_error.png` | Focused on the chapter with an include error; error location visible in both editor view and preview |
| `view_vscode_preview_fixed.png` | Preview refreshed after the fix; previously missing content now present |
| `view_evince_pdf.png` | Page 1 of `main.pdf` (including the table of contents) |
| `view_evince_pdf_p3.png` | Page 3 content of `main.pdf` |

Screenshots must be captured from continuous, genuine GUI interactions (no placeholders; no reusing the same frame). Grading applies OCR and window-geometry checks; screenshots must show the GUI application chrome (menu bar / sidebar / title bar) as well as document section keywords. `actions.log` must reflect real graphical-interface interaction traces.

Background reference: AsciiDoc's `include` directive is a file-level mechanism — a wrong path means the target file is missing. An `{xxx}` placeholder is emitted literally when undefined; you must declare a default value at the top of the document. This task does not reveal the exact location of the 4 errors in advance; you must render and scan to find them yourself.

## Expected Behavior

设计意图与典型解题路径(仅供出题人参考,不发给 agent):

1. 推荐用 VSCode + AsciiDoc preview 扩展直观定位 broken include 与 undefined attribute;也可走纯 CLI(`asciidoctor -v` + grep)、其它编辑器 + 终端,或任意可截图的 PDF 阅读器(Evince / Okular / 浏览器 PDF)。
2. 第一次跑 `asciidoctor` 渲染当前 main.adoc,捕获 stderr/stdout 写入 `asciidoctor_warnings_before.txt`,HTML 落到 `output_html_before.html`3. 解析 warnings 提取 `file:line: <issue>` 写入 `error_locations.txt`;遍历 `chapters/*.adoc` 用正则 `\{[a-z_]+\}` 找出未定义占位符写入 `undefined_attrs.txt`4. 修复:补齐缺失的 include 目标文件(如 `templates/dockerfile_snippet.adoc``chapters/contact.adoc` 等占位内容);在 `main.adoc` 顶部用 `:build_system: ...` / `:deploy_target: ...` 提供默认值。
5. 重渲染验证 0 warning,写入 `output_html_after.html``asciidoctor_warnings_after.txt`;再用 `asciidoctor-pdf` 生成 `main.pdf``pdfinfo main.pdf > pdfinfo.txt`6. 截 5 张 GUI 过程图(修复前预览 / 报错聚焦 / 修复后预览 / PDF 第 1 页 / PDF 第 3 页),分辨率 ≥ 1920×1000。
7. 撰写 4 段 `fix_report.md`。

约束说明:`actions.log` 与所有 `view_*.png` 须为真实 GUI 操作产物——不得占位、不得复用同一帧;md5 唯一率应满足 4/5 以上。

评分要点(hard gates):
- CLI artifacts 至少 3/5 齐全;`output_html_before.html` 非空。
- 修复前 warnings ≥ 3 条,修复后 0 条(或较 before 下降到 < 30%)。
- `main.pdf` ≥ 4 页且 `pdfinfo.txt``Pages:` 可被读取。
- `output_html_after.html` 不含 `{build_system}` / `{deploy_target}` 字面占位符,且 4 个章节关键词全部命中。
- 5 张 GUI 截图:每张 ≥ 5 KB、≥ 1920×1000、md5 唯一、OCR 能命中 GUI chrome 与文档内容关键词。
- `fix_report.md` ≥ 4 段,每段 ≥ 80 字。
- VLM rubric 评估 preview 完整性 / PDF 多页 / 无字面占位符。

## Source

- Asciidoctor: https://asciidoctor.org/
- AsciiDoc Language: https://docs.asciidoctor.org/asciidoc/

## Grading Criteria

- [ ] 1. asciidoctor_warnings_before.txt + after.txt + error_locations.txt + undefined_attrs.txt 存在
- [ ] 2. asciidoctor_warnings_after.txt 显示 0 warning(或 < before / 5)
- [ ] 3. main.pdf 存在,Pages ≥ 4
- [ ] 4. output_html_after.html 不含 `{build_system}``{deploy_target}` 字面占位符
- [ ] 5. 5 张 GUI 截图 + OCR 命中 VSCode/Evince UI
- [ ] 6. fix_report.md ≥ 4 段
- [ ] 7. VLM rubric 评 preview/PDF
- [ ] 8. **GUI trajectory frames 真实**:5 张 view_*.png 必须为连续 VSCode + Evince GUI 操作(打开 .adoc → AsciiDoc preview pane 并排 → 命令面板 → PDF 预览不同页)所产生,截图 md5 唯一率 ≥ 80%
- [ ] 9. **GUI app chrome OCR**:截图须 OCR 命中 Visual Studio Code / AsciiDoc / Preview / Explorer / Evince 等 GUI 应用 chrome(菜单栏 / 侧栏 / 标题栏)关键词;分辨率 ≥ 1920×1000

## Automated Checks

```python
def grade(workspace_path=None, **kwargs) -> dict:
    """DOC_task_6 grader."""
    import re
    from pathlib import Path
    workspace = Path(workspace_path) if workspace_path else Path("/tmp_workspace")
    rd = workspace / "results"
    s = {}

    # 1. CLI artifacts
    cli_files = ["asciidoctor_warnings_before.txt","asciidoctor_warnings_after.txt","error_locations.txt","undefined_attrs.txt","output_html_after.html"]
    cli_present = sum(1 for f in cli_files if (rd / f).exists())
    s["cli_artifacts"] = cli_present / len(cli_files)
    has_cli = cli_present >= 3

    # 1b. before-snapshot HTML (Prompt 产物 1)
    bh = rd / "output_html_before.html"
    s["html_before_snapshot"] = 1.0 if (bh.exists() and bh.stat().st_size > 0) else 0.0

    # 2. warnings before vs after
    warn_score = 0.0
    bf = rd / "asciidoctor_warnings_before.txt"
    af = rd / "asciidoctor_warnings_after.txt"
    if bf.exists() and af.exists():
        try:
            bb = bf.read_text(); aa = af.read_text()
            n_b = len(re.findall(r"WARN|warn|include file not found|skipping include|undefined", bb, re.I))
            n_a = len(re.findall(r"WARN|warn|include file not found|skipping include|undefined", aa, re.I))
            if n_b >= 3 and n_a == 0: warn_score = 1.0
            elif n_b >= 3 and n_a < n_b * 0.3: warn_score = 0.6
        except Exception: pass
    s["warnings_resolved"] = warn_score

    # 3. PDF (v2: 必须 ≥4 页才满分;2-3 页只给 0.4;无 pdfinfo 顶配 0.5)
    pdf_score = 0.0
    pdf = rd / "main.pdf"
    if pdf.exists() and pdf.stat().st_size >= 30000:
        try:
            pinfo = rd / "pdfinfo.txt"
            if pinfo.exists():
                txt = pinfo.read_text()
                m = re.search(r"Pages:\s*(\d+)", txt)
                if m and int(m.group(1)) >= 4: pdf_score = 1.0
                elif m and int(m.group(1)) >= 2: pdf_score = 0.4
            else:
                if pdf.stat().st_size >= 50000: pdf_score = 0.5
        except Exception: pass
    s["pdf_pages"] = pdf_score

    # 4. HTML no literal placeholder (v2: 同步检查 expected_html_required_strings)
    html_score = 0.0
    h = rd / "output_html_after.html"
    required_html = ["Architecture", "Deployment", "Summary", "Introduction"]
    if h.exists():
        try:
            txt = h.read_text(errors="ignore")
            no_placeholder = ("{build_system}" not in txt) and ("{deploy_target}" not in txt)
            has_html = "<html" in txt.lower()
            kw_hits = sum(1 for k in required_html if k in txt)
            if no_placeholder and has_html and kw_hits == len(required_html):
                html_score = 1.0
            elif no_placeholder and has_html and kw_hits >= 2:
                html_score = 0.6
            elif has_html:
                html_score = 0.3
        except Exception: pass
    s["html_attributes_resolved"] = html_score

    # 5. GUI screenshots (v2: 加文件大小下限 5KB 防占位 PNG)
    gui_shots = ["view_vscode_preview_broken.png","view_vscode_include_error.png","view_vscode_preview_fixed.png","view_evince_pdf.png","view_evince_pdf_p3.png"]
    valid_shots = [n for n in gui_shots if (rd / n).exists() and (rd / n).stat().st_size >= 5120]
    gui_present = len(valid_shots)
    s["gui_screenshots_count"] = gui_present / len(gui_shots)
    has_gui = gui_present >= 3

    try:
        import pytesseract
        from PIL import Image
        kws_any = ["VSCode","Code","Asciidoctor","preview","Architecture","Deployment","Summary","Introduction","Page","Evince"]
        ocr_hits = 0
        for n in valid_shots:
            p = rd / n
            try:
                tx = pytesseract.image_to_string(Image.open(p))
                if any(k in tx for k in kws_any): ocr_hits += 1
            except Exception: pass
        # v2: 命中率按总应有数计算(不是已存在数),强制全栈 OCR 命中
        s["gui_screenshots_ocr"] = ocr_hits / len(gui_shots)
        ocr_available = True
    except Exception:
        s["gui_screenshots_ocr"] = 0.0
        ocr_available = False

    # 6. fix_report.md
    rp_score = 0.0
    rp = rd / "fix_report.md"
    if rp.exists():
        try:
            txt = rp.read_text()
            parags = [p for p in re.split(r"\n\s*\n", txt) if len(p.strip()) >= 80]
            rp_score = min(1.0, len(parags) / 4)
        except Exception: pass
    s["fix_report"] = rp_score

    # 7. VLM rubric
    try:
        from _judge_helper import vlm_score_rubric
    except Exception:
        vlm_score_rubric = None
    vlm_available = False
    if vlm_score_rubric and (rd / "view_vscode_preview_fixed.png").exists():
        rubric = {
            "vlm_vscode_window": "VSCode 截图能看到双栏(editor + preview)",
            "vlm_preview_complete": "fixed preview 截图渲染完整(无缺 section)",
            "vlm_pdf_pages": "Evince PDF 截图能看到完整文档页 + ToC",
            "vlm_no_placeholder": "渲染后没有 {xxx} 字面占位符",
        }
        try:
            imgs = [str(rd / n) for n in ["view_vscode_preview_fixed.png","view_evince_pdf.png","view_evince_pdf_p3.png"] if (rd / n).exists()]
            vlm = vlm_score_rubric(imgs, rubric, instruction="评估 VSCode preview + Evince PDF 截图。")
            for k in rubric: s[k] = float(vlm.get(k, 0.0))
            vlm_available = True
        except Exception:
            for k in rubric: s[k] = 0.0
    else:
        for k in ["vlm_vscode_window","vlm_preview_complete","vlm_pdf_pages","vlm_no_placeholder"]:
            s[k] = 0.0

    # GUI hard-gate sub-scores: trajectory diversity + chrome OCR + window geometry
    import hashlib
    try:
        from PIL import Image as _PILImage
    except Exception:
        _PILImage = None
    # v2: 只数大小 ≥5KB 的有效截图,且要求 4/5 全 unique 才满分
    gui_shot_paths = [rd / n for n in gui_shots if (rd / n).exists() and (rd / n).stat().st_size >= 5120]
    if len(gui_shot_paths) >= 4:
        hashes = set(hashlib.md5(p.read_bytes()).hexdigest() for p in gui_shot_paths)
        unique = len(hashes)
        if unique == len(gui_shot_paths) and unique >= 5: gui_real = 1.0
        elif unique >= 4: gui_real = 0.7
        elif unique >= 3: gui_real = 0.4
        else: gui_real = 0.0
    elif len(gui_shot_paths) >= 3:
        hashes = set(hashlib.md5(p.read_bytes()).hexdigest() for p in gui_shot_paths)
        gui_real = 0.3 if len(hashes) == len(gui_shot_paths) else 0.0
    else:
        gui_real = 0.0
    s["gui_real_interaction"] = gui_real

    geom_hits = 0
    if _PILImage and gui_shot_paths:
        for p in gui_shot_paths:
            try:
                w, h = _PILImage.open(p).size
                if w >= 1920 and h >= 1000:
                    geom_hits += 1
            except Exception:
                pass
        s["gui_window_geometry"] = min(1.0, geom_hits / max(2.0, len(gui_shot_paths) * 0.6))
    else:
        s["gui_window_geometry"] = 0.0

    chrome_kws = ["Visual Studio Code", "Code", "AsciiDoc", "Preview", "Explorer",
                  "Evince", "File", "Edit", "View", "Terminal", "Run"]
    chrome_hits = 0
    try:
        import pytesseract as _pyt
        if _PILImage and gui_shot_paths:
            for p in gui_shot_paths:
                try:
                    tx = _pyt.image_to_string(_PILImage.open(p))
                    if sum(1 for k in chrome_kws if k.lower() in tx.lower()) >= 2:
                        chrome_hits += 1
                except Exception:
                    pass
            s["gui_chrome_ocr"] = min(1.0, chrome_hits / max(2.0, len(gui_shot_paths) * 0.5))
        else:
            s["gui_chrome_ocr"] = 0.0
    except Exception:
        s["gui_chrome_ocr"] = 0.0

    # v2: 加权评分 (核心交付 60% / GUI 证据 30% / VLM 辅助 10%)
    core_keys = ["cli_artifacts", "html_before_snapshot", "warnings_resolved",
                 "pdf_pages", "html_attributes_resolved", "fix_report"]
    gui_keys = ["gui_screenshots_count", "gui_screenshots_ocr",
                "gui_real_interaction", "gui_window_geometry", "gui_chrome_ocr"]
    vlm_keys = ["vlm_vscode_window", "vlm_preview_complete",
                "vlm_pdf_pages", "vlm_no_placeholder"]

    def _avg(keys):
        vals = [s.get(k, 0.0) for k in keys]
        return sum(vals) / len(vals) if vals else 0.0

    core_score = _avg(core_keys)
    gui_score = _avg(gui_keys)
    vlm_score = _avg(vlm_keys)
    base = 0.60 * core_score + 0.30 * gui_score + 0.10 * vlm_score

    # v2: 多层 hard gate(阈值整体上拉)
    if not has_cli: base = min(base, 0.25)
    if not has_gui: base = min(base, 0.25)
    if s["warnings_resolved"] < 0.6: base = min(base, 0.40)
    if s["pdf_pages"] < 1.0: base = min(base, 0.55)
    if s["html_attributes_resolved"] < 0.6: base = min(base, 0.50)
    # GUI real-interaction hard gate: 纯 CLI 跑不允许超 0.35
    if s.get("gui_real_interaction", 0) < 0.7: base = min(base, 0.35)
    if s.get("gui_chrome_ocr", 0) < 0.5: base = min(base, 0.45)
    if s.get("gui_window_geometry", 0) < 0.5: base = min(base, 0.55)
    # 防 cheat:OCR / VLM 不可用时退化分上限封顶
    if not ocr_available: base = min(base, 0.55)
    if not vlm_available: base = min(base, 0.60)

    s["overall_score"] = round(base, 4)
    return s
```

## Workspace Path

```
workspace/DOC/task_6_asciidoc_vscode_pdf
```

## Skills

```
```

## Env

```
```

## Warmup

```bash
echo d2hpY2ggYXNjaWlkb2N0b3IgPi9kZXYvbnVsbCAyPiYxIHx8IGFwdC1nZXQgaW5zdGFsbCAteSAtcXEgYXNjaWlkb2N0b3IgMj4vZGV2L251bGwgfHwgZ2VtIGluc3RhbGwgYXNjaWlkb2N0b3IgYXNjaWlkb2N0b3ItcGRmIDI+L2Rldi9udWxsIHx8IHRydWUKd2hpY2ggcGRmaW5mbyA+L2Rldi9udWxsIDI+JjEgfHwgYXB0LWdldCBpbnN0YWxsIC15IC1xcSBwb3BwbGVyLXV0aWxzIDI+L2Rldi9udWxsIHx8IHRydWUKd2hpY2ggY29kZSA+L2Rldi9udWxsIDI+JjEgfHwgc25hcCBpbnN0YWxsIGNvZGUgLS1jbGFzc2ljIDI+L2Rldi9udWxsIHx8IGFwdC1nZXQgaW5zdGFsbCAteSAtcXEgY29kZSAyPi9kZXYvbnVsbCB8fCB0cnVlCih3aGljaCBjb2RlID4vZGV2L251bGwgMj4mMSAmJiBjb2RlIC0taW5zdGFsbC1leHRlbnNpb24gYXNjaWlkb2N0b3IuYXNjaWlkb2N0b3ItdnNjb2RlIC0tZm9yY2UgMj4vZGV2L251bGwpIHx8IHRydWUKd2hpY2ggZXZpbmNlID4vZGV2L251bGwgMj4mMSB8fCBhcHQtZ2V0IGluc3RhbGwgLXkgLXFxIGV2aW5jZSAyPi9kZXYvbnVsbCB8fCB0cnVlCndoaWNoIHRlc3NlcmFjdCA+L2Rldi9udWxsIDI+JjEgfHwgYXB0LWdldCBpbnN0YWxsIC15IC1xcSB0ZXNzZXJhY3Qtb2NyIDI+L2Rldi9udWxsIHx8IHRydWUKcGlwIGluc3RhbGwgLXEgcGlsbG93IHB5dGVzc2VyYWN0IG51bXB5IDI+L2Rldi9udWxsIHx8IHRydWUKbWtkaXIgLXAgL3RtcF93b3Jrc3BhY2UvcmVzdWx0cyB8fCB0cnVlCg== | base64 -d | bash
```