dimcode-darwin-x64 0.1.0 → 0.1.2-beta.1

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.
Files changed (148) hide show
  1. package/bin/dimcode +0 -0
  2. package/bin/runtime/sandbox/dim-sandbox-runner +0 -0
  3. package/bin/runtime/sandbox/manifest.json +15 -0
  4. package/bin/skills-assets/deep-investigate/SKILL.md +101 -0
  5. package/bin/skills-assets/deep-investigate/references/prompts.md +75 -0
  6. package/bin/skills-assets/deep-investigate/references/templates.md +73 -0
  7. package/bin/skills-assets/deep-investigate/references/thinking-tools.md +36 -0
  8. package/bin/skills-assets/docs-sprint/SKILL.md +73 -0
  9. package/bin/skills-assets/docs-sprint/agents/openai.yaml +4 -0
  10. package/bin/skills-assets/docs-sprint/references/contract-discipline.md +30 -0
  11. package/bin/skills-assets/docs-sprint/references/delivery-plan.md +162 -0
  12. package/bin/skills-assets/docs-sprint/references/documentation-system.md +109 -0
  13. package/bin/skills-assets/docs-sprint/references/ui-layout.md +73 -0
  14. package/bin/skills-assets/docs-sprint/references/worktree-guide.md +45 -0
  15. package/bin/skills-assets/docx/SKILL.md +273 -0
  16. package/bin/skills-assets/docx/assets/styles/academic_styles.xml +250 -0
  17. package/bin/skills-assets/docx/assets/styles/corporate_styles.xml +284 -0
  18. package/bin/skills-assets/docx/assets/styles/default_styles.xml +449 -0
  19. package/bin/skills-assets/docx/assets/xsd/aesthetic-rules.xsd +470 -0
  20. package/bin/skills-assets/docx/assets/xsd/business-rules.xsd +130 -0
  21. package/bin/skills-assets/docx/assets/xsd/common-types.xsd +159 -0
  22. package/bin/skills-assets/docx/assets/xsd/wml-subset.xsd +589 -0
  23. package/bin/skills-assets/docx/references/cjk_typography.md +357 -0
  24. package/bin/skills-assets/docx/references/cjk_university_template_guide.md +184 -0
  25. package/bin/skills-assets/docx/references/comments_guide.md +191 -0
  26. package/bin/skills-assets/docx/references/design_good_bad_examples.md +829 -0
  27. package/bin/skills-assets/docx/references/design_principles.md +819 -0
  28. package/bin/skills-assets/docx/references/openxml_element_order.md +308 -0
  29. package/bin/skills-assets/docx/references/openxml_encyclopedia_part1.md +4061 -0
  30. package/bin/skills-assets/docx/references/openxml_encyclopedia_part2.md +2820 -0
  31. package/bin/skills-assets/docx/references/openxml_encyclopedia_part3.md +3381 -0
  32. package/bin/skills-assets/docx/references/openxml_namespaces.md +82 -0
  33. package/bin/skills-assets/docx/references/openxml_units.md +72 -0
  34. package/bin/skills-assets/docx/references/scenario_a_create.md +284 -0
  35. package/bin/skills-assets/docx/references/scenario_b_edit_content.md +295 -0
  36. package/bin/skills-assets/docx/references/scenario_c_apply_template.md +456 -0
  37. package/bin/skills-assets/docx/references/track_changes_guide.md +200 -0
  38. package/bin/skills-assets/docx/references/troubleshooting.md +506 -0
  39. package/bin/skills-assets/docx/references/typography_guide.md +294 -0
  40. package/bin/skills-assets/docx/references/xsd_validation_guide.md +158 -0
  41. package/bin/skills-assets/docx/scripts/doc_to_docx.sh +40 -0
  42. package/bin/skills-assets/docx/scripts/docx_preview.sh +37 -0
  43. package/bin/skills-assets/docx/scripts/dotnet/Docx.Cli/Docx.Cli.csproj +19 -0
  44. package/bin/skills-assets/docx/scripts/dotnet/Docx.Cli/Program.cs +18 -0
  45. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Commands/AnalyzeCommand.cs +147 -0
  46. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Commands/ApplyTemplateCommand.cs +322 -0
  47. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Commands/CreateCommand.cs +324 -0
  48. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Commands/DiffCommand.cs +155 -0
  49. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Commands/EditContentCommand.cs +487 -0
  50. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Commands/FixOrderCommand.cs +108 -0
  51. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Commands/MergeRunsCommand.cs +122 -0
  52. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Commands/ValidateCommand.cs +107 -0
  53. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Docx.Core.csproj +15 -0
  54. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/OpenXml/CommentSynchronizer.cs +169 -0
  55. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/OpenXml/ElementOrder.cs +80 -0
  56. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/OpenXml/NamespaceConstants.cs +42 -0
  57. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/OpenXml/RunMerger.cs +81 -0
  58. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/OpenXml/StyleAnalyzer.cs +81 -0
  59. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/OpenXml/TrackChangesHelper.cs +99 -0
  60. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/OpenXml/UnitConverter.cs +23 -0
  61. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/AestheticRecipeSamples.cs +1832 -0
  62. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/AestheticRecipeSamples_Batch1.cs +910 -0
  63. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/AestheticRecipeSamples_Batch2.cs +999 -0
  64. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/AestheticRecipeSamples_Batch3.cs +1048 -0
  65. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/AestheticRecipeSamples_Batch4.cs +1038 -0
  66. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/CharacterFormattingSamples.cs +1020 -0
  67. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/DocumentCreationSamples.cs +1121 -0
  68. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/FieldAndTocSamples.cs +624 -0
  69. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/FootnoteAndCommentSamples.cs +675 -0
  70. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/HeaderFooterSamples.cs +838 -0
  71. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/ImageSamples.cs +917 -0
  72. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/ListAndNumberingSamples.cs +826 -0
  73. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/ParagraphFormattingSamples.cs +1199 -0
  74. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/StyleSystemSamples.cs +1487 -0
  75. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/TableSamples.cs +1163 -0
  76. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Samples/TrackChangesSamples.cs +595 -0
  77. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Typography/CjkHelper.cs +39 -0
  78. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Typography/FontDefaults.cs +24 -0
  79. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Typography/PageSizes.cs +20 -0
  80. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Validation/BusinessRuleValidator.cs +224 -0
  81. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Validation/GateCheckValidator.cs +148 -0
  82. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Validation/ValidationResult.cs +23 -0
  83. package/bin/skills-assets/docx/scripts/dotnet/Docx.Core/Validation/XsdValidator.cs +69 -0
  84. package/bin/skills-assets/docx/scripts/dotnet/Docx.slnx +4 -0
  85. package/bin/skills-assets/docx/scripts/env_check.sh +196 -0
  86. package/bin/skills-assets/docx/scripts/setup.ps1 +274 -0
  87. package/bin/skills-assets/docx/scripts/setup.sh +504 -0
  88. package/bin/skills-assets/pdf/README.md +222 -0
  89. package/bin/skills-assets/pdf/SKILL.md +191 -0
  90. package/bin/skills-assets/pdf/design/design.md +381 -0
  91. package/bin/skills-assets/pdf/scripts/cover.py +1579 -0
  92. package/bin/skills-assets/pdf/scripts/fill_inspect.py +200 -0
  93. package/bin/skills-assets/pdf/scripts/fill_write.py +242 -0
  94. package/bin/skills-assets/pdf/scripts/make.sh +491 -0
  95. package/bin/skills-assets/pdf/scripts/merge.py +112 -0
  96. package/bin/skills-assets/pdf/scripts/palette.py +521 -0
  97. package/bin/skills-assets/pdf/scripts/reformat_parse.py +374 -0
  98. package/bin/skills-assets/pdf/scripts/render_body.py +1052 -0
  99. package/bin/skills-assets/pdf/scripts/render_cover.js +111 -0
  100. package/bin/skills-assets/pptx-generator/SKILL.md +248 -0
  101. package/bin/skills-assets/pptx-generator/references/design-system.md +392 -0
  102. package/bin/skills-assets/pptx-generator/references/editing.md +162 -0
  103. package/bin/skills-assets/pptx-generator/references/pitfalls.md +112 -0
  104. package/bin/skills-assets/pptx-generator/references/pptxgenjs.md +420 -0
  105. package/bin/skills-assets/pptx-generator/references/slide-types.md +413 -0
  106. package/bin/skills-assets/skill-creator/SKILL.md +368 -0
  107. package/bin/skills-assets/skill-creator/agents/openai.yaml +5 -0
  108. package/bin/skills-assets/skill-creator/assets/skill-creator-small.svg +3 -0
  109. package/bin/skills-assets/skill-creator/assets/skill-creator.png +0 -0
  110. package/bin/skills-assets/skill-creator/license.txt +202 -0
  111. package/bin/skills-assets/skill-creator/references/openai_yaml.md +49 -0
  112. package/bin/skills-assets/skill-creator/scripts/generate_openai_yaml.py +226 -0
  113. package/bin/skills-assets/skill-creator/scripts/init_skill.py +397 -0
  114. package/bin/skills-assets/skill-creator/scripts/quick_validate.py +101 -0
  115. package/bin/skills-assets/skill-installer/LICENSE.txt +202 -0
  116. package/bin/skills-assets/skill-installer/SKILL.md +58 -0
  117. package/bin/skills-assets/skill-installer/agents/openai.yaml +5 -0
  118. package/bin/skills-assets/skill-installer/assets/skill-installer-small.svg +3 -0
  119. package/bin/skills-assets/skill-installer/assets/skill-installer.png +0 -0
  120. package/bin/skills-assets/skill-installer/scripts/github_utils.py +21 -0
  121. package/bin/skills-assets/skill-installer/scripts/install-skill-from-github.py +308 -0
  122. package/bin/skills-assets/skill-installer/scripts/list-skills.py +107 -0
  123. package/bin/skills-assets/xlsx/SKILL.md +137 -0
  124. package/bin/skills-assets/xlsx/references/create.md +691 -0
  125. package/bin/skills-assets/xlsx/references/edit.md +684 -0
  126. package/bin/skills-assets/xlsx/references/fix.md +37 -0
  127. package/bin/skills-assets/xlsx/references/format.md +768 -0
  128. package/bin/skills-assets/xlsx/references/ooxml-cheatsheet.md +231 -0
  129. package/bin/skills-assets/xlsx/references/read-analyze.md +97 -0
  130. package/bin/skills-assets/xlsx/references/validate.md +772 -0
  131. package/bin/skills-assets/xlsx/scripts/formula_check.py +422 -0
  132. package/bin/skills-assets/xlsx/scripts/libreoffice_recalc.py +248 -0
  133. package/bin/skills-assets/xlsx/scripts/shared_strings_builder.py +163 -0
  134. package/bin/skills-assets/xlsx/scripts/style_audit.py +575 -0
  135. package/bin/skills-assets/xlsx/scripts/xlsx_add_column.py +395 -0
  136. package/bin/skills-assets/xlsx/scripts/xlsx_insert_row.py +274 -0
  137. package/bin/skills-assets/xlsx/scripts/xlsx_pack.py +87 -0
  138. package/bin/skills-assets/xlsx/scripts/xlsx_reader.py +362 -0
  139. package/bin/skills-assets/xlsx/scripts/xlsx_shift_rows.py +396 -0
  140. package/bin/skills-assets/xlsx/scripts/xlsx_unpack.py +130 -0
  141. package/bin/skills-assets/xlsx/templates/minimal_xlsx/[Content_Types].xml +9 -0
  142. package/bin/skills-assets/xlsx/templates/minimal_xlsx/_rels/.rels +6 -0
  143. package/bin/skills-assets/xlsx/templates/minimal_xlsx/xl/_rels/workbook.xml.rels +19 -0
  144. package/bin/skills-assets/xlsx/templates/minimal_xlsx/xl/sharedStrings.xml +33 -0
  145. package/bin/skills-assets/xlsx/templates/minimal_xlsx/xl/styles.xml +160 -0
  146. package/bin/skills-assets/xlsx/templates/minimal_xlsx/xl/workbook.xml +30 -0
  147. package/bin/skills-assets/xlsx/templates/minimal_xlsx/xl/worksheets/sheet1.xml +70 -0
  148. package/package.json +1 -1
@@ -0,0 +1,109 @@
1
+ # Documentation System
2
+
3
+ ## Directory Model
4
+
5
+ ```text
6
+ docs/
7
+ ├─ INDEX.md # documentation entry point (required)
8
+ ├─ plan/ # delivery workflow (required, owned by this skill)
9
+ │ ├─ README.md
10
+ │ ├─ analysis/
11
+ │ ├─ tasks/
12
+ │ └─ backlog.md
13
+ ├─ {scope}/ # design docs, organized by project's own scoping
14
+ │ ├─ README.md
15
+ │ └─ {module}/ or {module}.md
16
+ └─ issues/ # optional, for tracking inconsistencies and design gaps
17
+ └─ archived/
18
+ ```
19
+
20
+ | Directory | Required | Owner | Purpose |
21
+ |---|---|---|---|
22
+ | `docs/INDEX.md` | yes | project | Documentation entry point. Links to all design doc areas |
23
+ | `docs/plan/` | yes | this skill | Delivery plan: analysis, tasks, backlog. See [delivery-plan.md](delivery-plan.md) |
24
+ | `docs/{scope}/` | yes | project | Design docs. Scope is defined by the project — package, feature area, service, etc. |
25
+ | `docs/issues/` | no | project | Issue tracking when the project uses file-based issues |
26
+
27
+ `{scope}` is whatever grouping the project uses for its design docs. A monorepo might use `docs/packages/{pkg}/`. A single-package project might use `docs/modules/` or `docs/features/`. The skill does not prescribe the scoping — it only requires that design docs exist and are reachable from `INDEX.md`.
28
+
29
+ ## Scope README Contract
30
+
31
+ Each scope has a README that answers relationship and ownership questions.
32
+
33
+ Required coverage:
34
+
35
+ - Purpose and boundary.
36
+ - Relationship to other scopes.
37
+ - Main concepts and one-line definitions.
38
+ - Ownership: who creates whom, who calls whom, who stores state.
39
+ - Lifecycle and state ownership.
40
+ - Public API surface or entry points.
41
+ - Design decisions that affect multiple modules.
42
+ - Module index linking to child docs.
43
+ - Scope-wide constraints.
44
+
45
+ Use diagrams for structure and flow.
46
+
47
+ ## Module Doc Contract
48
+
49
+ Module docs cover local contracts. Cross-module collaboration belongs in the parent scope README.
50
+
51
+ | Section | Content |
52
+ |---|---|
53
+ | Purpose | What the module owns |
54
+ | Boundary | What it handles and what it delegates |
55
+ | Types | Inputs, outputs, optional/nullable fields, invariants |
56
+ | API | Function/method contracts and return types |
57
+ | State | State ownership, persistence, mutation path |
58
+ | Errors | Typed errors and thrown conditions |
59
+ | Extension points | Hooks, adapters, plugin points, injected dependencies |
60
+ | Tests | Required contract and error tests |
61
+
62
+ ## Maintenance Rules
63
+
64
+ Docs are the source of truth for contracts. Code follows docs, not the other way around.
65
+
66
+ ### When to create
67
+
68
+ - Before implementation. A task's `context` field points to design docs that must exist before development starts.
69
+ - When a new scope, module, or capability is introduced.
70
+
71
+ ### When to update
72
+
73
+ - When a task changes the contract defined in a design doc, the same task updates the doc. Doc changes and code changes are one atomic delivery.
74
+ - When verify finds a mismatch between docs and code, the fix updates whichever is wrong — not just the code.
75
+
76
+ ### Task path includes docs
77
+
78
+ A task's `path` field lists both code paths and doc paths it touches. This ensures overlap detection accounts for doc changes — two tasks modifying the same design doc cannot run in parallel.
79
+
80
+ ### Staleness prevention
81
+
82
+ - Verify checks docs-code consistency: if code diverges from the design doc referenced in `context`, it is a blocking finding.
83
+ - `INDEX.md` must stay current. When a new scope or doc is added, `INDEX.md` is updated in the same task.
84
+ - Orphaned docs (docs that describe removed code) are deleted or archived when discovered.
85
+
86
+ ## Single Source of Truth
87
+
88
+ - Each rule or process lives in exactly one location.
89
+ - Cross-module flows go in the parent scope README.
90
+ - Local API details go in module docs.
91
+ - Implementation tasks go in `docs/plan/tasks/`.
92
+ - Non-blocking findings go in `docs/plan/backlog.md` or `docs/issues/`.
93
+ - Reference existing docs instead of repeating rules.
94
+
95
+ ## Writing Style
96
+
97
+ - Direct, concrete statements.
98
+ - Tables and ASCII diagrams for relationships.
99
+ - Define only terms that reduce ambiguity.
100
+ - Stable, searchable headings.
101
+ - English for code identifiers, package names, API names, type names, and commit messages.
102
+
103
+ ## Issues
104
+
105
+ When the project uses `docs/issues/`:
106
+
107
+ - New issues: `状态:待处理`.
108
+ - Fixed issues: `状态:已修复`, then move to `docs/issues/archived/`.
109
+ - One issue per file, focused on a single inconsistency, bug, or design gap.
@@ -0,0 +1,73 @@
1
+ # UI Layout Documentation
2
+
3
+ ## Scope
4
+
5
+ Use this reference when documenting UI layouts and interactions — web, mobile, desktop, or terminal.
6
+
7
+ UI layout docs describe user-visible contracts: what regions exist, how they are arranged, how users reach each function, how input behaves, and how loading/empty/error states display.
8
+
9
+ ## Layout Doc Template
10
+
11
+ Use this structure when it fits. Shorter files may omit empty sections.
12
+
13
+ ```markdown
14
+ # {Feature} Layout
15
+
16
+ Status: Draft
17
+
18
+ ## Design Principles
19
+ ## Overall Structure
20
+ ## Page-Level Layout
21
+ ## Region Layout
22
+ ## Interactions
23
+ ## State Variants
24
+ ## Responsive / Size Constraints
25
+ ## Component Tree
26
+ ## Page Entry Points
27
+ ```
28
+
29
+ Each layout file focuses on one page, shell, dialog family, or component group.
30
+
31
+ ## Visual Layout Rules
32
+
33
+ Use ASCII art or diagrams for every meaningful layout.
34
+
35
+ ```text
36
+ ┌──────────────────────────────────────┐
37
+ │ Header │
38
+ ├──────────────────────────────────────┤
39
+ │ Main content area │
40
+ ├──────────────────────────────────────┤
41
+ │ Footer / status bar │
42
+ └──────────────────────────────────────┘
43
+ ```
44
+
45
+ Include:
46
+
47
+ - Region names.
48
+ - Conditional regions (shown/hidden by state).
49
+ - Dialog and overlay layering.
50
+ - Focus target when relevant.
51
+ - Responsive behavior for size constraints.
52
+
53
+ ## Interaction Contract
54
+
55
+ Document input behavior in tables:
56
+
57
+ | Input | Scope | Behavior |
58
+ |---|---|---|
59
+ | `Enter` | Input area | submit |
60
+ | `Esc` | Dialog | close |
61
+ | `Tab` | Form | next field |
62
+
63
+ For dialogs, document: open/close trigger, focus movement, selection behavior, empty state, error state, apply/cancel behavior.
64
+
65
+ ## State Variants
66
+
67
+ Document these states for each region when applicable:
68
+
69
+ - **Loading**: what the user sees while data is being fetched.
70
+ - **Empty**: what the user sees when there is no content.
71
+ - **Error**: what the user sees on failure, and how to recover.
72
+ - **Busy**: what the user sees during a long-running operation.
73
+ - **Constrained**: how the layout adapts to limited screen/window size.
@@ -0,0 +1,45 @@
1
+ # Worktree Guide
2
+
3
+ Parallel task execution via git worktrees.
4
+
5
+ ## Convention
6
+
7
+ - Directory: `.worktrees/<task-id>/`
8
+ - Branch: `task/<task-id>`
9
+ - Base: determine the correct base branch before creating. Check which branch the current delivery targets (main, a feature branch, a release branch, etc.) and verify it is up to date. A stale or wrong base causes the agent to work against an outdated snapshot, and its merge can silently revert other tasks' work.
10
+ - Create: `git worktree add .worktrees/<task-id> -b task/<task-id> <base>`
11
+ - Remove: `git worktree remove .worktrees/<task-id>`
12
+
13
+ ## Workflow
14
+
15
+ 1. Check execution mode from the delivery plan (path overlap, dependency chain).
16
+ 2. For parallel tasks, create the worktree before dispatching. Pass the worktree path as the sub-agent's cwd.
17
+ 3. Verify agent uses the same worktree as its develop agent.
18
+ 4. Sub-agent works in its cwd as normal — it does not need to know it is in a worktree.
19
+ 5. After merge, remove the worktree. For abandoned tasks, force remove and delete the branch.
20
+
21
+ ## Rules
22
+
23
+ - Only the orchestrator creates and removes worktrees. Sub-agents never manage worktrees.
24
+ - Sub-agents operate only within their own cwd. Never touch other worktrees or the main working directory.
25
+ - Serial tasks use the main working directory — no worktree needed.
26
+
27
+ ## Cleanup
28
+
29
+ | Trigger | Action |
30
+ |---|---|
31
+ | Task merged to base | `git worktree remove .worktrees/<task-id>` then `git branch -d task/<task-id>` |
32
+ | Task abandoned | `git worktree remove --force .worktrees/<task-id>` then `git branch -D task/<task-id>` |
33
+ | Sprint end or session start | Run `git worktree list`, cross-check against task statuses, remove all worktrees whose task is `done` or no longer exists |
34
+
35
+ Orchestrator is responsible for cleanup. Do not leave worktrees accumulating — clean up immediately after merge or abandonment. On session resume, always run a sweep before creating new worktrees.
36
+
37
+ ## Recovery
38
+
39
+ See delivery-plan.md Recovery for task-level state→action mapping. For worktree-specific issues:
40
+
41
+ | Observed state | Action |
42
+ |---|---|
43
+ | Worktree exists but branch is missing | Force remove worktree, reset task to `ready` |
44
+ | Worktree has `.git/worktrees/<id>/locked` | Unlock with `git worktree unlock`, then decide based on task status |
45
+ | Worktree exists for a `done` task | Remove worktree and delete branch (merge cleanup was interrupted) |
@@ -0,0 +1,273 @@
1
+ ---
2
+ name: docx
3
+ metadata:
4
+ version: "1.0.0"
5
+ category: document-processing
6
+ author: DimCode
7
+ sources:
8
+ - "ECMA-376 Office Open XML File Formats"
9
+ - "GB/T 9704-2012 Layout Standard for Official Documents"
10
+ - "IEEE / ACM / APA / MLA / Chicago / Turabian Style Guides"
11
+ - "Springer LNCS / Nature / HBR Document Templates"
12
+ description: >
13
+ Professional DOCX document creation, editing, and formatting using OpenXML SDK (.NET).
14
+ Three pipelines: (A) create new documents from scratch, (B) fill/edit content in existing
15
+ documents, (C) apply template formatting with XSD validation gate-check.
16
+ MUST use this skill whenever the user wants to produce, modify, or format a Word document —
17
+ including when they say "write a report", "draft a proposal", "make a contract",
18
+ "fill in this form", "reformat to match this template", or any task whose final output
19
+ is a .docx file. Even if the user doesn't mention "docx" explicitly, if the task
20
+ implies a printable/formal document, use this skill.
21
+ triggers:
22
+ - Word
23
+ - docx
24
+ - document
25
+ - 文档
26
+ - Word文档
27
+ - 报告
28
+ - 合同
29
+ - 公文
30
+ - 排版
31
+ - 套模板
32
+ ---
33
+
34
+ # docx
35
+
36
+ Create, edit, and format DOCX documents via CLI tools or direct C# scripts built on OpenXML SDK (.NET).
37
+
38
+ ## Setup
39
+
40
+ **First time:** `bash scripts/setup.sh` (or `powershell scripts/setup.ps1` on Windows, `--minimal` to skip optional deps).
41
+
42
+ **First operation in session:** `scripts/env_check.sh` — do not proceed if `NOT READY`. (Skip on subsequent operations within the same session.)
43
+
44
+ ## Quick Start: Direct C# Path
45
+
46
+ When the task requires structural document manipulation (custom styles, complex tables, multi-section layouts, headers/footers, TOC, images), write C# directly instead of wrestling with CLI limitations. Use this scaffold:
47
+
48
+ ```csharp
49
+ // File: scripts/dotnet/task.csx (or a new .cs in a Console project)
50
+ // dotnet run --project scripts/dotnet/Docx.Cli -- run-script task.csx
51
+ #r "nuget: DocumentFormat.OpenXml, 3.2.0"
52
+
53
+ using DocumentFormat.OpenXml;
54
+ using DocumentFormat.OpenXml.Packaging;
55
+ using DocumentFormat.OpenXml.Wordprocessing;
56
+
57
+ using var doc = WordprocessingDocument.Create("output.docx", WordprocessingDocumentType.Document);
58
+ var mainPart = doc.AddMainDocumentPart();
59
+ mainPart.Document = new Document(new Body());
60
+
61
+ // --- Your logic here ---
62
+ // Read the relevant Samples/*.cs file FIRST for tested patterns.
63
+ // See Samples/ table in References section below.
64
+ ```
65
+
66
+ **Before writing any C#, read the relevant `Samples/*.cs` file** — they contain compilable, SDK-version-verified patterns. The Samples table in the References section below maps topics to files.
67
+
68
+ ## CLI shorthand
69
+
70
+ All CLI commands below use `$CLI` as shorthand for:
71
+ ```bash
72
+ dotnet run --project scripts/dotnet/Docx.Cli --
73
+ ```
74
+
75
+ ## Pipeline routing
76
+
77
+ Route by checking: does the user have an input .docx file?
78
+
79
+ ```
80
+ User task
81
+ ├─ No input file → Pipeline A: CREATE
82
+ │ signals: "write", "create", "draft", "generate", "new", "make a report/proposal/memo"
83
+ │ → Read references/scenario_a_create.md
84
+
85
+ └─ Has input .docx
86
+ ├─ Replace/fill/modify content → Pipeline B: FILL-EDIT
87
+ │ signals: "fill in", "replace", "update", "change text", "add section", "edit"
88
+ │ → Read references/scenario_b_edit_content.md
89
+
90
+ └─ Reformat/apply style/template → Pipeline C: FORMAT-APPLY
91
+ signals: "reformat", "apply template", "restyle", "match this format", "套模板", "排版"
92
+ ├─ Template is pure style (no content) → C-1: OVERLAY (apply styles to source)
93
+ └─ Template has structure (cover/TOC/example sections) → C-2: BASE-REPLACE
94
+ (use template as base, replace example content with user content)
95
+ → Read references/scenario_c_apply_template.md
96
+ ```
97
+
98
+ If the request spans multiple pipelines, run them sequentially (e.g., Create then Format-Apply).
99
+
100
+ ## Pre-processing
101
+
102
+ Convert `.doc` → `.docx` if needed: `scripts/doc_to_docx.sh input.doc output_dir/`
103
+
104
+ Preview before editing (avoids reading raw XML): `scripts/docx_preview.sh document.docx`
105
+
106
+ Analyze structure for editing scenarios: `$CLI analyze --input document.docx`
107
+
108
+ ## Scenario A: Create
109
+
110
+ Read `references/scenario_a_create.md`, `references/typography_guide.md`, and `references/design_principles.md` first. Pick an aesthetic recipe from `Samples/AestheticRecipeSamples.cs` that matches the document type — do not invent formatting values. For CJK, also read `references/cjk_typography.md`.
111
+
112
+ **Choose your path:**
113
+ - **Simple** (plain text, minimal formatting): use CLI — `$CLI create --type report --output out.docx --config content.json`
114
+ - **Structural** (custom styles, multi-section, TOC, images, complex tables): write C# directly. Read the relevant `Samples/*.cs` first.
115
+
116
+ CLI options: `--type` (report|letter|memo|academic), `--title`, `--author`, `--page-size` (letter|a4|legal|a3), `--margins` (standard|narrow|wide), `--header`, `--footer`, `--page-numbers`, `--toc`, `--content-json`.
117
+
118
+ Then run the **validation pipeline** (below).
119
+
120
+ ## Scenario B: Edit / Fill
121
+
122
+ Read `references/scenario_b_edit_content.md` first. Preview → analyze → edit → validate.
123
+
124
+ **Choose your path:**
125
+ - **Simple** (text replacement, placeholder fill): use CLI subcommands.
126
+ - **Structural** (add/reorganize sections, modify styles, manipulate tables, insert images): write C# directly. Read `references/openxml_element_order.md` and the relevant `Samples/*.cs`.
127
+
128
+ Available CLI edit subcommands:
129
+ - `replace-text --find "X" --replace "Y"`
130
+ - `fill-placeholders --data '{"key":"value"}'`
131
+ - `fill-table --data table.json`
132
+ - `insert-section`, `remove-section`, `update-header-footer`
133
+
134
+ ```bash
135
+ $CLI edit replace-text --input in.docx --output out.docx --find "OLD" --replace "NEW"
136
+ $CLI edit fill-placeholders --input in.docx --output out.docx --data '{"name":"John"}'
137
+ ```
138
+
139
+ Then run the **validation pipeline**. Also run diff to verify minimal changes:
140
+ ```bash
141
+ $CLI diff --before in.docx --after out.docx
142
+ ```
143
+
144
+ ## Scenario C: Apply Template
145
+
146
+ Read `references/scenario_c_apply_template.md` first. Preview and analyze both source and template.
147
+
148
+ ```bash
149
+ $CLI apply-template --input source.docx --template template.docx --output out.docx
150
+ ```
151
+
152
+ For complex template operations (multi-template merge, per-section headers/footers, style merging), write C# directly — see Critical Rules below for required patterns.
153
+
154
+ Run the **validation pipeline**, then the **hard gate-check**:
155
+ ```bash
156
+ $CLI validate --input out.docx --gate-check assets/xsd/business-rules.xsd
157
+ ```
158
+ Gate-check is a **hard requirement**. Do NOT deliver until it passes. If it fails: diagnose, fix, re-run.
159
+
160
+ Also diff to verify content preservation: `$CLI diff --before source.docx --after out.docx`
161
+
162
+ ## Validation pipeline
163
+
164
+ Run after every write operation. For Scenario C the full pipeline is **mandatory**; for A/B it is **recommended** (skip only if the operation was trivially simple).
165
+
166
+ ```bash
167
+ $CLI merge-runs --input doc.docx # 1. consolidate runs
168
+ $CLI validate --input doc.docx --xsd assets/xsd/wml-subset.xsd # 2. XSD structure
169
+ $CLI validate --input doc.docx --business # 3. business rules
170
+ ```
171
+
172
+ If XSD fails, auto-repair and retry:
173
+ ```bash
174
+ $CLI fix-order --input doc.docx
175
+ $CLI validate --input doc.docx --xsd assets/xsd/wml-subset.xsd
176
+ ```
177
+
178
+ If XSD still fails, fall back to business rules + preview:
179
+ ```bash
180
+ $CLI validate --input doc.docx --business
181
+ scripts/docx_preview.sh doc.docx
182
+ # Verify: font contamination=0, table count correct, drawing count correct, sectPr count correct
183
+ ```
184
+
185
+ Final preview: `scripts/docx_preview.sh doc.docx`
186
+
187
+ ## Critical rules
188
+
189
+ These prevent file corruption — OpenXML is strict about element ordering.
190
+
191
+ **Element order** (properties always first):
192
+
193
+ | Parent | Order |
194
+ |--------|-------|
195
+ | `w:p` | `pPr` → runs |
196
+ | `w:r` | `rPr` → `t`/`br`/`tab` |
197
+ | `w:tbl`| `tblPr` → `tblGrid` → `tr` |
198
+ | `w:tr` | `trPr` → `tc` |
199
+ | `w:tc` | `tcPr` → `p` (min 1 `<w:p/>`) |
200
+ | `w:body` | block content → `sectPr` (LAST child) |
201
+
202
+ **Direct format contamination:** When copying content from a source document, inline `rPr` (fonts, color) and `pPr` (borders, shading, spacing) override template styles. Always strip direct formatting — keep only `pStyle` reference and `t` text. Clean tables too (including `pPr/rPr` inside cells).
203
+
204
+ **Track changes:** `<w:del>` uses `<w:delText>`, never `<w:t>`. `<w:ins>` uses `<w:t>`, never `<w:delText>`.
205
+
206
+ **Font size:** `w:sz` = points × 2 (12pt → `sz="24"`). Margins/spacing in DXA (1 inch = 1440, 1cm ≈ 567).
207
+
208
+ **Heading styles MUST have OutlineLevel:** When defining heading styles (Heading1, ThesisH1, etc.), always include `new OutlineLevel { Val = N }` in `StyleParagraphProperties` (H1→0, H2→1, H3→2). Without this, Word sees them as plain styled text — TOC and navigation pane won't work.
209
+
210
+ **Multi-template merge:** When given multiple template files (font, heading, breaks), read `references/scenario_c_apply_template.md` section "Multi-Template Merge" FIRST. Key rules:
211
+ - Merge styles from all templates into one styles.xml. Structure (sections/breaks) comes from the breaks template.
212
+ - Each content paragraph must appear exactly ONCE — never duplicate when inserting section breaks.
213
+ - NEVER insert empty/blank paragraphs as padding or section separators. Output paragraph count must equal input. Use section break properties (`w:sectPr` inside `w:pPr`) and style spacing (`w:spacing` before/after) for visual separation.
214
+ - Insert oddPage section breaks before EVERY chapter heading, not just the first. Even if a chapter has dual-column content, it MUST start with oddPage; use a second continuous break after the heading for column switching.
215
+ - Dual-column chapters need THREE section breaks: (1) oddPage in preceding para's pPr, (2) continuous+cols=2 in the chapter HEADING's pPr, (3) continuous+cols=1 in the last body para's pPr to revert.
216
+ - Copy `titlePg` settings from the breaks template for EACH section. Abstract and TOC sections typically need `titlePg=true`.
217
+
218
+ **Multi-section headers/footers:** Templates with 10+ sections (e.g., Chinese thesis) have DIFFERENT headers/footers per section (Roman vs Arabic page numbers, different header text per zone). Rules:
219
+ - Use C-2 Base-Replace: copy the TEMPLATE as output base, then replace body content. This preserves all sections, headers, footers, and titlePg settings automatically.
220
+ - NEVER recreate headers/footers from scratch — copy template header/footer XML byte-for-byte.
221
+ - NEVER add formatting (borders, alignment, font size) not present in the template header XML.
222
+ - Non-cover sections MUST have header/footer XML files (at least empty header + page number footer).
223
+ - See `references/scenario_c_apply_template.md` section "Multi-Section Header/Footer Transfer".
224
+
225
+ ## References
226
+
227
+ Load as needed — don't load all at once. Pick the most relevant files for the task.
228
+
229
+ **The C# samples and design references below are the project's knowledge base ("encyclopedia").** When writing OpenXML code, ALWAYS read the relevant sample file first — it contains compilable, SDK-version-verified patterns that prevent common errors. When making aesthetic decisions, read the design principles and recipe files — they encode tested, harmonious parameter sets from authoritative sources (IEEE, ACM, APA, Nature, etc.), not guesses.
230
+
231
+ ### Scenario guides (read first for each pipeline)
232
+
233
+ | File | When |
234
+ |------|------|
235
+ | `references/scenario_a_create.md` | Pipeline A: creating from scratch |
236
+ | `references/scenario_b_edit_content.md` | Pipeline B: editing existing content |
237
+ | `references/scenario_c_apply_template.md` | Pipeline C: applying template formatting |
238
+
239
+ ### C# code samples (compilable, heavily commented — read when writing code)
240
+
241
+ | File | Topic |
242
+ |------|-------|
243
+ | `Samples/DocumentCreationSamples.cs` | Document lifecycle: create, open, save, streams, doc defaults, settings, properties, page setup, multi-section |
244
+ | `Samples/StyleSystemSamples.cs` | Styles: Normal/Heading chain, character/table/list styles, DocDefaults, latentStyles, CJK 公文, APA 7th, import, resolve inheritance |
245
+ | `Samples/CharacterFormattingSamples.cs` | RunProperties: fonts, size, bold/italic, all underlines, color, highlight, strike, sub/super, caps, spacing, shading, border, emphasis marks |
246
+ | `Samples/ParagraphFormattingSamples.cs` | ParagraphProperties: justification, indentation, line/paragraph spacing, keep/widow, outline level, borders, tabs, numbering, bidi, frame |
247
+ | `Samples/TableSamples.cs` | Tables: borders, grid, cell props, margins, row height, header repeat, merge (H+V), nested, floating, three-line 三线表, zebra striping |
248
+ | `Samples/HeaderFooterSamples.cs` | Headers/footers: page numbers, "Page X of Y", first/even/odd, logo image, table layout, 公文 "-X-", per-section |
249
+ | `Samples/ImageSamples.cs` | Images: inline, floating, text wrapping, border, alt text, in header/table, replace, SVG fallback, dimension calc |
250
+ | `Samples/ListAndNumberingSamples.cs` | Numbering: bullets, multi-level decimal, custom symbols, outline→headings, legal, Chinese 一/(一)/1./(1), restart/continue |
251
+ | `Samples/FieldAndTocSamples.cs` | Fields: TOC, SimpleField vs complex field, DATE/PAGE/REF/SEQ/MERGEFIELD/IF/STYLEREF, TOC styles |
252
+ | `Samples/FootnoteAndCommentSamples.cs` | Footnotes, endnotes, comments (4-file system), bookmarks, hyperlinks (internal + external) |
253
+ | `Samples/TrackChangesSamples.cs` | Revisions: insertions (w:t), deletions (w:delText!), formatting changes, accept/reject all, move tracking |
254
+ | `Samples/AestheticRecipeSamples.cs` | 13 aesthetic recipes from authoritative sources: ModernCorporate, AcademicThesis, ExecutiveBrief, ChineseGovernment (GB/T 9704), MinimalModern, IEEE Conference, ACM sigconf, APA 7th, MLA 9th, Chicago/Turabian, Springer LNCS, Nature, HBR — each with exact values from official style guides |
255
+
256
+ Note: `Samples/` path is relative to `scripts/dotnet/Docx.Core/`.
257
+
258
+ ### Markdown references (read when you need specifications or design rules)
259
+
260
+ | File | When |
261
+ |------|------|
262
+ | `references/openxml_element_order.md` | XML element ordering rules (prevents corruption) |
263
+ | `references/openxml_units.md` | Unit conversion: DXA, EMU, half-points, eighth-points |
264
+ | `references/openxml_encyclopedia_part1.md` | Detailed C# encyclopedia: document creation, styles, character & paragraph formatting |
265
+ | `references/openxml_encyclopedia_part2.md` | Detailed C# encyclopedia: page setup, tables, headers/footers, sections, doc properties |
266
+ | `references/openxml_encyclopedia_part3.md` | Detailed C# encyclopedia: TOC, footnotes, fields, track changes, comments, images, math, numbering, protection |
267
+ | `references/typography_guide.md` | Font pairing, sizes, spacing, page layout, table design, color schemes |
268
+ | `references/cjk_typography.md` | CJK fonts, 字号 sizes, RunFonts mapping, GB/T 9704 公文 standard |
269
+ | `references/cjk_university_template_guide.md` | Chinese university thesis templates: numeric styleIds (1/2/3 vs Heading1), document zone structure (cover→abstract→TOC→body→references), font expectations, common mistakes |
270
+ | `references/design_principles.md` | **Aesthetic foundations**: 6 design principles (white space, contrast/scale, proximity, alignment, repetition, hierarchy) — teaches WHY, not just WHAT |
271
+ | `references/design_good_bad_examples.md` | **Good vs Bad comparisons**: 10 categories of typography mistakes with OpenXML values, ASCII mockups, and fixes |
272
+ | `references/track_changes_guide.md` | Revision marks deep dive |
273
+ | `references/troubleshooting.md` | **Symptom-driven fixes**: 13 common problems indexed by what you SEE (headings wrong, images missing, TOC broken, etc.) — search by symptom, find the fix |