@aryaminus/controlkeel-opencode 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.
- package/.opencode/agents/controlkeel-operator.md +25 -0
- package/.opencode/commands/controlkeel-annotate.md +8 -0
- package/.opencode/commands/controlkeel-last.md +8 -0
- package/.opencode/commands/controlkeel-review.md +14 -0
- package/.opencode/commands/controlkeel-submit-plan.md +12 -0
- package/.opencode/mcp.json +12 -0
- package/.opencode/plugins/controlkeel-governance.ts +85 -0
- package/AGENTS.md +25 -0
- package/README.md +22 -0
- package/index.js +92 -0
- package/package.json +36 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: ControlKeel governed code review agent — validates changes against security, budget, and compliance policies.
|
|
3
|
+
model: anthropic/claude-sonnet-4-5
|
|
4
|
+
tools:
|
|
5
|
+
write: false
|
|
6
|
+
edit: false
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You are the ControlKeel governance operator. Your role is to review code changes
|
|
10
|
+
and validate them against the project's security, budget, and compliance policies.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Use the `ck-validate` tool to run governance checks before providing feedback.
|
|
15
|
+
2. Report findings by severity: critical > high > medium > low.
|
|
16
|
+
3. Never approve changes that have unresolved critical or high findings.
|
|
17
|
+
4. Reference specific policy rules when flagging issues.
|
|
18
|
+
5. Summarize budget impact if token/cost tracking is enabled.
|
|
19
|
+
|
|
20
|
+
## Available MCP Tools
|
|
21
|
+
|
|
22
|
+
- `ck_validate` — Run full governance validation
|
|
23
|
+
- `ck_budget` — Check remaining budget and spend history
|
|
24
|
+
- `ck_findings` — List open findings for the current session
|
|
25
|
+
- `ck_approve` — Approve a finding (requires operator confirmation)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# /controlkeel-annotate <file>
|
|
2
|
+
|
|
3
|
+
Use this command in OpenCode when a specific file needs focused human notes.
|
|
4
|
+
|
|
5
|
+
Suggested flow:
|
|
6
|
+
1. Save the file path, risks, and requested annotation context to `.opencode/annotate.md`.
|
|
7
|
+
2. Run `controlkeel review plan submit --title "File annotation review" --body-file .opencode/annotate.md --submitted-by opencode --json`
|
|
8
|
+
3. Wait for the response before applying risky edits.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# /controlkeel-last
|
|
2
|
+
|
|
3
|
+
Use this command in OpenCode to reopen the latest ControlKeel review you are tracking for the current task.
|
|
4
|
+
|
|
5
|
+
Suggested flow:
|
|
6
|
+
1. Read the last stored review id from your notes or prior command output.
|
|
7
|
+
2. Run `controlkeel review plan open --id <review_id> --json`
|
|
8
|
+
3. If the review is still pending, run `controlkeel review plan wait --id <review_id> --json`
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Run ControlKeel governance review on the current project
|
|
3
|
+
agent: controlkeel-operator
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Review the current project for governance compliance. Run `ck-validate` to check
|
|
7
|
+
for security findings, budget status, and proof readiness. Summarize the results
|
|
8
|
+
and highlight any blockers that need attention before shipping.
|
|
9
|
+
|
|
10
|
+
Focus on:
|
|
11
|
+
1. Open findings by severity
|
|
12
|
+
2. Budget remaining vs. spent
|
|
13
|
+
3. Proof coverage for completed tasks
|
|
14
|
+
4. Any policy violations that block release
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Submit the current plan to ControlKeel browser review and wait for approval
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Save the current plan to a markdown file, then submit it through ControlKeel.
|
|
6
|
+
|
|
7
|
+
Recommended flow:
|
|
8
|
+
1. Save the plan to `.opencode/review-plan.md`
|
|
9
|
+
2. Run `controlkeel review plan submit --body-file .opencode/review-plan.md --submitted-by opencode --json`
|
|
10
|
+
3. Read the returned `review.id` and `browser_url`
|
|
11
|
+
4. Wait with `controlkeel review plan wait --id <review_id> --json`
|
|
12
|
+
4. Do not execute until the review is approved
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Plugin } from "@opencode-ai/plugin"
|
|
2
|
+
import { tool } from "@opencode-ai/plugin"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ControlKeel Review Bridge for OpenCode
|
|
6
|
+
*
|
|
7
|
+
* Host-specific adapter behavior:
|
|
8
|
+
* - injects a submit_plan review tool for planning agents
|
|
9
|
+
* - suppresses plan_exit in favor of ControlKeel browser review
|
|
10
|
+
* - keeps the review tool primary-agent only by default
|
|
11
|
+
* - routes plan submission and wait decisions through the CK CLI
|
|
12
|
+
*/
|
|
13
|
+
export const ControlKeelGovernance: Plugin = async ({ project, client, $, directory }) => {
|
|
14
|
+
const parseJson = (output: string) => {
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(output)
|
|
17
|
+
} catch (_error) {
|
|
18
|
+
throw new Error(`ControlKeel returned invalid JSON: ${output}`)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const submitPlan = async (body: string, submittedBy: string) => {
|
|
23
|
+
const result = await $`controlkeel review plan submit --stdin --submitted-by ${submittedBy} --json`
|
|
24
|
+
.text(body)
|
|
25
|
+
const submitPayload = parseJson(result)
|
|
26
|
+
const reviewId = submitPayload?.review?.id
|
|
27
|
+
if (!reviewId) {
|
|
28
|
+
throw new Error("ControlKeel did not return a review id")
|
|
29
|
+
}
|
|
30
|
+
const waitPayload = parseJson(await $`controlkeel review plan wait --id ${reviewId} --json`)
|
|
31
|
+
return {
|
|
32
|
+
reviewId,
|
|
33
|
+
submitPayload,
|
|
34
|
+
waitPayload,
|
|
35
|
+
browserUrl: submitPayload?.browser_url,
|
|
36
|
+
status: waitPayload?.review?.status,
|
|
37
|
+
feedbackNotes: waitPayload?.review?.feedback_notes ?? null,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
"shell.env": async (_input, output) => {
|
|
43
|
+
output.env.CONTROLKEEL_PROJECT_ROOT = directory
|
|
44
|
+
output.env.CONTROLKEEL_AGENT_ID = "opencode"
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
config: async (config) => {
|
|
48
|
+
const primaryTools = config.experimental?.primary_tools ?? []
|
|
49
|
+
if (!primaryTools.includes("submit_plan")) {
|
|
50
|
+
config.experimental = {
|
|
51
|
+
...config.experimental,
|
|
52
|
+
primary_tools: [...primaryTools, "submit_plan"],
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
"tool.definition": async (input, output) => {
|
|
58
|
+
if (input.toolID === "plan_exit") {
|
|
59
|
+
output.description =
|
|
60
|
+
"Do not call this tool. Use submit_plan so ControlKeel can collect approval in the browser review flow."
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
"experimental.chat.system.transform": async (_input, output) => {
|
|
65
|
+
output.system.push(
|
|
66
|
+
"Use submit_plan when you are ready for human review. Do not proceed with implementation until ControlKeel approves the plan."
|
|
67
|
+
)
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
tool: {
|
|
71
|
+
"submit_plan": tool({
|
|
72
|
+
description:
|
|
73
|
+
"Submit a plan to ControlKeel for browser review. The tool waits for approval before execution continues.",
|
|
74
|
+
args: {
|
|
75
|
+
plan: tool.schema.string().describe("Markdown plan body to submit for review."),
|
|
76
|
+
title: tool.schema.string().optional(),
|
|
77
|
+
},
|
|
78
|
+
async execute(args) {
|
|
79
|
+
const result = await submitPlan(args.plan, "opencode")
|
|
80
|
+
return JSON.stringify(result, null, 2)
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
}
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# ControlKeel Companion Instructions
|
|
2
|
+
|
|
3
|
+
This project is governed by ControlKeel. Prefer the ControlKeel MCP server for validation, findings, budgets, proof context, and routing.
|
|
4
|
+
|
|
5
|
+
Project root: `.`
|
|
6
|
+
Target: `opencode`
|
|
7
|
+
|
|
8
|
+
Required workflow:
|
|
9
|
+
1. Call `ck_context` at the start of a task.
|
|
10
|
+
2. Call `ck_validate` before writing code, config, shell, or deploy content.
|
|
11
|
+
3. Submit plans or approval packets with `ck_review_submit` and check `ck_review_status` before execution.
|
|
12
|
+
4. Record any human-review issue with `ck_finding`.
|
|
13
|
+
5. Check `ck_budget` before expensive model or multi-agent work.
|
|
14
|
+
6. Use `ck_route`, `ck_skill_list`, and `ck_skill_load` to delegate or activate specialized CK workflows.
|
|
15
|
+
|
|
16
|
+
Install ControlKeel:
|
|
17
|
+
- Homebrew: `brew tap aryaminus/controlkeel && brew install controlkeel`
|
|
18
|
+
- npm bootstrap: `npm i -g @aryaminus/controlkeel`
|
|
19
|
+
- Unix installer: `curl -fsSL https://github.com/aryaminus/controlkeel/releases/latest/download/install.sh | sh`
|
|
20
|
+
- Raw GitHub shell installer: `curl -fsSL https://raw.githubusercontent.com/aryaminus/controlkeel/main/scripts/install.sh | sh`
|
|
21
|
+
- PowerShell installer: `irm https://github.com/aryaminus/controlkeel/releases/latest/download/install.ps1 | iex`
|
|
22
|
+
- Raw GitHub PowerShell installer: `irm https://raw.githubusercontent.com/aryaminus/controlkeel/main/scripts/install.ps1 | iex`
|
|
23
|
+
- GitHub Releases: `https://github.com/aryaminus/controlkeel/releases`
|
|
24
|
+
|
|
25
|
+
ControlKeel auto-bootstraps project binding on first use. Provider access resolves through agent bridge, CK-owned provider profiles, local Ollama, then heuristic fallback.
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# ControlKeel OpenCode plugin
|
|
2
|
+
|
|
3
|
+
Direct install:
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"plugin": ["@aryaminus/controlkeel-opencode"]
|
|
8
|
+
}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This npm package exposes the ControlKeel OpenCode governance plugin entrypoint.
|
|
12
|
+
For the full repo-local experience with commands, agents, and MCP config, also run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
controlkeel attach opencode
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The repo-local command bundle now includes:
|
|
19
|
+
- `/controlkeel-review`
|
|
20
|
+
- `/controlkeel-submit-plan`
|
|
21
|
+
- `/controlkeel-annotate`
|
|
22
|
+
- `/controlkeel-last`
|
package/index.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Published OpenCode package entrypoint for ControlKeel.
|
|
3
|
+
*
|
|
4
|
+
* This mirrors the repo-local plugin in `.opencode/plugins/controlkeel-governance.ts`
|
|
5
|
+
* but ships as plain JavaScript for npm-based installs.
|
|
6
|
+
*/
|
|
7
|
+
export const ControlKeelGovernance = async ({ $, directory }) => {
|
|
8
|
+
const parseJson = (output) => {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(output)
|
|
11
|
+
} catch (_error) {
|
|
12
|
+
throw new Error(`ControlKeel returned invalid JSON: ${output}`)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const submitPlan = async (body, submittedBy) => {
|
|
17
|
+
const result = await $`controlkeel review plan submit --stdin --submitted-by ${submittedBy} --json`
|
|
18
|
+
.text(body)
|
|
19
|
+
const submitPayload = parseJson(result)
|
|
20
|
+
const reviewId = submitPayload?.review?.id
|
|
21
|
+
if (!reviewId) {
|
|
22
|
+
throw new Error("ControlKeel did not return a review id")
|
|
23
|
+
}
|
|
24
|
+
const waitPayload = parseJson(await $`controlkeel review plan wait --id ${reviewId} --json`)
|
|
25
|
+
return {
|
|
26
|
+
reviewId,
|
|
27
|
+
submitPayload,
|
|
28
|
+
waitPayload,
|
|
29
|
+
browserUrl: submitPayload?.browser_url,
|
|
30
|
+
status: waitPayload?.review?.status,
|
|
31
|
+
feedbackNotes: waitPayload?.review?.feedback_notes ?? null,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
"shell.env": async (_input, output) => {
|
|
37
|
+
output.env.CONTROLKEEL_PROJECT_ROOT = directory
|
|
38
|
+
output.env.CONTROLKEEL_AGENT_ID = "opencode"
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
config: async (config) => {
|
|
42
|
+
const primaryTools = config.experimental?.primary_tools ?? []
|
|
43
|
+
if (!primaryTools.includes("submit_plan")) {
|
|
44
|
+
config.experimental = {
|
|
45
|
+
...config.experimental,
|
|
46
|
+
primary_tools: [...primaryTools, "submit_plan"],
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
"tool.definition": async (input, output) => {
|
|
52
|
+
if (input.toolID === "plan_exit") {
|
|
53
|
+
output.description =
|
|
54
|
+
"Do not call this tool. Use submit_plan so ControlKeel can collect approval in the browser review flow."
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
"tool.execute": async (input, output) => {
|
|
59
|
+
if (input.toolID !== "submit_plan") {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const planBody = typeof input.args?.plan === "string" ? input.args.plan : ""
|
|
64
|
+
const review = await submitPlan(planBody, "opencode")
|
|
65
|
+
output.metadata = {
|
|
66
|
+
reviewId: review.reviewId,
|
|
67
|
+
browserUrl: review.browserUrl,
|
|
68
|
+
status: review.status,
|
|
69
|
+
feedbackNotes: review.feedbackNotes,
|
|
70
|
+
}
|
|
71
|
+
output.result = JSON.stringify(output.metadata, null, 2)
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
tools: async () => ({
|
|
75
|
+
submit_plan: {
|
|
76
|
+
description: "Submit the current plan to ControlKeel and wait for browser review approval.",
|
|
77
|
+
parameters: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: {
|
|
80
|
+
plan: {
|
|
81
|
+
type: "string",
|
|
82
|
+
description: "Markdown plan body to submit to ControlKeel review.",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
required: ["plan"],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default ControlKeelGovernance
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bugs": {
|
|
3
|
+
"url": "https://github.com/aryaminus/controlkeel/issues"
|
|
4
|
+
},
|
|
5
|
+
"description": "ControlKeel OpenCode adapter bundle",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.js",
|
|
8
|
+
"./plugin": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
".opencode",
|
|
12
|
+
"AGENTS.md",
|
|
13
|
+
"README.md",
|
|
14
|
+
"index.js"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/aryaminus/controlkeel",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"controlkeel",
|
|
19
|
+
"opencode",
|
|
20
|
+
"plugin",
|
|
21
|
+
"governance",
|
|
22
|
+
"mcp"
|
|
23
|
+
],
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"main": "./index.js",
|
|
26
|
+
"name": "@aryaminus/controlkeel-opencode",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/aryaminus/controlkeel.git"
|
|
33
|
+
},
|
|
34
|
+
"type": "module",
|
|
35
|
+
"version": "0.1.0"
|
|
36
|
+
}
|