@descryy/core 0.3.0 → 0.5.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/dist/budget/reply.d.ts +11 -46
- package/dist/budget/reply.d.ts.map +1 -1
- package/dist/budget/reply.js +10 -39
- package/dist/budget/reply.js.map +1 -1
- package/dist/budget/size.d.ts +2 -21
- package/dist/budget/size.d.ts.map +1 -1
- package/dist/budget/size.js +3 -24
- package/dist/budget/size.js.map +1 -1
- package/dist/capabilities/preconditions.d.ts +7 -68
- package/dist/capabilities/preconditions.d.ts.map +1 -1
- package/dist/capabilities/preconditions.js +6 -57
- package/dist/capabilities/preconditions.js.map +1 -1
- package/dist/contracts/engine.d.ts +26 -12
- package/dist/contracts/engine.d.ts.map +1 -1
- package/dist/contracts/engine.js +28 -11
- package/dist/contracts/engine.js.map +1 -1
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/orphans.d.ts +28 -77
- package/dist/contracts/orphans.d.ts.map +1 -1
- package/dist/contracts/orphans.js +124 -94
- package/dist/contracts/orphans.js.map +1 -1
- package/dist/contracts/paths.d.ts +4 -114
- package/dist/contracts/paths.d.ts.map +1 -1
- package/dist/contracts/paths.js +7 -140
- package/dist/contracts/paths.js.map +1 -1
- package/dist/contracts/shapes.d.ts +13 -66
- package/dist/contracts/shapes.d.ts.map +1 -1
- package/dist/contracts/shapes.js +20 -91
- package/dist/contracts/shapes.js.map +1 -1
- package/dist/governance/budget.d.ts +12 -48
- package/dist/governance/budget.d.ts.map +1 -1
- package/dist/governance/budget.js +12 -48
- package/dist/governance/budget.js.map +1 -1
- package/dist/governance/candidate-boundary.d.ts +4 -32
- package/dist/governance/candidate-boundary.d.ts.map +1 -1
- package/dist/governance/candidate-boundary.js +4 -32
- package/dist/governance/candidate-boundary.js.map +1 -1
- package/dist/governance/escalation.d.ts +7 -45
- package/dist/governance/escalation.d.ts.map +1 -1
- package/dist/governance/escalation.js +7 -45
- package/dist/governance/escalation.js.map +1 -1
- package/dist/governance/fact-boundary.d.ts +7 -49
- package/dist/governance/fact-boundary.d.ts.map +1 -1
- package/dist/governance/fact-boundary.js +5 -43
- package/dist/governance/fact-boundary.js.map +1 -1
- package/dist/governance/finding-funnel.d.ts +11 -72
- package/dist/governance/finding-funnel.d.ts.map +1 -1
- package/dist/governance/finding-funnel.js +9 -68
- package/dist/governance/finding-funnel.js.map +1 -1
- package/dist/graph/build.d.ts +13 -75
- package/dist/graph/build.d.ts.map +1 -1
- package/dist/graph/build.js +0 -0
- package/dist/graph/build.js.map +1 -1
- package/dist/graph/cross-language.d.ts +4 -43
- package/dist/graph/cross-language.d.ts.map +1 -1
- package/dist/graph/cross-language.js +9 -77
- package/dist/graph/cross-language.js.map +1 -1
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/index.d.ts.map +1 -1
- package/dist/graph/merge.d.ts +8 -76
- package/dist/graph/merge.d.ts.map +1 -1
- package/dist/graph/merge.js +27 -77
- package/dist/graph/merge.js.map +1 -1
- package/dist/graph/observed-tests.d.ts +7 -68
- package/dist/graph/observed-tests.d.ts.map +1 -1
- package/dist/graph/observed-tests.js +5 -60
- package/dist/graph/observed-tests.js.map +1 -1
- package/dist/graph/persist.d.ts +2 -25
- package/dist/graph/persist.d.ts.map +1 -1
- package/dist/graph/persist.js +2 -25
- package/dist/graph/persist.js.map +1 -1
- package/dist/graph/runtime-confirmation.d.ts +14 -91
- package/dist/graph/runtime-confirmation.d.ts.map +1 -1
- package/dist/graph/runtime-confirmation.js +19 -103
- package/dist/graph/runtime-confirmation.js.map +1 -1
- package/dist/ledger/mint.d.ts +9 -43
- package/dist/ledger/mint.d.ts.map +1 -1
- package/dist/ledger/mint.js +15 -65
- package/dist/ledger/mint.js.map +1 -1
- package/dist/ledger/resolve.d.ts +13 -81
- package/dist/ledger/resolve.d.ts.map +1 -1
- package/dist/ledger/resolve.js +13 -76
- package/dist/ledger/resolve.js.map +1 -1
- package/dist/multipr/fingerprint.d.ts +5 -46
- package/dist/multipr/fingerprint.d.ts.map +1 -1
- package/dist/multipr/fingerprint.js +22 -74
- package/dist/multipr/fingerprint.js.map +1 -1
- package/dist/multipr/hidden-dependency.d.ts +13 -73
- package/dist/multipr/hidden-dependency.d.ts.map +1 -1
- package/dist/multipr/hidden-dependency.js +12 -63
- package/dist/multipr/hidden-dependency.js.map +1 -1
- package/dist/multipr/mechanical.d.ts +25 -160
- package/dist/multipr/mechanical.d.ts.map +1 -1
- package/dist/multipr/mechanical.js +21 -137
- package/dist/multipr/mechanical.js.map +1 -1
- package/dist/multipr/migration-heads.d.ts +18 -105
- package/dist/multipr/migration-heads.d.ts.map +1 -1
- package/dist/multipr/migration-heads.js +15 -84
- package/dist/multipr/migration-heads.js.map +1 -1
- package/dist/multipr/overlap.d.ts +16 -94
- package/dist/multipr/overlap.d.ts.map +1 -1
- package/dist/multipr/overlap.js +25 -105
- package/dist/multipr/overlap.js.map +1 -1
- package/dist/multipr/scope-store.d.ts +15 -80
- package/dist/multipr/scope-store.d.ts.map +1 -1
- package/dist/multipr/scope-store.js +17 -87
- package/dist/multipr/scope-store.js.map +1 -1
- package/dist/multipr/superseded.d.ts +10 -95
- package/dist/multipr/superseded.d.ts.map +1 -1
- package/dist/multipr/superseded.js +7 -60
- package/dist/multipr/superseded.js.map +1 -1
- package/dist/query/confirmed-facts.d.ts +12 -58
- package/dist/query/confirmed-facts.d.ts.map +1 -1
- package/dist/query/confirmed-facts.js +8 -47
- package/dist/query/confirmed-facts.js.map +1 -1
- package/dist/query/declared-value-closure.d.ts +13 -104
- package/dist/query/declared-value-closure.d.ts.map +1 -1
- package/dist/query/declared-value-closure.js +15 -104
- package/dist/query/declared-value-closure.js.map +1 -1
- package/dist/query/memory.d.ts +5 -9
- package/dist/query/memory.d.ts.map +1 -1
- package/dist/query/memory.js +31 -15
- package/dist/query/memory.js.map +1 -1
- package/dist/query/prominence.d.ts +6 -55
- package/dist/query/prominence.d.ts.map +1 -1
- package/dist/query/prominence.js +6 -55
- package/dist/query/prominence.js.map +1 -1
- package/dist/query/provider.d.ts +28 -81
- package/dist/query/provider.d.ts.map +1 -1
- package/dist/query/provider.js +8 -29
- package/dist/query/provider.js.map +1 -1
- package/dist/query/queries.d.ts +15 -65
- package/dist/query/queries.d.ts.map +1 -1
- package/dist/query/queries.js +43 -100
- package/dist/query/queries.js.map +1 -1
- package/dist/query/refusal-fetch.d.ts +8 -85
- package/dist/query/refusal-fetch.d.ts.map +1 -1
- package/dist/query/refusal-fetch.js +11 -93
- package/dist/query/refusal-fetch.js.map +1 -1
- package/dist/query/refusal-questions.d.ts +17 -92
- package/dist/query/refusal-questions.d.ts.map +1 -1
- package/dist/query/refusal-questions.js +14 -78
- package/dist/query/refusal-questions.js.map +1 -1
- package/dist/query/resolution-floor.d.ts +3 -23
- package/dist/query/resolution-floor.d.ts.map +1 -1
- package/dist/query/resolution-floor.js +3 -23
- package/dist/query/resolution-floor.js.map +1 -1
- package/dist/query/root-cause-score.d.ts +11 -161
- package/dist/query/root-cause-score.d.ts.map +1 -1
- package/dist/query/root-cause-score.js +6 -137
- package/dist/query/root-cause-score.js.map +1 -1
- package/dist/query/row-closure-picture.d.ts +5 -67
- package/dist/query/row-closure-picture.d.ts.map +1 -1
- package/dist/query/row-closure-picture.js +6 -67
- package/dist/query/row-closure-picture.js.map +1 -1
- package/dist/query/similar-incidents.d.ts +6 -41
- package/dist/query/similar-incidents.d.ts.map +1 -1
- package/dist/query/similar-incidents.js +15 -69
- package/dist/query/similar-incidents.js.map +1 -1
- package/dist/query/sqlite.d.ts +3 -7
- package/dist/query/sqlite.d.ts.map +1 -1
- package/dist/query/sqlite.js +13 -16
- package/dist/query/sqlite.js.map +1 -1
- package/dist/query/test-coverage.d.ts +5 -45
- package/dist/query/test-coverage.d.ts.map +1 -1
- package/dist/query/test-coverage.js +10 -53
- package/dist/query/test-coverage.js.map +1 -1
- package/dist/query/traverse.d.ts +22 -126
- package/dist/query/traverse.d.ts.map +1 -1
- package/dist/query/traverse.js +0 -0
- package/dist/query/traverse.js.map +1 -1
- package/dist/query/unresolved.d.ts +19 -164
- package/dist/query/unresolved.d.ts.map +1 -1
- package/dist/query/unresolved.js +11 -138
- package/dist/query/unresolved.js.map +1 -1
- package/dist/query/verification-status.d.ts +12 -109
- package/dist/query/verification-status.d.ts.map +1 -1
- package/dist/query/verification-status.js +9 -99
- package/dist/query/verification-status.js.map +1 -1
- package/dist/recording/migrate.d.ts +4 -10
- package/dist/recording/migrate.d.ts.map +1 -1
- package/dist/recording/migrate.js +4 -10
- package/dist/recording/migrate.js.map +1 -1
- package/dist/recording/reader.d.ts +2 -7
- package/dist/recording/reader.d.ts.map +1 -1
- package/dist/recording/reader.js +2 -7
- package/dist/recording/reader.js.map +1 -1
- package/dist/recording/redact.d.ts +6 -57
- package/dist/recording/redact.d.ts.map +1 -1
- package/dist/recording/redact.js +8 -64
- package/dist/recording/redact.js.map +1 -1
- package/dist/recording/schema.d.ts +3 -38
- package/dist/recording/schema.d.ts.map +1 -1
- package/dist/recording/schema.js +3 -38
- package/dist/recording/schema.js.map +1 -1
- package/dist/recording/writer.d.ts +11 -74
- package/dist/recording/writer.d.ts.map +1 -1
- package/dist/recording/writer.js +3 -43
- package/dist/recording/writer.js.map +1 -1
- package/dist/scoping/fanout.d.ts +6 -68
- package/dist/scoping/fanout.d.ts.map +1 -1
- package/dist/scoping/fanout.js +6 -68
- package/dist/scoping/fanout.js.map +1 -1
- package/dist/scoping/score.d.ts +20 -70
- package/dist/scoping/score.d.ts.map +1 -1
- package/dist/scoping/score.js +20 -70
- package/dist/scoping/score.js.map +1 -1
- package/dist/scoping/tiers.d.ts +4 -16
- package/dist/scoping/tiers.d.ts.map +1 -1
- package/dist/scoping/tiers.js +4 -16
- package/dist/scoping/tiers.js.map +1 -1
- package/dist/scoping/traverse.d.ts +3 -25
- package/dist/scoping/traverse.d.ts.map +1 -1
- package/dist/scoping/traverse.js +14 -49
- package/dist/scoping/traverse.js.map +1 -1
- package/dist/scoping/weights.d.ts +10 -74
- package/dist/scoping/weights.d.ts.map +1 -1
- package/dist/scoping/weights.js +14 -86
- package/dist/scoping/weights.js.map +1 -1
- package/dist/sources/confirmed/incidents.d.ts +5 -35
- package/dist/sources/confirmed/incidents.d.ts.map +1 -1
- package/dist/sources/confirmed/incidents.js +14 -48
- package/dist/sources/confirmed/incidents.js.map +1 -1
- package/dist/sources/git/diff.d.ts +71 -65
- package/dist/sources/git/diff.d.ts.map +1 -1
- package/dist/sources/git/diff.js +136 -83
- package/dist/sources/git/diff.js.map +1 -1
- package/dist/sources/git/env.d.ts +7 -0
- package/dist/sources/git/env.d.ts.map +1 -1
- package/dist/sources/git/env.js +10 -11
- package/dist/sources/git/env.js.map +1 -1
- package/dist/sources/git/history.d.ts +64 -84
- package/dist/sources/git/history.d.ts.map +1 -1
- package/dist/sources/git/history.js +141 -112
- package/dist/sources/git/history.js.map +1 -1
- package/dist/sources/git/incidents.d.ts +13 -75
- package/dist/sources/git/incidents.d.ts.map +1 -1
- package/dist/sources/git/incidents.js +21 -91
- package/dist/sources/git/incidents.js.map +1 -1
- package/dist/sources/git/index.d.ts +5 -3
- package/dist/sources/git/index.d.ts.map +1 -1
- package/dist/sources/git/index.js +3 -2
- package/dist/sources/git/index.js.map +1 -1
- package/dist/sources/git/source.d.ts +9 -79
- package/dist/sources/git/source.d.ts.map +1 -1
- package/dist/sources/git/source.js +0 -0
- package/dist/sources/git/source.js.map +1 -1
- package/dist/sources/migrations/across-change.d.ts +94 -0
- package/dist/sources/migrations/across-change.d.ts.map +1 -0
- package/dist/sources/migrations/across-change.js +278 -0
- package/dist/sources/migrations/across-change.js.map +1 -0
- package/dist/sources/migrations/dialects.d.ts +20 -36
- package/dist/sources/migrations/dialects.d.ts.map +1 -1
- package/dist/sources/migrations/dialects.js +11 -36
- package/dist/sources/migrations/dialects.js.map +1 -1
- package/dist/sources/migrations/index.d.ts +3 -1
- package/dist/sources/migrations/index.d.ts.map +1 -1
- package/dist/sources/migrations/index.js +2 -1
- package/dist/sources/migrations/index.js.map +1 -1
- package/dist/sources/migrations/read.d.ts +14 -79
- package/dist/sources/migrations/read.d.ts.map +1 -1
- package/dist/sources/migrations/read.js +14 -89
- package/dist/sources/migrations/read.js.map +1 -1
- package/dist/sources/workspace/workspace.d.ts +6 -42
- package/dist/sources/workspace/workspace.d.ts.map +1 -1
- package/dist/sources/workspace/workspace.js +10 -53
- package/dist/sources/workspace/workspace.js.map +1 -1
- package/dist/store/driver/driver.d.ts +9 -38
- package/dist/store/driver/driver.d.ts.map +1 -1
- package/dist/store/driver/driver.js +4 -22
- package/dist/store/driver/driver.js.map +1 -1
- package/dist/store/driver/node-sqlite.d.ts +3 -12
- package/dist/store/driver/node-sqlite.d.ts.map +1 -1
- package/dist/store/driver/node-sqlite.js +4 -18
- package/dist/store/driver/node-sqlite.js.map +1 -1
- package/dist/store/index.d.ts +2 -7
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +4 -10
- package/dist/store/index.js.map +1 -1
- package/dist/store/migrate.d.ts +14 -50
- package/dist/store/migrate.d.ts.map +1 -1
- package/dist/store/migrate.js +15 -52
- package/dist/store/migrate.js.map +1 -1
- package/dist/store/reader.d.ts +19 -84
- package/dist/store/reader.d.ts.map +1 -1
- package/dist/store/reader.js +25 -92
- package/dist/store/reader.js.map +1 -1
- package/dist/store/schema.d.ts +14 -76
- package/dist/store/schema.d.ts.map +1 -1
- package/dist/store/schema.js +14 -76
- package/dist/store/schema.js.map +1 -1
- package/dist/store/writer.d.ts +14 -88
- package/dist/store/writer.d.ts.map +1 -1
- package/dist/store/writer.js +29 -123
- package/dist/store/writer.js.map +1 -1
- package/dist/tiers/certify.d.ts +46 -281
- package/dist/tiers/certify.d.ts.map +1 -1
- package/dist/tiers/certify.js +46 -226
- package/dist/tiers/certify.js.map +1 -1
- package/dist/tiers/ladder.d.ts +7 -51
- package/dist/tiers/ladder.d.ts.map +1 -1
- package/dist/tiers/ladder.js +13 -89
- package/dist/tiers/ladder.js.map +1 -1
- package/dist/validation/attributes.d.ts +47 -0
- package/dist/validation/attributes.d.ts.map +1 -0
- package/dist/validation/attributes.js +130 -0
- package/dist/validation/attributes.js.map +1 -0
- package/dist/validation/config-graph.d.ts +7 -56
- package/dist/validation/config-graph.d.ts.map +1 -1
- package/dist/validation/config-graph.js +15 -61
- package/dist/validation/config-graph.js.map +1 -1
- package/dist/validation/env.d.ts +53 -2
- package/dist/validation/env.d.ts.map +1 -1
- package/dist/validation/env.js +99 -4
- package/dist/validation/env.js.map +1 -1
- package/dist/validation/index.d.ts +5 -1
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/index.js +3 -1
- package/dist/validation/index.js.map +1 -1
- package/dist/validation/join-substitution.d.ts +22 -120
- package/dist/validation/join-substitution.d.ts.map +1 -1
- package/dist/validation/join-substitution.js +13 -90
- package/dist/validation/join-substitution.js.map +1 -1
- package/dist/validation/migration-integrity.d.ts +72 -0
- package/dist/validation/migration-integrity.d.ts.map +1 -0
- package/dist/validation/migration-integrity.js +238 -0
- package/dist/validation/migration-integrity.js.map +1 -0
- package/dist/validation/migrations.d.ts +23 -88
- package/dist/validation/migrations.d.ts.map +1 -1
- package/dist/validation/migrations.js +20 -79
- package/dist/validation/migrations.js.map +1 -1
- package/dist/validation/nodes.d.ts +3 -1
- package/dist/validation/nodes.d.ts.map +1 -1
- package/dist/validation/nodes.js +3 -1
- package/dist/validation/nodes.js.map +1 -1
- package/dist/validation/rollback.d.ts +10 -73
- package/dist/validation/rollback.d.ts.map +1 -1
- package/dist/validation/rollback.js +23 -81
- package/dist/validation/rollback.js.map +1 -1
- package/dist/validation/route-drift.d.ts +9 -62
- package/dist/validation/route-drift.d.ts.map +1 -1
- package/dist/validation/route-drift.js +7 -52
- package/dist/validation/route-drift.js.map +1 -1
- package/dist/validation/sources.d.ts +16 -94
- package/dist/validation/sources.d.ts.map +1 -1
- package/dist/validation/sources.js +51 -147
- package/dist/validation/sources.js.map +1 -1
- package/dist/worker/pool.d.ts +6 -45
- package/dist/worker/pool.d.ts.map +1 -1
- package/dist/worker/pool.js +5 -42
- package/dist/worker/pool.js.map +1 -1
- package/dist/worker/protocol.d.ts +7 -20
- package/dist/worker/protocol.d.ts.map +1 -1
- package/dist/worker/protocol.js +3 -10
- package/dist/worker/protocol.js.map +1 -1
- package/dist/worker/traversal.worker.d.ts +2 -21
- package/dist/worker/traversal.worker.d.ts.map +1 -1
- package/dist/worker/traversal.worker.js +4 -23
- package/dist/worker/traversal.worker.js.map +1 -1
- package/package.json +11 -2
package/dist/sources/git/diff.js
CHANGED
|
@@ -1,79 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* bare path list. This answers "what changed in them" — per-file status and
|
|
6
|
-
* line counts always, plus the actual unified-diff patch text when it is
|
|
7
|
-
* cheap enough to hand to a model. §4's own worry ("the client's context
|
|
8
|
-
* window is not yours to spend") is the reason a patch is never returned
|
|
9
|
-
* unconditionally: a single large file rewrite can be tens of thousands of
|
|
10
|
-
* tokens, and a caller that wanted only "did this file change and how much"
|
|
11
|
-
* pays that cost with no way to decline it. `patchOmittedReason` names why,
|
|
12
|
-
* rather than silently shrinking the reply — the empty-denominator rule
|
|
13
|
-
* applies to a dropped patch exactly as it does to a dropped finding.
|
|
14
|
-
*
|
|
15
|
-
* Two size caps here, because one of them bounds nothing on its own:
|
|
16
|
-
* `maxPatchBytes` per file, and `maxTotalPatchBytes` across every patch in the
|
|
17
|
-
* reply. The second exists because a real 48-file branch diff, with 44 patches
|
|
18
|
-
* each *under* the per-file cap, summed to 229KB and hard-failed the call —
|
|
19
|
-
* the reply never reached the caller at all, which is the one failure mode a
|
|
20
|
-
* disclosure cannot repair after the fact.
|
|
21
|
-
*
|
|
22
|
-
* And a third above this file, for the same reason one level out: the same
|
|
23
|
-
* diff re-run with `maxTotalPatchBytes` correctly enforced still failed, at
|
|
24
|
-
* 84,516 characters, because these two caps bound patch text and a reply is
|
|
25
|
-
* not only patch text. `MAX_REPLY_BYTES` and `ToolAnswer.fitToBudget` in the
|
|
26
|
-
* MCP layer bound the serialized reply itself. Nothing here needs to know
|
|
27
|
-
* about that; it is noted because "the aggregate cap is enforced" was once
|
|
28
|
-
* mistaken for "the call now succeeds," and they are different claims.
|
|
29
|
-
*
|
|
30
|
-
* One `git diff` invocation for every file at once, not one per file — a
|
|
31
|
-
* PR touching fifty files would otherwise spawn fifty processes. The output
|
|
32
|
-
* is a concatenation of per-file blocks, each beginning with a line
|
|
33
|
-
* `diff --git a/<path> b/<path>`; parsing splits on that boundary and reads
|
|
34
|
-
* the more specific `rename from`/`rename to`/`new file mode`/
|
|
35
|
-
* `deleted file mode`/`Binary files … differ`/`---`/`+++` lines within each
|
|
36
|
-
* block, which are unambiguous where the `diff --git` header line alone is
|
|
37
|
-
* not (a path containing the literal substring `" b/"` defeats that header's
|
|
38
|
-
* own regex — an accepted, narrow gap, not a silent one, since every other
|
|
39
|
-
* line used here does not share it).
|
|
2
|
+
* §18's `get_git_diff`: live diff, patch text only when cheap — `patchOmittedReason` names why otherwise.
|
|
3
|
+
* Two caps here (`maxPatchBytes` per file, `maxTotalPatchBytes` total) plus a third in the MCP layer
|
|
4
|
+
* (`MAX_REPLY_BYTES`) — measured real failures at 229KB and 84,516 chars before these existed.
|
|
40
5
|
*/
|
|
41
6
|
import { execFile } from "node:child_process";
|
|
42
7
|
import { promisify } from "node:util";
|
|
43
8
|
import { applySerializedSizeBudget } from "../../budget/index.js";
|
|
44
|
-
import { cleanGitEnv } from "./env.js";
|
|
9
|
+
import { cleanGitEnv, HARDENED_GIT_CONFIG_ARGS } from "./env.js";
|
|
45
10
|
const execFileAsync = promisify(execFile);
|
|
46
|
-
//
|
|
11
|
+
// Strips GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE/GIT_COMMON_DIR, applies HARDENED_GIT_CONFIG_ARGS (env.ts, B-11).
|
|
47
12
|
function run(command, args, options) {
|
|
48
|
-
return execFileAsync(command, args, {
|
|
13
|
+
return execFileAsync(command, [...HARDENED_GIT_CONFIG_ARGS, ...args], {
|
|
49
14
|
...options,
|
|
50
15
|
encoding: "utf8",
|
|
51
16
|
env: cleanGitEnv(),
|
|
52
17
|
});
|
|
53
18
|
}
|
|
54
19
|
const DEFAULT_MAX_PATCH_BYTES = 20_000;
|
|
55
|
-
/**
|
|
56
|
-
* The cap on the sum of every returned patch. A per-file cap bounds no total:
|
|
57
|
-
* 44 files each under the 20,000-byte per-file cap summed to 229KB and
|
|
58
|
-
* hard-failed an ordinary 48-file branch diff before the reply was ever
|
|
59
|
-
* returned.
|
|
60
|
-
*
|
|
61
|
-
* Was 80,000, lowered after the same diff was re-run against that value and
|
|
62
|
-
* the call *still* failed, at 84,516 characters: 80,000 bytes of patch text
|
|
63
|
-
* leaves nothing for the 48 per-file rows, the disclosures and the envelope
|
|
64
|
-
* that surround them, so a budget that large is one the reply can never
|
|
65
|
-
* actually afford to spend. 40,000 leaves the reply's own size ceiling
|
|
66
|
-
* (`MAX_REPLY_BYTES`, in the MCP layer) room to be a backstop rather than the
|
|
67
|
-
* thing that fires on every ordinary wide diff — which matters because this
|
|
68
|
-
* budget's reason names an action the caller can take and that ceiling's does
|
|
69
|
-
* not. A starting value, as before, not a measurement.
|
|
70
|
-
*/
|
|
20
|
+
/** Cap on the sum of every returned patch — a per-file cap alone let 44 files summed to 229KB hard-fail a real diff. Was 80,000, lowered after 84,516 chars still failed. Starting value. */
|
|
71
21
|
const DEFAULT_MAX_TOTAL_PATCH_BYTES = 40_000;
|
|
72
|
-
/**
|
|
73
|
-
* The stable prefix of `patchOmittedReason` when the *total* budget, not the
|
|
74
|
-
* per-file cap, is what withheld a patch. Exported so a caller can tell the
|
|
75
|
-
* two apart without matching on prose it does not own.
|
|
76
|
-
*/
|
|
22
|
+
/** Stable prefix of `patchOmittedReason` when the total budget, not the per-file cap, withheld a patch. */
|
|
77
23
|
export const TOTAL_PATCH_BUDGET_REASON_PREFIX = "the reply's total patch budget";
|
|
78
24
|
function stripPrefix(path, prefix) {
|
|
79
25
|
return path.startsWith(prefix) ? path.slice(prefix.length) : path;
|
|
@@ -138,7 +84,9 @@ function parseDiffBlock(block) {
|
|
|
138
84
|
async function runGitDiff(cwd, revisionArgs, options) {
|
|
139
85
|
const maxPatchBytes = options.maxPatchBytes ?? DEFAULT_MAX_PATCH_BYTES;
|
|
140
86
|
const maxTotalPatchBytes = options.maxTotalPatchBytes ?? DEFAULT_MAX_TOTAL_PATCH_BYTES;
|
|
141
|
-
|
|
87
|
+
// --no-ext-diff (B-11): renders real patch text, so a repo-local
|
|
88
|
+
// `diff.external` would actually run here otherwise.
|
|
89
|
+
const args = ["diff", "--no-ext-diff", "-M", ...revisionArgs];
|
|
142
90
|
if (options.files !== undefined && options.files.length > 0)
|
|
143
91
|
args.push("--", ...options.files);
|
|
144
92
|
const { stdout } = await run("git", args, { cwd, maxBuffer: 256 * 1024 * 1024 });
|
|
@@ -170,19 +118,13 @@ async function runGitDiff(cwd, revisionArgs, options) {
|
|
|
170
118
|
: null,
|
|
171
119
|
});
|
|
172
120
|
}
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
// here and keeps the reason it already has.
|
|
121
|
+
// Aggregate cap, applied after per-file decisions — a file already withheld
|
|
122
|
+
// (binary or over its own cap) costs nothing here.
|
|
176
123
|
return applySerializedSizeBudget(files, {
|
|
177
124
|
maxTotalBytes: maxTotalPatchBytes,
|
|
178
125
|
sizeOf: (f) => (f.patch === null ? 0 : Buffer.byteLength(f.patch, "utf8")),
|
|
179
|
-
// Short on purpose
|
|
180
|
-
//
|
|
181
|
-
// files, or raise maxTotalPatchBytes") was paid for once per file to say
|
|
182
|
-
// the same thing each time, and measured at ~30KB on that diff: more than
|
|
183
|
-
// the patches it was explaining the absence of. The caller is told what to
|
|
184
|
-
// do once, in the reply's own note, which is where advice that is identical
|
|
185
|
-
// for every file belongs.
|
|
126
|
+
// Short on purpose: this reason repeats per file (187 of 200 on one wide
|
|
127
|
+
// diff), so a longer advice tail measured ~30KB — bigger than the patches it explained.
|
|
186
128
|
withhold: (f, spentBytes) => ({
|
|
187
129
|
...f,
|
|
188
130
|
patch: null,
|
|
@@ -191,24 +133,135 @@ async function runGitDiff(cwd, revisionArgs, options) {
|
|
|
191
133
|
}),
|
|
192
134
|
}).items;
|
|
193
135
|
}
|
|
194
|
-
/**
|
|
195
|
-
* `base...head` (three dots), matching `changedFiles`'s own reasoning: two
|
|
196
|
-
* dots would include everything changed on `base` since the branch point,
|
|
197
|
-
* misattributing someone else's history to this diff.
|
|
198
|
-
*/
|
|
136
|
+
/** `base...head` (three dots) — two dots would include everything changed on `base` since the branch point. */
|
|
199
137
|
export async function gitDiff(cwd, base, head = "HEAD", options = {}) {
|
|
200
138
|
return runGitDiff(cwd, [`${base}...${head}`], options);
|
|
201
139
|
}
|
|
202
140
|
/**
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* (`HEAD...HEAD` is empty by construction). Reuses the exact same block
|
|
206
|
-
* parser, rename detection and patch cap `gitDiff` does — see
|
|
207
|
-
* `DEC-NEXT-working-tree-diff-in-core` for why a second parser was rejected.
|
|
141
|
+
* Working-tree counterpart to {@link gitDiff}: a live diff against uncommitted state, which no
|
|
142
|
+
* two-revision `git diff` form can express. Reuses the same parser (`DEC-NEXT-working-tree-diff-in-core`).
|
|
208
143
|
*/
|
|
209
144
|
export async function gitWorkingTreeDiff(cwd, options = {}) {
|
|
210
145
|
const scope = options.scope ?? "unstaged";
|
|
211
146
|
const revisionArgs = scope === "staged" ? ["--cached"] : scope === "all" ? ["HEAD"] : [];
|
|
212
147
|
return runGitDiff(cwd, revisionArgs, options);
|
|
213
148
|
}
|
|
149
|
+
/** Untracked files past this many are counted and not diffed. */
|
|
150
|
+
const DEFAULT_MAX_UNTRACKED = 200;
|
|
151
|
+
/**
|
|
152
|
+
* The working tree as a change set, including files git has never seen.
|
|
153
|
+
*
|
|
154
|
+
* ## Why untracked needs its own mechanism
|
|
155
|
+
*
|
|
156
|
+
* No form of `git diff` reports an untracked file. `git diff HEAD` compares
|
|
157
|
+
* against what the index and `HEAD` hold, and a file git has never seen is in
|
|
158
|
+
* neither — so a working-tree mode built on the scopes above alone still misses
|
|
159
|
+
* the most common shape of work in progress: a new file, written, not yet
|
|
160
|
+
* added. That is exactly the case this was built for.
|
|
161
|
+
*
|
|
162
|
+
* ## `--no-index` rather than `add -N`
|
|
163
|
+
*
|
|
164
|
+
* The usual trick is `git add -N` to give the file an intent-to-add entry, then
|
|
165
|
+
* diff normally. **It writes to the index**, and a read tool that mutates the
|
|
166
|
+
* caller's repository to answer a question is not a read tool — it would also
|
|
167
|
+
* race any real `git add` the developer runs while it works.
|
|
168
|
+
*
|
|
169
|
+
* `git diff --no-index -- /dev/null <path>` needs no index and emits exactly the
|
|
170
|
+
* `new file mode` block the shared parser already handles, with the real path.
|
|
171
|
+
* It exits non-zero when the files differ, which for this call is always, so a
|
|
172
|
+
* non-zero exit here is the success case and is read for its stdout.
|
|
173
|
+
*
|
|
174
|
+
* ## `--exclude-standard` is load-bearing
|
|
175
|
+
*
|
|
176
|
+
* Without it the first answer on any real repository is a dependency directory
|
|
177
|
+
* reported as the developer's uncommitted work.
|
|
178
|
+
*/
|
|
179
|
+
export async function gitWorkingTreeChange(cwd, options = {}) {
|
|
180
|
+
const all = await gitWorkingTreeDiff(cwd, options);
|
|
181
|
+
const tracked = all.filter((file) => !isExcluded(file.path, options.exclude));
|
|
182
|
+
if (options.includeUntracked !== true) {
|
|
183
|
+
return { files: tracked, untrackedTotal: 0, untrackedTruncated: false };
|
|
184
|
+
}
|
|
185
|
+
const maxUntracked = options.maxUntracked ?? DEFAULT_MAX_UNTRACKED;
|
|
186
|
+
const listArgs = ["ls-files", "--others", "--exclude-standard"];
|
|
187
|
+
if (options.files !== undefined && options.files.length > 0) {
|
|
188
|
+
listArgs.push("--", ...options.files);
|
|
189
|
+
}
|
|
190
|
+
const { stdout } = await run("git", listArgs, { cwd, maxBuffer: 64 * 1024 * 1024 });
|
|
191
|
+
const untracked = stdout
|
|
192
|
+
.split("\n")
|
|
193
|
+
.map((line) => line.trim())
|
|
194
|
+
.filter((line) => line !== "" && !isExcluded(line, options.exclude))
|
|
195
|
+
.sort();
|
|
196
|
+
const diffed = untracked.slice(0, maxUntracked);
|
|
197
|
+
const added = [];
|
|
198
|
+
for (const path of diffed) {
|
|
199
|
+
let text;
|
|
200
|
+
try {
|
|
201
|
+
const result = await run("git", ["diff", "--no-index", "--", "/dev/null", path], {
|
|
202
|
+
cwd,
|
|
203
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
204
|
+
});
|
|
205
|
+
text = result.stdout;
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
// Non-zero exit is the ordinary outcome here: `--no-index` reports a
|
|
209
|
+
// difference the way `diff(1)` does. The patch is on the error.
|
|
210
|
+
const stdout = error.stdout;
|
|
211
|
+
if (typeof stdout !== "string" || stdout.trim() === "")
|
|
212
|
+
continue;
|
|
213
|
+
text = stdout;
|
|
214
|
+
}
|
|
215
|
+
const parsed = parseUntrackedBlock(text, path, options);
|
|
216
|
+
if (parsed !== null)
|
|
217
|
+
added.push(parsed);
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
files: [...tracked, ...added].sort((a, b) => a.path.localeCompare(b.path)),
|
|
221
|
+
untrackedTotal: untracked.length,
|
|
222
|
+
untrackedTruncated: untracked.length > diffed.length,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Is this path inside an excluded directory?
|
|
227
|
+
*
|
|
228
|
+
* A segment-boundary prefix match rather than `startsWith`: `.descry` must
|
|
229
|
+
* exclude `.descry/graph.db` and leave `src/.descryfile.ts` alone.
|
|
230
|
+
*/
|
|
231
|
+
function isExcluded(path, exclude) {
|
|
232
|
+
if (exclude === undefined)
|
|
233
|
+
return false;
|
|
234
|
+
return exclude.some((prefix) => path === prefix || path.startsWith(`${prefix}/`));
|
|
235
|
+
}
|
|
236
|
+
/** One `--no-index` block, through the same cap rules every other patch gets. */
|
|
237
|
+
function parseUntrackedBlock(text, path, options) {
|
|
238
|
+
const block = text.split(/\n(?=diff --git )/).find((b) => b.startsWith("diff --git "));
|
|
239
|
+
if (block === undefined)
|
|
240
|
+
return null;
|
|
241
|
+
const parsed = parseDiffBlock(block);
|
|
242
|
+
if (parsed === null)
|
|
243
|
+
return null;
|
|
244
|
+
const maxPatchBytes = options.maxPatchBytes ?? DEFAULT_MAX_PATCH_BYTES;
|
|
245
|
+
const bytes = Buffer.byteLength(block, "utf8");
|
|
246
|
+
const overCap = !parsed.binary && bytes > maxPatchBytes;
|
|
247
|
+
return {
|
|
248
|
+
// `--no-index` was given a path relative to `cwd` and echoes it back, but
|
|
249
|
+
// the finding is reported under the path the caller asked about.
|
|
250
|
+
path,
|
|
251
|
+
fromPath: null,
|
|
252
|
+
// A file git has never seen is an addition, whatever the block header says
|
|
253
|
+
// about `/dev/null` on the left.
|
|
254
|
+
status: "A",
|
|
255
|
+
binary: parsed.binary,
|
|
256
|
+
additions: parsed.binary ? null : parsed.additions,
|
|
257
|
+
deletions: parsed.binary ? null : 0,
|
|
258
|
+
patch: parsed.binary || overCap ? null : block,
|
|
259
|
+
patchOmittedReason: parsed.binary
|
|
260
|
+
? "binary file — no textual patch"
|
|
261
|
+
: overCap
|
|
262
|
+
? `diff for this file is ${bytes} bytes, over the ${maxPatchBytes}-byte cap — narrow ` +
|
|
263
|
+
'"files" to fetch it on its own, or raise "maxPatchBytes"'
|
|
264
|
+
: null,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
214
267
|
//# sourceMappingURL=diff.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/sources/git/diff.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/sources/git/diff.ts"],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OAAO,IAAI,CAAC;IAEjC,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,uBAAuB,CAAC;IACvE,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,KAAK,GAAG,aAAa,CAAC;IACxD,OAAO;QACL,0EAA0E;QAC1E,iEAAiE;QACjE,IAAI;QACJ,QAAQ,EAAE,IAAI;QACd,2EAA2E;QAC3E,iCAAiC;QACjC,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS;QAClD,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnC,KAAK,EAAE,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QAC9C,kBAAkB,EAAE,MAAM,CAAC,MAAM;YAC/B,CAAC,CAAC,gCAAgC;YAClC,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,yBAAyB,KAAK,oBAAoB,aAAa,qBAAqB;oBACpF,0DAA0D;gBAC5D,CAAC,CAAC,IAAI;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/** B-11: `cwd` may be an untrusted repo (e.g. an extracted archive with an
|
|
2
|
+
* attacker-authored `.git/config`). `GIT_CONFIG_NOSYSTEM` closes only the
|
|
3
|
+
* system-config layer, not repo-local config — see `HARDENED_GIT_CONFIG_ARGS`. */
|
|
1
4
|
export declare function cleanGitEnv(base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
5
|
+
/** `-c` overrides ahead of every git subcommand against a caller-supplied repo (B-11): neutralises `core.fsmonitor`/`core.pager` (external-command hooks; `GIT_CONFIG_NOSYSTEM` can't reach repo-local config), zero behavioural cost since output here never hits a tty.
|
|
6
|
+
* `diff.external` handled separately via `--no-ext-diff` at its two call sites (`diff.ts`, `multipr/fingerprint.ts`).
|
|
7
|
+
* `filter.*.clean` is NOT addressed — driver name is dynamic per-repo; unreachable through any call here today, disclosed as a residual gap. */
|
|
8
|
+
export declare const HARDENED_GIT_CONFIG_ARGS: readonly string[];
|
|
2
9
|
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/sources/git/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/sources/git/env.ts"],"names":[],"mappings":"AAMA;;mFAEmF;AACnF,wBAAgB,WAAW,CAAC,IAAI,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAAC,UAAU,CAKpF;AAED;;iJAEiJ;AACjJ,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAA2D,CAAC"}
|
package/dist/sources/git/env.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `GIT_WORK_TREE`/`GIT_INDEX_FILE`/`GIT_COMMON_DIR`) overrides repository
|
|
5
|
-
* discovery even when a git subprocess is given an explicit `cwd` — confirmed
|
|
6
|
-
* directly: `GIT_DIR=<other>/.git` with `cwd` pointed elsewhere still
|
|
7
|
-
* initialises `<other>/.git`, not a repository at `cwd`.
|
|
8
|
-
*
|
|
9
|
-
* Anything here that shells out to git against a caller-supplied path must
|
|
10
|
-
* not inherit these, or a caller running inside a git hook (which always has
|
|
11
|
-
* `GIT_DIR` set) silently operates on the hook's own repository instead of
|
|
12
|
-
* the one it was given.
|
|
2
|
+
* Git env vars that override repo discovery even with an explicit `cwd` (confirmed: `GIT_DIR` elsewhere still wins). Must be stripped before shelling out against a
|
|
3
|
+
* caller-supplied path, or a caller inside a git hook silently operates on the hook's own repo.
|
|
13
4
|
*/
|
|
14
5
|
const LEAKY_GIT_VARS = ["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR"];
|
|
6
|
+
/** B-11: `cwd` may be an untrusted repo (e.g. an extracted archive with an
|
|
7
|
+
* attacker-authored `.git/config`). `GIT_CONFIG_NOSYSTEM` closes only the
|
|
8
|
+
* system-config layer, not repo-local config — see `HARDENED_GIT_CONFIG_ARGS`. */
|
|
15
9
|
export function cleanGitEnv(base = process.env) {
|
|
16
10
|
const env = { ...base };
|
|
17
11
|
for (const key of LEAKY_GIT_VARS)
|
|
18
12
|
delete env[key];
|
|
13
|
+
env["GIT_CONFIG_NOSYSTEM"] = "1";
|
|
19
14
|
return env;
|
|
20
15
|
}
|
|
16
|
+
/** `-c` overrides ahead of every git subcommand against a caller-supplied repo (B-11): neutralises `core.fsmonitor`/`core.pager` (external-command hooks; `GIT_CONFIG_NOSYSTEM` can't reach repo-local config), zero behavioural cost since output here never hits a tty.
|
|
17
|
+
* `diff.external` handled separately via `--no-ext-diff` at its two call sites (`diff.ts`, `multipr/fingerprint.ts`).
|
|
18
|
+
* `filter.*.clean` is NOT addressed — driver name is dynamic per-repo; unreachable through any call here today, disclosed as a residual gap. */
|
|
19
|
+
export const HARDENED_GIT_CONFIG_ARGS = ["-c", "core.fsmonitor=false", "-c", "core.pager=cat"];
|
|
21
20
|
//# sourceMappingURL=env.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/sources/git/env.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/sources/git/env.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,CAAU,CAAC;AAEjG;;mFAEmF;AACnF,MAAM,UAAU,WAAW,CAAC,OAA0B,OAAO,CAAC,GAAG;IAC/D,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IACxB,KAAK,MAAM,GAAG,IAAI,cAAc;QAAE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;IAClD,GAAG,CAAC,qBAAqB,CAAC,GAAG,GAAG,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;iJAEiJ;AACjJ,MAAM,CAAC,MAAM,wBAAwB,GAAsB,CAAC,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reading git history.
|
|
3
|
-
*
|
|
4
|
-
* No dependency: `git` is invoked directly. A library would buy parsing help and
|
|
5
|
-
* cost a dependency in a package that has none by design, and the format below
|
|
6
|
-
* is chosen so parsing is unambiguous rather than clever.
|
|
7
|
-
*
|
|
8
|
-
* ## Renames are resolved, not ignored
|
|
9
|
-
*
|
|
10
|
-
* `CHANGES_WITH` is file-to-file, and `FILE` identity is DEC-004's documented
|
|
11
|
-
* path fallback — a file's only stable name *is* its path. So a rename silently
|
|
12
|
-
* splits a file's history in two: the co-change weight built up over two years
|
|
13
|
-
* resets to zero, and nothing in the output reveals it happened. That is the
|
|
14
|
-
* exact failure DEC-004 exists to prevent, arriving through the one node type
|
|
15
|
-
* that cannot avoid it.
|
|
16
|
-
*
|
|
17
|
-
* The fix is `-M` plus a canonicalisation pass: history is walked newest-first,
|
|
18
|
-
* and every historical path is mapped forward to the name the file has today. It
|
|
19
|
-
* makes DEC-004's guarantee total for files that git can *follow*; where git's
|
|
20
|
-
* rename detection fails (a rewrite with no similarity), the guarantee stays
|
|
21
|
-
* partial and that is now a bounded, stated gap rather than an unbounded one.
|
|
2
|
+
* Reading git history. No dependency: git invoked directly, no parsing library. Renames are resolved, not ignored: FILE identity is path-based (DEC-004), so an unresolved rename would silently reset co-change weight to zero.
|
|
3
|
+
* `-M` plus a newest-first canonicalisation pass maps every historical path forward to today's name — total where git can follow the rename, a disclosed partial gap where it can't (a rewrite with no similarity match).
|
|
22
4
|
*/
|
|
23
5
|
export interface CommitChange {
|
|
24
6
|
/** Path as it is known **today**, after following renames forward. */
|
|
@@ -42,15 +24,20 @@ export interface HistoryOptions {
|
|
|
42
24
|
readonly maxFilesPerCommit?: number;
|
|
43
25
|
}
|
|
44
26
|
export declare function gitHead(cwd: string): Promise<string>;
|
|
27
|
+
/** Thrown when the git process itself could not be run (missing binary,
|
|
28
|
+
* bad cwd) — distinct from git running and answering "not a repository".
|
|
29
|
+
* Collapsing the two (as this used to) teaches a false fact with no way to detect it; every caller must let this propagate rather than treat it as "not a repository". */
|
|
30
|
+
export declare class GitUnavailableError extends Error {
|
|
31
|
+
constructor(cwd: string, cause: unknown);
|
|
32
|
+
}
|
|
45
33
|
export declare function isGitRepository(cwd: string): Promise<boolean>;
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*/
|
|
34
|
+
/** Whether `absolutePath` is tracked by git in `cwd`. A-F1: a bare module
|
|
35
|
+
* specifier resolves against the scanned repo's own node_modules — a real
|
|
36
|
+
* `npm install` leaves it untracked, but a hostile repo can COMMIT a payload there for a victim who only clones and never runs install; tracked-in-git is the discriminator. Returns null (not false) when `cwd` isn't a git repo at all — "cannot determine" must never collapse into "untracked, therefore safe". Outside `cwd` entirely returns false. */
|
|
37
|
+
export declare function isPathTrackedByGit(cwd: string, absolutePath: string): Promise<boolean | null>;
|
|
38
|
+
/** Read history newest-first, renames followed forward. `--no-merges` is
|
|
39
|
+
* deliberate: a merge's file list is the union of both branches — the
|
|
40
|
+
* single largest source of false CHANGES_WITH edges, and free to exclude. */
|
|
54
41
|
export declare function readHistory(cwd: string, options?: HistoryOptions): Promise<Commit[]>;
|
|
55
42
|
export interface PathLogOptions {
|
|
56
43
|
/** Cap on commits returned. Default 20 — this is a live, on-demand read, not a bulk ingestion. */
|
|
@@ -70,71 +57,64 @@ export interface PathLogCommit {
|
|
|
70
57
|
}
|
|
71
58
|
export interface PathLogResult {
|
|
72
59
|
readonly commits: readonly PathLogCommit[];
|
|
73
|
-
/**
|
|
74
|
-
*
|
|
75
|
-
* A second, cheap `git log --format=%H` count — not `commits.length`,
|
|
76
|
-
* which stops at the cap — so a caller can tell "here are the 20 most
|
|
77
|
-
* recent" from "here are all 3 there are" without guessing from the cap.
|
|
78
|
-
*/
|
|
60
|
+
/** Total commits touching this path, independent of `maxCommits` — a
|
|
61
|
+
* second cheap count, not `commits.length`, which stops at the cap. */
|
|
79
62
|
readonly totalTouching: number;
|
|
80
63
|
}
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* built once at `analyze` time. `--follow` tracks the file across renames;
|
|
85
|
-
* unlike `readHistory`'s whole-repo walk, each commit here reports its own
|
|
86
|
-
* historical name rather than today's — the rename itself is part of what a
|
|
87
|
-
* caller asking "what happened to this file" wants to see.
|
|
88
|
-
*/
|
|
64
|
+
/** Live commit history for one file — distinct from the graph's stored
|
|
65
|
+
* CHANGES_WITH ledger. `--follow` tracks renames; each commit reports its
|
|
66
|
+
* own historical name, not today's — the rename is part of what's asked. */
|
|
89
67
|
export declare function logForPath(cwd: string, path: string, options?: PathLogOptions): Promise<PathLogResult>;
|
|
68
|
+
/** Resolve one commit by sha, bypassing readHistory's HEAD-reachability and
|
|
69
|
+
* --no-merges filters — a revert can name a merge or an unreachable, not-yet-GC'd
|
|
70
|
+
* commit that readHistory's index can't see. Returns null only if the object is truly gone; caller must disclose, never drop silently (rule 7). Paths aren't forward-canonicalised (disclosed gap). */
|
|
71
|
+
export declare function resolveCommitBySha(cwd: string, sha: string, maxFilesPerCommit?: number): Promise<Commit | null>;
|
|
72
|
+
/** Files changed between two refs, for PR analysis. `base...head` (three
|
|
73
|
+
* dots, not two) diffs against the merge base — two dots would include every
|
|
74
|
+
* file changed on base since the branch point, someone else's change. Deletions included: what called the removed thing is the useful question. */
|
|
75
|
+
export declare function changedFiles(cwd: string, base: string, head?: string): Promise<string[]>;
|
|
76
|
+
/** `git show --name-only` for one commit, with today's paths where known. */
|
|
77
|
+
export declare function filesInCommit(cwd: string, sha: string): Promise<string[]>;
|
|
90
78
|
/**
|
|
91
|
-
*
|
|
92
|
-
* reachability filter and its `--no-merges` exclusion.
|
|
79
|
+
* Which of these paths git reports as uncommitted — modified, staged or untracked.
|
|
93
80
|
*
|
|
94
|
-
* `
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* the
|
|
98
|
-
*
|
|
99
|
-
* `git revert`'s `This reverts commit <sha>` line can point at a commit that
|
|
100
|
-
* **is** a merge ("Revert Merge pull request #N"), or at a commit that is
|
|
101
|
-
* real and still in the object database but not an ancestor of `HEAD` — an
|
|
102
|
-
* abandoned branch, or one deleted after a squash/rebase merge whose objects
|
|
103
|
-
* have not yet been garbage-collected. Neither case means the commit does
|
|
104
|
-
* not exist; `readHistory`'s index just cannot see it.
|
|
81
|
+
* One `git status --porcelain` over the named paths rather than a call per
|
|
82
|
+
* file. `--porcelain` is the stable machine format, guaranteed across versions,
|
|
83
|
+
* and its two status columns cover every state that matters here at once: a
|
|
84
|
+
* file the index has and `HEAD` does not, one the working tree has and the
|
|
85
|
+
* index does not, and one git has never seen.
|
|
105
86
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* squash-merge case, where the original commit was never an ancestor of
|
|
112
|
-
* anything that survived and its object is gone from the store. That is the
|
|
113
|
-
* one case nothing can resolve; the caller must disclose it rather than
|
|
114
|
-
* drop it silently (CLAUDE.md rule 7 — every fallback is labelled).
|
|
115
|
-
*
|
|
116
|
-
* File paths returned here are **not** forward-canonicalised through
|
|
117
|
-
* `readHistory`'s rename map — this commit was never visited by that walk.
|
|
118
|
-
* A file renamed on mainline *after* this commit landed will show under its
|
|
119
|
-
* name at the time, not today's name. That is a narrower, disclosed version
|
|
120
|
-
* of the same rename gap the module doc already states for the primary walk.
|
|
87
|
+
* The distinction this exists to make is not cosmetic. A path absent from a
|
|
88
|
+
* ref-to-ref diff might be uncommitted work, or it might be a file the caller
|
|
89
|
+
* named that this branch simply did not touch. Both make a coverage section
|
|
90
|
+
* describe something else; only the first is a fact about timing that the
|
|
91
|
+
* developer can act on in the next thirty seconds.
|
|
121
92
|
*/
|
|
122
|
-
export declare function
|
|
93
|
+
export declare function uncommittedAmong(cwd: string, paths: readonly string[]): Promise<readonly string[]>;
|
|
94
|
+
export interface WorkingTreeFilesOptions {
|
|
95
|
+
/** Which tracked-file comparison to make. Default `"all"` — everything uncommitted. */
|
|
96
|
+
readonly scope?: "unstaged" | "staged" | "all";
|
|
97
|
+
/** Include files git has never seen. Default true — see below. */
|
|
98
|
+
readonly includeUntracked?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Directory prefixes whose contents are not the change under review — a
|
|
101
|
+
* tool's own state, where a `.gitignore` does not happen to cover it.
|
|
102
|
+
* Matched at a segment boundary, so `.descry` leaves `src/.descryfile.ts`.
|
|
103
|
+
*/
|
|
104
|
+
readonly exclude?: readonly string[];
|
|
105
|
+
}
|
|
123
106
|
/**
|
|
124
|
-
*
|
|
107
|
+
* The paths a working tree changes, as {@link changedFiles} does for a range.
|
|
125
108
|
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* since the branch point appears in the result as though the PR had touched it.
|
|
129
|
-
* On a branch a week behind `main` that is most of the diff, and the blast
|
|
130
|
-
* radius it produces belongs to somebody else's change. Three dots diffs against
|
|
131
|
-
* the merge base, which is what a reviewer is actually looking at.
|
|
109
|
+
* Name-only, so it is the cheap counterpart to `gitWorkingTreeChange`: a caller
|
|
110
|
+
* that only needs to know *which* files changed should not pay for every patch.
|
|
132
111
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
112
|
+
* **Untracked is on by default here**, unlike the diff-producing function. That
|
|
113
|
+
* one is a library primitive whose existing callers must not change behaviour
|
|
114
|
+
* by upgrading. This one exists to answer "what is the change about to be
|
|
115
|
+
* committed", and a new file written and not yet added is part of that change —
|
|
116
|
+
* defaulting it off would mean the function misses, by default, the case it was
|
|
117
|
+
* written for.
|
|
136
118
|
*/
|
|
137
|
-
export declare function
|
|
138
|
-
/** `git show --name-only` for one commit, with today's paths where known. */
|
|
139
|
-
export declare function filesInCommit(cwd: string, sha: string): Promise<string[]>;
|
|
119
|
+
export declare function workingTreeChangedFiles(cwd: string, options?: WorkingTreeFilesOptions): Promise<string[]>;
|
|
140
120
|
//# sourceMappingURL=history.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/sources/git/history.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/sources/git/history.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4BH,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAC7C,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,cAAc;IAC7B,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