@webpresso/agent-kit 0.21.0 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/_run.js +2 -1
- package/catalog/agent/rules/changeset-release.md +5 -3
- package/dist/esm/audit/repo-guardrails.js +2 -1
- package/dist/esm/blueprint/core/schema.d.ts +1 -1
- package/dist/esm/blueprint/db/enums.d.ts +1 -1
- package/dist/esm/blueprint/execution/progress-bridge.js +2 -2
- package/dist/esm/blueprint/graph/schema.d.ts +3 -3
- package/dist/esm/build/package-manifest.d.ts +13 -0
- package/dist/esm/build/package-manifest.js +165 -0
- package/dist/esm/cli/commands/bench/session-memory.js +1 -1
- package/dist/esm/config/docs-lint/schemas/agents.d.ts +2 -2
- package/dist/esm/config/docs-lint/schemas/audit.d.ts +3 -3
- package/dist/esm/config/docs-lint/schemas/common.d.ts +1 -1
- package/dist/esm/config/docs-lint/schemas/cookbook.d.ts +1 -1
- package/dist/esm/config/docs-lint/schemas/core.d.ts +7 -7
- package/dist/esm/config/docs-lint/schemas/draft.d.ts +2 -2
- package/dist/esm/config/docs-lint/schemas/evaluation.d.ts +1 -1
- package/dist/esm/config/docs-lint/schemas/ongoing-initiative.d.ts +2 -2
- package/dist/esm/config/docs-lint/schemas/rule.d.ts +1 -1
- package/dist/esm/mcp/blueprint-server.js +1 -1
- package/dist/esm/mcp/runners/test.js +1 -1
- package/package.json +1 -1
- package/dist/esm/ai-prompts/business-canvas.d.ts +0 -52
- package/dist/esm/ai-prompts/business-canvas.js +0 -292
- package/dist/esm/ai-prompts/circuit-breaker.d.ts +0 -35
- package/dist/esm/ai-prompts/circuit-breaker.js +0 -171
- package/dist/esm/ai-prompts/experiment-draft.d.ts +0 -86
- package/dist/esm/ai-prompts/experiment-draft.js +0 -188
- package/dist/esm/ai-prompts/index.d.ts +0 -12
- package/dist/esm/ai-prompts/index.js +0 -11
- package/dist/esm/ai-prompts/persona-context.d.ts +0 -70
- package/dist/esm/ai-prompts/persona-context.js +0 -158
- package/dist/esm/ai-prompts/persona-debate.d.ts +0 -67
- package/dist/esm/ai-prompts/persona-debate.js +0 -172
- package/dist/esm/ai-prompts/persona-tools.d.ts +0 -26
- package/dist/esm/ai-prompts/persona-tools.js +0 -172
- package/dist/esm/ai-prompts/personas.d.ts +0 -16
- package/dist/esm/ai-prompts/personas.js +0 -492
- package/dist/esm/ai-prompts/rachel-planning.d.ts +0 -28
- package/dist/esm/ai-prompts/rachel-planning.js +0 -217
- package/dist/esm/ai-prompts/task-analysis.d.ts +0 -49
- package/dist/esm/ai-prompts/task-analysis.js +0 -434
- package/dist/esm/ai-prompts/types.d.ts +0 -3
- package/dist/esm/ai-prompts/types.js +0 -2
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Experiment draft generation from analytics signals
|
|
3
|
-
*
|
|
4
|
-
* Converts analytics data into structured experiment drafts with
|
|
5
|
-
* hypothesis, primary metric, guardrails, and rollout plan.
|
|
6
|
-
*/
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// Signal analysis
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
/**
|
|
11
|
-
* Compute urgency score for a signal.
|
|
12
|
-
* Higher = more urgent to experiment on.
|
|
13
|
-
*/
|
|
14
|
-
export function computeSignalUrgency(signal) {
|
|
15
|
-
if (signal.previousValue === 0 && signal.currentValue === 0)
|
|
16
|
-
return 0;
|
|
17
|
-
const deltaPercent = Math.abs((signal.currentValue - signal.previousValue) /
|
|
18
|
-
Math.max(Math.abs(signal.previousValue), Number.EPSILON));
|
|
19
|
-
const trendMultiplier = signal.trend === 'declining' ? 2 : signal.trend === 'improving' ? 0.5 : 0.1;
|
|
20
|
-
const sampleConfidence = Math.min(signal.sampleSize / 1000, 1);
|
|
21
|
-
return deltaPercent * trendMultiplier * sampleConfidence;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Select the primary signal to experiment on.
|
|
25
|
-
* Prefers declining signals with largest delta.
|
|
26
|
-
*/
|
|
27
|
-
export function selectPrimarySignal(signals) {
|
|
28
|
-
if (signals.length === 0) {
|
|
29
|
-
throw new Error('No analytics signals provided');
|
|
30
|
-
}
|
|
31
|
-
const scored = signals
|
|
32
|
-
.map((s) => ({ signal: s, score: computeSignalUrgency(s) }))
|
|
33
|
-
.toSorted((a, b) => b.score - a.score);
|
|
34
|
-
return scored[0].signal;
|
|
35
|
-
}
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
// Prompt building
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
/**
|
|
40
|
-
* Build the LLM prompt for experiment draft generation.
|
|
41
|
-
*/
|
|
42
|
-
export function buildExperimentDraftPrompt(input) {
|
|
43
|
-
const primary = selectPrimarySignal(input.signals);
|
|
44
|
-
const signalDescriptions = input.signals
|
|
45
|
-
.map((s) => {
|
|
46
|
-
const delta = s.previousValue !== 0
|
|
47
|
-
? (((s.currentValue - s.previousValue) / Math.abs(s.previousValue)) * 100).toFixed(1)
|
|
48
|
-
: 'N/A';
|
|
49
|
-
return `- ${s.metricName}: ${s.currentValue} (was ${s.previousValue}, ${delta}% change, trend: ${s.trend}, sample: ${s.sampleSize} over ${s.periodDays} days)`;
|
|
50
|
-
})
|
|
51
|
-
.join('\n');
|
|
52
|
-
const existingFlagsSection = input.existingFlagKeys && input.existingFlagKeys.length > 0
|
|
53
|
-
? `\n<existing_flags>\n${input.existingFlagKeys.join(', ')}\n</existing_flags>\nDo NOT propose experiments for these existing flag keys.`
|
|
54
|
-
: '';
|
|
55
|
-
return `You are an experimentation engineer analyzing analytics signals for project "${input.projectName}".
|
|
56
|
-
|
|
57
|
-
<analytics_signals>
|
|
58
|
-
${signalDescriptions}
|
|
59
|
-
</analytics_signals>
|
|
60
|
-
|
|
61
|
-
Primary concern: ${primary.metricName} (trend: ${primary.trend}, sample: ${primary.sampleSize})
|
|
62
|
-
${existingFlagsSection}
|
|
63
|
-
|
|
64
|
-
<instructions>
|
|
65
|
-
Based on these analytics signals, propose a concrete experiment draft. The experiment should:
|
|
66
|
-
1. Address the most impactful signal (especially declining metrics)
|
|
67
|
-
2. Have a clear, testable hypothesis
|
|
68
|
-
3. Define primary metric and guardrails
|
|
69
|
-
4. Include a safe rollout plan with milestones
|
|
70
|
-
5. Estimate confidence and expected impact
|
|
71
|
-
|
|
72
|
-
Respond in JSON format only:
|
|
73
|
-
{
|
|
74
|
-
"name": "Short experiment name",
|
|
75
|
-
"hypothesis": "If we [change], then [metric] will [improve] because [reasoning]",
|
|
76
|
-
"primaryMetric": "metric_name",
|
|
77
|
-
"guardrails": [
|
|
78
|
-
{ "metricName": "error_rate", "operator": "lt", "threshold": 0.05 }
|
|
79
|
-
],
|
|
80
|
-
"variants": [
|
|
81
|
-
{ "name": "control", "description": "Current behavior", "isControl": true },
|
|
82
|
-
{ "name": "treatment", "description": "Proposed change", "isControl": false }
|
|
83
|
-
],
|
|
84
|
-
"rolloutPlan": {
|
|
85
|
-
"initialPercentage": 10,
|
|
86
|
-
"milestones": [
|
|
87
|
-
{ "percentage": 25, "criteria": "No guardrail violations after 48h" },
|
|
88
|
-
{ "percentage": 50, "criteria": "Primary metric shows improvement after 7 days" }
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
|
-
"rationale": "Why this experiment is worth running",
|
|
92
|
-
"confidence": 0.75,
|
|
93
|
-
"estimatedImpact": "Expected impact range on the primary metric"
|
|
94
|
-
}
|
|
95
|
-
</instructions>`;
|
|
96
|
-
}
|
|
97
|
-
// ---------------------------------------------------------------------------
|
|
98
|
-
// Response parsing
|
|
99
|
-
// ---------------------------------------------------------------------------
|
|
100
|
-
const VALID_OPERATORS = new Set(['lt', 'lte', 'gt', 'gte']);
|
|
101
|
-
/**
|
|
102
|
-
* Parse and validate an LLM response into an ExperimentDraft.
|
|
103
|
-
* Returns null if the response is invalid or incomplete.
|
|
104
|
-
*/
|
|
105
|
-
export function parseExperimentDraftResponse(response) {
|
|
106
|
-
const jsonMatch = response.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
107
|
-
const jsonStr = jsonMatch?.[1]?.trim() ?? response.trim();
|
|
108
|
-
let parsed;
|
|
109
|
-
try {
|
|
110
|
-
parsed = JSON.parse(jsonStr);
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
if (!parsed.name || typeof parsed.name !== 'string')
|
|
116
|
-
return null;
|
|
117
|
-
if (!parsed.hypothesis || typeof parsed.hypothesis !== 'string')
|
|
118
|
-
return null;
|
|
119
|
-
if (!parsed.primaryMetric || typeof parsed.primaryMetric !== 'string')
|
|
120
|
-
return null;
|
|
121
|
-
// Validate variants
|
|
122
|
-
if (!Array.isArray(parsed.variants) || parsed.variants.length === 0)
|
|
123
|
-
return null;
|
|
124
|
-
const variants = [];
|
|
125
|
-
for (const v of parsed.variants) {
|
|
126
|
-
if (!v || typeof v !== 'object')
|
|
127
|
-
return null;
|
|
128
|
-
const obj = v;
|
|
129
|
-
if (typeof obj.name !== 'string' ||
|
|
130
|
-
typeof obj.description !== 'string' ||
|
|
131
|
-
typeof obj.isControl !== 'boolean') {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
variants.push({ name: obj.name, description: obj.description, isControl: obj.isControl });
|
|
135
|
-
}
|
|
136
|
-
const hasControl = variants.some((v) => v.isControl);
|
|
137
|
-
if (!hasControl)
|
|
138
|
-
return null;
|
|
139
|
-
// Validate guardrails
|
|
140
|
-
const guardrails = [];
|
|
141
|
-
if (Array.isArray(parsed.guardrails)) {
|
|
142
|
-
for (const g of parsed.guardrails) {
|
|
143
|
-
if (!g || typeof g !== 'object')
|
|
144
|
-
continue;
|
|
145
|
-
const obj = g;
|
|
146
|
-
if (typeof obj.metricName !== 'string' ||
|
|
147
|
-
typeof obj.operator !== 'string' ||
|
|
148
|
-
typeof obj.threshold !== 'number') {
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const operator = obj.operator.toLowerCase();
|
|
152
|
-
if (!VALID_OPERATORS.has(operator))
|
|
153
|
-
continue;
|
|
154
|
-
guardrails.push({ metricName: obj.metricName, operator, threshold: obj.threshold });
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
// Validate rollout plan
|
|
158
|
-
const rawPlan = parsed.rolloutPlan;
|
|
159
|
-
const initialPercentage = typeof rawPlan?.initialPercentage === 'number'
|
|
160
|
-
? Math.max(1, Math.min(100, rawPlan.initialPercentage))
|
|
161
|
-
: 10;
|
|
162
|
-
const milestones = [];
|
|
163
|
-
if (Array.isArray(rawPlan?.milestones)) {
|
|
164
|
-
for (const m of rawPlan.milestones) {
|
|
165
|
-
if (!m || typeof m !== 'object')
|
|
166
|
-
continue;
|
|
167
|
-
const obj = m;
|
|
168
|
-
if (typeof obj.percentage === 'number' && typeof obj.criteria === 'string') {
|
|
169
|
-
milestones.push({ percentage: obj.percentage, criteria: obj.criteria });
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// Clamp confidence
|
|
174
|
-
let confidence = typeof parsed.confidence === 'number' ? parsed.confidence : 0.5;
|
|
175
|
-
confidence = Math.max(0, Math.min(1, confidence));
|
|
176
|
-
return {
|
|
177
|
-
name: parsed.name,
|
|
178
|
-
hypothesis: parsed.hypothesis,
|
|
179
|
-
primaryMetric: parsed.primaryMetric,
|
|
180
|
-
guardrails,
|
|
181
|
-
variants,
|
|
182
|
-
rolloutPlan: { initialPercentage, milestones },
|
|
183
|
-
rationale: typeof parsed.rationale === 'string' ? parsed.rationale : '',
|
|
184
|
-
confidence,
|
|
185
|
-
estimatedImpact: typeof parsed.estimatedImpact === 'string' ? parsed.estimatedImpact : 'Unknown',
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=experiment-draft.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { AGENT_PERSONAS } from './types.js';
|
|
2
|
-
export type { AgentPersona } from './types.js';
|
|
3
|
-
export { BUSINESS_CANVAS_SYSTEM_PROMPT, BUSINESS_CANVAS_USER_PROMPT, isValidBusinessCanvas, parseBusinessCanvas, type BusinessCanvas, type FeatureProposal, type MarketResearch, type ParsedSteveResponse, type SuccessMetric, type TargetAudience, type ViabilityDecision, } from './business-canvas.js';
|
|
4
|
-
export { BAZIL_PROMPT, JERAMY_PROMPT, OZBY_PROMPT, PERSONA_PROMPTS, RACHEL_PROMPT, RODRIGO_PROMPT, VOLKER_PROMPT, } from './personas.js';
|
|
5
|
-
export { formatPersonaContext, getPersonaContextHeader, type BusinessContext, type EngineeringContext, type PersonaContext, type ProductContext, } from './persona-context.js';
|
|
6
|
-
export { addContribution, calculateConsensus, createDebateState, DEBATE_PROMPTS, DEFAULT_DEBATE_CONFIG, finalizeDebate, generateDebateId, parseConfidence, parsePosition, shouldContinueDebate, startNewRound, type AgentContribution, type DebateConfig, type DebateOutcome, type DebateRound, type DebateState, type DebateType, } from './persona-debate.js';
|
|
7
|
-
export { ALL_TOOLS, filterToolsForPersona, getPersonaToolDescription, getRestrictedToolsForPersona, isToolAllowedForPersona, PERSONA_TOOL_CONFIG, TOOL_CATEGORIES, type PersonaToolConfig, type ToolName, } from './persona-tools.js';
|
|
8
|
-
export { calculateSimilarity, checkCircuitBreaker, checkForHallucinationLoop, createCircuitBreakerLog, createCircuitBreakerState, DEFAULT_CIRCUIT_BREAKER_CONFIG, flagForHumanReview, requiresHumanReview, updateSimilarity, updateTokens, type CircuitBreakerCheckResult, type CircuitBreakerConfig, type CircuitBreakerState, type CircuitBreakerTripReason, } from './circuit-breaker.js';
|
|
9
|
-
export { getRachelPromptForGranularity, GRANULARITY_INSTRUCTIONS, isNonEmptyString, isValidTechBreakdown, parseRachelBreakdown, RACHEL_FEATURE_PROMPT, RACHEL_PLANNING_PROMPT, type Complexity, type ComponentType, type ParsedRachelResponse, type TechBreakdown, type TechComponent, } from './rachel-planning.js';
|
|
10
|
-
export { AGENT_FOCUS_AREAS, AGENT_SUGGESTED_FIELDS, buildTaskAnalysisPrompt, parseTaskAnalysisResponse, TASK_ANALYSIS_PROMPTS, type SuggestedFields, type TaskAnalysisResponse, type TaskContext, } from './task-analysis.js';
|
|
11
|
-
export { buildExperimentDraftPrompt, computeSignalUrgency, parseExperimentDraftResponse, selectPrimarySignal, type AnalyticsSignal, type DraftDisposition, type ExperimentDecisionEvent, type ExperimentDraft, type ExperimentDraftInput, type GuardrailDraft, type RolloutMilestone, type RolloutPlan, type VariantDraft, } from './experiment-draft.js';
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { AGENT_PERSONAS } from './types.js';
|
|
2
|
-
export { BUSINESS_CANVAS_SYSTEM_PROMPT, BUSINESS_CANVAS_USER_PROMPT, isValidBusinessCanvas, parseBusinessCanvas, } from './business-canvas.js';
|
|
3
|
-
export { BAZIL_PROMPT, JERAMY_PROMPT, OZBY_PROMPT, PERSONA_PROMPTS, RACHEL_PROMPT, RODRIGO_PROMPT, VOLKER_PROMPT, } from './personas.js';
|
|
4
|
-
export { formatPersonaContext, getPersonaContextHeader, } from './persona-context.js';
|
|
5
|
-
export { addContribution, calculateConsensus, createDebateState, DEBATE_PROMPTS, DEFAULT_DEBATE_CONFIG, finalizeDebate, generateDebateId, parseConfidence, parsePosition, shouldContinueDebate, startNewRound, } from './persona-debate.js';
|
|
6
|
-
export { ALL_TOOLS, filterToolsForPersona, getPersonaToolDescription, getRestrictedToolsForPersona, isToolAllowedForPersona, PERSONA_TOOL_CONFIG, TOOL_CATEGORIES, } from './persona-tools.js';
|
|
7
|
-
export { calculateSimilarity, checkCircuitBreaker, checkForHallucinationLoop, createCircuitBreakerLog, createCircuitBreakerState, DEFAULT_CIRCUIT_BREAKER_CONFIG, flagForHumanReview, requiresHumanReview, updateSimilarity, updateTokens, } from './circuit-breaker.js';
|
|
8
|
-
export { getRachelPromptForGranularity, GRANULARITY_INSTRUCTIONS, isNonEmptyString, isValidTechBreakdown, parseRachelBreakdown, RACHEL_FEATURE_PROMPT, RACHEL_PLANNING_PROMPT, } from './rachel-planning.js';
|
|
9
|
-
export { AGENT_FOCUS_AREAS, AGENT_SUGGESTED_FIELDS, buildTaskAnalysisPrompt, parseTaskAnalysisResponse, TASK_ANALYSIS_PROMPTS, } from './task-analysis.js';
|
|
10
|
-
export { buildExperimentDraftPrompt, computeSignalUrgency, parseExperimentDraftResponse, selectPrimarySignal, } from './experiment-draft.js';
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { AgentPersona } from './types.js';
|
|
2
|
-
export interface BusinessContext {
|
|
3
|
-
mrr?: number;
|
|
4
|
-
arr?: number;
|
|
5
|
-
mau?: number;
|
|
6
|
-
dau?: number;
|
|
7
|
-
cac?: number;
|
|
8
|
-
ltv?: number;
|
|
9
|
-
churnRate?: number;
|
|
10
|
-
conversionRate?: number;
|
|
11
|
-
growth?: {
|
|
12
|
-
mrrGrowth?: number;
|
|
13
|
-
userGrowth?: number;
|
|
14
|
-
period?: string;
|
|
15
|
-
};
|
|
16
|
-
competitors?: string[];
|
|
17
|
-
priorities?: string[];
|
|
18
|
-
}
|
|
19
|
-
export interface ProductContext {
|
|
20
|
-
nps?: number;
|
|
21
|
-
csat?: number;
|
|
22
|
-
feedbackThemes?: Array<{
|
|
23
|
-
theme: string;
|
|
24
|
-
count: number;
|
|
25
|
-
sentiment: 'positive' | 'neutral' | 'negative';
|
|
26
|
-
}>;
|
|
27
|
-
featureRequests?: Array<{
|
|
28
|
-
title: string;
|
|
29
|
-
votes: number;
|
|
30
|
-
status: 'open' | 'planned' | 'in_progress' | 'completed';
|
|
31
|
-
}>;
|
|
32
|
-
funnelMetrics?: Array<{
|
|
33
|
-
step: string;
|
|
34
|
-
dropOffRate: number;
|
|
35
|
-
}>;
|
|
36
|
-
accessibilityScore?: number;
|
|
37
|
-
supportThemes?: string[];
|
|
38
|
-
userPersonas?: string[];
|
|
39
|
-
}
|
|
40
|
-
export interface EngineeringContext {
|
|
41
|
-
testCoverage?: number;
|
|
42
|
-
lintErrors?: number;
|
|
43
|
-
typeErrors?: number;
|
|
44
|
-
techDebt?: Array<{
|
|
45
|
-
description: string;
|
|
46
|
-
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
47
|
-
file?: string;
|
|
48
|
-
}>;
|
|
49
|
-
vulnerabilities?: Array<{
|
|
50
|
-
package: string;
|
|
51
|
-
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
52
|
-
fixAvailable: boolean;
|
|
53
|
-
}>;
|
|
54
|
-
errorRate?: number;
|
|
55
|
-
performance?: {
|
|
56
|
-
p50Latency?: number;
|
|
57
|
-
p95Latency?: number;
|
|
58
|
-
p99Latency?: number;
|
|
59
|
-
};
|
|
60
|
-
buildStatus?: 'passing' | 'failing' | 'unknown';
|
|
61
|
-
openPRs?: number;
|
|
62
|
-
}
|
|
63
|
-
export interface PersonaContext {
|
|
64
|
-
business?: BusinessContext;
|
|
65
|
-
product?: ProductContext;
|
|
66
|
-
engineering?: EngineeringContext;
|
|
67
|
-
}
|
|
68
|
-
export declare function formatPersonaContext(persona: AgentPersona, context: PersonaContext): string | undefined;
|
|
69
|
-
export declare function getPersonaContextHeader(persona: AgentPersona): string;
|
|
70
|
-
//# sourceMappingURL=persona-context.d.ts.map
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { match } from 'ts-pattern';
|
|
2
|
-
function addBusinessGrowthMetrics(lines, growth) {
|
|
3
|
-
if (!growth)
|
|
4
|
-
return;
|
|
5
|
-
lines.push('Growth:');
|
|
6
|
-
if (growth.mrrGrowth !== undefined)
|
|
7
|
-
lines.push(` - MRR Growth: ${growth.mrrGrowth}%`);
|
|
8
|
-
if (growth.userGrowth !== undefined)
|
|
9
|
-
lines.push(` - User Growth: ${growth.userGrowth}%`);
|
|
10
|
-
if (growth.period)
|
|
11
|
-
lines.push(` - Period: ${growth.period}`);
|
|
12
|
-
}
|
|
13
|
-
function addBusinessMetrics(lines, ctx) {
|
|
14
|
-
if (ctx.mrr !== undefined)
|
|
15
|
-
lines.push(`MRR: $${ctx.mrr.toLocaleString()}`);
|
|
16
|
-
if (ctx.arr !== undefined)
|
|
17
|
-
lines.push(`ARR: $${ctx.arr.toLocaleString()}`);
|
|
18
|
-
if (ctx.mau !== undefined)
|
|
19
|
-
lines.push(`MAU: ${ctx.mau.toLocaleString()}`);
|
|
20
|
-
if (ctx.dau !== undefined)
|
|
21
|
-
lines.push(`DAU: ${ctx.dau.toLocaleString()}`);
|
|
22
|
-
if (ctx.cac !== undefined)
|
|
23
|
-
lines.push(`CAC: $${ctx.cac}`);
|
|
24
|
-
if (ctx.ltv !== undefined)
|
|
25
|
-
lines.push(`LTV: $${ctx.ltv}`);
|
|
26
|
-
if (ctx.churnRate !== undefined)
|
|
27
|
-
lines.push(`Churn Rate: ${ctx.churnRate}%`);
|
|
28
|
-
if (ctx.conversionRate !== undefined)
|
|
29
|
-
lines.push(`Conversion Rate: ${ctx.conversionRate}%`);
|
|
30
|
-
}
|
|
31
|
-
function addBusinessPriorities(lines, priorities) {
|
|
32
|
-
if (!priorities?.length)
|
|
33
|
-
return;
|
|
34
|
-
lines.push('Strategic Priorities:');
|
|
35
|
-
for (const priority of priorities) {
|
|
36
|
-
lines.push(` - ${priority}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function formatBusinessContext(ctx) {
|
|
40
|
-
const lines = ['<business_context>'];
|
|
41
|
-
addBusinessMetrics(lines, ctx);
|
|
42
|
-
addBusinessGrowthMetrics(lines, ctx.growth);
|
|
43
|
-
if (ctx.competitors?.length) {
|
|
44
|
-
lines.push(`Competitors: ${ctx.competitors.join(', ')}`);
|
|
45
|
-
}
|
|
46
|
-
addBusinessPriorities(lines, ctx.priorities);
|
|
47
|
-
lines.push('</business_context>');
|
|
48
|
-
return lines.join('\n');
|
|
49
|
-
}
|
|
50
|
-
function addFeedbackThemes(lines, feedbackThemes) {
|
|
51
|
-
if (!feedbackThemes?.length)
|
|
52
|
-
return;
|
|
53
|
-
lines.push('User Feedback Themes:');
|
|
54
|
-
for (const theme of feedbackThemes) {
|
|
55
|
-
lines.push(` - ${theme.theme} (${theme.count} mentions, ${theme.sentiment})`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function addFeatureRequests(lines, featureRequests) {
|
|
59
|
-
if (!featureRequests?.length)
|
|
60
|
-
return;
|
|
61
|
-
lines.push('Top Feature Requests:');
|
|
62
|
-
for (const req of featureRequests.slice(0, 5)) {
|
|
63
|
-
lines.push(` - ${req.title} (${req.votes} votes, ${req.status})`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function addFunnelMetrics(lines, funnelMetrics) {
|
|
67
|
-
if (!funnelMetrics?.length)
|
|
68
|
-
return;
|
|
69
|
-
lines.push('Funnel Drop-off Rates:');
|
|
70
|
-
for (const step of funnelMetrics) {
|
|
71
|
-
lines.push(` - ${step.step}: ${step.dropOffRate}%`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function formatProductContext(ctx) {
|
|
75
|
-
const lines = ['<product_context>'];
|
|
76
|
-
if (ctx.nps !== undefined)
|
|
77
|
-
lines.push(`NPS Score: ${ctx.nps}`);
|
|
78
|
-
if (ctx.csat !== undefined)
|
|
79
|
-
lines.push(`CSAT Score: ${ctx.csat}`);
|
|
80
|
-
if (ctx.accessibilityScore !== undefined)
|
|
81
|
-
lines.push(`Accessibility Score: ${ctx.accessibilityScore}/100`);
|
|
82
|
-
addFeedbackThemes(lines, ctx.feedbackThemes);
|
|
83
|
-
addFeatureRequests(lines, ctx.featureRequests);
|
|
84
|
-
addFunnelMetrics(lines, ctx.funnelMetrics);
|
|
85
|
-
if (ctx.supportThemes?.length) {
|
|
86
|
-
lines.push(`Support Ticket Themes: ${ctx.supportThemes.join(', ')}`);
|
|
87
|
-
}
|
|
88
|
-
if (ctx.userPersonas?.length) {
|
|
89
|
-
lines.push(`User Personas: ${ctx.userPersonas.join(', ')}`);
|
|
90
|
-
}
|
|
91
|
-
lines.push('</product_context>');
|
|
92
|
-
return lines.join('\n');
|
|
93
|
-
}
|
|
94
|
-
function addPerformanceMetrics(lines, performance) {
|
|
95
|
-
if (!performance)
|
|
96
|
-
return;
|
|
97
|
-
lines.push('Performance:');
|
|
98
|
-
if (performance.p50Latency !== undefined)
|
|
99
|
-
lines.push(` - P50 Latency: ${performance.p50Latency}ms`);
|
|
100
|
-
if (performance.p95Latency !== undefined)
|
|
101
|
-
lines.push(` - P95 Latency: ${performance.p95Latency}ms`);
|
|
102
|
-
if (performance.p99Latency !== undefined)
|
|
103
|
-
lines.push(` - P99 Latency: ${performance.p99Latency}ms`);
|
|
104
|
-
}
|
|
105
|
-
function addTechDebtItems(lines, techDebt) {
|
|
106
|
-
if (!techDebt?.length)
|
|
107
|
-
return;
|
|
108
|
-
lines.push('Tech Debt:');
|
|
109
|
-
for (const item of techDebt.slice(0, 5)) {
|
|
110
|
-
lines.push(` - [${item.severity}] ${item.description}${item.file ? ` (${item.file})` : ''}`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function addVulnerabilityItems(lines, vulnerabilities) {
|
|
114
|
-
if (!vulnerabilities?.length)
|
|
115
|
-
return;
|
|
116
|
-
lines.push('Vulnerabilities:');
|
|
117
|
-
for (const vuln of vulnerabilities.slice(0, 5)) {
|
|
118
|
-
lines.push(` - [${vuln.severity}] ${vuln.package} (fix ${vuln.fixAvailable ? 'available' : 'not available'})`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function formatEngineeringContext(ctx) {
|
|
122
|
-
const lines = ['<engineering_context>'];
|
|
123
|
-
if (ctx.testCoverage !== undefined)
|
|
124
|
-
lines.push(`Test Coverage: ${ctx.testCoverage}%`);
|
|
125
|
-
if (ctx.lintErrors !== undefined)
|
|
126
|
-
lines.push(`Lint Errors: ${ctx.lintErrors}`);
|
|
127
|
-
if (ctx.typeErrors !== undefined)
|
|
128
|
-
lines.push(`Type Errors: ${ctx.typeErrors}`);
|
|
129
|
-
if (ctx.errorRate !== undefined)
|
|
130
|
-
lines.push(`Error Rate: ${ctx.errorRate}%`);
|
|
131
|
-
if (ctx.buildStatus)
|
|
132
|
-
lines.push(`Build Status: ${ctx.buildStatus}`);
|
|
133
|
-
if (ctx.openPRs !== undefined)
|
|
134
|
-
lines.push(`Open PRs: ${ctx.openPRs}`);
|
|
135
|
-
addPerformanceMetrics(lines, ctx.performance);
|
|
136
|
-
addTechDebtItems(lines, ctx.techDebt);
|
|
137
|
-
addVulnerabilityItems(lines, ctx.vulnerabilities);
|
|
138
|
-
lines.push('</engineering_context>');
|
|
139
|
-
return lines.join('\n');
|
|
140
|
-
}
|
|
141
|
-
export function formatPersonaContext(persona, context) {
|
|
142
|
-
return match(persona)
|
|
143
|
-
.with('steve', () => (context.business ? formatBusinessContext(context.business) : undefined))
|
|
144
|
-
.with('rachel', () => (context.product ? formatProductContext(context.product) : undefined))
|
|
145
|
-
.with('ozby', () => context.engineering ? formatEngineeringContext(context.engineering) : undefined)
|
|
146
|
-
.with('volker', 'jeramy', 'rodrigo', () => {
|
|
147
|
-
return;
|
|
148
|
-
})
|
|
149
|
-
.exhaustive();
|
|
150
|
-
}
|
|
151
|
-
export function getPersonaContextHeader(persona) {
|
|
152
|
-
return match(persona)
|
|
153
|
-
.with('steve', () => '# Business Intelligence')
|
|
154
|
-
.with('rachel', () => '# Product & User Insights')
|
|
155
|
-
.with('ozby', () => '# Engineering Metrics')
|
|
156
|
-
.otherwise(() => '# Context');
|
|
157
|
-
}
|
|
158
|
-
//# sourceMappingURL=persona-context.js.map
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { AgentPersona } from './types.js';
|
|
2
|
-
export interface AgentContribution {
|
|
3
|
-
persona: AgentPersona;
|
|
4
|
-
content: string;
|
|
5
|
-
position?: 'approve' | 'reject' | 'abstain' | 'needs_clarification';
|
|
6
|
-
confidence?: number;
|
|
7
|
-
keyPoints?: string[];
|
|
8
|
-
timestamp: Date;
|
|
9
|
-
}
|
|
10
|
-
export interface DebateRound {
|
|
11
|
-
roundNumber: number;
|
|
12
|
-
topic: string;
|
|
13
|
-
contributions: AgentContribution[];
|
|
14
|
-
summary?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface DebateOutcome {
|
|
17
|
-
consensusReached: boolean;
|
|
18
|
-
decision: 'approved' | 'rejected' | 'needs_more_info' | 'escalate_to_human';
|
|
19
|
-
confidence: number;
|
|
20
|
-
summary: string;
|
|
21
|
-
agreements: string[];
|
|
22
|
-
disagreements: string[];
|
|
23
|
-
actionItems?: string[];
|
|
24
|
-
votes: Record<AgentPersona, 'approve' | 'reject' | 'abstain' | 'needs_clarification'>;
|
|
25
|
-
}
|
|
26
|
-
export type DebateType = 'feature_review' | 'bug_priority' | 'technical_decision' | 'sprint_planning' | 'user_story_refinement';
|
|
27
|
-
export interface DebateConfig {
|
|
28
|
-
type: DebateType;
|
|
29
|
-
topic: string;
|
|
30
|
-
context?: string;
|
|
31
|
-
maxRounds?: number;
|
|
32
|
-
consensusThreshold?: number;
|
|
33
|
-
participants?: AgentPersona[];
|
|
34
|
-
useModerator?: boolean;
|
|
35
|
-
moderator?: AgentPersona;
|
|
36
|
-
verbose?: boolean;
|
|
37
|
-
}
|
|
38
|
-
export declare const DEFAULT_DEBATE_CONFIG: Required<Omit<DebateConfig, 'type' | 'topic' | 'context'>>;
|
|
39
|
-
export interface DebateState {
|
|
40
|
-
id: string;
|
|
41
|
-
config: DebateConfig;
|
|
42
|
-
rounds: DebateRound[];
|
|
43
|
-
status: 'in_progress' | 'consensus_reached' | 'max_rounds_exceeded' | 'escalated';
|
|
44
|
-
outcome?: DebateOutcome;
|
|
45
|
-
startedAt: Date;
|
|
46
|
-
completedAt?: Date;
|
|
47
|
-
}
|
|
48
|
-
export declare const DEBATE_PROMPTS: {
|
|
49
|
-
readonly initialPrompt: (config: DebateConfig, persona: AgentPersona) => string;
|
|
50
|
-
readonly followUpPrompt: (config: DebateConfig, persona: AgentPersona, previousRound: DebateRound) => string;
|
|
51
|
-
readonly moderatorPrompt: (config: DebateConfig, state: DebateState) => string;
|
|
52
|
-
};
|
|
53
|
-
export declare function parsePosition(text: string): 'approve' | 'reject' | 'abstain' | 'needs_clarification';
|
|
54
|
-
export declare function parseConfidence(text: string): number;
|
|
55
|
-
export declare function calculateConsensus(contributions: AgentContribution[]): {
|
|
56
|
-
hasConsensus: boolean;
|
|
57
|
-
majorityPosition: 'approve' | 'reject' | 'abstain' | 'needs_clarification';
|
|
58
|
-
percentAgreement: number;
|
|
59
|
-
averageConfidence: number;
|
|
60
|
-
};
|
|
61
|
-
export declare function generateDebateId(): string;
|
|
62
|
-
export declare function createDebateState(config: DebateConfig): DebateState;
|
|
63
|
-
export declare function addContribution(state: DebateState, contribution: AgentContribution): DebateState;
|
|
64
|
-
export declare function startNewRound(state: DebateState, topic?: string): DebateState;
|
|
65
|
-
export declare function finalizeDebate(state: DebateState, outcome: DebateOutcome): DebateState;
|
|
66
|
-
export declare function shouldContinueDebate(state: DebateState): boolean;
|
|
67
|
-
//# sourceMappingURL=persona-debate.d.ts.map
|