rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:puppetcat-fire/dsh-plugin-dreaming
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
中文 | English
Knowing what a skill can actually do before you execute it — that is consciousness strength. Dreaming raises it by measuring every skill call and correcting skill boundaries overnight, so skills are invoked precisely and tokens are not wasted on descriptions that merely look right.
Dreaming is a global DeepSeek Harness plugin (Host plugin + Web panel). It is not a logging plugin; it is a capability self-model:
A skill description is a claim. Claims and reality often disagree:
Dreaming closes the loop: measure → judge → write the boundary back → measure again. The metric is rising consciousness and falling wasted tokens, not the number of log lines.
┌──────────── every skill call ────────────┐
user/agent ── skill ─┤ tools/pre-execute │
│ ├─ record the task context (truncated) │
│ └─ concurrent probe: a cheap LLM call │
│ predicting fit / expected use / │
│ pitfalls / capability gap │
├─ tools/result: record the skill body and │
│ the load outcome │
├─ tools/post-execute: append measured │
│ history + prediction + learned │
│ boundaries to the skill result │
├─ session/event: observe later assistant/ │
│ tool/user events until turn end │
└─ judge: expectation vs reality → score / │
root cause / reusable rules │
│
┌──────────────┴──────────────┐
│ capability belief per skill │
│ consciousness / calibration │
│ boundary accuracy / waste │
└──────────────┬──────────────┘
│
global awareness section in the system prompt
+ annotation appended to the skill result
│
┌──────────┴──────────┐
│ nightly dream (timer)│
│ pick mismatches → │
│ reflect → edit the │
│ description/boundary │
│ → backup + journal + │
│ revert │
└─────────────────────┘
Inside tools/pre-execute the plugin registers an episode before the skill runs and starts a budgeted prediction subtask concurrently (default probe.mode = 'subagent', a real caller-delivered child via ctx.subagents.startActivation({ delivery: 'caller' }); inline uses ctx.llm.stream directly). The probe returns a structured prediction:
fit (0–1): whether and how well the skill fits this task;expected_use: the concrete steps the model is expected to take;success_signals: what using it correctly would look like;likely_pitfalls: the most likely traps;capability_gap: a capability the task needs that the skill may not actually provide;cheaper_alternative: a cheaper path when the skill is not needed.Subagents are the default: both prediction and judgement run as caller-delivered subtasks, and the skill call never waits for them (
probe.attachDeadlineMsdefaults to 0). If the service is unavailable, times out, or returns no text, the plugin falls back to a single inline call, so behaviour never disappears.inlineis cheaper for cost-sensitive setups.The task pack only takes real user requests: user-role metadata such as
runtime-context, AGENTS instructions and<system-reminder>is filtered out, and the whole derivation is scanned — otherwise “Time sampled…” can masquerade as the task.
tools/result records the skill load; session/event collects a bounded trace from the load point: assistant text, tool-call sequence (name/outcome/summary), user corrections, and the turn/end reason. The window closes at the same turn's turn/end, or after observe.maxTurnExtensionMs / observe.maxEvents. Closed sessions are never read again and the window does not stay in memory.
After the turn, one judge call produces (default judge.mode = 'subagent', also a caller-delivered child; falls back to inline):
score (0–100) and verdict (matched / partial / missed / misapplied);predictionAccuracy: agreement between prediction and reality;capabilityGap: difference between what the description claims and what was delivered;mismatches, rootCause (description / instructions / selection / user / execution);reusableRule: a rule that can be reused next time;cost.wastedEstimate: a conservative estimate of wasted tokens.Each skill keeps a belief: load count, verdict distribution, fit history, cost, learned boundaries. Core metrics:
| Metric | Definition | Question it answers |
|---|---|---|
fitAccuracy |
1 − Brier score (predicted fit vs. actual success) |
Does it predict itself accurately? |
boundaryAccuracy |
1 − share of judged calls with a capability gap |
Is its stated boundary accurate? |
precision |
1 − misapplied / judged (judged calls only) |
When it was called, was it on topic? |
consciousness |
100 × (0.45·fitAccuracy + 0.30·boundaryAccuracy + 0.25·precision) |
The combined consciousness score |
wasteRate |
wasted tokens / loaded skill tokens | How much did it waste? |
confidence |
<3 / <10 / ≥10 judged → low / medium / high |
How trustworthy is the score? |
No fake high score with few samples:
confidence = lowis reported, and both the panel and the model-facing text say so.Waste accounting: a call judged
misappliedormissedcounts its whole skill-body cost as wasted;partialonly counts rework tokens when rework was actually observed.
Dreaming · capability awareness, appears only when there is enough evidence, at most prompt.maxSkills lines, explicitly marked as observed tendency and not overriding the skill's own instructions.prompt.annotationMaxChars characters are appended to the result:probe.attachDeadlineMs > 0 opts into waiting; the default 0 never blocks the skill result, and the prediction is still recorded for the judge);first observation line when a first load has neither history nor a usable prediction — no invented metrics.The model sees this after reading the skill body and before acting, so it can adjust immediately.
dream.time (default 03:30, local time zone, configurable IANA zone) triggers a run; catch-up and jitter are supported. Each run:
caseWindowDays) missed / misapplied / low-score cases, grouped by skill (at most maxCasesPerSkill cases per skill, maxSkillsPerRun skills per run);description edit, a body capability-boundary section, reusable rules, confidence; the output cap is 2600 tokens, and invalid JSON gets one compact retry so a long proposal is not rejected wholesale for truncation;dream.editableSources (default user-dsh, user-agents), path-checked against the user skill roots (realpath), backup first, atomic replace, sha256 verified;before together with an explicitly estimated afterEstimate.Body edits use markers so repeated dreams only replace the block between them and never rewrite your hand-written body or other frontmatter:
<!-- dreaming:begin -->
## Capability boundaries (Dreaming · auto-maintained)
...
<!-- dreaming:end -->
Requires DSH ≥ 0.2.1-0 (see engines.dsh).
Install from this Git repository (the plugin is distributed from GitHub; npm publishing is planned).
In the Harness Plugins page, paste the repository URL:
https://github.com/puppetcat-fire/dsh-plugin-dreaming
or from the CLI for a profile:
dsh plugin --profile <profile> add git+https://github.com/puppetcat-fire/dsh-plugin-dreaming.git
A profile-level bundle takes effect for all sessions and survives restarts. Remove it from the Plugins page, or with plugin_manager(action="remove_bundle", target="dsh-plugin-dreaming").
Runtime packages (
@deepseek-ai/dsh-tools,@deepseek-ai/dsh-llm,@deepseek-ai/schemastery,@deepseek-ai/cordis) are provided by Harness; they are declared aspeerDependenciesand need no separate install.
All configuration lives in the profile's cordis.patch.yml (or a home patch). The plugin exports no editable volatile fields, so Settings shows no generic form; Settings → Dreaming is a read-only observability page. Defaults are defined in lib/config.js. The most useful keys:
| Key | Default | Meaning |
|---|---|---|
enabled |
true |
Master switch |
dataDir |
'' |
Data directory; empty = $DSH_HOME/dreaming |
probe.enabled |
true |
Predict on skill load |
probe.mode |
'subagent' |
subagent (default, real child) or inline (cheaper, used as the fallback) |
probe.sampleRate |
1 |
Sampling rate; known-gap skills are always probed |
probe.reasoningEffort |
'low' |
off / low / high / max; empty inherits the session route (DeepSeek rejects medium) |
probe.attachDeadlineMs |
0 |
Max wait for the same-call prediction; 0 (default) never blocks the skill call, and the prediction is still recorded for the judge |
probe.maxPerHour |
120 |
Hourly probe cap |
judge.enabled |
true |
Judge after the turn |
judge.mode |
'subagent' |
subagent (default) or inline; falls back automatically |
judge.reasoningEffort |
'low' |
off / low / high / max; empty inherits |
observe.maxTurnExtensionMs |
600000 |
Hard cap on the observation window |
prompt.awarenessSection |
true |
Inject the global awareness section |
prompt.annotateSkillResult |
true |
Annotate the skill result |
prompt.refreshMinutes |
10 |
Minimum refresh interval for the global section (KV-cache friendly) |
dream.enabled |
true |
Nightly dream |
dream.time |
'03:30' |
Local wall-clock time HH:MM |
dream.timeZone |
'' |
IANA zone; empty uses the process zone |
dream.scoreThreshold |
78 |
Below this score a judged episode is a mismatch case |
dream.autoApply |
false |
false records suggestions only; true applies validated edits with backup and revert |
dream.editableSources |
['user-dsh','user-agents'] |
Skill sources that may be edited on disk |
dream.dailyTokenBudget |
60000 |
Daily dream token budget |
run.maxConcurrent |
2 |
Concurrent probe/judge calls |
store.retainDays |
120 |
Episode retention |
store.maxEpisodes |
4000 |
Episode cap |
Example (probe office skills only and opt into automatic edits):
- id: dreaming
config:
probe:
sampleRate: 0.5
attachDeadlineMs: 1200
dream:
time: '04:10'
timeZone: Asia/Shanghai
autoApply: true
Settings → Dreaming · consciousness strength (settings.section, order 95):
The panel only reads /dreaming/api/* (a Host prefix route: JSON only, Origin check on POST, request-size limit). Every write goes through the same revert path as the dream engine.
$DSH_HOME/dreaming/ (episodes.jsonl, state.json, dreams.json, edits.json, backups/);edits.json stores the full pre-edit text and sha256 of the one skill file this plugin modified (in the local data directory only; never sent to a model, never shown in the panel/API);backups/<editId>/SKILL.md; edits.json records the before/after sha256;debug level only lengths and timings are logged..catch; every timer and AbortController is owned and released on unload;store offline and sessions are unaffected;conflict — your edits are never clobbered;Under the default configuration:
dream.dailyTokenBudget.If one wrong load wastes 3–8k tokens, cutting misuse by 10% is enough to pay for this overhead. The panel shows both “probe + judge spend” and “estimated waste avoided”, so you can tune sampling up or down.
cd dsh-plugin-dreaming
npm test # node --test --test-isolation=none "test/*.test.mjs"
# or run a single file:
node test/config.test.mjs
node test/stats.test.mjs
node test/store.test.mjs
ARCHITECTURE.md: the full design contract, Harness extension points, data schemas, module interfaces and failure posture;node:test only. CI runs the same suite on Windows.dream.autoApply is false, so dreams journal proposals without touching files. Enable it explicitly to correct descriptions/boundaries (backups, journal, conflict detection and revert still apply).dream.mode is recorded truthfully as inline and logs one warning.SKILL.md is a symlink the plugin refuses to write (symlink-path) and only records a suggestion, so the link is never replaced by a regular file./dreaming/api/ has no extra auth beyond the loopback binding (POST has an Origin check). Do not expose the profile's listener on a non-loopback address without adding authentication, and treat the data directory and backups as local user data.POST /dreaming/api/dream/run runId: the run is asynchronous; the call returns accepted:true immediately and runId may be null — the actual run id is in the next journal refresh.CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm、deepseek-harness。