@memorax/memorax-code 0.1.9 → 0.1.10

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 (101) hide show
  1. package/README.md +10 -0
  2. package/bin/memorax-code-codebuddy.mjs +4 -0
  3. package/bin/memorax-code-setup.mjs +182 -65
  4. package/bin/memorax-code.mjs +74 -45
  5. package/docs/configuration.md +82 -22
  6. package/docs/troubleshooting.md +69 -5
  7. package/lib/automatic-update.mjs +233 -0
  8. package/lib/memorax-code-adapter-common/src/automatic-update-state.d.mts +24 -0
  9. package/lib/memorax-code-adapter-common/src/automatic-update-state.mjs +73 -0
  10. package/lib/memorax-code-adapter-common/src/clients/codebuddy-command.mjs +82 -0
  11. package/lib/memorax-code-adapter-common/src/config-utils.d.mts +2 -0
  12. package/lib/memorax-code-adapter-common/src/config-utils.mjs +11 -0
  13. package/lib/memorax-code-adapter-common/src/hooks/client-hook-launcher.mjs +3 -0
  14. package/lib/memorax-code-adapter-common/src/hooks/ensure-backend-runner.mjs +45 -10
  15. package/lib/memorax-code-adapter-common/src/repo-memory/repo-memory-job-worker.mjs +88 -3
  16. package/lib/memorax-code-adapter-common/src/windows-cli-invocation.mjs +11 -1
  17. package/lib/memorax-code-backend/dist/app/backend-server.js +2 -2
  18. package/lib/memorax-code-backend/dist/app/memory-observability.js +2 -2
  19. package/lib/memorax-code-backend/dist/clients/codebuddy/jsonl-history.js +208 -0
  20. package/lib/memorax-code-backend/dist/clients/codebuddy/lifecycle.js +44 -0
  21. package/lib/memorax-code-backend/dist/clients/codebuddy/memory-hook-runtime.js +250 -0
  22. package/lib/memorax-code-backend/dist/clients/codebuddy/turn-id.js +16 -0
  23. package/lib/memorax-code-backend/dist/clients/codex/plugin-install.js +129 -7
  24. package/lib/memorax-code-backend/dist/config/memorax-code.js +14 -1
  25. package/lib/memorax-code-backend/dist/entrypoints/backend-cli.js +43 -6
  26. package/lib/memorax-code-backend/dist/lifecycle/active-clients.js +3 -0
  27. package/lib/memorax-code-backend/dist/lifecycle/automatic-update-scheduler.js +133 -0
  28. package/lib/memorax-code-backend/dist/lifecycle/client-plugin-removal.js +14 -2
  29. package/lib/memorax-code-backend/dist/lifecycle/client-selection.js +6 -4
  30. package/lib/memorax-code-backend/dist/lifecycle/orchestrator.js +48 -9
  31. package/lib/memorax-code-backend/dist/memory/cli.js +4 -2
  32. package/lib/memorax-code-backend/dist/memory/hook-command.js +31 -1
  33. package/lib/memorax-code-backend/dist/memory/reminder-trace-recorder.js +5 -1
  34. package/lib/memorax-code-backend/dist/memory/service.js +12 -0
  35. package/lib/memorax-code-backend/dist/shared/windows-cli-invocation.js +10 -1
  36. package/lib/memorax-code-backend/dist/trace/config.js +12 -0
  37. package/lib/memorax-code-backend/dist/trace/context.js +21 -1
  38. package/lib/memorax-code-backend/dist/trace/store.js +12 -1
  39. package/lib/memorax-code-backend/package.json +1 -1
  40. package/lib/memorax-code-claude-adapter/.claude-plugin/plugin.json +1 -1
  41. package/lib/memorax-code-claude-adapter/hooks/runtime-shell.json +1 -1
  42. package/lib/memorax-code-claude-adapter/package.json +1 -1
  43. package/lib/memorax-code-claude-adapter/runtime-hooks/ensure-backend.mjs +2 -0
  44. package/lib/memorax-code-claude-adapter/src/plugin-install.mjs +3 -0
  45. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/.claude-plugin/plugin.json +1 -1
  46. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/hooks/runtime-shell.json +1 -1
  47. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/automatic-update-state.d.mts +24 -0
  48. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/automatic-update-state.mjs +73 -0
  49. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/clients/codebuddy-command.mjs +82 -0
  50. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/config-utils.d.mts +2 -0
  51. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/config-utils.mjs +11 -0
  52. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/hooks/client-hook-launcher.mjs +3 -0
  53. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/hooks/ensure-backend-runner.mjs +45 -10
  54. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/repo-memory/repo-memory-job-worker.mjs +88 -3
  55. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/windows-cli-invocation.mjs +11 -1
  56. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/package.json +1 -1
  57. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/runtime-hooks/ensure-backend.mjs +2 -0
  58. package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/src/plugin-install.mjs +3 -0
  59. package/lib/memorax-code-codebuddy-adapter/.codebuddy-plugin/plugin.json +7 -0
  60. package/lib/memorax-code-codebuddy-adapter/hooks/common-runtime.mjs +13 -0
  61. package/lib/memorax-code-codebuddy-adapter/hooks/hooks.json +38 -0
  62. package/lib/memorax-code-codebuddy-adapter/hooks/repo-memory-job.mjs +40 -0
  63. package/lib/memorax-code-codebuddy-adapter/hooks/runtime-hook.mjs +279 -0
  64. package/lib/memorax-code-codebuddy-adapter/package.json +9 -0
  65. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/SKILL.md +85 -0
  66. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/agents/claude.yaml +10 -0
  67. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/agents/openai.yaml +7 -0
  68. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/defaults.json +12 -0
  69. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/memorax-add.md +88 -0
  70. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/memorax-search.md +93 -0
  71. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/personal-read.md +46 -0
  72. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/personal-write.md +120 -0
  73. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/repo-build.md +319 -0
  74. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/repo-read.md +103 -0
  75. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/repo-templates.md +390 -0
  76. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/references/repo-update.md +127 -0
  77. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/scripts/collect_all.py +579 -0
  78. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/scripts/detect_updates.py +919 -0
  79. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/scripts/git_commit_facets.py +222 -0
  80. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/scripts/github_resource_facets.py +512 -0
  81. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/scripts/gitlab_resource_facets.py +517 -0
  82. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/scripts/prepare_repo_memory.py +411 -0
  83. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/scripts/user_profile_memory.py +528 -0
  84. package/lib/memorax-code-codebuddy-adapter/skills/memorax-code/scripts/validate_memory.py +248 -0
  85. package/lib/memorax-code-codebuddy-adapter/src/cli.mjs +58 -0
  86. package/lib/memorax-code-codebuddy-adapter/src/config.mjs +277 -0
  87. package/lib/memorax-code-codebuddy-adapter/src/hook-manifest.mjs +47 -0
  88. package/lib/memorax-code-codebuddy-adapter/src/runtime-observation.mjs +65 -0
  89. package/lib/memorax-code-codex-adapter/.codex-plugin/plugin.json +1 -1
  90. package/lib/memorax-code-codex-adapter/hooks/runtime-shell.json +1 -1
  91. package/lib/memorax-code-codex-adapter/package.json +1 -1
  92. package/lib/memorax-code-codex-adapter/runtime-hooks/ensure-backend.mjs +4 -1
  93. package/lib/memorax-code-dsh-adapter/package.json +2 -1
  94. package/lib/memorax-code-dsh-adapter/src/profile-lifecycle.mjs +1 -0
  95. package/lib/memorax-code-opencode-adapter/package.json +1 -1
  96. package/lib/npm-invocation.mjs +51 -8
  97. package/lib/resolve-codebuddy-command.mjs +112 -0
  98. package/lib/run-entrypoint.mjs +25 -1
  99. package/lib/windows-cli-invocation.mjs +11 -1
  100. package/lib/windows-user-path.mjs +218 -0
  101. package/package.json +5 -3
@@ -0,0 +1,390 @@
1
+ # Repo Memory Authoring Templates
2
+
3
+ Use these templates as fill-in scaffolds. Replace all bracketed placeholders with conclusions from local code inspection and raw facets. Remove sections that are genuinely unavailable; do not leave placeholders in final files.
4
+
5
+ ### `.repo_memory/PROFILE.md`
6
+
7
+ `PROFILE.md` is the only fixed conceptual wiki file. It is a wiki landing page, not a dense resource index. It should read like a wiki-style repository memory home page: concise project identity, first-use path, major areas, supporting pages, and historical/provider pointers. Keep MemoraX frontmatter so the validator and maintenance hooks can still trust the bundle.
8
+
9
+ ```markdown
10
+ ---
11
+ schema: "repo_memory_profile.v0.2"
12
+ layout: "wiki_landing_page.v0.1"
13
+ disclosure_model: "progressive_wiki"
14
+ repo_name: "[repo name]"
15
+ repo_owner: "[owner or empty]"
16
+ repo_full_name: "[owner/name or empty]"
17
+ repo_url: "[remote URL or empty]"
18
+ code_host_provider: "github|gitlab|none"
19
+ source_repo_path: "[absolute repo path]"
20
+ generated_at: "[ISO timestamp]"
21
+ build_mode: "lightweight|deep"
22
+ local_head: "[git HEAD]"
23
+ local_branch: "[branch or detached HEAD]"
24
+ working_tree_state: "clean|dirty|unknown"
25
+ trust_state: "draft"
26
+ code_host_resource_state: "available|unavailable|partial"
27
+ resources:
28
+ commits: "resources/commits.md"
29
+ prs: "resources/prs.md"
30
+ issues: "resources/issues.md"
31
+ raw:
32
+ prepare_report: "raw/prepare-report.json"
33
+ commit_facets: "raw/git-commits.json"
34
+ provider_facets: "raw/github-facets.json|raw/gitlab-facets.json|"
35
+ ---
36
+
37
+ # [Repo Name] Repository Wiki
38
+
39
+ [One short paragraph explaining what this repository is, who uses it, and the primary runtime/package/product surface. Ground this in inspected docs or source.]
40
+
41
+ - Repository: `[owner/name or local repo]`
42
+ - Local HEAD when prepared: `[sha]` on `[branch]`
43
+ - Build mode: `[lightweight|deep]`; working tree was `[clean/dirty + explanation]`
44
+ - License: `[license if known]`
45
+
46
+ ## What This Repo Contains
47
+
48
+ | Area | What it does |
49
+ |------|--------------|
50
+ | `[repo-native product/module/workflow name]` (`path/`) | [Plain-language responsibility and primary entrypoint.] |
51
+ | `[repo-native product/module/workflow name]` (`path/`) | [Plain-language responsibility and primary entrypoint.] |
52
+
53
+ ## How It Works
54
+
55
+ [Five to ten sentences describing the main runtime/build/request/data flow. Link to supporting pages instead of explaining every detail here. Use conservative wording when lightweight mode did not inspect representative source.]
56
+
57
+ ## First-Use Path
58
+
59
+ ```bash
60
+ [install or setup command]
61
+ [one fast verification or smoke command]
62
+ ```
63
+
64
+ [Explain the shortest safe path a future agent should use to orient, build, test, or run the project.]
65
+
66
+ ## Major Areas
67
+
68
+ Choose these rows from `.repo_memory/_plan.md` after clustering inspected docs/source paths. Do not assume fixed page names; generic names are fallback names only when repository vocabulary gives no stronger topic.
69
+
70
+ | Area | Page | What It Covers |
71
+ |------|------|----------------|
72
+ | `[repo-native area name]` | [`[human page title]`](./repo-native-topic.md) | [What task cluster this page routes and why it is a canonical home.] |
73
+ | `[repo-native area name]` | [`[human page title]`](./repo-native-topic.md) | [What task cluster this page routes and why it is a canonical home.] |
74
+
75
+ ## Supporting Pages
76
+
77
+ - [`[human page title]`](./repo-native-topic.md) - open when [task cue, change surface, workflow, or risk].
78
+ - [`[human page title]`](./another-repo-native-topic.md) - open when [task cue, change surface, workflow, or risk].
79
+
80
+ ## Agent Consumption Rules
81
+
82
+ 1. Read this file first, then open only the supporting page relevant to the task. Memory is a map, not proof.
83
+ 2. Verify current behavior against live source, configs, tests, or executable checks before editing or making strong claims.
84
+ 3. Treat commits, PRs/MRs, and issues as historical routing context; they do not prove current checkout behavior.
85
+ 4. Prefer source paths and commands linked from supporting pages over broad repository scanning.
86
+
87
+ ## Coding Memory Boundary
88
+
89
+ This repo memory is a cold-start repository map presented as a repository wiki. Use it for module routing, architecture boundaries, verification gates, historical PR/issue context, and repository-specific conventions.
90
+
91
+ Runtime coding memory is narrower and should take precedence when it matches the current repo, module, API, behavior, lifecycle surface, ownership boundary, or failure mode. Use runtime coding memory for verified repair invariants, failed-attempt evidence, mutable-state ownership, callback/hook boundaries, adapter behavior, validation contracts, and other task-learned engineering lessons.
92
+
93
+ Do not treat repo memory, commits, PRs, or issues as implementation recipes. They are routing evidence and historical context. Always verify current behavior against live source and focused checks before editing.
94
+
95
+ ## Provider Context
96
+
97
+ - [Historical commits](./resources/commits.md) - local checkout history and regression routing.
98
+ - [Historical PRs/MRs](./resources/prs.md) - implementation context from provider facets when available.
99
+ - [Historical issues](./resources/issues.md) - user/request/problem context when available.
100
+ - Raw local commit facets: `./raw/git-commits.json`.
101
+ - Raw code-host facets: `./raw/github-facets.json` or `./raw/gitlab-facets.json` when present.
102
+
103
+ ## Evidence Inspected
104
+
105
+ - Root docs and agent instructions: `[README/docs/AGENTS.md/CLAUDE.md or similar files inspected]`.
106
+ - Module docs: `[module README/docs inspected]`.
107
+ - Representative source: `[important source/entrypoint files inspected, or 'not inspected in lightweight mode']`.
108
+ - Manifests/scripts/CI: `[manifests, scripts, workflows inspected, or 'not inspected in lightweight mode']`.
109
+ - Local commit snapshot: `[raw/git-commits.json status and count]`.
110
+ - Historical code-host snapshot: `[raw/github-facets.json or raw/gitlab-facets.json status and counts]`.
111
+ ```
112
+
113
+ ### `.repo_memory/_plan.md`
114
+
115
+ Create this temporary planning artifact after discovery and before final wiki writing. Use it to cluster repository concepts and choose natural page boundaries. Remove `_plan.md` before final validation; it is not part of the durable bundle.
116
+
117
+ ```markdown
118
+ # Repo Memory Wiki Plan
119
+
120
+ ## Candidate Domains Considered
121
+
122
+ - [selected, merged, or skipped candidate domain] - [source evidence and decision].
123
+
124
+ ## Intended Final Pages
125
+
126
+ | Page | Purpose | Source evidence | Boundary |
127
+ |------|---------|-----------------|----------|
128
+ | `repo-native-topic.md` | [Future-agent task this page routes.] | [Docs/source/tests/scripts inspected.] | [What belongs here and what belongs elsewhere.] |
129
+
130
+ ## Canonical Homes And Overlaps
131
+
132
+ - [Overlapping concept] belongs in `[page]`; link from `[other page]` instead of duplicating because [reason].
133
+
134
+ ## Weak Evidence And Verification Needs
135
+
136
+ - [Claim/path/command] needs [specific verification] before final writing, or should be omitted.
137
+ ```
138
+
139
+ ### `.repo_memory/<repo-native-topic>.md`
140
+
141
+ Create supporting conceptual pages after clustering inspected evidence. Name pages from repository vocabulary, not from this template. Use lowercase kebab-case filenames derived from product surfaces, runtime components, commands, protocols, adapters, workflows, data models, operations, or other durable repository concepts. Generic names are fallback names only when repository vocabulary gives no stronger topic. Every conceptual page must include frontmatter so validation can scan it.
142
+
143
+ ```markdown
144
+ ---
145
+ schema: "repo_memory_wiki_page.v0.1"
146
+ page_type: "architecture|workflow|data-model|integration|operation|testing|extension|domain"
147
+ generated_at: "[ISO timestamp]"
148
+ source_profile: "PROFILE.md"
149
+ trust_state: "draft_wiki_page"
150
+ ---
151
+
152
+ # [Human Documentation Title]
153
+
154
+ ## Purpose
155
+
156
+ [Explain which future tasks should open this page and what decisions it helps route.]
157
+
158
+ ## Key Paths
159
+
160
+ | Path | Responsibility | When to inspect |
161
+ |------|----------------|-----------------|
162
+ | `path/to/file-or-dir` | [What it owns.] | [Task cue, symbol, command, or failure mode.] |
163
+
164
+ ## Flow Or Boundaries
165
+
166
+ [Explain the concept, lifecycle, dependency direction, or ownership boundary. Prefer short paragraphs and bullets over exhaustive API reference.]
167
+
168
+ ## Verification
169
+
170
+ - [Fast command or source check relevant to this page.]
171
+ - [Expensive or environment-dependent check, or say none identified.]
172
+
173
+ ## Agent Notes
174
+
175
+ - Treat this page as routing context and verify current behavior in live source before editing.
176
+ - [One repo-specific caution, extension rule, or likely pitfall.]
177
+ ```
178
+
179
+ ### `.repo_memory/resources/commits.md`
180
+
181
+ Use fixed-field sections, not Markdown tables. Every commit needs a search-grade `Description` following the standard in `SKILL.md`. Do not paste the full raw summary; full raw summaries stay in `../raw/git-commits.json`.
182
+
183
+ ```markdown
184
+ ---
185
+ schema: "repo_memory_commit_resource.v0.1"
186
+ repo_full_name: "[owner/name or local repo name]"
187
+ generated_at: "[ISO timestamp]"
188
+ source: "git_commit_facets"
189
+ resource_count: [count]
190
+ trust_state: "draft_resource"
191
+ raw_source: "../raw/git-commits.json"
192
+ ---
193
+
194
+ # Commit Resource Snapshot
195
+
196
+ Source: `.repo_memory/raw/git-commits.json`. Treat commits as local checkout history only: they are useful routing evidence, but current-code verification is still required.
197
+
198
+ ## Commit [short_sha]: [title]
199
+
200
+ - SHA: `[full sha]`
201
+ - Evidence status: [One short sentence describing local-history evidence strength and whether current source was verified.]
202
+ - Author: `[author name]`
203
+ - Authored: `[ISO timestamp]`
204
+ - Modules: `[semantic modules for human routing]`
205
+ - Path modules: `[path prefixes from raw facets or current inspection]`
206
+ - Description: [2-4 search-grade sentences: what this commit changes, when future agents should open it, affected modules/files/runtime behavior, search cues, and evidence strength]
207
+ - Key files: `[path/a.py]`, `[path/b.md]`
208
+ - Diff: `[changed_files] files, +[additions]/-[deletions]`
209
+ - Parent count: `[count]`
210
+ - Agent note: [how future agents should treat this commit]
211
+ - Raw lookup: `facetId=commit.abc1234`
212
+
213
+ ---
214
+
215
+ ## Commit [short_sha]: [title]
216
+
217
+ - SHA: `...`
218
+ - Evidence status: ...
219
+ - Author: `...`
220
+ - Authored: `...`
221
+ - Modules: `...`
222
+ - Path modules: `...`
223
+ - Description: ...
224
+ - Key files: ...
225
+ - Diff: ...
226
+ - Parent count: ...
227
+ - Agent note: ...
228
+ - Raw lookup: `facetId=commit.abc1234`
229
+ ```
230
+
231
+ When commit history is disabled by policy, still write a disabled resource file:
232
+
233
+ ```markdown
234
+ ---
235
+ schema: "repo_memory_commit_resource.v0.1"
236
+ repo_full_name: "[owner/name or local repo name]"
237
+ generated_at: "[ISO timestamp]"
238
+ source: "history_disabled"
239
+ resource_count: 0
240
+ trust_state: "disabled_by_policy"
241
+ raw_source: ""
242
+ ---
243
+
244
+ # Commit Resource Snapshot
245
+
246
+ No commit evidence was collected because historical evidence was disabled for this build. This is a collection-policy statement, not proof that the repository has no commits.
247
+ ```
248
+
249
+ ### `.repo_memory/resources/prs.md`
250
+
251
+ Use fixed-field sections, not Markdown tables. Every GitHub PR or GitLab MR needs a search-grade `Description` following the standard in `SKILL.md`. Do not paste the full raw summary; full raw summaries stay in `../raw/github-facets.json` or `../raw/gitlab-facets.json`.
252
+
253
+ ```markdown
254
+ ---
255
+ schema: "repo_memory_pr_resource.v0.1"
256
+ repo_full_name: "[owner/name]"
257
+ generated_at: "[ISO timestamp]"
258
+ source: "github_resource_facets|gitlab_resource_facets"
259
+ resource_count: [count]
260
+ trust_state: "draft_resource"
261
+ raw_source: "../raw/github-facets.json|../raw/gitlab-facets.json"
262
+ ---
263
+
264
+ # Pull Request Resource Snapshot
265
+
266
+ Source: `.repo_memory/raw/github-facets.json` or `.repo_memory/raw/gitlab-facets.json`. Treat PRs/MRs as historical context only: merged PRs/MRs still require current-code verification, open PRs/MRs are branch intent, and closed-unmerged PRs/MRs are weak evidence.
267
+
268
+ ## PR/MR #[number]: [title]
269
+
270
+ - State: `MERGED|OPEN|CLOSED` [include draft if applicable]
271
+ - Evidence status: [One short sentence describing historical/current relevance and whether current source was verified.]
272
+ - Branch: `base <- head`
273
+ - Modules: `[semantic modules for human routing]`
274
+ - Path modules: `[path prefixes from raw facets or current inspection]`
275
+ - Description: [2-4 search-grade sentences: what this PR explains, when future agents should open it, affected modules/files/runtime behavior, search cues, and evidence strength]
276
+ - Key files: `[path/a.py]`, `[path/b.md]`
277
+ - Diff: `[changed_files] files, +[additions]/-[deletions]`
278
+ - Linked issues: `#[issue]` or `-`
279
+ - Commit signal: [1-3 commit headlines or `-`]
280
+ - Agent note: [how future agents should treat this PR]
281
+ - URL: [PR URL]
282
+ - Raw lookup: use `facetId=pr.123` for GitHub PRs or `facetId=mr.123` for GitLab MRs.
283
+
284
+ ---
285
+
286
+ ## PR/MR #[number]: [title]
287
+
288
+ - State: `...`
289
+ - Evidence status: ...
290
+ - Branch: `...`
291
+ - Modules: `...`
292
+ - Path modules: `...`
293
+ - Description: ...
294
+ - Key files: ...
295
+ - Diff: ...
296
+ - Linked issues: ...
297
+ - Commit signal: ...
298
+ - Agent note: ...
299
+ - URL: ...
300
+ - Raw lookup: use `facetId=pr.123` for GitHub PRs or `facetId=mr.123` for GitLab MRs.
301
+ ```
302
+
303
+ ### `.repo_memory/resources/issues.md`
304
+
305
+ Use fixed-field sections, not Markdown tables. Every issue needs a search-grade `Description` following the standard in `SKILL.md`. Keep evidence compact; full raw summaries stay in `../raw/github-facets.json` or `../raw/gitlab-facets.json`.
306
+
307
+ ```markdown
308
+ ---
309
+ schema: "repo_memory_issue_resource.v0.1"
310
+ repo_full_name: "[owner/name]"
311
+ generated_at: "[ISO timestamp]"
312
+ source: "github_resource_facets|gitlab_resource_facets"
313
+ resource_count: [count]
314
+ trust_state: "draft_resource"
315
+ raw_source: "../raw/github-facets.json|../raw/gitlab-facets.json"
316
+ ---
317
+
318
+ # Issue Resource Snapshot
319
+
320
+ Source: `.repo_memory/raw/github-facets.json` or `.repo_memory/raw/gitlab-facets.json`. Treat issues as requirement, bug, support, or planning context; verify against current code before acting.
321
+
322
+ ## Issue #[number]: [title]
323
+
324
+ - State: `OPEN|CLOSED`
325
+ - Evidence status: [One short sentence describing issue evidence strength, relevance, and whether current source was verified.]
326
+ - Modules: `[semantic modules for human routing]`
327
+ - Path modules: `[path prefixes from linked PR facets or current inspection, or -]`
328
+ - Description: [2-4 search-grade sentences: what user problem/request this issue explains, when future agents should open it, affected behavior/modules, symptoms/errors, search cues, and evidence strength]
329
+ - Evidence: [short evidence: label, error, user pain point, requirement, or theme]
330
+ - Linked PRs: `#[pr]` or `-`
331
+ - Linked branches: `base <- head` or `-`
332
+ - Agent note: [how future agents should use this issue]
333
+ - URL: [Issue URL]
334
+ - Raw lookup: `facetId=issue.123`
335
+
336
+ ---
337
+
338
+ ## Issue #[number]: [title]
339
+
340
+ - State: `...`
341
+ - Modules: `...`
342
+ - Path modules: `...`
343
+ - Description: ...
344
+ - Evidence: ...
345
+ - Linked PRs: ...
346
+ - Linked branches: ...
347
+ - Agent note: ...
348
+ - URL: ...
349
+ - Raw lookup: `facetId=issue.123`
350
+ ```
351
+
352
+ ### Disabled Or Unavailable Resource Files
353
+
354
+ Use this pattern when historical evidence or provider evidence was intentionally not collected, unavailable, or degraded to local-only. Keep `resource_count: 0` and `raw_source: ""`; do not fabricate PRs, MRs, issues, or raw provider evidence. Use `source: "history_disabled"` when the entire history channel is disabled, `source: "provider_skipped_local_only"` when provider collection was skipped for a local-only build, and `source: "provider_unavailable"` when provider collection could not be completed.
355
+
356
+ For PR/MR resources:
357
+
358
+ ```markdown
359
+ ---
360
+ schema: "repo_memory_pr_resource.v0.1"
361
+ repo_full_name: "[owner/name or local repo name]"
362
+ generated_at: "[ISO timestamp]"
363
+ source: "provider_skipped_local_only|provider_unavailable|history_disabled"
364
+ resource_count: 0
365
+ trust_state: "unavailable_local_only|disabled_by_policy"
366
+ raw_source: ""
367
+ ---
368
+
369
+ # Pull Request Resource Snapshot
370
+
371
+ No provider evidence was collected for PRs/MRs in this build. This means PR/MR history is unavailable in the memory bundle; it does not mean the repository has no PRs or MRs.
372
+ ```
373
+
374
+ For issue resources:
375
+
376
+ ```markdown
377
+ ---
378
+ schema: "repo_memory_issue_resource.v0.1"
379
+ repo_full_name: "[owner/name or local repo name]"
380
+ generated_at: "[ISO timestamp]"
381
+ source: "provider_skipped_local_only|provider_unavailable|history_disabled"
382
+ resource_count: 0
383
+ trust_state: "unavailable_local_only|disabled_by_policy"
384
+ raw_source: ""
385
+ ---
386
+
387
+ # Issue Resource Snapshot
388
+
389
+ No provider evidence was collected for issues in this build. This means issue history is unavailable in the memory bundle; it does not mean the repository has no issues.
390
+ ```
@@ -0,0 +1,127 @@
1
+ # Repo Memory Update
2
+
3
+ ## Core Principle
4
+
5
+ Update existing repo memory from a delta, not a full rebuild. Treat the current `.repo_memory/` bundle as the baseline, follow the effective history policy, detect only the enabled local commit and provider PR/MR/issue changes, then edit only the affected resources.
6
+
7
+ Do not rebuild the whole bundle by default. Return to `SKILL.md` and use `repo-build.md` only when `.repo_memory/PROFILE.md` is missing, the existing memory is structurally unusable, or the user explicitly asks for a full rebuild.
8
+
9
+ This is the incremental updater, not the daily reader. Use `repo-read.md` for task-time search over existing memory. Use `repo-build.md` for first-time creation, full rebuild flows, or full refresh work that should rerun builder collection with `collect_all.py --reuse`.
10
+
11
+ ## Prerequisite
12
+
13
+ The user selects a repository, not a memory directory. Derive the memory path as `<repo>/.repo_memory`.
14
+
15
+ Require:
16
+
17
+ - `<repo>` is a local git repository;
18
+ - `<repo>/.repo_memory/PROFILE.md` exists;
19
+ - existing `PROFILE.md` and `resources/*.md` are treated as the baseline.
20
+
21
+ If `.repo_memory/PROFILE.md` is missing, stop and route to `repo-build.md`; do not fabricate an incremental baseline from live files alone.
22
+
23
+ ## Path Convention
24
+
25
+ `<skill-dir>` means the parent directory of the `references/` directory containing this file.
26
+
27
+ ## Default Settings
28
+
29
+ Updater uses `<skill-dir>/defaults.json` so build and update operations stay aligned. It reads `repoHistory.mode`, `repoHistory.limits.prs`, `repoHistory.limits.issues`, and `summaryChars`, with compatibility fallback to legacy `limits.prs` and `limits.issues`; local commit deltas are not limit-capped because they are computed from the stored baseline commit to current `HEAD` when commit history is enabled.
30
+
31
+ Override one updater run with `--history-mode`, `--pr-limit`, `--issue-limit`, or `--summary-chars`. Do not edit `defaults.json` for a one-run updater request.
32
+
33
+ History policy modes:
34
+
35
+ - `none`: skip local commit deltas and provider PR/MR/issue deltas.
36
+ - `commits-only` or `local-only`: detect local commit deltas and skip provider PR/MR/issue deltas.
37
+ - `provider`: detect local commit deltas and fetch provider PR/MR/issue deltas when provider evidence is ready.
38
+ - `provider-required`: detect local commit deltas and require provider PR/MR/issue evidence rather than silently authoring provider resources without evidence.
39
+
40
+ Do not re-enable commit or provider channels disabled by policy. Use the detector's `effective_settings.history` block as the authority for which history channels are enabled.
41
+
42
+ ## User Count Requests
43
+
44
+ If the user says how many PRs/MRs or issues to compare, pass explicit one-run flags:
45
+
46
+ - "PR 拉 20 条" means add `--pr-limit 20`.
47
+ - "issue 拉 30 条" means add `--issue-limit 30`.
48
+ - "PR 和 issue 都拉 50 条" means add `--pr-limit 50 --issue-limit 50`.
49
+
50
+ Only change `<skill-dir>/defaults.json` when the user asks to change future default behavior.
51
+
52
+ ## Detection
53
+
54
+ Start every updater run by detecting deltas:
55
+
56
+ ```bash
57
+ python3 <skill-dir>/scripts/detect_updates.py \
58
+ --repo-path <repo-path> \
59
+ --pretty
60
+ ```
61
+
62
+ The detector:
63
+
64
+ - reads the effective history policy from `repoHistory.mode` and reports it in `effective_settings.history`;
65
+ - reads the commit baseline from `PROFILE.md` `local_head`, with a fallback to the nearest stored ancestor commit in `resources/commits.md`;
66
+ - reads PR/MR and issue baselines from `resources/prs.md` and `resources/issues.md`, enriched by existing raw provider facets when available;
67
+ - compares local git `HEAD` against the newest stored commit only when commit history is enabled;
68
+ - reports `local_commit_status.status: "skipped"` with `reason: "history_disabled_by_policy"` when `repoHistory.mode` disables commit history;
69
+ - reports `local_commit_status.status: "skipped"` with `reason: "missing_baseline_commit"` when no stored local commit baseline can be found;
70
+ - reports `local_commit_status.status: "skipped"` with `reason: "baseline_not_ancestor_of_head"` when history was rebased or force-pushed, instead of silently returning no commit delta;
71
+ - detects provider state from live git remotes and provider CLIs only when provider history is enabled;
72
+ - fetches bounded latest GitHub/GitLab PR/MR/issue facets only when provider history is enabled and provider evidence is available;
73
+ - reports added or changed PR/MR/issue numbers without editing memory files;
74
+ - reports provider items missing from the current bounded window as `baseline_only_numbers`, not as deletions.
75
+
76
+ Warnings such as rewritten commit baselines or provider fetch failures are returned as structured `notices[]` with `render_as: "assistant_message"`. Show these notices to the user as normal assistant messages; do not bury them in terminal output.
77
+
78
+ When provider fetch succeeds, the report includes fetched authoring evidence under `current.provider_items.pull_requests` and `current.provider_items.issues`. Use those facets, plus existing raw/provider resources when needed, to write or replace search-grade sections; do not author provider sections from number-only deltas.
79
+
80
+ The report also includes `builder_helpers` fingerprints for the sibling builder files that updater depends on, including `path`, `exists`, `mtime_ns`, and `size_bytes`. Use this only for compatibility diagnostics; it is not evidence for authoring repo-memory resources.
81
+
82
+ Use `--history-mode local-only` or `--history-mode none` when the user requests a one-run history-policy override. `--provider-mode off` remains supported as a compatibility provider-only override when provider access is intentionally unavailable.
83
+
84
+ ## Provider Sandbox and Transport Failures
85
+
86
+ `gh/glab` provider delta detection needs external network access. If `current.provider_fetch.ok` is false, or notice/stderr shows `fetch failed`, timeout, DNS, connection, TLS, `ENOTFOUND`, `EAI_AGAIN`, or similar transport text, show `Provider Delta Fetch Failed`, keep existing PR/MR/issue resources unchanged, and continue only with safe local commit updates.
87
+
88
+ Verify provider authentication in the same normal shell with the command reported by `detect_updates.py`; for GitHub Enterprise or self-hosted GitLab this may include `--hostname <host>`. Authenticate with `gh auth login` or `glab auth login` (also host-scoped when prompted), then rerun `detect_updates.py`; do not paste tokens into the skill or call provider APIs directly.
89
+
90
+ Do not use a restricted shell sandbox to verify provider/API availability. Verify in a normal shell or approved network-enabled mode before editing provider resources. If only restricted shell access is available, keep existing PR/MR/issue resources unchanged and continue only with safe local commit updates. Do not treat provider fetch failure as no PR/issue delta, empty provider evidence, bad login, or bypass the detector with direct APIs, browser scraping, copied credentials, or hand-written raw facets.
91
+
92
+ ## Report Gates
93
+
94
+ Read the JSON report as gates before editing. Stop at the first blocking gate; otherwise edit only resources named by the report.
95
+
96
+ | Report field | Action |
97
+ | --- | --- |
98
+ | `ok: false` and missing memory | Route to `repo-build.md`; do not invent a baseline. |
99
+ | no deltas and no notices | Report no update needed. |
100
+ | `commit_delta_skipped: "missing_baseline_commit"` | Stop commit-resource updates; recommend full rebuild. |
101
+ | `commit_delta_skipped: "baseline_not_ancestor_of_head"` | Stop commit-resource updates; recommend rebuild or explicit baseline reset. |
102
+ | provider fetch failed / `Provider Delta Fetch Failed` | Keep existing PR/MR/issue resources unchanged; local commits may still be updated. |
103
+ | `deltas.local_commits` | Update only `resources/commits.md`; refresh `PROFILE.md` local head and `generated_at` timestamp. |
104
+ | `deltas.pull_requests.upsert_numbers` | Upsert only matching PR/MR sections from `current.provider_items.pull_requests`; preserve `baseline_only_numbers`. |
105
+ | `deltas.issues.upsert_numbers` | Upsert only matching issue sections from `current.provider_items.issues`; preserve `baseline_only_numbers`. |
106
+
107
+ Never delete prior PR/MR/issue sections because they are absent from the bounded provider fetch; deletion needs explicit user instruction or verified invalidation. Finish with the builder validator:
108
+
109
+ ```bash
110
+ python3 <skill-dir>/scripts/validate_memory.py <repo-path> --pretty
111
+ ```
112
+
113
+ Whenever an update changes generated repo-memory artifacts, set `PROFILE.md.generated_at` to the successful update time and `PROFILE.md.local_head` to the processed snapshot. The read-time cooldown policy uses this timestamp; do not preserve an older build time after a successful incremental update.
114
+
115
+ ## Authoring Rules
116
+
117
+ Match existing fixed-field sections first; use builder templates only when the file shape is incomplete. Upsert by stable keys: commit SHA, PR/MR number, and issue number. Replace matching sections, append only new keys, and do not delete useful notes unless explicit instruction or verified evidence invalidates them.
118
+
119
+ Every new or replaced section needs a search-grade `Description`, evidence strength, and source from local commit delta, `current.provider_items`, or raw provider files. Number-only deltas route the edit; they are not authoring evidence. Do not invent PR/MR/issue evidence when provider fetch is skipped or unavailable, paste long raw summaries, or treat validator/counts as proof of body quality.
120
+
121
+ ## Trust Rules
122
+
123
+ - Live code and targeted verification are stronger than repo memory.
124
+ - Local commit deltas are checkout history, not current behavior proof.
125
+ - Provider PR/MR/issue deltas are historical or planning context, not implementation truth.
126
+ - Open PRs/MRs are branch intent, not landed behavior.
127
+ - Issues are user/problem context, not implementation proof.