@markjaquith/agency 2.71.27 → 2.73.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 +20 -9
- package/index.ts +1 -1
- package/package.json +3 -3
- package/schemas/{agency-kickoff-v1.schema.json → agency-execution-v1.schema.json} +66 -42
- package/src/commands/repo.test.ts +11 -1
- package/src/commands/repo.ts +17 -1
- package/src/commands/task.ts +1 -1
- package/src/commands/work.test.ts +9 -6
- package/src/commands/work.ts +5 -6
- package/src/services/IntegrationService.test.ts +42 -14
- package/src/services/RepositoryService.test.ts +150 -1
- package/src/services/RepositoryService.ts +290 -1
- package/src/workbase/AGENTS.md +74 -38
- package/src/workbase/{kickoff-contract.test.ts → execution-contract.test.ts} +45 -29
- package/src/workbase/{kickoff-contract.ts → execution-contract.ts} +46 -85
- package/src/workbase/opencode-file.ts +7 -2
|
@@ -5,11 +5,11 @@ import { FileSystemService } from "../services/FileSystemService"
|
|
|
5
5
|
import { WorkbaseService } from "../services/WorkbaseService"
|
|
6
6
|
import { documentRevision } from "./document-revision"
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const EXECUTION_CONTRACT_VERSION = 1 as const
|
|
9
9
|
|
|
10
|
-
export const
|
|
10
|
+
export const EXECUTION_SOURCE_LOCATIONS = [
|
|
11
11
|
"src/commands/task.ts",
|
|
12
|
-
"src/workbase/
|
|
12
|
+
"src/workbase/execution-contract.ts",
|
|
13
13
|
"src/commands/work.ts",
|
|
14
14
|
"src/services/WorktreeService.ts",
|
|
15
15
|
"src/workbase/AGENTS.md",
|
|
@@ -25,7 +25,7 @@ export const RecalledTaskContext = Schema.Struct({
|
|
|
25
25
|
export type RecalledTaskContext = Schema.Schema.Type<typeof RecalledTaskContext>
|
|
26
26
|
|
|
27
27
|
const ValidationEvidencePayload = Schema.Struct({
|
|
28
|
-
version: Schema.Literal(
|
|
28
|
+
version: Schema.Literal(EXECUTION_CONTRACT_VERSION),
|
|
29
29
|
workbaseRoot: Schema.String,
|
|
30
30
|
target: Schema.String,
|
|
31
31
|
documentPath: Schema.String,
|
|
@@ -166,7 +166,7 @@ export const buildValidationEvidence = (input: {
|
|
|
166
166
|
Effect.gen(function* () {
|
|
167
167
|
const identity = yield* workbaseIdentity(input.startPath)
|
|
168
168
|
const payload = {
|
|
169
|
-
version:
|
|
169
|
+
version: EXECUTION_CONTRACT_VERSION,
|
|
170
170
|
workbaseRoot: identity.root,
|
|
171
171
|
target: input.target,
|
|
172
172
|
documentPath: resolve(input.documentPath),
|
|
@@ -208,7 +208,7 @@ export const readValidationEvidence = (input: string, cwd: string) =>
|
|
|
208
208
|
parsed?.validationEvidence?.evidence ??
|
|
209
209
|
parsed?.evidence ??
|
|
210
210
|
(parsed?.target && parsed?.documentRevision ? parsed : undefined)
|
|
211
|
-
if (!candidate || candidate.version !==
|
|
211
|
+
if (!candidate || candidate.version !== EXECUTION_CONTRACT_VERSION) {
|
|
212
212
|
return undefined
|
|
213
213
|
}
|
|
214
214
|
return parseValidationEvidence(candidate)
|
|
@@ -259,100 +259,61 @@ export const assessValidationEvidence = (input: {
|
|
|
259
259
|
}
|
|
260
260
|
})
|
|
261
261
|
|
|
262
|
-
export const
|
|
262
|
+
export const buildExecutionContract = (input: {
|
|
263
263
|
readonly workbaseRoot: string
|
|
264
264
|
readonly target: string
|
|
265
|
-
readonly taskId: string
|
|
266
|
-
readonly phaseId?: string
|
|
267
265
|
readonly taskPath: string
|
|
268
266
|
readonly phasePath?: string | null
|
|
269
267
|
readonly checkoutPath?: string | null
|
|
270
268
|
readonly documentRevision: string
|
|
269
|
+
readonly dryRun: boolean
|
|
271
270
|
}) => {
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
version: KICKOFF_CONTRACT_VERSION,
|
|
271
|
+
const executionDirectory = dirname(input.phasePath ?? input.taskPath)
|
|
272
|
+
const key = digest({
|
|
273
|
+
version: EXECUTION_CONTRACT_VERSION,
|
|
276
274
|
workbaseRoot: input.workbaseRoot,
|
|
277
275
|
target: input.target,
|
|
278
276
|
})
|
|
277
|
+
const documentPath = input.phasePath ?? input.taskPath
|
|
278
|
+
const mode = input.dryRun ? "preview" : "applied"
|
|
279
279
|
return {
|
|
280
|
-
version:
|
|
281
|
-
|
|
280
|
+
version: EXECUTION_CONTRACT_VERSION,
|
|
281
|
+
capability: "agency-execution-v1" as const,
|
|
282
|
+
mode,
|
|
283
|
+
executionIdentity: {
|
|
284
|
+
key,
|
|
285
|
+
target: input.target,
|
|
286
|
+
documentRevision: input.documentRevision,
|
|
287
|
+
},
|
|
282
288
|
workbaseRoot: input.workbaseRoot,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
orchestrator: {
|
|
291
|
-
capability: "agency-kickoff-v1",
|
|
292
|
-
knownCurrentCommandsBypassDiscovery: true,
|
|
293
|
-
fallback:
|
|
294
|
-
"Discover Herdr capabilities only when capability/version evidence is absent or stale.",
|
|
289
|
+
sourceLocations: EXECUTION_SOURCE_LOCATIONS,
|
|
290
|
+
workspace: {
|
|
291
|
+
state: input.dryRun ? ("planned" as const) : ("materialized" as const),
|
|
292
|
+
executionDirectory,
|
|
293
|
+
taskDocument: input.taskPath,
|
|
294
|
+
phaseDocument: input.phasePath ?? null,
|
|
295
|
+
checkoutPath: input.checkoutPath ?? null,
|
|
295
296
|
},
|
|
296
|
-
|
|
297
|
-
{
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
id: "worktree-prepare",
|
|
311
|
-
argv: ["agency", "worktree", "prepare", ...selector, "--json"],
|
|
312
|
-
retry: "reuses matching clean workspaces",
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
id: "herdr-tab",
|
|
316
|
-
action: "create-or-reuse-background-tab",
|
|
317
|
-
idempotencyKey,
|
|
318
|
-
recovery:
|
|
319
|
-
"Reuse the tab recorded for this idempotency key; never create a duplicate.",
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
id: "task-document-split",
|
|
323
|
-
action: "open-side-by-side-document",
|
|
324
|
-
path: input.phasePath ?? input.taskPath,
|
|
325
|
-
recovery: "Reuse the existing split when present.",
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
id: "agent-start",
|
|
329
|
-
cwd: taskDirectory,
|
|
297
|
+
...(input.dryRun
|
|
298
|
+
? {
|
|
299
|
+
plannedActions: [
|
|
300
|
+
{
|
|
301
|
+
kind: "workspace-materialization" as const,
|
|
302
|
+
target: input.target,
|
|
303
|
+
checkoutPath: input.checkoutPath ?? null,
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
}
|
|
307
|
+
: {}),
|
|
308
|
+
commands: {
|
|
309
|
+
work: {
|
|
310
|
+
cwd: executionDirectory,
|
|
330
311
|
argv: ["agency", "work", ".", "--auto"],
|
|
331
|
-
recovery:
|
|
332
|
-
"Inspect the recorded tab before retrying; a working agent must not be duplicated.",
|
|
333
312
|
},
|
|
334
|
-
{
|
|
335
|
-
|
|
336
|
-
argv: [
|
|
337
|
-
"agency",
|
|
338
|
-
"context",
|
|
339
|
-
input.phasePath ?? input.taskPath,
|
|
340
|
-
"--json",
|
|
341
|
-
],
|
|
342
|
-
exactlyOnce: true,
|
|
343
|
-
recovery:
|
|
344
|
-
"If verification fails, inspect the existing tab; do not launch another agent.",
|
|
313
|
+
context: {
|
|
314
|
+
cwd: executionDirectory,
|
|
315
|
+
argv: ["agency", "context", documentPath, "--json"],
|
|
345
316
|
},
|
|
346
|
-
|
|
347
|
-
successFields: [
|
|
348
|
-
"target",
|
|
349
|
-
"taskDirectory",
|
|
350
|
-
"taskDocument",
|
|
351
|
-
"preparedCheckout",
|
|
352
|
-
"herdrWorkspace",
|
|
353
|
-
"herdrTab",
|
|
354
|
-
"agentStart",
|
|
355
|
-
"contextVerification",
|
|
356
|
-
],
|
|
317
|
+
},
|
|
357
318
|
}
|
|
358
319
|
}
|
|
@@ -20,6 +20,12 @@ const agencyPlanBashPermissions = {
|
|
|
20
20
|
"agency *": "allow",
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const agencyAgentPrompt = `You are the Agency workflow specialist. Use the Agency CLI to handle delegated workbase orchestration and workflow operations. Always start with \`agency context . --json\` and follow the managed Agency instructions and reported authority.
|
|
24
|
+
|
|
25
|
+
When the intent and parameters are known, use the matching managed Command Fast Path exactly. The recipes cover creation, preparation, synchronization, phase conversion, archiving, review work, inspection, dropping, continuation, publication, pull requests, non-PR completion, multi-phase setup, investigation handoff, and review refresh. Preparation recipes call \`agency work prepare <task-or-document> --json\`. Do not probe help or list unrelated state, never pass \`--work\` or \`--auto\` to \`agency task create\`, and use \`--dry-run\` only where the recipe or caller requests it. Use CLI discovery only when no fast-path recipe matches or a prescribed command rejects known-current syntax.
|
|
26
|
+
|
|
27
|
+
Return the prepared execution contract to the caller. Agency owns the target, validation, materialized workspace facts, and native commands; the caller owns presentation and process orchestration.`
|
|
28
|
+
|
|
23
29
|
const body = () =>
|
|
24
30
|
`${JSON.stringify(
|
|
25
31
|
{
|
|
@@ -30,8 +36,7 @@ const body = () =>
|
|
|
30
36
|
description:
|
|
31
37
|
"Handles Agency workbase orchestration and workflow operations with the Agency CLI",
|
|
32
38
|
mode: "subagent",
|
|
33
|
-
prompt:
|
|
34
|
-
"You are the Agency workflow specialist. Use the Agency CLI to handle delegated workbase orchestration and workflow operations. Always start with `agency context . --json`, follow the managed Agency instructions and reported authority, use Agency commands for durable mutations, and report the resulting state concisely. When delegated to start or kick off work in another agent, launch it, verify that the agent started successfully, and return without waiting for the task to finish.",
|
|
39
|
+
prompt: agencyAgentPrompt,
|
|
35
40
|
},
|
|
36
41
|
plan: {
|
|
37
42
|
disable: true,
|