compass-st 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -56
- package/VERSION +1 -1
- package/bin/install +0 -3
- package/cli/Cargo.lock +327 -1
- package/cli/Cargo.toml +4 -1
- package/cli/src/cmd/hook.rs +263 -3
- package/cli/src/cmd/version.rs +2 -2
- package/cli/tests/e2e_check_validates_prd.rs +104 -0
- package/cli/tests/e2e_common.rs +217 -0
- package/cli/tests/e2e_cross_cwd.rs +91 -0
- package/cli/tests/e2e_fallback.rs +175 -0
- package/cli/tests/e2e_migrate_v05.rs +299 -0
- package/cli/tests/e2e_no_shell_remains.rs +53 -0
- package/cli/tests/e2e_run_missing_context.rs +129 -0
- package/cli/tests/e2e_smart_init.rs +194 -0
- package/cli/tests/e2e_v1_smoke.rs +261 -0
- package/core/colleagues/manifest.json +1 -1
- package/core/manifest.json +1 -1
- package/core/workflows/update.md +5 -5
- package/package.json +1 -1
- package/bootstrap.sh +0 -95
- package/core/hooks/context-monitor.sh +0 -5
- package/core/hooks/manifest-tracker.sh +0 -62
- package/core/hooks/statusline.sh +0 -12
- package/core/hooks/update-checker.sh +0 -24
package/bootstrap.sh
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# COMPASS bootstrap — clones the repo to ~/.compass and runs install.sh.
|
|
3
|
-
#
|
|
4
|
-
# One-liner:
|
|
5
|
-
# curl -fsSL <repo-url>/raw/main/bootstrap.sh | bash
|
|
6
|
-
#
|
|
7
|
-
# This script is idempotent — safe to re-run for updates.
|
|
8
|
-
|
|
9
|
-
set -euo pipefail
|
|
10
|
-
|
|
11
|
-
# Defaults below; override via env vars before running (e.g. COMPASS_BRANCH=dev bash bootstrap.sh)
|
|
12
|
-
COMPASS_REPO="${COMPASS_REPO:-"https://github.com/mrmandovn/compass.git"}"
|
|
13
|
-
COMPASS_BRANCH="${COMPASS_BRANCH:-"main"}"
|
|
14
|
-
COMPASS_DIR="${HOME}/.compass"
|
|
15
|
-
|
|
16
|
-
bold() { printf "\033[1m%s\033[0m" "$*"; }
|
|
17
|
-
green() { printf "\033[32m%s\033[0m" "$*"; }
|
|
18
|
-
yellow() { printf "\033[33m%s\033[0m" "$*"; }
|
|
19
|
-
red() { printf "\033[31m%s\033[0m" "$*"; }
|
|
20
|
-
|
|
21
|
-
echo "$(bold 'COMPASS bootstrap')"
|
|
22
|
-
echo " repo: ${COMPASS_REPO}"
|
|
23
|
-
echo " branch: ${COMPASS_BRANCH}"
|
|
24
|
-
echo " target: ${COMPASS_DIR}"
|
|
25
|
-
echo
|
|
26
|
-
|
|
27
|
-
# Check git
|
|
28
|
-
if ! command -v git >/dev/null 2>&1; then
|
|
29
|
-
echo "$(red 'ERROR'): git is required but not installed."
|
|
30
|
-
exit 1
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
# Clone or update
|
|
34
|
-
if [[ -d "${COMPASS_DIR}/.git" ]]; then
|
|
35
|
-
echo "Existing install found, updating..."
|
|
36
|
-
|
|
37
|
-
# Defensive: back up user-level state files before git reset --hard.
|
|
38
|
-
# ~/.compass/ doubles as source clone AND user state dir, so
|
|
39
|
-
# projects.json / global-config.json must survive the reset.
|
|
40
|
-
BACKUP_DIR="$(mktemp -d -t compass-bootstrap-XXXXXX)"
|
|
41
|
-
# Clean up the backup dir no matter how the script exits (success, error,
|
|
42
|
-
# SIGINT) — prevents orphaned tmp dirs on abort.
|
|
43
|
-
trap 'rm -rf "${BACKUP_DIR}"' EXIT INT TERM
|
|
44
|
-
[ -f "${HOME}/.compass/projects.json" ] && cp "${HOME}/.compass/projects.json" "${BACKUP_DIR}/projects.json"
|
|
45
|
-
[ -f "${HOME}/.compass/global-config.json" ] && cp "${HOME}/.compass/global-config.json" "${BACKUP_DIR}/global-config.json"
|
|
46
|
-
|
|
47
|
-
git -C "${COMPASS_DIR}" fetch origin "${COMPASS_BRANCH}"
|
|
48
|
-
git -C "${COMPASS_DIR}" reset --hard "origin/${COMPASS_BRANCH}"
|
|
49
|
-
|
|
50
|
-
# Restore user-level state files after reset.
|
|
51
|
-
[ -f "${BACKUP_DIR}/projects.json" ] && cp "${BACKUP_DIR}/projects.json" "${HOME}/.compass/projects.json"
|
|
52
|
-
[ -f "${BACKUP_DIR}/global-config.json" ] && cp "${BACKUP_DIR}/global-config.json" "${HOME}/.compass/global-config.json"
|
|
53
|
-
elif [[ -d "${COMPASS_DIR}" ]]; then
|
|
54
|
-
echo "$(red 'ERROR'): ${COMPASS_DIR} exists but is not a git repo."
|
|
55
|
-
echo " Move it aside or remove it, then re-run bootstrap."
|
|
56
|
-
exit 1
|
|
57
|
-
else
|
|
58
|
-
echo "Cloning..."
|
|
59
|
-
git clone --branch "${COMPASS_BRANCH}" "${COMPASS_REPO}" "${COMPASS_DIR}"
|
|
60
|
-
fi
|
|
61
|
-
|
|
62
|
-
echo
|
|
63
|
-
echo "$(green 'ok') Source ready at ${COMPASS_DIR}"
|
|
64
|
-
echo
|
|
65
|
-
|
|
66
|
-
# Generate file manifest for update tracking
|
|
67
|
-
"${COMPASS_DIR}/core/hooks/manifest-tracker.sh" generate > "${COMPASS_DIR}/.file-manifest.json" 2>/dev/null || true
|
|
68
|
-
|
|
69
|
-
# Auto-migrate project state if we're running inside an existing Compass project.
|
|
70
|
-
# The CWD here is the user's project directory (NOT ${COMPASS_DIR}). If it has
|
|
71
|
-
# .compass/.state/ and the compass-cli binary already exists, run the migration
|
|
72
|
-
# so any schema upgrades land before the installer wires everything up.
|
|
73
|
-
# On fresh installs the binary won't exist yet — install.sh builds it, and the
|
|
74
|
-
# user can re-run migration later via `/compass:migrate`.
|
|
75
|
-
PROJECT_CWD="$(pwd)"
|
|
76
|
-
COMPASS_CLI_BIN="${COMPASS_DIR}/cli/target/release/compass-cli"
|
|
77
|
-
if [[ "${PROJECT_CWD}" != "${COMPASS_DIR}" && -d "${PROJECT_CWD}/.compass/.state" ]]; then
|
|
78
|
-
if [[ -x "${COMPASS_CLI_BIN}" ]]; then
|
|
79
|
-
echo "Migrating project state at ${PROJECT_CWD}..."
|
|
80
|
-
if ! "${COMPASS_CLI_BIN}" migrate "${PROJECT_CWD}"; then
|
|
81
|
-
echo "$(yellow 'warn') compass-cli migrate returned non-zero — continuing bootstrap." >&2
|
|
82
|
-
echo " Re-run manually with: /compass:migrate" >&2
|
|
83
|
-
else
|
|
84
|
-
echo "$(green 'ok') Project state migrated"
|
|
85
|
-
fi
|
|
86
|
-
echo
|
|
87
|
-
else
|
|
88
|
-
echo "$(yellow 'note') Skipping auto-migration — compass-cli not built yet."
|
|
89
|
-
echo " After install completes, run: /compass:migrate"
|
|
90
|
-
echo
|
|
91
|
-
fi
|
|
92
|
-
fi
|
|
93
|
-
|
|
94
|
-
# Run installer
|
|
95
|
-
exec "${COMPASS_DIR}/bin/install"
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Compass manifest tracker — detect local modifications before update
|
|
3
|
-
# Usage: manifest-tracker.sh [generate|check]
|
|
4
|
-
|
|
5
|
-
COMPASS_DIR="${HOME}/.compass"
|
|
6
|
-
MANIFEST_FILE="${COMPASS_DIR}/.file-manifest.json"
|
|
7
|
-
|
|
8
|
-
case "${1:-check}" in
|
|
9
|
-
generate)
|
|
10
|
-
# Generate manifest of all tracked files
|
|
11
|
-
echo "{"
|
|
12
|
-
echo ' "version": "'$(cat "$COMPASS_DIR/VERSION" 2>/dev/null || echo "unknown")'",'
|
|
13
|
-
echo ' "generated_at": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",'
|
|
14
|
-
echo ' "files": {'
|
|
15
|
-
FIRST=true
|
|
16
|
-
find "$COMPASS_DIR" -type f \
|
|
17
|
-
-not -path '*/.git/*' \
|
|
18
|
-
-not -path '*/node_modules/*' \
|
|
19
|
-
-not -name '.file-manifest.json' \
|
|
20
|
-
-not -name '.update-check-cache' \
|
|
21
|
-
-not -name '.DS_Store' \
|
|
22
|
-
| sort | while read -r f; do
|
|
23
|
-
REL=$(echo "$f" | sed "s|$COMPASS_DIR/||")
|
|
24
|
-
HASH=$(shasum -a 256 "$f" 2>/dev/null | cut -d' ' -f1)
|
|
25
|
-
if [ "$FIRST" = true ]; then
|
|
26
|
-
FIRST=false
|
|
27
|
-
else
|
|
28
|
-
echo ","
|
|
29
|
-
fi
|
|
30
|
-
printf ' "%s": "%s"' "$REL" "$HASH"
|
|
31
|
-
done
|
|
32
|
-
echo ""
|
|
33
|
-
echo " }"
|
|
34
|
-
echo "}"
|
|
35
|
-
;;
|
|
36
|
-
check)
|
|
37
|
-
# Compare current files against manifest, report modifications
|
|
38
|
-
if [ ! -f "$MANIFEST_FILE" ]; then
|
|
39
|
-
echo "No manifest found. Run: manifest-tracker.sh generate > $MANIFEST_FILE"
|
|
40
|
-
exit 0
|
|
41
|
-
fi
|
|
42
|
-
python3 -c "
|
|
43
|
-
import json, hashlib, os, sys
|
|
44
|
-
manifest = json.load(open('$MANIFEST_FILE'))
|
|
45
|
-
compass_dir = os.path.expanduser('~/.compass')
|
|
46
|
-
modified = []
|
|
47
|
-
for rel_path, expected_hash in manifest.get('files', {}).items():
|
|
48
|
-
full_path = os.path.join(compass_dir, rel_path)
|
|
49
|
-
if not os.path.exists(full_path):
|
|
50
|
-
continue
|
|
51
|
-
actual_hash = hashlib.sha256(open(full_path, 'rb').read()).hexdigest()
|
|
52
|
-
if actual_hash != expected_hash:
|
|
53
|
-
modified.append(rel_path)
|
|
54
|
-
if modified:
|
|
55
|
-
print(f'Found {len(modified)} locally modified file(s):')
|
|
56
|
-
for f in modified:
|
|
57
|
-
print(f' {f}')
|
|
58
|
-
else:
|
|
59
|
-
print('No local modifications detected.')
|
|
60
|
-
" 2>/dev/null
|
|
61
|
-
;;
|
|
62
|
-
esac
|
package/core/hooks/statusline.sh
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Compass statusline hook — shows current session info
|
|
3
|
-
# Usage: source in shell prompt or tmux status-right
|
|
4
|
-
CONFIG=".compass/.state/config.json"
|
|
5
|
-
if [ -f "$CONFIG" ]; then
|
|
6
|
-
PROJECT=$(python3 -c "import json; d=json.load(open('$CONFIG')); print(d.get('project',{}).get('name','?'))" 2>/dev/null || echo "?")
|
|
7
|
-
MODE=$(python3 -c "import json; d=json.load(open('$CONFIG')); print(d.get('mode','?'))" 2>/dev/null || echo "?")
|
|
8
|
-
PREFIX=$(python3 -c "import json; d=json.load(open('$CONFIG')); print(d.get('prefix','?'))" 2>/dev/null || echo "?")
|
|
9
|
-
echo "Compass: ${PROJECT} (${PREFIX}) | ${MODE}"
|
|
10
|
-
else
|
|
11
|
-
echo "Compass: not initialized"
|
|
12
|
-
fi
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Compass update checker — runs on SessionStart
|
|
3
|
-
COMPASS_DIR="${HOME}/.compass"
|
|
4
|
-
VERSION_FILE="${COMPASS_DIR}/VERSION"
|
|
5
|
-
CACHE_FILE="${COMPASS_DIR}/.update-check-cache"
|
|
6
|
-
|
|
7
|
-
# Only check once per day
|
|
8
|
-
if [ -f "$CACHE_FILE" ]; then
|
|
9
|
-
LAST_CHECK=$(cat "$CACHE_FILE" 2>/dev/null)
|
|
10
|
-
NOW=$(date +%s)
|
|
11
|
-
DIFF=$((NOW - LAST_CHECK))
|
|
12
|
-
[ "$DIFF" -lt 86400 ] && exit 0
|
|
13
|
-
fi
|
|
14
|
-
|
|
15
|
-
LOCAL_VERSION=$(cat "$VERSION_FILE" 2>/dev/null || echo "0.0.0")
|
|
16
|
-
|
|
17
|
-
# Fetch latest tag from GitHub (timeout 5s)
|
|
18
|
-
LATEST=$(curl -sf --max-time 5 "https://api.github.com/repos/mrmandovn/compass/tags" | python3 -c "import sys,json; tags=json.load(sys.stdin); print(tags[0]['name'].lstrip('v') if tags else '')" 2>/dev/null || echo "")
|
|
19
|
-
|
|
20
|
-
date +%s > "$CACHE_FILE"
|
|
21
|
-
|
|
22
|
-
if [ -n "$LATEST" ] && [ "$LATEST" != "$LOCAL_VERSION" ]; then
|
|
23
|
-
echo "Compass update available: v${LOCAL_VERSION} → v${LATEST}. Run: cd ~/.compass && git pull"
|
|
24
|
-
fi
|