dsh-continual-evolve 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README.zh.md +3 -3
- package/lib/auto.js +2 -0
- package/lib/llm-text.d.ts +9 -1
- package/lib/llm-text.js +6 -0
- package/lib/memory-agent.d.ts +2 -0
- package/lib/memory-agent.js +1 -0
- package/lib/planner.js +2 -1
- package/lib/review.js +2 -1
- package/lib/wrapup.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](package.json)
|
|
10
|
-
[]()
|
|
11
11
|
|
|
12
12
|
Continual self-evolution for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness): a versioned, auditable, rollback-safe harness state layer — prompt notes, memories, skills, subagent specs — refined from session trajectories.
|
|
13
13
|
|
|
@@ -27,7 +27,7 @@ Agents accumulate reusable experience (repeated failures, durable facts, reusabl
|
|
|
27
27
|
## How it works
|
|
28
28
|
|
|
29
29
|
1. **Sediment** — the model creates entries via `evolve_add`, or the automatic pipeline consumes incremental snapshots captured after successful turns (plus compaction checkpoints): a dedicated memory agent runs first, then the general review/planner proposes non-memory refinements.
|
|
30
|
-
2. **Capability-aware auxiliary calls** — the memory loop, review, planner, wrapup, and fate resolve exact provider/model metadata through [`src/llm-text.ts`](src/llm-text.ts)
|
|
30
|
+
2. **Capability-aware auxiliary calls** — the memory loop, review, planner, wrapup, and fate resolve exact provider/model metadata through [`src/llm-text.ts`](src/llm-text.ts), use the lowest advertised enabled reasoning effort (falling back to a closing effort only when no enabled level exists), and forward the host session id for provider routing; models without reasoning metadata use their provider default.
|
|
31
31
|
3. **Guard** — code-enforced validation: edit schema, blast-radius/scope coherence, and the promotion policy (project-scoped markers, thin content, near-duplicate detection, credential screening keep the global store clean — secrets are rejected at every write sink, including mount materialization). Global creates that near-duplicate an existing entry are rejected at write time (≥0.8 similarity); moderate overlaps carry a `conflictHint` for later consolidation.
|
|
32
32
|
4. **Approve** — global and project writes require explicit human approval; the dialog shows the bounded structured edit diff and conflict warnings, while malformed/lost responses remain retryable rather than counting as rejection.
|
|
33
33
|
5. **Apply & inject** — memory batches preflight every persistent approval, recheck abort before writes, and compensate earlier scope writes if a later batch fails; every successful scope still passes through snapshot + audit. Prompt notes and delegation specs inject into the system prompt (capped, relevance-ranked, contradicted entries demoted, zero tokens when empty); memories/skills appear as a relevance-ordered capped directory index (`- [memory:type:id] title` hooks, full text one `evolve_list` away).
|
|
@@ -43,7 +43,7 @@ dsh plugin add dsh-continual-evolve
|
|
|
43
43
|
dsh plugin add ZK-Andy/dsh-continual-evolve
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
Restart `dsh web` after installing or updating.
|
|
46
|
+
Restart the DSH profile you use (`dsh web` or the desktop host) after installing or updating.
|
|
47
47
|
|
|
48
48
|
## Usage
|
|
49
49
|
|
package/README.zh.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](package.json)
|
|
10
|
-
[]()
|
|
11
11
|
|
|
12
12
|
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(`dsh`)的持续自进化插件:一套**版本化、可审计、可回滚**的 harness 状态层——提示词补充、记忆、技能、子代理规格——从会话轨迹中沉淀而来。
|
|
13
13
|
|
|
@@ -27,7 +27,7 @@ Agent 在每个会话里积累可复用经验(重复失败、持久事实、
|
|
|
27
27
|
## 工作原理
|
|
28
28
|
|
|
29
29
|
1. **沉淀**——模型经 `evolve_add` 创建条目,或自动管线消费成功回合后的增量 snapshot(以及压缩检查点):先运行专用 memory Agent,再由通用 review/planner 提议非 memory 精炼。
|
|
30
|
-
2. **能力感知的辅助调用**——memory loop、review、planner、wrapup、fate 通过 [`src/llm-text.ts`](src/llm-text.ts) 解析精确 provider/model 能力并使用模型公布的最低开启 reasoning effort
|
|
30
|
+
2. **能力感知的辅助调用**——memory loop、review、planner、wrapup、fate 通过 [`src/llm-text.ts`](src/llm-text.ts) 解析精确 provider/model 能力并使用模型公布的最低开启 reasoning effort,同时转发 host session id 供 provider 路由;只有没有开启档时才回退关闭档,没有 reasoning 元数据时使用 provider 默认行为。
|
|
31
31
|
3. **守卫**——代码强制校验:编辑 schema、blast-radius 与作用域一致性、晋升政策(项目专属标记 / 过薄内容 / 近似重复检测 / 凭据筛查保持全局库干净——密钥类内容在所有写入出口被拒,含 mount 物化)。全局 create 与既有条目高度相似(≥0.8)时写入即拒;中等重叠带 `conflictHint` 供后续合并。
|
|
32
32
|
4. **审批**——全局与项目写入需明确人工批准;弹窗展示有界结构化编辑 diff 与冲突提示,弹窗丢失/响应畸形会重试,不会被误记为拒绝。
|
|
33
33
|
5. **应用与注入**——memory 批次先完成所有持久化审批,写前重查 abort;后续 scope 失败时补偿回滚先前写入,成功 scope 仍保留快照与审计。prompt 补充与委派规格注入系统提示词(封顶、按相关性排序、被证伪条目降权、空 store 零 token);memory/skill 以按相关性排序的目录索引出现(`[memory:type:id] 标题`钩子)。
|
|
@@ -43,7 +43,7 @@ dsh plugin add dsh-continual-evolve
|
|
|
43
43
|
dsh plugin add ZK-Andy/dsh-continual-evolve
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
安装或更新后,重启你实际使用的 DSH profile(`dsh web` 或桌面宿主)。
|
|
47
47
|
|
|
48
48
|
## 使用
|
|
49
49
|
|
package/lib/auto.js
CHANGED
|
@@ -34,6 +34,7 @@ import { compareReviewCursors, createReviewScheduler } from "./review-scheduler.
|
|
|
34
34
|
import { captureTurnSnapshot, sliceTurnSnapshot } from "./turn-snapshot.js";
|
|
35
35
|
import { captureAutoCase } from "./autocase.js";
|
|
36
36
|
import { applyMemoryExtractionProposal, buildMemoryManifest, runMemoryAgent, } from "./memory-agent.js";
|
|
37
|
+
import { asLlmSessionId } from "./llm-text.js";
|
|
37
38
|
/** Turns a rejected skill candidate stays silent before being offered again. */
|
|
38
39
|
export const SKILL_CONSULT_COOLDOWN_TURNS = 10;
|
|
39
40
|
export function registerAutoReview(ctx, engine, config) {
|
|
@@ -361,6 +362,7 @@ export async function runMemoryExtractionPhase(ctx, engine, agent, config, state
|
|
|
361
362
|
const run = await runMemoryAgent(ctx, {
|
|
362
363
|
provider,
|
|
363
364
|
model,
|
|
365
|
+
sessionId: asLlmSessionId(sessionId),
|
|
364
366
|
manifest,
|
|
365
367
|
trajectory: memorySnapshot.trajectory,
|
|
366
368
|
trajectoryEvents: memorySnapshot.events,
|
package/lib/llm-text.d.ts
CHANGED
|
@@ -9,9 +9,13 @@
|
|
|
9
9
|
* and JSON parsing.
|
|
10
10
|
*/
|
|
11
11
|
import type { Context } from "@deepseek-ai/cordis";
|
|
12
|
-
import { type ContentBlock, type LlmResolvedModelInfo, type Message, type ReasoningEffortId, type RequestMessage, type TokenUsage, type ToolSchema } from "@deepseek-ai/dsh-llm";
|
|
12
|
+
import { type ContentBlock, type GenerateOptions, type LlmResolvedModelInfo, type Message, type ReasoningEffortId, type RequestMessage, type TokenUsage, type ToolSchema } from "@deepseek-ai/dsh-llm";
|
|
13
13
|
/** Terminal outcome of one shared direct LLM call. */
|
|
14
14
|
export type StreamTextOutcome = "success" | "max-tokens" | "error" | "aborted" | "empty";
|
|
15
|
+
/** Host-owned session identity type used by provider routing metadata. */
|
|
16
|
+
export type LlmSessionId = NonNullable<GenerateOptions["sessionId"]>;
|
|
17
|
+
/** Carry the host Agent id across the plugin's direct-call boundary. */
|
|
18
|
+
export declare function asLlmSessionId(value: string): LlmSessionId;
|
|
15
19
|
/** Provider usage and terminal result observed after the stream settles. */
|
|
16
20
|
export interface StreamTextObservation {
|
|
17
21
|
usage?: TokenUsage;
|
|
@@ -28,6 +32,8 @@ export interface StreamTextOptions {
|
|
|
28
32
|
prompt: string;
|
|
29
33
|
maxTokens?: number;
|
|
30
34
|
signal?: AbortSignal | undefined;
|
|
35
|
+
/** Host session identity forwarded to adapters for request routing. */
|
|
36
|
+
sessionId?: LlmSessionId;
|
|
31
37
|
/**
|
|
32
38
|
* Route A session prefix: session-derived messages sent before the
|
|
33
39
|
* trailing caller message so providers with prompt caching can serve
|
|
@@ -53,6 +59,8 @@ export interface StreamModelTurnOptions {
|
|
|
53
59
|
tools?: readonly ToolSchema[];
|
|
54
60
|
maxTokens?: number;
|
|
55
61
|
signal?: AbortSignal | undefined;
|
|
62
|
+
/** Host session identity forwarded to adapters for request routing. */
|
|
63
|
+
sessionId?: LlmSessionId;
|
|
56
64
|
/** Require at least one text block; tool-only turns must leave this false. */
|
|
57
65
|
requireText?: boolean;
|
|
58
66
|
/** Require visible text or a tool call; reasoning-only agent turns are empty. */
|
package/lib/llm-text.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { BlockAssembler, createUserMessage, } from "@deepseek-ai/dsh-llm";
|
|
2
2
|
import { EVOLVE_MESSAGE_SOURCE } from "./message-source.js";
|
|
3
|
+
/** Carry the host Agent id across the plugin's direct-call boundary. */
|
|
4
|
+
export function asLlmSessionId(value) {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
3
7
|
const CLOSED_REASONING_EFFORTS = new Set(["disabled", "off", "none"]);
|
|
4
8
|
/**
|
|
5
9
|
* Select the lowest reasoning effort an exact model advertises.
|
|
@@ -68,6 +72,7 @@ export async function streamModelTurn(ctx, opts) {
|
|
|
68
72
|
...(reasoningEffort === undefined ? {} : { reasoningEffort }),
|
|
69
73
|
maxTokens: opts.maxTokens ?? 8000,
|
|
70
74
|
...(opts.signal ? { signal: opts.signal } : {}),
|
|
75
|
+
...(opts.sessionId ? { sessionId: opts.sessionId } : {}),
|
|
71
76
|
})) {
|
|
72
77
|
assembler.push(chunk);
|
|
73
78
|
}
|
|
@@ -120,6 +125,7 @@ export async function streamText(ctx, opts) {
|
|
|
120
125
|
requireText: true,
|
|
121
126
|
...(opts.maxTokens === undefined ? {} : { maxTokens: opts.maxTokens }),
|
|
122
127
|
...(opts.signal ? { signal: opts.signal } : {}),
|
|
128
|
+
...(opts.sessionId ? { sessionId: opts.sessionId } : {}),
|
|
123
129
|
...(opts.onUsage ? { onUsage: opts.onUsage } : {}),
|
|
124
130
|
});
|
|
125
131
|
const text = blocks
|
package/lib/memory-agent.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { Context } from "@deepseek-ai/cordis";
|
|
|
11
11
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
12
12
|
import { type ToolSchema } from "@deepseek-ai/dsh-llm";
|
|
13
13
|
import { type ScopeApprovalDecision } from "./approval.js";
|
|
14
|
+
import { type LlmSessionId } from "./llm-text.js";
|
|
14
15
|
import { type PrefixCacheOptions } from "./prefix-cache.js";
|
|
15
16
|
import { type EvolutionEngine } from "./service.js";
|
|
16
17
|
import { type TokenUsageTarget } from "./token-usage.js";
|
|
@@ -64,6 +65,7 @@ export declare function searchMemoryManifest(entries: readonly MemoryManifestEnt
|
|
|
64
65
|
export interface MemoryAgentOptions {
|
|
65
66
|
provider: string;
|
|
66
67
|
model: string;
|
|
68
|
+
sessionId?: LlmSessionId;
|
|
67
69
|
manifest: readonly MemoryManifestEntry[];
|
|
68
70
|
trajectory: string;
|
|
69
71
|
trajectoryEvents?: readonly unknown[];
|
package/lib/memory-agent.js
CHANGED
|
@@ -172,6 +172,7 @@ export async function runMemoryAgent(ctx, options) {
|
|
|
172
172
|
const blocks = await streamModelTurn(ctx, {
|
|
173
173
|
provider: options.provider,
|
|
174
174
|
model: options.model,
|
|
175
|
+
...(options.sessionId ? { sessionId: options.sessionId } : {}),
|
|
175
176
|
system: MEMORY_AGENT_SYSTEM_PROMPT,
|
|
176
177
|
messages,
|
|
177
178
|
tools: MEMORY_AGENT_TOOL_SCHEMAS,
|
package/lib/planner.js
CHANGED
|
@@ -3,7 +3,7 @@ import { formatHarnessStateForPrompt, historyForPrompt } from "./render.js";
|
|
|
3
3
|
import { recentUserText, sessionEventsOf } from "./inject.js";
|
|
4
4
|
import { buildPrefixMessages, detectPlannerRoute, resolvePrefixCache } from "./prefix-cache.js";
|
|
5
5
|
import { skillQualityGuide } from "./skillquality.js";
|
|
6
|
-
import { streamText } from "./llm-text.js";
|
|
6
|
+
import { asLlmSessionId, streamText } from "./llm-text.js";
|
|
7
7
|
import { createTokenUsageObserver } from "./token-usage.js";
|
|
8
8
|
export const PLANNER_SYSTEM_PROMPT = `You are the /evolve continual harness subsystem.
|
|
9
9
|
|
|
@@ -121,6 +121,7 @@ export async function planWithLlm(ctx, options) {
|
|
|
121
121
|
const text = await streamText(ctx, {
|
|
122
122
|
provider: agent.options.provider,
|
|
123
123
|
model: agent.options.model,
|
|
124
|
+
sessionId: asLlmSessionId(agent.id),
|
|
124
125
|
system: PLANNER_SYSTEM_PROMPT,
|
|
125
126
|
prompt: userPrompt,
|
|
126
127
|
maxTokens: options.maxOutputTokens ?? 8000,
|
package/lib/review.js
CHANGED
|
@@ -2,7 +2,7 @@ import { extractJsonObject } from "./plan.js";
|
|
|
2
2
|
import { formatHarnessStateForPrompt, historyForPrompt } from "./render.js";
|
|
3
3
|
import { sessionEventsOf } from "./inject.js";
|
|
4
4
|
import { buildPrefixMessages, detectPlannerRoute, resolvePrefixCache } from "./prefix-cache.js";
|
|
5
|
-
import { streamText } from "./llm-text.js";
|
|
5
|
+
import { asLlmSessionId, streamText } from "./llm-text.js";
|
|
6
6
|
import { createTokenUsageObserver } from "./token-usage.js";
|
|
7
7
|
export const AUTO_REVIEW_SYSTEM_PROMPT = `You are the automatic /evolve review gate.
|
|
8
8
|
|
|
@@ -126,6 +126,7 @@ export async function reviewAutoRefine(ctx, options) {
|
|
|
126
126
|
const text = await streamText(ctx, {
|
|
127
127
|
provider,
|
|
128
128
|
model,
|
|
129
|
+
sessionId: asLlmSessionId(agent.id),
|
|
129
130
|
system: AUTO_REVIEW_SYSTEM_PROMPT,
|
|
130
131
|
prompt: userPrompt,
|
|
131
132
|
maxTokens: options.budgetTokens ?? 8000,
|
package/lib/wrapup.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ARCHIVED_AT_KEY, PROMOTED_AT_KEY, PROMOTED_TO_KEY, SOURCE_SEQS_KEY, SOU
|
|
|
2
2
|
import { MEMORY_TYPE_KEY, isMemoryType } from "./types.js";
|
|
3
3
|
import { extractJsonObject } from "./plan.js";
|
|
4
4
|
import { compactText } from "./render.js";
|
|
5
|
-
import { streamText } from "./llm-text.js";
|
|
5
|
+
import { asLlmSessionId, streamText } from "./llm-text.js";
|
|
6
6
|
import { getUsageCount, loadUsage } from "./usage.js";
|
|
7
7
|
import { createTokenUsageObserver } from "./token-usage.js";
|
|
8
8
|
import { recencyScore } from "./inject.js";
|
|
@@ -522,6 +522,7 @@ export async function assessLocalEntries(ctx, agent, candidates, options = {}) {
|
|
|
522
522
|
const text = await streamText(ctx, {
|
|
523
523
|
provider: agent.options.provider,
|
|
524
524
|
model: agent.options.model,
|
|
525
|
+
sessionId: asLlmSessionId(agent.id),
|
|
525
526
|
system: WRAPUP_ASSESS_SYSTEM_PROMPT,
|
|
526
527
|
prompt: userPrompt,
|
|
527
528
|
maxTokens: options.maxOutputTokens ?? 4096,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-continual-evolve",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Continual self-evolution plugin for DeepSeek Harness: versioned, auditable, rollback-safe harness state (prompt notes, memories, skills, subagent specs) refined from session trajectories.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|