feat(ipuaro): add impact score to initial context

Add High Impact Files section to initial context showing which files
are most critical based on percentage of codebase that depends on them.

Changes:
- Add impactScore field to FileMeta (0-100)
- Add calculateImpactScore() helper function
- Update MetaAnalyzer to compute impact scores
- Add formatHighImpactFiles() to prompts.ts
- Add includeHighImpactFiles config option (default: true)
- 28 new tests (1826 total)
This commit is contained in:
imfozilbek
2025-12-05 15:43:24 +05:00
parent d6d15dd271
commit e9aaa708fe
9 changed files with 606 additions and 12 deletions

View File

@@ -18,6 +18,7 @@ describe("ContextConfigSchema", () => {
includeSignatures: true,
includeDepsGraph: true,
includeCircularDeps: true,
includeHighImpactFiles: true,
})
})
@@ -32,6 +33,7 @@ describe("ContextConfigSchema", () => {
includeSignatures: true,
includeDepsGraph: true,
includeCircularDeps: true,
includeHighImpactFiles: true,
})
})
})
@@ -171,6 +173,7 @@ describe("ContextConfigSchema", () => {
includeSignatures: true,
includeDepsGraph: true,
includeCircularDeps: true,
includeHighImpactFiles: true,
})
})
@@ -187,6 +190,7 @@ describe("ContextConfigSchema", () => {
includeSignatures: true,
includeDepsGraph: true,
includeCircularDeps: true,
includeHighImpactFiles: true,
})
})
@@ -204,6 +208,7 @@ describe("ContextConfigSchema", () => {
includeSignatures: true,
includeDepsGraph: true,
includeCircularDeps: true,
includeHighImpactFiles: true,
})
})
})
@@ -218,6 +223,7 @@ describe("ContextConfigSchema", () => {
includeSignatures: false,
includeDepsGraph: false,
includeCircularDeps: false,
includeHighImpactFiles: false,
}
const result = ContextConfigSchema.parse(config)
@@ -233,6 +239,7 @@ describe("ContextConfigSchema", () => {
includeSignatures: true,
includeDepsGraph: true,
includeCircularDeps: true,
includeHighImpactFiles: true,
}
const result = ContextConfigSchema.parse(config)
@@ -314,4 +321,29 @@ describe("ContextConfigSchema", () => {
expect(() => ContextConfigSchema.parse({ includeCircularDeps: 1 })).toThrow()
})
})
describe("includeHighImpactFiles", () => {
it("should accept true", () => {
const result = ContextConfigSchema.parse({ includeHighImpactFiles: true })
expect(result.includeHighImpactFiles).toBe(true)
})
it("should accept false", () => {
const result = ContextConfigSchema.parse({ includeHighImpactFiles: false })
expect(result.includeHighImpactFiles).toBe(false)
})
it("should default to true", () => {
const result = ContextConfigSchema.parse({})
expect(result.includeHighImpactFiles).toBe(true)
})
it("should reject non-boolean", () => {
expect(() => ContextConfigSchema.parse({ includeHighImpactFiles: "true" })).toThrow()
})
it("should reject number", () => {
expect(() => ContextConfigSchema.parse({ includeHighImpactFiles: 1 })).toThrow()
})
})
})