opencode-codegraph 0.1.12 → 0.1.14

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.14 - 2026-03-20
4
+
5
+ - preserve dogfooding status across OpenCode session compaction so freshness and workflow guidance survive long chats
6
+
7
+ ## 0.1.13 - 2026-03-20
8
+
9
+ - add after-test guidance so common test commands are followed by workflow state, next action, and recommended command
10
+
3
11
  ## 0.1.12 - 2026-03-20
4
12
 
5
13
  - add `ready_to_push` workflow state when CPG is fresh, review trace is green, and the worktree is clean
package/README.md CHANGED
@@ -113,7 +113,9 @@ 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 |
118
+ | `experimental.session.compacting` | Preserve current dogfooding status when OpenCode compacts long sessions |
117
119
  | `permission.ask` | Auto-allow `codegraph_*` tools |
118
120
 
119
121
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-codegraph",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
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,
@@ -66,7 +68,22 @@ const codegraphPlugin: Plugin = async (input) => {
66
68
  // CodeGraph API not available — skip silently
67
69
  }
68
70
  },
69
-
71
+
72
+ // -----------------------------------------------------------------
73
+ // 1b. Session compaction: preserve workflow status across long sessions
74
+ // -----------------------------------------------------------------
75
+ "experimental.session.compacting": async (_inp, output) => {
76
+ try {
77
+ const rawStatus = await $`python -m src.cli.import_commands dogfood status --json`.quiet().text()
78
+ const statusSummary = formatDogfoodStatusSummary(JSON.parse(rawStatus))
79
+ if (statusSummary) {
80
+ output.context.push(statusSummary)
81
+ }
82
+ } catch {
83
+ // Keep compaction resilient if status lookup fails
84
+ }
85
+ },
86
+
70
87
  // -----------------------------------------------------------------
71
88
  // 2. Chat message: auto-enrich with CPG context for mentioned files
72
89
  // -----------------------------------------------------------------
@@ -129,6 +146,29 @@ const codegraphPlugin: Plugin = async (input) => {
129
146
  // -----------------------------------------------------------------
130
147
  "tool.execute.after": async (inp, output) => {
131
148
  if (inp.tool !== "bash") return
149
+ const command = typeof inp.args?.command === "string" ? inp.args.command : ""
150
+
151
+ if (isTestCommand(command)) {
152
+ try {
153
+ const rawStatus = await $`python -m src.cli.import_commands dogfood status --json`.quiet().text()
154
+ const status = JSON.parse(rawStatus)
155
+ const guidance = formatAfterTestGuidance(status)
156
+ if (guidance) {
157
+ output.title = "CodeGraph: after-test guidance ready"
158
+ const existingOutput = output.output?.trimEnd() || ""
159
+ output.output = existingOutput ? `${existingOutput}\n\n${guidance}` : guidance
160
+ output.metadata = {
161
+ ...output.metadata,
162
+ codegraph_after_test_workflow_state: status.workflow_state || null,
163
+ codegraph_after_test_next_action: status.recommended_next_action || null,
164
+ codegraph_after_test_recommended_command: status.recommended_command || null,
165
+ }
166
+ }
167
+ } catch {
168
+ // Best-effort guidance only
169
+ }
170
+ }
171
+
132
172
  if (!isGitCommit(output.output)) return
133
173
 
134
174
  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",