@kolbo/kolbo-code-linux-arm64-musl 1.1.74 → 2.0.0
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/kolbo +0 -0
- package/package.json +1 -1
- package/skills/brainstorming/SKILL.md +164 -0
- package/skills/brainstorming/scripts/frame-template.html +214 -0
- package/skills/brainstorming/scripts/helper.js +88 -0
- package/skills/brainstorming/scripts/server.cjs +354 -0
- package/skills/brainstorming/scripts/start-server.sh +148 -0
- package/skills/brainstorming/scripts/stop-server.sh +56 -0
- package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/skills/brainstorming/visual-companion.md +287 -0
- package/skills/dispatching-parallel-agents/SKILL.md +182 -0
- package/skills/docx/.skillfish.json +10 -0
- package/skills/docx/SKILL.md +196 -0
- package/skills/docx/docx-js.md +350 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/docx/ooxml/scripts/pack.py +159 -0
- package/skills/docx/ooxml/scripts/unpack.py +29 -0
- package/skills/docx/ooxml/scripts/validate.py +69 -0
- package/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/docx/ooxml/scripts/validation/base.py +951 -0
- package/skills/docx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/docx/ooxml.md +599 -0
- package/skills/docx/scripts/__init__.py +1 -0
- package/skills/docx/scripts/document.py +1272 -0
- package/skills/docx/scripts/templates/comments.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/skills/docx/scripts/templates/people.xml +3 -0
- package/skills/docx/scripts/utilities.py +374 -0
- package/skills/executing-plans/SKILL.md +70 -0
- package/skills/finishing-a-development-branch/SKILL.md +200 -0
- package/skills/fullstack-app/SKILL.md +621 -0
- package/skills/kolbo/SKILL.md +19 -263
- package/skills/ollama-vision/SKILL.md +105 -0
- package/skills/pdf/.skillfish.json +10 -0
- package/skills/pdf/FORMS.md +205 -0
- package/skills/pdf/REFERENCE.md +612 -0
- package/skills/pdf/SKILL.md +293 -0
- package/skills/pdf/scripts/check_bounding_boxes.py +70 -0
- package/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/skills/pdf/scripts/check_fillable_fields.py +12 -0
- package/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/skills/pdf/scripts/create_validation_image.py +41 -0
- package/skills/pdf/scripts/extract_form_field_info.py +152 -0
- package/skills/pdf/scripts/fill_fillable_fields.py +114 -0
- package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/skills/photo-studio/SKILL.md +122 -0
- package/skills/pptx/.skillfish.json +10 -0
- package/skills/pptx/SKILL.md +483 -0
- package/skills/pptx/html2pptx.md +626 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/pptx/ooxml/scripts/pack.py +159 -0
- package/skills/pptx/ooxml/scripts/unpack.py +29 -0
- package/skills/pptx/ooxml/scripts/validate.py +69 -0
- package/skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/pptx/ooxml/scripts/validation/base.py +951 -0
- package/skills/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/pptx/ooxml.md +427 -0
- package/skills/pptx/scripts/html2pptx.js +995 -0
- package/skills/pptx/scripts/inventory.py +1020 -0
- package/skills/pptx/scripts/rearrange.py +231 -0
- package/skills/pptx/scripts/replace.py +385 -0
- package/skills/pptx/scripts/thumbnail.py +450 -0
- package/skills/receiving-code-review/SKILL.md +213 -0
- package/skills/requesting-code-review/SKILL.md +105 -0
- package/skills/requesting-code-review/code-reviewer.md +146 -0
- package/skills/subagent-driven-development/SKILL.md +277 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/skills/subagent-driven-development/implementer-prompt.md +113 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/skills/supabase/.skillfish.json +10 -0
- package/skills/supabase/SKILL.md +106 -0
- package/skills/supabase/assets/feedback-issue-template.md +17 -0
- package/skills/supabase/references/skill-feedback.md +17 -0
- package/skills/supabase-postgres-best-practices/.skillfish.json +10 -0
- package/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/skills/supabase-postgres-best-practices/references/security-rls-performance.md +57 -0
- package/skills/supabase-quickstart/SKILL.md +400 -0
- package/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/skills/systematic-debugging/SKILL.md +296 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +63 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/systematic-debugging/test-academic.md +14 -0
- package/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/skills/test-driven-development/SKILL.md +371 -0
- package/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/skills/using-git-worktrees/SKILL.md +218 -0
- package/skills/using-superpowers/SKILL.md +115 -0
- package/skills/using-superpowers/references/codex-tools.md +100 -0
- package/skills/using-superpowers/references/gemini-tools.md +33 -0
- package/skills/verification-before-completion/SKILL.md +139 -0
- package/skills/video-production/SKILL.md +8 -7
- package/skills/writing-plans/SKILL.md +152 -0
- package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/skills/writing-skills/SKILL.md +655 -0
- package/skills/writing-skills/anthropic-best-practices.md +1150 -0
- package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/skills/writing-skills/persuasion-principles.md +187 -0
- package/skills/writing-skills/render-graphs.js +168 -0
- package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
- package/skills/xlsx/.skillfish.json +10 -0
- package/skills/xlsx/SKILL.md +288 -0
- package/skills/xlsx/recalc.py +178 -0
- package/skills/color-grading/SKILL.md +0 -152
- package/skills/ffmpeg-patterns/SKILL.md +0 -240
- package/skills/image-prompting-guide/SKILL.md +0 -143
- package/skills/music-prompting/SKILL.md +0 -146
- package/skills/production-review/SKILL.md +0 -152
- package/skills/short-form-video/SKILL.md +0 -168
- package/skills/sound-design/SKILL.md +0 -154
- package/skills/storytelling/SKILL.md +0 -139
- package/skills/subtitle-production/SKILL.md +0 -244
- package/skills/subtitle-production/reference/burn_to_video.py +0 -222
- package/skills/subtitle-production/reference/export_srts.py +0 -127
- package/skills/subtitle-production/reference/gen_srt.py +0 -42
- package/skills/typography-video/SKILL.md +0 -182
- package/skills/typography-video/reference/KineticTitleScene.tsx +0 -345
- package/skills/video-editing/SKILL.md +0 -128
- package/skills/video-prompting-guide/SKILL.md +0 -268
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# Visual Companion Guide
|
|
2
|
+
|
|
3
|
+
Browser-based visual brainstorming companion for showing mockups, diagrams, and options.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
Decide per-question, not per-session. The test: **would the user understand this better by seeing it than reading it?**
|
|
8
|
+
|
|
9
|
+
**Use the browser** when the content itself is visual:
|
|
10
|
+
|
|
11
|
+
- **UI mockups** — wireframes, layouts, navigation structures, component designs
|
|
12
|
+
- **Architecture diagrams** — system components, data flow, relationship maps
|
|
13
|
+
- **Side-by-side visual comparisons** — comparing two layouts, two color schemes, two design directions
|
|
14
|
+
- **Design polish** — when the question is about look and feel, spacing, visual hierarchy
|
|
15
|
+
- **Spatial relationships** — state machines, flowcharts, entity relationships rendered as diagrams
|
|
16
|
+
|
|
17
|
+
**Use the terminal** when the content is text or tabular:
|
|
18
|
+
|
|
19
|
+
- **Requirements and scope questions** — "what does X mean?", "which features are in scope?"
|
|
20
|
+
- **Conceptual A/B/C choices** — picking between approaches described in words
|
|
21
|
+
- **Tradeoff lists** — pros/cons, comparison tables
|
|
22
|
+
- **Technical decisions** — API design, data modeling, architectural approach selection
|
|
23
|
+
- **Clarifying questions** — anything where the answer is words, not a visual preference
|
|
24
|
+
|
|
25
|
+
A question *about* a UI topic is not automatically a visual question. "What kind of wizard do you want?" is conceptual — use the terminal. "Which of these wizard layouts feels right?" is visual — use the browser.
|
|
26
|
+
|
|
27
|
+
## How It Works
|
|
28
|
+
|
|
29
|
+
The server watches a directory for HTML files and serves the newest one to the browser. You write HTML content to `screen_dir`, the user sees it in their browser and can click to select options. Selections are recorded to `state_dir/events` that you read on your next turn.
|
|
30
|
+
|
|
31
|
+
**Content fragments vs full documents:** If your HTML file starts with `<!DOCTYPE` or `<html`, the server serves it as-is (just injects the helper script). Otherwise, the server automatically wraps your content in the frame template — adding the header, CSS theme, selection indicator, and all interactive infrastructure. **Write content fragments by default.** Only write full documents when you need complete control over the page.
|
|
32
|
+
|
|
33
|
+
## Starting a Session
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Start server with persistence (mockups saved to project)
|
|
37
|
+
scripts/start-server.sh --project-dir /path/to/project
|
|
38
|
+
|
|
39
|
+
# Returns: {"type":"server-started","port":52341,"url":"http://localhost:52341",
|
|
40
|
+
# "screen_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/content",
|
|
41
|
+
# "state_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/state"}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Save `screen_dir` and `state_dir` from the response. Tell user to open the URL.
|
|
45
|
+
|
|
46
|
+
**Finding connection info:** The server writes its startup JSON to `$STATE_DIR/server-info`. If you launched the server in the background and didn't capture stdout, read that file to get the URL and port. When using `--project-dir`, check `<project>/.superpowers/brainstorm/` for the session directory.
|
|
47
|
+
|
|
48
|
+
**Note:** Pass the project root as `--project-dir` so mockups persist in `.superpowers/brainstorm/` and survive server restarts. Without it, files go to `/tmp` and get cleaned up. Remind the user to add `.superpowers/` to `.gitignore` if it's not already there.
|
|
49
|
+
|
|
50
|
+
**Launching the server by platform:**
|
|
51
|
+
|
|
52
|
+
**Claude Code (macOS / Linux):**
|
|
53
|
+
```bash
|
|
54
|
+
# Default mode works — the script backgrounds the server itself
|
|
55
|
+
scripts/start-server.sh --project-dir /path/to/project
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Claude Code (Windows):**
|
|
59
|
+
```bash
|
|
60
|
+
# Windows auto-detects and uses foreground mode, which blocks the tool call.
|
|
61
|
+
# Use run_in_background: true on the Bash tool call so the server survives
|
|
62
|
+
# across conversation turns.
|
|
63
|
+
scripts/start-server.sh --project-dir /path/to/project
|
|
64
|
+
```
|
|
65
|
+
When calling this via the Bash tool, set `run_in_background: true`. Then read `$STATE_DIR/server-info` on the next turn to get the URL and port.
|
|
66
|
+
|
|
67
|
+
**Codex:**
|
|
68
|
+
```bash
|
|
69
|
+
# Codex reaps background processes. The script auto-detects CODEX_CI and
|
|
70
|
+
# switches to foreground mode. Run it normally — no extra flags needed.
|
|
71
|
+
scripts/start-server.sh --project-dir /path/to/project
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Gemini CLI:**
|
|
75
|
+
```bash
|
|
76
|
+
# Use --foreground and set is_background: true on your shell tool call
|
|
77
|
+
# so the process survives across turns
|
|
78
|
+
scripts/start-server.sh --project-dir /path/to/project --foreground
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Other environments:** The server must keep running in the background across conversation turns. If your environment reaps detached processes, use `--foreground` and launch the command with your platform's background execution mechanism.
|
|
82
|
+
|
|
83
|
+
If the URL is unreachable from your browser (common in remote/containerized setups), bind a non-loopback host:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
scripts/start-server.sh \
|
|
87
|
+
--project-dir /path/to/project \
|
|
88
|
+
--host 0.0.0.0 \
|
|
89
|
+
--url-host localhost
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Use `--url-host` to control what hostname is printed in the returned URL JSON.
|
|
93
|
+
|
|
94
|
+
## The Loop
|
|
95
|
+
|
|
96
|
+
1. **Check server is alive**, then **write HTML** to a new file in `screen_dir`:
|
|
97
|
+
- Before each write, check that `$STATE_DIR/server-info` exists. If it doesn't (or `$STATE_DIR/server-stopped` exists), the server has shut down — restart it with `start-server.sh` before continuing. The server auto-exits after 30 minutes of inactivity.
|
|
98
|
+
- Use semantic filenames: `platform.html`, `visual-style.html`, `layout.html`
|
|
99
|
+
- **Never reuse filenames** — each screen gets a fresh file
|
|
100
|
+
- Use Write tool — **never use cat/heredoc** (dumps noise into terminal)
|
|
101
|
+
- Server automatically serves the newest file
|
|
102
|
+
|
|
103
|
+
2. **Tell user what to expect and end your turn:**
|
|
104
|
+
- Remind them of the URL (every step, not just first)
|
|
105
|
+
- Give a brief text summary of what's on screen (e.g., "Showing 3 layout options for the homepage")
|
|
106
|
+
- Ask them to respond in the terminal: "Take a look and let me know what you think. Click to select an option if you'd like."
|
|
107
|
+
|
|
108
|
+
3. **On your next turn** — after the user responds in the terminal:
|
|
109
|
+
- Read `$STATE_DIR/events` if it exists — this contains the user's browser interactions (clicks, selections) as JSON lines
|
|
110
|
+
- Merge with the user's terminal text to get the full picture
|
|
111
|
+
- The terminal message is the primary feedback; `state_dir/events` provides structured interaction data
|
|
112
|
+
|
|
113
|
+
4. **Iterate or advance** — if feedback changes current screen, write a new file (e.g., `layout-v2.html`). Only move to the next question when the current step is validated.
|
|
114
|
+
|
|
115
|
+
5. **Unload when returning to terminal** — when the next step doesn't need the browser (e.g., a clarifying question, a tradeoff discussion), push a waiting screen to clear the stale content:
|
|
116
|
+
|
|
117
|
+
```html
|
|
118
|
+
<!-- filename: waiting.html (or waiting-2.html, etc.) -->
|
|
119
|
+
<div style="display:flex;align-items:center;justify-content:center;min-height:60vh">
|
|
120
|
+
<p class="subtitle">Continuing in terminal...</p>
|
|
121
|
+
</div>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
This prevents the user from staring at a resolved choice while the conversation has moved on. When the next visual question comes up, push a new content file as usual.
|
|
125
|
+
|
|
126
|
+
6. Repeat until done.
|
|
127
|
+
|
|
128
|
+
## Writing Content Fragments
|
|
129
|
+
|
|
130
|
+
Write just the content that goes inside the page. The server wraps it in the frame template automatically (header, theme CSS, selection indicator, and all interactive infrastructure).
|
|
131
|
+
|
|
132
|
+
**Minimal example:**
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<h2>Which layout works better?</h2>
|
|
136
|
+
<p class="subtitle">Consider readability and visual hierarchy</p>
|
|
137
|
+
|
|
138
|
+
<div class="options">
|
|
139
|
+
<div class="option" data-choice="a" onclick="toggleSelect(this)">
|
|
140
|
+
<div class="letter">A</div>
|
|
141
|
+
<div class="content">
|
|
142
|
+
<h3>Single Column</h3>
|
|
143
|
+
<p>Clean, focused reading experience</p>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
<div class="option" data-choice="b" onclick="toggleSelect(this)">
|
|
147
|
+
<div class="letter">B</div>
|
|
148
|
+
<div class="content">
|
|
149
|
+
<h3>Two Column</h3>
|
|
150
|
+
<p>Sidebar navigation with main content</p>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
That's it. No `<html>`, no CSS, no `<script>` tags needed. The server provides all of that.
|
|
157
|
+
|
|
158
|
+
## CSS Classes Available
|
|
159
|
+
|
|
160
|
+
The frame template provides these CSS classes for your content:
|
|
161
|
+
|
|
162
|
+
### Options (A/B/C choices)
|
|
163
|
+
|
|
164
|
+
```html
|
|
165
|
+
<div class="options">
|
|
166
|
+
<div class="option" data-choice="a" onclick="toggleSelect(this)">
|
|
167
|
+
<div class="letter">A</div>
|
|
168
|
+
<div class="content">
|
|
169
|
+
<h3>Title</h3>
|
|
170
|
+
<p>Description</p>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Multi-select:** Add `data-multiselect` to the container to let users select multiple options. Each click toggles the item. The indicator bar shows the count.
|
|
177
|
+
|
|
178
|
+
```html
|
|
179
|
+
<div class="options" data-multiselect>
|
|
180
|
+
<!-- same option markup — users can select/deselect multiple -->
|
|
181
|
+
</div>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Cards (visual designs)
|
|
185
|
+
|
|
186
|
+
```html
|
|
187
|
+
<div class="cards">
|
|
188
|
+
<div class="card" data-choice="design1" onclick="toggleSelect(this)">
|
|
189
|
+
<div class="card-image"><!-- mockup content --></div>
|
|
190
|
+
<div class="card-body">
|
|
191
|
+
<h3>Name</h3>
|
|
192
|
+
<p>Description</p>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Mockup container
|
|
199
|
+
|
|
200
|
+
```html
|
|
201
|
+
<div class="mockup">
|
|
202
|
+
<div class="mockup-header">Preview: Dashboard Layout</div>
|
|
203
|
+
<div class="mockup-body"><!-- your mockup HTML --></div>
|
|
204
|
+
</div>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Split view (side-by-side)
|
|
208
|
+
|
|
209
|
+
```html
|
|
210
|
+
<div class="split">
|
|
211
|
+
<div class="mockup"><!-- left --></div>
|
|
212
|
+
<div class="mockup"><!-- right --></div>
|
|
213
|
+
</div>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Pros/Cons
|
|
217
|
+
|
|
218
|
+
```html
|
|
219
|
+
<div class="pros-cons">
|
|
220
|
+
<div class="pros"><h4>Pros</h4><ul><li>Benefit</li></ul></div>
|
|
221
|
+
<div class="cons"><h4>Cons</h4><ul><li>Drawback</li></ul></div>
|
|
222
|
+
</div>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Mock elements (wireframe building blocks)
|
|
226
|
+
|
|
227
|
+
```html
|
|
228
|
+
<div class="mock-nav">Logo | Home | About | Contact</div>
|
|
229
|
+
<div style="display: flex;">
|
|
230
|
+
<div class="mock-sidebar">Navigation</div>
|
|
231
|
+
<div class="mock-content">Main content area</div>
|
|
232
|
+
</div>
|
|
233
|
+
<button class="mock-button">Action Button</button>
|
|
234
|
+
<input class="mock-input" placeholder="Input field">
|
|
235
|
+
<div class="placeholder">Placeholder area</div>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Typography and sections
|
|
239
|
+
|
|
240
|
+
- `h2` — page title
|
|
241
|
+
- `h3` — section heading
|
|
242
|
+
- `.subtitle` — secondary text below title
|
|
243
|
+
- `.section` — content block with bottom margin
|
|
244
|
+
- `.label` — small uppercase label text
|
|
245
|
+
|
|
246
|
+
## Browser Events Format
|
|
247
|
+
|
|
248
|
+
When the user clicks options in the browser, their interactions are recorded to `$STATE_DIR/events` (one JSON object per line). The file is cleared automatically when you push a new screen.
|
|
249
|
+
|
|
250
|
+
```jsonl
|
|
251
|
+
{"type":"click","choice":"a","text":"Option A - Simple Layout","timestamp":1706000101}
|
|
252
|
+
{"type":"click","choice":"c","text":"Option C - Complex Grid","timestamp":1706000108}
|
|
253
|
+
{"type":"click","choice":"b","text":"Option B - Hybrid","timestamp":1706000115}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
The full event stream shows the user's exploration path — they may click multiple options before settling. The last `choice` event is typically the final selection, but the pattern of clicks can reveal hesitation or preferences worth asking about.
|
|
257
|
+
|
|
258
|
+
If `$STATE_DIR/events` doesn't exist, the user didn't interact with the browser — use only their terminal text.
|
|
259
|
+
|
|
260
|
+
## Design Tips
|
|
261
|
+
|
|
262
|
+
- **Scale fidelity to the question** — wireframes for layout, polish for polish questions
|
|
263
|
+
- **Explain the question on each page** — "Which layout feels more professional?" not just "Pick one"
|
|
264
|
+
- **Iterate before advancing** — if feedback changes current screen, write a new version
|
|
265
|
+
- **2-4 options max** per screen
|
|
266
|
+
- **Use real content when it matters** — for a photography portfolio, use actual images (Unsplash). Placeholder content obscures design issues.
|
|
267
|
+
- **Keep mockups simple** — focus on layout and structure, not pixel-perfect design
|
|
268
|
+
|
|
269
|
+
## File Naming
|
|
270
|
+
|
|
271
|
+
- Use semantic names: `platform.html`, `visual-style.html`, `layout.html`
|
|
272
|
+
- Never reuse filenames — each screen must be a new file
|
|
273
|
+
- For iterations: append version suffix like `layout-v2.html`, `layout-v3.html`
|
|
274
|
+
- Server serves newest file by modification time
|
|
275
|
+
|
|
276
|
+
## Cleaning Up
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
scripts/stop-server.sh $SESSION_DIR
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
If the session used `--project-dir`, mockup files persist in `.superpowers/brainstorm/` for later reference. Only `/tmp` sessions get deleted on stop.
|
|
283
|
+
|
|
284
|
+
## Reference
|
|
285
|
+
|
|
286
|
+
- Frame template (CSS reference): `scripts/frame-template.html`
|
|
287
|
+
- Helper script (client-side): `scripts/helper.js`
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dispatching-parallel-agents
|
|
3
|
+
description: Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dispatching Parallel Agents
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
You delegate tasks to specialized agents with isolated context. By precisely crafting their instructions and context, you ensure they stay focused and succeed at their task. They should never inherit your session's context or history — you construct exactly what they need. This also preserves your own context for coordination work.
|
|
11
|
+
|
|
12
|
+
When you have multiple unrelated failures (different test files, different subsystems, different bugs), investigating them sequentially wastes time. Each investigation is independent and can happen in parallel.
|
|
13
|
+
|
|
14
|
+
**Core principle:** Dispatch one agent per independent problem domain. Let them work concurrently.
|
|
15
|
+
|
|
16
|
+
## When to Use
|
|
17
|
+
|
|
18
|
+
```dot
|
|
19
|
+
digraph when_to_use {
|
|
20
|
+
"Multiple failures?" [shape=diamond];
|
|
21
|
+
"Are they independent?" [shape=diamond];
|
|
22
|
+
"Single agent investigates all" [shape=box];
|
|
23
|
+
"One agent per problem domain" [shape=box];
|
|
24
|
+
"Can they work in parallel?" [shape=diamond];
|
|
25
|
+
"Sequential agents" [shape=box];
|
|
26
|
+
"Parallel dispatch" [shape=box];
|
|
27
|
+
|
|
28
|
+
"Multiple failures?" -> "Are they independent?" [label="yes"];
|
|
29
|
+
"Are they independent?" -> "Single agent investigates all" [label="no - related"];
|
|
30
|
+
"Are they independent?" -> "Can they work in parallel?" [label="yes"];
|
|
31
|
+
"Can they work in parallel?" -> "Parallel dispatch" [label="yes"];
|
|
32
|
+
"Can they work in parallel?" -> "Sequential agents" [label="no - shared state"];
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Use when:**
|
|
37
|
+
- 3+ test files failing with different root causes
|
|
38
|
+
- Multiple subsystems broken independently
|
|
39
|
+
- Each problem can be understood without context from others
|
|
40
|
+
- No shared state between investigations
|
|
41
|
+
|
|
42
|
+
**Don't use when:**
|
|
43
|
+
- Failures are related (fix one might fix others)
|
|
44
|
+
- Need to understand full system state
|
|
45
|
+
- Agents would interfere with each other
|
|
46
|
+
|
|
47
|
+
## The Pattern
|
|
48
|
+
|
|
49
|
+
### 1. Identify Independent Domains
|
|
50
|
+
|
|
51
|
+
Group failures by what's broken:
|
|
52
|
+
- File A tests: Tool approval flow
|
|
53
|
+
- File B tests: Batch completion behavior
|
|
54
|
+
- File C tests: Abort functionality
|
|
55
|
+
|
|
56
|
+
Each domain is independent - fixing tool approval doesn't affect abort tests.
|
|
57
|
+
|
|
58
|
+
### 2. Create Focused Agent Tasks
|
|
59
|
+
|
|
60
|
+
Each agent gets:
|
|
61
|
+
- **Specific scope:** One test file or subsystem
|
|
62
|
+
- **Clear goal:** Make these tests pass
|
|
63
|
+
- **Constraints:** Don't change other code
|
|
64
|
+
- **Expected output:** Summary of what you found and fixed
|
|
65
|
+
|
|
66
|
+
### 3. Dispatch in Parallel
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// In Claude Code / AI environment
|
|
70
|
+
Task("Fix agent-tool-abort.test.ts failures")
|
|
71
|
+
Task("Fix batch-completion-behavior.test.ts failures")
|
|
72
|
+
Task("Fix tool-approval-race-conditions.test.ts failures")
|
|
73
|
+
// All three run concurrently
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 4. Review and Integrate
|
|
77
|
+
|
|
78
|
+
When agents return:
|
|
79
|
+
- Read each summary
|
|
80
|
+
- Verify fixes don't conflict
|
|
81
|
+
- Run full test suite
|
|
82
|
+
- Integrate all changes
|
|
83
|
+
|
|
84
|
+
## Agent Prompt Structure
|
|
85
|
+
|
|
86
|
+
Good agent prompts are:
|
|
87
|
+
1. **Focused** - One clear problem domain
|
|
88
|
+
2. **Self-contained** - All context needed to understand the problem
|
|
89
|
+
3. **Specific about output** - What should the agent return?
|
|
90
|
+
|
|
91
|
+
```markdown
|
|
92
|
+
Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:
|
|
93
|
+
|
|
94
|
+
1. "should abort tool with partial output capture" - expects 'interrupted at' in message
|
|
95
|
+
2. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed
|
|
96
|
+
3. "should properly track pendingToolCount" - expects 3 results but gets 0
|
|
97
|
+
|
|
98
|
+
These are timing/race condition issues. Your task:
|
|
99
|
+
|
|
100
|
+
1. Read the test file and understand what each test verifies
|
|
101
|
+
2. Identify root cause - timing issues or actual bugs?
|
|
102
|
+
3. Fix by:
|
|
103
|
+
- Replacing arbitrary timeouts with event-based waiting
|
|
104
|
+
- Fixing bugs in abort implementation if found
|
|
105
|
+
- Adjusting test expectations if testing changed behavior
|
|
106
|
+
|
|
107
|
+
Do NOT just increase timeouts - find the real issue.
|
|
108
|
+
|
|
109
|
+
Return: Summary of what you found and what you fixed.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Common Mistakes
|
|
113
|
+
|
|
114
|
+
**❌ Too broad:** "Fix all the tests" - agent gets lost
|
|
115
|
+
**✅ Specific:** "Fix agent-tool-abort.test.ts" - focused scope
|
|
116
|
+
|
|
117
|
+
**❌ No context:** "Fix the race condition" - agent doesn't know where
|
|
118
|
+
**✅ Context:** Paste the error messages and test names
|
|
119
|
+
|
|
120
|
+
**❌ No constraints:** Agent might refactor everything
|
|
121
|
+
**✅ Constraints:** "Do NOT change production code" or "Fix tests only"
|
|
122
|
+
|
|
123
|
+
**❌ Vague output:** "Fix it" - you don't know what changed
|
|
124
|
+
**✅ Specific:** "Return summary of root cause and changes"
|
|
125
|
+
|
|
126
|
+
## When NOT to Use
|
|
127
|
+
|
|
128
|
+
**Related failures:** Fixing one might fix others - investigate together first
|
|
129
|
+
**Need full context:** Understanding requires seeing entire system
|
|
130
|
+
**Exploratory debugging:** You don't know what's broken yet
|
|
131
|
+
**Shared state:** Agents would interfere (editing same files, using same resources)
|
|
132
|
+
|
|
133
|
+
## Real Example from Session
|
|
134
|
+
|
|
135
|
+
**Scenario:** 6 test failures across 3 files after major refactoring
|
|
136
|
+
|
|
137
|
+
**Failures:**
|
|
138
|
+
- agent-tool-abort.test.ts: 3 failures (timing issues)
|
|
139
|
+
- batch-completion-behavior.test.ts: 2 failures (tools not executing)
|
|
140
|
+
- tool-approval-race-conditions.test.ts: 1 failure (execution count = 0)
|
|
141
|
+
|
|
142
|
+
**Decision:** Independent domains - abort logic separate from batch completion separate from race conditions
|
|
143
|
+
|
|
144
|
+
**Dispatch:**
|
|
145
|
+
```
|
|
146
|
+
Agent 1 → Fix agent-tool-abort.test.ts
|
|
147
|
+
Agent 2 → Fix batch-completion-behavior.test.ts
|
|
148
|
+
Agent 3 → Fix tool-approval-race-conditions.test.ts
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Results:**
|
|
152
|
+
- Agent 1: Replaced timeouts with event-based waiting
|
|
153
|
+
- Agent 2: Fixed event structure bug (threadId in wrong place)
|
|
154
|
+
- Agent 3: Added wait for async tool execution to complete
|
|
155
|
+
|
|
156
|
+
**Integration:** All fixes independent, no conflicts, full suite green
|
|
157
|
+
|
|
158
|
+
**Time saved:** 3 problems solved in parallel vs sequentially
|
|
159
|
+
|
|
160
|
+
## Key Benefits
|
|
161
|
+
|
|
162
|
+
1. **Parallelization** - Multiple investigations happen simultaneously
|
|
163
|
+
2. **Focus** - Each agent has narrow scope, less context to track
|
|
164
|
+
3. **Independence** - Agents don't interfere with each other
|
|
165
|
+
4. **Speed** - 3 problems solved in time of 1
|
|
166
|
+
|
|
167
|
+
## Verification
|
|
168
|
+
|
|
169
|
+
After agents return:
|
|
170
|
+
1. **Review each summary** - Understand what changed
|
|
171
|
+
2. **Check for conflicts** - Did agents edit same code?
|
|
172
|
+
3. **Run full suite** - Verify all fixes work together
|
|
173
|
+
4. **Spot check** - Agents can make systematic errors
|
|
174
|
+
|
|
175
|
+
## Real-World Impact
|
|
176
|
+
|
|
177
|
+
From debugging session (2025-10-03):
|
|
178
|
+
- 6 failures across 3 files
|
|
179
|
+
- 3 agents dispatched in parallel
|
|
180
|
+
- All investigations completed concurrently
|
|
181
|
+
- All fixes integrated successfully
|
|
182
|
+
- Zero conflicts between agent changes
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docx
|
|
3
|
+
description: "Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# DOCX creation, editing, and analysis
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
A user may ask you to create, edit, or analyze the contents of a .docx file. A .docx file is essentially a ZIP archive containing XML files and other resources that you can read or edit. You have different tools and workflows available for different tasks.
|
|
11
|
+
|
|
12
|
+
## Workflow Decision Tree
|
|
13
|
+
|
|
14
|
+
### Reading/Analyzing Content
|
|
15
|
+
Use "Text extraction" or "Raw XML access" sections below
|
|
16
|
+
|
|
17
|
+
### Creating New Document
|
|
18
|
+
Use "Creating a new Word document" workflow
|
|
19
|
+
|
|
20
|
+
### Editing Existing Document
|
|
21
|
+
- **Your own document + simple changes**
|
|
22
|
+
Use "Basic OOXML editing" workflow
|
|
23
|
+
|
|
24
|
+
- **Someone else's document**
|
|
25
|
+
Use **"Redlining workflow"** (recommended default)
|
|
26
|
+
|
|
27
|
+
- **Legal, academic, business, or government docs**
|
|
28
|
+
Use **"Redlining workflow"** (required)
|
|
29
|
+
|
|
30
|
+
## Reading and analyzing content
|
|
31
|
+
|
|
32
|
+
### Text extraction
|
|
33
|
+
If you just need to read the text contents of a document, you should convert the document to markdown using pandoc. Pandoc provides excellent support for preserving document structure and can show tracked changes:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Convert document to markdown with tracked changes
|
|
37
|
+
pandoc --track-changes=all path-to-file.docx -o output.md
|
|
38
|
+
# Options: --track-changes=accept/reject/all
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Raw XML access
|
|
42
|
+
You need raw XML access for: comments, complex formatting, document structure, embedded media, and metadata. For any of these features, you'll need to unpack a document and read its raw XML contents.
|
|
43
|
+
|
|
44
|
+
#### Unpacking a file
|
|
45
|
+
`python ooxml/scripts/unpack.py <office_file> <output_directory>`
|
|
46
|
+
|
|
47
|
+
#### Key file structures
|
|
48
|
+
* `word/document.xml` - Main document contents
|
|
49
|
+
* `word/comments.xml` - Comments referenced in document.xml
|
|
50
|
+
* `word/media/` - Embedded images and media files
|
|
51
|
+
* Tracked changes use `<w:ins>` (insertions) and `<w:del>` (deletions) tags
|
|
52
|
+
|
|
53
|
+
## Creating a new Word document
|
|
54
|
+
|
|
55
|
+
When creating a new Word document from scratch, use **docx-js**, which allows you to create Word documents using JavaScript/TypeScript.
|
|
56
|
+
|
|
57
|
+
### Workflow
|
|
58
|
+
1. **MANDATORY - READ ENTIRE FILE**: Read [`docx-js.md`](docx-js.md) (~500 lines) completely from start to finish. **NEVER set any range limits when reading this file.** Read the full file content for detailed syntax, critical formatting rules, and best practices before proceeding with document creation.
|
|
59
|
+
2. Create a JavaScript/TypeScript file using Document, Paragraph, TextRun components (You can assume all dependencies are installed, but if not, refer to the dependencies section below)
|
|
60
|
+
3. Export as .docx using Packer.toBuffer()
|
|
61
|
+
|
|
62
|
+
## Editing an existing Word document
|
|
63
|
+
|
|
64
|
+
When editing an existing Word document, use the **Document library** (a Python library for OOXML manipulation). The library automatically handles infrastructure setup and provides methods for document manipulation. For complex scenarios, you can access the underlying DOM directly through the library.
|
|
65
|
+
|
|
66
|
+
### Workflow
|
|
67
|
+
1. **MANDATORY - READ ENTIRE FILE**: Read [`ooxml.md`](ooxml.md) (~600 lines) completely from start to finish. **NEVER set any range limits when reading this file.** Read the full file content for the Document library API and XML patterns for directly editing document files.
|
|
68
|
+
2. Unpack the document: `python ooxml/scripts/unpack.py <office_file> <output_directory>`
|
|
69
|
+
3. Create and run a Python script using the Document library (see "Document Library" section in ooxml.md)
|
|
70
|
+
4. Pack the final document: `python ooxml/scripts/pack.py <input_directory> <office_file>`
|
|
71
|
+
|
|
72
|
+
The Document library provides both high-level methods for common operations and direct DOM access for complex scenarios.
|
|
73
|
+
|
|
74
|
+
## Redlining workflow for document review
|
|
75
|
+
|
|
76
|
+
This workflow allows you to plan comprehensive tracked changes using markdown before implementing them in OOXML. **CRITICAL**: For complete tracked changes, you must implement ALL changes systematically.
|
|
77
|
+
|
|
78
|
+
**Batching Strategy**: Group related changes into batches of 3-10 changes. This makes debugging manageable while maintaining efficiency. Test each batch before moving to the next.
|
|
79
|
+
|
|
80
|
+
**Principle: Minimal, Precise Edits**
|
|
81
|
+
When implementing tracked changes, only mark text that actually changes. Repeating unchanged text makes edits harder to review and appears unprofessional. Break replacements into: [unchanged text] + [deletion] + [insertion] + [unchanged text]. Preserve the original run's RSID for unchanged text by extracting the `<w:r>` element from the original and reusing it.
|
|
82
|
+
|
|
83
|
+
Example - Changing "30 days" to "60 days" in a sentence:
|
|
84
|
+
```python
|
|
85
|
+
# BAD - Replaces entire sentence
|
|
86
|
+
'<w:del><w:r><w:delText>The term is 30 days.</w:delText></w:r></w:del><w:ins><w:r><w:t>The term is 60 days.</w:t></w:r></w:ins>'
|
|
87
|
+
|
|
88
|
+
# GOOD - Only marks what changed, preserves original <w:r> for unchanged text
|
|
89
|
+
'<w:r w:rsidR="00AB12CD"><w:t>The term is </w:t></w:r><w:del><w:r><w:delText>30</w:delText></w:r></w:del><w:ins><w:r><w:t>60</w:t></w:r></w:ins><w:r w:rsidR="00AB12CD"><w:t> days.</w:t></w:r>'
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Tracked changes workflow
|
|
93
|
+
|
|
94
|
+
1. **Get markdown representation**: Convert document to markdown with tracked changes preserved:
|
|
95
|
+
```bash
|
|
96
|
+
pandoc --track-changes=all path-to-file.docx -o current.md
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
2. **Identify and group changes**: Review the document and identify ALL changes needed, organizing them into logical batches:
|
|
100
|
+
|
|
101
|
+
**Location methods** (for finding changes in XML):
|
|
102
|
+
- Section/heading numbers (e.g., "Section 3.2", "Article IV")
|
|
103
|
+
- Paragraph identifiers if numbered
|
|
104
|
+
- Grep patterns with unique surrounding text
|
|
105
|
+
- Document structure (e.g., "first paragraph", "signature block")
|
|
106
|
+
- **DO NOT use markdown line numbers** - they don't map to XML structure
|
|
107
|
+
|
|
108
|
+
**Batch organization** (group 3-10 related changes per batch):
|
|
109
|
+
- By section: "Batch 1: Section 2 amendments", "Batch 2: Section 5 updates"
|
|
110
|
+
- By type: "Batch 1: Date corrections", "Batch 2: Party name changes"
|
|
111
|
+
- By complexity: Start with simple text replacements, then tackle complex structural changes
|
|
112
|
+
- Sequential: "Batch 1: Pages 1-3", "Batch 2: Pages 4-6"
|
|
113
|
+
|
|
114
|
+
3. **Read documentation and unpack**:
|
|
115
|
+
- **MANDATORY - READ ENTIRE FILE**: Read [`ooxml.md`](ooxml.md) (~600 lines) completely from start to finish. **NEVER set any range limits when reading this file.** Pay special attention to the "Document Library" and "Tracked Change Patterns" sections.
|
|
116
|
+
- **Unpack the document**: `python ooxml/scripts/unpack.py <file.docx> <dir>`
|
|
117
|
+
- **Note the suggested RSID**: The unpack script will suggest an RSID to use for your tracked changes. Copy this RSID for use in step 4b.
|
|
118
|
+
|
|
119
|
+
4. **Implement changes in batches**: Group changes logically (by section, by type, or by proximity) and implement them together in a single script. This approach:
|
|
120
|
+
- Makes debugging easier (smaller batch = easier to isolate errors)
|
|
121
|
+
- Allows incremental progress
|
|
122
|
+
- Maintains efficiency (batch size of 3-10 changes works well)
|
|
123
|
+
|
|
124
|
+
**Suggested batch groupings:**
|
|
125
|
+
- By document section (e.g., "Section 3 changes", "Definitions", "Termination clause")
|
|
126
|
+
- By change type (e.g., "Date changes", "Party name updates", "Legal term replacements")
|
|
127
|
+
- By proximity (e.g., "Changes on pages 1-3", "Changes in first half of document")
|
|
128
|
+
|
|
129
|
+
For each batch of related changes:
|
|
130
|
+
|
|
131
|
+
**a. Map text to XML**: Grep for text in `word/document.xml` to verify how text is split across `<w:r>` elements.
|
|
132
|
+
|
|
133
|
+
**b. Create and run script**: Use `get_node` to find nodes, implement changes, then `doc.save()`. See **"Document Library"** section in ooxml.md for patterns.
|
|
134
|
+
|
|
135
|
+
**Note**: Always grep `word/document.xml` immediately before writing a script to get current line numbers and verify text content. Line numbers change after each script run.
|
|
136
|
+
|
|
137
|
+
5. **Pack the document**: After all batches are complete, convert the unpacked directory back to .docx:
|
|
138
|
+
```bash
|
|
139
|
+
python ooxml/scripts/pack.py unpacked reviewed-document.docx
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
6. **Final verification**: Do a comprehensive check of the complete document:
|
|
143
|
+
- Convert final document to markdown:
|
|
144
|
+
```bash
|
|
145
|
+
pandoc --track-changes=all reviewed-document.docx -o verification.md
|
|
146
|
+
```
|
|
147
|
+
- Verify ALL changes were applied correctly:
|
|
148
|
+
```bash
|
|
149
|
+
grep "original phrase" verification.md # Should NOT find it
|
|
150
|
+
grep "replacement phrase" verification.md # Should find it
|
|
151
|
+
```
|
|
152
|
+
- Check that no unintended changes were introduced
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
## Converting Documents to Images
|
|
156
|
+
|
|
157
|
+
To visually analyze Word documents, convert them to images using a two-step process:
|
|
158
|
+
|
|
159
|
+
1. **Convert DOCX to PDF**:
|
|
160
|
+
```bash
|
|
161
|
+
soffice --headless --convert-to pdf document.docx
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
2. **Convert PDF pages to JPEG images**:
|
|
165
|
+
```bash
|
|
166
|
+
pdftoppm -jpeg -r 150 document.pdf page
|
|
167
|
+
```
|
|
168
|
+
This creates files like `page-1.jpg`, `page-2.jpg`, etc.
|
|
169
|
+
|
|
170
|
+
Options:
|
|
171
|
+
- `-r 150`: Sets resolution to 150 DPI (adjust for quality/size balance)
|
|
172
|
+
- `-jpeg`: Output JPEG format (use `-png` for PNG if preferred)
|
|
173
|
+
- `-f N`: First page to convert (e.g., `-f 2` starts from page 2)
|
|
174
|
+
- `-l N`: Last page to convert (e.g., `-l 5` stops at page 5)
|
|
175
|
+
- `page`: Prefix for output files
|
|
176
|
+
|
|
177
|
+
Example for specific range:
|
|
178
|
+
```bash
|
|
179
|
+
pdftoppm -jpeg -r 150 -f 2 -l 5 document.pdf page # Converts only pages 2-5
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Code Style Guidelines
|
|
183
|
+
**IMPORTANT**: When generating code for DOCX operations:
|
|
184
|
+
- Write concise code
|
|
185
|
+
- Avoid verbose variable names and redundant operations
|
|
186
|
+
- Avoid unnecessary print statements
|
|
187
|
+
|
|
188
|
+
## Dependencies
|
|
189
|
+
|
|
190
|
+
Required dependencies (install if not available):
|
|
191
|
+
|
|
192
|
+
- **pandoc**: `sudo apt-get install pandoc` (for text extraction)
|
|
193
|
+
- **docx**: `npm install -g docx` (for creating new documents)
|
|
194
|
+
- **LibreOffice**: `sudo apt-get install libreoffice` (for PDF conversion)
|
|
195
|
+
- **Poppler**: `sudo apt-get install poppler-utils` (for pdftoppm to convert PDF to images)
|
|
196
|
+
- **defusedxml**: `pip install defusedxml` (for secure XML parsing)
|