pi-para 0.5.5 → 0.6.1

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.
Files changed (77) hide show
  1. package/ARCHITECTURE.md +0 -9
  2. package/CHANGELOG.md +35 -0
  3. package/CONFIGURATION.md +0 -23
  4. package/README.md +1 -29
  5. package/SETUP.md +1 -1
  6. package/STRUCTURE.md +0 -9
  7. package/dist/cli.js +0 -84
  8. package/dist/cli.js.map +1 -1
  9. package/dist/config.d.ts +0 -10
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/config.js +0 -14
  12. package/dist/config.js.map +1 -1
  13. package/dist/doctor.js +5 -0
  14. package/dist/doctor.js.map +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -18
  17. package/dist/index.js.map +1 -1
  18. package/dist/templates/prompts.d.ts +0 -12
  19. package/dist/templates/prompts.d.ts.map +1 -1
  20. package/dist/templates/prompts.js +0 -57
  21. package/dist/templates/prompts.js.map +1 -1
  22. package/package.json +9 -5
  23. package/scripts/build-assets.mjs +17 -0
  24. package/scripts/install.ps1 +27 -16
  25. package/scripts/install.sh +3 -2
  26. package/scripts/smoke-install.mjs +5 -3
  27. package/skills/setup/SKILL.md +1 -1
  28. package/src/cli.ts +0 -70
  29. package/src/config.ts +0 -25
  30. package/src/doctor.ts +5 -0
  31. package/src/index.ts +1 -38
  32. package/src/templates/prompts.ts +0 -56
  33. package/dist/gepa/dataset.d.ts +0 -36
  34. package/dist/gepa/dataset.d.ts.map +0 -1
  35. package/dist/gepa/dataset.js +0 -148
  36. package/dist/gepa/dataset.js.map +0 -1
  37. package/dist/gepa/evaluator.d.ts +0 -51
  38. package/dist/gepa/evaluator.d.ts.map +0 -1
  39. package/dist/gepa/evaluator.js +0 -317
  40. package/dist/gepa/evaluator.js.map +0 -1
  41. package/dist/gepa/index.d.ts +0 -66
  42. package/dist/gepa/index.d.ts.map +0 -1
  43. package/dist/gepa/index.js +0 -240
  44. package/dist/gepa/index.js.map +0 -1
  45. package/dist/gepa/llm.d.ts +0 -35
  46. package/dist/gepa/llm.d.ts.map +0 -1
  47. package/dist/gepa/llm.js +0 -268
  48. package/dist/gepa/llm.js.map +0 -1
  49. package/dist/gepa/optimized/capture-prompt.txt +0 -65
  50. package/dist/gepa/optimizer.d.ts +0 -29
  51. package/dist/gepa/optimizer.d.ts.map +0 -1
  52. package/dist/gepa/optimizer.js +0 -249
  53. package/dist/gepa/optimizer.js.map +0 -1
  54. package/dist/gepa/targets.d.ts +0 -39
  55. package/dist/gepa/targets.d.ts.map +0 -1
  56. package/dist/gepa/targets.js +0 -326
  57. package/dist/gepa/targets.js.map +0 -1
  58. package/dist/gepa/types.d.ts +0 -168
  59. package/dist/gepa/types.d.ts.map +0 -1
  60. package/dist/gepa/types.js +0 -124
  61. package/dist/gepa/types.js.map +0 -1
  62. package/scripts/gepa/__pycache__/dataset.cpython-313.pyc +0 -0
  63. package/scripts/gepa/__pycache__/lm_providers.cpython-313.pyc +0 -0
  64. package/scripts/gepa/__pycache__/metric.cpython-313.pyc +0 -0
  65. package/scripts/gepa/__pycache__/program.cpython-313.pyc +0 -0
  66. package/scripts/gepa/__pycache__/wiki_reader.cpython-313.pyc +0 -0
  67. package/scripts/gepa/dataset.py +0 -192
  68. package/scripts/gepa/lm_providers.py +0 -472
  69. package/scripts/gepa/metric.py +0 -279
  70. package/scripts/gepa/optimize.py +0 -367
  71. package/scripts/gepa/program.py +0 -99
  72. package/scripts/gepa/pyproject.toml +0 -19
  73. package/scripts/gepa/run-all.sh +0 -53
  74. package/scripts/gepa/uv.lock +0 -2241
  75. package/scripts/gepa/wiki_reader.py +0 -113
  76. package/src/gepa/index.ts +0 -287
  77. package/src/gepa/optimized/capture-prompt.txt +0 -65
@@ -1,148 +0,0 @@
1
- /**
2
- * GEPA dataset extraction — builds evaluation context from wiki state and session history.
3
- *
4
- * The evaluation context gives the LLM judge grounding:
5
- * it knows about the wiki's current size, structure, common patterns,
6
- * and recent capture results to judge whether a prompt would work well.
7
- */
8
- import { readFile, readdir } from "node:fs/promises";
9
- import { join } from "node:path";
10
- import { existsSync } from "node:fs";
11
- import { homedir } from "node:os";
12
- // -- Wiki state extraction ---------------------------------------------------
13
- async function extractWikiStats(wikiDir) {
14
- const categories = ["projects", "areas", "resources", "archives"];
15
- const categoryCounts = {};
16
- const allScopes = [];
17
- const allTags = [];
18
- const sampleTitles = [];
19
- let totalPages = 0;
20
- for (const cat of categories) {
21
- const catDir = join(wikiDir, cat);
22
- if (!existsSync(catDir)) {
23
- categoryCounts[cat] = 0;
24
- continue;
25
- }
26
- try {
27
- const files = await readdir(catDir);
28
- const mdFiles = files.filter((f) => f.endsWith(".md"));
29
- categoryCounts[cat] = mdFiles.length;
30
- totalPages += mdFiles.length;
31
- // Parse frontmatter from each page (lightweight — just YAML header)
32
- for (const file of mdFiles.slice(0, 30)) {
33
- try {
34
- const content = await readFile(join(catDir, file), "utf-8");
35
- const fm = parseFrontmatter(content);
36
- if (fm) {
37
- if (fm.title && sampleTitles.length < 15) {
38
- sampleTitles.push(fm.title);
39
- }
40
- if (fm.scope)
41
- allScopes.push(...fm.scope);
42
- if (fm.tags)
43
- allTags.push(...fm.tags);
44
- }
45
- }
46
- catch {
47
- // Skip unreadable pages
48
- }
49
- }
50
- }
51
- catch {
52
- categoryCounts[cat] = 0;
53
- }
54
- }
55
- const scopeCounts = countOccurrences(allScopes);
56
- const tagCounts = countOccurrences(allTags);
57
- return {
58
- totalPages,
59
- categoryCounts,
60
- scopeCount: Object.keys(scopeCounts).length,
61
- topScopes: topN(scopeCounts, 5),
62
- tagCount: Object.keys(tagCounts).length,
63
- topTags: topN(tagCounts, 10),
64
- sampleTitles,
65
- };
66
- }
67
- /** Minimal frontmatter parser — extract title, scope, tags from YAML header. */
68
- function parseFrontmatter(content) {
69
- const match = content.match(/^---\s*\n([\s\S]*?)\n---/);
70
- if (!match)
71
- return null;
72
- const yaml = match[1];
73
- const result = {};
74
- // Extract title
75
- const titleMatch = yaml.match(/^title:\s*(.+)$/m);
76
- if (titleMatch) {
77
- result.title = titleMatch[1].replace(/^["']|["']$/g, "").trim();
78
- }
79
- // Extract scope (inline array)
80
- const scopeMatch = yaml.match(/^scope:\s*\[([^\]]*)\]/m);
81
- if (scopeMatch) {
82
- result.scope = scopeMatch[1].split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
83
- }
84
- else {
85
- // Multi-line array format
86
- const scopeSection = yaml.match(/^scope:\s*\n((?:\s+-\s+.+\n?)*)/m);
87
- if (scopeSection) {
88
- result.scope = scopeSection[1].match(/^\s+-\s+(.+)$/gm)?.map((l) => l.replace(/^\s+-\s+/, "").replace(/^["']|["']$/g, "").trim()) ?? [];
89
- }
90
- }
91
- // Extract tags (inline array)
92
- const tagsMatch = yaml.match(/^tags:\s*\[([^\]]*)\]/m);
93
- if (tagsMatch) {
94
- result.tags = tagsMatch[1].split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
95
- }
96
- else {
97
- const tagsSection = yaml.match(/^tags:\s*\n((?:\s+-\s+.+\n?)*)/m);
98
- if (tagsSection) {
99
- result.tags = tagsSection[1].match(/^\s+-\s+(.+)$/gm)?.map((l) => l.replace(/^\s+-\s+/, "").replace(/^["']|["']$/g, "").trim()) ?? [];
100
- }
101
- }
102
- return result;
103
- }
104
- function countOccurrences(items) {
105
- const counts = {};
106
- for (const item of items) {
107
- counts[item] = (counts[item] ?? 0) + 1;
108
- }
109
- return counts;
110
- }
111
- function topN(counts, n) {
112
- return Object.entries(counts)
113
- .sort((a, b) => b[1] - a[1])
114
- .slice(0, n)
115
- .map(([key]) => key);
116
- }
117
- // -- Context building --------------------------------------------------------
118
- /**
119
- * Build a formatted evaluation context string from wiki state.
120
- */
121
- export async function buildEvalContext(wikiDir) {
122
- const dir = wikiDir ?? join(homedir(), ".pi", "wiki");
123
- const wikiStats = await extractWikiStats(dir);
124
- const lines = [
125
- "## Wiki State Summary",
126
- "",
127
- `Total pages: ${wikiStats.totalPages}`,
128
- `Categories: ${Object.entries(wikiStats.categoryCounts).map(([k, v]) => `${k}=${v}`).join(", ")}`,
129
- `Scopes: ${wikiStats.scopeCount} unique (top: ${wikiStats.topScopes.join(", ") || "none"})`,
130
- `Tags: ${wikiStats.tagCount} unique (top: ${wikiStats.topTags.slice(0, 5).join(", ") || "none"})`,
131
- "",
132
- ];
133
- if (wikiStats.sampleTitles.length > 0) {
134
- lines.push("Sample page titles:");
135
- for (const title of wikiStats.sampleTitles.slice(0, 10)) {
136
- lines.push(` - ${title}`);
137
- }
138
- lines.push("");
139
- }
140
- // Check for recent processing history
141
- const stateDbPath = join(dir, ".daemon.sqlite");
142
- if (existsSync(stateDbPath)) {
143
- lines.push("Daemon: active (session processing enabled)");
144
- }
145
- const contextString = lines.join("\n");
146
- return { contextString, wikiStats };
147
- }
148
- //# sourceMappingURL=dataset.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataset.js","sourceRoot":"","sources":["../../src/gepa/dataset.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAqClC,+EAA+E;AAE/E,KAAK,UAAU,gBAAgB,CAAC,OAAe;IAC7C,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAClE,MAAM,cAAc,GAA2B,EAAE,CAAC;IAClD,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,KAAK,MAAM,GAAG,IAAI,UAA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E,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACjG,WAAW,SAAS,CAAC,UAAU,iBAAiB,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG;QAC3F,SAAS,SAAS,CAAC,QAAQ,iBAAiB,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG;QACjG,EAAE;KACH,CAAC;IAEF,IAAI,SAAS,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAClC,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;YACxD,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,sCAAsC;IACtC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAChD,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;AACtC,CAAC"}
@@ -1,51 +0,0 @@
1
- /**
2
- * GEPA LLM-based evaluator — judges prompt/skill candidates on multiple dimensions.
3
- *
4
- * Every candidate is scored by an LLM judge across 5 equally-weighted dimensions:
5
- * Structure (0.20), Clarity (0.20), Completeness (0.20),
6
- * Error Prevention (0.20), Actionability (0.20)
7
- *
8
- * The evaluator builds a target-specific evaluation prompt that describes what
9
- * "good" looks like for each target type (system prompts, capture prompts,
10
- * maintenance prompts, skills), then parses the LLM's JSON response robustly.
11
- *
12
- * Constraint violations (missing required concepts) cap the score at 0.3.
13
- */
14
- import type { Target, LLMClient, EvalResult, EvalDimension } from "./types.js";
15
- /** Evaluation dimensions with equal weighting. */
16
- declare const EVAL_DIMENSIONS: readonly [{
17
- readonly name: "structure";
18
- readonly weight: 0.2;
19
- }, {
20
- readonly name: "clarity";
21
- readonly weight: 0.2;
22
- }, {
23
- readonly name: "completeness";
24
- readonly weight: 0.2;
25
- }, {
26
- readonly name: "error-prevention";
27
- readonly weight: 0.2;
28
- }, {
29
- readonly name: "actionability";
30
- readonly weight: 0.2;
31
- }];
32
- /** Maximum score when constraint violations are detected. */
33
- declare const CONSTRAINT_VIOLATION_CAP = 0.3;
34
- declare function getTargetTypeGuidance(target: Target): string;
35
- declare function buildEvaluationPrompt(candidate: string, target: Target, context: string): string;
36
- declare function extractJSON(raw: string): Record<string, unknown> | null;
37
- interface ParsedJudgeResponse {
38
- success: boolean;
39
- dimensions: EvalDimension[];
40
- constraintViolations: string[];
41
- overallFeedback: string;
42
- }
43
- declare function parseJudgeResponse(raw: string): ParsedJudgeResponse;
44
- declare function checkConstraintViolations(candidate: string, constraints: string[]): string[];
45
- declare function computeWeightedScore(dimensions: EvalDimension[]): number;
46
- /**
47
- * Evaluate a candidate prompt/skill using an LLM judge.
48
- */
49
- export declare function evaluateCandidate(candidate: string, target: Target, context: string, llm: LLMClient): Promise<EvalResult>;
50
- export { buildEvaluationPrompt, extractJSON, parseJudgeResponse, checkConstraintViolations, computeWeightedScore, getTargetTypeGuidance, EVAL_DIMENSIONS, CONSTRAINT_VIOLATION_CAP, };
51
- //# sourceMappingURL=evaluator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/gepa/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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2
- * GEPA LLM-based evaluator — judges prompt/skill candidates on multiple dimensions.
3
- *
4
- * Every candidate is scored by an LLM judge across 5 equally-weighted dimensions:
5
- * Structure (0.20), Clarity (0.20), Completeness (0.20),
6
- * Error Prevention (0.20), Actionability (0.20)
7
- *
8
- * The evaluator builds a target-specific evaluation prompt that describes what
9
- * "good" looks like for each target type (system prompts, capture prompts,
10
- * maintenance prompts, skills), then parses the LLM's JSON response robustly.
11
- *
12
- * Constraint violations (missing required concepts) cap the score at 0.3.
13
- */
14
- // -- Constants ---------------------------------------------------------------
15
- /** Evaluation dimensions with equal weighting. */
16
- const EVAL_DIMENSIONS = [
17
- { name: "structure", weight: 0.20 },
18
- { name: "clarity", weight: 0.20 },
19
- { name: "completeness", weight: 0.20 },
20
- { name: "error-prevention", weight: 0.20 },
21
- { name: "actionability", weight: 0.20 },
22
- ];
23
- /** Maximum score when constraint violations are detected. */
24
- const CONSTRAINT_VIOLATION_CAP = 0.3;
25
- /** System prompt for the LLM judge. */
26
- const JUDGE_SYSTEM_PROMPT = `You are an expert prompt engineer evaluating prompt templates and skill documents for an AI-powered PARA knowledge base system called pi-para.
27
-
28
- Your evaluations must be precise, calibrated, and honest. Do not inflate scores.
29
-
30
- Scoring scale:
31
- - 0.0–0.2: Fundamentally broken or missing
32
- - 0.2–0.4: Major issues, needs significant rework
33
- - 0.4–0.6: Functional but has clear gaps or weaknesses
34
- - 0.6–0.8: Good, minor improvements possible
35
- - 0.8–1.0: Excellent, best-in-class for this type of content
36
-
37
- Always respond with valid JSON only. No markdown formatting, no explanatory text outside the JSON.`;
38
- // -- Target-type-specific quality criteria -----------------------------------
39
- function getTargetTypeGuidance(target) {
40
- const name = target.name.toLowerCase();
41
- if (name.includes("system-prompt") || name.includes("capture-prompt-processor")) {
42
- return `This is a SYSTEM PROMPT — it sets the persona and rules for an LLM agent.
43
-
44
- Quality criteria for system prompts:
45
- - MUST define a clear agent role/persona at the top
46
- - MUST include explicit PARA category rules (resources/ as default, projects/ ONLY for goals with end dates)
47
- - MUST include security rules (never store API keys/tokens/secrets in content)
48
- - MUST include scope rules (kebab-case project names)
49
- - SHOULD include content format guidance (wiki summary format)
50
- - SHOULD include [[wikilink]] usage instructions
51
- - Must be authoritative and unambiguous
52
- - Must prevent common mistakes (wrong category, duplicate pages, secrets in content)`;
53
- }
54
- if (name.includes("capture")) {
55
- return `This is a CAPTURE PROMPT — it instructs the LLM on extracting knowledge from coding sessions.
56
-
57
- Quality criteria for capture prompts:
58
- - MUST emphasize deduplication: search wiki_query BEFORE creating new pages
59
- - MUST include session reference instructions (include session file path in Sources)
60
- - MUST include skip-trivial logic (only skip pure greetings/chitchat)
61
- - MUST define what constitutes capturable knowledge
62
- - SHOULD specify capture bias: "when in doubt, capture it"
63
- - SHOULD emphasize small operational facts are valuable`;
64
- }
65
- if (name.includes("maintenance")) {
66
- return `This is a MAINTENANCE PROMPT — it instructs the LLM on keeping the wiki healthy.
67
-
68
- Quality criteria:
69
- - MUST take a conservative approach: "when unsure, leave it alone"
70
- - MUST include duplicate detection and merge rules
71
- - MUST include wikilink discovery
72
- - MUST include category review rules
73
- - SHOULD include project lifecycle review with safeguards`;
74
- }
75
- if (name.includes("ingest")) {
76
- return `This is an INGEST PROMPT — it instructs the LLM on integrating new source material.
77
-
78
- Quality criteria:
79
- - MUST instruct to review existing pages before creating new ones
80
- - MUST include PARA category assignment rules
81
- - MUST include wiki summary format
82
- - MUST instruct to flag contradictions`;
83
- }
84
- if (name.includes("query")) {
85
- return `This is a QUERY PROMPT — it instructs the LLM on synthesizing answers from wiki search.
86
-
87
- Quality criteria:
88
- - MUST include citation instructions (use [[page-slug]] references)
89
- - MUST include freshness verification rules
90
- - MUST include self-healing instructions (fix incorrect wiki pages)`;
91
- }
92
- if (target.type === "skill") {
93
- return `This is a SKILL DOCUMENT — behavioral guidelines or setup instructions.
94
-
95
- Quality criteria:
96
- - MUST have clear structure with numbered or headed sections
97
- - MUST have actionable steps the agent can follow without ambiguity
98
- - MUST include concrete examples where helpful
99
- - SHOULD include "common mistakes" or anti-patterns to avoid`;
100
- }
101
- return `This is a prompt template for the pi-para PARA knowledge base system.
102
-
103
- General quality criteria:
104
- - Clear structure with logical sections
105
- - Unambiguous instructions
106
- - Appropriate level of detail
107
- - Covers edge cases and error scenarios`;
108
- }
109
- // -- Evaluation prompt builder -----------------------------------------------
110
- function buildEvaluationPrompt(candidate, target, context) {
111
- const typeGuidance = getTargetTypeGuidance(target);
112
- const constraintSection = target.constraints.length > 0
113
- ? `\n## Required Constraints\n\nThe following concepts MUST be present. If any are missing, the candidate has a constraint violation.\n\n${target.constraints.map((c, i) => `${i + 1}. ${c}`).join("\n")}\n`
114
- : "";
115
- const descriptionSection = target.description
116
- ? `\n**Purpose**: ${target.description}\n`
117
- : "";
118
- return `# Prompt Evaluation Task
119
-
120
- You are evaluating a candidate ${target.type === "skill" ? "skill document" : "prompt template"} for the pi-para PARA knowledge base system.
121
-
122
- ## Target: "${target.name}"
123
- **Type**: ${target.type}${descriptionSection}
124
-
125
- ## Target-Specific Quality Criteria
126
-
127
- ${typeGuidance}
128
- ${constraintSection}
129
- ## Current Wiki Context
130
-
131
- ${context || "No additional context available."}
132
-
133
- ## Candidate to Evaluate
134
-
135
- <candidate>
136
- ${candidate}
137
- </candidate>
138
-
139
- ## Evaluation Instructions
140
-
141
- Score this candidate on exactly 5 dimensions, each from 0.0 to 1.0:
142
-
143
- 1. **structure** (0.20): Organization, clear sections, appropriate length, logical grouping
144
- 2. **clarity** (0.20): Unambiguous instructions, no contradictions, consistent interpretation
145
- 3. **completeness** (0.20): Covers all necessary aspects, no gaps, all constraints present
146
- 4. **error-prevention** (0.20): Guards against common mistakes, includes safety rails
147
- 5. **actionability** (0.20): Concrete rules to follow, clear decision criteria, not vague
148
-
149
- Respond with ONLY this JSON structure (no markdown, no extra text):
150
- {
151
- "dimensions": {
152
- "structure": { "score": 0.0, "feedback": "..." },
153
- "clarity": { "score": 0.0, "feedback": "..." },
154
- "completeness": { "score": 0.0, "feedback": "..." },
155
- "error-prevention": { "score": 0.0, "feedback": "..." },
156
- "actionability": { "score": 0.0, "feedback": "..." }
157
- },
158
- "constraintViolations": [],
159
- "overallFeedback": "2-3 sentence summary"
160
- }`;
161
- }
162
- // -- JSON parsing ------------------------------------------------------------
163
- function extractJSON(raw) {
164
- const trimmed = raw.trim();
165
- try {
166
- return JSON.parse(trimmed);
167
- }
168
- catch { /* continue */ }
169
- const codeBlockMatch = trimmed.match(/```(?:json)?\s*\n?([\s\S]*?)```/);
170
- if (codeBlockMatch) {
171
- try {
172
- return JSON.parse(codeBlockMatch[1].trim());
173
- }
174
- catch { /* continue */ }
175
- }
176
- const firstBrace = trimmed.indexOf("{");
177
- const lastBrace = trimmed.lastIndexOf("}");
178
- if (firstBrace !== -1 && lastBrace > firstBrace) {
179
- try {
180
- return JSON.parse(trimmed.slice(firstBrace, lastBrace + 1));
181
- }
182
- catch { /* continue */ }
183
- }
184
- return null;
185
- }
186
- function parseJudgeResponse(raw) {
187
- const json = extractJSON(raw);
188
- if (!json) {
189
- return {
190
- success: false,
191
- dimensions: createZeroDimensions("Failed to parse LLM judge response as JSON"),
192
- constraintViolations: [],
193
- overallFeedback: `[gepa] Parse error: could not extract JSON from response.`,
194
- };
195
- }
196
- const dims = json.dimensions;
197
- const dimensions = [];
198
- for (const dim of EVAL_DIMENSIONS) {
199
- const dimData = dims?.[dim.name];
200
- const score = typeof dimData?.score === "number"
201
- ? clamp(dimData.score, 0, 1)
202
- : 0;
203
- const feedback = typeof dimData?.feedback === "string"
204
- ? dimData.feedback
205
- : "No feedback provided";
206
- dimensions.push({
207
- name: dim.name,
208
- score,
209
- feedback,
210
- weight: dim.weight,
211
- });
212
- }
213
- const violations = Array.isArray(json.constraintViolations)
214
- ? json.constraintViolations.filter((v) => typeof v === "string")
215
- : [];
216
- const overallFeedback = typeof json.overallFeedback === "string"
217
- ? json.overallFeedback
218
- : "No overall feedback provided";
219
- return { success: true, dimensions, constraintViolations: violations, overallFeedback };
220
- }
221
- // -- Constraint checking -----------------------------------------------------
222
- function checkConstraintViolations(candidate, constraints) {
223
- if (constraints.length === 0)
224
- return [];
225
- const lowerCandidate = candidate.toLowerCase();
226
- const missing = [];
227
- for (const constraint of constraints) {
228
- const keyTerms = extractKeyTerms(constraint);
229
- const hasAnyTerm = keyTerms.some((term) => lowerCandidate.includes(term.toLowerCase()));
230
- if (!hasAnyTerm) {
231
- missing.push(constraint);
232
- }
233
- }
234
- return missing;
235
- }
236
- function extractKeyTerms(constraint) {
237
- const fillerWords = new Set([
238
- "must", "should", "include", "have", "contain", "mention",
239
- "use", "provide", "specify", "ensure", "be", "the", "a", "an",
240
- "and", "or", "for", "with", "about", "that", "this", "is", "are",
241
- "in", "of", "to", "not", "no", "any", "all", "each",
242
- ]);
243
- return constraint
244
- .toLowerCase()
245
- .replace(/[^a-z0-9\s-]/g, "")
246
- .split(/\s+/)
247
- .filter((w) => w.length > 2 && !fillerWords.has(w));
248
- }
249
- // -- Helpers -----------------------------------------------------------------
250
- function clamp(value, min, max) {
251
- return Math.max(min, Math.min(max, value));
252
- }
253
- function createZeroDimensions(feedback) {
254
- return EVAL_DIMENSIONS.map((dim) => ({
255
- name: dim.name,
256
- score: 0,
257
- feedback,
258
- weight: dim.weight,
259
- }));
260
- }
261
- function computeWeightedScore(dimensions) {
262
- let totalWeight = 0;
263
- let weightedSum = 0;
264
- for (const dim of dimensions) {
265
- weightedSum += dim.score * dim.weight;
266
- totalWeight += dim.weight;
267
- }
268
- if (totalWeight === 0)
269
- return 0;
270
- return weightedSum / totalWeight;
271
- }
272
- // -- Main evaluation function ------------------------------------------------
273
- /**
274
- * Evaluate a candidate prompt/skill using an LLM judge.
275
- */
276
- export async function evaluateCandidate(candidate, target, context, llm) {
277
- const evalPrompt = buildEvaluationPrompt(candidate, target, context);
278
- let rawResponse;
279
- try {
280
- rawResponse = await llm.complete(evalPrompt, JUDGE_SYSTEM_PROMPT);
281
- }
282
- catch (error) {
283
- const msg = error instanceof Error ? error.message : String(error);
284
- console.error(`[gepa] LLM judge call failed for target "${target.name}": ${msg}`);
285
- return {
286
- score: 0,
287
- dimensions: createZeroDimensions(`LLM judge error: ${msg}`),
288
- overallFeedback: `[gepa] Evaluation failed: ${msg}`,
289
- };
290
- }
291
- const parsed = parseJudgeResponse(rawResponse);
292
- if (!parsed.success) {
293
- console.warn(`[gepa] Failed to parse judge response for "${target.name}", using zero scores`);
294
- }
295
- let { dimensions } = parsed;
296
- let { overallFeedback } = parsed;
297
- // Check for constraint violations
298
- const hardViolations = checkConstraintViolations(candidate, target.constraints);
299
- const allViolationsArr = [...hardViolations, ...parsed.constraintViolations];
300
- const allViolations = Array.from(new Set(allViolationsArr));
301
- if (allViolations.length > 0) {
302
- const violationList = allViolations.join("; ");
303
- console.log(`[gepa] Constraint violations for "${target.name}": ${violationList} — capping score at ${CONSTRAINT_VIOLATION_CAP}`);
304
- dimensions = dimensions.map((dim) => ({
305
- ...dim,
306
- score: Math.min(dim.score, CONSTRAINT_VIOLATION_CAP),
307
- feedback: dim.score > CONSTRAINT_VIOLATION_CAP
308
- ? `${dim.feedback} [CAPPED: constraint violations]`
309
- : dim.feedback,
310
- }));
311
- overallFeedback = `${overallFeedback}\n\n⚠️ CONSTRAINT VIOLATIONS (score capped at ${CONSTRAINT_VIOLATION_CAP}): ${violationList}`;
312
- }
313
- const score = computeWeightedScore(dimensions);
314
- return { score, dimensions, overallFeedback };
315
- }
316
- export { buildEvaluationPrompt, extractJSON, parseJudgeResponse, checkConstraintViolations, computeWeightedScore, getTargetTypeGuidance, EVAL_DIMENSIONS, CONSTRAINT_VIOLATION_CAP, };
317
- //# sourceMappingURL=evaluator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/gepa/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,+EAA+E;AAE/E,kDAAkD;AAClD,MAAM,eAAe,GAAG;IACtB,EAAE,IAAI,EAAE,WAAW,E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AAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AAChD,CAAC;AAED,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,wBAAwB,GACzB,CAAC"}
@@ -1,66 +0,0 @@
1
- /**
2
- * GEPA optimizer orchestrator — TypeScript side.
3
- *
4
- * 1. Extracts all prompt/tool/skill instruction texts from source
5
- * 2. Writes targets.json for the Python DSPy GEPA script
6
- * 3. Reads auth.json → passes API keys as env vars to uv subprocess
7
- * 4. Calls `uv run scripts/gepa/optimize.py`
8
- * 5. Reads results.json → saves optimized prompts to disk
9
- */
10
- interface GEPATarget {
11
- name: string;
12
- type: "prompt" | "tool" | "skill";
13
- content: string;
14
- sourceFile: string;
15
- }
16
- interface GEPAResult {
17
- target: string;
18
- status: "success" | "error";
19
- baseline_score?: number;
20
- optimized_score?: number;
21
- improvement_pct?: number;
22
- optimized_instruction?: string;
23
- original_instruction?: string;
24
- model?: string;
25
- auto?: string;
26
- error?: string;
27
- timestamp?: string;
28
- }
29
- interface GEPAOutput {
30
- results: GEPAResult[];
31
- model: string;
32
- auto: string;
33
- wiki_dir: string;
34
- timestamp: string;
35
- }
36
- export interface GEPAOptions {
37
- target?: string;
38
- /** Student model — runs the proxy (fast, cheap). */
39
- studentModel?: string;
40
- /** Teacher/reflection model — proposes mutations (smart, creative). */
41
- teacherModel?: string;
42
- /** Judge model — scores outputs (fast, cheap). Default: same as student. */
43
- judgeModel?: string;
44
- /** Shorthand: sets studentModel (backward compat with --model flag) */
45
- model?: string;
46
- /** Shorthand: sets teacherModel (backward compat with --reflection-model flag) */
47
- reflectionModel?: string;
48
- auto?: "light" | "medium" | "heavy";
49
- maxMetricCalls?: number;
50
- threads?: number;
51
- seed?: number;
52
- }
53
- export declare function extractTargets(packageRoot?: string): GEPATarget[];
54
- export declare function runGEPA(options?: GEPAOptions): Promise<GEPAOutput>;
55
- export declare function listOptimized(): {
56
- name: string;
57
- score: number;
58
- timestamp: string;
59
- model: string;
60
- }[];
61
- export declare function compareTarget(targetName: string): {
62
- original: string;
63
- optimized: string;
64
- } | null;
65
- export {};
66
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gepa/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,UAAU;IAClB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,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