@sunilp-org/jam-cli 0.1.0 → 0.1.2
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 +431 -63
- package/dist/commands/ask.d.ts +4 -0
- package/dist/commands/ask.d.ts.map +1 -1
- package/dist/commands/ask.js +202 -10
- package/dist/commands/ask.js.map +1 -1
- package/dist/commands/commit.d.ts +12 -0
- package/dist/commands/commit.d.ts.map +1 -0
- package/dist/commands/commit.js +135 -0
- package/dist/commands/commit.js.map +1 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +2 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/context.d.ts +12 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +52 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/review.d.ts +25 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +117 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +1 -0
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +199 -197
- package/dist/commands/run.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +39 -3
- package/dist/config/loader.js.map +1 -1
- package/dist/index.js +63 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/base.d.ts +26 -0
- package/dist/providers/base.d.ts.map +1 -1
- package/dist/providers/embedded.d.ts +20 -0
- package/dist/providers/embedded.d.ts.map +1 -0
- package/dist/providers/embedded.js +302 -0
- package/dist/providers/embedded.js.map +1 -0
- package/dist/providers/factory.d.ts.map +1 -1
- package/dist/providers/factory.js +25 -1
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/groq.d.ts +16 -0
- package/dist/providers/groq.d.ts.map +1 -0
- package/dist/providers/groq.js +23 -0
- package/dist/providers/groq.js.map +1 -0
- package/dist/providers/ollama.d.ts +6 -1
- package/dist/providers/ollama.d.ts.map +1 -1
- package/dist/providers/ollama.js +77 -4
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.d.ts +18 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +229 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/tools/all-tools.d.ts +18 -0
- package/dist/tools/all-tools.d.ts.map +1 -0
- package/dist/tools/all-tools.js +95 -0
- package/dist/tools/all-tools.js.map +1 -0
- package/dist/tools/apply_patch.js +1 -1
- package/dist/tools/apply_patch.js.map +1 -1
- package/dist/tools/context-tools.d.ts +14 -0
- package/dist/tools/context-tools.d.ts.map +1 -0
- package/dist/tools/context-tools.js +63 -0
- package/dist/tools/context-tools.js.map +1 -0
- package/dist/tools/git_diff.js +1 -1
- package/dist/tools/git_diff.js.map +1 -1
- package/dist/tools/git_status.js +1 -1
- package/dist/tools/git_status.js.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +2 -0
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/run_command.d.ts +8 -3
- package/dist/tools/run_command.d.ts.map +1 -1
- package/dist/tools/run_command.js +90 -3
- package/dist/tools/run_command.js.map +1 -1
- package/dist/ui/chat.d.ts.map +1 -1
- package/dist/ui/chat.js +173 -1
- package/dist/ui/chat.js.map +1 -1
- package/dist/ui/logo.d.ts.map +1 -1
- package/dist/ui/logo.js +5 -1
- package/dist/ui/logo.js.map +1 -1
- package/dist/utils/agent.d.ts +130 -0
- package/dist/utils/agent.d.ts.map +1 -0
- package/dist/utils/agent.js +449 -0
- package/dist/utils/agent.js.map +1 -0
- package/dist/utils/cache.d.ts +30 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +62 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/context.d.ts +38 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +383 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/critic.d.ts +31 -0
- package/dist/utils/critic.d.ts.map +1 -0
- package/dist/utils/critic.js +126 -0
- package/dist/utils/critic.js.map +1 -0
- package/dist/utils/index-builder.d.ts +53 -0
- package/dist/utils/index-builder.d.ts.map +1 -0
- package/dist/utils/index-builder.js +241 -0
- package/dist/utils/index-builder.js.map +1 -0
- package/dist/utils/memory.d.ts +104 -0
- package/dist/utils/memory.d.ts.map +1 -0
- package/dist/utils/memory.js +215 -0
- package/dist/utils/memory.js.map +1 -0
- package/dist/utils/past-sessions.d.ts +31 -0
- package/dist/utils/past-sessions.d.ts.map +1 -0
- package/dist/utils/past-sessions.js +126 -0
- package/dist/utils/past-sessions.js.map +1 -0
- package/dist/utils/tokens.d.ts +53 -0
- package/dist/utils/tokens.d.ts.map +1 -0
- package/dist/utils/tokens.js +138 -0
- package/dist/utils/tokens.js.map +1 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
Ask questions • Explain code • Review diffs • Generate patches • Run agentic tasks
|
|
29
29
|
|
|
30
|
-
*All from your command line, powered by any
|
|
30
|
+
*All from your command line, powered by Ollama, OpenAI, Groq, or any compatible provider.*
|
|
31
31
|
|
|
32
32
|
[Getting Started](#quick-start) · [Commands](#commands) · [Configuration](#configuration) · [Contributing](#contributing) · [Security](#security-policy)
|
|
33
33
|
|
|
@@ -58,7 +58,8 @@ Most AI coding tools are built around a single vendor's model, require a browser
|
|
|
58
58
|
| 📂 | **Repo-aware** | Explain files, search code, review diffs with full workspace context |
|
|
59
59
|
| 🩹 | **Patch workflow** | Generate unified diffs, validate, preview, and apply with confirmation |
|
|
60
60
|
| 🤖 | **Tool-calling agent** | `jam run` gives the model access to local tools (read, search, diff, apply) |
|
|
61
|
-
| 🔌 | **Pluggable providers** | Ollama
|
|
61
|
+
| 🔌 | **Pluggable providers** | Ollama, OpenAI, Groq, **Embedded** built-in; adapter pattern for adding any LLM |
|
|
62
|
+
| 📦 | **Embedded inference** | **[Experimental]** Run without Ollama — tiny GGUF model runs directly in-process via `node-llama-cpp` |
|
|
62
63
|
| ⚙️ | **Layered config** | Global → repo → CLI flags; multiple named profiles |
|
|
63
64
|
| 🔐 | **Secure secrets** | OS keychain via keytar, env var fallback |
|
|
64
65
|
| 🐚 | **Shell completions** | Bash and Zsh |
|
|
@@ -100,14 +101,23 @@ Most AI coding tools are built around a single vendor's model, require a browser
|
|
|
100
101
|
### Prerequisites
|
|
101
102
|
|
|
102
103
|
- **Node.js 20+**
|
|
103
|
-
- **
|
|
104
|
-
-
|
|
104
|
+
- **One of the following model backends:**
|
|
105
|
+
- **[Ollama](https://ollama.ai)** running locally (`ollama serve`) + a pulled model (`ollama pull llama3.2`)
|
|
106
|
+
- **Embedded mode** — no server needed! Uses `node-llama-cpp` to run a tiny GGUF model in-process.
|
|
107
|
+
Install with: `npm install node-llama-cpp` (auto-downloads a ~250 MB model on first run)
|
|
105
108
|
|
|
106
109
|
### Install
|
|
107
110
|
|
|
108
111
|
```bash
|
|
109
|
-
#
|
|
110
|
-
|
|
112
|
+
# Try instantly — no install required
|
|
113
|
+
npx @sunilp-org/jam-cli doctor
|
|
114
|
+
|
|
115
|
+
# Global install from npm
|
|
116
|
+
npm install -g @sunilp-org/jam-cli
|
|
117
|
+
|
|
118
|
+
# Homebrew (macOS / Linux)
|
|
119
|
+
brew tap sunilp/tap
|
|
120
|
+
brew install jam-cli
|
|
111
121
|
|
|
112
122
|
# Or run from source
|
|
113
123
|
git clone https://github.com/sunilp/jam-cli.git
|
|
@@ -162,7 +172,9 @@ jam ask "Hello" --profile work
|
|
|
162
172
|
| `--provider <name>` | Override provider |
|
|
163
173
|
| `--base-url <url>` | Override provider base URL |
|
|
164
174
|
| `--profile <name>` | Use a named config profile |
|
|
165
|
-
| `--no-
|
|
175
|
+
| `--no-tools` | Disable read-only tool use (file discovery) |
|
|
176
|
+
| `--no-color` | Strip ANSI colors from output (global flag) |
|
|
177
|
+
| `-q, --quiet` | Suppress all non-essential output (spinners, status lines, decorations) |
|
|
166
178
|
|
|
167
179
|
---
|
|
168
180
|
|
|
@@ -236,6 +248,50 @@ jam diff --staged --json # JSON output
|
|
|
236
248
|
|
|
237
249
|
---
|
|
238
250
|
|
|
251
|
+
### `jam review`
|
|
252
|
+
|
|
253
|
+
Review a branch or pull request with AI.
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
jam review # review current branch against main
|
|
257
|
+
jam review --base develop # diff against a different base branch
|
|
258
|
+
jam review --pr 42 # review a specific PR (requires GitHub CLI)
|
|
259
|
+
jam review --json # JSON output
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Options:**
|
|
263
|
+
|
|
264
|
+
| Flag | Description |
|
|
265
|
+
|------|-------------|
|
|
266
|
+
| `--base <ref>` | Base branch or ref to diff against (default: `main`) |
|
|
267
|
+
| `--pr <number>` | Review a specific PR number (requires `gh` CLI) |
|
|
268
|
+
| `--json` | Machine-readable JSON output |
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
### `jam commit`
|
|
273
|
+
|
|
274
|
+
Generate an AI-written commit message from staged changes and commit.
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
jam commit # generate message, confirm, then commit
|
|
278
|
+
jam commit --dry # generate message only, do not commit
|
|
279
|
+
jam commit --yes # skip confirmation prompt
|
|
280
|
+
jam commit --amend # amend the last commit with a new AI message
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Options:**
|
|
284
|
+
|
|
285
|
+
| Flag | Description |
|
|
286
|
+
|------|-------------|
|
|
287
|
+
| `--dry` | Generate the message but do not commit |
|
|
288
|
+
| `--yes` | Auto-confirm without prompting |
|
|
289
|
+
| `--amend` | Amend the last commit with a new AI-generated message |
|
|
290
|
+
|
|
291
|
+
Messages follow the [Conventional Commits](https://conventionalcommits.org) specification.
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
239
295
|
### `jam patch`
|
|
240
296
|
|
|
241
297
|
Ask the AI to generate a unified diff patch, validate it, and optionally apply it.
|
|
@@ -278,6 +334,7 @@ jam run "Read src/config.ts and identify any security issues"
|
|
|
278
334
|
| `git_diff` | Read | Get git diff |
|
|
279
335
|
| `write_file` | **Write** | Write to a file (prompts for confirmation) |
|
|
280
336
|
| `apply_patch` | **Write** | Apply a unified diff (prompts for confirmation) |
|
|
337
|
+
| `run_command` | **Write** | Execute a shell command (dangerous patterns blocked; prompts for confirmation) |
|
|
281
338
|
|
|
282
339
|
Write tools require confirmation unless `toolPolicy` is set to `allowlist` in config.
|
|
283
340
|
|
|
@@ -302,6 +359,18 @@ jam config init --global # create ~/.config/jam/config.json
|
|
|
302
359
|
|
|
303
360
|
---
|
|
304
361
|
|
|
362
|
+
### `jam context`
|
|
363
|
+
|
|
364
|
+
Manage the `JAM.md` project context file. This file is auto-read by `jam ask` and `jam chat` to give the model awareness of your project's architecture, conventions, and goals.
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
jam context init # generate JAM.md at the workspace root
|
|
368
|
+
jam context init --force # overwrite an existing JAM.md
|
|
369
|
+
jam context show # display the current JAM.md contents
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
305
374
|
### `jam models list`
|
|
306
375
|
|
|
307
376
|
```bash
|
|
@@ -356,12 +425,16 @@ Checks:
|
|
|
356
425
|
Jam merges config in priority order (highest wins):
|
|
357
426
|
|
|
358
427
|
```
|
|
359
|
-
1. CLI flags
|
|
360
|
-
2. .jam/config.json or .jamrc
|
|
361
|
-
3. ~/.
|
|
362
|
-
4.
|
|
428
|
+
1. CLI flags (--provider, --model, etc.)
|
|
429
|
+
2. .jam/config.json or .jamrc (repo-level)
|
|
430
|
+
3. ~/.jam/config.json (user home-dir dotfile — preferred)
|
|
431
|
+
4. ~/.config/jam/config.json (XDG user config — fallback)
|
|
432
|
+
5. Built-in defaults
|
|
363
433
|
```
|
|
364
434
|
|
|
435
|
+
> **Recommended:** Use `~/.jam/config.json` for your personal settings (provider, API keys, default model).
|
|
436
|
+
> Use `.jam/config.json` at the repo root for project-specific overrides (tool policy, redact patterns).
|
|
437
|
+
|
|
365
438
|
### Config Schema
|
|
366
439
|
|
|
367
440
|
```json
|
|
@@ -380,6 +453,10 @@ Jam merges config in priority order (highest wins):
|
|
|
380
453
|
"provider": "ollama",
|
|
381
454
|
"model": "qwen2.5-coder:1.5b",
|
|
382
455
|
"baseUrl": "http://localhost:11434"
|
|
456
|
+
},
|
|
457
|
+
"embedded": {
|
|
458
|
+
"provider": "embedded",
|
|
459
|
+
"model": "smollm2-360m"
|
|
383
460
|
}
|
|
384
461
|
},
|
|
385
462
|
"toolPolicy": "ask_every_time",
|
|
@@ -406,7 +483,7 @@ Jam merges config in priority order (highest wins):
|
|
|
406
483
|
|
|
407
484
|
| Field | Type | Description |
|
|
408
485
|
|-------|------|-------------|
|
|
409
|
-
| `provider` | string | Provider name (`ollama`) |
|
|
486
|
+
| `provider` | string | Provider name (`ollama`, `openai`, `groq`, `embedded`) |
|
|
410
487
|
| `model` | string | Model ID (e.g. `llama3.2`, `codellama`) |
|
|
411
488
|
| `baseUrl` | string | Provider API base URL |
|
|
412
489
|
| `apiKey` | string | API key (prefer keychain or env vars) |
|
|
@@ -417,11 +494,43 @@ Jam merges config in priority order (highest wins):
|
|
|
417
494
|
### Initialize Config
|
|
418
495
|
|
|
419
496
|
```bash
|
|
420
|
-
#
|
|
497
|
+
# User-level — creates ~/.jam/config.json (recommended)
|
|
498
|
+
jam config init --global
|
|
499
|
+
|
|
500
|
+
# Repo-level — creates .jam/config.json (committed to version control)
|
|
421
501
|
jam config init
|
|
502
|
+
```
|
|
422
503
|
|
|
423
|
-
|
|
424
|
-
|
|
504
|
+
The global config at `~/.jam/config.json` is the best place to set your default provider, model, API keys, and personal preferences. Edit it directly:
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
# Example: switch default provider to embedded
|
|
508
|
+
vim ~/.jam/config.json
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
```json
|
|
512
|
+
{
|
|
513
|
+
"defaultProfile": "default",
|
|
514
|
+
"profiles": {
|
|
515
|
+
"default": {
|
|
516
|
+
"provider": "ollama",
|
|
517
|
+
"model": "llama3.2",
|
|
518
|
+
"baseUrl": "http://localhost:11434"
|
|
519
|
+
},
|
|
520
|
+
"openai": {
|
|
521
|
+
"provider": "openai",
|
|
522
|
+
"model": "gpt-4o-mini",
|
|
523
|
+
"apiKey": "sk-..."
|
|
524
|
+
},
|
|
525
|
+
"offline": {
|
|
526
|
+
"provider": "embedded",
|
|
527
|
+
"model": "smollm2-360m"
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
"toolPolicy": "ask_every_time",
|
|
531
|
+
"historyEnabled": true,
|
|
532
|
+
"logLevel": "warn"
|
|
533
|
+
}
|
|
425
534
|
```
|
|
426
535
|
|
|
427
536
|
### Using Profiles
|
|
@@ -442,6 +551,74 @@ echo '{"defaultProfile": "fast"}' > .jamrc
|
|
|
442
551
|
|----------|-------------|
|
|
443
552
|
| `JAM_API_KEY` | API key fallback (if keytar unavailable) |
|
|
444
553
|
| `JAM_BASE_URL` | Override provider base URL |
|
|
554
|
+
| `OPENAI_API_KEY` | OpenAI API key (used when `provider: openai`) |
|
|
555
|
+
| `GROQ_API_KEY` | Groq API key (used when `provider: groq`) |
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
## Embedded Provider — Experimental ⚗️
|
|
560
|
+
|
|
561
|
+
> **⚠️ EXPERIMENTAL** — The embedded provider is functional but quality is limited by small model sizes. For production workloads, use Ollama or OpenAI.
|
|
562
|
+
|
|
563
|
+
The `embedded` provider runs a tiny GGUF model **directly in-process** via [`node-llama-cpp`](https://github.com/withcatai/node-llama-cpp). No Ollama installation, no server process, no network calls. **Models are only downloaded when you explicitly set `provider: "embedded"`** — it never downloads anything unless you opt in.
|
|
564
|
+
|
|
565
|
+
### Setup
|
|
566
|
+
|
|
567
|
+
```bash
|
|
568
|
+
# Install the native dependency (optional — only needed for embedded mode)
|
|
569
|
+
npm install node-llama-cpp
|
|
570
|
+
|
|
571
|
+
# Switch to embedded provider
|
|
572
|
+
jam ask "Hello" --provider embedded
|
|
573
|
+
|
|
574
|
+
# Or set it permanently in your config
|
|
575
|
+
jam config init --global # then edit ~/.jam/config.json
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### How It Works
|
|
579
|
+
|
|
580
|
+
1. On first use, Jam auto-downloads a small model (~250 MB) to `~/.jam/models/`
|
|
581
|
+
2. The model loads in-process using llama.cpp bindings — no external server
|
|
582
|
+
3. Streaming, tool-calling, and all standard commands work as usual
|
|
583
|
+
|
|
584
|
+
### Available Models
|
|
585
|
+
|
|
586
|
+
| Alias | Size (Q4_K_M) | Notes |
|
|
587
|
+
|-------|---------------|-------|
|
|
588
|
+
| `smollm2-135m` | ~100 MB | Ultra-light, very fast, basic quality |
|
|
589
|
+
| `smollm2-360m` | ~250 MB | **Default** — good quality-to-size ratio |
|
|
590
|
+
| `smollm2-1.7b` | ~1 GB | Best quality for embedded, needs more RAM |
|
|
591
|
+
|
|
592
|
+
```bash
|
|
593
|
+
# Use a specific embedded model alias
|
|
594
|
+
jam ask "Explain git rebase" --provider embedded --model smollm2-1.7b
|
|
595
|
+
|
|
596
|
+
# Or point to any local GGUF file
|
|
597
|
+
jam ask "Hello" --provider embedded --model /path/to/custom-model.gguf
|
|
598
|
+
|
|
599
|
+
# Profile-based setup
|
|
600
|
+
# In ~/.jam/config.json:
|
|
601
|
+
# {
|
|
602
|
+
# "profiles": {
|
|
603
|
+
# "offline": {
|
|
604
|
+
# "provider": "embedded",
|
|
605
|
+
# "model": "smollm2-1.7b"
|
|
606
|
+
# }
|
|
607
|
+
# }
|
|
608
|
+
# }
|
|
609
|
+
jam ask "Hello" --profile offline
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
### When to Use Embedded vs Ollama
|
|
613
|
+
|
|
614
|
+
| Scenario | Recommendation |
|
|
615
|
+
|----------|---------------|
|
|
616
|
+
| No Ollama / can't install system software | **Embedded** |
|
|
617
|
+
| CI/CD pipeline, Docker container, SSH box | **Embedded** |
|
|
618
|
+
| Air-gapped / offline machine | **Embedded** (after initial model download) |
|
|
619
|
+
| Want best quality & larger models (7B+) | **Ollama** |
|
|
620
|
+
| GPU acceleration needed | **Ollama** |
|
|
621
|
+
| Already have Ollama running | **Ollama** |
|
|
445
622
|
|
|
446
623
|
---
|
|
447
624
|
|
|
@@ -461,50 +638,14 @@ npm run test:coverage # coverage report
|
|
|
461
638
|
|
|
462
639
|
```
|
|
463
640
|
src/
|
|
464
|
-
├── index.ts
|
|
465
|
-
├── commands/
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
│ ├── patch.ts # jam patch
|
|
473
|
-
│ ├── auth.ts # jam auth
|
|
474
|
-
│ ├── config.ts # jam config
|
|
475
|
-
│ ├── models.ts # jam models
|
|
476
|
-
│ ├── history.ts # jam history
|
|
477
|
-
│ ├── completion.ts # jam completion
|
|
478
|
-
│ └── doctor.ts # jam doctor
|
|
479
|
-
├── providers/ # LLM adapter layer
|
|
480
|
-
│ ├── base.ts # ProviderAdapter interface
|
|
481
|
-
│ ├── ollama.ts # Ollama adapter (NDJSON streaming)
|
|
482
|
-
│ └── factory.ts # createProvider()
|
|
483
|
-
├── tools/ # Model-callable local tools
|
|
484
|
-
│ ├── types.ts # ToolDefinition, ToolResult interfaces
|
|
485
|
-
│ ├── registry.ts # ToolRegistry + permission enforcement
|
|
486
|
-
│ ├── read_file.ts
|
|
487
|
-
│ ├── list_dir.ts
|
|
488
|
-
│ ├── search_text.ts
|
|
489
|
-
│ ├── git_diff.ts
|
|
490
|
-
│ ├── git_status.ts
|
|
491
|
-
│ ├── apply_patch.ts
|
|
492
|
-
│ └── write_file.ts
|
|
493
|
-
├── config/ # Config loading and schema
|
|
494
|
-
│ ├── schema.ts # Zod schema
|
|
495
|
-
│ ├── defaults.ts # Built-in defaults
|
|
496
|
-
│ └── loader.ts # cosmiconfig + deep merge
|
|
497
|
-
├── storage/
|
|
498
|
-
│ └── history.ts # Chat session persistence (JSON files)
|
|
499
|
-
├── ui/
|
|
500
|
-
│ ├── chat.tsx # Ink chat REPL (React TUI)
|
|
501
|
-
│ └── renderer.ts # Markdown + streaming renderer
|
|
502
|
-
└── utils/
|
|
503
|
-
├── errors.ts # JamError class
|
|
504
|
-
├── stream.ts # withRetry, collectStream
|
|
505
|
-
├── logger.ts # Logger (stderr, redaction)
|
|
506
|
-
├── secrets.ts # keytar + env fallback
|
|
507
|
-
└── workspace.ts # Git root detection
|
|
641
|
+
├── index.ts # CLI entry point — command registration (Commander)
|
|
642
|
+
├── commands/ # One file per command (ask, chat, run, review, commit, …)
|
|
643
|
+
├── providers/ # LLM adapter layer — ProviderAdapter interface + Ollama, Embedded impl
|
|
644
|
+
├── tools/ # Model-callable tools + registry + permission enforcement
|
|
645
|
+
├── config/ # Zod schema, cosmiconfig loader, built-in defaults
|
|
646
|
+
├── storage/ # Chat session persistence (JSON files)
|
|
647
|
+
├── ui/ # Ink/React TUI (chat REPL) + Markdown/streaming renderer
|
|
648
|
+
└── utils/ # Shared helpers: streaming, logger, secrets, agent loop, tokens
|
|
508
649
|
```
|
|
509
650
|
|
|
510
651
|
---
|
|
@@ -584,17 +725,244 @@ We take security seriously. If you discover a vulnerability, please **do not** o
|
|
|
584
725
|
|
|
585
726
|
## Roadmap
|
|
586
727
|
|
|
587
|
-
- [
|
|
728
|
+
- [x] OpenAI provider
|
|
729
|
+
- [ ] Azure OpenAI provider
|
|
588
730
|
- [ ] Anthropic Claude provider
|
|
589
|
-
- [
|
|
590
|
-
- [ ] `jam commit` — AI-generated commit messages
|
|
591
|
-
- [ ] `jam review` — PR review workflow
|
|
731
|
+
- [x] Groq provider
|
|
592
732
|
- [ ] Plugin system for custom tools
|
|
593
733
|
- [ ] Token usage tracking and budgets
|
|
594
734
|
- [ ] Web UI companion
|
|
595
735
|
|
|
596
736
|
---
|
|
597
737
|
|
|
738
|
+
## Probable Enhancements
|
|
739
|
+
|
|
740
|
+
> Ideas and directions under consideration. These range from quick wins to deep architectural changes. Contributions, RFCs, and discussion on any of these are welcome.
|
|
741
|
+
|
|
742
|
+
### 🧩 Plugin System
|
|
743
|
+
|
|
744
|
+
The tool registry (`ToolRegistry.register()`) already accepts any `ToolDefinition`, but tool discovery is hardcoded. A proper plugin system would allow external tools without modifying source.
|
|
745
|
+
|
|
746
|
+
- **Local plugins** — load `ToolDefinition` modules from `.jam/plugins/` or `~/.config/jam/plugins/`
|
|
747
|
+
- **npm plugin packages** — `jam plugin install @scope/jam-plugin-docker` discovers and registers tools at startup
|
|
748
|
+
- **Plugin manifest** — declarative `jam-plugin.json` with name, version, tool definitions, required permissions
|
|
749
|
+
- **Lifecycle hooks** — `onActivate`, `onDeactivate`, `beforeToolCall`, `afterToolCall` for plugin-level middleware
|
|
750
|
+
- **Sandboxed execution** — plugins run with restricted filesystem/network access based on declared capabilities
|
|
751
|
+
|
|
752
|
+
```
|
|
753
|
+
jam plugin install jam-plugin-docker
|
|
754
|
+
jam plugin list
|
|
755
|
+
jam plugin remove jam-plugin-docker
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
### 🎯 Skills
|
|
759
|
+
|
|
760
|
+
Skills are named, composable mini-agents — each with a focused system prompt, a curated tool subset, and a defined output contract. Think of them as recipes the model can invoke.
|
|
761
|
+
|
|
762
|
+
- **Built-in skills** — `refactor`, `test-writer`, `documenter`, `security-audit`, `dependency-update`, `migration`
|
|
763
|
+
- **Skill registry** — each skill declares its name, description, required tools, system prompt template, and output schema
|
|
764
|
+
- **Composable** — skills can call other skills (e.g., `refactor` invokes `test-writer` to verify changes)
|
|
765
|
+
- **User-defined skills** — `.jam/skills/` directory with YAML/JSON skill definitions
|
|
766
|
+
- **Skill marketplace** — share and import community skills via npm or a registry
|
|
767
|
+
|
|
768
|
+
```yaml
|
|
769
|
+
# .jam/skills/api-endpoint.yaml
|
|
770
|
+
name: api-endpoint
|
|
771
|
+
description: Generate a new REST API endpoint with tests
|
|
772
|
+
tools: [read_file, write_file, search_text, run_command]
|
|
773
|
+
system: |
|
|
774
|
+
You are an API endpoint generator. Given a resource name and
|
|
775
|
+
fields, generate the route handler, validation, tests, and
|
|
776
|
+
OpenAPI schema following the project's existing patterns.
|
|
777
|
+
output:
|
|
778
|
+
type: files
|
|
779
|
+
confirm: true
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
```bash
|
|
783
|
+
jam skill run refactor --file src/api/auth.ts
|
|
784
|
+
jam skill run test-writer --file src/utils/cache.ts
|
|
785
|
+
jam skill list
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
### 🤖 Sub-Agents & Task Decomposition
|
|
789
|
+
|
|
790
|
+
The current agent loop (`jam run`) is a single monolithic ReAct loop. Sub-agents would enable the planner to decompose complex instructions into specialized child tasks.
|
|
791
|
+
|
|
792
|
+
- **Planner agent** — breaks a complex instruction into an ordered DAG of sub-tasks
|
|
793
|
+
- **Specialist delegation** — each sub-task dispatched to a purpose-built sub-agent (e.g., "read and understand", "refactor", "write tests", "verify")
|
|
794
|
+
- **Result aggregation** — parent agent collects sub-agent outputs and synthesizes a final result
|
|
795
|
+
- **Parallel sub-agents** — independent sub-tasks execute concurrently (e.g., "write tests" and "update docs" in parallel)
|
|
796
|
+
- **Scoped context** — each sub-agent receives only the context it needs, reducing token waste
|
|
797
|
+
- **Fail-and-retry isolation** — a failed sub-agent can be retried without restarting the entire task
|
|
798
|
+
|
|
799
|
+
```bash
|
|
800
|
+
jam run "Refactor the auth module to use JWT, update all tests, and document the changes"
|
|
801
|
+
# Planner decomposes into:
|
|
802
|
+
# 1. [understand] Read current auth module and tests
|
|
803
|
+
# 2. [refactor] Rewrite auth module with JWT
|
|
804
|
+
# 3. [test] Update tests for new implementation (parallel with 4)
|
|
805
|
+
# 4. [document] Update docs and JSDoc comments (parallel with 3)
|
|
806
|
+
# 5. [verify] Run tests and validate the patch
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
### 🔌 Connectors
|
|
810
|
+
|
|
811
|
+
Connectors are adapters for external services — bringing data in and pushing results out. Currently Jam only understands the local filesystem and git.
|
|
812
|
+
|
|
813
|
+
- **GitHub** — read/create issues, PRs, review comments; `jam review --pr 42` already shells out to `gh`, a connector would be native
|
|
814
|
+
- **GitLab / Bitbucket** — equivalent PR/MR workflows for non-GitHub teams
|
|
815
|
+
- **JIRA / Linear / Shortcut** — fetch issue context, update status, attach AI-generated summaries
|
|
816
|
+
- **Slack / Discord** — post review summaries, commit digests, or search results to channels
|
|
817
|
+
- **Database** — read schema, run read-only queries, explain query plans
|
|
818
|
+
- **REST / GraphQL** — generic HTTP connector for internal APIs (`jam ask "Why is /api/users slow?" --connector api-prod`)
|
|
819
|
+
- **Docker / K8s** — read container logs, describe pods, inspect images
|
|
820
|
+
- **CI/CD** — read build logs, trigger pipelines, analyze failures
|
|
821
|
+
|
|
822
|
+
```json
|
|
823
|
+
// .jam/config.json
|
|
824
|
+
{
|
|
825
|
+
"connectors": {
|
|
826
|
+
"github": { "token": "env:GITHUB_TOKEN" },
|
|
827
|
+
"jira": { "baseUrl": "https://myorg.atlassian.net", "token": "env:JIRA_TOKEN" },
|
|
828
|
+
"postgres": { "connectionString": "env:DATABASE_URL", "readOnly": true }
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
### 🧠 MCP (Model Context Protocol) Support
|
|
834
|
+
|
|
835
|
+
[MCP](https://modelcontextprotocol.io) is an open standard for connecting AI models to external tools and data sources. Adding MCP client support would let Jam consume any MCP-compatible server.
|
|
836
|
+
|
|
837
|
+
- **MCP client** — Jam discovers and connects to MCP servers declared in config
|
|
838
|
+
- **Tool bridge** — MCP tools appear as native Jam tools in the registry, usable by `jam run`
|
|
839
|
+
- **Resource bridge** — MCP resources (files, database rows, API responses) injected as context
|
|
840
|
+
- **Prompt bridge** — MCP prompt templates available as Jam skills
|
|
841
|
+
- **Server mode** — expose Jam's own tools (read_file, search_text, git_diff, etc.) as an MCP server for other agents
|
|
842
|
+
|
|
843
|
+
```json
|
|
844
|
+
{
|
|
845
|
+
"mcp": {
|
|
846
|
+
"servers": {
|
|
847
|
+
"filesystem": { "command": "npx @modelcontextprotocol/server-filesystem /path/to/dir" },
|
|
848
|
+
"postgres": { "command": "npx @modelcontextprotocol/server-postgres", "env": { "DATABASE_URL": "..." } }
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
### ⚡ Parallel Tool Execution
|
|
855
|
+
|
|
856
|
+
Currently tools execute sequentially within each agent round. When the model requests multiple independent tool calls (e.g., read three files), they could run concurrently.
|
|
857
|
+
|
|
858
|
+
- **Dependency analysis** — detect independent tool calls within a single round
|
|
859
|
+
- **Concurrent dispatch** — `Promise.all()` for independent read operations
|
|
860
|
+
- **Write serialization** — write tools always execute sequentially and with confirmation
|
|
861
|
+
- **Progress display** — show parallel tool execution status in real time
|
|
862
|
+
|
|
863
|
+
### 🔗 Middleware & Hooks
|
|
864
|
+
|
|
865
|
+
A middleware chain around LLM calls and tool executions, enabling cross-cutting concerns without modifying core logic.
|
|
866
|
+
|
|
867
|
+
- **Pre/post LLM hooks** — prompt injection defense, cost tracking, audit logging
|
|
868
|
+
- **Pre/post tool hooks** — rate limiting, output sanitization, metrics
|
|
869
|
+
- **Error interceptors** — custom retry logic, fallback providers, graceful degradation
|
|
870
|
+
- **Event emitter** — structured events (`tool:start`, `tool:end`, `llm:stream`, `agent:iteration`) for UI decoupling, telemetry, and external integrations
|
|
871
|
+
|
|
872
|
+
```typescript
|
|
873
|
+
// .jam/middleware/cost-tracker.ts
|
|
874
|
+
export default {
|
|
875
|
+
name: 'cost-tracker',
|
|
876
|
+
afterCompletion({ usage, provider, model }) {
|
|
877
|
+
const cost = estimateCost(provider, model, usage);
|
|
878
|
+
appendToLog(`~/.jam/cost.csv`, { timestamp: Date.now(), model, cost });
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
### 🧭 Embeddings & Vector Search
|
|
884
|
+
|
|
885
|
+
The current past-session search uses keyword overlap (Jaccard scoring), and the symbol index is regex-based. Optional local embeddings would enable true semantic search.
|
|
886
|
+
|
|
887
|
+
- **Local embedding model** — use Ollama's embedding endpoint (`nomic-embed-text`, `mxbai-embed-large`) so nothing leaves your machine
|
|
888
|
+
- **Codebase index** — vector index of functions, classes, and doc comments stored at `.jam/vectors/`
|
|
889
|
+
- **Semantic code search** — `jam search "authentication flow"` returns semantically relevant code, not just keyword matches
|
|
890
|
+
- **Session memory** — embed past Q&A pairs for cross-session context recall with relevance decay
|
|
891
|
+
- **RAG pipeline** — retrieve relevant code chunks before prompting, reducing token usage and improving accuracy
|
|
892
|
+
|
|
893
|
+
### 💰 Cost & Token Tracking
|
|
894
|
+
|
|
895
|
+
`TokenUsage` is already captured per request but not aggregated or displayed.
|
|
896
|
+
|
|
897
|
+
- **Session cost estimation** — estimate cost based on provider pricing (configurable per-profile)
|
|
898
|
+
- **Budget limits** — `maxCostPerSession`, `maxCostPerDay` in config; warn or hard-stop when exceeded
|
|
899
|
+
- **Usage dashboard** — `jam usage` command showing tokens consumed, cost by model, by command, over time
|
|
900
|
+
- **Token budget per tool call** — prevent runaway context from a single large file read
|
|
901
|
+
|
|
902
|
+
```bash
|
|
903
|
+
jam usage # summary: today, this week, this month
|
|
904
|
+
jam usage --detail # per-session breakdown
|
|
905
|
+
jam usage --export csv # export for expense tracking
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
### 📦 Multi-File Transactions
|
|
909
|
+
|
|
910
|
+
`apply_patch` and `write_file` currently operate on single files with no rollback mechanism.
|
|
911
|
+
|
|
912
|
+
- **Transaction block** — group multiple file writes into an atomic operation
|
|
913
|
+
- **Git stash checkpoint** — auto-stash before a multi-file edit, restore on failure
|
|
914
|
+
- **Dry-run preview** — show all proposed changes across files before any writes
|
|
915
|
+
- **Selective accept** — accept/reject individual file changes within a transaction
|
|
916
|
+
|
|
917
|
+
### 🔍 Provider Capabilities & Feature Negotiation
|
|
918
|
+
|
|
919
|
+
The `ProviderAdapter` interface treats all providers equally, but providers differ in capabilities.
|
|
920
|
+
|
|
921
|
+
- **Capability flags** — `supportsToolCalling`, `supportsVision`, `supportsStructuredOutput`, `supportsEmbeddings` on `ProviderInfo`
|
|
922
|
+
- **Graceful degradation** — if a provider doesn't support tool calling, fall back to prompt-based tool simulation
|
|
923
|
+
- **Model capability discovery** — query the provider for model-specific features at runtime
|
|
924
|
+
- **Auto-routing** — route tasks to the best-fit model/provider (e.g., use a fast model for planning, a capable model for generation)
|
|
925
|
+
|
|
926
|
+
### 🧠 Persistent Agent Memory
|
|
927
|
+
|
|
928
|
+
Working memory is currently session-scoped. Cross-session memory would make Jam smarter over time.
|
|
929
|
+
|
|
930
|
+
- **Workspace knowledge base** — facts, patterns, and conventions learned from past sessions, stored per-repo
|
|
931
|
+
- **Memory decay** — older memories lose relevance weight over time unless reinforced
|
|
932
|
+
- **Explicit memory** — `jam remember "the auth module uses bcrypt, not argon2"` for user-declared facts
|
|
933
|
+
- **Memory retrieval** — automatically surface relevant memories during planning and synthesis
|
|
934
|
+
- **Forgetting** — `jam forget` to clear or selectively prune memories
|
|
935
|
+
|
|
936
|
+
### 🌐 Web UI Companion
|
|
937
|
+
|
|
938
|
+
A local web interface for sessions that benefit from richer display.
|
|
939
|
+
|
|
940
|
+
- **Diff viewer** — syntax-highlighted side-by-side diffs for `jam patch` and `jam review`
|
|
941
|
+
- **Session browser** — visual history of past chat sessions with search
|
|
942
|
+
- **Tool call inspector** — expandable timeline of every tool call, its input, output, and duration
|
|
943
|
+
- **Markdown preview** — rendered Markdown responses with code block copy buttons
|
|
944
|
+
- **Served locally** — `jam ui` starts a local server; no external hosting
|
|
945
|
+
|
|
946
|
+
### 🧪 Testing & Verification Skills
|
|
947
|
+
|
|
948
|
+
First-class support for test generation and verification.
|
|
949
|
+
|
|
950
|
+
- **Test generation** — `jam test generate src/utils/cache.ts` generates tests matching project conventions
|
|
951
|
+
- **Test-driven patch** — `jam patch` can optionally run tests before and after applying changes
|
|
952
|
+
- **Coverage-aware context** — prioritize uncovered code paths in review and audit workflows
|
|
953
|
+
- **Regression detection** — track which tests fail after a patch and auto-revert if needed
|
|
954
|
+
|
|
955
|
+
### 🐚 Shell Integration & Workflow Automation
|
|
956
|
+
|
|
957
|
+
Deeper shell integration for power users and CI/CD pipelines.
|
|
958
|
+
|
|
959
|
+
- **Git hooks** — `jam hooks install` sets up pre-commit (auto-lint), prepare-commit-msg (AI message), pre-push (review)
|
|
960
|
+
- **Watch mode** — `jam watch` monitors file changes and provides continuous AI feedback
|
|
961
|
+
- **Pipeline mode** — structured JSON I/O for chaining Jam commands in shell scripts and CI
|
|
962
|
+
- **Makefile/Taskfile recipes** — pre-built task definitions for common workflows
|
|
963
|
+
|
|
964
|
+
---
|
|
965
|
+
|
|
598
966
|
## Acknowledgments
|
|
599
967
|
|
|
600
968
|
Built with these excellent open source projects:
|
package/dist/commands/ask.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ export interface AskOptions extends CliOverrides {
|
|
|
3
3
|
file?: string;
|
|
4
4
|
json?: boolean;
|
|
5
5
|
noColor?: boolean;
|
|
6
|
+
quiet?: boolean;
|
|
6
7
|
system?: string;
|
|
8
|
+
/** Enable read-only tool use so the model can discover and read files.
|
|
9
|
+
* Defaults to true when stdout is a TTY and the provider supports chatWithTools. */
|
|
10
|
+
tools?: boolean;
|
|
7
11
|
}
|
|
8
12
|
export declare function runAsk(inlinePrompt: string | undefined, options: AskOptions): Promise<void>;
|
|
9
13
|
//# sourceMappingURL=ask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../../src/commands/ask.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../../src/commands/ask.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;yFACqF;IACrF,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA0CD,wBAAsB,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAyQjG"}
|