sf-agentpmd 0.1.0 → 0.1.1
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/NOTICE +7 -5
- package/dist/commands/agentpmd/analyze.js +4141 -109
- package/dist/commands/agentpmd/analyze.js.map +7 -1
- package/dist/commands/agentpmd/install-skill.js +27 -30
- package/dist/commands/agentpmd/install-skill.js.map +7 -1
- package/dist/index.js +4155 -3
- package/dist/index.js.map +7 -1
- package/oclif.manifest.json +1 -1
- package/package.json +7 -8
- package/dist/analyzer/action-references.d.ts +0 -21
- package/dist/analyzer/action-references.js +0 -130
- package/dist/analyzer/action-references.js.map +0 -1
- package/dist/analyzer/analyze.d.ts +0 -43
- package/dist/analyzer/analyze.js +0 -222
- package/dist/analyzer/analyze.js.map +0 -1
- package/dist/analyzer/apex-analyze.d.ts +0 -14
- package/dist/analyzer/apex-analyze.js +0 -60
- package/dist/analyzer/apex-analyze.js.map +0 -1
- package/dist/analyzer/apex-complexity.d.ts +0 -27
- package/dist/analyzer/apex-complexity.js +0 -133
- package/dist/analyzer/apex-complexity.js.map +0 -1
- package/dist/analyzer/apex-parse.d.ts +0 -39
- package/dist/analyzer/apex-parse.js +0 -32
- package/dist/analyzer/apex-parse.js.map +0 -1
- package/dist/analyzer/apex-resolve.d.ts +0 -32
- package/dist/analyzer/apex-resolve.js +0 -59
- package/dist/analyzer/apex-resolve.js.map +0 -1
- package/dist/analyzer/complexity.d.ts +0 -30
- package/dist/analyzer/complexity.js +0 -126
- package/dist/analyzer/complexity.js.map +0 -1
- package/dist/analyzer/parse.d.ts +0 -51
- package/dist/analyzer/parse.js +0 -143
- package/dist/analyzer/parse.js.map +0 -1
- package/dist/analyzer/project.d.ts +0 -12
- package/dist/analyzer/project.js +0 -51
- package/dist/analyzer/project.js.map +0 -1
- package/dist/analyzer/types.d.ts +0 -76
- package/dist/analyzer/types.js +0 -2
- package/dist/analyzer/types.js.map +0 -1
- package/dist/commands/agentpmd/analyze.d.ts +0 -20
- package/dist/commands/agentpmd/install-skill.d.ts +0 -11
- package/dist/index.d.ts +0 -3
- package/dist/renderers/csv.d.ts +0 -6
- package/dist/renderers/csv.js +0 -78
- package/dist/renderers/csv.js.map +0 -1
- package/dist/renderers/index.d.ts +0 -8
- package/dist/renderers/index.js +0 -25
- package/dist/renderers/index.js.map +0 -1
- package/dist/renderers/markdown.d.ts +0 -12
- package/dist/renderers/markdown.js +0 -233
- package/dist/renderers/markdown.js.map +0 -1
- package/dist/renderers/options.d.ts +0 -20
- package/dist/renderers/options.js +0 -2
- package/dist/renderers/options.js.map +0 -1
- package/dist/renderers/sarif.d.ts +0 -3
- package/dist/renderers/sarif.js +0 -131
- package/dist/renderers/sarif.js.map +0 -1
- package/dist/renderers/text.d.ts +0 -3
- package/dist/renderers/text.js +0 -243
- package/dist/renderers/text.js.map +0 -1
- package/vendor/agentscript-parser-javascript/dist/cst-node.d.ts +0 -83
- package/vendor/agentscript-parser-javascript/dist/cst-node.js +0 -238
- package/vendor/agentscript-parser-javascript/dist/errors.d.ts +0 -34
- package/vendor/agentscript-parser-javascript/dist/errors.js +0 -74
- package/vendor/agentscript-parser-javascript/dist/expressions.d.ts +0 -36
- package/vendor/agentscript-parser-javascript/dist/expressions.js +0 -682
- package/vendor/agentscript-parser-javascript/dist/highlighter.d.ts +0 -24
- package/vendor/agentscript-parser-javascript/dist/highlighter.js +0 -260
- package/vendor/agentscript-parser-javascript/dist/index.d.ts +0 -29
- package/vendor/agentscript-parser-javascript/dist/index.js +0 -35
- package/vendor/agentscript-parser-javascript/dist/lexer.d.ts +0 -60
- package/vendor/agentscript-parser-javascript/dist/lexer.js +0 -630
- package/vendor/agentscript-parser-javascript/dist/parse-mapping.d.ts +0 -46
- package/vendor/agentscript-parser-javascript/dist/parse-mapping.js +0 -549
- package/vendor/agentscript-parser-javascript/dist/parse-sequence.d.ts +0 -10
- package/vendor/agentscript-parser-javascript/dist/parse-sequence.js +0 -118
- package/vendor/agentscript-parser-javascript/dist/parse-statements.d.ts +0 -15
- package/vendor/agentscript-parser-javascript/dist/parse-statements.js +0 -519
- package/vendor/agentscript-parser-javascript/dist/parse-templates.d.ts +0 -15
- package/vendor/agentscript-parser-javascript/dist/parse-templates.js +0 -323
- package/vendor/agentscript-parser-javascript/dist/parser.d.ts +0 -65
- package/vendor/agentscript-parser-javascript/dist/parser.js +0 -163
- package/vendor/agentscript-parser-javascript/dist/recovery.d.ts +0 -51
- package/vendor/agentscript-parser-javascript/dist/recovery.js +0 -199
- package/vendor/agentscript-parser-javascript/dist/token.d.ts +0 -58
- package/vendor/agentscript-parser-javascript/dist/token.js +0 -62
- package/vendor/agentscript-parser-javascript/package.json +0 -19
- package/vendor/agentscript-types/dist/comment.d.ts +0 -11
- package/vendor/agentscript-types/dist/comment.js +0 -10
- package/vendor/agentscript-types/dist/cst.d.ts +0 -7
- package/vendor/agentscript-types/dist/cst.js +0 -8
- package/vendor/agentscript-types/dist/diagnostic.d.ts +0 -34
- package/vendor/agentscript-types/dist/diagnostic.js +0 -23
- package/vendor/agentscript-types/dist/index.d.ts +0 -9
- package/vendor/agentscript-types/dist/index.js +0 -10
- package/vendor/agentscript-types/dist/position.d.ts +0 -11
- package/vendor/agentscript-types/dist/position.js +0 -16
- package/vendor/agentscript-types/dist/syntax-node.d.ts +0 -39
- package/vendor/agentscript-types/dist/syntax-node.js +0 -8
- package/vendor/agentscript-types/package.json +0 -15
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
const KIND_LABEL = {
|
|
2
|
-
after_reasoning: 'after_reasoning',
|
|
3
|
-
available_when: 'available_when',
|
|
4
|
-
before_reasoning: 'before_reasoning',
|
|
5
|
-
other: 'other',
|
|
6
|
-
reasoning_instructions: 'reasoning.instructions',
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Renders a GFM Markdown report with a Mermaid bar chart at the top
|
|
10
|
-
* (agent CC vs Apex CC per bundle) followed by per-bundle and per-class
|
|
11
|
-
* drilldown tables. Designed to be portable into PR descriptions, gists,
|
|
12
|
-
* Slack snippets, and whitepaper appendices.
|
|
13
|
-
*
|
|
14
|
-
* Palette is whitepaper § 1: Reasoning hot (#a82820), Conversation amber
|
|
15
|
-
* (#c4942a), Deterministic green (#6b8c52), Scaffolding cool gray (#9aa5ad).
|
|
16
|
-
*/
|
|
17
|
-
export function renderMarkdown(report) {
|
|
18
|
-
const lines = [];
|
|
19
|
-
lines.push('# AgentForce PMD — Cyclomatic Complexity (McCabe)', '', 'Per the categorization rule § 7, CC is reported by the standard ' +
|
|
20
|
-
'McCabe convention used in SonarQube / PMD / Checkstyle for the ' +
|
|
21
|
-
'relevant language.', '');
|
|
22
|
-
if (report.files.length === 0) {
|
|
23
|
-
lines.push('_(no `.agent` files found)_');
|
|
24
|
-
return lines.join('\n');
|
|
25
|
-
}
|
|
26
|
-
// ── CC by location chart ──────────────────────────────────────────
|
|
27
|
-
lines.push('## CC by location', '', renderMermaid(report), '', `| | AgentScript | Apex | Combined |\n` +
|
|
28
|
-
`| --- | ---: | ---: | ---: |\n` +
|
|
29
|
-
`| **Totals** | ${report.totalComplexity} | ${report.totalApexComplexity} | ${report.totalComplexity + report.totalApexComplexity} |`, '', '## Per-bundle (`.agent` files)', '');
|
|
30
|
-
for (const f of report.files) {
|
|
31
|
-
lines.push(`### \`${f.path}\` — CC = ${f.fileComplexity}`, '');
|
|
32
|
-
if (f.procedures.length === 0) {
|
|
33
|
-
lines.push('_(no procedure-bearing scopes)_');
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
lines.push('| Scope | Procedure | CC | Contributors |', '| --- | --- | ---: | --- |');
|
|
37
|
-
for (const p of f.procedures) {
|
|
38
|
-
lines.push(`| ${escapeCell(p.scope)} | ${KIND_LABEL[p.kind]} | ${p.complexity} | ${escapeCell(breakdownProc(p.contributors))} |`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
lines.push('');
|
|
42
|
-
if (f.declarations.length > 0) {
|
|
43
|
-
lines.push('**Action references**', '', '| Action | Target kind | Target | Uses |', '| --- | --- | --- | ---: |');
|
|
44
|
-
const usage = countReferences(f);
|
|
45
|
-
for (const d of f.declarations) {
|
|
46
|
-
const used = usage.get(d.name) ?? 0;
|
|
47
|
-
lines.push(`| \`${d.name}\` | ${d.targetKind} | ${d.target ?? '_n/a_'} | ${used} |`);
|
|
48
|
-
}
|
|
49
|
-
const undeclared = listUndeclaredRefs(f);
|
|
50
|
-
if (undeclared.length > 0) {
|
|
51
|
-
lines.push('', 'Referenced but not declared in-file: ' + undeclared.map(u => `\`${u}\``).join(', '));
|
|
52
|
-
}
|
|
53
|
-
lines.push('');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// ── Apex backing logic ────────────────────────────────────────────
|
|
57
|
-
if (report.apexClasses.length > 0 || report.unresolvedApexTargets.length > 0) {
|
|
58
|
-
lines.push('## Apex backing logic', '');
|
|
59
|
-
for (const cls of report.apexClasses) {
|
|
60
|
-
lines.push(`### \`${cls.path}\` — class CC = ${cls.classComplexity}`, '', `Referenced by: ${cls.referencedBy.map(r => `\`${r}\``).join(', ') || '_none_'}`, '');
|
|
61
|
-
if (cls.methods.length === 0) {
|
|
62
|
-
lines.push('_(no methods with bodies)_');
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
lines.push('| Method | CC | Contributors |', '| --- | ---: | --- |');
|
|
66
|
-
for (const m of cls.methods) {
|
|
67
|
-
lines.push(`| \`${escapeCell(m.signature)}\` | ${m.complexity} | ${escapeCell(breakdownApex(m.contributors))} |`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
lines.push('');
|
|
71
|
-
}
|
|
72
|
-
if (report.unresolvedApexTargets.length > 0) {
|
|
73
|
-
lines.push('### Unresolved `apex://` targets', '');
|
|
74
|
-
for (const u of report.unresolvedApexTargets) {
|
|
75
|
-
lines.push(`- \`${u}\` — no matching \`.cls\` under \`--source-dir\` or \`--apex-source\``);
|
|
76
|
-
}
|
|
77
|
-
lines.push('');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// ── Footer ────────────────────────────────────────────────────────
|
|
81
|
-
lines.push('---', '', `Action declarations: **${report.totalDeclarations}** ` +
|
|
82
|
-
`(apex ${report.byTargetKind.apex}, flow ${report.byTargetKind.flow}, ` +
|
|
83
|
-
`prompt ${report.byTargetKind.prompt}, unknown ${report.byTargetKind.unknown}). ` +
|
|
84
|
-
`Action references: **${report.totalReferences}**.`);
|
|
85
|
-
return lines.join('\n');
|
|
86
|
-
}
|
|
87
|
-
function renderMermaid(report) {
|
|
88
|
-
// Per-bundle agent CC + the sum of Apex CC for classes that bundle
|
|
89
|
-
// references. We compute that mapping rather than counting classes
|
|
90
|
-
// globally so each bundle's bar reflects its full "implementation
|
|
91
|
-
// CC" footprint.
|
|
92
|
-
const apexByBundle = new Map();
|
|
93
|
-
for (const cls of report.apexClasses) {
|
|
94
|
-
for (const ref of cls.referencedBy) {
|
|
95
|
-
apexByBundle.set(ref, (apexByBundle.get(ref) ?? 0) + cls.classComplexity);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const labels = [];
|
|
99
|
-
const agentVals = [];
|
|
100
|
-
const apexVals = [];
|
|
101
|
-
for (const f of report.files) {
|
|
102
|
-
labels.push(shortBundleLabel(f.path));
|
|
103
|
-
agentVals.push(f.fileComplexity);
|
|
104
|
-
apexVals.push(apexByBundle.get(f.path) ?? 0);
|
|
105
|
-
}
|
|
106
|
-
// Mermaid xychart-beta supports stacked-bar style via two series.
|
|
107
|
-
// Palette: AgentScript = Reasoning red (#a82820); Apex = Deterministic green (#6b8c52).
|
|
108
|
-
return [
|
|
109
|
-
'```mermaid',
|
|
110
|
-
'%%{init: {"theme":"base","themeVariables":{"xyChart":{"plotColorPalette":"#a82820, #6b8c52"}}}}%%',
|
|
111
|
-
'xychart-beta',
|
|
112
|
-
' title "CC by location, per .agent bundle"',
|
|
113
|
-
` x-axis [${labels.map(l => `"${l}"`).join(', ')}]`,
|
|
114
|
-
` y-axis "Cyclomatic complexity"`,
|
|
115
|
-
` bar [${agentVals.join(', ')}]`,
|
|
116
|
-
` bar [${apexVals.join(', ')}]`,
|
|
117
|
-
'```',
|
|
118
|
-
'',
|
|
119
|
-
'<sub>Series: **AgentScript CC** (red, whitepaper "Reasoning Logic") · **Apex CC** (green, whitepaper "Deterministic Logic"). Apex CC per bundle is the sum of the CC of every `apex://` class that bundle references; classes referenced by multiple bundles contribute to each.</sub>',
|
|
120
|
-
].join('\n');
|
|
121
|
-
}
|
|
122
|
-
function shortBundleLabel(path) {
|
|
123
|
-
// Strip "aiAuthoringBundles/" and the trailing ".agent" to keep x-axis tight.
|
|
124
|
-
const stripped = path
|
|
125
|
-
.replace(/^.*aiAuthoringBundles\//, '')
|
|
126
|
-
.replace(/\.agent$/, '');
|
|
127
|
-
// Use only the basename if it appears twice (Bundle/Bundle.agent → Bundle).
|
|
128
|
-
const parts = stripped.split('/');
|
|
129
|
-
if (parts.length === 2 && parts[0] === parts[1])
|
|
130
|
-
return parts[0];
|
|
131
|
-
return parts.join('/');
|
|
132
|
-
}
|
|
133
|
-
function breakdownProc(contributors) {
|
|
134
|
-
if (contributors.length === 0)
|
|
135
|
-
return '(base only)';
|
|
136
|
-
const counts = {};
|
|
137
|
-
for (const c of contributors)
|
|
138
|
-
counts[c.kind] = (counts[c.kind] ?? 0) + 1;
|
|
139
|
-
return Object.entries(counts)
|
|
140
|
-
.map(([k, n]) => `${shortKind(k)}=${n}`)
|
|
141
|
-
.join(' ');
|
|
142
|
-
}
|
|
143
|
-
function breakdownApex(contributors) {
|
|
144
|
-
if (contributors.length === 0)
|
|
145
|
-
return '(base only)';
|
|
146
|
-
const counts = {};
|
|
147
|
-
for (const c of contributors)
|
|
148
|
-
counts[c.kind] = (counts[c.kind] ?? 0) + 1;
|
|
149
|
-
return Object.entries(counts)
|
|
150
|
-
.map(([k, n]) => `${shortApexKind(k)}=${n}`)
|
|
151
|
-
.join(' ');
|
|
152
|
-
}
|
|
153
|
-
function shortKind(k) {
|
|
154
|
-
switch (k) {
|
|
155
|
-
case 'elif_clause': {
|
|
156
|
-
return 'elif';
|
|
157
|
-
}
|
|
158
|
-
case 'if_statement': {
|
|
159
|
-
return 'if';
|
|
160
|
-
}
|
|
161
|
-
case 'short_circuit_and': {
|
|
162
|
-
return 'and';
|
|
163
|
-
}
|
|
164
|
-
case 'short_circuit_or': {
|
|
165
|
-
return 'or';
|
|
166
|
-
}
|
|
167
|
-
case 'ternary_expression': {
|
|
168
|
-
return 'ternary';
|
|
169
|
-
}
|
|
170
|
-
default: {
|
|
171
|
-
return k;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function shortApexKind(k) {
|
|
176
|
-
switch (k) {
|
|
177
|
-
case 'catch_clause': {
|
|
178
|
-
return 'catch';
|
|
179
|
-
}
|
|
180
|
-
case 'do_while_statement': {
|
|
181
|
-
return 'do-while';
|
|
182
|
-
}
|
|
183
|
-
case 'for_statement': {
|
|
184
|
-
return 'for';
|
|
185
|
-
}
|
|
186
|
-
case 'if_statement': {
|
|
187
|
-
return 'if';
|
|
188
|
-
}
|
|
189
|
-
case 'short_circuit_and': {
|
|
190
|
-
return '&&';
|
|
191
|
-
}
|
|
192
|
-
case 'short_circuit_or': {
|
|
193
|
-
return '||';
|
|
194
|
-
}
|
|
195
|
-
case 'ternary': {
|
|
196
|
-
return 'ternary';
|
|
197
|
-
}
|
|
198
|
-
case 'when_arm': {
|
|
199
|
-
return 'when';
|
|
200
|
-
}
|
|
201
|
-
case 'while_statement': {
|
|
202
|
-
return 'while';
|
|
203
|
-
}
|
|
204
|
-
default: {
|
|
205
|
-
return k;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
function countReferences(f) {
|
|
210
|
-
const m = new Map();
|
|
211
|
-
for (const r of f.references)
|
|
212
|
-
m.set(r.name, (m.get(r.name) ?? 0) + 1);
|
|
213
|
-
return m;
|
|
214
|
-
}
|
|
215
|
-
function listUndeclaredRefs(f) {
|
|
216
|
-
const declared = new Set(f.declarations.map(d => d.name));
|
|
217
|
-
const seen = new Set();
|
|
218
|
-
const out = [];
|
|
219
|
-
for (const r of f.references) {
|
|
220
|
-
if (declared.has(r.name))
|
|
221
|
-
continue;
|
|
222
|
-
if (seen.has(r.name))
|
|
223
|
-
continue;
|
|
224
|
-
seen.add(r.name);
|
|
225
|
-
out.push(r.name);
|
|
226
|
-
}
|
|
227
|
-
return out;
|
|
228
|
-
}
|
|
229
|
-
function escapeCell(s) {
|
|
230
|
-
// GFM table cells: escape pipes and turn embedded newlines into <br>.
|
|
231
|
-
return s.replaceAll('|', String.raw `\|`).replaceAll('\n', '<br>');
|
|
232
|
-
}
|
|
233
|
-
//# sourceMappingURL=markdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/renderers/markdown.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,GAAwC;IACtD,eAAe,EAAE,iBAAiB;IAClC,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IACpC,KAAK,EAAE,OAAO;IACd,sBAAsB,EAAE,wBAAwB;CACjD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,mDAAmD,EAAE,EAAE,EAChE,kEAAkE;QAChE,iEAAiE;QACjE,oBAAoB,EAAE,EAAE,CAC3B,CAAC;IAEF,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,qEAAqE;IACrE,KAAK,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,EAChC,aAAa,CAA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AAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,sEAAsE;IACtE,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAA,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AnalysisReport } from '../analyzer/types.js';
|
|
2
|
-
export type RenderFormat = 'csv' | 'markdown' | 'sarif' | 'text';
|
|
3
|
-
export interface RenderOptions {
|
|
4
|
-
/** Force ASCII-only output (no Unicode box chars, no emoji). Default: auto. */
|
|
5
|
-
ascii?: boolean;
|
|
6
|
-
/** Force/disable color in text output. Default: auto (TTY + no NO_COLOR). */
|
|
7
|
-
color?: boolean;
|
|
8
|
-
sarifErrorThreshold?: number;
|
|
9
|
-
/**
|
|
10
|
-
* SARIF severity thresholds. Methods/procedures with complexity at or above
|
|
11
|
-
* `warning` are flagged `level: warning`; at or above `error` → `level: error`.
|
|
12
|
-
* Default: warning=10, error=20 (matches PMD's methodReportLevel default).
|
|
13
|
-
*/
|
|
14
|
-
sarifWarningThreshold?: number;
|
|
15
|
-
/** Rule width for the text renderer. Default: 60. */
|
|
16
|
-
width?: number;
|
|
17
|
-
}
|
|
18
|
-
export interface Renderer {
|
|
19
|
-
render(report: AnalysisReport, options?: RenderOptions): string;
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/renderers/options.ts"],"names":[],"mappings":""}
|
package/dist/renderers/sarif.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
const DEFAULT_WARNING = 10;
|
|
2
|
-
const DEFAULT_ERROR = 20;
|
|
3
|
-
const RULE_AGENT_CC = {
|
|
4
|
-
defaultConfiguration: { level: 'note' },
|
|
5
|
-
fullDescription: {
|
|
6
|
-
text: 'Reports cyclomatic complexity (McCabe) of an AgentScript before_reasoning, ' +
|
|
7
|
-
'after_reasoning, or reasoning.instructions block. Computed as 1 + ' +
|
|
8
|
-
'count(if) + count(elif) + count(ternary) + count(and) + count(or).',
|
|
9
|
-
},
|
|
10
|
-
helpUri: 'https://github.com/bobbywhitesfdc/sf-agentpmd/blob/main/docs/agent-loc-categorization-skill-v2.md#-7--cyclomatic-complexity',
|
|
11
|
-
id: 'AGENTPMD.AgentScriptCyclomaticComplexity',
|
|
12
|
-
name: 'AgentScriptCyclomaticComplexity',
|
|
13
|
-
shortDescription: {
|
|
14
|
-
text: 'McCabe cyclomatic complexity of an AgentScript procedure.',
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
const RULE_APEX_CC = {
|
|
18
|
-
defaultConfiguration: { level: 'note' },
|
|
19
|
-
fullDescription: {
|
|
20
|
-
text: 'Reports cyclomatic complexity (McCabe) of an Apex method or ' +
|
|
21
|
-
'constructor body, mirroring SonarQube / PMD CyclomaticComplexity.',
|
|
22
|
-
},
|
|
23
|
-
helpUri: 'https://github.com/bobbywhitesfdc/sf-agentpmd/blob/main/docs/agent-loc-categorization-skill-v2.md#-7--cyclomatic-complexity',
|
|
24
|
-
id: 'AGENTPMD.ApexCyclomaticComplexity',
|
|
25
|
-
name: 'ApexCyclomaticComplexity',
|
|
26
|
-
shortDescription: {
|
|
27
|
-
text: 'McCabe cyclomatic complexity of an Apex method or constructor.',
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
export function renderSarif(report, opts) {
|
|
31
|
-
const warn = opts?.sarifWarningThreshold ?? DEFAULT_WARNING;
|
|
32
|
-
const err = opts?.sarifErrorThreshold ?? DEFAULT_ERROR;
|
|
33
|
-
const results = [];
|
|
34
|
-
for (const f of report.files) {
|
|
35
|
-
for (const p of f.procedures) {
|
|
36
|
-
results.push(buildAgentResult(f, p, warn, err));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
for (const cls of report.apexClasses) {
|
|
40
|
-
for (const m of cls.methods) {
|
|
41
|
-
results.push(buildApexResult(cls, m, warn, err));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const log = {
|
|
45
|
-
$schema: 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json',
|
|
46
|
-
runs: [
|
|
47
|
-
{
|
|
48
|
-
results,
|
|
49
|
-
tool: {
|
|
50
|
-
driver: {
|
|
51
|
-
informationUri: 'https://github.com/bobbywhitesfdc/sf-agentpmd',
|
|
52
|
-
name: 'sf-agentpmd',
|
|
53
|
-
rules: [RULE_AGENT_CC, RULE_APEX_CC],
|
|
54
|
-
semanticVersion: pluginVersion(),
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
version: '2.1.0',
|
|
60
|
-
};
|
|
61
|
-
return JSON.stringify(log, null, 2);
|
|
62
|
-
}
|
|
63
|
-
function buildAgentResult(f, p, warn, err) {
|
|
64
|
-
return {
|
|
65
|
-
level: levelFor(p.complexity, warn, err),
|
|
66
|
-
locations: [
|
|
67
|
-
{
|
|
68
|
-
physicalLocation: {
|
|
69
|
-
artifactLocation: { uri: f.path },
|
|
70
|
-
// AgentScript CST locations are 0-based — bump to SARIF 1-based.
|
|
71
|
-
region: regionFromZeroBased(p.location),
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
message: {
|
|
76
|
-
text: `Procedure '${p.kind}' in '${p.scope}' has cyclomatic complexity ` +
|
|
77
|
-
`${p.complexity}.`,
|
|
78
|
-
},
|
|
79
|
-
properties: { complexity: p.complexity, kind: p.kind },
|
|
80
|
-
ruleId: RULE_AGENT_CC.id,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function buildApexResult(cls, m, warn, err) {
|
|
84
|
-
return {
|
|
85
|
-
level: levelFor(m.complexity, warn, err),
|
|
86
|
-
locations: [
|
|
87
|
-
{
|
|
88
|
-
physicalLocation: {
|
|
89
|
-
artifactLocation: { uri: cls.path },
|
|
90
|
-
// ANTLR token positions are 1-based for line, 0-based for column;
|
|
91
|
-
// SARIF wants 1-based for both.
|
|
92
|
-
region: regionFromAntlr(m.location),
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
message: {
|
|
97
|
-
text: `${m.kind} '${m.name}' has cyclomatic complexity ${m.complexity}.`,
|
|
98
|
-
},
|
|
99
|
-
properties: { complexity: m.complexity, kind: m.kind },
|
|
100
|
-
ruleId: RULE_APEX_CC.id,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function levelFor(cc, warn, err) {
|
|
104
|
-
if (cc >= err)
|
|
105
|
-
return 'error';
|
|
106
|
-
if (cc >= warn)
|
|
107
|
-
return 'warning';
|
|
108
|
-
return 'note';
|
|
109
|
-
}
|
|
110
|
-
function regionFromZeroBased(loc) {
|
|
111
|
-
return {
|
|
112
|
-
endColumn: loc.endCol + 1,
|
|
113
|
-
endLine: loc.endRow + 1,
|
|
114
|
-
startColumn: loc.startCol + 1,
|
|
115
|
-
startLine: loc.startRow + 1,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function regionFromAntlr(loc) {
|
|
119
|
-
return {
|
|
120
|
-
endColumn: loc.endCol + 1,
|
|
121
|
-
endLine: Math.max(1, loc.endRow),
|
|
122
|
-
startColumn: loc.startCol + 1,
|
|
123
|
-
startLine: Math.max(1, loc.startRow),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function pluginVersion() {
|
|
127
|
-
// Avoid a JSON-file dep at runtime; this stays in sync with package.json
|
|
128
|
-
// manually. Bumping the plugin should bump this string.
|
|
129
|
-
return '0.1.0';
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=sarif.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sarif.js","sourceRoot":"","sources":["../../src/renderers/sarif.ts"],"names":[],"mappings":"AAmDA,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MA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AS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC;KACrC,CAAC;AACJ,CAAC;AAED,SAAS,aAAa;IACpB,yEAAyE;IACzE,wDAAwD;IACxD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/renderers/text.d.ts
DELETED
package/dist/renderers/text.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import pc from 'picocolors';
|
|
2
|
-
const KIND_LABEL = {
|
|
3
|
-
after_reasoning: 'after_reasoning',
|
|
4
|
-
available_when: 'available_when',
|
|
5
|
-
before_reasoning: 'before_reasoning',
|
|
6
|
-
other: 'other',
|
|
7
|
-
reasoning_instructions: 'reasoning.instructions',
|
|
8
|
-
};
|
|
9
|
-
const UNICODE_GLYPHS = {
|
|
10
|
-
agentFile: '📄',
|
|
11
|
-
apexFile: '📜',
|
|
12
|
-
ruleHeavy: '═',
|
|
13
|
-
ruleLight: '─',
|
|
14
|
-
};
|
|
15
|
-
const ASCII_GLYPHS = {
|
|
16
|
-
agentFile: '[agent]',
|
|
17
|
-
apexFile: '[apex] ',
|
|
18
|
-
ruleHeavy: '=',
|
|
19
|
-
ruleLight: '-',
|
|
20
|
-
};
|
|
21
|
-
function resolveOptions(opts) {
|
|
22
|
-
// Auto-detect: text + emoji unless explicitly disabled, color on TTY only
|
|
23
|
-
// and respecting the well-known NO_COLOR env var.
|
|
24
|
-
const stdoutIsTty = Boolean(process.stdout.isTTY);
|
|
25
|
-
const noColorEnv = Boolean(process.env.NO_COLOR);
|
|
26
|
-
return {
|
|
27
|
-
ascii: opts?.ascii ?? !stdoutIsTty,
|
|
28
|
-
color: opts?.color ?? (stdoutIsTty && !noColorEnv),
|
|
29
|
-
width: opts?.width ?? 60,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export function renderText(report, opts) {
|
|
33
|
-
const r = resolveOptions(opts);
|
|
34
|
-
const g = r.ascii ? ASCII_GLYPHS : UNICODE_GLYPHS;
|
|
35
|
-
const c = colorize(r.color);
|
|
36
|
-
const lines = [];
|
|
37
|
-
lines.push(c.title('AgentForce PMD — Cyclomatic Complexity (McCabe)'), g.ruleHeavy.repeat(r.width));
|
|
38
|
-
if (report.files.length === 0) {
|
|
39
|
-
lines.push(' (no .agent files found)');
|
|
40
|
-
return lines.join('\n');
|
|
41
|
-
}
|
|
42
|
-
for (const f of report.files) {
|
|
43
|
-
lines.push('', `${g.agentFile} ${c.path(f.path)} CC=${c.cc(f.fileComplexity)}`, g.ruleLight.repeat(r.width));
|
|
44
|
-
if (f.procedures.length === 0) {
|
|
45
|
-
lines.push(' (no procedure-bearing scopes)');
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
const scopes = groupByScope(f.procedures);
|
|
49
|
-
for (const [scope, procs] of scopes) {
|
|
50
|
-
const scopeTotal = procs.reduce((a, p) => a + p.complexity, 0);
|
|
51
|
-
lines.push(` ${c.scope(scope)} subtotal CC=${c.cc(scopeTotal)}`);
|
|
52
|
-
for (const p of procs) {
|
|
53
|
-
lines.push(` ${pad(KIND_LABEL[p.kind], 24)} CC=${c.cc(p.complexity)} ` +
|
|
54
|
-
c.breakdown(breakdownProc(p)));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (f.declarations.length > 0 || f.references.length > 0) {
|
|
59
|
-
lines.push('', ' Action references', ' ' + g.ruleLight.repeat(Math.max(0, r.width - 2)));
|
|
60
|
-
const usage = countReferences(f);
|
|
61
|
-
for (const d of f.declarations) {
|
|
62
|
-
const used = usage.get(d.name) ?? 0;
|
|
63
|
-
const tgt = d.target ?? '(no target)';
|
|
64
|
-
lines.push(` ${pad(d.name, 32)} [${pad(d.targetKind, 6)}] used ${used}x → ${tgt}`);
|
|
65
|
-
}
|
|
66
|
-
const undeclared = listUndeclaredRefs(f);
|
|
67
|
-
if (undeclared.length > 0) {
|
|
68
|
-
lines.push('', ' Referenced but not declared in-file:');
|
|
69
|
-
for (const u of undeclared) {
|
|
70
|
-
lines.push(` ${u}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (report.apexClasses.length > 0 || report.unresolvedApexTargets.length > 0) {
|
|
76
|
-
lines.push('', c.title('Apex backing logic (resolved via apex:// targets)'), g.ruleHeavy.repeat(r.width));
|
|
77
|
-
for (const cls of report.apexClasses) {
|
|
78
|
-
lines.push('', `${g.apexFile} ${c.path(cls.path)} class CC=${c.cc(cls.classComplexity)}`, ` referenced by: ${cls.referencedBy.join(', ') || '(none)'}`, g.ruleLight.repeat(r.width));
|
|
79
|
-
if (cls.methods.length === 0) {
|
|
80
|
-
lines.push(' (no methods with bodies)');
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
for (const m of cls.methods) {
|
|
84
|
-
lines.push(` ${pad(m.signature, 44)} CC=${c.cc(m.complexity)} ${c.breakdown(breakdownApex(m.contributors))}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (report.unresolvedApexTargets.length > 0) {
|
|
89
|
-
lines.push('', 'Unresolved apex:// targets:');
|
|
90
|
-
for (const u of report.unresolvedApexTargets) {
|
|
91
|
-
lines.push(` - ${u} (no matching .cls under source-dir or --apex-source)`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
lines.push('', g.ruleHeavy.repeat(r.width), c.title('CC by location (whitepaper § 7)'), ` AgentScript: ${c.cc(report.totalComplexity)}` +
|
|
96
|
-
` Apex: ${c.cc(report.totalApexComplexity)}` +
|
|
97
|
-
` Combined: ${c.cc(report.totalComplexity + report.totalApexComplexity)}`, `Action declarations: ${report.totalDeclarations} ` +
|
|
98
|
-
`(apex ${report.byTargetKind.apex}, flow ${report.byTargetKind.flow}, ` +
|
|
99
|
-
`prompt ${report.byTargetKind.prompt}, unknown ${report.byTargetKind.unknown})`, `Action references: ${report.totalReferences}`);
|
|
100
|
-
return lines.join('\n');
|
|
101
|
-
}
|
|
102
|
-
function colorize(on) {
|
|
103
|
-
if (!on) {
|
|
104
|
-
return {
|
|
105
|
-
breakdown: s => s,
|
|
106
|
-
cc: String,
|
|
107
|
-
path: s => s,
|
|
108
|
-
scope: s => s,
|
|
109
|
-
title: s => s,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
breakdown: pc.gray,
|
|
114
|
-
cc(n) {
|
|
115
|
-
// Palette echoes whitepaper temperature: cool for low, hot for high.
|
|
116
|
-
const s = String(n);
|
|
117
|
-
if (n >= 20)
|
|
118
|
-
return pc.red(s);
|
|
119
|
-
if (n >= 10)
|
|
120
|
-
return pc.yellow(s);
|
|
121
|
-
if (n >= 5)
|
|
122
|
-
return pc.green(s);
|
|
123
|
-
return pc.gray(s);
|
|
124
|
-
},
|
|
125
|
-
path: pc.cyan,
|
|
126
|
-
scope: pc.bold,
|
|
127
|
-
title: pc.bold,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function breakdownProc(p) {
|
|
131
|
-
if (p.contributors.length === 0)
|
|
132
|
-
return '(base only)';
|
|
133
|
-
const counts = {};
|
|
134
|
-
for (const c of p.contributors)
|
|
135
|
-
counts[c.kind] = (counts[c.kind] ?? 0) + 1;
|
|
136
|
-
return Object.entries(counts)
|
|
137
|
-
.map(([k, n]) => `${shortKind(k)}=${n}`)
|
|
138
|
-
.join(' ');
|
|
139
|
-
}
|
|
140
|
-
function breakdownApex(contributors) {
|
|
141
|
-
if (contributors.length === 0)
|
|
142
|
-
return '(base only)';
|
|
143
|
-
const counts = {};
|
|
144
|
-
for (const c of contributors)
|
|
145
|
-
counts[c.kind] = (counts[c.kind] ?? 0) + 1;
|
|
146
|
-
return Object.entries(counts)
|
|
147
|
-
.map(([k, n]) => `${shortApexKind(k)}=${n}`)
|
|
148
|
-
.join(' ');
|
|
149
|
-
}
|
|
150
|
-
function shortKind(k) {
|
|
151
|
-
switch (k) {
|
|
152
|
-
case 'elif_clause': {
|
|
153
|
-
return 'elif';
|
|
154
|
-
}
|
|
155
|
-
case 'if_statement': {
|
|
156
|
-
return 'if';
|
|
157
|
-
}
|
|
158
|
-
case 'short_circuit_and': {
|
|
159
|
-
return 'and';
|
|
160
|
-
}
|
|
161
|
-
case 'short_circuit_or': {
|
|
162
|
-
return 'or';
|
|
163
|
-
}
|
|
164
|
-
case 'ternary_expression': {
|
|
165
|
-
return 'ternary';
|
|
166
|
-
}
|
|
167
|
-
default: {
|
|
168
|
-
return k;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function shortApexKind(k) {
|
|
173
|
-
switch (k) {
|
|
174
|
-
case 'catch_clause': {
|
|
175
|
-
return 'catch';
|
|
176
|
-
}
|
|
177
|
-
case 'do_while_statement': {
|
|
178
|
-
return 'do-while';
|
|
179
|
-
}
|
|
180
|
-
case 'for_statement': {
|
|
181
|
-
return 'for';
|
|
182
|
-
}
|
|
183
|
-
case 'if_statement': {
|
|
184
|
-
return 'if';
|
|
185
|
-
}
|
|
186
|
-
case 'short_circuit_and': {
|
|
187
|
-
return '&&';
|
|
188
|
-
}
|
|
189
|
-
case 'short_circuit_or': {
|
|
190
|
-
return '||';
|
|
191
|
-
}
|
|
192
|
-
case 'ternary': {
|
|
193
|
-
return 'ternary';
|
|
194
|
-
}
|
|
195
|
-
case 'when_arm': {
|
|
196
|
-
return 'when';
|
|
197
|
-
}
|
|
198
|
-
case 'while_statement': {
|
|
199
|
-
return 'while';
|
|
200
|
-
}
|
|
201
|
-
default: {
|
|
202
|
-
return k;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function groupByScope(procs) {
|
|
207
|
-
const m = new Map();
|
|
208
|
-
for (const p of procs) {
|
|
209
|
-
let arr = m.get(p.scope);
|
|
210
|
-
if (!arr) {
|
|
211
|
-
arr = [];
|
|
212
|
-
m.set(p.scope, arr);
|
|
213
|
-
}
|
|
214
|
-
arr.push(p);
|
|
215
|
-
}
|
|
216
|
-
return m;
|
|
217
|
-
}
|
|
218
|
-
function pad(s, n) {
|
|
219
|
-
if (s.length >= n)
|
|
220
|
-
return s;
|
|
221
|
-
return s + ' '.repeat(n - s.length);
|
|
222
|
-
}
|
|
223
|
-
function countReferences(f) {
|
|
224
|
-
const m = new Map();
|
|
225
|
-
for (const r of f.references)
|
|
226
|
-
m.set(r.name, (m.get(r.name) ?? 0) + 1);
|
|
227
|
-
return m;
|
|
228
|
-
}
|
|
229
|
-
function listUndeclaredRefs(f) {
|
|
230
|
-
const declared = new Set(f.declarations.map(d => d.name));
|
|
231
|
-
const seen = new Set();
|
|
232
|
-
const out = [];
|
|
233
|
-
for (const r of f.references) {
|
|
234
|
-
if (declared.has(r.name))
|
|
235
|
-
continue;
|
|
236
|
-
if (seen.has(r.name))
|
|
237
|
-
continue;
|
|
238
|
-
seen.add(r.name);
|
|
239
|
-
out.push(r.name);
|
|
240
|
-
}
|
|
241
|
-
return out;
|
|
242
|
-
}
|
|
243
|
-
//# sourceMappingURL=text.js.map
|