autotel-cli 0.13.0 → 0.14.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel-cli",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "CLI for autotel - setup wizard, diagnostics, and incremental features",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,8 +13,7 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist",
17
- "skills"
16
+ "dist"
18
17
  ],
19
18
  "dependencies": {
20
19
  "@inquirer/prompts": "^8.5.2",
@@ -25,7 +24,7 @@
25
24
  "semver": "^7.8.5",
26
25
  "ts-morph": "^28.0.0",
27
26
  "yaml": "^2.9.0",
28
- "autotel-mcp": "0.1.18"
27
+ "autotel-mcp": "0.1.19"
29
28
  },
30
29
  "devDependencies": {
31
30
  "@eslint/js": "^10.0.1",
@@ -1,265 +0,0 @@
1
- ---
2
- name: autotel-cli
3
- description: >
4
- Use this skill when running autotel CLI commands to set up, configure, or extend OpenTelemetry instrumentation in a Node.js project — including init, doctor, add, and codemod trace.
5
- ---
6
-
7
- # autotel-cli
8
-
9
- CLI for autotel: interactive setup wizard, diagnostics, incremental feature addition, and a codemod to adopt tracing on existing code. Targets Node.js 18+.
10
-
11
- ## Setup
12
-
13
- ```bash
14
- # One-off use (no global install needed)
15
- npx autotel <command>
16
-
17
- # Or install globally
18
- npm install -g autotel-cli
19
- ```
20
-
21
- ## Commands
22
-
23
- ### `autotel init`
24
-
25
- Interactive wizard that writes an instrumentation file and installs dependencies.
26
-
27
- ```bash
28
- # Interactive (prompts for backend, plugins, etc.)
29
- npx autotel init
30
-
31
- # Non-interactive: accept all defaults (local backend, all auto-instrumentations)
32
- npx autotel init --yes
33
-
34
- # Use a named quick preset
35
- npx autotel init --preset node-datadog-pino
36
-
37
- # Preview what would happen without writing files
38
- npx autotel init --dry-run
39
- ```
40
-
41
- **Quick presets:** `node-datadog-pino`, `node-datadog-agent`, `node-honeycomb`, `node-otlp`
42
-
43
- **Key options:**
44
-
45
- | Option | Effect |
46
- | --------------------- | ---------------------------------------------------------- |
47
- | `--yes / -y` | Non-interactive, accept defaults |
48
- | `--preset <name>` | Use a quick preset |
49
- | `--dry-run` | Print what would be done, no writes or installs |
50
- | `--no-install` | Generate files only, skip package installation |
51
- | `--print-install-cmd` | Output the install command instead of running it |
52
- | `--force` | Overwrite existing config (backs up the old file first) |
53
- | `--workspace-root` | Install at monorepo workspace root instead of package root |
54
-
55
- Generated files:
56
-
57
- - `src/instrumentation.mts` (or `.mjs`): the instrumentation entry point with section markers
58
- - `.env.example`: env var template based on selected presets (written only if file does not exist)
59
-
60
- After init, start your app with `--import`:
61
-
62
- ```bash
63
- # Node.js ESM
64
- node --import ./src/instrumentation.mts dist/index.js
65
-
66
- # With tsx (development)
67
- tsx --import ./src/instrumentation.mts src/index.ts
68
- ```
69
-
70
- ---
71
-
72
- ### `autotel doctor`
73
-
74
- Diagnose the current autotel setup.
75
-
76
- ```bash
77
- npx autotel doctor # Run all checks, human-readable output
78
- npx autotel doctor --json # Machine-readable JSON
79
- npx autotel doctor --fix # Auto-fix resolvable issues
80
- npx autotel doctor --list-checks # Show all available check names
81
- npx autotel doctor --env-file .env.production # Check a specific env file
82
- ```
83
-
84
- Exit codes: `0` = all passed, `1` = warnings, `2` = errors.
85
-
86
- ---
87
-
88
- ### `autotel add <type> <name>`
89
-
90
- Incrementally add a backend, subscriber, plugin, or platform to an existing instrumentation file.
91
-
92
- ```bash
93
- # List all available presets
94
- npx autotel add --list
95
-
96
- # List backends only
97
- npx autotel add backend --list
98
-
99
- # Add Datadog backend
100
- npx autotel add backend datadog
101
-
102
- # Add a PostHog event subscriber
103
- npx autotel add subscriber posthog
104
-
105
- # Add Mongoose plugin
106
- npx autotel add plugin mongoose
107
-
108
- # Show help for a specific preset (packages, env vars, next steps)
109
- npx autotel add backend datadog --help
110
- ```
111
-
112
- **Preset types:**
113
-
114
- | Type | Examples |
115
- | ------------ | ----------------------------------------- |
116
- | `backend` | `datadog`, `honeycomb`, `otlp`, `local` |
117
- | `subscriber` | `posthog`, `mixpanel`, `segment`, `slack` |
118
- | `plugin` | `mongoose`, `drizzle` |
119
- | `platform` | AWS Lambda, Cloudflare Workers |
120
-
121
- **Key options:** `--dry-run`, `--no-install`, `--force`, `--json` (for `--list`).
122
-
123
- `add` is idempotent: if the package is already installed and the instrumentation file already contains the feature, it exits cleanly with `[OK]`.
124
-
125
- `add` requires an existing CLI-owned instrumentation file (created by `autotel init`). Use `--force` to modify a user-created file.
126
-
127
- ---
128
-
129
- ### `autotel codemod trace <path>`
130
-
131
- Wrap existing functions in `trace()` calls, deriving span names from the function or variable name. Use this to adopt tracing on existing code without manual edits.
132
-
133
- ```bash
134
- # Single file
135
- npx autotel codemod trace src/index.ts
136
-
137
- # Glob (quote to prevent shell expansion)
138
- npx autotel codemod trace "src/**/*.ts"
139
-
140
- # All supported types
141
- npx autotel codemod trace "src/**/*.{ts,tsx,js,jsx}"
142
-
143
- # Dry run — preview changes without writing
144
- npx autotel codemod trace "src/**/*.ts" --dry-run
145
-
146
- # Custom span name: {name}, {file} (basename), {path} (relative from --cwd)
147
- npx autotel codemod trace "src/**/*.ts" --name-pattern "{file}.{name}"
148
-
149
- # Skip functions matching a regex (repeatable, combined as OR)
150
- npx autotel codemod trace "src/**/*.ts" --skip "^_" --skip "test|mock"
151
-
152
- # Print per-file summary
153
- npx autotel codemod trace "src/**/*.ts" --print-files
154
- ```
155
-
156
- **What gets wrapped:** function declarations, arrow/function expressions in `const`/`let`/`var`, class and static methods, object method shorthand, named default export functions.
157
-
158
- **Never wrapped:** generator functions, getters/setters, constructors, `super` usage in body, anonymous default exports, `.d.ts` files, `node_modules/`, files that already use `require('autotel')`.
159
-
160
- ## Configuration Patterns
161
-
162
- ### Global options (all commands)
163
-
164
- ```bash
165
- --cwd <path> # Target directory (default: cwd)
166
- --verbose # Show detailed output
167
- --quiet # Only show warnings and errors
168
- ```
169
-
170
- ### Package manager detection
171
-
172
- Detected automatically from the nearest lockfile in this order:
173
-
174
- 1. `pnpm-lock.yaml` → pnpm
175
- 2. `bun.lockb` → bun
176
- 3. `yarn.lock` → yarn
177
- 4. `package-lock.json` → npm
178
-
179
- Fallback: npm.
180
-
181
- ### Monorepo usage
182
-
183
- ```bash
184
- # Install into a specific workspace package
185
- npx autotel init --cwd ./packages/my-app
186
-
187
- # Install at workspace root (shared instrumentation)
188
- npx autotel init --cwd ./packages/my-app --workspace-root
189
- ```
190
-
191
- ### Generated instrumentation file structure
192
-
193
- The CLI uses section markers to allow `autotel add` to safely modify the file:
194
-
195
- ```typescript
196
- /**
197
- * autotel instrumentation - managed by autotel-cli
198
- * Run `autotel add <feature>` to update this file
199
- */
200
- import 'autotel/register';
201
- import { init } from 'autotel';
202
-
203
- // --- AUTOTEL:BACKEND ---
204
- import { createDatadogConfig } from 'autotel-backends/datadog';
205
-
206
- init({
207
- // --- AUTOTEL:BACKEND_CONFIG ---
208
- ...createDatadogConfig({ apiKey: process.env.DATADOG_API_KEY }),
209
- // --- AUTOTEL:SUBSCRIBERS_CONFIG ---
210
- subscribers: [],
211
- });
212
-
213
- // --- AUTOTEL:PLUGIN_INIT ---
214
- ```
215
-
216
- Do not remove these markers if you want `autotel add` to continue working on the file.
217
-
218
- ## Common Mistakes
219
-
220
- ### HIGH: Forgetting `--import` when starting the app
221
-
222
- ```bash
223
- # Wrong: instrumentation never runs
224
- node dist/index.js
225
-
226
- # Correct: register instrumentation before app code loads
227
- node --import ./src/instrumentation.mts dist/index.js
228
- ```
229
-
230
- The instrumentation file must be loaded before any other module. The `--import` flag (Node.js 18.19+) is the correct mechanism. `require` or a top-level import inside app code is too late.
231
-
232
- ### HIGH: Running `autotel add` before `autotel init`
233
-
234
- ```bash
235
- # Wrong: no instrumentation file exists yet
236
- npx autotel add plugin mongoose
237
-
238
- # Correct: create the file first
239
- npx autotel init
240
- npx autotel add plugin mongoose
241
- ```
242
-
243
- `add` reads and modifies the existing instrumentation file. It will fail if the file does not exist or is not CLI-owned (use `--force` for user-created files).
244
-
245
- ### MEDIUM: Globbing without quotes
246
-
247
- ```bash
248
- # Wrong: shell expands the glob before the CLI sees it
249
- npx autotel codemod trace src/**/*.ts
250
-
251
- # Correct: quote the glob so the CLI handles expansion
252
- npx autotel codemod trace "src/**/*.ts"
253
- ```
254
-
255
- ### MEDIUM: Using `--force` on init without understanding the backup
256
-
257
- `--force` on `init` overwrites an existing instrumentation file but creates a `.bak` backup first. The backup path is logged at `--verbose` level. If you ran `--force` accidentally, check for `instrumentation.mts.bak` in the same directory.
258
-
259
- ### MEDIUM: Using `--dry-run` and expecting installs to have run
260
-
261
- `--dry-run` implies `--no-install` and `--print-install-cmd`. No files are written and no packages are installed. It is purely a preview mode.
262
-
263
- ## Version
264
-
265
- Targets autotel-cli v0.8.2. Node.js >= 18.0.0 required (18.19+ for `--import` flag support).