opencode-swarm-plugin 0.43.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.
- package/bin/cass.characterization.test.ts +422 -0
- package/bin/swarm.serve.test.ts +6 -4
- package/bin/swarm.test.ts +68 -0
- package/bin/swarm.ts +81 -8
- package/dist/compaction-prompt-scoring.js +139 -0
- package/dist/contributor-tools.d.ts +42 -0
- package/dist/contributor-tools.d.ts.map +1 -0
- package/dist/eval-capture.js +12811 -0
- package/dist/hive.d.ts.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7728 -62590
- package/dist/plugin.js +23833 -78695
- 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/dist/swarm-orchestrate.d.ts.map +1 -1
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/dist/swarm-review.d.ts.map +1 -1
- package/package.json +17 -5
- package/.changeset/swarm-insights-data-layer.md +0 -63
- package/.hive/analysis/eval-failure-analysis-2025-12-25.md +0 -331
- package/.hive/analysis/session-data-quality-audit.md +0 -320
- package/.hive/eval-results.json +0 -483
- package/.hive/issues.jsonl +0 -138
- package/.hive/memories.jsonl +0 -729
- package/.opencode/eval-history.jsonl +0 -327
- package/.turbo/turbo-build.log +0 -9
- package/CHANGELOG.md +0 -2255
- package/SCORER-ANALYSIS.md +0 -598
- package/docs/analysis/subagent-coordination-patterns.md +0 -902
- package/docs/analysis-socratic-planner-pattern.md +0 -504
- package/docs/planning/ADR-001-monorepo-structure.md +0 -171
- package/docs/planning/ADR-002-package-extraction.md +0 -393
- package/docs/planning/ADR-003-performance-improvements.md +0 -451
- package/docs/planning/ADR-004-message-queue-features.md +0 -187
- package/docs/planning/ADR-005-devtools-observability.md +0 -202
- package/docs/planning/ADR-007-swarm-enhancements-worktree-review.md +0 -168
- package/docs/planning/ADR-008-worker-handoff-protocol.md +0 -293
- package/docs/planning/ADR-009-oh-my-opencode-patterns.md +0 -353
- package/docs/planning/ROADMAP.md +0 -368
- package/docs/semantic-memory-cli-syntax.md +0 -123
- package/docs/swarm-mail-architecture.md +0 -1147
- package/docs/testing/context-recovery-test.md +0 -470
- package/evals/ARCHITECTURE.md +0 -1189
- package/evals/README.md +0 -768
- package/evals/compaction-prompt.eval.ts +0 -149
- package/evals/compaction-resumption.eval.ts +0 -289
- package/evals/coordinator-behavior.eval.ts +0 -307
- package/evals/coordinator-session.eval.ts +0 -154
- package/evals/evalite.config.ts.bak +0 -15
- package/evals/example.eval.ts +0 -31
- package/evals/fixtures/compaction-cases.ts +0 -350
- package/evals/fixtures/compaction-prompt-cases.ts +0 -311
- package/evals/fixtures/coordinator-sessions.ts +0 -328
- package/evals/fixtures/decomposition-cases.ts +0 -105
- package/evals/lib/compaction-loader.test.ts +0 -248
- package/evals/lib/compaction-loader.ts +0 -320
- package/evals/lib/data-loader.evalite-test.ts +0 -289
- package/evals/lib/data-loader.test.ts +0 -345
- package/evals/lib/data-loader.ts +0 -281
- package/evals/lib/llm.ts +0 -115
- package/evals/scorers/compaction-prompt-scorers.ts +0 -145
- package/evals/scorers/compaction-scorers.ts +0 -305
- package/evals/scorers/coordinator-discipline.evalite-test.ts +0 -539
- package/evals/scorers/coordinator-discipline.ts +0 -325
- package/evals/scorers/index.test.ts +0 -146
- package/evals/scorers/index.ts +0 -328
- package/evals/scorers/outcome-scorers.evalite-test.ts +0 -27
- package/evals/scorers/outcome-scorers.ts +0 -349
- package/evals/swarm-decomposition.eval.ts +0 -121
- package/examples/commands/swarm.md +0 -745
- package/examples/plugin-wrapper-template.ts +0 -2426
- package/examples/skills/hive-workflow/SKILL.md +0 -212
- package/examples/skills/skill-creator/SKILL.md +0 -223
- package/examples/skills/swarm-coordination/SKILL.md +0 -292
- package/global-skills/cli-builder/SKILL.md +0 -344
- package/global-skills/cli-builder/references/advanced-patterns.md +0 -244
- package/global-skills/learning-systems/SKILL.md +0 -644
- package/global-skills/skill-creator/LICENSE.txt +0 -202
- package/global-skills/skill-creator/SKILL.md +0 -352
- package/global-skills/skill-creator/references/output-patterns.md +0 -82
- package/global-skills/skill-creator/references/workflows.md +0 -28
- package/global-skills/swarm-coordination/SKILL.md +0 -995
- package/global-skills/swarm-coordination/references/coordinator-patterns.md +0 -235
- package/global-skills/swarm-coordination/references/strategies.md +0 -138
- package/global-skills/system-design/SKILL.md +0 -213
- package/global-skills/testing-patterns/SKILL.md +0 -430
- package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +0 -586
- package/opencode-swarm-plugin-0.30.7.tgz +0 -0
- package/opencode-swarm-plugin-0.31.0.tgz +0 -0
- package/scripts/cleanup-test-memories.ts +0 -346
- package/scripts/init-skill.ts +0 -222
- package/scripts/migrate-unknown-sessions.ts +0 -349
- package/scripts/validate-skill.ts +0 -204
- package/src/agent-mail.ts +0 -1724
- package/src/anti-patterns.test.ts +0 -1167
- package/src/anti-patterns.ts +0 -448
- package/src/compaction-capture.integration.test.ts +0 -257
- package/src/compaction-hook.test.ts +0 -838
- package/src/compaction-hook.ts +0 -1204
- package/src/compaction-observability.integration.test.ts +0 -139
- package/src/compaction-observability.test.ts +0 -187
- package/src/compaction-observability.ts +0 -324
- package/src/compaction-prompt-scorers.test.ts +0 -475
- package/src/compaction-prompt-scoring.ts +0 -300
- package/src/dashboard.test.ts +0 -611
- package/src/dashboard.ts +0 -462
- package/src/error-enrichment.test.ts +0 -403
- package/src/error-enrichment.ts +0 -219
- package/src/eval-capture.test.ts +0 -1015
- package/src/eval-capture.ts +0 -929
- package/src/eval-gates.test.ts +0 -306
- package/src/eval-gates.ts +0 -218
- package/src/eval-history.test.ts +0 -508
- package/src/eval-history.ts +0 -214
- package/src/eval-learning.test.ts +0 -378
- package/src/eval-learning.ts +0 -360
- package/src/eval-runner.test.ts +0 -223
- package/src/eval-runner.ts +0 -402
- package/src/export-tools.test.ts +0 -476
- package/src/export-tools.ts +0 -257
- package/src/hive.integration.test.ts +0 -2241
- package/src/hive.ts +0 -1628
- package/src/index.ts +0 -935
- package/src/learning.integration.test.ts +0 -1815
- package/src/learning.ts +0 -1079
- package/src/logger.test.ts +0 -189
- package/src/logger.ts +0 -135
- package/src/mandate-promotion.test.ts +0 -473
- package/src/mandate-promotion.ts +0 -239
- package/src/mandate-storage.integration.test.ts +0 -601
- package/src/mandate-storage.test.ts +0 -578
- package/src/mandate-storage.ts +0 -794
- package/src/mandates.ts +0 -540
- package/src/memory-tools.test.ts +0 -195
- package/src/memory-tools.ts +0 -344
- package/src/memory.integration.test.ts +0 -334
- package/src/memory.test.ts +0 -158
- package/src/memory.ts +0 -527
- package/src/model-selection.test.ts +0 -188
- package/src/model-selection.ts +0 -68
- package/src/observability-tools.test.ts +0 -359
- package/src/observability-tools.ts +0 -871
- package/src/output-guardrails.test.ts +0 -438
- package/src/output-guardrails.ts +0 -381
- package/src/pattern-maturity.test.ts +0 -1160
- package/src/pattern-maturity.ts +0 -525
- package/src/planning-guardrails.test.ts +0 -491
- package/src/planning-guardrails.ts +0 -438
- package/src/plugin.ts +0 -23
- package/src/post-compaction-tracker.test.ts +0 -251
- package/src/post-compaction-tracker.ts +0 -237
- package/src/query-tools.test.ts +0 -636
- package/src/query-tools.ts +0 -324
- package/src/rate-limiter.integration.test.ts +0 -466
- package/src/rate-limiter.ts +0 -774
- package/src/replay-tools.test.ts +0 -496
- package/src/replay-tools.ts +0 -240
- package/src/repo-crawl.integration.test.ts +0 -441
- package/src/repo-crawl.ts +0 -610
- package/src/schemas/cell-events.test.ts +0 -347
- package/src/schemas/cell-events.ts +0 -807
- package/src/schemas/cell.ts +0 -257
- package/src/schemas/evaluation.ts +0 -166
- package/src/schemas/index.test.ts +0 -199
- package/src/schemas/index.ts +0 -286
- package/src/schemas/mandate.ts +0 -232
- package/src/schemas/swarm-context.ts +0 -115
- package/src/schemas/task.ts +0 -161
- package/src/schemas/worker-handoff.test.ts +0 -302
- package/src/schemas/worker-handoff.ts +0 -131
- package/src/skills.integration.test.ts +0 -1192
- package/src/skills.test.ts +0 -643
- package/src/skills.ts +0 -1549
- package/src/storage.integration.test.ts +0 -341
- package/src/storage.ts +0 -884
- package/src/structured.integration.test.ts +0 -817
- package/src/structured.test.ts +0 -1046
- package/src/structured.ts +0 -762
- package/src/swarm-decompose.test.ts +0 -188
- package/src/swarm-decompose.ts +0 -1302
- package/src/swarm-deferred.integration.test.ts +0 -157
- package/src/swarm-deferred.test.ts +0 -38
- package/src/swarm-insights.test.ts +0 -214
- package/src/swarm-insights.ts +0 -459
- package/src/swarm-mail.integration.test.ts +0 -970
- package/src/swarm-mail.ts +0 -739
- package/src/swarm-orchestrate.integration.test.ts +0 -282
- package/src/swarm-orchestrate.test.ts +0 -548
- package/src/swarm-orchestrate.ts +0 -3084
- package/src/swarm-prompts.test.ts +0 -1270
- package/src/swarm-prompts.ts +0 -2077
- package/src/swarm-research.integration.test.ts +0 -701
- package/src/swarm-research.test.ts +0 -698
- package/src/swarm-research.ts +0 -472
- package/src/swarm-review.integration.test.ts +0 -285
- package/src/swarm-review.test.ts +0 -879
- package/src/swarm-review.ts +0 -709
- package/src/swarm-strategies.ts +0 -407
- package/src/swarm-worktree.test.ts +0 -501
- package/src/swarm-worktree.ts +0 -575
- package/src/swarm.integration.test.ts +0 -2377
- package/src/swarm.ts +0 -38
- package/src/tool-adapter.integration.test.ts +0 -1221
- package/src/tool-availability.ts +0 -461
- 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");
|
package/scripts/init-skill.ts
DELETED
|
@@ -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!);
|