opencode-codegraph 0.1.5 → 0.1.6
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/CHANGELOG.md +6 -0
- package/README.md +14 -2
- package/package.json +1 -1
- package/src/index.ts +23 -1
- package/src/util.ts +77 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.6 - 2026-03-20
|
|
4
|
+
|
|
5
|
+
- add explicit pending post-commit summary when durable review trace is not yet available
|
|
6
|
+
- guide developers to `/status` instead of leaving post-commit review state ambiguous
|
|
7
|
+
- document pending-trace behavior in plugin and OpenCode workflow docs
|
|
8
|
+
|
|
3
9
|
## 0.1.5 - 2026-03-20
|
|
4
10
|
|
|
5
11
|
- add unified next-action summary to review-trace status output
|
package/README.md
CHANGED
|
@@ -45,7 +45,19 @@ Every conversation includes a project summary with file count, top complexity ho
|
|
|
45
45
|
|
|
46
46
|
### Post-Commit Updates
|
|
47
47
|
|
|
48
|
-
After `git commit`, the plugin triggers incremental CPG re-parsing via GoCPG and syncs the ChromaDB vector store. If durable review-trace artifacts exist for the new `HEAD`, the plugin also appends a
|
|
48
|
+
After `git commit`, the plugin triggers incremental CPG re-parsing via GoCPG and syncs the ChromaDB vector store. If durable review-trace artifacts exist for the new `HEAD`, the plugin also appends a structured post-commit block with:
|
|
49
|
+
|
|
50
|
+
- what changed in the review trace
|
|
51
|
+
- why it matters
|
|
52
|
+
- top recommendations
|
|
53
|
+
- one clear next action
|
|
54
|
+
|
|
55
|
+
If the durable review trace is not available yet, the plugin still appends a pending summary telling the developer to check `/status` instead of leaving the post-commit state ambiguous.
|
|
56
|
+
|
|
57
|
+
This means the post-commit UX now has two explicit states:
|
|
58
|
+
|
|
59
|
+
- trace ready -> structured summary with findings, recommendations, and next action
|
|
60
|
+
- trace pending/missing -> structured pending summary with deterministic follow-up
|
|
49
61
|
|
|
50
62
|
### Custom Tools
|
|
51
63
|
|
|
@@ -89,7 +101,7 @@ Place in `.opencode/commands/`:
|
|
|
89
101
|
| `experimental.chat.system.transform` | Inject project summary into system prompt |
|
|
90
102
|
| `chat.message` | Add CPG context for mentioned files |
|
|
91
103
|
| `chat.message` (edit intent) | Add pre-edit warnings for files likely to be modified |
|
|
92
|
-
| `tool.execute.after` | Trigger CPG update after git commit and append
|
|
104
|
+
| `tool.execute.after` | Trigger CPG update after git commit and append structured post-commit review summary |
|
|
93
105
|
| `permission.ask` | Auto-allow `codegraph_*` tools |
|
|
94
106
|
|
|
95
107
|
## License
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -17,12 +17,15 @@ import { CodeGraphAPI } from "./api"
|
|
|
17
17
|
import {
|
|
18
18
|
extractFileRefs,
|
|
19
19
|
fileNeedsRegistrationCheck,
|
|
20
|
+
formatPendingReviewTraceSummary,
|
|
20
21
|
formatReviewTraceSummary,
|
|
21
22
|
getHeadCommit,
|
|
22
23
|
isGitCommit,
|
|
23
24
|
messageSuggestsEditing,
|
|
24
25
|
recommendedNextActionFromReviewTrace,
|
|
25
26
|
readReviewTraceSnapshot,
|
|
27
|
+
whatChangedFromReviewTrace,
|
|
28
|
+
whyItMattersFromReviewTrace,
|
|
26
29
|
} from "./util"
|
|
27
30
|
|
|
28
31
|
const codegraphPlugin: Plugin = async (input) => {
|
|
@@ -114,13 +117,32 @@ const codegraphPlugin: Plugin = async (input) => {
|
|
|
114
117
|
codegraph_review_trace_recommendations:
|
|
115
118
|
traceSnapshot.review_recommendations?.slice(0, 3) || [],
|
|
116
119
|
codegraph_review_trace_next_action: recommendedNextActionFromReviewTrace(traceSnapshot),
|
|
120
|
+
codegraph_review_trace_what_changed: whatChangedFromReviewTrace(traceSnapshot),
|
|
121
|
+
codegraph_review_trace_why_it_matters: whyItMattersFromReviewTrace(traceSnapshot),
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
traceSummary = formatPendingReviewTraceSummary(commit)
|
|
125
|
+
output.metadata = {
|
|
126
|
+
...output.metadata,
|
|
127
|
+
codegraph_review_trace_status: "pending_or_missing",
|
|
128
|
+
codegraph_review_trace_phase: "awaiting_trace",
|
|
129
|
+
codegraph_review_trace_findings: null,
|
|
130
|
+
codegraph_review_trace_recommendations: [],
|
|
131
|
+
codegraph_review_trace_next_action:
|
|
132
|
+
"Wait briefly for review trace completion, then run /status to check the latest result.",
|
|
133
|
+
codegraph_review_trace_what_changed: [
|
|
134
|
+
`Incremental CPG update was triggered for ${commit.slice(0, 12)}.`,
|
|
135
|
+
"Durable review trace is not available yet or has not been written.",
|
|
136
|
+
],
|
|
137
|
+
codegraph_review_trace_why_it_matters:
|
|
138
|
+
"Post-commit findings and recommendations may still be pending, so the commit is not fully evaluated yet.",
|
|
117
139
|
}
|
|
118
140
|
}
|
|
119
141
|
}
|
|
120
142
|
|
|
121
143
|
// Notify user via output metadata (visible in OpenCode UI)
|
|
122
144
|
output.title = traceSummary
|
|
123
|
-
? "CodeGraph:
|
|
145
|
+
? "CodeGraph: post-commit review summary ready"
|
|
124
146
|
: "CodeGraph: CPG update triggered"
|
|
125
147
|
output.metadata = {
|
|
126
148
|
...output.metadata,
|
package/src/util.ts
CHANGED
|
@@ -129,18 +129,65 @@ export async function readReviewTraceSnapshot(
|
|
|
129
129
|
return null
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
export function formatPendingReviewTraceSummary(commit: string | null): string {
|
|
133
|
+
const commitLabel = commit ? ` for \`${commit.slice(0, 12)}\`` : ""
|
|
134
|
+
return [
|
|
135
|
+
"## CodeGraph Post-Commit Summary",
|
|
136
|
+
"",
|
|
137
|
+
"### What changed",
|
|
138
|
+
"",
|
|
139
|
+
`- Incremental CPG update was triggered${commitLabel}.`,
|
|
140
|
+
"- Durable review trace is not available yet or has not been written.",
|
|
141
|
+
"",
|
|
142
|
+
"### Why it matters",
|
|
143
|
+
"",
|
|
144
|
+
"- Post-commit findings and recommendations may still be pending, so the commit is not fully evaluated yet.",
|
|
145
|
+
"",
|
|
146
|
+
"### What to do now",
|
|
147
|
+
"",
|
|
148
|
+
"- Wait briefly for review trace completion, then run `/status` to check the latest result.",
|
|
149
|
+
].join("\n")
|
|
150
|
+
}
|
|
151
|
+
|
|
132
152
|
export function formatReviewTraceSummary(snapshot: ReviewTraceSnapshot): string | null {
|
|
133
|
-
const status = snapshot.status || "unknown"
|
|
134
|
-
const phase = snapshot.phase || "unknown"
|
|
135
|
-
const findingsCount = snapshot.review_findings_count
|
|
136
153
|
const recommendations = Array.isArray(snapshot.review_recommendations)
|
|
137
154
|
? snapshot.review_recommendations.filter(Boolean)
|
|
138
155
|
: []
|
|
156
|
+
const whatChanged = whatChangedFromReviewTrace(snapshot)
|
|
157
|
+
const whyItMatters = whyItMattersFromReviewTrace(snapshot)
|
|
158
|
+
const nextAction = recommendedNextActionFromReviewTrace(snapshot)
|
|
159
|
+
|
|
160
|
+
const lines = ["## CodeGraph Post-Commit Summary", ""]
|
|
139
161
|
|
|
140
|
-
|
|
162
|
+
if (whatChanged) {
|
|
163
|
+
lines.push("### What changed", "", ...whatChanged.map((item) => `- ${item}`), "")
|
|
164
|
+
}
|
|
141
165
|
|
|
142
|
-
if (
|
|
143
|
-
lines.push(`-
|
|
166
|
+
if (whyItMatters) {
|
|
167
|
+
lines.push("### Why it matters", "", `- ${whyItMatters}`, "")
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (recommendations.length) {
|
|
171
|
+
lines.push("### Top recommendations", "")
|
|
172
|
+
for (const recommendation of recommendations.slice(0, 3)) {
|
|
173
|
+
lines.push(`- ${recommendation}`)
|
|
174
|
+
}
|
|
175
|
+
lines.push("")
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
lines.push("### What to do now", "", `- ${nextAction}`)
|
|
179
|
+
|
|
180
|
+
return lines.join("\n")
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function whatChangedFromReviewTrace(snapshot: ReviewTraceSnapshot): string[] {
|
|
184
|
+
const items: string[] = []
|
|
185
|
+
const status = snapshot.status || "unknown"
|
|
186
|
+
const phase = snapshot.phase || "unknown"
|
|
187
|
+
items.push(`Review trace status is ${status} (phase: ${phase}).`)
|
|
188
|
+
|
|
189
|
+
if (typeof snapshot.review_findings_count === "number") {
|
|
190
|
+
items.push(`CodeGraph reported ${snapshot.review_findings_count} review finding(s).`)
|
|
144
191
|
}
|
|
145
192
|
|
|
146
193
|
const severityCounts = snapshot.review_severity_counts || {}
|
|
@@ -149,26 +196,37 @@ export function formatReviewTraceSummary(snapshot: ReviewTraceSnapshot): string
|
|
|
149
196
|
.map(([severity, count]) => `${severity}:${count}`)
|
|
150
197
|
.join(", ")
|
|
151
198
|
if (severitySummary) {
|
|
152
|
-
|
|
199
|
+
items.push(`Severity mix: ${severitySummary}.`)
|
|
153
200
|
}
|
|
154
201
|
|
|
155
202
|
if (snapshot.error) {
|
|
156
|
-
|
|
203
|
+
items.push(`Review trace recorded an error: ${snapshot.error}`)
|
|
157
204
|
}
|
|
158
205
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
for (const recommendation of recommendations.slice(0, 3)) {
|
|
162
|
-
lines.push(`- ${recommendation}`)
|
|
163
|
-
}
|
|
164
|
-
}
|
|
206
|
+
return items
|
|
207
|
+
}
|
|
165
208
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
209
|
+
export function whyItMattersFromReviewTrace(snapshot: ReviewTraceSnapshot): string {
|
|
210
|
+
const severityCounts = snapshot.review_severity_counts || {}
|
|
211
|
+
const high = severityCounts.high || 0
|
|
212
|
+
const medium = severityCounts.medium || 0
|
|
170
213
|
|
|
171
|
-
|
|
214
|
+
if (snapshot.error) {
|
|
215
|
+
return "The post-commit feedback loop is incomplete, so current review guidance may be missing or stale."
|
|
216
|
+
}
|
|
217
|
+
if ((snapshot.status || "").toLowerCase() === "running") {
|
|
218
|
+
return "The review trace is still running, so findings and recommendations can still change."
|
|
219
|
+
}
|
|
220
|
+
if (high > 0) {
|
|
221
|
+
return "High-severity findings were recorded, so the commit may need immediate follow-up before merge or push."
|
|
222
|
+
}
|
|
223
|
+
if (medium > 0) {
|
|
224
|
+
return "Medium-severity findings were recorded, so follow-up review is recommended before treating the commit as clean."
|
|
225
|
+
}
|
|
226
|
+
if (typeof snapshot.review_findings_count === "number" && snapshot.review_findings_count > 0) {
|
|
227
|
+
return "The review trace found issues worth checking, even if none were marked high severity."
|
|
228
|
+
}
|
|
229
|
+
return "No review findings were recorded, so the commit looks clean from the current trace perspective."
|
|
172
230
|
}
|
|
173
231
|
|
|
174
232
|
export function recommendedNextActionFromReviewTrace(snapshot: ReviewTraceSnapshot): string {
|