@aria-cli/tools 1.0.12 → 1.0.14
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/index.js +378 -70
- package/dist/network-runtime/index.js +8 -12
- package/dist-cjs/index.js +400 -435
- package/dist-cjs/network-runtime/index.js +8 -172
- package/package.json +8 -6
- package/dist/.tsbuildinfo +0 -1
- package/dist/ask-user-interaction.js +0 -22
- package/dist/cache/web-cache.js +0 -66
- package/dist/definitions/arion.js +0 -104
- package/dist/definitions/browser/browser.js +0 -418
- package/dist/definitions/browser/index.js +0 -4
- package/dist/definitions/browser/pw-downloads.js +0 -114
- package/dist/definitions/browser/pw-interactions.js +0 -199
- package/dist/definitions/browser/pw-responses.js +0 -76
- package/dist/definitions/browser/pw-session.js +0 -310
- package/dist/definitions/browser/pw-shared.js +0 -66
- package/dist/definitions/browser/pw-snapshot.js +0 -301
- package/dist/definitions/browser/pw-state.js +0 -62
- package/dist/definitions/browser/types.js +0 -4
- package/dist/definitions/code-intelligence.js +0 -470
- package/dist/definitions/core.js +0 -109
- package/dist/definitions/delegation.js +0 -512
- package/dist/definitions/deploy.js +0 -65
- package/dist/definitions/filesystem.js +0 -196
- package/dist/definitions/frg.js +0 -63
- package/dist/definitions/index.js +0 -20
- package/dist/definitions/memory.js +0 -123
- package/dist/definitions/messaging.js +0 -625
- package/dist/definitions/meta.js +0 -349
- package/dist/definitions/network.js +0 -159
- package/dist/definitions/outlook.js +0 -277
- package/dist/definitions/patch/apply-patch.js +0 -184
- package/dist/definitions/patch/fuzzy-match.js +0 -166
- package/dist/definitions/patch/index.js +0 -1
- package/dist/definitions/patch/patch-parser.js +0 -207
- package/dist/definitions/patch/sandbox-paths.js +0 -105
- package/dist/definitions/process/index.js +0 -4
- package/dist/definitions/process/process-registry.js +0 -213
- package/dist/definitions/process/process.js +0 -386
- package/dist/definitions/process/pty-keys.js +0 -254
- package/dist/definitions/process/session-slug.js +0 -142
- package/dist/definitions/quip.js +0 -195
- package/dist/definitions/search.js +0 -60
- package/dist/definitions/session-history.js +0 -69
- package/dist/definitions/shell.js +0 -181
- package/dist/definitions/slack.js +0 -180
- package/dist/definitions/web.js +0 -109
- package/dist/executors/apply-patch.js +0 -901
- package/dist/executors/arion.js +0 -119
- package/dist/executors/code-intelligence.js +0 -882
- package/dist/executors/deploy.js +0 -848
- package/dist/executors/filesystem.js +0 -1122
- package/dist/executors/frg-freshness.js +0 -576
- package/dist/executors/frg.js +0 -298
- package/dist/executors/index.js +0 -46
- package/dist/executors/learning-meta.js +0 -1146
- package/dist/executors/lsp-client.js +0 -296
- package/dist/executors/memory.js +0 -750
- package/dist/executors/meta.js +0 -220
- package/dist/executors/process-registry.js +0 -465
- package/dist/executors/pty-session-store.js +0 -30
- package/dist/executors/pty.js +0 -271
- package/dist/executors/restart.js +0 -119
- package/dist/executors/search-freshness.js +0 -195
- package/dist/executors/search-types.js +0 -52
- package/dist/executors/search.js +0 -66
- package/dist/executors/self-diagnose.js +0 -398
- package/dist/executors/session-history.js +0 -283
- package/dist/executors/shell-safety.js +0 -473
- package/dist/executors/shell.js +0 -954
- package/dist/executors/utils.js +0 -33
- package/dist/executors/web.js +0 -542
- package/dist/extraction/content-extraction.js +0 -235
- package/dist/extraction/index.js +0 -4
- package/dist/headless-control-contract.js +0 -967
- package/dist/local-control-http-auth.js +0 -2
- package/dist/mcp/client.js +0 -181
- package/dist/mcp/connection.js +0 -480
- package/dist/mcp/index.js +0 -10
- package/dist/mcp/jsonrpc.js +0 -144
- package/dist/mcp/types.js +0 -7
- package/dist/network-control-adapter.js +0 -72
- package/dist/network-runtime/address-types.js +0 -165
- package/dist/network-runtime/db-owner-fencing.js +0 -69
- package/dist/network-runtime/delivery-receipts.js +0 -267
- package/dist/network-runtime/direct-endpoint-authority.js +0 -25
- package/dist/network-runtime/local-control-contract.js +0 -627
- package/dist/network-runtime/node-store-contract.js +0 -34
- package/dist/network-runtime/pair-route-contract.js +0 -77
- package/dist/network-runtime/peer-capabilities.js +0 -28
- package/dist/network-runtime/peer-principal-ref.js +0 -12
- package/dist/network-runtime/peer-state-machine.js +0 -121
- package/dist/network-runtime/protocol-schemas.js +0 -205
- package/dist/network-runtime/runtime-bootstrap-contract.js +0 -60
- package/dist/outlook/desktop-session.js +0 -279
- package/dist/policy.js +0 -149
- package/dist/providers/brave.js +0 -62
- package/dist/providers/duckduckgo.js +0 -176
- package/dist/providers/exa.js +0 -63
- package/dist/providers/firecrawl.js +0 -55
- package/dist/providers/index.js +0 -7
- package/dist/providers/jina.js +0 -49
- package/dist/providers/router.js +0 -96
- package/dist/providers/search-provider.js +0 -32
- package/dist/providers/tavily.js +0 -54
- package/dist/quip/desktop-session.js +0 -317
- package/dist/registry/index.js +0 -1
- package/dist/registry/registry.js +0 -756
- package/dist/runtime-socket-local-control-client.js +0 -330
- package/dist/security/dns-normalization.js +0 -19
- package/dist/security/dns-pinning.js +0 -123
- package/dist/security/external-content.js +0 -91
- package/dist/security/ssrf.js +0 -181
- package/dist/slack/desktop-session.js +0 -324
- package/dist/tool-factory.js +0 -47
- package/dist/types.js +0 -7
- package/dist/utils/retry.js +0 -132
- package/dist/utils/safe-parse-json.js +0 -160
- package/dist/utils/url.js +0 -19
- package/dist-cjs/.tsbuildinfo +0 -1
- package/dist-cjs/ask-user-interaction.js +0 -27
- package/dist-cjs/cache/web-cache.js +0 -70
- package/dist-cjs/definitions/arion.js +0 -107
- package/dist-cjs/definitions/browser/browser.js +0 -421
- package/dist-cjs/definitions/browser/index.js +0 -8
- package/dist-cjs/definitions/browser/pw-downloads.js +0 -117
- package/dist-cjs/definitions/browser/pw-interactions.js +0 -213
- package/dist-cjs/definitions/browser/pw-responses.js +0 -84
- package/dist-cjs/definitions/browser/pw-session.js +0 -326
- package/dist-cjs/definitions/browser/pw-shared.js +0 -72
- package/dist-cjs/definitions/browser/pw-snapshot.js +0 -307
- package/dist-cjs/definitions/browser/pw-state.js +0 -70
- package/dist-cjs/definitions/browser/types.js +0 -5
- package/dist-cjs/definitions/code-intelligence.js +0 -473
- package/dist-cjs/definitions/core.js +0 -133
- package/dist-cjs/definitions/delegation.js +0 -515
- package/dist-cjs/definitions/deploy.js +0 -68
- package/dist-cjs/definitions/filesystem.js +0 -199
- package/dist-cjs/definitions/frg.js +0 -66
- package/dist-cjs/definitions/index.js +0 -43
- package/dist-cjs/definitions/memory.js +0 -126
- package/dist-cjs/definitions/messaging.js +0 -631
- package/dist-cjs/definitions/meta.js +0 -352
- package/dist-cjs/definitions/network.js +0 -162
- package/dist-cjs/definitions/outlook.js +0 -280
- package/dist-cjs/definitions/patch/apply-patch.js +0 -191
- package/dist-cjs/definitions/patch/fuzzy-match.js +0 -172
- package/dist-cjs/definitions/patch/index.js +0 -5
- package/dist-cjs/definitions/patch/patch-parser.js +0 -215
- package/dist-cjs/definitions/patch/sandbox-paths.js +0 -113
- package/dist-cjs/definitions/process/index.js +0 -8
- package/dist-cjs/definitions/process/process-registry.js +0 -231
- package/dist-cjs/definitions/process/process.js +0 -389
- package/dist-cjs/definitions/process/pty-keys.js +0 -259
- package/dist-cjs/definitions/process/session-slug.js +0 -145
- package/dist-cjs/definitions/quip.js +0 -198
- package/dist-cjs/definitions/search.js +0 -63
- package/dist-cjs/definitions/session-history.js +0 -72
- package/dist-cjs/definitions/shell.js +0 -184
- package/dist-cjs/definitions/slack.js +0 -183
- package/dist-cjs/definitions/web.js +0 -112
- package/dist-cjs/executors/apply-patch.js +0 -938
- package/dist-cjs/executors/arion.js +0 -125
- package/dist-cjs/executors/code-intelligence.js +0 -925
- package/dist-cjs/executors/deploy.js +0 -869
- package/dist-cjs/executors/filesystem.js +0 -1167
- package/dist-cjs/executors/frg-freshness.js +0 -627
- package/dist-cjs/executors/frg.js +0 -334
- package/dist-cjs/executors/index.js +0 -143
- package/dist-cjs/executors/learning-meta.js +0 -1165
- package/dist-cjs/executors/lsp-client.js +0 -310
- package/dist-cjs/executors/memory.js +0 -796
- package/dist-cjs/executors/meta.js +0 -226
- package/dist-cjs/executors/process-registry.js +0 -469
- package/dist-cjs/executors/pty-session-store.js +0 -34
- package/dist-cjs/executors/pty.js +0 -312
- package/dist-cjs/executors/restart.js +0 -155
- package/dist-cjs/executors/search-freshness.js +0 -234
- package/dist-cjs/executors/search-types.js +0 -56
- package/dist-cjs/executors/search.js +0 -102
- package/dist-cjs/executors/self-diagnose.js +0 -434
- package/dist-cjs/executors/session-history.js +0 -320
- package/dist-cjs/executors/shell-safety.js +0 -478
- package/dist-cjs/executors/shell.js +0 -1001
- package/dist-cjs/executors/utils.js +0 -73
- package/dist-cjs/executors/web.js +0 -547
- package/dist-cjs/extraction/content-extraction.js +0 -243
- package/dist-cjs/extraction/index.js +0 -8
- package/dist-cjs/headless-control-contract.js +0 -972
- package/dist-cjs/local-control-http-auth.js +0 -5
- package/dist-cjs/mcp/client.js +0 -185
- package/dist-cjs/mcp/connection.js +0 -484
- package/dist-cjs/mcp/index.js +0 -30
- package/dist-cjs/mcp/jsonrpc.js +0 -148
- package/dist-cjs/mcp/types.js +0 -8
- package/dist-cjs/network-control-adapter.js +0 -77
- package/dist-cjs/network-runtime/address-types.js +0 -168
- package/dist-cjs/network-runtime/db-owner-fencing.js +0 -76
- package/dist-cjs/network-runtime/delivery-receipts.js +0 -276
- package/dist-cjs/network-runtime/direct-endpoint-authority.js +0 -29
- package/dist-cjs/network-runtime/local-control-contract.js +0 -633
- package/dist-cjs/network-runtime/node-store-contract.js +0 -38
- package/dist-cjs/network-runtime/pair-route-contract.js +0 -80
- package/dist-cjs/network-runtime/peer-capabilities.js +0 -37
- package/dist-cjs/network-runtime/peer-principal-ref.js +0 -15
- package/dist-cjs/network-runtime/peer-state-machine.js +0 -129
- package/dist-cjs/network-runtime/protocol-schemas.js +0 -212
- package/dist-cjs/network-runtime/runtime-bootstrap-contract.js +0 -63
- package/dist-cjs/outlook/desktop-session.js +0 -318
- package/dist-cjs/policy.js +0 -155
- package/dist-cjs/providers/brave.js +0 -66
- package/dist-cjs/providers/duckduckgo.js +0 -180
- package/dist-cjs/providers/exa.js +0 -67
- package/dist-cjs/providers/firecrawl.js +0 -59
- package/dist-cjs/providers/index.js +0 -17
- package/dist-cjs/providers/jina.js +0 -53
- package/dist-cjs/providers/router.js +0 -100
- package/dist-cjs/providers/search-provider.js +0 -36
- package/dist-cjs/providers/tavily.js +0 -58
- package/dist-cjs/quip/desktop-session.js +0 -353
- package/dist-cjs/registry/index.js +0 -6
- package/dist-cjs/registry/registry.js +0 -761
- package/dist-cjs/runtime-socket-local-control-client.js +0 -367
- package/dist-cjs/security/dns-normalization.js +0 -22
- package/dist-cjs/security/dns-pinning.js +0 -160
- package/dist-cjs/security/external-content.js +0 -95
- package/dist-cjs/security/ssrf.js +0 -221
- package/dist-cjs/slack/desktop-session.js +0 -366
- package/dist-cjs/tool-factory.js +0 -50
- package/dist-cjs/types.js +0 -8
- package/dist-cjs/utils/retry.js +0 -169
- package/dist-cjs/utils/safe-parse-json.js +0 -164
- package/dist-cjs/utils/url.js +0 -23
|
@@ -1,627 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.MAX_CACHED_MUTATION_CONTENT_BYTES = exports.MAX_PENDING_MUTATION_BYTES_BEFORE_SYNC_FLUSH = exports.MAX_PENDING_MUTATIONS_BEFORE_SYNC_FLUSH = exports.BACKGROUND_FRG_MAX_FLUSH_DELAY_MS = exports.DEFAULT_BACKGROUND_FRG_FLUSH_DELAY_MS = void 0;
|
|
37
|
-
exports.getTrackedRepoRootForPath = getTrackedRepoRootForPath;
|
|
38
|
-
exports.ensureFrgRepoStateLoaded = ensureFrgRepoStateLoaded;
|
|
39
|
-
exports.recordFrgMutation = recordFrgMutation;
|
|
40
|
-
exports.getPendingFrgMutations = getPendingFrgMutations;
|
|
41
|
-
exports.getPendingFrgMutationBytes = getPendingFrgMutationBytes;
|
|
42
|
-
exports.clearPendingFrgMutations = clearPendingFrgMutations;
|
|
43
|
-
exports.flushPendingFrgMutations = flushPendingFrgMutations;
|
|
44
|
-
exports.maybeBuildFrgIndexForRepo = maybeBuildFrgIndexForRepo;
|
|
45
|
-
exports.scheduleBackgroundFrgFlush = scheduleBackgroundFrgFlush;
|
|
46
|
-
exports.shouldForceSynchronousFrgFlush = shouldForceSynchronousFrgFlush;
|
|
47
|
-
exports.getFrgFlushStatus = getFrgFlushStatus;
|
|
48
|
-
exports.getGitDirtyStatus = getGitDirtyStatus;
|
|
49
|
-
exports.reconcileGitDirtyMutations = reconcileGitDirtyMutations;
|
|
50
|
-
exports.getFrgFreshnessSnapshot = getFrgFreshnessSnapshot;
|
|
51
|
-
exports.searchPendingFrgMutations = searchPendingFrgMutations;
|
|
52
|
-
const fsSync = __importStar(require("node:fs"));
|
|
53
|
-
const fs = __importStar(require("node:fs/promises"));
|
|
54
|
-
const nodePath = __importStar(require("node:path"));
|
|
55
|
-
const node_child_process_1 = require("node:child_process");
|
|
56
|
-
const fastripgrep_1 = require("@aria-cli/fastripgrep");
|
|
57
|
-
const repoStates = new Map();
|
|
58
|
-
const flushStates = new Map();
|
|
59
|
-
exports.DEFAULT_BACKGROUND_FRG_FLUSH_DELAY_MS = 750;
|
|
60
|
-
exports.BACKGROUND_FRG_MAX_FLUSH_DELAY_MS = 30_000;
|
|
61
|
-
exports.MAX_PENDING_MUTATIONS_BEFORE_SYNC_FLUSH = 32;
|
|
62
|
-
exports.MAX_PENDING_MUTATION_BYTES_BEFORE_SYNC_FLUSH = 512 * 1024;
|
|
63
|
-
exports.MAX_CACHED_MUTATION_CONTENT_BYTES = 256 * 1024;
|
|
64
|
-
function normalizePath(p) {
|
|
65
|
-
return nodePath.resolve(p);
|
|
66
|
-
}
|
|
67
|
-
function walDir(repoRoot) {
|
|
68
|
-
return nodePath.join(normalizePath(repoRoot), ".frg", "session");
|
|
69
|
-
}
|
|
70
|
-
function walPath(repoRoot) {
|
|
71
|
-
return nodePath.join(walDir(repoRoot), "aria-pending.jsonl");
|
|
72
|
-
}
|
|
73
|
-
function ensureSessionStorageDir(repoRoot) {
|
|
74
|
-
fsSync.mkdirSync(walDir(repoRoot), { recursive: true });
|
|
75
|
-
}
|
|
76
|
-
function normalizeStoredContent(content) {
|
|
77
|
-
if (typeof content !== "string") {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
return Buffer.byteLength(content, "utf8") <= exports.MAX_CACHED_MUTATION_CONTENT_BYTES
|
|
81
|
-
? content
|
|
82
|
-
: undefined;
|
|
83
|
-
}
|
|
84
|
-
function getRepoState(repoRoot) {
|
|
85
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
86
|
-
const existing = repoStates.get(normalizedRepoRoot);
|
|
87
|
-
if (existing) {
|
|
88
|
-
ensureRepoStateLoaded(normalizedRepoRoot, existing);
|
|
89
|
-
return existing;
|
|
90
|
-
}
|
|
91
|
-
const created = { loaded: false, sequence: 0, pending: new Map() };
|
|
92
|
-
repoStates.set(normalizedRepoRoot, created);
|
|
93
|
-
ensureRepoStateLoaded(normalizedRepoRoot, created);
|
|
94
|
-
return created;
|
|
95
|
-
}
|
|
96
|
-
function getFlushState(repoRoot) {
|
|
97
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
98
|
-
const existing = flushStates.get(normalizedRepoRoot);
|
|
99
|
-
if (existing)
|
|
100
|
-
return existing;
|
|
101
|
-
const created = { timer: null, inFlight: false, retryCount: 0 };
|
|
102
|
-
flushStates.set(normalizedRepoRoot, created);
|
|
103
|
-
return created;
|
|
104
|
-
}
|
|
105
|
-
function ensureRepoStateLoaded(repoRoot, state) {
|
|
106
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
107
|
-
const currentState = state ?? repoStates.get(normalizedRepoRoot);
|
|
108
|
-
if (!currentState || currentState.loaded) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const pendingWalPath = walPath(normalizedRepoRoot);
|
|
112
|
-
if (fsSync.existsSync(pendingWalPath)) {
|
|
113
|
-
try {
|
|
114
|
-
const lines = fsSync.readFileSync(pendingWalPath, "utf8").split(/\r?\n/).filter(Boolean);
|
|
115
|
-
for (const line of lines) {
|
|
116
|
-
const parsed = JSON.parse(line);
|
|
117
|
-
const normalizedPath = normalizePath(parsed.path);
|
|
118
|
-
currentState.pending.set(normalizedPath, {
|
|
119
|
-
...parsed,
|
|
120
|
-
repoRoot: normalizedRepoRoot,
|
|
121
|
-
path: normalizedPath,
|
|
122
|
-
content: normalizeStoredContent(parsed.content),
|
|
123
|
-
});
|
|
124
|
-
currentState.sequence = Math.max(currentState.sequence, parsed.sequence ?? 0);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
// Ignore malformed WAL and proceed with empty/in-memory state.
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
currentState.loaded = true;
|
|
132
|
-
}
|
|
133
|
-
function rewriteWal(repoRoot) {
|
|
134
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
135
|
-
const state = repoStates.get(normalizedRepoRoot);
|
|
136
|
-
if (!state || state.pending.size === 0) {
|
|
137
|
-
try {
|
|
138
|
-
fsSync.rmSync(walPath(normalizedRepoRoot), { force: true });
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
// ignore
|
|
142
|
-
}
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
ensureSessionStorageDir(normalizedRepoRoot);
|
|
146
|
-
const records = [...state.pending.values()].sort((a, b) => a.sequence - b.sequence);
|
|
147
|
-
const content = records.map((record) => JSON.stringify(record)).join("\n") + "\n";
|
|
148
|
-
fsSync.writeFileSync(walPath(normalizedRepoRoot), content, "utf8");
|
|
149
|
-
}
|
|
150
|
-
function appendWalRecord(repoRoot, record) {
|
|
151
|
-
ensureSessionStorageDir(repoRoot);
|
|
152
|
-
fsSync.appendFileSync(walPath(repoRoot), `${JSON.stringify(record)}\n`, "utf8");
|
|
153
|
-
}
|
|
154
|
-
function findGitRepoRoot(startPath) {
|
|
155
|
-
let current = normalizePath(startPath);
|
|
156
|
-
try {
|
|
157
|
-
const stat = fsSync.statSync(current);
|
|
158
|
-
if (!stat.isDirectory()) {
|
|
159
|
-
current = nodePath.dirname(current);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
current = nodePath.dirname(current);
|
|
164
|
-
}
|
|
165
|
-
while (true) {
|
|
166
|
-
if (fsSync.existsSync(nodePath.join(current, ".git"))) {
|
|
167
|
-
return current;
|
|
168
|
-
}
|
|
169
|
-
const parent = nodePath.dirname(current);
|
|
170
|
-
if (parent === current) {
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
current = parent;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function escapeRegex(text) {
|
|
177
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
178
|
-
}
|
|
179
|
-
function compilePattern(options) {
|
|
180
|
-
let pattern = options.literal ? escapeRegex(options.pattern) : options.pattern;
|
|
181
|
-
const smartCaseInsensitive = options.smartCase && !/[A-Z]/.test(options.pattern);
|
|
182
|
-
const flags = `${options.caseInsensitive || smartCaseInsensitive ? "i" : ""}g`;
|
|
183
|
-
return new RegExp(pattern, flags);
|
|
184
|
-
}
|
|
185
|
-
function globToRegExp(glob) {
|
|
186
|
-
const escaped = glob
|
|
187
|
-
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
188
|
-
.replace(/\*\*/g, "::DOUBLE_STAR::")
|
|
189
|
-
.replace(/\*/g, "[^/]*")
|
|
190
|
-
.replace(/::DOUBLE_STAR::/g, ".*")
|
|
191
|
-
.replace(/\?/g, ".");
|
|
192
|
-
return new RegExp(`^${escaped}$`);
|
|
193
|
-
}
|
|
194
|
-
function pathMatchesFilters(relativePath, options) {
|
|
195
|
-
if (options.fileType) {
|
|
196
|
-
const ext = options.fileType.startsWith(".") ? options.fileType : `.${options.fileType}`;
|
|
197
|
-
if (!relativePath.endsWith(ext)) {
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if (options.glob) {
|
|
202
|
-
const re = globToRegExp(options.glob);
|
|
203
|
-
if (!re.test(relativePath)) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
function buildContextLines(lines, lineIndex, radius) {
|
|
210
|
-
const before = [];
|
|
211
|
-
const after = [];
|
|
212
|
-
for (let i = Math.max(0, lineIndex - radius); i < lineIndex; i++) {
|
|
213
|
-
before.push({ line: i + 1, content: lines[i] ?? "" });
|
|
214
|
-
}
|
|
215
|
-
for (let i = lineIndex + 1; i <= Math.min(lines.length - 1, lineIndex + radius); i++) {
|
|
216
|
-
after.push({ line: i + 1, content: lines[i] ?? "" });
|
|
217
|
-
}
|
|
218
|
-
return { before, after };
|
|
219
|
-
}
|
|
220
|
-
function relativeToRepo(repoRoot, filePath) {
|
|
221
|
-
return nodePath.relative(repoRoot, filePath).split(nodePath.sep).join("/");
|
|
222
|
-
}
|
|
223
|
-
function isBinaryBuffer(content) {
|
|
224
|
-
const checkLength = Math.min(content.length, 8192);
|
|
225
|
-
for (let i = 0; i < checkLength; i++) {
|
|
226
|
-
if (content[i] === 0) {
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
function setMutationRecordForRepo(repoRoot, filePath, operation, content, options) {
|
|
233
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
234
|
-
const state = getRepoState(normalizedRepoRoot);
|
|
235
|
-
state.sequence += 1;
|
|
236
|
-
const normalizedPath = normalizePath(filePath);
|
|
237
|
-
const record = {
|
|
238
|
-
repoRoot: normalizedRepoRoot,
|
|
239
|
-
path: normalizedPath,
|
|
240
|
-
operation,
|
|
241
|
-
sequence: state.sequence,
|
|
242
|
-
recordedAt: Date.now(),
|
|
243
|
-
content: normalizeStoredContent(content),
|
|
244
|
-
};
|
|
245
|
-
state.pending.set(normalizedPath, record);
|
|
246
|
-
if (options?.persistWal !== false) {
|
|
247
|
-
appendWalRecord(normalizedRepoRoot, record);
|
|
248
|
-
}
|
|
249
|
-
if (options?.scheduleFlush !== false) {
|
|
250
|
-
scheduleBackgroundFrgFlush(normalizedRepoRoot);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function runGit(repoRoot, args) {
|
|
254
|
-
try {
|
|
255
|
-
return (0, node_child_process_1.execFileSync)("git", args, {
|
|
256
|
-
cwd: normalizePath(repoRoot),
|
|
257
|
-
encoding: "utf8",
|
|
258
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
259
|
-
}).trim();
|
|
260
|
-
}
|
|
261
|
-
catch {
|
|
262
|
-
return null;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
function getTrackedRepoRootForPath(filePath) {
|
|
266
|
-
return findGitRepoRoot(filePath);
|
|
267
|
-
}
|
|
268
|
-
function ensureFrgRepoStateLoaded(repoRoot) {
|
|
269
|
-
void getRepoState(repoRoot);
|
|
270
|
-
}
|
|
271
|
-
function recordFrgMutation(filePath, operation, content) {
|
|
272
|
-
const repoRoot = getTrackedRepoRootForPath(filePath);
|
|
273
|
-
if (!repoRoot)
|
|
274
|
-
return;
|
|
275
|
-
setMutationRecordForRepo(repoRoot, filePath, operation, content);
|
|
276
|
-
}
|
|
277
|
-
function getPendingFrgMutations(repoRoot) {
|
|
278
|
-
const state = getRepoState(repoRoot);
|
|
279
|
-
return [...state.pending.values()].sort((a, b) => a.sequence - b.sequence);
|
|
280
|
-
}
|
|
281
|
-
function getPendingFrgMutationBytes(repoRoot) {
|
|
282
|
-
return getPendingFrgMutations(repoRoot).reduce((total, record) => {
|
|
283
|
-
if (typeof record.content === "string") {
|
|
284
|
-
return total + Buffer.byteLength(record.content, "utf8");
|
|
285
|
-
}
|
|
286
|
-
try {
|
|
287
|
-
return total + fsSync.statSync(record.path).size;
|
|
288
|
-
}
|
|
289
|
-
catch {
|
|
290
|
-
return total;
|
|
291
|
-
}
|
|
292
|
-
}, 0);
|
|
293
|
-
}
|
|
294
|
-
function clearPendingFrgMutations(repoRoot) {
|
|
295
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
296
|
-
repoStates.delete(normalizedRepoRoot);
|
|
297
|
-
try {
|
|
298
|
-
fsSync.rmSync(walPath(normalizedRepoRoot), { force: true });
|
|
299
|
-
}
|
|
300
|
-
catch {
|
|
301
|
-
// ignore
|
|
302
|
-
}
|
|
303
|
-
const flushState = flushStates.get(normalizedRepoRoot);
|
|
304
|
-
if (flushState?.timer) {
|
|
305
|
-
clearTimeout(flushState.timer);
|
|
306
|
-
}
|
|
307
|
-
flushStates.delete(normalizedRepoRoot);
|
|
308
|
-
}
|
|
309
|
-
function flushPendingFrgMutations(repoRoot) {
|
|
310
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
311
|
-
const state = getRepoState(normalizedRepoRoot);
|
|
312
|
-
const flushState = getFlushState(normalizedRepoRoot);
|
|
313
|
-
const pendingCount = state.pending.size;
|
|
314
|
-
if (pendingCount === 0) {
|
|
315
|
-
return { flushed: false, reason: "no-pending-mutations", pendingCount };
|
|
316
|
-
}
|
|
317
|
-
if (flushState.timer) {
|
|
318
|
-
clearTimeout(flushState.timer);
|
|
319
|
-
flushState.timer = null;
|
|
320
|
-
}
|
|
321
|
-
if (flushState.inFlight) {
|
|
322
|
-
return { flushed: false, reason: "flush-in-flight", pendingCount };
|
|
323
|
-
}
|
|
324
|
-
flushState.inFlight = true;
|
|
325
|
-
try {
|
|
326
|
-
maybeBuildFrgIndexForRepo(normalizedRepoRoot);
|
|
327
|
-
// Targeted update: pass only changed/deleted files instead of full directory walk.
|
|
328
|
-
// O(changed_files) instead of O(all_files).
|
|
329
|
-
const pending = [...state.pending.values()];
|
|
330
|
-
const targetChanged = pending.filter((r) => r.operation === "write").map((r) => r.path);
|
|
331
|
-
const targetDeleted = pending.filter((r) => r.operation === "delete").map((r) => r.path);
|
|
332
|
-
const result = targetChanged.length > 0 || targetDeleted.length > 0
|
|
333
|
-
? (0, fastripgrep_1.frg)({ command: "update", path: normalizedRepoRoot, targetChanged, targetDeleted })
|
|
334
|
-
: (0, fastripgrep_1.frg)({ command: "update", path: normalizedRepoRoot });
|
|
335
|
-
state.pending.clear();
|
|
336
|
-
rewriteWal(normalizedRepoRoot);
|
|
337
|
-
flushState.lastFlushAt = Date.now();
|
|
338
|
-
flushState.lastError = undefined;
|
|
339
|
-
flushState.retryCount = 0;
|
|
340
|
-
flushState.retryDelayMs = undefined;
|
|
341
|
-
return { flushed: true, pendingCount, result };
|
|
342
|
-
}
|
|
343
|
-
catch (error) {
|
|
344
|
-
flushState.lastError = error instanceof Error ? error.message : String(error);
|
|
345
|
-
flushState.retryCount += 1;
|
|
346
|
-
flushState.retryDelayMs = Math.min((flushState.retryDelayMs ?? exports.DEFAULT_BACKGROUND_FRG_FLUSH_DELAY_MS) * 2, exports.BACKGROUND_FRG_MAX_FLUSH_DELAY_MS);
|
|
347
|
-
return { flushed: false, reason: "flush-failed", pendingCount };
|
|
348
|
-
}
|
|
349
|
-
finally {
|
|
350
|
-
flushState.inFlight = false;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
function maybeBuildFrgIndexForRepo(repoRoot) {
|
|
354
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
355
|
-
const frgDir = nodePath.join(normalizedRepoRoot, ".frg");
|
|
356
|
-
if (fsSync.existsSync(frgDir))
|
|
357
|
-
return;
|
|
358
|
-
try {
|
|
359
|
-
(0, fastripgrep_1.frg)({ command: "init", path: normalizedRepoRoot });
|
|
360
|
-
}
|
|
361
|
-
catch {
|
|
362
|
-
// best effort; search may still fall back to noIndex if init fails
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
function scheduleBackgroundFrgFlush(repoRoot, delayMs = exports.DEFAULT_BACKGROUND_FRG_FLUSH_DELAY_MS) {
|
|
366
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
367
|
-
const state = getRepoState(normalizedRepoRoot);
|
|
368
|
-
if (state.pending.size === 0) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const flushState = getFlushState(normalizedRepoRoot);
|
|
372
|
-
flushState.lastScheduledAt = Date.now();
|
|
373
|
-
if (flushState.inFlight) {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
if (flushState.timer) {
|
|
377
|
-
clearTimeout(flushState.timer);
|
|
378
|
-
}
|
|
379
|
-
const effectiveDelay = flushState.retryDelayMs ?? delayMs;
|
|
380
|
-
flushState.timer = setTimeout(() => {
|
|
381
|
-
flushState.timer = null;
|
|
382
|
-
const result = flushPendingFrgMutations(normalizedRepoRoot);
|
|
383
|
-
if (!result.flushed && result.reason === "flush-failed" && result.pendingCount > 0) {
|
|
384
|
-
scheduleBackgroundFrgFlush(normalizedRepoRoot, flushState.retryDelayMs ?? delayMs);
|
|
385
|
-
}
|
|
386
|
-
}, effectiveDelay);
|
|
387
|
-
if (typeof flushState.timer.unref === "function") {
|
|
388
|
-
flushState.timer.unref();
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
function shouldForceSynchronousFrgFlush(repoRoot) {
|
|
392
|
-
const pendingCount = getPendingFrgMutations(repoRoot).length;
|
|
393
|
-
const pendingBytes = getPendingFrgMutationBytes(repoRoot);
|
|
394
|
-
return (pendingCount >= exports.MAX_PENDING_MUTATIONS_BEFORE_SYNC_FLUSH ||
|
|
395
|
-
pendingBytes >= exports.MAX_PENDING_MUTATION_BYTES_BEFORE_SYNC_FLUSH);
|
|
396
|
-
}
|
|
397
|
-
function getFrgFlushStatus(repoRoot) {
|
|
398
|
-
const flushState = getFlushState(repoRoot);
|
|
399
|
-
return {
|
|
400
|
-
inFlight: flushState.inFlight,
|
|
401
|
-
scheduled: Boolean(flushState.timer),
|
|
402
|
-
lastScheduledAt: flushState.lastScheduledAt,
|
|
403
|
-
lastFlushAt: flushState.lastFlushAt,
|
|
404
|
-
lastError: flushState.lastError,
|
|
405
|
-
retryCount: flushState.retryCount,
|
|
406
|
-
retryDelayMs: flushState.retryDelayMs,
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
function getGitDirtyStatus(repoRoot) {
|
|
410
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
411
|
-
const headCommit = runGit(normalizedRepoRoot, ["rev-parse", "HEAD"]) ?? undefined;
|
|
412
|
-
const headTree = runGit(normalizedRepoRoot, ["rev-parse", "HEAD^{tree}"]) ?? undefined;
|
|
413
|
-
const tracked = [];
|
|
414
|
-
const trackedOutput = runGit(normalizedRepoRoot, ["diff", "--name-status", "-z", "HEAD", "--"]);
|
|
415
|
-
if (trackedOutput) {
|
|
416
|
-
const tokens = trackedOutput.split("\0").filter(Boolean);
|
|
417
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
418
|
-
const status = tokens[i] ?? "";
|
|
419
|
-
if (status.startsWith("R")) {
|
|
420
|
-
const oldPath = tokens[++i];
|
|
421
|
-
const newPath = tokens[++i];
|
|
422
|
-
if (oldPath)
|
|
423
|
-
tracked.push({
|
|
424
|
-
path: normalizePath(nodePath.join(normalizedRepoRoot, oldPath)),
|
|
425
|
-
operation: "delete",
|
|
426
|
-
});
|
|
427
|
-
if (newPath)
|
|
428
|
-
tracked.push({
|
|
429
|
-
path: normalizePath(nodePath.join(normalizedRepoRoot, newPath)),
|
|
430
|
-
operation: "write",
|
|
431
|
-
});
|
|
432
|
-
continue;
|
|
433
|
-
}
|
|
434
|
-
const filePath = tokens[++i];
|
|
435
|
-
if (!filePath)
|
|
436
|
-
continue;
|
|
437
|
-
tracked.push({
|
|
438
|
-
path: normalizePath(nodePath.join(normalizedRepoRoot, filePath)),
|
|
439
|
-
operation: status.startsWith("D") ? "delete" : "write",
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
const untracked = [];
|
|
444
|
-
const untrackedOutput = runGit(normalizedRepoRoot, [
|
|
445
|
-
"ls-files",
|
|
446
|
-
"-o",
|
|
447
|
-
"--exclude-standard",
|
|
448
|
-
"-z",
|
|
449
|
-
]);
|
|
450
|
-
if (untrackedOutput) {
|
|
451
|
-
for (const token of untrackedOutput.split("\0").filter(Boolean)) {
|
|
452
|
-
untracked.push(normalizePath(nodePath.join(normalizedRepoRoot, token)));
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return { headCommit, headTree, tracked, untracked };
|
|
456
|
-
}
|
|
457
|
-
function reconcileGitDirtyMutations(repoRoot) {
|
|
458
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
459
|
-
const status = getGitDirtyStatus(normalizedRepoRoot);
|
|
460
|
-
const state = getRepoState(normalizedRepoRoot);
|
|
461
|
-
let changed = false;
|
|
462
|
-
for (const entry of status.tracked) {
|
|
463
|
-
const existing = state.pending.get(entry.path);
|
|
464
|
-
if (!existing || existing.operation !== entry.operation) {
|
|
465
|
-
setMutationRecordForRepo(normalizedRepoRoot, entry.path, entry.operation, undefined, {
|
|
466
|
-
persistWal: false,
|
|
467
|
-
scheduleFlush: false,
|
|
468
|
-
});
|
|
469
|
-
changed = true;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
for (const filePath of status.untracked) {
|
|
473
|
-
const existing = state.pending.get(filePath);
|
|
474
|
-
if (!existing || existing.operation !== "write") {
|
|
475
|
-
setMutationRecordForRepo(normalizedRepoRoot, filePath, "write", undefined, {
|
|
476
|
-
persistWal: false,
|
|
477
|
-
scheduleFlush: false,
|
|
478
|
-
});
|
|
479
|
-
changed = true;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
if (changed) {
|
|
483
|
-
rewriteWal(normalizedRepoRoot);
|
|
484
|
-
scheduleBackgroundFrgFlush(normalizedRepoRoot);
|
|
485
|
-
}
|
|
486
|
-
return status;
|
|
487
|
-
}
|
|
488
|
-
function getFrgFreshnessSnapshot(repoRoot, indexed) {
|
|
489
|
-
const normalizedRepoRoot = normalizePath(repoRoot);
|
|
490
|
-
const gitStatus = getGitDirtyStatus(normalizedRepoRoot);
|
|
491
|
-
const flush = getFrgFlushStatus(normalizedRepoRoot);
|
|
492
|
-
const sessionPendingCount = getPendingFrgMutations(normalizedRepoRoot).length;
|
|
493
|
-
const sessionPendingBytes = getPendingFrgMutationBytes(normalizedRepoRoot);
|
|
494
|
-
let freshnessState = "fresh";
|
|
495
|
-
if (!indexed) {
|
|
496
|
-
freshnessState = "missing";
|
|
497
|
-
}
|
|
498
|
-
else if (flush.inFlight) {
|
|
499
|
-
freshnessState = "syncing";
|
|
500
|
-
}
|
|
501
|
-
else if (flush.scheduled) {
|
|
502
|
-
freshnessState = "sync-scheduled";
|
|
503
|
-
}
|
|
504
|
-
else if ((indexed.tree_hash ?? null) &&
|
|
505
|
-
gitStatus.headTree &&
|
|
506
|
-
indexed.tree_hash !== gitStatus.headTree) {
|
|
507
|
-
freshnessState = "head-mismatch";
|
|
508
|
-
}
|
|
509
|
-
else if (sessionPendingCount > 0) {
|
|
510
|
-
freshnessState = "session-dirty";
|
|
511
|
-
}
|
|
512
|
-
else if (gitStatus.tracked.length > 0 || gitStatus.untracked.length > 0) {
|
|
513
|
-
freshnessState = "overlay-dirty";
|
|
514
|
-
}
|
|
515
|
-
else if ((indexed.age_seconds ?? 0) > 86400) {
|
|
516
|
-
freshnessState = "stale";
|
|
517
|
-
}
|
|
518
|
-
return {
|
|
519
|
-
headCommit: gitStatus.headCommit,
|
|
520
|
-
headTree: gitStatus.headTree,
|
|
521
|
-
dirtyTrackedCount: gitStatus.tracked.length,
|
|
522
|
-
dirtyUntrackedCount: gitStatus.untracked.length,
|
|
523
|
-
sessionPendingCount,
|
|
524
|
-
sessionPendingBytes,
|
|
525
|
-
flush,
|
|
526
|
-
freshnessState,
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
async function searchPendingFrgMutations(repoRoot, options) {
|
|
530
|
-
const pending = getPendingFrgMutations(repoRoot);
|
|
531
|
-
if (pending.length === 0) {
|
|
532
|
-
return null;
|
|
533
|
-
}
|
|
534
|
-
const regex = compilePattern(options);
|
|
535
|
-
const fileSet = new Set();
|
|
536
|
-
const counts = new Map();
|
|
537
|
-
const matches = [];
|
|
538
|
-
let matched = false;
|
|
539
|
-
for (const record of pending) {
|
|
540
|
-
if (record.operation === "delete") {
|
|
541
|
-
continue;
|
|
542
|
-
}
|
|
543
|
-
const relativePath = relativeToRepo(repoRoot, record.path);
|
|
544
|
-
if (!pathMatchesFilters(relativePath, options)) {
|
|
545
|
-
continue;
|
|
546
|
-
}
|
|
547
|
-
let content;
|
|
548
|
-
if (typeof record.content === "string") {
|
|
549
|
-
content = record.content;
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
let raw;
|
|
553
|
-
try {
|
|
554
|
-
raw = await fs.readFile(record.path);
|
|
555
|
-
}
|
|
556
|
-
catch {
|
|
557
|
-
continue;
|
|
558
|
-
}
|
|
559
|
-
if (isBinaryBuffer(raw)) {
|
|
560
|
-
continue;
|
|
561
|
-
}
|
|
562
|
-
content = raw.toString("utf8");
|
|
563
|
-
}
|
|
564
|
-
const lines = content.split(/\r?\n/);
|
|
565
|
-
let fileMatchCount = 0;
|
|
566
|
-
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
567
|
-
const line = lines[lineIndex] ?? "";
|
|
568
|
-
regex.lastIndex = 0;
|
|
569
|
-
let lineMatched = false;
|
|
570
|
-
let execMatch;
|
|
571
|
-
while ((execMatch = regex.exec(line)) !== null) {
|
|
572
|
-
matched = true;
|
|
573
|
-
lineMatched = true;
|
|
574
|
-
fileMatchCount += 1;
|
|
575
|
-
if (!options.filesOnly && !options.count && !options.quiet) {
|
|
576
|
-
const context = buildContextLines(lines, lineIndex, options.context ?? 0);
|
|
577
|
-
matches.push({
|
|
578
|
-
file: relativePath,
|
|
579
|
-
line: lineIndex + 1,
|
|
580
|
-
content: line,
|
|
581
|
-
match_start: execMatch.index,
|
|
582
|
-
match_end: execMatch.index + execMatch[0].length,
|
|
583
|
-
context_before: context.before,
|
|
584
|
-
context_after: context.after,
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
if ((options.maxCount ?? Number.POSITIVE_INFINITY) <= fileMatchCount) {
|
|
588
|
-
break;
|
|
589
|
-
}
|
|
590
|
-
if (execMatch[0].length === 0) {
|
|
591
|
-
regex.lastIndex += 1;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
if (options.filesOnly && lineMatched) {
|
|
595
|
-
fileSet.add(relativePath);
|
|
596
|
-
break;
|
|
597
|
-
}
|
|
598
|
-
if ((options.maxCount ?? Number.POSITIVE_INFINITY) <= fileMatchCount) {
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
if (options.count && fileMatchCount > 0) {
|
|
603
|
-
counts.set(relativePath, fileMatchCount);
|
|
604
|
-
}
|
|
605
|
-
if (options.filesOnly && fileMatchCount > 0) {
|
|
606
|
-
fileSet.add(relativePath);
|
|
607
|
-
}
|
|
608
|
-
if (options.quiet && fileMatchCount > 0) {
|
|
609
|
-
return { mode: "quiet", matched: true };
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
if (options.quiet) {
|
|
613
|
-
return { mode: "quiet", matched };
|
|
614
|
-
}
|
|
615
|
-
if (options.filesOnly) {
|
|
616
|
-
return { mode: "files", files: [...fileSet].sort() };
|
|
617
|
-
}
|
|
618
|
-
if (options.count) {
|
|
619
|
-
return {
|
|
620
|
-
mode: "counts",
|
|
621
|
-
counts: [...counts.entries()]
|
|
622
|
-
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
623
|
-
.map(([file, count]) => ({ file, count })),
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
return { mode: "matches", matches };
|
|
627
|
-
}
|