opencode-onboard 0.2.7 → 0.2.12

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.
@@ -0,0 +1,59 @@
1
+ import { checkbox } from '@inquirer/prompts'
2
+ import { header, info, loading, success, warn } from '../utils/exec.js'
3
+ import { checkRtk } from './check-rtk.js'
4
+ import { installQuota } from './install-quota.js'
5
+ import { installCaveman } from './install-caveman.js'
6
+ import { enableCavemanGuidance } from './enable-caveman-guidance.js'
7
+
8
+ export async function tokenOptimizationStep(options = {}) {
9
+ header('Step 10, Token optimization tools')
10
+
11
+ const defaultSelected = ['rtk', 'quota', 'caveman']
12
+ let selected = defaultSelected
13
+
14
+ if (!options.skipPrompt && process.stdin.isTTY) {
15
+ info('Choose which optimization tools to enable (recommended: all).')
16
+ const timeoutMs = 30000
17
+ const choice = await Promise.race([
18
+ checkbox({
19
+ message: 'Enable tools:',
20
+ choices: [
21
+ { name: 'RTK check (recommended)', value: 'rtk', checked: true },
22
+ { name: 'opencode-quota plugin (recommended)', value: 'quota', checked: true },
23
+ { name: 'caveman concise mode (recommended)', value: 'caveman', checked: true },
24
+ ],
25
+ }),
26
+ new Promise(resolve => setTimeout(() => resolve(defaultSelected), timeoutMs)),
27
+ ])
28
+ selected = Array.isArray(choice) ? choice : defaultSelected
29
+ }
30
+
31
+ loading('applying token optimization selections...')
32
+
33
+ const has = value => selected.includes(value)
34
+
35
+ const rtk = has('rtk')
36
+ ? await checkRtk({ skipHeader: true, skipPrompt: true })
37
+ : { optedIn: false, checked: false, available: false }
38
+
39
+ const quota = has('quota')
40
+ ? await installQuota({ skipHeader: true, skipPrompt: true })
41
+ : { optedIn: false, installed: false }
42
+
43
+ const caveman = has('caveman')
44
+ ? await installCaveman({
45
+ skipHeader: true,
46
+ skipPrompt: true,
47
+ skillsProvider: options.skillsProvider,
48
+ })
49
+ : { optedIn: false, installed: false }
50
+
51
+ const cavemanGuidance = has('caveman')
52
+ ? await enableCavemanGuidance(caveman)
53
+ : { enabled: false }
54
+
55
+ if (selected.length === 0) warn('No token optimization tools selected')
56
+ else success('Token optimization step completed')
57
+
58
+ return { rtk, quota, caveman, cavemanGuidance }
59
+ }
@@ -44,6 +44,8 @@ export async function writeOnboardConfig(data) {
44
44
  build: data.buildModel,
45
45
  fast: data.fastModel,
46
46
  },
47
+ optionalTools: data.optionalTools ?? null,
48
+ cavemanGuidance: data.cavemanGuidance ?? null,
47
49
  },
48
50
  note: 'Informational file only. Editing this file does not change runtime behavior.',
49
51
  }
package/src/utils/exec.js CHANGED
@@ -12,12 +12,17 @@ function appendLine(line) {
12
12
  currentStepLines.push(line)
13
13
  }
14
14
 
15
- function stopSpinner() {
15
+ function stopSpinner() {
16
16
  if (stepSpinner) {
17
17
  stepSpinner.stop()
18
18
  stepSpinner = null
19
19
  }
20
- }
20
+ }
21
+
22
+ function startSpinner(text = 'working...') {
23
+ stopSpinner()
24
+ stepSpinner = ora({ text: chalk.dim(text), color: 'red' }).start()
25
+ }
21
26
 
22
27
  function redraw() {
23
28
  if (process.stdout.isTTY) console.clear()
@@ -88,11 +93,18 @@ export function header(text) {
88
93
  appendLine(line2)
89
94
  appendLine(line3)
90
95
 
91
- redraw()
92
-
93
- // Start a spinner while the step is working
94
- stepSpinner = ora({ text: chalk.dim('working...'), color: 'red' }).start()
95
- }
96
+ redraw()
97
+
98
+ // Start a spinner while the step is working
99
+ startSpinner('working...')
100
+ }
101
+
102
+ /**
103
+ * Restart the step spinner after prompts or logs.
104
+ */
105
+ export function loading(text = 'working...') {
106
+ startSpinner(text)
107
+ }
96
108
 
97
109
  /**
98
110
  * Print a success line.