opencode-codegraph 0.1.17 → 0.1.19

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.19 - 2026-03-20
4
+
5
+ - add workflow guidance directly to `git status` and `git diff` command output inside OpenCode
6
+
7
+ ## 0.1.18 - 2026-03-20
8
+
9
+ - make after-test guidance test-result aware so failing test runs explicitly block review/push guidance until failures are fixed
10
+
3
11
  ## 0.1.17 - 2026-03-20
4
12
 
5
13
  - include git branch and worktree cleanliness in dogfooding status summaries shown in OpenCode
package/README.md CHANGED
@@ -114,7 +114,8 @@ Place in `.opencode/commands/`:
114
114
  | `chat.message` | Add CPG context for mentioned files |
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
- | `tool.execute.after` on test commands | Add after-test workflow guidance with the next recommended command |
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 |
119
120
  | `experimental.session.compacting` | Preserve current dogfooding status when OpenCode compacts long sessions |
120
121
  | `command.execute.before` | Inject current dogfooding status into `/review`, `/audit`, `/update`, `/status`, and `/next` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-codegraph",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
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
@@ -17,12 +17,14 @@ import { CodeGraphAPI } from "./api"
17
17
  import {
18
18
  extractFileRefs,
19
19
  fileNeedsRegistrationCheck,
20
+ didTestCommandFail,
20
21
  formatAfterTestGuidance,
21
22
  formatDogfoodStatusSummary,
22
23
  formatPendingReviewTraceSummary,
23
24
  formatReviewTraceSummary,
24
25
  getHeadCommit,
25
26
  isGitCommit,
27
+ isGitStatusLikeCommand,
26
28
  isTestCommand,
27
29
  messageSuggestsEditing,
28
30
  messageSuggestsWorkflowGuidance,
@@ -174,13 +176,15 @@ const codegraphPlugin: Plugin = async (input) => {
174
176
  try {
175
177
  const rawStatus = await $`python -m src.cli.import_commands dogfood status --json`.quiet().text()
176
178
  const status = JSON.parse(rawStatus)
177
- const guidance = formatAfterTestGuidance(status)
179
+ const testFailed = didTestCommandFail(output.output)
180
+ const guidance = formatAfterTestGuidance(status, testFailed)
178
181
  if (guidance) {
179
182
  output.title = "CodeGraph: after-test guidance ready"
180
183
  const existingOutput = output.output?.trimEnd() || ""
181
184
  output.output = existingOutput ? `${existingOutput}\n\n${guidance}` : guidance
182
185
  output.metadata = {
183
186
  ...output.metadata,
187
+ codegraph_after_test_result: testFailed ? "failed" : "passed_or_unknown",
184
188
  codegraph_after_test_workflow_state: status.workflow_state || null,
185
189
  codegraph_after_test_next_action: status.recommended_next_action || null,
186
190
  codegraph_after_test_recommended_command: status.recommended_command || null,
@@ -191,6 +195,27 @@ const codegraphPlugin: Plugin = async (input) => {
191
195
  }
192
196
  }
193
197
 
198
+ if (isGitStatusLikeCommand(command)) {
199
+ try {
200
+ const rawStatus = await $`python -m src.cli.import_commands dogfood status --json`.quiet().text()
201
+ const status = JSON.parse(rawStatus)
202
+ const guidance = formatDogfoodStatusSummary(status)
203
+ if (guidance) {
204
+ output.title = "CodeGraph: git workflow guidance ready"
205
+ const existingOutput = output.output?.trimEnd() || ""
206
+ output.output = existingOutput ? `${existingOutput}\n\n${guidance}` : guidance
207
+ output.metadata = {
208
+ ...output.metadata,
209
+ codegraph_git_workflow_state: status.workflow_state || null,
210
+ codegraph_git_next_action: status.recommended_next_action || null,
211
+ codegraph_git_recommended_command: status.recommended_command || null,
212
+ }
213
+ }
214
+ } catch {
215
+ // Best-effort guidance only
216
+ }
217
+ }
218
+
194
219
  if (!isGitCommit(output.output)) return
195
220
 
196
221
  try {
package/src/util.ts CHANGED
@@ -99,6 +99,25 @@ 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
+
108
+ export function didTestCommandFail(output: string): boolean {
109
+ if (!output) return false
110
+ const normalized = output.toLowerCase()
111
+ return [
112
+ "failed",
113
+ "error:",
114
+ "errors:",
115
+ "assertionerror",
116
+ "test failed",
117
+ "1 failed",
118
+ ].some((pattern) => normalized.includes(pattern))
119
+ }
120
+
102
121
  /**
103
122
  * Heuristic: detect whether the user is likely asking to modify code.
104
123
  */
@@ -398,7 +417,10 @@ export function formatDogfoodStatusSummary(snapshot: DogfoodStatusSnapshot): str
398
417
  return lines.join("\n")
399
418
  }
400
419
 
401
- export function formatAfterTestGuidance(snapshot: DogfoodStatusSnapshot): string | null {
420
+ export function formatAfterTestGuidance(
421
+ snapshot: DogfoodStatusSnapshot,
422
+ testFailed = false,
423
+ ): string | null {
402
424
  const workflowState = snapshot.workflow_state
403
425
  const nextAction = snapshot.recommended_next_action
404
426
  const nextCommand = snapshot.recommended_command
@@ -408,6 +430,12 @@ export function formatAfterTestGuidance(snapshot: DogfoodStatusSnapshot): string
408
430
  }
409
431
 
410
432
  const lines = ["## CodeGraph After-Test Guidance", ""]
433
+ if (testFailed) {
434
+ lines.push("- Test result: failed")
435
+ lines.push("- Next action: fix the failing tests before trusting review or push guidance")
436
+ lines.push("- Suggested command: rerun the failing tests after you fix them")
437
+ return lines.join("\n")
438
+ }
411
439
  if (workflowState) {
412
440
  lines.push(`- Workflow state: ${workflowState}`)
413
441
  }