@mmerterden/multi-agent-pipeline 23.2.0 → 23.4.0

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 (230) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +25 -6
  3. package/README.tr.md +26 -7
  4. package/docs/adr/0008-installer-modularization-and-secret-leak-defense.md +1 -1
  5. package/docs/adr/0010-own-code-graph.md +299 -8
  6. package/docs/architecture.md +3 -3
  7. package/docs/ecosystem.md +10 -10
  8. package/docs/engineering.md +4 -4
  9. package/docs/facts.json +8 -8
  10. package/docs/features.md +6 -6
  11. package/docs/performance.md +17 -17
  12. package/install/_dev-only-files.mjs +9 -0
  13. package/install/claude.mjs +28 -2
  14. package/install/templates/claude-hooks.json +32 -1
  15. package/manifest.json +229 -161
  16. package/package.json +11 -3
  17. package/pipeline/commands/multi-agent/SKILL.md +1 -1
  18. package/pipeline/commands/multi-agent/design-check/SKILL.md +2 -2
  19. package/pipeline/commands/multi-agent/diff-explain/SKILL.md +3 -3
  20. package/pipeline/commands/multi-agent/fable-status/SKILL.md +1 -1
  21. package/pipeline/commands/multi-agent/graph/SKILL.md +57 -24
  22. package/pipeline/commands/multi-agent/pair/SKILL.md +92 -0
  23. package/pipeline/commands/multi-agent/prune-prompts/SKILL.md +1 -1
  24. package/pipeline/commands/multi-agent/search/SKILL.md +7 -1
  25. package/pipeline/commands/multi-agent/status/SKILL.md +4 -0
  26. package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
  27. package/pipeline/contract/CHANGELOG.md +49 -0
  28. package/pipeline/contract/build.mjs +13 -1
  29. package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
  30. package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
  31. package/pipeline/contract/fixtures/runs-awaiting-question.json +4 -1
  32. package/pipeline/contract/fixtures/runs-empty.json +1 -1
  33. package/pipeline/contract/fixtures/runs-failed.json +4 -1
  34. package/pipeline/contract/fixtures/runs-old-schema.json +3 -0
  35. package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +4 -1
  36. package/pipeline/contract/fixtures/runs-pr-opened.json +4 -1
  37. package/pipeline/contract/fixtures/runs-running.json +4 -1
  38. package/pipeline/contract/manifest.json +28 -15
  39. package/pipeline/contract/types/index.d.ts +55 -3
  40. package/pipeline/lib/detach-self.mjs +95 -0
  41. package/pipeline/lib/model-rung.sh +1 -1
  42. package/pipeline/lib/public-mcp-servers.mjs +33 -0
  43. package/pipeline/lib/rotated-log.mjs +93 -0
  44. package/pipeline/lib/tls-trust.mjs +29 -0
  45. package/pipeline/lib/usage-lifecycle.mjs +9 -11
  46. package/pipeline/lib/usage-names.generated.mjs +614 -0
  47. package/pipeline/lib/usage-run-key.mjs +235 -0
  48. package/pipeline/lib/usage-vocab.mjs +210 -0
  49. package/pipeline/multi-agent-refs/analysis/intake.md +2 -2
  50. package/pipeline/multi-agent-refs/analysis/render.md +1 -1
  51. package/pipeline/multi-agent-refs/channels/generator.md +4 -5
  52. package/pipeline/multi-agent-refs/cross-cli-contract.md +4 -4
  53. package/pipeline/multi-agent-refs/design-check/scope-and-ledger.md +1 -1
  54. package/pipeline/multi-agent-refs/features/code-graph.md +146 -11
  55. package/pipeline/multi-agent-refs/features/code-intelligence.md +16 -14
  56. package/pipeline/multi-agent-refs/features/dev-critic.md +7 -7
  57. package/pipeline/multi-agent-refs/features/model-fallback.md +9 -7
  58. package/pipeline/multi-agent-refs/features/remote-control.md +252 -0
  59. package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
  60. package/pipeline/multi-agent-refs/features/review-file-set.md +3 -3
  61. package/pipeline/multi-agent-refs/features/review-multi-repo.md +1 -1
  62. package/pipeline/multi-agent-refs/features/session-brief.md +42 -0
  63. package/pipeline/multi-agent-refs/features/skill-conformance.md +3 -3
  64. package/pipeline/multi-agent-refs/features/usage-reporting.md +252 -24
  65. package/pipeline/multi-agent-refs/help/en.md +3 -2
  66. package/pipeline/multi-agent-refs/help/tr.md +3 -2
  67. package/pipeline/multi-agent-refs/knowledge.md +1 -1
  68. package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +1 -1
  69. package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +1 -1
  70. package/pipeline/multi-agent-refs/phases/operations.md +2 -2
  71. package/pipeline/multi-agent-refs/phases/phase-0-init.md +13 -12
  72. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
  73. package/pipeline/multi-agent-refs/phases/phase-3-review.md +5 -3
  74. package/pipeline/multi-agent-refs/phases/phase-5-report.md +1 -1
  75. package/pipeline/multi-agent-refs/platform-parity.md +2 -2
  76. package/pipeline/multi-agent-refs/review/panel.md +1 -1
  77. package/pipeline/multi-agent-refs/wiki-capture.md +3 -17
  78. package/pipeline/office/index.html +1207 -233
  79. package/pipeline/office/toolkit.json +1 -1
  80. package/pipeline/rules/outside-the-pipeline.md +1 -1
  81. package/pipeline/schemas/activity.schema.json +23 -0
  82. package/pipeline/schemas/agent-state.schema.json +6 -1
  83. package/pipeline/schemas/code-graph-calls.schema.json +254 -0
  84. package/pipeline/schemas/code-graph-docs.schema.json +223 -0
  85. package/pipeline/schemas/code-graph-infra.schema.json +227 -0
  86. package/pipeline/schemas/code-graph.schema.json +2 -2
  87. package/pipeline/schemas/examples/design-check-config.json +27 -0
  88. package/pipeline/schemas/learning-curve.schema.json +67 -0
  89. package/pipeline/schemas/office-jobs.json +69 -2
  90. package/pipeline/schemas/office-jobs.schema.json +8 -1
  91. package/pipeline/schemas/phases.json +5 -0
  92. package/pipeline/schemas/phases.schema.json +8 -0
  93. package/pipeline/schemas/prefs.schema.json +46 -12
  94. package/pipeline/schemas/runs-index.schema.json +17 -0
  95. package/pipeline/schemas/toolkit-path-params.json +84 -8
  96. package/pipeline/scripts/README.md +1 -0
  97. package/pipeline/scripts/_code-graph.mjs +184 -103
  98. package/pipeline/scripts/_contract-core.mjs +1 -1
  99. package/pipeline/scripts/_contract-routes-office.mjs +21 -0
  100. package/pipeline/scripts/_diff-impact.mjs +21 -2
  101. package/pipeline/scripts/_graph-sidecars.mjs +372 -0
  102. package/pipeline/scripts/_http-post.mjs +103 -115
  103. package/pipeline/scripts/_safe-read.mjs +57 -0
  104. package/pipeline/scripts/_skill-practices.mjs +26 -0
  105. package/pipeline/scripts/_strip-code.mjs +380 -0
  106. package/pipeline/scripts/activity-snapshot.mjs +13 -1
  107. package/pipeline/scripts/aggregate-metrics.mjs +3 -5
  108. package/pipeline/scripts/call-graph/index.mjs +78 -0
  109. package/pipeline/scripts/call-graph/lang/cpp.mjs +308 -0
  110. package/pipeline/scripts/call-graph/lang/csharp.mjs +130 -0
  111. package/pipeline/scripts/call-graph/lang/go.mjs +303 -0
  112. package/pipeline/scripts/call-graph/lang/java.mjs +370 -0
  113. package/pipeline/scripts/call-graph/lang/kotlin.mjs +397 -0
  114. package/pipeline/scripts/call-graph/lang/python.mjs +399 -0
  115. package/pipeline/scripts/call-graph/lang/rust.mjs +345 -0
  116. package/pipeline/scripts/call-graph/lang/shared.mjs +230 -0
  117. package/pipeline/scripts/call-graph/lang/swift.mjs +432 -0
  118. package/pipeline/scripts/call-graph/lang/typescript.mjs +692 -0
  119. package/pipeline/scripts/call-graph/lex.mjs +396 -0
  120. package/pipeline/scripts/call-graph/platform.mjs +86 -0
  121. package/pipeline/scripts/call-graph/profiles.mjs +89 -0
  122. package/pipeline/scripts/call-graph/resolve.mjs +1125 -0
  123. package/pipeline/scripts/call-graph/scan.mjs +267 -0
  124. package/pipeline/scripts/code-graph-rules/android.json +7 -2
  125. package/pipeline/scripts/code-graph-rules/cpp.json +99 -0
  126. package/pipeline/scripts/code-graph-rules/csharp.json +102 -0
  127. package/pipeline/scripts/code-graph-rules/go.json +2 -1
  128. package/pipeline/scripts/code-graph-rules/ios.json +3 -1
  129. package/pipeline/scripts/code-graph-rules/java.json +76 -0
  130. package/pipeline/scripts/code-graph-rules/node.json +7 -2
  131. package/pipeline/scripts/code-graph-rules/python.json +6 -2
  132. package/pipeline/scripts/code-graph-rules/rust.json +105 -0
  133. package/pipeline/scripts/contract-server.mjs +1 -0
  134. package/pipeline/scripts/cost-table.json +6 -5
  135. package/pipeline/scripts/feedback-send.mjs +26 -26
  136. package/pipeline/scripts/gate-ledger.mjs +2 -1
  137. package/pipeline/scripts/gen-usage-names.mjs +124 -0
  138. package/pipeline/scripts/graph-affected.mjs +109 -20
  139. package/pipeline/scripts/graph-build.mjs +95 -15
  140. package/pipeline/scripts/graph-export.mjs +272 -0
  141. package/pipeline/scripts/graph-hint.mjs +15 -2
  142. package/pipeline/scripts/graph-query.mjs +305 -26
  143. package/pipeline/scripts/graph-report.mjs +187 -1
  144. package/pipeline/scripts/health-report.mjs +3 -4
  145. package/pipeline/scripts/infra/docs.mjs +317 -0
  146. package/pipeline/scripts/infra/extract.mjs +998 -0
  147. package/pipeline/scripts/infra/graph.mjs +245 -0
  148. package/pipeline/scripts/infra/yaml-lite.mjs +311 -0
  149. package/pipeline/scripts/job-launch.mjs +67 -2
  150. package/pipeline/scripts/learning-curve.mjs +288 -178
  151. package/pipeline/scripts/log-metric.sh +10 -1
  152. package/pipeline/scripts/note-agent-event.mjs +3 -4
  153. package/pipeline/scripts/note-command-use.mjs +333 -0
  154. package/pipeline/scripts/note-command-use.sh +126 -0
  155. package/pipeline/scripts/note-mcp-call.sh +89 -0
  156. package/pipeline/scripts/note-mcp-failure.mjs +272 -1
  157. package/pipeline/scripts/note-session.sh +62 -3
  158. package/pipeline/scripts/note-skill-use.mjs +58 -2
  159. package/pipeline/scripts/office-build.mjs +115 -1
  160. package/pipeline/scripts/office-memory.mjs +14 -5
  161. package/pipeline/scripts/pair.mjs +333 -0
  162. package/pipeline/scripts/pre-push-check.sh +1 -1
  163. package/pipeline/scripts/remote/cbor.mjs +128 -0
  164. package/pipeline/scripts/remote/contract.mjs +98 -0
  165. package/pipeline/scripts/remote/handler.mjs +317 -0
  166. package/pipeline/scripts/remote/handles.mjs +57 -0
  167. package/pipeline/scripts/remote/lifecycle.mjs +186 -0
  168. package/pipeline/scripts/remote/listener.mjs +204 -0
  169. package/pipeline/scripts/remote/lockout.mjs +103 -0
  170. package/pipeline/scripts/remote/nonces.mjs +61 -0
  171. package/pipeline/scripts/remote/pairing.mjs +519 -0
  172. package/pipeline/scripts/remote/qr-encode.mjs +459 -0
  173. package/pipeline/scripts/remote/store.mjs +188 -0
  174. package/pipeline/scripts/remote/transport.mjs +211 -0
  175. package/pipeline/scripts/remote/verbs.json +70 -0
  176. package/pipeline/scripts/remote/verbs.mjs +217 -0
  177. package/pipeline/scripts/remote/webauthn.mjs +169 -0
  178. package/pipeline/scripts/remote/wire.mjs +364 -0
  179. package/pipeline/scripts/remote-listener.mjs +83 -0
  180. package/pipeline/scripts/route-learn.mjs +4 -4
  181. package/pipeline/scripts/run-kill.mjs +1 -1
  182. package/pipeline/scripts/run-write.mjs +13 -2
  183. package/pipeline/scripts/runs-index.mjs +30 -3
  184. package/pipeline/scripts/search-logs.sh +9 -0
  185. package/pipeline/scripts/session-brief.mjs +458 -0
  186. package/pipeline/scripts/session-brief.sh +130 -0
  187. package/pipeline/scripts/test-gap-rules/cpp.json +25 -0
  188. package/pipeline/scripts/test-gap-rules/csharp.json +20 -0
  189. package/pipeline/scripts/test-gap-rules/java.json +20 -0
  190. package/pipeline/scripts/test-gap-rules/rust.json +14 -0
  191. package/pipeline/scripts/token-budget-report.mjs +3 -2
  192. package/pipeline/scripts/uninstall.mjs +29 -0
  193. package/pipeline/scripts/usage-access.mjs +16 -31
  194. package/pipeline/scripts/usage-health.mjs +31 -62
  195. package/pipeline/scripts/usage-register-beacon.mjs +11 -22
  196. package/pipeline/scripts/usage-register.mjs +39 -29
  197. package/pipeline/scripts/usage-report.mjs +579 -178
  198. package/pipeline/scripts/validate-code-graph.mjs +361 -111
  199. package/pipeline/scripts/write-state.mjs +39 -0
  200. package/pipeline/skills/.skill-manifest.json +22 -18
  201. package/pipeline/skills/.skills-index.json +13 -2
  202. package/pipeline/skills/shared/README.md +5 -4
  203. package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +1 -1
  204. package/pipeline/skills/shared/core/multi-agent-diff-explain/SKILL.md +3 -3
  205. package/pipeline/skills/shared/core/multi-agent-fable-status/SKILL.md +1 -1
  206. package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +55 -21
  207. package/pipeline/skills/shared/core/multi-agent-pair/SKILL.md +41 -0
  208. package/pipeline/skills/shared/core/multi-agent-prune-prompts/SKILL.md +1 -1
  209. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
  210. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +2 -3
  211. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +2 -2
  212. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +2 -2
  213. package/pipeline/skills/shared/external/app-store-review/SKILL.md +11 -4
  214. package/pipeline/skills/shared/external/build-settings-audit/SKILL.md +1 -1
  215. package/pipeline/skills/shared/external/build-time-benchmark/SKILL.md +5 -5
  216. package/pipeline/skills/shared/external/build-time-fixes/SKILL.md +5 -5
  217. package/pipeline/skills/shared/external/build-time-optimizer/SKILL.md +6 -6
  218. package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +1 -0
  219. package/pipeline/skills/shared/external/ios-coding-standard/references/STANDARD.md +2 -2
  220. package/pipeline/skills/shared/external/ios-haptics/references/core-haptics.md +1 -1
  221. package/pipeline/skills/shared/external/localization-reuse-map/references/publish-and-snapshot.md +1 -1
  222. package/pipeline/skills/shared/external/package-build-audit/SKILL.md +3 -3
  223. package/pipeline/skills/shared/external/reverse-engineer-own-app/SKILL.md +2 -3
  224. package/pipeline/skills/shared/external/swift-compile-hotspots/SKILL.md +2 -2
  225. package/pipeline/skills/shared/external/weatherkit/SKILL.md +5 -6
  226. package/pipeline/skills/skills-index.md +3 -2
  227. package/docs/FIGMA_PIPELINE.md +0 -137
  228. package/pipeline/lib/identifier-scan.mjs +0 -156
  229. package/pipeline/scripts/publish-staged.mjs +0 -324
  230. package/pipeline/skills/shared/external/ios-coding-standard/scripts/check_structure.py +0 -765
@@ -0,0 +1,458 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @file session-brief.mjs - an opt-in block a plain session can open with:
4
+ * an index of the repository's learnings ledger, one line about its code graph,
5
+ * and, as separate settings, the skill indexes and a few working notes.
6
+ *
7
+ * It is off until prefs.global.sessionBrief.enabled is true. A run loads the
8
+ * ledger in Phase 0; an ordinary session would otherwise start knowing none of
9
+ * it. The block is an index, not the memory: each ledger line carries its
10
+ * pointer, and the detail is one call away (`learnings_get`, or
11
+ * `learnings-ledger.mjs show --id <id>`).
12
+ *
13
+ * What it injects, by setting:
14
+ *
15
+ * ledger always, when enabled: the counts and up to `maxEntries`
16
+ * standing entries, as many as fit, best first
17
+ * graph one line when a code graph exists (unless codeGraph is off)
18
+ * routing with ledger or graph: the `index` skill of each enabled toolkit
19
+ * discipline only with `discipline: true`: a few working notes
20
+ *
21
+ * A repository with no ledger entries and no code graph gets nothing at all.
22
+ * The block is also withheld for a repository in memory.excludeProjects.
23
+ *
24
+ * The block is built here, in a detached process, and cached; the SessionStart
25
+ * hook (session-brief.sh) only prints the cache, because starting node on every
26
+ * session start costs more than the hook may take. The cache sits under
27
+ * ~/.claude/memory/multi-agent/_session-brief/ (directory 0700, file 0600) and
28
+ * starts with a header naming the repository's git common directory and HEAD;
29
+ * the hook prints it only when both match. It depends on exactly these files:
30
+ * the repo's ledger and feedback, the cross-repo ledger, the repo's code graph,
31
+ * the preferences file, ~/.claude/settings.json and settings.local.json, the
32
+ * repo's .claude/settings.json and settings.local.json, and
33
+ * ~/.claude/plugins/installed_plugins.json.
34
+ *
35
+ * Everything printed is text a model or a person wrote, so each line is
36
+ * cleaned (control, bidi and zero-width characters removed, home paths and
37
+ * ticket-key-shaped tokens masked, markup tags and tool-call words defused),
38
+ * clipped by code point, secret-scanned in the exact form that is printed, and
39
+ * the entries sit inside an <untrusted-data> block.
40
+ *
41
+ * Every file is read only when it is a regular file reached without a final
42
+ * symlink and under a size cap; a FIFO, directory or link is skipped. The
43
+ * builder gives up after BUILD_LIMIT_MS.
44
+ *
45
+ * Settings, each under prefs.global:
46
+ * sessionBrief.enabled true turns the brief on (default off)
47
+ * sessionBrief.maxEntries ledger lines shown, 0 to 10 (default 5)
48
+ * sessionBrief.maxChars size of the whole block, 400 to 4000 (default 2400)
49
+ * sessionBrief.kinds ledger kinds shown (default all)
50
+ * sessionBrief.discipline true adds the working notes (default off)
51
+ *
52
+ * Usage:
53
+ * session-brief.mjs build [--cwd <dir>] rebuild the cache for the repo at cwd
54
+ * session-brief.mjs print [--cwd <dir>] print the hook output without writing
55
+ *
56
+ * Exit is 0 on every path.
57
+ *
58
+ * @module pipeline/scripts/session-brief
59
+ */
60
+
61
+ import { spawnSync } from "node:child_process";
62
+ import { chmodSync, mkdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
63
+ import { homedir } from "node:os";
64
+ import { join } from "node:path";
65
+
66
+ import { fitToBudget } from "../lib/context-budget.mjs";
67
+ import { invokedDirectly } from "../lib/invoked-directly.mjs";
68
+ import { prefsPath } from "../lib/prefs-value.mjs";
69
+ import { readRegularFile } from "../lib/regular-file.mjs";
70
+ import { repoName } from "../lib/slug.mjs";
71
+ import { wrapUntrusted } from "../lib/untrusted.mjs";
72
+ import { messages, outputLanguage } from "../lib/user-facing.mjs";
73
+ import { exitOnHelp } from "../lib/cli-help.mjs";
74
+ import { ledgerRowId, memoryExcluded, standing, supersededBy } from "./_memory-policy.mjs";
75
+ import { openScanner } from "./_secret-scan.mjs";
76
+
77
+ exitOnHelp(import.meta.url);
78
+
79
+ export const CACHE_DIR = "_session-brief";
80
+ export const CACHE_MAGIC = "#sb1";
81
+ export const BUILD_LIMIT_MS = 10_000;
82
+ export const DEFAULTS = Object.freeze({ maxEntries: 5, maxChars: 2400 });
83
+ const STORE_MAX_BYTES = 4 * 1024 * 1024;
84
+ const PREFS_MAX_BYTES = 1024 * 1024;
85
+ const GRAPH_MAX_BYTES = 128 * 1024 * 1024;
86
+ const LINE_CHARS = 130;
87
+ const KINDS = ["security-note", "decision", "convention", "fact", "rejected-preference"];
88
+ const CONFIDENCE = { high: 0, medium: 1, low: 2 };
89
+ const MAX_TOOLKITS = 4;
90
+ const SCAN_LIMIT = 40;
91
+
92
+ /** The cache file name for a repository folder name and its git common directory. */
93
+ export function cacheName(slug, common = "") {
94
+ const safe = String(slug).replace(/[^A-Za-z0-9._-]/g, "_");
95
+ return common ? `${safe}-${pathHash(common)}` : safe;
96
+ }
97
+
98
+ /**
99
+ * 32-bit djb2 of the path's UTF-8 bytes, 8 hex digits. The hook computes the
100
+ * same value in bash, so the two agree on a file name without a hashing tool.
101
+ */
102
+ export function pathHash(path) {
103
+ let h = 5381;
104
+ for (const b of Buffer.from(String(path), "utf8")) h = (h * 33 + b) % 4294967296;
105
+ return h.toString(16).padStart(8, "0");
106
+ }
107
+
108
+ const home = (env) => env.HOME || homedir();
109
+ export const cacheDir = (env = process.env) =>
110
+ join(home(env), ".claude", "memory", "multi-agent", CACHE_DIR);
111
+
112
+ /** The text of a regular file under a size cap, or null for anything else. */
113
+ function readText(path, maxBytes) {
114
+ try {
115
+ return readRegularFile(path, { maxBytes, noFollow: true });
116
+ } catch {
117
+ return null;
118
+ }
119
+ }
120
+
121
+ function readJson(path, maxBytes) {
122
+ const text = readText(path, maxBytes);
123
+ if (text === null) return null;
124
+ try {
125
+ return JSON.parse(text);
126
+ } catch {
127
+ return null;
128
+ }
129
+ }
130
+
131
+ /** The `sessionBrief` settings with their bounds applied. */
132
+ export function settingsOf(prefs) {
133
+ const raw =
134
+ prefs?.sessionBrief && typeof prefs.sessionBrief === "object" ? prefs.sessionBrief : {};
135
+ const clamp = (v, lo, hi, d) => (Number.isInteger(v) ? Math.min(hi, Math.max(lo, v)) : d);
136
+ const kinds = Array.isArray(raw.kinds) ? raw.kinds.filter((k) => KINDS.includes(k)) : KINDS;
137
+ return {
138
+ enabled: raw.enabled === true,
139
+ maxEntries: clamp(raw.maxEntries, 0, 10, DEFAULTS.maxEntries),
140
+ maxChars: clamp(raw.maxChars, 400, 4000, DEFAULTS.maxChars),
141
+ kinds: kinds.length ? kinds : KINDS,
142
+ discipline: raw.discipline === true,
143
+ graph: prefs?.codeGraph?.enabled !== false,
144
+ };
145
+ }
146
+
147
+ const MARKS = /[\p{Cc}\p{Cf}]/gu;
148
+
149
+ /**
150
+ * One piece of ledger text made safe to print on a single line: invisible and
151
+ * directional characters removed, home paths and ticket-key-shaped tokens
152
+ * masked, markup tags and tool-call words defused, whitespace folded, then
153
+ * clipped by code point so no half of a surrogate pair is left.
154
+ */
155
+ export function clean(text, limit = LINE_CHARS) {
156
+ const one = String(text ?? "")
157
+ .replace(MARKS, " ")
158
+ .replace(/(?:[A-Za-z]:\\Users\\|\/(?:Users|home)\/)[^\s/\\]+/g, "~")
159
+ .replace(/\b[A-Z][A-Z0-9]{1,9}-\d{1,7}\b/g, "[key]")
160
+ .replace(/<\/?[A-Za-z][^>]{0,80}>/g, "[tag]")
161
+ .replace(/\b(?:tool_use|tool_result|tool_call|function_call|antml)\w*/gi, "[x]")
162
+ .replace(/\s+/g, " ")
163
+ .trim();
164
+ const points = Array.from(one);
165
+ return points.length > limit ? `${points.slice(0, limit - 3).join("")}...` : one;
166
+ }
167
+
168
+ function rows(path) {
169
+ const text = readText(path, STORE_MAX_BYTES);
170
+ if (text === null) return [];
171
+ return text
172
+ .split("\n")
173
+ .filter((l) => l.trim())
174
+ .flatMap((l) => {
175
+ try {
176
+ const r = JSON.parse(l);
177
+ return r && typeof r === "object" && !Array.isArray(r) ? [r] : [];
178
+ } catch {
179
+ return [];
180
+ }
181
+ });
182
+ }
183
+
184
+ /**
185
+ * The repository's standing ledger entries: not superseded, not suppressed by
186
+ * feedback. Each carries its pointer id and its place in the file.
187
+ */
188
+ export function standingEntries(storeDir) {
189
+ const ledger = rows(join(storeDir, "learnings-ledger.jsonl"));
190
+ const retired = supersededBy(ledger);
191
+ const feedback = new Map();
192
+ for (const f of rows(join(storeDir, "learnings-feedback.jsonl"))) {
193
+ if (!feedback.has(f.id)) feedback.set(f.id, []);
194
+ feedback.get(f.id).push(f);
195
+ }
196
+ const out = [];
197
+ for (const [i, r] of ledger.entries()) {
198
+ if (retired[i] !== null || typeof r.statement !== "string" || !r.statement.trim()) continue;
199
+ const id = ledgerRowId(r);
200
+ if (standing(feedback.get(id) ?? []).suppressed) continue;
201
+ out.push({ id, order: i, row: r });
202
+ }
203
+ return out;
204
+ }
205
+
206
+ /** Best first: confidence, repository-wide before path-scoped, kind, newest. */
207
+ export function rankEntries(entries) {
208
+ const rank = (e) => CONFIDENCE[e.row.confidence] ?? CONFIDENCE.medium;
209
+ const wide = (e) => (!e.row.scope || e.row.scope === "global" ? 0 : 1);
210
+ const kind = (e) => {
211
+ const k = KINDS.indexOf(e.row.kind);
212
+ return k === -1 ? KINDS.length : k;
213
+ };
214
+ return [...entries].sort(
215
+ (a, b) => rank(a) - rank(b) || wide(a) - wide(b) || kind(a) - kind(b) || b.order - a.order,
216
+ );
217
+ }
218
+
219
+ /** The line printed for one entry: every printed field is in this string. */
220
+ export function entryLine(e) {
221
+ const scope = e.row.scope && e.row.scope !== "global" ? ` (scope ${clean(e.row.scope, 40)})` : "";
222
+ return `- [${e.id}] ${clean(e.row.kind, 24)}: ${clean(e.row.statement)}${scope}`;
223
+ }
224
+
225
+ /**
226
+ * The ledger layer: the count by kind and the best entries whose printed line
227
+ * passes the secret scan. The count excludes entries the scan refused.
228
+ */
229
+ export function ledgerLayer(storeDir, cfg, globalRows = 0) {
230
+ const all = standingEntries(storeDir).filter((e) => cfg.kinds.includes(e.row.kind));
231
+ if (!all.length || cfg.maxEntries === 0) return null;
232
+ const scan = openScanner();
233
+ const shown = [];
234
+ const refused = new Set();
235
+ try {
236
+ for (const e of rankEntries(all).slice(0, SCAN_LIMIT)) {
237
+ const line = entryLine(e);
238
+ const whole = `${e.row.kind} ${e.row.statement} ${e.row.scope ?? ""}`;
239
+ if (scan.isClean(line) && scan.isClean(whole)) {
240
+ if (shown.length < cfg.maxEntries) shown.push({ e, line });
241
+ } else {
242
+ refused.add(e.id);
243
+ }
244
+ }
245
+ } finally {
246
+ scan.close();
247
+ }
248
+ if (!shown.length) return null;
249
+ const kept = all.filter((e) => !refused.has(e.id));
250
+ const total = kept.length;
251
+ const kinds = KINDS.map((k) => [k, kept.filter((e) => e.row.kind === k).length])
252
+ .filter(([, n]) => n > 0)
253
+ .map(([k, n]) => `${n} ${k}`)
254
+ .join(", ");
255
+ const extra = globalRows > 0 ? `; the ledger profile adds ${globalRows} cross-repo entries` : "";
256
+ const head = `Learnings ledger: ${total} standing entries (${kinds})${extra}. Fetch one with learnings_get or learnings-ledger.mjs show --id <id>; search with learnings_search.`;
257
+ return { head, lines: shown.map((s) => s.line), total, shown: shown.length };
258
+ }
259
+
260
+ /** One line about the repository's code graph, or null when there is none. */
261
+ export function graphLine(slug, env = process.env) {
262
+ const g = readJson(
263
+ join(home(env), ".claude", "knowledge", slug, "code-graph.json"),
264
+ GRAPH_MAX_BYTES,
265
+ );
266
+ const nodes = Number(g?.stats?.nodes);
267
+ if (!Number.isFinite(nodes) || nodes <= 0) return null;
268
+ const files = Number(g.stats.files);
269
+ const at =
270
+ typeof g.baseCommit === "string" && /^[0-9a-f]{7,64}$/.test(g.baseCommit)
271
+ ? ` at ${g.baseCommit.slice(0, 7)}`
272
+ : "";
273
+ const size =
274
+ Number.isFinite(files) && files > 0 ? `${files} files, ${nodes} symbols` : `${nodes} symbols`;
275
+ return `Code graph: ${size} indexed${at}. For a symbol or concept question try graph_query or /multi-agent:graph ask before grepping the whole repo; grep stays right for exact text.`;
276
+ }
277
+
278
+ /** The enabled toolkits that ship an index skill, from the effective settings. */
279
+ export async function indexSkills(top, env = process.env) {
280
+ try {
281
+ const { resolveSkillCandidates } = await import("./skill-candidates.mjs");
282
+ const r = resolveSkillCandidates(top, { home: home(env) });
283
+ return (r.toolkits ?? [])
284
+ .filter((t) => Array.isArray(t.skills) && t.skills.includes("index"))
285
+ .map((t) => `${t.name}:index`)
286
+ .slice(0, MAX_TOOLKITS);
287
+ } catch {
288
+ return [];
289
+ }
290
+ }
291
+
292
+ export const DISCIPLINE =
293
+ "Working notes: lead with the answer. Only when the goal behind a request is genuinely unclear, ask one question about why before how; otherwise state the assumption and go. For an open choice, name 2-3 options and recommend one. Give each step a check (step -> verify: how). Say so when a simpler route exists. Give time in minutes or hours.";
294
+
295
+ function routingLine(index) {
296
+ const open = index.length ? ` When unsure which applies, open ${index.join(", ")} first.` : "";
297
+ return `Skills: before replying, check whether an available skill fits the request.${open}`;
298
+ }
299
+
300
+ /** Git's view of the repository at cwd: common dir, top level and HEAD, or null. */
301
+ export function gitFacts(cwd) {
302
+ const r = spawnSync(
303
+ "git",
304
+ [
305
+ "-C",
306
+ cwd,
307
+ "rev-parse",
308
+ "--path-format=absolute",
309
+ "--git-common-dir",
310
+ "--show-toplevel",
311
+ "HEAD",
312
+ ],
313
+ { encoding: "utf8", timeout: 3000 },
314
+ );
315
+ if (r.status !== 0) return null;
316
+ const [common, top, head] = String(r.stdout).split("\n");
317
+ return common && top ? { common, top, head: head || "" } : null;
318
+ }
319
+
320
+ /** The preferences when the file is a regular file and parses; null otherwise. */
321
+ function loadPrefs(env) {
322
+ const file = prefsPath(env);
323
+ try {
324
+ if (!statSync(file).isFile()) return null;
325
+ } catch {
326
+ return null;
327
+ }
328
+ const doc = readJson(file, PREFS_MAX_BYTES);
329
+ return doc && typeof doc === "object" && doc.global && typeof doc.global === "object"
330
+ ? { file, global: doc.global }
331
+ : null;
332
+ }
333
+
334
+ /**
335
+ * The hook output for one repository, or null when there is nothing to say.
336
+ *
337
+ * @returns {Promise<null | {output: object, bytes: number, entries: number}>}
338
+ */
339
+ export async function composeBrief({ cwd = process.cwd(), env = process.env } = {}) {
340
+ const prefs = loadPrefs(env);
341
+ if (!prefs) return null;
342
+ const cfg = settingsOf(prefs.global);
343
+ if (!cfg.enabled) return null;
344
+ const git = gitFacts(cwd);
345
+ if (!git) return null;
346
+ const slug = repoName({ cwd, env });
347
+ if (memoryExcluded(slug, env)) return null;
348
+
349
+ const root = join(home(env), ".claude", "memory", "multi-agent");
350
+ const globalRows = rows(join(root, "_global", "learnings-ledger.jsonl")).length;
351
+ const ledger = ledgerLayer(join(root, slug), cfg, globalRows);
352
+ const graph = cfg.graph ? graphLine(slug, env) : null;
353
+ if (!ledger && !graph) return null;
354
+ const index = await indexSkills(git.top, env);
355
+
356
+ const items = [];
357
+ if (ledger) {
358
+ items.push({ id: "ledger-head", priority: 100, block: ledger.head });
359
+ ledger.lines.forEach((line, i) =>
360
+ items.push({ id: `ledger-${i}`, priority: 60 - i, block: line }),
361
+ );
362
+ }
363
+ if (graph) items.push({ id: "graph", priority: 30, block: graph });
364
+ items.push({ id: "routing", priority: 20, block: routingLine(index) });
365
+ if (cfg.discipline) items.push({ id: "discipline", priority: 10, block: DISCIPLINE });
366
+
367
+ const render = (kept) => {
368
+ const ledgerBlocks = kept.filter((k) => k.id.startsWith("ledger")).map((k) => k.block);
369
+ const rest = kept.filter((k) => !k.id.startsWith("ledger")).map((k) => k.block);
370
+ const fenced = ledgerBlocks.length
371
+ ? [wrapUntrusted(`memory:${slug}`, ledgerBlocks.join("\n")).trimEnd()]
372
+ : [];
373
+ return [...fenced, ...rest].join("\n");
374
+ };
375
+ const { text } = fitToBudget(items, { maxChars: cfg.maxChars, render });
376
+ if (!text) return null;
377
+ const bytes = Buffer.byteLength(text, "utf8");
378
+ const tokens = Math.ceil(bytes / 4);
379
+ const shown = text.split("\n").filter((l) => l.startsWith("- [L:")).length;
380
+ const say = messages(
381
+ {
382
+ en: (n, t) =>
383
+ n > 0
384
+ ? `multi-agent: session brief loaded, ${n} ledger entries indexed (~${t} tokens).`
385
+ : `multi-agent: session brief loaded (~${t} tokens).`,
386
+ tr: (n, t) =>
387
+ n > 0
388
+ ? `multi-agent: oturum özeti yüklendi, ${n} ledger kaydı dizinlendi (~${t} token).`
389
+ : `multi-agent: oturum özeti yüklendi (~${t} token).`,
390
+ },
391
+ outputLanguage(prefs.file),
392
+ );
393
+ return {
394
+ output: {
395
+ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: text },
396
+ systemMessage: say(shown, tokens),
397
+ },
398
+ bytes,
399
+ entries: shown,
400
+ };
401
+ }
402
+
403
+ function writePrivate(path, data) {
404
+ const tmp = `${path}.${process.pid}.tmp`;
405
+ writeFileSync(tmp, data, { mode: 0o600, flag: "w" });
406
+ chmodSync(tmp, 0o600);
407
+ renameSync(tmp, path);
408
+ }
409
+
410
+ /**
411
+ * Rebuild the cache for the repository at `cwd`. The file is the header line
412
+ * `#sb1|<git common dir>|<HEAD>` and then the hook output as one JSON line; an
413
+ * empty brief is cached as the header alone, so the hook can tell "nothing to
414
+ * say" from "never built".
415
+ */
416
+ export async function buildCache({ cwd = process.cwd(), env = process.env } = {}) {
417
+ const git = gitFacts(cwd);
418
+ if (!git) return null;
419
+ const dir = cacheDir(env);
420
+ const name = cacheName(repoName({ cwd, env }), git.common);
421
+ const lock = join(dir, `${name}.lock`);
422
+ try {
423
+ if (!loadPrefs(env) || !settingsOf(loadPrefs(env).global).enabled) return null;
424
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
425
+ chmodSync(dir, 0o700);
426
+ const brief = await composeBrief({ cwd, env });
427
+ const header = `${CACHE_MAGIC}|${git.common}|${git.head}\n`;
428
+ writePrivate(
429
+ join(dir, `${name}.json`),
430
+ header + (brief ? `${JSON.stringify(brief.output)}\n` : ""),
431
+ );
432
+ return brief;
433
+ } finally {
434
+ rmSync(lock, { recursive: true, force: true });
435
+ }
436
+ }
437
+
438
+ async function main(argv) {
439
+ const timer = setTimeout(() => process.exit(0), BUILD_LIMIT_MS);
440
+ timer.unref();
441
+ const sub = argv[0];
442
+ const at = argv.indexOf("--cwd");
443
+ const cwd = at > 0 && argv[at + 1] ? argv[at + 1] : process.cwd();
444
+ try {
445
+ if (sub === "build") {
446
+ await buildCache({ cwd });
447
+ } else if (sub === "print") {
448
+ const brief = await composeBrief({ cwd });
449
+ if (brief) process.stdout.write(`${JSON.stringify(brief.output)}\n`);
450
+ } else {
451
+ process.stderr.write("usage: session-brief.mjs build|print [--cwd <dir>]\n");
452
+ }
453
+ } catch {
454
+ /* a session start is never failed over a brief */
455
+ }
456
+ }
457
+
458
+ if (invokedDirectly(import.meta.url)) await main(process.argv.slice(2));
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env bash
2
+ # session-brief.sh - opt-in SessionStart hook for the pipeline.
3
+ #
4
+ # Prints the cached session brief for the repository the session opens in (what
5
+ # it holds is described in session-brief.mjs). It only reads a file. Starting
6
+ # node on every session start costs more than this hook may take, so a detached
7
+ # node process builds the cache whenever HEAD or the repository differs from the
8
+ # cache header, or a file the cache was built from is newer than it. The cache
9
+ # is printed only when its header names this repository's git common directory
10
+ # and this HEAD; otherwise nothing is printed this session and a rebuild starts.
11
+ #
12
+ # Silent and instant unless prefs.global.sessionBrief.enabled is true. Also
13
+ # silent in a pipeline or unattended context (MULTI_AGENT_UNATTENDED,
14
+ # MULTI_AGENT_TASK_ID, MULTI_AGENT_PHASE), when the host says the session is not
15
+ # attended (CLAUDE_CODE_SESSION_ATTENDED set to anything but 1), for an SDK
16
+ # entrypoint (CLAUDE_CODE_ENTRYPOINT starting with sdk), outside a git
17
+ # repository, with HOME unset, and with MULTI_AGENT_SESSION_BRIEF=0.
18
+ # Exits 0 on every path.
19
+
20
+ case "${1:-}" in
21
+ --help | -h)
22
+ cat <<'USAGE'
23
+ session-brief.sh - SessionStart hook: prints the cached, opt-in session brief.
24
+ Turn it on with prefs.global.sessionBrief.enabled true; see
25
+ multi-agent-refs/features/session-brief.md. Reads the hook payload on stdin
26
+ only to ignore it. Exits 0 on every path.
27
+ USAGE
28
+ exit 0
29
+ ;;
30
+ esac
31
+
32
+ [ -n "${HOME:-}" ] || exit 0
33
+ [ "${MULTI_AGENT_SESSION_BRIEF:-}" = "0" ] && exit 0
34
+ [ -n "${MULTI_AGENT_UNATTENDED:-}" ] && [ "${MULTI_AGENT_UNATTENDED}" != "0" ] && exit 0
35
+ [ -n "${MULTI_AGENT_TASK_ID:-}${MULTI_AGENT_PHASE:-}" ] && exit 0
36
+ [ -n "${CLAUDE_CODE_SESSION_ATTENDED:-}" ] && [ "${CLAUDE_CODE_SESSION_ATTENDED}" != "1" ] && exit 0
37
+ [[ "${CLAUDE_CODE_ENTRYPOINT:-}" == sdk* ]] && exit 0
38
+
39
+ # Off unless the preferences switch it on. Only builtins read the file, and only
40
+ # when it is a regular file under 256 KiB (a FIFO or a huge file reads as off).
41
+ PREFS="${MULTI_AGENT_PREFS:-$HOME/.claude/multi-agent-preferences.json}"
42
+ [ -f "$PREFS" ] || exit 0
43
+ PREFS_TEXT=""
44
+ IFS= read -r -d '' -n 262144 PREFS_TEXT <"$PREFS" 2>/dev/null
45
+ [ "${#PREFS_TEXT}" -lt 262144 ] || exit 0
46
+ [[ "$PREFS_TEXT" == *sessionBrief* ]] || exit 0
47
+ ON='"sessionBrief"[[:space:]]*:[[:space:]]*\{[^{}]*"enabled"[[:space:]]*:[[:space:]]*true'
48
+ [[ "$PREFS_TEXT" =~ $ON ]] || exit 0
49
+
50
+ export LC_ALL=C
51
+ {
52
+ IFS= read -r COMMON
53
+ IFS= read -r TOP
54
+ IFS= read -r HEAD_SHA
55
+ } < <(git rev-parse --path-format=absolute --git-common-dir --show-toplevel HEAD 2>/dev/null)
56
+ [ -n "${COMMON:-}" ] && [ -n "${TOP:-}" ] || exit 0
57
+
58
+ if [ -n "${MULTI_AGENT_REPO_SLUG:-}" ]; then
59
+ SLUG="$MULTI_AGENT_REPO_SLUG"
60
+ else
61
+ SLUG="${COMMON%/}"
62
+ if [ "${SLUG##*/}" = ".git" ]; then
63
+ SLUG="${SLUG%/.git}"
64
+ SLUG="${SLUG##*/}"
65
+ else
66
+ SLUG="${SLUG##*/}"
67
+ SLUG="${SLUG%.git}"
68
+ fi
69
+ fi
70
+ SAFE="${SLUG//[^A-Za-z0-9._-]/_}"
71
+ [ -n "$SAFE" ] || exit 0
72
+
73
+ # 32-bit djb2 over the common dir's bytes: the cache file name, as in
74
+ # pathHash() in session-brief.mjs.
75
+ h=5381
76
+ for ((i = 0; i < ${#COMMON}; i++)); do
77
+ printf -v c '%d' "'${COMMON:i:1}"
78
+ h=$(((h * 33 + c) & 0xffffffff))
79
+ done
80
+ printf -v HASH '%08x' "$h"
81
+
82
+ MEM="$HOME/.claude/memory/multi-agent"
83
+ DIR="$MEM/_session-brief"
84
+ CACHE="$DIR/$SAFE-$HASH.json"
85
+ STORE="$MEM/$SLUG"
86
+ EXPECT="#sb1|$COMMON|$HEAD_SHA"
87
+
88
+ CONTENT=""
89
+ if [ -f "$CACHE" ] && [ ! -L "$CACHE" ]; then
90
+ IFS= read -r -d '' -n 16000 CONTENT <"$CACHE" 2>/dev/null
91
+ [ "${#CONTENT}" -lt 16000 ] || CONTENT=""
92
+ fi
93
+ HEADER="${CONTENT%%$'\n'*}"
94
+
95
+ stale=0
96
+ if [ "$HEADER" != "$EXPECT" ]; then
97
+ stale=1
98
+ else
99
+ for dep in "$STORE/learnings-ledger.jsonl" "$STORE/learnings-feedback.jsonl" \
100
+ "$MEM/_global/learnings-ledger.jsonl" "$HOME/.claude/knowledge/$SLUG/code-graph.json" \
101
+ "$PREFS" "$HOME/.claude/settings.json" "$HOME/.claude/settings.local.json" \
102
+ "$TOP/.claude/settings.json" "$TOP/.claude/settings.local.json" \
103
+ "$HOME/.claude/plugins/installed_plugins.json"; do
104
+ if [ -f "$dep" ] && [ "$dep" -nt "$CACHE" ]; then stale=1; break; fi
105
+ done
106
+ fi
107
+
108
+ if [ "$stale" = "1" ]; then
109
+ CORE="${BASH_SOURCE[0]%/*}/session-brief.mjs"
110
+ if [ -f "$CORE" ] && command -v node >/dev/null 2>&1; then
111
+ (umask 077; mkdir -p "$DIR" 2>/dev/null)
112
+ LOCK="$DIR/$SAFE-$HASH.lock"
113
+ if [ -d "$LOCK" ] && [ -n "$(find "$LOCK" -maxdepth 0 -mmin +5 2>/dev/null)" ]; then
114
+ rmdir "$LOCK" 2>/dev/null
115
+ fi
116
+ if mkdir "$LOCK" 2>/dev/null; then
117
+ nohup node "$CORE" build --cwd "$PWD" </dev/null >/dev/null 2>&1 &
118
+ fi
119
+ fi
120
+ fi
121
+
122
+ # Print only a cache built for this repository and HEAD whose body is one line
123
+ # without control characters.
124
+ [ "$HEADER" = "$EXPECT" ] || exit 0
125
+ BODY="${CONTENT#*$'\n'}"
126
+ BODY="${BODY%$'\n'}"
127
+ [ -n "$BODY" ] && [ "$BODY" != "$CONTENT" ] || exit 0
128
+ [[ "$BODY" == *[[:cntrl:]]* ]] && exit 0
129
+ printf '%s\n' "$BODY"
130
+ exit 0
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "stack": "cpp",
4
+ "description": "C and C++ test gap rules. Headers and sources are both source; tests carry a _test or Test suffix or live under a test directory.",
5
+ "sourceExtensions": [".c", ".h", ".cc", ".cpp", ".cxx", ".hpp", ".hh", ".hxx"],
6
+ "testPathSuffixes": ["_test.cpp", "_test.cc", "_test.c", "Test.cpp", "Tests.cpp", "Test.cc"],
7
+ "testPathContains": ["/test/", "/tests/", "/unittests/"],
8
+ "excludePathGlobs": [
9
+ "build/",
10
+ "cmake-build-debug/",
11
+ "cmake-build-release/",
12
+ "third_party/",
13
+ "vendor/",
14
+ "external/",
15
+ "*.pb.cc",
16
+ "*.pb.h"
17
+ ],
18
+ "publicApiPatterns": [
19
+ {
20
+ "id": "class",
21
+ "regex": "\\b(?:class|struct)\\s+([A-Z][A-Za-z0-9_]*)\\s*(?:final\\s*)?(?::[^;{]*)?\\{"
22
+ }
23
+ ],
24
+ "hint": "Cover each class with a test that includes its header. A free function is covered through the public entry point that calls it."
25
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "stack": "csharp",
4
+ "description": "C# test gap rules. Sources in *.cs; tests sit in a sibling project named *.Tests or *Tests with a Tests or Test suffix on the class file.",
5
+ "sourceExtensions": [".cs"],
6
+ "testPathSuffixes": ["Tests.cs", "Test.cs"],
7
+ "testPathContains": [".Tests/", "Tests/", ".Test/"],
8
+ "excludePathGlobs": ["bin/", "obj/", "*.g.cs", "*.Designer.cs", "*.generated.cs", "Migrations/"],
9
+ "publicApiPatterns": [
10
+ {
11
+ "id": "public_type",
12
+ "regex": "\\bpublic\\s+(?:static\\s+|abstract\\s+|sealed\\s+|partial\\s+)*(?:class|interface|struct|enum|record)\\s+([A-Z][A-Za-z0-9_]*)"
13
+ },
14
+ {
15
+ "id": "public_method",
16
+ "regex": "\\bpublic\\s+(?:static\\s+|virtual\\s+|override\\s+|async\\s+)*[\\w<>\\[\\],.? ]+\\s+([A-Z][A-Za-z0-9_]*)\\s*\\("
17
+ }
18
+ ],
19
+ "hint": "Cover public types and methods with a test class named <Type>Tests in the matching test project."
20
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "stack": "java",
4
+ "description": "Java test gap rules for Maven and Gradle projects. Sources in src/main/java, tests in src/test/java with a Test, Tests or IT suffix.",
5
+ "sourceExtensions": [".java"],
6
+ "testPathSuffixes": ["Test.java", "Tests.java", "IT.java"],
7
+ "testPathContains": ["/src/test/", "/src/integrationTest/"],
8
+ "excludePathGlobs": ["build/", "target/", ".gradle/", "generated/", "out/"],
9
+ "publicApiPatterns": [
10
+ {
11
+ "id": "public_class",
12
+ "regex": "\\bpublic\\s+(?:abstract\\s+|final\\s+)?(?:class|interface|enum|record)\\s+([A-Z][A-Za-z0-9_]*)"
13
+ },
14
+ {
15
+ "id": "public_method",
16
+ "regex": "\\bpublic\\s+(?:static\\s+)?(?:final\\s+)?[\\w<>\\[\\],.? ]+\\s+([a-z_][A-Za-z0-9_]*)\\s*\\("
17
+ }
18
+ ],
19
+ "hint": "Cover public types and methods with a JUnit test named <Type>Test in the mirrored package under src/test/java."
20
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "stack": "rust",
4
+ "description": "Rust test gap rules. Sources in *.rs; integration tests live under tests/ and unit tests sit in the same file under #[cfg(test)], which is why the suffix list is short.",
5
+ "sourceExtensions": [".rs"],
6
+ "testPathSuffixes": ["_test.rs", "_tests.rs"],
7
+ "testPathContains": ["/tests/", "/benches/"],
8
+ "excludePathGlobs": ["target/", "vendor/", "third_party/"],
9
+ "publicApiPatterns": [
10
+ { "id": "pub_fn", "regex": "^\\s*pub\\s+(?:async\\s+)?fn\\s+([a-z_][A-Za-z0-9_]*)" },
11
+ { "id": "pub_type", "regex": "^\\s*pub\\s+(?:struct|enum|trait)\\s+([A-Z][A-Za-z0-9_]*)" }
12
+ ],
13
+ "hint": "Cover public items with a #[test] in the same module or an integration test under tests/. A private function is covered through the public one that calls it."
14
+ }