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,260 @@
1
+ /*
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * For full license text, see the LICENSE file in the repo root or https://www.apache.org/licenses/LICENSE-2.0
6
+ */
7
+ /**
8
+ * Walk the CST and produce highlight captures matching highlights.scm.
9
+ *
10
+ * Tree-sitter query priority: later patterns override earlier ones.
11
+ * We replicate this by first assigning generic captures, then overriding
12
+ * with contextual ones (e.g., id → variable, then key > id → property).
13
+ */
14
+ export function highlight(root) {
15
+ const captures = [];
16
+ walkNode(root, captures);
17
+ return captures;
18
+ }
19
+ function capture(node, name, captures) {
20
+ captures.push({
21
+ name,
22
+ text: node.text,
23
+ startRow: node.startRow,
24
+ startCol: node.startCol,
25
+ endRow: node.endRow,
26
+ endCol: node.endCol,
27
+ });
28
+ }
29
+ function walkNode(node, captures) {
30
+ // --- Named node type-based captures ---
31
+ switch (node.type) {
32
+ case 'comment':
33
+ capture(node, 'comment', captures);
34
+ return; // Don't recurse into comments
35
+ case 'number':
36
+ capture(node, 'number', captures);
37
+ return;
38
+ case 'string':
39
+ capture(node, 'string', captures);
40
+ // Recurse to get escape_sequence captures
41
+ for (const child of node.children) {
42
+ if (child.type === 'escape_sequence') {
43
+ capture(child, 'string.escape', captures);
44
+ }
45
+ }
46
+ return;
47
+ case 'string_content':
48
+ capture(node, 'string', captures);
49
+ return;
50
+ case 'escape_sequence':
51
+ capture(node, 'string.escape', captures);
52
+ return;
53
+ case 'template_content':
54
+ capture(node, 'string', captures);
55
+ return;
56
+ case 'ellipsis':
57
+ capture(node, 'constant.builtin', captures);
58
+ return;
59
+ case 'id':
60
+ captureId(node, captures);
61
+ return;
62
+ case 'at_id':
63
+ captureAtId(node, captures);
64
+ return;
65
+ case 'template_expression':
66
+ captureTemplateExpression(node, captures);
67
+ return;
68
+ case 'variable_declaration':
69
+ captureVariableDeclaration(node, captures);
70
+ return;
71
+ }
72
+ // --- Anonymous node captures (punctuation, keywords, operators) ---
73
+ if (!node.isNamed && node.children.length === 0) {
74
+ captureAnonymous(node, captures);
75
+ return;
76
+ }
77
+ // Recurse into children
78
+ for (const child of node.children) {
79
+ walkNode(child, captures);
80
+ }
81
+ }
82
+ /** Check if a key node belongs to a root-level mapping element (source_file > mapping > mapping_element > key). */
83
+ function isRootLevelKey(keyNode) {
84
+ const mappingElement = keyNode.parent;
85
+ if (mappingElement?.type !== 'mapping_element')
86
+ return false;
87
+ const mapping = mappingElement.parent;
88
+ if (mapping?.type !== 'mapping')
89
+ return false;
90
+ return mapping.parent?.type === 'source_file';
91
+ }
92
+ /** Capture an identifier based on its parent context. */
93
+ function captureId(node, captures) {
94
+ const parent = node.parent;
95
+ // Constants: True, False, None
96
+ if (node.text === 'True' || node.text === 'False' || node.text === 'None') {
97
+ capture(node, 'constant.builtin', captures);
98
+ return;
99
+ }
100
+ // Inside at_id: @identifier → module (namespace)
101
+ if (parent?.type === 'at_id') {
102
+ capture(node, 'module', captures);
103
+ return;
104
+ }
105
+ // Mapping key: (key (id)) → property, or block keyword/name at root level
106
+ if (parent?.type === 'key') {
107
+ if (isRootLevelKey(parent)) {
108
+ const namedSiblings = parent.namedChildren;
109
+ if (namedSiblings.length > 0 && namedSiblings[0] === node) {
110
+ capture(node, 'keyword.block', captures);
111
+ }
112
+ else {
113
+ capture(node, 'keyword.block.name', captures);
114
+ }
115
+ }
116
+ else {
117
+ capture(node, 'key', captures);
118
+ }
119
+ return;
120
+ }
121
+ // Member expression: expr.id → variable (the property after dot)
122
+ if (parent?.type === 'member_expression') {
123
+ // Only the trailing id (not the expression part)
124
+ const parentChildren = parent.namedChildren;
125
+ if (parentChildren.length > 0 &&
126
+ parentChildren[parentChildren.length - 1] === node) {
127
+ capture(node, 'variable', captures);
128
+ return;
129
+ }
130
+ }
131
+ // With-statement param: with param=value → variable
132
+ if (parent?.type === 'with_statement') {
133
+ const fieldName = parent.fieldNameForChild(node._childIndex);
134
+ if (fieldName === 'param') {
135
+ capture(node, 'variable', captures);
136
+ return;
137
+ }
138
+ }
139
+ // Default: variable
140
+ capture(node, 'variable', captures);
141
+ }
142
+ /** Capture @identifier — the @ and the id inside. */
143
+ function captureAtId(node, captures) {
144
+ for (const child of node.children) {
145
+ if (child.type === '@' || child.text === '@') {
146
+ capture(child, 'decorator', captures);
147
+ }
148
+ else if (child.type === 'id') {
149
+ capture(child, 'module', captures);
150
+ }
151
+ }
152
+ }
153
+ /** Capture template expression delimiters {! and }. */
154
+ function captureTemplateExpression(node, captures) {
155
+ for (const child of node.children) {
156
+ if (child.text === '{!') {
157
+ capture(child, 'punctuation.template', captures);
158
+ }
159
+ else if (child.text === '}') {
160
+ capture(child, 'punctuation.template', captures);
161
+ }
162
+ else {
163
+ walkNode(child, captures);
164
+ }
165
+ }
166
+ }
167
+ /** Capture variable declaration modifiers (mutable/linked). */
168
+ function captureVariableDeclaration(node, captures) {
169
+ for (const child of node.children) {
170
+ if (!child.isNamed &&
171
+ (child.text === 'mutable' || child.text === 'linked')) {
172
+ capture(child, 'keyword.modifier', captures);
173
+ }
174
+ else {
175
+ walkNode(child, captures);
176
+ }
177
+ }
178
+ }
179
+ /** Capture anonymous nodes: keywords, operators, punctuation. */
180
+ function captureAnonymous(node, captures) {
181
+ const text = node.text;
182
+ // Keywords
183
+ switch (text) {
184
+ case 'if':
185
+ case 'elif':
186
+ case 'else':
187
+ case 'run':
188
+ case 'with':
189
+ case 'set':
190
+ case 'transition':
191
+ case 'available':
192
+ case 'when':
193
+ case 'and':
194
+ case 'or':
195
+ case 'not':
196
+ case 'is':
197
+ case 'to':
198
+ capture(node, 'keyword', captures);
199
+ return;
200
+ case 'mutable':
201
+ case 'linked':
202
+ capture(node, 'keyword.modifier', captures);
203
+ return;
204
+ case 'True':
205
+ case 'False':
206
+ case 'None':
207
+ capture(node, 'constant.builtin', captures);
208
+ return;
209
+ }
210
+ // Operators
211
+ switch (text) {
212
+ case '==':
213
+ case '!=':
214
+ case '<':
215
+ case '>':
216
+ case '<=':
217
+ case '>=':
218
+ case '+':
219
+ case '*':
220
+ case '/':
221
+ case '=':
222
+ capture(node, 'operator', captures);
223
+ return;
224
+ case '-':
225
+ // '-' in sequence dash is punctuation.special, otherwise operator
226
+ if (node.parent?.type === 'sequence_element') {
227
+ capture(node, 'punctuation.special', captures);
228
+ }
229
+ else {
230
+ capture(node, 'operator', captures);
231
+ }
232
+ return;
233
+ }
234
+ // Punctuation
235
+ switch (text) {
236
+ case ':':
237
+ case '.':
238
+ case ',':
239
+ capture(node, 'punctuation.delimiter', captures);
240
+ return;
241
+ case '[':
242
+ case ']':
243
+ case '{':
244
+ case '}':
245
+ capture(node, 'punctuation.bracket', captures);
246
+ return;
247
+ case '|':
248
+ case '->':
249
+ case '- ':
250
+ capture(node, 'punctuation.special', captures);
251
+ return;
252
+ case '@':
253
+ capture(node, 'decorator', captures);
254
+ return;
255
+ case '"':
256
+ capture(node, 'string', captures);
257
+ return;
258
+ }
259
+ }
260
+ //# sourceMappingURL=highlighter.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @agentscript/parser-javascript — Hand-written TypeScript parser for AgentScript.
3
+ *
4
+ * Error-tolerant: NEWLINE and DEDENT are unconditional recovery points.
5
+ */
6
+ export { CSTNode } from './cst-node.js';
7
+ export type { SyntaxNode } from '@agentscript/types';
8
+ export { TokenKind } from './token.js';
9
+ export type { Token, Position } from './token.js';
10
+ export type { TokenStream, NodeBuilder, ParserContext } from './parser.js';
11
+ export { highlight } from './highlighter.js';
12
+ export type { HighlightCapture } from './highlighter.js';
13
+ import type { CSTNode } from './cst-node.js';
14
+ import type { HighlightCapture } from './highlighter.js';
15
+ /**
16
+ * Parse AgentScript source code and return a CST.
17
+ * The returned rootNode implements the SyntaxNode interface
18
+ * used by all consumers (dialect, LSP, monaco, agentforce).
19
+ */
20
+ export declare function parse(source: string): {
21
+ rootNode: CSTNode;
22
+ };
23
+ /**
24
+ * Parse and highlight source code in one call.
25
+ * Returns captures compatible with the QueryCapture format
26
+ * used by LSP semantic tokens.
27
+ */
28
+ export declare function parseAndHighlight(source: string): HighlightCapture[];
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * For full license text, see the LICENSE file in the repo root or https://www.apache.org/licenses/LICENSE-2.0
6
+ */
7
+ /**
8
+ * @agentscript/parser-javascript — Hand-written TypeScript parser for AgentScript.
9
+ *
10
+ * Error-tolerant: NEWLINE and DEDENT are unconditional recovery points.
11
+ */
12
+ export { CSTNode } from './cst-node.js';
13
+ export { TokenKind } from './token.js';
14
+ export { highlight } from './highlighter.js';
15
+ import { Parser } from './parser.js';
16
+ import { highlight } from './highlighter.js';
17
+ /**
18
+ * Parse AgentScript source code and return a CST.
19
+ * The returned rootNode implements the SyntaxNode interface
20
+ * used by all consumers (dialect, LSP, monaco, agentforce).
21
+ */
22
+ export function parse(source) {
23
+ const parser = new Parser(source);
24
+ return { rootNode: parser.parse() };
25
+ }
26
+ /**
27
+ * Parse and highlight source code in one call.
28
+ * Returns captures compatible with the QueryCapture format
29
+ * used by LSP semantic tokens.
30
+ */
31
+ export function parseAndHighlight(source) {
32
+ const { rootNode } = parse(source);
33
+ return highlight(rootNode);
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,60 @@
1
+ import { type Token } from './token.js';
2
+ export declare class Lexer {
3
+ private source;
4
+ private offset;
5
+ private row;
6
+ private col;
7
+ private tokens;
8
+ private indentStack;
9
+ /** True when the current line started with `|` (template line). */
10
+ private onTemplateLine;
11
+ /** Indent level of the line containing `|`. Content deeper than this is template content. */
12
+ private templateBaseIndent;
13
+ /** Nested brace depth inside a template expression (for `{` inside `{!...}`). -1 means not inside a template expression. */
14
+ private templateExprBraceDepth;
15
+ private get inTemplateExpr();
16
+ /** Parenthesis depth — suppresses INDENT/DEDENT/NEWLINE when > 0 to support multi-line call expressions. */
17
+ private bracketDepth;
18
+ constructor(source: string);
19
+ tokenize(): Token[];
20
+ private tokenizeLine;
21
+ private emitIndentation;
22
+ private tokenizeToken;
23
+ private tokenizeId;
24
+ private tokenizeNumber;
25
+ private tryDatetime;
26
+ private tokenizeString;
27
+ private tokenizeComment;
28
+ private consumeIndentation;
29
+ /**
30
+ * Scan ahead (without advancing) past comment/blank lines to find the indent
31
+ * of the next line with real (non-comment) content. Returns -1 if only
32
+ * comments, blanks, or EOF remain. Matches tree-sitter scanner behavior which
33
+ * skips past comment-only lines when computing INDENT/DEDENT.
34
+ */
35
+ private peekNextContentIndent;
36
+ private peekCharCode;
37
+ private get hasMore();
38
+ /**
39
+ * Attempt to advance n characters.
40
+ * @returns how many characters were advanced.
41
+ */
42
+ private advance;
43
+ /**
44
+ * Attempt to consume a newline.
45
+ * @returns whether a newline was consumed.
46
+ */
47
+ private consumeNewline;
48
+ /**
49
+ * Checks if the current position is at a newline.
50
+ * @param additiveOffset
51
+ * @returns 0 if not at a newline, 1 if at an LF newline, 2 if at a CR LF newline.
52
+ */
53
+ private atNewline;
54
+ private get position();
55
+ private emitSpan;
56
+ private emit;
57
+ private emitVirtual;
58
+ private makeToken;
59
+ }
60
+ //# sourceMappingURL=lexer.d.ts.map