@ikieaneh/opencode-kit 0.5.8 → 0.6.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/.claude-plugin/plugin.json +1 -1
- package/.opencode/plugins/opencode-kit.js +0 -1
- package/README.md +97 -26
- package/docs/guides/contract-protocol.md +67 -0
- package/docs/guides/scoring-pipeline.md +60 -0
- package/docs/guides/troubleshooting.md +78 -0
- package/package.json +3 -3
- package/rules/rules.json +1 -1
- package/src/adr.sh +26 -15
- package/src/analytics.sh +1 -1
- package/src/diff.sh +1 -1
- package/src/init.sh +3 -3
- package/src/status.sh +5 -7
- package/src/telemetry.sh +1 -1
- package/templates/contract.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-kit",
|
|
3
3
|
"description": "Standardized orchestration framework — contract-based, rules-enforced, zero-touch agent workflow",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rizki Rachman",
|
|
7
7
|
"url": "https://github.com/RizkiRachman"
|
|
@@ -184,7 +184,6 @@ export const OpencodeKitPlugin = async ({ client, directory }) => {
|
|
|
184
184
|
|
|
185
185
|
// Register user project skills FIRST (higher priority)
|
|
186
186
|
const userSkillsDir = path.join(projectDir, '.opencode/skills');
|
|
187
|
-
const userSkillsDir = path.join(projectDir, '.opencode/skills');
|
|
188
187
|
if (fs.existsSync(userSkillsDir) && !config.skills.paths.includes(userSkillsDir)) {
|
|
189
188
|
config.skills.paths.push(userSkillsDir);
|
|
190
189
|
log('info', `Registered user skills: ${userSkillsDir}`);
|
package/README.md
CHANGED
|
@@ -59,25 +59,67 @@
|
|
|
59
59
|
<!-- ABOUT THE PROJECT -->
|
|
60
60
|
## About The Project
|
|
61
61
|
|
|
62
|
-
`opencode-kit` is a
|
|
62
|
+
`opencode-kit` is a **workflow enforcement framework** for AI coding agents. It ensures agents follow a structured process — plan, build, review, learn — instead of jumping straight to implementation.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
### The Problem
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
AI agents (Claude, Copilot, etc.) are powerful but **unpredictable**. When given a task, they often:
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
- Skip project conventions and jump directly to writing code
|
|
69
|
+
- Ignore shared state — each session starts from scratch
|
|
70
|
+
- Bypass quality gates — no review, no scoring, no learning
|
|
71
|
+
- Use different approaches on every run — inconsistent results
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
Traditional frameworks try to fix this with **prose in .md files** ("load the contract before any tool call"). But agents routinely ignore prose because there's no enforcement — it's a suggestion, not a requirement.
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
2. **`contract.json`** — shared state machine every agent MUST read/write (local or global)
|
|
74
|
-
3. **`rules.json`** — machine-readable rules with CRITICAL/HIGH severity
|
|
75
|
-
4. **3 auto-registered skills** — `orchestration-template`, `scoring-pipeline`, `adr-generator`
|
|
76
|
-
5. **Config resolution** — `.opencode/` → `~/.config/opencode-kit/` → plugin defaults
|
|
75
|
+
### The Solution
|
|
77
76
|
|
|
78
|
-
|
|
77
|
+
`opencode-kit` replaces prose conventions with **machine-readable enforcement**:
|
|
79
78
|
|
|
80
|
-
|
|
79
|
+
| Instead of ... | opencode-kit uses ... |
|
|
80
|
+
|:---------------|:----------------------|
|
|
81
|
+
| "read the state file" | `contract.json` — a JSON state machine agents MUST read/write |
|
|
82
|
+
| "follow the rules" | `rules.json` — CRITICAL rules BLOCK agents, HIGH rules FLAG them |
|
|
83
|
+
| "check before editing" | `preflight.sh` — an enforcement gate that fails if rules aren't met |
|
|
84
|
+
| "review your work" | **Scoring pipeline** — every output is scored (≥70 PASS, <50 BLOCK) |
|
|
85
|
+
| "remember what you learned" | `postflight.sh` — auto-persists state + telemetry + lessons learned |
|
|
86
|
+
|
|
87
|
+
The result: **zero-touch agent workflow**. Set a goal, and the system self-executes through Plan → Build → Review → Learn, pausing only when BLOCKED.
|
|
88
|
+
|
|
89
|
+
### How It Works
|
|
90
|
+
|
|
91
|
+
As an OpenCode **plugin**, `opencode-kit` injects enforcement into every session globally:
|
|
92
|
+
|
|
93
|
+
1. **Plugin bootstrap** — every session auto-loads the orchestration contract before any work
|
|
94
|
+
2. **Pre-flight gate** — validates branch, contract state, and rule compliance. BLOCKs on CRITICAL violations
|
|
95
|
+
3. **Contract protocol** — shared state machine (`contract.json`) tracks phase, decisions, scores, telemetry
|
|
96
|
+
4. **Scoring pipeline** — every subagent output scored. ≥70 PASS, 50-69 RETRY, <50 BLOCKED
|
|
97
|
+
5. **ADR logging** — every architectural decision recorded in `decisions.adr_log[]`
|
|
98
|
+
6. **Extension model** — project-specific skills in `.opencode/skills/` override plugin defaults
|
|
99
|
+
|
|
100
|
+
### The 9 Built-in Skills
|
|
101
|
+
|
|
102
|
+
| Skill | Purpose |
|
|
103
|
+
|-------|---------|
|
|
104
|
+
| `orchestration-template` | Contract protocol, state machine, persistence rules |
|
|
105
|
+
| `scoring-pipeline` | Tier 1 rule checks + Tier 2 LLM judge + verdict |
|
|
106
|
+
| `adr-generator` | Architecture Decision Record format and auto-ID |
|
|
107
|
+
| `qa-expert` | Test standards, edge cases, coverage goals |
|
|
108
|
+
| `system-analyst` | Impact analysis, execution tracing, architecture checks |
|
|
109
|
+
| `token-optimize` | Efficient reading, batching, and delegation |
|
|
110
|
+
| `verification-before-completion` | Quality gates — formatting, compile, test, verify |
|
|
111
|
+
| `learner` | Post-execution learning, memory persistence |
|
|
112
|
+
| *(extensible)* | Create your own skills in `.opencode/skills/` |
|
|
113
|
+
|
|
114
|
+
### Built for Cost-Efficient Models
|
|
115
|
+
|
|
116
|
+
`opencode-kit` was designed for teams using **cost-optimized models** (DeepSeek V4 Flash, Gemini Flash, GPT-4o Mini, etc.) who want to compete with premium models through **process rigor**, not raw intelligence. The scoring pipeline and pre-flight enforcement create a quality floor that cheap models can meet through architecture, not model power.
|
|
117
|
+
|
|
118
|
+
### Platform Support
|
|
119
|
+
|
|
120
|
+
- **macOS M-Series** (Apple Silicon) — primary development target
|
|
121
|
+
- **Linux** (Ubuntu) — CI-verified via GitHub Actions
|
|
122
|
+
- **Any OpenCode-compatible environment** with `lean-ctx`, `gitnexus`, `graphify`
|
|
81
123
|
|
|
82
124
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
83
125
|
|
|
@@ -122,6 +164,17 @@ node --version # ≥ 18
|
|
|
122
164
|
git --version # any recent version
|
|
123
165
|
```
|
|
124
166
|
|
|
167
|
+
### Documentation Guides
|
|
168
|
+
|
|
169
|
+
| Guide | Description |
|
|
170
|
+
|-------|-------------|
|
|
171
|
+
| [Contract Protocol](docs/guides/contract-protocol.md) | State machine, fields, resolution order |
|
|
172
|
+
| [Scoring Pipeline](docs/guides/scoring-pipeline.md) | Tier 1 + Tier 2 + verdict |
|
|
173
|
+
| [Troubleshooting](docs/guides/troubleshooting.md) | Common issues and solutions |
|
|
174
|
+
| [Quickstart](docs/examples/QUICKSTART.md) | 6-step setup from scratch |
|
|
175
|
+
| [Extension Skills](docs/examples/extension-skill-template.md) | Create project-specific skills |
|
|
176
|
+
| [Model Configs](docs/examples/model-configs.md) | Provider configuration examples |
|
|
177
|
+
|
|
125
178
|
### Installation
|
|
126
179
|
|
|
127
180
|
#### Option 1: Install as plugin (recommended)
|
|
@@ -252,24 +305,42 @@ Once installed, run these from the project root:
|
|
|
252
305
|
opencode-kit/
|
|
253
306
|
├── rules/
|
|
254
307
|
│ ├── rules.json ← Machine-enforceable rules (CRITICAL/HIGH/state machine)
|
|
255
|
-
│ └── validation.sh ← Validates agent actions against rules
|
|
308
|
+
│ └── validation.sh ← Validates agent actions against rules
|
|
256
309
|
├── src/
|
|
257
310
|
│ ├── init.sh ← Scaffold into target project
|
|
258
311
|
│ ├── preflight.sh ← Envelope load gate (zero deps, fails if rules violated)
|
|
259
|
-
│ ├── postflight.sh ← Auto-persist + scoring pipeline
|
|
260
|
-
│
|
|
312
|
+
│ ├── postflight.sh ← Auto-persist + scoring pipeline + contract migration
|
|
313
|
+
│ ├── doctor.sh ← Diagnostic command
|
|
314
|
+
│ ├── status.sh ← Dashboard view
|
|
315
|
+
│ ├── diff.sh ← Compare contract across branches
|
|
316
|
+
│ ├── analytics.sh ← Telemetry aggregation
|
|
317
|
+
│ ├── adr.sh ← ADR auto-generator
|
|
318
|
+
│ ├── telemetry.sh ← Phase telemetry viewer
|
|
319
|
+
│ ├── new-skill.sh ← Skill template generator
|
|
320
|
+
│ ├── update.sh ← Pull latest from GitHub
|
|
321
|
+
│ ├── verify.sh ← Installation health check
|
|
322
|
+
│ ├── platform.sh ← Cross-platform detection
|
|
323
|
+
│ ├── global-config.sh ← Config resolution chain
|
|
324
|
+
│ └── cli.js ← --version / --help
|
|
325
|
+
├── skills/ ← 9 auto-registered skills
|
|
261
326
|
├── templates/
|
|
262
|
-
│ ├── contract.json ← Shared state contract
|
|
263
|
-
│ ├──
|
|
264
|
-
│
|
|
265
|
-
│
|
|
266
|
-
|
|
267
|
-
│
|
|
268
|
-
│
|
|
269
|
-
│
|
|
270
|
-
|
|
271
|
-
├──
|
|
272
|
-
|
|
327
|
+
│ ├── contract.json ← Shared state contract
|
|
328
|
+
│ ├── opencode-kit.schema.json ← Agent config schema
|
|
329
|
+
│ ├── judge-prompt.md ← LLM judge prompt template
|
|
330
|
+
│ └── agents/ ← 6 agent .md templates
|
|
331
|
+
├── docs/
|
|
332
|
+
│ ├── guides/ ← Usage guides (contract, scoring, troubleshooting)
|
|
333
|
+
│ ├── examples/ ← Quickstart, model configs, extension skills
|
|
334
|
+
│ └── plans/ ← Implementation plans
|
|
335
|
+
├── test/ ← Integration + E2E tests (16 total)
|
|
336
|
+
├── .github/workflows/ ← CI (ShellCheck + scaffold + tests)
|
|
337
|
+
├── .opencode/plugins/ ← Plugin entry point
|
|
338
|
+
├── .claude-plugin/ ← Plugin metadata
|
|
339
|
+
├── package.json ← npm publish
|
|
340
|
+
├── CHANGELOG.md
|
|
341
|
+
├── CONTRIBUTING.md
|
|
342
|
+
├── RELEASE.md
|
|
343
|
+
└── ROADMAP.md
|
|
273
344
|
```
|
|
274
345
|
|
|
275
346
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Contract Protocol
|
|
2
|
+
|
|
3
|
+
The orchestrator contract (`contract.json`) is the single source of truth for every agent session.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
- Tracks **state** — what phase the workflow is in (INIT → PLAN → ... → COMPLETE)
|
|
8
|
+
- Stores **requirements** — the goal, acceptance criteria, and constraints
|
|
9
|
+
- Logs **decisions** — Architecture Decision Records (ADRs)
|
|
10
|
+
- Records **scores** — quality metrics from the scoring pipeline
|
|
11
|
+
- Captures **telemetry** — elapsed time, phases completed, agents used
|
|
12
|
+
|
|
13
|
+
## State Machine
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
INIT → PLAN → PLAN_SCORED → EXECUTE → EXECUTE_SCORED → REVIEW → REVIEW_SCORED → COMPLETE
|
|
17
|
+
↘
|
|
18
|
+
BLOCKED (any phase) → user intervention → retry
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Transition rules:**
|
|
22
|
+
- Each phase transition requires score ≥ 70
|
|
23
|
+
- Score < 50 → BLOCKED
|
|
24
|
+
- Max 3 retry attempts before escalation
|
|
25
|
+
|
|
26
|
+
## Key Fields
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"state": "INIT",
|
|
31
|
+
"contract_version": "0.5.8",
|
|
32
|
+
"requirements": {
|
|
33
|
+
"goal": "What we're building",
|
|
34
|
+
"acceptance_criteria": ["testable condition 1"],
|
|
35
|
+
"constraints": ["must not..."]
|
|
36
|
+
},
|
|
37
|
+
"governance": {
|
|
38
|
+
"active_agent": "orchestrator",
|
|
39
|
+
"current_guidance": "Instructions for this session",
|
|
40
|
+
"extension_skills": ["java-conventions"],
|
|
41
|
+
"permissions": { "do": [], "dont": ["push to main"] }
|
|
42
|
+
},
|
|
43
|
+
"decisions": {
|
|
44
|
+
"adr_log": [
|
|
45
|
+
{ "id": "ADR-001", "date": "2026-06-11", "title": "Use contract protocol", ... }
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"score": {
|
|
49
|
+
"combined": 85,
|
|
50
|
+
"verdict": "PASS"
|
|
51
|
+
},
|
|
52
|
+
"metrics": {
|
|
53
|
+
"phases_completed": ["INIT", "PLAN", "PLAN_SCORED"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Resolution Order
|
|
59
|
+
|
|
60
|
+
1. `.opencode/orchestration/contract.json` — project override
|
|
61
|
+
2. `~/.config/opencode-kit/contract.json` — global defaults
|
|
62
|
+
3. Plugin `templates/contract.json` — shipped defaults
|
|
63
|
+
|
|
64
|
+
## CLI
|
|
65
|
+
|
|
66
|
+
View contract state: `bash .opencode/src/status.sh`
|
|
67
|
+
Compare across branches: `bash .opencode/src/diff.sh [branch1] [branch2]`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Scoring Pipeline
|
|
2
|
+
|
|
3
|
+
Every subagent output is scored before the next phase begins.
|
|
4
|
+
|
|
5
|
+
## Tier 1 — Rule Checks
|
|
6
|
+
|
|
7
|
+
Automatic checks run by the orchestrator. Start at 100, deduct per violation:
|
|
8
|
+
|
|
9
|
+
| Check | Deduction |
|
|
10
|
+
|-------|:---------:|
|
|
11
|
+
| Schema valid (required fields present) | -15 |
|
|
12
|
+
| Permissions violated | -40 |
|
|
13
|
+
| Blast radius HIGH/CRITICAL | -40 |
|
|
14
|
+
| Writing order wrong | -15 |
|
|
15
|
+
| Fields missing | -15 |
|
|
16
|
+
|
|
17
|
+
If subtotal < 70 → skip Tier 2, use subtotal as combined score.
|
|
18
|
+
|
|
19
|
+
## Tier 2 — LLM Judge
|
|
20
|
+
|
|
21
|
+
If Tier 1 score ≥ 70, the orchestrator runs a judge via `subtask()`.
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"score": 85,
|
|
26
|
+
"rationale": "All requirements met. Writing order correct.",
|
|
27
|
+
"missing_items": ["Test for null boundary case"]
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Dimensions:**
|
|
32
|
+
| Dimension | Max | What it evaluates |
|
|
33
|
+
|-----------|:---:|-------------------|
|
|
34
|
+
| Requirements | 40 | Does output satisfy goal + acceptance criteria? |
|
|
35
|
+
| Governance | 30 | Follows rules.json + writing order? |
|
|
36
|
+
| Completeness | 20 | All files created? Edge cases documented? |
|
|
37
|
+
| Edge cases | 10 | Nulls, errors, boundaries covered? |
|
|
38
|
+
|
|
39
|
+
## Tier 3 — Verdict
|
|
40
|
+
|
|
41
|
+
| Combined Score | Verdict | Action |
|
|
42
|
+
|:--------------:|:-------:|--------|
|
|
43
|
+
| ≥ 70 | **PASS** | Advance to next phase |
|
|
44
|
+
| 50–69 | **RETRY** | Increment retry count, re-delegate |
|
|
45
|
+
| < 50 | **BLOCKED** | Escalate to user |
|
|
46
|
+
|
|
47
|
+
## Configuration
|
|
48
|
+
|
|
49
|
+
Thresholds and deductions are in `rules.json` → `scoring`:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"scoring": {
|
|
54
|
+
"tier1": { "schema_valid_deduction": 15, ... },
|
|
55
|
+
"thresholds": { "pass": 70, "retry": 50, "max_attempts": 3 }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Projects can override rule severity via `contract.json` → `validation.rule_overrides`.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
## Common Issues
|
|
4
|
+
|
|
5
|
+
### Plugin doesn't load
|
|
6
|
+
|
|
7
|
+
**Symptom**: Skills not available, contract not injected.
|
|
8
|
+
|
|
9
|
+
**Checks:**
|
|
10
|
+
1. Is `@ikieaneh/opencode-kit` in `opencode.json` plugin array? Must be **first**.
|
|
11
|
+
2. Is it installed? `ls node_modules/@ikieaneh/opencode-kit`
|
|
12
|
+
3. Is the plugin array syntax correct? `"plugin": ["@ikieaneh/opencode-kit"]`
|
|
13
|
+
|
|
14
|
+
### Agent jumps straight to implementation
|
|
15
|
+
|
|
16
|
+
**Symptom**: Agent starts working without loading contract.
|
|
17
|
+
|
|
18
|
+
**Fix:** The plugin's `messages.transform` hook injects the bootstrap. Make sure:
|
|
19
|
+
1. Plugin is first in the array
|
|
20
|
+
2. No other plugin overrides the same hook
|
|
21
|
+
3. Run `bash .opencode/src/doctor.sh` to verify
|
|
22
|
+
|
|
23
|
+
### Contract not found
|
|
24
|
+
|
|
25
|
+
**Symptom**: "Contract not found" error from preflight.
|
|
26
|
+
|
|
27
|
+
**Solution:**
|
|
28
|
+
```sh
|
|
29
|
+
bash .opencode/src/doctor.sh
|
|
30
|
+
# Or manually:
|
|
31
|
+
mkdir -p .opencode/orchestration
|
|
32
|
+
cp node_modules/@ikieaneh/opencode-kit/templates/contract.json .opencode/orchestration/contract.json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Score below threshold
|
|
36
|
+
|
|
37
|
+
**Symptom**: Workflow keeps retrying or gets blocked.
|
|
38
|
+
|
|
39
|
+
**Check:**
|
|
40
|
+
- Tier 1 violations (blast radius, permissions)
|
|
41
|
+
- Tier 2 judge feedback — read `judge.missing_items`
|
|
42
|
+
- Retry count — max 3 attempts before BLOCKED
|
|
43
|
+
|
|
44
|
+
### ShellCheck fails in CI
|
|
45
|
+
|
|
46
|
+
**Symptom**: GitHub Actions ShellCheck job fails.
|
|
47
|
+
|
|
48
|
+
**Fix:** Run locally:
|
|
49
|
+
```sh
|
|
50
|
+
shellcheck src/*.sh rules/*.sh
|
|
51
|
+
```
|
|
52
|
+
Look for SC1091 (source path) or SC2001 (sed style) — most are info-level.
|
|
53
|
+
|
|
54
|
+
### Scaffold test fails in CI
|
|
55
|
+
|
|
56
|
+
**Symptom**: init.sh exits with error.
|
|
57
|
+
|
|
58
|
+
**Check:**
|
|
59
|
+
- Are all `mkdir -p` paths created before `cp`?
|
|
60
|
+
- Run locally: `cd /tmp && git init && bash /path/to/init.sh`
|
|
61
|
+
|
|
62
|
+
### Custom skill not loading
|
|
63
|
+
|
|
64
|
+
**Symptom**: Skill referenced in opencode.json not available.
|
|
65
|
+
|
|
66
|
+
**Solution:**
|
|
67
|
+
1. Place skill at `.opencode/skills/<name>/SKILL.md`
|
|
68
|
+
2. Verify frontmatter has `description:` field
|
|
69
|
+
3. Verify SKILL.md starts with `---` (YAML frontmatter)
|
|
70
|
+
4. Run `bash .opencode/src/doctor.sh` to verify
|
|
71
|
+
|
|
72
|
+
## Diagnostics
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
bash .opencode/src/doctor.sh # Full health check
|
|
76
|
+
bash .opencode/src/status.sh # Dashboard view
|
|
77
|
+
bash .opencode/src/analytics.sh # Telemetry analysis
|
|
78
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikieaneh/opencode-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Standardized OpenCode orchestration framework — contract-based, rules-enforced, zero-touch agent workflow. Install as plugin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "RizkiRachman",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
|
-
"opencode-kit": "
|
|
15
|
+
"opencode-kit": "src/cli.js"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
".opencode/plugins/",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/RizkiRachman/opencode-kit"
|
|
42
|
+
"url": "git+https://github.com/RizkiRachman/opencode-kit.git"
|
|
43
43
|
},
|
|
44
44
|
"bugs": {
|
|
45
45
|
"url": "https://github.com/RizkiRachman/opencode-kit/issues"
|
package/rules/rules.json
CHANGED
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
"id": "WRITE_001",
|
|
91
|
-
"severity": "
|
|
91
|
+
"severity": "HIGH",
|
|
92
92
|
"description": "Agent MUST follow writing order: Port → Service → Mapper → Adapter → Constants → Events → Tests",
|
|
93
93
|
"condition": "writing_order_violation",
|
|
94
94
|
"action": "FLAG",
|
package/src/adr.sh
CHANGED
|
@@ -86,31 +86,42 @@ if [ -n "$DUP" ]; then
|
|
|
86
86
|
exit 0
|
|
87
87
|
fi
|
|
88
88
|
|
|
89
|
-
# --- Build ADR entry ---
|
|
90
|
-
#
|
|
91
|
-
|
|
89
|
+
# --- Build ADR entry via temp JSON file (avoids shell injection) ---
|
|
90
|
+
# Write ADR fields to temp file to avoid shell interpolation into Python
|
|
91
|
+
ADR_DATA=$(mktemp /tmp/opencode-adr-data-XXXXX.json)
|
|
92
|
+
cat > "$ADR_DATA" << ADRDATA
|
|
93
|
+
{
|
|
94
|
+
"title": "$TITLE",
|
|
95
|
+
"context": "$CONTEXT",
|
|
96
|
+
"decision": "$DECISION",
|
|
97
|
+
"alternatives": "$ALTERNATIVES",
|
|
98
|
+
"consequences": "$CONSEQUENCES"
|
|
99
|
+
}
|
|
100
|
+
ADRDATA
|
|
101
|
+
|
|
92
102
|
$PYTHON_CMD -c "
|
|
93
|
-
import json
|
|
103
|
+
import json
|
|
94
104
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
next_id = '$NEXT_ID'
|
|
105
|
+
with open('$ADR_DATA') as f:
|
|
106
|
+
data = json.load(f)
|
|
98
107
|
|
|
99
108
|
entry = {
|
|
100
|
-
'id':
|
|
101
|
-
'date':
|
|
102
|
-
'title': title,
|
|
103
|
-
'context': ''
|
|
104
|
-
'decision': ''
|
|
105
|
-
'alternatives': ''
|
|
106
|
-
'consequences': ''
|
|
109
|
+
'id': '$NEXT_ID',
|
|
110
|
+
'date': '$(date +%Y-%m-%d)',
|
|
111
|
+
'title': data['title'],
|
|
112
|
+
'context': data['context'],
|
|
113
|
+
'decision': data['decision'],
|
|
114
|
+
'alternatives': data['alternatives'],
|
|
115
|
+
'consequences': data['consequences']
|
|
107
116
|
}
|
|
108
117
|
|
|
109
118
|
with open('/tmp/opencode-adr-entry.json', 'w') as f:
|
|
110
|
-
|
|
119
|
+
json.dump(entry, f, indent=2)
|
|
111
120
|
print('Entry written')
|
|
112
121
|
"
|
|
113
122
|
|
|
123
|
+
rm -f "$ADR_DATA"
|
|
124
|
+
|
|
114
125
|
# --- Inject into contract.json ---
|
|
115
126
|
$PYTHON_CMD -c "
|
|
116
127
|
import json
|
package/src/analytics.sh
CHANGED
|
@@ -69,7 +69,7 @@ for p in phases:
|
|
|
69
69
|
frm = p.get('from', '?')
|
|
70
70
|
to = p.get('to', '?')
|
|
71
71
|
ms = p.get('elapsed_ms', 0)
|
|
72
|
-
bar = '
|
|
72
|
+
bar = '#' * max(1, int(ms / max(1, total_ms) * 30))
|
|
73
73
|
print(f' {frm:16s} → {to:16s} {ms/1000:6.1f}s {bar}')
|
|
74
74
|
|
|
75
75
|
# Cost estimate (rough: ~$0.15/1M tokens, ~1000 tok/s)
|
package/src/diff.sh
CHANGED
|
@@ -65,7 +65,7 @@ b = get_state('''$CONTRACT_B''') if '''$CONTRACT_B''' else None
|
|
|
65
65
|
|
|
66
66
|
if a and b:
|
|
67
67
|
print(f' Field $BRANCH_A $BRANCH_B')
|
|
68
|
-
print(f' {"
|
|
68
|
+
print(f' {"-"*50}')
|
|
69
69
|
for field in ['state', 'goal', 'score', 'version']:
|
|
70
70
|
va = str(a.get(field, '?'))[:20]
|
|
71
71
|
vb = str(b.get(field, '?'))[:20]
|
package/src/init.sh
CHANGED
|
@@ -180,9 +180,9 @@ echo ""
|
|
|
180
180
|
echo "[opencode-kit] Running verification..."
|
|
181
181
|
if "$KIT_DIR/src/verify.sh"; then
|
|
182
182
|
echo ""
|
|
183
|
-
echo -e "${GREEN}
|
|
184
|
-
echo -e "${GREEN} ✅ opencode-kit
|
|
185
|
-
echo -e "${GREEN}
|
|
183
|
+
echo -e "${GREEN}========================================${NC}"
|
|
184
|
+
echo -e "${GREEN} ✅ opencode-kit initialized (version: $(cat "$KIT_DIR/package.json" | grep '"version"' | head -1 | cut -d'"' -f4))${NC}"
|
|
185
|
+
echo -e "${GREEN}========================================${NC}"
|
|
186
186
|
echo ""
|
|
187
187
|
echo " Next steps:"
|
|
188
188
|
echo " 1. Set GOAL & SCOPE in .opencode/orchestration/contract.json"
|
package/src/status.sh
CHANGED
|
@@ -19,9 +19,9 @@ BOLD='\033[1m'
|
|
|
19
19
|
NC='\033[0m'
|
|
20
20
|
|
|
21
21
|
echo ""
|
|
22
|
-
echo -e "${CYAN}${BOLD}
|
|
23
|
-
echo -e "${CYAN}${BOLD}
|
|
24
|
-
echo -e "${CYAN}${BOLD}
|
|
22
|
+
echo -e "${CYAN}${BOLD}##══════════════════════════════════════════╗${NC}"
|
|
23
|
+
echo -e "${CYAN}${BOLD}# opencode-kit Dashboard #${NC}"
|
|
24
|
+
echo -e "${CYAN}${BOLD}##══════════════════════════════════════════╝${NC}"
|
|
25
25
|
echo ""
|
|
26
26
|
|
|
27
27
|
# === Contract State ===
|
|
@@ -94,10 +94,8 @@ with open('$RULES_FILE') as f:
|
|
|
94
94
|
rules = r.get('rules', [])
|
|
95
95
|
critical = [x for x in rules if x.get('severity') == 'CRITICAL']
|
|
96
96
|
high = [x for x in rules if x.get('severity') == 'HIGH']
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
mcps = list(r.get('required_mcps', {}).keys())
|
|
100
|
-
mcps = [m for m in mcps if m != 'description']
|
|
97
|
+
mcps = list(r.get('required_mcps', {}).keys())
|
|
98
|
+
mcps = [m for m in mcps if m != 'description']
|
|
101
99
|
print(f' {len(critical)} CRITICAL rules, {len(high)} HIGH rules')
|
|
102
100
|
if mcps:
|
|
103
101
|
print(f' Required MCPs: {\", \".join(mcps)}')
|
package/src/telemetry.sh
CHANGED
|
@@ -37,7 +37,7 @@ case "$MODE" in
|
|
|
37
37
|
FROM=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('from','?'))" 2>/dev/null)
|
|
38
38
|
TO=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('to','?'))" 2>/dev/null)
|
|
39
39
|
MS=$(echo "$line" | $PYTHON_CMD -c "import sys,json; d=json.load(sys.stdin); print(d.get('elapsed_ms',0))" 2>/dev/null)
|
|
40
|
-
printf " %-20s → %-20s %5.1fs\n" "$FROM" "$TO" "$(
|
|
40
|
+
printf " %-20s → %-20s %5.1fs\n" "$FROM" "$TO" "$($PYTHON_CMD -c "print($MS/1000)" 2>/dev/null || echo "0.0")"
|
|
41
41
|
done
|
|
42
42
|
else
|
|
43
43
|
echo -e "${YELLOW}No phase data yet.${NC}"
|
package/templates/contract.json
CHANGED