@ikieaneh/opencode-kit 0.6.2 → 0.6.4

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/src/update.sh DELETED
@@ -1,188 +0,0 @@
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
- # shellcheck source=./platform.sh
9
- . "$SCRIPT_DIR/platform.sh"
10
-
11
- RED='\033[0;31m'
12
- GREEN='\033[0;32m'
13
- YELLOW='\033[1;33m'
14
- CYAN='\033[0;36m'
15
- NC='\033[0m'
16
-
17
- DRY_RUN=false
18
- VERSION="main"
19
- REPO_URL="https://github.com/RizkiRachman/opencode-kit.git"
20
-
21
- # --- Parse args ---
22
- while [ $# -gt 0 ]; do
23
- case "$1" in
24
- --dry-run) DRY_RUN=true; shift ;;
25
- --version) VERSION="$2"; shift 2 ;;
26
- -v) VERSION="$2"; shift 2 ;;
27
- *) echo -e "${RED}Unknown: $1${NC}"; exit 1 ;;
28
- esac
29
- done
30
-
31
- # --- Verify Python availability ---
32
- if [ -z "${PYTHON_CMD:-}" ]; then
33
- echo -e "${RED}❌ PYTHON_CMD is not set. Python is required for update operations.${NC}"
34
- exit 1
35
- fi
36
-
37
- echo -e "${CYAN}[opencode-kit] 🔄 Update check${NC}"
38
- echo " Current dir: $PWD"
39
- echo " Source: $REPO_URL (branch: $VERSION)"
40
- echo " Dry run: $DRY_RUN"
41
- echo ""
42
-
43
- # --- Check we're in an opencode-kit project ---
44
- if [ ! -d ".opencode" ]; then
45
- echo -e "${RED}❌ No .opencode/ directory found. Are you in an opencode-kit project?${NC}"
46
- exit 1
47
- fi
48
-
49
- # --- Clone latest to temp ---
50
- TEMP_DIR=$(mktemp -d /tmp/opencode-kit-XXXXX)
51
- trap 'rm -rf "$TEMP_DIR"' EXIT INT TERM
52
- echo " Cloning latest version to $TEMP_DIR..."
53
-
54
- if ! git clone --depth 1 --branch "$VERSION" "$REPO_URL" "$TEMP_DIR" 2>/dev/null; then
55
- echo -e "${RED}❌ Failed to clone $REPO_URL (branch: $VERSION)${NC}"
56
- rm -rf "$TEMP_DIR"
57
- exit 1
58
- fi
59
- echo " ✅ Cloned"
60
-
61
- # --- Read versions ---
62
- CURRENT_VERSION=""
63
- if [ -f ".opencode/orchestration/contract.json" ]; then
64
- CURRENT_VERSION=$($PYTHON_CMD -c "
65
- import json
66
- with open('.opencode/orchestration/contract.json') as f:
67
- d=json.load(f)
68
- print(d.get('contract_version', 'unknown'))
69
- " 2>/dev/null || echo "unknown")
70
- fi
71
-
72
- LATEST_VERSION=$(TEMP_DIR="$TEMP_DIR" $PYTHON_CMD -c "
73
- import os, json
74
- with open(os.environ['TEMP_DIR'] + '/templates/contract.json') as f:
75
- d=json.load(f)
76
- print(d.get('contract_version', 'unknown'))
77
- " 2>/dev/null || echo "unknown")
78
-
79
- echo " Current version: $CURRENT_VERSION"
80
- echo " Latest version: $LATEST_VERSION"
81
- echo ""
82
-
83
- if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ] && [ "$VERSION" = "main" ]; then
84
- echo -e "${GREEN}✅ Already up to date (v$CURRENT_VERSION)${NC}"
85
- rm -rf "$TEMP_DIR"
86
- exit 0
87
- fi
88
-
89
- # --- Backup contract state ---
90
- echo " Backing up contract state..."
91
- STATE_BACKUP=$(mktemp /tmp/opencode-contract-state-XXXXX.json)
92
- STATE_BACKUP="$STATE_BACKUP" $PYTHON_CMD -c "
93
- import os, json
94
- with open('.opencode/orchestration/contract.json') as f:
95
- d = json.load(f)
96
- # Extract only the state fields to preserve
97
- state = {
98
- 'requirements': d.get('requirements', {}),
99
- 'scope': d.get('scope', {}),
100
- 'decisions': d.get('decisions', {}),
101
- 'governance': d.get('governance', {}),
102
- 'metrics': d.get('metrics', {}),
103
- 'lessons_learned': d.get('lessons_learned', []),
104
- 'retry': d.get('retry', {}),
105
- 'score': d.get('score', {}),
106
- 'outputs': d.get('outputs', {})
107
- }
108
- with open(os.environ['STATE_BACKUP'], 'w') as f:
109
- json.dump(state, f, indent=2)
110
- " 2>/dev/null || echo " ⚠️ Could not backup contract state"
111
- echo " ✅ State backed up"
112
-
113
- # --- Files to update ---
114
- echo ""
115
- echo " Files to update:"
116
- UPDATES=0
117
-
118
- update_file() {
119
- local src="$1"
120
- local dst="$2"
121
- local label="$3"
122
- if [ -f "$src" ]; then
123
- if [ "$DRY_RUN" = true ]; then
124
- echo " [DRY-RUN] Would update: $label"
125
- else
126
- cp "$src" "$dst"
127
- chmod +x "$dst" 2>/dev/null || true
128
- echo " ✅ Updated: $label"
129
- fi
130
- UPDATES=$((UPDATES + 1))
131
- else
132
- echo " ⚠️ Source not found: $src"
133
- fi
134
- }
135
-
136
- # Update scripts
137
- for script in preflight.sh postflight.sh verify.sh adr.sh platform.sh; do
138
- update_file "$TEMP_DIR/src/$script" ".opencode/src/$script" "src/$script"
139
- done
140
-
141
- # Update init.sh (for future --force re-inits)
142
- update_file "$TEMP_DIR/src/init.sh" ".opencode/src/init.sh" "src/init.sh"
143
-
144
- # Update update.sh itself
145
- update_file "$TEMP_DIR/src/update.sh" ".opencode/src/update.sh" "src/update.sh"
146
-
147
- # Update rules
148
- update_file "$TEMP_DIR/rules/rules.json" ".opencode/rules/rules.json" "rules/rules.json"
149
- update_file "$TEMP_DIR/rules/validation.sh" ".opencode/rules/validation.sh" "rules/validation.sh"
150
-
151
- # Update agent templates (but NOT contract.json — preserve state)
152
- for agent in orchestrator planner task-manager code-reviewer learner fixer; do
153
- update_file "$TEMP_DIR/templates/agents/$agent.md" ".opencode/agents/$agent.md" "agents/$agent.md"
154
- done
155
-
156
- # Update superpowers contract template
157
- update_file "$TEMP_DIR/templates/superpowers-contract.json" ".opencode/templates/superpowers-contract.json" "superpowers-contract.json"
158
-
159
- # --- Restore contract state ---
160
- if [ "$DRY_RUN" = false ] && [ -f "$STATE_BACKUP" ]; then
161
- STATE_BACKUP="$STATE_BACKUP" LATEST_VERSION="$LATEST_VERSION" $PYTHON_CMD -c "
162
- import os, json
163
- with open('.opencode/orchestration/contract.json') as f:
164
- contract = json.load(f)
165
- with open(os.environ['STATE_BACKUP']) as f:
166
- state = json.load(f)
167
- # Merge preserved state back into new contract
168
- for key, val in state.items():
169
- if val: # only overwrite if backup has data
170
- contract[key] = val
171
- # Update contract_version to latest
172
- contract['contract_version'] = os.environ['LATEST_VERSION']
173
- with open('.opencode/orchestration/contract.json', 'w') as f:
174
- json.dump(contract, f, indent=2)
175
- " 2>/dev/null && echo " ✅ Contract state restored" || echo " ⚠️ Contract state restore failed"
176
- fi
177
-
178
- # --- Cleanup ---
179
- rm -rf "$TEMP_DIR" "$STATE_BACKUP"
180
-
181
- # --- Summary ---
182
- echo ""
183
- if [ "$DRY_RUN" = true ]; then
184
- echo -e "${YELLOW}[opencode-kit] 🔄 Dry run complete. $UPDATES files would be updated.${NC}"
185
- else
186
- echo -e "${GREEN}[opencode-kit] ✅ Update complete. $UPDATES files updated.${NC}"
187
- echo " Run .opencode/src/verify.sh to verify installation."
188
- fi
package/src/verify.sh DELETED
@@ -1,67 +0,0 @@
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" ".opencode/src/doctor.sh" ".opencode/src/status.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"