@operad-io/dev 0.1.0 → 0.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @operad-io/dev
2
2
 
3
- **The dev plugin: plans and tasks on a repository.** Turns a request into planned work and follows each task through work, checks, review and merge, with you at the merge.
3
+ **The dev plugin: plans and tasks on a repository.** Turns a request into planned work and follows each task through code, tests, review and merge, with you at the merge.
4
4
 
5
5
  This package is part of [operad](https://github.com/operad-io/operad). Most people install only [`@operad-io/cli`](https://www.npmjs.com/package/@operad-io/cli).
6
6
 
package/dev.schema.json CHANGED
@@ -61,10 +61,16 @@
61
61
  "description": "One stage of a repository flow. A parameter left out falls back to its dev.json setting.",
62
62
  "oneOf": [
63
63
  {
64
- "description": "A worker changes the task branch.",
64
+ "description": "A code stage: a worker changes the task branch.",
65
65
  "type": "object",
66
66
  "properties": {
67
- "stage": { "const": "work" },
67
+ "stage": {
68
+ "description": "The stage kind: code, or its older name work, which still loads.",
69
+ "oneOf": [
70
+ { "const": "code" },
71
+ { "const": "work", "description": "Older name of code; still loads.", "deprecated": true }
72
+ ]
73
+ },
68
74
  "use": { "description": "The harness step, such as radian/agent; unset uses the repository's worker.", "type": "string", "minLength": 1 },
69
75
  "args": { "description": "Arguments for the harness step; unset uses the worker's own.", "type": "array", "items": { "type": "string" } },
70
76
  "pool": { "description": "The pool this stage takes its workers from; unset is default. The name must be in pools.", "type": "string", "minLength": 1 },
@@ -77,10 +83,16 @@
77
83
  "additionalProperties": false
78
84
  },
79
85
  {
80
- "description": "Commands run in a gate checkout of the task commit.",
86
+ "description": "A test stage: commands run in a gate checkout of the task commit.",
81
87
  "type": "object",
82
88
  "properties": {
83
- "stage": { "const": "check" },
89
+ "stage": {
90
+ "description": "The stage kind: test, or its older name check, which still loads.",
91
+ "oneOf": [
92
+ { "const": "test" },
93
+ { "const": "check", "description": "Older name of test; still loads.", "deprecated": true }
94
+ ]
95
+ },
84
96
  "commands": { "description": "The shell lines to run; unset uses gate.commands.", "type": "array", "items": { "$ref": "#/$defs/checkCommand" } },
85
97
  "rerun": { "description": "How many times a failed line list runs again; unset uses check.rerun.", "type": "integer", "minimum": 0 }
86
98
  },
@@ -112,7 +124,7 @@
112
124
  ]
113
125
  },
114
126
  "flow": {
115
- "description": "One repository flow: its stages, in order. At least one stage must be check, review or human. A human stage asks a person; when it is last its merge goes to integrate, and when it is not it continues with the next stage.",
127
+ "description": "One repository flow: its stages, in order. At least one stage must be test, review or human. A human stage asks a person; when it is last its merge goes to integrate, and when it is not it continues with the next stage.",
116
128
  "type": "object",
117
129
  "properties": {
118
130
  "stages": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/stage" } }
@@ -156,6 +168,7 @@
156
168
  "deprecated": true
157
169
  },
158
170
  "concurrency": {
171
+ "title": "Tasks at once",
159
172
  "description": "A cap on running tasks across every pool together. Each pool has its own cap: the sum of the counts of its workers, or the pool's own concurrency when that is smaller. This cap never raises a pool's cap; when the file does not set it, the pools' caps alone decide.",
160
173
  "type": "integer",
161
174
  "minimum": 1
@@ -171,10 +184,9 @@
171
184
  "type": "object",
172
185
  "properties": {
173
186
  "use": {
174
- "description": "The harness step, such as radian/agent.",
187
+ "description": "The harness step, such as claude/agent; unset uses the first enabled harness in the home (radian, claude, pi, codex), or radian/agent when none is enabled.",
175
188
  "type": "string",
176
- "minLength": 1,
177
- "default": "radian/agent"
189
+ "minLength": 1
178
190
  },
179
191
  "args": {
180
192
  "description": "Extra arguments the harness step passes to its command.",
@@ -195,11 +207,7 @@
195
207
  "exclusiveMinimum": 0
196
208
  }
197
209
  },
198
- "additionalProperties": false,
199
- "default": {
200
- "use": "radian/agent",
201
- "args": []
202
- }
210
+ "additionalProperties": false
203
211
  },
204
212
  "workers": {
205
213
  "description": "The repository's workers, by name. At least one. Not allowed together with worker.",
@@ -250,7 +258,7 @@
250
258
  }
251
259
  },
252
260
  "pools": {
253
- "description": "Groups of workers by pool name. dev uses the pool default, which must be defined here, unless a work stage names another pool; without pools, default holds every worker in the order written. A pool is a list of worker names, or an object with the list and a concurrency that caps the pool's running tasks below the sum of its workers' counts. Needs workers.",
261
+ "description": "Groups of workers by pool name. dev uses the pool default, which must be defined here, unless a code stage names another pool; without pools, default holds every worker in the order written. A pool is a list of worker names, or an object with the list and a concurrency that caps the pool's running tasks below the sum of its workers' counts. Needs workers.",
254
262
  "type": "object",
255
263
  "minProperties": 1,
256
264
  "additionalProperties": {
@@ -278,6 +286,13 @@
278
286
  "minLength": 1,
279
287
  "default": ".operad/worker-brief.md"
280
288
  },
289
+ "skills": {
290
+ "title": "Skills for chats",
291
+ "description": "The skill directories this repository's chats read, relative to the repository and inside it. A path may be a directory with a SKILL.md, a directory whose direct subdirectories each have one (such as .agents/skills), or a .agents directory (such as .agents), whose skills directory is read the same way. Every skill directly inside such a directory is loaded, including one added later. Empty gives the chats no skills. Task workers do not get them.",
292
+ "type": "array",
293
+ "items": { "type": "string", "minLength": 1 },
294
+ "default": [".agents/skills"]
295
+ },
281
296
  "prepare": {
282
297
  "description": "Shell lines run in every checkout dev makes (the worker's worktree, the gate checkout for verify and review, the integration checkout) after it is created or moved to a new commit and before any step uses it, for example installing dependencies. They also run, in order, in the repository's main clone after a merge fast-forwarded it. Output goes to the step's log; a failing line fails the step with reason \"prepare failed\"; in the main clone a failing line is reported in the task's Changes and the fast-forward stays.",
283
298
  "type": "array",
@@ -289,18 +304,21 @@
289
304
  "type": "object",
290
305
  "properties": {
291
306
  "commands": {
307
+ "title": "Check commands",
292
308
  "description": "The commands the verify step runs, in order, in a detached checkout of the task commit.",
293
309
  "type": "array",
294
310
  "items": { "$ref": "#/$defs/checkCommand" },
295
311
  "default": []
296
312
  },
297
313
  "commandTimeoutSecs": {
314
+ "title": "Check timeout",
298
315
  "description": "The longest one gate command may run, in seconds.",
299
316
  "type": "number",
300
317
  "exclusiveMinimum": 0,
301
318
  "default": 1800
302
319
  },
303
320
  "stallSecs": {
321
+ "title": "Check stall limit",
304
322
  "description": "How long a gate command, or an integration key command, may write nothing before dev stops its process group, in seconds. A stalled command fails the check with reason \"stall\" and goes to the worker; it is not rerun and is not a \"not the code\" wait. Unset turns the limit off.",
305
323
  "type": "number",
306
324
  "exclusiveMinimum": 0
@@ -377,12 +395,13 @@
377
395
  "type": "object",
378
396
  "properties": {
379
397
  "use": {
380
- "description": "The harness step, such as radian/agent.",
398
+ "title": "Reviewer",
399
+ "description": "The harness step, such as claude/agent; unset uses the first enabled harness in the home (radian, claude, pi, codex), or radian/agent when none is enabled.",
381
400
  "type": "string",
382
- "minLength": 1,
383
- "default": "radian/agent"
401
+ "minLength": 1
384
402
  },
385
403
  "args": {
404
+ "title": "Reviewer arguments",
386
405
  "description": "Extra arguments the harness step passes to its command.",
387
406
  "type": "array",
388
407
  "items": {
@@ -474,6 +493,7 @@
474
493
  ]
475
494
  },
476
495
  "timeoutSecs": {
496
+ "title": "Review timeout",
477
497
  "description": "The longest a review may run, in seconds.",
478
498
  "type": "number",
479
499
  "exclusiveMinimum": 0,
@@ -485,6 +505,7 @@
485
505
  "exclusiveMinimum": 0
486
506
  },
487
507
  "fixLevel": {
508
+ "title": "Reviewer rework threshold",
488
509
  "description": "The lowest finding severity that fails the gate.",
489
510
  "type": "string",
490
511
  "enum": [
@@ -518,17 +539,7 @@
518
539
  "default": 1000000
519
540
  }
520
541
  },
521
- "additionalProperties": false,
522
- "default": {
523
- "use": "radian/agent",
524
- "args": [],
525
- "timeoutSecs": 600,
526
- "fixLevel": "major",
527
- "followups": true,
528
- "retrySecs": 120,
529
- "maxFileDiffBytes": 200000,
530
- "maxDiffBytes": 1000000
531
- }
542
+ "additionalProperties": false
532
543
  },
533
544
  "integration": {
534
545
  "description": "How the integrate step builds the candidate and lands it on main.",
@@ -601,6 +612,7 @@
601
612
  "default": 2
602
613
  },
603
614
  "autoDefault": {
615
+ "title": "Auto for new plans",
604
616
  "description": "The auto level a new plan starts at: off waits for you to start tasks, run starts them by itself, merge also merges a task whose review passed.",
605
617
  "enum": ["off", "run", "merge"],
606
618
  "default": "off"
@@ -622,6 +634,7 @@
622
634
  }
623
635
  },
624
636
  "flows": {
637
+ "title": "Custom flows",
625
638
  "description": "The repository's own flows, by name. An absent map runs the built-in default. A flow is an ordered list of stages; dev adds the worktree at the start and integrate and cleanup at the end. A plan or task chooses a flow with --flow, and a flow with no review skips review. A flow whose last stage is not human goes straight to integrate after it passes.",
626
639
  "type": "object",
627
640
  "additionalProperties": { "$ref": "#/$defs/flow" }
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "@operad-io/dev",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
7
7
  },
8
8
  "dependencies": {
9
- "@operad-io/chat": "0.1.0",
10
- "@operad-io/engine": "0.1.0",
11
- "@operad-io/pool": "0.1.0",
12
- "@operad-io/review-grading": "0.1.0"
9
+ "@operad-io/access-match": "0.2.0",
10
+ "@operad-io/chat": "0.2.0",
11
+ "@operad-io/engine": "0.2.0",
12
+ "@operad-io/pool": "0.2.0",
13
+ "@operad-io/review-grading": "0.2.0"
13
14
  },
14
15
  "devDependencies": {
15
- "@operad-io/shell": "0.1.0"
16
+ "@operad-io/shell": "0.2.0",
17
+ "@operad-io/test-support": "0.0.0"
16
18
  },
17
19
  "description": "operad: the dev plugin, plans and tasks on a repository",
18
20
  "repository": {
@@ -24,6 +26,7 @@
24
26
  "files": [
25
27
  "src",
26
28
  "flows",
29
+ "skills",
27
30
  "dev.schema.json",
28
31
  "README.md",
29
32
  "LICENSE"
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: setup-dev
3
+ description: Setup Dev. Set up operad's dev for one repository: read its CI and scripts, choose the checks and agents, and propose a .operad/dev.json.
4
+ ---
5
+
6
+ Set up operad's dev for the repository at {target}. dev is operad's way of running coding
7
+ agents through verified flows (plan, work, verify, review, merge). Your job is to write a
8
+ correct `.operad/dev.json` for this repo and propose it. Do not change source code, do not
9
+ write the file yourself, do not commit, push or start anything. Reply in the language I write
10
+ to you in.
11
+
12
+ Reference, if you need a key's details: https://operad.io/docs/dev/ (the full key table)
13
+ and https://operad.io/llms.txt.
14
+
15
+ 1. Look at the repository. Run `git remote -v` and find the main branch name in {target}.
16
+ The repository needs a git remote; if it has none, say so and stop. Check which agents
17
+ are on PATH: `claude`, `pi`, `radian`. When none is, operad's own pi is the agent.
18
+
19
+ 2. Find this repo's checks. Read CI config (.github/workflows, .gitlab-ci.yml, ...), the
20
+ Makefile, package.json scripts, pyproject, Cargo.toml or whatever applies. Choose the
21
+ commands that CI runs to judge whether a change is good: tests, typecheck, lint, build.
22
+ Each must exit non-zero on failure. Order them fast to slow. Run each once on the
23
+ current checkout; if one already fails on main, tell me instead of hiding it. If the
24
+ repo has no checks, say so and leave `gate.commands` empty.
25
+
26
+ 3. Find what a fresh checkout needs. Each task runs in its own git worktree, so dependencies
27
+ are not there. Put the install step in `prepare` (for example
28
+ `bun install --frozen-lockfile` or `npm ci`), only if the repo needs one.
29
+
30
+ 4. Write the `.operad/dev.json` text. Use only keys that matter; keep it small. Use the
31
+ `workers` form, never the old `worker` form:
32
+
33
+ {
34
+ "name": "<repo name>",
35
+ "remote": "<remote>",
36
+ "mainBranch": "<main branch>",
37
+ "workers": { "<agent>": { "use": "<agent>/agent", "args": [] } },
38
+ "prepare": [ ... ],
39
+ "gate": { "commands": [ ... ], "commandTimeoutSecs": 1800 },
40
+ "reviewer": { "use": "<agent>/agent", "args": [] },
41
+ "autoDefault": "off"
42
+ }
43
+
44
+ - Workers and reviewer: use agents that are actually installed. If two or more are
45
+ installed, use a different one for the reviewer than for the worker. `use` is
46
+ `<plugin>/<step>`, such as `claude/agent`, `pi/agent`, `radian/agent`.
47
+ - Leave `autoDefault` at "off": nothing merges without me.
48
+ - Do not invent model names or flags. Leave `args` empty unless I give you some.
49
+
50
+ 5. Propose it. Call the operad `command` tool with plugin `bot`, verb `setup-dev`,
51
+ arguments `{bot}` and `{target}`, and the `.operad/dev.json` text as its input. It makes
52
+ a pending item; nothing is turned on or written until I approve it in Pending. If it
53
+ refuses, fix what it names and call it again.
54
+
55
+ 6. Report. Show me the `.operad/dev.json` you proposed, say in one line why you chose each
56
+ check command, worker and reviewer, and list anything you were unsure about. Tell me
57
+ to commit `.operad/dev.json` after I approve it (operad reads it from the main clone).
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The repository's view of the target grants: list the outward targets a
3
+ * background run may write to without asking, and remove one. The data belongs
4
+ * to the access user layer (ADR 0025 D12); this action only reads and writes
5
+ * it through `@operad-io/access-match`, so the command line and the HTTP/MCP
6
+ * action see the same list.
7
+ */
8
+
9
+ import type { ActionTypeDefinition } from "@operad-io/engine";
10
+ import { isRecord } from "@operad-io/engine";
11
+ import { readTargetGrants, revokeTargetGrants, type TargetGrant } from "@operad-io/access-match";
12
+
13
+ function grantLine(grant: TargetGrant): string {
14
+ const at = Number.isFinite(grant.at) ? new Date(grant.at).toISOString() : "unknown time";
15
+ return `${grant.flow} ${grant.target} (${grant.kind}) by ${grant.by.via}:${grant.by.id} at ${at}`;
16
+ }
17
+
18
+ /** The action that lists the target grants, or removes those of one target. */
19
+ export const accessAction: ActionTypeDefinition = {
20
+ name: "allow",
21
+ on: "repo",
22
+ args: {
23
+ type: "object",
24
+ properties: {
25
+ target: {
26
+ type: "string",
27
+ minLength: 1,
28
+ description: "The outward target to stop allowing; omit to list them.",
29
+ },
30
+ flow: {
31
+ type: "string",
32
+ minLength: 1,
33
+ description: "Only remove what this flow allows to the target.",
34
+ },
35
+ },
36
+ additionalProperties: false,
37
+ },
38
+ when() {
39
+ return true;
40
+ },
41
+ async run(ctx, args) {
42
+ const input = isRecord(args) ? args : {};
43
+ const target = typeof input["target"] === "string" ? input["target"] : undefined;
44
+ const flow = typeof input["flow"] === "string" ? input["flow"] : undefined;
45
+ if (target === undefined) {
46
+ const read = await readTargetGrants(ctx.home);
47
+ if (read.problem !== undefined) throw new Error(read.problem);
48
+ if (read.file.grants.length === 0) return "no always-allowed outward targets";
49
+ return read.file.grants.map(grantLine).join("\n");
50
+ }
51
+ const removed = await revokeTargetGrants(ctx.home, target, flow);
52
+ if (removed === 0) {
53
+ return flow === undefined
54
+ ? `no always-allowed target "${target}"`
55
+ : `no always-allowed target "${target}" for the flow "${flow}"`;
56
+ }
57
+ return `removed ${removed} always-allowed target${removed === 1 ? "" : "s"} for "${target}"`;
58
+ },
59
+ };
package/src/actions.ts CHANGED
@@ -6,10 +6,11 @@ import type {
6
6
  ObjectStore,
7
7
  StoredObject,
8
8
  } from "@operad-io/engine";
9
+ import { isRecord } from "@operad-io/engine";
9
10
  import {
10
11
  appendChange,
11
12
  appendRework,
12
- bareId,
13
+ idOfKey,
13
14
  DevError,
14
15
  DevRefusal,
15
16
  isIntegrating,
@@ -40,6 +41,7 @@ import {
40
41
  getPlan,
41
42
  getTask,
42
43
  releaseWaitingClaim,
44
+ addRepository,
43
45
  setAuto,
44
46
  setConcurrency,
45
47
  validatePlanConcurrency,
@@ -63,7 +65,7 @@ async function planOfTask(
63
65
  /** What a task action's line needs to know about the task. */
64
66
  async function taskFacts(store: ObjectStore, object: StoredObject): Promise<Facts> {
65
67
  const task = taskData(object.data);
66
- const id = bareId(object.id);
68
+ const id = idOfKey(object.id);
67
69
  return task.phase === "proposed"
68
70
  ? { id, plan: await planOfTask(store, task) }
69
71
  : { id };
@@ -92,14 +94,14 @@ export function planRefusal(
92
94
  action: PlanActionName,
93
95
  object: StoredObject,
94
96
  ): string | undefined {
95
- const said = planLine(action, planData(object.data), { id: bareId(object.id) });
97
+ const said = planLine(action, planData(object.data), { id: idOfKey(object.id) });
96
98
  return said?.kind === "refuse" ? said.text : undefined;
97
99
  }
98
100
 
99
101
  /** Whether a set-a-value action gets the value the plan already has. */
100
102
  function sameValue(action: PlanActionName, plan: PlanData, args: unknown): string | number | undefined {
101
103
  const given =
102
- typeof args === "object" && args !== null ? (args as Record<string, unknown>) : {};
104
+ isRecord(args) ? args : {};
103
105
  if (action === "auto" && given.level === plan.auto) return plan.auto;
104
106
  if (action === "priority" && given.level === plan.priority) return plan.priority;
105
107
  if (action === "concurrency" && given.count === plan.concurrency) return plan.concurrency;
@@ -115,7 +117,7 @@ const planWhy = (action: PlanActionName) =>
115
117
  /** The line for a task action whose result is already true. */
116
118
  const taskSettled = (action: TaskActionName) =>
117
119
  (object: StoredObject): string | undefined => {
118
- const said = taskLine(action, taskData(object.data), { id: bareId(object.id) });
120
+ const said = taskLine(action, taskData(object.data), { id: idOfKey(object.id) });
119
121
  return said?.kind === "done" ? said.text : undefined;
120
122
  };
121
123
 
@@ -124,7 +126,7 @@ const planSettled = (action: PlanActionName) =>
124
126
  (object: StoredObject, args: unknown): string | undefined => {
125
127
  const plan = planData(object.data);
126
128
  const value = sameValue(action, plan, args);
127
- const said = planLine(action, plan, { id: bareId(object.id), value }, value !== undefined);
129
+ const said = planLine(action, plan, { id: idOfKey(object.id), value }, value !== undefined);
128
130
  return said?.kind === "done" ? said.text : undefined;
129
131
  };
130
132
 
@@ -176,16 +178,19 @@ export const PLAN_RANKS: Record<PlanActionName, (state: Parameters<typeof planDa
176
178
  cancel: () => 9,
177
179
  };
178
180
 
181
+ /** The rank of the action that adds a task: after the plan's own actions, before cancel. */
182
+ export const PLAN_CREATE_TASK_RANK = 4;
183
+
179
184
  /** Reads a required enum argument; the kernel checks it first, this is for types. */
180
185
  function enumArgument<T extends string>(
181
186
  args: unknown,
182
187
  field: string,
183
188
  allowed: readonly T[],
184
189
  ): T {
185
- if (typeof args !== "object" || args === null) {
190
+ if (!isRecord(args)) {
186
191
  throw new DevError(field, `must be one of ${allowed.join(", ")}`);
187
192
  }
188
- const raw = (args as Record<string, unknown>)[field];
193
+ const raw = args[field];
189
194
  if (typeof raw !== "string" || !(allowed as readonly string[]).includes(raw)) {
190
195
  throw new DevError(field, `must be one of ${allowed.join(", ")}`);
191
196
  }
@@ -246,7 +251,7 @@ async function claimAndAnswer(
246
251
  // action that starts after a competing one wrote must still lose.
247
252
  const seen = ctx.object.version ?? object.version;
248
253
  if (ctx.answer === undefined) {
249
- throw new DevRefusal(`${bareId(ctx.object.id)} is not waiting for an answer now`);
254
+ throw new DevRefusal(`${idOfKey(ctx.object.id)} is not waiting for an answer now`);
250
255
  }
251
256
  const claim = await claimWaitingTask(
252
257
  ctx.store,
@@ -284,7 +289,7 @@ const mergeTask: ActionTypeDefinition = {
284
289
  // The merge step would refuse later, in the background; say so now.
285
290
  throw new DevError(
286
291
  "merge",
287
- `${bareId(ctx.object.id)} has no verified commit; run operad dev:reverify ${bareId(ctx.object.id)} first`,
292
+ `${idOfKey(ctx.object.id)} has no verified commit; run operad dev:reverify ${idOfKey(ctx.object.id)} first`,
288
293
  );
289
294
  }
290
295
  return { ...latest, brief: appendChange(latest.brief, "merge requested") };
@@ -399,7 +404,56 @@ const reverifyTaskAction: ActionTypeDefinition = {
399
404
  },
400
405
  };
401
406
 
407
+ /**
408
+ * Registers a repository from a client that talks to a serve on another
409
+ * machine. The path is on the serve's machine; the refusal is `addRepository`'s,
410
+ * the same line the command prints.
411
+ */
412
+ const repoAddAction: ActionTypeDefinition = {
413
+ name: "repo-add",
414
+ args: {
415
+ type: "object",
416
+ properties: {
417
+ path: {
418
+ type: "string",
419
+ minLength: 1,
420
+ description: "The repository's path on the machine that runs serve.",
421
+ },
422
+ name: {
423
+ type: "string",
424
+ minLength: 1,
425
+ description: "The name to register it under; the folder name when left out.",
426
+ },
427
+ },
428
+ required: ["path"],
429
+ additionalProperties: false,
430
+ },
431
+ confirm: true,
432
+ when() {
433
+ return true;
434
+ },
435
+ async run(ctx, args) {
436
+ const given =
437
+ isRecord(args) ? args : {};
438
+ const path = given.path;
439
+ const name = given.name;
440
+ if (typeof path !== "string") {
441
+ throw new DevError("path", "repo add needs a path");
442
+ }
443
+ if (name !== undefined && typeof name !== "string") {
444
+ throw new DevError("name", "must be a string");
445
+ }
446
+ const repository = await addRepository(ctx.store, {
447
+ path,
448
+ ...(name === undefined ? {} : { name }),
449
+ cwd: ctx.cwd,
450
+ });
451
+ return `added ${repository.name} (${repository.path})`;
452
+ },
453
+ };
454
+
402
455
  export const actions: readonly ActionTypeDefinition[] = [
456
+ repoAddAction,
403
457
  {
404
458
  name: "confirm",
405
459
  on: "plan",
@@ -443,7 +497,13 @@ export const actions: readonly ActionTypeDefinition[] = [
443
497
  why: planWhy("cancel"),
444
498
  settled: planSettled("cancel"),
445
499
  async run(ctx) {
446
- await cancelPlan(ctx.store, ctx.object.id, { runs: ctx.runs });
500
+ const cancelled = await cancelPlan(ctx.store, ctx.object.id, {
501
+ runs: ctx.runs,
502
+ home: ctx.home,
503
+ });
504
+ return cancelled.merged.length === 0
505
+ ? undefined
506
+ : `${cancelled.merged.map(idOfKey).join(", ")} merged before the cancel and stays merged`;
447
507
  },
448
508
  },
449
509
  {
@@ -459,7 +519,11 @@ export const actions: readonly ActionTypeDefinition[] = [
459
519
  why: taskWhy("cancel"),
460
520
  settled: taskSettled("cancel"),
461
521
  async run(ctx) {
462
- await cancelTask(ctx.store, ctx.object.id, { runs: ctx.runs });
522
+ const cancelled = await cancelTask(ctx.store, ctx.object.id, {
523
+ runs: ctx.runs,
524
+ home: ctx.home,
525
+ });
526
+ return cancelled.alreadyMerged;
463
527
  },
464
528
  },
465
529
  {
@@ -549,7 +613,7 @@ export const actions: readonly ActionTypeDefinition[] = [
549
613
  async run(ctx, args) {
550
614
  const level = enumArgument(args, "level", PRIORITIES);
551
615
  await setPriority(ctx.store, ctx.object.id, level);
552
- const id = bareId(ctx.object.id);
616
+ const id = idOfKey(ctx.object.id);
553
617
  if (planData((await getPlan(ctx.store, ctx.object.id)).data).auto === "off") {
554
618
  return `${id} has auto off: the scheduler does not start its tasks; run operad dev:auto ${id} --level merge`;
555
619
  }
@@ -580,10 +644,7 @@ export const actions: readonly ActionTypeDefinition[] = [
580
644
  why: planWhy("concurrency"),
581
645
  settled: planSettled("concurrency"),
582
646
  async run(ctx, args) {
583
- const count =
584
- typeof args === "object" && args !== null
585
- ? (args as Record<string, unknown>).count
586
- : undefined;
647
+ const count = isRecord(args) ? args.count : undefined;
587
648
  await setConcurrency(ctx.store, ctx.object.id, validatePlanConcurrency(count));
588
649
  },
589
650
  },