@empirical-gauzza/cli 1.0.21 → 1.0.23

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.
@@ -1,47 +1,47 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const os = require('os');
5
- const path = require('path');
6
- const { commandExists } = require('../fsUtils');
7
- const { installCodex } = require('./codex');
8
- const { installCopilot } = require('./copilot');
9
- const { installClaude } = require('./claude');
10
-
11
- function detectInstallTargets() {
12
- const home = os.homedir();
13
- const targets = [];
14
-
15
- const codexDetected = commandExists('codex') || fs.existsSync(path.join(home, '.codex'));
16
- if (codexDetected) {
17
- targets.push({
18
- id: 'codex',
19
- label: 'Codex CLI',
20
- install: installCodex
21
- });
22
- }
23
-
24
- const copilotDetected = commandExists('copilot') || fs.existsSync(path.join(home, '.copilot'));
25
- if (copilotDetected) {
26
- targets.push({
27
- id: 'copilot',
28
- label: 'GitHub Copilot CLI',
29
- install: installCopilot
30
- });
31
- }
32
-
33
- const claudeDetected = commandExists('claude') || fs.existsSync(path.join(home, '.claude'));
34
- if (claudeDetected) {
35
- targets.push({
36
- id: 'claude',
37
- label: 'Claude CLI',
38
- install: installClaude
39
- });
40
- }
41
-
42
- return targets;
43
- }
44
-
45
- module.exports = {
46
- detectInstallTargets
47
- };
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const os = require('os');
5
+ const path = require('path');
6
+ const { commandExists } = require('../fsUtils');
7
+ const { installCodex } = require('./codex');
8
+ const { installCopilot } = require('./copilot');
9
+ const { installClaude } = require('./claude');
10
+
11
+ function detectInstallTargets() {
12
+ const home = os.homedir();
13
+ const targets = [];
14
+
15
+ const codexDetected = commandExists('codex') || fs.existsSync(path.join(home, '.codex'));
16
+ if (codexDetected) {
17
+ targets.push({
18
+ id: 'codex',
19
+ label: 'Codex CLI',
20
+ install: installCodex
21
+ });
22
+ }
23
+
24
+ const copilotDetected = commandExists('copilot') || fs.existsSync(path.join(home, '.copilot'));
25
+ if (copilotDetected) {
26
+ targets.push({
27
+ id: 'copilot',
28
+ label: 'GitHub Copilot CLI',
29
+ install: installCopilot
30
+ });
31
+ }
32
+
33
+ const claudeDetected = commandExists('claude') || fs.existsSync(path.join(home, '.claude'));
34
+ if (claudeDetected) {
35
+ targets.push({
36
+ id: 'claude',
37
+ label: 'Claude CLI',
38
+ install: installClaude
39
+ });
40
+ }
41
+
42
+ return targets;
43
+ }
44
+
45
+ module.exports = {
46
+ detectInstallTargets
47
+ };
@@ -643,20 +643,20 @@ try {
643
643
  // The message itself is generated per-install from the actual plugin set being installed, not one
644
644
  // fixed string for everyone - e.g. someone who declined empirical-scar-tissue at install time
645
645
  // never sees a scar-tissue reminder, since that capability isn't actually available to them.
646
- function buildPromptReminderMessage(pluginNames, platform) {
646
+ function buildPromptReminderMessage(pluginNames, platform) {
647
647
  const names = normalizePluginNames(pluginNames);
648
648
  const lines = [
649
649
  'Before responding: if this task needs prior context (research, debugging, a spec or status update, a handoff), query Empirical memory first via the empirical-memory skill or empirical memory query - do not assume you already have enough context.'
650
650
  ];
651
- if (names.includes('empirical-work-history')) {
652
- lines.push('If you are picking up previously completed work, check for a recent work-history entry before assuming there is none.');
653
- // Codex Stop runs after its final response has already been emitted, so it can only be an
654
- // advisory reminder. Put the completion gate into the pre-response context instead, where
655
- // Codex can still act on it. Keep this Codex-specific: Claude and Copilot have their own
656
- // stop-hook control flows and should not receive a changed prompt contract here.
657
- if (platform === 'codex') {
658
- lines.push('If this turn results in meaningful completed work, BEFORE sending your final response you MUST use the empirical-work-history skill or record it via Empirical. The entry must carry tag work-history and mass 1; verify the create receipt. CLI fallback must use --json-file with data.session and data.git; do not use the shorthand record command for coding work. Do not wait for the Stop hook.');
659
- }
651
+ if (names.includes('empirical-work-history')) {
652
+ lines.push('If you are picking up previously completed work, check for a recent work-history entry before assuming there is none.');
653
+ // Codex Stop runs after its final response has already been emitted, so it can only be an
654
+ // advisory reminder. Put the completion gate into the pre-response context instead, where
655
+ // Codex can still act on it. Keep this Codex-specific: Claude and Copilot have their own
656
+ // stop-hook control flows and should not receive a changed prompt contract here.
657
+ if (platform === 'codex') {
658
+ lines.push('If this turn results in meaningful completed work, BEFORE sending your final response you MUST use the empirical-work-history skill or record it via Empirical. The entry must carry tag work-history and mass 1; verify the create receipt. CLI fallback must use --json-file with data.session and data.git; do not use the shorthand record command for coding work. Do not wait for the Stop hook.');
659
+ }
660
660
  }
661
661
  if (names.includes('empirical-scar-tissue')) {
662
662
  lines.push('Check for scar tissue before repeating a past mistake in this area.');
@@ -685,8 +685,8 @@ function buildPromptReminderMessage(pluginNames, platform) {
685
685
  // - default (Claude/Copilot's plain console.log was the old assumption for both - WRONG for
686
686
  // Copilot, which requires valid JSON on stdout for every event, confirmed via the same fetch
687
687
  // above): plain console.log, confirmed correct for Claude only.
688
- function buildUserPromptSubmitHookSource(pluginNames, platform) {
689
- const messageLiteral = JSON.stringify(buildPromptReminderMessage(pluginNames, platform));
688
+ function buildUserPromptSubmitHookSource(pluginNames, platform) {
689
+ const messageLiteral = JSON.stringify(buildPromptReminderMessage(pluginNames, platform));
690
690
 
691
691
  let stdinHelper = '';
692
692
  let outputStatement;
@@ -1,154 +1,165 @@
1
- ---
2
- name: empirical-memory
3
- description: Use Empirical to recall/save durable project context across sessions and projects, and to look up how to use Empirical itself - CLI commands, install/auth/workspace/kit/skill setup, docs.
4
- ---
5
-
6
- # Empirical Memory
7
-
8
- Use Empirical to carry durable context across projects and clients, and as the first stop for
9
- "how do I use Empirical" questions — CLI command syntax, install/auth/workspace/kit/skill setup,
10
- or what Empirical can do. Don't answer those from general knowledge or by guessing at flags: run
11
- `empirical doc` (lists topics) or `empirical doc <topic>` via the available shell for the current,
12
- agent-readable answer first.
13
-
14
- This variant is for installs where the user chose to have both the CLI and MCP tools available.
15
- Both paths now run through the same write pipeline (dedupe and auto-link on by default), so
16
- either is safe to use for reads and writes. The CLI is the default choice below because it avoids
17
- an extra MCP tool-discovery round trip and is easier to script, but that is a latency preference,
18
- not a safety one — if the CLI is unavailable in this environment, use the equivalent MCP tool
19
- instead without hesitation.
20
-
21
- **This is a required step in the workflows listed below, not optional guidance you weigh against
22
- the current task.** The most common way this skill fails is not a broken tool — it's an agent
23
- mid-task deciding a memory check "isn't worth pausing for" and skipping it. That decision is wrong
24
- by default: the entire point of querying first is to catch context you don't know you're missing.
25
- If you are not sure whether a task qualifies, treat it as if it does.
26
-
27
- ## Before doing work — MUST, not discretionary
28
-
29
- 1. Query relevant memories BEFORE your first substantive response or tool call whenever the task
30
- is: research, debugging, a spec/PRD, a status update, a handoff, personal health, leads/CRM, or
31
- assistant operations. This applies even if you believe you already have enough context — you
32
- cannot know what you're missing without checking. Only outside this list is discretionary use
33
- ("query when it seems useful") the right frame.
34
- 2. Before using the CLI, load its authoritative command reference:
35
-
36
- ```text
37
- empirical doc memory
38
- ```
39
-
40
- Follow the documented flags exactly; never guess a positional query form. Use the `empirical`
41
- CLI first when it is available — both it and the MCP tools carry the same dedupe/auto-link
42
- guarantees, so this is a convenience choice, not a safety one:
43
-
44
- ```text
45
- empirical memory query --match "<specific relevant context>" --top-k 3
46
- ```
47
-
48
- Add `--category` or `--tags` when known. Omit `--pretty` for routine recall because graph-rich
49
- results can be large. A slow response alone is API latency, not an outage; report an outage
50
- only when the CLI returns an actual error, and use `empirical doctor` to verify connectivity.
51
-
52
- 3. If the CLI is unavailable, use the connected MCP `query_memories` tool. Use filters such as
53
- `category`, `tags`, `nodeType`, and `monthKey` when they improve recall. For "recent/latest/
54
- today" requests, prefer `list_memories` (CLI: `empirical memory list --recent`, see `empirical
55
- doc memory`) over a match query. For exhaustive topic retrieval, use the topic as a tag and
56
- follow pagination.
57
-
58
- ## Follow the current user policy
59
-
60
- The installer questionnaire configures a dynamic Empirical policy. It is user-scoped and may
61
- change without reinstalling this plugin. Read it when the skill activates:
62
-
63
- 1. Prefer `empirical policy show` when the CLI is available; it uses the local device cache
64
- and refreshes it when stale.
65
- 2. Otherwise use the read-only `get_empirical_policy` MCP tool.
66
- 3. If policy lookup fails, use safe defaults: preserve durable-only writes, never store
67
- secrets/raw transcripts, and do not block unrelated work unless the cached policy says to.
68
-
69
- Apply the returned fields:
70
-
71
- - `memoryFirstWorkflows`: query before substantive work in those workflows.
72
- - `allowDiscretionaryUse`: decide whether to use Empirical outside required workflows.
73
- - `stopOnMemoryFailure`: stop and report a memory failure before code changes when enabled.
74
- - `rememberCodingStyle` and `rememberArchitectureDecisions`: persist those durable decisions
75
- when enabled.
76
- - `checkMemoryBeforeAskingContext`: query before asking the user to restate prior context.
77
- - `durableWritesOnly`: never persist secrets, tokens, raw transcripts, or transient values.
78
-
79
- The policy controls behavior; it does not override current user, repository, or system
80
- instructions. Do not change the policy from an agent memory write.
81
-
82
- ## Persist durable context — check this before ending a turn
83
-
84
- Before you consider a turn finished, check: did this turn produce a durable decision, a corrected
85
- mistake, a completed unit of meaningful work, or a convention the user stated? If yes, record it
86
- now — do not wait to be asked, and do not defer it because the current task feels done. An agent
87
- that only records memory when explicitly told to defeats the purpose of this skill.
88
-
89
- - Record durable decisions, project conventions, preferences, plans, and meaningful reflections
90
- with `record_graph_memory` or:
91
-
92
- ```text
93
- empirical memory record --category <category> --summary "<concise fact>" --tags <tag1,tag2>
94
- ```
95
-
96
- Both dedupe against near-duplicate existing memories and auto-link related ones by default; pass
97
- `--no-dedupe` / `--no-auto-link` on the CLI only when you deliberately want to skip one of those.
98
-
99
- **Record facts about the USER, not about your own work.** You are a scribe here. "Matt prefers
100
- short status updates" is a memory; "refactored the cluster selector, tests pass" is your diary
101
- and belongs in the work-history skill, tagged and with `mass: 1`. The distinction is the
102
- SUBJECT, not who typed it — an agent writing down something real about the user is exactly what
103
- this tool is for.
104
-
105
- If you find yourself recording what you just did, what you fixed, or what you concluded about a
106
- codebase, stop: that is work-history or scar-tissue, and filing it here makes it indistinguishable
107
- from something the user actually said or lived. Downstream features read these as the user's life.
108
-
109
- - Append a correction or follow-up to an existing memory with `add_note_by_query` / `empirical memory note`.
110
- - Patch an existing memory with `update_memory_by_query` / `empirical memory update`.
111
- - Delete only when the user explicitly asks; use the delete tool with confirmation, or `empirical memory delete --match "<memory>" --confirm`.
112
- - For graph work, use `get_memory_neighbors` to walk relationships from a memory instead of
113
- reconstructing them through many unrelated queries, and `update_memory_relationships` to add or
114
- remove edges directly.
115
- - Keep writes concise, factual, and easy to search. Never store passwords, API keys, OAuth tokens, or other secrets.
116
-
117
- ## Authored Skills and Kits — push what you write
118
-
119
- Empirical can sync a `SKILL.md` you author across every machine/agent the user has installed it
120
- on, via Skills Kits. Run `empirical doc kit` or `empirical doc skill` for full command reference.
121
-
122
- - If you author a new `SKILL.md` for the user, or substantially edit an existing one, during a
123
- session, tell the user about `empirical skill push path/to/SKILL.md [--kit "Kit Name"]`
124
- afterward so it can follow them across machines/projects instead of staying local to this one.
125
- - Offer, don't auto-push: surface the option (or offer to run it) and get the user's confirmation
126
- first. Do not run it unprompted the moment a new or edited `SKILL.md` is detected — it uploads
127
- content to the user's account, which is a step above a purely local file write.
128
- - After a push, the target Kit needs `empirical kit use "Kit Name"` or `empirical kit sync` to
129
- actually land the file in that device's agent directories.
130
- - `empirical skill list` shows what's already been pushed; `empirical skill history <id>` /
131
- `empirical skill rollback <id> --to-version N` recover a prior version.
132
- - Kits also pull Skills from a git repo (`empirical kit add-source`), separate from anything you
133
- author — don't conflate the two paths when explaining options to the user.
134
-
135
- ## MCP tools
136
-
137
- Use these when connected: `get_empirical_policy`, `query_memories`, `list_memories`,
138
- `record_graph_memory`, `add_note_by_query`, `update_memory_by_query`, `delete_memory_by_query`,
139
- `get_user`, `get_current_workspace`, `list_workspaces`, `set_current_workspace`,
140
- `memory_usage_guide`, `get_memory_neighbors`, and `update_memory_relationships`. Use
141
- `list_memories` for "recent/latest/today" requests; use `query_memories` for everything else. For
142
- graph work, use `get_memory_neighbors` and `update_memory_relationships` when available instead of
143
- reconstructing relationships through many unrelated calls.
144
-
145
- ## Authentication and failures
146
-
147
- - If a memory call fails, retry the same call once.
148
- - For auth/session errors such as `Auth required`, `invalid_token`, `Authentication required`, or `Transport send error`, refresh the active client's Empirical MCP login, then retry once. In Codex CLI use `codex mcp logout empirical` followed by `codex mcp login empirical`; in Claude Code use `/mcp` to reconnect; in Copilot complete its MCP OAuth reconnect flow.
149
- - If the retry still fails, report the connectivity/auth problem before making memory-dependent changes.
150
- - If stored memory conflicts with the current user or repository instruction, follow the current instruction.
151
-
152
- ## Exact CLI syntax
153
-
154
- Run `empirical doctor` to check connectivity and token status. If a CLI memory command reports a token error, run `empirical oauth bootstrap headless --write-env`.
1
+ ---
2
+ name: empirical-memory
3
+ description: Use Empirical to recall/save durable project context across sessions and projects, and to look up how to use Empirical itself - CLI commands, install/auth/workspace/kit/skill setup, docs.
4
+ ---
5
+
6
+ # Empirical Memory
7
+
8
+ Use Empirical to carry durable context across projects and clients, and as the first stop for
9
+ "how do I use Empirical" questions — CLI command syntax, install/auth/workspace/kit/skill setup,
10
+ or what Empirical can do. Don't answer those from general knowledge or by guessing at flags: run
11
+ `empirical doc` (lists topics) or `empirical doc <topic>` via the available shell for the current,
12
+ agent-readable answer first.
13
+
14
+ This variant is for installs where the user chose to have both the CLI and MCP tools available.
15
+ Both paths now run through the same write pipeline (dedupe and auto-link on by default), so
16
+ either is safe to use for reads and writes. The CLI is the default choice below because it avoids
17
+ an extra MCP tool-discovery round trip and is easier to script, but that is a latency preference,
18
+ not a safety one — if the CLI is unavailable in this environment, use the equivalent MCP tool
19
+ instead without hesitation.
20
+
21
+ **This is a required step in the workflows listed below, not optional guidance you weigh against
22
+ the current task.** The most common way this skill fails is not a broken tool — it's an agent
23
+ mid-task deciding a memory check "isn't worth pausing for" and skipping it. That decision is wrong
24
+ by default: the entire point of querying first is to catch context you don't know you're missing.
25
+ If you are not sure whether a task qualifies, treat it as if it does.
26
+
27
+ ## Before doing work — MUST, not discretionary
28
+
29
+ 1. Query relevant memories BEFORE your first substantive response or tool call whenever the task
30
+ is: research, debugging, a spec/PRD, a status update, a handoff, personal health, leads/CRM, or
31
+ assistant operations. This applies even if you believe you already have enough context — you
32
+ cannot know what you're missing without checking. Only outside this list is discretionary use
33
+ ("query when it seems useful") the right frame.
34
+ 2. Before using the CLI, load its authoritative command reference:
35
+
36
+ ```text
37
+ empirical doc memory
38
+ ```
39
+
40
+ Follow the documented flags exactly; never guess a positional query form. Use the `empirical`
41
+ CLI first when it is available — both it and the MCP tools carry the same dedupe/auto-link
42
+ guarantees, so this is a convenience choice, not a safety one:
43
+
44
+ ```text
45
+ empirical memory query --match "<specific relevant context>" --top-k 3
46
+ ```
47
+
48
+ Add `--category` or `--tags` when known. Omit `--pretty` for routine recall because graph-rich
49
+ results can be large. A slow response alone is API latency, not an outage; report an outage
50
+ only when the CLI returns an actual error, and use `empirical doctor` to verify connectivity.
51
+
52
+ 3. Scope recall to the project you are in. Derive a project tag from the repository name
53
+ (`git rev-parse --show-toplevel`, then the folder name) or, outside a repo, the working
54
+ directory name, lowercased with spaces as hyphens. Pass it as `tags: ["<project>"]` on every
55
+ `query_memories` call and add it to `tags` on every `record_graph_memory` call. If a scoped
56
+ query comes back with a `retrievalNote`, nothing from this project matched: the results are
57
+ from other projects, so use them as background only and say so if you rely on one.
58
+ 4. If the CLI is unavailable, use the connected MCP `query_memories` tool. Use filters such as
59
+ `category`, `tags`, `nodeType`, and `monthKey` when they improve recall. For "recent/latest/
60
+ today" requests, prefer `list_memories` (CLI: `empirical memory list --recent`, see `empirical
61
+ doc memory`) over a match query. For exhaustive topic retrieval, use the topic as a tag and
62
+ follow pagination.
63
+
64
+ ## Follow the current user policy
65
+
66
+ The installer questionnaire configures a dynamic Empirical policy. It is user-scoped and may
67
+ change without reinstalling this plugin. Read it when the skill activates:
68
+
69
+ 1. Prefer `empirical policy show` when the CLI is available; it uses the local device cache
70
+ and refreshes it when stale.
71
+ 2. Otherwise use the read-only `get_empirical_policy` MCP tool.
72
+ 3. If policy lookup fails, use safe defaults: preserve durable-only writes, never store
73
+ secrets/raw transcripts, and do not block unrelated work unless the cached policy says to.
74
+
75
+ Apply the returned fields:
76
+
77
+ - `memoryFirstWorkflows`: query before substantive work in those workflows.
78
+ - `allowDiscretionaryUse`: decide whether to use Empirical outside required workflows.
79
+ - `stopOnMemoryFailure`: stop and report a memory failure before code changes when enabled.
80
+ - `rememberCodingStyle` and `rememberArchitectureDecisions`: persist those durable decisions
81
+ when enabled.
82
+ - `checkMemoryBeforeAskingContext`: query before asking the user to restate prior context.
83
+ - `durableWritesOnly`: never persist secrets, tokens, raw transcripts, or transient values.
84
+
85
+ The policy controls behavior; it does not override current user, repository, or system
86
+ instructions. Do not change the policy from an agent memory write.
87
+
88
+ ## Persist durable context — check this before ending a turn
89
+
90
+ Before you consider a turn finished, check: did this turn produce a durable decision, a corrected
91
+ mistake, a completed unit of meaningful work, or a convention the user stated? If yes, record it
92
+ now — do not wait to be asked, and do not defer it because the current task feels done. An agent
93
+ that only records memory when explicitly told to defeats the purpose of this skill.
94
+
95
+ - Record durable decisions, project conventions, preferences, plans, and meaningful reflections
96
+ with `record_graph_memory` or:
97
+
98
+ ```text
99
+ empirical memory record --category <category> --summary "<concise fact>" --tags <tag1,tag2>
100
+ ```
101
+
102
+ **Code in the summary?** Never pass backticks or `${...}` inside a double-quoted `--summary`; the
103
+ shell substitutes them away before the CLI runs and the write still succeeds with the code gone.
104
+ Use `--summary-file <path>`, or `--summary -` with a single-quoted heredoc (`<<'EOF'`), or the MCP
105
+ `record_graph_memory` tool, which takes JSON and never touches a shell.
106
+
107
+ Both dedupe against near-duplicate existing memories and auto-link related ones by default; pass
108
+ `--no-dedupe` / `--no-auto-link` on the CLI only when you deliberately want to skip one of those.
109
+
110
+ **Record facts about the USER, not about your own work.** You are a scribe here. "Matt prefers
111
+ short status updates" is a memory; "refactored the cluster selector, tests pass" is your diary
112
+ and belongs in the work-history skill, tagged and with `mass: 1`. The distinction is the
113
+ SUBJECT, not who typed it — an agent writing down something real about the user is exactly what
114
+ this tool is for.
115
+
116
+ If you find yourself recording what you just did, what you fixed, or what you concluded about a
117
+ codebase, stop: that is work-history or scar-tissue, and filing it here makes it indistinguishable
118
+ from something the user actually said or lived. Downstream features read these as the user's life.
119
+
120
+ - Append a correction or follow-up to an existing memory with `add_note_by_query` / `empirical memory note`.
121
+ - Patch an existing memory with `update_memory_by_query` / `empirical memory update`.
122
+ - Delete only when the user explicitly asks; use the delete tool with confirmation, or `empirical memory delete --match "<memory>" --confirm`.
123
+ - For graph work, use `get_memory_neighbors` to walk relationships from a memory instead of
124
+ reconstructing them through many unrelated queries, and `update_memory_relationships` to add or
125
+ remove edges directly.
126
+ - Keep writes concise, factual, and easy to search. Never store passwords, API keys, OAuth tokens, or other secrets.
127
+
128
+ ## Authored Skills and Kits — push what you write
129
+
130
+ Empirical can sync a `SKILL.md` you author across every machine/agent the user has installed it
131
+ on, via Skills Kits. Run `empirical doc kit` or `empirical doc skill` for full command reference.
132
+
133
+ - If you author a new `SKILL.md` for the user, or substantially edit an existing one, during a
134
+ session, tell the user about `empirical skill push path/to/SKILL.md [--kit "Kit Name"]`
135
+ afterward so it can follow them across machines/projects instead of staying local to this one.
136
+ - Offer, don't auto-push: surface the option (or offer to run it) and get the user's confirmation
137
+ first. Do not run it unprompted the moment a new or edited `SKILL.md` is detected — it uploads
138
+ content to the user's account, which is a step above a purely local file write.
139
+ - After a push, the target Kit needs `empirical kit use "Kit Name"` or `empirical kit sync` to
140
+ actually land the file in that device's agent directories.
141
+ - `empirical skill list` shows what's already been pushed; `empirical skill history <id>` /
142
+ `empirical skill rollback <id> --to-version N` recover a prior version.
143
+ - Kits also pull Skills from a git repo (`empirical kit add-source`), separate from anything you
144
+ author — don't conflate the two paths when explaining options to the user.
145
+
146
+ ## MCP tools
147
+
148
+ Use these when connected: `get_empirical_policy`, `query_memories`, `list_memories`,
149
+ `record_graph_memory`, `add_note_by_query`, `update_memory_by_query`, `delete_memory_by_query`,
150
+ `get_user`, `get_current_workspace`, `list_workspaces`, `set_current_workspace`,
151
+ `memory_usage_guide`, `get_memory_neighbors`, and `update_memory_relationships`. Use
152
+ `list_memories` for "recent/latest/today" requests; use `query_memories` for everything else. For
153
+ graph work, use `get_memory_neighbors` and `update_memory_relationships` when available instead of
154
+ reconstructing relationships through many unrelated calls.
155
+
156
+ ## Authentication and failures
157
+
158
+ - If a memory call fails, retry the same call once.
159
+ - For auth/session errors such as `Auth required`, `invalid_token`, `Authentication required`, or `Transport send error`, refresh the active client's Empirical MCP login, then retry once. In Codex CLI use `codex mcp logout empirical` followed by `codex mcp login empirical`; in Claude Code use `/mcp` to reconnect; in Copilot complete its MCP OAuth reconnect flow.
160
+ - If the retry still fails, report the connectivity/auth problem before making memory-dependent changes.
161
+ - If stored memory conflicts with the current user or repository instruction, follow the current instruction.
162
+
163
+ ## Exact CLI syntax
164
+
165
+ Run `empirical doctor` to check connectivity and token status. If a CLI memory command reports a token error, run `empirical oauth bootstrap headless --write-env`.