@lornatang/dsh-caveman 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +202 -0
- package/LICENSE-MIT +21 -0
- package/NOTICE +51 -0
- package/README.md +218 -0
- package/README.zh.md +218 -0
- package/cordis.patch.yml +3 -0
- package/examples/caveman-anthropic.patch.yml +14 -0
- package/examples/caveman-auto.patch.yml +15 -0
- package/lib/attribution.js +24 -0
- package/lib/blocks.js +80 -0
- package/lib/cavecrew-git.js +83 -0
- package/lib/cavecrew.js +67 -0
- package/lib/compression.js +434 -0
- package/lib/index.js +127 -0
- package/lib/memory.js +35 -0
- package/lib/mode.js +71 -0
- package/lib/native.js +357 -0
- package/lib/runtime.js +199 -0
- package/lib/skills.js +75 -0
- package/lib/stats.js +189 -0
- package/lib/types/attribution.d.ts +8 -0
- package/lib/types/blocks.d.ts +12 -0
- package/lib/types/cavecrew-git.d.ts +5 -0
- package/lib/types/cavecrew.d.ts +10 -0
- package/lib/types/compression.d.ts +50 -0
- package/lib/types/index.d.ts +30 -0
- package/lib/types/memory.d.ts +3 -0
- package/lib/types/mode.d.ts +33 -0
- package/lib/types/native.d.ts +43 -0
- package/lib/types/runtime.d.ts +23 -0
- package/lib/types/skills.d.ts +3 -0
- package/lib/types/stats.d.ts +6 -0
- package/package.json +129 -0
- package/presets/cavecrew.patch.yml +54 -0
- package/scripts/benchmark.mjs +79 -0
- package/scripts/caveman-cli.mjs +30 -0
- package/scripts/learn-binary.mjs +82 -0
- package/scripts/learn-checksums.json +29 -0
- package/vendor/caveman/LICENSE +202 -0
- package/vendor/caveman/LICENSE-MIT +21 -0
- package/vendor/caveman/NOTICE +49 -0
- package/vendor/caveman/agents/cavecrew-builder.md +46 -0
- package/vendor/caveman/agents/cavecrew-investigator.md +56 -0
- package/vendor/caveman/agents/cavecrew-reviewer.md +47 -0
- package/vendor/caveman/skills/activation-rule.mjs +43 -0
- package/vendor/caveman/skills/cavecrew/README.md +67 -0
- package/vendor/caveman/skills/cavecrew/SKILL.md +78 -0
- package/vendor/caveman/skills/caveman/README.md +68 -0
- package/vendor/caveman/skills/caveman/SKILL.md +89 -0
- package/vendor/caveman/skills/caveman-commit/README.md +44 -0
- package/vendor/caveman/skills/caveman-commit/SKILL.md +63 -0
- package/vendor/caveman/skills/caveman-compress/README.md +262 -0
- package/vendor/caveman/skills/caveman-compress/SECURITY.md +55 -0
- package/vendor/caveman/skills/caveman-compress/SKILL.md +114 -0
- package/vendor/caveman/skills/caveman-compress/scripts/__init__.py +9 -0
- package/vendor/caveman/skills/caveman-compress/scripts/__main__.py +3 -0
- package/vendor/caveman/skills/caveman-compress/scripts/benchmark.py +80 -0
- package/vendor/caveman/skills/caveman-compress/scripts/cli.py +94 -0
- package/vendor/caveman/skills/caveman-compress/scripts/compress.py +1331 -0
- package/vendor/caveman/skills/caveman-compress/scripts/detect.py +192 -0
- package/vendor/caveman/skills/caveman-compress/scripts/validate.py +440 -0
- package/vendor/caveman/skills/caveman-discover/SKILL.md +115 -0
- package/vendor/caveman/skills/caveman-evidence-review/SKILL.md +142 -0
- package/vendor/caveman/skills/caveman-explore/SKILL.md +42 -0
- package/vendor/caveman/skills/caveman-explore/package.json +12 -0
- package/vendor/caveman/skills/caveman-explore/tests/skill-file.test.mjs +44 -0
- package/vendor/caveman/skills/caveman-help/README.md +39 -0
- package/vendor/caveman/skills/caveman-help/SKILL.md +62 -0
- package/vendor/caveman/skills/caveman-learn/CLAUDE.md +32 -0
- package/vendor/caveman/skills/caveman-learn/README.md +38 -0
- package/vendor/caveman/skills/caveman-learn/SKILL.md +185 -0
- package/vendor/caveman/skills/caveman-learn/package.json +12 -0
- package/vendor/caveman/skills/caveman-learn/tests/index.js +1 -0
- package/vendor/caveman/skills/caveman-learn/tests/skill-file.test.mjs +54 -0
- package/vendor/caveman/skills/caveman-manage/SKILL.md +112 -0
- package/vendor/caveman/skills/caveman-optimize/SKILL.md +111 -0
- package/vendor/caveman/skills/caveman-review/README.md +33 -0
- package/vendor/caveman/skills/caveman-review/SKILL.md +53 -0
- package/vendor/caveman/skills/caveman-setup/SKILL.md +222 -0
- package/vendor/caveman/skills/caveman-stats/README.md +48 -0
- package/vendor/caveman/skills/caveman-stats/SKILL.md +17 -0
- package/vendor/caveman/skills/compile.mjs +298 -0
- package/vendor/caveman/skills/engine-mcp-tools.json +10 -0
- package/vendor/caveman/skills/generated/aider/pack.json +163 -0
- package/vendor/caveman/skills/generated/claude/pack.json +163 -0
- package/vendor/caveman/skills/generated/codex/pack.json +163 -0
- package/vendor/caveman/skills/generated/gemini/pack.json +163 -0
- package/vendor/caveman/skills/generated/hermes/pack.json +163 -0
- package/vendor/caveman/skills/generated/opencode/pack.json +163 -0
- package/vendor/caveman/skills/investigate-first/SKILL.md +16 -0
- package/vendor/caveman/skills/investigate-first/agents/openai.yaml +4 -0
- package/vendor/caveman/skills/lean-build/SKILL.md +18 -0
- package/vendor/caveman/skills/lean-build/agents/openai.yaml +4 -0
- package/vendor/caveman/skills/megacave/README.md +11 -0
- package/vendor/caveman/skills/megacave/SKILL.md +65 -0
- package/vendor/caveman/skills/migration/SKILL.md +17 -0
- package/vendor/caveman/skills/migration/agents/openai.yaml +4 -0
- package/vendor/caveman/skills/native/native-core.md +16 -0
- package/vendor/caveman/skills/registry.json +283 -0
- package/vendor/caveman/skills/safe-refactor/SKILL.md +16 -0
- package/vendor/caveman/skills/safe-refactor/agents/openai.yaml +4 -0
- package/vendor/caveman/skills/surgical-patch/SKILL.md +16 -0
- package/vendor/caveman/skills/surgical-patch/agents/openai.yaml +4 -0
- package/vendor/caveman/skills/ultracave/README.md +13 -0
- package/vendor/caveman/skills/ultracave/SKILL.md +63 -0
- package/vendor/caveman/skills/verbs-gate.mjs +213 -0
- package/vendor/caveman/skills/verify-and-stop/SKILL.md +16 -0
- package/vendor/caveman/skills/verify-and-stop/agents/openai.yaml +4 -0
- package/vendor/caveman/src/hooks/caveman-config.js +921 -0
- package/vendor/caveman/src/hooks/caveman-parse.js +342 -0
- package/vendor/caveman/src/hooks/package.json +3 -0
package/lib/stats.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
function countsFor(events, cutoff) {
|
|
2
|
+
const counts = { activity: false, messages: 0, usageReports: 0, output: 0, cacheReports: 0, cacheRead: 0, attempted: 0, modes: new Map() };
|
|
3
|
+
let mode = 'unattributed';
|
|
4
|
+
for (const event of events) {
|
|
5
|
+
if (event.type === 'user/message' && event.data.source.kind === 'dsh-caveman-mode')
|
|
6
|
+
mode = event.data.source.mode;
|
|
7
|
+
if (cutoff !== undefined && (!Number.isFinite(event.time) || event.time < cutoff))
|
|
8
|
+
continue;
|
|
9
|
+
counts.activity = true;
|
|
10
|
+
if (event.type === 'assistant/attempt')
|
|
11
|
+
counts.attempted++;
|
|
12
|
+
if (event.type !== 'assistant/message')
|
|
13
|
+
continue;
|
|
14
|
+
counts.messages++;
|
|
15
|
+
const group = counts.modes.get(mode) ?? { messages: 0, reports: 0, output: 0 };
|
|
16
|
+
group.messages++;
|
|
17
|
+
const usage = event.data.usage;
|
|
18
|
+
if (usage && Number.isSafeInteger(usage.outputTokens) && usage.outputTokens >= 0) {
|
|
19
|
+
counts.usageReports++;
|
|
20
|
+
counts.output += usage.outputTokens;
|
|
21
|
+
group.reports++;
|
|
22
|
+
group.output += usage.outputTokens;
|
|
23
|
+
}
|
|
24
|
+
if (usage && Number.isSafeInteger(usage.cacheReadTokens) && usage.cacheReadTokens >= 0) {
|
|
25
|
+
counts.cacheReports++;
|
|
26
|
+
counts.cacheRead += usage.cacheReadTokens;
|
|
27
|
+
}
|
|
28
|
+
counts.modes.set(mode, group);
|
|
29
|
+
}
|
|
30
|
+
return counts;
|
|
31
|
+
}
|
|
32
|
+
function mergeCounts(target, source) {
|
|
33
|
+
target.activity ||= source.activity;
|
|
34
|
+
target.messages += source.messages;
|
|
35
|
+
target.usageReports += source.usageReports;
|
|
36
|
+
target.output += source.output;
|
|
37
|
+
target.cacheReports += source.cacheReports;
|
|
38
|
+
target.cacheRead += source.cacheRead;
|
|
39
|
+
target.attempted += source.attempted;
|
|
40
|
+
for (const [mode, group] of source.modes) {
|
|
41
|
+
const current = target.modes.get(mode) ?? { messages: 0, reports: 0, output: 0 };
|
|
42
|
+
current.messages += group.messages;
|
|
43
|
+
current.reports += group.reports;
|
|
44
|
+
current.output += group.output;
|
|
45
|
+
target.modes.set(mode, current);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function available(value, reports, messages) {
|
|
49
|
+
if (!reports)
|
|
50
|
+
return 'unavailable';
|
|
51
|
+
return reports < messages ? `${value} known (partial; total unavailable)` : String(value);
|
|
52
|
+
}
|
|
53
|
+
function sharedReport(counts) {
|
|
54
|
+
return `Caveman: ${counts.messages} recorded assistant messages, ${available(counts.output, counts.usageReports, counts.messages)} output tokens; savings unknown.`;
|
|
55
|
+
}
|
|
56
|
+
function linesFor(counts) {
|
|
57
|
+
const lines = [
|
|
58
|
+
`Recorded assistant messages: ${counts.messages}`,
|
|
59
|
+
`Messages with usage: ${counts.usageReports} of ${counts.messages}`,
|
|
60
|
+
`Output tokens: ${available(counts.output, counts.usageReports, counts.messages)}`,
|
|
61
|
+
`Cache-read tokens: ${available(counts.cacheRead, counts.cacheReports, counts.messages)} (${counts.cacheReports} of ${counts.messages} messages reported cache reads)`,
|
|
62
|
+
`Uncommitted assistant attempts excluded: ${counts.attempted}`,
|
|
63
|
+
];
|
|
64
|
+
if (counts.modes.size) {
|
|
65
|
+
lines.push('Output tokens by response mode:');
|
|
66
|
+
for (const [mode, group] of [...counts.modes].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
|
|
67
|
+
lines.push(` ${mode}: ${available(group.output, group.reports, group.messages)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
lines.push('Savings: unknown (no comparison without Caveman)');
|
|
71
|
+
return lines;
|
|
72
|
+
}
|
|
73
|
+
function parseOptions(flags) {
|
|
74
|
+
const result = { all: false, share: false };
|
|
75
|
+
const args = flags.trim() ? flags.trim().split(/\s+/u) : [];
|
|
76
|
+
for (let index = 0; index < args.length; index++) {
|
|
77
|
+
const arg = args[index];
|
|
78
|
+
if (arg === '--all')
|
|
79
|
+
result.all = true;
|
|
80
|
+
else if (arg === '--share')
|
|
81
|
+
result.share = true;
|
|
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)
|
|
89
|
+
throw new Error('--since takes Nh or Nd (for example, 24h or 7d)');
|
|
90
|
+
const milliseconds = quantity * (match[2] === 'd' ? 86_400_000 : 3_600_000);
|
|
91
|
+
if (!Number.isSafeInteger(milliseconds))
|
|
92
|
+
throw new Error('--since duration is too large');
|
|
93
|
+
result.since = { label: label, milliseconds };
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
throw new Error(`Unknown statistics option: ${arg}`);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
/** Report recorded message usage without claiming savings or unreported counts. */
|
|
101
|
+
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');
|
|
108
|
+
}
|
|
109
|
+
/** Aggregate each live or stored session once, excluding fork-inherited events. */
|
|
110
|
+
export async function statsReport(ctx, current, flags, signal) {
|
|
111
|
+
signal.throwIfAborted();
|
|
112
|
+
let options;
|
|
113
|
+
try {
|
|
114
|
+
options = parseOptions(flags);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return error.message;
|
|
118
|
+
}
|
|
119
|
+
if (!options.all && !options.since)
|
|
120
|
+
return sessionStats(current.snapshotEvents(), flags);
|
|
121
|
+
const totals = countsFor([]);
|
|
122
|
+
const live = ctx.get('sessions')?.list() ?? [current];
|
|
123
|
+
const known = new Set(live.map(session => String(session.id)));
|
|
124
|
+
if (!known.has(String(current.id))) {
|
|
125
|
+
live.push(current);
|
|
126
|
+
known.add(String(current.id));
|
|
127
|
+
}
|
|
128
|
+
const cutoff = options.since ? Date.now() - options.since.milliseconds : undefined;
|
|
129
|
+
let sessions = 0;
|
|
130
|
+
let unreadable = 0;
|
|
131
|
+
function add(events, createdAt) {
|
|
132
|
+
const counts = countsFor(events, cutoff);
|
|
133
|
+
if (cutoff !== undefined && createdAt < cutoff && !counts.activity)
|
|
134
|
+
return;
|
|
135
|
+
sessions++;
|
|
136
|
+
mergeCounts(totals, counts);
|
|
137
|
+
}
|
|
138
|
+
for (const session of live)
|
|
139
|
+
add(session.snapshotEvents(session.inheritedEventCount), session.header.createdAt);
|
|
140
|
+
const persistence = ctx.get('sessionPersistence');
|
|
141
|
+
let historyAvailable = Boolean(persistence);
|
|
142
|
+
if (persistence) {
|
|
143
|
+
let stored = [];
|
|
144
|
+
try {
|
|
145
|
+
stored = (await persistence.list({ signal })).filter(item => !known.has(String(item.header.id)));
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
signal.throwIfAborted();
|
|
149
|
+
historyAvailable = false;
|
|
150
|
+
}
|
|
151
|
+
let cursor = 0;
|
|
152
|
+
const workers = await Promise.allSettled(Array.from({ length: Math.min(4, stored.length) }, async () => {
|
|
153
|
+
for (;;) {
|
|
154
|
+
const item = stored[cursor++];
|
|
155
|
+
if (!item)
|
|
156
|
+
return;
|
|
157
|
+
signal.throwIfAborted();
|
|
158
|
+
let handle;
|
|
159
|
+
try {
|
|
160
|
+
handle = await persistence.open(item.header.id, 'read', { signal });
|
|
161
|
+
const result = await handle.read(handle.inheritedEventCount, undefined, { signal });
|
|
162
|
+
add(result.events, item.header.createdAt);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
signal.throwIfAborted();
|
|
166
|
+
unreadable++;
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
try {
|
|
170
|
+
await handle?.close();
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
unreadable++;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}));
|
|
178
|
+
signal.throwIfAborted();
|
|
179
|
+
unreadable += workers.filter(result => result.status === 'rejected').length;
|
|
180
|
+
}
|
|
181
|
+
if (options.share)
|
|
182
|
+
return `${sharedReport(totals)}${!historyAvailable || unreadable ? ' History incomplete.' : ''}`;
|
|
183
|
+
const lines = [`DSH usage across sessions${options.since ? ` (last ${options.since.label})` : ''}`, `Sessions counted: ${sessions}`];
|
|
184
|
+
if (!historyAvailable)
|
|
185
|
+
lines.push('History unavailable; showing live sessions only.');
|
|
186
|
+
if (unreadable)
|
|
187
|
+
lines.push(`Stored session read or close errors: ${unreadable} (totals may be incomplete)`);
|
|
188
|
+
return [...lines, ...linesFor(totals)].join('\n');
|
|
189
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
/** Attribute only requests routed to the configured loopback proxy. */
|
|
3
|
+
export declare function cavemanSessionId(sessionId: string): string;
|
|
4
|
+
export declare function cavemanRequestHeaders(endpoint: string, request: {
|
|
5
|
+
baseURL: string;
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
}, headers: Headers): Headers;
|
|
8
|
+
export declare function registerAttribution(ctx: Context, endpoint: string): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
declare module '@deepseek-ai/dsh-llm' {
|
|
3
|
+
interface MessageSourceMap {
|
|
4
|
+
'dsh-caveman-blocks': {
|
|
5
|
+
kind: 'dsh-caveman-blocks';
|
|
6
|
+
form: 'notice';
|
|
7
|
+
summary: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Invoke the generic Blocks hook before shell dispatch; never change the command. */
|
|
12
|
+
export declare function registerBlocks(ctx: Context, binary: string): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
type ReadOnlyRole = 'investigator' | 'reviewer';
|
|
3
|
+
/** Provide the read-only Git operations used by the two inspection roles. */
|
|
4
|
+
export declare function registerCavecrewGit(ctx: Context, role: ReadOnlyRole): void;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import z from '@deepseek-ai/schemastery';
|
|
3
|
+
export declare const name = "cavecrew";
|
|
4
|
+
export declare const inject: string[];
|
|
5
|
+
export interface Config {
|
|
6
|
+
role: 'investigator' | 'builder' | 'reviewer';
|
|
7
|
+
}
|
|
8
|
+
export declare const Config: z<Config>;
|
|
9
|
+
/** Install one original Cavecrew persona and keep its agent's tools bounded. */
|
|
10
|
+
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { Session, SessionEvent, SessionLogOffset } from '@deepseek-ai/dsh-session';
|
|
3
|
+
export declare function isManagedTool(name: string): boolean;
|
|
4
|
+
interface CompressionHistory {
|
|
5
|
+
seq: SessionLogOffset;
|
|
6
|
+
toolNames: Map<string, string>;
|
|
7
|
+
managedCalls: Set<string>;
|
|
8
|
+
hasMarker: boolean;
|
|
9
|
+
originals: Map<string, {
|
|
10
|
+
text: string;
|
|
11
|
+
sourceId: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
/** Index immutable history once per session instead of rescanning it on every step. */
|
|
15
|
+
export declare class CompressionHistoryIndex {
|
|
16
|
+
private readonly states;
|
|
17
|
+
read(session: Session): CompressionHistory;
|
|
18
|
+
}
|
|
19
|
+
/** Resolve immutable event ancestry once per session, reusing earlier results. */
|
|
20
|
+
export declare function resolveOriginalResult(session: Session, event: SessionEvent<'tool/result'>): SessionEvent<'tool/result'>;
|
|
21
|
+
type ExpectedProjection = {
|
|
22
|
+
callId: string;
|
|
23
|
+
blocks: readonly {
|
|
24
|
+
index: number;
|
|
25
|
+
text: string;
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
type ProjectedMessage = {
|
|
29
|
+
role: string;
|
|
30
|
+
toolCallId?: string;
|
|
31
|
+
content: readonly {
|
|
32
|
+
type: string;
|
|
33
|
+
text?: string;
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
/** Check the changed blocks on each matching tool result, including partial projections. */
|
|
37
|
+
export declare function projectionCoverage(expected: readonly ExpectedProjection[], messages: readonly ProjectedMessage[]): 'none' | 'incomplete' | 'complete';
|
|
38
|
+
/** Keep each result together while respecting middleware limits and unique segment ids. */
|
|
39
|
+
export declare function planCompressionBatches<T extends {
|
|
40
|
+
bytes: number;
|
|
41
|
+
segments: readonly {
|
|
42
|
+
id: string;
|
|
43
|
+
}[];
|
|
44
|
+
}>(items: readonly T[], byteBudget: number, maxSegments: number): T[][];
|
|
45
|
+
/** Install recoverable compression using the middleware protocol. */
|
|
46
|
+
export declare function registerCompression(ctx: Context, endpoint: string, automatic?: {
|
|
47
|
+
fetch: typeof fetch;
|
|
48
|
+
available: (signal: AbortSignal) => Promise<boolean>;
|
|
49
|
+
}): void;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import z from '@deepseek-ai/schemastery';
|
|
3
|
+
import { type DefaultMode, type VoiceMode } from './mode.js';
|
|
4
|
+
declare module '@deepseek-ai/dsh-llm' {
|
|
5
|
+
interface MessageSourceMap {
|
|
6
|
+
'dsh-caveman-mode': {
|
|
7
|
+
kind: 'dsh-caveman-mode';
|
|
8
|
+
form: 'instructions';
|
|
9
|
+
mode: VoiceMode;
|
|
10
|
+
};
|
|
11
|
+
'dsh-caveman-stats': {
|
|
12
|
+
kind: 'dsh-caveman-stats';
|
|
13
|
+
form: 'notice';
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export declare const name = "caveman";
|
|
18
|
+
export declare const inject: string[];
|
|
19
|
+
export interface Config {
|
|
20
|
+
defaultMode?: DefaultMode;
|
|
21
|
+
inputCompression?: boolean;
|
|
22
|
+
middlewareEndpoint?: string;
|
|
23
|
+
blocksBinary?: string;
|
|
24
|
+
browseBinary?: string;
|
|
25
|
+
mcpBinary?: string;
|
|
26
|
+
memoryBinary?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const Config: z<Config>;
|
|
29
|
+
/** Register skills and reinforce the selected mode per session. */
|
|
30
|
+
export declare function apply(ctx: Context, config?: Config): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
2
|
+
export type VoiceMode = 'off' | 'caveman' | 'ultracave' | 'megacave';
|
|
3
|
+
export type DefaultMode = VoiceMode | 'manual';
|
|
4
|
+
export type ModeAction = 'none' | 'change' | 'status' | 'one-shot' | 'unresolved';
|
|
5
|
+
interface InputMessage {
|
|
6
|
+
readonly source: {
|
|
7
|
+
readonly kind: string;
|
|
8
|
+
};
|
|
9
|
+
readonly content: readonly {
|
|
10
|
+
readonly type: string;
|
|
11
|
+
readonly text?: string;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
interface InputEvent {
|
|
15
|
+
readonly type: string;
|
|
16
|
+
readonly data: unknown;
|
|
17
|
+
}
|
|
18
|
+
/** A profile override wins; otherwise follow environment and file resolution. */
|
|
19
|
+
export declare function defaultModeFor(configured: DefaultMode | undefined, cwd?: string): DefaultMode;
|
|
20
|
+
/** Replay only user-authored messages, then evaluate the incoming batch. */
|
|
21
|
+
export declare function resolveMode(configured: DefaultMode, events: readonly InputEvent[], pending: readonly InputMessage[]): {
|
|
22
|
+
mode: VoiceMode;
|
|
23
|
+
action: ModeAction;
|
|
24
|
+
};
|
|
25
|
+
/** Incrementally replay immutable session logs; pending messages are never cached. */
|
|
26
|
+
export declare class SessionModeTracker {
|
|
27
|
+
private readonly states;
|
|
28
|
+
resolve(configured: DefaultMode, session: Session, pending: readonly InputMessage[]): {
|
|
29
|
+
mode: VoiceMode;
|
|
30
|
+
action: ModeAction;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
|
|
3
|
+
import type { PromptAssembly } from '@deepseek-ai/dsh-system-prompt';
|
|
4
|
+
declare module '@deepseek-ai/dsh-llm' {
|
|
5
|
+
interface MessageSourceMap {
|
|
6
|
+
'dsh-caveman-native': {
|
|
7
|
+
kind: 'dsh-caveman-native';
|
|
8
|
+
form: 'notice';
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
type PolicyMode = 'record' | 'safe' | 'max';
|
|
13
|
+
interface NativeResponse {
|
|
14
|
+
protocol_version: 1;
|
|
15
|
+
action: string;
|
|
16
|
+
visibility: string;
|
|
17
|
+
fail_open: true;
|
|
18
|
+
context?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Confirm that the model's assembled tool surface includes the admitted MCP recovery tool. */
|
|
21
|
+
export declare function recoveryIsPublished(assembly: Pick<PromptAssembly, 'tools' | 'sections'>, tool: ToolDefinition): boolean;
|
|
22
|
+
/** Hash and classify the prompt locally; the runtime does not receive the prompt text. */
|
|
23
|
+
export declare function nativePrompt(prompt: string): {
|
|
24
|
+
prompt: {
|
|
25
|
+
bytes: number;
|
|
26
|
+
sha256: string;
|
|
27
|
+
};
|
|
28
|
+
task_profile: {
|
|
29
|
+
type: string;
|
|
30
|
+
terms: string[];
|
|
31
|
+
continuation: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/** Name the same per-install socket as the local runtime. */
|
|
35
|
+
export declare function nativeSocketPath(home: string, platform?: NodeJS.Platform): string;
|
|
36
|
+
export declare function nativeCall(home: string, request: object, signal?: AbortSignal): Promise<NativeResponse | undefined>;
|
|
37
|
+
/** Add dynamic native task context when the verified local runtime is running. */
|
|
38
|
+
export declare function registerNative(ctx: Context, endpoint: string, policy: {
|
|
39
|
+
mode: PolicyMode;
|
|
40
|
+
profile: string;
|
|
41
|
+
core: boolean;
|
|
42
|
+
}): void;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Binary = 'blocks' | 'browse' | 'mcp' | 'memory';
|
|
2
|
+
type Module = 'scripts' | 'browse' | 'input';
|
|
3
|
+
/** Find a configured binary, PATH command, or the CLI's installation. */
|
|
4
|
+
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
|
+
export declare function runtimeSettings(env?: NodeJS.ProcessEnv): {
|
|
7
|
+
input: boolean;
|
|
8
|
+
scripts: boolean;
|
|
9
|
+
browse: boolean;
|
|
10
|
+
mcp: boolean;
|
|
11
|
+
memory: boolean;
|
|
12
|
+
core: boolean;
|
|
13
|
+
coreLeanBuild: boolean;
|
|
14
|
+
nativeMode: 'record' | 'safe' | 'max';
|
|
15
|
+
nativeProfile: string;
|
|
16
|
+
};
|
|
17
|
+
/** Modules default to on; a saved explicit off is respected. */
|
|
18
|
+
export declare function moduleEnabled(kind: Module, env?: NodeJS.ProcessEnv): boolean;
|
|
19
|
+
/** Verify that the loopback listener matches the runtime's private run-state record. */
|
|
20
|
+
export declare function verifiedRuntime(endpoint: string, env?: NodeJS.ProcessEnv, signal?: AbortSignal): Promise<boolean>;
|
|
21
|
+
/** Guard every automatic middleware call against a different or replaced listener. */
|
|
22
|
+
export declare function guardedRuntimeFetch(endpoint: string, env?: NodeJS.ProcessEnv): typeof fetch;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { Session, SessionEvent } from '@deepseek-ai/dsh-session';
|
|
3
|
+
/** Report recorded message usage without claiming savings or unreported counts. */
|
|
4
|
+
export declare function sessionStats(events: readonly SessionEvent[], flags: string): string;
|
|
5
|
+
/** Aggregate each live or stored session once, excluding fork-inherited events. */
|
|
6
|
+
export declare function statsReport(ctx: Context, current: Session, flags: string, signal: AbortSignal): Promise<string>;
|
package/package.json
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lornatang/dsh-caveman",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Caveman integration for DeepSeek Harness.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "Lornatang",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"deepseek-harness",
|
|
10
|
+
"dsh",
|
|
11
|
+
"dsh-plugin",
|
|
12
|
+
"caveman",
|
|
13
|
+
"skills"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=22.19",
|
|
17
|
+
"dsh": "*"
|
|
18
|
+
},
|
|
19
|
+
"main": "lib/index.js",
|
|
20
|
+
"types": "lib/types/index.d.ts",
|
|
21
|
+
"bin": {
|
|
22
|
+
"dsh-caveman": "./scripts/caveman-cli.mjs"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./lib/types/index.d.ts",
|
|
27
|
+
"default": "./lib/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./cavecrew": {
|
|
30
|
+
"types": "./lib/types/cavecrew.d.ts",
|
|
31
|
+
"default": "./lib/cavecrew.js"
|
|
32
|
+
},
|
|
33
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"lib",
|
|
38
|
+
"scripts/caveman-cli.mjs",
|
|
39
|
+
"scripts/learn-binary.mjs",
|
|
40
|
+
"scripts/learn-checksums.json",
|
|
41
|
+
"scripts/benchmark.mjs",
|
|
42
|
+
"examples",
|
|
43
|
+
"presets",
|
|
44
|
+
"vendor/caveman/skills",
|
|
45
|
+
"vendor/caveman/agents/cavecrew-*.md",
|
|
46
|
+
"vendor/caveman/src/hooks/caveman-config.js",
|
|
47
|
+
"vendor/caveman/src/hooks/caveman-parse.js",
|
|
48
|
+
"vendor/caveman/src/hooks/package.json",
|
|
49
|
+
"vendor/caveman/LICENSE",
|
|
50
|
+
"vendor/caveman/LICENSE-MIT",
|
|
51
|
+
"vendor/caveman/NOTICE",
|
|
52
|
+
"cordis.patch.yml",
|
|
53
|
+
"README.md",
|
|
54
|
+
"README.zh.md",
|
|
55
|
+
"CHANGELOG.md",
|
|
56
|
+
"LICENSE",
|
|
57
|
+
"LICENSE-MIT",
|
|
58
|
+
"NOTICE"
|
|
59
|
+
],
|
|
60
|
+
"scripts": {
|
|
61
|
+
"clean": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\"",
|
|
62
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
63
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
64
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
65
|
+
"test:dsh": "node scripts/verify-dsh.mjs",
|
|
66
|
+
"benchmark": "node scripts/benchmark.mjs",
|
|
67
|
+
"prepack": "npm test"
|
|
68
|
+
},
|
|
69
|
+
"dsh": {
|
|
70
|
+
"bundle": {
|
|
71
|
+
"patch": [
|
|
72
|
+
"./cordis.patch.yml",
|
|
73
|
+
"./presets/cavecrew.patch.yml"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@caveman-ai/cli": "4.1.0",
|
|
79
|
+
"@caveman-ai/sdk": "1.2.0",
|
|
80
|
+
"@deepseek-ai/schemastery": "~3.19.0",
|
|
81
|
+
"undici": "^7.30.2",
|
|
82
|
+
"yaml": "^2.8.1"
|
|
83
|
+
},
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"@deepseek-ai/cordis": "~4.1.0",
|
|
86
|
+
"@deepseek-ai/dsh-llm": "*"
|
|
87
|
+
},
|
|
88
|
+
"devDependencies": {
|
|
89
|
+
"@deepseek-ai/cordis": "~4.1.0",
|
|
90
|
+
"@deepseek-ai/cordis-plugin-group": "1.1.0",
|
|
91
|
+
"@deepseek-ai/dsh-agent": "0.2.2-rc.3",
|
|
92
|
+
"@deepseek-ai/dsh-agent-loop": "^0.2.2-rc.3",
|
|
93
|
+
"@deepseek-ai/dsh-agent-preset": "0.2.2-rc.3",
|
|
94
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.3",
|
|
95
|
+
"@deepseek-ai/dsh-fs-local": "0.2.2-rc.3",
|
|
96
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.3",
|
|
97
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.2.2-rc.3",
|
|
98
|
+
"@deepseek-ai/dsh-mcp-manager": "0.2.2-rc.3",
|
|
99
|
+
"@deepseek-ai/dsh-ptc-runtime": "0.2.2-rc.3",
|
|
100
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.3",
|
|
101
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.2-rc.3",
|
|
102
|
+
"@deepseek-ai/dsh-skill": "0.2.2-rc.3",
|
|
103
|
+
"@deepseek-ai/dsh-subagent": "0.2.2-rc.3",
|
|
104
|
+
"@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.2-rc.3",
|
|
105
|
+
"@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.3",
|
|
106
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.3",
|
|
107
|
+
"@deepseek-ai/dsh-tool-executor-native": "^0.2.2-rc.3",
|
|
108
|
+
"@deepseek-ai/dsh-tool-executor-ptc": "0.2.2-rc.3",
|
|
109
|
+
"@deepseek-ai/dsh-tool-fs": "0.2.2-rc.3",
|
|
110
|
+
"@deepseek-ai/dsh-tool-fs-search": "0.2.2-rc.3",
|
|
111
|
+
"@deepseek-ai/dsh-tool-subagent": "0.2.2-rc.3",
|
|
112
|
+
"@deepseek-ai/dsh-tools": "^0.2.2-rc.3",
|
|
113
|
+
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.3",
|
|
114
|
+
"@types/node": "^22.18.0",
|
|
115
|
+
"typescript": "^5.9.3"
|
|
116
|
+
},
|
|
117
|
+
"repository": {
|
|
118
|
+
"type": "git",
|
|
119
|
+
"url": "git+https://github.com/Lornatang/dsh-caveman.git"
|
|
120
|
+
},
|
|
121
|
+
"homepage": "https://github.com/Lornatang/dsh-caveman#readme",
|
|
122
|
+
"bugs": {
|
|
123
|
+
"url": "https://github.com/Lornatang/dsh-caveman/issues"
|
|
124
|
+
},
|
|
125
|
+
"publishConfig": {
|
|
126
|
+
"access": "public",
|
|
127
|
+
"registry": "https://registry.npmjs.org/"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Cavecrew agent presets and their in-process delegation tools. The read-only
|
|
2
|
+
# roles use a read-only Git tool instead of a shell.
|
|
3
|
+
- insert:
|
|
4
|
+
- id: preset-cavecrew-investigator
|
|
5
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
6
|
+
config:
|
|
7
|
+
id: cavecrew-investigator
|
|
8
|
+
name: Cavecrew Investigator
|
|
9
|
+
plugins:
|
|
10
|
+
- id: cavecrew
|
|
11
|
+
name: '@lornatang/dsh-caveman/cavecrew'
|
|
12
|
+
config: { role: investigator }
|
|
13
|
+
- id: tool-fs
|
|
14
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
15
|
+
config: { readImage: false, write: false, edit: false, applyPatch: false }
|
|
16
|
+
- id: tool-fs-search
|
|
17
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
18
|
+
config: { sampleOverCapGlobResults: false }
|
|
19
|
+
- id: preset-cavecrew-builder
|
|
20
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
21
|
+
config:
|
|
22
|
+
id: cavecrew-builder
|
|
23
|
+
name: Cavecrew Builder
|
|
24
|
+
plugins:
|
|
25
|
+
- id: cavecrew
|
|
26
|
+
name: '@lornatang/dsh-caveman/cavecrew'
|
|
27
|
+
config: { role: builder }
|
|
28
|
+
- id: tool-fs
|
|
29
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
30
|
+
config: { readImage: false, write: false, applyPatch: false }
|
|
31
|
+
- id: preset-cavecrew-reviewer
|
|
32
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
33
|
+
config:
|
|
34
|
+
id: cavecrew-reviewer
|
|
35
|
+
name: Cavecrew Reviewer
|
|
36
|
+
plugins:
|
|
37
|
+
- id: cavecrew
|
|
38
|
+
name: '@lornatang/dsh-caveman/cavecrew'
|
|
39
|
+
config: { role: reviewer }
|
|
40
|
+
- id: tool-fs
|
|
41
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
42
|
+
config: { readImage: false, write: false, edit: false, applyPatch: false }
|
|
43
|
+
- id: tool-fs-search
|
|
44
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
45
|
+
config: { sampleOverCapGlobResults: false }
|
|
46
|
+
- id: tool-cavecrew-investigator
|
|
47
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
48
|
+
config: { provider: spawn, toolName: cavecrew-investigator, agentPreset: cavecrew-investigator }
|
|
49
|
+
- id: tool-cavecrew-builder
|
|
50
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
51
|
+
config: { provider: spawn, toolName: cavecrew-builder, agentPreset: cavecrew-builder }
|
|
52
|
+
- id: tool-cavecrew-reviewer
|
|
53
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
54
|
+
config: { provider: spawn, toolName: cavecrew-reviewer, agentPreset: cavecrew-reviewer }
|