metagit-bootstrap · diff
git:20260605.bbd0b89 to git:20260916.0fdac6b
32 added, 88 removed. Audit A to A.
---
name: metagit-bootstrap
- description: Use when generating or refining local .metagit.yml files using deterministic discovery plus MCP sampling or CLI-only fallbacks.
+ description: Create or refine a local .metagit.yml. Default is deterministic `metagit init`; do not dump detect payloads into context.
metadata:
internal: true
---
- # Metagit MCP Bootstrap Skill
-
- Use this skill to create a local `.metagit.yml` using discovery-driven prompts and MCP sampling.
+ # Metagit bootstrap
- ## Purpose
+ Create a valid `.metagit.yml` with **minimal tokens**. Prefer code over sampling.
- Generate schema-compliant `.metagit.yml` files with high contextual quality while preserving safety and explicit user control.
+ ## Token rules
- ## Bundled scripts (optional)
+ - Default to **deterministic init**. Do not start with MCP sampling or `config example`.
+ - Never run `metagit detect repo_map` (full directory maps blow the context window).
+ - Never paste full detect YAML/JSON into the conversation. Write it to a file and read only the fields you need.
+ - Prefer `detect … -o summary` on stdout. Use `--output-file` for the full payload.
- Helper scripts require the full skill tree or the PyPI package copy. Hermes `skill_manage`
- (SKILL.md only) does **not** include `scripts/`.
+ ## Default path (deterministic)
```bash
+ export METAGIT_AGENT_MODE=true
+ # missing manifest:
+ metagit init --kind application --no-prompt
+ # or:
SKILL_ROOT="$(python3 -c "import metagit, pathlib; print(pathlib.Path(metagit.__file__).parent / 'data/skills/metagit-bootstrap')")"
- "$SKILL_ROOT/scripts/bootstrap-config.sh" [root_path] [force]
+ "$SKILL_ROOT/scripts/bootstrap-config.sh" .
+ metagit config validate -c .metagit.yml
```
- Behavior:
- - Writes `.metagit.yml` when missing (minimal application scaffold)
- - Validates via Metagit config models
- - Returns a compact status line for agents
-
- ## Execution modes
-
- | Mode | When |
- |------|------|
- | **CLI-only** | Shell agent, no MCP host, Hermes without sampling |
- | **MCP sampling** | Host supports `sampling/createMessage` |
- | **Plan-only** | Sampling unavailable; return draft for human/agent review |
-
- ## CLI-only fallback (no MCP sampling)
-
- Use this path when `sampling/createMessage` is unavailable — common in CLI-only agent
- sessions or Hermes installs without MCP sampling.
-
- 1. **Discover evidence** from the target repository:
-
- ```bash
- export METAGIT_AGENT_MODE=true
- metagit detect repository -p . -o json
- metagit detect repo -p . -o yaml
- metagit detect project -p . -o yaml
- metagit detect repo_map -p . -o json
- ```
+ `bootstrap-config.sh` writes a minimal application scaffold when `.metagit.yml` is missing and prints `status=written|exists`. Do not overwrite a valid manifest without explicit confirmation.
- 2. **Minimal manifest** when none exists:
+ Existing manifest: `metagit config validate -c .metagit.yml`. Patch with `metagit config patch` — do not regenerate from detect dumps.
- ```bash
- metagit init --kind application --no-prompt
- # or: "$SKILL_ROOT/scripts/bootstrap-config.sh" .
- metagit config validate -c .metagit.yml
- ```
+ ## Optional enrichment (file-backed)
- 3. **Richer draft** — agent composes YAML from detect output + schema reference:
+ Only after init, and only if catalog fields are still empty:
```bash
- metagit config example # full annotated exemplar
- metagit config tree -c .metagit.yml --json # after minimal init
+ mkdir -p .metagit/.detect
+ metagit detect repository -p . -o summary
+ metagit detect repository -p . -o json --output-file .metagit/.detect/repository.json
+ # jq '.language, .kind, .frameworks' .metagit/.detect/repository.json
```
- Write draft to `.metagit.generated.yml`, validate, then promote on confirmation:
+ Stdout of `--output-file` is a compact line (`status=written path=… bytes=… format=json`). Do not `cat` the file unless selecting fields.
- ```bash
- metagit config validate -c .metagit.generated.yml
- mv .metagit.generated.yml .metagit.yml # only after explicit operator approval
- metagit config validate -c .metagit.yml
- ```
+ `detect repo` / `detect project` follow the same rule: `--output-file .metagit/.detect/…` or `-o summary`. Skip them if summary already has language/kind.
- 4. **Incremental refinement** on an existing manifest:
+ ## Incremental patch
```bash
metagit config show -c .metagit.yml --json
metagit config patch -c .metagit.yml --op set --path <path> --value <json> --save
- metagit prompt repo -p P -n R -k repo-enrich --text-only # merge detect into catalog
+ metagit prompt repo -p P -n R -k repo-enrich --text-only
```
- Never call MCP-only bootstrap tools from CLI-only sessions. Do not overwrite `.metagit.yml`
- without explicit confirmation.
-
- ## MCP sampling workflow
-
- When sampling **is** supported:
-
- 1. Gather deterministic discovery data from the target repository:
- - source language/framework indicators
- - package/lock/build files
- - Dockerfiles and CI workflows
- - terraform files and module usage
- 2. Build a strict prompt package:
- - output format contract: valid YAML only
- - required schema fields and constraints
- - extracted discovery evidence
- 3. Call `sampling/createMessage`.
- 4. Validate generated YAML with Metagit config models.
- 5. Retry with validation feedback up to a fixed max attempt count.
- 6. Return draft output and write only on explicit confirmation.
-
- ## Output Modes
-
- - **Plan-only mode**: return prompt + discovery summary if sampling unavailable.
- - **Draft mode**: return `.metagit.generated.yml` content.
- - **Confirmed write mode**: write to `.metagit.yml` only with explicit parameter (`confirm_write=true`).
-
- ## Quality Bar
+ ## MCP sampling (optional, not default)
- - Preserve discovered evidence in structured fields.
- - Include workspace project and related repo entries where detectable.
- - Avoid invented repositories or unverifiable dependencies.
+ Use `metagit_bootstrap_config` only when the host supports `sampling/createMessage` **and** the operator asked for a richer draft than `init`. Discovery context is already a short artifact list — do not attach repo maps. Validate YAML; write `.metagit.yml` only with `confirm_write=true`. Plan-only: return the prompt, do not invent repos.
- ## Safety Rules
+ ## Safety
- Never overwrite `.metagit.yml` silently.
- - Never emit secrets in cleartext.
- - Prefer placeholders for credentials or tokens.
+ - Never emit secrets. Prefer placeholders for tokens.
+ - Do not invent repositories or unverifiable dependencies.