@adobe-commerce/aio-toolkit 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,122 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.15] - 2026-02-09
9
+
10
+ ### ✨ Features
11
+
12
+ - **feat(cli):** New Cursor IDE Context Management CLI (`aio-toolkit-cursor-context`)
13
+ - Command-line tool for managing Cursor IDE context files in Adobe App Builder projects
14
+ - Three sub-commands: `check`, `apply`, and `help`
15
+ - Automatic IDE detection (macOS, Windows, Linux)
16
+ - Model Context Protocol (MCP) server configuration
17
+ - Force mode for CI/CD pipelines
18
+ - Multi-directory support (`.cursor/rules` and `.cursor/commands`)
19
+ - Comprehensive error handling and user feedback
20
+
21
+ ### 💡 Usage Examples
22
+
23
+ **Check context setup**:
24
+ ```bash
25
+ npx aio-toolkit-cursor-context check
26
+ ```
27
+
28
+ **Apply contexts (standard mode)**:
29
+ ```bash
30
+ npx aio-toolkit-cursor-context apply
31
+ ```
32
+
33
+ **Apply contexts (force mode)**:
34
+ ```bash
35
+ npx aio-toolkit-cursor-context apply -f
36
+ ```
37
+
38
+ **Display help**:
39
+ ```bash
40
+ npx aio-toolkit-cursor-context help
41
+ ```
42
+
43
+ ---
44
+
45
+ ## [1.0.14] - 2026-01-20
46
+
47
+ ### ✨ Features
48
+
49
+ - **feat(telemetry):** Enhanced telemetry instrumentation with conditional span access
50
+ - Added `Telemetry.getCurrentSpan()` method that accepts params and conditionally returns spans based on `ENABLE_TELEMETRY` flag
51
+ - Updated all action classes to pass params to `getCurrentSpan()` for conditional instrumentation
52
+ - Enables developers to access current OpenTelemetry span for custom instrumentation when telemetry is enabled
53
+ - Returns `undefined` when telemetry is disabled, allowing safe optional chaining patterns
54
+
55
+ ### 🔧 Refactoring
56
+
57
+ - **refactor(telemetry):** Converted Telemetry class from static to instance methods
58
+ - Telemetry class now uses instance methods instead of static methods for better testability
59
+ - Added telemetry object to action context (`ctx.telemetry`) for easy access in action handlers
60
+ - Standardized parameter ordering across all action classes (params, ctx, logger)
61
+ - Updated JSDoc documentation with consistent examples showing telemetry usage
62
+ - Improved encapsulation and dependency injection patterns
63
+
64
+ ### 📝 Technical Details
65
+
66
+ - Enhanced action classes with telemetry context:
67
+ - `RuntimeAction`: Added `ctx.telemetry` with access to current span and `instrument()` method
68
+ - `WebhookAction`: Added `ctx.telemetry` with access to current span and `instrument()` method
69
+ - `OpenwhiskAction`: Added `ctx.telemetry` with access to current span and `instrument()` method
70
+ - `EventConsumerAction`: Added `ctx.telemetry` with access to current span and `instrument()` method
71
+ - `GraphQlAction`: Added `ctx.telemetry` with access to current span and `instrument()` method
72
+ - Telemetry API methods:
73
+ - `getCurrentSpan(params?)`: Returns current OpenTelemetry span (conditional based on ENABLE_TELEMETRY)
74
+ - `instrument(spanName, fn)`: Wraps function with automatic span creation for custom instrumentation
75
+ - Achieved 100% test coverage for all framework action classes:
76
+ - RuntimeAction (100% statements/branches/functions/lines)
77
+ - Telemetry (100% statements/branches/functions/lines)
78
+ - WebhookAction (100% statements/branches/functions/lines)
79
+ - OpenwhiskAction (100% statements/branches/functions/lines)
80
+ - GraphQlAction (100% statements/branches/functions/lines)
81
+ - EventConsumerAction (100% statements/branches/functions/lines)
82
+ - Added 25 comprehensive instrumentation tests covering all action types and edge cases
83
+ - Fixed all linting and formatting issues (0 errors, 0 warnings)
84
+ - All 636 tests passing across 30 test suites
85
+ - No breaking changes - purely additive enhancements with backward compatibility
86
+
87
+ ### 💡 Usage Example
88
+
89
+ ```typescript
90
+ const { RuntimeAction, RuntimeActionResponse, HttpMethod } = require('@adobe-commerce/aio-toolkit');
91
+
92
+ // Custom function with telemetry
93
+ const processData = (data, telemetry, logger) => {
94
+ const span = telemetry?.getCurrentSpan?.();
95
+ if (span) {
96
+ span.setAttribute('data.size', data.length);
97
+ }
98
+ logger.info('Processing data');
99
+ return { processed: true };
100
+ };
101
+
102
+ exports.main = RuntimeAction.execute(
103
+ 'my-action',
104
+ [HttpMethod.POST],
105
+ ['data'],
106
+ ['Authorization'],
107
+ async (params, ctx) => {
108
+ const { logger, telemetry } = ctx;
109
+
110
+ // Wrap function to create child span
111
+ const instrumented = telemetry?.instrument?.('data.process', processData) || processData;
112
+ const result = instrumented(params.data, telemetry, logger);
113
+
114
+ return RuntimeActionResponse.success(result);
115
+ }
116
+ );
117
+ ```
118
+
119
+ **Key Features:**
120
+ - `telemetry.getCurrentSpan(params)` - Access current span for custom attributes and events
121
+ - `telemetry.instrument(spanName, fn)` - Wrap functions to create child spans automatically
122
+ - Safe with optional chaining - gracefully degrades when telemetry is disabled
123
+
8
124
  ## [1.0.13] - 2026-01-07
9
125
 
10
126
  ### ✨ Features
package/README.md CHANGED
@@ -289,6 +289,9 @@ OpenTelemetry integration for enterprise-grade observability with distributed tr
289
289
  - Automatic telemetry instrumentation for all framework action classes
290
290
  - Request ID correlation across all log messages (`x-adobe-commerce-request-id`)
291
291
  - Action type identification for better filtering (`action.type`)
292
+ - Access to current OpenTelemetry span via `ctx.telemetry` for custom instrumentation
293
+ - `telemetry.instrument()` method for wrapping functions with automatic span creation
294
+ - Conditional span access based on `ENABLE_TELEMETRY` flag
292
295
  - Multi-provider support (New Relic implemented, Grafana ready)
293
296
  - Graceful fallback when telemetry is not configured
294
297
  - Zero performance impact when disabled (opt-in via feature flags)
@@ -334,27 +337,43 @@ Telemetry is automatically initialized when you use framework action classes:
334
337
  */
335
338
 
336
339
  const { RuntimeAction, RuntimeActionResponse, HttpMethod } = require("@adobe-commerce/aio-toolkit");
337
- const name = 'runtime-action';
340
+
341
+ // Custom function with telemetry
342
+ const processData = (data, telemetry, logger) => {
343
+ const span = telemetry?.getCurrentSpan?.();
344
+ if (span) {
345
+ span.setAttribute('data.size', data.length);
346
+ }
347
+ logger.info('Processing data');
348
+ return { processed: true };
349
+ };
338
350
 
339
351
  exports.main = RuntimeAction.execute(
340
- name,
352
+ 'my-action',
341
353
  [HttpMethod.POST],
342
- [],
354
+ ['data'],
343
355
  ['Authorization'],
344
356
  async (params, ctx) => {
345
- const { logger } = ctx;
357
+ const { logger, telemetry } = ctx;
346
358
 
347
359
  // Logger automatically includes x-adobe-commerce-request-id and action.type
348
- logger.info({
349
- message: `${name}-log`,
350
- params: JSON.stringify(params),
351
- });
360
+ logger.info('Action started');
361
+
362
+ // Wrap function to create child span
363
+ const instrumented = telemetry?.instrument?.('data.process', processData) || processData;
364
+ const result = instrumented(params.data, telemetry, logger);
352
365
 
353
- return RuntimeActionResponse.success("Hello World");
366
+ return RuntimeActionResponse.success(result);
354
367
  }
355
368
  );
356
369
  ```
357
370
 
371
+ **Key Features:**
372
+ - `telemetry.getCurrentSpan(params)` - Access current span for custom attributes and events
373
+ - `telemetry.instrument(spanName, fn)` - Wrap functions to create child spans automatically
374
+ - Safe with optional chaining - gracefully degrades when telemetry is disabled
375
+ - Logger automatically includes request ID and action type for correlation
376
+
358
377
  **What Gets Logged Automatically:**
359
378
 
360
379
  All log messages automatically include:
@@ -1468,6 +1487,100 @@ const registrations = await manager.list();
1468
1487
  await manager.delete('your-registration-id');
1469
1488
  ```
1470
1489
 
1490
+ ### 🛠️ CLI Tools
1491
+
1492
+ #### `aio-toolkit-cursor-context`
1493
+
1494
+ Command-line tool for managing Cursor IDE context files (rules and commands) in your Adobe App Builder projects. This CLI automatically sets up Cursor IDE-specific contexts and configures the Model Context Protocol (MCP) server for enhanced development experience.
1495
+
1496
+ ##### Commands
1497
+
1498
+ ###### `check`
1499
+ Validates that Cursor contexts are properly set up in your project.
1500
+
1501
+ ```bash
1502
+ npx aio-toolkit-cursor-context check
1503
+ ```
1504
+
1505
+ **Features:**
1506
+ - ✅ Checks for `.cursor/rules` and `.cursor/commands` directories
1507
+ - ✅ Validates MCP server configuration
1508
+ - ✅ Detects if running in Cursor IDE
1509
+ - ✅ Reports missing files or configurations
1510
+
1511
+ **Output Example:**
1512
+ ```
1513
+ ✅ Cursor IDE detected
1514
+ ✅ MCP server configured
1515
+ ✅ Found 3 context files in .cursor/rules
1516
+ ✅ Found 4 context files in .cursor/commands
1517
+ ✅ Cursor contexts are properly set up
1518
+ ```
1519
+
1520
+ ###### `apply`
1521
+ Copies Cursor context files from the package to your project.
1522
+
1523
+ ```bash
1524
+ # Standard mode - copies missing files only
1525
+ npx aio-toolkit-cursor-context apply
1526
+
1527
+ # Force mode - overwrites existing files and bypasses IDE detection
1528
+ npx aio-toolkit-cursor-context apply -f
1529
+ npx aio-toolkit-cursor-context apply --force
1530
+ ```
1531
+
1532
+ **Features:**
1533
+ - 📁 Copies context files to `.cursor/rules` and `.cursor/commands`
1534
+ - 🔄 Creates MCP configuration in `.cursor/mcp.json`
1535
+ - 🛡️ IDE detection prevents accidental application in non-Cursor environments
1536
+ - ⚡ Force mode for CI/CD pipelines or when IDE detection fails
1537
+ - 📊 Reports copied, skipped, and overwritten files
1538
+
1539
+ **Standard Mode Output:**
1540
+ ```
1541
+ Copied 3 new context files to .cursor/rules
1542
+ Skipped 2 files (already exist)
1543
+ ✅ MCP server configured
1544
+ ✅ All cursor contexts applied successfully
1545
+ ```
1546
+
1547
+ **Force Mode Output:**
1548
+ ```
1549
+ Overwritten 5 existing files in .cursor/rules
1550
+ Copied 4 new files to .cursor/commands
1551
+ ✅ MCP server configured
1552
+ ✅ All cursor contexts applied successfully (force mode)
1553
+ ```
1554
+
1555
+ ###### `help`
1556
+ Displays help information for the CLI.
1557
+
1558
+ ```bash
1559
+ npx aio-toolkit-cursor-context help
1560
+ ```
1561
+
1562
+ ##### Context Files Included
1563
+
1564
+ The CLI provides the following context files:
1565
+
1566
+ **Rules (`.cursor/rules/`):**
1567
+ - `aio-toolkit-create-adobe-commerce-client.mdc` - Creating Adobe Commerce client operations
1568
+ - `aio-toolkit-oop-best-practices.mdc` - Object-oriented programming best practices
1569
+ - `aio-toolkit-setup-new-relic-telemetry.mdc` - Setting up New Relic telemetry
1570
+
1571
+ **Commands (`.cursor/commands/`):**
1572
+ - `aio-toolkit-create-event-consumer-action.md` - Create event consumer actions
1573
+ - `aio-toolkit-create-graphql-action.md` - Create GraphQL actions
1574
+ - `aio-toolkit-create-runtime-action.md` - Create runtime actions
1575
+ - `aio-toolkit-create-webhook-action.md` - Create webhook actions
1576
+
1577
+ ##### Use Cases
1578
+
1579
+ 1. **Initial Project Setup**: Run `apply` to set up all Cursor contexts
1580
+ 2. **Continuous Integration**: Use `apply -f` in CI/CD pipelines
1581
+ 3. **Verification**: Run `check` to ensure contexts are properly configured
1582
+ 4. **Updates**: Run `apply -f` after toolkit updates to get latest contexts
1583
+
1471
1584
  ## Environment Variables
1472
1585
 
1473
1586
  Common environment variables used across components: