@nodeint/migent 0.1.5 → 0.1.6
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 +191 -151
- package/dist/commands/agent.d.ts +8 -1
- package/dist/commands/agent.js +290 -17
- package/dist/commands/config.js +3 -1
- package/dist/commands/execute.d.ts +1 -2
- package/dist/commands/execute.js +93 -24
- package/dist/commands/sessions.js +10 -10
- package/dist/commands/skill.js +8 -1
- package/dist/display.d.ts +1 -0
- package/dist/display.js +3 -0
- package/dist/exits.d.ts +3 -1
- package/dist/exits.js +9 -2
- package/dist/program.js +62 -28
- package/dist/templates/migent/SKILL.md +155 -157
- package/dist/templates/migent/references/config.md +52 -0
- package/dist/templates/migent/references/inspect.md +32 -0
- package/dist/templates/migent/references/schema-workflow.yaml +11 -1
- package/dist/templates/migent/references/sessions.md +65 -0
- package/package.json +4 -4
package/dist/program.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import { ConfigurationError, DEFAULT_MAX_DISPATCHES } from "@nodeint/migent-kernel";
|
|
4
|
-
import { dispatchAgent } from "./commands/agent.js";
|
|
3
|
+
import { ConfigurationError, DEFAULT_MAX_DISPATCHES, requireAgentSession } from "@nodeint/migent-kernel";
|
|
4
|
+
import { continueAgent, dispatchAgent } from "./commands/agent.js";
|
|
5
5
|
import { runConfigModel, runConfigRole, runConfigShow } from "./commands/config.js";
|
|
6
6
|
import { runDoctor } from "./commands/doctor.js";
|
|
7
7
|
import { executeWorkflow } from "./commands/execute.js";
|
|
@@ -20,7 +20,7 @@ import { PACKAGE_VERSION } from "./version.js";
|
|
|
20
20
|
import { findWorkspace, invocationCwdPath } from "./workspace.js";
|
|
21
21
|
const PRIOR_HELP = "Completed session with the workflow id and decision named in requires. Checked before outputs are injected.";
|
|
22
22
|
const PROGRESS_HELP = "Print each tool call when it finishes. The default prints one line when a stage starts and one when it finishes.";
|
|
23
|
-
const VERBOSE_HELP = "
|
|
23
|
+
const VERBOSE_HELP = "Accepted for compatibility. Stage lines already include the attempt and the time. The response stays in the execution directory.";
|
|
24
24
|
export function createProgram(status) {
|
|
25
25
|
const program = new Command();
|
|
26
26
|
program
|
|
@@ -195,10 +195,11 @@ export function createProgram(status) {
|
|
|
195
195
|
return program;
|
|
196
196
|
}
|
|
197
197
|
const ROLE_EXITS = [
|
|
198
|
-
"Exit 0 when the outcome is complete.",
|
|
198
|
+
"Exit 0 when the outcome is complete, or the role session is already completed.",
|
|
199
199
|
"Exit 1 when the outcome is not complete.",
|
|
200
200
|
"Exit 2 on a configuration error.",
|
|
201
|
-
"Exit
|
|
201
|
+
"Exit 6 when a cancelled role session reopened more than one execution and one exhausted verify.",
|
|
202
|
+
"Exit 130 when cancelled. session continue resumes that execution.",
|
|
202
203
|
];
|
|
203
204
|
const RUN_SPLIT = "Pass --workflow for a workflow run, or --role for an agent run.";
|
|
204
205
|
function registerSessionCommand(program, status) {
|
|
@@ -218,7 +219,7 @@ function registerSessionCommand(program, status) {
|
|
|
218
219
|
.option("--prompt <prompt>", "Prompt text for a role run.")
|
|
219
220
|
.option("--file <file>", "Read the role prompt from this file.")
|
|
220
221
|
.option("--stdin", "Read the role prompt from stdin.")
|
|
221
|
-
.option("--json", "Print the role result as one JSON object.
|
|
222
|
+
.option("--json", "Print the role result as one JSON object.")
|
|
222
223
|
.addHelpText("after", `With --workflow:\n${exitText(LOOP_EXITS)}With --workflow and --once:\n${exitText(STAGE_EXITS)}Without --workflow:\n${exitText(ROLE_EXITS)}Examples:\n migent session run --workflow plan --task "<one line>"\n migent session run --session wave-3 --workflow plan\n migent session run --role reviewer --prompt "<prompt>"\n`)
|
|
223
224
|
.action((options) => settle(status, () => runSessionCommand(options)));
|
|
224
225
|
session
|
|
@@ -231,13 +232,13 @@ function registerSessionCommand(program, status) {
|
|
|
231
232
|
.action((id, options) => settle(status, () => prepareWorkflowSession(findWorkspace(invocationCwdPath()), id, String(options.workflow), optionalText(options.prior))));
|
|
232
233
|
const continueCommand = session
|
|
233
234
|
.command("continue")
|
|
234
|
-
.description("Resume
|
|
235
|
+
.description("Resume a stopped workflow or role session. A workflow session runs until it stops and resets revision counts. --once dispatches one workflow stage and does not reset them.")
|
|
235
236
|
.argument("<session>", "Session to resume.");
|
|
236
237
|
addDispatchOptions(continueCommand, "Dispatch the next eligible stage once and do not reset revision counts. Without --once, continue resets them.");
|
|
237
238
|
continueCommand
|
|
238
239
|
.option("--reply <text>", "Reply for the blocked stage. The new execution prompt body is this text.")
|
|
239
240
|
.option("--reply-file <file>", "Read the blocked stage's reply from this file.")
|
|
240
|
-
.addHelpText("after",
|
|
241
|
+
.addHelpText("after", `Workflow session:\n${exitText(LOOP_EXITS)}With --once:\n${exitText(STAGE_EXITS)}Role session:\n${exitText(ROLE_EXITS)}Examples:\n migent session continue <session>\n migent session continue <session> --once\n migent session continue <session> --reply "<reply>"\n migent session continue <session> --stage plan --reply-file answer.md\n`)
|
|
241
242
|
.action((id, options) => settle(status, () => continueSession(id, options)));
|
|
242
243
|
session
|
|
243
244
|
.command("repair")
|
|
@@ -290,15 +291,15 @@ function registerSessionCommand(program, status) {
|
|
|
290
291
|
})));
|
|
291
292
|
session
|
|
292
293
|
.command("metrics")
|
|
293
|
-
.description("Print
|
|
294
|
-
.argument("[session]", "
|
|
294
|
+
.description("Print usage, time, and revision counts recorded for a completed workflow session.")
|
|
295
|
+
.argument("[session]", "Workflow session to read. Omit to list sessions that have metrics.")
|
|
295
296
|
.option("--json", "Print one JSON object, or one object per line for a list.")
|
|
296
297
|
.option("--workflow <id>", "With a list, keep sessions for this workflow.")
|
|
297
298
|
.option("--status <status>", "With a list, keep sessions in this status.")
|
|
298
299
|
.option("--limit <n>", "With a list, keep the newest n sessions.")
|
|
299
300
|
.addHelpText("after", `${exitText([
|
|
300
301
|
"Exit 0 after one session object, or one object per line. An empty list prints nothing.",
|
|
301
|
-
"Exit 2 when --json is missing, the session has no
|
|
302
|
+
"Exit 2 when --json is missing, the session has no metrics.json, that file is corrupt, or a list flag is invalid.",
|
|
302
303
|
])}Examples:\n migent session metrics <session> --json\n migent session metrics --json --workflow <id> --status completed --limit 10\n`)
|
|
303
304
|
.action((id, options) => settle(status, () => runSessionMetrics(findWorkspace(invocationCwdPath()), id, {
|
|
304
305
|
asJson: options.json === true,
|
|
@@ -393,7 +394,6 @@ function workflowFlagsPresent(options) {
|
|
|
393
394
|
return (options.once === true ||
|
|
394
395
|
options.stage !== undefined ||
|
|
395
396
|
options.prior !== undefined ||
|
|
396
|
-
options.attempts !== undefined ||
|
|
397
397
|
options.maxDispatches !== undefined ||
|
|
398
398
|
options.unlimitedDispatches === true ||
|
|
399
399
|
options.progress === true ||
|
|
@@ -418,7 +418,6 @@ function runWorkflowCommand(args) {
|
|
|
418
418
|
sessionId,
|
|
419
419
|
startPrepared: args.prepared,
|
|
420
420
|
priorSessionId: optionalText(args.options.prior),
|
|
421
|
-
maxAttempts: attemptsOf(args.options),
|
|
422
421
|
maxDispatches: ceiling,
|
|
423
422
|
refreshWorkflow: args.options.refreshWorkflow === true,
|
|
424
423
|
...outputFlags(args.options),
|
|
@@ -432,7 +431,6 @@ function runWorkflowCommand(args) {
|
|
|
432
431
|
stageId,
|
|
433
432
|
startPrepared: args.prepared,
|
|
434
433
|
priorSessionId: optionalText(args.options.prior),
|
|
435
|
-
maxAttempts: null,
|
|
436
434
|
maxDispatches: null,
|
|
437
435
|
refreshWorkflow: args.options.refreshWorkflow === true,
|
|
438
436
|
...outputFlags(args.options),
|
|
@@ -443,6 +441,9 @@ function continueSession(session, options) {
|
|
|
443
441
|
printError("--stage is empty.");
|
|
444
442
|
return 2;
|
|
445
443
|
}
|
|
444
|
+
const workspace = findWorkspace(invocationCwdPath());
|
|
445
|
+
if (isAgentSession(workspace, session))
|
|
446
|
+
return continueRoleSession(workspace, session, options);
|
|
446
447
|
if (rejectOnce(options))
|
|
447
448
|
return 2;
|
|
448
449
|
const reply = readReply(options);
|
|
@@ -455,8 +456,8 @@ function continueSession(session, options) {
|
|
|
455
456
|
sessionId: session,
|
|
456
457
|
stageId,
|
|
457
458
|
priorSessionId: optionalText(options.prior),
|
|
458
|
-
maxAttempts: null,
|
|
459
459
|
maxDispatches: null,
|
|
460
|
+
continueFailed: true,
|
|
460
461
|
refreshWorkflow: options.refreshWorkflow === true,
|
|
461
462
|
reply,
|
|
462
463
|
...outputFlags(options),
|
|
@@ -469,13 +470,57 @@ function continueSession(session, options) {
|
|
|
469
470
|
action: "continue",
|
|
470
471
|
sessionId: session,
|
|
471
472
|
priorSessionId: optionalText(options.prior),
|
|
472
|
-
maxAttempts: attemptsOf(options),
|
|
473
473
|
maxDispatches: ceiling,
|
|
474
|
+
continueFailed: true,
|
|
474
475
|
refreshWorkflow: options.refreshWorkflow === true,
|
|
475
476
|
reply,
|
|
476
477
|
...outputFlags(options),
|
|
477
478
|
});
|
|
478
479
|
}
|
|
480
|
+
function isAgentSession(workspace, sessionId) {
|
|
481
|
+
try {
|
|
482
|
+
requireAgentSession(workspace, sessionId);
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
catch (error) {
|
|
486
|
+
if (!(error instanceof ConfigurationError))
|
|
487
|
+
throw error;
|
|
488
|
+
if (error.message === `Session not found: ${sessionId}.`)
|
|
489
|
+
return false;
|
|
490
|
+
if (error.message === `Session ${sessionId} was not created by agent.`)
|
|
491
|
+
return false;
|
|
492
|
+
if (error.message.startsWith("Session status file is corrupt:"))
|
|
493
|
+
return false;
|
|
494
|
+
throw error;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function continueRoleSession(workspace, sessionId, options) {
|
|
498
|
+
const flags = [];
|
|
499
|
+
if (options.once === true)
|
|
500
|
+
flags.push("--once");
|
|
501
|
+
if (options.stage !== undefined)
|
|
502
|
+
flags.push("--stage");
|
|
503
|
+
if (options.prior !== undefined)
|
|
504
|
+
flags.push("--prior");
|
|
505
|
+
if (options.maxDispatches !== undefined)
|
|
506
|
+
flags.push("--max-dispatches");
|
|
507
|
+
if (options.unlimitedDispatches === true)
|
|
508
|
+
flags.push("--unlimited-dispatches");
|
|
509
|
+
if (options.progress === true)
|
|
510
|
+
flags.push("--progress");
|
|
511
|
+
if (options.verbose === true)
|
|
512
|
+
flags.push("--verbose");
|
|
513
|
+
if (options.refreshWorkflow === true)
|
|
514
|
+
flags.push("--refresh-workflow");
|
|
515
|
+
if (flags.length > 0) {
|
|
516
|
+
printError(`Session ${sessionId} is a role session. Omit ${flags.join(", ")}.`);
|
|
517
|
+
return 2;
|
|
518
|
+
}
|
|
519
|
+
const reply = readReply(options);
|
|
520
|
+
if (reply === "invalid")
|
|
521
|
+
return 2;
|
|
522
|
+
return continueAgent(workspace, { sessionId, reply });
|
|
523
|
+
}
|
|
479
524
|
function readReply(options) {
|
|
480
525
|
const hasReply = options.reply !== undefined;
|
|
481
526
|
const hasFile = options.replyFile !== undefined;
|
|
@@ -518,7 +563,6 @@ function addDispatchOptions(command, onceDescription) {
|
|
|
518
563
|
.option("--once", onceDescription)
|
|
519
564
|
.option("--stage <stage>", "Dispatch this ready stage once. It does not have to be the first ready stage.")
|
|
520
565
|
.option("--prior <session>", PRIOR_HELP)
|
|
521
|
-
.option("--attempts <count>", "Failed executions allowed for one stage. Default: 3.")
|
|
522
566
|
.option("--max-dispatches <count>", `Stage dispatches allowed in this command. Default: ${DEFAULT_MAX_DISPATCHES}. Pass --unlimited-dispatches to remove the ceiling.`)
|
|
523
567
|
.option("--unlimited-dispatches", "Remove the dispatch ceiling for this command.")
|
|
524
568
|
.option("--progress", PROGRESS_HELP)
|
|
@@ -526,7 +570,7 @@ function addDispatchOptions(command, onceDescription) {
|
|
|
526
570
|
.option("--refresh-workflow", "Use the current workflow, models, and role instructions for this session. Requires an existing session that has a frozen workflow.");
|
|
527
571
|
}
|
|
528
572
|
function outputFlags(options) {
|
|
529
|
-
return {
|
|
573
|
+
return { itemProgress: options.progress === true };
|
|
530
574
|
}
|
|
531
575
|
function showHelpWhenBare(status, command) {
|
|
532
576
|
command.action(() => {
|
|
@@ -590,10 +634,6 @@ function rejectOnce(options) {
|
|
|
590
634
|
if (options.once !== true && options.stage === undefined)
|
|
591
635
|
return false;
|
|
592
636
|
const flag = options.once === true ? "--once" : "--stage";
|
|
593
|
-
if (options.attempts !== undefined) {
|
|
594
|
-
printError(`${flag} cannot be combined with --attempts.`);
|
|
595
|
-
return true;
|
|
596
|
-
}
|
|
597
637
|
if (options.maxDispatches !== undefined) {
|
|
598
638
|
printError(`${flag} cannot be combined with --max-dispatches.`);
|
|
599
639
|
return true;
|
|
@@ -617,12 +657,6 @@ function dispatchCeiling(options) {
|
|
|
617
657
|
return DEFAULT_MAX_DISPATCHES;
|
|
618
658
|
return integerFlag(maxDispatches, "--max-dispatches");
|
|
619
659
|
}
|
|
620
|
-
function attemptsOf(options) {
|
|
621
|
-
const raw = optionalText(options.attempts);
|
|
622
|
-
if (raw === null)
|
|
623
|
-
return 3;
|
|
624
|
-
return integerFlag(raw, "--attempts");
|
|
625
|
-
}
|
|
626
660
|
function integerFlag(raw, flag) {
|
|
627
661
|
if (!/^[0-9]+$/.test(raw) || Number(raw) < 1) {
|
|
628
662
|
throw new ConfigurationError(`${flag} must be at least 1.`);
|
|
@@ -6,166 +6,164 @@ description: Set up Migent in a project, or configure, run, inspect, and resume
|
|
|
6
6
|
# Migent
|
|
7
7
|
|
|
8
8
|
Migent runs a project's multi-stage agent workflows from the `migent` CLI.
|
|
9
|
-
A workflow is a set of stages
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
`config model` and `config role` writes too. The object includes the doctor
|
|
25
|
-
result.
|
|
9
|
+
A workflow is a set of stages. A stage runs a role, or runs `verify` alone when `role` is omitted. A role uses a model name
|
|
10
|
+
defined in `.migent/config.yaml`. Each run is a session, stored under
|
|
11
|
+
`.migent/sessions/<session-id>/`.
|
|
12
|
+
|
|
13
|
+
This skill is already in the prompt. Do not open its file again.
|
|
14
|
+
|
|
15
|
+
## Rules
|
|
16
|
+
|
|
17
|
+
- Work from the project root, the directory containing `.migent/config.yaml`.
|
|
18
|
+
- Read `.migent/config.yaml` and the relevant `.migent/workflows/` file before
|
|
19
|
+
running a workflow.
|
|
20
|
+
- Before writing either, read `.agents/skills/migent/references/schema-config.yaml`
|
|
21
|
+
and `schema-workflow.yaml` in the same folder. A key absent from them is
|
|
22
|
+
ignored. Then run `migent doctor --json`; if it reports an outdated schema,
|
|
23
|
+
run `migent migrate --yes`.
|
|
26
24
|
- You have no terminal for prompts. Pass `--no-input` (or set
|
|
27
25
|
`MIGENT_NO_INPUT=1`) to `init`, `config model`, and `config role`, and give
|
|
28
26
|
every value as a flag.
|
|
29
|
-
-
|
|
30
|
-
`
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
- Do not edit generated session state: `manifest.yaml`, `status.json`,
|
|
28
|
+
`events.jsonl`, `metrics.json`, or anything under `executions/`.
|
|
29
|
+
- Keep the user's task wording. Do not read `task.md` or the documents it
|
|
30
|
+
names; the stage agent does.
|
|
31
|
+
- Never start a replacement session to reset limits or get past `blocked`.
|
|
32
|
+
Resume the same one.
|
|
33
|
+
|
|
34
|
+
## Run a task
|
|
35
|
+
|
|
36
|
+
`<workflow>` is a workflow id or a path to a workflow file.
|
|
37
|
+
|
|
38
|
+
One-line task. The command runs until the session stops:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
migent session run --workflow <workflow> --task "<task>"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Longer task. `<some-id>` is a lowercase slug such as `wave-3`:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
migent session prepare <some-id> --workflow <workflow>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Write the task, unchanged, to `.migent/sessions/<some-id>/task.md` (plus any
|
|
51
|
+
files next to it). Do not edit `task.md` once the first stage has started.
|
|
52
|
+
Then:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
migent session run --session <some-id> --workflow <workflow>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Dispatch only one stage: add `--once`.
|
|
59
|
+
|
|
60
|
+
### Read the result
|
|
61
|
+
|
|
62
|
+
A workflow run prints plain lines on stderr and leaves stdout empty. It does
|
|
63
|
+
not print JSON, and it does not print the stage report.
|
|
64
|
+
|
|
65
|
+
- `session_id: <id>` when the session is created.
|
|
66
|
+
- `stage <id> · attempt <n> · <HH:MM:SS> · <provider>/<model> (<options>).` when a stage starts. A description follows the model when the stage has one.
|
|
67
|
+
- `stage <id> · attempt <n> · <duration> · <outcome>.` when it finishes. A decision is `decision=<value>` on that line.
|
|
68
|
+
- A completed session adds `completed · <duration>` and one `artifact: <absolute-path>` line per published file. The path starts at the filesystem root and names the published file, so the suffix stays, such as `plan.md`. Report those paths.
|
|
69
|
+
- Exit 1, 3, 6, and 8 also print `response: executions/<id>/response.md`. Read that file to see why it stopped.
|
|
70
|
+
- Exit 7 prints `verify: executions/<id>/turns/01/verify.md`.
|
|
71
|
+
- A session that stops before it is completed ends with `Resume with:` and `migent session continue <session-id>`.
|
|
72
|
+
|
|
73
|
+
- Do not pass `--verbose` or `--progress`. Do not use `session follow`.
|
|
74
|
+
- If the command runs in the background, wait for its completion notice. Do not
|
|
75
|
+
add a watcher that waits on the same exit.
|
|
76
|
+
|
|
77
|
+
### Exit codes
|
|
78
|
+
|
|
79
|
+
Read the exit code first. Exit 0 with `completed ·` is a completed session.
|
|
80
|
+
Exit 0 without that line is `--once` after a complete stage.
|
|
81
|
+
|
|
82
|
+
| Exit | Meaning | What to do |
|
|
83
|
+
| --- | --- | --- |
|
|
84
|
+
| 0 | Completed, or with `--once` the stage is complete | Report each `artifact:` path when the session completed. |
|
|
85
|
+
| 1 | Blocked, or with `--once` the stage is not complete | If the stage line says `blocked`: read the `response:` path, then resume with the user's answer (below), or plain `session continue` once the blocker is fixed in the workspace. Otherwise `session continue` keeps going. |
|
|
86
|
+
| 2 | Configuration error | Run `migent doctor --json`, fix config. |
|
|
87
|
+
| 3 | A stage failed and the command did not wait | Read the `response:` path, fix the cause, `session continue`. Continue runs the stage and does not sleep until an old `retry_at`. |
|
|
88
|
+
| 4 | A route would exceed `max_revisions` | Review why the stage keeps being revised, then `session continue` for another batch. |
|
|
89
|
+
| 5 | `--max-dispatches` spent | `session continue` if more stages are appropriate. |
|
|
90
|
+
| 6 | A stage's `verify` stayed red | Read the `response:` path, fix the cause, `session continue`. |
|
|
91
|
+
| 7 | A stage with no role failed `verify` | Read the `verify:` path, fix the tree, `session continue`. That reruns the commands and does not open a provider. |
|
|
92
|
+
| 8 | `--once` or `--stage` hit a provider quota and did not wait | Read the `response:` path. `session continue` runs the stage and does not sleep until the recorded `retry_at`. |
|
|
93
|
+
| 130 | Cancelled, including a wait that was disarmed | Ask the user before resuming. Continue does not sleep until an old `retry_at`. |
|
|
94
|
+
|
|
95
|
+
A stopped session that is not `completed` is resumable. Do not call it done.
|
|
96
|
+
|
|
97
|
+
### Resume
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
migent session continue <session-id>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Same command for a workflow session and a role session. Read `session_status`, then use one row.
|
|
104
|
+
|
|
105
|
+
| Kind | When | What to run |
|
|
106
|
+
| --- | --- | --- |
|
|
107
|
+
| Workflow | Not `completed`, including a blocker already fixed in the workspace | The command above. Runs until the session stops and resets revision counts. A blocked stage runs again. |
|
|
108
|
+
| Workflow | The user answered a blocked stage | Add `--reply "<reply>"`. That text is the whole prompt body. |
|
|
109
|
+
| Workflow | One stage, then stop | Add `--once`. Revision counts stay. |
|
|
110
|
+
| Role | `cancelled` | The command above. The cut-off turn resumes in the same execution. Omit `--reply`. |
|
|
111
|
+
| Role | `active` | The command above. The last prompt is sent again. |
|
|
112
|
+
| Role | `blocked` | Add `--reply "<reply>"`. That is the next user turn. With no reply, the agent is only told to continue. |
|
|
113
|
+
| Role | `completed` | Leave it stopped. Add `--reply` only to give a new turn. |
|
|
114
|
+
|
|
115
|
+
`--reply-file <path>` is a longer reply. Pass only one of `--reply` and `--reply-file`. Do not pass `--once` or `--stage` on a role session.
|
|
116
|
+
|
|
117
|
+
## Check a session
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
migent session show <session-id> --json
|
|
121
|
+
migent session list --latest --json
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`show` gives status, latest execution, decision, and outputs. `list --latest`
|
|
125
|
+
is the newest session, or `null`. Report the session ID, status, stop reason,
|
|
126
|
+
decisions, and the outputs that matter. Output paths are relative to
|
|
127
|
+
`.migent/sessions/<session-id>/`; use the paths Migent reports.
|
|
128
|
+
|
|
129
|
+
## Set up a project
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
migent init --no-input --provider <provider> --model <model-id> [--preset implement|plan] [--skill]
|
|
47
133
|
migent doctor --json
|
|
48
134
|
```
|
|
49
135
|
|
|
50
|
-
`--provider` and `--model` go together.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
`roles.<role>.instructions` in config, when set, is prepended to that prompt.
|
|
85
|
-
Use `--file <path>` or `--stdin` for a long prompt. `--task` labels a new
|
|
86
|
-
role session and cannot be combined with `--session <session-id>`, which
|
|
87
|
-
continues an earlier role session. `--provider`/`--model` (together) and
|
|
88
|
-
`--option KEY=VALUE` override the role for this turn. Add `--json` for one
|
|
89
|
-
result object. Exit 0 means the outcome is complete, 1 not complete.
|
|
90
|
-
- Read the JSON result on stdout for a workflow run. Do not pass `--verbose`
|
|
91
|
-
or `--progress`. `--verbose` inlines every stage response. `--progress`
|
|
92
|
-
prints each tool call.
|
|
93
|
-
- Exit 1, 3, and 6 also include `latest_execution_id` and `response_path`,
|
|
94
|
-
relative to `.migent/sessions/<session-id>/`. Read that file when you must
|
|
95
|
-
fix the execution.
|
|
96
|
-
- Stderr is not the outcome. Do not read the command log while a run is healthy.
|
|
97
|
-
- When `session run` or `session continue` is in the background, wait for that
|
|
98
|
-
command's completion notice. Do not add a watcher that only waits for the same exit.
|
|
99
|
-
- To check a run without waiting on the command, use
|
|
100
|
-
`migent session show <session-id> --json` once.
|
|
101
|
-
- Do not run `session follow` or `--cursor`.
|
|
102
|
-
|
|
103
|
-
Limits, accepted by workflow `session run` and by `session continue`:
|
|
104
|
-
|
|
105
|
-
- `--attempts <n>`: failed executions allowed for one stage (default 3). On
|
|
106
|
-
`session continue` it sets a new total, not extra retries.
|
|
107
|
-
- `--max-dispatches <n>`: stage dispatches allowed in this command (default
|
|
108
|
-
20). `--unlimited-dispatches` removes the ceiling; use it only if the user
|
|
109
|
-
agrees.
|
|
110
|
-
|
|
111
|
-
### Exit codes and stop reasons
|
|
112
|
-
|
|
113
|
-
A workflow result on stdout includes `stop_reason`. Read the exit code first.
|
|
114
|
-
|
|
115
|
-
| Exit | Meaning | `stop_reason` | Session | What to do |
|
|
116
|
-
| --- | --- | --- | --- | --- |
|
|
117
|
-
| 0 | Completed (with `--once`: stage complete) | | completed or advancing | Report outputs. |
|
|
118
|
-
| 1 | Blocked (with `--once`: stage not complete) | `blocked`, or `stage` with `--once` | blocked, or active with `--once` | When `stop_reason` is `blocked`, read `response_path`. Pass the user's words with `session continue --reply`, or `session continue` without `--reply` after the blocker is fixed in the workspace. When `stop_reason` is `stage`, `session continue` keeps going. |
|
|
119
|
-
| 2 | Configuration error | | unchanged | Run `migent doctor --json`, fix config. |
|
|
120
|
-
| 3 | `--attempts` spent | `retry_exhausted` | active | Read `response_path`, fix the cause, then `session continue` (add `--attempts` for a higher total). |
|
|
121
|
-
| 4 | A route would exceed `max_revisions` | `revisions_exhausted` | active | Review why the stage keeps being revised; `session continue` (without `--once`) resets counts for another batch. |
|
|
122
|
-
| 5 | `--max-dispatches` spent | `dispatch_limit` | active | `session continue` the same session if more stages are appropriate. |
|
|
123
|
-
| 130 | Cancelled | | see snapshot | Ask the user before resuming. `session continue` resumes that same execution. |
|
|
124
|
-
|
|
125
|
-
A stopped active session is resumable; do not describe it as completed. A
|
|
126
|
-
blocked session is resumed the same way: `session continue` runs that stage
|
|
127
|
-
again. Do not start a replacement session to reset limits or to get past
|
|
128
|
-
`blocked`. If you change a workflow or
|
|
129
|
-
config while a session is active, that session keeps the workflow, models, and
|
|
130
|
-
role instructions it started with. Run `migent doctor --json` and tell the user.
|
|
131
|
-
`migent session continue <session-id> --refresh-workflow` adopts the current
|
|
132
|
-
workflow, models, and role instructions. `session run --session <id> --workflow <workflow> --refresh-workflow`
|
|
133
|
-
does the same when starting a prepared session.
|
|
134
|
-
|
|
135
|
-
## Inspect sessions
|
|
136
|
-
|
|
137
|
-
- Newest match: `migent session list --latest --json`. Add `--workflow <id>` and
|
|
138
|
-
`--status active|prepared|completed|blocked|cancelled` to narrow it. `--limit <n>`
|
|
139
|
-
returns the newest n rows. Do not combine `--latest` with `--limit`.
|
|
140
|
-
- `--latest --json` is one object, or `null` when nothing matches. A list is
|
|
141
|
-
a JSON array. Snapshot: `migent session show <session-id> --json` has the
|
|
142
|
-
status, latest execution, decision, and outputs. JSON omits the task text.
|
|
143
|
-
- Compare runs with `migent session metrics --json`. One session is one
|
|
144
|
-
object. Several sessions are one object per line, newest first.
|
|
145
|
-
`--workflow`, `--status`, and `--limit` match `session list`. Read
|
|
146
|
-
`usage_missing` and `uncaptured_turns` before comparing totals.
|
|
147
|
-
`stage_attempt` is not a retry count.
|
|
148
|
-
- `session follow` streams the event trace for a person at a terminal.
|
|
149
|
-
Do not use it or `--cursor` to coordinate a run.
|
|
150
|
-
|
|
151
|
-
Report the session ID, status, stop reason, decisions, and published outputs
|
|
152
|
-
that matter to the user. Published output paths are relative to
|
|
153
|
-
`.migent/sessions/<session-id>/`; use the paths Migent reports instead of
|
|
154
|
-
guessing.
|
|
155
|
-
|
|
156
|
-
## Configure models and roles
|
|
157
|
-
|
|
158
|
-
- Show: `migent config` or `migent config show`.
|
|
159
|
-
- List models or roles: `migent config model --json`,
|
|
160
|
-
`migent config role --json`.
|
|
161
|
-
- Change a model name:
|
|
162
|
-
`migent config model <name> --provider <provider> --model <model-id> --no-input --json`.
|
|
163
|
-
This updates every role and stage that uses the name. Use
|
|
164
|
-
`--option KEY=VALUE` and `--clear-option KEY` for provider options.
|
|
165
|
-
- Point roles at an existing model name:
|
|
166
|
-
`migent config role <role>... --model-name <name> --no-input --json`. The value is
|
|
167
|
-
a name from `models`, not a provider model id.
|
|
168
|
-
- Override one role without touching the shared name:
|
|
169
|
-
`migent config role <role> --provider <provider> --model <model-id> --no-input --json`.
|
|
170
|
-
- `roles.<name>.instructions` is an optional list of strings. A stage prompt
|
|
171
|
-
includes it before that stage's instructions. A role run prepends it to the prompt.
|
|
136
|
+
`--provider` and `--model` go together. The default preset is `implement`.
|
|
137
|
+
`--skill` installs this skill; `migent skill update` refreshes it.
|
|
138
|
+
|
|
139
|
+
## Change models
|
|
140
|
+
|
|
141
|
+
Edit a model name (updates every role and stage that uses it):
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
migent config model <name> --provider <provider> --model <model-id> --no-input --json
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Show the config with `migent config`, `migent config model --json`, or
|
|
148
|
+
`migent config role --json`.
|
|
149
|
+
|
|
150
|
+
## Look up anything else
|
|
151
|
+
|
|
152
|
+
This skill covers the common path. Every command takes `--help`; use it before
|
|
153
|
+
guessing a flag:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
migent --help
|
|
157
|
+
migent session run --help
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
References, read only when the task needs them:
|
|
161
|
+
|
|
162
|
+
| File | Read when |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `references/schema-config.yaml`, `references/schema-workflow.yaml` | Writing config or a workflow. |
|
|
165
|
+
| `references/sessions.md` | Prerequisite session (`--prior`), several blocked stages (`--stage`), resuming a cancelled session, raising limits, adopting workflow edits (`--refresh-workflow`). |
|
|
166
|
+
| `references/config.md` | Running one role, pointing roles at another model, overriding one role, role instructions. |
|
|
167
|
+
| `references/inspect.md` | Filtering `session list`, comparing runs with `session metrics`, `session follow`. |
|
|
168
|
+
|
|
169
|
+
All paths are under `.agents/skills/migent/`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Roles and model configuration
|
|
2
|
+
|
|
3
|
+
Write commands take `--no-input --json`. The JSON includes the doctor result.
|
|
4
|
+
|
|
5
|
+
## Run one role
|
|
6
|
+
|
|
7
|
+
Without `--workflow`, `session run` runs a single role:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
migent session run --role <role> --prompt "<prompt>"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
| Flag | Meaning |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `--file <path>`, `--stdin` | Supply a long prompt. |
|
|
16
|
+
| `--task` | Labels a new role session. Cannot be combined with `--session`. |
|
|
17
|
+
| `--session <session-id>` | Sends a new prompt to an earlier role session. `session continue <session-id>` resumes a stopped role session. |
|
|
18
|
+
| `--provider`, `--model` | Override the role for this turn. Pass together. |
|
|
19
|
+
| `--option KEY=VALUE` | Override a provider option for this turn. |
|
|
20
|
+
| `--json` | Print one result object (the role result, with `outcome_status`; not the workflow result). |
|
|
21
|
+
|
|
22
|
+
Without `--json` it prints a table. Exit 0 means the outcome is complete, 1
|
|
23
|
+
not complete. `roles.<role>.instructions`, when set, is prepended to the prompt.
|
|
24
|
+
|
|
25
|
+
## Model names
|
|
26
|
+
|
|
27
|
+
Provider options on a model name: `--option KEY=VALUE` to set,
|
|
28
|
+
`--clear-option KEY` to remove.
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
migent config model <name> --provider <provider> --model <model-id> --no-input --json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Point roles at an existing model name
|
|
35
|
+
|
|
36
|
+
The value is a name from `models`, not a provider model id.
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
migent config role <role>... --model-name <name> --no-input --json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Override one role without touching the shared name
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
migent config role <role> --provider <provider> --model <model-id> --no-input --json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Role instructions
|
|
49
|
+
|
|
50
|
+
`roles.<name>.instructions` is an optional list of strings. A stage prompt
|
|
51
|
+
includes it before that stage's instructions. A role run prepends it to the
|
|
52
|
+
prompt.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Inspecting many sessions
|
|
2
|
+
|
|
3
|
+
For one session use `migent session show <session-id> --json` (SKILL.md).
|
|
4
|
+
|
|
5
|
+
## List
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
migent session list --workflow <id> --status completed --limit 5 --json
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- Output is a JSON array. `--latest` gives one object, or `null`; do not
|
|
12
|
+
combine it with `--limit`.
|
|
13
|
+
- `--status` is one of `active|prepared|completed|blocked|cancelled|corrupt`.
|
|
14
|
+
A session whose `status.json` does not parse is listed as `corrupt`.
|
|
15
|
+
- JSON rows omit the task text.
|
|
16
|
+
|
|
17
|
+
## Metrics
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
migent session metrics --json
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- One session prints its `metrics.json`. Several print one object per
|
|
24
|
+
line, newest first. Only a completed session has this file. `--workflow`,
|
|
25
|
+
`--status`, and `--limit` filter those rows.
|
|
26
|
+
- Read `usage_missing` and `uncaptured_turns` before comparing totals.
|
|
27
|
+
- `stage_attempt` is not a retry count.
|
|
28
|
+
|
|
29
|
+
## Follow
|
|
30
|
+
|
|
31
|
+
`session follow` streams the event trace for a person at a terminal. Do not use
|
|
32
|
+
it or `--cursor` to coordinate a run.
|