weavatrix 0.3.13 → 1.0.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/LICENSE +1 -0
- package/README.md +231 -199
- package/bin/native/darwin-arm64/weavatrix +0 -0
- package/bin/native/darwin-x64/weavatrix +0 -0
- package/bin/native/linux-arm64/weavatrix +0 -0
- package/bin/native/linux-x64/weavatrix +0 -0
- package/bin/native/win32-arm64/weavatrix.exe +0 -0
- package/bin/native/win32-x64/weavatrix.exe +0 -0
- package/bin/resolve-binary.mjs +73 -0
- package/bin/run-native.mjs +26 -0
- package/bin/weavatrix-mcp.mjs +7 -6
- package/bin/weavatrix.mjs +5 -0
- package/package.json +8 -65
- package/skill/SKILL.md +62 -374
- package/skill/agents/openai.yaml +4 -0
- package/skill/references/tool-routing.md +45 -0
- package/SECURITY.md +0 -101
- package/docs/adr/0001-v0.3-offline-online-split.md +0 -60
- package/docs/agent-task-benchmark.md +0 -58
- package/docs/releases/v0.2.19.md +0 -33
- package/docs/releases/v0.3.0.md +0 -43
- package/docs/releases/v0.3.1.md +0 -30
- package/docs/releases/v0.3.10.md +0 -76
- package/docs/releases/v0.3.11.md +0 -55
- package/docs/releases/v0.3.12.md +0 -44
- package/docs/releases/v0.3.13.md +0 -34
- package/docs/releases/v0.3.2.md +0 -15
- package/docs/releases/v0.3.3.md +0 -25
- package/docs/releases/v0.3.4.md +0 -40
- package/docs/releases/v0.3.5.md +0 -50
- package/docs/releases/v0.3.6.md +0 -44
- package/docs/releases/v0.3.7.md +0 -37
- package/docs/releases/v0.3.8.md +0 -21
- package/docs/releases/v0.3.9.md +0 -36
- package/scripts/run-agent-task-benchmark.mjs +0 -118
- package/src/analysis/allowed-test-runner.js +0 -70
- package/src/analysis/architecture/contract-graph.js +0 -119
- package/src/analysis/architecture/contract-schema.js +0 -110
- package/src/analysis/architecture/contract-storage.js +0 -35
- package/src/analysis/architecture/contract-verification.js +0 -168
- package/src/analysis/architecture-contract.js +0 -16
- package/src/analysis/audit-debt.js +0 -94
- package/src/analysis/audit-extensions.js +0 -60
- package/src/analysis/cargo-dependency-evidence.js +0 -108
- package/src/analysis/cargo-manifests.js +0 -81
- package/src/analysis/change-classification/diff-parser.js +0 -103
- package/src/analysis/change-classification/options.js +0 -40
- package/src/analysis/change-classification/symbol-classifier.js +0 -177
- package/src/analysis/change-classification.js +0 -188
- package/src/analysis/coverage-reports.js +0 -235
- package/src/analysis/cycle-route.js +0 -14
- package/src/analysis/data-flow-evidence.js +0 -114
- package/src/analysis/dead-check.js +0 -300
- package/src/analysis/dead-code-review/candidates.js +0 -194
- package/src/analysis/dead-code-review/policy.js +0 -23
- package/src/analysis/dead-code-review.js +0 -119
- package/src/analysis/dep-check-ecosystems.js +0 -205
- package/src/analysis/dep-check.js +0 -290
- package/src/analysis/dep-rules.js +0 -10
- package/src/analysis/dependency/conventions.js +0 -16
- package/src/analysis/dependency/scoped-dependencies.js +0 -51
- package/src/analysis/dependency/source-references.js +0 -21
- package/src/analysis/duplicate-groups.js +0 -104
- package/src/analysis/duplicates-worker.js +0 -11
- package/src/analysis/duplicates.compute.js +0 -269
- package/src/analysis/duplicates.js +0 -15
- package/src/analysis/duplicates.run.js +0 -52
- package/src/analysis/duplicates.tokenize.js +0 -199
- package/src/analysis/endpoints/common.js +0 -62
- package/src/analysis/endpoints/extract.js +0 -107
- package/src/analysis/endpoints/inventory.js +0 -84
- package/src/analysis/endpoints/mounts.js +0 -129
- package/src/analysis/endpoints-java.js +0 -260
- package/src/analysis/endpoints-rust.js +0 -124
- package/src/analysis/endpoints.js +0 -3
- package/src/analysis/findings.js +0 -70
- package/src/analysis/git-history/analytics.js +0 -177
- package/src/analysis/git-history/collector.js +0 -67
- package/src/analysis/git-history/options.js +0 -66
- package/src/analysis/git-history.js +0 -143
- package/src/analysis/git-ref-graph.js +0 -76
- package/src/analysis/go-dependency-evidence.js +0 -62
- package/src/analysis/graph-analysis.aggregate.js +0 -295
- package/src/analysis/graph-analysis.edges.js +0 -24
- package/src/analysis/graph-analysis.js +0 -7
- package/src/analysis/graph-analysis.refs.js +0 -154
- package/src/analysis/graph-analysis.summaries.js +0 -65
- package/src/analysis/health-capabilities.js +0 -83
- package/src/analysis/hot-path-review.js +0 -266
- package/src/analysis/http-contract-wrappers.js +0 -241
- package/src/analysis/http-contracts/analysis.js +0 -179
- package/src/analysis/http-contracts/client-call-detection.js +0 -82
- package/src/analysis/http-contracts/client-call-parser.js +0 -273
- package/src/analysis/http-contracts/graph-context.js +0 -143
- package/src/analysis/http-contracts/matching.js +0 -61
- package/src/analysis/http-contracts/shared.js +0 -85
- package/src/analysis/http-contracts.js +0 -6
- package/src/analysis/internal-audit/dependency-health.js +0 -113
- package/src/analysis/internal-audit/python-manifests.js +0 -78
- package/src/analysis/internal-audit/repo-files.js +0 -50
- package/src/analysis/internal-audit/supply-chain.js +0 -149
- package/src/analysis/internal-audit.collect.js +0 -213
- package/src/analysis/internal-audit.js +0 -9
- package/src/analysis/internal-audit.reach.js +0 -173
- package/src/analysis/internal-audit.run.js +0 -256
- package/src/analysis/java-source.js +0 -36
- package/src/analysis/jvm-artifact-index.js +0 -87
- package/src/analysis/jvm-dependency-evidence.js +0 -138
- package/src/analysis/jvm-manifests.js +0 -114
- package/src/analysis/manifests.js +0 -123
- package/src/analysis/package-reachability.js +0 -39
- package/src/analysis/source-complexity.ast.js +0 -97
- package/src/analysis/source-complexity.constants.js +0 -55
- package/src/analysis/source-complexity.js +0 -14
- package/src/analysis/source-complexity.report.js +0 -81
- package/src/analysis/source-complexity.walk.js +0 -228
- package/src/analysis/source-correctness/retry-patterns.js +0 -93
- package/src/analysis/source-correctness.js +0 -222
- package/src/analysis/static-test-reachability.js +0 -150
- package/src/analysis/structure/dependency-graph.js +0 -151
- package/src/analysis/structure/findings.js +0 -162
- package/src/analysis/task-retrieval.js +0 -107
- package/src/analysis/transport-contracts.js +0 -224
- package/src/analysis/transport-runtime-evidence.js +0 -155
- package/src/analysis-kit.mjs +0 -17
- package/src/bounds.js +0 -4
- package/src/build-graph.js +0 -209
- package/src/child-env.js +0 -7
- package/src/config.js +0 -5
- package/src/extension/local-services.mjs +0 -75
- package/src/git-exec.js +0 -67
- package/src/graph/build-worker.js +0 -49
- package/src/graph/builder/go-receiver-resolution.js +0 -112
- package/src/graph/builder/js/dynamic-import.js +0 -26
- package/src/graph/builder/js/queries.js +0 -48
- package/src/graph/builder/lang-csharp.js +0 -40
- package/src/graph/builder/lang-css.js +0 -29
- package/src/graph/builder/lang-go.js +0 -140
- package/src/graph/builder/lang-html.js +0 -29
- package/src/graph/builder/lang-java-calls.js +0 -142
- package/src/graph/builder/lang-java.js +0 -215
- package/src/graph/builder/lang-js.js +0 -291
- package/src/graph/builder/lang-python.js +0 -235
- package/src/graph/builder/lang-rust-calls.js +0 -63
- package/src/graph/builder/lang-rust.js +0 -299
- package/src/graph/builder/lang-solidity.js +0 -126
- package/src/graph/builder/lang-sql.js +0 -263
- package/src/graph/builder/pass2-resolution.js +0 -81
- package/src/graph/builder/spec-pkg.js +0 -87
- package/src/graph/community.js +0 -27
- package/src/graph/edge-provenance.js +0 -31
- package/src/graph/file-lock.js +0 -69
- package/src/graph/freshness-probe.js +0 -142
- package/src/graph/graph-filter.js +0 -63
- package/src/graph/incremental-refresh.js +0 -235
- package/src/graph/internal-builder.barrels.js +0 -235
- package/src/graph/internal-builder.build.js +0 -300
- package/src/graph/internal-builder.java.js +0 -33
- package/src/graph/internal-builder.js +0 -12
- package/src/graph/internal-builder.langs.js +0 -157
- package/src/graph/internal-builder.pass2.js +0 -163
- package/src/graph/internal-builder.resolvers.js +0 -286
- package/src/graph/layout.js +0 -51
- package/src/graph/node-id.js +0 -7
- package/src/graph/parser-artifact-boundary.js +0 -55
- package/src/graph/relations.js +0 -4
- package/src/graph/repo-registry.js +0 -124
- package/src/graph/resolvers/rust.js +0 -117
- package/src/infra/infra-items.js +0 -255
- package/src/infra/infra-registry.js +0 -184
- package/src/infra/infra.detect.js +0 -119
- package/src/infra/infra.js +0 -38
- package/src/infra/infra.match.js +0 -102
- package/src/infra/infra.scan.js +0 -93
- package/src/mcp/actions/graph-lifecycle.mjs +0 -148
- package/src/mcp/architecture-bootstrap.mjs +0 -168
- package/src/mcp/architecture-starter.mjs +0 -234
- package/src/mcp/catalog.mjs +0 -233
- package/src/mcp/company-contract-page.mjs +0 -142
- package/src/mcp/company-contract-reconcile.mjs +0 -87
- package/src/mcp/company-contract-verdict.mjs +0 -42
- package/src/mcp/evidence/bun-lock-graph.mjs +0 -209
- package/src/mcp/evidence/duplicate-member-order.mjs +0 -8
- package/src/mcp/evidence/package-graph-common.mjs +0 -115
- package/src/mcp/evidence/package-lock-graph.mjs +0 -92
- package/src/mcp/evidence-snapshot.architecture.mjs +0 -80
- package/src/mcp/evidence-snapshot.common.mjs +0 -158
- package/src/mcp/evidence-snapshot.duplicates.mjs +0 -213
- package/src/mcp/evidence-snapshot.health.mjs +0 -102
- package/src/mcp/evidence-snapshot.inventory.mjs +0 -148
- package/src/mcp/evidence-snapshot.mjs +0 -50
- package/src/mcp/evidence-snapshot.package-graph.mjs +0 -34
- package/src/mcp/evidence-snapshot.structure.mjs +0 -84
- package/src/mcp/extension-api.mjs +0 -77
- package/src/mcp/git-output.mjs +0 -7
- package/src/mcp/graph/context-core.mjs +0 -111
- package/src/mcp/graph/context-seeds.mjs +0 -207
- package/src/mcp/graph/context-state.mjs +0 -85
- package/src/mcp/graph/reverse-reach.mjs +0 -42
- package/src/mcp/graph/tools-core.mjs +0 -143
- package/src/mcp/graph/tools-query.mjs +0 -276
- package/src/mcp/graph-context.mjs +0 -5
- package/src/mcp/graph-diff.mjs +0 -218
- package/src/mcp/health/audit-format.mjs +0 -199
- package/src/mcp/health/audit.mjs +0 -174
- package/src/mcp/health/dead-code.mjs +0 -110
- package/src/mcp/health/duplicates.mjs +0 -85
- package/src/mcp/health/endpoints.mjs +0 -71
- package/src/mcp/health/structure.mjs +0 -219
- package/src/mcp/runtime-version.mjs +0 -31
- package/src/mcp/server/auto-refresh.mjs +0 -66
- package/src/mcp/server/runtime-config.mjs +0 -43
- package/src/mcp/server/shutdown.mjs +0 -40
- package/src/mcp/staleness-notice.mjs +0 -20
- package/src/mcp/sync/evidence-architecture.mjs +0 -54
- package/src/mcp/sync/evidence-common.mjs +0 -88
- package/src/mcp/sync/evidence-duplicates.mjs +0 -97
- package/src/mcp/sync/evidence-health.mjs +0 -56
- package/src/mcp/sync/evidence-packages.mjs +0 -95
- package/src/mcp/sync/payload-common.mjs +0 -97
- package/src/mcp/sync/payload-v2.mjs +0 -54
- package/src/mcp/sync/payload-v3.mjs +0 -79
- package/src/mcp/sync-evidence.mjs +0 -23
- package/src/mcp/sync-payload.mjs +0 -70
- package/src/mcp/tool-result.mjs +0 -54
- package/src/mcp/tools-actions.mjs +0 -11
- package/src/mcp/tools-architecture.mjs +0 -177
- package/src/mcp/tools-company.mjs +0 -251
- package/src/mcp/tools-context.mjs +0 -222
- package/src/mcp/tools-endpoints.mjs +0 -207
- package/src/mcp/tools-graph-hubs.mjs +0 -78
- package/src/mcp/tools-graph.mjs +0 -17
- package/src/mcp/tools-health.mjs +0 -24
- package/src/mcp/tools-history.mjs +0 -28
- package/src/mcp/tools-impact-change.mjs +0 -220
- package/src/mcp/tools-impact-precision.mjs +0 -89
- package/src/mcp/tools-impact.mjs +0 -169
- package/src/mcp/tools-source.mjs +0 -238
- package/src/mcp/tools-verified-change.mjs +0 -200
- package/src/mcp-rg.mjs +0 -50
- package/src/mcp-runtime.mjs +0 -2
- package/src/mcp-server.mjs +0 -298
- package/src/mcp-source-tools.mjs +0 -163
- package/src/path-classification.js +0 -220
- package/src/path-ignore.js +0 -69
- package/src/precision/lsp-client/constants.js +0 -12
- package/src/precision/lsp-client/environment.js +0 -20
- package/src/precision/lsp-client/errors.js +0 -15
- package/src/precision/lsp-client/lifecycle.js +0 -114
- package/src/precision/lsp-client/message-parser.js +0 -81
- package/src/precision/lsp-client/protocol.js +0 -212
- package/src/precision/lsp-client/registry.js +0 -59
- package/src/precision/lsp-client/repo-uri.js +0 -60
- package/src/precision/lsp-client/stdio-client.js +0 -140
- package/src/precision/lsp-client.js +0 -10
- package/src/precision/lsp-overlay/budget-policy.js +0 -78
- package/src/precision/lsp-overlay/build.js +0 -261
- package/src/precision/lsp-overlay/contract.js +0 -61
- package/src/precision/lsp-overlay/reference-results.js +0 -108
- package/src/precision/lsp-overlay/semantic-inputs.js +0 -62
- package/src/precision/lsp-overlay/source-session.js +0 -142
- package/src/precision/lsp-overlay/store.js +0 -150
- package/src/precision/lsp-overlay/target-index.js +0 -152
- package/src/precision/lsp-overlay/target-query.js +0 -55
- package/src/precision/lsp-overlay.js +0 -11
- package/src/precision/symbol-query.js +0 -224
- package/src/precision/typescript-lsp-provider.js +0 -12
- package/src/precision/typescript-provider/client.js +0 -89
- package/src/precision/typescript-provider/discovery.js +0 -124
- package/src/precision/typescript-provider/isolated-runtime.js +0 -39
- package/src/precision/typescript-provider/project-host.js +0 -254
- package/src/precision/typescript-provider/project-safety.js +0 -166
- package/src/precision/typescript-provider/reference-usage.js +0 -53
- package/src/process.js +0 -95
- package/src/repo-path.js +0 -53
- package/src/scan/discover.inventory.js +0 -78
- package/src/scan/discover.js +0 -5
- package/src/scan/discover.list.js +0 -79
- package/src/scan/discover.stack.js +0 -227
- package/src/scan/search.core.js +0 -24
- package/src/scan/search.git.js +0 -102
- package/src/scan/search.js +0 -9
- package/src/scan/search.node.js +0 -83
- package/src/scan/search.preview.js +0 -49
- package/src/scan/search.rg.js +0 -145
- package/src/security/advisory-store.js +0 -172
- package/src/security/installed-jvm-rust.js +0 -46
- package/src/security/installed.js +0 -280
- package/src/security/malware-file-heuristics.js +0 -121
- package/src/security/malware-heuristics.exclusions.js +0 -134
- package/src/security/malware-heuristics.js +0 -15
- package/src/security/malware-heuristics.roots.js +0 -145
- package/src/security/malware-heuristics.scan.js +0 -89
- package/src/security/malware-heuristics.sweep.js +0 -122
- package/src/security/malware-scoring.js +0 -105
- package/src/security/match.js +0 -85
- package/src/security/registry-sig.classify.js +0 -137
- package/src/security/registry-sig.js +0 -18
- package/src/security/registry-sig.rules.js +0 -192
- package/src/security/rust-advisory-report.js +0 -60
- package/src/security/typosquat.js +0 -81
- package/src/util.js +0 -40
- package/src/version.js +0 -7
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {extname} from 'node:path'
|
|
2
|
-
import {createRequire} from 'node:module'
|
|
3
|
-
|
|
4
|
-
const requireFromWeavatrix = createRequire(import.meta.url)
|
|
5
|
-
|
|
6
|
-
function typeScriptScriptKind(ts, filePath) {
|
|
7
|
-
const extension = extname(String(filePath)).toLowerCase()
|
|
8
|
-
if (extension === '.tsx') return ts.ScriptKind.TSX
|
|
9
|
-
if (extension === '.jsx') return ts.ScriptKind.JSX
|
|
10
|
-
if (extension === '.js' || extension === '.mjs' || extension === '.cjs') return ts.ScriptKind.JS
|
|
11
|
-
return ts.ScriptKind.TS
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Unknown is deliberately fail-closed: callers must not promote it to runtime.
|
|
15
|
-
export function classifyTypeScriptReferenceUsage(filePath, text, position) {
|
|
16
|
-
if (!Number.isInteger(position?.line) || !Number.isInteger(position?.character)) return 'unknown'
|
|
17
|
-
let ts
|
|
18
|
-
try { ts = requireFromWeavatrix('typescript') } catch { return 'unknown' }
|
|
19
|
-
let sourceFile
|
|
20
|
-
let offset
|
|
21
|
-
try {
|
|
22
|
-
sourceFile = ts.createSourceFile(
|
|
23
|
-
String(filePath || 'source.ts'),
|
|
24
|
-
String(text || ''),
|
|
25
|
-
ts.ScriptTarget.Latest,
|
|
26
|
-
true,
|
|
27
|
-
typeScriptScriptKind(ts, filePath),
|
|
28
|
-
)
|
|
29
|
-
if (sourceFile.parseDiagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) {
|
|
30
|
-
return 'unknown'
|
|
31
|
-
}
|
|
32
|
-
offset = sourceFile.getPositionOfLineAndCharacter(position.line, position.character)
|
|
33
|
-
} catch { return 'unknown' }
|
|
34
|
-
let token
|
|
35
|
-
try { token = ts.getTokenAtPosition(sourceFile, offset) } catch { return 'unknown' }
|
|
36
|
-
if (!token || (!ts.isIdentifier(token) && !ts.isPrivateIdentifier(token))) return 'unknown'
|
|
37
|
-
if (offset < token.getStart(sourceFile) || offset >= token.getEnd()) return 'unknown'
|
|
38
|
-
for (let current = token; current && current !== sourceFile; current = current.parent) {
|
|
39
|
-
if ((ts.isImportSpecifier(current) || ts.isImportClause(current)
|
|
40
|
-
|| ts.isExportSpecifier(current) || ts.isExportDeclaration(current))
|
|
41
|
-
&& current.isTypeOnly === true) return 'type'
|
|
42
|
-
if (ts.isExpressionWithTypeArguments(current) && ts.isHeritageClause(current.parent)) {
|
|
43
|
-
const heritage = current.parent
|
|
44
|
-
if (heritage.token === ts.SyntaxKind.ExtendsKeyword && ts.isClassLike(heritage.parent)) {
|
|
45
|
-
const expression = current.expression
|
|
46
|
-
if (offset >= expression.getStart(sourceFile) && offset < expression.getEnd()) return 'value'
|
|
47
|
-
}
|
|
48
|
-
return 'type'
|
|
49
|
-
}
|
|
50
|
-
if (ts.isTypeNode(current)) return 'type'
|
|
51
|
-
}
|
|
52
|
-
return 'value'
|
|
53
|
-
}
|
package/src/process.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// Subprocess runner shared by the search engines and security sweeps.
|
|
2
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
-
import { childProcessEnv } from "./child-env.js";
|
|
4
|
-
|
|
5
|
-
// Windows: .cmd/.ps1 shims (npx, etc.) can't be spawned directly by Node — they need a
|
|
6
|
-
// shell. With shell:true Node does NOT quote args, so we build a quoted command line ourselves
|
|
7
|
-
// (repo paths contain spaces). POSIX uses the normal argv array, no shell.
|
|
8
|
-
export function winQuote(value) {
|
|
9
|
-
const s = String(value);
|
|
10
|
-
return /[\s&()[\]{}^=;!'+,`~|<>"]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function runCommand(command, args = [], options = {}) {
|
|
14
|
-
// Windows: .cmd/.ps1/bare-name shims (npx, …) need a cmd.exe shell. But a real .exe
|
|
15
|
-
// (rg.exe, where.exe) must be spawned DIRECTLY — wrapping an .exe in the shell breaks stdin
|
|
16
|
-
// piping, which surfaced as "command returned no output".
|
|
17
|
-
const needsShell = process.platform === "win32" && !/\.exe$/i.test(command);
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
const child = needsShell
|
|
20
|
-
? spawn([command, ...args].map(winQuote).join(" "), [], {
|
|
21
|
-
cwd: options.cwd || undefined,
|
|
22
|
-
env: childProcessEnv(options.env || {}),
|
|
23
|
-
shell: true,
|
|
24
|
-
windowsHide: true
|
|
25
|
-
})
|
|
26
|
-
: spawn(command, args, {
|
|
27
|
-
cwd: options.cwd || undefined,
|
|
28
|
-
env: childProcessEnv(options.env || {}),
|
|
29
|
-
windowsHide: true
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
let stdout = "";
|
|
33
|
-
let stderr = "";
|
|
34
|
-
let timedOut = false;
|
|
35
|
-
let settled = false;
|
|
36
|
-
let hardTimer = null;
|
|
37
|
-
const finish = (fn) => {
|
|
38
|
-
if (settled) return;
|
|
39
|
-
settled = true;
|
|
40
|
-
if (timer) clearTimeout(timer);
|
|
41
|
-
if (hardTimer) clearTimeout(hardTimer);
|
|
42
|
-
fn();
|
|
43
|
-
};
|
|
44
|
-
// On timeout, kill the WHOLE process tree. With shell:true the child is cmd.exe; child.kill() would only
|
|
45
|
-
// kill the shell, leaving npx→node→tool running and the stdio pipes open → 'close' never fires → the
|
|
46
|
-
// caller hangs forever. taskkill /T kills the tree; SIGKILL group on POSIX.
|
|
47
|
-
const killTree = () => {
|
|
48
|
-
if (process.platform === "win32" && child.pid) {
|
|
49
|
-
try {
|
|
50
|
-
spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], { windowsHide: true, env: childProcessEnv() });
|
|
51
|
-
} catch {
|
|
52
|
-
try { child.kill(); } catch { /* process may already be gone */ }
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
try { child.kill("SIGKILL"); } catch { /* process may already be gone */ }
|
|
56
|
-
}
|
|
57
|
-
// hard fallback: if 'close' still never fires after the kill, settle anyway so the caller can't hang
|
|
58
|
-
hardTimer = setTimeout(() => finish(() => reject(new Error("Command timed out"))), 4000);
|
|
59
|
-
};
|
|
60
|
-
const timer = options.timeoutMs
|
|
61
|
-
? setTimeout(() => {
|
|
62
|
-
timedOut = true;
|
|
63
|
-
killTree();
|
|
64
|
-
}, options.timeoutMs)
|
|
65
|
-
: null;
|
|
66
|
-
|
|
67
|
-
child.stdout?.on("data", (chunk) => (stdout += chunk));
|
|
68
|
-
child.stderr?.on("data", (chunk) => (stderr += chunk));
|
|
69
|
-
if (options.stdin) {
|
|
70
|
-
child.stdin.write(options.stdin);
|
|
71
|
-
child.stdin.end();
|
|
72
|
-
} else {
|
|
73
|
-
child.stdin?.end();
|
|
74
|
-
}
|
|
75
|
-
child.on("error", (error) => finish(() => reject(error)));
|
|
76
|
-
child.on("close", (code) => finish(() => (timedOut ? reject(new Error("Command timed out")) : resolve({ stdout, stderr, exitCode: code }))));
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Synchronous run-and-collect variant for callers that resolve a real binary and read its output in
|
|
81
|
-
// one shot (ripgrep resolution/search, tar extraction). These launch a resolved .exe or bare binary
|
|
82
|
-
// directly, so no shell quoting is needed; the child env is stripped of connector secrets and a
|
|
83
|
-
// bounded timeout/buffer applies. Returns the raw spawnSync result ({status, stdout, stderr, error}).
|
|
84
|
-
export function runCommandSync(command, args = [], options = {}) {
|
|
85
|
-
const spawnOptions = {
|
|
86
|
-
cwd: options.cwd || undefined,
|
|
87
|
-
encoding: options.encoding ?? "utf8",
|
|
88
|
-
env: childProcessEnv(options.env),
|
|
89
|
-
windowsHide: true,
|
|
90
|
-
};
|
|
91
|
-
if (options.timeout != null) spawnOptions.timeout = options.timeout;
|
|
92
|
-
if (options.maxBuffer != null) spawnOptions.maxBuffer = options.maxBuffer;
|
|
93
|
-
if (options.stdio != null) spawnOptions.stdio = options.stdio;
|
|
94
|
-
return spawnSync(command, args, spawnOptions);
|
|
95
|
-
}
|
package/src/repo-path.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { realpathSync } from "node:fs";
|
|
2
|
-
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
|
-
|
|
4
|
-
export function isPathInside(root, target) {
|
|
5
|
-
const rel = relative(root, target);
|
|
6
|
-
return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Cache the canonical root for callers that resolve many graph-derived paths.
|
|
10
|
-
export function createRepoBoundary(repoRoot) {
|
|
11
|
-
let root;
|
|
12
|
-
let rootError;
|
|
13
|
-
try {
|
|
14
|
-
root = realpathSync.native(repoRoot);
|
|
15
|
-
} catch (error) {
|
|
16
|
-
rootError = error;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
root,
|
|
21
|
-
resolve(candidate) {
|
|
22
|
-
if (!root) return { ok: false, reason: "invalid-root", error: rootError };
|
|
23
|
-
const input = String(candidate ?? "");
|
|
24
|
-
if (!input || input.includes("\0")) return { ok: false, reason: "invalid-path" };
|
|
25
|
-
if (isAbsolute(input)) return { ok: false, reason: "escape" };
|
|
26
|
-
|
|
27
|
-
let lexical;
|
|
28
|
-
try {
|
|
29
|
-
lexical = resolve(root, input);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return { ok: false, reason: "invalid-path", error };
|
|
32
|
-
}
|
|
33
|
-
if (!isPathInside(root, lexical)) return { ok: false, reason: "escape" };
|
|
34
|
-
|
|
35
|
-
let target;
|
|
36
|
-
try {
|
|
37
|
-
target = realpathSync.native(lexical);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
return { ok: false, reason: error?.code === "ENOENT" ? "not-found" : "unreadable", error };
|
|
40
|
-
}
|
|
41
|
-
if (!isPathInside(root, target)) return { ok: false, reason: "escape" };
|
|
42
|
-
|
|
43
|
-
return { ok: true, path: target };
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Resolve one existing repo-relative path without allowing lexical traversal or
|
|
49
|
-
// symlink/junction escapes. Callers get a reason instead of an exception so MCP
|
|
50
|
-
// tools can refuse the read without exposing host filesystem details.
|
|
51
|
-
export function resolveRepoPath(repoRoot, candidate) {
|
|
52
|
-
return createRepoBoundary(repoRoot).resolve(candidate);
|
|
53
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// Filesystem inventory helpers for repo discovery: size proxy, file/extension census, last commit.
|
|
2
|
-
import { readFileSync, readdirSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
|
|
5
|
-
// Directories never worth walking when sizing a repo (vendored deps, build output, caches).
|
|
6
|
-
const SIZE_SKIP_DIRS = new Set([
|
|
7
|
-
".git", "node_modules", "dist", "build", "out", ".next", "coverage", "vendor",
|
|
8
|
-
".venv", "venv", "env", "target", "__pycache__", ".idea", ".vscode", ".cache", "bin", "obj"
|
|
9
|
-
]);
|
|
10
|
-
|
|
11
|
-
// Cheap "size" proxy: count source files in the working tree (skipping the heavy dirs above).
|
|
12
|
-
// Bounded so a pathological tree can't stall the scan.
|
|
13
|
-
export function repoFileCount(dir) {
|
|
14
|
-
let count = 0;
|
|
15
|
-
const stack = [dir];
|
|
16
|
-
while (stack.length) {
|
|
17
|
-
const cur = stack.pop();
|
|
18
|
-
let entries;
|
|
19
|
-
try {
|
|
20
|
-
entries = readdirSync(cur, { withFileTypes: true });
|
|
21
|
-
} catch {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
for (const entry of entries) {
|
|
25
|
-
if (entry.isDirectory()) {
|
|
26
|
-
if (!SIZE_SKIP_DIRS.has(entry.name)) stack.push(join(cur, entry.name));
|
|
27
|
-
} else if (entry.isFile()) {
|
|
28
|
-
if (++count >= 100000) return count;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return count;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function repoInventory(dir) {
|
|
36
|
-
let count = 0;
|
|
37
|
-
const ext = {};
|
|
38
|
-
const files = new Set();
|
|
39
|
-
const stack = [dir];
|
|
40
|
-
while (stack.length) {
|
|
41
|
-
const cur = stack.pop();
|
|
42
|
-
let entries;
|
|
43
|
-
try {
|
|
44
|
-
entries = readdirSync(cur, { withFileTypes: true });
|
|
45
|
-
} catch {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
for (const entry of entries) {
|
|
49
|
-
if (entry.isDirectory()) {
|
|
50
|
-
if (!SIZE_SKIP_DIRS.has(entry.name)) stack.push(join(cur, entry.name));
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (!entry.isFile()) continue;
|
|
54
|
-
if (++count >= 100000) return { count, ext, files };
|
|
55
|
-
const full = join(cur, entry.name);
|
|
56
|
-
const rel = full.slice(dir.length).replace(/^[\\/]/, "").replace(/\\/g, "/").toLowerCase();
|
|
57
|
-
files.add(rel);
|
|
58
|
-
const m = entry.name.toLowerCase().match(/(\.[a-z0-9]+)$/);
|
|
59
|
-
if (m) ext[m[1]] = (ext[m[1]] || 0) + 1;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return { count, ext, files };
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Last commit time (ms) read straight from .git/logs/HEAD — no `git` spawn. Each reflog line is
|
|
66
|
-
// "<old> <new> <Name> <email> <unixtime> <tz>\t<message>"; the unixtime is the token before the tz.
|
|
67
|
-
export function repoLastCommit(dir) {
|
|
68
|
-
try {
|
|
69
|
-
const log = readFileSync(join(dir, ".git", "logs", "HEAD"), "utf8").trimEnd();
|
|
70
|
-
if (!log) return 0;
|
|
71
|
-
const lastLine = log.slice(log.lastIndexOf("\n") + 1).split("\t")[0];
|
|
72
|
-
const tokens = lastLine.trim().split(/\s+/);
|
|
73
|
-
const unixTime = Number(tokens[tokens.length - 2]);
|
|
74
|
-
return Number.isFinite(unixTime) ? unixTime * 1000 : 0;
|
|
75
|
-
} catch {
|
|
76
|
-
return 0;
|
|
77
|
-
}
|
|
78
|
-
}
|
package/src/scan/discover.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// Discover local git repos under a folder, browse child folders, and persist per-repo run results.
|
|
2
|
-
// Facade: implementation lives in discover.inventory.js (fs walking / git metadata),
|
|
3
|
-
// discover.stack.js (framework + badge detection) and discover.list.js (repo/folder listing).
|
|
4
|
-
export { cleanVersion, detectFramework, detectRepoStack } from "./discover.stack.js";
|
|
5
|
-
export { listGitRepos, repoBaseName, listChildFolders } from "./discover.list.js";
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// Repo listing: describe direct child git repos of a folder and browse child folders.
|
|
2
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { ROOT_DIR } from "../config.js";
|
|
5
|
-
import { repoFileCount, repoInventory, repoLastCommit } from "./discover.inventory.js";
|
|
6
|
-
import { detectFramework, detectRepoStack } from "./discover.stack.js";
|
|
7
|
-
|
|
8
|
-
function reposDefaultFolder() {
|
|
9
|
-
return join(ROOT_DIR, "..", "..");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function describeRepo(dir, name) {
|
|
13
|
-
const has = (file) => existsSync(join(dir, file));
|
|
14
|
-
// RUNTIME first — a Bun/Deno project also has a package.json, so check its markers before falling
|
|
15
|
-
// back to "node". (Fixes Bun repos like edge-analytics being mislabelled "node".)
|
|
16
|
-
let language = "other";
|
|
17
|
-
if (has("bun.lock") || has("bun.lockb") || has("bunfig.toml")) language = "bun";
|
|
18
|
-
else if (has("deno.json") || has("deno.jsonc") || has("deno.lock")) language = "deno";
|
|
19
|
-
else if (has("package.json")) language = "node";
|
|
20
|
-
else if (has("go.mod")) language = "go";
|
|
21
|
-
else if (has("pom.xml") || has("build.gradle")) language = "java";
|
|
22
|
-
else if (has("requirements.txt") || has("pyproject.toml") || has("setup.py") || has("Pipfile")) language = "python";
|
|
23
|
-
else if (has("Cargo.toml")) language = "rust";
|
|
24
|
-
else if (has("composer.json")) language = "php";
|
|
25
|
-
else if (has("Gemfile")) language = "ruby";
|
|
26
|
-
// framework detection uses the JS-ecosystem table for bun/deno too (they run npm packages)
|
|
27
|
-
const fwRuntime = language === "bun" || language === "deno" ? "node" : language;
|
|
28
|
-
const inventory = repoInventory(dir);
|
|
29
|
-
const stack = detectRepoStack(dir, inventory);
|
|
30
|
-
language = stack.languages[0]?.id || stack.runtimes[0]?.id || language;
|
|
31
|
-
const stackRunsJs = stack.runtimes.some((badge) => ["node", "bun", "deno"].includes(badge.id)) || ["javascript", "typescript"].includes(language);
|
|
32
|
-
const stackFwRuntime = stackRunsJs ? "node" : language;
|
|
33
|
-
return {
|
|
34
|
-
name,
|
|
35
|
-
path: dir,
|
|
36
|
-
language,
|
|
37
|
-
stack,
|
|
38
|
-
framework: detectFramework(dir, stackFwRuntime || fwRuntime),
|
|
39
|
-
knipEligible: has("package.json"),
|
|
40
|
-
size: inventory.count || repoFileCount(dir),
|
|
41
|
-
lastCommit: repoLastCommit(dir)
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Only DIRECT child git repos of the opened folder. We do not descend into folders or into
|
|
46
|
-
// repos, so nested/sub-repos are not listed.
|
|
47
|
-
export function listGitRepos(folder) {
|
|
48
|
-
const root = folder && String(folder).trim() ? String(folder).trim() : reposDefaultFolder();
|
|
49
|
-
if (!existsSync(root)) throw new Error(`Folder not found: ${root}`);
|
|
50
|
-
let entries;
|
|
51
|
-
try {
|
|
52
|
-
entries = readdirSync(root, { withFileTypes: true });
|
|
53
|
-
} catch (error) {
|
|
54
|
-
throw new Error(`Cannot read folder: ${error.message}`);
|
|
55
|
-
}
|
|
56
|
-
const repos = entries
|
|
57
|
-
.filter((entry) => entry.isDirectory() && existsSync(join(root, entry.name, ".git")))
|
|
58
|
-
.map((entry) => describeRepo(join(root, entry.name), entry.name))
|
|
59
|
-
.sort((left, right) => left.name.localeCompare(right.name));
|
|
60
|
-
return { root, repos };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function repoBaseName(repoPath) {
|
|
64
|
-
return String(repoPath).split(/[\\/]/).filter(Boolean).pop() || repoPath;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function listChildFolders(folder) {
|
|
68
|
-
const root = folder && existsSync(folder) ? folder : reposDefaultFolder();
|
|
69
|
-
const entries = readdirSync(root, { withFileTypes: true })
|
|
70
|
-
.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules")
|
|
71
|
-
.map((entry) => ({
|
|
72
|
-
name: entry.name,
|
|
73
|
-
path: join(root, entry.name),
|
|
74
|
-
isRepo: existsSync(join(root, entry.name, ".git"))
|
|
75
|
-
}))
|
|
76
|
-
.sort((left, right) => left.name.localeCompare(right.name));
|
|
77
|
-
const parent = join(root, "..");
|
|
78
|
-
return { path: root, parent: parent !== root ? parent : null, entries };
|
|
79
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
// Stack detection for repo cards: frameworks, languages/runtimes, test/infra/deploy badges.
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { INFRA_SERVICES } from "../infra/infra-registry.js";
|
|
5
|
-
import { depMatches, depsFromManifest } from "../infra/infra.js";
|
|
6
|
-
import { repoInventory } from "./discover.inventory.js";
|
|
7
|
-
|
|
8
|
-
// Web/app frameworks worth surfacing on the repo card, per ecosystem. token → display name; first
|
|
9
|
-
// match (in array order) wins, so list server frameworks before generic UI libs. Versions come from
|
|
10
|
-
// the manifest's declared range (not the installed lockfile — close enough for "which version").
|
|
11
|
-
const FRAMEWORKS = {
|
|
12
|
-
node: [
|
|
13
|
-
["@nestjs/core", "NestJS"], ["express", "Express"], ["fastify", "Fastify"], ["koa", "Koa"],
|
|
14
|
-
["@hapi/hapi", "Hapi"], ["hapi", "Hapi"], ["restify", "Restify"], ["hono", "Hono"],
|
|
15
|
-
["@adonisjs/core", "AdonisJS"], ["@feathersjs/feathers", "Feathers"], ["sails", "Sails"],
|
|
16
|
-
["next", "Next.js"], ["nuxt", "Nuxt"], ["@sveltejs/kit", "SvelteKit"], ["@remix-run/server-runtime", "Remix"],
|
|
17
|
-
["@angular/core", "Angular"], ["react", "React"], ["vue", "Vue"], ["svelte", "Svelte"],
|
|
18
|
-
],
|
|
19
|
-
python: [
|
|
20
|
-
["django", "Django"], ["fastapi", "FastAPI"], ["flask", "Flask"], ["sanic", "Sanic"],
|
|
21
|
-
["tornado", "Tornado"], ["aiohttp", "aiohttp"], ["falcon", "Falcon"], ["bottle", "Bottle"],
|
|
22
|
-
],
|
|
23
|
-
go: [
|
|
24
|
-
["github.com/gin-gonic/gin", "Gin"], ["github.com/labstack/echo", "Echo"], ["github.com/gofiber/fiber", "Fiber"],
|
|
25
|
-
["github.com/go-chi/chi", "Chi"], ["github.com/gorilla/mux", "Gorilla"], ["github.com/beego/beego", "Beego"],
|
|
26
|
-
],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// "^5.2.0" / "~4.18" / "v1.9.1" / ">=2,<3" / "==4.2" → "5.2" (major.minor, range operators stripped).
|
|
30
|
-
export function cleanVersion(raw) {
|
|
31
|
-
const m = String(raw || "").match(/(\d+)(?:\.(\d+))?/);
|
|
32
|
-
return m ? (m[2] != null ? `${m[1]}.${m[2]}` : m[1]) : "";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Read a manifest and return the first framework {name, version} it declares. Cheap: one file read.
|
|
36
|
-
export function detectFramework(dir, runtime) {
|
|
37
|
-
const read = (file) => { try { return readFileSync(join(dir, file), "utf8"); } catch { return ""; } };
|
|
38
|
-
const list = FRAMEWORKS[runtime];
|
|
39
|
-
if (!list) return null;
|
|
40
|
-
if (runtime === "node") {
|
|
41
|
-
let pkg;
|
|
42
|
-
try { pkg = JSON.parse(read("package.json")); } catch { return null; }
|
|
43
|
-
const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
|
|
44
|
-
for (const [tok, label] of list) if (deps[tok] != null) return { name: label, version: cleanVersion(deps[tok]) };
|
|
45
|
-
} else if (runtime === "python") {
|
|
46
|
-
const text = (read("requirements.txt") + "\n" + read("pyproject.toml") + "\n" + read("Pipfile")).toLowerCase();
|
|
47
|
-
for (const [tok, label] of list) {
|
|
48
|
-
const m = text.match(new RegExp(`(?:^|[\\s"'\\[])${tok}\\s*[~^>=<! ]*\\s*([0-9][0-9.]*)`, "m"));
|
|
49
|
-
if (m || new RegExp(`(?:^|[\\s"'\\[])${tok}(?:$|[\\s"'\\],~^>=<])`, "m").test(text)) return { name: label, version: m ? cleanVersion(m[1]) : "" };
|
|
50
|
-
}
|
|
51
|
-
} else if (runtime === "go") {
|
|
52
|
-
const text = read("go.mod");
|
|
53
|
-
for (const [tok, label] of list) {
|
|
54
|
-
const m = text.match(new RegExp(`${tok.replace(/[.\\]/g, "\\$&")}(?:/v\\d+)?\\s+v([0-9][0-9.]*)`));
|
|
55
|
-
if (m) return { name: label, version: cleanVersion(m[1]) };
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function readRootFile(dir, file) {
|
|
62
|
-
try {
|
|
63
|
-
return readFileSync(join(dir, file), "utf8");
|
|
64
|
-
} catch {
|
|
65
|
-
return "";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function readPackage(dir) {
|
|
70
|
-
try {
|
|
71
|
-
return JSON.parse(readRootFile(dir, "package.json"));
|
|
72
|
-
} catch {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function packageDeps(pkg, includeDev = true) {
|
|
78
|
-
if (!pkg || typeof pkg !== "object") return {};
|
|
79
|
-
return {
|
|
80
|
-
...(pkg.dependencies || {}),
|
|
81
|
-
...(pkg.optionalDependencies || {}),
|
|
82
|
-
...(pkg.peerDependencies || {}),
|
|
83
|
-
...(includeDev ? pkg.devDependencies || {} : {})
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function manifestDeps(dir) {
|
|
88
|
-
const out = new Set();
|
|
89
|
-
for (const file of [
|
|
90
|
-
"package.json", "go.mod", "go.sum", "requirements.txt", "constraints.txt", "pyproject.toml",
|
|
91
|
-
"Pipfile", "Cargo.toml", "pom.xml", "build.gradle", "build.gradle.kts", "composer.json", "Gemfile"
|
|
92
|
-
]) {
|
|
93
|
-
if (!existsSync(join(dir, file))) continue;
|
|
94
|
-
for (const dep of depsFromManifest(file, readRootFile(dir, file))) out.add(dep);
|
|
95
|
-
}
|
|
96
|
-
return out;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function addBadge(list, seen, id, label, extra = {}) {
|
|
100
|
-
if (!id || seen.has(id)) return;
|
|
101
|
-
seen.add(id);
|
|
102
|
-
list.push({ id, label, ...extra });
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function infraDisplayName(service) {
|
|
106
|
-
const names = {
|
|
107
|
-
postgres: "Postgres",
|
|
108
|
-
mysql: "MySQL",
|
|
109
|
-
mariadb: "MariaDB",
|
|
110
|
-
sqlserver: "SQL Server",
|
|
111
|
-
sqlite: "SQLite",
|
|
112
|
-
mongodb: "MongoDB",
|
|
113
|
-
dynamodb: "DynamoDB",
|
|
114
|
-
elasticsearch: "Elastic",
|
|
115
|
-
clickhouse: "ClickHouse",
|
|
116
|
-
influxdb: "InfluxDB",
|
|
117
|
-
timescaledb: "Timescale",
|
|
118
|
-
redis: "Redis",
|
|
119
|
-
valkey: "Valkey",
|
|
120
|
-
memcached: "Memcached",
|
|
121
|
-
kafka: "Kafka",
|
|
122
|
-
rabbitmq: "RabbitMQ",
|
|
123
|
-
"gcp-pubsub": "Pub/Sub",
|
|
124
|
-
"azure-servicebus": "Service Bus",
|
|
125
|
-
keycloak: "Keycloak",
|
|
126
|
-
"firebase-auth": "Firebase Auth",
|
|
127
|
-
"oidc-generic": "OIDC",
|
|
128
|
-
"azure-blob": "Azure Blob"
|
|
129
|
-
};
|
|
130
|
-
return names[service.id] || String(service.name || service.id || "").replace(/_/g, " ").replace(/\b\w/g, (m) => m.toUpperCase());
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function detectInfraBadges(prodDeps) {
|
|
134
|
-
const badges = [];
|
|
135
|
-
const seen = new Set();
|
|
136
|
-
const visibleKinds = new Set(["db", "ts", "cache", "queue", "cloud"]);
|
|
137
|
-
for (const service of INFRA_SERVICES) {
|
|
138
|
-
if (!visibleKinds.has(service.kind)) continue;
|
|
139
|
-
const hit = (service.deps || []).some((token) => [...prodDeps].some((dep) => depMatches(dep, token)));
|
|
140
|
-
if (hit) addBadge(badges, seen, service.id, infraDisplayName(service), { kind: service.kind });
|
|
141
|
-
}
|
|
142
|
-
return badges;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function detectTestBadges({ dir, pkg, inventory, allDeps }) {
|
|
146
|
-
const badges = [];
|
|
147
|
-
const seen = new Set();
|
|
148
|
-
const deps = new Set(Object.keys(allDeps || {}).map((x) => x.toLowerCase()));
|
|
149
|
-
const scripts = Object.values(pkg?.scripts || {}).join("\n").toLowerCase();
|
|
150
|
-
const hasDep = (...names) => names.some((name) => deps.has(name.toLowerCase()));
|
|
151
|
-
const hasFile = (re) => [...(inventory.files || [])].some((file) => re.test(file));
|
|
152
|
-
const hasScript = (re) => re.test(scripts);
|
|
153
|
-
|
|
154
|
-
if (hasDep("@playwright/test", "playwright") || hasFile(/(^|\/)playwright\.config\.[cm]?[jt]s$/) || hasScript(/\bplaywright\b/)) {
|
|
155
|
-
addBadge(badges, seen, "playwright", "Playwright", { kind: "e2e" });
|
|
156
|
-
}
|
|
157
|
-
if (hasDep("vitest") || hasFile(/(^|\/)vitest\.config\.[cm]?[jt]s$/) || hasScript(/\bvitest\b/)) {
|
|
158
|
-
addBadge(badges, seen, "vitest", "Vitest", { kind: "unit" });
|
|
159
|
-
}
|
|
160
|
-
if (hasDep("jest", "@jest/globals", "ts-jest") || hasFile(/(^|\/)jest\.config\.[cm]?[jt]s$/) || hasScript(/\bjest\b/)) {
|
|
161
|
-
addBadge(badges, seen, "jest", "Jest", { kind: "unit" });
|
|
162
|
-
}
|
|
163
|
-
if (hasDep("cypress") || hasFile(/(^|\/)cypress\.config\.[cm]?[jt]s$/) || hasScript(/\bcypress\b/)) {
|
|
164
|
-
addBadge(badges, seen, "cypress", "Cypress", { kind: "e2e" });
|
|
165
|
-
}
|
|
166
|
-
if (hasDep("mocha") || hasScript(/\bmocha\b/)) addBadge(badges, seen, "mocha", "Mocha", { kind: "unit" });
|
|
167
|
-
if (hasDep("ava") || hasScript(/\bava\b/)) addBadge(badges, seen, "ava", "AVA", { kind: "unit" });
|
|
168
|
-
if (hasDep("pytest") || existsSync(join(dir, "pytest.ini")) || hasFile(/(^|\/)test_.*\.py$/)) {
|
|
169
|
-
addBadge(badges, seen, "pytest", "pytest", { kind: "unit" });
|
|
170
|
-
}
|
|
171
|
-
if (existsSync(join(dir, "go.mod")) && hasFile(/_test\.go$/)) addBadge(badges, seen, "go-test", "go test", { kind: "unit" });
|
|
172
|
-
if (existsSync(join(dir, "Cargo.toml")) && hasFile(/(^|\/)tests\/.*\.rs$/)) addBadge(badges, seen, "cargo-test", "cargo test", { kind: "unit" });
|
|
173
|
-
return badges;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Deployment / infra-as-code tooling, detected by file presence. inventory.files is a lowercased,
|
|
177
|
-
// "/"-joined recursive path list (vendored/build dirs already skipped), so a repo's Dockerfile,
|
|
178
|
-
// skaffold.yaml, k8s manifests, helm chart or *.tf light up even when nested.
|
|
179
|
-
function detectDeployBadges(inventory) {
|
|
180
|
-
const badges = [];
|
|
181
|
-
const seen = new Set();
|
|
182
|
-
const files = [...(inventory.files || [])];
|
|
183
|
-
const hasFile = (re) => files.some((file) => re.test(file));
|
|
184
|
-
if (hasFile(/(^|\/)(dockerfile|containerfile)(\.[\w.-]+)?$/) || hasFile(/\.dockerfile$/)) addBadge(badges, seen, "docker", "Docker", { kind: "container" });
|
|
185
|
-
if (hasFile(/(^|\/)(docker-)?compose(\.[\w.-]+)?\.ya?ml$/)) addBadge(badges, seen, "compose", "Compose", { kind: "container" });
|
|
186
|
-
if (hasFile(/(^|\/)skaffold(\.[\w.-]+)?\.ya?ml$/)) addBadge(badges, seen, "skaffold", "Skaffold", { kind: "deploy" });
|
|
187
|
-
if (hasFile(/(^|\/)chart\.ya?ml$/) || hasFile(/(^|\/)helm\//)) addBadge(badges, seen, "helm", "Helm", { kind: "orchestration" });
|
|
188
|
-
if (hasFile(/(^|\/)kustomization\.ya?ml$/) || hasFile(/(^|\/)(k8s|kubernetes|manifests)\/.*\.ya?ml$/)) addBadge(badges, seen, "kubernetes", "K8s", { kind: "orchestration" });
|
|
189
|
-
if (hasFile(/(^|\/)[^/]+\.tf$/)) addBadge(badges, seen, "terraform", "Terraform", { kind: "iac" });
|
|
190
|
-
return badges;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export function detectRepoStack(dir, inventory = repoInventory(dir)) {
|
|
194
|
-
const has = (file) => existsSync(join(dir, file));
|
|
195
|
-
const pkg = readPackage(dir);
|
|
196
|
-
const allDeps = packageDeps(pkg, true);
|
|
197
|
-
const prodDeps = manifestDeps(dir);
|
|
198
|
-
const ext = inventory.ext || {};
|
|
199
|
-
const languages = [];
|
|
200
|
-
const runtimes = [];
|
|
201
|
-
const seenLang = new Set();
|
|
202
|
-
const seenRuntime = new Set();
|
|
203
|
-
const depNames = new Set(Object.keys(allDeps).map((x) => x.toLowerCase()));
|
|
204
|
-
|
|
205
|
-
const hasTs = !!(ext[".ts"] || ext[".tsx"] || has("tsconfig.json") || depNames.has("typescript"));
|
|
206
|
-
const hasJs = !!(ext[".js"] || ext[".jsx"] || ext[".mjs"] || ext[".cjs"] || pkg);
|
|
207
|
-
if (hasTs) addBadge(languages, seenLang, "typescript", "TS", { title: "TypeScript" });
|
|
208
|
-
if (hasJs) addBadge(languages, seenLang, "javascript", "JS", { title: "JavaScript" });
|
|
209
|
-
if (ext[".go"] || has("go.mod")) addBadge(languages, seenLang, "go", "Go", { title: "Go" });
|
|
210
|
-
if (ext[".py"] || has("requirements.txt") || has("pyproject.toml") || has("setup.py") || has("Pipfile")) addBadge(languages, seenLang, "python", "Python");
|
|
211
|
-
if (ext[".java"] || has("pom.xml") || has("build.gradle")) addBadge(languages, seenLang, "java", "Java");
|
|
212
|
-
if (ext[".rs"] || has("Cargo.toml")) addBadge(languages, seenLang, "rust", "Rust");
|
|
213
|
-
if (ext[".php"] || has("composer.json")) addBadge(languages, seenLang, "php", "PHP");
|
|
214
|
-
if (ext[".rb"] || has("Gemfile")) addBadge(languages, seenLang, "ruby", "Ruby");
|
|
215
|
-
|
|
216
|
-
if (has("bun.lock") || has("bun.lockb") || has("bunfig.toml")) addBadge(runtimes, seenRuntime, "bun", "Bun");
|
|
217
|
-
if (has("deno.json") || has("deno.jsonc") || has("deno.lock")) addBadge(runtimes, seenRuntime, "deno", "Deno");
|
|
218
|
-
if (pkg && !seenRuntime.has("bun") && !seenRuntime.has("deno")) addBadge(runtimes, seenRuntime, "node", "Node");
|
|
219
|
-
|
|
220
|
-
return {
|
|
221
|
-
languages,
|
|
222
|
-
runtimes,
|
|
223
|
-
tests: detectTestBadges({ dir, pkg, inventory, allDeps }),
|
|
224
|
-
infra: detectInfraBadges(prodDeps),
|
|
225
|
-
deploy: detectDeployBadges(inventory)
|
|
226
|
-
};
|
|
227
|
-
}
|
package/src/scan/search.core.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Orchestrator for the cross-repo search: picks ripgrep → git grep → pure-Node engine per the
|
|
2
|
-
// configured engine and delegates to the matching module. Split out of search.js.
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
|
-
import { resolve } from "node:path";
|
|
5
|
-
import { resolveRg, rgSearch } from "./search.rg.js";
|
|
6
|
-
import { gitSearch } from "./search.git.js";
|
|
7
|
-
import { nodeSearch } from "./search.node.js";
|
|
8
|
-
|
|
9
|
-
// repos: array of absolute repo paths; mode: "content" | "filename"; engine/rgPath: see resolveRg.
|
|
10
|
-
// Returns { ok, engine, truncated, results:[{repo, path, line, column, preview}] }.
|
|
11
|
-
export async function searchAcrossRepos({ repos, query, mode = "content", cap = 300, engine = "auto", rgPath = "", gitPath = "" } = {}) {
|
|
12
|
-
const roots = [...new Set((Array.isArray(repos) ? repos : []).filter((p) => p && existsSync(p)).map((p) => resolve(p)))].sort((a, b) => b.length - a.length);
|
|
13
|
-
const q = String(query || "");
|
|
14
|
-
if (!roots.length || q.trim().length < 2) return { ok: true, engine: "none", truncated: false, results: [] };
|
|
15
|
-
const rg = await resolveRg(engine, rgPath);
|
|
16
|
-
const git = (engine === "auto" || engine === "git") ? String(gitPath || "").trim() || "git" : "";
|
|
17
|
-
try {
|
|
18
|
-
if (rg) return await rgSearch(rg, roots, q, mode, cap);
|
|
19
|
-
if (git) return await gitSearch(git, roots, q, mode, cap);
|
|
20
|
-
return await nodeSearch(roots, q, mode, cap);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
return { ok: false, error: error.message, engine: rg ? "ripgrep" : git ? "git-grep" : "node-fallback", results: [] };
|
|
23
|
-
}
|
|
24
|
-
}
|