@ai-primitives-hub/cli 0.2.1 → 0.2.2-next.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/README.md +26 -1
- package/dist/commands/bundle-build.d.ts +1 -0
- package/dist/commands/bundle-build.d.ts.map +1 -1
- package/dist/commands/bundle-build.js +23 -4
- package/dist/commands/bundle-build.js.map +1 -1
- package/dist/commands/collection-affected.d.ts.map +1 -1
- package/dist/commands/collection-affected.js +1 -34
- package/dist/commands/collection-affected.js.map +1 -1
- package/dist/commands/collection-validate.d.ts +15 -2
- package/dist/commands/collection-validate.d.ts.map +1 -1
- package/dist/commands/collection-validate.js +42 -4
- package/dist/commands/collection-validate.js.map +1 -1
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +37 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/explain.d.ts.map +1 -1
- package/dist/commands/explain.js +54 -4
- package/dist/commands/explain.js.map +1 -1
- package/dist/commands/hub-replicate.d.ts +1 -0
- package/dist/commands/hub-replicate.d.ts.map +1 -1
- package/dist/commands/hub-replicate.js +16 -5
- package/dist/commands/hub-replicate.js.map +1 -1
- package/dist/commands/hub-scoped-governance.d.ts +21 -0
- package/dist/commands/hub-scoped-governance.d.ts.map +1 -0
- package/dist/commands/hub-scoped-governance.js +74 -0
- package/dist/commands/hub-scoped-governance.js.map +1 -0
- package/dist/commands/hub.d.ts +6 -0
- package/dist/commands/hub.d.ts.map +1 -1
- package/dist/commands/hub.js +68 -0
- package/dist/commands/hub.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +3 -10
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts +18 -10
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +472 -253
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/plugin-create.d.ts.map +1 -1
- package/dist/commands/plugin-create.js +72 -43
- package/dist/commands/plugin-create.js.map +1 -1
- package/dist/commands/profile.d.ts +42 -4
- package/dist/commands/profile.d.ts.map +1 -1
- package/dist/commands/profile.js +739 -144
- package/dist/commands/profile.js.map +1 -1
- package/dist/commands/registry.d.ts.map +1 -1
- package/dist/commands/registry.js +5 -0
- package/dist/commands/registry.js.map +1 -1
- package/dist/commands/security-rate.d.ts +26 -0
- package/dist/commands/security-rate.d.ts.map +1 -0
- package/dist/commands/security-rate.js +281 -0
- package/dist/commands/security-rate.js.map +1 -0
- package/dist/commands/security-scan.d.ts +40 -0
- package/dist/commands/security-scan.d.ts.map +1 -0
- package/dist/commands/security-scan.js +395 -0
- package/dist/commands/security-scan.js.map +1 -0
- package/dist/commands/status.d.ts +18 -11
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +42 -33
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/uninstall.d.ts +2 -9
- package/dist/commands/uninstall.d.ts.map +1 -1
- package/dist/commands/uninstall.js +413 -147
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.d.ts +1 -2
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +379 -56
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validation-governance.d.ts +27 -0
- package/dist/commands/validation-governance.d.ts.map +1 -0
- package/dist/commands/validation-governance.js +92 -0
- package/dist/commands/validation-governance.js.map +1 -0
- package/dist/doctor/diagnostics.d.ts +72 -5
- package/dist/doctor/diagnostics.d.ts.map +1 -1
- package/dist/doctor/diagnostics.js +94 -40
- package/dist/doctor/diagnostics.js.map +1 -1
- package/dist/doctor/primitive-driver.d.ts +24 -0
- package/dist/doctor/primitive-driver.d.ts.map +1 -0
- package/dist/doctor/primitive-driver.js +162 -0
- package/dist/doctor/primitive-driver.js.map +1 -0
- package/dist/doctor/primitives-text.d.ts +27 -0
- package/dist/doctor/primitives-text.d.ts.map +1 -0
- package/dist/doctor/primitives-text.js +131 -0
- package/dist/doctor/primitives-text.js.map +1 -0
- package/dist/doctor/primitives.d.ts +24 -0
- package/dist/doctor/primitives.d.ts.map +1 -0
- package/dist/doctor/primitives.js +101 -0
- package/dist/doctor/primitives.js.map +1 -0
- package/dist/framework/error.d.ts +19 -18
- package/dist/framework/error.d.ts.map +1 -1
- package/dist/framework/error.js +78 -22
- package/dist/framework/error.js.map +1 -1
- package/dist/framework/index.d.ts +3 -1
- package/dist/framework/index.d.ts.map +1 -1
- package/dist/framework/index.js +42 -1
- package/dist/framework/index.js.map +1 -1
- package/dist/framework/install-record.d.ts +555 -0
- package/dist/framework/install-record.d.ts.map +1 -0
- package/dist/framework/install-record.js +968 -0
- package/dist/framework/install-record.js.map +1 -0
- package/dist/framework/target.d.ts +9 -12
- package/dist/framework/target.d.ts.map +1 -1
- package/dist/framework/target.js +9 -12
- package/dist/framework/target.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-scan.d.ts","sourceRoot":"","sources":["../../src/commands/security-scan.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,OAAO,EAER,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,OAAO,EAER,MAAM,cAAc,CAAC;AA+PtB,qBAAa,mBAAoB,SAAQ,OAAO;IAC9C,gBAAuB,KAAK,aAA0B;IACtD,gBAAuB,KAAK,4BAUzB;IAEI,MAAM,qBAAgC;IACtC,GAAG,uBAAyB;IAC5B,WAAW,UAA2C;IACtD,OAAO,uBAA6B;IACpC,eAAe,UAAgD;IAC/D,QAAQ,uBAA8B;IACtC,eAAe,qBAAuC;IACtD,kBAAkB,UAAmD;IACrE,gBAAgB,UAAiD;IACjE,MAAM,SAAsC;IAC5C,UAAU,UAA0C;IACpD,EAAE,UAAiC;IACnC,WAAW,qBAAmC;IAC9C,oBAAoB,qBAA4C;IAChE,kBAAkB,qBAA2C;IAC7D,UAAU,qBAAkC;IAC5C,cAAc,qBAAsC;IACpD,eAAe,qBAAuC;IACtD,UAAU,SAAqD;IAC/D,eAAe,SAAgD;IAC/D,QAAQ,qBAAgC;IACxC,YAAY,qBAAqC;IACjD,aAAa,qBAAsC;IACnD,QAAQ,qBAAgC;IACxC,WAAW,qBAAmC;IAC9C,OAAO,qBAA8B;IACrC,MAAM,UAAqC;IAC3C,KAAK,UAAoC;IAEzC,IAAI,WAAgC;IACpC,cAAc,EAAG;QAAE,GAAG,EAAE,OAAO,CAAA;KAAE,CAAC;IAE5B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAwGxC"}
|
|
@@ -0,0 +1,395 @@
|
|
|
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.SecurityScanCommand = void 0;
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
|
+
const app_1 = require("@ai-primitives-hub/app");
|
|
39
|
+
const core_1 = require("@ai-primitives-hub/core");
|
|
40
|
+
const infra_1 = require("@ai-primitives-hub/infra");
|
|
41
|
+
const clipanion_1 = require("clipanion");
|
|
42
|
+
const framework_1 = require("../framework");
|
|
43
|
+
const SEVERITIES = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'INFO'];
|
|
44
|
+
const severitySelection = (minimum) => {
|
|
45
|
+
if (minimum === undefined) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const index = SEVERITIES.indexOf(minimum.toUpperCase());
|
|
49
|
+
return index === -1 ? undefined : SEVERITIES.slice(0, index + 1);
|
|
50
|
+
};
|
|
51
|
+
const reportJson = (result) => `${JSON.stringify({
|
|
52
|
+
scanner: 'ai-primitives-hub-security',
|
|
53
|
+
version: result.engine.version,
|
|
54
|
+
compatibility: result.compatibility,
|
|
55
|
+
scan_date: result.timing.startedAt,
|
|
56
|
+
complete: result.complete,
|
|
57
|
+
coverage: result.coverage,
|
|
58
|
+
policy: result.summary.policy,
|
|
59
|
+
errors: result.errors,
|
|
60
|
+
warnings: result.warnings,
|
|
61
|
+
scanned_files: result.coverage.scanned.map((file) => file.path),
|
|
62
|
+
ignored_files: result.coverage.ignored.map((file) => String(file.path)),
|
|
63
|
+
summary: {
|
|
64
|
+
total_findings: result.summary.active.total,
|
|
65
|
+
suppressed_findings: result.summary.suppressed.total,
|
|
66
|
+
by_severity: result.summary.active.bySeverity
|
|
67
|
+
},
|
|
68
|
+
findings: result.findings.map((finding) => ({
|
|
69
|
+
rule_id: finding.ruleId,
|
|
70
|
+
title: finding.title,
|
|
71
|
+
severity: finding.severity,
|
|
72
|
+
confidence: finding.confidence,
|
|
73
|
+
category: finding.category,
|
|
74
|
+
file: finding.file,
|
|
75
|
+
line: finding.line,
|
|
76
|
+
section: finding.section,
|
|
77
|
+
related_ast: finding.relatedAst,
|
|
78
|
+
vulnerable_content: finding.vulnerableContent,
|
|
79
|
+
risk: finding.risk,
|
|
80
|
+
owasp: finding.owasp,
|
|
81
|
+
fingerprint: finding.fingerprint,
|
|
82
|
+
instance_fingerprint: finding.fingerprint,
|
|
83
|
+
canonical_fingerprint: finding.canonicalFingerprint,
|
|
84
|
+
recommended_fix: finding.recommendedFix,
|
|
85
|
+
is_info_control: finding.isInfoControl ?? false
|
|
86
|
+
})),
|
|
87
|
+
references: { rule_pack: result.engine.rulePackId }
|
|
88
|
+
}, null, 2)}\n`;
|
|
89
|
+
const escapeMarkdown = (value) => value
|
|
90
|
+
.replaceAll(/[\r\n]/g, ' ')
|
|
91
|
+
.replaceAll('&', '&')
|
|
92
|
+
.replaceAll(/[\\`*_{}[\]()<>#!|~]/g, '\\$&')
|
|
93
|
+
.replaceAll('@', '@');
|
|
94
|
+
const backtickLength = (value) => [...value.matchAll(/`+/g)].reduce((maximum, match) => Math.max(maximum, match[0].length), 0);
|
|
95
|
+
const inlineCode = (value) => {
|
|
96
|
+
const text = value.replaceAll(/[\r\n]/g, ' ');
|
|
97
|
+
const length = backtickLength(text);
|
|
98
|
+
const fence = '`'.repeat(length + 1);
|
|
99
|
+
return length === 0 ? `${fence}${text}${fence}` : `${fence} ${text} ${fence}`;
|
|
100
|
+
};
|
|
101
|
+
const reportMarkdown = (result) => {
|
|
102
|
+
const lines = [
|
|
103
|
+
'# AI Primitives Hub Security Report',
|
|
104
|
+
'',
|
|
105
|
+
`- Complete: **${String(result.complete)}**`,
|
|
106
|
+
`- Compatibility: **${result.compatibility}**`,
|
|
107
|
+
`- Files scanned: **${String(result.coverage.scanned.length)}**`,
|
|
108
|
+
`- Suppressed findings: **${String(result.summary.suppressed.total)}**`,
|
|
109
|
+
'',
|
|
110
|
+
'## Findings',
|
|
111
|
+
''
|
|
112
|
+
];
|
|
113
|
+
if (result.findings.length === 0) {
|
|
114
|
+
lines.push('No active findings.');
|
|
115
|
+
}
|
|
116
|
+
for (const finding of result.findings) {
|
|
117
|
+
const location = `${finding.file.replaceAll(/[\r\n]/g, ' ')}${finding.line === undefined ? '' : `:${String(finding.line)}`}`;
|
|
118
|
+
const suggestions = [
|
|
119
|
+
`${finding.fingerprint} # Fingerprint — ${finding.ruleId} — ${location}`,
|
|
120
|
+
`${finding.canonicalFingerprint} # Canonical fingerprint — ${finding.ruleId} — ${location}`
|
|
121
|
+
].join('\n');
|
|
122
|
+
const fence = '`'.repeat(Math.max(3, backtickLength(suggestions) + 1));
|
|
123
|
+
lines.push(`### ${finding.severity} — ${escapeMarkdown(finding.title)}`, '', `- Rule: \`${finding.ruleId}\``, `- Location: ${inlineCode(finding.file)}${finding.line === undefined ? '' : ` — line ${String(finding.line)}`}`, `- Confidence: ${finding.confidence}`, ...(finding.relatedAst === undefined ? [] : [`- Related AST: ${escapeMarkdown(finding.relatedAst)}`]), `- Vulnerable content: ${inlineCode(finding.vulnerableContent)}`, ...(finding.owasp === undefined ? [] : [`- OWASP: [${finding.owasp.id} — ${finding.owasp.name}](${finding.owasp.url})`]), `- Risk: ${escapeMarkdown(finding.risk)}`, `- Recommended fix: ${escapeMarkdown(finding.recommendedFix)}`, '', '**.markdown.ignore suggestions:**', '', `${fence}text`, suggestions, fence, '');
|
|
124
|
+
}
|
|
125
|
+
if (result.warnings.length > 0) {
|
|
126
|
+
lines.push('## Warnings', '', ...result.warnings.map((warning) => `- ${escapeMarkdown(warning)}`), '');
|
|
127
|
+
}
|
|
128
|
+
if (result.errors.length > 0) {
|
|
129
|
+
lines.push('## Coverage Errors', '', ...result.errors.map((error) => `- ${error.code}: ${escapeMarkdown(error.message)}`), '');
|
|
130
|
+
}
|
|
131
|
+
return `${lines.join('\n')}\n`;
|
|
132
|
+
};
|
|
133
|
+
const displayPath = (value, roots) => {
|
|
134
|
+
if (!path.isAbsolute(value)) {
|
|
135
|
+
return value.replaceAll('\\', '/');
|
|
136
|
+
}
|
|
137
|
+
for (const root of roots) {
|
|
138
|
+
const relative = path.relative(path.resolve(root), value);
|
|
139
|
+
if (relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative))) {
|
|
140
|
+
return relative.replaceAll('\\', '/') || path.basename(value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return path.basename(value);
|
|
144
|
+
};
|
|
145
|
+
const presentResult = (result, roots) => ({
|
|
146
|
+
...result,
|
|
147
|
+
coverage: {
|
|
148
|
+
...result.coverage,
|
|
149
|
+
ignored: result.coverage.ignored.map((file) => ({ ...file, path: displayPath(file.path, roots), source: file.source === undefined ? undefined : displayPath(file.source, roots) })),
|
|
150
|
+
skipped: result.coverage.skipped.map((file) => ({ ...file, path: displayPath(file.path, roots) })),
|
|
151
|
+
errors: result.coverage.errors.map((error) => ({ ...error, path: error.path === undefined ? undefined : displayPath(error.path, roots) }))
|
|
152
|
+
},
|
|
153
|
+
errors: result.errors.map((error) => ({ ...error, path: error.path === undefined ? undefined : displayPath(error.path, roots) })),
|
|
154
|
+
suppressed: result.suppressed.map((item) => ({ ...item, sourcePath: displayPath(item.sourcePath, roots) }))
|
|
155
|
+
});
|
|
156
|
+
const findingLocation = (finding) => `${finding.file}${finding.line === undefined ? '' : `:${String(finding.line)}`}`;
|
|
157
|
+
const textResult = (result, quiet) => {
|
|
158
|
+
const counts = result.summary.active.bySeverity;
|
|
159
|
+
const lines = [
|
|
160
|
+
`Security scan ${result.complete ? 'complete' : 'incomplete'}`,
|
|
161
|
+
`Scanned ${String(result.coverage.scanned.length)} file(s)`,
|
|
162
|
+
`Suppressed: ${String(result.summary.suppressed.total)}`,
|
|
163
|
+
`Policy (${result.summary.policy.failOn}): ${result.summary.policy.passed ? 'passed' : 'failed'}`,
|
|
164
|
+
...result.errors.map((error) => `Error: ${error.code} — ${error.message}`)
|
|
165
|
+
];
|
|
166
|
+
if (!quiet) {
|
|
167
|
+
if (result.findings.length === 0) {
|
|
168
|
+
lines.push('Findings: none');
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
lines.push('Findings:');
|
|
172
|
+
for (const finding of result.findings) {
|
|
173
|
+
lines.push(`- [${finding.severity}] ${finding.ruleId} — ${finding.title} (${findingLocation(finding)})`, ` Risk: ${finding.risk}`, ` Fix: ${finding.recommendedFix}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
lines.splice(2, 0, ...SEVERITIES.map((severity) => `${severity}: ${String(counts[severity] ?? 0)}`));
|
|
178
|
+
return `${lines.join('\n')}\n`;
|
|
179
|
+
};
|
|
180
|
+
class StaticCancellation {
|
|
181
|
+
cancelled = false;
|
|
182
|
+
throwIfCancelled() {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const writeReports = async (ctx, result, outputDirectory, outputName, reportJsonPath, reportMarkdownPath, overwrite) => {
|
|
187
|
+
const destinations = [];
|
|
188
|
+
if (outputDirectory === undefined) {
|
|
189
|
+
if (reportJsonPath !== undefined) {
|
|
190
|
+
destinations.push({ path: reportJsonPath, contents: reportJson(result) });
|
|
191
|
+
}
|
|
192
|
+
if (reportMarkdownPath !== undefined) {
|
|
193
|
+
destinations.push({ path: reportMarkdownPath, contents: reportMarkdown(result) });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
const name = path.basename(outputName);
|
|
198
|
+
if (name !== outputName || name === '.' || name === '..') {
|
|
199
|
+
throw new Error('Invalid --output-name; expected a basename');
|
|
200
|
+
}
|
|
201
|
+
destinations.push({ path: path.join(outputDirectory, `${name}.json`), contents: reportJson(result) }, { path: path.join(outputDirectory, `${name}.md`), contents: reportMarkdown(result) });
|
|
202
|
+
}
|
|
203
|
+
const store = new infra_1.SecureAtomicSecurityReportStore(true);
|
|
204
|
+
for (const destination of destinations) {
|
|
205
|
+
if (Buffer.byteLength(destination.contents, 'utf8') > infra_1.SECURITY_DEFAULT_LIMITS.maxReportBytes) {
|
|
206
|
+
throw new Error('SECURITY.LIMIT_EXCEEDED: maximum report bytes exceeded');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
for (const destination of destinations) {
|
|
210
|
+
await store.write({ destination: path.resolve(ctx.cwd(), destination.path), contents: destination.contents, overwrite: overwrite === 'replace' ? 'replace' : 'never' });
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const parsePositive = (value, fallback, duration = false) => {
|
|
214
|
+
if (value === undefined) {
|
|
215
|
+
return fallback;
|
|
216
|
+
}
|
|
217
|
+
const match = /^(\d+)(ms|s|m)?$/i.exec(value);
|
|
218
|
+
if (match === null) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
const amount = Number(match[1]);
|
|
222
|
+
const unit = match[2]?.toLowerCase();
|
|
223
|
+
if (!duration && unit !== undefined) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
const multiplier = unit === 'm' ? 60_000 : (unit === 's' ? 1000 : 1);
|
|
227
|
+
const parsed = amount * multiplier;
|
|
228
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
229
|
+
};
|
|
230
|
+
const validLimits = (limits) => Object.values(limits).every((value) => value !== undefined && Number.isSafeInteger(value) && value > 0)
|
|
231
|
+
&& limits.timeoutMs !== undefined && limits.timeoutMs <= 2_147_483_647;
|
|
232
|
+
const writeNdjson = (ctx, result) => {
|
|
233
|
+
const records = [
|
|
234
|
+
{ type: 'scan.header', schemaVersion: 1, scanId: result.scanId, complete: result.complete },
|
|
235
|
+
...result.findings.map((finding) => ({ type: 'scan.finding', schemaVersion: 1, scanId: result.scanId, finding })),
|
|
236
|
+
...result.errors.map((error) => ({ type: 'scan.coverage-error', schemaVersion: 1, scanId: result.scanId, error })),
|
|
237
|
+
{ type: 'scan.summary', schemaVersion: 1, scanId: result.scanId, summary: result.summary }
|
|
238
|
+
];
|
|
239
|
+
for (const record of records) {
|
|
240
|
+
ctx.stdout.write(`${JSON.stringify(record)}\n`);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
class SecurityScanCommand extends clipanion_1.Command {
|
|
244
|
+
static paths = [['security', 'scan']];
|
|
245
|
+
static usage = clipanion_1.Command.Usage({
|
|
246
|
+
description: 'Scan AI primitive files for security findings.',
|
|
247
|
+
category: 'Security',
|
|
248
|
+
details: `
|
|
249
|
+
Usage: ai-primitives-hub security scan [PATH...]
|
|
250
|
+
|
|
251
|
+
Use --ci for fail-closed CI defaults, --ignore-trust none to disable repository suppressions,
|
|
252
|
+
and --fail-on HIGH to gate on high or critical findings. Secret evidence is redacted by default.
|
|
253
|
+
Reports are opt-in with --report-json, --report-markdown, or --output-directory.
|
|
254
|
+
`
|
|
255
|
+
});
|
|
256
|
+
output = clipanion_1.Option.String('-o,--output');
|
|
257
|
+
ext = clipanion_1.Option.Array('--ext');
|
|
258
|
+
noRecursive = clipanion_1.Option.Boolean('--no-recursive', false);
|
|
259
|
+
exclude = clipanion_1.Option.Array('--exclude');
|
|
260
|
+
includeDocFiles = clipanion_1.Option.Boolean('--include-doc-files', false);
|
|
261
|
+
severity = clipanion_1.Option.Array('--severity');
|
|
262
|
+
minimumSeverity = clipanion_1.Option.String('--minimum-severity');
|
|
263
|
+
includeLlmControls = clipanion_1.Option.Boolean('--include-llm-controls', false);
|
|
264
|
+
skipInfoControls = clipanion_1.Option.Boolean('--skip-info-controls', false);
|
|
265
|
+
failOn = clipanion_1.Option.String('--fail-on', 'HIGH');
|
|
266
|
+
allowEmpty = clipanion_1.Option.Boolean('--allow-empty', false);
|
|
267
|
+
ci = clipanion_1.Option.Boolean('--ci', false);
|
|
268
|
+
ignoreTrust = clipanion_1.Option.String('--ignore-trust');
|
|
269
|
+
baselineSuppressions = clipanion_1.Option.String('--baseline-suppressions');
|
|
270
|
+
baselineFileIgnore = clipanion_1.Option.String('--baseline-file-ignore');
|
|
271
|
+
reportJson = clipanion_1.Option.String('--report-json');
|
|
272
|
+
reportMarkdown = clipanion_1.Option.String('--report-markdown');
|
|
273
|
+
outputDirectory = clipanion_1.Option.String('--output-directory');
|
|
274
|
+
outputName = clipanion_1.Option.String('--output-name', 'security-report');
|
|
275
|
+
reportOverwrite = clipanion_1.Option.String('--report-overwrite', 'never');
|
|
276
|
+
maxFiles = clipanion_1.Option.String('--max-files');
|
|
277
|
+
maxFileBytes = clipanion_1.Option.String('--max-file-bytes');
|
|
278
|
+
maxTotalBytes = clipanion_1.Option.String('--max-total-bytes');
|
|
279
|
+
maxDepth = clipanion_1.Option.String('--max-depth');
|
|
280
|
+
maxFindings = clipanion_1.Option.String('--max-findings');
|
|
281
|
+
timeout = clipanion_1.Option.String('--timeout');
|
|
282
|
+
report = clipanion_1.Option.Boolean('--report', false);
|
|
283
|
+
quiet = clipanion_1.Option.Boolean('--quiet', false);
|
|
284
|
+
// eslint-disable-next-line new-cap -- Clipanion exposes Rest as a factory function with an uppercase name.
|
|
285
|
+
rest = clipanion_1.Option.Rest({ required: 0 });
|
|
286
|
+
commandContext;
|
|
287
|
+
async execute() {
|
|
288
|
+
const { ctx } = this.commandContext;
|
|
289
|
+
const output = (this.output ?? 'text').toLowerCase();
|
|
290
|
+
if (!['text', 'json', 'yaml', 'ndjson'].includes(output)) {
|
|
291
|
+
ctx.stderr.write(`Invalid --output value: ${String(this.output)}\n`);
|
|
292
|
+
return 64;
|
|
293
|
+
}
|
|
294
|
+
if (this.report && output !== 'text') {
|
|
295
|
+
ctx.stderr.write('--report can only be used with text output\n');
|
|
296
|
+
return 64;
|
|
297
|
+
}
|
|
298
|
+
if (this.outputDirectory !== undefined && (this.reportJson !== undefined || this.reportMarkdown !== undefined)) {
|
|
299
|
+
ctx.stderr.write('--output-directory cannot be combined with explicit report paths\n');
|
|
300
|
+
return 64;
|
|
301
|
+
}
|
|
302
|
+
if (this.reportOverwrite !== 'never' && this.reportOverwrite !== 'replace') {
|
|
303
|
+
ctx.stderr.write(`Invalid --report-overwrite value: ${this.reportOverwrite}\n`);
|
|
304
|
+
return 64;
|
|
305
|
+
}
|
|
306
|
+
const roots = (this.rest.length > 0 ? this.rest : ['.']).map((root) => path.resolve(ctx.cwd(), root));
|
|
307
|
+
const rawIgnoreTrust = this.ignoreTrust ?? (this.ci ? 'none' : 'repository');
|
|
308
|
+
if (rawIgnoreTrust !== 'repository' && rawIgnoreTrust !== 'none' && rawIgnoreTrust !== 'baseline') {
|
|
309
|
+
ctx.stderr.write(`Invalid --ignore-trust value: ${rawIgnoreTrust}\n`);
|
|
310
|
+
return 64;
|
|
311
|
+
}
|
|
312
|
+
const ignoreTrust = rawIgnoreTrust;
|
|
313
|
+
const rawFailOn = this.failOn.toUpperCase();
|
|
314
|
+
if (rawFailOn !== 'NONE' && rawFailOn !== 'ANY' && !SEVERITIES.includes(rawFailOn)) {
|
|
315
|
+
ctx.stderr.write(`Invalid --fail-on value: ${rawFailOn}\n`);
|
|
316
|
+
return 64;
|
|
317
|
+
}
|
|
318
|
+
const failOn = rawFailOn === 'NONE' ? 'none' : (rawFailOn === 'ANY' ? 'any' : rawFailOn);
|
|
319
|
+
const severityValues = this.severity ?? [];
|
|
320
|
+
const extensionValues = this.ext ?? [];
|
|
321
|
+
const excludeValues = this.exclude ?? [];
|
|
322
|
+
const selected = severityValues.length > 0
|
|
323
|
+
? severityValues.map((value) => value.toUpperCase())
|
|
324
|
+
: severitySelection(this.minimumSeverity);
|
|
325
|
+
if (selected?.some((severity) => !SEVERITIES.includes(severity))) {
|
|
326
|
+
ctx.stderr.write('Invalid --severity value\n');
|
|
327
|
+
return 64;
|
|
328
|
+
}
|
|
329
|
+
if (this.minimumSeverity !== undefined && severitySelection(this.minimumSeverity) === undefined) {
|
|
330
|
+
ctx.stderr.write(`Invalid --minimum-severity value: ${this.minimumSeverity}\n`);
|
|
331
|
+
return 64;
|
|
332
|
+
}
|
|
333
|
+
const request = {
|
|
334
|
+
roots,
|
|
335
|
+
extensions: extensionValues.length > 0 ? extensionValues : ['.md', '.markdown'],
|
|
336
|
+
recursive: !this.noRecursive,
|
|
337
|
+
excludes: excludeValues.length > 0 ? excludeValues : ['.git', 'node_modules'],
|
|
338
|
+
includeDocFiles: this.includeDocFiles,
|
|
339
|
+
ignoreTrust,
|
|
340
|
+
baselineSuppressionPath: this.baselineSuppressions === undefined ? undefined : path.resolve(ctx.cwd(), this.baselineSuppressions),
|
|
341
|
+
baselineFileIgnorePath: this.baselineFileIgnore === undefined ? undefined : path.resolve(ctx.cwd(), this.baselineFileIgnore)
|
|
342
|
+
};
|
|
343
|
+
const limits = {
|
|
344
|
+
...infra_1.SECURITY_DEFAULT_LIMITS,
|
|
345
|
+
maxFiles: parsePositive(this.maxFiles, infra_1.SECURITY_DEFAULT_LIMITS.maxFiles),
|
|
346
|
+
maxFileBytes: parsePositive(this.maxFileBytes, infra_1.SECURITY_DEFAULT_LIMITS.maxFileBytes),
|
|
347
|
+
maxTotalBytes: parsePositive(this.maxTotalBytes, infra_1.SECURITY_DEFAULT_LIMITS.maxTotalBytes),
|
|
348
|
+
maxDepth: parsePositive(this.maxDepth, infra_1.SECURITY_DEFAULT_LIMITS.maxDepth),
|
|
349
|
+
maxFindings: parsePositive(this.maxFindings, infra_1.SECURITY_DEFAULT_LIMITS.maxFindings),
|
|
350
|
+
timeoutMs: parsePositive(this.timeout, infra_1.SECURITY_DEFAULT_LIMITS.timeoutMs, true)
|
|
351
|
+
};
|
|
352
|
+
if (!validLimits(limits)) {
|
|
353
|
+
ctx.stderr.write('Security scan count and byte limits must be positive integers; only timeout accepts ms, s, or m suffixes and must not exceed 2147483647ms\n');
|
|
354
|
+
return 64;
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
357
|
+
const baseEngine = new core_1.RuleBasedSecurityScanEngine();
|
|
358
|
+
const result = await (0, app_1.runSecurityScan)({
|
|
359
|
+
input: new infra_1.NodeSecurityScanInput(),
|
|
360
|
+
engine: new infra_1.IsolatedSecurityScanEngine(baseEngine.descriptor, baseEngine.capabilities, limits.documentTimeoutMs),
|
|
361
|
+
clock: ctx.clock,
|
|
362
|
+
cancellation: new StaticCancellation(),
|
|
363
|
+
request,
|
|
364
|
+
scanOptions: { includeLlmControls: this.includeLlmControls, skipInfoControls: this.skipInfoControls, selectedSeverities: selected },
|
|
365
|
+
failOn,
|
|
366
|
+
limits
|
|
367
|
+
});
|
|
368
|
+
const visibleResult = presentResult(result, roots);
|
|
369
|
+
await writeReports(ctx, visibleResult, this.outputDirectory, this.outputName, this.reportJson, this.reportMarkdown, this.reportOverwrite);
|
|
370
|
+
if (output === 'ndjson') {
|
|
371
|
+
writeNdjson(ctx, visibleResult);
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
(0, framework_1.formatOutput)({
|
|
375
|
+
ctx, command: 'security.scan', output,
|
|
376
|
+
status: visibleResult.complete && visibleResult.summary.policy.passed ? 'ok' : 'warning',
|
|
377
|
+
data: visibleResult, textRenderer: (value) => textResult(value, this.quiet)
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
if (this.report) {
|
|
381
|
+
ctx.stdout.write(reportMarkdown(visibleResult));
|
|
382
|
+
}
|
|
383
|
+
if (!result.complete || (result.coverage.scanned.length === 0 && !this.allowEmpty)) {
|
|
384
|
+
return 65;
|
|
385
|
+
}
|
|
386
|
+
return result.summary.policy.passed ? 0 : 1;
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
ctx.stderr.write(`Security scan failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
390
|
+
return 74;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
exports.SecurityScanCommand = SecurityScanCommand;
|
|
395
|
+
//# sour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AAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;oBACxF,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC;iBAC5E,CAAC,CAAC;YACL,CAAC;YACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC;YAClD,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACnF,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACtG,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;;AArJH,kDAsJC"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ai-primitives-hub status` — show current configuration state at a glance.
|
|
3
|
+
*
|
|
4
|
+
* Reads targets, active hub, primitive index, and the install record to produce
|
|
5
|
+
* a concise dashboard without any network calls. Useful for verifying
|
|
6
|
+
* that a project is correctly configured before activating profiles.
|
|
7
|
+
*
|
|
8
|
+
* It lists one row per (bundle, tool) of the repository record, or of the user
|
|
9
|
+
* record when there is none; bundles only in an old file show under tool `unknown`.
|
|
10
|
+
* @module commands/status
|
|
11
|
+
*/
|
|
12
|
+
import { type StatusRow } from '@ai-primitives-hub/app';
|
|
13
|
+
import { type RecordLevel } from '@ai-primitives-hub/core';
|
|
1
14
|
import { Command, type CommandDefinition, type Context, type OutputFormat } from '../framework';
|
|
2
|
-
/** Bundle detail shown in verbose mode. */
|
|
3
|
-
export interface StatusBundle {
|
|
4
|
-
bundleId: string;
|
|
5
|
-
bundleVersion: string;
|
|
6
|
-
installedAt: string;
|
|
7
|
-
}
|
|
8
15
|
/** Status data shape returned to callers. */
|
|
9
16
|
export interface StatusData {
|
|
10
17
|
configPath: string | null;
|
|
@@ -20,11 +27,11 @@ export interface StatusData {
|
|
|
20
27
|
primitives: number;
|
|
21
28
|
path: string;
|
|
22
29
|
} | null;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
level: RecordLevel;
|
|
31
|
+
/** Record files read, plus the old file when it exists. */
|
|
32
|
+
records: string[];
|
|
33
|
+
/** One row per (bundle, tool), sorted. */
|
|
34
|
+
entries: StatusRow[];
|
|
28
35
|
}
|
|
29
36
|
/**
|
|
30
37
|
* Build the `status` command using defineCommand (for test compatibility).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EACL,OAAO,EACP,KAAK,iBAAiB,EACtB,KAAK,OAAO,EAMZ,KAAK,YAAY,EAOlB,MAAM,cAAc,CAAC;AAEtB,6CAA6C;AAC7C,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACnD,KAAK,EAAE,WAAW,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,0CAA0C;IAC1C,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAM;IAAE,MAAM,CAAC,EAAE,YAAY,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,KACtD,iBAQC,CAAC;AAEL;;GAEG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,gBAAuB,KAAK,aAAgB;IAE5C,gBAAuB,KAAK,4BAsBzB;IAEI,MAAM,qBAAgC;IACtC,OAAO,UAAsC;IAC7C,cAAc,EAAG;QAAE,GAAG,EAAE,OAAO,CAAA;KAAE,CAAC;IAE5B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAIxC"}
|
package/dist/commands/status.js
CHANGED
|
@@ -4,18 +4,16 @@ exports.StatusCommand = exports.createStatusCommand = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* `ai-primitives-hub status` — show current configuration state at a glance.
|
|
6
6
|
*
|
|
7
|
-
* Reads targets, active hub, primitive index, and
|
|
7
|
+
* Reads targets, active hub, primitive index, and the install record to produce
|
|
8
8
|
* a concise dashboard without any network calls. Useful for verifying
|
|
9
9
|
* that a project is correctly configured before activating profiles.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* branch's array-of-entries schema — `LockfileBundleEntry` has no `target` field
|
|
14
|
-
* since repository-scope entries always write to `.github/` regardless of which
|
|
15
|
-
* IDE target nominally triggered the install (see `app/stores/json-lockfile-store.ts`).
|
|
11
|
+
* It lists one row per (bundle, tool) of the repository record, or of the user
|
|
12
|
+
* record when there is none; bundles only in an old file show under tool `unknown`.
|
|
16
13
|
* @module commands/status
|
|
17
14
|
*/
|
|
18
15
|
const app_1 = require("@ai-primitives-hub/app");
|
|
16
|
+
const core_1 = require("@ai-primitives-hub/core");
|
|
19
17
|
const infra_1 = require("@ai-primitives-hub/infra");
|
|
20
18
|
const framework_1 = require("../framework");
|
|
21
19
|
/**
|
|
@@ -75,7 +73,7 @@ exports.StatusCommand = StatusCommand;
|
|
|
75
73
|
* Core status logic shared by both command variants.
|
|
76
74
|
* @param ctx CLI context.
|
|
77
75
|
* @param fmt Output format.
|
|
78
|
-
* @param verbose Whether
|
|
76
|
+
* @param verbose Whether text output shows each entry's record file.
|
|
79
77
|
* @returns Exit code.
|
|
80
78
|
*/
|
|
81
79
|
async function runStatus(ctx, fmt, verbose) {
|
|
@@ -90,20 +88,7 @@ async function runStatus(ctx, fmt, verbose) {
|
|
|
90
88
|
]);
|
|
91
89
|
const indexPath = (0, infra_1.defaultIndexFile)(ctx.env);
|
|
92
90
|
const indexStats = (0, infra_1.tryLoadIndex)(indexPath);
|
|
93
|
-
const
|
|
94
|
-
const lockfile = lockPath === null ? null : await (0, app_1.readLockfile)(lockPath, ctx.fs);
|
|
95
|
-
let lockfileData = null;
|
|
96
|
-
if (lockfile !== null && lockPath !== null) {
|
|
97
|
-
const bundleIds = Object.keys(lockfile.bundles);
|
|
98
|
-
lockfileData = { entries: bundleIds.length, path: lockPath };
|
|
99
|
-
if (verbose) {
|
|
100
|
-
lockfileData.bundles = bundleIds.map((bundleId) => ({
|
|
101
|
-
bundleId,
|
|
102
|
-
bundleVersion: lockfile.bundles[bundleId].version,
|
|
103
|
-
installedAt: lockfile.bundles[bundleId].installedAt
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
91
|
+
const record = await readRecordStatus(ctx);
|
|
107
92
|
const data = {
|
|
108
93
|
configPath: configPath ?? null,
|
|
109
94
|
userTargetsPath: userTargetsExists ? userPaths.userTargets : null,
|
|
@@ -113,7 +98,7 @@ async function runStatus(ctx, fmt, verbose) {
|
|
|
113
98
|
index: indexStats === null
|
|
114
99
|
? null
|
|
115
100
|
: { primitives: indexStats.search({}).total, path: indexPath },
|
|
116
|
-
|
|
101
|
+
...record
|
|
117
102
|
};
|
|
118
103
|
(0, framework_1.formatOutput)({
|
|
119
104
|
ctx,
|
|
@@ -121,7 +106,7 @@ async function runStatus(ctx, fmt, verbose) {
|
|
|
121
106
|
output: fmt,
|
|
122
107
|
status: 'ok',
|
|
123
108
|
data,
|
|
124
|
-
textRenderer: renderStatusText
|
|
109
|
+
textRenderer: (d) => renderStatusText(d, verbose)
|
|
125
110
|
});
|
|
126
111
|
return 0;
|
|
127
112
|
}
|
|
@@ -138,6 +123,27 @@ async function runStatus(ctx, fmt, verbose) {
|
|
|
138
123
|
return 1;
|
|
139
124
|
}
|
|
140
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* The `level`, `records` and `entries` fields for `status`, with old-file-only bundles under tool `unknown`.
|
|
128
|
+
* @param ctx CLI context.
|
|
129
|
+
* @throws {RegistryError} A `RECORD.*` error naming the file.
|
|
130
|
+
*/
|
|
131
|
+
async function readRecordStatus(ctx) {
|
|
132
|
+
const prepared = await (0, framework_1.prepareRecordSelection)(ctx, { command: 'status' });
|
|
133
|
+
const { selection, service, fs } = prepared;
|
|
134
|
+
const entries = await service.listEntries(selection.locations);
|
|
135
|
+
const old = await (0, framework_1.oldFileOnlyBundles)(ctx, prepared);
|
|
136
|
+
if (old !== undefined) {
|
|
137
|
+
for (const bundleId of old.bundleIds) {
|
|
138
|
+
entries.push({
|
|
139
|
+
bundleId, tool: core_1.UNKNOWN_TOOL_NAME, level: selection.level, version: old.lock.bundles[bundleId].version, record: old.lockPath, needsReinstall: false
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
entries.sort((left, right) => (0, core_1.compareCodeUnits)(left.bundleId, right.bundleId) || (0, core_1.compareCodeUnits)(left.tool, right.tool));
|
|
144
|
+
const { level, records } = await (0, framework_1.recordOutputFields)(selection, fs, old?.lockPath);
|
|
145
|
+
return { level, records, entries };
|
|
146
|
+
}
|
|
141
147
|
/**
|
|
142
148
|
* Read list of hub IDs from the hubs directory.
|
|
143
149
|
* @param hubsDir Path to hubs directory.
|
|
@@ -199,24 +205,26 @@ function renderIndexLine(index) {
|
|
|
199
205
|
}
|
|
200
206
|
return `index ${index.primitives} primitives [${index.path}]\n`;
|
|
201
207
|
}
|
|
202
|
-
function
|
|
203
|
-
if (
|
|
208
|
+
function renderEntryLines(d, verbose) {
|
|
209
|
+
if (d.entries.length === 0) {
|
|
204
210
|
return ['lockfile (none)\n'];
|
|
205
211
|
}
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
212
|
+
const bundles = new Set(d.entries.map((row) => row.bundleId)).size;
|
|
213
|
+
const lines = [`lockfile ${bundles} bundle${bundles === 1 ? '' : 's'} installed (${d.entries.length} entr${d.entries.length === 1 ? 'y' : 'ies'})\n`];
|
|
214
|
+
for (const row of d.entries) {
|
|
215
|
+
const flag = row.needsReinstall ? ' needs reinstall' : '';
|
|
216
|
+
const hub = row.hubId === undefined ? '' : ` hub ${row.hubId}`;
|
|
217
|
+
lines.push(` ${row.bundleId}@${row.version} (${row.tool})${hub}${flag}${verbose ? ` [${row.record}]` : ''}\n`);
|
|
211
218
|
}
|
|
212
219
|
return lines;
|
|
213
220
|
}
|
|
214
221
|
/**
|
|
215
|
-
* Render status as human-readable text.
|
|
222
|
+
* Render status as human-readable text: one line per (bundle, tool) and the `Record:` line.
|
|
216
223
|
* @param d Status data.
|
|
224
|
+
* @param verbose Whether to show each row's record file.
|
|
217
225
|
* @returns Rendered text.
|
|
218
226
|
*/
|
|
219
|
-
function renderStatusText(d) {
|
|
227
|
+
function renderStatusText(d, verbose) {
|
|
220
228
|
return [
|
|
221
229
|
'ai-primitives-hub status\n',
|
|
222
230
|
'─'.repeat(40) + '\n',
|
|
@@ -224,7 +232,8 @@ function renderStatusText(d) {
|
|
|
224
232
|
renderTargetsLine(d.targets),
|
|
225
233
|
...renderHubLines(d.activeHubId, d.hubs),
|
|
226
234
|
renderIndexLine(d.index),
|
|
227
|
-
...
|
|
235
|
+
...renderEntryLines(d, verbose),
|
|
236
|
+
(0, framework_1.renderRecordLine)({ level: d.level, records: d.records })
|
|
228
237
|
].join('');
|
|
229
238
|
}
|
|
230
239
|
//# sourceMappingURL=status.js.map
|