opencode-swarm-plugin 0.43.0 → 0.44.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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +31 -0
- package/bin/cass.characterization.test.ts +422 -0
- package/bin/swarm.test.ts +68 -0
- package/bin/swarm.ts +67 -0
- package/dist/contributor-tools.d.ts +42 -0
- package/dist/contributor-tools.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -2
- package/dist/plugin.js +95 -2
- package/dist/sessions/agent-discovery.d.ts +59 -0
- package/dist/sessions/agent-discovery.d.ts.map +1 -0
- package/dist/sessions/index.d.ts +10 -0
- package/dist/sessions/index.d.ts.map +1 -0
- package/docs/planning/ADR-010-cass-inhousing.md +1215 -0
- package/evals/fixtures/cass-baseline.ts +217 -0
- package/examples/plugin-wrapper-template.ts +89 -0
- package/package.json +1 -1
- package/src/contributor-tools.test.ts +133 -0
- package/src/contributor-tools.ts +201 -0
- package/src/index.ts +8 -3
- package/src/sessions/agent-discovery.test.ts +137 -0
- package/src/sessions/agent-discovery.ts +112 -0
- package/src/sessions/index.ts +15 -0
package/src/index.ts
CHANGED
|
@@ -50,6 +50,7 @@ import { memoryTools } from "./memory-tools";
|
|
|
50
50
|
import { observabilityTools } from "./observability-tools";
|
|
51
51
|
import { researchTools } from "./swarm-research";
|
|
52
52
|
import { evalTools } from "./eval-runner";
|
|
53
|
+
import { contributorTools } from "./contributor-tools";
|
|
53
54
|
import {
|
|
54
55
|
guardrailOutput,
|
|
55
56
|
DEFAULT_GUARDRAIL_CONFIG,
|
|
@@ -80,6 +81,7 @@ import { createCompactionHook } from "./compaction-hook";
|
|
|
80
81
|
* - skills:* - Agent skills discovery, activation, and execution
|
|
81
82
|
* - mandate:* - Agent voting system for collaborative knowledge curation
|
|
82
83
|
* - semantic-memory:* - Semantic memory with vector embeddings (Ollama + PGLite)
|
|
84
|
+
* - contributor_lookup - GitHub contributor profile lookup with changeset credit generation
|
|
83
85
|
*
|
|
84
86
|
* @param input - Plugin context from OpenCode
|
|
85
87
|
* @returns Plugin hooks including tools, events, and tool execution hooks
|
|
@@ -159,9 +161,10 @@ const SwarmPlugin: Plugin = async (
|
|
|
159
161
|
* - beads:* - Legacy aliases (deprecated, use hive:* instead)
|
|
160
162
|
* - agent-mail:init, agent-mail:send, agent-mail:reserve, etc. (legacy MCP)
|
|
161
163
|
* - swarm-mail:init, swarm-mail:send, swarm-mail:reserve, etc. (embedded)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
* - repo-crawl:readme, repo-crawl:structure, etc.
|
|
165
|
+
* - mandate:file, mandate:vote, mandate:query, etc.
|
|
166
|
+
* - semantic-memory:store, semantic-memory:find, semantic-memory:get, etc.
|
|
167
|
+
* - contributor_lookup - GitHub contributor profile lookup with changeset credits
|
|
165
168
|
*/
|
|
166
169
|
tool: {
|
|
167
170
|
...hiveTools,
|
|
@@ -177,6 +180,7 @@ const SwarmPlugin: Plugin = async (
|
|
|
177
180
|
...observabilityTools,
|
|
178
181
|
...researchTools,
|
|
179
182
|
...evalTools,
|
|
183
|
+
...contributorTools,
|
|
180
184
|
},
|
|
181
185
|
|
|
182
186
|
/**
|
|
@@ -516,6 +520,7 @@ export const allTools = {
|
|
|
516
520
|
...mandateTools,
|
|
517
521
|
...memoryTools,
|
|
518
522
|
...observabilityTools,
|
|
523
|
+
...contributorTools,
|
|
519
524
|
} as const;
|
|
520
525
|
|
|
521
526
|
/**
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Discovery Tests
|
|
3
|
+
*
|
|
4
|
+
* Maps file paths to agent types using pattern matching.
|
|
5
|
+
* Follows TDD pattern from ADR-010 Section 4.5.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, test, expect, afterEach } from "bun:test";
|
|
9
|
+
import {
|
|
10
|
+
detectAgentType,
|
|
11
|
+
loadAgentPatterns,
|
|
12
|
+
resetAgentPatterns,
|
|
13
|
+
} from "./agent-discovery";
|
|
14
|
+
|
|
15
|
+
describe("detectAgentType", () => {
|
|
16
|
+
test("detects OpenCode Swarm sessions", () => {
|
|
17
|
+
expect(
|
|
18
|
+
detectAgentType(
|
|
19
|
+
"/home/user/.config/swarm-tools/sessions/ses_123.jsonl"
|
|
20
|
+
)
|
|
21
|
+
).toBe("opencode-swarm");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("detects Cursor sessions", () => {
|
|
25
|
+
expect(
|
|
26
|
+
detectAgentType(
|
|
27
|
+
"/Users/joel/Library/Application Support/Cursor/User/History/abc/9ScS.jsonl"
|
|
28
|
+
)
|
|
29
|
+
).toBe("cursor");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("detects OpenCode sessions", () => {
|
|
33
|
+
expect(detectAgentType("/Users/joel/.opencode/session.jsonl")).toBe(
|
|
34
|
+
"opencode"
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("detects Claude sessions", () => {
|
|
39
|
+
expect(
|
|
40
|
+
detectAgentType("/home/user/.local/share/Claude/ses_456.jsonl")
|
|
41
|
+
).toBe("claude");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("detects Aider sessions", () => {
|
|
45
|
+
expect(detectAgentType("/home/user/.aider/session.jsonl")).toBe("aider");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("returns null for unknown paths", () => {
|
|
49
|
+
expect(detectAgentType("/tmp/random.jsonl")).toBeNull();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("handles Windows-style paths", () => {
|
|
53
|
+
expect(
|
|
54
|
+
detectAgentType("C:\\Users\\joel\\.config\\swarm-tools\\sessions\\ses.jsonl")
|
|
55
|
+
).toBe("opencode-swarm");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("handles nested paths", () => {
|
|
59
|
+
expect(
|
|
60
|
+
detectAgentType(
|
|
61
|
+
"/Users/joel/.opencode/deeply/nested/folder/session.jsonl"
|
|
62
|
+
)
|
|
63
|
+
).toBe("opencode");
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("loadAgentPatterns", () => {
|
|
68
|
+
afterEach(() => {
|
|
69
|
+
// Reset to defaults after each test
|
|
70
|
+
resetAgentPatterns();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("loads custom agent patterns", () => {
|
|
74
|
+
const count = loadAgentPatterns([
|
|
75
|
+
{ pattern: "\\.codex[/\\\\]", agentType: "opencode-swarm" },
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
expect(count).toBe(1);
|
|
79
|
+
expect(detectAgentType("/home/user/.codex/session.jsonl")).toBe(
|
|
80
|
+
"opencode-swarm"
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("replaces default patterns with custom ones", () => {
|
|
85
|
+
loadAgentPatterns([
|
|
86
|
+
{ pattern: "\\.custom[/\\\\]", agentType: "cursor" },
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
// Custom pattern works
|
|
90
|
+
expect(detectAgentType("/path/.custom/file.jsonl")).toBe("cursor");
|
|
91
|
+
|
|
92
|
+
// Default patterns no longer work
|
|
93
|
+
expect(
|
|
94
|
+
detectAgentType("/home/user/.config/swarm-tools/sessions/ses.jsonl")
|
|
95
|
+
).toBeNull();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("supports multiple custom patterns", () => {
|
|
99
|
+
loadAgentPatterns([
|
|
100
|
+
{ pattern: "\\.agent1[/\\\\]", agentType: "opencode-swarm" },
|
|
101
|
+
{ pattern: "\\.agent2[/\\\\]", agentType: "cursor" },
|
|
102
|
+
{ pattern: "\\.agent3[/\\\\]", agentType: "claude" },
|
|
103
|
+
]);
|
|
104
|
+
|
|
105
|
+
expect(detectAgentType("/path/.agent1/file.jsonl")).toBe(
|
|
106
|
+
"opencode-swarm"
|
|
107
|
+
);
|
|
108
|
+
expect(detectAgentType("/path/.agent2/file.jsonl")).toBe("cursor");
|
|
109
|
+
expect(detectAgentType("/path/.agent3/file.jsonl")).toBe("claude");
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe("resetAgentPatterns", () => {
|
|
114
|
+
test("restores default patterns after custom load", () => {
|
|
115
|
+
// Load custom patterns
|
|
116
|
+
loadAgentPatterns([
|
|
117
|
+
{ pattern: "\\.custom[/\\\\]", agentType: "opencode-swarm" },
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
// Custom works, defaults don't
|
|
121
|
+
expect(detectAgentType("/path/.custom/file.jsonl")).toBe(
|
|
122
|
+
"opencode-swarm"
|
|
123
|
+
);
|
|
124
|
+
expect(
|
|
125
|
+
detectAgentType("/home/user/.config/swarm-tools/sessions/ses.jsonl")
|
|
126
|
+
).toBeNull();
|
|
127
|
+
|
|
128
|
+
// Reset
|
|
129
|
+
resetAgentPatterns();
|
|
130
|
+
|
|
131
|
+
// Defaults work again
|
|
132
|
+
expect(
|
|
133
|
+
detectAgentType("/home/user/.config/swarm-tools/sessions/ses.jsonl")
|
|
134
|
+
).toBe("opencode-swarm");
|
|
135
|
+
expect(detectAgentType("/path/.custom/file.jsonl")).toBeNull();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Discovery Module
|
|
3
|
+
*
|
|
4
|
+
* Maps file paths to agent types using pattern matching.
|
|
5
|
+
* Supports cross-platform paths (Unix and Windows).
|
|
6
|
+
*
|
|
7
|
+
* @module sessions/agent-discovery
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Agent type identifier
|
|
12
|
+
*/
|
|
13
|
+
export type AgentType =
|
|
14
|
+
| "opencode-swarm"
|
|
15
|
+
| "cursor"
|
|
16
|
+
| "opencode"
|
|
17
|
+
| "claude"
|
|
18
|
+
| "aider";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Path pattern configuration for agent type detection
|
|
22
|
+
*/
|
|
23
|
+
interface AgentPathPattern {
|
|
24
|
+
/** RegExp pattern to match against file path */
|
|
25
|
+
pattern: RegExp;
|
|
26
|
+
/** Agent type to return when pattern matches */
|
|
27
|
+
agentType: AgentType;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Default path patterns for agent type detection
|
|
32
|
+
* Order matters - first match wins
|
|
33
|
+
*
|
|
34
|
+
* Can be overridden via loadAgentPatterns()
|
|
35
|
+
*/
|
|
36
|
+
let AGENT_PATH_PATTERNS: AgentPathPattern[] = [
|
|
37
|
+
{ pattern: /\.config[\/\\]swarm-tools[\/\\]sessions[\/\\]/, agentType: "opencode-swarm" },
|
|
38
|
+
{ pattern: /Cursor[\/\\]User[\/\\]History[\/\\]/, agentType: "cursor" },
|
|
39
|
+
{ pattern: /\.opencode[\/\\]/, agentType: "opencode" },
|
|
40
|
+
{ pattern: /\.local[\/\\]share[\/\\]Claude[\/\\]/, agentType: "claude" },
|
|
41
|
+
{ pattern: /\.aider/, agentType: "aider" },
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Configuration for custom agent patterns
|
|
46
|
+
*/
|
|
47
|
+
interface AgentPatternConfig {
|
|
48
|
+
/** Pattern string (will be converted to RegExp) */
|
|
49
|
+
pattern: string;
|
|
50
|
+
/** Agent type identifier */
|
|
51
|
+
agentType: AgentType;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Load custom agent patterns from config
|
|
56
|
+
*
|
|
57
|
+
* @param patterns - Array of custom pattern configurations
|
|
58
|
+
* @returns Number of patterns loaded
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* loadAgentPatterns([
|
|
63
|
+
* { pattern: "\\.codex[/\\\\]", agentType: "codex" },
|
|
64
|
+
* { pattern: "\\.gemini[/\\\\]", agentType: "gemini" }
|
|
65
|
+
* ]);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function loadAgentPatterns(patterns: AgentPatternConfig[]): number {
|
|
69
|
+
AGENT_PATH_PATTERNS = patterns.map(({ pattern, agentType }) => ({
|
|
70
|
+
pattern: new RegExp(pattern),
|
|
71
|
+
agentType,
|
|
72
|
+
}));
|
|
73
|
+
return AGENT_PATH_PATTERNS.length;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Reset agent patterns to defaults
|
|
78
|
+
* Useful for testing
|
|
79
|
+
*/
|
|
80
|
+
export function resetAgentPatterns(): void {
|
|
81
|
+
AGENT_PATH_PATTERNS = [
|
|
82
|
+
{ pattern: /\.config[\/\\]swarm-tools[\/\\]sessions[\/\\]/, agentType: "opencode-swarm" },
|
|
83
|
+
{ pattern: /Cursor[\/\\]User[\/\\]History[\/\\]/, agentType: "cursor" },
|
|
84
|
+
{ pattern: /\.opencode[\/\\]/, agentType: "opencode" },
|
|
85
|
+
{ pattern: /\.local[\/\\]share[\/\\]Claude[\/\\]/, agentType: "claude" },
|
|
86
|
+
{ pattern: /\.aider/, agentType: "aider" },
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Detect agent type from file path
|
|
92
|
+
*
|
|
93
|
+
* @param filePath - Absolute or relative file path (Unix or Windows)
|
|
94
|
+
* @returns Agent type identifier, or null if unknown
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* detectAgentType("/home/user/.config/swarm-tools/sessions/ses_123.jsonl")
|
|
99
|
+
* // => "opencode-swarm"
|
|
100
|
+
*
|
|
101
|
+
* detectAgentType("/tmp/random.jsonl")
|
|
102
|
+
* // => null
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export function detectAgentType(filePath: string): AgentType | null {
|
|
106
|
+
for (const { pattern, agentType } of AGENT_PATH_PATTERNS) {
|
|
107
|
+
if (pattern.test(filePath)) {
|
|
108
|
+
return agentType;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Indexing Module
|
|
3
|
+
*
|
|
4
|
+
* Provides agent session discovery and indexing capabilities.
|
|
5
|
+
* Part of the CASS Inhousing initiative (ADR-010).
|
|
6
|
+
*
|
|
7
|
+
* @module sessions
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
detectAgentType,
|
|
12
|
+
loadAgentPatterns,
|
|
13
|
+
resetAgentPatterns,
|
|
14
|
+
type AgentType,
|
|
15
|
+
} from "./agent-discovery";
|