tokless 0.0.0-stage → 0.4.1
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 +21 -0
- package/README.en.md +205 -0
- package/README.md +240 -2
- package/agents/tokless-coder.md +17 -0
- package/agents/tokless-reviewer.md +16 -0
- package/assets/logo.svg +15 -0
- package/bin/tokless.js +106 -0
- package/hooks.json +17 -0
- package/index.js +76 -0
- package/install.js +116 -0
- package/lib/audit.js +15 -0
- package/lib/read-guard.js +3 -0
- package/lib/skeleton.js +3 -0
- package/package.json +66 -4
- package/plugin.json +12 -0
- package/rules/AGENTS.md +20 -0
- package/scripts/read-guard-hook.js +266 -0
- package/skills/code-skeleton/SKILL.md +34 -0
- package/skills/token-audit/SKILL.md +38 -0
- package/targets/antigravity.js +150 -0
- package/targets/claude-code.js +245 -0
- package/targets/codex.js +100 -0
- package/targets/index.js +75 -0
- package/targets/shared.js +103 -0
- package/tools/agy-audit/cli.js +114 -0
- package/tools/agy-audit/lib/analyzer.js +864 -0
- package/tools/agy-audit/lib/compare.js +66 -0
- package/tools/agy-audit/lib/formatter.js +448 -0
- package/tools/agy-audit/lib/paths.js +437 -0
- package/tools/agy-audit/lib/project.js +497 -0
- package/tools/repo-skeleton/cli.js +109 -0
- package/tools/repo-skeleton/lib/skeleton.js +1511 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 agy-tokless contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
<p align="left">
|
|
2
|
+
<img src="./assets/logo.svg" width="60" height="60" alt="Tokless Logo" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# Tokless
|
|
6
|
+
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](./package.json)
|
|
9
|
+
[](./package.json)
|
|
10
|
+
|
|
11
|
+
[简体中文](./README.md) | English
|
|
12
|
+
|
|
13
|
+
**Zero-dependency token optimizer for AI coding agents (Google Antigravity, Claude Code, Codex CLI, and extensible via `targets/`).**
|
|
14
|
+
|
|
15
|
+
`tokless` cuts runaway prompt-cache snowballing without sacrificing code quality by combining sub-100ms `[Lstart-Lend]` AST-like code skeleton navigation, native `PreToolUse` blind-read brakes, MCP-stripped subagents, and 0-token local session billing/compaction audits.
|
|
16
|
+
|
|
17
|
+
In a controlled A/B bug-hunt and fix benchmark on a production Tauri + Rust + React desktop codebase, `tokless` reduced **total token throughput by 53.2% (-11.38M tokens)**, cut **cumulative Cache Read tokens by 53.8% (-11.23M tokens)**, and finished in **34.4% fewer model turns** while finding and fixing the exact same **7 deep concurrency/logic bugs** (*Note: this A/B benchmark was recorded on early `v0.1.0` with only the baseline skeletonizer and unsliced blind-read block; we have not yet re-run a full long-horizon comparison on newer releases, which add MCP-stripped lean subagents and refined line-range pass-through for even stronger theoretical savings*).
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Quick Install (Zero Dependencies · Node.js `>=18`)
|
|
22
|
+
|
|
23
|
+
### Option 1: One-Line CLI Setup (Recommended)
|
|
24
|
+
|
|
25
|
+
Auto-detects and installs into Google Antigravity, Claude Code (`~/.claude`), and Codex CLI (`~/.codex`). When invoked via `npx`, `tokless` automatically switches to file-copy mode so hooks never break after npm cache cleanup:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx tokless install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Target specific hosts or cleanly uninstall anytime:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx tokless install --target agy # Google Antigravity only
|
|
35
|
+
npx tokless install --target claude # Non-destructively merge into ~/.claude/settings.json + skills
|
|
36
|
+
npx tokless install --target codex # Install ~/.codex/skills/code-skeleton
|
|
37
|
+
npx tokless install --target all # Install across all supported hosts
|
|
38
|
+
npx tokless uninstall --target all # Cleanly remove hooks/skills and restore original settings
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Option 2: Paste One Prompt to Your AI Agent
|
|
42
|
+
|
|
43
|
+
Drop this directly into Antigravity or Claude Code and let the agent wire itself up:
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
Please run `npx tokless install` to enable tokless (or clone https://github.com/daoif/tokless and run `node install.js`), then verify that the read-guard hook and skills are active.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Why `@Codebase` or `repomix` Alone Isn't Enough
|
|
52
|
+
|
|
53
|
+
A common question from heavy AI coding users: *"My IDE already has `@Codebase` semantic search, or I use `repomix`. Why does my 5-hour / weekly quota still burn out so fast?"*
|
|
54
|
+
|
|
55
|
+
- **`@Codebase` is a search engine; `tokless` is a blind-read brake.** Semantic search tells the agent *which file* looks relevant, but it does not stop the agent from lazily calling `read_file` / `Read` without line numbers and dumping a 1,500-line file straight into context.
|
|
56
|
+
- **`repomix` is a full-repo packer for web chat.** Packing an entire repo is great for browser chat UIs without local file tools, but inside a multi-turn CLI/IDE agent loop it front-loads tens of thousands of tokens from turn 1.
|
|
57
|
+
- **The Cache Read Snowball:** In multi-step agent loops, `Cumulative Cache Read ≈ Average Context Size × Model Turns`. Dumping 30K tokens of irrelevant code on step 3 across a 50-turn task charges you 47 times—over **1.4M wasted Cache Read tokens** from a single lazy read.
|
|
58
|
+
- **Compaction Thresholds:** Generation-3 models commonly trigger forced context compaction around **256K tokens** (`CHECKPOINT: # Resuming from a compaction`, collapsing context into a lossy summary), while Generation-4 models have been observed running past 440K without compacting (widely estimated around **512K**). Regardless of where the ceiling sits, keeping per-turn context lean and cutting redundant turns directly determines how fast your quota drains.
|
|
59
|
+
|
|
60
|
+
`tokless` works alongside `@Codebase`: once the agent knows which directory or file to inspect, `tokless` generates `[Lstart-Lend]` function/class maps in ~80ms with zero pre-indexing, and its `PreToolUse` hook blocks un-sliced reads over 200 lines (returning the file's skeleton inline so the agent immediately re-reads the exact line range).
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Real-World Benchmark (Tauri + Rust + React Bug Hunt & Fix)
|
|
65
|
+
|
|
66
|
+
Two isolated Git worktrees from the same commit (`3908815`), running the exact same model (`Gemini 4 Hydrogen High`) and prompt:
|
|
67
|
+
|
|
68
|
+
| Metric | Baseline (Default Agent) | With `tokless` | Delta |
|
|
69
|
+
| :--- | :--- | :--- | :--- |
|
|
70
|
+
| **Total Tokens (`input + cache_read + output`)** | 21,410,381 | **10,029,592** | **-53.2% (-11.38M)** |
|
|
71
|
+
| **Cumulative Cache Read Tokens** | 20,858,589 | **9,627,700** | **-53.8% (-11.23M)** |
|
|
72
|
+
| **Cumulative Input Tokens** | 494,886 | **352,020** | **-28.9%** |
|
|
73
|
+
| **Model Invocations (Turns)** | 64 | **42** | **-34.4%** |
|
|
74
|
+
| **Total Execution Steps** | 220 | **150** | **-31.8%** |
|
|
75
|
+
| **`read_file` Calls (Full Blind Reads)** | 79 (3 blind reads) | **51 (0 blind reads)** | **-35.4%** |
|
|
76
|
+
| **Peak Context Watermark** | 439,830 tokens | **323,344 tokens** | **-26.5%** |
|
|
77
|
+
| **Time to First Code Edit** | 227s (Step 115) | **196s (Step 81)** | **31s faster / -34 steps** |
|
|
78
|
+
| **Real Bugs Found & Fixed (Build Verified)** | 7 | **7** | **Zero quality loss** |
|
|
79
|
+
|
|
80
|
+
> **Version Note (`v0.1.0` Baseline)**: The Tauri + Rust + React A/B figures above were captured on early `v0.1.0` (which only included baseline syntax skeleton extraction and unsliced blind-read blocking) and have not yet been re-run end-to-end on the latest release. With MCP-stripped lean roles (`inheritMcp: false`) and refined line-slice pass-through introduced in subsequent versions, current theoretical end-to-end token savings are even higher. Full reports: [benchmarks/real-world-bugfix-case.md](./benchmarks/real-world-bugfix-case.md) and [benchmarks/static-skeleton-benchmark.md](./benchmarks/static-skeleton-benchmark.md).
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Four Core Capabilities & Platform Boundaries (v0.4.1)
|
|
85
|
+
|
|
86
|
+
`tokless` draws a transparent line between **universal capabilities that work with every AI coding tool** and **host-specific hooks or log parsers**:
|
|
87
|
+
|
|
88
|
+
| Host Agent | 1. `tokless skeleton` + `AGENTS.md` Rules | 2. `PreToolUse` Blind-Read Guard | 3. Lean Subagents (`inheritMcp: false`) | 4. `tokless audit` Inspector |
|
|
89
|
+
| :--- | :---: | :---: | :---: | :---: |
|
|
90
|
+
| **Platform Scope** | **100% Universal across all AI coding tools** | **Extensible hook (Native on Antigravity & Claude Code)** | **Antigravity Plugin Only** | **`audit project` Universal; `session / compare` Antigravity Only** |
|
|
91
|
+
| **Google Antigravity** | Native Skill + CLI + `rules/AGENTS.md` | Native `hooks.json` (`read_file` / `view_file`) | `tokless-coder` / `tokless-reviewer` | Full (`project` + `session` / `compare`) |
|
|
92
|
+
| **Claude Code** | `~/.claude/skills` + CLI | Merged `~/.claude/settings.json` (`Read`) | — | `audit project` (rules & MCP tax) |
|
|
93
|
+
| **Codex CLI** | `~/.codex/skills` + CLI + `AGENTS.md` | — | — | `audit project` (rules density) |
|
|
94
|
+
| **Other Agents** (Cursor / Windsurf / Cline / Roo Code / Trae / OpenCode, etc.) | `npm i -g tokless` + root `AGENTS.md` (Ready Today) | PRs welcome via `targets/` (see `claude-code.js`) | — | `audit project` (rules density) |
|
|
95
|
+
|
|
96
|
+
### 1. `tokless skeleton` (alias `repo-skeleton`) + `rules/AGENTS.md` — [100% Universal]
|
|
97
|
+
|
|
98
|
+
Zero pre-indexing, pure Node.js standard library. Extracts class/function signatures and exact **`[Lstart-Lend]` line ranges** across `.js/.ts/.tsx/.py/.go/.rs/.java/.c/.cpp/.md` in milliseconds, cutting exploration tokens by **85%~97%** when paired with [`rules/AGENTS.md`](./rules/AGENTS.md):
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx tokless skeleton ./src --depth 2
|
|
102
|
+
npx tokless skeleton ./src/App.tsx --json
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 2. `PreToolUse` Blind-Read Brake (`scripts/read-guard-hook.js`) — [Extensible Hook · Native on Antigravity & Claude Code]
|
|
106
|
+
|
|
107
|
+
Only intercepts blind full-file reads (`> 200` lines, configurable via `TOKLESS_READ_MAX_LINES`) and fake `1..EOF` slices, returning the file's `[Lstart-Lend]` skeleton inline. Once explicit line numbers are supplied, any function span—whether 50 or 500 lines—is allowed in a single read so agents never burn extra turns reading fragments.
|
|
108
|
+
|
|
109
|
+
### 3. MCP-Stripped Lean Subagents (`agents/`) — [Antigravity Plugin Only]
|
|
110
|
+
|
|
111
|
+
Ships [`tokless-coder`](./agents/tokless-coder.md) and read-only [`tokless-reviewer`](./agents/tokless-reviewer.md) with `inheritMcp: false`, stripping unused external MCP schemas to eliminate thousands of idle base tokens on every coding/review turn.
|
|
112
|
+
|
|
113
|
+
### 4. `tokless audit` (alias `agy-audit`) — [`audit project` Universal · `session / compare` Antigravity Only]
|
|
114
|
+
|
|
115
|
+
Offline 0-LLM-token inspector for rule bloat, MCP schema overhead, and Antigravity session transcripts:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# [Universal] Audit AGENTS.md / SKILL.md bloat and workspace/global MCP schema base tax
|
|
119
|
+
npx tokless audit project <project-dir>
|
|
120
|
+
|
|
121
|
+
# [Antigravity Only] Dissect a session's Top 5 costliest steps, Prefix Cache cliffs, and compactions
|
|
122
|
+
npx tokless audit session <session-id-prefix>
|
|
123
|
+
|
|
124
|
+
# [Antigravity Only] Side-by-side A/B token bill comparison between two sessions
|
|
125
|
+
npx tokless audit compare <before-id> <after-id>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Where Each Target Installs & How to Use Day-to-Day
|
|
131
|
+
|
|
132
|
+
### 1. Built-in One-Command Targets (`npx tokless install`)
|
|
133
|
+
|
|
134
|
+
- **Google Antigravity** (`--target agy`):
|
|
135
|
+
- **Installed to**: `~/.gemini/config/plugins/agy-tokless/` (`plugin.json`, `hooks.json`, `rules/AGENTS.md`, `skills/`, `agents/`).
|
|
136
|
+
- **How it triggers**: Active automatically in new sessions—`PreToolUse` blocks blind reads on large files, `code-skeleton` guides ranged reads, `tokless-coder` / `tokless-reviewer` run without MCP tax, and `token-audit` / `npx tokless audit session <id>` inspects session bills.
|
|
137
|
+
- **Claude Code** (`--target claude`):
|
|
138
|
+
- **Installed to**: Core runtime in `~/.claude/tokless/`, skill in `~/.claude/skills/code-skeleton/SKILL.md`, and non-destructively merged `PreToolUse` (`Read`) hook in `~/.claude/settings.json` (preserves your existing permissions and custom hooks; cleanly restored on uninstall).
|
|
139
|
+
- **How it triggers**: Active automatically whenever you launch `claude`—un-sliced `Read` calls over 200 lines are intercepted with an inline `[Lstart-Lend]` map so Claude immediately re-reads the exact target lines.
|
|
140
|
+
- **Codex CLI** (`--target codex`):
|
|
141
|
+
- **Installed to**: `~/.codex/skills/code-skeleton/` (`SKILL.md` + bundled `tools/repo-skeleton`).
|
|
142
|
+
- **How it triggers**: Codex discovers the `code-skeleton` skill automatically; copy [`rules/AGENTS.md`](./rules/AGENTS.md) into your repo root `AGENTS.md` for consistent proactive triggering.
|
|
143
|
+
|
|
144
|
+
### 2. Using `tokless` with Cursor, Windsurf, Cline, Roo Code, Trae, OpenCode & Others
|
|
145
|
+
|
|
146
|
+
- **Use It Right Now (1-Minute Universal Setup)**:
|
|
147
|
+
1. Install the global CLI via `npm i -g tokless` (exposes `tokless skeleton` and `tokless audit project` globally);
|
|
148
|
+
2. Copy the lean-reading rules from [`rules/AGENTS.md`](./rules/AGENTS.md) into your repository's root `AGENTS.md` (or `.cursor/rules/`, `.windsurfrules`, `.clinerules`, etc.). Your agent can immediately run `tokless skeleton <path>` before reading large files, and you can run `tokless audit project .` anytime.
|
|
149
|
+
- **Honest Note on Native Auto-Installers & Community Co-Creation**:
|
|
150
|
+
Because maintainer bandwidth is currently focused on core accuracy, we haven't hand-wired global config paths and hook formats for a dozen different editors yet. **If you use another coding agent daily, you are warmly encouraged to ask your AI to build a target adapter modeled after [`targets/claude-code.js`](./targets/claude-code.js) and open a PR—we will review and publish it promptly, and we will also add more official built-in targets over time.**
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Programmatic Node.js API
|
|
155
|
+
|
|
156
|
+
`tokless` exports clean CommonJS modules (`tokless`, `tokless/skeleton`, `tokless/read-guard`, `tokless/audit`) for in-process agent harnesses and custom tooling with zero child-process overhead:
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
const {
|
|
160
|
+
generateSkeleton,
|
|
161
|
+
evaluateReadGuard,
|
|
162
|
+
analyzeSession,
|
|
163
|
+
auditProject,
|
|
164
|
+
} = require('tokless');
|
|
165
|
+
|
|
166
|
+
// Extract [Lstart-Lend] map for a file or directory
|
|
167
|
+
const skel = generateSkeleton('./src', { maxDepth: 2 });
|
|
168
|
+
console.log(skel.formatted);
|
|
169
|
+
|
|
170
|
+
// Evaluate Antigravity or Claude Code PreToolUse payloads in memory
|
|
171
|
+
const verdict = evaluateReadGuard({
|
|
172
|
+
tool_name: 'Read',
|
|
173
|
+
tool_input: { file_path: './src/large-module.ts' },
|
|
174
|
+
});
|
|
175
|
+
// => { decision: 'deny' | 'allow', reason?: string, host: 'claude' | 'antigravity' }
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Contributing New Agent Targets (`targets/`)
|
|
181
|
+
|
|
182
|
+
Host integrations live as self-contained adapters under [`targets/`](./targets/):
|
|
183
|
+
|
|
184
|
+
- [`targets/antigravity.js`](./targets/antigravity.js) — Google Antigravity plugin, hooks, and lean subagents
|
|
185
|
+
- [`targets/claude-code.js`](./targets/claude-code.js) — Claude Code `~/.claude/settings.json` non-destructive hook merge + skill (best reference template for new adapters)
|
|
186
|
+
- [`targets/codex.js`](./targets/codex.js) — OpenAI Codex CLI skill installer
|
|
187
|
+
|
|
188
|
+
Rather than guessing every editor's private config layout upfront, we prioritize clean community co-creation: if you use **Cursor, Windsurf, Cline, Roo Code, Trae, OpenCode, or GitHub Copilot**, point your AI at [`targets/claude-code.js`](./targets/claude-code.js), register the new adapter in [`targets/index.js`](./targets/index.js), and open a Pull Request (language parser additions under `tools/repo-skeleton` are welcome too). Verified PRs are merged and released right away, while official support for additional hosts will continue rolling out over time. Run the verification suite locally before submitting:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm test
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Acknowledgments
|
|
197
|
+
|
|
198
|
+
Built from scratch on the Node.js standard library. Special thanks to:
|
|
199
|
+
|
|
200
|
+
- **Contributors**: [@PXY000](https://github.com/PXY000) for cross-platform PowerShell skill templates, absolute Node binary resolution in hooks, path traversal guards, and regression tests.
|
|
201
|
+
- **Open-Source Inspiration**: [HoangP8/tokless](https://github.com/HoangP8/tokless), [ILoveMyJay/repocontext](https://github.com/ILoveMyJay/repocontext), [pdavis68/RepoMapper](https://github.com/pdavis68/RepoMapper), and [ooples/token-optimizer-mcp](https://github.com/ooples/token-optimizer-mcp).
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
[MIT](./LICENSE)
|
package/README.md
CHANGED
|
@@ -1,3 +1,241 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="left">
|
|
2
|
+
<img src="./assets/logo.svg" width="60" height="60" alt="Tokless Logo" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# Tokless
|
|
6
|
+
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](./package.json)
|
|
9
|
+
[](./package.json)
|
|
10
|
+
|
|
11
|
+
简体中文 | [English](./README.en.md)
|
|
12
|
+
|
|
13
|
+
> **核心初心:在不损失一行代码排查与修复质量的前提下,把 AI 编程工具里无意义的盲读膨胀与滚雪球 Token 消耗砍到最低。**
|
|
14
|
+
|
|
15
|
+
**面向主流 AI 编程 Agent(原生支持 Google Antigravity、Claude Code、Codex CLI,开放 `targets/` 插件架构扩展更多工具)的纯 Node.js 零依赖省流套件——毫秒级 `[L起-L止]` 语法骨架导航、原生 `PreToolUse` 防盲读硬刹车、剥离 MCP 空载税的净身角色与 0 Token 本地账单/缓存断层体检。**
|
|
16
|
+
|
|
17
|
+
在真实跨语言生产工程(Tauri + Rust + React)的严格 A/B 盲测中,启用 `tokless` 后单次任务减少 **34.4% 模型往返轮次**、砍掉 **53.2% 总 Token 吞吐(净省 1,138 万 Token)**、滚雪球 Cache Read 净省 **53.8%(少烧 1,123 万 Token)**,7 个真实深层 Bug 检出与修复质量零折损(*注:该组盲测数据完成于早期 `v0.1.0` 版本,当时仅含基础语法骨架与无行号盲读拦截,尚未针对后续新增净身角色与优化行号放行机制的新版本重跑完整长任务对照,当前版本理论综合省流表现更强*)。
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 一行命令极速启用(零界面 · 纯 Node.js `>=18` 零外部依赖)
|
|
22
|
+
|
|
23
|
+
### 方式一:终端一键挂载(推荐)
|
|
24
|
+
|
|
25
|
+
自动检测并挂载本机已安装的 Antigravity、Claude Code(`~/.claude`)与 Codex CLI(`~/.codex`),从 `npx` 临时目录运行时会自动切换为实体文件拷贝,杜绝缓存清理后软链悬空:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx tokless install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
按需指定单个或全部目标宿主 / 一键干净卸载:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx tokless install --target agy # 仅挂载 Google Antigravity
|
|
35
|
+
npx tokless install --target claude # 仅无损合并 Claude Code ~/.claude/settings.json 钩子与技能
|
|
36
|
+
npx tokless install --target codex # 仅安装 Codex CLI ~/.codex/skills/code-skeleton
|
|
37
|
+
npx tokless install --target all # 挂载全部已支持宿主
|
|
38
|
+
npx tokless uninstall --target all # 一键卸载并还原原有宿主配置
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 方式二:复制一句话直接交给你的 AI 编程助手
|
|
42
|
+
|
|
43
|
+
不想自己切终端,直接把下面这句话发给 Antigravity 或 Claude Code 对话框即可:
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
请运行 npx tokless install 帮我安装启用 tokless 省流套件(若网络受限可克隆 https://github.com/daoif/tokless 后运行 node install.js),装好后帮我确认钩子与技能已生效。
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 方式三:源码克隆本地安装(适合二次开发或离线环境)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git clone https://github.com/daoif/tokless.git
|
|
53
|
+
cd tokless
|
|
54
|
+
node install.js
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 为什么你的周额度掉得这么快?有了 `@Codebase` 或 `repomix` 为什么还是拦不住?
|
|
60
|
+
|
|
61
|
+
很多重度 AI 编程玩家都有同一个困惑:**“IDE 明明自带了 `@Codebase` 语义索引,我也试过 `repomix`,为什么跑几个复杂需求,5 小时窗口和周额度还是见底了?”**
|
|
62
|
+
|
|
63
|
+
通过对数十份底层会话账单日志(`transcript_full.jsonl`)的逐帧解剖,吃光额度的元凶非常清晰:
|
|
64
|
+
|
|
65
|
+
### 1. `@Codebase` 是找线索的「搜索引擎」,`tokless` 是防偷懒的「省流刹车系统」
|
|
66
|
+
|
|
67
|
+
| 工具类型 | 代表工具 | 核心职责 | 为什么单靠它省不了 Agent 循环里的额度? |
|
|
68
|
+
| :--- | :--- | :--- | :--- |
|
|
69
|
+
| **语义搜索引擎** | IDE 自带 `@Codebase` | 向量/关键词检索,帮 AI 找到“大概在哪个文件” | **只管找路,不管怎么读**。AI 拿到文件名后,下一步依然习惯性调用无行号的 `read_file` / `Read`,顺手把整份一两千行源码全量塞进上下文。 |
|
|
70
|
+
| **全仓打包器** | `repomix` / `gitingest` | 把整个仓库压成单文件喂给网页聊天框 | 适合无本地工具权限的网页问答;若塞进本地 Agent 会话,相当于第 1 步直接背上几万 Token 包袱。 |
|
|
71
|
+
| **省流导航与硬刹车** | **`tokless`** | **80ms 零索引出 `[L起-L止]` 骨架 + `PreToolUse` 硬拦盲读** | 当 AI 偷懒盲读 >200 行代码文件(或传 `1~文件末尾` 假切片)时,底层钩子当场拦截并直接甩回该文件的函数/类 `[L起-L止]` 行号骨架,逼它按行号精准切片读取。 |
|
|
72
|
+
|
|
73
|
+
`tokless` 与 `@Codebase` 完全不冲突,而是天然互补:`@Codebase` 负责回答“去哪几个文件找”,`tokless` 负责在读取那一刻踩住刹车,只让真正要改的那几十行代码进入上下文。
|
|
74
|
+
|
|
75
|
+
### 2. 「Cache Read 滚雪球效应」与上下文自动压缩水位
|
|
76
|
+
|
|
77
|
+
在多步 Agent 循环中,真正烧光额度的往往不是单次 `Input`,而是每一步反复重读历史上下文的 **`Cache Read`**:
|
|
78
|
+
|
|
79
|
+
$$\text{累计 Cache Read} \approx \text{平均上下文水位} \times \text{模型调用轮数}$$
|
|
80
|
+
|
|
81
|
+
- **早一步塞进废话,步步交复利税**:如果第 3 步盲读塞进 3 万 Token 无关代码,整个任务跑了 50 轮,这 3 万 Token 就会在后续每一步被重复计费 47 次,单这一步就白烧 **140 万+ Cache Read Token**。
|
|
82
|
+
- **远离隐式压缩失忆线**:在 Antigravity 等宿主中,三代模型常见在约 **256K** 上下文水位触发底层强制摘要压缩(`CHECKPOINT: # Resuming from a compaction`,将数十万上下文压成几千字摘要导致细节丢失与反复重读);四代模型实测跑上 440K 未触发压缩(社区普遍推测阈值约 **512K**)。但无论压缩上限在哪,**压低每步水位 + 减少探索轮数**都是同时保住代码记忆精度与周额度的核心解法。
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 真实工程 A/B 实测账单(Tauri + Rust + React 全仓找 Bug 与修复)
|
|
87
|
+
|
|
88
|
+
在同一个生产级桌面工程(Rust 后端 + TypeScript/React 前端)上,基于同一 Git Commit (`3908815`) 切出两个独立 Worktree,由同一模型(`Gemini 4 Hydrogen High`)执行完全相同的全仓深层 Bug 排查、修复与编译验证任务:
|
|
89
|
+
|
|
90
|
+
| 对比维度 | 对照组 (原生常规模式) | 实验组 (启用 `tokless`) | 真实节省 / 提升 |
|
|
91
|
+
| :--- | :--- | :--- | :--- |
|
|
92
|
+
| **总 Token 吞吐 (`input + cache_read + output`)** | 21,410,381 (2,141 万) | **10,029,592 (1,003 万)** | **净省 53.2% (-1,138 万 Tokens)** |
|
|
93
|
+
| **累计 Cache Read(滚雪球缓存消耗)** | 20,858,589 (2,086 万) | **9,627,700 (963 万)** | **净省 53.8% (-1,123 万 Tokens)** |
|
|
94
|
+
| **累计 Input Tokens(新增输入)** | 494,886 | **352,020** | **省 28.9%** |
|
|
95
|
+
| **模型调用轮数(Planner Invocations)** | 64 次 | **42 次** | **少跑 34.4% 轮次** |
|
|
96
|
+
| **总执行步数(Steps)** | 220 步 | **150 步** | **少走 31.8% 弯路** |
|
|
97
|
+
| **`read_file` 调用次数(全量盲读次数)** | 79 次(含 3 次全量盲读) | **51 次(0 次盲读)** | **文件读取减少 35.4%** |
|
|
98
|
+
| **峰值上下文水位(Peak Context)** | 439,830 Tokens | **323,344 Tokens** | **峰值降低 26.5%** |
|
|
99
|
+
| **定位首个 Bug 开始改代码耗时** | 227 秒(第 115 步) | **196 秒(第 81 步)** | **提速 31 秒 / 少花 34 步** |
|
|
100
|
+
| **检出并修复的真实硬核 Bug 数** | 7 个(全部编译通过) | **7 个(全部编译通过)** | **0 质量损耗(并发细节更深)** |
|
|
101
|
+
|
|
102
|
+
> **实测版本与模型说明**:
|
|
103
|
+
> 1. **测试版本背景(`v0.1.0` 基线)**:上表 A/B 盲测数据完成于早期的 `v0.1.0` 版本(当时仅包含基础语法骨架提取与无行号盲读拦截),目前尚未针对新版本重跑完整长任务对照;随着后续版本加入剥离外部 MCP 空载税的净身角色(`inheritMcp: false`)与优化后的行号切片放行机制,当前版本的理论综合省流表现更强。
|
|
104
|
+
> 2. **压缩阈值参考**:本轮实测基于四代模型,对照组峰值达 439,830 Tokens 未触发自动压缩(若换作 256K 阈值的三代模型早已触发强制压缩失忆)。完整逐项对比见 [benchmarks/real-world-bugfix-case.md](./benchmarks/real-world-bugfix-case.md) 与静态骨架基准测试 [benchmarks/static-skeleton-benchmark.md](./benchmarks/static-skeleton-benchmark.md)。
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 四大核心能力与全平台支持边界(v0.4.1)
|
|
109
|
+
|
|
110
|
+
`tokless` 把「跨所有 AI 编程工具通用的省流内核」与「特定客户端的深度钩子/日志解析」拆得清清楚楚,绝不混为一谈:
|
|
111
|
+
|
|
112
|
+
| 宿主工具 | 1. `tokless skeleton` 语法骨架 + `AGENTS.md` 规范 | 2. `PreToolUse` 防盲读硬刹车 | 3. 净身子角色 (`inheritMcp: false`) | 4. `tokless audit` 体检仪 |
|
|
113
|
+
| :--- | :---: | :---: | :---: | :---: |
|
|
114
|
+
| **能力通用边界** | **100% 所有 AI 编程工具通用** | **可扩展钩子机制(已打通 Antigravity / Claude Code)** | **Antigravity 插件专用** | **`audit project` 跨端通用;`session / compare` 属 Antigravity 专用** |
|
|
115
|
+
| **Google Antigravity** | 原生 Skill + CLI + `rules/AGENTS.md` | 原生 `hooks.json` (`read_file` / `view_file`) | `tokless-coder` / `tokless-reviewer` | 全功能支持(`project` + `session` / `compare`) |
|
|
116
|
+
| **Claude Code** | `~/.claude/skills` + CLI | 无损合并 `~/.claude/settings.json` (`Read`) | — | 支持 `audit project` 规则与 MCP 税体检 |
|
|
117
|
+
| **Codex CLI** | `~/.codex/skills` + CLI + `AGENTS.md` | — | — | 支持 `audit project` 规则体检 |
|
|
118
|
+
| **其他工具**(Cursor / Windsurf / Cline / Roo Code / Trae / OpenCode 等) | `npm i -g tokless` + 项目根 `AGENTS.md` 立即可用 | 欢迎参考 `targets/claude-code.js` 共创适配 PR | — | 支持 `audit project` 规则体检 |
|
|
119
|
+
|
|
120
|
+
### 1. `tokless skeleton`(兼容 `repo-skeleton`)+ `rules/AGENTS.md` 省流规范 —【100% 所有 AI 编程工具通用】
|
|
121
|
+
|
|
122
|
+
无需预建索引数据库,纯 Node.js 标准库毫秒级提取 `.js/.ts/.tsx/.py/.go/.rs/.java/.c/.cpp/.md` 等文件的类名、函数签名、接口与精确 **`[L起-L止]` 行号范围**,配合 [`rules/AGENTS.md`](./rules/AGENTS.md) 中的两步精准读取规范,探索期单文件省流 **85%~97%**:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# 扫描整个源码目录(自动排除 node_modules/.git/dist/target 等),一步生成全局行号地图
|
|
126
|
+
npx tokless skeleton ./src --depth 3
|
|
127
|
+
|
|
128
|
+
# 提取单个大文件的函数签名与 [L起-L止] 行号(支持 --json 输出结构化数据)
|
|
129
|
+
npx tokless skeleton ./src/App.tsx
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 2. `PreToolUse` 防盲读硬刹车(`scripts/read-guard-hook.js`)—【可扩展钩子机制,目前已原生打通 Google Antigravity 与 Claude Code】
|
|
133
|
+
|
|
134
|
+
精准防盲读,绝不设死板跨度锁死:当 AI 不传起止行号盲读超过 200 行(可通过环境变量 `TOKLESS_READ_MAX_LINES` 调整)的代码文件,或传入 `1~文件末尾` 假切片糊弄时,钩子自动拦截并当场返回该文件的 `[L起-L止]` 语法骨架;一旦拿到明确行号,无论目标函数是 50 行还是 500 行均一次完整放行,避免拆成多轮碎片读取倒贴 Cache Read。
|
|
135
|
+
|
|
136
|
+
### 3. 剥离外部 MCP 空载底座税的净身子角色(`agents/`)—【Antigravity 插件专用】
|
|
137
|
+
|
|
138
|
+
内置 [`tokless-coder`](./agents/tokless-coder.md) 与只读 [`tokless-reviewer`](./agents/tokless-reviewer.md),默认声明 `inheritMcp: false` 卸除纯写代码/审代码时用不上的外部 MCP Schema,消除每一步固定背负的数千至数万空载底座税。
|
|
139
|
+
|
|
140
|
+
### 4. `tokless audit`(兼容 `agy-audit`)体检仪 —【`audit project` 跨端通用;`audit session / compare` 属 Antigravity 专用】
|
|
141
|
+
|
|
142
|
+
直接离线解析本地项目规则配置与 Antigravity 会话日志,不花 1 个模型 Token:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# [跨端通用] 诊断项目的 AGENTS.md / SKILL.md 肥胖度与全局/工作区 MCP 空载底座税
|
|
146
|
+
npx tokless audit project <项目目录路径>
|
|
147
|
+
|
|
148
|
+
# [Antigravity 专用] 解剖单个会话(支持短 ID 前缀):查 Top 5 烧钱步骤、Prefix Cache 断层与压缩节点
|
|
149
|
+
npx tokless audit session <会话ID前缀>
|
|
150
|
+
|
|
151
|
+
# [Antigravity 专用] 优化前后两个会话的 A/B 量化账单对比
|
|
152
|
+
npx tokless audit compare <优化前ID> <优化后ID>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 各工具安装位置与日常使用方法
|
|
158
|
+
|
|
159
|
+
### 1. 已内置一键挂载的三大工具(运行 `npx tokless install` 后分别装到了哪里、怎么触发)
|
|
160
|
+
|
|
161
|
+
- **Google Antigravity**(`--target agy`):
|
|
162
|
+
- **安装位置**:`~/.gemini/config/plugins/agy-tokless/`(挂载 `plugin.json`、`hooks.json`、`rules/AGENTS.md`、`skills/` 与 `agents/`)。
|
|
163
|
+
- **日常触发**:装好后新开对话即自动生效——探索大文件时自动触发 `code-skeleton` 技能与 `PreToolUse` 防盲读拦截;派发纯编码或审查子任务时可指定 `tokless-coder` / `tokless-reviewer` 卸除 MCP 税;需要查账单时直接让 AI 调用 `token-audit` 技能或手动运行 `npx tokless audit session <ID>`。
|
|
164
|
+
- **Claude Code**(`--target claude`):
|
|
165
|
+
- **安装位置**:核心脚本存入 `~/.claude/tokless/`,技能写入 `~/.claude/skills/code-skeleton/SKILL.md`,并将 `Read` 防盲读钩子无损合并进 `~/.claude/settings.json`(保留你原有的权限与自定义钩子,卸载时精准剥离还原)。
|
|
166
|
+
- **日常触发**:在任意项目启动 `claude` 后自动生效——当 Claude 试图不带 `offset/limit` 盲读超过 200 行的代码文件时,`PreToolUse` 钩子会自动拦下并把 `[L起-L止]` 骨架直接喂回给它,引导它按行号精读。
|
|
167
|
+
- **Codex CLI**(`--target codex`):
|
|
168
|
+
- **安装位置**:`~/.codex/skills/code-skeleton/`(含 `SKILL.md` 与零依赖 `tools/repo-skeleton` 脚本)。
|
|
169
|
+
- **日常触发**:Codex 会自动发现并按需调用 `code-skeleton` 技能先看行号骨架再精读源码;建议同时将 [`rules/AGENTS.md`](./rules/AGENTS.md) 中的省流规范合入项目根目录的 `AGENTS.md` 以强化主动触发。
|
|
170
|
+
|
|
171
|
+
### 2. 其他 AI 编程工具(Cursor、Windsurf、Cline、Roo Code、Trae、OpenCode 等)怎么用?
|
|
172
|
+
|
|
173
|
+
- **当下立即可用法(1 分钟接入核心省流能力)**:
|
|
174
|
+
1. 在终端运行 `npm i -g tokless` 安装全局 CLI(获得全局 `tokless skeleton` 与 `tokless audit project` 命令);
|
|
175
|
+
2. 将仓库内 [`rules/AGENTS.md`](./rules/AGENTS.md) 的省流读取规范复制到你项目根目录的 `AGENTS.md`(或对应编辑器的 `.cursor/rules/`、`.windsurfrules`、`.clinerules` 等规则文件)中。配置完成后,你的 AI 助手就会在读大文件前主动调用 `tokless skeleton <路径>` 拿 `[L起-L止]` 行号地图并按需精读,也能随时用 `tokless audit project .` 检查规则体积。
|
|
176
|
+
- **关于官方一键挂载与共创适配的坦诚说明**:
|
|
177
|
+
由于作者近期精力有限,暂时还没法逐一去折腾十几个编辑器各自的专属全局目录与钩子格式。**如果你日常主力使用其他工具,非常欢迎直接让你的 AI 参考 [`targets/claude-code.js`](./targets/claude-code.js) 写一个对应的挂载适配并提交 PR——我们审核代码确认干净无误后会第一时间合并发版;后续作者空下来也会逐步跟进补充更多主流工具的官方一键支持。**
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Node.js 编程接口(Programmatic API)
|
|
182
|
+
|
|
183
|
+
`tokless` 同时导出零依赖标准 CommonJS 接口(支持 `tokless`、`tokless/skeleton`、`tokless/read-guard`、`tokless/audit` 子路径按需引入),方便其他 Agent 编排器或评测脚本在进程内直接调用,零子进程开销:
|
|
184
|
+
|
|
185
|
+
```js
|
|
186
|
+
const {
|
|
187
|
+
generateSkeleton, // 自动识别文件或目录生成 [L起-L止] 骨架
|
|
188
|
+
evaluateReadGuard, // 纯函数评估 Antigravity / Claude Code 读取请求是否盲读
|
|
189
|
+
analyzeSession, // 解析单次会话账单、缓存断层与峰值水位
|
|
190
|
+
auditProject, // 审计项目常驻规则体积与 MCP Schema 底座税
|
|
191
|
+
} = require('tokless');
|
|
192
|
+
|
|
193
|
+
// 1. 提取目录或单文件骨架
|
|
194
|
+
const skel = generateSkeleton('./src', { maxDepth: 2 });
|
|
195
|
+
console.log(skel.formatted);
|
|
196
|
+
|
|
197
|
+
// 2. 进程内调用防盲读判定(支持 Antigravity 与 Claude Code 载荷格式)
|
|
198
|
+
const verdict = evaluateReadGuard({
|
|
199
|
+
tool_name: 'Read',
|
|
200
|
+
tool_input: { file_path: './src/large-module.ts' },
|
|
201
|
+
});
|
|
202
|
+
// verdict => { decision: 'deny' | 'allow', reason?: string, host: 'claude' | 'antigravity' }
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 社区共建:欢迎扩展更多 AI 编程工具(Contributing)
|
|
208
|
+
|
|
209
|
+
`tokless` 将各宿主的安装与卸载逻辑完全解耦在 [`targets/`](./targets/) 目录下,每个宿主只需一个独立的百行级适配器文件:
|
|
210
|
+
|
|
211
|
+
- [`targets/antigravity.js`](./targets/antigravity.js) — Google Antigravity 插件、钩子与净身角色挂载
|
|
212
|
+
- [`targets/claude-code.js`](./targets/claude-code.js) — Claude Code `~/.claude/settings.json` 无损合并与技能挂载(推荐新增适配时优先参考)
|
|
213
|
+
- [`targets/codex.js`](./targets/codex.js) — OpenAI Codex CLI 技能挂载
|
|
214
|
+
|
|
215
|
+
因作者近期精力有限,暂未逐一折腾十几个编辑器的专属全局配置与钩子格式。非常欢迎使用 **Cursor、Windsurf、Cline、Roo Code、Trae、OpenCode、GitHub Copilot** 等工具的开发者,直接让自己的 AI 参考 [`targets/claude-code.js`](./targets/claude-code.js) 完成适配并在 [`targets/index.js`](./targets/index.js) 中注册后提交 Pull Request(或为 `tools/repo-skeleton` 补充更多语言的语法签名识别)——我们审核无误后会立即合并发版;后续作者空下来也会逐步补充更多工具的官方一键支持。
|
|
216
|
+
|
|
217
|
+
提交 PR 前请在本地运行全套自检(包含跨平台路径测试与 100% 零私人路径泄漏门禁):
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
npm test
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 开源致谢(Acknowledgments)
|
|
226
|
+
|
|
227
|
+
`tokless` 全部代码基于 Node.js 标准库从零独立实现,核心设计思路受益于以下优秀开源探索与社区贡献者,特此致谢:
|
|
228
|
+
|
|
229
|
+
- **社区贡献者**:感谢 [@PXY000](https://github.com/PXY000) 在跨平台 PowerShell 技能文档、钩子 Node 绝对路径解析、路径穿越防护与沙箱安全审计查找上的扎实修复与单测贡献。
|
|
230
|
+
- **灵感致敬**:
|
|
231
|
+
- [HoangP8/tokless](https://github.com/HoangP8/tokless):启发了项目命名及“指令规范 + 生命周期钩子”组合拦截上下文膨胀的思路;
|
|
232
|
+
- [ILoveMyJay/repocontext](https://github.com/ILoveMyJay/repocontext) 与 [pdavis68/RepoMapper](https://github.com/pdavis68/RepoMapper):启发了“先拿带行号的紧凑语法骨架地图,再按行号精准切片读取”的探索期降耗策略;
|
|
233
|
+
- [ooples/token-optimizer-mcp](https://github.com/ooples/token-optimizer-mcp):启发了针对工具返回体积与会话级 Token 账单做量化透视的思路。
|
|
234
|
+
|
|
235
|
+
如果 `tokless` 切实帮你省下了宝贵的周额度,欢迎在右上角点一颗 **Star** 支持,或关注作者技术手记公众号 **【织歌AI笔记】** 交流实战经验。
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
[MIT](./LICENSE)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tokless-coder
|
|
3
|
+
description: Lightweight coding execution agent with MCP servers stripped (inheritMcp: false) and core file/command tools only, saving per-step schema tokens during implementation and bug fixing.
|
|
4
|
+
mainAgent: true
|
|
5
|
+
subagent: true
|
|
6
|
+
inheritMcp: false
|
|
7
|
+
tools: [read_file, write_file, edit_file, run_command]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Tokless Fast Coding Agent
|
|
11
|
+
|
|
12
|
+
You are a lean, high-precision coding agent stripped of external MCP schema overhead (`inheritMcp: false`).
|
|
13
|
+
|
|
14
|
+
## Execution Rules
|
|
15
|
+
1. **Locate before reading**: Before reading unfamiliar code files larger than 200 lines, run `repo-skeleton` (or `~/.gemini/config/plugins/agy-tokless/tools/repo-skeleton/cli.js`) to inspect signatures and `[Lstart-Lend]` line numbers, then call `read_file` with `StartLine` and `EndLine`.
|
|
16
|
+
2. **Keep command output bounded**: Avoid dumping thousands of lines of build logs or directory trees into context; filter or cap output when running commands.
|
|
17
|
+
3. **Verify before reporting**: Run syntax checks, unit tests, or targeted verification commands to confirm your changes work cleanly before finishing.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tokless-reviewer
|
|
3
|
+
description: Read-only code review, verification, and audit agent (inheritMcp: false, read_file + run_command only) with zero write tools and zero MCP schema overhead.
|
|
4
|
+
mainAgent: true
|
|
5
|
+
subagent: true
|
|
6
|
+
inheritMcp: false
|
|
7
|
+
tools: [read_file, run_command]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Tokless Read-Only Verifier & Reviewer
|
|
11
|
+
|
|
12
|
+
You are an independent read-only verification and code review agent (`inheritMcp: false`, no file-editing tools).
|
|
13
|
+
|
|
14
|
+
## Execution Rules
|
|
15
|
+
1. **Never attempt to modify source files**: Inspect diffs, run read-only diagnostics or test suites via `run_command`, and read targeted code ranges via `read_file(Path, StartLine, EndLine)`.
|
|
16
|
+
2. **Evidence-based findings**: Cite exact file paths, line ranges, and command exit codes/outputs for every defect or risk reported.
|
package/assets/logo.svg
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 80" width="80" height="80" fill="none" role="img" aria-label="Tokless Logo">
|
|
2
|
+
<rect width="80" height="80" rx="18" fill="#18181B"/>
|
|
3
|
+
<rect x="0.75" y="0.75" width="78.5" height="78.5" rx="17.25" stroke="#F9F9F8" stroke-opacity="0.1" stroke-width="1.5"/>
|
|
4
|
+
<!-- Left & Right [ ] Code Line-Range Brackets -->
|
|
5
|
+
<path d="M24 20H18C16.8954 20 16 20.8954 16 22V58C16 59.1046 16.8954 60 18 60H24" stroke="#F9F9F8" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6
|
+
<path d="M56 20H62C63.1046 20 64 20.8954 64 22V58C64 59.1046 63.1046 60 62 60H56" stroke="#F9F9F8" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7
|
+
<!-- Dimmed Trimmed Noise Lines (Top & Bottom) -->
|
|
8
|
+
<line x1="27" y1="27" x2="50" y2="27" stroke="#F9F9F8" stroke-opacity="0.22" stroke-width="2.6" stroke-linecap="round"/>
|
|
9
|
+
<line x1="31" y1="33.5" x2="45" y2="33.5" stroke="#F9F9F8" stroke-opacity="0.16" stroke-width="2.4" stroke-linecap="round"/>
|
|
10
|
+
<line x1="31" y1="46.5" x2="47" y2="46.5" stroke="#F9F9F8" stroke-opacity="0.16" stroke-width="2.4" stroke-linecap="round"/>
|
|
11
|
+
<line x1="27" y1="53" x2="43" y2="53" stroke="#F9F9F8" stroke-opacity="0.22" stroke-width="2.6" stroke-linecap="round"/>
|
|
12
|
+
<!-- Highlighted Focused Target Code Slice -->
|
|
13
|
+
<circle cx="27.5" cy="40" r="2.2" fill="#10B981"/>
|
|
14
|
+
<line x1="34" y1="40" x2="53" y2="40" stroke="#10B981" stroke-width="3.6" stroke-linecap="round"/>
|
|
15
|
+
</svg>
|
package/bin/tokless.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { spawnSync } = require('child_process');
|
|
6
|
+
const pkg = require('../package.json');
|
|
7
|
+
const { parseCliArgs, runInstall, runUninstall } = require('../install');
|
|
8
|
+
|
|
9
|
+
const REPO_ROOT = path.resolve(__dirname, '..');
|
|
10
|
+
|
|
11
|
+
function printHelp() {
|
|
12
|
+
console.log(`tokless v${pkg.version} - AST codebase skeletonizer, blind-read guard & session token auditor
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
tokless install [--target agy|claude|codex|all] [--copy]
|
|
16
|
+
tokless uninstall [--target agy|claude|codex|all]
|
|
17
|
+
tokless skeleton <file-or-dir> [--depth <N>] [--json]
|
|
18
|
+
tokless audit <session|compare|project> [args...] [--json]
|
|
19
|
+
tokless --version | -v
|
|
20
|
+
tokless --help | -h
|
|
21
|
+
|
|
22
|
+
Targets:
|
|
23
|
+
agy Antigravity (~/.gemini/config/plugins/agy-tokless)
|
|
24
|
+
claude Claude Code (~/.claude/tokless + skills + settings.json PreToolUse Read hook)
|
|
25
|
+
codex Codex CLI (~/.codex/skills/code-skeleton)
|
|
26
|
+
all Install/uninstall across all supported targets
|
|
27
|
+
(omit) Auto-install Antigravity + any detected ~/.claude or ~/.codex host`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function forwardSubtool(relScriptPath, subArgs) {
|
|
31
|
+
const scriptPath = path.join(REPO_ROOT, relScriptPath);
|
|
32
|
+
const res = spawnSync(process.execPath, [scriptPath, ...subArgs], {
|
|
33
|
+
stdio: 'inherit',
|
|
34
|
+
env: process.env,
|
|
35
|
+
});
|
|
36
|
+
process.exit(res.status !== null ? res.status : 1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function main() {
|
|
40
|
+
const argv = process.argv.slice(2);
|
|
41
|
+
if (argv.length === 0 || argv[0] === '--help' || argv[0] === '-h' || argv[0] === 'help') {
|
|
42
|
+
printHelp();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (argv[0] === '--version' || argv[0] === '-v' || argv[0] === 'version') {
|
|
47
|
+
console.log(pkg.version);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const subcmd = argv[0];
|
|
52
|
+
const rest = argv.slice(1);
|
|
53
|
+
|
|
54
|
+
if (subcmd === 'install') {
|
|
55
|
+
const parsed = parseCliArgs(rest);
|
|
56
|
+
if (parsed.help) {
|
|
57
|
+
printHelp();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
runInstall({
|
|
62
|
+
sourceDir: REPO_ROOT,
|
|
63
|
+
target: parsed.target,
|
|
64
|
+
copy: parsed.copy,
|
|
65
|
+
mode: 'auto',
|
|
66
|
+
});
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.error(`[tokless] ${err.message}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (subcmd === 'uninstall') {
|
|
75
|
+
const parsed = parseCliArgs(rest);
|
|
76
|
+
if (parsed.help) {
|
|
77
|
+
printHelp();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
runUninstall({
|
|
82
|
+
target: parsed.target || 'all',
|
|
83
|
+
mode: 'auto',
|
|
84
|
+
});
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.error(`[tokless] ${err.message}`);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (subcmd === 'skeleton' || subcmd === 'skel') {
|
|
93
|
+
forwardSubtool('tools/repo-skeleton/cli.js', rest);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (subcmd === 'audit') {
|
|
98
|
+
forwardSubtool('tools/agy-audit/cli.js', rest);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
console.error(`[tokless] Unknown command: "${subcmd}". Run "tokless --help" for usage.`);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
main();
|