@codexa/cli 9.0.7 → 9.0.9

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.
@@ -0,0 +1,300 @@
1
+ import { describe, it, expect } from "bun:test";
2
+ import {
3
+ getAgentDomain,
4
+ domainToScope,
5
+ adjustSectionPriorities,
6
+ AGENT_DOMAIN,
7
+ DOMAIN_PROFILES,
8
+ } from "./domains";
9
+ import type { ContextSection } from "./assembly";
10
+
11
+ function makeSections(): ContextSection[] {
12
+ return [
13
+ { name: "STANDARDS", content: "...", priority: 1 },
14
+ { name: "REFERENCIAS", content: "...", priority: 2 },
15
+ { name: "ALERTAS", content: "...", priority: 2 },
16
+ { name: "ARQUITETURA", content: "...", priority: 3 },
17
+ { name: "DECISOES", content: "...", priority: 4 },
18
+ { name: "CONTEXTO DE TASKS ANTERIORES", content: "...", priority: 5 },
19
+ { name: "GRAPH", content: "...", priority: 6 },
20
+ { name: "PRODUTO", content: "...", priority: 7 },
21
+ { name: "DISCOVERIES", content: "...", priority: 8 },
22
+ { name: "UTILITIES", content: "...", priority: 8 },
23
+ { name: "PATTERNS", content: "...", priority: 9 },
24
+ { name: "HINTS", content: "...", priority: 10 },
25
+ { name: "STACK", content: "...", priority: 11 },
26
+ ];
27
+ }
28
+
29
+ // ── getAgentDomain ───────────────────────────────────────────
30
+
31
+ describe("getAgentDomain", () => {
32
+ it("maps backend agents correctly", () => {
33
+ expect(getAgentDomain("backend-javascript")).toBe("backend");
34
+ expect(getAgentDomain("expert-csharp-developer")).toBe("backend");
35
+ expect(getAgentDomain("golang-pro")).toBe("backend");
36
+ });
37
+
38
+ it("maps frontend agents correctly", () => {
39
+ expect(getAgentDomain("expert-nextjs-developer")).toBe("frontend");
40
+ expect(getAgentDomain("frontend-flutter")).toBe("frontend");
41
+ });
42
+
43
+ it("maps database agent correctly", () => {
44
+ expect(getAgentDomain("expert-postgres-developer")).toBe("database");
45
+ });
46
+
47
+ it("maps testing agent correctly", () => {
48
+ expect(getAgentDomain("testing-unit")).toBe("testing");
49
+ });
50
+
51
+ it("maps review agent correctly", () => {
52
+ expect(getAgentDomain("expert-code-reviewer")).toBe("review");
53
+ });
54
+
55
+ it("maps security agent correctly", () => {
56
+ expect(getAgentDomain("security-specialist")).toBe("security");
57
+ });
58
+
59
+ it("maps explore agent correctly", () => {
60
+ expect(getAgentDomain("deep-explore")).toBe("explore");
61
+ });
62
+
63
+ it("maps architecture agent correctly", () => {
64
+ expect(getAgentDomain("architect")).toBe("architecture");
65
+ });
66
+
67
+ it("returns null for unknown agents", () => {
68
+ expect(getAgentDomain("unknown-agent")).toBeNull();
69
+ expect(getAgentDomain("general-purpose")).toBeNull();
70
+ });
71
+
72
+ it("returns null for null/undefined/empty input", () => {
73
+ expect(getAgentDomain(null)).toBeNull();
74
+ expect(getAgentDomain(undefined)).toBeNull();
75
+ expect(getAgentDomain("")).toBeNull();
76
+ });
77
+ });
78
+
79
+ // ── domainToScope ────────────────────────────────────────────
80
+
81
+ describe("domainToScope", () => {
82
+ it("maps code domains to their scope names", () => {
83
+ expect(domainToScope("backend")).toBe("backend");
84
+ expect(domainToScope("frontend")).toBe("frontend");
85
+ expect(domainToScope("database")).toBe("database");
86
+ expect(domainToScope("testing")).toBe("testing");
87
+ });
88
+
89
+ it("maps cross-cutting domains to 'all'", () => {
90
+ expect(domainToScope("review")).toBe("all");
91
+ expect(domainToScope("security")).toBe("all");
92
+ expect(domainToScope("explore")).toBe("all");
93
+ expect(domainToScope("architecture")).toBe("all");
94
+ });
95
+
96
+ it("returns 'all' for null domain", () => {
97
+ expect(domainToScope(null)).toBe("all");
98
+ });
99
+
100
+ // Regression: verifies the split("-")[0] bug is fixed
101
+ it("expert-postgres-developer resolves to 'database' scope (not 'expert')", () => {
102
+ const domain = getAgentDomain("expert-postgres-developer");
103
+ expect(domainToScope(domain)).toBe("database");
104
+ });
105
+
106
+ it("expert-nextjs-developer resolves to 'frontend' scope (not 'expert')", () => {
107
+ const domain = getAgentDomain("expert-nextjs-developer");
108
+ expect(domainToScope(domain)).toBe("frontend");
109
+ });
110
+
111
+ it("golang-pro resolves to 'backend' scope (not 'golang')", () => {
112
+ const domain = getAgentDomain("golang-pro");
113
+ expect(domainToScope(domain)).toBe("backend");
114
+ });
115
+ });
116
+
117
+ // ── adjustSectionPriorities ──────────────────────────────────
118
+
119
+ describe("adjustSectionPriorities", () => {
120
+ it("null domain passes all sections through unchanged", () => {
121
+ const sections = makeSections();
122
+ const result = adjustSectionPriorities(sections, null);
123
+ expect(result).toHaveLength(13);
124
+ expect(result).toEqual(sections);
125
+ });
126
+
127
+ it("explore domain excludes relevance-0 sections", () => {
128
+ const result = adjustSectionPriorities(makeSections(), "explore");
129
+ const names = result.map(s => s.name);
130
+
131
+ // explore profile: 8 sections have relevance 0
132
+ expect(names).not.toContain("STANDARDS");
133
+ expect(names).not.toContain("REFERENCIAS");
134
+ expect(names).not.toContain("CONTEXTO DE TASKS ANTERIORES");
135
+ expect(names).not.toContain("GRAPH");
136
+ expect(names).not.toContain("PRODUTO");
137
+ expect(names).not.toContain("UTILITIES");
138
+ expect(names).not.toContain("PATTERNS");
139
+ expect(names).not.toContain("HINTS");
140
+
141
+ // Should contain the 5 non-zero sections
142
+ expect(names).toContain("ALERTAS");
143
+ expect(names).toContain("ARQUITETURA");
144
+ expect(names).toContain("DECISOES");
145
+ expect(names).toContain("DISCOVERIES");
146
+ expect(names).toContain("STACK");
147
+ expect(result).toHaveLength(5);
148
+ });
149
+
150
+ it("essential sections (relevance=3) get priority boosted by -2", () => {
151
+ const result = adjustSectionPriorities(makeSections(), "backend");
152
+
153
+ // backend: DECISOES=3 (base 4 + offset -2 = 2)
154
+ const decisoes = result.find(s => s.name === "DECISOES");
155
+ expect(decisoes?.priority).toBe(2);
156
+
157
+ // backend: UTILITIES=3 (base 8 + offset -2 = 6)
158
+ const utilities = result.find(s => s.name === "UTILITIES");
159
+ expect(utilities?.priority).toBe(6);
160
+ });
161
+
162
+ it("priority floor is 1 (never goes below)", () => {
163
+ const result = adjustSectionPriorities(makeSections(), "backend");
164
+
165
+ // backend: STANDARDS=3 (base 1 + offset -2 = -1 → floor 1)
166
+ const standards = result.find(s => s.name === "STANDARDS");
167
+ expect(standards?.priority).toBe(1);
168
+
169
+ // backend: ALERTAS=3 (base 2 + offset -2 = 0 → floor 1)
170
+ const alertas = result.find(s => s.name === "ALERTAS");
171
+ expect(alertas?.priority).toBe(1);
172
+ });
173
+
174
+ it("nice-to-have sections (relevance=1) get deprioritized by +4", () => {
175
+ const result = adjustSectionPriorities(makeSections(), "backend");
176
+
177
+ // backend: PRODUTO=1 (base 7 + offset +4 = 11)
178
+ const produto = result.find(s => s.name === "PRODUTO");
179
+ expect(produto?.priority).toBe(11);
180
+ });
181
+
182
+ it("useful sections (relevance=2) keep base priority", () => {
183
+ const result = adjustSectionPriorities(makeSections(), "backend");
184
+
185
+ // backend: ARQUITETURA=2 (base 3 + offset 0 = 3)
186
+ const arq = result.find(s => s.name === "ARQUITETURA");
187
+ expect(arq?.priority).toBe(3);
188
+ });
189
+
190
+ it("testing domain excludes only PRODUTO (relevance=0)", () => {
191
+ const result = adjustSectionPriorities(makeSections(), "testing");
192
+ const names = result.map(s => s.name);
193
+ expect(names).not.toContain("PRODUTO");
194
+ expect(result).toHaveLength(12);
195
+ });
196
+
197
+ it("testing domain boosts CONTEXTO DE TASKS ANTERIORES (relevance=3)", () => {
198
+ const result = adjustSectionPriorities(makeSections(), "testing");
199
+ const ctx = result.find(s => s.name === "CONTEXTO DE TASKS ANTERIORES");
200
+ // base 5 + offset -2 = 3
201
+ expect(ctx?.priority).toBe(3);
202
+ });
203
+
204
+ it("database domain excludes PRODUTO (relevance=0)", () => {
205
+ const result = adjustSectionPriorities(makeSections(), "database");
206
+ const names = result.map(s => s.name);
207
+ expect(names).not.toContain("PRODUTO");
208
+ });
209
+
210
+ it("frontend domain keeps PRODUTO with boosted priority", () => {
211
+ const result = adjustSectionPriorities(makeSections(), "frontend");
212
+ const produto = result.find(s => s.name === "PRODUTO");
213
+ // frontend: PRODUTO=3 (base 7 + offset -2 = 5)
214
+ expect(produto?.priority).toBe(5);
215
+ });
216
+
217
+ it("backend domain boosts REFERENCIAS (relevance=3)", () => {
218
+ const result = adjustSectionPriorities(makeSections(), "backend");
219
+ const refs = result.find(s => s.name === "REFERENCIAS");
220
+ // backend: REFERENCIAS=3 (base 2 + offset -2 = 0 → floor 1)
221
+ expect(refs?.priority).toBe(1);
222
+ });
223
+
224
+ it("explore domain excludes REFERENCIAS (relevance=0)", () => {
225
+ const result = adjustSectionPriorities(makeSections(), "explore");
226
+ const names = result.map(s => s.name);
227
+ expect(names).not.toContain("REFERENCIAS");
228
+ });
229
+
230
+ it("architecture domain excludes REFERENCIAS (relevance=0)", () => {
231
+ const result = adjustSectionPriorities(makeSections(), "architecture");
232
+ const names = result.map(s => s.name);
233
+ expect(names).not.toContain("REFERENCIAS");
234
+ });
235
+
236
+ it("security domain excludes PRODUTO and REFERENCIAS (relevance=0)", () => {
237
+ const result = adjustSectionPriorities(makeSections(), "security");
238
+ const names = result.map(s => s.name);
239
+ expect(names).not.toContain("PRODUTO");
240
+ expect(names).not.toContain("REFERENCIAS");
241
+ expect(result).toHaveLength(11);
242
+ });
243
+
244
+ it("handles unknown section names gracefully (forward compatibility)", () => {
245
+ const sections: ContextSection[] = [
246
+ { name: "FUTURE_SECTION", content: "...", priority: 5 },
247
+ { name: "STANDARDS", content: "...", priority: 1 },
248
+ ];
249
+ const result = adjustSectionPriorities(sections, "backend");
250
+ expect(result).toHaveLength(2);
251
+ const future = result.find(s => s.name === "FUTURE_SECTION");
252
+ expect(future?.priority).toBe(5); // unchanged
253
+ });
254
+ });
255
+
256
+ // ── DOMAIN_PROFILES completeness ─────────────────────────────
257
+
258
+ describe("DOMAIN_PROFILES completeness", () => {
259
+ const allSectionNames = [
260
+ "STANDARDS", "REFERENCIAS", "ALERTAS", "ARQUITETURA", "DECISOES",
261
+ "CONTEXTO DE TASKS ANTERIORES", "GRAPH", "PRODUTO",
262
+ "DISCOVERIES", "UTILITIES", "PATTERNS", "HINTS", "STACK",
263
+ ];
264
+
265
+ it("every domain profile covers all 13 sections", () => {
266
+ for (const [domain, profile] of Object.entries(DOMAIN_PROFILES)) {
267
+ for (const section of allSectionNames) {
268
+ expect(profile[section as keyof typeof profile]).toBeDefined();
269
+ }
270
+ }
271
+ });
272
+
273
+ it("all relevance values are 0, 1, 2, or 3", () => {
274
+ for (const [domain, profile] of Object.entries(DOMAIN_PROFILES)) {
275
+ for (const [section, relevance] of Object.entries(profile)) {
276
+ expect([0, 1, 2, 3]).toContain(relevance);
277
+ }
278
+ }
279
+ });
280
+ });
281
+
282
+ // ── AGENT_DOMAIN completeness ────────────────────────────────
283
+
284
+ describe("AGENT_DOMAIN completeness", () => {
285
+ it("maps all 11 known agents", () => {
286
+ const knownAgents = [
287
+ "backend-javascript", "expert-csharp-developer", "golang-pro",
288
+ "expert-nextjs-developer", "frontend-flutter",
289
+ "expert-postgres-developer",
290
+ "testing-unit",
291
+ "expert-code-reviewer",
292
+ "security-specialist",
293
+ "deep-explore",
294
+ "architect",
295
+ ];
296
+ for (const agent of knownAgents) {
297
+ expect(AGENT_DOMAIN[agent]).toBeDefined();
298
+ }
299
+ });
300
+ });
@@ -0,0 +1,157 @@
1
+ // ═══════════════════════════════════════════════════════════════
2
+ // DOMAIN-BASED CONTEXT PRIORITY (v9.4)
3
+ // Replaces binary AGENT_SECTIONS with relevance-based filtering.
4
+ // ═══════════════════════════════════════════════════════════════
5
+
6
+ import type { ContextSection } from "./assembly";
7
+
8
+ export type AgentDomain =
9
+ | "backend"
10
+ | "frontend"
11
+ | "database"
12
+ | "testing"
13
+ | "review"
14
+ | "security"
15
+ | "explore"
16
+ | "architecture";
17
+
18
+ export type Relevance = 0 | 1 | 2 | 3;
19
+
20
+ export type SectionName =
21
+ | "STANDARDS"
22
+ | "REFERENCIAS"
23
+ | "ALERTAS"
24
+ | "ARQUITETURA"
25
+ | "DECISOES"
26
+ | "CONTEXTO DE TASKS ANTERIORES"
27
+ | "GRAPH"
28
+ | "PRODUTO"
29
+ | "DISCOVERIES"
30
+ | "UTILITIES"
31
+ | "PATTERNS"
32
+ | "HINTS"
33
+ | "STACK";
34
+
35
+ export type DomainProfile = Record<SectionName, Relevance>;
36
+
37
+ // ── Agent → Domain mapping ───────────────────────────────────
38
+
39
+ export const AGENT_DOMAIN: Record<string, AgentDomain> = {
40
+ "backend-javascript": "backend",
41
+ "expert-csharp-developer": "backend",
42
+ "golang-pro": "backend",
43
+ "expert-nextjs-developer": "frontend",
44
+ "frontend-flutter": "frontend",
45
+ "expert-postgres-developer": "database",
46
+ "testing-unit": "testing",
47
+ "expert-code-reviewer": "review",
48
+ "security-specialist": "security",
49
+ "deep-explore": "explore",
50
+ "architect": "architecture",
51
+ };
52
+
53
+ // ── Domain → Section relevance profiles ──────────────────────
54
+ //
55
+ // 3 = essential (priority offset -2, survives truncation)
56
+ // 2 = useful (priority offset 0, base priority kept)
57
+ // 1 = nice-to-have (priority offset +4, dropped first on truncation)
58
+ // 0 = noise (excluded entirely)
59
+
60
+ export const DOMAIN_PROFILES: Record<AgentDomain, DomainProfile> = {
61
+ backend: {
62
+ "STANDARDS": 3, "REFERENCIAS": 3, "ALERTAS": 3, "ARQUITETURA": 2, "DECISOES": 3,
63
+ "CONTEXTO DE TASKS ANTERIORES": 2, "GRAPH": 2, "PRODUTO": 1,
64
+ "DISCOVERIES": 2, "UTILITIES": 3, "PATTERNS": 2, "HINTS": 2, "STACK": 2,
65
+ },
66
+ frontend: {
67
+ "STANDARDS": 3, "REFERENCIAS": 3, "ALERTAS": 3, "ARQUITETURA": 2, "DECISOES": 3,
68
+ "CONTEXTO DE TASKS ANTERIORES": 2, "GRAPH": 2, "PRODUTO": 3,
69
+ "DISCOVERIES": 2, "UTILITIES": 3, "PATTERNS": 3, "HINTS": 2, "STACK": 2,
70
+ },
71
+ database: {
72
+ "STANDARDS": 3, "REFERENCIAS": 3, "ALERTAS": 3, "ARQUITETURA": 3, "DECISOES": 3,
73
+ "CONTEXTO DE TASKS ANTERIORES": 2, "GRAPH": 2, "PRODUTO": 0,
74
+ "DISCOVERIES": 2, "UTILITIES": 1, "PATTERNS": 2, "HINTS": 2, "STACK": 3,
75
+ },
76
+ testing: {
77
+ "STANDARDS": 3, "REFERENCIAS": 3, "ALERTAS": 3, "ARQUITETURA": 1, "DECISOES": 2,
78
+ "CONTEXTO DE TASKS ANTERIORES": 3, "GRAPH": 1, "PRODUTO": 0,
79
+ "DISCOVERIES": 2, "UTILITIES": 3, "PATTERNS": 3, "HINTS": 2, "STACK": 1,
80
+ },
81
+ review: {
82
+ "STANDARDS": 3, "REFERENCIAS": 1, "ALERTAS": 3, "ARQUITETURA": 3, "DECISOES": 3,
83
+ "CONTEXTO DE TASKS ANTERIORES": 2, "GRAPH": 2, "PRODUTO": 1,
84
+ "DISCOVERIES": 2, "UTILITIES": 3, "PATTERNS": 2, "HINTS": 3, "STACK": 2,
85
+ },
86
+ security: {
87
+ "STANDARDS": 3, "REFERENCIAS": 0, "ALERTAS": 3, "ARQUITETURA": 2, "DECISOES": 2,
88
+ "CONTEXTO DE TASKS ANTERIORES": 1, "GRAPH": 1, "PRODUTO": 0,
89
+ "DISCOVERIES": 2, "UTILITIES": 1, "PATTERNS": 1, "HINTS": 2, "STACK": 3,
90
+ },
91
+ explore: {
92
+ "STANDARDS": 0, "REFERENCIAS": 0, "ALERTAS": 1, "ARQUITETURA": 3, "DECISOES": 1,
93
+ "CONTEXTO DE TASKS ANTERIORES": 0, "GRAPH": 0, "PRODUTO": 0,
94
+ "DISCOVERIES": 1, "UTILITIES": 0, "PATTERNS": 0, "HINTS": 0, "STACK": 3,
95
+ },
96
+ architecture: {
97
+ "STANDARDS": 2, "REFERENCIAS": 0, "ALERTAS": 2, "ARQUITETURA": 3, "DECISOES": 3,
98
+ "CONTEXTO DE TASKS ANTERIORES": 2, "GRAPH": 2, "PRODUTO": 3,
99
+ "DISCOVERIES": 2, "UTILITIES": 1, "PATTERNS": 2, "HINTS": 1, "STACK": 3,
100
+ },
101
+ };
102
+
103
+ // ── Priority offset per relevance level ──────────────────────
104
+
105
+ const RELEVANCE_OFFSET: Record<Relevance, number> = {
106
+ 3: -2, // essential: boost
107
+ 2: 0, // useful: keep as-is
108
+ 1: 4, // nice-to-have: deprioritize
109
+ 0: 0, // noise: excluded before this applies
110
+ };
111
+
112
+ // ── Functions ────────────────────────────────────────────────
113
+
114
+ export function getAgentDomain(agentName: string | null | undefined): AgentDomain | null {
115
+ if (!agentName) return null;
116
+ return AGENT_DOMAIN[agentName] ?? null;
117
+ }
118
+
119
+ export function domainToScope(domain: AgentDomain | null): string {
120
+ if (!domain) return "all";
121
+
122
+ const scopeMap: Record<AgentDomain, string> = {
123
+ backend: "backend",
124
+ frontend: "frontend",
125
+ database: "database",
126
+ testing: "testing",
127
+ review: "all",
128
+ security: "all",
129
+ explore: "all",
130
+ architecture: "all",
131
+ };
132
+
133
+ return scopeMap[domain];
134
+ }
135
+
136
+ export function adjustSectionPriorities(
137
+ sections: ContextSection[],
138
+ domain: AgentDomain | null,
139
+ ): ContextSection[] {
140
+ if (!domain) return sections;
141
+
142
+ const profile = DOMAIN_PROFILES[domain];
143
+
144
+ return sections
145
+ .filter(s => {
146
+ const relevance = profile[s.name as SectionName];
147
+ // Unknown section names pass through (forward compatibility)
148
+ return relevance === undefined || relevance > 0;
149
+ })
150
+ .map(s => {
151
+ const relevance = profile[s.name as SectionName];
152
+ if (relevance === undefined) return s;
153
+
154
+ const offset = RELEVANCE_OFFSET[relevance];
155
+ return { ...s, priority: Math.max(1, s.priority + offset) };
156
+ });
157
+ }
@@ -2,7 +2,8 @@ import { getDb } from "../db/connection";
2
2
  import { initSchema, getPatternsForFiles, getRelatedDecisions, getArchitecturalAnalysisForSpec } from "../db/schema";
3
3
  import { getKnowledgeForTask } from "../commands/knowledge";
4
4
  import type { ContextSection, ContextData } from "./assembly";
5
- import { assembleSections, AGENT_SECTIONS } from "./assembly";
5
+ import { assembleSections } from "./assembly";
6
+ import { getAgentDomain, adjustSectionPriorities, domainToScope } from "./domains";
6
7
  import { filterRelevantDecisions, filterRelevantStandards } from "./scoring";
7
8
  import {
8
9
  buildProductSection,
@@ -17,6 +18,7 @@ import {
17
18
  buildGraphSection,
18
19
  buildStackSection,
19
20
  buildHintsSection,
21
+ buildReferencesSection,
20
22
  } from "./sections";
21
23
 
22
24
  // v9.0: Contexto minimo para subagent (max ~2KB)
@@ -33,7 +35,7 @@ export function getMinimalContextForSubagent(taskId: number): string {
33
35
  const context = db.query("SELECT * FROM context WHERE spec_id = ?").get(task.spec_id) as any;
34
36
 
35
37
  const taskFiles = task.files ? JSON.parse(task.files) : [];
36
- const domain = task.agent?.split("-")[0] || "all";
38
+ const domain = domainToScope(getAgentDomain(task.agent));
37
39
 
38
40
  // 1. Standards REQUIRED apenas (nao recommended)
39
41
  const requiredStandards = db.query(
@@ -42,11 +44,12 @@ export function getMinimalContextForSubagent(taskId: number): string {
42
44
  LIMIT 10`
43
45
  ).all(domain) as any[];
44
46
 
45
- // 2. Blockers CRITICAL apenas
47
+ // 2. Blockers CRITICAL (spec atual + cross-feature)
46
48
  const criticalBlockers = db.query(
47
- `SELECT content FROM knowledge
48
- WHERE spec_id = ? AND severity = 'critical'
49
- ORDER BY created_at DESC LIMIT 5`
49
+ `SELECT DISTINCT content FROM knowledge
50
+ WHERE severity = 'critical'
51
+ ORDER BY CASE WHEN spec_id = ? THEN 0 ELSE 1 END, created_at DESC
52
+ LIMIT 5`
50
53
  ).all(task.spec_id) as any[];
51
54
 
52
55
  // 3. Decisoes da task anterior (dependency direta)
@@ -124,7 +127,7 @@ function fetchContextData(taskId: number): ContextData | null {
124
127
 
125
128
  // Arquivos da task para filtrar contexto relevante
126
129
  const taskFiles = task.files ? JSON.parse(task.files) : [];
127
- const domain = task.agent?.split("-")[0] || "all";
130
+ const domain = domainToScope(getAgentDomain(task.agent));
128
131
 
129
132
  // Decisoes relevantes (max 8, priorizando as que mencionam arquivos da task)
130
133
  const allDecisions = db
@@ -251,6 +254,7 @@ export function getContextForSubagent(taskId: number): string {
251
254
  buildProductSection(data),
252
255
  buildArchitectureSection(data),
253
256
  buildStandardsSection(data),
257
+ buildReferencesSection(data),
254
258
  buildDecisionsSection(data),
255
259
  buildReasoningSection(data),
256
260
  buildAlertsSection(data),
@@ -262,12 +266,9 @@ export function getContextForSubagent(taskId: number): string {
262
266
  buildHintsSection(data),
263
267
  ].filter((s): s is ContextSection => s !== null);
264
268
 
265
- // v9.3: Filtrar secoes por tipo de agente
266
- const agentType = data.task.agent || "";
267
- const allowedSections = AGENT_SECTIONS[agentType];
268
- const sections = allowedSections
269
- ? allSections.filter(s => allowedSections.includes(s.name))
270
- : allSections;
269
+ // v9.4: Domain-based priority adjustment (replaces binary AGENT_SECTIONS)
270
+ const agentDomain = getAgentDomain(data.task.agent);
271
+ const sections = adjustSectionPriorities(allSections, agentDomain);
271
272
 
272
273
  return assembleSections(header, sections);
273
274
  }
package/context/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  // Re-exports for backward compatibility
2
2
  export { getContextForSubagent, getMinimalContextForSubagent } from "./generator";
3
- export { assembleSections, MAX_CONTEXT_SIZE, AGENT_SECTIONS } from "./assembly";
3
+ export { assembleSections, MAX_CONTEXT_SIZE } from "./assembly";
4
+ export { AGENT_DOMAIN, DOMAIN_PROFILES, getAgentDomain, adjustSectionPriorities, domainToScope } from "./domains";
5
+ export type { AgentDomain, Relevance, SectionName, DomainProfile } from "./domains";
4
6
  export type { ContextSection, ContextData } from "./assembly";
5
7
  export { filterRelevantDecisions, filterRelevantStandards } from "./scoring";
6
8
  export {
@@ -16,4 +18,7 @@ export {
16
18
  buildGraphSection,
17
19
  buildStackSection,
18
20
  buildHintsSection,
21
+ buildReferencesSection,
19
22
  } from "./sections";
23
+ export { findReferenceFiles } from "./references";
24
+ export type { ReferenceFile } from "./references";