@ikieaneh/opencode-kit 0.5.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.
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env bash
2
+ # ⛔ opencode-kit preflight — MANDATORY enforcement gate
3
+ # Must run before any tool call. Exits with error if rules violated.
4
+ set -euo pipefail
5
+
6
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7
+ . "$SCRIPT_DIR/platform.sh"
8
+
9
+ CONTRACT_KEY="orchestration-contract"
10
+ RULES_FILE=".opencode/rules/rules.json"
11
+ CONTRACT_FILE=".opencode/orchestration/contract.json"
12
+
13
+ RED='\033[0;31m'
14
+ GREEN='\033[0;32m'
15
+ YELLOW='\033[1;33m'
16
+ NC='\033[0m'
17
+
18
+ echo "[opencode-kit] ⛔ Pre-flight check..."
19
+
20
+ # --- Check 1: contract.json exists on disk ---
21
+ if [ ! -f "$CONTRACT_FILE" ]; then
22
+ echo -e "${RED}⛔ FAILED: $CONTRACT_FILE not found. Run 'opencode-kit init' first.${NC}"
23
+ exit 1
24
+ fi
25
+ echo " ✅ contract.json exists"
26
+
27
+ # --- Check 2: not on main ---
28
+ BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
29
+ if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then
30
+ echo -e "${RED}⛔ FAILED: On '$BRANCH' branch. Create a feature branch first.${NC}"
31
+ echo " → git checkout -b feature/<YYYYMMDD>-<description>"
32
+ exit 1
33
+ fi
34
+ echo " ✅ Branch: $BRANCH (safe)"
35
+
36
+ # --- Check 3: MCP Availability ---
37
+ echo ""
38
+ echo " Checking MCP availability..."
39
+
40
+ MCP_FAIL=0
41
+
42
+ # 3a. lean-ctx
43
+ LEAN_CTX_AVAILABLE=false
44
+ if command -v lean-ctx &>/dev/null; then
45
+ echo " ✅ lean-ctx MCP: available (cli)"
46
+ LEAN_CTX_AVAILABLE=true
47
+ elif lean-ctx ctx_knowledge recall --query "$CONTRACT_KEY" &>/dev/null; then
48
+ echo " ✅ lean-ctx MCP: available (tool)"
49
+ LEAN_CTX_AVAILABLE=true
50
+ else
51
+ echo -e "${YELLOW} ⚠️ lean-ctx MCP: NOT DETECTED — contract persistence will fail${NC}"
52
+ echo -e "${YELLOW} → Ensure lean-ctx is configured in opencode.json MCP servers${NC}"
53
+ MCP_FAIL=1
54
+ fi
55
+
56
+ # 3b. gitnexus
57
+ if npx --yes gitnexus --version &>/dev/null; then
58
+ echo " ✅ gitnexus MCP: available"
59
+ elif npx --yes gitnexus list-repos &>/dev/null; then
60
+ echo " ✅ gitnexus MCP: available"
61
+ else
62
+ echo -e "${YELLOW} ⚠️ gitnexus MCP: NOT DETECTED — impact analysis will fail${NC}"
63
+ echo -e "${YELLOW} → Ensure gitnexus is configured in opencode.json MCP servers${NC}"
64
+ MCP_FAIL=1
65
+ fi
66
+
67
+ # 3c. graphify (check via gitnexus index since graphify consumes gitnexus data)
68
+ GRAPHIFY_AVAILABLE=false
69
+ if npx --yes gitnexus analyze --help &>/dev/null; then
70
+ # gitnexus is available — check if index exists
71
+ GITNEXUS_DIR=$(find . -name "gitnexus-out" -type d 2>/dev/null | head -1)
72
+ if [ -n "$GITNEXUS_DIR" ]; then
73
+ echo " ✅ graphify: available (gitnexus index found)"
74
+ GRAPHIFY_AVAILABLE=true
75
+ else
76
+ echo -e "${YELLOW} ⚠️ graphify: gitnexus index not built yet. Run: npx gitnexus analyze${NC}"
77
+ fi
78
+ else
79
+ echo -e "${YELLOW} ⚠️ graphify: gitnexus not available — graphify depends on gitnexus index${NC}"
80
+ fi
81
+
82
+ # 3d. context7 (library docs — soft check, non-blocking)
83
+ if command -v curl &>/dev/null; then
84
+ echo " ✅ context7 MCP: curl available (http transport)"
85
+ fi
86
+
87
+ echo ""
88
+
89
+ # --- Check 4: rules.json exists ---
90
+ if [ ! -f "$RULES_FILE" ]; then
91
+ echo -e "${YELLOW}⚠️ WARNING: $RULES_FILE not found. Rules enforcement disabled.${NC}"
92
+ else
93
+ echo " ✅ rules.json found"
94
+ fi
95
+
96
+ # --- Telemetry: record phase start ---
97
+ mkdir -p .opencode/telemetry
98
+ echo $(date +%s) > .opencode/telemetry/.phase_start
99
+
100
+ # --- Check 5: contract state validation ---
101
+ if [ -n "$PYTHON_CMD" ] && [ -f "$CONTRACT_FILE" ]; then
102
+ STATE=$($PYTHON_CMD -c "
103
+ import json,sys
104
+ try:
105
+ with open('$CONTRACT_FILE') as f: d=json.load(f)
106
+ print(d.get('state','UNKNOWN'))
107
+ except: print('PARSE_ERROR')
108
+ " 2>/dev/null)
109
+ if [ "$STATE" = "PARSE_ERROR" ] || [ "$STATE" = "UNKNOWN" ]; then
110
+ echo -e "${YELLOW} ⚠️ Contract state: unknown — contract.json may be malformed${NC}"
111
+ else
112
+ echo " ✅ Contract state: $STATE"
113
+ fi
114
+ fi
115
+
116
+ # --- Final verdict ---
117
+ if [ "$MCP_FAIL" -eq 1 ]; then
118
+ echo -e "${YELLOW}[opencode-kit] ⛔ Pre-flight completed with WARNINGS. Missing MCPs may cause failures.${NC}"
119
+ else
120
+ echo "[opencode-kit] ✅ Pre-flight passed. All MCPs available. Proceed."
121
+ fi
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env bash
2
+ # opencode-kit telemetry — view phase telemetry
3
+ # Usage: bash src/telemetry.sh [--json|--summary|--phases]
4
+ set -euo pipefail
5
+
6
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7
+ . "$SCRIPT_DIR/platform.sh"
8
+
9
+ TELEMETRY_DIR=".opencode/telemetry"
10
+ CONTRACT_FILE=".opencode/orchestration/contract.json"
11
+
12
+ RED='\033[0;31m'
13
+ GREEN='\033[0;32m'
14
+ YELLOW='\033[1;33m'
15
+ CYAN='\033[0;36m'
16
+ NC='\033[0m'
17
+
18
+ MODE="${1:-summary}"
19
+
20
+ echo -e "${CYAN}[opencode-kit] 📊 Telemetry${NC}"
21
+ echo ""
22
+
23
+ case "$MODE" in
24
+ --json)
25
+ if [ -f "$TELEMETRY_DIR/summary.json" ]; then
26
+ cat "$TELEMETRY_DIR/summary.json"
27
+ else
28
+ echo -e "${YELLOW}No telemetry data yet. Run a phase first.${NC}"
29
+ fi
30
+ ;;
31
+ --phases)
32
+ if [ -f "$TELEMETRY_DIR/phases.jsonl" ]; then
33
+ echo "Phase transitions:"
34
+ cat "$TELEMETRY_DIR/phases.jsonl" | while IFS= read -r line; do
35
+ [ -z "$line" ] && continue
36
+ FROM=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('from','?'))" 2>/dev/null)
37
+ TO=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('to','?'))" 2>/dev/null)
38
+ MS=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('elapsed_ms',0))" 2>/dev/null)
39
+ printf " %-20s → %-20s %5.1fs\n" "$FROM" "$TO" "$(echo "scale=1; $MS/1000" | bc 2>/dev/null || echo "$((MS/1000)).$((MS%1000/100))")"
40
+ done
41
+ else
42
+ echo -e "${YELLOW}No phase data yet.${NC}"
43
+ fi
44
+ ;;
45
+ --summary|*)
46
+ if [ -f "$TELEMETRY_DIR/summary.json" ]; then
47
+ TOTAL_S=$($PYTHON_CMD -c "import json; d=json.load(open('$TELEMETRY_DIR/summary.json')); print(d.get('total_elapsed_s',0))" 2>/dev/null || echo "0")
48
+ PHASES=$($PYTHON_CMD -c "import json; d=json.load(open('$TELEMETRY_DIR/summary.json')); print(len(d.get('phases_completed',[])))" 2>/dev/null || echo "0")
49
+ echo " Total elapsed: ${TOTAL_S}s"
50
+ echo " Phases completed: $PHASES"
51
+ echo ""
52
+ echo " Latest phases:"
53
+ tail -5 "$TELEMETRY_DIR/phases.jsonl" 2>/dev/null | while IFS= read -r line; do
54
+ [ -z "$line" ] && continue
55
+ TS=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('ts','?'))" 2>/dev/null | cut -dT -f2 | cut -d. -f1)
56
+ FROM=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('from','?'))" 2>/dev/null)
57
+ TO=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('to','?'))" 2>/dev/null)
58
+ MS=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('elapsed_ms',0))" 2>/dev/null)
59
+ echo " $TS $FROM → $TO ($((MS/1000))s)"
60
+ done
61
+ else
62
+ echo -e "${YELLOW}No telemetry data yet. Run a phase first.${NC}"
63
+ echo " Phases are recorded automatically by postflight.sh"
64
+ fi
65
+ ;;
66
+ esac
package/src/update.sh ADDED
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env bash
2
+ # opencode-kit update — pull latest templates and scripts from GitHub
3
+ # Preserves existing contract.json state (goal, scope, decisions).
4
+ # Usage: bash src/update.sh [--dry-run] [--version <tag>]
5
+ set -euo pipefail
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8
+ . "$SCRIPT_DIR/platform.sh"
9
+
10
+ RED='\033[0;31m'
11
+ GREEN='\033[0;32m'
12
+ YELLOW='\033[1;33m'
13
+ CYAN='\033[0;36m'
14
+ NC='\033[0m'
15
+
16
+ DRY_RUN=false
17
+ VERSION="main"
18
+ REPO_URL="https://github.com/RizkiRachman/opencode-kit.git"
19
+
20
+ # --- Parse args ---
21
+ while [ $# -gt 0 ]; do
22
+ case "$1" in
23
+ --dry-run) DRY_RUN=true; shift ;;
24
+ --version) VERSION="$2"; shift 2 ;;
25
+ -v) VERSION="$2"; shift 2 ;;
26
+ *) echo -e "${RED}Unknown: $1${NC}"; exit 1 ;;
27
+ esac
28
+ done
29
+
30
+ echo -e "${CYAN}[opencode-kit] 🔄 Update check${NC}"
31
+ echo " Current dir: $PWD"
32
+ echo " Source: $REPO_URL (branch: $VERSION)"
33
+ echo " Dry run: $DRY_RUN"
34
+ echo ""
35
+
36
+ # --- Check we're in an opencode-kit project ---
37
+ if [ ! -d ".opencode" ]; then
38
+ echo -e "${RED}❌ No .opencode/ directory found. Are you in an opencode-kit project?${NC}"
39
+ exit 1
40
+ fi
41
+
42
+ # --- Clone latest to temp ---
43
+ TEMP_DIR=$(mktemp -d /tmp/opencode-kit-XXXXX)
44
+ echo " Cloning latest version to $TEMP_DIR..."
45
+
46
+ if ! git clone --depth 1 --branch "$VERSION" "$REPO_URL" "$TEMP_DIR" 2>/dev/null; then
47
+ echo -e "${RED}❌ Failed to clone $REPO_URL (branch: $VERSION)${NC}"
48
+ rm -rf "$TEMP_DIR"
49
+ exit 1
50
+ fi
51
+ echo " ✅ Cloned"
52
+
53
+ # --- Read versions ---
54
+ CURRENT_VERSION=""
55
+ if [ -f ".opencode/orchestration/contract.json" ]; then
56
+ CURRENT_VERSION=$($PYTHON_CMD -c "
57
+ import json
58
+ with open('.opencode/orchestration/contract.json') as f:
59
+ d=json.load(f)
60
+ print(d.get('contract_version', 'unknown'))
61
+ " 2>/dev/null || echo "unknown")
62
+ fi
63
+
64
+ LATEST_VERSION=$($PYTHON_CMD -c "
65
+ import json
66
+ with open('$TEMP_DIR/templates/contract.json') as f:
67
+ d=json.load(f)
68
+ print(d.get('contract_version', 'unknown'))
69
+ " 2>/dev/null || echo "unknown")
70
+
71
+ echo " Current version: $CURRENT_VERSION"
72
+ echo " Latest version: $LATEST_VERSION"
73
+ echo ""
74
+
75
+ if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ] && [ "$VERSION" = "main" ]; then
76
+ echo -e "${GREEN}✅ Already up to date (v$CURRENT_VERSION)${NC}"
77
+ rm -rf "$TEMP_DIR"
78
+ exit 0
79
+ fi
80
+
81
+ # --- Backup contract state ---
82
+ echo " Backing up contract state..."
83
+ STATE_BACKUP=$(mktemp /tmp/opencode-contract-state-XXXXX.json)
84
+ $PYTHON_CMD -c "
85
+ import json
86
+ with open('.opencode/orchestration/contract.json') as f:
87
+ d = json.load(f)
88
+ # Extract only the state fields to preserve
89
+ state = {
90
+ 'requirements': d.get('requirements', {}),
91
+ 'scope': d.get('scope', {}),
92
+ 'decisions': d.get('decisions', {}),
93
+ 'governance': d.get('governance', {}),
94
+ 'metrics': d.get('metrics', {}),
95
+ 'lessons_learned': d.get('lessons_learned', []),
96
+ 'retry': d.get('retry', {}),
97
+ 'score': d.get('score', {}),
98
+ 'outputs': d.get('outputs', {})
99
+ }
100
+ with open('$STATE_BACKUP', 'w') as f:
101
+ json.dump(state, f, indent=2)
102
+ " 2>/dev/null || echo " ⚠️ Could not backup contract state"
103
+ echo " ✅ State backed up"
104
+
105
+ # --- Files to update ---
106
+ echo ""
107
+ echo " Files to update:"
108
+ UPDATES=0
109
+
110
+ update_file() {
111
+ local src="$1"
112
+ local dst="$2"
113
+ local label="$3"
114
+ if [ -f "$src" ]; then
115
+ if [ "$DRY_RUN" = true ]; then
116
+ echo " [DRY-RUN] Would update: $label"
117
+ else
118
+ cp "$src" "$dst"
119
+ chmod +x "$dst" 2>/dev/null || true
120
+ echo " ✅ Updated: $label"
121
+ fi
122
+ UPDATES=$((UPDATES + 1))
123
+ else
124
+ echo " ⚠️ Source not found: $src"
125
+ fi
126
+ }
127
+
128
+ # Update scripts
129
+ for script in preflight.sh postflight.sh verify.sh adr.sh platform.sh; do
130
+ update_file "$TEMP_DIR/src/$script" ".opencode/src/$script" "src/$script"
131
+ done
132
+
133
+ # Update init.sh (for future --force re-inits)
134
+ update_file "$TEMP_DIR/src/init.sh" ".opencode/src/init.sh" "src/init.sh"
135
+
136
+ # Update update.sh itself
137
+ update_file "$TEMP_DIR/src/update.sh" ".opencode/src/update.sh" "src/update.sh"
138
+
139
+ # Update rules
140
+ update_file "$TEMP_DIR/rules/rules.json" ".opencode/rules/rules.json" "rules/rules.json"
141
+ update_file "$TEMP_DIR/rules/validation.sh" ".opencode/rules/validation.sh" "rules/validation.sh"
142
+
143
+ # Update agent templates (but NOT contract.json — preserve state)
144
+ for agent in orchestrator planner task-manager code-reviewer learner fixer; do
145
+ update_file "$TEMP_DIR/templates/agents/$agent.md" ".opencode/agents/$agent.md" "agents/$agent.md"
146
+ done
147
+
148
+ # Update superpowers contract template
149
+ update_file "$TEMP_DIR/templates/superpowers-contract.json" ".opencode/templates/superpowers-contract.json" "superpowers-contract.json"
150
+
151
+ # --- Restore contract state ---
152
+ if [ "$DRY_RUN" = false ] && [ -f "$STATE_BACKUP" ]; then
153
+ $PYTHON_CMD -c "
154
+ import json
155
+ with open('.opencode/orchestration/contract.json') as f:
156
+ contract = json.load(f)
157
+ with open('$STATE_BACKUP') as f:
158
+ state = json.load(f)
159
+ # Merge preserved state back into new contract
160
+ for key, val in state.items():
161
+ if val: # only overwrite if backup has data
162
+ contract[key] = val
163
+ # Update contract_version to latest
164
+ contract['contract_version'] = '$LATEST_VERSION'
165
+ with open('.opencode/orchestration/contract.json', 'w') as f:
166
+ json.dump(contract, f, indent=2)
167
+ " 2>/dev/null && echo " ✅ Contract state restored" || echo " ⚠️ Contract state restore failed"
168
+ fi
169
+
170
+ # --- Cleanup ---
171
+ rm -rf "$TEMP_DIR" "$STATE_BACKUP"
172
+
173
+ # --- Summary ---
174
+ echo ""
175
+ if [ "$DRY_RUN" = true ]; then
176
+ echo -e "${YELLOW}[opencode-kit] 🔄 Dry run complete. $UPDATES files would be updated.${NC}"
177
+ else
178
+ echo -e "${GREEN}[opencode-kit] ✅ Update complete. $UPDATES files updated.${NC}"
179
+ echo " Run .opencode/src/verify.sh to verify installation."
180
+ fi
package/src/verify.sh ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ # opencode-kit verify — check installation health
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+
7
+ echo "[opencode-kit] 🔍 Verify: checking installation..."
8
+ FAIL=0
9
+
10
+ # --- Check 1: required files exist ---
11
+ for f in \
12
+ ".opencode/orchestration/contract.json" \
13
+ ".opencode/rules/rules.json" \
14
+ ".opencode/templates/superpowers-contract.json"; do
15
+ if [ -f "$f" ]; then
16
+ echo " ✅ $f"
17
+ else
18
+ echo " ❌ $f MISSING"
19
+ FAIL=1
20
+ fi
21
+ done
22
+
23
+ # --- Check 2: agent .md files exist ---
24
+ for agent in orchestrator planner task-manager code-reviewer learner fixer; do
25
+ FILE=".opencode/agents/$agent.md"
26
+ if [ -f "$FILE" ]; then
27
+ # Check pre-flight gate exists in file
28
+ if grep -q "load contract" "$FILE" 2>/dev/null; then
29
+ echo " ✅ agents/$agent.md (has pre-flight gate)"
30
+ else
31
+ echo " ⚠️ agents/$agent.md (MISSING pre-flight gate)"
32
+ fi
33
+ else
34
+ echo " ❌ agents/$agent.md MISSING"
35
+ FAIL=1
36
+ fi
37
+ done
38
+
39
+ # --- Check 3: telemetry directory ---
40
+ mkdir -p .opencode/telemetry 2>/dev/null
41
+ echo " ✅ telemetry directory ready"
42
+
43
+ # --- Check 4: scripts executable ---
44
+ for script in ".opencode/src/preflight.sh" ".opencode/src/postflight.sh" ".opencode/src/telemetry.sh"; do
45
+ if [ -x "$script" ]; then
46
+ echo " ✅ $script (executable)"
47
+ elif [ -f "$script" ]; then
48
+ echo " ⚠️ $script (not executable — run chmod +x)"
49
+ else
50
+ echo " ❌ $script MISSING"
51
+ FAIL=1
52
+ fi
53
+ done
54
+
55
+ # --- Check 5: not on main ---
56
+ BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
57
+ if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then
58
+ echo " ⚠️ On '$BRANCH' branch — create a feature branch"
59
+ fi
60
+ echo " ℹ️ Branch: $BRANCH"
61
+
62
+ if [ "$FAIL" -eq 1 ]; then
63
+ echo "[opencode-kit] ❌ Verify FAILED — run 'opencode-kit init' to repair"
64
+ exit 1
65
+ fi
66
+
67
+ echo "[opencode-kit] ✅ All checks passed"
@@ -0,0 +1,88 @@
1
+ ---
2
+ description: Read-only code review — quality, security, performance, DevOps. No edits.
3
+ mode: subagent
4
+ temperature: 0.1
5
+ permission:
6
+ read: allow
7
+ glob: allow
8
+ grep: allow
9
+ list: allow
10
+ webfetch: allow
11
+ edit: deny
12
+ bash:
13
+ "*": ask
14
+ "git diff*": allow
15
+ "git log*": allow
16
+ "mvn test*": allow
17
+ "mvn compile*": allow
18
+ "mvn verify": allow
19
+ task:
20
+ "*": deny
21
+ ---
22
+
23
+ ## ⛔ PRE-FLIGHT GATE — DO NOT SKIP
24
+
25
+ ```
26
+ 1. Load contract: lean-ctx ctx_knowledge recall --query "orchestration-contract"
27
+ → Extract: requirements.*, governance.*, outputs.code_changes[]
28
+ → If empty → STOP
29
+
30
+ 2. Validate state: Must be REVIEW
31
+ → If wrong state → STOP
32
+
33
+ 3. Read rules.json: Understand what rules to check against
34
+ ```
35
+
36
+ ## Permissions
37
+ - Read: All project files
38
+ - Write: None (strictly read-only)
39
+ - Cannot: Edit files, spawn subagents
40
+
41
+ You are a read-only code reviewer. You never make edits.
42
+
43
+ ## Four Lenses
44
+
45
+ ### 1. Code Quality & SOLID
46
+ - SOLID violations, god classes, feature envy
47
+ - Duplicate code, dead code, TODOs
48
+ - Naming clarity, proper abstractions
49
+
50
+ ### 2. Security
51
+ - Input validation, injection, XSS, CSRF
52
+ - AuthZ checked on every endpoint?
53
+ - Secrets in code, config, logs?
54
+
55
+ ### 3. Performance & Reliability
56
+ - N+1 queries, missing indexes, no pagination
57
+ - Timeout handling, retry with backoff
58
+ - Race conditions, deadlocks
59
+
60
+ ### 4. DevOps Operability
61
+ - Zero-downtime deploy? Backward-compatible migrations?
62
+ - New env vars documented? Observability adequate?
63
+
64
+ ## Report Format
65
+ ```json
66
+ {
67
+ "verdict": "PASS|FLAG|BLOCK",
68
+ "findings": {
69
+ "critical": [{ "file": "path:line", "impact": "...", "recommendation": "..." }],
70
+ "high": [],
71
+ "medium": [],
72
+ "low": []
73
+ },
74
+ "summary": "X critical, Y high, Z medium, W low",
75
+ "lens_coverage": {
76
+ "code_quality": "red|yellow|green",
77
+ "security": "red|yellow|green",
78
+ "performance": "red|yellow|green",
79
+ "devops": "red|yellow|green"
80
+ },
81
+ "blast_radius_verified": true
82
+ }
83
+ ```
84
+
85
+ **Verdict rules:**
86
+ - `PASS` — no critical/high findings
87
+ - `FLAG` — has high findings, needs discussion
88
+ - `BLOCK` — has critical findings or architecture violations
@@ -0,0 +1,56 @@
1
+ ---
2
+ description: Fast implementation specialist for well-defined bounded tasks. Read/write files, scoped edits only.
3
+ mode: subagent
4
+ temperature: 0.1
5
+ permission:
6
+ read: allow
7
+ edit: allow
8
+ write: allow
9
+ glob: allow
10
+ grep: allow
11
+ list: allow
12
+ bash:
13
+ "*": ask
14
+ "mvn spotless:apply": allow
15
+ "mvn test*": allow
16
+ "mvn compile*": allow
17
+ "git diff*": allow
18
+ task:
19
+ "*": deny
20
+ ---
21
+
22
+ ## ⛔ PRE-FLIGHT GATE — DO NOT SKIP
23
+
24
+ ```
25
+ 1. Load contract: lean-ctx ctx_knowledge recall --query "orchestration-contract"
26
+ → Extract: decisions.*, governance.*, scope.included
27
+ → If empty → STOP
28
+
29
+ 2. Check branch: git branch --show-current
30
+ → If main/master: STOP
31
+
32
+ 3. Read scope: scope.included defines what you may modify
33
+ → Do NOT touch files outside scope
34
+ ```
35
+
36
+ ## Permissions
37
+ - Read: All project files
38
+ - Write: Scoped to assigned task only
39
+ - Execute: mvn spotless:apply, mvn test/compile, git diff
40
+ - Cannot: Spawn subagents, push to git, modify CI/CD
41
+
42
+ You are a **fast implementation specialist for well-defined bounded tasks**. You do NOT research, make decisions, or expand scope.
43
+
44
+ ## Process
45
+ 1. Read assigned scope only
46
+ 2. Follow project conventions (writing order, naming)
47
+ 3. Make changes efficiently
48
+ 4. Run spotless:apply + mvn compile on affected modules
49
+ 5. Do NOT expand scope or make unsolicited improvements
50
+
51
+ ## Output Format
52
+ Return concise report:
53
+ 1. Files modified (paths + line ranges)
54
+ 2. Summary of changes per file
55
+ 3. Test results (compile/test pass/fail)
56
+ 4. Any risks introduced or deviations from spec
@@ -0,0 +1,87 @@
1
+ ---
2
+ description: Post-execution learning agent. Extracts lessons, persists knowledge, updates all memory systems.
3
+ mode: subagent
4
+ temperature: 0.3
5
+ permission:
6
+ read: allow
7
+ glob: allow
8
+ grep: allow
9
+ list: allow
10
+ edit: deny
11
+ bash:
12
+ "*": ask
13
+ "git diff*": allow
14
+ "git log*": allow
15
+ task:
16
+ "*": deny
17
+ ---
18
+
19
+ ## ⛔ PRE-FLIGHT GATE — DO NOT SKIP
20
+
21
+ ```
22
+ 1. Load contract: lean-ctx ctx_knowledge recall --query "orchestration-contract"
23
+ → Extract ALL fields: session, requirements, decisions, outputs, score, metrics, retry, lessons_learned[]
24
+ → If empty → STOP. Cannot analyze without contract.
25
+
26
+ 2. Sync ALL memory systems before analysis:
27
+ - STATE.md, PROJECT.md, AGENTS.md
28
+ - lean-ctx knowledge (recall architecture, conventions, testing)
29
+ - gitnexus: re-index + detect_changes
30
+ - graphify: check stats
31
+ - git log --oneline -10
32
+ - git diff main...HEAD --stat
33
+
34
+ 3. Read rules.json: Check LEARN_001 (must update ALL 11 memory systems)
35
+ ```
36
+
37
+ ## Permissions
38
+ - Read: All project files
39
+ - Write: None (read-only analysis)
40
+ - Cannot: Edit files, run builds, spawn subagents
41
+
42
+ You are the **learner agent** — the last agent called. You turn every completed task into durable knowledge.
43
+
44
+ ## Mandatory: Update ALL Memory Systems
45
+
46
+ | System | Tool | What to Do |
47
+ |--------|------|------------|
48
+ | lean-ctx knowledge | `ctx_knowledge remember` | Persist gotchas, patterns, decisions |
49
+ | STATE.md | Note updates needed | Append completed work, update focus |
50
+ | Orchestration contract | `ctx_knowledge remember --key orchestration-contract` | Set state=COMPLETE, append lessons |
51
+ | gitnexus | `npx gitnexus analyze` | Re-index code intelligence |
52
+ | graphify | Auto-consumes gitnexus | Verify via graphify_graph_stats |
53
+ | Handoff pack | Via memory-mcp | Label: handoff.learner.<task_id> |
54
+ | ctx_session | `ctx_session save` | Persist conversation |
55
+
56
+ ## Analysis Process
57
+
58
+ ### Step 1: Review what happened
59
+ - Read git diff, contract, test results
60
+ - Check: Did plan match execution?
61
+
62
+ ### Step 2: Extract learnings
63
+ - **What went well** (1-3) — reinforce as patterns
64
+ - **What went wrong** (1-3) — prevent recurrence
65
+ - **What to change next time** (1-2) — concrete, actionable
66
+
67
+ ### Step 3: Persist knowledge
68
+ - Gotchas → `ctx_knowledge remember category gotchas`
69
+ - Patterns → `ctx_knowledge remember category architecture`
70
+ - Decisions → `ctx_knowledge remember category architecture`
71
+
72
+ ### 4. Output Format
73
+ ```json
74
+ {
75
+ "lessons_learned": ["..."],
76
+ "knowledge_updates": [
77
+ { "category": "gotchas", "key": "...", "value": "...", "severity": "warning" }
78
+ ],
79
+ "next_session_tips": "...",
80
+ "docs_updated": [],
81
+ "envelope_updates": {
82
+ "state": "COMPLETE",
83
+ "score_combined": 0,
84
+ "phases_completed": []
85
+ }
86
+ }
87
+ ```