sf-agentpmd 0.1.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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +26 -0
  3. package/README.md +204 -0
  4. package/bin/dev.js +5 -0
  5. package/bin/run.js +3 -0
  6. package/dist/analyzer/action-references.d.ts +21 -0
  7. package/dist/analyzer/action-references.js +130 -0
  8. package/dist/analyzer/action-references.js.map +1 -0
  9. package/dist/analyzer/analyze.d.ts +43 -0
  10. package/dist/analyzer/analyze.js +222 -0
  11. package/dist/analyzer/analyze.js.map +1 -0
  12. package/dist/analyzer/apex-analyze.d.ts +14 -0
  13. package/dist/analyzer/apex-analyze.js +60 -0
  14. package/dist/analyzer/apex-analyze.js.map +1 -0
  15. package/dist/analyzer/apex-complexity.d.ts +27 -0
  16. package/dist/analyzer/apex-complexity.js +133 -0
  17. package/dist/analyzer/apex-complexity.js.map +1 -0
  18. package/dist/analyzer/apex-parse.d.ts +39 -0
  19. package/dist/analyzer/apex-parse.js +32 -0
  20. package/dist/analyzer/apex-parse.js.map +1 -0
  21. package/dist/analyzer/apex-resolve.d.ts +32 -0
  22. package/dist/analyzer/apex-resolve.js +59 -0
  23. package/dist/analyzer/apex-resolve.js.map +1 -0
  24. package/dist/analyzer/complexity.d.ts +30 -0
  25. package/dist/analyzer/complexity.js +126 -0
  26. package/dist/analyzer/complexity.js.map +1 -0
  27. package/dist/analyzer/parse.d.ts +51 -0
  28. package/dist/analyzer/parse.js +143 -0
  29. package/dist/analyzer/parse.js.map +1 -0
  30. package/dist/analyzer/project.d.ts +12 -0
  31. package/dist/analyzer/project.js +51 -0
  32. package/dist/analyzer/project.js.map +1 -0
  33. package/dist/analyzer/types.d.ts +76 -0
  34. package/dist/analyzer/types.js +2 -0
  35. package/dist/analyzer/types.js.map +1 -0
  36. package/dist/commands/agentpmd/analyze.d.ts +20 -0
  37. package/dist/commands/agentpmd/analyze.js +122 -0
  38. package/dist/commands/agentpmd/analyze.js.map +1 -0
  39. package/dist/commands/agentpmd/install-skill.d.ts +11 -0
  40. package/dist/commands/agentpmd/install-skill.js +33 -0
  41. package/dist/commands/agentpmd/install-skill.js.map +1 -0
  42. package/dist/index.d.ts +3 -0
  43. package/dist/index.js +3 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/renderers/csv.d.ts +6 -0
  46. package/dist/renderers/csv.js +78 -0
  47. package/dist/renderers/csv.js.map +1 -0
  48. package/dist/renderers/index.d.ts +8 -0
  49. package/dist/renderers/index.js +25 -0
  50. package/dist/renderers/index.js.map +1 -0
  51. package/dist/renderers/markdown.d.ts +12 -0
  52. package/dist/renderers/markdown.js +233 -0
  53. package/dist/renderers/markdown.js.map +1 -0
  54. package/dist/renderers/options.d.ts +20 -0
  55. package/dist/renderers/options.js +2 -0
  56. package/dist/renderers/options.js.map +1 -0
  57. package/dist/renderers/sarif.d.ts +3 -0
  58. package/dist/renderers/sarif.js +131 -0
  59. package/dist/renderers/sarif.js.map +1 -0
  60. package/dist/renderers/text.d.ts +3 -0
  61. package/dist/renderers/text.js +243 -0
  62. package/dist/renderers/text.js.map +1 -0
  63. package/oclif.manifest.json +168 -0
  64. package/package.json +97 -0
  65. package/skill/SKILL.md +103 -0
  66. package/skill/references/command-structure.md +89 -0
  67. package/skill/references/install.md +112 -0
  68. package/skill/references/output-formats.md +205 -0
  69. package/skill/references/upgrade.md +112 -0
  70. package/vendor/agentscript-parser-javascript/dist/cst-node.d.ts +83 -0
  71. package/vendor/agentscript-parser-javascript/dist/cst-node.js +238 -0
  72. package/vendor/agentscript-parser-javascript/dist/errors.d.ts +34 -0
  73. package/vendor/agentscript-parser-javascript/dist/errors.js +74 -0
  74. package/vendor/agentscript-parser-javascript/dist/expressions.d.ts +36 -0
  75. package/vendor/agentscript-parser-javascript/dist/expressions.js +682 -0
  76. package/vendor/agentscript-parser-javascript/dist/highlighter.d.ts +24 -0
  77. package/vendor/agentscript-parser-javascript/dist/highlighter.js +260 -0
  78. package/vendor/agentscript-parser-javascript/dist/index.d.ts +29 -0
  79. package/vendor/agentscript-parser-javascript/dist/index.js +35 -0
  80. package/vendor/agentscript-parser-javascript/dist/lexer.d.ts +60 -0
  81. package/vendor/agentscript-parser-javascript/dist/lexer.js +630 -0
  82. package/vendor/agentscript-parser-javascript/dist/parse-mapping.d.ts +46 -0
  83. package/vendor/agentscript-parser-javascript/dist/parse-mapping.js +549 -0
  84. package/vendor/agentscript-parser-javascript/dist/parse-sequence.d.ts +10 -0
  85. package/vendor/agentscript-parser-javascript/dist/parse-sequence.js +118 -0
  86. package/vendor/agentscript-parser-javascript/dist/parse-statements.d.ts +15 -0
  87. package/vendor/agentscript-parser-javascript/dist/parse-statements.js +519 -0
  88. package/vendor/agentscript-parser-javascript/dist/parse-templates.d.ts +15 -0
  89. package/vendor/agentscript-parser-javascript/dist/parse-templates.js +323 -0
  90. package/vendor/agentscript-parser-javascript/dist/parser.d.ts +65 -0
  91. package/vendor/agentscript-parser-javascript/dist/parser.js +163 -0
  92. package/vendor/agentscript-parser-javascript/dist/recovery.d.ts +51 -0
  93. package/vendor/agentscript-parser-javascript/dist/recovery.js +199 -0
  94. package/vendor/agentscript-parser-javascript/dist/token.d.ts +58 -0
  95. package/vendor/agentscript-parser-javascript/dist/token.js +62 -0
  96. package/vendor/agentscript-parser-javascript/package.json +19 -0
  97. package/vendor/agentscript-types/dist/comment.d.ts +11 -0
  98. package/vendor/agentscript-types/dist/comment.js +10 -0
  99. package/vendor/agentscript-types/dist/cst.d.ts +7 -0
  100. package/vendor/agentscript-types/dist/cst.js +8 -0
  101. package/vendor/agentscript-types/dist/diagnostic.d.ts +34 -0
  102. package/vendor/agentscript-types/dist/diagnostic.js +23 -0
  103. package/vendor/agentscript-types/dist/index.d.ts +9 -0
  104. package/vendor/agentscript-types/dist/index.js +10 -0
  105. package/vendor/agentscript-types/dist/position.d.ts +11 -0
  106. package/vendor/agentscript-types/dist/position.js +16 -0
  107. package/vendor/agentscript-types/dist/syntax-node.d.ts +39 -0
  108. package/vendor/agentscript-types/dist/syntax-node.js +8 -0
  109. package/vendor/agentscript-types/package.json +15 -0
@@ -0,0 +1,131 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sarif.js","sourceRoot":"","sources":["../../src/renderers/sarif.ts"],"names":[],"mappings":"AAmDA,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,aAAa,GAAc;IAC/B,oBAAoB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;IACvC,eAAe,EAAE;QACf,IAAI,EACF,6EAA6E;YAC7E,oEAAoE;YACpE,oEAAoE;KACvE;IACD,OAAO,EACL,6HAA6H;IAC/H,EAAE,EAAE,0CAA0C;IAC9C,IAAI,EAAE,iCAAiC;IACvC,gBAAgB,EAAE;QAChB,IAAI,EAAE,2DAA2D;KAClE;CACF,CAAC;AAEF,MAAM,YAAY,GAAc;IAC9B,oBAAoB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;IACvC,eAAe,EAAE;QACf,IAAI,EACF,8DAA8D;YAC9D,mEAAmE;KACtE;IACD,OAAO,EACL,6HAA6H;IAC/H,EAAE,EAAE,mCAAmC;IACvC,IAAI,EAAE,0BAA0B;IAChC,gBAAgB,EAAE;QAChB,IAAI,EAAE,gEAAgE;KACvE;CACF,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,MAA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O,CAAC;IAC9B,IAAI,EAAE,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IACjC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,GAA4B;IACvD,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC;QACzB,OAAO,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC;QACvB,WAAW,EAAE,GAAG,CAAC,QAAQ,GAAG,CAAC;QAC7B,SAAS,EAAE,GAAG,CAAC,QAAQ,GAAG,CAAC;KAC5B,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,GAA4B;IACnD,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC;QACzB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;QAChC,WAAW,EAAE,GAAG,CAAC,QAAQ,GAAG,CAAC;QAC7B,SAAS,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"}
@@ -0,0 +1,3 @@
1
+ import type { AnalysisReport } from '../analyzer/types.js';
2
+ import type { RenderOptions } from './options.js';
3
+ export declare function renderText(report: AnalysisReport, opts?: RenderOptions): string;
@@ -0,0 +1,243 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/renderers/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAU5B,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;AASF,MAAM,cAAc,GAAW;IAC7B,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,GAAG;CACf,CAAC;AAEF,MAAM,YAAY,GAAW;IAC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,CAAC;AAED,SAAS,kBAAkB,CAAC,CAAa;IACvC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;QAC7B,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAAE,SAAS;QACnC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAAE,SAAS;QAC/B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACjB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,168 @@
1
+ {
2
+ "commands": {
3
+ "agentpmd:analyze": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "description": "Walks .agent source files under --source-dir and emits per-procedure\ncyclomatic complexity totals (before_reasoning, after_reasoning, and\nreasoning.instructions blocks), plus an inventory of declared and used\n@actions.X targets. For every apex:// target, resolves the .cls file\nand computes per-method Apex CC.\n\nDefault output is human-readable text. --json emits the SF CLI envelope\nwith the full structured report. --format <markdown|sarif|csv> emits the\nnamed format on stdout for piping into PR comments, GitHub Code Scanning,\nor spreadsheet pivots.",
7
+ "examples": [
8
+ "<%= config.bin %> <%= command.id %> --source-dir force-app/main/default",
9
+ "<%= config.bin %> <%= command.id %> --source-dir force-app/main/default --json",
10
+ "<%= config.bin %> <%= command.id %> --source-dir force-app/main/default --format markdown > report.md",
11
+ "<%= config.bin %> <%= command.id %> --source-dir force-app/main/default --format sarif > report.sarif"
12
+ ],
13
+ "flags": {
14
+ "json": {
15
+ "description": "Format output as json.",
16
+ "helpGroup": "GLOBAL",
17
+ "name": "json",
18
+ "allowNo": false,
19
+ "type": "boolean"
20
+ },
21
+ "flags-dir": {
22
+ "helpGroup": "GLOBAL",
23
+ "name": "flags-dir",
24
+ "summary": "Import flag values from a directory.",
25
+ "hasDynamicHelp": false,
26
+ "multiple": false,
27
+ "type": "option"
28
+ },
29
+ "apex-source": {
30
+ "name": "apex-source",
31
+ "summary": "Override directory to look up apex:// targets. By default we walk up from each .agent file looking for a sibling classes/ folder.",
32
+ "hasDynamicHelp": false,
33
+ "multiple": false,
34
+ "type": "option"
35
+ },
36
+ "api-name": {
37
+ "char": "n",
38
+ "name": "api-name",
39
+ "summary": "Filter to specific agent bundles. Matched against the bundle directory name and the config.developer_name field. Repeatable.",
40
+ "hasDynamicHelp": false,
41
+ "multiple": true,
42
+ "type": "option"
43
+ },
44
+ "ascii": {
45
+ "name": "ascii",
46
+ "summary": "Force ASCII-only output in the text renderer (no Unicode box chars, no emoji).",
47
+ "allowNo": false,
48
+ "type": "boolean"
49
+ },
50
+ "fail-on": {
51
+ "name": "fail-on",
52
+ "summary": "Exit non-zero if combined agent+Apex CC meets or exceeds this threshold.",
53
+ "hasDynamicHelp": false,
54
+ "multiple": false,
55
+ "type": "option"
56
+ },
57
+ "format": {
58
+ "name": "format",
59
+ "summary": "Non-JSON output format. --json takes precedence per SF CLI convention.",
60
+ "default": "text",
61
+ "hasDynamicHelp": false,
62
+ "multiple": false,
63
+ "options": [
64
+ "text",
65
+ "markdown",
66
+ "sarif",
67
+ "csv"
68
+ ],
69
+ "type": "option"
70
+ },
71
+ "no-color": {
72
+ "name": "no-color",
73
+ "summary": "Disable ANSI color in the text renderer. NO_COLOR env also disables.",
74
+ "allowNo": false,
75
+ "type": "boolean"
76
+ },
77
+ "sarif-error": {
78
+ "name": "sarif-error",
79
+ "summary": "SARIF \"error\" level threshold. Default 20.",
80
+ "hasDynamicHelp": false,
81
+ "multiple": false,
82
+ "type": "option"
83
+ },
84
+ "sarif-warning": {
85
+ "name": "sarif-warning",
86
+ "summary": "SARIF \"warning\" level threshold. Default 10.",
87
+ "hasDynamicHelp": false,
88
+ "multiple": false,
89
+ "type": "option"
90
+ },
91
+ "source-dir": {
92
+ "char": "d",
93
+ "name": "source-dir",
94
+ "summary": "Directory or single .agent file to analyze. Defaults to the packageDirectories of the nearest sfdx-project.json.",
95
+ "hasDynamicHelp": false,
96
+ "multiple": false,
97
+ "type": "option"
98
+ },
99
+ "width": {
100
+ "name": "width",
101
+ "summary": "Rule width for the text renderer.",
102
+ "default": 60,
103
+ "hasDynamicHelp": false,
104
+ "multiple": false,
105
+ "type": "option"
106
+ }
107
+ },
108
+ "hasDynamicHelp": false,
109
+ "hiddenAliases": [],
110
+ "id": "agentpmd:analyze",
111
+ "pluginAlias": "sf-agentpmd",
112
+ "pluginName": "sf-agentpmd",
113
+ "pluginType": "core",
114
+ "strict": true,
115
+ "summary": "Compute McCabe cyclomatic complexity and action-reference inventory for AgentScript bundles and their Apex backing logic.",
116
+ "enableJsonFlag": true,
117
+ "isESM": true,
118
+ "relativePath": [
119
+ "dist",
120
+ "commands",
121
+ "agentpmd",
122
+ "analyze.js"
123
+ ]
124
+ },
125
+ "agentpmd:install-skill": {
126
+ "aliases": [],
127
+ "args": {},
128
+ "description": "Recursively copies the bundled skill tree (SKILL.md plus its references/\npages) to ~/.claude/skills/agentforcepmd/ so Claude Code can use it as a\nskill. Restart Claude Code (or reload skills) afterward to activate it.",
129
+ "examples": [
130
+ "$ sf agentpmd install-skill"
131
+ ],
132
+ "flags": {
133
+ "json": {
134
+ "description": "Format output as json.",
135
+ "helpGroup": "GLOBAL",
136
+ "name": "json",
137
+ "allowNo": false,
138
+ "type": "boolean"
139
+ },
140
+ "flags-dir": {
141
+ "helpGroup": "GLOBAL",
142
+ "name": "flags-dir",
143
+ "summary": "Import flag values from a directory.",
144
+ "hasDynamicHelp": false,
145
+ "multiple": false,
146
+ "type": "option"
147
+ }
148
+ },
149
+ "hasDynamicHelp": false,
150
+ "hiddenAliases": [],
151
+ "id": "agentpmd:install-skill",
152
+ "pluginAlias": "sf-agentpmd",
153
+ "pluginName": "sf-agentpmd",
154
+ "pluginType": "core",
155
+ "strict": true,
156
+ "summary": "Install the agentforcepmd Claude Code skill to ~/.claude/skills/.",
157
+ "enableJsonFlag": true,
158
+ "isESM": true,
159
+ "relativePath": [
160
+ "dist",
161
+ "commands",
162
+ "agentpmd",
163
+ "install-skill.js"
164
+ ]
165
+ }
166
+ },
167
+ "version": "0.1.0"
168
+ }
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "sf-agentpmd",
3
+ "version": "0.1.0",
4
+ "description": "SF CLI plugin: McCabe cyclomatic complexity and Agent LOC analysis for AgentScript (.agent) bundles.",
5
+ "license": "MIT",
6
+ "author": "Bobby White",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/bobbywhitesfdc/sf-agentpmd.git"
13
+ },
14
+ "bugs": "https://github.com/bobbywhitesfdc/sf-agentpmd/issues",
15
+ "homepage": "https://github.com/bobbywhitesfdc/sf-agentpmd",
16
+ "keywords": [
17
+ "salesforce",
18
+ "sf-plugin",
19
+ "sfdx-plugin",
20
+ "oclif",
21
+ "agentforce",
22
+ "agentscript",
23
+ "cyclomatic-complexity",
24
+ "mccabe",
25
+ "pmd",
26
+ "static-analysis",
27
+ "code-quality",
28
+ "apex"
29
+ ],
30
+ "files": [
31
+ "./bin",
32
+ "./dist",
33
+ "./vendor",
34
+ "./skill",
35
+ "./oclif.manifest.json",
36
+ "./LICENSE",
37
+ "./NOTICE"
38
+ ],
39
+ "bin": {
40
+ "sf-agentpmd": "bin/run.js"
41
+ },
42
+ "scripts": {
43
+ "build": "shx rm -rf dist tsconfig.tsbuildinfo && tsc -b",
44
+ "clean": "shx rm -rf dist oclif.manifest.json tsconfig.tsbuildinfo",
45
+ "lint": "eslint",
46
+ "posttest": "npm run lint",
47
+ "prepack": "oclif manifest && oclif readme",
48
+ "postpack": "shx rm -f oclif.manifest.json",
49
+ "test": "mocha --forbid-only \"test/**/*.test.ts\"",
50
+ "version": "git add README.md"
51
+ },
52
+ "dependencies": {
53
+ "@agentscript/parser-javascript": "file:./vendor/agentscript-parser-javascript",
54
+ "@agentscript/types": "file:./vendor/agentscript-types",
55
+ "@apexdevtools/apex-parser": "^5.0.0",
56
+ "@oclif/core": "^4",
57
+ "@oclif/plugin-help": "^6",
58
+ "@salesforce/sf-plugins-core": "^11",
59
+ "antlr4": "^4.13.2",
60
+ "picocolors": "^1.1.1",
61
+ "tiny-invariant": "^1.3.3"
62
+ },
63
+ "devDependencies": {
64
+ "@eslint/compat": "^1",
65
+ "@oclif/prettier-config": "^0.2.1",
66
+ "@oclif/test": "^4",
67
+ "@types/chai": "^4",
68
+ "@types/mocha": "^10",
69
+ "@types/node": "^22",
70
+ "chai": "^4",
71
+ "eslint": "^9",
72
+ "eslint-config-oclif": "^6",
73
+ "eslint-config-prettier": "^10",
74
+ "mocha": "^11",
75
+ "oclif": "^4",
76
+ "shx": "^0.3.3",
77
+ "ts-node": "^10",
78
+ "typescript": "^5.6"
79
+ },
80
+ "engines": {
81
+ "node": ">=18.0.0"
82
+ },
83
+ "oclif": {
84
+ "bin": "sf",
85
+ "dirname": "sf-agentpmd",
86
+ "commands": "./dist/commands",
87
+ "plugins": [
88
+ "@oclif/plugin-help"
89
+ ],
90
+ "topicSeparator": " ",
91
+ "topics": {
92
+ "agentpmd": {
93
+ "description": "Static analysis for Agentforce / AgentScript bundles (CC and LOC)."
94
+ }
95
+ }
96
+ }
97
+ }