counterparts 0.3.11 → 0.3.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 +326 -0
- package/docs/QUICKSTART.md +5 -0
- package/docs/README.md +2 -2
- package/docs/module-map.md +3 -3
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +36 -10
- package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
- package/src/adapters/claude-code/NOTES.md +182 -0
- package/src/adapters/claude-code/bin/hook.ts +46 -12
- package/src/adapters/claude-code/bin/runner.ts +7 -1
- package/src/adapters/claude-code/doctor.ts +632 -18
- package/src/adapters/claude-code/hooks.ts +61 -16
- package/src/adapters/claude-code/index.ts +11 -0
- package/src/adapters/claude-code/night-run.ts +150 -14
- package/src/adapters/claude-code/transcript.ts +268 -1
- package/src/adapters/cli/CONTRACT.md +5 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
- package/src/adapters/cli/NOTES.md +111 -0
- package/src/adapters/cli/commands.ts +134 -92
- package/src/adapters/cli/dream-core.ts +57 -42
- package/src/adapters/cli/export.ts +320 -21
- package/src/adapters/cli/help.ts +2 -1
- package/src/adapters/cli/index.ts +1 -0
- package/src/adapters/cli/install.ts +39 -7
- package/src/adapters/cli/mechanisms.ts +7 -1
- package/src/adapters/cli/uninstall.ts +13 -5
- package/src/adapters/cli/wire.ts +189 -63
- package/src/adapters/config.ts +2 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
- package/src/adapters/dashboard/NOTES.md +79 -0
- package/src/adapters/dashboard/registries.ts +34 -2
- package/src/adapters/dashboard/web/README.md +19 -14
- package/src/adapters/dashboard/web/actions.ts +23 -1
- package/src/adapters/dashboard/web/flow.ts +14 -0
- package/src/adapters/dashboard/web/lanes.ts +10 -0
- package/src/adapters/dashboard/web/narrate.ts +88 -2
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +2 -0
- package/src/adapters/dashboard/web/pages/health/sections/wake.js +3 -1
- package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
- package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
- package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
- package/src/adapters/dashboard/web/server.ts +0 -5
- package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
- package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
- package/src/adapters/dashboard/web/views/health.ts +21 -3
- package/src/adapters/dashboard/web/views/search.ts +4 -45
- package/src/adapters/dashboard/web/views.ts +2 -2
- package/src/adapters/fired.ts +430 -28
- package/src/adapters/host-wiring.ts +300 -0
- package/src/adapters/hosts.ts +11 -0
- package/src/adapters/lifecycle.ts +42 -2
- package/src/adapters/log/index.ts +9 -0
- package/src/adapters/mcp/CONTRACT.md +151 -11
- package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
- package/src/adapters/mcp/NOTES.md +313 -1
- package/src/adapters/mcp/bin/serve.ts +74 -1
- package/src/adapters/mcp/deliberate.ts +169 -651
- package/src/adapters/mcp/facts.ts +1094 -0
- package/src/adapters/mcp/index.ts +25 -7
- package/src/adapters/mcp/meaning.ts +1610 -0
- package/src/adapters/mcp/server.ts +835 -150
- package/src/adapters/mcp/stdio.ts +3 -1
- package/src/adapters/mcp/stood-down.ts +51 -0
- package/src/adapters/mcp/tools.ts +167 -41
- package/src/adapters/plugin-run.sh +133 -0
- package/src/adapters/plugin.ts +329 -0
- package/src/adapters/sessions.ts +18 -4
- package/src/core/associate/CONTRACT.md +2 -1
- package/src/core/associate/INTERFACE-GAPS.md +6 -1
- package/src/core/associate/NOTES.md +45 -0
- package/src/core/briefing.ts +12 -3
- package/src/core/contradictions.ts +184 -0
- package/src/core/counterpart.ts +797 -51
- package/src/core/dream/CONTRACT.md +36 -4
- package/src/core/dream/INTERFACE-GAPS.md +29 -6
- package/src/core/dream/NOTES.md +107 -0
- package/src/core/dream/feeling-weeks.ts +198 -0
- package/src/core/dream/index.ts +109 -18
- package/src/core/dream/reflect.ts +346 -87
- package/src/core/dream/tunables.ts +24 -4
- package/src/core/encode/INTERFACE-GAPS.md +3 -1
- package/src/core/encode/NOTES.md +7 -0
- package/src/core/encode/words.ts +45 -0
- package/src/core/fit/INTERFACE-GAPS.md +8 -2
- package/src/core/fit/NOTES.md +39 -1
- package/src/core/fit/index.ts +40 -0
- package/src/core/handoff/CONTRACT.md +37 -2
- package/src/core/handoff/INTERFACE-GAPS.md +10 -0
- package/src/core/handoff/NOTES.md +72 -0
- package/src/core/handoff/index.ts +214 -12
- package/src/core/handoff/last-here.ts +6 -4
- package/src/core/mint.ts +12 -2
- package/src/core/physics/CONTRACT.md +14 -2
- package/src/core/physics/NOTES.md +33 -1
- package/src/core/physics/index.ts +28 -5
- package/src/core/prospective/CONTRACT.md +45 -6
- package/src/core/prospective/INTERFACE-GAPS.md +4 -0
- package/src/core/prospective/NOTES.md +138 -0
- package/src/core/prospective/derive.ts +33 -5
- package/src/core/prospective/index.ts +90 -5
- package/src/core/prospective/windows.ts +72 -1
- package/src/core/recall/CONTRACT.md +31 -12
- package/src/core/recall/INTERFACE-GAPS.md +28 -4
- package/src/core/recall/NOTES.md +70 -1
- package/src/core/recall/feeling-ask.ts +10 -1
- package/src/core/recall/index.ts +3 -1
- package/src/core/recall/probe.ts +58 -0
- package/src/core/recall/session.ts +46 -2
- package/src/core/recall/time-ask.ts +487 -0
- package/src/core/remember/CONTRACT.md +4 -1
- package/src/core/remember/INTERFACE-GAPS.md +9 -1
- package/src/core/remember/NOTES.md +8 -0
- package/src/core/remember/proposals.ts +47 -5
- package/src/core/revision.ts +18 -1
- package/src/core/schemas/CONTRACT.md +21 -1
- package/src/core/schemas/INTERFACE-GAPS.md +20 -2
- package/src/core/schemas/NOTES.md +144 -0
- package/src/core/schemas/aliases.ts +55 -5
- package/src/core/schemas/index.ts +93 -1
- package/src/core/schemas/types.ts +2 -0
- package/src/core/self/CONTRACT.md +32 -5
- package/src/core/self/INTERFACE-GAPS.md +7 -2
- package/src/core/self/NOTES.md +102 -1
- package/src/core/self/behind.ts +43 -3
- package/src/core/self/briefing.ts +12 -2
- package/src/core/self/chapter-address.ts +254 -0
- package/src/core/self/episodes.ts +27 -0
- package/src/core/self/index.ts +83 -8
- package/src/core/self/page.ts +88 -0
- package/src/core/self/tunables.ts +5 -0
- package/src/core/self/work.ts +35 -2
- package/src/core/self/writer.ts +30 -0
- package/src/core/sleep/INTERFACE-GAPS.md +22 -3
- package/src/core/sleep/NOTES.md +20 -1
- package/src/core/sleep/consolidate.ts +59 -7
- package/src/core/sleep/index.ts +3 -0
- package/src/core/sleep/prune.ts +6 -2
- package/src/core/sleep/types.ts +7 -0
- package/src/core/store/CONTRACT.md +16 -0
- package/src/core/store/NOTES.md +66 -0
- package/src/core/store/feelings.ts +14 -1
- package/src/core/store/index.ts +483 -16
- package/src/core/store/operational.ts +95 -2
- package/src/core/store/owner-op-seam.ts +23 -0
- package/src/core/time.ts +152 -0
- package/tools/install-loop/run.sh +48 -12
- package/src/adapters/dashboard/web/pages/memories/fold.js +0 -53
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHAT THE NPM INSTALL WROTE INTO CLAUDE CODE'S OWN FILES — recognised, and
|
|
3
|
+
* only ever READ.
|
|
4
|
+
*
|
|
5
|
+
* Two installs of Counterparts can now reach one Claude Code: the npm one,
|
|
6
|
+
* which `counterparts connect` wires by editing `settings.json` (five hook
|
|
7
|
+
* entries) and running `claude mcp add` (one server), and the Claude Code
|
|
8
|
+
* plugin, whose hooks and server Claude Code loads from the plugin's own files
|
|
9
|
+
* (`.claude-plugin/plugin.json`, `hooks/hooks.json`). Hooks from settings and
|
|
10
|
+
* hooks from plugins MERGE — they all fire, in parallel — and an MCP server
|
|
11
|
+
* from a plugin is a duplicate of a configured one only when it runs the same
|
|
12
|
+
* command, which ours never does (the paths differ). So a person who has both
|
|
13
|
+
* gets every turn captured twice and two sets of memory tools. `plugin.ts`
|
|
14
|
+
* decides who stands down; this file only answers "is the npm wiring there,
|
|
15
|
+
* and would it run?".
|
|
16
|
+
*
|
|
17
|
+
* Why it lives here and not in `cli/wire.ts`, which wrote the entries: the
|
|
18
|
+
* hook and the MCP server both need the answer, and adapters are leaves that
|
|
19
|
+
* never import each other (`mcp/INTERFACE-GAPS.md` §7). `isOurHookCommand`
|
|
20
|
+
* moved here from `wire.ts` on 2026-10-09 for that reason and `wire.ts`
|
|
21
|
+
* re-exports it unchanged, so the writer and this reader still recognise
|
|
22
|
+
* exactly the same set of commands.
|
|
23
|
+
*
|
|
24
|
+
* WHERE CLAUDE CODE KEEPS THEM, measured against 2.1.295 on 2026-10-09 (a
|
|
25
|
+
* throwaway HOME, `--debug-file` naming every settings path it read):
|
|
26
|
+
* `$CLAUDE_CONFIG_DIR/settings.json` and `$CLAUDE_CONFIG_DIR/.claude.json` when
|
|
27
|
+
* that variable is set, else `~/.claude/settings.json` and `~/.claude.json`.
|
|
28
|
+
* (`cli/wire.ts#userSettingsPath` puts the settings file at
|
|
29
|
+
* `$CLAUDE_CONFIG_DIR/.claude/settings.json`, which is not where Claude Code
|
|
30
|
+
* reads it; recorded in the plugin PR rather than changed here.)
|
|
31
|
+
*/
|
|
32
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
33
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
34
|
+
|
|
35
|
+
import { CONFIG_FLAG } from "./config-path.js";
|
|
36
|
+
import { parseScriptInvocation, runtimePresent, shellTokens } from "./runtime.js";
|
|
37
|
+
|
|
38
|
+
/** The name `counterparts connect` registers the server under
|
|
39
|
+
* (`cli/install.ts#MCP_SERVER_NAME`), spelled again because this module may
|
|
40
|
+
* not import the console. `test/plugin.test.ts` holds the two equal. */
|
|
41
|
+
export const NPM_MCP_NAME = "counterparts";
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* IS THIS COMMAND OURS TO REWRITE — which is a stricter question than "does it
|
|
45
|
+
* mention us" (review m1).
|
|
46
|
+
*
|
|
47
|
+
* `HOOK_COMMAND_MARK` answers the reporting question `doctor` asks: is a hook
|
|
48
|
+
* of ours installed on this event? It matches a COMPOSITE command, and it
|
|
49
|
+
* should — a wrapper that ends in `counterparts-hook` really does run our hook,
|
|
50
|
+
* and a doctor that said otherwise would be wrong.
|
|
51
|
+
*
|
|
52
|
+
* It is the wrong question for a WRITE. The review wrapped our hook two ways —
|
|
53
|
+
* `~/bin/log-start.sh && counterparts-hook`, and `/opt/mytool/bin/wrap --then
|
|
54
|
+
* counterparts-hook` — and `wire` overwrote the first with ours alone while
|
|
55
|
+
* `unwire` deleted the second outright. Both are somebody's own line, and
|
|
56
|
+
* `wire.ts`'s own promise is that nothing belonging to another tool is a
|
|
57
|
+
* candidate.
|
|
58
|
+
*
|
|
59
|
+
* So a command is ours to rewrite only when it IS our invocation and nothing
|
|
60
|
+
* else: our runtime and our hook script, or the installed shim, optionally
|
|
61
|
+
* followed by `--config <path>`. Anything with a shell operator in it is
|
|
62
|
+
* refused outright, whatever else it looks like — a command this cannot parse
|
|
63
|
+
* is a command this does not edit.
|
|
64
|
+
*
|
|
65
|
+
* `test/wire.test.ts` holds the two to each other in the direction that
|
|
66
|
+
* matters: everything `wire` WRITES is matched by both, so a hook we installed
|
|
67
|
+
* can never read as missing on the surface a person checks.
|
|
68
|
+
*/
|
|
69
|
+
export function isOurHookCommand(command: string): boolean {
|
|
70
|
+
// A shell operator means the line does something besides run our hook.
|
|
71
|
+
if (/&&|\|\||;|\||>|<|`|\$\(/.test(command)) return false;
|
|
72
|
+
const tokens = shellTokens(command);
|
|
73
|
+
if (tokens.length === 0) return false;
|
|
74
|
+
const tail = (from: number): boolean => {
|
|
75
|
+
const rest = tokens.slice(from);
|
|
76
|
+
if (rest.length === 0) return true;
|
|
77
|
+
return rest.length === 2 && rest[0] === CONFIG_FLAG && (rest[1] ?? "").length > 0;
|
|
78
|
+
};
|
|
79
|
+
const first = tokens[0] ?? "";
|
|
80
|
+
// The installed shim, by itself.
|
|
81
|
+
if (/(^|[/\\])counterparts-hook$/.test(first)) return tail(1);
|
|
82
|
+
// `<runtime> run <our hook script>`, or Node's
|
|
83
|
+
// `<runtime> --import <node-hooks.mjs> <our hook script>` (`runtime.ts`).
|
|
84
|
+
const run = parseScriptInvocation(tokens);
|
|
85
|
+
if (run !== null && /claude-code[/\\]bin[/\\]hook\.ts$/.test(run.script)) {
|
|
86
|
+
return tail(tokens.length - run.rest.length);
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Claude Code's two user-level files, wherever `CLAUDE_CONFIG_DIR` puts them. */
|
|
92
|
+
export function claudeUserFiles(
|
|
93
|
+
home: string,
|
|
94
|
+
env: Record<string, string | undefined>,
|
|
95
|
+
): { readonly settings: string; readonly globalConfig: string } {
|
|
96
|
+
const moved = (env["CLAUDE_CONFIG_DIR"] ?? "").trim();
|
|
97
|
+
return moved.length > 0
|
|
98
|
+
? { settings: join(moved, "settings.json"), globalConfig: join(moved, ".claude.json") }
|
|
99
|
+
: { settings: join(home, ".claude", "settings.json"), globalConfig: join(home, ".claude.json") };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A hook entry of ours in a settings file, and whether it would run. */
|
|
103
|
+
export interface WiredHook {
|
|
104
|
+
readonly file: string;
|
|
105
|
+
readonly event: string;
|
|
106
|
+
readonly command: string;
|
|
107
|
+
/** Its runtime and its script are both still there. A dead entry (an npm
|
|
108
|
+
* install removed, a checkout deleted) runs nothing, so nobody stands down
|
|
109
|
+
* for it — it is reported instead. */
|
|
110
|
+
readonly live: boolean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Our MCP registration in one of the two scopes `claude mcp add` writes. */
|
|
114
|
+
export interface WiredMcp {
|
|
115
|
+
readonly file: string;
|
|
116
|
+
readonly scope: "user" | "local";
|
|
117
|
+
readonly command: string;
|
|
118
|
+
readonly live: boolean;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface NpmWiring {
|
|
122
|
+
readonly hooks: readonly WiredHook[];
|
|
123
|
+
readonly mcp: readonly WiredMcp[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
127
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** A JSON object from disk, or null for absent, unreadable or not-an-object.
|
|
131
|
+
* Read-only, and quiet: a file this cannot read says nothing about our wiring. */
|
|
132
|
+
function readObject(path: string): Record<string, unknown> | null {
|
|
133
|
+
if (!existsSync(path)) return null;
|
|
134
|
+
try {
|
|
135
|
+
const value: unknown = JSON.parse(readFileSync(path, "utf8"));
|
|
136
|
+
return isRecord(value) ? value : null;
|
|
137
|
+
} catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Would this hook command actually run? The shim must be on PATH (or at the
|
|
144
|
+
* absolute path named); `<runtime> run <script>` needs both the runtime and
|
|
145
|
+
* the script on disk. `env` is the hook process's own, which is the host's —
|
|
146
|
+
* the PATH that counts is the one the host will run the command with.
|
|
147
|
+
*/
|
|
148
|
+
export function hookCommandLive(command: string, env: Record<string, string | undefined>): boolean {
|
|
149
|
+
const tokens = shellTokens(command);
|
|
150
|
+
const first = tokens[0] ?? "";
|
|
151
|
+
if (/(^|[/\\])counterparts-hook$/.test(first)) return runtimePresent(first, env);
|
|
152
|
+
const run = parseScriptInvocation(tokens);
|
|
153
|
+
if (run === null) return false;
|
|
154
|
+
return runtimePresent(run.exe, env) && existsSync(run.script);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Every hook entry of ours in one settings object, by event. */
|
|
158
|
+
function hooksIn(file: string, settings: Record<string, unknown> | null, env: Record<string, string | undefined>): WiredHook[] {
|
|
159
|
+
if (settings === null) return [];
|
|
160
|
+
const hooks = settings["hooks"];
|
|
161
|
+
if (!isRecord(hooks)) return [];
|
|
162
|
+
const out: WiredHook[] = [];
|
|
163
|
+
for (const [event, groups] of Object.entries(hooks)) {
|
|
164
|
+
if (!Array.isArray(groups)) continue;
|
|
165
|
+
for (const group of groups) {
|
|
166
|
+
if (!isRecord(group) || !Array.isArray(group["hooks"])) continue;
|
|
167
|
+
for (const entry of group["hooks"] as unknown[]) {
|
|
168
|
+
if (!isRecord(entry)) continue;
|
|
169
|
+
const command = entry["command"];
|
|
170
|
+
if (typeof command !== "string" || !isOurHookCommand(command)) continue;
|
|
171
|
+
out.push({ file, event, command, live: hookCommandLive(command, env) });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** An MCP entry named like ours, with the command it would run. */
|
|
179
|
+
function mcpEntry(
|
|
180
|
+
file: string,
|
|
181
|
+
scope: WiredMcp["scope"],
|
|
182
|
+
servers: unknown,
|
|
183
|
+
env: Record<string, string | undefined>,
|
|
184
|
+
): WiredMcp[] {
|
|
185
|
+
if (!isRecord(servers)) return [];
|
|
186
|
+
const entry = servers[NPM_MCP_NAME];
|
|
187
|
+
if (!isRecord(entry)) return [];
|
|
188
|
+
const command = typeof entry["command"] === "string" ? entry["command"] : "";
|
|
189
|
+
const args = Array.isArray(entry["args"]) ? (entry["args"] as unknown[]).filter((a): a is string => typeof a === "string") : [];
|
|
190
|
+
// A disabled-in-`/mcp` server is still registered; Claude Code keeps the
|
|
191
|
+
// switch elsewhere and this reader does not chase it. Live means "the
|
|
192
|
+
// command it names is there", which is the half that decides double tools.
|
|
193
|
+
const run = parseScriptInvocation([command, ...args]);
|
|
194
|
+
const live =
|
|
195
|
+
command.length > 0 &&
|
|
196
|
+
runtimePresent(command, env) &&
|
|
197
|
+
(run === null ? true : existsSync(isAbsolute(run.script) ? run.script : resolve(run.script)));
|
|
198
|
+
return [{ file, scope, command: [command, ...args].join(" "), live }];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** The Counterparts plugin as Claude Code records it, for `doctor`. */
|
|
202
|
+
export interface PluginInstallRead {
|
|
203
|
+
/** `counterparts@<marketplace>`. */
|
|
204
|
+
readonly id: string;
|
|
205
|
+
readonly installPath: string | null;
|
|
206
|
+
readonly version: string | null;
|
|
207
|
+
/** `enabledPlugins[id]` from user, project and local settings, the last one
|
|
208
|
+
* that says anything winning (Claude Code's precedence); unset is enabled. */
|
|
209
|
+
readonly enabled: boolean;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Is the plugin installed, and on? Read from `installed_plugins.json` under
|
|
214
|
+
* Claude Code's plugins root (`CLAUDE_CODE_PLUGIN_CACHE_DIR`, else
|
|
215
|
+
* `<config dir>/plugins`) and `enabledPlugins` in the settings files — the
|
|
216
|
+
* shapes measured on 2.1.295 (`{"version":2,"plugins":{"<id>":[{"scope",
|
|
217
|
+
* "installPath","version",…}]}}`; `enabledPlugins: {"<id>": true|false}`).
|
|
218
|
+
* READ-ONLY. Null when no `counterparts@…` install is recorded.
|
|
219
|
+
*/
|
|
220
|
+
export function pluginInstall(input: {
|
|
221
|
+
readonly home: string;
|
|
222
|
+
readonly env: Record<string, string | undefined>;
|
|
223
|
+
readonly cwd: string | null;
|
|
224
|
+
}): PluginInstallRead | null {
|
|
225
|
+
const moved = (input.env["CLAUDE_CONFIG_DIR"] ?? "").trim();
|
|
226
|
+
const configDir = moved.length > 0 ? moved : join(input.home, ".claude");
|
|
227
|
+
const cacheRoot = (input.env["CLAUDE_CODE_PLUGIN_CACHE_DIR"] ?? "").trim();
|
|
228
|
+
const pluginsRoot = cacheRoot.length > 0 ? cacheRoot : join(configDir, "plugins");
|
|
229
|
+
const installed = readObject(join(pluginsRoot, "installed_plugins.json"));
|
|
230
|
+
const plugins = installed === null ? null : installed["plugins"];
|
|
231
|
+
if (!isRecord(plugins)) return null;
|
|
232
|
+
const id = Object.keys(plugins).find((k) => k.startsWith(`${NPM_MCP_NAME}@`));
|
|
233
|
+
if (id === undefined) return null;
|
|
234
|
+
const records = plugins[id];
|
|
235
|
+
const first = Array.isArray(records) ? (records as unknown[]).find(isRecord) : isRecord(records) ? records : undefined;
|
|
236
|
+
const files = [claudeUserFiles(input.home, input.env).settings];
|
|
237
|
+
if (input.cwd !== null && input.cwd.length > 0) {
|
|
238
|
+
files.push(join(resolve(input.cwd), ".claude", "settings.json"), join(resolve(input.cwd), ".claude", "settings.local.json"));
|
|
239
|
+
}
|
|
240
|
+
let enabled = true;
|
|
241
|
+
for (const file of files) {
|
|
242
|
+
const settings = readObject(file);
|
|
243
|
+
const on = settings === null ? undefined : settings["enabledPlugins"];
|
|
244
|
+
if (isRecord(on) && typeof on[id] === "boolean") enabled = on[id] as boolean;
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
id,
|
|
248
|
+
installPath: first !== undefined && typeof first["installPath"] === "string" ? first["installPath"] : null,
|
|
249
|
+
version: first !== undefined && typeof first["version"] === "string" ? first["version"] : null,
|
|
250
|
+
enabled,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The npm install's wiring as Claude Code will see it for a session in `cwd`:
|
|
256
|
+
* our hook entries in the user, project and local settings files, and a
|
|
257
|
+
* server registered as `counterparts` in the user scope (`~/.claude.json`) or
|
|
258
|
+
* the local scope (that file's `projects[<cwd>]`). READ-ONLY, every file,
|
|
259
|
+
* always.
|
|
260
|
+
*/
|
|
261
|
+
export function npmWiring(input: {
|
|
262
|
+
readonly home: string;
|
|
263
|
+
readonly env: Record<string, string | undefined>;
|
|
264
|
+
/** The session's project directory: `CLAUDE_PROJECT_DIR`, else the event's `cwd`. */
|
|
265
|
+
readonly cwd: string | null;
|
|
266
|
+
/**
|
|
267
|
+
* Which half to read; both by default. The hook passes `{ mcp: false }`:
|
|
268
|
+
* it runs every turn and needs only the hooks, and `~/.claude.json` grows
|
|
269
|
+
* with every project's history, so parsing it per prompt is a cost for
|
|
270
|
+
* nothing. The server, once per session, passes `{ hooks: false }`.
|
|
271
|
+
*/
|
|
272
|
+
readonly read?: { readonly hooks?: boolean; readonly mcp?: boolean };
|
|
273
|
+
}): NpmWiring {
|
|
274
|
+
const { settings, globalConfig } = claudeUserFiles(input.home, input.env);
|
|
275
|
+
const cwd = input.cwd === null || input.cwd.length === 0 ? null : resolve(input.cwd);
|
|
276
|
+
const hooks: WiredHook[] = [];
|
|
277
|
+
if (input.read?.hooks !== false) {
|
|
278
|
+
hooks.push(...hooksIn(settings, readObject(settings), input.env));
|
|
279
|
+
if (cwd !== null) {
|
|
280
|
+
for (const name of ["settings.json", "settings.local.json"]) {
|
|
281
|
+
const file = join(cwd, ".claude", name);
|
|
282
|
+
hooks.push(...hooksIn(file, readObject(file), input.env));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const mcp: WiredMcp[] = [];
|
|
287
|
+
if (input.read?.mcp === false) return { hooks, mcp };
|
|
288
|
+
const global = readObject(globalConfig);
|
|
289
|
+
if (global !== null) {
|
|
290
|
+
mcp.push(...mcpEntry(globalConfig, "user", global["mcpServers"], input.env));
|
|
291
|
+
const projects = global["projects"];
|
|
292
|
+
if (cwd !== null && isRecord(projects) && isRecord(projects[cwd])) {
|
|
293
|
+
mcp.push(...mcpEntry(globalConfig, "local", (projects[cwd] as Record<string, unknown>)["mcpServers"], input.env));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
// A project `.mcp.json` is not read: `connect` never writes one, and a server
|
|
297
|
+
// there waits for the person's approval, so its presence says nothing about
|
|
298
|
+
// whether it runs.
|
|
299
|
+
return { hooks, mcp };
|
|
300
|
+
}
|
package/src/adapters/hosts.ts
CHANGED
|
@@ -45,6 +45,17 @@ export function isHostName(value: unknown): value is string {
|
|
|
45
45
|
*/
|
|
46
46
|
export const DESKTOP_HOST = "claude-desktop";
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* WHAT THE INSTALL AND QUICKSTART SAY ABOUT DESKTOP'S TOOL PERMISSION
|
|
50
|
+
* (2026-10-02). Measured in a Desktop chat: its tools still asked before each
|
|
51
|
+
* call, the model never called `wake`, answered "what do you remember about
|
|
52
|
+
* yesterday" from `recall` alone, and called that slice the full record.
|
|
53
|
+
* Nothing on disk says which setting Desktop holds, so it is said, not
|
|
54
|
+
* measured; doctor's Claude Desktop line says it too.
|
|
55
|
+
*/
|
|
56
|
+
export const DESKTOP_ALWAYS_ALLOW =
|
|
57
|
+
"In Claude Desktop, set the counterparts tools to Always allow, or a chat cannot wake on its own: Desktop asks before each tool, and until it may, the model does not call a tool nobody asked for.";
|
|
58
|
+
|
|
48
59
|
/**
|
|
49
60
|
* THE ONE PLACE EVERY DESKTOP CHAT SHARES (owner, 2026-09-30: one pseudo-scope
|
|
50
61
|
* for now, per-Project only if real use calls for it). Not a directory: it
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
ADAPTER_ASK_EVENT,
|
|
50
50
|
BOUNDARY_EVENT,
|
|
51
51
|
Counterpart,
|
|
52
|
+
ENVELOPE_GAVE_WAY_EVENT,
|
|
52
53
|
RECALL_CREDIT_EVENT,
|
|
53
54
|
RECALL_DELIVERED_EVENT,
|
|
54
55
|
SPAWN_FAILED_EVENT,
|
|
@@ -56,7 +57,7 @@ import {
|
|
|
56
57
|
SPAWN_STARTED_EVENT,
|
|
57
58
|
WRITE_UP_FAILED_EVENT,
|
|
58
59
|
} from "../core/counterpart.js";
|
|
59
|
-
import type { AdapterDurableEventName, PlainReminder } from "../core/counterpart.js";
|
|
60
|
+
import type { AdapterDurableEventName, DeliveryWarningName, PlainReminder } from "../core/counterpart.js";
|
|
60
61
|
import type {
|
|
61
62
|
BoundaryKind,
|
|
62
63
|
CaptureResult,
|
|
@@ -770,7 +771,7 @@ export class Lifecycle implements HostLifecycle {
|
|
|
770
771
|
this.emit("adapter.writeup.deferred", { reason: "host-cap", need: bytes, room });
|
|
771
772
|
// WHICH MOMENT gave way is the host's word for it (2026-09-30): Claude
|
|
772
773
|
// Code's SessionStart, or Desktop's `wake` tool result.
|
|
773
|
-
this.
|
|
774
|
+
this.noteDeliveryWarning(ENVELOPE_GAVE_WAY_EVENT, { hook: opts.label ?? "session-start", part: "pointer", need: bytes, room }, input);
|
|
774
775
|
outcome("deferred", "host-cap");
|
|
775
776
|
return "";
|
|
776
777
|
}
|
|
@@ -1164,6 +1165,20 @@ export class Lifecycle implements HostLifecycle {
|
|
|
1164
1165
|
/** Of the expanded, how many this session had seen as a QUIET POINTER
|
|
1165
1166
|
* (reached only through links, 2026-09-28) — whether pointers are used. */
|
|
1166
1167
|
pointersExpanded: summary.pointersExpanded,
|
|
1168
|
+
/** RECALL'S HIT RATE (2026-10-09, measurement only): what recall showed
|
|
1169
|
+
* this session since the last boundary that judged, by lane, and how
|
|
1170
|
+
* many of those the replies neither expanded nor quoted — with their
|
|
1171
|
+
* ids. Footnotes are the cued ones; a quiet pointer counts as a pointer.
|
|
1172
|
+
* On a `budget-exceeded` row a quote may have gone unchecked. */
|
|
1173
|
+
shownLoud: summary.shown.loud,
|
|
1174
|
+
shownFootnotes: summary.shown.footnotes,
|
|
1175
|
+
shownPointers: summary.shown.pointers,
|
|
1176
|
+
unusedLoud: summary.unused.loud,
|
|
1177
|
+
unusedFootnotes: summary.unused.footnotes,
|
|
1178
|
+
unusedPointers: summary.unused.pointers,
|
|
1179
|
+
shownNotUsed: summary.shownNotUsed.slice(0, 64),
|
|
1180
|
+
shownNotUsedTotal: summary.shownNotUsed.length,
|
|
1181
|
+
judgedThrough: summary.judgedThrough,
|
|
1167
1182
|
elapsedMs: this.nowFn() - started,
|
|
1168
1183
|
});
|
|
1169
1184
|
} catch (err) {
|
|
@@ -1587,6 +1602,31 @@ export class Lifecycle implements HostLifecycle {
|
|
|
1587
1602
|
this.counterpart.noteAdapterEvent(name, row);
|
|
1588
1603
|
}
|
|
1589
1604
|
|
|
1605
|
+
/**
|
|
1606
|
+
* A DELIVERY WARNING, to the ring and, since 2026-10-02, to box 2 — what an
|
|
1607
|
+
* envelope could not carry (`counterpart.ts#ENVELOPE_GAVE_WAY_EVENT` and its
|
|
1608
|
+
* three siblings). One row per name, hook, part and session per lived day:
|
|
1609
|
+
* the count doctor reads is of sessions and days, not of prompts. The
|
|
1610
|
+
* session is null where the caller has none. Never throws.
|
|
1611
|
+
*/
|
|
1612
|
+
protected noteDeliveryWarning(
|
|
1613
|
+
name: DeliveryWarningName,
|
|
1614
|
+
data: Record<string, string | number | boolean | null>,
|
|
1615
|
+
input?: SessionInput,
|
|
1616
|
+
): void {
|
|
1617
|
+
this.emit(name, data);
|
|
1618
|
+
try {
|
|
1619
|
+
const store = this.counterpart.store;
|
|
1620
|
+
const day = store.livedDay();
|
|
1621
|
+
const session = input?.sessionId ?? null;
|
|
1622
|
+
const date = input?.at ?? localDate(this.nowFn(), store.zone());
|
|
1623
|
+
const key = [name, String(data["hook"] ?? ""), String(data["part"] ?? ""), session ?? "", String(day)].join(":");
|
|
1624
|
+
this.counterpart.noteAdapterEvent(name, { ...data, date, session }, { dedupKey: key });
|
|
1625
|
+
} catch {
|
|
1626
|
+
/* a warning that cannot be recorded is still said on the ring */
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1590
1630
|
protected emit(name: string, data: Record<string, string | number | boolean | null>): void {
|
|
1591
1631
|
const event: AdapterEvent = { at: this.nowFn(), name, data };
|
|
1592
1632
|
this.ring.push(event);
|
|
@@ -93,6 +93,8 @@ export const LOGGED: { readonly names: ReadonlySet<string>; readonly suffixes: r
|
|
|
93
93
|
"adapter.night.handed",
|
|
94
94
|
// ...and its morning catch-up: granted, written up, left owed (2026-10-01).
|
|
95
95
|
"adapter.night.writeup",
|
|
96
|
+
// ...and what its own transcript said about the host's cut (2026-10-09).
|
|
97
|
+
"adapter.night.spill",
|
|
96
98
|
// ...and a run a session nobody watched started (2026-10-01, lane 8).
|
|
97
99
|
"adapter.dream.unwatched",
|
|
98
100
|
"dream.night",
|
|
@@ -112,6 +114,13 @@ export const LOGGED: { readonly names: ReadonlySet<string>; readonly suffixes: r
|
|
|
112
114
|
// Refusals a process or a tool made by name.
|
|
113
115
|
"runner.refused",
|
|
114
116
|
"mcp.refused",
|
|
117
|
+
// A tool result cut to the host's ceiling (2026-10-02; durable too).
|
|
118
|
+
"mcp.result.oversize",
|
|
119
|
+
// A hook past the host's cap, a dropped notice, a start over its ceiling
|
|
120
|
+
// (2026-10-02; durable too).
|
|
121
|
+
"adapter.envelope.overcap",
|
|
122
|
+
"adapter.notice.dropped",
|
|
123
|
+
"adapter.injection.overbudget",
|
|
115
124
|
]),
|
|
116
125
|
// Every failure, and every stand-down.
|
|
117
126
|
suffixes: [".failed", ".threw", ".standdown"],
|
|
@@ -33,11 +33,15 @@ load-bearing, and this adapter is designed on the assumption that it will be use
|
|
|
33
33
|
- **An explicit "remember this" channel exists, and is never the interface.** [v1]
|
|
34
34
|
decisions-triage 07-23, constitution line 8.
|
|
35
35
|
- **One tool, not two.** [v1] test-triage `mcp.test.ts` — a real design decision, kept.
|
|
36
|
-
- **Deliberate recall is
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
- **Deliberate recall is its own path, not the ambient one with lower thresholds.** [v1]
|
|
37
|
+
behavioral-spec §9.1 G2 kept the ambient ranking and added a labeled lower-confidence
|
|
38
|
+
tier; **dropped 2026-10-03 (Release B, Mike's design of 10-02/10-03):** a question asked
|
|
39
|
+
on purpose gets every memory it matches, in one of two modes with their own ranking
|
|
40
|
+
(§6f), and the vivid / quiet / dim tiers and the hard gates effort could not overturn are
|
|
41
|
+
gone.
|
|
42
|
+
- **One kind of ask per call**: a handle (or `ids`) reads *that* memory exactly; a question
|
|
43
|
+
runs a search in the mode it names. Expansion must never degrade into fuzzy search. [v1]
|
|
44
|
+
§9.1 G1.
|
|
41
45
|
- **Exposure is not recording; retrieval is.** A SEARCH strengthens nothing — `build()` is
|
|
42
46
|
pure, and nothing on that path calls `resolveUse` or `coactivate`, so a memory that was
|
|
43
47
|
merely ranked and listed is no stronger for it. EXPANDING one in full, by id or by title
|
|
@@ -98,7 +102,7 @@ load-bearing, and this adapter is designed on the assumption that it will be use
|
|
|
98
102
|
|
|
99
103
|
**Inputs** — MCP tool calls:
|
|
100
104
|
`note(text[, salience, relevance, emotional, predictive, kind, title, updates])`,
|
|
101
|
-
`recall(handle | question)`, `status()`, `session_end(session, memories[], handoff?,
|
|
105
|
+
`recall(handle | ids[, part] | question, mode[, page])`, `status()`, `session_end(session, memories[], handoff?,
|
|
102
106
|
writeUp?, part?)` whose
|
|
103
107
|
entries take the same optional dimensions — `handoff` (2026-09-20, E1) is a FIELD on the
|
|
104
108
|
call and never one of the entries: it is this directory's working context, filed by
|
|
@@ -117,7 +121,8 @@ each bound to one session as `session_end` is (their fields are `tools.ts`'s); f
|
|
|
117
121
|
Claude Desktop client only, `wake()` (§5 G20) and the `prompts/list` / `prompts/get` pair; the
|
|
118
122
|
session's observer role; the launch's session, scope, data dir and host when the host can
|
|
119
123
|
supply them.
|
|
120
|
-
**Outputs** — a stored memory (note),
|
|
124
|
+
**Outputs** — a stored memory (note), a mode's answer as labeled lines or memories read
|
|
125
|
+
whole (recall), a
|
|
121
126
|
census (status), an appended chapter with the episode's id and the chapter number the store
|
|
122
127
|
actually wrote (chapter), the written self page or the version a write to it produced
|
|
123
128
|
(`self_page`, 2026-09-18); telemetry by reference.
|
|
@@ -144,8 +149,11 @@ actually wrote (chapter), the written self page or the version a write to it pro
|
|
|
144
149
|
its description, plus an engine-side check wherever the rule is safety-relevant
|
|
145
150
|
(scar §2.16 — v1's `thread.open` shipped with no criteria and produced 33 opens and zero
|
|
146
151
|
closes in 13 days).
|
|
147
|
-
4. **[M] `recall` and `status` write
|
|
148
|
-
runs both against a populated store and checks
|
|
152
|
+
4. **[M] `recall` and `status` write no memory and train nothing in the call**, asserted by
|
|
153
|
+
a test that runs both against a populated store and checks every body, version and use
|
|
154
|
+
count is unchanged. What `recall` writes is bookkeeping: its durable count row, the
|
|
155
|
+
handle-resolution line, and (2026-10-03) the `asked` gate records that let a QUOTE of
|
|
156
|
+
an answer's words be credited at the boundary — the credit itself is the boundary's.
|
|
149
157
|
5. **[M] Under observer, every tool stands down over the wire and says so** (scars E7,
|
|
150
158
|
§2.4).
|
|
151
159
|
6. **[M] Confidential material is returned only in the owner's own session.**
|
|
@@ -430,6 +438,137 @@ writing one; `reflect` phase `settle` is the reflection's door; the dream's `pro
|
|
|
430
438
|
takes a `settle` action. Every settle is `core/contradictions.ts#settle`'s, recorded with
|
|
431
439
|
who, how, why and when; an observer writes nothing and says so.
|
|
432
440
|
|
|
441
|
+
**[M] A held `updates` answers in the same field** (2026-10-09, the update guard,
|
|
442
|
+
`schemas/CONTRACT.md` §5 1b). A `changed` or `corrected` at a memory that looks unrelated
|
|
443
|
+
comes back as `settled: {ok: false, held: true, reason: "looks-unrelated", how, holds,
|
|
444
|
+
over, title, text, detail}` — the old memory's own title and text (none for a
|
|
445
|
+
confidential one outside the owner's session), the two ids to settle with, and
|
|
446
|
+
`HELD_HINT`, the neighbours' ask said for this case. The held memory is not listed again
|
|
447
|
+
among the neighbours. Nothing else about the reply changes: the memory is stored.
|
|
448
|
+
|
|
449
|
+
## 6c. Re-feeling while awake (2026-10-02, lane B)
|
|
450
|
+
|
|
451
|
+
**[M]** `note` takes `feelingsNow`: how memories this session was shown feel now, recorded
|
|
452
|
+
beside the first feeling (which is never rewritten), with or without `text`. One not shown
|
|
453
|
+
here — not delivered by `recall`, not a write's neighbour, not surfaced (a footnote is not)
|
|
454
|
+
by ambient recall for the session; kept per session — is refused with the way in (recall it by id). At most once a calendar day per
|
|
455
|
+
memory, five a call; source `awake`, `recorded_later` today. The path and the rest of its
|
|
456
|
+
guarantees are the reflection's (`dream/reflect.ts#Reflections.feelAgain`).
|
|
457
|
+
|
|
458
|
+
## 6d. The writer's three fields (2026-10-03, schema v12)
|
|
459
|
+
|
|
460
|
+
**[M]** `note` and each `session_end` entry (write-ups included) take `occurredOn` (when
|
|
461
|
+
it happened: a day, month, range or year, read by `time.ts`), `saidBy` (owner, self,
|
|
462
|
+
inferred) and `status` (done, planned, proposed, asked), all optional. **[M]** None of them
|
|
463
|
+
refuses a memory: one that cannot be read is dropped and said in the answer's `facts`, with
|
|
464
|
+
what to send instead (`server.ts#readWriteFacts`). **[M]** A revision by `updates` carries
|
|
465
|
+
each over from the memory it revises unless one is sent (null: none); nothing moves off the
|
|
466
|
+
old memory (`counterpart.ts#carryFacts`). **[A]** The descriptions ask the writer to
|
|
467
|
+
resolve "last week" to a date at write time and keep `occurredOn` (when it happened) apart
|
|
468
|
+
from `eventDate` (a future date to be reminded on). Facts mode reads them (§6f).
|
|
469
|
+
|
|
470
|
+
## 6e. Meaning mode (2026-10-03, Release B of deliberate recall)
|
|
471
|
+
|
|
472
|
+
`recall` with `mode: "meaning"` arranges what memory holds about a subject over time;
|
|
473
|
+
the reader interprets (`meaning.ts`). Working defaults, held lightly; the revisit checks
|
|
474
|
+
them.
|
|
475
|
+
|
|
476
|
+
- **[M]** The subject is read from the question: the cards its names reach
|
|
477
|
+
(`Schemas#subjectsIn` → `memory_subjects`), the one it is about the arc and the rest
|
|
478
|
+
one-liners (`meaning.ts#subjectOf`, 2026-10-09). A name the words before it ask about
|
|
479
|
+
("what has X been", "how has X changed", "about X", "my arc with X") ranks over a plain
|
|
480
|
+
mention, and that over an aside ("been to Y", "since Y", "after Y"); a name joined to the one
|
|
481
|
+
before it ("X and Y") shares its place; a name typed in lower case that its card
|
|
482
|
+
capitalises ("will" for Will) is a step under the same place typed as written; the
|
|
483
|
+
owner's own card leaves a place it shares; then the first named wins, memory counts
|
|
484
|
+
only break a tie, and the answer says when more than one were asked about alike. The
|
|
485
|
+
owner's "I" ("you" in the counterpart's voice) asked about is his card, except in a
|
|
486
|
+
question about feeling or about "us" — and under any card named outside an aside:
|
|
487
|
+
"what have I done on Driftwood" is Driftwood's, "how have I been since Driftwood" his.
|
|
488
|
+
"us" (the words *us*, *ourselves*, *together*) is the memories marked
|
|
489
|
+
`about: us`; a ranked question about feeling (`feeling-ask.ts`) with no card is the
|
|
490
|
+
stamps that match it by word, core and whose — narrowed, when it names a topic no card
|
|
491
|
+
holds, to the stamped moments the topic's words reach (none reached: all of them, and
|
|
492
|
+
the answer says no card names the topic); with none of those, the question's rarer
|
|
493
|
+
words and its meaning, and the answer says no card named it. A word the asker
|
|
494
|
+
capitalised mid-sentence is a topic word whatever it is ("Will"), matched as typed.
|
|
495
|
+
- **[M]** The arc is the chapters (`epi_…#N`) that hold the subject — its memories
|
|
496
|
+
written in a chapter's span, and the chapter's own words naming it — ranked by how much
|
|
497
|
+
they hold and shown in time order, 8 to a page (`page`); moments a session wrote with no
|
|
498
|
+
chapter, or under none of its chapters (their moments unknown, from before v12, or a
|
|
499
|
+
later write-up), are an entry per session, labelled which. A long arc keeps its start, its end and
|
|
500
|
+
its turns (the feelings' valence changing sign) on page 1; what is not on the page folds
|
|
501
|
+
to one line per stretch.
|
|
502
|
+
- **[M]** Feelings are shown per entry with whose they are, the asker's and the other's
|
|
503
|
+
side by side, never merged.
|
|
504
|
+
- **[M]** Faded moments (kept a fifth of their strength or less, `deliberate.ts#hasFaded`)
|
|
505
|
+
are a few labelled lines after the arc, not in its slots. Readings (dream gists,
|
|
506
|
+
reflection entries) that name the subject or cite its memories are listed dated; the
|
|
507
|
+
dream journal stays outside. Open threads and reminders dated today or later are listed.
|
|
508
|
+
Recurring subjects and feelings are laid side by side, unnamed.
|
|
509
|
+
- **[M]** A search writes nothing. `shown` is exactly the ids printed, for the seen set
|
|
510
|
+
and quote credit. Confidential material is left out of a non-owner's answer silently.
|
|
511
|
+
The rendered answer stays inside the 12,000-character list room (`fit`).
|
|
512
|
+
- **[A]** "us" is not triggered by *we* or *our*, which a question uses for joint work.
|
|
513
|
+
A chapter address names a chapter, and `ids` / `handle` open it (§6f).
|
|
514
|
+
|
|
515
|
+
## 6f. Facts mode, and the recall tool's two modes (2026-10-03, Release B)
|
|
516
|
+
|
|
517
|
+
Working defaults, held lightly; the revisit (a few days of daily use) checks them.
|
|
518
|
+
|
|
519
|
+
- **[M]** A `question` needs `mode`: `facts` or `meaning`, no default (`mode-required`,
|
|
520
|
+
`mode-unknown`, each naming both modes). `ids` and `handle` take none: a `mode` beside
|
|
521
|
+
one is ignored and the result says so (`modeIgnored`). Each mode is its own path with
|
|
522
|
+
its own ranking; the answer is its rendering, shipped as `answer`, with the `ids` it
|
|
523
|
+
showed. Those ids feed the seen set (`note.feelingsNow`) and the `asked` records, so
|
|
524
|
+
quoting their words credits at the boundary (`counterpart.ts#creditReferences`).
|
|
525
|
+
- **[M]** Facts mode (`facts.ts`) pools every memory the question's content words reach
|
|
526
|
+
(each word's every hit, weighted by rarity), every memory linked to a card it names
|
|
527
|
+
(`memory_subjects`), and the 100 nearest by meaning above this embedder's inline floor;
|
|
528
|
+
a question that is only a time pools its window. Score is the sum over the ways matched;
|
|
529
|
+
recency breaks ties only; the order is stable and pages by 10 (`page`).
|
|
530
|
+
- **[M]** A time in the question (`recall/time-ask.ts`) filters, by `occurred_on` or, with
|
|
531
|
+
none, the learned date (the line says which); weeks and months stretch two days each
|
|
532
|
+
side, "N days ago" one, dates stay exact; matches outside are counted as distinct facts,
|
|
533
|
+
after the same folds and without the weak tail. "Last Saturday" (any weekday; "this
|
|
534
|
+
past Saturday" too) is the most recent one strictly before today — asked on a Saturday,
|
|
535
|
+
a week back — and exact; "this Saturday" and "on Saturday" are not read, since either
|
|
536
|
+
can be the coming one. A word in front of a date bounds it (2026-10-09): "before" /
|
|
537
|
+
"prior to" is every day before it and "after" every day after it, open-ended (the
|
|
538
|
+
header says "through 07-21", "07-23 onward"); "until", "till", "up to", "up until" and
|
|
539
|
+
"by" every day through it; "since" from it to today, as before. When the date names a
|
|
540
|
+
thing on that day ("before the 7/22 flight", "after July 22's standup": a "the" in front
|
|
541
|
+
and a word after it, or an 's), "before" and "after" keep that day (review of #338). A
|
|
542
|
+
bound does not stretch ("since" keeps a month's two days). A date is `2026-07-22`, `2026-07`, `7/22`
|
|
543
|
+
or `07-22` (month first), `7/22/2026`, "July 22", "22 July", "July 22, 2026"; a year
|
|
544
|
+
written with it is the year meant; without one, this year's when its month has begun,
|
|
545
|
+
else last year's ("before 1/5" asked on 01-03 is through this year's 01-04). "Around the X"
|
|
546
|
+
resolves X to the date of its best word match, shown in the header; "the last session"
|
|
547
|
+
is the session "Last here" names (else the newest here), whose rows lead.
|
|
548
|
+
- **[M]** Rebuilt here, not inherited from ambient: a chapter and its copy are one result
|
|
549
|
+
(the chapter, labeled journal); near-duplicates (token overlap ≥ 0.85) are left out and
|
|
550
|
+
counted; the self page and handoffs are never results; confidential rows are absent for
|
|
551
|
+
a non-owner, silently (counted on the durable row only).
|
|
552
|
+
- **[M]** Each result: title and id; `you said / I said / inferred · status · happened <date>
|
|
553
|
+
| no event date`; `learned <date> in <dir> · <who> · CURRENT`; earlier versions folded
|
|
554
|
+
(in-place `versions`, and `changed` pairs — an earlier one that matched brings its
|
|
555
|
+
current one in); corrected ones hidden and counted; `open` and unsettled pairs named —
|
|
556
|
+
never naming a confidential or removed memory to a non-owner.
|
|
557
|
+
Unknown fields say so. Short bodies whole, long ones a 300-character excerpt.
|
|
558
|
+
- **[M]** The header counts distinct facts; "may not be everything" only when the meaning
|
|
559
|
+
cap cut or weak matches (below a fifth of the best score) were left out. Faded matches
|
|
560
|
+
(kept a fifth of their strength or less — `deliberate.ts#hasFaded`, the rule meaning
|
|
561
|
+
mode shares) are title lines after the results, never in the main slots. The whole
|
|
562
|
+
answer stays under 12,000 characters.
|
|
563
|
+
- **[M]** `ids` / `handle` read a chapter address `epi_…#N` as that chapter
|
|
564
|
+
(`self/chapter-address.ts#resolveChapter`): its words, `address`, and its `moments`.
|
|
565
|
+
- **Deleted promises (Mike, 10-03):** "effort lowers the bar but never removes the hard
|
|
566
|
+
gates: a memory the conversation did not reach stays dark"; "the lower-confidence tier is
|
|
567
|
+
labeled"; "a question about time is answered with the session it means first, marked
|
|
568
|
+
`recent: true`" (replaced by the time filter and the session anchor); "a question about
|
|
569
|
+
feeling is answered from the feelings recorded on memories" (meaning mode's now);
|
|
570
|
+
"considered is reported beside `consideredCap`" (the count header replaces it).
|
|
571
|
+
|
|
433
572
|
## 7. Open questions
|
|
434
573
|
|
|
435
574
|
1. **Does `note` still need to exist** once the experiencer writes at every session end?
|
|
@@ -438,8 +577,9 @@ who, how, why and when; an observer writes nothing and says so.
|
|
|
438
577
|
2. **What does `status` show?** v1's answer grew into a dashboard. The useful minimum is
|
|
439
578
|
probably the symmetry counters (created versus exited per kind, up-moves versus
|
|
440
579
|
down-moves) — the numbers that made v1's pathologies visible — not a store census.
|
|
441
|
-
3.
|
|
442
|
-
the
|
|
580
|
+
3. ~~**Should `recall` expose the confidence label as a tier name or a number?**~~
|
|
581
|
+
**Moot 2026-10-03:** the tiers are retired; a facts result says how it matched (its
|
|
582
|
+
ways) and the header says when the tail was weak (§6f).
|
|
443
583
|
4. **NAMED GAP: the stated-emotion gate cannot supply the `emotional` dimension.**
|
|
444
584
|
The obvious brain-faithful move — affect at encoding stamping a memory vivid — is not
|
|
445
585
|
available here, for two separate reasons, and neither was papered over. (a)
|