ccmanager 2.9.2 → 2.10.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.
|
@@ -23,3 +23,6 @@ export declare class CursorStateDetector extends BaseStateDetector {
|
|
|
23
23
|
export declare class GitHubCopilotStateDetector extends BaseStateDetector {
|
|
24
24
|
detectState(terminal: Terminal, _currentState: SessionState): SessionState;
|
|
25
25
|
}
|
|
26
|
+
export declare class ClineStateDetector extends BaseStateDetector {
|
|
27
|
+
detectState(terminal: Terminal, _currentState: SessionState): SessionState;
|
|
28
|
+
}
|
|
@@ -10,6 +10,8 @@ export function createStateDetector(strategy = 'claude') {
|
|
|
10
10
|
return new CursorStateDetector();
|
|
11
11
|
case 'github-copilot':
|
|
12
12
|
return new GitHubCopilotStateDetector();
|
|
13
|
+
case 'cline':
|
|
14
|
+
return new ClineStateDetector();
|
|
13
15
|
default:
|
|
14
16
|
return new ClaudeStateDetector();
|
|
15
17
|
}
|
|
@@ -48,8 +50,9 @@ export class ClaudeStateDetector extends BaseStateDetector {
|
|
|
48
50
|
content.includes('│ Would you like')) {
|
|
49
51
|
return 'waiting_input';
|
|
50
52
|
}
|
|
51
|
-
// Check for "Do you want"
|
|
52
|
-
|
|
53
|
+
// Check for "Do you want" or "Would you like" pattern with options
|
|
54
|
+
// Handles both simple ("Do you want...\nYes") and complex (numbered options) formats
|
|
55
|
+
if (/(?:do you want|would you like).+\n+[\s\S]*?(?:yes|❯)/.test(lowerContent)) {
|
|
53
56
|
return 'waiting_input';
|
|
54
57
|
}
|
|
55
58
|
// Check for busy state
|
|
@@ -131,3 +134,26 @@ export class GitHubCopilotStateDetector extends BaseStateDetector {
|
|
|
131
134
|
return 'idle';
|
|
132
135
|
}
|
|
133
136
|
}
|
|
137
|
+
// https://github.com/cline/cline/blob/580db36476b6b52def03c8aeda325aae1c817cde/cli/pkg/cli/task/input_handler.go
|
|
138
|
+
export class ClineStateDetector extends BaseStateDetector {
|
|
139
|
+
detectState(terminal, _currentState) {
|
|
140
|
+
const content = this.getTerminalContent(terminal);
|
|
141
|
+
const lowerContent = content.toLowerCase();
|
|
142
|
+
// Check for waiting prompts with tool permission - Priority 1
|
|
143
|
+
// Pattern: [\[act|plan\] mode].*?\n.*yes (when mode indicator present)
|
|
144
|
+
// Or simply: let cline use this tool (distinctive text)
|
|
145
|
+
if (/\[(act|plan) mode\].*?\n.*yes/i.test(lowerContent) ||
|
|
146
|
+
/let cline use this tool/i.test(lowerContent)) {
|
|
147
|
+
return 'waiting_input';
|
|
148
|
+
}
|
|
149
|
+
// Check for idle state - Priority 2
|
|
150
|
+
// Pattern: [\[act|plan\] mode].*Cline is ready for your message... (when mode indicator present)
|
|
151
|
+
// Or simply: cline is ready for your message (distinctive text)
|
|
152
|
+
if (/\[(act|plan) mode\].*cline is ready for your message/i.test(lowerContent) ||
|
|
153
|
+
/cline is ready for your message/i.test(lowerContent)) {
|
|
154
|
+
return 'idle';
|
|
155
|
+
}
|
|
156
|
+
// Otherwise busy - Priority 3
|
|
157
|
+
return 'busy';
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
-
import { ClaudeStateDetector, GeminiStateDetector, CodexStateDetector, CursorStateDetector, GitHubCopilotStateDetector, } from './stateDetector.js';
|
|
2
|
+
import { ClaudeStateDetector, GeminiStateDetector, CodexStateDetector, CursorStateDetector, GitHubCopilotStateDetector, ClineStateDetector, } from './stateDetector.js';
|
|
3
3
|
const createMockTerminal = (lines) => {
|
|
4
4
|
const buffer = {
|
|
5
5
|
length: lines.length,
|
|
@@ -193,6 +193,51 @@ describe('ClaudeStateDetector', () => {
|
|
|
193
193
|
// Assert
|
|
194
194
|
expect(state).toBe('waiting_input'); // waiting_input should take precedence
|
|
195
195
|
});
|
|
196
|
+
it('should detect waiting_input with "Would you like" and multiple numbered options', () => {
|
|
197
|
+
// Arrange
|
|
198
|
+
terminal = createMockTerminal([
|
|
199
|
+
'Some previous output',
|
|
200
|
+
'Would you like to proceed?',
|
|
201
|
+
'',
|
|
202
|
+
'❯ 1. Yes, and auto-accept edits',
|
|
203
|
+
' 2. Yes, and manually approve edits',
|
|
204
|
+
' 3. No, keep planning',
|
|
205
|
+
]);
|
|
206
|
+
// Act
|
|
207
|
+
const state = detector.detectState(terminal, 'idle');
|
|
208
|
+
// Assert
|
|
209
|
+
expect(state).toBe('waiting_input');
|
|
210
|
+
});
|
|
211
|
+
it('should detect waiting_input with complex multi-line prompt and cursor indicator', () => {
|
|
212
|
+
// Arrange
|
|
213
|
+
terminal = createMockTerminal([
|
|
214
|
+
'Processing complete.',
|
|
215
|
+
'Would you like to apply these changes?',
|
|
216
|
+
'',
|
|
217
|
+
'❯ 1. Yes, apply all changes',
|
|
218
|
+
' 2. Yes, review changes first',
|
|
219
|
+
' 3. No, discard changes',
|
|
220
|
+
' 4. Cancel operation',
|
|
221
|
+
]);
|
|
222
|
+
// Act
|
|
223
|
+
const state = detector.detectState(terminal, 'idle');
|
|
224
|
+
// Assert
|
|
225
|
+
expect(state).toBe('waiting_input');
|
|
226
|
+
});
|
|
227
|
+
it('should detect waiting_input when cursor indicator is present without explicit "yes" text', () => {
|
|
228
|
+
// Arrange
|
|
229
|
+
terminal = createMockTerminal([
|
|
230
|
+
'Do you want to proceed?',
|
|
231
|
+
'',
|
|
232
|
+
'❯ 1. Apply all',
|
|
233
|
+
' 2. Review first',
|
|
234
|
+
' 3. Skip',
|
|
235
|
+
]);
|
|
236
|
+
// Act
|
|
237
|
+
const state = detector.detectState(terminal, 'idle');
|
|
238
|
+
// Assert
|
|
239
|
+
expect(state).toBe('waiting_input');
|
|
240
|
+
});
|
|
196
241
|
});
|
|
197
242
|
});
|
|
198
243
|
describe('GeminiStateDetector', () => {
|
|
@@ -546,3 +591,115 @@ describe('GitHubCopilotStateDetector', () => {
|
|
|
546
591
|
expect(state).toBe('idle');
|
|
547
592
|
});
|
|
548
593
|
});
|
|
594
|
+
describe('ClineStateDetector', () => {
|
|
595
|
+
let detector;
|
|
596
|
+
let terminal;
|
|
597
|
+
beforeEach(() => {
|
|
598
|
+
detector = new ClineStateDetector();
|
|
599
|
+
});
|
|
600
|
+
it('should detect waiting_input when "Let Cline use this tool?" is present', () => {
|
|
601
|
+
// Arrange
|
|
602
|
+
terminal = createMockTerminal([
|
|
603
|
+
'┃ [act mode] Let Cline use this tool?',
|
|
604
|
+
'┃ > Yes',
|
|
605
|
+
"┃ Yes, and don't ask again for this task",
|
|
606
|
+
'┃ No, with feedback',
|
|
607
|
+
]);
|
|
608
|
+
// Act
|
|
609
|
+
const state = detector.detectState(terminal, 'idle');
|
|
610
|
+
// Assert
|
|
611
|
+
expect(state).toBe('waiting_input');
|
|
612
|
+
});
|
|
613
|
+
it('should detect waiting_input when "let cline use this tool?" is present (case insensitive)', () => {
|
|
614
|
+
// Arrange
|
|
615
|
+
terminal = createMockTerminal([
|
|
616
|
+
'Some output',
|
|
617
|
+
'LET CLINE USE THIS TOOL?',
|
|
618
|
+
'> Yes',
|
|
619
|
+
]);
|
|
620
|
+
// Act
|
|
621
|
+
const state = detector.detectState(terminal, 'idle');
|
|
622
|
+
// Assert
|
|
623
|
+
expect(state).toBe('waiting_input');
|
|
624
|
+
});
|
|
625
|
+
it('should detect idle when "Cline is ready for your message" is present in act mode', () => {
|
|
626
|
+
// Arrange
|
|
627
|
+
terminal = createMockTerminal([
|
|
628
|
+
'┃ [act mode] Cline is ready for your message...',
|
|
629
|
+
'┃ /plan or /act to switch modes',
|
|
630
|
+
'┃ ctrl+e to open editor',
|
|
631
|
+
]);
|
|
632
|
+
// Act
|
|
633
|
+
const state = detector.detectState(terminal, 'idle');
|
|
634
|
+
// Assert
|
|
635
|
+
expect(state).toBe('idle');
|
|
636
|
+
});
|
|
637
|
+
it('should detect idle when "Cline is ready for your message" is present in plan mode', () => {
|
|
638
|
+
// Arrange
|
|
639
|
+
terminal = createMockTerminal([
|
|
640
|
+
'┃ [plan mode] Cline is ready for your message...',
|
|
641
|
+
'┃ /plan or /act to switch modes',
|
|
642
|
+
'┃ ctrl+e to open editor',
|
|
643
|
+
]);
|
|
644
|
+
// Act
|
|
645
|
+
const state = detector.detectState(terminal, 'idle');
|
|
646
|
+
// Assert
|
|
647
|
+
expect(state).toBe('idle');
|
|
648
|
+
});
|
|
649
|
+
it('should detect idle when "cline is ready" is present (case insensitive)', () => {
|
|
650
|
+
// Arrange
|
|
651
|
+
terminal = createMockTerminal([
|
|
652
|
+
'Some output',
|
|
653
|
+
'CLINE IS READY FOR YOUR MESSAGE',
|
|
654
|
+
'Ready to go',
|
|
655
|
+
]);
|
|
656
|
+
// Act
|
|
657
|
+
const state = detector.detectState(terminal, 'idle');
|
|
658
|
+
// Assert
|
|
659
|
+
expect(state).toBe('idle');
|
|
660
|
+
});
|
|
661
|
+
it('should detect busy when no specific patterns are found', () => {
|
|
662
|
+
// Arrange
|
|
663
|
+
terminal = createMockTerminal([
|
|
664
|
+
'Processing your request...',
|
|
665
|
+
'Running analysis...',
|
|
666
|
+
'Working on it...',
|
|
667
|
+
]);
|
|
668
|
+
// Act
|
|
669
|
+
const state = detector.detectState(terminal, 'idle');
|
|
670
|
+
// Assert
|
|
671
|
+
expect(state).toBe('busy');
|
|
672
|
+
});
|
|
673
|
+
it('should handle empty terminal as busy', () => {
|
|
674
|
+
// Arrange
|
|
675
|
+
terminal = createMockTerminal([]);
|
|
676
|
+
// Act
|
|
677
|
+
const state = detector.detectState(terminal, 'idle');
|
|
678
|
+
// Assert
|
|
679
|
+
expect(state).toBe('busy');
|
|
680
|
+
});
|
|
681
|
+
it('should prioritize waiting_input over idle', () => {
|
|
682
|
+
// Arrange
|
|
683
|
+
terminal = createMockTerminal([
|
|
684
|
+
'┃ [act mode] Cline is ready for your message...',
|
|
685
|
+
'┃ Let Cline use this tool?',
|
|
686
|
+
'┃ > Yes',
|
|
687
|
+
]);
|
|
688
|
+
// Act
|
|
689
|
+
const state = detector.detectState(terminal, 'idle');
|
|
690
|
+
// Assert
|
|
691
|
+
expect(state).toBe('waiting_input'); // waiting_input should take precedence
|
|
692
|
+
});
|
|
693
|
+
it('should prioritize idle over busy', () => {
|
|
694
|
+
// Arrange
|
|
695
|
+
terminal = createMockTerminal([
|
|
696
|
+
'Processing...',
|
|
697
|
+
'Working...',
|
|
698
|
+
'┃ [act mode] Cline is ready for your message...',
|
|
699
|
+
]);
|
|
700
|
+
// Act
|
|
701
|
+
const state = detector.detectState(terminal, 'idle');
|
|
702
|
+
// Assert
|
|
703
|
+
expect(state).toBe('idle'); // idle should take precedence over busy
|
|
704
|
+
});
|
|
705
|
+
});
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type pkg from '@xterm/headless';
|
|
|
3
3
|
import { GitStatus } from '../utils/gitStatus.js';
|
|
4
4
|
export type Terminal = InstanceType<typeof pkg.Terminal>;
|
|
5
5
|
export type SessionState = 'idle' | 'busy' | 'waiting_input';
|
|
6
|
-
export type StateDetectionStrategy = 'claude' | 'gemini' | 'codex' | 'cursor' | 'github-copilot';
|
|
6
|
+
export type StateDetectionStrategy = 'claude' | 'gemini' | 'codex' | 'cursor' | 'github-copilot' | 'cline';
|
|
7
7
|
export interface Worktree {
|
|
8
8
|
path: string;
|
|
9
9
|
branch?: string;
|