@guiho/mirror 3.1.2 → 3.2.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.
- package/CHANGELOG.md +26 -0
- package/DOCS.md +129 -6
- package/README.md +8 -5
- package/jsr.json +1 -1
- package/library/adapters.d.ts +4 -0
- package/library/adapters.d.ts.map +1 -1
- package/library/adapters.js +8 -1
- package/library/agents.d.ts +3 -1
- package/library/agents.d.ts.map +1 -1
- package/library/agents.js +14 -2
- package/library/cli.d.ts.map +1 -1
- package/library/cli.js +87 -20
- package/library/config.d.ts +5 -1
- package/library/config.d.ts.map +1 -1
- package/library/config.js +138 -89
- package/library/executor.d.ts +2 -2
- package/library/executor.d.ts.map +1 -1
- package/library/executor.js +27 -13
- package/library/flags.d.ts.map +1 -1
- package/library/flags.js +11 -1
- package/library/guiho-mirror.d.ts +7 -4
- package/library/guiho-mirror.d.ts.map +1 -1
- package/library/guiho-mirror.js +6 -3
- package/library/hooks.d.ts +14 -0
- package/library/hooks.d.ts.map +1 -0
- package/library/hooks.js +122 -0
- package/library/init.d.ts +12 -0
- package/library/init.d.ts.map +1 -0
- package/library/init.js +100 -0
- package/library/plan.d.ts.map +1 -1
- package/library/plan.js +9 -5
- package/library/reporter.d.ts +2 -1
- package/library/reporter.d.ts.map +1 -1
- package/library/reporter.js +31 -2
- package/library/schema.d.ts +164 -0
- package/library/schema.d.ts.map +1 -0
- package/library/schema.js +152 -0
- package/library/types.d.ts +50 -0
- package/library/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/schema/mirror.config.schema.json +379 -0
- package/skills/guiho-as-mirror/SKILL.md +13 -7
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.2.1] - 2026-06-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added lifecycle hooks with before/after hook points around planning, applying, writing, committing, tagging, pushing, and the full execution flow.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Wrapped the generated Mirror `AGENTS.md` guidance in `BEGIN/END GUIHO MIRROR` markers that tell agents not to edit the Mirror-managed block.
|
|
17
|
+
- Made Mirror AGENTS guidance detection whitespace-insensitive so markdown formatting that only adds or removes blank lines does not duplicate the section.
|
|
18
|
+
- Updated hook tests to use the active Bun runtime instead of requiring a separate `node` binary on `PATH`.
|
|
19
|
+
|
|
20
|
+
## [3.2.0] - 2026-06-07
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Added auxiliary package outputs via `[package].auxiliary_paths` so extra `package.json` files mirror the main package version.
|
|
25
|
+
- Added an interactive `mirror init` wizard (TTY-only) with defaults you accept by pressing Enter, plus flags for every answer and `--non-interactive` for automation.
|
|
26
|
+
- Added new `mirror init` flags: `--output`, `--auxiliary`, `--tag-template`, `--name`, `--commit`, `--push`, `--non-interactive`.
|
|
27
|
+
- Added a JSON Schema for `mirror.config.toml`, shipped at `schema/mirror.config.schema.json` and printable via `mirror config schema --format json`.
|
|
28
|
+
- Generated config files now include a `#:schema` directive for editor autocomplete.
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- `mirror init` now reconciles an existing `mirror.config.toml` (adds missing defaults) instead of failing, and `--yes` overwrites with generated defaults.
|
|
33
|
+
|
|
8
34
|
## [3.1.1] - 2026-06-07
|
|
9
35
|
|
|
10
36
|
### Changed
|
package/DOCS.md
CHANGED
|
@@ -160,7 +160,15 @@ Version and config commands accept runtime overrides.
|
|
|
160
160
|
|
|
161
161
|
### `mirror init`
|
|
162
162
|
|
|
163
|
-
Creates `mirror.config.toml` in the current working directory.
|
|
163
|
+
Creates `mirror.config.toml` in the current working directory. When a configuration file already exists, `mirror init` reconciles missing default keys into it without overwriting user-configured values. Use `--yes` only when you intentionally want to replace the file with freshly generated defaults.
|
|
164
|
+
|
|
165
|
+
On an interactive terminal, `mirror init` runs a step-by-step wizard for the core fields (version source, outputs, package path, auxiliary package paths, jsr path, git tag template, commit, push). Each prompt shows a default that you accept by pressing Enter. Defaults are source `package.json` and outputs `package.json` + `git`.
|
|
166
|
+
|
|
167
|
+
Every answer also has a flag, so the command runs fully non-interactively when flags are provided. In non-TTY environments (CI, AI agents) or with `--non-interactive`/`--yes`, Mirror skips prompts and uses flags + defaults instead of waiting for input.
|
|
168
|
+
|
|
169
|
+
Init flags: `--source`, `--output`, `--package-file`, `--jsr-file`, `--auxiliary`, `--tag-template`, `--name`, `--preid`, `--commit`, `--push`, `--non-interactive`, `--yes`.
|
|
170
|
+
|
|
171
|
+
Generated configuration files start with a `#:schema` directive pointing at the bundled JSON Schema (`./node_modules/@guiho/mirror/schema/mirror.config.schema.json`) so editors with Taplo / Even Better TOML provide autocomplete and validation.
|
|
164
172
|
|
|
165
173
|
```bash
|
|
166
174
|
mirror init package.json
|
|
@@ -182,7 +190,7 @@ mirror config schema
|
|
|
182
190
|
|
|
183
191
|
- `show`: Prints the resolved configuration after defaults and CLI overrides.
|
|
184
192
|
- `check`: Validates configuration, adapter files, Git availability, and supported Git tag templates.
|
|
185
|
-
- `schema`: Prints the configuration reference.
|
|
193
|
+
- `schema`: Prints the configuration reference. `--format json` prints a JSON Schema for editor autocomplete; the same schema ships at `schema/mirror.config.schema.json`.
|
|
186
194
|
|
|
187
195
|
### `mirror agents`
|
|
188
196
|
|
|
@@ -196,7 +204,7 @@ mirror agents instructions
|
|
|
196
204
|
|
|
197
205
|
- `install local`: Writes `.agents/skills/guiho-as-mirror/SKILL.md` in the project.
|
|
198
206
|
- `install global`: Writes `~/.agents/skills/guiho-as-mirror/SKILL.md`.
|
|
199
|
-
- `instructions`: Creates or updates `AGENTS.md` with the GUIHO Mirror semantic versioning section.
|
|
207
|
+
- `instructions`: Creates or updates `AGENTS.md` with the protected GUIHO Mirror semantic versioning section.
|
|
200
208
|
|
|
201
209
|
Global skill installation uses the user home directory. Tests and automation can override that home root with `MIRROR_AGENT_HOME`.
|
|
202
210
|
|
|
@@ -245,6 +253,7 @@ prerelease_id = "alpha"
|
|
|
245
253
|
|
|
246
254
|
[package]
|
|
247
255
|
path = "package.json"
|
|
256
|
+
auxiliary_paths = []
|
|
248
257
|
|
|
249
258
|
[jsr]
|
|
250
259
|
path = "jsr.json"
|
|
@@ -285,6 +294,9 @@ Exactly one source is used. Multiple outputs are allowed.
|
|
|
285
294
|
### `[package]`
|
|
286
295
|
|
|
287
296
|
- `path`: Optional path to `package.json`. Default: `package.json`.
|
|
297
|
+
- `auxiliary_paths`: Optional array of extra `package.json` files that mirror the main package version. Default: `[]`.
|
|
298
|
+
|
|
299
|
+
The main package path remains the source of truth for package version reads and project name reads. Auxiliary package files are write-only mirrors: when `package.json` is in `[version].output`, Mirror plans and writes the same next version to each auxiliary package file and includes those files in release commits.
|
|
288
300
|
|
|
289
301
|
### `[jsr]`
|
|
290
302
|
|
|
@@ -328,7 +340,7 @@ Automation is controlled by `[agents]`.
|
|
|
328
340
|
- Disable changelog edits by agents with `write_changelog = false`.
|
|
329
341
|
- Direct agents to the correct changelog with `changelog_path = "path/to/CHANGELOG.md"`.
|
|
330
342
|
|
|
331
|
-
The generated AGENTS section instructs agents to invoke `guiho-as-mirror` for versioning work, inspect `mirror.config.toml`, respect `write_changelog`, and use `changelog_path` for changelog edits. Use `mirror agents install local` only when a project-local skill copy is desired explicitly.
|
|
343
|
+
The generated AGENTS section is wrapped in `<!-- BEGIN GUIHO MIRROR - DO NOT EDIT THIS SECTION -->` and `<!-- END GUIHO MIRROR -->` markers so agents know the block is Mirror-managed. It instructs agents to invoke `guiho-as-mirror` for versioning work, inspect `mirror.config.toml`, respect `write_changelog`, and use `changelog_path` for changelog edits. Mirror detects the existing block with whitespace-insensitive matching so markdown formatting that only adds or removes blank lines does not duplicate the section. Use `mirror agents install local` only when a project-local skill copy is desired explicitly.
|
|
332
344
|
|
|
333
345
|
## Release Safety Rules
|
|
334
346
|
|
|
@@ -343,6 +355,110 @@ Mirror intentionally separates planning from mutation.
|
|
|
343
355
|
|
|
344
356
|
`mirror version apply` refuses to mutate unless `--yes` is passed, unless `--dry-run` is used.
|
|
345
357
|
|
|
358
|
+
## Lifecycle Hooks
|
|
359
|
+
|
|
360
|
+
Mirror supports lifecycle hooks that run shell commands at defined points during `mirror version apply`. Hooks are configured in the `[hooks]` section of `mirror.config.toml`.
|
|
361
|
+
|
|
362
|
+
### Lifecycle Tree
|
|
363
|
+
|
|
364
|
+
```
|
|
365
|
+
before:everything # Runs once, before anything else
|
|
366
|
+
│
|
|
367
|
+
├─ before:plan # Runs before buildVersionPlan()
|
|
368
|
+
│ buildVersionPlan() # Plan construction (read-only)
|
|
369
|
+
│ after:plan # Runs after plan is built
|
|
370
|
+
│
|
|
371
|
+
├─ before:apply # Runs before executeVersionPlan()
|
|
372
|
+
│ │
|
|
373
|
+
│ ├─ before:write # Runs before each file-write batch
|
|
374
|
+
│ │ write-file(s) # Mutate package.json / jsr.json
|
|
375
|
+
│ │ after:write # Runs after all file writes
|
|
376
|
+
│ │
|
|
377
|
+
│ ├─ before:commit # Runs before git commit
|
|
378
|
+
│ │ git-commit # git add + git commit
|
|
379
|
+
│ │ after:commit # Runs after git commit
|
|
380
|
+
│ │
|
|
381
|
+
│ ├─ before:tag # Runs before git tag
|
|
382
|
+
│ │ git-tag # git tag -m "..."
|
|
383
|
+
│ │ after:tag # Runs after git tag
|
|
384
|
+
│ │
|
|
385
|
+
│ ├─ before:push # Runs before git push
|
|
386
|
+
│ │ git-push # git push + git push --tags
|
|
387
|
+
│ │ after:push # Runs after git push
|
|
388
|
+
│ │
|
|
389
|
+
│ after:apply # Runs after executeVersionPlan() completes (always runs)
|
|
390
|
+
│
|
|
391
|
+
after:everything # Runs once, after everything else (always runs)
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Hook Configuration
|
|
395
|
+
|
|
396
|
+
```toml
|
|
397
|
+
[hooks]
|
|
398
|
+
before_everything = "npm run typecheck"
|
|
399
|
+
after_everything = "echo 'Release complete!'"
|
|
400
|
+
|
|
401
|
+
before_plan = ["npm run lint", "npm run typecheck"]
|
|
402
|
+
after_plan = "echo 'Plan is ready'"
|
|
403
|
+
|
|
404
|
+
before_apply = "npm run build"
|
|
405
|
+
after_apply = "node scripts/notify-release.js"
|
|
406
|
+
|
|
407
|
+
before_write = "echo 'Writing version files...'"
|
|
408
|
+
after_write = "echo 'Files written'"
|
|
409
|
+
|
|
410
|
+
before_commit = ["npm run format", "echo 'Committing...'"]
|
|
411
|
+
after_commit = "echo 'Committed'"
|
|
412
|
+
|
|
413
|
+
before_tag = "echo 'Tagging release...'"
|
|
414
|
+
after_tag = "echo 'Tagged'"
|
|
415
|
+
|
|
416
|
+
before_push = "echo 'Pushing...'"
|
|
417
|
+
after_push = "echo 'Pushed'"
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
- Each hook key maps to a string (single command) or array of strings (multiple commands run sequentially).
|
|
421
|
+
- Hook names use underscores (`before_everything`) in TOML, which normalizes to colon form (`before:everything`) internally.
|
|
422
|
+
- Hook commands run in the project root directory through the default platform shell.
|
|
423
|
+
- Action-level hooks (`before:write`, `before:commit`, `before:tag`, `before:push` and their `after:` variants) fire only when the corresponding action is part of the plan.
|
|
424
|
+
- Hooks are skipped during `--dry-run`.
|
|
425
|
+
|
|
426
|
+
### Hook Error Handling
|
|
427
|
+
|
|
428
|
+
- When a hook exits with a non-zero code, Mirror stops the pipeline and reports the failure.
|
|
429
|
+
- `after:apply` and `after:everything` always run, even when a prior hook or action failed. This ensures cleanup and notification hooks fire reliably.
|
|
430
|
+
|
|
431
|
+
### Hook Environment Variables
|
|
432
|
+
|
|
433
|
+
Every hook receives `MIRROR_*` environment variables with release context:
|
|
434
|
+
|
|
435
|
+
| Variable | Scope | Description |
|
|
436
|
+
|------------------------|--------------|-------------------------------------------------------|
|
|
437
|
+
| `MIRROR_CWD` | Always | Project root directory |
|
|
438
|
+
| `MIRROR_CONFIG_PATH` | Always | Path to resolved `mirror.config.toml` |
|
|
439
|
+
| `MIRROR_SOURCE` | Always | Version source adapter |
|
|
440
|
+
| `MIRROR_OUTPUT` | Always | Comma-separated output adapters |
|
|
441
|
+
| `MIRROR_TARGET` | Always | The release target argument |
|
|
442
|
+
| `MIRROR_CURRENT` | Plan+ | Current version string |
|
|
443
|
+
| `MIRROR_NEXT` | Plan+ | Next version string |
|
|
444
|
+
| `MIRROR_PROJECT_NAME` | Plan+ | Resolved project name |
|
|
445
|
+
| `MIRROR_GIT_TAG` | Plan+ | Rendered git tag (if git output) |
|
|
446
|
+
| `MIRROR_FILE_PATHS` | Plan+ | Comma-separated file output paths |
|
|
447
|
+
| `MIRROR_COMMIT_ENABLED`| Plan+ | `true`/`false` |
|
|
448
|
+
| `MIRROR_PUSH_ENABLED` | Plan+ | `true`/`false` |
|
|
449
|
+
| `MIRROR_FILE_PATH` | Write | Path being written to |
|
|
450
|
+
| `MIRROR_FILE_CURRENT` | Write | Current version in the file |
|
|
451
|
+
| `MIRROR_FILE_NEXT` | Write | Next version being written |
|
|
452
|
+
| `MIRROR_COMMIT_MSG` | Commit | Commit message |
|
|
453
|
+
| `MIRROR_COMMIT_PATHS` | Commit | Space-separated paths being committed |
|
|
454
|
+
| `MIRROR_TAG` | Tag | Git tag being created |
|
|
455
|
+
| `MIRROR_INCLUDE_COMMIT`| Push | `true`/`false` |
|
|
456
|
+
| `MIRROR_INCLUDE_TAGS` | Push | `true`/`false` |
|
|
457
|
+
| `MIRROR_APPLIED` | Results | `true`/`false` (whether execution actually applied) |
|
|
458
|
+
| `MIRROR_DRY_RUN` | Results | `true`/`false` |
|
|
459
|
+
|
|
460
|
+
"Plan+" means the variable is available starting from `before:plan` and all later hooks. "Write", "Commit", "Tag", and "Push" mean the variable is available at the corresponding action-level hooks. "Results" means `after:apply` and `after:everything`.
|
|
461
|
+
|
|
346
462
|
## Recommended Agent Release Workflow
|
|
347
463
|
|
|
348
464
|
When an AI coding agent prepares a Mirror-managed release, it should follow this sequence.
|
|
@@ -414,12 +530,15 @@ The API uses the same configuration discovery and safety rules as the CLI.
|
|
|
414
530
|
- `source/guiho-mirror.ts`: public library export surface.
|
|
415
531
|
- `source/guiho-mirror-bin.ts`: CLI binary entrypoint.
|
|
416
532
|
- `source/cli.ts`: citty command tree, CLI argument mapping, and process-facing error handling.
|
|
417
|
-
- `source/config.ts`: TOML discovery, schema validation, defaulting, init config generation, and override merge.
|
|
533
|
+
- `source/config.ts`: TOML discovery, schema validation, defaulting, init config generation, init reconciliation, and override merge.
|
|
534
|
+
- `source/init.ts`: init answer resolution, interactive prompts (TTY-only), and defaults.
|
|
535
|
+
- `source/schema.ts`: JSON Schema for `mirror.config.toml` and the `#:schema` reference.
|
|
418
536
|
- `source/types.ts`: public and internal TypeScript types.
|
|
419
537
|
- `source/version.ts`: semver target validation and next-version resolution.
|
|
420
538
|
- `source/adapters.ts`: package, JSR, and Git read/write primitives.
|
|
421
539
|
- `source/plan.ts`: validation and read-only release plan construction.
|
|
422
540
|
- `source/executor.ts`: mutation layer for file writes, Git commits, tags, and pushes.
|
|
541
|
+
- `source/hooks.ts`: lifecycle hook configuration, execution, and environment variable construction.
|
|
423
542
|
- `source/reporter.ts`: text and JSON report formatting.
|
|
424
543
|
- `source/agents.ts`: agent skill installation and AGENTS.md guidance automation.
|
|
425
544
|
- `source/errors.ts`: user-facing errors with stable exit codes.
|
|
@@ -516,7 +635,11 @@ Run `mirror init package.json`, `mirror init jsr.json`, or `mirror init git` fro
|
|
|
516
635
|
|
|
517
636
|
### Adapter file not found
|
|
518
637
|
|
|
519
|
-
Check `[package].path` or `[jsr].path`, or pass `--package-file` or `--jsr-file`.
|
|
638
|
+
Check `[package].path`, `[package].auxiliary_paths`, or `[jsr].path`, or pass `--package-file` or `--jsr-file`.
|
|
639
|
+
|
|
640
|
+
### Auxiliary package version did not change
|
|
641
|
+
|
|
642
|
+
Ensure `package.json` is present in `[version].output` and the file is listed in `[package].auxiliary_paths`.
|
|
520
643
|
|
|
521
644
|
### Unsupported Git tag template
|
|
522
645
|
|
package/README.md
CHANGED
|
@@ -73,16 +73,18 @@ Adapters connect Mirror to different versioning ecosystems:
|
|
|
73
73
|
Mirror provides a concise CLI with three main command groups:
|
|
74
74
|
|
|
75
75
|
#### `mirror init`
|
|
76
|
-
Creates a `mirror.config.toml` file in the current directory.
|
|
77
|
-
- `mirror init
|
|
78
|
-
- `mirror init jsr.json`
|
|
79
|
-
-
|
|
76
|
+
Creates or reconciles a `mirror.config.toml` file in the current directory. On an interactive terminal, `mirror init` asks step-by-step questions (version source, outputs, package path, auxiliary paths, tag template, commit/push) with defaults you accept by pressing Enter. Pass flags to answer non-interactively, and in CI / non-TTY environments it uses flags + defaults without prompting.
|
|
77
|
+
- `mirror init` (interactive wizard, or flags + defaults when non-interactive)
|
|
78
|
+
- `mirror init package.json` / `mirror init jsr.json` / `mirror init git` (source shortcut)
|
|
79
|
+
- Flags: `--source`, `--output`, `--package-file`, `--jsr-file`, `--auxiliary`, `--tag-template`, `--name`, `--preid`, `--commit`, `--push`, `--non-interactive`, `--yes`
|
|
80
|
+
|
|
81
|
+
Defaults: source `package.json`, outputs `package.json` + `git`.
|
|
80
82
|
|
|
81
83
|
#### `mirror config`
|
|
82
84
|
Validates and inspects configuration.
|
|
83
85
|
- `mirror config show`: Prints the resolved configuration.
|
|
84
86
|
- `mirror config check`: Validates configuration without output.
|
|
85
|
-
- `mirror config schema`: Prints the comprehensive configuration reference.
|
|
87
|
+
- `mirror config schema`: Prints the comprehensive configuration reference. Use `--format json` to print a JSON Schema for editor autocomplete.
|
|
86
88
|
|
|
87
89
|
#### `mirror agents`
|
|
88
90
|
Installs Mirror-aware agent guidance for projects that use AI coding agents.
|
|
@@ -118,6 +120,7 @@ prerelease_id = "alpha" # Optional. e.g., creates 1.0.1-alpha.0
|
|
|
118
120
|
|
|
119
121
|
[package]
|
|
120
122
|
path = "package.json" # Optional. Override path to package.json
|
|
123
|
+
auxiliary_paths = [] # Optional. Extra package.json files that mirror the main version
|
|
121
124
|
|
|
122
125
|
[jsr]
|
|
123
126
|
path = "jsr.json" # Optional. Override path to jsr.json
|
package/jsr.json
CHANGED
package/library/adapters.d.ts
CHANGED
|
@@ -9,10 +9,14 @@ export declare const readJsrJson: (path: string) => Promise<MirrorJsonObject>;
|
|
|
9
9
|
export declare const writeJsonObject: (path: string, object: MirrorJsonObject) => Promise<void>;
|
|
10
10
|
export declare const readPackageVersion: (config: MirrorConfig) => Promise<string>;
|
|
11
11
|
export declare const readJsrVersion: (config: MirrorConfig) => Promise<string>;
|
|
12
|
+
export declare const readPackageVersionFile: (path: string) => Promise<string>;
|
|
13
|
+
export declare const readJsrVersionFile: (path: string) => Promise<string>;
|
|
12
14
|
export declare const readPackageName: (config: MirrorConfig) => Promise<string>;
|
|
13
15
|
export declare const readJsrName: (config: MirrorConfig) => Promise<string>;
|
|
14
16
|
export declare const writePackageVersion: (config: MirrorConfig, nextVersion: string) => Promise<void>;
|
|
15
17
|
export declare const writeJsrVersion: (config: MirrorConfig, nextVersion: string) => Promise<void>;
|
|
18
|
+
export declare const writePackageVersionFile: (path: string, nextVersion: string) => Promise<void>;
|
|
19
|
+
export declare const writeJsrVersionFile: (path: string, nextVersion: string) => Promise<void>;
|
|
16
20
|
export declare const ensureAdapterFiles: (config: MirrorConfig) => Promise<void>;
|
|
17
21
|
export declare const resolveProjectName: (config: MirrorConfig) => Promise<string | undefined>;
|
|
18
22
|
export declare const readCurrentVersion: (config: MirrorConfig, projectName?: string) => Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../source/adapters.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAsBhE,eA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,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,KAAK,MAAM,qBAG3C,CAAA;AAED,eAAO,MAAM,eAAe,GAAU,KAAK,MAAM,EAAE,OAAO,MAAM,EAAE,EAAE,SAAS,MAAM,kBAIlF,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,KAAK,MAAM,EAAE,KAAK,MAAM,kBAG1D,CAAA;AAED,eAAO,MAAM,WAAW,GAAU,KAAK,MAAM,EAAE,eAAe,OAAO,EAAE,aAAa,OAAO,kBAI1F,CAAA"}
|
package/library/adapters.js
CHANGED
|
@@ -51,13 +51,20 @@ export const writeJsonObject = async (path, object) => {
|
|
|
51
51
|
};
|
|
52
52
|
export const readPackageVersion = async (config) => readVersionField(resolveMirrorPath(config.cwd, config.package.path), 'package.json');
|
|
53
53
|
export const readJsrVersion = async (config) => readVersionField(resolveMirrorPath(config.cwd, config.jsr.path), 'jsr.json');
|
|
54
|
+
export const readPackageVersionFile = async (path) => readVersionField(path, 'package.json');
|
|
55
|
+
export const readJsrVersionFile = async (path) => readVersionField(path, 'jsr.json');
|
|
54
56
|
export const readPackageName = async (config) => readNameField(resolveMirrorPath(config.cwd, config.package.path), 'package.json');
|
|
55
57
|
export const readJsrName = async (config) => readNameField(resolveMirrorPath(config.cwd, config.jsr.path), 'jsr.json');
|
|
56
58
|
export const writePackageVersion = async (config, nextVersion) => writeVersionField(resolveMirrorPath(config.cwd, config.package.path), 'package.json', nextVersion);
|
|
57
59
|
export const writeJsrVersion = async (config, nextVersion) => writeVersionField(resolveMirrorPath(config.cwd, config.jsr.path), 'jsr.json', nextVersion);
|
|
60
|
+
export const writePackageVersionFile = async (path, nextVersion) => writeVersionField(path, 'package.json', nextVersion);
|
|
61
|
+
export const writeJsrVersionFile = async (path, nextVersion) => writeVersionField(path, 'jsr.json', nextVersion);
|
|
58
62
|
export const ensureAdapterFiles = async (config) => {
|
|
59
|
-
if (usesAdapter(config, 'package.json'))
|
|
63
|
+
if (usesAdapter(config, 'package.json')) {
|
|
60
64
|
ensureFile(resolveMirrorPath(config.cwd, config.package.path), 'package.json');
|
|
65
|
+
for (const path of config.package.auxiliaryPaths)
|
|
66
|
+
ensureFile(resolveMirrorPath(config.cwd, path), 'package.json');
|
|
67
|
+
}
|
|
61
68
|
if (usesAdapter(config, 'jsr.json'))
|
|
62
69
|
ensureFile(resolveMirrorPath(config.cwd, config.jsr.path), 'jsr.json');
|
|
63
70
|
if (usesAdapter(config, 'git'))
|
package/library/agents.d.ts
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { MirrorAgentAutomationResult, MirrorAgentSettings, MirrorAgentsInstructionsResult, MirrorCliOptions, MirrorSkillInstallResult, MirrorSkillInstallScope } from './types.js';
|
|
5
5
|
export declare const mirrorSkillName = "guiho-as-mirror";
|
|
6
|
+
export declare const mirrorAgentsSectionStartMarker = "<!-- BEGIN GUIHO MIRROR - DO NOT EDIT THIS SECTION -->";
|
|
7
|
+
export declare const mirrorAgentsSectionEndMarker = "<!-- END GUIHO MIRROR -->";
|
|
6
8
|
export declare const mirrorAgentsSectionHeading = "## Semantic Project Versioning -- GUIHO Mirror";
|
|
7
9
|
export declare const defaultMirrorAgentSettings: MirrorAgentSettings;
|
|
8
|
-
export declare const mirrorAgentsSection
|
|
10
|
+
export declare const mirrorAgentsSection: string;
|
|
9
11
|
type MirrorSkillPathOptions = {
|
|
10
12
|
cwd?: string;
|
|
11
13
|
homeDirectory?: string;
|
package/library/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../source/agents.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,8BAA8B,EAC9B,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAA;AAInB,eAAO,MAAM,eAAe,oBAAoB,CAAA;AAChD,eAAO,MAAM,0BAA0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MAAM,GAAG,SAWrD,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAU,UAAS,gBAAqB,KAAG,OAAO,CAAC,mBAAmB,CAa5G,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,UAAS,4BAAiC,EAC1C,SAAQ,CAAC,OAAO,EAAE,MAAM,KAAK,IAAe,KAC3C,OAAO,CAAC,2BAA2B,CAkBrC,CAAA"}
|
package/library/agents.js
CHANGED
|
@@ -8,6 +8,8 @@ import { dirname, resolve } from 'node:path';
|
|
|
8
8
|
import { MirrorError } from './errors.js';
|
|
9
9
|
import { discoverMirrorConfig, resolveMirrorPath } from './config.js';
|
|
10
10
|
export const mirrorSkillName = 'guiho-as-mirror';
|
|
11
|
+
export const mirrorAgentsSectionStartMarker = '<!-- BEGIN GUIHO MIRROR - DO NOT EDIT THIS SECTION -->';
|
|
12
|
+
export const mirrorAgentsSectionEndMarker = '<!-- END GUIHO MIRROR -->';
|
|
11
13
|
export const mirrorAgentsSectionHeading = '## Semantic Project Versioning -- GUIHO Mirror';
|
|
12
14
|
export const defaultMirrorAgentSettings = {
|
|
13
15
|
writeChangelog: true,
|
|
@@ -15,7 +17,7 @@ export const defaultMirrorAgentSettings = {
|
|
|
15
17
|
autoAgentsMd: true,
|
|
16
18
|
autoSkillInstall: true,
|
|
17
19
|
};
|
|
18
|
-
|
|
20
|
+
const mirrorAgentsSectionBody = `${mirrorAgentsSectionHeading}
|
|
19
21
|
|
|
20
22
|
Invoke the guiho-as-mirror agent skill every time the user wants to bump, tag, release, plan, initialize, configure, or troubleshoot semantic project versioning with GUIHO Mirror.
|
|
21
23
|
|
|
@@ -23,6 +25,9 @@ Before editing release docs or changelogs, inspect mirror.config.toml. If [agent
|
|
|
23
25
|
|
|
24
26
|
Use [agents].changelog_path as the changelog file path. If it is missing, use CHANGELOG.md in the project root.
|
|
25
27
|
`;
|
|
28
|
+
export const mirrorAgentsSection = `${mirrorAgentsSectionStartMarker}
|
|
29
|
+
${mirrorAgentsSectionBody.trimEnd()}
|
|
30
|
+
${mirrorAgentsSectionEndMarker}`;
|
|
26
31
|
export const resolveMirrorSkillPath = (scope, options = {}) => {
|
|
27
32
|
if (scope === 'local')
|
|
28
33
|
return resolve(options.cwd ?? process.cwd(), '.agents', 'skills', mirrorSkillName, 'SKILL.md');
|
|
@@ -52,7 +57,7 @@ export const ensureMirrorAgentsInstructions = async (cwd, create = false) => {
|
|
|
52
57
|
return { path, exists: true, changed: true };
|
|
53
58
|
}
|
|
54
59
|
const content = await readFile(path, 'utf8');
|
|
55
|
-
if (content
|
|
60
|
+
if (hasMirrorAgentsSection(content))
|
|
56
61
|
return { path, exists: true, changed: false };
|
|
57
62
|
const nextContent = `${content.trimEnd()}\n\n${mirrorAgentsSection}\n`;
|
|
58
63
|
await writeFile(path, nextContent, 'utf8');
|
|
@@ -126,6 +131,13 @@ const optionalString = (value, key) => {
|
|
|
126
131
|
throw new MirrorError(`Invalid ${key}. Expected a string.`);
|
|
127
132
|
return value;
|
|
128
133
|
};
|
|
134
|
+
const hasMirrorAgentsSection = (content) => {
|
|
135
|
+
const normalizedContent = normalizeMirrorAgentsSection(content);
|
|
136
|
+
return [mirrorAgentsSection, mirrorAgentsSectionBody].some((section) => {
|
|
137
|
+
return normalizedContent.includes(normalizeMirrorAgentsSection(section));
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
const normalizeMirrorAgentsSection = (content) => content.replace(/\s+/g, ' ').trim();
|
|
129
141
|
const embeddedMirrorSkillContent = [
|
|
130
142
|
'---',
|
|
131
143
|
'name: guiho-as-mirror',
|
package/library/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../source/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../source/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6DH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;EAc5B,CAAA;AAEJ,eAAO,MAAM,YAAY,GAAU,kBAA+B,kBAwEjE,CAAA"}
|
package/library/cli.js
CHANGED
|
@@ -7,12 +7,14 @@ import { resolve } from 'node:path';
|
|
|
7
7
|
import { ensureMirrorAgentsInstructions, installMirrorSkill, runMirrorAgentAutomation } from './agents.js';
|
|
8
8
|
import { MirrorError } from './errors.js';
|
|
9
9
|
import { readCurrentVersion, resolveProjectName } from './adapters.js';
|
|
10
|
-
import { configPathForDisplay, discoverMirrorConfig, loadMirrorConfig, relativeFromCwd,
|
|
10
|
+
import { configPathForDisplay, discoverMirrorConfig, loadMirrorConfig, relativeFromCwd, writeInitConfigFromAnswers } from './config.js';
|
|
11
11
|
import { executeVersionPlan } from './executor.js';
|
|
12
12
|
import { parseMirrorCliOptions } from './flags.js';
|
|
13
|
+
import { createReadlineInitPrompter, isInteractiveInit, resolveInitAnswers } from './init.js';
|
|
13
14
|
import { buildVersionPlan, validateMirrorConfig } from './plan.js';
|
|
14
15
|
import { mirrorBanner, reportAgentsInstructions, reportConfig, reportConfigSchema, reportExecution, reportExecutionSummary, reportPlan, reportSkillInstall, reportValue, } from './reporter.js';
|
|
15
16
|
import { resolveNextVersion } from './version.js';
|
|
17
|
+
import { runHooks, runHooksQuiet, hookEnvFromConfig, hookEnvForPlan, hookEnvForResult } from './hooks.js';
|
|
16
18
|
const mirrorVersion = readInstalledVersion();
|
|
17
19
|
const globalArgs = {
|
|
18
20
|
config: { type: 'string', description: 'Path to mirror.config.toml' },
|
|
@@ -143,23 +145,50 @@ const handleCliError = (error, verbose, exitCode) => {
|
|
|
143
145
|
process.exit(exitCode ?? 1);
|
|
144
146
|
};
|
|
145
147
|
const createInitCommand = () => defineCommand({
|
|
146
|
-
meta: { name: 'init', description: 'Create a Mirror configuration file.' },
|
|
147
|
-
subCommands: {
|
|
148
|
-
'package.json': createInitKindCommand('package.json'),
|
|
149
|
-
'jsr.json': createInitKindCommand('jsr.json'),
|
|
150
|
-
git: createInitKindCommand('git'),
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
const createInitKindCommand = (kind) => defineCommand({
|
|
154
|
-
meta: { name: kind, description: `Create ${kind} project configuration.` },
|
|
148
|
+
meta: { name: 'init', description: 'Create or update a Mirror configuration file.' },
|
|
155
149
|
args: {
|
|
156
150
|
...globalArgs,
|
|
157
|
-
|
|
151
|
+
source: { type: 'positional', required: false, description: 'Version source: package.json, jsr.json, or git' },
|
|
152
|
+
output: { type: 'string', description: 'Version outputs. Repeat or comma-separate package.json, jsr.json, git.' },
|
|
153
|
+
'package-file': { type: 'string', description: 'Path to package.json' },
|
|
154
|
+
'jsr-file': { type: 'string', description: 'Path to jsr.json' },
|
|
155
|
+
auxiliary: { type: 'string', description: 'Auxiliary package.json paths. Repeat or comma-separate values.' },
|
|
156
|
+
'tag-template': { type: 'string', description: 'Git tag template' },
|
|
157
|
+
name: { type: 'string', description: 'Explicit project name' },
|
|
158
|
+
preid: { type: 'string', description: 'Default prerelease identifier' },
|
|
159
|
+
commit: { type: 'boolean', description: 'Create release commits' },
|
|
160
|
+
push: { type: 'boolean', description: 'Push release refs' },
|
|
161
|
+
'non-interactive': { type: 'boolean', description: 'Skip interactive prompts and use flags + defaults' },
|
|
162
|
+
yes: { type: 'boolean', description: 'Overwrite an existing mirror.config.toml with generated defaults' },
|
|
158
163
|
},
|
|
159
164
|
async run(context) {
|
|
160
165
|
const options = cliOptions(context.rawArgs, context.args);
|
|
161
|
-
const
|
|
162
|
-
|
|
166
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
167
|
+
const positionalSource = adapterArg(context.args['source']);
|
|
168
|
+
const commitProvided = context.rawArgs.includes('--commit');
|
|
169
|
+
const pushProvided = context.rawArgs.includes('--push');
|
|
170
|
+
const flags = {
|
|
171
|
+
source: options.source ?? positionalSource,
|
|
172
|
+
output: options.output,
|
|
173
|
+
packagePath: options.packageFile,
|
|
174
|
+
auxiliaryPaths: options.auxiliary,
|
|
175
|
+
jsrPath: options.jsrFile,
|
|
176
|
+
tagTemplate: options.tagTemplate,
|
|
177
|
+
name: options.name,
|
|
178
|
+
prereleaseId: options.preid,
|
|
179
|
+
commit: commitProvided ? options.commit : undefined,
|
|
180
|
+
push: pushProvided ? options.push : undefined,
|
|
181
|
+
};
|
|
182
|
+
const interactive = isInteractiveInit(options);
|
|
183
|
+
const prompter = interactive ? createReadlineInitPrompter() : undefined;
|
|
184
|
+
try {
|
|
185
|
+
const answers = await resolveInitAnswers(flags, cwd, prompter);
|
|
186
|
+
const path = await writeInitConfigFromAnswers(answers, cwd, Boolean(options.yes));
|
|
187
|
+
process.stdout.write(reportValue(`created ${path}`, options.format));
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
await prompter?.close();
|
|
191
|
+
}
|
|
163
192
|
},
|
|
164
193
|
});
|
|
165
194
|
const createConfigCommand = () => defineCommand({
|
|
@@ -273,13 +302,41 @@ const createVersionCommand = () => defineCommand({
|
|
|
273
302
|
async run(context) {
|
|
274
303
|
const options = cliOptions(context.rawArgs, context.args);
|
|
275
304
|
await prepareAgents(options);
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
305
|
+
const target = String(context.args['target']);
|
|
306
|
+
const config = await loadMirrorConfig(options);
|
|
307
|
+
const hooks = config.hooks;
|
|
308
|
+
const hookResults = [];
|
|
309
|
+
const baseEnv = hookEnvFromConfig(config, target);
|
|
310
|
+
try {
|
|
311
|
+
await runHooks('before:everything', hooks['before:everything'], baseEnv, config.cwd);
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
hookResults.push({ name: 'before:everything', commands: hooks['before:everything'] ?? [], status: 'failure', durationMs: 0, exitCode: error instanceof Error ? 1 : 1, stderr: error instanceof Error ? error.message : String(error) });
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
try {
|
|
318
|
+
await runHooks('before:plan', hooks['before:plan'], baseEnv, config.cwd);
|
|
319
|
+
const plan = await buildVersionPlan(target, options);
|
|
320
|
+
const planEnv = hookEnvForPlan(plan, target);
|
|
321
|
+
await runHooks('after:plan', hooks['after:plan'], planEnv, config.cwd);
|
|
322
|
+
if (options.format !== 'json')
|
|
323
|
+
process.stdout.write(mirrorBanner(plan.configPath ? plan.configPath : ''));
|
|
324
|
+
if (options.format !== 'json')
|
|
325
|
+
process.stdout.write(reportPlan(plan, options.format));
|
|
326
|
+
await runHooks('before:apply', hooks['before:apply'], planEnv, config.cwd);
|
|
327
|
+
try {
|
|
328
|
+
const result = await executeVersionPlan(plan, options, hooks, target);
|
|
329
|
+
result.hookResults = hookResults;
|
|
330
|
+
process.stdout.write(options.format === 'json' ? reportExecution(result, options.format) : reportExecutionSummary(result, options.format));
|
|
331
|
+
}
|
|
332
|
+
finally {
|
|
333
|
+
const resultEnv = hookEnvForResult(plan, target, true, Boolean(options.dryRun));
|
|
334
|
+
await runHooksQuiet('after:apply', hooks['after:apply'], resultEnv, config.cwd, hookResults);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
finally {
|
|
338
|
+
await runHooksQuiet('after:everything', hooks['after:everything'], baseEnv, config.cwd, hookResults);
|
|
339
|
+
}
|
|
283
340
|
},
|
|
284
341
|
}),
|
|
285
342
|
},
|
|
@@ -295,16 +352,26 @@ const cliOptions = (rawArgs, args) => {
|
|
|
295
352
|
output: parsed.output ?? outputArg(args['output']),
|
|
296
353
|
packageFile: parsed.packageFile ?? stringArg(args['packageFile']),
|
|
297
354
|
jsrFile: parsed.jsrFile ?? stringArg(args['jsrFile']),
|
|
355
|
+
auxiliary: parsed.auxiliary ?? outputListArg(args['auxiliary']),
|
|
356
|
+
tagTemplate: parsed.tagTemplate ?? stringArg(args['tagTemplate']),
|
|
357
|
+
name: parsed.name ?? stringArg(args['name']),
|
|
298
358
|
preid: parsed.preid ?? stringArg(args['preid']),
|
|
299
359
|
dryRun: parsed.dryRun || args['dryRun'] === true,
|
|
300
360
|
commit: parsed.commit || args['commit'] === true,
|
|
301
361
|
push: parsed.push || args['push'] === true,
|
|
302
362
|
allowDirty: parsed.allowDirty || args['allowDirty'] === true,
|
|
363
|
+
nonInteractive: parsed.nonInteractive || args['nonInteractive'] === true,
|
|
303
364
|
yes: parsed.yes || args['yes'] === true,
|
|
304
365
|
verbose: parsed.verbose || args['verbose'] === true,
|
|
305
366
|
};
|
|
306
367
|
};
|
|
307
368
|
const stringArg = (value) => (typeof value === 'string' ? value : undefined);
|
|
369
|
+
const outputListArg = (value) => {
|
|
370
|
+
if (typeof value !== 'string')
|
|
371
|
+
return undefined;
|
|
372
|
+
const values = value.split(',').map((item) => item.trim()).filter(Boolean);
|
|
373
|
+
return values.length > 0 ? values : undefined;
|
|
374
|
+
};
|
|
308
375
|
const adapterArg = (value) => {
|
|
309
376
|
if (value === 'package.json' || value === 'jsr.json' || value === 'git')
|
|
310
377
|
return value;
|
package/library/config.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
3
|
*/
|
|
4
|
-
import type { MirrorAdapterName, MirrorCliOptions, MirrorConfig, MirrorConfigDiscovery, MirrorRawConfig } from './types.js';
|
|
4
|
+
import type { MirrorAdapterName, MirrorCliOptions, MirrorConfig, MirrorConfigDiscovery, MirrorInitAnswers, MirrorRawConfig } from './types.js';
|
|
5
5
|
export declare const resolveMirrorPath: (cwd: string, path: string) => string;
|
|
6
6
|
export declare const relativeFromCwd: (cwd: string, path: string) => string;
|
|
7
7
|
export declare const discoverMirrorConfig: (cwd: string, explicitPath?: string) => Promise<MirrorConfigDiscovery>;
|
|
8
8
|
export declare const readConfigFile: (path: string) => Promise<MirrorRawConfig>;
|
|
9
9
|
export declare const loadMirrorConfig: (options?: MirrorCliOptions) => Promise<MirrorConfig>;
|
|
10
10
|
export declare const normalizeMirrorConfig: (raw: MirrorRawConfig, cwd: string, configPath: string | undefined, options?: MirrorCliOptions) => MirrorConfig;
|
|
11
|
+
export declare const defaultInitAnswersForSource: (kind: MirrorAdapterName, cwd: string) => MirrorInitAnswers;
|
|
12
|
+
export declare const generateInitConfig: (answers: MirrorInitAnswers, cwd: string) => string;
|
|
11
13
|
export declare const createInitConfig: (kind: MirrorAdapterName, cwd: string) => string;
|
|
12
14
|
export declare const writeInitConfig: (kind: MirrorAdapterName, cwd: string, overwrite?: boolean) => Promise<string>;
|
|
15
|
+
export declare const writeInitConfigFromAnswers: (answers: MirrorInitAnswers, cwd: string, overwrite?: boolean) => Promise<string>;
|
|
16
|
+
export declare const reconcileInitConfig: (existingContent: string, defaultsContent: string) => string;
|
|
13
17
|
export declare const configPathForDisplay: (config: MirrorConfig) => string;
|
|
14
18
|
//# sourceMappingURL=config.d.ts.map
|
package/library/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../source/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../source/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EAEjB,eAAe,EAChB,MAAM,YAAY,CAAA;AAQnB,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,MAAM,MAAM,WAAmD,CAAA;AAE9G,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,EAAE,MAAM,MAAM,WAGxD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,KAAK,MAAM,EAAE,eAAe,MAAM,KAAG,OAAO,CAAC,qBAAqB,CAa5G,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,MAAM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