gitx.do 0.0.1
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/README.md +156 -0
- package/dist/durable-object/object-store.d.ts +113 -0
- package/dist/durable-object/object-store.d.ts.map +1 -0
- package/dist/durable-object/object-store.js +387 -0
- package/dist/durable-object/object-store.js.map +1 -0
- package/dist/durable-object/schema.d.ts +17 -0
- package/dist/durable-object/schema.d.ts.map +1 -0
- package/dist/durable-object/schema.js +43 -0
- package/dist/durable-object/schema.js.map +1 -0
- package/dist/durable-object/wal.d.ts +111 -0
- package/dist/durable-object/wal.d.ts.map +1 -0
- package/dist/durable-object/wal.js +200 -0
- package/dist/durable-object/wal.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +101 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/adapter.d.ts +231 -0
- package/dist/mcp/adapter.d.ts.map +1 -0
- package/dist/mcp/adapter.js +502 -0
- package/dist/mcp/adapter.js.map +1 -0
- package/dist/mcp/sandbox.d.ts +261 -0
- package/dist/mcp/sandbox.d.ts.map +1 -0
- package/dist/mcp/sandbox.js +983 -0
- package/dist/mcp/sandbox.js.map +1 -0
- package/dist/mcp/sdk-adapter.d.ts +413 -0
- package/dist/mcp/sdk-adapter.d.ts.map +1 -0
- package/dist/mcp/sdk-adapter.js +672 -0
- package/dist/mcp/sdk-adapter.js.map +1 -0
- package/dist/mcp/tools.d.ts +133 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +1604 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/ops/blame.d.ts +148 -0
- package/dist/ops/blame.d.ts.map +1 -0
- package/dist/ops/blame.js +754 -0
- package/dist/ops/blame.js.map +1 -0
- package/dist/ops/branch.d.ts +215 -0
- package/dist/ops/branch.d.ts.map +1 -0
- package/dist/ops/branch.js +608 -0
- package/dist/ops/branch.js.map +1 -0
- package/dist/ops/commit-traversal.d.ts +209 -0
- package/dist/ops/commit-traversal.d.ts.map +1 -0
- package/dist/ops/commit-traversal.js +755 -0
- package/dist/ops/commit-traversal.js.map +1 -0
- package/dist/ops/commit.d.ts +221 -0
- package/dist/ops/commit.d.ts.map +1 -0
- package/dist/ops/commit.js +606 -0
- package/dist/ops/commit.js.map +1 -0
- package/dist/ops/merge-base.d.ts +223 -0
- package/dist/ops/merge-base.d.ts.map +1 -0
- package/dist/ops/merge-base.js +581 -0
- package/dist/ops/merge-base.js.map +1 -0
- package/dist/ops/merge.d.ts +385 -0
- package/dist/ops/merge.d.ts.map +1 -0
- package/dist/ops/merge.js +1203 -0
- package/dist/ops/merge.js.map +1 -0
- package/dist/ops/tag.d.ts +182 -0
- package/dist/ops/tag.d.ts.map +1 -0
- package/dist/ops/tag.js +608 -0
- package/dist/ops/tag.js.map +1 -0
- package/dist/ops/tree-builder.d.ts +82 -0
- package/dist/ops/tree-builder.d.ts.map +1 -0
- package/dist/ops/tree-builder.js +246 -0
- package/dist/ops/tree-builder.js.map +1 -0
- package/dist/ops/tree-diff.d.ts +243 -0
- package/dist/ops/tree-diff.d.ts.map +1 -0
- package/dist/ops/tree-diff.js +657 -0
- package/dist/ops/tree-diff.js.map +1 -0
- package/dist/pack/delta.d.ts +68 -0
- package/dist/pack/delta.d.ts.map +1 -0
- package/dist/pack/delta.js +343 -0
- package/dist/pack/delta.js.map +1 -0
- package/dist/pack/format.d.ts +84 -0
- package/dist/pack/format.d.ts.map +1 -0
- package/dist/pack/format.js +261 -0
- package/dist/pack/format.js.map +1 -0
- package/dist/pack/full-generation.d.ts +327 -0
- package/dist/pack/full-generation.d.ts.map +1 -0
- package/dist/pack/full-generation.js +1159 -0
- package/dist/pack/full-generation.js.map +1 -0
- package/dist/pack/generation.d.ts +118 -0
- package/dist/pack/generation.d.ts.map +1 -0
- package/dist/pack/generation.js +459 -0
- package/dist/pack/generation.js.map +1 -0
- package/dist/pack/index.d.ts +181 -0
- package/dist/pack/index.d.ts.map +1 -0
- package/dist/pack/index.js +552 -0
- package/dist/pack/index.js.map +1 -0
- package/dist/refs/branch.d.ts +224 -0
- package/dist/refs/branch.d.ts.map +1 -0
- package/dist/refs/branch.js +170 -0
- package/dist/refs/branch.js.map +1 -0
- package/dist/refs/storage.d.ts +208 -0
- package/dist/refs/storage.d.ts.map +1 -0
- package/dist/refs/storage.js +421 -0
- package/dist/refs/storage.js.map +1 -0
- package/dist/refs/tag.d.ts +230 -0
- package/dist/refs/tag.d.ts.map +1 -0
- package/dist/refs/tag.js +188 -0
- package/dist/refs/tag.js.map +1 -0
- package/dist/storage/lru-cache.d.ts +188 -0
- package/dist/storage/lru-cache.d.ts.map +1 -0
- package/dist/storage/lru-cache.js +410 -0
- package/dist/storage/lru-cache.js.map +1 -0
- package/dist/storage/object-index.d.ts +140 -0
- package/dist/storage/object-index.d.ts.map +1 -0
- package/dist/storage/object-index.js +166 -0
- package/dist/storage/object-index.js.map +1 -0
- package/dist/storage/r2-pack.d.ts +394 -0
- package/dist/storage/r2-pack.d.ts.map +1 -0
- package/dist/storage/r2-pack.js +1062 -0
- package/dist/storage/r2-pack.js.map +1 -0
- package/dist/tiered/cdc-pipeline.d.ts +316 -0
- package/dist/tiered/cdc-pipeline.d.ts.map +1 -0
- package/dist/tiered/cdc-pipeline.js +771 -0
- package/dist/tiered/cdc-pipeline.js.map +1 -0
- package/dist/tiered/migration.d.ts +242 -0
- package/dist/tiered/migration.d.ts.map +1 -0
- package/dist/tiered/migration.js +592 -0
- package/dist/tiered/migration.js.map +1 -0
- package/dist/tiered/parquet-writer.d.ts +248 -0
- package/dist/tiered/parquet-writer.d.ts.map +1 -0
- package/dist/tiered/parquet-writer.js +555 -0
- package/dist/tiered/parquet-writer.js.map +1 -0
- package/dist/tiered/read-path.d.ts +141 -0
- package/dist/tiered/read-path.d.ts.map +1 -0
- package/dist/tiered/read-path.js +204 -0
- package/dist/tiered/read-path.js.map +1 -0
- package/dist/types/objects.d.ts +53 -0
- package/dist/types/objects.d.ts.map +1 -0
- package/dist/types/objects.js +291 -0
- package/dist/types/objects.js.map +1 -0
- package/dist/types/storage.d.ts +117 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +8 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/utils/hash.d.ts +31 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +60 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/sha1.d.ts +26 -0
- package/dist/utils/sha1.d.ts.map +1 -0
- package/dist/utils/sha1.js +127 -0
- package/dist/utils/sha1.js.map +1 -0
- package/dist/wire/capabilities.d.ts +236 -0
- package/dist/wire/capabilities.d.ts.map +1 -0
- package/dist/wire/capabilities.js +437 -0
- package/dist/wire/capabilities.js.map +1 -0
- package/dist/wire/pkt-line.d.ts +67 -0
- package/dist/wire/pkt-line.d.ts.map +1 -0
- package/dist/wire/pkt-line.js +145 -0
- package/dist/wire/pkt-line.js.map +1 -0
- package/dist/wire/receive-pack.d.ts +302 -0
- package/dist/wire/receive-pack.d.ts.map +1 -0
- package/dist/wire/receive-pack.js +885 -0
- package/dist/wire/receive-pack.js.map +1 -0
- package/dist/wire/smart-http.d.ts +321 -0
- package/dist/wire/smart-http.d.ts.map +1 -0
- package/dist/wire/smart-http.js +654 -0
- package/dist/wire/smart-http.js.map +1 -0
- package/dist/wire/upload-pack.d.ts +333 -0
- package/dist/wire/upload-pack.d.ts.map +1 -0
- package/dist/wire/upload-pack.js +850 -0
- package/dist/wire/upload-pack.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synchronous SHA-1 utilities for git pack operations
|
|
3
|
+
*
|
|
4
|
+
* These functions provide synchronous SHA-1 hashing needed for pack file
|
|
5
|
+
* generation and verification. For async operations, use hash.ts instead.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Compute SHA-1 hash of data synchronously
|
|
9
|
+
* @param data - Input data to hash
|
|
10
|
+
* @returns 20-byte hash as Uint8Array
|
|
11
|
+
*/
|
|
12
|
+
export function sha1(data) {
|
|
13
|
+
function rotl(n, s) {
|
|
14
|
+
return ((n << s) | (n >>> (32 - s))) >>> 0;
|
|
15
|
+
}
|
|
16
|
+
// Initialize hash values
|
|
17
|
+
let h0 = 0x67452301;
|
|
18
|
+
let h1 = 0xefcdab89;
|
|
19
|
+
let h2 = 0x98badcfe;
|
|
20
|
+
let h3 = 0x10325476;
|
|
21
|
+
let h4 = 0xc3d2e1f0;
|
|
22
|
+
// Pre-processing: add padding
|
|
23
|
+
const msgLen = data.length;
|
|
24
|
+
const bitLen = BigInt(msgLen) * 8n;
|
|
25
|
+
// Message needs to be padded to 64-byte boundary (512 bits)
|
|
26
|
+
// Padding: 1 bit (0x80), then zeros, then 64-bit length
|
|
27
|
+
const paddingLength = (64 - ((msgLen + 9) % 64)) % 64;
|
|
28
|
+
const paddedLen = msgLen + 1 + paddingLength + 8;
|
|
29
|
+
const padded = new Uint8Array(paddedLen);
|
|
30
|
+
padded.set(data, 0);
|
|
31
|
+
padded[msgLen] = 0x80;
|
|
32
|
+
// Write length as 64-bit big-endian at the end
|
|
33
|
+
const lengthView = new DataView(padded.buffer);
|
|
34
|
+
lengthView.setBigUint64(paddedLen - 8, bitLen, false);
|
|
35
|
+
// Process in 64-byte (512-bit) chunks
|
|
36
|
+
const w = new Uint32Array(80);
|
|
37
|
+
for (let chunkStart = 0; chunkStart < paddedLen; chunkStart += 64) {
|
|
38
|
+
const chunkView = new DataView(padded.buffer, chunkStart, 64);
|
|
39
|
+
// Break chunk into sixteen 32-bit big-endian words
|
|
40
|
+
for (let i = 0; i < 16; i++) {
|
|
41
|
+
w[i] = chunkView.getUint32(i * 4, false);
|
|
42
|
+
}
|
|
43
|
+
// Extend the sixteen 32-bit words into eighty 32-bit words
|
|
44
|
+
for (let i = 16; i < 80; i++) {
|
|
45
|
+
w[i] = rotl(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
|
|
46
|
+
}
|
|
47
|
+
// Initialize working variables
|
|
48
|
+
let a = h0;
|
|
49
|
+
let b = h1;
|
|
50
|
+
let c = h2;
|
|
51
|
+
let d = h3;
|
|
52
|
+
let e = h4;
|
|
53
|
+
// Main loop
|
|
54
|
+
for (let i = 0; i < 80; i++) {
|
|
55
|
+
let f, k;
|
|
56
|
+
if (i < 20) {
|
|
57
|
+
f = (b & c) | (~b & d);
|
|
58
|
+
k = 0x5a827999;
|
|
59
|
+
}
|
|
60
|
+
else if (i < 40) {
|
|
61
|
+
f = b ^ c ^ d;
|
|
62
|
+
k = 0x6ed9eba1;
|
|
63
|
+
}
|
|
64
|
+
else if (i < 60) {
|
|
65
|
+
f = (b & c) | (b & d) | (c & d);
|
|
66
|
+
k = 0x8f1bbcdc;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
f = b ^ c ^ d;
|
|
70
|
+
k = 0xca62c1d6;
|
|
71
|
+
}
|
|
72
|
+
const temp = (rotl(a, 5) + f + e + k + w[i]) >>> 0;
|
|
73
|
+
e = d;
|
|
74
|
+
d = c;
|
|
75
|
+
c = rotl(b, 30);
|
|
76
|
+
b = a;
|
|
77
|
+
a = temp;
|
|
78
|
+
}
|
|
79
|
+
// Add this chunk's hash to result so far
|
|
80
|
+
h0 = (h0 + a) >>> 0;
|
|
81
|
+
h1 = (h1 + b) >>> 0;
|
|
82
|
+
h2 = (h2 + c) >>> 0;
|
|
83
|
+
h3 = (h3 + d) >>> 0;
|
|
84
|
+
h4 = (h4 + e) >>> 0;
|
|
85
|
+
}
|
|
86
|
+
// Produce the final hash value (big-endian)
|
|
87
|
+
const result = new Uint8Array(20);
|
|
88
|
+
const resultView = new DataView(result.buffer);
|
|
89
|
+
resultView.setUint32(0, h0, false);
|
|
90
|
+
resultView.setUint32(4, h1, false);
|
|
91
|
+
resultView.setUint32(8, h2, false);
|
|
92
|
+
resultView.setUint32(12, h3, false);
|
|
93
|
+
resultView.setUint32(16, h4, false);
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Compute SHA-1 hash and return as hex string
|
|
98
|
+
* @param data - Input data to hash
|
|
99
|
+
* @returns 40-character lowercase hex string
|
|
100
|
+
*/
|
|
101
|
+
export function sha1Hex(data) {
|
|
102
|
+
const hash = sha1(data);
|
|
103
|
+
let hex = '';
|
|
104
|
+
for (let i = 0; i < hash.length; i++) {
|
|
105
|
+
hex += hash[i].toString(16).padStart(2, '0');
|
|
106
|
+
}
|
|
107
|
+
return hex;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Verify data against expected SHA-1 hash
|
|
111
|
+
* @param data - Data to verify
|
|
112
|
+
* @param expected - Expected 20-byte hash
|
|
113
|
+
* @returns true if hash matches
|
|
114
|
+
*/
|
|
115
|
+
export function sha1Verify(data, expected) {
|
|
116
|
+
if (expected.length !== 20) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const computed = sha1(data);
|
|
120
|
+
for (let i = 0; i < 20; i++) {
|
|
121
|
+
if (computed[i] !== expected[i]) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=sha1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha1.js","sourceRoot":"","sources":["../../src/utils/sha1.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,IAAgB;IACnC,SAAS,IAAI,CAAC,CAAS,EAAE,CAAS;QAChC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;IAED,yBAAyB;IACzB,IAAI,EAAE,GAAG,UAAU,CAAA;IACn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EAAE,EAAE,KAAK,CAAC,CAAA;IAClC,UAAU,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAA;IACnC,UAAU,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAA;IAEnC,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,IAAgB;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC9C,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,QAAoB;IAC/D,IAAI,QAAQ,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;IAE3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YAChC,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git wire protocol capability negotiation
|
|
3
|
+
*
|
|
4
|
+
* Capabilities are used during the initial handshake between git client and server
|
|
5
|
+
* to determine what features are supported by both sides.
|
|
6
|
+
*
|
|
7
|
+
* Protocol v1: Capabilities are sent as a space-separated list after the first ref
|
|
8
|
+
* Protocol v2: Capabilities are advertised line by line in the initial handshake
|
|
9
|
+
*
|
|
10
|
+
* Reference: https://git-scm.com/docs/protocol-capabilities
|
|
11
|
+
* Reference: https://git-scm.com/docs/protocol-v2
|
|
12
|
+
*/
|
|
13
|
+
/** Git wire protocol version */
|
|
14
|
+
export type ProtocolVersion = 1 | 2;
|
|
15
|
+
/** Standard protocol v1 capabilities */
|
|
16
|
+
export type CapabilityV1 = 'multi_ack' | 'multi_ack_detailed' | 'thin-pack' | 'side-band' | 'side-band-64k' | 'ofs-delta' | 'shallow' | 'deepen-since' | 'deepen-not' | 'deepen-relative' | 'no-progress' | 'include-tag' | 'report-status' | 'report-status-v2' | 'delete-refs' | 'quiet' | 'atomic' | 'push-options' | 'allow-tip-sha1-in-want' | 'allow-reachable-sha1-in-want' | 'push-cert' | 'filter' | 'agent' | 'symref' | 'object-format';
|
|
17
|
+
/** Protocol v2 capabilities/commands */
|
|
18
|
+
export type CapabilityV2 = 'agent' | 'ls-refs' | 'fetch' | 'server-option' | 'object-format' | 'session-id' | 'wait-for-done' | 'object-info' | 'bundle-uri';
|
|
19
|
+
/** Capability with optional value (e.g., agent=git/2.30.0) */
|
|
20
|
+
export interface CapabilityEntry {
|
|
21
|
+
name: string;
|
|
22
|
+
value?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Parsed capability set */
|
|
25
|
+
export interface CapabilitySet {
|
|
26
|
+
/** Protocol version being used */
|
|
27
|
+
version: ProtocolVersion;
|
|
28
|
+
/** Map of capability name to optional value */
|
|
29
|
+
capabilities: Map<string, string | undefined>;
|
|
30
|
+
}
|
|
31
|
+
/** Ref advertisement with capabilities (protocol v1) */
|
|
32
|
+
export interface RefAdvertisement {
|
|
33
|
+
/** The SHA-1 of the ref */
|
|
34
|
+
oid: string;
|
|
35
|
+
/** The ref name (e.g., refs/heads/main) */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Capabilities (only on first ref line) */
|
|
38
|
+
capabilities?: CapabilitySet;
|
|
39
|
+
}
|
|
40
|
+
/** Protocol v2 server capabilities response */
|
|
41
|
+
export interface ServerCapabilitiesV2 {
|
|
42
|
+
version: 2;
|
|
43
|
+
/** List of supported commands */
|
|
44
|
+
commands: string[];
|
|
45
|
+
/** Agent string */
|
|
46
|
+
agent?: string;
|
|
47
|
+
/** Object format (sha1 or sha256) */
|
|
48
|
+
objectFormat?: 'sha1' | 'sha256';
|
|
49
|
+
/** Other capabilities */
|
|
50
|
+
capabilities: Map<string, string | undefined>;
|
|
51
|
+
}
|
|
52
|
+
/** Want line with capabilities for fetch request */
|
|
53
|
+
export interface WantRequest {
|
|
54
|
+
/** SHA-1s of objects we want */
|
|
55
|
+
wants: string[];
|
|
56
|
+
/** Capabilities to send */
|
|
57
|
+
capabilities: CapabilityEntry[];
|
|
58
|
+
}
|
|
59
|
+
/** Have line for negotiation */
|
|
60
|
+
export interface HaveRequest {
|
|
61
|
+
/** SHA-1s of objects we have */
|
|
62
|
+
haves: string[];
|
|
63
|
+
/** Whether this is the final batch */
|
|
64
|
+
done?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** Version negotiation result */
|
|
67
|
+
export interface VersionNegotiationResult {
|
|
68
|
+
/** Agreed upon version */
|
|
69
|
+
version: ProtocolVersion;
|
|
70
|
+
/** Whether the server supports v2 */
|
|
71
|
+
serverSupportsV2: boolean;
|
|
72
|
+
/** Common capabilities */
|
|
73
|
+
commonCapabilities: string[];
|
|
74
|
+
}
|
|
75
|
+
/** Default client capabilities for fetch (protocol v1) */
|
|
76
|
+
export declare const DEFAULT_FETCH_CAPABILITIES_V1: CapabilityV1[];
|
|
77
|
+
/** Default client capabilities for push (protocol v1) */
|
|
78
|
+
export declare const DEFAULT_PUSH_CAPABILITIES_V1: CapabilityV1[];
|
|
79
|
+
/** Minimum required capabilities for basic fetch */
|
|
80
|
+
export declare const REQUIRED_FETCH_CAPABILITIES: CapabilityV1[];
|
|
81
|
+
/**
|
|
82
|
+
* Parse a capability string from ref advertisement (protocol v1).
|
|
83
|
+
*
|
|
84
|
+
* Format: "<oid> <refname>\0<cap1> <cap2> cap3=value..."
|
|
85
|
+
*
|
|
86
|
+
* @param line - The ref advertisement line with capabilities
|
|
87
|
+
* @returns Parsed capabilities
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseCapabilityString(line: string): CapabilitySet;
|
|
90
|
+
/**
|
|
91
|
+
* Parse individual capability entries from a space-separated string.
|
|
92
|
+
*
|
|
93
|
+
* @param capString - Space-separated capability string
|
|
94
|
+
* @returns Array of capability entries
|
|
95
|
+
*/
|
|
96
|
+
export declare function parseCapabilities(capString: string): CapabilityEntry[];
|
|
97
|
+
/**
|
|
98
|
+
* Parse a ref advertisement line (protocol v1).
|
|
99
|
+
*
|
|
100
|
+
* First line format: "<oid> <refname>\0<capabilities>"
|
|
101
|
+
* Subsequent lines: "<oid> <refname>"
|
|
102
|
+
*
|
|
103
|
+
* @param line - The pkt-line data (without length prefix)
|
|
104
|
+
* @param isFirst - Whether this is the first line (contains capabilities)
|
|
105
|
+
* @returns Parsed ref advertisement
|
|
106
|
+
*/
|
|
107
|
+
export declare function parseRefAdvertisement(line: string, isFirst: boolean): RefAdvertisement;
|
|
108
|
+
/**
|
|
109
|
+
* Parse protocol v2 capability advertisement.
|
|
110
|
+
*
|
|
111
|
+
* Format:
|
|
112
|
+
* version 2
|
|
113
|
+
* agent=git/2.30.0
|
|
114
|
+
* ls-refs
|
|
115
|
+
* fetch=...
|
|
116
|
+
* server-option
|
|
117
|
+
* object-format=sha1
|
|
118
|
+
*
|
|
119
|
+
* @param lines - Array of pkt-line data
|
|
120
|
+
* @returns Parsed server capabilities
|
|
121
|
+
*/
|
|
122
|
+
export declare function parseServerCapabilitiesV2(lines: string[]): ServerCapabilitiesV2;
|
|
123
|
+
/**
|
|
124
|
+
* Build a capability string for want/have request (protocol v1).
|
|
125
|
+
*
|
|
126
|
+
* @param capabilities - Capabilities to include
|
|
127
|
+
* @returns Space-separated capability string
|
|
128
|
+
*/
|
|
129
|
+
export declare function buildCapabilityString(capabilities: CapabilityEntry[]): string;
|
|
130
|
+
/**
|
|
131
|
+
* Build a want line with capabilities (first want only).
|
|
132
|
+
*
|
|
133
|
+
* Format: "want <oid> <capabilities>\n"
|
|
134
|
+
*
|
|
135
|
+
* @param oid - The object ID to want
|
|
136
|
+
* @param capabilities - Capabilities to include
|
|
137
|
+
* @returns Formatted want line
|
|
138
|
+
*/
|
|
139
|
+
export declare function buildWantLine(oid: string, capabilities?: CapabilityEntry[]): string;
|
|
140
|
+
/**
|
|
141
|
+
* Build a have line for negotiation.
|
|
142
|
+
*
|
|
143
|
+
* Format: "have <oid>\n"
|
|
144
|
+
*
|
|
145
|
+
* @param oid - The object ID we have
|
|
146
|
+
* @returns Formatted have line
|
|
147
|
+
*/
|
|
148
|
+
export declare function buildHaveLine(oid: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Build a complete want/have request.
|
|
151
|
+
*
|
|
152
|
+
* @param request - The want request with capabilities
|
|
153
|
+
* @returns Array of pkt-line format strings
|
|
154
|
+
*/
|
|
155
|
+
export declare function buildFetchRequest(request: WantRequest): string[];
|
|
156
|
+
/**
|
|
157
|
+
* Build protocol v2 command request.
|
|
158
|
+
*
|
|
159
|
+
* Format:
|
|
160
|
+
* command=<cmd>
|
|
161
|
+
* capability1
|
|
162
|
+
* capability2=value
|
|
163
|
+
* 0001 (delimiter)
|
|
164
|
+
* <command-specific args>
|
|
165
|
+
* 0000 (flush)
|
|
166
|
+
*
|
|
167
|
+
* @param command - The v2 command (e.g., 'fetch', 'ls-refs')
|
|
168
|
+
* @param capabilities - Client capabilities
|
|
169
|
+
* @param args - Command-specific arguments
|
|
170
|
+
* @returns Array of pkt-line format strings
|
|
171
|
+
*/
|
|
172
|
+
export declare function buildV2CommandRequest(command: string, capabilities: CapabilityEntry[], args?: string[]): string[];
|
|
173
|
+
/**
|
|
174
|
+
* Negotiate protocol version with server.
|
|
175
|
+
*
|
|
176
|
+
* @param serverAdvertisement - First line from server
|
|
177
|
+
* @param preferredVersion - Client's preferred version
|
|
178
|
+
* @returns Negotiation result
|
|
179
|
+
*/
|
|
180
|
+
export declare function negotiateVersion(serverAdvertisement: string, preferredVersion?: ProtocolVersion): VersionNegotiationResult;
|
|
181
|
+
/**
|
|
182
|
+
* Find common capabilities between client and server.
|
|
183
|
+
*
|
|
184
|
+
* @param clientCaps - Client capabilities
|
|
185
|
+
* @param serverCaps - Server capabilities
|
|
186
|
+
* @returns Array of common capability names
|
|
187
|
+
*/
|
|
188
|
+
export declare function findCommonCapabilities(clientCaps: CapabilityEntry[], serverCaps: CapabilitySet): string[];
|
|
189
|
+
/**
|
|
190
|
+
* Check if a specific capability is supported.
|
|
191
|
+
*
|
|
192
|
+
* @param capSet - The capability set to check
|
|
193
|
+
* @param name - The capability name
|
|
194
|
+
* @returns True if capability is supported
|
|
195
|
+
*/
|
|
196
|
+
export declare function hasCapability(capSet: CapabilitySet, name: string): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Get the value of a capability (if it has one).
|
|
199
|
+
*
|
|
200
|
+
* @param capSet - The capability set
|
|
201
|
+
* @param name - The capability name
|
|
202
|
+
* @returns The capability value or undefined
|
|
203
|
+
*/
|
|
204
|
+
export declare function getCapabilityValue(capSet: CapabilitySet, name: string): string | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Create a capability set from entries.
|
|
207
|
+
*
|
|
208
|
+
* @param version - Protocol version
|
|
209
|
+
* @param entries - Capability entries
|
|
210
|
+
* @returns CapabilitySet
|
|
211
|
+
*/
|
|
212
|
+
export declare function createCapabilitySet(version: ProtocolVersion, entries: CapabilityEntry[]): CapabilitySet;
|
|
213
|
+
/**
|
|
214
|
+
* Select optimal capabilities for a fetch operation.
|
|
215
|
+
*
|
|
216
|
+
* @param serverCaps - Server advertised capabilities
|
|
217
|
+
* @param clientPrefs - Client preferred capabilities (in priority order)
|
|
218
|
+
* @returns Selected capabilities to use
|
|
219
|
+
*/
|
|
220
|
+
export declare function selectFetchCapabilities(serverCaps: CapabilitySet, clientPrefs: CapabilityEntry[]): CapabilityEntry[];
|
|
221
|
+
/**
|
|
222
|
+
* Validate that a capability name is well-formed.
|
|
223
|
+
*
|
|
224
|
+
* @param name - The capability name to validate
|
|
225
|
+
* @returns True if valid
|
|
226
|
+
*/
|
|
227
|
+
export declare function isValidCapabilityName(name: string): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Validate that required capabilities are present.
|
|
230
|
+
*
|
|
231
|
+
* @param capSet - The capability set to check
|
|
232
|
+
* @param required - Required capability names
|
|
233
|
+
* @returns Array of missing capability names
|
|
234
|
+
*/
|
|
235
|
+
export declare function validateRequiredCapabilities(capSet: CapabilitySet, required: string[]): string[];
|
|
236
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/wire/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,CAAC,CAAA;AAEnC,wCAAwC;AACxC,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,oBAAoB,GACpB,WAAW,GACX,WAAW,GACX,eAAe,GACf,WAAW,GACX,SAAS,GACT,cAAc,GACd,YAAY,GACZ,iBAAiB,GACjB,aAAa,GACb,aAAa,GACb,eAAe,GACf,kBAAkB,GAClB,aAAa,GACb,OAAO,GACP,QAAQ,GACR,cAAc,GACd,wBAAwB,GACxB,8BAA8B,GAC9B,WAAW,GACX,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,eAAe,CAAA;AAEnB,wCAAwC;AACxC,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,SAAS,GACT,OAAO,GACP,eAAe,GACf,eAAe,GACf,YAAY,GACZ,eAAe,GACf,aAAa,GACb,YAAY,CAA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