generated from coulomb/repo-seed
feat(registration): write CLAUDE.custodian.md instead of overwriting CLAUDE.md
Instead of overwriting the target repo's CLAUDE.md, the registration script now writes CLAUDE.custodian.md — a suggestion file with an integration header. The repo's Claude agent integrates both files and deletes the suggestion when done, preserving existing project conventions. Also fix: `read` prompt now redirects from /dev/tty so the script doesn't exit with code 1 when run non-interactively via make. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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'
|
||||
<!--
|
||||
CUSTODIAN SUGGESTION — generated by `make register-project`
|
||||
|
||||
This file was written by the Custodian State Hub registration workflow.
|
||||
It contains the standard State Hub integration block for this repository.
|
||||
|
||||
A Claude Code agent in this repo should:
|
||||
1. Read this file and the existing CLAUDE.md side by side
|
||||
2. Integrate the sections below into CLAUDE.md — preserve all existing
|
||||
project-specific conventions; add or update the hub integration block
|
||||
3. Delete this file once integration is complete and commit the result
|
||||
|
||||
Do NOT add this file to .gitignore. It is a temporary artefact that signals
|
||||
pending integration work to the repo agent.
|
||||
-->
|
||||
|
||||
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 </dev/tty || INGEST_NOW="N"
|
||||
if [[ "$INGEST_NOW" =~ ^[Yy]$ ]]; then
|
||||
echo "==> Ingesting SBOM for '$REPO_SLUG' ..."
|
||||
INGEST_UV="$STATE_HUB_DIR/.venv/bin/python"
|
||||
|
||||
Reference in New Issue
Block a user