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/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
$ bun build ./src/index.ts --outdir ./dist --target node --external @electric-sql/pglite --external swarm-mail --external vitest --external @vitest/ui --external lightningcss && bun build ./src/plugin.ts --outfile ./dist/plugin.js --target node --external @electric-sql/pglite --external swarm-mail --external vitest --external @vitest/ui --external lightningcss && tsc
|
|
2
|
-
Bundled
|
|
2
|
+
Bundled 1350 modules in 208ms
|
|
3
3
|
|
|
4
4
|
index.js 4.34 MB (entry point)
|
|
5
5
|
|
|
6
|
-
Bundled
|
|
6
|
+
Bundled 1351 modules in 192ms
|
|
7
7
|
|
|
8
8
|
plugin.js 4.31 MB (entry point)
|
|
9
9
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# opencode-swarm-plugin
|
|
2
2
|
|
|
3
|
+
## 0.44.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`5c13dcf`](https://github.com/joelhooks/swarm-tools/commit/5c13dcf02ca0613199dbc84c5809bf8b9d57d3d1) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🎯 New Tool: `contributor_lookup`
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌────────────────────────────────────────────────┐
|
|
11
|
+
│ GitHub Profile → Changeset Credit Line │
|
|
12
|
+
│ │
|
|
13
|
+
│ @bcheung → Thanks to Brian Cheung │
|
|
14
|
+
│ twitter: ... → ([@justBCheung](x.com/)) │
|
|
15
|
+
│ → for reporting #53! │
|
|
16
|
+
└────────────────────────────────────────────────┘
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Workers can now call `contributor_lookup(login, issue)` to automatically:
|
|
20
|
+
|
|
21
|
+
1. Fetch GitHub profile (name, twitter, bio)
|
|
22
|
+
2. Get a ready-to-paste changeset credit line
|
|
23
|
+
3. Store contributor info in semantic-memory
|
|
24
|
+
|
|
25
|
+
**Usage:**
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
contributor_lookup({ login: "bcheung", issue: 53 });
|
|
29
|
+
// → "Thanks to Brian Cheung ([@justBCheung](https://x.com/justBCheung)) for reporting #53!"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
No more forgetting to credit contributors properly. The tool handles fallbacks when twitter/name is missing.
|
|
33
|
+
|
|
3
34
|
## 0.43.0
|
|
4
35
|
|
|
5
36
|
### Minor Changes
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* CASS Binary Characterization Tests
|
|
4
|
+
*
|
|
5
|
+
* These tests capture the CURRENT behavior of the CASS binary tools.
|
|
6
|
+
* They document WHAT the binary DOES, not what it SHOULD do.
|
|
7
|
+
*
|
|
8
|
+
* Purpose: Enable safe refactoring during ADR-010 (CASS inhousing).
|
|
9
|
+
* Our inhouse implementation must match these behaviors exactly.
|
|
10
|
+
*
|
|
11
|
+
* Pattern: Feathers Characterization Testing
|
|
12
|
+
* 1. Write a test you KNOW will fail
|
|
13
|
+
* 2. Run it - let the failure tell you actual behavior
|
|
14
|
+
* 3. Change the test to expect actual behavior
|
|
15
|
+
* 4. Repeat until you've characterized the code
|
|
16
|
+
*
|
|
17
|
+
* DO NOT modify these tests to match desired behavior.
|
|
18
|
+
* These are BASELINE tests - they verify behaviors ARE present.
|
|
19
|
+
*/
|
|
20
|
+
import { describe, test, expect } from "bun:test";
|
|
21
|
+
import { $ } from "bun";
|
|
22
|
+
import {
|
|
23
|
+
cassStatsBaseline,
|
|
24
|
+
cassSearchBaseline,
|
|
25
|
+
cassHealthHumanBaseline,
|
|
26
|
+
cassStatsHumanBaseline,
|
|
27
|
+
cassViewBaseline,
|
|
28
|
+
cassErrorBaseline,
|
|
29
|
+
type CassStatsResponse,
|
|
30
|
+
type CassSearchResponse,
|
|
31
|
+
} from "../evals/fixtures/cass-baseline.ts";
|
|
32
|
+
|
|
33
|
+
describe("CASS Binary - cass stats", () => {
|
|
34
|
+
test("JSON output structure matches baseline", async () => {
|
|
35
|
+
// CHARACTERIZATION: This documents the actual JSON structure
|
|
36
|
+
const result = await $`cass stats --json`.quiet().json();
|
|
37
|
+
|
|
38
|
+
// Verify top-level structure
|
|
39
|
+
expect(result).toHaveProperty("by_agent");
|
|
40
|
+
expect(result).toHaveProperty("conversations");
|
|
41
|
+
expect(result).toHaveProperty("date_range");
|
|
42
|
+
expect(result).toHaveProperty("db_path");
|
|
43
|
+
expect(result).toHaveProperty("messages");
|
|
44
|
+
expect(result).toHaveProperty("top_workspaces");
|
|
45
|
+
|
|
46
|
+
// Verify by_agent structure
|
|
47
|
+
expect(Array.isArray(result.by_agent)).toBe(true);
|
|
48
|
+
if (result.by_agent.length > 0) {
|
|
49
|
+
const firstAgent = result.by_agent[0];
|
|
50
|
+
expect(firstAgent).toHaveProperty("agent");
|
|
51
|
+
expect(firstAgent).toHaveProperty("count");
|
|
52
|
+
expect(typeof firstAgent.agent).toBe("string");
|
|
53
|
+
expect(typeof firstAgent.count).toBe("number");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Verify date_range structure
|
|
57
|
+
expect(result.date_range).toHaveProperty("newest");
|
|
58
|
+
expect(result.date_range).toHaveProperty("oldest");
|
|
59
|
+
expect(typeof result.date_range.newest).toBe("string");
|
|
60
|
+
expect(typeof result.date_range.oldest).toBe("string");
|
|
61
|
+
|
|
62
|
+
// Verify top_workspaces structure
|
|
63
|
+
expect(Array.isArray(result.top_workspaces)).toBe(true);
|
|
64
|
+
if (result.top_workspaces.length > 0) {
|
|
65
|
+
const firstWorkspace = result.top_workspaces[0];
|
|
66
|
+
expect(firstWorkspace).toHaveProperty("count");
|
|
67
|
+
expect(firstWorkspace).toHaveProperty("workspace");
|
|
68
|
+
expect(typeof firstWorkspace.count).toBe("number");
|
|
69
|
+
expect(typeof firstWorkspace.workspace).toBe("string");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Verify numeric fields are numbers
|
|
73
|
+
expect(typeof result.conversations).toBe("number");
|
|
74
|
+
expect(typeof result.messages).toBe("number");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("human-readable output format matches baseline", async () => {
|
|
78
|
+
// CHARACTERIZATION: This documents the actual human-readable format
|
|
79
|
+
const result = await $`cass stats`.quiet().text();
|
|
80
|
+
|
|
81
|
+
// Verify presence of key sections (order matters)
|
|
82
|
+
expect(result).toContain("CASS Index Statistics");
|
|
83
|
+
expect(result).toContain("Database:");
|
|
84
|
+
expect(result).toContain("Totals:");
|
|
85
|
+
expect(result).toContain("Conversations:");
|
|
86
|
+
expect(result).toContain("Messages:");
|
|
87
|
+
expect(result).toContain("By Agent:");
|
|
88
|
+
expect(result).toContain("Top Workspaces:");
|
|
89
|
+
expect(result).toContain("Date Range:");
|
|
90
|
+
|
|
91
|
+
// Verify format patterns
|
|
92
|
+
expect(result).toMatch(/Conversations: \d+/);
|
|
93
|
+
expect(result).toMatch(/Messages: \d+/);
|
|
94
|
+
expect(result).toMatch(/\w+: \d+/); // Agent counts
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe("CASS Binary - cass search", () => {
|
|
99
|
+
test("JSON output structure matches baseline", async () => {
|
|
100
|
+
// CHARACTERIZATION: This documents the actual search response structure
|
|
101
|
+
const result = await $`cass search "test" --limit 2 --json`.quiet().json();
|
|
102
|
+
|
|
103
|
+
// Verify top-level structure
|
|
104
|
+
expect(result).toHaveProperty("count");
|
|
105
|
+
expect(result).toHaveProperty("cursor");
|
|
106
|
+
expect(result).toHaveProperty("hits");
|
|
107
|
+
expect(result).toHaveProperty("hits_clamped");
|
|
108
|
+
expect(result).toHaveProperty("limit");
|
|
109
|
+
expect(result).toHaveProperty("max_tokens");
|
|
110
|
+
expect(result).toHaveProperty("offset");
|
|
111
|
+
expect(result).toHaveProperty("query");
|
|
112
|
+
expect(result).toHaveProperty("request_id");
|
|
113
|
+
expect(result).toHaveProperty("total_matches");
|
|
114
|
+
|
|
115
|
+
// Verify types
|
|
116
|
+
expect(typeof result.count).toBe("number");
|
|
117
|
+
expect(typeof result.hits_clamped).toBe("boolean");
|
|
118
|
+
expect(typeof result.limit).toBe("number");
|
|
119
|
+
expect(typeof result.offset).toBe("number");
|
|
120
|
+
expect(typeof result.query).toBe("string");
|
|
121
|
+
expect(typeof result.total_matches).toBe("number");
|
|
122
|
+
expect(Array.isArray(result.hits)).toBe(true);
|
|
123
|
+
|
|
124
|
+
// Verify hit structure (if any hits returned)
|
|
125
|
+
if (result.hits.length > 0) {
|
|
126
|
+
const firstHit = result.hits[0];
|
|
127
|
+
expect(firstHit).toHaveProperty("agent");
|
|
128
|
+
expect(firstHit).toHaveProperty("content");
|
|
129
|
+
expect(firstHit).toHaveProperty("created_at");
|
|
130
|
+
expect(firstHit).toHaveProperty("line_number");
|
|
131
|
+
expect(firstHit).toHaveProperty("match_type");
|
|
132
|
+
expect(firstHit).toHaveProperty("score");
|
|
133
|
+
expect(firstHit).toHaveProperty("snippet");
|
|
134
|
+
expect(firstHit).toHaveProperty("source_path");
|
|
135
|
+
expect(firstHit).toHaveProperty("title");
|
|
136
|
+
expect(firstHit).toHaveProperty("workspace");
|
|
137
|
+
|
|
138
|
+
expect(typeof firstHit.agent).toBe("string");
|
|
139
|
+
expect(typeof firstHit.content).toBe("string");
|
|
140
|
+
expect(typeof firstHit.created_at).toBe("number");
|
|
141
|
+
expect(typeof firstHit.line_number).toBe("number");
|
|
142
|
+
expect(typeof firstHit.match_type).toBe("string");
|
|
143
|
+
expect(typeof firstHit.score).toBe("number");
|
|
144
|
+
expect(typeof firstHit.snippet).toBe("string");
|
|
145
|
+
expect(typeof firstHit.source_path).toBe("string");
|
|
146
|
+
expect(typeof firstHit.title).toBe("string");
|
|
147
|
+
expect(typeof firstHit.workspace).toBe("string");
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("query parameter is preserved in response", async () => {
|
|
152
|
+
// CHARACTERIZATION: Query echoed back in response
|
|
153
|
+
const testQuery = "characterization-test-query-12345";
|
|
154
|
+
const result = await $`cass search "${testQuery}" --json`.quiet().json();
|
|
155
|
+
|
|
156
|
+
expect(result.query).toBe(testQuery);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("limit parameter is respected", async () => {
|
|
160
|
+
// CHARACTERIZATION: Limit controls max hits returned
|
|
161
|
+
const result = await $`cass search "test" --limit 3 --json`.quiet().json();
|
|
162
|
+
|
|
163
|
+
expect(result.limit).toBe(3);
|
|
164
|
+
if (result.hits.length > 0) {
|
|
165
|
+
expect(result.hits.length).toBeLessThanOrEqual(3);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("empty results include suggestions field", async () => {
|
|
170
|
+
// CHARACTERIZATION: Empty results return suggestions
|
|
171
|
+
const result =
|
|
172
|
+
await $`cass search "xyzzy-nonexistent-term-99999" --json`.quiet().json();
|
|
173
|
+
|
|
174
|
+
if (result.total_matches === 0) {
|
|
175
|
+
// Empty results may include suggestions (optional feature)
|
|
176
|
+
// Just verify structure if present
|
|
177
|
+
if (result.suggestions) {
|
|
178
|
+
expect(Array.isArray(result.suggestions)).toBe(true);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe("CASS Binary - cass health", () => {
|
|
185
|
+
test("health check returns status indicator", async () => {
|
|
186
|
+
// CHARACTERIZATION: Health check outputs status with timing
|
|
187
|
+
const result = await $`cass health`.quiet().text();
|
|
188
|
+
|
|
189
|
+
// Should contain status indicator (✓ or ✗)
|
|
190
|
+
const hasHealthyIndicator = result.includes("✓ Healthy");
|
|
191
|
+
const hasUnhealthyIndicator = result.includes("✗");
|
|
192
|
+
|
|
193
|
+
expect(hasHealthyIndicator || hasUnhealthyIndicator).toBe(true);
|
|
194
|
+
|
|
195
|
+
// Should include timing information
|
|
196
|
+
if (hasHealthyIndicator) {
|
|
197
|
+
expect(result).toMatch(/\(\d+ms\)/);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("health check may include staleness note", async () => {
|
|
202
|
+
// CHARACTERIZATION: May warn about stale index
|
|
203
|
+
const result = await $`cass health`.quiet().text();
|
|
204
|
+
|
|
205
|
+
// If index is stale, should mention it
|
|
206
|
+
// This is conditional - test just verifies format if present
|
|
207
|
+
if (result.includes("stale")) {
|
|
208
|
+
expect(result).toContain("Note:");
|
|
209
|
+
expect(result).toMatch(/older than \d+s/);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("health check exits with code 0 when healthy", async () => {
|
|
214
|
+
// CHARACTERIZATION: Exit code 0 = healthy
|
|
215
|
+
const proc = Bun.spawn(["cass", "health"], {
|
|
216
|
+
stdout: "pipe",
|
|
217
|
+
stderr: "pipe",
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const exitCode = await proc.exited;
|
|
221
|
+
// Exit code 0 means healthy (even if stale)
|
|
222
|
+
// Exit code 3 means missing index
|
|
223
|
+
expect([0, 3]).toContain(exitCode);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
describe("CASS Binary - cass view", () => {
|
|
228
|
+
test("view output includes file path header", async () => {
|
|
229
|
+
// CHARACTERIZATION: View starts with file path
|
|
230
|
+
// We can only test this if session files exist
|
|
231
|
+
const sessionFiles = await $`ls ~/.config/swarm-tools/sessions/*.jsonl`
|
|
232
|
+
.quiet()
|
|
233
|
+
.text()
|
|
234
|
+
.catch(() => "");
|
|
235
|
+
|
|
236
|
+
if (sessionFiles.trim()) {
|
|
237
|
+
const firstFile = sessionFiles.split("\n")[0].trim();
|
|
238
|
+
const result = await $`cass view ${firstFile} -n 1`.quiet().text();
|
|
239
|
+
|
|
240
|
+
expect(result).toContain(`File: ${firstFile}`);
|
|
241
|
+
expect(result).toContain("Line: 1");
|
|
242
|
+
expect(result).toContain("context:");
|
|
243
|
+
expect(result).toContain("----------------------------------------");
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("view output shows line numbers with content", async () => {
|
|
248
|
+
// CHARACTERIZATION: Lines prefixed with numbers
|
|
249
|
+
const sessionFiles = await $`ls ~/.config/swarm-tools/sessions/*.jsonl`
|
|
250
|
+
.quiet()
|
|
251
|
+
.text()
|
|
252
|
+
.catch(() => "");
|
|
253
|
+
|
|
254
|
+
if (sessionFiles.trim()) {
|
|
255
|
+
const firstFile = sessionFiles.split("\n")[0].trim();
|
|
256
|
+
const result = await $`cass view ${firstFile} -n 1`.quiet().text();
|
|
257
|
+
|
|
258
|
+
// Target line marked with >
|
|
259
|
+
expect(result).toMatch(/>\s+\d+\s+\|/);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test("view with non-existent file returns error", async () => {
|
|
264
|
+
// CHARACTERIZATION: File not found error structure
|
|
265
|
+
const result = await $`cass view /nonexistent/path.jsonl -n 1 --json`
|
|
266
|
+
.quiet()
|
|
267
|
+
.json()
|
|
268
|
+
.catch((e) => JSON.parse(e.stderr.toString()));
|
|
269
|
+
|
|
270
|
+
expect(result).toHaveProperty("error");
|
|
271
|
+
expect(result.error).toHaveProperty("code");
|
|
272
|
+
expect(result.error).toHaveProperty("kind");
|
|
273
|
+
expect(result.error).toHaveProperty("message");
|
|
274
|
+
expect(result.error).toHaveProperty("retryable");
|
|
275
|
+
|
|
276
|
+
expect(result.error.code).toBe(3);
|
|
277
|
+
expect(result.error.kind).toBe("file-not-found");
|
|
278
|
+
expect(result.error.retryable).toBe(false);
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
describe("CASS Binary - Error handling", () => {
|
|
283
|
+
test("invalid arguments return usage error with hints", async () => {
|
|
284
|
+
// CHARACTERIZATION: Helpful error messages with examples
|
|
285
|
+
const proc = Bun.spawn(["cass", "stats", "--invalid-flag"], {
|
|
286
|
+
stdout: "pipe",
|
|
287
|
+
stderr: "pipe",
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
await proc.exited;
|
|
291
|
+
const stderr = await new Response(proc.stderr).text();
|
|
292
|
+
|
|
293
|
+
// Should contain helpful error information
|
|
294
|
+
expect(stderr).toBeTruthy();
|
|
295
|
+
// Typically shows usage or suggests --help
|
|
296
|
+
expect(stderr.toLowerCase()).toMatch(/usage|help|invalid|unexpected/);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test("error responses include exit codes", async () => {
|
|
300
|
+
// CHARACTERIZATION: Exit codes documented in baseline
|
|
301
|
+
// Code 2 = usage error
|
|
302
|
+
// Code 3 = missing file/db
|
|
303
|
+
// Code 0 = success
|
|
304
|
+
|
|
305
|
+
const procInvalidArg = Bun.spawn(["cass", "stats", "--invalid-flag"], {
|
|
306
|
+
stdout: "pipe",
|
|
307
|
+
stderr: "pipe",
|
|
308
|
+
});
|
|
309
|
+
const exitCodeInvalid = await procInvalidArg.exited;
|
|
310
|
+
expect(exitCodeInvalid).toBe(2); // Usage error
|
|
311
|
+
|
|
312
|
+
const procSuccess = Bun.spawn(["cass", "stats", "--json"], {
|
|
313
|
+
stdout: "pipe",
|
|
314
|
+
stderr: "pipe",
|
|
315
|
+
});
|
|
316
|
+
const exitCodeSuccess = await procSuccess.exited;
|
|
317
|
+
expect([0, 3]).toContain(exitCodeSuccess); // Success or missing index
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
describe("CASS Binary - Robot mode documentation", () => {
|
|
322
|
+
test("--robot-help provides machine-readable documentation", async () => {
|
|
323
|
+
// CHARACTERIZATION: Robot help is designed for AI agents
|
|
324
|
+
const result = await $`cass --robot-help`.quiet().text();
|
|
325
|
+
|
|
326
|
+
expect(result).toContain("cass --robot-help (contract v1)");
|
|
327
|
+
expect(result).toContain("QUICKSTART (for AI agents):");
|
|
328
|
+
expect(result).toContain("TIME FILTERS:");
|
|
329
|
+
expect(result).toContain("WORKFLOW:");
|
|
330
|
+
expect(result).toContain("OUTPUT:");
|
|
331
|
+
expect(result).toContain("Exit codes:");
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
test("robot-docs subcommand exists", async () => {
|
|
335
|
+
// CHARACTERIZATION: robot-docs provides detailed docs for AI
|
|
336
|
+
const result = await $`cass robot-docs commands`.quiet().text();
|
|
337
|
+
|
|
338
|
+
// Should return command documentation (exact format may vary)
|
|
339
|
+
expect(result.length).toBeGreaterThan(0);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
describe("CASS Binary - Flag behavior", () => {
|
|
344
|
+
test("--json flag produces machine-readable output", async () => {
|
|
345
|
+
// CHARACTERIZATION: --json enables JSON mode
|
|
346
|
+
const result = await $`cass stats --json`.quiet().text();
|
|
347
|
+
|
|
348
|
+
// Should be valid JSON
|
|
349
|
+
expect(() => JSON.parse(result)).not.toThrow();
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test("--json and --robot are equivalent", async () => {
|
|
353
|
+
// CHARACTERIZATION: Both flags enable robot mode
|
|
354
|
+
const jsonResult = await $`cass search "test" --limit 1 --json`
|
|
355
|
+
.quiet()
|
|
356
|
+
.json();
|
|
357
|
+
const robotResult = await $`cass search "test" --limit 1 --robot`
|
|
358
|
+
.quiet()
|
|
359
|
+
.json();
|
|
360
|
+
|
|
361
|
+
// Both should return same structure
|
|
362
|
+
expect(jsonResult).toHaveProperty("hits");
|
|
363
|
+
expect(robotResult).toHaveProperty("hits");
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
test("limit flag controls result count", async () => {
|
|
367
|
+
// CHARACTERIZATION: --limit parameter
|
|
368
|
+
const result = await $`cass search "test" --limit 1 --json`.quiet().json();
|
|
369
|
+
|
|
370
|
+
expect(result.limit).toBe(1);
|
|
371
|
+
expect(result.hits.length).toBeLessThanOrEqual(1);
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* CHARACTERIZATION NOTES:
|
|
377
|
+
*
|
|
378
|
+
* These tests document the following CASS binary behaviors:
|
|
379
|
+
*
|
|
380
|
+
* 1. JSON Output Structure:
|
|
381
|
+
* - cass stats: by_agent[], conversations, date_range, messages, top_workspaces[]
|
|
382
|
+
* - cass search: count, cursor, hits[], limit, offset, query, total_matches
|
|
383
|
+
* - Hit objects: agent, content, created_at, line_number, score, source_path, etc.
|
|
384
|
+
*
|
|
385
|
+
* 2. Human-Readable Output:
|
|
386
|
+
* - Formatted tables with headers
|
|
387
|
+
* - Numeric statistics
|
|
388
|
+
* - Date ranges
|
|
389
|
+
*
|
|
390
|
+
* 3. Error Handling:
|
|
391
|
+
* - Exit code 0 = success
|
|
392
|
+
* - Exit code 2 = usage error
|
|
393
|
+
* - Exit code 3 = missing file/db
|
|
394
|
+
* - Error objects with code, kind, message, retryable fields
|
|
395
|
+
*
|
|
396
|
+
* 4. Robot Mode:
|
|
397
|
+
* - --json and --robot flags are equivalent
|
|
398
|
+
* - --robot-help provides AI-friendly documentation
|
|
399
|
+
* - robot-docs subcommand for detailed docs
|
|
400
|
+
*
|
|
401
|
+
* 5. Search Behavior:
|
|
402
|
+
* - Query parameter echoed in response
|
|
403
|
+
* - Limit parameter controls max hits
|
|
404
|
+
* - Empty results may include suggestions
|
|
405
|
+
*
|
|
406
|
+
* 6. View Behavior:
|
|
407
|
+
* - File path header
|
|
408
|
+
* - Line numbers with > indicator for target
|
|
409
|
+
* - Context window (default 5 lines)
|
|
410
|
+
* - Horizontal separators
|
|
411
|
+
*
|
|
412
|
+
* 7. Health Check:
|
|
413
|
+
* - Status indicator (✓ or ✗)
|
|
414
|
+
* - Timing in milliseconds
|
|
415
|
+
* - Optional staleness warning
|
|
416
|
+
*
|
|
417
|
+
* When implementing the inhouse version:
|
|
418
|
+
* - Match these structures exactly
|
|
419
|
+
* - Preserve field names and types
|
|
420
|
+
* - Maintain error response format
|
|
421
|
+
* - Keep exit codes consistent
|
|
422
|
+
*/
|
package/bin/swarm.test.ts
CHANGED
|
@@ -1938,6 +1938,74 @@ describe("swarm replay", () => {
|
|
|
1938
1938
|
});
|
|
1939
1939
|
});
|
|
1940
1940
|
|
|
1941
|
+
describe("swarm viz", () => {
|
|
1942
|
+
test("parses port flag", () => {
|
|
1943
|
+
function parseVizArgs(args: string[]): { port: number } {
|
|
1944
|
+
let port = 4483; // HIVE on phone keypad
|
|
1945
|
+
|
|
1946
|
+
for (let i = 0; i < args.length; i++) {
|
|
1947
|
+
if (args[i] === "--port") {
|
|
1948
|
+
const portNum = Number.parseInt(args[i + 1]);
|
|
1949
|
+
if (!isNaN(portNum) && portNum > 0) {
|
|
1950
|
+
port = portNum;
|
|
1951
|
+
}
|
|
1952
|
+
i++;
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
return { port };
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
const result = parseVizArgs(["--port", "8080"]);
|
|
1960
|
+
|
|
1961
|
+
expect(result.port).toBe(8080);
|
|
1962
|
+
});
|
|
1963
|
+
|
|
1964
|
+
test("defaults to port 4483 (HIVE)", () => {
|
|
1965
|
+
function parseVizArgs(args: string[]): { port: number } {
|
|
1966
|
+
let port = 4483;
|
|
1967
|
+
|
|
1968
|
+
for (let i = 0; i < args.length; i++) {
|
|
1969
|
+
if (args[i] === "--port") {
|
|
1970
|
+
const portNum = Number.parseInt(args[i + 1]);
|
|
1971
|
+
if (!isNaN(portNum) && portNum > 0) {
|
|
1972
|
+
port = portNum;
|
|
1973
|
+
}
|
|
1974
|
+
i++;
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
return { port };
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
const result = parseVizArgs([]);
|
|
1982
|
+
|
|
1983
|
+
expect(result.port).toBe(4483);
|
|
1984
|
+
});
|
|
1985
|
+
|
|
1986
|
+
test("ignores invalid port values", () => {
|
|
1987
|
+
function parseVizArgs(args: string[]): { port: number } {
|
|
1988
|
+
let port = 4483;
|
|
1989
|
+
|
|
1990
|
+
for (let i = 0; i < args.length; i++) {
|
|
1991
|
+
if (args[i] === "--port") {
|
|
1992
|
+
const portNum = Number.parseInt(args[i + 1]);
|
|
1993
|
+
if (!isNaN(portNum) && portNum > 0) {
|
|
1994
|
+
port = portNum;
|
|
1995
|
+
}
|
|
1996
|
+
i++;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
return { port };
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
const result = parseVizArgs(["--port", "invalid"]);
|
|
2004
|
+
|
|
2005
|
+
expect(result.port).toBe(4483); // Falls back to default
|
|
2006
|
+
});
|
|
2007
|
+
});
|
|
2008
|
+
|
|
1941
2009
|
describe("swarm export", () => {
|
|
1942
2010
|
test("parses format flag", () => {
|
|
1943
2011
|
function parseExportArgs(args: string[]): {
|
package/bin/swarm.ts
CHANGED
|
@@ -2919,6 +2919,8 @@ ${cyan("Commands:")}
|
|
|
2919
2919
|
swarm migrate Migrate PGlite database to libSQL
|
|
2920
2920
|
swarm serve Start SSE server for real-time event streaming
|
|
2921
2921
|
--port <n> Port to listen on (default: 3001)
|
|
2922
|
+
swarm viz Start dashboard server (port 4483 - HIVE on phone keypad)
|
|
2923
|
+
--port <n> Port to listen on (default: 4483)
|
|
2922
2924
|
swarm cells List or get cells from database (replaces 'swarm tool hive_query')
|
|
2923
2925
|
swarm log View swarm logs with filtering
|
|
2924
2926
|
swarm stats Show swarm health metrics powered by swarm-insights (strategy success rates, patterns)
|
|
@@ -4968,6 +4970,68 @@ async function serve() {
|
|
|
4968
4970
|
}
|
|
4969
4971
|
}
|
|
4970
4972
|
|
|
4973
|
+
// ============================================================================
|
|
4974
|
+
// Viz Command - Start Dashboard Server
|
|
4975
|
+
// ============================================================================
|
|
4976
|
+
|
|
4977
|
+
async function viz() {
|
|
4978
|
+
p.intro("swarm viz v" + VERSION);
|
|
4979
|
+
|
|
4980
|
+
// Parse --port flag (default 4483 - HIVE on phone keypad)
|
|
4981
|
+
const portFlagIndex = process.argv.indexOf("--port");
|
|
4982
|
+
const port = portFlagIndex !== -1
|
|
4983
|
+
? Number.parseInt(process.argv[portFlagIndex + 1]) || 4483
|
|
4984
|
+
: 4483;
|
|
4985
|
+
|
|
4986
|
+
const projectPath = process.cwd();
|
|
4987
|
+
|
|
4988
|
+
p.log.step("Starting dashboard server...");
|
|
4989
|
+
p.log.message(dim(` Project: ${projectPath}`));
|
|
4990
|
+
p.log.message(dim(` Port: ${port}`));
|
|
4991
|
+
|
|
4992
|
+
try {
|
|
4993
|
+
// Import dependencies
|
|
4994
|
+
const { getSwarmMailLibSQL, createHiveAdapter } = await import("swarm-mail");
|
|
4995
|
+
const { createDurableStreamAdapter, createDurableStreamServer } = await import("swarm-mail");
|
|
4996
|
+
|
|
4997
|
+
// Get swarm-mail adapter
|
|
4998
|
+
const swarmMail = await getSwarmMailLibSQL(projectPath);
|
|
4999
|
+
|
|
5000
|
+
// Create stream adapter
|
|
5001
|
+
const streamAdapter = createDurableStreamAdapter(swarmMail, projectPath);
|
|
5002
|
+
|
|
5003
|
+
// Create hive adapter for cells endpoint
|
|
5004
|
+
const db = swarmMail.db;
|
|
5005
|
+
const hiveAdapter = createHiveAdapter(db, projectPath);
|
|
5006
|
+
|
|
5007
|
+
// Create and start server
|
|
5008
|
+
const server = createDurableStreamServer({
|
|
5009
|
+
adapter: streamAdapter,
|
|
5010
|
+
hiveAdapter,
|
|
5011
|
+
port,
|
|
5012
|
+
projectKey: projectPath,
|
|
5013
|
+
});
|
|
5014
|
+
|
|
5015
|
+
await server.start();
|
|
5016
|
+
|
|
5017
|
+
p.log.success("Dashboard server running!");
|
|
5018
|
+
p.log.message("");
|
|
5019
|
+
p.log.message(cyan(` Dashboard: http://localhost:${port}`));
|
|
5020
|
+
p.log.message(cyan(` SSE endpoint: http://localhost:${port}/streams/${encodeURIComponent(projectPath)}`));
|
|
5021
|
+
p.log.message(cyan(` Cells API: http://localhost:${port}/cells`));
|
|
5022
|
+
p.log.message("");
|
|
5023
|
+
p.log.message(dim(" Press Ctrl+C to stop"));
|
|
5024
|
+
|
|
5025
|
+
// Keep process alive
|
|
5026
|
+
await new Promise(() => {});
|
|
5027
|
+
} catch (error) {
|
|
5028
|
+
p.log.error("Failed to start dashboard server");
|
|
5029
|
+
p.log.message(error instanceof Error ? error.message : String(error));
|
|
5030
|
+
p.outro("Aborted");
|
|
5031
|
+
process.exit(1);
|
|
5032
|
+
}
|
|
5033
|
+
}
|
|
5034
|
+
|
|
4971
5035
|
// ============================================================================
|
|
4972
5036
|
// Main
|
|
4973
5037
|
// ============================================================================
|
|
@@ -4993,6 +5057,9 @@ switch (command) {
|
|
|
4993
5057
|
case "serve":
|
|
4994
5058
|
await serve();
|
|
4995
5059
|
break;
|
|
5060
|
+
case "viz":
|
|
5061
|
+
await viz();
|
|
5062
|
+
break;
|
|
4996
5063
|
case "update":
|
|
4997
5064
|
await update();
|
|
4998
5065
|
break;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contributor Tools - GitHub profile extraction for changeset credits
|
|
3
|
+
*
|
|
4
|
+
* Provides contributor_lookup tool for fetching GitHub profiles and
|
|
5
|
+
* generating formatted changeset credit lines. Automatically stores
|
|
6
|
+
* contributor info in semantic-memory for future reference.
|
|
7
|
+
*
|
|
8
|
+
* Based on patterns from gh-issue-triage skill.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
/**
|
|
12
|
+
* Reset cache for testing
|
|
13
|
+
*/
|
|
14
|
+
export declare function resetContributorCache(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Look up GitHub contributor and generate changeset credit
|
|
17
|
+
*/
|
|
18
|
+
export declare const contributor_lookup: {
|
|
19
|
+
description: string;
|
|
20
|
+
args: {
|
|
21
|
+
login: z.ZodString;
|
|
22
|
+
issue: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
};
|
|
24
|
+
execute(args: {
|
|
25
|
+
login: string;
|
|
26
|
+
issue?: number | undefined;
|
|
27
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
28
|
+
};
|
|
29
|
+
export declare const contributorTools: {
|
|
30
|
+
readonly contributor_lookup: {
|
|
31
|
+
description: string;
|
|
32
|
+
args: {
|
|
33
|
+
login: z.ZodString;
|
|
34
|
+
issue: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
};
|
|
36
|
+
execute(args: {
|
|
37
|
+
login: string;
|
|
38
|
+
issue?: number | undefined;
|
|
39
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=contributor-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contributor-tools.d.ts","sourceRoot":"","sources":["../src/contributor-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuHxB;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAMD;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;CAgD7B,CAAC;AAMH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;CAEnB,CAAC"}
|