@guiho/mirror 3.0.0-alpha.9 → 3.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.
@@ -0,0 +1,227 @@
1
+ ---
2
+ name: guiho-as-mirror
3
+ description: Use this skill whenever the user asks to version, bump, release, tag, initialize, configure, or troubleshoot a project with GUIHO Mirror (`@guiho/mirror`). This includes Bun, npm, JSR, package.json, jsr.json, Git tag, semantic versioning, changelog, release-plan, prerelease, and "what version comes next" workflows, even when the user only says "cut a patch" or "prepare a release" without naming Mirror.
4
+ ---
5
+
6
+ # GUIHO Mirror
7
+
8
+ GUIHO Mirror is a deterministic CLI and TypeScript library for semantic project versioning. It reads one version source, calculates the next semantic version, builds a transparent read-only plan, and applies the plan to configured outputs such as `package.json`, `jsr.json`, and Git tags.
9
+
10
+ ```text
11
+ source -> version engine -> plan -> outputs
12
+ ```
13
+
14
+ Use Mirror for project versioning work instead of ad hoc edits to version fields, manual tag creation, or package-manager-specific version commands. The value of Mirror is that the agent and user can see the intended release plan before anything mutates.
15
+
16
+ ## Command Selection
17
+
18
+ Choose the Mirror command in this order:
19
+
20
+ 1. Use `bun @guiho/mirror` when the package is installed locally and Bun is available.
21
+ 2. Use `mirror` when a global binary is available.
22
+ 3. Use `bunx @guiho/mirror` when running without installation.
23
+
24
+ When unsure, run a cheap availability check (`bun @guiho/mirror --help`, `mirror --help`, or `bunx @guiho/mirror --help`) and then reuse the working command consistently. Run `mirror --help` or `mirror <command> --help` for command-specific details when needed.
25
+
26
+ Mirror runs on Node >= 20 at runtime, Bun, and Deno. Bun is the recommended development tool for the Mirror project itself. Git is required only for Git-based workflows: `source = "git"`, `output = ["git"]`, commits, tags, or pushes.
27
+
28
+ ## Release Workflow
29
+
30
+ When the user asks to bump, release, tag, or version a project, follow this sequence exactly. The ordering matters because the release tag should land on a commit that includes the release preparation, and the version apply step should only happen after validation and planning.
31
+
32
+ 1. Confirm the target and project root.
33
+ - Use the user's requested target: `major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, `prerelease`, or an exact semver like `2.0.0`.
34
+ - If the target is ambiguous, ask before mutating anything.
35
+ - Work from the project root containing `mirror.config.toml`, `package.json`, `jsr.json`, or `.git` as appropriate.
36
+
37
+ 2. Inspect Mirror configuration.
38
+ - Run `<mirror> config show`.
39
+ - Read the resolved `[git] allow_dirty` value.
40
+ - Read the resolved `[agents] write_changelog` value.
41
+ - Read the resolved `[agents] changelog_path` value.
42
+ - If config loading fails, stop and report the configuration problem instead of improvising a release.
43
+
44
+ 3. Verify Git cleanliness when required.
45
+ - If `allow_dirty = false` or the setting is absent, check the worktree with `git status --short`.
46
+ - If the worktree is dirty, stop before typecheck, tests, plan, docs, changelog, commit, or apply. Tell the user the worktree is not clean and that they need to commit or stash changes first.
47
+ - If `allow_dirty = true`, note that the configuration allows a dirty worktree and continue carefully.
48
+
49
+ 4. Run the project type checker.
50
+ - Prefer the project's existing script or documented command.
51
+ - Common Bun projects use `bun run typecheck`.
52
+ - Fix type errors before continuing. Do not apply a version bump while the typecheck is failing.
53
+
54
+ 5. Run the project test suite.
55
+ - Prefer the project's existing script or documented command.
56
+ - Common Bun projects use `bun test`.
57
+ - Fix test failures before continuing. Do not apply a version bump while tests are failing.
58
+
59
+ 6. Build the release plan before editing release docs.
60
+ - Run `<mirror> version plan <target>`.
61
+ - Capture the `nextVersion` from the plan output.
62
+ - Treat the plan as the source of truth for release documentation, changelog headings, and the final apply step.
63
+
64
+ 7. Update release documentation if the project has it.
65
+ - Update documentation files that are part of the project's release process.
66
+ - Reference the planned `nextVersion` where appropriate.
67
+ - Keep unrelated documentation untouched.
68
+
69
+ 8. Update the changelog if present and enabled.
70
+ - If `[agents].write_changelog = false`, skip changelog edits even when `CHANGELOG.md` exists.
71
+ - If changelog writing is enabled or absent, use `[agents].changelog_path` as the changelog file path; if it is missing, use `CHANGELOG.md` in the project root.
72
+ - Add an entry headed by the planned `nextVersion`.
73
+ - Summarize the actual release changes; do not invent changes that are not in the repository history or current diff.
74
+
75
+ 9. Commit release-preparation changes before applying the bump.
76
+ - Commit docs, changelog, and other pending release-preparation changes before running `version apply`.
77
+ - Use a message like `docs: prepare release <nextVersion>` unless the repo has a stricter convention.
78
+ - This pre-apply commit keeps release notes and documentation before the eventual version tag.
79
+
80
+ 10. Apply the version bump.
81
+ - Run `<mirror> version apply <target> --yes`.
82
+ - If configured outputs include both file outputs (`package.json` or `jsr.json`) and Git output, include `--commit` unless the configuration already enables release commits or the user intentionally uses `--push`. Mirror requires the tag to attach to a commit containing updated version files.
83
+ - Do not use `--push` unless the user explicitly requested pushing or the project configuration intentionally enables it.
84
+
85
+ ## Safety Rules
86
+
87
+ - Never skip `version plan`; planning is the point where the user and agent can see what will happen before mutations.
88
+ - Never hand-edit `package.json` or `jsr.json` version fields as a substitute for Mirror when Mirror is configured for the project.
89
+ - Never create Git tags manually for a Mirror-managed release unless the user is intentionally recovering from a failed release and understands the state.
90
+ - Do not proceed past a dirty worktree when `allow_dirty` is false.
91
+ - Do not apply a version bump after failed typecheck or tests.
92
+ - Do not push release refs unless explicitly requested or configured.
93
+ - When an exact version is requested, still run `version plan <exact-version>` first.
94
+ - When the plan output is surprising, stop and explain the mismatch instead of forcing the release.
95
+
96
+ ## Initialization Workflow
97
+
98
+ When the user asks to set up Mirror in a project:
99
+
100
+ 1. Identify the version source the project should use.
101
+ - Use `package.json` for npm/Bun package versioning.
102
+ - Use `jsr.json` for JSR package versioning.
103
+ - Use `git` when tags are the source of truth.
104
+ 2. Run one of:
105
+ - `<mirror> init package.json`
106
+ - `<mirror> init jsr.json`
107
+ - `<mirror> init git`
108
+ 3. Review `mirror.config.toml` with the user if outputs, tag templates, commits, or pushes need customization.
109
+ 4. Validate with `<mirror> config check` and inspect with `<mirror> config show`.
110
+ 5. Run `<mirror> version current` and a harmless `<mirror> version plan patch` to confirm the lifecycle works.
111
+
112
+ ## Configuration Reference
113
+
114
+ Mirror searches for configuration via `--config <path>`, `./mirror.config.toml`, or `./config/mirror.config.toml`.
115
+
116
+ ```toml
117
+ schema = 1
118
+
119
+ [project]
120
+ name = "my-project"
121
+ name_source = "package.json"
122
+
123
+ [version]
124
+ scheme = "semver"
125
+ source = "package.json"
126
+ output = ["package.json", "git"]
127
+ prerelease_id = "alpha"
128
+
129
+ [package]
130
+ path = "package.json"
131
+
132
+ [jsr]
133
+ path = "jsr.json"
134
+
135
+ [git]
136
+ tag_template = "{name}@{version}"
137
+ commit = false
138
+ push = false
139
+ allow_dirty = false
140
+
141
+ [agents]
142
+ write_changelog = true
143
+ changelog_path = "CHANGELOG.md"
144
+ auto_agents_md = true
145
+ auto_skill_install = true
146
+ ```
147
+
148
+ Supported version sources and outputs are `package.json`, `jsr.json`, and `git`. Supported Git tag templates are `v{version}`, `{name}@{version}`, and `{name}/v{version}`.
149
+
150
+ Agent automation options default to true. Set `write_changelog = false` to tell agents to skip changelog edits, `changelog_path = "docs/CHANGELOG.md"` to specify the changelog file, `auto_agents_md = false` to stop Mirror from inserting its AGENTS.md section, and `auto_skill_install = false` to stop Mirror from installing `guiho-as-mirror` when missing.
151
+
152
+ ## CLI Reference
153
+
154
+ Common commands:
155
+
156
+ ```bash
157
+ mirror init package.json
158
+ mirror init jsr.json
159
+ mirror init git
160
+ mirror config show
161
+ mirror config check
162
+ mirror config schema
163
+ mirror agents install local
164
+ mirror agents install global
165
+ mirror agents instructions
166
+ mirror version current
167
+ mirror version next <target>
168
+ mirror version plan <target>
169
+ mirror version apply <target> --yes
170
+ ```
171
+
172
+ Supported targets are `major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, `prerelease`, or an exact semantic version such as `2.0.0`.
173
+
174
+ ## TypeScript API
175
+
176
+ When the user wants automation code rather than CLI usage, use the typed API:
177
+
178
+ ```ts
179
+ import { applyVersionPlan, buildVersionPlan, executeVersionPlan } from '@guiho/mirror';
180
+
181
+ const plan = await buildVersionPlan('patch', { cwd: process.cwd() });
182
+
183
+ console.log(plan.currentVersion);
184
+ console.log(plan.nextVersion);
185
+ console.log(plan.actions);
186
+
187
+ await executeVersionPlan(plan, { dryRun: false, yes: true });
188
+
189
+ await applyVersionPlan('minor', { cwd: process.cwd(), yes: true });
190
+ ```
191
+
192
+ For reading state:
193
+
194
+ ```ts
195
+ import { loadMirrorConfig, readCurrentVersion } from '@guiho/mirror';
196
+
197
+ const config = await loadMirrorConfig({ cwd: process.cwd() });
198
+ const version = await readCurrentVersion(config);
199
+ ```
200
+
201
+ ## Mirror Project Development
202
+
203
+ When working inside the Mirror project repository itself, run development commands from the `mirror/` directory:
204
+
205
+ ```bash
206
+ cd mirror
207
+ bun install
208
+ bun run typecheck
209
+ bun test
210
+ bun run build
211
+ bun run binary
212
+ ```
213
+
214
+ Use these for development validation. For release validation, still follow the release workflow above.
215
+
216
+ ## Response Style
217
+
218
+ When reporting a Mirror release result, include:
219
+
220
+ - The target requested.
221
+ - The current version and planned next version.
222
+ - Whether typecheck and tests passed.
223
+ - Which docs or changelog files changed, if any.
224
+ - The final apply command that ran.
225
+ - Whether commits, tags, or pushes were created.
226
+
227
+ Keep the explanation short and operational. The user usually needs to know what version was planned, what was mutated, and whether anything remains for them to do.