@lornatang/dsh-caveman 0.1.12 → 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,9 @@
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
+
3
7
  ## 0.1.12 - 2026-11-25
4
8
 
5
9
  - Sync the upstream Caveman source, CLI and tested runtime binaries to 4.2.0 while retaining DSH session analysis.
@@ -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) {
package/lib/index.js CHANGED
@@ -11,28 +11,29 @@ import { statsReport } from './stats.js';
11
11
  import { findCavemanBinary, guardedRuntimeFetch, runtimeSettings, verifiedRuntime } from './runtime.js';
12
12
  import { registerMemoryRecovery } from './memory.js';
13
13
  import { registerAttribution } from './attribution.js';
14
- import { registerNative } from './native.js';
14
+ import { isCavecrewPreset, registerNative } from './native.js';
15
15
  export const name = 'caveman';
16
16
  export const inject = ['skills', 'tools', 'systemPrompt', 'llm'];
17
+ const DEFAULT_ENDPOINT = 'http://127.0.0.1:8787';
17
18
  export const Config = z.object({
18
19
  defaultMode: z.union([
19
20
  z.const('caveman'), z.const('ultracave'), z.const('megacave'), z.const('off'), z.const('manual'),
20
21
  ]),
21
22
  inputCompression: z.boolean(),
22
- middlewareEndpoint: z.string().default('http://127.0.0.1:8787'),
23
+ middlewareEndpoint: z.string().default(DEFAULT_ENDPOINT),
23
24
  blocksBinary: z.string().min(1),
24
25
  browseBinary: z.string().min(1),
25
26
  mcpBinary: z.string().min(1),
26
27
  memoryBinary: z.string().min(1),
27
28
  codeMode: z.union([z.const(false), z.object({ config: z.string().required(), workspace: z.string().required() })]).default(false),
28
29
  });
29
- /** Register skills and reinforce the selected mode per session. */
30
30
  export function apply(ctx, config = {}) {
31
31
  const root = fileURLToPath(new URL('../vendor/caveman/skills/', import.meta.url));
32
32
  const modes = new SessionModeTracker();
33
33
  const settings = runtimeSettings();
34
- registerAttribution(ctx, config.middlewareEndpoint ?? 'http://127.0.0.1:8787');
35
- 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 });
36
37
  if (settings.core) {
37
38
  let core = readFileSync(new URL('../vendor/caveman/skills/native/native-core.md', import.meta.url), 'utf8').trim();
38
39
  if (settings.coreLeanBuild) {
@@ -44,13 +45,12 @@ export function apply(ctx, config = {}) {
44
45
  name: 'caveman:core', order: ctx.systemPrompt.getSectionOrder('DEPLOYMENT_PERSONA_PREFIX') + 10, interpolate: false,
45
46
  text: context => {
46
47
  const preset = context.agent && ctx.get('agentPresets')?.composedPreset(context.agent.ctx);
47
- return preset === 'cavecrew-investigator' || preset === 'cavecrew-builder' || preset === 'cavecrew-reviewer' ? '' : core;
48
+ return isCavecrewPreset(preset) ? '' : core;
48
49
  },
49
50
  });
50
51
  }
51
52
  ctx.skills.registerProvider(control => createSkillProvider(root, control));
52
53
  if (config.inputCompression !== false && settings.input) {
53
- const endpoint = config.middlewareEndpoint ?? 'http://127.0.0.1:8787';
54
54
  const automatic = config.inputCompression === true ? undefined : {
55
55
  fetch: guardedRuntimeFetch(endpoint), available: (signal) => verifiedRuntime(endpoint, process.env, signal),
56
56
  };
@@ -92,16 +92,16 @@ export function apply(ctx, config = {}) {
92
92
  if (decision.kind === 'reject')
93
93
  return decision;
94
94
  const preset = ctx.get('agentPresets')?.composedPreset(agent.ctx);
95
- if (preset === 'cavecrew-investigator' || preset === 'cavecrew-builder' || preset === 'cavecrew-reviewer')
95
+ if (isCavecrewPreset(preset))
96
96
  return decision;
97
97
  const directMessages = decision.messages.filter(message => message.source.kind === 'user');
98
98
  if (directMessages.length === 0)
99
99
  return decision;
100
100
  signal.throwIfAborted();
101
- const statsRequest = directMessages.map(message => message.content
102
- .filter(block => block.type === 'text').map(block => block.text).join('\n'))
103
- .map(text => /^\/caveman(?::caveman)?-stats(?:\s+(.*))?$/u.exec(text.trim()))
104
- .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);
105
105
  if (statsRequest) {
106
106
  const report = await statsReport(ctx, agent.session, statsRequest[1]?.trim() ?? '', signal);
107
107
  const reminder = createUserMessage({
package/lib/mode.js CHANGED
@@ -17,10 +17,8 @@ function transition(mode, message, configured) {
17
17
  const change = parser.parseModeChange(text, { getDefaultMode: () => configured });
18
18
  if (!change)
19
19
  return { mode, action: 'none' };
20
- if (change.action === 'status')
21
- return { mode, action: 'status' };
22
- if (change.action === 'unresolved')
23
- return { mode, action: 'unresolved' };
20
+ if (change.action === 'status' || change.action === 'unresolved')
21
+ return { mode, action: change.action };
24
22
  if (change.action === 'clear')
25
23
  return { mode: 'off', action: 'change' };
26
24
  if (change.mode && parser.INDEPENDENT_MODES.has(change.mode))
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;
@@ -30,5 +30,4 @@ export interface Config {
30
30
  };
31
31
  }
32
32
  export declare const Config: z<Config>;
33
- /** Register skills and reinforce the selected mode per session. */
34
33
  export declare function apply(ctx: Context, config?: Config): void;
@@ -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.12",
3
+ "version": "0.1.13",
4
4
  "description": "Caveman integration for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -1,29 +1,29 @@
1
1
  {
2
- "version": "0.1.12",
2
+ "version": "0.1.13",
3
3
  "binaries": {
4
4
  "linux-x64": {
5
5
  "name": "dsh-caveman-learn_linux_amd64",
6
- "sha256": "4f73e771ac59e218ac7ec5f3648e79e472d565e5f3621755b5a1cf28b18bb0e1"
6
+ "sha256": "030472af90cfe270db5eca21de8ae3774dde68374cf7e7302cd3946e321d2174"
7
7
  },
8
8
  "linux-arm64": {
9
9
  "name": "dsh-caveman-learn_linux_arm64",
10
- "sha256": "c29a8cc49fff51b23352e687bb3974398ee6d2835b84fd31e290c9e3f0852f22"
10
+ "sha256": "fb5aeef95e1a170879154d0ed613f9a1626d52e9239db3babe2150562defbed7"
11
11
  },
12
12
  "darwin-x64": {
13
13
  "name": "dsh-caveman-learn_darwin_amd64",
14
- "sha256": "e460f3fe253eb76b85064e857f748dcb718d96ec59ea93a31d90d540e7326175"
14
+ "sha256": "300ee7c738dddba8ac924ac49b7df9b35f277553a359334db792c2aca4c74be2"
15
15
  },
16
16
  "darwin-arm64": {
17
17
  "name": "dsh-caveman-learn_darwin_arm64",
18
- "sha256": "c8f21233f3f4a66322ee961a4f75aa03315e65b17ba3f9b4ae44fffe19805131"
18
+ "sha256": "704f0c3eaf6d9c7aac0b2d60f963589f9dfde2b244ba37e5a8fb516e99b5896c"
19
19
  },
20
20
  "win32-x64": {
21
21
  "name": "dsh-caveman-learn_win32_amd64",
22
- "sha256": "e5ea9938bedbdf3fd4dbae9717da2d643a4acb3802cdfcb116b878ea47e885b1"
22
+ "sha256": "2c5849cb55f354f1a21989f08567358921d1cf1960c9c330d187ce42a9b02843"
23
23
  },
24
24
  "win32-arm64": {
25
25
  "name": "dsh-caveman-learn_win32_arm64",
26
- "sha256": "c5d43c0dcf011490a1fe6aaf1239a9d90f959949ce34be9f971933c073b3c64d"
26
+ "sha256": "303091eea771dc9dc1d09c3cbf5e65d3ceb1d7d0098e8781b82b91a216c6da16"
27
27
  }
28
28
  }
29
29
  }