@srobroek/pi-speckit-beads 1.0.1 → 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,19 @@
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
+
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)
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * **speckit-beads:** pi reads the speckit-beads key of `<agentDir>/settings.json`; `<agentDir>/speckit-beads.json` is no longer read. Move its object under the key.
12
+
13
+ ### Features
14
+
15
+ * **speckit-beads:** read settings from pi settings.json ([3d0dd48](https://github.com/srobroek/harness-plugins/commit/3d0dd48d51fc20249d560e497578a46b549f096b))
16
+
1
17
  ## speckit-beads [1.0.1](https://github.com/srobroek/harness-plugins/compare/speckit-beads--v1.0.0...speckit-beads--v1.0.1) (2026-11-25)
2
18
 
3
19
  ### Bug Fixes
package/README.md CHANGED
@@ -35,9 +35,14 @@ On pi, a session start reports a missing or too-old tool with its install hint
35
35
 
36
36
  ## Options
37
37
 
38
- OpenCode takes them as the plugin's `options`. pi reads the same keys from
39
- `~/.pi/agent/speckit-beads.json` (`$PI_CODING_AGENT_DIR/speckit-beads.json`). Claude Code
40
- takes none.
38
+ OpenCode takes them as the plugin's `options`, and Claude Code takes none.
39
+
40
+ pi reads the same keys from the `speckit-beads` key of its user settings,
41
+ `~/.pi/agent/settings.json` (`$PI_CODING_AGENT_DIR/settings.json`). For example,
42
+ `{ "speckit-beads": { "tasksGuard": false } }` turns the tasks.md guard off. The extension ignores
43
+ a project's `.pi/settings.json`, so a repository cannot switch a guard off. Without the key, the
44
+ defaults below apply. A `speckit-beads` value that is not an object gives the defaults and a
45
+ warning at session start. So does a `settings.json` that is unreadable or not valid JSON.
41
46
 
42
47
  | Option | Default | Effect |
43
48
  | --- | --- | --- |
@@ -92,14 +97,28 @@ checks. Never skip a review or verification because its extension is not install
92
97
  an explicit routine-approval choice before pouring, records it on the run root, reads
93
98
  it back, and reuses it on resume.
94
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
+
95
110
  | Human approvals | Formula selection | Routine sign-offs |
96
111
  | --- | --- | --- |
97
112
  | Required | `autonomous=no` | Retained |
98
113
  | Declined | `autonomous=yes` | Omitted |
99
114
 
100
- - `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`.
101
- - `READY` names the run root and both selections.
102
- - `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.
103
122
 
104
123
  The whole start holds the beads store's embedded-write lock, so concurrent starts for
105
124
  a spec cannot pour duplicate runs. The lock module comes from this repository's shared
@@ -618,24 +618,35 @@ function repositoryRoot(dir) {
618
618
  }
619
619
  }
620
620
 
621
- // lib/src/pi-options.ts
621
+ // lib/src/pi-settings.ts
622
622
  import { readFileSync } from "fs";
623
- function loadPiOptionsFile(path, plugin, fallback) {
623
+ var PI_SETTINGS_FILE = "settings.json";
624
+ var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
625
+ function loadPiPluginSettings(path, plugin, fallback) {
626
+ const unusable = (problem) => ({ options: {}, warning: `${plugin}: ${problem}; ${fallback}.` });
627
+ const unread = `so its "${plugin}" key was not read`;
624
628
  let text;
625
629
  try {
626
630
  text = readFileSync(path, "utf8");
627
631
  } catch (error) {
628
632
  if (error.code === "ENOENT")
629
633
  return { options: {} };
630
- return { options: {}, warning: `${plugin}: ${path} could not be read; ${fallback}.` };
634
+ return unusable(`${path} could not be read, ${unread}`);
631
635
  }
632
- let raw;
636
+ let settings;
633
637
  try {
634
- raw = JSON.parse(text);
638
+ settings = JSON.parse(text.replace(/^\uFEFF/, ""));
635
639
  } catch {
636
- return { options: {}, warning: `${plugin}: ${path} is not valid JSON; ${fallback}.` };
640
+ return unusable(`${path} is not valid JSON, ${unread}`);
637
641
  }
638
- return { options: raw !== null && typeof raw === "object" && !Array.isArray(raw) ? raw : {} };
642
+ if (!isObject(settings))
643
+ return unusable(`${path} is not a JSON object, ${unread}`);
644
+ const value = settings[plugin];
645
+ if (value === undefined)
646
+ return { options: {} };
647
+ if (!isObject(value))
648
+ return unusable(`the "${plugin}" key in ${path} is not an object`);
649
+ return { options: value };
639
650
  }
640
651
 
641
652
  // plugins/speckit-beads/opencode/instructions/speckit-workflow.md
@@ -693,10 +704,35 @@ MUST Pour one molecule per spec dir. Profiles: \`speckit-basic\`,
693
704
  --set-metadata spec_dir=specs/<NNN-slug>\`.
694
705
  DEFAULT Track position with \`bd mol current <root-id>\`.
695
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)
696
727
  MUST Use the \`speckit_start\` tool for workflow start and resume.
697
- MUST On \`CHOICE_REQUIRED\` or \`MIGRATION_REQUIRED\`, ask the returned question
698
- and supply only the explicit user answer and decision when invoking it again.
699
- 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
+
700
736
  SPEC START (new or resumed spec lifecycle)
701
737
  MUST Before pouring, bonding, or advancing, find the spec's existing molecule root;
702
738
  read its metadata if one exists.
@@ -1822,7 +1858,15 @@ function issueList(value) {
1822
1858
  issue_type: typeof row.issue_type === "string" ? row.issue_type : undefined,
1823
1859
  spec_id: typeof row.spec_id === "string" ? row.spec_id : undefined,
1824
1860
  await_type: typeof row.await_type === "string" ? row.await_type : undefined,
1825
- 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
1826
1870
  };
1827
1871
  });
1828
1872
  }
@@ -1839,8 +1883,15 @@ var ROUTINE = [
1839
1883
  ["analyze-approval", "analyze approval"],
1840
1884
  ["verify-signoff", "verify sign-off"]
1841
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
+ }
1842
1893
  function isRunRoot(row) {
1843
- 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;
1844
1895
  }
1845
1896
  function recordedChoice(root, spec) {
1846
1897
  const metadata = root?.metadata ?? {};
@@ -1951,6 +2002,89 @@ async function migrateRoutine(root, options, command) {
1951
2002
  if (resolutions.some((row) => after.find((issue) => issue.id === row.gate)?.status !== "closed" || after.find((issue) => issue.id === row.step)?.status !== "closed"))
1952
2003
  throw new Error("Routine migration readback failed; do not record approvals as declined");
1953
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
+ }
1954
2088
  async function startSpec(input, command) {
1955
2089
  const options = { ...input, spec: input.spec ?? await specOfRoot(input.root, command) };
1956
2090
  if (!/^[0-9]{3}-[a-z0-9-]+$/.test(options.spec))
@@ -1961,7 +2095,8 @@ async function startSpec(input, command) {
1961
2095
  const requested = approval(options.approvals);
1962
2096
  if (options.migrate !== undefined && requested !== "no")
1963
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");
1964
- 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);
1965
2100
  if (roots.length > 1 && !options.root)
1966
2101
  throw new Error("Multiple runs exist; select an explicit root");
1967
2102
  let root = options.root ? issueList(await command(["show", options.root]))[0] : roots[0];
@@ -1982,17 +2117,31 @@ async function startSpec(input, command) {
1982
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.`;
1983
2118
  return { status: "MIGRATION_REQUIRED", root: root.id, question, text: question };
1984
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;
1985
2126
  if ((saved === undefined || migration) && !options.decision?.trim())
1986
2127
  throw new Error("Record the explicit user decision before creating or migrating a workflow");
1987
2128
  if (root && migration)
1988
2129
  await migrateRoutine(root, options, command);
1989
2130
  const mode = selected === "yes" ? "no" : "yes";
1990
- if (!root) {
1991
- const poured = object(payload(await command(["mol", "pour", profile, "--var", `feature=${options.spec}`, "--var", `autonomous=${mode}`])));
1992
- if (typeof poured.new_epic_id !== "string")
1993
- throw new Error("Pour returned no new_epic_id; inspect the created run before retrying");
1994
- root = { id: poured.new_epic_id };
1995
- }
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
+ ]);
1996
2145
  if (saved === undefined || migration)
1997
2146
  await command([
1998
2147
  "update",
@@ -2011,12 +2160,17 @@ async function startSpec(input, command) {
2011
2160
  const confirmed = issueList(await command(["show", root.id]))[0];
2012
2161
  if (confirmed?.metadata?.human_approvals !== selected || confirmed.metadata.autonomous !== mode)
2013
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("");
2014
2166
  return {
2015
2167
  status: "READY",
2016
2168
  root: root.id,
2169
+ ...epic ? { epic: epic.id } : {},
2017
2170
  humanApprovals: selected,
2018
2171
  autonomous: mode,
2019
- 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}`
2020
2174
  };
2021
2175
  }
2022
2176
 
@@ -2690,7 +2844,9 @@ async function withEmbeddedWriteLock(cwd, owner, write, env = process.env, deadl
2690
2844
  // plugins/speckit-beads/opencode/src/spec-start-runtime.ts
2691
2845
  var BEADS_LOCK = { embeddedStoreFor, withEmbeddedWriteLock };
2692
2846
  var COMMAND_MS = 120000;
2693
- 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"]);
2694
2850
  var TERMINATION_GRACE_MS = 5000;
2695
2851
 
2696
2852
  class IncompleteStart extends Error {
@@ -2701,6 +2857,18 @@ class IncompleteStart extends Error {
2701
2857
  this.name = "IncompleteStart";
2702
2858
  }
2703
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
+ }
2704
2872
  async function runSpecStart(options, signal, commandMs = COMMAND_MS, module = BEADS_LOCK, timers = globalThis) {
2705
2873
  const started = Date.now();
2706
2874
  const cwd = realpathSync4(options.workspace);
@@ -2730,7 +2898,7 @@ async function runSpecStart(options, signal, commandMs = COMMAND_MS, module = BE
2730
2898
  };
2731
2899
  if (!completedSteps.length && why === "cancelled before")
2732
2900
  return new IncompleteStart(`Workflow start cancelled before \`${step}\`. No workflow-start command ran.`, details);
2733
- 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";
2734
2902
  const ran = completedSteps.length ? `Completed: ${completedSteps.join(", ")}` : "No earlier command completed";
2735
2903
  return new IncompleteStart(`Workflow start incomplete: ${why} \`${step}\`. ${ran}; ${pour}. Inspect the run before retrying.`, details);
2736
2904
  };
@@ -2785,7 +2953,7 @@ async function runSpecStart(options, signal, commandMs = COMMAND_MS, module = BE
2785
2953
  return;
2786
2954
  }
2787
2955
  completedSteps.push(step);
2788
- if (args[0] !== "query" && args[0] !== "show" && args[0] !== "mol") {
2956
+ if (!READS.has(String(args[0]))) {
2789
2957
  resolveResult(undefined);
2790
2958
  return;
2791
2959
  }
@@ -2796,9 +2964,10 @@ async function runSpecStart(options, signal, commandMs = COMMAND_MS, module = BE
2796
2964
  reject(new Error("Beads returned invalid JSON; inspect the run before retrying"));
2797
2965
  return;
2798
2966
  }
2799
- const poured = step === "mol pour" ? payload(value) : undefined;
2800
- if (poured && typeof poured === "object" && "new_epic_id" in poured && typeof poured.new_epic_id === "string")
2801
- 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;
2802
2971
  resolveResult(value);
2803
2972
  });
2804
2973
  return promise;
@@ -2860,12 +3029,20 @@ var START_INPUT = {
2860
3029
  migrate: {
2861
3030
  type: "boolean",
2862
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"
2863
3040
  }
2864
3041
  },
2865
3042
  additionalProperties: false
2866
3043
  };
2867
3044
  var START_DESCRIPTION = `Start or resume a spec workflow, with an explicit routine approval choice from the user before pouring.
2868
- ` + "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.";
2869
3046
  var within = (base, path) => path === undefined ? base : isAbsolute7(path) ? path : resolve7(base, path);
2870
3047
  var record = (input) => input !== null && typeof input === "object" && !Array.isArray(input) ? input : {};
2871
3048
  function toolDirectory(input, session, speckitWorkspace) {
@@ -2939,7 +3116,7 @@ function readStartParams(input, directory) {
2939
3116
  return "approvals must be exactly yes or no";
2940
3117
  options.approvals = value.approvals;
2941
3118
  }
2942
- for (const key of ["root", "decision"]) {
3119
+ for (const key of ["root", "decision", "epic"]) {
2943
3120
  const field = value[key];
2944
3121
  if (field === undefined)
2945
3122
  continue;
@@ -2952,6 +3129,11 @@ function readStartParams(input, directory) {
2952
3129
  return "migrate must be a boolean";
2953
3130
  options.migrate = value.migrate;
2954
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
+ }
2955
3137
  return options;
2956
3138
  }
2957
3139
  async function executeStart(input, directory, signal, lock = BEADS_LOCK) {
@@ -2972,14 +3154,13 @@ async function executeStart(input, directory, signal, lock = BEADS_LOCK) {
2972
3154
  // plugins/speckit-beads/pi-src/routes.ts
2973
3155
  import { homedir as homedir2 } from "os";
2974
3156
  import { isAbsolute as isAbsolute8, resolve as resolve8 } from "path";
2975
- var OPTIONS_FILE = "speckit-beads.json";
2976
3157
  var WORKFLOW_SECTION = "speckit_workflow";
2977
3158
  var MESSAGE_TYPE = "speckit-beads";
2978
- function guardReason(optionsPath) {
2979
- return `${GUARD_REASON} Disable: set "tasksGuard": false in ${optionsPath}`;
3159
+ function guardReason(settingsPath) {
3160
+ return `${GUARD_REASON} Disable: set "tasksGuard": false under the "speckit-beads" key of ${settingsPath}`;
2980
3161
  }
2981
- function tasksToIssuesReason(optionsPath) {
2982
- return `${TASKSTOISSUES_REASON} Disable: set "blockTasksToIssues": false in ${optionsPath}`;
3162
+ function tasksToIssuesReason(settingsPath) {
3163
+ return `${TASKSTOISSUES_REASON} Disable: set "blockTasksToIssues": false under the "speckit-beads" key of ${settingsPath}`;
2983
3164
  }
2984
3165
  var ROUTED = new Set([...IMPLEMENT_SKILLS, ...ANALYZE_SKILLS, ...TASKSTOISSUES_SKILLS]);
2985
3166
  function routedCommand(text) {
@@ -3037,12 +3218,12 @@ function notify(ctx, message) {
3037
3218
  `);
3038
3219
  }
3039
3220
  function setupSpeckitPi(pi, deps = {}) {
3040
- const optionsPath = deps.optionsPath ?? join8(getAgentDir(), OPTIONS_FILE);
3041
- const loaded = loadPiOptionsFile(optionsPath, "speckit-beads", "the defaults apply");
3221
+ const settingsPath = deps.settingsPath ?? join8(getAgentDir(), PI_SETTINGS_FILE);
3222
+ const loaded = loadPiPluginSettings(settingsPath, "speckit-beads", "the defaults apply");
3042
3223
  const options = parseOptions(loaded.options, PI_INTEGRATION);
3043
3224
  const probe = deps.probe ?? ((directory) => beadsActive(directory));
3044
3225
  const workflow = speckit_workflow_default.trim();
3045
- const refusal = tasksToIssuesReason(optionsPath);
3226
+ const refusal = tasksToIssuesReason(settingsPath);
3046
3227
  const workspaceOf = (directory) => speckitWorkspace(directory, repositoryRoot(directory));
3047
3228
  const routing = async (cwd) => {
3048
3229
  const active = await probe(cwd);
@@ -3090,7 +3271,7 @@ function setupSpeckitPi(pi, deps = {}) {
3090
3271
  return;
3091
3272
  let reason;
3092
3273
  try {
3093
- reason = await decideToolCall(event.toolName, guardInput(event.input, ctx.cwd), ctx.cwd, probe, guardReason(optionsPath));
3274
+ reason = await decideToolCall(event.toolName, guardInput(event.input, ctx.cwd), ctx.cwd, probe, guardReason(settingsPath));
3094
3275
  } catch {
3095
3276
  return;
3096
3277
  }
@@ -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": "1.0.1",
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