diff --git a/scripts/register_project.sh b/scripts/register_project.sh index fae3402..45f06b3 100755 --- a/scripts/register_project.sh +++ b/scripts/register_project.sh @@ -15,7 +15,7 @@ # 2. Verify the domain exists via GET /domains/{slug}/ # 3. Look up the topic ID for the domain (first active topic) # 4. Check that state-hub is in ~/.claude.json; warn if missing -# 5. Write $project_path/CLAUDE.md from the template (skip if exists or --additional) +# 5. Write $project_path/CLAUDE.custodian.md (suggestion; repo agent integrates → CLAUDE.md) # 6. POST to /repos/ to register the repo # 7. POST a progress event recording the registration @@ -112,24 +112,39 @@ else echo " MCP OK" fi -# ── Step 5: Write CLAUDE.md ──────────────────────────────────────────────────── +# ── Step 5: Write CLAUDE.custodian.md (suggestion for the repo agent) ───────── CLAUDE_MD="$PROJECT_PATH/CLAUDE.md" +SUGGESTION_FILE="$PROJECT_PATH/CLAUDE.custodian.md" TEMPLATE="$SCRIPT_DIR/project_claude_md.template" -if [[ "$ADDITIONAL" == "--additional" ]]; then - echo "==> --additional flag: skipping CLAUDE.md (already exists for this domain)." -elif [[ -f "$CLAUDE_MD" ]]; then - echo "==> CLAUDE.md already exists at $CLAUDE_MD — skipping." -else - echo "==> Writing CLAUDE.md to $CLAUDE_MD ..." +echo "==> Writing custodian suggestion to $SUGGESTION_FILE ..." +{ + cat <<'PREAMBLE' + + +PREAMBLE sed \ -e "s|{PROJECT_NAME}|$PROJECT_NAME|g" \ -e "s|{DOMAIN}|$DOMAIN|g" \ -e "s|{TOPIC_ID}|$TOPIC_ID|g" \ -e "s|{REPO_SLUG}|$REPO_SLUG|g" \ - "$TEMPLATE" > "$CLAUDE_MD" - echo " Written." -fi + "$TEMPLATE" +} > "$SUGGESTION_FILE" +echo " Written. The repo agent should integrate it into CLAUDE.md and delete this file." # ── Step 6: Register repo in State Hub ──────────────────────────────────────── echo "==> Registering repo '$PROJECT_NAME' under domain '$DOMAIN' ..." @@ -165,7 +180,7 @@ payload = { 'author': 'custodian', 'detail': { 'project_path': '$PROJECT_PATH', - 'claude_md': '$CLAUDE_MD', + 'suggestion_file': '$SUGGESTION_FILE', 'domain': '$DOMAIN', 'repo_slug': '$REPO_SLUG', }, @@ -184,14 +199,14 @@ echo " Project: $PROJECT_NAME" echo " Domain: $DOMAIN" echo " Repo slug: $REPO_SLUG" [[ -n "$TOPIC_ID" ]] && echo " Topic ID: $TOPIC_ID" -echo " CLAUDE.md: $CLAUDE_MD" +echo " Suggestion: $SUGGESTION_FILE (repo agent should integrate → CLAUDE.md)" echo "" echo "Next: restart Claude Code for the MCP server to be available in this project." # ── Optional: SBOM ingest ───────────────────────────────────────────────────── if [[ "$ADDITIONAL" != "--additional" ]]; then echo "" - read -r -p "==> Run SBOM ingest now? (auto-detects lockfile in $PROJECT_PATH) [y/N] " INGEST_NOW + read -r -p "==> Run SBOM ingest now? (auto-detects lockfile in $PROJECT_PATH) [y/N] " INGEST_NOW Ingesting SBOM for '$REPO_SLUG' ..." INGEST_UV="$STATE_HUB_DIR/.venv/bin/python"