@krtclcdy/tersio 2.6.0 → 2.7.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.
- package/README.md +11 -34
- package/cli/doctor.js +5 -1
- package/cli/install.js +115 -12
- package/cli/interactive.js +13 -2
- package/cli/uninstall.js +1 -0
- package/extensions/tersio-commands/index.js +25 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,40 +94,17 @@ Everything runs under one root. Bare `/tersio` prints status.
|
|
|
94
94
|
|
|
95
95
|
| Command | Purpose |
|
|
96
96
|
|---|---|
|
|
97
|
-
| `/tersio combo off\|medium\|balanced\|max\|status` | preset for all three
|
|
98
|
-
| `/tersio caveman lite\|full\|ultra\|wenyan\|off\|status` |
|
|
99
|
-
| `/tersio rtk on\|off\|status` |
|
|
100
|
-
| `/tersio ponytail off\|lite\|full\|ultra\|review\|status` |
|
|
101
|
-
| `/tersio status` |
|
|
102
|
-
| `/tersio check` |
|
|
103
|
-
| `/tersio update <ponytail\|rtk\|caveman\|all> [--dry-run]` |
|
|
104
|
-
| `/tersio gain` |
|
|
105
|
-
| `/tersio usage` |
|
|
106
|
-
| `/tersio help` |
|
|
107
|
-
|
|
108
|
-
### Combo — one preset for all three
|
|
109
|
-
|
|
110
|
-
Start here: one setting drives all three modes (`medium` = lite/lite/on, `balanced` = full/full/on, `max` = ultra/ultra/on, `off` = normal). Tweaking a mode individually drops to a `custom` mix.
|
|
111
|
-
|
|
112
|
-
### Caveman — terse replies
|
|
113
|
-
|
|
114
|
-
Pleasantries and restatements go; substance stays. Ladder: `lite`, `full`, `ultra` (fragments only), `wenyan` (compressed classical-Chinese-inspired register).
|
|
115
|
-
|
|
116
|
-
### RTK — compact shell output
|
|
117
|
-
|
|
118
|
-
A real binary, not a prompt trick: `rtk git status|diff|grep|test|tsc|lint` strips noise before output reaches the model. Exact bytes (checksums, patches) bypass it by policy.
|
|
119
|
-
|
|
120
|
-
### Ponytail — minimal code (YAGNI)
|
|
121
|
-
|
|
122
|
-
You Aren't Gonna Need It: smallest working change, no speculative abstractions, no new deps for stdlib jobs. `lite` nudges, `full` enforces, `ultra` challenges the requirement, `review` audits for over-engineering.
|
|
123
|
-
|
|
124
|
-
`/tersio` persists state and reloads OMP without emitting separate command messages. Presets propagate to task subagents and light the Combo footer indicator; mixed individual settings report via `/tersio status`.
|
|
125
|
-
|
|
126
|
-
### Legacy aliases (still work)
|
|
127
|
-
|
|
128
|
-
The pre-`/tersio` commands remain registered: `/caveman`, `/rtk`, `/combo`, `/ai-addons`. Prefer `/tersio` in new muscle memory; help output lists the aliases as deprecated-but-working.
|
|
129
|
-
|
|
130
|
-
Usage rows land in `~/.omp/plugins/tersio-usage.jsonl` (local only); `tersio dashboard` serves them as a plain-HTML page on 127.0.0.1.
|
|
97
|
+
| `/tersio combo off\|medium\|balanced\|max\|status` | One preset for all three (start here): medium = lite/lite/on, balanced = full/full/on, max = ultra/ultra/on; per-mode tweaks drop to `custom`. |
|
|
98
|
+
| `/tersio caveman lite\|full\|ultra\|wenyan\|off\|status` | Terse replies (substance stays); `ultra` uses fragments only, `wenyan` a compressed classical-Chinese-inspired register. |
|
|
99
|
+
| `/tersio rtk on\|off\|status` | Compact shell output via the real `rtk` binary; exact bytes (checksums, patches) bypass it by policy. |
|
|
100
|
+
| `/tersio ponytail off\|lite\|full\|ultra\|review\|status` | Minimal code (YAGNI): `lite` nudges, `full` enforces, `ultra` challenges the requirement, `review` audits for over-engineering. |
|
|
101
|
+
| `/tersio status` | Active modes + combo level; state persists, propagates to subagents, and lights the Combo footer indicator. |
|
|
102
|
+
| `/tersio check` | Add-on version check |
|
|
103
|
+
| `/tersio update <ponytail\|rtk\|caveman\|all> [--dry-run]` | Update add-ons, preview with dry-run |
|
|
104
|
+
| `/tersio gain` | Savings summary; the gain dashboard charts `~/.omp/plugins/tersio-usage.jsonl` (`tersio dashboard` serves on 127.0.0.1, `--export` writes one file). |
|
|
105
|
+
| `/tersio usage` | Ledger report for this machine (rows in `~/.omp/plugins/tersio-usage.jsonl`, local only) |
|
|
106
|
+
| `/tersio help` | This table |
|
|
107
|
+
| `/caveman`, `/rtk`, `/combo`, `/ai-addons` | Legacy aliases, still work; prefer `/tersio`. |
|
|
131
108
|
|
|
132
109
|
## Files and backups
|
|
133
110
|
|
package/cli/doctor.js
CHANGED
|
@@ -22,6 +22,7 @@ async function runDoctor() {
|
|
|
22
22
|
const rtkIndex = path.join(extDir, 'rtk-session', 'index.js');
|
|
23
23
|
const updaterIndex = path.join(extDir, 'ai-addons-updater', 'index.js');
|
|
24
24
|
const comboIndex = path.join(extDir, 'combo-toggle', 'index.js');
|
|
25
|
+
const tersioIndex = path.join(extDir, 'tersio-commands', 'index.js');
|
|
25
26
|
const modeReinforcement = path.join(extDir, 'shared', 'mode-reinforcement.js');
|
|
26
27
|
const selfPkg = path.join(pluginsDir, 'node_modules', PACKAGE_NAME, 'package.json');
|
|
27
28
|
// Independent probes start concurrently; sections report in fixed order as
|
|
@@ -42,6 +43,7 @@ async function runDoctor() {
|
|
|
42
43
|
rtkIndexText: readTextIfExists(rtkIndex),
|
|
43
44
|
updaterIndexText: readTextIfExists(updaterIndex),
|
|
44
45
|
comboIndexText: readTextIfExists(comboIndex),
|
|
46
|
+
tersioIndexText: readTextIfExists(tersioIndex),
|
|
45
47
|
modeReinforcementText: readTextIfExists(modeReinforcement),
|
|
46
48
|
ruleMtime: fs.stat(cavemanRule).catch(() => null),
|
|
47
49
|
rtkMtime: fs.stat(rtkBin).catch(() => null),
|
|
@@ -60,11 +62,12 @@ async function runDoctor() {
|
|
|
60
62
|
probes.configText,
|
|
61
63
|
probes.updateVersion,
|
|
62
64
|
]));
|
|
63
|
-
const [cavemanIndexText, rtkIndexText, updaterIndexText, comboIndexText, modeReinforcementText, ponytailPkgText, ponytailExtText, pluginsPkgRaw, selfPkgText] = await runInteractivePhase('Checking extensions and plugins', () => Promise.all([
|
|
65
|
+
const [cavemanIndexText, rtkIndexText, updaterIndexText, comboIndexText, tersioIndexText, modeReinforcementText, ponytailPkgText, ponytailExtText, pluginsPkgRaw, selfPkgText] = await runInteractivePhase('Checking extensions and plugins', () => Promise.all([
|
|
64
66
|
probes.cavemanIndexText,
|
|
65
67
|
probes.rtkIndexText,
|
|
66
68
|
probes.updaterIndexText,
|
|
67
69
|
probes.comboIndexText,
|
|
70
|
+
probes.tersioIndexText,
|
|
68
71
|
probes.modeReinforcementText,
|
|
69
72
|
probes.ponytailPkgText,
|
|
70
73
|
probes.ponytailExtText,
|
|
@@ -113,6 +116,7 @@ async function runDoctor() {
|
|
|
113
116
|
check('RTK extension', rtkIndexText !== null);
|
|
114
117
|
check('Updater extension', updaterIndexText !== null);
|
|
115
118
|
check('Combo extension', comboIndexText !== null);
|
|
119
|
+
check('Tersio commands extension', tersioIndexText !== null);
|
|
116
120
|
check('Mode reinforcement extension', modeReinforcementText !== null);
|
|
117
121
|
section('Plugins');
|
|
118
122
|
check('Ponytail package', ponytailPkgText !== null);
|
package/cli/install.js
CHANGED
|
@@ -3,10 +3,13 @@ import { promises as fs } from 'node:fs';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { BUN_BIN_DIR, COMBO_PRESET_MODES, EXTENSIONS_KEY_RE, HOME, IS_WINDOWS, OMP_AGENT_DIR, OMP_PLUGINS_DIR, OMP_BIN, PACKAGE_NAME, PACKAGE_VERSION, RTK_BINARY_NAME, SCOPE_MAP, applyUpdate, cavemanDefaultFlag, comboDefaultFlag, command, dryRun, install, ponytailDefaultFlag, profileFlagsGiven, reinstall, rtkDefaultFlag, scopeFlag, verbose, yes, debug, ensureExtensionAfterConfigEntry, ensureExtensionInConfig, ensurePonytailConfigValue, execP, parseJsonObject, readPluginsPackage, writeIfChanged, } from './common.js';
|
|
7
|
-
import { ask, askInteractiveChoice, closeRL, execNetwork, tty, withInteractiveSpinner, } from './interactive.js';
|
|
8
|
-
import { checkForUpdate } from './update.js';
|
|
6
|
+
import { BUN_BIN_DIR, COMBO_PRESET_MODES, EXTENSIONS_KEY_RE, HOME, IS_WINDOWS, OMP_AGENT_DIR, OMP_PLUGINS_DIR, OMP_BIN, PACKAGE_NAME, PACKAGE_VERSION, RTK_BINARY_NAME, SCOPE_MAP, applyUpdate, cavemanDefaultFlag, comboDefaultFlag, command, dryRun, install, ponytailDefaultFlag, profileFlagsGiven, reinstall, rtkDefaultFlag, scopeFlag, verbose, yes, dashboardExport, dashboardOpen, dashboardPort, debug, ensureExtensionAfterConfigEntry, ensureExtensionInConfig, ensurePonytailConfigValue, execP, parseJsonObject, readPluginsPackage, writeIfChanged, } from './common.js';
|
|
7
|
+
import { ask, askInteractiveChoice, askInteractiveConfirm, closeRL, execNetwork, tty, withInteractiveSpinner, } from './interactive.js';
|
|
8
|
+
import { checkForUpdate, runLatestUpdate } from './update.js';
|
|
9
9
|
import { runUninstall } from './uninstall.js';
|
|
10
|
+
import { runDoctor } from './doctor.js';
|
|
11
|
+
import { runUsage } from './usage.js';
|
|
12
|
+
import { runDashboard } from './dashboard.js';
|
|
10
13
|
import { CAVEMAN_REMOTE_RULE, RTK_RELEASE_API, fetchJson, findFile, httpsGet, httpsDownload, parseChecksum, readTextIfExists, rtkPlatformSpec, sha256File, } from '../extensions/lib/utils.js';
|
|
11
14
|
// Paths to extension source files (relative to this script)
|
|
12
15
|
const EXT_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'extensions');
|
|
@@ -15,6 +18,7 @@ const CAVEMAN_INDEX = path.join(EXT_DIR, 'caveman-session', 'index.js');
|
|
|
15
18
|
const RTK_SESSION_INDEX = path.join(EXT_DIR, 'rtk-session', 'index.js');
|
|
16
19
|
const UPDATER_INDEX = path.join(EXT_DIR, 'ai-addons-updater', 'index.js');
|
|
17
20
|
const COMBO_TOGGLE_INDEX = path.join(EXT_DIR, 'combo-toggle', 'index.js');
|
|
21
|
+
const TERSIO_COMMANDS_INDEX = path.join(EXT_DIR, 'tersio-commands', 'index.js');
|
|
18
22
|
const MODE_REINFORCEMENT_INDEX = path.join(EXT_DIR, 'shared', 'mode-reinforcement.js');
|
|
19
23
|
const SHARED_TYPES = path.join(EXT_DIR, 'shared', 'types.js');
|
|
20
24
|
const LIB_UTILS = path.join(EXT_DIR, 'lib', 'utils.js');
|
|
@@ -22,7 +26,7 @@ const SHARED_PLUGIN_SETTINGS = path.join(EXT_DIR, 'shared', 'plugin-settings.js'
|
|
|
22
26
|
const PONYTAIL_GITHUB_SPEC = 'github:DietrichGebert/ponytail';
|
|
23
27
|
const PONYTAIL_NPM_SPEC = '@dietrichgebert/ponytail@latest';
|
|
24
28
|
async function stepPonytail(pluginsDir, userDir, options) {
|
|
25
|
-
console.log('\n[1/
|
|
29
|
+
console.log('\n[1/8] Installing Ponytail plugin...');
|
|
26
30
|
await fs.mkdir(pluginsDir, { recursive: true });
|
|
27
31
|
const pkgPath = path.join(pluginsDir, 'package.json');
|
|
28
32
|
const pkg = await readPluginsPackage(pkgPath);
|
|
@@ -124,7 +128,7 @@ async function stepPonytail(pluginsDir, userDir, options) {
|
|
|
124
128
|
// Settings → Plugins page (OMP enumerates plugins/package.json dependencies).
|
|
125
129
|
// Returns true when the package is verified in plugins/node_modules.
|
|
126
130
|
async function stepSelfPlugin(pluginsDir, options) {
|
|
127
|
-
console.log('\n[2/
|
|
131
|
+
console.log('\n[2/8] Registering tersio as OMP plugin...');
|
|
128
132
|
const pkgPath = path.join(pluginsDir, 'package.json');
|
|
129
133
|
const pkg = await readPluginsPackage(pkgPath);
|
|
130
134
|
pkg.dependencies[PACKAGE_NAME] = `^${PACKAGE_VERSION}`;
|
|
@@ -253,7 +257,7 @@ async function extractRtkArchive(archivePath, extractDir) {
|
|
|
253
257
|
return false;
|
|
254
258
|
}
|
|
255
259
|
async function stepRtk(binDir, options) {
|
|
256
|
-
console.log('\n[3/
|
|
260
|
+
console.log('\n[3/8] Installing RTK binary...');
|
|
257
261
|
try {
|
|
258
262
|
const release = await withInteractiveSpinner('Finding latest RTK release', () => fetchJson(RTK_RELEASE_API));
|
|
259
263
|
const triple = resolveRtkTriple();
|
|
@@ -342,14 +346,14 @@ async function stepSharedSessionState(extDir, options) {
|
|
|
342
346
|
], 'shared/session-state.js', options);
|
|
343
347
|
}
|
|
344
348
|
async function stepModeReinforcement(extDir, ponytailExtPath, options) {
|
|
345
|
-
console.log('\n[
|
|
349
|
+
console.log('\n[8/8] Installing mode reinforcement extension...');
|
|
346
350
|
const dest = path.join(extDir, 'shared', 'mode-reinforcement.js');
|
|
347
351
|
if (!await copySources(extDir, [[MODE_REINFORCEMENT_INDEX, path.join('shared', 'mode-reinforcement.js')]], 'shared/mode-reinforcement.js', options))
|
|
348
352
|
return;
|
|
349
353
|
await ensureExtensionAfterConfigEntry(path.join(path.dirname(extDir), 'config.yml'), dest, ponytailExtPath, 'mode reinforcement', options);
|
|
350
354
|
}
|
|
351
355
|
async function stepRtkSession(extDir, options) {
|
|
352
|
-
console.log('\n[4/
|
|
356
|
+
console.log('\n[4/8] Installing RTK session extension...');
|
|
353
357
|
await copySources(extDir, [[RTK_SESSION_INDEX, path.join('rtk-session', 'index.js')]], 'rtk-session/index.js', options);
|
|
354
358
|
}
|
|
355
359
|
// One rule fetch serves user- and project-level installs; dry runs stay offline
|
|
@@ -366,7 +370,7 @@ async function fetchCavemanRule(options) {
|
|
|
366
370
|
}
|
|
367
371
|
}
|
|
368
372
|
async function stepCaveman(extDir, rule, options) {
|
|
369
|
-
console.log('\n[5/
|
|
373
|
+
console.log('\n[5/8] Installing Caveman session extension...');
|
|
370
374
|
const cavemanDir = path.join(extDir, 'caveman-session');
|
|
371
375
|
if (!options.dryRun)
|
|
372
376
|
await fs.mkdir(cavemanDir, { recursive: true });
|
|
@@ -383,11 +387,15 @@ async function stepCaveman(extDir, rule, options) {
|
|
|
383
387
|
}
|
|
384
388
|
await copySources(extDir, [[CAVEMAN_INDEX, path.join('caveman-session', 'index.js')]], 'caveman-session/index.js', options);
|
|
385
389
|
}
|
|
390
|
+
async function stepTersioCommands(extDir, options) {
|
|
391
|
+
console.log('\n[7/8] Installing Tersio root-command extension...');
|
|
392
|
+
await copySources(extDir, [[TERSIO_COMMANDS_INDEX, path.join('tersio-commands', 'index.js')]], 'tersio-commands/index.js', options);
|
|
393
|
+
}
|
|
386
394
|
async function stepUpdater(extDir, options) {
|
|
387
395
|
await copySources(extDir, [[UPDATER_INDEX, path.join('ai-addons-updater', 'index.js')]], 'ai-addons-updater/index.js', options);
|
|
388
396
|
}
|
|
389
397
|
async function stepCombo(extDir, options) {
|
|
390
|
-
console.log('\n[6/
|
|
398
|
+
console.log('\n[6/8] Installing Combo toggle extension...');
|
|
391
399
|
const dest = path.join(extDir, 'combo-toggle', 'index.js');
|
|
392
400
|
if (!await copySources(extDir, [[COMBO_TOGGLE_INDEX, path.join('combo-toggle', 'index.js')]], 'combo-toggle/index.js', options))
|
|
393
401
|
return;
|
|
@@ -536,7 +544,81 @@ async function writePluginSettings(profile, options) {
|
|
|
536
544
|
await fs.writeFile(lockPath, JSON.stringify(config, null, 2) + '\n', 'utf8');
|
|
537
545
|
console.log(` [write] Plugin settings in ${lockPath}`);
|
|
538
546
|
}
|
|
547
|
+
let updatePromptDone = false;
|
|
548
|
+
// Bare `tersio` at a terminal is a command picker, not an install run:
|
|
549
|
+
// update offer first (when pending), then a Clack menu over every command.
|
|
550
|
+
// Scripts, pipes, --yes, and --dry-run keep the old straight-to-install path.
|
|
551
|
+
async function runCommandMenu() {
|
|
552
|
+
const newer = await checkForUpdate();
|
|
553
|
+
if (newer && !dryRun) {
|
|
554
|
+
const answer = await askInteractiveConfirm(`tersio ${newer} is available (installed ${PACKAGE_VERSION}). Install it now?`);
|
|
555
|
+
if (answer.status === 'confirmed' && answer.value) {
|
|
556
|
+
await runLatestUpdate();
|
|
557
|
+
closeRL();
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
if (answer.status === 'cancelled') {
|
|
561
|
+
closeRL();
|
|
562
|
+
process.exit(130);
|
|
563
|
+
}
|
|
564
|
+
console.log(`\n [update] staying on ${PACKAGE_VERSION} — run ` + '`tersio update`' + ` anytime`);
|
|
565
|
+
}
|
|
566
|
+
updatePromptDone = true;
|
|
567
|
+
const choice = await askInteractiveChoice('Tersio — what next?', [
|
|
568
|
+
{ value: 'install', label: 'Install add-ons', hint: 'user/project scope + combo defaults' },
|
|
569
|
+
{ value: 'check', label: 'Check for updates', hint: 'compare installed vs latest release' },
|
|
570
|
+
{ value: 'update', label: 'Update everything', hint: 'CLI plus all ai-addons' },
|
|
571
|
+
{ value: 'doctor', label: 'Doctor', hint: 'verify the installation' },
|
|
572
|
+
{ value: 'usage', label: 'Usage', hint: 'token usage and savings report' },
|
|
573
|
+
{ value: 'gain', label: 'Gain dashboard', hint: 'open the report in your browser' },
|
|
574
|
+
{ value: 'dashboard', label: 'Serve dashboard', hint: 'localhost server, no browser' },
|
|
575
|
+
{ value: 'uninstall', label: 'Uninstall', hint: 'remove tersio' },
|
|
576
|
+
], 'install');
|
|
577
|
+
if (choice.status !== 'selected') {
|
|
578
|
+
closeRL();
|
|
579
|
+
process.exit(130);
|
|
580
|
+
}
|
|
581
|
+
switch (choice.value) {
|
|
582
|
+
case 'install':
|
|
583
|
+
await runInstall();
|
|
584
|
+
break;
|
|
585
|
+
case 'check': {
|
|
586
|
+
const latest = await checkForUpdate();
|
|
587
|
+
console.log(latest ? ` [update] tersio ${latest} available (installed ${PACKAGE_VERSION})` : ` [ok] tersio ${PACKAGE_VERSION} is the latest`);
|
|
588
|
+
closeRL();
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
case 'update':
|
|
592
|
+
await runLatestUpdate();
|
|
593
|
+
closeRL();
|
|
594
|
+
break;
|
|
595
|
+
case 'doctor':
|
|
596
|
+
await runDoctor();
|
|
597
|
+
closeRL();
|
|
598
|
+
break;
|
|
599
|
+
case 'usage':
|
|
600
|
+
await runUsage();
|
|
601
|
+
closeRL();
|
|
602
|
+
break;
|
|
603
|
+
case 'gain':
|
|
604
|
+
await runDashboard({ port: dashboardPort, open: true, exportFile: null });
|
|
605
|
+
closeRL();
|
|
606
|
+
break;
|
|
607
|
+
case 'dashboard':
|
|
608
|
+
await runDashboard({ port: dashboardPort, open: dashboardOpen, exportFile: dashboardExport });
|
|
609
|
+
closeRL();
|
|
610
|
+
break;
|
|
611
|
+
case 'uninstall':
|
|
612
|
+
await runUninstall();
|
|
613
|
+
closeRL();
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
539
617
|
async function runInstall() {
|
|
618
|
+
if (command === null && tty() && !yes) {
|
|
619
|
+
await runCommandMenu();
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
540
622
|
if (reinstall) {
|
|
541
623
|
await runUninstall({ yes: true, removePonytail: false, removeRtk: true });
|
|
542
624
|
}
|
|
@@ -550,8 +632,27 @@ async function runInstall() {
|
|
|
550
632
|
// the apply-update payload, which is itself an update run.
|
|
551
633
|
if (tty() && !applyUpdate && command !== 'uninstall') {
|
|
552
634
|
const newer = await checkForUpdate();
|
|
553
|
-
if (newer)
|
|
554
|
-
|
|
635
|
+
if (newer) {
|
|
636
|
+
// Bare `tersio` with an update pending: offer it now (Y/n) instead of
|
|
637
|
+
// burying the banner above the install prompts. Yes runs the full
|
|
638
|
+
// update and stops here — the fresh binary owns what follows.
|
|
639
|
+
if (command === null && !dryRun && !yes && !updatePromptDone) {
|
|
640
|
+
const answer = await askInteractiveConfirm(`tersio ${newer} is available (installed ${PACKAGE_VERSION}). Install it now?`);
|
|
641
|
+
if (answer.status === 'confirmed' && answer.value) {
|
|
642
|
+
await runLatestUpdate();
|
|
643
|
+
closeRL();
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
if (answer.status === 'cancelled') {
|
|
647
|
+
closeRL();
|
|
648
|
+
process.exit(130);
|
|
649
|
+
}
|
|
650
|
+
console.log(`\n [update] staying on ${PACKAGE_VERSION} — run \`tersio update\` anytime`);
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
console.log(`\n [update] tersio ${newer} available (installed ${PACKAGE_VERSION}) — run \`tersio update\``);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
555
656
|
}
|
|
556
657
|
const scope = await resolveScope();
|
|
557
658
|
// Resolve session defaults: flags > interactive prompt > defaults.
|
|
@@ -583,6 +684,7 @@ async function runInstall() {
|
|
|
583
684
|
await stepRtkSession(userExtDir, options);
|
|
584
685
|
await stepCaveman(userExtDir, cavemanRule, options);
|
|
585
686
|
await stepCombo(userExtDir, options);
|
|
687
|
+
await stepTersioCommands(userExtDir, options);
|
|
586
688
|
await stepModeReinforcement(userExtDir, ponytailExtPath, options);
|
|
587
689
|
await stepUpdater(userExtDir, options);
|
|
588
690
|
if (selfPlugin)
|
|
@@ -594,6 +696,7 @@ async function runInstall() {
|
|
|
594
696
|
await stepSharedSessionState(projectExtDir, options);
|
|
595
697
|
await stepRtkSession(projectExtDir, options);
|
|
596
698
|
await stepCaveman(projectExtDir, cavemanRule, options);
|
|
699
|
+
await stepTersioCommands(projectExtDir, options);
|
|
597
700
|
await stepUpdater(projectExtDir, options);
|
|
598
701
|
console.log(' [note] Ponytail, RTK binary, and Combo toggle require user-level (global) install');
|
|
599
702
|
}
|
package/cli/interactive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// cli/interactive.ts — TTY layer: readline, Clack spinners, selects, task phases.
|
|
2
2
|
import readline from 'node:readline';
|
|
3
|
-
import { cancel as clackCancel, select as clackSelect, spinner as clackSpinner, tasks as clackTasks } from '@clack/prompts';
|
|
3
|
+
import { cancel as clackCancel, confirm as clackConfirm, select as clackSelect, spinner as clackSpinner, tasks as clackTasks } from '@clack/prompts';
|
|
4
4
|
import { execP } from './common.js';
|
|
5
5
|
const RL = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
6
6
|
let rlOpen = true;
|
|
@@ -56,6 +56,17 @@ async function askInteractiveChoice(message, options, initialValue) {
|
|
|
56
56
|
}
|
|
57
57
|
return { status: 'selected', value: choice };
|
|
58
58
|
}
|
|
59
|
+
async function askInteractiveConfirm(message, initialValue = true) {
|
|
60
|
+
if (!tty())
|
|
61
|
+
return { status: 'unavailable' };
|
|
62
|
+
closeRL();
|
|
63
|
+
const answer = await clackConfirm({ message, initialValue });
|
|
64
|
+
if (typeof answer !== 'boolean') {
|
|
65
|
+
clackCancel('Aborted.');
|
|
66
|
+
return { status: 'cancelled' };
|
|
67
|
+
}
|
|
68
|
+
return { status: 'confirmed', value: answer };
|
|
69
|
+
}
|
|
59
70
|
// Run collecting work under one TTY-only Clack task. Callers print after the
|
|
60
71
|
// task completes, keeping normal output out of the spinner animation.
|
|
61
72
|
async function runInteractivePhase(title, collect) {
|
|
@@ -69,4 +80,4 @@ async function runInteractivePhase(title, collect) {
|
|
|
69
80
|
async function execNetwork(label, cmd, args, opts = {}) {
|
|
70
81
|
return withInteractiveSpinner(label, () => execP(cmd, args, opts));
|
|
71
82
|
}
|
|
72
|
-
export { ask, closeRL, tty, withInteractiveSpinner, execNetwork, askInteractiveChoice, runInteractivePhase, };
|
|
83
|
+
export { ask, closeRL, tty, withInteractiveSpinner, execNetwork, askInteractiveChoice, askInteractiveConfirm, runInteractivePhase, };
|
package/cli/uninstall.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
// sibling extensions restore from, then reloads so their local mirrors sync
|
|
5
5
|
// (same mechanism /combo already uses to drive its siblings).
|
|
6
6
|
import { COMBO_LEVELS, activeModesSummary, getSharedComboState, normalizeComboLevel, normalizeMode, reconcileSharedComboEntries, sessionEntries, setSharedComboLevel, setSharedComboMode, } from '../shared/session-state.js';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import path from 'node:path';
|
|
7
9
|
import { appendUsage, readUsage } from '../shared/usage-ledger.js';
|
|
8
10
|
import { checkAddonsSummary, runAddonUpdate } from '../ai-addons-updater/index.js';
|
|
9
11
|
const HELP = [
|
|
@@ -35,6 +37,23 @@ function usageSummary() {
|
|
|
35
37
|
const last = new Date(rows[rows.length - 1].ts).toISOString();
|
|
36
38
|
return `tersio usage: ${rows.length} rows (${parts.join(', ')}), last write ${last}.`;
|
|
37
39
|
}
|
|
40
|
+
// Gain opens instantaneously in the default browser: export a file://-ready
|
|
41
|
+
// snapshot (data inlined, no server to babysit) and open it. Falls back to
|
|
42
|
+
// the shell command when export or open fails.
|
|
43
|
+
async function openGainDashboard(pi, ctx) {
|
|
44
|
+
const file = path.join(os.tmpdir(), `tersio-gain-${Date.now()}.html`);
|
|
45
|
+
try {
|
|
46
|
+
const exported = await pi.exec?.('tersio', ['dashboard', '--export', file], { cwd: ctx?.cwd });
|
|
47
|
+
if (!exported || exported.code !== 0)
|
|
48
|
+
throw new Error((exported?.stderr || 'export failed').trim());
|
|
49
|
+
const openCmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
50
|
+
await pi.exec?.(openCmd, [file], { cwd: ctx?.cwd });
|
|
51
|
+
ctx?.ui?.notify?.(`tersio gain: dashboard opened in your browser.`, 'info');
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
ctx?.ui?.notify?.(`tersio gain: could not open dashboard (${e.message}). Run 'tersio dashboard --open' in a shell.`, 'warning');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
38
57
|
export default function tersioCommandsExtension(pi) {
|
|
39
58
|
pi.setLabel?.('Tersio unified root command');
|
|
40
59
|
async function reload(ctx) {
|
|
@@ -138,8 +157,12 @@ export default function tersioCommandsExtension(pi) {
|
|
|
138
157
|
await runAddonUpdate(pi, ctx, target, dryRun);
|
|
139
158
|
return;
|
|
140
159
|
}
|
|
141
|
-
if (sub === 'gain'
|
|
142
|
-
|
|
160
|
+
if (sub === 'gain') {
|
|
161
|
+
await openGainDashboard(pi, ctx);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (sub === 'usage') {
|
|
165
|
+
ctx?.ui?.notify?.(usageSummary(), 'info');
|
|
143
166
|
return;
|
|
144
167
|
}
|
|
145
168
|
ctx?.ui?.notify?.(`Unknown subcommand: ${sub}.\n${HELP}`, 'warning');
|
package/package.json
CHANGED