@andesyte-oss/cli 0.3.1 → 0.3.3
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/doctor.d.ts +2 -2
- package/dist/doctor.js +53 -9
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +5 -5
package/dist/doctor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { probeSemgrep } from "@andesyte-oss/scanner-core";
|
|
2
2
|
export type DoctorStatus = "ready" | "unavailable" | "attention";
|
|
3
3
|
export interface DoctorCapability {
|
|
4
4
|
status: DoctorStatus;
|
|
@@ -20,7 +20,7 @@ export interface DoctorReport {
|
|
|
20
20
|
}
|
|
21
21
|
export interface DoctorDeps {
|
|
22
22
|
nodeVersion?: string;
|
|
23
|
-
|
|
23
|
+
probeSemgrep?: typeof probeSemgrep;
|
|
24
24
|
rules?: () => {
|
|
25
25
|
name: string;
|
|
26
26
|
version: string;
|
package/dist/doctor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
|
-
import {
|
|
3
|
+
import { probeSemgrep } from "@andesyte-oss/scanner-core";
|
|
4
4
|
import { ruleset } from "@andesyte-oss/security-rules";
|
|
5
5
|
import { VERSION } from "./version.js";
|
|
6
6
|
const execFileAsync = promisify(execFile);
|
|
@@ -63,6 +63,21 @@ async function defaultLatestVersion(packageName) {
|
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Names the semgrep failure precisely. The old detail re-listed every
|
|
68
|
+
* prerequisite, so a probe timeout read as "install Semgrep" to a user who
|
|
69
|
+
* already had it (issue #23).
|
|
70
|
+
*/
|
|
71
|
+
function describeSemgrepProbeFailure(probe) {
|
|
72
|
+
switch (probe.outcome) {
|
|
73
|
+
case "timeout":
|
|
74
|
+
return `Semgrep probe timed out after ${probe.timeoutMs}ms (${probe.attempts} attempt${probe.attempts === 1 ? "" : "s"}) — Semgrep may still be installed; engine startup can exceed the probe budget under load. Raise it, e.g. ANDESYTE_SEMGREP_PROBE_TIMEOUT_MS=60000, and re-run`;
|
|
75
|
+
case "error":
|
|
76
|
+
return `Semgrep could not be started: ${probe.detail ?? "unknown failure"}`;
|
|
77
|
+
default:
|
|
78
|
+
return "Semgrep was not found on PATH — install it, e.g. `uv tool install semgrep` or `pipx install semgrep`";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
66
81
|
/**
|
|
67
82
|
* Reports prerequisites for the CLI's independently usable capabilities. The
|
|
68
83
|
* default path performs local probes only. Update checking is explicit because
|
|
@@ -72,8 +87,8 @@ export async function collectDoctor(root, options = {}, deps = {}) {
|
|
|
72
87
|
const command = deps.command ?? defaultCommand;
|
|
73
88
|
const installedNode = deps.nodeVersion ?? process.versions.node;
|
|
74
89
|
const nodeReady = versionAtLeast(installedNode, MINIMUM_NODE);
|
|
75
|
-
const [
|
|
76
|
-
(deps.
|
|
90
|
+
const [semgrepProbe, git, gitRepository, ghAuthenticated] = await Promise.all([
|
|
91
|
+
(deps.probeSemgrep ?? probeSemgrep)(),
|
|
77
92
|
command("git", ["--version"]),
|
|
78
93
|
command("git", ["-C", root, "rev-parse", "--is-inside-work-tree"]),
|
|
79
94
|
command("gh", ["auth", "status"]),
|
|
@@ -90,6 +105,40 @@ export async function collectDoctor(root, options = {}, deps = {}) {
|
|
|
90
105
|
? await (deps.latestVersion ?? defaultLatestVersion)("@andesyte-oss/cli")
|
|
91
106
|
: null;
|
|
92
107
|
const updateStatus = !updatesChecked || latest === VERSION ? "current" : latest ? "available" : "unavailable";
|
|
108
|
+
const rulesReady = packagedRules !== null && packagedRules.rulePaths.length > 0;
|
|
109
|
+
const codeScanCapability = (() => {
|
|
110
|
+
if (nodeReady && rulesReady && semgrepProbe.version !== null) {
|
|
111
|
+
// Probe timing on the READY line makes a marginal probe budget visible
|
|
112
|
+
// before it bites (issue #23).
|
|
113
|
+
return {
|
|
114
|
+
status: "ready",
|
|
115
|
+
detail: `Semgrep ${semgrepProbe.version} (probe ${(semgrepProbe.durationMs / 1000).toFixed(1)}s)`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// Name the failing components, never a re-list of all of them: a detail
|
|
119
|
+
// that repeats every prerequisite sends users hunting an install problem
|
|
120
|
+
// they do not have (issue #23).
|
|
121
|
+
const failures = [];
|
|
122
|
+
if (!nodeReady) {
|
|
123
|
+
failures.push(`a supported Node.js runtime (found ${installedNode}, need >=${MINIMUM_NODE.join(".")})`);
|
|
124
|
+
}
|
|
125
|
+
if (!rulesReady)
|
|
126
|
+
failures.push("packaged security rules");
|
|
127
|
+
if (semgrepProbe.version === null)
|
|
128
|
+
failures.push(describeSemgrepProbeFailure(semgrepProbe));
|
|
129
|
+
// A probe timeout means the engine is probably installed but unconfirmed;
|
|
130
|
+
// that is an "attention" state, not a missing install — but only when
|
|
131
|
+
// nothing else is definitively broken.
|
|
132
|
+
return {
|
|
133
|
+
status: semgrepProbe.version === null &&
|
|
134
|
+
semgrepProbe.outcome === "timeout" &&
|
|
135
|
+
nodeReady &&
|
|
136
|
+
rulesReady
|
|
137
|
+
? "attention"
|
|
138
|
+
: "unavailable",
|
|
139
|
+
detail: failures.join("; "),
|
|
140
|
+
};
|
|
141
|
+
})();
|
|
93
142
|
const capabilities = {
|
|
94
143
|
runtime: nodeReady
|
|
95
144
|
? { status: "ready", detail: `Node.js ${installedNode}` }
|
|
@@ -103,12 +152,7 @@ export async function collectDoctor(root, options = {}, deps = {}) {
|
|
|
103
152
|
detail: `${packagedRules.name} ${packagedRules.version}, ${packagedRules.rulePaths.length} rules file(s)`,
|
|
104
153
|
}
|
|
105
154
|
: { status: "unavailable", detail: "packaged security rules are unavailable" },
|
|
106
|
-
code_scan:
|
|
107
|
-
? { status: "ready", detail: `Semgrep ${semgrep}` }
|
|
108
|
-
: {
|
|
109
|
-
status: "unavailable",
|
|
110
|
-
detail: "requires a supported Node.js runtime, packaged rules, and Semgrep on PATH",
|
|
111
|
-
},
|
|
155
|
+
code_scan: codeScanCapability,
|
|
112
156
|
dependency_scan: nodeReady
|
|
113
157
|
? {
|
|
114
158
|
status: "ready",
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,8 @@ export declare class UsageError extends Error {
|
|
|
26
26
|
export declare function parseArgs(argv: string[], cwd: string): ParsedArgs;
|
|
27
27
|
/**
|
|
28
28
|
* Exit codes:
|
|
29
|
-
* 0 complete and clean — nothing found, nothing skipped, no
|
|
29
|
+
* 0 complete and clean — nothing found, nothing unaccounted skipped, no
|
|
30
|
+
* errors (a `covered_by_lockfile` skip is accounted coverage, not a gap)
|
|
30
31
|
* 1 findings present
|
|
31
32
|
* 2 invalid invocation
|
|
32
33
|
* 3 result not trustworthy: failed, partial, or complete with errors
|
package/dist/index.js
CHANGED
|
@@ -241,7 +241,8 @@ function requirePositiveInteger(value, flag) {
|
|
|
241
241
|
}
|
|
242
242
|
/**
|
|
243
243
|
* Exit codes:
|
|
244
|
-
* 0 complete and clean — nothing found, nothing skipped, no
|
|
244
|
+
* 0 complete and clean — nothing found, nothing unaccounted skipped, no
|
|
245
|
+
* errors (a `covered_by_lockfile` skip is accounted coverage, not a gap)
|
|
245
246
|
* 1 findings present
|
|
246
247
|
* 2 invalid invocation
|
|
247
248
|
* 3 result not trustworthy: failed, partial, or complete with errors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andesyte-oss/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Andesyte local security CLI and MCP server: check code and dependencies without uploading source.",
|
|
5
5
|
"homepage": "https://andesyte.com",
|
|
6
6
|
"author": "Andesyte <lewis@andesyte.com>",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
45
|
-
"zod": "^
|
|
46
|
-
"@andesyte-oss/security-rules": "0.3.
|
|
47
|
-
"@andesyte-oss/scanner-core": "0.3.
|
|
44
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
45
|
+
"zod": "^4.6.7",
|
|
46
|
+
"@andesyte-oss/security-rules": "0.3.3",
|
|
47
|
+
"@andesyte-oss/scanner-core": "0.3.3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc -p tsconfig.json && chmod +x dist/index.js && node scripts/copy-skill.mjs",
|