opencode-beads 0.1.1 → 0.2.0

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
1
  {
2
2
  "name": "opencode-beads",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "A plugin for OpenCode that provides integration with the beads issue tracker.",
6
6
  "author": "Josh Thomas <josh@joshthomas.dev>",
package/src/plugin.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  */
11
11
 
12
12
  import type { Plugin, PluginInput } from "@opencode-ai/plugin";
13
- import { CLI_GUIDANCE, loadAgent, loadCommands } from "./vendor";
13
+ import { BEADS_GUIDANCE, loadAgent, loadCommands } from "./vendor";
14
14
 
15
15
  type OpencodeClient = PluginInput["client"];
16
16
 
@@ -70,7 +70,7 @@ async function injectBeadsContext(
70
70
  ${primeOutput.trim()}
71
71
  </beads-context>
72
72
 
73
- ${CLI_GUIDANCE}`;
73
+ ${BEADS_GUIDANCE}`;
74
74
 
75
75
  // Inject content via noReply + synthetic
76
76
  // Must pass model and agent to prevent mode/model switching
@@ -101,16 +101,25 @@ export const BeadsPlugin: Plugin = async ({ client, $ }) => {
101
101
  // Skip if already injected this session
102
102
  if (injectedSessions.has(sessionID)) return;
103
103
 
104
- // Check if session already has messages (handles plugin reload/reconnection)
104
+ // Check if beads-context was already injected (handles plugin reload/reconnection)
105
105
  try {
106
106
  const existing = await client.session.messages({
107
107
  path: { id: sessionID },
108
- query: { limit: 1 },
109
108
  });
110
109
 
111
- if (existing.data && existing.data.length > 0) {
112
- injectedSessions.add(sessionID);
113
- return;
110
+ if (existing.data) {
111
+ const hasBeadsContext = existing.data.some(msg => {
112
+ const parts = (msg as any).parts || (msg.info as any).parts;
113
+ if (!parts) return false;
114
+ return parts.some((part: any) =>
115
+ part.type === 'text' && part.text?.includes('<beads-context>')
116
+ );
117
+ });
118
+
119
+ if (hasBeadsContext) {
120
+ injectedSessions.add(sessionID);
121
+ return;
122
+ }
114
123
  }
115
124
  } catch {
116
125
  // On error, proceed with injection
package/src/vendor.ts CHANGED
@@ -84,26 +84,40 @@ async function listVendorFiles(relativePath: string): Promise<string[]> {
84
84
  }
85
85
  }
86
86
 
87
- export const CLI_GUIDANCE = `<beads-cli-guidance>
88
- Beads MCP tools are not available. Use the \`bd\` CLI via bash instead:
89
-
90
- - \`init\` \`bd init [prefix]\`
91
- - \`ready\` → \`bd ready --json\`
92
- - \`show\` \`bd show <id> --json\`
93
- - \`create\` → \`bd create "title" -t bug|feature|task -p 0-4 --json\`
94
- - \`update\` \`bd update <id> --status in_progress --json\`
95
- - \`close\` \`bd close <id> --reason "message" --json\`
96
- - \`reopen\` → \`bd reopen <id> --json\`
97
- - \`dep\` → \`bd dep add <from> <to> --type blocks|discovered-from --json\`
98
- - \`list\` \`bd list --status open --json\`
99
- - \`blocked\` \`bd blocked --json\`
100
- - \`stats\` \`bd stats --json\`
101
- - \`sync\` \`bd sync\`
102
-
103
- MCP tools map directly to bd CLI commands. If a tool is not listed above, try \`bd <tool> --help\`.
87
+ export const BEADS_GUIDANCE = `<beads-guidance>
88
+ ## CLI Usage
89
+
90
+ **Note:** Beads MCP tools are not available in this environment. Use the \`bd\` CLI via bash instead. MCP tool names map directly to \`bd\` commands.
91
+
92
+ Use the \`bd\` CLI via bash for beads operations:
93
+
94
+ - \`bd init [prefix]\` - Initialize beads
95
+ - \`bd ready --json\` - List ready tasks
96
+ - \`bd show <id> --json\` - Show task details
97
+ - \`bd create "title" -t bug|feature|task -p 0-4 --json\` - Create issue
98
+ - \`bd update <id> --status in_progress --json\` - Update status
99
+ - \`bd close <id> --reason "message" --json\` - Close issue
100
+ - \`bd reopen <id> --json\` - Reopen issue
101
+ - \`bd dep add <from> <to> --type blocks|discovered-from --json\` - Add dependency
102
+ - \`bd list --status open --json\` - List issues
103
+ - \`bd blocked --json\` - Show blocked issues
104
+ - \`bd stats --json\` - Show statistics
105
+ - \`bd sync\` - Sync with git
106
+
107
+ If a tool is not listed above, try \`bd <tool> --help\`.
104
108
 
105
109
  Always use \`--json\` flag for structured output.
106
- </beads-cli-guidance>`;
110
+
111
+ ## Agent Delegation
112
+
113
+ For multi-step beads work, use the \`task\` tool with \`subagent_type: "beads-task-agent"\`:
114
+ - Finding and completing ready work autonomously
115
+ - Working through multiple issues in sequence
116
+ - Tasks involving claiming, executing, and closing issues
117
+ - When asked to "work on beads issues", "complete tasks", or similar
118
+
119
+ For single, specific operations (check status, create one issue, query info), use \`bd\` CLI directly.
120
+ </beads-guidance>`;
107
121
 
108
122
  export async function loadAgent(): Promise<Config["agent"]> {
109
123
  const content = await readVendorFile("agents/task-agent.md");
@@ -118,7 +132,7 @@ export async function loadAgent(): Promise<Config["agent"]> {
118
132
  return {
119
133
  "beads-task-agent": {
120
134
  description,
121
- prompt: CLI_GUIDANCE + "\n" + parsed.body,
135
+ prompt: BEADS_GUIDANCE + "\n" + parsed.body,
122
136
  mode: "subagent",
123
137
  },
124
138
  };