Skip to content

Make template fresh-start clean: derive Codex target, auto-clean dist - #6

Merged
mike-north merged 3 commits into
mainfrom
claude/keen-ellis-553e36
May 29, 2026
Merged

mike-north merged 3 commits into
mainfrom
claude/keen-ellis-553e36

Conversation

@mike-north

Copy link
Copy Markdown
Collaborator

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.ts pinned 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:

  • a single listed plugin is selected automatically;
  • multiple plugins require --plugin <name> (with a helpful list on miss);
  • an empty marketplace makes preflight a clean no-op instead of failing.

verify and cleanup read the target from the snapshot preflight writes, so they stay correct even if the manifest changes between phases. This brings the script in line with validate/build/build-hooks, which already iterate plugins/ generically.

Builds clear stale standalone exports

build-standalone regenerated dist/<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 committed dist/ tree until deleted by hand. buildAll now wipes the target roots it owns (gemini, kiro) before regenerating, making dist/ a pure function of plugins/. Rebuilding with the example present produces no diff.

Tests

New tests/codex-acceptance.test.ts (resolver, --plugin parsing, manifest loader incl. missing/malformed/invalid) and tests/build-standalone.test.ts (removal, rename, empty plugins/, missing plugins/). Full suite: 87 passing. typecheck, lint, and a clean build (no dist/ drift) all pass. Note: importing the acceptance script into a test put it under tsc for the first time, surfacing a few pre-existing strict-mode violations that are fixed here.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 buildAll wipe its managed dist/ 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.
@mike-north
mike-north merged commit 65c8c9c into main May 29, 2026
2 checks passed
@mike-north
mike-north deleted the claude/keen-ellis-553e36 branch May 29, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants