dorfl 0.14.3 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advance-ci-template.d.ts +17 -16
- package/dist/advance-ci-template.d.ts.map +1 -1
- package/dist/advance-ci-template.js +42 -53
- package/dist/advance-ci-template.js.map +1 -1
- package/dist/advance-drivers.d.ts +8 -0
- package/dist/advance-drivers.d.ts.map +1 -1
- package/dist/advance-drivers.js +28 -4
- package/dist/advance-drivers.js.map +1 -1
- package/dist/advance-isolated.d.ts.map +1 -1
- package/dist/advance-isolated.js +3 -2
- package/dist/advance-isolated.js.map +1 -1
- package/dist/advance-lifecycle-template.d.ts +41 -40
- package/dist/advance-lifecycle-template.d.ts.map +1 -1
- package/dist/advance-lifecycle-template.js +305 -486
- package/dist/advance-lifecycle-template.js.map +1 -1
- package/dist/advance-loop-driver.d.ts.map +1 -1
- package/dist/advance-loop-driver.js +3 -2
- package/dist/advance-loop-driver.js.map +1 -1
- package/dist/advance-treeless-publish.d.ts +31 -0
- package/dist/advance-treeless-publish.d.ts.map +1 -1
- package/dist/advance-treeless-publish.js +40 -0
- package/dist/advance-treeless-publish.js.map +1 -1
- package/dist/advance.d.ts +63 -3
- package/dist/advance.d.ts.map +1 -1
- package/dist/advance.js +80 -12
- package/dist/advance.js.map +1 -1
- package/dist/advancing-lock.d.ts +9 -0
- package/dist/advancing-lock.d.ts.map +1 -1
- package/dist/advancing-lock.js +21 -1
- package/dist/advancing-lock.js.map +1 -1
- package/dist/agent-env.d.ts +61 -0
- package/dist/agent-env.d.ts.map +1 -0
- package/dist/agent-env.js +144 -0
- package/dist/agent-env.js.map +1 -0
- package/dist/agent-stop.d.ts +35 -0
- package/dist/agent-stop.d.ts.map +1 -1
- package/dist/agent-stop.js +62 -0
- package/dist/agent-stop.js.map +1 -1
- package/dist/apply-merge-action.d.ts +76 -34
- package/dist/apply-merge-action.d.ts.map +1 -1
- package/dist/apply-merge-action.js +339 -129
- package/dist/apply-merge-action.js.map +1 -1
- package/dist/apply-stuck-action.js +2 -2
- package/dist/apply-stuck-action.js.map +1 -1
- package/dist/ci-agent-result.d.ts +151 -0
- package/dist/ci-agent-result.d.ts.map +1 -0
- package/dist/ci-agent-result.js +314 -0
- package/dist/ci-agent-result.js.map +1 -0
- package/dist/ci-handoff-apply.d.ts +162 -0
- package/dist/ci-handoff-apply.d.ts.map +1 -0
- package/dist/ci-handoff-apply.js +497 -0
- package/dist/ci-handoff-apply.js.map +1 -0
- package/dist/ci-handoff-format.d.ts +369 -0
- package/dist/ci-handoff-format.d.ts.map +1 -0
- package/dist/ci-handoff-format.js +646 -0
- package/dist/ci-handoff-format.js.map +1 -0
- package/dist/ci-handoff-lfs.d.ts +146 -0
- package/dist/ci-handoff-lfs.d.ts.map +1 -0
- package/dist/ci-handoff-lfs.js +397 -0
- package/dist/ci-handoff-lfs.js.map +1 -0
- package/dist/ci-handoff.d.ts +99 -0
- package/dist/ci-handoff.d.ts.map +1 -0
- package/dist/ci-handoff.js +277 -0
- package/dist/ci-handoff.js.map +1 -0
- package/dist/ci-lock-outputs.d.ts +93 -0
- package/dist/ci-lock-outputs.d.ts.map +1 -0
- package/dist/ci-lock-outputs.js +223 -0
- package/dist/ci-lock-outputs.js.map +1 -0
- package/dist/ci-phase-build.d.ts +178 -0
- package/dist/ci-phase-build.d.ts.map +1 -0
- package/dist/ci-phase-build.js +989 -0
- package/dist/ci-phase-build.js.map +1 -0
- package/dist/ci-phase-driver.d.ts +247 -0
- package/dist/ci-phase-driver.d.ts.map +1 -0
- package/dist/ci-phase-driver.js +370 -0
- package/dist/ci-phase-driver.js.map +1 -0
- package/dist/ci-phase-intake.d.ts +172 -0
- package/dist/ci-phase-intake.d.ts.map +1 -0
- package/dist/ci-phase-intake.js +555 -0
- package/dist/ci-phase-intake.js.map +1 -0
- package/dist/ci-phase-tasking.d.ts +205 -0
- package/dist/ci-phase-tasking.d.ts.map +1 -0
- package/dist/ci-phase-tasking.js +906 -0
- package/dist/ci-phase-tasking.js.map +1 -0
- package/dist/ci-phase-treeless.d.ts +224 -0
- package/dist/ci-phase-treeless.d.ts.map +1 -0
- package/dist/ci-phase-treeless.js +1482 -0
- package/dist/ci-phase-treeless.js.map +1 -0
- package/dist/ci-read-token.d.ts +47 -0
- package/dist/ci-read-token.d.ts.map +1 -0
- package/dist/ci-read-token.js +80 -0
- package/dist/ci-read-token.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +447 -22
- package/dist/cli.js.map +1 -1
- package/dist/close-job-template.d.ts +10 -1
- package/dist/close-job-template.d.ts.map +1 -1
- package/dist/close-job-template.js +44 -13
- package/dist/close-job-template.js.map +1 -1
- package/dist/close-job.d.ts +20 -5
- package/dist/close-job.d.ts.map +1 -1
- package/dist/close-job.js +65 -12
- package/dist/close-job.js.map +1 -1
- package/dist/complete.d.ts.map +1 -1
- package/dist/complete.js +20 -1
- package/dist/complete.js.map +1 -1
- package/dist/config.d.ts +41 -44
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -4
- package/dist/config.js.map +1 -1
- package/dist/continue-branch.d.ts +63 -15
- package/dist/continue-branch.d.ts.map +1 -1
- package/dist/continue-branch.js +75 -8
- package/dist/continue-branch.js.map +1 -1
- package/dist/crashed-run-save.d.ts +73 -0
- package/dist/crashed-run-save.d.ts.map +1 -0
- package/dist/crashed-run-save.js +86 -0
- package/dist/crashed-run-save.js.map +1 -0
- package/dist/cwd-section.d.ts.map +1 -1
- package/dist/cwd-section.js +10 -2
- package/dist/cwd-section.js.map +1 -1
- package/dist/decision-engine.d.ts +10 -0
- package/dist/decision-engine.d.ts.map +1 -1
- package/dist/decision-engine.js.map +1 -1
- package/dist/do-config.d.ts +2 -24
- package/dist/do-config.d.ts.map +1 -1
- package/dist/do-config.js +1 -33
- package/dist/do-config.js.map +1 -1
- package/dist/do.d.ts +149 -1
- package/dist/do.d.ts.map +1 -1
- package/dist/do.js +115 -25
- package/dist/do.js.map +1 -1
- package/dist/dorfl-item-template.d.ts +98 -0
- package/dist/dorfl-item-template.d.ts.map +1 -0
- package/dist/dorfl-item-template.js +504 -0
- package/dist/dorfl-item-template.js.map +1 -0
- package/dist/env-config.d.ts.map +1 -1
- package/dist/env-config.js +7 -5
- package/dist/env-config.js.map +1 -1
- package/dist/frontmatter.d.ts +52 -0
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/frontmatter.js +136 -2
- package/dist/frontmatter.js.map +1 -1
- package/dist/gc.d.ts +13 -0
- package/dist/gc.d.ts.map +1 -1
- package/dist/gc.js +16 -2
- package/dist/gc.js.map +1 -1
- package/dist/git.d.ts +18 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +70 -5
- package/dist/git.js.map +1 -1
- package/dist/harness.d.ts +44 -5
- package/dist/harness.d.ts.map +1 -1
- package/dist/harness.js +24 -1
- package/dist/harness.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/install-ci-action-pins.d.ts +25 -0
- package/dist/install-ci-action-pins.d.ts.map +1 -1
- package/dist/install-ci-action-pins.js +25 -0
- package/dist/install-ci-action-pins.js.map +1 -1
- package/dist/install-ci-actions-pr-creation.d.ts +70 -0
- package/dist/install-ci-actions-pr-creation.d.ts.map +1 -0
- package/dist/install-ci-actions-pr-creation.js +106 -0
- package/dist/install-ci-actions-pr-creation.js.map +1 -0
- package/dist/install-ci-capabilities/dorfl-item.d.ts +12 -0
- package/dist/install-ci-capabilities/dorfl-item.d.ts.map +1 -0
- package/dist/install-ci-capabilities/dorfl-item.js +26 -0
- package/dist/install-ci-capabilities/dorfl-item.js.map +1 -0
- package/dist/install-ci-core.d.ts +173 -36
- package/dist/install-ci-core.d.ts.map +1 -1
- package/dist/install-ci-core.js +379 -186
- package/dist/install-ci-core.js.map +1 -1
- package/dist/install-ci-github.d.ts +47 -2
- package/dist/install-ci-github.d.ts.map +1 -1
- package/dist/install-ci-github.js +113 -1
- package/dist/install-ci-github.js.map +1 -1
- package/dist/install-ci.d.ts +25 -6
- package/dist/install-ci.d.ts.map +1 -1
- package/dist/install-ci.js +72 -36
- package/dist/install-ci.js.map +1 -1
- package/dist/intake-marker.d.ts +6 -1
- package/dist/intake-marker.d.ts.map +1 -1
- package/dist/intake-marker.js.map +1 -1
- package/dist/intake-triage.d.ts.map +1 -1
- package/dist/intake-triage.js +6 -2
- package/dist/intake-triage.js.map +1 -1
- package/dist/intake-trigger-template.d.ts +31 -25
- package/dist/intake-trigger-template.d.ts.map +1 -1
- package/dist/intake-trigger-template.js +107 -293
- package/dist/intake-trigger-template.js.map +1 -1
- package/dist/intake.d.ts +186 -4
- package/dist/intake.d.ts.map +1 -1
- package/dist/intake.js +533 -416
- package/dist/intake.js.map +1 -1
- package/dist/integration-core.d.ts +154 -1
- package/dist/integration-core.d.ts.map +1 -1
- package/dist/integration-core.js +759 -486
- package/dist/integration-core.js.map +1 -1
- package/dist/integrator.d.ts +12 -0
- package/dist/integrator.d.ts.map +1 -1
- package/dist/integrator.js +21 -0
- package/dist/integrator.js.map +1 -1
- package/dist/isolation.d.ts +12 -2
- package/dist/isolation.d.ts.map +1 -1
- package/dist/isolation.js +19 -8
- package/dist/isolation.js.map +1 -1
- package/dist/item-lock.d.ts +93 -11
- package/dist/item-lock.d.ts.map +1 -1
- package/dist/item-lock.js +233 -65
- package/dist/item-lock.js.map +1 -1
- package/dist/land-question-residue.d.ts +58 -0
- package/dist/land-question-residue.d.ts.map +1 -0
- package/dist/land-question-residue.js +95 -0
- package/dist/land-question-residue.js.map +1 -0
- package/dist/lifecycle-gather.d.ts +16 -0
- package/dist/lifecycle-gather.d.ts.map +1 -1
- package/dist/lifecycle-gather.js +54 -6
- package/dist/lifecycle-gather.js.map +1 -1
- package/dist/merge-answer.d.ts +41 -0
- package/dist/merge-answer.d.ts.map +1 -0
- package/dist/merge-answer.js +60 -0
- package/dist/merge-answer.js.map +1 -0
- package/dist/merge-question-surfacer.d.ts +105 -30
- package/dist/merge-question-surfacer.d.ts.map +1 -1
- package/dist/merge-question-surfacer.js +202 -91
- package/dist/merge-question-surfacer.js.map +1 -1
- package/dist/merge-question-tick.d.ts +64 -0
- package/dist/merge-question-tick.d.ts.map +1 -0
- package/dist/merge-question-tick.js +96 -0
- package/dist/merge-question-tick.js.map +1 -0
- package/dist/mint-adr.d.ts.map +1 -1
- package/dist/mint-adr.js +20 -2
- package/dist/mint-adr.js.map +1 -1
- package/dist/needs-attention.d.ts +72 -2
- package/dist/needs-attention.d.ts.map +1 -1
- package/dist/needs-attention.js +275 -38
- package/dist/needs-attention.js.map +1 -1
- package/dist/phase-recorder.d.ts +168 -0
- package/dist/phase-recorder.d.ts.map +1 -0
- package/dist/phase-recorder.js +218 -0
- package/dist/phase-recorder.js.map +1 -0
- package/dist/phase.d.ts +94 -0
- package/dist/phase.d.ts.map +1 -0
- package/dist/phase.js +148 -0
- package/dist/phase.js.map +1 -0
- package/dist/pi-harness.d.ts.map +1 -1
- package/dist/pi-harness.js +19 -6
- package/dist/pi-harness.js.map +1 -1
- package/dist/prepare.d.ts.map +1 -1
- package/dist/prepare.js +4 -0
- package/dist/prepare.js.map +1 -1
- package/dist/prompt.d.ts +4 -0
- package/dist/prompt.d.ts.map +1 -1
- package/dist/prompt.js +48 -1
- package/dist/prompt.js.map +1 -1
- package/dist/protocol/CLAIM-PROTOCOL.md +3 -1
- package/dist/protocol/WORK-CONTRACT.md +1 -1
- package/dist/reap-branches.d.ts +48 -0
- package/dist/reap-branches.d.ts.map +1 -1
- package/dist/reap-branches.js +64 -0
- package/dist/reap-branches.js.map +1 -1
- package/dist/ref-write.d.ts +198 -0
- package/dist/ref-write.d.ts.map +1 -0
- package/dist/ref-write.js +79 -0
- package/dist/ref-write.js.map +1 -0
- package/dist/repo-config.js +8 -8
- package/dist/repo-config.js.map +1 -1
- package/dist/repo-mirror.d.ts +36 -0
- package/dist/repo-mirror.d.ts.map +1 -1
- package/dist/repo-mirror.js +91 -1
- package/dist/repo-mirror.js.map +1 -1
- package/dist/review-verdict.d.ts +1 -1
- package/dist/review-verdict.js +1 -1
- package/dist/run.d.ts +7 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +28 -4
- package/dist/run.js.map +1 -1
- package/dist/scan.d.ts +19 -1
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +21 -8
- package/dist/scan.js.map +1 -1
- package/dist/sidecar.d.ts +14 -0
- package/dist/sidecar.d.ts.map +1 -1
- package/dist/sidecar.js +21 -0
- package/dist/sidecar.js.map +1 -1
- package/dist/single-job-warning.d.ts +63 -0
- package/dist/single-job-warning.d.ts.map +1 -0
- package/dist/single-job-warning.js +110 -0
- package/dist/single-job-warning.js.map +1 -0
- package/dist/skills/setup/protocol/CLAIM-PROTOCOL.md +3 -1
- package/dist/skills/setup/protocol/WORK-CONTRACT.md +1 -1
- package/dist/spec-complete.d.ts +13 -6
- package/dist/spec-complete.d.ts.map +1 -1
- package/dist/spec-complete.js +23 -11
- package/dist/spec-complete.js.map +1 -1
- package/dist/start.d.ts.map +1 -1
- package/dist/start.js +47 -14
- package/dist/start.js.map +1 -1
- package/dist/status.d.ts +12 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +11 -3
- package/dist/status.js.map +1 -1
- package/dist/tasking.d.ts +246 -1
- package/dist/tasking.d.ts.map +1 -1
- package/dist/tasking.js +452 -358
- package/dist/tasking.js.map +1 -1
- package/dist/triage-persist.d.ts.map +1 -1
- package/dist/triage-persist.js +21 -2
- package/dist/triage-persist.js.map +1 -1
- package/dist/verify-workflow-template.d.ts.map +1 -1
- package/dist/verify-workflow-template.js +6 -3
- package/dist/verify-workflow-template.js.map +1 -1
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +4 -0
- package/dist/verify.js.map +1 -1
- package/dist/watch-session.d.ts +42 -13
- package/dist/watch-session.d.ts.map +1 -1
- package/dist/watch-session.js +52 -23
- package/dist/watch-session.js.map +1 -1
- package/dist/work-layout.d.ts +10 -4
- package/dist/work-layout.d.ts.map +1 -1
- package/dist/work-layout.js +11 -3
- package/dist/work-layout.js.map +1 -1
- package/dist/workspace.d.ts +65 -4
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +159 -11
- package/dist/workspace.js.map +1 -1
- package/package.json +1 -1
- package/src/advance-ci-template.ts +80 -81
- package/src/advance-drivers.ts +45 -6
- package/src/advance-isolated.ts +3 -5
- package/src/advance-lifecycle-template.ts +371 -535
- package/src/advance-loop-driver.ts +3 -5
- package/src/advance-treeless-publish.ts +61 -0
- package/src/advance.ts +145 -15
- package/src/advancing-lock.ts +36 -1
- package/src/agent-env.ts +174 -0
- package/src/agent-stop.ts +81 -0
- package/src/apply-merge-action.ts +401 -154
- package/src/apply-stuck-action.ts +2 -2
- package/src/ci-agent-result.ts +421 -0
- package/src/ci-handoff-apply.ts +737 -0
- package/src/ci-handoff-format.ts +926 -0
- package/src/ci-handoff-lfs.ts +519 -0
- package/src/ci-handoff.ts +392 -0
- package/src/ci-lock-outputs.ts +273 -0
- package/src/ci-phase-build.ts +1328 -0
- package/src/ci-phase-driver.ts +548 -0
- package/src/ci-phase-intake.ts +861 -0
- package/src/ci-phase-tasking.ts +1255 -0
- package/src/ci-phase-treeless.ts +2028 -0
- package/src/ci-read-token.ts +90 -0
- package/src/cli.ts +591 -29
- package/src/close-job-template.ts +50 -14
- package/src/close-job.ts +77 -12
- package/src/complete.ts +19 -1
- package/src/config.ts +43 -48
- package/src/continue-branch.ts +121 -16
- package/src/crashed-run-save.ts +162 -0
- package/src/cwd-section.ts +10 -0
- package/src/decision-engine.ts +10 -0
- package/src/do-config.ts +2 -57
- package/src/do.ts +170 -28
- package/src/dorfl-item-template.ts +556 -0
- package/src/env-config.ts +7 -5
- package/src/frontmatter.ts +155 -2
- package/src/gc.ts +27 -2
- package/src/git.ts +83 -5
- package/src/harness.ts +58 -6
- package/src/index.ts +50 -1
- package/src/install-ci-action-pins.ts +25 -0
- package/src/install-ci-actions-pr-creation.ts +186 -0
- package/src/install-ci-capabilities/dorfl-item.ts +33 -0
- package/src/install-ci-core.ts +458 -218
- package/src/install-ci-github.ts +149 -1
- package/src/install-ci.ts +83 -37
- package/src/intake-marker.ts +6 -1
- package/src/intake-triage.ts +7 -3
- package/src/intake-trigger-template.ts +126 -328
- package/src/intake.ts +725 -544
- package/src/integration-core.ts +975 -523
- package/src/integrator.ts +28 -0
- package/src/isolation.ts +29 -10
- package/src/item-lock.ts +308 -92
- package/src/land-question-residue.ts +122 -0
- package/src/lifecycle-gather.ts +82 -10
- package/src/merge-answer.ts +82 -0
- package/src/merge-question-surfacer.ts +320 -112
- package/src/merge-question-tick.ts +182 -0
- package/src/mint-adr.ts +28 -2
- package/src/needs-attention.ts +350 -42
- package/src/phase-recorder.ts +350 -0
- package/src/phase.ts +177 -0
- package/src/pi-harness.ts +25 -5
- package/src/prepare.ts +4 -0
- package/src/prompt.ts +68 -1
- package/src/reap-branches.ts +107 -0
- package/src/ref-write.ts +324 -0
- package/src/repo-config.ts +8 -8
- package/src/repo-mirror.ts +107 -1
- package/src/review-verdict.ts +1 -1
- package/src/run.ts +47 -6
- package/src/scan.ts +37 -7
- package/src/sidecar.ts +36 -0
- package/src/single-job-warning.ts +135 -0
- package/src/spec-complete.ts +36 -14
- package/src/start.ts +55 -16
- package/src/status.ts +29 -3
- package/src/tasking.ts +593 -378
- package/src/triage-persist.ts +24 -2
- package/src/verify-workflow-template.ts +6 -3
- package/src/verify.ts +4 -0
- package/src/watch-session.ts +86 -28
- package/src/work-layout.ts +11 -3
- package/src/workspace.ts +210 -14
package/dist/install-ci-core.js
CHANGED
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
* This module is the PROVIDER-AGNOSTIC half: the config model (`ProviderEntry` /
|
|
11
11
|
* `AuthMode` / `CIConfigFile`), the `models.json` builder, the secret-orchestration
|
|
12
12
|
* LOGIC (which secrets, dedup, prompt-or-take-from-config), the `--export-config`
|
|
13
|
-
* (+ `--include-secrets`) round-trip, the composite-setup-action
|
|
14
|
-
* script generators, the `--fake` snapshot mechanism (write to `.fake/` instead of
|
|
13
|
+
* (+ `--include-secrets`) round-trip, the composite-setup-action generators, the `--fake` snapshot mechanism (write to `.fake/` instead of
|
|
15
14
|
* `.github/`), and the capability-emitter REGISTRY seam. It imports NOTHING
|
|
16
15
|
* GitHub-specific: the thin GitHub adapter (`github-ci.ts`) plugs into the
|
|
17
16
|
* {@link CIProviderContext} seam, so a second provider could slot in WITHOUT
|
|
@@ -27,7 +26,17 @@
|
|
|
27
26
|
import { readFileSync, writeFileSync, mkdirSync, readdirSync, existsSync, } from 'node:fs';
|
|
28
27
|
import { dirname, join, relative } from 'node:path';
|
|
29
28
|
import { fileURLToPath } from 'node:url';
|
|
29
|
+
import { NO_FORWARD_ENV } from './bootstrap-forward.js';
|
|
30
|
+
import { REPO_CONFIG_FILENAME, REPO_CONFIG_FILENAME_LEGACY, } from './repo-config.js';
|
|
30
31
|
import { ACTION_PINS, pinnedUses, preserveExistingPins, } from './install-ci-action-pins.js';
|
|
32
|
+
/**
|
|
33
|
+
* The refusal a config naming the removed `auth-json` mode gets: it says the
|
|
34
|
+
* mode is gone and names the replacement (`models-json` + a proxy `baseUrl`).
|
|
35
|
+
*/
|
|
36
|
+
export const AUTH_JSON_REMOVED_MESSAGE = 'config file "authMode": "auth-json" is no longer supported (the mode was ' +
|
|
37
|
+
'removed: its OAuth refresh needed a write-capable GH_PAT in the agent job). ' +
|
|
38
|
+
'Use "authMode": "models-json" and point a provider\'s "baseUrl" at a proxy ' +
|
|
39
|
+
'that handles credential rotation outside GitHub.';
|
|
31
40
|
/** Parse a provider's visibility answer (`PUBLIC`, `private`, ...); unknown ⇒ `undefined`. */
|
|
32
41
|
export function parseRepoVisibility(raw) {
|
|
33
42
|
const v = raw.trim().toLowerCase();
|
|
@@ -126,15 +135,20 @@ function pathToFileUrl(absPath) {
|
|
|
126
135
|
// ─── models.json generation ──────────────────────────────────────────────────
|
|
127
136
|
/**
|
|
128
137
|
* Build the harness `models.json` object from the providers. Built-in providers
|
|
129
|
-
* (`anthropic`/`openai`) get `{apiKey:
|
|
130
|
-
* var at runtime); a custom provider carries its `baseUrl`/`api`/`models`/`compat`.
|
|
138
|
+
* (`anthropic`/`openai`) get `{apiKey: "$<ENV_VAR>"}` (the harness resolves the
|
|
139
|
+
* env var at runtime); a custom provider carries its `baseUrl`/`api`/`models`/`compat`.
|
|
131
140
|
* Mirrors whitesmith's `buildModelsJson`.
|
|
141
|
+
*
|
|
142
|
+
* The `apiKey` is an env-var REFERENCE (see {@link modelsJsonEnvRef}), never the
|
|
143
|
+
* bare env-var name: pi treats a bare value as a LITERAL key.
|
|
132
144
|
*/
|
|
133
145
|
export function buildModelsJson(providers) {
|
|
134
146
|
const providersObj = {};
|
|
135
147
|
for (const p of providers) {
|
|
136
148
|
if (p.builtin) {
|
|
137
|
-
const entry = {
|
|
149
|
+
const entry = {
|
|
150
|
+
apiKey: modelsJsonEnvRef(p.apiKeyEnvVar),
|
|
151
|
+
};
|
|
138
152
|
if (p.baseUrl)
|
|
139
153
|
entry.baseUrl = p.baseUrl;
|
|
140
154
|
providersObj[p.name] = entry;
|
|
@@ -143,7 +157,7 @@ export function buildModelsJson(providers) {
|
|
|
143
157
|
const entry = {
|
|
144
158
|
baseUrl: p.baseUrl,
|
|
145
159
|
api: p.api,
|
|
146
|
-
apiKey: p.apiKeyEnvVar,
|
|
160
|
+
apiKey: modelsJsonEnvRef(p.apiKeyEnvVar),
|
|
147
161
|
models: p.models,
|
|
148
162
|
};
|
|
149
163
|
if (p.compat)
|
|
@@ -153,18 +167,25 @@ export function buildModelsJson(providers) {
|
|
|
153
167
|
}
|
|
154
168
|
return { providers: providersObj };
|
|
155
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* The `models.json` config value that makes the pi harness read `envVarName`
|
|
172
|
+
* from the environment: `"$NAME"`. The pinned harness
|
|
173
|
+
* (`@earendil-works/pi-coding-agent`, `dist/core/resolve-config-value.js`)
|
|
174
|
+
* resolves a config value as a shell command when it starts with `!`, as an env
|
|
175
|
+
* var when it is `$NAME` / `${NAME}`, and as a LITERAL otherwise. Writing the bare
|
|
176
|
+
* name therefore sent the string `ANTHROPIC_API_KEY` as the token (`401
|
|
177
|
+
* Unauthorized` on every CI launch).
|
|
178
|
+
*/
|
|
179
|
+
export function modelsJsonEnvRef(envVarName) {
|
|
180
|
+
return `$${envVarName}`;
|
|
181
|
+
}
|
|
156
182
|
// ─── secret-orchestration LOGIC (which secrets, dedup) ───────────────────────
|
|
157
183
|
/**
|
|
158
184
|
* The DEDUPLICATED set of secret env-var names the config requires, in first-seen
|
|
159
|
-
* order
|
|
160
|
-
* for `auth-json` mode it is the fixed `PI_AUTH_JSON` + `GH_PAT` pair (the sharp
|
|
161
|
-
* edge). This is the pure secret-orchestration LOGIC the adapter's setter
|
|
185
|
+
* order: one per distinct provider `apiKeyEnvVar`. This is the pure secret-orchestration LOGIC the adapter's setter
|
|
162
186
|
* consumes — which secrets, deduped — separated from any provider I/O.
|
|
163
187
|
*/
|
|
164
188
|
export function requiredSecretNames(config) {
|
|
165
|
-
if (config.authMode === 'auth-json') {
|
|
166
|
-
return ['PI_AUTH_JSON', 'GH_PAT'];
|
|
167
|
-
}
|
|
168
189
|
const seen = new Set();
|
|
169
190
|
const names = [];
|
|
170
191
|
for (const p of config.providers) {
|
|
@@ -177,13 +198,13 @@ export function requiredSecretNames(config) {
|
|
|
177
198
|
}
|
|
178
199
|
/**
|
|
179
200
|
* The GitHub secret the propose/merge CI legs read as `GH_TOKEN` to open PRs
|
|
180
|
-
* under a CHOSEN identity (a PAT / App token).
|
|
181
|
-
* distinct purpose from `auth-json` mode's `GH_PAT` (which exists only to rotate
|
|
182
|
-
* the OAuth `PI_AUTH_JSON` secret). The generated workflows reference it as
|
|
201
|
+
* under a CHOSEN identity (a PAT / App token). The generated workflows reference it as
|
|
183
202
|
* `${{ secrets.DORFL_GH_TOKEN || secrets.GITHUB_TOKEN }}` so it is
|
|
184
203
|
* OPTIONAL: unset ⇒ the legs fall back to the built-in `GITHUB_TOKEN` (PRs are
|
|
185
|
-
* `github-actions[bot]
|
|
186
|
-
*
|
|
204
|
+
* `github-actions[bot]`, and GitHub holds their `on: pull_request` runs in
|
|
205
|
+
* `action_required` until someone approves them); set ⇒ PRs carry the token's
|
|
206
|
+
* identity and trigger those workflows on their own. `intake.yml` never passes
|
|
207
|
+
* it, so intake PRs always need the approval (`docs/ci/README.md`).
|
|
187
208
|
*/
|
|
188
209
|
export const PR_IDENTITY_SECRET_NAME = 'DORFL_GH_TOKEN';
|
|
189
210
|
/**
|
|
@@ -208,13 +229,13 @@ export function optionalSecretNames(config) {
|
|
|
208
229
|
* entry). Each entry maps the action input (named identically to the secret) to
|
|
209
230
|
* `${{ secrets.<NAME> }}`.
|
|
210
231
|
*
|
|
211
|
-
* Empty string when there are no provider keys (
|
|
232
|
+
* Empty string when there are no provider keys (no providers),
|
|
212
233
|
* so the `uses:` line is emitted bare and unchanged. This is the SINGLE place the
|
|
213
234
|
* provider→`with:` shape lives, shared by every capability workflow generator, so
|
|
214
235
|
* no template re-derives it.
|
|
215
236
|
*/
|
|
216
237
|
export function providerSecretsWithBlock(config) {
|
|
217
|
-
const names =
|
|
238
|
+
const names = providerSecretNames(config);
|
|
218
239
|
if (names.length === 0) {
|
|
219
240
|
return '';
|
|
220
241
|
}
|
|
@@ -223,6 +244,16 @@ export function providerSecretsWithBlock(config) {
|
|
|
223
244
|
.join('\n');
|
|
224
245
|
return `\n with:\n${entries}`;
|
|
225
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* The provider API key secrets the AGENT-running jobs forward to the setup
|
|
249
|
+
* action: one per distinct provider key (the same set as
|
|
250
|
+
* {@link requiredSecretNames}). The split item workflow declares exactly these (plus
|
|
251
|
+
* {@link PR_IDENTITY_SECRET_NAME}) as its `workflow_call` secrets, and hands
|
|
252
|
+
* them to its agent job only.
|
|
253
|
+
*/
|
|
254
|
+
export function providerSecretNames(config) {
|
|
255
|
+
return requiredSecretNames(config);
|
|
256
|
+
}
|
|
226
257
|
/**
|
|
227
258
|
* Orchestrate the required secrets through the provider seam: for each
|
|
228
259
|
* DEDUPLICATED required name, take its value from `knownSecrets` (the
|
|
@@ -290,10 +321,17 @@ export function loadCIConfigFile(filePath) {
|
|
|
290
321
|
throw new CIConfigError(`could not read/parse config file ${filePath}: ` +
|
|
291
322
|
(err instanceof Error ? err.message : String(err)));
|
|
292
323
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
324
|
+
// `authMode` is kept as a key (so existing configs still parse) but the only
|
|
325
|
+
// accepted value is `models-json`. The removed `auth-json` mode gets a refusal
|
|
326
|
+
// that names its replacement rather than the generic "must be" message.
|
|
327
|
+
const rawAuthMode = data.authMode;
|
|
328
|
+
if (rawAuthMode === 'auth-json') {
|
|
329
|
+
throw new CIConfigError(AUTH_JSON_REMOVED_MESSAGE);
|
|
330
|
+
}
|
|
331
|
+
if (rawAuthMode !== undefined && rawAuthMode !== 'models-json') {
|
|
332
|
+
throw new CIConfigError(`config file "authMode" must be "models-json"`);
|
|
296
333
|
}
|
|
334
|
+
const authMode = 'models-json';
|
|
297
335
|
if (!data.defaultProvider) {
|
|
298
336
|
throw new CIConfigError('config file must contain "defaultProvider"');
|
|
299
337
|
}
|
|
@@ -314,16 +352,14 @@ export function loadCIConfigFile(filePath) {
|
|
|
314
352
|
'the per-provider payload is OPAQUE to the core');
|
|
315
353
|
}
|
|
316
354
|
}
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
throw new CIConfigError('config file (models-json) must contain a non-empty "providers" array');
|
|
322
|
-
}
|
|
355
|
+
if (!data.providers ||
|
|
356
|
+
!Array.isArray(data.providers) ||
|
|
357
|
+
data.providers.length === 0) {
|
|
358
|
+
throw new CIConfigError('config file (models-json) must contain a non-empty "providers" array');
|
|
323
359
|
}
|
|
324
360
|
return {
|
|
325
361
|
authMode,
|
|
326
|
-
providers: data.providers
|
|
362
|
+
providers: data.providers,
|
|
327
363
|
defaultProvider: data.defaultProvider,
|
|
328
364
|
defaultModel: data.defaultModel,
|
|
329
365
|
harness: data.harness,
|
|
@@ -373,7 +409,7 @@ export function exportCIConfig(config, secrets) {
|
|
|
373
409
|
}
|
|
374
410
|
return JSON.stringify(file, null, 2) + '\n';
|
|
375
411
|
}
|
|
376
|
-
// ─── composite setup action
|
|
412
|
+
// ─── composite setup action generation ───────────────────────────────────────
|
|
377
413
|
/** Indent every non-blank line of `text` by `spaces` spaces. */
|
|
378
414
|
function indent(text, spaces) {
|
|
379
415
|
const pad = ' '.repeat(spaces);
|
|
@@ -412,6 +448,48 @@ export const PI_HARNESS_PACKAGE = '@earendil-works/pi-coding-agent';
|
|
|
412
448
|
* `node-version: '22'` satisfies (setup-node resolves the latest 22.x).
|
|
413
449
|
*/
|
|
414
450
|
export const PI_HARNESS_VERSION = '0.80.6';
|
|
451
|
+
/**
|
|
452
|
+
* The `pi` packages the harness LOADS besides itself, each pinned to an exact
|
|
453
|
+
* version that is known to load with {@link PI_HARNESS_VERSION}.
|
|
454
|
+
*
|
|
455
|
+
* `pi-coding-agent` declares its sibling packages with a caret range
|
|
456
|
+
* (`@earendil-works/pi-ai: ^0.80.6`), which on a `0.x` version floats within
|
|
457
|
+
* the minor. `pi-ai@0.80.10` removed the `getOAuthApiKey` export that
|
|
458
|
+
* `pi-coding-agent@0.80.6` imports, so a resolver that honours the caret kills
|
|
459
|
+
* `pi` on start. npm happens to be protected by the `npm-shrinkwrap.json` the
|
|
460
|
+
* package publishes; pnpm ignores that file and was broken. Pinning the family
|
|
461
|
+
* explicitly (as npm `overrides`, see {@link piHarnessManifest}) makes the
|
|
462
|
+
* install reproducible whatever the resolver.
|
|
463
|
+
*
|
|
464
|
+
* The set is `pi-coding-agent`'s own `@earendil-works/*` dependencies plus
|
|
465
|
+
* theirs (`npm view @earendil-works/pi-coding-agent@<v> dependencies`,
|
|
466
|
+
* recursively): at 0.80.6 that is pi-ai, pi-agent-core (which depends on pi-ai)
|
|
467
|
+
* and pi-tui. Re-derive it on every {@link PI_HARNESS_VERSION} bump: a newer
|
|
468
|
+
* harness may add a package (0.87 adds `@earendil-works/chord`).
|
|
469
|
+
*/
|
|
470
|
+
export const PI_HARNESS_PINNED_DEPENDENCIES = {
|
|
471
|
+
'@earendil-works/pi-agent-core': PI_HARNESS_VERSION,
|
|
472
|
+
'@earendil-works/pi-ai': PI_HARNESS_VERSION,
|
|
473
|
+
'@earendil-works/pi-tui': PI_HARNESS_VERSION,
|
|
474
|
+
};
|
|
475
|
+
/**
|
|
476
|
+
* The throwaway `package.json` the setup action installs the harness from: the
|
|
477
|
+
* harness at {@link PI_HARNESS_VERSION} as the only dependency, and every pi
|
|
478
|
+
* package it loads forced to its exact pin through npm `overrides`.
|
|
479
|
+
*
|
|
480
|
+
* A project-local install (not `npm install -g`) because `overrides` only apply
|
|
481
|
+
* to the ROOT project, and a global install makes each package its own root. The
|
|
482
|
+
* same file is used in `registry` and `workspace` mode: pnpm 11 also isolates
|
|
483
|
+
* every global package, so listing the pins next to the harness in
|
|
484
|
+
* `pnpm add -g` would not constrain the harness's own tree either.
|
|
485
|
+
*/
|
|
486
|
+
export function piHarnessManifest() {
|
|
487
|
+
return {
|
|
488
|
+
private: true,
|
|
489
|
+
dependencies: { [PI_HARNESS_PACKAGE]: PI_HARNESS_VERSION },
|
|
490
|
+
overrides: { ...PI_HARNESS_PINNED_DEPENDENCIES },
|
|
491
|
+
};
|
|
492
|
+
}
|
|
415
493
|
/**
|
|
416
494
|
* The version of THIS dorfl package, read at runtime from its own
|
|
417
495
|
* `package.json` (the single source changesets bumps on release). The composite
|
|
@@ -443,25 +521,47 @@ export function dorflPackageVersion() {
|
|
|
443
521
|
}
|
|
444
522
|
return version;
|
|
445
523
|
}
|
|
524
|
+
/** Where the setup action installs the harness (under the job's temp dir). */
|
|
525
|
+
const PI_HARNESS_DIR = '$RUNNER_TEMP/dorfl-harness';
|
|
446
526
|
/**
|
|
447
|
-
* The install
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
* `$GITHUB_PATH
|
|
527
|
+
* The install + smoke steps for the configured harness (the `pi` CLI; `''` ⇒
|
|
528
|
+
* none). Identical in `registry` and `workspace` mode: the harness is installed
|
|
529
|
+
* with npm from {@link piHarnessManifest} into a job-local directory whose
|
|
530
|
+
* `node_modules/.bin` is added to `$GITHUB_PATH`, so every pi package it loads
|
|
531
|
+
* is pinned whatever package manager the repository uses. The smoke step then
|
|
532
|
+
* runs `pi --version`, which imports the harness's whole module graph, so a
|
|
533
|
+
* broken install fails setup with a clear message instead of failing inside a
|
|
534
|
+
* dorfl agent launch.
|
|
451
535
|
*/
|
|
452
|
-
function harnessInstallStep(harness
|
|
536
|
+
function harnessInstallStep(harness) {
|
|
453
537
|
if (harness === 'pi') {
|
|
454
|
-
const
|
|
455
|
-
const run = installSource === 'workspace'
|
|
456
|
-
? `pnpm add -g ${spec}`
|
|
457
|
-
: `npm install -g ${spec}`;
|
|
538
|
+
const manifest = JSON.stringify(piHarnessManifest(), null, 2);
|
|
458
539
|
return `
|
|
459
540
|
# Pinned to the exact harness version this dorfl release declares
|
|
460
|
-
# (PI_HARNESS_VERSION)
|
|
461
|
-
#
|
|
541
|
+
# (PI_HARNESS_VERSION), with every pi package it loads pinned too (npm
|
|
542
|
+
# \`overrides\`; a caret range on a 0.x version floats within the minor): the
|
|
543
|
+
# job holds a provider key, so no version may move on its own. Re-run
|
|
544
|
+
# \`dorfl install-ci\` to upgrade.
|
|
462
545
|
- name: Install agent harness (pi)
|
|
463
546
|
shell: bash
|
|
464
|
-
run:
|
|
547
|
+
run: |
|
|
548
|
+
mkdir -p "${PI_HARNESS_DIR}"
|
|
549
|
+
cd "${PI_HARNESS_DIR}"
|
|
550
|
+
cat > package.json << 'HARNESS_EOF'
|
|
551
|
+
${indent(manifest, 8)}
|
|
552
|
+
HARNESS_EOF
|
|
553
|
+
npm install --no-audit --no-fund
|
|
554
|
+
echo "${PI_HARNESS_DIR}/node_modules/.bin" >> "$GITHUB_PATH"
|
|
555
|
+
|
|
556
|
+
# \`pi --version\` loads the harness's module graph, so an install whose pi
|
|
557
|
+
# packages do not load together fails HERE, not inside a dorfl agent launch.
|
|
558
|
+
- name: Check the agent harness loads (pi)
|
|
559
|
+
shell: bash
|
|
560
|
+
run: |
|
|
561
|
+
if ! pi --version; then
|
|
562
|
+
echo "::error title=dorfl-setup::The agent harness (pi) is installed but cannot start, so its pi packages do not load together. Re-run dorfl install-ci with a dorfl release that pins a working harness."
|
|
563
|
+
exit 1
|
|
564
|
+
fi`;
|
|
465
565
|
}
|
|
466
566
|
return '';
|
|
467
567
|
}
|
|
@@ -473,14 +573,11 @@ function harnessInstallStep(harness, installSource) {
|
|
|
473
573
|
* `uses: ./.github/actions/dorfl-setup`. The advance-loop seed template
|
|
474
574
|
* already references this exact action name + path (`docs/ci/README.md`).
|
|
475
575
|
*
|
|
476
|
-
* The auth step
|
|
477
|
-
* `~/.pi/agent/models.json` inline (the conservative default) AND exports each
|
|
576
|
+
* The auth step writes a generated `~/.pi/agent/models.json` inline AND exports each
|
|
478
577
|
* configured provider's API key from a same-named ACTION INPUT to `$GITHUB_ENV`,
|
|
479
578
|
* so the agent step (`pi`) can resolve the env var `models.json` references; the
|
|
480
579
|
* workflow passes the secrets ONCE via `with:` on the `uses:` line (no
|
|
481
|
-
* per-step / per-capability provider enumeration).
|
|
482
|
-
* `~/.pi/agent/auth.json` from `$PI_AUTH_JSON` + runs the OAuth-refresh script
|
|
483
|
-
* (the sharp edge). Deterministic: the same config produces byte-identical output.
|
|
580
|
+
* per-step / per-capability provider enumeration). Deterministic: the same config produces byte-identical output.
|
|
484
581
|
*/
|
|
485
582
|
export function generateSetupAction(config,
|
|
486
583
|
/**
|
|
@@ -492,43 +589,24 @@ export function generateSetupAction(config,
|
|
|
492
589
|
* baseline (the load-bearing absent-⇒-identical contract).
|
|
493
590
|
*/
|
|
494
591
|
projectSetupSteps) {
|
|
495
|
-
|
|
496
|
-
//
|
|
497
|
-
//
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
echo "$
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
# CI→repo mutation in the design; needs GH_PAT to rotate PI_AUTH_JSON.
|
|
514
|
-
- name: Refresh OAuth token
|
|
515
|
-
shell: bash
|
|
516
|
-
run: node .github/scripts/refresh-oauth-token.mjs`;
|
|
517
|
-
}
|
|
518
|
-
else {
|
|
519
|
-
const modelsJsonStr = JSON.stringify(buildModelsJson(config.providers), null, 2);
|
|
520
|
-
// Map each provider-key INPUT into the step env, then append the non-empty
|
|
521
|
-
// ones to `$GITHUB_ENV` so the agent step inherits them. Values flow via env
|
|
522
|
-
// (never interpolated into the script body), and Actions masks the secret in
|
|
523
|
-
// logs. `models.json`'s `apiKey` is the env-var NAME; this puts the value there.
|
|
524
|
-
const exportEnvLines = providerKeyNames
|
|
525
|
-
.map((name) => ` ${name}: \${{ inputs.${name} }}`)
|
|
526
|
-
.join('\n');
|
|
527
|
-
const exportRunLines = providerKeyNames
|
|
528
|
-
.map((name) => ` if [ -n "\${${name}}" ]; then echo "${name}=\${${name}}" >> "$GITHUB_ENV"; fi`)
|
|
529
|
-
.join('\n');
|
|
530
|
-
const exportStep = providerKeyNames.length > 0
|
|
531
|
-
? `\n
|
|
592
|
+
// models-json mode (the only mode) declares one ACTION INPUT per distinct
|
|
593
|
+
// provider key (named identically to the secret / env var) and exports it to
|
|
594
|
+
// `$GITHUB_ENV`, so every later step inherits it.
|
|
595
|
+
const providerKeyNames = providerSecretNames(config);
|
|
596
|
+
const modelsJsonStr = JSON.stringify(buildModelsJson(config.providers), null, 2);
|
|
597
|
+
// Map each provider-key INPUT into the step env, then append the non-empty
|
|
598
|
+
// ones to `$GITHUB_ENV` so the agent step inherits them. Values flow via env
|
|
599
|
+
// (never interpolated into the script body), and Actions masks the secret in
|
|
600
|
+
// logs. `models.json`'s `apiKey` is a `$NAME` env-var REFERENCE (pi resolves it at
|
|
601
|
+
// runtime; a bare name would be a literal key); this puts the value there.
|
|
602
|
+
const exportEnvLines = providerKeyNames
|
|
603
|
+
.map((name) => ` ${name}: \${{ inputs.${name} }}`)
|
|
604
|
+
.join('\n');
|
|
605
|
+
const exportRunLines = providerKeyNames
|
|
606
|
+
.map((name) => ` if [ -n "\${${name}}" ]; then echo "${name}=\${${name}}" >> "$GITHUB_ENV"; fi`)
|
|
607
|
+
.join('\n');
|
|
608
|
+
const exportStep = providerKeyNames.length > 0
|
|
609
|
+
? `\n
|
|
532
610
|
# Surface the configured provider API key(s) to the environment so the agent
|
|
533
611
|
# step (\`pi\`) can resolve the env var \`models.json\` references. The workflow
|
|
534
612
|
# passes the secret(s) via \`with:\` on the \`uses:\` line; we forward the
|
|
@@ -539,8 +617,8 @@ projectSetupSteps) {
|
|
|
539
617
|
${exportEnvLines}
|
|
540
618
|
run: |
|
|
541
619
|
${exportRunLines}`
|
|
542
|
-
|
|
543
|
-
|
|
620
|
+
: '';
|
|
621
|
+
const authStep = `\
|
|
544
622
|
- name: Configure agent models (models.json)
|
|
545
623
|
shell: bash
|
|
546
624
|
run: |
|
|
@@ -548,15 +626,14 @@ ${exportRunLines}`
|
|
|
548
626
|
cat > ~/.pi/agent/models.json << 'MODELS_EOF'
|
|
549
627
|
${indent(modelsJsonStr, 8)}
|
|
550
628
|
MODELS_EOF${exportStep}`;
|
|
551
|
-
|
|
552
|
-
const installHarness = harnessInstallStep(config.harness, config.installSource);
|
|
629
|
+
const installHarness = harnessInstallStep(config.harness);
|
|
553
630
|
// The CLI-install block branches on installSource. `registry` installs the
|
|
554
631
|
// published CLI via `npm install -g dorfl` (the default for every
|
|
555
632
|
// consumer repo). `workspace` builds the CLI from the checked-out source and
|
|
556
633
|
// links it onto PATH — for the self-hosting dorfl monorepo, which is
|
|
557
634
|
// not published under that npm name. We add pnpm's global bin to $GITHUB_PATH
|
|
558
|
-
// so the linked `dorfl`
|
|
559
|
-
//
|
|
635
|
+
// so the linked `dorfl` is on PATH in all subsequent steps (the harness adds
|
|
636
|
+
// its own bin dir, the same way in both modes); we always rebuild because source changes per commit.
|
|
560
637
|
let installSteps;
|
|
561
638
|
if (config.installSource === 'workspace') {
|
|
562
639
|
installSteps = `\
|
|
@@ -610,10 +687,9 @@ ${indent(modelsJsonStr, 8)}
|
|
|
610
687
|
// would exec the local bin which then forwards AGAIN — a confusing
|
|
611
688
|
// double-resolution. The install step below leaves `dorfl` on `$PATH` as the
|
|
612
689
|
// bootstrap; the forward does the pinning.
|
|
613
|
-
// One optional ACTION INPUT per provider key
|
|
614
|
-
//
|
|
615
|
-
//
|
|
616
|
-
// step skips an empty value. auth-json mode declares no inputs.
|
|
690
|
+
// One optional ACTION INPUT per provider key, named identically to the
|
|
691
|
+
// secret/env var. Optional + default '' so a workflow that does not pass it is
|
|
692
|
+
// valid; the export step skips an empty value.
|
|
617
693
|
const inputsBlock = providerKeyNames.length > 0
|
|
618
694
|
? `inputs:
|
|
619
695
|
${providerKeyNames
|
|
@@ -672,109 +748,228 @@ ${installSteps}
|
|
|
672
748
|
${authStep}
|
|
673
749
|
`;
|
|
674
750
|
}
|
|
751
|
+
/** The local path a workflow step `uses:` for the agent-role setup action. */
|
|
752
|
+
export const SETUP_ACTION_USES = './.github/actions/dorfl-setup';
|
|
753
|
+
/** The local path a workflow step `uses:` for the writer-role setup action. */
|
|
754
|
+
export const WRITER_SETUP_ACTION_USES = './.github/actions/dorfl-setup-writer';
|
|
675
755
|
/**
|
|
676
|
-
*
|
|
677
|
-
* `
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
*
|
|
756
|
+
* Generate the WRITER-ROLE composite setup action (`dorfl-setup-writer`, spec
|
|
757
|
+
* `ci-agent-job-without-write-token` §9, ADR
|
|
758
|
+
* `ci-agent-job-holds-no-write-token`; task `ci-split-generate-workflows`).
|
|
759
|
+
*
|
|
760
|
+
* The jobs that hold a write token and run no agent (the split item
|
|
761
|
+
* workflow's lock and apply jobs, `reap-merged-branches`, `close-job`, and the
|
|
762
|
+
* read-only `enumerate`) install Node and dorfl ONLY: no harness, no provider
|
|
763
|
+
* key, no `models.json`, no project-setup hook, no install of the project's
|
|
764
|
+
* dependencies, and no Actions cache. In `registry` mode the dorfl install runs
|
|
765
|
+
* from `$RUNNER_TEMP`, outside the checkout, with `--ignore-scripts`, so a
|
|
766
|
+
* repository `.npmrc` cannot redirect the registry and no install script runs.
|
|
686
767
|
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
768
|
+
* In `workspace` mode (dorfl's own repository) dorfl is built from source
|
|
769
|
+
* (decision 8): the tree of `source-ref` (default the checkout's `HEAD`) is
|
|
770
|
+
* exported with `git archive` into `$RUNNER_TEMP` and built there with
|
|
771
|
+
* `--ignore-scripts`. In merge mode that is code an earlier agent landed on
|
|
772
|
+
* `main`, which is the trust merge mode already implies.
|
|
691
773
|
*
|
|
692
|
-
*
|
|
774
|
+
* In both modes it then exports `DORFL_NO_FORWARD=1` for the rest of the job
|
|
775
|
+
* ({@link writerNoForwardStep}): the writer role never forwards to the
|
|
776
|
+
* repository's `dorflCmd`, which usually points into dependencies this role
|
|
777
|
+
* never installs. In `registry` mode it also warns when the repository pins a
|
|
778
|
+
* different dorfl version ({@link WRITER_PIN_CHECK_SCRIPT}).
|
|
779
|
+
*
|
|
780
|
+
* It is a SIBLING action rather than a `role` input on `dorfl-setup`: the
|
|
781
|
+
* project-setup hook is an opaque fragment spliced first into `dorfl-setup`
|
|
782
|
+
* (ADR `install-ci-project-provisioning-native-passthrough`), and a composite
|
|
783
|
+
* action cannot skip an opaque block of steps by input. `dorfl-setup` stays the
|
|
784
|
+
* agent role, byte for byte.
|
|
693
785
|
*/
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
786
|
+
export function generateWriterSetupAction(config) {
|
|
787
|
+
let installSteps;
|
|
788
|
+
let inputsBlock = '';
|
|
789
|
+
// Registry mode only: warn when the repository's `dorflCmd` names an exact
|
|
790
|
+
// `dorfl@<version>` that is not the version pinned here. Workspace mode builds
|
|
791
|
+
// dorfl from the checked-out source, so there is no second version to compare.
|
|
792
|
+
let pinCheckStep = '';
|
|
793
|
+
if (config.installSource === 'workspace') {
|
|
794
|
+
inputsBlock = `inputs:
|
|
795
|
+
source-ref:
|
|
796
|
+
description: 'The commit to build dorfl from (workspace mode). Blank: the checkout HEAD.'
|
|
797
|
+
required: false
|
|
798
|
+
default: ''
|
|
700
799
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
800
|
+
`;
|
|
801
|
+
installSteps = `\
|
|
802
|
+
- name: Setup pnpm
|
|
803
|
+
uses: ${pinnedUses(ACTION_PINS.pnpmSetup)}
|
|
704
804
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
805
|
+
- name: Add pnpm global bin to PATH
|
|
806
|
+
shell: bash
|
|
807
|
+
run: |
|
|
808
|
+
pnpm setup
|
|
809
|
+
echo "$HOME/.local/share/pnpm" >> "$GITHUB_PATH"
|
|
709
810
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
811
|
+
# Workspace mode (dorfl's own repository, decision 8 of ADR
|
|
812
|
+
# ci-agent-job-holds-no-write-token): build dorfl from the tree of
|
|
813
|
+
# \`source-ref\`, exported into $RUNNER_TEMP (outside the checkout), with
|
|
814
|
+
# \`--ignore-scripts\`. In merge mode this is code an earlier agent landed on
|
|
815
|
+
# main running in a write job, the trust merge mode already implies.
|
|
816
|
+
# Only dorfl and its workspace dependencies (\`--filter 'dorfl...'\`) are
|
|
817
|
+
# installed and built: the other workspace packages (the website) are not
|
|
818
|
+
# needed to run dorfl, so they do not run next to the write token.
|
|
819
|
+
- name: Build dorfl from the base commit (outside the checkout)
|
|
820
|
+
shell: bash
|
|
821
|
+
env:
|
|
822
|
+
SOURCE_REF: \${{ inputs.source-ref }}
|
|
823
|
+
run: |
|
|
824
|
+
set -euo pipefail
|
|
825
|
+
src="$RUNNER_TEMP/dorfl-src"
|
|
826
|
+
rm -rf "$src"
|
|
827
|
+
mkdir -p "$src"
|
|
828
|
+
git archive "$(git rev-parse --verify "\${SOURCE_REF:-HEAD}^{commit}")" | tar -x -C "$src"
|
|
829
|
+
cd "$src"
|
|
830
|
+
pnpm install --frozen-lockfile --ignore-scripts --filter 'dorfl...'
|
|
831
|
+
pnpm --filter 'dorfl...' build
|
|
832
|
+
cd packages/dorfl && pnpm link --global`;
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
installSteps = `\
|
|
836
|
+
# Pinned to the dorfl version that generated this action. Installed from
|
|
837
|
+
# $RUNNER_TEMP (outside the checkout, so a repository .npmrc cannot redirect
|
|
838
|
+
# the registry) with --ignore-scripts (no install script runs next to the
|
|
839
|
+
# write token).
|
|
840
|
+
- name: Install dorfl (outside the checkout, no install scripts)
|
|
841
|
+
shell: bash
|
|
842
|
+
run: |
|
|
843
|
+
cd "$RUNNER_TEMP"
|
|
844
|
+
npm install -g --ignore-scripts dorfl@${dorflPackageVersion()}`;
|
|
845
|
+
pinCheckStep = writerPinCheckStep(dorflPackageVersion());
|
|
846
|
+
}
|
|
847
|
+
return `\
|
|
848
|
+
name: Setup dorfl (writer role)
|
|
849
|
+
description: Install Node.js and dorfl only, for the CI jobs that run no agent (lock, apply, reap, close, enumerate)
|
|
714
850
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
851
|
+
${inputsBlock}# THE WRITER ROLE (ADR ci-agent-job-holds-no-write-token): the jobs that use
|
|
852
|
+
# this action hold a write token (or run next to one) and run NO agent and NO
|
|
853
|
+
# repository code. So it installs Node.js and dorfl ONLY: no agent harness, no
|
|
854
|
+
# provider API key, no models.json, no project-setup hook, no install of the
|
|
855
|
+
# project's dependencies, and no Actions cache (an agent can write
|
|
856
|
+
# default-branch cache entries, so a restore here would run its bytes with
|
|
857
|
+
# write access). The agent role is ./.github/actions/dorfl-setup.
|
|
858
|
+
runs:
|
|
859
|
+
using: composite
|
|
860
|
+
steps:
|
|
861
|
+
- name: Setup Node.js
|
|
862
|
+
uses: ${pinnedUses(ACTION_PINS.setupNode)}
|
|
863
|
+
with:
|
|
864
|
+
node-version: '22'
|
|
865
|
+
# No cache in the writer role (see above).
|
|
866
|
+
package-manager-cache: false
|
|
720
867
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
},
|
|
727
|
-
body: new URLSearchParams({
|
|
728
|
-
grant_type: "refresh_token",
|
|
729
|
-
client_id: ANTHROPIC_CLIENT_ID,
|
|
730
|
-
refresh_token: cred.refresh,
|
|
731
|
-
}).toString(),
|
|
732
|
-
signal: AbortSignal.timeout(30_000),
|
|
733
|
-
});
|
|
868
|
+
- name: Configure git identity
|
|
869
|
+
shell: bash
|
|
870
|
+
run: |
|
|
871
|
+
git config user.name "dorfl[bot]"
|
|
872
|
+
git config user.email "dorfl[bot]@users.noreply.github.com"
|
|
734
873
|
|
|
735
|
-
|
|
874
|
+
${installSteps}
|
|
736
875
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
process.exit(1);
|
|
876
|
+
${writerNoForwardStep()}${pinCheckStep}
|
|
877
|
+
`;
|
|
740
878
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
879
|
+
/**
|
|
880
|
+
* The writer-role step that turns OFF the bootstrap self-forward for every later
|
|
881
|
+
* step of the job, by exporting {@link NO_FORWARD_ENV}`=1` to `$GITHUB_ENV`.
|
|
882
|
+
*
|
|
883
|
+
* Why: a repository that pins dorfl through its dependencies declares
|
|
884
|
+
* `"dorflCmd": "node_modules/.bin/dorfl"`. The writer role deliberately installs
|
|
885
|
+
* no project dependency, so that path does not exist, and a forwarding dorfl
|
|
886
|
+
* would fail every writer job (0.15.0 regression). The dorfl installed above is
|
|
887
|
+
* already the exact version `install-ci` generated these workflows with (or,
|
|
888
|
+
* in workspace mode, dorfl built from the checked-out source), so forwarding
|
|
889
|
+
* gains nothing here. Set ONCE in the action so no job template can forget it.
|
|
890
|
+
* The agent-role `dorfl-setup` does install dependencies and keeps forwarding.
|
|
891
|
+
*/
|
|
892
|
+
function writerNoForwardStep() {
|
|
893
|
+
return `\
|
|
894
|
+
# The writer role runs the dorfl installed above and never forwards to the
|
|
895
|
+
# repository's dorflCmd: that command usually points into the project's
|
|
896
|
+
# dependencies (node_modules/.bin/dorfl), which this role never installs.
|
|
897
|
+
# Exported to $GITHUB_ENV so it holds for every later step of the job.
|
|
898
|
+
- name: Run the dorfl installed above, not the repository's dorflCmd
|
|
899
|
+
shell: bash
|
|
900
|
+
run: echo "${NO_FORWARD_ENV}=1" >> "$GITHUB_ENV"`;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* The JavaScript the registry-mode writer step runs with `node -e '<script>'
|
|
904
|
+
* <pinned>` to WARN (never fail) when the repository pins a different dorfl
|
|
905
|
+
* than the one the writer role installed. Exported so a test can run it.
|
|
906
|
+
*
|
|
907
|
+
* It reads JSON only (`dorfl.json`, and `package.json` for the devDependency
|
|
908
|
+
* case) and runs no project code, so it is safe next to a write token. It
|
|
909
|
+
* recognises two version-bearing shapes of `dorflCmd`:
|
|
910
|
+
*
|
|
911
|
+
* - an exact `dorfl@<version>` inside the command (`npx dorfl@0.16.0`,
|
|
912
|
+
* `mise exec dorfl@0.16.0 --`);
|
|
913
|
+
* - `node_modules/.bin/dorfl`, when `package.json` declares `dorfl` in
|
|
914
|
+
* `devDependencies` (or `dependencies`) at an EXACT version.
|
|
915
|
+
*
|
|
916
|
+
* Anything else (a caret range, `./bin/dorfl`, no `dorflCmd`) is skipped
|
|
917
|
+
* silently: resolving it would need the project's dependencies installed,
|
|
918
|
+
* which the writer role never does. No single quote may appear in it (it is
|
|
919
|
+
* wrapped in a single-quoted bash string).
|
|
920
|
+
*/
|
|
921
|
+
export const WRITER_PIN_CHECK_SCRIPT = `\
|
|
922
|
+
const fs = require("fs");
|
|
923
|
+
const pinned = process.argv[1];
|
|
924
|
+
const readJson = (p) => {
|
|
925
|
+
try { return JSON.parse(fs.readFileSync(p, "utf8")); } catch (e) { return undefined; }
|
|
747
926
|
};
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
);
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
765
|
-
});
|
|
766
|
-
console.log("PI_AUTH_JSON secret updated");
|
|
767
|
-
} catch (err) {
|
|
768
|
-
console.warn("Failed to update secret (non-fatal):", err.stderr?.toString() || err.message);
|
|
927
|
+
const semver = "\\\\d+\\\\.\\\\d+\\\\.\\\\d+(?:-[0-9A-Za-z.-]+)?";
|
|
928
|
+
const config = readJson("${REPO_CONFIG_FILENAME}") || readJson("${REPO_CONFIG_FILENAME_LEGACY}") || {};
|
|
929
|
+
const cmd = config.dorflCmd;
|
|
930
|
+
if (typeof cmd !== "string") process.exit(0);
|
|
931
|
+
let found;
|
|
932
|
+
let where;
|
|
933
|
+
const inCmd = new RegExp("(?:^|\\\\s)dorfl@(" + semver + ")(?=\\\\s|$)").exec(cmd);
|
|
934
|
+
if (inCmd) {
|
|
935
|
+
found = inCmd[1];
|
|
936
|
+
where = "${REPO_CONFIG_FILENAME} dorflCmd";
|
|
937
|
+
} else if (/(?:^|[\\s/])node_modules\\/\\.bin\\/dorfl(?=\\s|$)/.test(cmd)) {
|
|
938
|
+
const pkg = readJson("package.json") || {};
|
|
939
|
+
const spec = (pkg.devDependencies || {}).dorfl || (pkg.dependencies || {}).dorfl;
|
|
940
|
+
if (typeof spec === "string" && new RegExp("^" + semver + "$").test(spec)) {
|
|
941
|
+
found = spec;
|
|
942
|
+
where = "package.json (the dorflCmd " + cmd + ")";
|
|
769
943
|
}
|
|
770
|
-
} else {
|
|
771
|
-
console.log("Skipping secret update (no GH_PAT or GITHUB_REPOSITORY)");
|
|
772
944
|
}
|
|
773
|
-
|
|
945
|
+
if (found !== undefined && found !== pinned) {
|
|
946
|
+
const esc = (s) => s.replace(/%/g, "%25").replace(/\\r/g, "%0D").replace(/\\n/g, "%0A");
|
|
947
|
+
console.log("::warning title=dorfl-setup-writer::" + esc(where + " pins dorfl@" + found + " but the writer-role jobs run dorfl@" + pinned + ", the version install-ci generated these workflows with (writer jobs do not forward to dorflCmd). Re-run dorfl install-ci with dorfl " + found + " so every job runs the same version."));
|
|
948
|
+
}`;
|
|
949
|
+
/**
|
|
950
|
+
* The registry-mode writer step that runs {@link WRITER_PIN_CHECK_SCRIPT}. With
|
|
951
|
+
* the forward off (see {@link writerNoForwardStep}) a disagreement between the
|
|
952
|
+
* pinned global and the repository's own pin would otherwise go unnoticed: the
|
|
953
|
+
* agent job forwards to `dorflCmd` while the writer jobs run the pin.
|
|
954
|
+
*/
|
|
955
|
+
function writerPinCheckStep(pinned) {
|
|
956
|
+
return `
|
|
957
|
+
|
|
958
|
+
# Warn (never fail) when the repository pins a dorfl version other than the
|
|
959
|
+
# one installed above: the agent job forwards to dorflCmd, these writer jobs
|
|
960
|
+
# do not, so the two roles would run different versions. Reads dorfl.json
|
|
961
|
+
# and package.json as JSON only; runs no project code.
|
|
962
|
+
- name: Warn if the repository pins another dorfl version
|
|
963
|
+
shell: bash
|
|
964
|
+
run: |
|
|
965
|
+
node -e '
|
|
966
|
+
${indent(WRITER_PIN_CHECK_SCRIPT, 10)}
|
|
967
|
+
' "${pinned}"`;
|
|
968
|
+
}
|
|
774
969
|
// ─── the --fake snapshot mechanism + artifact assembly ───────────────────────
|
|
775
970
|
/**
|
|
776
|
-
* The setup ARTIFACTS this task generates: the composite setup
|
|
777
|
-
*
|
|
971
|
+
* The setup ARTIFACTS this task generates: the composite setup actions, plus
|
|
972
|
+
* any selected capabilities'
|
|
778
973
|
* workflow files. This task emits NO capability workflow itself (those are the
|
|
779
974
|
* sibling tasks); `capabilities` defaults to none.
|
|
780
975
|
*/
|
|
@@ -791,13 +986,11 @@ options) {
|
|
|
791
986
|
path: join('actions', 'dorfl-setup', 'action.yml'),
|
|
792
987
|
content: generateSetupAction(config, options?.projectSetupSteps),
|
|
793
988
|
},
|
|
989
|
+
{
|
|
990
|
+
path: join('actions', 'dorfl-setup-writer', 'action.yml'),
|
|
991
|
+
content: generateWriterSetupAction(config),
|
|
992
|
+
},
|
|
794
993
|
];
|
|
795
|
-
if (config.authMode === 'auth-json') {
|
|
796
|
-
files.push({
|
|
797
|
-
path: join('scripts', 'refresh-oauth-token.mjs'),
|
|
798
|
-
content: REFRESH_OAUTH_SCRIPT,
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
994
|
for (const cap of capabilities) {
|
|
802
995
|
files.push(...cap.emit(config));
|
|
803
996
|
}
|