@telora/daemon 0.17.8 → 0.17.13
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/build-info.json +5 -3
- package/dist/assembly-engine.d.ts +8 -0
- package/dist/assembly-engine.d.ts.map +1 -1
- package/dist/assembly-engine.js.map +1 -1
- package/dist/focus-engine.js +2 -2
- package/dist/focus-engine.js.map +1 -1
- package/dist/focus-executor.d.ts.map +1 -1
- package/dist/focus-executor.js +27 -0
- package/dist/focus-executor.js.map +1 -1
- package/dist/prd-controller.d.ts +37 -14
- package/dist/prd-controller.d.ts.map +1 -1
- package/dist/prd-controller.js +177 -66
- package/dist/prd-controller.js.map +1 -1
- package/dist/prd-focus-pushdown.d.ts +42 -0
- package/dist/prd-focus-pushdown.d.ts.map +1 -0
- package/dist/prd-focus-pushdown.js +47 -0
- package/dist/prd-focus-pushdown.js.map +1 -0
- package/dist/prd-frontier.d.ts +27 -0
- package/dist/prd-frontier.d.ts.map +1 -0
- package/dist/prd-frontier.js +46 -0
- package/dist/prd-frontier.js.map +1 -0
- package/dist/prd-steward.d.ts +94 -0
- package/dist/prd-steward.d.ts.map +1 -0
- package/dist/prd-steward.js +173 -0
- package/dist/prd-steward.js.map +1 -0
- package/dist/queries/prd.d.ts +48 -0
- package/dist/queries/prd.d.ts.map +1 -1
- package/dist/queries/prd.js +42 -0
- package/dist/queries/prd.js.map +1 -1
- package/dist/resolvers/index.d.ts +2 -0
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +2 -0
- package/dist/resolvers/index.js.map +1 -1
- package/dist/resolvers/prd-context.d.ts +30 -0
- package/dist/resolvers/prd-context.d.ts.map +1 -0
- package/dist/resolvers/prd-context.js +100 -0
- package/dist/resolvers/prd-context.js.map +1 -0
- package/dist/resolvers/prd-persona.d.ts +20 -0
- package/dist/resolvers/prd-persona.d.ts.map +1 -0
- package/dist/resolvers/prd-persona.js +45 -0
- package/dist/resolvers/prd-persona.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRD steward -- the CORTEX of the reflex/cortex PRD control loop.
|
|
3
|
+
*
|
|
4
|
+
* The deterministic prd-controller is the REFLEX: it computes the frontier,
|
|
5
|
+
* clears obstacles, and arms foci. It is fast, safe, and mechanical, and stays
|
|
6
|
+
* exactly as-is. The steward is the CORTEX: a milestone-altitude differential
|
|
7
|
+
* receiver that, on divergence, reads the tree + prd.context + prd.persona,
|
|
8
|
+
* computes milestone variance, and makes the re-capture-or-escalate JUDGMENT
|
|
9
|
+
* the controller would otherwise hardcode in selectSurvivingPath.
|
|
10
|
+
*
|
|
11
|
+
* Like loop-engine, the steward is MONITORING-ONLY: it calls an LLM (no Claude
|
|
12
|
+
* coder process is spawned) and its ONLY outputs are a pathway re-commit, an
|
|
13
|
+
* escalation, or a hold. It NEVER takes over arming/clearance (the reflex), and
|
|
14
|
+
* it NEVER reverts merged work on an abandoned pathway or lowers the goal --
|
|
15
|
+
* when no pathway survives it hands control up to the human (escalate).
|
|
16
|
+
*
|
|
17
|
+
* Activated under PRD Play (prds.assigned_agent_role_id): a Played PRD runs its
|
|
18
|
+
* milestone with the steward as cortex and the controller as reflexes. With no
|
|
19
|
+
* steward wired (or the LLM unavailable), runStewardJudgment returns null and
|
|
20
|
+
* the controller falls back to the deterministic reflex unchanged.
|
|
21
|
+
*/
|
|
22
|
+
import type { Prd, PrtNode, PrtEdge } from './queries/prd.js';
|
|
23
|
+
import type { DivergenceSignal, PathwayState } from './prd-divergence.js';
|
|
24
|
+
import type { DaemonConfig } from './types.js';
|
|
25
|
+
/** The judgment the steward returns to the controller. */
|
|
26
|
+
export interface StewardDecision {
|
|
27
|
+
/**
|
|
28
|
+
* recommit -> re-point the committed pathway to `pathwayId` (PLL re-capture).
|
|
29
|
+
* escalate -> hand control to the human (no surviving path / out of bounds).
|
|
30
|
+
* hold -> the milestone still tracks intent; take no action this tick.
|
|
31
|
+
*/
|
|
32
|
+
action: 'recommit' | 'escalate' | 'hold';
|
|
33
|
+
/** The pathway to re-commit to (recommit only). */
|
|
34
|
+
pathwayId?: string | null;
|
|
35
|
+
/** The steward's reasoning -- surfaced on escalations / path switches. */
|
|
36
|
+
rationale: string;
|
|
37
|
+
}
|
|
38
|
+
export interface StewardJudgmentInput {
|
|
39
|
+
prd: Prd;
|
|
40
|
+
nodes: PrtNode[];
|
|
41
|
+
edges: PrtEdge[];
|
|
42
|
+
signals: DivergenceSignal[];
|
|
43
|
+
pathwayStates: PathwayState[];
|
|
44
|
+
/** Deterministic viability oracle (from the controller) the cortex is informed by. */
|
|
45
|
+
isPathwayViable: (pathwayId: string) => boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface StewardDeps {
|
|
48
|
+
/** Resolve the PRD's milestone framing: prd.persona (system) + prd.context (user). */
|
|
49
|
+
resolveMilestoneFraming: (prd: Prd) => Promise<{
|
|
50
|
+
persona: string;
|
|
51
|
+
context: string;
|
|
52
|
+
}>;
|
|
53
|
+
/** Call the judgment LLM; raw text response, or null when unavailable. */
|
|
54
|
+
callLLM: (prompt: {
|
|
55
|
+
system: string;
|
|
56
|
+
user: string;
|
|
57
|
+
}) => Promise<string | null>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parse a StewardDecision out of the LLM's raw text. Lenient: extracts the
|
|
61
|
+
* first JSON object in the text (the model may wrap it in prose) and validates
|
|
62
|
+
* the action enum. Returns null when no valid decision can be parsed -- the
|
|
63
|
+
* caller treats null as "cortex unavailable" and falls back to the reflex.
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseStewardDecision(raw: string | null): StewardDecision | null;
|
|
66
|
+
/** Build the steward judgment prompt: persona framing (system) + the milestone
|
|
67
|
+
* state, divergence signals, and pathway options (user). */
|
|
68
|
+
export declare function buildStewardPrompt(framing: {
|
|
69
|
+
persona: string;
|
|
70
|
+
context: string;
|
|
71
|
+
}, input: StewardJudgmentInput): {
|
|
72
|
+
system: string;
|
|
73
|
+
user: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Run the steward's judgment for a diverged, committed PRD. Returns the decision
|
|
77
|
+
* the controller should enact, or null to fall back to the deterministic reflex.
|
|
78
|
+
*
|
|
79
|
+
* Safety rails enforced here (so the controller can trust the decision):
|
|
80
|
+
* - A `recommit` is honored ONLY if the target pathway exists, is not the
|
|
81
|
+
* already-committed path, and passes the deterministic viability oracle.
|
|
82
|
+
* An LLM that picks an unknown or non-viable pathway is converted to an
|
|
83
|
+
* `escalate` -- we never commit to a dead path or improvise the goal.
|
|
84
|
+
* - LLM/parse failure -> null (reflex fallback), never a silent bad action.
|
|
85
|
+
*/
|
|
86
|
+
export declare function runStewardJudgment(input: StewardJudgmentInput, deps: StewardDeps): Promise<StewardDecision | null>;
|
|
87
|
+
/**
|
|
88
|
+
* Default steward deps wired to the live assembly engine + LLM client. The
|
|
89
|
+
* resolver registration and LLM client are dynamically imported so this heavy
|
|
90
|
+
* graph is only pulled in when the steward actually runs (a Played PRD that
|
|
91
|
+
* diverged) -- runStewardJudgment's pure core stays light for tests.
|
|
92
|
+
*/
|
|
93
|
+
export declare function defaultStewardDeps(config: DaemonConfig): StewardDeps;
|
|
94
|
+
//# sourceMappingURL=prd-steward.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prd-steward.d.ts","sourceRoot":"","sources":["../src/prd-steward.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,0DAA0D;AAC1D,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,MAAM,EAAE,UAAU,GAAG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,GAAG,IAAI,CAAC,CA8BjC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CA0BpE"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRD steward -- the CORTEX of the reflex/cortex PRD control loop.
|
|
3
|
+
*
|
|
4
|
+
* The deterministic prd-controller is the REFLEX: it computes the frontier,
|
|
5
|
+
* clears obstacles, and arms foci. It is fast, safe, and mechanical, and stays
|
|
6
|
+
* exactly as-is. The steward is the CORTEX: a milestone-altitude differential
|
|
7
|
+
* receiver that, on divergence, reads the tree + prd.context + prd.persona,
|
|
8
|
+
* computes milestone variance, and makes the re-capture-or-escalate JUDGMENT
|
|
9
|
+
* the controller would otherwise hardcode in selectSurvivingPath.
|
|
10
|
+
*
|
|
11
|
+
* Like loop-engine, the steward is MONITORING-ONLY: it calls an LLM (no Claude
|
|
12
|
+
* coder process is spawned) and its ONLY outputs are a pathway re-commit, an
|
|
13
|
+
* escalation, or a hold. It NEVER takes over arming/clearance (the reflex), and
|
|
14
|
+
* it NEVER reverts merged work on an abandoned pathway or lowers the goal --
|
|
15
|
+
* when no pathway survives it hands control up to the human (escalate).
|
|
16
|
+
*
|
|
17
|
+
* Activated under PRD Play (prds.assigned_agent_role_id): a Played PRD runs its
|
|
18
|
+
* milestone with the steward as cortex and the controller as reflexes. With no
|
|
19
|
+
* steward wired (or the LLM unavailable), runStewardJudgment returns null and
|
|
20
|
+
* the controller falls back to the deterministic reflex unchanged.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Parse a StewardDecision out of the LLM's raw text. Lenient: extracts the
|
|
24
|
+
* first JSON object in the text (the model may wrap it in prose) and validates
|
|
25
|
+
* the action enum. Returns null when no valid decision can be parsed -- the
|
|
26
|
+
* caller treats null as "cortex unavailable" and falls back to the reflex.
|
|
27
|
+
*/
|
|
28
|
+
export function parseStewardDecision(raw) {
|
|
29
|
+
if (!raw)
|
|
30
|
+
return null;
|
|
31
|
+
const start = raw.indexOf('{');
|
|
32
|
+
const end = raw.lastIndexOf('}');
|
|
33
|
+
if (start === -1 || end === -1 || end <= start)
|
|
34
|
+
return null;
|
|
35
|
+
let parsed;
|
|
36
|
+
try {
|
|
37
|
+
parsed = JSON.parse(raw.slice(start, end + 1));
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (!parsed || typeof parsed !== 'object')
|
|
43
|
+
return null;
|
|
44
|
+
const obj = parsed;
|
|
45
|
+
const action = obj.action;
|
|
46
|
+
if (action !== 'recommit' && action !== 'escalate' && action !== 'hold') {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
action,
|
|
51
|
+
pathwayId: typeof obj.pathwayId === 'string' ? obj.pathwayId : null,
|
|
52
|
+
rationale: typeof obj.rationale === 'string' ? obj.rationale : '',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Build the steward judgment prompt: persona framing (system) + the milestone
|
|
56
|
+
* state, divergence signals, and pathway options (user). */
|
|
57
|
+
export function buildStewardPrompt(framing, input) {
|
|
58
|
+
const { signals, pathwayStates, prd, isPathwayViable } = input;
|
|
59
|
+
const protocol = [
|
|
60
|
+
'',
|
|
61
|
+
'---',
|
|
62
|
+
'',
|
|
63
|
+
'You are judging whether this milestone still tracks its committed intent after a divergence.',
|
|
64
|
+
'Decide ONE action and return it as a single JSON object (no prose around it):',
|
|
65
|
+
' {"action":"recommit","pathwayId":"<id>","rationale":"..."} -- re-acquire a viable surviving pathway',
|
|
66
|
+
' {"action":"escalate","rationale":"..."} -- no pathway can still reach the goal; hand up',
|
|
67
|
+
' {"action":"hold","rationale":"..."} -- the milestone still tracks; take no action',
|
|
68
|
+
'',
|
|
69
|
+
'Rules (asymmetry -- non-negotiable):',
|
|
70
|
+
'- NEVER lower or redefine the goal to make the signal look better.',
|
|
71
|
+
'- NEVER revert work already merged on an abandoned pathway -- that reality is the new fact.',
|
|
72
|
+
'- Prefer re-acquiring a VIABLE surviving pathway over forcing the original.',
|
|
73
|
+
'- Only recommit to a pathway listed as viable below. If none is viable, escalate.',
|
|
74
|
+
].join('\n');
|
|
75
|
+
const system = `${framing.persona}${protocol}`;
|
|
76
|
+
const signalLines = signals.length
|
|
77
|
+
? signals.map((s) => `- [${s.form}] node ${s.nodeId}: ${s.detail}`).join('\n')
|
|
78
|
+
: '- (none)';
|
|
79
|
+
const pathwayLines = pathwayStates.length
|
|
80
|
+
? pathwayStates
|
|
81
|
+
.map((p) => `- ${p.id} (status: ${p.status}${p.id === prd.committedPathId ? ', COMMITTED' : ''}) -- ` +
|
|
82
|
+
`${isPathwayViable(p.id) ? 'viable' : 'NOT viable'}`)
|
|
83
|
+
.join('\n')
|
|
84
|
+
: '- (none held)';
|
|
85
|
+
const user = [
|
|
86
|
+
framing.context || '## PRD Milestone Context\n\n(context unavailable)',
|
|
87
|
+
'',
|
|
88
|
+
'## Divergence Signals',
|
|
89
|
+
'',
|
|
90
|
+
signalLines,
|
|
91
|
+
'',
|
|
92
|
+
'## Pathways',
|
|
93
|
+
'',
|
|
94
|
+
pathwayLines,
|
|
95
|
+
'',
|
|
96
|
+
`Committed pathway: ${prd.committedPathId ?? '(none)'}`,
|
|
97
|
+
].join('\n');
|
|
98
|
+
return { system, user };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Run the steward's judgment for a diverged, committed PRD. Returns the decision
|
|
102
|
+
* the controller should enact, or null to fall back to the deterministic reflex.
|
|
103
|
+
*
|
|
104
|
+
* Safety rails enforced here (so the controller can trust the decision):
|
|
105
|
+
* - A `recommit` is honored ONLY if the target pathway exists, is not the
|
|
106
|
+
* already-committed path, and passes the deterministic viability oracle.
|
|
107
|
+
* An LLM that picks an unknown or non-viable pathway is converted to an
|
|
108
|
+
* `escalate` -- we never commit to a dead path or improvise the goal.
|
|
109
|
+
* - LLM/parse failure -> null (reflex fallback), never a silent bad action.
|
|
110
|
+
*/
|
|
111
|
+
export async function runStewardJudgment(input, deps) {
|
|
112
|
+
let framing;
|
|
113
|
+
try {
|
|
114
|
+
framing = await deps.resolveMilestoneFraming(input.prd);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const prompt = buildStewardPrompt(framing, input);
|
|
120
|
+
const raw = await deps.callLLM(prompt);
|
|
121
|
+
const decision = parseStewardDecision(raw);
|
|
122
|
+
if (!decision)
|
|
123
|
+
return null;
|
|
124
|
+
if (decision.action === 'recommit') {
|
|
125
|
+
const target = decision.pathwayId;
|
|
126
|
+
const known = target ? input.pathwayStates.some((p) => p.id === target) : false;
|
|
127
|
+
const isCurrent = target === input.prd.committedPathId;
|
|
128
|
+
if (!target || !known || isCurrent || !input.isPathwayViable(target)) {
|
|
129
|
+
// The cortex chose an unknown / current / non-viable path. Asymmetry:
|
|
130
|
+
// never commit to a dead path -- hand control up instead.
|
|
131
|
+
return {
|
|
132
|
+
action: 'escalate',
|
|
133
|
+
rationale: `Steward proposed recommit to ${target ?? '(none)'} which is not a viable surviving pathway; ` +
|
|
134
|
+
`escalating rather than committing to a dead path. ${decision.rationale}`.trim(),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return decision;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Default steward deps wired to the live assembly engine + LLM client. The
|
|
142
|
+
* resolver registration and LLM client are dynamically imported so this heavy
|
|
143
|
+
* graph is only pulled in when the steward actually runs (a Played PRD that
|
|
144
|
+
* diverged) -- runStewardJudgment's pure core stays light for tests.
|
|
145
|
+
*/
|
|
146
|
+
export function defaultStewardDeps(config) {
|
|
147
|
+
return {
|
|
148
|
+
resolveMilestoneFraming: async (prd) => {
|
|
149
|
+
// Register resolvers (side effect) then resolve persona + context.
|
|
150
|
+
await import('./assembly-resolvers.js');
|
|
151
|
+
const { resolveAssemblyRecipe } = await import('./assembly-engine.js');
|
|
152
|
+
const ctx = {
|
|
153
|
+
focusId: '',
|
|
154
|
+
deliveryIds: [],
|
|
155
|
+
worktreePath: null,
|
|
156
|
+
config,
|
|
157
|
+
organizationId: config.organizationId,
|
|
158
|
+
productId: prd.productId,
|
|
159
|
+
prdId: prd.id,
|
|
160
|
+
};
|
|
161
|
+
const [persona, context] = await Promise.all([
|
|
162
|
+
resolveAssemblyRecipe(['prd.persona'], ctx),
|
|
163
|
+
resolveAssemblyRecipe(['prd.context'], ctx),
|
|
164
|
+
]);
|
|
165
|
+
return { persona, context };
|
|
166
|
+
},
|
|
167
|
+
callLLM: async (prompt) => {
|
|
168
|
+
const { callLoopLLM } = await import('./loop-llm-client.js');
|
|
169
|
+
return callLoopLLM(config.organizationId, prompt, null, 'prd_steward');
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=prd-steward.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prd-steward.js","sourceRoot":"","sources":["../src/prd-steward.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAqCH;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAkB;IACrD,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,GAAG,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IAC5D,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IA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YAAY,EAAE,IAAI;gBAClB,MAAM;gBACN,cAAc,EAAE,MAAM,CAAC,cAAc;gBACrC,SAAS,EAAE,GAAG,CAAC,SAAS;gBACxB,KAAK,EAAE,GAAG,CAAC,EAAE;aACd,CAAC;YACF,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBAC3C,qBAAqB,CAAC,CAAC,aAAa,CAAC,EAAE,GAAG,CAAC;gBAC3C,qBAAqB,CAAC,CAAC,aAAa,CAAC,EAAE,GAAG,CAAC;aAC5C,CAAC,CAAC;YACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACxB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;YAC7D,OAAO,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QACzE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/queries/prd.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface PrtNode {
|
|
|
18
18
|
status: 'open' | 'cleared';
|
|
19
19
|
clearancePredicate: ClearancePredicate | null;
|
|
20
20
|
focusId: string | null;
|
|
21
|
+
/** The node assertion text (goal/obstacle/overcome statement). May be ''. */
|
|
22
|
+
statement: string;
|
|
21
23
|
}
|
|
22
24
|
export interface PrtEdge {
|
|
23
25
|
id: string;
|
|
@@ -32,6 +34,13 @@ export interface Prd {
|
|
|
32
34
|
title: string;
|
|
33
35
|
/** The pathway currently committed (locked) for this PRD, or null if none. */
|
|
34
36
|
committedPathId: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* The PRD "Play": the agent role the controller arms frontier foci with, or
|
|
39
|
+
* null if the PRD is paused (mirrors product_focuses.assigned_agent_role_id).
|
|
40
|
+
* Set = run all frontier foci; null = no foci arm. This is the per-entity
|
|
41
|
+
* signal that replaced the global TELORA_PRD_ARM_ROLE_ID env var.
|
|
42
|
+
*/
|
|
43
|
+
assignedAgentRoleId: string | null;
|
|
35
44
|
}
|
|
36
45
|
/** A held alternative pathway under a PRD (option / committed / abandoned). */
|
|
37
46
|
export interface Pathway {
|
|
@@ -76,4 +85,43 @@ export declare function loadPathways(prdId: string): Promise<Pathway[]>;
|
|
|
76
85
|
* NO revert: this never undoes work already done on a prior pathway.
|
|
77
86
|
*/
|
|
78
87
|
export declare function commitPathway(prdId: string, pathwayId: string): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Resolve the PRD a focus belongs to, if any. A focus materialized from a PRD
|
|
90
|
+
* overcome node carries back-reference data the controller exposes via
|
|
91
|
+
* prd_context_for_focus (items: { focusId, prd: { id, title }, overcome }).
|
|
92
|
+
* Returns the parent PRD id, or null when the focus was not materialized by a
|
|
93
|
+
* PRD (an ordinary focus). Used to decide whether to push milestone context
|
|
94
|
+
* into a spawned focus team.
|
|
95
|
+
*/
|
|
96
|
+
export declare function findPrdIdForFocus(focusId: string): Promise<string | null>;
|
|
97
|
+
/**
|
|
98
|
+
* The milestone-context view of a PRD: the narrow controller-facing `Prd`
|
|
99
|
+
* fields PLUS the rich milestone-intent fields (goal / expansion / vision
|
|
100
|
+
* snapshot) that the prd.context assembly resolver renders into a focus/steward
|
|
101
|
+
* prompt. Kept separate from `Prd` so the hot controller path stays lean.
|
|
102
|
+
*/
|
|
103
|
+
export interface PrdDetail {
|
|
104
|
+
id: string;
|
|
105
|
+
productId: string;
|
|
106
|
+
status: string;
|
|
107
|
+
title: string;
|
|
108
|
+
goal: string | null;
|
|
109
|
+
expansion: string | null;
|
|
110
|
+
visionSnapshot: string | null;
|
|
111
|
+
committedPathId: string | null;
|
|
112
|
+
assignedAgentRoleId: string | null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Load a PRD's full milestone-context bundle: the rich PRD fields plus its PRT
|
|
116
|
+
* nodes, edges, and pathways, in one prd_get call. Feeds the prd.context
|
|
117
|
+
* resolver (milestone facts + frontier state). prd_get returns
|
|
118
|
+
* { prd: { ...prd, nodes, edges, pathways } } -- transformPrd already camelCases
|
|
119
|
+
* goal/expansion/visionSnapshot, so we re-shape into the narrow detail type.
|
|
120
|
+
*/
|
|
121
|
+
export declare function loadPrdDetail(prdId: string): Promise<{
|
|
122
|
+
prd: PrdDetail;
|
|
123
|
+
nodes: PrtNode[];
|
|
124
|
+
edges: PrtEdge[];
|
|
125
|
+
pathways: Pathway[];
|
|
126
|
+
}>;
|
|
79
127
|
//# sourceMappingURL=prd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prd.d.ts","sourceRoot":"","sources":["../../src/queries/prd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;IAC3C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"prd.d.ts","sourceRoot":"","sources":["../../src/queries/prd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;IAC3C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,GAAG,IAAI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title: row.title,
|
|
20
20
|
committedPathId: row.committedPathId ?? null,
|
|
21
|
+
assignedAgentRoleId: row.assignedAgentRoleId ?? null,
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
function mapPathway(row) {
|
|
@@ -36,6 +37,7 @@ function mapNode(row) {
|
|
|
36
37
|
status: row.status,
|
|
37
38
|
clearancePredicate: row.clearancePredicate ?? null,
|
|
38
39
|
focusId: row.focusId ?? null,
|
|
40
|
+
statement: row.statement ?? '',
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
function mapEdge(row) {
|
|
@@ -113,4 +115,44 @@ export async function loadPathways(prdId) {
|
|
|
113
115
|
export async function commitPathway(prdId, pathwayId) {
|
|
114
116
|
await callApi('prd_pathway_commit', { prdId, pathwayId });
|
|
115
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Resolve the PRD a focus belongs to, if any. A focus materialized from a PRD
|
|
120
|
+
* overcome node carries back-reference data the controller exposes via
|
|
121
|
+
* prd_context_for_focus (items: { focusId, prd: { id, title }, overcome }).
|
|
122
|
+
* Returns the parent PRD id, or null when the focus was not materialized by a
|
|
123
|
+
* PRD (an ordinary focus). Used to decide whether to push milestone context
|
|
124
|
+
* into a spawned focus team.
|
|
125
|
+
*/
|
|
126
|
+
export async function findPrdIdForFocus(focusId) {
|
|
127
|
+
const body = await callApi('prd_context_for_focus', { focusIds: [focusId] });
|
|
128
|
+
const match = (body.items ?? []).find((i) => i.focusId === focusId && i.prd?.id);
|
|
129
|
+
return match?.prd?.id ?? null;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Load a PRD's full milestone-context bundle: the rich PRD fields plus its PRT
|
|
133
|
+
* nodes, edges, and pathways, in one prd_get call. Feeds the prd.context
|
|
134
|
+
* resolver (milestone facts + frontier state). prd_get returns
|
|
135
|
+
* { prd: { ...prd, nodes, edges, pathways } } -- transformPrd already camelCases
|
|
136
|
+
* goal/expansion/visionSnapshot, so we re-shape into the narrow detail type.
|
|
137
|
+
*/
|
|
138
|
+
export async function loadPrdDetail(prdId) {
|
|
139
|
+
const body = await callApi('prd_get', { prdId });
|
|
140
|
+
const row = body.prd;
|
|
141
|
+
return {
|
|
142
|
+
prd: {
|
|
143
|
+
id: row.id,
|
|
144
|
+
productId: row.productId,
|
|
145
|
+
status: row.status,
|
|
146
|
+
title: row.title,
|
|
147
|
+
goal: row.goal ?? null,
|
|
148
|
+
expansion: row.expansion ?? null,
|
|
149
|
+
visionSnapshot: row.visionSnapshot ?? null,
|
|
150
|
+
committedPathId: row.committedPathId ?? null,
|
|
151
|
+
assignedAgentRoleId: row.assignedAgentRoleId ?? null,
|
|
152
|
+
},
|
|
153
|
+
nodes: (row.nodes ?? []).map(mapNode),
|
|
154
|
+
edges: (row.edges ?? []).map(mapEdge),
|
|
155
|
+
pathways: (row.pathways ?? []).map(mapPathway),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
116
158
|
//# sourceMappingURL=prd.js.map
|
package/dist/queries/prd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prd.js","sourceRoot":"","sources":["../../src/queries/prd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"prd.js","sourceRoot":"","sources":["../../src/queries/prd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAgFtC,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,eAAe,EAAE,GAAG,CAAC,eAAe,IAAI,IAAI;QAC5C,mBAAmB,EAAE,GAAG,CAAC,mBAAmB,IAAI,IAAI;KACrD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;YACtB,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,IAAI;YAChC,cAAc,EAAE,GAAG,CAAC,cAAc,IAAI,IAAI;YAC1C,eAAe,EAAE,GAAG,CAAC,eAAe,IAAI,IAAI;YAC5C,mBAAmB,EAAE,GAAG,CAAC,mBAAmB,IAAI,IAAI;SACrD;QACD,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;QACrC,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;QACrC,QAAQ,EAAE,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -44,6 +44,8 @@ import './retired-injections.js';
|
|
|
44
44
|
import './agent-session-summaries.js';
|
|
45
45
|
import './agent-escalations.js';
|
|
46
46
|
import './reality-tree-snapshot.js';
|
|
47
|
+
import './prd-persona.js';
|
|
48
|
+
import './prd-context.js';
|
|
47
49
|
export { MAX_DIFF_BYTES, getGitDiff } from './shared/git-diff.js';
|
|
48
50
|
export { CRT_DUMP_BUDGET_CHARS, renderRealityTreeDump, FOCUS_REALITY_TREE_EMPTY_STATE, } from './shared/reality-tree.js';
|
|
49
51
|
export type { RealityTreeRow, RealityTreeListResponse, RealityNodeRow, RealityEdgeRow, NodeListResponse, EdgeListResponse, } from './shared/reality-tree.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resolvers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,mCAAmC,CAAC;AAC3C,OAAO,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,+BAA+B,CAAC;AACvC,OAAO,wBAAwB,CAAC;AAChC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C;AAC9B,OAAO,iCAAiC,CAAC;AACzC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0BAA0B,CAAC;AAClC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC,OAAO,0BAA0B,CAAC;AAClC,OAAO,yBAAyB,CAAC;AACjC,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAChC,OAAO,4BAA4B,CAAC;AACpC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,kBAAkB,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC"}
|
package/dist/resolvers/index.js
CHANGED
|
@@ -45,6 +45,8 @@ import './retired-injections.js';
|
|
|
45
45
|
import './agent-session-summaries.js';
|
|
46
46
|
import './agent-escalations.js';
|
|
47
47
|
import './reality-tree-snapshot.js';
|
|
48
|
+
import './prd-persona.js';
|
|
49
|
+
import './prd-context.js';
|
|
48
50
|
// ── Shared public surface (re-exports for external consumers) ─────────
|
|
49
51
|
export { MAX_DIFF_BYTES, getGitDiff } from './shared/git-diff.js';
|
|
50
52
|
export { CRT_DUMP_BUDGET_CHARS, renderRealityTreeDump, FOCUS_REALITY_TREE_EMPTY_STATE, } from './shared/reality-tree.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resolvers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,wEAAwE;AACxE,OAAO,mCAAmC,CAAC;AAC3C,OAAO,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,+BAA+B,CAAC;AACvC,OAAO,wBAAwB,CAAC;AAChC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,iBAAiB,CAAC;AACzB,OAAO,4BAA4B,CAAC;AACpC,OAAO,gCAAgC,CAAC;AACxC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,iCAAiC,CAAC;AACzC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0BAA0B,CAAC;AAClC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC,OAAO,0BAA0B,CAAC;AAClC,OAAO,yBAAyB,CAAC;AACjC,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAChC,OAAO,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resolvers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,wEAAwE;AACxE,OAAO,mCAAmC,CAAC;AAC3C,OAAO,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,+BAA+B,CAAC;AACvC,OAAO,wBAAwB,CAAC;AAChC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,iBAAiB,CAAC;AACzB,OAAO,4BAA4B,CAAC;AACpC,OAAO,gCAAgC,CAAC;AACxC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,iCAAiC,CAAC;AACzC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0BAA0B,CAAC;AAClC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AACjC,OAAO,0BAA0B,CAAC;AAClC,OAAO,yBAAyB,CAAC;AACjC,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAChC,OAAO,4BAA4B,CAAC;AACpC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,kBAAkB,CAAC;AAE1B,yEAAyE;AACzE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type PrdDetail, type PrtNode, type PrtEdge, type Pathway } from '../queries/prd.js';
|
|
2
|
+
/**
|
|
3
|
+
* prd.context
|
|
4
|
+
*
|
|
5
|
+
* The milestone facts an entity under a PRD needs: the goal + AI expansion +
|
|
6
|
+
* vision snapshot, plus the LIVE frontier state (cleared obstacles, the overcome
|
|
7
|
+
* currently arming, the committed pathway position). Pushed down to every armed
|
|
8
|
+
* focus team (so each focus inherits coherent milestone intent instead of
|
|
9
|
+
* rediscovering it from its own deliveries) and read by the PRD steward.
|
|
10
|
+
*
|
|
11
|
+
* The PRD is identified by params.prdId or context.prdId; with neither, this is
|
|
12
|
+
* a no-op (empty string) so the resolver is safe in any non-PRD assembly.
|
|
13
|
+
*
|
|
14
|
+
* Token-budgeted like the other large resolvers: the expansion (which can be
|
|
15
|
+
* very large) and vision snapshot are truncated to fit the section budget.
|
|
16
|
+
*/
|
|
17
|
+
/** Per-section budget, matching the wiki/diff resolver budgets (~10k chars). */
|
|
18
|
+
export declare const PRD_CONTEXT_BUDGET_CHARS = 10000;
|
|
19
|
+
/**
|
|
20
|
+
* Render the milestone context markdown from already-loaded PRD detail + tree.
|
|
21
|
+
* Pure: no I/O, so the frontier computation and budgeting are unit-testable
|
|
22
|
+
* directly with injected fixtures.
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderPrdMilestoneContext(input: {
|
|
25
|
+
prd: PrdDetail;
|
|
26
|
+
nodes: PrtNode[];
|
|
27
|
+
edges: PrtEdge[];
|
|
28
|
+
pathways: Pathway[];
|
|
29
|
+
}): string;
|
|
30
|
+
//# sourceMappingURL=prd-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prd-context.d.ts","sourceRoot":"","sources":["../../src/resolvers/prd-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5G;;;;;;;;;;;;;;GAcG;AAEH,gFAAgF;AAChF,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAW/C;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,GAAG,EAAE,SAAS,CAAC;IACf,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,GAAG,MAAM,CAuET"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { registerSourceResolver } from '../assembly-engine.js';
|
|
2
|
+
import { loadPrdDetail } from '../queries/prd.js';
|
|
3
|
+
import { computePrtFrontier } from '../prd-frontier.js';
|
|
4
|
+
/**
|
|
5
|
+
* prd.context
|
|
6
|
+
*
|
|
7
|
+
* The milestone facts an entity under a PRD needs: the goal + AI expansion +
|
|
8
|
+
* vision snapshot, plus the LIVE frontier state (cleared obstacles, the overcome
|
|
9
|
+
* currently arming, the committed pathway position). Pushed down to every armed
|
|
10
|
+
* focus team (so each focus inherits coherent milestone intent instead of
|
|
11
|
+
* rediscovering it from its own deliveries) and read by the PRD steward.
|
|
12
|
+
*
|
|
13
|
+
* The PRD is identified by params.prdId or context.prdId; with neither, this is
|
|
14
|
+
* a no-op (empty string) so the resolver is safe in any non-PRD assembly.
|
|
15
|
+
*
|
|
16
|
+
* Token-budgeted like the other large resolvers: the expansion (which can be
|
|
17
|
+
* very large) and vision snapshot are truncated to fit the section budget.
|
|
18
|
+
*/
|
|
19
|
+
/** Per-section budget, matching the wiki/diff resolver budgets (~10k chars). */
|
|
20
|
+
export const PRD_CONTEXT_BUDGET_CHARS = 10_000;
|
|
21
|
+
const GOAL_BUDGET_CHARS = 2_000;
|
|
22
|
+
const VISION_BUDGET_CHARS = 2_000;
|
|
23
|
+
const EXPANSION_BUDGET_CHARS = 5_000;
|
|
24
|
+
function truncate(text, max) {
|
|
25
|
+
const t = text.trim();
|
|
26
|
+
if (t.length <= max)
|
|
27
|
+
return t;
|
|
28
|
+
return `${t.slice(0, max).trimEnd()}\n...[truncated]`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Render the milestone context markdown from already-loaded PRD detail + tree.
|
|
32
|
+
* Pure: no I/O, so the frontier computation and budgeting are unit-testable
|
|
33
|
+
* directly with injected fixtures.
|
|
34
|
+
*/
|
|
35
|
+
export function renderPrdMilestoneContext(input) {
|
|
36
|
+
const { prd, nodes, edges, pathways } = input;
|
|
37
|
+
const parts = [];
|
|
38
|
+
parts.push(`## PRD Milestone Context`);
|
|
39
|
+
parts.push(`**Milestone:** ${prd.title || '(untitled)'} (status: ${prd.status})`);
|
|
40
|
+
if (prd.goal && prd.goal.trim()) {
|
|
41
|
+
parts.push(`### Goal\n\n${truncate(prd.goal, GOAL_BUDGET_CHARS)}`);
|
|
42
|
+
}
|
|
43
|
+
if (prd.visionSnapshot && prd.visionSnapshot.trim()) {
|
|
44
|
+
parts.push(`### Vision\n\n${truncate(prd.visionSnapshot, VISION_BUDGET_CHARS)}`);
|
|
45
|
+
}
|
|
46
|
+
if (prd.expansion && prd.expansion.trim()) {
|
|
47
|
+
parts.push(`### Expansion (the realized product)\n\n${truncate(prd.expansion, EXPANSION_BUDGET_CHARS)}`);
|
|
48
|
+
}
|
|
49
|
+
// --- Frontier state -------------------------------------------------------
|
|
50
|
+
// Cleared node ids come straight off the persisted node status (the controller
|
|
51
|
+
// marks obstacles/overcomes cleared as the milestone advances); the frontier
|
|
52
|
+
// (overcomes ready to arm/materialize) is computed from that exactly as the
|
|
53
|
+
// controller does, so the prompt shows the same frontier the controller acts on.
|
|
54
|
+
const clearedNodeIds = new Set(nodes.filter((n) => n.status === 'cleared').map((n) => n.id));
|
|
55
|
+
const { needsMaterialize, needsArm } = computePrtFrontier(nodes, edges, clearedNodeIds);
|
|
56
|
+
const frontierLines = [];
|
|
57
|
+
const clearedObstacles = nodes.filter((n) => n.nodeType === 'obstacle' && clearedNodeIds.has(n.id));
|
|
58
|
+
const openObstacles = nodes.filter((n) => n.nodeType === 'obstacle' && !clearedNodeIds.has(n.id));
|
|
59
|
+
frontierLines.push(`- Obstacles: ${clearedObstacles.length} cleared, ${openObstacles.length} open`);
|
|
60
|
+
if (clearedObstacles.length > 0) {
|
|
61
|
+
frontierLines.push(`- Cleared:\n${clearedObstacles.map((n) => ` - ${n.statement || n.id}`).join('\n')}`);
|
|
62
|
+
}
|
|
63
|
+
const armingOvercomes = [...needsArm, ...needsMaterialize];
|
|
64
|
+
if (armingOvercomes.length > 0) {
|
|
65
|
+
frontierLines.push(`- Arming overcome(s) (the live frontier):\n${armingOvercomes
|
|
66
|
+
.map((n) => ` - ${n.statement || n.id}`)
|
|
67
|
+
.join('\n')}`);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
frontierLines.push(`- Arming overcome(s): none ready (frontier blocked or milestone complete)`);
|
|
71
|
+
}
|
|
72
|
+
const committed = pathways.find((p) => p.id === prd.committedPathId) ??
|
|
73
|
+
pathways.find((p) => p.status === 'committed') ??
|
|
74
|
+
null;
|
|
75
|
+
if (committed) {
|
|
76
|
+
frontierLines.push(`- Committed pathway: ${committed.name}`);
|
|
77
|
+
}
|
|
78
|
+
else if (pathways.length > 0) {
|
|
79
|
+
frontierLines.push(`- Committed pathway: none committed (${pathways.length} option(s) held)`);
|
|
80
|
+
}
|
|
81
|
+
parts.push(`### Frontier\n\n${frontierLines.join('\n')}`);
|
|
82
|
+
const composed = parts.join('\n\n');
|
|
83
|
+
return composed.length > PRD_CONTEXT_BUDGET_CHARS
|
|
84
|
+
? `${composed.slice(0, PRD_CONTEXT_BUDGET_CHARS).trimEnd()}\n...[truncated]`
|
|
85
|
+
: composed;
|
|
86
|
+
}
|
|
87
|
+
registerSourceResolver('prd.context', async (context, params) => {
|
|
88
|
+
const prdId = params.prdId || context.prdId;
|
|
89
|
+
if (!prdId)
|
|
90
|
+
return '';
|
|
91
|
+
try {
|
|
92
|
+
const { prd, nodes, edges, pathways } = await loadPrdDetail(prdId);
|
|
93
|
+
return renderPrdMilestoneContext({ prd, nodes, edges, pathways });
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
console.warn(`[assembly-engine] prd.context: failed: ${err.message}`);
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
//# sour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