@amykit/agent-kit 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -21
- package/dist/HarnessRelay.d.ts.map +1 -1
- package/dist/HarnessRelay.js +4 -0
- package/dist/HarnessRelay.js.map +1 -1
- package/dist/collection.d.ts +8 -33
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +9 -8
- package/dist/collection.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/steps.d.ts +46 -0
- package/dist/steps.d.ts.map +1 -0
- package/dist/steps.js +53 -0
- package/dist/steps.js.map +1 -0
- package/dist/tiers.d.ts +5 -16
- package/dist/tiers.d.ts.map +1 -1
- package/dist/tiers.js +6 -19
- package/dist/tiers.js.map +1 -1
- package/package.json +3 -3
- package/dist/HarnessAgent.d.ts +0 -76
- package/dist/HarnessAgent.d.ts.map +0 -1
- package/dist/HarnessAgent.js +0 -261
- package/dist/HarnessAgent.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
The part of "being an agent" that is the same whichever harness answers.
|
|
4
4
|
|
|
5
|
-
Not a plugin. A library the harness plugins share, so that
|
|
6
|
-
means teaching amy a **command line**,
|
|
5
|
+
Not a plugin. A library the harness plugins and the workflows share, so that
|
|
6
|
+
adding a harness means teaching amy a **command line**, and writing a step
|
|
7
|
+
means writing a **prompt**.
|
|
7
8
|
|
|
8
9
|
## What is here
|
|
9
10
|
|
|
@@ -12,18 +13,40 @@ means teaching amy a **command line**, not re-teaching it the job.
|
|
|
12
13
|
```ts
|
|
13
14
|
interface Harness {
|
|
14
15
|
readonly name: string;
|
|
15
|
-
ask(prompt: string, cwd: string): Promise<HarnessReply>;
|
|
16
|
+
ask(prompt: string, cwd: string, context?: AskContext): Promise<HarnessReply>;
|
|
16
17
|
}
|
|
17
18
|
```
|
|
18
19
|
|
|
19
|
-
One method
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
One method, and the `agent` port is the same one method. A harness answers in
|
|
21
|
+
the directory it is handed and never touches git: when work is committed and
|
|
22
|
+
pushed is the workflow's decision
|
|
23
|
+
([an agent only answers](../../docs/design/an-agent-only-answers.md)).
|
|
23
24
|
|
|
24
|
-
**`
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
**`implementStep`** and **`judgeStep`** are what a workflow builds a step
|
|
26
|
+
with, on any agent:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// Ask for a change; commit it through the function you pass.
|
|
30
|
+
const { value } = await implementStep(agent, {
|
|
31
|
+
prompt, cwd, context: { workId, step: "implement" },
|
|
32
|
+
commit: () => git.commitAndPush(repo, branch, message, workId),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Ask a question whose answer is one JSON object, and read it.
|
|
36
|
+
const { value } = await judgeStep(agent, {
|
|
37
|
+
prompt, cwd, context: { workId, step: "triage" },
|
|
38
|
+
read: (answer) => readTriage(answer, at),
|
|
39
|
+
fallback: unreadTriage(at),
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**`HarnessRelay`** is one harness made of several: a skill ladder for who
|
|
44
|
+
should do a step and a harness ladder for what to do when the one asked ran
|
|
45
|
+
out of quota or was not up to it, both keyed by the `step` in the context.
|
|
46
|
+
|
|
47
|
+
**`contributeTiers`** adds one `NamedHarness` per model tier to the collection
|
|
48
|
+
the relay reads. The naming lives here rather than in each plugin because it
|
|
49
|
+
is a contract: `claude:opus` is what an operator writes in a ladder, so three
|
|
27
50
|
plugins inventing three conventions would make the config unlearnable.
|
|
28
51
|
|
|
29
52
|
## Why a harness contributes instead of mounting
|
|
@@ -32,18 +55,19 @@ A port has exactly one owner. Three harnesses that each mounted `agent` would
|
|
|
32
55
|
refuse to mount together, which is the correct behaviour for a port and the
|
|
33
56
|
wrong outcome here.
|
|
34
57
|
|
|
35
|
-
So a harness contributes a `
|
|
36
|
-
only thing that mounts the port. A single-harness install goes through the
|
|
58
|
+
So a harness contributes a `NamedHarness` and `@amykit/plugin-agent-relay` is
|
|
59
|
+
the only thing that mounts the port. A single-harness install goes through the
|
|
37
60
|
relay too, with a ladder one rung long and nothing special about that case.
|
|
38
61
|
|
|
39
|
-
`harness` and `model` are declared on each
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## Two decisions inherited by every harness
|
|
62
|
+
`harness` and `model` are declared on each rung rather than discovered from a
|
|
63
|
+
result, because the relay has to decide **where to go next** before it runs
|
|
64
|
+
anything.
|
|
44
65
|
|
|
45
|
-
|
|
46
|
-
Reporting success would send an empty pull request to a reviewer.
|
|
66
|
+
## A decision every step inherits
|
|
47
67
|
|
|
48
|
-
**
|
|
49
|
-
|
|
68
|
+
**A clean exit that changed nothing is a failure.** `implementStep` commits
|
|
69
|
+
as the context's `verify`, which the relay calls after each rung that
|
|
70
|
+
completed, so a rung that changed no file hands the step to the stronger model
|
|
71
|
+
or the next skill, and the attempt that changed nothing on every rung reports
|
|
72
|
+
`unchanged` progress. Reporting success would send an empty pull request to a
|
|
73
|
+
reviewer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HarnessRelay.d.ts","sourceRoot":"","sources":["../src/HarnessRelay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAkD,MAAM,cAAc,CAAC;AAE1F,OAAO,EAAE,OAAO,EAAuB,MAAM,cAAc,CAAC;AAE5D,mEAAmE;AACnE,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;AAEvE,MAAM,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ACG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAwBvF;;;;;;OAMG;YACW,KAAK;CAkCpB"}
|
package/dist/HarnessRelay.js
CHANGED
|
@@ -68,6 +68,10 @@ export class HarnessRelay {
|
|
|
68
68
|
while (index < ladder.length) {
|
|
69
69
|
const rung = ladder[index];
|
|
70
70
|
last = await rung.cli.ask(asked(prompt, skill, handoff), cwd, context);
|
|
71
|
+
// The caller says whether a completed run holds while there is still a
|
|
72
|
+
// rung to climb to, rather than after the ladder has stopped.
|
|
73
|
+
if (last.run.outcome === "completed" && context.verify)
|
|
74
|
+
last = await context.verify(last);
|
|
71
75
|
const next = nextRung(ladder, index, last.run.outcome);
|
|
72
76
|
if (next === null)
|
|
73
77
|
return last;
|
package/dist/HarnessRelay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HarnessRelay.js","sourceRoot":"","sources":["../src/HarnessRelay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAW,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAS5D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,YAAY;IAIJ;IACA;IAJV,IAAI,GAAG,OAAO,CAAC;IAExB,YACmB,OAA8B,EAC9B,OAAyB,EAAE;QAD3B,YAAO,GAAP,OAAO,CAAuB;QAC9B,SAAI,GAAJ,IAAI,CAAuB;QAE5C,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,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AI,KAAK,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC;AAED,kEAAkE;AAClE,SAAS,IAAI,CAAC,OAAmB;IAC/B,OAAO,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC;AAC/B,CAAC"}
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,44 +1,19 @@
|
|
|
1
1
|
import { Harness } from "@amykit/core";
|
|
2
|
-
import { Agent } from "@amykit/core";
|
|
3
2
|
import { Rung } from "./ladder.js";
|
|
4
|
-
/** The collection every harness plugin adds its ticket-shaped agents to. */
|
|
5
|
-
export declare const AGENT_COLLECTION = "agent";
|
|
6
3
|
/**
|
|
7
|
-
* The collection every harness plugin adds
|
|
4
|
+
* The collection every harness plugin adds its CLI to, one per model tier.
|
|
8
5
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* ladder as the first workflow's do.
|
|
14
|
-
*/
|
|
15
|
-
export declare const HARNESS_COLLECTION = "harness";
|
|
16
|
-
/**
|
|
17
|
-
* One harness at one model tier, ready to be asked.
|
|
18
|
-
*
|
|
19
|
-
* A harness plugin contributes one of these per model it was configured with,
|
|
20
|
-
* rather than mounting the `agent` port. Only one plugin can own a port, and
|
|
21
|
-
* three harnesses that each want to be *the* agent would simply refuse to
|
|
22
|
-
* mount together. Contributing instead lets a relay compose them, and lets a
|
|
23
|
-
* single-harness install work through the same relay with nothing special
|
|
24
|
-
* about it.
|
|
6
|
+
* A harness plugin contributes rather than mounting the `agent` port: only
|
|
7
|
+
* one plugin can own a port, and three harnesses that each wanted to be *the*
|
|
8
|
+
* agent would refuse to mount together. The relay composes what is
|
|
9
|
+
* contributed, and a single-harness install goes through the same relay.
|
|
25
10
|
*
|
|
26
11
|
* `harness` and `model` are declared rather than discovered, because the
|
|
27
12
|
* relay has to decide **where to go next** before running anything: a quota
|
|
28
|
-
* problem wants a different harness and a failure wants a stronger model
|
|
29
|
-
* both are choices made in advance.
|
|
13
|
+
* problem wants a different harness and a failure wants a stronger model.
|
|
30
14
|
*/
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The same harness and model, with a named skill doing the step.
|
|
35
|
-
*
|
|
36
|
-
* A second agent rather than an argument on the port, because which skill
|
|
37
|
-
* answers is decided before the call, exactly like which harness does.
|
|
38
|
-
*/
|
|
39
|
-
readonly using: (skill: string) => Agent;
|
|
40
|
-
}
|
|
41
|
-
/** The same rung of the same ladder, with no workflow's prompts on it. */
|
|
15
|
+
export declare const HARNESS_COLLECTION = "harness";
|
|
16
|
+
/** One rung of the ladder: a harness at one model, with nobody's prompts on it. */
|
|
42
17
|
export interface NamedHarness extends Rung {
|
|
43
18
|
readonly cli: Harness;
|
|
44
19
|
}
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C,mFAAmF;AACnF,MAAM,WAAW,YAAa,SAAQ,IAAI;IACxC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;CACvB"}
|
package/dist/collection.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
/** The collection every harness plugin adds its ticket-shaped agents to. */
|
|
2
|
-
export const AGENT_COLLECTION = "agent";
|
|
3
1
|
/**
|
|
4
|
-
* The collection every harness plugin adds
|
|
2
|
+
* The collection every harness plugin adds its CLI to, one per model tier.
|
|
5
3
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* A harness plugin contributes rather than mounting the `agent` port: only
|
|
5
|
+
* one plugin can own a port, and three harnesses that each wanted to be *the*
|
|
6
|
+
* agent would refuse to mount together. The relay composes what is
|
|
7
|
+
* contributed, and a single-harness install goes through the same relay.
|
|
8
|
+
*
|
|
9
|
+
* `harness` and `model` are declared rather than discovered, because the
|
|
10
|
+
* relay has to decide **where to go next** before running anything: a quota
|
|
11
|
+
* problem wants a different harness and a failure wants a stronger model.
|
|
11
12
|
*/
|
|
12
13
|
export const HARNESS_COLLECTION = "harness";
|
|
13
14
|
//# sourceMappingURL=collection.js.map
|
package/dist/collection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { HarnessAgent } from "./HarnessAgent.js";
|
|
2
|
-
export type { HarnessAgentConfig } from "./HarnessAgent.js";
|
|
3
1
|
export { HarnessRelay } from "./HarnessRelay.js";
|
|
4
2
|
export type { HarnessRelayDeps, SkillLadders } from "./HarnessRelay.js";
|
|
5
3
|
export { extractJson } from "./json.js";
|
|
6
|
-
export {
|
|
7
|
-
export type {
|
|
4
|
+
export { HARNESS_COLLECTION } from "./collection.js";
|
|
5
|
+
export type { NamedHarness } from "./collection.js";
|
|
6
|
+
export { implementStep, judgeStep } from "./steps.js";
|
|
7
|
+
export type { ImplementInput, JudgeInput, StepInput } from "./steps.js";
|
|
8
8
|
export { handoffNote, recordHandoff, recordSkillHandoff } from "./handoff.js";
|
|
9
9
|
export type { HandoffLog } from "./handoff.js";
|
|
10
10
|
export { nextRung } from "./ladder.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9E,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9D,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { HarnessAgent } from "./HarnessAgent.js";
|
|
2
1
|
export { HarnessRelay } from "./HarnessRelay.js";
|
|
3
2
|
export { extractJson } from "./json.js";
|
|
4
|
-
export {
|
|
3
|
+
export { HARNESS_COLLECTION } from "./collection.js";
|
|
4
|
+
export { implementStep, judgeStep } from "./steps.js";
|
|
5
5
|
export { handoffNote, recordHandoff, recordSkillHandoff } from "./handoff.js";
|
|
6
6
|
export { nextRung } from "./ladder.js";
|
|
7
7
|
export { everyRung, oneLadder, rungsFor } from "./ladders.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/steps.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Agent, AgentResult, AskContext, AttemptOutcome } from "@amykit/core";
|
|
2
|
+
/** One question to the agent, in the directory the work is in. */
|
|
3
|
+
export interface StepInput {
|
|
4
|
+
prompt: string;
|
|
5
|
+
cwd: string;
|
|
6
|
+
context?: AskContext;
|
|
7
|
+
}
|
|
8
|
+
export interface ImplementInput extends StepInput {
|
|
9
|
+
/**
|
|
10
|
+
* Commits what the agent left behind, and says whether there was anything.
|
|
11
|
+
*
|
|
12
|
+
* The caller's, because when work is committed and when it reaches the
|
|
13
|
+
* remote are the workflow's decisions: one pushes after every attempt,
|
|
14
|
+
* another once per cycle. This helper never names git.
|
|
15
|
+
*/
|
|
16
|
+
commit: () => Promise<boolean>;
|
|
17
|
+
/** The progress key a retry is judged by. */
|
|
18
|
+
key?: string;
|
|
19
|
+
now?: () => Date;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Asks for a change, commits it through the caller, and says whether it moved.
|
|
23
|
+
*
|
|
24
|
+
* The commit runs as the context's `verify`, so a relay commits after each
|
|
25
|
+
* rung that completed and climbs on one that changed nothing, exactly as it
|
|
26
|
+
* climbs on a failure. Over an agent that never calls `verify` the commit
|
|
27
|
+
* runs once the answer is back. A run that completed and changed no file is
|
|
28
|
+
* a failure with `unchanged` progress, so a retry policy can tell an attempt
|
|
29
|
+
* that added nothing from one that did. A run that did not complete is
|
|
30
|
+
* returned rather than thrown, with its account.
|
|
31
|
+
*/
|
|
32
|
+
export declare function implementStep(agent: Agent, input: ImplementInput): Promise<AgentResult<AttemptOutcome>>;
|
|
33
|
+
export interface JudgeInput<T> extends StepInput {
|
|
34
|
+
/** Turns the JSON object the prompt asked for into the step's answer. */
|
|
35
|
+
read: (answer: unknown) => T;
|
|
36
|
+
/** The answer when the run did not complete, so there is nothing to read. */
|
|
37
|
+
fallback: T;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Asks a question whose answer is one JSON object, and reads it.
|
|
41
|
+
*
|
|
42
|
+
* A run that did not complete yields the caller's fallback with the run's
|
|
43
|
+
* account, for the same reason `implementStep` returns rather than throws.
|
|
44
|
+
*/
|
|
45
|
+
export declare function judgeStep<T>(agent: Agent, input: JudgeInput<T>): Promise<AgentResult<T>>;
|
|
46
|
+
//# sourceMappingURL=steps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAgB,MAAM,cAAc,CAAC;AAG5F,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAID;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CA4B7G;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,CAAE,SAAQ,SAAS;IAC9C,yEAAyE;IACzE,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC;IAC7B,6EAA6E;IAC7E,QAAQ,EAAE,CAAC,CAAC;CACb;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAI9F"}
|
package/dist/steps.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { extractJson } from "./json.js";
|
|
2
|
+
const NO_CHANGE = "the agent finished without changing any file";
|
|
3
|
+
/**
|
|
4
|
+
* Asks for a change, commits it through the caller, and says whether it moved.
|
|
5
|
+
*
|
|
6
|
+
* The commit runs as the context's `verify`, so a relay commits after each
|
|
7
|
+
* rung that completed and climbs on one that changed nothing, exactly as it
|
|
8
|
+
* climbs on a failure. Over an agent that never calls `verify` the commit
|
|
9
|
+
* runs once the answer is back. A run that completed and changed no file is
|
|
10
|
+
* a failure with `unchanged` progress, so a retry policy can tell an attempt
|
|
11
|
+
* that added nothing from one that did. A run that did not complete is
|
|
12
|
+
* returned rather than thrown, with its account.
|
|
13
|
+
*/
|
|
14
|
+
export async function implementStep(agent, input) {
|
|
15
|
+
// The last run `verify` judged, and whether it changed anything. Only the
|
|
16
|
+
// run that comes back is the attempt's, so an earlier rung's verdict never
|
|
17
|
+
// speaks for a later rung that failed for another reason.
|
|
18
|
+
let judged;
|
|
19
|
+
const verify = async (reply) => {
|
|
20
|
+
const changed = await input.commit();
|
|
21
|
+
const verdict = changed ? reply : { ...reply, run: { ...reply.run, outcome: "failed", output: `${NO_CHANGE}\n\n${reply.run.output}` } };
|
|
22
|
+
judged = { reply: verdict, changed };
|
|
23
|
+
return verdict;
|
|
24
|
+
};
|
|
25
|
+
let reply = await agent.ask(input.prompt, input.cwd, { ...input.context, verify });
|
|
26
|
+
if (reply.run.outcome === "completed" && judged?.reply !== reply)
|
|
27
|
+
reply = await verify(reply);
|
|
28
|
+
const at = (input.now ?? (() => new Date()))().toISOString();
|
|
29
|
+
const key = input.key ?? "implementation";
|
|
30
|
+
if (judged?.reply === reply && !judged.changed) {
|
|
31
|
+
return {
|
|
32
|
+
value: { ok: false, output: reply.run.output, at, progress: { kind: "unchanged", key, detail: NO_CHANGE } },
|
|
33
|
+
run: reply.run,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (reply.run.outcome !== "completed") {
|
|
37
|
+
return { value: { ok: false, output: reply.run.output, at }, run: reply.run };
|
|
38
|
+
}
|
|
39
|
+
return { value: { ok: true, output: reply.run.output, at, progress: { kind: "advanced", key } }, run: reply.run };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Asks a question whose answer is one JSON object, and reads it.
|
|
43
|
+
*
|
|
44
|
+
* A run that did not complete yields the caller's fallback with the run's
|
|
45
|
+
* account, for the same reason `implementStep` returns rather than throws.
|
|
46
|
+
*/
|
|
47
|
+
export async function judgeStep(agent, input) {
|
|
48
|
+
const reply = await agent.ask(input.prompt, input.cwd, input.context);
|
|
49
|
+
if (reply.run.outcome !== "completed")
|
|
50
|
+
return { value: input.fallback, run: reply.run };
|
|
51
|
+
return { value: input.read(extractJson(reply.text)), run: reply.run };
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.js","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAuBxC,MAAM,SAAS,GAAG,8CAA8C,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAY,EAAE,KAAqB;IACrE,0EAA0E;IAC1E,2EAA2E;IAC3E,0DAA0D;IAC1D,IAAI,MAA6D,CAAC;IAClE,MAAM,MAAM,GAAG,KAAK,EAAE,KAAmB,EAAyB,EAAE;QAClE,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,QAAiB,EAAE,MAAM,EAAE,GAAG,SAAS,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC;QACjJ,MAAM,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QACrC,OAAO,OA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AM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;AACpH,CAAC;AASD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,KAAY,EAAE,KAAoB;IACnE,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACtE,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,KAAK,WAAW;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IACxF,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAU,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;AACjF,CAAC"}
|
package/dist/tiers.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { HarnessAgentConfig } from "./HarnessAgent.js";
|
|
1
|
+
import { Harness, Registry } from "@amykit/core";
|
|
2
|
+
import { NamedHarness } from "./collection.js";
|
|
4
3
|
export interface TierOptions {
|
|
5
4
|
/** The harness name, which is also the axis the relay swaps along. */
|
|
6
5
|
harness: string;
|
|
@@ -12,25 +11,15 @@ export interface TierOptions {
|
|
|
12
11
|
make: (model: string) => Harness;
|
|
13
12
|
/** See `Rung.pricesItsOwnRuns`. Declared once per harness, not per tier. */
|
|
14
13
|
pricesItsOwnRuns?: boolean;
|
|
15
|
-
git: Git;
|
|
16
|
-
agent?: HarnessAgentConfig;
|
|
17
14
|
}
|
|
18
15
|
/**
|
|
19
|
-
* Adds one
|
|
20
|
-
* the relay reads.
|
|
21
|
-
*
|
|
22
|
-
* Both, because they are used at different levels. The agent already knows
|
|
23
|
-
* what a ticket is; the harness knows nothing, and is what a second workflow
|
|
24
|
-
* asks its own questions through. Contributing only the first is what made
|
|
25
|
-
* `@amykit/plugin-claude` a plugin exactly one workflow could use.
|
|
16
|
+
* Adds one harness per model tier to the collection the relay reads.
|
|
26
17
|
*
|
|
27
18
|
* The naming lives here rather than in each harness plugin because it is a
|
|
28
19
|
* contract: the ladder in a config file refers to these names, so three
|
|
29
|
-
* plugins inventing three conventions would make the config unlearnable.
|
|
30
|
-
* name covers both collections, so a ladder means the same thing whichever
|
|
31
|
-
* level reads it.
|
|
20
|
+
* plugins inventing three conventions would make the config unlearnable.
|
|
32
21
|
*/
|
|
33
|
-
export declare function contributeTiers(registry: Registry, opts: TierOptions):
|
|
22
|
+
export declare function contributeTiers(registry: Registry, opts: TierOptions): NamedHarness[];
|
|
34
23
|
/** `claude:opus`, or plain `claude` when no model was named. */
|
|
35
24
|
export declare function tierName(harness: string, model: string): string;
|
|
36
25
|
//# sourceMappingURL=tiers.d.ts.map
|
package/dist/tiers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiers.d.ts","sourceRoot":"","sources":["../src/tiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tiers.d.ts","sourceRoot":"","sources":["../src/tiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAsB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACjC,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CA0BrF;AAED,gEAAgE;AAChE,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
package/dist/tiers.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HarnessAgent } from "./HarnessAgent.js";
|
|
1
|
+
import { HARNESS_COLLECTION } from "./collection.js";
|
|
3
2
|
/**
|
|
4
|
-
* Adds one
|
|
5
|
-
* the relay reads.
|
|
6
|
-
*
|
|
7
|
-
* Both, because they are used at different levels. The agent already knows
|
|
8
|
-
* what a ticket is; the harness knows nothing, and is what a second workflow
|
|
9
|
-
* asks its own questions through. Contributing only the first is what made
|
|
10
|
-
* `@amykit/plugin-claude` a plugin exactly one workflow could use.
|
|
3
|
+
* Adds one harness per model tier to the collection the relay reads.
|
|
11
4
|
*
|
|
12
5
|
* The naming lives here rather than in each harness plugin because it is a
|
|
13
6
|
* contract: the ladder in a config file refers to these names, so three
|
|
14
|
-
* plugins inventing three conventions would make the config unlearnable.
|
|
15
|
-
* name covers both collections, so a ladder means the same thing whichever
|
|
16
|
-
* level reads it.
|
|
7
|
+
* plugins inventing three conventions would make the config unlearnable.
|
|
17
8
|
*/
|
|
18
9
|
export function contributeTiers(registry, opts) {
|
|
19
10
|
// The union the config sent can name a model twice — `ladder` and a step's
|
|
@@ -32,18 +23,14 @@ export function contributeTiers(registry, opts) {
|
|
|
32
23
|
if (models.length === 0)
|
|
33
24
|
models.push("");
|
|
34
25
|
return models.map((model) => {
|
|
35
|
-
const
|
|
36
|
-
const agent = (skill) => new HarnessAgent(cli, opts.git, { ...(opts.agent ?? {}), skill });
|
|
37
|
-
const rung = {
|
|
26
|
+
const named = {
|
|
38
27
|
name: tierName(opts.harness, model),
|
|
39
28
|
harness: opts.harness,
|
|
40
29
|
model,
|
|
41
30
|
pricesItsOwnRuns: opts.pricesItsOwnRuns ?? false,
|
|
31
|
+
cli: opts.make(model),
|
|
42
32
|
};
|
|
43
|
-
|
|
44
|
-
const bare = { ...rung, cli };
|
|
45
|
-
registry.contribute(AGENT_COLLECTION, named.name, named);
|
|
46
|
-
registry.contribute(HARNESS_COLLECTION, bare.name, bare);
|
|
33
|
+
registry.contribute(HARNESS_COLLECTION, named.name, named);
|
|
47
34
|
return named;
|
|
48
35
|
});
|
|
49
36
|
}
|
package/dist/tiers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiers.js","sourceRoot":"","sources":["../src/tiers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tiers.js","sourceRoot":"","sources":["../src/tiers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,iBAAiB,CAAC;AAenE;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,QAAkB,EAAE,IAAiB;IACnE,2EAA2E;IAC3E,2EAA2E;IAC3E,4EAA4E;IAC5E,0EAA0E;IAC1E,qEAAqE;IACrE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,GAAG,KAAK,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEzC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,MAAM,KAAK,GAAiB;YAC1B,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;YACnC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK;YACL,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,KAAK;YAChD,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;SACtB,CAAC;QACF,QAAQ,CAAC,UAAU,CAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,KAAa;IACrD,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amykit/agent-kit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "What every agent does the same way: the
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "What every agent does the same way: the ladders, the handoffs, and steps built on ask that never touch git.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Nicolas Melo",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@amykit/core": "^0.
|
|
31
|
+
"@amykit/core": "^0.6.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@amykit/test-fixtures": "^0.1.0"
|
package/dist/HarnessAgent.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AgentResult, Git, Harness, ReviewThread } from "@amykit/core";
|
|
2
|
-
import { Agent, AttemptOutcome, ThreadVerdict, Ticket, TriageOutcome } from "@amykit/core";
|
|
3
|
-
export interface HarnessAgentConfig {
|
|
4
|
-
/**
|
|
5
|
-
* Extra guidance to append when answering a particular reviewer, keyed by
|
|
6
|
-
* their host login. A reviewer with known habits is cheaper to satisfy on
|
|
7
|
-
* the first pass than on the third.
|
|
8
|
-
*/
|
|
9
|
-
reviewerHints?: Readonly<Record<string, string>>;
|
|
10
|
-
/**
|
|
11
|
-
* A skill to hand the step to, instead of amy asking in its own words.
|
|
12
|
-
*
|
|
13
|
-
* The step's own instructions still follow the invocation, because the
|
|
14
|
-
* answer has to arrive in the same shape whoever does the work.
|
|
15
|
-
*/
|
|
16
|
-
skill?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* An agent for a ticket, over any harness.
|
|
20
|
-
*
|
|
21
|
-
* Every call runs in the ticket's own checkout, on the branch the tracker
|
|
22
|
-
* named, and anything the harness leaves behind is committed and pushed. The
|
|
23
|
-
* machine's notion of "implemented" means the work is on the remote, because
|
|
24
|
-
* that is what a pull request can be opened against.
|
|
25
|
-
*/
|
|
26
|
-
export declare class HarnessAgent implements Agent {
|
|
27
|
-
private readonly harness;
|
|
28
|
-
private readonly git;
|
|
29
|
-
private readonly config;
|
|
30
|
-
constructor(harness: Harness, git: Git, config?: HarnessAgentConfig);
|
|
31
|
-
triage(ticket: Ticket, conversation?: readonly string[]): Promise<AgentResult<TriageOutcome>>;
|
|
32
|
-
implement(ticket: Ticket, retryContext?: string, conversation?: readonly string[]): Promise<AgentResult<AttemptOutcome>>;
|
|
33
|
-
addressThreads(ticket: Ticket, threads: readonly ReviewThread[], from: "automated" | "human"): Promise<AgentResult<ThreadVerdict[]>>;
|
|
34
|
-
private threadPrompt;
|
|
35
|
-
private ask;
|
|
36
|
-
/**
|
|
37
|
-
* The current brief the ticket's work belongs to, when it has one.
|
|
38
|
-
*
|
|
39
|
-
* Rendered rather than referenced: a brief is the revisable statement of
|
|
40
|
-
* the feature, and what a step must judge is what it says *now*, not a link
|
|
41
|
-
* that says "see elsewhere". A ticket with no brief carries none, and every
|
|
42
|
-
* prompt built from it is unchanged — that is the compatibility rule.
|
|
43
|
-
*/
|
|
44
|
-
private briefLines;
|
|
45
|
-
/**
|
|
46
|
-
* The ticket's body, in the prompt, where the work can be judged by it.
|
|
47
|
-
*
|
|
48
|
-
* A ticket with no body says so rather than looking truncated: the absent
|
|
49
|
-
* line is the difference between an agent that asks for the description
|
|
50
|
-
* and one that guesses there was nothing to know.
|
|
51
|
-
*/
|
|
52
|
-
private bodyLines;
|
|
53
|
-
/**
|
|
54
|
-
* What the team says this ticket *is*, beside the body it says it with.
|
|
55
|
-
*
|
|
56
|
-
* A label is the tracker's fact, not the caller's — an epic labelled
|
|
57
|
-
* `Feature` is not work to implement, and its sub-issues are. Naming them
|
|
58
|
-
* here is what lets a step that judges the ticket see the label instead of
|
|
59
|
-
* guessing it; a ticket with none says nothing, because most carry none.
|
|
60
|
-
*/
|
|
61
|
-
private labelLines;
|
|
62
|
-
/**
|
|
63
|
-
* The conversation on the ticket, split by who wrote it.
|
|
64
|
-
*
|
|
65
|
-
* What amy asked is labelled as its own, so the agent reads its words as a
|
|
66
|
-
* question already put rather than as new information, and does not ask it
|
|
67
|
-
* twice. An answer from somebody is the answer to an earlier question, and
|
|
68
|
-
* carries their name, because an unattributed sentence is not a
|
|
69
|
-
* conversation. Nothing here is no conversation at all: most tickets have
|
|
70
|
-
* never been asked anything.
|
|
71
|
-
*/
|
|
72
|
-
private conversationLines;
|
|
73
|
-
/** The prompt, addressed to a skill when one was named. */
|
|
74
|
-
private invoke;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=HarnessAgent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HarnessAgent.d.ts","sourceRoot":"","sources":["../src/HarnessAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAgB,YAAY,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C,MAAM;CAGf"}
|
package/dist/HarnessAgent.js
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { extractJson } from "./json.js";
|
|
2
|
-
/**
|
|
3
|
-
* An agent for a ticket, over any harness.
|
|
4
|
-
*
|
|
5
|
-
* Every call runs in the ticket's own checkout, on the branch the tracker
|
|
6
|
-
* named, and anything the harness leaves behind is committed and pushed. The
|
|
7
|
-
* machine's notion of "implemented" means the work is on the remote, because
|
|
8
|
-
* that is what a pull request can be opened against.
|
|
9
|
-
*/
|
|
10
|
-
export class HarnessAgent {
|
|
11
|
-
harness;
|
|
12
|
-
git;
|
|
13
|
-
config;
|
|
14
|
-
constructor(harness, git, config = {}) {
|
|
15
|
-
this.harness = harness;
|
|
16
|
-
this.git = git;
|
|
17
|
-
this.config = config;
|
|
18
|
-
}
|
|
19
|
-
async triage(ticket, conversation) {
|
|
20
|
-
const reply = await this.ask(ticket, [
|
|
21
|
-
`You are deciding whether a ticket can be implemented as written.`,
|
|
22
|
-
``,
|
|
23
|
-
`Ticket ${ticket.id}: ${ticket.title}`,
|
|
24
|
-
`Tracker: ${ticket.url}`,
|
|
25
|
-
...this.briefLines(ticket),
|
|
26
|
-
...this.bodyLines(ticket),
|
|
27
|
-
...this.labelLines(ticket),
|
|
28
|
-
...this.conversationLines(conversation),
|
|
29
|
-
`Read enough of this repository to judge it. Answer with a`,
|
|
30
|
-
`single JSON object and nothing else:`,
|
|
31
|
-
``,
|
|
32
|
-
`{"clear": true}`,
|
|
33
|
-
``,
|
|
34
|
-
`if you could start implementing right now, or:`,
|
|
35
|
-
``,
|
|
36
|
-
`{"clear": false, "questions": ["...", "..."]}`,
|
|
37
|
-
``,
|
|
38
|
-
`listing only questions that genuinely block the work. A question you`,
|
|
39
|
-
`could answer yourself by reading the code is not a blocking question.`,
|
|
40
|
-
`A question already answered in the conversation above is not a`,
|
|
41
|
-
`question: an answer to an earlier question is part of the ticket.`,
|
|
42
|
-
].join("\n"));
|
|
43
|
-
// A run that did not complete has no answer to parse, and this returns
|
|
44
|
-
// rather than throwing so that a relay above can read the cause and try
|
|
45
|
-
// another harness. Throwing here would skip the whole escalation exactly
|
|
46
|
-
// when it is needed. Nothing consumes this value: an agent action whose
|
|
47
|
-
// run did not complete is failed by the engine.
|
|
48
|
-
if (reply.run.outcome !== "completed") {
|
|
49
|
-
return {
|
|
50
|
-
value: {
|
|
51
|
-
clear: false,
|
|
52
|
-
questions: [],
|
|
53
|
-
askedQuestions: [],
|
|
54
|
-
at: new Date().toISOString(),
|
|
55
|
-
},
|
|
56
|
-
run: reply.run,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
const answer = extractJson(reply.text);
|
|
60
|
-
return {
|
|
61
|
-
value: {
|
|
62
|
-
clear: answer.clear,
|
|
63
|
-
questions: answer.clear ? [] : (answer.questions ?? []),
|
|
64
|
-
// Recorded so the next look can tell its own words from new
|
|
65
|
-
// information, and so a question that was answered is never asked
|
|
66
|
-
// again.
|
|
67
|
-
askedQuestions: answer.clear ? [] : (answer.questions ?? []),
|
|
68
|
-
at: new Date().toISOString(),
|
|
69
|
-
},
|
|
70
|
-
run: reply.run,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
async implement(ticket, retryContext, conversation) {
|
|
74
|
-
await this.git.prepareBranch(ticket.repo, ticket.branchName, ticket.id);
|
|
75
|
-
const reply = await this.ask(ticket, [
|
|
76
|
-
`Implement this ticket in the current repository.`,
|
|
77
|
-
``,
|
|
78
|
-
`Ticket ${ticket.id}: ${ticket.title}`,
|
|
79
|
-
`Tracker: ${ticket.url}`,
|
|
80
|
-
...this.briefLines(ticket),
|
|
81
|
-
...this.bodyLines(ticket),
|
|
82
|
-
...this.labelLines(ticket),
|
|
83
|
-
...this.conversationLines(conversation),
|
|
84
|
-
...(retryContext
|
|
85
|
-
? [
|
|
86
|
-
``,
|
|
87
|
-
`A previous attempt did not hold. This is what went wrong, verbatim:`,
|
|
88
|
-
``,
|
|
89
|
-
retryContext,
|
|
90
|
-
``,
|
|
91
|
-
`Fix the underlying cause. Do not discard work that was already correct.`,
|
|
92
|
-
]
|
|
93
|
-
: []),
|
|
94
|
-
``,
|
|
95
|
-
`Follow the conventions already in this repository. Do not commit: that is`,
|
|
96
|
-
`handled for you.`,
|
|
97
|
-
].join("\n"));
|
|
98
|
-
const at = new Date().toISOString();
|
|
99
|
-
if (reply.run.outcome !== "completed") {
|
|
100
|
-
return { value: { ok: false, output: reply.run.output, at }, run: reply.run };
|
|
101
|
-
}
|
|
102
|
-
const pushed = await this.git.commitAndPush(ticket.repo, ticket.branchName, `${ticket.id}: ${ticket.title}`, ticket.id);
|
|
103
|
-
if (!pushed) {
|
|
104
|
-
// The harness exited cleanly and changed nothing. For a ticket that
|
|
105
|
-
// asked for work, that is a failure worth reporting rather than a
|
|
106
|
-
// success, and the account has to agree so a relay can act on it.
|
|
107
|
-
return {
|
|
108
|
-
value: {
|
|
109
|
-
ok: false,
|
|
110
|
-
output: `the agent finished without changing any file\n\n${reply.run.output}`,
|
|
111
|
-
at,
|
|
112
|
-
},
|
|
113
|
-
run: { ...reply.run, outcome: "failed" },
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
return { value: { ok: true, output: reply.run.output, at }, run: reply.run };
|
|
117
|
-
}
|
|
118
|
-
async addressThreads(ticket, threads, from) {
|
|
119
|
-
await this.git.prepareBranch(ticket.repo, ticket.branchName, ticket.id);
|
|
120
|
-
const reply = await this.ask(ticket, this.threadPrompt(ticket, threads, from));
|
|
121
|
-
// Returned rather than thrown, for the same reason as in `triage`: the
|
|
122
|
-
// relay above decides whether another harness gets a turn, and it needs
|
|
123
|
-
// the run to decide. The engine is what fails the action once every
|
|
124
|
-
// harness has been tried, so an empty list is never mistaken for "no
|
|
125
|
-
// comment needed answering".
|
|
126
|
-
if (reply.run.outcome !== "completed") {
|
|
127
|
-
return { value: [], run: reply.run };
|
|
128
|
-
}
|
|
129
|
-
const answer = extractJson(reply.text);
|
|
130
|
-
const verdicts = threads.map((thread) => {
|
|
131
|
-
const given = answer.verdicts?.find((v) => v.threadId === thread.id);
|
|
132
|
-
return {
|
|
133
|
-
threadId: thread.id,
|
|
134
|
-
// A comment the agent did not answer is not silently dropped. It is
|
|
135
|
-
// pushed to the owner, because an unanswered review comment is the
|
|
136
|
-
// one thing that must never disappear.
|
|
137
|
-
verdict: given?.verdict ?? "disagreed",
|
|
138
|
-
note: given?.note ?? "the agent did not answer this comment",
|
|
139
|
-
};
|
|
140
|
-
});
|
|
141
|
-
await this.git.commitAndPush(ticket.repo, ticket.branchName, `${ticket.id}: address review comments`, ticket.id);
|
|
142
|
-
return { value: verdicts, run: reply.run };
|
|
143
|
-
}
|
|
144
|
-
threadPrompt(ticket, threads, from) {
|
|
145
|
-
const hints = [
|
|
146
|
-
...new Set(threads
|
|
147
|
-
.map((thread) => this.config.reviewerHints?.[thread.author.toLowerCase()])
|
|
148
|
-
.filter((hint) => Boolean(hint))),
|
|
149
|
-
];
|
|
150
|
-
return [
|
|
151
|
-
from === "automated"
|
|
152
|
-
? `An automated reviewer left comments on the pull request for this ticket.`
|
|
153
|
-
: `A human reviewer left comments on the pull request for this ticket.`,
|
|
154
|
-
``,
|
|
155
|
-
`Ticket ${ticket.id}: ${ticket.title}`,
|
|
156
|
-
...this.briefLines(ticket),
|
|
157
|
-
...this.bodyLines(ticket),
|
|
158
|
-
...this.labelLines(ticket),
|
|
159
|
-
`Comments:`,
|
|
160
|
-
...threads.flatMap((thread) => [
|
|
161
|
-
`\n[${thread.id}] ${thread.author} said:\n${thread.body}`,
|
|
162
|
-
// A review is a conversation, not one comment: what follows the
|
|
163
|
-
// opening comment is a correction of it or an answer to it. The
|
|
164
|
-
// first comment is the header above, so the bullets carry only what
|
|
165
|
-
// came after it, oldest first — the last one says who is being
|
|
166
|
-
// waited on.
|
|
167
|
-
...thread.comments
|
|
168
|
-
.slice(1)
|
|
169
|
-
.map((comment) => ` - ${comment.author} replied:\n${comment.body}`),
|
|
170
|
-
]),
|
|
171
|
-
...(hints.length ? [``, `Reviewer notes:`, ...hints.map((hint) => `- ${hint}`)] : []),
|
|
172
|
-
``,
|
|
173
|
-
`A later comment in a thread answers the earlier ones, and the last`,
|
|
174
|
-
`comment says who the thread is waiting on. Answer the thread as it`,
|
|
175
|
-
`stands now, not as its first comment left it.`,
|
|
176
|
-
``,
|
|
177
|
-
`For each comment, either change the code or say why you disagree. Do not`,
|
|
178
|
-
`argue on the pull request. Do not commit: that is handled for you.`,
|
|
179
|
-
``,
|
|
180
|
-
`Then answer with a single JSON object and nothing else:`,
|
|
181
|
-
``,
|
|
182
|
-
`{"verdicts": [{"threadId": "...", "verdict": "fixed", "note": "what you changed"}]}`,
|
|
183
|
-
``,
|
|
184
|
-
`Use "disagreed" only when you did not change the code, and say why in the`,
|
|
185
|
-
`note. A disagreement goes to the ticket owner to settle, so be specific.`,
|
|
186
|
-
].join("\n");
|
|
187
|
-
}
|
|
188
|
-
async ask(ticket, prompt) {
|
|
189
|
-
// The work happens where the work is: with a worktree port behind the
|
|
190
|
-
// Git, the path handed over is the ticket's own tree, so the agent —
|
|
191
|
-
// the gate beside it, and every git effect — never sees another item's
|
|
192
|
-
// tree or the standing checkout.
|
|
193
|
-
const cwd = await this.git.acquire(ticket.repo, ticket.id);
|
|
194
|
-
return this.harness.ask(this.invoke(prompt), cwd, {
|
|
195
|
-
workId: ticket.id,
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* The current brief the ticket's work belongs to, when it has one.
|
|
200
|
-
*
|
|
201
|
-
* Rendered rather than referenced: a brief is the revisable statement of
|
|
202
|
-
* the feature, and what a step must judge is what it says *now*, not a link
|
|
203
|
-
* that says "see elsewhere". A ticket with no brief carries none, and every
|
|
204
|
-
* prompt built from it is unchanged — that is the compatibility rule.
|
|
205
|
-
*/
|
|
206
|
-
briefLines(ticket) {
|
|
207
|
-
if (!ticket.brief)
|
|
208
|
-
return [];
|
|
209
|
-
return [
|
|
210
|
-
`The current brief for the feature this ticket belongs to:`,
|
|
211
|
-
``,
|
|
212
|
-
ticket.brief,
|
|
213
|
-
``,
|
|
214
|
-
`Answer for the brief as it stands above, not for what the ticket`,
|
|
215
|
-
`title alone says.`,
|
|
216
|
-
];
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* The ticket's body, in the prompt, where the work can be judged by it.
|
|
220
|
-
*
|
|
221
|
-
* A ticket with no body says so rather than looking truncated: the absent
|
|
222
|
-
* line is the difference between an agent that asks for the description
|
|
223
|
-
* and one that guesses there was nothing to know.
|
|
224
|
-
*/
|
|
225
|
-
bodyLines(ticket) {
|
|
226
|
-
return [``, ticket.body ?? `(this ticket has no description)`];
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* What the team says this ticket *is*, beside the body it says it with.
|
|
230
|
-
*
|
|
231
|
-
* A label is the tracker's fact, not the caller's — an epic labelled
|
|
232
|
-
* `Feature` is not work to implement, and its sub-issues are. Naming them
|
|
233
|
-
* here is what lets a step that judges the ticket see the label instead of
|
|
234
|
-
* guessing it; a ticket with none says nothing, because most carry none.
|
|
235
|
-
*/
|
|
236
|
-
labelLines(ticket) {
|
|
237
|
-
if (ticket.labels.length === 0)
|
|
238
|
-
return [];
|
|
239
|
-
return [`Labels: ${ticket.labels.join(", ")}`];
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* The conversation on the ticket, split by who wrote it.
|
|
243
|
-
*
|
|
244
|
-
* What amy asked is labelled as its own, so the agent reads its words as a
|
|
245
|
-
* question already put rather than as new information, and does not ask it
|
|
246
|
-
* twice. An answer from somebody is the answer to an earlier question, and
|
|
247
|
-
* carries their name, because an unattributed sentence is not a
|
|
248
|
-
* conversation. Nothing here is no conversation at all: most tickets have
|
|
249
|
-
* never been asked anything.
|
|
250
|
-
*/
|
|
251
|
-
conversationLines(conversation) {
|
|
252
|
-
if (!conversation || conversation.length === 0)
|
|
253
|
-
return [];
|
|
254
|
-
return [``, `The conversation on the ticket, so far:`, ...conversation.map((line) => `- ${line}`)];
|
|
255
|
-
}
|
|
256
|
-
/** The prompt, addressed to a skill when one was named. */
|
|
257
|
-
invoke(prompt) {
|
|
258
|
-
return this.config.skill ? `/${this.config.skill}\n\n${prompt}` : prompt;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
//# sourceMappingURL=HarnessAgent.js.map
|
package/dist/HarnessAgent.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HarnessAgent.js","sourceRoot":"","sources":["../src/HarnessAgent.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AA2BxC;;;;;;;GAOG;AACH,MAAM,OAAO,YAAY;IAEJ;IACA;IACA;IAHnB,YACmB,OAAgB,EAChB,GAAQ,EACR,SAA6B,EAAE;QAF/B,YAAO,GAAP,OAAO,CAAS;QAChB,QAAG,GAAH,GAAG,CAAK;QACR,WAAM,GAAN,MAAM,CAAyB;IAC/C,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,YAAgC;QAC3D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAC1B,MAAM,EACN;YACE,kEAAkE;YAClE,EAAE;YACF,UAAU,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,EAAE;YACtC,YAAY,MAAM,CAAC,GAAG,EAAE;YACxB,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YAC1B,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YACzB,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YAC1B,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC;YACvC,2DAA2D;YAC3D,sCAAsC;YACtC,EAAE;YACF,iBAAiB;YACjB,EAAE;YACF,gDAAgD;YAChD,EAAE;YACF,+CAA+C;YAC/C,EAAE;YACF,sEAAsE;YACtE,uEAAuE;YACvE,gEAAgE;YAChE,mEAAmE;SACpE,C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