@johto-ai/cli 0.1.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.
- package/README.md +237 -0
- package/bin/johto.js +18 -0
- package/lib/resolve.js +55 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# @johto-ai/cli
|
|
2
|
+
|
|
3
|
+
> Competitive Pokémon TCG deck refinement at your terminal.
|
|
4
|
+
|
|
5
|
+
`johto` loads your 60-card deck as a TOML file, opens an AI agent session pre-populated with every card's stats, attacks, and regulation mark, and connects it to a local 19,818-card SQLite database via MCP. The agent reviews legality, flags consistency issues, and suggests specific swaps — informed by current Standard format rules baked into its system prompt.
|
|
6
|
+
|
|
7
|
+
No PostgreSQL. No Docker. No network calls for card data. Just a deck file and an API key.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @johto-ai/cli @johto-ai/card-data@latest
|
|
15
|
+
johto init
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`@johto-ai/card-data` is a [peer dependency](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#peerdependencies) and is released on its own cadence — install it explicitly so you can pull data refreshes (`@latest`) without bumping the CLI itself.
|
|
19
|
+
|
|
20
|
+
`johto init` runs an interactive wizard: writes `~/.config/johto/config.toml`, prompts for your Anthropic API key, and verifies the bundled binaries.
|
|
21
|
+
|
|
22
|
+
The meta package selects the matching platform binary at install time via `optionalDependencies`. Supported targets:
|
|
23
|
+
|
|
24
|
+
| OS | Arch |
|
|
25
|
+
|-------|--------------|
|
|
26
|
+
| Linux | x64, arm64 |
|
|
27
|
+
| macOS | x64, arm64 |
|
|
28
|
+
|
|
29
|
+
Windows is tracked for v1.1.
|
|
30
|
+
|
|
31
|
+
### Alternative install paths
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Docker (multi-arch)
|
|
35
|
+
docker run --rm -it \
|
|
36
|
+
-v "$PWD/decks:/decks" \
|
|
37
|
+
-e ANTHROPIC_API_KEY \
|
|
38
|
+
ghcr.io/mega-blastoise/johto:latest \
|
|
39
|
+
run --deck /decks/my-deck.toml
|
|
40
|
+
|
|
41
|
+
# Curl installer (writes to ~/.local/bin)
|
|
42
|
+
curl -fsSL https://johto.deckvault.gg/install.sh | sh
|
|
43
|
+
|
|
44
|
+
# Ephemeral
|
|
45
|
+
npx @johto-ai/cli run --deck ./my-deck.toml
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Quick start
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
johto init # one-time setup
|
|
54
|
+
johto run --deck ./decks/mega-gardevoir-ex.toml # REPL session
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The agent opens with a forced legality review, then waits for your questions:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
You: what's my turn 1 plan?
|
|
61
|
+
|
|
62
|
+
Agent: With Lillie's Determination as your engine, you're hunting Ralts
|
|
63
|
+
on T1. Best opener:
|
|
64
|
+
- Lead with Ralts (me1-58, 4 copies) — 70 HP, basic
|
|
65
|
+
- Attach Psychic Energy (sve-5)
|
|
66
|
+
- Play Lillie's Determination (me1-119, 4 copies) to redraw
|
|
67
|
+
- Hold Prime Catcher for a key gust on T2 once Kirlia is set up
|
|
68
|
+
...
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Commands
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
johto init # interactive first-run wizard
|
|
77
|
+
johto run --deck <file> # REPL session (Anthropic)
|
|
78
|
+
johto run --provider chrome # browser mode (Chrome Prompt API)
|
|
79
|
+
johto run --deck <file> --dry-run # print the system prompt and exit
|
|
80
|
+
johto run --deck <file> --stats # show probability table before REPL
|
|
81
|
+
johto doctor # diagnose install
|
|
82
|
+
johto auth set anthropic <key> # persist API key
|
|
83
|
+
johto auth show # list configured providers
|
|
84
|
+
johto sync-data # refresh the card database
|
|
85
|
+
johto --help # full subcommand reference
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### REPL mode (Anthropic)
|
|
89
|
+
|
|
90
|
+
Streams a Claude session with your full decklist injected into the system prompt and four MCP tools available for live card lookups. Requires `ANTHROPIC_API_KEY` in the environment or `johto auth set anthropic <key>`.
|
|
91
|
+
|
|
92
|
+
On the first message the agent will:
|
|
93
|
+
|
|
94
|
+
- Review the decklist for legality (regulation marks H, I, J only)
|
|
95
|
+
- Flag rotating cards (anything outside H/I/J)
|
|
96
|
+
- Identify consistency issues — wrong supporter ratios, missing search targets, energy math
|
|
97
|
+
|
|
98
|
+
Type `quit` or `exit` to end the session. Proposed deck edits are saved as versioned snapshots (`deck.v1.toml`, `deck.v2.toml`) — original files are never mutated.
|
|
99
|
+
|
|
100
|
+
### Browser mode (Chrome Prompt API)
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
johto run --provider chrome
|
|
104
|
+
johto run --deck ./decks/mega-gardevoir-ex.toml --provider chrome
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Serves a local three-panel page — card search, deck builder, on-device chat — powered by Gemini Nano. **No API key required.** Decks export as `.toml` files in the format below.
|
|
108
|
+
|
|
109
|
+
Requires Chrome Canary / Dev with `chrome://flags/#prompt-api-for-gemini-nano` enabled. When `window.ai` is unavailable, the page renders a setup guide rather than a blank state.
|
|
110
|
+
|
|
111
|
+
### Dry run
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
johto run --deck ./decks/mega-gardevoir-ex.toml --dry-run
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Prints the assembled system prompt and exits. No API calls, no key required. Useful for verifying prompt construction or diffing prompt changes across versions.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Deck file format
|
|
122
|
+
|
|
123
|
+
Plain TOML, 60 cards total, H/I/J regulation marks only. Human-writable, version-controllable, no tooling required.
|
|
124
|
+
|
|
125
|
+
```toml
|
|
126
|
+
name = "Mega Gardevoir ex — Psychic Control"
|
|
127
|
+
format = "standard"
|
|
128
|
+
regulation_marks = ["H", "I"]
|
|
129
|
+
|
|
130
|
+
# Pokémon — 14
|
|
131
|
+
[[cards]]
|
|
132
|
+
id = "me1-60" # Mega Gardevoir ex
|
|
133
|
+
quantity = 3
|
|
134
|
+
|
|
135
|
+
[[cards]]
|
|
136
|
+
id = "me1-58" # Ralts
|
|
137
|
+
quantity = 4
|
|
138
|
+
|
|
139
|
+
# Trainers — 31
|
|
140
|
+
[[cards]]
|
|
141
|
+
id = "me1-119" # Lillie's Determination
|
|
142
|
+
quantity = 4
|
|
143
|
+
|
|
144
|
+
# Energy — 15
|
|
145
|
+
[[cards]]
|
|
146
|
+
id = "sve-5" # Basic Psychic Energy
|
|
147
|
+
quantity = 15
|
|
148
|
+
|
|
149
|
+
[meta]
|
|
150
|
+
archetype = "mega-gardevoir-ex"
|
|
151
|
+
version = "1.0"
|
|
152
|
+
notes = "Prime Catcher ACE SPEC build"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Card IDs follow the Pokemon TCG API format: `{set-id}-{collector-number}` (e.g. `sv3-125`, `me1-60`). A complete 60-card example is bundled at `decks/example.toml`.
|
|
156
|
+
|
|
157
|
+
### Validation rules
|
|
158
|
+
|
|
159
|
+
| Rule | Check |
|
|
160
|
+
|----------|------------------------------------------------------------------|
|
|
161
|
+
| R1 | Total quantity = exactly 60 |
|
|
162
|
+
| R2 | No duplicate `id` values |
|
|
163
|
+
| R3 | Each `quantity` is 1–60 |
|
|
164
|
+
| R4 | Non-Basic Energy cards have quantity ≤ 4 |
|
|
165
|
+
| R5 | `format` = `"standard"` (case-sensitive) |
|
|
166
|
+
| R6 | `regulation_marks` non-empty; values in `["G","H","I","J"]` |
|
|
167
|
+
| R7 | No blank `id` values |
|
|
168
|
+
| LEGALITY | Cards with marks outside H/I/J flagged as rotating |
|
|
169
|
+
|
|
170
|
+
JSON is also accepted (`.json` extension) — useful for programmatic generation.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Agent tools
|
|
175
|
+
|
|
176
|
+
Available to the agent during REPL sessions via MCP. The agent invokes them automatically — no manual calls needed.
|
|
177
|
+
|
|
178
|
+
| Tool | Description |
|
|
179
|
+
|------------------|------------------------------------------------------------|
|
|
180
|
+
| `search_cards` | Search by name, type, supertype, rarity, set, HP range |
|
|
181
|
+
| `get_card_by_id` | Full card details — attacks, abilities, HP, regulation |
|
|
182
|
+
| `compare_cards` | Side-by-side stat comparison of two cards |
|
|
183
|
+
| `validate_deck` | Re-check legality after proposed changes |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Standard rotation
|
|
188
|
+
|
|
189
|
+
Legal regulation marks: **H, I, J**.
|
|
190
|
+
Mark **G** rotated out on **2026-04-10**.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Configuration
|
|
195
|
+
|
|
196
|
+
`johto init` writes `~/.config/johto/config.toml`:
|
|
197
|
+
|
|
198
|
+
```toml
|
|
199
|
+
[providers.anthropic]
|
|
200
|
+
api_key = "sk-ant-..."
|
|
201
|
+
|
|
202
|
+
[paths]
|
|
203
|
+
mcp_server = "/path/to/pokemon-mcp-server" # auto-resolved via npm
|
|
204
|
+
card_db = "/path/to/pokemon-data.sqlite3" # auto-resolved via npm
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Environment variable overrides:
|
|
208
|
+
|
|
209
|
+
| Variable | Purpose |
|
|
210
|
+
|-------------------------|-----------------------------------------------|
|
|
211
|
+
| `ANTHROPIC_API_KEY` | API key for REPL mode |
|
|
212
|
+
| `JOHTO_MCP_SERVER_PATH` | Override the bundled `pokemon-mcp-server` |
|
|
213
|
+
| `JOHTO_CARD_DB_PATH` | Override the bundled SQLite card database |
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Troubleshooting
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
johto doctor
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Checks every prerequisite — binary presence, database integrity, API key, network reachability — and prints actionable remediation for anything missing. Run it first if anything misbehaves.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Links
|
|
228
|
+
|
|
229
|
+
- **Documentation** — [johto.deckvault.gg](https://johto.deckvault.gg)
|
|
230
|
+
- **Source** — [github.com/mega-blastoise/deckvault](https://github.com/mega-blastoise/deckvault)
|
|
231
|
+
- **Issues** — [github.com/mega-blastoise/deckvault/issues](https://github.com/mega-blastoise/deckvault/issues)
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
MIT
|
package/bin/johto.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require('node:child_process');
|
|
3
|
+
const { resolveBinaries } = require('../lib/resolve');
|
|
4
|
+
|
|
5
|
+
const { cliBin, mcpBin, dbPath } = resolveBinaries();
|
|
6
|
+
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const env = {
|
|
9
|
+
...process.env,
|
|
10
|
+
JOHTO_MCP_SERVER_PATH: mcpBin,
|
|
11
|
+
JOHTO_DB_PATH: dbPath,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const child = spawn(cliBin, args, { stdio: 'inherit', env });
|
|
15
|
+
child.on('exit', (code, signal) => {
|
|
16
|
+
if (signal) process.kill(process.pid, signal);
|
|
17
|
+
else process.exit(code ?? 0);
|
|
18
|
+
});
|
package/lib/resolve.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const path = require('node:path');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
|
|
4
|
+
const PLATFORM_MAP = {
|
|
5
|
+
'linux:x64': 'linux-x64',
|
|
6
|
+
'linux:arm64': 'linux-arm64',
|
|
7
|
+
'darwin:x64': 'darwin-x64',
|
|
8
|
+
'darwin:arm64': 'darwin-arm64',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function platformSuffix() {
|
|
12
|
+
const key = `${process.platform}:${process.arch}`;
|
|
13
|
+
const suffix = PLATFORM_MAP[key];
|
|
14
|
+
if (!suffix) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Unsupported platform ${key}. Supported: linux-x64, linux-arm64, darwin-x64, darwin-arm64. ` +
|
|
17
|
+
`Windows is planned for v1.1.`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return suffix;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function resolvePackage(pkgName) {
|
|
24
|
+
try {
|
|
25
|
+
const pkgJson = require.resolve(`${pkgName}/package.json`);
|
|
26
|
+
return path.dirname(pkgJson);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Missing package ${pkgName}. This usually means npm skipped the platform-specific ` +
|
|
30
|
+
`optional dependency. Try \`npm install --force\` or report at https://github.com/mega-blastoise/deckvault/issues. ` +
|
|
31
|
+
`Original error: ${err.message}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function resolveBinaries() {
|
|
37
|
+
const suffix = platformSuffix();
|
|
38
|
+
const cliPkg = resolvePackage(`@johto-ai/cli-${suffix}`);
|
|
39
|
+
const mcpPkg = resolvePackage(`@johto-ai/mcp-server-${suffix}`);
|
|
40
|
+
const dataPkg = resolvePackage('@johto-ai/card-data');
|
|
41
|
+
|
|
42
|
+
const cliBin = path.join(cliPkg, 'bin', 'johto');
|
|
43
|
+
const mcpBin = path.join(mcpPkg, 'bin', 'pokemon-mcp-server');
|
|
44
|
+
const dbPath = path.join(dataPkg, 'data', 'pokemon-data.sqlite3.db');
|
|
45
|
+
|
|
46
|
+
for (const [p, label] of [[cliBin, 'CLI binary'], [mcpBin, 'MCP server'], [dbPath, 'card database']]) {
|
|
47
|
+
if (!fs.existsSync(p)) {
|
|
48
|
+
throw new Error(`${label} not found at ${p}. Try reinstalling: \`npm install -g @johto-ai/cli\`.`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return { cliBin, mcpBin, dbPath };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = { resolveBinaries, platformSuffix };
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@johto-ai/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Competitive Pokémon TCG deck refinement CLI with Anthropic agent loop and browser mode.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"johto": "./bin/johto.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"lib/",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@johto-ai/card-data": ">=0.1.0"
|
|
19
|
+
},
|
|
20
|
+
"optionalDependencies": {
|
|
21
|
+
"@johto-ai/cli-linux-x64": "0.1.0",
|
|
22
|
+
"@johto-ai/cli-linux-arm64": "0.1.0",
|
|
23
|
+
"@johto-ai/cli-darwin-x64": "0.1.0",
|
|
24
|
+
"@johto-ai/cli-darwin-arm64": "0.1.0",
|
|
25
|
+
"@johto-ai/mcp-server-linux-x64": "0.1.0",
|
|
26
|
+
"@johto-ai/mcp-server-linux-arm64": "0.1.0",
|
|
27
|
+
"@johto-ai/mcp-server-darwin-x64": "0.1.0",
|
|
28
|
+
"@johto-ai/mcp-server-darwin-arm64": "0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"repository": "https://github.com/mega-blastoise/deckvault",
|
|
31
|
+
"homepage": "https://johto.deckvault.gg"
|
|
32
|
+
}
|