@dev-sergeev/datalab-kit 0.1.4 → 0.1.6

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 (54) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +47 -4
  3. package/THIRD_PARTY_NOTICES.md +3 -0
  4. package/dist/datalab-provider.d.ts +2 -0
  5. package/dist/datalab-provider.js +45 -0
  6. package/dist/extension.js +4 -0
  7. package/dist/skills.d.ts +2 -0
  8. package/dist/skills.js +54 -0
  9. package/docs/adr/0003-datalab-environment-provider.md +11 -0
  10. package/package.json +36 -9
  11. package/skills/init/SKILL.md +31 -0
  12. package/skills/skill-creator/LICENSE.txt +202 -0
  13. package/skills/skill-creator/SKILL.md +610 -0
  14. package/skills/skill-creator/agents/analyzer.md +291 -0
  15. package/skills/skill-creator/agents/comparator.md +213 -0
  16. package/skills/skill-creator/agents/grader.md +234 -0
  17. package/skills/skill-creator/assets/eval_review.html +146 -0
  18. package/skills/skill-creator/eval-viewer/generate_review.py +453 -0
  19. package/skills/skill-creator/eval-viewer/viewer.html +1329 -0
  20. package/skills/skill-creator/references/schemas.md +521 -0
  21. package/skills/skill-creator/scripts/aggregate_benchmark.py +415 -0
  22. package/skills/skill-creator/scripts/generate_report.py +329 -0
  23. package/skills/skill-creator/scripts/improve_description.py +225 -0
  24. package/skills/skill-creator/scripts/package_skill.py +136 -0
  25. package/skills/skill-creator/scripts/pi_runtime.py +177 -0
  26. package/skills/skill-creator/scripts/quick_validate.py +107 -0
  27. package/skills/skill-creator/scripts/run_eval.py +215 -0
  28. package/skills/skill-creator/scripts/run_loop.py +334 -0
  29. package/skills/skill-creator/scripts/utils.py +41 -0
  30. package/node_modules/node-addon-api/common 2.gypi +0 -21
  31. package/node_modules/node-addon-api/except 2.gypi +0 -25
  32. package/node_modules/node-addon-api/napi 2.h +0 -3463
  33. package/node_modules/node-addon-api/napi-inl 2.h +0 -7250
  34. package/node_modules/node-addon-api/napi-inl.deprecated 2.h +0 -186
  35. package/node_modules/node-addon-api/node_addon_api 2.gyp +0 -42
  36. package/node_modules/node-addon-api/node_api 2.gyp +0 -9
  37. package/node_modules/node-addon-api/noexcept 2.gypi +0 -26
  38. package/node_modules/pi-toggle-skills/toggle-skills 2.ts +0 -316
  39. package/node_modules/pi-toggle-skills/vitest.config 2.ts +0 -15
  40. package/node_modules/sprintf-js/.npmignore 2 +0 -1
  41. package/node_modules/sprintf-js/LICENSE 2 +0 -24
  42. package/node_modules/sprintf-js/README 2.md +0 -88
  43. package/node_modules/sprintf-js/bower 2.json +0 -14
  44. package/node_modules/sprintf-js/gruntfile 2.js +0 -36
  45. package/node_modules/sprintf-js/package 2.json +0 -22
  46. package/node_modules/tree-sitter-bash/tree-sitter-bash 2.wasm +0 -0
  47. package/node_modules/typebox/license 2 +0 -23
  48. package/node_modules/typebox/package 2.json +0 -87
  49. package/node_modules/typebox/readme 2.md +0 -370
  50. package/node_modules/zod/compile 2.cjs +0 -96
  51. package/node_modules/zod/compile 2.js +0 -52
  52. package/node_modules/zod/index 2.cjs +0 -52
  53. package/node_modules/zod/index 2.js +0 -7
  54. /package/{node_modules/node-addon-api/nothing 2.c → skills/skill-creator/scripts/__init__.py} +0 -0
@@ -0,0 +1,234 @@
1
+ # Grader Agent
2
+
3
+ > Modified for Datalab Kit/Pi from Anthropic's skill-creator,
4
+ > revision `dbd4588f9e1033efb41dad4bef2f7947c8993d44`.
5
+ > Changes: Pi JSONL transcripts, evidence-only telemetry, and writable output paths.
6
+ > See [Apache-2.0 license](../LICENSE.txt) and [source attribution](../SKILL.md).
7
+
8
+ Run these instructions in a `general-purpose` Pi subagent with
9
+ `inherit_context: false`, or grade inline. This file is task guidance, not a
10
+ registered subagent type. Use the exact paths in the task; save no files inside
11
+ the installed skill-creator package.
12
+
13
+ Evaluate expectations against an execution transcript and outputs.
14
+
15
+ ## Role
16
+
17
+ The Grader reviews a transcript and output files, then determines whether each expectation passes or fails. Provide clear evidence for each judgment.
18
+
19
+ You have two jobs: grade the outputs, and critique the evals themselves. A passing grade on a weak assertion is worse than useless — it creates false confidence. When you notice an assertion that's trivially satisfied, or an important outcome that no assertion checks, say so.
20
+
21
+ ## Inputs
22
+
23
+ You receive these parameters in your prompt:
24
+
25
+ - **expectations**: List of expectations to evaluate (strings)
26
+ - **transcript_path**: Path to the execution transcript (Pi JSONL or a faithful readable export)
27
+ - **outputs_dir**: Directory containing output files from execution
28
+
29
+ ## Process
30
+
31
+ ### Step 1: Read the Transcript
32
+
33
+ 1. Read the transcript file completely. For Pi JSONL, use complete `message_end` messages and `tool_execution_start`/`tool_execution_end` events; streaming deltas may duplicate content and are not separate actions.
34
+ 2. Note the eval prompt, execution steps, and final result. An assistant claiming success is not proof: inspect the actual output files.
35
+ 3. Identify errors, aborted messages, nonzero exit status, and any `stderr.log` supplied by the executor. Keep execution failures visible rather than silently dropping a run.
36
+
37
+ ### Step 2: Examine Output Files
38
+
39
+ 1. List files in outputs_dir
40
+ 2. Read/examine each file relevant to the expectations. If outputs aren't plain text, use the inspection tools provided in your prompt — don't rely solely on what the transcript says the executor produced.
41
+ 3. Note contents, structure, and quality
42
+
43
+ ### Step 3: Evaluate Each Assertion
44
+
45
+ For each expectation:
46
+
47
+ 1. **Search for evidence** in the transcript and outputs
48
+ 2. **Determine verdict**:
49
+ - **PASS**: Clear evidence the expectation is true AND the evidence reflects genuine task completion, not just surface-level compliance
50
+ - **FAIL**: No evidence, or evidence contradicts the expectation, or the evidence is superficial (e.g., correct filename but empty/wrong content)
51
+ 3. **Cite the evidence**: Quote the specific text or describe what you found
52
+
53
+ ### Step 4: Extract and Verify Claims
54
+
55
+ Beyond the predefined expectations, extract implicit claims from the outputs and verify them:
56
+
57
+ 1. **Extract claims** from the transcript and outputs:
58
+ - Factual statements ("The form has 12 fields")
59
+ - Process claims ("Used pypdf to fill the form")
60
+ - Quality claims ("All fields were filled correctly")
61
+
62
+ 2. **Verify each claim**:
63
+ - **Factual claims**: Can be checked against the outputs or external sources
64
+ - **Process claims**: Can be verified from the transcript
65
+ - **Quality claims**: Evaluate whether the claim is justified
66
+
67
+ 3. **Flag unverifiable claims**: Note claims that cannot be verified with available information
68
+
69
+ This catches issues that predefined expectations might miss.
70
+
71
+ ### Step 5: Read User Notes
72
+
73
+ If `{outputs_dir}/user_notes.md` exists:
74
+ 1. Read it and note any uncertainties or issues flagged by the executor
75
+ 2. Include relevant concerns in the grading output
76
+ 3. These may reveal problems even when expectations pass
77
+
78
+ ### Step 6: Critique the Evals
79
+
80
+ After grading, consider whether the evals themselves could be improved. Only surface suggestions when there's a clear gap.
81
+
82
+ Good suggestions test meaningful outcomes — assertions that are hard to satisfy without actually doing the work correctly. Think about what makes an assertion *discriminating*: it passes when the skill genuinely succeeds and fails when it doesn't.
83
+
84
+ Suggestions worth raising:
85
+ - An assertion that passed but would also pass for a clearly wrong output (e.g., checking filename existence but not file content)
86
+ - An important outcome you observed — good or bad — that no assertion covers at all
87
+ - An assertion that can't actually be verified from the available outputs
88
+
89
+ Keep the bar high. The goal is to flag things the eval author would say "good catch" about, not to nitpick every assertion.
90
+
91
+ ### Step 7: Write Grading Results
92
+
93
+ Save results to `{outputs_dir}/../grading.json` (sibling to outputs_dir).
94
+
95
+ ## Grading Criteria
96
+
97
+ **PASS when**:
98
+ - The transcript or outputs clearly demonstrate the expectation is true
99
+ - Specific evidence can be cited
100
+ - The evidence reflects genuine substance, not just surface compliance (e.g., a file exists AND contains correct content, not just the right filename)
101
+
102
+ **FAIL when**:
103
+ - No evidence found for the expectation
104
+ - Evidence contradicts the expectation
105
+ - The expectation cannot be verified from available information
106
+ - The evidence is superficial — the assertion is technically satisfied but the underlying task outcome is wrong or incomplete
107
+ - The output appears to meet the assertion by coincidence rather than by actually doing the work
108
+
109
+ **When uncertain**: The burden of proof to pass is on the expectation.
110
+
111
+ ### Step 8: Read Executor Metrics and Timing
112
+
113
+ 1. If `{outputs_dir}/metrics.json` exists, copy only recorded metrics into the grading output; derive additional counts only from the actual transcript.
114
+ 2. If `{outputs_dir}/../timing.json` exists, copy its measured executor timing. Do not substitute the orchestration subagent's time or usage, and do not add grader time to executor benchmark time.
115
+ 3. Omit unavailable metrics or timing fields. Never estimate tokens from text length, invent tool counts, or report missing measurements as zero. State missing evidence in `user_notes_summary.needs_review`.
116
+
117
+ ## Output Format
118
+
119
+ Write a JSON file with this structure:
120
+
121
+ ```json
122
+ {
123
+ "expectations": [
124
+ {
125
+ "text": "The output includes the name 'John Smith'",
126
+ "passed": true,
127
+ "evidence": "Found in transcript Step 3: 'Extracted names: John Smith, Sarah Johnson'"
128
+ },
129
+ {
130
+ "text": "The spreadsheet has a SUM formula in cell B10",
131
+ "passed": false,
132
+ "evidence": "No spreadsheet was created. The output was a text file."
133
+ },
134
+ {
135
+ "text": "The assistant used the skill's OCR script",
136
+ "passed": true,
137
+ "evidence": "Pi tool execution shows: 'bash: python3 ocr_script.py image.png'"
138
+ }
139
+ ],
140
+ "summary": {
141
+ "passed": 2,
142
+ "failed": 1,
143
+ "total": 3,
144
+ "pass_rate": 0.67
145
+ },
146
+ "execution_metrics": {
147
+ "tool_calls": {
148
+ "read": 5,
149
+ "write": 2,
150
+ "bash": 8
151
+ },
152
+ "total_tool_calls": 15,
153
+ "total_steps": 6,
154
+ "errors_encountered": 0,
155
+ "output_chars": 12450,
156
+ "transcript_chars": 3200
157
+ },
158
+ "timing": {
159
+ "executor_duration_seconds": 165.0,
160
+ "grader_duration_seconds": 26.0,
161
+ "total_duration_seconds": 165.0
162
+ },
163
+ "claims": [
164
+ {
165
+ "claim": "The form has 12 fillable fields",
166
+ "type": "factual",
167
+ "verified": true,
168
+ "evidence": "Counted 12 fields in field_info.json"
169
+ },
170
+ {
171
+ "claim": "All required fields were populated",
172
+ "type": "quality",
173
+ "verified": false,
174
+ "evidence": "Reference section was left blank despite data being available"
175
+ }
176
+ ],
177
+ "user_notes_summary": {
178
+ "uncertainties": ["Used 2023 data, may be stale"],
179
+ "needs_review": [],
180
+ "workarounds": ["Fell back to text overlay for non-fillable fields"]
181
+ },
182
+ "eval_feedback": {
183
+ "suggestions": [
184
+ {
185
+ "assertion": "The output includes the name 'John Smith'",
186
+ "reason": "A hallucinated document that mentions the name would also pass — consider checking it appears as the primary contact with matching phone and email from the input"
187
+ },
188
+ {
189
+ "reason": "No assertion checks whether the extracted phone numbers match the input — I observed incorrect numbers in the output that went uncaught"
190
+ }
191
+ ],
192
+ "overall": "Assertions check presence but not correctness. Consider adding content verification."
193
+ }
194
+ }
195
+ ```
196
+
197
+ ## Field Descriptions
198
+
199
+ - **expectations**: Array of graded expectations
200
+ - **text**: The original expectation text
201
+ - **passed**: Boolean - true if expectation passes
202
+ - **evidence**: Specific quote or description supporting the verdict
203
+ - **summary**: Aggregate statistics
204
+ - **passed**: Count of passed expectations
205
+ - **failed**: Count of failed expectations
206
+ - **total**: Total expectations evaluated
207
+ - **pass_rate**: Fraction passed (0.0 to 1.0)
208
+ - **execution_metrics**: Copied from executor's metrics.json (if available)
209
+ - **output_chars**: Actual character count of output files; not a token measurement
210
+ - **transcript_chars**: Character count of transcript
211
+ - **timing**: Wall clock timing from timing.json (if available)
212
+ - **executor_duration_seconds**: Measured time spent in the fresh Pi executor process
213
+ - **total_duration_seconds**: Total elapsed time for the run
214
+ - **claims**: Extracted and verified claims from the output
215
+ - **claim**: The statement being verified
216
+ - **type**: "factual", "process", or "quality"
217
+ - **verified**: Boolean - whether the claim holds
218
+ - **evidence**: Supporting or contradicting evidence
219
+ - **user_notes_summary**: Issues flagged by the executor
220
+ - **uncertainties**: Things the executor wasn't sure about
221
+ - **needs_review**: Items requiring human attention
222
+ - **workarounds**: Places where the skill didn't work as expected
223
+ - **eval_feedback**: Improvement suggestions for the evals (only when warranted)
224
+ - **suggestions**: List of concrete suggestions, each with a `reason` and optionally an `assertion` it relates to
225
+ - **overall**: Brief assessment — can be "No suggestions, evals look solid" if nothing to flag
226
+
227
+ ## Guidelines
228
+
229
+ - **Be objective**: Base verdicts on evidence, not assumptions
230
+ - **Be specific**: Quote the exact text that supports your verdict
231
+ - **Be thorough**: Check both transcript and output files
232
+ - **Be consistent**: Apply the same standard to each expectation
233
+ - **Explain failures**: Make it clear why evidence was insufficient
234
+ - **No partial credit**: Each expectation is pass or fail, not partial
@@ -0,0 +1,146 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Eval Set Review - __SKILL_NAME_PLACEHOLDER__</title>
7
+ <link rel="preconnect" href="https://fonts.googleapis.com">
8
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
9
+ <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@500;600&family=Lora:wght@400;500&display=swap" rel="stylesheet">
10
+ <style>
11
+ * { box-sizing: border-box; margin: 0; padding: 0; }
12
+ body { font-family: 'Lora', Georgia, serif; background: #faf9f5; padding: 2rem; color: #141413; }
13
+ h1 { font-family: 'Poppins', sans-serif; margin-bottom: 0.5rem; font-size: 1.5rem; }
14
+ .description { color: #b0aea5; margin-bottom: 1.5rem; font-style: italic; max-width: 900px; }
15
+ .controls { margin-bottom: 1rem; display: flex; gap: 0.5rem; }
16
+ .btn { font-family: 'Poppins', sans-serif; padding: 0.5rem 1rem; border: none; border-radius: 6px; cursor: pointer; font-size: 0.875rem; font-weight: 500; }
17
+ .btn-add { background: #6a9bcc; color: white; }
18
+ .btn-add:hover { background: #5889b8; }
19
+ .btn-export { background: #d97757; color: white; }
20
+ .btn-export:hover { background: #c4613f; }
21
+ table { width: 100%; max-width: 1100px; border-collapse: collapse; background: white; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
22
+ th { font-family: 'Poppins', sans-serif; background: #141413; color: #faf9f5; padding: 0.75rem 1rem; text-align: left; font-size: 0.875rem; }
23
+ td { padding: 0.75rem 1rem; border-bottom: 1px solid #e8e6dc; vertical-align: top; }
24
+ tr:nth-child(even) td { background: #faf9f5; }
25
+ tr:hover td { background: #f3f1ea; }
26
+ .section-header td { background: #e8e6dc; font-family: 'Poppins', sans-serif; font-weight: 500; font-size: 0.8rem; color: #141413; text-transform: uppercase; letter-spacing: 0.05em; }
27
+ .query-input { width: 100%; padding: 0.4rem; border: 1px solid #e8e6dc; border-radius: 4px; font-size: 0.875rem; font-family: 'Lora', Georgia, serif; resize: vertical; min-height: 60px; }
28
+ .query-input:focus { outline: none; border-color: #d97757; box-shadow: 0 0 0 2px rgba(217,119,87,0.15); }
29
+ .toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
30
+ .toggle input { opacity: 0; width: 0; height: 0; }
31
+ .toggle .slider { position: absolute; inset: 0; background: #b0aea5; border-radius: 24px; cursor: pointer; transition: 0.2s; }
32
+ .toggle .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
33
+ .toggle input:checked + .slider { background: #d97757; }
34
+ .toggle input:checked + .slider::before { transform: translateX(20px); }
35
+ .btn-delete { background: #c44; color: white; padding: 0.3rem 0.6rem; border: none; border-radius: 4px; cursor: pointer; font-size: 0.75rem; font-family: 'Poppins', sans-serif; }
36
+ .btn-delete:hover { background: #a33; }
37
+ .summary { margin-top: 1rem; color: #b0aea5; font-size: 0.875rem; }
38
+ </style>
39
+ </head>
40
+ <body>
41
+ <h1>Eval Set Review: <span id="skill-name">__SKILL_NAME_PLACEHOLDER__</span></h1>
42
+ <p class="description">Current description: <span id="skill-desc">__SKILL_DESCRIPTION_PLACEHOLDER__</span></p>
43
+
44
+ <div class="controls">
45
+ <button class="btn btn-add" onclick="addRow()">+ Add Query</button>
46
+ <button class="btn btn-export" onclick="exportEvalSet()">Export Eval Set</button>
47
+ </div>
48
+
49
+ <table>
50
+ <thead>
51
+ <tr>
52
+ <th style="width:65%">Query</th>
53
+ <th style="width:18%">Should Trigger</th>
54
+ <th style="width:10%">Actions</th>
55
+ </tr>
56
+ </thead>
57
+ <tbody id="eval-body"></tbody>
58
+ </table>
59
+
60
+ <p class="summary" id="summary"></p>
61
+
62
+ <script>
63
+ const EVAL_DATA = __EVAL_DATA_PLACEHOLDER__;
64
+
65
+ let evalItems = [...EVAL_DATA];
66
+
67
+ function render() {
68
+ const tbody = document.getElementById('eval-body');
69
+ tbody.innerHTML = '';
70
+
71
+ // Sort: should-trigger first, then should-not-trigger
72
+ const sorted = evalItems
73
+ .map((item, origIdx) => ({ ...item, origIdx }))
74
+ .sort((a, b) => (b.should_trigger ? 1 : 0) - (a.should_trigger ? 1 : 0));
75
+
76
+ let lastGroup = null;
77
+ sorted.forEach(item => {
78
+ const group = item.should_trigger ? 'trigger' : 'no-trigger';
79
+ if (group !== lastGroup) {
80
+ const headerRow = document.createElement('tr');
81
+ headerRow.className = 'section-header';
82
+ headerRow.innerHTML = `<td colspan="3">${item.should_trigger ? 'Should Trigger' : 'Should NOT Trigger'}</td>`;
83
+ tbody.appendChild(headerRow);
84
+ lastGroup = group;
85
+ }
86
+
87
+ const idx = item.origIdx;
88
+ const tr = document.createElement('tr');
89
+ tr.innerHTML = `
90
+ <td><textarea class="query-input" onchange="updateQuery(${idx}, this.value)">${escapeHtml(item.query)}</textarea></td>
91
+ <td>
92
+ <label class="toggle">
93
+ <input type="checkbox" ${item.should_trigger ? 'checked' : ''} onchange="updateTrigger(${idx}, this.checked)">
94
+ <span class="slider"></span>
95
+ </label>
96
+ <span style="margin-left:8px;font-size:0.8rem;color:#b0aea5">${item.should_trigger ? 'Yes' : 'No'}</span>
97
+ </td>
98
+ <td><button class="btn-delete" onclick="deleteRow(${idx})">Delete</button></td>
99
+ `;
100
+ tbody.appendChild(tr);
101
+ });
102
+ updateSummary();
103
+ }
104
+
105
+ function escapeHtml(text) {
106
+ const div = document.createElement('div');
107
+ div.textContent = text;
108
+ return div.innerHTML;
109
+ }
110
+
111
+ function updateQuery(idx, value) { evalItems[idx].query = value; updateSummary(); }
112
+ function updateTrigger(idx, value) { evalItems[idx].should_trigger = value; render(); }
113
+ function deleteRow(idx) { evalItems.splice(idx, 1); render(); }
114
+
115
+ function addRow() {
116
+ evalItems.push({ query: '', should_trigger: true });
117
+ render();
118
+ const inputs = document.querySelectorAll('.query-input');
119
+ inputs[inputs.length - 1].focus();
120
+ }
121
+
122
+ function updateSummary() {
123
+ const trigger = evalItems.filter(i => i.should_trigger).length;
124
+ const noTrigger = evalItems.filter(i => !i.should_trigger).length;
125
+ document.getElementById('summary').textContent =
126
+ `${evalItems.length} queries total: ${trigger} should trigger, ${noTrigger} should not trigger`;
127
+ }
128
+
129
+ function exportEvalSet() {
130
+ const valid = evalItems.filter(i => i.query.trim() !== '');
131
+ const data = valid.map(i => ({ query: i.query.trim(), should_trigger: i.should_trigger }));
132
+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
133
+ const url = URL.createObjectURL(blob);
134
+ const a = document.createElement('a');
135
+ a.href = url;
136
+ a.download = 'eval_set.json';
137
+ document.body.appendChild(a);
138
+ a.click();
139
+ document.body.removeChild(a);
140
+ URL.revokeObjectURL(url);
141
+ }
142
+
143
+ render();
144
+ </script>
145
+ </body>
146
+ </html>