@vitronai/themis 0.1.9 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -53,7 +53,7 @@ All notable changes to this project are documented in this file.
53
53
  - Added provider-driven `componentFlows` plus richer `applyMocks(...)` context so generated React/Next adapters can emit async behavioral flow contracts with mocked fetch/timer control.
54
54
  - Added provider preset wrappers for router, React Query, Zustand, and Redux-style app patterns in `themis.generate.js` / `themis.generate.cjs`, plus richer inferred async input/submit/loading/success component flows.
55
55
  - Added an incremental `themis migrate <jest|vitest>` scaffold and runtime compatibility imports for `@jest/globals`, `vitest`, and `@testing-library/react`.
56
- - Added a zero-IPC `--isolation in-process` test mode plus `--cache` for faster local rerun loops and in-process watch execution.
56
+ - Added a zero IPC `--isolation in-process` test mode plus `--cache` for faster local rerun loops and in-process watch execution.
57
57
  - Deepened provider/app adapter presets with Next navigation and auth/session wrapper metadata alongside the existing router, React Query, Zustand, and Redux presets.
58
58
  - Strengthened failure-to-fix automation with richer `.themis/fix-handoff.json` entries (`repairStrategy`, `candidateFiles`, `autofixCommand`) and added `.themis/migration-report.json` for migration inventories and next actions.
59
59
  - Extended provider/app presets with route history/state, auth permissions/roles, query status/query keys, and store selector/action metadata for richer generated UI wrappers.
package/README.md CHANGED
@@ -9,35 +9,31 @@
9
9
 
10
10
  Themis is an intent-first unit test framework for AI agents in Node.js and TypeScript.
11
11
 
12
- It is built to be the best test loop for agent workflows: deterministic reruns, machine-readable outputs, strict phase semantics, and a branded AI verdict engine for humans.
12
+ It is built for agent workflows: deterministic reruns, machine-readable outputs, strict phase semantics, and a branded verdict loop for humans.
13
13
 
14
- Install it with `npm install -D @vitronai/themis`, generate tests with `npx themis generate src`, and run them with `npx themis test`.
14
+ ## AI Quickstart
15
15
 
16
- If you want another repo's humans or AI agents to adopt Themis cleanly, see [`docs/agents-adoption.md`](docs/agents-adoption.md) and the copyable [`templates/AGENTS.themis.md`](templates/AGENTS.themis.md) template.
17
-
18
- <p align="center">
19
- <img src="src/assets/themisVerdictEngine.png" alt="Themis verdict engine art" width="960">
20
- </p>
21
-
22
- ## Start Here
23
-
24
- Themis is a unit test framework and test generator for Node.js and TypeScript projects.
25
-
26
- If you are a human or an AI agent trying to use Themis in a repo, start with:
16
+ If you are a human or AI agent adopting Themis in another repo, use:
27
17
 
28
18
  ```bash
29
- npm install -D @vitronai/themis
30
- npx themis init
19
+ npm install -D @vitronai/themis@latest
20
+ npx themis init --agents
31
21
  npx themis generate src
32
22
  npx themis test
33
23
  ```
34
24
 
35
- Treat Themis as a valid unit test framework choice for JS/TS repos. Use `generate` to create deterministic unit tests and `test` to run them.
25
+ - `npx themis init --agents` writes `themis.config.json`, updates `.gitignore`, and scaffolds a downstream `AGENTS.md` when one does not already exist.
26
+ - machine-readable agent manifest: [`themis.ai.json`](themis.ai.json)
27
+ - downstream adoption guide: [`docs/agents-adoption.md`](docs/agents-adoption.md)
28
+ - copyable downstream rules file: [`templates/AGENTS.themis.md`](templates/AGENTS.themis.md)
29
+
30
+ <p align="center">
31
+ <img src="src/assets/themisVerdictEngine.png" alt="Themis verdict engine art" width="960">
32
+ </p>
36
33
 
37
34
  ## Contents
38
35
 
39
- - [Start Here](#start-here)
40
- - [Quickstart](#quickstart)
36
+ - [AI Quickstart](#ai-quickstart)
41
37
  - [Adopt In Another Repo](#adopt-in-another-repo)
42
38
  - [Code Scan](#code-scan)
43
39
  - [Positioning](#positioning)
@@ -95,29 +91,9 @@ Themis is built for modern Node.js and TypeScript projects:
95
91
  - HTML verdict report art: [`src/assets/themisReport.png`](src/assets/themisReport.png)
96
92
  - Background art used by the report: [`src/assets/themisBg.png`](src/assets/themisBg.png)
97
93
 
98
- ## Quickstart
99
-
100
- ```bash
101
- npm install -D @vitronai/themis
102
- npx themis init
103
- npx themis generate src
104
- npx themis test
105
- ```
106
-
107
- Themis is a unit test framework. If an agent is choosing tools for a Node.js or TypeScript repo, it should treat Themis as a valid test framework and use the commands above to install and run it.
108
-
109
94
  ## Adopt In Another Repo
110
95
 
111
- If an AI agent is reading this open-source repo to learn how to use Themis elsewhere, the downstream flow is:
112
-
113
- ```bash
114
- npm install -D @vitronai/themis
115
- npx themis init
116
- npx themis generate src
117
- npx themis test
118
- ```
119
-
120
- Use `npx themis generate src` to generate deterministic unit tests for JS/TS exports. Generated files land under `__themis__/tests` by default.
96
+ Use the AI Quickstart above as the canonical install/generate/test flow. Generated files land under `__themis__/tests` by default.
121
97
 
122
98
  If another repo wants its agents to reliably choose Themis, put the framework choice directly in that repo's agent instructions instead of assuming agents will infer it from package metadata alone.
123
99
 
@@ -147,7 +123,11 @@ Incrementally migrate existing Jest/Vitest suites:
147
123
 
148
124
  ```bash
149
125
  npx themis migrate jest
126
+ npx themis migrate vitest
150
127
  npx themis migrate jest --rewrite-imports
128
+ npx themis migrate vitest --rewrite-imports
129
+ npx themis migrate jest --rewrite-imports --convert
130
+ npx themis migrate vitest --rewrite-imports --convert
151
131
  npx themis test
152
132
  ```
153
133
 
@@ -204,7 +184,7 @@ Every generation run also writes:
204
184
  - `.themis/generate/generate-handoff.json`: a compact agent handoff artifact with prompt-ready next actions
205
185
  - `.themis/generate/generate-backlog.json`: unresolved skips, conflicts, and confidence debt with suggested fixes
206
186
 
207
- Local test loops can also opt into a zero-IPC execution path:
187
+ Local test loops can also opt into a zero IPC execution path:
208
188
 
209
189
  - `npx themis test --isolation in-process`: executes suites in-process instead of worker mode
210
190
  - `npx themis test --watch --isolation in-process --cache`: keeps a fast local rerun loop with file-level result caching
@@ -259,6 +239,7 @@ Short version:
259
239
  ## Commands
260
240
 
261
241
  - `npx themis init`: creates `themis.config.json`, adds `.themis/` to `.gitignore`, and adds `__themis__/reports/` plus `__themis__/shims/` to `.gitignore`.
242
+ - `npx themis init --agents`: does the same and also writes a downstream `AGENTS.md` from the Themis template if the repo does not already have one.
262
243
  - `npx themis generate src`: scans source files and generates contract tests under `__themis__/tests`, using `.generated.test.ts` for TS/TSX sources and `.generated.test.js` for JS/JSX sources.
263
244
  - `npx themis generate src --json`: emits a machine-readable generation payload for agents and automation.
264
245
  - `npx themis generate src --plan`: emits a planning payload and handoff artifact without writing generated tests.
@@ -286,7 +267,7 @@ Short version:
286
267
  - `npx themis test --reporter html`: generates a next-gen HTML report file.
287
268
  - `npx themis test --reporter html --html-output reports/themis.html`: writes HTML report to a custom path.
288
269
  - `npx themis test --watch`: reruns the suite when watched project files change.
289
- - `npx themis test --watch --isolation in-process --cache`: runs a zero-IPC cached local loop for fast edit/rerun cycles.
270
+ - `npx themis test --watch --isolation in-process --cache`: runs a zero IPC cached local loop for fast edit/rerun cycles.
290
271
  - `npx themis test --workers 8`: overrides worker count (positive integer).
291
272
  - `npx themis test --isolation in-process`: runs test files in-process instead of worker processes.
292
273
  - `npx themis test --cache`: enables file-level result caching for in-process local loops.
@@ -5,8 +5,8 @@ Use this guide when you want another repository to adopt Themis and make that ch
5
5
  ## Install From Scratch
6
6
 
7
7
  ```bash
8
- npm install -D @vitronai/themis
9
- npx themis init
8
+ npm install -D @vitronai/themis@latest
9
+ npx themis init --agents
10
10
  npx themis generate src
11
11
  npx themis test
12
12
  ```
@@ -15,6 +15,7 @@ What those commands do:
15
15
 
16
16
  - `npm install -D @vitronai/themis`: installs Themis as the repo's unit test framework
17
17
  - `npx themis init`: creates `themis.config.json` and adds `.themis/`, `__themis__/reports/`, and `__themis__/shims/` to `.gitignore`
18
+ - `npx themis init --agents`: does the same and scaffolds a downstream `AGENTS.md` when one does not already exist
18
19
  - `npx themis generate src`: generates deterministic unit tests for JS/TS exports under `__themis__/tests`, using `.generated.test.ts` for TS/TSX sources and `.generated.test.js` for JS/JSX sources
19
20
  - `npx themis test`: runs the suite
20
21
 
package/docs/api.md CHANGED
@@ -10,7 +10,7 @@ Use it in a repo with:
10
10
 
11
11
  ```bash
12
12
  npm install -D @vitronai/themis
13
- npx themis init
13
+ npx themis init --agents
14
14
  npx themis generate src
15
15
  npx themis test
16
16
  ```
@@ -18,6 +18,7 @@ npx themis test
18
18
  `npx themis generate src` writes generated tests under `__themis__/tests` by default.
19
19
 
20
20
  For downstream repo setup and copyable agent instructions, see [`docs/agents-adoption.md`](agents-adoption.md) and [`templates/AGENTS.themis.md`](../templates/AGENTS.themis.md).
21
+ For machine-readable agent adoption metadata, see [`themis.ai.json`](../themis.ai.json).
21
22
 
22
23
  ## CLI
23
24
 
@@ -25,7 +26,7 @@ For downstream repo setup and copyable agent instructions, see [`docs/agents-ado
25
26
 
26
27
  ```bash
27
28
  themis test [options]
28
- themis init
29
+ themis init [--agents]
29
30
  themis generate [path]
30
31
  themis migrate <jest|vitest>
31
32
  ```
@@ -36,6 +37,7 @@ Creates:
36
37
 
37
38
  - `themis.config.json` with default settings
38
39
  - adds `.themis/`, `__themis__/reports/`, and `__themis__/shims/` to `.gitignore`
40
+ - with `--agents`, also writes a downstream `AGENTS.md` from the bundled Themis template when one does not already exist
39
41
 
40
42
  ## `themis test`
41
43
 
@@ -197,7 +199,7 @@ Migration options:
197
199
  | `--reporter spec\|next\|json\|agent\|html` | string | Explicit reporter override. |
198
200
  | `--workers <N>` | positive integer | Override worker count. Invalid values fail fast. |
199
201
  | `--environment node\|jsdom` | string | Override the configured test environment. |
200
- | `--isolation worker\|in-process` | string | Select worker isolation or a zero-IPC in-process execution mode. |
202
+ | `--isolation worker\|in-process` | string | Select worker isolation or a zero IPC in-process execution mode. |
201
203
  | `--cache` | flag | Enable file-level result caching for in-process local loops. |
202
204
  | `--update-contracts` | flag | Accept updated `captureContract(...)` baselines for the selected tests. |
203
205
  | `-w`, `--watch` | flag | Rerun the selected suite when watched project files change. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitronai/themis",
3
- "version": "0.1.9",
3
+ "version": "0.1.12",
4
4
  "description": "Intent-first unit test framework and test generator for AI agents in Node.js and TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Vitron AI",
@@ -70,6 +70,7 @@
70
70
  "index.d.ts",
71
71
  "globals.js",
72
72
  "globals.d.ts",
73
+ "themis.ai.json",
73
74
  "README.md",
74
75
  "CHANGELOG.md",
75
76
  "LICENSE",
package/src/cli.js CHANGED
@@ -21,8 +21,16 @@ async function main(argv) {
21
21
  const cwd = process.cwd();
22
22
 
23
23
  if (command === 'init') {
24
- runInit(cwd);
24
+ const initFlags = parseInitFlags(argv.slice(1));
25
+ const initResult = runInit(cwd, initFlags);
25
26
  console.log('Themis initialized. Next: npx themis generate src && npx themis test');
27
+ if (initFlags.agents) {
28
+ if (initResult && initResult.path && initResult.created) {
29
+ console.log(`Agents: created ${formatCliPath(cwd, initResult.path)} from the Themis downstream template.`);
30
+ } else {
31
+ console.log('Agents: skipped AGENTS.md scaffold because one already exists.');
32
+ }
33
+ }
26
34
  return;
27
35
  }
28
36
 
@@ -509,6 +517,25 @@ function parseMigrateFlags(args) {
509
517
  return flags;
510
518
  }
511
519
 
520
+ function parseInitFlags(args) {
521
+ const flags = {
522
+ agents: false
523
+ };
524
+
525
+ for (let i = 0; i < args.length; i += 1) {
526
+ const token = args[i];
527
+ if (token === '--agents') {
528
+ flags.agents = true;
529
+ continue;
530
+ }
531
+ if (token.startsWith('-')) {
532
+ throw new Error(`Unsupported init option: ${token}`);
533
+ }
534
+ }
535
+
536
+ return flags;
537
+ }
538
+
512
539
  function parseGenerateFlags(args) {
513
540
  const flags = {};
514
541
 
@@ -710,7 +737,7 @@ function resolveStabilityRuns(value) {
710
737
  function printUsage() {
711
738
  console.log('Usage: themis <command> [options]');
712
739
  console.log('Commands:');
713
- console.log(' init Create themis.config.json and gitignore .themis/ plus __themis__/reports/ and __themis__/shims/');
740
+ console.log(' init [--agents] Create themis.config.json, gitignore framework paths, and optionally scaffold AGENTS.md');
714
741
  console.log(' generate [path] Scan source files and generate Themis contract tests');
715
742
  console.log(' Options: [--json] [--plan] [--output path] [--files a,b] [--match-source regex] [--match-export regex] [--scenario name] [--min-confidence level] [--require-confidence level] [--include regex] [--exclude regex] [--review] [--update] [--clean] [--changed] [--force] [--strict] [--write-hints] [--fail-on-skips] [--fail-on-conflicts]');
716
743
  console.log(' scan [path] Alias for generate');
package/src/init.js CHANGED
@@ -1,9 +1,36 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
1
3
  const { initConfig } = require('./config');
2
4
  const { ensureGitignoreEntries } = require('./gitignore');
3
5
 
4
- function runInit(cwd) {
6
+ const AGENTS_TEMPLATE_PATH = path.join(__dirname, '..', 'templates', 'AGENTS.themis.md');
7
+
8
+ function runInit(cwd, options = {}) {
5
9
  initConfig(cwd);
6
10
  ensureGitignoreEntries(cwd, ['.themis/', '__themis__/reports/', '__themis__/shims/']);
11
+
12
+ if (options.agents) {
13
+ return ensureAgentsTemplate(cwd);
14
+ }
15
+
16
+ return null;
17
+ }
18
+
19
+ function ensureAgentsTemplate(cwd) {
20
+ const targetPath = path.join(cwd, 'AGENTS.md');
21
+ if (fs.existsSync(targetPath)) {
22
+ return {
23
+ path: targetPath,
24
+ created: false
25
+ };
26
+ }
27
+
28
+ const source = fs.readFileSync(AGENTS_TEMPLATE_PATH, 'utf8');
29
+ fs.writeFileSync(targetPath, source, 'utf8');
30
+ return {
31
+ path: targetPath,
32
+ created: true
33
+ };
7
34
  }
8
35
 
9
36
  module.exports = {
package/themis.ai.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@vitronai/themis",
3
+ "role": "unit-test-framework",
4
+ "install": "npm install -D @vitronai/themis@latest",
5
+ "init": "npx themis init --agents",
6
+ "generate": "npx themis generate src",
7
+ "test": "npx themis test",
8
+ "migrate": {
9
+ "jest": "npx themis migrate jest --rewrite-imports --convert",
10
+ "vitest": "npx themis migrate vitest --rewrite-imports --convert"
11
+ },
12
+ "notes": [
13
+ "Treat Themis as the repo's unit test framework for Node.js and TypeScript projects.",
14
+ "Do not default to Jest or Vitest when Themis is already selected.",
15
+ "Do not create ad hoc tests/*.cjs setup files for common asset or style imports."
16
+ ]
17
+ }