@codexa/cli 9.0.6 → 9.0.8
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/commands/decide.ts +120 -3
- package/commands/discover.ts +18 -9
- package/commands/integration.test.ts +754 -0
- package/commands/knowledge.test.ts +2 -6
- package/commands/knowledge.ts +20 -4
- package/commands/patterns.ts +8 -644
- package/commands/product.ts +41 -104
- package/commands/spec-resolver.test.ts +2 -13
- package/commands/standards.ts +33 -3
- package/commands/task.ts +21 -4
- package/commands/utils.test.ts +25 -87
- package/commands/utils.ts +20 -82
- package/context/assembly.ts +81 -0
- package/context/domains.test.ts +278 -0
- package/context/domains.ts +156 -0
- package/context/generator.ts +272 -0
- package/context/index.ts +21 -0
- package/context/scoring.ts +106 -0
- package/context/sections.ts +247 -0
- package/db/schema.ts +40 -5
- package/db/test-helpers.ts +33 -0
- package/gates/standards-validator.test.ts +447 -0
- package/gates/standards-validator.ts +164 -125
- package/gates/typecheck-validator.ts +296 -92
- package/gates/validator.ts +93 -8
- package/package.json +4 -2
- package/protocol/process-return.ts +39 -4
- package/templates/loader.ts +22 -0
- package/templates/subagent-context.md +34 -0
- package/templates/subagent-return-protocol.md +29 -0
- package/workflow.ts +54 -84
|
@@ -2,6 +2,7 @@ import { describe, it, expect, beforeEach } from "bun:test";
|
|
|
2
2
|
import { jaccardSimilarity, compactKnowledge } from "./knowledge";
|
|
3
3
|
import { getDb } from "../db/connection";
|
|
4
4
|
import { initSchema } from "../db/schema";
|
|
5
|
+
import { cleanDb } from "../db/test-helpers";
|
|
5
6
|
|
|
6
7
|
describe("jaccardSimilarity", () => {
|
|
7
8
|
it("returns 1 for identical strings", () => {
|
|
@@ -49,12 +50,7 @@ describe("jaccardSimilarity", () => {
|
|
|
49
50
|
describe("compactKnowledge", () => {
|
|
50
51
|
beforeEach(() => {
|
|
51
52
|
initSchema();
|
|
52
|
-
|
|
53
|
-
db.run("DELETE FROM knowledge_graph");
|
|
54
|
-
db.run("DELETE FROM knowledge");
|
|
55
|
-
db.run("DELETE FROM tasks");
|
|
56
|
-
db.run("DELETE FROM context");
|
|
57
|
-
db.run("DELETE FROM specs");
|
|
53
|
+
cleanDb();
|
|
58
54
|
});
|
|
59
55
|
|
|
60
56
|
function createSpec(id: string, phase: string) {
|
package/commands/knowledge.ts
CHANGED
|
@@ -170,9 +170,9 @@ export function acknowledgeKnowledge(knowledgeId: string, specId?: string): void
|
|
|
170
170
|
export function getKnowledgeForTask(specId: string, taskId: number): any[] {
|
|
171
171
|
const db = getDb();
|
|
172
172
|
|
|
173
|
-
//
|
|
173
|
+
// Knowledge do spec atual (todas as severities)
|
|
174
174
|
// Fix: LIKE '%taskId%' causava substring match (taskId=1 matchava "1,10,11")
|
|
175
|
-
const
|
|
175
|
+
const specKnowledge = db
|
|
176
176
|
.query(
|
|
177
177
|
`SELECT * FROM knowledge
|
|
178
178
|
WHERE spec_id = ?
|
|
@@ -181,11 +181,27 @@ export function getKnowledgeForTask(specId: string, taskId: number): any[] {
|
|
|
181
181
|
)
|
|
182
182
|
.all(specId) as any[];
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
const filtered = specKnowledge.filter((k) => {
|
|
185
185
|
if (k.broadcast_to === 'all') return true;
|
|
186
186
|
const targets = k.broadcast_to.split(',').map((t: string) => parseInt(t.trim(), 10));
|
|
187
187
|
return targets.includes(taskId);
|
|
188
|
-
})
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Cross-feature: knowledge critical de outros specs (aprendizado global)
|
|
191
|
+
const crossFeature = db
|
|
192
|
+
.query(
|
|
193
|
+
`SELECT * FROM knowledge
|
|
194
|
+
WHERE spec_id != ? AND severity = 'critical'
|
|
195
|
+
ORDER BY created_at DESC
|
|
196
|
+
LIMIT 10`
|
|
197
|
+
)
|
|
198
|
+
.all(specId) as any[];
|
|
199
|
+
|
|
200
|
+
// Deduplicar por content (priorizar o do spec atual)
|
|
201
|
+
const seenContent = new Set(filtered.map((k) => k.content));
|
|
202
|
+
const uniqueCross = crossFeature.filter((k) => !seenContent.has(k.content));
|
|
203
|
+
|
|
204
|
+
return [...filtered, ...uniqueCross].slice(0, 25);
|
|
189
205
|
}
|
|
190
206
|
|
|
191
207
|
export function getUnreadKnowledgeForTask(specId: string, taskId: number): any[] {
|