@stacknext/cli 0.6.0 → 0.7.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 (42) hide show
  1. package/dist/collector/server.d.ts +3 -1
  2. package/dist/collector/server.d.ts.map +1 -1
  3. package/dist/collector/server.js +385 -15
  4. package/dist/collector/server.js.map +1 -1
  5. package/dist/commands/dev.d.ts.map +1 -1
  6. package/dist/commands/dev.js +87 -19
  7. package/dist/commands/dev.js.map +1 -1
  8. package/dist/commands/diagnose.d.ts.map +1 -1
  9. package/dist/commands/diagnose.js +36 -3
  10. package/dist/commands/diagnose.js.map +1 -1
  11. package/dist/commands/init.d.ts.map +1 -1
  12. package/dist/commands/init.js +1 -0
  13. package/dist/commands/init.js.map +1 -1
  14. package/dist/commands/skill.d.ts +34 -0
  15. package/dist/commands/skill.d.ts.map +1 -0
  16. package/dist/commands/skill.js +121 -0
  17. package/dist/commands/skill.js.map +1 -0
  18. package/dist/commands/snapshot.d.ts +36 -0
  19. package/dist/commands/snapshot.d.ts.map +1 -0
  20. package/dist/commands/snapshot.js +286 -0
  21. package/dist/commands/snapshot.js.map +1 -0
  22. package/dist/commands/uninstall.d.ts.map +1 -1
  23. package/dist/commands/uninstall.js +18 -5
  24. package/dist/commands/uninstall.js.map +1 -1
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/program.d.ts.map +1 -1
  30. package/dist/program.js +4 -0
  31. package/dist/program.js.map +1 -1
  32. package/dist/runtime.d.ts +17 -0
  33. package/dist/runtime.d.ts.map +1 -1
  34. package/dist/runtime.js +148 -4
  35. package/dist/runtime.js.map +1 -1
  36. package/dist/version.d.ts +1 -1
  37. package/dist/version.js +1 -1
  38. package/package.json +8 -7
  39. package/skills/stacknext-debugging/SKILL.md +306 -0
  40. package/skills/stacknext-debugging/references/setup.md +228 -0
  41. package/skills/stacknext-debugging/references/tools.md +369 -0
  42. package/skills/stacknext-debugging/references/workflows.md +332 -0
@@ -0,0 +1,369 @@
1
+ # StackNext MCP tool reference
2
+
3
+ All twenty tools are read-only, idempotent and restricted to the local
4
+ collector. Tool text content is pretty-printed JSON; clients that support
5
+ structured content also receive the same object in `structuredContent`. The
6
+ object always contains the tool payload plus a top-level `meta` object.
7
+
8
+ ## Common arguments
9
+
10
+ | Argument | Type | Notes |
11
+ | --- | --- | --- |
12
+ | `limit` | integer 1-200 | Default 50. The collector caps it at 200. |
13
+ | `offset` | integer >= 0 | Use with `meta.result.nextOffset` when `hasMore` is true. |
14
+ | `minDurationMs` | number 0-600000 | Inclusive threshold. |
15
+ | `sort` | `recent`, `oldest`, `slowest` | List tools that support sorting. |
16
+ | `q` | string, max 200 | Case-insensitive text search over the fields the tool exposes. |
17
+
18
+ ## Regression ids and statuses
19
+
20
+ Regression ids are strict: `run-<16 hex>`, `base-<16 hex>` and
21
+ `cmp-<16 hex>`. An id that does not match is rejected before storage is read.
22
+ The regression tools read only the collector's configured project directory;
23
+ they cannot read arbitrary files.
24
+
25
+ - Run status: `running`, `completed`, `failed`, `interrupted` or `incomplete`.
26
+ - Comparison status: `improved`, `regressed`, `unchanged` or `inconclusive`.
27
+ - Severity: `high`, `medium`, `low` or `none`, separate from status.
28
+
29
+ A scenario sample is `verified` only when the collector found the injected trace
30
+ and a server span parented to the injected span id. `incomplete` means the
31
+ telemetry could not be proven, never that a time window matched. Baselines are
32
+ immutable snapshots and are never deleted by these tools.
33
+
34
+ ## Common response metadata
35
+
36
+ ```json
37
+ {
38
+ "meta": {
39
+ "tool": "list_requests",
40
+ "generatedAt": "2026-11-02T12:00:00.000Z",
41
+ "project": "tasklight",
42
+ "timeRange": {
43
+ "firstEventTime": "2026-11-02T11:55:00.000Z",
44
+ "lastEventTime": "2026-11-02T11:59:59.000Z"
45
+ },
46
+ "result": {
47
+ "found": 120,
48
+ "returned": 50,
49
+ "limit": 50,
50
+ "offset": 0,
51
+ "hasMore": true,
52
+ "nextOffset": 50
53
+ },
54
+ "connection": {
55
+ "instrumentation": "connected",
56
+ "instances": 1,
57
+ "lastSeen": "2026-11-02T11:59:59.000Z",
58
+ "sdkVersion": "0.6.1",
59
+ "collectorVersion": "0.6.1"
60
+ },
61
+ "completeness": { "complete": true, "reasons": [] },
62
+ "notes": []
63
+ }
64
+ }
65
+ ```
66
+
67
+ - `result.found` is the total number of matching records in the retention
68
+ window, not the number returned in this page.
69
+ - `result.hasMore` and `nextOffset` describe pagination. `nextOffset` is `null`
70
+ on the last page.
71
+ - `connection.instrumentation` is `connected`, `waiting` (collector is running
72
+ but no app has connected) or `unknown` (health lookup failed).
73
+ - `completeness.complete` is false when telemetry is dropped, a result is
74
+ paginated, no app is connected, or a trace has missing parents. Read
75
+ `completeness.reasons`.
76
+ - `notes` carries short caveats, such as omitted stacks, unmeasured query
77
+ durations or incomplete regression correlation.
78
+ - `get_project_summary` adds `meta.coverage` with counts (`observed`, `active`,
79
+ `configured`, `notObserved`, `unsupported`, `unknown`,
80
+ `requestsInSample`). It also returns the full `coverage` report.
81
+ - Detail responses also include `meta.identifiers`, for example
82
+ `{ "traceId": "..." }`, `{ "runId": "run-..." }`,
83
+ `{ "comparisonId": "cmp-..." }` or `{ "snapshotId": "snap-..." }`.
84
+ - Times in payloads are Unix epoch milliseconds. Metadata times are ISO 8601
85
+ strings. Regression records use their own `createdAt` timestamps and are not
86
+ limited by the telemetry retention window. Snapshot records use their save
87
+ time and sample window.
88
+
89
+ ## get_project_summary
90
+
91
+ Arguments: none.
92
+
93
+ Returns `{ health, summary, coverage, meta }`. `summary` contains total/failed/slow
94
+ request counts, average and p95 duration, span/error/query/fetch counts, the five
95
+ slowest requests, five recent errors (without stacks), and the first/last event
96
+ time. `coverage` contains the sample window, status counts and one item per
97
+ framework/adapter/custom feature. Start here.
98
+
99
+ Coverage statuses are `observed`, `active`, `configured`, `not-observed`,
100
+ `unknown` and `unsupported`. There is no coverage percentage. A `not-observed`
101
+ or `unknown` item means evidence is missing from the current sample, not that
102
+ the app is broken. Read `coverage.items[].limitations` before recommending
103
+ instrumentation changes.
104
+
105
+ ## list_requests
106
+
107
+ Arguments: `limit`, `offset`, `q`, `method`, `status`, `slow`, `minDurationMs`,
108
+ `sort`.
109
+
110
+ Returns `{ items, total, limit, offset, meta }`. Each item includes `traceId`,
111
+ route, method, status code/class, duration, timestamp, span/error/query/fetch
112
+ counts, `failed`, `slow` and service name.
113
+
114
+ - `status` is one of `2xx`, `3xx`, `4xx`, `5xx`, `none`.
115
+ - `method` is matched case-insensitively by the collector.
116
+ - `slow` uses the project's `slowRequestMs` threshold.
117
+ - `sort` defaults to `recent`.
118
+
119
+ ## get_request
120
+
121
+ Arguments: `traceId` (32 hexadecimal characters).
122
+
123
+ Compatibility alias for `get_trace`, kept for clients that use the request
124
+ vocabulary. Returns the same detail: request summary (or `null` when no request
125
+ root was derived), every captured span, correlated errors and database queries,
126
+ start/end/duration and `missingParentSpanIds`.
127
+
128
+ Use the span tree to find the longest span, the failing span, or the gap between
129
+ request start and first child.
130
+
131
+ ## list_traces
132
+
133
+ Arguments: `limit`, `offset`, `q`, `sort`.
134
+
135
+ Returns `{ items, total, limit, offset, meta }`. Each trace summary includes the
136
+ root span, service, start/end, duration, span/error/query counts, `failed` and an
137
+ optional request summary.
138
+
139
+ ## get_trace
140
+
141
+ Arguments: `traceId` (32 hexadecimal characters).
142
+
143
+ Returns the same detail shape as `get_request`, plus an additive `diagnostics`
144
+ array of finding references that mention this trace. This is the canonical
145
+ detail tool; `get_request` is a compatibility alias for the same data.
146
+
147
+ Each reference has `id`, `ruleId`, `category`, `severity`, `status` and `title`.
148
+ The array is a pointer, not a second full trace: call
149
+ `stacknext_get_diagnostic` for the finding and its bounded evidence.
150
+
151
+ ## list_errors
152
+
153
+ Arguments: `limit`, `offset`, `q`, `route`, `name`, `includeStack`.
154
+
155
+ Returns `{ items, total, limit, offset, groups, meta }`. Items include the error
156
+ id, fingerprint, name, message, route, timestamps, trace correlation and
157
+ `resolvedTraceId`. `groups` aggregates by fingerprint with count and first/last
158
+ seen.
159
+
160
+ Stacks are omitted by default for context efficiency. Set `includeStack: true`
161
+ only when the list itself needs stack evidence; otherwise call `get_error` for
162
+ one error. When stacks are omitted, `meta.notes` says so.
163
+
164
+ ## get_error
165
+
166
+ Arguments: `errorId`.
167
+
168
+ Returns `{ error, trace, meta }`. `error` includes the redacted stack and
169
+ `resolvedTraceId`. `trace` is the full correlated trace detail or `null` when no
170
+ trace could be resolved. Treat the correlation as exact only when the error has
171
+ a captured span context; route/time fallback is weaker.
172
+
173
+ ## list_database_queries
174
+
175
+ Arguments: `limit`, `offset`, `q`, `minDurationMs`, `traceId`,
176
+ `databaseSystem`.
177
+
178
+ Returns `{ items, total, limit, offset, meta }`. Each item includes redacted
179
+ `sql`, `databaseSystem`, `operation`, `success`, `errorMessage`, `source`,
180
+ `durationMs`, `resolvedTraceId` and `route`.
181
+
182
+ `durationMs` is `null` for Drizzle queries because the Drizzle logger does not
183
+ expose duration. `null` means unmeasured, never zero. `minDurationMs` excludes
184
+ null-duration queries because they cannot be compared to a threshold.
185
+
186
+ ## find_slow_requests
187
+
188
+ Arguments: `minDurationMs` (default 500), `limit`.
189
+
190
+ Returns `{ items, total, limit, offset, meta }`, sorted slowest first. This is a
191
+ convenience wrapper over `list_requests` with `sort: "slowest"` and the duration
192
+ filter applied. Use `list_requests` when you also need method/status filters.
193
+
194
+ ## stacknext_list_diagnostics
195
+
196
+ Arguments: `limit`, `offset`, `category`, `severity`, `status`, `ruleId`,
197
+ `route`, `traceId`, `since`, `until`, `q`.
198
+
199
+ Returns `{ items, total, limit, offset, generatedAt, engineVersion,
200
+ ruleSetVersion, sample, counts, notes, limitations, meta }`.
201
+
202
+ - `category`: `database`, `http`, `performance`, `errors` or `runtime`.
203
+ - `severity`: `info`, `warning` or `error`.
204
+ - `status`: `observed`, `possible` or `insufficient-evidence`.
205
+ - `ruleId`: `n-plus-one-queries`, `slow-request`, `slow-span`,
206
+ `repeated-external-http`, `error-fingerprint` or `server-error-response`.
207
+ - `since`/`until` are epoch milliseconds and filter the finding window.
208
+
209
+ Findings are deterministic heuristics over the current retention window. Read
210
+ `sample`, `notes` and `limitations` before drawing conclusions. `sample`
211
+ includes request-trace and attribution integrity counts, so detached traces and
212
+ ignored control-flow errors stay visible. `total` is the number of matching
213
+ findings; `items` is the current page. Findings are already grouped by rule and
214
+ canonical route; use `affectedTraceCount` and `evidence.traces` for occurrence
215
+ evidence. Use `stacknext_get_diagnostic` to inspect one.
216
+
217
+ ## stacknext_get_diagnostic
218
+
219
+ Arguments: `diagnosticId` in the form `diag-xxxxxxxx-xxxxxxxx`.
220
+
221
+ Returns `{ finding, trace, meta }`. `finding` contains the rule, category,
222
+ severity, status, route, time window, affected trace count, fingerprint, bounded
223
+ evidence, `verification` steps and `limitations`. Evidence may include self-time
224
+ `contributors`, per-trace `traces` occurrences, span self time and Next.js
225
+ `nextPhase` values. `trace` is a related trace context
226
+ bounded by the server, or `null` when the evidence aged out. Use `get_trace` for
227
+ the complete span tree when the detail response is truncated.
228
+
229
+ A diagnostic id is not a credential. It identifies a deterministic finding in
230
+ the current sample; it can disappear when the underlying telemetry ages out.
231
+
232
+ ## stacknext_list_test_runs
233
+
234
+ Arguments: `limit`, `offset`.
235
+
236
+ Returns `{ items, total, limit, offset, meta }`. Items combine live collector
237
+ runs with saved runs from `.stacknext/runs`. Each summary includes `id`, `name`,
238
+ `projectName`, `status`, `createdAt`, `completedAt`, `durationMs`, scenario and
239
+ sample counts (`samples`, `verifiedSamples`, `incompleteSamples`) and the
240
+ captured `environment`. Live runs can be `running`; a non-completed run has
241
+ incomplete telemetry and supports no regression verdict.
242
+
243
+ ## stacknext_get_test_run
244
+
245
+ Arguments: `runId` (`run-<16 hex>`).
246
+
247
+ Returns the full run plus `meta`: `format`, `version`, `id`, `name`,
248
+ `projectName`, `status`, `createdAt`, `completedAt`, `command`, `environment`,
249
+ `collector`, `scenarios`, `warnings`, `notes`, `limitations` and `stats`. Each
250
+ scenario contains its stable `identity` (including `scenarioId`, title, file and
251
+ project), `samples`, aggregated `findings`, notes and limitations.
252
+
253
+ Each sample has its Playwright `status`, expected status, retry/repeat index,
254
+ duration, `capturedAt`, findings and `correlation`. Correlation is `verified` or
255
+ `incomplete` with bounded `reasons` and captured traces. Never turn an
256
+ incomplete sample into evidence by matching timestamps or nearby requests.
257
+
258
+ ## stacknext_list_baselines
259
+
260
+ Arguments: `limit`, `offset`.
261
+
262
+ Returns `{ items, total, limit, offset, meta }`. Each baseline summary includes
263
+ `id`, `name`, `projectName`, `createdAt`, `sourceRunId`, scenario/sample counts
264
+ and the recorded `environment`. Baselines are immutable and are never removed
265
+ automatically.
266
+
267
+ ## stacknext_get_baseline
268
+
269
+ Arguments: `baselineId` (`base-<16 hex>`).
270
+
271
+ Returns the baseline plus `meta`: `format`, `version`, `id`, `name`,
272
+ `projectName`, `createdAt`, `sourceRunId`, `environment`, `scenarios`,
273
+ `warnings`, `notes`, `limitations` and `stats`. `meta.identifiers` also carries
274
+ `sourceRunId`. The baseline does not follow later telemetry or app changes.
275
+
276
+ ## stacknext_list_comparisons
277
+
278
+ Arguments: `limit`, `offset`.
279
+
280
+ Returns `{ items, total, limit, offset, meta }`. Each item includes `id`,
281
+ `projectName`, `baselineId`, `candidateId`, `createdAt`, `status`, `severity`,
282
+ `summary` counts and `environmentCompatible`. Status and severity are separate;
283
+ `inconclusive` is not a pass.
284
+
285
+ ## stacknext_get_comparison
286
+
287
+ Arguments: `comparisonId` (`cmp-<16 hex>`).
288
+
289
+ Returns the comparison plus `meta`: `format`, `version`, `id`, `projectName`,
290
+ `createdAt`, `baselineId`, `candidateId`, `status`, `severity`, `environment`,
291
+ `options`, `summary`, `scenarios`, `warnings` and `limitations`.
292
+
293
+ - `environment.compatible`, `environment.ignored` and `environment.differences`
294
+ explain the environment gate. `--ignore-environment` is a CLI option; this
295
+ tool only reads the saved record.
296
+ - Each scenario includes `scenarioId`, title, file, project, `status`,
297
+ `severity`, `reasons`, `metrics`, and baseline/candidate sample counts.
298
+ - Metrics include `kind`, `status`, `severity`, `baselineValue`,
299
+ `candidateValue`, `delta`, `percent`, `sampleCount`, optional `note` and
300
+ `unmeasured`.
301
+
302
+ Comparisons use medians and explicit thresholds. They are not significance
303
+ tests and do not prove causality. Read the reasons and metrics before explaining
304
+ a result.
305
+
306
+ ## stacknext_list_snapshots
307
+
308
+ Arguments: `limit`, `offset`.
309
+
310
+ Returns `{ items, total, limit, offset, invalid, meta }`. Each item includes
311
+ `id` (`snap-<16 hex>`), `createdAt`, `source` (`manual`, `exit`, `error` or
312
+ `import`), `projectName`, `collectorVersion`, optional `label`, `sample`
313
+ (`firstEventTime`, `lastEventTime`, `retentionMs`), `stats` and `bytes`.
314
+ `invalid` counts unreadable summary files that are left on disk rather than
315
+ repaired or deleted.
316
+
317
+ ## stacknext_get_snapshot
318
+
319
+ Arguments: `snapshotId` (`snap-<16 hex>`).
320
+
321
+ Returns `{ snapshot, config, limitations, traces, errors, databaseQueries,
322
+ meta }`. The first 20 traces, errors and queries are included. `config` is the
323
+ captured collector config, not current live config. `meta.identifiers` carries
324
+ the `snapshotId`.
325
+
326
+ A snapshot has no diagnostics or coverage and never updates. Use
327
+ `stacknext_get_snapshot_trace` for one full scoped trace.
328
+
329
+ ## stacknext_get_snapshot_trace
330
+
331
+ Arguments: `snapshotId` (`snap-<16 hex>`), `traceId` (32 hexadecimal
332
+ characters).
333
+
334
+ Returns the same trace detail shape as `get_trace`, scoped to the frozen
335
+ snapshot, plus `meta`. It intentionally has no `diagnostics` array. A missing
336
+ trace or snapshot returns `isError: true`; use the list/detail tools to find
337
+ current ids.
338
+
339
+ ## Error responses
340
+
341
+ Tool failures return `isError: true` with a short text message and no structured
342
+ content. Typical messages:
343
+
344
+ - `Cannot reach the StackNext collector at ...` — the collector is stopped or
345
+ the runtime file is stale. Ask the user to run `stacknext dev`.
346
+ - `StackNext collector rejected the token ...` — the token changed after a
347
+ restart. Restart the MCP client or pass the current token.
348
+ - `No request with trace id ... was found ...` — the id is wrong or the trace
349
+ aged out of the retention window. Use `list_requests` to find a current id.
350
+ - `No error with id ... was found ...` — the error aged out or the id is wrong.
351
+ Use `list_errors`.
352
+ - `No diagnostic with id ... was found ...` — the finding aged out or the id is
353
+ wrong. Use `stacknext_list_diagnostics` to find a current id.
354
+ - `No saved test run with id ... was found ...` — the run id is wrong or the
355
+ record is outside the collector's project directory. Use
356
+ `stacknext_list_test_runs`.
357
+ - `No baseline with id ... was found ...` — use `stacknext_list_baselines`.
358
+ - `No comparison with id ... was found ...` — use
359
+ `stacknext_list_comparisons`.
360
+ - `No snapshot with id ... was found ...` — the snapshot id is wrong or the
361
+ record is outside the collector's project directory. Use
362
+ `stacknext_list_snapshots`.
363
+ - `No trace ... was found in snapshot ...` — use `stacknext_get_snapshot` to
364
+ see the traces stored in that snapshot.
365
+
366
+ Do not treat an empty result as a tool failure. Empty results are successful
367
+ responses with `total: 0` and a completeness reason. Missing regression or
368
+ snapshot records mean the MCP server has nothing saved to read; they do not
369
+ justify creating a record from telemetry.