@srobroek/pi-speckit-beads 2.0.0 → 2.0.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## speckit-beads [2.0.1](https://github.com/srobroek/harness-plugins/compare/speckit-beads--v2.0.0...speckit-beads--v2.0.1) (2026-11-29)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **speckit-beads:** nest the SpecKit run under its feature epic ([3336691](https://github.com/srobroek/harness-plugins/commit/3336691aa105dc8fe37a1dfabf6c4a33007633dd))
6
+
1
7
  ## speckit-beads [2.0.0](https://github.com/srobroek/harness-plugins/compare/speckit-beads--v1.0.1...speckit-beads--v2.0.0) (2026-11-25)
2
8
 
3
9
  ### ⚠ BREAKING CHANGES
package/README.md CHANGED
@@ -97,14 +97,28 @@ checks. Never skip a review or verification because its extension is not install
97
97
  an explicit routine-approval choice before pouring, records it on the run root, reads
98
98
  it back, and reuses it on resume.
99
99
 
100
+ A new run goes under the spec's feature epic. That is the `epic` argument, or else the
101
+ one open epic with the spec's `spec_id`.
102
+
103
+ - The tool bonds the run with `bd mol bond <profile> <epic> --type parallel --pour --ref speckit`.
104
+ The root is the epic's child in the same write, with no `blocks` edge.
105
+ - The root id reads `<epic>.speckit`. A second run under the same epic takes `speckit-2`.
106
+ - A spec without an epic gets a poured run with no parent, as before.
107
+ - In both cases the root title is `<NNN-slug> (<profile>)`, not the bare profile name. Each
108
+ profile declares a required `title` var, and bd titles the root from it.
109
+
100
110
  | Human approvals | Formula selection | Routine sign-offs |
101
111
  | --- | --- | --- |
102
112
  | Required | `autonomous=no` | Retained |
103
113
  | Declined | `autonomous=yes` | Omitted |
104
114
 
105
- - `CHOICE_REQUIRED` and `MIGRATION_REQUIRED` return a question. Ask the user, then call again: after `CHOICE_REQUIRED` with `approvals` and `decision`; after `MIGRATION_REQUIRED`, on consent, with the pending `approvals=no`, `migrate=true`, the returned `root` and `decision`. `migrate` with any other `approvals` is refused, so a yes to migrating cannot become `approvals=yes`.
106
- - `READY` names the run root and both selections.
107
- - `INCOMPLETE` means the store-lock wait ran out, a bounded `bd` command passed its 120 s bound, or the call was cancelled. It names the step reached and whether a pour was issued; inspect the run before retrying. `mol pour` and `gate resolve` are never cut off.
115
+ - `CHOICE_REQUIRED`, `MIGRATION_REQUIRED` and `REPARENT_REQUIRED` return a question. Ask the user. Then call again with the answer:
116
+ - After `CHOICE_REQUIRED`, send `approvals` and `decision`.
117
+ - After `MIGRATION_REQUIRED`, on consent, send the pending `approvals=no` and `migrate=true`. Also send the returned `root` and `decision`. `migrate` with any other `approvals` is refused, so a yes to migrating cannot become `approvals=yes`.
118
+ - An older run with no parent gets `REPARENT_REQUIRED` once its spec has an epic. Send the returned `root` with `reparent=true` or `reparent=false`. A yes moves the run under the epic and retitles it. A no is recorded, and the question does not come back.
119
+ - An epic that already blocks on a step of the run gets an error, because the move would make a cycle. The tool adds no `blocks` edge between an epic and its run.
120
+ - `READY` names the run root, its epic and both selections. It carries a warning when the epic has open `blocks` edges. bd marks every child of a blocked epic blocked, so no step of the run reaches `bd ready` until those edges close.
121
+ - `INCOMPLETE` means the store-lock wait ran out, a bounded `bd` command passed its 120 s bound, or the call was canceled. It names the step reached and whether a pour was issued; inspect the run before retrying. `mol pour`, `mol bond` and `gate resolve` run without a time bound.
108
122
 
109
123
  The whole start holds the beads store's embedded-write lock, so concurrent starts for
110
124
  a spec cannot pour duplicate runs. The lock module comes from this repository's shared
@@ -704,10 +704,35 @@ MUST Pour one molecule per spec dir. Profiles: \`speckit-basic\`,
704
704
  --set-metadata spec_dir=specs/<NNN-slug>\`.
705
705
  DEFAULT Track position with \`bd mol current <root-id>\`.
706
706
 
707
+ SPEC EPIC (spec-producing commands)
708
+ MUST Nest the molecule root under the spec's feature epic: the open epic with the
709
+ spec's \`spec_id\`.
710
+ DEFAULT \`speckit_start\` bonds the root there and titles it \`<NNN-slug> (<profile>)\`.
711
+ MUST File the spec's tasks under the molecule's implement step, never directly
712
+ under the epic.
713
+
714
+ EPIC EDGES (spec-producing commands)
715
+ NEVER Link an epic to a step of its own molecule with \`blocks\`. The parent link
716
+ already carries that relation, and the edge turns the nesting into a cycle.
717
+ MUST Order specced epics (epics with a live molecule) with \`related\` edges and a
718
+ note on both epics. A \`blocks\` edge on such an epic marks every step of its
719
+ molecule blocked, specify included.
720
+
721
+ TASK ORDER (spec-producing commands)
722
+ MUST Put the real cross-spec order on task edges. The consuming task blocks on the
723
+ producing task or its contract bead.
724
+ DEFAULT Use epic-to-epic \`blocks\` only onto an epic that has no live molecule.
725
+
726
+ SPEC START TOOL (new or resumed spec lifecycle)
707
727
  MUST Use the \`speckit_start\` tool for workflow start and resume.
708
- MUST On \`CHOICE_REQUIRED\` or \`MIGRATION_REQUIRED\`, ask the returned question
709
- and supply only the explicit user answer and decision when invoking it again.
710
- A migration answer is \`migrate\`, sent with the pending \`approvals=no\` and root.
728
+ MUST On \`CHOICE_REQUIRED\`, \`MIGRATION_REQUIRED\` or \`REPARENT_REQUIRED\`, ask the
729
+ returned question. Then call the tool again with only the user's explicit answer
730
+ and decision.
731
+ MUST Send a migration answer as \`migrate\`, with the pending \`approvals=no\` and root.
732
+ MUST Send a reparent answer as \`reparent\`, with the root.
733
+ MUST Pass \`epic\` when more than one open epic carries the spec's \`spec_id\`.
734
+ MUST Relay every warning a READY result carries to the user.
735
+
711
736
  SPEC START (new or resumed spec lifecycle)
712
737
  MUST Before pouring, bonding, or advancing, find the spec's existing molecule root;
713
738
  read its metadata if one exists.
@@ -1833,7 +1858,15 @@ function issueList(value) {
1833
1858
  issue_type: typeof row.issue_type === "string" ? row.issue_type : undefined,
1834
1859
  spec_id: typeof row.spec_id === "string" ? row.spec_id : undefined,
1835
1860
  await_type: typeof row.await_type === "string" ? row.await_type : undefined,
1836
- metadata: row.metadata === undefined || row.metadata === null ? undefined : object(row.metadata)
1861
+ parent: typeof row.parent === "string" && row.parent ? row.parent : undefined,
1862
+ metadata: row.metadata === undefined || row.metadata === null ? undefined : object(row.metadata),
1863
+ dependencies: Array.isArray(row.dependencies) ? row.dependencies.map(object).flatMap((link) => typeof link.id === "string" ? [
1864
+ {
1865
+ id: link.id,
1866
+ status: typeof link.status === "string" ? link.status : undefined,
1867
+ dependency_type: typeof link.dependency_type === "string" ? link.dependency_type : undefined
1868
+ }
1869
+ ] : []) : undefined
1837
1870
  };
1838
1871
  });
1839
1872
  }
@@ -1850,8 +1883,15 @@ var ROUTINE = [
1850
1883
  ["analyze-approval", "analyze approval"],
1851
1884
  ["verify-signoff", "verify sign-off"]
1852
1885
  ];
1886
+ var runTitle = (spec, profile) => `${spec} (${profile})`;
1887
+ function profileOf(row) {
1888
+ const named = PROFILES.find((profile) => profile === row.title);
1889
+ if (named)
1890
+ return named;
1891
+ return PROFILES.find((profile) => row.spec_id !== undefined && row.title === runTitle(row.spec_id, profile));
1892
+ }
1853
1893
  function isRunRoot(row) {
1854
- return (row.issue_type === "molecule" || row.issue_type === "epic") && PROFILES.some((profile) => profile === row.title);
1894
+ return (row.issue_type === "molecule" || row.issue_type === "epic") && profileOf(row) !== undefined;
1855
1895
  }
1856
1896
  function recordedChoice(root, spec) {
1857
1897
  const metadata = root?.metadata ?? {};
@@ -1962,6 +2002,89 @@ async function migrateRoutine(root, options, command) {
1962
2002
  if (resolutions.some((row) => after.find((issue) => issue.id === row.gate)?.status !== "closed" || after.find((issue) => issue.id === row.step)?.status !== "closed"))
1963
2003
  throw new Error("Routine migration readback failed; do not record approvals as declined");
1964
2004
  }
2005
+ async function specEpic(spec, named, rows, command) {
2006
+ const id = named ?? (() => {
2007
+ const open = rows.filter((row) => row.issue_type === "epic" && !isRunRoot(row) && row.status !== "closed");
2008
+ if (open.length > 1)
2009
+ throw new Error(`Several open epics carry spec_id ${spec} (${open.map((row) => row.id).join(", ")}); pass epic to choose one`);
2010
+ return open[0]?.id;
2011
+ })();
2012
+ if (id === undefined)
2013
+ return;
2014
+ const epic = issueList(await command(["show", id]))[0];
2015
+ if (epic?.issue_type !== "epic" || isRunRoot(epic))
2016
+ throw new Error(`${id} is not a feature epic`);
2017
+ if (epic.status === "closed")
2018
+ throw new Error(`Epic ${id} is closed; reopen it or pass another epic`);
2019
+ if (epic.spec_id !== undefined && epic.spec_id !== spec)
2020
+ throw new Error(`Epic ${id} belongs to spec ${epic.spec_id}, not ${spec}`);
2021
+ return epic;
2022
+ }
2023
+ var blocksOf = (epic) => (epic.dependencies ?? []).filter((link) => link.dependency_type === "blocks");
2024
+ function refuseBlocksOnRun(epic, run, root) {
2025
+ const steps = new Set([root, ...run.children.map((row) => row.id)]);
2026
+ const onRun = blocksOf(epic).filter((link) => steps.has(link.id));
2027
+ if (onRun.length)
2028
+ throw new Error(`Epic ${epic.id} blocks on ${onRun.map((link) => link.id).join(", ")} of run ${root}, so nesting the run under it would be a cycle. Remove that edge first (bd dep remove ${epic.id} ${onRun[0]?.id}); the run's tasks under its implement step carry the order.`);
2029
+ }
2030
+ function blockedEpicWarning(epic) {
2031
+ const open = blocksOf(epic).filter((link) => link.status !== "closed");
2032
+ if (!open.length)
2033
+ return;
2034
+ return `Epic ${epic.id} waits on open ${open.map((link) => link.id).join(", ")} (blocks). bd marks every child of a blocked epic blocked, so no step of this run reaches bd ready until those close. Order specced epics with related edges and put the real order on task edges.`;
2035
+ }
2036
+ async function runRef(epic, command) {
2037
+ const taken = new Set(issueList(await command(["list", "--parent", epic, "--all", "--limit", "0"])).map((row) => row.id));
2038
+ let ref = "speckit";
2039
+ for (let n = 2;taken.has(`${epic}.${ref}`); n++)
2040
+ ref = `speckit-${n}`;
2041
+ return ref;
2042
+ }
2043
+ async function placeExisting(root, epic, options, command) {
2044
+ const current = issueList(await command(["show", root.id]))[0] ?? root;
2045
+ if (current.parent === epic.id || current.metadata?.reparent === "declined")
2046
+ return { kind: "place" };
2047
+ if (current.parent !== undefined)
2048
+ throw new Error(`Run ${root.id} is under ${current.parent}, not epic ${epic.id}; move it by hand or pass that epic`);
2049
+ refuseBlocksOnRun(epic, await moleculeGraph(root, command), root.id);
2050
+ const title = runTitle(options.spec, profileOf(current) ?? options.profile);
2051
+ if (options.reparent === undefined) {
2052
+ const question = `Move existing run ${root.id} under epic ${epic.id} and retitle it "${title}", so the spec's work shows under its epic? Yes or no.`;
2053
+ return { kind: "ask", result: { status: "REPARENT_REQUIRED", root: root.id, epic: epic.id, question, text: question } };
2054
+ }
2055
+ if (options.reparent)
2056
+ return { kind: "place", move: { title, parent: epic.id } };
2057
+ await command([
2058
+ "update",
2059
+ root.id,
2060
+ "--set-metadata",
2061
+ "reparent=declined",
2062
+ "--append-notes",
2063
+ `Declined moving this run under epic ${epic.id}.`
2064
+ ]);
2065
+ return { kind: "place" };
2066
+ }
2067
+ async function createRun(spec, profile, mode, epic, command) {
2068
+ const vars = ["--var", `feature=${spec}`, "--var", `autonomous=${mode}`, "--var", `title=${runTitle(spec, profile)}`];
2069
+ if (epic) {
2070
+ const ref = await runRef(epic.id, command);
2071
+ const bonded = object(payload(await command(["mol", "bond", profile, epic.id, "--type", "parallel", "--pour", "--ref", ref, ...vars])));
2072
+ const id = bonded.id_mapping === undefined ? undefined : object(bonded.id_mapping)[profile];
2073
+ if (typeof id !== "string")
2074
+ throw new Error("Bond returned no root id; inspect the epic's children before retrying");
2075
+ return { id };
2076
+ }
2077
+ const poured = object(payload(await command(["mol", "pour", profile, ...vars])));
2078
+ if (typeof poured.new_epic_id !== "string")
2079
+ throw new Error("Pour returned no new_epic_id; inspect the created run before retrying");
2080
+ return { id: poured.new_epic_id };
2081
+ }
2082
+ function readBackPlacement(confirmed, title, parent) {
2083
+ if (title !== undefined && confirmed.title !== title)
2084
+ throw new Error(`Title readback failed for ${confirmed.id}; do not advance`);
2085
+ if (parent !== undefined && confirmed.parent !== parent)
2086
+ throw new Error(`Parent readback failed for ${confirmed.id}: expected epic ${parent}; do not advance`);
2087
+ }
1965
2088
  async function startSpec(input, command) {
1966
2089
  const options = { ...input, spec: input.spec ?? await specOfRoot(input.root, command) };
1967
2090
  if (!/^[0-9]{3}-[a-z0-9-]+$/.test(options.spec))
@@ -1972,7 +2095,8 @@ async function startSpec(input, command) {
1972
2095
  const requested = approval(options.approvals);
1973
2096
  if (options.migrate !== undefined && requested !== "no")
1974
2097
  throw new Error("migrate answers MIGRATION_REQUIRED only: send it with approvals=no (the pending choice) and the returned root, never the migration answer as approvals");
1975
- const roots = issueList(await command(["query", `spec_id="${options.spec}"`, "--limit", "0"])).filter(isRunRoot);
2098
+ const rows = issueList(await command(["query", `spec_id="${options.spec}"`, "--limit", "0"]));
2099
+ const roots = rows.filter(isRunRoot);
1976
2100
  if (roots.length > 1 && !options.root)
1977
2101
  throw new Error("Multiple runs exist; select an explicit root");
1978
2102
  let root = options.root ? issueList(await command(["show", options.root]))[0] : roots[0];
@@ -1993,17 +2117,31 @@ async function startSpec(input, command) {
1993
2117
  const question = `Explicitly migrate existing run ${root.id} to omit routine approvals, resolving only its routine formula approval gates while preserving history? Yes or no.`;
1994
2118
  return { status: "MIGRATION_REQUIRED", root: root.id, question, text: question };
1995
2119
  }
2120
+ const epic = await specEpic(options.spec, options.epic, rows, command);
2121
+ const warnings = [epic && blockedEpicWarning(epic)].filter((warning) => !!warning);
2122
+ const placed = root && epic ? await placeExisting(root, epic, { ...options, profile }, command) : undefined;
2123
+ if (placed?.kind === "ask")
2124
+ return placed.result;
2125
+ const move = placed?.move;
1996
2126
  if ((saved === undefined || migration) && !options.decision?.trim())
1997
2127
  throw new Error("Record the explicit user decision before creating or migrating a workflow");
1998
2128
  if (root && migration)
1999
2129
  await migrateRoutine(root, options, command);
2000
2130
  const mode = selected === "yes" ? "no" : "yes";
2001
- if (!root) {
2002
- const poured = object(payload(await command(["mol", "pour", profile, "--var", `feature=${options.spec}`, "--var", `autonomous=${mode}`])));
2003
- if (typeof poured.new_epic_id !== "string")
2004
- throw new Error("Pour returned no new_epic_id; inspect the created run before retrying");
2005
- root = { id: poured.new_epic_id };
2006
- }
2131
+ const fresh = !root;
2132
+ root ??= await createRun(options.spec, profile, mode, epic, command);
2133
+ const title = fresh ? runTitle(options.spec, profile) : move?.title;
2134
+ if (move)
2135
+ await command([
2136
+ "update",
2137
+ root.id,
2138
+ "--parent",
2139
+ move.parent,
2140
+ "--title",
2141
+ move.title,
2142
+ "--append-notes",
2143
+ `Moved under epic ${move.parent} and retitled with the user's consent.`
2144
+ ]);
2007
2145
  if (saved === undefined || migration)
2008
2146
  await command([
2009
2147
  "update",
@@ -2022,12 +2160,17 @@ async function startSpec(input, command) {
2022
2160
  const confirmed = issueList(await command(["show", root.id]))[0];
2023
2161
  if (confirmed?.metadata?.human_approvals !== selected || confirmed.metadata.autonomous !== mode)
2024
2162
  throw new Error(`Approval choice readback failed for ${root.id}; do not advance`);
2163
+ readBackPlacement(confirmed, title, fresh ? epic?.id : move?.parent);
2164
+ const nested = epic && confirmed.parent === epic.id ? ` under epic ${epic.id}` : "";
2165
+ const notes = warnings.map((warning) => ` Warning: ${warning}`).join("");
2025
2166
  return {
2026
2167
  status: "READY",
2027
2168
  root: root.id,
2169
+ ...epic ? { epic: epic.id } : {},
2028
2170
  humanApprovals: selected,
2029
2171
  autonomous: mode,
2030
- text: `${options.spec} / ${root.id}: human approvals=${selected}; autonomous=${mode}. Routine clarify, analyze, and verification sign-offs ${selected === "yes" ? "enabled" : "omitted"}. Reviews, verification, tests, and consequential safety/provider confirmations remain required. Only actual dependency consumers wait.`
2172
+ ...warnings.length ? { warnings } : {},
2173
+ text: `${options.spec} / ${root.id}${nested}: human approvals=${selected}; autonomous=${mode}. Routine clarify, analyze, and verification sign-offs ${selected === "yes" ? "enabled" : "omitted"}. Reviews, verification, tests, and consequential safety/provider confirmations remain required. Only actual dependency consumers wait.${notes}`
2031
2174
  };
2032
2175
  }
2033
2176
 
@@ -2701,7 +2844,9 @@ async function withEmbeddedWriteLock(cwd, owner, write, env = process.env, deadl
2701
2844
  // plugins/speckit-beads/opencode/src/spec-start-runtime.ts
2702
2845
  var BEADS_LOCK = { embeddedStoreFor, withEmbeddedWriteLock };
2703
2846
  var COMMAND_MS = 120000;
2704
- var UNBOUNDED = new Set(["mol pour", "gate resolve"]);
2847
+ var UNBOUNDED = new Set(["mol pour", "mol bond", "gate resolve"]);
2848
+ var CREATES = new Set(["mol pour", "mol bond"]);
2849
+ var READS = new Set(["query", "show", "list", "mol"]);
2705
2850
  var TERMINATION_GRACE_MS = 5000;
2706
2851
 
2707
2852
  class IncompleteStart extends Error {
@@ -2712,6 +2857,18 @@ class IncompleteStart extends Error {
2712
2857
  this.name = "IncompleteStart";
2713
2858
  }
2714
2859
  }
2860
+ function createdRootOf(created, formula) {
2861
+ if (created === null || typeof created !== "object")
2862
+ return;
2863
+ const result = created;
2864
+ if (typeof result.new_epic_id === "string")
2865
+ return result.new_epic_id;
2866
+ const mapping = result.id_mapping;
2867
+ if (formula === undefined || mapping === null || typeof mapping !== "object")
2868
+ return;
2869
+ const id = mapping[formula];
2870
+ return typeof id === "string" ? id : undefined;
2871
+ }
2715
2872
  async function runSpecStart(options, signal, commandMs = COMMAND_MS, module = BEADS_LOCK, timers = globalThis) {
2716
2873
  const started = Date.now();
2717
2874
  const cwd = realpathSync4(options.workspace);
@@ -2741,7 +2898,7 @@ async function runSpecStart(options, signal, commandMs = COMMAND_MS, module = BE
2741
2898
  };
2742
2899
  if (!completedSteps.length && why === "cancelled before")
2743
2900
  return new IncompleteStart(`Workflow start cancelled before \`${step}\`. No workflow-start command ran.`, details);
2744
- const pour = completedSteps.includes("mol pour") ? `the pour completed${root === undefined ? "" : ` (root ${root})`}` : step === "mol pour" ? "a pour was issued and may be partial" : "no pour was issued";
2901
+ const pour = completedSteps.some((done) => CREATES.has(done)) ? `the pour completed${root === undefined ? "" : ` (root ${root})`}` : CREATES.has(step) ? "a pour was issued and may be partial" : "no pour was issued";
2745
2902
  const ran = completedSteps.length ? `Completed: ${completedSteps.join(", ")}` : "No earlier command completed";
2746
2903
  return new IncompleteStart(`Workflow start incomplete: ${why} \`${step}\`. ${ran}; ${pour}. Inspect the run before retrying.`, details);
2747
2904
  };
@@ -2796,7 +2953,7 @@ async function runSpecStart(options, signal, commandMs = COMMAND_MS, module = BE
2796
2953
  return;
2797
2954
  }
2798
2955
  completedSteps.push(step);
2799
- if (args[0] !== "query" && args[0] !== "show" && args[0] !== "mol") {
2956
+ if (!READS.has(String(args[0]))) {
2800
2957
  resolveResult(undefined);
2801
2958
  return;
2802
2959
  }
@@ -2807,9 +2964,10 @@ async function runSpecStart(options, signal, commandMs = COMMAND_MS, module = BE
2807
2964
  reject(new Error("Beads returned invalid JSON; inspect the run before retrying"));
2808
2965
  return;
2809
2966
  }
2810
- const poured = step === "mol pour" ? payload(value) : undefined;
2811
- if (poured && typeof poured === "object" && "new_epic_id" in poured && typeof poured.new_epic_id === "string")
2812
- root = poured.new_epic_id;
2967
+ const created = CREATES.has(step) ? payload(value) : undefined;
2968
+ const createdRoot = createdRootOf(created, args[2]);
2969
+ if (createdRoot !== undefined)
2970
+ root = createdRoot;
2813
2971
  resolveResult(value);
2814
2972
  });
2815
2973
  return promise;
@@ -2871,12 +3029,20 @@ var START_INPUT = {
2871
3029
  migrate: {
2872
3030
  type: "boolean",
2873
3031
  description: "Only after MIGRATION_REQUIRED: true for the user's yes to migrating, with approvals=no and root"
3032
+ },
3033
+ epic: {
3034
+ type: "string",
3035
+ description: "Feature epic to nest the run under; default the one open epic with this spec_id"
3036
+ },
3037
+ reparent: {
3038
+ type: "boolean",
3039
+ description: "Only after REPARENT_REQUIRED: the user's answer to moving the run under its epic, with root"
2874
3040
  }
2875
3041
  },
2876
3042
  additionalProperties: false
2877
3043
  };
2878
3044
  var START_DESCRIPTION = `Start or resume a spec workflow, with an explicit routine approval choice from the user before pouring.
2879
- ` + "Persists and reads back the answer, reuses it on resume, and requires separate consent to migrate an existing gated run. Holds the Beads store's write lock for the whole start. Returns CHOICE_REQUIRED or MIGRATION_REQUIRED with a question to ask the user, READY when the run can advance, or INCOMPLETE (store-lock wait ran out, a bd command passed its bound, or cancellation) with the step reached and whether a pour was issued; inspect the run before retrying. Reviews, tests and safety confirmations remain required.";
3045
+ ` + "Persists and reads back the answer, reuses it on resume, and requires separate consent to migrate an existing gated run. Nests a new run under the spec's feature epic and titles it <spec> (<profile>); moving an existing unparented run needs the user's yes to REPARENT_REQUIRED. Refuses an epic that blocks on a step of the run, and warns when the epic's open blocks edges would hide the run from bd ready. Holds the Beads store's write lock for the whole start. Returns CHOICE_REQUIRED, MIGRATION_REQUIRED or REPARENT_REQUIRED with a question to ask the user, READY when the run can advance, or INCOMPLETE (store-lock wait ran out, a bd command passed its bound, or cancellation) with the step reached and whether a pour was issued; inspect the run before retrying. Reviews, tests and safety confirmations remain required.";
2880
3046
  var within = (base, path) => path === undefined ? base : isAbsolute7(path) ? path : resolve7(base, path);
2881
3047
  var record = (input) => input !== null && typeof input === "object" && !Array.isArray(input) ? input : {};
2882
3048
  function toolDirectory(input, session, speckitWorkspace) {
@@ -2950,7 +3116,7 @@ function readStartParams(input, directory) {
2950
3116
  return "approvals must be exactly yes or no";
2951
3117
  options.approvals = value.approvals;
2952
3118
  }
2953
- for (const key of ["root", "decision"]) {
3119
+ for (const key of ["root", "decision", "epic"]) {
2954
3120
  const field = value[key];
2955
3121
  if (field === undefined)
2956
3122
  continue;
@@ -2963,6 +3129,11 @@ function readStartParams(input, directory) {
2963
3129
  return "migrate must be a boolean";
2964
3130
  options.migrate = value.migrate;
2965
3131
  }
3132
+ if (value.reparent !== undefined) {
3133
+ if (typeof value.reparent !== "boolean")
3134
+ return "reparent must be a boolean";
3135
+ options.reparent = value.reparent;
3136
+ }
2966
3137
  return options;
2967
3138
  }
2968
3139
  async function executeStart(input, directory, signal, lock = BEADS_LOCK) {
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Install: copy this file into <repo>/.beads/formulas/ (or ~/.beads/formulas/).
4
4
  # Pour one molecule per feature:
5
- # bd mol pour speckit-basic --var feature=<NNN-slug> --var autonomous=<yes|no>
5
+ # bd mol pour speckit-basic --var feature=<NNN-slug> --var autonomous=<yes|no> --var title="<NNN-slug> (speckit-basic)"
6
6
  #
7
7
  # Every /speckit.* command here ships with spec-kit itself: specify,
8
8
  # clarify, plan, tasks, analyze. Verification requires no community extension.
@@ -24,6 +24,10 @@ pattern = "^[0-9]{3}-[a-z0-9-]+$"
24
24
  # Pass "no" for approvals enabled, or "yes" for approvals declined.
25
25
  # Persist the explicit choice on the root; reuse it on resume.
26
26
  # Reviews, verification, tests, and safety/provider confirmations remain required.
27
+ [vars.title]
28
+ description = "The run root's title, <NNN-slug> (speckit-basic); speckit_start passes it. bd titles the root from it."
29
+ required = true
30
+
27
31
  [vars.autonomous]
28
32
  required = true
29
33
  pattern = "^(yes|no)$"
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Install: copy this file into <repo>/.beads/formulas/ (or ~/.beads/formulas/).
4
4
  # Pour one molecule per feature:
5
- # bd mol pour speckit-feature --var feature=<NNN-slug> --var autonomous=<yes|no>
5
+ # bd mol pour speckit-feature --var feature=<NNN-slug> --var autonomous=<yes|no> --var title="<NNN-slug> (speckit-feature)"
6
6
  #
7
7
  # Authoring gotchas (verified against the bd 1.3.0 floor):
8
8
  # - [steps.gate] must be a TOML table, not a string.
@@ -24,6 +24,10 @@ pattern = "^[0-9]{3}-[a-z0-9-]+$"
24
24
  # Pass "no" for approvals enabled, or "yes" for approvals declined.
25
25
  # Persist the explicit choice on the root; reuse it on resume.
26
26
  # Reviews, verification, tests, and safety/provider confirmations remain required.
27
+ [vars.title]
28
+ description = "The run root's title, <NNN-slug> (speckit-feature); speckit_start passes it. bd titles the root from it."
29
+ required = true
30
+
27
31
  [vars.autonomous]
28
32
  required = true
29
33
  pattern = "^(yes|no)$"
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Install: copy this file into <repo>/.beads/formulas/ (or ~/.beads/formulas/).
4
4
  # Pour one molecule per feature:
5
- # bd mol pour speckit-lean --var feature=<NNN-slug> --var autonomous=<yes|no>
5
+ # bd mol pour speckit-lean --var feature=<NNN-slug> --var autonomous=<yes|no> --var title="<NNN-slug> (speckit-lean)"
6
6
  #
7
7
  # Omits the feature profile's checklist, security-review, code-review,
8
8
  # security-review-post, cleanup, sync-drift, sync-conflicts, and retro.
@@ -20,6 +20,10 @@ pattern = "^[0-9]{3}-[a-z0-9-]+$"
20
20
  # Pass "no" for approvals enabled, or "yes" for approvals declined.
21
21
  # Persist the explicit choice on the root; reuse it on resume.
22
22
  # Reviews, verification, tests, and safety/provider confirmations remain required.
23
+ [vars.title]
24
+ description = "The run root's title, <NNN-slug> (speckit-lean); speckit_start passes it. bd titles the root from it."
25
+ required = true
26
+
23
27
  [vars.autonomous]
24
28
  required = true
25
29
  pattern = "^(yes|no)$"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srobroek/pi-speckit-beads",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "SpecKit on Beads: a tasks.md guard, setup, ledger and bugfix skills, formulas, and the speckit-sync and speckit-verify subagents.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -13,9 +13,25 @@ speckit-beads plugin refuses the write. Once per session, run `bd prime` for the
13
13
  ## Find the implement step
14
14
 
15
15
  1. `bd query 'spec_id="<NNN-slug>"' --json` lists the spec's beads. The run root is the
16
- epic or molecule titled `speckit-basic`, `speckit-lean` or `speckit-feature`.
16
+ molecule titled `<NNN-slug> (<profile>)`, or for an older run, the epic or molecule
17
+ titled `speckit-basic`, `speckit-lean` or `speckit-feature`. The spec's feature epic
18
+ is its parent.
17
19
  2. `bd mol current <root-id>` shows the steps. Note the id of the `implement` step.
18
20
 
21
+ ## Where the spec's beads go
22
+
23
+ - The molecule root is a child of the spec's feature epic. `speckit_start` puts it
24
+ there. For an older run that has no parent, it asks first.
25
+ - Tasks go under the molecule's `implement` step, never directly under the epic.
26
+ - Never link the epic to a step of its own molecule with `blocks`. The parent link
27
+ already relates them, and that edge turns the nesting into a cycle.
28
+ - bd marks every child of a blocked epic blocked. Thus a `blocks` edge on an epic
29
+ with a live molecule hides every step of that molecule from `bd ready`.
30
+ Order specced epics with a `related` edge and a note on both epics instead.
31
+ - Put the real order between specs on task edges. The consuming task blocks on the
32
+ producing task, or on its contract bead.
33
+ - When the waiting epic has no live molecule, an epic-to-epic `blocks` edge is safe.
34
+
19
35
  ## Write the task graph
20
36
 
21
37
  Where `/speckit.tasks` says to write `tasks.md`, write `specs/<NNN-slug>/tasks.graph.json`
@@ -69,19 +69,36 @@ Workflow order is the poured molecule; `bd mol current <root>` is the current po
69
69
  Where the tool is absent, do what it does, with `--json` on every `bd` call:
70
70
 
71
71
  1. Find the run root: `bd query 'spec_id="<NNN-slug>"' --limit 0`, keeping the
72
- epics and molecules titled `speckit-basic`, `speckit-lean` or `speckit-feature`.
73
- With several, ask the user which one.
72
+ molecules titled `<NNN-slug> (<profile>)` and, for older runs, the epics and
73
+ molecules titled `speckit-basic`, `speckit-lean` or `speckit-feature`.
74
+ With more than one, ask the user which one. The same query finds the spec's
75
+ feature epic: the open epic among the results. With more than one, ask the user
76
+ which one.
74
77
  2. Reuse a `human_approvals` value of exactly `yes` or `no` recorded in the root's
75
78
  metadata. Otherwise ask the user "Require routine human approval checkpoints for
76
79
  this spec/run? Yes or no." (the `question` tool in OpenCode, `AskUserQuestion` in
77
80
  Claude Code), and wait for an explicit answer.
78
81
  3. Set `autonomous` to the opposite of `human_approvals`.
79
- 4. With no root, pour one:
80
- `bd mol pour <profile> --var feature=<NNN-slug> --var autonomous=<yes|no>`.
81
- The profile defaults to `speckit-feature`; the root is `new_epic_id`.
82
+ 4. With no root, create one. The profile defaults to `speckit-feature`.
83
+ - With a feature epic, bond the run under it:
84
+ `bd mol bond <profile> <epic> --type parallel --pour --ref speckit --var feature=<NNN-slug> --var autonomous=<yes|no> --var title="<NNN-slug> (<profile>)"`.
85
+ The root is the profile's entry in `id_mapping`, `<epic>.speckit`.
86
+ - When the epic already has a child `<epic>.speckit`, use `--ref speckit-2`.
87
+ If `speckit-2` exists too, use `speckit-3`, and so on. bd accepts a used ref
88
+ without an error and merges the two runs.
89
+ - Without one, pour it:
90
+ `bd mol pour <profile> --var feature=<NNN-slug> --var autonomous=<yes|no> --var title="<NNN-slug> (<profile>)"`.
91
+ The root is `new_epic_id`. bd titles it from `title`.
82
92
  5. Record the choice:
83
93
  `bd update <root> --spec-id <NNN-slug> --set-metadata spec_dir=specs/<NNN-slug> --set-metadata human_approvals=<answer> --set-metadata autonomous=<yes|no> --append-notes "Routine approvals: <answer>. Explicit user decision: <decision>"`.
84
- 6. Read it back with `bd show <root>`. Stop when the metadata differs.
94
+ 6. Read it back with `bd show <root>`. If the metadata, the title or the parent differs, stop.
95
+
96
+ An existing run with no parent moves under its epic only with the user's yes:
97
+
98
+ 1. Run `bd show <epic>`. If the epic blocks on a step of that run, stop and report it.
99
+ 2. Run `bd update <root> --parent <epic> --title "<NNN-slug> (<profile>)"`.
100
+
101
+ Never add a `blocks` edge from an epic to a step of its own molecule.
85
102
 
86
103
  Never add approval gates to an existing ungated run; start a new run instead. Changing
87
104
  a gated run to ungated needs `speckit_start` with the user's separate consent; without