@wrongstack/tools 0.7.7 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin.js +208 -155
- package/dist/builtin.js.map +1 -1
- package/dist/codebase-index/index.js +218 -164
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/index.js +208 -155
- package/dist/index.js.map +1 -1
- package/dist/pack.js +208 -155
- package/dist/pack.js.map +1 -1
- package/package.json +2 -2
package/dist/builtin.js
CHANGED
|
@@ -5,9 +5,9 @@ import { dirname } from 'node:path';
|
|
|
5
5
|
import * as os from 'node:os';
|
|
6
6
|
import * as fs11 from 'node:fs/promises';
|
|
7
7
|
import { stat } from 'node:fs/promises';
|
|
8
|
+
import { createRequire } from 'node:module';
|
|
8
9
|
import * as fs from 'node:fs';
|
|
9
|
-
import { statSync, mkdirSync, writeFileSync
|
|
10
|
-
import { DatabaseSync } from 'node:sqlite';
|
|
10
|
+
import { statSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
11
11
|
import * as ts from 'typescript';
|
|
12
12
|
import * as dns from 'node:dns/promises';
|
|
13
13
|
import * as net from 'node:net';
|
|
@@ -952,12 +952,39 @@ function lspKindToInternalKind(k) {
|
|
|
952
952
|
// src/codebase-index/writer.ts
|
|
953
953
|
var INDEX_DIR = ".codebase-index";
|
|
954
954
|
var DB_FILE = "index.db";
|
|
955
|
+
var warningSilenced = false;
|
|
956
|
+
function silenceSqliteExperimentalWarning() {
|
|
957
|
+
if (warningSilenced) return;
|
|
958
|
+
warningSilenced = true;
|
|
959
|
+
const original = process.emitWarning.bind(process);
|
|
960
|
+
process.emitWarning = ((warning, ...rest) => {
|
|
961
|
+
const msg = typeof warning === "string" ? warning : warning?.message ?? "";
|
|
962
|
+
const name = typeof warning === "string" ? String(rest[0] ?? "") : warning?.name ?? "";
|
|
963
|
+
if (/sqlite/i.test(msg) && /experimental/i.test(`${name} ${msg}`)) return;
|
|
964
|
+
original(warning, ...rest);
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
var DatabaseSyncCtor;
|
|
968
|
+
function loadDatabaseSync() {
|
|
969
|
+
if (DatabaseSyncCtor) return DatabaseSyncCtor;
|
|
970
|
+
silenceSqliteExperimentalWarning();
|
|
971
|
+
try {
|
|
972
|
+
const req = createRequire(import.meta.url);
|
|
973
|
+
DatabaseSyncCtor = req("node:sqlite").DatabaseSync;
|
|
974
|
+
} catch (err) {
|
|
975
|
+
throw new Error(
|
|
976
|
+
`The codebase index needs Node's built-in SQLite (node:sqlite), available since Node 22.5. This runtime doesn't provide it: ${err instanceof Error ? err.message : String(err)}`
|
|
977
|
+
);
|
|
978
|
+
}
|
|
979
|
+
return DatabaseSyncCtor;
|
|
980
|
+
}
|
|
955
981
|
var IndexStore = class {
|
|
956
982
|
constructor(projectRoot) {
|
|
957
983
|
this.projectRoot = projectRoot;
|
|
958
984
|
const dir = path.join(projectRoot, INDEX_DIR);
|
|
959
985
|
fs.mkdirSync(dir, { recursive: true });
|
|
960
|
-
|
|
986
|
+
const Database = loadDatabaseSync();
|
|
987
|
+
this.db = new Database(path.join(dir, DB_FILE));
|
|
961
988
|
this.initSchema();
|
|
962
989
|
}
|
|
963
990
|
projectRoot;
|
|
@@ -1460,6 +1487,7 @@ import (
|
|
|
1460
1487
|
"go/ast"
|
|
1461
1488
|
"go/parser"
|
|
1462
1489
|
"go/token"
|
|
1490
|
+
"io"
|
|
1463
1491
|
"os"
|
|
1464
1492
|
"strings"
|
|
1465
1493
|
)
|
|
@@ -1474,17 +1502,13 @@ type Sym struct {
|
|
|
1474
1502
|
}
|
|
1475
1503
|
|
|
1476
1504
|
func main() {
|
|
1477
|
-
|
|
1478
|
-
fmt.Print("[]")
|
|
1479
|
-
return
|
|
1480
|
-
}
|
|
1481
|
-
src, err := os.ReadFile(os.Args[1])
|
|
1505
|
+
src, err := io.ReadAll(os.Stdin)
|
|
1482
1506
|
if err != nil {
|
|
1483
1507
|
fmt.Print("[]")
|
|
1484
1508
|
return
|
|
1485
1509
|
}
|
|
1486
1510
|
fset := token.NewFileSet()
|
|
1487
|
-
node, err := parser.ParseFile(fset,
|
|
1511
|
+
node, err := parser.ParseFile(fset, "src.go", src, 0)
|
|
1488
1512
|
if err != nil {
|
|
1489
1513
|
fmt.Print("[]")
|
|
1490
1514
|
return
|
|
@@ -1628,7 +1652,7 @@ func formatMethods(fields []*ast.Field) string {
|
|
|
1628
1652
|
return formatFields(fields)
|
|
1629
1653
|
}
|
|
1630
1654
|
|
|
1631
|
-
func formatTypeParams(tp *ast.
|
|
1655
|
+
func formatTypeParams(tp *ast.FieldList) string {
|
|
1632
1656
|
if tp == nil || len(tp.List) == 0 {
|
|
1633
1657
|
return ""
|
|
1634
1658
|
}
|
|
@@ -1671,30 +1695,33 @@ func formatType(t ast.Expr) string {
|
|
|
1671
1695
|
return "chan " + formatType(v.Value)
|
|
1672
1696
|
case *ast.BasicLit:
|
|
1673
1697
|
return v.Value
|
|
1698
|
+
case *ast.IndexExpr:
|
|
1699
|
+
// Generic instantiation with one type arg, e.g. Logger[int].
|
|
1700
|
+
return formatType(v.X) + "[" + formatType(v.Index) + "]"
|
|
1701
|
+
case *ast.IndexListExpr:
|
|
1702
|
+
// Generic instantiation with multiple type args, e.g. Map[K, V].
|
|
1703
|
+
args := make([]string, len(v.Indices))
|
|
1704
|
+
for i, idx := range v.Indices {
|
|
1705
|
+
args[i] = formatType(idx)
|
|
1706
|
+
}
|
|
1707
|
+
return formatType(v.X) + "[" + strings.Join(args, ", ") + "]"
|
|
1674
1708
|
default:
|
|
1675
1709
|
return "?"
|
|
1676
1710
|
}
|
|
1677
1711
|
}
|
|
1678
1712
|
`;
|
|
1679
|
-
function syncGoParse(filePath,
|
|
1680
|
-
const tmpDir = path.join(
|
|
1713
|
+
function syncGoParse(filePath, content, lang) {
|
|
1714
|
+
const tmpDir = path.join(os.tmpdir(), "ws-go-parse");
|
|
1681
1715
|
try {
|
|
1682
1716
|
mkdirSync(tmpDir, { recursive: true });
|
|
1683
1717
|
const scriptPath = path.join(tmpDir, "parse.go");
|
|
1684
1718
|
writeFileSync(scriptPath, GO_PARSE_SCRIPT, "utf8");
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
});
|
|
1692
|
-
} finally {
|
|
1693
|
-
try {
|
|
1694
|
-
unlinkSync(scriptPath);
|
|
1695
|
-
} catch {
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1719
|
+
const stdout = execSync(`go run "${scriptPath}"`, {
|
|
1720
|
+
input: content,
|
|
1721
|
+
timeout: 15e3,
|
|
1722
|
+
encoding: "utf8",
|
|
1723
|
+
windowsHide: true
|
|
1724
|
+
});
|
|
1698
1725
|
if (!stdout.trim()) {
|
|
1699
1726
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1700
1727
|
}
|
|
@@ -1931,7 +1958,11 @@ print(json.dumps([s.to_dict() for s in syms]))
|
|
|
1931
1958
|
`;
|
|
1932
1959
|
function syncPyParse(filePath, lang) {
|
|
1933
1960
|
try {
|
|
1934
|
-
const
|
|
1961
|
+
const tmpDir = path.join(os.tmpdir(), "ws-py-parse");
|
|
1962
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
1963
|
+
const scriptPath = path.join(tmpDir, "parse.py");
|
|
1964
|
+
writeFileSync(scriptPath, PY_PARSE_SCRIPT, "utf8");
|
|
1965
|
+
const stdout = execSync(`python "${scriptPath}" "${filePath}"`, {
|
|
1935
1966
|
timeout: 15e3,
|
|
1936
1967
|
encoding: "utf8",
|
|
1937
1968
|
windowsHide: true
|
|
@@ -1972,7 +2003,10 @@ function checkNativeParser() {
|
|
|
1972
2003
|
execSync("rustc --version", { stdio: "pipe" });
|
|
1973
2004
|
const toolsDir = path.join(process.cwd(), "tools");
|
|
1974
2005
|
try {
|
|
1975
|
-
execSync(
|
|
2006
|
+
execSync(
|
|
2007
|
+
"cargo metadata --no-deps --format-version 1 --manifest-path " + path.join(toolsDir, "Cargo.toml"),
|
|
2008
|
+
{ stdio: "pipe" }
|
|
2009
|
+
);
|
|
1976
2010
|
return true;
|
|
1977
2011
|
} catch {
|
|
1978
2012
|
return false;
|
|
@@ -1986,14 +2020,18 @@ function tryNativeParse(file, content) {
|
|
|
1986
2020
|
const toolsDir = path.join(process.cwd(), "tools");
|
|
1987
2021
|
const crateDir = path.join(toolsDir, "syn-parser");
|
|
1988
2022
|
const tmpFile = path.join(crateDir, "src", "input.rs");
|
|
1989
|
-
const { writeFileSync:
|
|
1990
|
-
|
|
1991
|
-
const result = spawnSync(
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2023
|
+
const { writeFileSync: writeFileSync3 } = __require("node:fs");
|
|
2024
|
+
writeFileSync3(tmpFile, content, "utf8");
|
|
2025
|
+
const result = spawnSync(
|
|
2026
|
+
"cargo",
|
|
2027
|
+
["run", "--manifest-path", path.join(toolsDir, "Cargo.toml")],
|
|
2028
|
+
{
|
|
2029
|
+
cwd: process.cwd(),
|
|
2030
|
+
encoding: "utf8",
|
|
2031
|
+
timeout: 15e3,
|
|
2032
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
2033
|
+
}
|
|
2034
|
+
);
|
|
1997
2035
|
if (result.status === 0 && result.stdout) {
|
|
1998
2036
|
const symbols = JSON.parse(result.stdout);
|
|
1999
2037
|
return {
|
|
@@ -2027,7 +2065,8 @@ function regexParse(opts) {
|
|
|
2027
2065
|
lineOffsets.push(lineOffsets[i] + lines[i].length + 1);
|
|
2028
2066
|
}
|
|
2029
2067
|
function lineFromOffset(offset) {
|
|
2030
|
-
let lo = 0
|
|
2068
|
+
let lo = 0;
|
|
2069
|
+
let hi = lineOffsets.length - 1;
|
|
2031
2070
|
while (lo < hi) {
|
|
2032
2071
|
const mid = lo + hi + 1 >>> 1;
|
|
2033
2072
|
if (lineOffsets[mid] <= offset) lo = mid;
|
|
@@ -2041,8 +2080,7 @@ function regexParse(opts) {
|
|
|
2041
2080
|
}
|
|
2042
2081
|
for (const pattern of RS_PATTERNS) {
|
|
2043
2082
|
pattern.regex.lastIndex = 0;
|
|
2044
|
-
let match;
|
|
2045
|
-
while ((match = pattern.regex.exec(content)) !== null) {
|
|
2083
|
+
for (let match = pattern.regex.exec(content); match !== null; match = pattern.regex.exec(content)) {
|
|
2046
2084
|
const name = match[1];
|
|
2047
2085
|
const offset = match.index;
|
|
2048
2086
|
const line = lineFromOffset(offset);
|
|
@@ -2095,7 +2133,8 @@ function regexParse2(opts) {
|
|
|
2095
2133
|
lineOffsets.push(lineOffsets[i] + lines[i].length + 1);
|
|
2096
2134
|
}
|
|
2097
2135
|
function lineFromOffset(offset) {
|
|
2098
|
-
let lo = 0
|
|
2136
|
+
let lo = 0;
|
|
2137
|
+
let hi = lineOffsets.length - 1;
|
|
2099
2138
|
while (lo < hi) {
|
|
2100
2139
|
const mid = lo + hi + 1 >>> 1;
|
|
2101
2140
|
if (lineOffsets[mid] <= offset) lo = mid;
|
|
@@ -2107,19 +2146,20 @@ function regexParse2(opts) {
|
|
|
2107
2146
|
if (rootMatch) {
|
|
2108
2147
|
const offset = rootMatch.index;
|
|
2109
2148
|
const line = lineFromOffset(offset);
|
|
2110
|
-
symbols.push(
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2149
|
+
symbols.push(
|
|
2150
|
+
makeSymbol({
|
|
2151
|
+
name: path.basename(file),
|
|
2152
|
+
kind: "object",
|
|
2153
|
+
line,
|
|
2154
|
+
col: 0,
|
|
2155
|
+
signature: `"${path.basename(file)}" = { ... }`,
|
|
2156
|
+
file,
|
|
2157
|
+
lang
|
|
2158
|
+
})
|
|
2159
|
+
);
|
|
2119
2160
|
}
|
|
2120
2161
|
const topLevelKeyRegex = /^\s*"([^"]+)"\s*:/gm;
|
|
2121
|
-
let match;
|
|
2122
|
-
while ((match = topLevelKeyRegex.exec(content)) !== null) {
|
|
2162
|
+
for (let match = topLevelKeyRegex.exec(content); match !== null; match = topLevelKeyRegex.exec(content)) {
|
|
2123
2163
|
const key = match[1];
|
|
2124
2164
|
const offset = match.index;
|
|
2125
2165
|
const line = lineFromOffset(offset);
|
|
@@ -2146,15 +2186,17 @@ function regexParse2(opts) {
|
|
|
2146
2186
|
signature = `"$ref": "..."`;
|
|
2147
2187
|
}
|
|
2148
2188
|
}
|
|
2149
|
-
symbols.push(
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2189
|
+
symbols.push(
|
|
2190
|
+
makeSymbol({
|
|
2191
|
+
name: key,
|
|
2192
|
+
kind,
|
|
2193
|
+
line,
|
|
2194
|
+
col,
|
|
2195
|
+
signature,
|
|
2196
|
+
file,
|
|
2197
|
+
lang
|
|
2198
|
+
})
|
|
2199
|
+
);
|
|
2158
2200
|
if (isPackageJson && key === "scripts") {
|
|
2159
2201
|
extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFromOffset);
|
|
2160
2202
|
}
|
|
@@ -2163,20 +2205,21 @@ function regexParse2(opts) {
|
|
|
2163
2205
|
}
|
|
2164
2206
|
}
|
|
2165
2207
|
const defsRegex = /"\$defs"\s*:|"\$defs"\s*:/g;
|
|
2166
|
-
|
|
2167
|
-
|
|
2208
|
+
const defsMatch = defsRegex.exec(content);
|
|
2209
|
+
if (defsMatch !== null) {
|
|
2168
2210
|
const offset = defsMatch.index;
|
|
2169
2211
|
const line = lineFromOffset(offset);
|
|
2170
|
-
symbols.push(
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2212
|
+
symbols.push(
|
|
2213
|
+
makeSymbol({
|
|
2214
|
+
name: "$defs",
|
|
2215
|
+
kind: "property",
|
|
2216
|
+
line,
|
|
2217
|
+
col: offset - (lineOffsets[line - 1] ?? 0),
|
|
2218
|
+
signature: '"$defs": { ... }',
|
|
2219
|
+
file,
|
|
2220
|
+
lang
|
|
2221
|
+
})
|
|
2222
|
+
);
|
|
2180
2223
|
}
|
|
2181
2224
|
const defsPatterns = [
|
|
2182
2225
|
/"\$defs"\s*:/g,
|
|
@@ -2186,69 +2229,71 @@ function regexParse2(opts) {
|
|
|
2186
2229
|
];
|
|
2187
2230
|
for (const pat of defsPatterns) {
|
|
2188
2231
|
pat.lastIndex = 0;
|
|
2189
|
-
|
|
2232
|
+
for (let match = pat.exec(content); match !== null; match = pat.exec(content)) {
|
|
2190
2233
|
const offset = match.index;
|
|
2191
2234
|
const line = lineFromOffset(offset);
|
|
2192
2235
|
const key = match[0].match(/"([^"]+)"/)?.[1] ?? match[0];
|
|
2193
|
-
symbols.push(
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2236
|
+
symbols.push(
|
|
2237
|
+
makeSymbol({
|
|
2238
|
+
name: key,
|
|
2239
|
+
kind: "property",
|
|
2240
|
+
line,
|
|
2241
|
+
col: offset - (lineOffsets[line - 1] ?? 0),
|
|
2242
|
+
signature: `"${key}": { ... }`,
|
|
2243
|
+
file,
|
|
2244
|
+
lang
|
|
2245
|
+
})
|
|
2246
|
+
);
|
|
2202
2247
|
}
|
|
2203
2248
|
}
|
|
2204
2249
|
return { file, lang, symbols, mtimeMs: Date.now() };
|
|
2205
2250
|
}
|
|
2206
2251
|
function extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFromOffset) {
|
|
2207
2252
|
const scriptsBlockRegex = /"scripts"\s*:\s*\{([^}]+)\}/g;
|
|
2208
|
-
let match;
|
|
2209
|
-
while ((match = scriptsBlockRegex.exec(content)) !== null) {
|
|
2253
|
+
for (let match = scriptsBlockRegex.exec(content); match !== null; match = scriptsBlockRegex.exec(content)) {
|
|
2210
2254
|
const blockContent = match[0];
|
|
2211
2255
|
const blockOffset = match.index;
|
|
2212
2256
|
const scriptKeyRegex = /"(\w[\w-]*)"\s*:/g;
|
|
2213
|
-
let scriptMatch;
|
|
2214
|
-
while ((scriptMatch = scriptKeyRegex.exec(blockContent)) !== null) {
|
|
2257
|
+
for (let scriptMatch = scriptKeyRegex.exec(blockContent); scriptMatch !== null; scriptMatch = scriptKeyRegex.exec(blockContent)) {
|
|
2215
2258
|
const key = scriptMatch[1];
|
|
2216
2259
|
const keyOffset = blockOffset + scriptMatch.index;
|
|
2217
2260
|
const line = lineFromOffset(keyOffset);
|
|
2218
|
-
symbols.push(
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2261
|
+
symbols.push(
|
|
2262
|
+
makeSymbol({
|
|
2263
|
+
name: key,
|
|
2264
|
+
kind: "function",
|
|
2265
|
+
line,
|
|
2266
|
+
col: keyOffset - (lineOffsets[line - 1] ?? 0),
|
|
2267
|
+
signature: `"${key}": "..."`,
|
|
2268
|
+
file,
|
|
2269
|
+
lang
|
|
2270
|
+
})
|
|
2271
|
+
);
|
|
2227
2272
|
}
|
|
2228
2273
|
}
|
|
2229
2274
|
}
|
|
2230
2275
|
function extractCompilerOptions(content, symbols, file, lang, lineOffsets, parentLine, lineFromOffset) {
|
|
2231
2276
|
const optsBlockRegex = /"compilerOptions"\s*:\s*\{([^}]+)\}/g;
|
|
2232
|
-
let match;
|
|
2233
|
-
while ((match = optsBlockRegex.exec(content)) !== null) {
|
|
2277
|
+
for (let match = optsBlockRegex.exec(content); match !== null; match = optsBlockRegex.exec(content)) {
|
|
2234
2278
|
const blockContent = match[0];
|
|
2235
2279
|
const blockOffset = match.index;
|
|
2236
2280
|
const optKeyRegex = /"(\w[\w]*)"\s*:/g;
|
|
2237
|
-
let optMatch;
|
|
2238
|
-
while ((optMatch = optKeyRegex.exec(blockContent)) !== null) {
|
|
2281
|
+
for (let optMatch = optKeyRegex.exec(blockContent); optMatch !== null; optMatch = optKeyRegex.exec(blockContent)) {
|
|
2239
2282
|
const key = optMatch[1];
|
|
2240
2283
|
const keyOffset = blockOffset + optMatch.index;
|
|
2241
2284
|
const line = lineFromOffset(keyOffset);
|
|
2242
2285
|
if (line <= parentLine) continue;
|
|
2243
|
-
symbols.push(
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2286
|
+
symbols.push(
|
|
2287
|
+
makeSymbol({
|
|
2288
|
+
name: key,
|
|
2289
|
+
kind: "property",
|
|
2290
|
+
line,
|
|
2291
|
+
col: keyOffset - (lineOffsets[line - 1] ?? 0),
|
|
2292
|
+
signature: `"${key}": ...`,
|
|
2293
|
+
file,
|
|
2294
|
+
lang
|
|
2295
|
+
})
|
|
2296
|
+
);
|
|
2252
2297
|
}
|
|
2253
2298
|
}
|
|
2254
2299
|
}
|
|
@@ -2286,7 +2331,8 @@ function regexParse3(opts) {
|
|
|
2286
2331
|
lineOffsets.push(lineOffsets[i] + lines[i].length + 1);
|
|
2287
2332
|
}
|
|
2288
2333
|
function lineFromOffset(offset) {
|
|
2289
|
-
let lo = 0
|
|
2334
|
+
let lo = 0;
|
|
2335
|
+
let hi = lineOffsets.length - 1;
|
|
2290
2336
|
while (lo < hi) {
|
|
2291
2337
|
const mid = lo + hi + 1 >>> 1;
|
|
2292
2338
|
if (lineOffsets[mid] <= offset) lo = mid;
|
|
@@ -2295,40 +2341,43 @@ function regexParse3(opts) {
|
|
|
2295
2341
|
return lo + 1;
|
|
2296
2342
|
}
|
|
2297
2343
|
const anchorRegex = /&(\w[\w-]*)/g;
|
|
2298
|
-
let match;
|
|
2299
|
-
while ((match = anchorRegex.exec(content)) !== null) {
|
|
2344
|
+
for (let match = anchorRegex.exec(content); match !== null; match = anchorRegex.exec(content)) {
|
|
2300
2345
|
const name = match[1];
|
|
2301
2346
|
const offset = match.index;
|
|
2302
2347
|
const line = lineFromOffset(offset);
|
|
2303
2348
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2304
|
-
symbols.push(
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2349
|
+
symbols.push(
|
|
2350
|
+
makeSymbol2({
|
|
2351
|
+
name,
|
|
2352
|
+
kind: "const",
|
|
2353
|
+
line,
|
|
2354
|
+
col,
|
|
2355
|
+
signature: `&${name}`,
|
|
2356
|
+
file,
|
|
2357
|
+
lang
|
|
2358
|
+
})
|
|
2359
|
+
);
|
|
2313
2360
|
}
|
|
2314
2361
|
const aliasRegex = /\*(\w[\w-]*)/g;
|
|
2315
|
-
|
|
2362
|
+
for (let match = aliasRegex.exec(content); match !== null; match = aliasRegex.exec(content)) {
|
|
2316
2363
|
const name = match[1];
|
|
2317
2364
|
const offset = match.index;
|
|
2318
2365
|
const line = lineFromOffset(offset);
|
|
2319
2366
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2320
|
-
symbols.push(
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2367
|
+
symbols.push(
|
|
2368
|
+
makeSymbol2({
|
|
2369
|
+
name,
|
|
2370
|
+
kind: "const",
|
|
2371
|
+
line,
|
|
2372
|
+
col,
|
|
2373
|
+
signature: `*${name}`,
|
|
2374
|
+
file,
|
|
2375
|
+
lang
|
|
2376
|
+
})
|
|
2377
|
+
);
|
|
2329
2378
|
}
|
|
2330
2379
|
const kvRegex = /^(\s*)([^:#\s][^:#\s]*)\s*:/gm;
|
|
2331
|
-
|
|
2380
|
+
for (let match = kvRegex.exec(content); match !== null; match = kvRegex.exec(content)) {
|
|
2332
2381
|
const indent = match[1].length;
|
|
2333
2382
|
const key = match[2];
|
|
2334
2383
|
const offset = match.index;
|
|
@@ -2344,38 +2393,42 @@ function regexParse3(opts) {
|
|
|
2344
2393
|
symbols.push(makeSymbol2({ name: key, kind, line, col, signature, file, lang }));
|
|
2345
2394
|
}
|
|
2346
2395
|
const listItemRegex = /^-(\s+)([^:#\s][^:#\s]*)\s*:/gm;
|
|
2347
|
-
|
|
2396
|
+
for (let match = listItemRegex.exec(content); match !== null; match = listItemRegex.exec(content)) {
|
|
2348
2397
|
const key = match[2];
|
|
2349
2398
|
const offset = match.index;
|
|
2350
2399
|
const line = lineFromOffset(offset);
|
|
2351
2400
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2352
2401
|
const value = extractValue(content, offset + match[0].length);
|
|
2353
2402
|
const kind = isScalar(value) ? "literal" : "property";
|
|
2354
|
-
symbols.push(
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2403
|
+
symbols.push(
|
|
2404
|
+
makeSymbol2({
|
|
2405
|
+
name: key,
|
|
2406
|
+
kind,
|
|
2407
|
+
line,
|
|
2408
|
+
col,
|
|
2409
|
+
signature: `- ${key}: ${truncate(value, 60)}`,
|
|
2410
|
+
file,
|
|
2411
|
+
lang
|
|
2412
|
+
})
|
|
2413
|
+
);
|
|
2363
2414
|
}
|
|
2364
2415
|
const blockScalarRegex = /^(\s*)([^:#\s][^:#\s]*)\s*:\s*[|>](\s|$)/gm;
|
|
2365
|
-
|
|
2416
|
+
for (let match = blockScalarRegex.exec(content); match !== null; match = blockScalarRegex.exec(content)) {
|
|
2366
2417
|
const key = match[2];
|
|
2367
2418
|
const offset = match.index;
|
|
2368
2419
|
const line = lineFromOffset(offset);
|
|
2369
2420
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2370
|
-
symbols.push(
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2421
|
+
symbols.push(
|
|
2422
|
+
makeSymbol2({
|
|
2423
|
+
name: key,
|
|
2424
|
+
kind: "property",
|
|
2425
|
+
line,
|
|
2426
|
+
col,
|
|
2427
|
+
signature: `${key}: | ...`,
|
|
2428
|
+
file,
|
|
2429
|
+
lang
|
|
2430
|
+
})
|
|
2431
|
+
);
|
|
2379
2432
|
}
|
|
2380
2433
|
return { file, lang, symbols, mtimeMs: Date.now() };
|
|
2381
2434
|
}
|
|
@@ -4625,8 +4678,8 @@ var jsonTool = {
|
|
|
4625
4678
|
};
|
|
4626
4679
|
}
|
|
4627
4680
|
};
|
|
4628
|
-
function query(data,
|
|
4629
|
-
const parts =
|
|
4681
|
+
function query(data, path18) {
|
|
4682
|
+
const parts = path18.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
|
|
4630
4683
|
let current = data;
|
|
4631
4684
|
for (const part of parts) {
|
|
4632
4685
|
if (current === null || current === void 0) return void 0;
|
|
@@ -4880,7 +4933,7 @@ async function dockerLogs(service, lines, filterRe, cwd, signal, since) {
|
|
|
4880
4933
|
});
|
|
4881
4934
|
}
|
|
4882
4935
|
var MAX_TAIL_LINES = 1e5;
|
|
4883
|
-
async function fileLogs(
|
|
4936
|
+
async function fileLogs(path18, lines, filterRe, stream) {
|
|
4884
4937
|
const { createInterface } = await import('node:readline');
|
|
4885
4938
|
const { createReadStream } = await import('node:fs');
|
|
4886
4939
|
const entries = [];
|
|
@@ -4889,7 +4942,7 @@ async function fileLogs(path17, lines, filterRe, stream) {
|
|
|
4889
4942
|
let writeIdx = 0;
|
|
4890
4943
|
let totalLines = 0;
|
|
4891
4944
|
const rl = createInterface({
|
|
4892
|
-
input: createReadStream(
|
|
4945
|
+
input: createReadStream(path18),
|
|
4893
4946
|
crlfDelay: Number.POSITIVE_INFINITY
|
|
4894
4947
|
});
|
|
4895
4948
|
for await (const line of rl) {
|
|
@@ -4910,7 +4963,7 @@ async function fileLogs(path17, lines, filterRe, stream) {
|
|
|
4910
4963
|
if (parsed) entries.push(parsed);
|
|
4911
4964
|
}
|
|
4912
4965
|
return {
|
|
4913
|
-
source:
|
|
4966
|
+
source: path18,
|
|
4914
4967
|
entries,
|
|
4915
4968
|
total: entries.length,
|
|
4916
4969
|
truncated: totalLines > effLines,
|