@attalabs/vinaya 0.31.0 → 0.33.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/README.md +2 -3
- package/aeg-root/contracts/principal-operator.md +18 -5
- package/aeg-root/roles/developer/reference.md +3 -3
- package/aeg-root/roles/operator.md +69 -16
- package/aeg-root/roles/planner/reference.md +1 -1
- package/aeg-root/roles/tranche-archivist.md +1 -0
- package/aeg-root/skills/aeg-context-packets/SKILL.md +1 -1
- package/aeg-root/skills/aeg-context-packets/examples/operator-start.md +1 -1
- package/aeg-root/templates/pr-report-template.md +7 -2
- package/dist/checks/bin/check-body-bare-digits.js +340 -101
- package/dist/checks/bin/check-branch-topology.js +184 -105
- package/dist/checks/bin/check-brief-shape.js +333 -94
- package/dist/checks/bin/check-changeset-coverage.js +1028 -248
- package/dist/checks/bin/check-ci-shard-coverage.js +82 -0
- package/dist/checks/bin/check-closes-n.js +184 -105
- package/dist/checks/bin/check-coherence.js +345 -145
- package/dist/checks/bin/check-dead-branch-push.js +179 -59
- package/dist/checks/bin/check-dispatch-readiness.js +350 -150
- package/dist/checks/bin/check-doc-coverage-push.js +1011 -231
- package/dist/checks/bin/check-doc-coverage.js +1015 -235
- package/dist/checks/bin/check-doctrine-no-procedures.js +333 -94
- package/dist/checks/bin/check-doctrine-portability.js +1013 -233
- package/dist/checks/bin/check-evidence-fresh.js +1010 -222
- package/dist/checks/bin/check-exec-bits.js +1009 -229
- package/dist/checks/bin/check-first-push-dispatch.js +343 -145
- package/dist/checks/bin/check-issue-assignment.js +186 -107
- package/dist/checks/bin/check-issue-milestone-attach.js +176 -56
- package/dist/checks/bin/check-issue-objectives-numbering.js +176 -56
- package/dist/checks/bin/check-issue-parts-coverage.js +176 -56
- package/dist/checks/bin/check-issue-surface-globs.js +363 -143
- package/dist/checks/bin/check-issue-title-grammar.js +176 -56
- package/dist/checks/bin/check-issue-tranche-label.js +176 -56
- package/dist/checks/bin/check-main-branch-refusal.js +176 -56
- package/dist/checks/bin/check-no-disk-state.js +176 -56
- package/dist/checks/bin/check-pr-premise-reassert.js +333 -92
- package/dist/checks/bin/check-pr-report-density.js +176 -56
- package/dist/checks/bin/check-principal-test-plan-wait.js +176 -54
- package/dist/checks/bin/check-quoted-command.js +999 -217
- package/dist/checks/bin/check-reader-resolvable-prose.js +1011 -229
- package/dist/checks/bin/check-registry-gates.js +186 -56
- package/dist/checks/bin/check-retired-vocabulary.js +997 -215
- package/dist/checks/bin/check-review-gate.js +403 -203
- package/dist/checks/bin/check-single-plan-pr.js +176 -56
- package/dist/checks/bin/check-surface-scope.js +184 -105
- package/dist/checks/bin/check-test-plan.js +176 -54
- package/dist/checks/bin/check-token-collection-wired.js +182 -57
- package/dist/checks/bin/check-token-report.js +178 -58
- package/dist/checks/bin/check-workspace-escape.js +1011 -229
- package/dist/index.js +5971 -3489
- package/dist/lib/pre-push-cache-test-run.js +4431 -0
- package/dist/lib/pre-push-select-tests.js +799 -110
- package/package.json +3 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/actions.ts +10 -12
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/archive-task.ts +42 -17
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/baseline-capture.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/branch-topology-gate.ts +3 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +554 -95
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +264 -44
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/claude-code-transcript.ts +9 -9
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +211 -30
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/consumer-enumeration.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +75 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +961 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +212 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/outcomes.ts +135 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +394 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-audit.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-guard.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/derive-section7.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +514 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +110 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +27 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +123 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +27 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +240 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/diagram-model.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/direct-main-push.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +65 -22
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +238 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-owners.ts +14 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/docs-coherence.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/legacy-anchors.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/node-route.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/surfaced-manifest.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-no-procedures.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +5 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ensure-label.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/first-push-dispatch-gate.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +14 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +379 -11
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +3 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +1450 -33
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +1 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/local-anchor-coverage.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +119 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +75 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/redact.ts +87 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +801 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +373 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/metering-io-guard.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/milestone-validation.ts +2 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/no-disk-state.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +288 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-token-report.ts +3 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-tranche.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +30 -16
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-tier.ts +17 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/premise-check.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/quoted-command.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +267 -19
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +91 -24
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-scaffold.ts +6 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/report-tokens.ts +4 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +239 -110
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +384 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +184 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +65 -18
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +76 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/single-plan-pr.ts +4 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/state-machine-model.ts +40 -27
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/symbol-collisions.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +38 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +488 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +7 -9
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-section.ts +5 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/types.ts +4 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +314 -56
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +2 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/workspace-escape.ts +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__1agj1ww._.js → [externals]__0cki-x_._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +6 -6
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0r7e54g._.js → [root-of-the-server]__18paley._.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1r47dr7._.js → _08onyya._.js} +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +5 -5
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1dc2_-c_gavj1.js → 1ce2dj27_cgbj.js} +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xg6-flovrcx-.js → 22s44f5k3ecmj.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/34hhdtbp20krb.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0hstap0._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2t_rfsztmwu6y.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3ua4rm5f-a9k6.js +0 -1
- /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_ssgManifest.js +0 -0
|
@@ -121,9 +121,11 @@ function parseHunkRanges(patch) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// src/lib/config.ts
|
|
124
|
-
import {
|
|
124
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
125
|
+
import { promisify as promisify4 } from "node:util";
|
|
126
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
|
|
125
127
|
import { homedir } from "node:os";
|
|
126
|
-
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
128
|
+
import { dirname as dirname2, isAbsolute, join as join2, resolve as resolve2 } from "node:path";
|
|
127
129
|
import { z as z4 } from "zod";
|
|
128
130
|
// ../../packages/aeg-forge-state/src/gh.ts
|
|
129
131
|
import { execFile, execFileSync } from "node:child_process";
|
|
@@ -352,6 +354,52 @@ var systemEnv3 = {
|
|
|
352
354
|
...process.env,
|
|
353
355
|
PATH: [process.env.PATH, "/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin"].filter(Boolean).join(":")
|
|
354
356
|
};
|
|
357
|
+
var defaultExec = () => execFileAsync3("git", ["remote", "get-url", "origin"], { env: systemEnv3, timeout: 5000 });
|
|
358
|
+
var cached;
|
|
359
|
+
var inflight;
|
|
360
|
+
async function resolveRepo(exec = defaultExec) {
|
|
361
|
+
if (cached !== undefined)
|
|
362
|
+
return cached;
|
|
363
|
+
const fromEnv = process.env.AEG_REPO;
|
|
364
|
+
if (fromEnv) {
|
|
365
|
+
const parsed = parseOwnerRepo(fromEnv);
|
|
366
|
+
if (parsed) {
|
|
367
|
+
cached = parsed;
|
|
368
|
+
return cached;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (inflight)
|
|
372
|
+
return inflight;
|
|
373
|
+
inflight = (async () => {
|
|
374
|
+
try {
|
|
375
|
+
const { stdout } = await exec();
|
|
376
|
+
cached = parseGitRemoteUrl(stdout.trim());
|
|
377
|
+
return cached;
|
|
378
|
+
} catch (err) {
|
|
379
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
380
|
+
console.warn(`[aeg-forge-state] resolveRepo: git remote lookup failed (will retry): ${message}`);
|
|
381
|
+
return null;
|
|
382
|
+
} finally {
|
|
383
|
+
inflight = undefined;
|
|
384
|
+
}
|
|
385
|
+
})();
|
|
386
|
+
return inflight;
|
|
387
|
+
}
|
|
388
|
+
function parseGitRemoteUrl(url) {
|
|
389
|
+
const ssh = url.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
|
|
390
|
+
if (ssh?.[1] && ssh[2])
|
|
391
|
+
return { owner: ssh[1], repo: ssh[2] };
|
|
392
|
+
const https = url.match(/^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
393
|
+
if (https?.[1] && https[2])
|
|
394
|
+
return { owner: https[1], repo: https[2] };
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
function parseOwnerRepo(value) {
|
|
398
|
+
const match = value.match(/^([^/]+)\/(.+)$/);
|
|
399
|
+
if (!match?.[1] || !match[2])
|
|
400
|
+
return null;
|
|
401
|
+
return { owner: match[1], repo: match[2] };
|
|
402
|
+
}
|
|
355
403
|
// ../../packages/aeg-core/src/state-machine-model.ts
|
|
356
404
|
var FORGE_FACT_INPUTS = [
|
|
357
405
|
{
|
|
@@ -584,11 +632,27 @@ var ObservedSchema = z.object({
|
|
|
584
632
|
var TaskStatusInputSchema = z.object({
|
|
585
633
|
task: TaskToolRefSchema.optional()
|
|
586
634
|
}).merge(PageRequestSchema).strict();
|
|
635
|
+
var TaskConfidenceSchema = z.object({
|
|
636
|
+
round: z.number().int().positive(),
|
|
637
|
+
percent: z.number().int().min(0).max(100).nullable(),
|
|
638
|
+
source: z.enum(["stated", "published-summary"])
|
|
639
|
+
}).strict();
|
|
640
|
+
var TaskPhaseHistorySchema = z.object({
|
|
641
|
+
typicalPhaseMinutes: z.number().nonnegative(),
|
|
642
|
+
typicalPhaseSamples: z.number().int().positive()
|
|
643
|
+
}).strict();
|
|
587
644
|
var TaskStatusItemSchema = z.object({
|
|
588
645
|
task: TaskToolRefSchema,
|
|
589
646
|
issue: z.number().int().positive(),
|
|
590
647
|
pr: z.number().int().positive().nullable(),
|
|
591
|
-
state: z.string()
|
|
648
|
+
state: z.string(),
|
|
649
|
+
round: z.number().int().positive().nullable().optional(),
|
|
650
|
+
phase: z.string().min(1).nullable().optional(),
|
|
651
|
+
minutesInPhase: z.number().nonnegative().nullable().optional(),
|
|
652
|
+
phaseIsCurrent: z.boolean().nullable().optional(),
|
|
653
|
+
lastConfidence: TaskConfidenceSchema.nullable().optional(),
|
|
654
|
+
lastConfidenceUnread: z.boolean().optional(),
|
|
655
|
+
phaseHistory: TaskPhaseHistorySchema.nullable().optional()
|
|
592
656
|
}).merge(ObservedSchema);
|
|
593
657
|
var TaskStatusResultSchema = z.object({
|
|
594
658
|
items: z.array(TaskStatusItemSchema),
|
|
@@ -600,7 +664,7 @@ var EscalationInputsSchema = z.object({
|
|
|
600
664
|
round: z.number().int().nonnegative(),
|
|
601
665
|
head: z.string(),
|
|
602
666
|
branch: z.string(),
|
|
603
|
-
prNumber: z.number().int().positive()
|
|
667
|
+
prNumber: z.number().int().positive().nullable()
|
|
604
668
|
});
|
|
605
669
|
var EscalationEvidenceSchema = z.object({
|
|
606
670
|
round: z.number().int().nonnegative(),
|
|
@@ -636,13 +700,45 @@ var TaskEscalationReadResultSchema = z.object({
|
|
|
636
700
|
items: z.array(TaskEscalationPacketSchema),
|
|
637
701
|
nextCursor: z.string().nullable()
|
|
638
702
|
}).merge(ObservedSchema);
|
|
639
|
-
var
|
|
640
|
-
|
|
641
|
-
|
|
703
|
+
var TaskPrCheckSchema = z.object({
|
|
704
|
+
name: z.string(),
|
|
705
|
+
required: z.boolean(),
|
|
706
|
+
status: z.string(),
|
|
707
|
+
conclusion: z.string().nullable(),
|
|
708
|
+
detailsUrl: z.string().nullable(),
|
|
709
|
+
failureSummary: z.string().nullable()
|
|
710
|
+
});
|
|
711
|
+
var TaskPrVerdictSchema = z.object({
|
|
712
|
+
role: z.enum(["code-review", "security"]),
|
|
713
|
+
value: z.string(),
|
|
714
|
+
judgedHead: z.string().nullable(),
|
|
715
|
+
objectivesVersion: z.string().nullable()
|
|
716
|
+
});
|
|
717
|
+
var TaskPrPauseSchema = z.object({
|
|
718
|
+
reason: z.string(),
|
|
719
|
+
body: z.string()
|
|
720
|
+
});
|
|
721
|
+
var TaskPrReviewRecordSchema = z.object({
|
|
722
|
+
verdicts: z.array(TaskPrVerdictSchema),
|
|
723
|
+
roundMarkers: z.array(z.number().int().nonnegative()),
|
|
724
|
+
summaryTable: z.string().nullable(),
|
|
725
|
+
pause: TaskPrPauseSchema.nullable()
|
|
726
|
+
});
|
|
727
|
+
var TaskPrReadInputSchema = z.object({
|
|
728
|
+
task: TaskToolRefSchema,
|
|
729
|
+
pr: z.number().int().positive().optional()
|
|
642
730
|
}).strict();
|
|
731
|
+
var TaskPrReadResultSchema = z.object({
|
|
732
|
+
task: TaskToolRefSchema,
|
|
733
|
+
issue: z.number().int().positive(),
|
|
734
|
+
pr: z.number().int().positive(),
|
|
735
|
+
head: z.string().nullable(),
|
|
736
|
+
checks: z.array(TaskPrCheckSchema),
|
|
737
|
+
review: TaskPrReviewRecordSchema
|
|
738
|
+
}).merge(ObservedSchema);
|
|
643
739
|
var TaskStartResultSchema = z.object({
|
|
644
740
|
requestId: z.string().min(1),
|
|
645
|
-
run:
|
|
741
|
+
run: TaskToolRefSchema,
|
|
646
742
|
started: z.boolean(),
|
|
647
743
|
startedAt: z.string(),
|
|
648
744
|
mode: z.literal("attended")
|
|
@@ -656,7 +752,7 @@ var TaskCancelInputSchema = z.object({
|
|
|
656
752
|
}).strict();
|
|
657
753
|
var TaskResumeResultSchema = z.object({
|
|
658
754
|
task: z.number().int().positive(),
|
|
659
|
-
pr: z.number().int().positive(),
|
|
755
|
+
pr: z.number().int().positive().nullable(),
|
|
660
756
|
escalationId: z.string().min(1),
|
|
661
757
|
outcome: z.enum(["started", "already_resumed"]),
|
|
662
758
|
authenticatedBy: z.string().min(1),
|
|
@@ -665,7 +761,7 @@ var TaskResumeResultSchema = z.object({
|
|
|
665
761
|
var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
|
|
666
762
|
var TaskCancelResultSchema = z.object({
|
|
667
763
|
task: z.number().int().positive(),
|
|
668
|
-
pr: z.number().int().positive(),
|
|
764
|
+
pr: z.number().int().positive().nullable(),
|
|
669
765
|
escalationId: z.string().min(1),
|
|
670
766
|
outcome: TaskCancelOutcomeSchema,
|
|
671
767
|
authenticatedBy: z.string().min(1),
|
|
@@ -676,11 +772,19 @@ var TASK_TOOL_NAMES = [
|
|
|
676
772
|
"task_start",
|
|
677
773
|
"task_status",
|
|
678
774
|
"task_escalation_read",
|
|
775
|
+
"task_pr_read",
|
|
679
776
|
"task_resume",
|
|
680
777
|
"task_cancel"
|
|
681
778
|
];
|
|
682
779
|
var OPERATOR_STATUS_FOLLOW = "task_status_follow";
|
|
683
780
|
var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
|
|
781
|
+
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
782
|
+
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
783
|
+
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
784
|
+
var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
|
|
785
|
+
// ../../packages/aeg-core/src/log/envelope.ts
|
|
786
|
+
import { createHash } from "node:crypto";
|
|
787
|
+
|
|
684
788
|
// ../../packages/aeg-core/src/log/schema.ts
|
|
685
789
|
import { z as z2 } from "zod";
|
|
686
790
|
var CONFIDENCE_REASON_MAX_LENGTH = 280;
|
|
@@ -1103,10 +1207,197 @@ var LogEventSchema = z2.union([
|
|
|
1103
1207
|
HandoffEventSchema,
|
|
1104
1208
|
EffectEventSchema
|
|
1105
1209
|
]);
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1210
|
+
|
|
1211
|
+
// ../../packages/aeg-core/src/log/envelope.ts
|
|
1212
|
+
function isRole(value) {
|
|
1213
|
+
return value !== undefined && ROLE_VALUES.includes(value);
|
|
1214
|
+
}
|
|
1215
|
+
function actorIdFromEnv(role) {
|
|
1216
|
+
return role === undefined || role === "" ? null : role;
|
|
1217
|
+
}
|
|
1218
|
+
function lineageFieldFromEnv(value) {
|
|
1219
|
+
return value === undefined || value === "" ? null : value;
|
|
1220
|
+
}
|
|
1221
|
+
function attemptFromEnv(value) {
|
|
1222
|
+
if (value === undefined || value === "")
|
|
1223
|
+
return null;
|
|
1224
|
+
const n = Number(value);
|
|
1225
|
+
return Number.isInteger(n) ? n : null;
|
|
1226
|
+
}
|
|
1227
|
+
function provenanceFor(input) {
|
|
1228
|
+
if (input.provenance)
|
|
1229
|
+
return input.provenance;
|
|
1230
|
+
if (input.env.role || input.env.task)
|
|
1231
|
+
return "env_correlated";
|
|
1232
|
+
return "unavailable";
|
|
1233
|
+
}
|
|
1234
|
+
function issueFromTask(task) {
|
|
1235
|
+
if (task === undefined || task === "")
|
|
1236
|
+
return null;
|
|
1237
|
+
const n = Number(task);
|
|
1238
|
+
return Number.isInteger(n) ? n : null;
|
|
1239
|
+
}
|
|
1240
|
+
function roundFromEnv(round) {
|
|
1241
|
+
if (round === undefined || round === "")
|
|
1242
|
+
return;
|
|
1243
|
+
const n = Number(round);
|
|
1244
|
+
return Number.isInteger(n) ? n : undefined;
|
|
1245
|
+
}
|
|
1246
|
+
function buildHeader(input) {
|
|
1247
|
+
const role = isRole(input.env.role) ? input.env.role : "unattributed";
|
|
1248
|
+
const round = roundFromEnv(input.env.round);
|
|
1249
|
+
const subject = {
|
|
1250
|
+
issue: issueFromTask(input.env.task),
|
|
1251
|
+
role,
|
|
1252
|
+
...round !== undefined ? { round } : {},
|
|
1253
|
+
...input.subject ?? {}
|
|
1254
|
+
};
|
|
1255
|
+
return {
|
|
1256
|
+
meta: {
|
|
1257
|
+
schema: 2,
|
|
1258
|
+
ts: input.now.toISOString(),
|
|
1259
|
+
run_id: input.runId,
|
|
1260
|
+
seq: input.seq,
|
|
1261
|
+
repo: input.repo,
|
|
1262
|
+
vinaya: input.vinaya,
|
|
1263
|
+
doctrine: input.doctrine,
|
|
1264
|
+
host: input.host,
|
|
1265
|
+
machine: createHash("sha256").update(input.hostname).digest("hex"),
|
|
1266
|
+
event_id: input.eventId,
|
|
1267
|
+
process_id: input.processId,
|
|
1268
|
+
actor_id: actorIdFromEnv(input.env.role),
|
|
1269
|
+
lineage: {
|
|
1270
|
+
run: lineageFieldFromEnv(input.env.run),
|
|
1271
|
+
attempt: attemptFromEnv(input.env.attempt),
|
|
1272
|
+
parent: lineageFieldFromEnv(input.env.parent)
|
|
1273
|
+
},
|
|
1274
|
+
input_versions: {
|
|
1275
|
+
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
1276
|
+
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
1277
|
+
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
1278
|
+
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
1279
|
+
},
|
|
1280
|
+
provenance: provenanceFor(input)
|
|
1281
|
+
},
|
|
1282
|
+
subject
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
// ../../packages/aeg-core/src/log/redact.ts
|
|
1286
|
+
var GITHUB_TOKEN_PATTERN = /\b(?:gho_|ghp_|ghs_|ghu_|ghr_|github_pat_)[A-Za-z0-9_]+\b/g;
|
|
1287
|
+
var CLASSIC_GITHUB_PAT_PATTERN = /\b((?:token|GITHUB_TOKEN|PAT|api[_-]?key|api[_-]?token)\s*[:=]\s*)[a-f0-9]{40}\b/gi;
|
|
1288
|
+
var BEARER_TOKEN_PATTERN = /\bBearer\s+\S+/g;
|
|
1289
|
+
var AWS_ACCESS_KEY_PATTERN = /\bAKIA[0-9A-Z]{16}\b/g;
|
|
1290
|
+
var SLACK_TOKEN_PATTERN = /\bxox[baprs]-[0-9A-Za-z-]+\b/g;
|
|
1291
|
+
var STRIPE_KEY_PATTERN = /\b(?:sk|pk|rk)_(?:live|test)_[0-9A-Za-z]{10,}\b/g;
|
|
1292
|
+
var ANTHROPIC_KEY_PATTERN = /\bsk-ant-[A-Za-z0-9_-]{20,}\b/g;
|
|
1293
|
+
var OPENAI_KEY_PATTERN = /\bsk-(?!ant-)[A-Za-z0-9]{20,}\b/g;
|
|
1294
|
+
var NPM_TOKEN_PATTERN = /\bnpm_[A-Za-z0-9]{36}\b/g;
|
|
1295
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g;
|
|
1296
|
+
var PEM_BLOCK_PATTERN = /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g;
|
|
1297
|
+
var BASIC_AUTH_URL_PATTERN = /(https?:\/\/)[^/\s:@]+:[^/\s@]+@/g;
|
|
1298
|
+
var GENERIC_SECRET_ASSIGNMENT_PATTERN = /\b((?:secret|password|passwd|api[_-]?key|access[_-]?key|client[_-]?secret|private[_-]?key)\s*[:=]\s*)[A-Za-z0-9+/_=-]{16,}\b/gi;
|
|
1299
|
+
function redactString(value, home) {
|
|
1300
|
+
let out = value.replace(GITHUB_TOKEN_PATTERN, "<redacted>").replace(CLASSIC_GITHUB_PAT_PATTERN, "$1<redacted>").replace(BEARER_TOKEN_PATTERN, "<redacted>").replace(AWS_ACCESS_KEY_PATTERN, "<redacted>").replace(SLACK_TOKEN_PATTERN, "<redacted>").replace(STRIPE_KEY_PATTERN, "<redacted>").replace(ANTHROPIC_KEY_PATTERN, "<redacted>").replace(OPENAI_KEY_PATTERN, "<redacted>").replace(NPM_TOKEN_PATTERN, "<redacted>").replace(JWT_PATTERN, "<redacted>").replace(PEM_BLOCK_PATTERN, "<redacted>").replace(BASIC_AUTH_URL_PATTERN, "$1<redacted>@").replace(GENERIC_SECRET_ASSIGNMENT_PATTERN, "$1<redacted>");
|
|
1301
|
+
if (home.length > 0 && out.startsWith(home)) {
|
|
1302
|
+
const rest = out.slice(home.length);
|
|
1303
|
+
if (rest === "" || rest.startsWith("/"))
|
|
1304
|
+
out = `~${rest}`;
|
|
1305
|
+
}
|
|
1306
|
+
return out;
|
|
1307
|
+
}
|
|
1308
|
+
function redact(value, home) {
|
|
1309
|
+
if (typeof value === "string")
|
|
1310
|
+
return redactString(value, home);
|
|
1311
|
+
if (Array.isArray(value))
|
|
1312
|
+
return value.map((v) => redact(v, home));
|
|
1313
|
+
if (value !== null && typeof value === "object") {
|
|
1314
|
+
const out = {};
|
|
1315
|
+
for (const [k, v] of Object.entries(value)) {
|
|
1316
|
+
out[k] = redact(v, home);
|
|
1317
|
+
}
|
|
1318
|
+
return out;
|
|
1319
|
+
}
|
|
1320
|
+
return value;
|
|
1321
|
+
}
|
|
1322
|
+
// ../../packages/aeg-core/src/log/store.ts
|
|
1323
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2];
|
|
1324
|
+
function metaOf(obj) {
|
|
1325
|
+
if (obj === null || typeof obj !== "object")
|
|
1326
|
+
return null;
|
|
1327
|
+
const meta = obj.meta;
|
|
1328
|
+
if (meta === null || typeof meta !== "object")
|
|
1329
|
+
return null;
|
|
1330
|
+
return meta;
|
|
1331
|
+
}
|
|
1332
|
+
function recordIdentity(obj) {
|
|
1333
|
+
const meta = metaOf(obj);
|
|
1334
|
+
if (meta === null)
|
|
1335
|
+
return null;
|
|
1336
|
+
const eventId = meta.event_id;
|
|
1337
|
+
if (typeof eventId === "string" && eventId.length > 0)
|
|
1338
|
+
return eventId;
|
|
1339
|
+
const runId = meta.run_id;
|
|
1340
|
+
const seq = meta.seq;
|
|
1341
|
+
if (typeof runId === "string" && runId.length > 0 && typeof seq === "number" && Number.isInteger(seq)) {
|
|
1342
|
+
return `${runId}:${seq}`;
|
|
1343
|
+
}
|
|
1344
|
+
return null;
|
|
1345
|
+
}
|
|
1346
|
+
function schemaVersionOf(obj) {
|
|
1347
|
+
const meta = metaOf(obj);
|
|
1348
|
+
const schema = meta?.schema;
|
|
1349
|
+
return typeof schema === "number" ? schema : null;
|
|
1350
|
+
}
|
|
1351
|
+
function isKnownSchema(version) {
|
|
1352
|
+
return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
|
|
1353
|
+
}
|
|
1354
|
+
function classifyStoredLine(raw, home) {
|
|
1355
|
+
let obj;
|
|
1356
|
+
try {
|
|
1357
|
+
obj = JSON.parse(raw);
|
|
1358
|
+
} catch {
|
|
1359
|
+
return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
|
|
1360
|
+
}
|
|
1361
|
+
const version = schemaVersionOf(obj);
|
|
1362
|
+
if (version === null) {
|
|
1363
|
+
return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
|
|
1364
|
+
}
|
|
1365
|
+
if (!isKnownSchema(version)) {
|
|
1366
|
+
return {
|
|
1367
|
+
status: "unknown_version",
|
|
1368
|
+
identity: recordIdentity(obj),
|
|
1369
|
+
schema: version,
|
|
1370
|
+
raw,
|
|
1371
|
+
reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
const result = LogEventSchema.safeParse(obj);
|
|
1375
|
+
if (!result.success) {
|
|
1376
|
+
return {
|
|
1377
|
+
status: "invalid",
|
|
1378
|
+
identity: recordIdentity(obj),
|
|
1379
|
+
raw,
|
|
1380
|
+
reason: result.error.issues[0]?.message ?? "schema violation"
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
const event = result.data;
|
|
1384
|
+
const identity = recordIdentity(event);
|
|
1385
|
+
if (identity === null) {
|
|
1386
|
+
return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
|
|
1387
|
+
}
|
|
1388
|
+
const redacted = redact(event, home);
|
|
1389
|
+
const provenance = version === 2 ? event.meta.provenance ?? null : null;
|
|
1390
|
+
return {
|
|
1391
|
+
status: "ok",
|
|
1392
|
+
identity,
|
|
1393
|
+
runId: event.meta.run_id,
|
|
1394
|
+
seq: event.meta.seq,
|
|
1395
|
+
schema: version,
|
|
1396
|
+
provenance,
|
|
1397
|
+
event,
|
|
1398
|
+
postLine: JSON.stringify(redacted)
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1110
1401
|
// ../../packages/aeg-core/src/control-store/records.ts
|
|
1111
1402
|
import { z as z3 } from "zod";
|
|
1112
1403
|
var isoTimestamp = z3.string().min(1);
|
|
@@ -1236,6 +1527,82 @@ var ResolutionRecordSchema = z3.object({
|
|
|
1236
1527
|
authenticatedFrom: z3.string().min(1),
|
|
1237
1528
|
consumedAt: isoTimestamp
|
|
1238
1529
|
}).strict();
|
|
1530
|
+
// ../../packages/aeg-core/src/control-store/local.ts
|
|
1531
|
+
import {
|
|
1532
|
+
closeSync as closeSync2,
|
|
1533
|
+
constants as fsConstants2,
|
|
1534
|
+
existsSync,
|
|
1535
|
+
fsyncSync,
|
|
1536
|
+
linkSync,
|
|
1537
|
+
lstatSync,
|
|
1538
|
+
mkdirSync,
|
|
1539
|
+
openSync as openSync2,
|
|
1540
|
+
readdirSync,
|
|
1541
|
+
readFileSync as readFileSync2,
|
|
1542
|
+
renameSync,
|
|
1543
|
+
statSync,
|
|
1544
|
+
unlinkSync,
|
|
1545
|
+
writeSync
|
|
1546
|
+
} from "node:fs";
|
|
1547
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
1548
|
+
function isErrnoException(err, code) {
|
|
1549
|
+
return typeof err === "object" && err !== null && err.code === code;
|
|
1550
|
+
}
|
|
1551
|
+
function isTrustedDirStat(stat, ownUid) {
|
|
1552
|
+
if (typeof ownUid !== "number")
|
|
1553
|
+
return true;
|
|
1554
|
+
if (stat.uid !== ownUid && stat.uid !== 0)
|
|
1555
|
+
return false;
|
|
1556
|
+
const worldWritable = (stat.mode & 2) !== 0;
|
|
1557
|
+
const sticky = (stat.mode & 512) !== 0;
|
|
1558
|
+
return !worldWritable || sticky;
|
|
1559
|
+
}
|
|
1560
|
+
function currentUid() {
|
|
1561
|
+
return typeof process.getuid === "function" ? process.getuid() : undefined;
|
|
1562
|
+
}
|
|
1563
|
+
function mkdirNoSymlinks(dir, mode, trustedRoot) {
|
|
1564
|
+
const absolute = resolve(dir);
|
|
1565
|
+
const rootSegments = resolve(trustedRoot).split(sep).filter((s) => s.length > 0);
|
|
1566
|
+
const segments = absolute.split(sep).filter((s) => s.length > 0);
|
|
1567
|
+
const ownUid = currentUid();
|
|
1568
|
+
let current = absolute.startsWith(sep) ? sep : "";
|
|
1569
|
+
segments.forEach((segment, index) => {
|
|
1570
|
+
current = current === "" || current === sep ? `${current}${segment}` : `${current}${sep}${segment}`;
|
|
1571
|
+
const atOrBelowTrustedRoot = index >= rootSegments.length - 1;
|
|
1572
|
+
try {
|
|
1573
|
+
mkdirSync(current, { mode });
|
|
1574
|
+
} catch (err) {
|
|
1575
|
+
if (!isErrnoException(err, "EEXIST"))
|
|
1576
|
+
throw err;
|
|
1577
|
+
}
|
|
1578
|
+
const stat = lstatSync(current);
|
|
1579
|
+
if (stat.isSymbolicLink()) {
|
|
1580
|
+
if (atOrBelowTrustedRoot) {
|
|
1581
|
+
throw new Error(`control-store: refusing to create a run directory through ${current} — it already exists and is not a real directory (a symlink or a file)`);
|
|
1582
|
+
}
|
|
1583
|
+
let real;
|
|
1584
|
+
try {
|
|
1585
|
+
real = statSync(current);
|
|
1586
|
+
} catch (err) {
|
|
1587
|
+
throw new Error(`control-store: refusing to create a run directory through ${current} — it is a symlink whose target could not be resolved: ${err instanceof Error ? err.message : String(err)}`);
|
|
1588
|
+
}
|
|
1589
|
+
if (!real.isDirectory()) {
|
|
1590
|
+
throw new Error(`control-store: refusing to create a run directory through ${current} — it is a symlink that does not resolve to a real directory`);
|
|
1591
|
+
}
|
|
1592
|
+
if (!isTrustedDirStat(real, ownUid)) {
|
|
1593
|
+
throw new Error(`control-store: refusing to create a run directory through ${current} — its symlink target is owned by uid ${real.uid} with mode ${(real.mode & 4095).toString(8)}, neither this process's own user nor a safe shared mode`);
|
|
1594
|
+
}
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
if (!stat.isDirectory()) {
|
|
1598
|
+
throw new Error(`control-store: refusing to create a run directory through ${current} — it already exists and is not a real directory (a symlink or a file)`);
|
|
1599
|
+
}
|
|
1600
|
+
if (!isTrustedDirStat(stat, ownUid)) {
|
|
1601
|
+
throw new Error(`control-store: refusing to create a run directory through ${current} — it already exists, owned by uid ${stat.uid} with mode ${(stat.mode & 4095).toString(8)}, neither this process's own user nor a safe shared mode`);
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
var CONTROL_AREA_DIRNAME = "control";
|
|
1239
1606
|
// src/lib/agent-vendors.ts
|
|
1240
1607
|
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
1241
1608
|
|
|
@@ -1257,10 +1624,10 @@ var CheckEntrySchema = z4.object({
|
|
|
1257
1624
|
ownWorkflow: z4.boolean().optional(),
|
|
1258
1625
|
principalOwed: z4.literal(true).optional(),
|
|
1259
1626
|
validates: z4.enum(["body", "issue"]).optional()
|
|
1260
|
-
}).superRefine((
|
|
1261
|
-
if (!
|
|
1627
|
+
}).superRefine((entry, ctx) => {
|
|
1628
|
+
if (!entry.env)
|
|
1262
1629
|
return;
|
|
1263
|
-
for (const [key, value] of Object.entries(
|
|
1630
|
+
for (const [key, value] of Object.entries(entry.env)) {
|
|
1264
1631
|
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
1265
1632
|
continue;
|
|
1266
1633
|
const members = value.anyOf;
|
|
@@ -1417,31 +1784,32 @@ var VinayaConfigSchema = z4.object({
|
|
|
1417
1784
|
});
|
|
1418
1785
|
}
|
|
1419
1786
|
}).optional(),
|
|
1420
|
-
logPublish: z4.
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
}).refine((v) => v.
|
|
1429
|
-
message: "
|
|
1430
|
-
}).
|
|
1431
|
-
|
|
1787
|
+
logPublish: z4.unknown().refine((v) => v === undefined, {
|
|
1788
|
+
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
1789
|
+
}),
|
|
1790
|
+
runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
1791
|
+
logs: z4.object({
|
|
1792
|
+
folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
1793
|
+
url: z4.string().url().optional(),
|
|
1794
|
+
headers: z4.record(z4.string()).optional()
|
|
1795
|
+
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
1796
|
+
message: "logs: set at most one of folder/url"
|
|
1797
|
+
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
1798
|
+
message: "logs: headers requires url"
|
|
1799
|
+
}).optional()
|
|
1432
1800
|
});
|
|
1433
|
-
var GLOBAL_VINAYA_HOME =
|
|
1434
|
-
var GLOBAL_CONFIG_PATH =
|
|
1801
|
+
var GLOBAL_VINAYA_HOME = join2(homedir(), ".vinaya");
|
|
1802
|
+
var GLOBAL_CONFIG_PATH = join2(GLOBAL_VINAYA_HOME, "config.json");
|
|
1435
1803
|
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
1436
1804
|
function findLocalConfig() {
|
|
1437
1805
|
let dir = process.cwd();
|
|
1438
1806
|
while (true) {
|
|
1439
|
-
const candidate =
|
|
1440
|
-
if (
|
|
1807
|
+
const candidate = join2(dir, LOCAL_CONFIG_FILENAME);
|
|
1808
|
+
if (existsSync2(candidate))
|
|
1441
1809
|
return candidate;
|
|
1442
|
-
if (
|
|
1810
|
+
if (existsSync2(join2(dir, ".git")))
|
|
1443
1811
|
return null;
|
|
1444
|
-
const parent =
|
|
1812
|
+
const parent = dirname2(dir);
|
|
1445
1813
|
if (parent === dir)
|
|
1446
1814
|
return null;
|
|
1447
1815
|
dir = parent;
|
|
@@ -1451,7 +1819,7 @@ function configPath() {
|
|
|
1451
1819
|
const local = findLocalConfig();
|
|
1452
1820
|
if (local)
|
|
1453
1821
|
return local;
|
|
1454
|
-
if (
|
|
1822
|
+
if (existsSync2(GLOBAL_CONFIG_PATH))
|
|
1455
1823
|
return GLOBAL_CONFIG_PATH;
|
|
1456
1824
|
return null;
|
|
1457
1825
|
}
|
|
@@ -1473,52 +1841,235 @@ function globalTokensCollectIgnoredWarning(path) {
|
|
|
1473
1841
|
function globalRuntimeDirIgnoredWarning(path) {
|
|
1474
1842
|
return `${path}: "runtimeDir" in the global config is ignored — it carries no repository segment, so a machine-wide value would collapse every repository's task folders into one tree. Declare it from a repo-local vinaya.config.json.`;
|
|
1475
1843
|
}
|
|
1844
|
+
var emittedGlobalKeyWarnings = new Set;
|
|
1845
|
+
function warnGlobalKeyIgnoredOnce(message) {
|
|
1846
|
+
if (emittedGlobalKeyWarnings.has(message))
|
|
1847
|
+
return;
|
|
1848
|
+
emittedGlobalKeyWarnings.add(message);
|
|
1849
|
+
console.error(`⚠ ${message}`);
|
|
1850
|
+
}
|
|
1476
1851
|
function stripGlobalOnlyKeys(config, path) {
|
|
1477
1852
|
if (path !== GLOBAL_CONFIG_PATH)
|
|
1478
1853
|
return config;
|
|
1479
1854
|
let result = config;
|
|
1480
1855
|
if (result.checks && Object.keys(result.checks).length > 0) {
|
|
1481
|
-
|
|
1856
|
+
warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
|
|
1482
1857
|
result = { ...result, checks: undefined };
|
|
1483
1858
|
}
|
|
1484
1859
|
if (result.roles && Object.keys(result.roles).length > 0) {
|
|
1485
|
-
|
|
1860
|
+
warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
|
|
1486
1861
|
result = { ...result, roles: undefined };
|
|
1487
1862
|
}
|
|
1488
1863
|
if (result.principals && result.principals.length > 0) {
|
|
1489
|
-
|
|
1864
|
+
warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
|
|
1490
1865
|
result = { ...result, principals: undefined };
|
|
1491
1866
|
}
|
|
1492
1867
|
if (result.releaseActor) {
|
|
1493
|
-
|
|
1868
|
+
warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
|
|
1494
1869
|
result = { ...result, releaseActor: undefined };
|
|
1495
1870
|
}
|
|
1496
1871
|
if (result.tokens) {
|
|
1497
|
-
|
|
1872
|
+
warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
|
|
1498
1873
|
result = { ...result, tokens: undefined };
|
|
1499
1874
|
}
|
|
1500
1875
|
if (result.runtimeDir) {
|
|
1501
|
-
|
|
1876
|
+
warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
|
|
1502
1877
|
result = { ...result, runtimeDir: undefined };
|
|
1503
1878
|
}
|
|
1504
1879
|
return result;
|
|
1505
1880
|
}
|
|
1881
|
+
function resolveRuntimeDirSetting(config) {
|
|
1882
|
+
return config?.runtimeDir ?? null;
|
|
1883
|
+
}
|
|
1884
|
+
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
1885
|
+
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
1886
|
+
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
1887
|
+
}
|
|
1888
|
+
function resolveLogsSetting(config) {
|
|
1889
|
+
const raw = config?.logs;
|
|
1890
|
+
if (!raw)
|
|
1891
|
+
return null;
|
|
1892
|
+
if (raw.url !== undefined)
|
|
1893
|
+
return { url: raw.url, headers: raw.headers };
|
|
1894
|
+
if (raw.folder !== undefined)
|
|
1895
|
+
return { folder: raw.folder };
|
|
1896
|
+
return null;
|
|
1897
|
+
}
|
|
1898
|
+
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
1899
|
+
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
1900
|
+
if (!anchored)
|
|
1901
|
+
return null;
|
|
1902
|
+
if ("url" in local)
|
|
1903
|
+
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
1904
|
+
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
1905
|
+
}
|
|
1906
|
+
function resolveLogsHeaderValues(headers, env) {
|
|
1907
|
+
if (!headers)
|
|
1908
|
+
return;
|
|
1909
|
+
const resolved = {};
|
|
1910
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
1911
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
1912
|
+
}
|
|
1913
|
+
return resolved;
|
|
1914
|
+
}
|
|
1915
|
+
function trustAnchorRepo() {
|
|
1916
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
1917
|
+
if (fromRunner)
|
|
1918
|
+
return fromRunner;
|
|
1919
|
+
try {
|
|
1920
|
+
const url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
1921
|
+
encoding: "utf-8",
|
|
1922
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1923
|
+
});
|
|
1924
|
+
return trustAnchorRepoFromRemoteUrl(url);
|
|
1925
|
+
} catch {
|
|
1926
|
+
return null;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
async function trustAnchorRepoAsync() {
|
|
1930
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
1931
|
+
if (fromRunner)
|
|
1932
|
+
return fromRunner;
|
|
1933
|
+
try {
|
|
1934
|
+
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
1935
|
+
encoding: "utf-8",
|
|
1936
|
+
timeout: 1e4
|
|
1937
|
+
});
|
|
1938
|
+
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
1939
|
+
} catch {
|
|
1940
|
+
return null;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
function wellFormedRepoSlug(slug) {
|
|
1944
|
+
return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
1945
|
+
}
|
|
1946
|
+
function trustAnchorRepoFromRunner() {
|
|
1947
|
+
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
1948
|
+
return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
|
|
1949
|
+
}
|
|
1950
|
+
function trustAnchorRepoFromRemoteUrl(url) {
|
|
1951
|
+
const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
1952
|
+
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
1953
|
+
}
|
|
1954
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
1955
|
+
function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
1956
|
+
const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
|
|
1957
|
+
if (!ref)
|
|
1958
|
+
return null;
|
|
1959
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
1960
|
+
return null;
|
|
1961
|
+
if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
|
|
1962
|
+
return null;
|
|
1963
|
+
return ref;
|
|
1964
|
+
}
|
|
1965
|
+
function readTrustAnchorConfigAtRef(ref) {
|
|
1966
|
+
const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
1967
|
+
encoding: "utf-8",
|
|
1968
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
1969
|
+
timeout: 1e4
|
|
1970
|
+
});
|
|
1971
|
+
return Buffer.from(raw, "utf-8").toString("base64");
|
|
1972
|
+
}
|
|
1973
|
+
function ghFetchTrustAnchorConfig() {
|
|
1974
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
1975
|
+
if (probeRef)
|
|
1976
|
+
return readTrustAnchorConfigAtRef(probeRef);
|
|
1977
|
+
const repo = trustAnchorRepo();
|
|
1978
|
+
if (!repo)
|
|
1979
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
1980
|
+
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
1981
|
+
encoding: "utf-8",
|
|
1982
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
async function ghFetchTrustAnchorConfigAsync() {
|
|
1986
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
1987
|
+
if (probeRef) {
|
|
1988
|
+
const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
|
|
1989
|
+
encoding: "utf-8",
|
|
1990
|
+
timeout: 1e4
|
|
1991
|
+
});
|
|
1992
|
+
return Buffer.from(stdout, "utf-8").toString("base64");
|
|
1993
|
+
}
|
|
1994
|
+
const repo = await trustAnchorRepoAsync();
|
|
1995
|
+
if (!repo)
|
|
1996
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
1997
|
+
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
|
|
1998
|
+
return stdout;
|
|
1999
|
+
}
|
|
2000
|
+
function firstLine(err) {
|
|
2001
|
+
return err?.message?.split(`
|
|
2002
|
+
`)[0] ?? "unknown error";
|
|
2003
|
+
}
|
|
2004
|
+
function isMissingFileError(err) {
|
|
2005
|
+
const stderr = err?.stderr;
|
|
2006
|
+
const haystack = [
|
|
2007
|
+
err?.message ?? "",
|
|
2008
|
+
typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
|
|
2009
|
+
].join(`
|
|
2010
|
+
`);
|
|
2011
|
+
return /\b404\b|not found/i.test(haystack);
|
|
2012
|
+
}
|
|
2013
|
+
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
2014
|
+
let base64;
|
|
2015
|
+
try {
|
|
2016
|
+
base64 = fetcher();
|
|
2017
|
+
} catch (err) {
|
|
2018
|
+
return trustAnchorFetchFailed(err);
|
|
2019
|
+
}
|
|
2020
|
+
return parseTrustAnchorContent(base64);
|
|
2021
|
+
}
|
|
2022
|
+
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
2023
|
+
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
2024
|
+
let base64;
|
|
2025
|
+
try {
|
|
2026
|
+
base64 = await fetcher();
|
|
2027
|
+
} catch (err) {
|
|
2028
|
+
return trustAnchorFetchFailed(err, warn);
|
|
2029
|
+
}
|
|
2030
|
+
return parseTrustAnchorContent(base64, warn);
|
|
2031
|
+
}
|
|
2032
|
+
function warnTrustAnchorFallback(why) {
|
|
2033
|
+
process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
|
|
2034
|
+
`);
|
|
2035
|
+
}
|
|
2036
|
+
function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
2037
|
+
if (!isMissingFileError(err))
|
|
2038
|
+
warn(firstLine(err));
|
|
2039
|
+
return null;
|
|
2040
|
+
}
|
|
2041
|
+
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
2042
|
+
const base64 = content.trim();
|
|
2043
|
+
if (!base64)
|
|
2044
|
+
return null;
|
|
2045
|
+
try {
|
|
2046
|
+
const raw = Buffer.from(base64, "base64").toString("utf-8");
|
|
2047
|
+
const parsed = VinayaConfigSchema.safeParse(JSON.parse(raw));
|
|
2048
|
+
if (parsed.success)
|
|
2049
|
+
return parsed.data;
|
|
2050
|
+
warn("it did not satisfy the config schema");
|
|
2051
|
+
return null;
|
|
2052
|
+
} catch {
|
|
2053
|
+
warn("it was not readable as JSON");
|
|
2054
|
+
return null;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
1506
2057
|
function loadConfig() {
|
|
1507
2058
|
const path = configPath();
|
|
1508
2059
|
if (!path)
|
|
1509
2060
|
return null;
|
|
1510
2061
|
try {
|
|
1511
|
-
const raw = JSON.parse(
|
|
2062
|
+
const raw = JSON.parse(readFileSync3(path, "utf-8"));
|
|
1512
2063
|
return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
|
|
1513
2064
|
} catch {
|
|
1514
2065
|
return null;
|
|
1515
2066
|
}
|
|
1516
2067
|
}
|
|
1517
|
-
var TOKENS_COLLECT_TRUST_PATH =
|
|
2068
|
+
var TOKENS_COLLECT_TRUST_PATH = join2(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
1518
2069
|
|
|
1519
2070
|
// src/lib/remote-base.ts
|
|
1520
|
-
import { execFileSync as
|
|
1521
|
-
import { join as
|
|
2071
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
2072
|
+
import { join as join3 } from "node:path";
|
|
1522
2073
|
function cleanGitEnv() {
|
|
1523
2074
|
const env = { ...process.env };
|
|
1524
2075
|
for (const key of Object.keys(env)) {
|
|
@@ -1529,7 +2080,7 @@ function cleanGitEnv() {
|
|
|
1529
2080
|
}
|
|
1530
2081
|
function git(repoRoot, args) {
|
|
1531
2082
|
try {
|
|
1532
|
-
return
|
|
2083
|
+
return execFileSync3("git", args, {
|
|
1533
2084
|
cwd: repoRoot,
|
|
1534
2085
|
encoding: "utf8",
|
|
1535
2086
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -1555,7 +2106,7 @@ function changedFilesSinceRemoteBase(repoRoot) {
|
|
|
1555
2106
|
`).map((s) => s.trim()).filter(Boolean);
|
|
1556
2107
|
}
|
|
1557
2108
|
function changedFilesSinceRemoteBaseAbsolute(repoRoot) {
|
|
1558
|
-
return changedFilesSinceRemoteBase(repoRoot).map((f) =>
|
|
2109
|
+
return changedFilesSinceRemoteBase(repoRoot).map((f) => join3(repoRoot, f));
|
|
1559
2110
|
}
|
|
1560
2111
|
function addedOrRenamedFilesSinceRemoteBase(repoRoot) {
|
|
1561
2112
|
const base = resolveRemoteBase(repoRoot);
|
|
@@ -1564,7 +2115,7 @@ function addedOrRenamedFilesSinceRemoteBase(repoRoot) {
|
|
|
1564
2115
|
`).map((s) => s.trim()).filter(Boolean);
|
|
1565
2116
|
}
|
|
1566
2117
|
function addedOrRenamedFilesSinceRemoteBaseAbsolute(repoRoot) {
|
|
1567
|
-
return addedOrRenamedFilesSinceRemoteBase(repoRoot).map((f) =>
|
|
2118
|
+
return addedOrRenamedFilesSinceRemoteBase(repoRoot).map((f) => join3(repoRoot, f));
|
|
1568
2119
|
}
|
|
1569
2120
|
function changedFileDiffsSinceRemoteBase(repoRoot) {
|
|
1570
2121
|
const base = resolveRemoteBase(repoRoot);
|
|
@@ -1574,7 +2125,7 @@ function changedFileDiffsSinceRemoteBase(repoRoot) {
|
|
|
1574
2125
|
const patch = git(repoRoot, ["diff", "-U0", `${mergeBase}..HEAD`, "--", relative]);
|
|
1575
2126
|
const { beforeRanges, afterRanges } = parseHunkRanges(patch);
|
|
1576
2127
|
out.push({
|
|
1577
|
-
file:
|
|
2128
|
+
file: join3(repoRoot, relative),
|
|
1578
2129
|
after: showBlob(repoRoot, "HEAD", relative),
|
|
1579
2130
|
before: showBlob(repoRoot, mergeBase, relative),
|
|
1580
2131
|
beforeRanges,
|
|
@@ -1585,7 +2136,7 @@ function changedFileDiffsSinceRemoteBase(repoRoot) {
|
|
|
1585
2136
|
}
|
|
1586
2137
|
function showBlob(repoRoot, ref, relative) {
|
|
1587
2138
|
try {
|
|
1588
|
-
return
|
|
2139
|
+
return execFileSync3("git", ["show", `${ref}:${relative}`], {
|
|
1589
2140
|
cwd: repoRoot,
|
|
1590
2141
|
encoding: "utf8",
|
|
1591
2142
|
maxBuffer: 64 * 1024 * 1024,
|
|
@@ -1598,11 +2149,124 @@ function showBlob(repoRoot, ref, relative) {
|
|
|
1598
2149
|
}
|
|
1599
2150
|
|
|
1600
2151
|
// src/lib/test-selector.ts
|
|
1601
|
-
import { readdirSync, readFileSync as
|
|
1602
|
-
import { dirname as
|
|
2152
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync4, statSync as statSync2 } from "node:fs";
|
|
2153
|
+
import { dirname as dirname6, extname, isAbsolute as isAbsolute4, join as join7, resolve as resolve6 } from "node:path";
|
|
2154
|
+
|
|
2155
|
+
// src/lib/cli-spawn-tests.ts
|
|
2156
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join4, resolve as resolve3 } from "node:path";
|
|
2157
|
+
function evaluateExpression(ts, node, file, fileDir, repoRoot, bindings) {
|
|
2158
|
+
if (ts.isStringLiteral(node))
|
|
2159
|
+
return node.text;
|
|
2160
|
+
if (ts.isIdentifier(node))
|
|
2161
|
+
return node.text === "__dirname" ? fileDir : bindings.get(node.text) ?? null;
|
|
2162
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
2163
|
+
const text = node.getText();
|
|
2164
|
+
if (text === "import.meta.dir" || text === "import.meta.dirname")
|
|
2165
|
+
return fileDir;
|
|
2166
|
+
if (text === "import.meta.url")
|
|
2167
|
+
return file;
|
|
2168
|
+
return null;
|
|
2169
|
+
}
|
|
2170
|
+
if (ts.isCallExpression(node)) {
|
|
2171
|
+
const callee = ts.isIdentifier(node.expression) ? node.expression.text : ts.isPropertyAccessExpression(node.expression) ? node.expression.name.text : "";
|
|
2172
|
+
if (callee === "cwd")
|
|
2173
|
+
return repoRoot;
|
|
2174
|
+
if (callee === "dirname") {
|
|
2175
|
+
const arg = node.arguments[0];
|
|
2176
|
+
const inner = arg ? evaluateExpression(ts, arg, file, fileDir, repoRoot, bindings) : null;
|
|
2177
|
+
return inner !== null ? dirname3(inner) : null;
|
|
2178
|
+
}
|
|
2179
|
+
if (callee === "fileURLToPath") {
|
|
2180
|
+
const arg = node.arguments[0];
|
|
2181
|
+
return arg ? evaluateExpression(ts, arg, file, fileDir, repoRoot, bindings) : null;
|
|
2182
|
+
}
|
|
2183
|
+
if (callee === "join" || callee === "resolve") {
|
|
2184
|
+
const parts = [];
|
|
2185
|
+
for (const arg of node.arguments) {
|
|
2186
|
+
const part = evaluateExpression(ts, arg, file, fileDir, repoRoot, bindings);
|
|
2187
|
+
if (part === null)
|
|
2188
|
+
return null;
|
|
2189
|
+
parts.push(part);
|
|
2190
|
+
}
|
|
2191
|
+
if (parts.length === 0)
|
|
2192
|
+
return null;
|
|
2193
|
+
const first = parts[0];
|
|
2194
|
+
if (!isAbsolute2(first))
|
|
2195
|
+
return null;
|
|
2196
|
+
return callee === "join" ? join4(...parts) : resolve3(...parts);
|
|
2197
|
+
}
|
|
2198
|
+
return null;
|
|
2199
|
+
}
|
|
2200
|
+
if (ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "URL") {
|
|
2201
|
+
const base = node.arguments?.[1];
|
|
2202
|
+
if (base?.getText() !== "import.meta.url")
|
|
2203
|
+
return null;
|
|
2204
|
+
const relativeArg = node.arguments?.[0];
|
|
2205
|
+
if (!relativeArg || !ts.isStringLiteral(relativeArg))
|
|
2206
|
+
return null;
|
|
2207
|
+
return join4(fileDir, relativeArg.text);
|
|
2208
|
+
}
|
|
2209
|
+
return null;
|
|
2210
|
+
}
|
|
2211
|
+
function collectTopLevelBindings(ts, sourceFile, file, fileDir, repoRoot) {
|
|
2212
|
+
const bindings = new Map;
|
|
2213
|
+
for (const statement of sourceFile.statements) {
|
|
2214
|
+
if (!ts.isVariableStatement(statement))
|
|
2215
|
+
continue;
|
|
2216
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
2217
|
+
if (!ts.isIdentifier(declaration.name) || !declaration.initializer)
|
|
2218
|
+
continue;
|
|
2219
|
+
const value = evaluateExpression(ts, declaration.initializer, file, fileDir, repoRoot, bindings);
|
|
2220
|
+
if (value !== null)
|
|
2221
|
+
bindings.set(declaration.name.text, value);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
return bindings;
|
|
2225
|
+
}
|
|
2226
|
+
function cliSpawnEdgeOf(ts, file, source, repoRoot, entrypoint) {
|
|
2227
|
+
const fileDir = dirname3(file);
|
|
2228
|
+
let sourceFile;
|
|
2229
|
+
try {
|
|
2230
|
+
sourceFile = ts.createSourceFile(file, source, ts.ScriptTarget.ES2022, true);
|
|
2231
|
+
} catch {
|
|
2232
|
+
return null;
|
|
2233
|
+
}
|
|
2234
|
+
const bindings = collectTopLevelBindings(ts, sourceFile, file, fileDir, repoRoot);
|
|
2235
|
+
let classification = null;
|
|
2236
|
+
const visit = (node) => {
|
|
2237
|
+
if (ts.isCallExpression(node)) {
|
|
2238
|
+
const candidates = [];
|
|
2239
|
+
for (const arg of node.arguments) {
|
|
2240
|
+
candidates.push(arg);
|
|
2241
|
+
if (ts.isArrayLiteralExpression(arg)) {
|
|
2242
|
+
for (const element of arg.elements) {
|
|
2243
|
+
if (!ts.isSpreadElement(element))
|
|
2244
|
+
candidates.push(element);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
let sawBun = false;
|
|
2249
|
+
let sawEntrypoint = false;
|
|
2250
|
+
for (const candidate of candidates) {
|
|
2251
|
+
const value = evaluateExpression(ts, candidate, file, fileDir, repoRoot, bindings);
|
|
2252
|
+
if (value === "bun")
|
|
2253
|
+
sawBun = true;
|
|
2254
|
+
else if (value === entrypoint)
|
|
2255
|
+
sawEntrypoint = true;
|
|
2256
|
+
}
|
|
2257
|
+
if (sawBun && sawEntrypoint)
|
|
2258
|
+
classification = "entrypoint";
|
|
2259
|
+
else if ((sawBun || sawEntrypoint) && classification !== "entrypoint")
|
|
2260
|
+
classification = "fallback";
|
|
2261
|
+
}
|
|
2262
|
+
ts.forEachChild(node, visit);
|
|
2263
|
+
};
|
|
2264
|
+
visit(sourceFile);
|
|
2265
|
+
return classification;
|
|
2266
|
+
}
|
|
1603
2267
|
|
|
1604
2268
|
// src/lib/repo-scanner-tests.ts
|
|
1605
|
-
import { dirname as
|
|
2269
|
+
import { dirname as dirname4, isAbsolute as isAbsolute3, join as join5, resolve as resolve4 } from "node:path";
|
|
1606
2270
|
var TREE_READERS = new Set([
|
|
1607
2271
|
"readdirSync",
|
|
1608
2272
|
"readdir",
|
|
@@ -1642,9 +2306,9 @@ function evaluatePath(ts, node, fileDir, repoRoot, bindings) {
|
|
|
1642
2306
|
if (parts.length === 0)
|
|
1643
2307
|
return null;
|
|
1644
2308
|
const first = parts[0];
|
|
1645
|
-
if (!
|
|
2309
|
+
if (!isAbsolute3(first))
|
|
1646
2310
|
return null;
|
|
1647
|
-
return callee === "join" ?
|
|
2311
|
+
return callee === "join" ? join5(...parts) : resolve4(...parts);
|
|
1648
2312
|
}
|
|
1649
2313
|
return null;
|
|
1650
2314
|
}
|
|
@@ -1655,12 +2319,12 @@ function evaluatePath(ts, node, fileDir, repoRoot, bindings) {
|
|
|
1655
2319
|
const relativeArg = node.arguments?.[0];
|
|
1656
2320
|
if (!relativeArg || !ts.isStringLiteral(relativeArg))
|
|
1657
2321
|
return null;
|
|
1658
|
-
return
|
|
2322
|
+
return join5(fileDir, relativeArg.text);
|
|
1659
2323
|
}
|
|
1660
2324
|
return null;
|
|
1661
2325
|
}
|
|
1662
2326
|
function scannedRootsOf(ts, file, source, repoRoot) {
|
|
1663
|
-
const fileDir =
|
|
2327
|
+
const fileDir = dirname4(file);
|
|
1664
2328
|
let sourceFile;
|
|
1665
2329
|
try {
|
|
1666
2330
|
sourceFile = ts.createSourceFile(file, source, ts.ScriptTarget.ES2022, true);
|
|
@@ -1711,9 +2375,9 @@ function scannedRootsOf(ts, file, source, repoRoot) {
|
|
|
1711
2375
|
|
|
1712
2376
|
// src/lib/ts-module-graph.ts
|
|
1713
2377
|
import { createRequire } from "node:module";
|
|
1714
|
-
import { dirname as
|
|
2378
|
+
import { dirname as dirname5, join as join6, resolve as resolve5 } from "node:path";
|
|
1715
2379
|
function loadTypeScript(repoRoot) {
|
|
1716
|
-
for (const from of [
|
|
2380
|
+
for (const from of [join6(repoRoot, "package.json"), import.meta.url]) {
|
|
1717
2381
|
try {
|
|
1718
2382
|
const loaded = createRequire(from)("typescript");
|
|
1719
2383
|
if (loaded && typeof loaded.createProgram === "function" && loaded.ScriptTarget)
|
|
@@ -1732,8 +2396,8 @@ var SCAN_PREFIX = "scan:";
|
|
|
1732
2396
|
var NAME_SEPARATOR = "#";
|
|
1733
2397
|
function graphCompilerOptions(ts, input) {
|
|
1734
2398
|
const paths = {};
|
|
1735
|
-
for (const [specifier,
|
|
1736
|
-
paths[specifier] = [
|
|
2399
|
+
for (const [specifier, entry] of input.entrypoints)
|
|
2400
|
+
paths[specifier] = [entry];
|
|
1737
2401
|
return {
|
|
1738
2402
|
baseUrl: input.repoRoot,
|
|
1739
2403
|
paths,
|
|
@@ -1841,7 +2505,7 @@ ${specifier}`;
|
|
|
1841
2505
|
const resolveWithLiteral = (specifier, into) => {
|
|
1842
2506
|
const target = resolveToWorkspaceFile(specifier, file);
|
|
1843
2507
|
if (specifier.startsWith(".")) {
|
|
1844
|
-
const literal =
|
|
2508
|
+
const literal = resolve5(dirname5(file), specifier);
|
|
1845
2509
|
if (literal !== target && fileSet.has(literal))
|
|
1846
2510
|
into.push(`${ALL_PREFIX}${literal}`);
|
|
1847
2511
|
}
|
|
@@ -1996,8 +2660,8 @@ function parseNamedList(inside) {
|
|
|
1996
2660
|
if (entries.length === 0)
|
|
1997
2661
|
clean = false;
|
|
1998
2662
|
for (const raw of entries) {
|
|
1999
|
-
const
|
|
2000
|
-
const origin =
|
|
2663
|
+
const entry = raw.replace(/^type\s+/, "");
|
|
2664
|
+
const origin = entry.split(/\s+as\s+/)[0].trim();
|
|
2001
2665
|
if (/^[A-Za-z_$][\w$]*$/.test(origin))
|
|
2002
2666
|
names.push(origin);
|
|
2003
2667
|
else
|
|
@@ -2056,17 +2720,17 @@ function walkFiles(root) {
|
|
|
2056
2720
|
const out = [];
|
|
2057
2721
|
let entries;
|
|
2058
2722
|
try {
|
|
2059
|
-
entries =
|
|
2723
|
+
entries = readdirSync2(root);
|
|
2060
2724
|
} catch {
|
|
2061
2725
|
return out;
|
|
2062
2726
|
}
|
|
2063
|
-
for (const
|
|
2064
|
-
if (SKIP_DIRS.has(
|
|
2727
|
+
for (const entry of entries) {
|
|
2728
|
+
if (SKIP_DIRS.has(entry))
|
|
2065
2729
|
continue;
|
|
2066
|
-
const abs =
|
|
2730
|
+
const abs = join7(root, entry);
|
|
2067
2731
|
let s;
|
|
2068
2732
|
try {
|
|
2069
|
-
s =
|
|
2733
|
+
s = statSync2(abs);
|
|
2070
2734
|
} catch {
|
|
2071
2735
|
continue;
|
|
2072
2736
|
}
|
|
@@ -2092,7 +2756,7 @@ function resolveFileCandidate(base, knownFiles) {
|
|
|
2092
2756
|
return base + ext;
|
|
2093
2757
|
}
|
|
2094
2758
|
for (const ext of SOURCE_EXTENSIONS) {
|
|
2095
|
-
const indexed =
|
|
2759
|
+
const indexed = join7(base, `index${ext}`);
|
|
2096
2760
|
if (knownFiles.has(indexed))
|
|
2097
2761
|
return indexed;
|
|
2098
2762
|
}
|
|
@@ -2101,7 +2765,7 @@ function resolveFileCandidate(base, knownFiles) {
|
|
|
2101
2765
|
function resolveRelativeImport(fromFile, specifier, knownFiles) {
|
|
2102
2766
|
if (!specifier.startsWith("."))
|
|
2103
2767
|
return null;
|
|
2104
|
-
return resolveFileCandidate(
|
|
2768
|
+
return resolveFileCandidate(resolve6(dirname6(fromFile), specifier), knownFiles);
|
|
2105
2769
|
}
|
|
2106
2770
|
function isBunTestScript(script) {
|
|
2107
2771
|
if (!script)
|
|
@@ -2130,7 +2794,7 @@ function deriveEntrypoints(dir, pkg, knownFiles) {
|
|
|
2130
2794
|
for (const target of declaredTargets(value)) {
|
|
2131
2795
|
if (!target.startsWith("."))
|
|
2132
2796
|
return;
|
|
2133
|
-
const resolved = resolveFileCandidate(
|
|
2797
|
+
const resolved = resolveFileCandidate(resolve6(dir, target), knownFiles);
|
|
2134
2798
|
if (resolved)
|
|
2135
2799
|
files.add(resolved);
|
|
2136
2800
|
}
|
|
@@ -2150,10 +2814,10 @@ function deriveEntrypoints(dir, pkg, knownFiles) {
|
|
|
2150
2814
|
return out;
|
|
2151
2815
|
}
|
|
2152
2816
|
function discoverWorkspacePackages(repoRoot) {
|
|
2153
|
-
const rootPkgPath =
|
|
2817
|
+
const rootPkgPath = join7(repoRoot, "package.json");
|
|
2154
2818
|
let workspaces = [];
|
|
2155
2819
|
try {
|
|
2156
|
-
const rootPkg = JSON.parse(
|
|
2820
|
+
const rootPkg = JSON.parse(readFileSync4(rootPkgPath, "utf8"));
|
|
2157
2821
|
workspaces = rootPkg.workspaces ?? [];
|
|
2158
2822
|
} catch {
|
|
2159
2823
|
return [];
|
|
@@ -2163,19 +2827,19 @@ function discoverWorkspacePackages(repoRoot) {
|
|
|
2163
2827
|
const m = /^([^*]+)\*$/.exec(glob);
|
|
2164
2828
|
if (!m)
|
|
2165
2829
|
continue;
|
|
2166
|
-
const parentDir =
|
|
2830
|
+
const parentDir = join7(repoRoot, m[1].replace(/\/$/, ""));
|
|
2167
2831
|
let entries;
|
|
2168
2832
|
try {
|
|
2169
|
-
entries =
|
|
2833
|
+
entries = readdirSync2(parentDir);
|
|
2170
2834
|
} catch {
|
|
2171
2835
|
continue;
|
|
2172
2836
|
}
|
|
2173
|
-
for (const
|
|
2174
|
-
const dir =
|
|
2175
|
-
const pkgPath =
|
|
2837
|
+
for (const entry of entries) {
|
|
2838
|
+
const dir = join7(parentDir, entry);
|
|
2839
|
+
const pkgPath = join7(dir, "package.json");
|
|
2176
2840
|
let pkg;
|
|
2177
2841
|
try {
|
|
2178
|
-
pkg = JSON.parse(
|
|
2842
|
+
pkg = JSON.parse(readFileSync4(pkgPath, "utf8"));
|
|
2179
2843
|
} catch {
|
|
2180
2844
|
continue;
|
|
2181
2845
|
}
|
|
@@ -2223,10 +2887,10 @@ function parseExportTable(source) {
|
|
|
2223
2887
|
for (let m = EXPORT_BRACE_RE.exec(source);m !== null; m = EXPORT_BRACE_RE.exec(source)) {
|
|
2224
2888
|
const specifier = m[3];
|
|
2225
2889
|
for (const raw of m[1].split(",")) {
|
|
2226
|
-
const
|
|
2227
|
-
if (
|
|
2890
|
+
const entry = raw.trim().replace(/^type\s+/, "");
|
|
2891
|
+
if (entry.length === 0)
|
|
2228
2892
|
continue;
|
|
2229
|
-
const parts =
|
|
2893
|
+
const parts = entry.split(/\s+as\s+/);
|
|
2230
2894
|
const origin = parts[0].trim();
|
|
2231
2895
|
const exported = (parts[1] ?? parts[0]).trim();
|
|
2232
2896
|
if (!/^[A-Za-z_$][\w$]*$/.test(origin) || !/^[A-Za-z_$][\w$]*$/.test(exported))
|
|
@@ -2250,10 +2914,10 @@ function parseExportTable(source) {
|
|
|
2250
2914
|
const specifier = m[5];
|
|
2251
2915
|
if (m[1] !== undefined) {
|
|
2252
2916
|
for (const raw of m[1].split(",")) {
|
|
2253
|
-
const
|
|
2254
|
-
if (
|
|
2917
|
+
const entry = raw.trim().replace(/^type\s+/, "");
|
|
2918
|
+
if (entry.length === 0)
|
|
2255
2919
|
continue;
|
|
2256
|
-
const parts =
|
|
2920
|
+
const parts = entry.split(/\s+as\s+/);
|
|
2257
2921
|
const origin = parts[0].trim();
|
|
2258
2922
|
const local = (parts[1] ?? parts[0]).trim();
|
|
2259
2923
|
if (/^[A-Za-z_$][\w$]*$/.test(local))
|
|
@@ -2274,7 +2938,7 @@ function makeSourceReader() {
|
|
|
2274
2938
|
let cached = cache.get(file);
|
|
2275
2939
|
if (cached === undefined) {
|
|
2276
2940
|
try {
|
|
2277
|
-
cached =
|
|
2941
|
+
cached = readFileSync4(file, "utf8");
|
|
2278
2942
|
} catch {
|
|
2279
2943
|
cached = "";
|
|
2280
2944
|
}
|
|
@@ -2309,12 +2973,12 @@ function resolveExportedName(ctx, file, name, stack) {
|
|
|
2309
2973
|
ctx.resultCache.set(cacheKey, result);
|
|
2310
2974
|
return result;
|
|
2311
2975
|
}
|
|
2312
|
-
function resolveHopNames(ctx,
|
|
2976
|
+
function resolveHopNames(ctx, entry, names, stack) {
|
|
2313
2977
|
if (names.length === 0)
|
|
2314
2978
|
return null;
|
|
2315
2979
|
const deps = [];
|
|
2316
2980
|
for (const name of names) {
|
|
2317
|
-
const sub = resolveExportedName(ctx,
|
|
2981
|
+
const sub = resolveExportedName(ctx, entry, name, stack);
|
|
2318
2982
|
if (!sub.resolved)
|
|
2319
2983
|
return null;
|
|
2320
2984
|
for (const t of sub.touched)
|
|
@@ -2350,13 +3014,13 @@ function resolveThroughTable(ctx, file, name, table, stack) {
|
|
|
2350
3014
|
out.add(`${EXTERNAL_PREFIX}${pkg.name}`);
|
|
2351
3015
|
continue;
|
|
2352
3016
|
}
|
|
2353
|
-
const
|
|
2354
|
-
const precise = record.kind === "named" && record.clean ? resolveHopNames(ctx,
|
|
3017
|
+
const entry = pkg.entry;
|
|
3018
|
+
const precise = record.kind === "named" && record.clean ? resolveHopNames(ctx, entry, record.names, stack) : null;
|
|
2355
3019
|
if (precise)
|
|
2356
3020
|
for (const dep of precise)
|
|
2357
3021
|
out.add(dep);
|
|
2358
3022
|
else
|
|
2359
|
-
out.add(
|
|
3023
|
+
out.add(entry);
|
|
2360
3024
|
}
|
|
2361
3025
|
return out;
|
|
2362
3026
|
};
|
|
@@ -2407,11 +3071,13 @@ function resolveThroughTable(ctx, file, name, table, stack) {
|
|
|
2407
3071
|
hopDeps: new Set([...ownHopDeps(), ...only.hopDeps])
|
|
2408
3072
|
};
|
|
2409
3073
|
}
|
|
3074
|
+
var DEFAULT_CLI_ENTRYPOINT = "apps/cli/src/index.ts";
|
|
3075
|
+
var ROOT_CONFIG_FILENAME = "vinaya.config.json";
|
|
2410
3076
|
function selectAffectedTestFiles(repoRoot, changedFiles, options = {}) {
|
|
2411
3077
|
const packages = discoverWorkspacePackages(repoRoot);
|
|
2412
|
-
const absChanged = new Set(changedFiles.map((f) =>
|
|
3078
|
+
const absChanged = new Set(changedFiles.map((f) => isAbsolute4(f) ? f : join7(repoRoot, f)));
|
|
2413
3079
|
const alwaysRunRegexes = (options.alwaysRun ?? []).map(globToRegex);
|
|
2414
|
-
const addedOrRenamed = new Set((options.addedOrRenamed ?? []).map((f) =>
|
|
3080
|
+
const addedOrRenamed = new Set((options.addedOrRenamed ?? []).map((f) => isAbsolute4(f) ? f : join7(repoRoot, f)));
|
|
2415
3081
|
const readSource = makeSourceReader();
|
|
2416
3082
|
const tableCache = new Map;
|
|
2417
3083
|
const resultCache = new Map;
|
|
@@ -2473,8 +3139,8 @@ function selectAffectedTestFiles(repoRoot, changedFiles, options = {}) {
|
|
|
2473
3139
|
if (graphTypescript) {
|
|
2474
3140
|
const entrypoints = new Map;
|
|
2475
3141
|
for (const pkg of packages) {
|
|
2476
|
-
for (const [subpath,
|
|
2477
|
-
entrypoints.set(subpath === "." ? pkg.name : `${pkg.name}${subpath.slice(1)}`,
|
|
3142
|
+
for (const [subpath, entry] of pkg.entrypoints) {
|
|
3143
|
+
entrypoints.set(subpath === "." ? pkg.name : `${pkg.name}${subpath.slice(1)}`, entry);
|
|
2478
3144
|
}
|
|
2479
3145
|
}
|
|
2480
3146
|
const graph = buildCompilerGraph(graphTypescript, {
|
|
@@ -2510,14 +3176,14 @@ function selectAffectedTestFiles(repoRoot, changedFiles, options = {}) {
|
|
|
2510
3176
|
continue;
|
|
2511
3177
|
if (coarsePackages.has(match.pkg.name))
|
|
2512
3178
|
continue;
|
|
2513
|
-
const
|
|
2514
|
-
if (record.kind !== "named" || !record.clean || !
|
|
3179
|
+
const entry = match.pkg.entrypoints.get(match.subpath);
|
|
3180
|
+
if (record.kind !== "named" || !record.clean || !entry) {
|
|
2515
3181
|
coarsePackages.add(match.pkg.name);
|
|
2516
3182
|
continue;
|
|
2517
3183
|
}
|
|
2518
3184
|
let acc = resolvedNamed.get(match.pkg.name);
|
|
2519
3185
|
for (const name of record.names) {
|
|
2520
|
-
const resolution = resolveExportedName(ctx,
|
|
3186
|
+
const resolution = resolveExportedName(ctx, entry, name, new Set);
|
|
2521
3187
|
if (!resolution.resolved) {
|
|
2522
3188
|
coarsePackages.add(match.pkg.name);
|
|
2523
3189
|
acc = undefined;
|
|
@@ -2563,18 +3229,24 @@ function selectAffectedTestFiles(repoRoot, changedFiles, options = {}) {
|
|
|
2563
3229
|
}
|
|
2564
3230
|
}
|
|
2565
3231
|
}
|
|
2566
|
-
const
|
|
3232
|
+
const affectedNames = options.affectedNames ?? new Map;
|
|
2567
3233
|
const changeFacts = {
|
|
2568
3234
|
files: absChanged,
|
|
2569
3235
|
packages: changedPackageNames,
|
|
2570
3236
|
nonSourcePackages: nonSourceChangedPackages,
|
|
2571
3237
|
packageOfFile: (f) => fileToPackage.get(f) ?? null,
|
|
2572
3238
|
affects: (file, name) => {
|
|
2573
|
-
const affected =
|
|
3239
|
+
const affected = affectedNames.get(file) ?? affectedNames.get(file.startsWith(repoRoot) ? file.slice(repoRoot.length + 1) : file);
|
|
2574
3240
|
return affected === undefined || affected === "all" || affected.has(name);
|
|
2575
3241
|
}
|
|
2576
3242
|
};
|
|
2577
|
-
|
|
3243
|
+
const depthOneDefault = options.depth === "one" ? "ignore" : "select";
|
|
3244
|
+
const repoTreeScanners = options.repoTreeScanners ?? depthOneDefault;
|
|
3245
|
+
const cliSpawnDetection = options.cliSpawnDetection ?? depthOneDefault;
|
|
3246
|
+
const cliEntrypoint = join7(repoRoot, options.cliEntrypoint ?? DEFAULT_CLI_ENTRYPOINT);
|
|
3247
|
+
const rootConfigChanged = absChanged.has(join7(repoRoot, ROOT_CONFIG_FILENAME));
|
|
3248
|
+
const cliPackage = packages.find((pkg) => cliEntrypoint.startsWith(`${pkg.dir}/`)) ?? null;
|
|
3249
|
+
if (typescript && repoTreeScanners !== "ignore") {
|
|
2578
3250
|
for (const file of allSourceFiles) {
|
|
2579
3251
|
if (!isTestFile(file))
|
|
2580
3252
|
continue;
|
|
@@ -2585,6 +3257,19 @@ function selectAffectedTestFiles(repoRoot, changedFiles, options = {}) {
|
|
|
2585
3257
|
edges.set(key, [...edges.get(key) ?? [], ...roots.map((r) => `${SCAN_PREFIX}${r}`)]);
|
|
2586
3258
|
}
|
|
2587
3259
|
}
|
|
3260
|
+
if (typescript && cliSpawnDetection !== "ignore") {
|
|
3261
|
+
const cliEntrypointSourceRoot = dirname6(cliEntrypoint);
|
|
3262
|
+
for (const file of allSourceFiles) {
|
|
3263
|
+
if (!isTestFile(file))
|
|
3264
|
+
continue;
|
|
3265
|
+
const classification = cliSpawnEdgeOf(typescript, file, readSource(file), repoRoot, cliEntrypoint);
|
|
3266
|
+
if (!classification)
|
|
3267
|
+
continue;
|
|
3268
|
+
const key = `${ALL_PREFIX}${file}`;
|
|
3269
|
+
const edge = classification === "entrypoint" ? `${ALL_PREFIX}${cliEntrypoint}` : `${SCAN_PREFIX}${cliEntrypointSourceRoot}`;
|
|
3270
|
+
edges.set(key, [...edges.get(key) ?? [], edge]);
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
2588
3273
|
const anythingChanged = absChanged.size > 0 || changedPackageNames.size > 0;
|
|
2589
3274
|
const selected = [];
|
|
2590
3275
|
let totalTestFiles = 0;
|
|
@@ -2593,26 +3278,29 @@ function selectAffectedTestFiles(repoRoot, changedFiles, options = {}) {
|
|
|
2593
3278
|
totalTestFiles += testFiles.length;
|
|
2594
3279
|
if (!pkg.bunTestCompatible)
|
|
2595
3280
|
continue;
|
|
3281
|
+
const maxDepth = options.depth === "one" ? 1 : Number.POSITIVE_INFINITY;
|
|
2596
3282
|
for (const test of testFiles) {
|
|
2597
|
-
const forced = alwaysRunRegexes.some((re) => re.test(test.slice(repoRoot.length + 1))) || addedOrRenamed.has(test);
|
|
2598
|
-
if (forced || anythingChanged && reaches(`${ALL_PREFIX}${test}`, edges, changeFacts)) {
|
|
3283
|
+
const forced = alwaysRunRegexes.some((re) => re.test(test.slice(repoRoot.length + 1))) || addedOrRenamed.has(test) || rootConfigChanged && pkg === cliPackage;
|
|
3284
|
+
if (forced || anythingChanged && reaches(`${ALL_PREFIX}${test}`, edges, changeFacts, maxDepth)) {
|
|
2599
3285
|
selected.push(test);
|
|
2600
3286
|
}
|
|
2601
3287
|
}
|
|
2602
3288
|
}
|
|
2603
3289
|
return { selected, totalTestFiles, resolver: graphTypescript ? "compiler" : "text-scan", programMs };
|
|
2604
3290
|
}
|
|
2605
|
-
function reaches(start, edges, changed) {
|
|
3291
|
+
function reaches(start, edges, changed, maxDepth = Number.POSITIVE_INFINITY) {
|
|
2606
3292
|
const visited = new Set;
|
|
2607
|
-
const stack = [start];
|
|
3293
|
+
const stack = [[start, 0]];
|
|
2608
3294
|
while (stack.length > 0) {
|
|
2609
|
-
const current = stack.pop();
|
|
3295
|
+
const [current, depth] = stack.pop();
|
|
2610
3296
|
if (visited.has(current))
|
|
2611
3297
|
continue;
|
|
2612
3298
|
visited.add(current);
|
|
2613
3299
|
const currentFile = current.startsWith(ALL_PREFIX) ? current.slice(ALL_PREFIX.length) : current.startsWith(OWN_PREFIX) ? current.slice(OWN_PREFIX.length) : null;
|
|
2614
3300
|
if (current.startsWith(ALL_PREFIX) && currentFile && changed.files.has(currentFile))
|
|
2615
3301
|
return true;
|
|
3302
|
+
if (depth >= maxDepth)
|
|
3303
|
+
continue;
|
|
2616
3304
|
const ownPackage = currentFile ? changed.packageOfFile(currentFile) : null;
|
|
2617
3305
|
for (const dep of edges.get(current) ?? []) {
|
|
2618
3306
|
if (dep.startsWith(NAME_PREFIX)) {
|
|
@@ -2648,7 +3336,7 @@ function reaches(start, edges, changed) {
|
|
|
2648
3336
|
continue;
|
|
2649
3337
|
}
|
|
2650
3338
|
if (!visited.has(dep))
|
|
2651
|
-
stack.push(dep);
|
|
3339
|
+
stack.push([dep, depth + 1]);
|
|
2652
3340
|
}
|
|
2653
3341
|
}
|
|
2654
3342
|
return false;
|
|
@@ -2666,7 +3354,8 @@ function main() {
|
|
|
2666
3354
|
const { selected, totalTestFiles, resolver, programMs } = selectAffectedTestFiles(repoRoot, changed, {
|
|
2667
3355
|
alwaysRun,
|
|
2668
3356
|
addedOrRenamed,
|
|
2669
|
-
affectedNames: names
|
|
3357
|
+
affectedNames: names,
|
|
3358
|
+
depth: "one"
|
|
2670
3359
|
});
|
|
2671
3360
|
const elapsed = performance.now() - started;
|
|
2672
3361
|
for (const file of selected)
|