@memorax/memorax-code 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/bin/memorax-code-setup.mjs +136 -34
- package/bin/memorax-code-trae.mjs +4 -0
- package/docs/configuration.md +111 -54
- package/docs/troubleshooting.md +50 -8
- package/lib/memorax-code-backend/dist/clients/claude/transcript-turn.js +2 -2
- package/lib/memorax-code-backend/dist/clients/codex/rollout-turn.js +1 -1
- package/lib/memorax-code-backend/dist/clients/trae/lifecycle.js +53 -0
- package/lib/memorax-code-backend/dist/clients/trae/memory-hook-runtime.js +302 -0
- package/lib/memorax-code-backend/dist/clients/trae/turn-id.js +16 -0
- package/lib/memorax-code-backend/dist/config/memorax-code.js +14 -1
- package/lib/memorax-code-backend/dist/entrypoints/backend-cli.js +22 -4
- package/lib/memorax-code-backend/dist/lifecycle/active-clients.js +3 -0
- package/lib/memorax-code-backend/dist/lifecycle/client-plugin-removal.js +14 -2
- package/lib/memorax-code-backend/dist/lifecycle/client-selection.js +5 -3
- package/lib/memorax-code-backend/dist/lifecycle/orchestrator.js +62 -9
- package/lib/memorax-code-backend/dist/memory/hook-command.js +34 -2
- package/lib/memorax-code-backend/dist/memory/reminder-trace-recorder.js +5 -1
- package/lib/memorax-code-backend/dist/memory/service.js +12 -0
- package/lib/memorax-code-backend/dist/trace/config.js +12 -1
- package/lib/memorax-code-backend/dist/trace/context.js +26 -1
- package/lib/memorax-code-backend/package.json +1 -1
- package/lib/memorax-code-claude-adapter/.claude-plugin/plugin.json +1 -1
- package/lib/memorax-code-claude-adapter/hooks/runtime-shell.json +1 -1
- package/lib/memorax-code-claude-adapter/package.json +1 -1
- package/lib/memorax-code-claude-adapter/skills/memorax-code/SKILL.md +3 -1
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/memorax-add.md +16 -3
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/memorax-search.md +15 -2
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/.claude-plugin/plugin.json +1 -1
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/hooks/runtime-shell.json +1 -1
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/package.json +1 -1
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/SKILL.md +3 -1
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/memorax-add.md +16 -3
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/memorax-search.md +15 -2
- package/lib/memorax-code-codebuddy-adapter/.codebuddy-plugin/plugin.json +1 -1
- package/lib/memorax-code-codebuddy-adapter/hooks/runtime-hook.mjs +11 -1
- package/lib/memorax-code-codebuddy-adapter/package.json +1 -1
- package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/SKILL.md +3 -1
- package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/memorax-add.md +16 -3
- package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/memorax-search.md +15 -2
- package/lib/memorax-code-codebuddy-adapter/src/config.mjs +86 -23
- package/lib/memorax-code-codex-adapter/.codex-plugin/plugin.json +1 -1
- package/lib/memorax-code-codex-adapter/hooks/runtime-shell.json +1 -1
- package/lib/memorax-code-codex-adapter/package.json +1 -1
- package/lib/memorax-code-codex-adapter/skills/memorax-code/SKILL.md +3 -1
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/memorax-add.md +16 -3
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/memorax-search.md +15 -2
- package/lib/memorax-code-dsh-adapter/package.json +1 -1
- package/lib/memorax-code-dsh-adapter/skills/memorax-code/SKILL.md +3 -1
- package/lib/memorax-code-dsh-adapter/skills/memorax-code/references/memorax-add.md +16 -3
- package/lib/memorax-code-dsh-adapter/skills/memorax-code/references/memorax-search.md +15 -2
- package/lib/memorax-code-opencode-adapter/package.json +1 -1
- package/lib/memorax-code-opencode-adapter/skills/memorax-code/SKILL.md +3 -1
- package/lib/memorax-code-opencode-adapter/skills/memorax-code/references/memorax-add.md +16 -3
- package/lib/memorax-code-opencode-adapter/skills/memorax-code/references/memorax-search.md +15 -2
- package/lib/memorax-code-trae-adapter/hooks/runtime-hook.mjs +340 -0
- package/lib/memorax-code-trae-adapter/package.json +9 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/SKILL.md +87 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/agents/claude.yaml +10 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/agents/openai.yaml +7 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/defaults.json +12 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/references/memorax-add.md +101 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/references/memorax-search.md +106 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/references/personal-read.md +46 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/references/personal-write.md +120 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/references/repo-build.md +319 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/references/repo-read.md +103 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/references/repo-templates.md +390 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/references/repo-update.md +127 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/collect_all.py +579 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/detect_updates.py +919 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/git_commit_facets.py +222 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/github_resource_facets.py +512 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/gitlab_resource_facets.py +517 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/prepare_repo_memory.py +411 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/user_profile_memory.py +528 -0
- package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/validate_memory.py +248 -0
- package/lib/memorax-code-trae-adapter/src/adapter-paths.mjs +69 -0
- package/lib/memorax-code-trae-adapter/src/cli.mjs +59 -0
- package/lib/memorax-code-trae-adapter/src/config.mjs +630 -0
- package/lib/memorax-code-trae-adapter/src/runtime-observation.mjs +55 -0
- package/lib/resolve-codebuddy-command.mjs +15 -4
- package/lib/run-entrypoint.mjs +6 -0
- package/package.json +5 -3
|
@@ -74,7 +74,9 @@ Examples:
|
|
|
74
74
|
|
|
75
75
|
## Shared Rules
|
|
76
76
|
|
|
77
|
-
For MemoraX Code coding memory, run
|
|
77
|
+
For MemoraX Code coding memory, run the platform command from the active task workspace. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry the same command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
78
|
+
|
|
79
|
+
The installed Hook and session binding supply the authoritative workspace root; do not run Git commands to discover or replace it. The Backend resolves repository scope from that trusted workspace and read-only filesystem Git metadata.
|
|
78
80
|
|
|
79
81
|
Repo memory and personal memory remain local `.repo_memory` authorities. Resolve their repository root exactly as described by the selected reference, including its Git requirements.
|
|
80
82
|
|
|
@@ -17,9 +17,22 @@ Do not add positive repair lessons based only on unverified edits or assistant s
|
|
|
17
17
|
|
|
18
18
|
## Add Workflow
|
|
19
19
|
|
|
20
|
+
Select the executable before constructing any Add command. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry that command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
21
|
+
|
|
20
22
|
For a proactive add, write all generated prose in `--memory`, `--reason`, and the confirmation in the language of the user's current request; preserve exact code, API, path, workflow, and project identifiers.
|
|
21
23
|
|
|
22
|
-
Run from the active task workspace. Pass the memory and reason directly. Put every dynamically generated `--memory` and `--reason` value in single quotes, never double quotes.
|
|
24
|
+
Run from the active task workspace. Pass the memory and reason directly. Put every dynamically generated `--memory` and `--reason` value in single quotes, never double quotes. Apply the escaping rule for the active shell:
|
|
25
|
+
|
|
26
|
+
- Windows PowerShell: single quotes keep `$HOME`, backticks, and `$(command)` literal. Replace each literal single quote in a value with two single quotes (`''`); for example, `don't` becomes `'don''t'`.
|
|
27
|
+
- macOS and Linux: Treat `$HOME`, backticks, and `$(command)` as literal text inside the quotes. Replace each literal single quote in a value with the exact POSIX sequence `'\''`.
|
|
28
|
+
|
|
29
|
+
Windows PowerShell:
|
|
30
|
+
|
|
31
|
+
```powershell
|
|
32
|
+
memorax-cli.cmd add --memory 'Concise reusable memory.' --type procedural --reason 'Capture reusable coding memory.'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
macOS and Linux:
|
|
23
36
|
|
|
24
37
|
```bash
|
|
25
38
|
memorax-cli add \
|
|
@@ -49,7 +62,7 @@ anchors: <stable repository source, tests, or public docs>
|
|
|
49
62
|
|
|
50
63
|
Keep the card under 1,100 characters when practical. It must guide future investigation while still requiring live-code inspection.
|
|
51
64
|
|
|
52
|
-
Pass a completed multi-line card as one single-quoted `--memory` argument
|
|
65
|
+
Pass a completed multi-line card as one single-quoted `--memory` argument. On Windows PowerShell, the command must start with `memorax-cli.cmd add`; on macOS and Linux, use the form shown below.
|
|
53
66
|
|
|
54
67
|
```bash
|
|
55
68
|
memorax-cli add \
|
|
@@ -69,7 +82,7 @@ anchors: stable/source/path' \
|
|
|
69
82
|
--reason 'Capture verified reusable coding memory.'
|
|
70
83
|
```
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
Except for the pre-start Windows shim correction above, if add fails, report the exact failure and do not retry automatically, bypass the CLI, or call MemoraX directly. Do not retry Add after the CLI may have started.
|
|
73
86
|
|
|
74
87
|
If a successful Add result reports `workspaceScopeFallbackReason: git_metadata_invalid`, malformed or incomplete metadata inside a direct `.git` directory was downgraded to the normalized local folder scope. Add has already been submitted with the reported `effectiveUserId`. Present its `userNotice` once without pausing the current task or asking the user to repair Git first, then continue the current task. After the repository or `.git` metadata is repaired, later Search, Add, and automatic writeback in the same client session automatically use the restored Git repository scope.
|
|
75
88
|
|
|
@@ -4,6 +4,8 @@ Use these instructions only to search reusable coding memory through `memorax-cl
|
|
|
4
4
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
7
|
+
Select the executable before constructing any Search command. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry the same command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
8
|
+
|
|
7
9
|
Run the CLI from the active task workspace. The installed Hook and session binding supply the authoritative workspace root; do not run `git rev-parse`, infer the root from Git metadata, or substitute an unrelated working directory. Do not make `memorax-cli status` a mandatory preflight; use it only to diagnose a configuration or scope failure.
|
|
8
10
|
|
|
9
11
|
Coding memory uses `<MemoraX base username>@<normalized repository name>` for Git workspaces and the normalized folder name for genuine non-Git directories. MemoraX Code resolves `.git`, `gitdir`, and `commondir` without executing Git. Linked worktrees share one repository scope; another clone, repository, or non-Git directory retains a different local session key even when its readable name matches.
|
|
@@ -12,7 +14,7 @@ If a successful Search result reports `workspaceScopeFallbackReason: git_metadat
|
|
|
12
14
|
|
|
13
15
|
Require a readable active workspace binding. A CLI command from a linked worktree of the bound repository is valid. If `memorax-cli search` reports `workspace_scope_mismatch` or `workspace_scope_unavailable`, do not bypass the scope or fall back to an unscoped username. Do not change the CLI working directory and retry. Tell the user that memory search was not executed and no request was sent to MemoraX, then present the CLI's `userAction` in natural language. Continue the current task using only live code and documentation.
|
|
14
16
|
|
|
15
|
-
If
|
|
17
|
+
If the selected platform command is not on `PATH`, or memory is disabled, unconfigured, or unavailable, report that briefly and continue with live code or documentation. Authenticate through MemoraX Code configuration; never recover credentials from shell history or place tokens in prompts. Treat injected memory as a hypothesis and verify it against the current checkout.
|
|
16
18
|
|
|
17
19
|
## Search Decision
|
|
18
20
|
|
|
@@ -50,10 +52,21 @@ State a fact-sized relationship that can change the next action: a target under
|
|
|
50
52
|
|
|
51
53
|
For a complementary first-round pair, each query must stand alone and cover a different decision boundary. Use a complementary pair only when the provided context gives each decision boundary a distinct exact code, API, path, workflow, or project identifier; otherwise keep one focused combined query that preserves both user-stated facts. Do not merely restate the same question with synonyms. If the user describes only one tightly coupled decision, emit exactly one query. Use one or two stable exact identifiers when they sharpen the query, and integrate them grammatically instead of appending search tags or filler. Use only user-provided anchors and stable terms from live code or documentation; do not reconstruct unseen fact wording from recalled memory.
|
|
52
54
|
|
|
53
|
-
Pass the query directly with `--query`. Put every dynamically generated query in single quotes, never double quotes.
|
|
55
|
+
Pass the query directly with `--query`. Put every dynamically generated query in single quotes, never double quotes. Apply the escaping rule for the active shell:
|
|
56
|
+
|
|
57
|
+
- Windows PowerShell: single quotes keep `$HOME`, backticks, and `$(command)` literal. Replace each literal single quote in the value with two single quotes (`''`); for example, `don't` becomes `'don''t'`.
|
|
58
|
+
- macOS and Linux: Treat `$HOME`, backticks, and `$(command)` as literal text inside the quotes. Replace each literal single quote in the value with the exact POSIX sequence `'\''`.
|
|
54
59
|
|
|
55
60
|
Use these actual output shapes as examples. They are queries themselves, not full user prompts or instructions for the user. Each Chinese/English pair is a language variant: choose the one matching the user, never run both merely because both are shown. The comments explain the example only and are not part of emitted query text.
|
|
56
61
|
|
|
62
|
+
On Windows PowerShell, the first example must be invoked as:
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
memorax-cli.cmd search --query 'Trace 生产版本:升级后到达的记录中,应以哪个客户端版本字段判断由旧插件产生,而非新版本上传进程?'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
On macOS and Linux, use the `memorax-cli search` forms below. For other Windows examples, preserve every argument but replace the leading executable with `memorax-cli.cmd`.
|
|
69
|
+
|
|
57
70
|
```bash
|
|
58
71
|
# One tightly coupled decision: emit one query.
|
|
59
72
|
memorax-cli search --query 'Trace 生产版本:升级后到达的记录中,应以哪个客户端版本字段判断由旧插件产生,而非新版本上传进程?'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
3
4
|
import { appendFile, mkdir, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
4
5
|
import { homedir } from "node:os";
|
|
5
6
|
import { join } from "node:path";
|
|
@@ -40,7 +41,7 @@ const codeBuddyHome = commonStringValue(process.env.CODEBUDDY_HOME)
|
|
|
40
41
|
?? commonStringValue(packageMetadata.codeBuddyHome)
|
|
41
42
|
?? commonStringValue(input?.codebuddy_home)
|
|
42
43
|
?? commonStringValue(input?.codeBuddyHome)
|
|
43
|
-
??
|
|
44
|
+
?? defaultCodeBuddyHome();
|
|
44
45
|
try {
|
|
45
46
|
await writeCodeBuddyRuntimeObservation({ memoraxCodeHome: home, codeBuddyHome, pluginRoot });
|
|
46
47
|
} catch (error) {
|
|
@@ -239,6 +240,15 @@ async function bindMemoryCliTraceSession(sessionId) {
|
|
|
239
240
|
function shellSingleQuote(value) { return `'${value.replaceAll("'", "'\"'\"'")}'`; }
|
|
240
241
|
function stringValue(value) { return typeof value === "string" && value.trim() ? value.trim() : undefined; }
|
|
241
242
|
|
|
243
|
+
function defaultCodeBuddyHome() {
|
|
244
|
+
const workBuddyHome = join(homedir(), ".workbuddy");
|
|
245
|
+
if (process.platform !== "win32") return workBuddyHome;
|
|
246
|
+
const legacyCodeBuddyHome = join(homedir(), ".codebuddy");
|
|
247
|
+
return existsSync(workBuddyHome) || !existsSync(legacyCodeBuddyHome)
|
|
248
|
+
? workBuddyHome
|
|
249
|
+
: legacyCodeBuddyHome;
|
|
250
|
+
}
|
|
251
|
+
|
|
242
252
|
function provisionalTurnId(sessionId, boundary, prompt) {
|
|
243
253
|
return `${sessionId}:${boundary}:${createHash("sha256").update(prompt.trim()).digest("hex")}`;
|
|
244
254
|
}
|
|
@@ -74,7 +74,9 @@ Examples:
|
|
|
74
74
|
|
|
75
75
|
## Shared Rules
|
|
76
76
|
|
|
77
|
-
For MemoraX Code coding memory, run
|
|
77
|
+
For MemoraX Code coding memory, run the platform command from the active task workspace. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry the same command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
78
|
+
|
|
79
|
+
The installed Hook and session binding supply the authoritative workspace root; do not run Git commands to discover or replace it. The Backend resolves repository scope from that trusted workspace and read-only filesystem Git metadata.
|
|
78
80
|
|
|
79
81
|
Repo memory and personal memory remain local `.repo_memory` authorities. Resolve their repository root exactly as described by the selected reference, including its Git requirements.
|
|
80
82
|
|
|
@@ -17,9 +17,22 @@ Do not add positive repair lessons based only on unverified edits or assistant s
|
|
|
17
17
|
|
|
18
18
|
## Add Workflow
|
|
19
19
|
|
|
20
|
+
Select the executable before constructing any Add command. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry that command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
21
|
+
|
|
20
22
|
For a proactive add, write all generated prose in `--memory`, `--reason`, and the confirmation in the language of the user's current request; preserve exact code, API, path, workflow, and project identifiers.
|
|
21
23
|
|
|
22
|
-
Run from the active task workspace. Pass the memory and reason directly. Put every dynamically generated `--memory` and `--reason` value in single quotes, never double quotes.
|
|
24
|
+
Run from the active task workspace. Pass the memory and reason directly. Put every dynamically generated `--memory` and `--reason` value in single quotes, never double quotes. Apply the escaping rule for the active shell:
|
|
25
|
+
|
|
26
|
+
- Windows PowerShell: single quotes keep `$HOME`, backticks, and `$(command)` literal. Replace each literal single quote in a value with two single quotes (`''`); for example, `don't` becomes `'don''t'`.
|
|
27
|
+
- macOS and Linux: Treat `$HOME`, backticks, and `$(command)` as literal text inside the quotes. Replace each literal single quote in a value with the exact POSIX sequence `'\''`.
|
|
28
|
+
|
|
29
|
+
Windows PowerShell:
|
|
30
|
+
|
|
31
|
+
```powershell
|
|
32
|
+
memorax-cli.cmd add --memory 'Concise reusable memory.' --type procedural --reason 'Capture reusable coding memory.'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
macOS and Linux:
|
|
23
36
|
|
|
24
37
|
```bash
|
|
25
38
|
memorax-cli add \
|
|
@@ -49,7 +62,7 @@ anchors: <stable repository source, tests, or public docs>
|
|
|
49
62
|
|
|
50
63
|
Keep the card under 1,100 characters when practical. It must guide future investigation while still requiring live-code inspection.
|
|
51
64
|
|
|
52
|
-
Pass a completed multi-line card as one single-quoted `--memory` argument
|
|
65
|
+
Pass a completed multi-line card as one single-quoted `--memory` argument. On Windows PowerShell, the command must start with `memorax-cli.cmd add`; on macOS and Linux, use the form shown below.
|
|
53
66
|
|
|
54
67
|
```bash
|
|
55
68
|
memorax-cli add \
|
|
@@ -69,7 +82,7 @@ anchors: stable/source/path' \
|
|
|
69
82
|
--reason 'Capture verified reusable coding memory.'
|
|
70
83
|
```
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
Except for the pre-start Windows shim correction above, if add fails, report the exact failure and do not retry automatically, bypass the CLI, or call MemoraX directly. Do not retry Add after the CLI may have started.
|
|
73
86
|
|
|
74
87
|
If a successful Add result reports `workspaceScopeFallbackReason: git_metadata_invalid`, malformed or incomplete metadata inside a direct `.git` directory was downgraded to the normalized local folder scope. Add has already been submitted with the reported `effectiveUserId`. Present its `userNotice` once without pausing the current task or asking the user to repair Git first, then continue the current task. After the repository or `.git` metadata is repaired, later Search, Add, and automatic writeback in the same client session automatically use the restored Git repository scope.
|
|
75
88
|
|
|
@@ -4,6 +4,8 @@ Use these instructions only to search reusable coding memory through `memorax-cl
|
|
|
4
4
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
7
|
+
Select the executable before constructing any Search command. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry the same command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
8
|
+
|
|
7
9
|
Run the CLI from the active task workspace. The installed Hook and session binding supply the authoritative workspace root; do not run `git rev-parse`, infer the root from Git metadata, or substitute an unrelated working directory. Do not make `memorax-cli status` a mandatory preflight; use it only to diagnose a configuration or scope failure.
|
|
8
10
|
|
|
9
11
|
Coding memory uses `<MemoraX base username>@<normalized repository name>` for Git workspaces and the normalized folder name for genuine non-Git directories. MemoraX Code resolves `.git`, `gitdir`, and `commondir` without executing Git. Linked worktrees share one repository scope; another clone, repository, or non-Git directory retains a different local session key even when its readable name matches.
|
|
@@ -12,7 +14,7 @@ If a successful Search result reports `workspaceScopeFallbackReason: git_metadat
|
|
|
12
14
|
|
|
13
15
|
Require a readable active workspace binding. A CLI command from a linked worktree of the bound repository is valid. If `memorax-cli search` reports `workspace_scope_mismatch` or `workspace_scope_unavailable`, do not bypass the scope or fall back to an unscoped username. Do not change the CLI working directory and retry. Tell the user that memory search was not executed and no request was sent to MemoraX, then present the CLI's `userAction` in natural language. Continue the current task using only live code and documentation.
|
|
14
16
|
|
|
15
|
-
If
|
|
17
|
+
If the selected platform command is not on `PATH`, or memory is disabled, unconfigured, or unavailable, report that briefly and continue with live code or documentation. Authenticate through MemoraX Code configuration; never recover credentials from shell history or place tokens in prompts. Treat injected memory as a hypothesis and verify it against the current checkout.
|
|
16
18
|
|
|
17
19
|
## Search Decision
|
|
18
20
|
|
|
@@ -50,10 +52,21 @@ State a fact-sized relationship that can change the next action: a target under
|
|
|
50
52
|
|
|
51
53
|
For a complementary first-round pair, each query must stand alone and cover a different decision boundary. Use a complementary pair only when the provided context gives each decision boundary a distinct exact code, API, path, workflow, or project identifier; otherwise keep one focused combined query that preserves both user-stated facts. Do not merely restate the same question with synonyms. If the user describes only one tightly coupled decision, emit exactly one query. Use one or two stable exact identifiers when they sharpen the query, and integrate them grammatically instead of appending search tags or filler. Use only user-provided anchors and stable terms from live code or documentation; do not reconstruct unseen fact wording from recalled memory.
|
|
52
54
|
|
|
53
|
-
Pass the query directly with `--query`. Put every dynamically generated query in single quotes, never double quotes.
|
|
55
|
+
Pass the query directly with `--query`. Put every dynamically generated query in single quotes, never double quotes. Apply the escaping rule for the active shell:
|
|
56
|
+
|
|
57
|
+
- Windows PowerShell: single quotes keep `$HOME`, backticks, and `$(command)` literal. Replace each literal single quote in the value with two single quotes (`''`); for example, `don't` becomes `'don''t'`.
|
|
58
|
+
- macOS and Linux: Treat `$HOME`, backticks, and `$(command)` as literal text inside the quotes. Replace each literal single quote in the value with the exact POSIX sequence `'\''`.
|
|
54
59
|
|
|
55
60
|
Use these actual output shapes as examples. They are queries themselves, not full user prompts or instructions for the user. Each Chinese/English pair is a language variant: choose the one matching the user, never run both merely because both are shown. The comments explain the example only and are not part of emitted query text.
|
|
56
61
|
|
|
62
|
+
On Windows PowerShell, the first example must be invoked as:
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
memorax-cli.cmd search --query 'Trace 生产版本:升级后到达的记录中,应以哪个客户端版本字段判断由旧插件产生,而非新版本上传进程?'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
On macOS and Linux, use the `memorax-cli search` forms below. For other Windows examples, preserve every argument but replace the leading executable with `memorax-cli.cmd`.
|
|
69
|
+
|
|
57
70
|
```bash
|
|
58
71
|
# One tightly coupled decision: emit one query.
|
|
59
72
|
memorax-cli search --query 'Trace 生产版本:升级后到达的记录中,应以哪个客户端版本字段判断由旧插件产生,而非新版本上传进程?'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { chmod, cp, mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
|
-
import { dirname, join, relative, sep, win32 } from "node:path";
|
|
4
|
+
import { basename, dirname, join, relative, sep, win32 } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { resolveHookCodeBuddyCommand } from "../../memorax-code-adapter-common/src/clients/codebuddy-command.mjs";
|
|
7
7
|
import {
|
|
@@ -19,10 +19,20 @@ const PLUGIN_NAME = "memorax-code-codebuddy-adapter";
|
|
|
19
19
|
const MARKETPLACE_NAME = "memorax-code-local";
|
|
20
20
|
const PLUGIN_ID = `${PLUGIN_NAME}@${MARKETPLACE_NAME}`;
|
|
21
21
|
|
|
22
|
-
export function defaultCodeBuddyHome(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
export function defaultCodeBuddyHome(
|
|
23
|
+
env = process.env,
|
|
24
|
+
homeDir = homedir(),
|
|
25
|
+
platform = process.platform,
|
|
26
|
+
pathExists = existsSync,
|
|
27
|
+
) {
|
|
28
|
+
const configured = env.CODEBUDDY_HOME?.trim() || env.WORKBUDDY_HOME?.trim();
|
|
29
|
+
if (configured) return configured;
|
|
30
|
+
if (platform !== "win32") return join(homeDir, ".workbuddy");
|
|
31
|
+
const workBuddyHome = win32.join(homeDir, ".workbuddy");
|
|
32
|
+
const legacyCodeBuddyHome = win32.join(homeDir, ".codebuddy");
|
|
33
|
+
return pathExists(workBuddyHome) || !pathExists(legacyCodeBuddyHome)
|
|
34
|
+
? workBuddyHome
|
|
35
|
+
: legacyCodeBuddyHome;
|
|
26
36
|
}
|
|
27
37
|
// CodeBuddy stores installed plugin caches under the marketplace namespace.
|
|
28
38
|
export function codeBuddyInstallPath(home = defaultCodeBuddyHome()) { return join(home, "plugins", "cache", MARKETPLACE_NAME, PLUGIN_NAME, VERSION); }
|
|
@@ -61,20 +71,21 @@ export async function enableCodeBuddyAdapter(options = {}) {
|
|
|
61
71
|
settings.enabledPlugins[PLUGIN_ID] = true;
|
|
62
72
|
});
|
|
63
73
|
await updateLegacyRegistry(home, { installPath, enabled: true });
|
|
74
|
+
await removeLegacyManagedInstallation(home, platform);
|
|
64
75
|
return { ok: true, action: "enable", runtime: "codebuddy", integration: "hooks", installed: true, enabled: true, codeBuddyHome: home, installPath, marketplace: MARKETPLACE_NAME, pluginId: PLUGIN_ID, marketplacePath: localPluginPath, codebuddyHooks: { ok: true, configured: true, runtimeObserved: false, status: "unverified" }, codebuddySkills: { ok: true, status: "installed", managed: true, memoraxCode: true, path: join(localPluginPath, "skills", "memorax-code", "SKILL.md") } };
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
export async function disableCodeBuddyAdapter(options = {}) {
|
|
68
79
|
const home = options.codeBuddyHome ?? defaultCodeBuddyHome();
|
|
80
|
+
const platform = options.platform ?? process.platform;
|
|
69
81
|
const registryPath = installedRegistryPath(home);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
await
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return { ok: true, action: "disable", runtime: "codebuddy", installed: true, enabled: false, codeBuddyHome: home, statePath: registryPath, marketplace: MARKETPLACE_NAME, pluginId: PLUGIN_ID };
|
|
82
|
+
const legacyHome = legacyCodeBuddyHome(home, platform);
|
|
83
|
+
const installed = await managedCodeBuddyInstallationExists(home);
|
|
84
|
+
const legacyInstalled = legacyHome ? await managedCodeBuddyInstallationExists(legacyHome) : false;
|
|
85
|
+
if (!installed && !legacyInstalled) return { ok: true, action: "disable", runtime: "codebuddy", installed: false, enabled: false, codeBuddyHome: home, statePath: registryPath, marketplace: MARKETPLACE_NAME, pluginId: PLUGIN_ID };
|
|
86
|
+
if (installed) await disableManagedCodeBuddyInstallation(home);
|
|
87
|
+
if (legacyInstalled) await disableManagedCodeBuddyInstallation(legacyHome);
|
|
88
|
+
return { ok: true, action: "disable", runtime: "codebuddy", installed: true, enabled: false, codeBuddyHome: home, statePath: registryPath, marketplace: MARKETPLACE_NAME, pluginId: PLUGIN_ID, legacyCodeBuddyHome: legacyInstalled ? legacyHome : undefined, legacyManaged: legacyInstalled };
|
|
78
89
|
}
|
|
79
90
|
|
|
80
91
|
export async function readCodeBuddyAdapterStatus(options = {}) {
|
|
@@ -94,28 +105,73 @@ export async function readCodeBuddyAdapterStatus(options = {}) {
|
|
|
94
105
|
const skillInstalled = await pathExists(skillPath);
|
|
95
106
|
const enabled = settings.enabledPlugins?.[PLUGIN_ID] === true;
|
|
96
107
|
const marketplaceReady = Boolean(known[MARKETPLACE_NAME]);
|
|
108
|
+
const legacyHome = legacyCodeBuddyHome(home, platform);
|
|
109
|
+
const legacyManaged = legacyHome ? await managedCodeBuddyInstallationExists(legacyHome) : false;
|
|
97
110
|
const hookConfigured = installedRoots.length > 0
|
|
98
111
|
&& (await Promise.all(installedRoots.map((root) => codeBuddyHookManifestConfigured(root, platform)))).every(Boolean);
|
|
99
112
|
const observation = await readCodeBuddyRuntimeObservation(memoraxCodeHome);
|
|
100
113
|
const runtimeObserved = hookConfigured && observationMatches(observation, home, platform);
|
|
101
|
-
return { ok: true, action: "status", runtime: "codebuddy", integration: "hooks", installed, enabled, managed: installed && marketplaceReady, codeBuddyHome: home, installPath, marketplace: MARKETPLACE_NAME, pluginId: PLUGIN_ID, marketplaceReady, codebuddyHooks: { ok: hookConfigured, configured: hookConfigured, runtimeObserved, status: hookConfigured ? (runtimeObserved ? "observed" : "unverified") : "invalid", observationPath: codeBuddyRuntimeObservationPath(memoraxCodeHome) }, codebuddySkills: { ok: skillInstalled, status: skillInstalled ? "installed" : "missing", managed: skillInstalled, memoraxCode: skillInstalled, path: skillPath } };
|
|
114
|
+
return { ok: true, action: "status", runtime: "codebuddy", integration: "hooks", installed, enabled, managed: installed && marketplaceReady, codeBuddyHome: home, installPath, marketplace: MARKETPLACE_NAME, pluginId: PLUGIN_ID, marketplaceReady, legacyCodeBuddyHome: legacyManaged ? legacyHome : undefined, legacyManaged, codebuddyHooks: { ok: hookConfigured, configured: hookConfigured, runtimeObserved, status: hookConfigured ? (runtimeObserved ? "observed" : "unverified") : "invalid", observationPath: codeBuddyRuntimeObservationPath(memoraxCodeHome) }, codebuddySkills: { ok: skillInstalled, status: skillInstalled ? "installed" : "missing", managed: skillInstalled, memoraxCode: skillInstalled, path: skillPath } };
|
|
102
115
|
}
|
|
103
116
|
|
|
104
117
|
export async function removeCodeBuddyPluginInstallation(options = {}) {
|
|
105
118
|
const home = options.codeBuddyHome ?? defaultCodeBuddyHome();
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
const
|
|
119
|
+
const platform = options.platform ?? process.platform;
|
|
120
|
+
const legacyHome = legacyCodeBuddyHome(home, platform);
|
|
121
|
+
const removed = await removeManagedCodeBuddyInstallation(home);
|
|
122
|
+
const legacyRemoved = legacyHome ? await removeManagedCodeBuddyInstallation(legacyHome) : false;
|
|
123
|
+
return { ok: true, action: "codebuddy-plugin-remove", runtime: "codebuddy", installed: false, enabled: false, removed: removed || legacyRemoved, codeBuddyHome: home, statePath: installedRegistryPath(home), marketplace: MARKETPLACE_NAME, pluginId: PLUGIN_ID };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function disableManagedCodeBuddyInstallation(home) {
|
|
109
127
|
await updateSettings(home, (settings) => {
|
|
128
|
+
settings.enabledPlugins = recordValue(settings.enabledPlugins);
|
|
129
|
+
settings.enabledPlugins[PLUGIN_ID] = false;
|
|
130
|
+
});
|
|
131
|
+
await updateLegacyRegistry(home, { installPath: codeBuddyInstallPath(home), enabled: false });
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function removeLegacyManagedInstallation(home, platform) {
|
|
135
|
+
const legacyHome = legacyCodeBuddyHome(home, platform);
|
|
136
|
+
return legacyHome ? await removeManagedCodeBuddyInstallation(legacyHome) : false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function removeManagedCodeBuddyInstallation(home) {
|
|
140
|
+
if (!await managedCodeBuddyInstallationExists(home)) return false;
|
|
141
|
+
await updateJsonRecordIfPresent(codeBuddySettingsPath(home), (settings) => {
|
|
110
142
|
settings.enabledPlugins = recordValue(settings.enabledPlugins);
|
|
111
143
|
delete settings.enabledPlugins[PLUGIN_ID];
|
|
112
144
|
});
|
|
113
|
-
await
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
await
|
|
145
|
+
await updateJsonRecordIfPresent(knownMarketplacesPath(home), (known) => {
|
|
146
|
+
delete known[MARKETPLACE_NAME];
|
|
147
|
+
});
|
|
148
|
+
await updateJsonRecordIfPresent(installedRegistryPath(home), (value) => {
|
|
149
|
+
value.version = 2;
|
|
150
|
+
value.plugins = recordValue(value.plugins);
|
|
151
|
+
delete value.plugins[PLUGIN_ID];
|
|
152
|
+
});
|
|
153
|
+
await rm(codeBuddyPluginCacheRoot(home), { recursive: true, force: true });
|
|
154
|
+
await rm(legacyCodeBuddyPluginCacheRoot(home), { recursive: true, force: true });
|
|
117
155
|
await rm(marketplaceRoot(home), { recursive: true, force: true });
|
|
118
|
-
return
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function managedCodeBuddyInstallationExists(home) {
|
|
160
|
+
if (await pathExists(marketplaceRoot(home))
|
|
161
|
+
|| await pathExists(codeBuddyPluginCacheRoot(home))
|
|
162
|
+
|| await pathExists(legacyCodeBuddyPluginCacheRoot(home))) return true;
|
|
163
|
+
const settings = await readJsonRecord(codeBuddySettingsPath(home));
|
|
164
|
+
const known = await readJsonRecord(knownMarketplacesPath(home));
|
|
165
|
+
const registry = await readJsonRecord(installedRegistryPath(home));
|
|
166
|
+
return Object.hasOwn(recordValue(settings.enabledPlugins), PLUGIN_ID)
|
|
167
|
+
|| Object.hasOwn(known, MARKETPLACE_NAME)
|
|
168
|
+
|| Object.hasOwn(recordValue(registry.plugins), PLUGIN_ID);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function legacyCodeBuddyHome(home, platform) {
|
|
172
|
+
return platform === "win32" && basename(home).toLowerCase() === ".workbuddy"
|
|
173
|
+
? join(dirname(home), ".codebuddy")
|
|
174
|
+
: undefined;
|
|
119
175
|
}
|
|
120
176
|
|
|
121
177
|
async function readRegistry(home) {
|
|
@@ -196,6 +252,11 @@ async function updateJsonRecord(path, mutate) {
|
|
|
196
252
|
await rm(lockPath, { force: true });
|
|
197
253
|
}
|
|
198
254
|
}
|
|
255
|
+
|
|
256
|
+
async function updateJsonRecordIfPresent(path, mutate) {
|
|
257
|
+
if (await pathExists(path)) await updateJsonRecord(path, mutate);
|
|
258
|
+
}
|
|
259
|
+
|
|
199
260
|
async function readJsonRecord(path) {
|
|
200
261
|
try {
|
|
201
262
|
const value = JSON.parse(await readFile(path, "utf8"));
|
|
@@ -225,6 +286,8 @@ function readPluginVersion() {
|
|
|
225
286
|
return manifest.version.trim();
|
|
226
287
|
}
|
|
227
288
|
function legacyCodeBuddyInstallPath(home) { return join(home, "plugins", "cache", PLUGIN_NAME, VERSION); }
|
|
289
|
+
function codeBuddyPluginCacheRoot(home) { return dirname(codeBuddyInstallPath(home)); }
|
|
290
|
+
function legacyCodeBuddyPluginCacheRoot(home) { return dirname(legacyCodeBuddyInstallPath(home)); }
|
|
228
291
|
|
|
229
292
|
async function materializeCanonicalSkill(destination) {
|
|
230
293
|
const packagedSkill = join(ROOT, "skills", "memorax-code");
|
|
@@ -74,7 +74,9 @@ Examples:
|
|
|
74
74
|
|
|
75
75
|
## Shared Rules
|
|
76
76
|
|
|
77
|
-
For MemoraX Code coding memory, run
|
|
77
|
+
For MemoraX Code coding memory, run the platform command from the active task workspace. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry the same command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
78
|
+
|
|
79
|
+
The installed Hook and session binding supply the authoritative workspace root; do not run Git commands to discover or replace it. The Backend resolves repository scope from that trusted workspace and read-only filesystem Git metadata.
|
|
78
80
|
|
|
79
81
|
Repo memory and personal memory remain local `.repo_memory` authorities. Resolve their repository root exactly as described by the selected reference, including its Git requirements.
|
|
80
82
|
|
|
@@ -17,9 +17,22 @@ Do not add positive repair lessons based only on unverified edits or assistant s
|
|
|
17
17
|
|
|
18
18
|
## Add Workflow
|
|
19
19
|
|
|
20
|
+
Select the executable before constructing any Add command. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry that command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
21
|
+
|
|
20
22
|
For a proactive add, write all generated prose in `--memory`, `--reason`, and the confirmation in the language of the user's current request; preserve exact code, API, path, workflow, and project identifiers.
|
|
21
23
|
|
|
22
|
-
Run from the active task workspace. Pass the memory and reason directly. Put every dynamically generated `--memory` and `--reason` value in single quotes, never double quotes.
|
|
24
|
+
Run from the active task workspace. Pass the memory and reason directly. Put every dynamically generated `--memory` and `--reason` value in single quotes, never double quotes. Apply the escaping rule for the active shell:
|
|
25
|
+
|
|
26
|
+
- Windows PowerShell: single quotes keep `$HOME`, backticks, and `$(command)` literal. Replace each literal single quote in a value with two single quotes (`''`); for example, `don't` becomes `'don''t'`.
|
|
27
|
+
- macOS and Linux: Treat `$HOME`, backticks, and `$(command)` as literal text inside the quotes. Replace each literal single quote in a value with the exact POSIX sequence `'\''`.
|
|
28
|
+
|
|
29
|
+
Windows PowerShell:
|
|
30
|
+
|
|
31
|
+
```powershell
|
|
32
|
+
memorax-cli.cmd add --memory 'Concise reusable memory.' --type procedural --reason 'Capture reusable coding memory.'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
macOS and Linux:
|
|
23
36
|
|
|
24
37
|
```bash
|
|
25
38
|
memorax-cli add \
|
|
@@ -49,7 +62,7 @@ anchors: <stable repository source, tests, or public docs>
|
|
|
49
62
|
|
|
50
63
|
Keep the card under 1,100 characters when practical. It must guide future investigation while still requiring live-code inspection.
|
|
51
64
|
|
|
52
|
-
Pass a completed multi-line card as one single-quoted `--memory` argument
|
|
65
|
+
Pass a completed multi-line card as one single-quoted `--memory` argument. On Windows PowerShell, the command must start with `memorax-cli.cmd add`; on macOS and Linux, use the form shown below.
|
|
53
66
|
|
|
54
67
|
```bash
|
|
55
68
|
memorax-cli add \
|
|
@@ -69,7 +82,7 @@ anchors: stable/source/path' \
|
|
|
69
82
|
--reason 'Capture verified reusable coding memory.'
|
|
70
83
|
```
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
Except for the pre-start Windows shim correction above, if add fails, report the exact failure and do not retry automatically, bypass the CLI, or call MemoraX directly. Do not retry Add after the CLI may have started.
|
|
73
86
|
|
|
74
87
|
If a successful Add result reports `workspaceScopeFallbackReason: git_metadata_invalid`, malformed or incomplete metadata inside a direct `.git` directory was downgraded to the normalized local folder scope. Add has already been submitted with the reported `effectiveUserId`. Present its `userNotice` once without pausing the current task or asking the user to repair Git first, then continue the current task. After the repository or `.git` metadata is repaired, later Search, Add, and automatic writeback in the same client session automatically use the restored Git repository scope.
|
|
75
88
|
|
|
@@ -4,6 +4,8 @@ Use these instructions only to search reusable coding memory through `memorax-cl
|
|
|
4
4
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
7
|
+
Select the executable before constructing any Search command. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry the same command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
8
|
+
|
|
7
9
|
Run the CLI from the active task workspace. The installed Hook and session binding supply the authoritative workspace root; do not run `git rev-parse`, infer the root from Git metadata, or substitute an unrelated working directory. Do not make `memorax-cli status` a mandatory preflight; use it only to diagnose a configuration or scope failure.
|
|
8
10
|
|
|
9
11
|
Coding memory uses `<MemoraX base username>@<normalized repository name>` for Git workspaces and the normalized folder name for genuine non-Git directories. MemoraX Code resolves `.git`, `gitdir`, and `commondir` without executing Git. Linked worktrees share one repository scope; another clone, repository, or non-Git directory retains a different local session key even when its readable name matches.
|
|
@@ -12,7 +14,7 @@ If a successful Search result reports `workspaceScopeFallbackReason: git_metadat
|
|
|
12
14
|
|
|
13
15
|
Require a readable active workspace binding. A CLI command from a linked worktree of the bound repository is valid. If `memorax-cli search` reports `workspace_scope_mismatch` or `workspace_scope_unavailable`, do not bypass the scope or fall back to an unscoped username. Do not change the CLI working directory and retry. Tell the user that memory search was not executed and no request was sent to MemoraX, then present the CLI's `userAction` in natural language. Continue the current task using only live code and documentation.
|
|
14
16
|
|
|
15
|
-
If
|
|
17
|
+
If the selected platform command is not on `PATH`, or memory is disabled, unconfigured, or unavailable, report that briefly and continue with live code or documentation. Authenticate through MemoraX Code configuration; never recover credentials from shell history or place tokens in prompts. Treat injected memory as a hypothesis and verify it against the current checkout.
|
|
16
18
|
|
|
17
19
|
## Search Decision
|
|
18
20
|
|
|
@@ -50,10 +52,21 @@ State a fact-sized relationship that can change the next action: a target under
|
|
|
50
52
|
|
|
51
53
|
For a complementary first-round pair, each query must stand alone and cover a different decision boundary. Use a complementary pair only when the provided context gives each decision boundary a distinct exact code, API, path, workflow, or project identifier; otherwise keep one focused combined query that preserves both user-stated facts. Do not merely restate the same question with synonyms. If the user describes only one tightly coupled decision, emit exactly one query. Use one or two stable exact identifiers when they sharpen the query, and integrate them grammatically instead of appending search tags or filler. Use only user-provided anchors and stable terms from live code or documentation; do not reconstruct unseen fact wording from recalled memory.
|
|
52
54
|
|
|
53
|
-
Pass the query directly with `--query`. Put every dynamically generated query in single quotes, never double quotes.
|
|
55
|
+
Pass the query directly with `--query`. Put every dynamically generated query in single quotes, never double quotes. Apply the escaping rule for the active shell:
|
|
56
|
+
|
|
57
|
+
- Windows PowerShell: single quotes keep `$HOME`, backticks, and `$(command)` literal. Replace each literal single quote in the value with two single quotes (`''`); for example, `don't` becomes `'don''t'`.
|
|
58
|
+
- macOS and Linux: Treat `$HOME`, backticks, and `$(command)` as literal text inside the quotes. Replace each literal single quote in the value with the exact POSIX sequence `'\''`.
|
|
54
59
|
|
|
55
60
|
Use these actual output shapes as examples. They are queries themselves, not full user prompts or instructions for the user. Each Chinese/English pair is a language variant: choose the one matching the user, never run both merely because both are shown. The comments explain the example only and are not part of emitted query text.
|
|
56
61
|
|
|
62
|
+
On Windows PowerShell, the first example must be invoked as:
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
memorax-cli.cmd search --query 'Trace 生产版本:升级后到达的记录中,应以哪个客户端版本字段判断由旧插件产生,而非新版本上传进程?'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
On macOS and Linux, use the `memorax-cli search` forms below. For other Windows examples, preserve every argument but replace the leading executable with `memorax-cli.cmd`.
|
|
69
|
+
|
|
57
70
|
```bash
|
|
58
71
|
# One tightly coupled decision: emit one query.
|
|
59
72
|
memorax-cli search --query 'Trace 生产版本:升级后到达的记录中,应以哪个客户端版本字段判断由旧插件产生,而非新版本上传进程?'
|
|
@@ -74,7 +74,9 @@ Examples:
|
|
|
74
74
|
|
|
75
75
|
## Shared Rules
|
|
76
76
|
|
|
77
|
-
For MemoraX Code coding memory, run
|
|
77
|
+
For MemoraX Code coding memory, run the platform command from the active task workspace. In Windows PowerShell, use `memorax-cli.cmd`; on macOS and Linux, use `memorax-cli`. Never invoke `memorax-cli.ps1`. Never run `Set-ExecutionPolicy` or otherwise change PowerShell execution policy for MemoraX commands. If an unqualified Windows invocation is blocked before the CLI starts with `UnauthorizedAccess` or `PSSecurityException`, retry the same command once with `memorax-cli.cmd`, preserving all arguments, the active workspace, and environment variables.
|
|
78
|
+
|
|
79
|
+
The installed Hook and session binding supply the authoritative workspace root; do not run Git commands to discover or replace it. The Backend resolves repository scope from that trusted workspace and read-only filesystem Git metadata.
|
|
78
80
|
|
|
79
81
|
Repo memory and personal memory remain local `.repo_memory` authorities. Resolve their repository root exactly as described by the selected reference, including its Git requirements.
|
|
80
82
|
|