audrey 1.1.2 → 1.2.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.
- package/CHANGELOG.md +101 -0
- package/README.md +39 -12
- package/dist/mcp-server/codex-hooks-probe.d.ts +22 -0
- package/dist/mcp-server/codex-hooks-probe.d.ts.map +1 -0
- package/dist/mcp-server/codex-hooks-probe.js +160 -0
- package/dist/mcp-server/codex-hooks-probe.js.map +1 -0
- package/dist/mcp-server/config.d.ts +26 -2
- package/dist/mcp-server/config.d.ts.map +1 -1
- package/dist/mcp-server/config.js +52 -20
- package/dist/mcp-server/config.js.map +1 -1
- package/dist/mcp-server/hooks.d.ts +28 -0
- package/dist/mcp-server/hooks.d.ts.map +1 -1
- package/dist/mcp-server/hooks.js +91 -2
- package/dist/mcp-server/hooks.js.map +1 -1
- package/dist/mcp-server/index.d.ts +242 -2
- package/dist/mcp-server/index.d.ts.map +1 -1
- package/dist/mcp-server/index.js +806 -240
- package/dist/mcp-server/index.js.map +1 -1
- package/dist/mcp-server/tool-schemas.d.ts +32 -2
- package/dist/mcp-server/tool-schemas.d.ts.map +1 -1
- package/dist/mcp-server/tool-schemas.js +55 -0
- package/dist/mcp-server/tool-schemas.js.map +1 -1
- package/dist/src/audrey.d.ts +14 -2
- package/dist/src/audrey.d.ts.map +1 -1
- package/dist/src/audrey.js +152 -28
- package/dist/src/audrey.js.map +1 -1
- package/dist/src/autopilot.d.ts +22 -0
- package/dist/src/autopilot.d.ts.map +1 -1
- package/dist/src/autopilot.js +271 -50
- package/dist/src/autopilot.js.map +1 -1
- package/dist/src/capsule.d.ts +23 -0
- package/dist/src/capsule.d.ts.map +1 -1
- package/dist/src/capsule.js +56 -11
- package/dist/src/capsule.js.map +1 -1
- package/dist/src/confidence.d.ts +9 -1
- package/dist/src/confidence.d.ts.map +1 -1
- package/dist/src/confidence.js +16 -2
- package/dist/src/confidence.js.map +1 -1
- package/dist/src/consolidate.d.ts +4 -0
- package/dist/src/consolidate.d.ts.map +1 -1
- package/dist/src/consolidate.js +206 -34
- package/dist/src/consolidate.js.map +1 -1
- package/dist/src/controller.d.ts +17 -1
- package/dist/src/controller.d.ts.map +1 -1
- package/dist/src/controller.js +244 -128
- package/dist/src/controller.js.map +1 -1
- package/dist/src/db.d.ts.map +1 -1
- package/dist/src/db.js +233 -56
- package/dist/src/db.js.map +1 -1
- package/dist/src/encode.d.ts +2 -1
- package/dist/src/encode.d.ts.map +1 -1
- package/dist/src/encode.js +41 -4
- package/dist/src/encode.js.map +1 -1
- package/dist/src/events.d.ts +48 -1
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/events.js +160 -62
- package/dist/src/events.js.map +1 -1
- package/dist/src/export.d.ts.map +1 -1
- package/dist/src/export.js +4 -4
- package/dist/src/export.js.map +1 -1
- package/dist/src/grounding.d.ts +111 -0
- package/dist/src/grounding.d.ts.map +1 -0
- package/dist/src/grounding.js +259 -0
- package/dist/src/grounding.js.map +1 -0
- package/dist/src/hybrid-recall.d.ts +16 -7
- package/dist/src/hybrid-recall.d.ts.map +1 -1
- package/dist/src/hybrid-recall.js +22 -11
- package/dist/src/hybrid-recall.js.map +1 -1
- package/dist/src/import.d.ts +10 -0
- package/dist/src/import.d.ts.map +1 -1
- package/dist/src/import.js +122 -22
- package/dist/src/import.js.map +1 -1
- package/dist/src/llm.d.ts.map +1 -1
- package/dist/src/llm.js +16 -0
- package/dist/src/llm.js.map +1 -1
- package/dist/src/preflight.d.ts.map +1 -1
- package/dist/src/preflight.js +89 -47
- package/dist/src/preflight.js.map +1 -1
- package/dist/src/project.d.ts +4 -1
- package/dist/src/project.d.ts.map +1 -1
- package/dist/src/project.js +65 -5
- package/dist/src/project.js.map +1 -1
- package/dist/src/recall.d.ts.map +1 -1
- package/dist/src/recall.js +138 -13
- package/dist/src/recall.js.map +1 -1
- package/dist/src/redact.d.ts +1 -1
- package/dist/src/redact.d.ts.map +1 -1
- package/dist/src/redact.js +185 -5
- package/dist/src/redact.js.map +1 -1
- package/dist/src/routes.d.ts.map +1 -1
- package/dist/src/routes.js +91 -18
- package/dist/src/routes.js.map +1 -1
- package/dist/src/trust.d.ts +35 -0
- package/dist/src/trust.d.ts.map +1 -0
- package/dist/src/trust.js +77 -0
- package/dist/src/trust.js.map +1 -0
- package/dist/src/types.d.ts +24 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +4 -38
- package/benchmarks/adapter-kit.mjs +0 -20
- package/benchmarks/adapter-self-test.mjs +0 -170
- package/benchmarks/adapters/example-allow.mjs +0 -31
- package/benchmarks/adapters/mem0-platform.mjs +0 -274
- package/benchmarks/adapters/registry.json +0 -51
- package/benchmarks/adapters/zep-cloud.mjs +0 -304
- package/benchmarks/baselines.js +0 -174
- package/benchmarks/build-leaderboard.mjs +0 -183
- package/benchmarks/cases.js +0 -549
- package/benchmarks/create-conformance-card.mjs +0 -148
- package/benchmarks/create-submission-bundle.mjs +0 -190
- package/benchmarks/dry-run-external-adapters.mjs +0 -177
- package/benchmarks/guardbench.js +0 -1265
- package/benchmarks/output/adapter-self-test/guardbench-adapter-self-test.json +0 -50
- package/benchmarks/output/external/guardbench-external-dry-run.json +0 -69
- package/benchmarks/output/external/guardbench-external-evidence.json +0 -56
- package/benchmarks/output/guardbench-conformance-card.json +0 -63
- package/benchmarks/output/guardbench-manifest.json +0 -414
- package/benchmarks/output/guardbench-raw.json +0 -1279
- package/benchmarks/output/guardbench-summary.json +0 -2123
- package/benchmarks/output/leaderboard/guardbench-leaderboard.json +0 -93
- package/benchmarks/output/leaderboard/guardbench-leaderboard.md +0 -7
- package/benchmarks/output/submission-bundle/guardbench-conformance-card.json +0 -63
- package/benchmarks/output/submission-bundle/guardbench-manifest.json +0 -414
- package/benchmarks/output/submission-bundle/guardbench-raw.json +0 -1279
- package/benchmarks/output/submission-bundle/guardbench-summary.json +0 -2123
- package/benchmarks/output/submission-bundle/schemas/guardbench-adapter-registry.schema.json +0 -69
- package/benchmarks/output/submission-bundle/schemas/guardbench-adapter-self-test.schema.json +0 -156
- package/benchmarks/output/submission-bundle/schemas/guardbench-conformance-card.schema.json +0 -184
- package/benchmarks/output/submission-bundle/schemas/guardbench-external-dry-run.schema.json +0 -74
- package/benchmarks/output/submission-bundle/schemas/guardbench-external-evidence.schema.json +0 -108
- package/benchmarks/output/submission-bundle/schemas/guardbench-external-run.schema.json +0 -160
- package/benchmarks/output/submission-bundle/schemas/guardbench-leaderboard.schema.json +0 -179
- package/benchmarks/output/submission-bundle/schemas/guardbench-manifest.schema.json +0 -213
- package/benchmarks/output/submission-bundle/schemas/guardbench-publication-verification.schema.json +0 -47
- package/benchmarks/output/submission-bundle/schemas/guardbench-raw.schema.json +0 -184
- package/benchmarks/output/submission-bundle/schemas/guardbench-submission-manifest.schema.json +0 -151
- package/benchmarks/output/submission-bundle/schemas/guardbench-summary.schema.json +0 -249
- package/benchmarks/output/submission-bundle/submission-manifest.json +0 -131
- package/benchmarks/output/submission-bundle/validation-report.json +0 -31
- package/benchmarks/output/summary.json +0 -2354
- package/benchmarks/perf-snapshot.js +0 -307
- package/benchmarks/perf.bench.js +0 -169
- package/benchmarks/public-paths.mjs +0 -97
- package/benchmarks/reference-results.js +0 -75
- package/benchmarks/report.js +0 -280
- package/benchmarks/run-external-guardbench.mjs +0 -303
- package/benchmarks/run.js +0 -735
- package/benchmarks/schemas/guardbench-adapter-registry.schema.json +0 -69
- package/benchmarks/schemas/guardbench-adapter-self-test.schema.json +0 -156
- package/benchmarks/schemas/guardbench-conformance-card.schema.json +0 -184
- package/benchmarks/schemas/guardbench-external-dry-run.schema.json +0 -74
- package/benchmarks/schemas/guardbench-external-evidence.schema.json +0 -108
- package/benchmarks/schemas/guardbench-external-run.schema.json +0 -160
- package/benchmarks/schemas/guardbench-leaderboard.schema.json +0 -179
- package/benchmarks/schemas/guardbench-manifest.schema.json +0 -213
- package/benchmarks/schemas/guardbench-publication-verification.schema.json +0 -47
- package/benchmarks/schemas/guardbench-raw.schema.json +0 -184
- package/benchmarks/schemas/guardbench-submission-manifest.schema.json +0 -151
- package/benchmarks/schemas/guardbench-summary.schema.json +0 -249
- package/benchmarks/snapshots/perf-0.22.2.json +0 -123
- package/benchmarks/snapshots/perf-0.23.0.json +0 -123
- package/benchmarks/validate-adapter-module.mjs +0 -107
- package/benchmarks/validate-adapter-registry.mjs +0 -145
- package/benchmarks/validate-adapter-self-test.mjs +0 -96
- package/benchmarks/validate-guardbench-artifacts.mjs +0 -400
- package/benchmarks/verify-external-evidence.mjs +0 -351
- package/benchmarks/verify-publication-artifacts.mjs +0 -309
- package/benchmarks/verify-submission-bundle.mjs +0 -172
- package/docs/AUDREY_PAPER_OUTLINE.md +0 -178
- package/docs/MEMORY_BENCHMARKING.md +0 -59
- package/docs/PRODUCTION_BACKLOG.md +0 -321
- package/docs/assets/audrey-feature-grid.jpg +0 -0
- package/docs/assets/audrey-logo.svg +0 -45
- package/docs/assets/audrey-wordmark.png +0 -0
- package/docs/paper/00-master.md +0 -48
- package/docs/paper/01-introduction.md +0 -27
- package/docs/paper/02-related-work.md +0 -47
- package/docs/paper/03-problem-definition.md +0 -108
- package/docs/paper/04-design.md +0 -164
- package/docs/paper/05-guardbench-spec.md +0 -412
- package/docs/paper/06-implementation.md +0 -115
- package/docs/paper/07-evaluation.md +0 -168
- package/docs/paper/08-discussion-limitations.md +0 -61
- package/docs/paper/09-conclusion.md +0 -11
- package/docs/paper/SUBMISSION_README.md +0 -162
- package/docs/paper/appendix-a-demo-transcript.md +0 -114
- package/docs/paper/arxiv-compile-report.schema.json +0 -116
- package/docs/paper/arxiv-source.schema.json +0 -61
- package/docs/paper/audrey-paper-v1.md +0 -1108
- package/docs/paper/browser-launch-plan.json +0 -209
- package/docs/paper/browser-launch-plan.schema.json +0 -100
- package/docs/paper/browser-launch-results.json +0 -86
- package/docs/paper/browser-launch-results.schema.json +0 -66
- package/docs/paper/claim-register.json +0 -138
- package/docs/paper/claim-register.schema.json +0 -81
- package/docs/paper/evidence-ledger.md +0 -103
- package/docs/paper/output/arxiv/README-arxiv.txt +0 -8
- package/docs/paper/output/arxiv/arxiv-manifest.json +0 -41
- package/docs/paper/output/arxiv/main.tex +0 -951
- package/docs/paper/output/arxiv/references.bib +0 -222
- package/docs/paper/output/arxiv-compile-report.json +0 -24
- package/docs/paper/output/submission-bundle/LICENSE +0 -21
- package/docs/paper/output/submission-bundle/README.md +0 -440
- package/docs/paper/output/submission-bundle/benchmarks/output/adapter-self-test/guardbench-adapter-self-test.json +0 -50
- package/docs/paper/output/submission-bundle/benchmarks/output/external/guardbench-external-dry-run.json +0 -69
- package/docs/paper/output/submission-bundle/benchmarks/output/external/guardbench-external-evidence.json +0 -56
- package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-conformance-card.json +0 -63
- package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-manifest.json +0 -414
- package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-raw.json +0 -1279
- package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-summary.json +0 -2123
- package/docs/paper/output/submission-bundle/benchmarks/output/leaderboard/guardbench-leaderboard.json +0 -93
- package/docs/paper/output/submission-bundle/benchmarks/output/leaderboard/guardbench-leaderboard.md +0 -7
- package/docs/paper/output/submission-bundle/benchmarks/output/submission-bundle/submission-manifest.json +0 -131
- package/docs/paper/output/submission-bundle/benchmarks/output/submission-bundle/validation-report.json +0 -31
- package/docs/paper/output/submission-bundle/benchmarks/output/summary.json +0 -2354
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-adapter-registry.schema.json +0 -69
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-adapter-self-test.schema.json +0 -156
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-conformance-card.schema.json +0 -184
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-external-dry-run.schema.json +0 -74
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-external-evidence.schema.json +0 -108
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-external-run.schema.json +0 -160
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-leaderboard.schema.json +0 -179
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-manifest.schema.json +0 -213
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-publication-verification.schema.json +0 -47
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-raw.schema.json +0 -184
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-submission-manifest.schema.json +0 -151
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-summary.schema.json +0 -249
- package/docs/paper/output/submission-bundle/docs/AUDREY_PAPER_OUTLINE.md +0 -178
- package/docs/paper/output/submission-bundle/docs/paper/00-master.md +0 -48
- package/docs/paper/output/submission-bundle/docs/paper/01-introduction.md +0 -27
- package/docs/paper/output/submission-bundle/docs/paper/02-related-work.md +0 -47
- package/docs/paper/output/submission-bundle/docs/paper/03-problem-definition.md +0 -108
- package/docs/paper/output/submission-bundle/docs/paper/04-design.md +0 -164
- package/docs/paper/output/submission-bundle/docs/paper/05-guardbench-spec.md +0 -412
- package/docs/paper/output/submission-bundle/docs/paper/06-implementation.md +0 -115
- package/docs/paper/output/submission-bundle/docs/paper/07-evaluation.md +0 -168
- package/docs/paper/output/submission-bundle/docs/paper/08-discussion-limitations.md +0 -61
- package/docs/paper/output/submission-bundle/docs/paper/09-conclusion.md +0 -11
- package/docs/paper/output/submission-bundle/docs/paper/SUBMISSION_README.md +0 -162
- package/docs/paper/output/submission-bundle/docs/paper/appendix-a-demo-transcript.md +0 -114
- package/docs/paper/output/submission-bundle/docs/paper/arxiv-compile-report.schema.json +0 -116
- package/docs/paper/output/submission-bundle/docs/paper/arxiv-source.schema.json +0 -61
- package/docs/paper/output/submission-bundle/docs/paper/audrey-paper-v1.md +0 -1108
- package/docs/paper/output/submission-bundle/docs/paper/browser-launch-plan.json +0 -209
- package/docs/paper/output/submission-bundle/docs/paper/browser-launch-plan.schema.json +0 -100
- package/docs/paper/output/submission-bundle/docs/paper/browser-launch-results.json +0 -86
- package/docs/paper/output/submission-bundle/docs/paper/browser-launch-results.schema.json +0 -66
- package/docs/paper/output/submission-bundle/docs/paper/claim-register.json +0 -138
- package/docs/paper/output/submission-bundle/docs/paper/claim-register.schema.json +0 -81
- package/docs/paper/output/submission-bundle/docs/paper/evidence-ledger.md +0 -103
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/README-arxiv.txt +0 -8
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/arxiv-manifest.json +0 -41
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/main.tex +0 -951
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/references.bib +0 -222
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv-compile-report.json +0 -24
- package/docs/paper/output/submission-bundle/docs/paper/paper-submission-bundle.schema.json +0 -70
- package/docs/paper/output/submission-bundle/docs/paper/publication-pack.json +0 -81
- package/docs/paper/output/submission-bundle/docs/paper/publication-pack.schema.json +0 -60
- package/docs/paper/output/submission-bundle/docs/paper/references.bib +0 -222
- package/docs/paper/output/submission-bundle/package.json +0 -235
- package/docs/paper/output/submission-bundle/paper-submission-manifest.json +0 -379
- package/docs/paper/paper-submission-bundle.schema.json +0 -70
- package/docs/paper/publication-pack.json +0 -81
- package/docs/paper/publication-pack.schema.json +0 -60
- package/docs/paper/references.bib +0 -222
- package/scripts/audit-release-completion.mjs +0 -440
- package/scripts/create-arxiv-source.mjs +0 -368
- package/scripts/create-paper-submission-bundle.mjs +0 -214
- package/scripts/finalize-release.mjs +0 -601
- package/scripts/prepare-release-cut.mjs +0 -277
- package/scripts/publish-release-bundle.mjs +0 -252
- package/scripts/publish-release-github-api.mjs +0 -494
- package/scripts/run-vitest.mjs +0 -34
- package/scripts/smoke-cli.js +0 -92
- package/scripts/sync-paper-artifacts.mjs +0 -112
- package/scripts/verify-arxiv-compile.mjs +0 -476
- package/scripts/verify-arxiv-source.mjs +0 -224
- package/scripts/verify-browser-launch-plan.mjs +0 -254
- package/scripts/verify-browser-launch-results.mjs +0 -303
- package/scripts/verify-paper-artifacts.mjs +0 -798
- package/scripts/verify-paper-claims.mjs +0 -254
- package/scripts/verify-paper-submission-bundle.mjs +0 -218
- package/scripts/verify-publication-pack.mjs +0 -210
- package/scripts/verify-python-package.py +0 -201
- package/scripts/verify-release-readiness.mjs +0 -920
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { spawnSync } from 'node:child_process';
|
|
4
|
-
import { createHash } from 'node:crypto';
|
|
5
|
-
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
6
|
-
import { resolve } from 'node:path';
|
|
7
|
-
|
|
8
|
-
const ROOT = process.cwd();
|
|
9
|
-
const DEFAULT_REPOSITORY = 'Evilander/Audrey';
|
|
10
|
-
const DEFAULT_BRANCH = 'master';
|
|
11
|
-
const DEFAULT_VERSION = '1.1.1';
|
|
12
|
-
const DEFAULT_TOKEN_ENV = 'GITHUB_TOKEN';
|
|
13
|
-
const API_VERSION = '2022-11-28';
|
|
14
|
-
|
|
15
|
-
function parseArgs(argv = process.argv.slice(2)) {
|
|
16
|
-
const args = {
|
|
17
|
-
repository: DEFAULT_REPOSITORY,
|
|
18
|
-
branch: DEFAULT_BRANCH,
|
|
19
|
-
version: DEFAULT_VERSION,
|
|
20
|
-
tokenEnv: DEFAULT_TOKEN_ENV,
|
|
21
|
-
apply: false,
|
|
22
|
-
json: false,
|
|
23
|
-
force: false,
|
|
24
|
-
concurrency: 4,
|
|
25
|
-
includeEntries: false,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
for (let i = 0; i < argv.length; i++) {
|
|
29
|
-
const token = argv[i];
|
|
30
|
-
if ((token === '--repository' || token === '--repo') && argv[i + 1])
|
|
31
|
-
args.repository = argv[++i];
|
|
32
|
-
else if (token === '--branch' && argv[i + 1]) args.branch = argv[++i];
|
|
33
|
-
else if ((token === '--version' || token === '--target-version') && argv[i + 1])
|
|
34
|
-
args.version = argv[++i];
|
|
35
|
-
else if (token === '--token-env' && argv[i + 1]) args.tokenEnv = argv[++i];
|
|
36
|
-
else if (token === '--concurrency' && argv[i + 1])
|
|
37
|
-
args.concurrency = Number.parseInt(argv[++i], 10);
|
|
38
|
-
else if (token === '--apply') args.apply = true;
|
|
39
|
-
else if (token === '--json') args.json = true;
|
|
40
|
-
else if (token === '--force') args.force = true;
|
|
41
|
-
else if (token === '--include-entries') args.includeEntries = true;
|
|
42
|
-
else if (token === '--help' || token === '-h') args.help = true;
|
|
43
|
-
else throw new Error(`Unknown argument: ${token}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (!Number.isInteger(args.concurrency) || args.concurrency < 1 || args.concurrency > 12) {
|
|
47
|
-
throw new Error('--concurrency must be an integer between 1 and 12');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return args;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function usage() {
|
|
54
|
-
return `Usage: node scripts/publish-release-github-api.mjs [options]
|
|
55
|
-
|
|
56
|
-
Options:
|
|
57
|
-
--apply Create GitHub blobs/tree/commit/tag and update the branch.
|
|
58
|
-
--repository <owner/repo> Repository to publish. Default: ${DEFAULT_REPOSITORY}.
|
|
59
|
-
--branch <name> Branch ref to update. Default: ${DEFAULT_BRANCH}.
|
|
60
|
-
--version <version> Release version. Default: ${DEFAULT_VERSION}.
|
|
61
|
-
--token-env <name> Environment variable containing a GitHub token. Default: ${DEFAULT_TOKEN_ENV}.
|
|
62
|
-
--concurrency <n> Concurrent blob uploads. Default: 4.
|
|
63
|
-
--force Force branch ref update if remote branch moved.
|
|
64
|
-
--include-entries Include every changed path in the JSON report.
|
|
65
|
-
--json Print the machine-readable report.
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function run(command, args, options = {}) {
|
|
70
|
-
const result = spawnSync(command, args, {
|
|
71
|
-
cwd: ROOT,
|
|
72
|
-
encoding: 'utf-8',
|
|
73
|
-
timeout: options.timeout ?? 120_000,
|
|
74
|
-
env: {
|
|
75
|
-
...process.env,
|
|
76
|
-
...options.env,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
command: [command, ...args].join(' '),
|
|
81
|
-
ok: result.status === 0,
|
|
82
|
-
status: result.status,
|
|
83
|
-
stdout: result.stdout?.trim() ?? '',
|
|
84
|
-
stderr: result.stderr?.trim() ?? '',
|
|
85
|
-
error: result.error?.message ?? null,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function assertOk(result) {
|
|
90
|
-
if (!result.ok)
|
|
91
|
-
throw new Error(
|
|
92
|
-
`${result.command} failed: ${result.stderr || result.stdout || result.error || result.status}`,
|
|
93
|
-
);
|
|
94
|
-
return result.stdout;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function splitZ(output) {
|
|
98
|
-
return output.split('\0').filter(Boolean);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function normalized(path) {
|
|
102
|
-
return path.replaceAll('\\', '/');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function sha256(path) {
|
|
106
|
-
return createHash('sha256')
|
|
107
|
-
.update(readFileSync(resolve(ROOT, path)))
|
|
108
|
-
.digest('hex');
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function readJsonIfExists(path) {
|
|
112
|
-
const full = resolve(ROOT, path);
|
|
113
|
-
return existsSync(full) ? JSON.parse(readFileSync(full, 'utf-8').replace(/^\uFEFF/, '')) : null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function collectChangedPaths() {
|
|
117
|
-
const changed = splitZ(
|
|
118
|
-
assertOk(run('git', ['-c', 'core.quotepath=false', 'diff', '--name-only', '-z', 'HEAD', '--'])),
|
|
119
|
-
);
|
|
120
|
-
const untracked = splitZ(
|
|
121
|
-
assertOk(
|
|
122
|
-
run('git', [
|
|
123
|
-
'-c',
|
|
124
|
-
'core.quotepath=false',
|
|
125
|
-
'ls-files',
|
|
126
|
-
'--others',
|
|
127
|
-
'--exclude-standard',
|
|
128
|
-
'-z',
|
|
129
|
-
]),
|
|
130
|
-
),
|
|
131
|
-
);
|
|
132
|
-
return [...new Set([...changed, ...untracked].map(normalized))].sort((a, b) =>
|
|
133
|
-
a.localeCompare(b),
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function fileMode(path) {
|
|
138
|
-
const listing = run('git', ['ls-files', '-s', '--', path]);
|
|
139
|
-
if (listing.ok && listing.stdout) return listing.stdout.split(/\s+/)[0] || '100644';
|
|
140
|
-
return '100644';
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function changedEntries() {
|
|
144
|
-
return collectChangedPaths().map(path => {
|
|
145
|
-
const full = resolve(ROOT, path);
|
|
146
|
-
if (!existsSync(full)) {
|
|
147
|
-
return { path, deleted: true, mode: '100644', bytes: 0, sha256: null };
|
|
148
|
-
}
|
|
149
|
-
const stat = statSync(full);
|
|
150
|
-
if (!stat.isFile()) throw new Error(`Changed path is not a file: ${path}`);
|
|
151
|
-
return {
|
|
152
|
-
path,
|
|
153
|
-
deleted: false,
|
|
154
|
-
mode: fileMode(path),
|
|
155
|
-
bytes: stat.size,
|
|
156
|
-
sha256: sha256(path),
|
|
157
|
-
};
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function remoteRefs(repository, branch, version) {
|
|
162
|
-
let result = run(
|
|
163
|
-
'git',
|
|
164
|
-
[
|
|
165
|
-
'ls-remote',
|
|
166
|
-
`https://github.com/${repository}.git`,
|
|
167
|
-
`refs/heads/${branch}`,
|
|
168
|
-
`refs/tags/v${version}`,
|
|
169
|
-
],
|
|
170
|
-
{ timeout: 60_000 },
|
|
171
|
-
);
|
|
172
|
-
if (
|
|
173
|
-
!result.ok &&
|
|
174
|
-
/schannel|AcquireCredentialsHandle|SEC_E_NO_CREDENTIALS/i.test(
|
|
175
|
-
`${result.stderr}\n${result.stdout}`,
|
|
176
|
-
)
|
|
177
|
-
) {
|
|
178
|
-
result = run(
|
|
179
|
-
'git',
|
|
180
|
-
[
|
|
181
|
-
'-c',
|
|
182
|
-
'http.sslBackend=openssl',
|
|
183
|
-
'ls-remote',
|
|
184
|
-
`https://github.com/${repository}.git`,
|
|
185
|
-
`refs/heads/${branch}`,
|
|
186
|
-
`refs/tags/v${version}`,
|
|
187
|
-
],
|
|
188
|
-
{ timeout: 60_000 },
|
|
189
|
-
);
|
|
190
|
-
result.fallback = 'openssl';
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const refs = {};
|
|
194
|
-
for (const line of result.stdout.split(/\r?\n/)) {
|
|
195
|
-
const [sha, ref] = line.trim().split(/\s+/);
|
|
196
|
-
if (sha && ref) refs[ref] = sha;
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
result,
|
|
200
|
-
branch: refs[`refs/heads/${branch}`] ?? null,
|
|
201
|
-
tag: refs[`refs/tags/v${version}`] ?? null,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function releaseDates() {
|
|
206
|
-
const headTime = Number.parseInt(
|
|
207
|
-
assertOk(run('git', ['show', '-s', '--format=%ct', 'HEAD'])),
|
|
208
|
-
10,
|
|
209
|
-
);
|
|
210
|
-
const commitEpoch = headTime + 1;
|
|
211
|
-
return {
|
|
212
|
-
commitEpoch,
|
|
213
|
-
tagEpoch: commitEpoch + 1,
|
|
214
|
-
commitIso: isoWithOffset(commitEpoch, -300),
|
|
215
|
-
tagIso: isoWithOffset(commitEpoch + 1, -300),
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function isoWithOffset(epochSeconds, offsetMinutes) {
|
|
220
|
-
const shifted = new Date((epochSeconds + offsetMinutes * 60) * 1000);
|
|
221
|
-
const stamp = shifted.toISOString().replace(/\.\d{3}Z$/, '');
|
|
222
|
-
const sign = offsetMinutes < 0 ? '-' : '+';
|
|
223
|
-
const absolute = Math.abs(offsetMinutes);
|
|
224
|
-
const hours = String(Math.floor(absolute / 60)).padStart(2, '0');
|
|
225
|
-
const minutes = String(absolute % 60).padStart(2, '0');
|
|
226
|
-
return `${stamp}${sign}${hours}:${minutes}`;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
async function githubJson(token, repository, path, options = {}) {
|
|
230
|
-
const response = await fetch(`https://api.github.com/repos/${repository}${path}`, {
|
|
231
|
-
method: options.method ?? 'GET',
|
|
232
|
-
headers: {
|
|
233
|
-
Accept: 'application/vnd.github+json',
|
|
234
|
-
Authorization: `Bearer ${token}`,
|
|
235
|
-
'Content-Type': 'application/json',
|
|
236
|
-
'User-Agent': 'audrey-release-publisher',
|
|
237
|
-
'X-GitHub-Api-Version': API_VERSION,
|
|
238
|
-
},
|
|
239
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
240
|
-
});
|
|
241
|
-
const text = await response.text();
|
|
242
|
-
const payload = text ? JSON.parse(text) : null;
|
|
243
|
-
if (!response.ok) {
|
|
244
|
-
const message = payload?.message ?? text.slice(0, 500) ?? response.statusText;
|
|
245
|
-
throw new Error(
|
|
246
|
-
`GitHub API ${options.method ?? 'GET'} ${path} failed (${response.status}): ${message}`,
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
return payload;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
async function mapLimit(items, limit, mapper) {
|
|
253
|
-
const results = new Array(items.length);
|
|
254
|
-
let next = 0;
|
|
255
|
-
async function worker() {
|
|
256
|
-
while (next < items.length) {
|
|
257
|
-
const index = next++;
|
|
258
|
-
results[index] = await mapper(items[index], index);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
262
|
-
return results;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
async function uploadBlob(token, repository, entry) {
|
|
266
|
-
const content = readFileSync(resolve(ROOT, entry.path)).toString('base64');
|
|
267
|
-
const blob = await githubJson(token, repository, '/git/blobs', {
|
|
268
|
-
method: 'POST',
|
|
269
|
-
body: {
|
|
270
|
-
content,
|
|
271
|
-
encoding: 'base64',
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
return {
|
|
275
|
-
path: entry.path,
|
|
276
|
-
mode: entry.mode,
|
|
277
|
-
type: 'blob',
|
|
278
|
-
sha: blob.sha,
|
|
279
|
-
bytes: entry.bytes,
|
|
280
|
-
sha256: entry.sha256,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function localState(args) {
|
|
285
|
-
const localHead = assertOk(run('git', ['rev-parse', 'HEAD']));
|
|
286
|
-
const localTree = assertOk(run('git', ['rev-parse', 'HEAD^{tree}']));
|
|
287
|
-
const objectReport = readJsonIfExists('.tmp/release-git-object-report.json');
|
|
288
|
-
const finalizeReport = readJsonIfExists('.tmp/release-artifacts/release-finalize-report.json');
|
|
289
|
-
const refs = remoteRefs(args.repository, args.branch, args.version);
|
|
290
|
-
const entries = changedEntries();
|
|
291
|
-
const bytes = entries.reduce((total, entry) => total + entry.bytes, 0);
|
|
292
|
-
const blockers = [];
|
|
293
|
-
|
|
294
|
-
if (!refs.result.ok)
|
|
295
|
-
blockers.push(
|
|
296
|
-
`Remote ref check failed: ${refs.result.stderr || refs.result.stdout || refs.result.error}`,
|
|
297
|
-
);
|
|
298
|
-
if (refs.branch && refs.branch !== localHead && !args.force) {
|
|
299
|
-
blockers.push(`Remote ${args.branch} is ${refs.branch}, but local HEAD is ${localHead}`);
|
|
300
|
-
}
|
|
301
|
-
if (refs.tag) blockers.push(`Remote tag v${args.version} already exists at ${refs.tag}`);
|
|
302
|
-
if (!objectReport?.commit || !objectReport?.tree)
|
|
303
|
-
blockers.push(
|
|
304
|
-
'Missing .tmp/release-git-object-report.json; run npm run release:artifacts first',
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
return {
|
|
308
|
-
localHead,
|
|
309
|
-
localTree,
|
|
310
|
-
expectedReleaseTree: objectReport?.tree ?? null,
|
|
311
|
-
expectedReleaseCommit: objectReport?.commit ?? null,
|
|
312
|
-
expectedReleaseTag: objectReport?.tag ?? null,
|
|
313
|
-
remoteBranch: refs.branch,
|
|
314
|
-
remoteTag: refs.tag,
|
|
315
|
-
remoteCheck: refs.result,
|
|
316
|
-
changedFiles: entries.length,
|
|
317
|
-
changedBytes: bytes,
|
|
318
|
-
entries,
|
|
319
|
-
finalizeArtifacts: finalizeReport?.artifacts ?? [],
|
|
320
|
-
blockers,
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
async function publishWithGitHubApi(args, state, token) {
|
|
325
|
-
const apiCommit = await githubJson(token, args.repository, `/git/commits/${state.remoteBranch}`);
|
|
326
|
-
const uploaded = await mapLimit(
|
|
327
|
-
state.entries.filter(entry => !entry.deleted),
|
|
328
|
-
args.concurrency,
|
|
329
|
-
entry => uploadBlob(token, args.repository, entry),
|
|
330
|
-
);
|
|
331
|
-
const uploadedByPath = new Map(uploaded.map(entry => [entry.path, entry]));
|
|
332
|
-
const tree = await githubJson(token, args.repository, '/git/trees', {
|
|
333
|
-
method: 'POST',
|
|
334
|
-
body: {
|
|
335
|
-
base_tree: apiCommit.tree.sha,
|
|
336
|
-
tree: state.entries.map(entry => {
|
|
337
|
-
if (entry.deleted) return { path: entry.path, mode: entry.mode, type: 'blob', sha: null };
|
|
338
|
-
const blob = uploadedByPath.get(entry.path);
|
|
339
|
-
return { path: entry.path, mode: entry.mode, type: 'blob', sha: blob.sha };
|
|
340
|
-
}),
|
|
341
|
-
},
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
if (state.expectedReleaseTree && tree.sha !== state.expectedReleaseTree) {
|
|
345
|
-
throw new Error(
|
|
346
|
-
`GitHub release tree ${tree.sha} does not match local source-bundle tree ${state.expectedReleaseTree}`,
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const dates = releaseDates();
|
|
351
|
-
const identity = { name: 'Tyler Eveland', email: 'j.tyler.eveland@gmail.com' };
|
|
352
|
-
const commit = await githubJson(token, args.repository, '/git/commits', {
|
|
353
|
-
method: 'POST',
|
|
354
|
-
body: {
|
|
355
|
-
message: `Release Audrey ${args.version}`,
|
|
356
|
-
tree: tree.sha,
|
|
357
|
-
parents: [state.remoteBranch],
|
|
358
|
-
author: { ...identity, date: dates.commitIso },
|
|
359
|
-
committer: { ...identity, date: dates.commitIso },
|
|
360
|
-
},
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
if (state.expectedReleaseCommit && commit.sha !== state.expectedReleaseCommit) {
|
|
364
|
-
throw new Error(
|
|
365
|
-
`GitHub release commit ${commit.sha} does not match local source-bundle commit ${state.expectedReleaseCommit}`,
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
const branchUpdate = await githubJson(token, args.repository, `/git/refs/heads/${args.branch}`, {
|
|
370
|
-
method: 'PATCH',
|
|
371
|
-
body: {
|
|
372
|
-
sha: commit.sha,
|
|
373
|
-
force: args.force,
|
|
374
|
-
},
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
const tagObject = await githubJson(token, args.repository, '/git/tags', {
|
|
378
|
-
method: 'POST',
|
|
379
|
-
body: {
|
|
380
|
-
tag: `v${args.version}`,
|
|
381
|
-
message: `Audrey ${args.version}`,
|
|
382
|
-
object: commit.sha,
|
|
383
|
-
type: 'commit',
|
|
384
|
-
tagger: { ...identity, date: dates.tagIso },
|
|
385
|
-
},
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
const tagRef = await githubJson(token, args.repository, '/git/refs', {
|
|
389
|
-
method: 'POST',
|
|
390
|
-
body: {
|
|
391
|
-
ref: `refs/tags/v${args.version}`,
|
|
392
|
-
sha: tagObject.sha,
|
|
393
|
-
},
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
return {
|
|
397
|
-
uploadedBlobs: uploaded.length,
|
|
398
|
-
tree: tree.sha,
|
|
399
|
-
commit: commit.sha,
|
|
400
|
-
tagObject: tagObject.sha,
|
|
401
|
-
branchRef: branchUpdate.object?.sha ?? commit.sha,
|
|
402
|
-
tagRef: tagRef.object?.sha ?? tagObject.sha,
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function printableReport(report, json) {
|
|
407
|
-
if (json) return JSON.stringify(report, null, 2);
|
|
408
|
-
const lines = [
|
|
409
|
-
`Audrey GitHub API source publisher: apply=${report.apply}`,
|
|
410
|
-
`repository=${report.repository}`,
|
|
411
|
-
`branch=${report.branch}`,
|
|
412
|
-
`changed files=${report.changedFiles}`,
|
|
413
|
-
`changed bytes=${report.changedBytes}`,
|
|
414
|
-
`remote branch=${report.remoteBranch ?? 'missing'}`,
|
|
415
|
-
`remote tag=${report.remoteTag ?? 'missing'}`,
|
|
416
|
-
`expected release commit=${report.expectedReleaseCommit ?? 'missing'}`,
|
|
417
|
-
];
|
|
418
|
-
if (report.blockers.length) {
|
|
419
|
-
lines.push('Blockers:');
|
|
420
|
-
for (const blocker of report.blockers) lines.push(`- ${blocker}`);
|
|
421
|
-
}
|
|
422
|
-
if (report.publish) {
|
|
423
|
-
lines.push(`published commit=${report.publish.commit}`);
|
|
424
|
-
lines.push(`published tag=${report.publish.tagRef}`);
|
|
425
|
-
}
|
|
426
|
-
return lines.join('\n');
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
async function main() {
|
|
430
|
-
const args = parseArgs();
|
|
431
|
-
if (args.help) {
|
|
432
|
-
console.log(usage());
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
const state = localState(args);
|
|
437
|
-
const report = {
|
|
438
|
-
schemaVersion: '1.0.0',
|
|
439
|
-
suite: 'Audrey GitHub API source publication',
|
|
440
|
-
generatedAt: new Date().toISOString(),
|
|
441
|
-
apply: args.apply,
|
|
442
|
-
repository: args.repository,
|
|
443
|
-
branch: args.branch,
|
|
444
|
-
version: args.version,
|
|
445
|
-
tokenEnv: args.tokenEnv,
|
|
446
|
-
localHead: state.localHead,
|
|
447
|
-
localTree: state.localTree,
|
|
448
|
-
expectedReleaseTree: state.expectedReleaseTree,
|
|
449
|
-
expectedReleaseCommit: state.expectedReleaseCommit,
|
|
450
|
-
expectedReleaseTag: state.expectedReleaseTag,
|
|
451
|
-
remoteBranch: state.remoteBranch,
|
|
452
|
-
remoteTag: state.remoteTag,
|
|
453
|
-
changedFiles: state.changedFiles,
|
|
454
|
-
changedBytes: state.changedBytes,
|
|
455
|
-
changedEntrySample: state.entries.slice(0, 12).map(entry => ({
|
|
456
|
-
path: entry.path,
|
|
457
|
-
deleted: entry.deleted,
|
|
458
|
-
mode: entry.mode,
|
|
459
|
-
bytes: entry.bytes,
|
|
460
|
-
sha256: entry.sha256,
|
|
461
|
-
})),
|
|
462
|
-
changedEntries: args.includeEntries
|
|
463
|
-
? state.entries.map(entry => ({
|
|
464
|
-
path: entry.path,
|
|
465
|
-
deleted: entry.deleted,
|
|
466
|
-
mode: entry.mode,
|
|
467
|
-
bytes: entry.bytes,
|
|
468
|
-
sha256: entry.sha256,
|
|
469
|
-
}))
|
|
470
|
-
: undefined,
|
|
471
|
-
finalizeArtifacts: state.finalizeArtifacts,
|
|
472
|
-
blockers: [...state.blockers],
|
|
473
|
-
publish: null,
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
if (args.apply) {
|
|
477
|
-
const token = process.env[args.tokenEnv];
|
|
478
|
-
if (!token) {
|
|
479
|
-
report.blockers.push(
|
|
480
|
-
`Set ${args.tokenEnv} to a GitHub token with contents:write before applying`,
|
|
481
|
-
);
|
|
482
|
-
} else if (report.blockers.length === 0) {
|
|
483
|
-
report.publish = await publishWithGitHubApi(args, state, token);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
console.log(printableReport(report, args.json));
|
|
488
|
-
if (report.blockers.length) process.exit(1);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
main().catch(error => {
|
|
492
|
-
console.error(error.stack ?? error.message);
|
|
493
|
-
process.exit(1);
|
|
494
|
-
});
|
package/scripts/run-vitest.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { mkdirSync } from 'node:fs';
|
|
3
|
-
import { resolve } from 'node:path';
|
|
4
|
-
|
|
5
|
-
const tempDir = resolve('.tmp-vitest');
|
|
6
|
-
mkdirSync(tempDir, { recursive: true });
|
|
7
|
-
|
|
8
|
-
const vitestEntry = resolve('node_modules/vitest/vitest.mjs');
|
|
9
|
-
const args = process.argv.slice(2);
|
|
10
|
-
const mode = args[0] === 'watch' ? [] : ['run'];
|
|
11
|
-
const passthrough = args[0] === 'watch' ? args.slice(1) : args;
|
|
12
|
-
|
|
13
|
-
const child = spawn(process.execPath, [vitestEntry, ...mode, ...passthrough], {
|
|
14
|
-
stdio: 'inherit',
|
|
15
|
-
env: {
|
|
16
|
-
...process.env,
|
|
17
|
-
TEMP: tempDir,
|
|
18
|
-
TMP: tempDir,
|
|
19
|
-
TMPDIR: tempDir,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
child.on('error', err => {
|
|
24
|
-
console.error(err);
|
|
25
|
-
process.exit(1);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
child.on('exit', (code, signal) => {
|
|
29
|
-
if (signal) {
|
|
30
|
-
process.kill(process.pid, signal);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
process.exit(code ?? 1);
|
|
34
|
-
});
|
package/scripts/smoke-cli.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { spawnSync } from 'node:child_process';
|
|
4
|
-
import { existsSync, mkdirSync, mkdtempSync, rmSync, readFileSync } from 'node:fs';
|
|
5
|
-
import { tmpdir } from 'node:os';
|
|
6
|
-
import { dirname, join, resolve } from 'node:path';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
|
|
9
|
-
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
10
|
-
const cli = join(root, 'dist', 'mcp-server', 'index.js');
|
|
11
|
-
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
12
|
-
|
|
13
|
-
function fail(message, result) {
|
|
14
|
-
console.error(`[audrey smoke] ${message}`);
|
|
15
|
-
if (result) {
|
|
16
|
-
if (result.stdout) console.error(`stdout:\n${result.stdout}`);
|
|
17
|
-
if (result.stderr) console.error(`stderr:\n${result.stderr}`);
|
|
18
|
-
}
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (!existsSync(cli)) {
|
|
23
|
-
fail(`missing built CLI at ${cli}; run npm run build first`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function createTempRoot() {
|
|
27
|
-
const candidates = [process.env.AUDREY_SMOKE_TMPDIR, tmpdir(), join(root, '.tmp')].filter(
|
|
28
|
-
Boolean,
|
|
29
|
-
);
|
|
30
|
-
const failures = [];
|
|
31
|
-
|
|
32
|
-
for (const candidate of candidates) {
|
|
33
|
-
try {
|
|
34
|
-
mkdirSync(candidate, { recursive: true });
|
|
35
|
-
return mkdtempSync(join(candidate, 'audrey-smoke-'));
|
|
36
|
-
} catch (error) {
|
|
37
|
-
failures.push(`${candidate}: ${error.code ?? error.message}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
fail(`unable to create smoke temp directory (${failures.join('; ')})`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const tempRoot = createTempRoot();
|
|
45
|
-
const env = {
|
|
46
|
-
...process.env,
|
|
47
|
-
AUDREY_DATA_DIR: join(tempRoot, 'store'),
|
|
48
|
-
AUDREY_EMBEDDING_PROVIDER: 'mock',
|
|
49
|
-
AUDREY_LLM_PROVIDER: 'mock',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
function run(label, args) {
|
|
53
|
-
const result = spawnSync(process.execPath, [cli, ...args], {
|
|
54
|
-
cwd: root,
|
|
55
|
-
env,
|
|
56
|
-
encoding: 'utf8',
|
|
57
|
-
timeout: 60_000,
|
|
58
|
-
});
|
|
59
|
-
if (result.error) {
|
|
60
|
-
fail(`${label} failed to spawn: ${result.error.message}`, result);
|
|
61
|
-
}
|
|
62
|
-
if (result.status !== 0) {
|
|
63
|
-
fail(`${label} exited ${result.status}`, result);
|
|
64
|
-
}
|
|
65
|
-
return result.stdout;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
const version = run('--version', ['--version']).trim();
|
|
70
|
-
if (version !== `audrey ${pkg.version}`) {
|
|
71
|
-
fail(`version mismatch: expected audrey ${pkg.version}, got ${version}`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const doctor = JSON.parse(run('doctor --json', ['doctor', '--json']));
|
|
75
|
-
if (doctor.version !== pkg.version || doctor.ok !== true) {
|
|
76
|
-
fail(
|
|
77
|
-
`doctor --json returned unexpected release status: ${JSON.stringify({
|
|
78
|
-
version: doctor.version,
|
|
79
|
-
ok: doctor.ok,
|
|
80
|
-
})}`,
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const demo = run('demo', ['demo']);
|
|
85
|
-
if (!demo.includes('Audrey 60-second memory demo') || !demo.includes('Recall proof:')) {
|
|
86
|
-
fail('demo output did not include expected proof markers', { stdout: demo, stderr: '' });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
console.log(`[audrey smoke] CLI smoke checks passed for ${pkg.version}`);
|
|
90
|
-
} finally {
|
|
91
|
-
rmSync(tempRoot, { recursive: true, force: true });
|
|
92
|
-
}
|