counterparts 0.3.12 → 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 +184 -0
- package/docs/module-map.md +1 -1
- 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 +131 -0
- package/src/adapters/claude-code/bin/hook.ts +35 -2
- package/src/adapters/claude-code/doctor.ts +155 -21
- package/src/adapters/claude-code/hooks.ts +49 -7
- package/src/adapters/claude-code/index.ts +11 -0
- package/src/adapters/claude-code/night-run.ts +133 -12
- 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 +65 -14
- package/src/adapters/cli/dream-core.ts +57 -42
- package/src/adapters/cli/export.ts +320 -21
- 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/dashboard/INTERFACE-GAPS.md +10 -1
- package/src/adapters/dashboard/NOTES.md +79 -0
- package/src/adapters/dashboard/registries.ts +10 -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 +4 -1
- package/src/adapters/dashboard/web/lanes.ts +3 -0
- package/src/adapters/dashboard/web/narrate.ts +30 -2
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
- 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 +1 -1
- package/src/adapters/dashboard/web/views/search.ts +4 -45
- package/src/adapters/dashboard/web/views.ts +2 -2
- package/src/adapters/fired.ts +410 -25
- package/src/adapters/host-wiring.ts +300 -0
- package/src/adapters/lifecycle.ts +14 -0
- package/src/adapters/log/index.ts +2 -0
- package/src/adapters/mcp/CONTRACT.md +33 -3
- package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
- package/src/adapters/mcp/NOTES.md +136 -0
- package/src/adapters/mcp/bin/serve.ts +30 -0
- package/src/adapters/mcp/facts.ts +13 -1
- package/src/adapters/mcp/meaning.ts +208 -13
- package/src/adapters/mcp/server.ts +87 -15
- package/src/adapters/mcp/stdio.ts +3 -1
- package/src/adapters/mcp/stood-down.ts +51 -0
- package/src/adapters/mcp/tools.ts +27 -7
- package/src/adapters/plugin-run.sh +133 -0
- package/src/adapters/plugin.ts +329 -0
- 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 +451 -18
- package/src/core/dream/CONTRACT.md +5 -2
- package/src/core/dream/INTERFACE-GAPS.md +29 -6
- package/src/core/dream/NOTES.md +21 -0
- package/src/core/dream/index.ts +33 -1
- package/src/core/dream/reflect.ts +20 -5
- package/src/core/encode/INTERFACE-GAPS.md +3 -1
- package/src/core/fit/INTERFACE-GAPS.md +8 -2
- package/src/core/fit/NOTES.md +5 -2
- package/src/core/fit/index.ts +4 -1
- package/src/core/handoff/CONTRACT.md +37 -2
- package/src/core/handoff/INTERFACE-GAPS.md +10 -0
- package/src/core/handoff/NOTES.md +66 -0
- package/src/core/handoff/index.ts +214 -12
- package/src/core/mint.ts +8 -2
- package/src/core/physics/CONTRACT.md +11 -1
- package/src/core/physics/NOTES.md +30 -0
- package/src/core/physics/index.ts +26 -4
- 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 +6 -2
- package/src/core/recall/INTERFACE-GAPS.md +28 -4
- package/src/core/recall/NOTES.md +57 -1
- package/src/core/recall/probe.ts +58 -0
- package/src/core/recall/session.ts +27 -3
- package/src/core/recall/time-ask.ts +116 -18
- package/src/core/remember/CONTRACT.md +4 -1
- package/src/core/remember/INTERFACE-GAPS.md +9 -1
- package/src/core/remember/proposals.ts +38 -5
- package/src/core/revision.ts +5 -0
- package/src/core/schemas/CONTRACT.md +13 -1
- package/src/core/schemas/INTERFACE-GAPS.md +20 -2
- package/src/core/schemas/NOTES.md +127 -0
- package/src/core/schemas/types.ts +2 -0
- package/src/core/self/CONTRACT.md +15 -4
- package/src/core/self/INTERFACE-GAPS.md +7 -2
- package/src/core/self/NOTES.md +49 -0
- package/src/core/self/briefing.ts +12 -2
- package/src/core/self/index.ts +82 -8
- package/src/core/self/page.ts +88 -0
- package/src/core/sleep/INTERFACE-GAPS.md +22 -3
- package/src/core/sleep/NOTES.md +11 -0
- package/src/core/sleep/prune.ts +6 -2
- package/src/core/store/NOTES.md +14 -0
- package/src/core/store/index.ts +107 -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
|
+
}
|
|
@@ -1165,6 +1165,20 @@ export class Lifecycle implements HostLifecycle {
|
|
|
1165
1165
|
/** Of the expanded, how many this session had seen as a QUIET POINTER
|
|
1166
1166
|
* (reached only through links, 2026-09-28) — whether pointers are used. */
|
|
1167
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,
|
|
1168
1182
|
elapsedMs: this.nowFn() - started,
|
|
1169
1183
|
});
|
|
1170
1184
|
} catch (err) {
|
|
@@ -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",
|
|
@@ -438,6 +438,14 @@ writing one; `reflect` phase `settle` is the reflection's door; the dream's `pro
|
|
|
438
438
|
takes a `settle` action. Every settle is `core/contradictions.ts#settle`'s, recorded with
|
|
439
439
|
who, how, why and when; an observer writes nothing and says so.
|
|
440
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
|
+
|
|
441
449
|
## 6c. Re-feeling while awake (2026-10-02, lane B)
|
|
442
450
|
|
|
443
451
|
**[M]** `note` takes `feelingsNow`: how memories this session was shown feel now, recorded
|
|
@@ -466,8 +474,18 @@ the reader interprets (`meaning.ts`). Working defaults, held lightly; the revisi
|
|
|
466
474
|
them.
|
|
467
475
|
|
|
468
476
|
- **[M]** The subject is read from the question: the cards its names reach
|
|
469
|
-
(`Schemas#subjectsIn` → `memory_subjects`), the
|
|
470
|
-
one-liners
|
|
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
|
|
471
489
|
`about: us`; a ranked question about feeling (`feeling-ask.ts`) with no card is the
|
|
472
490
|
stamps that match it by word, core and whose — narrowed, when it names a topic no card
|
|
473
491
|
holds, to the stamped moments the topic's words reach (none reached: all of them, and
|
|
@@ -512,7 +530,19 @@ Working defaults, held lightly; the revisit (a few days of daily use) checks the
|
|
|
512
530
|
- **[M]** A time in the question (`recall/time-ask.ts`) filters, by `occurred_on` or, with
|
|
513
531
|
none, the learned date (the line says which); weeks and months stretch two days each
|
|
514
532
|
side, "N days ago" one, dates stay exact; matches outside are counted as distinct facts,
|
|
515
|
-
after the same folds and without the weak tail. "
|
|
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"
|
|
516
546
|
resolves X to the date of its best word match, shown in the header; "the last session"
|
|
517
547
|
is the session "Last here" names (else the newest here), whose rows lead.
|
|
518
548
|
- **[M]** Rebuilt here, not inherited from ambient: a chapter and its copy are one result
|
|
@@ -9,6 +9,12 @@ the honest fix is, and where the proof lives. Written 2026-08-25 alongside
|
|
|
9
9
|
|
|
10
10
|
## 1. `recall/` has no deliberate mode — the tiering lives here
|
|
11
11
|
|
|
12
|
+
*(Noted 2026-10-09: the re-tiering below is retired. Since #323 (2026-10-03) a question
|
|
13
|
+
takes a `mode`, facts or meaning, each with its own ranking (`facts.ts`, `meaning.ts`),
|
|
14
|
+
and nothing in this adapter calls `Recall.build()`; `deliberate.ts` keeps the address
|
|
15
|
+
paths. The per-call override asked for below was never built, and this adapter no longer
|
|
16
|
+
needs it. Kept as written.)*
|
|
17
|
+
|
|
12
18
|
**What exists.** `Recall.build()` is the pure half of the ambient path and is
|
|
13
19
|
public precisely so it can be reused ("a private half is a promise, not a seam",
|
|
14
20
|
`recall/index.ts`). It returns every candidate's verdict, so the information a
|
|
@@ -196,7 +202,8 @@ answers an exact TITLE with the whole body. So a session that named a memory and
|
|
|
196
202
|
|
|
197
203
|
**Closed on the tool side, where the resolution happened.** `server.ts#noteHandleResolution`
|
|
198
204
|
writes `<salted hash of the handle> → <resolved id>` to `adapters/expansions.ts`'s log, and
|
|
199
|
-
`claude-code/hooks.ts#creditAtBoundary`
|
|
205
|
+
`claude-code/hooks.ts#creditAtBoundary` (in `adapters/lifecycle.ts` since #292,
|
|
206
|
+
2026-09-30) translates the transcript's own handle with it
|
|
200
207
|
before `creditReferences` sees the slice. `reference.ts` is unchanged and still resolves
|
|
201
208
|
nothing; it is simply handed the address the tool reached.
|
|
202
209
|
|
|
@@ -328,7 +335,9 @@ JSON" was narrowed to what stays true: never without a notice, and never the doc
|
|
|
328
335
|
migrates, and that is a hook, while the automatic snapshot runs only in the worker, after
|
|
329
336
|
its own open, once a day. If a pre-migration copy is wanted, the place is the writer path
|
|
330
337
|
of `openOperational`, just before the migrate transaction — a store decision, not this
|
|
331
|
-
adapter's.
|
|
338
|
+
adapter's. *(CLOSED 2026-09-24 by #214, noted 2026-10-09: `openOperational`'s writer
|
|
339
|
+
path copies the store to `snapshots/<time>-pre-migration-…` before it migrates
|
|
340
|
+
(`store/pre-migration.ts`).)*
|
|
332
341
|
|
|
333
342
|
## 11. The page writer has no settle door — OPEN 2026-09-29
|
|
334
343
|
|
|
@@ -337,3 +346,16 @@ reflection (`reflect` phase `settle`), the owner (`counterparts settle`). The pa
|
|
|
337
346
|
writes through `self_page`, which takes no settle; if it settles through `note`, the
|
|
338
347
|
trail says the launching session. A `settle` on `self_page`, or a page-writer claim on
|
|
339
348
|
`note`, would close it — neither is built until the writer is seen wanting one.
|
|
349
|
+
|
|
350
|
+
## 12. Nobody reads how often the update guard fires — OPEN 2026-10-09
|
|
351
|
+
|
|
352
|
+
A held `updates` (`schemas/CONTRACT.md` §5 1b) leaves one durable `contradiction.held`
|
|
353
|
+
row: the two ids, the `how`, which reading decided (`meaning` or `words`), the cosine and
|
|
354
|
+
the shared-word count, the door, whether it was a write-up, and the session. The dashboard
|
|
355
|
+
narrates each row on the flow lane; nothing COUNTS them. `core/contradictions.ts#heldCorrections`
|
|
356
|
+
is the reader, written and tested and called by nobody: holds since a day, by which
|
|
357
|
+
reading, and how many the writer settled by hand afterwards (the guard's likely mistakes).
|
|
358
|
+
A doctor line — "N held this week, M settled after" — is the obvious caller; `doctor.ts`
|
|
359
|
+
belonged to another lane when the guard landed, so it was left for that lane to add. The
|
|
360
|
+
number to watch is `settledAfter / held`: high means the 0.30 bar holds back real
|
|
361
|
+
corrections, and it is the evidence for moving it.
|
|
@@ -1201,3 +1201,139 @@ reason (the function is synchronous, so the embedder is not in it). What the bui
|
|
|
1201
1201
|
`matched`; `--full` is the facts answer; `--json` the `FactsResult`, whose `memories`,
|
|
1202
1202
|
`considered` and `id`/`title`/`body`/`kind` the dashboard's search already reads. `--voiced`
|
|
1203
1203
|
is accepted and unused (feelings are meaning's).
|
|
1204
|
+
(2026-10-09: the dashboard read more than that — `tier`, `from` and a date at the front of
|
|
1205
|
+
the body — and lost them quietly, its tests fed by hand in the old shape; see the
|
|
1206
|
+
dashboard's NOTES of that day. `ask` takes `--mode meaning` now, and there `--voiced`
|
|
1207
|
+
decides whose "I" a question about feeling means.)
|
|
1208
|
+
|
|
1209
|
+
## 2026-10-09 — meaning's subject is the card the question is about
|
|
1210
|
+
|
|
1211
|
+
Meaning mode took the card with the most memories as the arc. On a real store that is
|
|
1212
|
+
usually the owner's own card, so "what has Ilya been to Mike" answered about Mike, with Ilya
|
|
1213
|
+
under "also named". The review of #333 found it on the dashboard and fixed that side by
|
|
1214
|
+
turning the owner's "I" into "you"; the `recall` tool picked the same way. Reproduced on the
|
|
1215
|
+
demo store through the tool: "what has Ilya Broadbent been to Rosalind Achebe" (6 memories
|
|
1216
|
+
against the owner's 10) answered about Rosalind, and "how has Ilya Broadbent changed since
|
|
1217
|
+
Nkechi Abernathy arrived" answered about Nkechi.
|
|
1218
|
+
|
|
1219
|
+
- **Grammar first, then the order of the names, then counts** (`meaning.ts#subjectOf`). Each
|
|
1220
|
+
name is read in place by the words just before it: asked about ("what has X been", "how
|
|
1221
|
+
has X changed", "how did X", "about X", "my arc with X", "between X and Y"), an aside
|
|
1222
|
+
("been to Y", "meant for Y", "since Y", "after Y", "than Y"), or plain. A bare "to" is
|
|
1223
|
+
not an aside: "what happened to X after Y left" is X's. A name joined to the one before it
|
|
1224
|
+
("X and Y", "X, Y") shares its place. The best place wins; within it the first named; a
|
|
1225
|
+
longer name at the same spot, then more memories, then the name, break a tie.
|
|
1226
|
+
- **The owner leaves a place he shares.** Every memory in his store is his, so beside
|
|
1227
|
+
another card in the same place the other says more ("Rosalind and Ilya" is Ilya's arc).
|
|
1228
|
+
When the grammar puts him alone in the subject's place ("what has Rosalind been to Ilya")
|
|
1229
|
+
he is the subject, and the person is the one-liner.
|
|
1230
|
+
- **Ambiguity is said, not hidden.** More than one card left in the best place: the arc
|
|
1231
|
+
follows the first, and a note says "it asks about A and B alike: this follows A, named
|
|
1232
|
+
first". "Also named" already offers the other's arc by name.
|
|
1233
|
+
- **The owner's "I", asked about, is his card again.** The pronoun that means the owner by
|
|
1234
|
+
`feeling-ask.ts`'s rule ("you" when the counterpart asks, "I"/"me"/"myself" when the
|
|
1235
|
+
owner does) counts as his card, read by the identity core's id rather than his name, only
|
|
1236
|
+
where it sits in an asked-about place. So the dashboard's "what have I been like" (sent as
|
|
1237
|
+
"what have you been like", voiced) finds his card, as it did before #333; "do you remember
|
|
1238
|
+
the budget" names nothing and is read by its words; "my" and "your" own a topic and name
|
|
1239
|
+
no one. Off for a question about feeling (the pronoun says whose feeling, so "how have you
|
|
1240
|
+
felt lately" stays the feelings answer) and for "us".
|
|
1241
|
+
- **Facts mode is untouched.** `facts.ts` reads `subjectsIn` itself and imports nothing from
|
|
1242
|
+
`meaning.ts`. The only code changed is `meaning.ts`; the `recall` description gained one
|
|
1243
|
+
sentence in its meaning claim, so a benchmark pinned to facts answers the same.
|
|
1244
|
+
- **Not done:** an arc of two cards together (the memories naming both). "What has Rosalind
|
|
1245
|
+
been to Ilya" is still one card's arc; the overlap would be the better answer, and a
|
|
1246
|
+
bigger change.
|
|
1247
|
+
- **Review of #334: two seams, both regressions against master.** (1) The owner's pronoun
|
|
1248
|
+
took the about place's full rank, so "what have I done on Driftwood", "how have I been
|
|
1249
|
+
with Nkechi" and "what have you learned from Ilya" answered with his own card where
|
|
1250
|
+
master answered with the card named. It now ranks under any card named in a plain or
|
|
1251
|
+
about place and over an aside (`mentionRank`): "how have I been since Driftwood" and
|
|
1252
|
+
"what have I been to Ilya" stay his; a name joined to the pronoun still takes the about
|
|
1253
|
+
place. (2) The alias index matches a name in any case, so a card named with a common
|
|
1254
|
+
word — Will, Hope, Bridge — is found in "how will Driftwood go" and "I hope Ilya is ok",
|
|
1255
|
+
and "first named wins" made it the arc, with an "alike" note. A name typed in lower case
|
|
1256
|
+
where its card writes a capital is now a step under the same place typed as written; a
|
|
1257
|
+
question typed all in lower case loses the step on every name, so the grammar still
|
|
1258
|
+
decides. The matching itself (and a Will card linking every "will" in the store's
|
|
1259
|
+
memories at birth) is the alias index's, untouched here.
|
|
1260
|
+
|
|
1261
|
+
## 2026-10-09 — `recurring` beside `eventDate` (the owner's design, held lightly)
|
|
1262
|
+
|
|
1263
|
+
- **The field**: `recurring: "daily" | "weekly" | "monthly" | "yearly" | null` on `note`
|
|
1264
|
+
and on each `session_end` entry, one sentence on the field (served whole; the tool
|
|
1265
|
+
descriptions are cut at 2,048 characters, so the field is where the model reads it).
|
|
1266
|
+
The plain/quiet privilege grew one short sentence — "A recurring date counts each time
|
|
1267
|
+
it comes round as its own" — rather than a new privilege, so nothing the cut tests pin
|
|
1268
|
+
moves.
|
|
1269
|
+
- **Refused by name, before anything is captured** (`readReminder`), as an unreadable
|
|
1270
|
+
date is: an unknown word is `recurring-unknown` (the detail lists the four, and says
|
|
1271
|
+
every other week and the like are not kept); a word beside a month, a range or a year
|
|
1272
|
+
is `recurring-needs-day`. On `session_end` either refuses its own entry only. With no
|
|
1273
|
+
`eventDate` it is dropped and said (`ignored: "recurring"`), unless a revision carries
|
|
1274
|
+
a date for it.
|
|
1275
|
+
- **The answer**: `reminder` carries `recurring`, `every` ("every May 14") and `next`
|
|
1276
|
+
(the next occurrence on or after today) — and never the "already passed" note, which
|
|
1277
|
+
a birthday anchored in 1990 would otherwise get. A revision's `carriedOver` can name
|
|
1278
|
+
`recurring`.
|
|
1279
|
+
- **Meaning recall** dates a repeating reminder by its next occurrence and says how
|
|
1280
|
+
often: `dated 2026-10-12, every October 12`. Facts mode and an expansion show no
|
|
1281
|
+
reminder date today, so they have nothing to add it beside.
|
|
1282
|
+
|
|
1283
|
+
## 2026-10-09 — facts mode: "last Saturday", and a word in front of a date
|
|
1284
|
+
|
|
1285
|
+
The LongMemEval run (counterparts-87, about 2,000 facts searches) found two misreadings in
|
|
1286
|
+
`recall/time-ask.ts`. "Last Saturday" was no time at all, so nothing was filtered. "Before
|
|
1287
|
+
7/22" filtered to 07-22 alone: only "since" was read in front of a date, and every other
|
|
1288
|
+
word was left in the question while the date stood as one exact day. "Two weeks ago" was
|
|
1289
|
+
right (asked on 2023-02-01: 01-16..01-22, checked on a benchmark store).
|
|
1290
|
+
|
|
1291
|
+
- **What changed meaning, exactly.** (1) "last <weekday>" and "this past <weekday>", full
|
|
1292
|
+
names only, any case, a possessive allowed ("last Saturday's"): was no window; now the
|
|
1293
|
+
most recent such day strictly before today, exact (no stretch). Asked on a Saturday,
|
|
1294
|
+
"last Saturday" is a week back. (2) "before" / "prior to" a date: was that one day; now
|
|
1295
|
+
`OPEN_START`..the day before. (3) "after" a date: was that one day; now the day
|
|
1296
|
+
after..`OPEN_END`. (4) "until", "till", "up to", "up until", "by" a date: was that one
|
|
1297
|
+
day; now `OPEN_START`..the date. Each in every date shape the parser reads: ISO day and
|
|
1298
|
+
month (`2026-07-22`, `2026-07`), `7/22` and `07-22` (month first, as before), "July 22",
|
|
1299
|
+
"22 July", "July 22nd". A "the" between the word and the date is allowed ("after the 4th
|
|
1300
|
+
of July"). (5) `7/22/2023` and "July 22, 2023" / "22 July 2023": the written year was
|
|
1301
|
+
ignored (the date took `yearFor`'s year, and `/2023` stayed in the question's words);
|
|
1302
|
+
now it is the year. (6) "since" + "last <weekday>" runs from that day to today, as
|
|
1303
|
+
"since" + a date always did. "Since" + a date is unchanged, its month stretch included.
|
|
1304
|
+
- **The rule for "last <weekday>"** is the CONTRACT's (§6f). Exact, as "yesterday" and
|
|
1305
|
+
"the day before yesterday" are: a named day. A day's stretch would not cover the other
|
|
1306
|
+
reading people mean by it (the Saturday a week earlier) anyway. Not "the last Saturday"
|
|
1307
|
+
(the last of something: "of June").
|
|
1308
|
+
- **An open end is a sentinel, not a null.** `OPEN_START = 0001-01-01`, `OPEN_END =
|
|
1309
|
+
9999-12-31`, so `DayWindow` keeps its shape and `inWindow`'s string comparisons, the
|
|
1310
|
+
chapter-date filter and the only-time pool work unchanged. The header and the dashboard's
|
|
1311
|
+
Ask line read them as "through 07-21" and "07-23 onward"; `ask --json` shows the
|
|
1312
|
+
sentinels as they are. `stretched` leaves an open end open.
|
|
1313
|
+
- *Choices:*
|
|
1314
|
+
- "After" is open-ended, where "since" stops at today. "Since" means "from then until
|
|
1315
|
+
now"; "after" does not, and a plan dated past today ("what is coming after 7/22") is
|
|
1316
|
+
inside it.
|
|
1317
|
+
- A bound does not stretch, even under a month ("before 2026-07" is through 06-30): the
|
|
1318
|
+
person named the cutoff. "Since" keeps the stretch it had.
|
|
1319
|
+
- "By" reads as "through" (a deadline). Only right in front of the date: "by the way on
|
|
1320
|
+
7/22" is 07-22 alone.
|
|
1321
|
+
- "The day after 7/22", "a week after 7/22", "the night before 7/22" read as the bound
|
|
1322
|
+
("after 7/22", "before 7/22"): wider than meant, but they cover the day meant. They
|
|
1323
|
+
were 07-22 alone, which missed it.
|
|
1324
|
+
- *Review of #338:* a date that names a thing on that day keeps that day under "before"
|
|
1325
|
+
and "after". "What did I eat before the 7/22 flight" was through 07-21, and the meal
|
|
1326
|
+
was on 07-22 (master's 07-22 alone found it; the bound hid it). "After the July 22
|
|
1327
|
+
launch" was 07-23 on, hiding the launch day; 07-22 alone would hide the days after.
|
|
1328
|
+
So: a "the" between the word and the date and a word after the date that is not the
|
|
1329
|
+
question going on (`PHRASE_STOP`: "after the 4th of July we sailed" is still a cutoff),
|
|
1330
|
+
or an 's on the date ("after July 22's standup", "after last Saturday's party"), and
|
|
1331
|
+
the window is through the date / from the date on. Only the date leaves the question
|
|
1332
|
+
("what did I eat before the flight"), and the header says "before the 7/22". Wider by
|
|
1333
|
+
one day than a cutoff, never narrower than either earlier reading.
|
|
1334
|
+
- **Not done:** a month NAME under a bound ("before September" is still no time;
|
|
1335
|
+
"before September 2023" is still all of September, stretched), "between X and Y" and
|
|
1336
|
+
"from X to Y" (still the first date alone), "this Saturday" and "on Saturday" (either can
|
|
1337
|
+
be the coming one), "last weekend" (no time), a two-digit year (`7/22/23` is still 7/22
|
|
1338
|
+
with `yearFor`'s year, `/23` left in), `2023/07/22`. The learned-date fallback for a row
|
|
1339
|
+
with no `occurred_on` is the owner's decision and untouched.
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* Nothing in this file is a memory rule; all of it is host trivia (§5 G8).
|
|
26
26
|
*/
|
|
27
27
|
import { readFileSync } from "node:fs";
|
|
28
|
+
import { homedir } from "node:os";
|
|
28
29
|
import { resolve } from "node:path";
|
|
29
30
|
import { fileURLToPath } from "node:url";
|
|
30
31
|
import { parseArgs } from "node:util";
|
|
@@ -60,6 +61,9 @@ import { hostScope, openServer } from "../index.js";
|
|
|
60
61
|
import { openLog } from "../../log/index.js";
|
|
61
62
|
import type { LogEvent, ProcessLog } from "../../log/index.js";
|
|
62
63
|
import { serveStdio } from "../stdio.js";
|
|
64
|
+
import { stoodDownServer } from "../stood-down.js";
|
|
65
|
+
import { npmWiring } from "../../host-wiring.js";
|
|
66
|
+
import { ensureFirstRun, mcpGate, runningAsPlugin } from "../../plugin.js";
|
|
63
67
|
import { DATA_DIR_ENV, describeGuardRefusal } from "../../../core/store/index.js";
|
|
64
68
|
import { scriptArgs } from "../../runtime.js";
|
|
65
69
|
import {
|
|
@@ -317,6 +321,32 @@ async function main(): Promise<void> {
|
|
|
317
321
|
// an unrelated reason (scar §2.4 — a path that discards something says what).
|
|
318
322
|
for (const line of stanceNotices) process.stderr.write(`${line}\n`);
|
|
319
323
|
const choice = serverConfigChoice();
|
|
324
|
+
// THE PLUGIN'S PREAMBLE (`adapters/plugin.ts`), only when Claude Code started
|
|
325
|
+
// this process as the Counterparts plugin's server. A live `counterparts`
|
|
326
|
+
// registration from the npm install wins: this one then serves the protocol
|
|
327
|
+
// and no tools, so the model is never offered every memory tool twice. And a
|
|
328
|
+
// machine with no install yet gets one here, the way `counterparts install`
|
|
329
|
+
// makes it — the hook may be racing to do the same, which the lock settles.
|
|
330
|
+
if (runningAsPlugin(process.env)) {
|
|
331
|
+
const home = homedir();
|
|
332
|
+
const projectDir = process.env["CLAUDE_PROJECT_DIR"] ?? process.cwd();
|
|
333
|
+
const gate = mcpGate(npmWiring({ home, env: process.env, cwd: projectDir, read: { hooks: false } }), home);
|
|
334
|
+
if (gate.standDown) {
|
|
335
|
+
process.stderr.write("[counterparts] plugin server stood down: the npm install's server is registered in this host\n");
|
|
336
|
+
await serveStdio(stoodDownServer(gate.instructions ?? ""), process.stdin, {
|
|
337
|
+
write: (chunk) => {
|
|
338
|
+
process.stdout.write(chunk);
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
try {
|
|
344
|
+
const first = ensureFirstRun({ choice, env: process.env, home });
|
|
345
|
+
if (first.detail !== undefined) process.stderr.write(`[counterparts] plugin first run ${first.state}: ${first.detail}\n`);
|
|
346
|
+
} catch (err) {
|
|
347
|
+
process.stderr.write(`[counterparts] plugin first run threw: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
320
350
|
// The second refusal is the explicit-dir guard (`config-path.ts#implicitConfigRefusal`):
|
|
321
351
|
// armed, an UNNAMED configuration refuses the launch too — the default one is
|
|
322
352
|
// somebody's configuration and names somebody's store. Never armed on the live host.
|