@vitronai/themis 0.1.0-beta.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.
@@ -0,0 +1,277 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/vitron-ai/themis/docs/schemas/agent-result.v1.json",
4
+ "title": "Themis Agent Result v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schema", "meta", "summary", "failures", "artifacts", "analysis", "hints"],
8
+ "properties": {
9
+ "schema": {
10
+ "type": "string",
11
+ "const": "themis.agent.result.v1"
12
+ },
13
+ "meta": {
14
+ "$ref": "#/$defs/meta"
15
+ },
16
+ "summary": {
17
+ "$ref": "#/$defs/summary"
18
+ },
19
+ "failures": {
20
+ "type": "array",
21
+ "items": {
22
+ "$ref": "#/$defs/failure"
23
+ }
24
+ },
25
+ "artifacts": {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "required": ["lastRun", "failedTests", "runDiff", "runHistory"],
29
+ "properties": {
30
+ "lastRun": {
31
+ "type": "string"
32
+ },
33
+ "failedTests": {
34
+ "type": "string"
35
+ },
36
+ "runDiff": {
37
+ "type": "string"
38
+ },
39
+ "runHistory": {
40
+ "type": "string"
41
+ }
42
+ }
43
+ },
44
+ "analysis": {
45
+ "$ref": "#/$defs/analysis"
46
+ },
47
+ "hints": {
48
+ "type": "object",
49
+ "additionalProperties": false,
50
+ "required": ["rerunFailed", "targetedRerun", "updateSnapshots", "diffLastRun"],
51
+ "properties": {
52
+ "rerunFailed": {
53
+ "type": "string"
54
+ },
55
+ "targetedRerun": {
56
+ "type": "string"
57
+ },
58
+ "updateSnapshots": {
59
+ "type": "string"
60
+ },
61
+ "diffLastRun": {
62
+ "type": "string"
63
+ }
64
+ }
65
+ }
66
+ },
67
+ "$defs": {
68
+ "meta": {
69
+ "type": "object",
70
+ "additionalProperties": false,
71
+ "required": ["startedAt", "finishedAt", "maxWorkers"],
72
+ "properties": {
73
+ "startedAt": {
74
+ "type": "string"
75
+ },
76
+ "finishedAt": {
77
+ "type": "string"
78
+ },
79
+ "maxWorkers": {
80
+ "type": "number"
81
+ }
82
+ }
83
+ },
84
+ "summary": {
85
+ "type": "object",
86
+ "additionalProperties": false,
87
+ "required": ["total", "passed", "failed", "skipped", "durationMs"],
88
+ "properties": {
89
+ "total": {
90
+ "type": "number"
91
+ },
92
+ "passed": {
93
+ "type": "number"
94
+ },
95
+ "failed": {
96
+ "type": "number"
97
+ },
98
+ "skipped": {
99
+ "type": "number"
100
+ },
101
+ "durationMs": {
102
+ "type": "number"
103
+ }
104
+ }
105
+ },
106
+ "failure": {
107
+ "type": "object",
108
+ "additionalProperties": false,
109
+ "required": ["file", "testName", "fullName", "durationMs", "message", "stack", "fingerprint"],
110
+ "properties": {
111
+ "file": {
112
+ "type": "string"
113
+ },
114
+ "testName": {
115
+ "type": "string"
116
+ },
117
+ "fullName": {
118
+ "type": "string"
119
+ },
120
+ "durationMs": {
121
+ "type": "number"
122
+ },
123
+ "message": {
124
+ "type": "string"
125
+ },
126
+ "stack": {
127
+ "type": "string"
128
+ },
129
+ "fingerprint": {
130
+ "type": "string"
131
+ }
132
+ }
133
+ },
134
+ "analysis": {
135
+ "type": "object",
136
+ "additionalProperties": false,
137
+ "required": ["fingerprintVersion", "failureClusters", "stability", "comparison"],
138
+ "properties": {
139
+ "fingerprintVersion": {
140
+ "type": "string",
141
+ "const": "fnv1a32-message-v1"
142
+ },
143
+ "failureClusters": {
144
+ "type": "array",
145
+ "items": {
146
+ "$ref": "#/$defs/failureCluster"
147
+ }
148
+ },
149
+ "stability": {
150
+ "$ref": "#/$defs/stability"
151
+ },
152
+ "comparison": {
153
+ "$ref": "#/$defs/comparison"
154
+ }
155
+ }
156
+ },
157
+ "failureCluster": {
158
+ "type": "object",
159
+ "additionalProperties": false,
160
+ "required": ["fingerprint", "count", "message", "tests"],
161
+ "properties": {
162
+ "fingerprint": {
163
+ "type": "string"
164
+ },
165
+ "count": {
166
+ "type": "number"
167
+ },
168
+ "message": {
169
+ "type": "string"
170
+ },
171
+ "tests": {
172
+ "type": "array",
173
+ "items": {
174
+ "type": "string"
175
+ }
176
+ }
177
+ }
178
+ },
179
+ "stability": {
180
+ "type": "object",
181
+ "additionalProperties": false,
182
+ "required": ["runs", "summary", "tests"],
183
+ "properties": {
184
+ "runs": {
185
+ "type": "number"
186
+ },
187
+ "summary": {
188
+ "$ref": "#/$defs/stabilitySummary"
189
+ },
190
+ "tests": {
191
+ "type": "array",
192
+ "items": {
193
+ "$ref": "#/$defs/stabilityTest"
194
+ }
195
+ }
196
+ }
197
+ },
198
+ "stabilitySummary": {
199
+ "type": "object",
200
+ "additionalProperties": false,
201
+ "required": ["stablePass", "stableFail", "unstable"],
202
+ "properties": {
203
+ "stablePass": {
204
+ "type": "number"
205
+ },
206
+ "stableFail": {
207
+ "type": "number"
208
+ },
209
+ "unstable": {
210
+ "type": "number"
211
+ }
212
+ }
213
+ },
214
+ "stabilityTest": {
215
+ "type": "object",
216
+ "additionalProperties": false,
217
+ "required": ["file", "testName", "fullName", "statuses", "classification"],
218
+ "properties": {
219
+ "file": {
220
+ "type": "string"
221
+ },
222
+ "testName": {
223
+ "type": "string"
224
+ },
225
+ "fullName": {
226
+ "type": "string"
227
+ },
228
+ "statuses": {
229
+ "type": "array",
230
+ "items": {
231
+ "type": "string",
232
+ "enum": ["passed", "failed", "missing"]
233
+ }
234
+ },
235
+ "classification": {
236
+ "type": "string",
237
+ "enum": ["stable_pass", "stable_fail", "unstable"]
238
+ }
239
+ }
240
+ },
241
+ "comparison": {
242
+ "type": "object",
243
+ "additionalProperties": false,
244
+ "required": ["status", "previousRunId", "previousRunAt", "currentRunAt", "delta", "newFailures", "resolvedFailures"],
245
+ "properties": {
246
+ "status": {
247
+ "type": "string",
248
+ "enum": ["baseline", "changed"]
249
+ },
250
+ "previousRunId": {
251
+ "type": "string"
252
+ },
253
+ "previousRunAt": {
254
+ "type": "string"
255
+ },
256
+ "currentRunAt": {
257
+ "type": "string"
258
+ },
259
+ "delta": {
260
+ "$ref": "#/$defs/summary"
261
+ },
262
+ "newFailures": {
263
+ "type": "array",
264
+ "items": {
265
+ "type": "string"
266
+ }
267
+ },
268
+ "resolvedFailures": {
269
+ "type": "array",
270
+ "items": {
271
+ "type": "string"
272
+ }
273
+ }
274
+ }
275
+ }
276
+ }
277
+ }
@@ -0,0 +1,78 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/vitron-ai/themis/docs/schemas/failures.v1.json",
4
+ "title": "Themis Failures Artifact v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schema", "runId", "createdAt", "summary", "failedTests"],
8
+ "properties": {
9
+ "schema": {
10
+ "type": "string",
11
+ "const": "themis.failures.v1"
12
+ },
13
+ "runId": {
14
+ "type": "string"
15
+ },
16
+ "createdAt": {
17
+ "type": "string"
18
+ },
19
+ "summary": {
20
+ "$ref": "#/$defs/summary"
21
+ },
22
+ "failedTests": {
23
+ "type": "array",
24
+ "items": {
25
+ "$ref": "#/$defs/failedTest"
26
+ }
27
+ }
28
+ },
29
+ "$defs": {
30
+ "summary": {
31
+ "type": "object",
32
+ "additionalProperties": false,
33
+ "required": ["total", "passed", "failed", "skipped", "durationMs"],
34
+ "properties": {
35
+ "total": {
36
+ "type": "number"
37
+ },
38
+ "passed": {
39
+ "type": "number"
40
+ },
41
+ "failed": {
42
+ "type": "number"
43
+ },
44
+ "skipped": {
45
+ "type": "number"
46
+ },
47
+ "durationMs": {
48
+ "type": "number"
49
+ }
50
+ }
51
+ },
52
+ "failedTest": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "required": ["file", "name", "fullName", "durationMs", "message", "stack"],
56
+ "properties": {
57
+ "file": {
58
+ "type": "string"
59
+ },
60
+ "name": {
61
+ "type": "string"
62
+ },
63
+ "fullName": {
64
+ "type": "string"
65
+ },
66
+ "durationMs": {
67
+ "type": "number"
68
+ },
69
+ "message": {
70
+ "type": "string"
71
+ },
72
+ "stack": {
73
+ "type": "string"
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,40 @@
1
+ # VS Code Extension
2
+
3
+ Themis includes an in-repo VS Code extension scaffold at [`packages/themis-vscode`](../packages/themis-vscode).
4
+
5
+ This is the intended shape of the editor UX:
6
+
7
+ - a Themis activity-bar container
8
+ - a results sidebar driven by `.themis/*` artifacts
9
+ - commands to run tests, rerun failures, refresh results, and open the HTML report
10
+ - failure navigation that jumps from artifact data into the source file
11
+
12
+ ## Current MVP Scope
13
+
14
+ The scaffold currently supports:
15
+
16
+ - reading `.themis/last-run.json`
17
+ - reading `.themis/failed-tests.json`
18
+ - reading `.themis/run-diff.json`
19
+ - opening `.themis/report.html` in a webview
20
+ - refreshing when `.themis/*` files change
21
+
22
+ The extension is intentionally thin. It shells out to Themis commands and treats the CLI plus artifacts as the canonical contract.
23
+
24
+ ## Local Development
25
+
26
+ Open the repository in VS Code and use an Extension Development Host pointed at:
27
+
28
+ `packages/themis-vscode`
29
+
30
+ The extension does not need marketplace publishing to be exercised locally.
31
+
32
+ ## Publishing Later
33
+
34
+ When you decide to publish:
35
+
36
+ 1. create a VS Code publisher
37
+ 2. package the extension under `packages/themis-vscode`
38
+ 3. publish it separately from the npm package
39
+
40
+ The npm package and the VS Code extension should version together, but they do not need to ship from the same registry.
@@ -0,0 +1,111 @@
1
+ # Why Themis
2
+
3
+ Themis is built for AI-era testing loops where humans and agents both need reliable signals, fast reruns, and machine-readable context.
4
+
5
+ The core positioning is simple:
6
+
7
+ - The best unit test framework for AI agents in Node.js and TypeScript
8
+ - An AI verdict engine for human and agent review loops
9
+
10
+ ## What "Next-Gen" Means Here
11
+
12
+ Next-gen is not styling. It means test infrastructure designed for:
13
+
14
+ - deterministic execution
15
+ - agent-native output contracts
16
+ - explicit intent modeling
17
+ - performance accountability
18
+
19
+ ## Why It Can Be Best-in-Class
20
+
21
+ ## 1) Intent-First Test Design
22
+
23
+ The `intent(...)` DSL makes behavior explicit through ordered phases:
24
+
25
+ - `context`
26
+ - `run`
27
+ - `verify`
28
+ - `cleanup`
29
+
30
+ This gives agents and humans a clearer semantic map than flat assertion blocks.
31
+ Legacy aliases (`arrange/act/assert`, `given/when/then`) remain available for compatibility.
32
+
33
+ ## 2) Agent-Native Outputs
34
+
35
+ Themis supports structured outputs for tooling loops:
36
+
37
+ - `--json` for generic automation
38
+ - `--agent` for AI-agent workflows
39
+ - `.themis/failed-tests.json` for deterministic reruns
40
+
41
+ ## 3) Deterministic Rerun Workflow
42
+
43
+ `--rerun-failed`, `--watch`, and test-name filtering (`--match`) reduce iteration time and keep failure focus tight.
44
+
45
+ ## 4) Modern JS/TS Project Parity
46
+
47
+ Themis is built for current Node.js and TypeScript repos:
48
+
49
+ - `.js`, `.jsx`, `.ts`, `.tsx`
50
+ - ESM `.js` in `type: "module"` projects
51
+ - `tsconfig` path aliases
52
+ - `node` and `jsdom` environments
53
+ - `setupFiles` for project harness bootstrapping
54
+
55
+ ## 5) Strong Runtime Guarantees
56
+
57
+ The runtime enforces intent ordering rules and clear phase-level failure annotation, reducing ambiguous failures.
58
+
59
+ ## 6) TypeScript-Ready Without Runtime Tax
60
+
61
+ Themis keeps a lean JS runtime and ships first-party typings:
62
+
63
+ - package API types (`index.d.ts`)
64
+ - global test API types (`globals.d.ts`)
65
+ - typecheck lane (`npm run typecheck`)
66
+
67
+ ## 7) First-Party Agent Loop Utilities
68
+
69
+ Themis ships workflow features agents can use directly:
70
+
71
+ - snapshots with `toMatchSnapshot()`
72
+ - mocks and spies with `fn`, `spyOn`, and `mock`
73
+ - `.themis/run-diff.json` and `.themis/run-history.json`
74
+ - HTML verdict reports for human review
75
+
76
+ ## 8) Performance Discipline, Not Guesswork
77
+
78
+ Performance is measured and guarded:
79
+
80
+ - synthetic benchmark runner (`npm run benchmark`)
81
+ - regression gate (`npm run benchmark:gate`)
82
+ - threshold config (`benchmark-gate.json`)
83
+
84
+ ## 9) CLI Designed for Humans and Machines
85
+
86
+ - high-signal human reporter (`--next`)
87
+ - strict machine reporter outputs (`--json`, `--agent`)
88
+ - branded banner for human mode only
89
+
90
+ ## 10) Editor Surface Without Replacing The CLI
91
+
92
+ Themis includes a thin VS Code extension scaffold that reads `.themis/*` artifacts, reruns tests, and opens the HTML report. The CLI remains the source of truth.
93
+
94
+ ## Proof Checklist
95
+
96
+ Run these to validate core claims:
97
+
98
+ ```bash
99
+ npm test
100
+ npm run typecheck
101
+ npm run benchmark:gate
102
+ ```
103
+
104
+ ## Messaging for the Community
105
+
106
+ If you describe Themis publicly, use this framing:
107
+
108
+ - "The best unit test framework for AI agents in Node.js and TypeScript"
109
+ - "An AI verdict engine for human and agent review loops"
110
+ - "Intent-first testing with deterministic reruns and machine-readable artifacts"
111
+ - "JS-fast runtime with first-party TypeScript DX and benchmark-gated discipline"
package/globals.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { Describe, Expect, Fn, Hook, Intent, MockControl, MockModule, SpyOn, Test } from './index';
2
+
3
+ declare global {
4
+ var describe: Describe;
5
+ var test: Test;
6
+ var it: Test;
7
+ var intent: Intent;
8
+ var beforeAll: Hook;
9
+ var beforeEach: Hook;
10
+ var afterEach: Hook;
11
+ var afterAll: Hook;
12
+ var expect: Expect;
13
+ var fn: Fn;
14
+ var spyOn: SpyOn;
15
+ var mock: MockModule;
16
+ var unmock: MockModule;
17
+ var clearAllMocks: MockControl;
18
+ var resetAllMocks: MockControl;
19
+ var restoreAllMocks: MockControl;
20
+ }
21
+
22
+ export {};
package/globals.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = {};