Skip to content

Commit 5637f13

Browse files
anton-107Isaac
andcommitted
aitools: add install funnel telemetry
Every `databricks aitools install` run now logs an `aitools_command_event` funnel next to the existing `aitools_install_event`, so the telemetry shows where runs stop: ```text install RunE STARTED (every run past flag parsing) validate flags --> FINISHED FAILURE INVALID_FLAGS STEP FLAGS_VALIDATED --path dump --> STEP SKILLS_DUMPED, FINISHED SUCCESS (0 skills written: FINISHED FAILURE, exit 0 unchanged) scope prompt --> FINISHED CANCELLED USER_ABORTED | FAILURE PROMPT_FAILED STEP SCOPE_RESOLVED --agents / picker --> FINISHED FAILURE UNKNOWN_AGENT | CANCELLED (nothing checked) no agent detected: FINISHED NOTHING_TO_DO STEP AGENTS_SELECTED confirm prompt --> FINISHED CANCELLED (declined) STEP PLAN_CONFIRMED executePlan STEP SKILLS_INSTALLED (skills group installed) STEP PLUGINS_INSTALLED (at least one plugin installed) FINISHED SUCCESS | FAILURE <category> ``` Each event carries `command`, `stage`, `interactive`, `install_mode` (DEFAULT / SKILLS_ONLY / PATH) and, once known, `scope`. FINISHED also carries `outcome`, `error_category` and the targeted `agents`. Every event of a run shares the entry's `cmd_exec_id`. There is no calling-agent field: the upload's User-Agent already has `agent/<name>` and `cmd-exec-id`. `error_category` comes from the existing `classifyInstallError`. Failures in flag validation, agent lookup and prompts are tagged with a category where they happen (a prompt step's error is PROMPT_FAILED whatever its type, except a Ctrl-C abort). `Error()` / `Unwrap()` pass through, so the user still sees the same message: ```diff classifyInstallError(err) *installer.BlockedError / *installer.SkillError -> their category + *categorizedError (withCategory, promptError) -> the tagged category stdlibErrorCategory(err) ``` Some runs get an explicit outcome instead of the one their return value implies: - Returns nil but installed nothing (e.g. the only detected agent's plugin install failed, which is a warning): FAILURE with the first failing agent's category. - Fails only because a named agent failed or was skipped (`--agents`): the category comes from that agent's outcome (e.g. UNSUPPORTED_SCOPE), not UNCATEGORIZED. - `--output json` failure: classifies the real error, not the `ErrAlreadyPrinted` sentinel. - `--project --global` and `--agents ","`: INVALID_FLAGS, not PROMPT_FAILED / UNKNOWN_AGENT. No change to output, prompts, exit codes or error text. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 0d29efd commit 5637f13

17 files changed

Lines changed: 1014 additions & 23 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cloud = false
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
2+
=== invalid flag combination fails before any step
3+
Error: cannot use --skills-only with --path; --path always writes raw skill files
4+
5+
Exit code: 1
6+
7+
>>> print_telemetry
8+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STARTED","interactive":false,"install_mode":"PATH"}}
9+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"INVALID_FLAGS","interactive":false,"install_mode":"PATH"}}
10+
11+
=== unknown agent fails after the scope step
12+
Error: unknown agent "no-such-agent". Available agents: claude-code, cursor, codex, opencode, copilot, antigravity, pi, gemini, goose, kiro
13+
14+
Exit code: 1
15+
16+
>>> print_telemetry
17+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STARTED","interactive":false,"install_mode":"SKILLS_ONLY"}}
18+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"FLAGS_VALIDATED","interactive":false,"install_mode":"SKILLS_ONLY"}}
19+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"SCOPE_RESOLVED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
20+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"UNKNOWN_AGENT","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
21+
22+
=== a skill missing from the manifest fails after the plan is confirmed
23+
Installing Databricks skills for Cursor...
24+
Using skills version test-ref
25+
Fetching skills manifest...
26+
Error: skill "nonexistent" not found
27+
28+
Exit code: 1
29+
30+
>>> print_telemetry
31+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STARTED","interactive":false,"install_mode":"SKILLS_ONLY"}}
32+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"FLAGS_VALIDATED","interactive":false,"install_mode":"SKILLS_ONLY"}}
33+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"SCOPE_RESOLVED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
34+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"AGENTS_SELECTED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
35+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"PLAN_CONFIRMED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
36+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"SKILL_NOT_FOUND","interactive":false,"install_mode":"SKILLS_ONLY","agents":["CURSOR"],"scope":"GLOBAL"}}
37+
{"command":"aitools_install","exit_code":1,"aitools_install_event":{"agents":["CURSOR"],"scope":"GLOBAL","error_category":"SKILL_NOT_FOUND"}}
38+
39+
=== a manifest the server does not have is MANIFEST_NOT_FOUND
40+
Installing Databricks skills for Cursor...
41+
Using skills version missing-ref
42+
Fetching skills manifest...
43+
Error: skills manifest at databricks-agent-skills@missing-ref: not found
44+
45+
Exit code: 1
46+
47+
>>> print_telemetry
48+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STARTED","interactive":false,"install_mode":"SKILLS_ONLY"}}
49+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"FLAGS_VALIDATED","interactive":false,"install_mode":"SKILLS_ONLY"}}
50+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"SCOPE_RESOLVED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
51+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"AGENTS_SELECTED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
52+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"PLAN_CONFIRMED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
53+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"MANIFEST_NOT_FOUND","interactive":false,"install_mode":"SKILLS_ONLY","agents":["CURSOR"],"scope":"GLOBAL"}}
54+
{"command":"aitools_install","exit_code":1,"aitools_install_event":{"agents":["CURSOR"],"scope":"GLOBAL","error_category":"MANIFEST_NOT_FOUND"}}
55+
56+
=== any other HTTP error status from the manifest fetch is not classified yet (the error is untyped)
57+
Installing Databricks skills for Cursor...
58+
Using skills version broken-ref
59+
Fetching skills manifest...
60+
Error: failed to fetch manifest: HTTP 500
61+
62+
Exit code: 1
63+
64+
>>> print_telemetry
65+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STARTED","interactive":false,"install_mode":"SKILLS_ONLY"}}
66+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"FLAGS_VALIDATED","interactive":false,"install_mode":"SKILLS_ONLY"}}
67+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"SCOPE_RESOLVED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
68+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"AGENTS_SELECTED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
69+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"PLAN_CONFIRMED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
70+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"UNCATEGORIZED","interactive":false,"install_mode":"SKILLS_ONLY","agents":["CURSOR"],"scope":"GLOBAL"}}
71+
{"command":"aitools_install","exit_code":1,"aitools_install_event":{"agents":["CURSOR"],"scope":"GLOBAL","error_category":"UNCATEGORIZED"}}
72+
73+
=== a named agent skipped for the scope takes its category from the agent's outcome
74+
Skipped Cursor: does not support project-scoped skills
75+
Error: Cursor: does not support project-scoped skills
76+
77+
Exit code: 1
78+
79+
>>> print_telemetry
80+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STARTED","interactive":false,"install_mode":"SKILLS_ONLY"}}
81+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"FLAGS_VALIDATED","interactive":false,"install_mode":"SKILLS_ONLY"}}
82+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"SCOPE_RESOLVED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"PROJECT"}}
83+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"AGENTS_SELECTED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"PROJECT"}}
84+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"PLAN_CONFIRMED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"PROJECT"}}
85+
{"command":"aitools_install","exit_code":1,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"UNSUPPORTED_SCOPE","interactive":false,"install_mode":"SKILLS_ONLY","agents":["CURSOR"],"scope":"PROJECT"}}
86+
{"command":"aitools_install","exit_code":1,"aitools_install_event":{"agents":["CURSOR"],"scope":"PROJECT","error_category":"TYPE_UNSPECIFIED","agent_results":[{"agent":"CURSOR","error_category":"UNSUPPORTED_SCOPE"}]}}
87+
88+
=== a --path dump that writes no skill exits 0 but finishes as FAILURE, with no SKILLS_DUMPED step
89+
90+
>>> env DATABRICKS_SKILLS_REF=experimental-ref [CLI] aitools install --path dump
91+
Using skills version experimental-ref
92+
Wrote 0 skills to dump
93+
94+
>>> print_telemetry
95+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"STARTED","interactive":false,"install_mode":"PATH"}}
96+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"FLAGS_VALIDATED","interactive":false,"install_mode":"PATH"}}
97+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"FAILURE","error_category":"UNCATEGORIZED","interactive":false,"install_mode":"PATH"}}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Isolate HOME so parallel aitools tests don't race on a shared ~/.databricks.
2+
sethome home
3+
mkdir -p "${USERPROFILE:-$HOME}/.cursor"
4+
5+
title "invalid flag combination fails before any step\n"
6+
errcode $CLI aitools install --skills-only --path out
7+
trace print_telemetry
8+
9+
title "unknown agent fails after the scope step\n"
10+
errcode $CLI aitools install --skills-only --scope=global --agents=no-such-agent
11+
trace print_telemetry
12+
13+
title "a skill missing from the manifest fails after the plan is confirmed\n"
14+
errcode $CLI aitools install --skills-only --scope=global --agents=cursor --skills=nonexistent
15+
trace print_telemetry
16+
17+
title "a manifest the server does not have is MANIFEST_NOT_FOUND\n"
18+
errcode env DATABRICKS_SKILLS_REF=missing-ref $CLI aitools install --skills-only --scope=global --agents=cursor
19+
trace print_telemetry
20+
21+
title "any other HTTP error status from the manifest fetch is not classified yet (the error is untyped)\n"
22+
errcode env DATABRICKS_SKILLS_REF=broken-ref $CLI aitools install --skills-only --scope=global --agents=cursor
23+
trace print_telemetry
24+
25+
title "a named agent skipped for the scope takes its category from the agent's outcome\n"
26+
errcode $CLI aitools install --skills-only --scope=project --agents=cursor
27+
trace print_telemetry
28+
29+
title "a --path dump that writes no skill exits 0 but finishes as FAILURE, with no SKILLS_DUMPED step\n"
30+
trace env DATABRICKS_SKILLS_REF=experimental-ref $CLI aitools install --path dump
31+
trace print_telemetry
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[[Server]]
2+
Pattern = "GET /missing-ref/manifest.json"
3+
Response.StatusCode = 404
4+
5+
[[Server]]
6+
Pattern = "GET /broken-ref/manifest.json"
7+
Response.StatusCode = 500
8+
9+
# Only an experimental skill, so a dump without --experimental writes nothing.
10+
[[Server]]
11+
Pattern = "GET /experimental-ref/manifest.json"
12+
Response.Body = '''
13+
{
14+
"version": "2",
15+
"updated_at": "2026-01-01T00:00:00Z",
16+
"skills": {
17+
"databricks-preview": {
18+
"version": "1.0.0",
19+
"description": "Experimental skill",
20+
"files": ["SKILL.md"],
21+
"repo_dir": "experimental"
22+
}
23+
}
24+
}
25+
'''
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cloud = false
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
=== install: STARTED, one event per step reached, FINISHED with SUCCESS
3+
4+
>>> [CLI] aitools install --skills-only --scope=global --agents=cursor
5+
Installing Databricks skills for Cursor...
6+
Using skills version test-ref
7+
Fetching skills manifest...
8+
Installed 1 skill.
9+
10+
>>> print_telemetry
11+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"STARTED","interactive":false,"install_mode":"SKILLS_ONLY"}}
12+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"FLAGS_VALIDATED","interactive":false,"install_mode":"SKILLS_ONLY"}}
13+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"SCOPE_RESOLVED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
14+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"AGENTS_SELECTED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
15+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"PLAN_CONFIRMED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
16+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"STEP_COMPLETED","step":"SKILLS_INSTALLED","interactive":false,"install_mode":"SKILLS_ONLY","scope":"GLOBAL"}}
17+
{"command":"aitools_install","exit_code":0,"aitools_install_event":{"agents":["CURSOR"],"scope":"GLOBAL","error_category":"TYPE_UNSPECIFIED"}}
18+
{"command":"aitools_install","exit_code":0,"aitools_command_event":{"command":"INSTALL","stage":"FINISHED","outcome":"SUCCESS","interactive":false,"install_mode":"SKILLS_ONLY","agents":["CURSOR"],"scope":"GLOBAL"}}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Isolate HOME so parallel aitools tests don't race on a shared ~/.databricks.
2+
sethome home
3+
mkdir -p "${USERPROFILE:-$HOME}/.cursor"
4+
5+
title "install: STARTED, one event per step reached, FINISHED with SUCCESS\n"
6+
trace $CLI aitools install --skills-only --scope=global --agents=cursor
7+
trace print_telemetry

‎acceptance/cmd/aitools/telemetry/test.toml‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Telemetry payloads of the install hint.
1+
# Telemetry payloads of the aitools commands and of the install hint.
2+
# The mock server replaces raw.githubusercontent.com (skills manifest and files).
3+
Env.DATABRICKS_SKILLS_BASE_URL = "$DATABRICKS_HOST"
4+
Env.DATABRICKS_CLI_GITHUB_API_URL = "$DATABRICKS_HOST"
5+
Env.DATABRICKS_SKILLS_REF = "test-ref"
26
RecordRequests = true
37

48
Ignore = [
@@ -13,3 +17,29 @@ Response.Body = '''
1317
"numProtoSuccess": 100
1418
}
1519
'''
20+
21+
[[Server]]
22+
Pattern = "GET /test-ref/manifest.json"
23+
Response.Body = '''
24+
{
25+
"version": "2",
26+
"updated_at": "2026-01-01T00:00:00Z",
27+
"skills": {
28+
"databricks-test": {
29+
"version": "1.0.0",
30+
"description": "Test skill",
31+
"files": ["SKILL.md"],
32+
"repo_dir": "skills"
33+
}
34+
}
35+
}
36+
'''
37+
38+
[[Server]]
39+
Pattern = "GET /test-ref/skills/databricks-test/SKILL.md"
40+
Response.Body = '''---
41+
name: databricks-test
42+
---
43+
44+
# Test skill
45+
'''

‎cmd/aitools/categorize.go‎

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,41 @@ import (
1414
"github.com/databricks/cli/libs/telemetry/protos"
1515
)
1616

17+
// categorizedError tags an error with a telemetry category at the site that
18+
// knows what failed (flag validation, agent lookup, a prompt). The tag wins
19+
// over the standard library types. Error() and Unwrap() pass through, so the
20+
// user-visible message is unchanged.
21+
type categorizedError struct {
22+
err error
23+
category protos.AitoolsErrorCategory
24+
}
25+
26+
func (e *categorizedError) Error() string { return e.err.Error() }
27+
func (e *categorizedError) Unwrap() error { return e.err }
28+
29+
// withCategory tags err with category; nil stays nil.
30+
func withCategory(err error, category protos.AitoolsErrorCategory) error {
31+
if err == nil {
32+
return nil
33+
}
34+
return &categorizedError{err: err, category: category}
35+
}
36+
37+
// promptError tags a prompt failure. A user abort (Ctrl-C) keeps its own
38+
// classification so the funnel reports it as CANCELLED, not as a failure.
39+
// Any other error of a prompt step is PROMPT_FAILED, even one with an OS
40+
// error type: the prompt library wraps a failure to open the terminal as an
41+
// *fs.PathError, and FILESYSTEM would point at the skill files instead.
42+
func promptError(err error) error {
43+
if err == nil || errors.Is(err, huh.ErrUserAborted) {
44+
return err
45+
}
46+
return withCategory(err, protos.AitoolsErrorCategoryPromptFailed)
47+
}
48+
1749
// classifyInstallError maps an aitools error to its telemetry category without
18-
// reading any error text. Typed installer errors win, then standard library
19-
// error types.
50+
// reading any error text. Typed installer errors win, then categories tagged at
51+
// the failure site, then standard library error types.
2052
func classifyInstallError(err error) protos.AitoolsErrorCategory {
2153
if err == nil {
2254
return protos.AitoolsErrorCategoryUnspecified
@@ -28,6 +60,9 @@ func classifyInstallError(err error) protos.AitoolsErrorCategory {
2860
if skill, ok := errors.AsType[*installer.SkillError](err); ok {
2961
return skillErrorCategory(skill)
3062
}
63+
if tagged, ok := errors.AsType[*categorizedError](err); ok {
64+
return tagged.category
65+
}
3166
return stdlibErrorCategory(err)
3267
}
3368

‎cmd/aitools/categorize_test.go‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ func TestClassifyInstallErrorGenericCauses(t *testing.T) {
114114
{"filesystem on rename", fmt.Errorf("replace skill: %w", &os.LinkError{Op: "rename", Old: "/a", New: "/b", Err: syscall.EBUSY}), protos.AitoolsErrorCategoryFilesystem},
115115
{"filesystem syscall", fmt.Errorf("resolve cwd: %w", os.NewSyscallError("getwd", syscall.ENOENT)), protos.AitoolsErrorCategoryFilesystem},
116116
{"user abort", huh.ErrUserAborted, protos.AitoolsErrorCategoryUserAborted},
117+
{"tagged", withCategory(errors.New("bad flags"), protos.AitoolsErrorCategoryInvalidFlags), protos.AitoolsErrorCategoryInvalidFlags},
118+
{"prompt failure", promptError(errors.New("no tty")), protos.AitoolsErrorCategoryPromptFailed},
119+
{"prompt abort keeps abort", promptError(huh.ErrUserAborted), protos.AitoolsErrorCategoryUserAborted},
120+
{"typed error beats tag", withCategory(&installer.BlockedError{Reason: installer.ReasonCLINotOnPath}, protos.AitoolsErrorCategoryInvalidFlags), protos.AitoolsErrorCategoryCLINotOnPath},
117121
{"plain text stays uncategorized", errors.New("something"), protos.AitoolsErrorCategoryUncategorized},
118122
}
119123
for _, tc := range cases {
@@ -123,6 +127,15 @@ func TestClassifyInstallErrorGenericCauses(t *testing.T) {
123127
}
124128
}
125129

130+
func TestWithCategoryKeepsMessage(t *testing.T) {
131+
cause := errors.New("cannot use --skills-only with --path")
132+
err := withCategory(cause, protos.AitoolsErrorCategoryInvalidFlags)
133+
assert.Equal(t, cause.Error(), err.Error())
134+
assert.ErrorIs(t, err, cause)
135+
assert.NoError(t, withCategory(nil, protos.AitoolsErrorCategoryInvalidFlags))
136+
assert.NoError(t, promptError(nil))
137+
}
138+
126139
// A corrupt install state must not be blamed on the remote manifest. It stays
127140
// UNCATEGORIZED until the installer returns a typed state error, which should
128141
// change this to STATE_INVALID.

0 commit comments

Comments
 (0)