@lornatang/dsh-caveman 0.1.11 → 0.1.13

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.13 - 2026-11-25
4
+
5
+ - Reuse loopback configuration, preset checks, and skill and session helpers across the Caveman integration.
6
+
7
+ ## 0.1.12 - 2026-11-25
8
+
9
+ - Sync the upstream Caveman source, CLI and tested runtime binaries to 4.2.0 while retaining DSH session analysis.
10
+ - Add opt-in Code-Mode to DSH through the official Caveman MCP gateway.
11
+ - Honor the upstream reinforcement setting while supplying the initial and changed mode rules.
12
+
3
13
  ## 0.1.11 - 2026-11-23
4
14
 
5
15
  - Keep native events local to DSH on Windows and enforce resource limits on crew operations.
package/README.md CHANGED
@@ -84,6 +84,7 @@ The bundle supplies a `caveman` row. Override only the fields you want to change
84
84
  | `browseBinary` | auto-detected | Override the absolute path to `caveman-browse`; requires the DSH MCP manager. |
85
85
  | `mcpBinary` | auto-detected | Override the absolute path to `caveman-mcp`; requires the DSH MCP manager. |
86
86
  | `memoryBinary` | auto-detected | Override the absolute path to `cavemem`; enables its local memory tools. |
87
+ | `codeMode` | `false` | Enable the Caveman 4.2.0 Code-Mode MCP gateway with an explicit configuration file and workspace. |
87
88
 
88
89
  ### Voice and usage
89
90
 
@@ -91,6 +92,8 @@ Use `/caveman`, `/ultracave`, `/megacave`, `/caveman ultra`, `/caveman wenyan`,
91
92
 
92
93
  `defaultMode` accepts `caveman`, `ultracave`, `megacave`, `manual`, or `off`. An explicit profile value wins; otherwise the resolver checks `CAVEMAN_DEFAULT_MODE`, project configuration, and user configuration before falling back to `caveman`.
93
94
 
95
+ Set `CAVEMAN_REINFORCE=0` or `"reinforce": false` in Caveman configuration to skip per-turn voice reminders. The initial rules and mode switches still reach the model.
96
+
94
97
  The native coding policy is included in the system prompt when the output module and Core are active. When the local runtime is running, it also supplies task-specific rules, maintains state across compaction, and can suggest reusing a verified unchanged file observation. Recovery references are shown only when the recovery MCP tool is available. `CAVEMAN_CORE=off`, record mode, or the `record-only` native profile disables the active rules; restart DSH after changing these settings. The `core-lean-build` profile adds the lean-build policy.
95
98
 
96
99
  On Windows, DSH disables the native event hooks until the local runtime can prove its pipe identity. Dynamic task rules, native compaction state, and file observation reuse require these hooks. On this platform, use the static coding policy and HTTP middleware.
@@ -136,6 +139,18 @@ For Anthropic API traffic, merge [examples/caveman-anthropic.patch.yml](examples
136
139
 
137
140
  ### MCP, Blocks and Browse
138
141
 
142
+ To enable Code-Mode, install the Caveman 4.2.0 or newer runtime and add this to the DSH profile patch:
143
+
144
+ ```yaml
145
+ - id: caveman
146
+ config:
147
+ codeMode:
148
+ config: /absolute/path/to/servers.json
149
+ workspace: /absolute/path/to/workspace
150
+ ```
151
+
152
+ The JSON file uses the upstream `mcpServers` format. Use `{"mcpServers":{}}` for the gateway's built-in tools only. DSH exposes the gateway as `mcp__caveman_codemode__*`. The gateway loads the explicitly configured MCP servers and keeps execution and mutation tools separate.
153
+
139
154
  When `caveman-mcp` is installed, the DSH MCP manager exposes the `mcp__caveman__*` tools `caveman_compress`, `caveman_retrieve`, `caveman_stats`, `caveman_toon_encode`, and `caveman_toon_decode`. The server uses the local Caveman recovery store for its handles. Set `CAVEMAN_MCP=off` to disable automatic registration.
140
155
 
141
156
  When `cavemem` is installed, the MCP manager exposes `mcp__cavemem__*` tools for remembering, recalling, revising, inspecting, and forgetting local facts. `cavemem_recover` returns the exact original behind a recall handle and requires the DSH subprocess and working-directory services. Memories persist in the local Caveman home.
package/README.zh.md CHANGED
@@ -84,6 +84,7 @@ bundle 自带 `caveman` 行。在 profile 的 `cordis.patch.yml` 中添加覆盖
84
84
  | `browseBinary` | 自动查找 | 覆盖 `caveman-browse` 的绝对路径;需要 DSH MCP manager。 |
85
85
  | `mcpBinary` | 自动查找 | 覆盖 `caveman-mcp` 的绝对路径;需要 DSH MCP manager。 |
86
86
  | `memoryBinary` | 自动发现 | 覆盖 `cavemem` 的绝对路径;启用本地记忆工具。 |
87
+ | `codeMode` | `false` | 使用指定的配置文件和工作区启用 Caveman 4.2.0 的 Code-Mode MCP 网关。 |
87
88
 
88
89
  ### 回答模式与用量
89
90
 
@@ -91,6 +92,8 @@ bundle 自带 `caveman` 行。在 profile 的 `cordis.patch.yml` 中添加覆盖
91
92
 
92
93
  `defaultMode` 可设为 `caveman`、`ultracave`、`megacave`、`manual` 或 `off`。profile 的显式配置优先;否则依次检查 `CAVEMAN_DEFAULT_MODE`、项目配置和用户配置,均未设置时使用 `caveman`。
93
94
 
95
+ 设置 `CAVEMAN_REINFORCE=0`,或在 Caveman 配置中设置 `"reinforce": false`,可关闭每轮风格提醒。首次规则和切换模式时的规则仍会传给模型。
96
+
94
97
  output 模块和 Core 启用时,原生编码规则会加入系统提示词。本地运行时启动后,还会提供任务规则、衔接压缩前后的状态,并在文件确定未变化时提示复用已有观察;只有恢复 MCP 工具可用时才会展示恢复引用。设置 `CAVEMAN_CORE=off`、使用 record 模式或 `record-only` 原生 profile 可关闭活动规则;更改后重启 DSH。`core-lean-build` profile 会额外加入 lean-build 规则。
95
98
 
96
99
  Windows 上,DSH 会暂停原生事件钩子,直到本地运行时能够证明其管道身份。动态任务规则、原生压缩状态和文件观察复用依赖这些钩子。Windows 上可通过 HTTP middleware 使用压缩,也可使用静态编码规则。
@@ -136,6 +139,18 @@ Anthropic API 请求可将 [examples/caveman-anthropic.patch.yml](examples/cavem
136
139
 
137
140
  ### MCP、Blocks 和 Browse
138
141
 
142
+ 安装 Caveman 4.2.0 或更新的运行组件后,可在 DSH profile patch 中启用 Code-Mode:
143
+
144
+ ```yaml
145
+ - id: caveman
146
+ config:
147
+ codeMode:
148
+ config: /absolute/path/to/servers.json
149
+ workspace: /absolute/path/to/workspace
150
+ ```
151
+
152
+ 配置文件使用上游 `mcpServers` JSON 格式。填写 `{"mcpServers":{}}` 时只使用网关内置工具。DSH 以 `mcp__caveman_codemode__*` 注册网关,网关加载显式配置的 MCP 服务,并将只读执行与修改操作分配给不同工具。
153
+
139
154
  安装 `caveman-mcp` 后,DSH MCP manager 会提供 `mcp__caveman__*` 工具:`caveman_compress`、`caveman_retrieve`、`caveman_stats`、`caveman_toon_encode` 和 `caveman_toon_decode`。服务使用本地 Caveman 恢复存储保存句柄。设置 `CAVEMAN_MCP=off` 可关闭自动注册。
140
155
 
141
156
  安装 `cavemem` 后,MCP manager 会提供 `mcp__cavemem__*` 工具,用于记住、检索、修订、查看和删除本地事实。`cavemem_recover` 可取回检索句柄对应的完整原文,需要 DSH subprocess 和 working-directory 服务。记忆保存在本地 Caveman 目录。
@@ -1,14 +1,13 @@
1
1
  import { createHash } from 'node:crypto';
2
- /** Attribute only requests routed to the configured loopback proxy. */
2
+ import { localOrigin } from './runtime.js';
3
3
  export function cavemanSessionId(sessionId) {
4
4
  return `dsh-${createHash('sha256').update(sessionId).digest('hex').slice(0, 32)}`;
5
5
  }
6
6
  export function cavemanRequestHeaders(endpoint, request, headers) {
7
7
  try {
8
- const target = new URL(endpoint);
8
+ const target = localOrigin(endpoint);
9
9
  const base = new URL(request.baseURL);
10
- if (target.protocol !== 'http:' || target.username || target.password ||
11
- !['127.0.0.1', 'localhost', '[::1]'].includes(target.hostname) || base.origin !== target.origin || base.username || base.password)
10
+ if (!target || base.origin !== target.origin || base.username || base.password)
12
11
  return headers;
13
12
  if (!headers.has('x-cave-agent'))
14
13
  headers.set('x-cave-agent', 'dsh');
@@ -16,7 +15,7 @@ export function cavemanRequestHeaders(endpoint, request, headers) {
16
15
  headers.set('x-cave-session', cavemanSessionId(request.sessionId));
17
16
  }
18
17
  }
19
- catch { /* Invalid or unrelated routes keep their existing headers. */ }
18
+ catch { /* Headers supplied by another handler may be immutable. */ }
20
19
  return headers;
21
20
  }
22
21
  export function registerAttribution(ctx, endpoint) {
@@ -36,7 +36,7 @@ function textBlocks(event) {
36
36
  return event.data.message.content.flatMap((block, index) => block.type === 'text' ? [{ index, text: block.text }] : []);
37
37
  }
38
38
  export function isManagedTool(name) {
39
- return name === 'caveman_retrieve' || name === 'cavemem_recover' || name.startsWith('mcp__caveman__') || name.startsWith('mcp__caveman_browse__') || name.startsWith('mcp__cavemem__') ||
39
+ return name === 'caveman_retrieve' || name === 'cavemem_recover' || name.startsWith('mcp__caveman__') || name.startsWith('mcp__caveman_browse__') || name.startsWith('mcp__caveman_codemode__') || name.startsWith('mcp__cavemem__') ||
40
40
  /^mcp__.+__(?:caveman_retrieve|browser_recover)$/u.test(name);
41
41
  }
42
42
  const MAX_ORIGINAL_ENTRIES = 64;
package/lib/index.js CHANGED
@@ -1,36 +1,39 @@
1
- import { readFileSync } from 'node:fs';
1
+ import { readFileSync, statSync } from 'node:fs';
2
+ import { isAbsolute } from 'node:path';
2
3
  import { fileURLToPath } from 'node:url';
3
4
  import z from '@deepseek-ai/schemastery';
4
5
  import { createUserMessage } from '@deepseek-ai/dsh-llm';
5
6
  import { createSkillProvider } from './skills.js';
6
- import { defaultModeFor, SessionModeTracker } from './mode.js';
7
+ import { defaultModeFor, getReinforce, SessionModeTracker } from './mode.js';
7
8
  import { registerCompression } from './compression.js';
8
9
  import { registerBlocks } from './blocks.js';
9
10
  import { statsReport } from './stats.js';
10
11
  import { findCavemanBinary, guardedRuntimeFetch, runtimeSettings, verifiedRuntime } from './runtime.js';
11
12
  import { registerMemoryRecovery } from './memory.js';
12
13
  import { registerAttribution } from './attribution.js';
13
- import { registerNative } from './native.js';
14
+ import { isCavecrewPreset, registerNative } from './native.js';
14
15
  export const name = 'caveman';
15
16
  export const inject = ['skills', 'tools', 'systemPrompt', 'llm'];
17
+ const DEFAULT_ENDPOINT = 'http://127.0.0.1:8787';
16
18
  export const Config = z.object({
17
19
  defaultMode: z.union([
18
20
  z.const('caveman'), z.const('ultracave'), z.const('megacave'), z.const('off'), z.const('manual'),
19
21
  ]),
20
22
  inputCompression: z.boolean(),
21
- middlewareEndpoint: z.string().default('http://127.0.0.1:8787'),
23
+ middlewareEndpoint: z.string().default(DEFAULT_ENDPOINT),
22
24
  blocksBinary: z.string().min(1),
23
25
  browseBinary: z.string().min(1),
24
26
  mcpBinary: z.string().min(1),
25
27
  memoryBinary: z.string().min(1),
28
+ codeMode: z.union([z.const(false), z.object({ config: z.string().required(), workspace: z.string().required() })]).default(false),
26
29
  });
27
- /** Register skills and reinforce the selected mode per session. */
28
30
  export function apply(ctx, config = {}) {
29
31
  const root = fileURLToPath(new URL('../vendor/caveman/skills/', import.meta.url));
30
32
  const modes = new SessionModeTracker();
31
33
  const settings = runtimeSettings();
32
- registerAttribution(ctx, config.middlewareEndpoint ?? 'http://127.0.0.1:8787');
33
- registerNative(ctx, config.middlewareEndpoint ?? 'http://127.0.0.1:8787', { mode: settings.nativeMode, profile: settings.nativeProfile, core: settings.core });
34
+ const endpoint = config.middlewareEndpoint ?? DEFAULT_ENDPOINT;
35
+ registerAttribution(ctx, endpoint);
36
+ registerNative(ctx, endpoint, { mode: settings.nativeMode, profile: settings.nativeProfile, core: settings.core });
34
37
  if (settings.core) {
35
38
  let core = readFileSync(new URL('../vendor/caveman/skills/native/native-core.md', import.meta.url), 'utf8').trim();
36
39
  if (settings.coreLeanBuild) {
@@ -42,13 +45,12 @@ export function apply(ctx, config = {}) {
42
45
  name: 'caveman:core', order: ctx.systemPrompt.getSectionOrder('DEPLOYMENT_PERSONA_PREFIX') + 10, interpolate: false,
43
46
  text: context => {
44
47
  const preset = context.agent && ctx.get('agentPresets')?.composedPreset(context.agent.ctx);
45
- return preset === 'cavecrew-investigator' || preset === 'cavecrew-builder' || preset === 'cavecrew-reviewer' ? '' : core;
48
+ return isCavecrewPreset(preset) ? '' : core;
46
49
  },
47
50
  });
48
51
  }
49
52
  ctx.skills.registerProvider(control => createSkillProvider(root, control));
50
53
  if (config.inputCompression !== false && settings.input) {
51
- const endpoint = config.middlewareEndpoint ?? 'http://127.0.0.1:8787';
52
54
  const automatic = config.inputCompression === true ? undefined : {
53
55
  fetch: guardedRuntimeFetch(endpoint), available: (signal) => verifiedRuntime(endpoint, process.env, signal),
54
56
  };
@@ -64,6 +66,18 @@ export function apply(ctx, config = {}) {
64
66
  ctx.inject(['subprocess', 'workingDirectory'], scoped => registerMemoryRecovery(scoped, memory));
65
67
  const servers = [{ name: 'caveman', binary: mcp, args: [] }, { name: 'caveman_browse', binary: browse, args: [] }, { name: 'cavemem', binary: memory, args: ['mcp'] }]
66
68
  .filter((server) => server.binary !== undefined);
69
+ if (settings.mcp && config.codeMode) {
70
+ if (!mcp)
71
+ throw new Error('dsh-caveman: Code-Mode requires the Caveman 4.2.0 or newer MCP binary');
72
+ const { config: serversFile, workspace } = config.codeMode;
73
+ if (!isAbsolute(serversFile) || !statSync(serversFile, { throwIfNoEntry: false })?.isFile()) {
74
+ throw new Error('dsh-caveman: codeMode.config must be an absolute path to an MCP configuration file');
75
+ }
76
+ if (!isAbsolute(workspace) || !statSync(workspace, { throwIfNoEntry: false })?.isDirectory()) {
77
+ throw new Error('dsh-caveman: codeMode.workspace must be an absolute path to a directory');
78
+ }
79
+ servers.push({ name: 'caveman_codemode', binary: mcp, args: ['codemode', '--config', serversFile, '--workspace', workspace] });
80
+ }
67
81
  if (servers.length) {
68
82
  ctx.inject(['mcpManager'], scoped => {
69
83
  for (const server of servers) {
@@ -78,16 +92,16 @@ export function apply(ctx, config = {}) {
78
92
  if (decision.kind === 'reject')
79
93
  return decision;
80
94
  const preset = ctx.get('agentPresets')?.composedPreset(agent.ctx);
81
- if (preset === 'cavecrew-investigator' || preset === 'cavecrew-builder' || preset === 'cavecrew-reviewer')
95
+ if (isCavecrewPreset(preset))
82
96
  return decision;
83
97
  const directMessages = decision.messages.filter(message => message.source.kind === 'user');
84
98
  if (directMessages.length === 0)
85
99
  return decision;
86
100
  signal.throwIfAborted();
87
- const statsRequest = directMessages.map(message => message.content
88
- .filter(block => block.type === 'text').map(block => block.text).join('\n'))
89
- .map(text => /^\/caveman(?::caveman)?-stats(?:\s+(.*))?$/u.exec(text.trim()))
90
- .reverse().find(match => match !== null);
101
+ const statsRequest = directMessages.map(message => {
102
+ const text = message.content.filter(block => block.type === 'text').map(block => block.text).join('\n');
103
+ return /^\/caveman(?::caveman)?-stats(?:\s+(.*))?$/u.exec(text.trim());
104
+ }).reverse().find(match => match !== null);
91
105
  if (statsRequest) {
92
106
  const report = await statsReport(ctx, agent.session, statsRequest[1]?.trim() ?? '', signal);
93
107
  const reminder = createUserMessage({
@@ -101,6 +115,8 @@ export function apply(ctx, config = {}) {
101
115
  const selected = modes.resolve(defaultModeFor(config.defaultMode, cwd), agent.session, directMessages);
102
116
  if (selected.action === 'one-shot' || (selected.mode === 'off' && selected.action === 'none'))
103
117
  return decision;
118
+ if (selected.action === 'none' && selected.hasRules && !getReinforce(cwd))
119
+ return decision;
104
120
  let text;
105
121
  if (selected.action === 'status') {
106
122
  text = `Report this status without changing it: Caveman mode: ${selected.mode}`;
package/lib/mode.js CHANGED
@@ -2,6 +2,7 @@ import { createRequire } from 'node:module';
2
2
  const require = createRequire(import.meta.url);
3
3
  const parser = require('../vendor/caveman/src/hooks/caveman-parse.js');
4
4
  const modeConfig = require('../vendor/caveman/src/hooks/caveman-config.js');
5
+ export const getReinforce = modeConfig.getReinforce;
5
6
  /** A profile override wins; otherwise follow environment and file resolution. */
6
7
  export function defaultModeFor(configured, cwd) {
7
8
  if (configured !== undefined)
@@ -16,10 +17,8 @@ function transition(mode, message, configured) {
16
17
  const change = parser.parseModeChange(text, { getDefaultMode: () => configured });
17
18
  if (!change)
18
19
  return { mode, action: 'none' };
19
- if (change.action === 'status')
20
- return { mode, action: 'status' };
21
- if (change.action === 'unresolved')
22
- return { mode, action: 'unresolved' };
20
+ if (change.action === 'status' || change.action === 'unresolved')
21
+ return { mode, action: change.action };
23
22
  if (change.action === 'clear')
24
23
  return { mode: 'off', action: 'change' };
25
24
  if (change.mode && parser.INDEPENDENT_MODES.has(change.mode))
@@ -65,7 +64,9 @@ export class SessionModeTracker {
65
64
  const initial = reusable ? previous.mode : configured === 'manual' ? 'off' : configured;
66
65
  const events = session.snapshotEvents(reusable ? previous.seq : undefined, end);
67
66
  const mode = replay(initial, configured, events);
68
- this.states.set(session, { seq: end, configured, mode });
69
- return resolvePending(mode, configured, pending);
67
+ const hasRules = (reusable && previous.hasRules) || events.some(event => event.type === 'user/message' && event.data.source.kind === 'dsh-caveman-mode' &&
68
+ event.data.content.some(block => block.type === 'text' && /^Caveman mode: (?:caveman|ultracave|megacave)\n\n/u.test(block.text)));
69
+ this.states.set(session, { seq: end, configured, mode, hasRules });
70
+ return { ...resolvePending(mode, configured, pending), hasRules };
70
71
  }
71
72
  }
package/lib/native.js CHANGED
@@ -2,16 +2,17 @@ import { createHash } from 'node:crypto';
2
2
  import { constants } from 'node:fs';
3
3
  import { lstat, open, realpath, stat } from 'node:fs/promises';
4
4
  import { connect } from 'node:net';
5
- import { homedir } from 'node:os';
6
5
  import { join, resolve } from 'node:path';
7
6
  import { setTimeout as delay } from 'node:timers/promises';
8
7
  import { isDeepStrictEqual } from 'node:util';
9
8
  import { createUserMessage } from '@deepseek-ai/dsh-llm';
10
9
  import { cavemanSessionId } from './attribution.js';
11
- import { verifiedRuntimeInstance } from './runtime.js';
10
+ import { cavemanHome, NATIVE_PROFILES, verifiedRuntimeInstance } from './runtime.js';
12
11
  import { isManagedTool } from './compression.js';
13
- const profiles = new Set(['record-only', 'core', 'core-lean-build', 'ledger', 'ccr-masking', 'cache-aware', 'full-safe', 'full-max']);
14
12
  const stopwords = new Set(['about', 'after', 'again', 'agent', 'before', 'build', 'change', 'code', 'could', 'create', 'does', 'from', 'have', 'help', 'implement', 'into', 'make', 'please', 'project', 'repository', 'should', 'spec', 'task', 'that', 'their', 'then', 'there', 'these', 'they', 'this', 'through', 'user', 'want', 'what', 'when', 'where', 'which', 'with', 'would', 'your']);
13
+ export function isCavecrewPreset(preset) {
14
+ return preset === 'cavecrew-investigator' || preset === 'cavecrew-builder' || preset === 'cavecrew-reviewer';
15
+ }
15
16
  /** Confirm that the model's assembled tool surface includes the admitted MCP recovery tool. */
16
17
  export function recoveryIsPublished(assembly, tool) {
17
18
  const direct = assembly.tools.find(entry => entry.name === tool.name);
@@ -49,7 +50,6 @@ export function nativePrompt(prompt) {
49
50
  const bytes = Buffer.from(prompt, 'utf8');
50
51
  return { prompt: { bytes: bytes.length, sha256: `sha256:${createHash('sha256').update(bytes).digest('hex')}` }, task_profile: { type, terms: [...seen], continuation } };
51
52
  }
52
- /** Return the supported local socket endpoint, if available on this platform. */
53
53
  export function nativeSocketPath(home, platform = process.platform) {
54
54
  // The current Windows runtime has no pipe peer proof, and its HTTP health
55
55
  // check only verifies the HTTP listener. Keep native events local to DSH.
@@ -64,7 +64,7 @@ function validResponse(value) {
64
64
  return false;
65
65
  if (response.policy_mode !== undefined && !['record', 'safe', 'max'].includes(String(response.policy_mode)))
66
66
  return false;
67
- if (response.profile !== undefined && !profiles.has(String(response.profile)))
67
+ if (response.profile !== undefined && !NATIVE_PROFILES.has(String(response.profile)))
68
68
  return false;
69
69
  for (const [key, maximum] of [['context', 65536], ['message', 4096], ['output_replacement', 2097152], ['recovery_ref', 1024], ['decision_id', 256]]) {
70
70
  const field = response[key];
@@ -218,9 +218,12 @@ async function runtimeInstance(endpoint, home, signal) {
218
218
  }
219
219
  /** Add dynamic native task context when the verified local runtime is running. */
220
220
  export function registerNative(ctx, endpoint, policy) {
221
- const home = process.env.CAVEMAN_HOME ?? join(homedir(), '.caveman');
221
+ const home = cavemanHome();
222
222
  if (!nativeSocketPath(home))
223
223
  return;
224
+ const envelope = (session) => ({
225
+ protocol_version: 1, policy_mode: policy.mode, profile: policy.profile, agent: { id: 'dsh', surface: 'dsh' }, session,
226
+ });
224
227
  const sessions = new WeakMap();
225
228
  const owners = new WeakMap();
226
229
  const selections = new WeakMap();
@@ -236,7 +239,7 @@ export function registerNative(ctx, endpoint, policy) {
236
239
  if (decision.kind === 'reject')
237
240
  return decision;
238
241
  const preset = ctx.get('agentPresets')?.composedPreset(agent.ctx);
239
- const specialized = preset === 'cavecrew-investigator' || preset === 'cavecrew-builder' || preset === 'cavecrew-reviewer';
242
+ const specialized = isCavecrewPreset(preset);
240
243
  const existing = sessions.get(agent);
241
244
  if (existing?.queue)
242
245
  await existing.queue;
@@ -286,8 +289,7 @@ export function registerNative(ctx, endpoint, policy) {
286
289
  const parent = agent.session.header.origin === 'subagent' && agent.session.header.parentSession
287
290
  ? cavemanSessionId(String(agent.session.header.parentSession)) : undefined;
288
291
  const session = { caveman_session_id: id, host_session_id: id, cwd, ...(parent ? { parent_session_id: parent } : {}) };
289
- const base = { protocol_version: 1, policy_mode: policy.mode, profile: policy.profile, agent: { id: 'dsh', surface: 'dsh' }, session,
290
- model: { provider: modelSelection.provider, model: modelSelection.model } };
292
+ const base = { ...envelope(session), model: { provider: modelSelection.provider, model: modelSelection.model } };
291
293
  const current = sessions.get(agent);
292
294
  if (!current || current.instance !== instance) {
293
295
  const started = await nativeCall(home, { ...base, event: { type: 'session.start', timestamp_ms: Date.now() } }, signal);
@@ -321,8 +323,7 @@ export function registerNative(ctx, endpoint, policy) {
321
323
  const task = (state.queue ?? Promise.resolve()).then(async () => {
322
324
  if (sessions.get(agent) !== state || await runtimeInstance(endpoint, home) !== state.instance)
323
325
  return;
324
- const response = await nativeCall(home, { protocol_version: 1, policy_mode: policy.mode, profile: policy.profile,
325
- agent: { id: 'dsh', surface: 'dsh' }, session: state.session,
326
+ const response = await nativeCall(home, { ...envelope(state.session),
326
327
  event: { type: kind === 'compaction/start' ? 'context.compact.before' : 'context.compact.after', timestamp_ms: Date.now() } });
327
328
  if (response)
328
329
  state.confirmed = true;
@@ -343,7 +344,7 @@ export function registerNative(ctx, endpoint, policy) {
343
344
  sessions.delete(exec.agent);
344
345
  return next();
345
346
  }
346
- const base = { protocol_version: 1, policy_mode: policy.mode, profile: policy.profile, agent: { id: 'dsh', surface: 'dsh' }, session: state.session };
347
+ const base = envelope(state.session);
347
348
  const beforeState = exec.name === 'read' ? await inputState(ctx, state.session.cwd, exec.arguments, exec.signal) : undefined;
348
349
  const before = await nativeCall(home, { ...base, event: { type: 'tool.before', timestamp_ms: Date.now() },
349
350
  tool: { name: exec.name, input: exec.arguments, ...(beforeState ? { input_state: beforeState } : {}) } }, exec.signal);
@@ -380,8 +381,7 @@ export function registerNative(ctx, endpoint, policy) {
380
381
  const task = (state.queue ?? Promise.resolve()).then(async () => {
381
382
  if (await runtimeInstance(endpoint, home) !== state.instance)
382
383
  return;
383
- const base = { protocol_version: 1, policy_mode: policy.mode, profile: policy.profile,
384
- agent: { id: 'dsh', surface: 'dsh' }, session: state.session };
384
+ const base = envelope(state.session);
385
385
  if (state.session.parent_session_id && !await nativeCall(home, { ...base, event: { type: 'subagent.stop', timestamp_ms: Date.now() } }))
386
386
  return;
387
387
  await nativeCall(home, { ...base, event: { type: 'session.end', timestamp_ms: Date.now() } });
package/lib/runtime.js CHANGED
@@ -3,6 +3,10 @@ import { request as httpRequest } from 'node:http';
3
3
  import { homedir } from 'node:os';
4
4
  import { delimiter, isAbsolute, join, resolve } from 'node:path';
5
5
  import { Readable } from 'node:stream';
6
+ export const NATIVE_PROFILES = new Set(['record-only', 'core', 'core-lean-build', 'ledger', 'ccr-masking', 'cache-aware', 'full-safe', 'full-max']);
7
+ export function cavemanHome(env = process.env) {
8
+ return env.CAVEMAN_HOME ?? join(homedir(), '.caveman');
9
+ }
6
10
  function executable(path) {
7
11
  try {
8
12
  accessSync(path, constants.X_OK);
@@ -45,7 +49,7 @@ export function findCavemanBinary(kind, configured, env = process.env) {
45
49
  if (onPath)
46
50
  return onPath;
47
51
  const filename = process.platform === 'win32' ? `${name}.exe` : name;
48
- const local = resolve(env.CAVEMAN_HOME ?? join(homedir(), '.caveman'), 'bin', filename);
52
+ const local = resolve(cavemanHome(env), 'bin', filename);
49
53
  return executable(local) ? local : undefined;
50
54
  }
51
55
  function object(value) {
@@ -53,10 +57,9 @@ function object(value) {
53
57
  }
54
58
  function configDocument(env) {
55
59
  try {
56
- const home = env.CAVEMAN_HOME ?? join(homedir(), '.caveman');
57
60
  let raw;
58
61
  try {
59
- raw = readFileSync(join(home, 'cloud.json'), 'utf8');
62
+ raw = readFileSync(join(cavemanHome(env), 'cloud.json'), 'utf8');
60
63
  }
61
64
  catch (error) {
62
65
  if (error.code !== 'ENOENT')
@@ -81,7 +84,6 @@ function booleanSetting(value) {
81
84
  return false;
82
85
  return undefined;
83
86
  }
84
- /** Read the module switches and native coding policy in one configuration snapshot. */
85
87
  export function runtimeSettings(env = process.env) {
86
88
  const document = configDocument(env);
87
89
  const modules = object(document.modules);
@@ -95,15 +97,15 @@ export function runtimeSettings(env = process.env) {
95
97
  const mcp = mcpMode !== 'marker-only' && booleanSetting(mcpMode) !== false;
96
98
  const memory = booleanSetting(object(document.remember).mem) ?? true;
97
99
  const configuredCore = booleanSetting(env.CAVEMAN_CORE) ?? booleanSetting(think.core ?? wrap.core) ?? explicit(modules.output) ?? true;
98
- const profile = env.CAVEMAN_NATIVE_PROFILE?.trim().toLowerCase();
99
- const profiles = ['record-only', 'core', 'core-lean-build', 'ledger', 'ccr-masking', 'cache-aware', 'full-safe', 'full-max'];
100
+ const profile = env.CAVEMAN_NATIVE_PROFILE?.trim().toLowerCase() ?? '';
101
+ const supportedProfile = NATIVE_PROFILES.has(profile);
100
102
  const configuredMode = env.CAVEMAN_NATIVE_MODE?.trim().toLowerCase();
101
103
  const proxyMode = env.CAVEMAN_WRAP_MODE ?? think.mode ?? wrap.mode ?? 'compress';
102
- const nativeMode = profile && !profiles.includes(profile) || profile === 'record-only'
104
+ const nativeMode = profile && !supportedProfile || profile === 'record-only'
103
105
  ? 'record'
104
106
  : configuredMode ? configuredMode === 'safe' || configuredMode === 'max' ? configuredMode : 'record'
105
107
  : proxyMode === 'record' ? 'record' : proxyMode === 'pixel' ? 'max' : 'safe';
106
- const nativeProfile = profile && profiles.includes(profile) ? profile : nativeMode === 'record' ? 'record-only' : nativeMode === 'max' ? 'full-max' : 'full-safe';
108
+ const nativeProfile = supportedProfile ? profile : nativeMode === 'record' ? 'record-only' : nativeMode === 'max' ? 'full-max' : 'full-safe';
107
109
  const core = configuredCore && nativeMode !== 'record' && nativeProfile !== 'record-only';
108
110
  return { input, scripts, browse, mcp, memory, core, coreLeanBuild: core && nativeProfile === 'core-lean-build', nativeMode, nativeProfile };
109
111
  }
@@ -111,7 +113,7 @@ export function runtimeSettings(env = process.env) {
111
113
  export function moduleEnabled(kind, env = process.env) {
112
114
  return runtimeSettings(env)[kind];
113
115
  }
114
- function localOrigin(endpoint) {
116
+ export function localOrigin(endpoint) {
115
117
  try {
116
118
  const url = new URL(endpoint);
117
119
  if (url.protocol !== 'http:' || url.username || url.password || !['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname))
@@ -162,7 +164,7 @@ async function directLocalFetch(input, init) {
162
164
  }
163
165
  /** Verify that the loopback listener matches the runtime's private run-state record. */
164
166
  export async function verifiedRuntime(endpoint, env = process.env, signal) {
165
- return Boolean(await verifiedRuntimeInstance(endpoint, env.CAVEMAN_HOME ?? join(homedir(), '.caveman'), signal));
167
+ return Boolean(await verifiedRuntimeInstance(endpoint, cavemanHome(env), signal));
166
168
  }
167
169
  /** Reuse a recent health check only while the private run-state record is unchanged. */
168
170
  export async function verifiedRuntimeInstance(endpoint, home, signal, cached) {
package/lib/skills.js CHANGED
@@ -10,7 +10,6 @@ const NAMES = [
10
10
  'caveman-manage', 'caveman-optimize', 'caveman-evidence-review', 'caveman-setup',
11
11
  'investigate-first', 'lean-build', 'migration', 'safe-refactor', 'surgical-patch', 'verify-and-stop',
12
12
  ];
13
- const knownNames = new Set(NAMES);
14
13
  async function readSkill(root, name, signal) {
15
14
  const path = join(root, name, 'SKILL.md');
16
15
  const raw = await readFile(path, { encoding: 'utf8', signal });
@@ -30,7 +29,6 @@ async function readSkill(root, name, signal) {
30
29
  userInvocable: fields['user-invocable'] !== false,
31
30
  };
32
31
  }
33
- /** Expose skills through the DSH provider registry. */
34
32
  export function createSkillProvider(root, control) {
35
33
  if (!isAbsolute(root))
36
34
  throw new Error('dsh-caveman: skill root must be absolute');
@@ -48,13 +46,11 @@ export function createSkillProvider(root, control) {
48
46
  };
49
47
  }));
50
48
  signal?.throwIfAborted();
51
- return {
52
- candidates: results.flatMap(result => result.status === 'fulfilled' ? [result.value] : []),
53
- complete: results.every(result => result.status === 'fulfilled'),
54
- };
49
+ const candidates = results.flatMap(result => result.status === 'fulfilled' ? [result.value] : []);
50
+ return { candidates, complete: candidates.length === results.length };
55
51
  },
56
52
  async get(candidate, { signal }) {
57
- if (!knownNames.has(candidate.name) || candidate.locator !== candidate.name)
53
+ if (!NAMES.includes(candidate.name) || candidate.locator !== candidate.name)
58
54
  return undefined;
59
55
  try {
60
56
  const { content } = await readSkill(root, candidate.name, signal);
package/lib/stats.js CHANGED
@@ -72,7 +72,7 @@ function linesFor(counts) {
72
72
  }
73
73
  function parseOptions(flags) {
74
74
  const result = { all: false, share: false };
75
- const args = flags.trim() ? flags.trim().split(/\s+/u) : [];
75
+ const args = flags.match(/\S+/gu) ?? [];
76
76
  for (let index = 0; index < args.length; index++) {
77
77
  const arg = args[index];
78
78
  if (arg === '--all')
@@ -80,31 +80,27 @@ function parseOptions(flags) {
80
80
  else if (arg === '--share')
81
81
  result.share = true;
82
82
  else if (arg === '--since') {
83
- const label = args[++index];
84
- const match = label ? /^(\d+)([dh])$/u.exec(label) : null;
85
- if (!match)
86
- throw new Error('--since takes Nh or Nd (for example, 24h or 7d)');
87
- const quantity = Number(match[1]);
88
- if (!Number.isSafeInteger(quantity) || quantity < 0)
83
+ const match = /^(\d+)([dh])$/u.exec(args[++index] ?? '');
84
+ const quantity = Number(match?.[1]);
85
+ if (!match || !Number.isSafeInteger(quantity))
89
86
  throw new Error('--since takes Nh or Nd (for example, 24h or 7d)');
90
87
  const milliseconds = quantity * (match[2] === 'd' ? 86_400_000 : 3_600_000);
91
88
  if (!Number.isSafeInteger(milliseconds))
92
89
  throw new Error('--since duration is too large');
93
- result.since = { label: label, milliseconds };
90
+ result.since = { label: match[0], milliseconds };
94
91
  }
95
92
  else
96
93
  throw new Error(`Unknown statistics option: ${arg}`);
97
94
  }
98
95
  return result;
99
96
  }
97
+ function formatSessionStats(events, options) {
98
+ const counts = countsFor(events);
99
+ return options.share ? sharedReport(counts) : ['DSH session usage (recorded assistant messages only)', ...linesFor(counts)].join('\n');
100
+ }
100
101
  /** Report recorded message usage without claiming savings or unreported counts. */
101
102
  export function sessionStats(events, flags) {
102
- const options = parseOptions(flags);
103
- const counts = countsFor(events);
104
- if (options.share) {
105
- return sharedReport(counts);
106
- }
107
- return ['DSH session usage (recorded assistant messages only)', ...linesFor(counts)].join('\n');
103
+ return formatSessionStats(events, parseOptions(flags));
108
104
  }
109
105
  /** Aggregate each live or stored session once, excluding fork-inherited events. */
110
106
  export async function statsReport(ctx, current, flags, signal) {
@@ -117,7 +113,7 @@ export async function statsReport(ctx, current, flags, signal) {
117
113
  return error.message;
118
114
  }
119
115
  if (!options.all && !options.since)
120
- return sessionStats(current.snapshotEvents(current.inheritedEventCount), flags);
116
+ return formatSessionStats(current.snapshotEvents(current.inheritedEventCount), options);
121
117
  const totals = countsFor([]);
122
118
  const live = ctx.get('sessions')?.list() ?? [current];
123
119
  const known = new Set(live.map(session => String(session.id)));
@@ -1,5 +1,4 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
- /** Attribute only requests routed to the configured loopback proxy. */
3
2
  export declare function cavemanSessionId(sessionId: string): string;
4
3
  export declare function cavemanRequestHeaders(endpoint: string, request: {
5
4
  baseURL: string;
@@ -24,7 +24,10 @@ export interface Config {
24
24
  browseBinary?: string;
25
25
  mcpBinary?: string;
26
26
  memoryBinary?: string;
27
+ codeMode?: false | {
28
+ config: string;
29
+ workspace: string;
30
+ };
27
31
  }
28
32
  export declare const Config: z<Config>;
29
- /** Register skills and reinforce the selected mode per session. */
30
33
  export declare function apply(ctx: Context, config?: Config): void;
@@ -15,6 +15,7 @@ interface InputEvent {
15
15
  readonly type: string;
16
16
  readonly data: unknown;
17
17
  }
18
+ export declare const getReinforce: (startDir?: string) => boolean;
18
19
  /** A profile override wins; otherwise follow environment and file resolution. */
19
20
  export declare function defaultModeFor(configured: DefaultMode | undefined, cwd?: string): DefaultMode;
20
21
  /** Replay only user-authored messages, then evaluate the incoming batch. */
@@ -28,6 +29,7 @@ export declare class SessionModeTracker {
28
29
  resolve(configured: DefaultMode, session: Session, pending: readonly InputMessage[]): {
29
30
  mode: VoiceMode;
30
31
  action: ModeAction;
32
+ hasRules: boolean;
31
33
  };
32
34
  }
33
35
  export {};
@@ -17,6 +17,7 @@ interface NativeResponse {
17
17
  fail_open: true;
18
18
  context?: string;
19
19
  }
20
+ export declare function isCavecrewPreset(preset: string | undefined): boolean;
20
21
  /** Confirm that the model's assembled tool surface includes the admitted MCP recovery tool. */
21
22
  export declare function recoveryIsPublished(assembly: Pick<PromptAssembly, 'tools' | 'sections'>, tool: ToolDefinition): boolean;
22
23
  /** Hash and classify the prompt locally; the runtime does not receive the prompt text. */
@@ -31,7 +32,6 @@ export declare function nativePrompt(prompt: string): {
31
32
  continuation: boolean;
32
33
  };
33
34
  };
34
- /** Return the supported local socket endpoint, if available on this platform. */
35
35
  export declare function nativeSocketPath(home: string, platform?: NodeJS.Platform): string | undefined;
36
36
  export declare function nativeCall(home: string, request: object, signal?: AbortSignal): Promise<NativeResponse | undefined>;
37
37
  /** Add dynamic native task context when the verified local runtime is running. */
@@ -1,8 +1,9 @@
1
1
  type Binary = 'blocks' | 'browse' | 'mcp' | 'memory';
2
2
  type Module = 'scripts' | 'browse' | 'input';
3
+ export declare const NATIVE_PROFILES: ReadonlySet<string>;
4
+ export declare function cavemanHome(env?: NodeJS.ProcessEnv): string;
3
5
  /** Find a configured binary, PATH command, or the CLI's installation. */
4
6
  export declare function findCavemanBinary(kind: Binary, configured?: string, env?: NodeJS.ProcessEnv): string | undefined;
5
- /** Read the module switches and native coding policy in one configuration snapshot. */
6
7
  export declare function runtimeSettings(env?: NodeJS.ProcessEnv): {
7
8
  input: boolean;
8
9
  scripts: boolean;
@@ -16,6 +17,7 @@ export declare function runtimeSettings(env?: NodeJS.ProcessEnv): {
16
17
  };
17
18
  /** Modules default to on; a saved explicit off is respected. */
18
19
  export declare function moduleEnabled(kind: Module, env?: NodeJS.ProcessEnv): boolean;
20
+ export declare function localOrigin(endpoint: string): URL | undefined;
19
21
  /** Verify that the loopback listener matches the runtime's private run-state record. */
20
22
  export declare function verifiedRuntime(endpoint: string, env?: NodeJS.ProcessEnv, signal?: AbortSignal): Promise<boolean>;
21
23
  export interface VerifiedRuntimeInstance {
@@ -1,3 +1,2 @@
1
1
  import type { SkillProvider, SkillProviderControl } from '@deepseek-ai/dsh-skill';
2
- /** Expose skills through the DSH provider registry. */
3
2
  export declare function createSkillProvider(root: string, control?: SkillProviderControl): SkillProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lornatang/dsh-caveman",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Caveman integration for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -75,7 +75,7 @@
75
75
  }
76
76
  },
77
77
  "dependencies": {
78
- "@caveman-ai/cli": "4.1.0",
78
+ "@caveman-ai/cli": "4.2.0",
79
79
  "@caveman-ai/sdk": "1.2.0",
80
80
  "@deepseek-ai/schemastery": "~3.19.0",
81
81
  "undici": "^8.12.4",
@@ -1,29 +1,29 @@
1
1
  {
2
- "version": "0.1.11",
2
+ "version": "0.1.13",
3
3
  "binaries": {
4
4
  "linux-x64": {
5
5
  "name": "dsh-caveman-learn_linux_amd64",
6
- "sha256": "44ba840775952ee1e8f568a25f43fac236926b0d1ea2aebfdf5d0ce8e8c497af"
6
+ "sha256": "030472af90cfe270db5eca21de8ae3774dde68374cf7e7302cd3946e321d2174"
7
7
  },
8
8
  "linux-arm64": {
9
9
  "name": "dsh-caveman-learn_linux_arm64",
10
- "sha256": "74efd959b4a684abfd70a56b65b5d515e42d961d49d8cd6420e829ad8aea2f3d"
10
+ "sha256": "fb5aeef95e1a170879154d0ed613f9a1626d52e9239db3babe2150562defbed7"
11
11
  },
12
12
  "darwin-x64": {
13
13
  "name": "dsh-caveman-learn_darwin_amd64",
14
- "sha256": "12b351a47a3b0eaec6ce874315bb27feb7a01db2215c81c0f8fcd3358f6cbd8f"
14
+ "sha256": "300ee7c738dddba8ac924ac49b7df9b35f277553a359334db792c2aca4c74be2"
15
15
  },
16
16
  "darwin-arm64": {
17
17
  "name": "dsh-caveman-learn_darwin_arm64",
18
- "sha256": "b3e4566e3d04170cd777c9793a71995edfe91cabccf6a87897109cebaa39a105"
18
+ "sha256": "704f0c3eaf6d9c7aac0b2d60f963589f9dfde2b244ba37e5a8fb516e99b5896c"
19
19
  },
20
20
  "win32-x64": {
21
21
  "name": "dsh-caveman-learn_win32_amd64",
22
- "sha256": "bf305bfaff6e4ad2f1a6e399d2191e0a179f7096de05283d027d99f2a9b3f2af"
22
+ "sha256": "2c5849cb55f354f1a21989f08567358921d1cf1960c9c330d187ce42a9b02843"
23
23
  },
24
24
  "win32-arm64": {
25
25
  "name": "dsh-caveman-learn_win32_arm64",
26
- "sha256": "a03b3c3cc71264a8d5777cd807a69e7ea28a02e0d502b228578b30c9161c1593"
26
+ "sha256": "303091eea771dc9dc1d09c3cbf5e65d3ceb1d7d0098e8781b82b91a216c6da16"
27
27
  }
28
28
  }
29
29
  }
@@ -2,17 +2,16 @@
2
2
 
3
3
  ## New: Caveman Code. Free.
4
4
 
5
- **The most efficient coding agent.** Same model, same work, smaller bill.
5
+ **21% less than Codex per solved task on Terminal-Bench 4.** Same model on both sides.
6
6
 
7
7
  <table>
8
8
  <tr>
9
- <td align="center"><h3>21% cheaper</h3>than Codex<br><sub>Terminal-Bench 4, per solved task</sub></td>
10
- <td align="center"><h3>14% cheaper</h3>than Claude Code<br><sub>Terminal-Bench 4, 97 vs 83 solved</sub></td>
11
- <td align="center"><h3>76% cheaper</h3>than Claude Code<br><sub>full workday, 4 connected apps</sub></td>
9
+ <td align="center"><h3>21% cheaper</h3>than Codex<br><sub>Terminal-Bench 4, per solved task, GPT-6.1 Sol: $1.21 vs $1.52, 90 of 192 runs solved both</sub></td>
10
+ <td align="center"><h3>Level</h3>with Claude Code within noise<br><sub>Terminal-Bench 4, Opus 5.5: 97 of 180 runs solved vs 83 of 177; $5.19 vs $6.04 per solved task, 95% interval 0.70x to 1.02x</sub></td>
12
11
  </tr>
13
12
  </table>
14
13
 
15
- <sub>Same model on both sides: GPT-6.1 Sol against Codex, Opus 5.5 against Claude Code. Our own runs, November 2026, at list prices. <a href="https://caveman.so/code">How we measured</a></sub>
14
+ <sub>Measured build, benchmark settings on, not the shipped app: the app ships the same harness with three benchmark-only settings turned off. Same model on both sides: GPT-6.1 Sol against Codex, Opus 5.5 against Claude Code. Our own runs, November 2026, at list prices. <a href="https://caveman.so/code#benchmarks">How we measured</a></sub>
16
15
 
17
16
  Every coding agent in one window. Free on the subscriptions and keys you already have.
18
17
 
@@ -33,8 +32,8 @@ Every coding agent in one window. Free on the subscriptions and keys you already
33
32
 
34
33
  <table>
35
34
  <tr>
36
- <td align="center" width="25%"><h3>33.2% fewer</h3>input tokens, whole sessions<br><sub><a href="#read-less-332-fewer-input-tokens">54 Claude Code runs</a>, 18 of 18 answers right</sub></td>
37
- <td align="center" width="25%"><h3>54% cheaper</h3>with Auto, same score<br><sub><a href="#auto-54-cheaper-same-score">85 coding tasks</a> vs Opus 5.5 at xhigh, interim</sub></td>
35
+ <td align="center" width="25%"><h3>33.2% fewer</h3>input tokens, whole sessions<br><sub><a href="#read-less-332-fewer-input-tokens">6 synthetic large-tool-output tasks, 18 pairs</a>, Aug 2026 engine, 18 of 18 answers right</sub></td>
36
+ <td align="center" width="25%"><h3>0.46×</h3>the cost of Opus at xhigh, with Auto<br><sub><a href="#auto-046x-the-cost-of-opus-at-xhigh-interim">85 coding tasks</a>, interim, score gap ±7 points, unresolved</sub></td>
38
37
  <td align="center" width="25%"><h3>397 → 76</h3>tokens for one test run<br><sub><a href="#blocks-code-mode-script-written-once">Blocks</a> vs <code>| tail -20</code></sub></td>
39
38
  <td align="center" width="25%"><h3>1.4 to 2.4× cheaper</h3>with caveman-style output<br><sub><a href="https://arxiv.org/abs/2606.24083">Adobe Research</a>, eight models</sub></td>
40
39
  </tr>
@@ -43,7 +42,7 @@ Every coding agent in one window. Free on the subscriptions and keys you already
43
42
  Cited by **[Adobe Research](https://arxiv.org/abs/2606.24083)** · A/B tested by **[JetBrains](https://blog.jetbrains.com/ai/2026/07/speak-to-ai-agents-like-cavemen-tosave-tokens/)** · Remade for Elasticsearch on **[Elasticsearch Labs](https://www.elastic.co/search-labs/blog/elastic-caveman-ai-token-reduction)**<br>
44
43
  **#1** on [Hacker News](https://news.ycombinator.com/item?id=47647455) · **#1** on GitHub Trending · *"No way this actually works."* [ThePrimeagen](https://www.youtube.com/watch?v=L29q2LRiMRc)
45
44
 
46
- **[Install](#install) · [Six rocks](#six-rocks-one-install) · [Proof](#proof) · [Say less](#say-less-the-caveman-voice) · [Read less](#read-less-332-fewer-input-tokens) · [Auto](#auto-54-cheaper-same-score) · [Blocks](#blocks-code-mode-script-written-once) · [Commands](#commands) · [Caveman Cloud](#caveman-cloud)**
45
+ **[Install](#install) · [Six rocks](#six-rocks-one-install) · [Proof](#proof) · [Say less](#say-less-the-caveman-voice) · [Read less](#read-less-332-fewer-input-tokens) · [Auto](#auto-046x-the-cost-of-opus-at-xhigh-interim) · [Blocks](#blocks-code-mode-script-written-once) · [Commands](#commands) · [Caveman Cloud](#caveman-cloud)**
47
46
 
48
47
  </div>
49
48
 
@@ -76,7 +75,7 @@ Pick your club:
76
75
  |---|---|---:|
77
76
  | `/caveman` | New object ref each render, so React re-renders. Wrap the prop in `useMemo`. | 20 |
78
77
  | `/ultracave` | Inline object prop, new ref, re-render. `useMemo`. | 14 |
79
- | `/megacave` | 新參照致重繪。`useMemo`。 | **13** |
78
+ | `/megacave` | 新參照致重繪。`useMemo`。 | 13 |
80
79
 
81
80
  <sub>Token counts: tiktoken o200k.</sub>
82
81
 
@@ -98,12 +97,12 @@ New in 4.0: caveman is six parts. All on after install. Each has its own switch.
98
97
 
99
98
  | Rock | What it does | Measured |
100
99
  |---|---|---|
101
- | **[Say less](#say-less-the-caveman-voice)** | Agent answers short. Code stays exact | 63 → 20 tokens, same fix |
102
- | **[Read less](#read-less-332-fewer-input-tokens)** | Logs, JSON, CSV, test output shrink before the model reads them | **33.2%** fewer input tokens per session |
103
- | **[Auto](#auto-54-cheaper-same-score)** · new | Picks the model and the effort for each ask | **54%** cheaper than Opus at xhigh, same score |
100
+ | **[Say less](#say-less-the-caveman-voice)** | Agent answers short. Code stays exact | 3% shorter than "Answer concisely." (ultracave 35%), n=10 |
101
+ | **[Read less](#read-less-332-fewer-input-tokens)** | Logs, JSON, CSV, test output shrink before the model reads them | **33.2%** fewer input tokens per session (6 synthetic large-tool-output tasks, 18 pairs, Aug 2026 engine) |
102
+ | **[Auto](#auto-046x-the-cost-of-opus-at-xhigh-interim)** · new | Picks the model and the effort for each ask | 0.46× the cost of Opus at xhigh in an interim run (85 tasks); quality gap unresolved |
104
103
  | **[Blocks](#blocks-code-mode-script-written-once)** · new | Code mode: agent keeps the scripts it writes and runs them again | **397 → 76** tokens for one test run |
105
104
  | **[Waste fixes](#smaller-rocks)** | Finds where your tokens go and fixes it. New: keeps the prompt cache warm while you pause | Not measured yet |
106
- | **[Browse](#smaller-rocks)** | Web pages come back compressed | **129.8×** smaller page |
105
+ | **[Browse](#smaller-rocks)** | Web pages come back compressed | 14.9% smaller full page than Playwright; 121 vs 15,704 tokens with a query, on one 200-row table |
107
106
 
108
107
  `caveman status` shows what is on. `caveman off browse` turns one off. Only Auto needs an account, and it is free. [4.0.0 release notes](https://github.com/JuliusBrussee/caveman/releases/tag/v4.0.0)
109
108
 
@@ -133,7 +132,7 @@ Two findings shaped caveman. Adobe: cavemanning *your* prompt makes answers wors
133
132
  | **Knows when to stop** | Security warnings, irreversible actions, and confused users get full sentences. Then grunt resumes |
134
133
  | **Your prompts stay yours** | Never rewritten. [Research say that backfire](#proof) |
135
134
 
136
- Ten dev questions on claude-opus-5-5:
135
+ Example run, n=10, not a claim. Ten dev questions on claude-opus-5-5:
137
136
 
138
137
  | Instruction | Output tokens |
139
138
  |---|---:|
@@ -172,7 +171,7 @@ claude plugin marketplace add JuliusBrussee/caveman && claude plugin install cav
172
171
  gemini extensions install https://github.com/JuliusBrussee/caveman
173
172
 
174
173
  # Every agent on your machine at once, plus the Claude Code statusline badge (Node.js 22.13+)
175
- curl -fsSL https://raw.githubusercontent.com/JuliusBrussee/caveman/v4.1.0/install.sh | bash
174
+ curl -fsSL https://raw.githubusercontent.com/JuliusBrussee/caveman/v4.2.0/install.sh | bash
176
175
  ```
177
176
 
178
177
  Already inside Claude Code? Same rock, slash form. Type these where you talk to Claude:
@@ -185,23 +184,23 @@ Already inside Claude Code? Same rock, slash form. Type these where you talk to
185
184
  Windows, PowerShell 5.1+:
186
185
 
187
186
  ```powershell
188
- irm https://raw.githubusercontent.com/JuliusBrussee/caveman/v4.1.0/install.ps1 | iex
187
+ irm https://raw.githubusercontent.com/JuliusBrussee/caveman/v4.2.0/install.ps1 | iex
189
188
  ```
190
189
 
191
190
  On npm 12 or newer, new npm block git install. One-liners above handle it themselves from v3.2.0 on. Old one-liner pinned to v3.1.0 or older still fail there: use one above, or this:
192
- `npx --allow-git=root -y github:JuliusBrussee/caveman#v4.1.0`
191
+ `npx --allow-git=root -y github:JuliusBrussee/caveman#v4.2.0`
193
192
 
194
193
  Changed your mind: `npx -y github:JuliusBrussee/caveman -- --uninstall` (on npm 12+, add `--allow-git=root` too)
195
194
 
196
195
  Only grabbed the skill? `npx skills remove JuliusBrussee/caveman -g` take it back out.
197
196
 
198
- Install broke? Open your agent in this repo and say *"Read CLAUDE.md and INSTALL.md, install caveman for me."* Agent fix own brain.
197
+ Install broke? Open your agent in this repo and say *"Read INSTALL.md, install caveman for me."* Agent fix own brain.
199
198
 
200
199
  </details>
201
200
 
202
201
  ## Read less: 33.2% fewer input tokens
203
202
 
204
- **The voice shrinks what the agent says. This shrinks what it reads. Same answers: 18 of 18 right.**
203
+ **The voice shrinks what the agent says. This shrinks what it reads. Same answers: 18 of 18 right.** 6 synthetic large-tool-output tasks, 18 pairs, Aug 2026 engine.
205
204
 
206
205
  | File type | The file, through caveman | File saved | Whole Claude Code session, 3 runs | Session saved |
207
206
  |---|---:|---:|---:|---:|
@@ -213,11 +212,11 @@ Install broke? Open your agent in this repo and say *"Read CLAUDE.md and INSTALL
213
212
  | HTML | 21,670 → 21,670 | none yet | 140,687 → 154,641 | 9.9% worse |
214
213
  | **All six** | 130,611 → 22,994 | 82.4% | **885,793 → 591,673** | **33.2%** |
215
214
 
216
- *The file* is each test file through today's compressor alone. *The session* is the whole agent run, which also carries the system prompt and tools, so it moves less. Honest part: the session run is from August 2026 on an older engine, HTML has no compressor yet so it lost, and each test file hides one record in 61 to 72 KB of noise. Yours will vary. Headroom on the same suite: 15 of 18 right, 6.7% fewer tokens. [Method](./docs/WRAP-BENCHMARK.md#per-file-compression)
215
+ *The file* is each test file through today's compressor alone. *The session* is the whole agent run, which also carries the system prompt and tools, so it moves less. Honest part: the session run is from August 2026 on an older engine, HTML has no compressor yet so it lost, and each test file hides one record in 61 to 72 KB of noise. Yours will vary. Headroom on the same suite: 15 of 18 right, 6.7% fewer tokens (interval crosses zero; harness not public). [Method](./docs/WRAP-BENCHMARK.md#per-file-compression)
217
216
 
218
217
  Every original stays on your disk. The agent can pull it back any time.
219
218
 
220
- ## Auto: 54% cheaper, same score
219
+ ## Auto: 0.46x the cost of Opus at xhigh (interim)
221
220
 
222
221
  **New model in your agent's picker. Pick Auto and caveman chooses the model and the effort for each ask. Hard ask, big brain. Easy ask, save rocks.**
223
222
 
@@ -1,32 +0,0 @@
1
- # skills/caveman-learn — the Caveman Learn editing skill (Apache-2.0, public)
2
-
3
- The consent-gated half of `caveman learn`. The analyzer (the Go proxy) **measures**
4
- where an agent's tokens go and writes a ranked plan; this skill is what an agent
5
- loads to **act** on that plan — proposing each fix and applying it only with the
6
- user's per-edit yes. It is the loop-closer the learn spec §10
7
- describes, plus the new `cavemem_offload` move.
8
-
9
- ## Layout
10
- - `SKILL.md` — the canonical skill body (frontmatter `name: caveman-learn` + a
11
- trigger-phrase `description`; body = the read-plan → per-class consent loop). This
12
- file is the source of truth.
13
- - `tests/skill-file.test.mjs` — asserts the canonical file is well-formed and honest
14
- (frontmatter present; the net-token-negative gate, the never-make-the-agent-dumber
15
- guard, consent-per-edit, and reversibility are all stated; no imperative for
16
- behavioral findings; no placeholders).
17
-
18
- ## Install path
19
- `caveman tools skills install caveman-learn` (in `../../cli/src/index.ts`) writes this file
20
- into a repo's `.claude/skills/caveman-learn/SKILL.md` (Claude Code) or
21
- `~/.codex/skills/caveman-learn/SKILL.md` (Codex). The CLI **embeds a byte-identical copy**
22
- (`CAVEMAN_LEARN_SKILL_MD`) because the published CLI ships no sibling assets;
23
- `../../cli/tests/skills.runtime.mjs` asserts the embedded copy equals this canonical
24
- file (the drift guard). **Change this file and that constant together.**
25
-
26
- ## Boundary (binding)
27
- The skill — using the agent's own file tools — is the ONLY thing that edits a user's
28
- config. `caveman learn apply` stays read-only (it materializes candidates), and
29
- `caveman mem *` are mechanical store ops. The offload move enforces a net-token-negative
30
- gate and the never-make-the-agent-dumber guard before any trim.
31
-
32
- See ../../mem/CLAUDE.md (cavemem) · ../caveman-explore/SKILL.md (the packaging precedent)