flow-workflows 0.114.0 → 0.115.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -4
- package/adapters/codex/CORE.md +142 -134
- package/adapters/codex/skills/flow-bug-fix/SKILL.md +1 -1
- package/adapters/codex/skills/flow-bug-ship/SKILL.md +1 -1
- package/adapters/codex/skills/flow-doctor/SKILL.md +1 -1
- package/adapters/codex/skills/flow-feat-build/SKILL.md +2 -2
- package/adapters/codex/skills/flow-feat-ship/SKILL.md +1 -1
- package/adapters/codex/skills/flow-work-README/SKILL.md +5 -5
- package/adapters/codex/skills/flow-work-abandon/SKILL.md +1 -1
- package/adapters/codex/skills/flow-work-daily/SKILL.md +1 -1
- package/adapters/codex/skills/flow-work-handoff/SKILL.md +4 -3
- package/adapters/codex/skills/flow-work-resume/SKILL.md +8 -24
- package/adapters/gemini/CORE.md +142 -134
- package/adapters/gemini/commands/flow/bug/fix.toml +1 -1
- package/adapters/gemini/commands/flow/bug/ship.toml +1 -1
- package/adapters/gemini/commands/flow/doctor.toml +1 -1
- package/adapters/gemini/commands/flow/feat/build.toml +2 -2
- package/adapters/gemini/commands/flow/feat/ship.toml +1 -1
- package/adapters/gemini/commands/flow/work/README.toml +5 -5
- package/adapters/gemini/commands/flow/work/abandon.toml +1 -1
- package/adapters/gemini/commands/flow/work/daily.toml +1 -1
- package/adapters/gemini/commands/flow/work/handoff.toml +4 -3
- package/adapters/gemini/commands/flow/work/resume.toml +8 -24
- package/adapters/hermes/CORE.md +142 -134
- package/adapters/hermes/skills/flow-bug-fix/SKILL.md +1 -1
- package/adapters/hermes/skills/flow-bug-ship/SKILL.md +1 -1
- package/adapters/hermes/skills/flow-doctor/SKILL.md +1 -1
- package/adapters/hermes/skills/flow-feat-build/SKILL.md +2 -2
- package/adapters/hermes/skills/flow-feat-ship/SKILL.md +1 -1
- package/adapters/hermes/skills/flow-work-README/SKILL.md +5 -5
- package/adapters/hermes/skills/flow-work-abandon/SKILL.md +1 -1
- package/adapters/hermes/skills/flow-work-daily/SKILL.md +1 -1
- package/adapters/hermes/skills/flow-work-handoff/SKILL.md +4 -3
- package/adapters/hermes/skills/flow-work-resume/SKILL.md +8 -24
- package/adapters/opencode/CORE.md +142 -134
- package/adapters/opencode/commands/flow-bug-fix.md +1 -1
- package/adapters/opencode/commands/flow-bug-ship.md +1 -1
- package/adapters/opencode/commands/flow-doctor.md +1 -1
- package/adapters/opencode/commands/flow-feat-build.md +2 -2
- package/adapters/opencode/commands/flow-feat-ship.md +1 -1
- package/adapters/opencode/commands/flow-work-README.md +5 -5
- package/adapters/opencode/commands/flow-work-abandon.md +1 -1
- package/adapters/opencode/commands/flow-work-daily.md +1 -1
- package/adapters/opencode/commands/flow-work-handoff.md +4 -3
- package/adapters/opencode/commands/flow-work-resume.md +8 -24
- package/bin/cli.mjs +546 -12
- package/package.json +1 -1
- package/plugins/flow/.claude-plugin/plugin.json +1 -1
- package/plugins/flow/CHANGELOG.md +21 -0
- package/plugins/flow/examples/FLOW.template.md +1 -0
package/bin/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
3
3
|
import { homedir } from 'node:os'
|
|
4
|
-
import { dirname, join, resolve } from 'node:path'
|
|
4
|
+
import { basename, dirname, join, resolve } from 'node:path'
|
|
5
5
|
import { fileURLToPath } from 'node:url'
|
|
6
6
|
import { execFileSync, spawn } from 'node:child_process'
|
|
7
7
|
|
|
@@ -299,12 +299,6 @@ function mainCheckout(repo) {
|
|
|
299
299
|
return mainCheckouts.get(repo)
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
function rootHolding(repo, probe) {
|
|
303
|
-
if (existsSync(join(repo, probe))) return repo
|
|
304
|
-
const main = mainCheckout(repo)
|
|
305
|
-
return main !== repo && existsSync(join(main, probe)) ? main : repo
|
|
306
|
-
}
|
|
307
|
-
|
|
308
302
|
// Exactly this name, case included. A case-insensitive filesystem answers `existsSync` for
|
|
309
303
|
// `FLOW.CI.md` with `FLOW.ci.md`, which neither the agent's listing nor a Linux CI would read.
|
|
310
304
|
function hasFile(root, name) {
|
|
@@ -438,8 +432,22 @@ function flowConfig(repo, harness, rev = null) {
|
|
|
438
432
|
// the two things that read it fail silently when it is missing: the pack drops its `## Work`
|
|
439
433
|
// section, which it advertises and no reviewer knows to miss, and `--record` used to write the
|
|
440
434
|
// figure nowhere and exit 0. Same resolution as the config: here first, the main checkout otherwise.
|
|
435
|
+
// The work folders are the union of this checkout's and the main checkout's (flow-core §0): a
|
|
436
|
+
// worktree may hold a `.claude/work` of its own (an `_archive/`, a stray folder) while the work
|
|
437
|
+
// lives in the main checkout, and reading only the first root that exists missed it.
|
|
438
|
+
function workRoots(repo) {
|
|
439
|
+
return [...new Set([join(repo, '.claude', 'work'), join(mainCheckout(repo), '.claude', 'work')])]
|
|
440
|
+
}
|
|
441
|
+
|
|
441
442
|
function workFolder(repo, branch) {
|
|
442
|
-
const root
|
|
443
|
+
for (const root of workRoots(repo)) {
|
|
444
|
+
const found = workIn(root, branch)
|
|
445
|
+
if (found) return found
|
|
446
|
+
}
|
|
447
|
+
return null
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function workIn(root, branch) {
|
|
443
451
|
if (!existsSync(root)) return null
|
|
444
452
|
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
445
453
|
if (!entry.isDirectory() || entry.name === '_archive') continue
|
|
@@ -1244,9 +1252,7 @@ function editMeta(work, fn) {
|
|
|
1244
1252
|
let meta
|
|
1245
1253
|
try { meta = JSON.parse(readFileSync(p, 'utf8')) } catch { return false }
|
|
1246
1254
|
fn(meta)
|
|
1247
|
-
|
|
1248
|
-
writeFileSync(tmp, `${JSON.stringify(meta, null, 2)}\n`)
|
|
1249
|
-
renameSync(tmp, p)
|
|
1255
|
+
writeAtomic(p, `${JSON.stringify(meta, null, 2)}\n`)
|
|
1250
1256
|
return true
|
|
1251
1257
|
}
|
|
1252
1258
|
|
|
@@ -1442,7 +1448,7 @@ function canonicalOrigin(raw) {
|
|
|
1442
1448
|
// `seen` is shared across every repo of one call: a worktree and its main checkout, or the
|
|
1443
1449
|
// same path named twice, lead to the same folders and must count them once.
|
|
1444
1450
|
function worksOf(repo, seen) {
|
|
1445
|
-
const roots = new Set(
|
|
1451
|
+
const roots = new Set(workRoots(repo))
|
|
1446
1452
|
const works = []
|
|
1447
1453
|
for (const root of roots) {
|
|
1448
1454
|
for (const dir of [root, join(root, '_archive')]) {
|
|
@@ -1621,6 +1627,522 @@ function yieldOf(argv) {
|
|
|
1621
1627
|
}
|
|
1622
1628
|
}
|
|
1623
1629
|
|
|
1630
|
+
// --- panel -----------------------------------------------------------------------------
|
|
1631
|
+
// The live panel, rendered from what the work already records. The prose used to ask the agent
|
|
1632
|
+
// to rebuild it by hand at every stop, and the record of that is plain: since the plan-step
|
|
1633
|
+
// rule landed, 8 of 64 build sessions with a written plan ever published a step, and panels
|
|
1634
|
+
// written on other harnesses lost their clock, their links and their language. So everything
|
|
1635
|
+
// meta.json, the plan's ticks and the forge can say is said here; the agent writes only what
|
|
1636
|
+
// nobody else knows — what is running, what comes next, what it is asking — into
|
|
1637
|
+
// `panel-input.json`. meta.json is read, never written: its transitions belong to the phases.
|
|
1638
|
+
|
|
1639
|
+
const PANEL_INPUT_KEYS = ['phase', 'now', 'next', 'decision', 'attention', 'blocks', 'stale_after_minutes', 'labels']
|
|
1640
|
+
const PANEL_ATTENTION = ['wait', 'block', 'done']
|
|
1641
|
+
const PANEL_LABELS = {
|
|
1642
|
+
now: 'Now', next: 'Next', decision: 'Decision', open: 'Open', closed: 'nothing left here',
|
|
1643
|
+
review: 'review round', findings: 'open', followups: 'follow-ups',
|
|
1644
|
+
}
|
|
1645
|
+
const HARNESS_NAMES = {
|
|
1646
|
+
claude: 'Claude Code', codex: 'Codex', opencode: 'OpenCode', zcode: 'zcode', gemini: 'Gemini CLI', hermes: 'Hermes',
|
|
1647
|
+
}
|
|
1648
|
+
const MAX_STEP_LINES = 5
|
|
1649
|
+
|
|
1650
|
+
function flagValue(argv, name) {
|
|
1651
|
+
const at = argv.indexOf(name)
|
|
1652
|
+
return at === -1 ? null : argv[at + 1] ?? null
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
// `git@host:owner/repo.git`, `https://host/owner/repo.git`, `ssh://git@host:22/owner/repo.git`
|
|
1656
|
+
// → `owner.repo`; the control room groups its cards by this id (flow-core §4.6).
|
|
1657
|
+
function repoId(repo) {
|
|
1658
|
+
const url = git(['remote', 'get-url', 'origin'], repo).trim()
|
|
1659
|
+
let path
|
|
1660
|
+
if (!url) path = basename(mainCheckout(repo))
|
|
1661
|
+
else if (url.includes('//')) path = url.replace(/^[a-z+]+:\/\/[^/]*\//i, '')
|
|
1662
|
+
else path = url.replace(/^[^:]*:/, '')
|
|
1663
|
+
return path.replace(/\.git$/, '').replace(/\//g, '.').replace(/[^A-Za-z0-9_.~:@+-]/g, '-')
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
// The id is dropped only as a whole token: `244 · Ship it` loses it, `2440 widgets` does not.
|
|
1667
|
+
function shortTitle(title, ticket) {
|
|
1668
|
+
let t = String(title ?? '').trim()
|
|
1669
|
+
if (ticket) {
|
|
1670
|
+
const id = String(ticket).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
1671
|
+
t = t.replace(new RegExp(`^\\[?#?${id}\\]?(?=[\\s·:\\-–—]|$)\\s*[·:\\-–—]?\\s*`, 'i'), '')
|
|
1672
|
+
}
|
|
1673
|
+
return t
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
// What a URL names: `!123` on GitLab, `#123` on GitHub, or nothing recognisable.
|
|
1677
|
+
function mrRef(url) {
|
|
1678
|
+
const m = /\/(merge_requests|pull)\/(\d+)/.exec(String(url ?? ''))
|
|
1679
|
+
return m ? `${m[1] === 'pull' ? '#' : '!'}${m[2]}` : null
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
// The statuses meta.json really carries, not only the five the plan's table names: works in the
|
|
1683
|
+
// wild hold `open`, `draft`, `dropped`, `merged_into_umbrella`, `closed_superseded…`, none at
|
|
1684
|
+
// all, or a bare string. A status nobody listed is drawn from whether it has an MR/PR, never
|
|
1685
|
+
// refused — a refused panel is the hand-written one this exists to replace.
|
|
1686
|
+
const SETTLED_STATUS = /^(merged|closed|superseded|skipped|dropped)/
|
|
1687
|
+
|
|
1688
|
+
// What meta.json records wins over the forge: it is written only when a phase confirmed it,
|
|
1689
|
+
// while the forge's answer may be a cached one. A finished work's open MR/PR is a merged one.
|
|
1690
|
+
function trainMark(status, url, forge, done, abandoned) {
|
|
1691
|
+
const s = String(status ?? '')
|
|
1692
|
+
if (s.startsWith('merged')) return 'done'
|
|
1693
|
+
if (s.startsWith('closed') || s.startsWith('dropped')) return 'block'
|
|
1694
|
+
if (s.startsWith('superseded') || s.startsWith('skipped')) return null
|
|
1695
|
+
if (forge?.state === 'merged') return 'done'
|
|
1696
|
+
if (forge?.state === 'closed') return 'block'
|
|
1697
|
+
if (url) return done ? 'done' : 'wait'
|
|
1698
|
+
if (done) return 'done'
|
|
1699
|
+
if (s === 'in_progress' && !abandoned) return 'current'
|
|
1700
|
+
return 'pending'
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
// The single MR/PR of a work without `mrs[]`, under whichever key the phase wrote it.
|
|
1704
|
+
function singleUrl(meta) {
|
|
1705
|
+
return ['mr_url', 'pr_url', 'url', 'mr'].map((k) => meta[k]).find((v) => typeof v === 'string' && /^https?:\/\//.test(v)) ?? null
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
// The plan's numbered steps, as 126 real plans write them: top-level lines of its section, with
|
|
1709
|
+
// a checkbox or without (an unticked step is often a bare `3. …`), in file order — a step added
|
|
1710
|
+
// later with a lower number stays where it was written. Under a `###` only lines carrying a
|
|
1711
|
+
// checkbox are steps: that is how review fixes are appended (`### Arreglos de la review`), and a
|
|
1712
|
+
// subsection's bare numbers are notes. The repair rounds the plugin writes (`### Red suite …
|
|
1713
|
+
// round <k>`) count bare lines too, and restart at 1, so they are referred to as `r<k>.<n>`. A
|
|
1714
|
+
// step struck through (`~~…~~`) was dropped and is not drawn. Keys stay unique whatever repeats.
|
|
1715
|
+
function planSteps(work, heading) {
|
|
1716
|
+
let text
|
|
1717
|
+
try { text = readFileSync(join(work, heading.file), 'utf8') } catch { return [] }
|
|
1718
|
+
const lines = text.split('\n')
|
|
1719
|
+
const start = lines.findIndex((l) => heading.re.test(l))
|
|
1720
|
+
if (start === -1) return []
|
|
1721
|
+
const steps = []
|
|
1722
|
+
const keys = new Set()
|
|
1723
|
+
let fence = false
|
|
1724
|
+
let sub = null
|
|
1725
|
+
for (const line of lines.slice(start + 1)) {
|
|
1726
|
+
if (/^\s{0,3}(`{3,}|~{3,})/.test(line)) { fence = !fence; continue }
|
|
1727
|
+
if (fence) continue
|
|
1728
|
+
if (/^#{1,2}\s/.test(line)) break
|
|
1729
|
+
const h = /^#{3,6}\s+(.*)$/.exec(line)
|
|
1730
|
+
if (h) {
|
|
1731
|
+
const r = /^Red suite\b.*?\bround\s+(\d+)/i.exec(h[1])
|
|
1732
|
+
sub = r ? { round: Number(r[1]) } : { round: 0 }
|
|
1733
|
+
continue
|
|
1734
|
+
}
|
|
1735
|
+
const m = /^(?:-\s+\[([ xX])\]\s*)?(\d+)\.\s+(?:\[([ xX])\]\s*)?(.*)$/.exec(line)
|
|
1736
|
+
if (!m) continue
|
|
1737
|
+
const boxed = m[1] !== undefined || m[3] !== undefined
|
|
1738
|
+
if (sub && !sub.round && !boxed) continue
|
|
1739
|
+
if (/^~~.*~~/.test(m[4].trim())) continue
|
|
1740
|
+
const ref = sub?.round ? `r${sub.round}.${m[2]}` : m[2]
|
|
1741
|
+
let key = `step-${ref.replace('.', '-')}`
|
|
1742
|
+
for (let i = 2; keys.has(key); i++) key = `step-${ref.replace('.', '-')}-${i}`
|
|
1743
|
+
keys.add(key)
|
|
1744
|
+
const ticked = /x/i.test(m[1] ?? '') || /x/i.test(m[3] ?? '')
|
|
1745
|
+
const label = m[4].split(/\s+—\s+/)[0].replace(/`/g, '').trim()
|
|
1746
|
+
steps.push({ ref, key, ticked, text: label.length > 72 ? `${label.slice(0, 71)}…` : label })
|
|
1747
|
+
}
|
|
1748
|
+
return steps
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// One line per step, never ahead of the ticks, five lines at most: past three finished steps
|
|
1752
|
+
// they fold into one, and a long pending tail folds the same way (flow-core §4.1).
|
|
1753
|
+
function stepLines(steps) {
|
|
1754
|
+
if (!steps.length) return []
|
|
1755
|
+
const done = steps.filter((s) => s.ticked)
|
|
1756
|
+
const rest = steps.filter((s) => !s.ticked)
|
|
1757
|
+
// A folded range names its lowest and highest step; steps written out of order would otherwise
|
|
1758
|
+
// fold into a range that leaves one of them out.
|
|
1759
|
+
const range = (ss) => {
|
|
1760
|
+
if (ss.length === 1) return ss[0].ref
|
|
1761
|
+
const nums = ss.map((x) => Number(x.ref))
|
|
1762
|
+
return nums.every(Number.isFinite) ? `${Math.min(...nums)}–${Math.max(...nums)}` : `${ss[0].ref}–${ss[ss.length - 1].ref}`
|
|
1763
|
+
}
|
|
1764
|
+
const out = []
|
|
1765
|
+
if (done.length > 3) out.push({ key: 'steps-done', ref: range(done), text: done.map((s) => s.text).join(' · '), mark: 'done', indent: 4 })
|
|
1766
|
+
else done.forEach((s) => out.push({ key: s.key, ref: s.ref, text: s.text, mark: 'done', indent: 4 }))
|
|
1767
|
+
const [current, ...pending] = rest
|
|
1768
|
+
if (current) out.push({ key: current.key, ref: current.ref, text: current.text, mark: 'current', indent: 4 })
|
|
1769
|
+
const room = MAX_STEP_LINES - out.length
|
|
1770
|
+
if (pending.length > room && room > 0) {
|
|
1771
|
+
pending.slice(0, room - 1).forEach((s) => out.push({ key: s.key, ref: s.ref, text: s.text, mark: 'pending', indent: 4 }))
|
|
1772
|
+
const tail = pending.slice(room - 1)
|
|
1773
|
+
out.push({ key: 'steps-pending', ref: range(tail), text: tail.map((s) => s.text).join(' · '), mark: 'pending', indent: 4 })
|
|
1774
|
+
} else pending.forEach((s) => out.push({ key: s.key, ref: s.ref, text: s.text, mark: 'pending', indent: 4 }))
|
|
1775
|
+
return out
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
function readPanelInput(work, warn) {
|
|
1779
|
+
const p = join(work, 'panel-input.json')
|
|
1780
|
+
if (!existsSync(p)) return { input: {} }
|
|
1781
|
+
let input
|
|
1782
|
+
try { input = JSON.parse(readFileSync(p, 'utf8')) } catch (e) { return { error: `\`${p}\` is not readable JSON (${e.message})` } }
|
|
1783
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) return { error: `\`${p}\` must hold one JSON object` }
|
|
1784
|
+
for (const k of Object.keys(input)) if (!PANEL_INPUT_KEYS.includes(k)) { warn(`panel-input.json: \`${k}\` is not a field — ignored (fields: ${PANEL_INPUT_KEYS.join(', ')})`); delete input[k] }
|
|
1785
|
+
if (input.attention != null && !PANEL_ATTENTION.includes(input.attention)) {
|
|
1786
|
+
warn(`panel-input.json: attention \`${input.attention}\` ignored — one of ${PANEL_ATTENTION.join(' · ')}, or null`)
|
|
1787
|
+
delete input.attention
|
|
1788
|
+
}
|
|
1789
|
+
if (input.blocks != null && !Array.isArray(input.blocks)) { warn('panel-input.json: `blocks` must be a list — ignored'); delete input.blocks }
|
|
1790
|
+
if (input.labels != null) {
|
|
1791
|
+
if (typeof input.labels !== 'object' || Array.isArray(input.labels)) { warn('panel-input.json: `labels` must be an object — ignored'); delete input.labels }
|
|
1792
|
+
else for (const k of Object.keys(input.labels)) if (!(k in PANEL_LABELS)) { warn(`panel-input.json: label \`${k}\` is not one — ignored (labels: ${Object.keys(PANEL_LABELS).join(', ')})`); delete input.labels[k] }
|
|
1793
|
+
}
|
|
1794
|
+
return { input }
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
function renderPanel({ meta, work, input, forge = {}, foreign = false }) {
|
|
1798
|
+
const labels = { ...PANEL_LABELS, ...(input.labels ?? {}) }
|
|
1799
|
+
const done = meta.phase === 'done'
|
|
1800
|
+
const abandoned = meta.phase === 'abandoned'
|
|
1801
|
+
const lines = [{ key: 'title', text: shortTitle(meta.title, meta.ticket) || String(meta.ticket ?? ''), style: 'title' }]
|
|
1802
|
+
const block = (ls) => { if (ls.length) lines.push('', ...ls) }
|
|
1803
|
+
|
|
1804
|
+
const train = []
|
|
1805
|
+
const marks = []
|
|
1806
|
+
const mrs = Array.isArray(meta.mrs) ? meta.mrs : []
|
|
1807
|
+
// The MR/PR being built is the first one with a written plan that is neither shipped nor
|
|
1808
|
+
// settled — never a status: build marks an entry `in_progress` only in a train, so a work
|
|
1809
|
+
// planned as one MR/PR keeps it `pending` while its steps are ticked.
|
|
1810
|
+
const plans = new Map()
|
|
1811
|
+
const planOf = (n) => {
|
|
1812
|
+
if (!plans.has(n)) plans.set(n, planSteps(work, { file: '05-implementation.md', re: new RegExp(`^##\\s+Plan\\s+MR(/PR)?\\s+#${n}\\b`) }))
|
|
1813
|
+
return plans.get(n)
|
|
1814
|
+
}
|
|
1815
|
+
const building = done || abandoned ? null : mrs.map((m, i) => (m && typeof m === 'object' ? { m, n: m.n ?? i + 1 } : null))
|
|
1816
|
+
.find((e) => e && !e.m.url && !SETTLED_STATUS.test(String(e.m.status ?? '')) && planOf(e.n).length)?.m
|
|
1817
|
+
let pendingRun = []
|
|
1818
|
+
const flush = () => {
|
|
1819
|
+
if (!pendingRun.length) return
|
|
1820
|
+
const first = pendingRun[0].n, last = pendingRun[pendingRun.length - 1].n
|
|
1821
|
+
train.push({ key: pendingRun.length === 1 ? `mr-${first}` : `mr-${first}-${last}`, ref: pendingRun.length === 1 ? `#${first}` : `#${first}–#${last}`, text: pendingRun.map((m) => m.title).join(' · '), mark: 'pending' })
|
|
1822
|
+
pendingRun = []
|
|
1823
|
+
}
|
|
1824
|
+
mrs.forEach((raw, i) => {
|
|
1825
|
+
const m = raw && typeof raw === 'object' ? raw : { n: i + 1, title: String(raw ?? '') }
|
|
1826
|
+
const n = m.n ?? i + 1
|
|
1827
|
+
const f = m.url ? forge[m.url] : null
|
|
1828
|
+
let mark = trainMark(m.status, m.url, f, done, abandoned)
|
|
1829
|
+
if (!mark) return
|
|
1830
|
+
if (m === building && mark === 'pending') mark = 'current'
|
|
1831
|
+
marks.push(mark)
|
|
1832
|
+
if (mark === 'pending') { pendingRun.push({ n, title: m.title }); return }
|
|
1833
|
+
flush()
|
|
1834
|
+
train.push({ key: `mr-${n}`, ref: `#${n}`, text: String(m.title ?? ''), mark, ...(m.url ? { link: m.url } : {}) })
|
|
1835
|
+
if (mark === 'wait' && f?.summary) train.push({ key: `mr-${n}-state`, text: f.summary, mark: 'info', indent: 4 })
|
|
1836
|
+
if (m === building) train.push(...stepLines(planOf(n)))
|
|
1837
|
+
})
|
|
1838
|
+
flush()
|
|
1839
|
+
const url = !mrs.length ? singleUrl(meta) : null
|
|
1840
|
+
if (url) {
|
|
1841
|
+
const f = forge[url]
|
|
1842
|
+
const mark = trainMark(null, url, f, done)
|
|
1843
|
+
marks.push(mark)
|
|
1844
|
+
train.push({ key: 'mr-1', ref: mrRef(url) ?? '#1', text: shortTitle(meta.title, meta.ticket), mark, link: url })
|
|
1845
|
+
if (mark === 'wait' && f?.summary) train.push({ key: 'mr-1-state', text: f.summary, mark: 'info', indent: 4 })
|
|
1846
|
+
}
|
|
1847
|
+
// A bug's plan lives in 04-fix.md and is shown while fix runs: before `fix` first closes, and
|
|
1848
|
+
// when a review's or a red suite's steps send the work back into it — `fix` is then already in
|
|
1849
|
+
// phases_done, and the phase being run is the only thing that says so.
|
|
1850
|
+
if (meta.type === 'bug' && !done && !abandoned) {
|
|
1851
|
+
const fixClosed = Array.isArray(meta.phases_done) && meta.phases_done.includes('fix')
|
|
1852
|
+
if (!fixClosed || input.phase === 'fix') train.push(...stepLines(planSteps(work, { file: '04-fix.md', re: /^##\s+Plan\b/ })))
|
|
1853
|
+
}
|
|
1854
|
+
block(train)
|
|
1855
|
+
|
|
1856
|
+
// Every MR/PR merged is the end of the work's waiting, whatever meta.json.phase still says: a
|
|
1857
|
+
// merge done in the forge has no session to close the work, and the card it leaves behind
|
|
1858
|
+
// must stop claiming the person (flow-core §4.6).
|
|
1859
|
+
// A sibling repo's MRs/PRs keep the work open until each one merged — by the forge's word, or
|
|
1860
|
+
// by its entry's own `done`/`merged`. An entry with no MR/PR is a reminder `ship` and `daily`
|
|
1861
|
+
// carry, not something this panel waits on: no phase ever marks it done.
|
|
1862
|
+
const sibs = []
|
|
1863
|
+
let siblingOpen = false
|
|
1864
|
+
for (const r of Array.isArray(meta.related_repos) ? meta.related_repos : []) {
|
|
1865
|
+
const name = String(r?.repo ?? '').split(/[\s/]/).filter(Boolean).pop() ?? ''
|
|
1866
|
+
const finished = /^(done|merged)$/.test(String(r?.status ?? ''))
|
|
1867
|
+
for (const u of Array.isArray(r?.mrs) ? r.mrs : []) {
|
|
1868
|
+
const f = forge[u]
|
|
1869
|
+
const mark = f?.state === 'merged' || (finished && f?.state !== 'closed') ? 'done' : f?.state === 'closed' ? 'block' : 'wait'
|
|
1870
|
+
if (mark !== 'done') siblingOpen = true
|
|
1871
|
+
sibs.push({ key: `sib-${sibs.length + 1}`, ref: `${name} ${mrRef(u) ?? ''}`.trim(), text: f?.summary ?? String(r.scope ?? '').split(/[.;]/)[0], mark, link: u })
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
block(sibs)
|
|
1875
|
+
const blocks = (Array.isArray(input.blocks) ? input.blocks : []).map((b, i) => {
|
|
1876
|
+
const o = typeof b === 'string' ? { text: b } : (b ?? {})
|
|
1877
|
+
return { key: `block-${i + 1}`, text: String(o.text ?? ''), mark: 'block', ...(o.link ? { link: String(o.link) } : {}) }
|
|
1878
|
+
}).filter((b) => b.text)
|
|
1879
|
+
|
|
1880
|
+
// … but only when nothing else is still open: a sibling repo's MR/PR, a blocker, or a
|
|
1881
|
+
// question the session is waiting on keeps the work claiming someone. Rendered for another
|
|
1882
|
+
// session (`--work`: daily, clean), the input is whatever that session last wrote, and a
|
|
1883
|
+
// question about an MR/PR that has since merged is not one anybody is waiting on.
|
|
1884
|
+
const merged = !done && marks.length > 0 && marks.every((k) => k === 'done') && !siblingOpen
|
|
1885
|
+
&& (foreign || (!input.decision && !blocks.length))
|
|
1886
|
+
const closed = done || merged
|
|
1887
|
+
const over = closed || abandoned
|
|
1888
|
+
|
|
1889
|
+
if (!over) {
|
|
1890
|
+
const rows = Array.isArray(meta.review_findings) ? meta.review_findings : []
|
|
1891
|
+
const round = rows.reduce((n, r) => Math.max(n, Number(r?.round) || 0), 0)
|
|
1892
|
+
const openRows = rows.filter((r) => Number(r?.round) === round && r?.outcome === 'open').length
|
|
1893
|
+
const fups = (Array.isArray(meta.followups) ? meta.followups : []).filter((f) => ['proposed', 'accepted'].includes(f?.status)).length
|
|
1894
|
+
const parts = []
|
|
1895
|
+
if (openRows) parts.push(`${labels.review} ${round} · ${openRows} ${labels.findings}`)
|
|
1896
|
+
if (fups) parts.push(`${fups} ${labels.followups}`)
|
|
1897
|
+
if (parts.length) block([{ key: 'open', ref: labels.open, text: parts.join(' · '), mark: 'info' }])
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
const talk = []
|
|
1901
|
+
if (!over && input.now) talk.push({ key: 'now', ref: labels.now, text: String(input.now), mark: 'info' })
|
|
1902
|
+
if (!over && input.next) talk.push({ key: 'next', ref: labels.next, text: String(input.next), mark: 'info' })
|
|
1903
|
+
if (!over && input.decision) talk.push({ key: 'decision', ref: labels.decision, text: String(input.decision), mark: 'wait' })
|
|
1904
|
+
if (closed) talk.push({ key: 'closed', text: labels.closed, mark: 'info', style: 'ok' })
|
|
1905
|
+
block(talk)
|
|
1906
|
+
|
|
1907
|
+
if (!closed) block(blocks)
|
|
1908
|
+
|
|
1909
|
+
const phase = done ? 'done' : (abandoned ? meta.phase : input.phase ?? meta.phase ?? null)
|
|
1910
|
+
const attention = closed ? 'done'
|
|
1911
|
+
: abandoned ? null
|
|
1912
|
+
: input.decision ? 'wait'
|
|
1913
|
+
: input.attention ?? (blocks.length ? 'block' : null)
|
|
1914
|
+
return {
|
|
1915
|
+
updated_at: new Date().toISOString(),
|
|
1916
|
+
...(phase ? { phase } : {}),
|
|
1917
|
+
header: true,
|
|
1918
|
+
...(attention ? { attention } : {}),
|
|
1919
|
+
...(Number(input.stale_after_minutes) > 0 ? { stale_after_minutes: Number(input.stale_after_minutes) } : {}),
|
|
1920
|
+
lines,
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
// `publish_cmd` runs a shell command with no one asking, after every tool call once the hook
|
|
1925
|
+
// is in play — so it is taken only from a FLOW file git does not track: the personal, ignored
|
|
1926
|
+
// one. A command committed to a repo would run on every machine that merely opened it, and
|
|
1927
|
+
// when git cannot say which it is, the command does not run.
|
|
1928
|
+
function publishCmd(repo, harness) {
|
|
1929
|
+
let found = null
|
|
1930
|
+
for (const l of flowLayers(repo, harness).layers) {
|
|
1931
|
+
if (!l.found) continue
|
|
1932
|
+
const cmd = parseFlow(l.text ?? readFileSync(join(l.root, l.name), 'utf8')).panel?.publish_cmd
|
|
1933
|
+
if (cmd !== undefined) found = { cmd, layer: l }
|
|
1934
|
+
}
|
|
1935
|
+
if (!found?.cmd) return {}
|
|
1936
|
+
let tracked
|
|
1937
|
+
try {
|
|
1938
|
+
tracked = execFileSync('git', ['ls-files', '--error-unmatch', '--', found.layer.name], { cwd: found.layer.root, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8' })
|
|
1939
|
+
} catch (e) {
|
|
1940
|
+
// 1 is git's own "not tracked"; anything else (128: not a repo, unsafe directory) is no answer.
|
|
1941
|
+
if (e.status === 1) return { cmd: found.cmd }
|
|
1942
|
+
return { ignored: `panel.publish_cmd in ${found.layer.name} not run: git could not say whether that file is tracked (${String(e.stderr || e.message).trim().split('\n')[0]})` }
|
|
1943
|
+
}
|
|
1944
|
+
return tracked ? { ignored: `panel.publish_cmd in ${found.layer.name} ignored: that file is tracked by git, and a committed command would run on every machine that opens the repo — set it in a git-ignored FLOW file` } : { cmd: found.cmd }
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
// One panel line per text line: a reader that greps (the session-start hook looks for the
|
|
1948
|
+
// `now` line and takes its text) finds a line's fields together, and a diff shows a line moved.
|
|
1949
|
+
function panelText(doc) {
|
|
1950
|
+
const { lines, ...top } = doc
|
|
1951
|
+
const head = Object.entries(top).map(([k, v]) => ` ${JSON.stringify(k)}: ${JSON.stringify(v)},`)
|
|
1952
|
+
const body = lines.map((l, i) => ` ${JSON.stringify(l)}${i < lines.length - 1 ? ',' : ''}`)
|
|
1953
|
+
return `{\n${head.join('\n')}\n "lines": [\n${body.join('\n')}\n ]\n}\n`
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
// A temp name of its own per writer: the hook can start a render while another is still
|
|
1957
|
+
// writing, and two renames of one shared temp file lose one of them.
|
|
1958
|
+
function writeAtomic(p, text) {
|
|
1959
|
+
const tmp = `${p}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`
|
|
1960
|
+
try {
|
|
1961
|
+
writeFileSync(tmp, text)
|
|
1962
|
+
renameSync(tmp, p)
|
|
1963
|
+
} catch (e) {
|
|
1964
|
+
try { rmSync(tmp, { force: true }) } catch {}
|
|
1965
|
+
throw e
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
// `--work` takes a folder's path or its name. A path must be a work folder of this repo (live,
|
|
1970
|
+
// never `_archive/`): the hook names the exact folder it found, so the CLI cannot settle on a
|
|
1971
|
+
// namesake in the other checkout, nor on one that `abandon` or `clean` just archived.
|
|
1972
|
+
function findWork(repo, name) {
|
|
1973
|
+
const roots = workRoots(repo)
|
|
1974
|
+
if (name.includes('/')) {
|
|
1975
|
+
let real
|
|
1976
|
+
try { real = realpathSync(name) } catch { return null }
|
|
1977
|
+
const inside = roots.some((r) => { try { return dirname(real) === realpathSync(r) } catch { return false } })
|
|
1978
|
+
return inside && existsSync(join(real, 'meta.json')) ? real : null
|
|
1979
|
+
}
|
|
1980
|
+
// By name: a live folder only — an archived namesake's card was deleted with its folder.
|
|
1981
|
+
for (const root of roots) if (existsSync(join(root, name, 'meta.json'))) return join(root, name)
|
|
1982
|
+
return null
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
// What earlier `--forge` runs learnt, so a render without it — the hook's, a plan step's —
|
|
1986
|
+
// does not paint a merged MR/PR back to `wait`. A merge is final and kept; anything else (a
|
|
1987
|
+
// close can be reopened, a pipeline moves) is shown for an hour and then dropped rather than
|
|
1988
|
+
// passed off as current. Each entry carries its own time, so a run whose call failed keeps the
|
|
1989
|
+
// previous answer, and only URLs the work still records are kept.
|
|
1990
|
+
const FORGE_FRESH_MS = 60 * 60 * 1000
|
|
1991
|
+
|
|
1992
|
+
function workUrls(meta) {
|
|
1993
|
+
const mrs = Array.isArray(meta.mrs) ? meta.mrs : []
|
|
1994
|
+
return new Set([
|
|
1995
|
+
...mrs.map((m) => m?.url).filter(Boolean),
|
|
1996
|
+
...(mrs.length ? [] : [singleUrl(meta)].filter(Boolean)),
|
|
1997
|
+
...(Array.isArray(meta.related_repos) ? meta.related_repos.flatMap((r) => (Array.isArray(r?.mrs) ? r.mrs : [])) : []),
|
|
1998
|
+
])
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
function cachedForge(work, meta, now = Date.now()) {
|
|
2002
|
+
let states
|
|
2003
|
+
try { states = JSON.parse(readFileSync(join(work, 'forge-state.json'), 'utf8')).states ?? {} } catch { return {} }
|
|
2004
|
+
const keep = workUrls(meta)
|
|
2005
|
+
const out = {}
|
|
2006
|
+
for (const [url, s] of Object.entries(states)) {
|
|
2007
|
+
if (!keep.has(url) || !s || typeof s !== 'object') continue
|
|
2008
|
+
if (s.state === 'merged') out[url] = { state: 'merged', summary: null, at: s.at }
|
|
2009
|
+
else if (now - Date.parse(s.at ?? 0) < FORGE_FRESH_MS) out[url] = s
|
|
2010
|
+
}
|
|
2011
|
+
return out
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
function panel(argv) {
|
|
2015
|
+
const harness = flagValue(argv, '--harness')
|
|
2016
|
+
if (harness && !OVERLAY_HARNESSES.includes(harness)) {
|
|
2017
|
+
console.error(`flow panel: unknown --harness \`${harness}\` — one of ${OVERLAY_HARNESSES.join(', ')}`); process.exit(1)
|
|
2018
|
+
}
|
|
2019
|
+
// `--repo` lets the hook run this from outside the checkout, where nothing the repo commits
|
|
2020
|
+
// (an `.npmrc`, a `node_modules`) can choose what `npx` executes.
|
|
2021
|
+
const repo = git(['rev-parse', '--show-toplevel'], flagValue(argv, '--repo') ?? process.cwd()).trim()
|
|
2022
|
+
if (!repo) { console.error('flow panel: not a git checkout'); process.exit(1) }
|
|
2023
|
+
const named = flagValue(argv, '--work')
|
|
2024
|
+
const branch = git(['rev-parse', '--abbrev-ref', 'HEAD'], repo).trim()
|
|
2025
|
+
const work = named ? findWork(repo, named) : workFolder(repo, branch)
|
|
2026
|
+
if (!work) { console.error(named ? `flow panel: no work folder named \`${named}\`` : `flow panel: no work on \`${branch}\``); process.exit(1) }
|
|
2027
|
+
let meta
|
|
2028
|
+
try { meta = JSON.parse(readFileSync(join(work, 'meta.json'), 'utf8')) } catch (e) {
|
|
2029
|
+
console.error(`flow panel: \`${join(work, 'meta.json')}\` is missing or not JSON (${e.message})`); process.exit(1)
|
|
2030
|
+
}
|
|
2031
|
+
const warn = (m) => console.error(`flow panel: ${m}`)
|
|
2032
|
+
const { input, error } = readPanelInput(work, warn)
|
|
2033
|
+
if (error) { console.error(`flow panel: ${error} — nothing written`); process.exit(1) }
|
|
2034
|
+
let forge = cachedForge(work, meta)
|
|
2035
|
+
if (argv.includes('--forge')) {
|
|
2036
|
+
const at = new Date().toISOString()
|
|
2037
|
+
const fresh = Object.fromEntries(Object.entries(forgeStates(meta, warn)).map(([u, s]) => [u, { ...s, at }]))
|
|
2038
|
+
forge = { ...forge, ...fresh }
|
|
2039
|
+
writeAtomic(join(work, 'forge-state.json'), `${JSON.stringify({ states: forge }, null, 2)}\n`)
|
|
2040
|
+
}
|
|
2041
|
+
// Rendered for a work on another branch (daily, clean refreshing cards): not this pane's
|
|
2042
|
+
// panel, and its input is another session's. `--work` alone does not say it — the hook names
|
|
2043
|
+
// the folder of this branch's own work.
|
|
2044
|
+
const branches = [meta.branch, ...(Array.isArray(meta.mrs) ? meta.mrs.map((m) => m?.branch) : [])]
|
|
2045
|
+
const foreign = Boolean(named) && !branches.includes(branch)
|
|
2046
|
+
const doc = renderPanel({ meta, work, input, forge, foreign })
|
|
2047
|
+
// Another branch's panel.json is the live pane of the session that owns it: a render made for
|
|
2048
|
+
// the control room (daily, clean) writes only the card, never the file that session shows.
|
|
2049
|
+
if (!foreign) writeAtomic(join(work, 'panel.json'), panelText(doc))
|
|
2050
|
+
const config = flowConfig(repo, harness).panel ?? {}
|
|
2051
|
+
// A terminal that paints only what reaches it over its own channel never reads panel.json,
|
|
2052
|
+
// and a hook cannot call an MCP tool. `publish_cmd` is that channel as a command: the
|
|
2053
|
+
// document on its stdin, every time this branch's panel is rendered — the agent's
|
|
2054
|
+
// publication and the hook's refresh alike. Another branch's work is never sent there.
|
|
2055
|
+
if (!foreign) {
|
|
2056
|
+
const publish = publishCmd(repo, harness)
|
|
2057
|
+
if (publish.ignored) warn(publish.ignored)
|
|
2058
|
+
if (publish.cmd) {
|
|
2059
|
+
try {
|
|
2060
|
+
execFileSync('sh', ['-c', publish.cmd], { input: JSON.stringify(doc), cwd: repo, stdio: ['pipe', 'ignore', 'pipe'], timeout: 10000 })
|
|
2061
|
+
} catch (e) { warn(`panel.publish_cmd failed (${String(e.stderr || e.message).trim().split('\n')[0]}) — panel.json is written`) }
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
if (config.artifact) {
|
|
2065
|
+
writeAtomic(join(work, 'card.json'), panelText({
|
|
2066
|
+
...doc, repo: repoId(repo), work: basename(work), ticket: meta.ticket ?? null, type: meta.type ?? null,
|
|
2067
|
+
branch: meta.branch ?? null, ...(HARNESS_NAMES[harness] ? { harness: HARNESS_NAMES[harness] } : {}),
|
|
2068
|
+
}))
|
|
2069
|
+
}
|
|
2070
|
+
console.log(JSON.stringify(doc))
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
function forgeRun(cmd, args) {
|
|
2074
|
+
try {
|
|
2075
|
+
return execFileSync(cmd, args, { encoding: 'utf8', maxBuffer: 16 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'], timeout: 20000 })
|
|
2076
|
+
} catch { return null }
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
const GH_RED = ['FAILURE', 'ERROR', 'CANCELLED', 'TIMED_OUT', 'ACTION_REQUIRED', 'STARTUP_FAILURE']
|
|
2080
|
+
const GH_RUNNING = ['PENDING', 'EXPECTED', 'QUEUED', 'IN_PROGRESS']
|
|
2081
|
+
|
|
2082
|
+
function ghState(url) {
|
|
2083
|
+
const d = firstJson(forgeRun('gh', ['pr', 'view', url, '--json', 'state,isDraft,statusCheckRollup,reviewDecision']) ?? '')
|
|
2084
|
+
if (!d?.state) return null
|
|
2085
|
+
const state = d.state === 'MERGED' ? 'merged' : d.state === 'CLOSED' ? 'closed' : 'open'
|
|
2086
|
+
const checks = Array.isArray(d.statusCheckRollup) ? d.statusCheckRollup : []
|
|
2087
|
+
const verdict = (c) => String(c.conclusion || c.state || '').toUpperCase()
|
|
2088
|
+
const pipeline = !checks.length ? 'none'
|
|
2089
|
+
: checks.some((c) => GH_RED.includes(verdict(c))) ? 'failed'
|
|
2090
|
+
: checks.some((c) => (c.status && c.status !== 'COMPLETED') || GH_RUNNING.includes(verdict(c))) ? 'running'
|
|
2091
|
+
: 'passed'
|
|
2092
|
+
const review = { APPROVED: 'approved', CHANGES_REQUESTED: 'changes requested', REVIEW_REQUIRED: 'review required' }[d.reviewDecision]
|
|
2093
|
+
return { state, parts: [d.isDraft && 'draft', `pipeline ${pipeline}`, review] }
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
function glabState(url) {
|
|
2097
|
+
const m = /^(https?:\/\/[^/]+)\/(.+?)\/-\/merge_requests\/(\d+)/.exec(url)
|
|
2098
|
+
if (!m) return null
|
|
2099
|
+
const [, host, project, iid] = m
|
|
2100
|
+
const d = firstJson(forgeRun('glab', ['mr', 'view', iid, '-R', `${host}/${project}`, '-F', 'json']) ?? '')
|
|
2101
|
+
if (!d?.state) return null
|
|
2102
|
+
const state = d.state === 'merged' ? 'merged' : d.state === 'closed' ? 'closed' : 'open'
|
|
2103
|
+
if (state !== 'open') return { state, parts: [] }
|
|
2104
|
+
const hostname = host.replace(/^https?:\/\//, '')
|
|
2105
|
+
const api = (path) => {
|
|
2106
|
+
const out = forgeRun('glab', ['api', '--hostname', hostname, `projects/${encodeURIComponent(project)}/merge_requests/${iid}/${path}`])
|
|
2107
|
+
try { return out ? JSON.parse(out) : null } catch { return null }
|
|
2108
|
+
}
|
|
2109
|
+
const st = d.head_pipeline?.status
|
|
2110
|
+
const pipeline = !st ? 'none' : st === 'success' ? 'passed' : ['failed', 'canceled'].includes(st) ? 'failed' : st === 'skipped' ? 'skipped' : 'running'
|
|
2111
|
+
const ap = api('approvals')
|
|
2112
|
+
const need = Number(ap?.approvals_required) || 0
|
|
2113
|
+
const approvals = !ap ? null
|
|
2114
|
+
: need ? `${need - (Number(ap.approvals_left) || 0)}/${need} approvals`
|
|
2115
|
+
: (ap.approved_by?.length ? 'approved' : null)
|
|
2116
|
+
const disc = api('discussions?per_page=100')
|
|
2117
|
+
const open = Array.isArray(disc) ? disc.filter((x) => x?.notes?.[0]?.resolvable && !x.notes[0].resolved).length : 0
|
|
2118
|
+
return { state, parts: [d.draft && 'draft', `pipeline ${pipeline}`, approvals, open ? `${open} open threads` : null] }
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
// What the forge says about each MR/PR the panel would draw as open: merged or closed in the
|
|
2122
|
+
// forge while meta.json still says otherwise, and for an open one what it waits on. Only
|
|
2123
|
+
// `ship` writes `merged` into meta.json, and a merge done in the forge has no session to tell
|
|
2124
|
+
// it — 34 of 75 recorded MRs/PRs were still `in_progress` when the audit read them. Asked by
|
|
2125
|
+
// URL, so a sibling repo's MR/PR answers like this repo's. A field the forge does not report
|
|
2126
|
+
// is left out, never guessed; a failed call drops that MR/PR's state and nothing else.
|
|
2127
|
+
function forgeStates(meta, warn) {
|
|
2128
|
+
const urls = new Set()
|
|
2129
|
+
const mrs = Array.isArray(meta.mrs) ? meta.mrs : []
|
|
2130
|
+
for (const m of mrs) {
|
|
2131
|
+
if (m && typeof m === 'object' && m.url && !SETTLED_STATUS.test(String(m.status ?? ''))) urls.add(m.url)
|
|
2132
|
+
}
|
|
2133
|
+
const single = mrs.length ? null : singleUrl(meta)
|
|
2134
|
+
if (single) urls.add(single)
|
|
2135
|
+
for (const r of Array.isArray(meta.related_repos) ? meta.related_repos : []) for (const u of Array.isArray(r?.mrs) ? r.mrs : []) urls.add(u)
|
|
2136
|
+
const out = {}
|
|
2137
|
+
for (const url of urls) {
|
|
2138
|
+
if (!/^https?:\/\/[^\s-]/.test(String(url))) { warn(`--forge: \`${url}\` is not an http(s) URL — skipped`); continue }
|
|
2139
|
+
const s = /\/pull\/\d+/.test(url) ? ghState(url) : /\/merge_requests\/\d+/.test(url) ? glabState(url) : null
|
|
2140
|
+
if (!s) { warn(`--forge: no state for ${url} — drawn from meta.json`); continue }
|
|
2141
|
+
out[url] = { state: s.state, summary: s.parts.filter(Boolean).join(' · ') || null }
|
|
2142
|
+
}
|
|
2143
|
+
return out
|
|
2144
|
+
}
|
|
2145
|
+
|
|
1624
2146
|
function usage() {
|
|
1625
2147
|
console.log(`flow-workflows v${version()} — guided feat/bug workflows for coding agents
|
|
1626
2148
|
|
|
@@ -1632,6 +2154,7 @@ function usage() {
|
|
|
1632
2154
|
npx flow-workflows review [--out <file>] [--record] [same options as bundle]
|
|
1633
2155
|
npx flow-workflows cost
|
|
1634
2156
|
npx flow-workflows record-review --file <rows.json>
|
|
2157
|
+
npx flow-workflows panel [--harness <name>] [--work <folder>] [--forge] [--repo <path>]
|
|
1635
2158
|
npx flow-workflows yield [<repo-path>…]
|
|
1636
2159
|
npx flow-workflows escape <commit> [--file <path>]
|
|
1637
2160
|
|
|
@@ -1689,6 +2212,16 @@ Claude Code, Codex CLI and zcode have their own marketplaces:
|
|
|
1689
2212
|
severities and outcomes come from closed lists; one value outside them and nothing is
|
|
1690
2213
|
written, and the error names the values that are valid.
|
|
1691
2214
|
|
|
2215
|
+
"panel" renders this branch's work as its live panel — title, MR/PR train, the plan's steps
|
|
2216
|
+
from its ticks, sibling repos' MRs/PRs, open review findings and follow-ups — from
|
|
2217
|
+
meta.json and the plan, plus what the agent wrote in panel-input.json (now, next,
|
|
2218
|
+
decision, blockers, labels). It writes panel.json (and card.json when panel.artifact is
|
|
2219
|
+
set), pipes the document to panel.publish_cmd when set, and prints it — for another
|
|
2220
|
+
branch's work (daily, clean) it writes card.json only. --forge asks gh/glab for each open MR/PR's real state.
|
|
2221
|
+
--work names a work folder (another branch's is never sent to publish_cmd);
|
|
2222
|
+
--repo runs it on a checkout other than the current directory. A --forge run keeps its
|
|
2223
|
+
answers in forge-state.json for the renders that follow it. meta.json is never written.
|
|
2224
|
+
|
|
1692
2225
|
"escape" tells whether the commit a bug investigation blamed went through a flow review:
|
|
1693
2226
|
it must sit inside exactly one work's reviewed range (merge history), or carry the number
|
|
1694
2227
|
of exactly one reviewed MR/PR in its subject (squash). Then it is recorded in this branch's
|
|
@@ -1712,6 +2245,7 @@ else if (cmd === 'tier') tier(process.argv.slice(3))
|
|
|
1712
2245
|
else if (cmd === 'cost') cost(process.argv.slice(3))
|
|
1713
2246
|
else if (cmd === 'yield') yieldOf(process.argv.slice(3))
|
|
1714
2247
|
else if (cmd === 'record-review') recordReview(process.argv.slice(3))
|
|
2248
|
+
else if (cmd === 'panel') panel(process.argv.slice(3))
|
|
1715
2249
|
else if (cmd === 'escape') escapeOf(process.argv.slice(3))
|
|
1716
2250
|
else if (cmd === 'review') review(process.argv.slice(3)).catch((e) => { console.error(`flow review: ${e.message}`); process.exit(1) })
|
|
1717
2251
|
else if (cmd === 'check') check()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flow-workflows",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.115.0",
|
|
4
4
|
"description": "Guided feat/bug workflows (start→ship), post-deploy monitoring and multi-agent code review, stack-agnostic. Each repo uses a shared FLOW.md plus optional harness overlay.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "flow",
|
|
4
4
|
"displayName": "Flow — guided dev workflows",
|
|
5
5
|
"description": "Guided feat/bug workflows (start→ship), post-deploy monitoring and multi-agent code review, stack-agnostic. Each repo uses a shared FLOW.md plus optional harness overlay.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.115.0",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Alberto Vioque",
|
|
9
9
|
"email": "mashware@gmail.com"
|