@digital-agora/friday 0.9.0 → 0.11.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
@@ -21,7 +21,7 @@ that on (decision 43, "Develop" below). From npmjs.com it needs no token: leave
21
21
  `@digital-agora:registry` line out of `~/.npmrc`.
22
22
 
23
23
  Internal packages (Hybrid-Day's specialization, decision 42) are on GitHub Packages only, and so
24
- is every version of Friday. Installing from there needs a GitHub personal access token (classic)
24
+ is every version of Friday and of the open-source specializations (Google Cloud's, decision 53). Installing from there needs a GitHub personal access token (classic)
25
25
  with `read:packages`, from https://github.com/settings/tokens/new?scopes=read:packages, in
26
26
  `~/.npmrc`:
27
27
 
@@ -98,8 +98,25 @@ npx -y @digital-agora/friday install --with ./path/to/specialization --with @acm
98
98
  A project rule cites its repository (`<repo>/<path>`, a repository in the specialization's
99
99
  `sources`); `friday validate --with <it>` checks the merged pack.
100
100
 
101
- Hybrid-Day's specialization lives in `specializations/hybrid-day/` and is published to GitHub
102
- Packages only, as `@digital-agora/friday-hybrid-day`:
101
+ A specialization can build on another with `extends` in `specialization.yaml` (a folder, or a
102
+ package it depends on); what it extends is applied first, so it wins (decision 53):
103
+
104
+ ```yaml
105
+ extends: ["@digital-agora/friday-google-cloud"]
106
+ ```
107
+
108
+ Google Cloud's specialization lives in `specializations/google-cloud/`: the rules that hold for any
109
+ project on Google Cloud and Firebase (Firestore rules and `private/` documents for protected fields,
110
+ service accounts and Workload Identity Federation, Secret Manager, Cloud Run, `demo-` emulator
111
+ projects), each citing Google's documentation. It is MIT-licensed and published with friday, to
112
+ npmjs.com too, as `@digital-agora/friday-google-cloud`:
113
+
114
+ ```bash
115
+ npx -y @digital-agora/friday-google-cloud install
116
+ ```
117
+
118
+ Hybrid-Day's specialization lives in `specializations/hybrid-day/`, extends Google Cloud's, and is
119
+ published to GitHub Packages only, as `@digital-agora/friday-hybrid-day`:
103
120
 
104
121
  ```bash
105
122
  npx -y @digital-agora/friday-hybrid-day install
@@ -230,7 +247,7 @@ friday list [--with spec]... agents (with models) and workflows
230
247
  friday validate [--with spec]... schemas + cross-references + sources + model policy + test pyramid
231
248
  friday build [-t target] [-o dir] [--with spec]... unpacked bundles
232
249
  friday bundle [-t target] [-o dir] [--with spec]... friday-<target>-<version>.zip
233
- friday graph [orchestration] [--with spec]... steps, routes, loops and every way a run can end (Mermaid + table)
250
+ friday graph [orchestration] [--with spec]... steps, routes, loops, what each step reads and every way a run can end (Mermaid + table)
234
251
  friday handoff render <file> write the readable handoff.md next to handoff.yaml
235
252
  friday handoff check <file> [--pending]
236
253
  ```
@@ -251,14 +268,17 @@ pnpm typecheck && pnpm build && pnpm lint && pnpm test
251
268
  Friday releases itself from changesets too: `pnpm changeset` in every PR (CI checks it), then
252
269
  **Actions › Release › Run workflow** on `main` versions friday and the specializations, publishes
253
270
  them to GitHub Packages, and pushes the `chore(release)` commit and the tags (`v<version>` for
254
- friday, `friday-hybrid-day@<version>` for Hybrid-Day's; decision 22). **dry-run** rehearses it
271
+ friday, `friday-<id>@<version>` for a specialization, such as `friday-hybrid-day@<version>`;
272
+ decision 22). **dry-run** rehearses it
255
273
  and pushes nothing.
256
274
 
257
- Publishing friday to npmjs.com as well is off unless turned on (decision 43):
275
+ Publishing friday and the open-source specializations to npmjs.com as well is off unless turned
276
+ on (decisions 43, 53):
258
277
 
259
- 1. The `@digital-agora` scope is an npm organization that can publish `@digital-agora/friday`.
278
+ 1. The `@digital-agora` scope is an npm organization that can publish `@digital-agora/friday` and
279
+ `@digital-agora/friday-google-cloud`.
260
280
  2. The organization secret `NPM_TOKEN` (an automation token, or a granular token with read and
261
- write on `@digital-agora/friday` and bypass 2FA) is shared with this repository: Organization ›
281
+ write on the `@digital-agora` scope, or on both packages once they exist, and bypass 2FA) is shared with this repository: Organization ›
262
282
  Settings › Secrets and variables › Actions › `NPM_TOKEN` › Repository access.
263
283
  3. Turn it on for every release with the repository variable `PUBLISH_NPMJS` = `true`, or for one
264
284
  with **npmjs** ticked in Run workflow. `NPM_ACCESS` = `restricted` keeps it private (default
@@ -266,11 +286,13 @@ Publishing friday to npmjs.com as well is off unless turned on (decision 43):
266
286
 
267
287
  The npmjs.com step runs after GitHub Packages and before anything is pushed; a rerun skips what is
268
288
  already published. Without the secret it stops with an error instead of releasing to one registry
269
- only. Specializations never go to npmjs.com.
289
+ only. A specialization goes to npmjs.com only when its license is not `UNLICENSED` (Google
290
+ Cloud's); Hybrid-Day's never does.
270
291
 
271
292
  Layout: `schemas/` (the YAML schemas), `pack/` (Friday's personas, conventions, workflows,
272
- model policy and test pyramid, all generic), `specializations/` (project specializations, such
273
- as Hybrid-Day's, each its own package), `src/` (loader, validator, IR,
293
+ model policy and test pyramid, all generic), `specializations/` (platform and project specializations,
294
+ such as Google Cloud's and Hybrid-Day's, each its own package), `src/` (loader, validator, IR,
274
295
  `src/adapters/<target>/`, bundle, install, CLI), `test/` (vitest, including a harness that runs
275
296
  the generated workflow scripts with mocked agents). See `CLAUDE.md` for the rules and
276
- `docs/decisions.md` for why things are the way they are.
297
+ `docs/decisions.md` for why things are the way they are, and
298
+ `docs/how-friday-fits-together.md` for how the parts fit together as a pattern for other tools.
Binary file
Binary file
@@ -154,12 +154,48 @@ function context(stepId, item) {
154
154
  if (HANDOFF && HANDOFF.deliveryPolicy) {
155
155
  parts.push("Standing delivery policy (what delivery may settle itself; record each such decision in your summary, never product, copy or security-widening):\n" + JSON.stringify(HANDOFF.deliveryPolicy));
156
156
  }
157
- const earlier = Object.keys(state.outputs);
158
- if (earlier.length) parts.push("Results of earlier steps:\n" + JSON.stringify(state.outputs));
157
+ const earlier = visibleOutputs(stepId, item);
158
+ if (Object.keys(earlier).length) parts.push("Results of earlier steps:\n" + JSON.stringify(earlier));
159
159
  if (item) parts.push("Current item:\n" + JSON.stringify(item));
160
160
  return parts.join("\n\n");
161
161
  }
162
162
 
163
+ // The results of earlier steps one agent call sees (decision 55; the rules are in src/reads.ts).
164
+ // A result key is <stepId>[.<part>][:<itemId>]. A step's own results are always visible; with
165
+ // reads, only the steps it names besides its own loop. A result of the step's own loop is given
166
+ // for the current item whole, for the items it depends on summarized, and not for other items; any
167
+ // other per-item result is summarized (SUMMARY_DROPS left out).
168
+ function keyStep(k) { return k.split(/[.:]/)[0]; }
169
+ function keyItem(k) { const i = k.indexOf(":"); return i < 0 ? null : k.slice(i + 1); }
170
+ function summarized(v) {
171
+ if (Array.isArray(v)) return v.map(summarized);
172
+ if (!v || typeof v !== "object") return v;
173
+ const o = {};
174
+ Object.keys(v).forEach(function (k) { if (SUMMARY_DROPS.indexOf(k) < 0) o[k] = summarized(v[k]); });
175
+ return o;
176
+ }
177
+ function visibleOutputs(stepId, item) {
178
+ const base = keyStep(stepId);
179
+ const reads = READS[base] || null;
180
+ const loop = LOOPS[base] || null;
181
+ const deps = (item && item.dependsOn) || [];
182
+ const out = {};
183
+ Object.keys(state.outputs).forEach(function (k) {
184
+ const s = keyStep(k);
185
+ const it = keyItem(k);
186
+ const own = !!loop && LOOPS[s] === loop;
187
+ if (!own && s !== base && reads && reads.indexOf(s) < 0) return;
188
+ if (it === null) { out[k] = state.outputs[k]; return; }
189
+ if (own && item && item.id) {
190
+ if (it === item.id) out[k] = state.outputs[k];
191
+ else if (deps.indexOf(it) >= 0) out[k] = summarized(state.outputs[k]);
192
+ return;
193
+ }
194
+ out[k] = summarized(state.outputs[k]);
195
+ });
196
+ return out;
197
+ }
198
+
163
199
  // Per-repo command map: level id -> commands, from args.commands or the handoff's commands.
164
200
  // The pack's commands are only the default; an npm repo with test:architecture maps its own.
165
201
  const COMMANDS = Object.assign({}, (HANDOFF && HANDOFF.commands) || {}, A.commands || {});
@@ -1,6 +1,7 @@
1
1
  import { FIELD_GUIDES, LEAN_SCHEMAS } from "../../step-schemas.js";
2
2
  import * as P from "../../prompts.js";
3
3
  import { RUNTIME } from "./runtime.js";
4
+ import { SUMMARY_DROPS, loopMap, readsMap } from "../../reads.js";
4
5
  const j = (v) => JSON.stringify(v);
5
6
  function refLit(r) {
6
7
  return j(r);
@@ -310,6 +311,10 @@ export function compileClaudeWorkflow(w, ir) {
310
311
  `const BOOTSTRAPPED = ${j(P.BOOTSTRAPPED)};`,
311
312
  `const DECIDER = ${j(w.stream === "downstream" ? { persona: "lead-developer", taskKind: "decide" } : null)};`,
312
313
  `const LOOP_LEVELS = ${j(ir.pack.testPyramid?.loopLevels ?? [])};`,
314
+ // What each step's agents read from earlier steps (decision 55).
315
+ `const READS = ${j(readsMap(w))};`,
316
+ `const LOOPS = ${j(loopMap(w))};`,
317
+ `const SUMMARY_DROPS = ${j(SUMMARY_DROPS)};`,
313
318
  RUNTIME,
314
319
  ...ctx.fns,
315
320
  "",
@@ -1,4 +1,5 @@
1
1
  import { loopExits } from "../graph.js";
2
+ import { readsText } from "../reads.js";
2
3
  export const CLI = "npx -y @digital-agora/friday";
3
4
  function who(ref, ir) {
4
5
  const kinds = ref.taskKind === "{{task.taskKind}}" ? (ref.allowedTaskKinds ?? []) : [ref.taskKind];
@@ -87,6 +88,13 @@ function planLines(steps, ir, depth) {
87
88
  out.push(`${n} **${s.id}** (gate, up to ${s.maxLoops} fix loops) - ${ref(s)}: ${s.prompt}${s.onFail ? ` On fail, ${ref(s.onFail)} fixes the findings and the gate runs again.` : ""}${when}`, exitsLine(pad, s, down(s)));
88
89
  break;
89
90
  }
91
+ // What the step's agents are given from earlier steps (decision 55).
92
+ if (s.reads && out[start]) {
93
+ if (out[start].endsWith(":"))
94
+ out.splice(start + 1, 0, `${pad} - reads: ${readsText(s)}`);
95
+ else
96
+ out[start] += ` ${readsText(s)}`;
97
+ }
90
98
  if (s.checkpoint && s.type !== "approval" && out[start]) {
91
99
  out[start] += ` Builds checkpoint \`${s.checkpoint}\`: a person approves it before the next step reads it.`;
92
100
  }
@@ -217,9 +225,11 @@ user's behalf, never skip one, never fill a gap with a guess.
217
225
  - each **gap**: "<gap>. Why: <why>. Impact: <impact>." with its solutions as options
218
226
  (each with its trade-off), the recommended one first.${consolidates(w) ? `
219
227
  - each **contradiction**: "Contradiction: <conflict> (between <between>). Why: <why>. Both
220
- sides agree on: <overlap>." with its options, the inner-join sweet spot (the overlap plus the
228
+ sides agree on: <overlap>. It rests on: <premise>." with its options, the inner-join sweet spot (the overlap plus the
221
229
  least each side must add) first, marked "(Recommended)" when it is. Never pick for the user. Record the answer with
222
230
  \`supersedes\`: the ids in \`between\` that are answers; the run then reads only the new one.
231
+ If the user picks "None of these: the premise is wrong", ask for their design in the same
232
+ turn and record their words, verbatim, as the answer (decision 54).
223
233
  - **dropped**: list each in one line with its reason, after the questions. If the user wants
224
234
  one back, record what they say about it as an answer.` : ""}
225
235
  ${w.deferNonBlocking ? "Do not ask about an item explicitly marked \`blocking: false\`; defer it to \`scope.outOfScope\` and continue. Contradictions and items that block writing or testing a task still require an answer. " : ""}Keep asking until every blocking item has an answer. Append each answer to \`answers\`
@@ -227,9 +237,13 @@ user's behalf, never skip one, never fill a gap with a guess.
227
237
  \`resolution\`, to \`gapResolutions\`.
228
238
  **Record answers faithfully.** \`answer\` is the user's own words, verbatim (or the option
229
239
  label they picked); what you take it to mean goes in a separate \`interpretation\` line. Never
230
- fold an option, a detail or a safeguard the user did not pick into the answer. When an answer
231
- addresses a different layer than the question (e.g. the UI when the question is about the
232
- server), it does not answer it: record it as a note and re-ask the question in the same turn. Save them${bounded ? " and the round state" : ""} to \`docs/friday/<workId>/answers.yaml\` after
240
+ fold an option, a detail or a safeguard the user did not pick into the answer.
241
+ **Classify every free-text answer before you record it** (decision 54): an answer; a question
242
+ back (answer it now, from the results so far, then ask the item again in the same turn); a
243
+ directive (a rule for the whole work: record it verbatim as an answer with id
244
+ \`directive-<n>\` and ask the item again if it does not settle it); or another layer (e.g. the UI
245
+ when the question is about the server: it does not answer it, so record it as a note and ask
246
+ the question again in the same turn). Only an answer closes the item. Save them${bounded ? " and the round state" : ""} to \`docs/friday/<workId>/answers.yaml\` after
233
247
  every round, then go back to step 2. A re-run sees every answer, so new questions are
234
248
  follow-ups, not repeats. When the lists grow (more than about 20 items), pass
235
249
  \`answersFile: docs/friday/<workId>/answers.yaml\` with \`answeredIds\` and \`resolvedIds\` (the ids
@@ -144,7 +144,7 @@ function orchestrator(w, ir) {
144
144
  const persona = ir.agentIndex[w.orchestrator] ?? {};
145
145
  const kind = persona.decide ? "decide" : (Object.keys(persona)[0] ?? "decide");
146
146
  const up = w.stream === "upstream";
147
- const run = "Execute the step plan above yourself, in order, delegating every step to the named subagent with the task tool. Give each subagent the work id, the request or the handoff, every answer, every resolved gap and the results of earlier steps, and tell it which JSON shape to return (below). Steps marked parallel or in one wave may be delegated at the same time. Never do a step's work yourself and never use a different subagent or model than the plan names";
147
+ const run = "Execute the step plan above yourself, in order, delegating every step to the named subagent with the task tool. Give each subagent the work id, the request or the handoff, every answer, every resolved gap and the results of earlier steps (only the steps a plan step says it reads, when it says so; for a task, its own results whole, its dependencies' summarized without raw output, evidence or failures, and no other task's: decision 55), and tell it which JSON shape to return (below). Steps marked parallel or in one wave may be delegated at the same time. Never do a step's work yourself and never use a different subagent or model than the plan names";
148
148
  const ask = "the question tool (one question per call, as many calls as needed)";
149
149
  const driver = up
150
150
  ? upstreamDriver(w, { run, ask }, ir.pack.id)
@@ -154,7 +154,7 @@ function runSection(w, t, ir) {
154
154
  ...(w.steps.some((s) => s.type === "approval" && s.level)
155
155
  ? ["Approved prompt pyramid levels (build only from these; never change one): <level -> approving role>"]
156
156
  : []),
157
- "Results of earlier steps: <step id -> its result>",
157
+ "Results of earlier steps: <step id -> its result, as section 3 scopes them>",
158
158
  ]
159
159
  : [
160
160
  `Workflow ${w.id} (downstream), step <step id>.`,
@@ -162,7 +162,7 @@ function runSection(w, t, ir) {
162
162
  ? "Approved handoff (the only source of truth; anything it does not settle is a blocker, not a guess):"
163
163
  : "Run arguments (anything they and the repository do not settle is a blocker, not a guess):",
164
164
  "<the handoff or the run arguments>",
165
- "Results of earlier steps: <step id -> its result>",
165
+ "Results of earlier steps: <step id -> its result, as section 3 scopes them>",
166
166
  ];
167
167
  return [
168
168
  "## 3. How to run a step",
@@ -178,7 +178,10 @@ function runSection(w, t, ir) {
178
178
  "",
179
179
  "Check each result against its shape. A missing or malformed result: start the agent once more",
180
180
  "with the problem; still wrong -> stop, `failed`, with the step and the reason. Keep every",
181
- "result by step id; later steps get them all.",
181
+ "result by step id. A later step gets them all, unless its brief in steps.md says what it",
182
+ "reads: then only those (decision 55). A task's step gets its own task's results whole, the",
183
+ "results of the tasks it depends on summarized (without raw output, evidence or failures), and",
184
+ "no other task's.",
182
185
  up
183
186
  ? `\nCollect every question, assumption and gap a step returns, with its id and step. Ids are
184
187
  \`<step>.<id>\` so two steps never clash.${w.deferNonBlocking ? " An item marked `blocking: false` goes to `deferred` instead." : ""}`
package/dist/graph.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { outputsOf } from "./types.js";
2
+ import { stepPlaces } from "./reads.js";
2
3
  const n = (k, one, many) => `${k} ${k === 1 ? one : many}`;
3
4
  /** `handoff`: the run has a handoff to go back to (downstream, not release from changesets). */
4
5
  export function loopExits(step, handoff = true) {
@@ -166,6 +167,10 @@ export function orchestrationGraph(w) {
166
167
  route("round-limit", id, `checkpoint after round ${w.maxRounds} (+ extraRounds): the user freezes the scope, extends or stops`);
167
168
  };
168
169
  const last = chain(w.steps, at("start"));
170
+ // Data edges (decision 55): what each step with `reads` is given from earlier steps.
171
+ for (const [id, p] of stepPlaces(w))
172
+ for (const r of p.step.reads ?? [])
173
+ g.edges.push({ from: r, to: id, label: "reads", data: true });
169
174
  const end = down ? "done" : "awaiting-approval";
170
175
  for (const e of last)
171
176
  route(end, e.from, down ? "every step finished" : "the handoff is written; a person approves it");
@@ -182,7 +187,7 @@ const emitsWorkflow = (w) => outputsOf(w).includes("workflow");
182
187
  const mid = (id) => `n_${id.replace(/[^A-Za-z0-9_]/g, "_")}`;
183
188
  const tid = (status) => `t_${status.replace(/[^A-Za-z0-9_]/g, "_")}`;
184
189
  const esc = (s) => s.replace(/"/g, "'");
185
- /** A Mermaid flowchart: steps, routes, loop back-edges and the terminals each step reaches. */
190
+ /** A Mermaid flowchart: steps, routes, loop back-edges, data edges (--o) and the terminals each step reaches. */
186
191
  export function renderMermaid(g) {
187
192
  const lines = ["flowchart TD"];
188
193
  for (const n of g.nodes) {
@@ -194,7 +199,7 @@ export function renderMermaid(g) {
194
199
  for (const s of statuses)
195
200
  lines.push(` ${tid(s)}((("${s}")))`);
196
201
  for (const e of g.edges) {
197
- const arrow = e.back ? "-.->" : "-->";
202
+ const arrow = e.data ? "--o" : e.back ? "-.->" : "-->";
198
203
  lines.push(` ${mid(e.from)} ${arrow}${e.label ? `|"${esc(e.label)}"|` : ""} ${mid(e.to)}`);
199
204
  }
200
205
  const seen = new Set();
package/dist/prompts.js CHANGED
@@ -57,6 +57,8 @@ export const CONSOLIDATE = [
57
57
  " plus the least each side must add to meet the acceptance criteria; then each side as it",
58
58
  " stands. Recommend the sweet spot unless the overlap is empty or cannot meet an acceptance",
59
59
  " criterion (say which in why). Do not pick one yourself: the user does.",
60
+ " State in premise the assumption every option rests on (decision 54), and end the options",
61
+ " with \"None of these: the premise is wrong\", which asks the user for their design.",
60
62
  "4. Add the gaps you find yourself. A scope (result.scopes) whose expected outcome the user has",
61
63
  " not stated, in the request or an answer, is a blocking question: never drop or defer it.",
62
64
  "Every open item below must end up in your output, in a mergedFrom, or in dropped.",
package/dist/reads.js ADDED
@@ -0,0 +1,75 @@
1
+ /** Fields left out of a summarized result: raw output and evidence that belong to its own task. */
2
+ export const SUMMARY_DROPS = ["failureOutput", "output", "failures", "foreignFailures"];
3
+ export function stepPlaces(w) {
4
+ const out = new Map();
5
+ let order = 0;
6
+ const visit = (steps, ancestors, loop) => {
7
+ for (const s of steps) {
8
+ out.set(s.id, { step: s, order: order++, ancestors, loop });
9
+ const inner = [...ancestors, s.id];
10
+ if (s.type === "parallel" || s.type === "sequential")
11
+ visit(s.steps, inner, loop);
12
+ if (s.type === "foreach")
13
+ visit(s.steps, inner, s.id);
14
+ if (s.type === "integration-loop")
15
+ visit(s.followup, inner, s.id);
16
+ }
17
+ };
18
+ visit(w.steps, [], null);
19
+ return out;
20
+ }
21
+ /** The ids a step and every step it holds. */
22
+ export function heldIds(s) {
23
+ const kids = s.type === "parallel" || s.type === "sequential" || s.type === "foreach" ? s.steps
24
+ : s.type === "integration-loop" ? s.followup
25
+ : [];
26
+ return [s.id, ...kids.flatMap(heldIds)];
27
+ }
28
+ /** Step types that only hold other steps: `reads` goes on the steps they hold. */
29
+ export const CONTAINER_TYPES = new Set(["parallel", "sequential", "foreach"]);
30
+ /** Why one `reads` entry of a step is not allowed, or null when it is. */
31
+ export function readIssue(w, places, step, entry) {
32
+ const here = places.get(step.id);
33
+ const there = places.get(entry);
34
+ if (!there)
35
+ return `reads "${entry}", which is not a step of ${w.id}`;
36
+ if (entry === step.id)
37
+ return `reads itself; its own results for the current item are always visible`;
38
+ if (here.ancestors.includes(entry))
39
+ return `reads "${entry}", a step that holds it; its results are not finished yet`;
40
+ if (there.order > here.order)
41
+ return `reads "${entry}", which runs after it`;
42
+ return null;
43
+ }
44
+ /**
45
+ * Per step id with `reads`: every step id it may read (the entries and the steps they hold). Steps
46
+ * without `reads` are absent: they see every earlier step.
47
+ */
48
+ export function readsMap(w) {
49
+ const places = stepPlaces(w);
50
+ const out = {};
51
+ for (const [id, p] of places) {
52
+ const r = p.step.reads;
53
+ if (!r)
54
+ continue;
55
+ out[id] = [...new Set(r.flatMap((e) => (places.has(e) ? heldIds(places.get(e).step) : [e])))];
56
+ }
57
+ return out;
58
+ }
59
+ /** Per step id inside a loop: the id of that loop. */
60
+ export function loopMap(w) {
61
+ const out = {};
62
+ for (const [id, p] of stepPlaces(w))
63
+ if (p.loop)
64
+ out[id] = p.loop;
65
+ return out;
66
+ }
67
+ /** The plain-language rule for a step, for a skill or an orchestrator that passes the results itself. */
68
+ export function readsText(step) {
69
+ const r = step.reads;
70
+ if (!r)
71
+ return "";
72
+ return r.length
73
+ ? `Reads only the results of ${r.map((e) => `\`${e}\``).join(", ")} (and of its own task and the tasks it depends on).`
74
+ : "Reads no results of earlier steps (only those of its own task and the tasks it depends on).";
75
+ }
@@ -138,23 +138,59 @@ function mergePack(base, spec, file, raw) {
138
138
  return out;
139
139
  }
140
140
  /**
141
- * Merge specializations into a raw pack, in order. Problems become parse errors of the
142
- * specialization's file, so validation reports them with the rest.
141
+ * The specializations to apply, in order: each one's `extends` (decision 53) comes before it,
142
+ * depth first, and a folder reached twice is applied once, at its first place. A reference that
143
+ * does not resolve, or a cycle, becomes a parse error of the specialization that names it.
143
144
  */
144
- export function applySpecializations(raw, dirs) {
145
- const applied = [];
146
- for (const dir of dirs) {
145
+ function expandExtends(dirs, raw) {
146
+ const out = [];
147
+ const done = new Set();
148
+ const visit = (dir, stack) => {
149
+ const key = resolve(dir);
150
+ if (done.has(key))
151
+ return;
147
152
  const specFile = join(dir, SPECIALIZATION_FILE);
153
+ if (stack.includes(key)) {
154
+ raw.parseErrors.push({ file: specFile, message: `extends: cycle through ${[...stack, key].join(" -> ")}` });
155
+ return;
156
+ }
148
157
  let spec;
149
158
  try {
150
159
  spec = parse(readFileSync(specFile, "utf8"));
151
160
  }
152
161
  catch (err) {
153
162
  raw.parseErrors.push({ file: specFile, message: err.message });
154
- continue;
163
+ return;
155
164
  }
156
165
  if (!check(schemas().spec, spec, specFile, raw))
157
- continue;
166
+ return;
167
+ for (const ref of spec.extends ?? []) {
168
+ let base;
169
+ try {
170
+ base = resolveSpecialization(ref, dir);
171
+ }
172
+ catch (err) {
173
+ raw.parseErrors.push({ file: `${String(spec.id)}:${SPECIALIZATION_FILE}`, message: `extends: ${err.message}` });
174
+ continue;
175
+ }
176
+ visit(base, [...stack, key]);
177
+ }
178
+ if (done.has(key))
179
+ return;
180
+ done.add(key);
181
+ out.push({ dir, spec });
182
+ };
183
+ for (const dir of dirs)
184
+ visit(dir, []);
185
+ return out;
186
+ }
187
+ /**
188
+ * Merge specializations into a raw pack, in order, each after the ones it extends. Problems
189
+ * become parse errors of the specialization's file, so validation reports them with the rest.
190
+ */
191
+ export function applySpecializations(raw, dirs) {
192
+ const applied = [];
193
+ for (const { dir, spec } of expandExtends(dirs, raw)) {
158
194
  const label = spec.id;
159
195
  const name = spec.name;
160
196
  const file = `${label}:${SPECIALIZATION_FILE}`;
@@ -75,7 +75,7 @@ const mergedFrom = {
75
75
  const merged = (s) => ({ ...s, properties: { ...s.properties, mergedFrom } });
76
76
  export const CONTRADICTION = {
77
77
  type: "object",
78
- required: ["id", "conflict", "between", "why", "overlap", "options", "recommended"],
78
+ required: ["id", "conflict", "between", "why", "overlap", "premise", "options", "recommended"],
79
79
  properties: {
80
80
  id: { type: "string", description: "Stable id, e.g. C-export-format. Reuse it on re-runs." },
81
81
  conflict: { type: "string", description: "What contradicts what, in one sentence." },
@@ -85,9 +85,13 @@ export const CONTRADICTION = {
85
85
  type: "string",
86
86
  description: "The inner join: what every conflicting source already holds or accepts. Empty when they share nothing.",
87
87
  },
88
+ premise: {
89
+ type: "string",
90
+ description: "The assumption every option rests on, e.g. that the consumer pulls the data (decision 54).",
91
+ },
88
92
  options: {
89
93
  ...QUESTION.properties.options,
90
- description: "First the sweet spot: the overlap plus the least each side must add to meet the acceptance criteria. Then each side as it stands.",
94
+ description: 'First the sweet spot: the overlap plus the least each side must add to meet the acceptance criteria. Then each side as it stands. Last "None of these: the premise is wrong".',
91
95
  },
92
96
  recommended: QUESTION.properties.recommended,
93
97
  },
package/dist/validate.js CHANGED
@@ -6,6 +6,7 @@ import { SCHEMAS_DIR } from "./paths.js";
6
6
  import { loadRawPack } from "./load.js";
7
7
  import { applySpecializations } from "./specialize.js";
8
8
  import { SKILL_STEP_TYPES, emits } from "./types.js";
9
+ import { CONTAINER_TYPES, readIssue, stepPlaces } from "./reads.js";
9
10
  const SCHEMA_FILES = {
10
11
  pack: "pack.schema.yaml",
11
12
  "model-policy": "model-policy.schema.yaml",
@@ -351,6 +352,22 @@ function crossRefIssues(lp, files) {
351
352
  }
352
353
  }
353
354
  });
355
+ // What each step's agents read from earlier steps (decision 55).
356
+ const places = stepPlaces(w);
357
+ for (const [id, p] of places) {
358
+ const r = p.step.reads;
359
+ if (!r)
360
+ continue;
361
+ if (CONTAINER_TYPES.has(p.step.type) || p.step.type === "approval") {
362
+ err(f, `step ${id}: reads applies to agent steps; ${p.step.type === "approval" ? "no agent runs an approval" : `set it on the steps ${p.step.type} holds`}`);
363
+ continue;
364
+ }
365
+ for (const e of r) {
366
+ const why = readIssue(w, places, p.step, e);
367
+ if (why)
368
+ err(f, `step ${id}: ${why}`);
369
+ }
370
+ }
354
371
  approvalIssues(w, pack, upstreamApprovals, err.bind(null, f));
355
372
  if (w.retro)
356
373
  checkRef(f, "retro", w.retro, []);
@@ -56,7 +56,13 @@ steps:
56
56
  or an answer excludes), facts checked (what you verified in the repository, with the file, so
57
57
  no later step asks about it) and unknowns. Every field names its source: request,
58
58
  repository (file), answer (id), convention (id) or proposed. Never invent one; what you would
59
- have to guess is a proposal or a question. Put it in result.brief.
59
+ have to guess is a proposal or a question. Premises (decision 54): for the data the request
60
+ touches, state the classification of every named field, the consumers and the trust boundary
61
+ between them, whether protected data is pushed or pulled, the role of each data store (the
62
+ record or a live view), the load, and the latency targets with their measurement window. A
63
+ premise the request, the repository or an answer does not settle is a blocking question,
64
+ never a proposal, so every perspective starts from approved premises. Put the brief in
65
+ result.brief and the premises in result.brief.premises.
60
66
  - id: approve-brief
61
67
  type: approval
62
68
  checkpoint: brief
@@ -74,7 +80,11 @@ steps:
74
80
  blocking question to the user with 2-4 concrete outcomes as options (outcomeSource:
75
81
  answer, answerId: the question id). Never assume an outcome or derive it from the scope's
76
82
  title. Put them in result.scopes as { id, title, expectedOutcome, outcomeSource, answerId };
77
- a split you are unsure of is an assumption.
83
+ a split you are unsure of is an assumption. Trace the data the request touches (decision 54):
84
+ every producer, consumer and contract owner, each with the repository that holds it. Put them
85
+ in result.dataFlow as { data, role, owner, repository }. A repository that is not in this
86
+ session is a blocking question in this round: ask to add it, so no consumer turns up after
87
+ the design is set.
78
88
  - id: perspectives
79
89
  type: parallel
80
90
  steps:
@@ -22,6 +22,7 @@ steps:
22
22
  # contracts instead of inventing their own, and every red test has a known owner.
23
23
  - id: contracts
24
24
  type: agent
25
+ reads: []
25
26
  persona: architect
26
27
  taskKind: decide
27
28
  prompt: >-
@@ -38,6 +39,7 @@ steps:
38
39
  not settle is a blocker: return blocked with the question.
39
40
  - id: interfaces
40
41
  type: agent
42
+ reads: [contracts]
41
43
  persona: lead-developer
42
44
  taskKind: integrate
43
45
  prompt: >-
@@ -51,6 +53,7 @@ steps:
51
53
  change it.
52
54
  - id: orchestration
53
55
  type: agent
56
+ reads: [contracts, interfaces]
54
57
  persona: backend-engineer
55
58
  taskKind: integrate
56
59
  prompt: >-
@@ -71,6 +74,7 @@ steps:
71
74
  # task's own paths, code only in the task's files, against the frozen interfaces.
72
75
  - id: tdd
73
76
  type: tdd-pair
77
+ reads: [contracts, interfaces, orchestration]
74
78
  test: { persona: qa-engineer, taskKind: test-design }
75
79
  impl: { persona: "{{stack}}", taskKind: "{{task.taskKind}}", allowedTaskKinds: [implement, scaffold, adapter] }
76
80
  verify: { persona: qa-engineer, taskKind: verify }
@@ -81,12 +85,14 @@ steps:
81
85
  # that goes back through the bottom-of-pyramid loop. Repeats until green or maxRounds.
82
86
  - id: integrate
83
87
  type: integration-loop
88
+ reads: [contracts, interfaces, orchestration, build]
84
89
  integrate: { persona: "{{stack}}", taskKind: integrate }
85
90
  testScope: [static, unit, integration, e2e]
86
91
  maxRounds: 3
87
92
  followup:
88
93
  - id: followup-tdd
89
94
  type: tdd-pair
95
+ reads: [contracts, interfaces, orchestration]
90
96
  test: { persona: qa-engineer, taskKind: test-design }
91
97
  impl: { persona: "{{stack}}", taskKind: "{{task.taskKind}}", allowedTaskKinds: [implement, scaffold, adapter] }
92
98
  verify: { persona: qa-engineer, taskKind: verify }
@@ -97,6 +103,7 @@ steps:
97
103
  # steward checks the controls. Only when the handoff holds pii.
98
104
  - id: privacy-review
99
105
  type: gate
106
+ reads: [contracts, orchestration]
100
107
  when: pii
101
108
  persona: data-analyst-pii
102
109
  taskKind: analysis
@@ -105,6 +112,7 @@ steps:
105
112
  onFail: { persona: backend-engineer, taskKind: integrate }
106
113
  - id: security-review
107
114
  type: gate
115
+ reads: [contracts, orchestration]
108
116
  persona: security-steward
109
117
  taskKind: review
110
118
  prompt: Review the full diff against the security, data-classification, rules and config conventions and the handoff's decisions.
@@ -112,6 +120,7 @@ steps:
112
120
  onFail: { persona: backend-engineer, taskKind: integrate }
113
121
  - id: acceptance
114
122
  type: gate
123
+ reads: [orchestration, build, integrate]
115
124
  persona: lead-developer
116
125
  taskKind: integrate
117
126
  prompt: >-
@@ -123,6 +132,7 @@ steps:
123
132
  onFail: { persona: backend-engineer, taskKind: integrate }
124
133
  - id: pr
125
134
  type: agent
135
+ reads: [orchestration, build, integrate]
126
136
  persona: git-steward
127
137
  taskKind: git
128
138
  output: git
@@ -20,6 +20,7 @@ steps:
20
20
  taskKind: verify
21
21
  - id: contracts
22
22
  type: agent
23
+ reads: []
23
24
  persona: architect
24
25
  taskKind: decide
25
26
  prompt: >-
@@ -34,6 +35,7 @@ steps:
34
35
  question.
35
36
  - id: interfaces
36
37
  type: agent
38
+ reads: [contracts]
37
39
  persona: lead-developer
38
40
  taskKind: integrate
39
41
  prompt: >-
@@ -44,6 +46,7 @@ steps:
44
46
  that consume each.
45
47
  - id: orchestration
46
48
  type: agent
49
+ reads: [contracts, interfaces]
47
50
  persona: backend-engineer
48
51
  taskKind: integrate
49
52
  prompt: >-
@@ -62,6 +65,7 @@ steps:
62
65
  steps:
63
66
  - id: tdd
64
67
  type: tdd-pair
68
+ reads: [contracts, interfaces, orchestration]
65
69
  test: { persona: qa-engineer, taskKind: test-design }
66
70
  impl: { persona: "{{stack}}", taskKind: "{{task.taskKind}}", allowedTaskKinds: [implement, scaffold, adapter] }
67
71
  verify: { persona: qa-engineer, taskKind: verify }
@@ -69,12 +73,14 @@ steps:
69
73
  maxRounds: 3
70
74
  - id: integrate
71
75
  type: integration-loop
76
+ reads: [contracts, interfaces, orchestration, build]
72
77
  integrate: { persona: "{{stack}}", taskKind: integrate }
73
78
  testScope: [static, unit, integration, e2e]
74
79
  maxRounds: 3
75
80
  followup:
76
81
  - id: followup-tdd
77
82
  type: tdd-pair
83
+ reads: [contracts, interfaces, orchestration]
78
84
  test: { persona: qa-engineer, taskKind: test-design }
79
85
  impl: { persona: "{{stack}}", taskKind: "{{task.taskKind}}", allowedTaskKinds: [implement, scaffold, adapter] }
80
86
  verify: { persona: qa-engineer, taskKind: verify }
@@ -83,6 +89,7 @@ steps:
83
89
  # The top of the prompt pyramid. Neither agent wrote the prompt (decision 25).
84
90
  - id: eval-run
85
91
  type: agent
92
+ reads: [contracts, interfaces]
86
93
  level: eval-run
87
94
  persona: qa-engineer
88
95
  taskKind: verify
@@ -101,6 +108,7 @@ steps:
101
108
  changing one reopens its level in prompt-discovery.
102
109
  - id: eval-review
103
110
  type: agent
111
+ reads: [contracts, eval-run]
104
112
  level: eval-run
105
113
  persona: security-steward
106
114
  taskKind: review
@@ -115,6 +123,7 @@ steps:
115
123
  blocked.reason starting "Level <id>:". Never fix anything yourself.
116
124
  - id: privacy-review
117
125
  type: gate
126
+ reads: [contracts, orchestration]
118
127
  when: pii
119
128
  persona: data-analyst-pii
120
129
  taskKind: analysis
@@ -123,6 +132,7 @@ steps:
123
132
  onFail: { persona: backend-engineer, taskKind: integrate }
124
133
  - id: security-review
125
134
  type: gate
135
+ reads: [contracts, orchestration]
126
136
  persona: security-steward
127
137
  taskKind: review
128
138
  prompt: Review the full diff against the security, data-classification, rules and config conventions and the handoff's decisions. The approved prompt, examples and eval cases are not findings to fix here; a problem in one is a high finding naming its level.
@@ -130,6 +140,7 @@ steps:
130
140
  onFail: { persona: backend-engineer, taskKind: integrate }
131
141
  - id: acceptance
132
142
  type: gate
143
+ reads: [orchestration, build, integrate, eval-run]
133
144
  persona: lead-developer
134
145
  taskKind: integrate
135
146
  prompt: >-
@@ -143,6 +154,7 @@ steps:
143
154
  onFail: { persona: backend-engineer, taskKind: integrate }
144
155
  - id: pr
145
156
  type: agent
157
+ reads: [orchestration, build, integrate]
146
158
  persona: git-steward
147
159
  taskKind: git
148
160
  output: git
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-agora/friday",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Friday: the source of truth for AI-assisted SDLC. Compiles YAML personas, workflows and conventions into agent bundles (Claude Code, OpenCode).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -118,6 +118,16 @@ $defs:
118
118
  The checkpoint (pack.yaml checkpoints) this step builds, or an approval step approves
119
119
  (decision 39). A person approves it; a change to it reopens every approval after it.
120
120
  type: string
121
+ reads:
122
+ description: >-
123
+ The earlier steps whose results this step's agents are given (decision 55), by step id; a
124
+ step that holds others stands for all of them. Unset: every earlier step. Either way, a
125
+ result of the step's own loop is given only for the current item (whole) and the items it
126
+ depends on (summarized), and a per-item result of another loop is summarized. Not on
127
+ parallel, sequential or foreach: set it on the steps they hold.
128
+ type: array
129
+ uniqueItems: true
130
+ items: { type: string, pattern: "^[a-z][a-z0-9-]{1,40}$" }
121
131
  override:
122
132
  type: object
123
133
  additionalProperties: false
@@ -12,6 +12,12 @@ properties:
12
12
  id: { type: string, pattern: "^[a-z][a-z0-9-]{1,40}$" }
13
13
  name: { type: string }
14
14
  version: { type: string, pattern: "^\\d+\\.\\d+\\.\\d+$" }
15
+ extends:
16
+ description: >-
17
+ Specializations this one builds on (decision 53): folders relative to this one, or package
18
+ names resolved from it. Each is applied before this one, once, so this one wins over them.
19
+ type: array
20
+ items: { type: string }
15
21
  description:
16
22
  type: string
17
23
  description: Replaces the pack's description in the bundles built with this specialization.