← Back to Plugins
Tools

Little Coder

Uknak By Uknak 👁 19 views ▲ 0 votes

Little Coder extensions as native OpenClaw plugin

GitHub

Configuration Example

{
  "plugins": {
    "entries": {
      "little-coder": {
        "enabled": true,
        "config": {
          "qualityMonitorEnabled": true,
          "correctionMax": 2,
          "turnCapEnabled": false,
          "turnMax": 50,
          "writeGuardEnabled": true,
          "skillInjectionEnabled": true,
          "skillTokenBudget": 150,
          "skillsDir": "~/.openclaw/workspace/skills/tools"
        },
        "hooks": {
          "allowConversationAccess": true
        }
      }
    },
    "allow": ["little-coder"]
  }
}

README

# Little Coder โ€” OpenClaw Plugin

Port of Little Coder extensions (Evidence, ShellSession, Write Guard, Skill Injection) as a native OpenClaw plugin.

[![Build](https://github.com/openclaw/little-coder/actions/workflows/build.yml/badge.svg)](https://github.com/openclaw/little-coder/actions/workflows/build.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

## Features

### Tools (6)

| Tool | Description |
|------|-------------|
| `EvidenceAdd` | Add a citable piece of evidence/fact to the knowledge base |
| `EvidenceGet` | Retrieve evidence by ID |
| `EvidenceList` | List all stored evidence |
| `ShellSession` | Execute a command in a persistent shell session |
| `ShellCwd` | Get or set the current working directory of the shell session |
| `ShellReset` | Reset all persistent shell sessions |

### Hooks (5)

| Hook | Priority | Purpose |
|------|----------|---------|
| `before_tool_call` | 200 | Turn cap enforcement |
| `before_tool_call` | 100 | Tool tracking + WriteGuard |
| `after_tool_call` | 50 | Track tool usage for skill injection |
| `agent_end` | 10 | Quality monitoring (convergence detection) |
| `before_prompt_build` | 1 | Skill/context injection |

## Installation

### 1. Clone the plugin

```bash
git clone https://github.com/openclaw/little-coder.git
cd little-coder
```

### 2. Install dependencies

```bash
npm ci
```

### 3. Build

```bash
npm run build
```

### 4. Deploy to OpenClaw

Copy the built plugin to your OpenClaw extensions directory:

```bash
cp dist/index.js ~/.openclaw/extensions/little-coder/index.js
```

### 5. Configure OpenClaw

Add the plugin entry to `~/.openclaw/openclaw.json`:

```json
{
  "plugins": {
    "entries": {
      "little-coder": {
        "enabled": true,
        "config": {
          "qualityMonitorEnabled": true,
          "correctionMax": 2,
          "turnCapEnabled": false,
          "turnMax": 50,
          "writeGuardEnabled": true,
          "skillInjectionEnabled": true,
          "skillTokenBudget": 150,
          "skillsDir": "~/.openclaw/workspace/skills/tools"
        },
        "hooks": {
          "allowConversationAccess": true
        }
      }
    },
    "allow": ["little-coder"]
  }
}
```

Restart the Gateway after adding the plugin.

## Configuration

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `qualityMonitorEnabled` | `boolean` | `true` | Enable convergence detection and auto-correction |
| `correctionMax` | `integer` | `2` | Maximum quality corrections per session |
| `turnCapEnabled` | `boolean` | `false` | Enable turn count limit |
| `turnMax` | `integer` | `50` | Maximum turns per agent run |
| `writeGuardEnabled` | `boolean` | `true` | Enable path normalization for Write tool |
| `skillInjectionEnabled` | `boolean` | `true` | Enable skill card injection |
| `skillTokenBudget` | `integer` | `150` | Token budget for skill content injection |
| `skillsDir` | `string` | `~/.openclaw/workspace/skills/tools` | Directory for skill Markdown files |

## Usage Examples

### Evidence tools

```typescript
// Add evidence
api.call("EvidenceAdd", {
  content: "The quick brown fox jumps over the lazy dog",
  source: "wikipedia.org/article"
});

// Get specific evidence
api.call("EvidenceGet", { id: "ev_1234567890_0" });

// List all evidence
api.call("EvidenceList");
```

### Shell session

```typescript
// Execute a command
api.call("ShellSession", {
  command: "ls -la /home",
  cwd: "/home"
});

// Change working directory
api.call("ShellCwd", { path: "/tmp" });

// Reset all shell sessions
api.call("ShellReset");
```

## Architecture

### Module organization

```
little-coder/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.ts          # Plugin entry point
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ”œโ”€โ”€ quality-monitor.ts  # Convergence detection & correction
โ”‚   โ”‚   โ”œโ”€โ”€ skill-inject.ts     # Skill card injection
โ”‚   โ”‚   โ”œโ”€โ”€ turn-cap.ts        # Turn count limiting
โ”‚   โ”‚   โ””โ”€โ”€ write-guard.ts     # Path normalization
โ”‚   โ””โ”€โ”€ tools/
โ”‚       โ”œโ”€โ”€ evidence.ts     # Evidence knowledge base tools
โ”‚       โ””โ”€โ”€ shell.ts        # Persistent shell tools
โ”œโ”€โ”€ dist/
โ”‚   โ””โ”€โ”€ index.js            # Single-file bundle (compiled)
โ”œโ”€โ”€ .github/workflows/
โ”‚   โ””โ”€โ”€ build.yml           # CI: npm build + lint
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ””โ”€โ”€ README.md
```

### API patterns

**Hooks** use `api.on(name, handler, opts)`:

```typescript
api.on(
  "before_tool_call",
  async (event) => {
    const ctx = event.context || {};
    // inspect ctx.toolName, ctx.params
  },
  { priority: 100 }
);
```

**Tools** use `api.registerTool({ name, label, description, parameters, execute })`:

```typescript
api.registerTool({
  name: "MyTool",
  label: "MyTool",
  description: "Does something",
  parameters: Type.Object({ /* schema */ }),
  execute: async (toolCallId, params, signal, onUpdate) => {
    return { ok: true, result: "done" };
  }
});
```

### OpenClaw internals

This plugin extends OpenClaw's internal plugin API:

- **Plugin SDK**: `openclaw/plugin-sdk/plugin-entry`
- **Tool types**: `typebox` for schema validation
- **Hook system**: Internal `api.on()` for lifecycle hooks
- **Session API**: `api.session.workflow.enqueueNextTurnInjection()` for quality corrections

## License

MIT
tools

Comments

Sign in to leave a comment

Loading comments...