@operad-io/dev 0.1.1 → 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/src/model.ts CHANGED
@@ -1,28 +1,55 @@
1
1
  /** The objects the dev plugin owns, and the pure rules that change them. */
2
2
 
3
- import type { FlowDefinition, ObjectStore, StoredObject } from "@operad-io/engine";
3
+ import type {
4
+ FlowDefinition,
5
+ ObjectStore,
6
+ PluginFact,
7
+ StoredObject,
8
+ } from "@operad-io/engine";
4
9
  import type { ReviewHistoryEntry, ReviewSettingsUsed } from "./rework.ts";
10
+ import type { ModelErrorInfo } from "./model-error.ts";
5
11
  import type { WaitKind } from "./waits.ts";
6
12
  import { isRecord, oneLine } from "@operad-io/engine";
7
13
 
8
- /**
9
- * Every object of a type, following the store's pages. The store returns one
14
+ /** Every object of a type, following the store's pages. The store returns one
10
15
  * page at a time; an id scan must not stop at its default limit.
11
16
  */
12
17
  export async function listAll(
13
18
  store: ObjectStore,
14
19
  type: string,
20
+ where?: Readonly<Record<string, unknown>> | undefined,
15
21
  ): Promise<StoredObject[]> {
16
22
  const objects: StoredObject[] = [];
17
23
  let cursor: string | undefined;
18
24
  for (;;) {
19
- const page = await store.list(type, cursor === undefined ? {} : { cursor });
25
+ const page = await store.list(type, {
26
+ ...(where === undefined ? {} : { where }),
27
+ ...(cursor === undefined ? {} : { cursor }),
28
+ });
20
29
  objects.push(...page.objects);
21
30
  if (page.next === undefined) return objects;
22
31
  cursor = page.next;
23
32
  }
24
33
  }
25
34
 
35
+ /** Every fact of one object, following the store's pages. */
36
+ export async function allFactsOf(
37
+ store: ObjectStore,
38
+ object: Pick<StoredObject, "type" | "id">,
39
+ ): Promise<PluginFact[]> {
40
+ const facts: PluginFact[] = [];
41
+ let cursor: string | undefined;
42
+ for (;;) {
43
+ const page = await store.facts(
44
+ { type: object.type, id: object.id },
45
+ cursor === undefined ? {} : { cursor },
46
+ );
47
+ facts.push(...page.facts);
48
+ if (page.next === undefined) return facts;
49
+ cursor = page.next;
50
+ }
51
+ }
52
+
26
53
  /** A plan is a request the owner confirmed into work. */
27
54
  export type PlanStatus = "draft" | "confirmed" | "paused" | "cancelled";
28
55
 
@@ -238,6 +265,8 @@ export interface ReviewRunRecord {
238
265
  readonly outcome: ReviewRunOutcome;
239
266
  readonly run?: string | null;
240
267
  readonly message?: string | null;
268
+ /** What the model error said, when this run ended on one. */
269
+ readonly modelError?: ModelErrorInfo | null;
241
270
  /** The findings a report run returned, with pre-existing marks. */
242
271
  readonly findings?: readonly ReviewFinding[] | null;
243
272
  readonly verified?: readonly string[] | null;
@@ -648,6 +677,17 @@ export function validateSlug(slug: unknown): string {
648
677
  return slug;
649
678
  }
650
679
 
680
+ /** The slug an action takes from a title when it is given none. */
681
+ export function slugFromTitle(title: unknown, fallback: string): string {
682
+ const text = typeof title === "string" ? title : "";
683
+ const words = text
684
+ .toLowerCase()
685
+ .replace(/[^a-z0-9]+/g, "-")
686
+ .replace(/^-+|-+$/g, "");
687
+ const slug = words.slice(0, 48).replace(/-+$/g, "");
688
+ return slug.length === 0 ? fallback : slug;
689
+ }
690
+
651
691
  export function validateTitle(title: unknown): string {
652
692
  if (typeof title !== "string" || title.trim().length === 0) {
653
693
  throw new DevError("title", "must be a non-empty string");
@@ -707,7 +747,7 @@ function numberById(
707
747
  let highest = 0;
708
748
  for (const object of objects) {
709
749
  // The store key carries the repository; the number lives in the bare id.
710
- const parsed = parseId(bareId(object.id), kind);
750
+ const parsed = parseId(idOfKey(object.id), kind);
711
751
  if (parsed !== undefined && parsed.number > highest) {
712
752
  highest = parsed.number;
713
753
  }
@@ -725,7 +765,7 @@ export function storeKey(repository: string, id: string): string {
725
765
  }
726
766
 
727
767
  /** The id a person sees and types: the key without its repository prefix. */
728
- export function bareId(key: string): string {
768
+ export function idOfKey(key: string): string {
729
769
  const at = key.indexOf("/");
730
770
  return at < 0 ? key : key.slice(at + 1);
731
771
  }
@@ -741,7 +781,7 @@ export function dependencyKey(repository: string, entry: string): string {
741
781
 
742
782
  /** How a dependency is named in a note: bare in its own repository. */
743
783
  export function dependencyLabel(repository: string, key: string): string {
744
- return keyRepository(key) === repository ? bareId(key) : key;
784
+ return keyRepository(key) === repository ? idOfKey(key) : key;
745
785
  }
746
786
 
747
787
  /** The repository part of a store key. */
@@ -761,11 +801,7 @@ export async function nextId(
761
801
  repository: string,
762
802
  slug: string,
763
803
  ): Promise<string> {
764
- const all = await listAll(store, type);
765
- const mine = all.filter(
766
- (object) =>
767
- isRecord(object.data) && object.data.repository === repository,
768
- );
804
+ const mine = await listAll(store, type, { repository });
769
805
  let number = numberById(mine, type) + 1;
770
806
  for (;;) {
771
807
  const id = formatId(type, number, slug);
@@ -1024,16 +1060,6 @@ export function briefBody(brief: string): string {
1024
1060
  return splitBrief(brief).body;
1025
1061
  }
1026
1062
 
1027
- /** The Markdown of the rework sections, without the changes section. */
1028
- export function reworkBody(brief: string): string {
1029
- return splitBrief(brief).reworks;
1030
- }
1031
-
1032
- /** The Markdown of the trailing changes section. */
1033
- export function changesBody(brief: string): string {
1034
- return splitBrief(brief).changes;
1035
- }
1036
-
1037
1063
  /** Replaces the body and records the edit, unless the body did not change. */
1038
1064
  export function editBrief(brief: string, body: string): string {
1039
1065
  if (briefBody(brief) === body.replace(/\r\n/g, "\n").trimEnd()) return brief;
@@ -1139,23 +1165,10 @@ export function planNote(plan: PlanData): string {
1139
1165
  return `${parts.join(" · ")} // ${plan.concurrency}`;
1140
1166
  }
1141
1167
 
1142
- export function planDataOf(data: Record<string, unknown>): PlanData {
1143
- return planData(data);
1144
- }
1145
-
1146
- export function taskDataOf(data: Record<string, unknown>): TaskData {
1147
- return taskData(data);
1148
- }
1149
-
1150
1168
  export function priorityIndex(priority: Priority): number {
1151
1169
  return PRIORITIES.indexOf(priority);
1152
1170
  }
1153
1171
 
1154
- export function higherPriority(priority: Priority): Priority | undefined {
1155
- const index = priorityIndex(priority);
1156
- return index <= 0 ? undefined : PRIORITIES[index - 1];
1157
- }
1158
-
1159
1172
  /** A task is open until it merged or was cancelled. */
1160
1173
  export function isOpenTask(task: TaskData): boolean {
1161
1174
  return task.phase !== "merged" && task.phase !== "cancelled";
package/src/notcode.ts CHANGED
@@ -37,6 +37,7 @@ import { waitFor } from "./gate.ts";
37
37
  import { flakyLoadLimitOf } from "./flaky.ts";
38
38
  import { readSince, type CheckRun } from "./rerun.ts";
39
39
  import { isRecord } from "@operad-io/engine";
40
+ import { loadsFromLog, underLoad, type CheckLoad, type CheckLoadReading } from "./check-load.ts";
40
41
 
41
42
  /** The kind of a "not the code" result. */
42
43
  export type NotCodeKind = "limit" | "signal" | "test-timeout" | "rerun-passed";
@@ -177,14 +178,35 @@ function worthAnotherRun(found: NotCode | undefined): found is NotCode {
177
178
  }
178
179
 
179
180
  /** The waiting line for a check that came out the same way twice. */
180
- export function notCodeCause(found: NotCode, load: MachineLoad): string {
181
- return `${found.what} twice under load ${Math.round(load.load1)} on ${load.cores} cores`;
181
+ export function notCodeCause(found: NotCode, load: CheckLoadReading): string {
182
+ const shown = load.unknown === true ? undefined : String(Math.round(load.load1));
183
+ return `${found.what} twice ${underLoad(load, shown)}`;
182
184
  }
183
185
 
184
- /** The load when one run of a command started and when it ended. */
185
- export interface CheckLoad {
186
- readonly start: MachineLoad;
187
- readonly end: MachineLoad;
186
+ /** The busiest of a run's two readings, keeping an unknown reading as it is. */
187
+ function peakOf(load: CheckLoad): CheckLoadReading {
188
+ if (load.start.unknown === true) return load.start;
189
+ if (load.end.unknown === true) return load.end;
190
+ return load.end.load1 >= load.start.load1 ? load.end : load.start;
191
+ }
192
+
193
+ /**
194
+ * A run's load: what remote-check.sh wrote into its part of the log, else the
195
+ * local readings around it. A remote line that says unknown is not replaced.
196
+ * The part starts where the run's first command said its output began, not at
197
+ * a file size read before the run, which a buffered logger can leave stale.
198
+ */
199
+ function loadOfRun(
200
+ path: string | undefined,
201
+ checked: CheckRun,
202
+ start: MachineLoad,
203
+ end: MachineLoad,
204
+ ): CheckLoad {
205
+ if (path !== undefined && checked.logStart !== undefined) {
206
+ const remote = loadsFromLog(readSince(path, checked.logStart));
207
+ if (remote !== undefined) return remote;
208
+ }
209
+ return { start, end };
188
210
  }
189
211
 
190
212
  /**
@@ -202,15 +224,19 @@ function timeoutAlone(
202
224
  const limit = flakyLoadLimitOf(flakyLimit, load.end);
203
225
  // Busy means above the limit, as `flaky.ts` reads it. The reading spans the whole
204
226
  // check run (full suite and alone rerun), so a quiet reading is a strict test.
205
- if (load.start.load1 > limit || load.end.load1 > limit) return undefined;
227
+ // An unknown reading is judged as quiet, never against the local load.
228
+ const busy = (reading: CheckLoadReading): boolean =>
229
+ reading.unknown !== true && reading.load1 > limit;
230
+ if (busy(load.start) || busy(load.end)) return undefined;
206
231
  const outcome = checked.outcome;
207
232
  if (outcome === undefined) return undefined;
208
233
  const data = isRecord(outcome.data) ? outcome.data : {};
209
234
  const names = failedTests(facts.log).map((test) => test.name).join("; ");
210
235
  const seconds = testTimeoutOf(facts.line) / 1000;
211
- const peak = Math.max(load.start.load1, load.end.load1);
236
+ const peak = peakOf(load);
237
+ const shown = peak.unknown === true ? undefined : String(Number(peak.load1.toFixed(1)));
212
238
  const log = typeof data.log === "string" ? `; log: ${data.log}` : "";
213
- const message = `the failed test "${names}" timed out at ${seconds} s when run alone under load ${Number(peak.toFixed(1))} on ${load.end.cores} cores${log}`;
239
+ const message = `the failed test "${names}" timed out at ${seconds} s when run alone ${underLoad(peak, shown)}${log}`;
214
240
  return { ...checked, outcome: { ...outcome, data: { ...data, message } } };
215
241
  }
216
242
 
@@ -266,6 +292,8 @@ export async function runCheckSteadily(input: {
266
292
  readonly flakyLimit?: number | undefined;
267
293
  readonly signal?: AbortSignal | undefined;
268
294
  readonly log?: ((text: string) => Promise<unknown> | unknown) | undefined;
295
+ /** The step's log; the remote load lines are read from each run's part of it. */
296
+ readonly logPath?: string | undefined;
269
297
  }): Promise<SteadyCheck> {
270
298
  const firstStart = currentLoad();
271
299
  let peak = firstStart;
@@ -276,20 +304,28 @@ export async function runCheckSteadily(input: {
276
304
  };
277
305
  const first = await input.run();
278
306
  const firstEnd = sample();
279
- const loads: CheckLoad[] = [{ start: firstStart, end: firstEnd }];
280
- const firstCode = timeoutAlone(first, { start: firstStart, end: firstEnd }, input.flakyLimit);
307
+ const firstLoad = loadOfRun(input.logPath, first, firstStart, firstEnd);
308
+ const loads: CheckLoad[] = [firstLoad];
309
+ const firstCode = timeoutAlone(first, firstLoad, input.flakyLimit);
281
310
  if (firstCode !== undefined) return { checked: firstCode, runs: 1, load: peak, loads };
282
311
  if (!worthAnotherRun(classifyRun(first))) {
283
312
  return { checked: first, runs: 1, load: peak, loads };
284
313
  }
285
- if (!(await waitForQuiet(input.limit, input.signal, input.log ?? (() => {})))) {
314
+ // A remote check read its own host's load; there is no local reading to wait
315
+ // on, and an unknown one must not fall back to this machine either.
316
+ const quiet =
317
+ firstLoad.start.host !== undefined || firstLoad.start.unknown === true
318
+ ? true
319
+ : await waitForQuiet(input.limit, input.signal, input.log ?? (() => {}));
320
+ if (!quiet) {
286
321
  return { checked: first, runs: 1, load: peak, loads, cancelled: true };
287
322
  }
288
323
  const secondStart = sample();
289
324
  const second = await input.run();
290
325
  const after = sample();
291
- loads.push({ start: secondStart, end: after });
292
- const secondCode = timeoutAlone(second, { start: secondStart, end: after }, input.flakyLimit);
326
+ const secondLoad = loadOfRun(input.logPath, second, secondStart, after);
327
+ loads.push(secondLoad);
328
+ const secondCode = timeoutAlone(second, secondLoad, input.flakyLimit);
293
329
  if (secondCode !== undefined) return { checked: secondCode, runs: 2, load: peak, loads };
294
330
  const found = classifyRun(second);
295
331
  if (!worthAnotherRun(found)) {
@@ -300,6 +336,6 @@ export async function runCheckSteadily(input: {
300
336
  runs: 2,
301
337
  load: peak,
302
338
  loads,
303
- notCode: { cause: notCodeCause(found, after), kind: found.kind },
339
+ notCode: { cause: notCodeCause(found, secondLoad.end), kind: found.kind },
304
340
  };
305
341
  }
package/src/places.ts CHANGED
@@ -13,6 +13,7 @@ import type { StepContext } from "@operad-io/engine";
13
13
  import { taskPlaceWait } from "./place-wait.ts";
14
14
  import { withLockFile, waitForChange } from "@operad-io/engine/platform";
15
15
  import { WaitEntry, type CheckKind } from "./place-order.ts";
16
+ import { repositoryPathKey } from "./repository-key.ts";
16
17
 
17
18
  export { VERIFY_STARVATION_MS, type CheckKind } from "./place-order.ts";
18
19
 
@@ -105,9 +106,8 @@ class PlaceBusy extends Error {
105
106
 
106
107
  /** The lock files of the repository's places, next to the home's. */
107
108
  function repositoryKey(repository: RepositoryPlaces): string {
108
- const hash = new Bun.CryptoHasher("sha1").update(repository.path).digest("hex");
109
109
  const name = repository.name.replace(/[^A-Za-z0-9._-]/g, "_");
110
- return `repo-${name}-${hash.slice(0, 8)}`;
110
+ return `repo-${name}-${repositoryPathKey(repository.path).slice(0, 8)}`;
111
111
  }
112
112
 
113
113
  /**
package/src/prepare.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * plain checkout: dev installs and links nothing itself.
5
5
  */
6
6
 
7
- import { isRecord, messageOf, type StepContext, type StepRunOptions } from "@operad-io/engine";
7
+ import { isRecord, messageOf, type JsonValue, type StepContext, type StepRunOptions } from "@operad-io/engine";
8
8
 
9
9
  import type { CommandRunner } from "./mainclone.ts";
10
10
  import type { DevSettings } from "./settings.ts";
@@ -12,13 +12,18 @@ import type { DevSettings } from "./settings.ts";
12
12
  /** The reason a step reports when a prepare command failed. */
13
13
  export const PREPARE_FAILED = "prepare failed";
14
14
 
15
+ /** The profile every step of a dev task uses: the default's denies, not its asks (ADR 0025 D9). */
16
+ export function taskStepAccess(access: JsonValue): JsonValue {
17
+ return { ...(isRecord(access) ? access : {}), defaultAsks: false };
18
+ }
19
+
15
20
  export function stepOptions(ctx: StepContext, cwd: string): StepRunOptions {
16
21
  return {
17
22
  runId: ctx.runId,
18
23
  cwd,
19
24
  ...(ctx.object === undefined ? {} : { object: ctx.object }),
20
25
  params: ctx.params,
21
- access: ctx.access,
26
+ access: taskStepAccess(ctx.access),
22
27
  ...(ctx.trigger === undefined ? {} : { trigger: ctx.trigger }),
23
28
  signal: ctx.signal,
24
29
  };
@@ -5,12 +5,15 @@
5
5
  * one, or whose name dev.json also defines.
6
6
  */
7
7
 
8
+ import { messageOf } from "@operad-io/engine";
8
9
  import { createHash } from "node:crypto";
9
10
  import { existsSync, readdirSync, statSync } from "node:fs";
10
11
  import { join } from "node:path";
11
12
  import { pathToFileURL } from "node:url";
12
13
  import type { FlowDefinition, StepShape } from "@operad-io/engine";
13
14
  import type { DevSettings } from "./settings.ts";
15
+ import type { DevStage } from "./flow-compiler.ts";
16
+ import { isWorkQuestionWait } from "./waits.ts";
14
17
  import { isRecord } from "@operad-io/engine";
15
18
 
16
19
  const FLOW_SUFFIX = ".flow.ts";
@@ -40,7 +43,7 @@ function targetsOf(step: Record<string, unknown>): string[] {
40
43
  /**
41
44
  * The reason a flow breaks a hard rule, or undefined when it keeps both: the
42
45
  * step before a finished end is integrate (or the cleanup that follows it), and
43
- * there is at least one check, review or human step.
46
+ * there is at least one test, review or human step.
44
47
  */
45
48
  export function flowProblem(flow: unknown): string | undefined {
46
49
  if (!isRecord(flow) || !Array.isArray(flow.steps) || typeof flow.entry !== "string") {
@@ -49,9 +52,14 @@ export function flowProblem(flow: unknown): string | undefined {
49
52
  const steps = flow.steps.filter(isRecord);
50
53
  const decides = steps.some((step) => {
51
54
  const use = useOf(step);
52
- return step.kind === "wait_person" || use === "dev/verify" || use === "dev/review";
55
+ // A worker's own question keeps the worker going; it is not a step that
56
+ // asks a person what the task should do.
57
+ const asked = step.kind === "wait_person" && !(
58
+ typeof step.id === "string" && isWorkQuestionWait(step.id)
59
+ );
60
+ return asked || use === "dev/verify" || use === "dev/review";
53
61
  });
54
- if (!decides) return "needs at least one check, review or human step";
62
+ if (!decides) return "needs at least one test, review or human step";
55
63
  if (!steps.some((step) => useOf(step) === "dev/integrate")) {
56
64
  return "has no integrate step: a change reaches main only through integrate";
57
65
  }
@@ -136,7 +144,7 @@ export async function loadProjectFlows(
136
144
  } catch (error) {
137
145
  refused.set(
138
146
  name,
139
- `${where}: could not be loaded: ${error instanceof Error ? error.message : String(error)}`,
147
+ `${where}: could not be loaded: ${messageOf(error)}`,
140
148
  );
141
149
  continue;
142
150
  }
@@ -158,3 +166,126 @@ export async function loadProjectFlows(
158
166
  }
159
167
  return { flows, refused };
160
168
  }
169
+
170
+ /**
171
+ * The names `dev.flowList` shows for a repository, with `default` first. It
172
+ * names a TypeScript file without loading it, so an action's schema can list
173
+ * the choices synchronously.
174
+ */
175
+ export function flowNamesOf(
176
+ repositoryPath: string,
177
+ settings: DevSettings,
178
+ ): readonly string[] {
179
+ const names = Object.keys(settings.flows);
180
+ const directory = join(repositoryPath, PROJECT_FLOWS_DIR);
181
+ if (existsSync(directory)) {
182
+ const files = readdirSync(directory)
183
+ .filter((item) => item.endsWith(FLOW_SUFFIX))
184
+ .sort();
185
+ for (const file of files) names.push(file.slice(0, -FLOW_SUFFIX.length));
186
+ }
187
+ const unique = [...new Set(names)];
188
+ const at = unique.indexOf("default");
189
+ if (at < 0) {
190
+ unique.unshift("default");
191
+ } else if (at > 0) {
192
+ unique.splice(at, 1);
193
+ unique.unshift("default");
194
+ }
195
+ return unique;
196
+ }
197
+
198
+ /** One flow of a repository, as a client lists it. */
199
+ export interface FlowInfo {
200
+ readonly name: string;
201
+ /** Where the flow comes from. */
202
+ readonly source: "dev.json" | "typescript" | "built-in";
203
+ /** A dev.json flow or the built-in default: its stages. */
204
+ readonly stages?: readonly unknown[];
205
+ /** A TypeScript flow: the steps dev reads when it loads the file. */
206
+ readonly steps?: readonly { readonly id: string; readonly kind: string; readonly use?: string }[];
207
+ /** Why dev refuses the flow; the flow starts no task. */
208
+ readonly refused?: string;
209
+ }
210
+
211
+ /**
212
+ * The stages of the built-in default flow, with the parameters this
213
+ * repository's `worker`, `reviewer` and `gate` settings give them (ADR 0020
214
+ * D7), so a client can show them and start an edited copy from them. These
215
+ * three settings carry no secrets.
216
+ */
217
+ export function defaultFlowStages(settings: DevSettings): DevStage[] {
218
+ return [
219
+ { stage: "code", use: settings.worker.use, args: [...settings.worker.args] },
220
+ { stage: "test", commands: [...settings.gate.commands] },
221
+ { stage: "review", use: settings.reviewer.use, args: [...settings.reviewer.args] },
222
+ { stage: "human" },
223
+ ];
224
+ }
225
+
226
+ /**
227
+ * Every flow a repository has: those of dev.json, the TypeScript files in
228
+ * `.operad/flows`, and the built-in default when nothing names `default`. A
229
+ * TypeScript file dev refuses is listed with dev's reason.
230
+ */
231
+ export async function listRepositoryFlows(
232
+ repositoryPath: string,
233
+ repository: string,
234
+ settings: DevSettings,
235
+ ): Promise<FlowInfo[]> {
236
+ const infos: FlowInfo[] = Object.entries(settings.flows).map(([name, flow]) => ({
237
+ name,
238
+ source: "dev.json",
239
+ stages: flow.stages as readonly unknown[],
240
+ }));
241
+ const loaded = await loadProjectFlows(repositoryPath, repository, settings);
242
+ const directory = join(repositoryPath, PROJECT_FLOWS_DIR);
243
+ const files = existsSync(directory)
244
+ ? readdirSync(directory).filter((file) => file.endsWith(FLOW_SUFFIX)).sort()
245
+ : [];
246
+ for (const file of files) {
247
+ const name = file.slice(0, -FLOW_SUFFIX.length);
248
+ const reason = loaded.refused.get(name);
249
+ const flow = loaded.flows.get(name);
250
+ infos.push({
251
+ name,
252
+ source: "typescript",
253
+ ...(flow === undefined
254
+ ? {}
255
+ : {
256
+ steps: flow.steps.map((step) => {
257
+ const use = useOf(step as unknown as Record<string, unknown>);
258
+ return {
259
+ id: step.id,
260
+ kind: step.kind,
261
+ ...(use === undefined ? {} : { use }),
262
+ };
263
+ }),
264
+ }),
265
+ ...(reason === undefined ? {} : { refused: reason }),
266
+ });
267
+ }
268
+ if (!infos.some((info) => info.name === "default")) {
269
+ infos.unshift({
270
+ name: "default",
271
+ source: "built-in",
272
+ stages: defaultFlowStages(settings),
273
+ });
274
+ }
275
+ return infos;
276
+ }
277
+
278
+ /**
279
+ * The reason a dev.json value cannot be written because of a TypeScript flow:
280
+ * a flow of the same name is in `.operad/flows`.
281
+ */
282
+ export function flowClash(repositoryPath: string, flows: unknown): string | undefined {
283
+ if (!isRecord(flows)) return undefined;
284
+ for (const name of Object.keys(flows)) {
285
+ const where = `${PROJECT_FLOWS_DIR}/${name}${FLOW_SUFFIX}`;
286
+ if (existsSync(join(repositoryPath, where))) {
287
+ return `flow "${name}" is defined in dev.json and in ${where}; keep one`;
288
+ }
289
+ }
290
+ return undefined;
291
+ }