feat(module): scaffold local source tree on init#17
Merged
Conversation
`mirrorstack module init` now does both halves of "create a module": register on the platform AND scaffold a local Go source tree from the SDK template. Without this, every developer's first `mirrorstack dev` (future) would have nothing to launch. Two new flags: - --no-scaffold: register only, skip filesystem (CI / re-registration) - --dir <path>: override default ./<slug>/ (use --dir . for cwd) The scaffold target's writability is checked before any remote POST so we never leave a registered module without a local tree because of e.g. a non-empty target dir. Each file is written via OpenOptions::create_new so a file slipped in during the API round-trip surfaces as an error instead of a silent overwrite. Templates are vendored under templates/module/ and embedded via include_str!. Source of truth for the shape is app-module-sdk's examples/template/; vendored copies must be re-synced when the SDK changes shape (no automatic mirror yet). go.mod.tmpl pins github.com/mirrorstack-ai/app-module-sdk v0.1.0 — the SDK's first published tag — so scaffolded modules `go mod tidy` cleanly from anywhere on disk, no replace directive needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Used by devs as a convenience pointer to target/release/mirrorstack so they can run ./mirrorstack from the repo root without typing the full target path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI fmt --check failed on the SQL_INIT include_str! line; rustfmt prefers the long form on a single line. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
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.
Summary
mirrorstack module initnow registers the module on the platform AND scaffolds a local Go source tree from the embedded SDK template--no-scaffold(register only) and--dir <path>(override default./<slug>/)v0.1.0(cut in chore: add release workflow + cut v0.1.0 app-module-sdk#93) so scaffolded modules resolve via the Go module proxy with noreplacedirectiveAfter this lands
Why vendor templates instead of fetch from SDK?
Self-contained build —
cargo buildof the CLI doesn't depend on a sibling SDK checkout being present. Trade-off: when the SDK'sexamples/template/changes shape, the vendored copy here must be re-synced manually. Documented inscaffold.rsmodule doc.Test plan
cargo test— 40 tests pass (10 new for scaffolding)cargo clippy --all-targets -- -D warningscleanmediamodule into/tmp, rungo mod tidy && go vet && go build— all clean (SDK resolves via Go proxy)cd ~/Documents/MirrorStack-AI-V2 && ./mirrorstack-cli/mirrorstack module initagainst local stack, sanity-check scaffolded tree🤖 Generated with Claude Code