Self-evolving second brain with 35 AI skills, 10 agents, and people CRM. Closed-loop harness: a V-model verification lifecycle where the worker never grades its own homework. Plus paired anti-slop design skills for marketing and product UI. Works with Claude Code, Cursor, Kiro, Gemini CLI, Codex.
Python agent-loopagent-pluginsagent-skillsagenticai-agentsclaude-codeclosed-loopcursorgarry-tangbraingstackknowledge-managementloop-engineeringobsidianpeople-crmproductivitysecond-brainself-evolvingverification-harnessworker-agents
#!/usr/bin/env bash
# COG Upstream Update Script
# Safely updates framework files (skills, docs, scripts) without touching your personal content.
#
# Usage:
# ./cog-update.sh Interactive update
# ./cog-update.sh --check Check for available updates (no changes)
# ./cog-update.sh --dry-run Show what would change (no changes)
# ./cog-update.sh --force Update all framework files without prompting
# ./cog-update.sh --validate Run packaging validator only
# ./cog-update.sh --help Show this help message
set -euo pipefail
# ── Configuration ────────────────────────────────────────────────────
REMOTE_NAME="cog-upstream"
REMOTE_URL="https://github.com/huytieu/COG-second-brain.git"
BRANCH="main"
VERSION_FILE="COG-VERSION"
VALIDATOR_SCRIPT="scripts/validate-agent-surface.sh"
# Framework files — these are safe to overwrite (your content is never in this list)
FRAMEWORK_FILES=(
# Core docs
"README.md"
"SETUP.md"
"AGENTS.md"
"GEMINI.md"
"CHANGELOG.md"
"CONTRIBUTING.md"
"LICENSE"
"COG-VERSION"
"cog-update.sh"
"docs/AGENT-SUPPORT.md"
"docs/SKILL-DISTILLATION.md"
"WORKFLOW.md"
".claude/lib/checkpoint.sh"
".claude/lib/lane-classify.sh"
".github/MARKETPLACE.md"
"scripts/validate-agent-surface.sh"
# Claude Code skills
".claude/skills/onboarding/SKILL.md"
".claude/skills/braindump/SKILL.md"
".claude/skills/daily-brief/SKILL.md"
".claude/skills/weekly-checkin/SKILL.md"
".claude/skills/knowledge-consolidation/SKILL.md"
".claude/skills/url-dump/SKILL.md"
".claude/skills/loop-engineering/SKILL.md"
".claude/skills/scout/SKILL.md"
".claude/skills/update-cog/SKILL.md"
".claude/skills/team-brief/SKILL.md"
".claude/skills/comprehensive-analysis/SKILL.md"
".claude/skills/meeting-transcript/SKILL.md"
".claude/skills/auto-research/SKILL.md"
".claude/skills/create-user-story/SKILL.md"
".claude/skills/generate-prd/SKILL.md"
".claude/skills/generate-release-notes/SKILL.md"
".claude/skills/export-open-issues/SKILL.md"
".claude/skills/publish-to-confluence/SKILL.md"
".claude/skills/update-knowledge-base/SKILL.md"
".claude/skills/memory-hygiene/SKILL.md"
".claude/skills/content-factory/SKILL.md"
".claude/skills/closed-loop/SKILL.md"
".claude/skills/ultragoal/SKILL.md"
".claude/skills/harvest/SKILL.md"
".claude/skills/retro/SKILL.md"
".claude/skills/review-cockpit/SKILL.md"
".claude/skills/no-ai-slop/SKILL.md"
".claude/skills/slop-gate/SKILL.md"
".claude/skills/slop-gate/scripts/scan.py"
".claude/skills/voice-baseline/SKILL.md"
".claude/skills/voice-baseline/scripts/census.py"
".claude/skills/release-video/SKILL.md"
".claude/skills/release-video/scripts/engine.js"
".claude/skills/release-video/scripts/render.py"
".claude/skills/release-video/scripts/mix_sfx.py"
".claude/skills/release-video/scripts/gen_audio.sh"
".claude/skills/release-video/scripts/music_check.py"
".claude/skills/release-video/scripts/mix_final.sh"
".claude/skills/release-video/scripts/compose_demo.py"
".claude/skills/release-video/scripts/frames_from_video.sh"
".claude/skills/release-video/templates/index.html"
".claude/skills/release-video/templates/base.css"
".claude/skills/release-video/templates/demo-spec.example.json"
".claude/skills/release-video/templates/music-plan.example.json"
".claude/skills/blog-publish/SKILL.md"
".claude/skills/editorial-illustrations/assets/blog-figure-kit.html"
".claude/skills/editorial-illustrations/assets/gallery.html"
".claude/skills/editorial-illustrations/references/blog-figure-kit.md"
".claude/skills/feature-doc/SKILL.md"
".claude/skills/feature-doc/tools/arcade-record.py"
".claude/skills/feature-doc/tools/recompose.py"
".claude/skills/feature-doc/tools/screenrec.py"
".claude/skills/feature-doc/tools/videokit.py"
".claude/skills/no-ai-slop/LICENSE"
".claude/skills/no-ai-slop/SOURCE.md"
".claude/skills/no-ai-slop/eval.md"
".claude/skills/product-ui-taste/references/house-ui-rules.md"
".claude/skills/product-ui-taste/references/semantic-zoom.md"
".claude/skills/release-comms/SKILL.md"
".claude/skills/release-video/scripts/human_input.py"
".claude/skills/release-video/scripts/plain_demo.py"
".claude/skills/social-media-kit/SKILL.md"
".claude/skills/social-media-kit/scripts/cardrender.py"
".claude/skills/social-media-kit/scripts/linearcard.py"
".claude/skills/social-media-kit/scripts/terminal_banner.py"
".claude/skills/terminal-replica/SKILL.md"
".claude/skills/vector-cover/SKILL.md"
".claude/skills/vector-cover/render.sh"
".claude/skills/vector-cover/template.html"
".claude/skills/youtube-video-kit/SKILL.md"
".claude/skills/youtube-video-kit/scripts/ytopen.py"
".claude/skills/youtube-video-kit/scripts/ytthumb.py"
".claude/skills/slop-gate/scripts/model_compare.py"
".claude/skills/editorial-illustrations/SKILL.md"
".claude/skills/data-forms/SKILL.md"
".claude/skills/museum-art/SKILL.md"
".claude/skills/daily-journal/SKILL.md"
".claude/skills/taste-skill/SKILL.md"
".claude/skills/product-ui-taste/SKILL.md"
# Skill reference files (bundled lookup material, loaded on demand)
".claude/skills/closed-loop/references/report-template.html"
".claude/skills/closed-loop/references/spec-template.md"
".claude/skills/data-forms/references/forms.md"
".claude/skills/editorial-illustrations/references/design-system.md"
".claude/skills/editorial-illustrations/references/elements.md"
".claude/skills/editorial-illustrations/references/worked-examples.md"
".claude/skills/knowledge-consolidation/references/templates.md"
".claude/skills/museum-art/references/_synthesis.md"
".claude/skills/museum-art/references/artic.md"
".claude/skills/museum-art/references/cleveland.md"
".claude/skills/museum-art/references/getty.md"
".claude/skills/museum-art/references/met.md"
".claude/skills/museum-art/references/nga.md"
".claude/skills/museum-art/references/rijksmuseum.md"
".claude/skills/museum-art/references/smithsonian.md"
".claude/skills/museum-art/references/smk.md"
".claude/skills/onboarding/references/profile-templates.md"
".claude/skills/onboarding/references/welcome-guide.md"
".claude/skills/retro/references/retro-template.md"
".claude/skills/review-cockpit/references/session-review-template.md"
".claude/skills/product-ui-taste/references/block-skeletons.md"
".claude/skills/product-ui-taste/references/canonical-sources.md"
".claude/skills/product-ui-taste/references/install-commands.md"
".claude/skills/taste-skill/references/canonical-sources.md"
".claude/skills/taste-skill/references/design-systems-install.md"
".claude/skills/taste-skill/references/liquid-glass.md"
".claude/skills/taste-skill/references/motion-skeletons.md"
".claude/skills/taste-skill/references/pattern-vocabulary.md"
".claude/skills/team-brief/references/agent-prompts.md"
".claude/skills/team-brief/references/brief-frontmatter.md"
".claude/skills/team-brief/references/publish-templates.md"
# Role packs
".claude/roles/_template.md"
".claude/roles/product-manager.md"
".claude/roles/engineer.md"
".claude/roles/engineering-lead.md"
".claude/roles/designer.md"
".claude/roles/founder.md"
".claude/roles/marketer.md"
# Worker agents
".claude/agents/worker-data-collector.md"
".claude/agents/worker-researcher.md"
".claude/agents/worker-file-ops.md"
".claude/agents/worker-executor.md"
".claude/agents/worker-publisher.md"
".claude/agents/brief-people-updater.md"
".claude/agents/task-verifier.md"
".claude/agents/integration-verifier.md"
".claude/agents/fix-agent.md"
".claude/agents/harvest-curator.md"
# People CRM
"05-knowledge/people/README.md"
"06-templates/people-profile-template.md"
# Framework config
"CLAUDE.md"
# Kiro powers
".kiro/powers/cog-onboarding/POWER.md"
".kiro/powers/cog-braindump/POWER.md"
".kiro/powers/cog-daily-brief/POWER.md"
".kiro/powers/cog-weekly-checkin/POWER.md"
".kiro/powers/cog-knowledge-consolidation/POWER.md"
".kiro/powers/cog-url-dump/POWER.md"
".kiro/powers/cog-update/POWER.md"
# Antigravity (agy CLI + IDE)
".agents/rules/cog.md"
".agents/skills/auto-research/SKILL.md"
".agents/skills/braindump/SKILL.md"
".agents/skills/closed-loop/SKILL.md"
".agents/skills/comprehensive-analysis/SKILL.md"
".agents/skills/content-factory/SKILL.md"
".agents/skills/create-user-story/SKILL.md"
".agents/skills/daily-brief/SKILL.md"
".agents/skills/daily-journal/SKILL.md"
".agents/skills/data-forms/SKILL.md"
".agents/skills/editorial-illustrations/SKILL.md"
".agents/skills/export-open-issues/SKILL.md"
".agents/skills/generate-prd/SKILL.md"
".agents/skills/generate-release-notes/SKILL.md"
".agents/skills/harvest/SKILL.md"
".agents/skills/knowledge-consolidation/SKILL.md"
".agents/skills/loop-engineering/SKILL.md"
".agents/skills/meeting-transcript/SKILL.md"
".agents/skills/memory-hygiene/SKILL.md"
".agents/skills/museum-art/SKILL.md"
".agents/skills/no-ai-slop/SKILL.md"
".agents/skills/slop-gate/SKILL.md"
".agents/skills/voice-baseline/SKILL.md"
".agents/skills/release-video/SKILL.md"
".agents/skills/feature-doc/SKILL.md"
".agents/skills/release-comms/SKILL.md"
".agents/skills/blog-publish/SKILL.md"
".agents/skills/social-media-kit/SKILL.md"
".agents/skills/youtube-video-kit/SKILL.md"
".agents/skills/terminal-replica/SKILL.md"
".agents/skills/vector-cover/SKILL.md"
".agents/skills/onboarding/SKILL.md"
".agents/skills/product-ui-taste/SKILL.md"
".agents/skills/publish-to-confluence/SKILL.md"
".agents/skills/retro/SKILL.md"
".agents/skills/review-cockpit/SKILL.md"
".agents/skills/scout/SKILL.md"
".agents/skills/taste-skill/SKILL.md"
".agents/skills/team-brief/SKILL.md"
".agents/skills/ultragoal/SKILL.md"
".agents/skills/update-cog/SKILL.md"
".agents/skills/update-knowledge-base/SKILL.md"
".agents/skills/url-dump/SKILL.md"
".agents/skills/weekly-checkin/SKILL.md"
".agents/agents/brief-people-updater.md"
".agents/agents/worker-data-collector.md"
".agents/agents/worker-executor.md"
".agents/agents/worker-file-ops.md"
".agents/agents/worker-publisher.md"
".agents/agents/worker-researcher.md"
".agents/agents/task-verifier.md"
".agents/agents/integration-verifier.md"
".agents/agents/fix-agent.md"
".agents/agents/harvest-curator.md"
# Gemini CLI
".gemini/commands/onboarding.toml"
".gemini/commands/braindump.toml"
".gemini/commands/daily-brief.toml"
".gemini/commands/weekly-checkin.toml"
".gemini/commands/knowledge-consolidation.toml"
".gemini/commands/url-dump.toml"
".gemini/commands/update-cog.toml"
".gemini/skills/onboarding.md"
".gemini/skills/braindump.md"
".gemini/skills/daily-brief.md"
".gemini/skills/weekly-checkin.md"
".gemini/skills/knowledge-consolidation.md"
".gemini/skills/url-dump.md"
".gemini/skills/update-cog.md"
# Plugin metadata
".claude-plugin/plugin.json"
".cursor-plugin/plugin.json"
".cursorrules"
"marketplace-entry.json"
"plugin.json"
"scripts/build-agent-plugin.sh"
# Git infrastructure
".gitignore"
)
# ── Helpers ──────────────────────────────────────────────────────────
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
BOLD='\033[1m'
RESET='\033[0m'
info() { echo -e "${CYAN}ℹ${RESET} $*"; }
ok() { echo -e "${GREEN}✓${RESET} $*"; }
warn() { echo -e "${YELLOW}⚠${RESET} $*"; }
err() { echo -e "${RED}✗${RESET} $*" >&2; }
usage() {
cat <<'EOF'
COG Upstream Update Script
Updates framework files (skills, docs, scripts) from the official COG repo
without touching your personal content (braindumps, profiles, notes).
Usage:
./cog-update.sh Interactive update (prompts per file)
./cog-update.sh --check Check for available updates (no changes)
./cog-update.sh --dry-run Show what would change (no changes)
./cog-update.sh --force Update all framework files without prompting
./cog-update.sh --validate Run packaging validator only
./cog-update.sh --help Show this help message
How it works:
1. Adds/fetches the upstream remote (cog-upstream)
2. Compares each framework file against the upstream version
3. Offers to update changed files (interactive mode) or updates all (--force)
4. Warns if your working tree is already dirty before replacing framework files
5. Runs the packaging validator after updates when available
6. Your content folders (00-inbox, 01-daily, etc.) are NEVER modified
Safe to run anytime — your notes, profiles, and braindumps are never touched.
EOF
}
# ── Ensure remote exists & fetch ─────────────────────────────────────
ensure_remote() {
if ! git remote get-url "$REMOTE_NAME" &>/dev/null; then
info "Adding remote ${BOLD}${REMOTE_NAME}${RESET} → ${REMOTE_URL}"
git remote add "$REMOTE_NAME" "$REMOTE_URL"
fi
info "Fetching latest from ${BOLD}${REMOTE_NAME}/${BRANCH}${RESET}..."
git fetch "$REMOTE_NAME" "$BRANCH" --quiet
}
# ── Get local and upstream versions ──────────────────────────────────
local_version() {
if [[ -f "$VERSION_FILE" ]]; then
cat "$VERSION_FILE" | tr -d '[:space:]'
else
echo "unknown"
fi
}
upstream_version() {
git show "${REMOTE_NAME}/${BRANCH}:${VERSION_FILE}" 2>/dev/null | tr -d '[:space:]' || echo "unknown"
}
# ── Diff a single file ──────────────────────────────────────────────
file_has_changes() {
local file="$1"
# File exists upstream?
if ! git show "${REMOTE_NAME}/${BRANCH}:${file}" &>/dev/null; then
return 1 # no upstream version
fi
# File differs from upstream?
if [[ -f "$file" ]]; then
! diff -q <(git show "${REMOTE_NAME}/${BRANCH}:${file}" 2>/dev/null) "$file" &>/dev/null
else
return 0 # file missing locally → counts as changed
fi
}
# ── Update a single file from upstream ───────────────────────────────
update_file() {
local file="$1"
local dir
dir=$(dirname "$file")
[[ "$dir" != "." ]] && mkdir -p "$dir"
git show "${REMOTE_NAME}/${BRANCH}:${file}" > "$file" 2>/dev/null
}
# ── Backup a file before overwriting ─────────────────────────────────
backup_file() {
local file="$1"
if [[ -f "$file" ]]; then
local backup="${file}.backup-$(date +%Y%m%d-%H%M%S)"
cp "$file" "$backup"
echo "$backup"
fi
}
worktree_is_dirty() {
[[ -n "$(git status --porcelain)" ]]
}
warn_if_dirty() {
if worktree_is_dirty; then
warn "Your working tree has uncommitted changes. Framework updates are still safe, but review carefully before committing."
fi
}
# Regenerate the Agent Plugins standard mirror (root skills/) after framework
# updates so it never drifts from the updated .claude/skills/.
rebuild_agent_plugin() {
if [[ -x "scripts/build-agent-plugin.sh" ]]; then
./scripts/build-agent-plugin.sh || warn "Agent plugin mirror rebuild failed; run ./scripts/build-agent-plugin.sh manually"
fi
}
run_validator() {
if [[ -x "$VALIDATOR_SCRIPT" ]]; then
echo ""
info "Running ${BOLD}${VALIDATOR_SCRIPT}${RESET}..."
if "$VALIDATOR_SCRIPT"; then
ok "Packaging validation passed"
return 0
else
warn "Packaging validation reported issues. Review before committing."
return 1
fi
else
warn "Validator not found at ${VALIDATOR_SCRIPT}; skipping packaging validation"
return 0
fi
}
# ── Main logic ───────────────────────────────────────────────────────
main() {
local mode="interactive"
while [[ $# -gt 0 ]]; do
case "$1" in
--check) mode="check"; shift ;;
--dry-run) mode="dry-run"; shift ;;
--force) mode="force"; shift ;;
--validate) mode="validate"; shift ;;
--help|-h) usage; exit 0 ;;
*) err "Unknown option: $1"; usage; exit 1 ;;
esac
done
# Sanity check — are we in a git repo?
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
err "Not inside a git repository. Run this from your COG folder."
exit 1
fi
if [[ "$mode" == "validate" ]]; then
run_validator
exit $?
fi
echo ""
echo -e "${BOLD}COG Upstream Update${RESET}"
echo -e "─────────────────────"
echo ""
ensure_remote
local lv uv
lv=$(local_version)
uv=$(upstream_version)
info "Local version: ${BOLD}${lv}${RESET}"
info "Upstream version: ${BOLD}${uv}${RESET}"
echo ""
if [[ "$mode" == "interactive" || "$mode" == "force" ]]; then
warn_if_dirty
[[ -n "$(git status --porcelain)" ]] && echo ""
fi
if [[ "$uv" == "unknown" ]]; then
err "Could not read upstream version. Check your internet connection."
exit 1
fi
# Collect changed files
local changed=()
local new_files=()
for file in "${FRAMEWORK_FILES[@]}"; do
if file_has_changes "$file"; then
if [[ -f "$file" ]]; then
changed+=("$file")
else
new_files+=("$file")
fi
fi
done
local total=$(( ${#changed[@]} + ${#new_files[@]} ))
if [[ $total -eq 0 ]]; then
ok "Everything is up to date! (v${lv})"
exit 0
fi
info "${BOLD}${#changed[@]}${RESET} file(s) changed, ${BOLD}${#new_files[@]}${RESET} new file(s) available"
echo ""
# ── Check mode ───────────────────────────────────────────────────
if [[ "$mode" == "check" ]]; then
if [[ ${#changed[@]} -gt 0 ]]; then
echo -e "${BOLD}Changed:${RESET}"
for f in "${changed[@]}"; do echo " ~ $f"; done
fi
if [[ ${#new_files[@]} -gt 0 ]]; then
echo -e "${BOLD}New:${RESET}"
for f in "${new_files[@]}"; do echo " + $f"; done
fi
echo ""
info "Run ${BOLD}./cog-update.sh${RESET} to update, or ${BOLD}./cog-update.sh --dry-run${RESET} to preview."
exit 0
fi
# ── Dry-run mode ─────────────────────────────────────────────────
if [[ "$mode" == "dry-run" ]]; then
echo -e "${BOLD}Dry run — no changes will be made:${RESET}"
echo ""
if [[ ${#changed[@]} -gt 0 ]]; then
echo "Would update:"
for f in "${changed[@]}"; do echo " ~ $f"; done
fi
if [[ ${#new_files[@]} -gt 0 ]]; then
echo "Would create:"
for f in "${new_files[@]}"; do echo " + $f"; done
fi
echo ""
info "Run ${BOLD}./cog-update.sh --force${RESET} to apply all, or ${BOLD}./cog-update.sh${RESET} for interactive mode."
exit 0
fi
# ── Force mode ───────────────────────────────────────────────────
if [[ "$mode" == "force" ]]; then
local updated=0
for f in "${changed[@]}" "${new_files[@]}"; do
if [[ -f "$f" ]]; then
backup_file "$f" >/dev/null
fi
update_file "$f"
ok "Updated: $f"
((updated++))
done
echo ""
ok "Updated ${updated} file(s) to v${uv}"
info "Backups saved as *.backup-YYYYMMDD-HHMMSS alongside originals"
rebuild_agent_plugin
run_validator || true
exit 0
fi
# ── Interactive mode ─────────────────────────────────────────────
local updated=0 skipped=0
# New files first
if [[ ${#new_files[@]} -gt 0 ]]; then
echo -e "${BOLD}New files available:${RESET}"
for f in "${new_files[@]}"; do
echo -ne " ${GREEN}+${RESET} ${f} — add? [Y/n] "
read -r answer
if [[ -z "$answer" || "$answer" =~ ^[Yy] ]]; then
update_file "$f"
ok "Added: $f"
((updated++))
else
warn "Skipped: $f"
((skipped++))
fi
done
echo ""
fi
# Changed files
if [[ ${#changed[@]} -gt 0 ]]; then
echo -e "${BOLD}Changed files:${RESET}"
for f in "${changed[@]}"; do
echo -ne " ${YELLOW}~${RESET} ${f} — update? [Y/n/d(iff)/b(ackup+update)] "
read -r answer
case "$answer" in
d|D|diff)
diff --color=auto <(cat "$f") <(git show "${REMOTE_NAME}/${BRANCH}:${f}") || true
echo -ne " Update this file? [Y/n/b] "
read -r answer2
if [[ -z "$answer2" || "$answer2" =~ ^[Yy] ]]; then
update_file "$f"
ok "Updated: $f"
((updated++))
elif [[ "$answer2" =~ ^[Bb] ]]; then
local bk
bk=$(backup_file "$f")
update_file "$f"
ok "Updated: $f (backup: $bk)"
((updated++))
else
warn "Skipped: $f"
((skipped++))
fi
;;
b|B)
local bk
bk=$(backup_file "$f")
update_file "$f"
ok "Updated: $f (backup: $bk)"
((updated++))
;;
n|N)
warn "Skipped: $f"
((skipped++))
;;
*)
update_file "$f"
ok "Updated: $f"
((updated++))
;;
esac
done
fi
echo ""
echo -e "${BOLD}Summary:${RESET}"
ok "${updated} file(s) updated"
[[ $skipped -gt 0 ]] && warn "${skipped} file(s) skipped"
echo ""
if [[ $updated -gt 0 ]]; then
rebuild_agent_plugin
run_validator || true
info "Review changes with ${BOLD}git diff${RESET}, then commit when ready:"
echo " git add -A && git commit -m \"Update COG framework to v${uv}\""
fi
}
main "$@"