flowviant 0.105.0 → 0.106.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/bin/lib/agentCards.mjs +9 -2
- package/bin/lib/agentTaskTypes.mjs +135 -0
- package/bin/lib/cardThread.mjs +89 -0
- package/bin/lib/prompts.mjs +93 -11
- package/bin/lib/workAgentTurnExecution.mjs +10 -2
- package/package.json +1 -1
package/bin/lib/agentCards.mjs
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
import { appendFileSync, readFileSync } from 'node:fs';
|
|
40
|
+
import { CARD_THREAD_RENDER_MAX } from './cardThread.mjs';
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* How many card specs one agent may accumulate.
|
|
@@ -49,8 +50,14 @@ import { appendFileSync, readFileSync } from 'node:fs';
|
|
|
49
50
|
export const MAX_STASHED_CARDS = 40;
|
|
50
51
|
/** The most one spec may contribute. A brief is written by whoever filed the
|
|
51
52
|
* card and the server caps it, but this file is composed into a prompt and a
|
|
52
|
-
* bound it owns is a bound that cannot be argued away upstream.
|
|
53
|
-
|
|
53
|
+
* bound it owns is a bound that cannot be argued away upstream.
|
|
54
|
+
*
|
|
55
|
+
* 8,000 is the record's brief ceiling; since 0.106.0 the spec also carries
|
|
56
|
+
* the card's discussion, so the bound grows by the most a turn's discussion
|
|
57
|
+
* can render to (`CARD_THREAD_RENDER_MAX`). The discussion is printed LAST,
|
|
58
|
+
* and a stash that cut it would hand the pre-review a thread missing its
|
|
59
|
+
* newest words — the ones the agent read most recently. */
|
|
60
|
+
export const MAX_SPEC_CHARS = 8_000 + CARD_THREAD_RENDER_MAX;
|
|
54
61
|
|
|
55
62
|
/**
|
|
56
63
|
* Write down the spec this turn is about to hand the agent.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A CARD'S TYPE — the daemon's one table of what each type ASKS (0.106.0).
|
|
3
|
+
*
|
|
4
|
+
* A type is the kind of WORK a card asks for — a Bug fix, a Refactor, a Code
|
|
5
|
+
* review — a flavour over the card's KIND (agentTaskKinds.mjs), which stays the
|
|
6
|
+
* end product and the posture the turn runs under. Every type runs as exactly
|
|
7
|
+
* one kind (`kind` below, the app's `TASK_TYPE_KIND`), and adds the one thing
|
|
8
|
+
* the kind cannot say: a bug fix reproduces first, a refactor must not change
|
|
9
|
+
* behaviour, a code review changes nothing.
|
|
10
|
+
*
|
|
11
|
+
* The server sends the id — `agentTurnJobs[].task.taskType` and
|
|
12
|
+
* `agentPlanJobs[].tasks[].taskType` — and only to a daemon at 0.106.0 (below
|
|
13
|
+
* it the server parks a typed card's turn rather than hand it to a daemon that
|
|
14
|
+
* would drop the key). THE DAEMON OWNS THE WORDS: each type's `contract` is
|
|
15
|
+
* the one sentence an agent is held to, printed inside THE CARD right after
|
|
16
|
+
* the kind line (`AGENT_TASK_SPEC`), so the spec stashed for the pre-review
|
|
17
|
+
* carries it too. Each sentence is true to what its kind's posture can do: a
|
|
18
|
+
* code type may build and test; a write-up type reads and writes one Markdown
|
|
19
|
+
* file; a mockup type writes under .flowviant/artifacts/ and nothing else.
|
|
20
|
+
*
|
|
21
|
+
* `label` is the app's `TASK_TYPE_LABEL`, the word a person picked. The ids
|
|
22
|
+
* (in the app's picker order), their kinds and their labels are held to the
|
|
23
|
+
* app's `taskType.ts` by the release gate (`scripts/check-app-parity.mjs`,
|
|
24
|
+
* rule 6): a type the server sends that this table lacks is printed as
|
|
25
|
+
* nothing, and one it has that the server never sends is dead.
|
|
26
|
+
*
|
|
27
|
+
* Pure data and pure functions; its one import is the kind table's reader.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { agentTaskKindOf } from './agentTaskKinds.mjs';
|
|
31
|
+
|
|
32
|
+
export const AGENT_TASK_TYPES = Object.freeze({
|
|
33
|
+
feature: Object.freeze({
|
|
34
|
+
label: 'Feature',
|
|
35
|
+
kind: 'code',
|
|
36
|
+
contract: 'new behaviour: build it, and cover it with tests where the repository has them.',
|
|
37
|
+
}),
|
|
38
|
+
fix: Object.freeze({
|
|
39
|
+
label: 'Bug fix',
|
|
40
|
+
kind: 'code',
|
|
41
|
+
contract:
|
|
42
|
+
'reproduce it first, with a failing test where the repository has tests, then make that test pass.',
|
|
43
|
+
}),
|
|
44
|
+
tests: Object.freeze({
|
|
45
|
+
label: 'Tests',
|
|
46
|
+
kind: 'code',
|
|
47
|
+
contract:
|
|
48
|
+
'add tests for code that already exists and change no production code; if a test exposes a bug, ' +
|
|
49
|
+
'say so in your summary instead of fixing it.',
|
|
50
|
+
}),
|
|
51
|
+
refactor: Object.freeze({
|
|
52
|
+
label: 'Refactor',
|
|
53
|
+
kind: 'code',
|
|
54
|
+
contract: 'behaviour must not change; if an existing test would have to change, stop and ask.',
|
|
55
|
+
}),
|
|
56
|
+
infra: Object.freeze({
|
|
57
|
+
label: 'Infra & deploy',
|
|
58
|
+
kind: 'code',
|
|
59
|
+
contract: 'change the configuration in the repository; never run a deploy or touch a live environment.',
|
|
60
|
+
}),
|
|
61
|
+
automation: Object.freeze({
|
|
62
|
+
label: 'Automation',
|
|
63
|
+
kind: 'code',
|
|
64
|
+
contract:
|
|
65
|
+
"add the scheduled job to the repository (a CI schedule, or a script and its schedule) so it runs " +
|
|
66
|
+
"where the repository's CI runs; do not run it.",
|
|
67
|
+
}),
|
|
68
|
+
review: Object.freeze({
|
|
69
|
+
label: 'Code review',
|
|
70
|
+
kind: 'research',
|
|
71
|
+
contract:
|
|
72
|
+
'read the code the card names and write up what is wrong, by file and line, most serious first; ' +
|
|
73
|
+
'change nothing.',
|
|
74
|
+
}),
|
|
75
|
+
ui: Object.freeze({
|
|
76
|
+
label: 'UI design',
|
|
77
|
+
kind: 'design',
|
|
78
|
+
contract: "draw the screens and flows the card names as the mockup page, in this product's own components and words.",
|
|
79
|
+
}),
|
|
80
|
+
prototype: Object.freeze({
|
|
81
|
+
label: 'Prototype',
|
|
82
|
+
kind: 'design',
|
|
83
|
+
contract: 'make every control in the flow work, with realistic sample data, in the one page.',
|
|
84
|
+
}),
|
|
85
|
+
slides: Object.freeze({
|
|
86
|
+
label: 'Slides',
|
|
87
|
+
kind: 'deck',
|
|
88
|
+
contract: 'one deck for the audience and the length the card asks for, one point to a slide.',
|
|
89
|
+
}),
|
|
90
|
+
model3d: Object.freeze({
|
|
91
|
+
label: '3D model',
|
|
92
|
+
kind: 'model',
|
|
93
|
+
contract:
|
|
94
|
+
'model the object the card describes as the viewable bundle, at the scale and in the units of any ' +
|
|
95
|
+
'3D assets the repository already has.',
|
|
96
|
+
}),
|
|
97
|
+
vector: Object.freeze({
|
|
98
|
+
label: 'Icons & vector',
|
|
99
|
+
kind: 'design',
|
|
100
|
+
contract:
|
|
101
|
+
'write each icon as its own .svg file directly in .flowviant/artifacts/, and make the mockup page ' +
|
|
102
|
+
'the sheet that shows them all, inline, at the sizes they are used.',
|
|
103
|
+
}),
|
|
104
|
+
research: Object.freeze({
|
|
105
|
+
label: 'Research',
|
|
106
|
+
kind: 'research',
|
|
107
|
+
contract: 'answer the question the card asks, leading with the answer and citing what you read.',
|
|
108
|
+
}),
|
|
109
|
+
writing: Object.freeze({
|
|
110
|
+
label: 'Writing',
|
|
111
|
+
kind: 'research',
|
|
112
|
+
contract: 'write the document the card asks for, for the reader it names, in words that reader uses.',
|
|
113
|
+
}),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A CARD'S TYPE, READ THE ONE WAY THE DAEMON READS IT — a type this table
|
|
118
|
+
* knows, else null. ABSENT IS NO TYPE (every card before 0.106.0, and every
|
|
119
|
+
* job from an older server), and an unknown id (a newer server, a typo) is
|
|
120
|
+
* dropped rather than guessed at: a type only adds a sentence, so dropping one
|
|
121
|
+
* leaves the card running on its kind, which is what it always did.
|
|
122
|
+
*/
|
|
123
|
+
export const agentTaskTypeOf = (v) => (typeof v === 'string' && Object.hasOwn(AGENT_TASK_TYPES, v) ? v : null);
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The type of a card AS IT WILL BE PRINTED — null unless the card's type is
|
|
127
|
+
* known here AND runs as the card's own kind. The server sends a type only on
|
|
128
|
+
* its kind, but the card is a document any editor writes; a Bug fix sentence
|
|
129
|
+
* ("with a failing test") under a mockup's posture is a contract the turn
|
|
130
|
+
* cannot keep, so a type on another kind is printed as nothing.
|
|
131
|
+
*/
|
|
132
|
+
export const agentTaskTypeFor = (task) => {
|
|
133
|
+
const type = agentTaskTypeOf(task?.taskType);
|
|
134
|
+
return type && AGENT_TASK_TYPES[type].kind === agentTaskKindOf(task?.taskKind) ? type : null;
|
|
135
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A CARD'S DISCUSSION, AS THE WIRE HANDS IT OVER (0.106.0) — the owner,
|
|
3
|
+
* 2026-09-27: "yes agents should read card comments".
|
|
4
|
+
*
|
|
5
|
+
* The server relays a card's thread (people's comments AND agents' own notes,
|
|
6
|
+
* replies and delivery cards) onto the jobs that work or plan it:
|
|
7
|
+
* `agentTurnJobs[].cardThread` (the one card a turn is about, named by
|
|
8
|
+
* `taskId` and `title`) and `agentPlanJobs[].tasks[].thread`. Each is
|
|
9
|
+
* `{ entries: [{ who, at, text }], omitted }`, oldest first — the newest run
|
|
10
|
+
* of the thread that fits the server's budget, with `omitted` counting the
|
|
11
|
+
* older entries it left out.
|
|
12
|
+
*
|
|
13
|
+
* THE WIRE IS NOT TRUSTED. The server bounded it (`CARD_THREAD_BUDGET` in the
|
|
14
|
+
* app's agent-runner.schema.ts); this module reads it again, entry by entry,
|
|
15
|
+
* and applies the SAME numbers — a copy the release gate holds to the server's
|
|
16
|
+
* (`scripts/check-app-parity.mjs`, rule 5). A malformed entry is dropped
|
|
17
|
+
* alone; a name or a time is one bounded line (a line break would forge a
|
|
18
|
+
* second entry); a text past its cap is cut and marked; entries past the
|
|
19
|
+
* budget are dropped from the OLDEST end and counted, so an agent is never
|
|
20
|
+
* handed a thread that silently starts in the middle.
|
|
21
|
+
*
|
|
22
|
+
* Absent, empty or wholly malformed reads as null, and a null thread prints
|
|
23
|
+
* NOTHING — which is why every prompt for a card nobody discussed (and every
|
|
24
|
+
* job from a server older than 0.106.0) stays byte-identical.
|
|
25
|
+
*
|
|
26
|
+
* Pure data and pure functions: no imports, no environment, no I/O — prompts
|
|
27
|
+
* imports it, and prompts is strings.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** The server's `CARD_THREAD_BUDGET`, row for row: a TURN reads one card, a
|
|
31
|
+
* PLAN glances at many. */
|
|
32
|
+
export const CARD_THREAD_BUDGET = Object.freeze({
|
|
33
|
+
turn: Object.freeze({ entries: 30, chars: 6000, entryChars: 1500 }),
|
|
34
|
+
plan: Object.freeze({ entries: 6, chars: 1200, entryChars: 400 }),
|
|
35
|
+
});
|
|
36
|
+
/** The server's `CARD_THREAD_WHO_MAX` — a name is a label. */
|
|
37
|
+
export const CARD_THREAD_WHO_MAX = 80;
|
|
38
|
+
/** The server's `CARD_THREAD_AT_MAX` — an ISO time, with room. */
|
|
39
|
+
export const CARD_THREAD_AT_MAX = 40;
|
|
40
|
+
/** A count is a number a prompt prints; past this it is not a count. */
|
|
41
|
+
const OMITTED_MAX = 1_000_000;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* THE MOST ONE TURN'S DISCUSSION CAN ADD TO A CARD SPEC, rendered — so the
|
|
45
|
+
* spec stash (agentCards.mjs `MAX_SPEC_CHARS`) can hold a card with its
|
|
46
|
+
* discussion whole, and the pre-review reads what the agent read. The text is
|
|
47
|
+
* at most `chars`; the renderer adds at most two characters and a newline per
|
|
48
|
+
* text line (<= 3x the text), a header line per entry, and two lines of its
|
|
49
|
+
* own. `cardThread.test.mjs` renders the worst case against it.
|
|
50
|
+
*/
|
|
51
|
+
export const CARD_THREAD_RENDER_MAX =
|
|
52
|
+
3 * CARD_THREAD_BUDGET.turn.chars +
|
|
53
|
+
CARD_THREAD_BUDGET.turn.entries * (CARD_THREAD_WHO_MAX + CARD_THREAD_AT_MAX + 10) +
|
|
54
|
+
200;
|
|
55
|
+
|
|
56
|
+
const oneLine = (v, max) => String(v).replace(/[\r\n]+/g, ' ').trim().slice(0, max);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A thread off the wire, re-bounded at `budget`'s row ('turn' | 'plan'; an
|
|
60
|
+
* unknown row is the tighter plan one), or null when there is nothing in it to
|
|
61
|
+
* print. Never throws.
|
|
62
|
+
*/
|
|
63
|
+
export function readCardThread(raw, budget = 'turn') {
|
|
64
|
+
const b = CARD_THREAD_BUDGET[budget] ?? CARD_THREAD_BUDGET.plan;
|
|
65
|
+
if (!raw || typeof raw !== 'object' || !Array.isArray(raw.entries)) return null;
|
|
66
|
+
const good = [];
|
|
67
|
+
for (const e of raw.entries) {
|
|
68
|
+
if (!e || typeof e !== 'object') continue;
|
|
69
|
+
if (typeof e.who !== 'string' || typeof e.at !== 'string' || typeof e.text !== 'string') continue;
|
|
70
|
+
const whole = e.text.replace(/\r\n?/g, '\n').trim();
|
|
71
|
+
if (!whole) continue;
|
|
72
|
+
good.push({
|
|
73
|
+
who: oneLine(e.who, CARD_THREAD_WHO_MAX) || 'member',
|
|
74
|
+
at: oneLine(e.at, CARD_THREAD_AT_MAX),
|
|
75
|
+
text: whole.length > b.entryChars ? `${whole.slice(0, b.entryChars - 1)}…` : whole,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// The newest contiguous run that fits — the server's own walk.
|
|
79
|
+
const kept = [];
|
|
80
|
+
let chars = 0;
|
|
81
|
+
for (let i = good.length - 1; i >= 0 && kept.length < b.entries; i--) {
|
|
82
|
+
if (chars + good[i].text.length > b.chars) break;
|
|
83
|
+
chars += good[i].text.length;
|
|
84
|
+
kept.push(good[i]);
|
|
85
|
+
}
|
|
86
|
+
if (kept.length === 0) return null;
|
|
87
|
+
const sent = Number.isInteger(raw.omitted) && raw.omitted > 0 ? Math.min(raw.omitted, OMITTED_MAX) : 0;
|
|
88
|
+
return { entries: kept.reverse(), omitted: sent + (good.length - kept.length) };
|
|
89
|
+
}
|
package/bin/lib/prompts.mjs
CHANGED
|
@@ -3,19 +3,26 @@
|
|
|
3
3
|
* hands a coding CLI, in one place. Split out of claude.mjs purely for size
|
|
4
4
|
* (the permission sets are claudePosture.mjs's, the turn plumbing runTurn.mjs's);
|
|
5
5
|
* every call site imports them from here. These are strings and
|
|
6
|
-
* nothing else: no environment, no I/O, and
|
|
6
|
+
* nothing else: no environment, no I/O, and five imports — the card-kind
|
|
7
7
|
* table (agentTaskKinds.mjs, itself pure data), which selects among them; the
|
|
8
|
+
* card-type table (agentTaskTypes.mjs, pure data, 0.106.0), which holds each
|
|
9
|
+
* type's label and its one contract sentence; the
|
|
8
10
|
* 3D-model and presentation contracts and the tail every file-handing contract
|
|
9
|
-
* ends in (artifactContracts.mjs, strings split out for size);
|
|
11
|
+
* ends in (artifactContracts.mjs, strings split out for size); the kept
|
|
10
12
|
* library's reference rule (knowledgeLibrary.mjs, pure but for the pure
|
|
11
|
-
* safe-name rule), which decides which card references are printed
|
|
13
|
+
* safe-name rule), which decides which card references are printed; and the
|
|
14
|
+
* card-thread reader (cardThread.mjs, pure), which decides which of a card's
|
|
15
|
+
* discussion is printed (0.106.0).
|
|
12
16
|
*/
|
|
13
17
|
|
|
14
18
|
// A card's kind is read through agentTaskKinds.mjs — the one table of what a
|
|
15
19
|
// kind is. This file keeps only the STRINGS each kind is handed.
|
|
16
20
|
import { agentTaskKindOf } from './agentTaskKinds.mjs';
|
|
21
|
+
// A card's type (0.106.0) likewise: the table holds the words, this file prints them.
|
|
22
|
+
import { AGENT_TASK_TYPES, agentTaskTypeFor } from './agentTaskTypes.mjs';
|
|
17
23
|
import { ARTIFACT_CONTRACT_TAIL, SYSTEM_AGENT_DECK, SYSTEM_AGENT_MODEL } from './artifactContracts.mjs';
|
|
18
24
|
import { isLibraryReference } from './knowledgeLibrary.mjs';
|
|
25
|
+
import { readCardThread } from './cardThread.mjs';
|
|
19
26
|
|
|
20
27
|
// Wiki-gen turn: the local Claude READS the repo (cwd) and writes/maintains the
|
|
21
28
|
// knowledge VAULT — a plain directory of markdown files with [[wikilinks]]
|
|
@@ -791,7 +798,10 @@ exactly as given.`;
|
|
|
791
798
|
* The cards and the live agents are FENCED: their titles, briefs and criteria
|
|
792
799
|
* are written by whoever files cards in this project and by agents themselves,
|
|
793
800
|
* and this turn reads a repository afterwards. The instruction that matters —
|
|
794
|
-
* "split this" — is ours and sits outside the fence.
|
|
801
|
+
* "split this" — is ours and sits outside the fence. A card's discussion
|
|
802
|
+
* (0.106.0) is the same kind of text and sits inside the same fence. A card's
|
|
803
|
+
* TYPE (0.106.0) is printed under its kind by its label alone — the planner
|
|
804
|
+
* splits work, and the type's contract sentence is for the agent that does it.
|
|
795
805
|
*/
|
|
796
806
|
export const AGENT_PLAN_KICKOFF = ({ tasks, liveAgents, agentCap }) => {
|
|
797
807
|
const cards = tasks
|
|
@@ -802,10 +812,18 @@ export const AGENT_PLAN_KICKOFF = ({ tasks, liveAgents, agentCap }) => {
|
|
|
802
812
|
// by it (SYSTEM_PLAN rule 8), and an absent line would read as "not
|
|
803
813
|
// stated" rather than as the default. Absent on the wire IS code.
|
|
804
814
|
` kind: ${agentTaskKindOf(t.taskKind)}\n` +
|
|
815
|
+
// WHAT KIND OF WORK IT ASKS FOR (0.106.0), by its label — only on a
|
|
816
|
+
// typed card (a type on another kind is none), so an untyped card's
|
|
817
|
+
// listing, and every plan from an older server, is unchanged.
|
|
818
|
+
(agentTaskTypeFor(t) ? ` type: ${AGENT_TASK_TYPES[agentTaskTypeFor(t)].label}\n` : '') +
|
|
805
819
|
(t.points ? ` points: ${t.points}\n` : '') +
|
|
806
820
|
(t.anchors?.length ? ` owns: ${t.anchors.join(', ')}\n` : '') +
|
|
807
821
|
(t.brief ? ` brief: ${t.brief}\n` : '') +
|
|
808
|
-
(t.criteria?.length ? ` done when:\n${t.criteria.map((c) => ` - ${c}`).join('\n')}\n` : '')
|
|
822
|
+
(t.criteria?.length ? ` done when:\n${t.criteria.map((c) => ` - ${c}`).join('\n')}\n` : '') +
|
|
823
|
+
// WHAT HAS BEEN SAID ON IT (0.106.0) — at the plan row of the budget,
|
|
824
|
+
// inside the fence with the rest of the card. Absent on a card nobody
|
|
825
|
+
// discussed (and from an older server), so its listing is unchanged.
|
|
826
|
+
cardThreadText(readCardThread(t.thread, 'plan'), ' ')
|
|
809
827
|
)
|
|
810
828
|
.join('\n');
|
|
811
829
|
const live = liveAgents.length
|
|
@@ -1040,18 +1058,20 @@ export const AGENT_HANDS_BACK = Object.freeze({
|
|
|
1040
1058
|
*
|
|
1041
1059
|
* The card is FENCED: its title, brief and criteria are written by whoever
|
|
1042
1060
|
* files cards in this project, and this turn is about to edit code. The
|
|
1043
|
-
* instruction is ours and sits outside the fence.
|
|
1061
|
+
* instruction is ours and sits outside the fence. The card's DISCUSSION
|
|
1062
|
+
* (`cardThread`, 0.106.0) is printed inside the same fence, as part of the
|
|
1063
|
+
* spec (`AGENT_TASK_SPEC`), so the spec stashed for the pre-review carries it.
|
|
1044
1064
|
*
|
|
1045
1065
|
* The queue POSITION is stated because it changes behaviour: an agent that
|
|
1046
1066
|
* thinks it is finishing tidies up, writes summaries and stops; one that knows
|
|
1047
1067
|
* three more cards are coming leaves the ground ready for them.
|
|
1048
1068
|
*/
|
|
1049
|
-
export const AGENT_TASK_KICKOFF = ({ agentName, task, position, total }) =>
|
|
1069
|
+
export const AGENT_TASK_KICKOFF = ({ agentName, task, cardThread, position, total }) =>
|
|
1050
1070
|
agentTaskKindOf(task?.taskKind) === 'code'
|
|
1051
1071
|
? `You are the agent "${safeName(agentName)}", working card ${position} of ${total} ` +
|
|
1052
1072
|
`on this branch. Everything you commit here is reviewed and merged TOGETHER with ` +
|
|
1053
1073
|
`the other cards in this run.\n\n` +
|
|
1054
|
-
`${fence('THE CARD', taskBlock(task))}\n\n` +
|
|
1074
|
+
`${fence('THE CARD', taskBlock(task, cardThread))}\n\n` +
|
|
1055
1075
|
`When you commit, put this trailer on the LAST line of each commit message so ` +
|
|
1056
1076
|
`the card can find its own commits:\n` +
|
|
1057
1077
|
`Flowviant-Task: ${task?.id ?? ''}\n\n` +
|
|
@@ -1063,7 +1083,7 @@ export const AGENT_TASK_KICKOFF = ({ agentName, task, position, total }) =>
|
|
|
1063
1083
|
`You are the agent "${safeName(agentName)}", working card ${position} of ${total} ` +
|
|
1064
1084
|
`in this run. This card is ${AGENT_HANDS_BACK[agentTaskKindOf(task?.taskKind)]}, ` +
|
|
1065
1085
|
`written under .flowviant/artifacts/, and changes nothing in the repository.\n\n` +
|
|
1066
|
-
`${fence('THE CARD', taskBlock(task))}\n\n` +
|
|
1086
|
+
`${fence('THE CARD', taskBlock(task, cardThread))}\n\n` +
|
|
1067
1087
|
`Do it, and end with the JSON object.`;
|
|
1068
1088
|
|
|
1069
1089
|
/**
|
|
@@ -1091,7 +1111,7 @@ const safeName = (n) =>
|
|
|
1091
1111
|
* renderings of a card that can drift — and the drift would be invisible,
|
|
1092
1112
|
* because nobody reads both prompts side by side.
|
|
1093
1113
|
*/
|
|
1094
|
-
export const AGENT_TASK_SPEC = (task) =>
|
|
1114
|
+
export const AGENT_TASK_SPEC = (task, cardThread) =>
|
|
1095
1115
|
`id: ${task?.id ?? ''}\n` +
|
|
1096
1116
|
`title: ${task?.title ?? ''}\n` +
|
|
1097
1117
|
// THE KIND, when it is news (0.97.0). A code card's spec stays byte-for-byte
|
|
@@ -1099,6 +1119,11 @@ export const AGENT_TASK_SPEC = (task) =>
|
|
|
1099
1119
|
// and a line saying "kind: code" on every card is a change to every prompt
|
|
1100
1120
|
// for a fact that was always true.
|
|
1101
1121
|
(agentTaskKindOf(task?.taskKind) !== 'code' ? `kind: ${agentTaskKindOf(task.taskKind)}\n` : '') +
|
|
1122
|
+
// THE TYPE AND ITS ONE CONTRACT SENTENCE (0.106.0), right under the kind:
|
|
1123
|
+
// "type: Bug fix — reproduce it first, …". Only a type this daemon knows,
|
|
1124
|
+
// on its own kind (`agentTaskTypeFor`); an untyped card's spec — and every
|
|
1125
|
+
// job from an older server — is byte-for-byte what it was.
|
|
1126
|
+
typeLine(task) +
|
|
1102
1127
|
(task?.brief ? `\nbrief:\n${task.brief}\n` : '') +
|
|
1103
1128
|
(task?.criteria?.length ? `\ndone when:\n${task.criteria.map((c) => `- ${c}`).join('\n')}\n` : '') +
|
|
1104
1129
|
(task?.anchors?.length ? `\nthis card owns:\n${task.anchors.map((a) => `- ${a}`).join('\n')}\n` : '') +
|
|
@@ -1111,8 +1136,48 @@ export const AGENT_TASK_SPEC = (task) =>
|
|
|
1111
1136
|
.filter(isReference)
|
|
1112
1137
|
.map((r) => `- ${oneLine(r.name, 200)} — ${oneLine(r.title, 200)}`)
|
|
1113
1138
|
.join('\n')}\n`
|
|
1139
|
+
: '') +
|
|
1140
|
+
// WHAT HAS BEEN SAID ON THE CARD (0.106.0) — the task turn's `cardThread`,
|
|
1141
|
+
// LAST, after everything the card asks. Printed only when it names THIS
|
|
1142
|
+
// card and holds something, so every spec without a discussion — every
|
|
1143
|
+
// stash and every prompt before 0.106.0 — is byte-for-byte what it was.
|
|
1144
|
+
(cardThread && task?.id && String(cardThread.taskId ?? '') === String(task.id)
|
|
1145
|
+
? prefixed('\n', cardThreadText(readCardThread(cardThread, 'turn')))
|
|
1114
1146
|
: '');
|
|
1115
1147
|
|
|
1148
|
+
/** A card's type as the spec prints it, or ''. */
|
|
1149
|
+
const typeLine = (task) => {
|
|
1150
|
+
const type = agentTaskTypeFor(task);
|
|
1151
|
+
if (!type) return '';
|
|
1152
|
+
const { label, contract } = AGENT_TASK_TYPES[type];
|
|
1153
|
+
return `type: ${label} — ${contract}\n`;
|
|
1154
|
+
};
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* A CARD'S DISCUSSION AS TEXT — the one renderer, for the spec, a human
|
|
1158
|
+
* turn's own block and the plan's listing (0.106.0). '' for a null thread.
|
|
1159
|
+
*
|
|
1160
|
+
* Oldest first, one header line per entry (who, and when when it is known),
|
|
1161
|
+
* the words beneath it indented two spaces, so no line of somebody's comment
|
|
1162
|
+
* can start a new entry under another name. How many earlier entries the
|
|
1163
|
+
* budget left out is said, not hidden: an agent reading a reply without the
|
|
1164
|
+
* message it answers should know there was one.
|
|
1165
|
+
*/
|
|
1166
|
+
const cardThreadText = (thread, indent = '') => {
|
|
1167
|
+
if (!thread) return '';
|
|
1168
|
+
const lines = [`${indent}discussion on this card (oldest first):`];
|
|
1169
|
+
if (thread.omitted > 0) {
|
|
1170
|
+
lines.push(`${indent}(${thread.omitted} earlier message${thread.omitted === 1 ? '' : 's'} not shown)`);
|
|
1171
|
+
}
|
|
1172
|
+
for (const e of thread.entries) {
|
|
1173
|
+
lines.push(`${indent}- ${e.who}${e.at ? `, ${e.at}` : ''}:`);
|
|
1174
|
+
for (const line of e.text.split('\n')) lines.push(line ? `${indent} ${line}` : '');
|
|
1175
|
+
}
|
|
1176
|
+
return `${lines.join('\n')}\n`;
|
|
1177
|
+
};
|
|
1178
|
+
/** `head` before `text`, or '' when there is no text. */
|
|
1179
|
+
const prefixed = (head, text) => (text ? `${head}${text}` : '');
|
|
1180
|
+
|
|
1116
1181
|
/** A reference as the server sends it: a library path and its title. Anything
|
|
1117
1182
|
* else is not printed — this text is fenced as card content, but a path that
|
|
1118
1183
|
* is not a path is not worth handing an agent.
|
|
@@ -1135,16 +1200,33 @@ const taskBlock = AGENT_TASK_SPEC;
|
|
|
1135
1200
|
* It is the same shape as a task turn on purpose: the agent still ends with the
|
|
1136
1201
|
* JSON object, because whatever it does next either finishes the card it was on
|
|
1137
1202
|
* or blocks again, and those are the only two things the board can act on.
|
|
1203
|
+
*
|
|
1204
|
+
* THE CARD'S DISCUSSION (0.106.0) — when the turn is about one card (an
|
|
1205
|
+
* answer that names it, or a message to an agent holding one), the server
|
|
1206
|
+
* sends that card's thread, and it is printed AFTER the person's words in a
|
|
1207
|
+
* fence of its own, naming the card (a message often carries no `task` to name
|
|
1208
|
+
* it by). Never inside THE CARD YOU ARE ON: that block is the spec, as it
|
|
1209
|
+
* always was. Absent, nothing is printed, and the prompt is what it was.
|
|
1138
1210
|
*/
|
|
1139
|
-
export const AGENT_HUMAN_KICKOFF = ({ agentName, message, askedByName, task, position, total }) =>
|
|
1211
|
+
export const AGENT_HUMAN_KICKOFF = ({ agentName, message, askedByName, task, cardThread, position, total }) =>
|
|
1140
1212
|
`You are the agent "${safeName(agentName)}"` +
|
|
1141
1213
|
(task ? `, working card ${position} of ${total} on this branch` : '') +
|
|
1142
1214
|
`.\n\n` +
|
|
1143
1215
|
`${fence('WHO IS TALKING', askedByName || 'a member of this project')}\n\n` +
|
|
1144
1216
|
`${fence('WHAT THEY SAID', message)}\n\n` +
|
|
1145
1217
|
(task ? `${fence('THE CARD YOU ARE ON', taskBlock(task))}\n\n` : '') +
|
|
1218
|
+
cardDiscussionBlock(cardThread) +
|
|
1146
1219
|
`Carry on, and end with the JSON object as usual.`;
|
|
1147
1220
|
|
|
1221
|
+
/** A human turn's card discussion, fenced, naming the card — '' when there is
|
|
1222
|
+
* none to print. */
|
|
1223
|
+
const cardDiscussionBlock = (cardThread) => {
|
|
1224
|
+
const text = cardThreadText(readCardThread(cardThread, 'turn'));
|
|
1225
|
+
if (!text) return '';
|
|
1226
|
+
const head = `card: ${oneLine(cardThread.taskId, 64)}\ntitle: ${oneLine(cardThread.title, 300)}\n\n`;
|
|
1227
|
+
return `${fence("THE CARD'S DISCUSSION", `${head}${text}`)}\n\n`;
|
|
1228
|
+
};
|
|
1229
|
+
|
|
1148
1230
|
/**
|
|
1149
1231
|
* THE AI PRE-REVIEW — a FRESH Claude reads the branch before the human does
|
|
1150
1232
|
* (2026-09-16).
|
|
@@ -282,7 +282,9 @@ export function createAgentTurnExecution({
|
|
|
282
282
|
* what was asked for either way.
|
|
283
283
|
*
|
|
284
284
|
* ONE SPEC BUILDER (`AGENT_TASK_SPEC`) shared with the kickoff below, so
|
|
285
|
-
* what the reviewer reads is byte-identical to what the agent read
|
|
285
|
+
* what the reviewer reads is byte-identical to what the agent read — the
|
|
286
|
+
* card's discussion included (0.106.0): both are handed the same
|
|
287
|
+
* `job.cardThread`, and the builder prints it inside the spec.
|
|
286
288
|
* Failure is swallowed inside `stashCard`: a note about a turn may never
|
|
287
289
|
* cost the turn.
|
|
288
290
|
*/
|
|
@@ -290,7 +292,7 @@ export function createAgentTurnExecution({
|
|
|
290
292
|
stashCard(
|
|
291
293
|
sessionMetaPath(wt, 'flowviant-agent-cards', agentId),
|
|
292
294
|
job.task.id,
|
|
293
|
-
AGENT_TASK_SPEC(job.task)
|
|
295
|
+
AGENT_TASK_SPEC(job.task, job.cardThread)
|
|
294
296
|
);
|
|
295
297
|
}
|
|
296
298
|
|
|
@@ -372,6 +374,9 @@ export function createAgentTurnExecution({
|
|
|
372
374
|
? AGENT_TASK_KICKOFF({
|
|
373
375
|
agentName: job.agentName,
|
|
374
376
|
task: job.task,
|
|
377
|
+
// The card's discussion (0.106.0), printed inside THE CARD by
|
|
378
|
+
// the same builder the stash above wrote down.
|
|
379
|
+
cardThread: job.cardThread,
|
|
375
380
|
position: job.position ?? 1,
|
|
376
381
|
total: job.total ?? 1,
|
|
377
382
|
})
|
|
@@ -380,6 +385,9 @@ export function createAgentTurnExecution({
|
|
|
380
385
|
message: job.body ?? '',
|
|
381
386
|
askedByName: job.askedByName,
|
|
382
387
|
task: job.task,
|
|
388
|
+
// The discussion on the one card this message is about, in a
|
|
389
|
+
// fence of its own after the person's words (0.106.0).
|
|
390
|
+
cardThread: job.cardThread,
|
|
383
391
|
position: job.position ?? 1,
|
|
384
392
|
total: job.total ?? 1,
|
|
385
393
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowviant",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.106.0",
|
|
4
4
|
"description": "Run your own coding CLIs as build agents for Flowviant — Claude Code, Codex or Antigravity, on your own credentials. Holds your sessions, keeps a worktree per tab, and ships branches on your word.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|