@krtclcdy/tersio 2.25.4 → 2.25.6
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 +27 -63
- package/dashboard/dist/index.html +18 -16
- package/dist/cli/backups.js +187 -0
- package/dist/cli/banner.js +4 -3
- package/dist/cli/common.js +29 -13
- package/dist/cli/currency.js +1 -1
- package/dist/cli/dashboard.js +168 -110
- package/dist/cli/doctor-fix.js +232 -50
- package/dist/cli/doctor.js +281 -32
- package/dist/cli/hosts.js +29 -9
- package/dist/cli/install.js +204 -69
- package/dist/cli/interactive.js +3 -3
- package/dist/cli/manifest.js +125 -17
- package/dist/cli/profile.js +14 -9
- package/dist/cli/rtk-wiring.js +1 -1
- package/dist/cli/settings.js +20 -5
- package/dist/cli/uninstall.js +24 -8
- package/dist/cli/update.js +9 -10
- package/dist/cli/usage.js +75 -7
- package/dist/extensions/{caveman-session → caveman}/index.js +4 -2
- package/{extensions/caveman-session → dist/extensions/caveman}/rule-megacave.md +5 -3
- package/{extensions/caveman-session → dist/extensions/caveman}/rule-ultra.md +4 -4
- package/dist/extensions/caveman/rule.md +89 -0
- package/dist/extensions/{combo-toggle → combo}/index.js +62 -21
- package/dist/extensions/{tersio-commands → commands}/index.js +2 -2
- package/dist/extensions/pstack/index.js +119 -0
- package/dist/extensions/pstack/rule.md +65 -0
- package/dist/extensions/{rtk-filter/index.js → rtk/filter.js} +1 -2
- package/dist/extensions/{rtk-session/index.js → rtk/session.js} +5 -5
- package/dist/extensions/{opencode/server.js → server.js} +98 -14
- package/dist/extensions/shared/agent-stats.js +1198 -0
- package/dist/extensions/shared/brand-marks.js +153 -0
- package/dist/extensions/shared/carbon.js +1 -1
- package/dist/extensions/shared/plugin-settings.js +12 -7
- package/dist/extensions/shared/pricing.js +86 -30
- package/dist/extensions/shared/rtk-gain.js +4 -9
- package/dist/extensions/shared/session-state.js +15 -10
- package/dist/extensions/shared/sqlite.js +168 -0
- package/dist/extensions/shared/status.js +8 -8
- package/dist/extensions/shared/types.js +1 -1
- package/dist/extensions/shared/usage-ledger.js +113 -39
- package/dist/extensions/shared/usage-store.js +191 -48
- package/dist/extensions/{lib → shared}/utils.js +6 -6
- package/dist/extensions/timing/index.js +31 -0
- package/dist/extensions/{ai-addons-updater → updater}/index.js +13 -6
- package/dist/probe-catalog.js +48 -0
- package/dist/probe-catalog188.js +44 -0
- package/dist/tersio.js +9 -4
- package/extensions/{caveman-session → caveman}/index.ts +4 -2
- package/{dist/extensions/caveman-session → extensions/caveman}/rule-megacave.md +5 -3
- package/{dist/extensions/caveman-session → extensions/caveman}/rule-ultra.md +4 -4
- package/extensions/caveman/rule.md +89 -0
- package/extensions/{combo-toggle → combo}/index.ts +62 -19
- package/extensions/{tersio-commands → commands}/index.ts +2 -2
- package/extensions/pstack/index.ts +128 -0
- package/extensions/pstack/rule.md +65 -0
- package/extensions/{rtk-filter/index.ts → rtk/filter.ts} +1 -2
- package/extensions/{rtk-session/index.ts → rtk/session.ts} +5 -5
- package/extensions/{opencode/server.ts → server.ts} +81 -16
- package/extensions/shared/agent-stats.ts +1605 -0
- package/extensions/shared/brand-marks.ts +163 -0
- package/extensions/shared/carbon.ts +1 -1
- package/extensions/shared/plugin-settings.ts +13 -7
- package/extensions/shared/pricing.ts +95 -32
- package/extensions/shared/rtk-gain.ts +4 -9
- package/extensions/shared/session-state.ts +18 -13
- package/extensions/shared/sqlite.ts +168 -0
- package/extensions/shared/status.ts +9 -8
- package/extensions/shared/types.ts +2 -1
- package/extensions/shared/usage-ledger.ts +134 -46
- package/extensions/shared/usage-store.ts +202 -50
- package/extensions/{lib → shared}/utils.ts +6 -6
- package/extensions/timing/index.ts +45 -0
- package/extensions/{ai-addons-updater → updater}/index.ts +15 -9
- package/package.json +27 -18
- package/dist/extensions/caveman-session/rule.md +0 -79
- package/extensions/caveman-session/rule.md +0 -79
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Throwaway: the current omp catalog's real rates for the fifteen models in the screenshot.
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
const root = process.env.HOME + "/.bun/install/global/node_modules/@oh-my-pi/pi-catalog/src";
|
|
4
|
+
const catalog = JSON.parse(readFileSync(root + "/models.json", "utf8"));
|
|
5
|
+
const wanted = [
|
|
6
|
+
"space-bunny",
|
|
7
|
+
"muse-spark-1.3-contributor",
|
|
8
|
+
"glm-5.3-flash",
|
|
9
|
+
"qwen38-flash-next",
|
|
10
|
+
"muse-spark-1.2-contributor",
|
|
11
|
+
"qwen3.8-27b",
|
|
12
|
+
"m3",
|
|
13
|
+
"ox-alpha",
|
|
14
|
+
"deepseek-v4-flash",
|
|
15
|
+
"ling-3.0-flash-sante",
|
|
16
|
+
"qwen3.6-35b-a3b-fp8",
|
|
17
|
+
"mimo-v2.6-flash",
|
|
18
|
+
"deepseek-v4.1-flash",
|
|
19
|
+
"step-5-preview",
|
|
20
|
+
"ling-3.1-flash",
|
|
21
|
+
"longcat-2.5-preview",
|
|
22
|
+
];
|
|
23
|
+
const hits = new Map();
|
|
24
|
+
for (const [provider, models] of Object.entries(catalog)) {
|
|
25
|
+
if (!models || typeof models !== "object")
|
|
26
|
+
continue;
|
|
27
|
+
for (const [id, row] of Object.entries(models)) {
|
|
28
|
+
const bare = id.toLowerCase().split("/").pop();
|
|
29
|
+
if (!wanted.includes(bare))
|
|
30
|
+
continue;
|
|
31
|
+
const list = hits.get(bare) ?? [];
|
|
32
|
+
list.push({ key: provider + "/" + id, cost: row.cost, status: row.pricingStatus });
|
|
33
|
+
hits.set(bare, list);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const w of wanted) {
|
|
37
|
+
const list = hits.get(w) ?? [];
|
|
38
|
+
console.log("\n" + w.toUpperCase() + (list.length === 0 ? " -- NOT IN CATALOG --" : " -- " + list.length + " rows --"));
|
|
39
|
+
for (const h of list) {
|
|
40
|
+
const c = h.cost;
|
|
41
|
+
const zero = c && c.input === 0 && c.output === 0 && c.cacheRead === 0 && c.cacheWrite === 0;
|
|
42
|
+
console.log(" " + h.key.padEnd(50) + (zero ? "FREE ($0)" : "in=" + c?.input + " out=" + c?.output) + " status=" + JSON.stringify(h.status));
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/tersio.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Install Tersio add-ons on any OMP device; see help for commands.
|
|
3
|
-
import { PACKAGE_BIN, PACKAGE_VERSION, applyUpdate, commandArg, dashboard, dashboardExport, dashboardOpen, dashboardPort, doctor, reset, settings, showHelp, showVersion, uninstall, unknownCommand, update, usage, } from './cli/common.js';
|
|
3
|
+
import { PACKAGE_BIN, PACKAGE_VERSION, applyUpdate, commandArg, dashboard, dashboardExport, dashboardOpen, dashboardPort, doctor, reinstall, reset, settings, showHelp, showVersion, uninstall, unknownCommand, update, usage, currency, } from './cli/common.js';
|
|
4
4
|
import { closeRL } from './cli/interactive.js';
|
|
5
|
-
import { runInstall } from './cli/install.js';
|
|
5
|
+
import { runInstall, runReinstall } from './cli/install.js';
|
|
6
6
|
import { runDoctor } from './cli/doctor.js';
|
|
7
7
|
import { runLatestUpdate } from './cli/update.js';
|
|
8
8
|
import { runUninstall } from './cli/uninstall.js';
|
|
@@ -15,6 +15,7 @@ function printHelp() {
|
|
|
15
15
|
|
|
16
16
|
Commands:
|
|
17
17
|
install Install the add-ons for one agent (--host omp|pi|opencode, or ask at a terminal)
|
|
18
|
+
reinstall Refresh one agent's install: pick it, reinstall, then verify (--host picks without asking)
|
|
18
19
|
update Refresh the CLI and add-ons (RTK binary, Caveman rule, Ponytail; --host limits to one agent)
|
|
19
20
|
doctor Check the current installation (--fix repairs, --dry-run previews)
|
|
20
21
|
usage Ledger-backed usage + savings report
|
|
@@ -26,7 +27,7 @@ Commands:
|
|
|
26
27
|
help Show this help
|
|
27
28
|
|
|
28
29
|
Options:
|
|
29
|
-
--fix (doctor: repairs all; --fix=<scope> repairs one of extensions, registrations, rtk, ponytail, cli)
|
|
30
|
+
--fix (doctor: repairs all; --fix=<scope> repairs one of extensions, registrations, rtk, ponytail, cli, service)
|
|
30
31
|
--scope user (legacy; accepted and ignored — user scope is the only scope)
|
|
31
32
|
--host omp|pi|opencode (install|uninstall|update: target agent; a terminal asks instead)
|
|
32
33
|
--keep-ponytail (uninstall: keep the bundled Ponytail copy — removed by default)
|
|
@@ -79,7 +80,7 @@ async function main() {
|
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
82
|
if (dashboard) {
|
|
82
|
-
await runDashboard({ port: dashboardPort, open: dashboardOpen, exportFile: dashboardExport });
|
|
83
|
+
await runDashboard({ port: dashboardPort, open: dashboardOpen, exportFile: dashboardExport, currency });
|
|
83
84
|
closeRL();
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
@@ -97,6 +98,10 @@ async function main() {
|
|
|
97
98
|
closeRL();
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
101
|
+
if (reinstall) {
|
|
102
|
+
await runReinstall();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
100
105
|
await runInstall();
|
|
101
106
|
}
|
|
102
107
|
main().catch((e) => { closeRL(); console.error(e); process.exitCode = 1; });
|
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
3
3
|
import { getSharedComboState, hasModeState, isOmpSubagentPrompt, lastCustomValue, normalizeInputCommand, normalizeMode, reconcileSharedComboEntries, sessionEntries, setSharedComboListener, setSharedComboMode, systemPromptIncludes } from '../shared/session-state.ts';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
import { injectPromptText, onHostEvent, setExtensionLabel } from '../shared/host.ts';
|
|
6
|
-
import { announceStatus } from '../shared/status.ts';
|
|
6
|
+
import { announceStatus, formatCavemanStatus } from '../shared/status.ts';
|
|
7
7
|
import { readCavemanDefault } from '../shared/plugin-settings.ts';
|
|
8
8
|
import type { ExtensionApi, ExtensionCtx, InputEvent, SessionEntry, SystemPromptEvent } from '../shared/types.ts';
|
|
9
9
|
|
|
@@ -71,6 +71,8 @@ export default function cavemanSessionExtension(pi: ExtensionApi): void {
|
|
|
71
71
|
}
|
|
72
72
|
if (arg === 'status') {
|
|
73
73
|
announceStatus(ctx);
|
|
74
|
+
// The footer carries one line, so the mode is answered here instead of standing as a second status key.
|
|
75
|
+
ctx?.ui?.notify?.(formatCavemanStatus(currentMode), 'info');
|
|
74
76
|
return;
|
|
75
77
|
}
|
|
76
78
|
if (!setMode(arg, ctx)) {
|
|
@@ -88,7 +90,7 @@ export default function cavemanSessionExtension(pi: ExtensionApi): void {
|
|
|
88
90
|
const entries = sessionEntries(ctx);
|
|
89
91
|
// A subagent's branch has no Tersio entries; reconciling it would wipe shared state.
|
|
90
92
|
if (hasModeState(entries)) reconcileSharedComboEntries(entries);
|
|
91
|
-
// Persisted state wins, then a mode already chosen
|
|
93
|
+
// Persisted state wins, then a mode already chosen, then the default. `off` is the start value, not unset.
|
|
92
94
|
const persisted = resolveMode(entries, '');
|
|
93
95
|
const alreadyChosen = currentMode !== DEFAULT_MODE;
|
|
94
96
|
currentMode = persisted || (alreadyChosen ? currentMode : normalizeMode('caveman', readCavemanDefault())) || DEFAULT_MODE;
|
|
@@ -15,11 +15,11 @@ Megacave is caveman in Classical Chinese. 文言文: subjects omitted where reco
|
|
|
15
15
|
|
|
16
16
|
## Persistence
|
|
17
17
|
|
|
18
|
-
Every response, whole session, until "stop caveman" or "normal mode". Unsure? Still on. `/caveman status` reports the mode and changes nothing: relay the hook's `Caveman mode: <mode>` value or
|
|
18
|
+
Every response, whole session, until "stop caveman" or "normal mode". Unsure? Still on. `/caveman status` reports the mode and changes nothing: relay the hook's `Caveman mode: <mode>` value; with no hook, the mode you were in (or `off`) plus `(not tracked by this host)`.
|
|
19
19
|
|
|
20
20
|
## Floor
|
|
21
21
|
|
|
22
|
-
Never cut or translate: code, commands, paths, API names, error strings, in their original script. Negation (不, 非, 勿, 未, 毋). Numbers and units, Arabic numerals. One term per thing. A clause ambiguous in 文言 becomes 白話.
|
|
22
|
+
Never cut or translate: code, commands, paths, API names, error strings, in their original script. Negation (不, 非, 勿, 未, 毋). Numbers and units, Arabic numerals. One term per thing. A clause ambiguous in 文言 becomes 白話. Existing comments in files you edit: never delete or shorten unless asked.
|
|
23
23
|
|
|
24
24
|
## Rules
|
|
25
25
|
|
|
@@ -39,6 +39,8 @@ Good: "池蓄已開之連,不逐請而新開,省握手之費。"
|
|
|
39
39
|
|
|
40
40
|
### 3. Each fact once
|
|
41
41
|
|
|
42
|
+
Code change: changed lines plus context, not the whole file.
|
|
43
|
+
|
|
42
44
|
Good: "新參照則重繪。`useMemo` 包之。"
|
|
43
45
|
|
|
44
46
|
### 4. Payload in original script
|
|
@@ -56,7 +58,7 @@ No "文言模式啟", no modern answer plus classical copy. 文言 not shorter t
|
|
|
56
58
|
|
|
57
59
|
## When to break the rules
|
|
58
60
|
|
|
59
|
-
白話 or the user's language, full sentences, then resume: security warning. Irreversible action, confirm first. Any clause with two readings. User confused. Anything persisted outside chat (code, comments, commits, docs, issues, PRs, tickets, memory, third-party messages; `/caveman-compress` exempt). Harness asks for a status line.
|
|
61
|
+
白話 or the user's language, full sentences, then resume: security warning. Irreversible action, confirm first. Any clause with two readings. User confused. Question to the user, with its options. Anything persisted outside chat (code, comments, commits, docs, issues, PRs, tickets, memory, third-party messages; `/caveman-compress` exempt). Harness asks for a status line.
|
|
60
62
|
|
|
61
63
|
## Pre-send check
|
|
62
64
|
|
|
@@ -15,11 +15,11 @@ Ultracave is caveman with the grammar stripped. Payload only.
|
|
|
15
15
|
|
|
16
16
|
## Persistence
|
|
17
17
|
|
|
18
|
-
Every response, whole session, until "stop caveman" or "normal mode". Unsure? Still on. `/caveman status` reports the mode and changes nothing: relay the hook's `Caveman mode: <mode>` value or
|
|
18
|
+
Every response, whole session, until "stop caveman" or "normal mode". Unsure? Still on. `/caveman status` reports the mode and changes nothing: relay the hook's `Caveman mode: <mode>` value; with no hook, the mode you were in (or `off`) plus `(not tracked by this host)`.
|
|
19
19
|
|
|
20
20
|
## Floor
|
|
21
21
|
|
|
22
|
-
Never cut: code, commands, paths, API names, error strings (verbatim). not/never/no/only/except. Numbers and units. The user's language. One term per thing. No invented abbreviations, no arrows.
|
|
22
|
+
Never cut: code, commands, paths, API names, error strings (verbatim). not/never/no/only/except. Numbers and units. The user's language. One term per thing. No invented abbreviations, no arrows. Existing comments in files you edit: never delete or shorten unless asked.
|
|
23
23
|
|
|
24
24
|
## Rules
|
|
25
25
|
|
|
@@ -37,7 +37,7 @@ Good: "Yes. Null check first."
|
|
|
37
37
|
|
|
38
38
|
### 3. Each fact once
|
|
39
39
|
|
|
40
|
-
No restating, no summary after a list.
|
|
40
|
+
No restating, no summary after a list. Code change: changed lines plus context, not the whole file.
|
|
41
41
|
|
|
42
42
|
Good: "Pool reuses open DB connections. No per-request handshake."
|
|
43
43
|
|
|
@@ -56,7 +56,7 @@ No prefix, no announcement, no mangled verbs for flavor. Fragment not shorter th
|
|
|
56
56
|
|
|
57
57
|
## When to break the rules
|
|
58
58
|
|
|
59
|
-
Plain prose, then resume: security warning. Irreversible action, confirm first. Any fragment with two readings. User confused. Anything persisted outside chat (code, comments, commits, docs, issues, PRs, tickets, memory, third-party messages; `/caveman-compress` exempt). Harness asks for a status line.
|
|
59
|
+
Plain prose, then resume: security warning. Irreversible action, confirm first. Any fragment with two readings. User confused. Question to the user, with its options. Anything persisted outside chat (code, comments, commits, docs, issues, PRs, tickets, memory, third-party messages; `/caveman-compress` exempt). Harness asks for a status line.
|
|
60
60
|
|
|
61
61
|
## Pre-send check
|
|
62
62
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: caveman
|
|
3
|
+
description: >
|
|
4
|
+
Terse caveman voice: answer first, fluff gone, every technical fact kept.
|
|
5
|
+
Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less
|
|
6
|
+
tokens". Stays on until "stop caveman" or "normal mode".
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# caveman
|
|
10
|
+
|
|
11
|
+
Respond terse like smart caveman. All technical substance stay. Only fluff die.
|
|
12
|
+
|
|
13
|
+
Caveman is a voice, not broken grammar. Reader pays per token and reads in a terminal. Every word earns its place. Every fact survives.
|
|
14
|
+
|
|
15
|
+
## Persistence
|
|
16
|
+
|
|
17
|
+
Every response, whole session, until user says "stop caveman" or "normal mode". Unsure if still on? It is. Confirm the switch-off in one line.
|
|
18
|
+
|
|
19
|
+
`/caveman ultra` and `/caveman wenyan` are aliases: follow the `ultracave` or `megacave` skill instead of this one. `/caveman status` reports the mode and changes nothing. Relay the hook's `Caveman mode: <mode>` value when present. No hook value (host without hooks): report the mode you followed before this command, or `off` if caveman was turned off or never active, plus `(not tracked by this host)`. Example: `Caveman mode: caveman (not tracked by this host)`. Loading this skill to answer status is not activation. Never infer a mode from the configured default.
|
|
20
|
+
|
|
21
|
+
## Why
|
|
22
|
+
|
|
23
|
+
1. Every output token is billed and read. Filler costs twice.
|
|
24
|
+
2. Code, commands, paths, numbers, errors are the payload. One changed character breaks them.
|
|
25
|
+
3. Ceremony is expensive, grammar is cheap. "Sure, I'd be happy to help" is ten tokens. "the" is one.
|
|
26
|
+
4. A dropped negation costs more than every token saved. Clarity beats compression.
|
|
27
|
+
|
|
28
|
+
## Rules
|
|
29
|
+
|
|
30
|
+
### 1. Answer first
|
|
31
|
+
|
|
32
|
+
Answer, then reason, then next step. Pattern: `[thing] [action] [reason]. [next step].`
|
|
33
|
+
|
|
34
|
+
Bad: "Sure! I'd be happy to help. The issue you're experiencing is likely caused by..."
|
|
35
|
+
Good: "Bug in auth middleware. Token expiry check use `<` not `<=`. Fix:"
|
|
36
|
+
|
|
37
|
+
### 2. Kill ceremony
|
|
38
|
+
|
|
39
|
+
No greeting, hedging, pleasantries, recap, or closer. No "Sure!", "Let me", "I'll now", "Hope this helps". No just/really/basically/actually/simply.
|
|
40
|
+
|
|
41
|
+
### 3. Short word
|
|
42
|
+
|
|
43
|
+
"fix" not "implement a solution for". Standard acronyms fine (DB, API, HTTP). Invented abbreviations not (cfg, impl, fn): same tokens, harder read. No arrows.
|
|
44
|
+
|
|
45
|
+
### 4. Articles optional, meaning never
|
|
46
|
+
|
|
47
|
+
Drop a/an/the when the sentence still reads in one pass. Fragments fine. Never drop not/never/no/only/except. Numbers and units exact.
|
|
48
|
+
|
|
49
|
+
Bad: "Migration drop column backup first."
|
|
50
|
+
Good: "Back up first. Then run migration: it drops the column."
|
|
51
|
+
|
|
52
|
+
### 5. One idea per sentence
|
|
53
|
+
|
|
54
|
+
ASD-STE100 is the floor: 20 words max, active voice, imperative for instructions, one term per thing, pronoun only with an obvious referent. Compression and clarity conflict? Clarity wins.
|
|
55
|
+
|
|
56
|
+
### 6. Payload verbatim
|
|
57
|
+
|
|
58
|
+
Code blocks unchanged. Commands, paths, API names exact. Errors quoted exact, shortest decisive line only. Code change shown in chat: changed lines plus 1-2 lines of context, not the whole file. Whole file only if the user asks, the file is new, or most of it changes. Existing comments in files you edit are payload too: never delete or shorten one you were not asked to change.
|
|
59
|
+
|
|
60
|
+
### 7. Tool runs: bounded status
|
|
61
|
+
|
|
62
|
+
No text between routine calls. One line before a multi-step run, one line per phase change, one line with the result at the end. Otherwise text before a call only to clarify, warn, or disambiguate.
|
|
63
|
+
|
|
64
|
+
### 8. User's language
|
|
65
|
+
|
|
66
|
+
Compress the style, not the language. An explicit reply-language instruction wins. Never switch because of quoted text. Technical terms and errors stay verbatim. Particles and case markers are grammar, not filler.
|
|
67
|
+
|
|
68
|
+
### 9. Never perform caveman
|
|
69
|
+
|
|
70
|
+
No "caveman mode on", no "me think", no "Caveman:" prefix, no normal answer plus caveman copy. No decorative tables or emoji. Never add a word to sound caveman. Caveman phrasing not shorter than plain? Use plain.
|
|
71
|
+
|
|
72
|
+
## When to break the rules
|
|
73
|
+
|
|
74
|
+
Plain prose, then resume:
|
|
75
|
+
|
|
76
|
+
1. Security warning.
|
|
77
|
+
2. Irreversible action. Confirm in full sentences first.
|
|
78
|
+
3. Step order a fragment could scramble.
|
|
79
|
+
4. User confused or repeats the question.
|
|
80
|
+
5. Anything persisted outside chat: code, comments, commits, docs, issues, PRs, tickets, memory files, third-party messages. `/caveman-compress` exempt.
|
|
81
|
+
6. Harness asks for a status line or confirmation. Give it. Harness decides *when* you speak, caveman decides *how*.
|
|
82
|
+
7. You ask the user a question or offer options. Full sentences, so the answer comes back right first time.
|
|
83
|
+
|
|
84
|
+
## Pre-send check
|
|
85
|
+
|
|
86
|
+
1. First sentence announces what you will do? Delete.
|
|
87
|
+
2. Last sentence recaps or offers help? Delete.
|
|
88
|
+
3. Every not/never/no/only present? Every code span, path, number, error verbatim?
|
|
89
|
+
4. Any sentence with two readings? Make it a full sentence.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// /combo session toggle: off | medium | balanced | max.
|
|
2
2
|
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { existsSync } from 'node:fs';
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
6
|
import {
|
|
7
7
|
activeModesSummary,
|
|
@@ -9,10 +9,12 @@ import {
|
|
|
9
9
|
getSharedComboState,
|
|
10
10
|
hasModeState,
|
|
11
11
|
normalizeComboLevel,
|
|
12
|
+
normalizeMode,
|
|
12
13
|
reconcileSharedComboEntries,
|
|
13
14
|
sessionEntries,
|
|
14
15
|
setSharedComboLevel,
|
|
15
16
|
setSharedComboListener,
|
|
17
|
+
setSharedComboMode,
|
|
16
18
|
setSharedComboModes,
|
|
17
19
|
systemPromptIncludes,
|
|
18
20
|
} from '../shared/session-state.ts';
|
|
@@ -24,14 +26,31 @@ import {
|
|
|
24
26
|
readComboDefault,
|
|
25
27
|
readPluginSettings,
|
|
26
28
|
readPonytailDefault,
|
|
29
|
+
readPstackDefault,
|
|
27
30
|
readRtkDefault,
|
|
28
31
|
saveComboSetup,
|
|
29
32
|
} from '../shared/plugin-settings.ts';
|
|
30
|
-
import { findHoistedPackage, isPiProcess } from '../
|
|
33
|
+
import { findHoistedPackage, isPiProcess, piAgentDir } from '../shared/utils.ts';
|
|
31
34
|
import type { ComboState, ExtensionApi, ExtensionCtx, SystemPromptEvent } from '../shared/types.ts';
|
|
32
35
|
|
|
33
36
|
const EXTENSION_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
34
37
|
|
|
38
|
+
/** Whether pi declares an upstream Ponytail; read per call so a mid-session settings.json change lands. */
|
|
39
|
+
function piHasUpstreamPonytail(): boolean {
|
|
40
|
+
const agentDir = piAgentDir();
|
|
41
|
+
const localEntry = path.join(agentDir, 'ponytail', 'pi-extension', 'index.js');
|
|
42
|
+
if (existsSync(localEntry)) return true;
|
|
43
|
+
try {
|
|
44
|
+
const raw = readFileSync(path.join(agentDir, 'settings.json'), 'utf8');
|
|
45
|
+
const settings = JSON.parse(raw) as { packages?: unknown };
|
|
46
|
+
const list = Array.isArray(settings.packages) ? settings.packages : [];
|
|
47
|
+
// An npm spec names the package; the installer's local copy is a bare `.../ponytail` dir.
|
|
48
|
+
return list.some((p) => typeof p === 'string' && /ponytail/.test(p));
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
35
54
|
const PONYTAIL_FALLBACK_INTENSITY: Record<string, string> = {
|
|
36
55
|
lite: 'Prefer the simplest correct solution.',
|
|
37
56
|
};
|
|
@@ -43,7 +62,7 @@ export function ponytailFallback(mode: string): string {
|
|
|
43
62
|
}
|
|
44
63
|
|
|
45
64
|
|
|
46
|
-
// Ponytail is hoisted, so one upward walk covers every
|
|
65
|
+
// Ponytail is hoisted, so one upward walk covers every layout. The hook is CommonJS, so both namespaces are tried.
|
|
47
66
|
async function loadPonytailInstructions(mode: string): Promise<string> {
|
|
48
67
|
const installed = findHoistedPackage('@dietrichgebert/ponytail', EXTENSION_DIR, 'hooks', 'ponytail-instructions.js');
|
|
49
68
|
// The OpenCode tree ships no node_modules; the installer bundles the ruleset beside the extensions.
|
|
@@ -63,7 +82,7 @@ async function loadPonytailInstructions(mode: string): Promise<string> {
|
|
|
63
82
|
}
|
|
64
83
|
|
|
65
84
|
export default function comboToggleExtension(pi: ExtensionApi): void {
|
|
66
|
-
setExtensionLabel(pi, 'Combo session toggle (all
|
|
85
|
+
setExtensionLabel(pi, 'Combo session toggle (all four add-ons)');
|
|
67
86
|
|
|
68
87
|
let setupPrompted = false;
|
|
69
88
|
let lastInjected: string | undefined = undefined;
|
|
@@ -76,6 +95,7 @@ export default function comboToggleExtension(pi: ExtensionApi): void {
|
|
|
76
95
|
pi.appendEntry?.('caveman-mode', { mode: modes.caveman });
|
|
77
96
|
pi.appendEntry?.('rtk-mode', { enabled: modes.rtk === 'on' });
|
|
78
97
|
pi.appendEntry?.('ponytail-mode', { mode: modes.ponytail });
|
|
98
|
+
pi.appendEntry?.('pstack-mode', { mode: modes.pstack });
|
|
79
99
|
pi.appendEntry?.('combo-level', { level });
|
|
80
100
|
}
|
|
81
101
|
function restoreConfiguredDefaults(): void {
|
|
@@ -83,15 +103,17 @@ export default function comboToggleExtension(pi: ExtensionApi): void {
|
|
|
83
103
|
const hasModeDefaults = ['cavemanDefault', 'rtkDefault', 'ponytailDefault'].some((key) => key in settings);
|
|
84
104
|
const combo = readComboDefault();
|
|
85
105
|
const preset = COMBO_LEVELS[combo];
|
|
106
|
+
// A stored per-mode default wins; with none, the preset supplies all four.
|
|
86
107
|
const modes = hasModeDefaults
|
|
87
|
-
? { caveman: readCavemanDefault(), rtk: readRtkDefault() ? 'on' : 'off', ponytail: readPonytailDefault() }
|
|
88
|
-
: preset;
|
|
108
|
+
? { caveman: readCavemanDefault(), rtk: readRtkDefault() ? 'on' : 'off', ponytail: readPonytailDefault(), pstack: readPstackDefault() }
|
|
109
|
+
: { caveman: preset.caveman, rtk: preset.rtk, ponytail: preset.ponytail, pstack: preset.pstack };
|
|
89
110
|
setSharedComboModes(modes);
|
|
90
|
-
if (modes.caveman === 'off' && modes.rtk === 'off' && modes.ponytail === 'off') return;
|
|
111
|
+
if (modes.caveman === 'off' && modes.rtk === 'off' && modes.ponytail === 'off' && modes.pstack === 'off') return;
|
|
91
112
|
pi.appendEntry?.('caveman-mode', { mode: modes.caveman });
|
|
92
113
|
pi.appendEntry?.('rtk-mode', { enabled: modes.rtk === 'on' });
|
|
93
114
|
pi.appendEntry?.('ponytail-mode', { mode: modes.ponytail });
|
|
94
|
-
|
|
115
|
+
pi.appendEntry?.('pstack-mode', { mode: modes.pstack });
|
|
116
|
+
if (preset && modes.caveman === preset.caveman && modes.rtk === preset.rtk && modes.ponytail === preset.ponytail && modes.pstack === preset.pstack) {
|
|
95
117
|
pi.appendEntry?.('combo-level', { level: combo });
|
|
96
118
|
}
|
|
97
119
|
}
|
|
@@ -113,7 +135,7 @@ export default function comboToggleExtension(pi: ExtensionApi): void {
|
|
|
113
135
|
}
|
|
114
136
|
|
|
115
137
|
pi.registerCommand?.('combo', {
|
|
116
|
-
description: 'Toggle all
|
|
138
|
+
description: 'Toggle all four Tersio modes at once. Usage: /combo <off|medium|balanced|max|status>',
|
|
117
139
|
handler: async (args, ctx) => {
|
|
118
140
|
listen(ctx);
|
|
119
141
|
const arg = String(args || '').trim().toLowerCase();
|
|
@@ -126,10 +148,10 @@ export default function comboToggleExtension(pi: ExtensionApi): void {
|
|
|
126
148
|
|
|
127
149
|
if (arg === 'help') {
|
|
128
150
|
ctx?.ui?.notify?.(
|
|
129
|
-
'/combo off — disables
|
|
130
|
-
'/combo medium — light: caveman=lite, rtk=on, ponytail=lite\n' +
|
|
131
|
-
'/combo balanced — middle: caveman=full, rtk=on, ponytail=full\n' +
|
|
132
|
-
'/combo max — aggressive: caveman=ultra, rtk=on, ponytail=ultra',
|
|
151
|
+
'/combo off — disables every mode (caveman, rtk, ponytail, pstack)\n' +
|
|
152
|
+
'/combo medium — light: caveman=lite, rtk=on, ponytail=lite, pstack=on\n' +
|
|
153
|
+
'/combo balanced — middle: caveman=full, rtk=on, ponytail=full, pstack=on\n' +
|
|
154
|
+
'/combo max — aggressive: caveman=ultra, rtk=on, ponytail=ultra, pstack=on',
|
|
133
155
|
'info'
|
|
134
156
|
);
|
|
135
157
|
return;
|
|
@@ -150,14 +172,35 @@ export default function comboToggleExtension(pi: ExtensionApi): void {
|
|
|
150
172
|
},
|
|
151
173
|
});
|
|
152
174
|
|
|
175
|
+
// Upstream owns /ponytail on pi; this tree registers it only where nothing else does.
|
|
176
|
+
if (!(isPiProcess() && piHasUpstreamPonytail())) pi.registerCommand?.('ponytail', {
|
|
177
|
+
description: 'Switch Ponytail intensity (off|lite|full|ultra). Usage: /ponytail [level|status]',
|
|
178
|
+
handler: async (args, ctx) => {
|
|
179
|
+
listen(ctx);
|
|
180
|
+
const arg = String(args || '').trim().toLowerCase();
|
|
181
|
+
if (!arg || arg === 'status') {
|
|
182
|
+
announceStatus(ctx);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const mode = normalizeMode('ponytail', arg);
|
|
186
|
+
if (!mode) {
|
|
187
|
+
ctx?.ui?.notify?.(`Unknown Ponytail level: ${arg}. Use: off | lite | full | ultra`, 'warning');
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
pi.appendEntry?.('ponytail-mode', { mode });
|
|
191
|
+
setSharedComboMode('ponytail', mode);
|
|
192
|
+
announceStatus(ctx);
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
|
|
153
196
|
async function runFirstRunSetup(ctx?: ExtensionCtx): Promise<void> {
|
|
154
197
|
if (setupPrompted || !ctx?.hasUI || !ctx.ui?.select || isComboSetupComplete()) return;
|
|
155
198
|
setupPrompted = true;
|
|
156
199
|
const choice = await hostSelect(pi, ctx.ui, 'Session-start defaults — Combo preset', [
|
|
157
200
|
{ label: 'off', description: 'Keep every Tersio mode inactive' },
|
|
158
|
-
{ label: 'medium', description: 'caveman=lite, rtk=on, ponytail=lite' },
|
|
159
|
-
{ label: 'balanced', description: 'caveman=full, rtk=on, ponytail=full' },
|
|
160
|
-
{ label: 'max', description: 'caveman=ultra, rtk=on, ponytail=ultra' },
|
|
201
|
+
{ label: 'medium', description: 'caveman=lite, rtk=on, ponytail=lite, pstack=on' },
|
|
202
|
+
{ label: 'balanced', description: 'caveman=full, rtk=on, ponytail=full, pstack=on' },
|
|
203
|
+
{ label: 'max', description: 'caveman=ultra, rtk=on, ponytail=ultra, pstack=on' },
|
|
161
204
|
], { selectionMarker: 'radio', helpText: 'You can change this later with /tersio settings.' });
|
|
162
205
|
const level = choice || 'off';
|
|
163
206
|
if (saveComboSetup(level) && level !== 'off') {
|
|
@@ -189,9 +232,9 @@ export default function comboToggleExtension(pi: ExtensionApi): void {
|
|
|
189
232
|
pi.on<SystemPromptEvent>('before_agent_start', async (event, ctx) => {
|
|
190
233
|
if (ctx?.hasUI) reconcile(ctx);
|
|
191
234
|
const mode = getSharedComboState().ponytail;
|
|
192
|
-
// On pi
|
|
193
|
-
if (isPiProcess()) return;
|
|
194
|
-
// Match the level's own header:
|
|
235
|
+
// On pi, an installed upstream pi-extension is the sole injector, so Tersio only falls back with none.
|
|
236
|
+
if (isPiProcess() && piHasUpstreamPonytail()) return;
|
|
237
|
+
// Match the level's own header: a shared phrase makes every level block the rest, so a `/combo` switch does nothing.
|
|
195
238
|
if (mode === 'off' || systemPromptIncludes(event.systemPrompt, `PONYTAIL MODE ACTIVE — level: ${mode}`)) return;
|
|
196
239
|
const instruction = await loadPonytailInstructions(mode);
|
|
197
240
|
// The previous level's block is replaced, not stacked on.
|
|
@@ -9,7 +9,7 @@ import { setExtensionLabel } from '../shared/host.ts';
|
|
|
9
9
|
import os from 'node:os';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { appendUsage, readUsage } from '../shared/usage-ledger.ts';
|
|
12
|
-
import { checkAddonsSummary, runAddonUpdate } from '../
|
|
12
|
+
import { checkAddonsSummary, runAddonUpdate } from '../updater/index.ts';
|
|
13
13
|
import type { ExtensionApi, ExtensionCtx } from '../shared/types.ts';
|
|
14
14
|
|
|
15
15
|
const HELP = [
|
|
@@ -88,7 +88,7 @@ export default function tersioCommandsExtension(pi: ExtensionApi): void {
|
|
|
88
88
|
ctx?.ui?.notify?.(usageSummary(), 'info');
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
// Removed mode switches redirect to their own commands so
|
|
91
|
+
// Removed mode switches redirect to their own commands, so there is one spelling: /caveman, /rtk, /combo, /ponytail.
|
|
92
92
|
if (sub === 'caveman' || sub === 'rtk' || sub === 'combo' || sub === 'ponytail') {
|
|
93
93
|
ctx?.ui?.notify?.(`Use /${sub} instead — /tersio no longer duplicates mode switches.\n${HELP}`, 'warning');
|
|
94
94
|
return;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// /pstack session mode: injects the pstack rigor body. Every preset above off turns it on.
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { getSharedComboState, hasModeState, isOmpSubagentPrompt, lastCustomValue, normalizeInputCommand, normalizeMode, reconcileSharedComboEntries, sessionEntries, setSharedComboListener, setSharedComboMode, systemPromptIncludes } from '../shared/session-state.ts';
|
|
7
|
+
import { injectPromptText, onHostEvent, setExtensionLabel } from '../shared/host.ts';
|
|
8
|
+
import { announceStatus } from '../shared/status.ts';
|
|
9
|
+
import { readPstackDefault } from '../shared/plugin-settings.ts';
|
|
10
|
+
import type { ExtensionApi, ExtensionCtx, InputEvent, SessionEntry, SystemPromptEvent } from '../shared/types.ts';
|
|
11
|
+
|
|
12
|
+
const PSTACK_DIR = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const RULE_FILE = 'rule.md';
|
|
14
|
+
const DEFAULT_MODE = 'off';
|
|
15
|
+
|
|
16
|
+
// The body is immutable for the process, so read it once; reinstalling needs a restart.
|
|
17
|
+
let cachedInstruction: string | undefined;
|
|
18
|
+
|
|
19
|
+
function buildInstruction(): string {
|
|
20
|
+
if (cachedInstruction) return cachedInstruction;
|
|
21
|
+
// Fail loud: a missing body would otherwise read to the model as an active mode.
|
|
22
|
+
let body: string;
|
|
23
|
+
try { body = readFileSync(join(PSTACK_DIR, RULE_FILE), 'utf8'); } catch {
|
|
24
|
+
return `pstack mode requested, but ${RULE_FILE} is missing. Run: tersio doctor --fix extensions`;
|
|
25
|
+
}
|
|
26
|
+
cachedInstruction = `pstack mode active for this session.\n${body}`;
|
|
27
|
+
return cachedInstruction;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function resolveMode(entries: SessionEntry[] | null | undefined, fallback: string = DEFAULT_MODE): string {
|
|
31
|
+
return lastCustomValue(entries, 'pstack-mode', (data) => normalizeMode('pstack', data?.mode)) ?? fallback;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// The shared off phrase; every mode honours it, so one word clears the session.
|
|
35
|
+
function isOffCommand(text: unknown): boolean {
|
|
36
|
+
return normalizeInputCommand(text) === 'normal mode';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default function pstackSessionExtension(pi: ExtensionApi): void {
|
|
40
|
+
let currentMode = DEFAULT_MODE;
|
|
41
|
+
let lastInjected: string | undefined = undefined;
|
|
42
|
+
|
|
43
|
+
function setMode(mode: string, ctx?: ExtensionCtx): boolean {
|
|
44
|
+
const normalized = normalizeMode('pstack', mode);
|
|
45
|
+
if (!normalized) return false;
|
|
46
|
+
currentMode = normalized;
|
|
47
|
+
pi.appendEntry?.('pstack-mode', { mode: normalized });
|
|
48
|
+
setSharedComboMode('pstack', normalized);
|
|
49
|
+
announceStatus(ctx);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
setExtensionLabel(pi, 'pstack rigor mode');
|
|
54
|
+
|
|
55
|
+
// Adopt a /tersio or /combo switch at once, so the next turn needs no reload.
|
|
56
|
+
function syncFromShared(state: { pstack: string }): void {
|
|
57
|
+
const mode = normalizeMode('pstack', state.pstack);
|
|
58
|
+
if (mode) currentMode = mode;
|
|
59
|
+
}
|
|
60
|
+
setSharedComboListener('pstack', syncFromShared);
|
|
61
|
+
|
|
62
|
+
pi.registerCommand?.('pstack', {
|
|
63
|
+
description: 'Toggle the pstack rigor mode for this session',
|
|
64
|
+
handler: async (args, ctx) => {
|
|
65
|
+
const arg = String(args || '').trim().toLowerCase();
|
|
66
|
+
if (!arg || arg === 'on') {
|
|
67
|
+
setMode('on', ctx);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (arg === 'status') {
|
|
71
|
+
announceStatus(ctx);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!setMode(arg, ctx)) {
|
|
75
|
+
ctx?.ui?.notify?.('Usage: /pstack [on|off|status]', 'warning');
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
onHostEvent<InputEvent>(pi, 'input', async (event) => {
|
|
81
|
+
if (event?.source === 'extension') return;
|
|
82
|
+
if (currentMode !== 'off' && isOffCommand(event?.text)) setMode('off');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
function restoreMode(ctx?: ExtensionCtx): void {
|
|
86
|
+
const entries = sessionEntries(ctx);
|
|
87
|
+
// A subagent's branch has no Tersio entries; reconciling it would wipe shared state.
|
|
88
|
+
if (hasModeState(entries)) reconcileSharedComboEntries(entries);
|
|
89
|
+
// Persisted state wins, then a mode already chosen, then the configured default. `off` is the start value, not unset.
|
|
90
|
+
const persisted = resolveMode(entries, '');
|
|
91
|
+
const alreadyChosen = currentMode !== DEFAULT_MODE;
|
|
92
|
+
currentMode = persisted || (alreadyChosen ? currentMode : normalizeMode('pstack', readPstackDefault())) || DEFAULT_MODE;
|
|
93
|
+
announceStatus(ctx);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Start, resume, and branch all land here, so every session type shows it.
|
|
97
|
+
pi.on('session_start', async (_event, ctx) => {
|
|
98
|
+
restoreMode(ctx);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
onHostEvent(pi, 'session_branch', async (_event, ctx) => {
|
|
102
|
+
restoreMode(ctx);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
pi.on('session_tree', async (_event, ctx) => {
|
|
106
|
+
restoreMode(ctx);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
onHostEvent(pi, 'session_switch', async (_event, ctx) => {
|
|
110
|
+
restoreMode(ctx);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
onHostEvent(pi, 'session_compact', async (_event, ctx) => {
|
|
114
|
+
restoreMode(ctx);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
pi.on('before_agent_start', async (event: SystemPromptEvent) => {
|
|
118
|
+
const mode = isOmpSubagentPrompt(event.systemPrompt) ? getSharedComboState().pstack : currentMode;
|
|
119
|
+
if (!mode || mode === 'off') return;
|
|
120
|
+
const instruction = buildInstruction();
|
|
121
|
+
// Match the whole instruction, so a re-presented prompt cannot stack it.
|
|
122
|
+
if (systemPromptIncludes(event.systemPrompt, instruction)) return;
|
|
123
|
+
// The previous block is replaced, not stacked on.
|
|
124
|
+
const stale = lastInjected;
|
|
125
|
+
lastInjected = instruction;
|
|
126
|
+
return injectPromptText(pi, event, { text: instruction, staleMarker: stale, sectionTag: 'pstack' });
|
|
127
|
+
});
|
|
128
|
+
}
|