xuanzhu 0.1.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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +424 -0
  3. package/bin/xzh.js +3 -0
  4. package/dist/cli.js +5602 -0
  5. package/dist/cli.js.map +7 -0
  6. package/dist/skills/aws/SKILL.md +70 -0
  7. package/dist/skills/datadog/SKILL.md +261 -0
  8. package/dist/skills/elasticsearch/SKILL.md +88 -0
  9. package/dist/skills/elasticsearch/install.sh +91 -0
  10. package/dist/skills/email/SKILL.md +63 -0
  11. package/dist/skills/github/SKILL.md +69 -0
  12. package/dist/skills/gitlab/SKILL.md +68 -0
  13. package/dist/skills/gitlab/install.sh +74 -0
  14. package/dist/skills/gmail/README.md +139 -0
  15. package/dist/skills/gmail/SECURITY.md +552 -0
  16. package/dist/skills/gmail/SETUP.md +258 -0
  17. package/dist/skills/gmail/activate-gmail-cli.sh +15 -0
  18. package/dist/skills/gmail/generate-hashes.sh +82 -0
  19. package/dist/skills/gmail/gmail-cli-secure.py +599 -0
  20. package/dist/skills/gmail/install.sh +313 -0
  21. package/dist/skills/gmail/requirements.txt +38 -0
  22. package/dist/skills/gmail/skill.md +225 -0
  23. package/dist/skills/jira/SKILL.md +68 -0
  24. package/dist/skills/kubernetes/SKILL.md +70 -0
  25. package/dist/skills/linear/SKILL.md +48 -0
  26. package/dist/skills/mongodb/SKILL.md +53 -0
  27. package/dist/skills/mysql/SKILL.md +71 -0
  28. package/dist/skills/mysql/install.sh +74 -0
  29. package/dist/skills/officecli/SKILL.md +429 -0
  30. package/dist/skills/playwright/SKILL.md +171 -0
  31. package/dist/skills/postgres/SKILL.md +44 -0
  32. package/dist/skills/postgres/install.sh +73 -0
  33. package/dist/skills/redis/SKILL.md +58 -0
  34. package/dist/skills/redis/install.sh +39 -0
  35. package/dist/skills/sentry/SKILL.md +59 -0
  36. package/dist/skills/telegram/SKILL.md +151 -0
  37. package/package.json +46 -0
@@ -0,0 +1,429 @@
1
+ ---
2
+ name: officecli
3
+ description: Create, analyze, proofread, and modify Office documents (.docx, .xlsx, .pptx) using the officecli CLI tool. Use when the user wants to create, inspect, check formatting, find issues, add charts, or modify Office documents.
4
+ metadata:
5
+ displayName: OfficeCLI
6
+ icon: file-text
7
+ category: document
8
+ version: 1.0.0
9
+ dependencies:
10
+ cli: officecli
11
+ checkCommand: officecli --version
12
+ install:
13
+ linux: curl -fsSL https://d.officecli.ai/install.sh | bash
14
+ darwin: curl -fsSL https://d.officecli.ai/install.sh | bash
15
+ windows: irm https://d.officecli.ai/install.ps1 | iex
16
+ ---
17
+
18
+ # officecli
19
+
20
+ AI-friendly CLI for .docx, .xlsx, .pptx. Single binary, no dependencies, no Office installation needed.
21
+
22
+ ## Install
23
+
24
+ If `officecli` is not installed:
25
+
26
+ ```bash
27
+ # macOS / Linux
28
+ curl -fsSL https://d.officecli.ai/install.sh | bash
29
+
30
+ # Windows (PowerShell)
31
+ irm https://d.officecli.ai/install.ps1 | iex
32
+ ```
33
+
34
+ Verify with `officecli --version`. If still not found after install, open a new terminal.
35
+
36
+ ---
37
+
38
+ ## Strategy
39
+
40
+ **L1 (read) → L2 (DOM edit) → L3 (raw XML)**. Always prefer higher layers. Add `--json` for structured output.
41
+
42
+ **Before doc work, check Specialized Skills** (bottom of this file). Fundraising decks, academic papers, financial models, dashboards, and Morph animations need their own skill loaded first — `load_skill` once, then proceed.
43
+
44
+ ---
45
+
46
+ ## Help System (IMPORTANT)
47
+
48
+ **When unsure about property names, value formats, or command syntax, ALWAYS run help instead of guessing.** One help query beats guess-fail-retry loops.
49
+
50
+ `officecli help` ≡ `officecli --help`, and `officecli <cmd> --help` ≡ `officecli help <cmd>` — same content.
51
+
52
+ ```bash
53
+ officecli help # All commands + global options + schema entry points
54
+ officecli help docx # List all docx elements
55
+ officecli help docx paragraph # Full schema: properties, aliases, examples, readbacks
56
+ officecli help docx set paragraph # Verb-filtered: only props usable with `set`
57
+ officecli help docx paragraph --json # Structured schema (machine-readable)
58
+ ```
59
+
60
+ Format aliases: `word`→`docx`, `excel`→`xlsx`, `ppt`/`powerpoint`→`pptx`. Verbs: `add`, `set`, `get`, `query`, `remove`. MCP exposes the same schema via the single `command` string param: `{"command":"help docx paragraph"}` (not a structured `{"format":...,"type":...}` object — the MCP tool has exactly one param, `command`, and passes it through to the CLI verbatim).
61
+
62
+ ---
63
+
64
+ ## Performance: Resident Mode
65
+
66
+ **Every command auto-starts a resident on first access** (60s idle timeout) — file-lock conflicts are automatically avoided. Explicit `open`/`close` is still recommended for longer sessions (12min idle):
67
+ ```bash
68
+ officecli open report.docx # explicitly keep in memory
69
+ officecli set report.docx ... # no file I/O overhead
70
+ officecli close report.docx # save and release
71
+ ```
72
+
73
+ Opt out of auto-start: `OFFICECLI_NO_AUTO_RESIDENT=1`.
74
+
75
+ **Flush only at the non-officecli boundary.** officecli's own reads (`get`/`query`/`view`/`dump`) always see your latest edits, so you never need to save mid-workflow. Run `save` (keeps the resident) or `close` (flush + release) only **before a non-officecli program reads the file** — python-docx/openpyxl, Word, a renderer, delivery/upload. (Idle sessions auto-flush within seconds; `OFFICECLI_RESIDENT_FLUSH=each` makes every mutation flush before returning.)
76
+
77
+ ---
78
+
79
+ ## Quick Start
80
+
81
+ **PPT:**
82
+ ```bash
83
+ officecli create slides.pptx
84
+ officecli add slides.pptx / --type slide --prop title="Q4 Report" --prop background=1A1A2E
85
+ officecli add slides.pptx '/slide[1]' --type shape --prop text="Revenue grew 25%" --prop x=2cm --prop y=5cm --prop font=Arial --prop size=24 --prop color=FFFFFF
86
+ ```
87
+
88
+ **Word:**
89
+ ```bash
90
+ officecli create report.docx
91
+ officecli add report.docx /body --type paragraph --prop text="Executive Summary" --prop style=Heading1
92
+ officecli add report.docx /body --type paragraph --prop text="Revenue increased by 25% year-over-year."
93
+ ```
94
+
95
+ **Excel:**
96
+ ```bash
97
+ officecli create data.xlsx
98
+ officecli set data.xlsx /Sheet1/A1 --prop value="Name" --prop bold=true
99
+ officecli set data.xlsx /Sheet1/A2 --prop value="Alice"
100
+ ```
101
+
102
+ ---
103
+
104
+ ## L1: Create, Read & Inspect
105
+
106
+ ```bash
107
+ officecli create <file> # Create blank .docx/.xlsx/.pptx (type from extension)
108
+ officecli view <file> <mode> # outline | stats | issues | text | annotated | html
109
+ officecli get <file> <path> --depth N # Get a node and its children [--json]
110
+ officecli query <file> <selector> # CSS-like query
111
+ officecli validate <file> # Validate against OpenXML schema
112
+ ```
113
+
114
+ ### view modes
115
+
116
+ | Mode | Description | Useful flags |
117
+ |------|-------------|-------------|
118
+ | `outline` | Document structure | |
119
+ | `stats` | Statistics (pages, words, shapes) | |
120
+ | `issues` | Formatting/content/structure problems | `--type format\|content\|structure`, `--limit N` |
121
+ | `text` | Plain text extraction | `--start N --end N`, `--max-lines N` |
122
+ | `annotated` | Text with formatting annotations | |
123
+ | `html` | Static HTML snapshot — same renderer as `watch`, no server needed | `--browser`, `--page N` (docx), `--start N --end N` (pptx) |
124
+ | `screenshot` / `svg` / `pdf` / `forms` | PNG via headless browser / SVG (pptx slide) / PDF via exporter plugin / form-fields JSON via format-handler plugin | `-o`, `--screenshot-width/-height`, pptx `--grid N` |
125
+
126
+ Use `view html` for one-shot snapshots (CI artifacts, archival, diffing); use `watch` when you need live refresh or browser-side click-to-select.
127
+
128
+ ### get
129
+
130
+ Any XML path via element localName. Use `--depth N` to expand children. Add `--json` for structured output. Default text output is grep-friendly: `path (type) "text" key=val key=val ...`
131
+
132
+ ```bash
133
+ officecli get report.docx '/body/p[3]' --depth 2 --json
134
+ officecli get slides.pptx '/slide[1]' --depth 1 # list all shapes on slide 1
135
+ officecli get data.xlsx '/Sheet1/B2' --json
136
+ ```
137
+
138
+ ### Stable ID Addressing
139
+
140
+ Elements with stable IDs return `@attr=value` paths instead of positional indices. Prefer these in multi-step workflows — positional indices shift on insert/delete, stable IDs do not.
141
+
142
+ ```
143
+ /slide[1]/shape[@id=550950021] # PPT shape
144
+ /slide[1]/table[@id=1388430425]/tr[1]/tc[2] # PPT table
145
+ /body/p[@paraId=1A2B3C4D] # Word paragraph
146
+ /comments/comment[@commentId=1] # Word comment
147
+ ```
148
+
149
+ PPT also accepts `@name=` (e.g. `shape[@name=Title 1]`), with morph `!!` prefix awareness. Elements without stable IDs (slide, run, tr/tc, row) fall back to positional indices.
150
+
151
+ ### query
152
+
153
+ CSS-like selectors: `[attr=value]`, `[attr!=value]`, `[attr~=text]`, `[attr>=value]`, `[attr<=value]`, `:contains("text")`, `:empty`, `:has(formula)`, `:no-alt`. Boolean `and`/`or` supported across `query`/`set`/`remove`: `cell[value>5000 or value<100]`, `cell[(type=Number or type=Date) and value>0]`. Excel row-by-column-name: `Sheet1!row[Salary>5000]`. `set` accepts selectors and Excel-native paths (parity with `get`/`query`). Bare unscoped selectors rejected on `set`/`remove`.
154
+
155
+ ```bash
156
+ officecli query report.docx 'paragraph[style=Normal] > run[font!=Arial]'
157
+ officecli query slides.pptx 'shape[fill=FF0000]'
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Watch & Interactive Selection
163
+
164
+ Live HTML preview that auto-refreshes on every file change. Browsers can click / shift-click / box-drag to select shapes; the CLI can read the current browser selection and act on it.
165
+
166
+ ```bash
167
+ officecli watch <file> [--port N] # Start preview server (default port 26315)
168
+ officecli unwatch <file> # Stop
169
+ officecli goto <file> <path> # Scroll watching browser(s) to element (docx: p / table / tr / tc)
170
+ ```
171
+
172
+ Open the printed `http://localhost:N` URL. Click to select; shift/cmd/ctrl+click to multi-select; drag from empty space to box-select. PPT/Word use blue outline; Excel uses native-style green selection (double-click cell to edit inline; drag a chart to reposition).
173
+
174
+ ### `get <file> selected` — read what the user clicked
175
+
176
+ ```bash
177
+ officecli get <file> selected [--json]
178
+ ```
179
+
180
+ Returns DocumentNodes for whatever is currently selected. Empty result if nothing selected. Exit code != 0 if no watch is running.
181
+
182
+ ```bash
183
+ # User clicks shapes in the browser, then asks "make these red"
184
+ PATHS=$(officecli get deck.pptx selected --json | jq -r '.data.Results[].path')
185
+ for p in $PATHS; do officecli set deck.pptx "$p" --prop fill=FF0000; done
186
+ ```
187
+
188
+ ### Key properties
189
+
190
+ - **Selection survives file edits.** Paths use stable `@id=` form.
191
+ - **All connected browsers share one selection.** Last-write-wins.
192
+ - **Same-file single-watch.** A given file can have only one watch process at a time.
193
+ - **Group shapes select as a whole.** Drilling into individual children of a group is not supported in v1.
194
+ - **Coverage:** `.pptx` shapes/pictures/tables/charts/connectors/groups; `.docx` top-level paragraphs and tables. Inherited layout/master decorations and Word nested elements (table cells, run-level) are not addressable. **`.xlsx` does not emit `data-path`** — `mark`/`selection` on xlsx always resolve `stale=true` (v2 candidate).
195
+
196
+ ### Marks — edit proposals waiting for review
197
+
198
+ Use `mark` when changes need human review BEFORE they hit the file. Marks live in the watch process only; a separate `set` pipeline applies accepted ones. For one-shot changes use `set` directly; for permanent file annotations use `add --type comment` (Word native).
199
+
200
+ ```bash
201
+ officecli mark <file> <path> [--prop find=... color=... note=... tofix=... regex=true] [--json]
202
+ officecli unmark <file> [--path <p> | --all] [--json]
203
+ officecli get-marks <file> [--json]
204
+ ```
205
+
206
+ Props: `find` (literal or regex when `regex=true`; raw form `find='r"[abc]"'`), `color` (hex / `rgb(...)` / 22 named whitelist), `note`, `tofix` (drives apply pipeline). **Path** must be `data-path` format from watch HTML — see subskills for full pipeline.
207
+
208
+ ---
209
+
210
+ ## L2: DOM Operations
211
+
212
+ ### set — modify properties
213
+
214
+ ```bash
215
+ officecli set <file> <path> --prop key=value [--prop ...]
216
+ ```
217
+
218
+ **Any XML attribute is settable** via element path (found via `get --depth N`) — even attributes not currently present. Without `find=`, `set` applies format to the entire element.
219
+
220
+ **Value formats:**
221
+
222
+ | Type | Format | Examples |
223
+ |------|--------|---------|
224
+ | Colors | Hex (with/without `#`), named, RGB, theme | `FF0000`, `#FF0000`, `red`, `rgb(255,0,0)`, `accent1`..`accent6` |
225
+ | Spacing | Unit-qualified | `12pt`, `0.5cm`, `1.5x`, `150%` |
226
+ | Dimensions | EMU or suffixed | `914400`, `2.54cm`, `1in`, `72pt`, `96px` |
227
+
228
+ **Dotted-attr aliases** — `font.<attr>` forms accepted on shape/run/paragraph/table/row/cell/section/styles, e.g. `--prop font.color=red --prop font.bold=true --prop font.size=14pt`. Run `officecli help <fmt> <element>` for the full list.
229
+
230
+ ### find — format or replace matched text
231
+
232
+ Use top-level `--find` / `--replace` on `set` (and `--find` on `query`). Legacy `--prop find=X` still works but emits a hint.
233
+
234
+ ```bash
235
+ # Format matched text (auto-splits runs)
236
+ officecli set doc.docx '/body/p[1]' --find weather --prop bold=true --prop color=red
237
+
238
+ # Regex matching (regex= still a prop flag)
239
+ officecli set doc.docx '/body/p[1]' --find '\d+%' --prop regex=true --prop color=red
240
+
241
+ # Replace text (use `/` for whole-document scope)
242
+ officecli set doc.docx / --find draft --replace final
243
+
244
+ # docx: tracked Find&Replace
245
+ officecli set doc.docx / --find draft --replace final --prop revision.author=Alice
246
+
247
+ # PPT — same syntax, different paths
248
+ officecli set slides.pptx / --find draft --replace final
249
+ ```
250
+
251
+ **Path controls search scope:** `/` = whole document, `/body/p[1]` or `/slide[N]/shape[M]` = specific element, `/header[1]` / `/footer[1]` = headers/footers.
252
+
253
+ **Notes:**
254
+ - Case-sensitive by default. Case-insensitive: `--prop 'find=(?i)error' --prop regex=true`
255
+ - Matches work across run boundaries
256
+ - No match = silent success. `--json` includes `"matched": N`
257
+ - **Excel:** only `find` + `replace` supported (no find + format props)
258
+
259
+ ### add — add elements or clone
260
+
261
+ ```bash
262
+ officecli add <file> <parent> --type <type> [--prop ...]
263
+ officecli add <file> <parent> --type <type> --after <path> [--prop ...] # insert after anchor
264
+ officecli add <file> <parent> --type <type> --before <path> [--prop ...] # insert before anchor
265
+ officecli add <file> <parent> --type <type> --index N [--prop ...] # 0-based position (legacy)
266
+ officecli add <file> <parent> --from <path> # clone existing element
267
+ ```
268
+
269
+ `--after`, `--before`, `--index` are mutually exclusive. No position flag = append to end.
270
+
271
+ **Element types (with aliases):**
272
+
273
+ | Format | Types |
274
+ |--------|-------|
275
+ | **pptx** | slide (incl. hidden), shape (font.latin/ea/cs, direction=rtl, underline.color, highlight=COLOR (Add/Set/Get/HTML preview), effective.X+effective.X.src; arrow alias for rightArrow; slideMaster/slideLayout typed add/set/remove), picture (SVG, brightness/contrast/glow/shadow, rotation, link, tooltip), chart (direction=rtl, pieOfPie, barOfPie, axisLine/gridline per-attr setters, animation+chartBuild=byCategory|bySeries, line dropLines/hiLowLines/upDownBars, anchor=x,y,w,h shorthand), table (cell direction=rtl, fill/background, built-in PowerPoint style catalogue, /col[C] get + swap/copyFrom, row/col Move/CopyFrom), row (tr), connector (from/to accept full-path `@name=`/`@id=` forms — bare `@name=Foo` is rejected, must be `/slide[N]/shape[@name=Foo]` — startshape/endshape SetByPath; edge-to-edge anchoring by default, fromSide/toSide to force an edge, fromIdx/toIdx for raw cxn index), group (link, tooltip, deep walk by get/query/add/remove, ungroup=true dissolves back to slide-absolute), align/distribute (targets= accepts shape[@id=N] paths, not just positional), video/audio (loop, autoStart alias), equation, notes (direction=rtl, lang), comment (legacy + modern p188 threaded round-trip), animation (15 emphasis + 16 exit presets, multi-effect chains, motion-path presets, repeat/restart/autoReverse, chart animations), transition (12 p15 presets + morph/p14), paragraph (para), run, zoom, ole (preview=, full dump round-trip via add-part+raw-set), placeholder (phType=...), model3d (rotation=ax,ay,az; full dump round-trip), smartart (dump round-trip via add-part), diagram (add-only mermaid → native shapes or rendered image, `--type diagram`/`flowchart`). |
276
+ | **docx** | paragraph (direction/font.latin/ea/cs, bold.cs/italic.cs/size.cs, lang.latin/ea/cs, wordWrap, framePr.\*, tabs shorthand), run (lang slots, direction, underline.color, position half-pts, **revision.type=ins\|del\|format\|moveFrom\|moveTo + revision.action=accept\|reject** with .author/.date — bare `@author=`/`@type=` selector on `set /revision[...]` for filtered accept/reject, but `query 'revision[...]'` needs the dotted `revision.author=`/`revision.type=` form; move+revision is run-level paths only, not paragraph-level; **range=START:END** on a paragraph/shape path formats a char span by explicit 0-based half-open offset instead of addressing a run — the offset sibling of find=), table (direction=rtl, hMerge, cantSplit on row/nowrap on cell (both add+set), **virtual column ops**: add/remove/move/copyfrom on /body/tbl[N]/col), row (tr), cell (td), image, header/footer (direction), section (pageNumFmt full enum, direction=rtl, rtlGutter, pgBorders=box), bookmark, comment, footnote, endnote, formfield, sdt, chart, equation, field (28 types), hyperlink, style (direction, indents, pbdr, lineSpacing on Add/Set), toc, watermark, break, ole, **num/abstractNum/lvl**, **tab**, **textbox/shape** (add-mostly — Get returns raw XML preview only, no structured readback; Set is limited to width/height/geometry/fill/line.\*; position is `anchor.x`/`anchor.y` not bare x/y; **textbox-only** `textDirection`/rotation/gradient/shadow — docx shape itself has neither rotation nor gradient), embedded **OLE round-trip on dump→batch**, **diagram** (add-only mermaid → native shapes or rendered image, `--type diagram`/`flowchart`, no x/y at add-time — reposition via `set /body/group[N]`). docDefaults.rtl, autoHyphenation, `get /` exposes locale + /comments /footnotes /endnotes. `create --minimal` for raw OOXML scaffolding. |
277
+ | **xlsx** | sheet (visible/hidden/veryHidden, print margins, printTitleRows/Cols, rightToLeft sheetView, cascade-aware rename), row (c{N}= cell-content shorthand; add accepts --from /Sheet/col[L]; formula-ref rewrite on insert), col (formula-ref rewrite, named-range follow on move), cell (type=richtext+runs, merge=range/sweep, direction=rtl, phonetic; **--shift left\|up on remove, shift=right\|down on add** — Excel UI dialog parity; formula auto-detect; OFFSET/INDIRECT in calc), chart (per-axis RTL/title, anchor=x,y,w,h, pareto), image (SVG), comment (direction=rtl), table (listobject), namedrange (definedname, volatile, `[@name=X]`; formula-body inlined at parse), pivottable (cache CoW + cross-pivot sharing, labelFilter=field:type:value add-time-only, topN=integer add-time-only, fillDownLabels is an alias of repeatLabels not a separate feature, calculatedField), sparkline, validation, autofilter, shape, textbox, CF (databar/colorscale/iconset/formulacf/cellIs/topN/aboveAverage), ole, csv. Query supports `merge`/`mergedrange`. Workbook: password. Shape selector enumerates leaves inside grpSp. |
278
+
279
+ ### Pivot tables (xlsx)
280
+
281
+ ```bash
282
+ officecli add data.xlsx /Sheet1 --type pivottable \
283
+ --prop source="Sheet1!A1:E100" --prop rows=Region,Category \
284
+ --prop cols=Year --prop values="Sales:sum,Qty:count" \
285
+ --prop grandTotals=rows --prop subtotals=off --prop sort=asc
286
+ ```
287
+
288
+ Key props: `rows`, `cols`, `values` (Field:func[:showDataAs]), `filters`, `source`, `position`, `layout` (compact/outline/tabular), `repeatLabels`, `blankRows`, `aggregate`, `showDataAs` (percent_of_total/row/col, running_total), `grandTotals`, `subtotals`, `sort`. Aggregators: sum, count, average, max, min, product, stdDev, stdDevp, var, varp, countNums. Date columns auto-group. Run `officecli help xlsx pivottable` for full schema.
289
+
290
+ ### Document-level properties (all formats)
291
+
292
+ ```bash
293
+ officecli set doc.docx / --prop docDefaults.font=Arial --prop docDefaults.fontSize=11pt
294
+ officecli set doc.docx / --prop protection=forms --prop evenAndOddHeaders=true
295
+ officecli set data.xlsx / --prop calc.mode=manual --prop calc.refMode=r1c1
296
+ officecli set slides.pptx / --prop defaultFont=Arial --prop show.loop=true --prop print.what=handouts
297
+ ```
298
+
299
+ Run `officecli help <format> /` for all document-level properties (docDefaults, docGrid, CJK spacing, calc, print, show, theme, extended).
300
+
301
+ ### Sort (xlsx)
302
+
303
+ ```bash
304
+ officecli set data.xlsx /Sheet1 --prop sort="C desc" --prop sortHeader=true
305
+ officecli set data.xlsx '/Sheet1/A1:D100' --prop sort="A asc" --prop sortHeader=true
306
+ ```
307
+
308
+ Format: `COL DIR[, COL DIR ...]`. Rejects ranges with merged cells or formulas. Sidecar metadata (hyperlinks, comments, conditional formatting, drawings) follows rows automatically.
309
+
310
+ ### Text-anchored insert (`--after find:X` / `--before find:X`)
311
+
312
+ Locate an insertion point by text match within a paragraph. Inline types (run, picture, hyperlink) insert within the paragraph; block types (table, paragraph) auto-split it. PPT only supports inline.
313
+
314
+ ```bash
315
+ # Word: inline run after matched text
316
+ officecli add doc.docx '/body/p[1]' --type run --after find:weather --prop text=" (sunny)"
317
+
318
+ # Word: block table after matched text (auto-splits paragraph)
319
+ officecli add doc.docx '/body/p[1]' --type table --after "find:First sentence." --prop rows=2 --prop cols=2
320
+ ```
321
+
322
+ ### Clone
323
+
324
+ `officecli add <file> / --from '/slide[1]'` — copies with all cross-part relationships.
325
+
326
+ ### move, swap, remove
327
+
328
+ ```bash
329
+ officecli move <file> <path> [--to <parent>] [--index N] [--after <path>] [--before <path>]
330
+ officecli swap <file> <path1> <path2>
331
+ officecli remove <file> '/body/p[4]'
332
+ ```
333
+
334
+ When using `--after` or `--before`, `--to` can be omitted — the target container is inferred from the anchor.
335
+
336
+ ### batch — multiple operations in one save cycle
337
+
338
+ **Atomic by default (v1.0.137+):** every item still runs and is reported (so `N succeeded, M failed` stays meaningful and every failure surfaces), but if *any* item fails the whole batch rolls back — the file on disk is left byte-identical to before the batch ran (confirmed live in both standalone and resident mode). Use `--best-effort` to restore the old apply-what-succeeds behavior (useful for lossy `dump→batch` replays where losing the whole thing over one unsupported item is worse than a partial result). `--stop-on-error` only changes how early the run stops (remaining items are `skipped`), not whether what ran gets kept — combine it with `--best-effort` if you want "stop at first failure but keep what already succeeded." `--force` is unrelated — it's only the docx-protection bypass. Failed items carry a machine-readable `code` field (same list as `error.code`); a rolled-back batch's JSON summary carries `"atomicRolledBack": true`.
339
+
340
+ `officecli dump <file> [<path>]` emits a replayable batch JSON for round-trip — `.docx` (full coverage), `.pptx` (text/tables/pictures/charts/notes/theme + OLE/3D/video/audio/SmartArt/morph/p15 transitions via raw-set passthrough), and `.xlsx` (cells/formulas/styles + tables, conditional formatting, validations, comments, charts, sparklines, pictures, shapes, pivot tables; slicers/chartEx/OLE via verbatim carrier). Path defaults to `/` (whole document); pass a subtree path (docx: `/body`, `/body/p[N]`, `/body/tbl[N]`, `/theme`, `/settings`, `/numbering`, `/styles`; xlsx: `/SheetName`, `/sheet[N]`) to scope the dump. `officecli refresh <file.docx>` recalculates TOC page numbers / PAGE / cross-references after replay (Word backend on Windows; headless-HTML fallback elsewhere). `officecli plugins list` extends support to `.doc`, `.hwpx`, `.pdf` export.
341
+
342
+ ```bash
343
+ echo '[
344
+ {"command":"set","path":"/Sheet1/A1","props":{"value":"Name","bold":"true"}},
345
+ {"command":"set","path":"/Sheet1/B1","props":{"value":"Score","bold":"true"}}
346
+ ]' | officecli batch data.xlsx --json
347
+
348
+ officecli batch data.xlsx --commands '[{"op":"set","path":"/Sheet1/A1","props":{"value":"Done"}}]' --json
349
+ officecli batch data.xlsx --input updates.json --best-effort --json # keep whatever succeeds even if some items fail
350
+ ```
351
+
352
+ Supports: `add`, `set`, `get`, `query`, `remove`, `move`, `swap`, `view`, `raw`, `raw-set`, `validate`. Fields: `command` (or `op`), `path`, `parent`, `type`, `from`, `to`, `index`, `after`, `before`, `props`, `selector`, `mode`, `depth`, `part`, `xpath`, `action`, `xml`.
353
+
354
+ ---
355
+
356
+ ## L3: Raw XML
357
+
358
+ Use when L2 cannot express what you need. No xmlns declarations needed — prefixes auto-registered.
359
+
360
+ ```bash
361
+ officecli raw <file> <part> # view raw XML
362
+ officecli raw-set <file> <part> --xpath "..." --action replace --xml '<w:p>...</w:p>'
363
+ officecli add-part <file> <parent> # create new document part (returns rId)
364
+ ```
365
+
366
+ `raw-set` actions: `append`, `prepend`, `insertbefore`, `insertafter`, `replace`, `remove`, `setattr`. Run `officecli help <format> raw` for available parts.
367
+
368
+ ---
369
+
370
+ ## Common Pitfalls
371
+
372
+ | Pitfall | Correct Approach |
373
+ |---------|-----------------|
374
+ | `--name "foo"` | Use `--prop name="foo"` — all attributes go through `--prop` |
375
+ | Unquoted `[N]` paths in zsh/bash | Always quote: `'/slide[1]'` or `"/slide[1]"` (shell glob-expands brackets) |
376
+ | PPT `shape[1]` for content | `shape[1]` is typically the title placeholder. Use `shape[2]+` for content shapes |
377
+ | `/shape[myname]` | Name indexing not supported. Use numeric index or `@name=` (PPT only) |
378
+ | Guessing property names | Run `officecli help <format> <element>` to see exact names |
379
+ | Modifying an open file | Close the file in PowerPoint/WPS first |
380
+ | `\n` in shell strings | Use `\\n` for newlines in `--prop text="..."` |
381
+ | `$` in shell text | `--prop text="$15M"` strips `$15`. Use single quotes: `--prop text='$15M'`, or heredoc batch |
382
+
383
+ ---
384
+
385
+ ## Specialized Skills
386
+
387
+ `officecli load_skill <name>` — output is a SKILL.md, follow its rules.
388
+
389
+ **Loading rule**:
390
+ - Pick the most specific match in "When to use"; if none fits, load the format default (`word` / `pptx` / `excel`).
391
+ - Scenes already contain the format default's rules — load **one** skill per artifact, never stack.
392
+ - Loaded rules persist across turns; don't re-load each reply.
393
+ - Two distinct artifacts → two separate loads.
394
+
395
+ ### Word (.docx)
396
+
397
+ | Name | When to use |
398
+ |------|-------------|
399
+ | `word` | Reports, letters, memos, proposals, generic documents |
400
+ | `academic-paper` | Journal / conference / thesis: APA / Chicago / IEEE / MLA citations, equations, SEQ + PAGEREF cross-refs, multi-column journal layout, bibliography. NOT for business reports or letters (route those to `word`) |
401
+
402
+ ### PowerPoint (.pptx)
403
+
404
+ | Name | When to use |
405
+ |------|-------------|
406
+ | `pptx` | Generic decks: board reviews, sales decks, all-hands, product launches |
407
+ | `pitch-deck` | **Fundraising only** — seed / Series A-C / SAFE / convertible / strategic raise. NOT for sales / product / board decks (route those to `pptx`) |
408
+ | `morph-ppt` | Cinematic Morph-animated presentations. NOT for static decks (route those to `pptx`) |
409
+ | `morph-ppt-3d` | 3D Morph: GLB models, camera moves, depth. NOT for 2D-only Morph (route those to `morph-ppt`) |
410
+
411
+ ### Excel (.xlsx)
412
+
413
+ | Name | When to use |
414
+ |------|-------------|
415
+ | `excel` | Generic workbooks, formulas, pivots, trackers |
416
+ | `financial-model` | Financial models, scenarios, projections. NOT for general data analysis (route those to `excel`) |
417
+ | `data-dashboard` | CSV/tabular data → KPI / analytics / executive dashboards with charts and sparklines. NOT for raw data tracking (route those to `excel`) |
418
+
419
+ Example: a fundraising deck task → `officecli load_skill pitch-deck` → use the printed rules.
420
+
421
+ ---
422
+
423
+ ## Notes
424
+
425
+ - Paths are **1-based** (XPath convention): `'/body/p[3]'` = third paragraph
426
+ - `--index` is **0-based** (array convention): `--index 0` = first position
427
+ - **Excel exception**: for `add --type row` and `add --type col`, `--index N` is **1-based** (matches OOXML RowIndex / column letter index). `--index 5` inserts at row 5 / column 5.
428
+ - After modifications, verify with `validate` and/or `view issues`
429
+ - **When unsure**, run `officecli help <format> <element>` instead of guessing
@@ -0,0 +1,171 @@
1
+ ---
2
+ name: playwright
3
+ description: 使用 Playwright 驱动真实浏览器完成网页自动化与端到端测试:打开页面、点击、输入、按键、截图、断言。适用于需要浏览器操作、验证 Web 功能、抓取渲染后页面的场景。默认优先调用系统已安装的 Chrome(--browser chrome),以降低被网站反爬拦截的概率。
4
+ metadata:
5
+ displayName: Playwright
6
+ icon: browser
7
+ category: browser-automation
8
+ version: 1.2.0
9
+ dependencies:
10
+ cli: playwright-cli
11
+ checkCommand: playwright-cli --version
12
+ install:
13
+ npm: npm install -g @playwright/cli@latest
14
+ # 仅当环境里没有可用的系统 Chrome / Edge,才需要 Playwright 自带内核
15
+ browsers: playwright-cli install-browser chromium
16
+ ---
17
+
18
+ # playwright-cli
19
+
20
+ 面向编码 Agent 的浏览器自动化 CLI。相比 MCP,命令式交互不会把庞大的工具 schema
21
+ 与可访问性树塞进模型上下文,更省 token。
22
+
23
+ ## 安装
24
+
25
+ 先检查是否可用:
26
+
27
+ ```bash
28
+ playwright-cli --version
29
+ ```
30
+
31
+ 若不可用:
32
+
33
+ ```bash
34
+ npm install -g @playwright/cli@latest
35
+
36
+ # 仅当环境里没有可用的系统 Chrome / Edge 时才需要(见「浏览器选择」)
37
+ playwright-cli install-browser chromium
38
+ ```
39
+
40
+ 如果安装后仍然找不到命令,请打开新的终端会话(PATH 尚未刷新)。
41
+
42
+ ## 浏览器选择(重要:优先使用系统已安装的浏览器)
43
+
44
+ `playwright-cli open --browser <值>` 接受 `chrome`、`msedge`、`firefox`、`webkit`
45
+ (帮助原文:*browser or chrome channel to use*)。
46
+
47
+ **默认加 `--browser chrome`。** 按以下顺序选择,能用前面的就不要用后面的:
48
+
49
+ | 优先级 | 取值 | 实际使用的浏览器 | 备注 |
50
+ | --- | --- | --- | --- |
51
+ | 1 | 系统默认浏览器对应的取值 | 视系统而定 | 若默认浏览器为 Chrome / Edge,就用对应的 `chrome` / `msedge`;为 Firefox 或 Safari 时**无法使用**(见下文) |
52
+ | 2 | **`chrome`** | **系统安装的 Google Chrome** | ✅ 首选,真实二进制与版本号 |
53
+ | 3 | **`msedge`** | **系统安装的 Microsoft Edge** | ✅ 同样走后系统安装 |
54
+ | 4 | `firefox` | ⚠️ **Playwright 自带**的定制 Firefox | **不是系统 Firefox**,见下文 |
55
+ | 5 | `webkit` | Playwright 自带的 WebKit | 仅用于 Safari 兼容性验证 |
56
+ | 6 | 不指定(默认) | Playwright 自带的 Chromium | 最后兜底 |
57
+
58
+ ### 为什么不要用自带的 Chromium
59
+
60
+ 不指定 `--browser` 时启动的是 Playwright 自带的 Chromium。它带有明显的自动化特征:
61
+ 版本号与官方发布版不一致、缺少常见插件、暴露 `navigator.webdriver` 等。
62
+ Cloudflare、Akamai 以及各类风控系统很容易据此判定为机器人,返回验证页或直接拦截。
63
+
64
+ 改用**系统安装的 Chrome / Edge** 后,浏览器指纹与普通用户一致,通过率显著提高 ——
65
+ 这也是本技能把它列为默认选择的原因。
66
+
67
+ ### 必须避开 snap 版本(Linux)
68
+
69
+ snap 包的浏览器运行在沙箱中,profile 目录写入、文件系统访问与 `--user-data-dir`
70
+ 都可能异常,导致启动失败或行为不一致。**选择前先确认目标浏览器不是 snap 安装**:
71
+
72
+ ```bash
73
+ for b in google-chrome google-chrome-stable microsoft-edge; do
74
+ p=$(command -v "$b" 2>/dev/null) || continue
75
+ case "$(readlink -f "$p")" in
76
+ */snap/*) echo "$b → snap 安装(不要用)" ;;
77
+ *) echo "$b → 原生安装 ✓" ;;
78
+ esac
79
+ done
80
+ ```
81
+
82
+ 若只有 snap 版本,**不要勉强使用**:宁可退回自带内核(`chromium`),也不要使用
83
+ 受沙箱限制的 snap 浏览器。
84
+
85
+ ### 关于 Firefox(重要限制)
86
+
87
+ **`--browser firefox` 使用的不是系统安装的 Firefox,而是 Playwright 自带的定制构建**
88
+ (位于 Playwright 的浏览器缓存目录,需先执行 `playwright-cli install-browser firefox`)。
89
+
90
+ 原因是 Playwright 依赖定制补丁实现的浏览器控制协议,系统原版 Firefox 无法被驱动。
91
+ 这一点对 Node 脚本同样成立:`channel: "firefox"` 依然指向自带构建,用 `executablePath`
92
+ 指向系统 Firefox 也无法工作。
93
+
94
+ 因此 **「使用系统已安装的 Firefox」在 Playwright 下是做不到的**。Firefox 的适用场景:
95
+ 需要验证 Gecko 引擎兼容性,或 Chromium 系被某站点针对性拦截时换一个引擎再试。
96
+
97
+ ### 与 Node 脚本的对应关系
98
+
99
+ | CLI 取值 | Node 脚本写法 | 实际浏览器 |
100
+ | --- | --- | --- |
101
+ | `--browser chrome` | `chromium.launch({ channel: "chrome" })` | 系统 Chrome |
102
+ | `--browser msedge` | `chromium.launch({ channel: "msedge" })` | 系统 Edge |
103
+ | `--browser firefox` | `firefox.launch()` | 自带 Firefox |
104
+ | `--browser webkit` | `webkit.launch()` | 自带 WebKit |
105
+ | (不指定) | `chromium.launch()` | 自带 Chromium |
106
+
107
+ ## 基本用法
108
+
109
+ ```bash
110
+ playwright-cli open https://example.com --browser chrome # 打开页面(默认无头)
111
+ playwright-cli open https://example.com --browser chrome --headed # 带头显示,便于观察
112
+ playwright-cli type "Buy groceries" # 向当前焦点元素输入文本
113
+ playwright-cli press Enter # 按下按键
114
+ playwright-cli screenshot # 截图(返回文件路径)
115
+ playwright-cli show # 打开会话面板,实时预览所有会话
116
+ ```
117
+
118
+ `playwright-cli` 的命令会随版本演进。**不确定参数时不要猜测**,直接查询帮助:
119
+
120
+ ```bash
121
+ playwright-cli --help
122
+ playwright-cli <command> --help
123
+ ```
124
+
125
+ 需要登录态或长期保持浏览器时,可配合 `--persistent` / `--profile <目录>` 复用用户数据目录。
126
+
127
+ ## 推荐工作流
128
+
129
+ 1. 明确目标:目标 URL、需要执行的交互步骤、期望结果。
130
+ 2. **按上面的优先级确定可用的浏览器**(优先系统安装的 Chrome / Edge,避开 snap 版),
131
+ 然后 `open` 时带上 `--browser <值>`。
132
+ 3. 逐步执行交互(`type` / `press` / 点击等),每步确认页面状态。
133
+ 4. 对每个关键步骤(尤其是失败场景)执行 `screenshot` 留存证据。
134
+ 5. 汇总结果:说明通过/失败的步骤,并给出截图文件路径。
135
+
136
+ ## 备选方案:Node 脚本
137
+
138
+ 当流程复杂(循环、条件、数据驱动)时,改用 Playwright 库编写脚本更合适。
139
+ 同样应优先指定 `channel`:
140
+
141
+ ```js
142
+ const { chromium } = require("playwright");
143
+
144
+ (async () => {
145
+ // channel: "chrome" → 使用系统安装的 Chrome(不要用默认的 bundled chromium)
146
+ const browser = await chromium.launch({ channel: "chrome" });
147
+ const page = await browser.newPage();
148
+ await page.goto("https://example.com");
149
+ await page.screenshot({ path: "shot.png" });
150
+ await browser.close();
151
+ })();
152
+ ```
153
+
154
+ 若环境里没有系统 Chrome / Edge,再退回 `chromium.launch()`。
155
+
156
+ ## 注意事项
157
+
158
+ - 需要 Node.js >= 20。
159
+ - **默认加 `--browser chrome`**:既避免使用带自动化特征的 bundled Chromium 被反爬拦截,
160
+ 也省去下载内核的步骤(见「浏览器选择」)。
161
+ - 不要使用 snap 安装的浏览器(沙箱会破坏 profile 与文件访问)。
162
+ - 无头模式是默认行为;只有在需要观察或调试时才使用 `--headed`。
163
+ - 遇到验证码 / 风控页时,先确认是否漏了 `--browser chrome`,再考虑 `--headed` 人工介入。
164
+ - 截图等产物默认写入当前工作目录,注意不要污染项目源码目录。
165
+ - 一次会话无人交互会超时,长任务请分步执行。
166
+
167
+ ## 参考
168
+
169
+ - 官方文档:https://playwright.dev/agent-cli/introduction
170
+ - 浏览器 channel 说明:https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
171
+ - 仓库:https://github.com/microsoft/playwright-cli
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: postgres
3
+ description: Manage PostgreSQL databases via the psql CLI.
4
+ metadata:
5
+ displayName: PostgreSQL
6
+ icon: postgres
7
+ category: databases
8
+ version: 1.0.0
9
+ dependencies:
10
+ cli: psql
11
+ checkCommand: psql --version
12
+ bundledInstall: skills/postgres/install.sh
13
+ install:
14
+ darwin:
15
+ brew: postgresql
16
+ linux:
17
+ apt: postgresql-client
18
+ windows:
19
+ scoop: postgresql
20
+ auth:
21
+ type: none
22
+ ---
23
+
24
+ # psql
25
+
26
+ Use `psql` to interact with PostgreSQL databases.
27
+
28
+ ## Common Commands
29
+
30
+ ### Connection
31
+
32
+ - Connect: `psql "postgresql://user:password@host:port/dbname"`
33
+
34
+ ### Operations
35
+
36
+ - List databases: `\l`
37
+ - List tables: `\dt`
38
+ - Describe table: `\d <table_name>`
39
+ - Execute query: `SELECT * FROM table LIMIT 10;`
40
+ - Quit: `\q`
41
+
42
+ ## Notes
43
+
44
+ - Requires `psql` to be installed in the environment.