operbe 1.0.0-rc.2 → 1.0.0-rc.3

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.
Files changed (84) hide show
  1. package/README.md +26 -22
  2. package/conformance/describe/edge/body.json +1 -1
  3. package/conformance/describe/edge/digest +1 -1
  4. package/conformance/describe/edge/project/operbe.md +1 -1
  5. package/conformance/describe/example/body.json +1 -1
  6. package/conformance/describe/example/digest +1 -1
  7. package/conformance/describe/example/project/behaviors/B-0001.md +13 -9
  8. package/conformance/describe/example/project/behaviors/B-0002.md +1 -1
  9. package/conformance/describe/example/project/behaviors/B-0003.md +2 -2
  10. package/conformance/describe/example/project/behaviors/B-0004.md +2 -2
  11. package/conformance/describe/example/project/behaviors/B-0005.md +2 -2
  12. package/conformance/describe/example/project/behaviors/coverage/mcp.md +9 -0
  13. package/conformance/describe/example/project/operbe.md +9 -5
  14. package/conformance/diff/core/a/behaviors/B-0002.md +1 -1
  15. package/conformance/diff/core/a/behaviors/B-0003.md +1 -1
  16. package/conformance/diff/core/a/operbe.md +5 -5
  17. package/conformance/diff/core/b/behaviors/B-0002.md +1 -1
  18. package/conformance/diff/core/b/behaviors/B-0003.md +1 -1
  19. package/conformance/diff/core/b/operbe.md +5 -5
  20. package/conformance/diff/core/changes.json +45 -17
  21. package/conformance/diff/declared/a/operbe.md +1 -1
  22. package/conformance/diff/declared/b/operbe.md +1 -1
  23. package/conformance/diff/reworded/a/behaviors/B-0002.md +1 -1
  24. package/conformance/diff/reworded/a/behaviors/B-0003.md +1 -1
  25. package/conformance/diff/reworded/a/operbe.md +5 -5
  26. package/conformance/diff/reworded/b/behaviors/B-0002.md +1 -1
  27. package/conformance/diff/reworded/b/behaviors/B-0003.md +1 -1
  28. package/conformance/diff/reworded/b/operbe.md +5 -5
  29. package/dist/check.d.ts +1 -1
  30. package/dist/check.js +124 -67
  31. package/dist/cli.js +19 -15
  32. package/dist/describe.js +23 -20
  33. package/dist/diff.js +35 -24
  34. package/dist/indexes.js +20 -12
  35. package/dist/read.d.ts +8 -6
  36. package/dist/read.js +39 -15
  37. package/dist/reconcile.d.ts +2 -2
  38. package/dist/reconcile.js +12 -13
  39. package/dist/version.d.ts +1 -1
  40. package/dist/version.js +1 -1
  41. package/package.json +3 -3
  42. package/schema/description.schema.json +26 -9
  43. package/skills/operbe/SKILL.md +42 -16
  44. package/skills/operbe/example/behaviors/B-0001.md +13 -9
  45. package/skills/operbe/example/behaviors/B-0002.md +1 -1
  46. package/skills/operbe/example/behaviors/B-0003.md +2 -2
  47. package/skills/operbe/example/behaviors/B-0004.md +2 -2
  48. package/skills/operbe/example/behaviors/B-0005.md +2 -2
  49. package/skills/operbe/example/behaviors/coverage/mcp.md +9 -0
  50. package/skills/operbe/example/operbe.md +9 -5
  51. package/skills/operbe/references/actions.md +226 -0
  52. package/skills/operbe/references/adopting.md +6 -6
  53. package/skills/operbe/references/behaviors.md +75 -59
  54. package/skills/operbe/references/formats.md +69 -51
  55. package/skills/operbe/references/operations.md +13 -14
  56. package/skills/operbe/references/tandem.md +31 -30
  57. package/skills/operbe/templates/{client-action.md → action.md} +3 -3
  58. package/skills/operbe/templates/behavior.md +1 -1
  59. package/skills/operbe/templates/coverage.md +1 -1
  60. package/skills/operbe/templates/operbe.md +1 -1
  61. package/skills/operbe/references/client-actions.md +0 -211
  62. /package/conformance/describe/example/project/{client-actions → actions}/archive-conversation.md +0 -0
  63. /package/conformance/describe/example/project/{client-actions → actions}/show-conversations.md +0 -0
  64. /package/conformance/describe/example/project/{client-actions → actions}/start-retitle.md +0 -0
  65. /package/conformance/describe/example/project/{client-actions → actions}/unarchive-conversation.md +0 -0
  66. /package/conformance/diff/core/a/{client-actions → actions}/archive-conversation.md +0 -0
  67. /package/conformance/diff/core/a/{client-actions → actions}/show-conversations.md +0 -0
  68. /package/conformance/diff/core/a/{client-actions → actions}/start-retitle.md +0 -0
  69. /package/conformance/diff/core/a/{client-actions → actions}/unarchive-conversation.md +0 -0
  70. /package/conformance/diff/core/b/{client-actions → actions}/archive-conversation.md +0 -0
  71. /package/conformance/diff/core/b/{client-actions → actions}/show-conversations.md +0 -0
  72. /package/conformance/diff/core/b/{client-actions → actions}/unarchive-conversation.md +0 -0
  73. /package/conformance/diff/reworded/a/{client-actions → actions}/archive-conversation.md +0 -0
  74. /package/conformance/diff/reworded/a/{client-actions → actions}/show-conversations.md +0 -0
  75. /package/conformance/diff/reworded/a/{client-actions → actions}/start-retitle.md +0 -0
  76. /package/conformance/diff/reworded/a/{client-actions → actions}/unarchive-conversation.md +0 -0
  77. /package/conformance/diff/reworded/b/{client-actions → actions}/archive-conversation.md +0 -0
  78. /package/conformance/diff/reworded/b/{client-actions → actions}/show-conversations.md +0 -0
  79. /package/conformance/diff/reworded/b/{client-actions → actions}/start-retitle.md +0 -0
  80. /package/conformance/diff/reworded/b/{client-actions → actions}/unarchive-conversation.md +0 -0
  81. /package/skills/operbe/example/{client-actions → actions}/archive-conversation.md +0 -0
  82. /package/skills/operbe/example/{client-actions → actions}/show-conversations.md +0 -0
  83. /package/skills/operbe/example/{client-actions → actions}/start-retitle.md +0 -0
  84. /package/skills/operbe/example/{client-actions → actions}/unarchive-conversation.md +0 -0
package/dist/diff.js CHANGED
@@ -23,16 +23,16 @@ function coreLevel(what, field, before, after) {
23
23
  case "many-at-once": return "warning";
24
24
  default: return "info";
25
25
  }
26
- if (what === "client-action")
26
+ if (what === "action")
27
27
  switch (field) {
28
- case "class": return "breaking"; // a show may now send a change
28
+ case "class": return "breaking"; // a show may now call a change
29
29
  case "operations":
30
30
  case "available-when":
31
31
  case "behaviors": return "warning";
32
32
  default: return "info";
33
33
  }
34
34
  if (field === "applies-to" || field === "operations")
35
- return "warning"; // a UI may no longer owe it; what it sends changed
35
+ return "warning"; // a front end may no longer owe it; the outcome it describes changed
36
36
  return "info";
37
37
  }
38
38
  export function diff(a, b) {
@@ -89,11 +89,11 @@ export function diff(a, b) {
89
89
  if (f === "status" && x[f] === "firm" && y[f] === "rough") {
90
90
  kind = `${what}.demoted`;
91
91
  l = "warning";
92
- } // UIs built it as firm
92
+ } // front ends built it as firm
93
93
  if (f === "form" && Number(y[f]) > Number(x[f])) {
94
94
  kind = `${what}.form-up`;
95
95
  l = "warning";
96
- } // UIs built against the old form are stale
96
+ } // front ends built against the old form are stale
97
97
  add({ kind, record: name, field: f, before: x[f], after: y[f], level: lvl(l), message: `${show(x[f])} -> ${show(y[f])}` });
98
98
  }
99
99
  // M3: a class change that changes the effect, with before and after, always breaking.
@@ -130,11 +130,15 @@ export function diff(a, b) {
130
130
  }
131
131
  records("operation", A.operations ?? {}, B.operations ?? {});
132
132
  records("behavior", A.behaviors ?? {}, B.behaviors ?? {});
133
- records("client-action", A["client-actions"] ?? {}, B["client-actions"] ?? {});
134
- // Coverage: per UI and id. Worse (a lower value, or the row gone) is a warning, unless the record is rough.
135
- const rec = (S, id) => own(S.behaviors, id) ?? own(S["client-actions"], id);
136
- for (const ui of [...new Set([...Object.keys(A.coverage ?? {}), ...Object.keys(B.coverage ?? {})])].sort()) {
137
- const ca = own(A.coverage, ui) ?? {}, cb = own(B.coverage, ui) ?? {};
133
+ records("action", A.actions ?? {}, B.actions ?? {});
134
+ // Coverage: per front end and id. Worse (a lower value, or the row gone) is a warning, unless the record is rough.
135
+ const rec = (S, id) => own(S.behaviors, id) ?? own(S.actions, id);
136
+ for (const fe of [...new Set([...Object.keys(A.coverage ?? {}), ...Object.keys(B.coverage ?? {})])].sort()) {
137
+ const ca = own(A.coverage, fe) ?? {}, cb = own(B.coverage, fe) ?? {};
138
+ // A coverage file with no lines appearing or going: its rows (none) say nothing, so say this.
139
+ // Found on fake repos, where an empty file fell through to description.changed.
140
+ if ((own(A.coverage, fe) === undefined) !== (own(B.coverage, fe) === undefined) && !Object.keys(ca).length && !Object.keys(cb).length)
141
+ add({ kind: own(A.coverage, fe) === undefined ? "coverage.file-added" : "coverage.file-removed", record: "profile", field: fe, level: "info", message: `${fe}'s coverage file, with no lines, was ${own(A.coverage, fe) === undefined ? "added" : "removed"}` });
138
142
  for (const id of [...new Set([...Object.keys(ca), ...Object.keys(cb)])].sort()) {
139
143
  const ra = own(ca, id), rb = own(cb, id), x = ra?.value, y = rb?.value;
140
144
  if (same(ra, rb))
@@ -143,23 +147,30 @@ export function diff(a, b) {
143
147
  const gone = y === undefined && !rec(B, id); // the record itself left
144
148
  const rough = rec(A, id)?.status === "rough";
145
149
  add({
146
- kind: worse ? "coverage.worse" : better ? "coverage.better" : "coverage.changed", record: id, field: ui, before: ra, after: rb,
150
+ kind: worse ? "coverage.worse" : better ? "coverage.better" : "coverage.changed", record: id, field: fe, before: ra, after: rb,
147
151
  level: worse && !rough && !gone ? "warning" : "info",
148
152
  message: `${x ?? "no row"} -> ${y ?? "no row"}`,
149
153
  });
150
154
  }
151
155
  }
152
- // The profile: its UIs, its known deviations, and every other field and section.
156
+ // The profile: its front ends, its groups, its known deviations, and every other field and section.
153
157
  const P = A.profile ?? {}, Q = B.profile ?? {};
154
- for (const f of [...new Set([...Object.keys(P), ...Object.keys(Q)])].filter((k) => !["uis", "sections", "ext"].includes(k)).sort())
158
+ for (const f of [...new Set([...Object.keys(P), ...Object.keys(Q)])].filter((k) => !["front-ends", "groups", "sections", "ext"].includes(k)).sort())
155
159
  if (!same(own(P, f), own(Q, f)))
156
160
  add({ kind: "profile.field-changed", record: "profile", field: f, before: own(P, f), after: own(Q, f), level: "info", message: `${show(own(P, f))} -> ${show(own(Q, f))}` });
157
- for (const ui of P.uis ?? [])
158
- if (!(Q.uis ?? []).includes(ui))
159
- add({ kind: "profile.ui-removed", record: "profile", field: ui, level: "warning", message: `UI '${ui}' was removed` });
160
- for (const ui of Q.uis ?? [])
161
- if (!(P.uis ?? []).includes(ui))
162
- add({ kind: "profile.ui-added", record: "profile", field: ui, level: "info", message: `UI '${ui}' was added` });
161
+ const fa = P["front-ends"] ?? [], fb = Q["front-ends"] ?? [];
162
+ for (const fe of fa)
163
+ if (!fb.includes(fe))
164
+ add({ kind: "profile.front-end-removed", record: "profile", field: fe, level: "warning", message: `front end '${fe}' was removed` });
165
+ for (const fe of fb)
166
+ if (!fa.includes(fe))
167
+ add({ kind: "profile.front-end-added", record: "profile", field: fe, level: "info", message: `front end '${fe}' was added` });
168
+ // A group's front ends are what every behavior naming it applies to: changing or removing one is a
169
+ // warning. A new group is info: nothing could name it before (found on fake repos).
170
+ const ga = P.groups ?? {}, gb = Q.groups ?? {};
171
+ for (const g of [...new Set([...Object.keys(ga), ...Object.keys(gb)])].sort())
172
+ if (!same(own(ga, g), own(gb, g)))
173
+ add({ kind: "profile.group-changed", record: "profile", field: g, before: own(ga, g), after: own(gb, g), level: own(ga, g) === undefined ? "info" : "warning", message: `group '${g}': ${show(own(ga, g))} -> ${show(own(gb, g))}` });
163
174
  const pe = extFields(P), qe = extFields(Q);
164
175
  for (const f of [...new Set([...pe.keys(), ...qe.keys()])].sort())
165
176
  if (!same(pe.get(f), qe.get(f)))
@@ -236,12 +247,12 @@ export function diff(a, b) {
236
247
  // Findings: an error that appears is a warning, a gap that appears is info, one that goes is info.
237
248
  // A finding is the same one when rule, file, record, field and message match; its line may move.
238
249
  const fkey = (f) => JSON.stringify([f.rule, f.file, f.record ?? "", f.field ?? "", f.message]);
239
- const fa = new Map(a.findings.map((f) => [fkey(f), f])), fb = new Map(b.findings.map((f) => [fkey(f), f]));
240
- for (const [k, f] of fb)
241
- if (!fa.has(k))
250
+ const xa = new Map(a.findings.map((f) => [fkey(f), f])), xb = new Map(b.findings.map((f) => [fkey(f), f]));
251
+ for (const [k, f] of xb)
252
+ if (!xa.has(k))
242
253
  add({ kind: "finding.appeared", record: f.record ?? f.file, field: f.rule, after: f, level: f.level === "error" ? "warning" : "info", message: `${f.level} ${f.rule}: ${f.message}` });
243
- for (const [k, f] of fa)
244
- if (!fb.has(k))
254
+ for (const [k, f] of xa)
255
+ if (!xb.has(k))
245
256
  add({ kind: "finding.resolved", record: f.record ?? f.file, field: f.rule, before: f, level: "info", message: `${f.level} ${f.rule}: ${f.message}` });
246
257
  return out;
247
258
  }
package/dist/indexes.js CHANGED
@@ -1,4 +1,4 @@
1
- // renderIndex: the behavior index, the coverage table and the client action index, as markdown.
1
+ // renderIndex: the behavior index, the coverage table and the action index, as markdown.
2
2
  // operbe ≤ 0.2 committed these as INDEX.md and COVERAGE.md; they changed with every behavior edit
3
3
  // and made parallel changes conflict, so v1 prints them on demand (`operbe index`) instead.
4
4
  // Built from the description's body, so it shows exactly what describe would.
@@ -6,22 +6,30 @@ import { body } from "./describe.js";
6
6
  const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
7
7
  export function renderIndex(m) {
8
8
  const b = body(m);
9
- const uis = b.profile?.uis ?? [];
10
- const applies = (r, ui) => r["applies-to"] === "all" || (Array.isArray(r["applies-to"]) && r["applies-to"].includes(ui));
11
- // A coverage cell: the value, blank if the UI hasn't built it yet, n/a if it doesn't apply.
12
- const cell = (id, r, ui) => b.coverage?.[ui]?.[id]?.value ?? (applies(r, ui) ? "" : "n/a");
9
+ const fes = b.profile?.["front-ends"] ?? [];
10
+ const groups = b.profile?.groups ?? {};
11
+ // applies-to: `all`, a group, or a list of front ends and groups.
12
+ const applies = (r, fe) => {
13
+ const a = r["applies-to"];
14
+ if (a === "all")
15
+ return true;
16
+ const names = typeof a === "string" ? [a] : Array.isArray(a) ? a : [];
17
+ return names.some((n) => n === fe || (Object.hasOwn(groups, n) && Array.isArray(groups[n]) && groups[n].includes(fe)));
18
+ };
19
+ // A coverage cell: the value, blank if the front end hasn't built it yet, n/a if it doesn't apply.
20
+ const cell = (id, r, fe) => b.coverage?.[fe]?.[id]?.value ?? (applies(r, fe) ? "" : "n/a");
13
21
  const row = (cells) => `| ${cells.join(" | ")} |\n`;
14
22
  const head = (cols) => row(cols) + `|${"---|".repeat(cols.length)}\n`;
15
- const blank = "Blank = not yet built. n/a = doesn't apply to that UI.\n\n";
23
+ const blank = "Blank = not yet built. n/a = doesn't apply to that front end.\n\n";
16
24
  const behaviors = Object.entries(b.behaviors ?? {}).sort(([x], [y]) => cmp(x, y));
17
25
  let out = "# Behaviors\n\n" + head(["id", "name", "status", "form"]) +
18
26
  behaviors.map(([id, r]) => row([id, r.name ?? "", r.status ?? "", r.form ?? ""])).join("");
19
- out += "\n# Coverage\n\n" + blank + head(["id", "name", ...uis]) +
20
- behaviors.map(([id, r]) => row([id, r.name ?? "", ...uis.map((u) => cell(id, r, u))])).join("");
21
- if (b["client-actions"]) {
22
- const acts = Object.entries(b["client-actions"]).sort(([x], [y]) => cmp(x, y));
23
- out += "\n# Client actions\n\n" + blank + head(["name", "class", "status", "behaviors", ...uis]) +
24
- acts.map(([n, r]) => row([n, r.class ?? "", r.status ?? "", (Array.isArray(r.behaviors) ? r.behaviors : []).join(", "), ...uis.map((u) => cell(n, r, u))])).join("");
27
+ out += "\n# Coverage\n\n" + blank + head(["id", "name", ...fes]) +
28
+ behaviors.map(([id, r]) => row([id, r.name ?? "", ...fes.map((u) => cell(id, r, u))])).join("");
29
+ if (b.actions) {
30
+ const acts = Object.entries(b.actions).sort(([x], [y]) => cmp(x, y));
31
+ out += "\n# Actions\n\n" + blank + head(["name", "class", "status", "behaviors", ...fes]) +
32
+ acts.map(([n, r]) => row([n, r.class ?? "", r.status ?? "", (Array.isArray(r.behaviors) ? r.behaviors : []).join(", "), ...fes.map((u) => cell(n, r, u))])).join("");
25
33
  }
26
34
  return out;
27
35
  }
package/dist/read.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Finding } from "./findings.ts";
2
2
  import type { Source } from "./source.ts";
3
- export type Value = string | string[];
3
+ export type Value = string | string[] | Record<string, string[]>;
4
4
  export interface Field {
5
5
  value: Value;
6
6
  line: number;
@@ -10,8 +10,8 @@ export interface Section {
10
10
  text: string;
11
11
  line: number;
12
12
  }
13
- export type Kind = "profile" | "operation" | "behavior" | "client-action" | "architecture";
14
- export declare const RECORD_KINDS: readonly ["operation", "behavior", "client-action"];
13
+ export type Kind = "profile" | "operation" | "behavior" | "action" | "architecture";
14
+ export declare const RECORD_KINDS: readonly ["operation", "behavior", "action"];
15
15
  export type RecordKind = (typeof RECORD_KINDS)[number];
16
16
  export interface Rec {
17
17
  kind: Kind;
@@ -27,16 +27,17 @@ export interface CoverageLine {
27
27
  }
28
28
  export interface Model {
29
29
  profile: Rec | null;
30
- uis: string[];
30
+ frontEnds: string[];
31
+ groups: Record<string, string[]>;
31
32
  folders: {
32
33
  operations: string;
33
34
  behaviors: string;
34
- clientActions: string | null;
35
+ actions: string | null;
35
36
  };
36
37
  absent: string[];
37
38
  operations: Rec[];
38
39
  behaviors: Rec[];
39
- clientActions: Rec[];
40
+ actions: Rec[];
40
41
  coverage: Record<string, {
41
42
  file: string;
42
43
  lines: CoverageLine[] | null;
@@ -75,6 +76,7 @@ export declare function parseRecord(raw: string, file: string, kind: Kind): {
75
76
  };
76
77
  export declare const str: (r: Rec | null, k: string) => string;
77
78
  export declare const list: (r: Rec | null, k: string) => string[];
79
+ export declare const items: (v: Value | undefined) => string[];
78
80
  export declare const section: (r: Rec, title: string) => string;
79
81
  export declare function read(src: Source): Model;
80
82
  export declare function parseArchitecture(raw: string, file: string, name: string): {
package/dist/read.js CHANGED
@@ -1,9 +1,10 @@
1
- export const RECORD_KINDS = ["operation", "behavior", "client-action"];
1
+ export const RECORD_KINDS = ["operation", "behavior", "action"];
2
2
  // --- The header grammar -------------------------------------------------------------------------
3
3
  // key: value a key is lowercase words joined by hyphens, optionally prefixed `arch.`
4
4
  // key: [a, b] a list; items are split on commas and trimmed, so an item can't hold a comma
5
5
  // key: value # note " #" then a space (or the line's end) starts a comment
6
- // Nothing else: no quotes, no indentation, no multi-line values.
6
+ // Nothing else: no quotes, no multi-line values, and no indentation, except in the profile's
7
+ // `groups`: the line `groups:` and then one indented `name: [a, b]` line per group.
7
8
  const KEY = /^[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*)*$/;
8
9
  const QUOTED = /^".*"$|^'.*'$/;
9
10
  // A file's lines: a leading byte-order mark dropped (editors on Windows write one; it isn't
@@ -25,10 +26,15 @@ export function parseRecord(raw, file, kind) {
25
26
  if (end < 0)
26
27
  return { rec, findings }; // check reports operbe/no-header
27
28
  rec.readable = true;
29
+ let groups = null; // set while reading the profile's indented groups
28
30
  for (let i = 1; i < end; i++) {
29
- const n = i + 1, line = lines[i];
30
- if (!line.trim())
31
+ const n = i + 1, raw = lines[i];
32
+ if (!raw.trim())
31
33
  continue;
34
+ const indented = /^\s/.test(raw);
35
+ if (!indented)
36
+ groups = null;
37
+ const line = indented && groups ? raw.trimStart() : raw;
32
38
  // The comment. " #x" is a trap: it reads as part of the value but would cut it off here.
33
39
  let body = line;
34
40
  const hash = line.indexOf(" #");
@@ -44,7 +50,8 @@ export function parseRecord(raw, file, kind) {
44
50
  say("operbe/header-line", n, "a header line is 'key: value', the key in lowercase words joined by hyphens");
45
51
  continue;
46
52
  }
47
- if (key in rec.fields) {
53
+ const into = indented && groups ? groups : rec.fields;
54
+ if (key in into) {
48
55
  say("operbe/duplicate-key", n, `'${key}' is already set above; this line is ignored`, key);
49
56
  continue;
50
57
  }
@@ -64,7 +71,14 @@ export function parseRecord(raw, file, kind) {
64
71
  }
65
72
  else if (QUOTED.test(text))
66
73
  say("operbe/quoted-value", n, "quotes aren't part of the header grammar and would be kept as written; write the value bare", key);
74
+ if (groups && into === groups) {
75
+ groups[key] = Array.isArray(value) ? value : [value];
76
+ continue;
77
+ } // check says a group must be a list
67
78
  rec.fields[key] = { value, line: n };
79
+ // The profile's `groups:` with nothing after it opens the map its indented lines fill.
80
+ if (kind === "profile" && key === "groups" && value === "")
81
+ rec.fields[key].value = groups = dict();
68
82
  }
69
83
  // Sections: each starts at a "## " line and runs to the next one. Text before the first belongs to none.
70
84
  // A "## " line inside a fenced code block (``` or ~~~) is text, not a heading.
@@ -93,11 +107,13 @@ export function parseRecord(raw, file, kind) {
93
107
  // --- Field access, shared with check --------------------------------------------------------------
94
108
  export const str = (r, k) => { const v = r?.fields[k]?.value; return typeof v === "string" ? v : ""; };
95
109
  export const list = (r, k) => { const v = r?.fields[k]?.value; return Array.isArray(v) ? v : []; };
110
+ // A value's items: a list as it is, text as one item (none if empty), a map as none.
111
+ export const items = (v) => (Array.isArray(v) ? v : typeof v === "string" && v ? [v] : []);
96
112
  export const section = (r, title) => r.sections.find((s) => s.title === title)?.text ?? "";
97
113
  // Project-relative folder from a profile value: "./ops/" -> "ops". null: it would leave the project
98
114
  // ("..", or an absolute path), which read refuses: a profile can't make operbe read outside its root.
99
115
  const folder = (v) => (/^[/\\]|^[a-zA-Z]:|(^|[/\\])\.\.([/\\]|$)/.test(v) ? null : v.split("/").filter((p) => p && p !== ".").join("/"));
100
- // A UI or architecture name becomes one path segment, so it is a plain name: no slash, no dot first.
116
+ // A front end or architecture name becomes one path segment, so it is a plain name: no slash, no dot first.
101
117
  const SEGMENT = /^[^/\\.][^/\\]*$/;
102
118
  // --- The project ---------------------------------------------------------------------------------
103
119
  export function read(src) {
@@ -111,7 +127,7 @@ export function read(src) {
111
127
  findings.push({ rule: "operbe/conflict", level: "error", file, line: i + 1, message: "this file has conflict markers; resolve the conflict, and check again" });
112
128
  return text;
113
129
  };
114
- const empty = { profile: null, uis: [], folders: { operations: "operations", behaviors: "behaviors", clientActions: null }, absent: [], operations: [], behaviors: [], clientActions: [], coverage: {}, architectures: [], findings };
130
+ const empty = { profile: null, frontEnds: [], groups: dict(), folders: { operations: "operations", behaviors: "behaviors", actions: null }, absent: [], operations: [], behaviors: [], actions: [], coverage: {}, architectures: [], findings };
115
131
  const raw = get("operbe.md");
116
132
  if (raw === null) {
117
133
  findings.push({ rule: "operbe/no-profile", level: "error", file: "operbe.md", message: "operbe.md not found; see references/adopting.md" });
@@ -130,19 +146,27 @@ export function read(src) {
130
146
  const dirOf = (field) => { const d = folder(str(profile, field)); if (d === null)
131
147
  outside(field, `'${str(profile, field)}'`); return d; };
132
148
  const named = (field) => list(profile, field).filter((n) => SEGMENT.test(n) || (outside(field, `'${n}'`), false));
133
- const uis = named("uis");
149
+ // A profile still on rc.2's names (`uis`, `client-actions`) is read by them, so check reports the
150
+ // rename once (operbe/renamed) instead of everything that follows from reading nothing.
151
+ const frontEnds = named("front-ends" in profile.fields ? "front-ends" : "uis");
152
+ const g = profile.fields.groups?.value;
153
+ const groups = g && typeof g === "object" && !Array.isArray(g) ? g : dict();
134
154
  const ops = dirOf("operations") || "operations";
135
155
  const behs = dirOf("behaviors") || "behaviors";
136
- const acts = "client-actions" in profile.fields ? dirOf("client-actions") ?? "" : null;
156
+ const actsField = "actions" in profile.fields ? "actions" : "client-actions" in profile.fields ? "client-actions" : null;
157
+ const acts = actsField ? dirOf(actsField) ?? "" : null;
158
+ // The folder's name before rc.3, still on disk and not what the profile names: rename it.
159
+ if (acts !== "client-actions" && src.list("client-actions") !== null)
160
+ findings.push({ rule: "operbe/renamed", level: "error", file: "client-actions", message: "the folder 'client-actions' was renamed 'actions' in operbe 1.0.0-rc.3; rename it, and write 'actions: actions' in operbe.md" });
137
161
  // Every .md file in a folder, except the generated files of operbe ≤ 0.2 and a README.
138
162
  const records = (dir, kind, keep = () => true) => (src.list(dir) ?? []).filter((f) => f.endsWith(".md") && keep(f)).map((f) => load(`${dir}/${f}`, kind)).filter((r) => r !== null);
139
163
  const coverage = dict();
140
- for (const ui of uis) {
141
- const file = `${behs}/coverage/${ui}.md`, text = get(file);
164
+ for (const fe of frontEnds) {
165
+ const file = `${behs}/coverage/${fe}.md`, text = get(file);
142
166
  const lines = text === null ? null : linesOf(text);
143
167
  if (lines?.at(-1) === "")
144
168
  lines.pop();
145
- coverage[ui] = { file, lines: lines?.map((l, i) => ({ line: i + 1, cells: cellsOf(l) })) ?? null };
169
+ coverage[fe] = { file, lines: lines?.map((l, i) => ({ line: i + 1, cells: cellsOf(l) })) ?? null };
146
170
  }
147
171
  const architectures = named("architectures").flatMap((name) => {
148
172
  const file = `${name}/architecture.md`, text = get(file);
@@ -153,12 +177,12 @@ export function read(src) {
153
177
  return [arch];
154
178
  });
155
179
  return {
156
- profile, uis, findings, coverage, architectures,
157
- folders: { operations: ops, behaviors: behs, clientActions: acts },
180
+ profile, frontEnds, groups, findings, coverage, architectures,
181
+ folders: { operations: ops, behaviors: behs, actions: acts },
158
182
  absent: [ops, behs, ...(acts ? [acts] : [])].filter((d) => src.list(d) === null),
159
183
  operations: records(ops, "operation"),
160
184
  behaviors: records(behs, "behavior", (f) => f.startsWith("B-")),
161
- clientActions: acts ? records(acts, "client-action", (f) => f !== "INDEX.md" && f !== "README.md") : [],
185
+ actions: acts ? records(acts, "action", (f) => f !== "INDEX.md" && f !== "README.md") : [],
162
186
  };
163
187
  }
164
188
  // A table row's cells, trimmed. `\|` is a pipe inside a cell, as in GitHub's tables.
@@ -1,8 +1,8 @@
1
1
  import type { Finding } from "./findings.ts";
2
2
  import { type Model } from "./read.ts";
3
3
  export interface ReconcileQuery {
4
- kind: "operation" | "client-action";
5
- ui?: string;
4
+ kind: "operation" | "action";
5
+ frontEnd?: string;
6
6
  names: string[];
7
7
  via?: string;
8
8
  }
package/dist/reconcile.js CHANGED
@@ -1,14 +1,14 @@
1
- import { str } from "./read.js";
1
+ import { items, str } from "./read.js";
2
2
  export function reconcile(m, q) {
3
- if (q.kind === "client-action" && !q.ui)
4
- throw new TypeError("reconcile: a client-action query needs `ui`");
3
+ if (q.kind === "action" && !q.frontEnd)
4
+ throw new TypeError("reconcile: an action query needs `frontEnd`");
5
5
  const out = [];
6
- const folder = (q.kind === "operation" ? m.folders.operations : m.folders.clientActions) ?? "client-actions";
7
- // Client actions: only those this UI should have. Retired ones are no longer anyone's to build.
8
- const records = q.kind === "operation" ? m.operations : m.clientActions.filter((a) => {
9
- const to = a.fields["applies-to"]?.value;
10
- return str(a, "status") !== "retired" && (to === "all" ? m.uis : Array.isArray(to) ? to : []).includes(q.ui);
11
- });
6
+ const folder = (q.kind === "operation" ? m.folders.operations : m.folders.actions) ?? "actions";
7
+ // Actions: only those this front end should have. Retired ones are no longer anyone's to build.
8
+ // applies-to is `all`, a group, or a list of front ends and groups.
9
+ const fes = (to) => (to === "all" ? m.frontEnds : (typeof to === "string" ? [to] : Array.isArray(to) ? to : [])
10
+ .flatMap((n) => (Object.hasOwn(m.groups, n) ? m.groups[n] : [n])));
11
+ const records = q.kind === "operation" ? m.operations : m.actions.filter((a) => str(a, "status") !== "retired" && fes(a.fields["applies-to"]?.value).includes(q.frontEnd));
12
12
  const nameOf = (r) => str(r, "name") || r.stem;
13
13
  const say = (r, level, rule, message, field) => {
14
14
  const line = r && field ? r.fields[field]?.line : undefined;
@@ -17,8 +17,7 @@ export function reconcile(m, q) {
17
17
  const code = new Set(q.names), owner = new Map(), matched = new Set(), claimedAny = new Set();
18
18
  if (q.via)
19
19
  for (const r of records) {
20
- const v = r.fields[q.via]?.value;
21
- for (const c of Array.isArray(v) ? v : v ? [v] : []) {
20
+ for (const c of items(r.fields[q.via]?.value)) {
22
21
  claimedAny.add(r);
23
22
  if (owner.has(c) && owner.get(c) !== r) {
24
23
  say(r, "error", "operbe/reconcile-claimed-twice", `${q.via} '${c}' is also claimed by ${nameOf(owner.get(c))}`, q.via);
@@ -36,11 +35,11 @@ export function reconcile(m, q) {
36
35
  if (r)
37
36
  matched.add(r);
38
37
  else
39
- say(null, "error", "operbe/reconcile-unlisted", `'${n}' is in the code${q.ui ? ` (${q.ui})` : ""}, but no ${q.kind} record ${q.via ? `names it in ${q.via} or ` : ""}has that name`);
38
+ say(null, "error", "operbe/reconcile-unlisted", `'${n}' is in the code${q.frontEnd ? ` (${q.frontEnd})` : ""}, but no ${q.kind} record ${q.via ? `names it in ${q.via} or ` : ""}has that name`);
40
39
  }
41
40
  // A record whose claims are all absent already has an error for each; don't add a gap on top.
42
41
  for (const r of records)
43
42
  if (!matched.has(r) && !claimedAny.has(r))
44
- say(r, "gap", "operbe/reconcile-unbuilt", `no name in the code${q.ui ? ` (${q.ui})` : ""} matches this ${q.kind}${q.via ? ` (by name; it has no ${q.via})` : ""}`);
43
+ say(r, "gap", "operbe/reconcile-unbuilt", `no name in the code${q.frontEnd ? ` (${q.frontEnd})` : ""} matches this ${q.kind}${q.via ? ` (by name; it has no ${q.via})` : ""}`);
45
44
  return out;
46
45
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.0.0-rc.2";
1
+ export declare const VERSION = "1.0.0-rc.3";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // This build's version, as in package.json (test/describe.ts keeps the two equal).
2
- export const VERSION = "1.0.0-rc.2";
2
+ export const VERSION = "1.0.0-rc.3";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "operbe",
3
- "version": "1.0.0-rc.2",
4
- "description": "operbe, the operations and behaviors method: read, check, reconcile, describe and diff a project's operations, behaviors and client actions.",
3
+ "version": "1.0.0-rc.3",
4
+ "description": "operbe, the operations and behaviors method: read, check, reconcile, describe and diff a project's operations, behaviors and actions, for every front end it names.",
5
5
  "license": "MIT",
6
6
  "author": "Trevor Schoeny",
7
7
  "repository": "https://github.com/trevorschoeny/operbe",
@@ -32,7 +32,7 @@
32
32
  "scripts": {
33
33
  "build": "rm -rf dist && tsc",
34
34
  "prepare": "npm run build",
35
- "check": "npm run build && node --disable-warning=ExperimentalWarning test/read.ts && node --disable-warning=ExperimentalWarning test/declare.ts && node --disable-warning=ExperimentalWarning test/describe.ts && node --disable-warning=ExperimentalWarning test/diff.ts && node --disable-warning=ExperimentalWarning test/review.ts && node --disable-warning=ExperimentalWarning test/rename.ts && node --disable-warning=ExperimentalWarning test/tools.ts && node --disable-warning=ExperimentalWarning test/jj.ts && node --disable-warning=ExperimentalWarning test/parity.ts && node --disable-warning=ExperimentalWarning test/pack.ts"
35
+ "check": "npm run build && node --disable-warning=ExperimentalWarning test/read.ts && node --disable-warning=ExperimentalWarning test/declare.ts && node --disable-warning=ExperimentalWarning test/describe.ts && node --disable-warning=ExperimentalWarning test/diff.ts && node --disable-warning=ExperimentalWarning test/review.ts && node --disable-warning=ExperimentalWarning test/front-ends.ts && node --disable-warning=ExperimentalWarning test/words.ts && node --disable-warning=ExperimentalWarning test/rename.ts && node --disable-warning=ExperimentalWarning test/tools.ts && node --disable-warning=ExperimentalWarning test/jj.ts && node --disable-warning=ExperimentalWarning test/parity.ts && node --disable-warning=ExperimentalWarning test/pack.ts"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^26.6.11",
@@ -31,9 +31,21 @@
31
31
  "operbe": {
32
32
  "type": "string"
33
33
  },
34
- "uis": {
34
+ "front-ends": {
35
+ "description": "Everything that acts for a person.",
35
36
  "$ref": "#/$defs/names"
36
37
  },
38
+ "groups": {
39
+ "description": "Named groups of front ends, as written.",
40
+ "type": "object",
41
+ "additionalProperties": {
42
+ "$ref": "#/$defs/names"
43
+ }
44
+ },
45
+ "operations-offered-on": {
46
+ "description": "The surfaces that offer the Operations set to outsiders.",
47
+ "$ref": "#/$defs/value"
48
+ },
37
49
  "architectures": {
38
50
  "$ref": "#/$defs/names"
39
51
  },
@@ -57,14 +69,14 @@
57
69
  "$ref": "#/$defs/behavior"
58
70
  }
59
71
  },
60
- "client-actions": {
72
+ "actions": {
61
73
  "type": "object",
62
74
  "additionalProperties": {
63
- "$ref": "#/$defs/client-action"
75
+ "$ref": "#/$defs/action"
64
76
  }
65
77
  },
66
78
  "coverage": {
67
- "description": "UI -> behavior id or client action name -> its row. A UI with no coverage file is absent.",
79
+ "description": "Front end -> behavior id or action name -> its row. A front end with no coverage file is absent.",
68
80
  "type": "object",
69
81
  "additionalProperties": {
70
82
  "type": "object",
@@ -119,7 +131,7 @@
119
131
  "enum": [
120
132
  "operation",
121
133
  "behavior",
122
- "client-action"
134
+ "action"
123
135
  ]
124
136
  },
125
137
  "required": {
@@ -202,9 +214,11 @@
202
214
  "type": "object",
203
215
  "properties": {
204
216
  "behaviors": {
217
+ "description": "The behaviors that describe its outcome.",
205
218
  "$ref": "#/$defs/names"
206
219
  },
207
- "client-actions": {
220
+ "actions": {
221
+ "description": "The actions that call it.",
208
222
  "$ref": "#/$defs/names"
209
223
  }
210
224
  }
@@ -222,7 +236,7 @@
222
236
  "$ref": "#/$defs/counts"
223
237
  }
224
238
  },
225
- "client-actions": {
239
+ "actions": {
226
240
  "type": "object",
227
241
  "additionalProperties": {
228
242
  "type": "object",
@@ -423,17 +437,18 @@
423
437
  "$ref": "#/$defs/value"
424
438
  },
425
439
  "operations": {
440
+ "description": "The operations whose outcome it describes.",
426
441
  "$ref": "#/$defs/value"
427
442
  },
428
443
  "replaced-by": {
429
444
  "type": "string"
430
445
  },
431
- "client-actions": {
446
+ "actions": {
432
447
  "type": "string"
433
448
  }
434
449
  }
435
450
  },
436
- "client-action": {
451
+ "action": {
437
452
  "type": "object",
438
453
  "allOf": [
439
454
  {
@@ -455,9 +470,11 @@
455
470
  ]
456
471
  },
457
472
  "behaviors": {
473
+ "description": "The behaviors that describe it.",
458
474
  "$ref": "#/$defs/value"
459
475
  },
460
476
  "operations": {
477
+ "description": "The operations it calls.",
461
478
  "$ref": "#/$defs/value"
462
479
  },
463
480
  "show-because": {