opencode-codegraph 0.1.18 → 0.1.20

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.20 - 2026-03-20
4
+
5
+ - append workflow guidance to the `codegraph_review` custom tool so tool results stay aligned with current dogfooding state
6
+
7
+ ## 0.1.19 - 2026-03-20
8
+
9
+ - add workflow guidance directly to `git status` and `git diff` command output inside OpenCode
10
+
3
11
  ## 0.1.18 - 2026-03-20
4
12
 
5
13
  - make after-test guidance test-result aware so failing test runs explicitly block review/push guidance until failures are fixed
package/README.md CHANGED
@@ -115,7 +115,9 @@ Place in `.opencode/commands/`:
115
115
  | `chat.message` (edit intent) | Add pre-edit warnings for files likely to be modified |
116
116
  | `chat.message` (workflow intent) | Add dogfooding status when the user asks what to do next |
117
117
  | `tool.execute.after` on test commands | Add after-test workflow guidance and detect failed test runs before suggesting the next command |
118
+ | `tool.execute.after` on `git status` / `git diff` | Add current workflow guidance directly to common git inspection commands |
118
119
  | `tool.execute.after` | Trigger CPG update after git commit and append structured post-commit review summary |
120
+ | `codegraph_review` tool | Returns review results together with current workflow guidance and suggested follow-up command |
119
121
  | `experimental.session.compacting` | Preserve current dogfooding status when OpenCode compacts long sessions |
120
122
  | `command.execute.before` | Inject current dogfooding status into `/review`, `/audit`, `/update`, `/status`, and `/next` |
121
123
  | `permission.ask` | Auto-allow `codegraph_*` tools |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-codegraph",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "OpenCode plugin for CodeGraph CPG-powered code analysis",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -22,8 +22,10 @@ import {
22
22
  formatDogfoodStatusSummary,
23
23
  formatPendingReviewTraceSummary,
24
24
  formatReviewTraceSummary,
25
+ formatWorkflowGuidanceBlock,
25
26
  getHeadCommit,
26
27
  isGitCommit,
28
+ isGitStatusLikeCommand,
27
29
  isTestCommand,
28
30
  messageSuggestsEditing,
29
31
  messageSuggestsWorkflowGuidance,
@@ -194,6 +196,27 @@ const codegraphPlugin: Plugin = async (input) => {
194
196
  }
195
197
  }
196
198
 
199
+ if (isGitStatusLikeCommand(command)) {
200
+ try {
201
+ const rawStatus = await $`python -m src.cli.import_commands dogfood status --json`.quiet().text()
202
+ const status = JSON.parse(rawStatus)
203
+ const guidance = formatDogfoodStatusSummary(status)
204
+ if (guidance) {
205
+ output.title = "CodeGraph: git workflow guidance ready"
206
+ const existingOutput = output.output?.trimEnd() || ""
207
+ output.output = existingOutput ? `${existingOutput}\n\n${guidance}` : guidance
208
+ output.metadata = {
209
+ ...output.metadata,
210
+ codegraph_git_workflow_state: status.workflow_state || null,
211
+ codegraph_git_next_action: status.recommended_next_action || null,
212
+ codegraph_git_recommended_command: status.recommended_command || null,
213
+ }
214
+ }
215
+ } catch {
216
+ // Best-effort guidance only
217
+ }
218
+ }
219
+
197
220
  if (!isGitCommit(output.output)) return
198
221
 
199
222
  try {
@@ -273,17 +296,22 @@ const codegraphPlugin: Plugin = async (input) => {
273
296
  .optional()
274
297
  .describe("Base git ref to compare against (default: HEAD~1)"),
275
298
  },
276
- async execute(args) {
277
- const baseRef = args.base_ref || "HEAD~1"
278
- const diff = await $`git diff ${baseRef}`.quiet().text()
279
- if (!diff.trim()) {
280
- return "No changes found."
281
- }
282
-
283
- const result = await api.reviewChanges(projectId, diff, baseRef)
284
- return result
285
- },
286
- }),
299
+ async execute(args) {
300
+ const baseRef = args.base_ref || "HEAD~1"
301
+ const diff = await $`git diff ${baseRef}`.quiet().text()
302
+ const rawStatus = await $`python -m src.cli.import_commands dogfood status --json`.quiet().text()
303
+ const status = JSON.parse(rawStatus)
304
+ const guidance = formatWorkflowGuidanceBlock(status)
305
+ if (!diff.trim()) {
306
+ return guidance ? `No changes found.\n\n${guidance}` : "No changes found."
307
+ }
308
+
309
+ const result = await api.reviewChanges(projectId, diff, baseRef)
310
+ return guidance
311
+ ? `${result}\n\n${guidance}\n\nUse the suggested command if the review result and session state disagree.`
312
+ : result
313
+ },
314
+ }),
287
315
 
288
316
  codegraph_explain_function: tool({
289
317
  description:
package/src/util.ts CHANGED
@@ -99,6 +99,12 @@ export function isTestCommand(command: string): boolean {
99
99
  )
100
100
  }
101
101
 
102
+ export function isGitStatusLikeCommand(command: string): boolean {
103
+ if (!command) return false
104
+ const normalized = command.toLowerCase()
105
+ return normalized.includes("git status") || normalized.includes("git diff")
106
+ }
107
+
102
108
  export function didTestCommandFail(output: string): boolean {
103
109
  if (!output) return false
104
110
  const normalized = output.toLowerCase()
@@ -411,6 +417,28 @@ export function formatDogfoodStatusSummary(snapshot: DogfoodStatusSnapshot): str
411
417
  return lines.join("\n")
412
418
  }
413
419
 
420
+ export function formatWorkflowGuidanceBlock(snapshot: DogfoodStatusSnapshot): string | null {
421
+ const workflowState = snapshot.workflow_state
422
+ const nextAction = snapshot.recommended_next_action
423
+ const nextCommand = snapshot.recommended_command
424
+
425
+ if (!workflowState && !nextAction && !nextCommand) {
426
+ return null
427
+ }
428
+
429
+ const lines = ["## CodeGraph Workflow Guidance", ""]
430
+ if (workflowState) {
431
+ lines.push(`- Workflow state: ${workflowState}`)
432
+ }
433
+ if (nextAction) {
434
+ lines.push(`- Next action: ${nextAction}`)
435
+ }
436
+ if (nextCommand) {
437
+ lines.push(`- Suggested command: ${nextCommand}`)
438
+ }
439
+ return lines.join("\n")
440
+ }
441
+
414
442
  export function formatAfterTestGuidance(
415
443
  snapshot: DogfoodStatusSnapshot,
416
444
  testFailed = false,