feat(deploy): install update/remove scripts into .mam_deploy/ and refine markdown staging
This commit is contained in:
+69
-27
@@ -114,15 +114,27 @@ log_info "Deploying orchestration rules & skills (.agents/)..."
|
||||
mkdir -p "$TARGET_DIR/.agents"
|
||||
|
||||
# Sync rules and skills, avoiding copying temporary or system files
|
||||
# Exclude git histories, reports, logs or internal runtime cache if any
|
||||
rsync -a --exclude='.git/' --exclude='/reports/' --exclude='*.log' --exclude='__pycache__/' --exclude='*.pyc' "$SRC_DIR/.agents/" "$TARGET_DIR/.agents/"
|
||||
# Exclude git histories, reports, references, logs or internal runtime cache
|
||||
rsync -a --exclude='.git/' --exclude='/reports/' --exclude='/references/' --exclude='*.log' --exclude='*.tmp' --exclude='__pycache__/' --exclude='*.pyc' "$SRC_DIR/.agents/" "$TARGET_DIR/.agents/"
|
||||
log_ok "Deployed Rules and Skills under target's .agents/"
|
||||
|
||||
|
||||
# Copy config templates and generate scripts (M-2)
|
||||
if [ -f "$SRC_DIR/.mam.env.example" ]; then
|
||||
cp "$SRC_DIR/.mam.env.example" "$TARGET_DIR/.mam.env.example"
|
||||
log_ok "Copied .mam.env.example configuration template"
|
||||
fi
|
||||
|
||||
# Deploy remove.sh and update.sh into .mam_deploy/ (R-3)
|
||||
mkdir -p "$TARGET_DIR/.mam_deploy"
|
||||
if [ -f "$SRC_DIR/deploy/remove.sh" ]; then
|
||||
cp "$SRC_DIR/deploy/remove.sh" "$TARGET_DIR/.mam_deploy/remove.sh"
|
||||
chmod 0755 "$TARGET_DIR/.mam_deploy/remove.sh"
|
||||
fi
|
||||
if [ -f "$SRC_DIR/deploy/update.sh" ]; then
|
||||
cp "$SRC_DIR/deploy/update.sh" "$TARGET_DIR/.mam_deploy/update.sh"
|
||||
chmod 0755 "$TARGET_DIR/.mam_deploy/update.sh"
|
||||
fi
|
||||
|
||||
if [ -f "$SRC_DIR/deploy/generate-env.sh" ]; then
|
||||
mkdir -p "$TARGET_DIR/scripts"
|
||||
cp "$SRC_DIR/deploy/generate-env.sh" "$TARGET_DIR/scripts/generate-env.sh"
|
||||
@@ -160,32 +172,62 @@ else
|
||||
log_ok "Guidelines AGENTS.md copied to project root."
|
||||
fi
|
||||
|
||||
# 4. Gitignore adjustments
|
||||
# 4. Gitignore adjustments (R-4: managed block)
|
||||
log_info "Registering runtime isolation blocks in .gitignore..."
|
||||
GITIGNORE="$TARGET_DIR/.gitignore"
|
||||
MAM_PATTERN="/.mam/"
|
||||
VENV_PATTERN="/.venv/"
|
||||
|
||||
if [ -f "$GITIGNORE" ]; then
|
||||
# Register .mam/ if absent
|
||||
if grep -Eq '^/?\.mam/?$' "$GITIGNORE"; then
|
||||
log_ok ".mam/ already registered in target's .gitignore."
|
||||
else
|
||||
echo -e "\n# Multi-Agent Mux (MAM) runtime databases and isolation cache\n$MAM_PATTERN" >> "$GITIGNORE"
|
||||
log_ok "Appended /.mam/ registration to .gitignore."
|
||||
fi
|
||||
|
||||
# Register .venv/ if absent
|
||||
if grep -Eq '^/?\.venv/?$' "$GITIGNORE"; then
|
||||
log_ok ".venv/ already registered in target's .gitignore."
|
||||
else
|
||||
echo -e "\n# Python virtual environment\n$VENV_PATTERN" >> "$GITIGNORE"
|
||||
log_ok "Appended /.venv/ registration to .gitignore."
|
||||
fi
|
||||
else
|
||||
echo -e "# Multi-Agent Mux (MAM) runtime databases and isolation cache\n$MAM_PATTERN\n\n# Python virtual environment\n$VENV_PATTERN" > "$GITIGNORE"
|
||||
log_ok "Created .gitignore with MAM and .venv exclusions."
|
||||
fi
|
||||
MAM_GI_START="# >>> MAM managed block (managed by install.sh — do not edit) >>>"
|
||||
MAM_GI_END="# <<< MAM managed block <<<"
|
||||
|
||||
python3 - "$GITIGNORE" "$MAM_GI_START" "$MAM_GI_END" <<'PY'
|
||||
import sys, os
|
||||
|
||||
gi_path, start_marker, end_marker = sys.argv[1], sys.argv[2], sys.argv[3]
|
||||
|
||||
block_lines = [
|
||||
start_marker + "\n",
|
||||
"/.venv/\n",
|
||||
"/.mam/\n",
|
||||
"/.mam_deploy/\n",
|
||||
"/.mam.env\n",
|
||||
"/.mam.env.*\n",
|
||||
"!/.mam.env.example\n",
|
||||
"/.cache/multi-agent-mux-monitor/\n",
|
||||
"/.mam-skill-backup.*/\n",
|
||||
"CURRENT_JOB.md\n",
|
||||
end_marker + "\n"
|
||||
]
|
||||
|
||||
lines = []
|
||||
if os.path.exists(gi_path):
|
||||
with open(gi_path, "r") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
new_lines = []
|
||||
in_block = False
|
||||
block_inserted = False
|
||||
|
||||
for line in lines:
|
||||
if line.strip() == start_marker:
|
||||
in_block = True
|
||||
if not block_inserted:
|
||||
new_lines.extend(block_lines)
|
||||
block_inserted = True
|
||||
continue
|
||||
if line.strip() == end_marker:
|
||||
in_block = False
|
||||
continue
|
||||
if not in_block:
|
||||
new_lines.append(line)
|
||||
|
||||
if not block_inserted:
|
||||
if new_lines and not new_lines[-1].endswith("\n"):
|
||||
new_lines[-1] += "\n"
|
||||
new_lines.extend(block_lines)
|
||||
|
||||
with open(gi_path, "w") as f:
|
||||
f.writelines(new_lines)
|
||||
PY
|
||||
log_ok "Registered MAM managed block in .gitignore."
|
||||
|
||||
# 5. Python Virtual Environment Setup (F-1)
|
||||
log_info "Bootstrapping Python virtual environment (.venv) in target..."
|
||||
|
||||
Reference in New Issue
Block a user