opencode-mad 0.3.11 → 0.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
- {
2
- "name": "opencode-mad",
3
- "version": "0.3.11",
1
+ {
2
+ "name": "opencode-mad",
3
+ "version": "0.4.1",
4
4
  "description": "Multi-Agent Dev - Parallel development orchestration plugin for OpenCode",
5
5
  "type": "module",
6
6
  "main": "plugins/mad-plugin.ts",
@@ -12,8 +12,8 @@ import { execSync } from "child_process"
12
12
  * running in parallel via OpenCode's Task tool.
13
13
  */
14
14
 
15
- // Current version of opencode-mad
16
- const CURRENT_VERSION = "0.3.11"
15
+ // Current version of opencode-mad
16
+ const CURRENT_VERSION = "0.4.1"
17
17
 
18
18
  // Update notification state (shown only once per session)
19
19
  let updateNotificationShown = false
@@ -21,6 +21,9 @@ let pendingUpdateMessage: string | null = null
21
21
 
22
22
  export const MADPlugin: Plugin = async ({ project, client, $, directory, worktree }) => {
23
23
 
24
+ // Use the directory provided by OpenCode, fallback to process.cwd() for backwards compatibility
25
+ const baseDirectory = directory || process.cwd()
26
+
24
27
  /**
25
28
  * Helper to run shell commands with proper error handling (cross-platform)
26
29
  */
@@ -28,7 +31,7 @@ export const MADPlugin: Plugin = async ({ project, client, $, directory, worktre
28
31
  try {
29
32
  const output = execSync(cmd, {
30
33
  encoding: "utf-8",
31
- cwd: cwd || process.cwd(),
34
+ cwd: cwd || baseDirectory,
32
35
  stdio: ["pipe", "pipe", "pipe"]
33
36
  })
34
37
  return { success: true, output: output.trim() }
@@ -43,9 +46,10 @@ export const MADPlugin: Plugin = async ({ project, client, $, directory, worktre
43
46
 
44
47
  /**
45
48
  * Helper to get git root with error handling
49
+ * @param basePath - Optional base path to start from (defaults to baseDirectory)
46
50
  */
47
- const getGitRoot = (): string => {
48
- const result = runCommand("git rev-parse --show-toplevel")
51
+ const getGitRoot = (basePath?: string): string => {
52
+ const result = runCommand("git rev-parse --show-toplevel", basePath || baseDirectory)
49
53
  if (!result.success) {
50
54
  throw new Error(`Not a git repository or git not found: ${result.error}`)
51
55
  }
@@ -54,18 +58,20 @@ export const MADPlugin: Plugin = async ({ project, client, $, directory, worktre
54
58
 
55
59
  /**
56
60
  * Helper to get current branch with fallback
61
+ * @param basePath - Optional base path to run git command from (defaults to baseDirectory)
57
62
  */
58
- const getCurrentBranch = (): string => {
59
- const result = runCommand("git symbolic-ref --short HEAD")
63
+ const getCurrentBranch = (basePath?: string): string => {
64
+ const result = runCommand("git symbolic-ref --short HEAD", basePath || baseDirectory)
60
65
  return result.success ? result.output : "main"
61
66
  }
62
67
 
63
68
  /**
64
69
  * Helper to log MAD events
70
+ * Uses baseDirectory to find the git root for log file location
65
71
  */
66
72
  const logEvent = (level: "info" | "warn" | "error" | "debug", message: string, context?: any) => {
67
73
  try {
68
- const gitRoot = getGitRoot()
74
+ const gitRoot = getGitRoot(baseDirectory)
69
75
  const logFile = join(gitRoot, ".mad-logs.jsonl")
70
76
  const logEntry = JSON.stringify({
71
77
  timestamp: new Date().toISOString(),