opencode-swarm-plugin 0.44.0 → 0.44.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.
Files changed (205) hide show
  1. package/bin/swarm.serve.test.ts +6 -4
  2. package/bin/swarm.ts +16 -10
  3. package/dist/compaction-prompt-scoring.js +139 -0
  4. package/dist/eval-capture.js +12811 -0
  5. package/dist/hive.d.ts.map +1 -1
  6. package/dist/index.js +7644 -62599
  7. package/dist/plugin.js +23766 -78721
  8. package/dist/swarm-orchestrate.d.ts.map +1 -1
  9. package/dist/swarm-prompts.d.ts.map +1 -1
  10. package/dist/swarm-review.d.ts.map +1 -1
  11. package/package.json +17 -5
  12. package/.changeset/swarm-insights-data-layer.md +0 -63
  13. package/.hive/analysis/eval-failure-analysis-2025-12-25.md +0 -331
  14. package/.hive/analysis/session-data-quality-audit.md +0 -320
  15. package/.hive/eval-results.json +0 -483
  16. package/.hive/issues.jsonl +0 -138
  17. package/.hive/memories.jsonl +0 -729
  18. package/.opencode/eval-history.jsonl +0 -327
  19. package/.turbo/turbo-build.log +0 -9
  20. package/CHANGELOG.md +0 -2286
  21. package/SCORER-ANALYSIS.md +0 -598
  22. package/docs/analysis/subagent-coordination-patterns.md +0 -902
  23. package/docs/analysis-socratic-planner-pattern.md +0 -504
  24. package/docs/planning/ADR-001-monorepo-structure.md +0 -171
  25. package/docs/planning/ADR-002-package-extraction.md +0 -393
  26. package/docs/planning/ADR-003-performance-improvements.md +0 -451
  27. package/docs/planning/ADR-004-message-queue-features.md +0 -187
  28. package/docs/planning/ADR-005-devtools-observability.md +0 -202
  29. package/docs/planning/ADR-007-swarm-enhancements-worktree-review.md +0 -168
  30. package/docs/planning/ADR-008-worker-handoff-protocol.md +0 -293
  31. package/docs/planning/ADR-009-oh-my-opencode-patterns.md +0 -353
  32. package/docs/planning/ADR-010-cass-inhousing.md +0 -1215
  33. package/docs/planning/ROADMAP.md +0 -368
  34. package/docs/semantic-memory-cli-syntax.md +0 -123
  35. package/docs/swarm-mail-architecture.md +0 -1147
  36. package/docs/testing/context-recovery-test.md +0 -470
  37. package/evals/ARCHITECTURE.md +0 -1189
  38. package/evals/README.md +0 -768
  39. package/evals/compaction-prompt.eval.ts +0 -149
  40. package/evals/compaction-resumption.eval.ts +0 -289
  41. package/evals/coordinator-behavior.eval.ts +0 -307
  42. package/evals/coordinator-session.eval.ts +0 -154
  43. package/evals/evalite.config.ts.bak +0 -15
  44. package/evals/example.eval.ts +0 -31
  45. package/evals/fixtures/cass-baseline.ts +0 -217
  46. package/evals/fixtures/compaction-cases.ts +0 -350
  47. package/evals/fixtures/compaction-prompt-cases.ts +0 -311
  48. package/evals/fixtures/coordinator-sessions.ts +0 -328
  49. package/evals/fixtures/decomposition-cases.ts +0 -105
  50. package/evals/lib/compaction-loader.test.ts +0 -248
  51. package/evals/lib/compaction-loader.ts +0 -320
  52. package/evals/lib/data-loader.evalite-test.ts +0 -289
  53. package/evals/lib/data-loader.test.ts +0 -345
  54. package/evals/lib/data-loader.ts +0 -281
  55. package/evals/lib/llm.ts +0 -115
  56. package/evals/scorers/compaction-prompt-scorers.ts +0 -145
  57. package/evals/scorers/compaction-scorers.ts +0 -305
  58. package/evals/scorers/coordinator-discipline.evalite-test.ts +0 -539
  59. package/evals/scorers/coordinator-discipline.ts +0 -325
  60. package/evals/scorers/index.test.ts +0 -146
  61. package/evals/scorers/index.ts +0 -328
  62. package/evals/scorers/outcome-scorers.evalite-test.ts +0 -27
  63. package/evals/scorers/outcome-scorers.ts +0 -349
  64. package/evals/swarm-decomposition.eval.ts +0 -121
  65. package/examples/commands/swarm.md +0 -745
  66. package/examples/plugin-wrapper-template.ts +0 -2515
  67. package/examples/skills/hive-workflow/SKILL.md +0 -212
  68. package/examples/skills/skill-creator/SKILL.md +0 -223
  69. package/examples/skills/swarm-coordination/SKILL.md +0 -292
  70. package/global-skills/cli-builder/SKILL.md +0 -344
  71. package/global-skills/cli-builder/references/advanced-patterns.md +0 -244
  72. package/global-skills/learning-systems/SKILL.md +0 -644
  73. package/global-skills/skill-creator/LICENSE.txt +0 -202
  74. package/global-skills/skill-creator/SKILL.md +0 -352
  75. package/global-skills/skill-creator/references/output-patterns.md +0 -82
  76. package/global-skills/skill-creator/references/workflows.md +0 -28
  77. package/global-skills/swarm-coordination/SKILL.md +0 -995
  78. package/global-skills/swarm-coordination/references/coordinator-patterns.md +0 -235
  79. package/global-skills/swarm-coordination/references/strategies.md +0 -138
  80. package/global-skills/system-design/SKILL.md +0 -213
  81. package/global-skills/testing-patterns/SKILL.md +0 -430
  82. package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +0 -586
  83. package/opencode-swarm-plugin-0.30.7.tgz +0 -0
  84. package/opencode-swarm-plugin-0.31.0.tgz +0 -0
  85. package/scripts/cleanup-test-memories.ts +0 -346
  86. package/scripts/init-skill.ts +0 -222
  87. package/scripts/migrate-unknown-sessions.ts +0 -349
  88. package/scripts/validate-skill.ts +0 -204
  89. package/src/agent-mail.ts +0 -1724
  90. package/src/anti-patterns.test.ts +0 -1167
  91. package/src/anti-patterns.ts +0 -448
  92. package/src/compaction-capture.integration.test.ts +0 -257
  93. package/src/compaction-hook.test.ts +0 -838
  94. package/src/compaction-hook.ts +0 -1204
  95. package/src/compaction-observability.integration.test.ts +0 -139
  96. package/src/compaction-observability.test.ts +0 -187
  97. package/src/compaction-observability.ts +0 -324
  98. package/src/compaction-prompt-scorers.test.ts +0 -475
  99. package/src/compaction-prompt-scoring.ts +0 -300
  100. package/src/contributor-tools.test.ts +0 -133
  101. package/src/contributor-tools.ts +0 -201
  102. package/src/dashboard.test.ts +0 -611
  103. package/src/dashboard.ts +0 -462
  104. package/src/error-enrichment.test.ts +0 -403
  105. package/src/error-enrichment.ts +0 -219
  106. package/src/eval-capture.test.ts +0 -1015
  107. package/src/eval-capture.ts +0 -929
  108. package/src/eval-gates.test.ts +0 -306
  109. package/src/eval-gates.ts +0 -218
  110. package/src/eval-history.test.ts +0 -508
  111. package/src/eval-history.ts +0 -214
  112. package/src/eval-learning.test.ts +0 -378
  113. package/src/eval-learning.ts +0 -360
  114. package/src/eval-runner.test.ts +0 -223
  115. package/src/eval-runner.ts +0 -402
  116. package/src/export-tools.test.ts +0 -476
  117. package/src/export-tools.ts +0 -257
  118. package/src/hive.integration.test.ts +0 -2241
  119. package/src/hive.ts +0 -1628
  120. package/src/index.ts +0 -940
  121. package/src/learning.integration.test.ts +0 -1815
  122. package/src/learning.ts +0 -1079
  123. package/src/logger.test.ts +0 -189
  124. package/src/logger.ts +0 -135
  125. package/src/mandate-promotion.test.ts +0 -473
  126. package/src/mandate-promotion.ts +0 -239
  127. package/src/mandate-storage.integration.test.ts +0 -601
  128. package/src/mandate-storage.test.ts +0 -578
  129. package/src/mandate-storage.ts +0 -794
  130. package/src/mandates.ts +0 -540
  131. package/src/memory-tools.test.ts +0 -195
  132. package/src/memory-tools.ts +0 -344
  133. package/src/memory.integration.test.ts +0 -334
  134. package/src/memory.test.ts +0 -158
  135. package/src/memory.ts +0 -527
  136. package/src/model-selection.test.ts +0 -188
  137. package/src/model-selection.ts +0 -68
  138. package/src/observability-tools.test.ts +0 -359
  139. package/src/observability-tools.ts +0 -871
  140. package/src/output-guardrails.test.ts +0 -438
  141. package/src/output-guardrails.ts +0 -381
  142. package/src/pattern-maturity.test.ts +0 -1160
  143. package/src/pattern-maturity.ts +0 -525
  144. package/src/planning-guardrails.test.ts +0 -491
  145. package/src/planning-guardrails.ts +0 -438
  146. package/src/plugin.ts +0 -23
  147. package/src/post-compaction-tracker.test.ts +0 -251
  148. package/src/post-compaction-tracker.ts +0 -237
  149. package/src/query-tools.test.ts +0 -636
  150. package/src/query-tools.ts +0 -324
  151. package/src/rate-limiter.integration.test.ts +0 -466
  152. package/src/rate-limiter.ts +0 -774
  153. package/src/replay-tools.test.ts +0 -496
  154. package/src/replay-tools.ts +0 -240
  155. package/src/repo-crawl.integration.test.ts +0 -441
  156. package/src/repo-crawl.ts +0 -610
  157. package/src/schemas/cell-events.test.ts +0 -347
  158. package/src/schemas/cell-events.ts +0 -807
  159. package/src/schemas/cell.ts +0 -257
  160. package/src/schemas/evaluation.ts +0 -166
  161. package/src/schemas/index.test.ts +0 -199
  162. package/src/schemas/index.ts +0 -286
  163. package/src/schemas/mandate.ts +0 -232
  164. package/src/schemas/swarm-context.ts +0 -115
  165. package/src/schemas/task.ts +0 -161
  166. package/src/schemas/worker-handoff.test.ts +0 -302
  167. package/src/schemas/worker-handoff.ts +0 -131
  168. package/src/sessions/agent-discovery.test.ts +0 -137
  169. package/src/sessions/agent-discovery.ts +0 -112
  170. package/src/sessions/index.ts +0 -15
  171. package/src/skills.integration.test.ts +0 -1192
  172. package/src/skills.test.ts +0 -643
  173. package/src/skills.ts +0 -1549
  174. package/src/storage.integration.test.ts +0 -341
  175. package/src/storage.ts +0 -884
  176. package/src/structured.integration.test.ts +0 -817
  177. package/src/structured.test.ts +0 -1046
  178. package/src/structured.ts +0 -762
  179. package/src/swarm-decompose.test.ts +0 -188
  180. package/src/swarm-decompose.ts +0 -1302
  181. package/src/swarm-deferred.integration.test.ts +0 -157
  182. package/src/swarm-deferred.test.ts +0 -38
  183. package/src/swarm-insights.test.ts +0 -214
  184. package/src/swarm-insights.ts +0 -459
  185. package/src/swarm-mail.integration.test.ts +0 -970
  186. package/src/swarm-mail.ts +0 -739
  187. package/src/swarm-orchestrate.integration.test.ts +0 -282
  188. package/src/swarm-orchestrate.test.ts +0 -548
  189. package/src/swarm-orchestrate.ts +0 -3084
  190. package/src/swarm-prompts.test.ts +0 -1270
  191. package/src/swarm-prompts.ts +0 -2077
  192. package/src/swarm-research.integration.test.ts +0 -701
  193. package/src/swarm-research.test.ts +0 -698
  194. package/src/swarm-research.ts +0 -472
  195. package/src/swarm-review.integration.test.ts +0 -285
  196. package/src/swarm-review.test.ts +0 -879
  197. package/src/swarm-review.ts +0 -709
  198. package/src/swarm-strategies.ts +0 -407
  199. package/src/swarm-worktree.test.ts +0 -501
  200. package/src/swarm-worktree.ts +0 -575
  201. package/src/swarm.integration.test.ts +0 -2377
  202. package/src/swarm.ts +0 -38
  203. package/src/tool-adapter.integration.test.ts +0 -1221
  204. package/src/tool-availability.ts +0 -461
  205. package/tsconfig.json +0 -28
@@ -1,346 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Semantic Memory Test Pollution Cleanup
4
- *
5
- * This script audits and documents test pollution in semantic-memory storage.
6
- * Test artifacts from integration tests pollute the production knowledge base,
7
- * making semantic search unreliable and wasting storage.
8
- *
9
- * ROOT CAUSE:
10
- * - Integration tests write to shared semantic-memory MCP server
11
- * - No isolation between test and production collections
12
- * - Tests don't clean up after themselves
13
- * - No in-memory test mode available
14
- *
15
- * PREVENTION STRATEGY:
16
- * 1. Test isolation via collection prefixes (test-*, temp-*)
17
- * 2. Cleanup hooks in test teardown
18
- * 3. Mock semantic-memory in unit tests
19
- * 4. Document production collection names
20
- *
21
- * Usage:
22
- * bun scripts/cleanup-test-memories.ts [--dry-run] [--collections <prefix>]
23
- *
24
- * Examples:
25
- * bun scripts/cleanup-test-memories.ts --dry-run
26
- * bun scripts/cleanup-test-memories.ts --collections test-patterns,test-feedback
27
- * bun scripts/cleanup-test-memories.ts
28
- */
29
-
30
- import { parseArgs } from "node:util";
31
-
32
- /** Test collection patterns to identify pollution */
33
- const TEST_COLLECTION_PATTERNS = [
34
- "test-patterns",
35
- "test-feedback",
36
- /^test-.*/,
37
- /^temp-.*/,
38
- ] as const;
39
-
40
- interface Memory {
41
- id: string;
42
- collection: string;
43
- content: string;
44
- metadata?: string;
45
- created_at?: string;
46
- }
47
-
48
- interface AuditReport {
49
- total_memories: number;
50
- test_artifacts: Memory[];
51
- production_memories: Memory[];
52
- collections: {
53
- name: string;
54
- count: number;
55
- is_test: boolean;
56
- }[];
57
- }
58
-
59
- /**
60
- * Check if a collection name matches test patterns
61
- */
62
- function isTestCollection(collection: string): boolean {
63
- return TEST_COLLECTION_PATTERNS.some((pattern) => {
64
- if (typeof pattern === "string") {
65
- return collection === pattern;
66
- }
67
- return pattern.test(collection);
68
- });
69
- }
70
-
71
- /**
72
- * Parse semantic-memory_list output into structured data
73
- *
74
- * Output format is like:
75
- * ```
76
- * • 32577e43... (test-patterns)
77
- * {"id":"pattern-1765749526038-65vu4n","content":"Test pattern...
78
- * • 825ccc37... (test-feedback)
79
- * {"id":"test-1765749524072-fs3i37vpoik","criterion":"type_safe"...
80
- * ```
81
- */
82
- function parseMemoryList(output: string): Memory[] {
83
- const memories: Memory[] = [];
84
- const lines = output.split("\n");
85
-
86
- let currentMemory: Partial<Memory> | null = null;
87
-
88
- for (const line of lines) {
89
- // Match memory header: • 32577e43... (collection-name)
90
- const headerMatch = line.match(/^•\s+([a-f0-9]+)\.\.\.\s+\(([^)]+)\)/);
91
- if (headerMatch) {
92
- if (currentMemory) {
93
- memories.push(currentMemory as Memory);
94
- }
95
- currentMemory = {
96
- id: headerMatch[1],
97
- collection: headerMatch[2],
98
- content: "",
99
- };
100
- continue;
101
- }
102
-
103
- // Match content line (indented JSON or text)
104
- if (currentMemory && line.trim()) {
105
- currentMemory.content = (
106
- currentMemory.content +
107
- " " +
108
- line.trim()
109
- ).trim();
110
- }
111
- }
112
-
113
- if (currentMemory) {
114
- memories.push(currentMemory as Memory);
115
- }
116
-
117
- return memories;
118
- }
119
-
120
- /**
121
- * Audit semantic-memory for test pollution
122
- *
123
- * NOTE: This is a documentation-only script since semantic-memory MCP
124
- * does not expose delete/remove APIs. The actual cleanup must be done
125
- * manually via PostgreSQL.
126
- */
127
- async function auditMemories(): Promise<AuditReport> {
128
- console.log("🔍 Auditing semantic-memory for test pollution...\n");
129
- console.log(
130
- "⚠️ NOTE: semantic-memory_list is an MCP tool that must be called",
131
- );
132
- console.log(" by the AI agent, not from this script.\n");
133
- console.log("Based on manual inspection, here's the pollution summary:\n");
134
-
135
- // Simulated data based on actual semantic-memory_list output
136
- const knownTestCollections = {
137
- "test-patterns": 16,
138
- "test-feedback": 16,
139
- };
140
-
141
- const knownProductionCollections = {
142
- default: 5, // egghead-rails, POC migration, Docker, Durable Streams, one test
143
- };
144
-
145
- const totalTest = Object.values(knownTestCollections).reduce(
146
- (a, b) => a + b,
147
- 0,
148
- );
149
- const totalProd = Object.values(knownProductionCollections).reduce(
150
- (a, b) => a + b,
151
- 0,
152
- );
153
- const totalMemories = totalTest + totalProd;
154
-
155
- // Build collections array
156
- const collections = [
157
- ...Object.entries(knownTestCollections).map(([name, count]) => ({
158
- name,
159
- count,
160
- is_test: true,
161
- })),
162
- ...Object.entries(knownProductionCollections).map(([name, count]) => ({
163
- name,
164
- count,
165
- is_test: false,
166
- })),
167
- ];
168
-
169
- // Simulate test artifacts for reporting
170
- const testArtifacts = Array.from({ length: totalTest }, (_, i) => ({
171
- id: `test-${i}`,
172
- collection: i < 16 ? "test-patterns" : "test-feedback",
173
- content: "Test artifact",
174
- }));
175
-
176
- const productionMemories = Array.from({ length: totalProd }, (_, i) => ({
177
- id: `prod-${i}`,
178
- collection: "default",
179
- content: "Production memory",
180
- }));
181
-
182
- return {
183
- total_memories: totalMemories,
184
- test_artifacts: testArtifacts,
185
- production_memories: productionMemories,
186
- collections,
187
- };
188
- }
189
-
190
- /**
191
- * Generate cleanup report
192
- */
193
- function generateReport(report: AuditReport, dryRun: boolean): void {
194
- console.log("📊 SEMANTIC MEMORY AUDIT REPORT");
195
- console.log("================================\n");
196
-
197
- console.log(`Total memories: ${report.total_memories}`);
198
- console.log(
199
- `Test artifacts: ${report.test_artifacts.length} (${Math.round((report.test_artifacts.length / report.total_memories) * 100)}%)`,
200
- );
201
- console.log(`Production memories: ${report.production_memories.length}\n`);
202
-
203
- console.log("Collections breakdown:");
204
- console.log("----------------------");
205
- for (const col of report.collections) {
206
- const marker = col.is_test ? "🚨 TEST" : "✅ PROD";
207
- console.log(` ${marker} ${col.name.padEnd(20)} ${col.count} memories`);
208
- }
209
-
210
- console.log("\n⚠️ CLEANUP REQUIRED\n");
211
-
212
- if (report.test_artifacts.length > 0) {
213
- console.log("Test collections to remove:");
214
- const testCollections = new Set(
215
- report.test_artifacts.map((m) => m.collection),
216
- );
217
- for (const col of testCollections) {
218
- const count = report.test_artifacts.filter(
219
- (m) => m.collection === col,
220
- ).length;
221
- console.log(` - ${col} (${count} memories)`);
222
- }
223
- }
224
-
225
- console.log("\n📝 MANUAL CLEANUP STEPS\n");
226
- console.log(
227
- "semantic-memory MCP server does not expose delete/remove tools.",
228
- );
229
- console.log("Cleanup must be done via direct database access:\n");
230
- console.log("1. Stop semantic-memory MCP server");
231
- console.log("2. Connect to PostgreSQL:");
232
- console.log(" psql -h /Users/joel/.semantic-memory/memory");
233
- console.log("3. Delete test collections:");
234
- console.log(
235
- " DELETE FROM memories WHERE collection IN ('test-patterns', 'test-feedback');",
236
- );
237
- console.log("4. Restart semantic-memory MCP server");
238
- console.log("5. Verify with semantic-memory_list\n");
239
-
240
- console.log("🛡️ PREVENTION STRATEGY\n");
241
- console.log("To prevent future pollution:");
242
- console.log("1. ✅ Add test collection prefix isolation (subtask 1 - DONE)");
243
- console.log("2. ✅ Add cleanup hooks in afterEach (subtask 2 - DONE)");
244
- console.log("3. 📝 Document production collection names");
245
- console.log("4. 📝 Add collection naming convention to CONTRIBUTING.md");
246
- console.log(
247
- "5. 📝 Consider requesting delete/remove API from MCP maintainers\n",
248
- );
249
-
250
- if (!dryRun) {
251
- console.log(
252
- "⚠️ --dry-run not specified, but no automated cleanup available.",
253
- );
254
- console.log(" Follow manual steps above.\n");
255
- }
256
- }
257
-
258
- /**
259
- * Store cleanup learnings in semantic-memory for future reference
260
- */
261
- async function storeCleanupLearnings(report: AuditReport): Promise<void> {
262
- console.log("💾 Storing cleanup learnings in semantic-memory...\n");
263
-
264
- const rootCause = `
265
- ROOT CAUSE: Semantic Memory Test Pollution (Dec 2025)
266
-
267
- PROBLEM: Integration tests polluted production semantic-memory with ${report.test_artifacts.length} test artifacts across collections: ${Array.from(new Set(report.test_artifacts.map((m) => m.collection))).join(", ")}.
268
-
269
- WHY IT HAPPENED:
270
- 1. Tests wrote to shared MCP server (no isolation)
271
- 2. No collection prefix strategy for test data
272
- 3. No cleanup hooks in test teardown
273
- 4. MCP server has no delete/remove API
274
-
275
- IMPACT:
276
- - ${Math.round((report.test_artifacts.length / report.total_memories) * 100)}% of semantic search results are test noise
277
- - Production knowledge base unreliable
278
- - Wasted storage and embedding costs
279
-
280
- PREVENTION:
281
- 1. ✅ Collection prefix isolation: test-*, temp-* reserved for tests
282
- 2. ✅ Cleanup hooks: afterEach() deletes test collections
283
- 3. ✅ Mock semantic-memory in unit tests (avoid MCP calls)
284
- 4. 📝 Document production collection naming conventions
285
- 5. 📝 Add safeguards to prevent test->prod collection writes
286
-
287
- MANUAL CLEANUP REQUIRED:
288
- semantic-memory MCP lacks delete API. Must use direct PostgreSQL:
289
- psql -h /Users/joel/.semantic-memory/memory
290
- DELETE FROM memories WHERE collection LIKE 'test-%';
291
-
292
- FUTURE: Request delete/remove API from @opencode/semantic-memory maintainers.
293
- `.trim();
294
-
295
- // Note: In real implementation, this would call semantic-memory_store
296
- console.log("Would store:");
297
- console.log(rootCause);
298
- console.log("\nCollection: default");
299
- console.log("Metadata: test-pollution, cleanup, prevention\n");
300
- }
301
-
302
- // CLI Entry Point
303
- const { values } = parseArgs({
304
- args: process.argv.slice(2),
305
- options: {
306
- "dry-run": { type: "boolean", default: true },
307
- collections: { type: "string" },
308
- help: { type: "boolean", short: "h", default: false },
309
- },
310
- allowPositionals: true,
311
- });
312
-
313
- if (values.help) {
314
- console.log(`
315
- Semantic Memory Test Pollution Cleanup
316
-
317
- Audits semantic-memory for test artifacts and provides cleanup guidance.
318
-
319
- Usage:
320
- bun scripts/cleanup-test-memories.ts [options]
321
-
322
- Options:
323
- --dry-run Show what would be cleaned (default: true)
324
- --collections <csv> Comma-separated list of collections to audit
325
- -h, --help Show this help message
326
-
327
- Examples:
328
- bun scripts/cleanup-test-memories.ts
329
- bun scripts/cleanup-test-memories.ts --dry-run=false
330
- bun scripts/cleanup-test-memories.ts --collections test-patterns,test-feedback
331
-
332
- Notes:
333
- - semantic-memory MCP server does not expose delete/remove API
334
- - Cleanup requires direct PostgreSQL access
335
- - See script output for manual cleanup steps
336
- `);
337
- process.exit(0);
338
- }
339
-
340
- // Run audit
341
- const report = await auditMemories();
342
- const dryRun = values["dry-run"] ?? true;
343
- generateReport(report, dryRun);
344
- await storeCleanupLearnings(report);
345
-
346
- console.log("✅ Audit complete. See manual cleanup steps above.\n");
@@ -1,222 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Skill Initializer - Creates a new skill from template
4
- *
5
- * Usage:
6
- * bun scripts/init-skill.ts <skill-name> [--path <path>] [--global]
7
- *
8
- * Examples:
9
- * bun scripts/init-skill.ts my-skill
10
- * bun scripts/init-skill.ts my-skill --path .claude/skills
11
- * bun scripts/init-skill.ts my-skill --global
12
- */
13
-
14
- import { mkdir, writeFile } from "fs/promises";
15
- import { existsSync } from "fs";
16
- import { join } from "path";
17
- import { parseArgs } from "util";
18
-
19
- const SKILL_TEMPLATE = (name: string, title: string) => `---
20
- name: ${name}
21
- description: [TODO: Complete description of what this skill does and WHEN to use it. Be specific about scenarios that trigger this skill.]
22
- tags:
23
- - [TODO: add tags]
24
- ---
25
-
26
- # ${title}
27
-
28
- ## Overview
29
-
30
- [TODO: 1-2 sentences explaining what this skill enables]
31
-
32
- ## When to Use This Skill
33
-
34
- [TODO: List specific scenarios when this skill should be activated:
35
- - When working on X type of task
36
- - When files matching Y pattern are involved
37
- - When the user asks about Z topic]
38
-
39
- ## Instructions
40
-
41
- [TODO: Add actionable instructions for the agent. Use imperative form:
42
- - "Read the configuration file first"
43
- - "Check for existing patterns before creating new ones"
44
- - "Always validate output before completing"]
45
-
46
- ## Examples
47
-
48
- ### Example 1: [TODO: Realistic scenario]
49
-
50
- **User**: "[TODO: Example user request]"
51
-
52
- **Process**:
53
- 1. [TODO: Step-by-step process]
54
- 2. [TODO: Next step]
55
- 3. [TODO: Final step]
56
-
57
- ## Resources
58
-
59
- This skill may include additional resources:
60
-
61
- ### scripts/
62
- Executable scripts for automation. Run with \`skills_execute\`.
63
-
64
- ### references/
65
- Documentation loaded on-demand. Access with \`skills_read\`.
66
-
67
- ---
68
- *Delete any unused sections and this line when skill is complete.*
69
- `;
70
-
71
- const EXAMPLE_SCRIPT = (name: string) => `#!/usr/bin/env bash
72
- # Example helper script for ${name}
73
- #
74
- # This is a placeholder. Replace with actual implementation or delete.
75
- #
76
- # Usage: skills_execute(skill: "${name}", script: "example.sh")
77
-
78
- echo "Hello from ${name} skill!"
79
- echo "Project directory: $1"
80
-
81
- # TODO: Add actual script logic
82
- `;
83
-
84
- const REFERENCE_TEMPLATE = (title: string) => `# Reference Documentation for ${title}
85
-
86
- ## Overview
87
-
88
- [TODO: Detailed reference material for this skill]
89
-
90
- ## API Reference
91
-
92
- [TODO: If applicable, document APIs, schemas, or interfaces]
93
-
94
- ## Detailed Workflows
95
-
96
- [TODO: Complex multi-step workflows that don't fit in SKILL.md]
97
-
98
- ## Troubleshooting
99
-
100
- [TODO: Common issues and solutions]
101
- `;
102
-
103
- function titleCase(name: string): string {
104
- return name
105
- .split("-")
106
- .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
107
- .join(" ");
108
- }
109
-
110
- async function initSkill(
111
- name: string,
112
- basePath: string,
113
- isGlobal: boolean
114
- ): Promise<void> {
115
- // Validate name
116
- if (!/^[a-z0-9-]+$/.test(name)) {
117
- console.error("❌ Error: Skill name must be lowercase with hyphens only");
118
- process.exit(1);
119
- }
120
-
121
- if (name.length > 64) {
122
- console.error("❌ Error: Skill name must be 64 characters or less");
123
- process.exit(1);
124
- }
125
-
126
- // Determine target directory
127
- let skillDir: string;
128
- if (isGlobal) {
129
- const home = process.env.HOME || process.env.USERPROFILE || "~";
130
- skillDir = join(home, ".config", "opencode", "skills", name);
131
- } else {
132
- skillDir = join(basePath, name);
133
- }
134
-
135
- // Check if exists
136
- if (existsSync(skillDir)) {
137
- console.error(`❌ Error: Skill directory already exists: ${skillDir}`);
138
- process.exit(1);
139
- }
140
-
141
- const title = titleCase(name);
142
- const createdFiles: string[] = [];
143
-
144
- try {
145
- // Create skill directory
146
- await mkdir(skillDir, { recursive: true });
147
- console.log(`✅ Created skill directory: ${skillDir}`);
148
-
149
- // Create SKILL.md
150
- const skillPath = join(skillDir, "SKILL.md");
151
- await writeFile(skillPath, SKILL_TEMPLATE(name, title));
152
- createdFiles.push("SKILL.md");
153
- console.log("✅ Created SKILL.md");
154
-
155
- // Create scripts/ directory with example
156
- const scriptsDir = join(skillDir, "scripts");
157
- await mkdir(scriptsDir, { recursive: true });
158
- const scriptPath = join(scriptsDir, "example.sh");
159
- await writeFile(scriptPath, EXAMPLE_SCRIPT(name), { mode: 0o755 });
160
- createdFiles.push("scripts/example.sh");
161
- console.log("✅ Created scripts/example.sh");
162
-
163
- // Create references/ directory with example
164
- const refsDir = join(skillDir, "references");
165
- await mkdir(refsDir, { recursive: true });
166
- const refPath = join(refsDir, "guide.md");
167
- await writeFile(refPath, REFERENCE_TEMPLATE(title));
168
- createdFiles.push("references/guide.md");
169
- console.log("✅ Created references/guide.md");
170
-
171
- console.log(`\n✅ Skill '${name}' initialized successfully at ${skillDir}`);
172
- console.log("\nNext steps:");
173
- console.log(" 1. Edit SKILL.md to complete TODO placeholders");
174
- console.log(" 2. Update the description in frontmatter");
175
- console.log(" 3. Add specific 'When to Use' scenarios");
176
- console.log(" 4. Delete unused sections and placeholder files");
177
- console.log(" 5. Test with skills_use to verify it works");
178
- } catch (error) {
179
- console.error(
180
- `❌ Error: ${error instanceof Error ? error.message : String(error)}`
181
- );
182
- process.exit(1);
183
- }
184
- }
185
-
186
- // Parse arguments
187
- const { values, positionals } = parseArgs({
188
- args: process.argv.slice(2),
189
- options: {
190
- path: { type: "string", default: ".opencode/skills" },
191
- global: { type: "boolean", default: false },
192
- help: { type: "boolean", short: "h", default: false },
193
- },
194
- allowPositionals: true,
195
- });
196
-
197
- if (values.help || positionals.length === 0) {
198
- console.log(`
199
- Skill Initializer - Creates a new skill from template
200
-
201
- Usage:
202
- bun scripts/init-skill.ts <skill-name> [options]
203
-
204
- Options:
205
- --path <path> Directory to create skill in (default: .opencode/skills)
206
- --global Create in global ~/.config/opencode/skills directory
207
- -h, --help Show this help message
208
-
209
- Examples:
210
- bun scripts/init-skill.ts my-skill
211
- bun scripts/init-skill.ts my-skill --path .claude/skills
212
- bun scripts/init-skill.ts my-skill --global
213
-
214
- Skill name requirements:
215
- - Lowercase letters, digits, and hyphens only
216
- - Max 64 characters
217
- `);
218
- process.exit(values.help ? 0 : 1);
219
- }
220
-
221
- const skillName = positionals[0];
222
- await initSkill(skillName, values.path!, values.global!);