@deltrace/cli 0.1.1 → 0.1.3
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 +19 -69
- package/dist/cli.js +22 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,83 +1,33 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @deltrace/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Deltrace compresses your codebase into a high-density context block and injects it into every Claude Code or Codex request automatically — no manual file sharing, no wasted context.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Before every prompt, a `UserPromptSubmit` hook runs `sync.ts`. It walks the current working directory, hashes each file, and POSTs changed files to the **chunker**. The chunker parses each file with tree-sitter into semantic `CodeChunk[]` objects and stores them in RDS (keyed by content hash — unchanged files are skipped). When a Claude Code or Codex request arrives at the **proxy**, it creates a job in the `jobs` table, pushes it to SQS, and a **Minions inference worker** (Qwen2.5-Coder-14B on a GPU box) pulls the message, runs the MinionS protocol against all workspace chunks, and writes a compressed codebase summary back. The proxy polls the row, injects the summary as `<codebase_context>` into the system prompt, and forwards to `api.anthropic.com` or `api.openai.com` with the user's own API key. If the worker doesn't finish in time, the proxy degrades gracefully and forwards without context.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Processes
|
|
14
|
-
|
|
15
|
-
Three PM2 processes, each on its own port. nginx terminates TLS on 443 and routes by path prefix — ports 3000/3001/3002 are never exposed to the internet.
|
|
16
|
-
|
|
17
|
-
| Process | Port | Handles |
|
|
18
|
-
|---|---|---|
|
|
19
|
-
| `proxy` | 3000 | `/ws/:id/v1/*` — AI request forwarding, pure I/O |
|
|
20
|
-
| `chunker` | 3001 | `/upload`, `/auth/activate` — file ingestion, tree-sitter |
|
|
21
|
-
| `api` | 3002 | `/api/*` — user auth, API keys, repos, usage stats |
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## Codebase structure
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
src/
|
|
29
|
-
├── proxy.ts — Port 3000. AI proxy routes.
|
|
30
|
-
├── chunker-server.ts — Port 3001. File ingestion.
|
|
31
|
-
├── api-server.ts — Port 3002. User-facing API server.
|
|
32
|
-
├── userApi.ts — Route handlers for api-server (me, keys, repos, usage).
|
|
33
|
-
├── store.ts — All PostgreSQL access. Fetches DB credentials from AWS
|
|
34
|
-
│ Secrets Manager at startup — no DATABASE_URL needed in env.
|
|
35
|
-
├── session.ts — Redis session store. Falls back to in-memory Map in dev.
|
|
36
|
-
├── s3.ts — Chunk blob storage helpers.
|
|
37
|
-
├── sqs.ts — SQS helpers for Minions job dispatch.
|
|
38
|
-
├── chunker.ts — AST-based semantic chunking via tree-sitter.
|
|
39
|
-
├── treeSitter.ts — WASM tree-sitter init and language loading.
|
|
40
|
-
├── languageMap.ts — File extension → language + WASM mapping.
|
|
41
|
-
├── tokenizer.ts — Token estimation and overlap splitting.
|
|
42
|
-
├── types.ts — Shared types (CodeChunk, CompressedChunk, etc.)
|
|
43
|
-
├── sync.ts — Pre-prompt hook: walks cwd, uploads changed files.
|
|
44
|
-
├── login.ts — OAuth setup for Claude Code.
|
|
45
|
-
└── login-codex.ts — OAuth setup for Codex.
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @deltrace/cli
|
|
46
9
|
```
|
|
47
10
|
|
|
48
|
-
|
|
11
|
+
## Setup
|
|
49
12
|
|
|
50
|
-
|
|
13
|
+
**Claude Code:**
|
|
14
|
+
```bash
|
|
15
|
+
deltrace-claude
|
|
16
|
+
```
|
|
51
17
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
| Credentials | EC2 IAM role (`compression-server-ec2-ssm-role`) — no API keys in env |
|
|
57
|
-
| Session state | ElastiCache Redis (in-memory fallback for dev) |
|
|
58
|
-
| Chunk storage | S3 `deltrace-chunks` bucket |
|
|
59
|
-
| Job queue | SQS `compression-jobs-queue` |
|
|
60
|
-
| TLS | nginx + Let's Encrypt |
|
|
61
|
-
| Process manager | PM2 |
|
|
18
|
+
**Codex:**
|
|
19
|
+
```bash
|
|
20
|
+
deltrace-codex
|
|
21
|
+
```
|
|
62
22
|
|
|
63
|
-
|
|
23
|
+
Both commands open a browser, sign you in, and configure your agent automatically.
|
|
64
24
|
|
|
65
|
-
##
|
|
25
|
+
## Uninstall
|
|
66
26
|
|
|
67
27
|
```bash
|
|
68
|
-
|
|
69
|
-
npm run build # compile TypeScript → dist/
|
|
70
|
-
npm start # run compiled output
|
|
71
|
-
|
|
72
|
-
npm run compressor:claude # OAuth setup for Claude Code
|
|
73
|
-
npm run compressor:codex # OAuth setup for Codex
|
|
74
|
-
npm run teardown:claude # undo Claude Code setup
|
|
75
|
-
npm run teardown:codex # undo Codex setup
|
|
76
|
-
npm run sync # manually upload cwd to server
|
|
28
|
+
deltrace-teardown
|
|
77
29
|
```
|
|
78
30
|
|
|
79
|
-
##
|
|
31
|
+
## How it works
|
|
80
32
|
|
|
81
|
-
|
|
82
|
-
git pull && npm run build && pm2 restart all
|
|
83
|
-
```
|
|
33
|
+
A hook runs before every prompt. It walks your working directory, uploads changed files to the Deltrace service, and the proxy injects a compressed codebase summary into the system prompt before forwarding to Anthropic or OpenAI. Your API keys are forwarded directly and never stored.
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const cmd = process.argv[2];
|
|
4
|
+
const help = `
|
|
5
|
+
Deltrace — codebase context compression for AI coding agents
|
|
6
|
+
|
|
7
|
+
Commands:
|
|
8
|
+
deltrace-claude Set up Claude Code (writes ~/.claude/settings.json)
|
|
9
|
+
deltrace-codex Set up Codex (writes ~/.codex/config.toml)
|
|
10
|
+
deltrace-teardown Remove Deltrace config and hooks from this machine
|
|
11
|
+
|
|
12
|
+
Sync runs automatically before every prompt once set up.
|
|
13
|
+
Your API keys are forwarded directly and never stored.
|
|
14
|
+
|
|
15
|
+
docs: deltrace.com
|
|
16
|
+
`;
|
|
17
|
+
if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') {
|
|
18
|
+
console.log(help);
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
console.error(` Unknown command: ${cmd}\n${help}`);
|
|
22
|
+
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deltrace/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Codebase context compression for AI coding agents",
|
|
5
5
|
"files": [
|
|
6
|
+
"dist/cli.js",
|
|
6
7
|
"dist/login.js",
|
|
7
8
|
"dist/login-codex.js",
|
|
8
9
|
"dist/sync.js",
|
|
@@ -10,7 +11,8 @@
|
|
|
10
11
|
"dist/teardown-codex.js"
|
|
11
12
|
],
|
|
12
13
|
"bin": {
|
|
13
|
-
"deltrace": "dist/
|
|
14
|
+
"deltrace": "dist/cli.js",
|
|
15
|
+
"deltrace-claude": "dist/login.js",
|
|
14
16
|
"deltrace-codex": "dist/login-codex.js",
|
|
15
17
|
"deltrace-sync": "dist/sync.js",
|
|
16
18
|
"deltrace-teardown": "dist/teardown.js"
|