@mnaimfaizy/agent-kit 1.0.0-beta.14 → 1.0.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -4
- package/custom-harness.schema.json +243 -0
- package/harnesses.json +244 -6
- package/package.json +3 -2
- package/src/checks/ci-workflow.mjs +105 -0
- package/src/checks/claude-app.mjs +11 -2
- package/src/checks/custom-harness.mjs +157 -0
- package/src/checks/github-app.mjs +214 -0
- package/src/checks/rulesets.mjs +9 -8
- package/src/checks/secrets-and-variables.mjs +27 -8
- package/src/checks/stages.mjs +705 -0
- package/src/cli.mjs +583 -36
- package/src/deep-scan/agent.mjs +88 -21
- package/src/deep-scan/credential.mjs +81 -32
- package/src/deep-scan/docker-driver.mjs +105 -42
- package/src/deep-scan/harness-text.mjs +99 -0
- package/src/deep-scan/lifecycle.mjs +68 -178
- package/src/deep-scan/limits.mjs +13 -7
- package/src/deep-scan/model-proxy.mjs +21 -10
- package/src/deep-scan/preflight.mjs +19 -6
- package/src/deep-scan/recipe.mjs +4 -0
- package/src/deep-scan/runtime.mjs +54 -6
- package/src/deep-scan/sandbox-run.mjs +232 -0
- package/src/deep-scan/sbx-driver.mjs +224 -39
- package/src/deep-scan/tar.mjs +69 -22
- package/src/deep-scan/verify.mjs +6 -1
- package/src/deep-scan.mjs +73 -13
- package/src/doctor.mjs +166 -5
- package/src/exec.mjs +14 -5
- package/src/factory/budget/budget.mjs +259 -0
- package/src/factory/build/command.mjs +321 -0
- package/src/factory/build/factory.mjs +473 -0
- package/src/factory/build/findings.mjs +55 -0
- package/src/factory/build/host.mjs +230 -0
- package/src/factory/build/notes.mjs +191 -0
- package/src/factory/build/pull-request.mjs +74 -0
- package/src/factory/bundle.mjs +146 -0
- package/src/factory/checks/allowed-paths.mjs +50 -0
- package/src/factory/checks/plan-header.mjs +296 -0
- package/src/factory/checks/qa.mjs +85 -0
- package/src/factory/checks/review.mjs +73 -0
- package/src/factory/checks/security.mjs +50 -0
- package/src/factory/checks/stage-check.mjs +89 -0
- package/src/factory/claims/command.mjs +187 -0
- package/src/factory/claims/release.mjs +111 -0
- package/src/factory/decision/answers.mjs +103 -0
- package/src/factory/decision/command.mjs +64 -0
- package/src/factory/decision/plan.mjs +99 -0
- package/src/factory/decision/request.mjs +116 -0
- package/src/factory/doctor/files.mjs +329 -0
- package/src/factory/doctor/index.mjs +56 -0
- package/src/factory/doctor/local.mjs +497 -0
- package/src/factory/doctor/orchestrate.mjs +146 -0
- package/src/factory/engine/lease.mjs +146 -0
- package/src/factory/engine/local-engine.mjs +177 -0
- package/src/factory/engine/lockfile.mjs +64 -0
- package/src/factory/engine/workflow-engine.mjs +124 -0
- package/src/factory/gate/comment.mjs +88 -0
- package/src/factory/gate/config.mjs +57 -0
- package/src/factory/gate/gate-core.mjs +250 -0
- package/src/factory/gate/guarded.mjs +17 -0
- package/src/factory/gate/reads.mjs +105 -0
- package/src/factory/gate/task.mjs +193 -0
- package/src/factory/gate/trip-reads.mjs +82 -0
- package/src/factory/gate/trip.mjs +87 -0
- package/src/factory/init/blueprint.mjs +174 -0
- package/src/factory/init/index.mjs +337 -0
- package/src/factory/labels/evidence.mjs +162 -0
- package/src/factory/labels/moves.mjs +32 -0
- package/src/factory/labels/reconcile.mjs +267 -0
- package/src/factory/labels/revert.mjs +87 -0
- package/src/factory/labels/timeline.mjs +72 -0
- package/src/factory/labels/voided.mjs +59 -0
- package/src/factory/limits/harness.mjs +39 -0
- package/src/factory/limits/limits.mjs +123 -0
- package/src/factory/merge/command.mjs +172 -0
- package/src/factory/outbox/check.mjs +240 -0
- package/src/factory/outbox/rulings.mjs +195 -0
- package/src/factory/plan/command.mjs +66 -0
- package/src/factory/plan/comment.mjs +156 -0
- package/src/factory/plan/publish.mjs +149 -0
- package/src/factory/plan/risk.mjs +153 -0
- package/src/factory/qa/command.mjs +163 -0
- package/src/factory/records/engine-record.mjs +133 -0
- package/src/factory/records/main.mjs +96 -0
- package/src/factory/records/record.mjs +226 -0
- package/src/factory/records/sink.mjs +57 -0
- package/src/factory/report/build.mjs +92 -0
- package/src/factory/report/command.mjs +80 -0
- package/src/factory/report/facts.mjs +226 -0
- package/src/factory/report/gate-section.mjs +122 -0
- package/src/factory/report/metrics.mjs +111 -0
- package/src/factory/report/reads.mjs +246 -0
- package/src/factory/report/render.mjs +121 -0
- package/src/factory/report/rollout.mjs +154 -0
- package/src/factory/review/command.mjs +182 -0
- package/src/factory/run/awake.mjs +70 -0
- package/src/factory/run/collect.mjs +77 -0
- package/src/factory/run/command.mjs +490 -0
- package/src/factory/run/gh.mjs +46 -0
- package/src/factory/run/launch.mjs +47 -0
- package/src/factory/run/pipelines.mjs +261 -0
- package/src/factory/run/raw.mjs +96 -0
- package/src/factory/run/restart.mjs +83 -0
- package/src/factory/run/s3.mjs +193 -0
- package/src/factory/run/secrets.mjs +142 -0
- package/src/factory/run/teardown.mjs +242 -0
- package/src/factory/run/token.mjs +68 -0
- package/src/factory/security/command.mjs +157 -0
- package/src/factory/setup/app.mjs +122 -0
- package/src/factory/setup/command.mjs +409 -0
- package/src/factory/setup/labels.mjs +25 -0
- package/src/factory/setup/reads.mjs +129 -0
- package/src/factory/setup/writes.mjs +126 -0
- package/src/factory/snapshot/write.mjs +176 -0
- package/src/factory/stop/command.mjs +136 -0
- package/src/factory/sweep/actions-main.mjs +117 -0
- package/src/factory/sweep/command.mjs +65 -0
- package/src/factory/sweep/knobs.mjs +78 -0
- package/src/factory/sweep/marker-version.mjs +15 -0
- package/src/factory/sweep/markers.mjs +112 -0
- package/src/factory/sweep/overlap.mjs +24 -0
- package/src/factory/sweep/run.mjs +198 -0
- package/src/factory/sweep/shell.mjs +394 -0
- package/src/factory/sweep/split.mjs +104 -0
- package/src/factory/sweep/states.mjs +87 -0
- package/src/factory/sweep/sweep-core.mjs +1781 -0
- package/src/factory/tracker/github.mjs +674 -0
- package/src/factory/tracker/operations.mjs +153 -0
- package/src/factory/upgrade/index.mjs +83 -0
- package/src/harness/adapters.mjs +30 -0
- package/src/harness/antigravity.mjs +187 -0
- package/src/harness/claude-code.mjs +8 -1
- package/src/harness/codex.mjs +219 -0
- package/src/harness/cursor.mjs +199 -0
- package/src/harness/custom/registry.mjs +21 -0
- package/src/harness/custom/schema.mjs +90 -0
- package/src/harness/custom.mjs +299 -0
- package/src/harness/facts.mjs +44 -7
- package/src/harness/gemini.mjs +164 -0
- package/src/harness/install-layer.mjs +86 -3
- package/src/harness/opencode.mjs +289 -0
- package/src/harness/resolve.mjs +156 -0
- package/src/harness/support-levels.mjs +151 -3
- package/src/harness-live/assess.mjs +29 -6
- package/src/harness-live/cursor-real.mjs +146 -0
- package/src/harness-live/cursor-version.mjs +70 -0
- package/src/harness-live/cursor.mjs +80 -0
- package/src/harness-live/custom.mjs +91 -0
- package/src/harness-live/fixture-harness.mjs +45 -0
- package/src/harness-live/harnesses.mjs +263 -0
- package/src/harness-live/host.mjs +113 -4
- package/src/harness-live/opencode.mjs +289 -0
- package/src/harness-live/probes.mjs +87 -7
- package/src/harness-live/run.mjs +101 -20
- package/src/harness-live/setup.mjs +126 -0
- package/src/harness-live/stage.mjs +25 -15
- package/src/harness-live/suite.mjs +276 -95
- package/src/harness-test.mjs +116 -0
- package/src/init.mjs +374 -36
- package/src/kit-owned-paths.mjs +1 -1
- package/src/model-proxy/core.mjs +128 -20
- package/src/model-proxy/profiles/anthropic.mjs +54 -10
- package/src/model-proxy/profiles/gemini-api.mjs +311 -0
- package/src/model-proxy/profiles/openai.mjs +327 -0
- package/src/model-proxy/stub-dialects/gemini-api.mjs +178 -0
- package/src/model-proxy/stub-dialects/openai.mjs +173 -0
- package/src/model-proxy/stub.mjs +9 -1
- package/src/stage/audit.mjs +79 -0
- package/src/stage/egress-route.mjs +207 -0
- package/src/stage/implement/carry.mjs +308 -0
- package/src/stage/implement/sandbox.mjs +271 -0
- package/src/stage/implement/verify.mjs +70 -0
- package/src/stage/implement.mjs +218 -0
- package/src/stage/plan.mjs +115 -0
- package/src/stage/review-response.mjs +172 -0
- package/src/stage/review.mjs +185 -0
- package/src/stage/workspace.mjs +274 -0
- package/src/stage.mjs +1087 -0
- package/src/upgrade.mjs +39 -7
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// The tracker adapter's named operations, as in TRACKERS.md, and how the
|
|
2
|
+
// `github` mapping realises each one. The sweep and its shell speak only these
|
|
3
|
+
// names; a second tracker would add a mapping beside `github`, not change them.
|
|
4
|
+
//
|
|
5
|
+
// `implemented` says whether the adapter realises the operation; every one does today. An
|
|
6
|
+
// operation marked `implemented: false` would throw when called, so a sweep that needs it
|
|
7
|
+
// fails loudly.
|
|
8
|
+
|
|
9
|
+
export const OPERATIONS = Object.freeze({
|
|
10
|
+
"read-state": {
|
|
11
|
+
implemented: true,
|
|
12
|
+
does: "Every open issue carrying a factory:* state label, with labels, the label timeline, comments (and who last edited each) and linked pull requests.",
|
|
13
|
+
github: "One GraphQL query, one aliased `issues(labels:)` field per state; then head statuses.",
|
|
14
|
+
},
|
|
15
|
+
"read-head-statuses": {
|
|
16
|
+
implemented: true,
|
|
17
|
+
does: "The commit statuses of each linked pull request's head commit.",
|
|
18
|
+
github:
|
|
19
|
+
"REST `GET repos/{r}/commits/{sha}/statuses?per_page=100` (newest first, every creator), one call per distinct head.",
|
|
20
|
+
},
|
|
21
|
+
"set-state": {
|
|
22
|
+
implemented: true,
|
|
23
|
+
does: "Move an issue's one Factory state label from one state to another.",
|
|
24
|
+
github: "REST: add the new label, then remove the old one (no compare-and-swap exists).",
|
|
25
|
+
},
|
|
26
|
+
claim: {
|
|
27
|
+
implemented: true,
|
|
28
|
+
does: "Write a Claim comment and return its id.",
|
|
29
|
+
github: "REST `POST repos/{r}/issues/{n}/comments`.",
|
|
30
|
+
},
|
|
31
|
+
"read-claim": {
|
|
32
|
+
implemented: true,
|
|
33
|
+
does: "Read an issue's comments again, fresh, to see which Claim won.",
|
|
34
|
+
github: "REST `GET repos/{r}/issues/{n}/comments`, paginated.",
|
|
35
|
+
},
|
|
36
|
+
release: {
|
|
37
|
+
implemented: true,
|
|
38
|
+
does: "Edit a Claim comment in place to add `released=<reason>`.",
|
|
39
|
+
github: "REST `GET` then `PATCH repos/{r}/issues/comments/{id}`.",
|
|
40
|
+
},
|
|
41
|
+
comment: {
|
|
42
|
+
implemented: true,
|
|
43
|
+
does: "Post a comment on an issue.",
|
|
44
|
+
github: "REST `POST repos/{r}/issues/{n}/comments`.",
|
|
45
|
+
},
|
|
46
|
+
"read-issue": {
|
|
47
|
+
implemented: true,
|
|
48
|
+
does: "An issue's body and labels, for the plan Stage's trusted step.",
|
|
49
|
+
github: "REST `GET repos/{r}/issues/{n}`.",
|
|
50
|
+
},
|
|
51
|
+
"read-comments": {
|
|
52
|
+
implemented: true,
|
|
53
|
+
does: "An issue's comments, fresh and complete, with their authors.",
|
|
54
|
+
github: "REST `GET repos/{r}/issues/{n}/comments`, paginated (the same read as `read-claim`).",
|
|
55
|
+
},
|
|
56
|
+
"post-comment": {
|
|
57
|
+
implemented: true,
|
|
58
|
+
does: "Post a comment from a body that may be large, and return its id and link.",
|
|
59
|
+
github: "REST `POST repos/{r}/issues/{n}/comments`, the body on stdin.",
|
|
60
|
+
},
|
|
61
|
+
"edit-comment": {
|
|
62
|
+
implemented: true,
|
|
63
|
+
does: "Replace a comment's body (a superseded plan's first line).",
|
|
64
|
+
github: "REST `PATCH repos/{r}/issues/comments/{id}`, the body on stdin.",
|
|
65
|
+
},
|
|
66
|
+
"read-file": {
|
|
67
|
+
implemented: true,
|
|
68
|
+
does: "A file's text on the base branch, or null when it is not there (the risk rules).",
|
|
69
|
+
github: "REST `GET repos/{r}/contents/{path}?ref={branch}`, raw media type.",
|
|
70
|
+
},
|
|
71
|
+
"read-writers": {
|
|
72
|
+
implemented: true,
|
|
73
|
+
does: "Which of some logins have write access, so only their replies to a Decision Request count.",
|
|
74
|
+
github:
|
|
75
|
+
"REST `GET repos/{r}/collaborators/{login}/permission`, one call per distinct login: `admin` and `write` count; a 404 is not a writer; any other failure throws.",
|
|
76
|
+
},
|
|
77
|
+
"read-pull": {
|
|
78
|
+
implemented: true,
|
|
79
|
+
does: "A pull request's state, head, base, changed paths and lines, and whether it merges cleanly (the merge gate).",
|
|
80
|
+
github: "REST `GET repos/{r}/pulls/{n}` and `.../files` (paginated); a diff cut short throws.",
|
|
81
|
+
},
|
|
82
|
+
"read-compare": {
|
|
83
|
+
implemented: true,
|
|
84
|
+
does: "How far one ref is ahead of and behind another, and the files that differ.",
|
|
85
|
+
github: "REST `GET repos/{r}/compare/{base}...{head}`; 300 files or more throws.",
|
|
86
|
+
},
|
|
87
|
+
"read-required-contexts": {
|
|
88
|
+
implemented: true,
|
|
89
|
+
does: "The status contexts the ruleset on a branch requires.",
|
|
90
|
+
github: "REST `GET repos/{r}/rules/branches/{branch}`: the `required_status_checks` rules.",
|
|
91
|
+
},
|
|
92
|
+
"read-checks": {
|
|
93
|
+
implemented: true,
|
|
94
|
+
does: "The checks and statuses on a commit or branch tip, by name, each success, failure or pending.",
|
|
95
|
+
github: "GraphQL `object(expression:) { ... on Commit { statusCheckRollup } }`.",
|
|
96
|
+
},
|
|
97
|
+
"update-branch": {
|
|
98
|
+
implemented: true,
|
|
99
|
+
does: "Merge the base into a pull request's branch, only if its head is the one the gate read.",
|
|
100
|
+
github: "REST `PUT repos/{r}/pulls/{n}/update-branch` with `expected_head_sha`.",
|
|
101
|
+
},
|
|
102
|
+
"write-stage-check": {
|
|
103
|
+
implemented: true,
|
|
104
|
+
does: "Write one Stage check on a commit (the gate's carry-over).",
|
|
105
|
+
github: "REST `POST repos/{r}/statuses/{sha}`, through the shared Stage check writer.",
|
|
106
|
+
},
|
|
107
|
+
"revert-label": {
|
|
108
|
+
implemented: true,
|
|
109
|
+
does: "Put an issue's labels back: add the state the evidence supports, then remove the wrong one.",
|
|
110
|
+
github: "REST `POST` then `DELETE repos/{r}/issues/{n}/labels`; a label already gone is done.",
|
|
111
|
+
},
|
|
112
|
+
"remove-label": {
|
|
113
|
+
implemented: true,
|
|
114
|
+
does: "Take one label off an issue (a Trigger label on a Factory issue).",
|
|
115
|
+
github: "REST `DELETE repos/{r}/issues/{n}/labels/{name}`; a label already gone is done.",
|
|
116
|
+
},
|
|
117
|
+
"read-control": {
|
|
118
|
+
implemented: true,
|
|
119
|
+
does: "The Factory control issue and its comments with who last edited each (the merge gate's trip marker).",
|
|
120
|
+
github:
|
|
121
|
+
"REST `GET repos/{r}/issues?state=open` to find the issue by its marker, then a GraphQL `issue.comments(first: 100, after: cursor)`, paged in full, for the editors.",
|
|
122
|
+
},
|
|
123
|
+
"add-assignee": {
|
|
124
|
+
implemented: true,
|
|
125
|
+
does: "Assign an issue to a login (the Orchestrate engine's Claims also assign the user).",
|
|
126
|
+
github: "REST `POST repos/{r}/issues/{n}/assignees`.",
|
|
127
|
+
},
|
|
128
|
+
"create-sub-issue": {
|
|
129
|
+
implemented: true,
|
|
130
|
+
does: "Create an issue under a parent, with its labels in the same request (a plan's split).",
|
|
131
|
+
github:
|
|
132
|
+
"REST `POST repos/{r}/issues` (title, body, labels), then `POST repos/{r}/issues/{parent}/sub_issues` with the new issue's id; an issue already attached is done.",
|
|
133
|
+
},
|
|
134
|
+
"add-blocked-by": {
|
|
135
|
+
implemented: true,
|
|
136
|
+
does: "Make one issue block another (a split child's `blocked_by`), unless it already does.",
|
|
137
|
+
github:
|
|
138
|
+
"REST `GET` then `POST repos/{r}/issues/{n}/dependencies/blocked_by` with the blocker's id.",
|
|
139
|
+
},
|
|
140
|
+
"read-split-parent": {
|
|
141
|
+
implemented: true,
|
|
142
|
+
does: "A split's parent: its state, comments with their last editor, and each sub-issue's state and whether it is merged.",
|
|
143
|
+
github:
|
|
144
|
+
"One GraphQL `issue(number:) { state comments subIssues }`; a sub-issue is merged when it is closed and carries `factory:merged`; more than 100 sub-issues throws.",
|
|
145
|
+
},
|
|
146
|
+
"close-issue": {
|
|
147
|
+
implemented: true,
|
|
148
|
+
does: "Close an issue as completed, after one comment (the parent of a split, once every child is merged).",
|
|
149
|
+
github: "REST `POST` a comment, then `PATCH repos/{r}/issues/{n}` with `state=closed`.",
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export const OPERATION_NAMES = Object.freeze(Object.keys(OPERATIONS));
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// The Factory's part of `agent-kit upgrade` (spec #500, #520), wired in by
|
|
2
|
+
// cli/src/upgrade.mjs. Upgrade replaces what the Kit owns: the bundle
|
|
3
|
+
// `.github/agent-factory/` is a Kit-owned path, so the Kit-owned step already
|
|
4
|
+
// replaces it whole, and every `uses:` pin of a Caller is moved to the new tag.
|
|
5
|
+
// What this adds is the second pin a Factory Caller holds: the version of the CLI
|
|
6
|
+
// it installs (`@mnaimfaizy/agent-kit@<version>`), which must be the tag's own.
|
|
7
|
+
//
|
|
8
|
+
// What upgrade never touches, and why that holds:
|
|
9
|
+
// - the factory config, the risk rules, the ruleset JSON and `CODEOWNERS` are the
|
|
10
|
+
// Consumer's after the first copy. They are no Kit-owned path: the parser of
|
|
11
|
+
// kit-owned-paths.txt takes only a short list of shapes for deletion (ALLOWED_SHAPE),
|
|
12
|
+
// so a tag that listed one is refused before anything is written. Only the two
|
|
13
|
+
// pins in a Caller are rewritten, and only in `.github/workflows/factory-*.yml`.
|
|
14
|
+
// - the control issue, the App and the secrets live on GitHub. Upgrade writes local
|
|
15
|
+
// files only: its runner is `git` and `gh` on doctor's allowlist, and it makes no `gh`
|
|
16
|
+
// call at all.
|
|
17
|
+
// Contract suite: scripts/factory-upgrade.test.mjs. Docs: docs/factory/upgrade.md.
|
|
18
|
+
|
|
19
|
+
import { versionForTag } from "../../tags.mjs";
|
|
20
|
+
|
|
21
|
+
/** The blueprint Callers, the only workflow files whose CLI pin upgrade moves. */
|
|
22
|
+
export const FACTORY_CALLER_PATH = /^\.github\/workflows\/factory-[a-z][a-z0-9-]*\.ya?ml$/;
|
|
23
|
+
|
|
24
|
+
const CLI_PIN = /(@mnaimfaizy\/agent-kit@)([0-9][0-9A-Za-z.+-]*)(?=$|[\s"'#\\])/gm;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* `text` with every `@mnaimfaizy/agent-kit@<version>` moved to `version`. Only the
|
|
28
|
+
* version changes, so every other byte, the line endings included, stays.
|
|
29
|
+
* @returns {{ text: string, count: number }}
|
|
30
|
+
*/
|
|
31
|
+
export function rewriteCliPins(text, version) {
|
|
32
|
+
let count = 0;
|
|
33
|
+
const next = String(text).replace(CLI_PIN, (all, prefix, found) => {
|
|
34
|
+
if (found === version) return all;
|
|
35
|
+
count++;
|
|
36
|
+
return `${prefix}${version}`;
|
|
37
|
+
});
|
|
38
|
+
return { text: next, count };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The edits of Factory Callers' CLI pins, laid over the edits upgrade already holds for their
|
|
43
|
+
* `uses:` pins (one write per file, holding both).
|
|
44
|
+
*
|
|
45
|
+
* @param {{
|
|
46
|
+
* files: { path: string, pins: object[] }[],
|
|
47
|
+
* edits: { path: string, count: number, bytes: Buffer, cliOnly?: boolean }[],
|
|
48
|
+
* readText: (path: string) => string,
|
|
49
|
+
* newTag: string,
|
|
50
|
+
* }} input
|
|
51
|
+
* @returns {{ edits: object[], cli: { path: string, count: number }[] }}
|
|
52
|
+
*/
|
|
53
|
+
export function withCliPins({ files, edits, readText, newTag }) {
|
|
54
|
+
const version = versionForTag(newTag);
|
|
55
|
+
const byPath = new Map(edits.map((e) => [e.path, e]));
|
|
56
|
+
const cli = [];
|
|
57
|
+
for (const file of files) {
|
|
58
|
+
if (!FACTORY_CALLER_PATH.test(file.path)) continue;
|
|
59
|
+
const held = byPath.get(file.path);
|
|
60
|
+
const base = held ? held.bytes.toString("utf8") : readText(file.path);
|
|
61
|
+
const rewritten = rewriteCliPins(base, version);
|
|
62
|
+
if (rewritten.count === 0) continue;
|
|
63
|
+
cli.push({ path: file.path, count: rewritten.count });
|
|
64
|
+
byPath.set(file.path, {
|
|
65
|
+
path: file.path,
|
|
66
|
+
count: held?.count ?? 0,
|
|
67
|
+
cliOnly: held === undefined,
|
|
68
|
+
bytes: Buffer.from(rewritten.text, "utf8"),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Keep the order upgrade already had, then the Callers only this step touched.
|
|
72
|
+
const order = [...edits.map((e) => e.path), ...cli.map((c) => c.path)];
|
|
73
|
+
return { edits: [...new Set(order)].map((p) => byPath.get(p)), cli };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The lines upgrade prints about the Factory when the checkout has one, after its examples/ diff. */
|
|
77
|
+
export function factoryNotes({ newTag }) {
|
|
78
|
+
return [
|
|
79
|
+
`The Factory blueprint (${"`.github/factory/`"} config, risk rules and ruleset, ${"`CODEOWNERS`"} lines) is yours:`,
|
|
80
|
+
`upgrade left it as it was and changed only the bundle and the Callers' pins. The examples/factory/ part of the diff above is for you to apply by hand where you want it.`,
|
|
81
|
+
`Nothing on GitHub was touched either: the control issue, the App and the secrets are as setup left them (${newTag}'s \`agent-kit factory setup\` is safe to run again).`,
|
|
82
|
+
];
|
|
83
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The Harness adapters the kit ships (ADR 0027), by harness name: each takes a
|
|
2
|
+
// Stage request and returns its launch plan.
|
|
3
|
+
|
|
4
|
+
import { antigravity } from "./antigravity.mjs";
|
|
5
|
+
import { claudeCode } from "./claude-code.mjs";
|
|
6
|
+
import { codex } from "./codex.mjs";
|
|
7
|
+
import { cursor } from "./cursor.mjs";
|
|
8
|
+
import { loadedCustom } from "./custom/registry.mjs";
|
|
9
|
+
import { gemini } from "./gemini.mjs";
|
|
10
|
+
import { opencode } from "./opencode.mjs";
|
|
11
|
+
|
|
12
|
+
/** @type {Readonly<Record<string, (request?: object) => import("./claude-code.mjs").LaunchPlan>>} */
|
|
13
|
+
export const ADAPTERS = Object.freeze({
|
|
14
|
+
"claude-code": claudeCode,
|
|
15
|
+
codex,
|
|
16
|
+
gemini,
|
|
17
|
+
antigravity,
|
|
18
|
+
opencode,
|
|
19
|
+
cursor,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `harness`'s adapter: the kit's own, or a Custom harness's once its file is
|
|
24
|
+
* loaded from the trusted commit (harness/resolve.mjs).
|
|
25
|
+
* @param {string} harness
|
|
26
|
+
*/
|
|
27
|
+
export const adapterFor = (harness) => loadedCustom(harness)?.adapter ?? ADAPTERS[harness];
|
|
28
|
+
|
|
29
|
+
/** The harness a Stage runs on when no setting names one (ADR 0022). */
|
|
30
|
+
export const DEFAULT_HARNESS = "claude-code";
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// The Antigravity CLI Harness adapter (ADR 0027): one function that takes a
|
|
2
|
+
// Stage request and returns a launch plan, as plain data. The Launcher does
|
|
3
|
+
// everything with the plan; this module starts nothing and imports nothing.
|
|
4
|
+
//
|
|
5
|
+
// The CLI (`agy`): one pinned version, in `/opt/agent-kit` of the kit's Harness
|
|
6
|
+
// image (ADR 0029, docker/harness-images/), which is pinned by digest. The
|
|
7
|
+
// updater is off in the image and in the run's environment. Nothing is
|
|
8
|
+
// installed at run time.
|
|
9
|
+
//
|
|
10
|
+
// The launch: headless, the brief on stdin (with no `-p`, which takes the
|
|
11
|
+
// prompt on the command line), every tool call approved, since the Launcher's
|
|
12
|
+
// sandbox reaches the Guards. Everything the CLI reads and writes of its own is
|
|
13
|
+
// under `--gemini_dir`, in a folder of the Launcher's that it empties first, so
|
|
14
|
+
// nothing in the sandbox's home is read. There the Launcher writes the
|
|
15
|
+
// settings (`modelProvider: "gemini"`, which makes the CLI use the key in
|
|
16
|
+
// `GEMINI_API_KEY` with no sign-in) and one agent of its own, which the run is
|
|
17
|
+
// made as. No setting of the pinned version turns its web search off, and a
|
|
18
|
+
// permission rule naming it is dropped, so that agent lists the local tools it
|
|
19
|
+
// has and no other: no web search and no subagent, which could have its own.
|
|
20
|
+
//
|
|
21
|
+
// `agy` loads `.agents/`, `.agent/`, `_agents/` and `_agent/` (hooks, MCP
|
|
22
|
+
// servers, plugins, skills, agents) from the working directory with no trust
|
|
23
|
+
// asked, so the Launcher removes each from the copy, and `.gemini/` with them.
|
|
24
|
+
// `AGENTS.md` and `GEMINI.md` are instruction files it loads by itself.
|
|
25
|
+
//
|
|
26
|
+
// The model API's base URL is the model proxy, over plain HTTP, which the
|
|
27
|
+
// pinned version accepts; the live suite names that cause if a bump does not.
|
|
28
|
+
//
|
|
29
|
+
// The agent holds only the run's caller key as its `GEMINI_API_KEY`. It has no
|
|
30
|
+
// turn limit: the wall clock and the proxy's token cap bound the run. A CLI
|
|
31
|
+
// that asks for a sign-in was not given a credential it reads.
|
|
32
|
+
//
|
|
33
|
+
// The only credential is a Gemini API key. A Google sign-in is not accepted:
|
|
34
|
+
// the CLI's signed-in calls include one to a fixed Google host that no setting
|
|
35
|
+
// points at the model proxy (#578).
|
|
36
|
+
|
|
37
|
+
/** The Antigravity CLI version every sandbox runs, pinned. */
|
|
38
|
+
const VERSION = "1.5.20";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The Harness image that holds that version. The `harness-images` workflow
|
|
42
|
+
* builds it in the pull request that changes the pin or its Dockerfile, and
|
|
43
|
+
* fails until this holds the digest it pushed
|
|
44
|
+
* (`node docker/harness-images/image.mjs record antigravity`).
|
|
45
|
+
*/
|
|
46
|
+
const IMAGE = "ghcr.io/mnaimfaizy/agent-kit-sandbox-antigravity";
|
|
47
|
+
const IMAGE_DIGEST = "sha256:db9e91a505fb28977a0d1a13af747060eba9facdf16385c0461a5a08726c06be"; // inputs-7f6aaef296738b4eb2ed3d0e2588a7b3
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* What a Consumer needs to know about Antigravity CLI, which
|
|
51
|
+
* `cli/harnesses.json` publishes per tag (ADR 0030): the kit secret it accepts,
|
|
52
|
+
* with where to get it; the values its `--effort` takes (each model offers some
|
|
53
|
+
* of them, and the CLI refuses one its model does not); and the model a Stage
|
|
54
|
+
* gets when none is named, which is the pinned version's own default.
|
|
55
|
+
*/
|
|
56
|
+
export const FACTS = Object.freeze({
|
|
57
|
+
displayName: "Antigravity CLI",
|
|
58
|
+
secrets: Object.freeze([
|
|
59
|
+
{
|
|
60
|
+
name: "gemini_api_key",
|
|
61
|
+
whereToGet:
|
|
62
|
+
"Create an API key in Google AI Studio, in a project with its own budget: https://aistudio.google.com/apikey.",
|
|
63
|
+
},
|
|
64
|
+
]),
|
|
65
|
+
effortValues: Object.freeze(["low", "medium", "high", "xhigh", "max"]),
|
|
66
|
+
defaultModel: "gemini-3.1-pro",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/** The CLI's own tools the run's agent has: all local. */
|
|
70
|
+
export const TOOLS = Object.freeze([
|
|
71
|
+
"run_command",
|
|
72
|
+
"read_file",
|
|
73
|
+
"write_file",
|
|
74
|
+
"edit_file",
|
|
75
|
+
"manage_task",
|
|
76
|
+
"update_steps",
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
/** The agent the run is made as, which only the Launcher's folder holds. */
|
|
80
|
+
const AGENT = "agent-kit";
|
|
81
|
+
|
|
82
|
+
const AGENT_FILE = [
|
|
83
|
+
"---",
|
|
84
|
+
`name: ${AGENT}`,
|
|
85
|
+
"description: The agent of an Agent-kit run.",
|
|
86
|
+
"mainAgent: true",
|
|
87
|
+
"subagent: false",
|
|
88
|
+
"tools:",
|
|
89
|
+
...TOOLS.map((tool) => ` - ${tool}`),
|
|
90
|
+
"---",
|
|
91
|
+
"You are the agent of an Agent-kit run, working alone with no human to ask.",
|
|
92
|
+
"Do what the request says, with the tools you have, until it is done.",
|
|
93
|
+
"",
|
|
94
|
+
].join("\n");
|
|
95
|
+
|
|
96
|
+
/** The credential Antigravity CLI accepts, and the placeholder the model proxy swaps. */
|
|
97
|
+
const CREDENTIALS = {
|
|
98
|
+
"api-key": {
|
|
99
|
+
secret: "gemini_api_key",
|
|
100
|
+
env: "GEMINI_API_KEY",
|
|
101
|
+
placeholder: "agent-kit-deep-scan-placeholder",
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** The settings every run holds. */
|
|
106
|
+
const SETTINGS = {
|
|
107
|
+
modelProvider: "gemini",
|
|
108
|
+
enableTelemetry: false,
|
|
109
|
+
permissions: { deny: ["read_url(*)"] },
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const UPDATER_OFF = "AGY_CLI_DISABLE_AUTO_UPDATE=true";
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The launch plan for `request`.
|
|
116
|
+
* @param {object} [request] a Stage request, as the Claude Code adapter
|
|
117
|
+
* describes it. `maxTurns` is ignored: Antigravity CLI has no turn limit.
|
|
118
|
+
* The only `credentialKind` is `api-key`.
|
|
119
|
+
* @returns the nine-part launch plan, in the same shape as Claude Code's.
|
|
120
|
+
*/
|
|
121
|
+
export function antigravity({
|
|
122
|
+
model,
|
|
123
|
+
effort,
|
|
124
|
+
credentialKind = "api-key",
|
|
125
|
+
proxyUrl,
|
|
126
|
+
briefPath,
|
|
127
|
+
kitDir,
|
|
128
|
+
callerKey,
|
|
129
|
+
} = {}) {
|
|
130
|
+
if (!Object.hasOwn(CREDENTIALS, credentialKind)) {
|
|
131
|
+
throw new Error(`Antigravity CLI has no credential kind ${JSON.stringify(credentialKind)}`);
|
|
132
|
+
}
|
|
133
|
+
const accepted = structuredClone(CREDENTIALS);
|
|
134
|
+
const credential = accepted[credentialKind];
|
|
135
|
+
if (callerKey !== undefined) credential.placeholder = callerKey;
|
|
136
|
+
const home = kitDir ?? "/agent-kit";
|
|
137
|
+
const own = `${home}/agy`;
|
|
138
|
+
return {
|
|
139
|
+
identity: { name: "antigravity", displayName: "Antigravity CLI", version: VERSION, major: 1 },
|
|
140
|
+
installLayer: {
|
|
141
|
+
image: `${IMAGE}@${IMAGE_DIGEST}`,
|
|
142
|
+
env: [UPDATER_OFF],
|
|
143
|
+
run: ["ln -sf /opt/agent-kit/bin/agy /usr/local/bin/agy"],
|
|
144
|
+
},
|
|
145
|
+
modelRoute: { profile: "gemini-api" },
|
|
146
|
+
credentials: { accepted, scrub: ["GEMINI_API_KEY", "GOOGLE_API_KEY"] },
|
|
147
|
+
launch: {
|
|
148
|
+
argv: [
|
|
149
|
+
"agy",
|
|
150
|
+
`--gemini_dir=${own}`,
|
|
151
|
+
"--dangerously-skip-permissions",
|
|
152
|
+
// The brief is text to follow, never one of the CLI's own commands.
|
|
153
|
+
"--disable-slash-commands",
|
|
154
|
+
// Its answer goes to stdout, the transcript.
|
|
155
|
+
"--output-format",
|
|
156
|
+
"text",
|
|
157
|
+
"--agent",
|
|
158
|
+
AGENT,
|
|
159
|
+
...(model !== undefined ? ["--model", model] : []),
|
|
160
|
+
...(effort !== undefined ? ["--effort", effort] : []),
|
|
161
|
+
],
|
|
162
|
+
stdin: briefPath !== undefined ? { file: briefPath } : null,
|
|
163
|
+
files: [
|
|
164
|
+
{ path: `${own}/antigravity-cli/settings.json`, text: JSON.stringify(SETTINGS, null, 2) },
|
|
165
|
+
{ path: `${own}/config/agents/${AGENT}.md`, text: AGENT_FILE },
|
|
166
|
+
],
|
|
167
|
+
env: [
|
|
168
|
+
`${credential.env}=${credential.placeholder}`,
|
|
169
|
+
UPDATER_OFF,
|
|
170
|
+
...(proxyUrl !== undefined ? [`GOOGLE_GEMINI_BASE_URL=${proxyUrl}`] : []),
|
|
171
|
+
],
|
|
172
|
+
// The Launcher removes `checkoutConfig` from the copy before the launch.
|
|
173
|
+
removeCheckoutConfig: true,
|
|
174
|
+
},
|
|
175
|
+
checkoutConfig: [".agents", ".agent", "_agents", "_agent", ".gemini"],
|
|
176
|
+
instructionFiles: ["GEMINI.md", "AGENTS.md"],
|
|
177
|
+
stops: {
|
|
178
|
+
turnCap: null,
|
|
179
|
+
// What it says on its error output when it has no credential it reads.
|
|
180
|
+
credentialMissing: {
|
|
181
|
+
stderrPattern:
|
|
182
|
+
"^(error: )?authentication required|GEMINI_API_KEY environment variable is not set",
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
transcript: { path: `${home}/logs/agent.log` },
|
|
186
|
+
};
|
|
187
|
+
}
|
|
@@ -220,7 +220,14 @@ export function claudeCode({
|
|
|
220
220
|
// itself. Declared for the Launcher; the Deep scan keeps the config from
|
|
221
221
|
// loading by the flags above, and removes nothing from the copy.
|
|
222
222
|
checkoutConfig: [".claude/settings.json", ".claude/settings.local.json", ".mcp.json"],
|
|
223
|
-
instructionFiles: [
|
|
223
|
+
instructionFiles: [
|
|
224
|
+
"CLAUDE.md",
|
|
225
|
+
"CLAUDE.local.md",
|
|
226
|
+
".claude/rules",
|
|
227
|
+
".claude/skills",
|
|
228
|
+
".claude/agents",
|
|
229
|
+
".claude/commands",
|
|
230
|
+
],
|
|
224
231
|
// Print mode says "Error: Reached max turns" on its error output.
|
|
225
232
|
stops: { turnCap: { stderrPattern: "^Error: Reached max turns" } },
|
|
226
233
|
// Where the Launcher keeps Claude Code's own output.
|