pi-long-task 0.3.8 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +222 -6
- package/package.json +1 -1
- package/src/coordinator.ts +336 -31
- package/src/coverage_goal.ts +90 -0
- package/src/goal_discovery.ts +739 -0
- package/src/goal_loop.ts +567 -0
- package/src/goal_orchestrator.ts +396 -0
- package/src/goal_review.ts +575 -0
- package/src/goal_spec.ts +670 -0
- package/src/goal_state.ts +227 -0
- package/src/goal_todo_execution.ts +309 -0
- package/src/goal_todo_generation.ts +539 -0
- package/src/index.ts +90 -2
- package/src/input_router.ts +124 -6
- package/src/render.ts +223 -4
- package/src/session_guard.ts +287 -0
- package/src/todo_generator.ts +143 -5
- package/src/types.ts +66 -3
- package/src/worker_session.ts +23 -2
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createGoalSpecification,
|
|
3
|
+
type GoalAcceptanceCriterion,
|
|
4
|
+
type GoalDefinitionOfDone,
|
|
5
|
+
type GoalDesignConstraints,
|
|
6
|
+
type GoalDiscoveryConsolidation,
|
|
7
|
+
type GoalMarketingGrowthContext,
|
|
8
|
+
type GoalMilestone,
|
|
9
|
+
type GoalProductConstraints,
|
|
10
|
+
type GoalScopedRequirements,
|
|
11
|
+
type GoalSpecification,
|
|
12
|
+
type GoalVerificationGate,
|
|
13
|
+
} from "./goal_spec.ts";
|
|
14
|
+
import type { GoalLoopState } from "./goal_loop.ts";
|
|
15
|
+
import type { GoalStateStore } from "./goal_state.ts";
|
|
16
|
+
|
|
17
|
+
export type GoalDiscoveryEntrypoint = "pi_goal_task" | "pi_long_task";
|
|
18
|
+
export type GoalDiscoveryRoute = "discovery" | "direct";
|
|
19
|
+
export type GoalConcreteness = "vague" | "concrete";
|
|
20
|
+
|
|
21
|
+
export interface GoalDiscoveryDecision {
|
|
22
|
+
route: GoalDiscoveryRoute;
|
|
23
|
+
classification: GoalConcreteness;
|
|
24
|
+
confidence: number;
|
|
25
|
+
concreteSignals: string[];
|
|
26
|
+
vagueSignals: string[];
|
|
27
|
+
reason: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface DecideGoalDiscoveryOptions {
|
|
31
|
+
goal: string;
|
|
32
|
+
entrypoint?: GoalDiscoveryEntrypoint;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface GoalDiscoveryRunnerOptions {
|
|
36
|
+
state: GoalLoopState;
|
|
37
|
+
store: GoalStateStore;
|
|
38
|
+
decision: GoalDiscoveryDecision;
|
|
39
|
+
cwd?: string;
|
|
40
|
+
abortSignal?: AbortSignal;
|
|
41
|
+
model?: unknown;
|
|
42
|
+
modelName?: string;
|
|
43
|
+
thinkingLevel?: string;
|
|
44
|
+
now: () => Date;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type GoalDiscoveryRunner = (options: GoalDiscoveryRunnerOptions) => Promise<GoalSpecification>;
|
|
48
|
+
|
|
49
|
+
export function decideGoalDiscovery(options: DecideGoalDiscoveryOptions): GoalDiscoveryDecision {
|
|
50
|
+
const entrypoint = options.entrypoint ?? "pi_goal_task";
|
|
51
|
+
const goal = options.goal.trim();
|
|
52
|
+
const classification = classifyGoalForDiscovery(goal);
|
|
53
|
+
|
|
54
|
+
if (entrypoint !== "pi_goal_task") {
|
|
55
|
+
return {
|
|
56
|
+
...classification,
|
|
57
|
+
route: "direct",
|
|
58
|
+
reason: "Discovery is only enabled by default for pi_goal_task; pi_long_task keeps direct long-task behavior.",
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (classification.classification === "vague") {
|
|
63
|
+
return {
|
|
64
|
+
...classification,
|
|
65
|
+
route: "discovery",
|
|
66
|
+
reason:
|
|
67
|
+
"Goal is vague enough that pi_goal_task should define scope and definition-of-done before implementation.",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
...classification,
|
|
73
|
+
route: "direct",
|
|
74
|
+
reason:
|
|
75
|
+
"Goal already contains concrete implementation or verification detail, so existing TODO generation is preserved.",
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function classifyGoalForDiscovery(goal: string): Omit<GoalDiscoveryDecision, "route" | "reason"> {
|
|
80
|
+
const normalized = goal.toLowerCase().replace(/\s+/g, " ").trim();
|
|
81
|
+
const words = normalized.match(/[a-z0-9_./:-]+/g) ?? [];
|
|
82
|
+
const concreteSignals = concreteGoalSignals(goal, normalized);
|
|
83
|
+
const vagueSignals = vagueGoalSignals(normalized, words.length);
|
|
84
|
+
|
|
85
|
+
if (explicitDiscoveryRequested(normalized)) {
|
|
86
|
+
vagueSignals.push("explicit discovery/planning request");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const concreteScore = concreteSignals.length;
|
|
90
|
+
const vagueScore = vagueSignals.length;
|
|
91
|
+
const hasStrongConcreteSignal = concreteSignals.some((signal) =>
|
|
92
|
+
["file or path reference", "test or verification command", "explicit acceptance or verification criteria"].includes(
|
|
93
|
+
signal,
|
|
94
|
+
),
|
|
95
|
+
);
|
|
96
|
+
const classification: GoalConcreteness =
|
|
97
|
+
explicitDiscoveryRequested(normalized) ||
|
|
98
|
+
(!hasStrongConcreteSignal &&
|
|
99
|
+
(vagueScore > concreteScore || words.length <= 6 || (concreteScore === 0 && words.length <= 12)))
|
|
100
|
+
? "vague"
|
|
101
|
+
: "concrete";
|
|
102
|
+
const signalTotal = Math.max(1, concreteScore + vagueScore);
|
|
103
|
+
const confidence =
|
|
104
|
+
classification === "vague"
|
|
105
|
+
? Math.min(1, Math.max(0.55, vagueScore / signalTotal))
|
|
106
|
+
: Math.min(1, Math.max(0.55, concreteScore / signalTotal));
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
classification,
|
|
110
|
+
confidence: Number(confidence.toFixed(2)),
|
|
111
|
+
concreteSignals,
|
|
112
|
+
vagueSignals,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function runDefaultGoalDiscovery(options: GoalDiscoveryRunnerOptions): Promise<GoalSpecification> {
|
|
117
|
+
throwIfAborted(options.abortSignal);
|
|
118
|
+
const goal = options.state.goal.trim();
|
|
119
|
+
const requirementIds = ["REQ-1", "REQ-2", "REQ-3", "REQ-4", "REQ-5", "REQ-6"];
|
|
120
|
+
const acceptanceCriterionIds = ["AC-1", "AC-2", "AC-3", "AC-4", "AC-5", "AC-6"];
|
|
121
|
+
const requiredGateIds = ["VG-1", "VG-2", "VG-3", "VG-4"];
|
|
122
|
+
|
|
123
|
+
const scopedRequirements = buildScopedRequirements(goal);
|
|
124
|
+
const milestones = buildMilestones();
|
|
125
|
+
const acceptanceCriteria = buildAcceptanceCriteria(goal);
|
|
126
|
+
const verificationGates = buildVerificationGates(goal);
|
|
127
|
+
const designConstraints = buildDesignConstraints(goal);
|
|
128
|
+
const productConstraints = buildProductConstraints(goal);
|
|
129
|
+
const marketingGrowthContext = buildMarketingGrowthContext(goal);
|
|
130
|
+
const discovery = buildDiscoveryConsolidation(goal);
|
|
131
|
+
const definitionOfDone = buildDefinitionOfDone(requirementIds, acceptanceCriterionIds, requiredGateIds);
|
|
132
|
+
|
|
133
|
+
return createGoalSpecification({
|
|
134
|
+
goalRunId: options.state.goalRunId,
|
|
135
|
+
originalGoal: goal,
|
|
136
|
+
summary: `Software product discovery converted the vague goal into a scoped delivery definition: ${goal}`,
|
|
137
|
+
now: options.now,
|
|
138
|
+
traceability: {
|
|
139
|
+
source: "discovery_consolidation",
|
|
140
|
+
sourceArtifacts: [
|
|
141
|
+
{
|
|
142
|
+
label: "Original vague pi_goal_task goal",
|
|
143
|
+
description: goal,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: "Role-based software product discovery consolidation",
|
|
147
|
+
description:
|
|
148
|
+
"Product Owner, Project Manager, Software Architect/Tech Lead, UX/UI Designer, QA/Reviewer, and optional Marketing/Growth planning outputs were consolidated into this specification.",
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
discovery,
|
|
153
|
+
scopedRequirements,
|
|
154
|
+
milestones,
|
|
155
|
+
acceptanceCriteria,
|
|
156
|
+
verificationGates,
|
|
157
|
+
designConstraints,
|
|
158
|
+
productConstraints,
|
|
159
|
+
marketingGrowthContext,
|
|
160
|
+
definitionOfDone,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function buildScopedRequirements(goal: string): GoalScopedRequirements {
|
|
165
|
+
return {
|
|
166
|
+
inScope: [
|
|
167
|
+
{
|
|
168
|
+
id: "REQ-1",
|
|
169
|
+
title: "Primary product outcome",
|
|
170
|
+
description: `Define and deliver the smallest coherent software/product slice that satisfies the user goal: ${goal}`,
|
|
171
|
+
priority: "must",
|
|
172
|
+
acceptanceCriterionIds: ["AC-1", "AC-2"],
|
|
173
|
+
milestoneIds: ["MS-1", "MS-2"],
|
|
174
|
+
source: "Product Owner",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
id: "REQ-2",
|
|
178
|
+
title: "Delivery milestones and sequencing",
|
|
179
|
+
description:
|
|
180
|
+
"Plan implementation as sequenced milestones with explicit dependencies, handoffs, and completion signals before worker TODOs begin.",
|
|
181
|
+
priority: "must",
|
|
182
|
+
acceptanceCriterionIds: ["AC-2"],
|
|
183
|
+
milestoneIds: ["MS-1"],
|
|
184
|
+
source: "Project Manager",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: "REQ-3",
|
|
188
|
+
title: "Technical approach and integration constraints",
|
|
189
|
+
description:
|
|
190
|
+
"Use the existing codebase architecture and extension boundaries, preserving current pi_long_task behavior and concrete pi_goal_task behavior unless scope explicitly requires otherwise.",
|
|
191
|
+
priority: "must",
|
|
192
|
+
acceptanceCriterionIds: ["AC-4"],
|
|
193
|
+
milestoneIds: ["MS-2"],
|
|
194
|
+
source: "Software Architect/Tech Lead",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
id: "REQ-4",
|
|
198
|
+
title: "User experience and accessibility constraints",
|
|
199
|
+
description:
|
|
200
|
+
"Define the primary workflow, user-facing states, accessible interaction expectations, and design constraints needed for a usable product result.",
|
|
201
|
+
priority: "should",
|
|
202
|
+
acceptanceCriterionIds: ["AC-3"],
|
|
203
|
+
milestoneIds: ["MS-1", "MS-2"],
|
|
204
|
+
source: "UX/UI Designer",
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
id: "REQ-5",
|
|
208
|
+
title: "Quality, review, and verification readiness",
|
|
209
|
+
description:
|
|
210
|
+
"Establish acceptance criteria, required verification gates, and review evidence before implementation is planned.",
|
|
211
|
+
priority: "must",
|
|
212
|
+
acceptanceCriterionIds: ["AC-5"],
|
|
213
|
+
milestoneIds: ["MS-3"],
|
|
214
|
+
source: "QA/Reviewer",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
id: "REQ-6",
|
|
218
|
+
title: "Launch and growth context",
|
|
219
|
+
description:
|
|
220
|
+
"Capture lightweight marketing, positioning, launch, and success-metric context when the goal represents a user-facing product or feature.",
|
|
221
|
+
priority: "could",
|
|
222
|
+
acceptanceCriterionIds: ["AC-6"],
|
|
223
|
+
milestoneIds: ["MS-3"],
|
|
224
|
+
source: "Marketing/Growth",
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
outOfScope: [
|
|
228
|
+
{
|
|
229
|
+
id: "OOS-1",
|
|
230
|
+
title: "Unvalidated expansion beyond discovered scope",
|
|
231
|
+
description:
|
|
232
|
+
"Do not add unrelated features, broad rewrites, or speculative enhancements that are not required by the scoped requirements.",
|
|
233
|
+
priority: "wont",
|
|
234
|
+
acceptanceCriterionIds: [],
|
|
235
|
+
milestoneIds: [],
|
|
236
|
+
source: "Discovery consolidation",
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
id: "OOS-2",
|
|
240
|
+
title: "Full launch campaign execution",
|
|
241
|
+
description:
|
|
242
|
+
"Do not execute marketing campaigns, analytics rollouts, or external communications unless they become explicit implementation tasks later.",
|
|
243
|
+
priority: "wont",
|
|
244
|
+
acceptanceCriterionIds: [],
|
|
245
|
+
milestoneIds: [],
|
|
246
|
+
source: "Marketing/Growth",
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
assumptions: [
|
|
250
|
+
"The goal is a software/product delivery goal that needs product definition before implementation planning.",
|
|
251
|
+
"Automated discovery cannot interview stakeholders, so unresolved stakeholder decisions are preserved as open questions.",
|
|
252
|
+
"Implementation workers should use this persisted specification as the definition-of-done instead of relying only on the original vague goal.",
|
|
253
|
+
],
|
|
254
|
+
openQuestions: [
|
|
255
|
+
"Who are the primary and secondary users, and what job-to-be-done should the first implementation slice satisfy?",
|
|
256
|
+
"Which repository areas, platforms, integrations, or external services constrain the implementation?",
|
|
257
|
+
"What measurable product or operational signal proves the delivered slice is successful?",
|
|
258
|
+
"Which non-goals or edge cases must remain out of scope for the first implementation pass?",
|
|
259
|
+
],
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function buildMilestones(): GoalMilestone[] {
|
|
264
|
+
return [
|
|
265
|
+
{
|
|
266
|
+
id: "MS-1",
|
|
267
|
+
title: "Product definition and delivery plan",
|
|
268
|
+
description:
|
|
269
|
+
"Consolidate role planning into scoped requirements, acceptance criteria, verification gates, and constraints.",
|
|
270
|
+
requirementIds: ["REQ-1", "REQ-2", "REQ-4"],
|
|
271
|
+
acceptanceCriterionIds: ["AC-1", "AC-2", "AC-3"],
|
|
272
|
+
doneWhen: [
|
|
273
|
+
"The persisted specification names in-scope and out-of-scope work.",
|
|
274
|
+
"Milestones, acceptance criteria, and verification gates are available for TODO generation and review.",
|
|
275
|
+
],
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
id: "MS-2",
|
|
279
|
+
title: "Implementable technical and UX slice",
|
|
280
|
+
description: "Generate and execute implementation TODOs that deliver the scoped product outcome safely.",
|
|
281
|
+
requirementIds: ["REQ-1", "REQ-3", "REQ-4"],
|
|
282
|
+
acceptanceCriterionIds: ["AC-1", "AC-3", "AC-4"],
|
|
283
|
+
doneWhen: [
|
|
284
|
+
"Implementation work traces to requirement IDs and acceptance criteria.",
|
|
285
|
+
"Technical and UX constraints are respected by the implementation plan.",
|
|
286
|
+
],
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
id: "MS-3",
|
|
290
|
+
title: "Verification, review, and readiness",
|
|
291
|
+
description: "Collect verification evidence and review completion against the persisted definition-of-done.",
|
|
292
|
+
requirementIds: ["REQ-5", "REQ-6"],
|
|
293
|
+
acceptanceCriterionIds: ["AC-5", "AC-6"],
|
|
294
|
+
doneWhen: [
|
|
295
|
+
"Required verification gates pass or record justified blockers.",
|
|
296
|
+
"Reviewer evaluation references the persisted specification and any remaining work.",
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function buildAcceptanceCriteria(goal: string): GoalAcceptanceCriterion[] {
|
|
303
|
+
return [
|
|
304
|
+
{
|
|
305
|
+
id: "AC-1",
|
|
306
|
+
description: `The delivered software/product slice demonstrably addresses the primary user outcome implied by: ${goal}`,
|
|
307
|
+
requirementIds: ["REQ-1"],
|
|
308
|
+
verificationGateIds: ["VG-1", "VG-3"],
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
id: "AC-2",
|
|
312
|
+
description:
|
|
313
|
+
"Implementation TODOs and review evidence can be traced back to requirements, milestones, constraints, and definition-of-done IDs in this specification.",
|
|
314
|
+
requirementIds: ["REQ-1", "REQ-2"],
|
|
315
|
+
verificationGateIds: ["VG-1", "VG-4"],
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
id: "AC-3",
|
|
319
|
+
description:
|
|
320
|
+
"Primary user workflows, empty/error states where relevant, accessibility expectations, and design constraints are considered before the feature is marked complete.",
|
|
321
|
+
requirementIds: ["REQ-4"],
|
|
322
|
+
verificationGateIds: ["VG-3"],
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
id: "AC-4",
|
|
326
|
+
description:
|
|
327
|
+
"The implementation fits existing architecture, minimizes unrelated change, and preserves current pi_long_task behavior plus concrete pi_goal_task behavior.",
|
|
328
|
+
requirementIds: ["REQ-3"],
|
|
329
|
+
verificationGateIds: ["VG-2", "VG-4"],
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
id: "AC-5",
|
|
333
|
+
description:
|
|
334
|
+
"Required tests, focused checks, or manual verification evidence are recorded, and blockers are explicit if a gate cannot be run.",
|
|
335
|
+
requirementIds: ["REQ-5"],
|
|
336
|
+
verificationGateIds: ["VG-2", "VG-4"],
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
id: "AC-6",
|
|
340
|
+
description:
|
|
341
|
+
"Relevant launch, positioning, target segment, and growth metric context is available or explicitly deemed unnecessary for the first slice.",
|
|
342
|
+
requirementIds: ["REQ-6"],
|
|
343
|
+
verificationGateIds: ["VG-5"],
|
|
344
|
+
},
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function buildVerificationGates(goal: string): GoalVerificationGate[] {
|
|
349
|
+
return [
|
|
350
|
+
{
|
|
351
|
+
id: "VG-1",
|
|
352
|
+
title: "Specification persistence and traceability review",
|
|
353
|
+
description: "Confirm the software discovery specification is saved and used as downstream context.",
|
|
354
|
+
required: true,
|
|
355
|
+
successCriteria: [
|
|
356
|
+
"GOAL_SPEC.json exists for this pi_goal_task run.",
|
|
357
|
+
"The specification includes scoped requirements, milestones, acceptance criteria, verification gates, design constraints, product constraints, and definition-of-done.",
|
|
358
|
+
`The original vague goal remains traceable: ${goal}`,
|
|
359
|
+
],
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
id: "VG-2",
|
|
363
|
+
title: "Focused technical verification",
|
|
364
|
+
description:
|
|
365
|
+
"Run the most relevant project checks for the implementation slice, such as targeted tests, typechecking, linting, or smoke checks.",
|
|
366
|
+
required: true,
|
|
367
|
+
successCriteria: [
|
|
368
|
+
"Focused verification commands pass, or an explicit blocker explains why they could not be run.",
|
|
369
|
+
"Verification output is referenced in worker or reviewer results.",
|
|
370
|
+
],
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
id: "VG-3",
|
|
374
|
+
title: "Product and UX acceptance review",
|
|
375
|
+
description:
|
|
376
|
+
"Review the implemented slice against primary workflow, usability, accessibility, and design constraints.",
|
|
377
|
+
required: true,
|
|
378
|
+
successCriteria: [
|
|
379
|
+
"The primary user outcome is satisfied by observable behavior or documented implementation evidence.",
|
|
380
|
+
"Relevant accessibility and UX states are handled or explicitly scoped out.",
|
|
381
|
+
],
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
id: "VG-4",
|
|
385
|
+
title: "Architecture and regression review",
|
|
386
|
+
description:
|
|
387
|
+
"Confirm the solution is maintainable, scoped, and does not regress existing extension/task behavior.",
|
|
388
|
+
required: true,
|
|
389
|
+
successCriteria: [
|
|
390
|
+
"Changes are limited to the implementation scope described by the persisted specification.",
|
|
391
|
+
"Existing pi_long_task behavior and concrete pi_goal_task behavior remain stable unless explicitly changed.",
|
|
392
|
+
],
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
id: "VG-5",
|
|
396
|
+
title: "Launch/growth readiness check",
|
|
397
|
+
description: "For user-facing work, confirm positioning, target segment, and success metric notes are captured.",
|
|
398
|
+
required: false,
|
|
399
|
+
successCriteria: [
|
|
400
|
+
"Marketing/growth context is present for user-facing product work.",
|
|
401
|
+
"If not relevant, the reviewer can explain why this optional gate is unnecessary.",
|
|
402
|
+
],
|
|
403
|
+
},
|
|
404
|
+
];
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function buildDesignConstraints(goal: string): GoalDesignConstraints {
|
|
408
|
+
return {
|
|
409
|
+
uxPrinciples: [
|
|
410
|
+
"Optimize for the primary user workflow before secondary or administrative flows.",
|
|
411
|
+
"Prefer clear, reversible, and observable interactions over hidden automation.",
|
|
412
|
+
"Keep first-slice UX simple enough for implementation workers to verify without stakeholder interviews.",
|
|
413
|
+
],
|
|
414
|
+
uiRequirements: [
|
|
415
|
+
`Any user-facing UI for '${goal}' should use existing project components, layout conventions, and content tone where available.`,
|
|
416
|
+
"Represent loading, empty, error, and success states when the feature has asynchronous or data-dependent behavior.",
|
|
417
|
+
"Avoid introducing a new visual system unless explicitly required by the generated implementation TODOs.",
|
|
418
|
+
],
|
|
419
|
+
accessibility: [
|
|
420
|
+
"Interactive controls need accessible names, keyboard-operable behavior, and visible focus where applicable.",
|
|
421
|
+
"User-facing status, error, and completion messages should be perceivable without relying on color alone.",
|
|
422
|
+
],
|
|
423
|
+
architecturalConstraints: [
|
|
424
|
+
"Preserve pi_long_task behavior and the direct path for already-concrete pi_goal_task goals.",
|
|
425
|
+
"Use existing repository patterns before introducing new dependencies, frameworks, services, or state-management layers.",
|
|
426
|
+
"Keep TODO generation, execution, and review boundaries explicit so downstream workers can operate independently.",
|
|
427
|
+
],
|
|
428
|
+
constraints: [
|
|
429
|
+
{
|
|
430
|
+
id: "DC-1",
|
|
431
|
+
title: "Existing design system first",
|
|
432
|
+
description: "Reuse established spacing, typography, color, and component conventions from the repository.",
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
id: "DC-2",
|
|
436
|
+
title: "Accessible first slice",
|
|
437
|
+
description:
|
|
438
|
+
"Do not mark user-facing work complete without considering keyboard, screen-reader, and contrast needs.",
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
id: "DC-3",
|
|
442
|
+
title: "Minimal architectural footprint",
|
|
443
|
+
description: "Prefer small, cohesive changes that are easy for reviewers to trace to this specification.",
|
|
444
|
+
},
|
|
445
|
+
],
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function buildProductConstraints(goal: string): GoalProductConstraints {
|
|
450
|
+
return {
|
|
451
|
+
targetUsers: [
|
|
452
|
+
`Primary users or operators who need the outcome described by: ${goal}`,
|
|
453
|
+
"Implementation and review workers who need a concrete definition-of-done for the goal loop.",
|
|
454
|
+
],
|
|
455
|
+
platforms: [
|
|
456
|
+
"Existing software platform and repository surfaces implied by the goal.",
|
|
457
|
+
"Pi goal-task orchestration artifacts under the run directory.",
|
|
458
|
+
],
|
|
459
|
+
businessRules: [
|
|
460
|
+
"Only first-slice behavior required to satisfy the scoped goal should be implemented.",
|
|
461
|
+
"Out-of-scope enhancements require a later goal or explicit stakeholder decision.",
|
|
462
|
+
],
|
|
463
|
+
compliance: [
|
|
464
|
+
"Respect existing authorization, privacy, data-retention, and safety constraints present in the repository.",
|
|
465
|
+
"Do not expose secrets, credentials, private user data, or internal paths in user-facing output unless already standard for the project.",
|
|
466
|
+
],
|
|
467
|
+
dependencies: [
|
|
468
|
+
"Existing codebase APIs, tests, build tooling, and extension integration points.",
|
|
469
|
+
"Persisted goal specification availability for downstream TODO generation and review.",
|
|
470
|
+
],
|
|
471
|
+
risks: [
|
|
472
|
+
"The original goal is vague; implementation may overbuild without the persisted scope and non-goals.",
|
|
473
|
+
"Missing stakeholder details may leave open questions that should be converted into safe assumptions or blockers.",
|
|
474
|
+
"Skipping verification gates may produce a result that appears complete but fails product or regression expectations.",
|
|
475
|
+
],
|
|
476
|
+
constraints: [
|
|
477
|
+
{
|
|
478
|
+
id: "PC-1",
|
|
479
|
+
title: "Scoped first release",
|
|
480
|
+
description: "Deliver a coherent first slice rather than a broad product rewrite or speculative roadmap.",
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
id: "PC-2",
|
|
484
|
+
title: "Traceable definition-of-done",
|
|
485
|
+
description: "Completion must be judged against persisted requirements, acceptance criteria, and gates.",
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
id: "PC-3",
|
|
489
|
+
title: "Behavior compatibility",
|
|
490
|
+
description: "Avoid regressions to existing task orchestration unless explicitly required by the scope.",
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function buildMarketingGrowthContext(goal: string): GoalMarketingGrowthContext {
|
|
497
|
+
return {
|
|
498
|
+
targetSegments: [
|
|
499
|
+
`Users, teams, or operators whose workflow improves when '${goal}' is delivered.`,
|
|
500
|
+
"Early internal adopters or reviewers who can validate the first implementation slice.",
|
|
501
|
+
],
|
|
502
|
+
positioning: [
|
|
503
|
+
"A scoped software improvement with a clear first-use outcome and reviewable definition-of-done.",
|
|
504
|
+
"Avoid promising broad product transformation beyond the accepted first slice.",
|
|
505
|
+
],
|
|
506
|
+
acquisitionChannels: [
|
|
507
|
+
"Release notes, README/update documentation, in-app messaging, or internal handoff notes as appropriate.",
|
|
508
|
+
],
|
|
509
|
+
growthMetrics: [
|
|
510
|
+
"Primary workflow completion or adoption for the delivered feature.",
|
|
511
|
+
"Reduction in manual clarification needed before implementation and review.",
|
|
512
|
+
],
|
|
513
|
+
launchConsiderations: [
|
|
514
|
+
"Document any user-facing behavior changes, migration notes, or follow-up decisions before broad release.",
|
|
515
|
+
"Treat external launch execution as out of scope unless a future implementation TODO makes it explicit.",
|
|
516
|
+
],
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function buildDiscoveryConsolidation(goal: string): GoalDiscoveryConsolidation {
|
|
521
|
+
return {
|
|
522
|
+
approach:
|
|
523
|
+
"Structured software product discovery with role-specific planning outputs, consolidated into implementation-ready requirements rather than generic brainstorming.",
|
|
524
|
+
roleOutputs: [
|
|
525
|
+
{
|
|
526
|
+
role: "product_owner",
|
|
527
|
+
title: "Product Owner",
|
|
528
|
+
objective: "Define user value, first-slice scope, non-goals, and product acceptance for the vague goal.",
|
|
529
|
+
findings: [
|
|
530
|
+
`The goal '${goal}' needs a primary user outcome before implementation begins.`,
|
|
531
|
+
"Scope should emphasize one coherent product slice and preserve unresolved stakeholder questions.",
|
|
532
|
+
],
|
|
533
|
+
decisions: [
|
|
534
|
+
"Use REQ-1 as the core product outcome and AC-1 as the primary acceptance criterion.",
|
|
535
|
+
"Keep speculative expansion in OOS-1 unless future goals explicitly add it.",
|
|
536
|
+
],
|
|
537
|
+
risks: ["Implementation may overbuild if product non-goals are ignored."],
|
|
538
|
+
requirementIds: ["REQ-1", "REQ-6"],
|
|
539
|
+
milestoneIds: ["MS-1", "MS-2"],
|
|
540
|
+
acceptanceCriterionIds: ["AC-1", "AC-2", "AC-6"],
|
|
541
|
+
verificationGateIds: ["VG-1", "VG-3", "VG-5"],
|
|
542
|
+
constraintIds: ["PC-1", "PC-2"],
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
role: "project_manager",
|
|
546
|
+
title: "Project Manager",
|
|
547
|
+
objective: "Sequence delivery into milestones with dependencies, handoffs, and readiness gates.",
|
|
548
|
+
findings: [
|
|
549
|
+
"The work needs definition, implementation, and verification milestones before task workers start.",
|
|
550
|
+
"Downstream TODOs should be independently assignable and traceable to persisted IDs.",
|
|
551
|
+
],
|
|
552
|
+
decisions: [
|
|
553
|
+
"Use MS-1 for planning, MS-2 for implementation, and MS-3 for verification/readiness.",
|
|
554
|
+
"Require verification evidence before marking the goal complete.",
|
|
555
|
+
],
|
|
556
|
+
risks: ["Skipping sequencing may create TODOs that mix planning, implementation, and review responsibilities."],
|
|
557
|
+
requirementIds: ["REQ-2", "REQ-5"],
|
|
558
|
+
milestoneIds: ["MS-1", "MS-2", "MS-3"],
|
|
559
|
+
acceptanceCriterionIds: ["AC-2", "AC-5"],
|
|
560
|
+
verificationGateIds: ["VG-1", "VG-2", "VG-4"],
|
|
561
|
+
constraintIds: ["PC-2"],
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
role: "software_architect_tech_lead",
|
|
565
|
+
title: "Software Architect/Tech Lead",
|
|
566
|
+
objective:
|
|
567
|
+
"Define implementation boundaries, architecture compatibility, and technical verification expectations.",
|
|
568
|
+
findings: [
|
|
569
|
+
"The implementation plan must fit existing repository structure and preserve stable task behavior.",
|
|
570
|
+
"Technical verification should be selected from the project tooling available to workers.",
|
|
571
|
+
],
|
|
572
|
+
decisions: [
|
|
573
|
+
"Use REQ-3 and AC-4 to constrain technical design.",
|
|
574
|
+
"Make architecture/regression review a required gate.",
|
|
575
|
+
],
|
|
576
|
+
risks: ["New dependencies or rewrites could exceed the first-slice product scope."],
|
|
577
|
+
requirementIds: ["REQ-3"],
|
|
578
|
+
milestoneIds: ["MS-2"],
|
|
579
|
+
acceptanceCriterionIds: ["AC-4", "AC-5"],
|
|
580
|
+
verificationGateIds: ["VG-2", "VG-4"],
|
|
581
|
+
constraintIds: ["DC-3", "PC-3"],
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
role: "ux_ui_designer",
|
|
585
|
+
title: "UX/UI Designer",
|
|
586
|
+
objective:
|
|
587
|
+
"Translate vague product intent into workflow, UI state, accessibility, and design-system constraints.",
|
|
588
|
+
findings: [
|
|
589
|
+
"User-facing work needs explicit workflow states and accessibility expectations.",
|
|
590
|
+
"Existing design conventions should guide any first-slice UI rather than a new visual direction.",
|
|
591
|
+
],
|
|
592
|
+
decisions: [
|
|
593
|
+
"Use REQ-4 and AC-3 to keep UX/design review in scope.",
|
|
594
|
+
"Record design constraints DC-1 and DC-2 for downstream workers.",
|
|
595
|
+
],
|
|
596
|
+
risks: ["A technically complete feature may still fail if empty, error, or accessible states are omitted."],
|
|
597
|
+
requirementIds: ["REQ-4"],
|
|
598
|
+
milestoneIds: ["MS-1", "MS-2"],
|
|
599
|
+
acceptanceCriterionIds: ["AC-3"],
|
|
600
|
+
verificationGateIds: ["VG-3"],
|
|
601
|
+
constraintIds: ["DC-1", "DC-2"],
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
role: "qa_reviewer",
|
|
605
|
+
title: "QA/Reviewer",
|
|
606
|
+
objective: "Define acceptance evidence, verification gates, and review expectations before implementation.",
|
|
607
|
+
findings: [
|
|
608
|
+
"The goal loop needs a definition-of-done that reviewers can evaluate beyond the original vague goal.",
|
|
609
|
+
"Blocked or skipped checks must be explicit so remaining work is actionable.",
|
|
610
|
+
],
|
|
611
|
+
decisions: [
|
|
612
|
+
"Use REQ-5 and AC-5 to require verification evidence.",
|
|
613
|
+
"Reviewer evaluation should reference persisted requirement, acceptance, and gate IDs.",
|
|
614
|
+
],
|
|
615
|
+
risks: ["Review may falsely pass if it only checks worker summaries rather than persisted criteria."],
|
|
616
|
+
requirementIds: ["REQ-5"],
|
|
617
|
+
milestoneIds: ["MS-3"],
|
|
618
|
+
acceptanceCriterionIds: ["AC-2", "AC-5"],
|
|
619
|
+
verificationGateIds: ["VG-1", "VG-2", "VG-3", "VG-4"],
|
|
620
|
+
constraintIds: ["PC-2"],
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
role: "marketing_growth",
|
|
624
|
+
title: "Marketing/Growth",
|
|
625
|
+
objective:
|
|
626
|
+
"Capture optional launch, positioning, target segment, and success-metric context for product-facing work.",
|
|
627
|
+
findings: [
|
|
628
|
+
"Vague product goals often imply a target segment and success signal that implementation TODOs should preserve.",
|
|
629
|
+
"Launch execution can remain out of scope while launch context informs product decisions.",
|
|
630
|
+
],
|
|
631
|
+
decisions: [
|
|
632
|
+
"Use REQ-6, AC-6, and optional VG-5 for lightweight growth/readiness context.",
|
|
633
|
+
"Keep full campaign execution out of scope via OOS-2.",
|
|
634
|
+
],
|
|
635
|
+
risks: ["A useful implementation may be hard to evaluate or announce if success metrics are never captured."],
|
|
636
|
+
requirementIds: ["REQ-6"],
|
|
637
|
+
milestoneIds: ["MS-3"],
|
|
638
|
+
acceptanceCriterionIds: ["AC-6"],
|
|
639
|
+
verificationGateIds: ["VG-5"],
|
|
640
|
+
constraintIds: ["PC-1"],
|
|
641
|
+
},
|
|
642
|
+
],
|
|
643
|
+
consolidationNotes: [
|
|
644
|
+
"Role outputs were normalized into scoped requirements, milestones, acceptance criteria, verification gates, design constraints, product constraints, and marketing/growth context.",
|
|
645
|
+
"This discovery workflow is software-delivery oriented: it defines scope, build constraints, quality gates, and review criteria instead of open-ended ideation.",
|
|
646
|
+
"Downstream implementation planning should treat the persisted specification as the product definition and definition-of-done.",
|
|
647
|
+
],
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
function buildDefinitionOfDone(
|
|
652
|
+
requirementIds: string[],
|
|
653
|
+
acceptanceCriterionIds: string[],
|
|
654
|
+
requiredGateIds: string[],
|
|
655
|
+
): GoalDefinitionOfDone {
|
|
656
|
+
return {
|
|
657
|
+
summary:
|
|
658
|
+
"Done when all must/should scoped requirements are implemented or explicitly deferred, acceptance criteria are satisfied, required verification gates pass or record justified blockers, and review evaluates the result against this persisted product definition.",
|
|
659
|
+
requirementIds,
|
|
660
|
+
acceptanceCriterionIds,
|
|
661
|
+
verificationGateIds: requiredGateIds,
|
|
662
|
+
requiredArtifacts: [
|
|
663
|
+
"Persisted GOAL_SPEC.json with discovery consolidation",
|
|
664
|
+
"Implementation TODO results traceable to requirement and acceptance IDs",
|
|
665
|
+
"Focused verification output or documented blockers",
|
|
666
|
+
"Reviewer evaluation against the persisted definition-of-done",
|
|
667
|
+
],
|
|
668
|
+
notes: [
|
|
669
|
+
"REQ-6 and VG-5 are optional launch/growth context unless the implementation TODOs make them required.",
|
|
670
|
+
"The original vague goal remains available through traceability, but completion is judged against this structured specification.",
|
|
671
|
+
],
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function concreteGoalSignals(goal: string, normalized: string): string[] {
|
|
676
|
+
const signals: string[] = [];
|
|
677
|
+
if (
|
|
678
|
+
/(`[^`]+`|\b(?:src|test|tests|docs|scripts|tmp)\/|\b[\w.-]+\.(?:ts|tsx|js|jsx|mjs|cjs|json|md|css|scss|html|yml|yaml)\b)/i.test(
|
|
679
|
+
goal,
|
|
680
|
+
)
|
|
681
|
+
) {
|
|
682
|
+
signals.push("file or path reference");
|
|
683
|
+
}
|
|
684
|
+
if (/\b(?:npm|pnpm|yarn|node|tsc|eslint|vitest|jest|pytest|cargo|go test)\b|\btest(?:s|ing)?\b/.test(normalized)) {
|
|
685
|
+
signals.push("test or verification command");
|
|
686
|
+
}
|
|
687
|
+
if (/\b(?:acceptance criteria|definition of done|done when|verify|ensure that|must|should)\b/.test(normalized)) {
|
|
688
|
+
signals.push("explicit acceptance or verification criteria");
|
|
689
|
+
}
|
|
690
|
+
if (/\b(?:fix|update|modify|rename|remove|refactor|migrate|implement|add|wire|export|handle)\b/.test(normalized)) {
|
|
691
|
+
signals.push("implementation action verb");
|
|
692
|
+
}
|
|
693
|
+
if (
|
|
694
|
+
/\b(?:function|class|component|endpoint|route|api|schema|parser|config|option|flag|error|bug)\b/.test(normalized)
|
|
695
|
+
) {
|
|
696
|
+
signals.push("specific technical artifact");
|
|
697
|
+
}
|
|
698
|
+
if (/\b(?:from|to|in|inside|under|when|if|without)\b/.test(normalized) && normalized.length > 80) {
|
|
699
|
+
signals.push("implementation constraints");
|
|
700
|
+
}
|
|
701
|
+
return unique(signals);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
function vagueGoalSignals(normalized: string, wordCount: number): string[] {
|
|
705
|
+
const signals: string[] = [];
|
|
706
|
+
if (wordCount > 0 && wordCount <= 6) {
|
|
707
|
+
signals.push("short goal with limited detail");
|
|
708
|
+
}
|
|
709
|
+
if (
|
|
710
|
+
/\b(?:build|create|make|ship|improve|redesign|launch)\b.*\b(?:app|dashboard|platform|product|feature|website|tool|ui|experience|system)\b/.test(
|
|
711
|
+
normalized,
|
|
712
|
+
)
|
|
713
|
+
) {
|
|
714
|
+
signals.push("broad product or feature request");
|
|
715
|
+
}
|
|
716
|
+
if (/\b(?:better|modern|simple|nice|polished|user-friendly|awesome|clean|robust|reliable)\b/.test(normalized)) {
|
|
717
|
+
signals.push("qualitative outcome without measurable criteria");
|
|
718
|
+
}
|
|
719
|
+
if (/\b(?:something|stuff|etc|and so on|whatever)\b/.test(normalized)) {
|
|
720
|
+
signals.push("placeholder wording");
|
|
721
|
+
}
|
|
722
|
+
return unique(signals);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function explicitDiscoveryRequested(normalized: string): boolean {
|
|
726
|
+
return /\b(?:discover|discovery|scope|plan|product definition|requirements gathering)\b|\bdefine\s+(?:requirements|scope|product|project|acceptance|definition)\b/.test(
|
|
727
|
+
normalized,
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
function unique(values: string[]): string[] {
|
|
732
|
+
return [...new Set(values)];
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
function throwIfAborted(signal: AbortSignal | undefined): void {
|
|
736
|
+
if (signal?.aborted) {
|
|
737
|
+
throw new Error("Goal discovery was aborted before producing a goal specification.");
|
|
738
|
+
}
|
|
739
|
+
}
|