@papi-ai/adapter-md 0.1.0-alpha
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 +29 -0
- package/dist/index.d.ts +904 -0
- package/dist/index.js +2398 -0
- package/package.json +45 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,904 @@
|
|
|
1
|
+
import { TaskStatus as TaskStatus$1, TaskPriority as TaskPriority$1, EffortSize as EffortSize$1, ReviewStage as ReviewStage$1, ReviewVerdict as ReviewVerdict$1, TaskComplexity as TaskComplexity$1, TaskType as TaskType$1, isValidStatus as isValidStatus$1, isValidTransition as isValidTransition$1, validateTransition as validateTransition$1 } from '@papi-ai/shared';
|
|
2
|
+
|
|
3
|
+
/** Valid phase statuses in the product brief. */
|
|
4
|
+
type PhaseStatus = 'Not Started' | 'In Progress' | 'Done' | 'Deferred';
|
|
5
|
+
/** Feature lifecycle status. */
|
|
6
|
+
type FeatureStatus = 'Not Started' | 'In Progress' | 'Done' | 'Deferred';
|
|
7
|
+
/** A workstream or capability being built. Replaces Phase as the primary planning construct (AD-23). */
|
|
8
|
+
interface Feature {
|
|
9
|
+
id: string;
|
|
10
|
+
displayId: string;
|
|
11
|
+
slug: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
status: FeatureStatus;
|
|
15
|
+
roadmapPosition: number;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
completedAt?: string;
|
|
18
|
+
commitDate?: string;
|
|
19
|
+
createdSprint: number;
|
|
20
|
+
completedSprint?: number;
|
|
21
|
+
}
|
|
22
|
+
/** A development phase defined in the product brief. */
|
|
23
|
+
interface Phase {
|
|
24
|
+
id: string;
|
|
25
|
+
slug: string;
|
|
26
|
+
label: string;
|
|
27
|
+
description: string;
|
|
28
|
+
status: PhaseStatus;
|
|
29
|
+
order: number;
|
|
30
|
+
}
|
|
31
|
+
/** Sprint lifecycle status. */
|
|
32
|
+
type SprintStatus = 'planning' | 'active' | 'complete';
|
|
33
|
+
/** A sprint entity giving sprints first-class identity. */
|
|
34
|
+
/** Per-section SHA-256 hashes for context diff optimisation between sprints. */
|
|
35
|
+
interface ContextHashes {
|
|
36
|
+
productBrief?: string;
|
|
37
|
+
activeDecisions?: string;
|
|
38
|
+
reviews?: string;
|
|
39
|
+
[key: string]: string | undefined;
|
|
40
|
+
}
|
|
41
|
+
interface Sprint {
|
|
42
|
+
id: string;
|
|
43
|
+
number: number;
|
|
44
|
+
status: SprintStatus;
|
|
45
|
+
startDate: string;
|
|
46
|
+
endDate?: string;
|
|
47
|
+
goals: string[];
|
|
48
|
+
boardHealth: string;
|
|
49
|
+
taskIds: string[];
|
|
50
|
+
contextHashes?: ContextHashes;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type TaskStatus = TaskStatus$1;
|
|
54
|
+
type TaskPriority = TaskPriority$1;
|
|
55
|
+
type TaskComplexity = TaskComplexity$1;
|
|
56
|
+
type EffortSize = EffortSize$1;
|
|
57
|
+
type TaskType = TaskType$1;
|
|
58
|
+
type ReviewVerdict = ReviewVerdict$1;
|
|
59
|
+
type ReviewStage = ReviewStage$1;
|
|
60
|
+
declare const VALID_TRANSITIONS: Readonly<Record<TaskStatus, readonly TaskStatus[]>>;
|
|
61
|
+
declare const isValidTransition: typeof isValidTransition$1;
|
|
62
|
+
declare const validateTransition: typeof validateTransition$1;
|
|
63
|
+
declare const isValidStatus: typeof isValidStatus$1;
|
|
64
|
+
/**
|
|
65
|
+
* Context tiers control which tasks the planner sees:
|
|
66
|
+
* Tier 1 (Sprint-eligible): Bug, Task — fed to planner for scheduling
|
|
67
|
+
* Tier 2 (Plannable): Research — scheduled but output is knowledge not code
|
|
68
|
+
* Tier 3 (Pre-triage): Idea, Feedback — invisible to planner until promoted
|
|
69
|
+
*/
|
|
70
|
+
type ContextTier = 1 | 2 | 3;
|
|
71
|
+
/** Map task types to their context tier. */
|
|
72
|
+
declare const TASK_TYPE_TIERS: Record<TaskType, ContextTier>;
|
|
73
|
+
/** How scoped/ready a task is for scheduling. */
|
|
74
|
+
type TaskMaturity = 'raw' | 'investigated' | 'ready';
|
|
75
|
+
/** Active Decision confidence level. */
|
|
76
|
+
type Confidence = 'HIGH' | 'MEDIUM' | 'LOW';
|
|
77
|
+
/** Event types for the decision lifecycle log. */
|
|
78
|
+
type DecisionEventType = 'created' | 'confidence_changed' | 'modified' | 'superseded' | 'validated' | 'invalidated' | 'scored';
|
|
79
|
+
/** Source of a decision event. */
|
|
80
|
+
type DecisionEventSource = 'strategy_review' | 'build_complete' | 'strategy_change' | 'manual';
|
|
81
|
+
/** An append-only event in a decision's lifecycle. */
|
|
82
|
+
interface DecisionEvent {
|
|
83
|
+
id: string;
|
|
84
|
+
decisionId: string;
|
|
85
|
+
eventType: DecisionEventType;
|
|
86
|
+
sprint: number;
|
|
87
|
+
source: DecisionEventSource;
|
|
88
|
+
sourceRef?: string;
|
|
89
|
+
detail?: string;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
}
|
|
92
|
+
/** Dimensional scores for an Active Decision at a point in time. */
|
|
93
|
+
interface DecisionScore {
|
|
94
|
+
id: string;
|
|
95
|
+
decisionId: string;
|
|
96
|
+
sprint: number;
|
|
97
|
+
effort: number;
|
|
98
|
+
risk: number;
|
|
99
|
+
reversibility: number;
|
|
100
|
+
scaleCost: number;
|
|
101
|
+
lockIn: number;
|
|
102
|
+
totalScore: number;
|
|
103
|
+
rationale?: string;
|
|
104
|
+
createdAt: string;
|
|
105
|
+
}
|
|
106
|
+
/** Sprint health metadata from PLANNING_LOG.md header. */
|
|
107
|
+
interface SprintHealth {
|
|
108
|
+
totalSprints: number;
|
|
109
|
+
latestSprintStatus?: string;
|
|
110
|
+
sprintsSinceLastStrategyReview: number;
|
|
111
|
+
strategyReviewDue: string;
|
|
112
|
+
boardHealth: string;
|
|
113
|
+
strategicDirection: string;
|
|
114
|
+
lastFullMode: number;
|
|
115
|
+
}
|
|
116
|
+
/** An Active Decision (AD) tracked in the planning log. */
|
|
117
|
+
interface ActiveDecision {
|
|
118
|
+
uuid: string;
|
|
119
|
+
id: string;
|
|
120
|
+
displayId: string;
|
|
121
|
+
title: string;
|
|
122
|
+
confidence: Confidence;
|
|
123
|
+
superseded: boolean;
|
|
124
|
+
supersededBy?: string;
|
|
125
|
+
createdSprint?: number;
|
|
126
|
+
modifiedSprint?: number;
|
|
127
|
+
body: string;
|
|
128
|
+
}
|
|
129
|
+
/** A single sprint entry in the planning log. */
|
|
130
|
+
interface SprintLogEntry {
|
|
131
|
+
uuid: string;
|
|
132
|
+
sprintNumber: number;
|
|
133
|
+
title: string;
|
|
134
|
+
content: string;
|
|
135
|
+
carryForward?: string;
|
|
136
|
+
notes?: string;
|
|
137
|
+
}
|
|
138
|
+
/** A strategy review entry stored in its own table (not planning_log_entries). */
|
|
139
|
+
interface StrategyReviewEntry {
|
|
140
|
+
sprintNumber: number;
|
|
141
|
+
sprintRange?: string;
|
|
142
|
+
title: string;
|
|
143
|
+
content: string;
|
|
144
|
+
notes?: string;
|
|
145
|
+
boardHealth?: string;
|
|
146
|
+
strategicDirection?: string;
|
|
147
|
+
recommendations?: unknown;
|
|
148
|
+
createdAt?: string;
|
|
149
|
+
}
|
|
150
|
+
/** Full parsed contents of PLANNING_LOG.md. */
|
|
151
|
+
interface PlanningLog {
|
|
152
|
+
sprintHealth: SprintHealth;
|
|
153
|
+
northStar: string;
|
|
154
|
+
activeDecisions: ActiveDecision[];
|
|
155
|
+
deferred: string[];
|
|
156
|
+
sprintLog: SprintLogEntry[];
|
|
157
|
+
}
|
|
158
|
+
/** A single state transition entry recording when a task changed status. */
|
|
159
|
+
interface StateTransition {
|
|
160
|
+
status: TaskStatus;
|
|
161
|
+
timestamp: string;
|
|
162
|
+
}
|
|
163
|
+
/** A task on the sprint board (parsed from SPRINT_BOARD.md YAML). */
|
|
164
|
+
interface SprintTask {
|
|
165
|
+
uuid: string;
|
|
166
|
+
id: string;
|
|
167
|
+
displayId: string;
|
|
168
|
+
title: string;
|
|
169
|
+
status: TaskStatus;
|
|
170
|
+
priority: TaskPriority;
|
|
171
|
+
complexity: TaskComplexity;
|
|
172
|
+
module: string;
|
|
173
|
+
epic: string;
|
|
174
|
+
phase: string;
|
|
175
|
+
owner: string;
|
|
176
|
+
reviewed: boolean;
|
|
177
|
+
sprint?: number;
|
|
178
|
+
createdSprint?: number;
|
|
179
|
+
createdAt?: string;
|
|
180
|
+
why?: string;
|
|
181
|
+
dependsOn?: string;
|
|
182
|
+
notes?: string;
|
|
183
|
+
closureReason?: string;
|
|
184
|
+
stateHistory?: StateTransition[];
|
|
185
|
+
buildHandoff?: BuildHandoff;
|
|
186
|
+
buildReport?: string;
|
|
187
|
+
taskType?: TaskType;
|
|
188
|
+
maturity?: TaskMaturity;
|
|
189
|
+
}
|
|
190
|
+
/** A build report entry from BUILD_REPORTS.md. */
|
|
191
|
+
interface BuildReport {
|
|
192
|
+
uuid: string;
|
|
193
|
+
displayId?: string;
|
|
194
|
+
createdAt?: string;
|
|
195
|
+
taskId: string;
|
|
196
|
+
taskName: string;
|
|
197
|
+
date: string;
|
|
198
|
+
sprint: number;
|
|
199
|
+
completed: 'Yes' | 'No' | 'Partial';
|
|
200
|
+
actualEffort: EffortSize;
|
|
201
|
+
estimatedEffort: EffortSize;
|
|
202
|
+
surprises: string;
|
|
203
|
+
discoveredIssues: string;
|
|
204
|
+
architectureNotes: string;
|
|
205
|
+
scopeAccuracy: 'accurate' | 'over-scoped' | 'under-scoped' | 'missed-context';
|
|
206
|
+
commitSha?: string;
|
|
207
|
+
filesChanged?: string[];
|
|
208
|
+
relatedDecisions?: string[];
|
|
209
|
+
}
|
|
210
|
+
/** A single tool call metric entry from METRICS.md. */
|
|
211
|
+
interface ToolCallMetric {
|
|
212
|
+
timestamp: string;
|
|
213
|
+
tool: string;
|
|
214
|
+
durationMs: number;
|
|
215
|
+
inputTokens?: number;
|
|
216
|
+
outputTokens?: number;
|
|
217
|
+
estimatedCostUsd?: number;
|
|
218
|
+
model?: string;
|
|
219
|
+
/** Sprint number when this metric was recorded. Absent on legacy rows. */
|
|
220
|
+
sprintNumber?: number;
|
|
221
|
+
/** Context size in bytes for plan tool calls. Absent on non-plan tools. */
|
|
222
|
+
contextBytes?: number;
|
|
223
|
+
/** Context utilisation ratio (0.0–1.0). Fraction of input entities referenced in output. */
|
|
224
|
+
contextUtilisation?: number;
|
|
225
|
+
}
|
|
226
|
+
/** Per-command cost aggregation. */
|
|
227
|
+
interface CommandCost {
|
|
228
|
+
command: string;
|
|
229
|
+
totalCostUsd: number;
|
|
230
|
+
calls: number;
|
|
231
|
+
avgCostUsd: number;
|
|
232
|
+
}
|
|
233
|
+
/** Aggregated cost summary computed from tool call metrics. */
|
|
234
|
+
interface CostSummary {
|
|
235
|
+
totalCostUsd: number;
|
|
236
|
+
totalInputTokens: number;
|
|
237
|
+
totalOutputTokens: number;
|
|
238
|
+
totalCalls: number;
|
|
239
|
+
costByCommand: CommandCost[];
|
|
240
|
+
mostExpensiveCommand: string | null;
|
|
241
|
+
avgCostPerCall: number;
|
|
242
|
+
}
|
|
243
|
+
/** A cost snapshot persisted in the Cost Summary section of METRICS.md. */
|
|
244
|
+
interface CostSnapshot {
|
|
245
|
+
sprint: number;
|
|
246
|
+
date: string;
|
|
247
|
+
totalCostUsd: number;
|
|
248
|
+
totalInputTokens: number;
|
|
249
|
+
totalOutputTokens: number;
|
|
250
|
+
totalCalls: number;
|
|
251
|
+
}
|
|
252
|
+
/** An entry to be semantically clustered. */
|
|
253
|
+
interface ClusterEntry {
|
|
254
|
+
text: string;
|
|
255
|
+
source: string;
|
|
256
|
+
}
|
|
257
|
+
/** A cluster of semantically similar text entries. */
|
|
258
|
+
interface ClusterResult {
|
|
259
|
+
theme: string;
|
|
260
|
+
entries: ClusterEntry[];
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Callback that groups text entries into semantic clusters.
|
|
264
|
+
* Used by pattern detection to optionally replace normalised string matching with LLM-based clustering.
|
|
265
|
+
*/
|
|
266
|
+
type TextClusterer = (entries: ClusterEntry[]) => Promise<ClusterResult[]>;
|
|
267
|
+
/** A recurring surprise detected across build reports. */
|
|
268
|
+
interface RecurringSurprise {
|
|
269
|
+
text: string;
|
|
270
|
+
count: number;
|
|
271
|
+
sprints: number[];
|
|
272
|
+
}
|
|
273
|
+
/** Build pattern detection results from analyzing recent build reports. */
|
|
274
|
+
interface BuildPatterns {
|
|
275
|
+
recurringSurprises: RecurringSurprise[];
|
|
276
|
+
estimationBias: 'under' | 'over' | 'none';
|
|
277
|
+
estimationBiasRate: number;
|
|
278
|
+
scopeAccuracyBreakdown: Record<string, number>;
|
|
279
|
+
untriagedIssues: string[];
|
|
280
|
+
}
|
|
281
|
+
/** Per-sprint estimation accuracy stats. */
|
|
282
|
+
interface SprintEstimationAccuracy {
|
|
283
|
+
sprint: number;
|
|
284
|
+
reports: number;
|
|
285
|
+
matchRate: number;
|
|
286
|
+
mae: number;
|
|
287
|
+
bias: number;
|
|
288
|
+
}
|
|
289
|
+
/** Per-sprint velocity stats. */
|
|
290
|
+
interface SprintVelocity {
|
|
291
|
+
sprint: number;
|
|
292
|
+
completed: number;
|
|
293
|
+
partial: number;
|
|
294
|
+
failed: number;
|
|
295
|
+
effortPoints: number;
|
|
296
|
+
}
|
|
297
|
+
/** A sprint methodology metrics snapshot stored in SPRINT_METRICS.md. */
|
|
298
|
+
interface SprintMetricsSnapshot {
|
|
299
|
+
sprint: number;
|
|
300
|
+
date: string;
|
|
301
|
+
accuracy: SprintEstimationAccuracy[];
|
|
302
|
+
velocity: SprintVelocity[];
|
|
303
|
+
}
|
|
304
|
+
/** A recurring feedback theme detected across human reviews. */
|
|
305
|
+
interface RecurringFeedback {
|
|
306
|
+
text: string;
|
|
307
|
+
count: number;
|
|
308
|
+
taskIds: string[];
|
|
309
|
+
}
|
|
310
|
+
/** Review pattern detection results from analyzing recent human reviews. */
|
|
311
|
+
interface ReviewPatterns {
|
|
312
|
+
recurringFeedback: RecurringFeedback[];
|
|
313
|
+
verdictBreakdown: Record<string, number>;
|
|
314
|
+
requestChangesRate: number;
|
|
315
|
+
}
|
|
316
|
+
/** A human review entry stored in REVIEWS.md. */
|
|
317
|
+
interface HumanReview {
|
|
318
|
+
uuid: string;
|
|
319
|
+
displayId?: string;
|
|
320
|
+
taskId: string;
|
|
321
|
+
stage: ReviewStage;
|
|
322
|
+
reviewer: string;
|
|
323
|
+
verdict: ReviewVerdict;
|
|
324
|
+
sprint: number;
|
|
325
|
+
date: string;
|
|
326
|
+
comments: string;
|
|
327
|
+
handoffRevision?: number;
|
|
328
|
+
buildCommitSha?: string;
|
|
329
|
+
}
|
|
330
|
+
/** A structured BUILD HANDOFF parsed from the markdown handoff block. */
|
|
331
|
+
interface BuildHandoff {
|
|
332
|
+
uuid: string;
|
|
333
|
+
displayId?: string;
|
|
334
|
+
createdAt?: string;
|
|
335
|
+
taskId: string;
|
|
336
|
+
taskTitle: string;
|
|
337
|
+
sprint: number;
|
|
338
|
+
whyNow: string;
|
|
339
|
+
scope: string[];
|
|
340
|
+
scopeBoundary: string[];
|
|
341
|
+
acceptanceCriteria: string[];
|
|
342
|
+
securityConsiderations: string;
|
|
343
|
+
filesLikelyTouched: string[];
|
|
344
|
+
effort: EffortSize;
|
|
345
|
+
}
|
|
346
|
+
/** Module and epic registries loaded from REGISTRIES.md. */
|
|
347
|
+
interface Registries {
|
|
348
|
+
modules: string[];
|
|
349
|
+
epics: string[];
|
|
350
|
+
}
|
|
351
|
+
/** Recommendation types written by strategy_review, consumed by plan. */
|
|
352
|
+
type RecommendationType = 'priority_change' | 'new_task' | 'ad_update' | 'phase_transition' | 'process_improvement' | 'infrastructure' | 'velocity_observation';
|
|
353
|
+
/** Recommendation lifecycle status. */
|
|
354
|
+
type RecommendationStatus = 'pending' | 'actioned' | 'dismissed';
|
|
355
|
+
/** A structured strategy recommendation. */
|
|
356
|
+
interface StrategyRecommendation {
|
|
357
|
+
id: string;
|
|
358
|
+
type: RecommendationType;
|
|
359
|
+
status: RecommendationStatus;
|
|
360
|
+
content: string;
|
|
361
|
+
createdSprint: number;
|
|
362
|
+
actionedSprint?: number;
|
|
363
|
+
}
|
|
364
|
+
/** Entity reference — tracks which decisions/entities are used in tool calls. */
|
|
365
|
+
interface EntityReference {
|
|
366
|
+
id: string;
|
|
367
|
+
entityType: 'active_decision';
|
|
368
|
+
entityId: string;
|
|
369
|
+
referenceContext: 'plan_input' | 'plan_output' | 'strategy_input' | 'strategy_output';
|
|
370
|
+
toolName: string;
|
|
371
|
+
sprintNumber: number;
|
|
372
|
+
createdAt: string;
|
|
373
|
+
}
|
|
374
|
+
/** Per-AD usage summary returned by getDecisionUsage. */
|
|
375
|
+
interface DecisionUsageSummary {
|
|
376
|
+
decisionId: string;
|
|
377
|
+
referenceCount: number;
|
|
378
|
+
lastReferencedSprint: number;
|
|
379
|
+
sprintsSinceLastReference: number;
|
|
380
|
+
}
|
|
381
|
+
/** Options for updateTask to control validation behaviour. */
|
|
382
|
+
interface UpdateTaskOptions {
|
|
383
|
+
/** Skip state-machine transition validation when true. */
|
|
384
|
+
force?: boolean;
|
|
385
|
+
}
|
|
386
|
+
/** Filter options for querying the sprint board. */
|
|
387
|
+
interface BoardQueryOptions {
|
|
388
|
+
status?: TaskStatus[];
|
|
389
|
+
priority?: TaskPriority[];
|
|
390
|
+
phase?: string;
|
|
391
|
+
reviewed?: boolean;
|
|
392
|
+
module?: string;
|
|
393
|
+
epic?: string;
|
|
394
|
+
/** Filter by context tier (1=sprint-eligible, 2=plannable, 3=pre-triage). */
|
|
395
|
+
contextTier?: ContextTier;
|
|
396
|
+
}
|
|
397
|
+
/** Core adapter interface for reading/writing .papi/ markdown files. */
|
|
398
|
+
interface PapiAdapter {
|
|
399
|
+
readPlanningLog(): Promise<PlanningLog>;
|
|
400
|
+
getSprintHealth(): Promise<SprintHealth>;
|
|
401
|
+
getActiveDecisions(): Promise<ActiveDecision[]>;
|
|
402
|
+
getSprintLog(limit?: number): Promise<SprintLogEntry[]>;
|
|
403
|
+
getSprintLogSince(sprintNumber: number): Promise<SprintLogEntry[]>;
|
|
404
|
+
setSprintHealth(updates: Partial<SprintHealth>): Promise<void>;
|
|
405
|
+
writeSprintLogEntry(entry: SprintLogEntry): Promise<void>;
|
|
406
|
+
updateActiveDecision(id: string, body: string, sprintNumber?: number): Promise<void>;
|
|
407
|
+
queryBoard(options?: BoardQueryOptions): Promise<SprintTask[]>;
|
|
408
|
+
getTask(id: string): Promise<SprintTask | null>;
|
|
409
|
+
getTasks(ids: string[]): Promise<SprintTask[]>;
|
|
410
|
+
createTask(task: Omit<SprintTask, 'id'>): Promise<SprintTask>;
|
|
411
|
+
updateTask(id: string, updates: Partial<Omit<SprintTask, 'id'>>, options?: UpdateTaskOptions): Promise<void>;
|
|
412
|
+
updateTaskStatus(id: string, status: TaskStatus): Promise<void>;
|
|
413
|
+
appendBuildReport(report: BuildReport): Promise<void>;
|
|
414
|
+
getRecentBuildReports(count: number): Promise<BuildReport[]>;
|
|
415
|
+
getBuildReportsSince(sprintNumber: number): Promise<BuildReport[]>;
|
|
416
|
+
getRecentReviews(count?: number): Promise<HumanReview[]>;
|
|
417
|
+
writeReview(review: HumanReview): Promise<void>;
|
|
418
|
+
compressSprintLog(threshold: number, summary: string): Promise<void>;
|
|
419
|
+
compressBuildReports(threshold: number, summary: string): Promise<void>;
|
|
420
|
+
archiveTasks(phases: string[], statuses?: string[]): Promise<{
|
|
421
|
+
archivedCount: number;
|
|
422
|
+
taskIds: string[];
|
|
423
|
+
}>;
|
|
424
|
+
readProductBrief(): Promise<string>;
|
|
425
|
+
updateProductBrief(content: string): Promise<void>;
|
|
426
|
+
readPhases(): Promise<Phase[]>;
|
|
427
|
+
writePhases(phases: Phase[]): Promise<void>;
|
|
428
|
+
readFeatures(): Promise<Feature[]>;
|
|
429
|
+
getFeature(id: string): Promise<Feature | null>;
|
|
430
|
+
createFeature(feature: Omit<Feature, 'id'>): Promise<Feature>;
|
|
431
|
+
updateFeature(id: string, updates: Partial<Omit<Feature, 'id'>>): Promise<void>;
|
|
432
|
+
appendToolMetric(metric: ToolCallMetric): Promise<void>;
|
|
433
|
+
readToolMetrics(): Promise<ToolCallMetric[]>;
|
|
434
|
+
getCostSummary(sprintNumber?: number): Promise<CostSummary>;
|
|
435
|
+
writeCostSnapshot(snapshot: CostSnapshot): Promise<void>;
|
|
436
|
+
getCostSnapshots(): Promise<CostSnapshot[]>;
|
|
437
|
+
appendSprintMetrics(snapshot: SprintMetricsSnapshot): Promise<void>;
|
|
438
|
+
readSprintMetrics(): Promise<SprintMetricsSnapshot[]>;
|
|
439
|
+
readSprints(): Promise<Sprint[]>;
|
|
440
|
+
createSprint(sprint: Sprint): Promise<void>;
|
|
441
|
+
getContextHashes?(sprintNumber: number): Promise<Record<string, string> | null>;
|
|
442
|
+
readRegistries(): Promise<Registries>;
|
|
443
|
+
updateRegistries(registries: Registries): Promise<void>;
|
|
444
|
+
writeRecommendation(rec: Omit<StrategyRecommendation, 'id'>): Promise<StrategyRecommendation>;
|
|
445
|
+
getPendingRecommendations(): Promise<StrategyRecommendation[]>;
|
|
446
|
+
actionRecommendation(id: string, sprintNumber: number): Promise<void>;
|
|
447
|
+
appendDecisionEvent(event: Omit<DecisionEvent, 'id' | 'createdAt'>): Promise<DecisionEvent>;
|
|
448
|
+
getDecisionEvents(decisionId: string, limit?: number): Promise<DecisionEvent[]>;
|
|
449
|
+
getDecisionEventsSince(sprint: number): Promise<DecisionEvent[]>;
|
|
450
|
+
writeDecisionScore(score: Omit<DecisionScore, 'id' | 'createdAt' | 'totalScore'>): Promise<DecisionScore>;
|
|
451
|
+
getDecisionScores(decisionId: string): Promise<DecisionScore[]>;
|
|
452
|
+
getLatestDecisionScores(): Promise<DecisionScore[]>;
|
|
453
|
+
logEntityReferences(refs: Omit<EntityReference, 'id' | 'createdAt'>[]): Promise<void>;
|
|
454
|
+
getDecisionUsage(currentSprint: number): Promise<DecisionUsageSummary[]>;
|
|
455
|
+
writeStrategyReview(review: StrategyReviewEntry): Promise<void>;
|
|
456
|
+
getLastStrategyReviewSprint(): Promise<number>;
|
|
457
|
+
getStrategyReviews(limit?: number): Promise<StrategyReviewEntry[]>;
|
|
458
|
+
/**
|
|
459
|
+
* Optional: return recent task comments for plan context.
|
|
460
|
+
* Returns up to `limit` comments across all active tasks, newest first.
|
|
461
|
+
*/
|
|
462
|
+
getRecentTaskComments?(limit?: number): Promise<{
|
|
463
|
+
taskId: string;
|
|
464
|
+
author: string;
|
|
465
|
+
content: string;
|
|
466
|
+
createdAt: string;
|
|
467
|
+
}[]>;
|
|
468
|
+
/**
|
|
469
|
+
* Optional: return a lean pre-formatted plan context summary.
|
|
470
|
+
* When implemented (e.g. by pg adapter with SQL aggregates), assembleContext
|
|
471
|
+
* uses this instead of fetching full objects and formatting them.
|
|
472
|
+
* Return undefined to fall back to the default assembly path.
|
|
473
|
+
*/
|
|
474
|
+
getPlanContextSummary?(): Promise<PlanContextSummary | undefined>;
|
|
475
|
+
}
|
|
476
|
+
/** Lean plan context returned by adapters that support SQL aggregation. */
|
|
477
|
+
interface PlanContextSummary {
|
|
478
|
+
/** Compact board: id, title, status, priority, complexity, module — no handoffs/reports. */
|
|
479
|
+
board: string;
|
|
480
|
+
/** Pre-computed build intelligence: accuracy %, velocity trend, top surprises. */
|
|
481
|
+
buildIntelligence: string;
|
|
482
|
+
/** Last 3 sprint entries with carry-forward. */
|
|
483
|
+
sprintLog: string;
|
|
484
|
+
/** One-liner per active decision: id, title, confidence. */
|
|
485
|
+
activeDecisions: string;
|
|
486
|
+
}
|
|
487
|
+
/** Everything the plan write-back needs to persist in a single transaction. */
|
|
488
|
+
interface PlanWriteBackPayload {
|
|
489
|
+
/** The NEW sprint number (current + 1). */
|
|
490
|
+
sprintNumber: number;
|
|
491
|
+
/** Sprint log entry to upsert. */
|
|
492
|
+
sprintLog: SprintLogEntry;
|
|
493
|
+
/** Health updates: boardHealth, strategicDirection, etc. */
|
|
494
|
+
healthUpdates: Partial<SprintHealth>;
|
|
495
|
+
/** New tasks to create (already deduplicated by plan service). */
|
|
496
|
+
newTasks: Array<Omit<SprintTask, 'id' | 'uuid' | 'displayId'>>;
|
|
497
|
+
/** Board corrections: taskId + partial updates. */
|
|
498
|
+
boardCorrections: Array<{
|
|
499
|
+
taskId: string;
|
|
500
|
+
updates: Partial<Omit<SprintTask, 'id'>>;
|
|
501
|
+
}>;
|
|
502
|
+
/** Phases parsed from product brief update. Empty array = no phase changes. */
|
|
503
|
+
phases: Phase[];
|
|
504
|
+
/** Active Decision updates: id + new body text. */
|
|
505
|
+
activeDecisions: Array<{
|
|
506
|
+
id: string;
|
|
507
|
+
body: string;
|
|
508
|
+
}>;
|
|
509
|
+
/** IDs of pending strategy recommendations to mark as actioned. */
|
|
510
|
+
pendingRecommendationIds: string[];
|
|
511
|
+
/** Handoffs to write: taskId (may be "new-N" placeholder) + parsed handoff. */
|
|
512
|
+
handoffs: Array<{
|
|
513
|
+
taskId: string;
|
|
514
|
+
handoff: BuildHandoff;
|
|
515
|
+
}>;
|
|
516
|
+
/** Sprint entity to create. */
|
|
517
|
+
sprint: Sprint;
|
|
518
|
+
/** Whether to run feature sync from phases. */
|
|
519
|
+
featureSync: boolean;
|
|
520
|
+
/** IDs of tasks whose reviewed status should be checked before allowing priority changes. */
|
|
521
|
+
reviewedTaskIds: string[];
|
|
522
|
+
}
|
|
523
|
+
/** Result of a transactional plan write-back. */
|
|
524
|
+
interface PlanWriteBackResult {
|
|
525
|
+
/** Maps placeholder IDs ("new-1", "new-2") to real task IDs ("task-456"). */
|
|
526
|
+
newTaskIdMap: Map<string, string>;
|
|
527
|
+
/** Notes about priority changes blocked by review lock. */
|
|
528
|
+
priorityLockNotes: string[];
|
|
529
|
+
/** Non-fatal warnings (e.g. post-write verification discrepancies). */
|
|
530
|
+
warnings: string[];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** Markdown file adapter — reads/writes .papi/ directory files as structured data. */
|
|
534
|
+
declare class MdFileAdapter implements PapiAdapter {
|
|
535
|
+
private readonly dir;
|
|
536
|
+
constructor(projectDir: string);
|
|
537
|
+
/** Resolve a filename to an absolute path within the .papi/ directory. */
|
|
538
|
+
private path;
|
|
539
|
+
/** Read a .papi/ file as UTF-8 text. Throws a clear error if the file is missing. */
|
|
540
|
+
private read;
|
|
541
|
+
/** Write UTF-8 text to a .papi/ file. */
|
|
542
|
+
private write;
|
|
543
|
+
/** Parse the full planning context into structured sections (reads from PLANNING_LOG.md + ACTIVE_DECISIONS.md + SPRINT_LOG.md). */
|
|
544
|
+
readPlanningLog(): Promise<PlanningLog>;
|
|
545
|
+
/** Read the Sprint Health table from PLANNING_LOG.md. */
|
|
546
|
+
getSprintHealth(): Promise<SprintHealth>;
|
|
547
|
+
/** Read all Active Decisions from ACTIVE_DECISIONS.md. */
|
|
548
|
+
getActiveDecisions(): Promise<ActiveDecision[]>;
|
|
549
|
+
/** Read sprint log entries (newest first), optionally limited to {@link limit} entries. */
|
|
550
|
+
getSprintLog(limit?: number): Promise<SprintLogEntry[]>;
|
|
551
|
+
getSprintLogSince(sprintNumber: number): Promise<SprintLogEntry[]>;
|
|
552
|
+
/** Merge partial updates into the Sprint Health table and write back. */
|
|
553
|
+
setSprintHealth(updates: Partial<SprintHealth>): Promise<void>;
|
|
554
|
+
/** Prepend a new sprint log entry at the top of the Sprint Log section. */
|
|
555
|
+
writeSprintLogEntry(entry: SprintLogEntry): Promise<void>;
|
|
556
|
+
/** Write a strategy review — for md adapter, delegates to sprint log. */
|
|
557
|
+
writeStrategyReview(review: StrategyReviewEntry): Promise<void>;
|
|
558
|
+
/** Get the sprint number of the last strategy review. */
|
|
559
|
+
getLastStrategyReviewSprint(): Promise<number>;
|
|
560
|
+
/** Get strategy reviews — md adapter returns empty (reviews live in sprint log). */
|
|
561
|
+
getStrategyReviews(_limit?: number): Promise<StrategyReviewEntry[]>;
|
|
562
|
+
/** Update or insert an Active Decision block by ID. */
|
|
563
|
+
updateActiveDecision(id: string, body: string, sprintNumber?: number): Promise<void>;
|
|
564
|
+
/** Query the sprint board, optionally filtering by status/priority/phase/etc. */
|
|
565
|
+
queryBoard(options?: BoardQueryOptions): Promise<SprintTask[]>;
|
|
566
|
+
/** Look up a single task by ID, returning null if not found. */
|
|
567
|
+
getTask(id: string): Promise<SprintTask | null>;
|
|
568
|
+
/** Look up multiple tasks by ID in a single board read. */
|
|
569
|
+
getTasks(ids: string[]): Promise<SprintTask[]>;
|
|
570
|
+
/** Warn if a phase name doesn't match any known phase label from PRODUCT_BRIEF.md. */
|
|
571
|
+
private warnInvalidPhase;
|
|
572
|
+
/** Warn if a module name doesn't match any registered module in REGISTRIES.md. */
|
|
573
|
+
private warnInvalidModule;
|
|
574
|
+
/** Warn if an epic name doesn't match any registered epic in REGISTRIES.md. */
|
|
575
|
+
private warnInvalidEpic;
|
|
576
|
+
/** Create a new task on the board with an auto-generated sequential ID. */
|
|
577
|
+
createTask(task: Omit<SprintTask, 'id'>): Promise<SprintTask>;
|
|
578
|
+
/** Update one or more fields on an existing task. Throws if the task ID is not found. */
|
|
579
|
+
updateTask(id: string, updates: Partial<Omit<SprintTask, 'id'>>, options?: UpdateTaskOptions): Promise<void>;
|
|
580
|
+
/** Shorthand to update only the status field of a task. */
|
|
581
|
+
updateTaskStatus(id: string, status: TaskStatus): Promise<void>;
|
|
582
|
+
/** Insert a new build report at the top of BUILD_REPORTS.md. */
|
|
583
|
+
appendBuildReport(report: BuildReport): Promise<void>;
|
|
584
|
+
/** Return the most recent {@link count} build reports. */
|
|
585
|
+
getRecentBuildReports(count: number): Promise<BuildReport[]>;
|
|
586
|
+
/** Return all build reports from sprints >= {@link sprintNumber}. */
|
|
587
|
+
getBuildReportsSince(sprintNumber: number): Promise<BuildReport[]>;
|
|
588
|
+
/** Return recent human reviews from REVIEWS.md (newest first), optionally limited to {@link count}. */
|
|
589
|
+
getRecentReviews(count?: number): Promise<HumanReview[]>;
|
|
590
|
+
/** Write a new human review to REVIEWS.md. */
|
|
591
|
+
writeReview(review: HumanReview): Promise<void>;
|
|
592
|
+
/** Compress old sprint log entries below {@link threshold} into a summary block. */
|
|
593
|
+
compressSprintLog(threshold: number, summary: string): Promise<void>;
|
|
594
|
+
/** Compress old build reports below {@link threshold} into a summary block. */
|
|
595
|
+
compressBuildReports(threshold: number, summary: string): Promise<void>;
|
|
596
|
+
/** Read a .papi/ file, returning empty string if it doesn't exist. */
|
|
597
|
+
private readOptional;
|
|
598
|
+
/** Strip build_handoff and build_report from a task before archiving — these are already in BUILD_REPORTS.md. */
|
|
599
|
+
private stripHeavyFields;
|
|
600
|
+
/** Append tasks to ARCHIVE_SPRINT_BOARD.md, stripping heavy fields and deduplicating by ID. */
|
|
601
|
+
private appendToArchive;
|
|
602
|
+
/** Archive tasks matching phases and/or statuses to ARCHIVE_SPRINT_BOARD.md and remove them from active board. */
|
|
603
|
+
archiveTasks(phases: string[], statuses?: string[]): Promise<{
|
|
604
|
+
archivedCount: number;
|
|
605
|
+
taskIds: string[];
|
|
606
|
+
}>;
|
|
607
|
+
/** Read the raw PRODUCT_BRIEF.md content. */
|
|
608
|
+
readProductBrief(): Promise<string>;
|
|
609
|
+
/** Overwrite PRODUCT_BRIEF.md with new content. */
|
|
610
|
+
updateProductBrief(content: string): Promise<void>;
|
|
611
|
+
/** Read all phases from PHASES.md (falls back to PRODUCT_BRIEF.md for migration). */
|
|
612
|
+
readPhases(): Promise<Phase[]>;
|
|
613
|
+
/** Write phases to PHASES.md. */
|
|
614
|
+
writePhases(phases: Phase[]): Promise<void>;
|
|
615
|
+
/** Read all features from FEATURES.md. */
|
|
616
|
+
readFeatures(): Promise<Feature[]>;
|
|
617
|
+
/** Get a single feature by UUID. */
|
|
618
|
+
getFeature(id: string): Promise<Feature | null>;
|
|
619
|
+
/** Create a new feature and append it to FEATURES.md. */
|
|
620
|
+
createFeature(feature: Omit<Feature, 'id'>): Promise<Feature>;
|
|
621
|
+
/** Update an existing feature by UUID. */
|
|
622
|
+
updateFeature(id: string, updates: Partial<Omit<Feature, 'id'>>): Promise<void>;
|
|
623
|
+
/** Write all features to FEATURES.md. */
|
|
624
|
+
private writeFeatures;
|
|
625
|
+
/** Append a tool call metric entry to METRICS.md. */
|
|
626
|
+
appendToolMetric(metric: ToolCallMetric): Promise<void>;
|
|
627
|
+
/** Read all tool call metrics from METRICS.md. */
|
|
628
|
+
readToolMetrics(): Promise<ToolCallMetric[]>;
|
|
629
|
+
/** Aggregate tool call metrics into a cost summary, optionally filtered by sprint. */
|
|
630
|
+
getCostSummary(sprintNumber?: number): Promise<CostSummary>;
|
|
631
|
+
/** Write a cost snapshot to the Cost Summary section of METRICS.md. */
|
|
632
|
+
writeCostSnapshot(snapshot: CostSnapshot): Promise<void>;
|
|
633
|
+
/** Read all cost snapshots from the Cost Summary section of METRICS.md. */
|
|
634
|
+
getCostSnapshots(): Promise<CostSnapshot[]>;
|
|
635
|
+
/** Append a sprint metrics snapshot to SPRINT_METRICS.md. */
|
|
636
|
+
appendSprintMetrics(snapshot: SprintMetricsSnapshot): Promise<void>;
|
|
637
|
+
/** Read all sprint metrics snapshots from SPRINT_METRICS.md. */
|
|
638
|
+
readSprintMetrics(): Promise<SprintMetricsSnapshot[]>;
|
|
639
|
+
/** Read all Sprint entities from SPRINTS.md (newest first). */
|
|
640
|
+
readSprints(): Promise<Sprint[]>;
|
|
641
|
+
/** Write a new Sprint entity to SPRINTS.md. */
|
|
642
|
+
createSprint(sprint: Sprint): Promise<void>;
|
|
643
|
+
/** Read module and epic registries from REGISTRIES.md. */
|
|
644
|
+
readRegistries(): Promise<Registries>;
|
|
645
|
+
/** Overwrite REGISTRIES.md with updated registries. */
|
|
646
|
+
updateRegistries(registries: Registries): Promise<void>;
|
|
647
|
+
/**
|
|
648
|
+
* Write a new strategy recommendation to STRATEGY_RECOMMENDATIONS.md.
|
|
649
|
+
* File-based implementation stores as YAML entries.
|
|
650
|
+
*/
|
|
651
|
+
writeRecommendation(rec: Omit<StrategyRecommendation, 'id'>): Promise<StrategyRecommendation>;
|
|
652
|
+
/** Read all pending (unactioned) strategy recommendations. */
|
|
653
|
+
getPendingRecommendations(): Promise<StrategyRecommendation[]>;
|
|
654
|
+
/** Mark a recommendation as actioned. */
|
|
655
|
+
actionRecommendation(id: string, sprintNumber: number): Promise<void>;
|
|
656
|
+
appendDecisionEvent(event: Omit<DecisionEvent, 'id' | 'createdAt'>): Promise<DecisionEvent>;
|
|
657
|
+
getDecisionEvents(decisionId: string, limit?: number): Promise<DecisionEvent[]>;
|
|
658
|
+
getDecisionEventsSince(sprint: number): Promise<DecisionEvent[]>;
|
|
659
|
+
private parseDecisionEvents;
|
|
660
|
+
writeDecisionScore(score: Omit<DecisionScore, 'id' | 'createdAt' | 'totalScore'>): Promise<DecisionScore>;
|
|
661
|
+
getDecisionScores(decisionId: string): Promise<DecisionScore[]>;
|
|
662
|
+
getLatestDecisionScores(): Promise<DecisionScore[]>;
|
|
663
|
+
private parseDecisionScores;
|
|
664
|
+
logEntityReferences(_refs: Omit<EntityReference, 'id' | 'createdAt'>[]): Promise<void>;
|
|
665
|
+
getDecisionUsage(_currentSprint: number): Promise<DecisionUsageSummary[]>;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** Validate and normalise an effort string to EffortSize. Returns the value or undefined if invalid. */
|
|
669
|
+
declare function parseEffortSize(value: string): EffortSize | undefined;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Parse a BUILD HANDOFF markdown string into a structured BuildHandoff object.
|
|
673
|
+
* Returns null if the string is not a recognisable handoff block.
|
|
674
|
+
*/
|
|
675
|
+
declare function parseBuildHandoff(markdown: string): BuildHandoff | null;
|
|
676
|
+
/** Serialize a BuildHandoff object back into the standard markdown format. */
|
|
677
|
+
declare function serializeBuildHandoff(handoff: BuildHandoff): string;
|
|
678
|
+
|
|
679
|
+
/** Calculate Tier 1 sprint metrics from build reports. */
|
|
680
|
+
declare function calculateSprintMetrics(reports: BuildReport[], currentSprint: number, window?: number): {
|
|
681
|
+
accuracy: SprintEstimationAccuracy[];
|
|
682
|
+
velocity: SprintVelocity[];
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* Detect recurring patterns across build reports.
|
|
686
|
+
* Analyzes surprises, estimation bias, scope accuracy, and untriaged discovered issues.
|
|
687
|
+
* When a TextClusterer is provided, uses LLM-based semantic clustering for surprises
|
|
688
|
+
* instead of normalised string matching.
|
|
689
|
+
*/
|
|
690
|
+
declare function detectBuildPatterns(reports: BuildReport[], currentSprint: number, window?: number, clusterer?: TextClusterer): Promise<BuildPatterns>;
|
|
691
|
+
/** Returns true if the patterns contain any actionable findings. */
|
|
692
|
+
declare function hasBuildPatterns(patterns: BuildPatterns): boolean;
|
|
693
|
+
|
|
694
|
+
/** Parse REVIEWS.md content into an array of HumanReview objects (newest first). */
|
|
695
|
+
declare function parseReviews(content: string): HumanReview[];
|
|
696
|
+
/** Serialize a single HumanReview to a markdown block. */
|
|
697
|
+
declare function serializeReview(review: HumanReview): string;
|
|
698
|
+
/** Insert a new review at the top of REVIEWS.md (after the header). */
|
|
699
|
+
declare function prependReview(review: HumanReview, content: string): string;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Detect recurring patterns across human reviews.
|
|
703
|
+
* Analyzes comments for recurring feedback themes, verdict breakdown, and request-changes rate.
|
|
704
|
+
* When a TextClusterer is provided, uses LLM-based semantic clustering for feedback
|
|
705
|
+
* instead of normalised string matching.
|
|
706
|
+
*/
|
|
707
|
+
declare function detectReviewPatterns(reviews: HumanReview[], currentSprint: number, window?: number, clusterer?: TextClusterer): Promise<ReviewPatterns>;
|
|
708
|
+
/** Returns true if the patterns contain any actionable findings. */
|
|
709
|
+
declare function hasReviewPatterns(patterns: ReviewPatterns): boolean;
|
|
710
|
+
|
|
711
|
+
/** Parse METRICS.md tool call metrics table into ToolCallMetric objects. */
|
|
712
|
+
declare function parseToolMetrics(content: string): ToolCallMetric[];
|
|
713
|
+
/** Serialize a ToolCallMetric to a markdown table row. */
|
|
714
|
+
declare function serializeToolMetric(metric: ToolCallMetric): string;
|
|
715
|
+
/** Append a tool metric row to METRICS.md content. Creates the file template if content is empty. */
|
|
716
|
+
declare function appendToolMetricToContent(metric: ToolCallMetric, content: string): string;
|
|
717
|
+
/** Aggregate tool call metrics into a cost summary, optionally filtered by sprint. */
|
|
718
|
+
declare function aggregateCostSummary(metrics: ToolCallMetric[], sprintNumber?: number): CostSummary;
|
|
719
|
+
|
|
720
|
+
/** Parse the PHASES YAML section from PRODUCT_BRIEF.md content. */
|
|
721
|
+
declare function parsePhases(content: string): Phase[];
|
|
722
|
+
/** Serialize an array of phases to a YAML block. */
|
|
723
|
+
declare function serializePhases(phases: Phase[]): string;
|
|
724
|
+
/** Serialize phases and write them into the PHASES section of PRODUCT_BRIEF.md content. */
|
|
725
|
+
declare function writePhasesToContent(phases: Phase[], content: string): string;
|
|
726
|
+
|
|
727
|
+
/** Parse the FEATURES YAML section from FEATURES.md content. */
|
|
728
|
+
declare function parseFeatures(content: string): Feature[];
|
|
729
|
+
/** Serialize an array of features to a YAML block. */
|
|
730
|
+
declare function serializeFeatures(features: Feature[]): string;
|
|
731
|
+
/** Serialize features and write them into the FEATURES section of FEATURES.md content. */
|
|
732
|
+
declare function writeFeaturesToContent(features: Feature[], content: string): string;
|
|
733
|
+
|
|
734
|
+
/** Parse SPRINTS.md content into an array of Sprint objects (newest first). */
|
|
735
|
+
declare function parseSprints(content: string): Sprint[];
|
|
736
|
+
/** Serialize sprints to a complete SPRINTS.md file content. */
|
|
737
|
+
declare function serializeSprints(sprints: Sprint[], content: string): string;
|
|
738
|
+
/** Serialize a single Sprint to a YAML string (for display/export). */
|
|
739
|
+
declare function serializeSprint(sprint: Sprint): string;
|
|
740
|
+
/** Add a new sprint to SPRINTS.md (prepended to the array so newest is first). */
|
|
741
|
+
declare function prependSprint(sprint: Sprint, content: string): string;
|
|
742
|
+
|
|
743
|
+
/** Parse REGISTRIES.md content into a Registries object. */
|
|
744
|
+
declare function parseRegistries(content: string): Registries;
|
|
745
|
+
/** Serialize registries back into REGISTRIES.md content, preserving surrounding text. */
|
|
746
|
+
declare function serializeRegistries(registries: Registries, content: string): string;
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Shared entity interfaces for the cross-project layer.
|
|
750
|
+
*
|
|
751
|
+
* These types model the shared memory domain described in domain-model.md
|
|
752
|
+
* (Section: Shared Entities). Both the current MdFileAdapter and a future
|
|
753
|
+
* PgAdapter implement these same interfaces.
|
|
754
|
+
*
|
|
755
|
+
* @see docs/domain-model.md — Shared Entities
|
|
756
|
+
*/
|
|
757
|
+
/** Confidence level for shared decisions. @see domain-model.md — SharedDecision */
|
|
758
|
+
type SharedDecisionConfidence = 'low' | 'medium' | 'high';
|
|
759
|
+
/** Lifecycle status of a shared decision. @see domain-model.md — SharedDecision */
|
|
760
|
+
type SharedDecisionStatus = 'proposed' | 'accepted' | 'superseded';
|
|
761
|
+
/** Acknowledgement response status. @see domain-model.md — Acknowledgement */
|
|
762
|
+
type AcknowledgementStatus = 'pending' | 'accepted' | 'rejected';
|
|
763
|
+
/** Shared milestone lifecycle status. @see domain-model.md — SharedMilestone */
|
|
764
|
+
type SharedMilestoneStatus = 'not_started' | 'in_progress' | 'complete';
|
|
765
|
+
/** Project contribution status toward a milestone. @see domain-model.md — ProjectContribution */
|
|
766
|
+
type ProjectContributionStatus = 'blocked' | 'in_progress' | 'delivered';
|
|
767
|
+
/** Classification of a detected conflict. @see domain-model.md — ConflictAlert */
|
|
768
|
+
type ConflictType = 'direct_contradiction' | 'assumption_mismatch' | 'north_star_drift' | 'staleness';
|
|
769
|
+
/** How a conflict alert was raised. @see domain-model.md — ConflictAlert */
|
|
770
|
+
type ConflictRaisedBy = 'heuristic' | 'llm' | 'human';
|
|
771
|
+
/** Conflict alert lifecycle status. @see domain-model.md — ConflictAlert */
|
|
772
|
+
type ConflictAlertStatus = 'open' | 'acknowledged' | 'resolved';
|
|
773
|
+
/**
|
|
774
|
+
* A project registered in the shared layer.
|
|
775
|
+
* Every shared entity references a project — this is the anchor table.
|
|
776
|
+
*
|
|
777
|
+
* @see domain-model.md — Project Registry
|
|
778
|
+
*/
|
|
779
|
+
interface Project {
|
|
780
|
+
id: string;
|
|
781
|
+
slug: string;
|
|
782
|
+
name: string;
|
|
783
|
+
repo_url?: string;
|
|
784
|
+
papi_dir?: string;
|
|
785
|
+
created_at: string;
|
|
786
|
+
updated_at: string;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* A cross-project decision that requires explicit acknowledgement from each project.
|
|
790
|
+
*
|
|
791
|
+
* @see domain-model.md — SharedDecision
|
|
792
|
+
*/
|
|
793
|
+
interface SharedDecision {
|
|
794
|
+
id: string;
|
|
795
|
+
display_id: string;
|
|
796
|
+
title: string;
|
|
797
|
+
decision: string;
|
|
798
|
+
confidence: SharedDecisionConfidence;
|
|
799
|
+
status: SharedDecisionStatus;
|
|
800
|
+
origin_project_id: string;
|
|
801
|
+
evidence: string;
|
|
802
|
+
superseded_by_id?: string;
|
|
803
|
+
created_at: string;
|
|
804
|
+
updated_at: string;
|
|
805
|
+
archived_at?: string;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Join between SharedDecision and Project.
|
|
809
|
+
* Each project must explicitly respond to a shared decision.
|
|
810
|
+
*
|
|
811
|
+
* @see domain-model.md — Acknowledgement
|
|
812
|
+
*/
|
|
813
|
+
interface Acknowledgement {
|
|
814
|
+
id: string;
|
|
815
|
+
decision_id: string;
|
|
816
|
+
project_id: string;
|
|
817
|
+
status: AcknowledgementStatus;
|
|
818
|
+
comments?: string;
|
|
819
|
+
responded_at?: string;
|
|
820
|
+
created_at: string;
|
|
821
|
+
updated_at: string;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* A cross-project milestone that tracks what each project owes.
|
|
825
|
+
*
|
|
826
|
+
* @see domain-model.md — SharedMilestone
|
|
827
|
+
*/
|
|
828
|
+
interface SharedMilestone {
|
|
829
|
+
id: string;
|
|
830
|
+
title: string;
|
|
831
|
+
description: string;
|
|
832
|
+
status: SharedMilestoneStatus;
|
|
833
|
+
target_date?: string;
|
|
834
|
+
completed_at?: string;
|
|
835
|
+
created_at: string;
|
|
836
|
+
updated_at: string;
|
|
837
|
+
archived_at?: string;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Self-referencing join for milestone ordering.
|
|
841
|
+
* Records that one milestone must complete before another can proceed.
|
|
842
|
+
*
|
|
843
|
+
* @see domain-model.md — MilestoneDependency
|
|
844
|
+
*/
|
|
845
|
+
interface MilestoneDependency {
|
|
846
|
+
id: string;
|
|
847
|
+
milestone_id: string;
|
|
848
|
+
depends_on_id: string;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Join between SharedMilestone and Project.
|
|
852
|
+
* Tracks what each project owes to a milestone.
|
|
853
|
+
*
|
|
854
|
+
* @see domain-model.md — ProjectContribution
|
|
855
|
+
*/
|
|
856
|
+
interface ProjectContribution {
|
|
857
|
+
id: string;
|
|
858
|
+
milestone_id: string;
|
|
859
|
+
project_id: string;
|
|
860
|
+
status: ProjectContributionStatus;
|
|
861
|
+
required_phases: string[];
|
|
862
|
+
notes?: string;
|
|
863
|
+
delivered_at?: string;
|
|
864
|
+
created_at: string;
|
|
865
|
+
updated_at: string;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* A project's North Star statement, tracked over time.
|
|
869
|
+
* Enables drift detection when strategy reviews reveal unrecorded shifts.
|
|
870
|
+
*
|
|
871
|
+
* @see domain-model.md — NorthStar
|
|
872
|
+
*/
|
|
873
|
+
interface NorthStar {
|
|
874
|
+
id: string;
|
|
875
|
+
project_id: string;
|
|
876
|
+
statement: string;
|
|
877
|
+
set_at: string;
|
|
878
|
+
superseded_by_id?: string;
|
|
879
|
+
superseded_at?: string;
|
|
880
|
+
created_at: string;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* A detected conflict or drift between projects.
|
|
884
|
+
* Can be raised by heuristic rules, LLM reasoning, or human observation.
|
|
885
|
+
*
|
|
886
|
+
* @see domain-model.md — ConflictAlert
|
|
887
|
+
*/
|
|
888
|
+
interface ConflictAlert {
|
|
889
|
+
id: string;
|
|
890
|
+
conflict_type: ConflictType;
|
|
891
|
+
title: string;
|
|
892
|
+
description: string;
|
|
893
|
+
status: ConflictAlertStatus;
|
|
894
|
+
decision_a_id?: string;
|
|
895
|
+
decision_b_id?: string;
|
|
896
|
+
north_star_id?: string;
|
|
897
|
+
resolution_decision_id?: string;
|
|
898
|
+
raised_by: ConflictRaisedBy;
|
|
899
|
+
created_at: string;
|
|
900
|
+
updated_at: string;
|
|
901
|
+
resolved_at?: string;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
export { type Acknowledgement, type AcknowledgementStatus, type ActiveDecision, type BoardQueryOptions, type BuildHandoff, type BuildPatterns, type BuildReport, type ClusterEntry, type ClusterResult, type CommandCost, type Confidence, type ConflictAlert, type ConflictAlertStatus, type ConflictRaisedBy, type ConflictType, type ContextHashes, type ContextTier, type CostSnapshot, type CostSummary, type DecisionEvent, type DecisionEventSource, type DecisionEventType, type DecisionScore, type DecisionUsageSummary, type EffortSize, type EntityReference, type Feature, type FeatureStatus, type HumanReview, MdFileAdapter, type MilestoneDependency, type NorthStar, type PapiAdapter, type Phase, type PhaseStatus, type PlanContextSummary, type PlanWriteBackPayload, type PlanWriteBackResult, type PlanningLog, type Project, type ProjectContribution, type ProjectContributionStatus, type RecommendationStatus, type RecommendationType, type RecurringFeedback, type RecurringSurprise, type Registries, type ReviewPatterns, type ReviewStage, type ReviewVerdict, type SharedDecision, type SharedDecisionConfidence, type SharedDecisionStatus, type SharedMilestone, type SharedMilestoneStatus, type Sprint, type SprintEstimationAccuracy, type SprintHealth, type SprintLogEntry, type SprintMetricsSnapshot, type SprintStatus, type SprintTask, type SprintVelocity, type StateTransition, type StrategyRecommendation, type StrategyReviewEntry, TASK_TYPE_TIERS, type TaskComplexity, type TaskMaturity, type TaskPriority, type TaskStatus, type TaskType, type TextClusterer, type ToolCallMetric, type UpdateTaskOptions, VALID_TRANSITIONS, aggregateCostSummary, appendToolMetricToContent, calculateSprintMetrics, detectBuildPatterns, detectReviewPatterns, hasBuildPatterns, hasReviewPatterns, isValidStatus, isValidTransition, parseBuildHandoff, parseEffortSize, parseFeatures, parsePhases, parseRegistries, parseReviews, parseSprints, parseToolMetrics, prependReview, prependSprint, serializeBuildHandoff, serializeFeatures, serializePhases, serializeRegistries, serializeReview, serializeSprint, serializeSprints, serializeToolMetric, validateTransition, writeFeaturesToContent, writePhasesToContent };
|