@oyasmi/pipiclaw 0.5.2 → 0.5.3
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 +308 -209
- package/dist/agent/channel-runner.d.ts +2 -1
- package/dist/agent/channel-runner.js +15 -8
- package/dist/agent/index.d.ts +0 -1
- package/dist/agent/index.js +0 -1
- package/dist/agent/progress-formatter.d.ts +0 -1
- package/dist/agent/progress-formatter.js +0 -1
- package/dist/agent/run-queue.d.ts +0 -1
- package/dist/agent/run-queue.js +0 -1
- package/dist/agent/runner-factory.d.ts +0 -1
- package/dist/agent/runner-factory.js +0 -1
- package/dist/agent/session-events.d.ts +0 -1
- package/dist/agent/session-events.js +0 -1
- package/dist/agent/session-resource-gate.d.ts +10 -0
- package/dist/agent/session-resource-gate.js +44 -0
- package/dist/agent/type-guards.d.ts +0 -1
- package/dist/agent/type-guards.js +0 -1
- package/dist/agent/types.d.ts +0 -1
- package/dist/agent/types.js +0 -1
- package/dist/agent.d.ts +0 -1
- package/dist/agent.js +0 -1
- package/dist/command-extension.d.ts +0 -1
- package/dist/command-extension.js +0 -1
- package/dist/commands.d.ts +0 -1
- package/dist/commands.js +0 -1
- package/dist/config-loader.d.ts +0 -1
- package/dist/config-loader.js +1 -2
- package/dist/context.d.ts +0 -1
- package/dist/context.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/log.d.ts +0 -1
- package/dist/log.js +0 -1
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -1
- package/dist/memory/bootstrap.d.ts +0 -1
- package/dist/memory/bootstrap.js +0 -1
- package/dist/memory/candidates.d.ts +0 -1
- package/dist/memory/candidates.js +0 -1
- package/dist/memory/chinese-words.d.ts +0 -1
- package/dist/memory/chinese-words.js +64 -1
- package/dist/memory/consolidation.d.ts +0 -1
- package/dist/memory/consolidation.js +1 -2
- package/dist/memory/files.d.ts +0 -1
- package/dist/memory/files.js +0 -1
- package/dist/memory/lifecycle.d.ts +0 -1
- package/dist/memory/lifecycle.js +0 -1
- package/dist/memory/recall.d.ts +1 -1
- package/dist/memory/recall.js +76 -10
- package/dist/memory/session.d.ts +0 -1
- package/dist/memory/session.js +1 -2
- package/dist/model-utils.d.ts +0 -1
- package/dist/model-utils.js +0 -1
- package/dist/paths.d.ts +0 -1
- package/dist/paths.js +0 -1
- package/dist/prompt-builder.d.ts +0 -1
- package/dist/prompt-builder.js +0 -1
- package/dist/runtime/bootstrap.d.ts +0 -1
- package/dist/runtime/bootstrap.js +0 -1
- package/dist/runtime/delivery.d.ts +0 -1
- package/dist/runtime/delivery.js +0 -1
- package/dist/runtime/dingtalk.d.ts +0 -1
- package/dist/runtime/dingtalk.js +0 -1
- package/dist/runtime/events.d.ts +0 -1
- package/dist/runtime/events.js +0 -1
- package/dist/runtime/store.d.ts +0 -1
- package/dist/runtime/store.js +0 -1
- package/dist/sandbox.d.ts +0 -1
- package/dist/sandbox.js +1 -2
- package/dist/{llm-json.d.ts → shared/llm-json.d.ts} +0 -1
- package/dist/{llm-json.js → shared/llm-json.js} +0 -1
- package/dist/shared/markdown-sections.d.ts +0 -1
- package/dist/shared/markdown-sections.js +0 -1
- package/dist/{shell-escape.d.ts → shared/shell-escape.d.ts} +0 -1
- package/dist/{shell-escape.js → shared/shell-escape.js} +0 -1
- package/dist/shared/text-utils.d.ts +0 -1
- package/dist/shared/text-utils.js +0 -1
- package/dist/shared/type-guards.d.ts +0 -1
- package/dist/shared/type-guards.js +0 -1
- package/dist/shared/types.d.ts +0 -1
- package/dist/shared/types.js +0 -1
- package/dist/sidecar-worker.d.ts +0 -1
- package/dist/sidecar-worker.js +0 -1
- package/dist/subagents/discovery.d.ts +0 -1
- package/dist/subagents/discovery.js +0 -1
- package/dist/subagents/tool.d.ts +0 -1
- package/dist/subagents/tool.js +0 -1
- package/dist/tools/attach.d.ts +0 -1
- package/dist/tools/attach.js +0 -1
- package/dist/tools/bash.d.ts +0 -1
- package/dist/tools/bash.js +0 -1
- package/dist/tools/edit.d.ts +0 -1
- package/dist/tools/edit.js +1 -2
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.js +0 -1
- package/dist/tools/read.d.ts +0 -1
- package/dist/tools/read.js +1 -2
- package/dist/tools/truncate.d.ts +0 -1
- package/dist/tools/truncate.js +0 -1
- package/dist/tools/write-content.d.ts +0 -1
- package/dist/tools/write-content.js +1 -2
- package/dist/tools/write.d.ts +0 -1
- package/dist/tools/write.js +0 -1
- package/package.json +9 -3
- package/CHANGELOG.md +0 -47
- package/dist/agent/channel-runner.d.ts.map +0 -1
- package/dist/agent/channel-runner.js.map +0 -1
- package/dist/agent/index.d.ts.map +0 -1
- package/dist/agent/index.js.map +0 -1
- package/dist/agent/progress-formatter.d.ts.map +0 -1
- package/dist/agent/progress-formatter.js.map +0 -1
- package/dist/agent/run-queue.d.ts.map +0 -1
- package/dist/agent/run-queue.js.map +0 -1
- package/dist/agent/runner-factory.d.ts.map +0 -1
- package/dist/agent/runner-factory.js.map +0 -1
- package/dist/agent/session-events.d.ts.map +0 -1
- package/dist/agent/session-events.js.map +0 -1
- package/dist/agent/type-guards.d.ts.map +0 -1
- package/dist/agent/type-guards.js.map +0 -1
- package/dist/agent/types.d.ts.map +0 -1
- package/dist/agent/types.js.map +0 -1
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js.map +0 -1
- package/dist/command-extension.d.ts.map +0 -1
- package/dist/command-extension.js.map +0 -1
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js.map +0 -1
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config-loader.js.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/llm-json.d.ts.map +0 -1
- package/dist/llm-json.js.map +0 -1
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js.map +0 -1
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/memory/bootstrap.d.ts.map +0 -1
- package/dist/memory/bootstrap.js.map +0 -1
- package/dist/memory/candidates.d.ts.map +0 -1
- package/dist/memory/candidates.js.map +0 -1
- package/dist/memory/chinese-words.d.ts.map +0 -1
- package/dist/memory/chinese-words.js.map +0 -1
- package/dist/memory/consolidation.d.ts.map +0 -1
- package/dist/memory/consolidation.js.map +0 -1
- package/dist/memory/files.d.ts.map +0 -1
- package/dist/memory/files.js.map +0 -1
- package/dist/memory/lifecycle.d.ts.map +0 -1
- package/dist/memory/lifecycle.js.map +0 -1
- package/dist/memory/recall.d.ts.map +0 -1
- package/dist/memory/recall.js.map +0 -1
- package/dist/memory/session.d.ts.map +0 -1
- package/dist/memory/session.js.map +0 -1
- package/dist/model-utils.d.ts.map +0 -1
- package/dist/model-utils.js.map +0 -1
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/prompt-builder.d.ts.map +0 -1
- package/dist/prompt-builder.js.map +0 -1
- package/dist/runtime/bootstrap.d.ts.map +0 -1
- package/dist/runtime/bootstrap.js.map +0 -1
- package/dist/runtime/delivery.d.ts.map +0 -1
- package/dist/runtime/delivery.js.map +0 -1
- package/dist/runtime/dingtalk.d.ts.map +0 -1
- package/dist/runtime/dingtalk.js.map +0 -1
- package/dist/runtime/events.d.ts.map +0 -1
- package/dist/runtime/events.js.map +0 -1
- package/dist/runtime/store.d.ts.map +0 -1
- package/dist/runtime/store.js.map +0 -1
- package/dist/sandbox.d.ts.map +0 -1
- package/dist/sandbox.js.map +0 -1
- package/dist/shared/markdown-sections.d.ts.map +0 -1
- package/dist/shared/markdown-sections.js.map +0 -1
- package/dist/shared/text-utils.d.ts.map +0 -1
- package/dist/shared/text-utils.js.map +0 -1
- package/dist/shared/type-guards.d.ts.map +0 -1
- package/dist/shared/type-guards.js.map +0 -1
- package/dist/shared/types.d.ts.map +0 -1
- package/dist/shared/types.js.map +0 -1
- package/dist/shell-escape.d.ts.map +0 -1
- package/dist/shell-escape.js.map +0 -1
- package/dist/sidecar-worker.d.ts.map +0 -1
- package/dist/sidecar-worker.js.map +0 -1
- package/dist/subagents/discovery.d.ts.map +0 -1
- package/dist/subagents/discovery.js.map +0 -1
- package/dist/subagents/tool.d.ts.map +0 -1
- package/dist/subagents/tool.js.map +0 -1
- package/dist/tools/attach.d.ts.map +0 -1
- package/dist/tools/attach.js.map +0 -1
- package/dist/tools/bash.d.ts.map +0 -1
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/edit.d.ts.map +0 -1
- package/dist/tools/edit.js.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/read.d.ts.map +0 -1
- package/dist/tools/read.js.map +0 -1
- package/dist/tools/truncate.d.ts.map +0 -1
- package/dist/tools/truncate.js.map +0 -1
- package/dist/tools/write-content.d.ts.map +0 -1
- package/dist/tools/write-content.js.map +0 -1
- package/dist/tools/write.d.ts.map +0 -1
- package/dist/tools/write.js.map +0 -1
- package/docs/memory-audit.md +0 -330
- package/docs/memory-optimization-round2.md +0 -319
- package/docs/specs/001-implement-memory/memory-rfc.md +0 -297
- package/docs/specs/002-subagent/pi-subagent-analyse.txt +0 -190
- package/docs/specs/002-subagent/pi-subagent-design.txt +0 -266
- package/docs/specs/002-subagent/pi-subagent-phase1-plan.txt +0 -529
- package/docs/specs/003-improve-memory/design.md +0 -537
- package/docs/specs/003-improve-memory/interfaces-and-tests.md +0 -473
- package/docs/specs/003-improve-memory/spec.md +0 -357
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
# Pipiclaw Context Upgrade Spec
|
|
2
|
-
|
|
3
|
-
## Status
|
|
4
|
-
|
|
5
|
-
Draft
|
|
6
|
-
|
|
7
|
-
## Purpose
|
|
8
|
-
|
|
9
|
-
This spec defines the next-stage context architecture for `pipiclaw`.
|
|
10
|
-
|
|
11
|
-
It extends the existing [memory RFC](/Users/oyasmi/projects/pipiclaw/docs/memory-rfc.md) rather than replacing it wholesale.
|
|
12
|
-
|
|
13
|
-
The primary goal is not "more memory files". The goal is to materially improve:
|
|
14
|
-
|
|
15
|
-
1. cross-turn continuity
|
|
16
|
-
2. long-task stability
|
|
17
|
-
3. compaction resilience
|
|
18
|
-
4. sub-agent usefulness
|
|
19
|
-
5. skill usefulness in a long-running DingTalk channel workspace
|
|
20
|
-
|
|
21
|
-
The design remains file-based and runtime-local. It does not introduce embeddings, vector search, or a dedicated memory database.
|
|
22
|
-
|
|
23
|
-
## Problems To Solve
|
|
24
|
-
|
|
25
|
-
The current model is good enough to persist durable facts, but still leaves several gaps:
|
|
26
|
-
|
|
27
|
-
1. `MEMORY.md` and `HISTORY.md` are available but not proactively surfaced, so the model often fails to use them at the right time.
|
|
28
|
-
2. "current working state" is mixed into durable memory and is therefore either too weak, too stale, or too noisy.
|
|
29
|
-
3. compaction happens with only indirect help from memory consolidation, which is weaker than having an explicit working-state artifact.
|
|
30
|
-
4. sub-agents are context-isolated, but there is no standard way to give them the most relevant channel memory automatically.
|
|
31
|
-
5. skills are loaded, but they do not yet participate in a richer lifecycle where memory and runtime hooks reinforce one another.
|
|
32
|
-
|
|
33
|
-
## Non-Goals
|
|
34
|
-
|
|
35
|
-
1. No vector retrieval, embedding index, semantic database, or memory plugin framework.
|
|
36
|
-
2. No special standalone `memory_search` tool for the model.
|
|
37
|
-
3. No automatic mutation of workspace-level `SOUL.md`, `AGENTS.md`, or workspace `MEMORY.md`.
|
|
38
|
-
4. No proactive scanning of `log.jsonl` or `context.jsonl` as normal memory inputs.
|
|
39
|
-
5. No attempt to clone the full `claude-code` agent OS, swarm runtime, or prompt-cache infrastructure in this phase.
|
|
40
|
-
|
|
41
|
-
## Context Layers
|
|
42
|
-
|
|
43
|
-
The upgraded context model has five layers.
|
|
44
|
-
|
|
45
|
-
### 1. Identity Layer
|
|
46
|
-
|
|
47
|
-
- `workspace/SOUL.md`
|
|
48
|
-
- `workspace/AGENTS.md`
|
|
49
|
-
|
|
50
|
-
Semantics:
|
|
51
|
-
|
|
52
|
-
- loaded into session context at session start
|
|
53
|
-
- human-managed
|
|
54
|
-
- authoritative
|
|
55
|
-
- not rewritten by runtime maintenance
|
|
56
|
-
|
|
57
|
-
### 2. Shared Durable Memory
|
|
58
|
-
|
|
59
|
-
- `workspace/MEMORY.md`
|
|
60
|
-
|
|
61
|
-
Semantics:
|
|
62
|
-
|
|
63
|
-
- stable shared background
|
|
64
|
-
- read on demand
|
|
65
|
-
- not auto-rewritten by runtime
|
|
66
|
-
|
|
67
|
-
### 3. Channel Durable Memory
|
|
68
|
-
|
|
69
|
-
- `<channel>/MEMORY.md`
|
|
70
|
-
|
|
71
|
-
Semantics:
|
|
72
|
-
|
|
73
|
-
- durable facts, decisions, preferences, constraints, medium-horizon open loops
|
|
74
|
-
- append-first, then cleanup/fold
|
|
75
|
-
- channel-scoped
|
|
76
|
-
- runtime-managed
|
|
77
|
-
|
|
78
|
-
Important change:
|
|
79
|
-
|
|
80
|
-
`MEMORY.md` is no longer the primary owner of minute-by-minute "what am I doing right now" state. It may still contain open loops, but detailed active execution state belongs to `SESSION.md`.
|
|
81
|
-
|
|
82
|
-
### 4. Channel Working Memory
|
|
83
|
-
|
|
84
|
-
- `<channel>/SESSION.md`
|
|
85
|
-
|
|
86
|
-
Semantics:
|
|
87
|
-
|
|
88
|
-
- current task state
|
|
89
|
-
- active files and commands
|
|
90
|
-
- current hypotheses and next steps
|
|
91
|
-
- recent important errors and corrections
|
|
92
|
-
- channel-scoped handoff artifact across sessions and compactions
|
|
93
|
-
- runtime-managed
|
|
94
|
-
|
|
95
|
-
This is the major addition in this spec.
|
|
96
|
-
|
|
97
|
-
### 5. Channel History
|
|
98
|
-
|
|
99
|
-
- `<channel>/HISTORY.md`
|
|
100
|
-
|
|
101
|
-
Semantics:
|
|
102
|
-
|
|
103
|
-
- summarized chronological recovery material
|
|
104
|
-
- older work periods, decisions, milestones
|
|
105
|
-
- runtime-managed
|
|
106
|
-
- not intended for normal manual maintenance
|
|
107
|
-
|
|
108
|
-
## Cold Storage
|
|
109
|
-
|
|
110
|
-
These files remain cold:
|
|
111
|
-
|
|
112
|
-
- `<channel>/log.jsonl`
|
|
113
|
-
- `<channel>/context.jsonl`
|
|
114
|
-
|
|
115
|
-
They are not part of normal memory recall and are not proactively loaded into prompts.
|
|
116
|
-
|
|
117
|
-
## Core Invariants
|
|
118
|
-
|
|
119
|
-
The upgraded design must preserve these invariants:
|
|
120
|
-
|
|
121
|
-
1. File-based operation remains the source of truth.
|
|
122
|
-
2. The model should not need to remember to manually read the right memory file in common cases.
|
|
123
|
-
3. `SESSION.md` is the working-state artifact.
|
|
124
|
-
4. `MEMORY.md` is the durable-facts artifact.
|
|
125
|
-
5. `HISTORY.md` is the chronological-summary artifact.
|
|
126
|
-
6. Workspace memory remains human-managed.
|
|
127
|
-
7. Raw transport/session archives remain cold.
|
|
128
|
-
8. Failure of a background updater must not corrupt persisted memory files.
|
|
129
|
-
9. The system must degrade gracefully when an updater fails.
|
|
130
|
-
10. Memory improvements must help sub-agents and skills, not just the main agent.
|
|
131
|
-
|
|
132
|
-
## File Semantics
|
|
133
|
-
|
|
134
|
-
### `SESSION.md`
|
|
135
|
-
|
|
136
|
-
`SESSION.md` is channel-scoped hot memory.
|
|
137
|
-
|
|
138
|
-
It should answer:
|
|
139
|
-
|
|
140
|
-
1. What is the user currently trying to achieve?
|
|
141
|
-
2. What is the current state of work?
|
|
142
|
-
3. Which files and commands matter right now?
|
|
143
|
-
4. What constraints and recent failures should not be forgotten?
|
|
144
|
-
5. What are the next likely steps?
|
|
145
|
-
|
|
146
|
-
It should not become:
|
|
147
|
-
|
|
148
|
-
1. a raw transcript
|
|
149
|
-
2. a duplicate of all durable facts already in `MEMORY.md`
|
|
150
|
-
3. an infinite worklog
|
|
151
|
-
|
|
152
|
-
Read/write rule:
|
|
153
|
-
|
|
154
|
-
1. runtime-managed by default
|
|
155
|
-
2. eligible for automatic targeted recall
|
|
156
|
-
3. not intended for normal manual maintenance by the main agent
|
|
157
|
-
4. may be edited only when an explicit user/admin instruction makes that the task itself
|
|
158
|
-
|
|
159
|
-
### `MEMORY.md`
|
|
160
|
-
|
|
161
|
-
`MEMORY.md` remains the durable channel memory, but the threshold for what belongs here gets stricter.
|
|
162
|
-
|
|
163
|
-
It should keep:
|
|
164
|
-
|
|
165
|
-
1. stable preferences
|
|
166
|
-
2. durable decisions
|
|
167
|
-
3. medium-horizon constraints
|
|
168
|
-
4. important open loops that must survive beyond the current execution burst
|
|
169
|
-
|
|
170
|
-
It should avoid:
|
|
171
|
-
|
|
172
|
-
1. step-by-step active worklog
|
|
173
|
-
2. temporary local debugging observations unless they have lasting value
|
|
174
|
-
3. detailed "current state" that will likely be obsolete after a few turns
|
|
175
|
-
|
|
176
|
-
Read/write rule:
|
|
177
|
-
|
|
178
|
-
1. readable on demand
|
|
179
|
-
2. writable by runtime consolidation
|
|
180
|
-
3. still manually writable when necessary
|
|
181
|
-
4. cleanup is allowed to remove transient state that should now live in `SESSION.md`
|
|
182
|
-
|
|
183
|
-
### `HISTORY.md`
|
|
184
|
-
|
|
185
|
-
`HISTORY.md` remains the recovery narrative.
|
|
186
|
-
|
|
187
|
-
It should keep:
|
|
188
|
-
|
|
189
|
-
1. notable work periods
|
|
190
|
-
2. milestones
|
|
191
|
-
3. decision outcomes
|
|
192
|
-
4. enough chronology for later recovery
|
|
193
|
-
|
|
194
|
-
It should avoid:
|
|
195
|
-
|
|
196
|
-
1. dense per-turn detail
|
|
197
|
-
2. raw snippets copied from transcript
|
|
198
|
-
3. facts better represented in `MEMORY.md`
|
|
199
|
-
|
|
200
|
-
Read/write rule:
|
|
201
|
-
|
|
202
|
-
1. readable on demand
|
|
203
|
-
2. runtime-managed
|
|
204
|
-
3. not intended for ordinary manual edits
|
|
205
|
-
|
|
206
|
-
## Closed-Loop Lifecycle
|
|
207
|
-
|
|
208
|
-
The upgraded model introduces an explicit closed loop:
|
|
209
|
-
|
|
210
|
-
1. active session work happens in warm context
|
|
211
|
-
2. recent work updates `SESSION.md`
|
|
212
|
-
3. stable facts and medium-horizon open loops are promoted into `MEMORY.md`
|
|
213
|
-
4. older narrative is summarized into `HISTORY.md`
|
|
214
|
-
5. future prompts receive targeted recall from `SESSION.md`, `MEMORY.md`, and `HISTORY.md`
|
|
215
|
-
|
|
216
|
-
This loop must work even when:
|
|
217
|
-
|
|
218
|
-
1. the session compacts
|
|
219
|
-
2. the user starts a new session in the same channel
|
|
220
|
-
3. the process restarts
|
|
221
|
-
4. the main agent delegates work to a sub-agent
|
|
222
|
-
|
|
223
|
-
## Recall Model
|
|
224
|
-
|
|
225
|
-
The system should stop relying purely on "the model may remember to read memory files".
|
|
226
|
-
|
|
227
|
-
Instead, each turn may inject a small amount of relevant memory context chosen from:
|
|
228
|
-
|
|
229
|
-
1. `SESSION.md`
|
|
230
|
-
2. channel `MEMORY.md`
|
|
231
|
-
3. workspace `MEMORY.md`
|
|
232
|
-
4. channel `HISTORY.md`
|
|
233
|
-
|
|
234
|
-
Selection rules:
|
|
235
|
-
|
|
236
|
-
1. small budget
|
|
237
|
-
2. high precision
|
|
238
|
-
3. recency-aware
|
|
239
|
-
4. section-aware
|
|
240
|
-
5. prefer `SESSION.md` when current work state matters
|
|
241
|
-
6. prefer `MEMORY.md` when durable constraints or preferences matter
|
|
242
|
-
7. prefer `HISTORY.md` when recovery of older narrative matters
|
|
243
|
-
|
|
244
|
-
## SESSION.md Lifecycle Contract
|
|
245
|
-
|
|
246
|
-
`SESSION.md` must follow this lifecycle:
|
|
247
|
-
|
|
248
|
-
1. created automatically with the channel memory files
|
|
249
|
-
2. not loaded wholesale into every prompt
|
|
250
|
-
3. eligible for targeted recall injection
|
|
251
|
-
4. updated in the background during normal work
|
|
252
|
-
5. synchronously refreshed before context-reduction boundaries when possible
|
|
253
|
-
6. carried across `/new` session boundaries within the same channel
|
|
254
|
-
7. cleaned and condensed periodically so it remains current
|
|
255
|
-
8. recreated automatically if missing on an old channel directory
|
|
256
|
-
|
|
257
|
-
Important semantic rule:
|
|
258
|
-
|
|
259
|
-
`/new` starts a new model session, but does not imply "forget current channel work". `SESSION.md` is allowed to survive `/new` if the channel still has active work.
|
|
260
|
-
|
|
261
|
-
## Relationship Between SESSION.md And Existing Memory Files
|
|
262
|
-
|
|
263
|
-
The relationship is:
|
|
264
|
-
|
|
265
|
-
1. `SESSION.md` owns high-churn working state
|
|
266
|
-
2. `MEMORY.md` owns durable and semi-durable channel knowledge
|
|
267
|
-
3. `HISTORY.md` owns older narrative recovery
|
|
268
|
-
|
|
269
|
-
Promotion rules:
|
|
270
|
-
|
|
271
|
-
1. stable facts discovered in `SESSION.md` may be promoted into `MEMORY.md`
|
|
272
|
-
2. resolved work periods may be summarized into `HISTORY.md`
|
|
273
|
-
3. stale transient content should be removed from `SESSION.md`
|
|
274
|
-
4. cleanup may also remove overly transient content that had historically accumulated in `MEMORY.md`
|
|
275
|
-
|
|
276
|
-
This lets the system gradually migrate away from using channel `MEMORY.md` as the sole carrier of both durable and active state.
|
|
277
|
-
|
|
278
|
-
## Source Of Truth Precedence
|
|
279
|
-
|
|
280
|
-
When the same topic appears in multiple files, runtime and prompts should treat them in this precedence order:
|
|
281
|
-
|
|
282
|
-
1. `SESSION.md` for current active work state
|
|
283
|
-
2. `MEMORY.md` for durable constraints and decisions
|
|
284
|
-
3. `HISTORY.md` for older chronology
|
|
285
|
-
|
|
286
|
-
Practical implication:
|
|
287
|
-
|
|
288
|
-
1. a stale `MEMORY.md` note must not override a fresher `SESSION.md` current-state section
|
|
289
|
-
2. a stale `HISTORY.md` block must not override a fresher durable decision in `MEMORY.md`
|
|
290
|
-
|
|
291
|
-
## Compaction Contract
|
|
292
|
-
|
|
293
|
-
Compaction should become `SESSION.md`-aware.
|
|
294
|
-
|
|
295
|
-
The preferred order is:
|
|
296
|
-
|
|
297
|
-
1. refresh `SESSION.md`
|
|
298
|
-
2. run inline durable consolidation into `MEMORY.md` and `HISTORY.md`
|
|
299
|
-
3. compact using the latest `SESSION.md` as part of the retained context strategy
|
|
300
|
-
|
|
301
|
-
Graceful degradation rules:
|
|
302
|
-
|
|
303
|
-
1. if `SESSION.md` refresh fails, use the last persisted `SESSION.md`
|
|
304
|
-
2. if durable consolidation fails, compaction may still proceed if `SESSION.md` is available
|
|
305
|
-
3. failures must be logged and retried in background maintenance
|
|
306
|
-
|
|
307
|
-
This keeps compaction safe without turning memory maintenance into a hard availability dependency.
|
|
308
|
-
|
|
309
|
-
## Migration Contract
|
|
310
|
-
|
|
311
|
-
Existing channel directories already containing only `MEMORY.md` and `HISTORY.md` must migrate safely.
|
|
312
|
-
|
|
313
|
-
Migration rules:
|
|
314
|
-
|
|
315
|
-
1. missing `SESSION.md` is treated as normal and repaired by ensure-file bootstrap
|
|
316
|
-
2. existing `MEMORY.md` and `HISTORY.md` content remains authoritative
|
|
317
|
-
3. no one-time destructive rewrite of historical `MEMORY.md` content is required
|
|
318
|
-
4. transient content historically living in `MEMORY.md` is cleaned gradually by normal maintenance
|
|
319
|
-
|
|
320
|
-
This keeps rollout incremental and low-risk for live DingTalk channels.
|
|
321
|
-
|
|
322
|
-
## Sub-Agent Contract
|
|
323
|
-
|
|
324
|
-
Sub-agents remain isolated by default, but the runtime gains a standard way to provide them with the right memory context.
|
|
325
|
-
|
|
326
|
-
Two modes should exist:
|
|
327
|
-
|
|
328
|
-
1. isolated
|
|
329
|
-
- current behavior
|
|
330
|
-
- only runtime basics plus the explicitly provided task
|
|
331
|
-
2. contextual
|
|
332
|
-
- runtime prepends relevant memory and working-state context automatically
|
|
333
|
-
|
|
334
|
-
The contextual mode should pull from the same recall pipeline as the main agent, but with stricter budgets.
|
|
335
|
-
|
|
336
|
-
## Skill Contract
|
|
337
|
-
|
|
338
|
-
Skills should become lightweight participants in the upgraded context system.
|
|
339
|
-
|
|
340
|
-
Expected improvements:
|
|
341
|
-
|
|
342
|
-
1. richer frontmatter describing when a skill should be used
|
|
343
|
-
2. optional scoped hooks for session lifecycle events
|
|
344
|
-
3. optional declaration of memory relevance or path relevance
|
|
345
|
-
|
|
346
|
-
The skill system is still intentionally lighter than the `claude-code` version. The goal is stronger reuse and better context shaping, not a full plugin platform.
|
|
347
|
-
|
|
348
|
-
## Rollout Principle
|
|
349
|
-
|
|
350
|
-
This spec is designed for staged implementation:
|
|
351
|
-
|
|
352
|
-
1. first improve recall
|
|
353
|
-
2. then add `SESSION.md`
|
|
354
|
-
3. then bridge compaction
|
|
355
|
-
4. then upgrade sub-agent and skill integration
|
|
356
|
-
|
|
357
|
-
At each stage, existing `MEMORY.md` and `HISTORY.md` behavior must continue to work.
|