Skip to content

Commit e12e48f

Browse files
Update investigation skill asset guidance (#1349)
* docs: update investigation skill asset guidance * test: normalize ai context fixture line endings * docs: clarify asset selector discovery * docs: mirror asset variability warning
1 parent f11219d commit e12e48f

5 files changed

Lines changed: 141 additions & 9 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { readFile } from 'node:fs/promises'
2+
import { dirname, join } from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
import { describe, expect, it } from 'vitest'
5+
6+
const referencesDir = join(dirname(fileURLToPath(import.meta.url)), '../references')
7+
8+
function readReference (name: string): Promise<string> {
9+
return readFile(join(referencesDir, name), 'utf8')
10+
}
11+
12+
function normalizeLineEndings (content: string): string {
13+
return content.replace(/\r\n/g, '\n')
14+
}
15+
16+
describe('AI context investigation references', () => {
17+
it('points test-session asset retrieval at the assets commands', async () => {
18+
const content = normalizeLineEndings(await readReference('investigate-test-sessions.md'))
19+
20+
expect(content).toContain('npx checkly assets list --test-session-id <test-session-id> --result-id <test-session-result-id>')
21+
expect(content).toContain('npx checkly assets download --test-session-id <test-session-id> --result-id <test-session-result-id> --asset "<Asset>"')
22+
expect(content).toContain('The default table output\nhas an `Asset` column; copy that value into `--asset` for single-file downloads.')
23+
expect(content).toContain('"pagination": {\n "length": 0\n }')
24+
expect(content).not.toContain('There is no dedicated `test-sessions download` command')
25+
expect(content).not.toContain('download those URLs directly')
26+
})
27+
28+
it('documents check result attempts and asset retrieval', async () => {
29+
const content = normalizeLineEndings(await readReference('investigate-checks.md'))
30+
31+
expect(content).toContain('npx checkly checks get <check-id> --result <result-id> --include-attempts --output json')
32+
expect(content).toContain('"result": {}')
33+
expect(content).toContain('"attempts": []')
34+
expect(content).toContain('npx checkly assets list --check-id <check-id> --result-id <result-id>')
35+
expect(content).toContain('npx checkly assets download --check-id <check-id> --result-id <result-id> --asset "<Asset>"')
36+
expect(content).toContain('The default table output\nhas an `Asset` column; copy that value into `--asset` for single-file downloads.')
37+
expect(content).toContain('Do not invent asset names or assume every result has the same artifact set.')
38+
})
39+
})

packages/cli/src/ai-context/context.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export const REFERENCES = [
6060
export const INVESTIGATE_REFERENCES = [
6161
{
6262
id: 'investigate-checks',
63-
description: 'Inspecting checks (`checks list`, `checks get`) and triggering on-demand runs',
63+
description: 'Inspect checks (`checks list`, `checks get`), retry attempts, result assets, and trigger on-demand runs',
6464
},
6565
{
6666
id: 'investigate-test-sessions',
67-
description: 'Run and inspect recorded test sessions, drill into test-session error groups, run RCA, and retrieve result assets',
67+
description: 'Run and inspect recorded test sessions, drill into test-session error groups, run RCA, and list/download result assets',
6868
},
6969
] as const
7070

@@ -103,7 +103,7 @@ export const ACTIONS = [
103103
},
104104
{
105105
id: 'investigate',
106-
description: 'Access check and test-session status, analyze failures, and investigate errors.',
106+
description: 'Access check and test-session status, analyze failures, inspect attempts/assets, and investigate errors.',
107107
references: INVESTIGATE_REFERENCES,
108108
},
109109
{

packages/cli/src/ai-context/references/investigate-checks.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Flags:
4848

4949
```bash
5050
npx checkly checks get <check-id> --result <result-id>
51+
npx checkly checks get <check-id> --result <result-id> --output json
5152
```
5253

5354
### View retry attempts for a result
@@ -60,8 +61,63 @@ error summary:
6061

6162
```bash
6263
npx checkly checks get <check-id> --result <result-id> --include-attempts
64+
npx checkly checks get <check-id> --result <result-id> --include-attempts --output json
6365
```
6466

67+
With `--include-attempts --output json`, the command returns a stable envelope:
68+
69+
```json
70+
{
71+
"result": {},
72+
"attempts": []
73+
}
74+
```
75+
76+
Use the `attempts` array to inspect intermediate retry failures. Use the `result`
77+
object for the requested result row.
78+
79+
### List or download result assets
80+
81+
Result detail output summarizes available screenshots, traces, and videos when
82+
present. Use the dedicated asset manifest commands to inspect exact asset names
83+
and download files:
84+
85+
```bash
86+
npx checkly assets list --check-id <check-id> --result-id <result-id>
87+
npx checkly assets list --check-id <check-id> --result-id <result-id> --type trace --view tree
88+
npx checkly assets list --check-id <check-id> --result-id <result-id> --output json
89+
npx checkly assets download --check-id <check-id> --result-id <result-id> --asset "<Asset>"
90+
npx checkly assets download --check-id <check-id> --result-id <result-id> --type all --dir ./checkly-assets
91+
```
92+
93+
Run `assets list` first to discover available files. The default table output
94+
has an `Asset` column; copy that value into `--asset` for single-file downloads.
95+
96+
Flags:
97+
- `--type <type>` - filter/select by `log`, `trace`, `video`, `screenshot`, `pcap`, `report`, `file`, or `all`.
98+
- `--asset <value>` - exact Asset/Name value or glob. Prefer copying the `Asset` value from the default table output before downloading a single file.
99+
- `--dir <path>` - destination directory for downloads; defaults under `./checkly-assets/`.
100+
- `--force` / `--skip-existing` - overwrite or preserve existing files.
101+
102+
`assets list --output json` uses a stable list envelope:
103+
104+
```json
105+
{
106+
"data": [],
107+
"pagination": {
108+
"length": 0
109+
}
110+
}
111+
```
112+
113+
`assets download` requires `--type` or `--asset` unless the manifest is a single
114+
archive bundle. Archive entries download as their containing archive; filters
115+
narrow the manifest list, not the archive bytes.
116+
117+
Do not invent asset names or assume every result has the same artifact set. Some
118+
results have screenshots only, some have traces or videos, and some have no
119+
downloadable assets.
120+
65121
### View an error group
66122

67123
```bash

packages/cli/src/ai-context/references/investigate-test-sessions.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Flags:
7878

7979
The detail view shows the session status, metadata, result rows, test-session result IDs, check IDs when available, and test-session error group IDs. Prefer `--watch` before investigating failures so you do not act on partial results.
8080

81-
Use `--output json` when you need exact fields, result links, or asset URLs. For Playwright Check Suite results, inspect result payload fields such as Playwright result details, traces, videos, screenshots, reports, and links when present.
81+
Use `--output json` when you need exact fields, result links, check IDs, or test-session result IDs. For downloadable logs, traces, videos, screenshots, reports, and files, use `checkly assets list` and `checkly assets download` with the test session ID and result ID.
8282

8383
## Inspect a test-session error group
8484

@@ -116,13 +116,50 @@ If RCA is unavailable because of plan or entitlement limits, run `npx checkly ac
116116

117117
## Retrieve result assets
118118

119-
There is no dedicated `test-sessions download` command. Use the JSON outputs and links exposed by the session or result payload.
119+
Use the asset manifest commands for recorded test-session result files. Start
120+
from `test-sessions get` to identify the `testSessionResultId` (and `checkId`
121+
when available) for the row you want to inspect.
120122

121123
```bash
122124
npx checkly test-sessions get <test-session-id> --output json
123-
npx checkly checks get <check-id> --result <test-session-result-id> --output json
125+
npx checkly assets list --test-session-id <test-session-id> --result-id <test-session-result-id>
126+
npx checkly assets list --test-session-id <test-session-id> --result-id <test-session-result-id> --type trace --view tree
127+
npx checkly assets list --test-session-id <test-session-id> --result-id <test-session-result-id> --output json
128+
npx checkly assets download --test-session-id <test-session-id> --result-id <test-session-result-id> --asset "<Asset>"
129+
npx checkly assets download --test-session-id <test-session-id> --result-id <test-session-result-id> --type all --dir ./checkly-assets
124130
```
125131

126-
Use `test-sessions get --output json` first. If a result includes public URLs or asset fields, download those URLs directly. If a result only gives `checkId` plus `testSessionResultId`, use `checks get <check-id> --result <test-session-result-id> --output json` to fetch detailed result data; terminal output summarizes available screenshots, traces, and videos, while JSON output exposes the underlying URLs/fields.
132+
Run `assets list` first to discover available files. The default table output
133+
has an `Asset` column; copy that value into `--asset` for single-file downloads.
127134

128-
Do not invent asset names or assume every result has the same artifact set. Some results have screenshots only, some have traces or videos, and some have no downloadable assets.
135+
Flags:
136+
- `--type <type>` - filter/select by `log`, `trace`, `video`, `screenshot`, `pcap`, `report`, `file`, or `all`.
137+
- `--asset <value>` - exact Asset/Name value or glob. Prefer copying the `Asset` value from `assets list --view table` for single-file downloads.
138+
- `--dir <path>` - destination directory for downloads; defaults under `./checkly-assets/`.
139+
- `--force` / `--skip-existing` - overwrite or preserve existing files.
140+
141+
`assets list --output json` uses a stable list envelope:
142+
143+
```json
144+
{
145+
"data": [],
146+
"pagination": {
147+
"length": 0
148+
}
149+
}
150+
```
151+
152+
`assets download` requires `--type` or `--asset` unless the manifest is a single
153+
archive bundle. Archive entries download as their containing archive; filters
154+
narrow the manifest list, not the archive bytes.
155+
156+
If you also need the scheduled check result view for the same row, and the row
157+
has a `checkId`, use:
158+
159+
```bash
160+
npx checkly checks get <check-id> --result <test-session-result-id>
161+
```
162+
163+
Do not invent asset names or assume every result has the same artifact set. Some
164+
results have screenshots only, some have traces or videos, and some have no
165+
downloadable assets.

skills/checkly/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Learn how to initialize and set up a new Checkly CLI project from scratch.
103103
Learn how to create and manage monitoring checks using Checkly constructs and the CLI.
104104

105105
### `npx checkly skills investigate`
106-
Access check and test-session status, analyze failures, and investigate errors.
106+
Access check and test-session status, analyze failures, inspect attempts/assets, and investigate errors.
107107

108108
### `npx checkly skills communicate`
109109
Open incidents and lead customer communications via status pages.

0 commit comments

Comments
 (0)