@tokenring-ai/coder 0.1.5

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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2025 Mark Dierolf
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # Token Ring AI Monorepo
2
+
3
+ ## Overview
4
+
5
+ The Token Ring AI monorepo hosts the development of the Token Ring Coder Application, an interactive AI-powered developer assistant. This framework enables conversational interaction with codebases, supporting tasks like code editing, refactoring, testing, git operations, and integrations with external services (e.g., AWS, Docker, web search). Built as a TypeScript monorepo using Bun, it provides pluggable packages under the `@tokenring-ai/*` scope for modular AI agent functionality. Key features include persistent chat sessions in SQLite, command-based workflows, plugin extensibility, and sandboxed execution. The ecosystem targets developers seeking AI-assisted coding in a secure, local environment (version 0.1.0, early-stage).
6
+
7
+ ## Monorepo Structure
8
+
9
+ - **src/**: Core application source, including the main entry point `tr-coder.js` for the CLI REPL.
10
+ - **pkg/**: Workspace packages for modular components (e.g., `@tokenring-ai/agent`, `@tokenring-ai/ai-client`). Each package has its own `package.json`, source in `index.ts`, and optional tests/docs.
11
+ - **docker/**: Dockerfile and configs for containerized deployment (base: oven/bun:debian).
12
+ - **.github/**: CI/CD workflows (e.g., for building/testing).
13
+ - **Root configs**: `package.json` (workspaces, scripts), `tsconfig.json` (ES2022, strict mode), `biome.json` (linting/formatting), `.gitmodules` (submodules for external deps like inquirer packages).
14
+ - **docs**: `AGENTS.md` (project overview), existing `README.md` (Coder app details).
15
+ - Other: `.tokenring/` (per-project config/DB), `node_modules/` (hoisted via workspaces).
16
+
17
+ Packages integrate via scoped imports (e.g., `import { Agent } from '@tokenring-ai/agent';`), with the root app wiring them into the Coder CLI.
18
+
19
+ ## Installation/Setup
20
+
21
+ ### Prerequisites
22
+ - Bun (package manager/runtime)
23
+ - Git (with submodules support)
24
+ - Node.js-compatible env for deps (e.g., for testing)
25
+
26
+ ### Cloning and Setup
27
+ 1. Clone the repo:
28
+ ```
29
+ git clone <repo-url>
30
+ cd tokenring-ai-monorepo
31
+ ```
32
+ 2. Initialize submodules (required for external packages like inquirer variants):
33
+ ```
34
+ git submodule update --init --recursive
35
+ ```
36
+ 3. Install dependencies (uses Bun workspaces for hoisting):
37
+ ```
38
+ bun install
39
+ ```
40
+ 4. (Optional) Initialize a project with Token Ring config:
41
+ ```
42
+ bun src/tr-coder.js --source ./your-codebase --initialize
43
+ ```
44
+ This creates `.tokenring/coder-config.js` and SQLite DB for chat history.
45
+
46
+ ### Environment Setup
47
+ Set API keys for integrations (e.g., AI providers, AWS):
48
+ - Export vars like `OPENAI_API_KEY`, `AWS_ACCESS_KEY_ID` (passed to Docker via `-e`).
49
+ - For AI clients: Configure via `@tokenring-ai/ai-client` (supports OpenAI, Anthropic, Groq, etc.).
50
+
51
+ ### Docker Setup
52
+ 1. Build image:
53
+ ```
54
+ docker build -t tokenring-ai/coder:latest -f docker/Dockerfile .
55
+ ```
56
+ 2. Run (mounts codebase, passes env):
57
+ ```
58
+ docker run -ti --net host -v ./:/repo:rw $(env | grep '_KEY' | sed 's/^/-e /') tokenring-ai/coder:latest
59
+ ```
60
+
61
+ ## Core Packages and Integration
62
+
63
+ The monorepo uses workspaces for loosely coupled packages. Core packages form the agent framework; integrations extend tools/resources. Agents compose tools from multiple packages (e.g., an agent using `filesystem` for reads, `git` for commits, `ai-client` for LLM calls).
64
+
65
+ ### Core Packages
66
+ | Package | Description | Key Exports/Usage |
67
+ |---------|--------------------------------------------------------------------------------------------------|-------------------|
68
+ | `@tokenring-ai/agent` | Central agent orchestration with event emitters, UUIDs, glob-gitignore. | `Agent` class; integrates tools via registries. Used in CLI for chat sessions. |
69
+ | `@tokenring-ai/ai-client` | Multi-provider AI SDK wrapper (OpenAI, Anthropic, Groq, etc., via `@ai-sdk/*`). | LLM calls, streaming; e.g., `generateText({ model: 'gpt-4o' })`. Ties to agent for reasoning. |
70
+ | `@tokenring-ai/filesystem` | Abstract FS ops (read/write/search) with ignore patterns. | `FileSystem` interface; extended by `local-filesystem` for local ops. |
71
+ | `@tokenring-ai/cli` | Agent CLI for interactive agent selection, chat commands, and human interface handling. | `REPLService` class; provides agent lifecycle management, event streaming, and extensible slash commands. |
72
+ | `@tokenring-ai/memory` | In-memory storage for agent state/context. | Session persistence; integrates with `queue` for batched prompts. |
73
+ | `@tokenring-ai/queue` | Task queuing for sequential AI operations. | `Queue` class; used for multi-step workflows like code gen + test. |
74
+
75
+ ### Integration Packages
76
+ These provide domain-specific tools/resources, registered to agents:
77
+ - **Cloud/Infra**: `@tokenring-ai/aws` (S3/STF clients), `@tokenring-ai/docker` (container exec), `@tokenring-ai/kubernetes` (K8s client), `@tokenring-ai/s3` (S3 FS impl).
78
+ - **CLI/Interface**: `@tokenring-ai/cli` (REPL service with REPLService class, agent selection/creation, chat commands like /help, /exit, /multi, /edit, human interface handlers for confirmations/selections).
79
+ - **Dev Tools**: `@tokenring-ai/git` (commit/rollback via execa), `@tokenring-ai/javascript` (ESLint, jscodeshift for JS ops), `@tokenring-ai/testing` (Vitest integration), `@tokenring-ai/code-watch` (chokidar for change detection).
80
+ - **Data/DB**: `@tokenring-ai/database` (abstract DB), `@tokenring-ai/mysql` (MySQL2 connector), `@tokenring-ai/sqlite-storage` (local DB for history).
81
+ - **Web/Search**: `@tokenring-ai/chrome` (Puppeteer automation), `@tokenring-ai/websearch` (abstract), `@tokenring-ai/serper` (Google search), `@tokenring-ai/scraperapi` (web scraping), `@tokenring-ai/wikipedia` (wiki queries).
82
+ - **Other**: `@tokenring-ai/codebase` (repo scanning), `@tokenring-ai/file-index` (vector search with tree-sitter), `@tokenring-ai/feedback` (UI for sessions with React/Express), `@tokenring-ai/sandbox` (isolated exec via Zod validation).
83
+
84
+ Cross-package example: The CLI's `REPLService` uses `agent` for team management, provides chat commands via modular command system (/help, /exit, /multi, /edit), handles human interface requests (confirmations, selections, tree navigation), and streams agent events (chat output, reasoning, system messages, busy/idle states). See pkg/ READMEs for details (e.g., pkg/agent/README.md, pkg/cli/README.md).
85
+
86
+ ## Usage Examples
87
+
88
+ 1. **Running the Coder CLI** (full agent workflow):
89
+ ```
90
+ bun src/tr-coder.js --source ./my-project
91
+ ```
92
+ - Chat: "Refactor this function in src/main.ts" → AI edits via `filesystem` + `javascript`.
93
+ - Command: `/commit` → Uses `git` to commit with AI message.
94
+ - Queue: `/queue add "Run tests"` → Batches via `queue` + `testing`.
95
+
96
+ 2. **Building the Monorepo**:
97
+ ```
98
+ bun run build # Compiles root + workspaces
99
+ bun run test # Runs Vitest across pkgs
100
+ ```
101
+
102
+ 3. **Custom REPL Integration** (in a script):
103
+ ```typescript
104
+ import { REPLService } from '@tokenring-ai/cli';
105
+ import AgentTeam from '@tokenring-ai/agent/AgentTeam';
106
+
107
+ const team = new AgentTeam(/* config */);
108
+ const repl = new REPLService(team);
109
+ await repl.run(); // Starts interactive CLI with agent selection
110
+ ```
111
+
112
+ ## Configuration Options
113
+
114
+ - **Root `package.json`**: Workspaces (`pkg/*`), scripts (e.g., `build:ts` for TSC, `biome` for linting), deps hoisted.
115
+ - **tsconfig.json**: ES2022 target, NodeNext resolution, strict TS, includes `src/**/*` + `types/`, excludes tests/dist/pkg tests.
116
+ - **biome.json**: Linting/formatting (tabs, double quotes), applies to `src/**/*.js` + `pkg/**/*.js` (excl. some inquirer pkgs).
117
+ - **Env Vars**: AI keys (e.g., `ANTHROPIC_API_KEY`), AWS creds, Serper API for search. Per-project: `.tokenring/coder-config.js` for plugins/tests.
118
+ - **Yarn/Bun Workspaces**: Hoists root deps; submodules for non-npm pkgs (e.g., inquirer forks).
119
+
120
+ ## Build/Development Workflow
121
+
122
+ 1. **Build**: `bun run build` (TSC on root + workspaces via `tsc -p tsconfig.tson` in pkgs).
123
+ 2. **Test**: `bun run test` (Vitest; per-pkg configs, coverage via `@vitest/coverage-v8`).
124
+ 3. **Lint/Format**: `bun run biome` (fixes via Biome); ESLint in some pkgs.
125
+ 4. **Typecheck**: `bun run typecheck` (TSC no-emit).
126
+ 5. **Contribute**:
127
+ - Add pkg: Create `pkg/new-pkg/` with `package.json` (name `@tokenring-ai/new-pkg`, exports `./index.ts`), add to root deps if needed.
128
+ - PR: Fork, update submodules, run `bun install`, build/test, submit to main.
129
+ - Hooks: Husky for pre-commit (Biome lint).
130
+
131
+ Known limitations: Early v0.1.0; submodules may need manual sync; binary deps (e.g., tree-sitter) require build tools.
132
+
133
+ ## API/Exports Overview
134
+
135
+ Root exports via bin `tr-coder` (CLI). Packages use `exports: { ".": "./index.ts", "./*": "./*.ts" }` for tree-shaking. Import scoped: `import { Tool } from '@tokenring-ai/agent/tools';`. Main root entry: `dist/tr-coder.js`. No direct root API; use packages or CLI.
136
+
137
+ ## Dependencies
138
+
139
+ - **Root Runtime**: `@inquirer/prompts` (CLI UI), all `@tokenring-ai/*` (internal, version 0.1.0).
140
+ - **Dev**: `@biomejs/biome` (lint), `vitest` (test), `husky` (hooks), `typescript` (in pkgs).
141
+ - **Hoisting**: Workspaces hoist common deps (e.g., `zod`, `execa`); submodules for custom (e.g., `@tokenring-ai/inquirer-command-prompt`).
142
+ - Update: `bun run update-all-dependencies-latest` (via submodules).
143
+
144
+ ## Contributing/Notes
145
+
146
+ - **Guidelines**: Follow TS strict, Biome rules. Add tests for new pkgs/tools. Document in pkg/ README.md. Reference `AGENTS.md` for architecture.
147
+ - **License**: MIT (see LICENSE).
148
+ - **Future Plans**: Full CI/CD, more integrations (e.g., GitHub), stable v1.0 with plugin marketplace.
149
+ - **Known Issues**: Submodule sync required pre-install; Docker needs env passthrough for keys. For pkg-specific docs, see individual READMEs (e.g., pkg/ai-client/README.md).
150
+
151
+ This monorepo powers AI-driven development; extend via packages for custom agents.
package/dist/tr-coder ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@tokenring-ai/coder",
3
+ "description": "TokenRing Coder Application",
4
+ "version": "0.1.5",
5
+ "dependencies": {
6
+ "@inquirer/prompts": "^7.8.3",
7
+ "@tokenring-ai/audio": "workspace:*",
8
+ "@tokenring-ai/agent": "workspace:*",
9
+ "@tokenring-ai/ai-client": "workspace:*",
10
+ "@tokenring-ai/aws": "workspace:*",
11
+ "@tokenring-ai/chrome": "workspace:*",
12
+ "@tokenring-ai/checkpoint": "workspace:*",
13
+ "@tokenring-ai/cli": "workspace:*",
14
+ "@tokenring-ai/code-watch": "workspace:*",
15
+ "@tokenring-ai/codebase": "workspace:*",
16
+ "@tokenring-ai/database": "workspace:*",
17
+ "@tokenring-ai/docker": "workspace:*",
18
+ "@tokenring-ai/feedback": "workspace:*",
19
+ "@tokenring-ai/file-index": "workspace:*",
20
+ "@tokenring-ai/filesystem": "workspace:*",
21
+ "@tokenring-ai/git": "workspace:*",
22
+ "@tokenring-ai/javascript": "workspace:*",
23
+ "@tokenring-ai/kubernetes": "workspace:*",
24
+ "@tokenring-ai/linux-audio": "workspace:*",
25
+ "@tokenring-ai/local-filesystem": "workspace:*",
26
+ "@tokenring-ai/mcp": "workspace:*",
27
+ "@tokenring-ai/memory": "workspace:*",
28
+ "@tokenring-ai/mysql": "workspace:*",
29
+ "@tokenring-ai/queue": "workspace:*",
30
+ "@tokenring-ai/s3": "workspace:*",
31
+ "@tokenring-ai/sandbox": "workspace:*",
32
+ "@tokenring-ai/scraperapi": "workspace:*",
33
+ "@tokenring-ai/scripting": "workspace:*",
34
+ "@tokenring-ai/serper": "workspace:*",
35
+ "@tokenring-ai/sqlite-storage": "workspace:*",
36
+ "@tokenring-ai/tasks": "workspace:*",
37
+ "@tokenring-ai/testing": "workspace:*",
38
+ "@tokenring-ai/websearch": "workspace:*",
39
+ "@biomejs/biome": "^2.2.0",
40
+ "husky": "^9.1.7",
41
+ "jsdom": "^26.1.0",
42
+ "node-gyp": "^11.3.0",
43
+ "trufflehog": "^0.0.5",
44
+ "ts": "^0.2.2",
45
+ "vitest": "^3.2.4"
46
+ },
47
+ "license": "MIT",
48
+ "bin": {
49
+ "tr-coder": "./dist/tr-coder"
50
+ },
51
+ "files": [
52
+ "dist",
53
+ "LICENSE",
54
+ "README.md"
55
+ ],
56
+ "scripts": {
57
+ "build": "bun build --compile --outfile=dist/tr-coder src/tr-coder.ts",
58
+ "prepublishOnly": "bun run build",
59
+ "coder": "bun src/tr-coder.js --source ./",
60
+ "test": "vitest run",
61
+ "prepare": "husky",
62
+ "biome": "biome format --fix",
63
+ "update-all-dependencies-latest": "git submodule foreach npx npm-check-updates -u",
64
+ "release:patch": "NEWVERSION=`bun pm version patch` && git add package.json && git commit -m \"Bump version to ${NEWVERSION}\" && git tag ${NEWVERSION} && git submodule foreach git push && git push && git push --tags"
65
+ },
66
+ "type": "module",
67
+ "workspaces": [
68
+ "pkg/*"
69
+ ]
70
+ }