pi-dev-flow 0.85.0 → 0.86.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 +27 -0
- package/README.md +2 -1
- package/docs/development.md +10 -0
- package/docs/gates.md +1 -1
- package/docs/guardrails.md +2 -2
- package/docs/playbook.md +17 -2
- package/extensions/dev-flow.ts +120 -2655
- package/package.json +4 -2
- package/skills/dev-flow/SKILL.md +52 -74
- package/skills/dev-flow/references/finish.md +41 -58
- package/skills/dev-flow/references/implement.md +62 -152
- package/skills/dev-flow/references/plan.md +40 -68
- package/skills/dev-flow/references/pre-release.md +39 -50
- package/skills/dev-flow/references/reflect.md +51 -85
- package/skills/dev-flow/references/release.md +31 -64
- package/skills/dev-flow/references/start.md +50 -69
- package/src/core.ts +24 -20
- package/src/present.ts +224 -0
- package/src/projectmd.ts +6 -1
- package/src/runtime/base.ts +554 -0
- package/src/runtime/checks.ts +358 -0
- package/src/runtime/gates.ts +719 -0
- package/src/runtime/reflect.ts +160 -0
- package/src/runtime/setup.ts +85 -0
- package/src/runtime/ship.ts +629 -0
- package/src/runtime/workers.ts +170 -0
- package/src/timeouts.ts +52 -17
package/src/core.ts
CHANGED
|
@@ -51,6 +51,7 @@ export interface FlowState {
|
|
|
51
51
|
verifiedHead?: string; // HEAD the operator's Verified? was given over — release names commits after it, so the word is not recorded as the verdict for a tree nobody looked at (#162)
|
|
52
52
|
reflectedAt?: string; // a reflect worker reported for this flow — finish runs one first while this is unset (only --no-reflect --confirmed skips it)
|
|
53
53
|
devPort?: number; // the port the operator chose for this flow's dev deploy when the default was held by another flow — finish stops it (devDown)
|
|
54
|
+
friction?: number; // gate refusals and guard blocks this feature hit — finish skips the closing reflection at 0 (playbook reflect = on-friction)
|
|
54
55
|
aborted?: string; // flow abort on a feature whose worktree exists: the state is a deliberate abandoned-feature record (gh#138) — the doctor's git-consistency sweep must never flag its hand-removed worktree as drift
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -118,7 +119,7 @@ export interface Config {
|
|
|
118
119
|
/** Bytes one dev instance needs (playbook `instanceMem` / `instanceDisk`, e.g. 2G) — the side-by-side feasibility check. */
|
|
119
120
|
instanceMem?: number;
|
|
120
121
|
instanceDisk?: number;
|
|
121
|
-
release: { review: string; changelog?: string; releases?: boolean; artifact?: string; preflight?: string; merge?: MergeStyle | "any"; /** `until-release`: a standing yolo never answers Release? (gh#176) */ yolo?: "all" | "until-release" };
|
|
122
|
+
release: { review: string; changelog?: string; releases?: boolean; artifact?: string; preflight?: string; merge?: MergeStyle | "any"; /** `until-release`: a standing yolo never answers Release? (gh#176) */ yolo?: "all" | "until-release"; /** `always`: finish runs the closing reflection even on a flow with no friction */ reflect?: "always" | "on-friction" };
|
|
122
123
|
mainHook: boolean; // flow init installs a pre-commit hook blocking main commits
|
|
123
124
|
/** `inject` (default): the class default timeout is armed silently on every shell call.
|
|
124
125
|
* `require`: a shell call without its own visible timeout is refused (costs a turn per miss). */
|
|
@@ -2138,10 +2139,9 @@ export function shouldTakeOverCompaction(d: { reason: "manual" | "threshold" | "
|
|
|
2138
2139
|
/** The playbook's merge style spelled for a hint: "" when the project has no policy. */
|
|
2139
2140
|
function mergeHintFor(cfg: Config): string {
|
|
2140
2141
|
const m = cfg.release.merge;
|
|
2141
|
-
return m && m !== "any" ? ` (
|
|
2142
|
+
return m && m !== "any" ? ` (merge = ${m} — gh pr merge <n> --${m === "merge" ? "merge" : m}, number before the flag)` : "";
|
|
2142
2143
|
}
|
|
2143
2144
|
|
|
2144
|
-
/** What the agent/user should do next, per stage. */
|
|
2145
2145
|
/** The block a flow-aware compaction appends to its summary: the flow's state as the disk holds it.
|
|
2146
2146
|
* A summarizer merging an older summary can carry a stale stage forward (lettuce rail-ui-fixes: a
|
|
2147
2147
|
* pre-release compaction still said "implement, next: flow verify"); this block is written from
|
|
@@ -2160,34 +2160,38 @@ export function compactionStateBlock(state: FlowState, cfg: Config): string {
|
|
|
2160
2160
|
].join("\n");
|
|
2161
2161
|
}
|
|
2162
2162
|
|
|
2163
|
+
/** The next action for the agent, per stage — one line. The stage file (skills/dev-flow/references/)
|
|
2164
|
+
* holds the how; this carries only what the gate knows and the file cannot: paths, the playbook's
|
|
2165
|
+
* merge command, which versioning steps apply. */
|
|
2163
2166
|
export function nextHint(state: FlowState, cfg: Config): string {
|
|
2164
2167
|
switch (state.stage) {
|
|
2165
2168
|
case "plan":
|
|
2166
|
-
if (state.patch) return
|
|
2167
|
-
|
|
2168
|
-
return `investigate, present your direction and proposed mode to the operator and clarify in chat, then write the plan into .dev-flow/${state.slug}/plan/plan.md${state.ui ? ` and render mockups to plan/mockups/ (${cfg.mockupGlobs.join(", ")}) with headless chromium, embedded in plan.md` : ""}, then ask the operator Approve? in chat and run flow approve --confirmed when they answer`;
|
|
2169
|
+
if (state.patch || state.docs) return `${state.patch ? "patch" : "docs"}: describe the change in one line, ask Approve? in chat, then flow approve --confirmed — no plan file${state.docs ? ", no tier-1 checks" : ""}`;
|
|
2170
|
+
return `clarify the direction in chat, write .dev-flow/${state.slug}/plan/plan.md${state.ui ? ` and render mockups to plan/mockups/ (${cfg.mockupGlobs.join(", ")}) with headless chromium, embedded in plan.md` : ""}, then ask Approve? and run flow approve --confirmed on the answer`;
|
|
2169
2171
|
case "implement":
|
|
2170
|
-
if (state.docs) return `
|
|
2171
|
-
return `
|
|
2172
|
-
case "pre-release":
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
return `${cfg.release.review}
|
|
2172
|
+
if (state.docs) return `edit in ${state.worktree} (docs mode: no project commands), tick the tier-2 checklist with the operator, ask Verified?, then flow verify --confirmed`;
|
|
2173
|
+
return `build and test in ${state.worktree}, commit as you go, flow check; then flow verify (deploys for review), look yourself, keep the app running, ask Verified? and run flow verify --confirmed on the answer`;
|
|
2174
|
+
case "pre-release": {
|
|
2175
|
+
const prep = [cfg.release.changelog ? `prepare ${cfg.release.changelog} (fold Unreleased lines verbatim)` : "", cfg.versioning.file ? `bump version in ${cfg.versioning.file}` : ""].filter(Boolean).join(" and ");
|
|
2176
|
+
if (state.docs && prep) return `${cfg.release.review}, fix must/should; a docs flow usually ships unversioned — ask the operator (flow release --no-version on their word); versioned instead: ${prep}; then ask Release? and run flow release`;
|
|
2177
|
+
return `${cfg.release.review}, fix must/should, update docs${prep ? `, ${prep}` : ""}, flow check; show the PR summary, version and changelog, ask Release? and run flow release`;
|
|
2178
|
+
}
|
|
2176
2179
|
case "release":
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
: state.noVersion
|
|
2180
|
-
? `publish: commit and push the branch, open the PR, merge only once CI is green (gh pr checks <n> --watch — a locally-green branch can still fail CI-only jobs)${mergeHintFor(cfg)} — unversioned release: no manifest bump, no tag, your changelog entry rides under Unreleased; then run flow release-done (no further question)`
|
|
2181
|
-
: `publish: commit and push the branch, open the PR, merge only once CI is green (gh pr checks <n> --watch — a locally-green branch can still fail CI-only jobs)${mergeHintFor(cfg)}, create the annotated tag from the manifest version and push it, then run flow release-done (no further question)`;
|
|
2180
|
+
if (state.approvals.release) return `release recorded — commit and push any release chores in the main checkout (DEV_FLOW_ALLOW_MAIN=1 for the pre-commit hook), then flow finish (closing reflection first; its fold/drop answer is Finish?)`;
|
|
2181
|
+
return `publish: push the branch, open the PR, merge once CI is green (gh pr checks <n> --watch)${mergeHintFor(cfg)}${state.noVersion ? " — unversioned: no bump, no tag" : ", push the annotated tag"}; then flow finish records the release and closes out`;
|
|
2182
2182
|
}
|
|
2183
2183
|
}
|
|
2184
2184
|
|
|
2185
2185
|
/** Stable token prefixing every no-UI operator refusal, so a headless orchestrator can route refusals without grepping prose. */
|
|
2186
2186
|
export const NEEDS_OPERATOR = "NEEDS-OPERATOR";
|
|
2187
2187
|
|
|
2188
|
-
/**
|
|
2189
|
-
export
|
|
2190
|
-
|
|
2188
|
+
/** Prefix of a gate-output line meant for the agent only: the operator's view (src/present.ts) leaves it out. */
|
|
2189
|
+
export const AGENT_MARK = "↪ ";
|
|
2190
|
+
|
|
2191
|
+
/** Refusal for "the gate needs the operator's word and no UI is present": `<TOKEN> [Question?] — <what the
|
|
2192
|
+
* operator should know>`, then the agent's own instructions on an agent-only line (`todo`). */
|
|
2193
|
+
export function needsOperator(detail: string, question?: string, todo?: string): string {
|
|
2194
|
+
return `${NEEDS_OPERATOR}${question ? ` ${question}` : ""} — ${detail}${todo ? `\n${AGENT_MARK}${todo}` : ""}`;
|
|
2191
2195
|
}
|
|
2192
2196
|
|
|
2193
2197
|
/** Machine-readable `flow status --json`: the prose view's facts as stable JSON (no git probes, same as prose). */
|
package/src/present.ts
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presentation: how a gate's result reaches the two readers it has.
|
|
3
|
+
*
|
|
4
|
+
* Every gate returns one text written for the agent — what happened, what is missing, what to run next.
|
|
5
|
+
* The operator sees the same result in the transcript, and raw agent instructions ("ask the operator
|
|
6
|
+
* Verified? and run flow verify --confirmed") are exactly what made sessions read as "please type this
|
|
7
|
+
* command". So the result is split:
|
|
8
|
+
*
|
|
9
|
+
* - the **user view**: a header, the stage line, the facts, and the one question waiting on the operator
|
|
10
|
+
* — never a flow command (the smoke suite asserts this for every gate it drives);
|
|
11
|
+
* - the **agent part**: every instruction, untouched, still in the tool result the model reads.
|
|
12
|
+
*
|
|
13
|
+
* Gates mark agent-only lines with `↪ `; anything else that names a flow command is split clause by clause,
|
|
14
|
+
* so a refusal like "test has not passed — run flow check" shows the operator "test has not passed".
|
|
15
|
+
*
|
|
16
|
+
* The stage line is written here, from state, so it is the same every time — the model pastes it instead of
|
|
17
|
+
* rebuilding glyphs and provenance marks from memory.
|
|
18
|
+
*/
|
|
19
|
+
import { AGENT_MARK, applicableItems, checklistPending, NEEDS_OPERATOR, STAGE_EMOJI, type Config, type FlowState } from "./core.ts";
|
|
20
|
+
|
|
21
|
+
export { AGENT_MARK };
|
|
22
|
+
|
|
23
|
+
const FLOW_VERBS = "start|use|approve|verify|check|test|release-done|release|finish|abort|init|doctor|reflect|roadmap|status|version|help";
|
|
24
|
+
|
|
25
|
+
/** Text that tells someone to run dev-flow machinery: a flow verb, a gate flag, the worker tool, the slash command. */
|
|
26
|
+
export const OPERATOR_COMMAND_RE = new RegExp(`(?:^|[\\s\`'"(*_])/?flow (?:${FLOW_VERBS})\\b|(?:^|\\s)--[a-z][a-z-]*\\b|\\bflow_stage\\b|(?:^|\\s)/flow\\b`);
|
|
27
|
+
|
|
28
|
+
export const commandish = (s: string): boolean => OPERATOR_COMMAND_RE.test(s);
|
|
29
|
+
|
|
30
|
+
/** Clause separators that keep a refusal's fact apart from its instruction. */
|
|
31
|
+
const CLAUSE_SPLIT = /(\s+—\s+|;\s+|(?<=[.!?])\s+(?=[A-Z`(])|,\s+then\s+|\s+\(or\s+)/;
|
|
32
|
+
|
|
33
|
+
/** One gate line → the part the operator should read and the clauses only the agent needs. */
|
|
34
|
+
export function splitLine(line: string): { user: string; agent: string[] } {
|
|
35
|
+
if (line.startsWith(AGENT_MARK)) return { user: "", agent: [line.slice(AGENT_MARK.length)] };
|
|
36
|
+
if (!commandish(line)) return { user: line, agent: [] };
|
|
37
|
+
const parts = line.split(CLAUSE_SPLIT);
|
|
38
|
+
const agent: string[] = [];
|
|
39
|
+
let user = "";
|
|
40
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
41
|
+
const clause = parts[i];
|
|
42
|
+
if (!clause.trim()) continue;
|
|
43
|
+
if (commandish(clause)) agent.push(clause.trim());
|
|
44
|
+
else user += (user ? (parts[i - 1] ?? " ") : "") + clause;
|
|
45
|
+
}
|
|
46
|
+
user = user.replace(/[\s:;,—(-]+$/, "");
|
|
47
|
+
// a bullet whose every clause was an instruction leaves only its marker
|
|
48
|
+
if (/^\s*[-*]?\s*$/.test(user)) user = "";
|
|
49
|
+
return { user, agent };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The operator's checkpoint word a result is waiting on, if any. */
|
|
53
|
+
export function askOf(text: string, state: FlowState | null): string | undefined {
|
|
54
|
+
const m = new RegExp(`${NEEDS_OPERATOR}(?: ([A-Z][\\w -]*\\?))?`).exec(text);
|
|
55
|
+
if (m) return m[1] ?? "your decision";
|
|
56
|
+
return state?.pendingAsk;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const GATE_TITLES: Record<string, string> = {
|
|
60
|
+
init: "Playbook",
|
|
61
|
+
start: "Start",
|
|
62
|
+
use: "Session bound",
|
|
63
|
+
status: "Status",
|
|
64
|
+
approve: "Plan approval",
|
|
65
|
+
check: "Checks",
|
|
66
|
+
test: "Checks",
|
|
67
|
+
verify: "Verification",
|
|
68
|
+
release: "Release",
|
|
69
|
+
"release-done": "Release record",
|
|
70
|
+
finish: "Finish",
|
|
71
|
+
abort: "Abort",
|
|
72
|
+
doctor: "Doctor",
|
|
73
|
+
reflect: "Reflections",
|
|
74
|
+
roadmap: "Roadmap",
|
|
75
|
+
version: "Version",
|
|
76
|
+
help: "Help",
|
|
77
|
+
"--help": "Help",
|
|
78
|
+
"-h": "Help",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const gateTitle = (sub: string): string => GATE_TITLES[sub] ?? sub.charAt(0).toUpperCase() + sub.slice(1);
|
|
82
|
+
|
|
83
|
+
/** Cheap facts a gate can add to the stage line beyond what state holds (git counts, the plan file). */
|
|
84
|
+
export interface StageFacts {
|
|
85
|
+
plan?: "missing" | "draft" | "written";
|
|
86
|
+
mockups?: { rendered: number; total: number };
|
|
87
|
+
ahead?: number;
|
|
88
|
+
uncommitted?: number;
|
|
89
|
+
head?: string;
|
|
90
|
+
manifest?: string | null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function checksSummary(state: FlowState): string {
|
|
94
|
+
const entries = Object.entries(state.checks);
|
|
95
|
+
if (!entries.length) return "`none run` ?";
|
|
96
|
+
return entries.map(([k, v]) => `${k} ${v.ok ? "✓" : "✗"}`).join(" ");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The stage line: stage glyph, slug, mode glyphs, then provenance-marked decision fields.
|
|
100
|
+
* `✓` operator · `✓playbook` rule/default · `~` agent-assumed · `?` waiting on the operator. */
|
|
101
|
+
export function stageLine(state: FlowState, cfg: Config, f: StageFacts = {}): string {
|
|
102
|
+
const marks = [state.patch ? "⚡" : state.docs ? "📚" : "", state.yolo ? "🎱" : ""].filter(Boolean).join("");
|
|
103
|
+
const fields: string[] = [];
|
|
104
|
+
fields.push(state.patch ? "`patch` ✓" : state.docs ? "`docs` ✓" : "`normal` ✓playbook");
|
|
105
|
+
fields.push(state.ui ? "ui `on` ✓" : "ui `off` ✓playbook");
|
|
106
|
+
const stage = state.stage;
|
|
107
|
+
if (stage === "plan") {
|
|
108
|
+
if (!state.patch && !state.docs) fields.push(`plan \`${f.plan ?? "missing"}\` ${f.plan === "written" ? "~" : "?"}`);
|
|
109
|
+
if (state.ui && f.mockups) fields.push(`mockups \`${f.mockups.rendered}/${f.mockups.total}\` ${f.mockups.total && f.mockups.rendered === f.mockups.total ? "~" : "?"}`);
|
|
110
|
+
}
|
|
111
|
+
if (stage === "implement" || stage === "pre-release") {
|
|
112
|
+
if (f.ahead !== undefined) fields.push(`commits \`${f.ahead} ahead, ${f.uncommitted ?? 0} uncommitted\``);
|
|
113
|
+
if (!state.docs) fields.push(`checks ${checksSummary(state)}`);
|
|
114
|
+
const items = applicableItems(cfg, state, stage).length;
|
|
115
|
+
const pend = checklistPending(cfg, state, stage);
|
|
116
|
+
if (pend) fields.push(`tier-2 \`${pend} open\` ?`);
|
|
117
|
+
else if (items) fields.push("tier-2 `confirmed` ✓");
|
|
118
|
+
}
|
|
119
|
+
if (stage === "pre-release" || stage === "release") {
|
|
120
|
+
const version = state.noVersion ? "version `no-version` ✓" : state.releaseVersion ? `version \`${state.releaseVersion}\` ✓` : f.manifest ? `version \`${f.manifest}\` ~` : "version `pending` ?";
|
|
121
|
+
fields.push(version);
|
|
122
|
+
const merge = cfg.release.merge;
|
|
123
|
+
fields.push(merge ? `merge \`${merge}\` ✓playbook` : "merge `unset` ?");
|
|
124
|
+
}
|
|
125
|
+
if (stage === "release") {
|
|
126
|
+
fields.push(state.approvals.release ? "release `recorded` ✓" : "release `publishing` ~");
|
|
127
|
+
if (state.forgeReleaseSkipped) fields.push("forge release `skipped` ?");
|
|
128
|
+
}
|
|
129
|
+
if (f.head && state.branch) fields.push(`\`${state.branch}@${f.head.slice(0, 7)}\``);
|
|
130
|
+
if (state.pendingAsk) fields.push(`waiting on you \`${state.pendingAsk}\` ?`);
|
|
131
|
+
return `**${STAGE_EMOJI[stage]} ${stage} · \`${state.slug}\`${marks ? ` ${marks}` : ""}** — ${fields.join(" · ")}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** What the renderer and the /flow command show, plus the agent's own lines. */
|
|
135
|
+
export interface GateView {
|
|
136
|
+
ok: boolean;
|
|
137
|
+
title: string;
|
|
138
|
+
slug?: string;
|
|
139
|
+
stageLine?: string;
|
|
140
|
+
lines: string[];
|
|
141
|
+
ask?: string;
|
|
142
|
+
agent: string[];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Split one gate result into the operator's view and the agent's instructions. */
|
|
146
|
+
export function presentGate(sub: string, text: string, isError: boolean, state: FlowState | null, cfg: Config, facts?: StageFacts): GateView {
|
|
147
|
+
const base = { ok: !isError, title: gateTitle(sub), slug: state?.slug, stageLine: state ? stageLine(state, cfg, facts) : undefined };
|
|
148
|
+
// machine output and the command reference are for the agent; the operator sees what they are, not their body
|
|
149
|
+
if (/^\s*[[{]/.test(text)) return { ...base, lines: ["machine-readable output (for the agent)"], agent: [] };
|
|
150
|
+
if (sub === "help" || sub === "--help" || sub === "-h") return { ...base, lines: ["dev-flow command reference (for the agent — you answer in words)"], agent: [] };
|
|
151
|
+
const lines: string[] = [];
|
|
152
|
+
const agent: string[] = [];
|
|
153
|
+
for (const raw of text.split("\n")) {
|
|
154
|
+
const line = raw.startsWith(NEEDS_OPERATOR) ? raw.replace(new RegExp(`^${NEEDS_OPERATOR}(?: [A-Z][\\w -]*\\?)?\\s*—?\\s*`), "") : raw;
|
|
155
|
+
const s = splitLine(line);
|
|
156
|
+
if (s.user.trim()) lines.push(s.user);
|
|
157
|
+
agent.push(...s.agent);
|
|
158
|
+
}
|
|
159
|
+
const ask = askOf(text, state);
|
|
160
|
+
return {
|
|
161
|
+
ok: !isError || ask !== undefined,
|
|
162
|
+
title: gateTitle(sub),
|
|
163
|
+
slug: state?.slug,
|
|
164
|
+
stageLine: state ? stageLine(state, cfg, facts) : undefined,
|
|
165
|
+
lines: trimBlank(lines),
|
|
166
|
+
ask,
|
|
167
|
+
agent,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function trimBlank(lines: string[]): string[] {
|
|
172
|
+
const out = [...lines];
|
|
173
|
+
while (out.length && !out[0].trim()) out.shift();
|
|
174
|
+
while (out.length && !out.at(-1)!.trim()) out.pop();
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Header glyph: done, refused, or parked on the operator. */
|
|
179
|
+
export function viewGlyph(v: GateView): string {
|
|
180
|
+
if (v.ask) return "💬";
|
|
181
|
+
return v.ok ? "✅" : "❌";
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function viewHeader(v: GateView): string {
|
|
185
|
+
return `${viewGlyph(v)} ${v.title}${v.ok || v.ask ? "" : " refused"}${v.slug ? ` · ${v.slug}` : ""}`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** The question line: the checkpoint word, said in chat — never a command. */
|
|
189
|
+
export function askLine(ask: string): string {
|
|
190
|
+
const word = /\?$/.test(ask) ? `**${ask}**` : ask;
|
|
191
|
+
return /^(Approve|Verified|Release|Finish)\?$/.test(ask) ? `Your call: ${word} — answer in chat (yes / no with a reason / yolo)` : `Your call: ${word} — answer in chat`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Plain markdown of the user view — the /flow command's message and the fallback for hosts with no renderer. */
|
|
195
|
+
export function renderPlain(v: GateView): string {
|
|
196
|
+
const out = [`**${viewHeader(v)}**`];
|
|
197
|
+
if (v.stageLine) out.push(v.stageLine);
|
|
198
|
+
if (v.lines.length) out.push("", ...v.lines);
|
|
199
|
+
if (v.ask) out.push("", askLine(v.ask));
|
|
200
|
+
return out.join("\n");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** The agent's copy: its original text, with the stage line it must open its report with. */
|
|
204
|
+
export function agentText(text: string, v: GateView): string {
|
|
205
|
+
return v.stageLine ? `${text}\n${AGENT_MARK}stage line for your report (paste as is): ${v.stageLine}` : text;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Sentences in an assistant message that hand the operator a dev-flow command to type. */
|
|
209
|
+
export function operatorCommandAsks(message: string): string[] {
|
|
210
|
+
const hits: string[] = [];
|
|
211
|
+
// fenced code is command output being shown, not a request
|
|
212
|
+
const prose = message.replace(/```[\s\S]*?```/g, "");
|
|
213
|
+
for (const sentence of prose.split(/(?<=[.!?])\s+|\n+/)) {
|
|
214
|
+
if (!commandish(sentence)) continue;
|
|
215
|
+
// addressed to the operator: an imperative or a "you can / please" form around the command
|
|
216
|
+
if (/\b(you (can|could|may|should|need to|might)|please|type|run|enter|use|try|send|invoke)\b/i.test(sentence) && !/\bI('ll| will| am going to| ran|'m running| run)\b/.test(sentence)) hits.push(sentence.trim());
|
|
217
|
+
}
|
|
218
|
+
return hits;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** The hidden correction the session gets after an answer that asked the operator to type a command. */
|
|
222
|
+
export function operatorCommandCorrection(hits: string[]): string {
|
|
223
|
+
return `[dev-flow] Your last message asked the operator to run a dev-flow command (${hits.map((h) => `"${h.slice(0, 120)}"`).join("; ")}). The operator answers in words — you run the flow tool. From now on ask the checkpoint word (Approve? / Verified? / Release? / Finish?) or a plain question, and run the gate yourself once they answer. Do not apologise for this note; just follow it next time.`;
|
|
224
|
+
}
|
package/src/projectmd.ts
CHANGED
|
@@ -63,6 +63,7 @@ const KEYMAP: Record<string, Record<string, string>> = {
|
|
|
63
63
|
preflight: "release.preflight", // run in the worktree at flow release, before anything ships (e.g. docker build .)
|
|
64
64
|
merge: "release.merge", // how a merged branch lands: squash | merge | rebase | any
|
|
65
65
|
yolo: "release.yolo", // how far a standing yolo reaches: all (default) | until-release (gh#176)
|
|
66
|
+
reflect: "release.reflect", // when finish runs the closing reflection: on-friction (default) | always
|
|
66
67
|
},
|
|
67
68
|
};
|
|
68
69
|
// pre-release owns release preparation; the release keys are accepted under both sections so
|
|
@@ -173,6 +174,10 @@ export function parseProjectMd(text: string): ParsedMd {
|
|
|
173
174
|
p.warn.push(`${where}: yolo = "${m[2]}" — expected all or until-release, keeping all`);
|
|
174
175
|
return;
|
|
175
176
|
}
|
|
177
|
+
if (mapped === "release.reflect" && !/^(always|on-friction)$/.test(m[2].trim())) {
|
|
178
|
+
p.warn.push(`${where}: reflect = "${m[2]}" — expected always or on-friction, keeping on-friction`);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
176
181
|
p.flow[stage as MdStage][mapped] = m[2];
|
|
177
182
|
}
|
|
178
183
|
}
|
|
@@ -350,7 +355,7 @@ const ANSWER_STAGE: Record<string, MdStage> = {
|
|
|
350
355
|
setup: "implement", test: "implement", build: "implement", run: "implement", seedData: "implement", health: "implement", dev: "implement", healthWait: "implement",
|
|
351
356
|
port: "implement", parallelDev: "implement", instanceMem: "implement", instanceDisk: "implement", devDown: "implement", servedBuild: "implement",
|
|
352
357
|
versionFile: "pre-release", versionTag: "pre-release", changelog: "pre-release", review: "pre-release",
|
|
353
|
-
releases: "release", artifact: "release", preflight: "release", merge: "release", yolo: "release",
|
|
358
|
+
releases: "release", artifact: "release", preflight: "release", merge: "release", yolo: "release", reflect: "release",
|
|
354
359
|
};
|
|
355
360
|
/** The draft's placeholder comment per key (buildDraft) — stale once the key has an answer. */
|
|
356
361
|
const DRAFT_HINTS: Record<string, RegExp> = { versionFile: /<!-- versionFile = /, merge: /<!-- merge = /, changelog: /<!-- no changelog found/ };
|