@swarmdo/cli 1.12.0 → 1.13.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.
@@ -0,0 +1,57 @@
1
+ /**
2
+ * License MCP Tool
3
+ *
4
+ * Let an agent audit dependency licenses in-session — e.g. before adding a
5
+ * package or approving a release — against an allow/deny policy. Deterministic;
6
+ * shares the pure engine in ../license/license.ts with the CLI command. The
7
+ * caller passes the dependency list (name/version/license), so no fs access.
8
+ */
9
+ import { auditLicenses } from '../license/license.js';
10
+ const licenseCheckTool = {
11
+ name: 'license_check',
12
+ description: 'Audit a dependency list against a license allow/deny policy. Returns violations (denied, not-allowed, or unknown license) plus a license breakdown. Use before adding a dependency or approving a release to keep a permissive tree clean. Deterministic; pass the deps directly.',
13
+ category: 'license',
14
+ tags: ['license', 'compliance', 'supply-chain', 'ci'],
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ deps: {
19
+ type: 'array',
20
+ description: 'dependencies to audit',
21
+ items: {
22
+ type: 'object',
23
+ properties: {
24
+ name: { type: 'string' },
25
+ version: { type: 'string' },
26
+ license: { type: 'string', description: 'SPDX id/expression (e.g. MIT, "(MIT OR Apache-2.0)", or UNKNOWN)' },
27
+ },
28
+ required: ['name', 'license'],
29
+ },
30
+ },
31
+ allow: { type: 'array', items: { type: 'string' }, description: 'SPDX allowlist; a dep must match at least one' },
32
+ deny: { type: 'array', items: { type: 'string' }, description: 'SPDX denylist; any match is a violation' },
33
+ allowUnknown: { type: 'boolean', description: 'treat UNKNOWN as allowed even under an allowlist', default: false },
34
+ },
35
+ required: ['deps'],
36
+ },
37
+ handler: async (params) => {
38
+ if (!Array.isArray(params.deps))
39
+ return { error: true, message: 'deps[] is required' };
40
+ const deps = params.deps
41
+ .filter((d) => !!d && typeof d === 'object')
42
+ .map((d) => ({
43
+ name: String(d.name ?? '?'),
44
+ version: String(d.version ?? '0.0.0'),
45
+ license: String(d.license ?? 'UNKNOWN'),
46
+ }));
47
+ const policy = {
48
+ allow: Array.isArray(params.allow) ? params.allow.filter((x) => typeof x === 'string') : undefined,
49
+ deny: Array.isArray(params.deny) ? params.deny.filter((x) => typeof x === 'string') : undefined,
50
+ allowUnknown: params.allowUnknown === true,
51
+ };
52
+ const report = auditLicenses(deps, policy);
53
+ return { clean: report.violations.length === 0, total: report.total, violations: report.violations, byLicense: report.byLicense };
54
+ },
55
+ };
56
+ export const licenseTools = [licenseCheckTool];
57
+ //# sourceMappingURL=license-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license-tools.js","sourceRoot":"","sources":["../../../src/mcp-tools/license-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,aAAa,EAAuC,MAAM,uBAAuB,CAAC;AAE3F,MAAM,gBAAgB,GAAY;IAChC,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,mRAAmR;IACrR,QAAQ,EAAE,SAAS;IACnB,IAAI,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,CAAC;IACrD,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,uBAAuB;gBACpC,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACxB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kEAAkE,EAAE;qBAC7G;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;iBAC9B;aACF;YACD,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,+CAA+C,EAAE;YACjH,IAAI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