feat: initial mosaic bootstrap framework

This commit is contained in:
Jason Woltje
2026-02-17 10:41:09 -06:00
commit a7ceeb0bbb
18 changed files with 441 additions and 0 deletions

87
bin/mosaic-bootstrap-repo Executable file
View File

@@ -0,0 +1,87 @@
#!/usr/bin/env bash
set -euo pipefail
TARGET_DIR="$(pwd)"
FORCE=0
while [[ $# -gt 0 ]]; do
case "$1" in
--force)
FORCE=1
shift
;;
*)
TARGET_DIR="$1"
shift
;;
esac
done
if [[ ! -d "$TARGET_DIR" ]]; then
echo "[mosaic] Target directory does not exist: $TARGET_DIR" >&2
exit 1
fi
MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.mosaic}"
TEMPLATE_ROOT="$MOSAIC_HOME/templates/repo"
if [[ ! -d "$TEMPLATE_ROOT" ]]; then
echo "[mosaic] Missing templates at $TEMPLATE_ROOT" >&2
echo "[mosaic] Install or refresh framework: ~/.mosaic/install.sh" >&2
exit 1
fi
mkdir -p "$TARGET_DIR/.mosaic" "$TARGET_DIR/scripts/agent"
copy_file() {
local src="$1"
local dst="$2"
if [[ -f "$dst" && "$FORCE" -ne 1 ]]; then
echo "[mosaic] Skip existing: $dst"
return
fi
cp "$src" "$dst"
echo "[mosaic] Wrote: $dst"
}
copy_file "$TEMPLATE_ROOT/.mosaic/README.md" "$TARGET_DIR/.mosaic/README.md"
copy_file "$TEMPLATE_ROOT/.mosaic/repo-hooks.sh" "$TARGET_DIR/.mosaic/repo-hooks.sh"
for file in "$TEMPLATE_ROOT"/scripts/agent/*.sh; do
base="$(basename "$file")"
copy_file "$file" "$TARGET_DIR/scripts/agent/$base"
chmod +x "$TARGET_DIR/scripts/agent/$base"
done
if [[ ! -f "$TARGET_DIR/AGENTS.md" ]]; then
cat > "$TARGET_DIR/AGENTS.md" <<'AGENTS_EOF'
# Agent Guidelines
## Standards Load Order
1. `~/.mosaic/STANDARDS.md`
2. `AGENTS.md` (this file)
3. `.mosaic/repo-hooks.sh`
## Session Lifecycle
```bash
bash scripts/agent/session-start.sh
bash scripts/agent/critical.sh
bash scripts/agent/session-end.sh
```
## Repo-Specific Notes
- Add project constraints and workflows here.
- Implement hook functions in `.mosaic/repo-hooks.sh`.
AGENTS_EOF
echo "[mosaic] Wrote: $TARGET_DIR/AGENTS.md"
else
echo "[mosaic] AGENTS.md exists; add standards load order if missing"
fi
echo "[mosaic] Repo bootstrap complete: $TARGET_DIR"
echo "[mosaic] Next: edit $TARGET_DIR/.mosaic/repo-hooks.sh with project workflows"

9
bin/mosaic-critical Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ -x "scripts/agent/critical.sh" ]]; then
exec bash scripts/agent/critical.sh
fi
echo "[mosaic] Missing scripts/agent/critical.sh in $(pwd)" >&2
exit 1

9
bin/mosaic-log-limitation Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ -x "scripts/agent/log-limitation.sh" ]]; then
exec bash scripts/agent/log-limitation.sh "$@"
fi
echo "[mosaic] Missing scripts/agent/log-limitation.sh in $(pwd)" >&2
exit 1

9
bin/mosaic-session-end Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ -x "scripts/agent/session-end.sh" ]]; then
exec bash scripts/agent/session-end.sh "$@"
fi
echo "[mosaic] Missing scripts/agent/session-end.sh in $(pwd)" >&2
exit 1

9
bin/mosaic-session-start Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ -x "scripts/agent/session-start.sh" ]]; then
exec bash scripts/agent/session-start.sh
fi
echo "[mosaic] Missing scripts/agent/session-start.sh in $(pwd)" >&2
exit 1