@kmugalkhod/lightcode 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.
Files changed (5) hide show
  1. package/README.md +62 -0
  2. package/cli.js +13754 -0
  3. package/lightcode.cjs +52 -0
  4. package/package.json +34 -0
  5. package/server.js +7585 -0
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # Lightcode
2
+
3
+ A personal AI coding agent with a terminal UI. Lightcode pairs an OpenTUI
4
+ chat interface with a local Hono API server, persistent SQLite sessions, a
5
+ permission-gated tool suite (files, shell, git, web, MCP), and tiered context
6
+ optimization that keeps long sessions inside the model's context window
7
+ without ever losing history.
8
+
9
+ ## Quick start (from source)
10
+
11
+ ```bash
12
+ bun install
13
+ bun run cli:dev # starts the TUI; it boots the server automatically
14
+ ```
15
+
16
+ On first run Lightcode walks you through provider setup (Anthropic,
17
+ OpenRouter, OpenCode Zen, or any OpenAI-compatible endpoint) and stores the
18
+ API key in `~/.lightcode/credentials.json`. Environment variables such as
19
+ `ANTHROPIC_API_KEY` always take precedence.
20
+
21
+ ## Commands
22
+
23
+ ```bash
24
+ bun run cli:dev # TUI (auto-starts the server)
25
+ bun run server:dev # API server alone, watch mode
26
+ bun run typecheck # TypeScript + tool schema preflight
27
+ bun test # test suite
28
+ bun run build # build the publishable package into dist/
29
+ bun run release # verify + build + npm pack (--publish to release)
30
+ ```
31
+
32
+ ## Configuration
33
+
34
+ Settings merge from `~/.lightcode/settings.json`, then
35
+ `.lightcode/settings.json` in the project, then `LIGHTCODE_*` environment
36
+ variables. Notable keys:
37
+
38
+ | Key | Purpose |
39
+ | --- | --- |
40
+ | `provider`, `model`, `baseUrl` | Provider selection and model id |
41
+ | `defaultMode` | `build` or `plan` |
42
+ | `permissionMode`, `permissions` | Tool permission policy |
43
+ | `context.compactAtFraction` | Context compaction threshold (default 0.8) |
44
+ | `context.pruneAtFraction` | Tool-output pruning threshold (default 0.6) |
45
+ | `context.contextWindowOverride` | Override the model context window |
46
+
47
+ ## Context optimization
48
+
49
+ Long sessions stay healthy through three tiers: real-usage-calibrated token
50
+ estimation, free pruning of stale tool outputs and duplicate file reads, and
51
+ LLM-written summaries once the compaction threshold is crossed (with an
52
+ extractive fallback when the model is unreachable). The full conversation is
53
+ always preserved in SQLite — compaction only changes what the model sees.
54
+ Use `/compact` in a chat to compact manually.
55
+
56
+ ## Workspaces
57
+
58
+ - `apps/cli` — OpenTUI React terminal interface
59
+ - `apps/server` — Hono API server (sessions, streaming, diagnostics)
60
+ - `packages/ai` — agent core: tools, permissions, context engine, config
61
+ - `packages/db` — Prisma + local SQLite storage
62
+ - `packages/shared` — logging, errors, version