# @leojlin/pi-frizbee-autocomplete

Fast fuzzy word and path autocomplete for [Pi](https://pi.dev), learned from the active conversation.

As you type, the extension suggests words and existing filesystem paths seen in user messages, assistant messages, and tool results. The native backend also indexes `/usr/share/dict/words` when available.

## Install

```bash
pi install npm:@leojlin/pi-frizbee-autocomplete
```

Run `/reload` or restart Pi after installation.

## Usage

Type at least two characters of a word. Suggestions appear in Pi's normal autocomplete popup.

- `Tab` and `Shift+Tab` cycle word suggestions.
- Pi's slash-command, `@` file, `#`, and path completion keep their built-in behavior.
- Pressing Enter while slash-command completion is visible inserts the selected command instead of immediately submitting it, so you can add arguments.

Candidate matching is case-insensitive and deduplicated. Suggestions show their source, such as `session:user`, `session:assistant`, `session:path`, or `dictionary`.

## Backends

The package includes the native [Frizbee](https://crates.io/crates/frizbee) backend for macOS ARM64. Other platforms automatically use a dependency-free JavaScript fuzzy matcher, so installation never requires Rust.

To build the native backend for your current platform:

```bash
npm install
npm run build:native
```

This requires a Rust toolchain. The generated N-API module is written to:

```text
native-build/<platform>-<architecture>/frizbee_autocomplete.node
```

Restart Pi after building it.

## Privacy

All indexing and matching happen locally. The extension makes no network requests and does not send autocomplete content to a model.

The in-memory index lasts only for the current Pi process. It is not written to disk.

## Development

```bash
npm install
npm run check
npm test
pi -e ./index.ts
```

## Limitations

- Interactive TUI mode only; it replaces Pi's editor component.
- It does not recursively scan your project. Filesystem paths must appear in conversation content before they are indexed.
- It uses a small compatibility shim around Pi's editor internals to trigger word completion while typing. A future Pi editor API change may require an update.

## License

MIT
