pi-dev-flow 0.101.1 → 0.101.2

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
@@ -4,6 +4,13 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.101.2] - 2026-12-04
8
+
9
+ **Your Jira comments count as answers when dev-flow posts as a separate account.**
10
+
11
+ ### Fixed
12
+ - **Your Jira comments count as answers when dev-flow posts as a separate account.** dev-flow treated only the token owner's comments as your answer. With a token made for a separate agent account, your own comments were shown as "information only" and never answered a question or approved a gate. A new `answerers` key in the `flow-jira` block names the accounts whose comments count: Jira account ids, or `token` for the token's own account (the default). `flow jira init` now asks **Who answers?** and lists the people on the project's recent issues with their account ids. A project already set up with a separate agent account adds the key by hand, or re-runs `flow jira init`.
13
+
7
14
  ## [0.101.1] - 2026-12-04
8
15
 
9
16
  **A reply in Jira reaches the session within about a minute.**
package/docs/jira.md CHANGED
@@ -11,6 +11,7 @@ It talks to Atlassian's official **Rovo MCP server** (`https://mcp.atlassian.com
11
11
  3. **Ask the agent to set up Jira sync.** It runs `flow jira init`, which asks you one question at a time:
12
12
  - **Jira project?** Which project this repo syncs with.
13
13
  - **Issue types?** The types a flow may start from, such as Story or Bug.
14
+ - **Who answers?** Whose comments count as your answer. dev-flow posts as the token's account. If that is a separate account, such as a bot made for the agent, name the account you comment as. dev-flow lists the people on the project's recent issues with their account ids. Pick `token` when the token is your own.
14
15
  - **Mapping OK?** For each type, dev-flow reads its workflow and suggests a status for each flow stage. You can change any of them.
15
16
 
16
17
  The answers are written to `project.md`:
@@ -20,6 +21,7 @@ site = acme.atlassian.net
20
21
  cloudId = …
21
22
  project = DEV
22
23
  issueTypes = Story, Bug
24
+ answerers = 557058:1361862d-…
23
25
  status.Story.plan = To Do, Backlog
24
26
  status.Story.implement = In Progress
25
27
  status.Story.pre-release = In Review
@@ -30,6 +32,7 @@ status.Story.done = Done
30
32
  | Key | Meaning |
31
33
  |---|---|
32
34
  | `status.<Type>.<stage>` | Statuses that mean that stage: `plan`, `implement`, `pre-release`, `release` or `done`. dev-flow moves the issue to the first one listed. |
35
+ | `answerers` | Whose comments answer dev-flow's questions and can approve its gates: Jira account ids, or `token` for the token's own account. The default is `token`. Set it when dev-flow posts as a bot account and you answer as yourself; otherwise your comments are shown as information only. An account id is the last part of your Jira profile URL (`…/jira/people/<id>`). |
33
36
  | `mirror` | `asks` (the default) posts the agent's closing message when it asks you something. `all` posts every closing message. |
34
37
  | `watch` | How long to wait between checks for your reply after a question: `30m, 1h, 2h, 4h` by default. The last interval repeats. |
35
38
  | `watchCap` | Stop checking this long after the question. Default `72h`. |
@@ -43,7 +46,7 @@ status.Story.done = Done
43
46
  - **The plan goes as a PDF, one per round.** Jira can't show `plan.md` with its embedded mockups, so at the plan stage dev-flow prints the plan to a PDF with the mockups in it and attaches it to the comment, for example `DEV-12-plan-v1.pdf`. When the plan changes and you are asked again, the next comment gets `DEV-12-plan-v2.pdf`, so each round of the plan discussion has its own PDF on the issue. A re-rendered mockup counts as a change. If you are asked about an unchanged plan, the comment names the PDF already on the issue instead of attaching another. Until the plan is more than the issue's own description, no PDF is attached. The PDF is printed with the same headless chromium the plan stage renders mockups with: `chromium` or `google-chrome` on `PATH`, Playwright's browser cache, or the binary in `DEV_FLOW_CHROMIUM`. Without one, dev-flow attaches `plan.md` and the mockup images as files and says why.
44
47
  - **The approved plan always reaches the issue.** When the plan is approved, dev-flow posts it to the issue, with its PDF attached unless that version is already there. This covers approvals that never passed through a mirrored question: you approved in chat, or the issue was created or linked at the moment you approved. If the identical plan was already posted with the Approve? question, the approval comment names that PDF. A flow linked to an issue after approval gets its plan posted at link time.
45
48
  - **Answering in Jira:**
46
- - **Comment**, for example "Approved", "Verified", or a change request. Only comments from your own account (the token's owner) count as your answer. Other people's comments are shown in the session as information and never approve anything.
49
+ - **Comment**, for example "Approved", "Verified", or a change request. Only comments from the `answerers` accounts count as your answer: by default the token's owner, which is you when the token is your own. Other people's comments are shown in the session as information and never approve anything.
47
50
  - **Move the issue** to the status mapped to the next stage. A move to `implement` answers Approve?, `pre-release` answers Verified?, `release` answers Release?, and `done` answers Finish?. Any other move is shown as information.
48
51
 
49
52
  Your answer arrives in the session as your own message, so the gates treat it exactly like a chat reply.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.101.1",
3
+ "version": "0.101.2",
4
4
  "description": "Enforced feature workflow for Pi: plan → implement → pre-release → release, gated checkpoints, self-improvement reflections, one git worktree per feature, changelog + publish as part of the release",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -63,7 +63,10 @@ knobs · merge-policy state.
63
63
  ask for the token in chat.
64
64
  2. `Jira project?` → `--project=KEY`.
65
65
  3. `Issue types?` → `--types=A,B`.
66
- 4. `Mapping OK?` — show the proposed status mapping. The operator can
66
+ 4. `Who answers?` → `--answerers=<account id>[,…]`, or `--answerers=token`
67
+ when the token is the operator's own. Only these accounts' comments
68
+ answer questions and grant gates.
69
+ 5. `Mapping OK?` — show the proposed status mapping. The operator can
67
70
  change it with `--map=<Type>.<stage>=<Status>`. On their word,
68
71
  re-run with `--confirmed`.
69
72
  - **Starting from an issue.** When the operator names an issue key, run
package/src/core.ts CHANGED
@@ -153,6 +153,9 @@ export interface JiraConfig {
153
153
  watch: number[];
154
154
  /** seconds after the question when the watch gives up */
155
155
  watchCap: number;
156
+ /** the Jira accounts whose comments answer dev-flow's questions (and so may grant a gate): account ids, or
157
+ * `token` for the token's own account. Unset = the token's account — wrong when the token is a bot's */
158
+ answerers?: string[];
156
159
  /** seconds between cheap "did the issue change?" probes while a question waits; 0 = off; unset = 60 */
157
160
  probe?: number;
158
161
  }
@@ -54,12 +54,15 @@ const TOOLS = {
54
54
  transitions: ["listJiraIssueTransitions", "getTransitionsForJiraIssue"],
55
55
  transition: ["transitionJiraIssue"],
56
56
  create: ["createJiraIssue"],
57
+ search: ["searchJiraIssuesUsingJql"],
57
58
  } as const;
58
59
  type Op = keyof typeof TOOLS;
59
60
 
60
61
  /** Ops that change nothing: a lost answer may be asked for again. The rest (comment, upload, transition,
61
62
  * create) are retried only when the server said it did not run them. */
62
- const READ_OPS: ReadonlySet<Op> = new Set<Op>(["me", "resources", "projects", "issueTypes", "statuses", "issue", "comments", "transitions"]);
63
+ const READ_OPS: ReadonlySet<Op> = new Set<Op>(["me", "resources", "projects", "issueTypes", "statuses", "issue", "comments", "transitions", "search"]);
64
+ /** Ops sync works without: check() does not require them. */
65
+ const OPTIONAL_OPS: ReadonlySet<Op> = new Set<Op>(["search"]);
63
66
 
64
67
  const COMMENTS_PAGE = 20; // the server's cap per page
65
68
  const COMMENTS_MAX = 100;
@@ -239,7 +242,7 @@ export class JiraClient {
239
242
  try {
240
243
  await this.cloudId();
241
244
  const tools = await this.mcp.listTools();
242
- const missing = (Object.keys(TOOLS) as Op[]).filter((op) => !TOOLS[op].some((n) => tools.some((x) => x.name === n)));
245
+ const missing = (Object.keys(TOOLS) as Op[]).filter((op) => !OPTIONAL_OPS.has(op) && !TOOLS[op].some((n) => tools.some((x) => x.name === n)));
243
246
  if (missing.length) return { ok: false, error: missing.map(missingTool).join("; ") };
244
247
  } catch (e) {
245
248
  return { ok: false, error: explain((e as Error).message) };
@@ -256,6 +259,21 @@ export class JiraClient {
256
259
  return { ok: true, value: { accountId, displayName: str(v.displayName ?? v.name ?? v.email) || accountId } };
257
260
  }
258
261
 
262
+ /** The people on a project's recently updated issues (reporter, assignee, creator) — candidates for who
263
+ * answers dev-flow, with the account ids the playbook needs. */
264
+ async people(project: string): Promise<JiraResult<JiraUser[]>> {
265
+ const r = await this.call("search", { jql: `project = "${project.replace(/"/g, "")}" ORDER BY updated DESC`, max: 30, fields: ["reporter", "assignee", "creator"], view: "full" });
266
+ if (!r.ok) return r;
267
+ const seen = new Map<string, JiraUser>();
268
+ for (const i of arr(r.value, "issues").map(rec))
269
+ for (const k of ["reporter", "assignee", "creator"]) {
270
+ const u = rec(rec(i.fields)[k]);
271
+ const id = str(u.accountId);
272
+ if (id && !seen.has(id)) seen.set(id, { accountId: id, displayName: str(u.displayName) || id });
273
+ }
274
+ return { ok: true, value: [...seen.values()] };
275
+ }
276
+
259
277
  async projects(): Promise<JiraResult<{ key: string; name: string }[]>> {
260
278
  const r = await this.call("projects", { max: 100 });
261
279
  if (!r.ok) return r;
@@ -13,6 +13,8 @@
13
13
  * mirror = asks asks (default) | all — which of the agent's closing messages become comments
14
14
  * watch = 30m, 1h, 2h, 4h reply-check intervals after a question; the last repeats
15
15
  * watchCap = 72h stop watching this long after the question
16
+ * answerers = 557058:…, token whose comments answer dev-flow (account ids; token = the token's own account,
17
+ * the default) — set it when dev-flow posts as a bot account and you answer as yourself
16
18
  * probe = 1m while a question waits, look this often whether the issue changed (one
17
19
  * small call); a change runs the full check. off = the schedule only
18
20
  *
@@ -101,6 +103,13 @@ export function parseJiraBlock(entries: { line: string; where: string }[]): { cf
101
103
  else cfg.watchCap = s;
102
104
  break;
103
105
  }
106
+ case "answerers": {
107
+ const ids = list(value);
108
+ const bad = ids.filter((x) => x !== "token" && !/^[\w:-]{6,}$/.test(x));
109
+ if (!ids.length || bad.length) warn.push(`${where}: flow-jira answerers = "${value}" — expected Jira account ids or token — keeping the token's account`);
110
+ else cfg.answerers = ids;
111
+ break;
112
+ }
104
113
  case "probe": {
105
114
  const v = value.trim().toLowerCase();
106
115
  const s = /^(off|no|none|0)$/.test(v) ? 0 : parseDuration(v);
@@ -133,6 +142,7 @@ export function renderJiraBlock(cfg: JiraConfig): string[] {
133
142
  if (cfg.mirror !== "asks") L.push(`mirror = ${cfg.mirror}`);
134
143
  if (cfg.watch.join() !== DEFAULT_WATCH.join()) L.push(`watch = ${cfg.watch.map(fmtDuration).join(", ")}`);
135
144
  if (cfg.watchCap !== DEFAULT_WATCH_CAP) L.push(`watchCap = ${fmtDuration(cfg.watchCap)}`);
145
+ if (cfg.answerers?.length) L.push(`answerers = ${cfg.answerers.join(", ")}`);
136
146
  if (cfg.probe !== undefined && cfg.probe !== DEFAULT_PROBE) L.push(`probe = ${cfg.probe ? fmtDuration(cfg.probe) : "off"}`);
137
147
  return L;
138
148
  }
package/src/jira/sync.ts CHANGED
@@ -2,9 +2,10 @@
2
2
  * Jira sync decisions — pure, no I/O: what a mirrored comment says, which Jira activity is the operator's
3
3
  * answer, and when the watch checks next.
4
4
  *
5
- * Who may answer: only the token owner's account (`link.accountId`) — you, replying in Jira. dev-flow posts
6
- * as that same account, so its own comments are told apart by the ids it saved (`link.posted`) and by the
7
- * footer marker. Anyone else's comment, and any status move that answers nothing, is relayed as information.
5
+ * Who may answer: the accounts in the playbook's `answerers` (answererIds), by default the token owner's
6
+ * (`link.accountId`) — you, replying in Jira. dev-flow posts as the token's account, so its own comments are
7
+ * told apart by the ids it saved (`link.posted`) and by the footer marker. Anyone else's comment, and any
8
+ * status move that answers nothing, is relayed as information.
8
9
  */
9
10
  import type { FlowState, JiraConfig, JiraLink, JiraStage } from "../core.ts";
10
11
  import { stageOfStatus, statusForStage } from "./config.ts";
@@ -53,6 +54,13 @@ export interface Relay {
53
54
  text: string;
54
55
  }
55
56
 
57
+ /** The account ids whose comments are answers: the configured `answerers` (`token` = the token's own
58
+ * account), else the token's account. */
59
+ export function answererIds(cfg: Pick<JiraConfig, "answerers">, link: Pick<JiraLink, "accountId">): string[] {
60
+ const ids = cfg.answerers?.length ? cfg.answerers : ["token"];
61
+ return ids.map((a) => (a === "token" ? (link.accountId ?? "") : a)).filter(Boolean);
62
+ }
63
+
56
64
  /** Read new Jira activity against the link: the relays to deliver, and the link fields to store. */
57
65
  export function classifyActivity(o: {
58
66
  link: JiraLink;
@@ -78,7 +86,7 @@ export function classifyActivity(o: {
78
86
  if (link.posted.includes(c.id) || c.body.includes(MARKER)) continue;
79
87
  const body = c.body.trim();
80
88
  if (!body) continue;
81
- if (link.accountId && c.authorId === link.accountId) relays.push({ kind: "answer", text: `[Jira ${link.key} · your comment] ${body}` });
89
+ if (c.authorId && answererIds(cfg, link).includes(c.authorId)) relays.push({ kind: "answer", text: `[Jira ${link.key} · your comment] ${body}` });
82
90
  else relays.push({ kind: "info", text: `[Jira ${link.key} · comment from ${c.authorName || "someone else"} — information only, not an answer] ${body}` });
83
91
  }
84
92
  if (o.status && link.lastStatus && o.status.toLowerCase() !== link.lastStatus.toLowerCase()) {
@@ -84,6 +84,25 @@ export async function gateJiraInit(root: string, cfg: Config, rest: string[], fl
84
84
  if (unknown.length) return { text: `${project} has no issue type ${unknown.join(", ")} — it has ${offered.map((t) => t.name).join(", ")}`, isError: true };
85
85
  const canon = chosen.map((t) => types.value.find((x) => x.name.toLowerCase() === t.toLowerCase())!.name);
86
86
 
87
+ // who answers: dev-flow posts as the token's account, which may be a bot's — then the operator's own
88
+ // comments would read as a teammate's and never answer anything
89
+ const ansArg = flagValue(rest, "answerers");
90
+ const answerers = ansArg !== null ? ansArg.split(",").map((a) => a.trim()).filter(Boolean) : cfg.jira?.project === project ? cfg.jira.answerers : undefined;
91
+ if (answerers?.some((a) => a !== "token" && !/^[\w:-]{6,}$/.test(a))) return { text: `--answerers takes Jira account ids or token, comma-separated — got ${ansArg}`, isError: true };
92
+ if (!answerers?.length) {
93
+ const people = await client.people(project);
94
+ const others = people.ok ? people.value.filter((p) => p.accountId !== me.value.accountId) : [];
95
+ const lines = [` token — ${me.value.displayName}, the account this token belongs to (pick it when the token is your own)`, ...others.map((p) => ` ${p.accountId} — ${p.displayName}`)];
96
+ return {
97
+ text: needsOperator(
98
+ `${head}, project ${project}\nWhose Jira comments answer dev-flow's questions (and may approve its gates)? dev-flow posts as ${me.value.displayName}; when that is not the account you comment as, name yours.\n${lines.join("\n")}${others.length ? "" : `\n (no one else found on ${project}'s recent issues${people.ok ? "" : ` — ${people.error}`}; an account id is the last part of your Jira profile URL, …/jira/people/<id>)`}`,
99
+ "Who answers?",
100
+ `ask the operator, then re-run flow jira init --project=${project} --types=${canon.join(",")} --answerers=<id>[,<id>] (or --answerers=token)`,
101
+ ),
102
+ isError: true,
103
+ };
104
+ }
105
+
87
106
  const st = await client.statuses(project);
88
107
  if (!st.ok) return { text: `${head}\ncould not read the workflow statuses of ${project}: ${st.error}`, isError: true };
89
108
  // mapping: what is configured for this project, else the suggestion; --map overrides one stage of one type
@@ -120,6 +139,7 @@ export async function gateJiraInit(root: string, cfg: Config, rest: string[], fl
120
139
  watch: cfg.jira?.watch ?? [...DEFAULT_WATCH],
121
140
  watchCap: cfg.jira?.watchCap ?? DEFAULT_WATCH_CAP,
122
141
  ...(cfg.jira?.probe !== undefined ? { probe: cfg.jira.probe } : {}),
142
+ answerers,
123
143
  };
124
144
  const block = ["```flow-jira", ...renderJiraBlock(next), "```"].join("\n");
125
145
  const table = canon.map((t) => ` ${t}: ${JIRA_STAGES.map((g) => `${g} ← ${status[t][g]?.join(" | ") || "—"}`).join("; ")}`).join("\n");
@@ -128,7 +148,7 @@ export async function gateJiraInit(root: string, cfg: Config, rest: string[], fl
128
148
  text: needsOperator(
129
149
  `${head}, project ${project}\n${notes.join("\n")}\nProposed mapping (a move into a stage's status answers that stage's question: implement answers Approve?, pre-release Verified?, release Release?, done Finish?; dev-flow moves the issue to the first status listed):\n${table}\n\nproject.md ## global gets:\n${block}`,
130
150
  "Mapping OK?",
131
- `show the operator the mapping; on their word re-run flow jira init --project=${project} --types=${canon.join(",")} [--map=<Type>.<stage>=<Status>…] --confirmed`,
151
+ `show the operator the mapping; on their word re-run flow jira init --project=${project} --types=${canon.join(",")} --answerers=${answerers.join(",")} [--map=<Type>.<stage>=<Status>…] --confirmed`,
132
152
  ),
133
153
  isError: true,
134
154
  };