smart_ide/docs/repo/ia-dev-repository-overview.md
Nicolas Cantu 58cc2493e5 chore: consolidate ia_dev module, sync tooling, and harden gateways (0.0.5)
Initial state:
- ia_dev was historically referenced as ./ia_dev in docs and integrations, while the vendored module lives under services/ia_dev.
- AnythingLLM sync and hook installation had error masking / weak exit signaling.
- Proxy layers did not validate proxy path segments, allowing path normalization tricks.

Motivation:
- Make the IDE-oriented workflow usable (sync -> act -> deploy/preview) with explicit errors.
- Reduce security footguns in proxying and script automation.

Resolution:
- Standardize IA_DEV_ROOT usage and documentation to services/ia_dev.
- Add SSH remote data mirroring + optional AnythingLLM ingestion.
- Extend AnythingLLM pull sync to support upload-all/prefix and fail on upload errors.
- Harden smart-ide-sso-gateway and smart-ide-global-api proxying with safe-path checks and non-leaking error responses.
- Improve ia-dev-gateway runner validation and reduce sensitive path leakage.
- Add site scaffold tool (Vite/React) with OIDC + chat via sso-gateway -> orchestrator.

Root cause:
- Historical layout changes (submodule -> vendored tree) and missing central contracts for path resolution.
- Missing validation for proxy path traversal patterns.
- Overuse of silent fallbacks (|| true, exit 0 on partial failures) in automation scripts.

Impacted features:
- Project sync: git pull + AnythingLLM sync + remote data mirror ingestion.
- Site frontends: SSO gateway proxy and orchestrator intents (rag.query, chat.local).
- Agent execution: ia-dev-gateway script runner and SSE output.

Code modified:
- scripts/remote-data-ssh-sync.sh
- scripts/anythingllm-pull-sync/sync.mjs
- scripts/install-anythingllm-post-merge-hook.sh
- cron/git-pull-project-clones.sh
- services/smart-ide-sso-gateway/src/server.ts
- services/smart-ide-global-api/src/server.ts
- services/smart-ide-orchestrator/src/server.ts
- services/ia-dev-gateway/src/server.ts
- services/ia_dev/tools/site-generate.sh

Documentation modified:
- docs/** (architecture, API docs, ia_dev module + integration, scripts)

Configurations modified:
- config/services.local.env.example
- services/*/.env.example

Files in deploy modified:
- services/ia_dev/deploy/*

Files in logs impacted:
- logs/ia_dev.log (runtime only)
- .logs/* (runtime only)

Databases and other sources modified:
- None

Off-project modifications:
- None

Files in .smartIde modified:
- .smartIde/agents/*.md
- services/ia_dev/.smartIde/**

Files in .secrets modified:
- None

New patch version in VERSION:
- 0.0.5

CHANGELOG.md updated:
- yes
2026-04-04 18:36:43 +02:00

53 lines
4.7 KiB
Markdown

# ia_dev — dépôt de pilotage (agents, deploy, ticketing)
Dépôt de pilotage par l'IA pour les projets : **équipe d'agents IA** dont le code et les définitions sont dans ia_dev, lancés de façon centralisée pour tous les projets configurés (lecoffreio, enso, algo, etc.) ; ils agissent sur ces projets, pas sur ia_dev. Objectif : une équipe autonome couvrant la **documentation**, le **code** (correctifs, évolutions), le **ticketing** (issues Gitea, mails), le **devops** (push, déploiement, branches), la **sécurité** et la **qualité** (lint, règles).
**Principe** : ia_dev est un **dépôt autonome** (usage unique : standalone). La config par projet est dans `projects/<id>/conf.json` ; l'id projet est résolu par **MAIL_TO** (adresse « to » des mails) ou **AI_AGENT_TOKEN** (token des requêtes). Schéma détaillé : [ia-dev-project-conf-schema.md](./ia-dev-project-conf-schema.md).
## Usage (standalone)
- **Racine d'exécution** : tous les scripts sont lancés depuis la **racine `IA_DEV_ROOT`**. L'id projet est résolu par **MAIL_TO**, **AI_AGENT_TOKEN**, **`IA_PROJECT_ID`**, **`--project`**, ou premier argument selon le script (voir [ia-dev-project-conf-schema.md](./ia-dev-project-conf-schema.md)).
- **Config** : dans `projects/<id>/conf.json`, les chemins vers les dépôts projet peuvent être **absolus** ou **relatifs à la racine du monorepo smart_ide** lorsque ia_dev y est intégré (`lib/conf_path_resolve.sh`). Les champs `mail.imap_bridge_env` et `git.token_file` sont **relatifs à `IA_DEV_ROOT`**. Le répertoire `.secrets` à la racine de `IA_DEV_ROOT` contient `token` et `git-issues/agent-loop.env`, `git-issues/imap-bridge.env`.
## Agents et domaines
Les **agents** ont leur **code et définitions** dans ia_dev (`.smartIde/agents/`, `.smartIde/rules/`) et sont **lancés de façon centralisée** depuis ce dépôt pour **tous les projets**. Ils sont **dédiés aux projets configurés** : ils agissent sur ces projets (doc, code, déploiement, ticketing), pas sur ia_dev.
Chaque agent indique où se trouve la doc : **projets gérés**`projects/<id>/docs` ; **ia_dev**`IA_DEV_ROOT/projects/ia_dev/docs` (copie embarquée selon checkout).
| Domaine | Agents / composants |
|---------|---------------------|
| **Doc** | `docupdate` ; `IA_DEV_ROOT/projects/ia_dev/docs/` ; migration wiki (`git-issues/wiki-migrate-docs.sh`). |
| **Code** | `fix`, `evol`, `code`, `fix-search` ; workflow correctifs/évolutions. |
| **Ticketing** | `git-issues-process`, `agent-loop` ; spooler `projects/<id>/data/issues` ; scripts `git-issues/`. |
| **IA notaire (ai_working_help)** | `notary-ai-loop`, `notary-ai-process` ; API `ai_working_help/server.js` ; spooler `projects/<id>/data/notary-ai/{pending,responded}`. |
| **DevOps** | `push-by-script`, `deploy-by-script`, `deploy-pprod-or-prod`, `branch-align-by-script-from-test`, `change-to-all-branches` ; scripts `deploy/`. |
| **Sécurité / Qualité** | Règles `.smartIde/rules/` ; pas de secrets en dur ; `fix-lint` ; clôture obligatoire (`.smartIde/rules/cloture-evolution.mdc`). |
Référence détaillée : `IA_DEV_ROOT/projects/ia_dev/docs/GIT_ISSUES_SCRIPTS_AGENTS.md`. Index : `IA_DEV_ROOT/projects/ia_dev/docs/README.md`.
## Répertoire d'exécution (standalone)
Tous les scripts sont invoqués depuis la **racine `IA_DEV_ROOT`**.
- **deploy/** : déploient les **projets configurés**, pas ia_dev.
- **git-issues/** : logs et data par projet sous `projects/<id>/logs/` et `projects/<id>/data/issues/`.
- **ai_working_help/** : API et scripts `notary-ai/` ; doc `ai_working_help/docs/notary-ai-api.md`.
## Scripts centralisés (`deploy/`)
Les scripts **déploient et versionnent les projets configurés** dans leurs répertoires. Chaque script accepte en option un **project_id** (ou `--project`) ; sinon résolution par MAIL_TO ou AI_AGENT_TOKEN.
**Orchestration générique** :
- **deploy/lib/deploy-methodology.sh** : environnements `test` \| `pprod` \| `prod`, validations communes.
- **deploy.sh** : `./deploy/deploy.sh <project_id> <env> [options…]` — puis **orchestrator.sh**.
- **orchestrator.sh** : secrets depuis `conf.json`, puis **`exec`** du **script orchestrateur projet** : `deploy.project_orchestrator_path` (relatif à `repository_root`). **Repli** : `hooks.phases` ou `deploy.deploy_script_path`.
- **run-project-hooks.sh** : délègue à **orchestrator.sh**.
Autres : **bump-version.sh**, **deploy-by-script-to.sh**, **pousse.sh**, **branch-align.sh**, **change-to-all-branches.sh**. Bibliothèque partagée : **deploy/_lib/** — détail [ia-dev-deploy-lib.md](./ia-dev-deploy-lib.md).
## Intégration smart_ide
Quand ia_dev est dans le monorepo **smart_ide** : [ia-dev-smart-ide-integration.md](./ia-dev-smart-ide-integration.md), [ia_dev-module.md](../ia_dev-module.md).