71 lines
2.4 KiB
Bash
Executable file
71 lines
2.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Shared AI ignore / permission defaults for init and sync flows.
|
|
AGENT_OPS_TASK_ARCHIVE_IGNORE_PATTERN="agent-task/archive/**"
|
|
AGENT_OPS_ROADMAP_ARCHIVE_IGNORE_PATTERN="agent-ops/roadmap/archive/**"
|
|
AGENT_OPS_AI_IGNORE_FILES=(".geminiignore" ".aiexclude" ".cursorignore" ".clineignore")
|
|
AGENT_OPS_AI_PERMISSION_FILES=(".claude/settings.json" "opencode.json")
|
|
AGENT_OPS_AI_SYNC_FILES=("${AGENT_OPS_AI_IGNORE_FILES[@]}" "${AGENT_OPS_AI_PERMISSION_FILES[@]}")
|
|
|
|
agent_ops_append_unique_line() {
|
|
local file="$1"
|
|
local line="$2"
|
|
|
|
touch "$file"
|
|
if ! grep -qxF "$line" "$file"; then
|
|
printf "%s\n" "$line" >> "$file"
|
|
fi
|
|
}
|
|
|
|
ensure_agent_ops_ai_ignore_config() {
|
|
local target_dir="$1"
|
|
local ignore_file
|
|
|
|
for ignore_file in "${AGENT_OPS_AI_IGNORE_FILES[@]}"; do
|
|
agent_ops_append_unique_line "$target_dir/$ignore_file" "$AGENT_OPS_TASK_ARCHIVE_IGNORE_PATTERN"
|
|
agent_ops_append_unique_line "$target_dir/$ignore_file" "$AGENT_OPS_ROADMAP_ARCHIVE_IGNORE_PATTERN"
|
|
done
|
|
|
|
mkdir -p "$target_dir/.claude"
|
|
if [[ ! -f "$target_dir/.claude/settings.json" ]]; then
|
|
cat > "$target_dir/.claude/settings.json" <<'EOF'
|
|
{
|
|
"$schema": "https://json.schemastore.org/claude-code-settings.json",
|
|
"permissions": {
|
|
"deny": [
|
|
"Read(./agent-task/archive/**)",
|
|
"Read(./agent-ops/roadmap/archive/**)"
|
|
]
|
|
}
|
|
}
|
|
EOF
|
|
elif ! grep -q "agent-task/archive" "$target_dir/.claude/settings.json" || ! grep -q "agent-ops/roadmap/archive" "$target_dir/.claude/settings.json"; then
|
|
echo "Note: .claude/settings.json exists; add Read(./agent-task/archive/**) and Read(./agent-ops/roadmap/archive/**) manually."
|
|
fi
|
|
|
|
if [[ ! -f "$target_dir/opencode.json" ]]; then
|
|
cat > "$target_dir/opencode.json" <<'EOF'
|
|
{
|
|
"$schema": "https://opencode.ai/config.json",
|
|
"permission": {
|
|
"read": {
|
|
"agent-task/archive/**": "deny",
|
|
"agent-ops/roadmap/archive/**": "deny"
|
|
},
|
|
"glob": {
|
|
"agent-task/archive/**": "deny",
|
|
"agent-ops/roadmap/archive/**": "deny"
|
|
}
|
|
},
|
|
"watcher": {
|
|
"ignore": [
|
|
"agent-task/archive/**",
|
|
"agent-ops/roadmap/archive/**"
|
|
]
|
|
}
|
|
}
|
|
EOF
|
|
elif ! grep -q "agent-task/archive" "$target_dir/opencode.json" || ! grep -q "agent-ops/roadmap/archive" "$target_dir/opencode.json"; then
|
|
echo "Note: opencode.json exists; add agent-task/archive/** and agent-ops/roadmap/archive/** read/glob deny and watcher ignore manually."
|
|
fi
|
|
}
|