opencode-codegraph 0.1.12 → 0.1.13

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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.13 - 2026-03-20
4
+
5
+ - add after-test guidance so common test commands are followed by workflow state, next action, and recommended command
6
+
3
7
  ## 0.1.12 - 2026-03-20
4
8
 
5
9
  - add `ready_to_push` workflow state when CPG is fresh, review trace is green, and the worktree is clean
package/README.md CHANGED
@@ -113,6 +113,7 @@ Place in `.opencode/commands/`:
113
113
  | `chat.message` | Add CPG context for mentioned files |
114
114
  | `chat.message` (edit intent) | Add pre-edit warnings for files likely to be modified |
115
115
  | `chat.message` (workflow intent) | Add dogfooding status when the user asks what to do next |
116
+ | `tool.execute.after` on test commands | Add after-test workflow guidance with the next recommended command |
116
117
  | `tool.execute.after` | Trigger CPG update after git commit and append structured post-commit review summary |
117
118
  | `permission.ask` | Auto-allow `codegraph_*` tools |
118
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-codegraph",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
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,11 +17,13 @@ import { CodeGraphAPI } from "./api"
17
17
  import {
18
18
  extractFileRefs,
19
19
  fileNeedsRegistrationCheck,
20
+ formatAfterTestGuidance,
20
21
  formatDogfoodStatusSummary,
21
22
  formatPendingReviewTraceSummary,
22
23
  formatReviewTraceSummary,
23
24
  getHeadCommit,
24
25
  isGitCommit,
26
+ isTestCommand,
25
27
  messageSuggestsEditing,
26
28
  messageSuggestsWorkflowGuidance,
27
29
  recommendedCommandFromReviewTrace,
@@ -129,6 +131,29 @@ const codegraphPlugin: Plugin = async (input) => {
129
131
  // -----------------------------------------------------------------
130
132
  "tool.execute.after": async (inp, output) => {
131
133
  if (inp.tool !== "bash") return
134
+ const command = typeof inp.args?.command === "string" ? inp.args.command : ""
135
+
136
+ if (isTestCommand(command)) {
137
+ try {
138
+ const rawStatus = await $`python -m src.cli.import_commands dogfood status --json`.quiet().text()
139
+ const status = JSON.parse(rawStatus)
140
+ const guidance = formatAfterTestGuidance(status)
141
+ if (guidance) {
142
+ output.title = "CodeGraph: after-test guidance ready"
143
+ const existingOutput = output.output?.trimEnd() || ""
144
+ output.output = existingOutput ? `${existingOutput}\n\n${guidance}` : guidance
145
+ output.metadata = {
146
+ ...output.metadata,
147
+ codegraph_after_test_workflow_state: status.workflow_state || null,
148
+ codegraph_after_test_next_action: status.recommended_next_action || null,
149
+ codegraph_after_test_recommended_command: status.recommended_command || null,
150
+ }
151
+ }
152
+ } catch {
153
+ // Best-effort guidance only
154
+ }
155
+ }
156
+
132
157
  if (!isGitCommit(output.output)) return
133
158
 
134
159
  try {
package/src/util.ts CHANGED
@@ -84,6 +84,14 @@ export function isGitCommit(output: string): boolean {
84
84
  )
85
85
  }
86
86
 
87
+ export function isTestCommand(command: string): boolean {
88
+ if (!command) return false
89
+ const normalized = command.toLowerCase()
90
+ return ["pytest", "go test", "npm test", "pnpm test", "bun test", "cargo test", "vitest", "jest"].some(
91
+ (pattern) => normalized.includes(pattern),
92
+ )
93
+ }
94
+
87
95
  /**
88
96
  * Heuristic: detect whether the user is likely asking to modify code.
89
97
  */
@@ -374,6 +382,28 @@ export function formatDogfoodStatusSummary(snapshot: DogfoodStatusSnapshot): str
374
382
  return lines.join("\n")
375
383
  }
376
384
 
385
+ export function formatAfterTestGuidance(snapshot: DogfoodStatusSnapshot): string | null {
386
+ const workflowState = snapshot.workflow_state
387
+ const nextAction = snapshot.recommended_next_action
388
+ const nextCommand = snapshot.recommended_command
389
+
390
+ if (!workflowState && !nextAction && !nextCommand) {
391
+ return null
392
+ }
393
+
394
+ const lines = ["## CodeGraph After-Test Guidance", ""]
395
+ if (workflowState) {
396
+ lines.push(`- Workflow state: ${workflowState}`)
397
+ }
398
+ if (nextAction) {
399
+ lines.push(`- Next action: ${nextAction}`)
400
+ }
401
+ if (nextCommand) {
402
+ lines.push(`- Suggested command: ${nextCommand}`)
403
+ }
404
+ return lines.join("\n")
405
+ }
406
+
377
407
  // File extensions recognized as source code
378
408
  const SOURCE_EXTENSIONS = new Set([
379
409
  "py",