@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.
Files changed (84) hide show
  1. package/README.md +7 -4
  2. package/bin/memorax-code-setup.mjs +136 -34
  3. package/bin/memorax-code-trae.mjs +4 -0
  4. package/docs/configuration.md +111 -54
  5. package/docs/troubleshooting.md +50 -8
  6. package/lib/memorax-code-backend/dist/clients/claude/transcript-turn.js +2 -2
  7. package/lib/memorax-code-backend/dist/clients/codex/rollout-turn.js +1 -1
  8. package/lib/memorax-code-backend/dist/clients/trae/lifecycle.js +53 -0
  9. package/lib/memorax-code-backend/dist/clients/trae/memory-hook-runtime.js +302 -0
  10. package/lib/memorax-code-backend/dist/clients/trae/turn-id.js +16 -0
  11. package/lib/memorax-code-backend/dist/config/memorax-code.js +14 -1
  12. package/lib/memorax-code-backend/dist/entrypoints/backend-cli.js +22 -4
  13. package/lib/memorax-code-backend/dist/lifecycle/active-clients.js +3 -0
  14. package/lib/memorax-code-backend/dist/lifecycle/client-plugin-removal.js +14 -2
  15. package/lib/memorax-code-backend/dist/lifecycle/client-selection.js +5 -3
  16. package/lib/memorax-code-backend/dist/lifecycle/orchestrator.js +62 -9
  17. package/lib/memorax-code-backend/dist/memory/hook-command.js +34 -2
  18. package/lib/memorax-code-backend/dist/memory/reminder-trace-recorder.js +5 -1
  19. package/lib/memorax-code-backend/dist/memory/service.js +12 -0
  20. package/lib/memorax-code-backend/dist/trace/config.js +12 -1
  21. package/lib/memorax-code-backend/dist/trace/context.js +26 -1
  22. package/lib/memorax-code-backend/package.json +1 -1
  23. package/lib/memorax-code-claude-adapter/.claude-plugin/plugin.json +1 -1
  24. package/lib/memorax-code-claude-adapter/hooks/runtime-shell.json +1 -1
  25. package/lib/memorax-code-claude-adapter/package.json +1 -1
  26. package/lib/memorax-code-claude-adapter/skills/memorax-code/SKILL.md +3 -1
  27. package/lib/memorax-code-claude-adapter/skills/memorax-code/references/memorax-add.md +16 -3
  28. package/lib/memorax-code-claude-adapter/skills/memorax-code/references/memorax-search.md +15 -2
  29. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/.claude-plugin/plugin.json +1 -1
  30. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/hooks/runtime-shell.json +1 -1
  31. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/package.json +1 -1
  32. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/SKILL.md +3 -1
  33. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/memorax-add.md +16 -3
  34. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/memorax-search.md +15 -2
  35. package/lib/memorax-code-codebuddy-adapter/.codebuddy-plugin/plugin.json +1 -1
  36. package/lib/memorax-code-codebuddy-adapter/hooks/runtime-hook.mjs +11 -1
  37. package/lib/memorax-code-codebuddy-adapter/package.json +1 -1
  38. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/SKILL.md +3 -1
  39. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/memorax-add.md +16 -3
  40. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/memorax-search.md +15 -2
  41. package/lib/memorax-code-codebuddy-adapter/src/config.mjs +86 -23
  42. package/lib/memorax-code-codex-adapter/.codex-plugin/plugin.json +1 -1
  43. package/lib/memorax-code-codex-adapter/hooks/runtime-shell.json +1 -1
  44. package/lib/memorax-code-codex-adapter/package.json +1 -1
  45. package/lib/memorax-code-codex-adapter/skills/memorax-code/SKILL.md +3 -1
  46. package/lib/memorax-code-codex-adapter/skills/memorax-code/references/memorax-add.md +16 -3
  47. package/lib/memorax-code-codex-adapter/skills/memorax-code/references/memorax-search.md +15 -2
  48. package/lib/memorax-code-dsh-adapter/package.json +1 -1
  49. package/lib/memorax-code-dsh-adapter/skills/memorax-code/SKILL.md +3 -1
  50. package/lib/memorax-code-dsh-adapter/skills/memorax-code/references/memorax-add.md +16 -3
  51. package/lib/memorax-code-dsh-adapter/skills/memorax-code/references/memorax-search.md +15 -2
  52. package/lib/memorax-code-opencode-adapter/package.json +1 -1
  53. package/lib/memorax-code-opencode-adapter/skills/memorax-code/SKILL.md +3 -1
  54. package/lib/memorax-code-opencode-adapter/skills/memorax-code/references/memorax-add.md +16 -3
  55. package/lib/memorax-code-opencode-adapter/skills/memorax-code/references/memorax-search.md +15 -2
  56. package/lib/memorax-code-trae-adapter/hooks/runtime-hook.mjs +340 -0
  57. package/lib/memorax-code-trae-adapter/package.json +9 -0
  58. package/lib/memorax-code-trae-adapter/skills/memorax-code/SKILL.md +87 -0
  59. package/lib/memorax-code-trae-adapter/skills/memorax-code/agents/claude.yaml +10 -0
  60. package/lib/memorax-code-trae-adapter/skills/memorax-code/agents/openai.yaml +7 -0
  61. package/lib/memorax-code-trae-adapter/skills/memorax-code/defaults.json +12 -0
  62. package/lib/memorax-code-trae-adapter/skills/memorax-code/references/memorax-add.md +101 -0
  63. package/lib/memorax-code-trae-adapter/skills/memorax-code/references/memorax-search.md +106 -0
  64. package/lib/memorax-code-trae-adapter/skills/memorax-code/references/personal-read.md +46 -0
  65. package/lib/memorax-code-trae-adapter/skills/memorax-code/references/personal-write.md +120 -0
  66. package/lib/memorax-code-trae-adapter/skills/memorax-code/references/repo-build.md +319 -0
  67. package/lib/memorax-code-trae-adapter/skills/memorax-code/references/repo-read.md +103 -0
  68. package/lib/memorax-code-trae-adapter/skills/memorax-code/references/repo-templates.md +390 -0
  69. package/lib/memorax-code-trae-adapter/skills/memorax-code/references/repo-update.md +127 -0
  70. package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/collect_all.py +579 -0
  71. package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/detect_updates.py +919 -0
  72. package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/git_commit_facets.py +222 -0
  73. package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/github_resource_facets.py +512 -0
  74. package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/gitlab_resource_facets.py +517 -0
  75. package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/prepare_repo_memory.py +411 -0
  76. package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/user_profile_memory.py +528 -0
  77. package/lib/memorax-code-trae-adapter/skills/memorax-code/scripts/validate_memory.py +248 -0
  78. package/lib/memorax-code-trae-adapter/src/adapter-paths.mjs +69 -0
  79. package/lib/memorax-code-trae-adapter/src/cli.mjs +59 -0
  80. package/lib/memorax-code-trae-adapter/src/config.mjs +630 -0
  81. package/lib/memorax-code-trae-adapter/src/runtime-observation.mjs +55 -0
  82. package/lib/resolve-codebuddy-command.mjs +15 -4
  83. package/lib/run-entrypoint.mjs +6 -0
  84. package/package.json +5 -3
@@ -0,0 +1,7 @@
1
+ interface:
2
+ display_name: "MemoraX Code"
3
+ short_description: "Route coding, repo, and personal memory"
4
+ default_prompt: "Use $memorax-code to route a coding-memory, repo-memory, or personal-memory request to the correct operation."
5
+
6
+ policy:
7
+ allow_implicit_invocation: true
@@ -0,0 +1,12 @@
1
+ {
2
+ "schema": "repo_memory_builder_defaults.v2",
3
+ "repoHistory": {
4
+ "mode": "provider",
5
+ "limits": {
6
+ "commits": 30,
7
+ "prs": 30,
8
+ "issues": 30
9
+ }
10
+ },
11
+ "summaryChars": 4000
12
+ }
@@ -0,0 +1,101 @@
1
+ # MemoraX Code Coding Memory Add
2
+
3
+ Use these instructions only to add reusable coding knowledge through `memorax-cli`. Invoke the skill as `$memorax-code` in Codex or `/memorax-code` in Claude Code. In OpenCode, ask the agent to use the `memorax-code` skill by name. Do not route memory operations through the lifecycle-only `memorax-code` CLI. Do not use this authority for personal procedures, interaction preferences, generated repository facts, or one-off task details.
4
+
5
+ ## Eligible Knowledge
6
+
7
+ Add a coding memory only when the task yields stable, grounded, reusable engineering knowledge, such as:
8
+
9
+ - a verified repair invariant or validation pattern;
10
+ - a reusable failed-attempt lesson;
11
+ - a confirmed coding convention, lifecycle boundary, or implementation pitfall;
12
+ - durable design rationale that will help future coding work.
13
+
14
+ Route user-owned ordered actions, checklists, gates, and work rules to personal procedure memory. Route preferred language, tone, verbosity, name, and presentation to personal profile memory. Route commit, PR, issue, architecture-map, and repository-history facts to repo memory.
15
+
16
+ Do not add positive repair lessons based only on unverified edits or assistant self-report. Verification may come from a focused test, evaluator, CI check, accepted review, manual reproduction, or deployed behavior. A failed attempt may be saved as negative evidence when the failure itself is clear and reusable.
17
+
18
+ ## Add Workflow
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
+
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.
23
+
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:
36
+
37
+ ```bash
38
+ memorax-cli add \
39
+ --memory 'Concise reusable memory.' \
40
+ --type procedural \
41
+ --reason 'Capture reusable coding memory.'
42
+ ```
43
+
44
+ Use an appropriate supported type such as `core`, `semantic`, `procedural`, `episodic`, or `unclassified`. Use `preference` only for an engineering convention owned by MemoraX Code coding memory, not for a personal interaction preference.
45
+
46
+ For a complex verified repair or failed approach, use this compact card when it improves later retrieval:
47
+
48
+ ```text
49
+ CODE_AGENT_MEMORY
50
+ repo: <repository or product area>
51
+ scope: <module/path::symbol/API or lifecycle boundary>
52
+ status: <verified|failed_attempt|candidate>
53
+ signal: <test, CI, review, reproduction, deployment, failure, or unknown>
54
+ problem: <small behavioral symptom or engineering situation>
55
+ technical_context: <stable API, lifecycle, state owner, or data-shape detail>
56
+ surfaces: <observable producer/consumer or setup/runtime/cleanup boundaries>
57
+ failed_shape: <reusable wrong assumption or unsafe patch shape, or none>
58
+ validation: <small reusable check contract>
59
+ principle: <abstract invariant or decision rule>
60
+ anchors: <stable repository source, tests, or public docs>
61
+ ```
62
+
63
+ Keep the card under 1,100 characters when practical. It must guide future investigation while still requiring live-code inspection.
64
+
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.
66
+
67
+ ```bash
68
+ memorax-cli add \
69
+ --memory 'CODE_AGENT_MEMORY
70
+ repo: owner/name
71
+ scope: module/path::symbol
72
+ status: verified
73
+ signal: focused test passed
74
+ problem: concise reusable symptom
75
+ technical_context: stable implementation fact
76
+ surfaces: affected boundary
77
+ failed_shape: reusable pitfall or none
78
+ validation: smallest reusable check
79
+ principle: reusable invariant
80
+ anchors: stable/source/path' \
81
+ --type procedural \
82
+ --reason 'Capture verified reusable coding memory.'
83
+ ```
84
+
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.
86
+
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.
88
+
89
+ If `memorax-cli add` reports `workspace_scope_mismatch` or `workspace_scope_unavailable`, do not bypass the scope. Do not change the CLI working directory and retry. Tell the user that the memory was not submitted 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.
90
+
91
+ ## Exclusions
92
+
93
+ Do not add secrets, credentials, private URLs, raw authorization headers, exact patches, target commits, hidden tests, target diffs, vulnerability details, exploit steps, copied source, long logs, stack traces, raw transcripts, temporary errors, or facts directly recoverable from current files and git history.
94
+
95
+ Do not add speculation, assistant-only praise, or a current instruction merely because it contains "remember". Return to `SKILL.md` when the content belongs to personal memory or repo memory.
96
+
97
+ ## Output
98
+
99
+ If a successful Add returns `quotaNotice`, or prints it as a quota-reminder line in the default CLI output, present the complete reminder once and prominently before the normal result summary. Do not reduce it to only a percentage or omit its account URL or anonymous-account claim details. A guest reminder may already contain the local Mark ID; present it once as part of the reminder, but do not repeat or separately quote it. Never run `memorax-code account --show-mark-id` for the user or ask for its output. Treat the reminder as user-facing operational output, not coding memory content, and continue the current task.
100
+
101
+ After an add request is accepted, confirm briefly that it was submitted for processing and identify the reusable coding lesson at a high level. If add is disabled or fails, report the issue and continue without bypassing the CLI.
@@ -0,0 +1,106 @@
1
+ # MemoraX Code Coding Memory Search
2
+
3
+ Use these instructions only to search reusable coding memory through `memorax-cli`. Invoke the skill as `$memorax-code` in Codex or `/memorax-code` in Claude Code. In OpenCode, ask the agent to use the `memorax-code` skill by name. Do not route memory operations through the lifecycle-only `memorax-code` CLI. Do not call MemoraX HTTP endpoints directly, print credentials, or edit memory storage by hand.
4
+
5
+ ## Scope
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
+
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.
10
+
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
+
13
+ If a successful Search result reports `workspaceScopeFallbackReason: git_metadata_invalid`, malformed or incomplete metadata inside a direct `.git` directory was downgraded to the normalized local folder scope. Search has already run with the reported `effectiveUserId`. Present its `userNotice` once without pausing the current task or asking the user to repair Git first, then continue with the returned memory and live evidence. 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.
14
+
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.
16
+
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.
18
+
19
+ ## Search Decision
20
+
21
+ Search when prior coding memory may change localization, implementation, review, validation, or explanation. Typical triggers include:
22
+
23
+ - a request for a previous fix, failed approach, coding convention, design decision, or reusable lesson;
24
+ - implementation, review, planning, API, schema, parser, workflow-contract, or migration work where prior project guidance may matter;
25
+ - explicit instructions to follow previous agreements or remembered engineering conventions.
26
+ - a request to recover, verify, or apply prior project discussions, experiment results, saved memory, earlier decisions, previous changes, or historical constraints, unless the needed facts are fully present in the current visible context.
27
+ - a requested action that depends on prior project state, results, fixes, constraints, or plans when the exact evidence needed is not explicitly present in the current user-provided material.
28
+
29
+ Skip search for simple current-code facts, tiny edits, typo fixes, one-shot commands, or behavior directly established by a clear live source. Do not skip merely by saying the current conversation is sufficient or a relevant result was already retrieved; skip only when the current user message, selected text, or nearby visible context fully contains the facts needed for the answer. A nearby summary is sufficient for explaining that summary, but not automatically sufficient for diagnosing a regression, continuing an experiment, reviewing consistency with prior behavior, or claiming a complete historical account. A word such as "previous", "earlier", "remember", or "history" is not enough by itself to search when the visible context already contains the requested prior facts.
30
+
31
+ Do not search merely because a prior result or fix might exist. For an exact calculation from currently available data, or a current screenshot or reproducible symptom with sufficient live evidence, use the current evidence first. Search only when the user request or visible context establishes a concrete historical dependency.
32
+
33
+ Choose the closest coding scene to shape the query:
34
+
35
+ - **Development:** implementation, debugging, refactoring, test repair, build failures, feature work, API design, or migration planning.
36
+ - **Review:** diff, commit, PR, patch, audit, risk assessment, or review-comment handling.
37
+ - **Understanding:** implementation location, module explanation, architecture rationale, or repository comprehension when repo memory is not the requested authority.
38
+
39
+ If the user asks for commit, PR, MR, issue, or repository architecture evidence, return to `SKILL.md` and route to repo memory instead.
40
+
41
+ ## Query Workflow
42
+
43
+ Before searching, identify the user's current action, target, concrete behavior or symptom, and the historical knowledge that could change the next action. When the request is fragmented, derive one narrow working intent from only its explicit target, condition, and requested or implied outcome. Do not add generic security, authorization, concurrency, auditing, reliability, or best-practice concerns unless the request names that boundary or it is necessary to resolve the working intent. Ask one focused question when no actionable intent can be named.
44
+
45
+ Run up to two focused first-round searches before answering or editing: a primary query for the smallest user-facing decision, and a materially different complementary query only when a second independent fact can change the action. Keep one query when the request describes one strongly coupled calculation, diagnosis, ownership question, or lifecycle decision; do not split it merely to create coverage. Run independent first-round searches in parallel by default. If parallel execution encounters a transport, rate-limit, or caller-environment failure, run any remaining searches serially; do not switch solely because a successful search returns an unexpected number of items. After merging the first-round results, run at most one follow-up query only when one named residual gap can change implementation, localization, risk, or validation. Do not use the follow-up merely because results are few, generic, or incomplete.
46
+
47
+ Write each query as one short natural-language question or intent statement, not a keyword list. Derive it from the user's retrieval goal instead of copying or concatenating nouns from the prompt. Follow the user's language for the prose while preserving exact code, API, path, workflow, and project identifiers. Retain at least one distinctive noun phrase from the user's wording as an anchor, together with any explicit negation, time/order, quantity, or scope qualifier. Also retain one stable task entity explicitly established by the current conversation or live code/documentation when it is needed to resolve that anchor or make the target decidable; do not drop it merely because it is absent from the newest fragmented user message. Do not replace an anchor or stable entity with a more abstract mechanism, a more specific implementation guess, or an unverified term. Preserve whether a retained detail is an observed symptom, desired outcome, disputed field or hypothesis, or explicit exclusion; do not turn an observation into a required invariant or replace a named disputed field with a generic reference.
48
+
49
+ Preserve the user's requested answer shape as well as the target: for example, whether a value was introduced by a prior code change, which failed experiments require rerun, how a negative case differs, what source boundary applies, or which existing plan remains current. Encode an explicit exclusion, source boundary, or qualifier such as only, previous, failed, negative, not, latest, or before/after when it changes the answer. Do not turn an imperative, URL, copied log, or full task request into the query verbatim; extract the smallest reusable historical fact that could change the next action. When the user explicitly names several independent deliverables and their respective historical facts could change different next actions, use the existing two-query allowance for complementary coverage: let the primary query cover the central implementation or decision, and let the complementary query cover the separate validation, artifact, reporting, or boundary question. Do not split one tightly coupled task or create a second query merely to enumerate every noun.
50
+
51
+ State a fact-sized relationship that can change the next action: a target under a condition, and the decision, invariant, consequence, root cause, ownership, compatibility, validation question, or requested answer at issue. For behavior, data, and lifecycle work, every query must use this visible shape: `<target>: <condition>,<decision / invariant / consequence / validation question>?`. Keep the colon in both Chinese and English so the target, condition, and decision boundary remain explicit. Do not emit a generic topic, a keyword list, a label such as `primary query`, or an explanation around the query.
52
+
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.
54
+
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 `'\''`.
59
+
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.
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
+
70
+ ```bash
71
+ # One tightly coupled decision: emit one query.
72
+ memorax-cli search --query 'Trace 生产版本:升级后到达的记录中,应以哪个客户端版本字段判断由旧插件产生,而非新版本上传进程?'
73
+ memorax-cli search --query 'Trace producer version: after an upgrade, which client-version field shows that an event came from the old plugin rather than the new uploader?'
74
+
75
+ # Two independent boundaries: emit a complementary pair.
76
+ memorax-cli search --query '任务上下文:升级新包后已打开任务仍按旧提示,是否绑定旧版本且必须新开对话?'
77
+ memorax-cli search --query '包缓存版本冲突:本地新包与缓存冲突时,已打开任务为何仍使用旧提示,如何确认实际加载版本?'
78
+ memorax-cli search --query 'Task context after upgrade: can an already-open task keep old injected context, and must validation use a fresh task?'
79
+ memorax-cli search --query 'Package-cache version collision: how do we confirm which version the active task actually loaded?'
80
+
81
+ # Preserve an explicit lifecycle condition and the required invariant.
82
+ memorax-cli search --query '自动写回:事件回调不等待 Promise 时,如何在消息终态后执行并防止重复?'
83
+ memorax-cli search --query 'Automatic writeback: when an event callback does not await a Promise, how should it run after message terminal state without duplicates?'
84
+
85
+ # Preserve a source boundary rather than turning it into a generic SDK question.
86
+ memorax-cli search --query '桌面 SDK 数据权威:无原生命令行时,应从哪些规范化消息和会话生命周期事件获取数据?'
87
+ memorax-cli search --query 'Desktop SDK authority: without a native CLI, which normalized messages and session lifecycle events are authoritative?'
88
+ ```
89
+
90
+ Keep queries under 25 words when practical for the language, but do not shorten them into ungrammatical fragments. Exclude secrets, private URLs, full prompts, raw transcripts, copied files, long logs, stack traces, and one-off task details.
91
+
92
+ Do not use abstract query facets such as "state", "fix", "safety", or "best practice" unless they are the concrete target. Do not use generic security or safety queries as complementary queries; bind every query to an exact target, condition, and behavior boundary.
93
+
94
+ Merge and deduplicate first-round results by item identity when available, otherwise by matching scope, condition, claim, and consequence. Accept a memory only when all three checks pass: it has the same component, API, workflow, or ownership boundary; it has the same behavior, symptom, condition, or change; and it supplies a condition, conclusion, consequence, fix, or validation idea that can change the current action. Read or summarize at most two accepted direct hits. Prefer memories matching the current repository, module, API, lifecycle surface, ownership boundary, behavior, and failure mode. Treat verified memories as routing and validation hints, not patch recipes. Treat failed-attempt memories as negative evidence. Ignore stale or unrelated items and anything conflicting with current source, tests, or durable documentation. For application questions, reject retrieval-strategy, evaluation, prompting, or workflow-process memories as domain evidence even if they repeat application terms. If no memory passes all three checks, say that memory is insufficient for the requested decision rather than filling the gap with a generic principle.
95
+
96
+ ## Transport Failures
97
+
98
+ If search fails with `fetch failed`, `This operation was aborted`, a timeout, DNS failure, `ENOTFOUND`, `EAI_AGAIN`, or a similar transport or sandbox error, retry the same `memorax-cli search` once in an approved network-enabled execution mode when one is available. Preserve the same query, workspace, and environment variables.
99
+
100
+ Do not apply this retry to `memorax-cli add`, authentication or configuration failures, or HTTP errors. If no approved mode is available or the one retry fails, report the exact CLI failure and continue with live evidence. Do not interpret a transport failure as an empty result, bypass the CLI, or call MemoraX directly.
101
+
102
+ ## Output
103
+
104
+ If a successful Search returns `quotaNotice`, or prints it as a quota-reminder line in the default CLI output, present the complete reminder once and prominently before the normal result summary. Do not reduce it to only a percentage or omit its account URL or anonymous-account claim details. A guest reminder may already contain the local Mark ID; present it once as part of the reminder, but do not repeat or separately quote it. Never run `memorax-code account --show-mark-id` for the user or ask for its output. Treat the reminder as user-facing operational output, not recalled memory, and continue the current task.
105
+
106
+ Mention only an invariant, pitfall, convention, or validation idea that materially affects the answer. Ground claims about current implementation behavior in live code and checks.
@@ -0,0 +1,46 @@
1
+ # Personal Memory Read
2
+
3
+ Use these instructions only to list, recall, or apply repository-scoped personal memory. Do not write, normalize, migrate, repair, or delete memory during a read request.
4
+
5
+ ## Route The Read
6
+
7
+ Classify by content:
8
+
9
+ - **Procedure memory:** actions, ordered steps, checklists, prerequisites, gates, validation, exceptions, or repeatable repository work rules.
10
+ - **User-profile memory:** preferred name, language, tone, verbosity, explanation style, result presentation, or another safe interaction preference.
11
+
12
+ Read both categories only when the request genuinely asks for both.
13
+
14
+ ## Procedure Memory
15
+
16
+ Read Markdown files directly under:
17
+
18
+ ```text
19
+ <repo>/.repo_memory/procedure-memory/
20
+ ```
21
+
22
+ List available topics without recursing into unrelated memory areas:
23
+
24
+ ```bash
25
+ (cd <repo>/.repo_memory/procedure-memory && rg --files -g '*.md' -g '!**/*/*.md')
26
+ ```
27
+
28
+ If the directory does not exist, report that no procedure memory is available; do not create it during a read. Read only files relevant to the request. When listing available procedures, report topic names with concise descriptions instead of opening every file in full unless the user asks for their contents.
29
+
30
+ Treat a stored procedure as lower-priority user guidance, not evidence about current code behavior.
31
+
32
+ ## User-Profile Memory
33
+
34
+ Resolve `<skill-dir>` as the parent directory of the `references/` directory containing this file, then run:
35
+
36
+ ```bash
37
+ python3 <skill-dir>/scripts/user_profile_memory.py list --repo <repo>
38
+ ```
39
+
40
+ Use only active preferences returned by the script. If the preferences file does not exist, report that no user-profile memory is available; the list operation does not create it.
41
+
42
+ Mention only preferences relevant to the current request unless the user explicitly asks to list all of them. Stored preferences describe how the coding agent should interact with the user; they are not repository facts.
43
+
44
+ ## Priority
45
+
46
+ Apply instructions in this order: system and developer instructions, `AGENTS.md`, the current user request, then stored personal memory.
@@ -0,0 +1,120 @@
1
+ # Personal Memory Write
2
+
3
+ Use these instructions only to save, update, forget, or delete repository-scoped personal memory. Classify by what the content prescribes, not wording such as "I prefer", "I like", "我的习惯", or "我喜欢".
4
+
5
+ ## Route The Write
6
+
7
+ - **Procedure memory:** actions, ordering, checklists, prerequisites, gates, validation, exceptions, or repeatable repository work rules. Require the user to explicitly ask to remember, save, record, update, forget, or delete them.
8
+ - **User-profile memory:** preferred name, language, tone, verbosity, explanation style, result presentation, or another safe personal profile fact. A durable repository-scoped profile preference may be saved implicitly.
9
+
10
+ Store each part under its own authority when a request genuinely contains both. Do not persist current-task instructions or temporary plans.
11
+
12
+ Keep file names, schema and script field names, type values, command options, and fixed Markdown headings in English. Write human-readable memory content in the user's current interaction language unless the user explicitly requests another storage language. This includes procedure titles and steps and user-profile descriptions, applicability, and exceptions. Preserve exact code identifiers, commands, paths, API names, and quoted literals without translation.
13
+
14
+ ## Procedure Memory
15
+
16
+ Before writing, ensure the repository root `.gitignore` contains `.repo_memory/`. Store each procedure topic in its own concise kebab-case file directly under:
17
+
18
+ ```text
19
+ <repo>/.repo_memory/procedure-memory/
20
+ ```
21
+
22
+ Do not create a global procedures file, index, event log, generated metadata, or version history. Do not edit `.repo_memory/PROFILE.md`, `.repo_memory/resources/`, `.repo_memory/raw/`, or `.repo_memory/user-profile/`.
23
+
24
+ Choose the closest existing topic file before writing:
25
+
26
+ - New topic: create a file.
27
+ - Addition or refinement to the same topic: update the existing file.
28
+ - A new rule directly conflicts with or replaces an old rule: update the existing file and remove the superseded content.
29
+ - An old rule references a command, file, or workflow that no longer exists: update the invalid part; delete the file if the entire procedure is obsolete.
30
+ - Equivalent content: do not add a duplicate.
31
+ - If it is unclear whether the change is durable or only applies to the current task: ask the user.
32
+
33
+ Do not modify existing memory because of a one-time instruction for the current task. Do not scan or clean up unrelated topics.
34
+
35
+ Use this shape when useful:
36
+
37
+ ```markdown
38
+ # Reviewing Code
39
+
40
+ Use when: reviewing changes in this repository.
41
+
42
+ ## Procedure
43
+
44
+ 1. Review the changes before creating a PR.
45
+ 2. Resolve blocking findings.
46
+ 3. Create the PR only after review is complete.
47
+
48
+ ## Exceptions
49
+
50
+ - Follow a more specific current user instruction first.
51
+ ```
52
+
53
+ Delete only the topic file, section, or step the user explicitly identifies, and preserve unrelated content. Do not retain deleted text in tombstones, backups, inactive entries, or history files. Apply the same rule to superseded text.
54
+
55
+ ## User-Profile Memory
56
+
57
+ Use only:
58
+
59
+ ```text
60
+ <repo>/.repo_memory/user-profile/preferences.md
61
+ ```
62
+
63
+ Resolve `<skill-dir>` as the parent directory of the `references/` directory containing this file. The script owns directory creation, `.gitignore` updates, parsing, normalization, locking, duplicate detection, counts, and deterministic rewriting. Do not hand-edit `preferences.md` except when diagnosing a script failure.
64
+
65
+ List existing preferences before adding and perform semantic matching:
66
+
67
+ ```bash
68
+ python3 <skill-dir>/scripts/user_profile_memory.py list --repo <repo>
69
+ ```
70
+
71
+ Handle the semantic match before writing:
72
+
73
+ - New preference: add a new preference.
74
+ - Equivalent content: do not add a duplicate.
75
+ - Addition or refinement to the same preference: update the existing preference.
76
+ - A new preference directly conflicts with or replaces an old preference in the same scope: update the existing id and remove the superseded content.
77
+ - The user explicitly says a preference no longer applies: delete that preference.
78
+ - Its `Applies when` environment, tool, or workflow no longer exists: update the scope; delete it if the entire preference is obsolete.
79
+
80
+ Do not modify or delete existing preferences because of a one-time instruction for the current task. Do not scan or clean up unrelated preferences.
81
+
82
+ Use the matching id for updates. Add only a genuinely new preference:
83
+
84
+ ```bash
85
+ python3 <skill-dir>/scripts/user_profile_memory.py add \
86
+ --repo <repo> \
87
+ --type communication \
88
+ --description "User prefers concise Chinese answers for this repository." \
89
+ --applies-when "Answering questions in this repository." \
90
+ --do-not-apply-when "The user explicitly requests another language or format."
91
+ ```
92
+
93
+ Allowed script types are `communication`, `workflow`, `environment`, and `profile`. These type names do not expand this authority: never use `workflow` or `environment` to store an executable repository procedure.
94
+
95
+ Update a clearly identified preference in place:
96
+
97
+ ```bash
98
+ python3 <skill-dir>/scripts/user_profile_memory.py update \
99
+ --repo <repo> \
100
+ --id <preference-id> \
101
+ --description <current-description> \
102
+ --applies-when <current-scope> \
103
+ --do-not-apply-when <exception>
104
+ ```
105
+
106
+ If multiple preferences may match, or it is unclear whether the change is durable, ask the user. Delete only an explicitly identified preference:
107
+
108
+ ```bash
109
+ python3 <skill-dir>/scripts/user_profile_memory.py delete \
110
+ --repo <repo> \
111
+ --id <preference-id>
112
+ ```
113
+
114
+ For delete-all requests, list active preferences and delete each id. Do not preserve deleted text elsewhere.
115
+
116
+ ## Safety And Output
117
+
118
+ Do not store secrets, tokens, credentials, `.env` content, sensitive personal data, repository facts, code history, design rationale, one-off task details, raw transcripts, hidden tests, exact patches, raw diffs, target commits, or unsafe destructive commands.
119
+
120
+ After a successful write, update, or deletion, identify the affected topic or preference briefly and confirm that it is local to the current repository.