Make template fresh-start clean: derive Codex target, auto-clean dist - #6
Merged
Merged
Conversation
The codex-acceptance driver hardcoded the example plugin and marketplace names, so removing or renaming the example required editing the script. It now reads both from .agents/plugins/marketplace.json: a single listed plugin is selected automatically, multiple require --plugin <name>, and an empty marketplace makes preflight a no-op. verify and cleanup key off the preflight snapshot so they stay correct even after the manifest changes. Adds unit tests for the resolver, --plugin parsing, and the manifest loader.
build-standalone wrote dist output for current plugins but never removed dist/<target>/<plugin> for plugins that no longer exist, so a removed or renamed plugin left orphaned exports in the committed dist/ tree until they were deleted by hand. buildAll now wipes the target roots it owns before regenerating, making dist/ a pure function of plugins/. Adds regression tests covering plugin removal, rename, an empty plugins/ directory, and a missing plugins/ directory.
There was a problem hiding this comment.
Pull request overview
This PR updates the template’s tooling so it no longer hardcodes the bundled example plugin and so generated dist/ output is automatically cleaned, making plugins/ the single source of truth for both Codex acceptance testing and standalone export builds.
Changes:
- Derive Codex acceptance test target (marketplace + plugin) from
.agents/plugins/marketplace.json, with--plugin <name>required only when ambiguous and a no-op when no plugins are listed. - Make
buildAllwipe its manageddist/target roots (gemini,kiro) before regenerating, eliminating stale exports from removed/renamed plugins. - Add Vitest coverage for both target resolution/parsing/manifest loading and for stale
dist/cleanup behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
scripts/codex-acceptance.ts |
Derives Codex acceptance targets from the marketplace manifest; adds CLI parsing + snapshot-driven verify/cleanup. |
src/build-standalone.ts |
Ensures dist/gemini + dist/kiro are cleaned before rebuild so dist/ mirrors plugins/. |
tests/codex-acceptance.test.ts |
Adds unit tests for manifest loading, --plugin parsing, and plugin selection resolution. |
tests/build-standalone.test.ts |
Adds regression tests ensuring stale dist/ artifacts are removed across rebuild scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+163
to
+168
| let raw: unknown; | ||
| try { | ||
| raw = readJson(file); | ||
| } catch (e) { | ||
| return { kind: "invalid", issues: `not valid JSON: ${String(e)}` }; | ||
| } |
Comment on lines
+215
to
+222
| export function parsePluginArg(argv: readonly string[]): string | undefined { | ||
| for (let i = 0; i < argv.length; i++) { | ||
| const a = argv[i]; | ||
| if (a === "--plugin") return argv[i + 1]; | ||
| if (a?.startsWith("--plugin=")) return a.slice("--plugin=".length); | ||
| } | ||
| return undefined; | ||
| } |
Addresses review feedback on the Codex acceptance driver: - loadMarketplace now reads the file and parses JSON in separate steps, so filesystem errors report as read errors instead of being mislabeled "not valid JSON". - parsePluginArg returns undefined when the value is missing, empty, or looks like another option (e.g. `--plugin --dry-run`, `--plugin=`), rather than consuming the next flag as the plugin name. Adds tests for the read-error branch and the new argument-parsing edge cases.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Removing the bundled example plugin to start a fresh template should be deleting files, not performing surgery on build scripts or hand-cleaning generated output. Two scripts stood in the way; this branch fixes both so
plugins/is the single source of truth and the rest of the tooling adapts on its own.Codex acceptance driver no longer hardcodes the example
scripts/codex-acceptance.tspinned the marketplace and plugin names in two module constants, so renaming or removing the example plugin meant editing the script. It now derives both from.agents/plugins/marketplace.json:--plugin <name>(with a helpful list on miss);preflighta clean no-op instead of failing.verifyandcleanupread the target from the snapshotpreflightwrites, so they stay correct even if the manifest changes between phases. This brings the script in line withvalidate/build/build-hooks, which already iterateplugins/generically.Builds clear stale standalone exports
build-standaloneregenerateddist/<target>/<plugin>for current plugins but never removed output for plugins that no longer exist — so a removed or renamed plugin left orphaned exports in the committeddist/tree until deleted by hand.buildAllnow wipes the target roots it owns (gemini,kiro) before regenerating, makingdist/a pure function ofplugins/. Rebuilding with the example present produces no diff.Tests
New
tests/codex-acceptance.test.ts(resolver,--pluginparsing, manifest loader incl. missing/malformed/invalid) andtests/build-standalone.test.ts(removal, rename, emptyplugins/, missingplugins/). Full suite: 87 passing.typecheck,lint, and a cleanbuild(nodist/drift) all pass. Note: importing the acceptance script into a test put it undertscfor the first time, surfacing a few pre-existing strict-mode violations that are fixed here.