flowseeker 0.1.7
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/CHANGELOG.md +111 -0
- package/COMPATIBILITY.md +281 -0
- package/LICENSE +21 -0
- package/README.md +375 -0
- package/dist/adapters/frameworkEdges.js +586 -0
- package/dist/agent/approvalPolicy.js +81 -0
- package/dist/agent/commandRunner.js +166 -0
- package/dist/agent/flowCommandRunner.js +124 -0
- package/dist/agent/mcpToolRunner.js +167 -0
- package/dist/auth/githubAuth.js +71 -0
- package/dist/auth/modelList.js +127 -0
- package/dist/auth/oauthHandler.js +377 -0
- package/dist/chat/nativeChatParticipant.js +616 -0
- package/dist/cli/mcpServer.js +383 -0
- package/dist/cli/runEvaluation.js +789 -0
- package/dist/cli/runReplay.js +481 -0
- package/dist/commands/checkHostCompatibility.js +149 -0
- package/dist/commands/copyAgentPrompt.js +52 -0
- package/dist/commands/copyContext.js +54 -0
- package/dist/commands/explainSelectionRelevance.js +57 -0
- package/dist/commands/findRelevantContext.js +127 -0
- package/dist/commands/openEvidence.js +49 -0
- package/dist/commands/openMcpConfig.js +81 -0
- package/dist/commands/openRelatedTests.js +54 -0
- package/dist/commands/rebuildIndex.js +45 -0
- package/dist/commands/runEvaluationSuite.js +323 -0
- package/dist/commands/runReplaySuite.js +228 -0
- package/dist/config/defaultConfig.js +72 -0
- package/dist/config/loadConfig.js +84 -0
- package/dist/config/loadConfigFromPath.js +60 -0
- package/dist/extension.js +513 -0
- package/dist/gateway/agentPrompts.js +176 -0
- package/dist/gateway/aiGateway.js +1255 -0
- package/dist/gateway/aiProviders.js +901 -0
- package/dist/gateway/contextExpansion.js +331 -0
- package/dist/gateway/editProposalStore.js +238 -0
- package/dist/gateway/planProposalStore.js +28 -0
- package/dist/index/cacheStore.js +51 -0
- package/dist/index/chunker.js +45 -0
- package/dist/index/dependencyExtractor.js +107 -0
- package/dist/index/fileDiscovery.js +177 -0
- package/dist/index/structuredExtractor.js +256 -0
- package/dist/index/workspaceIndex.js +518 -0
- package/dist/mcp/mcpConfig.js +154 -0
- package/dist/mcp/mcpProvider.js +109 -0
- package/dist/mcp/mcpTools.js +215 -0
- package/dist/pipeline/agentPrompt.js +79 -0
- package/dist/pipeline/agentPromptHeadless.js +85 -0
- package/dist/pipeline/contextBlueprint.js +346 -0
- package/dist/pipeline/contextPack.js +80 -0
- package/dist/pipeline/diffPreview.js +79 -0
- package/dist/pipeline/evaluationMetrics.js +154 -0
- package/dist/pipeline/evidenceGraph.js +389 -0
- package/dist/pipeline/feedback.js +215 -0
- package/dist/pipeline/fileGroups.js +84 -0
- package/dist/pipeline/fileScanner.js +866 -0
- package/dist/pipeline/nodeScan.js +219 -0
- package/dist/pipeline/ranker.js +563 -0
- package/dist/pipeline/responseLanguage.js +39 -0
- package/dist/pipeline/retrievalPlan.js +163 -0
- package/dist/pipeline/runHeadless.js +54 -0
- package/dist/pipeline/runPipeline.js +114 -0
- package/dist/pipeline/solvePacket.js +382 -0
- package/dist/pipeline/subsystem.js +257 -0
- package/dist/pipeline/taskUnderstanding.js +453 -0
- package/dist/pipeline/tokenSavings.js +146 -0
- package/dist/pipeline/universalScan.js +216 -0
- package/dist/pipeline/verifyAfterApply.js +233 -0
- package/dist/runtime/capabilities.js +71 -0
- package/dist/runtime/hostDetect.js +98 -0
- package/dist/runtime/hostTier.js +68 -0
- package/dist/runtime/statusBar.js +80 -0
- package/dist/skills/skillRegistry.js +208 -0
- package/dist/types.js +3 -0
- package/dist/ui/chatViewProvider.js +3899 -0
- package/dist/ui/resultTreeProvider.js +174 -0
- package/dist/usage/quotaTracker.js +358 -0
- package/dist/utils/async.js +30 -0
- package/dist/utils/logger.js +64 -0
- package/dist/utils/text.js +364 -0
- package/dist/utils/updateChecker.js +140 -0
- package/package.json +561 -0
|
@@ -0,0 +1,364 @@
|
|
|
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.normalizeText = normalizeText;
|
|
37
|
+
exports.splitIdentifier = splitIdentifier;
|
|
38
|
+
exports.semanticPhraseTerms = semanticPhraseTerms;
|
|
39
|
+
exports.uniq = uniq;
|
|
40
|
+
exports.tokenEstimate = tokenEstimate;
|
|
41
|
+
exports.fastTokenEstimate = fastTokenEstimate;
|
|
42
|
+
exports.countTextTokens = countTextTokens;
|
|
43
|
+
exports.languageFromPath = languageFromPath;
|
|
44
|
+
exports.hasGlobMagic = hasGlobMagic;
|
|
45
|
+
exports.toWorkspaceGlob = toWorkspaceGlob;
|
|
46
|
+
exports.toExcludeGlob = toExcludeGlob;
|
|
47
|
+
exports.snippetFromLines = snippetFromLines;
|
|
48
|
+
exports.isLikelyTextPath = isLikelyTextPath;
|
|
49
|
+
exports.clamp = clamp;
|
|
50
|
+
const path = __importStar(require("path"));
|
|
51
|
+
const { Tiktoken } = require("js-tiktoken/lite");
|
|
52
|
+
const cl100kBase = require("js-tiktoken/ranks/cl100k_base");
|
|
53
|
+
const stopWords = new Set([
|
|
54
|
+
"a",
|
|
55
|
+
"an",
|
|
56
|
+
"and",
|
|
57
|
+
"are",
|
|
58
|
+
"as",
|
|
59
|
+
"at",
|
|
60
|
+
"be",
|
|
61
|
+
"by",
|
|
62
|
+
"for",
|
|
63
|
+
"from",
|
|
64
|
+
"how",
|
|
65
|
+
"in",
|
|
66
|
+
"is",
|
|
67
|
+
"it",
|
|
68
|
+
"of",
|
|
69
|
+
"on",
|
|
70
|
+
"or",
|
|
71
|
+
"that",
|
|
72
|
+
"the",
|
|
73
|
+
"this",
|
|
74
|
+
"to",
|
|
75
|
+
"with",
|
|
76
|
+
"và",
|
|
77
|
+
"la",
|
|
78
|
+
"là",
|
|
79
|
+
"cua",
|
|
80
|
+
"của",
|
|
81
|
+
"cho",
|
|
82
|
+
"trong",
|
|
83
|
+
"ngoài",
|
|
84
|
+
"khi",
|
|
85
|
+
"thi",
|
|
86
|
+
"thì",
|
|
87
|
+
"một",
|
|
88
|
+
"mot",
|
|
89
|
+
"những",
|
|
90
|
+
"nhung",
|
|
91
|
+
"các",
|
|
92
|
+
"cac",
|
|
93
|
+
"được",
|
|
94
|
+
"duoc",
|
|
95
|
+
"không",
|
|
96
|
+
"khong",
|
|
97
|
+
"này",
|
|
98
|
+
"nay",
|
|
99
|
+
"đó",
|
|
100
|
+
"do",
|
|
101
|
+
"sua",
|
|
102
|
+
"sửa",
|
|
103
|
+
"thay",
|
|
104
|
+
"doi",
|
|
105
|
+
"đổi",
|
|
106
|
+
"cach",
|
|
107
|
+
"cách",
|
|
108
|
+
"tu",
|
|
109
|
+
"từ",
|
|
110
|
+
"lan",
|
|
111
|
+
"lần",
|
|
112
|
+
"dau",
|
|
113
|
+
"đầu",
|
|
114
|
+
"sang",
|
|
115
|
+
"sau",
|
|
116
|
+
"truoc",
|
|
117
|
+
"trước",
|
|
118
|
+
"thanh",
|
|
119
|
+
"thành",
|
|
120
|
+
"cong",
|
|
121
|
+
"công",
|
|
122
|
+
"moi",
|
|
123
|
+
"mới",
|
|
124
|
+
"vi",
|
|
125
|
+
"vì",
|
|
126
|
+
"bang",
|
|
127
|
+
"bằng",
|
|
128
|
+
"dua",
|
|
129
|
+
"theo",
|
|
130
|
+
"toi",
|
|
131
|
+
"minh",
|
|
132
|
+
"ban",
|
|
133
|
+
"muon",
|
|
134
|
+
"can",
|
|
135
|
+
"hay",
|
|
136
|
+
"giup",
|
|
137
|
+
"chuyen",
|
|
138
|
+
"dong",
|
|
139
|
+
"khu",
|
|
140
|
+
"vuc",
|
|
141
|
+
"chi",
|
|
142
|
+
"nhan",
|
|
143
|
+
"thoi",
|
|
144
|
+
"viet",
|
|
145
|
+
"nam"
|
|
146
|
+
]);
|
|
147
|
+
const semanticPhraseRules = [
|
|
148
|
+
{ pattern: /\btu dong\b|\bautomatic\b|\bauto\b/, terms: ["automatic", "auto"] },
|
|
149
|
+
{ pattern: /\btrinh duyet\b|\bbrowser\b/, terms: ["browser", "client", "navigator"] },
|
|
150
|
+
{ pattern: /\bmui gio\b|\btimezone\b|\btime zone\b/, terms: ["timezone", "tz", "offset"] },
|
|
151
|
+
{ pattern: /\bthoi gian\b|\btimestamp\b/, terms: ["timestamp", "time", "date", "datetime"] },
|
|
152
|
+
{ pattern: /(?=.*\b(timestamp|time|date|datetime|thoi gian)\b)(?=.*\b(browser|client|navigator|trinh duyet)\b)/, terms: ["timezone", "tz", "offset", "locale"] },
|
|
153
|
+
{ pattern: /\bkhu vuc\b|\bregion\b|\barea\b/, terms: ["region", "area", "location"] },
|
|
154
|
+
{ pattern: /\bviet nam\b|\bvietnam\b/, terms: ["vietnam", "vn"] },
|
|
155
|
+
{ pattern: /\bchi nhan\b|\bchi chap nhan\b|\bonly accept\b/, terms: ["accept", "allow", "only"] },
|
|
156
|
+
{ pattern: /\blocating?\b|\blocate\b|\bgeo\b|\bgeoip\b|\bgeolocation\b/, terms: ["locate", "location", "geolocation", "geoip"] },
|
|
157
|
+
{ pattern: /\bdia chi ip\b|\bip address\b/, terms: ["ip"] }
|
|
158
|
+
];
|
|
159
|
+
let encoder;
|
|
160
|
+
function normalizeText(input) {
|
|
161
|
+
return repairCommonMojibake(input)
|
|
162
|
+
.normalize("NFD")
|
|
163
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
164
|
+
.replace(/đ|\u0111/g, "d")
|
|
165
|
+
.replace(/Đ|\u0110/g, "D")
|
|
166
|
+
.toLowerCase();
|
|
167
|
+
}
|
|
168
|
+
function repairCommonMojibake(input) {
|
|
169
|
+
if (!/(?:Ã.|Â.|Ä.|Æ.|á[º»])/.test(input)) {
|
|
170
|
+
return input;
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
const repaired = Buffer.from(input, "latin1").toString("utf8");
|
|
174
|
+
return mojibakeNoiseScore(repaired) < mojibakeNoiseScore(input) ? repaired : input;
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return input;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function mojibakeNoiseScore(input) {
|
|
181
|
+
return (input.match(/(?:Ã.|Â.|Ä.|Æ.|á[º»]|�)/g) ?? []).length;
|
|
182
|
+
}
|
|
183
|
+
function splitIdentifier(input) {
|
|
184
|
+
const spaced = input
|
|
185
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
186
|
+
.replace(/[_-]+/g, " ");
|
|
187
|
+
const tokens = normalizeText(spaced)
|
|
188
|
+
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
189
|
+
.replace(/[^a-z0-9]+/gi, " ")
|
|
190
|
+
.split(/\s+/)
|
|
191
|
+
.map((part) => part.trim())
|
|
192
|
+
.filter((part) => part.length > 1 && !stopWords.has(part));
|
|
193
|
+
return uniq([...suppressPhraseComponents(input, tokens), ...semanticPhraseTerms(input)]);
|
|
194
|
+
}
|
|
195
|
+
function semanticPhraseTerms(input) {
|
|
196
|
+
const normalized = normalizeText(input).replace(/[^a-z0-9]+/g, " ");
|
|
197
|
+
return uniq(semanticPhraseRules.flatMap((rule) => (rule.pattern.test(normalized) ? rule.terms : [])));
|
|
198
|
+
}
|
|
199
|
+
function suppressPhraseComponents(input, tokens) {
|
|
200
|
+
const normalized = normalizeText(input).replace(/[^a-z0-9]+/g, " ");
|
|
201
|
+
const suppressed = new Set();
|
|
202
|
+
if (/\btrinh duyet\b/.test(normalized)) {
|
|
203
|
+
suppressed.add("trinh");
|
|
204
|
+
suppressed.add("duyet");
|
|
205
|
+
}
|
|
206
|
+
if (/\btu dong\b/.test(normalized)) {
|
|
207
|
+
suppressed.add("tu");
|
|
208
|
+
suppressed.add("dong");
|
|
209
|
+
}
|
|
210
|
+
if (/\bkhu vuc\b/.test(normalized)) {
|
|
211
|
+
suppressed.add("khu");
|
|
212
|
+
suppressed.add("vuc");
|
|
213
|
+
}
|
|
214
|
+
if (/\bviet nam\b/.test(normalized)) {
|
|
215
|
+
suppressed.add("viet");
|
|
216
|
+
suppressed.add("nam");
|
|
217
|
+
}
|
|
218
|
+
return tokens.filter((token) => !suppressed.has(token));
|
|
219
|
+
}
|
|
220
|
+
function uniq(items) {
|
|
221
|
+
return Array.from(new Set(items));
|
|
222
|
+
}
|
|
223
|
+
function tokenEstimate(text) {
|
|
224
|
+
return countTextTokens(text).tokens;
|
|
225
|
+
}
|
|
226
|
+
function fastTokenEstimate(text) {
|
|
227
|
+
if (!text.trim()) {
|
|
228
|
+
return 0;
|
|
229
|
+
}
|
|
230
|
+
return Math.ceil(text.length / 4);
|
|
231
|
+
}
|
|
232
|
+
function countTextTokens(text) {
|
|
233
|
+
if (!text.trim()) {
|
|
234
|
+
return { tokens: 0, method: "local_bpe", tokenizer: "cl100k_base" };
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
encoder ?? (encoder = new Tiktoken(cl100kBase));
|
|
238
|
+
return {
|
|
239
|
+
tokens: encoder.encode(text).length,
|
|
240
|
+
method: "local_bpe",
|
|
241
|
+
tokenizer: "cl100k_base"
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
return {
|
|
246
|
+
tokens: Math.ceil(text.length / 4),
|
|
247
|
+
method: "heuristic",
|
|
248
|
+
tokenizer: "chars_per_4"
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function languageFromPath(filePath) {
|
|
253
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
254
|
+
const map = {
|
|
255
|
+
".ts": "typescript",
|
|
256
|
+
".tsx": "typescriptreact",
|
|
257
|
+
".js": "javascript",
|
|
258
|
+
".jsx": "javascriptreact",
|
|
259
|
+
".py": "python",
|
|
260
|
+
".php": "php",
|
|
261
|
+
".java": "java",
|
|
262
|
+
".kt": "kotlin",
|
|
263
|
+
".kts": "kotlin",
|
|
264
|
+
".go": "go",
|
|
265
|
+
".cs": "csharp",
|
|
266
|
+
".rb": "ruby",
|
|
267
|
+
".rs": "rust",
|
|
268
|
+
".cpp": "cpp",
|
|
269
|
+
".cc": "cpp",
|
|
270
|
+
".c": "c",
|
|
271
|
+
".h": "c",
|
|
272
|
+
".swift": "swift",
|
|
273
|
+
".html": "html",
|
|
274
|
+
".vue": "vue",
|
|
275
|
+
".svelte": "svelte",
|
|
276
|
+
".md": "markdown",
|
|
277
|
+
".json": "json",
|
|
278
|
+
".yaml": "yaml",
|
|
279
|
+
".yml": "yaml",
|
|
280
|
+
".toml": "toml",
|
|
281
|
+
".xml": "xml",
|
|
282
|
+
".sql": "sql",
|
|
283
|
+
".graphql": "graphql",
|
|
284
|
+
".gql": "graphql"
|
|
285
|
+
};
|
|
286
|
+
return map[ext];
|
|
287
|
+
}
|
|
288
|
+
function hasGlobMagic(value) {
|
|
289
|
+
return /[*?{[\]]/.test(value);
|
|
290
|
+
}
|
|
291
|
+
function toWorkspaceGlob(value) {
|
|
292
|
+
const normalized = value.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/$/, "");
|
|
293
|
+
if (!normalized || normalized === ".") {
|
|
294
|
+
return "**/*";
|
|
295
|
+
}
|
|
296
|
+
if (hasGlobMagic(normalized)) {
|
|
297
|
+
const basename = normalized.split("/").at(-1) ?? normalized;
|
|
298
|
+
if (!normalized.includes("**") && !basename.includes(".")) {
|
|
299
|
+
return `${normalized}/**/*`;
|
|
300
|
+
}
|
|
301
|
+
return normalized;
|
|
302
|
+
}
|
|
303
|
+
return `${normalized}/**/*`;
|
|
304
|
+
}
|
|
305
|
+
function toExcludeGlob(values) {
|
|
306
|
+
const parts = values
|
|
307
|
+
.map((value) => value.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/$/, ""))
|
|
308
|
+
.filter(Boolean)
|
|
309
|
+
.map((value) => (hasGlobMagic(value) ? value : `**/${value}/**`));
|
|
310
|
+
return parts.length > 0 ? `{${parts.join(",")}}` : "";
|
|
311
|
+
}
|
|
312
|
+
function snippetFromLines(lines, startLine, endLine, maxLineChars = 1200) {
|
|
313
|
+
const start = Math.max(1, startLine);
|
|
314
|
+
const end = Math.min(lines.length, endLine);
|
|
315
|
+
const width = String(end).length;
|
|
316
|
+
return lines
|
|
317
|
+
.slice(start - 1, end)
|
|
318
|
+
.map((line, index) => `${String(start + index).padStart(width, " ")}: ${truncateLine(line, maxLineChars)}`)
|
|
319
|
+
.join("\n");
|
|
320
|
+
}
|
|
321
|
+
function truncateLine(line, maxLineChars) {
|
|
322
|
+
if (line.length <= maxLineChars) {
|
|
323
|
+
return line;
|
|
324
|
+
}
|
|
325
|
+
return `${line.slice(0, maxLineChars)} ... [truncated ${line.length - maxLineChars} chars]`;
|
|
326
|
+
}
|
|
327
|
+
function isLikelyTextPath(filePath) {
|
|
328
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
329
|
+
const denied = new Set([
|
|
330
|
+
".png",
|
|
331
|
+
".jpg",
|
|
332
|
+
".jpeg",
|
|
333
|
+
".gif",
|
|
334
|
+
".webp",
|
|
335
|
+
".ico",
|
|
336
|
+
".pdf",
|
|
337
|
+
".zip",
|
|
338
|
+
".gz",
|
|
339
|
+
".tar",
|
|
340
|
+
".rar",
|
|
341
|
+
".7z",
|
|
342
|
+
".exe",
|
|
343
|
+
".dll",
|
|
344
|
+
".so",
|
|
345
|
+
".dylib",
|
|
346
|
+
".class",
|
|
347
|
+
".jar",
|
|
348
|
+
".wasm",
|
|
349
|
+
".bin",
|
|
350
|
+
".db",
|
|
351
|
+
".sqlite",
|
|
352
|
+
".sqlite3",
|
|
353
|
+
".map",
|
|
354
|
+
".log",
|
|
355
|
+
".csv",
|
|
356
|
+
".tsv",
|
|
357
|
+
".lock"
|
|
358
|
+
]);
|
|
359
|
+
return !denied.has(ext);
|
|
360
|
+
}
|
|
361
|
+
function clamp(value, min, max) {
|
|
362
|
+
return Math.max(min, Math.min(max, value));
|
|
363
|
+
}
|
|
364
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1,140 @@
|
|
|
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.checkForExtensionUpdate = checkForExtensionUpdate;
|
|
37
|
+
exports.checkForPackageUpdate = checkForPackageUpdate;
|
|
38
|
+
exports.fetchLatestPackageVersion = fetchLatestPackageVersion;
|
|
39
|
+
exports.compareSemver = compareSemver;
|
|
40
|
+
const PACKAGE_NAME = "flowseeker";
|
|
41
|
+
const NPM_LATEST_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
42
|
+
const NPM_PACKAGE_URL = `https://www.npmjs.com/package/${PACKAGE_NAME}`;
|
|
43
|
+
const UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
44
|
+
const UPDATE_CHECK_TIMEOUT_MS = 5000;
|
|
45
|
+
const LAST_CHECKED_KEY = "flowseeker.update.lastCheckedAt";
|
|
46
|
+
const DISMISSED_VERSION_KEY = "flowseeker.update.dismissedVersion";
|
|
47
|
+
async function checkForExtensionUpdate(context) {
|
|
48
|
+
const now = Date.now();
|
|
49
|
+
const lastCheckedAt = context.globalState.get(LAST_CHECKED_KEY, 0);
|
|
50
|
+
if (now - lastCheckedAt < UPDATE_CHECK_INTERVAL_MS) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
await context.globalState.update(LAST_CHECKED_KEY, now);
|
|
54
|
+
const currentVersion = String(context.extension.packageJSON?.version ?? "");
|
|
55
|
+
const result = await checkForPackageUpdate(currentVersion);
|
|
56
|
+
if (result.error) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!result.hasUpdate || !result.latestVersion) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const dismissedVersion = context.globalState.get(DISMISSED_VERSION_KEY, "");
|
|
63
|
+
if (dismissedVersion === result.latestVersion) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const vscode = await Promise.resolve().then(() => __importStar(require("vscode")));
|
|
67
|
+
const action = await vscode.window.showInformationMessage(`FlowSeeker ${result.latestVersion} is available. You are using ${result.currentVersion}.`, "View on npm", "Dismiss this version");
|
|
68
|
+
if (action === "View on npm") {
|
|
69
|
+
await vscode.env.openExternal(vscode.Uri.parse(NPM_PACKAGE_URL));
|
|
70
|
+
}
|
|
71
|
+
else if (action === "Dismiss this version") {
|
|
72
|
+
await context.globalState.update(DISMISSED_VERSION_KEY, result.latestVersion);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function checkForPackageUpdate(currentVersion) {
|
|
76
|
+
try {
|
|
77
|
+
const latestVersion = await fetchLatestPackageVersion();
|
|
78
|
+
return {
|
|
79
|
+
currentVersion,
|
|
80
|
+
latestVersion,
|
|
81
|
+
hasUpdate: compareSemver(latestVersion, currentVersion) > 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
86
|
+
return { currentVersion, hasUpdate: false, error: message };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function fetchLatestPackageVersion() {
|
|
90
|
+
const controller = new AbortController();
|
|
91
|
+
const timeout = setTimeout(() => controller.abort(), UPDATE_CHECK_TIMEOUT_MS);
|
|
92
|
+
try {
|
|
93
|
+
const response = await fetch(NPM_LATEST_URL, { signal: controller.signal });
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
throw new Error(`npm registry returned ${response.status}`);
|
|
96
|
+
}
|
|
97
|
+
const body = await response.json();
|
|
98
|
+
if (typeof body.version !== "string" || !body.version.trim()) {
|
|
99
|
+
throw new Error("npm registry response did not include a version");
|
|
100
|
+
}
|
|
101
|
+
return body.version.trim();
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
clearTimeout(timeout);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function compareSemver(left, right) {
|
|
108
|
+
const a = parseSemver(left);
|
|
109
|
+
const b = parseSemver(right);
|
|
110
|
+
if (!a || !b) {
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
for (let i = 0; i < 3; i++) {
|
|
114
|
+
const diff = a.parts[i] - b.parts[i];
|
|
115
|
+
if (diff !== 0) {
|
|
116
|
+
return diff > 0 ? 1 : -1;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (a.prerelease === b.prerelease) {
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
if (!a.prerelease && b.prerelease) {
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
if (a.prerelease && !b.prerelease) {
|
|
126
|
+
return -1;
|
|
127
|
+
}
|
|
128
|
+
return a.prerelease > b.prerelease ? 1 : -1;
|
|
129
|
+
}
|
|
130
|
+
function parseSemver(version) {
|
|
131
|
+
const match = version.trim().replace(/^v/i, "").match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/);
|
|
132
|
+
if (!match) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
parts: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
137
|
+
prerelease: match[4] ?? ""
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=updateChecker.js.map
|