fix: update scripts/context-sync.sh with HANDROLLED sentinel support
Phase 4 sweep updated .gitignore and Taskfile.yml but missed this script. Copy the canonical from ~/dev/project-template/ so the HANDROLLED escape hatch works in this project (a CLAUDE.md or adapter file containing '<!-- HANDROLLED: do not regenerate -->' near the top is now skipped on regeneration).
This commit is contained in:
@@ -14,6 +14,21 @@ set -euo pipefail
|
|||||||
|
|
||||||
PROJECT_FILE=".context/PROJECT.md"
|
PROJECT_FILE=".context/PROJECT.md"
|
||||||
SKILLS_DIR=".skills"
|
SKILLS_DIR=".skills"
|
||||||
|
HANDROLLED_MARKER="HANDROLLED: do not regenerate"
|
||||||
|
|
||||||
|
# Skip regenerating any target file that opts out via the HANDROLLED sentinel.
|
||||||
|
# Add `<!-- HANDROLLED: do not regenerate -->` near the top of a file to keep
|
||||||
|
# it hand-maintained even when context:sync runs. Useful for projects whose
|
||||||
|
# CLAUDE.md (or other adapter) is the single source of truth — e.g. ops repos
|
||||||
|
# where incident-derived safety rules must not be diluted by templated content.
|
||||||
|
skip_if_handrolled() {
|
||||||
|
local file="$1"
|
||||||
|
if [ -f "$file" ] && head -n 20 "$file" | grep -q "$HANDROLLED_MARKER"; then
|
||||||
|
echo " → $file (handrolled, skipped)"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Walk up to find root .context/AGENT.md
|
# Walk up to find root .context/AGENT.md
|
||||||
find_root_context() {
|
find_root_context() {
|
||||||
@@ -56,6 +71,7 @@ root_block() {
|
|||||||
# Claude Code walks up the tree — it finds ~/dev/CLAUDE.md automatically.
|
# Claude Code walks up the tree — it finds ~/dev/CLAUDE.md automatically.
|
||||||
# Project-level CLAUDE.md only needs project-specific context.
|
# Project-level CLAUDE.md only needs project-specific context.
|
||||||
generate_claude() {
|
generate_claude() {
|
||||||
|
skip_if_handrolled CLAUDE.md && return
|
||||||
cat "$PROJECT_FILE" > CLAUDE.md
|
cat "$PROJECT_FILE" > CLAUDE.md
|
||||||
echo " → CLAUDE.md (project-only; Claude Code inherits root)"
|
echo " → CLAUDE.md (project-only; Claude Code inherits root)"
|
||||||
}
|
}
|
||||||
@@ -64,12 +80,14 @@ generate_claude() {
|
|||||||
# These tools read AGENTS.md from cwd but don't walk up.
|
# These tools read AGENTS.md from cwd but don't walk up.
|
||||||
# Concatenate root + project.
|
# Concatenate root + project.
|
||||||
generate_agents() {
|
generate_agents() {
|
||||||
|
skip_if_handrolled AGENTS.md && return
|
||||||
{ root_block; cat "$PROJECT_FILE"; } > AGENTS.md
|
{ root_block; cat "$PROJECT_FILE"; } > AGENTS.md
|
||||||
echo " → AGENTS.md (root + project; Crush, Pi, Antigravity)"
|
echo " → AGENTS.md (root + project; Crush, Pi, Antigravity)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ── Cursor ───────────────────────────────────────────────────
|
# ── Cursor ───────────────────────────────────────────────────
|
||||||
generate_cursor() {
|
generate_cursor() {
|
||||||
|
skip_if_handrolled .cursorrules && return
|
||||||
{
|
{
|
||||||
echo "# Cursor rules — auto-generated"
|
echo "# Cursor rules — auto-generated"
|
||||||
echo "# Do not edit. Run: task context:sync"
|
echo "# Do not edit. Run: task context:sync"
|
||||||
@@ -82,6 +100,7 @@ generate_cursor() {
|
|||||||
|
|
||||||
# ── Aider ────────────────────────────────────────────────────
|
# ── Aider ────────────────────────────────────────────────────
|
||||||
generate_aider() {
|
generate_aider() {
|
||||||
|
skip_if_handrolled .aider.conventions.md && return
|
||||||
{ root_block; cat "$PROJECT_FILE"; } > .aider.conventions.md
|
{ root_block; cat "$PROJECT_FILE"; } > .aider.conventions.md
|
||||||
if [ ! -f .aider.conf.yml ]; then
|
if [ ! -f .aider.conf.yml ]; then
|
||||||
cat > .aider.conf.yml << 'YAML'
|
cat > .aider.conf.yml << 'YAML'
|
||||||
@@ -94,6 +113,7 @@ YAML
|
|||||||
|
|
||||||
# ── Generic system prompt (Open WebUI, Mods, etc.) ──────────
|
# ── Generic system prompt (Open WebUI, Mods, etc.) ──────────
|
||||||
generate_system_prompt() {
|
generate_system_prompt() {
|
||||||
|
skip_if_handrolled .context/system-prompt.txt && return
|
||||||
{
|
{
|
||||||
echo "You are a coding assistant working on a specific project."
|
echo "You are a coding assistant working on a specific project."
|
||||||
echo "Follow all conventions from both the root agent context and project context."
|
echo "Follow all conventions from both the root agent context and project context."
|
||||||
|
|||||||
Reference in New Issue
Block a user