@kya-os/cli 1.8.1 → 1.8.3
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/commands/agent.d.ts +35 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +321 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/build.js +2 -2
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/checkpoint-init.d.ts +1 -1
- package/dist/commands/checkpoint-init.d.ts.map +1 -1
- package/dist/commands/checkpoint-init.js +8 -41
- package/dist/commands/checkpoint-init.js.map +1 -1
- package/dist/commands/claim.js +2 -2
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/dco.d.ts +59 -0
- package/dist/commands/dco.d.ts.map +1 -1
- package/dist/commands/dco.js +280 -5
- package/dist/commands/dco.js.map +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +18 -24
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env.js +6 -6
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/identity.js +3 -3
- package/dist/commands/identity.js.map +1 -1
- package/dist/commands/init-stages.d.ts +141 -0
- package/dist/commands/init-stages.d.ts.map +1 -0
- package/dist/commands/init-stages.js +684 -0
- package/dist/commands/init-stages.js.map +1 -0
- package/dist/commands/init.d.ts +46 -16
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +229 -279
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/orchestrator.d.ts +18 -0
- package/dist/commands/orchestrator.d.ts.map +1 -0
- package/dist/commands/orchestrator.js +251 -0
- package/dist/commands/orchestrator.js.map +1 -0
- package/dist/commands/register.d.ts +1 -1
- package/dist/commands/register.d.ts.map +1 -1
- package/dist/commands/register.js +35 -7
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/review.d.ts +48 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +220 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/rotate.js +4 -4
- package/dist/commands/rotate.js.map +1 -1
- package/dist/commands/score.d.ts +15 -0
- package/dist/commands/score.d.ts.map +1 -0
- package/dist/commands/score.js +471 -0
- package/dist/commands/score.js.map +1 -0
- package/dist/commands/start.js +3 -3
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/verify.js +6 -6
- package/dist/commands/verify.js.map +1 -1
- package/dist/dco.d.ts +4 -0
- package/dist/dco.d.ts.map +1 -0
- package/dist/dco.js +23 -0
- package/dist/dco.js.map +1 -0
- package/dist/index.js +52 -9
- package/dist/orchestrator/daemon.d.ts +137 -0
- package/dist/orchestrator/daemon.d.ts.map +1 -0
- package/dist/orchestrator/daemon.js +242 -0
- package/dist/orchestrator/daemon.js.map +1 -0
- package/dist/orchestrator/db/dispatches.d.ts +108 -0
- package/dist/orchestrator/db/dispatches.d.ts.map +1 -0
- package/dist/orchestrator/db/dispatches.js +122 -0
- package/dist/orchestrator/db/dispatches.js.map +1 -0
- package/dist/orchestrator/db/index.d.ts +50 -0
- package/dist/orchestrator/db/index.d.ts.map +1 -0
- package/dist/orchestrator/db/index.js +116 -0
- package/dist/orchestrator/db/index.js.map +1 -0
- package/dist/orchestrator/db/journal.d.ts +93 -0
- package/dist/orchestrator/db/journal.d.ts.map +1 -0
- package/dist/orchestrator/db/journal.js +91 -0
- package/dist/orchestrator/db/journal.js.map +1 -0
- package/dist/orchestrator/db/liveness.d.ts +97 -0
- package/dist/orchestrator/db/liveness.d.ts.map +1 -0
- package/dist/orchestrator/db/liveness.js +105 -0
- package/dist/orchestrator/db/liveness.js.map +1 -0
- package/dist/orchestrator/db/mission.d.ts +78 -0
- package/dist/orchestrator/db/mission.d.ts.map +1 -0
- package/dist/orchestrator/db/mission.js +99 -0
- package/dist/orchestrator/db/mission.js.map +1 -0
- package/dist/orchestrator/db/schema.d.ts +14 -0
- package/dist/orchestrator/db/schema.d.ts.map +1 -0
- package/dist/orchestrator/db/schema.js +169 -0
- package/dist/orchestrator/db/schema.js.map +1 -0
- package/dist/orchestrator/db/tickets.d.ts +147 -0
- package/dist/orchestrator/db/tickets.d.ts.map +1 -0
- package/dist/orchestrator/db/tickets.js +238 -0
- package/dist/orchestrator/db/tickets.js.map +1 -0
- package/dist/orchestrator/db/verdicts.d.ts +187 -0
- package/dist/orchestrator/db/verdicts.d.ts.map +1 -0
- package/dist/orchestrator/db/verdicts.js +197 -0
- package/dist/orchestrator/db/verdicts.js.map +1 -0
- package/dist/orchestrator/events.d.ts +69 -0
- package/dist/orchestrator/events.d.ts.map +1 -0
- package/dist/orchestrator/events.js +20 -0
- package/dist/orchestrator/events.js.map +1 -0
- package/dist/orchestrator/github-credential-anchor-sender.d.ts +159 -0
- package/dist/orchestrator/github-credential-anchor-sender.d.ts.map +1 -0
- package/dist/orchestrator/github-credential-anchor-sender.js +313 -0
- package/dist/orchestrator/github-credential-anchor-sender.js.map +1 -0
- package/dist/orchestrator/hub-dispatch.d.ts +120 -0
- package/dist/orchestrator/hub-dispatch.d.ts.map +1 -0
- package/dist/orchestrator/hub-dispatch.js +257 -0
- package/dist/orchestrator/hub-dispatch.js.map +1 -0
- package/dist/orchestrator/hub-observer.d.ts +201 -0
- package/dist/orchestrator/hub-observer.d.ts.map +1 -0
- package/dist/orchestrator/hub-observer.js +474 -0
- package/dist/orchestrator/hub-observer.js.map +1 -0
- package/dist/orchestrator/journal-writer.d.ts +80 -0
- package/dist/orchestrator/journal-writer.d.ts.map +1 -0
- package/dist/orchestrator/journal-writer.js +113 -0
- package/dist/orchestrator/journal-writer.js.map +1 -0
- package/dist/orchestrator/mcp/server.d.ts +136 -0
- package/dist/orchestrator/mcp/server.d.ts.map +1 -0
- package/dist/orchestrator/mcp/server.js +582 -0
- package/dist/orchestrator/mcp/server.js.map +1 -0
- package/dist/orchestrator/mcp/stdio.d.ts +22 -0
- package/dist/orchestrator/mcp/stdio.d.ts.map +1 -0
- package/dist/orchestrator/mcp/stdio.js +51 -0
- package/dist/orchestrator/mcp/stdio.js.map +1 -0
- package/dist/orchestrator/review.d.ts +131 -0
- package/dist/orchestrator/review.d.ts.map +1 -0
- package/dist/orchestrator/review.js +322 -0
- package/dist/orchestrator/review.js.map +1 -0
- package/dist/tui/app.d.ts +33 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +71 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/components.d.ts +110 -0
- package/dist/tui/components.d.ts.map +1 -0
- package/dist/tui/components.js +118 -0
- package/dist/tui/components.js.map +1 -0
- package/dist/tui/index.d.ts +30 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +95 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/keymap.d.ts +33 -0
- package/dist/tui/keymap.d.ts.map +1 -0
- package/dist/tui/keymap.js +49 -0
- package/dist/tui/keymap.js.map +1 -0
- package/dist/tui/nav.d.ts +29 -0
- package/dist/tui/nav.d.ts.map +1 -0
- package/dist/tui/nav.js +39 -0
- package/dist/tui/nav.js.map +1 -0
- package/dist/tui/sanitize.d.ts +25 -0
- package/dist/tui/sanitize.d.ts.map +1 -0
- package/dist/tui/sanitize.js +36 -0
- package/dist/tui/sanitize.js.map +1 -0
- package/dist/tui/theme.d.ts +32 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +63 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/tui/views/agents.d.ts +67 -0
- package/dist/tui/views/agents.d.ts.map +1 -0
- package/dist/tui/views/agents.js +231 -0
- package/dist/tui/views/agents.js.map +1 -0
- package/dist/tui/views/index.d.ts +93 -0
- package/dist/tui/views/index.d.ts.map +1 -0
- package/dist/tui/views/index.js +150 -0
- package/dist/tui/views/index.js.map +1 -0
- package/dist/tui/views/registry.d.ts +22 -0
- package/dist/tui/views/registry.d.ts.map +1 -0
- package/dist/tui/views/registry.js +110 -0
- package/dist/tui/views/registry.js.map +1 -0
- package/dist/utils/agent/backoff.d.ts +31 -0
- package/dist/utils/agent/backoff.d.ts.map +1 -0
- package/dist/utils/agent/backoff.js +51 -0
- package/dist/utils/agent/backoff.js.map +1 -0
- package/dist/utils/agent/markers.d.ts +87 -0
- package/dist/utils/agent/markers.d.ts.map +1 -0
- package/dist/utils/agent/markers.js +147 -0
- package/dist/utils/agent/markers.js.map +1 -0
- package/dist/utils/agent/review.d.ts +67 -0
- package/dist/utils/agent/review.d.ts.map +1 -0
- package/dist/utils/agent/review.js +305 -0
- package/dist/utils/agent/review.js.map +1 -0
- package/dist/utils/agent/spawn-agent.d.ts +117 -0
- package/dist/utils/agent/spawn-agent.d.ts.map +1 -0
- package/dist/utils/agent/spawn-agent.js +177 -0
- package/dist/utils/agent/spawn-agent.js.map +1 -0
- package/dist/utils/agent/task.d.ts +101 -0
- package/dist/utils/agent/task.d.ts.map +1 -0
- package/dist/utils/agent/task.js +357 -0
- package/dist/utils/agent/task.js.map +1 -0
- package/dist/utils/agent/verify.d.ts +47 -0
- package/dist/utils/agent/verify.d.ts.map +1 -0
- package/dist/utils/agent/verify.js +144 -0
- package/dist/utils/agent/verify.js.map +1 -0
- package/dist/utils/agent-detector.d.ts +48 -0
- package/dist/utils/agent-detector.d.ts.map +1 -0
- package/dist/utils/agent-detector.js +74 -0
- package/dist/utils/agent-detector.js.map +1 -0
- package/dist/utils/agent-profile-stage.d.ts +70 -0
- package/dist/utils/agent-profile-stage.d.ts.map +1 -0
- package/dist/utils/agent-profile-stage.js +153 -0
- package/dist/utils/agent-profile-stage.js.map +1 -0
- package/dist/utils/agent-profiles.d.ts +27 -0
- package/dist/utils/agent-profiles.d.ts.map +1 -0
- package/dist/utils/agent-profiles.js +61 -0
- package/dist/utils/agent-profiles.js.map +1 -0
- package/dist/utils/checkpoint-api.d.ts +1 -1
- package/dist/utils/checkpoint-api.js +1 -1
- package/dist/utils/checkpoint-env.d.ts +1 -1
- package/dist/utils/checkpoint-env.js +2 -2
- package/dist/utils/checkpoint-env.js.map +1 -1
- package/dist/utils/checkpoint-scaffold.d.ts +1 -1
- package/dist/utils/checkpoint-scaffold.js +1 -1
- package/dist/utils/cli-kit/browser.d.ts +24 -0
- package/dist/utils/cli-kit/browser.d.ts.map +1 -0
- package/dist/utils/cli-kit/browser.js +58 -0
- package/dist/utils/cli-kit/browser.js.map +1 -0
- package/dist/utils/cli-kit/claim-polling.d.ts +18 -0
- package/dist/utils/cli-kit/claim-polling.d.ts.map +1 -0
- package/dist/utils/{claim-polling.js → cli-kit/claim-polling.js} +19 -26
- package/dist/utils/cli-kit/claim-polling.js.map +1 -0
- package/dist/utils/cli-kit/diagnostics.d.ts +9 -0
- package/dist/utils/cli-kit/diagnostics.d.ts.map +1 -0
- package/dist/utils/cli-kit/diagnostics.js +11 -0
- package/dist/utils/cli-kit/diagnostics.js.map +1 -0
- package/dist/utils/cli-kit/fs-safe.d.ts +14 -0
- package/dist/utils/cli-kit/fs-safe.d.ts.map +1 -0
- package/dist/utils/cli-kit/fs-safe.js +20 -0
- package/dist/utils/cli-kit/fs-safe.js.map +1 -0
- package/dist/utils/cli-kit/index.d.ts +15 -0
- package/dist/utils/cli-kit/index.d.ts.map +1 -0
- package/dist/utils/cli-kit/index.js +10 -0
- package/dist/utils/cli-kit/index.js.map +1 -0
- package/dist/utils/cli-kit/json-file.d.ts +21 -0
- package/dist/utils/cli-kit/json-file.d.ts.map +1 -0
- package/dist/utils/cli-kit/json-file.js +51 -0
- package/dist/utils/cli-kit/json-file.js.map +1 -0
- package/dist/utils/cli-kit/marker-block.d.ts +26 -0
- package/dist/utils/cli-kit/marker-block.d.ts.map +1 -0
- package/dist/utils/cli-kit/marker-block.js +61 -0
- package/dist/utils/cli-kit/marker-block.js.map +1 -0
- package/dist/utils/cli-kit/paths.d.ts +15 -0
- package/dist/utils/cli-kit/paths.d.ts.map +1 -0
- package/dist/utils/cli-kit/paths.js +21 -0
- package/dist/utils/cli-kit/paths.js.map +1 -0
- package/dist/utils/cli-kit/secure-storage.d.ts +14 -0
- package/dist/utils/cli-kit/secure-storage.d.ts.map +1 -0
- package/dist/utils/cli-kit/secure-storage.js +20 -0
- package/dist/utils/cli-kit/secure-storage.js.map +1 -0
- package/dist/utils/cli-kit/step-report.d.ts +16 -0
- package/dist/utils/cli-kit/step-report.d.ts.map +1 -0
- package/dist/utils/cli-kit/step-report.js +36 -0
- package/dist/utils/cli-kit/step-report.js.map +1 -0
- package/dist/utils/dco/agent-metadata.d.ts +1 -1
- package/dist/utils/dco/agent-metadata.js +1 -1
- package/dist/utils/dco/agent-metadata.js.map +1 -1
- package/dist/utils/dco/claude-config.d.ts +18 -14
- package/dist/utils/dco/claude-config.d.ts.map +1 -1
- package/dist/utils/dco/claude-config.js +31 -97
- package/dist/utils/dco/claude-config.js.map +1 -1
- package/dist/utils/dco/dispatch.d.ts +134 -0
- package/dist/utils/dco/dispatch.d.ts.map +1 -0
- package/dist/utils/dco/dispatch.js +399 -0
- package/dist/utils/dco/dispatch.js.map +1 -0
- package/dist/utils/dco/fix.d.ts +122 -0
- package/dist/utils/dco/fix.d.ts.map +1 -0
- package/dist/utils/dco/fix.js +560 -0
- package/dist/utils/dco/fix.js.map +1 -0
- package/dist/utils/dco/git-config.d.ts.map +1 -1
- package/dist/utils/dco/git-config.js +5 -3
- package/dist/utils/dco/git-config.js.map +1 -1
- package/dist/utils/dco/github.d.ts +101 -0
- package/dist/utils/dco/github.d.ts.map +1 -1
- package/dist/utils/dco/github.js +133 -0
- package/dist/utils/dco/github.js.map +1 -1
- package/dist/utils/dco/paths.d.ts +1 -8
- package/dist/utils/dco/paths.d.ts.map +1 -1
- package/dist/utils/dco/paths.js +3 -12
- package/dist/utils/dco/paths.js.map +1 -1
- package/dist/utils/dco/render.d.ts +1 -1
- package/dist/utils/dco/render.d.ts.map +1 -1
- package/dist/utils/dco/render.js +4 -21
- package/dist/utils/dco/render.js.map +1 -1
- package/dist/utils/dco/resolve-agent.d.ts +54 -0
- package/dist/utils/dco/resolve-agent.d.ts.map +1 -0
- package/dist/utils/dco/resolve-agent.js +164 -0
- package/dist/utils/dco/resolve-agent.js.map +1 -0
- package/dist/utils/dco/setup.d.ts +10 -7
- package/dist/utils/dco/setup.d.ts.map +1 -1
- package/dist/utils/dco/setup.js +264 -200
- package/dist/utils/dco/setup.js.map +1 -1
- package/dist/utils/dco/signing-key-writer.d.ts +40 -0
- package/dist/utils/dco/signing-key-writer.d.ts.map +1 -0
- package/dist/utils/dco/signing-key-writer.js +76 -0
- package/dist/utils/dco/signing-key-writer.js.map +1 -0
- package/dist/utils/dco/ssh-key.d.ts +50 -0
- package/dist/utils/dco/ssh-key.d.ts.map +1 -1
- package/dist/utils/dco/ssh-key.js +129 -8
- package/dist/utils/dco/ssh-key.js.map +1 -1
- package/dist/utils/dco/status.d.ts +1 -1
- package/dist/utils/dco/status.d.ts.map +1 -1
- package/dist/utils/dco/status.js +3 -3
- package/dist/utils/dco/status.js.map +1 -1
- package/dist/utils/dco/verify.d.ts +170 -0
- package/dist/utils/dco/verify.d.ts.map +1 -0
- package/dist/utils/dco/verify.js +550 -0
- package/dist/utils/dco/verify.js.map +1 -0
- package/dist/utils/dependency-installer.d.ts +37 -0
- package/dist/utils/dependency-installer.d.ts.map +1 -0
- package/dist/utils/dependency-installer.js +32 -0
- package/dist/utils/dependency-installer.js.map +1 -0
- package/dist/utils/github-credential-stage.d.ts +87 -0
- package/dist/utils/github-credential-stage.d.ts.map +1 -0
- package/dist/utils/github-credential-stage.js +168 -0
- package/dist/utils/github-credential-stage.js.map +1 -0
- package/dist/utils/github-credential.d.ts +160 -0
- package/dist/utils/github-credential.d.ts.map +1 -0
- package/dist/utils/github-credential.js +308 -0
- package/dist/utils/github-credential.js.map +1 -0
- package/dist/utils/gitignore.d.ts +17 -0
- package/dist/utils/gitignore.d.ts.map +1 -0
- package/dist/utils/gitignore.js +40 -0
- package/dist/utils/gitignore.js.map +1 -0
- package/dist/utils/hub-config.d.ts +21 -0
- package/dist/utils/hub-config.d.ts.map +1 -0
- package/dist/utils/hub-config.js +28 -0
- package/dist/utils/hub-config.js.map +1 -0
- package/dist/utils/identity-heal.d.ts +16 -0
- package/dist/utils/identity-heal.d.ts.map +1 -0
- package/dist/utils/identity-heal.js +37 -0
- package/dist/utils/identity-heal.js.map +1 -0
- package/dist/utils/init/pipeline.d.ts +74 -0
- package/dist/utils/init/pipeline.d.ts.map +1 -0
- package/dist/utils/init/pipeline.js +96 -0
- package/dist/utils/init/pipeline.js.map +1 -0
- package/dist/utils/poll.d.ts +15 -1
- package/dist/utils/poll.d.ts.map +1 -1
- package/dist/utils/poll.js +6 -3
- package/dist/utils/poll.js.map +1 -1
- package/dist/utils/register-agent-identity.d.ts +67 -0
- package/dist/utils/register-agent-identity.d.ts.map +1 -0
- package/dist/utils/register-agent-identity.js +34 -0
- package/dist/utils/register-agent-identity.js.map +1 -0
- package/dist/utils/review/did-web-key.d.ts +34 -0
- package/dist/utils/review/did-web-key.d.ts.map +1 -0
- package/dist/utils/review/did-web-key.js +104 -0
- package/dist/utils/review/did-web-key.js.map +1 -0
- package/dist/utils/review/load-registry.d.ts +33 -0
- package/dist/utils/review/load-registry.d.ts.map +1 -0
- package/dist/utils/review/load-registry.js +62 -0
- package/dist/utils/review/load-registry.js.map +1 -0
- package/dist/utils/review/verdict-verify.d.ts +43 -0
- package/dist/utils/review/verdict-verify.d.ts.map +1 -0
- package/dist/utils/review/verdict-verify.js +53 -0
- package/dist/utils/review/verdict-verify.js.map +1 -0
- package/dist/utils/review-registry-writer.d.ts +52 -0
- package/dist/utils/review-registry-writer.d.ts.map +1 -0
- package/dist/utils/review-registry-writer.js +79 -0
- package/dist/utils/review-registry-writer.js.map +1 -0
- package/dist/utils/should-install-dependency.d.ts +17 -0
- package/dist/utils/should-install-dependency.d.ts.map +1 -0
- package/dist/utils/should-install-dependency.js +25 -0
- package/dist/utils/should-install-dependency.js.map +1 -0
- package/dist/utils/tool-readiness.d.ts +57 -0
- package/dist/utils/tool-readiness.d.ts.map +1 -0
- package/dist/utils/tool-readiness.js +114 -0
- package/dist/utils/tool-readiness.js.map +1 -0
- package/dist/utils/which.d.ts +2 -0
- package/dist/utils/which.d.ts.map +1 -0
- package/dist/utils/which.js +22 -0
- package/dist/utils/which.js.map +1 -0
- package/dist/version.d.ts +15 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +29 -0
- package/dist/version.js.map +1 -0
- package/package.json +19 -6
- package/dist/utils/claim-polling.d.ts +0 -21
- package/dist/utils/claim-polling.d.ts.map +0 -1
- package/dist/utils/claim-polling.js.map +0 -1
- package/dist/utils/dco/fs-safe.d.ts +0 -14
- package/dist/utils/dco/fs-safe.d.ts.map +0 -1
- package/dist/utils/dco/fs-safe.js +0 -20
- package/dist/utils/dco/fs-safe.js.map +0 -1
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { execFile } from "child_process";
|
|
2
|
+
import { existsSync, lstatSync, readFileSync, rmSync } from "fs";
|
|
3
|
+
import { basename, join } from "path";
|
|
4
|
+
import { promisify } from "util";
|
|
5
|
+
import { writeFileAtomicSafe } from "../cli-kit/index.js";
|
|
6
|
+
import { getPullRequestBody } from "./github.js";
|
|
7
|
+
import { signingKeyPath } from "./paths.js";
|
|
8
|
+
import { resolveAgentIdentity } from "./resolve-agent.js";
|
|
9
|
+
import { RESOLVE_TIMEOUT_MS, didWebToHttpsUrl, hasAgentDidClaim, verifyPrAttribution, } from "./verify.js";
|
|
10
|
+
const execFileAsync = promisify(execFile);
|
|
11
|
+
async function run(cmd, args, cwd) {
|
|
12
|
+
const { stdout } = await execFileAsync(cmd, args, {
|
|
13
|
+
cwd,
|
|
14
|
+
encoding: "utf8",
|
|
15
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
16
|
+
});
|
|
17
|
+
return stdout.trim();
|
|
18
|
+
}
|
|
19
|
+
async function gitSucceeds(args, cwd) {
|
|
20
|
+
try {
|
|
21
|
+
await run("git", args, cwd);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function errorMessage(error) {
|
|
29
|
+
if (error && typeof error === "object" && "stderr" in error) {
|
|
30
|
+
const stderr = String(error.stderr ?? "").trim();
|
|
31
|
+
if (stderr) {
|
|
32
|
+
return stderr;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return error instanceof Error ? error.message : String(error);
|
|
36
|
+
}
|
|
37
|
+
// commitlint's default subject-max-length is 100; ~72 for the PR title
|
|
38
|
+
// mirrors GitHub's own soft wrap, and ~60 after the "docs: " prefix keeps the
|
|
39
|
+
// full commit subject comfortably inside that even in stricter repos.
|
|
40
|
+
const MAX_TITLE_LENGTH = 72;
|
|
41
|
+
const MAX_COMMIT_SUBJECT_LENGTH = 60;
|
|
42
|
+
function truncate(value, maxLength) {
|
|
43
|
+
return value.length > maxLength ? value.slice(0, maxLength).trimEnd() : value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resolve the PR title: the explicit `--title`, or the description's first
|
|
47
|
+
* NON-EMPTY line when omitted (a description that opens with a blank line,
|
|
48
|
+
* e.g. "\n\nActual title", must not yield an empty title). Either way it's
|
|
49
|
+
* truncated to a safe length, since the title also seeds the commit subject
|
|
50
|
+
* and a raw description can run long.
|
|
51
|
+
*/
|
|
52
|
+
export function deriveDispatchTitle(description, explicitTitle) {
|
|
53
|
+
if (explicitTitle && explicitTitle.trim().length > 0) {
|
|
54
|
+
return truncate(explicitTitle.trim(), MAX_TITLE_LENGTH);
|
|
55
|
+
}
|
|
56
|
+
const firstNonEmptyLine = description
|
|
57
|
+
.split(/\r?\n/)
|
|
58
|
+
.map((line) => line.trim())
|
|
59
|
+
.find((line) => line.length > 0);
|
|
60
|
+
return truncate(firstNonEmptyLine ?? "", MAX_TITLE_LENGTH);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Lowercase subject on purpose: commitlint `subject-case` hooks reject an
|
|
64
|
+
* uppercase one, and lowercase passes everywhere. Truncated separately from
|
|
65
|
+
* the title (after the "docs: " prefix) so a title near MAX_TITLE_LENGTH
|
|
66
|
+
* still yields a commit subject well inside commitlint's own length rule.
|
|
67
|
+
*/
|
|
68
|
+
export function buildDispatchCommitSubject(title) {
|
|
69
|
+
return `docs: ${truncate(title.toLowerCase(), MAX_COMMIT_SUBJECT_LENGTH)}`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Extra `git -c` config prepended to the commit so it signs with the exact
|
|
73
|
+
* key belonging to the agent this run is attributing the PR to, regardless
|
|
74
|
+
* of what the repo's ambient config says (and so agent-slug mode works from
|
|
75
|
+
* any repo, with no `.mcpi/` state there at all).
|
|
76
|
+
*/
|
|
77
|
+
function buildSigningConfig(keyPath) {
|
|
78
|
+
return [
|
|
79
|
+
"-c",
|
|
80
|
+
"gpg.format=ssh",
|
|
81
|
+
"-c",
|
|
82
|
+
"commit.gpgsign=true",
|
|
83
|
+
"-c",
|
|
84
|
+
`user.signingkey=${keyPath}`,
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Whether `rawCommit` (the raw `git cat-file commit HEAD` output) carries a
|
|
89
|
+
* `gpgsig` header — the reliable signed-commit check (`git log
|
|
90
|
+
* --show-signature` needs `gpg.ssh.allowedSignersFile` locally and
|
|
91
|
+
* misreports otherwise). Exported so `dispatch.ts` and `fix.ts` share the
|
|
92
|
+
* exact same check rather than each re-deriving it: a raw commit object is
|
|
93
|
+
* headers, then ONE blank line, then the free-text commit message, and a
|
|
94
|
+
* naive `/^gpgsig /m.test(rawCommit)` over the WHOLE string false-positives
|
|
95
|
+
* on an unsigned commit whose message body happens to contain a line
|
|
96
|
+
* starting with "gpgsig " (an agent-composed `-m`/`--message` value is
|
|
97
|
+
* exactly that kind of free text). Splitting off the header section before
|
|
98
|
+
* testing closes that gap: git's object format guarantees no blank line
|
|
99
|
+
* appears within the headers themselves, including a multi-line `gpgsig`
|
|
100
|
+
* value's space-prefixed continuation lines, so the first `\n\n` reliably
|
|
101
|
+
* marks the header/message boundary.
|
|
102
|
+
*/
|
|
103
|
+
export function isCommitSigned(rawCommit) {
|
|
104
|
+
const headers = rawCommit.split("\n\n")[0] ?? "";
|
|
105
|
+
return /^gpgsig /m.test(headers);
|
|
106
|
+
}
|
|
107
|
+
/** Fail fast when the DID isn't claimed/resolvable, BEFORE any git or GitHub
|
|
108
|
+
* side effects: an unclaimed agent otherwise only surfaces as a verification
|
|
109
|
+
* failure after a junk repo, branch, and PR already exist. */
|
|
110
|
+
async function resolveDidPreflight(did) {
|
|
111
|
+
const documentUrl = didWebToHttpsUrl(did);
|
|
112
|
+
if (!documentUrl) {
|
|
113
|
+
return `could not derive a document URL from ${did}`;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const controller = new AbortController();
|
|
117
|
+
const timer = setTimeout(() => controller.abort(), RESOLVE_TIMEOUT_MS);
|
|
118
|
+
let response;
|
|
119
|
+
try {
|
|
120
|
+
response = await fetch(documentUrl, {
|
|
121
|
+
signal: controller.signal,
|
|
122
|
+
redirect: "manual",
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
clearTimeout(timer);
|
|
127
|
+
}
|
|
128
|
+
if (!response.ok) {
|
|
129
|
+
return `HTTP ${response.status} from ${documentUrl}`;
|
|
130
|
+
}
|
|
131
|
+
const doc = (await response.json());
|
|
132
|
+
if (doc?.id !== did) {
|
|
133
|
+
return `${documentUrl} describes ${String(doc?.id)}, not ${did}`;
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return `${documentUrl} unreachable: ${errorMessage(error)}`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Resolve the agent identity, slug-derived DID, and per-invocation git
|
|
143
|
+
* signing config for a dispatch-style operation: either an explicit
|
|
144
|
+
* `--agent <slug>` (signs with `~/.mcpi/keys/<slug>`, works from any repo
|
|
145
|
+
* and ignores conflicting repo signing config) or the checkout's own
|
|
146
|
+
* `.mcpi/` identity. Fails closed, in order, BEFORE any git or GitHub side
|
|
147
|
+
* effects: invalid/missing slug, missing signing key, then DID preflight
|
|
148
|
+
* (`resolveDidPreflight`) so an unclaimed agent never reaches a git or `gh`
|
|
149
|
+
* call.
|
|
150
|
+
*
|
|
151
|
+
* `runDcoDispatch` below and `runDcoFix` (`fix.ts`) both call this instead
|
|
152
|
+
* of re-deriving the same agent/DID/signing-key logic: a second
|
|
153
|
+
* implementation that drifted from this one could sign a commit with a
|
|
154
|
+
* different key than the one an `Agent DID:`/attestation line claims.
|
|
155
|
+
*/
|
|
156
|
+
export async function resolveSigningIdentity(cwd, agentSlug) {
|
|
157
|
+
let agent;
|
|
158
|
+
let signingConfig;
|
|
159
|
+
let keyPath;
|
|
160
|
+
if (agentSlug) {
|
|
161
|
+
try {
|
|
162
|
+
keyPath = signingKeyPath(agentSlug);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
return { ok: false, failure: errorMessage(error) };
|
|
166
|
+
}
|
|
167
|
+
if (!existsSync(keyPath)) {
|
|
168
|
+
return {
|
|
169
|
+
ok: false,
|
|
170
|
+
failure: `No signing key for agent "${agentSlug}" at ${keyPath}. Run \`dco setup ${agentSlug}\` once, or check the slug.`,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
agent = {
|
|
174
|
+
name: agentSlug,
|
|
175
|
+
slug: agentSlug,
|
|
176
|
+
url: `https://knowthat.ai/agents/${agentSlug}`,
|
|
177
|
+
};
|
|
178
|
+
signingConfig = buildSigningConfig(keyPath);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const resolved = await resolveAgentIdentity(cwd);
|
|
182
|
+
if (!resolved) {
|
|
183
|
+
return {
|
|
184
|
+
ok: false,
|
|
185
|
+
failure:
|
|
186
|
+
// Command-agnostic on purpose: `dco fix` takes the slug via
|
|
187
|
+
// `--agent <slug>`, `dco dispatch` takes it as a leading
|
|
188
|
+
// positional (`dco dispatch <slug> <description>`) with no
|
|
189
|
+
// --agent option at all, and this failure is shared by both.
|
|
190
|
+
"No agent identity configured in this checkout. Run `kya-os register` + `dco setup` here, or specify an existing claimed agent's slug (see this command's --help for the syntax).",
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
agent = { name: resolved.name, slug: resolved.slug, url: resolved.url };
|
|
194
|
+
// Sign with the SAME agent's key the PR/commit is attributed to, exactly
|
|
195
|
+
// like agent-slug mode, instead of silently relying on whatever ambient
|
|
196
|
+
// repo git config happens to be configured: without this, a checkout
|
|
197
|
+
// signed by a different key (or unsigned) than the one named in the
|
|
198
|
+
// Agent DID line would produce a commit whose signature and attribution
|
|
199
|
+
// disagree.
|
|
200
|
+
try {
|
|
201
|
+
keyPath = signingKeyPath(resolved.slug);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
return { ok: false, failure: errorMessage(error) };
|
|
205
|
+
}
|
|
206
|
+
if (!existsSync(keyPath)) {
|
|
207
|
+
return {
|
|
208
|
+
ok: false,
|
|
209
|
+
failure: `No signing key for agent "${resolved.slug}" at ${keyPath}. Run \`dco setup\` in this checkout, then try again.`,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
signingConfig = buildSigningConfig(keyPath);
|
|
213
|
+
}
|
|
214
|
+
// Built from the slug instead of trusting identity.json's `did`, which can
|
|
215
|
+
// still hold the unresolvable pre-claim placeholder (known bug; see the
|
|
216
|
+
// quickstart runbook). The slug is what registration actually persisted.
|
|
217
|
+
const did = `did:web:knowthat.ai:agents:${agent.slug}`;
|
|
218
|
+
const unresolvable = await resolveDidPreflight(did);
|
|
219
|
+
if (unresolvable) {
|
|
220
|
+
return {
|
|
221
|
+
ok: false,
|
|
222
|
+
failure: `Agent DID ${did} does not resolve (${unresolvable}). ` +
|
|
223
|
+
// Same command-agnostic wording as the "no agent identity" failure
|
|
224
|
+
// above — see its comment.
|
|
225
|
+
"Only a claimed registry agent can sign a verifiable PR. Specify the slug of a claimed agent instead (see this command's --help for the syntax), or claim this one first.",
|
|
226
|
+
agent: { name: agent.name, slug: agent.slug },
|
|
227
|
+
did,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return { ok: true, identity: { agent, did, signingConfig, keyPath } };
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The cold-start self-heal `runDcoDispatch` performs on `cwd` before its own
|
|
234
|
+
* demo commit: `git init` if `cwd` isn't a work tree yet, a signed initial
|
|
235
|
+
* commit if there's no `HEAD` yet, and a fresh private GitHub repo if there's
|
|
236
|
+
* no `origin` remote yet. Factored out so `kya-os agent task`
|
|
237
|
+
* (`utils/agent/task.ts`) reuses the exact same self-heal instead of a
|
|
238
|
+
* second copy that could drift on ordering or on which commit ends up
|
|
239
|
+
* signed — see this feature's design doc ("create or reuse a scratch repo
|
|
240
|
+
* the way `runDcoDispatch` cold-start does"). `agent task` runs this
|
|
241
|
+
* against a throwaway temp directory it creates itself, not the caller's own
|
|
242
|
+
* cwd, unlike `runDcoDispatch`'s in-place self-heal.
|
|
243
|
+
*/
|
|
244
|
+
export async function ensureColdStartRepo(cwd, signingConfig) {
|
|
245
|
+
const result = {};
|
|
246
|
+
if (!(await gitSucceeds(["rev-parse", "--is-inside-work-tree"], cwd))) {
|
|
247
|
+
await run("git", ["init", "-q"], cwd);
|
|
248
|
+
}
|
|
249
|
+
if (!(await gitSucceeds(["rev-parse", "HEAD"], cwd))) {
|
|
250
|
+
// Symlink-safe: a planted `.gitkeep` symlink in an untrusted cwd must
|
|
251
|
+
// not make this follow it and clobber an arbitrary file.
|
|
252
|
+
writeFileAtomicSafe(join(cwd, ".gitkeep"), "# demo repo\n");
|
|
253
|
+
await run("git", ["add", ".gitkeep"], cwd);
|
|
254
|
+
// Signed like the demo commit below: without this, agent-slug mode's
|
|
255
|
+
// cold-start init commit would fall back to ambient repo signing
|
|
256
|
+
// config (or none at all), landing an unsigned or wrong-key commit
|
|
257
|
+
// before the attributed one even exists. `-- .gitkeep` restricts the
|
|
258
|
+
// commit to that one file so nothing else already in the index rides
|
|
259
|
+
// along, and hooks are disabled so a stale prepare-commit-msg hook
|
|
260
|
+
// can't stamp this boilerplate commit with the wrong agent.
|
|
261
|
+
await run("git", [
|
|
262
|
+
"-c",
|
|
263
|
+
"core.hooksPath=/dev/null",
|
|
264
|
+
...signingConfig,
|
|
265
|
+
"commit",
|
|
266
|
+
"-q",
|
|
267
|
+
"-m",
|
|
268
|
+
"chore: init",
|
|
269
|
+
"--",
|
|
270
|
+
".gitkeep",
|
|
271
|
+
], cwd);
|
|
272
|
+
}
|
|
273
|
+
if (!(await gitSucceeds(["remote", "get-url", "origin"], cwd))) {
|
|
274
|
+
const repoName = `${basename(cwd)}-${Math.floor(Date.now() / 1000)}`;
|
|
275
|
+
await run("gh", ["repo", "create", repoName, "--private", "--source=.", "--remote=origin", "--push"], cwd);
|
|
276
|
+
result.createdRemote = repoName;
|
|
277
|
+
}
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
export async function runDcoDispatch(cwd, description, options = {}) {
|
|
281
|
+
if (!description || description.trim().length === 0) {
|
|
282
|
+
return { ok: false, failure: "A PR description is required." };
|
|
283
|
+
}
|
|
284
|
+
// Dispatch always appends its own authoritative `Agent DID:` line. A
|
|
285
|
+
// description that already carries one would put two DIDs in the PR body,
|
|
286
|
+
// and `extractAgentDid` treats a multi-DID body as unverifiable, so the PR
|
|
287
|
+
// would be created and then fail its own verification. `hasAgentDidClaim`
|
|
288
|
+
// uses the exact same line pattern the verifier does, so it catches the
|
|
289
|
+
// backticked, mid-line form the managed CLAUDE.md block emits, not just a
|
|
290
|
+
// line-start one. Reject before any side effects.
|
|
291
|
+
if (hasAgentDidClaim(description)) {
|
|
292
|
+
return {
|
|
293
|
+
ok: false,
|
|
294
|
+
failure: "The description already contains an `Agent DID:` line. Dispatch adds the attribution automatically; pass only your prose so the PR body has exactly one Agent DID line.",
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
const title = deriveDispatchTitle(description, options.title);
|
|
298
|
+
const identityResult = await resolveSigningIdentity(cwd, options.agent);
|
|
299
|
+
if (!identityResult.ok) {
|
|
300
|
+
return {
|
|
301
|
+
ok: false,
|
|
302
|
+
failure: identityResult.failure,
|
|
303
|
+
...(identityResult.agent ? { agent: identityResult.agent } : {}),
|
|
304
|
+
...(identityResult.did ? { did: identityResult.did } : {}),
|
|
305
|
+
title,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const { agent, did, signingConfig } = identityResult.identity;
|
|
309
|
+
const result = {
|
|
310
|
+
ok: false,
|
|
311
|
+
agent: { name: agent.name, slug: agent.slug },
|
|
312
|
+
did,
|
|
313
|
+
title,
|
|
314
|
+
};
|
|
315
|
+
try {
|
|
316
|
+
const coldStart = await ensureColdStartRepo(cwd, signingConfig);
|
|
317
|
+
result.createdRemote = coldStart.createdRemote;
|
|
318
|
+
const branch = `dco-demo-${Math.floor(Date.now() / 1000)}`;
|
|
319
|
+
await run("git", ["checkout", "-b", branch], cwd);
|
|
320
|
+
result.branch = branch;
|
|
321
|
+
// Symlink-safe append. Two vectors, both closed here:
|
|
322
|
+
// - Read: if a planted DCO-DEMO.md is a symlink, remove it (lstatSync
|
|
323
|
+
// does not follow the link) rather than readFileSync through it, so
|
|
324
|
+
// another file's contents can never be read into the committed demo
|
|
325
|
+
// file. A regular file is read and appended to as normal.
|
|
326
|
+
// - Write: writeFileAtomicSafe creates its temp sibling with O_EXCL and
|
|
327
|
+
// renameSync-replaces the destination inode without following it, so
|
|
328
|
+
// the write never lands outside the working tree.
|
|
329
|
+
const dcoDemoPath = join(cwd, "DCO-DEMO.md");
|
|
330
|
+
if (existsSync(dcoDemoPath) && lstatSync(dcoDemoPath).isSymbolicLink()) {
|
|
331
|
+
rmSync(dcoDemoPath);
|
|
332
|
+
}
|
|
333
|
+
const existingDcoDemo = existsSync(dcoDemoPath)
|
|
334
|
+
? readFileSync(dcoDemoPath, "utf-8")
|
|
335
|
+
: "";
|
|
336
|
+
writeFileAtomicSafe(dcoDemoPath, `${existingDcoDemo}${new Date().toISOString()} - ${title} - signed by ${agent.name} (${did})\n`);
|
|
337
|
+
await run("git", ["add", "DCO-DEMO.md"], cwd);
|
|
338
|
+
const commitSubject = buildDispatchCommitSubject(title);
|
|
339
|
+
// Own the trailers explicitly instead of relying on the setup-installed
|
|
340
|
+
// prepare-commit-msg hook: that hook is baked to whichever agent ran
|
|
341
|
+
// `dco setup`, which for a dispatch as a different slug (or in a fresh
|
|
342
|
+
// directory with no hook at all) would attribute the commit to the wrong
|
|
343
|
+
// agent, or to no agent. Disabling hooks and adding the sign-off (`-s`,
|
|
344
|
+
// the human committer) plus a Co-authored-by for THIS dispatch's agent
|
|
345
|
+
// keeps the commit trailer, the signing key, and the PR `Agent DID:` line
|
|
346
|
+
// all pointing at the same identity. `-- DCO-DEMO.md` restricts the
|
|
347
|
+
// commit to the demo file so unrelated staged changes never ride along.
|
|
348
|
+
const coAuthoredTrailer = `Co-authored-by: ${agent.name} <${agent.slug}@agents.knowthat.ai>`;
|
|
349
|
+
await run("git", [
|
|
350
|
+
"-c",
|
|
351
|
+
"core.hooksPath=/dev/null",
|
|
352
|
+
...signingConfig,
|
|
353
|
+
"commit",
|
|
354
|
+
"-s",
|
|
355
|
+
"--trailer",
|
|
356
|
+
coAuthoredTrailer,
|
|
357
|
+
"-m",
|
|
358
|
+
commitSubject,
|
|
359
|
+
"--",
|
|
360
|
+
"DCO-DEMO.md",
|
|
361
|
+
], cwd);
|
|
362
|
+
result.commitSha = await run("git", ["rev-parse", "HEAD"], cwd);
|
|
363
|
+
const rawCommit = await run("git", ["cat-file", "commit", "HEAD"], cwd);
|
|
364
|
+
result.signed = isCommitSigned(rawCommit);
|
|
365
|
+
if (!result.signed) {
|
|
366
|
+
result.failure =
|
|
367
|
+
"The commit was created but is NOT signed. Run `dco setup` in this repo, then dispatch again.";
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
370
|
+
await run("git", ["push", "-u", "origin", "HEAD"], cwd);
|
|
371
|
+
const body = [
|
|
372
|
+
description,
|
|
373
|
+
"",
|
|
374
|
+
`Agent: [${agent.name}](${agent.url})`,
|
|
375
|
+
`Agent DID: ${did}`,
|
|
376
|
+
].join("\n");
|
|
377
|
+
const prOutput = await run("gh", ["pr", "create", "--title", title, "--body", body], cwd);
|
|
378
|
+
const urlMatch = prOutput.match(/https:\/\/github\.com\/\S+\/pull\/\d+/);
|
|
379
|
+
if (!urlMatch) {
|
|
380
|
+
result.failure = `Could not find a PR URL in \`gh pr create\` output: ${prOutput}`;
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
result.prUrl = urlMatch[0];
|
|
384
|
+
const prBody = await getPullRequestBody(result.prUrl);
|
|
385
|
+
const verification = await verifyPrAttribution(prBody);
|
|
386
|
+
result.verified = verification.ok;
|
|
387
|
+
if (!verification.ok) {
|
|
388
|
+
result.failure = `PR created (${result.prUrl}) but attribution verification failed: ${verification.detail ?? verification.reason ?? "unknown"}`;
|
|
389
|
+
return result;
|
|
390
|
+
}
|
|
391
|
+
result.ok = true;
|
|
392
|
+
return result;
|
|
393
|
+
}
|
|
394
|
+
catch (error) {
|
|
395
|
+
result.failure = errorMessage(error);
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../src/utils/dco/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjE,OAAO,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AO,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { type FixAttestation } from "@kya-os/contracts/review";
|
|
2
|
+
/**
|
|
3
|
+
* `dco fix` — push a signed, attributed fix commit to an EXISTING PR's head
|
|
4
|
+
* branch, in response to a review that requested changes.
|
|
5
|
+
*
|
|
6
|
+
* `dco dispatch` (`dispatch.ts`) is a demo flow by construction: it always
|
|
7
|
+
* creates a fresh branch and a NEW PR, and its commit is path-scoped to one
|
|
8
|
+
* hardcoded demo file. Neither is safe or even possible for "land a real fix
|
|
9
|
+
* on a PR someone already opened." This command reuses dispatch's signing
|
|
10
|
+
* half in full (`resolveSigningIdentity`) but replaces its branch/commit/PR
|
|
11
|
+
* flow with one that: checks out the PR's actual head branch, commits
|
|
12
|
+
* exactly whatever the caller staged (no path scoping — see the commit step
|
|
13
|
+
* below for why that's the right guard here), pushes to that SAME branch
|
|
14
|
+
* (never a new one, never force), and optionally posts a signed attestation
|
|
15
|
+
* answering the review that requested the fix.
|
|
16
|
+
*
|
|
17
|
+
* Every step fails closed with a named `failure` BEFORE the step that would
|
|
18
|
+
* have side effects, and nothing is ever pushed after a failed verification
|
|
19
|
+
* step (see the signed-commit check before the push call below).
|
|
20
|
+
*/
|
|
21
|
+
export interface DcoFixOptions {
|
|
22
|
+
/** PR number, or a full PR URL. */
|
|
23
|
+
pr: string;
|
|
24
|
+
/** owner/name; when omitted, derived from `git remote get-url origin`. */
|
|
25
|
+
repo?: string;
|
|
26
|
+
/** Existing agent slug; same resolution rules as `dco dispatch`. */
|
|
27
|
+
agent?: string;
|
|
28
|
+
/** `git add -A` before committing. Default false: the caller stages. */
|
|
29
|
+
stageAll?: boolean;
|
|
30
|
+
/** Post the signed fix attestation as a PR comment. Default true. */
|
|
31
|
+
attest?: boolean;
|
|
32
|
+
/** The reviewed headSha this fix answers (40-hex). Required for attestation. */
|
|
33
|
+
respondsTo?: string;
|
|
34
|
+
/** The DIDComm fix task this run was dispatched for, when applicable. */
|
|
35
|
+
taskId?: string;
|
|
36
|
+
/** Commit subject. Default "fix: address signed review findings". */
|
|
37
|
+
message?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface DcoFixResult {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
/** Named, human-readable description of the step that failed, when !ok. */
|
|
42
|
+
failure?: string;
|
|
43
|
+
agent?: string;
|
|
44
|
+
did?: string;
|
|
45
|
+
branch?: string;
|
|
46
|
+
commitSha?: string;
|
|
47
|
+
signed?: boolean;
|
|
48
|
+
pushed?: boolean;
|
|
49
|
+
attested?: boolean;
|
|
50
|
+
prUrl?: string;
|
|
51
|
+
}
|
|
52
|
+
export declare function parseOwnerRepoFromRemoteUrl(url: string): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Parse "owner/repo" out of a full PR URL (`https://github.com/owner/repo/pull/123`).
|
|
55
|
+
* Returns null for a bare PR number (or anything else): a bare number carries
|
|
56
|
+
* no repo of its own, so there is nothing to cross-check it against — every
|
|
57
|
+
* gh call below is scoped to `targetRepo` explicitly regardless.
|
|
58
|
+
*
|
|
59
|
+
* Shares PR_URL_PATTERN with extractPrNumber on purpose, rather than each
|
|
60
|
+
* using its own regex: an input recognized by ONE as URL-shaped but not the
|
|
61
|
+
* OTHER used to let a same-numbered-PR mismatch slip through silently — an
|
|
62
|
+
* uppercase scheme, a missing scheme, or a URL embedded in surrounding text
|
|
63
|
+
* would fail this function's narrower original pattern (skipping the
|
|
64
|
+
* wrong-remote check below, since it only runs when this returns non-null)
|
|
65
|
+
* while still matching extractPrNumber's looser unanchored `/pull/(\d+)`
|
|
66
|
+
* search, so the flow proceeded against this checkout's same-numbered PR
|
|
67
|
+
* with no cross-repo check ever having run. One shared pattern means
|
|
68
|
+
* whatever extractPrNumber accepts as URL-shaped, this function recognizes
|
|
69
|
+
* too, so the check it guards can never be bypassed that way.
|
|
70
|
+
*/
|
|
71
|
+
export declare function parseOwnerRepoFromPrUrl(pr: string): string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Normalize `pr` (a bare number or a full PR URL) down to just the number,
|
|
74
|
+
* so every `gh pr` call below can be pinned with an explicit `-R targetRepo`
|
|
75
|
+
* instead of a heterogeneous target that sometimes carries its own repo and
|
|
76
|
+
* sometimes relies on ambient resolution. Ambient resolution is NOT
|
|
77
|
+
* guaranteed to agree with `cwd`'s git remote — `GH_REPO` or a `gh repo
|
|
78
|
+
* set-default` override takes precedence over it — so a bare number handed
|
|
79
|
+
* to `gh` unpinned could read a different repo's PR even after step 2's
|
|
80
|
+
* origin check. Returns null for anything that isn't a plain integer or a
|
|
81
|
+
* `.../pull/<number>` URL matching PR_URL_PATTERN.
|
|
82
|
+
*/
|
|
83
|
+
export declare function extractPrNumber(pr: string): string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Strip characters that could break out of the marker-bounded structure
|
|
86
|
+
* `buildFixAttestationCommentBody` builds around a value: a backtick would
|
|
87
|
+
* prematurely close/reopen an adjacent code span; `-->` would prematurely
|
|
88
|
+
* close this function's own HTML comment marker, letting whatever follows
|
|
89
|
+
* render as visible PR-comment content instead of staying hidden inside
|
|
90
|
+
* it; and, the other direction, a bare `<!--` would OPEN a new comment
|
|
91
|
+
* mid-line, hiding everything after it in GitHub's rendered view —
|
|
92
|
+
* including the fenced attestation block that's supposed to stay publicly
|
|
93
|
+
* visible and verifiable. Defense in depth alongside
|
|
94
|
+
* `FixAttestationSubjectSchema.repo`'s tighter character-class validation:
|
|
95
|
+
* this also covers `agentName`, a free-text display name with no schema of
|
|
96
|
+
* its own (an agent's `.mcpi/agent.json` name, sourced from a checkout —
|
|
97
|
+
* see resolve-agent.ts's threat model for the same class of hostile-repo
|
|
98
|
+
* risk applied to CLAUDE.md). Exported so `agent/markers.ts`'s review-verdict
|
|
99
|
+
* marker (the same breakout risk, applied to a reviewer DID/repo instead of
|
|
100
|
+
* an agent name/DID) reuses this exact sanitizer rather than a second copy
|
|
101
|
+
* that could drift on which characters it strips.
|
|
102
|
+
*/
|
|
103
|
+
export declare function sanitizeForMarkdownBlock(value: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Build the PR comment body posted for a fix attestation: an HTML-comment
|
|
106
|
+
* marker (so a future `dco` run can find and dedupe on it), a one-line
|
|
107
|
+
* human summary, and a fenced `kya-os-fix-attestation` JSON block that
|
|
108
|
+
* round-trips `FixAttestationSchema`. The marker's fields are duplicated
|
|
109
|
+
* from `attestation` in a stable, greppable form so tooling never has to
|
|
110
|
+
* parse the fenced block just to know which commit/PR a comment is about.
|
|
111
|
+
* The fenced JSON block itself carries the RAW, unsanitized values (it's
|
|
112
|
+
* the actual signed data — sanitizing it would make it not round-trip);
|
|
113
|
+
* only the marker and summary lines, which render as live markdown, are
|
|
114
|
+
* sanitized. That includes `agentDid`: `DidStringSchema` only requires a
|
|
115
|
+
* `did:<method>:` prefix followed by any non-whitespace method-specific
|
|
116
|
+
* id, so it's exactly as free-form (and exactly as hostile-repo-sourced,
|
|
117
|
+
* for a locally-registered agent whose name/DID this command reads off
|
|
118
|
+
* disk) as `agentName` is — same breakout risk, same fix.
|
|
119
|
+
*/
|
|
120
|
+
export declare function buildFixAttestationCommentBody(attestation: FixAttestation, agentName: string): string;
|
|
121
|
+
export declare function runDcoFix(cwd: string, options: DcoFixOptions): Promise<DcoFixResult>;
|
|
122
|
+
//# sourceMappingURL=fix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix.d.ts","sourceRoot":"","sources":["../../../src/utils/dco/fix.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,0BAA0B,CAAC;AAOlC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,K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