docs: restructure README, move detailed content to docs/ directory
This commit is contained in:
36
docs/COMMANDS.md
Normal file
36
docs/COMMANDS.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Slash Commands
|
||||||
|
|
||||||
|
AnchorCli provides several slash commands for managing your session and interacting with the AI.
|
||||||
|
|
||||||
|
## Available Commands
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
|---------|-------------|
|
||||||
|
| `/setup` | Run interactive TUI to configure API key and model (also accessible via `anchor setup` subcommand) |
|
||||||
|
| `/help` | Show available tools and commands |
|
||||||
|
| `/exit` | Exit the application |
|
||||||
|
| `/clear` | Clear the conversation history |
|
||||||
|
| `/status` | Show session token usage and cost |
|
||||||
|
| `/compact` | Manually trigger context compaction |
|
||||||
|
| `/reset` | Clear session and reset token tracker |
|
||||||
|
| `/load` | Load a previous session from disk |
|
||||||
|
| `/save` | Save current session to disk |
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Type any command starting with `/` in the REPL to execute it:
|
||||||
|
|
||||||
|
```
|
||||||
|
> /status
|
||||||
|
Session: 1,234 tokens used ($0.0015)
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
> /help
|
||||||
|
Available tools: read_file, grep_file, replace_lines, ...
|
||||||
|
Available commands: /setup, /help, /exit, /clear, ...
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Back to [README.md](../README.md)*
|
||||||
55
docs/HASHLINE.md
Normal file
55
docs/HASHLINE.md
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# The Hashline Technique
|
||||||
|
|
||||||
|
Hashline is AnchorCli's unique approach to safe, precise file editing.
|
||||||
|
|
||||||
|
## How It Works
|
||||||
|
|
||||||
|
Every line returned by file tools is prefixed with a content-derived hash anchor:
|
||||||
|
|
||||||
|
```
|
||||||
|
function hello() {
|
||||||
|
return "world";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The format is `lineNumber:hash|content` where:
|
||||||
|
- `lineNumber` is the current line number in the file
|
||||||
|
- `hash` is an Adler-8 checksum derived from the line content and position
|
||||||
|
- `content` is the actual line text
|
||||||
|
|
||||||
|
## Editing with Anchors
|
||||||
|
|
||||||
|
When editing, you reference these `line:hash` anchors instead of reproducing old content. Before any mutation, both the line number **and** hash are validated — stale anchors are rejected immediately.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
To replace lines 2-3 from the example above:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"tool": "replace_lines",
|
||||||
|
"path": "example.js",
|
||||||
|
"startAnchor": "2:f1",
|
||||||
|
"endAnchor": "3:0e",
|
||||||
|
"newLines": [" return \"hello world\";"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Benefits
|
||||||
|
|
||||||
|
This eliminates:
|
||||||
|
|
||||||
|
- **Whitespace/indentation reproduction errors** — No need to match exact spacing
|
||||||
|
- **Silent edits to the wrong line** — Hash validation ensures you're editing the right content
|
||||||
|
- **Entire-file rewrites** — Change just one line without touching the rest
|
||||||
|
- **Line drift in batch operations** — BatchEdit validates all anchors upfront and applies changes bottom-to-top
|
||||||
|
|
||||||
|
## Key Principles
|
||||||
|
|
||||||
|
1. **Never include anchors in your content** — When using `replace_lines`, `insert_after`, or similar tools, the `newLines` parameter should contain raw source code only, WITHOUT the `lineNumber:hash|` prefix
|
||||||
|
2. **Always validate before editing** — Re-read files to get fresh anchors if your previous anchors fail validation
|
||||||
|
3. **Use BatchEdit for multiple changes** — This validates all anchors upfront and applies operations atomically
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Back to [README.md](../README.md)* | *See [TOOLS.md](TOOLS.md) for all available tools*
|
||||||
53
docs/TOOLS.md
Normal file
53
docs/TOOLS.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Available Tools
|
||||||
|
|
||||||
|
AnchorCli provides a comprehensive set of tools for file operations, editing, directory management, and command execution.
|
||||||
|
|
||||||
|
## File Operations
|
||||||
|
|
||||||
|
| Tool | Description |
|
||||||
|
|------|-------------|
|
||||||
|
| `read_file` | Read a file (or a window) with Hashline-tagged lines |
|
||||||
|
| `grep_file` | Search a file by regex — results are pre-tagged for immediate editing |
|
||||||
|
| `grep_recursive` | Search for a regex pattern across all files in a directory tree |
|
||||||
|
| `find_files` | Search for files matching glob patterns |
|
||||||
|
| `get_file_info` | Get detailed file information (size, permissions, etc.) |
|
||||||
|
|
||||||
|
## Edit Operations
|
||||||
|
|
||||||
|
| Tool | Description |
|
||||||
|
|------|-------------|
|
||||||
|
| `replace_lines` | Replace a range identified by `line:hash` anchors |
|
||||||
|
| `insert_after` | Insert lines after an anchor |
|
||||||
|
| `delete_range` | Delete a range between two anchors |
|
||||||
|
| `create_file` | Create a new file with optional initial content |
|
||||||
|
| `delete_file` | Delete a file permanently |
|
||||||
|
| `rename_file` | Rename or move a file |
|
||||||
|
| `copy_file` | Copy a file to a new location |
|
||||||
|
| `append_to_file` | Append lines to the end of a file |
|
||||||
|
| `batch_edit` | Apply multiple replace/delete operations atomically in a single call |
|
||||||
|
|
||||||
|
## Directory Operations
|
||||||
|
|
||||||
|
| Tool | Description |
|
||||||
|
|------|-------------|
|
||||||
|
| `list_dir` | List directory contents |
|
||||||
|
| `create_dir` | Create a new directory (with parent directories) |
|
||||||
|
| `rename_dir` | Rename or move a directory |
|
||||||
|
| `delete_dir` | Delete a directory and all its contents |
|
||||||
|
|
||||||
|
## Command Execution
|
||||||
|
|
||||||
|
| Tool | Description |
|
||||||
|
|------|-------------|
|
||||||
|
| `execute_command` | Run shell commands (with user approval) |
|
||||||
|
|
||||||
|
## Tool Usage Guidelines
|
||||||
|
|
||||||
|
- All file editing tools use **Hashline anchors** (`line:hash`) for precise, safe edits
|
||||||
|
- Before any mutation, both the line number **and** hash are validated — stale anchors are rejected
|
||||||
|
- `batch_edit` is preferred for multiple operations to prevent line drift
|
||||||
|
- `grep_file` results are pre-tagged with anchors for immediate editing
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*For more details on the Hashline technique, see [HASHLINE.md](HASHLINE.md)*
|
||||||
Reference in New Issue
Block a user