audrey 0.23.1 → 1.0.1

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 (250) hide show
  1. package/CHANGELOG.md +101 -15
  2. package/LICENSE +21 -21
  3. package/README.md +232 -6
  4. package/SECURITY.md +2 -1
  5. package/benchmarks/adapter-kit.mjs +20 -0
  6. package/benchmarks/adapter-self-test.mjs +166 -0
  7. package/benchmarks/adapters/example-allow.mjs +28 -0
  8. package/benchmarks/adapters/mem0-platform.mjs +267 -0
  9. package/benchmarks/adapters/registry.json +51 -0
  10. package/benchmarks/adapters/zep-cloud.mjs +280 -0
  11. package/benchmarks/baselines.js +169 -0
  12. package/benchmarks/build-leaderboard.mjs +170 -0
  13. package/benchmarks/cases.js +537 -0
  14. package/benchmarks/create-conformance-card.mjs +139 -0
  15. package/benchmarks/create-submission-bundle.mjs +176 -0
  16. package/benchmarks/dry-run-external-adapters.mjs +165 -0
  17. package/benchmarks/guardbench.js +1125 -0
  18. package/benchmarks/output/adapter-self-test/guardbench-adapter-self-test.json +50 -0
  19. package/benchmarks/output/external/guardbench-external-dry-run.json +69 -0
  20. package/benchmarks/output/external/guardbench-external-evidence.json +56 -0
  21. package/benchmarks/output/guardbench-conformance-card.json +63 -0
  22. package/benchmarks/output/guardbench-manifest.json +414 -0
  23. package/benchmarks/output/guardbench-raw.json +1271 -0
  24. package/benchmarks/output/guardbench-summary.json +2107 -0
  25. package/benchmarks/output/leaderboard/guardbench-leaderboard.json +93 -0
  26. package/benchmarks/output/leaderboard/guardbench-leaderboard.md +7 -0
  27. package/benchmarks/output/submission-bundle/guardbench-conformance-card.json +63 -0
  28. package/benchmarks/output/submission-bundle/guardbench-manifest.json +414 -0
  29. package/benchmarks/output/submission-bundle/guardbench-raw.json +1271 -0
  30. package/benchmarks/output/submission-bundle/guardbench-summary.json +2107 -0
  31. package/benchmarks/output/submission-bundle/schemas/guardbench-adapter-registry.schema.json +69 -0
  32. package/benchmarks/output/submission-bundle/schemas/guardbench-adapter-self-test.schema.json +156 -0
  33. package/benchmarks/output/submission-bundle/schemas/guardbench-conformance-card.schema.json +184 -0
  34. package/benchmarks/output/submission-bundle/schemas/guardbench-external-dry-run.schema.json +74 -0
  35. package/benchmarks/output/submission-bundle/schemas/guardbench-external-evidence.schema.json +108 -0
  36. package/benchmarks/output/submission-bundle/schemas/guardbench-external-run.schema.json +160 -0
  37. package/benchmarks/output/submission-bundle/schemas/guardbench-leaderboard.schema.json +179 -0
  38. package/benchmarks/output/submission-bundle/schemas/guardbench-manifest.schema.json +213 -0
  39. package/benchmarks/output/submission-bundle/schemas/guardbench-publication-verification.schema.json +47 -0
  40. package/benchmarks/output/submission-bundle/schemas/guardbench-raw.schema.json +184 -0
  41. package/benchmarks/output/submission-bundle/schemas/guardbench-submission-manifest.schema.json +151 -0
  42. package/benchmarks/output/submission-bundle/schemas/guardbench-summary.schema.json +249 -0
  43. package/benchmarks/output/submission-bundle/submission-manifest.json +131 -0
  44. package/benchmarks/output/submission-bundle/validation-report.json +31 -0
  45. package/benchmarks/output/summary.json +2354 -0
  46. package/benchmarks/perf-snapshot.js +304 -0
  47. package/benchmarks/perf.bench.js +161 -0
  48. package/benchmarks/public-paths.mjs +78 -0
  49. package/benchmarks/reference-results.js +70 -0
  50. package/benchmarks/report.js +259 -0
  51. package/benchmarks/run-external-guardbench.mjs +281 -0
  52. package/benchmarks/run.js +682 -0
  53. package/benchmarks/schemas/guardbench-adapter-registry.schema.json +69 -0
  54. package/benchmarks/schemas/guardbench-adapter-self-test.schema.json +156 -0
  55. package/benchmarks/schemas/guardbench-conformance-card.schema.json +184 -0
  56. package/benchmarks/schemas/guardbench-external-dry-run.schema.json +74 -0
  57. package/benchmarks/schemas/guardbench-external-evidence.schema.json +108 -0
  58. package/benchmarks/schemas/guardbench-external-run.schema.json +160 -0
  59. package/benchmarks/schemas/guardbench-leaderboard.schema.json +179 -0
  60. package/benchmarks/schemas/guardbench-manifest.schema.json +213 -0
  61. package/benchmarks/schemas/guardbench-publication-verification.schema.json +47 -0
  62. package/benchmarks/schemas/guardbench-raw.schema.json +184 -0
  63. package/benchmarks/schemas/guardbench-submission-manifest.schema.json +151 -0
  64. package/benchmarks/schemas/guardbench-summary.schema.json +249 -0
  65. package/benchmarks/snapshots/perf-0.22.2.json +123 -0
  66. package/benchmarks/snapshots/perf-0.23.0.json +123 -0
  67. package/benchmarks/validate-adapter-module.mjs +104 -0
  68. package/benchmarks/validate-adapter-registry.mjs +134 -0
  69. package/benchmarks/validate-adapter-self-test.mjs +96 -0
  70. package/benchmarks/validate-guardbench-artifacts.mjs +343 -0
  71. package/benchmarks/verify-external-evidence.mjs +296 -0
  72. package/benchmarks/verify-publication-artifacts.mjs +286 -0
  73. package/benchmarks/verify-submission-bundle.mjs +167 -0
  74. package/dist/mcp-server/config.d.ts +1 -1
  75. package/dist/mcp-server/config.d.ts.map +1 -1
  76. package/dist/mcp-server/config.js +1 -1
  77. package/dist/mcp-server/config.js.map +1 -1
  78. package/dist/mcp-server/index.d.ts +65 -3
  79. package/dist/mcp-server/index.d.ts.map +1 -1
  80. package/dist/mcp-server/index.js +675 -157
  81. package/dist/mcp-server/index.js.map +1 -1
  82. package/dist/src/action-key.d.ts +9 -0
  83. package/dist/src/action-key.d.ts.map +1 -0
  84. package/dist/src/action-key.js +49 -0
  85. package/dist/src/action-key.js.map +1 -0
  86. package/dist/src/adaptive.js +5 -5
  87. package/dist/src/affect.js +8 -8
  88. package/dist/src/audrey.d.ts +13 -0
  89. package/dist/src/audrey.d.ts.map +1 -1
  90. package/dist/src/audrey.js +68 -3
  91. package/dist/src/audrey.js.map +1 -1
  92. package/dist/src/capsule.js +4 -4
  93. package/dist/src/causal.js +3 -3
  94. package/dist/src/consolidate.js +48 -48
  95. package/dist/src/controller.d.ts +78 -6
  96. package/dist/src/controller.d.ts.map +1 -1
  97. package/dist/src/controller.js +273 -53
  98. package/dist/src/controller.js.map +1 -1
  99. package/dist/src/db.js +172 -172
  100. package/dist/src/decay.js +8 -8
  101. package/dist/src/embedding.d.ts +2 -1
  102. package/dist/src/embedding.d.ts.map +1 -1
  103. package/dist/src/embedding.js +39 -29
  104. package/dist/src/embedding.js.map +1 -1
  105. package/dist/src/encode.js +6 -6
  106. package/dist/src/feedback.d.ts +6 -0
  107. package/dist/src/feedback.d.ts.map +1 -1
  108. package/dist/src/feedback.js +6 -0
  109. package/dist/src/feedback.js.map +1 -1
  110. package/dist/src/forget.js +12 -12
  111. package/dist/src/hybrid-recall.js +9 -9
  112. package/dist/src/impact.js +6 -6
  113. package/dist/src/import.d.ts +3 -3
  114. package/dist/src/import.js +41 -41
  115. package/dist/src/index.d.ts +5 -4
  116. package/dist/src/index.d.ts.map +1 -1
  117. package/dist/src/index.js +3 -3
  118. package/dist/src/index.js.map +1 -1
  119. package/dist/src/interference.js +14 -14
  120. package/dist/src/introspect.js +18 -18
  121. package/dist/src/preflight.d.ts.map +1 -1
  122. package/dist/src/preflight.js +41 -0
  123. package/dist/src/preflight.js.map +1 -1
  124. package/dist/src/promote.js +7 -7
  125. package/dist/src/prompts.js +118 -118
  126. package/dist/src/recall.js +30 -30
  127. package/dist/src/reflexes.d.ts +1 -0
  128. package/dist/src/reflexes.d.ts.map +1 -1
  129. package/dist/src/reflexes.js +3 -0
  130. package/dist/src/reflexes.js.map +1 -1
  131. package/dist/src/rollback.js +4 -4
  132. package/dist/src/routes.d.ts.map +1 -1
  133. package/dist/src/routes.js +71 -2
  134. package/dist/src/routes.js.map +1 -1
  135. package/dist/src/validate.js +25 -25
  136. package/docs/AUDREY_PAPER_OUTLINE.md +175 -0
  137. package/docs/MEMORY_BENCHMARKING.md +59 -0
  138. package/docs/PRODUCTION_BACKLOG.md +304 -0
  139. package/docs/paper/00-master.md +48 -0
  140. package/docs/paper/01-introduction.md +27 -0
  141. package/docs/paper/02-related-work.md +47 -0
  142. package/docs/paper/03-problem-definition.md +108 -0
  143. package/docs/paper/04-design.md +164 -0
  144. package/docs/paper/05-guardbench-spec.md +412 -0
  145. package/docs/paper/06-implementation.md +113 -0
  146. package/docs/paper/07-evaluation.md +168 -0
  147. package/docs/paper/08-discussion-limitations.md +61 -0
  148. package/docs/paper/09-conclusion.md +11 -0
  149. package/docs/paper/SUBMISSION_README.md +162 -0
  150. package/docs/paper/appendix-a-demo-transcript.md +114 -0
  151. package/docs/paper/arxiv-compile-report.schema.json +116 -0
  152. package/docs/paper/arxiv-source.schema.json +61 -0
  153. package/docs/paper/audrey-paper-v1.md +1106 -0
  154. package/docs/paper/browser-launch-plan.json +209 -0
  155. package/docs/paper/browser-launch-plan.schema.json +100 -0
  156. package/docs/paper/browser-launch-results.json +86 -0
  157. package/docs/paper/browser-launch-results.schema.json +66 -0
  158. package/docs/paper/claim-register.json +138 -0
  159. package/docs/paper/claim-register.schema.json +81 -0
  160. package/docs/paper/evidence-ledger.md +103 -0
  161. package/docs/paper/output/arxiv/README-arxiv.txt +8 -0
  162. package/docs/paper/output/arxiv/arxiv-manifest.json +41 -0
  163. package/docs/paper/output/arxiv/main.tex +949 -0
  164. package/docs/paper/output/arxiv/references.bib +222 -0
  165. package/docs/paper/output/arxiv-compile-report.json +24 -0
  166. package/docs/paper/output/submission-bundle/LICENSE +21 -0
  167. package/docs/paper/output/submission-bundle/README.md +555 -0
  168. package/docs/paper/output/submission-bundle/benchmarks/output/adapter-self-test/guardbench-adapter-self-test.json +50 -0
  169. package/docs/paper/output/submission-bundle/benchmarks/output/external/guardbench-external-dry-run.json +69 -0
  170. package/docs/paper/output/submission-bundle/benchmarks/output/external/guardbench-external-evidence.json +56 -0
  171. package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-conformance-card.json +63 -0
  172. package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-manifest.json +414 -0
  173. package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-raw.json +1271 -0
  174. package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-summary.json +2107 -0
  175. package/docs/paper/output/submission-bundle/benchmarks/output/leaderboard/guardbench-leaderboard.json +93 -0
  176. package/docs/paper/output/submission-bundle/benchmarks/output/leaderboard/guardbench-leaderboard.md +7 -0
  177. package/docs/paper/output/submission-bundle/benchmarks/output/submission-bundle/submission-manifest.json +131 -0
  178. package/docs/paper/output/submission-bundle/benchmarks/output/submission-bundle/validation-report.json +31 -0
  179. package/docs/paper/output/submission-bundle/benchmarks/output/summary.json +2354 -0
  180. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-adapter-registry.schema.json +69 -0
  181. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-adapter-self-test.schema.json +156 -0
  182. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-conformance-card.schema.json +184 -0
  183. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-external-dry-run.schema.json +74 -0
  184. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-external-evidence.schema.json +108 -0
  185. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-external-run.schema.json +160 -0
  186. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-leaderboard.schema.json +179 -0
  187. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-manifest.schema.json +213 -0
  188. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-publication-verification.schema.json +47 -0
  189. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-raw.schema.json +184 -0
  190. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-submission-manifest.schema.json +151 -0
  191. package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-summary.schema.json +249 -0
  192. package/docs/paper/output/submission-bundle/docs/AUDREY_PAPER_OUTLINE.md +175 -0
  193. package/docs/paper/output/submission-bundle/docs/paper/00-master.md +48 -0
  194. package/docs/paper/output/submission-bundle/docs/paper/01-introduction.md +27 -0
  195. package/docs/paper/output/submission-bundle/docs/paper/02-related-work.md +47 -0
  196. package/docs/paper/output/submission-bundle/docs/paper/03-problem-definition.md +108 -0
  197. package/docs/paper/output/submission-bundle/docs/paper/04-design.md +164 -0
  198. package/docs/paper/output/submission-bundle/docs/paper/05-guardbench-spec.md +412 -0
  199. package/docs/paper/output/submission-bundle/docs/paper/06-implementation.md +113 -0
  200. package/docs/paper/output/submission-bundle/docs/paper/07-evaluation.md +168 -0
  201. package/docs/paper/output/submission-bundle/docs/paper/08-discussion-limitations.md +61 -0
  202. package/docs/paper/output/submission-bundle/docs/paper/09-conclusion.md +11 -0
  203. package/docs/paper/output/submission-bundle/docs/paper/SUBMISSION_README.md +162 -0
  204. package/docs/paper/output/submission-bundle/docs/paper/appendix-a-demo-transcript.md +114 -0
  205. package/docs/paper/output/submission-bundle/docs/paper/arxiv-compile-report.schema.json +116 -0
  206. package/docs/paper/output/submission-bundle/docs/paper/arxiv-source.schema.json +61 -0
  207. package/docs/paper/output/submission-bundle/docs/paper/audrey-paper-v1.md +1106 -0
  208. package/docs/paper/output/submission-bundle/docs/paper/browser-launch-plan.json +209 -0
  209. package/docs/paper/output/submission-bundle/docs/paper/browser-launch-plan.schema.json +100 -0
  210. package/docs/paper/output/submission-bundle/docs/paper/browser-launch-results.json +86 -0
  211. package/docs/paper/output/submission-bundle/docs/paper/browser-launch-results.schema.json +66 -0
  212. package/docs/paper/output/submission-bundle/docs/paper/claim-register.json +138 -0
  213. package/docs/paper/output/submission-bundle/docs/paper/claim-register.schema.json +81 -0
  214. package/docs/paper/output/submission-bundle/docs/paper/evidence-ledger.md +103 -0
  215. package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/README-arxiv.txt +8 -0
  216. package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/arxiv-manifest.json +41 -0
  217. package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/main.tex +949 -0
  218. package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/references.bib +222 -0
  219. package/docs/paper/output/submission-bundle/docs/paper/output/arxiv-compile-report.json +24 -0
  220. package/docs/paper/output/submission-bundle/docs/paper/paper-submission-bundle.schema.json +70 -0
  221. package/docs/paper/output/submission-bundle/docs/paper/publication-pack.json +81 -0
  222. package/docs/paper/output/submission-bundle/docs/paper/publication-pack.schema.json +60 -0
  223. package/docs/paper/output/submission-bundle/docs/paper/references.bib +222 -0
  224. package/docs/paper/output/submission-bundle/package.json +212 -0
  225. package/docs/paper/output/submission-bundle/paper-submission-manifest.json +379 -0
  226. package/docs/paper/paper-submission-bundle.schema.json +70 -0
  227. package/docs/paper/publication-pack.json +81 -0
  228. package/docs/paper/publication-pack.schema.json +60 -0
  229. package/docs/paper/references.bib +222 -0
  230. package/package.json +87 -4
  231. package/scripts/audit-release-completion.mjs +362 -0
  232. package/scripts/create-arxiv-source.mjs +362 -0
  233. package/scripts/create-paper-submission-bundle.mjs +210 -0
  234. package/scripts/finalize-release.mjs +526 -0
  235. package/scripts/prepare-release-cut.mjs +269 -0
  236. package/scripts/publish-release-bundle.mjs +209 -0
  237. package/scripts/publish-release-github-api.mjs +429 -0
  238. package/scripts/run-vitest.mjs +34 -0
  239. package/scripts/smoke-cli.js +92 -0
  240. package/scripts/sync-paper-artifacts.mjs +109 -0
  241. package/scripts/verify-arxiv-compile.mjs +440 -0
  242. package/scripts/verify-arxiv-source.mjs +194 -0
  243. package/scripts/verify-browser-launch-plan.mjs +237 -0
  244. package/scripts/verify-browser-launch-results.mjs +285 -0
  245. package/scripts/verify-paper-artifacts.mjs +338 -0
  246. package/scripts/verify-paper-claims.mjs +226 -0
  247. package/scripts/verify-paper-submission-bundle.mjs +207 -0
  248. package/scripts/verify-publication-pack.mjs +196 -0
  249. package/scripts/verify-python-package.py +201 -0
  250. package/scripts/verify-release-readiness.mjs +785 -0
@@ -0,0 +1,269 @@
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const ROOT = process.cwd();
6
+ const DEFAULT_TARGET_VERSION = '1.0.0';
7
+ const VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
8
+
9
+ function fromRoot(path) {
10
+ return resolve(ROOT, path);
11
+ }
12
+
13
+ function readText(path) {
14
+ const absolute = fromRoot(path);
15
+ if (!existsSync(absolute)) throw new Error(`Missing required file: ${path}`);
16
+ return readFileSync(absolute, 'utf-8');
17
+ }
18
+
19
+ function writeText(path, content) {
20
+ writeFileSync(fromRoot(path), content, 'utf-8');
21
+ }
22
+
23
+ function readJson(path) {
24
+ return JSON.parse(readText(path));
25
+ }
26
+
27
+ function parseArgs(argv = process.argv.slice(2)) {
28
+ const args = {
29
+ targetVersion: DEFAULT_TARGET_VERSION,
30
+ date: new Date().toISOString().slice(0, 10),
31
+ apply: false,
32
+ json: false,
33
+ };
34
+
35
+ for (let i = 0; i < argv.length; i++) {
36
+ const token = argv[i];
37
+ if ((token === '--target-version' || token === '--version') && argv[i + 1]) args.targetVersion = argv[++i];
38
+ else if (token === '--date' && argv[i + 1]) args.date = argv[++i];
39
+ else if (token === '--apply') args.apply = true;
40
+ else if (token === '--json') args.json = true;
41
+ else if (token === '--help' || token === '-h') args.help = true;
42
+ else throw new Error(`Unknown argument: ${token}`);
43
+ }
44
+
45
+ return args;
46
+ }
47
+
48
+ function usage() {
49
+ return `Usage: node scripts/prepare-release-cut.mjs [options]
50
+
51
+ Options:
52
+ --target-version <version> Target release version. Default: ${DEFAULT_TARGET_VERSION}.
53
+ --date <YYYY-MM-DD> Changelog date. Default: today.
54
+ --apply Write the planned release-cut edits. Dry-run by default.
55
+ --json Print the machine-readable plan.
56
+ `;
57
+ }
58
+
59
+ function assertValidVersion(version) {
60
+ if (!VERSION_RE.test(version)) throw new Error(`Invalid semver version: ${version}`);
61
+ }
62
+
63
+ function compareCoreVersions(a, b) {
64
+ const pa = a.split(/[+-]/)[0].split('.').map(Number);
65
+ const pb = b.split(/[+-]/)[0].split('.').map(Number);
66
+ for (let i = 0; i < 3; i++) {
67
+ if (pa[i] !== pb[i]) return Math.sign(pa[i] - pb[i]);
68
+ }
69
+ return 0;
70
+ }
71
+
72
+ function currentVersionSnapshot() {
73
+ const pkg = readJson('package.json');
74
+ const lock = readJson('package-lock.json');
75
+ const config = readText('mcp-server/config.ts');
76
+ const python = readText('python/audrey_memory/_version.py');
77
+ return {
78
+ packageJson: pkg.version,
79
+ packageLock: lock.version,
80
+ packageLockRoot: lock.packages?.['']?.version,
81
+ mcpConfig: config.match(/export const VERSION = '([^']+)'/)?.[1] ?? null,
82
+ python: python.match(/__version__\s*=\s*"([^"]+)"/)?.[1] ?? null,
83
+ };
84
+ }
85
+
86
+ function replaceOnce(text, pattern, replacement, label) {
87
+ let count = 0;
88
+ const next = text.replace(pattern, (...args) => {
89
+ count += 1;
90
+ return typeof replacement === 'function' ? replacement(...args) : replacement;
91
+ });
92
+ if (count !== 1) throw new Error(`Expected one ${label} replacement, found ${count}`);
93
+ return next;
94
+ }
95
+
96
+ function updatePackageJson(targetVersion) {
97
+ const pkg = readJson('package.json');
98
+ pkg.version = targetVersion;
99
+ return `${JSON.stringify(pkg, null, 2)}\n`;
100
+ }
101
+
102
+ function updatePackageLock(targetVersion) {
103
+ const lock = readJson('package-lock.json');
104
+ lock.version = targetVersion;
105
+ if (!lock.packages?.['']) throw new Error('package-lock.json is missing packages[""]');
106
+ lock.packages[''].version = targetVersion;
107
+ return `${JSON.stringify(lock, null, 2)}\n`;
108
+ }
109
+
110
+ function updateMcpConfig(targetVersion) {
111
+ return replaceOnce(
112
+ readText('mcp-server/config.ts'),
113
+ /export const VERSION = '[^']+';/,
114
+ `export const VERSION = '${targetVersion}';`,
115
+ 'mcp VERSION',
116
+ );
117
+ }
118
+
119
+ function updatePythonVersion(targetVersion) {
120
+ return replaceOnce(
121
+ readText('python/audrey_memory/_version.py'),
122
+ /__version__\s*=\s*"[^"]+"/,
123
+ `__version__ = "${targetVersion}"`,
124
+ 'Python __version__',
125
+ );
126
+ }
127
+
128
+ function targetChangelogHeader(targetVersion) {
129
+ return `## ${targetVersion} - `;
130
+ }
131
+
132
+ export function releaseChangelogSection(targetVersion, date) {
133
+ return `## ${targetVersion} - ${date}
134
+
135
+ ### Audrey Guard
136
+
137
+ - Adds the Memory Controller layer and \`audrey guard\` CLI for memory-before-action decisions that return allow, warn, or block with evidence.
138
+ - Adds Claude Code hook generation and hook-stdin support so pre-tool checks and post-tool traces can run inside real agent sessions.
139
+ - Binds validation feedback to preflight event ids, evidence ids, and Guard action fingerprints so remembered guidance can be audited after use.
140
+
141
+ ### GuardBench And Paper Artifacts
142
+
143
+ - Ships GuardBench, a local comparative benchmark for pre-action memory control with Audrey Guard, no-memory, recent-window, vector-only, and FTS-only baselines.
144
+ - Adds portable GuardBench submission bundles, conformance cards, JSON schemas, adapter self-tests, leaderboard generation, and external adapter evidence reports.
145
+ - Adds Mem0 Platform and Zep Cloud adapter runners that use runtime-only API keys and keep dry-run evidence separate from live external scores.
146
+ - Ships the Audrey Guard paper source, claim register, launch-copy verifier, browser launch plan/results ledger, deterministic arXiv source package, and paper submission bundle.
147
+
148
+ ### Release Controls
149
+
150
+ - Adds the pending-aware \`release:readiness\` verifier and strict \`release:readiness:strict\` gate for the final 1.0 cut.
151
+ - Adds \`release:cut:plan\` and \`release:cut:apply\` so npm, lockfile, MCP, Python, and changelog version surfaces are cut consistently.
152
+ - Adds production dependency audit coverage to the release gates and keeps the current production audit clean.
153
+
154
+ ### Runtime And Client Hardening
155
+
156
+ - Improves recall degradation reporting across capsules, strict preflights, status surfaces, and Guard decisions.
157
+ - Batches embedding provider calls in \`encodeBatch\` and tightens exact-failure matching, redaction, action fingerprinting, and control-memory recall.
158
+ - Hardens Docker/API configuration, Python client behavior, MCP surfaces, and test execution on locked-down Windows hosts.
159
+
160
+ `;
161
+ }
162
+
163
+ export function insertChangelogSection(changelog, targetVersion, date) {
164
+ if (changelog.includes(targetChangelogHeader(targetVersion))) return changelog;
165
+ return replaceOnce(
166
+ changelog,
167
+ /(# Changelog\r?\n\r?\n)/,
168
+ match => `${match}${releaseChangelogSection(targetVersion, date)}`,
169
+ 'changelog insertion point',
170
+ );
171
+ }
172
+
173
+ function updateChangelog(targetVersion, date) {
174
+ return insertChangelogSection(readText('CHANGELOG.md'), targetVersion, date);
175
+ }
176
+
177
+ function plannedFiles(targetVersion, date) {
178
+ return [
179
+ ['package.json', updatePackageJson(targetVersion)],
180
+ ['package-lock.json', updatePackageLock(targetVersion)],
181
+ ['mcp-server/config.ts', updateMcpConfig(targetVersion)],
182
+ ['python/audrey_memory/_version.py', updatePythonVersion(targetVersion)],
183
+ ['CHANGELOG.md', updateChangelog(targetVersion, date)],
184
+ ];
185
+ }
186
+
187
+ function changeSummary(path, before, after) {
188
+ return {
189
+ path,
190
+ changed: before !== after,
191
+ beforeBytes: Buffer.byteLength(before),
192
+ afterBytes: Buffer.byteLength(after),
193
+ };
194
+ }
195
+
196
+ export function prepareReleaseCut(options = {}) {
197
+ const targetVersion = options.targetVersion ?? DEFAULT_TARGET_VERSION;
198
+ const date = options.date ?? new Date().toISOString().slice(0, 10);
199
+ const apply = options.apply === true;
200
+ assertValidVersion(targetVersion);
201
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) throw new Error(`Invalid release date: ${date}`);
202
+
203
+ const versions = currentVersionSnapshot();
204
+ const versionValues = Object.values(versions);
205
+ const failures = [];
206
+ if (versionValues.some(value => !value)) failures.push('One or more release version surfaces are missing');
207
+ if (new Set(versionValues).size !== 1) failures.push(`Release version surfaces are not aligned: ${JSON.stringify(versions)}`);
208
+ if (versions.packageJson && compareCoreVersions(targetVersion, versions.packageJson) < 0) {
209
+ failures.push(`Target version ${targetVersion} is lower than current package version ${versions.packageJson}`);
210
+ }
211
+
212
+ const files = plannedFiles(targetVersion, date).map(([path, after]) => {
213
+ const before = readText(path);
214
+ return { ...changeSummary(path, before, after), content: after };
215
+ });
216
+
217
+ if (apply && failures.length === 0) {
218
+ for (const file of files) {
219
+ if (file.changed) writeText(file.path, file.content);
220
+ }
221
+ }
222
+
223
+ return {
224
+ schemaVersion: '1.0.0',
225
+ suite: 'Audrey release cut preparation',
226
+ generatedAt: new Date().toISOString(),
227
+ targetVersion,
228
+ date,
229
+ apply,
230
+ ok: failures.length === 0,
231
+ currentVersions: versions,
232
+ files: files.map(({ content, ...file }) => file),
233
+ nextCommands: [
234
+ 'npm run release:gate:paper',
235
+ 'npm run release:readiness:strict -- --json',
236
+ 'npm run python:release:check',
237
+ ],
238
+ failures,
239
+ };
240
+ }
241
+
242
+ async function main() {
243
+ const args = parseArgs();
244
+ if (args.help) {
245
+ console.log(usage());
246
+ return;
247
+ }
248
+
249
+ const report = prepareReleaseCut(args);
250
+ if (args.json) {
251
+ console.log(JSON.stringify(report, null, 2));
252
+ } else if (report.ok) {
253
+ const changed = report.files.filter(file => file.changed).map(file => file.path);
254
+ console.log(`${report.apply ? 'Applied' : 'Planned'} Audrey ${report.targetVersion} release cut: ${changed.length} file(s)`);
255
+ for (const file of changed) console.log(`- ${file}`);
256
+ } else {
257
+ console.error('Release cut preparation failed:');
258
+ for (const failure of report.failures) console.error(`- ${failure}`);
259
+ }
260
+
261
+ if (!report.ok) process.exit(1);
262
+ }
263
+
264
+ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
265
+ main().catch(error => {
266
+ console.error(error.stack ?? error.message);
267
+ process.exit(1);
268
+ });
269
+ }
@@ -0,0 +1,209 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { mkdtempSync, rmSync } from 'node:fs';
4
+ import { tmpdir } from 'node:os';
5
+ import { join, resolve } from 'node:path';
6
+ import { spawnSync } from 'node:child_process';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const ROOT = process.cwd();
10
+ const DEFAULT_VERSION = '1.0.0';
11
+ const DEFAULT_BUNDLE = '.tmp/release-artifacts/audrey-1.0.0.git.bundle';
12
+ const DEFAULT_REMOTE = 'https://github.com/Evilander/Audrey.git';
13
+
14
+ function parseArgs(argv = process.argv.slice(2)) {
15
+ const args = {
16
+ version: DEFAULT_VERSION,
17
+ bundle: DEFAULT_BUNDLE,
18
+ remote: DEFAULT_REMOTE,
19
+ apply: false,
20
+ json: false,
21
+ };
22
+
23
+ for (let i = 0; i < argv.length; i++) {
24
+ const token = argv[i];
25
+ if ((token === '--version' || token === '--target-version') && argv[i + 1]) args.version = argv[++i];
26
+ else if (token === '--bundle' && argv[i + 1]) args.bundle = argv[++i];
27
+ else if (token === '--remote' && argv[i + 1]) args.remote = argv[++i];
28
+ else if (token === '--apply') args.apply = true;
29
+ else if (token === '--json') args.json = true;
30
+ else if (token === '--help' || token === '-h') args.help = true;
31
+ else throw new Error(`Unknown argument: ${token}`);
32
+ }
33
+
34
+ return args;
35
+ }
36
+
37
+ function usage() {
38
+ return `Usage: node scripts/publish-release-bundle.mjs [options]
39
+
40
+ Options:
41
+ --bundle <path> Release Git bundle. Default: ${DEFAULT_BUNDLE}.
42
+ --remote <url> Push remote. Default: ${DEFAULT_REMOTE}.
43
+ --version <version> Release version. Default: ${DEFAULT_VERSION}.
44
+ --apply Actually push master and v<version>. Dry-run by default.
45
+ --json Print the machine-readable report.
46
+ `;
47
+ }
48
+
49
+ function run(command, args, options = {}) {
50
+ const result = spawnSync(command, args, {
51
+ cwd: options.cwd ?? ROOT,
52
+ encoding: 'utf-8',
53
+ timeout: options.timeout ?? 120_000,
54
+ env: {
55
+ ...process.env,
56
+ GIT_TERMINAL_PROMPT: '0',
57
+ GCM_INTERACTIVE: 'never',
58
+ GIT_ASKPASS: '',
59
+ SSH_ASKPASS: '',
60
+ ...options.env,
61
+ },
62
+ });
63
+ return {
64
+ command: [command, ...args].join(' '),
65
+ ok: result.status === 0,
66
+ status: result.status,
67
+ signal: result.signal ?? null,
68
+ stdout: result.stdout?.trim() ?? '',
69
+ stderr: result.stderr?.trim() ?? '',
70
+ error: result.error?.message ?? null,
71
+ };
72
+ }
73
+
74
+ function firstLine(result) {
75
+ return `${result.stderr}\n${result.stdout}`.split(/\r?\n/).map(line => line.trim()).find(Boolean) ?? '';
76
+ }
77
+
78
+ function parseBundleRefs(output, version) {
79
+ const refs = {};
80
+ for (const line of output.split(/\r?\n/)) {
81
+ const match = line.match(/^([0-9a-f]{40})\s+(refs\/(?:heads\/master|tags\/v[^\s]+))$/);
82
+ if (!match) continue;
83
+ refs[match[2]] = match[1];
84
+ }
85
+ return {
86
+ master: refs['refs/heads/master'] ?? null,
87
+ tag: refs[`refs/tags/v${version}`] ?? null,
88
+ };
89
+ }
90
+
91
+ function parseRemoteRefs(output, version) {
92
+ const refs = {};
93
+ for (const line of output.split(/\r?\n/)) {
94
+ const [sha, ref] = line.trim().split(/\s+/);
95
+ if (sha && ref) refs[ref] = sha;
96
+ }
97
+ return {
98
+ master: refs['refs/heads/master'] ?? null,
99
+ tag: refs[`refs/tags/v${version}`] ?? refs[`refs/tags/v${version}^{}`] ?? null,
100
+ };
101
+ }
102
+
103
+ function remoteHead(args) {
104
+ let result = run('git', ['ls-remote', args.remote, 'refs/heads/master', `refs/tags/v${args.version}`], { timeout: 60_000 });
105
+ if (!result.ok && /schannel|AcquireCredentialsHandle|SEC_E_NO_CREDENTIALS/i.test(firstLine(result))) {
106
+ result = run('git', ['-c', 'http.sslBackend=openssl', 'ls-remote', args.remote, 'refs/heads/master', `refs/tags/v${args.version}`], { timeout: 60_000 });
107
+ result.fallback = 'openssl';
108
+ }
109
+ return result;
110
+ }
111
+
112
+ function publishFromBundle(args, refs) {
113
+ const temp = mkdtempSync(join(tmpdir(), 'audrey-release-push-'));
114
+ try {
115
+ const clone = run('git', ['clone', '--bare', resolve(ROOT, args.bundle), temp], { timeout: 120_000 });
116
+ if (!clone.ok) return [clone];
117
+ const push = run('git', [
118
+ '-c',
119
+ 'http.sslBackend=openssl',
120
+ '-c',
121
+ 'credential.helper=',
122
+ '-c',
123
+ 'core.askPass=',
124
+ 'push',
125
+ args.remote,
126
+ `${refs.master}:refs/heads/master`,
127
+ `${refs.tag}:refs/tags/v${args.version}`,
128
+ ], { cwd: temp, timeout: 45_000 });
129
+ return [clone, push];
130
+ } finally {
131
+ rmSync(temp, { recursive: true, force: true });
132
+ }
133
+ }
134
+
135
+ export function planPublish(args) {
136
+ const verify = run('git', ['bundle', 'verify', args.bundle], { timeout: 60_000 });
137
+ const remote = remoteHead(args);
138
+ const bundleRefs = verify.ok ? parseBundleRefs(verify.stdout, args.version) : { master: null, tag: null };
139
+ const remoteRefs = remote.ok ? parseRemoteRefs(remote.stdout, args.version) : { master: null, tag: null };
140
+ const blockers = [];
141
+
142
+ if (!verify.ok) blockers.push(`Bundle verification failed: ${firstLine(verify)}`);
143
+ if (!bundleRefs.master) blockers.push('Bundle is missing refs/heads/master');
144
+ if (!bundleRefs.tag) blockers.push(`Bundle is missing refs/tags/v${args.version}`);
145
+ if (!remote.ok) blockers.push(`Remote check failed: ${firstLine(remote)}`);
146
+ if (remoteRefs.tag && remoteRefs.tag !== bundleRefs.tag) blockers.push(`Remote v${args.version} already points at ${remoteRefs.tag}`);
147
+ if (remoteRefs.master === bundleRefs.master && remoteRefs.tag === bundleRefs.tag) blockers.push('Remote already matches the release bundle');
148
+
149
+ return {
150
+ schemaVersion: '1.0.0',
151
+ suite: 'Audrey release source publication',
152
+ generatedAt: new Date().toISOString(),
153
+ apply: args.apply,
154
+ version: args.version,
155
+ bundle: args.bundle,
156
+ remote: args.remote,
157
+ bundleRefs,
158
+ remoteRefs,
159
+ checks: {
160
+ bundleVerify: verify,
161
+ remote,
162
+ },
163
+ blockers,
164
+ publishResults: [],
165
+ };
166
+ }
167
+
168
+ async function main() {
169
+ const args = parseArgs();
170
+ if (args.help) {
171
+ console.log(usage());
172
+ return;
173
+ }
174
+
175
+ const report = planPublish(args);
176
+ if (args.apply && report.blockers.length === 0) {
177
+ report.publishResults = publishFromBundle(args, report.bundleRefs);
178
+ for (const result of report.publishResults) {
179
+ if (!result.ok) report.blockers.push(`${result.command} failed: ${firstLine(result)}`);
180
+ }
181
+ }
182
+
183
+ if (args.json) {
184
+ console.log(JSON.stringify(report, null, 2));
185
+ } else {
186
+ console.log(`Audrey source publication plan: apply=${report.apply}`);
187
+ console.log(`bundle master=${report.bundleRefs.master ?? 'missing'}`);
188
+ console.log(`bundle tag=${report.bundleRefs.tag ?? 'missing'}`);
189
+ console.log(`remote master=${report.remoteRefs.master ?? 'missing'}`);
190
+ console.log(`remote tag=${report.remoteRefs.tag ?? 'missing'}`);
191
+ if (report.blockers.length) {
192
+ console.log('Blockers:');
193
+ for (const blocker of report.blockers) console.log(`- ${blocker}`);
194
+ }
195
+ }
196
+
197
+ if (report.blockers.length) process.exit(1);
198
+ }
199
+
200
+ function isDirectRun() {
201
+ return Boolean(process.argv[1]) && resolve(process.argv[1]).toLowerCase() === fileURLToPath(import.meta.url).toLowerCase();
202
+ }
203
+
204
+ if (isDirectRun()) {
205
+ main().catch(error => {
206
+ console.error(error.stack ?? error.message);
207
+ process.exit(1);
208
+ });
209
+ }