opencode-beads 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/plugin.ts +14 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-beads",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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
@@ -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
@@ -141,5 +150,3 @@ export const BeadsPlugin: Plugin = async ({ client, $ }) => {
141
150
  },
142
151
  };
143
152
  };
144
-
145
- export default BeadsPlugin;