@intra-mart/accel 0.5.0-dev.202608040843 → 0.5.0-dev.202608250608

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.
Files changed (114) hide show
  1. package/README.md +33 -31
  2. package/dist/asset/deployer.d.ts +2 -0
  3. package/dist/asset/deployer.js +11 -9
  4. package/dist/asset/git-provider.d.ts +1 -0
  5. package/dist/asset/git-provider.js +20 -9
  6. package/dist/asset/updater.d.ts +9 -2
  7. package/dist/asset/updater.js +12 -6
  8. package/dist/asset/walker.d.ts +2 -1
  9. package/dist/asset/walker.js +36 -0
  10. package/dist/commands/asset-provider.d.ts +1 -1
  11. package/dist/commands/asset-provider.js +2 -2
  12. package/dist/commands/attach.d.ts +116 -82
  13. package/dist/commands/attach.js +176 -145
  14. package/dist/commands/cache.js +11 -19
  15. package/dist/commands/deploy.d.ts +53 -32
  16. package/dist/commands/deploy.js +112 -75
  17. package/dist/commands/detach.d.ts +18 -0
  18. package/dist/commands/detach.js +69 -54
  19. package/dist/commands/init.d.ts +117 -83
  20. package/dist/commands/init.js +119 -98
  21. package/dist/commands/login.d.ts +12 -10
  22. package/dist/commands/login.js +14 -10
  23. package/dist/commands/preset.js +26 -33
  24. package/dist/commands/run-wrapper.d.ts +15 -0
  25. package/dist/commands/run-wrapper.js +62 -0
  26. package/dist/commands/switch.d.ts +48 -20
  27. package/dist/commands/switch.js +201 -176
  28. package/dist/commands/update.d.ts +142 -87
  29. package/dist/commands/update.js +342 -296
  30. package/dist/core/color-env.d.ts +1 -0
  31. package/dist/core/color-env.js +6 -0
  32. package/dist/core/constants.d.ts +0 -1
  33. package/dist/core/constants.js +0 -3
  34. package/dist/core/errors.d.ts +6 -0
  35. package/dist/core/errors.js +16 -0
  36. package/dist/core/logger.d.ts +15 -0
  37. package/dist/core/logger.js +1 -0
  38. package/dist/core/paths.d.ts +6 -0
  39. package/dist/core/paths.js +22 -0
  40. package/dist/core/types.d.ts +6 -1
  41. package/dist/core/validation.d.ts +34 -0
  42. package/dist/core/validation.js +87 -0
  43. package/dist/deploy/api-client.d.ts +1 -0
  44. package/dist/deploy/api-client.js +7 -1
  45. package/dist/git/config-file.d.ts +3 -0
  46. package/dist/git/config-file.js +178 -0
  47. package/dist/git/errors.d.ts +5 -0
  48. package/dist/git/errors.js +21 -2
  49. package/dist/git/git-objects.d.ts +11 -0
  50. package/dist/git/git-objects.js +49 -0
  51. package/dist/git/http.d.ts +2 -2
  52. package/dist/git/http.js +22 -10
  53. package/dist/git/index-file.d.ts +17 -0
  54. package/dist/git/index-file.js +111 -0
  55. package/dist/git/object-cache.d.ts +1 -0
  56. package/dist/git/object-cache.js +11 -15
  57. package/dist/git/object-store.d.ts +4 -0
  58. package/dist/git/object-store.js +82 -107
  59. package/dist/git/pack-parse.d.ts +19 -0
  60. package/dist/git/pack-parse.js +261 -0
  61. package/dist/git/pack-store.d.ts +20 -0
  62. package/dist/git/pack-store.js +144 -0
  63. package/dist/git/read-capped.d.ts +1 -0
  64. package/dist/git/read-capped.js +26 -0
  65. package/dist/git/redact-url.d.ts +1 -0
  66. package/dist/git/redact-url.js +14 -0
  67. package/dist/git/repo-layout.d.ts +5 -0
  68. package/dist/git/repo-layout.js +44 -0
  69. package/dist/git/smart-http.d.ts +3 -2
  70. package/dist/git/smart-http.js +5 -5
  71. package/dist/git/untracked.d.ts +11 -0
  72. package/dist/git/untracked.js +93 -0
  73. package/dist/git/worktree-status.d.ts +4 -0
  74. package/dist/git/worktree-status.js +140 -0
  75. package/dist/git/zlib-inflate.d.ts +7 -0
  76. package/dist/git/zlib-inflate.js +78 -0
  77. package/dist/i18n/en.js +12 -0
  78. package/dist/i18n/index.js +1 -1
  79. package/dist/i18n/ja.js +12 -0
  80. package/dist/i18n/zh_CN.js +12 -0
  81. package/dist/index.d.ts +1 -1
  82. package/dist/index.js +3 -2
  83. package/dist/interactive/asset-messages.d.ts +2 -1
  84. package/dist/interactive/asset-messages.js +4 -4
  85. package/dist/interactive/clack-logger.d.ts +2 -0
  86. package/dist/interactive/clack-logger.js +11 -0
  87. package/dist/interactive/credential-auth.d.ts +2 -0
  88. package/dist/interactive/credential-auth.js +7 -6
  89. package/dist/interactive/credentials-prompts.js +10 -6
  90. package/dist/interactive/next-steps.d.ts +2 -1
  91. package/dist/interactive/next-steps.js +3 -3
  92. package/dist/interactive/progress.d.ts +8 -1
  93. package/dist/interactive/progress.js +0 -0
  94. package/dist/interactive/prompts.d.ts +3 -33
  95. package/dist/interactive/prompts.js +23 -111
  96. package/dist/interactive/summary.d.ts +2 -1
  97. package/dist/interactive/summary.js +3 -3
  98. package/dist/juggling/resolve.d.ts +7 -0
  99. package/dist/juggling/resolve.js +18 -0
  100. package/dist/lib.d.ts +34 -0
  101. package/dist/lib.js +29 -0
  102. package/dist/utils/args.d.ts +4 -1
  103. package/dist/utils/args.js +26 -3
  104. package/dist/utils/githooks-sync.d.ts +3 -1
  105. package/dist/utils/githooks-sync.js +37 -37
  106. package/dist/utils/mcp-generate.d.ts +26 -0
  107. package/dist/utils/mcp-generate.js +313 -0
  108. package/dist/utils/preset-io.d.ts +1 -0
  109. package/dist/utils/preset-io.js +5 -2
  110. package/dist/utils/settings-io.d.ts +1 -0
  111. package/dist/utils/settings-io.js +1 -1
  112. package/package.json +21 -14
  113. package/dist/utils/mcp-sync.d.ts +0 -4
  114. package/dist/utils/mcp-sync.js +0 -103
@@ -0,0 +1,261 @@
1
+ import { createHash } from "node:crypto";
2
+ import { createGitPackCorruptError } from "./errors.js";
3
+ import { hashObject } from "./git-objects.js";
4
+ import { inflateSlice } from "./zlib-inflate.js";
5
+ export const OBJ_COMMIT = 1;
6
+ export const OBJ_TREE = 2;
7
+ export const OBJ_BLOB = 3;
8
+ export const OBJ_TAG = 4;
9
+ const OBJ_OFS_DELTA = 6;
10
+ const OBJ_REF_DELTA = 7;
11
+ const TYPE_NAMES = {
12
+ [OBJ_COMMIT]: "commit",
13
+ [OBJ_TREE]: "tree",
14
+ [OBJ_BLOB]: "blob",
15
+ [OBJ_TAG]: "tag",
16
+ };
17
+ const HEADER_SIZE = 12;
18
+ const TRAILER_SIZE = 20;
19
+ const MAX_OBJECT_BYTES = 256 * 1024 * 1024;
20
+ const MAX_TOTAL_EXPANDED_BYTES = 1024 * 1024 * 1024;
21
+ const MAX_OBJECT_COUNT = 2_000_000;
22
+ export const oidOfObject = (type, data) => {
23
+ const typeName = TYPE_NAMES[type];
24
+ if (typeName === undefined) {
25
+ throw createGitPackCorruptError(`unknown object type ${type}`);
26
+ }
27
+ return hashObject(typeName, data);
28
+ };
29
+ export const applyDelta = (base, delta) => {
30
+ let pos = 0;
31
+ const nextByte = () => {
32
+ if (pos >= delta.length) {
33
+ throw createGitPackCorruptError("truncated delta");
34
+ }
35
+ return delta[pos++];
36
+ };
37
+ const readSizeVarint = () => {
38
+ let result = 0;
39
+ let shift = 0;
40
+ let byte;
41
+ do {
42
+ byte = nextByte();
43
+ result += (byte & 0x7f) * 2 ** shift;
44
+ shift += 7;
45
+ } while (byte & 0x80);
46
+ return result;
47
+ };
48
+ const baseSize = readSizeVarint();
49
+ if (baseSize !== base.length) {
50
+ throw createGitPackCorruptError("delta base size mismatch");
51
+ }
52
+ const resultSize = readSizeVarint();
53
+ if (resultSize > MAX_OBJECT_BYTES) {
54
+ throw createGitPackCorruptError("delta result size exceeds limit");
55
+ }
56
+ const out = Buffer.allocUnsafe(resultSize);
57
+ let outPos = 0;
58
+ while (pos < delta.length) {
59
+ const op = nextByte();
60
+ if (op & 0x80) {
61
+ let cpOff = 0;
62
+ let cpSize = 0;
63
+ if (op & 0x01)
64
+ cpOff = nextByte();
65
+ if (op & 0x02)
66
+ cpOff |= nextByte() << 8;
67
+ if (op & 0x04)
68
+ cpOff |= nextByte() << 16;
69
+ if (op & 0x08)
70
+ cpOff += nextByte() * 0x1000000;
71
+ if (op & 0x10)
72
+ cpSize = nextByte();
73
+ if (op & 0x20)
74
+ cpSize |= nextByte() << 8;
75
+ if (op & 0x40)
76
+ cpSize |= nextByte() << 16;
77
+ if (cpSize === 0)
78
+ cpSize = 0x10000;
79
+ if (cpOff + cpSize > base.length || outPos + cpSize > resultSize) {
80
+ throw createGitPackCorruptError("delta copy out of range");
81
+ }
82
+ base.copy(out, outPos, cpOff, cpOff + cpSize);
83
+ outPos += cpSize;
84
+ }
85
+ else if (op !== 0) {
86
+ if (pos + op > delta.length || outPos + op > resultSize) {
87
+ throw createGitPackCorruptError("delta insert out of range");
88
+ }
89
+ delta.copy(out, outPos, pos, pos + op);
90
+ pos += op;
91
+ outPos += op;
92
+ }
93
+ else {
94
+ throw createGitPackCorruptError("delta opcode 0 is reserved");
95
+ }
96
+ }
97
+ if (outPos !== resultSize) {
98
+ throw createGitPackCorruptError("delta result size mismatch");
99
+ }
100
+ return out;
101
+ };
102
+ export const parsePack = async (pack) => {
103
+ if (pack.length < HEADER_SIZE + TRAILER_SIZE) {
104
+ throw createGitPackCorruptError("pack too short");
105
+ }
106
+ if (pack.toString("latin1", 0, 4) !== "PACK") {
107
+ throw createGitPackCorruptError("bad pack magic");
108
+ }
109
+ const version = pack.readUInt32BE(4);
110
+ if (version !== 2) {
111
+ throw createGitPackCorruptError(`unsupported pack version ${version}`);
112
+ }
113
+ const count = pack.readUInt32BE(8);
114
+ if (count > MAX_OBJECT_COUNT) {
115
+ throw createGitPackCorruptError(`too many pack entries (${count})`);
116
+ }
117
+ const expectedTrailer = pack.toString("hex", pack.length - TRAILER_SIZE);
118
+ const actualTrailer = createHash("sha1")
119
+ .update(pack.subarray(0, pack.length - TRAILER_SIZE))
120
+ .digest("hex");
121
+ if (actualTrailer !== expectedTrailer) {
122
+ throw createGitPackCorruptError("pack trailer checksum mismatch");
123
+ }
124
+ const end = pack.length - TRAILER_SIZE;
125
+ let pos = HEADER_SIZE;
126
+ const nextByte = () => {
127
+ if (pos >= end) {
128
+ throw createGitPackCorruptError("truncated pack entry");
129
+ }
130
+ return pack[pos++];
131
+ };
132
+ const entries = [];
133
+ const deltaCounts = { ofs: 0, ref: 0 };
134
+ let totalExpanded = 0;
135
+ const addExpanded = (bytes) => {
136
+ totalExpanded += bytes;
137
+ if (totalExpanded > MAX_TOTAL_EXPANDED_BYTES) {
138
+ throw createGitPackCorruptError("pack expands beyond total size limit");
139
+ }
140
+ };
141
+ for (let i = 0; i < count; i++) {
142
+ const offset = pos;
143
+ let byte = nextByte();
144
+ const type = (byte >> 4) & 0x07;
145
+ let size = byte & 0x0f;
146
+ let shift = 4;
147
+ while (byte & 0x80) {
148
+ byte = nextByte();
149
+ size += (byte & 0x7f) * 2 ** shift;
150
+ shift += 7;
151
+ }
152
+ let baseOffset;
153
+ let baseOid;
154
+ if (type === OBJ_OFS_DELTA) {
155
+ byte = nextByte();
156
+ let negOffset = byte & 0x7f;
157
+ while (byte & 0x80) {
158
+ byte = nextByte();
159
+ negOffset = (negOffset + 1) * 128 + (byte & 0x7f);
160
+ }
161
+ baseOffset = offset - negOffset;
162
+ if (baseOffset < HEADER_SIZE) {
163
+ throw createGitPackCorruptError("ofs-delta base offset out of range");
164
+ }
165
+ deltaCounts.ofs++;
166
+ }
167
+ else if (type === OBJ_REF_DELTA) {
168
+ if (pos + 20 > end) {
169
+ throw createGitPackCorruptError("truncated ref-delta base oid");
170
+ }
171
+ baseOid = pack.toString("hex", pos, pos + 20);
172
+ pos += 20;
173
+ deltaCounts.ref++;
174
+ }
175
+ else if (TYPE_NAMES[type] === undefined) {
176
+ throw createGitPackCorruptError(`unknown pack entry type ${type}`);
177
+ }
178
+ if (size > MAX_OBJECT_BYTES) {
179
+ throw createGitPackCorruptError("pack entry size exceeds limit");
180
+ }
181
+ let payload;
182
+ let bytesRead;
183
+ try {
184
+ ({ data: payload, bytesRead } = await inflateSlice(pack, pos, MAX_OBJECT_BYTES));
185
+ }
186
+ catch (err) {
187
+ throw createGitPackCorruptError(`zlib inflate failed at offset ${pos}: ${err instanceof Error ? err.message : String(err)}`);
188
+ }
189
+ if (payload.length !== size) {
190
+ throw createGitPackCorruptError("pack entry size mismatch");
191
+ }
192
+ addExpanded(payload.length);
193
+ pos += bytesRead;
194
+ if (pos > end) {
195
+ throw createGitPackCorruptError("pack entry overruns trailer");
196
+ }
197
+ entries.push({ offset, type, payload, baseOffset, baseOid });
198
+ }
199
+ if (pos !== end) {
200
+ throw createGitPackCorruptError("trailing garbage after last pack entry");
201
+ }
202
+ const byOffset = new Map();
203
+ const byOid = new Map();
204
+ const childrenByOffset = new Map();
205
+ const childrenByOid = new Map();
206
+ const register = (entry, type, data) => {
207
+ const obj = { oid: oidOfObject(type, data), type, data };
208
+ byOffset.set(entry.offset, obj);
209
+ byOid.set(obj.oid, obj);
210
+ };
211
+ let unresolvedCount = 0;
212
+ const queue = [];
213
+ for (const entry of entries) {
214
+ if (entry.baseOffset === undefined && entry.baseOid === undefined) {
215
+ register(entry, entry.type, entry.payload);
216
+ queue.push(entry);
217
+ }
218
+ else {
219
+ unresolvedCount++;
220
+ if (entry.baseOffset !== undefined) {
221
+ const list = childrenByOffset.get(entry.baseOffset);
222
+ if (list === undefined)
223
+ childrenByOffset.set(entry.baseOffset, [entry]);
224
+ else
225
+ list.push(entry);
226
+ }
227
+ else {
228
+ const oid = entry.baseOid;
229
+ const list = childrenByOid.get(oid);
230
+ if (list === undefined)
231
+ childrenByOid.set(oid, [entry]);
232
+ else
233
+ list.push(entry);
234
+ }
235
+ }
236
+ }
237
+ while (queue.length > 0) {
238
+ const parent = queue.pop();
239
+ const base = byOffset.get(parent.offset);
240
+ const kids = [
241
+ ...(childrenByOffset.get(parent.offset) ?? []),
242
+ ...(childrenByOid.get(base.oid) ?? []),
243
+ ];
244
+ childrenByOffset.delete(parent.offset);
245
+ childrenByOid.delete(base.oid);
246
+ for (const child of kids) {
247
+ const resolved = applyDelta(base.data, child.payload);
248
+ addExpanded(resolved.length);
249
+ register(child, base.type, resolved);
250
+ unresolvedCount--;
251
+ queue.push(child);
252
+ }
253
+ }
254
+ if (unresolvedCount > 0) {
255
+ throw createGitPackCorruptError("unresolvable delta (base not found in pack)");
256
+ }
257
+ return {
258
+ objects: entries.map((entry) => byOffset.get(entry.offset)),
259
+ deltaCounts,
260
+ };
261
+ };
@@ -0,0 +1,20 @@
1
+ import type { PackedObject } from "./pack-parse.js";
2
+ export type StoreIndexEntry = {
3
+ oid: string;
4
+ type: number;
5
+ offset: number;
6
+ length: number;
7
+ };
8
+ export type StoredObject = {
9
+ type: number;
10
+ data: Buffer;
11
+ };
12
+ export type PackStore = {
13
+ hasObject: (oid: string) => boolean;
14
+ readObject: (oid: string) => Promise<StoredObject | undefined>;
15
+ writeObjects: (name: string, objects: PackedObject[]) => Promise<void>;
16
+ clearCache: () => void;
17
+ };
18
+ export declare const encodeStoreIndex: (entries: StoreIndexEntry[]) => Buffer;
19
+ export declare const decodeStoreIndex: (buf: Buffer) => StoreIndexEntry[] | null;
20
+ export declare const openPackStore: (storeDir: string) => Promise<PackStore>;
@@ -0,0 +1,144 @@
1
+ import { mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import zlib from "node:zlib";
4
+ import { createGitPackCorruptError } from "./errors.js";
5
+ const INDEX_MAGIC = "ACIX";
6
+ const INDEX_VERSION = 1;
7
+ const INDEX_HEADER_SIZE = 12;
8
+ const INDEX_ENTRY_SIZE = 33;
9
+ const PACKS_DIR = "packs";
10
+ const STAGING_DIR = "tmp";
11
+ const MAX_OBJECT_BYTES = 256 * 1024 * 1024;
12
+ export const encodeStoreIndex = (entries) => {
13
+ const buf = Buffer.alloc(INDEX_HEADER_SIZE + INDEX_ENTRY_SIZE * entries.length);
14
+ buf.write(INDEX_MAGIC, 0, "latin1");
15
+ buf.writeUInt32BE(INDEX_VERSION, 4);
16
+ buf.writeUInt32BE(entries.length, 8);
17
+ let pos = INDEX_HEADER_SIZE;
18
+ for (const entry of entries) {
19
+ buf.write(entry.oid, pos, 20, "hex");
20
+ buf.writeUInt8(entry.type, pos + 20);
21
+ buf.writeBigUInt64BE(BigInt(entry.offset), pos + 21);
22
+ buf.writeUInt32BE(entry.length, pos + 29);
23
+ pos += INDEX_ENTRY_SIZE;
24
+ }
25
+ return buf;
26
+ };
27
+ export const decodeStoreIndex = (buf) => {
28
+ if (buf.length < INDEX_HEADER_SIZE)
29
+ return null;
30
+ if (buf.toString("latin1", 0, 4) !== INDEX_MAGIC)
31
+ return null;
32
+ if (buf.readUInt32BE(4) !== INDEX_VERSION)
33
+ return null;
34
+ const count = buf.readUInt32BE(8);
35
+ if (buf.length !== INDEX_HEADER_SIZE + INDEX_ENTRY_SIZE * count)
36
+ return null;
37
+ const entries = [];
38
+ let pos = INDEX_HEADER_SIZE;
39
+ for (let i = 0; i < count; i++) {
40
+ const offsetBig = buf.readBigUInt64BE(pos + 21);
41
+ if (offsetBig > BigInt(Number.MAX_SAFE_INTEGER))
42
+ return null;
43
+ entries.push({
44
+ oid: buf.toString("hex", pos, pos + 20),
45
+ type: buf.readUInt8(pos + 20),
46
+ offset: Number(offsetBig),
47
+ length: buf.readUInt32BE(pos + 29),
48
+ });
49
+ pos += INDEX_ENTRY_SIZE;
50
+ }
51
+ return entries;
52
+ };
53
+ export const openPackStore = async (storeDir) => {
54
+ const packsDir = join(storeDir, PACKS_DIR);
55
+ const locations = new Map();
56
+ const dataCache = new Map();
57
+ const names = await readdir(packsDir).catch(() => []);
58
+ for (const name of names.filter((n) => n.endsWith(".idx")).sort()) {
59
+ const raw = await readFile(join(packsDir, name)).catch(() => null);
60
+ if (raw === null)
61
+ continue;
62
+ const entries = decodeStoreIndex(raw);
63
+ if (entries === null)
64
+ continue;
65
+ const dataPath = join(packsDir, name.slice(0, -".idx".length) + ".dat");
66
+ for (const entry of entries) {
67
+ if (!locations.has(entry.oid)) {
68
+ locations.set(entry.oid, { dataPath, ...entry });
69
+ }
70
+ }
71
+ }
72
+ const readDataFile = (dataPath) => {
73
+ let cached = dataCache.get(dataPath);
74
+ if (cached === undefined) {
75
+ cached = readFile(dataPath);
76
+ cached.catch(() => {
77
+ if (dataCache.get(dataPath) === cached)
78
+ dataCache.delete(dataPath);
79
+ });
80
+ dataCache.set(dataPath, cached);
81
+ }
82
+ return cached;
83
+ };
84
+ return {
85
+ hasObject: (oid) => locations.has(oid),
86
+ readObject: async (oid) => {
87
+ const loc = locations.get(oid);
88
+ if (loc === undefined)
89
+ return undefined;
90
+ let dat;
91
+ try {
92
+ dat = await readDataFile(loc.dataPath);
93
+ }
94
+ catch (err) {
95
+ throw createGitPackCorruptError(`store data file unreadable: ${loc.dataPath}: ${err instanceof Error ? err.message : String(err)}`);
96
+ }
97
+ if (loc.offset + loc.length > dat.length) {
98
+ throw createGitPackCorruptError(`store data file truncated: ${loc.dataPath}`);
99
+ }
100
+ try {
101
+ const data = zlib.inflateSync(dat.subarray(loc.offset, loc.offset + loc.length), { maxOutputLength: MAX_OBJECT_BYTES });
102
+ return { type: loc.type, data };
103
+ }
104
+ catch (err) {
105
+ throw createGitPackCorruptError(`store data corrupt: ${loc.dataPath}: ${err instanceof Error ? err.message : String(err)}`);
106
+ }
107
+ },
108
+ writeObjects: async (name, objects) => {
109
+ const stagingDir = join(storeDir, STAGING_DIR, name);
110
+ await mkdir(stagingDir, { recursive: true });
111
+ const chunks = [];
112
+ const entries = [];
113
+ let offset = 0;
114
+ for (const obj of objects) {
115
+ const compressed = zlib.deflateSync(obj.data);
116
+ chunks.push(compressed);
117
+ entries.push({
118
+ oid: obj.oid,
119
+ type: obj.type,
120
+ offset,
121
+ length: compressed.length,
122
+ });
123
+ offset += compressed.length;
124
+ }
125
+ const datName = `${name}.dat`;
126
+ const idxName = `${name}.idx`;
127
+ await writeFile(join(stagingDir, datName), Buffer.concat(chunks));
128
+ await writeFile(join(stagingDir, idxName), encodeStoreIndex(entries));
129
+ await mkdir(packsDir, { recursive: true });
130
+ await rename(join(stagingDir, datName), join(packsDir, datName));
131
+ await rename(join(stagingDir, idxName), join(packsDir, idxName));
132
+ await rm(stagingDir, { recursive: true, force: true }).catch(() => { });
133
+ const dataPath = join(packsDir, datName);
134
+ for (const entry of entries) {
135
+ if (!locations.has(entry.oid)) {
136
+ locations.set(entry.oid, { dataPath, ...entry });
137
+ }
138
+ }
139
+ },
140
+ clearCache: () => {
141
+ dataCache.clear();
142
+ },
143
+ };
144
+ };
@@ -0,0 +1 @@
1
+ export declare const readTextFileCapped: (path: string, maxBytes: number) => Promise<string | null>;
@@ -0,0 +1,26 @@
1
+ import { open } from "node:fs/promises";
2
+ export const readTextFileCapped = async (path, maxBytes) => {
3
+ let handle;
4
+ try {
5
+ handle = await open(path, "r");
6
+ const stats = await handle.stat();
7
+ if (!stats.isFile() || stats.size > maxBytes)
8
+ return null;
9
+ const size = Number(stats.size);
10
+ const buf = Buffer.alloc(size);
11
+ let pos = 0;
12
+ while (pos < size) {
13
+ const { bytesRead } = await handle.read(buf, pos, size - pos, pos);
14
+ if (bytesRead === 0)
15
+ break;
16
+ pos += bytesRead;
17
+ }
18
+ return buf.subarray(0, pos).toString("utf-8");
19
+ }
20
+ catch {
21
+ return null;
22
+ }
23
+ finally {
24
+ await handle?.close().catch(() => { });
25
+ }
26
+ };
@@ -0,0 +1 @@
1
+ export declare const redactUrlCredentials: (url: string) => string;
@@ -0,0 +1,14 @@
1
+ const AUTHORITY_USERINFO = /^([A-Za-z][A-Za-z0-9+.\-]*:)?(\/\/)[^/?#@]*@/;
2
+ export const redactUrlCredentials = (url) => {
3
+ try {
4
+ const parsed = new URL(url);
5
+ if (parsed.username || parsed.password) {
6
+ parsed.username = "";
7
+ parsed.password = "";
8
+ return parsed.toString();
9
+ }
10
+ }
11
+ catch {
12
+ }
13
+ return url.replace(AUTHORITY_USERINFO, "$1$2");
14
+ };
@@ -0,0 +1,5 @@
1
+ export type RepoLayout = {
2
+ gitDir: string;
3
+ commonDir: string;
4
+ };
5
+ export declare const resolveRepoLayout: (projectDir: string) => Promise<RepoLayout | null>;
@@ -0,0 +1,44 @@
1
+ import { lstat, readFile } from "node:fs/promises";
2
+ import { isAbsolute, join, resolve } from "node:path";
3
+ export const resolveRepoLayout = async (projectDir) => {
4
+ const dotGit = join(projectDir, ".git");
5
+ let stats;
6
+ try {
7
+ stats = await lstat(dotGit);
8
+ }
9
+ catch {
10
+ return null;
11
+ }
12
+ let gitDir;
13
+ if (stats.isDirectory()) {
14
+ gitDir = dotGit;
15
+ }
16
+ else if (stats.isFile()) {
17
+ const content = await readFile(dotGit, "utf-8").catch(() => null);
18
+ if (content === null)
19
+ return null;
20
+ const match = /^gitdir:[ \t]*(.+?)[ \t\r]*$/m.exec(content);
21
+ if (match === null || match[1].length === 0)
22
+ return null;
23
+ gitDir = isAbsolute(match[1]) ? match[1] : resolve(projectDir, match[1]);
24
+ try {
25
+ if (!(await lstat(gitDir)).isDirectory())
26
+ return null;
27
+ }
28
+ catch {
29
+ return null;
30
+ }
31
+ }
32
+ else {
33
+ return null;
34
+ }
35
+ let commonDir = gitDir;
36
+ const commonRef = await readFile(join(gitDir, "commondir"), "utf-8").catch(() => null);
37
+ if (commonRef !== null) {
38
+ const target = commonRef.trim();
39
+ if (target.length === 0)
40
+ return null;
41
+ commonDir = isAbsolute(target) ? target : resolve(gitDir, target);
42
+ }
43
+ return { gitDir, commonDir };
44
+ };
@@ -2,7 +2,7 @@ export type ServerCapabilities = {
2
2
  version2: boolean;
3
3
  fetchFeatures: string[];
4
4
  };
5
- export declare const fetchCapabilities: (repoUrl: string) => Promise<ServerCapabilities>;
5
+ export declare const fetchCapabilities: (repoUrl: string, signal?: AbortSignal) => Promise<ServerCapabilities>;
6
6
  export declare const assertServerSupported: (repoUrl: string, caps: ServerCapabilities) => void;
7
7
  export declare const isValidOid: (value: string) => boolean;
8
8
  export declare const isValidRefName: (ref: string) => boolean;
@@ -10,9 +10,10 @@ export type ResolvedRef = {
10
10
  oid: string;
11
11
  fullRef: string;
12
12
  };
13
- export declare const resolveRef: (repoUrl: string, ref: string) => Promise<ResolvedRef | null>;
13
+ export declare const resolveRef: (repoUrl: string, ref: string, signal?: AbortSignal) => Promise<ResolvedRef | null>;
14
14
  export type FetchPackOptions = {
15
15
  deepenOne?: boolean;
16
16
  filterBlobNone?: boolean;
17
+ signal?: AbortSignal;
17
18
  };
18
19
  export declare const fetchPack: (repoUrl: string, wants: string[], options?: FetchPackOptions) => Promise<Buffer>;
@@ -2,8 +2,8 @@ import { DELIM_PKT, FLUSH_PKT, decodeDataLines, decodePktLines, encodePktLine, }
2
2
  import { createGitServerUnsupportedError } from "./errors.js";
3
3
  import { getInfoRefs, postUploadPack } from "./http.js";
4
4
  const AGENT = "agent=accel-cli";
5
- export const fetchCapabilities = async (repoUrl) => {
6
- const buf = await getInfoRefs(repoUrl);
5
+ export const fetchCapabilities = async (repoUrl, signal) => {
6
+ const buf = await getInfoRefs(repoUrl, signal);
7
7
  const lines = decodeDataLines(buf);
8
8
  const version2 = lines.some((l) => l.trim() === "version 2");
9
9
  const fetchLine = lines.find((l) => l.startsWith("fetch="));
@@ -38,7 +38,7 @@ export const isValidRefName = (ref) => ref.length > 0 &&
38
38
  !ref.startsWith("/") &&
39
39
  !ref.endsWith("/") &&
40
40
  !ref.endsWith(".lock");
41
- export const resolveRef = async (repoUrl, ref) => {
41
+ export const resolveRef = async (repoUrl, ref, signal) => {
42
42
  if (!isValidRefName(ref)) {
43
43
  throw new Error(`Invalid ref name: ${JSON.stringify(ref)}`);
44
44
  }
@@ -46,7 +46,7 @@ export const resolveRef = async (repoUrl, ref) => {
46
46
  "peel",
47
47
  `ref-prefix refs/heads/${ref}`,
48
48
  `ref-prefix refs/tags/${ref}`,
49
- ]));
49
+ ]), signal);
50
50
  const entries = new Map();
51
51
  for (const line of decodeDataLines(buf)) {
52
52
  const [oid, name, ...rest] = line.split(" ");
@@ -77,7 +77,7 @@ export const fetchPack = async (repoUrl, wants, options = {}) => {
77
77
  "no-progress",
78
78
  "done",
79
79
  ];
80
- const buf = await postUploadPack(repoUrl, buildCommandBody("fetch", args));
80
+ const buf = await postUploadPack(repoUrl, buildCommandBody("fetch", args), options.signal);
81
81
  const chunks = [];
82
82
  let inPackfile = false;
83
83
  for (const pkt of decodePktLines(buf)) {
@@ -0,0 +1,11 @@
1
+ export declare const asciiFold: (path: string) => string;
2
+ export type UntrackedScanOptions = {
3
+ worktreeDir: string;
4
+ trackedFiles: ReadonlySet<string>;
5
+ trackedDirs: ReadonlySet<string>;
6
+ ignorecase: boolean;
7
+ baselinePatterns: string[];
8
+ deadline: number;
9
+ };
10
+ export declare const hasUntrackedFile: (opts: UntrackedScanOptions) => Promise<boolean>;
11
+ export declare const collectUntrackedPaths: (opts: UntrackedScanOptions) => Promise<string[]>;