-
Notifications
You must be signed in to change notification settings - Fork 0
feat(markdown-format): add setup skill on the uniform contract (0.5.0) #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bb6a90d
feat(markdown-format): add setup skill on the uniform contract (0.5.0)
kyle-sexton 5d9afdc
fix(markdown-format): setup respects repo package manager + nested co…
kyle-sexton d0efc44
fix(markdown-format): setup matches hook risk criteria + packageManag…
kyle-sexton 482ca75
fix(markdown-format): setup validates shim like the hook, handles Yar…
kyle-sexton 02c555c
refactor(markdown-format): setup derives hook behavior from hook source
kyle-sexton 114d4e5
fix(markdown-format): setup installs for Yarn Classic, exposes instal…
kyle-sexton 98c809e
fix(markdown-format): setup queries yarn config get nodeLinker before…
kyle-sexton 8fd0127
fix(markdown-format): carve install-lint out of setup's no-write guar…
kyle-sexton d39f19a
fix(markdown-format): spell Plug'n'Play in full for the typos gate
kyle-sexton 87fbd58
Merge branch 'main' into feat/setup-contract-flagship
kyle-sexton 42660b3
Merge branch 'main' into feat/setup-contract-flagship
kyle-sexton 52a1bb7
fix(markdown-format): round-7 review — docs match the skill, shrinkwr…
kyle-sexton 435af2e
fix(markdown-format): setup check adds a --version liveness probe
kyle-sexton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| --- | ||
| name: setup | ||
| description: "Verify the markdown-format hook's runtime prerequisites and configuration for this repository. Use when: 'set up markdown-format', 'configure markdown-format', 'is markdown-format working', formatting silently isn't happening, or the hook reported a missing prerequisite. Actions: check (read-only verification, default) | apply (resolve what check found). Re-runnable and safe." | ||
| argument-hint: "check | apply [install-lint]" | ||
| user-invocable: true | ||
| disable-model-invocation: true | ||
| --- | ||
|
|
||
| ## Purpose | ||
|
|
||
| Thin check-centric setup per the uniform contract: `check` inspects and reports, `apply` | ||
| resolves. This plugin owns no consumer-project configuration — rules come from the | ||
| repository's own markdownlint config, and the only tunable is the native `userConfig` | ||
| toggle — so `apply` is guidance-and-verify, with exactly one write path: the explicitly | ||
| invoked `apply install-lint` dependency install described below. | ||
|
|
||
| Action routing: no argument or `check` runs the check; `apply` runs the check first, then | ||
| remediation; `apply install-lint` additionally authorizes the consumer-repo dependency | ||
| install described below. All are non-interactive — never prompt when the action is given. | ||
|
|
||
| ## `check` (read-only) | ||
|
|
||
| The hook script (`${CLAUDE_PLUGIN_ROOT}/hooks/markdown-format.sh`) is the single source of | ||
| truth for what it requires and how it resolves things. **Read it first** — probe what it | ||
| actually does, don't recite this file. Then run each probe via Bash and report a | ||
| PASS/FAIL/INFO table with one remediation line per FAIL. Do not modify anything. | ||
|
|
||
| 1. **Bash version** — check against the hook's documented floor (README Requirements), | ||
| noting any features the hook degrades without (for example telemetry's Bash builtin). | ||
| 2. **`jq`** — `command -v jq`. FAIL if absent: the hook then skips with a visible | ||
| once-per-session notice instead of formatting. | ||
| 3. **`markdownlint-cli2`** — resolve it exactly the way the hook's resolution code does | ||
| (its sanctioned lookup paths, including its symlink/escape validation of a repo-local | ||
| shim). A binary or shim the hook would reject must not PASS here. Then confirm the | ||
| resolved tool actually executes — run it with `--version` (a repo shim can resolve yet | ||
| still be broken: missing Node interpreter, dangling target); resolution without | ||
| successful execution is FAIL, with the execution error in the remediation line. FAIL | ||
| when nothing the hook would accept resolves. | ||
| 4. **Consumer markdownlint config** — mirror the hook's config walk: it loads configs from | ||
| an edited file's directory up to the repo root, so nested configs apply to nested files. | ||
|
kyle-sexton marked this conversation as resolved.
|
||
| Search the whole tree (skip `node_modules`), report the root config the cascade | ||
| discovers (or INFO that none exists — tool defaults then apply), list nested configs | ||
| with their directory scope, and surface the README's configuration trust boundary for | ||
| every config the hook's own risk collection (`collect_risky_configs`) would flag. | ||
| 5. **Hook toggle** — report the effective `markdown_format_enabled` value: | ||
| `${user_config.markdown_format_enabled}` (unexpanded or empty means default `true`). | ||
| 6. **Hook registration** — INFO: confirm the plugin is enabled for this project | ||
| (`/plugin` → Installed) rather than parsing settings files. | ||
|
|
||
| ## `apply` (idempotent) | ||
|
|
||
| Run `check`, then for each FAIL offer the resolution — never install anything without the | ||
| consumer's explicit go-ahead in the invocation. `apply install-lint` adds | ||
| `markdownlint-cli2` as a dev dependency in the consumer repository **using the | ||
|
kyle-sexton marked this conversation as resolved.
|
||
| repository's own package manager**, resolved in order: lockfile (`pnpm-lock.yaml` → | ||
| `pnpm add -D`, `yarn.lock` → `yarn add -D`, `bun.lock`/`bun.lockb` → `bun add -d`, | ||
|
kyle-sexton marked this conversation as resolved.
|
||
| `package-lock.json` or `npm-shrinkwrap.json` → `npm install --save-dev`), then the | ||
| `package.json` `"packageManager"` field when no lockfile exists, then npm only when | ||
| neither signal is present. With no `package.json`, an ambiguous multi-lockfile state, or a lockfile that | ||
| contradicts `packageManager`, stop with manager-specific guidance instead of guessing — | ||
| never introduce a competing lockfile. The change is stated before running. For a Yarn repository, don't infer the linker — ask | ||
| the repo's own Yarn: run `yarn config get nodeLinker` in the repo. `pnp` (Berry's default | ||
| when unset) → skip the install and give guidance, because Plug'n'Play generates a loader file, | ||
| not the `node_modules/.bin` shim the hook resolves; install `markdownlint-cli2` on | ||
| `PATH` or switch the linker. `node-modules`/`pnpm`, or Yarn Classic (which has no such | ||
| setting and always materializes `node_modules`) → install. The | ||
| verify-after-remediation rule below is the backstop when an install still yields no | ||
| usable shim. After ANY remediation, re-run the | ||
| relevant `check` probe and report its actual result — never claim resolved on the | ||
| install command's exit code alone. For everything else `apply` only points: | ||
|
|
||
| - missing `jq` / Bash: platform install instructions from the README Requirements section; | ||
| this skill never installs system packages. | ||
| - toggle off: direct to `/plugin configure markdown-format` or | ||
| `claude plugin install markdown-format@<marketplace> --config markdown_format_enabled=true`; | ||
| this skill never writes user settings or `pluginConfigs`. | ||
| - no markdownlint config: offer to create a minimal `.markdownlint-cli2.jsonc` in the | ||
| repository root only when explicitly asked — the plugin imposes no rules of its own. | ||
|
|
||
| Re-running `apply` after everything passes changes nothing and reports "already configured". | ||
|
|
||
| ## What this skill does NOT do | ||
|
|
||
| - Run the formatter — editing any `.md` file exercises the hook end-to-end. The only | ||
| execution `check` performs is the harmless `--version` liveness probe of the resolved | ||
| linter; it never lints, fixes, or touches repository content. | ||
| - Write the plugin cache, Claude Code user settings, or `pluginConfigs`. | ||
| - Download anything during `check`; network use happens only in an explicitly | ||
| requested `apply install-lint` inside the consumer repository. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
jqresolves onPATHbut cannot run (for example, a stale binary with a missing dynamic loader or an incompatible executable), this probe reports PASS. The hook uses the samecommand -vgate inhooks/markdown-format.sh:132-139, then relies onjqto parsefile_pathat lines 193-210; a failed parse makes the hook exit without formatting. Run a harmlessjqexecution/capability probe so setup does not report the prerequisite as configured in this case.Useful? React with 👍 / 👎.