zcode-app-cli 3.3.5-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 (169) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +642 -0
  3. package/bin/zcode.js +848 -0
  4. package/config.example.json +110 -0
  5. package/package.json +81 -0
  6. package/vendor/.node-bundle-meta.json +6 -0
  7. package/vendor/extraction.json +11 -0
  8. package/vendor/node_modules/@zcode/tui/dist/index.js +161875 -0
  9. package/vendor/node_modules/@zcode/tui/package.json +14 -0
  10. package/vendor/packages/android-emulator-plugin/.mcp.json +19 -0
  11. package/vendor/packages/android-emulator-plugin/.zcode-plugin/plugin.json +63 -0
  12. package/vendor/packages/android-emulator-plugin/README.md +134 -0
  13. package/vendor/packages/android-emulator-plugin/commands/android-dev.md +11 -0
  14. package/vendor/packages/android-emulator-plugin/dist/lib/path.d.ts +4 -0
  15. package/vendor/packages/android-emulator-plugin/dist/lib/path.js +17 -0
  16. package/vendor/packages/android-emulator-plugin/dist/lib/result.d.ts +5 -0
  17. package/vendor/packages/android-emulator-plugin/dist/lib/result.js +22 -0
  18. package/vendor/packages/android-emulator-plugin/dist/lib/run.d.ts +18 -0
  19. package/vendor/packages/android-emulator-plugin/dist/lib/run.js +99 -0
  20. package/vendor/packages/android-emulator-plugin/dist/mcp/server.d.ts +3 -0
  21. package/vendor/packages/android-emulator-plugin/dist/mcp/server.js +47607 -0
  22. package/vendor/packages/android-emulator-plugin/dist/providers/app.d.ts +39 -0
  23. package/vendor/packages/android-emulator-plugin/dist/providers/app.js +50 -0
  24. package/vendor/packages/android-emulator-plugin/dist/providers/avd.d.ts +37 -0
  25. package/vendor/packages/android-emulator-plugin/dist/providers/avd.js +185 -0
  26. package/vendor/packages/android-emulator-plugin/dist/providers/build.d.ts +68 -0
  27. package/vendor/packages/android-emulator-plugin/dist/providers/build.js +131 -0
  28. package/vendor/packages/android-emulator-plugin/dist/providers/config.d.ts +7 -0
  29. package/vendor/packages/android-emulator-plugin/dist/providers/config.js +29 -0
  30. package/vendor/packages/android-emulator-plugin/dist/providers/device.d.ts +20 -0
  31. package/vendor/packages/android-emulator-plugin/dist/providers/device.js +91 -0
  32. package/vendor/packages/android-emulator-plugin/dist/providers/logs.d.ts +15 -0
  33. package/vendor/packages/android-emulator-plugin/dist/providers/logs.js +31 -0
  34. package/vendor/packages/android-emulator-plugin/dist/providers/preflight.d.ts +15 -0
  35. package/vendor/packages/android-emulator-plugin/dist/providers/preflight.js +123 -0
  36. package/vendor/packages/android-emulator-plugin/dist/providers/project-template.d.ts +13 -0
  37. package/vendor/packages/android-emulator-plugin/dist/providers/project-template.js +211 -0
  38. package/vendor/packages/android-emulator-plugin/dist/providers/project.d.ts +33 -0
  39. package/vendor/packages/android-emulator-plugin/dist/providers/project.js +195 -0
  40. package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.d.ts +14 -0
  41. package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.js +73 -0
  42. package/vendor/packages/android-emulator-plugin/dist/providers/sdk.d.ts +14 -0
  43. package/vendor/packages/android-emulator-plugin/dist/providers/sdk.js +185 -0
  44. package/vendor/packages/android-emulator-plugin/dist/providers/ui.d.ts +92 -0
  45. package/vendor/packages/android-emulator-plugin/dist/providers/ui.js +146 -0
  46. package/vendor/packages/android-emulator-plugin/hooks/hooks.json +3 -0
  47. package/vendor/packages/android-emulator-plugin/package.json +35 -0
  48. package/vendor/packages/android-emulator-plugin/skills/android-dev/INSTALL_ENVIRONMENT.md +357 -0
  49. package/vendor/packages/android-emulator-plugin/skills/android-dev/SKILL.md +73 -0
  50. package/vendor/packages/android-emulator-plugin/templates/compose-app/README.md +5 -0
  51. package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +8 -0
  52. package/vendor/packages/document-skills-plugin/package.json +8 -0
  53. package/vendor/packages/document-skills-plugin/skills/docx/LICENSE.txt +13 -0
  54. package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +201 -0
  55. package/vendor/packages/document-skills-plugin/skills/docx/references/chart-templates.md +386 -0
  56. package/vendor/packages/document-skills-plugin/skills/docx/references/common-rules.md +419 -0
  57. package/vendor/packages/document-skills-plugin/skills/docx/references/decorations.md +537 -0
  58. package/vendor/packages/document-skills-plugin/skills/docx/references/design-system.md +1797 -0
  59. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-advanced.md +257 -0
  60. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-core.md +332 -0
  61. package/vendor/packages/document-skills-plugin/skills/docx/references/faq.md +323 -0
  62. package/vendor/packages/document-skills-plugin/skills/docx/references/math-formulas.md +276 -0
  63. package/vendor/packages/document-skills-plugin/skills/docx/references/ooxml.md +222 -0
  64. package/vendor/packages/document-skills-plugin/skills/docx/references/toc.md +264 -0
  65. package/vendor/packages/document-skills-plugin/skills/docx/routes/comment.md +88 -0
  66. package/vendor/packages/document-skills-plugin/skills/docx/routes/create.md +207 -0
  67. package/vendor/packages/document-skills-plugin/skills/docx/routes/edit.md +115 -0
  68. package/vendor/packages/document-skills-plugin/skills/docx/routes/format.md +120 -0
  69. package/vendor/packages/document-skills-plugin/skills/docx/routes/read.md +114 -0
  70. package/vendor/packages/document-skills-plugin/skills/docx/scenes/academic.md +783 -0
  71. package/vendor/packages/document-skills-plugin/skills/docx/scenes/contract.md +463 -0
  72. package/vendor/packages/document-skills-plugin/skills/docx/scenes/copywriting.md +139 -0
  73. package/vendor/packages/document-skills-plugin/skills/docx/scenes/exam.md +698 -0
  74. package/vendor/packages/document-skills-plugin/skills/docx/scenes/official-doc.md +411 -0
  75. package/vendor/packages/document-skills-plugin/skills/docx/scenes/report.md +340 -0
  76. package/vendor/packages/document-skills-plugin/skills/docx/scenes/resume.md +534 -0
  77. package/vendor/packages/document-skills-plugin/skills/docx/scripts/__init__.py +1 -0
  78. package/vendor/packages/document-skills-plugin/skills/docx/scripts/add_toc_placeholders.py +749 -0
  79. package/vendor/packages/document-skills-plugin/skills/docx/scripts/document.py +1333 -0
  80. package/vendor/packages/document-skills-plugin/skills/docx/scripts/postcheck.py +807 -0
  81. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/comments.xml +3 -0
  82. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  83. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  84. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsIds.xml +3 -0
  85. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/people.xml +3 -0
  86. package/vendor/packages/document-skills-plugin/skills/docx/scripts/utilities.py +374 -0
  87. package/vendor/packages/document-skills-plugin/skills/docx/setup.sh +177 -0
  88. package/vendor/packages/document-skills-plugin/skills/pdf/LICENSE.txt +13 -0
  89. package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +919 -0
  90. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/academic.md +1058 -0
  91. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/creative.md +770 -0
  92. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/poster.md +702 -0
  93. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process-advanced.md +284 -0
  94. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +319 -0
  95. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/report.md +1659 -0
  96. package/vendor/packages/document-skills-plugin/skills/pdf/configs/components.md +153 -0
  97. package/vendor/packages/document-skills-plugin/skills/pdf/configs/fonts.md +93 -0
  98. package/vendor/packages/document-skills-plugin/skills/pdf/configs/visual_framework.md +263 -0
  99. package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-academic.tex +130 -0
  100. package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-altacv.tex +190 -0
  101. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/cover_validate.js +367 -0
  102. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/design_engine.py +2816 -0
  103. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2pdf-next.js +754 -0
  104. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2poster.js +256 -0
  105. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +2959 -0
  106. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf_qa.py +901 -0
  107. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/poster_validate.py +1337 -0
  108. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +269 -0
  109. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/toc_validate.py +2075 -0
  110. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/charts.md +320 -0
  111. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover-backgrounds.md +384 -0
  112. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover.md +1442 -0
  113. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/fill-engine.md +527 -0
  114. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/geometry.md +142 -0
  115. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/overflow.md +630 -0
  116. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/pagination.md +367 -0
  117. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/palette.md +217 -0
  118. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/typography.md +20 -0
  119. package/vendor/packages/ios-simulator-plugin/.mcp.json +15 -0
  120. package/vendor/packages/ios-simulator-plugin/.zcode-plugin/plugin.json +34 -0
  121. package/vendor/packages/ios-simulator-plugin/README.md +111 -0
  122. package/vendor/packages/ios-simulator-plugin/commands/ios-dev.md +11 -0
  123. package/vendor/packages/ios-simulator-plugin/dist/lib/path.d.ts +4 -0
  124. package/vendor/packages/ios-simulator-plugin/dist/lib/path.js +18 -0
  125. package/vendor/packages/ios-simulator-plugin/dist/lib/result.d.ts +5 -0
  126. package/vendor/packages/ios-simulator-plugin/dist/lib/result.js +20 -0
  127. package/vendor/packages/ios-simulator-plugin/dist/lib/run.d.ts +17 -0
  128. package/vendor/packages/ios-simulator-plugin/dist/lib/run.js +83 -0
  129. package/vendor/packages/ios-simulator-plugin/dist/mcp/server.d.ts +3 -0
  130. package/vendor/packages/ios-simulator-plugin/dist/mcp/server.js +46833 -0
  131. package/vendor/packages/ios-simulator-plugin/dist/providers/build.d.ts +112 -0
  132. package/vendor/packages/ios-simulator-plugin/dist/providers/build.js +99 -0
  133. package/vendor/packages/ios-simulator-plugin/dist/providers/logs.d.ts +21 -0
  134. package/vendor/packages/ios-simulator-plugin/dist/providers/logs.js +26 -0
  135. package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.d.ts +12 -0
  136. package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.js +62 -0
  137. package/vendor/packages/ios-simulator-plugin/dist/providers/project.d.ts +35 -0
  138. package/vendor/packages/ios-simulator-plugin/dist/providers/project.js +288 -0
  139. package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.d.ts +22 -0
  140. package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.js +30 -0
  141. package/vendor/packages/ios-simulator-plugin/dist/providers/sim.d.ts +60 -0
  142. package/vendor/packages/ios-simulator-plugin/dist/providers/sim.js +116 -0
  143. package/vendor/packages/ios-simulator-plugin/dist/providers/ui.d.ts +57 -0
  144. package/vendor/packages/ios-simulator-plugin/dist/providers/ui.js +67 -0
  145. package/vendor/packages/ios-simulator-plugin/hooks/hooks.json +3 -0
  146. package/vendor/packages/ios-simulator-plugin/package.json +35 -0
  147. package/vendor/packages/ios-simulator-plugin/skills/ios-dev/SKILL.md +45 -0
  148. package/vendor/packages/ios-simulator-plugin/templates/swiftui-app/README.md +5 -0
  149. package/vendor/packages/restore-legacy-sessions-plugin/.zcode-plugin/plugin.json +9 -0
  150. package/vendor/packages/restore-legacy-sessions-plugin/README.md +35 -0
  151. package/vendor/packages/restore-legacy-sessions-plugin/commands/restore-legacy-sessions.md +11 -0
  152. package/vendor/packages/restore-legacy-sessions-plugin/package.json +8 -0
  153. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/SKILL.md +92 -0
  154. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/restore-conversation.mjs +648 -0
  155. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/scan-legacy-sessions.mjs +422 -0
  156. package/vendor/packages/skill-creator-plugin/.zcode-plugin/plugin.json +8 -0
  157. package/vendor/packages/skill-creator-plugin/package.json +8 -0
  158. package/vendor/packages/skill-creator-plugin/skills/skill-creator/SKILL.md +159 -0
  159. package/vendor/packages/zcode-guide-plugin/.zcode-plugin/plugin.json +8 -0
  160. package/vendor/packages/zcode-guide-plugin/README.md +22 -0
  161. package/vendor/packages/zcode-guide-plugin/package.json +8 -0
  162. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-commands/SKILL.md +66 -0
  163. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-hooks/SKILL.md +66 -0
  164. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-mcp/SKILL.md +97 -0
  165. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-plugins/SKILL.md +59 -0
  166. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-skills/SKILL.md +61 -0
  167. package/vendor/packages/zcode-guide-plugin/skills/zcode-configuration-guide/SKILL.md +99 -0
  168. package/vendor/zcode.cjs +2926 -0
  169. package/zcode-runtime.lock.json +8 -0
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: diagnosing-commands
3
+ description: Use to diagnose and fix ZCode custom slash-command (/command) configuration problems in the ZCode client. Applies when a command is missing, is overridden by a higher-precedence command of the same name, has a frontmatter parse error, is dropped for having an empty body, has an invalid name, does not substitute $ARGUMENTS/$1, uses a colon rather than a slash for nested names, has a misspelled frontmatter key, or disappears because the plugin providing it is disabled. Provides the discovery order, how to inspect commands in the client, common pitfalls, and a step-by-step localization and repair workflow.
4
+ ---
5
+
6
+ # Diagnosing Command Configuration
7
+
8
+ Goal: reduce any `/command` problem to a single concrete fix.
9
+
10
+ A person inspects commands from the **`/` menu** (the Commands group) in the input box; an agent inspects by reading the command files at the locations below.
11
+
12
+ > Two points that are often misunderstood: nested command names join with a **colon** (`review/code.md` becomes `/review:code`, not `/review/code`); and a command is a `.md` file whose **file name is the command name**.
13
+
14
+ ## 1. Discovery order (earlier locations take precedence)
15
+
16
+ 1. Explicitly configured roots
17
+ 2. User `~/.zcode/commands`
18
+ 3. User `~/.agents/commands`
19
+ 4. Workspace `.zcode/commands` (from the current directory up to the repository root; every level counts)
20
+ 5. Workspace `.agents/commands`
21
+ 6. Enabled **plugin** command roots (lowest precedence)
22
+
23
+ Within a level, `.zcode` is scanned before `.agents`. Subdirectories are scanned recursively, and a nested path joins into the command name with a colon.
24
+
25
+ ## 2. Deduplication rule (first match wins)
26
+
27
+ The key is the **normalized command name** (the relative path with `.md` removed, separators replaced by `:`, lowercased). The **first occurrence — the highest-precedence location — wins**: user overrides workspace, `.zcode` overrides `.agents`, and local files override plugins. Duplicates are ignored.
28
+
29
+ There is also an **interactive-surface-only** filter: a command whose name matches a built-in slash command (or `compress`) is filtered out of the live `/` menu, though it is still present on disk.
30
+
31
+ ## 3. Command .md format
32
+
33
+ - The command name comes from the file name and must match `^[a-z0-9][a-z0-9_:-]{0,63}$` (lowercase alphanumeric start; no spaces, dots, or leading `-`/`_`; at most 64 characters). A violation drops the command.
34
+ - Frontmatter (a flat parser; indented lines are ignored) recognizes `description`, `argument-hint`, `allowed-tools`, `model`, `skills`, and `disable-noninteractive` (all hyphenated). An unknown key is ignored but the command still loads.
35
+ - **A description or a non-empty body is required** — otherwise the command is dropped. When `description` is absent, the first non-empty body line is used.
36
+ - Argument substitution: `$ARGUMENTS` is the full argument string; `$1`/`$2` are positional (out of range is empty). When arguments are supplied but no placeholder is present, they are appended under a "User arguments:" heading.
37
+ - `skills` are auto-mounted. Inline dynamic shell (`` !`cmd` `` or a fenced `!` block) is rejected.
38
+
39
+ ## 4. How to inspect commands
40
+
41
+ - **In the client**: type **`/`** in the input box and open the **Commands** group; you can search by keyword. Each entry shows its name and description.
42
+ - **As an agent**: read the `.md` files at each location in discovery order. Derive each command's name from its path (subdirectories become `:`), and remember that for a same-named command the **first** in discovery order is the one that runs.
43
+
44
+ ## 5. Common pitfalls (symptom → cause → fix)
45
+
46
+ 1. **Missing — wrong directory** — the `.md` is not under a scanned root (for example a singular `.zcode/command/`, or above the repository root). → Move it into `~/.zcode/commands/` or `<repo>/.zcode/commands/`.
47
+ 2. **Missing — invalid name** — the file exists but no command appears. The file name violates the pattern (uppercase, spaces, dots, leading `-`/`_`, or over 64 characters). → Rename to a valid lowercase name; namespace with subdirectories (which become `:`), not dots.
48
+ 3. **Overridden by a higher-precedence duplicate** — a different command runs, or your edits have no effect. First match wins. → Find the higher-precedence copy in discovery order and rename or remove it. Local files always beat plugins.
49
+ 4. **Frontmatter parse error** — a key is silently missing. The flat parser reads only single-line top-level keys; indented lines and multi-line arrays are dropped. → Keep every value on one line; write lists inline, e.g. `allowed-tools: Read, Bash`.
50
+ 5. **Empty command is dropped** — both the description and the body are empty. → Add a `description:` or at least one non-empty body line.
51
+ 6. **Unknown frontmatter key (misspelling)** — `model`/`skills`/`allowed-tools` have no effect. → Use the hyphenated keys: `allowed-tools` (not `allowed_tools`), `argument-hint`, `disable-noninteractive`.
52
+ 7. **`$ARGUMENTS`/`$1` does not substitute** — the placeholder appears literally or is empty. The body has no placeholder (arguments are appended under "User arguments:" by design), `$1` is out of range, or a form like `${ARGUMENTS}` is not recognized. → Use the exact `$ARGUMENTS`/`$1` tokens.
53
+ 8. **Dynamic shell is rejected** — running the command reports an unsupported shell expansion. The body contains `` !`...` `` or a fenced `!` block. → Remove it; use static text or `$ARGUMENTS`.
54
+ 9. **A plugin command is missing** — a disabled plugin contributes no command roots, or a local same-named file is shadowing it. → Enable the plugin in **Settings → Plugin Management**, and ensure no local duplicate shadows it.
55
+ 10. **Disabled by configuration** — a valid command silently disappears. The configuration disables it by the command file's absolute path (not the command name). → Set that path's `enable` to `true` or remove it.
56
+ 11. **`/` versus `:` confusion** — `/review/code` reports not found although `review/code.md` exists. Subdirectories map to `:`, so the real name is `review:code`. → Invoke `/review:code`.
57
+ 12. **Reserved-name collision (interactive only)** — the command exists on disk but cannot be triggered in the live `/` menu, because its name matches a built-in slash command or `compress`. → Rename to a non-reserved name.
58
+
59
+ ## 6. Localization workflow (in order)
60
+
61
+ 1. **Is it in the `/` menu?** Open the Commands group. Absent → step 2. Present but the wrong content runs → step 4 (a duplicate).
62
+ 2. **Confirm the file and its root.** Ensure the `.md` sits directly under a scanned commands root for the current working directory — pitfall 1 — and that its name is valid — pitfall 2.
63
+ 3. **Check the frontmatter.** A missing/garbled key points to the flat-parser rules (pitfall 4) or an empty command (pitfall 5); a key with no effect is likely a misspelling (pitfall 6).
64
+ 4. **Resolve a duplicate.** For a given name, the winner is the first in discovery order; find and rename or remove the copy you do not want.
65
+ 5. **Check the body.** Verify the argument placeholders (pitfall 7) and that there is no rejected dynamic shell (pitfall 8).
66
+ 6. **Still missing with no obvious cause?** Check for a configuration disable (pitfall 10, by absolute file path), a disabled plugin (pitfall 9), or reserved-name filtering (pitfall 12).
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: diagnosing-hooks
3
+ description: Use to diagnose and fix ZCode hook configuration problems in the ZCode client. Applies when a hook does not trigger, an event name is wrong, a matcher does not match a tool name, a script is not executable, template variables are not expanded, a timeout unit is mistaken (seconds versus milliseconds), the command and process field styles are mixed, a hook's JSON output fails validation, a hook blocks the session unexpectedly, or configuration-file hooks are not enabled. Provides configuration sources, the hooks.json schema, how to inspect hooks in the client, and a step-by-step localization and repair workflow.
4
+ ---
5
+
6
+ # Diagnosing Hook Configuration
7
+
8
+ Goal: reduce any hook problem to a single concrete fix.
9
+
10
+ > Note on trust: plugin hooks execute regardless of the marketplace they came from — third-party plugin hooks run just like built-in ones. Any "diagnostic-only until trusted" wording you may see for marketplace hooks is stale; a plugin's detail view marks each hook as runnable, and that is now true for all hooks.
11
+
12
+ ## 1. Configuration sources and merging
13
+
14
+ - **Configuration-file hooks**: the top-level `hooks` key in `~/.zcode/cli/config.json` (or the workspace `<repo>/.zcode/config.json` / `zcode.json`), shaped as `{ enabled?, timeoutMs?, maxOutputBytes?, events: { <Event>: [ { matcher?, hooks: [...] } ] } }`. **These are disabled by default — configuration-file hooks must set `hooks.enabled: true` to run.**
15
+ - **Plugin hooks**: each plugin's `hooks/hooks.json` (or its manifest `hooks` field). Plugin matchers are appended after configuration matchers. **When any plugin contributes a hook, the hook runner is enabled automatically.**
16
+ - Non-plugin (user or workspace) configuration hooks have no trust gate; with `enabled: true` they run unconditionally.
17
+
18
+ ## 2. hooks.json schema
19
+
20
+ ```json
21
+ { "hooks": { "<Event>": [ { "matcher": "...", "hooks": [ { "type": "command"|"process", ... } ] } ] } }
22
+ ```
23
+
24
+ (A plugin file uses the outer `hooks` wrapper; the configuration file uses `hooks.events.<Event>`. The inner array is the same.)
25
+
26
+ - **Event names (exactly seven)**: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PermissionRequest`, `PostToolUse`, `PostToolUseFailure`, `Stop`. Any other name is an unsupported event. (Events such as `Notification`, `SubagentStop`, and `PreCompact` are **not** supported.)
27
+ - **The matcher is a case-sensitive regular expression**, tested against the event's match value:
28
+ - `SessionStart` → one of `startup`, `resume`, `clear`, `compact`
29
+ - Tool events (`PreToolUse`, `PostToolUse`, `PermissionRequest`, `PostToolUseFailure`) → the **tool name** (`Bash`, `Read`, `Write`, `Edit`, `Agent`, …), with aliases `Task` ↔ `Agent` and `Write`/`Edit` ← `ApplyPatch`
30
+ - `UserPromptSubmit` → the prompt text; `Stop` → the response preview
31
+ - An omitted matcher matches everything; an invalid regular expression never matches (silently)
32
+ - **`type: "command"`**: `command` (a shell string); optional `shell`, `timeout` (in **seconds**), `timeoutMs` (in milliseconds, takes precedence), and `statusMessage`. Note that `async` currently has no runtime effect.
33
+ - **`type: "process"`**: `command` (an executable) plus `args[]` (an argument vector run without a shell, the most portable choice), `timeoutMs` (in **milliseconds**), and `statusMessage`.
34
+ - Timeout resolution: `timeoutMs` → `timeout × 1000` → the configuration's `timeoutMs` → a default of 60000 ms.
35
+ - Template variables (expanded in the command and each argument, and also injected as environment variables): `${CLAUDE_PROJECT_DIR}` / `${ZCODE_PROJECT_DIR}`, `${CLAUDE_SESSION_ID}`; and, for plugin hooks only, `${CLAUDE_PLUGIN_ROOT}` / `${ZCODE_PLUGIN_ROOT}` and the plugin data directory. Note that a skill-directory variable is not valid in a hook and raises an error.
36
+ - **Hook output**: standard output is parsed as JSON (a strict schema — any extra key fails validation), or you may use exit codes: `0` passes, `2` blocks (a deny for `PreToolUse`/`PermissionRequest`), and any other non-zero raises an error. `additionalContext` is injected into the conversation; `PreToolUse` may return a permission decision of `allow`/`ask`/`deny`; `Stop` may request continuation (up to three times).
37
+
38
+ ## 3. How to inspect hooks
39
+
40
+ - **In the client**: **Settings → Plugin Management** → open a plugin's detail view to see the hooks it registers and whether each is runnable.
41
+ - **As an agent**: read the `hooks/hooks.json` (or the manifest `hooks` field) for a plugin, and the `hooks` block of `~/.zcode/cli/config.json` / the workspace config for configuration hooks.
42
+ - **Execution** (fired, timed out, blocked) is recorded in the ZCode log, with the hook's source, matcher, outcome, duration, and a preview of its error stream — enough to distinguish a timeout from a failure from a block.
43
+
44
+ ## 4. Common pitfalls (symptom → cause → fix)
45
+
46
+ 1. **Configuration-file hooks do not run** — you added `hooks.events.*` but nothing fires. They are disabled by default and are enabled automatically only when a plugin hook is present. → Set `"hooks": { "enabled": true, ... }` in the configuration.
47
+ 2. **Wrong event name** — the hook never triggers. → Use exactly one of the seven supported events.
48
+ 3. **Matcher does not match (tool name, case, or regex)** — it is registered but never fires for the tool you expect. The matcher is a case-sensitive regular expression; `"bash"` will not match `Bash`, and an invalid expression never matches. → Use the exact tool name or a correct expression (for example `"Edit|Write"`), or omit the matcher to match all. Remember the aliases `Task` → `Agent` and `Write`/`Edit` → `ApplyPatch`.
49
+ 4. **Script is not executable** — `permission denied`, with a failed outcome. The script was installed without the executable bit. → Run `chmod +x` on it, or invoke it through an interpreter, e.g. `{"type":"command","command":"bash \"${CLAUDE_PLUGIN_ROOT}/hooks/x.sh\""}`, so the executable bit is irrelevant.
50
+ 5. **Template variable not expanded** — a literal `${...}` or an empty path. Only recognized variables are expanded; a skill-directory variable raises an error inside a hook, and `${CLAUDE_PLUGIN_ROOT}` is available only for plugin hooks. → Use only supported variables, and `${CLAUDE_PLUGIN_ROOT}` for plugin-relative paths.
51
+ 6. **Timeout unit mistaken** — the hook is killed with a timed-out outcome. `command`'s `timeout` is in **seconds**; `process`'s `timeoutMs` is in **milliseconds**. `timeout: 500` means 500 seconds; `timeoutMs: 5` means 5 milliseconds. → Use `"timeout": <seconds>` for a command hook and `"timeoutMs": <milliseconds>` for a process hook.
52
+ 7. **Command and process fields mixed** — the hook is dropped. A `process` hook accepts only `command`, `args`, and `timeoutMs`; a `command` hook accepts `command`, `shell`, `timeout`, and `timeoutMs`. → Match the fields to the `type`.
53
+ 8. **JSON output fails validation** — the hook ran but its effect was discarded and the run marked failed. The output was not valid JSON, contained an extra key (the schema is strict), or its event-specific output named the wrong event. → Emit only the recognized keys with the correct event name, or emit nothing (empty output is fine) and rely on exit codes.
54
+ 9. **Assuming `async` runs in the background** — you set `async: true` but the session still waits. The `async` field has no runtime effect and hooks always run inline. → Do not rely on `async`; for background work, have the script daemonize itself.
55
+ 10. **Cross-platform failure** — it works on one operating system but not another. A `command` hook runs through a shell, so POSIX syntax fails on Windows. → Prefer a `process` hook (an argument vector, no shell), or ship a polyglot wrapper script and keep hook scripts extensionless.
56
+ 11. **A hook blocks the session unexpectedly** — a tool is denied or the run halts. The hook returned a block, exited with code 2, or returned a `deny` decision. → Inspect the block's reason in the log; fix the script's exit code — return 0 to pass and reserve 2 for a deliberate block.
57
+ 12. **Believing third-party hooks are "diagnostic only"** — a third-party plugin hook did not run and you suspect a trust gate. That is not the cause: all plugin hooks are runnable. → Diagnose via pitfalls 2, 3, 4, and 8.
58
+
59
+ ## 5. Localization workflow (in order)
60
+
61
+ 1. **Is a runner active?** Confirm that either `hooks.enabled: true` is set in the configuration or at least one plugin contributes a hook; otherwise no runner exists and every hook is skipped.
62
+ 2. **Enumerate what is registered.** In **Settings → Plugin Management**, open the plugin's detail view and confirm the hook you expect is present and runnable, and that its plugin is enabled. For configuration hooks, read the `hooks` block directly.
63
+ 3. **Event name and matcher.** Check against the seven events; confirm the match value and the case-sensitive expression; test by omitting the matcher (which matches everything).
64
+ 4. **Executable and interpreter.** Confirm the script has its executable bit, or invoke it explicitly via `bash`/`node`.
65
+ 5. **Run it by hand.** Feed a sample hook input to the script and inspect the exit code and output — `0` plus valid JSON is healthy, `2` is a deliberate block, any other non-zero is a failure.
66
+ 6. **Observe live.** Trigger the event and read the hook run records in the log (outcome, duration, error-stream preview) to distinguish a timeout from a failure from a block.
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: diagnosing-mcp
3
+ description: Use to diagnose and fix ZCode MCP (Model Context Protocol) server configuration problems in the ZCode client. Applies when an MCP server will not connect, its tools (mcp__server__tool) do not appear, it shows as disabled or failed, connections time out, a command cannot be found, template variables are not expanded, or a server defined in a configuration file has no effect. Provides configuration locations, how to inspect status in Settings, common pitfalls, and a step-by-step localization and repair workflow.
4
+ ---
5
+
6
+ # Diagnosing MCP Configuration
7
+
8
+ Goal: reduce any MCP problem to a single concrete file-field edit. A person inspects status from the client; an agent reads and edits the configuration files directly.
9
+
10
+ > Key points that are often misunderstood: the user configuration file is `~/.zcode/cli/config.json`; `.agents/mcp.json` is a **compatibility fallback** (read only when the same scope's `.zcode` has no MCP servers); and in the desktop client, MCP status and repair live under **Settings → MCP**.
11
+
12
+ ## 1. Configuration locations and precedence
13
+
14
+ | Scope | File | Field |
15
+ |---|---|---|
16
+ | User | `~/.zcode/cli/config.json` | `mcp.servers` |
17
+ | User (fallback) | `~/.agents/mcp.json` | `mcpServers` (used only if `~/.zcode/cli/config.json` has no MCP servers) |
18
+ | Workspace | `<repo>/.zcode/config.json` or `<repo>/zcode.json` (every directory from the repository root down to the working directory is read) | `mcp.servers` |
19
+ | Workspace (fallback) | `<repo>/.agents/mcp.json` | `mcpServers` (used only if the workspace `.zcode` has no MCP servers) |
20
+ | Plugin | `<pluginRoot>/.mcp.json` or the manifest's `mcpServers` field | Keys are namespaced as `plugin:<plugin>:<server>` |
21
+
22
+ Within each scope, `.zcode` takes priority and `.agents/mcp.json` is a same-scope fallback: if that scope's `.zcode` defines any MCP server, its `.agents/mcp.json` is ignored entirely. Note the different key shape — `.zcode` uses nested `mcp.servers`, while `.agents/mcp.json` uses a top-level `mcpServers`.
23
+
24
+ Override order across scopes for a same-named server: **CLI → environment → user → workspace → system**. In short, **user overrides workspace**. Plugin-provided servers form the base layer and are overridden by explicit configuration.
25
+
26
+ **Auto-connect**: MCP servers from every scope — user, **workspace**, plugin, environment, and CLI — are **trusted and connected automatically** at session start. Workspace-scoped servers were previously untrusted (reported `Project MCP server requires explicit connection before use.`); they now connect by default like any other scope. Use **Settings → MCP** as the supported client surface for inspecting status and repairing configuration.
27
+
28
+ ## 2. Configuration schema
29
+
30
+ - `stdio`: requires `command`; optional `args[]`, `cwd`, `env`, `enabled`, `timeoutMs`.
31
+ - `http` / `sse`: requires `url`; optional `headers`, `enabled`, `timeoutMs`.
32
+ - Standard field names are `env` for stdio environment variables and `headers` for HTTP/SSE request headers. `command` is a string and `args` is an array of strings; do not paste OpenCode-style `command: ["npx", "-y", "..."]` into ZCode's JSON editor.
33
+ - When `type` is omitted it is inferred: a `command` implies `stdio`, a `url` implies `http`. Legacy forms are migrated automatically when the CLI reads config directly (`type: "remote"` → `http`, `environment` → `env`, `enable` → `enabled`, `http_headers` → `headers`). Desktop app-managed session creation may bypass part of that CLI file parser, so prefer canonical fields (`env`, `headers`, `enabled`, `type: "http"`) in files that the desktop Settings → MCP page reads.
34
+ - The configuration-file server schema is **strict**: an **unknown key causes the server to be dropped**.
35
+ - **Template variables `${...}` are expanded only for plugin-provided MCP servers** (for example `${CLAUDE_PLUGIN_ROOT}` / `${ZCODE_PLUGIN_ROOT}`, `${CLAUDE_PROJECT_DIR}`, `${user_config.KEY}`). Configuration-file MCP servers do **not** expand templates — use absolute paths there.
36
+ - The default timeout is 30000 ms.
37
+
38
+ Canonical examples:
39
+
40
+ ```json
41
+ {
42
+ "mcp": {
43
+ "servers": {
44
+ "mysql-local": {
45
+ "type": "stdio",
46
+ "command": "npx",
47
+ "args": ["-y", "@benborla29/mcp-server-mysql"],
48
+ "env": {
49
+ "MYSQL_HOST": "127.0.0.1",
50
+ "MYSQL_PORT": "3306"
51
+ }
52
+ },
53
+ "remote-reader": {
54
+ "type": "http",
55
+ "url": "https://example.com/mcp",
56
+ "headers": {
57
+ "Authorization": "Bearer ..."
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## 3. How to inspect status
66
+
67
+ - **List and status**: open **Settings → MCP** in the client. Each entry shows whether the server is connected, disabled, disconnected, or failed, with any error inline. Plugin-provided servers are marked as built-in. (`untrusted` is a legacy status that no longer appears for normally configured servers now that every scope auto-connects.)
68
+ - **After edits**: restart the affected session, or restart ZCode if the Settings page still shows stale data, then reopen **Settings → MCP** to confirm the server status.
69
+ - **Standard-I/O error output** (the root cause of most failures): a stdio server's captured error stream is written to the ZCode log. To see the full output, run the server's `command` with its arguments directly in a terminal.
70
+
71
+ ## 4. Common pitfalls (symptom → cause → fix)
72
+
73
+ 1. **Workspace server does not connect** — a server defined in `<repo>/.zcode/config.json` (or `<repo>/.agents/mcp.json`) is not connecting. Workspace servers now auto-connect like any other scope, so this is no longer a trust gate — the cause is a real config or startup problem. → Check its **Settings → MCP** status: `failed` → go to step 4; absent → the config was not loaded (pitfall 5/9) or it is in `.agents/mcp.json` but shadowed (pitfall 12).
74
+ 2. **`command not found`** — the server shows `failed` with an error such as `spawn npx ENOENT`. The `command` is not on `PATH`, or a relative path was not resolved. → Use an absolute path, add `cwd` when needed, and on Windows point at the `.cmd`/`.exe`.
75
+ 3. **`${...}` reaches the process literally** — configuration-file MCP servers do not expand templates. → Use concrete absolute paths (templates are a plugin-only feature).
76
+ 4. **Plugin is missing an environment value or secret** — the plugin reports a missing variable. → Set the plugin's configuration value (Plugin Management → the plugin's advanced settings) or export the required environment variable; sensitive values may only be placed in `env`/`headers`, not in `command`/`url`.
77
+ 5. **Wrong transport type or unknown key** — the server is silently dropped. → Make `type` match the fields, remove any extra top-level keys (the schema is strict), and ensure exactly one of `command` (stdio) or `url` (http/sse) is present.
78
+ 6. **Unexpected override** — editing the workspace `mcp.servers` entry has no effect. A same-named server in the user configuration is shadowing it (user overrides workspace for MCP). → Edit the user entry, or rename one of the servers.
79
+ 7. **Connection or tool-listing timeout** — `failed ... timed out after 30000ms`. → Add `"timeoutMs": 60000` to that server, and address the slow startup.
80
+ 8. **Only `Connection closed` with no cause** — the error stream was not surfaced in the status line. → Check the ZCode log for the captured error output, or run the `command` with its arguments in a terminal.
81
+ 9. **JSON syntax error in the configuration file** — MCP servers (and possibly the whole file) go missing. → Validate the JSON, then fix the syntax.
82
+ 10. **Server shows as disabled** — `enabled: false` (or legacy `enable: false`). → Set `"enabled": true` or remove the field.
83
+ 11. **A desktop-managed server list overrides the file** — edits to configuration files have no effect because the client is supplying the MCP list. → Manage MCP through **Settings → MCP** in that context.
84
+ 12. **`.agents/mcp.json` edits have no effect, or use the wrong key** — a server added to `.agents/mcp.json` never appears. Either the same scope's `.zcode` already defines MCP servers (so `.agents/mcp.json` is ignored entirely for that scope), or the servers were placed under `mcp.servers` instead of the top-level `mcpServers` that `.agents/mcp.json` expects. → Move the definition into the `.zcode` file for that scope, or ensure that scope's `.zcode` has no MCP servers and use the top-level `mcpServers` key in `.agents/mcp.json`.
85
+ 13. **Server name appears in logs but no MCP tools appear in the model request** — the desktop app read the server entry and passed its name to the runtime, but the server failed during startup, so `toolCount` and `registeredToolCount` are zero. A common cause is a legacy `environment` field in `~/.zcode/cli/config.json`: CLI direct config parsing can migrate it, but the desktop app-managed path currently expects `env` when converting to protocol `mcpServers`. → Rename `environment` to `env`, keep the values unchanged, restart ZCode, and reopen **Settings → MCP**.
86
+ 14. **Settings → MCP crashes after JSON editing with `command.trim is not a function`** — the saved server has a non-string `command`, usually OpenCode-style `command: ["npx", "-y", "server"]`. → Edit `~/.zcode/cli/config.json` manually: set `"command": "npx"` and move the rest into `"args": ["-y", "server"]`, then restart the app.
87
+
88
+ ## 5. Localization workflow (in order; stop when the cause is found)
89
+
90
+ 1. Confirm MCP is enabled (it is by default).
91
+ 2. Open **Settings → MCP** and read the status: `disabled` → pitfall 10; `failed (<error>)` → read the inline error and go to step 4; **not listed at all** → step 3. (`untrusted` should no longer appear for a normally configured server.)
92
+ 3. Verify the configuration is loaded and valid: check the JSON validity of `~/.zcode/cli/config.json` and `<repo>/.zcode/config.json` (and `zcode.json`) — pitfall 9. A server that is in the file but not listed failed schema validation (pitfall 5 — look for unknown keys, wrong `type`, or a missing `command`/`url`); a server defined only in `.agents/mcp.json` but not appearing points to the fallback shadowing or wrong-key issue (pitfall 12).
93
+ 4. Diagnose a `failed` server: `ENOENT` → pitfall 2; `timed out` → pitfall 7; `Connection closed` → pitfall 8; an http/sse network error → check proxy/CA, URL reachability, and `headers`.
94
+ 5. If **Settings → MCP** or service logs show `mcpServerCount` / server names but the model request has no `mcp__...` tools, check startup logs for `mcp.startup.completed` and `mcp.tools.registered`. If `toolCount=0` with failed statuses, inspect the config field names first (`env` vs `environment`, string `command` vs array `command`) before treating it as a model-selection issue.
95
+ 6. If edits have no effect → pitfall 6 (user overrides workspace) or pitfall 11 (desktop-managed list).
96
+ 7. If a `${...}` appears literally → pitfall 3 (configuration files do not expand templates) or pitfall 4 (an unset plugin variable).
97
+ 8. Apply the concrete fix — most commonly editing `~/.zcode/cli/config.json` at `mcp.servers.<name>` (`command` / `args` / `cwd` / `env` / `headers` / `timeoutMs` / `enabled`) — then restart the session (every scope auto-connects) and reopen **Settings → MCP** to confirm.
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: diagnosing-plugins
3
+ description: Use to diagnose and fix ZCode plugin and marketplace problems in the ZCode client. Applies when a plugin is not listed, adding a marketplace or installing a plugin fails, a plugin is enabled but its skills or commands are missing, a built-in plugin still appears after being disabled, a plugin is not enabled as expected, a plugin.json manifest has a parse error, a plugin name is invalid, a dependency is unresolved or blocked across marketplaces, or a sensitive configuration value cannot be entered in the interface. Provides the plugin lifecycle, manifest schema, how to manage plugins in the client, and a step-by-step localization and repair workflow.
4
+ ---
5
+
6
+ # Diagnosing Plugin Configuration
7
+
8
+ Goal: reduce any plugin problem to a single concrete fix.
9
+
10
+ Plugins are managed in **Settings → Plugin Management** — the **Installed** tab (enable/disable, view details, configure, uninstall) and the **Discover** tab (browse, install, and add marketplaces via the **`+`** button).
11
+
12
+ > Key facts: enable/disable state is stored under `plugins` in `~/.zcode/cli/config.json`; the official marketplace is `zcode-plugins-official`; and for cloning marketplace repositories behind a proxy, ZCode reads the proxy from `ZCODE_HTTP_PROXY` (a bare `http_proxy` is not used).
13
+
14
+ ## 1. Plugin lifecycle and persistence
15
+
16
+ - **Discovery sources** (first match wins): inline directories, bundled official plugins, the official plugin cache, and marketplace-installed plugins. The entire subsystem is governed by the `plugins.enabled` master switch.
17
+ - **Manifest location** (probed in order): `.zcode-plugin/plugin.json` (preferred), then `.claude-plugin/plugin.json`, then `.codex-plugin/plugin.json`. A plugin's identity is `<name>@<marketplace>`.
18
+ - **Enable/disable resolution**: an explicit enable/disable entry always wins; only when no entry exists does the plugin's default-enabled status apply. A disabled plugin still appears in the list as disabled, but its components resolve to nothing.
19
+ - **Persistence** (all under `plugins` in `~/.zcode/cli/config.json`): the enable/disable map, per-plugin configuration values, and the list of suppressed (uninstalled) built-in plugins. Because a built-in plugin ships with the application and cannot be deleted, "uninstalling" one records a suppression marker that hides it from discovery.
20
+ - **Built-in seeding**: on first launch, bundled official plugins are materialized into the plugin cache and registered in the official marketplace listing. This is idempotent and only re-materializes on a content or version change.
21
+
22
+ ## 2. Manifest schema
23
+
24
+ - **plugin.json**: requires `name` (matching `^[a-z0-9][a-z0-9._-]{0,127}$`); optional `version` (defaults to `0.0.0`), `description`, `commands`/`skills`/`hooks`/`mcpServers`, and `userConfig`.
25
+ - **Recorded but not executed**: `agents`, `channels`, `lspServers`, `outputStyles`, `settings`.
26
+ - Component paths are validated: an absolute path or one that escapes the plugin root is rejected as an invalid component path.
27
+ - **userConfig**: `type` is one of `string`, `number`, `boolean`, `directory`, or `file`, with `title`, `description`, `default`, `required`, and `sensitive`. A **sensitive value cannot currently be entered in the interface or persisted** to the configuration file.
28
+ - **marketplace.json**: `{ name, plugins[], pluginRoot?, allowCrossMarketplaceDependenciesOn? }`. Each `plugins[].source` may be a relative path string or an object of kind `directory`, `github`, `git`, `url`, or `git-subdir`; `npm` and `pip` are not supported.
29
+
30
+ ## 3. Managing plugins in the client
31
+
32
+ - **Install**: on the **Discover** tab, find the plugin card and click **Get**; when done it shows **Installed**. New plugins are enabled by default.
33
+ - **Enable / disable**: on the **Installed** tab, toggle the switch on the plugin's row. Disabling removes all of its components from the session immediately.
34
+ - **Configure**: open the plugin's detail view and expand **Advanced** to fill in its configuration values (required fields are marked; sensitive fields cannot be entered here).
35
+ - **Uninstall**: from the detail view; a built-in plugin can only be disabled, not uninstalled.
36
+ - **Add a marketplace**: the **`+`** button on the Discover tab accepts a GitHub repository, a Git URL, a local directory, or a file.
37
+
38
+ ## 4. Common pitfalls (symptom → cause → fix)
39
+
40
+ 1. **A plugin is not listed at all** — its marketplace was never added, so there is no installation record or cache; or `plugins.enabled` is false. → Add the marketplace on the Discover tab and install it, or set `plugins.enabled: true`.
41
+ 2. **Adding a marketplace or installing fails to clone** — an error such as `RPC failed`, `timed out`, or `early EOF` (after retries). The clone process did not inherit the shell proxy. → **Set `ZCODE_HTTP_PROXY=http://host:port`** (ZCode reads the proxy only from this variable; a bare `http_proxy` is ignored).
42
+ 3. **Enabled but its skills or commands are missing** — a component path escapes the plugin root, the plugin is actually disabled, or it is not being treated as enabled where the session reads it. → Open the plugin's detail view to see the invalid component, and make the manifest path relative and inside the plugin root.
43
+ 4. **A built-in plugin still appears after being disabled, or returns after uninstalling** — the suppression state was not applied where it was read. → Confirm the plugin id is in the suppressed-built-ins list in `~/.zcode/cli/config.json`; restoring it removes that entry and re-seeds.
44
+ 5. **Not enabled as expected — listed as enabled but a skill reports "not found" in the session** — the default-enabled set was not applied along the session's discovery path even though the listing shows it enabled. → Verify the plugin's skills are actually available in the session (via **Settings → Skills** and the `/` menu), not only that the plugin shows as enabled.
45
+ 6. **Manifest parse error** — the JSON is invalid, is not an object, or has a missing/invalid `name`. → Fix it into a valid object whose `name` matches the pattern.
46
+ 7. **Invalid plugin name** — the name violates `^[a-z0-9][a-z0-9._-]{0,127}$`. → Rename.
47
+ 8. **Unresolved or cross-marketplace dependency** — a dependency lives in another marketplace not listed in `allowCrossMarketplaceDependenciesOn`, is missing, or forms a cycle. → Add the target marketplace to `allowCrossMarketplaceDependenciesOn`, install the missing dependency's marketplace, or break the cycle. Dependencies are written as `name@marketplace`.
48
+ 9. **Version shows 0.0.0 or updates are not detected** — Git/URL plugins often lack a top-level version, and official plugins track updates by commit. → Confirm the installed record and the manifest entry both carry their source revision.
49
+ 10. **A sensitive configuration value cannot be set** — the field is disabled with a note that it requires secure storage. There is no secure credential store yet. → Remove `sensitive: true`, or provide the value out of band (for example via an environment variable); it cannot be persisted today.
50
+ 11. **A `filesystem`/`sea` source reports "unsupported"** — a built-in plugin's cache path is missing or stale. → Re-seed the plugin (clearing its cache entry so it is re-materialized on the next launch).
51
+
52
+ ## 5. Localization workflow (in order)
53
+
54
+ 1. **Is the subsystem on?** Check `plugins.enabled` (false means everything is empty).
55
+ 2. **Look at the plugin.** On the **Installed** tab, confirm whether the plugin is present and enabled; open its detail view for its source, components, and any warnings.
56
+ 3. **Classify by presence.** Entirely absent → a marketplace or installation problem (confirm the marketplace was added and the plugin installed). Present but disabled → check the enable state against the default. Present and enabled but broken at runtime → a component-path problem (pitfall 3) or a session-versus-listing divergence (pitfall 5).
57
+ 4. **Built-in issues.** Compare the suppressed-built-ins list against what the official marketplace offers, and confirm the plugin cache is current.
58
+ 5. **Installation and network.** Reproduce the clone with the proxy set, confirming `ZCODE_HTTP_PROXY`, and look for the retryable-error signatures.
59
+ 6. **Session-versus-listing divergence.** If the plugin shows enabled but its capabilities are absent in the session, treat it as a discovery-path problem: confirm the plugin's skills and commands actually appear in the session (Settings → Skills, the `/` menu), not merely that the plugin is enabled.
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: diagnosing-skills
3
+ description: Use to diagnose and fix ZCode skill configuration problems in the ZCode client. Applies when a skill is not discovered, is installed but does not trigger automatically, is shadowed by a higher-precedence skill of the same name, is disabled by configuration, has a SKILL.md frontmatter error, fails to load because its description is too long, or disappears because the plugin providing it is disabled. Provides the discovery order, how to inspect skills in the client, common pitfalls, and a step-by-step localization and repair workflow.
4
+ ---
5
+
6
+ # Diagnosing Skill Configuration
7
+
8
+ Goal: reduce any skill problem to a single concrete fix. A skill "loading successfully" and a skill "triggering" are two different things — distinguish them first.
9
+
10
+ A person inspects skills in **Settings → Skills** and the **`/` menu** (the Skills group); an agent inspects by reading the skill files at the locations below.
11
+
12
+ ## 1. Discovery order (earlier locations take precedence)
13
+
14
+ 1. Explicitly configured roots
15
+ 2. User `~/.zcode/skills`
16
+ 3. User `~/.agents/skills`
17
+ 4. Workspace `.zcode/skills` (from the current directory up to the repository root; every level counts, and a deeper location wins)
18
+ 5. Workspace `.agents/skills`
19
+ 6. Enabled **plugin** roots (lowest precedence)
20
+
21
+ Within a level, `.zcode` is scanned before `.agents`. A skill's identity is its **file path**, so same-named skills at different paths are **all discovered**, but only the first in discovery order is loaded — higher-precedence copies shadow the rest. Directories beginning with `.` (except `.system`) and `node_modules` are skipped.
22
+
23
+ ## 2. SKILL.md format (two-tier failure model)
24
+
25
+ A skill is a directory containing a `SKILL.md`. Frontmatter is a `---`-delimited block of flat `key: value` lines (indented keys are ignored; use `>` or `|` for multi-line values). The recognized keys are `name`, `description`, `when_to_use`, `license`, and `metadata`.
26
+
27
+ **Fails to load (the skill is dropped)**: frontmatter is present but `name` is missing, `description` is missing, or `description` exceeds 1024 characters.
28
+
29
+ **Loads but may not trigger**: no frontmatter at all — `name` defaults to the directory name and `description` is empty, leaving the model nothing to match on; a malformed line is skipped.
30
+
31
+ **Triggering**: a skill's `name`, `description` (truncated to ~250 characters), and `when_to_use` are presented to the model, which decides on its own whether to invoke the skill. There is no keyword matcher — **a description that clearly states "when to use this" is what makes a skill discoverable to the model.**
32
+
33
+ ## 3. How to inspect skills
34
+
35
+ - **In the client**: **Settings → Skills** lists every discovered skill and its group, including a **Plugin Skills** group for plugin-provided ones. In the input box, type **`/`** and open the **Skills** group to see what is available and search by keyword.
36
+ - **As an agent**: read the `SKILL.md` at each location in discovery order. The file that would actually load is the **first** one whose frontmatter `name` (or the plugin's `plugin:skill` qualified name) matches — if that is not the file you edited, you have found a shadow.
37
+
38
+ ## 4. Common pitfalls (symptom → cause → fix)
39
+
40
+ 1. **Not discovered — wrong directory** — absent from the Skills list. It is not directly under a discovery root, or the file is not named `SKILL.md` (case-sensitive on Linux). → Move the skill directory under a real root: `~/.zcode/skills/<name>/SKILL.md` or `<repo>/.zcode/skills/<name>/SKILL.md`.
41
+ 2. **Skipped inside a dot-directory** — a skill under, for example, `~/.zcode/skills/.foo/` never appears. Directories beginning with `.` (except `.system`) are excluded. → Rename to remove the leading `.`.
42
+ 3. **Not triggering — weak or empty description** — it appears but the model never invokes it. Without frontmatter the description is empty, and it is truncated to ~250 characters when presented. → Add a frontmatter `description` and `when_to_use`, front-loading the trigger wording within the first ~250 characters.
43
+ 4. **Shadowed by a higher-precedence skill of the same name** — your edits have no effect. On load the first same-named skill wins; user overrides workspace overrides plugin, and a deeper working-directory location overrides the repository root. → Find the higher-precedence copy in discovery order and rename or remove it.
44
+ 5. **Disabled by configuration** — a known-good skill disappears entirely. The configuration disables it by absolute path. → In `~/.zcode/cli/config.json` (or the workspace `.zcode/config.json`), set that path's `enable` to `true` or remove the override.
45
+ 6. **Frontmatter parse error or wrong shape** — `name`/`description` missing or garbled. The parser reads only top-level scalars; indented keys are ignored, and multi-line values need `>` or `|`. → Keep `name`/`description` as top-level scalars and use `description: >` with an indented continuation for long text.
46
+ 7. **Missing SKILL.md** — the directory exists but the skill never appears. → Ensure the file is named exactly `SKILL.md`.
47
+ 8. **Description too long (over 1024 characters)** — the skill is dropped. → Trim `description` under 1024 characters and move detail into the body.
48
+ 9. **An `.agents` copy is shadowed by a same-named `.zcode` copy** — it is discovered but the `.zcode` copy is what loads, because `.zcode` is scanned first within a level. → Remove the `.zcode` duplicate or rename one.
49
+ 10. **A plugin skill disappears because the plugin is disabled or suppressed** — a disabled plugin contributes no skill roots. → Enable the plugin in **Settings → Plugin Management**, or remove it from the suppressed-built-ins list.
50
+ 11. **Path-versus-name confusion** — a skill is invoked by `name` or `plugin:skill`, not by file path and not with a leading `/`. → Reference the exact name.
51
+ 12. **The whole skill subsystem is off** — no skills appear and the skill tool reports it is not configured. The skill feature or `skills.enabled` is false. → Set both to `true` (both default to true).
52
+
53
+ ## 5. Localization workflow (in order; stop when the cause is found)
54
+
55
+ 1. **Is the subsystem on?** In `~/.zcode/cli/config.json` (and the workspace file) confirm the skill feature and `skills.enabled`; either being false disables discovery — pitfall 12.
56
+ 2. **Is it discovered at all?** Check **Settings → Skills**, and read the skill files from the **same working directory the session runs in** (discovery is relative to it). Absent entirely → pitfalls 1, 2, 5, 7, 10, or 12.
57
+ 3. **Check for load failures.** A skill present on disk but not listed usually has a frontmatter problem: missing `name`/`description`, an over-long `description`, or a malformed frontmatter line — pitfalls 6 and 8.
58
+ 4. **Which file actually wins?** Walk the discovery order for the name and compare the first matching `SKILL.md` to the file you edited. A mismatch means shadowing — pitfalls 4 and 9.
59
+ 5. **Is it disabled?** Look in both configuration files for the skill's absolute path with `enable: false`.
60
+ 6. **A plugin skill?** If the name is `plugin:skill`, confirm the plugin is enabled and not suppressed.
61
+ 7. **Discovered but will not trigger?** Inspect the `description`/`when_to_use`; empty or overly long/truncated → pitfall 3.
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: zcode-configuration-guide
3
+ description: Use when configuring ZCode's extension resources (MCP servers, slash commands, skills, hooks, and plugins) or instruction files such as AGENTS.md in the ZCode client. Explains where each resource is configured at the user and workspace scope, the discovery order, precedence, and merge rules, plus guidance on which location to choose. Use when someone asks how to add an MCP server, command, skill, hook, plugin, or AGENTS.md instructions, where a configuration file lives, why a configuration is not taking effect, or needs routing to a specific diagnostic skill.
4
+ ---
5
+
6
+ # ZCode Configuration Guide
7
+
8
+ ZCode supports five types of extension resources, plus AGENTS.md instruction files. This skill is the **map**: it tells you where each resource is configured and how conflicts are resolved. For "something is not working, how do I fix it," follow the routing to the `diagnosing-*` skills at the end.
9
+
10
+ ## How things are configured
11
+
12
+ There are two ways to work with configuration in the ZCode client, and this plugin serves both:
13
+
14
+ - **A person** manages resources through the client's graphical interface — **Settings → Plugin Management**, **Settings → Skills**, **Settings → Subagents**, **Settings → MCP**, and the **`/` menu** in the input box.
15
+ - **An agent** repairs configuration by reading and editing the underlying files directly with its file tools. The locations and rules below are what an agent uses to find the right file and field.
16
+
17
+ ## Scopes and the main configuration files
18
+
19
+ - **User scope** — lives under your home directory and applies to every workspace.
20
+ - **Workspace scope** — lives inside a repository and applies only to that project; can be shared with a team through version control.
21
+ - **User configuration file**: `~/.zcode/cli/config.json`. Holds MCP servers, hooks, plugin enable/disable state, and skill/command disable overrides.
22
+ - **Workspace configuration file**: `<repo>/.zcode/config.json` (or `<repo>/zcode.json`).
23
+ - **User instruction file**: `~/.zcode/AGENTS.md`. Applies as default instructions for every workspace.
24
+ - **Workspace instruction file**: `<repo>/AGENTS.md`. Applies only to that project; the current workspace path is searched upward until the project root.
25
+
26
+ ## The five resources at a glance
27
+
28
+ | Resource | Form | User scope | Workspace scope | Conflict rule |
29
+ |---|---|---|---|---|
30
+ | **Skills** | Directory + `SKILL.md` | `~/.zcode/skills/`, `~/.agents/skills/` | `<repo>/.zcode/skills/`, `<repo>/.agents/skills/` | Identity is the file path; on load the **first same-named skill wins** (user scope has priority) |
31
+ | **Commands** | `.md` file | `~/.zcode/commands/`, `~/.agents/commands/` | `<repo>/.zcode/commands/`, `<repo>/.agents/commands/` | Deduplicated by normalized command name; **first match wins** (user scope overrides workspace), the loser is ignored |
32
+ | **MCP** | JSON object | `~/.zcode/cli/config.json` → `mcp.servers` (fallback `~/.agents/mcp.json` → `mcpServers`) | `<repo>/.zcode/config.json` → `mcp.servers` (fallback `<repo>/.agents/mcp.json` → `mcpServers`) | **User overrides workspace** for a same-named server; workspace-scoped servers are **trusted and auto-connected** by default, same as user-scoped |
33
+ | **Hooks** | `hooks.json` / config object | `~/.zcode/cli/config.json` → `hooks` | `<repo>/.zcode/config.json` → `hooks` | Configuration-file hooks require `hooks.enabled: true`; plugin hooks are appended |
34
+ | **Plugins** | Directory + `plugin.json` | Installed from a marketplace; enable/disable state stored in `~/.zcode/cli/config.json` | — | A plugin contributes skills, commands, hooks, MCP servers, and agents |
35
+ | **Instructions** | `AGENTS.md` file | `~/.zcode/AGENTS.md` | `<repo>/AGENTS.md` | User default instructions load first, then workspace instructions load later so the workspace can narrow or override broad defaults |
36
+
37
+ > Note: `.agents/mcp.json` is a **compatibility fallback** for MCP. Within each scope the client reads `.zcode` first; only if that scope has no MCP servers does it fall back to `.agents/mcp.json` (which uses a top-level `mcpServers` key, whereas `.zcode` uses nested `mcp.servers`).
38
+
39
+ ## Instructions / AGENTS.md: merge order
40
+
41
+ `AGENTS.md` is not a skill, command, hook, MCP server, or plugin. It is the instruction file ZCode loads into the model context for broad behavior rules.
42
+
43
+ - **User scope**: `~/.zcode/AGENTS.md`. Use this for personal defaults that should apply in every workspace, such as preferred language, review style, or local workflow conventions.
44
+ - **Workspace scope**: `<repo>/AGENTS.md`. Use this for repository-specific rules that should be shared with the project, such as architecture boundaries, logging rules, testing requirements, and commit/MR policy.
45
+ - **Resolution**: ZCode searches for the workspace `AGENTS.md` from the current working directory upward until the detected project root. The user default file is resolved from the user's home directory.
46
+ - **Merge order**: when both files exist, ZCode injects `~/.zcode/AGENTS.md` first, then the resolved workspace `AGENTS.md`. Workspace instructions appear later, so they can narrow or override broad user defaults for that repository.
47
+ - **Migration and creation**: onboarding can copy Claude user memory from `~/.claude/CLAUDE.md` into `~/.zcode/AGENTS.md`. The built-in `/init` command targets the current workspace `AGENTS.md`, creating or updating repository instructions instead of editing the user default file.
48
+
49
+ ## Skills and commands: discovery order (identical)
50
+
51
+ Locations are scanned in this order (earlier locations take precedence):
52
+
53
+ 1. Explicitly configured roots
54
+ 2. User `~/.zcode/skills` (or `commands`)
55
+ 3. User `~/.agents/skills`
56
+ 4. Workspace `.zcode/skills` (from the current directory up to the repository root; every level counts)
57
+ 5. Workspace `.agents/skills`
58
+ 6. Enabled **plugin** roots (lowest precedence)
59
+
60
+ Within a level, `.zcode` is scanned before `.agents`. A deeper working-directory location takes precedence over a repository-root location.
61
+
62
+ - **Skills merge**: identity is the file path, so same-named skills at different paths are **all discovered**, but only the first in discovery order is loaded — higher-precedence copies shadow the rest.
63
+ - **Commands merge**: the key is the normalized command name, and the **first match wins**; duplicates are ignored. Nested directories join into the name with a colon: `review/code.md` becomes `/review:code` (not `/review/code`).
64
+
65
+ ## MCP: merge and auto-connect
66
+
67
+ - **Override order** for a same-named server: CLI override → environment → user → workspace → system defaults. In short, **user overrides workspace**. Plugin-provided servers form the base layer and are overridden by explicit configuration.
68
+ - **Auto-connect**: MCP servers from every scope — user, **workspace**, plugin, environment, and CLI — are **trusted and connected automatically** at session start. (Workspace-scoped servers were previously untrusted and required manual authorization; they now connect by default like any other scope.) Use **Settings → MCP** to inspect status and repair server configuration.
69
+
70
+ ## Hooks: essentials
71
+
72
+ - Supported events (exactly seven): `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PermissionRequest`, `PostToolUse`, `PostToolUseFailure`, `Stop`.
73
+ - **Configuration-file hooks must set `hooks.enabled: true`** to run (disabled by default). When any plugin contributes a hook, the hook runner is enabled automatically.
74
+
75
+ ## Plugins: essentials
76
+
77
+ - Managed in **Settings → Plugin Management** (the **Installed** and **Discover** tabs). A plugin directory carries a manifest at `.zcode-plugin/plugin.json` (the compatibility names `.claude-plugin/` and `.codex-plugin/` are also recognized). The minimal manifest requires only `name` (matching `^[a-z0-9][a-z0-9._-]{0,127}$`).
78
+ - Component fields: `commands`, `skills`, `hooks`, `mcpServers`, `agents` (each may be a directory name, an array, or inline). The fields `channels`, `lspServers`, `outputStyles`, and `settings` are recorded but not executed.
79
+ - Enable/disable state is stored under `plugins` in `~/.zcode/cli/config.json`. A built-in plugin can be disabled but not uninstalled.
80
+ - Marketplaces can be added (via the **`+`** button on the Discover tab) from a GitHub repository, a Git URL, a local directory, or a file.
81
+
82
+ ## Choosing where to configure
83
+
84
+ - Personal, used across projects → user scope (`~/.zcode/...` or `~/.agents/...`).
85
+ - Team- or project-shared, versioned with the repository → workspace scope (`<repo>/.zcode/...` or `.agents/...`).
86
+ - Shared across tools (Claude, Codex, Cursor) → put skills in `~/.agents/skills/`; to override a same-named skill only inside ZCode, use `.zcode/skills/`.
87
+ - Personal default instructions → `~/.zcode/AGENTS.md`; repository-specific instructions → `<repo>/AGENTS.md`. If both exist, keep broad preferences in the user file and project rules in the workspace file.
88
+ - MCP servers → user configuration for personal servers, or workspace configuration to share with a team; both scopes connect automatically. Because opening a project now auto-connects the MCP servers declared in its configuration, only open workspaces you trust.
89
+ - Secrets → never commit them to version control; use environment variables or local settings.
90
+
91
+ ## When something is wrong — route to a diagnostic skill
92
+
93
+ When a configuration is read but has no effect, or reports an error, load the matching skill. Each provides a symptom → cause → check → fix workflow, covering both what to click in the client and which file and field an agent should edit:
94
+
95
+ - MCP server not connecting, tools missing, untrusted, or timing out → **`diagnosing-mcp`**
96
+ - A skill is not discovered, not triggering, shadowed, or disabled → **`diagnosing-skills`**
97
+ - A `/command` is missing, overridden, has a frontmatter error, or arguments do not substitute → **`diagnosing-commands`**
98
+ - A hook does not trigger, its matcher does not match, its script is not executable, or it blocks unexpectedly → **`diagnosing-hooks`**
99
+ - A plugin is not listed, fails to install, has missing components, or is not enabled → **`diagnosing-plugins`**