compass-cc 0.1.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/agents/adr-scribe.md +82 -0
  4. package/agents/architect-coach.md +88 -0
  5. package/agents/baseline-analyzer.md +93 -0
  6. package/agents/completion-tracker.md +55 -0
  7. package/agents/domain-researcher.md +122 -0
  8. package/agents/idiom-checker.md +111 -0
  9. package/agents/readiness-checker.md +93 -0
  10. package/agents/review-coach.md +94 -0
  11. package/agents/rubber-duck.md +69 -0
  12. package/agents/scope-guardian.md +98 -0
  13. package/agents/socratic-interrogator.md +93 -0
  14. package/agents/spec-writer.md +106 -0
  15. package/agents/test-auditor.md +92 -0
  16. package/agents/unit-decomposer.md +114 -0
  17. package/bin/install.js +306 -0
  18. package/constitution.md +191 -0
  19. package/hooks/compass-commit-check.sh +65 -0
  20. package/hooks/compass-context-monitor.sh +53 -0
  21. package/hooks/compass-preflight.sh +56 -0
  22. package/hooks/compass-scope-guardian.sh +95 -0
  23. package/package.json +36 -0
  24. package/references/inverted-contract.md +31 -0
  25. package/scripts/compass-tools.sh +602 -0
  26. package/skills/compass-architect/SKILL.md +91 -0
  27. package/skills/compass-build-duck/SKILL.md +53 -0
  28. package/skills/compass-build-idiom/SKILL.md +57 -0
  29. package/skills/compass-build-progress/SKILL.md +55 -0
  30. package/skills/compass-build-ready/SKILL.md +69 -0
  31. package/skills/compass-build-review/SKILL.md +61 -0
  32. package/skills/compass-build-scope/SKILL.md +67 -0
  33. package/skills/compass-build-tests/SKILL.md +57 -0
  34. package/skills/compass-build-transform/SKILL.md +63 -0
  35. package/skills/compass-build-units/SKILL.md +76 -0
  36. package/skills/compass-decide/SKILL.md +105 -0
  37. package/skills/compass-frame/SKILL.md +105 -0
  38. package/skills/compass-init/SKILL.md +142 -0
  39. package/skills/compass-next/SKILL.md +60 -0
  40. package/skills/compass-research/SKILL.md +81 -0
  41. package/skills/compass-spec/SKILL.md +115 -0
  42. package/skills/compass-status/SKILL.md +79 -0
  43. package/templates/ADR.md +48 -0
  44. package/templates/ARCHITECTURE.md +44 -0
  45. package/templates/BASELINE.md +32 -0
  46. package/templates/FRAMING.md +51 -0
  47. package/templates/RESEARCH-DOSSIER.md +36 -0
  48. package/templates/SESSION.md +23 -0
  49. package/templates/SPEC.md +40 -0
  50. package/templates/UNIT.md +33 -0
  51. package/templates/config.yaml +23 -0
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # compass-commit-check.sh — Claude Code PreToolUse hook
4
+ # Validates conventional commit format before git commit.
5
+ #
6
+ # Hook type: PreToolUse
7
+ # Matcher: tool_name == "Bash" and command contains "git commit"
8
+ #
9
+ # OPT-IN: Only active when hooks.commit_check is true in .compass/config.yaml.
10
+ # When active, BLOCKS non-conventional commits (exit 2).
11
+
12
+ # Timeout guard
13
+ TIMEOUT_PID=$$
14
+ ( sleep 5 && kill -0 "$TIMEOUT_PID" 2>/dev/null && kill "$TIMEOUT_PID" ) &
15
+ WATCHDOG=$!
16
+ trap "kill $WATCHDOG 2>/dev/null" EXIT
17
+
18
+ # Read hook input
19
+ INPUT=$(cat)
20
+
21
+ # Check if this is a git commit command
22
+ COMMAND=$(echo "$INPUT" | grep -o '"command":"[^"]*"' | head -1 | cut -d'"' -f4)
23
+
24
+ case "$COMMAND" in
25
+ *"git commit"*) ;;
26
+ *) exit 0 ;;
27
+ esac
28
+
29
+ # Find .compass/ and check if commit check is enabled
30
+ COMPASS_DIR=""
31
+ DIR="$PWD"
32
+ while [[ "$DIR" != "/" ]]; do
33
+ if [[ -d "$DIR/.compass" ]]; then
34
+ COMPASS_DIR="$DIR/.compass"
35
+ break
36
+ fi
37
+ DIR=$(dirname "$DIR")
38
+ done
39
+
40
+ [[ -n "$COMPASS_DIR" ]] || exit 0
41
+
42
+ CONFIG="$COMPASS_DIR/config.yaml"
43
+ [[ -f "$CONFIG" ]] || exit 0
44
+
45
+ ENABLED=$(grep -A1 "hooks:" "$CONFIG" | grep "commit_check:" | awk '{print $2}')
46
+ [[ "$ENABLED" == "true" ]] || exit 0
47
+
48
+ # Extract commit message from -m flag
49
+ MSG=$(echo "$COMMAND" | grep -oP '(?<=-m\s)["\x27]([^"\x27]*)["\x27]' | tr -d "\"'" | head -1)
50
+
51
+ # If no -m flag found (might use heredoc or other format), skip validation
52
+ [[ -n "$MSG" ]] || exit 0
53
+
54
+ # Validate conventional commit format
55
+ # Pattern: type(scope)?: description
56
+ # Types: feat, fix, chore, docs, refactor, test, ci, perf, build, style, revert
57
+ PATTERN='^(feat|fix|chore|docs|refactor|test|ci|perf|build|style|revert)(\([a-zA-Z0-9_-]+\))?!?:.+'
58
+
59
+ if ! echo "$MSG" | grep -qE "$PATTERN"; then
60
+ # Exit 2 = block the tool call
61
+ cat <<EOF
62
+ {"error": "COMPASS COMMIT CHECK: Commit message does not follow conventional commits format. Expected: type(scope)?: description. Types: feat, fix, chore, docs, refactor, test, ci, perf, build, style, revert. Got: '$MSG'"}
63
+ EOF
64
+ exit 2
65
+ fi
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # compass-context-monitor.sh — Claude Code PostToolUse hook
4
+ # Monitors context usage and warns when approaching limits.
5
+ #
6
+ # Hook type: PostToolUse
7
+ # Matcher: (all tool uses, debounced internally)
8
+ #
9
+ # This hook reads the Claude Code statusline metrics and injects
10
+ # warnings when context is running low.
11
+
12
+ # Timeout guard
13
+ TIMEOUT_PID=$$
14
+ ( sleep 5 && kill -0 "$TIMEOUT_PID" 2>/dev/null && kill "$TIMEOUT_PID" ) &
15
+ WATCHDOG=$!
16
+ trap "kill $WATCHDOG 2>/dev/null" EXIT
17
+
18
+ # Debounce — only check every 10 tool uses
19
+ COUNTER_FILE="/tmp/compass-ctx-counter-$$"
20
+ if [[ -f "$COUNTER_FILE" ]]; then
21
+ COUNT=$(cat "$COUNTER_FILE")
22
+ COUNT=$((COUNT + 1))
23
+ echo "$COUNT" > "$COUNTER_FILE"
24
+ [[ $((COUNT % 10)) -eq 0 ]] || exit 0
25
+ else
26
+ echo "1" > "$COUNTER_FILE"
27
+ exit 0
28
+ fi
29
+
30
+ # Look for Claude Code context metrics
31
+ # The statusline bridge file location varies — check common paths
32
+ SESSION_ID="${CLAUDE_SESSION_ID:-unknown}"
33
+ METRICS_FILE="/tmp/claude-ctx-${SESSION_ID}.json"
34
+
35
+ [[ -f "$METRICS_FILE" ]] || exit 0
36
+
37
+ # Try to read remaining percentage
38
+ REMAINING=$(grep -o '"remaining":[0-9.]*' "$METRICS_FILE" 2>/dev/null | head -1 | cut -d: -f2)
39
+
40
+ [[ -n "$REMAINING" ]] || exit 0
41
+
42
+ # Convert to integer for comparison
43
+ REMAINING_INT=${REMAINING%.*}
44
+
45
+ if [[ $REMAINING_INT -le 25 ]]; then
46
+ cat <<EOF
47
+ {"additionalContext": "COMPASS CONTEXT MONITOR — CRITICAL: Context is at ${REMAINING_INT}% remaining. Save your work: run /compass:next to capture current state, then /clear before continuing. SESSION.md will preserve your position."}
48
+ EOF
49
+ elif [[ $REMAINING_INT -le 35 ]]; then
50
+ cat <<EOF
51
+ {"additionalContext": "COMPASS CONTEXT MONITOR — WARNING: Context is at ${REMAINING_INT}% remaining. Consider finishing current task and running /clear soon. Use /compass:next to see where you are."}
52
+ EOF
53
+ fi
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # compass-preflight.sh — Claude Code PreToolUse hook
4
+ # Checks phase prerequisites before /compass:* commands execute.
5
+ #
6
+ # Hook type: PreToolUse
7
+ # Matcher: tool_name == "Skill" and skill name starts with "compass-"
8
+ #
9
+ # This hook injects advisory context about missing prerequisites.
10
+ # It does NOT block execution — the skill itself handles missing prereqs.
11
+
12
+ # Timeout guard
13
+ TIMEOUT_PID=$$
14
+ ( sleep 5 && kill -0 "$TIMEOUT_PID" 2>/dev/null && kill "$TIMEOUT_PID" ) &
15
+ WATCHDOG=$!
16
+ trap "kill $WATCHDOG 2>/dev/null" EXIT
17
+
18
+ # Read hook input
19
+ INPUT=$(cat)
20
+
21
+ # Check if this is a compass skill invocation
22
+ SKILL_NAME=$(echo "$INPUT" | grep -o '"skill":"[^"]*"' | head -1 | cut -d'"' -f4)
23
+
24
+ case "$SKILL_NAME" in
25
+ compass-*) ;;
26
+ *) exit 0 ;;
27
+ esac
28
+
29
+ # Extract phase from skill name
30
+ PHASE="${SKILL_NAME#compass-}"
31
+
32
+ # Find compass-tools.sh
33
+ TOOLS_SCRIPT=""
34
+ for candidate in \
35
+ "$HOME/.claude/compass/scripts/compass-tools.sh" \
36
+ "$(dirname "$(dirname "$0")")/scripts/compass-tools.sh"; do
37
+ if [[ -x "$candidate" ]]; then
38
+ TOOLS_SCRIPT="$candidate"
39
+ break
40
+ fi
41
+ done
42
+
43
+ [[ -n "$TOOLS_SCRIPT" ]] || exit 0
44
+
45
+ # Run preflight check
46
+ RESULT=$("$TOOLS_SCRIPT" preflight "$PHASE" 2>/dev/null)
47
+ [[ $? -eq 0 ]] || exit 0
48
+
49
+ READY=$(echo "$RESULT" | grep -o '"ready":[a-z]*' | cut -d: -f2)
50
+
51
+ if [[ "$READY" == "false" ]]; then
52
+ MISSING=$(echo "$RESULT" | grep -o '"missing":\[[^]]*\]' | sed 's/"missing":\[//;s/\]//;s/"//g')
53
+ cat <<EOF
54
+ {"additionalContext": "COMPASS PREFLIGHT: Phase '$PHASE' has missing prerequisites: $MISSING. The skill will handle this, but be aware."}
55
+ EOF
56
+ fi
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # compass-scope-guardian.sh — Claude Code PostToolUse hook
4
+ # Triggers on Write/Edit outside .compass/ during build phase.
5
+ # Compares changes against SPEC.md, ADRs, and FRAMING.md.
6
+ #
7
+ # Hook type: PostToolUse
8
+ # Matcher: tool_name in ["Write", "Edit"]
9
+ #
10
+ # This hook injects advisory context — it does not block operations.
11
+ # The scope-guardian agent interprets the findings.
12
+
13
+ # Timeout guard — do not block Claude Code
14
+ TIMEOUT_PID=$$
15
+ ( sleep 8 && kill -0 "$TIMEOUT_PID" 2>/dev/null && kill "$TIMEOUT_PID" ) &
16
+ WATCHDOG=$!
17
+ trap "kill $WATCHDOG 2>/dev/null" EXIT
18
+
19
+ # Read hook input from stdin
20
+ INPUT=$(cat)
21
+
22
+ # Extract tool name and file path
23
+ TOOL_NAME=$(echo "$INPUT" | grep -o '"tool_name":"[^"]*"' | head -1 | cut -d'"' -f4)
24
+ FILE_PATH=$(echo "$INPUT" | grep -o '"file_path":"[^"]*"' | head -1 | cut -d'"' -f4)
25
+
26
+ # Only process Write/Edit
27
+ case "$TOOL_NAME" in
28
+ Write|Edit) ;;
29
+ *) exit 0 ;;
30
+ esac
31
+
32
+ # Skip if editing inside .compass/
33
+ case "$FILE_PATH" in
34
+ */.compass/*) exit 0 ;;
35
+ esac
36
+
37
+ # Find .compass/ directory
38
+ COMPASS_DIR=""
39
+ DIR="$PWD"
40
+ while [[ "$DIR" != "/" ]]; do
41
+ if [[ -d "$DIR/.compass" ]]; then
42
+ COMPASS_DIR="$DIR/.compass"
43
+ break
44
+ fi
45
+ DIR=$(dirname "$DIR")
46
+ done
47
+
48
+ [[ -n "$COMPASS_DIR" ]] || exit 0
49
+
50
+ # Check if scope guardian is enabled
51
+ CONFIG="$COMPASS_DIR/config.yaml"
52
+ if [[ -f "$CONFIG" ]]; then
53
+ ENABLED=$(grep -A1 "hooks:" "$CONFIG" | grep "scope_guardian:" | awk '{print $2}')
54
+ [[ "$ENABLED" == "false" ]] && exit 0
55
+ fi
56
+
57
+ # Check if we're in build phase (units exist)
58
+ UNITS_DIR="$COMPASS_DIR/UNITS"
59
+ [[ -d "$UNITS_DIR" ]] || exit 0
60
+ UNIT_COUNT=$(find "$UNITS_DIR" -name 'unit-*.md' 2>/dev/null | wc -l)
61
+ [[ $UNIT_COUNT -gt 0 ]] || exit 0
62
+
63
+ # Check if spec exists
64
+ SPEC_FILE="$COMPASS_DIR/SPEC.md"
65
+ [[ -f "$SPEC_FILE" ]] || exit 0
66
+
67
+ # Find compass-tools.sh
68
+ TOOLS_SCRIPT=""
69
+ for candidate in \
70
+ "$HOME/.claude/compass/scripts/compass-tools.sh" \
71
+ "$(dirname "$(dirname "$0")")/scripts/compass-tools.sh"; do
72
+ if [[ -x "$candidate" ]]; then
73
+ TOOLS_SCRIPT="$candidate"
74
+ break
75
+ fi
76
+ done
77
+
78
+ # Run drift analysis if tools script is available
79
+ FILENAME=$(basename "$FILE_PATH")
80
+ if [[ -n "$TOOLS_SCRIPT" ]]; then
81
+ DRIFT_OUTPUT=$("$TOOLS_SCRIPT" drift --json 2>/dev/null || true)
82
+ if [[ -n "$DRIFT_OUTPUT" ]]; then
83
+ FILE_COUNT=$(echo "$DRIFT_OUTPUT" | grep -o '"files_changed":[0-9]*' | cut -d: -f2)
84
+ CHANGED=$(echo "$DRIFT_OUTPUT" | grep -o '"changed_files":\[[^]]*\]' | sed 's/"changed_files"://;s/\[//;s/\]//;s/"//g' | tr ',' ', ')
85
+ cat <<EOF
86
+ {"additionalContext": "SCOPE GUARDIAN: '$FILENAME' modified outside .compass/ during build phase. Drift analysis: $FILE_COUNT file(s) changed ($CHANGED). Check these against SPEC.md, active ADRs, and FRAMING.md. Report any drift to the user: out-of-scope additions, ADR contradictions, or unspecified behavior."}
87
+ EOF
88
+ exit 0
89
+ fi
90
+ fi
91
+
92
+ # Fallback if tools script not found
93
+ cat <<EOF
94
+ {"additionalContext": "SCOPE GUARDIAN: File '$FILENAME' was modified outside .compass/ during the build phase. Check whether this change aligns with SPEC.md, active ADRs, and FRAMING.md. Report any drift to the user."}
95
+ EOF
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "compass-cc",
3
+ "version": "0.1.0",
4
+ "description": "COMPASS — Collaborative Orientation, Mapping, Planning, Architecture, Spec & Supervision. An inverted AI coding skill: the human implements, the LLM orients.",
5
+ "license": "MIT",
6
+ "author": "hvpaiva",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/hvpaiva/compass"
10
+ },
11
+ "keywords": [
12
+ "claude-code",
13
+ "ai-coding",
14
+ "spec-driven",
15
+ "architecture",
16
+ "code-review",
17
+ "adr"
18
+ ],
19
+ "bin": {
20
+ "compass-cc": "bin/install.js"
21
+ },
22
+ "files": [
23
+ "bin/",
24
+ "skills/",
25
+ "agents/",
26
+ "scripts/",
27
+ "templates/",
28
+ "hooks/",
29
+ "references/",
30
+ "constitution.md",
31
+ "README.md"
32
+ ],
33
+ "engines": {
34
+ "node": ">=18.0.0"
35
+ }
36
+ }
@@ -0,0 +1,31 @@
1
+ # Inverted Contract — Binding Rules for All COMPASS Agents
2
+
3
+ This reference is loaded by every COMPASS sub-agent. It is non-negotiable.
4
+
5
+ ## You MUST NOT
6
+
7
+ - Generate production code: functions, methods, classes, modules, structs, traits,
8
+ implementations, algorithms, or business logic.
9
+ - Generate scaffolding, boilerplate, stubs, or starter code.
10
+ - Suggest specific code fixes: "change line N to X", "replace this with Y."
11
+ - Write to the target project's git repository.
12
+ - Resolve ambiguities the human could resolve — ask instead.
13
+
14
+ ## You MUST
15
+
16
+ - Ask questions that help the human think clearly.
17
+ - Cite sources for every factual claim.
18
+ - Report problems without prescribing code solutions.
19
+ - Respect phase gates — never advance without human approval.
20
+ - Read state from `.compass/` files, not from conversation memory.
21
+ - Call `compass-tools.sh` for state mutations, never edit state files directly.
22
+
23
+ ## Mechanical editing exception
24
+
25
+ You MAY execute textual transformations that are repetitive, non-creative, and
26
+ mechanically describable by the human. If judgment about design, architecture, or
27
+ logic is required, it is production code and you must refuse.
28
+
29
+ ## When in doubt
30
+
31
+ Ask the human. Never guess. Never infer. Never fill gaps with plausible defaults.