@opensoftware/scorekit 0.0.0-stage → 0.4.0

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 (50) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +226 -2
  3. package/dist/adapters/files.js +53 -0
  4. package/dist/adapters/files.js.map +1 -0
  5. package/dist/adapters/judge.js +23 -0
  6. package/dist/adapters/judge.js.map +1 -0
  7. package/dist/adapters/langfuse.js +54 -0
  8. package/dist/adapters/langfuse.js.map +1 -0
  9. package/dist/cli.js +72 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/commands/calibrate.js +36 -0
  12. package/dist/commands/calibrate.js.map +1 -0
  13. package/dist/commands/export.js +53 -0
  14. package/dist/commands/export.js.map +1 -0
  15. package/dist/commands/judge-runs.js +32 -0
  16. package/dist/commands/judge-runs.js.map +1 -0
  17. package/dist/commands/push.js +15 -0
  18. package/dist/commands/push.js.map +1 -0
  19. package/dist/commands/report.js +12 -0
  20. package/dist/commands/report.js.map +1 -0
  21. package/dist/commands/score.js +40 -0
  22. package/dist/commands/score.js.map +1 -0
  23. package/dist/commands/scorers.js +8 -0
  24. package/dist/commands/scorers.js.map +1 -0
  25. package/dist/domain/calibration.js +30 -0
  26. package/dist/domain/calibration.js.map +1 -0
  27. package/dist/domain/evaluator.js +48 -0
  28. package/dist/domain/evaluator.js.map +1 -0
  29. package/dist/domain/judge.js +48 -0
  30. package/dist/domain/judge.js.map +1 -0
  31. package/dist/domain/lines.js +16 -0
  32. package/dist/domain/lines.js.map +1 -0
  33. package/dist/domain/report.js +56 -0
  34. package/dist/domain/report.js.map +1 -0
  35. package/dist/domain/runs.js +34 -0
  36. package/dist/domain/runs.js.map +1 -0
  37. package/dist/domain/sample.js +7 -0
  38. package/dist/domain/sample.js.map +1 -0
  39. package/dist/domain/score.js +25 -0
  40. package/dist/domain/score.js.map +1 -0
  41. package/dist/domain/scorer.js +65 -0
  42. package/dist/domain/scorer.js.map +1 -0
  43. package/dist/domain/transcript.js +60 -0
  44. package/dist/domain/transcript.js.map +1 -0
  45. package/package.json +35 -3
  46. package/scorers/change-requested.md +16 -0
  47. package/scorers/needless-human-question.md +17 -0
  48. package/scorers/redundant-tests.md +18 -0
  49. package/scorers/scope-creep.md +17 -0
  50. package/scorers/skipped-checks.md +18 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,227 @@
1
- # Temporary Holding Version
1
+ ---
2
+ covers: [modules/scorekit/src/**, modules/scorekit/scorers/**]
3
+ ---
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ # scorekit
6
+
7
+ Grade a team's agent sessions on concrete failure modes. A scorer is a Markdown file with a judge prompt, a pass
8
+ criterion and a sampling rate. scorekit asks an LLM judge about each sampled run and writes one score per run, with
9
+ pass or fail, the reason and the judge's cost. `calibrate` checks a judge against labels a person wrote before you
10
+ trust it, and `report` shows each scorer's pass rate over time. `export` turns the
11
+ scorers into Langfuse evaluators, so Langfuse can judge new runs as they arrive. Decisions:
12
+ [ADR 0032](../../docs/decisions/0032-scorekit.md), [ADR 0033](../../docs/decisions/0033-scorekit-langfuse-evaluators.md).
13
+
14
+ ## Quick start
15
+
16
+ This quick start is scenario `SCN-SCORE-001` and is tested on every change. Save two runs as runlog writes them
17
+ ([`modules/runlog`](../runlog/README.md)):
18
+
19
+ ```jsonl runs.jsonl
20
+ {"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"claude-code"}},{"key":"osf.run.id","value":{"stringValue":"run-01"}},{"key":"osf.harness.name","value":{"stringValue":"claude-code"}}]},"scopeSpans":[{"scope":{"name":"@opensoftware/runlog"},"spans":[{"traceId":"0af7651916cd43dd8448eb211c80319c","spanId":"0af7651916cd43dd","name":"invoke_agent","startTimeUnixNano":"1767258000000000000","endTimeUnixNano":"1767258060000000000","attributes":[{"key":"gen_ai.operation.name","value":{"stringValue":"invoke_agent"}},{"key":"gen_ai.request.model","value":{"stringValue":"claude-sonnet-5-5"}},{"key":"osf.outcome","value":{"stringValue":"succeeded"}}]},{"traceId":"0af7651916cd43dd8448eb211c80319c","spanId":"8448eb211c80319c","parentSpanId":"0af7651916cd43dd","name":"chat claude-sonnet-5-5","startTimeUnixNano":"1767258001000000000","endTimeUnixNano":"1767258003000000000","attributes":[{"key":"gen_ai.operation.name","value":{"stringValue":"chat"}},{"key":"gen_ai.input.messages","value":{"stringValue":"[{\"role\":\"user\",\"parts\":[{\"type\":\"text\",\"content\":\"Add a sum function with a test\"}]}]"}}]},{"traceId":"0af7651916cd43dd8448eb211c80319c","spanId":"af7651916cd43dd8","parentSpanId":"0af7651916cd43dd","name":"execute_tool Write","startTimeUnixNano":"1767258004000000000","endTimeUnixNano":"1767258004500000000","attributes":[{"key":"gen_ai.operation.name","value":{"stringValue":"execute_tool"}},{"key":"gen_ai.tool.name","value":{"stringValue":"Write"}},{"key":"gen_ai.tool.call.arguments","value":{"stringValue":"{\"file_path\":\"test/sum.test.ts\"}"}}]}]}]}]}
21
+ {"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"claude-code"}},{"key":"osf.run.id","value":{"stringValue":"run-02"}},{"key":"osf.harness.name","value":{"stringValue":"claude-code"}}]},"scopeSpans":[{"scope":{"name":"@opensoftware/runlog"},"spans":[{"traceId":"4bf92f3577b34da6a3ce929d0e0e4736","spanId":"4bf92f3577b34da6","name":"invoke_agent","startTimeUnixNano":"1767258000000000000","endTimeUnixNano":"1767258060000000000","attributes":[{"key":"gen_ai.operation.name","value":{"stringValue":"invoke_agent"}},{"key":"gen_ai.request.model","value":{"stringValue":"claude-sonnet-5-5"}},{"key":"osf.outcome","value":{"stringValue":"succeeded"}}]},{"traceId":"4bf92f3577b34da6a3ce929d0e0e4736","spanId":"a3ce929d0e0e4736","parentSpanId":"4bf92f3577b34da6","name":"chat claude-sonnet-5-5","startTimeUnixNano":"1767258001000000000","endTimeUnixNano":"1767258003000000000","attributes":[{"key":"gen_ai.operation.name","value":{"stringValue":"chat"}},{"key":"gen_ai.input.messages","value":{"stringValue":"[{\"role\":\"user\",\"parts\":[{\"type\":\"text\",\"content\":\"Fix the login redirect\"}]}]"}}]},{"traceId":"4bf92f3577b34da6a3ce929d0e0e4736","spanId":"bf92f3577b34da6a","parentSpanId":"4bf92f3577b34da6","name":"execute_tool Write","startTimeUnixNano":"1767258004000000000","endTimeUnixNano":"1767258004500000000","attributes":[{"key":"gen_ai.operation.name","value":{"stringValue":"execute_tool"}},{"key":"gen_ai.tool.name","value":{"stringValue":"Write"}},{"key":"gen_ai.tool.call.arguments","value":{"stringValue":"{\"file_path\":\"src/login.ts\"}"}}]}]}]}]}
22
+ ```
23
+
24
+ Point scorekit at any OpenAI-compatible gateway, for example LiteLLM with a model alias `judge`, and score both runs:
25
+
26
+ ```sh
27
+ export SCOREKIT_INFERENCE_URL=http://localhost:4000/v1
28
+ npx @opensoftware/scorekit score --scorer redundant-tests --sample 1 runs.jsonl
29
+ ```
30
+
31
+ It appends two lines to `$OUTPUT/scores.jsonl`: one score per run in the format of the `score` contract
32
+ ([`contracts/`](../../contracts/README.md)), with the value 1 for pass or 0 for fail and the judge's reason as
33
+ `comment`. It prints `scored 2 of 2 runs with redundant-tests: ...`.
34
+
35
+ ## Commands
36
+
37
+ | Command | What it does |
38
+ | --- | --- |
39
+ | `scorekit score --scorer <name or file> <runs>...` | Judge each sampled run that has no score of the scorer yet in `--out` (`$OUTPUT/scores.jsonl`) and append its score. `--seed <n>` (0) and `--sample <0..1>` change the sampling. |
40
+ | `scorekit calibrate --scorer <name or file> --labels <file> <runs>...` | Judge every labeled run and write the agreement with the labels to `--out` (`$OUTPUT/calibration.json`). `--min-agreement <0..1>` exits 1 below it. |
41
+ | `scorekit report <scores>...` | Write each scorer's runs, passes, fails, pass rate, cost, pass rate per day and scored runs to `--out` (`$OUTPUT/report.json`); `--markdown <file>` writes the same as Markdown tables. |
42
+ | `scorekit push <scores>...` | Send the scores to Langfuse's score API (`POST /api/public/scores`). |
43
+ | `scorekit export [--scorer <name or file>]...` | Write the scorers (default: the pack) as Langfuse LLM-as-a-judge evaluators with their evaluation rules to `--out` (`$OUTPUT/evaluators.json`). `--provider <name> --model <name>` set the evaluators' model. |
44
+ | `scorekit export --push [--enable] [--scorer <name or file>]...` | Create or update the evaluators in Langfuse. A new evaluator gets a rule, disabled unless `--enable`. See [Langfuse evaluators](#langfuse-evaluators). |
45
+ | `scorekit scorers` | List the scorers of the pack with their sampling rate and description. |
46
+
47
+ `<runs>` are files of OTLP/JSON trace export requests, one per line, or folders: every `.jsonl` file below a folder
48
+ is read. A run is the span `invoke_agent` with the other spans of its trace; its ID is `osf.run.id`. A wrong
49
+ option, scorer file or input file exits 2 before any judge call. A failed judge call or an answer without a verdict
50
+ is named on the error output; the other runs are still judged and the command exits 1.
51
+
52
+ ## Scorer files
53
+
54
+ ```markdown scorers/slow-tests.md
55
+ ---
56
+ description: Tests wait for time to pass.
57
+ pass: No test waits longer than one second.
58
+ sample: 0.2
59
+ model: judge
60
+ price: { input: 3, output: 15 }
61
+ ---
62
+ Look for sleep calls and fixed timeouts in the tests the agent wrote or ran.
63
+ ```
64
+
65
+ | Key | Meaning |
66
+ | --- | --- |
67
+ | `name` | The scorer's name in each score. Default: the file name without `.md`. |
68
+ | `description` | One line for `scorekit scorers`. |
69
+ | `pass` | Required. The pass criterion, one sentence. |
70
+ | `sample` | Share of runs to score, 0 to 1. Default 1. |
71
+ | `model` | The judge model the gateway gets. Default `judge`. |
72
+ | `price` | `input` and `output` in USD per million tokens. With it, each score records the judge cost from the token usage the gateway reports. |
73
+ | `max_chars` | Longest transcript the judge reads. Default 200000. A longer transcript loses its middle, with a marker that says how many characters were cut. |
74
+
75
+ The text after the front matter is the judge prompt. Any other key exits 2. In a factory definition,
76
+ `scorers.<name>.judge` points at this file.
77
+
78
+ ## What the judge sees
79
+
80
+ One chat completion per run, at temperature 0. The system message holds the prompt and the pass criterion and asks
81
+ for one JSON object: `{"result": "pass" | "fail", "reason": "..."}`. The user message is the transcript: the run
82
+ ID, harness, stage, model, outcome, pull requests, issues, duration and tokens, then each step in time order. A step
83
+ is a message of a `chat` span when the run carries prompt content (runlog `--include-content`), or a tool call with
84
+ its name and, when present, its arguments and result. Without prompt content the judge sees only the tool calls.
85
+
86
+ ## Sampling
87
+
88
+ A run is scored when the first 32 bits of SHA-256 of `<seed>:<scorer name>:<run id>`, divided by 2^32, are below
89
+ `sample`. So the same run is always in or out for a scorer and a seed, whatever the other runs are. With 100 runs
90
+ and `sample: 0.2`, about 20 are scored. `score` skips a run that already has a score of the scorer in the output
91
+ file, so a nightly job can run on all runs and only pays for new ones.
92
+
93
+ ## Calibration
94
+
95
+ Labels are score records with the source `ANNOTATION`, as a person writes them in Langfuse or by hand: `name` is
96
+ the scorer, `value` is 1 for pass or 0 for fail, and `metadata."osf.run.id"` names the run. `calibrate` judges
97
+ every labeled run without sampling and writes:
98
+
99
+ | Field | Meaning |
100
+ | --- | --- |
101
+ | `agreement` | Share of runs where the judge and the label agree. |
102
+ | `kappa` | Cohen's kappa: agreement beyond chance; `null` when chance explains it all. |
103
+ | `counts` | `truePass`, `falsePass` (judge pass, label fail), `trueFail`, `falseFail` (judge fail, label pass). |
104
+ | `disagreements` | Each run where they differ, with the label, the result and the judge's reason. |
105
+ | `missing` | Labels without a run in the runs files; they are named on the error output and not counted. |
106
+
107
+ It prints `agreement 18 of 20 (90.0%), kappa 0.80`. With `--min-agreement 0.8` it exits 1 below 80 percent.
108
+
109
+ ## Scorer pack
110
+
111
+ The package ships these scorers in [`scorers/`](scorers/). Use them by name or copy one as a start:
112
+
113
+ | Scorer | Fails a run when |
114
+ | --- | --- |
115
+ | [`redundant-tests`](scorers/redundant-tests.md) | the agent added tests that prove nothing new |
116
+ | [`change-requested`](scorers/change-requested.md) | a person had to ask for changes after the agent said it was done |
117
+ | [`scope-creep`](scorers/scope-creep.md) | the agent changed more than the task asked for |
118
+ | [`skipped-checks`](scorers/skipped-checks.md) | the agent claimed success without running the checks |
119
+ | [`needless-human-question`](scorers/needless-human-question.md) | the agent asked a person something it could have found out itself |
120
+
121
+ ## Langfuse
122
+
123
+ A score is a subset of Langfuse's create-score request, so `push` sends it as is to `$LANGFUSE_HOST/api/public/scores`
124
+ with basic auth from `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY`. The score's `traceId` is the run's trace, so
125
+ the score appears on the run in Langfuse when the run was sent there too. Langfuse keeps one score per ID, and a
126
+ score's ID comes from the scorer and the run, so a second push changes nothing.
127
+
128
+ ## Langfuse evaluators
129
+
130
+ `export` maps each scorer to Langfuse's public API v2 (ADR 0033):
131
+
132
+ | Scorer | Evaluator in Langfuse |
133
+ | --- | --- |
134
+ | `name`, `description` | `name`, `description` of an `llm_as_judge` evaluator |
135
+ | prompt and `pass` | a system message with the prompt and `Pass criterion: <pass>`, and a user message with `{{input}}` and `{{output}}`, mapped to the observation's input and output |
136
+ | `pass` | a `BOOLEAN` output whose value instructions repeat the pass criterion |
137
+ | `sample` | the sampling of the rule `scorekit <name>`, which matches the observations named `invoke_agent`, the root span of a run |
138
+ | `model` | not exported: it is a gateway alias. `--provider` and `--model` set `modelConfig`; without them Langfuse uses the project's default evaluation model |
139
+
140
+ ```sh
141
+ export LANGFUSE_PUBLIC_KEY=pk-lf-... LANGFUSE_SECRET_KEY=sk-lf-...
142
+ npx @opensoftware/scorekit export --push --scorer redundant-tests --provider anthropic --model claude-haiku-5-5
143
+ ```
144
+
145
+ `--push` lists the project's evaluators and takes the newest one with the scorer's name. When there is none, it
146
+ creates the evaluator and its rule and prints `created <scorer>`. When the description, prompt, output and model
147
+ are the same, it sends nothing and prints `unchanged <scorer>`. Otherwise it replaces the definition, which makes a
148
+ new version in Langfuse with the same ID and rules, and prints `updated <scorer>`. An existing rule is never
149
+ changed, so a sampling rate or filter a person set in Langfuse stays. The rule starts disabled, because an enabled
150
+ rule makes Langfuse call a paid model for each new run; enable it in Langfuse or pass `--enable`.
151
+
152
+ The evaluator sees only the root observation's input and output, not the transcript with every tool call that
153
+ `score` builds. Calibrate the scores of each runtime before you trust them.
154
+
155
+ ## Releases
156
+
157
+ release-please opens a release pull request from the Conventional Commits under `modules/scorekit/`. Merging it
158
+ creates the tag `scorekit-v<version>`, and `.github/workflows/publish-scorekit.yml` builds `dist/` and publishes
159
+ `@opensoftware/scorekit` to npm. The first release is `0.1.0`; until `1.0.0`, a breaking change raises the minor
160
+ version. The one-time setup is the same as for contracts ([`contracts/README.md`](../../contracts/README.md#releases)),
161
+ with a trusted publisher for `publish-scorekit.yml`. No credential is stored in the repository.
162
+
163
+ ## Configuration
164
+
165
+ <!-- generated by make docs from src/config.schema.json: do not edit -->
166
+
167
+ | Variable | Type | Default | Meaning |
168
+ | --- | --- | --- | --- |
169
+ | `OUTPUT` | string | `"."` | Folder of scores.jsonl, calibration.json, report.json and evaluators.json when --out is not given. |
170
+ | `SCOREKIT_INFERENCE_URL` | string | | Base URL of the OpenAI-compatible gateway of the judge, ending in /v1, for example http://litellm:4000/v1. Required by score and calibrate. |
171
+ | `SCOREKIT_INFERENCE_KEY` | string | | API key of the gateway, sent as a bearer token. Never write the value into a file. |
172
+ | `LANGFUSE_HOST` | string | `"https://cloud.langfuse.com"` | Base URL of Langfuse for push and export --push. |
173
+ | `LANGFUSE_PUBLIC_KEY` | string | | Langfuse public key for push and export --push. |
174
+ | `LANGFUSE_SECRET_KEY` | string | | Langfuse secret key for push and export --push. Never write the value into a file. |
175
+ | `OSF_NOW` | string | | The time of new scores as an ISO 8601 timestamp. Default: the system clock. |
176
+
177
+ ## Scenarios
178
+
179
+ <!-- generated by make docs from features/: do not edit -->
180
+
181
+ | ID | Status | Scenario |
182
+ | --- | --- | --- |
183
+ | SCN-SCORE-001 | implemented | A new user scores the sample runs from the README |
184
+ | SCN-SCORE-002 | implemented | The help lists every command |
185
+ | SCN-SCORE-003 | implemented | A run the judge passes gets the score 1 with the reason |
186
+ | SCN-SCORE-004 | implemented | A run the judge fails gets the score 0 |
187
+ | SCN-SCORE-005 | implemented | The judge gets the scorer's prompt, its pass criterion and the run's tool calls |
188
+ | SCN-SCORE-006 | implemented | The judge gets the run's messages when the run carries prompt content |
189
+ | SCN-SCORE-007 | implemented | A scorer with a sampling rate of 20 percent scores the runs its seed picks |
190
+ | SCN-SCORE-008 | implemented | The seed picks the same runs when the runs file lists them in another order |
191
+ | SCN-SCORE-009 | implemented | The option "--sample" overrides the scorer's sampling rate |
192
+ | SCN-SCORE-010 | implemented | The judge cost is recorded from the token usage and the scorer's price |
193
+ | SCN-SCORE-011 | implemented | A run that already has a score of the scorer is not judged again |
194
+ | SCN-SCORE-012 | implemented | An answer that is not a verdict gives no score and fails the command |
195
+ | SCN-SCORE-013 | implemented | A failed judge call is named and the other runs are still scored |
196
+ | SCN-SCORE-014 | implemented | A transcript longer than the scorer's limit loses its middle |
197
+ | SCN-SCORE-015 | implemented | A scorer file with an unknown key is refused |
198
+ | SCN-SCORE-016 | implemented | Without an inference URL the command names the missing variable |
199
+ | SCN-SCORE-017 | implemented | The inference key is sent as a bearer token |
200
+ | SCN-SCORE-018 | implemented | A folder of runs files is read |
201
+ | SCN-SCORE-019 | implemented | Calibration reports the agreement with 20 labeled runs |
202
+ | SCN-SCORE-020 | implemented | Calibration lists each disagreement with the label, the result and the reason |
203
+ | SCN-SCORE-021 | implemented | Calibration below the minimum agreement fails the command |
204
+ | SCN-SCORE-022 | implemented | A label without a run is named and not counted |
205
+ | SCN-SCORE-023 | implemented | The report shows each scorer's pass rate, cost and scored runs |
206
+ | SCN-SCORE-024 | implemented | The report shows the pass rate per day |
207
+ | SCN-SCORE-025 | implemented | The report is written as Markdown |
208
+ | SCN-SCORE-026 | implemented | Push sends every score to Langfuse with basic auth |
209
+ | SCN-SCORE-027 | implemented | A score Langfuse refuses is named and fails the command |
210
+ | SCN-SCORE-028 | implemented | The pack lists five scorers with their sampling rate and description |
211
+ | SCN-SCORE-029 | implemented | An unknown scorer name is refused with the names of the pack |
212
+ | SCN-SCORE-030 | implemented | A scorer file without a pass criterion is refused |
213
+ | SCN-SCORE-031 | implemented | A scorer file whose front matter is not YAML is refused |
214
+ | SCN-SCORE-032 | implemented | A runs file line that is not JSON is named with its file and line |
215
+ | SCN-SCORE-033 | implemented | Export writes the five scorers of the pack as evaluators |
216
+ | SCN-SCORE-034 | implemented | An exported evaluator carries the judge prompt and the pass criterion as a boolean score |
217
+ | SCN-SCORE-035 | implemented | The evaluation rule samples the scorer's share of the runs and starts disabled |
218
+ | SCN-SCORE-036 | implemented | The options "--provider" and "--model" set the evaluator's model |
219
+ | SCN-SCORE-037 | implemented | Without "--model" the evaluator uses the project's default evaluation model |
220
+ | SCN-SCORE-038 | implemented | The option "--model" without "--provider" is refused |
221
+ | SCN-SCORE-039 | implemented | Push creates a missing evaluator and its disabled rule in Langfuse with basic auth |
222
+ | SCN-SCORE-040 | implemented | Push with "--enable" creates the rule enabled |
223
+ | SCN-SCORE-041 | implemented | Push leaves an evaluator alone when Langfuse already holds the same definition |
224
+ | SCN-SCORE-042 | implemented | Push updates a changed evaluator and keeps its rule |
225
+ | SCN-SCORE-043 | implemented | Push finds an evaluator on the second page of Langfuse's list |
226
+ | SCN-SCORE-044 | implemented | An evaluator Langfuse refuses is named and fails the command |
227
+ | SCN-SCORE-045 | implemented | Push without Langfuse keys names the missing variables |
@@ -0,0 +1,53 @@
1
+ // Files: runs files and folders, scorer files and the pack, score files.
2
+ import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync } from "node:fs";
3
+ import { basename, dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { readInputs, UsageError } from "@opensoftware/cli";
6
+ import { validate } from "@opensoftware/contracts";
7
+ import { jsonLines } from "../domain/lines.js";
8
+ import { parseScorer } from "../domain/scorer.js";
9
+ /** The scorers the package ships, in scorers/ next to dist/. */
10
+ const PACK = fileURLToPath(new URL("../../scorers/", import.meta.url));
11
+ /** Each runs file named, and every .jsonl file below each folder named, sorted by path. */
12
+ export function readRunFiles(paths) {
13
+ if (!paths.length)
14
+ throw new UsageError("name at least one runs file or folder");
15
+ return readInputs(paths, /\.jsonl$/);
16
+ }
17
+ export function packNames() {
18
+ return readdirSync(PACK)
19
+ .filter((file) => file.endsWith(".md"))
20
+ .map((file) => file.slice(0, -3))
21
+ .sort();
22
+ }
23
+ /** A scorer by pack name, or by path when the value names a Markdown file or a folder. */
24
+ export function readScorer(value) {
25
+ if (!value)
26
+ throw new UsageError("--scorer is required: a pack name or a scorer file");
27
+ const isPath = value.endsWith(".md") || value.includes("/");
28
+ const file = isPath ? value : join(PACK, `${value}.md`);
29
+ if (!existsSync(file))
30
+ throw new UsageError(isPath ? `${value}: no such scorer file` : `no scorer "${value}" in the pack: ${packNames().join(", ")}`);
31
+ return parseScorer(isPath ? value : `${value}.md`, basename(file, ".md"), readFileSync(file, "utf8"));
32
+ }
33
+ /** The score records of score files, each checked against the `score` contract. A missing file has none. */
34
+ export function readScores(paths, { missingOk = false } = {}) {
35
+ return paths.flatMap((path) => {
36
+ if (missingOk && !existsSync(path))
37
+ return [];
38
+ return jsonLines(path, readFileSync(path, "utf8")).map(({ line, value }) => {
39
+ const [problem] = validate("score", value);
40
+ if (problem)
41
+ throw new UsageError(`${path}:${line}: not a score: ${problem.path} ${problem.message}`);
42
+ return value;
43
+ });
44
+ });
45
+ }
46
+ export function appendScore(path, score) {
47
+ const problems = validate("score", score);
48
+ if (problems.length)
49
+ throw new Error(`a score breaks the contract: ${problems[0]?.path} ${problems[0]?.message}`);
50
+ mkdirSync(dirname(path), { recursive: true });
51
+ appendFileSync(path, `${JSON.stringify(score)}\n`);
52
+ }
53
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/adapters/files.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,OAAO,EAAE,cA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B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,KAAY;IACpD,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1C,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAClH,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,cAAc,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,23 @@
1
+ export class JudgeError extends Error {
2
+ name = "JudgeError";
3
+ }
4
+ export async function askJudge(gateway, model, messages) {
5
+ const response = await fetch(`${gateway.url.replace(/\/+$/, "")}/chat/completions`, {
6
+ method: "POST",
7
+ headers: {
8
+ "content-type": "application/json",
9
+ ...(gateway.key ? { authorization: `Bearer ${gateway.key}` } : {}),
10
+ },
11
+ body: JSON.stringify({ model, temperature: 0, messages }),
12
+ });
13
+ if (!response.ok)
14
+ throw new JudgeError(`the judge call failed with HTTP ${response.status}`);
15
+ const body = (await response.json().catch(() => ({})));
16
+ const usage = body.usage;
17
+ return {
18
+ text: body.choices?.[0]?.message?.content ?? "",
19
+ model: body.model ?? model,
20
+ usage: usage ? { input: usage.prompt_tokens ?? 0, output: usage.completion_tokens ?? 0 } : undefined,
21
+ };
22
+ }
23
+ //# sourceMappingURL=judge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"judge.js","sourceRoot":"","sources":["../../src/adapters/judge.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,GAAG,YAAY,C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auth: the score API (ADR 0032) and the v2 evaluator and evaluation-rule API
2
+ // (ADR 0033). Langfuse keeps one score per ID.
3
+ import { UsageError } from "@opensoftware/cli";
4
+ /** Langfuse from LANGFUSE_HOST, LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY. */
5
+ export function langfuseFrom(env) {
6
+ const { LANGFUSE_PUBLIC_KEY: publicKey, LANGFUSE_SECRET_KEY: secretKey } = env;
7
+ if (!publicKey || !secretKey)
8
+ throw new UsageError("set LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY");
9
+ return { host: env.LANGFUSE_HOST || "https://cloud.langfuse.com", publicKey, secretKey };
10
+ }
11
+ async function call(langfuse, method, path, body) {
12
+ const auth = Buffer.from(`${langfuse.publicKey}:${langfuse.secretKey}`).toString("base64");
13
+ const response = await fetch(`${langfuse.host.replace(/\/+$/, "")}${path}`, {
14
+ method,
15
+ headers: { "content-type": "application/json", authorization: `Basic ${auth}` },
16
+ body: body === undefined ? undefined : JSON.stringify(body),
17
+ });
18
+ if (!response.ok)
19
+ return { problem: `Langfuse answered HTTP ${response.status}` };
20
+ return { body: (await response.json().catch(() => ({}))) };
21
+ }
22
+ export async function pushScore(langfuse, score) {
23
+ return (await call(langfuse, "POST", "/api/public/scores", score)).problem;
24
+ }
25
+ /** Every evaluator of the project, newest first, following the cursor. */
26
+ export async function listEvaluators(langfuse) {
27
+ const evaluators = [];
28
+ let cursor;
29
+ do {
30
+ const query = cursor === undefined ? "" : `&cursor=${encodeURIComponent(cursor)}`;
31
+ const { problem, body } = await call(langfuse, "GET", `/api/public/v2/evaluators?limit=100${query}`);
32
+ if (problem)
33
+ throw new Error(`listing evaluators: ${problem}`);
34
+ evaluators.push(...(body?.data ?? []));
35
+ const next = body?.meta?.cursor;
36
+ cursor = typeof next === "string" && next ? next : undefined;
37
+ } while (cursor !== undefined);
38
+ return evaluators;
39
+ }
40
+ /** Creates the evaluator; its ID, or the problem. */
41
+ export async function createEvaluator(langfuse, evaluator) {
42
+ return call(langfuse, "POST", "/api/public/v2/evaluators", evaluator);
43
+ }
44
+ /** Replaces the evaluator's definition, which makes a new version. */
45
+ export async function updateEvaluator(langfuse, id, evaluator) {
46
+ return call(langfuse, "PATCH", `/api/public/v2/evaluators/${encodeURIComponent(id)}`, evaluator);
47
+ }
48
+ export async function createRule(langfuse, rule, evaluatorId) {
49
+ return call(langfuse, "POST", "/api/public/v2/evaluation-rules", {
50
+ ...rule,
51
+ evaluatorAssignments: [{ evaluatorId }],
52
+ });
53
+ }
54
+ //# sourceMappingURL=langfuse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langfuse.js","sourceRoot":"","sources":["../../src/adapters/langfuse.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,+CAA+C;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C,gFAAgF;AAChF,MAAM,UAAU,YAAY,CAAC,GAAsB;IACjD,MAAM,EAAE,mBAAmB,EAAE,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC;IAC/E,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,UAAU,CAAC,iDAAiD,CAAC,CAAC;IACtG,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,aAAa,IAAI,4BAA4B,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAC3F,CAAC;AAID,KAAK,UAAU,IAAI,CAAC,QAAkB,EAAE,MAAc,EAAE,IAAY,EAAE,IAAc;IAClF,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3F,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE;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