ghagga-core 2.9.1 → 3.1.0
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/LICENSE +21 -0
- package/dist/agents/audit.js +1 -1
- package/dist/agents/audit.js.map +1 -1
- package/dist/agents/consensus.d.ts.map +1 -1
- package/dist/agents/consensus.js +7 -2
- package/dist/agents/consensus.js.map +1 -1
- package/dist/agents/diagnostic.d.ts.map +1 -1
- package/dist/agents/diagnostic.js +8 -3
- package/dist/agents/diagnostic.js.map +1 -1
- package/dist/agents/fan-out-lenses.d.ts.map +1 -1
- package/dist/agents/fan-out-lenses.js +8 -3
- package/dist/agents/fan-out-lenses.js.map +1 -1
- package/dist/agents/prompts.d.ts +49 -1
- package/dist/agents/prompts.d.ts.map +1 -1
- package/dist/agents/prompts.js +133 -5
- package/dist/agents/prompts.js.map +1 -1
- package/dist/agents/simple.d.ts +1 -1
- package/dist/agents/simple.d.ts.map +1 -1
- package/dist/agents/simple.js +7 -5
- package/dist/agents/simple.js.map +1 -1
- package/dist/agents/workflow.d.ts.map +1 -1
- package/dist/agents/workflow.js +13 -4
- package/dist/agents/workflow.js.map +1 -1
- package/dist/critique/critique.d.ts.map +1 -1
- package/dist/critique/critique.js +14 -6
- package/dist/critique/critique.js.map +1 -1
- package/dist/diff/index.d.ts +12 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +11 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/diff/parse.d.ts +41 -0
- package/dist/diff/parse.d.ts.map +1 -0
- package/dist/diff/parse.js +303 -0
- package/dist/diff/parse.js.map +1 -0
- package/dist/diff/types.d.ts +106 -0
- package/dist/diff/types.d.ts.map +1 -0
- package/dist/diff/types.js +23 -0
- package/dist/diff/types.js.map +1 -0
- package/dist/embed.d.ts +5 -2
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.js +7 -3
- package/dist/embed.js.map +1 -1
- package/dist/enhance/prompt.d.ts +5 -1
- package/dist/enhance/prompt.d.ts.map +1 -1
- package/dist/enhance/prompt.js +9 -2
- package/dist/enhance/prompt.js.map +1 -1
- package/dist/format.d.ts +31 -0
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +256 -15
- package/dist/format.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/pageindex/index.d.ts +2 -2
- package/dist/memory/pageindex/index.d.ts.map +1 -1
- package/dist/memory/pageindex/index.js.map +1 -1
- package/dist/memory/pageindex/service.d.ts +10 -1
- package/dist/memory/pageindex/service.d.ts.map +1 -1
- package/dist/memory/pageindex/service.js +2 -2
- package/dist/memory/pageindex/service.js.map +1 -1
- package/dist/memory/persist.d.ts.map +1 -1
- package/dist/memory/persist.js +10 -3
- package/dist/memory/persist.js.map +1 -1
- package/dist/memory/privacy.d.ts.map +1 -1
- package/dist/memory/privacy.js +45 -6
- package/dist/memory/privacy.js.map +1 -1
- package/dist/memory/sqlite.d.ts +1 -13
- package/dist/memory/sqlite.d.ts.map +1 -1
- package/dist/memory/sqlite.js +45 -27
- package/dist/memory/sqlite.js.map +1 -1
- package/dist/memory/taxonomy.d.ts.map +1 -1
- package/dist/memory/taxonomy.js +6 -1
- package/dist/memory/taxonomy.js.map +1 -1
- package/dist/pipeline/degrade.d.ts +61 -0
- package/dist/pipeline/degrade.d.ts.map +1 -0
- package/dist/pipeline/degrade.js +58 -0
- package/dist/pipeline/degrade.js.map +1 -0
- package/dist/pipeline/enrich.d.ts +29 -0
- package/dist/pipeline/enrich.d.ts.map +1 -0
- package/dist/pipeline/enrich.js +271 -0
- package/dist/pipeline/enrich.js.map +1 -0
- package/dist/pipeline/execute.d.ts +22 -0
- package/dist/pipeline/execute.d.ts.map +1 -0
- package/dist/pipeline/execute.js +250 -0
- package/dist/pipeline/execute.js.map +1 -0
- package/dist/pipeline/finalize.d.ts +26 -0
- package/dist/pipeline/finalize.d.ts.map +1 -0
- package/dist/pipeline/finalize.js +52 -0
- package/dist/pipeline/finalize.js.map +1 -0
- package/dist/pipeline/gather-context.d.ts +25 -0
- package/dist/pipeline/gather-context.d.ts.map +1 -0
- package/dist/pipeline/gather-context.js +169 -0
- package/dist/pipeline/gather-context.js.map +1 -0
- package/dist/pipeline/gather-safe.d.ts +39 -0
- package/dist/pipeline/gather-safe.d.ts.map +1 -0
- package/dist/pipeline/gather-safe.js +127 -0
- package/dist/pipeline/gather-safe.js.map +1 -0
- package/dist/pipeline/prepare-graph.d.ts +54 -0
- package/dist/pipeline/prepare-graph.d.ts.map +1 -0
- package/dist/pipeline/prepare-graph.js +174 -0
- package/dist/pipeline/prepare-graph.js.map +1 -0
- package/dist/pipeline/prepare.d.ts +40 -0
- package/dist/pipeline/prepare.d.ts.map +1 -0
- package/dist/pipeline/prepare.js +233 -0
- package/dist/pipeline/prepare.js.map +1 -0
- package/dist/pipeline/providers.d.ts +54 -0
- package/dist/pipeline/providers.d.ts.map +1 -0
- package/dist/pipeline/providers.js +164 -0
- package/dist/pipeline/providers.js.map +1 -0
- package/dist/pipeline/results.d.ts +35 -0
- package/dist/pipeline/results.d.ts.map +1 -0
- package/dist/pipeline/results.js +122 -0
- package/dist/pipeline/results.js.map +1 -0
- package/dist/pipeline/state.d.ts +92 -0
- package/dist/pipeline/state.d.ts.map +1 -0
- package/dist/pipeline/state.js +13 -0
- package/dist/pipeline/state.js.map +1 -0
- package/dist/pipeline.d.ts +10 -9
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +36 -1213
- package/dist/pipeline.js.map +1 -1
- package/dist/providers/cli-bridge.d.ts +5 -0
- package/dist/providers/cli-bridge.d.ts.map +1 -1
- package/dist/providers/cli-bridge.js +65 -5
- package/dist/providers/cli-bridge.js.map +1 -1
- package/dist/providers/gateway-discovery.d.ts +60 -0
- package/dist/providers/gateway-discovery.d.ts.map +1 -0
- package/dist/providers/gateway-discovery.js +116 -0
- package/dist/providers/gateway-discovery.js.map +1 -0
- package/dist/providers/gateway.d.ts +8 -0
- package/dist/providers/gateway.d.ts.map +1 -1
- package/dist/providers/gateway.js +13 -1
- package/dist/providers/gateway.js.map +1 -1
- package/dist/providers/generate-fn.d.ts +1 -0
- package/dist/providers/generate-fn.d.ts.map +1 -1
- package/dist/providers/generate-fn.js.map +1 -1
- package/dist/recursive/index.d.ts +1 -0
- package/dist/recursive/index.d.ts.map +1 -1
- package/dist/recursive/index.js +7 -3
- package/dist/recursive/index.js.map +1 -1
- package/dist/recursive/patch-extractor.d.ts +58 -6
- package/dist/recursive/patch-extractor.d.ts.map +1 -1
- package/dist/recursive/patch-extractor.js +207 -26
- package/dist/recursive/patch-extractor.js.map +1 -1
- package/dist/sanitize.d.ts +51 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/sanitize.js +90 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/scope/diff-mapper.d.ts +12 -0
- package/dist/scope/diff-mapper.d.ts.map +1 -1
- package/dist/scope/diff-mapper.js +25 -18
- package/dist/scope/diff-mapper.js.map +1 -1
- package/dist/scope/entity-diff.d.ts +21 -4
- package/dist/scope/entity-diff.d.ts.map +1 -1
- package/dist/scope/entity-diff.js +132 -34
- package/dist/scope/entity-diff.js.map +1 -1
- package/dist/scope/types.d.ts +10 -0
- package/dist/scope/types.d.ts.map +1 -1
- package/dist/semantic-diff/index.d.ts +25 -2
- package/dist/semantic-diff/index.d.ts.map +1 -1
- package/dist/semantic-diff/index.js +147 -53
- package/dist/semantic-diff/index.js.map +1 -1
- package/dist/tools/cpd.js +2 -2
- package/dist/tools/cpd.js.map +1 -1
- package/dist/tools/execution.d.ts +3 -1
- package/dist/tools/execution.d.ts.map +1 -1
- package/dist/tools/execution.js +10 -2
- package/dist/tools/execution.js.map +1 -1
- package/dist/tools/gitleaks-config.toml +58 -0
- package/dist/tools/plugins/gitleaks.d.ts +10 -0
- package/dist/tools/plugins/gitleaks.d.ts.map +1 -1
- package/dist/tools/plugins/gitleaks.js +29 -2
- package/dist/tools/plugins/gitleaks.js.map +1 -1
- package/dist/tools/plugins/semgrep.d.ts +11 -0
- package/dist/tools/plugins/semgrep.d.ts.map +1 -1
- package/dist/tools/plugins/semgrep.js +30 -1
- package/dist/tools/plugins/semgrep.js.map +1 -1
- package/dist/tools/runner.d.ts.map +1 -1
- package/dist/tools/runner.js +2 -1
- package/dist/tools/runner.js.map +1 -1
- package/dist/tools/semgrep-rules.yml +305 -0
- package/dist/tools/semgrep.js +2 -2
- package/dist/tools/semgrep.js.map +1 -1
- package/dist/types.d.ts +58 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/diff.d.ts +22 -2
- package/dist/utils/diff.d.ts.map +1 -1
- package/dist/utils/diff.js +36 -40
- package/dist/utils/diff.js.map +1 -1
- package/package.json +21 -22
- package/dist/providers/fallback.d.ts +0 -54
- package/dist/providers/fallback.d.ts.map +0 -1
- package/dist/providers/fallback.js +0 -102
- package/dist/providers/fallback.js.map +0 -1
- package/dist/providers/index.d.ts +0 -49
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -146
- package/dist/providers/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff-mapper.d.ts","sourceRoot":"","sources":["../../src/scope/diff-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"diff-mapper.d.ts","sourceRoot":"","sources":["../../src/scope/diff-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIvE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,EAAE,CAqB1D;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,cAAc,EAAE,CAqB3F"}
|
|
@@ -6,34 +6,41 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Pure functions with no side effects.
|
|
8
8
|
*/
|
|
9
|
+
import { matchHunkHeader, parseUnifiedDiff } from '../diff/index.js';
|
|
9
10
|
// ─── Hunk Parsing ──────────────────────────────────────────────
|
|
10
|
-
/**
|
|
11
|
-
* Regex to match unified diff hunk headers.
|
|
12
|
-
* Format: @@ -oldStart[,oldCount] +newStart[,newCount] @@
|
|
13
|
-
*
|
|
14
|
-
* Examples:
|
|
15
|
-
* @@ -10,5 +10,7 @@
|
|
16
|
-
* @@ -1 +1,3 @@
|
|
17
|
-
* @@ -0,0 +1,20 @@
|
|
18
|
-
*/
|
|
19
|
-
const HUNK_HEADER_RE = /^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/;
|
|
20
11
|
/**
|
|
21
12
|
* Parse unified diff content to extract hunk line ranges.
|
|
22
13
|
*
|
|
14
|
+
* Thin adapter over the unified parser (`src/diff/parse.ts`): model hunks
|
|
15
|
+
* are mapped down to the 4 captures this module has always returned. Bare
|
|
16
|
+
* hunk fragments WITHOUT any `diff --git` header (a documented input shape —
|
|
17
|
+
* "raw unified diff content for a single file") land in the model's
|
|
18
|
+
* `preamble`, so those lines are scanned with the shared `matchHunkHeader`
|
|
19
|
+
* (THE single hunk-header regex of core, spec R8).
|
|
20
|
+
*
|
|
21
|
+
* KNOWN synthetic-only divergence vs the pre-adapter regex (`\s+`
|
|
22
|
+
* separators): headers with tabs or multiple spaces (`@@ -1,2 +3,4 @@`)
|
|
23
|
+
* no longer match. git only ever emits the single-space form; pinned in
|
|
24
|
+
* `src/diff/__tests__/parity-parse-hunks.test.ts`.
|
|
25
|
+
*
|
|
23
26
|
* @param diffContent - Raw unified diff content for a single file
|
|
24
27
|
* @returns Array of DiffHunk objects with line ranges
|
|
25
28
|
*/
|
|
26
29
|
export function parseHunks(diffContent) {
|
|
30
|
+
const { preamble, files } = parseUnifiedDiff(diffContent);
|
|
27
31
|
const hunks = [];
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
for (const line of preamble) {
|
|
33
|
+
const match = matchHunkHeader(line);
|
|
34
|
+
if (match)
|
|
35
|
+
hunks.push(match);
|
|
36
|
+
}
|
|
37
|
+
for (const file of files) {
|
|
38
|
+
for (const hunk of file.hunks) {
|
|
32
39
|
hunks.push({
|
|
33
|
-
oldStart:
|
|
34
|
-
oldCount:
|
|
35
|
-
newStart:
|
|
36
|
-
newCount:
|
|
40
|
+
oldStart: hunk.oldStart,
|
|
41
|
+
oldCount: hunk.oldCount,
|
|
42
|
+
newStart: hunk.newStart,
|
|
43
|
+
newCount: hunk.newCount,
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff-mapper.js","sourceRoot":"","sources":["../../src/scope/diff-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"diff-mapper.js","sourceRoot":"","sources":["../../src/scope/diff-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGrE,kEAAkE;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,UAAU,CAAC,WAAmB;IAC5C,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAe,EAAE,CAAC;IAE7B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,MAA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AI,IAAI,IAAI,MAAM,IAAI,IAAI,CAAC;AAC1C,CAAC"}
|
|
@@ -12,11 +12,28 @@
|
|
|
12
12
|
import type { AffectedSymbol, EntityChange, EntityDiffOptions, RenameMatch, SymbolInfo } from './types.js';
|
|
13
13
|
/**
|
|
14
14
|
* Extract the actual addition/deletion lines from a diff that fall
|
|
15
|
-
* within a symbol's line range
|
|
15
|
+
* within a symbol's line range. Symbol ranges are NEW-side line numbers
|
|
16
|
+
* (contract of mapDiffToSymbols: symbols come from the NEW version of the
|
|
17
|
+
* file), so BOTH additions and deletions are attributed by the live
|
|
18
|
+
* new-side position — for a deletion, the new-side line where the removal
|
|
19
|
+
* happened (CORE-M9 fix; previously deletions were compared by their
|
|
20
|
+
* OLD-side line number against the new-side ranges, mis-attributing them
|
|
21
|
+
* whenever earlier hunks made old/new drift apart).
|
|
16
22
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
23
|
+
* Thin adapter over the unified parser (`src/diff/parse.ts`): the walk runs
|
|
24
|
+
* over the byte-exact line stream `[...preamble, ...files[].rawLines]`
|
|
25
|
+
* (≡ `diffContent.split('\n')` by the model's R2 reconstruction invariant),
|
|
26
|
+
* NOT over `hunk.lines` — preserving the historical behaviors the structured
|
|
27
|
+
* hunks do not carry: bare hunk fragments without a `diff --git` header
|
|
28
|
+
* (kept in `preamble`), orphan +/- tails after a genuine empty line
|
|
29
|
+
* mid-hunk, and metadata lines counted as context. Hunk headers are
|
|
30
|
+
* detected with the shared `matchHunkHeader` (THE single hunk-header regex
|
|
31
|
+
* of core, spec R8).
|
|
32
|
+
*
|
|
33
|
+
* KNOWN synthetic-only divergence vs the pre-adapter `\s+` regex: hunk
|
|
34
|
+
* headers with tabs/multiple spaces no longer reset the position counter
|
|
35
|
+
* (git only emits the single-space form); pinned in
|
|
36
|
+
* `src/diff/__tests__/parity-extract-entity-diff-lines.test.ts`.
|
|
20
37
|
*
|
|
21
38
|
* @param diffContent - Raw unified diff content for a single file
|
|
22
39
|
* @param symbol - The symbol whose range to extract lines for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-diff.d.ts","sourceRoot":"","sources":["../../src/scope/entity-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"entity-diff.d.ts","sourceRoot":"","sources":["../../src/scope/entity-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,UAAU,EACX,MAAM,YAAY,CAAC;AAuBpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,CAoCxF;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,cAAc,EAAE,EACjC,WAAW,EAAE,MAAM,GAClB,YAAY,EAAE,CAqBhB;AAoID;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,cAAc,EAAE,UAAU,EAAE,EAC5B,YAAY,EAAE,UAAU,EAAE,EAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,WAAW,EAAE,CAuDf;AAID;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAE1E"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Pure functions with no side effects.
|
|
11
11
|
*/
|
|
12
|
+
import { matchHunkHeader, parseUnifiedDiff } from '../diff/index.js';
|
|
12
13
|
import { ENTITY_CHANGE_KIND } from './types.js';
|
|
13
14
|
// ─── Constants ────────────────────────────────────────────────
|
|
14
15
|
const DEFAULT_SIMILARITY_THRESHOLD = 0.9;
|
|
@@ -28,52 +29,65 @@ const COSMETIC_LINE_PATTERNS = [
|
|
|
28
29
|
// ─── Extract Diff Lines ───────────────────────────────────────
|
|
29
30
|
/**
|
|
30
31
|
* Extract the actual addition/deletion lines from a diff that fall
|
|
31
|
-
* within a symbol's line range
|
|
32
|
+
* within a symbol's line range. Symbol ranges are NEW-side line numbers
|
|
33
|
+
* (contract of mapDiffToSymbols: symbols come from the NEW version of the
|
|
34
|
+
* file), so BOTH additions and deletions are attributed by the live
|
|
35
|
+
* new-side position — for a deletion, the new-side line where the removal
|
|
36
|
+
* happened (CORE-M9 fix; previously deletions were compared by their
|
|
37
|
+
* OLD-side line number against the new-side ranges, mis-attributing them
|
|
38
|
+
* whenever earlier hunks made old/new drift apart).
|
|
32
39
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
40
|
+
* Thin adapter over the unified parser (`src/diff/parse.ts`): the walk runs
|
|
41
|
+
* over the byte-exact line stream `[...preamble, ...files[].rawLines]`
|
|
42
|
+
* (≡ `diffContent.split('\n')` by the model's R2 reconstruction invariant),
|
|
43
|
+
* NOT over `hunk.lines` — preserving the historical behaviors the structured
|
|
44
|
+
* hunks do not carry: bare hunk fragments without a `diff --git` header
|
|
45
|
+
* (kept in `preamble`), orphan +/- tails after a genuine empty line
|
|
46
|
+
* mid-hunk, and metadata lines counted as context. Hunk headers are
|
|
47
|
+
* detected with the shared `matchHunkHeader` (THE single hunk-header regex
|
|
48
|
+
* of core, spec R8).
|
|
49
|
+
*
|
|
50
|
+
* KNOWN synthetic-only divergence vs the pre-adapter `\s+` regex: hunk
|
|
51
|
+
* headers with tabs/multiple spaces no longer reset the position counter
|
|
52
|
+
* (git only emits the single-space form); pinned in
|
|
53
|
+
* `src/diff/__tests__/parity-extract-entity-diff-lines.test.ts`.
|
|
36
54
|
*
|
|
37
55
|
* @param diffContent - Raw unified diff content for a single file
|
|
38
56
|
* @param symbol - The symbol whose range to extract lines for
|
|
39
57
|
* @returns Array of raw diff lines (with +/- prefix) within the symbol range
|
|
40
58
|
*/
|
|
41
59
|
export function extractEntityDiffLines(diffContent, symbol) {
|
|
42
|
-
const
|
|
60
|
+
const { preamble, files } = parseUnifiedDiff(diffContent);
|
|
61
|
+
const stream = [...preamble, ...files.flatMap((f) => f.rawLines)];
|
|
43
62
|
const result = [];
|
|
44
63
|
let currentNewLine = 0;
|
|
45
|
-
let currentOldLine = 0;
|
|
46
64
|
let inHunk = false;
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
currentOldLine = Number.parseInt(hunkMatch[1], 10);
|
|
52
|
-
currentNewLine = Number.parseInt(hunkMatch[2], 10);
|
|
65
|
+
for (const line of stream) {
|
|
66
|
+
const hunk = matchHunkHeader(line);
|
|
67
|
+
if (hunk) {
|
|
68
|
+
currentNewLine = hunk.newStart;
|
|
53
69
|
inHunk = true;
|
|
54
70
|
continue;
|
|
55
71
|
}
|
|
56
72
|
if (!inHunk)
|
|
57
73
|
continue;
|
|
58
74
|
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
59
|
-
// Addition —
|
|
75
|
+
// Addition — lives at the current new-side line, then advances it.
|
|
60
76
|
if (currentNewLine >= symbol.startLine && currentNewLine <= symbol.endLine) {
|
|
61
77
|
result.push(line);
|
|
62
78
|
}
|
|
63
79
|
currentNewLine++;
|
|
64
80
|
}
|
|
65
81
|
else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
66
|
-
// Deletion —
|
|
67
|
-
//
|
|
68
|
-
if (
|
|
82
|
+
// Deletion — attributed to the new-side position where the removal
|
|
83
|
+
// happened (CORE-M9). A deletion does NOT advance the new side.
|
|
84
|
+
if (currentNewLine >= symbol.startLine && currentNewLine <= symbol.endLine) {
|
|
69
85
|
result.push(line);
|
|
70
86
|
}
|
|
71
|
-
currentOldLine++;
|
|
72
87
|
}
|
|
73
88
|
else {
|
|
74
|
-
// Context line — advances
|
|
89
|
+
// Context (or any other) line — advances the new-side position.
|
|
75
90
|
currentNewLine++;
|
|
76
|
-
currentOldLine++;
|
|
77
91
|
}
|
|
78
92
|
}
|
|
79
93
|
return result;
|
|
@@ -134,28 +148,106 @@ function normalizeBody(body) {
|
|
|
134
148
|
.trim();
|
|
135
149
|
}
|
|
136
150
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
151
|
+
* Defensive cap on LCS input size (CORE-M8). Inputs are normalized entity
|
|
152
|
+
* bodies from a diff, typically well under this. The DP below is O(n*m)
|
|
153
|
+
* time, so two pathological ~100 KB bodies (e.g. a class spanning a whole
|
|
154
|
+
* generated file) would cost ~10^10 cell updates. Beyond the cap the DP
|
|
155
|
+
* compares the first MAX chars of each body only, but the similarity
|
|
156
|
+
* denominator keeps the ORIGINAL lengths — so two giant bodies identical
|
|
157
|
+
* only within the capped prefix score at most `cap / max(original lens)`
|
|
158
|
+
* (e.g. two 15k bodies sharing only their first 10k score ≤ 0.67), never a
|
|
159
|
+
* false 1.0. Trade-off: similarity living past the cap is invisible to the
|
|
160
|
+
* DP, so genuinely-similar giant pairs may be under-scored and missed —
|
|
161
|
+
* degraded detection on pathological inputs, never unbounded CPU.
|
|
162
|
+
*/
|
|
163
|
+
const MAX_SIMILARITY_INPUT_LENGTH = 10_000;
|
|
164
|
+
/**
|
|
165
|
+
* Default total LCS DP work budget for one detectRenames call (CORE-M8
|
|
166
|
+
* fix-forward). detectRenames compares every removed×added pair and each
|
|
167
|
+
* pair that reaches the DP costs n*m cell updates (n, m ≤ the 10k input
|
|
168
|
+
* cap, so a single worst-case pair is 10^8 cells ≈ a few hundred ms).
|
|
169
|
+
* 200M cells keeps the absolute worst case at low single-digit seconds on
|
|
170
|
+
* commodity hardware while covering thousands of realistic pairs (~2000
|
|
171
|
+
* pairs of 300×300-char bodies). Trade-off (same spirit as the input cap):
|
|
172
|
+
* once the budget is exhausted, remaining pairs are reported as
|
|
173
|
+
* not-similar (no rename) — renames can go undetected on pathological
|
|
174
|
+
* diffs, CPU is never unbounded. Overridable per call via
|
|
175
|
+
* `EntityDiffOptions.lcsDpCellBudget`.
|
|
176
|
+
*/
|
|
177
|
+
const DEFAULT_LCS_DP_CELL_BUDGET = 200_000_000;
|
|
178
|
+
/**
|
|
179
|
+
* Compute similarity ratio between two strings (0.0–1.0) as
|
|
180
|
+
* `LCS(a, b) / max(len(a), len(b))` — a real longest-common-subsequence
|
|
181
|
+
* ratio (CORE-M8; the previous implementation claimed LCS but compared
|
|
182
|
+
* characters at the same positions, so a one-char shift like "Xabcde" vs
|
|
183
|
+
* "abcde" scored near 0 instead of high).
|
|
184
|
+
*
|
|
185
|
+
* Classic two-row dynamic programming: O(n*m) time, O(min(n, m)) memory.
|
|
139
186
|
* Returns 1.0 for identical strings, 0.0 for completely different.
|
|
187
|
+
*
|
|
188
|
+
* Guards, in evaluation order (CORE-M8 fix-forward):
|
|
189
|
+
* 1. Identity fast-path on the ORIGINAL strings → exact 1.0 (never on the
|
|
190
|
+
* capped slices — equal capped prefixes of differing bodies are NOT 1.0).
|
|
191
|
+
* 2. Free prefilter: LCS(a, b) ≤ min(len(a), len(b), cap), so when that
|
|
192
|
+
* bound over `max(len)` is already below `threshold` the pair cannot
|
|
193
|
+
* match — skip the O(n*m) DP entirely. Returns 0.0; the caller only
|
|
194
|
+
* compares the result against `threshold`, so any sub-threshold value
|
|
195
|
+
* is equivalent (reported similarities of accepted matches are exact).
|
|
196
|
+
* 3. Capped-identity shortcut: equal capped prefixes have LCS exactly
|
|
197
|
+
* equal to the capped length — score `cap / max(original lens)` with
|
|
198
|
+
* no DP.
|
|
199
|
+
* 4. DP cell budget: each DP run consumes n*m cells from `budget`; a pair
|
|
200
|
+
* that would exceed what remains returns 0.0 (treated as not similar)
|
|
201
|
+
* instead of running.
|
|
140
202
|
*/
|
|
141
|
-
function computeSimilarity(a, b) {
|
|
203
|
+
function computeSimilarity(a, b, threshold, budget) {
|
|
142
204
|
if (a === b)
|
|
143
205
|
return 1.0;
|
|
144
206
|
if (a.length === 0 || b.length === 0)
|
|
145
207
|
return 0.0;
|
|
208
|
+
// Denominator over ORIGINAL lengths: a post-cap denominator let two >10k
|
|
209
|
+
// bodies with identical capped prefixes score a false 1.0.
|
|
146
210
|
const maxLen = Math.max(a.length, b.length);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
211
|
+
const lcsUpperBound = Math.min(a.length, b.length, MAX_SIMILARITY_INPUT_LENGTH);
|
|
212
|
+
if (lcsUpperBound / maxLen < threshold)
|
|
213
|
+
return 0.0;
|
|
214
|
+
const s = a.length > MAX_SIMILARITY_INPUT_LENGTH ? a.slice(0, MAX_SIMILARITY_INPUT_LENGTH) : a;
|
|
215
|
+
const t = b.length > MAX_SIMILARITY_INPUT_LENGTH ? b.slice(0, MAX_SIMILARITY_INPUT_LENGTH) : b;
|
|
216
|
+
if (s === t)
|
|
217
|
+
return s.length / maxLen;
|
|
218
|
+
const cells = s.length * t.length;
|
|
219
|
+
if (cells > budget.cellsRemaining)
|
|
220
|
+
return 0.0;
|
|
221
|
+
budget.cellsRemaining -= cells;
|
|
222
|
+
return lcsLength(s, t) / maxLen;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Length of the longest common subsequence of two strings.
|
|
226
|
+
* Two-row DP over the shorter string to keep memory at O(min(n, m)).
|
|
227
|
+
*/
|
|
228
|
+
function lcsLength(a, b) {
|
|
229
|
+
const longer = a.length >= b.length ? a : b;
|
|
230
|
+
const shorter = a.length >= b.length ? b : a;
|
|
231
|
+
const cols = shorter.length;
|
|
232
|
+
let prev = new Uint32Array(cols + 1);
|
|
233
|
+
let curr = new Uint32Array(cols + 1);
|
|
234
|
+
for (let i = 1; i <= longer.length; i++) {
|
|
235
|
+
const charCode = longer.charCodeAt(i - 1);
|
|
236
|
+
for (let j = 1; j <= cols; j++) {
|
|
237
|
+
if (charCode === shorter.charCodeAt(j - 1)) {
|
|
238
|
+
curr[j] = prev[j - 1] + 1;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
const fromTop = prev[j];
|
|
242
|
+
const fromLeft = curr[j - 1];
|
|
243
|
+
curr[j] = fromTop >= fromLeft ? fromTop : fromLeft;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const swap = prev;
|
|
247
|
+
prev = curr;
|
|
248
|
+
curr = swap;
|
|
157
249
|
}
|
|
158
|
-
return
|
|
250
|
+
return prev[cols];
|
|
159
251
|
}
|
|
160
252
|
/**
|
|
161
253
|
* Detect renamed entities by matching removed symbols with added symbols
|
|
@@ -170,6 +262,12 @@ function computeSimilarity(a, b) {
|
|
|
170
262
|
*/
|
|
171
263
|
export function detectRenames(removedSymbols, addedSymbols, oldSource, newSource, options) {
|
|
172
264
|
const threshold = options?.similarityThreshold ?? DEFAULT_SIMILARITY_THRESHOLD;
|
|
265
|
+
// Shared across ALL removed×added pairs of this call (CORE-M8 fix-forward):
|
|
266
|
+
// bounds total DP work so a pathological diff (many large bodies) degrades
|
|
267
|
+
// to missed renames instead of unbounded CPU.
|
|
268
|
+
const budget = {
|
|
269
|
+
cellsRemaining: options?.lcsDpCellBudget ?? DEFAULT_LCS_DP_CELL_BUDGET,
|
|
270
|
+
};
|
|
173
271
|
const renames = [];
|
|
174
272
|
const matchedAdded = new Set();
|
|
175
273
|
const oldLines = oldSource.split('\n');
|
|
@@ -193,7 +291,7 @@ export function detectRenames(removedSymbols, addedSymbols, oldSource, newSource
|
|
|
193
291
|
const newBody = normalizeBody(newLines.slice(newBodyStart, added.endLine).join('\n'));
|
|
194
292
|
if (newBody.length === 0)
|
|
195
293
|
continue;
|
|
196
|
-
const similarity = computeSimilarity(oldBody, newBody);
|
|
294
|
+
const similarity = computeSimilarity(oldBody, newBody, threshold, budget);
|
|
197
295
|
if (similarity >= threshold && (!bestMatch || similarity > bestMatch.similarity)) {
|
|
198
296
|
bestMatch = { index: i, similarity, symbol: added };
|
|
199
297
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-diff.js","sourceRoot":"","sources":["../../src/scope/entity-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"entity-diff.js","sourceRoot":"","sources":["../../src/scope/entity-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAQrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,iEAAiE;AAEjE,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEzC;;;GAGG;AACH,MAAM,sBAAsB,GAAa;IACvC,OAAO,EAAE,0BAA0B;IACnC,UAAU,EAAE,wCAAwC;IACpD,OAAO,EAAE,8BAA8B;IACvC,WAAW,EAAE,mDAAmD;IAChE,cAAc,EAAE,oBAAoB;IACpC,SAAS,EAAE,6BAA6B;IACxC,SAAS,EAAE,4CAA4C;CACxD,CAAC;AAEF,iEAAiE;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAAmB,EAAE,MAAkB;IAC5E,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,CAAC,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI,EAAE,CA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AAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC"}
|
package/dist/scope/types.d.ts
CHANGED
|
@@ -74,6 +74,16 @@ export interface RenameMatch {
|
|
|
74
74
|
export interface EntityDiffOptions {
|
|
75
75
|
/** Minimum body similarity to consider a rename (0.0–1.0). Default: 0.9 */
|
|
76
76
|
similarityThreshold?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Total LCS dynamic-programming cell budget (n*m per compared pair of
|
|
79
|
+
* normalized bodies) for one `detectRenames` call. Once exhausted,
|
|
80
|
+
* remaining pairs are treated as not similar (no rename) instead of
|
|
81
|
+
* running the O(n*m) DP — bounds CPU on pathological diffs with many
|
|
82
|
+
* large removed/added bodies. Identity matches and pairs resolved by
|
|
83
|
+
* the cheap prefilter consume no budget. Default: 200_000_000
|
|
84
|
+
* (~low single-digit seconds worst case).
|
|
85
|
+
*/
|
|
86
|
+
lcsDpCellBudget?: number;
|
|
77
87
|
}
|
|
78
88
|
/** A file with its affected symbols and source content, ready for scoped review. */
|
|
79
89
|
export interface ScopedFile {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/scope/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,2DAA2D;AAC3D,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,IAAI,CAAC;AAI1E,iDAAiD;AACjD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEvE,sEAAsE;AACtE,MAAM,WAAW,UAAU;IACzB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IAEb,qBAAqB;IACrB,IAAI,EAAE,UAAU,CAAC;IAEjB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAElB,0CAA0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,0BAA0B;IAC1B,MAAM,EAAE,UAAU,CAAC;IAEnB,mCAAmC;IACnC,IAAI,EAAE,gBAAgB,CAAC;IAEvB,sDAAsD;IACtD,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAEhB,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAEhB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IAEnB,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID,oFAAoF;AACpF,MAAM,WAAW,UAAU;IACzB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IAEjB,gDAAgD;IAChD,OAAO,EAAE,cAAc,EAAE,CAAC;IAE1B,uDAAuD;IACvD,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB"}
|
|
@@ -4,9 +4,29 @@
|
|
|
4
4
|
* Instead of raw line diffs, extracts WHAT changed at the entity level:
|
|
5
5
|
* function renamed, class added, method signature changed, etc.
|
|
6
6
|
*
|
|
7
|
-
* Implementation is regex-based — no tree-sitter required.
|
|
7
|
+
* Implementation is regex-based — no tree-sitter required. File sectioning
|
|
8
|
+
* is delegated to the unified diff parser (`src/diff/parse.ts`); declaration
|
|
9
|
+
* detection stays local.
|
|
10
|
+
*
|
|
11
|
+
* WIRED TO PRODUCTION (SDD wire-semantic-diff, 2026-06-13).
|
|
12
|
+
* `extractSemanticDiff` runs in the enrich phase (`pipeline/enrich.ts`),
|
|
13
|
+
* its result lands on `ReviewResult.semanticDiff`, and that feeds the
|
|
14
|
+
* "What changed" section of the PR comment via `formatSemanticDiffSection`
|
|
15
|
+
* (`format.ts`). This is no longer an unwired re-export.
|
|
16
|
+
*
|
|
17
|
+
* Known limitations (real, by design — the extractor is regex-based, not a
|
|
18
|
+
* parser, and matches single-line declarations only; all pinned in
|
|
19
|
+
* `index.test.ts`):
|
|
20
|
+
* - a multiline arrow whose `=>` lands on the next line is not detected;
|
|
21
|
+
* - a generic constraint CONTAINING parens (`<T extends () => void>`) is
|
|
22
|
+
* not detected (the `[^(]*` guard that keeps comparisons out excludes it);
|
|
23
|
+
* - declarations spanning multiple lines are matched only by their first
|
|
24
|
+
* line.
|
|
25
|
+
* The presentation layer (`format.ts`) drops `method_*` noise and gates to
|
|
26
|
+
* TS/JS files, so these misses degrade the cosmetic comment section only —
|
|
27
|
+
* never the review verdict.
|
|
8
28
|
*/
|
|
9
|
-
export type EntityChangeKind = 'function_added' | 'function_removed' | 'function_modified' | 'class_added' | 'class_removed' | 'method_added' | 'method_removed' | 'method_modified' | 'import_added' | 'import_removed' | 'export_added' | 'export_removed' | 'type_added' | 'type_removed' | 'type_modified';
|
|
29
|
+
export type EntityChangeKind = 'function_added' | 'function_removed' | 'function_modified' | 'class_added' | 'class_removed' | 'class_modified' | 'method_added' | 'method_removed' | 'method_modified' | 'import_added' | 'import_removed' | 'import_modified' | 'export_added' | 'export_removed' | 'export_modified' | 'type_added' | 'type_removed' | 'type_modified';
|
|
10
30
|
export interface EntityChange {
|
|
11
31
|
kind: EntityChangeKind;
|
|
12
32
|
name: string;
|
|
@@ -26,6 +46,9 @@ export interface SemanticDiff {
|
|
|
26
46
|
*
|
|
27
47
|
* Returns a SemanticDiff with individual EntityChange items and a
|
|
28
48
|
* human-readable summary string.
|
|
49
|
+
*
|
|
50
|
+
* Wired into the review pipeline (enrich phase → `ReviewResult.semanticDiff`
|
|
51
|
+
* → "What changed" PR comment section). See the module header.
|
|
29
52
|
*/
|
|
30
53
|
export declare function extractSemanticDiff(unifiedDiff: string): SemanticDiff;
|
|
31
54
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic-diff/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic-diff/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,YAAY,GACZ,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;CACjB;AA+MD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,CAiCrE"}
|