pi-dev-flow 0.100.1 → 0.101.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.101.0] - 2026-12-04
8
+
9
+ **Jira issues get the plan as a PDF, mockups included, one per round of the plan discussion.**
10
+
11
+ ### Changed
12
+ - **Jira issues get the plan as a PDF, mockups included, one per round of the plan discussion.** dev-flow used to attach the raw `plan.md` only with the Approve? question, and Jira can't show the mockups it embeds. Other questions about the plan said "see plan.md" with nothing on the issue to see. Now, at the plan stage, each mirrored question carries the plan as it stands. A changed plan is printed to a new PDF with its mockups in it and attached as `<KEY>-plan-v1.pdf`, `-v2.pdf` and so on. An unchanged plan is named, not attached again, and a re-rendered mockup counts as a change. The issue's own seeded description gets no PDF. The approval comment attaches the approved round's PDF unless that round is already on the issue. The PDF is printed with the headless chromium the plan stage uses for mockups; `DEV_FLOW_CHROMIUM` can name the binary. With no chromium, `plan.md` and the mockups are attached as files, as before, and the note says why.
13
+
14
+ ## [0.100.2] - 2026-12-04
15
+
16
+ **Jira sync has one path: the Atlassian MCP server with a scoped token.**
17
+
18
+ ### Changed
19
+ - **Jira sync has one path: the Atlassian MCP server with a scoped token.** dev-flow used to retry some calls through Jira's REST API. Those calls were statuses, comments, attachments and issue creation. 0.100.1 also tried a Basic header when Bearer failed. But a token works on only one of these paths: a scoped token works only on MCP, and a plain one gets only the MCP search tool. So the fallbacks could never succeed, and when they failed they hid the real error. They are gone, and `/flow jira login` now asks only for the site and the token. Older `jira.json` files still load; the `email` and `auth` fields in them are ignored. `JIRA_EMAIL` is no longer needed.
20
+ - **Login and `flow jira init` check everything sync needs up front.** They confirm the token reaches the site and the server offers every tool dev-flow calls. If a tool is missing, they name the scope the token lacks. An unreachable site and a non-scoped token each get an error that says how to fix it.
21
+ - **MCP calls retry transient failures.** 429s, 5xx answers, timeouts and dropped connections are retried with backoff, honouring `Retry-After`. A write is retried only when the server said it did not run it (429 or 503), so a lost answer never posts a comment or creates an issue twice. Reply checks now page through the newest 100 comments instead of 20.
22
+
7
23
  ## [0.100.1] - 2026-12-04
8
24
 
9
25
  **Jira sync works with a scoped API token.**
package/README.md CHANGED
@@ -107,8 +107,8 @@ More detail, and what this deliberately is *not*, is in
107
107
  - **`flow_stage` workers.** The agent can hand big chunks of work, or a second-opinion review, to a
108
108
  fresh Pi session.
109
109
  - **Jira sync (opt-in).** `flow jira init` links the project to a Jira project. A flow can then start
110
- from an issue, each question goes to the issue as a comment (plan and screenshots attached), and you
111
- can answer there by commenting or by moving the issue.
110
+ from an issue, each question goes to the issue as a comment (the plan attached as a PDF with its
111
+ mockups, one per round), and you can answer there by commenting or by moving the issue.
112
112
  [More](https://github.com/dmarchevsky/pi-dev-flow/blob/main/docs/jira.md)
113
113
  - **A roadmap.** `.dev-flow/roadmap.md` is a backlog of future features. `flow start <slug>` can
114
114
  pick one up.
package/docs/jira.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Jira sync
2
2
 
3
- Optional. It is off until you run `flow jira init` in a project. Once on, a flow can start from a Jira issue. Every question dev-flow asks you is also posted on the issue, with the plan and screenshots attached. You can answer there, with a comment or by moving the issue, and the flow carries on.
3
+ Optional. It is off until you run `flow jira init` in a project. Once on, a flow can start from a Jira issue. Every question dev-flow asks you is also posted on the issue, with the plan attached as a PDF, mockups included, and any screenshots it names. You can answer there, with a comment or by moving the issue, and the flow carries on.
4
4
 
5
- It talks to Atlassian's official **Rovo MCP server** (`https://mcp.atlassian.com/v2/mcp`). It uses that server's tools for everything, except two calls the server has no tool for, which go to Jira's REST API with the same token (see [Limits](#limits)). Jira Cloud only.
5
+ It talks to Atlassian's official **Rovo MCP server** (`https://mcp.atlassian.com/v2/mcp`). That server is its only path to Jira: every read and write goes through its tools, and nothing goes to Jira's REST API. Jira Cloud only.
6
6
 
7
7
  ## Setup
8
8
 
9
- 1. **Create a scoped API token for the Atlassian MCP app** at id.atlassian.com → Security → API tokens → *Create API token with scopes*. Give it `read:jira:agent-interface` and `write:jira:agent-interface`; `search:jira:agent-interface` is optional. An org admin must have turned on API-token authentication for the Rovo MCP server (Atlassian Administration → Rovo MCP server). A plain token (*Create API token*) does not work: with one, the MCP server offers only its search tool. dev-flow sends a scoped token as `Authorization: Bearer <token>`. A scoped token sent as Basic `email:token` gets through the handshake, but every call fails with *Cloud id … isn't explicitly granted*.
10
- 2. **Run `/flow jira login [site]`** and type the site, your email and the token into its dialogs. dev-flow checks them against the MCP server, then saves them to `~/.pi/agent/dev-flow/jira.json` (mode 0600). The token never passes through the chat or the agent, and is never written to `project.md`. Login also records which auth scheme worked (`auth = bearer` or `basic`), so later sessions skip the check. You can use environment variables instead: `JIRA_SITE`, `JIRA_EMAIL` and `JIRA_API_TOKEN` override the file, and `JIRA_AUTH=bearer|basic` pins the scheme.
9
+ 1. **Create a scoped API token for the Atlassian MCP app** at id.atlassian.com → Security → API tokens → *Create API token with scopes*. Give it `read:jira:agent-interface` and `write:jira:agent-interface`; `search:jira:agent-interface` is optional. An org admin must have turned on API-token authentication for the Rovo MCP server (Atlassian Administration → Rovo MCP server). A plain token (*Create API token*) does not work: with one, the MCP server offers only its search tool. dev-flow sends the token as `Authorization: Bearer <token>`. No email is needed.
10
+ 2. **Run `/flow jira login [site]`** and type the site and the token into its dialogs. dev-flow checks the token against the MCP server before it saves anything. The token must reach the site and name your account, and the server must offer every tool dev-flow uses. If one is missing, the check names the scope the token lacks. The token is saved to `~/.pi/agent/dev-flow/jira.json` (mode 0600). It never passes through the chat or the agent, and is never written to `project.md`. You can use environment variables instead: `JIRA_SITE` and `JIRA_API_TOKEN` override the file.
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.
@@ -39,8 +39,9 @@ status.Story.done = Done
39
39
  - **"Start a flow for DEV-12"** runs `flow start --jira=DEV-12`. The issue must be in the project and of a synced type. The flow's slug comes from the issue key and summary, and the description seeds `plan/plan.md`. dev-flow posts a "started" comment and moves the issue to its `plan` status. To link a flow that is already running, use `flow jira link DEV-12`.
40
40
  - **No issue yet?** When you start a flow without naming an issue, the agent offers three choices: create a new issue in the synced project, link an existing one, or go without. The agent shows you the summary, type and description before anything is created (`flow jira create`), and links the new issue to the flow. Starting with `--no-jira` skips the offer.
41
41
  - **Issues for roadmap items.** Ask the agent to create issues for roadmap items (`flow jira create --roadmap=2,5`). You see the list first. Each item's text becomes the summary and its brief the description, and the item is stamped with its key (`- [ ] Dark mode [DEV-14]`). When that item is picked and started, the flow links to its issue automatically.
42
- - **Questions go to the issue.** When the agent stops to ask you something, its message is also posted as a comment. At **Approve?** it attaches `plan.md` and the mockups. Any screenshot the message names by path is attached as well. The same message is never posted twice, and the same file never uploaded twice.
43
- - **The approved plan always reaches the issue.** When the plan is approved, dev-flow posts it to the issue with `plan.md` and the mockups attached. 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 just says so. A flow linked to an issue after approval gets its plan posted at link time.
42
+ - **Questions go to the issue.** When the agent stops to ask you something, its message is also posted as a comment. Any screenshot the message names by path is attached. The same message is never posted twice, and the same file never uploaded twice.
43
+ - **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
+ - **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.
44
45
  - **Answering in Jira:**
45
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.
46
47
  - **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.
@@ -65,5 +66,6 @@ In a synced project, dev-flow also registers the Atlassian MCP server for the ag
65
66
 
66
67
  - Jira Cloud only. The Rovo MCP server does not serve Jira Data Center.
67
68
  - Attachments use the MCP server's two-step upload. Step one returns a short-lived Atlassian Media upload as a `curl` command. dev-flow never runs it. It reads the URL and token from the command, accepting only an https request to `api.media.atlassian.com`, sends the file itself, then attaches the file with step two.
68
- - If an MCP call can't do the job, dev-flow retries it through Jira's REST API with the same token. A token scoped to the MCP app is refused there, so those retries only help with a token that also has Jira REST scopes.
69
+ - MCP only. A scoped token works on the MCP server and nowhere else, so there is no REST fallback. Transient failures are retried with backoff: 429s, 5xx answers, timeouts and dropped connections. A write, such as a comment, a new issue, a transition or an attachment, is retried only when the server answered 429 or 503, meaning it did not run the request. A write is never sent twice because its answer was lost.
70
+ - Reply checks read the newest 100 comments on the issue, 20 per request.
69
71
  - dev-flow polls Jira; it does not use webhooks, which would need a public URL for Jira to call.
@@ -36,7 +36,7 @@ import { foldView, pluginUpstream } from "../src/runtime/reflect.ts";
36
36
  import { type FlowHooks, runFlow } from "../src/runtime/gates.ts";
37
37
  import { JiraWatch } from "../src/runtime/jira-watch.ts";
38
38
  import { mirrorClosingMessage, disarmWatch, jiraSeams, resetJiraClients } from "../src/runtime/jira.ts";
39
- import { loadCreds, mcpAuth, normSite, saveAuth, saveCreds } from "../src/jira/creds.ts";
39
+ import { bearer, loadCreds, normSite, saveCreds } from "../src/jira/creds.ts";
40
40
  import { JiraClient, MCP_URL } from "../src/jira/client.ts";
41
41
  import type { Relay } from "../src/jira/sync.ts";
42
42
  import { grantCheck, grantRecord, isFriction, lastOperatorText, newGrantLedger, operatorMessageCount, type RefusalStreak } from "../src/runtime/grants.ts";
@@ -288,47 +288,32 @@ export default function devFlow(pi: ExtensionAPI) {
288
288
  return "";
289
289
  };
290
290
  /** Give the agent the Atlassian MCP server's tools (deferred: found through tool search) for a Jira-synced
291
- * project — the issue, its links, its history. A server of the same name in mcp.json wins. With no stored
292
- * auth scheme the token is probed first (Bearer, then Basic) and the one that works is remembered. */
293
- const registerAtlassianMcp = async (cfg: ReturnType<typeof loadProject>["cfg"]) => {
294
- if (!cfg.jira || !pi.registerMcpServer) return;
291
+ * project — the issue, its links, its history. A server of the same name in mcp.json wins. */
292
+ const registerAtlassianMcp = (cfg: ReturnType<typeof loadProject>["cfg"]) => {
293
+ if (!cfg.jira) return;
295
294
  const creds = loadCreds(cfg.jira.site, jiraSeams.env ?? process.env, jiraSeams.credsFile);
296
295
  if (!creds) return;
297
- let scheme = creds.auth;
298
- if (!scheme) {
299
- try {
300
- const picked = await new JiraClient(creds, { fetch: jiraSeams.fetch }).authScheme();
301
- scheme = picked.scheme;
302
- if (picked.verified && creds.source === "file") saveAuth(creds, scheme, jiraSeams.credsFile);
303
- } catch {
304
- scheme = "bearer"; // unreachable now: the scoped token's scheme
305
- }
306
- }
307
296
  try {
308
- pi.registerMcpServer("atlassian", { url: MCP_URL, headers: { Authorization: mcpAuth(creds, scheme) }, exposure: "deferred", description: `Atlassian Jira/Confluence on ${creds.site} (dev-flow Jira sync: project ${cfg.jira.project})` });
297
+ pi.registerMcpServer?.("atlassian", { url: MCP_URL, headers: { Authorization: bearer(creds) }, exposure: "deferred", description: `Atlassian Jira/Confluence on ${creds.site} (dev-flow Jira sync: project ${cfg.jira.project})` });
309
298
  } catch {
310
299
  /* another extension owns the name, or no MCP support: the sync itself does not need it */
311
300
  }
312
301
  };
313
302
  /** /flow jira login [site] — the operator's own dialog: the token never passes through the chat or the agent. */
314
303
  const jiraLogin = async (ctx: ExtensionContext, root: string, siteArg?: string): Promise<string> => {
315
- if (!ctx.hasUI) return "flow jira login needs a dialog — set JIRA_SITE, JIRA_EMAIL and JIRA_API_TOKEN instead";
304
+ if (!ctx.hasUI) return "flow jira login needs a dialog — set JIRA_SITE and JIRA_API_TOKEN instead";
316
305
  const cfg = initiated(root) ? loadProject(dfDir(root)).cfg : undefined;
317
306
  const site = siteArg ?? cfg?.jira?.site ?? (await ctx.ui.input("Jira site", "acme.atlassian.net"));
318
307
  if (!site?.trim()) return "login cancelled";
319
- const prev = loadCreds(site, {}, jiraSeams.credsFile);
320
- const email = await ctx.ui.input(`Atlassian account email for ${normSite(site)}`, prev?.email ?? "you@example.com");
321
- if (!email?.trim()) return "login cancelled";
322
- const token = await ctx.ui.input("Atlassian API token (id.atlassian.com → Security → API tokens)", "paste the token");
308
+ const token = await ctx.ui.input("Scoped Atlassian API token (id.atlassian.com → Security → API tokens → Create API token with scopes: read:jira:agent-interface, write:jira:agent-interface)", "paste the token");
323
309
  if (!token?.trim()) return "login cancelled";
324
- const probe = new JiraClient({ site: normSite(site), email: email.trim(), token: token.trim(), source: "file" }, { fetch: jiraSeams.fetch });
325
- const me = await probe.me();
326
- if (!me.ok) return `not saved — the Atlassian MCP server refused the token: ${me.error}`;
327
- const auth = await probe.authScheme();
328
- saveCreds(site, email, token, jiraSeams.credsFile, auth.verified ? auth.scheme : undefined);
310
+ const probe = new JiraClient({ site: normSite(site), token: token.trim(), source: "file" }, { fetch: jiraSeams.fetch });
311
+ const ok = await probe.check();
312
+ if (!ok.ok) return `not saved — ${ok.error}`;
313
+ saveCreds(site, token, jiraSeams.credsFile);
329
314
  resetJiraClients();
330
- if (cfg) await registerAtlassianMcp(cfg);
331
- return `Jira login saved for ${normSite(site)} — authenticated as ${me.value.displayName}. ${cfg?.jira ? "Jira sync is ready." : "Next: flow jira init picks the project, issue types and status mapping."}`;
315
+ if (cfg) registerAtlassianMcp(cfg);
316
+ return `Jira login saved for ${normSite(site)} — authenticated as ${ok.value.displayName}. ${cfg?.jira ? "Jira sync is ready." : "Next: flow jira init picks the project, issue types and status mapping."}`;
332
317
  };
333
318
 
334
319
  pi.registerCommand("flow", {
@@ -719,7 +704,7 @@ export default function devFlow(pi: ExtensionAPI) {
719
704
  if (!initiated(root)) return;
720
705
  const cfg = loadProject(dfDir(root)).cfg;
721
706
  if (!cfg.jira) return;
722
- void registerAtlassianMcp(cfg);
707
+ registerAtlassianMcp(cfg);
723
708
  // a question asked before this session (or before a restart) is caught up now, then watched again
724
709
  const st = boundFeature(root, sessionKey(ctx));
725
710
  if (st?.jira?.watch && !isWorkerSession(ctx)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.100.1",
3
+ "version": "0.101.0",
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": [
package/src/core.ts CHANGED
@@ -172,6 +172,10 @@ export interface JiraLink {
172
172
  lastStatus?: string;
173
173
  /** sha1 of files already attached, so a re-ask does not attach them again */
174
174
  attached?: string[];
175
+ /** the plan PDFs attached, oldest first: one per plan iteration (plan.md and the images it embeds) */
176
+ plans?: { hash: string; name: string }[];
177
+ /** the plan iteration the link seeded from the issue (or the roadmap draft): not a plan worth a PDF yet */
178
+ seeded?: string;
175
179
  /** sha1 of the last closing message mirrored — the same message is never posted twice */
176
180
  mirrored?: string;
177
181
  /** the open question a watch is waiting on: armed when it was posted, `checks` made since */