@interlace/eslint-devkit 1.2.1 → 1.3.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 (79) hide show
  1. package/AGENTS.md +99 -300
  2. package/README.md +4 -3
  3. package/package.json +2 -3
  4. package/src/aria-definitions.d.ts +5 -0
  5. package/src/aria-definitions.js +7 -3
  6. package/src/ast/ast-utils.d.ts +5 -0
  7. package/src/ast/ast-utils.js +5 -1
  8. package/src/ast/index.d.ts +5 -0
  9. package/src/ast/index.js +5 -1
  10. package/src/index.d.ts +7 -2
  11. package/src/index.js +9 -4
  12. package/src/messaging/config.d.ts +129 -0
  13. package/src/messaging/config.js +186 -0
  14. package/src/messaging/constants.d.ts +16 -2
  15. package/src/messaging/constants.js +62 -6
  16. package/src/messaging/formatters-ai.d.ts +94 -0
  17. package/src/messaging/formatters-ai.js +265 -0
  18. package/src/messaging/formatters.d.ts +5 -0
  19. package/src/messaging/formatters.js +3 -4
  20. package/src/messaging/index.d.ts +7 -0
  21. package/src/messaging/index.js +7 -1
  22. package/src/messaging/types.d.ts +39 -1
  23. package/src/messaging/types.js +3 -4
  24. package/src/node/fs.d.ts +5 -0
  25. package/src/node/fs.js +5 -1
  26. package/src/node/index.d.ts +5 -0
  27. package/src/node/index.js +5 -1
  28. package/src/node/os.d.ts +5 -0
  29. package/src/node/os.js +5 -1
  30. package/src/node/path.d.ts +5 -0
  31. package/src/node/path.js +5 -1
  32. package/src/resolver/dependency-analysis.d.ts +5 -0
  33. package/src/resolver/dependency-analysis.js +5 -1
  34. package/src/resolver/index.d.ts +5 -0
  35. package/src/resolver/index.js +5 -1
  36. package/src/resolver/resolver-adapter.d.ts +5 -0
  37. package/src/resolver/resolver-adapter.js +5 -1
  38. package/src/resolver/resolver-detection.d.ts +5 -0
  39. package/src/resolver/resolver-detection.js +11 -7
  40. package/src/resolver/resolver.d.ts +5 -0
  41. package/src/resolver/resolver.js +5 -1
  42. package/src/resolver.d.ts +5 -0
  43. package/src/resolver.js +5 -1
  44. package/src/rule-creation/index.d.ts +5 -0
  45. package/src/rule-creation/index.js +5 -1
  46. package/src/rule-creation/rule-creator.d.ts +5 -0
  47. package/src/rule-creation/rule-creator.js +6 -2
  48. package/src/security/index.d.ts +5 -0
  49. package/src/security/index.js +5 -1
  50. package/src/security/security-utils.d.ts +5 -0
  51. package/src/security/security-utils.js +5 -1
  52. package/src/types/index.d.ts +5 -0
  53. package/src/types/index.js +5 -1
  54. package/src/types/type-utils.d.ts +5 -0
  55. package/src/types/type-utils.js +5 -1
  56. package/src/aria-definitions.js.map +0 -1
  57. package/src/ast/ast-utils.js.map +0 -1
  58. package/src/ast/index.js.map +0 -1
  59. package/src/index.js.map +0 -1
  60. package/src/messaging/constants.js.map +0 -1
  61. package/src/messaging/formatters.js.map +0 -1
  62. package/src/messaging/index.js.map +0 -1
  63. package/src/messaging/types.js.map +0 -1
  64. package/src/node/fs.js.map +0 -1
  65. package/src/node/index.js.map +0 -1
  66. package/src/node/os.js.map +0 -1
  67. package/src/node/path.js.map +0 -1
  68. package/src/resolver/dependency-analysis.js.map +0 -1
  69. package/src/resolver/index.js.map +0 -1
  70. package/src/resolver/resolver-adapter.js.map +0 -1
  71. package/src/resolver/resolver-detection.js.map +0 -1
  72. package/src/resolver/resolver.js.map +0 -1
  73. package/src/resolver.js.map +0 -1
  74. package/src/rule-creation/index.js.map +0 -1
  75. package/src/rule-creation/rule-creator.js.map +0 -1
  76. package/src/security/index.js.map +0 -1
  77. package/src/security/security-utils.js.map +0 -1
  78. package/src/types/index.js.map +0 -1
  79. package/src/types/type-utils.js.map +0 -1
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * Global configuration for AI-Native messaging
8
+ * Manages the "Target Intelligence Class" (TIC) state
9
+ *
10
+ * PRIORITY ORDER:
11
+ * 1. Environment Variable (ESLINT_AI_MODE) - Agent escape hatch
12
+ * 2. Explicit ESLint Settings (interlace/ai-mode) - Developer override
13
+ * 3. Auto-Detection (if enableAutoAgentDetection: true) - Opt-in magic
14
+ * 4. Default: CLI (Human)
15
+ */
16
+ import type { MessagingEnvironment } from './types';
17
+ /**
18
+ * ESLint Rule Context settings interface
19
+ * Matches the shape of `context.settings` in ESLint rules
20
+ */
21
+ export interface InterlaceSettings {
22
+ /** Explicit AI mode override */
23
+ 'interlace/ai-mode'?: MessagingEnvironment;
24
+ /** Enable automatic detection of AI agent environments */
25
+ 'interlace/enableAutoAgentDetection'?: boolean;
26
+ /** Enable token compression for smaller payloads */
27
+ 'interlace/compression'?: boolean;
28
+ }
29
+ /**
30
+ * Minimal ESLint RuleContext interface (subset we need)
31
+ */
32
+ export interface RuleContextLike {
33
+ settings?: InterlaceSettings & Record<string, unknown>;
34
+ }
35
+ /**
36
+ * Known AI Agent environments and their detection indicators
37
+ * Each entry includes a link to documentation confirming the env var
38
+ */
39
+ export declare const KNOWN_AGENT_ENVIRONMENTS: {
40
+ /**
41
+ * Cursor IDE AI Agent
42
+ * @see https://docs.cursor.com/context/rules-for-ai#agent-specific-rules
43
+ * @see https://forum.cursor.com/t/feature-request-env-variable-for-composer-agent-runs/49449
44
+ */
45
+ readonly CURSOR: {
46
+ readonly envVar: "CURSOR_AGENT";
47
+ readonly mode: MessagingEnvironment;
48
+ readonly description: "Cursor IDE AI Agent";
49
+ };
50
+ /**
51
+ * GitHub Copilot Workspace
52
+ * @see https://docs.github.com/en/copilot/using-github-copilot/using-github-copilot-for-pull-requests
53
+ * Note: Env var is convention-based, verify in your Copilot Workspace runtime
54
+ */
55
+ readonly GITHUB_COPILOT: {
56
+ readonly envVar: "GITHUB_COPILOT_WORKSPACE";
57
+ readonly mode: MessagingEnvironment;
58
+ readonly description: "GitHub Copilot Workspace";
59
+ };
60
+ /**
61
+ * Anthropic Model Context Protocol (Claude Code, etc.)
62
+ * @see https://modelcontextprotocol.io/introduction
63
+ * Note: Proposed convention for MCP-based agents
64
+ */
65
+ readonly ANTHROPIC_MCP: {
66
+ readonly envVar: "ANTHROPIC_MCP";
67
+ readonly mode: MessagingEnvironment;
68
+ readonly description: "Anthropic Model Context Protocol";
69
+ };
70
+ /**
71
+ * OpenAI Agent / Code Interpreter
72
+ * @see https://platform.openai.com/docs/assistants/tools/code-interpreter
73
+ * Note: Proposed convention for OpenAI-based agents
74
+ */
75
+ readonly OPENAI_AGENT: {
76
+ readonly envVar: "OPENAI_AGENT";
77
+ readonly mode: MessagingEnvironment;
78
+ readonly description: "OpenAI Agent / Code Interpreter";
79
+ };
80
+ /**
81
+ * Generic AI Agent flag
82
+ * Use this when your agent framework doesn't have a specific env var
83
+ * Set AI_AGENT=true in your agent's environment
84
+ */
85
+ readonly GENERIC_AI: {
86
+ readonly envVar: "AI_AGENT";
87
+ readonly mode: MessagingEnvironment;
88
+ readonly description: "Generic AI Agent (set AI_AGENT=true)";
89
+ };
90
+ };
91
+ /**
92
+ * Detects known AI agent environments from environment variables
93
+ * Returns the appropriate mode if a known environment is detected
94
+ */
95
+ export declare function detectKnownAgentEnvironment(): MessagingEnvironment | null;
96
+ /**
97
+ * Resolves the AI messaging mode based on the priority chain:
98
+ * 1. ENV VAR (ESLINT_AI_MODE) - Highest priority
99
+ * 2. Explicit setting (interlace/ai-mode)
100
+ * 3. Auto-detection (if enableAutoAgentDetection: true)
101
+ * 4. Default: CLI
102
+ *
103
+ * @param context - ESLint rule context (or context-like object with settings)
104
+ * @returns The resolved messaging environment
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // In an ESLint rule
109
+ * create(context) {
110
+ * const mode = resolveAIMode(context);
111
+ * // mode is 'CLI' | 'CI' | 'IDE_CURSOR' | 'AGENT_JSON'
112
+ * }
113
+ * ```
114
+ */
115
+ export declare function resolveAIMode(context?: RuleContextLike): MessagingEnvironment;
116
+ /**
117
+ * Resolves whether compression is enabled
118
+ */
119
+ export declare function resolveCompression(context?: RuleContextLike): boolean;
120
+ /** @deprecated Use resolveAIMode(context) instead */
121
+ export declare function setAIMessagingMode(mode: MessagingEnvironment): void;
122
+ /** @deprecated Use resolveAIMode(context) instead */
123
+ export declare function getAIMessagingMode(): MessagingEnvironment;
124
+ /** @deprecated Use resolveCompression(context) instead */
125
+ export declare function setTokenCompression(enabled: boolean): void;
126
+ /** @deprecated Use resolveCompression(context) instead */
127
+ export declare function isTokenCompressionEnabled(): boolean;
128
+ /** Reset config to defaults (for testing) */
129
+ export declare function resetGlobalAIConfig(): void;
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.KNOWN_AGENT_ENVIRONMENTS = void 0;
9
+ exports.detectKnownAgentEnvironment = detectKnownAgentEnvironment;
10
+ exports.resolveAIMode = resolveAIMode;
11
+ exports.resolveCompression = resolveCompression;
12
+ exports.setAIMessagingMode = setAIMessagingMode;
13
+ exports.getAIMessagingMode = getAIMessagingMode;
14
+ exports.setTokenCompression = setTokenCompression;
15
+ exports.isTokenCompressionEnabled = isTokenCompressionEnabled;
16
+ exports.resetGlobalAIConfig = resetGlobalAIConfig;
17
+ /**
18
+ * Known AI Agent environments and their detection indicators
19
+ * Each entry includes a link to documentation confirming the env var
20
+ */
21
+ exports.KNOWN_AGENT_ENVIRONMENTS = {
22
+ /**
23
+ * Cursor IDE AI Agent
24
+ * @see https://docs.cursor.com/context/rules-for-ai#agent-specific-rules
25
+ * @see https://forum.cursor.com/t/feature-request-env-variable-for-composer-agent-runs/49449
26
+ */
27
+ CURSOR: {
28
+ envVar: 'CURSOR_AGENT',
29
+ mode: 'IDE_CURSOR',
30
+ description: 'Cursor IDE AI Agent',
31
+ },
32
+ /**
33
+ * GitHub Copilot Workspace
34
+ * @see https://docs.github.com/en/copilot/using-github-copilot/using-github-copilot-for-pull-requests
35
+ * Note: Env var is convention-based, verify in your Copilot Workspace runtime
36
+ */
37
+ GITHUB_COPILOT: {
38
+ envVar: 'GITHUB_COPILOT_WORKSPACE',
39
+ mode: 'AGENT_JSON',
40
+ description: 'GitHub Copilot Workspace',
41
+ },
42
+ /**
43
+ * Anthropic Model Context Protocol (Claude Code, etc.)
44
+ * @see https://modelcontextprotocol.io/introduction
45
+ * Note: Proposed convention for MCP-based agents
46
+ */
47
+ ANTHROPIC_MCP: {
48
+ envVar: 'ANTHROPIC_MCP',
49
+ mode: 'AGENT_JSON',
50
+ description: 'Anthropic Model Context Protocol',
51
+ },
52
+ /**
53
+ * OpenAI Agent / Code Interpreter
54
+ * @see https://platform.openai.com/docs/assistants/tools/code-interpreter
55
+ * Note: Proposed convention for OpenAI-based agents
56
+ */
57
+ OPENAI_AGENT: {
58
+ envVar: 'OPENAI_AGENT',
59
+ mode: 'AGENT_JSON',
60
+ description: 'OpenAI Agent / Code Interpreter',
61
+ },
62
+ /**
63
+ * Generic AI Agent flag
64
+ * Use this when your agent framework doesn't have a specific env var
65
+ * Set AI_AGENT=true in your agent's environment
66
+ */
67
+ GENERIC_AI: {
68
+ envVar: 'AI_AGENT',
69
+ mode: 'AGENT_JSON',
70
+ description: 'Generic AI Agent (set AI_AGENT=true)',
71
+ },
72
+ };
73
+ const GLOBAL_AI_CONFIG = {
74
+ mode: 'CLI',
75
+ compression: false,
76
+ };
77
+ // ============================================================================
78
+ // DETECTION FUNCTIONS
79
+ // ============================================================================
80
+ /**
81
+ * Detects known AI agent environments from environment variables
82
+ * Returns the appropriate mode if a known environment is detected
83
+ */
84
+ function detectKnownAgentEnvironment() {
85
+ for (const env of Object.values(exports.KNOWN_AGENT_ENVIRONMENTS)) {
86
+ if (process.env[env.envVar]) {
87
+ return env.mode;
88
+ }
89
+ }
90
+ return null;
91
+ }
92
+ /**
93
+ * Detects environment from env vars (simple detection)
94
+ */
95
+ function detectEnvironmentFromEnv() {
96
+ // Explicit override via env var
97
+ if (process.env['ESLINT_AI_MODE']) {
98
+ return process.env['ESLINT_AI_MODE'];
99
+ }
100
+ // Known agent detection
101
+ const detected = detectKnownAgentEnvironment();
102
+ if (detected)
103
+ return detected;
104
+ // CI detection
105
+ if (process.env['CI'])
106
+ return 'CI';
107
+ // Default
108
+ return 'CLI';
109
+ }
110
+ // Auto-initialize on import
111
+ GLOBAL_AI_CONFIG.mode = detectEnvironmentFromEnv();
112
+ // ============================================================================
113
+ // CONTEXT-AWARE RESOLUTION (Next-Gen)
114
+ // ============================================================================
115
+ /**
116
+ * Resolves the AI messaging mode based on the priority chain:
117
+ * 1. ENV VAR (ESLINT_AI_MODE) - Highest priority
118
+ * 2. Explicit setting (interlace/ai-mode)
119
+ * 3. Auto-detection (if enableAutoAgentDetection: true)
120
+ * 4. Default: CLI
121
+ *
122
+ * @param context - ESLint rule context (or context-like object with settings)
123
+ * @returns The resolved messaging environment
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * // In an ESLint rule
128
+ * create(context) {
129
+ * const mode = resolveAIMode(context);
130
+ * // mode is 'CLI' | 'CI' | 'IDE_CURSOR' | 'AGENT_JSON'
131
+ * }
132
+ * ```
133
+ */
134
+ function resolveAIMode(context) {
135
+ // 1. ENV VAR (Highest priority - agent escape hatch)
136
+ if (process.env['ESLINT_AI_MODE']) {
137
+ return process.env['ESLINT_AI_MODE'];
138
+ }
139
+ // 2. EXPLICIT CONFIG (Developer override via settings)
140
+ if (context?.settings?.['interlace/ai-mode']) {
141
+ return context.settings['interlace/ai-mode'];
142
+ }
143
+ // 3. AUTO-DETECTION (Only if opted-in)
144
+ if (context?.settings?.['interlace/enableAutoAgentDetection'] === true) {
145
+ const detected = detectKnownAgentEnvironment();
146
+ if (detected)
147
+ return detected;
148
+ }
149
+ // 4. DEFAULT: Human CLI
150
+ return 'CLI';
151
+ }
152
+ /**
153
+ * Resolves whether compression is enabled
154
+ */
155
+ function resolveCompression(context) {
156
+ // Explicit setting takes priority
157
+ if (context?.settings?.['interlace/compression'] !== undefined) {
158
+ return context.settings['interlace/compression'];
159
+ }
160
+ // Fall back to global config
161
+ return GLOBAL_AI_CONFIG.compression;
162
+ }
163
+ // ============================================================================
164
+ // LEGACY API (Backward compatibility)
165
+ // ============================================================================
166
+ /** @deprecated Use resolveAIMode(context) instead */
167
+ function setAIMessagingMode(mode) {
168
+ GLOBAL_AI_CONFIG.mode = mode;
169
+ }
170
+ /** @deprecated Use resolveAIMode(context) instead */
171
+ function getAIMessagingMode() {
172
+ return GLOBAL_AI_CONFIG.mode;
173
+ }
174
+ /** @deprecated Use resolveCompression(context) instead */
175
+ function setTokenCompression(enabled) {
176
+ GLOBAL_AI_CONFIG.compression = enabled;
177
+ }
178
+ /** @deprecated Use resolveCompression(context) instead */
179
+ function isTokenCompressionEnabled() {
180
+ return GLOBAL_AI_CONFIG.compression;
181
+ }
182
+ /** Reset config to defaults (for testing) */
183
+ function resetGlobalAIConfig() {
184
+ GLOBAL_AI_CONFIG.mode = 'CLI';
185
+ GLOBAL_AI_CONFIG.compression = false;
186
+ }
@@ -1,9 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
1
6
  /**
2
7
  * Constants and mappings for LLM message formatting
3
8
  *
4
9
  * Contains all static data, severity mappings, CWE definitions, and icon constants
5
10
  */
6
- import type { Severity, OWASP2025Category, OWASP2021Category, OWASPCategory, ComplianceFramework } from './types';
11
+ import type { Severity, OWASP2025Category, OWASP2021Category, OWASPCategory, OWASPServerlessCategory, ComplianceFramework } from './types';
7
12
  /**
8
13
  * CVSS 3.1 Score mapping per NIST guidelines
9
14
  * @see https://nvd.nist.gov/vuln-metrics/cvss
@@ -48,7 +53,16 @@ export declare const OWASP_2021_DETAILS: Record<OWASP2021Category, {
48
53
  link: string;
49
54
  }>;
50
55
  /**
51
- * Combined OWASP details (2025 + 2021)
56
+ * OWASP Serverless Top 10 (SAS) category details
57
+ * @see https://owasp.org/www-project-serverless-top-10/
58
+ */
59
+ export declare const OWASP_SERVERLESS_DETAILS: Record<OWASPServerlessCategory, {
60
+ name: string;
61
+ description: string;
62
+ link: string;
63
+ }>;
64
+ /**
65
+ * Combined OWASP details (2025 + 2021 + Serverless)
52
66
  */
53
67
  export declare const OWASP_DETAILS: Record<OWASPCategory, {
54
68
  name: string;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  /**
3
- * Constants and mappings for LLM message formatting
4
- *
5
- * Contains all static data, severity mappings, CWE definitions, and icon constants
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.MessageIcons = exports.CWE_COMPLIANCE_MAPPING = exports.CWE_MAPPING = exports.OWASP_2021_TO_2025 = exports.OWASP_DETAILS = exports.OWASP_2021_DETAILS = exports.OWASP_2025_DETAILS = exports.CVSS_RANGES = void 0;
8
+ exports.MessageIcons = exports.CWE_COMPLIANCE_MAPPING = exports.CWE_MAPPING = exports.OWASP_2021_TO_2025 = exports.OWASP_DETAILS = exports.OWASP_SERVERLESS_DETAILS = exports.OWASP_2021_DETAILS = exports.OWASP_2025_DETAILS = exports.CVSS_RANGES = void 0;
9
9
  exports.severityToCVSS = severityToCVSS;
10
10
  // ============================================================================
11
11
  // SEVERITY TYPES & CVSS MAPPING (NIST Standard)
@@ -165,11 +165,68 @@ exports.OWASP_2021_DETAILS = {
165
165
  },
166
166
  };
167
167
  /**
168
- * Combined OWASP details (2025 + 2021)
168
+ * OWASP Serverless Top 10 (SAS) category details
169
+ * @see https://owasp.org/www-project-serverless-top-10/
170
+ */
171
+ exports.OWASP_SERVERLESS_DETAILS = {
172
+ 'SAS-1': {
173
+ name: 'Function Event Data Injection',
174
+ description: 'Injecting malicious input via event data sources (API Gateway, S3, DynamoDB, etc.)',
175
+ link: 'https://owasp.org/www-project-serverless-top-10/',
176
+ },
177
+ 'SAS-2': {
178
+ name: 'Broken Authentication',
179
+ description: 'Weak or missing authentication in serverless functions and API endpoints',
180
+ link: 'https://owasp.org/www-project-serverless-top-10/',
181
+ },
182
+ 'SAS-3': {
183
+ name: 'Insecure Serverless Deployment Configuration',
184
+ description: 'Misconfigured serverless settings exposing functions or data',
185
+ link: 'https://owasp.org/www-project-serverless-top-10/',
186
+ },
187
+ 'SAS-4': {
188
+ name: 'Over-Privileged Function Permissions',
189
+ description: 'Functions with excessive IAM permissions beyond what is needed',
190
+ link: 'https://owasp.org/www-project-serverless-top-10/',
191
+ },
192
+ 'SAS-5': {
193
+ name: 'Inadequate Function Monitoring and Logging',
194
+ description: 'Insufficient logging, monitoring, and alerting for serverless functions',
195
+ link: 'https://owasp.org/www-project-serverless-top-10/',
196
+ },
197
+ 'SAS-6': {
198
+ name: 'Insecure Third-Party Dependencies',
199
+ description: 'Vulnerable or malicious packages in serverless function dependencies',
200
+ link: 'https://owasp.org/www-project-serverless-top-10/',
201
+ },
202
+ 'SAS-7': {
203
+ name: 'Insecure Application Secrets Storage',
204
+ description: 'Hardcoded secrets or improper secret management in serverless environments',
205
+ link: 'https://owasp.org/www-project-serverless-top-10/',
206
+ },
207
+ 'SAS-8': {
208
+ name: 'Denial of Service & Financial Resource Exhaustion',
209
+ description: 'Attacks causing function overload, timeout, or cost explosion',
210
+ link: 'https://owasp.org/www-project-serverless-top-10/',
211
+ },
212
+ 'SAS-9': {
213
+ name: 'Serverless Business Logic Manipulation',
214
+ description: 'Exploiting business logic flaws in stateless serverless functions',
215
+ link: 'https://owasp.org/www-project-serverless-top-10/',
216
+ },
217
+ 'SAS-10': {
218
+ name: 'Improper Exception Handling',
219
+ description: 'Error handling that leaks sensitive information or fails silently',
220
+ link: 'https://owasp.org/www-project-serverless-top-10/',
221
+ },
222
+ };
223
+ /**
224
+ * Combined OWASP details (2025 + 2021 + Serverless)
169
225
  */
170
226
  exports.OWASP_DETAILS = {
171
227
  ...exports.OWASP_2025_DETAILS,
172
228
  ...exports.OWASP_2021_DETAILS,
229
+ ...exports.OWASP_SERVERLESS_DETAILS,
173
230
  };
174
231
  /**
175
232
  * Maps 2021 categories to 2025 equivalents
@@ -741,4 +798,3 @@ exports.MessageIcons = {
741
798
  /** Compliance */
742
799
  COMPLIANCE: '📋',
743
800
  };
744
- //# sourceMappingURL=constants.js.map
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * AI-Native Runtime functions for LLM message formatting (Next-Gen)
8
+ *
9
+ * Contains the "Dual-Hertz" formatting engine for Agentic workflows
10
+ * This module provides context-aware message formatting that automatically
11
+ * routes between Human (CLI), Agent (JSON), and Hybrid (Cursor) modes.
12
+ */
13
+ import type { LLMMessageOptions, EnterpriseMessageOptions, AgentMessageOptions } from './types';
14
+ import { type RuleContextLike } from './config';
15
+ /**
16
+ * Node-like interface for AST selector building
17
+ * Compatible with TSESTree nodes
18
+ */
19
+ export interface ASTNodeLike {
20
+ type: string;
21
+ parent?: ASTNodeLike;
22
+ callee?: {
23
+ name?: string;
24
+ property?: {
25
+ name?: string;
26
+ };
27
+ };
28
+ key?: {
29
+ name?: string;
30
+ };
31
+ id?: {
32
+ name?: string;
33
+ };
34
+ name?: string;
35
+ }
36
+ /**
37
+ * Builds a relative esquery selector from an AST node
38
+ * Goes up to the nearest "anchor" (function, class, method) for context
39
+ *
40
+ * @param node - The AST node that triggered the lint error
41
+ * @param maxDepth - Maximum levels to traverse up (default: 3)
42
+ * @returns An esquery-compatible selector string
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * // For a node: db.query('SELECT...')
47
+ * buildASTSelector(node)
48
+ * // Returns: "CallExpression[callee.property.name='query']"
49
+ *
50
+ * // For a node inside a method:
51
+ * buildASTSelector(node)
52
+ * // Returns: "MethodDefinition[key.name='getUser'] CallExpression[callee.name='eval']"
53
+ * ```
54
+ */
55
+ export declare function buildASTSelector(node: ASTNodeLike, maxDepth?: number): string;
56
+ /**
57
+ * Formats a message as structured JSON for AI Agents
58
+ * Minimizes token usage while retaining strict semantic targeting
59
+ */
60
+ export declare function formatAgentMessage(options: AgentMessageOptions, compress?: boolean): string;
61
+ /**
62
+ * Context-aware message formatter (Next-Gen)
63
+ *
64
+ * Automatically routes between output formats based on the resolved AI mode:
65
+ * - CLI: Human-readable with emojis and prose
66
+ * - CI: Human-readable (no colors)
67
+ * - IDE_CURSOR: Human-readable + hidden AI hints
68
+ * - AGENT_JSON: Structured JSON for agents
69
+ *
70
+ * @param options - Message options including optional agent hints
71
+ * @param context - ESLint rule context (for accessing settings)
72
+ * @returns Formatted message string
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // In an ESLint rule
77
+ * context.report({
78
+ * node,
79
+ * message: formatMessageNextGen({
80
+ * icon: '🔒',
81
+ * severity: 'CRITICAL',
82
+ * description: 'SQL Injection',
83
+ * fix: 'Use parameterized queries',
84
+ * astSelector: buildASTSelector(node),
85
+ * }, context),
86
+ * });
87
+ * ```
88
+ */
89
+ export declare function formatMessageNextGen(options: LLMMessageOptions | EnterpriseMessageOptions | AgentMessageOptions, context?: RuleContextLike): string;
90
+ /**
91
+ * @deprecated Use formatMessageNextGen(options, context) instead
92
+ * Legacy formatter that uses global state instead of context
93
+ */
94
+ export declare function formatLLMMessageNextGen(options: LLMMessageOptions | EnterpriseMessageOptions | AgentMessageOptions): string;