@alex.botez/elaborate 1.0.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/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/durable/index.d.ts +10 -0
- package/dist/durable/index.d.ts.map +1 -0
- package/dist/durable/index.js +9 -0
- package/dist/durable/index.js.map +1 -0
- package/dist/durable/workflow.d.ts +165 -0
- package/dist/durable/workflow.d.ts.map +1 -0
- package/dist/durable/workflow.js +224 -0
- package/dist/durable/workflow.js.map +1 -0
- package/dist/interview/classification.d.ts +16 -0
- package/dist/interview/classification.d.ts.map +1 -0
- package/dist/interview/classification.js +25 -0
- package/dist/interview/classification.js.map +1 -0
- package/dist/interview/composition.d.ts +12 -0
- package/dist/interview/composition.d.ts.map +1 -0
- package/dist/interview/composition.js +19 -0
- package/dist/interview/composition.js.map +1 -0
- package/dist/interview/describe.d.ts +41 -0
- package/dist/interview/describe.d.ts.map +1 -0
- package/dist/interview/describe.js +80 -0
- package/dist/interview/describe.js.map +1 -0
- package/dist/interview/deviation.d.ts +91 -0
- package/dist/interview/deviation.d.ts.map +1 -0
- package/dist/interview/deviation.js +137 -0
- package/dist/interview/deviation.js.map +1 -0
- package/dist/interview/extraction.d.ts +32 -0
- package/dist/interview/extraction.d.ts.map +1 -0
- package/dist/interview/extraction.js +102 -0
- package/dist/interview/extraction.js.map +1 -0
- package/dist/interview/index.d.ts +25 -0
- package/dist/interview/index.d.ts.map +1 -0
- package/dist/interview/index.js +22 -0
- package/dist/interview/index.js.map +1 -0
- package/dist/interview/macros.d.ts +91 -0
- package/dist/interview/macros.d.ts.map +1 -0
- package/dist/interview/macros.js +138 -0
- package/dist/interview/macros.js.map +1 -0
- package/dist/interview/preambles.d.ts +18 -0
- package/dist/interview/preambles.d.ts.map +1 -0
- package/dist/interview/preambles.js +93 -0
- package/dist/interview/preambles.js.map +1 -0
- package/dist/interview/progress.d.ts +31 -0
- package/dist/interview/progress.d.ts.map +1 -0
- package/dist/interview/progress.js +51 -0
- package/dist/interview/progress.js.map +1 -0
- package/dist/interview/prompt.d.ts +20 -0
- package/dist/interview/prompt.d.ts.map +1 -0
- package/dist/interview/prompt.js +58 -0
- package/dist/interview/prompt.js.map +1 -0
- package/dist/phases/aggregate/assumptions.d.ts +14 -0
- package/dist/phases/aggregate/assumptions.d.ts.map +1 -0
- package/dist/phases/aggregate/assumptions.js +33 -0
- package/dist/phases/aggregate/assumptions.js.map +1 -0
- package/dist/phases/aggregate/findings.d.ts +10 -0
- package/dist/phases/aggregate/findings.d.ts.map +1 -0
- package/dist/phases/aggregate/findings.js +20 -0
- package/dist/phases/aggregate/findings.js.map +1 -0
- package/dist/phases/aggregate/goals.d.ts +28 -0
- package/dist/phases/aggregate/goals.d.ts.map +1 -0
- package/dist/phases/aggregate/goals.js +74 -0
- package/dist/phases/aggregate/goals.js.map +1 -0
- package/dist/phases/aggregate/index.d.ts +128 -0
- package/dist/phases/aggregate/index.d.ts.map +1 -0
- package/dist/phases/aggregate/index.js +165 -0
- package/dist/phases/aggregate/index.js.map +1 -0
- package/dist/phases/aggregate/pam.d.ts +19 -0
- package/dist/phases/aggregate/pam.d.ts.map +1 -0
- package/dist/phases/aggregate/pam.js +37 -0
- package/dist/phases/aggregate/pam.js.map +1 -0
- package/dist/phases/aggregate/scope.d.ts +24 -0
- package/dist/phases/aggregate/scope.d.ts.map +1 -0
- package/dist/phases/aggregate/scope.js +67 -0
- package/dist/phases/aggregate/scope.js.map +1 -0
- package/dist/phases/aggregate/shared.d.ts +16 -0
- package/dist/phases/aggregate/shared.d.ts.map +1 -0
- package/dist/phases/aggregate/shared.js +26 -0
- package/dist/phases/aggregate/shared.js.map +1 -0
- package/dist/phases/aggregate/stakeholders.d.ts +27 -0
- package/dist/phases/aggregate/stakeholders.d.ts.map +1 -0
- package/dist/phases/aggregate/stakeholders.js +90 -0
- package/dist/phases/aggregate/stakeholders.js.map +1 -0
- package/dist/phases/aggregate/waitingRoom.d.ts +16 -0
- package/dist/phases/aggregate/waitingRoom.d.ts.map +1 -0
- package/dist/phases/aggregate/waitingRoom.js +32 -0
- package/dist/phases/aggregate/waitingRoom.js.map +1 -0
- package/dist/phases/assumptions.d.ts +19 -0
- package/dist/phases/assumptions.d.ts.map +1 -0
- package/dist/phases/assumptions.js +224 -0
- package/dist/phases/assumptions.js.map +1 -0
- package/dist/phases/configuration.d.ts +8 -0
- package/dist/phases/configuration.d.ts.map +1 -0
- package/dist/phases/configuration.js +14 -0
- package/dist/phases/configuration.js.map +1 -0
- package/dist/phases/goals.d.ts +15 -0
- package/dist/phases/goals.d.ts.map +1 -0
- package/dist/phases/goals.js +297 -0
- package/dist/phases/goals.js.map +1 -0
- package/dist/phases/index.d.ts +21 -0
- package/dist/phases/index.d.ts.map +1 -0
- package/dist/phases/index.js +56 -0
- package/dist/phases/index.js.map +1 -0
- package/dist/phases/opening.d.ts +12 -0
- package/dist/phases/opening.d.ts.map +1 -0
- package/dist/phases/opening.js +99 -0
- package/dist/phases/opening.js.map +1 -0
- package/dist/phases/purpose.d.ts +17 -0
- package/dist/phases/purpose.d.ts.map +1 -0
- package/dist/phases/purpose.js +207 -0
- package/dist/phases/purpose.js.map +1 -0
- package/dist/phases/schema.d.ts +861 -0
- package/dist/phases/schema.d.ts.map +1 -0
- package/dist/phases/schema.js +157 -0
- package/dist/phases/schema.js.map +1 -0
- package/dist/phases/scope.d.ts +18 -0
- package/dist/phases/scope.d.ts.map +1 -0
- package/dist/phases/scope.js +440 -0
- package/dist/phases/scope.js.map +1 -0
- package/dist/phases/session/archive.d.ts +19 -0
- package/dist/phases/session/archive.d.ts.map +1 -0
- package/dist/phases/session/archive.js +49 -0
- package/dist/phases/session/archive.js.map +1 -0
- package/dist/phases/session/file.d.ts +31 -0
- package/dist/phases/session/file.d.ts.map +1 -0
- package/dist/phases/session/file.js +113 -0
- package/dist/phases/session/file.js.map +1 -0
- package/dist/phases/session/index.d.ts +8 -0
- package/dist/phases/session/index.d.ts.map +1 -0
- package/dist/phases/session/index.js +8 -0
- package/dist/phases/session/index.js.map +1 -0
- package/dist/phases/session/persistence.d.ts +30 -0
- package/dist/phases/session/persistence.d.ts.map +1 -0
- package/dist/phases/session/persistence.js +91 -0
- package/dist/phases/session/persistence.js.map +1 -0
- package/dist/phases/shared.d.ts +64 -0
- package/dist/phases/shared.d.ts.map +1 -0
- package/dist/phases/shared.js +100 -0
- package/dist/phases/shared.js.map +1 -0
- package/dist/phases/stakeholders.d.ts +17 -0
- package/dist/phases/stakeholders.d.ts.map +1 -0
- package/dist/phases/stakeholders.js +370 -0
- package/dist/phases/stakeholders.js.map +1 -0
- package/dist/phases/validation.d.ts +13 -0
- package/dist/phases/validation.d.ts.map +1 -0
- package/dist/phases/validation.js +130 -0
- package/dist/phases/validation.js.map +1 -0
- package/dist/skill/adapter.d.ts +16 -0
- package/dist/skill/adapter.d.ts.map +1 -0
- package/dist/skill/adapter.js +278 -0
- package/dist/skill/adapter.js.map +1 -0
- package/dist/skill/index.d.ts +12 -0
- package/dist/skill/index.d.ts.map +1 -0
- package/dist/skill/index.js +11 -0
- package/dist/skill/index.js.map +1 -0
- package/dist/skill/log.d.ts +18 -0
- package/dist/skill/log.d.ts.map +1 -0
- package/dist/skill/log.js +53 -0
- package/dist/skill/log.js.map +1 -0
- package/package.json +83 -0
- package/skills/elaborate/SKILL.md +97 -0
- package/skills/elaborate/scripts/elaborate.cjs +589 -0
- package/skills/project-brief/SKILL.md +45 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Goal discovery phase — KAOS-inspired WHY/HOW probing.
|
|
3
|
+
*
|
|
4
|
+
* Captures goals through:
|
|
5
|
+
* 1. Seed extraction from prior artifacts + waiting room drain + list review (upfront)
|
|
6
|
+
* 2. Per-goal refinement (clarify → why → negative probing stages)
|
|
7
|
+
* 3. Confirmation with revision loop
|
|
8
|
+
*
|
|
9
|
+
* Goals follow KAOS goal model (MVP subset). Progressive status:
|
|
10
|
+
* fuzzy(0.5) → elaborated(0.7) → confirmed(0.9).
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { buildFullContext, confirmationCloser, confirmPhase } from "./shared.js";
|
|
14
|
+
import { inferCompositionStep, inferStep } from "../interview/index.js";
|
|
15
|
+
import { ENABLE_GOAL_NEGATIVE_STAGE, GOAL_DETAIL_CAP } from "./configuration.js";
|
|
16
|
+
/** Max probe attempts per stage before giving up. Keep low to avoid interrogation spirals. */
|
|
17
|
+
const MAX_PROBE_ATTEMPTS = 2;
|
|
18
|
+
const GoalSeedSchema = z.object({
|
|
19
|
+
goals: z.array(z.object({
|
|
20
|
+
title: z.string().describe("short goal name"),
|
|
21
|
+
description: z.string().describe("what the goal means"),
|
|
22
|
+
rationale: z.string().optional().describe("why this goal matters"),
|
|
23
|
+
})).optional().describe(`candidate goals extracted from the conversation so far, 1-${GOAL_DETAIL_CAP} goals`),
|
|
24
|
+
drainedWaitingRoomIds: z.array(z.string()).optional()
|
|
25
|
+
.describe('IDs of waiting room items used as goal sources (e.g. ["waiting_001"]), empty if none'),
|
|
26
|
+
});
|
|
27
|
+
const GoalSeedResponseSchema = z.object({
|
|
28
|
+
responseInterpretation: z.string().describe("what the stakeholder meant, resolving any suggestion references"),
|
|
29
|
+
confirmedGoalIds: z.array(z.string()).optional().describe("IDs the user confirmed (or all IDs if they confirmed)"),
|
|
30
|
+
removedGoalIds: z.array(z.string()).optional().describe("IDs the user wants removed"),
|
|
31
|
+
newGoals: z.array(z.object({ title: z.string().describe("short goal name"), description: z.string().describe("what the goal means") })).optional().describe("new goals the user mentioned, empty if none"),
|
|
32
|
+
waitingRoomItems: z.array(z.object({ content: z.string().describe("the item text") })).optional().describe("items that sound like scope or assumptions rather than goals, empty if none"),
|
|
33
|
+
});
|
|
34
|
+
const GoalExtractionSchema = z.object({
|
|
35
|
+
responseInterpretation: z.string().describe("what the stakeholder meant, resolving any suggestion references (a, b, c) to their full text"),
|
|
36
|
+
title: z.string().nullable().optional().describe("updated goal title if the response clarified it, null to keep current"),
|
|
37
|
+
description: z.string().nullable().optional().describe("updated description if the response expanded it, null to keep current"),
|
|
38
|
+
rationale: z.string().nullable().optional().describe("why this goal matters, extracted from the response, null if not addressed"),
|
|
39
|
+
contradictions: z.array(z.string()).optional().describe("genuine logical contradictions with existing goals or purpose/advantage where both statements CANNOT be true simultaneously (e.g. 'goal requires real-time' vs 'constraint is batch-only'). NOT: different priorities between stakeholders, complementary concerns, soft tensions, or different aspects of the same goal. Empty array if none"),
|
|
40
|
+
waitingRoomItems: z.array(z.object({ content: z.string().describe("the item text") })).optional().describe("items that sound like scope or assumptions rather than goals, empty if none"),
|
|
41
|
+
});
|
|
42
|
+
const InitialGoalExtractionSchema = z.object({
|
|
43
|
+
responseInterpretation: z.string().describe("what the stakeholder meant, resolving any suggestion references"),
|
|
44
|
+
goals: z.array(z.object({ title: z.string().describe("short goal name"), description: z.string().describe("what the goal means") })).optional().describe("goals mentioned by the stakeholder, empty if none"),
|
|
45
|
+
waitingRoomItems: z.array(z.object({ content: z.string().describe("the item text") })).optional().describe("items that sound like scope or assumptions rather than goals, empty if none"),
|
|
46
|
+
});
|
|
47
|
+
const GoalSortSchema = z.object({
|
|
48
|
+
rankedGoalIds: z.array(z.string()).describe("goal IDs ordered from highest to lowest priority for probing"),
|
|
49
|
+
});
|
|
50
|
+
function goalSort(artifacts, confirmedGoalIds) {
|
|
51
|
+
const goalRef = artifacts.goals.map((g) => `[${g.id}] "${g.title}" — ${g.description}`).join("; ");
|
|
52
|
+
const pamRef = [
|
|
53
|
+
artifacts.purpose ? `Purpose: ${artifacts.purpose}` : null,
|
|
54
|
+
artifacts.advantage ? `Advantage: ${artifacts.advantage}` : null,
|
|
55
|
+
artifacts.measurement ? `Measurement: ${artifacts.measurement}` : null,
|
|
56
|
+
].filter(Boolean).join("; ");
|
|
57
|
+
const confirmedRef = confirmedGoalIds.length > 0
|
|
58
|
+
? `Confirmed from suggestions (not user-originated): ${confirmedGoalIds.join(", ")}`
|
|
59
|
+
: "All goals are user-originated.";
|
|
60
|
+
return inferStep({
|
|
61
|
+
id: "goal-sort",
|
|
62
|
+
schema: GoalSortSchema,
|
|
63
|
+
message: `
|
|
64
|
+
Rank these goals by priority for detailed probing.
|
|
65
|
+
|
|
66
|
+
Goals: ${goalRef}
|
|
67
|
+
PAM: ${pamRef}
|
|
68
|
+
${confirmedRef}
|
|
69
|
+
|
|
70
|
+
Criteria (in order):
|
|
71
|
+
1. Genuine uniqueness: goals that don't substantially overlap with purpose/advantage/measurement rank highest.
|
|
72
|
+
2. User-originated: goals the user stated rank above goals they merely confirmed from suggestions.
|
|
73
|
+
3. Listing order as tertiary tiebreaker.
|
|
74
|
+
|
|
75
|
+
Return ALL goal IDs, ordered from highest to lowest priority.
|
|
76
|
+
`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function parkExcessGoals(agg, goalStates, keepIds) {
|
|
80
|
+
const parked = agg.data.goals.filter((g) => !keepIds.has(g.id));
|
|
81
|
+
for (const goal of parked) {
|
|
82
|
+
agg.addWaitingRoomItems([{ content: `Goal: ${goal.title} — ${goal.description}` }]);
|
|
83
|
+
delete goalStates[goal.id];
|
|
84
|
+
}
|
|
85
|
+
agg.removeGoals(new Set(parked.map((g) => g.id)));
|
|
86
|
+
}
|
|
87
|
+
function seedPresent(goals) {
|
|
88
|
+
const letters = "abcdefghijklmnopqrstuvwxyz";
|
|
89
|
+
const goalList = goals.map((g, i) => `${letters[i]}) **${g.title}** — ${g.description}`).join("\n");
|
|
90
|
+
return {
|
|
91
|
+
id: "goal-seed-present",
|
|
92
|
+
message: `
|
|
93
|
+
Based on what you've told me, I see these potential goals:
|
|
94
|
+
${goalList}
|
|
95
|
+
|
|
96
|
+
Did I capture the right goals? You can confirm, add new ones, or tell me which to remove.
|
|
97
|
+
`,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function initialComposition(artifacts) {
|
|
101
|
+
return inferCompositionStep({
|
|
102
|
+
id: "",
|
|
103
|
+
fallback: "What are the main **goals** for your project?",
|
|
104
|
+
message: `
|
|
105
|
+
Compose a question asking the stakeholder about their project goals — the outcomes they want to achieve.
|
|
106
|
+
Suggest 2-3 concrete goals relevant to their stated purpose.
|
|
107
|
+
|
|
108
|
+
Context:
|
|
109
|
+
${buildFullContext(artifacts)}
|
|
110
|
+
`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function refinementComposition(goalTitle, stage, attempt, artifacts) {
|
|
114
|
+
const rephrase = attempt > 0;
|
|
115
|
+
let direction;
|
|
116
|
+
let fallback;
|
|
117
|
+
switch (stage) {
|
|
118
|
+
case "clarify":
|
|
119
|
+
direction = rephrase
|
|
120
|
+
? `The previous question about "${goalTitle}" didn't get a clear answer. Offer concrete examples or choices to help them articulate it.`
|
|
121
|
+
: `Ask what "${goalTitle}" means concretely — what achieving it would look like in practice.`;
|
|
122
|
+
fallback = `What would achieving "${goalTitle}" look like in practice?`;
|
|
123
|
+
break;
|
|
124
|
+
case "why":
|
|
125
|
+
direction = rephrase
|
|
126
|
+
? `Rephrase the "why" question for "${goalTitle}". Try grounding it in a specific scenario or user experience.`
|
|
127
|
+
: `Ask why "${goalTitle}" is important — what value achieving it creates.`;
|
|
128
|
+
fallback = `What **value** does achieving "${goalTitle}" create?`;
|
|
129
|
+
break;
|
|
130
|
+
case "negative":
|
|
131
|
+
direction = rephrase
|
|
132
|
+
? `Rephrase the negative question for "${goalTitle}". Try a concrete scenario — e.g., imagine launching without it, what workaround people would use.`
|
|
133
|
+
: `Ask what would happen if "${goalTitle}" didn't exist or wasn't achieved.`;
|
|
134
|
+
fallback = `What would happen if "${goalTitle}" wasn't achieved?`;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
return inferCompositionStep({
|
|
138
|
+
id: "",
|
|
139
|
+
fallback,
|
|
140
|
+
message: `
|
|
141
|
+
Compose a question for the stakeholder about goal: "${goalTitle}".
|
|
142
|
+
${direction}
|
|
143
|
+
Include 2-3 suggested answers that show the expected level of specificity.
|
|
144
|
+
|
|
145
|
+
Context:
|
|
146
|
+
${buildFullContext(artifacts)}
|
|
147
|
+
`,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function confirmation(goals, findings) {
|
|
151
|
+
const goalList = goals.map((g) => {
|
|
152
|
+
const rationale = g.rationale ? `\n _Why it matters:_ ${g.rationale}` : "";
|
|
153
|
+
return `**${g.title}** [${g.status}]\n ${g.description}${rationale}`;
|
|
154
|
+
}).join("\n\n");
|
|
155
|
+
const goalsFindings = findings.filter((f) => f.phase === "goals");
|
|
156
|
+
const findingsSection = goalsFindings.length > 0
|
|
157
|
+
? `\n**Gaps noted**:\n${goalsFindings.map((f) => `- ${f.content}`).join("\n")}\n`
|
|
158
|
+
: "";
|
|
159
|
+
return {
|
|
160
|
+
id: "goals-confirmation",
|
|
161
|
+
message: `
|
|
162
|
+
Here's what I've captured for your project goals:
|
|
163
|
+
|
|
164
|
+
${goalList}
|
|
165
|
+
${findingsSection}
|
|
166
|
+
${confirmationCloser()}
|
|
167
|
+
`,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function addFuzzyGoals(agg, goalStates, raws, source) {
|
|
171
|
+
const ids = agg.addFuzzyGoals(raws, source);
|
|
172
|
+
for (const id of ids)
|
|
173
|
+
goalStates[id] = { attempts: 0, probingStage: "clarify" };
|
|
174
|
+
}
|
|
175
|
+
export async function runGoals(ctx, agg) {
|
|
176
|
+
const artifacts = agg.data;
|
|
177
|
+
const goalStates = {};
|
|
178
|
+
// Track waiting room IDs before seeding so we only drain pre-existing items
|
|
179
|
+
const preWaitingRoomIds = new Set(artifacts.waitingRoom.map((w) => w.id));
|
|
180
|
+
// Step 1: Seed extraction + waiting room drain + list review (upfront)
|
|
181
|
+
const seeds = await ctx.seed({
|
|
182
|
+
id: "goal-seed-extraction",
|
|
183
|
+
artifactsContext: buildFullContext(artifacts, { includeWaitingRoom: true }),
|
|
184
|
+
schema: GoalSeedSchema,
|
|
185
|
+
guidance: `Extract candidate project goals. Each goal: clear title (verb + outcome), description, optional rationale. 1-${GOAL_DETAIL_CAP} goals. Prefer goals that capture outcomes beyond what's already stated in purpose, advantage, and measurement. Pull hints from the waitingRoom items in the context; return drainedWaitingRoomIds for the items you consumed.`,
|
|
186
|
+
});
|
|
187
|
+
const goals = seeds.goals ?? [];
|
|
188
|
+
// Drain waiting room items the LLM reported as consumed (by ID)
|
|
189
|
+
const drainedIds = new Set((seeds.drainedWaitingRoomIds ?? []).filter((id) => preWaitingRoomIds.has(id)));
|
|
190
|
+
agg.drainWaitingRoom(drainedIds);
|
|
191
|
+
if (goals.length > 0) {
|
|
192
|
+
addFuzzyGoals(agg, goalStates, goals, ctx.currentSource);
|
|
193
|
+
const goalRef = artifacts.goals.map((g) => `${g.id}: "${g.title}"`).join(", ");
|
|
194
|
+
const seedClass = await ctx.promptReview(seedPresent(artifacts.goals), "goal-seed-classification", goalRef, buildFullContext(artifacts), GoalSeedResponseSchema, { defaults: { responseInterpretation: "", confirmedGoalIds: [], removedGoalIds: [], newGoals: [], waitingRoomItems: [] } });
|
|
195
|
+
const removedIds = new Set(seedClass.removedGoalIds ?? []);
|
|
196
|
+
if (removedIds.size > 0) {
|
|
197
|
+
agg.removeGoals(removedIds);
|
|
198
|
+
for (const id of removedIds)
|
|
199
|
+
delete goalStates[id];
|
|
200
|
+
}
|
|
201
|
+
addFuzzyGoals(agg, goalStates, seedClass.newGoals ?? [], ctx.currentSource);
|
|
202
|
+
agg.addWaitingRoomItems(seedClass.waitingRoomItems ?? []);
|
|
203
|
+
// Sort + cap: only probe top N goals, park the rest
|
|
204
|
+
if (artifacts.goals.length > GOAL_DETAIL_CAP) {
|
|
205
|
+
const effectiveConfirmed = (seedClass.confirmedGoalIds ?? []).filter((id) => !removedIds.has(id));
|
|
206
|
+
const sortResult = await ctx.infer(goalSort(artifacts, effectiveConfirmed));
|
|
207
|
+
const validIds = new Set(artifacts.goals.map((g) => g.id));
|
|
208
|
+
const ranked = sortResult.rankedGoalIds.filter((id) => validIds.has(id));
|
|
209
|
+
const keepIds = ranked.length >= GOAL_DETAIL_CAP
|
|
210
|
+
? new Set(ranked.slice(0, GOAL_DETAIL_CAP))
|
|
211
|
+
: new Set(artifacts.goals.slice(0, GOAL_DETAIL_CAP).map((g) => g.id));
|
|
212
|
+
parkExcessGoals(agg, goalStates, keepIds);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
// No seeds — ask user to name goals directly
|
|
217
|
+
const extraction = await ctx.composePromptExtract("goal-initial", () => initialComposition(artifacts), { artifactsContext: buildFullContext(artifacts), schema: InitialGoalExtractionSchema }, { defaults: { responseInterpretation: "", goals: [], waitingRoomItems: [] } });
|
|
218
|
+
addFuzzyGoals(agg, goalStates, extraction.goals ?? [], ctx.currentSource);
|
|
219
|
+
agg.addWaitingRoomItems(extraction.waitingRoomItems ?? []);
|
|
220
|
+
// Cap without sort: all user-originated, take first N in listing order
|
|
221
|
+
if (artifacts.goals.length > GOAL_DETAIL_CAP) {
|
|
222
|
+
const keepIds = new Set(artifacts.goals.slice(0, GOAL_DETAIL_CAP).map((g) => g.id));
|
|
223
|
+
parkExcessGoals(agg, goalStates, keepIds);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Step 2: Per-goal refinement (clarify → why → negative)
|
|
227
|
+
for (const goal of artifacts.goals) {
|
|
228
|
+
if (goal.status !== "fuzzy")
|
|
229
|
+
continue;
|
|
230
|
+
// Skip refinement if seed/review already provided rationale
|
|
231
|
+
if (goal.rationale) {
|
|
232
|
+
agg.setGoalStatus(goal.id, "elaborated");
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const gs = goalStates[goal.id] ?? { attempts: 0, probingStage: "clarify" };
|
|
236
|
+
if (!goalStates[goal.id])
|
|
237
|
+
goalStates[goal.id] = gs;
|
|
238
|
+
let goalDone = false;
|
|
239
|
+
while (!goalDone && gs.probingStage) {
|
|
240
|
+
let stageAdvanced = false;
|
|
241
|
+
for (let attempt = gs.attempts; attempt < MAX_PROBE_ATTEMPTS && !stageAdvanced; attempt++) {
|
|
242
|
+
gs.attempts = attempt + 1;
|
|
243
|
+
const stage = gs.probingStage;
|
|
244
|
+
const extraction = await ctx.composePromptExtract(`goal-refinement-${goal.id}-${stage}-${attempt}`, () => refinementComposition(goal.title, stage, attempt, artifacts), { artifactsContext: buildFullContext(artifacts), schema: GoalExtractionSchema, focus: `[${goal.id}] "${goal.title}"` }, { defaults: { responseInterpretation: "", title: null, description: null, rationale: null, contradictions: [], waitingRoomItems: [] } });
|
|
245
|
+
// Handle contradictions
|
|
246
|
+
if (extraction.contradictions && extraction.contradictions.length > 0) {
|
|
247
|
+
agg.applyGoalExtraction(goal.id, extraction);
|
|
248
|
+
const reExtraction = await ctx.promptReextract(`goal-contradiction-${goal.id}-${stage}-${attempt}`, extraction.contradictions, buildFullContext(artifacts), GoalExtractionSchema, { defaults: { responseInterpretation: "", title: null, description: null, rationale: null, contradictions: [], waitingRoomItems: [] } });
|
|
249
|
+
stageAdvanced = agg.applyGoalExtraction(goal.id, reExtraction);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
stageAdvanced = agg.applyGoalExtraction(goal.id, extraction);
|
|
253
|
+
}
|
|
254
|
+
if (!stageAdvanced) {
|
|
255
|
+
agg.addFinding(`Stakeholder could not elaborate goal "${goal.title}" after ${gs.attempts} attempts`, "goals");
|
|
256
|
+
goalDone = true;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
let nextStage = null;
|
|
260
|
+
if (gs.probingStage === "clarify" && !goal.rationale)
|
|
261
|
+
nextStage = "why";
|
|
262
|
+
else if (ENABLE_GOAL_NEGATIVE_STAGE && gs.probingStage !== "negative")
|
|
263
|
+
nextStage = "negative";
|
|
264
|
+
if (nextStage) {
|
|
265
|
+
gs.probingStage = nextStage;
|
|
266
|
+
gs.attempts = 0;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
agg.setGoalStatus(goal.id, "elaborated");
|
|
270
|
+
goalDone = true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// Quality check
|
|
276
|
+
const hasElaborated = artifacts.goals.some((g) => g.status === "elaborated" || g.status === "confirmed");
|
|
277
|
+
if (!hasElaborated) {
|
|
278
|
+
agg.addFinding("No goals reached elaborated status — downstream requirements may lack direction", "goals");
|
|
279
|
+
}
|
|
280
|
+
// Step 3: Single-pass confirmation
|
|
281
|
+
const { response, approved, targetId } = await confirmPhase(ctx, confirmation(artifacts.goals, artifacts.findings), artifacts, "goals", 0);
|
|
282
|
+
if (!approved) {
|
|
283
|
+
const extraction = await ctx.extract({
|
|
284
|
+
id: "goals-revision",
|
|
285
|
+
response,
|
|
286
|
+
artifactsContext: buildFullContext(artifacts),
|
|
287
|
+
schema: GoalExtractionSchema,
|
|
288
|
+
});
|
|
289
|
+
const target = (targetId && artifacts.goals.find((g) => g.id === targetId))
|
|
290
|
+
?? artifacts.goals[0];
|
|
291
|
+
if (target) {
|
|
292
|
+
agg.applyGoalExtraction(target.id, extraction);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
agg.confirmElaboratedGoals();
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=goals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goals.js","sourceRoot":"","sources":["../../src/phases/goals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIjF,8FAA8F;AAC9F,MAAM,kBAAkB,GAA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AC7G,CAAC;IAED,mCAAmC;IACnC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAE3I,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC;YACnC,EAAE,EAAE,gBAAgB;YACpB,QAAQ;YACR,gBAAgB,EAAE,gBAAgB,CAAC,SAAS,CAAC;YAC7C,MAAM,EAAE,oBAAoB;SAC7B,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,CAAC,QAAQ,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;eACtE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,MAAM,EAAE,CAAC;YACX,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,GAAG,CAAC,sBAAsB,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session workflow — main entry point.
|
|
3
|
+
*
|
|
4
|
+
* Wires together opening → purpose → goals → stakeholders → scope → assumptions → validation → completion
|
|
5
|
+
* on top of the durable interview framework.
|
|
6
|
+
*/
|
|
7
|
+
import type { Workflow } from "../durable/index.js";
|
|
8
|
+
import { ArtifactAggregate } from "./aggregate/index.js";
|
|
9
|
+
import "../interview/index.js";
|
|
10
|
+
import "./shared.js";
|
|
11
|
+
/** Create a session workflow bound to the given aggregate. */
|
|
12
|
+
export declare function createSession(agg: ArtifactAggregate): Workflow;
|
|
13
|
+
/** Self-contained workflow — creates its own aggregate per invocation. */
|
|
14
|
+
export declare const session: Workflow;
|
|
15
|
+
export { ArtifactAggregate };
|
|
16
|
+
export type { ContextSummary } from "./aggregate/index.js";
|
|
17
|
+
export { ArtifactsSchema, GoalSchema, StakeholderSchema, InScopeItemSchema, OutOfScopeItemSchema, ConstraintSchema, AssumptionSchema, PurposeSchema, AdvantageSchema, MeasurementSchema, SourceSchema, WaitingItemSchema, FindingSchema, ResidualItemSchema, GoalStatus, StakeholderType, StakeholderStatus, AssumptionType, AssumptionStatus, GOAL_CONFIDENCE, STAKEHOLDER_CONFIDENCE, ASSUMPTION_CONFIDENCE, createEmptyArtifacts, } from "./schema.js";
|
|
18
|
+
export type { Artifacts, Goal, Stakeholder, InScopeItem, OutOfScopeItem, Constraint, Assumption, Purpose, Advantage, Measurement, Source, WaitingItem, Finding, ResidualItem, } from "./schema.js";
|
|
19
|
+
export { createFilePersistence, archiveSession, archiveCorrupted, CorruptedSessionError } from "./session/index.js";
|
|
20
|
+
export type { SessionPersistence } from "./session/index.js";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/phases/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,uBAAuB,CAAC;AAC/B,OAAO,aAAa,CAAC;AAYrB,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,QAAQ,CA+B9D;AAED,0EAA0E;AAC1E,eAAO,MAAM,OAAO,EAAE,QAErB,CAAC;AAGF,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EACL,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,IAAI,EACJ,WAAW,EACX,WAAW,EACX,cAAc,EACd,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACX,MAAM,EACN,WAAW,EACX,OAAO,EACP,YAAY,GACb,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACpH,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session workflow — main entry point.
|
|
3
|
+
*
|
|
4
|
+
* Wires together opening → purpose → goals → stakeholders → scope → assumptions → validation → completion
|
|
5
|
+
* on top of the durable interview framework.
|
|
6
|
+
*/
|
|
7
|
+
import { ArtifactAggregate } from "./aggregate/index.js";
|
|
8
|
+
import "../interview/index.js";
|
|
9
|
+
import "./shared.js";
|
|
10
|
+
import { runOpening } from "./opening.js";
|
|
11
|
+
import { runPurpose } from "./purpose.js";
|
|
12
|
+
import { runGoals } from "./goals.js";
|
|
13
|
+
import { runStakeholders } from "./stakeholders.js";
|
|
14
|
+
import { runScope } from "./scope.js";
|
|
15
|
+
import { runAssumptions } from "./assumptions.js";
|
|
16
|
+
import { runValidation } from "./validation.js";
|
|
17
|
+
import { ENABLE_ASSUMPTIONS_PHASE } from "./configuration.js";
|
|
18
|
+
const TOTAL_PHASES = ENABLE_ASSUMPTIONS_PHASE ? 7 : 6;
|
|
19
|
+
/** Create a session workflow bound to the given aggregate. */
|
|
20
|
+
export function createSession(agg) {
|
|
21
|
+
return async (ctx) => {
|
|
22
|
+
ctx.setProgress(1, TOTAL_PHASES, "Opening");
|
|
23
|
+
const opening = await runOpening(ctx, agg);
|
|
24
|
+
ctx.setProgress(2, TOTAL_PHASES, "Purpose");
|
|
25
|
+
ctx.setTransition("Let's dig into the purpose behind this idea.");
|
|
26
|
+
await runPurpose(ctx, agg, opening);
|
|
27
|
+
ctx.setProgress(3, TOTAL_PHASES, "Goals");
|
|
28
|
+
ctx.setTransition("Good — now let's break that purpose down into concrete goals.");
|
|
29
|
+
await runGoals(ctx, agg);
|
|
30
|
+
ctx.setProgress(4, TOTAL_PHASES, "Stakeholders");
|
|
31
|
+
ctx.setTransition("Now let's talk about who's involved — the people affected by or contributing to this project.");
|
|
32
|
+
await runStakeholders(ctx, agg);
|
|
33
|
+
ctx.setProgress(5, TOTAL_PHASES, "Scope");
|
|
34
|
+
ctx.setTransition("We're past the halfway point. Let's define what's in scope and what's not.");
|
|
35
|
+
await runScope(ctx, agg);
|
|
36
|
+
if (ENABLE_ASSUMPTIONS_PHASE) {
|
|
37
|
+
ctx.setProgress(6, TOTAL_PHASES, "Assumptions");
|
|
38
|
+
ctx.setTransition("Almost done — let's surface the assumptions behind what we've discussed.");
|
|
39
|
+
await runAssumptions(ctx, agg);
|
|
40
|
+
}
|
|
41
|
+
ctx.setProgress(TOTAL_PHASES, TOTAL_PHASES, "Validation");
|
|
42
|
+
ctx.setTransition("Last step — let's review everything together.");
|
|
43
|
+
await runValidation(ctx, agg);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** Self-contained workflow — creates its own aggregate per invocation. */
|
|
47
|
+
export const session = async (ctx) => {
|
|
48
|
+
await createSession(new ArtifactAggregate())(ctx);
|
|
49
|
+
};
|
|
50
|
+
// Workflow + aggregate
|
|
51
|
+
export { ArtifactAggregate };
|
|
52
|
+
// Schema (whole module — artifact contract)
|
|
53
|
+
export { ArtifactsSchema, GoalSchema, StakeholderSchema, InScopeItemSchema, OutOfScopeItemSchema, ConstraintSchema, AssumptionSchema, PurposeSchema, AdvantageSchema, MeasurementSchema, SourceSchema, WaitingItemSchema, FindingSchema, ResidualItemSchema, GoalStatus, StakeholderType, StakeholderStatus, AssumptionType, AssumptionStatus, GOAL_CONFIDENCE, STAKEHOLDER_CONFIDENCE, ASSUMPTION_CONFIDENCE, createEmptyArtifacts, } from "./schema.js";
|
|
54
|
+
// Session (re-exported from session sub-barrel)
|
|
55
|
+
export { createFilePersistence, archiveSession, archiveCorrupted, CorruptedSessionError } from "./session/index.js";
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/phases/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,uBAAuB,CAAC;AAC/B,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,MAAM,YAAY,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtD,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,GAAsB;IAClD,OAAO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C,+CAA+C,CAAC,CAAC;QACnE,MAAM,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,OAAO,GAAa,KAAK,EAAE,GAAG,EAAE,EAAE;IAC7C,MAAM,aAAa,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,uBAAuB;AACvB,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAG7B,4CAA4C;AAC5C,OAAO,EACL,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAkBrB,gDAAgD;AAChD,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opening phase — initial greeting, description extraction, and brownfield context ingestion.
|
|
3
|
+
*
|
|
4
|
+
* After collecting the user's idea and extracting initial signals, the opening
|
|
5
|
+
* asks whether this is a brownfield project. If yes, the user indicates sources
|
|
6
|
+
* (files, URLs, docs) and the agent extracts atomic information items, which are
|
|
7
|
+
* deposited into the waiting room for later phases to consume.
|
|
8
|
+
*/
|
|
9
|
+
import type { WorkflowContext } from "../durable/index.js";
|
|
10
|
+
import type { ArtifactAggregate } from "./aggregate/index.js";
|
|
11
|
+
export declare function runOpening(ctx: WorkflowContext, agg: ArtifactAggregate): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=opening.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../../src/phases/opening.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAmD9D,wBAAsB,UAAU,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkE9F"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opening phase — initial greeting, description extraction, and brownfield context ingestion.
|
|
3
|
+
*
|
|
4
|
+
* After collecting the user's idea and extracting initial signals, the opening
|
|
5
|
+
* asks whether this is a brownfield project. If yes, the user indicates sources
|
|
6
|
+
* (files, URLs, docs) and the agent extracts atomic information items, which are
|
|
7
|
+
* deposited into the waiting room for later phases to consume.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { inferStep } from "../interview/index.js";
|
|
11
|
+
import { buildFullContext, confirmPhase } from "./shared.js";
|
|
12
|
+
function greeting() {
|
|
13
|
+
return {
|
|
14
|
+
id: "opening-greet",
|
|
15
|
+
message: `Hey — I'm Elaborate! I'll help you shape your project idea through a quick conversation.\n\nWhat are you building, and what problem does it solve? If it builds on existing work, feel free to mention that too.`,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const OpeningExtractionSchema = z.object({
|
|
19
|
+
purpose: z.string().describe("the core purpose or problem being solved"),
|
|
20
|
+
stakeholders: z.array(z.string()).describe("implied users or affected parties"),
|
|
21
|
+
domainHints: z.array(z.string()).describe("domain or industry keywords"),
|
|
22
|
+
});
|
|
23
|
+
const BrownfieldScreenSchema = z.object({
|
|
24
|
+
greenfieldConfidence: z.number().describe("1 (uncertain) to 10 (certain this is a brand-new project with no existing work)"),
|
|
25
|
+
});
|
|
26
|
+
const GREENFIELD_THRESHOLD = 7;
|
|
27
|
+
const BrownfieldClassificationSchema = z.object({
|
|
28
|
+
isBrownfield: z.boolean().describe("true if the user indicated this is part of an existing project with existing artifacts to review"),
|
|
29
|
+
sourceIndicators: z.array(z.string()).describe("file paths, URLs, or other source references the user mentioned, empty if greenfield"),
|
|
30
|
+
});
|
|
31
|
+
const BrownfieldExtractionSchema = z.object({
|
|
32
|
+
items: z.array(z.string()).describe("atomic information items extracted from the sources, each a single fact about purpose, goals, stakeholders, scope, constraints, or assumptions"),
|
|
33
|
+
});
|
|
34
|
+
function brownfieldPrompt() {
|
|
35
|
+
return {
|
|
36
|
+
id: "opening-brownfield",
|
|
37
|
+
message: `If there's existing work this builds on — code, docs, URLs — describe it here.\nOtherwise, **skip**.`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function summary(purpose, stakeholders) {
|
|
41
|
+
const parts = [];
|
|
42
|
+
if (purpose) {
|
|
43
|
+
parts.push(`So you want to ${purpose.toLowerCase()}.`);
|
|
44
|
+
}
|
|
45
|
+
if (stakeholders && stakeholders.length > 0) {
|
|
46
|
+
parts.push(`It sounds like this is for ${stakeholders.join(", ")}.`);
|
|
47
|
+
}
|
|
48
|
+
parts.push("\nDoes that sound right so far?");
|
|
49
|
+
return { id: "opening-summary", message: parts.join(" ") };
|
|
50
|
+
}
|
|
51
|
+
export async function runOpening(ctx, agg) {
|
|
52
|
+
const { purpose, stakeholders, domainHints } = await ctx.promptExtract(greeting(), { artifactsContext: buildFullContext(agg.data), schema: OpeningExtractionSchema }, { defaults: { purpose: "", stakeholders: [], domainHints: [] } });
|
|
53
|
+
const src = ctx.currentSource;
|
|
54
|
+
if (purpose) {
|
|
55
|
+
agg.setPurpose(purpose, 0.5, src);
|
|
56
|
+
}
|
|
57
|
+
if (stakeholders && stakeholders.length > 0) {
|
|
58
|
+
agg.addIdentifiedStakeholders(stakeholders.map((name) => ({ name, type: "primary" })), src);
|
|
59
|
+
}
|
|
60
|
+
if (domainHints && domainHints.length > 0) {
|
|
61
|
+
agg.addDomainHints(domainHints);
|
|
62
|
+
}
|
|
63
|
+
// Brownfield screen: skip the brownfield question when clearly greenfield
|
|
64
|
+
const { greenfieldConfidence } = await ctx.infer(inferStep({
|
|
65
|
+
id: "opening-brownfield-screen",
|
|
66
|
+
schema: BrownfieldScreenSchema,
|
|
67
|
+
message: `Based on the user's description, how confident are you that this is a brand-new project with no existing work to build on?
|
|
68
|
+
|
|
69
|
+
"Existing work" means concrete artifacts that THIS project inherits as its starting point — things the new work will extend, replace, integrate with, or add on to (e.g. prior versions, legacy systems, existing tools, institutional infrastructure, prototypes, documents, databases).
|
|
70
|
+
|
|
71
|
+
Everything else is context about the problem space, NOT existing work — this includes competitors, similar products, industry references, domain expertise, prior research, regulations, inspiration sources, or experience with unrelated projects.
|
|
72
|
+
|
|
73
|
+
Score high (greenfield) unless the user explicitly describes artifacts this project builds on.
|
|
74
|
+
|
|
75
|
+
Context: ${buildFullContext(agg.data)}`,
|
|
76
|
+
}));
|
|
77
|
+
if (greenfieldConfidence < GREENFIELD_THRESHOLD) {
|
|
78
|
+
const { isBrownfield, sourceIndicators } = await ctx.promptExtract(brownfieldPrompt(), { artifactsContext: buildFullContext(agg.data), schema: BrownfieldClassificationSchema, guidance: 'Classify the user\'s response to "Is this part of an existing project?"' }, { defaults: { isBrownfield: false, sourceIndicators: [] } });
|
|
79
|
+
if (isBrownfield && sourceIndicators.length > 0) {
|
|
80
|
+
const { items } = await ctx.seed({
|
|
81
|
+
id: "opening-brownfield-extraction",
|
|
82
|
+
artifactsContext: buildFullContext(agg.data),
|
|
83
|
+
schema: BrownfieldExtractionSchema,
|
|
84
|
+
guidance: `Read the indicated sources using your tools and extract atomic information items relevant to the idea.
|
|
85
|
+
Each item should be a single fact — one goal, one stakeholder, one constraint, one assumption, etc.
|
|
86
|
+
Focus on: purpose, goals, stakeholders, scope boundaries, constraints, assumptions.
|
|
87
|
+
Sources to read: ${JSON.stringify(sourceIndicators)}`,
|
|
88
|
+
});
|
|
89
|
+
if (items.length > 0) {
|
|
90
|
+
agg.addWaitingRoomItems(items.map((content) => ({ content })));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const { response: opening } = await confirmPhase(ctx, summary(purpose, stakeholders), agg.data, "opening", 0, {
|
|
95
|
+
defaults: { approved: true, revisionRequested: null },
|
|
96
|
+
});
|
|
97
|
+
return opening;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=opening.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opening.js","sourceRoot":"","sources":["../../src/phases/opening.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,SAAS,QAAQ;IACf,OAAO;QACL,EAAE,EAAE,eAAe;QACnB,OAAO,EAAE,kNAAkN;KAC5N,CAAC;AACJ,CAAC;AAED,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACxE,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAC/E,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,6BAA6B,CAAC;CACzE,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iFAAiF,CAAC;CAC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|
|
5
|
+
* 1. Initial extraction from opening response
|
|
6
|
+
* 2. Laddering (WHY-chain) if response is solution-framed
|
|
7
|
+
* 3. Slot-filling for remaining gaps
|
|
8
|
+
* 4. Confirmation with revision loop
|
|
9
|
+
*
|
|
10
|
+
* PAM is the capture schema (GQM-inspired). Laddering is the interview
|
|
11
|
+
* technique — start concrete, abstract upward via "why?" until purpose surfaces.
|
|
12
|
+
* Confidence is derived from artifact state, not tracked separately.
|
|
13
|
+
*/
|
|
14
|
+
import type { WorkflowContext } from "../durable/index.js";
|
|
15
|
+
import type { ArtifactAggregate } from "./aggregate/index.js";
|
|
16
|
+
export declare function runPurpose(ctx: WorkflowContext, agg: ArtifactAggregate, opening?: string): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=purpose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purpose.d.ts","sourceRoot":"","sources":["../../src/phases/purpose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkH9D,wBAAsB,UAAU,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwH9G"}
|