-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassifier.test.ts
More file actions
132 lines (100 loc) · 4.68 KB
/
Copy pathclassifier.test.ts
File metadata and controls
132 lines (100 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import assert from "node:assert/strict";
import { classifyPane } from "./classifier";
// Real fixture: pi working state (captured from a live session)
const working = classifyPane(`use the ask_user_question tool to ask me a question with 2 options
Thinking...
ask user Choose option
⠇ Working...
`);
assert.equal(working.status, "working");
assert.equal(working.dangerous, false);
// Real fixture: ask_user_question dialog rendered by pi's ui.select
const dialog = classifyPane(` Would you like to proceed with option A or option B?
> 1. Option A (Recommended)
This is the first option, recommended for most cases.
2. Option B
This is the alternative option, suitable for specific scenarios.
3. Type your own answer...
↑↓ navigate · Enter select · Esc cancel`);
assert.equal(dialog.status, "dialog");
assert.equal(dialog.question, true);
assert.equal(dialog.dangerous, false);
// Dangerous dialog (destructive content inside a selector)
const dangerousDialog = classifyPane(`Would you like to run this command?
> 1. Yes
Allow once
2. No
↑↓ navigate · Enter select · Esc cancel
rm -rf dist && git push origin main`);
assert.equal(dangerousDialog.status, "dialog");
assert.equal(dangerousDialog.dangerous, true);
// Real fixture: idle pane after a completed turn (status line + input prompt)
const idle = classifyPane(` Done — created /tmp/pisup-probe-1.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
/private/tmp/pisup-new • probe3
0.0%/1.0M (auto) (deepseek) deepseek-v4-pro • max
`);
assert.equal(idle.status, "idle");
assert.equal(idle.unresolvedFailure, false);
// A terminal failure in the live tail must be preserved by automatic cleanup.
const failed = classifyPane(`Test run completed.
Command exited with code 1
────────────────────────────────────────────────────────────────
~/project • worker
(openai) model • high`);
assert.equal(failed.status, "idle");
assert.equal(failed.unresolvedFailure, true);
// Merely discussing a fixed error must not prevent cleanup.
const fixedError = classifyPane(`Done — fixed the authentication error and added regression coverage.
All tests passed.
────────────────────────────────────────────────────────────────
~/project • worker
(openai) model • high`);
assert.equal(fixedError.unresolvedFailure, false);
// Scrollback can retain old working spinners after the agent has completed.
// Only the live pane tail should determine state.
const staleSpinner = classifyPane(` Thinking...
bash test
✓ done
Final implementation summary
- tests passed
- build passed
- no commit
line 01
line 02
line 03
line 04
line 05
line 06
line 07
line 08
line 09
line 10
line 11
line 12
line 13
line 14
line 15
line 16
────────────────────────────────────────────────────────────────
~/project (main) • worker
42%/272k (auto) (openai-codex) gpt-5.6-sol • high`);
assert.equal(staleSpinner.status, "idle");
// Assistant replies with numbered lists must NOT look like a dialog
const numberedList = classifyPane(`Here are the steps:
1. Clone the repository
2. Install dependencies
3. Run the tests
Done.`);
assert.equal(numberedList.status, "idle");
// Missing session
const missing = classifyPane("", false);
assert.equal(missing.status, "missing");
assert.equal(missing.piLike, false);
assert.equal(missing.unresolvedFailure, false);
// pi-like detection: startup screen
const piLike = classifyPane(` pi v0.83.0
escape interrupt · ctrl+c/ctrl+d clear/exit · / commands · ! bash · ctrl+o more
Press ctrl+o to show full startup help and loaded resources.`);
assert.equal(piLike.piLike, true);
console.log("pi-supervisor classifier tests passed");