smart_ide/docs/repo/service-agent-regex-search.md
Nicolas Cantu 3b3e1e67de docs: align regex-search with Cursor article; claw upstream submodule; SSO data ownership
- Add services/claw-harness-api/upstream → chinanpc/claude-code-rust (shallow)
- Document claw submodule and MIT Rust harness in service-claw-harness + feature doc
- agent-regex-search: map design principles to rg implementation vs indexed search
- SSO gateway: no user/project account storage; product DBs own identity context
2026-04-03 22:54:07 +02:00

42 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# agent-regex-search-api (`services/agent-regex-search-api/`)
API HTTP locale sur **`127.0.0.1`** pour la **recherche regex sur fichiers** via [ripgrep](https://github.com/BurntSushi/ripgrep) (`rg`). Elle matérialise côté `smart_ide` les **principes de conception** décrits pour les agents dans [Recherche regex rapide : indexer le texte pour les outils des agents](https://cursor.com/fr/blog/fast-regex-search) (outil regex dédié aux agents, plafonds de latence, périmètre de fichiers borné). Le **moteur indexé** du billet (trigrammes, sparse n-grams, fichiers `mmap`, etc.) nest **pas** recodé ici : limplémentation actuelle sappuie sur `rg`, comme la majorité des chaînes dagents ; une couche dindex open source (famille Zoekt / codesearch) reste une évolution possible pour les très gros arbres.
## Prérequis
`rg` dans le **`PATH`** (ex. `sudo apt install ripgrep` sur Debian/Ubuntu).
## Variables
| Variable | Obligatoire | Description |
|----------|-------------|-------------|
| `REGEX_SEARCH_TOKEN` | oui | `Authorization: Bearer <token>` (sauf `GET /health`). |
| `REGEX_SEARCH_ROOT` | non | Répertoire de base absolu (défaut typique `/home/ncantu/code` — à adapter). |
| `REGEX_SEARCH_HOST` | non | Bind (défaut `127.0.0.1`). |
| `REGEX_SEARCH_PORT` | non | Port (défaut `37143`). |
## Endpoints
- `GET /health`
- `POST /search` — JSON : `pattern`, `subpath` optionnel (relatif à `REGEX_SEARCH_ROOT`, pas de `..`), `maxMatches`, `timeoutMs`
Code sortie ripgrep `1` = aucun match → encore **200** avec `matches` vide si pas derreur.
## Risques
**ReDoS** : regex pathologiques jusquà `timeoutMs`. **`REGEX_SEARCH_ROOT`** : aligner avec la politique de lecture disque.
## Run
```bash
cd services/agent-regex-search-api
npm install
npm run build
export REGEX_SEARCH_TOKEN='…'
npm start
```
## Spécification
[API/agent-regex-search-api.md](../API/agent-regex-search-api.md), [features/agent-regex-search-api.md](../features/agent-regex-search-api.md).