sf-agentpmd 0.1.0 → 0.1.2

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 (100) hide show
  1. package/NOTICE +7 -5
  2. package/dist/commands/agentpmd/analyze.js +4141 -109
  3. package/dist/commands/agentpmd/analyze.js.map +7 -1
  4. package/dist/commands/agentpmd/install-skill.js +42 -31
  5. package/dist/commands/agentpmd/install-skill.js.map +7 -1
  6. package/dist/index.js +4155 -3
  7. package/dist/index.js.map +7 -1
  8. package/oclif.manifest.json +2 -2
  9. package/package.json +7 -8
  10. package/dist/analyzer/action-references.d.ts +0 -21
  11. package/dist/analyzer/action-references.js +0 -130
  12. package/dist/analyzer/action-references.js.map +0 -1
  13. package/dist/analyzer/analyze.d.ts +0 -43
  14. package/dist/analyzer/analyze.js +0 -222
  15. package/dist/analyzer/analyze.js.map +0 -1
  16. package/dist/analyzer/apex-analyze.d.ts +0 -14
  17. package/dist/analyzer/apex-analyze.js +0 -60
  18. package/dist/analyzer/apex-analyze.js.map +0 -1
  19. package/dist/analyzer/apex-complexity.d.ts +0 -27
  20. package/dist/analyzer/apex-complexity.js +0 -133
  21. package/dist/analyzer/apex-complexity.js.map +0 -1
  22. package/dist/analyzer/apex-parse.d.ts +0 -39
  23. package/dist/analyzer/apex-parse.js +0 -32
  24. package/dist/analyzer/apex-parse.js.map +0 -1
  25. package/dist/analyzer/apex-resolve.d.ts +0 -32
  26. package/dist/analyzer/apex-resolve.js +0 -59
  27. package/dist/analyzer/apex-resolve.js.map +0 -1
  28. package/dist/analyzer/complexity.d.ts +0 -30
  29. package/dist/analyzer/complexity.js +0 -126
  30. package/dist/analyzer/complexity.js.map +0 -1
  31. package/dist/analyzer/parse.d.ts +0 -51
  32. package/dist/analyzer/parse.js +0 -143
  33. package/dist/analyzer/parse.js.map +0 -1
  34. package/dist/analyzer/project.d.ts +0 -12
  35. package/dist/analyzer/project.js +0 -51
  36. package/dist/analyzer/project.js.map +0 -1
  37. package/dist/analyzer/types.d.ts +0 -76
  38. package/dist/analyzer/types.js +0 -2
  39. package/dist/analyzer/types.js.map +0 -1
  40. package/dist/commands/agentpmd/analyze.d.ts +0 -20
  41. package/dist/commands/agentpmd/install-skill.d.ts +0 -11
  42. package/dist/index.d.ts +0 -3
  43. package/dist/renderers/csv.d.ts +0 -6
  44. package/dist/renderers/csv.js +0 -78
  45. package/dist/renderers/csv.js.map +0 -1
  46. package/dist/renderers/index.d.ts +0 -8
  47. package/dist/renderers/index.js +0 -25
  48. package/dist/renderers/index.js.map +0 -1
  49. package/dist/renderers/markdown.d.ts +0 -12
  50. package/dist/renderers/markdown.js +0 -233
  51. package/dist/renderers/markdown.js.map +0 -1
  52. package/dist/renderers/options.d.ts +0 -20
  53. package/dist/renderers/options.js +0 -2
  54. package/dist/renderers/options.js.map +0 -1
  55. package/dist/renderers/sarif.d.ts +0 -3
  56. package/dist/renderers/sarif.js +0 -131
  57. package/dist/renderers/sarif.js.map +0 -1
  58. package/dist/renderers/text.d.ts +0 -3
  59. package/dist/renderers/text.js +0 -243
  60. package/dist/renderers/text.js.map +0 -1
  61. package/vendor/agentscript-parser-javascript/dist/cst-node.d.ts +0 -83
  62. package/vendor/agentscript-parser-javascript/dist/cst-node.js +0 -238
  63. package/vendor/agentscript-parser-javascript/dist/errors.d.ts +0 -34
  64. package/vendor/agentscript-parser-javascript/dist/errors.js +0 -74
  65. package/vendor/agentscript-parser-javascript/dist/expressions.d.ts +0 -36
  66. package/vendor/agentscript-parser-javascript/dist/expressions.js +0 -682
  67. package/vendor/agentscript-parser-javascript/dist/highlighter.d.ts +0 -24
  68. package/vendor/agentscript-parser-javascript/dist/highlighter.js +0 -260
  69. package/vendor/agentscript-parser-javascript/dist/index.d.ts +0 -29
  70. package/vendor/agentscript-parser-javascript/dist/index.js +0 -35
  71. package/vendor/agentscript-parser-javascript/dist/lexer.d.ts +0 -60
  72. package/vendor/agentscript-parser-javascript/dist/lexer.js +0 -630
  73. package/vendor/agentscript-parser-javascript/dist/parse-mapping.d.ts +0 -46
  74. package/vendor/agentscript-parser-javascript/dist/parse-mapping.js +0 -549
  75. package/vendor/agentscript-parser-javascript/dist/parse-sequence.d.ts +0 -10
  76. package/vendor/agentscript-parser-javascript/dist/parse-sequence.js +0 -118
  77. package/vendor/agentscript-parser-javascript/dist/parse-statements.d.ts +0 -15
  78. package/vendor/agentscript-parser-javascript/dist/parse-statements.js +0 -519
  79. package/vendor/agentscript-parser-javascript/dist/parse-templates.d.ts +0 -15
  80. package/vendor/agentscript-parser-javascript/dist/parse-templates.js +0 -323
  81. package/vendor/agentscript-parser-javascript/dist/parser.d.ts +0 -65
  82. package/vendor/agentscript-parser-javascript/dist/parser.js +0 -163
  83. package/vendor/agentscript-parser-javascript/dist/recovery.d.ts +0 -51
  84. package/vendor/agentscript-parser-javascript/dist/recovery.js +0 -199
  85. package/vendor/agentscript-parser-javascript/dist/token.d.ts +0 -58
  86. package/vendor/agentscript-parser-javascript/dist/token.js +0 -62
  87. package/vendor/agentscript-parser-javascript/package.json +0 -19
  88. package/vendor/agentscript-types/dist/comment.d.ts +0 -11
  89. package/vendor/agentscript-types/dist/comment.js +0 -10
  90. package/vendor/agentscript-types/dist/cst.d.ts +0 -7
  91. package/vendor/agentscript-types/dist/cst.js +0 -8
  92. package/vendor/agentscript-types/dist/diagnostic.d.ts +0 -34
  93. package/vendor/agentscript-types/dist/diagnostic.js +0 -23
  94. package/vendor/agentscript-types/dist/index.d.ts +0 -9
  95. package/vendor/agentscript-types/dist/index.js +0 -10
  96. package/vendor/agentscript-types/dist/position.d.ts +0 -11
  97. package/vendor/agentscript-types/dist/position.js +0 -16
  98. package/vendor/agentscript-types/dist/syntax-node.d.ts +0 -39
  99. package/vendor/agentscript-types/dist/syntax-node.js +0 -8
  100. package/vendor/agentscript-types/package.json +0 -15
@@ -125,7 +125,7 @@
125
125
  "agentpmd:install-skill": {
126
126
  "aliases": [],
127
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.",
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. Any existing install at that path (including a dev symlink into a\ncheckout) is replaced. Restart Claude Code (or reload skills) afterward.",
129
129
  "examples": [
130
130
  "$ sf agentpmd install-skill"
131
131
  ],
@@ -164,5 +164,5 @@
164
164
  ]
165
165
  }
166
166
  },
167
- "version": "0.1.0"
167
+ "version": "0.1.2"
168
168
  }
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "sf-agentpmd",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "SF CLI plugin: McCabe cyclomatic complexity and Agent LOC analysis for AgentScript (.agent) bundles.",
5
5
  "license": "MIT",
6
6
  "author": "Bobby White",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
- "types": "dist/index.d.ts",
10
9
  "repository": {
11
10
  "type": "git",
12
11
  "url": "git+https://github.com/bobbywhitesfdc/sf-agentpmd.git"
@@ -30,7 +29,6 @@
30
29
  "files": [
31
30
  "./bin",
32
31
  "./dist",
33
- "./vendor",
34
32
  "./skill",
35
33
  "./oclif.manifest.json",
36
34
  "./LICENSE",
@@ -40,7 +38,7 @@
40
38
  "sf-agentpmd": "bin/run.js"
41
39
  },
42
40
  "scripts": {
43
- "build": "shx rm -rf dist tsconfig.tsbuildinfo && tsc -b",
41
+ "build": "shx rm -rf dist tsconfig.tsbuildinfo && tsc --noEmit && node esbuild.config.mjs",
44
42
  "clean": "shx rm -rf dist oclif.manifest.json tsconfig.tsbuildinfo",
45
43
  "lint": "eslint",
46
44
  "posttest": "npm run lint",
@@ -50,17 +48,16 @@
50
48
  "version": "git add README.md"
51
49
  },
52
50
  "dependencies": {
53
- "@agentscript/parser-javascript": "file:./vendor/agentscript-parser-javascript",
54
- "@agentscript/types": "file:./vendor/agentscript-types",
55
51
  "@apexdevtools/apex-parser": "^5.0.0",
56
52
  "@oclif/core": "^4",
57
53
  "@oclif/plugin-help": "^6",
58
54
  "@salesforce/sf-plugins-core": "^11",
59
55
  "antlr4": "^4.13.2",
60
- "picocolors": "^1.1.1",
61
- "tiny-invariant": "^1.3.3"
56
+ "picocolors": "^1.1.1"
62
57
  },
63
58
  "devDependencies": {
59
+ "@agentscript/parser-javascript": "file:./vendor/agentscript-parser-javascript",
60
+ "@agentscript/types": "file:./vendor/agentscript-types",
64
61
  "@eslint/compat": "^1",
65
62
  "@oclif/prettier-config": "^0.2.1",
66
63
  "@oclif/test": "^4",
@@ -68,12 +65,14 @@
68
65
  "@types/mocha": "^10",
69
66
  "@types/node": "^22",
70
67
  "chai": "^4",
68
+ "esbuild": "^0.25.0",
71
69
  "eslint": "^9",
72
70
  "eslint-config-oclif": "^6",
73
71
  "eslint-config-prettier": "^10",
74
72
  "mocha": "^11",
75
73
  "oclif": "^4",
76
74
  "shx": "^0.3.3",
75
+ "tiny-invariant": "^1.3.3",
77
76
  "ts-node": "^10",
78
77
  "typescript": "^5.6"
79
78
  },
@@ -1,21 +0,0 @@
1
- import type { AgentScope } from './complexity.js';
2
- import type { ActionDeclaration, ActionReference } from './types.js';
3
- /**
4
- * Within a scope body (the value of a `topic` or `start_agent`/`subagent`
5
- * mapping_element), the `actions:` entry holds a mapping of named action
6
- * declarations. Each declaration is itself a mapping with metadata fields
7
- * like `target:`, `label:`, `inputs:`, `outputs:`.
8
- */
9
- export declare function collectDeclarations(scope: AgentScope): ActionDeclaration[];
10
- /**
11
- * Collect every member_expression of the form `@actions.X` *outside* the
12
- * `actions:` declaration block. We treat them as references — i.e. usages of
13
- * the declared actions in reasoning / before / after blocks.
14
- *
15
- * Context discrimination:
16
- * • inside reasoning > actions → 'reasoning_actions'
17
- * • inside after_reasoning → 'after_reasoning_run'
18
- * • inside before_reasoning → 'before_reasoning_run'
19
- * • inside transition_statement → 'transition'
20
- */
21
- export declare function collectReferences(scope: AgentScope): ActionReference[];
@@ -1,130 +0,0 @@
1
- import { descendants, extractStringLiteral, findMappingEntry, locOf, mappingKeyHeader, mappingValue, } from './parse.js';
2
- const TARGET_SCHEME = /^([a-z][a-z0-9+.-]*):\/\//i;
3
- function classifyTarget(uri) {
4
- if (!uri)
5
- return 'unknown';
6
- const m = TARGET_SCHEME.exec(uri);
7
- if (!m)
8
- return 'unknown';
9
- const scheme = m[1].toLowerCase();
10
- if (scheme === 'apex')
11
- return 'apex';
12
- if (scheme === 'flow')
13
- return 'flow';
14
- if (scheme.startsWith('prompt'))
15
- return 'prompt';
16
- return 'unknown';
17
- }
18
- /**
19
- * Within a scope body (the value of a `topic` or `start_agent`/`subagent`
20
- * mapping_element), the `actions:` entry holds a mapping of named action
21
- * declarations. Each declaration is itself a mapping with metadata fields
22
- * like `target:`, `label:`, `inputs:`, `outputs:`.
23
- */
24
- export function collectDeclarations(scope) {
25
- const decls = [];
26
- const actionsBlock = findMappingEntry(scope.body, 'actions');
27
- if (!actionsBlock)
28
- return decls;
29
- for (const child of actionsBlock.namedChildren) {
30
- if (child.type !== 'mapping_element')
31
- continue;
32
- const h = mappingKeyHeader(child);
33
- if (!h)
34
- continue;
35
- const declName = h.kind;
36
- const declBody = mappingValue(child);
37
- if (!declBody) {
38
- decls.push({
39
- location: locOf(child),
40
- name: declName,
41
- scope: scope.label,
42
- target: undefined,
43
- targetKind: 'unknown',
44
- });
45
- continue;
46
- }
47
- const targetVal = findMappingEntry(declBody, 'target');
48
- const targetStr = targetVal ? extractStringLiteral(targetVal) : undefined;
49
- decls.push({
50
- location: locOf(child),
51
- name: declName,
52
- scope: scope.label,
53
- target: targetStr,
54
- targetKind: classifyTarget(targetStr),
55
- });
56
- }
57
- return decls;
58
- }
59
- /**
60
- * Collect every member_expression of the form `@actions.X` *outside* the
61
- * `actions:` declaration block. We treat them as references — i.e. usages of
62
- * the declared actions in reasoning / before / after blocks.
63
- *
64
- * Context discrimination:
65
- * • inside reasoning > actions → 'reasoning_actions'
66
- * • inside after_reasoning → 'after_reasoning_run'
67
- * • inside before_reasoning → 'before_reasoning_run'
68
- * • inside transition_statement → 'transition'
69
- */
70
- export function collectReferences(scope) {
71
- const refs = [];
72
- const explore = (body, context) => {
73
- if (!body)
74
- return;
75
- for (const n of descendants(body)) {
76
- if (n.type !== 'member_expression')
77
- continue;
78
- // member_expression text is the full chain ("@actions.Foo[.Bar]");
79
- // text matching is more robust than peeking through the wrapper
80
- // chain (expression → atom → at_id).
81
- if (!n.text.startsWith('@actions.'))
82
- continue;
83
- const name = actionNameFromMember(n);
84
- if (!name)
85
- continue;
86
- // Differentiate when we're inside a transition_statement.
87
- const ctx = isInsideTransition(n) ? 'transition' : context;
88
- refs.push({
89
- context: ctx,
90
- location: locOf(n),
91
- name,
92
- scope: scope.label,
93
- });
94
- }
95
- };
96
- explore(findMappingEntry(scope.body, 'before_reasoning'), 'before_reasoning_run');
97
- explore(findMappingEntry(scope.body, 'after_reasoning'), 'after_reasoning_run');
98
- const reasoning = findMappingEntry(scope.body, 'reasoning');
99
- if (reasoning) {
100
- // `reasoning.actions:` — the declarative action contract block;
101
- // refs here describe what the LLM is allowed to call.
102
- explore(findMappingEntry(reasoning, 'actions'), 'reasoning_actions');
103
- // `reasoning.instructions: ->` — refs here are `run @actions.X`
104
- // invocations the LLM evaluates as part of its instructions.
105
- // Per the whitepaper, these execute non-deterministically.
106
- explore(findMappingEntry(reasoning, 'instructions'), 'reasoning_instructions_run');
107
- }
108
- return refs;
109
- }
110
- function actionNameFromMember(n) {
111
- // member_expression text is "@actions.Foo_Bar" — strip the prefix.
112
- const t = n.text;
113
- const dot = t.indexOf('.');
114
- if (dot === -1)
115
- return undefined;
116
- const rest = t.slice(dot + 1);
117
- // Take the leading identifier, in case of further chained access.
118
- const m = /^([A-Za-z_][A-Za-z0-9_]*)/.exec(rest);
119
- return m?.[1];
120
- }
121
- function isInsideTransition(n) {
122
- let p = n.parent;
123
- while (p) {
124
- if (p.type === 'transition_statement')
125
- return true;
126
- p = p.parent;
127
- }
128
- return false;
129
- }
130
- //# sourceMappingURL=action-references.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action-references.js","sourceRoot":"","sources":["../../src/analyzer/action-references.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,KAAK,EACL,gBAAgB,EAChB,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,MAAM,aAAa,GAAG,4BAA4B,CAAC;AAEnD,SAAS,cAAc,CAAC,GAAuB;IAC7C,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,MAAM,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACzB,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAClC,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IACrC,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IACrC,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IACjD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAiB;IACnD,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,MAAM,YAAY,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC7D,IAAI,CAAC,YAAY;QAAE,OAAO,KAAK,CAAC;IAChC,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,aAAa,EAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB;YAAE,SAAS;QAC/C,MAAM,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAA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CAAC;QAAE,OAAO,SAAS,CAAC;IACjC,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC9B,kEAAkE;IAClE,MAAM,CAAC,GAAG,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,kBAAkB,CAAC,CAAa;IACvC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC;QACT,IAAI,CAAC,CAAC,IAAI,KAAK,sBAAsB;YAAE,OAAO,IAAI,CAAC;QACnD,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,43 +0,0 @@
1
- import type { AnalysisReport, FileReport } from './types.js';
2
- export interface AnalyzeOptions {
3
- /** Override location for apex:// resolution. Optional. */
4
- apexSourceOverride?: string;
5
- /**
6
- * Filter to specific agent bundles by API name. Each entry is matched
7
- * against (a) the bundle directory name and (b) `config.developer_name`
8
- * inside the .agent file. When omitted or empty, all discovered bundles
9
- * are analyzed.
10
- */
11
- apiNames?: string[];
12
- /**
13
- * Base directory for relative paths in the report. Defaults to the source
14
- * root (or, when multiple roots are supplied, the longest common ancestor).
15
- */
16
- reportBase?: string;
17
- }
18
- /**
19
- * Error thrown when --api-name filters produce no matches. Carries the
20
- * candidate list so callers can show a useful hint.
21
- */
22
- export declare class NoMatchingBundlesError extends Error {
23
- readonly requested: string[];
24
- readonly available: BundleIdentity[];
25
- constructor(requested: string[], available: BundleIdentity[]);
26
- }
27
- export interface BundleIdentity {
28
- /** The config.developer_name value, if present. */
29
- developerName: string | undefined;
30
- /** The bundle's directory name (parent of the .agent file). */
31
- dirName: string;
32
- /** Absolute path of the .agent file. */
33
- path: string;
34
- }
35
- /**
36
- * Analyze AgentScript bundles under one or more source roots.
37
- *
38
- * Backward-compatible: pass a single path (string) for the legacy
39
- * single-root case. Pass an array of paths for multi-root analysis
40
- * (e.g. multiple `packageDirectories` in an sfdx project).
41
- */
42
- export declare function analyzeSource(rootPathOrPaths: string | string[], options?: AnalyzeOptions): Promise<AnalysisReport>;
43
- export declare function analyzeFile(absPath: string, base: string): Promise<FileReport>;
@@ -1,222 +0,0 @@
1
- import { readdir, readFile, stat } from 'node:fs/promises';
2
- import { basename, dirname, join, relative, resolve } from 'node:path';
3
- import { collectDeclarations, collectReferences } from './action-references.js';
4
- import { analyzeReferencedApex } from './apex-analyze.js';
5
- import { collectScopes, complexityForFile } from './complexity.js';
6
- import { extractDeveloperName, parseAgentSource } from './parse.js';
7
- /**
8
- * Error thrown when --api-name filters produce no matches. Carries the
9
- * candidate list so callers can show a useful hint.
10
- */
11
- export class NoMatchingBundlesError extends Error {
12
- requested;
13
- available;
14
- constructor(requested, available) {
15
- super(`No agent bundle matched ${requested.map(n => `'${n}'`).join(', ')}. ` +
16
- `Available: ${available.map((b) => formatBundleIdentity(b)).join(', ')}`);
17
- this.requested = requested;
18
- this.available = available;
19
- this.name = 'NoMatchingBundlesError';
20
- }
21
- }
22
- function formatBundleIdentity(b) {
23
- if (b.developerName && b.developerName !== b.dirName) {
24
- return `${b.developerName} (dir: ${b.dirName})`;
25
- }
26
- return b.dirName;
27
- }
28
- /**
29
- * Analyze AgentScript bundles under one or more source roots.
30
- *
31
- * Backward-compatible: pass a single path (string) for the legacy
32
- * single-root case. Pass an array of paths for multi-root analysis
33
- * (e.g. multiple `packageDirectories` in an sfdx project).
34
- */
35
- export async function analyzeSource(rootPathOrPaths, options = {}) {
36
- const rawRoots = Array.isArray(rootPathOrPaths)
37
- ? rootPathOrPaths
38
- : [rootPathOrPaths];
39
- if (rawRoots.length === 0) {
40
- throw new Error('analyzeSource requires at least one source path');
41
- }
42
- const absRoots = rawRoots.map(p => resolve(p));
43
- const reportBase = options.reportBase
44
- ? resolve(options.reportBase)
45
- : absRoots.length === 1
46
- ? absRoots[0]
47
- : longestCommonAncestor(absRoots);
48
- const allFiles = [];
49
- for (const root of absRoots) {
50
- const files = await findAgentFiles(root);
51
- for (const f of files)
52
- if (!allFiles.includes(f))
53
- allFiles.push(f);
54
- }
55
- allFiles.sort();
56
- const filteredFiles = await filterByApiNames(allFiles, options.apiNames);
57
- const fileReports = [];
58
- for (const file of filteredFiles) {
59
- fileReports.push(await analyzeFile(file, reportBase));
60
- }
61
- const apex = await analyzeReferencedApex({
62
- agentAbsPaths: filteredFiles,
63
- apexSourceOverride: options.apexSourceOverride,
64
- fileReports,
65
- sourceDirRoot: reportBase,
66
- });
67
- const report = {
68
- apexClasses: apex.classes,
69
- byTargetKind: tallyTargets(fileReports),
70
- files: fileReports,
71
- totalApexComplexity: apex.classes.reduce((acc, c) => acc + c.classComplexity, 0),
72
- totalComplexity: fileReports.reduce((acc, f) => acc + f.fileComplexity, 0),
73
- totalDeclarations: fileReports.reduce((acc, f) => acc + f.declarations.length, 0),
74
- totalReferences: fileReports.reduce((acc, f) => acc + f.references.length, 0),
75
- unresolvedApexTargets: apex.unresolved,
76
- };
77
- return report;
78
- }
79
- export async function analyzeFile(absPath, base) {
80
- const source = await readFile(absPath, 'utf8');
81
- const root = parseAgentSource(source);
82
- const cc = complexityForFile(root);
83
- const { procedures } = cc;
84
- const scopes = collectScopes(root);
85
- const declarations = [];
86
- const references = [];
87
- for (const s of scopes) {
88
- declarations.push(...collectDeclarations(s));
89
- references.push(...collectReferences(s));
90
- }
91
- return {
92
- declarations,
93
- fileComplexity: cc.total,
94
- parseErrors: [], // CST is error-tolerant; surface diagnostics in a later iteration.
95
- path: relative(base, absPath),
96
- procedures,
97
- references,
98
- };
99
- }
100
- async function findAgentFiles(root) {
101
- const s = await stat(root).catch(() => { });
102
- if (!s)
103
- throw new Error(`source path does not exist: ${root}`);
104
- if (s.isFile())
105
- return root.endsWith('.agent') ? [root] : [];
106
- const out = [];
107
- const visit = async (dir) => {
108
- const entries = await readdir(dir, { withFileTypes: true });
109
- for (const e of entries) {
110
- if (e.name.startsWith('.'))
111
- continue;
112
- if (e.name === 'node_modules' || e.name === 'vendor' || e.name === 'lib')
113
- continue;
114
- const full = join(dir, e.name);
115
- if (e.isDirectory())
116
- await visit(full);
117
- else if (e.isFile() && e.name.endsWith('.agent'))
118
- out.push(full);
119
- }
120
- };
121
- await visit(root);
122
- out.sort();
123
- return out;
124
- }
125
- function tallyTargets(files) {
126
- const acc = {
127
- apex: 0,
128
- flow: 0,
129
- prompt: 0,
130
- unknown: 0,
131
- utils: 0,
132
- };
133
- for (const f of files)
134
- for (const d of f.declarations)
135
- acc[d.targetKind]++;
136
- return acc;
137
- }
138
- /**
139
- * Filter the discovered .agent file list by the supplied `--api-name`
140
- * values. A bundle matches if (a) its directory name equals a requested
141
- * name, or (b) its `config.developer_name` equals one. Bundles whose dir
142
- * name already matches are kept without parsing; only the remainder are
143
- * parsed for `developer_name` resolution.
144
- *
145
- * Throws NoMatchingBundlesError when filters were supplied but nothing
146
- * matched, so callers can show the available list.
147
- */
148
- async function filterByApiNames(files, apiNames) {
149
- if (!apiNames || apiNames.length === 0)
150
- return files;
151
- const wanted = new Set(apiNames);
152
- const matches = [];
153
- const unmatched = [];
154
- for (const file of files) {
155
- const dirName = basename(dirname(file));
156
- if (wanted.has(dirName)) {
157
- matches.push(file);
158
- }
159
- else {
160
- unmatched.push(file);
161
- }
162
- }
163
- if (matches.length === files.length || unmatched.length === 0) {
164
- return matches;
165
- }
166
- // Slow path: parse the still-unmatched files to read developer_name.
167
- const identities = [];
168
- for (const file of unmatched) {
169
- const dirName = basename(dirname(file));
170
- const developerName = await readDeveloperName(file);
171
- identities.push({ developerName, dirName, path: file });
172
- if (developerName && wanted.has(developerName)) {
173
- matches.push(file);
174
- }
175
- }
176
- if (matches.length === 0) {
177
- // Build the full candidate list (matched dirs + parsed unmatched) for
178
- // the error message.
179
- const all = [];
180
- for (const file of files) {
181
- const existing = identities.find(i => i.path === file);
182
- if (existing) {
183
- all.push(existing);
184
- }
185
- else {
186
- all.push({
187
- developerName: await readDeveloperName(file),
188
- dirName: basename(dirname(file)),
189
- path: file,
190
- });
191
- }
192
- }
193
- all.sort((a, b) => a.dirName.localeCompare(b.dirName));
194
- throw new NoMatchingBundlesError(apiNames, all);
195
- }
196
- matches.sort();
197
- return matches;
198
- }
199
- async function readDeveloperName(file) {
200
- const source = await readFile(file, 'utf8');
201
- const root = parseAgentSource(source);
202
- return extractDeveloperName(root);
203
- }
204
- function longestCommonAncestor(paths) {
205
- if (paths.length === 0)
206
- return process.cwd();
207
- if (paths.length === 1)
208
- return paths[0];
209
- const split = paths.map(p => p.split('/'));
210
- const minLen = Math.min(...split.map(s => s.length));
211
- const common = [];
212
- for (let i = 0; i < minLen; i++) {
213
- const seg = split[0][i];
214
- if (split.every(s => s[i] === seg))
215
- common.push(seg);
216
- else
217
- break;
218
- }
219
- const joined = common.join('/') || '/';
220
- return joined;
221
- }
222
- //# sourceMappingURL=analyze.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../src/analyzer/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAG,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUvE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAmBpE;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAE7B;IACA;IAFlB,YACkB,SAAmB,EACnB,SAA2B;Q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,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,14 +0,0 @@
1
- import type { ApexClassReport, FileReport } from './types.js';
2
- /** Inputs needed to resolve and analyze every apex:// target in the bundle. */
3
- export interface ApexAnalyzeInputs {
4
- /** Absolute paths of every .agent file analyzed, parallel to fileReports. */
5
- agentAbsPaths: string[];
6
- apexSourceOverride?: string;
7
- fileReports: FileReport[];
8
- sourceDirRoot: string;
9
- }
10
- export interface ApexAnalyzeOutputs {
11
- classes: ApexClassReport[];
12
- unresolved: string[];
13
- }
14
- export declare function analyzeReferencedApex(inputs: ApexAnalyzeInputs): Promise<ApexAnalyzeOutputs>;
@@ -1,60 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { basename, relative } from 'node:path';
3
- import { complexityOfMethod, methodsInCompilationUnit } from './apex-complexity.js';
4
- import { parseApexSource } from './apex-parse.js';
5
- import { extractApexClassName, resolveApexClassPath, } from './apex-resolve.js';
6
- export async function analyzeReferencedApex(inputs) {
7
- const byPath = new Map();
8
- const unresolved = new Set();
9
- for (let i = 0; i < inputs.fileReports.length; i++) {
10
- const fr = inputs.fileReports[i];
11
- const agentAbs = inputs.agentAbsPaths[i];
12
- for (const decl of fr.declarations) {
13
- if (decl.targetKind !== 'apex' || !decl.target)
14
- continue;
15
- const className = extractApexClassName(decl.target);
16
- if (!className) {
17
- unresolved.add(decl.target);
18
- continue;
19
- }
20
- const path = await resolveApexClassPath(className, {
21
- agentFilePath: agentAbs,
22
- apexSourceOverride: inputs.apexSourceOverride,
23
- sourceDirRoot: inputs.sourceDirRoot,
24
- });
25
- if (!path) {
26
- unresolved.add(decl.target);
27
- continue;
28
- }
29
- const existing = byPath.get(path);
30
- if (existing) {
31
- if (!existing.referencedBy.includes(fr.path)) {
32
- existing.referencedBy.push(fr.path);
33
- }
34
- continue;
35
- }
36
- const report = await analyzeApexClass(path, className, [fr.path], inputs.sourceDirRoot);
37
- byPath.set(path, report);
38
- }
39
- }
40
- return {
41
- classes: [...byPath.values()].sort((a, b) => a.className.localeCompare(b.className)),
42
- unresolved: [...unresolved].sort(),
43
- };
44
- }
45
- async function analyzeApexClass(absPath, className, referencedBy, sourceDirRoot) {
46
- const source = await readFile(absPath, 'utf8');
47
- const cu = parseApexSource(source);
48
- const methodCtxs = methodsInCompilationUnit(cu);
49
- const methods = methodCtxs.map((m) => complexityOfMethod(m));
50
- const classComplexity = methods.reduce((acc, m) => acc + m.complexity, 0);
51
- return {
52
- classComplexity,
53
- className: className || basename(absPath, '.cls'),
54
- methods,
55
- parseErrors: [],
56
- path: relative(sourceDirRoot, absPath),
57
- referencedBy,
58
- };
59
- }
60
- //# sourceMappingURL=apex-analyze.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apex-analyze.js","sourceRoot":"","sources":["../../src/analyzer/apex-analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAQ/C,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAgB3B,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAyB;IAEzB,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;IAClD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IAErC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnD,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;Q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AAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACpF,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE;KACnC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,OAAe,EACf,SAAiB,EACjB,YAAsB,EACtB,aAAqB;IAErB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,wBAAwB,CAAC,EAAE,CAAC,CAAC;IAChD,MAAM,OAAO,GAAmB,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAE1E,OAAO;QACL,eAAe;QACf,SAAS,EAAE,SAAS,IAAI,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACjD,OAAO;QACP,WAAW,EAAE,EAAE;QACf,IAAI,EAAE,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;QACtC,YAAY;KACb,CAAC;AACJ,CAAC"}
@@ -1,27 +0,0 @@
1
- import { type CompilationUnitContext, ConstructorDeclarationContext, MethodDeclarationContext } from '@apexdevtools/apex-parser';
2
- import type { ApexMethodCC } from './types.js';
3
- /**
4
- * Standard McCabe Cyclomatic Complexity for Apex, per the SonarQube /
5
- * PMD CyclomaticComplexity convention used in the categorization
6
- * whitepaper § 7:
7
- *
8
- * CC = 1
9
- * + count(if)
10
- * + count(for) // includes enhanced-for (for-each)
11
- * + count(while)
12
- * + count(do-while)
13
- * + count(when arm) // each switch `when X { ... }`; `when else` excluded
14
- * + count(catch) // each catch clause
15
- * + count(ternary ?:)
16
- * + count(&&)
17
- * + count(||)
18
- *
19
- * Not counted: else, when else, finally, try itself.
20
- */
21
- export declare function complexityOfMethod(methodCtx: ConstructorDeclarationContext | MethodDeclarationContext): ApexMethodCC;
22
- /**
23
- * Enumerate every method and constructor in a compilation unit, including
24
- * those nested inside inner classes. Each gets its own CC entry per the
25
- * v2 scope ("all methods in any class touched by apex://").
26
- */
27
- export declare function methodsInCompilationUnit(cu: CompilationUnitContext): Array<ConstructorDeclarationContext | MethodDeclarationContext>;