返回 DeepSeek-Reasonix
preset.go
根目录 / internal / cli / preset.go
1 package cli
2
3 import (
4 "sync"
5
6 tea "charm.land/bubbletea/v2"
7
8 "reasonix/internal/agentpreset"
9 "reasonix/internal/i18n"
10 )
11
12 // /preset, /work-mode, and /profile remain as hidden compatibility commands.
13 // Recognized legacy values no longer alter the session runtime.
14
15 var presetDeprecationOnce sync.Once
16
17 // noticePresetFolded prints the one-time fold notice per process.
18 func (m *chatTUI) noticePresetFolded() {
19 presetDeprecationOnce.Do(func() {
20 m.notice(i18n.M.WorkModeDeprecatedNotice)
21 })
22 }
23
24 // parseAgentPreset validates a retired role argument and returns the standard
25 // compatibility value for every recognized legacy alias.
26 func parseAgentPreset(value string) (string, bool) {
27 if p, err := agentpreset.Normalize(value); err == nil {
28 return string(p), true
29 }
30 return "", false
31 }
32
33 // runPresetCommand accepts legacy input without changing the controller or
34 // scheduling a turn.
35 func (m *chatTUI) runPresetCommand(input string) tea.Cmd {
36 args := tokenizeArgs(input)
37 if len(args) == 2 {
38 floor, ok := parseAgentPreset(args[1])
39 if !ok {
40 m.notice(i18n.M.WorkModeUsage)
41 return nil
42 }
43 if err := m.ctrl.SetQualityFloor(floor); err != nil {
44 m.notice(err.Error())
45 return nil
46 }
47 m.noticePresetFolded()
48 return nil
49 }
50 if len(args) == 1 {
51 m.notice(i18n.M.WorkModeUsage)
52 return nil
53 }
54 m.noticePresetFolded()
55 return nil
56 }
57
58 // runWorkModeCommand keeps the legacy dispatch name compiling; /work-mode and
59 // /profile delegate to the same handler.
60 func (m *chatTUI) runWorkModeCommand(input string) tea.Cmd {
61 if len(tokenizeArgs(input)) > 2 {
62 m.noticePresetFolded()
63 return nil
64 }
65 return m.runPresetCommand(input)
66 }
67
67 lines GO