modified
.memory/history.md +7 -0 | @@ -378,3 +378,10 @@ | ||
| 378 | 378 | - **2026-11-15 — #117 closed** (owner); feature/117-linked-code-colours merged into main with the #118 per-channel note (not pushed). |
| 379 | 379 | - **2026-11-15 — #118** (branch feature/118-prompt-history): ↑ history per channel from Pebble — channels.Manager.Prompts + ChannelService.Prompts (100), history.seed, Composer loadHistory. Cause: Composer is keyed by channel, its in-memory history restarted each time. Xvfb after restart: direct and #general each recall only their own. make verify green. Not committed; #118 open for the owner's test. |
| 380 | 380 | - **2026-11-15 — #118 closed** (owner); feature/118-prompt-history merged into main (not pushed). |
| 381 | + | |
| 382 | +## 2026-11-15 — #113 agent instructions (branch feature/113-agent-instructions) | |
| 383 | + | |
| 384 | +- Asked: "go for 113". Research: AGENTS.md read by mm, Codex, Antigravity (+GEMINI.md), Vibe, Copilot; Claude Code reads CLAUDE.md first (AGENTS.md only as fallback, ≥ 2.1.277) → CLAUDE.md for Claude. | |
| 385 | +- Conflict with #54 (AGENTS.md always protected) put to the owner: chose "Instructions tab allowed" — Files tab stays locked, Instructions tab writes (never deletes), CLAUDE.md/GEMINI.md added to AlwaysProtected (config tests updated for the new list). | |
| 386 | +- Done: agents.InstructionsFiles, WorkspaceService Instructions/Create/Save(conflict)/Import/ChooseInstructions (uses workspace.ErrNotFound, writes with the read version — an empty version only creates), InstructionsTab.svelte + instructions.ts template EN/FR, AgentView tab. Tests Go + vitest; Xvfb (create, edit, save, restart note, 🔒 in Files). make verify green. Docs EN/FR, release notes v1.7.0. Not committed; #113 open for the owner's test. | |
| 387 | +- **2026-11-15 — #113 closed** (owner); feature/113-agent-instructions merged into main (not pushed). | |
| @@ -378,3 +378,10 @@ | |||
| 378 | - **2026-11-15 — #117 closed** (owner); feature/117-linked-code-colours merged into main with the #118 per-channel note (not pushed). | 378 | - **2026-11-15 — #117 closed** (owner); feature/117-linked-code-colours merged into main with the #118 per-channel note (not pushed). |
| 379 | - **2026-11-15 — #118** (branch feature/118-prompt-history): ↑ history per channel from Pebble — channels.Manager.Prompts + ChannelService.Prompts (100), history.seed, Composer loadHistory. Cause: Composer is keyed by channel, its in-memory history restarted each time. Xvfb after restart: direct and #general each recall only their own. make verify green. Not committed; #118 open for the owner's test. | 379 | - **2026-11-15 — #118** (branch feature/118-prompt-history): ↑ history per channel from Pebble — channels.Manager.Prompts + ChannelService.Prompts (100), history.seed, Composer loadHistory. Cause: Composer is keyed by channel, its in-memory history restarted each time. Xvfb after restart: direct and #general each recall only their own. make verify green. Not committed; #118 open for the owner's test. |
| 380 | - **2026-11-15 — #118 closed** (owner); feature/118-prompt-history merged into main (not pushed). | 380 | - **2026-11-15 — #118 closed** (owner); feature/118-prompt-history merged into main (not pushed). |
| 381 | + | ||
| 382 | +## 2026-11-15 — #113 agent instructions (branch feature/113-agent-instructions) | ||
| 383 | + | ||
| 384 | +- Asked: "go for 113". Research: AGENTS.md read by mm, Codex, Antigravity (+GEMINI.md), Vibe, Copilot; Claude Code reads CLAUDE.md first (AGENTS.md only as fallback, ≥ 2.1.277) → CLAUDE.md for Claude. | ||
| 385 | +- Conflict with #54 (AGENTS.md always protected) put to the owner: chose "Instructions tab allowed" — Files tab stays locked, Instructions tab writes (never deletes), CLAUDE.md/GEMINI.md added to AlwaysProtected (config tests updated for the new list). | ||
| 386 | +- Done: agents.InstructionsFiles, WorkspaceService Instructions/Create/Save(conflict)/Import/ChooseInstructions (uses workspace.ErrNotFound, writes with the read version — an empty version only creates), InstructionsTab.svelte + instructions.ts template EN/FR, AgentView tab. Tests Go + vitest; Xvfb (create, edit, save, restart note, 🔒 in Files). make verify green. Docs EN/FR, release notes v1.7.0. Not committed; #113 open for the owner's test. | ||
| 387 | +- **2026-11-15 — #113 closed** (owner); feature/113-agent-instructions merged into main (not pushed). | ||
modified
.memory/summary.md +1 -0 | @@ -28,6 +28,7 @@ What exists: | ||
| 28 | 28 | - Agent forms (#95): every conversation agent is started with `acp.Spec.Forms` (advertises `elicitation.form`); a form goes to the session named in `_meta["mm.elicitationScope"]`, else to the only session with a prompt in flight, and is shown as a `FormCard` under the answer (`form:requested`/`form:resolved`, `ChannelService.AnswerForm`); Stop cancels it. Fields rendered by `chat/FormFields.svelte`, shared with the creator. |
| 29 | 29 | - Sandbox creation assistant (#96, `SbxCreatorService`, page `CreateSbxAgent.svelte`, package `internal/sbxcreate`): catalogue of kinds (Claude `claude-agent-acp`, Antigravity (kind id `antigravity` since #108, was `gemini`) `agy acp` with kit `docker.io/sbx/antigravity`, Codex `codex-acp`, Vibe `vibe-acp` with kit `docker.io/sbx/vibe-kit`, service `mistral` — #86; Copilot `copilot --acp --stdio` with kit `docker.io/sbx/copilot-kit`, service `copilot` = a GitHub token, `Kind.Token` switches the key step to "token" texts — #103); writes `<agentsFolder>/<name>/sbxenv.yaml` (English comments) + `workspace/`; name = agent = folder = sandbox (`^[a-z][a-z0-9-]{0,31}$`); API key checked with `sbx secret ls --service`, set with `sbx secret set <service>` on stdin (never in args, files or logs). `appState.creator` is `'' | 'mini-me' | 'sbx'`. |
| 30 | 30 | - Agent icons (#100): `icon` may be `logo:<name>` (`config.LogoNames` = claude, gemini, antigravity, openai, mistral, copilot — copilot is GitHub Octicons, MIT, antigravity LobeHub Icons, MIT; drawn by `frontend/src/lib/logos.ts` from Simple Icons, CC0 — OpenAI from 13.21.0; a Go test checks both lists; unknown name = warning, shows a letter). Start progress (#98): `agent:progress` {agent, step checking|preparing|connecting, line, since} from `agents.Manager`, card `chat/StartProgress.svelte` (no log link since 2026-11-15, owner's request; `showLog` in state.svelte.ts is now unused). Assistants' @ name follows the name shown until edited, free variant from Go's `taken` list (#99). |
| 31 | +- Agent instructions (#113): an agent's instruction file is chosen from its program (`agents.InstructionsFiles`: Claude → `CLAUDE.md` then `AGENTS.md`; Antigravity → `AGENTS.md` then `GEMINI.md`; else `AGENTS.md`). `config.AlwaysProtected` = `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `skills/**`: the Files tab may neither change nor delete them; **only the agent's Instructions tab writes an instruction file** (create from template / save with version / import), never deletes it — owner's decision amending #54. | |
| 31 | 32 | - Interface language: ADR 0005 — `ui.language` defaults to `en`; every UI text is a key of `frontend/src/lib/i18n/messages.ts` (`fr` typed `Record<MessageKey,string>`, test checks keys and variables); config errors use the Go catalogue in the same language; agent titles and channel names are user data, never translated. Default config file and `examples/test-agents.yaml` are in English. |
| 32 | 33 | - Packages and data model: ADR 0003 + Amendments 1 and 2 (main at the root, only main.go imports Wails, `internal/events` with an `Emitter` interface, LRU eviction of idle agents at the limit). |
| 33 | 34 | - Frontend dependencies with **pnpm 12.11.2** and `frontend/pnpm-workspace.yaml` `supportedArchitectures` (darwin+linux): the repository folder is shared between the Mac and the Linux sandbox. Never use npm in `frontend/`. |
| @@ -28,6 +28,7 @@ What exists: | |||
| 28 | - Agent forms (#95): every conversation agent is started with `acp.Spec.Forms` (advertises `elicitation.form`); a form goes to the session named in `_meta["mm.elicitationScope"]`, else to the only session with a prompt in flight, and is shown as a `FormCard` under the answer (`form:requested`/`form:resolved`, `ChannelService.AnswerForm`); Stop cancels it. Fields rendered by `chat/FormFields.svelte`, shared with the creator. | 28 | - Agent forms (#95): every conversation agent is started with `acp.Spec.Forms` (advertises `elicitation.form`); a form goes to the session named in `_meta["mm.elicitationScope"]`, else to the only session with a prompt in flight, and is shown as a `FormCard` under the answer (`form:requested`/`form:resolved`, `ChannelService.AnswerForm`); Stop cancels it. Fields rendered by `chat/FormFields.svelte`, shared with the creator. |
| 29 | - Sandbox creation assistant (#96, `SbxCreatorService`, page `CreateSbxAgent.svelte`, package `internal/sbxcreate`): catalogue of kinds (Claude `claude-agent-acp`, Antigravity (kind id `antigravity` since #108, was `gemini`) `agy acp` with kit `docker.io/sbx/antigravity`, Codex `codex-acp`, Vibe `vibe-acp` with kit `docker.io/sbx/vibe-kit`, service `mistral` — #86; Copilot `copilot --acp --stdio` with kit `docker.io/sbx/copilot-kit`, service `copilot` = a GitHub token, `Kind.Token` switches the key step to "token" texts — #103); writes `<agentsFolder>/<name>/sbxenv.yaml` (English comments) + `workspace/`; name = agent = folder = sandbox (`^[a-z][a-z0-9-]{0,31}$`); API key checked with `sbx secret ls --service`, set with `sbx secret set <service>` on stdin (never in args, files or logs). `appState.creator` is `'' | 'mini-me' | 'sbx'`. | 29 | - Sandbox creation assistant (#96, `SbxCreatorService`, page `CreateSbxAgent.svelte`, package `internal/sbxcreate`): catalogue of kinds (Claude `claude-agent-acp`, Antigravity (kind id `antigravity` since #108, was `gemini`) `agy acp` with kit `docker.io/sbx/antigravity`, Codex `codex-acp`, Vibe `vibe-acp` with kit `docker.io/sbx/vibe-kit`, service `mistral` — #86; Copilot `copilot --acp --stdio` with kit `docker.io/sbx/copilot-kit`, service `copilot` = a GitHub token, `Kind.Token` switches the key step to "token" texts — #103); writes `<agentsFolder>/<name>/sbxenv.yaml` (English comments) + `workspace/`; name = agent = folder = sandbox (`^[a-z][a-z0-9-]{0,31}$`); API key checked with `sbx secret ls --service`, set with `sbx secret set <service>` on stdin (never in args, files or logs). `appState.creator` is `'' | 'mini-me' | 'sbx'`. |
| 30 | - Agent icons (#100): `icon` may be `logo:<name>` (`config.LogoNames` = claude, gemini, antigravity, openai, mistral, copilot — copilot is GitHub Octicons, MIT, antigravity LobeHub Icons, MIT; drawn by `frontend/src/lib/logos.ts` from Simple Icons, CC0 — OpenAI from 13.21.0; a Go test checks both lists; unknown name = warning, shows a letter). Start progress (#98): `agent:progress` {agent, step checking|preparing|connecting, line, since} from `agents.Manager`, card `chat/StartProgress.svelte` (no log link since 2026-11-15, owner's request; `showLog` in state.svelte.ts is now unused). Assistants' @ name follows the name shown until edited, free variant from Go's `taken` list (#99). | 30 | - Agent icons (#100): `icon` may be `logo:<name>` (`config.LogoNames` = claude, gemini, antigravity, openai, mistral, copilot — copilot is GitHub Octicons, MIT, antigravity LobeHub Icons, MIT; drawn by `frontend/src/lib/logos.ts` from Simple Icons, CC0 — OpenAI from 13.21.0; a Go test checks both lists; unknown name = warning, shows a letter). Start progress (#98): `agent:progress` {agent, step checking|preparing|connecting, line, since} from `agents.Manager`, card `chat/StartProgress.svelte` (no log link since 2026-11-15, owner's request; `showLog` in state.svelte.ts is now unused). Assistants' @ name follows the name shown until edited, free variant from Go's `taken` list (#99). |
| 31 | +- Agent instructions (#113): an agent's instruction file is chosen from its program (`agents.InstructionsFiles`: Claude → `CLAUDE.md` then `AGENTS.md`; Antigravity → `AGENTS.md` then `GEMINI.md`; else `AGENTS.md`). `config.AlwaysProtected` = `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `skills/**`: the Files tab may neither change nor delete them; **only the agent's Instructions tab writes an instruction file** (create from template / save with version / import), never deletes it — owner's decision amending #54. | ||
| 31 | - Interface language: ADR 0005 — `ui.language` defaults to `en`; every UI text is a key of `frontend/src/lib/i18n/messages.ts` (`fr` typed `Record<MessageKey,string>`, test checks keys and variables); config errors use the Go catalogue in the same language; agent titles and channel names are user data, never translated. Default config file and `examples/test-agents.yaml` are in English. | 32 | - Interface language: ADR 0005 — `ui.language` defaults to `en`; every UI text is a key of `frontend/src/lib/i18n/messages.ts` (`fr` typed `Record<MessageKey,string>`, test checks keys and variables); config errors use the Go catalogue in the same language; agent titles and channel names are user data, never translated. Default config file and `examples/test-agents.yaml` are in English. |
| 32 | - Packages and data model: ADR 0003 + Amendments 1 and 2 (main at the root, only main.go imports Wails, `internal/events` with an `Emitter` interface, LRU eviction of idle agents at the limit). | 33 | - Packages and data model: ADR 0003 + Amendments 1 and 2 (main at the root, only main.go imports Wails, `internal/events` with an `Emitter` interface, LRU eviction of idle agents at the limit). |
| 33 | - Frontend dependencies with **pnpm 12.11.2** and `frontend/pnpm-workspace.yaml` `supportedArchitectures` (darwin+linux): the repository folder is shared between the Mac and the Linux sandbox. Never use npm in `frontend/`. | 34 | - Frontend dependencies with **pnpm 12.11.2** and `frontend/pnpm-workspace.yaml` `supportedArchitectures` (darwin+linux): the repository folder is shared between the Mac and the Linux sandbox. Never use npm in `frontend/`. |
modified
.tickets/issues/0113-agents-md-des-agents-creer-modifier-et-importer.yaml +43 -6 | @@ -1,12 +1,12 @@ | ||
| 1 | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | 2 | id: 113 |
| 3 | 3 | title: "AGENTS.md des agents : créer, modifier et importer les instructions depuis Sidekicks" |
| 4 | -state: open | |
| 4 | +state: closed | |
| 5 | 5 | author: |
| 6 | 6 | name: k33g |
| 7 | 7 | email: ph.charriere@gmail.com |
| 8 | 8 | createdAt: 2026-11-15T17:22:23.000Z |
| 9 | -updatedAt: 2026-11-15T17:22:23.000Z | |
| 9 | +updatedAt: 2026-11-15T19:36:26.000Z | |
| 10 | 10 | labels: |
| 11 | 11 | - kind::feature |
| 12 | 12 | - area::workspace |
| @@ -39,26 +39,63 @@ body: | | ||
| 39 | 39 | tasks: |
| 40 | 40 | - id: 1 |
| 41 | 41 | title: "Relever le fichier d'instructions lu par chaque type d'agent" |
| 42 | - state: open | |
| 42 | + state: closed | |
| 43 | 43 | priority: high |
| 44 | 44 | author: |
| 45 | 45 | name: k33g |
| 46 | 46 | email: ph.charriere@gmail.com |
| 47 | 47 | createdAt: 2026-11-15T17:22:23.000Z |
| 48 | + updatedAt: 2026-11-15T19:21:53.000Z | |
| 49 | + closedAt: 2026-11-15T19:21:53.000Z | |
| 48 | 50 | - id: 2 |
| 49 | 51 | title: "Accès direct aux instructions de l'agent : créer (modèle), modifier, importer" |
| 50 | - state: open | |
| 52 | + state: closed | |
| 51 | 53 | priority: high |
| 52 | 54 | author: |
| 53 | 55 | name: k33g |
| 54 | 56 | email: ph.charriere@gmail.com |
| 55 | 57 | createdAt: 2026-11-15T17:22:23.000Z |
| 58 | + updatedAt: 2026-11-15T19:21:53.000Z | |
| 59 | + closedAt: 2026-11-15T19:21:53.000Z | |
| 56 | 60 | - id: 3 |
| 57 | 61 | title: "Prise en compte (redémarrage proposé), tests, doc EN + FR" |
| 58 | - state: open | |
| 62 | + state: closed | |
| 59 | 63 | priority: medium |
| 60 | 64 | author: |
| 61 | 65 | name: k33g |
| 62 | 66 | email: ph.charriere@gmail.com |
| 63 | 67 | createdAt: 2026-11-15T17:22:23.000Z |
| 64 | -comments: [] | |
| 68 | + updatedAt: 2026-11-15T19:21:53.000Z | |
| 69 | + closedAt: 2026-11-15T19:21:53.000Z | |
| 70 | +comments: | |
| 71 | + - id: 1 | |
| 72 | + author: | |
| 73 | + name: k33g | |
| 74 | + email: ph.charriere@gmail.com | |
| 75 | + createdAt: 2026-11-15T19:21:53.000Z | |
| 76 | + body: | | |
| 77 | + Fait sur `feature/113-agent-instructions`. | |
| 78 | + | |
| 79 | + **Fichier lu par chaque agent (recherche du 2026-11-15)** : `AGENTS.md` pour mini-me, Codex, Antigravity (qui lit | |
| 80 | + aussi `GEMINI.md`), Vibe (dossier de confiance) et Copilot ; Claude Code lit `CLAUDE.md` d'abord, et `AGENTS.md` | |
| 81 | + seulement sans `CLAUDE.md` et dans ses versions récentes (≥ 2.1.277) → pour Claude, Sidekicks crée `CLAUDE.md`. | |
| 82 | + `agents.InstructionsFiles` (d'après le programme) ; le premier qui existe est celui qu'on édite. | |
| 83 | + | |
| 84 | + **Décision de l'owner (conflit avec #54, qui protège `AGENTS.md` sans exception)** : l'onglet Fichiers reste | |
| 85 | + bloqué ; seul le nouvel onglet **Instructions** écrit le fichier (créer, modifier, importer), jamais ne le | |
| 86 | + supprime ; `CLAUDE.md` et `GEMINI.md` rejoignent `config.AlwaysProtected`. | |
| 87 | + | |
| 88 | + - Go : `WorkspaceService.Instructions / CreateInstructions / SaveInstructions (conflit par version) / | |
| 89 | + ImportInstructions (texte UTF-8, 1 Mio) / ChooseInstructions` ; local, conteneur et sandbox via le workspace. | |
| 90 | + - Front : `InstructionsTab.svelte` (explication, modèle EN/FR, éditeur CodeMirror Markdown + Enregistrer/Annuler, | |
| 91 | + import avec confirmation, rappel « redémarrer l'agent » s'il tourne). | |
| 92 | + - Vérifié sous Xvfb : création depuis le modèle, modification, enregistrement (fichier écrit), rappel de | |
| 93 | + redémarrage, 🔒 dans l'onglet Fichiers. Import : sélecteur natif non pilotable ici, couvert par les tests Go. | |
| 94 | + `make verify` vert. Doc EN + FR (guide, configuration, référence), notes v1.7.0. | |
| 95 | + - id: 2 | |
| 96 | + author: | |
| 97 | + name: k33g | |
| 98 | + email: ph.charriere@gmail.com | |
| 99 | + createdAt: 2026-11-15T19:36:26.000Z | |
| 100 | + body: | | |
| 101 | + Testé sur le Mac par l'owner : ça fonctionne. Mergé dans main. Ticket fermé. | |
| @@ -1,12 +1,12 @@ | |||
| 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | id: 113 | 2 | id: 113 |
| 3 | title: "AGENTS.md des agents : créer, modifier et importer les instructions depuis Sidekicks" | 3 | title: "AGENTS.md des agents : créer, modifier et importer les instructions depuis Sidekicks" |
| 4 | -state: open | 4 | +state: closed |
| 5 | author: | 5 | author: |
| 6 | name: k33g | 6 | name: k33g |
| 7 | email: ph.charriere@gmail.com | 7 | email: ph.charriere@gmail.com |
| 8 | createdAt: 2026-11-15T17:22:23.000Z | 8 | createdAt: 2026-11-15T17:22:23.000Z |
| 9 | -updatedAt: 2026-11-15T17:22:23.000Z | 9 | +updatedAt: 2026-11-15T19:36:26.000Z |
| 10 | labels: | 10 | labels: |
| 11 | - kind::feature | 11 | - kind::feature |
| 12 | - area::workspace | 12 | - area::workspace |
| @@ -39,26 +39,63 @@ body: | | |||
| 39 | tasks: | 39 | tasks: |
| 40 | - id: 1 | 40 | - id: 1 |
| 41 | title: "Relever le fichier d'instructions lu par chaque type d'agent" | 41 | title: "Relever le fichier d'instructions lu par chaque type d'agent" |
| 42 | - state: open | 42 | + state: closed |
| 43 | priority: high | 43 | priority: high |
| 44 | author: | 44 | author: |
| 45 | name: k33g | 45 | name: k33g |
| 46 | email: ph.charriere@gmail.com | 46 | email: ph.charriere@gmail.com |
| 47 | createdAt: 2026-11-15T17:22:23.000Z | 47 | createdAt: 2026-11-15T17:22:23.000Z |
| 48 | + updatedAt: 2026-11-15T19:21:53.000Z | ||
| 49 | + closedAt: 2026-11-15T19:21:53.000Z | ||
| 48 | - id: 2 | 50 | - id: 2 |
| 49 | title: "Accès direct aux instructions de l'agent : créer (modèle), modifier, importer" | 51 | title: "Accès direct aux instructions de l'agent : créer (modèle), modifier, importer" |
| 50 | - state: open | 52 | + state: closed |
| 51 | priority: high | 53 | priority: high |
| 52 | author: | 54 | author: |
| 53 | name: k33g | 55 | name: k33g |
| 54 | email: ph.charriere@gmail.com | 56 | email: ph.charriere@gmail.com |
| 55 | createdAt: 2026-11-15T17:22:23.000Z | 57 | createdAt: 2026-11-15T17:22:23.000Z |
| 58 | + updatedAt: 2026-11-15T19:21:53.000Z | ||
| 59 | + closedAt: 2026-11-15T19:21:53.000Z | ||
| 56 | - id: 3 | 60 | - id: 3 |
| 57 | title: "Prise en compte (redémarrage proposé), tests, doc EN + FR" | 61 | title: "Prise en compte (redémarrage proposé), tests, doc EN + FR" |
| 58 | - state: open | 62 | + state: closed |
| 59 | priority: medium | 63 | priority: medium |
| 60 | author: | 64 | author: |
| 61 | name: k33g | 65 | name: k33g |
| 62 | email: ph.charriere@gmail.com | 66 | email: ph.charriere@gmail.com |
| 63 | createdAt: 2026-11-15T17:22:23.000Z | 67 | createdAt: 2026-11-15T17:22:23.000Z |
| 64 | -comments: [] | 68 | + updatedAt: 2026-11-15T19:21:53.000Z |
| 69 | + closedAt: 2026-11-15T19:21:53.000Z | ||
| 70 | +comments: | ||
| 71 | + - id: 1 | ||
| 72 | + author: | ||
| 73 | + name: k33g | ||
| 74 | + email: ph.charriere@gmail.com | ||
| 75 | + createdAt: 2026-11-15T19:21:53.000Z | ||
| 76 | + body: | | ||
| 77 | + Fait sur `feature/113-agent-instructions`. | ||
| 78 | + | ||
| 79 | + **Fichier lu par chaque agent (recherche du 2026-11-15)** : `AGENTS.md` pour mini-me, Codex, Antigravity (qui lit | ||
| 80 | + aussi `GEMINI.md`), Vibe (dossier de confiance) et Copilot ; Claude Code lit `CLAUDE.md` d'abord, et `AGENTS.md` | ||
| 81 | + seulement sans `CLAUDE.md` et dans ses versions récentes (≥ 2.1.277) → pour Claude, Sidekicks crée `CLAUDE.md`. | ||
| 82 | + `agents.InstructionsFiles` (d'après le programme) ; le premier qui existe est celui qu'on édite. | ||
| 83 | + | ||
| 84 | + **Décision de l'owner (conflit avec #54, qui protège `AGENTS.md` sans exception)** : l'onglet Fichiers reste | ||
| 85 | + bloqué ; seul le nouvel onglet **Instructions** écrit le fichier (créer, modifier, importer), jamais ne le | ||
| 86 | + supprime ; `CLAUDE.md` et `GEMINI.md` rejoignent `config.AlwaysProtected`. | ||
| 87 | + | ||
| 88 | + - Go : `WorkspaceService.Instructions / CreateInstructions / SaveInstructions (conflit par version) / | ||
| 89 | + ImportInstructions (texte UTF-8, 1 Mio) / ChooseInstructions` ; local, conteneur et sandbox via le workspace. | ||
| 90 | + - Front : `InstructionsTab.svelte` (explication, modèle EN/FR, éditeur CodeMirror Markdown + Enregistrer/Annuler, | ||
| 91 | + import avec confirmation, rappel « redémarrer l'agent » s'il tourne). | ||
| 92 | + - Vérifié sous Xvfb : création depuis le modèle, modification, enregistrement (fichier écrit), rappel de | ||
| 93 | + redémarrage, 🔒 dans l'onglet Fichiers. Import : sélecteur natif non pilotable ici, couvert par les tests Go. | ||
| 94 | + `make verify` vert. Doc EN + FR (guide, configuration, référence), notes v1.7.0. | ||
| 95 | + - id: 2 | ||
| 96 | + author: | ||
| 97 | + name: k33g | ||
| 98 | + email: ph.charriere@gmail.com | ||
| 99 | + createdAt: 2026-11-15T19:36:26.000Z | ||
| 100 | + body: | | ||
| 101 | + Testé sur le Mac par l'owner : ça fonctionne. Mergé dans main. Ticket fermé. | ||
modified
docs/en/how-to/work-with-an-agents-files.md +12 -1 | @@ -50,9 +50,20 @@ The link must lead to a file of the agent's folder: a path relative to the folde | ||
| 50 | 50 | - **Right-click** an entry for a menu with all these actions, and **Show where it is**. |
| 51 | 51 | - **Delete**: hover the entry and click **🗑** (or **Delete** under the editor, or press **Delete** — ⌘⌫ on a Mac — in the tree), then confirm; with several entries selected, one confirmation covers them all. On this computer the file goes to the trash — restore it from the Finder if needed. In a container the deletion is final, and the confirmation says so. |
| 52 | 52 | |
| 53 | +## Give the agent its instructions | |
| 54 | + | |
| 55 | +An agent reads its **instructions** when its session starts: its role, its tone, its rules, in a Markdown file of its folder — `AGENTS.md` for most agents, `CLAUDE.md` for Claude (issue #113). Open the **Instructions** tab of the agent's workspace: | |
| 56 | + | |
| 57 | +- **Create from a template**: when the agent has none yet, Sidekicks writes a short template named after the agent (its role, how it answers, its rules). Fill it in with plain words. | |
| 58 | +- Change the text in the editor of the tab, then **Save** (⌘S, Ctrl+S on Linux and Windows); **Revert** drops your changes. If the file changed meanwhile — the agent may write it too — Sidekicks says so and writes nothing: **Reload**, then make your changes again. | |
| 59 | +- **Import a file…** copies a text file of this computer as the agent's instructions (it replaces them, after you confirm). | |
| 60 | +- The agent reads its instructions when its session starts: when it is running, **Restart the agent** so that it uses the new ones. | |
| 61 | + | |
| 62 | +The instruction file stays protected in the **Files** tab (below): only the **Instructions** tab writes it, and nothing deletes it. It works the same for an agent on this computer, in a Docker container or in an sbx sandbox. | |
| 63 | + | |
| 53 | 64 | ## Protect files |
| 54 | 65 | |
| 55 | -Some files must not be changed or deleted by mistake. Without writing anything, the agent's instructions (`AGENTS.md`), its skills (`skills/` and all it holds), its configuration file (after `--config` or `serve acp` in its `args`) and, for an agent in a container or a sandbox, the files it is built from (`compose.yaml`, `Dockerfile`, `sbxenv.yaml` named by its `runtime.lifecycle`) are protected. To protect others, list them under the agent in **Settings**: | |
| 66 | +Some files must not be changed or deleted by mistake. Without writing anything, the agent's instructions (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md` — written only from the **Instructions** tab), its skills (`skills/` and all it holds), its configuration file (after `--config` or `serve acp` in its `args`) and, for an agent in a container or a sandbox, the files it is built from (`compose.yaml`, `Dockerfile`, `sbxenv.yaml` named by its `runtime.lifecycle`) are protected. To protect others, list them under the agent in **Settings**: | |
| 56 | 67 | |
| 57 | 68 | ```yaml |
| 58 | 69 | - name: milo |
| @@ -50,9 +50,20 @@ The link must lead to a file of the agent's folder: a path relative to the folde | |||
| 50 | - **Right-click** an entry for a menu with all these actions, and **Show where it is**. | 50 | - **Right-click** an entry for a menu with all these actions, and **Show where it is**. |
| 51 | - **Delete**: hover the entry and click **🗑** (or **Delete** under the editor, or press **Delete** — ⌘⌫ on a Mac — in the tree), then confirm; with several entries selected, one confirmation covers them all. On this computer the file goes to the trash — restore it from the Finder if needed. In a container the deletion is final, and the confirmation says so. | 51 | - **Delete**: hover the entry and click **🗑** (or **Delete** under the editor, or press **Delete** — ⌘⌫ on a Mac — in the tree), then confirm; with several entries selected, one confirmation covers them all. On this computer the file goes to the trash — restore it from the Finder if needed. In a container the deletion is final, and the confirmation says so. |
| 52 | 52 | ||
| 53 | +## Give the agent its instructions | ||
| 54 | + | ||
| 55 | +An agent reads its **instructions** when its session starts: its role, its tone, its rules, in a Markdown file of its folder — `AGENTS.md` for most agents, `CLAUDE.md` for Claude (issue #113). Open the **Instructions** tab of the agent's workspace: | ||
| 56 | + | ||
| 57 | +- **Create from a template**: when the agent has none yet, Sidekicks writes a short template named after the agent (its role, how it answers, its rules). Fill it in with plain words. | ||
| 58 | +- Change the text in the editor of the tab, then **Save** (⌘S, Ctrl+S on Linux and Windows); **Revert** drops your changes. If the file changed meanwhile — the agent may write it too — Sidekicks says so and writes nothing: **Reload**, then make your changes again. | ||
| 59 | +- **Import a file…** copies a text file of this computer as the agent's instructions (it replaces them, after you confirm). | ||
| 60 | +- The agent reads its instructions when its session starts: when it is running, **Restart the agent** so that it uses the new ones. | ||
| 61 | + | ||
| 62 | +The instruction file stays protected in the **Files** tab (below): only the **Instructions** tab writes it, and nothing deletes it. It works the same for an agent on this computer, in a Docker container or in an sbx sandbox. | ||
| 63 | + | ||
| 53 | ## Protect files | 64 | ## Protect files |
| 54 | 65 | ||
| 55 | -Some files must not be changed or deleted by mistake. Without writing anything, the agent's instructions (`AGENTS.md`), its skills (`skills/` and all it holds), its configuration file (after `--config` or `serve acp` in its `args`) and, for an agent in a container or a sandbox, the files it is built from (`compose.yaml`, `Dockerfile`, `sbxenv.yaml` named by its `runtime.lifecycle`) are protected. To protect others, list them under the agent in **Settings**: | 66 | +Some files must not be changed or deleted by mistake. Without writing anything, the agent's instructions (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md` — written only from the **Instructions** tab), its skills (`skills/` and all it holds), its configuration file (after `--config` or `serve acp` in its `args`) and, for an agent in a container or a sandbox, the files it is built from (`compose.yaml`, `Dockerfile`, `sbxenv.yaml` named by its `runtime.lifecycle`) are protected. To protect others, list them under the agent in **Settings**: |
| 56 | 67 | ||
| 57 | ```yaml | 68 | ```yaml |
| 58 | - name: milo | 69 | - name: milo |
modified
docs/en/reference/agents-and-events.md +2 -0 | @@ -190,6 +190,8 @@ A file opened for editing has `path, content, version`; `version` identifies the | ||
| 190 | 190 | | `Info(agent)` | `{location, problem, revealable}`: where the folder is (`local · /path`, `container name · /path`), or why it cannot be shown; `revealable` when the folder is on this computer (issue #74). | |
| 191 | 191 | | `List(agent, dir)` | The entries of `dir` (`""` is the folder), folders first, then by name. | |
| 192 | 192 | | `Read(agent, path)` | A text file of at most 1 MB; a binary or larger file is an error. | |
| 193 | +| `Instructions(agent)` | The agent's instructions (issue #113): `{file, exists, content, version, files}` — the first of `files` (from its program: `CLAUDE.md` then `AGENTS.md` for Claude, `AGENTS.md` then `GEMINI.md` for Antigravity, else `AGENTS.md`) that exists at the root of its folder, else the first one, to create. | | |
| 194 | +| `CreateInstructions(agent, content)`, `SaveInstructions(agent, content, version)`, `ImportInstructions(agent, hostPath)`, `ChooseInstructions()` | Write the instruction file — the only way to, as it is protected (`protect`): from a template (refused when it exists), edited over `version` (`{instructions, conflict}`; `conflict` and nothing written when it changed), or copied from a UTF-8 text file of this computer (1 MiB at most; replaces it). Never removed. | | |
| 193 | 195 | | `Save(agent, path, content, version)` | Writes the file if it still has `version`; otherwise `{conflict: true}` and nothing is written. An empty `version` overwrites. The file is written next to its place and moved over it. | |
| 194 | 196 | | `Create(agent, dir, name)` | Creates an empty file; refused if the name exists or contains `/`. | |
| 195 | 197 | | `Remove(agent, path)` | Deletes a file or a folder with its content (see the table above). | |
| @@ -190,6 +190,8 @@ A file opened for editing has `path, content, version`; `version` identifies the | |||
| 190 | | `Info(agent)` | `{location, problem, revealable}`: where the folder is (`local · /path`, `container name · /path`), or why it cannot be shown; `revealable` when the folder is on this computer (issue #74). | | 190 | | `Info(agent)` | `{location, problem, revealable}`: where the folder is (`local · /path`, `container name · /path`), or why it cannot be shown; `revealable` when the folder is on this computer (issue #74). | |
| 191 | | `List(agent, dir)` | The entries of `dir` (`""` is the folder), folders first, then by name. | | 191 | | `List(agent, dir)` | The entries of `dir` (`""` is the folder), folders first, then by name. | |
| 192 | | `Read(agent, path)` | A text file of at most 1 MB; a binary or larger file is an error. | | 192 | | `Read(agent, path)` | A text file of at most 1 MB; a binary or larger file is an error. | |
| 193 | +| `Instructions(agent)` | The agent's instructions (issue #113): `{file, exists, content, version, files}` — the first of `files` (from its program: `CLAUDE.md` then `AGENTS.md` for Claude, `AGENTS.md` then `GEMINI.md` for Antigravity, else `AGENTS.md`) that exists at the root of its folder, else the first one, to create. | | ||
| 194 | +| `CreateInstructions(agent, content)`, `SaveInstructions(agent, content, version)`, `ImportInstructions(agent, hostPath)`, `ChooseInstructions()` | Write the instruction file — the only way to, as it is protected (`protect`): from a template (refused when it exists), edited over `version` (`{instructions, conflict}`; `conflict` and nothing written when it changed), or copied from a UTF-8 text file of this computer (1 MiB at most; replaces it). Never removed. | | ||
| 193 | | `Save(agent, path, content, version)` | Writes the file if it still has `version`; otherwise `{conflict: true}` and nothing is written. An empty `version` overwrites. The file is written next to its place and moved over it. | | 195 | | `Save(agent, path, content, version)` | Writes the file if it still has `version`; otherwise `{conflict: true}` and nothing is written. An empty `version` overwrites. The file is written next to its place and moved over it. | |
| 194 | | `Create(agent, dir, name)` | Creates an empty file; refused if the name exists or contains `/`. | | 196 | | `Create(agent, dir, name)` | Creates an empty file; refused if the name exists or contains `/`. | |
| 195 | | `Remove(agent, path)` | Deletes a file or a folder with its content (see the table above). | | 197 | | `Remove(agent, path)` | Deletes a file or a folder with its content (see the table above). | |
modified
docs/en/reference/configuration.md +1 -1 | @@ -90,7 +90,7 @@ agentTools: | ||
| 90 | 90 | | `env` | map text → text | no | | Extra environment variables. | |
| 91 | 91 | | `afterStop` | list of text, at least one | no | | Command run each time the agent's process ends — stopped, crashed, stopped to make room, or Sidekicks quitting: the program (a bare name is looked up in PATH, a path is relative to this file), then its arguments. It runs in `workspace` with `env`, for 30 s at most; its output goes to the agent's log; Sidekicks waits for it before quitting. A program that cannot be found is a warning. Example: `[../scripts/agents.sh, unload, alice]` to unload the model. | |
| 92 | 92 | | `workspace` | path | no | the configuration folder | The agent's folder: the process starts there and it is the `cwd` of its ACP sessions. mm reads `AGENTS.md` and `skills/` from it. | |
| 93 | -| `protect` | list of text | no | | Files of the agent's folder the interface (Files tab) may neither change nor delete: paths relative to the folder, or patterns where `*` and `?` match within a name and `**` any number of folders (`[AGENTS.md, "skills/**"]`). A folder holding a protected file cannot be deleted. Always protected, when they are in its folder: `AGENTS.md`, `skills/**`, the agent's configuration file (the argument after `--config`, `-config` or `serve acp` in `args`), and the files `runtime.lifecycle` builds the container or the sandbox from — the Compose file (after `-f`/`--file`, or `compose.yaml`… without it), the `Dockerfile` of the lifecycle folder for a container, the sbx environment file (`sbxenv.yaml` or the one named). Only the configuration lifts a protection; the agent itself, the terminal or the Finder are not bound by it. | | |
| 93 | +| `protect` | list of text | no | | Files of the agent's folder the interface (Files tab) may neither change nor delete: paths relative to the folder, or patterns where `*` and `?` match within a name and `**` any number of folders (`[AGENTS.md, "skills/**"]`). A folder holding a protected file cannot be deleted. Always protected, when they are in its folder: `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` (the agent's instructions, written only by its Instructions tab, issue #113), `skills/**`, the agent's configuration file (the argument after `--config`, `-config` or `serve acp` in `args`), and the files `runtime.lifecycle` builds the container or the sandbox from — the Compose file (after `-f`/`--file`, or `compose.yaml`… without it), the `Dockerfile` of the lifecycle folder for a container, the sbx environment file (`sbxenv.yaml` or the one named). Only the configuration lifts a protection; the agent itself, the terminal or the Finder are not bound by it. | | |
| 94 | 94 | | `runtime` | object | no | `{type: local}` | Where the agent runs (see below). | |
| 95 | 95 | |
| 96 | 96 | ### `runtime` |
| @@ -90,7 +90,7 @@ agentTools: | |||
| 90 | | `env` | map text → text | no | | Extra environment variables. | | 90 | | `env` | map text → text | no | | Extra environment variables. | |
| 91 | | `afterStop` | list of text, at least one | no | | Command run each time the agent's process ends — stopped, crashed, stopped to make room, or Sidekicks quitting: the program (a bare name is looked up in PATH, a path is relative to this file), then its arguments. It runs in `workspace` with `env`, for 30 s at most; its output goes to the agent's log; Sidekicks waits for it before quitting. A program that cannot be found is a warning. Example: `[../scripts/agents.sh, unload, alice]` to unload the model. | | 91 | | `afterStop` | list of text, at least one | no | | Command run each time the agent's process ends — stopped, crashed, stopped to make room, or Sidekicks quitting: the program (a bare name is looked up in PATH, a path is relative to this file), then its arguments. It runs in `workspace` with `env`, for 30 s at most; its output goes to the agent's log; Sidekicks waits for it before quitting. A program that cannot be found is a warning. Example: `[../scripts/agents.sh, unload, alice]` to unload the model. | |
| 92 | | `workspace` | path | no | the configuration folder | The agent's folder: the process starts there and it is the `cwd` of its ACP sessions. mm reads `AGENTS.md` and `skills/` from it. | | 92 | | `workspace` | path | no | the configuration folder | The agent's folder: the process starts there and it is the `cwd` of its ACP sessions. mm reads `AGENTS.md` and `skills/` from it. | |
| 93 | -| `protect` | list of text | no | | Files of the agent's folder the interface (Files tab) may neither change nor delete: paths relative to the folder, or patterns where `*` and `?` match within a name and `**` any number of folders (`[AGENTS.md, "skills/**"]`). A folder holding a protected file cannot be deleted. Always protected, when they are in its folder: `AGENTS.md`, `skills/**`, the agent's configuration file (the argument after `--config`, `-config` or `serve acp` in `args`), and the files `runtime.lifecycle` builds the container or the sandbox from — the Compose file (after `-f`/`--file`, or `compose.yaml`… without it), the `Dockerfile` of the lifecycle folder for a container, the sbx environment file (`sbxenv.yaml` or the one named). Only the configuration lifts a protection; the agent itself, the terminal or the Finder are not bound by it. | | 93 | +| `protect` | list of text | no | | Files of the agent's folder the interface (Files tab) may neither change nor delete: paths relative to the folder, or patterns where `*` and `?` match within a name and `**` any number of folders (`[AGENTS.md, "skills/**"]`). A folder holding a protected file cannot be deleted. Always protected, when they are in its folder: `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` (the agent's instructions, written only by its Instructions tab, issue #113), `skills/**`, the agent's configuration file (the argument after `--config`, `-config` or `serve acp` in `args`), and the files `runtime.lifecycle` builds the container or the sandbox from — the Compose file (after `-f`/`--file`, or `compose.yaml`… without it), the `Dockerfile` of the lifecycle folder for a container, the sbx environment file (`sbxenv.yaml` or the one named). Only the configuration lifts a protection; the agent itself, the terminal or the Finder are not bound by it. | |
| 94 | | `runtime` | object | no | `{type: local}` | Where the agent runs (see below). | | 94 | | `runtime` | object | no | `{type: local}` | Where the agent runs (see below). | |
| 95 | 95 | ||
| 96 | ### `runtime` | 96 | ### `runtime` |
modified
docs/fr/how-to/fichiers-et-terminal-d-un-agent.md +12 -1 | @@ -50,9 +50,20 @@ Le lien doit mener à un fichier du dossier de l'agent : un chemin relatif au do | ||
| 50 | 50 | - **Clic droit** sur une entrée : un menu avec toutes ces actions, et **Afficher l'emplacement**. |
| 51 | 51 | - **Supprimer** : survolez l'entrée et cliquez sur **🗑** (ou **Delete** sous l'éditeur, ou appuyez sur **Suppr** — ⌘⌫ sur Mac — dans l'arbre), puis confirmez ; avec plusieurs entrées sélectionnées, une seule confirmation suffit. Sur cet ordinateur, le fichier part à la corbeille — récupérez-le depuis le Finder si besoin. Dans un conteneur, la suppression est définitive, et la confirmation le dit. |
| 52 | 52 | |
| 53 | +## Donner ses instructions à l'agent | |
| 54 | + | |
| 55 | +Un agent lit ses **instructions** au début de sa session : son rôle, son ton, ses règles, dans un fichier Markdown de son dossier — `AGENTS.md` pour la plupart des agents, `CLAUDE.md` pour Claude (issue #113). Ouvrez l'onglet **Instructions** du workspace de l'agent : | |
| 56 | + | |
| 57 | +- **Créer depuis un modèle** : quand l'agent n'en a pas encore, Sidekicks écrit un court modèle à son nom (son rôle, comment il répond, ses règles). Complétez-le avec des mots simples. | |
| 58 | +- Modifiez le texte dans l'éditeur de l'onglet, puis **Enregistrer** (⌘S, Ctrl+S sous Linux et Windows) ; **Annuler les changements** abandonne vos modifications. Si le fichier a changé entre-temps — l'agent peut l'écrire aussi —, Sidekicks le dit et n'écrit rien : **Recharger**, puis refaites vos changements. | |
| 59 | +- **Importer un fichier…** copie un fichier texte de cet ordinateur comme instructions de l'agent (il les remplace, après confirmation). | |
| 60 | +- L'agent lit ses instructions au début de sa session : s'il tourne, **Redémarrer l'agent** pour qu'il utilise les nouvelles. | |
| 61 | + | |
| 62 | +Le fichier d'instructions reste protégé dans l'onglet **Fichiers** (ci-dessous) : seul l'onglet **Instructions** l'écrit, et rien ne le supprime. C'est pareil pour un agent sur cet ordinateur, dans un conteneur Docker ou dans une sandbox sbx. | |
| 63 | + | |
| 53 | 64 | ## Protéger des fichiers |
| 54 | 65 | |
| 55 | -Certains fichiers ne doivent pas être modifiés ou supprimés par erreur. Sans rien écrire, les instructions de l'agent (`AGENTS.md`), ses skills (`skills/` et tout ce qu'il contient), son fichier de configuration (après `--config` ou `serve acp` dans ses `args`) et, pour un agent en conteneur ou en sandbox, les fichiers à partir desquels il est construit (`compose.yaml`, `Dockerfile`, `sbxenv.yaml` cités par son `runtime.lifecycle`) sont protégés. Pour en protéger d'autres, listez-les sous l'agent dans **Settings** : | |
| 66 | +Certains fichiers ne doivent pas être modifiés ou supprimés par erreur. Sans rien écrire, les instructions de l'agent (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md` — écrites seulement depuis l'onglet **Instructions**), ses skills (`skills/` et tout ce qu'il contient), son fichier de configuration (après `--config` ou `serve acp` dans ses `args`) et, pour un agent en conteneur ou en sandbox, les fichiers à partir desquels il est construit (`compose.yaml`, `Dockerfile`, `sbxenv.yaml` cités par son `runtime.lifecycle`) sont protégés. Pour en protéger d'autres, listez-les sous l'agent dans **Settings** : | |
| 56 | 67 | |
| 57 | 68 | ```yaml |
| 58 | 69 | - name: milo |
| @@ -50,9 +50,20 @@ Le lien doit mener à un fichier du dossier de l'agent : un chemin relatif au do | |||
| 50 | - **Clic droit** sur une entrée : un menu avec toutes ces actions, et **Afficher l'emplacement**. | 50 | - **Clic droit** sur une entrée : un menu avec toutes ces actions, et **Afficher l'emplacement**. |
| 51 | - **Supprimer** : survolez l'entrée et cliquez sur **🗑** (ou **Delete** sous l'éditeur, ou appuyez sur **Suppr** — ⌘⌫ sur Mac — dans l'arbre), puis confirmez ; avec plusieurs entrées sélectionnées, une seule confirmation suffit. Sur cet ordinateur, le fichier part à la corbeille — récupérez-le depuis le Finder si besoin. Dans un conteneur, la suppression est définitive, et la confirmation le dit. | 51 | - **Supprimer** : survolez l'entrée et cliquez sur **🗑** (ou **Delete** sous l'éditeur, ou appuyez sur **Suppr** — ⌘⌫ sur Mac — dans l'arbre), puis confirmez ; avec plusieurs entrées sélectionnées, une seule confirmation suffit. Sur cet ordinateur, le fichier part à la corbeille — récupérez-le depuis le Finder si besoin. Dans un conteneur, la suppression est définitive, et la confirmation le dit. |
| 52 | 52 | ||
| 53 | +## Donner ses instructions à l'agent | ||
| 54 | + | ||
| 55 | +Un agent lit ses **instructions** au début de sa session : son rôle, son ton, ses règles, dans un fichier Markdown de son dossier — `AGENTS.md` pour la plupart des agents, `CLAUDE.md` pour Claude (issue #113). Ouvrez l'onglet **Instructions** du workspace de l'agent : | ||
| 56 | + | ||
| 57 | +- **Créer depuis un modèle** : quand l'agent n'en a pas encore, Sidekicks écrit un court modèle à son nom (son rôle, comment il répond, ses règles). Complétez-le avec des mots simples. | ||
| 58 | +- Modifiez le texte dans l'éditeur de l'onglet, puis **Enregistrer** (⌘S, Ctrl+S sous Linux et Windows) ; **Annuler les changements** abandonne vos modifications. Si le fichier a changé entre-temps — l'agent peut l'écrire aussi —, Sidekicks le dit et n'écrit rien : **Recharger**, puis refaites vos changements. | ||
| 59 | +- **Importer un fichier…** copie un fichier texte de cet ordinateur comme instructions de l'agent (il les remplace, après confirmation). | ||
| 60 | +- L'agent lit ses instructions au début de sa session : s'il tourne, **Redémarrer l'agent** pour qu'il utilise les nouvelles. | ||
| 61 | + | ||
| 62 | +Le fichier d'instructions reste protégé dans l'onglet **Fichiers** (ci-dessous) : seul l'onglet **Instructions** l'écrit, et rien ne le supprime. C'est pareil pour un agent sur cet ordinateur, dans un conteneur Docker ou dans une sandbox sbx. | ||
| 63 | + | ||
| 53 | ## Protéger des fichiers | 64 | ## Protéger des fichiers |
| 54 | 65 | ||
| 55 | -Certains fichiers ne doivent pas être modifiés ou supprimés par erreur. Sans rien écrire, les instructions de l'agent (`AGENTS.md`), ses skills (`skills/` et tout ce qu'il contient), son fichier de configuration (après `--config` ou `serve acp` dans ses `args`) et, pour un agent en conteneur ou en sandbox, les fichiers à partir desquels il est construit (`compose.yaml`, `Dockerfile`, `sbxenv.yaml` cités par son `runtime.lifecycle`) sont protégés. Pour en protéger d'autres, listez-les sous l'agent dans **Settings** : | 66 | +Certains fichiers ne doivent pas être modifiés ou supprimés par erreur. Sans rien écrire, les instructions de l'agent (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md` — écrites seulement depuis l'onglet **Instructions**), ses skills (`skills/` et tout ce qu'il contient), son fichier de configuration (après `--config` ou `serve acp` dans ses `args`) et, pour un agent en conteneur ou en sandbox, les fichiers à partir desquels il est construit (`compose.yaml`, `Dockerfile`, `sbxenv.yaml` cités par son `runtime.lifecycle`) sont protégés. Pour en protéger d'autres, listez-les sous l'agent dans **Settings** : |
| 56 | 67 | ||
| 57 | ```yaml | 68 | ```yaml |
| 58 | - name: milo | 69 | - name: milo |
modified
docs/fr/reference/agents-et-evenements.md +2 -0 | @@ -190,6 +190,8 @@ Un fichier ouvert pour modification a `path, content, version` ; `version` ident | ||
| 190 | 190 | | `Info(agent)` | `{location, problem, revealable}` : où est le dossier (`local · /chemin`, `container nom · /chemin`), ou pourquoi il ne peut pas être affiché ; `revealable` si le dossier est sur cet ordinateur (issue #74). | |
| 191 | 191 | | `List(agent, dir)` | Les entrées de `dir` (`""` est le dossier), dossiers d'abord, puis par nom. | |
| 192 | 192 | | `Read(agent, path)` | Un fichier texte de 1 Mo au plus ; un fichier binaire ou plus gros est une erreur. | |
| 193 | +| `Instructions(agent)` | Les instructions de l'agent (issue #113) : `{file, exists, content, version, files}` — le premier de `files` (d'après son programme : `CLAUDE.md` puis `AGENTS.md` pour Claude, `AGENTS.md` puis `GEMINI.md` pour Antigravity, sinon `AGENTS.md`) qui existe à la racine de son dossier, sinon le premier, à créer. | | |
| 194 | +| `CreateInstructions(agent, content)`, `SaveInstructions(agent, content, version)`, `ImportInstructions(agent, hostPath)`, `ChooseInstructions()` | Écrivent le fichier d'instructions — seul moyen de le faire, puisqu'il est protégé (`protect`) : depuis un modèle (refusé s'il existe), modifié par-dessus `version` (`{instructions, conflict}` ; `conflict` et rien d'écrit s'il a changé), ou copié depuis un fichier texte UTF-8 de cet ordinateur (1 Mio au plus ; il le remplace). Jamais supprimé. | | |
| 193 | 195 | | `Save(agent, path, content, version)` | Écrit le fichier s'il a toujours `version` ; sinon `{conflict: true}` et rien n'est écrit. Une `version` vide écrase. Le fichier est écrit à côté puis déplacé à sa place. | |
| 194 | 196 | | `Create(agent, dir, name)` | Crée un fichier vide ; refusé si le nom existe ou contient `/`. | |
| 195 | 197 | | `Remove(agent, path)` | Supprime un fichier ou un dossier avec son contenu (voir le tableau ci-dessus). | |
| @@ -190,6 +190,8 @@ Un fichier ouvert pour modification a `path, content, version` ; `version` ident | |||
| 190 | | `Info(agent)` | `{location, problem, revealable}` : où est le dossier (`local · /chemin`, `container nom · /chemin`), ou pourquoi il ne peut pas être affiché ; `revealable` si le dossier est sur cet ordinateur (issue #74). | | 190 | | `Info(agent)` | `{location, problem, revealable}` : où est le dossier (`local · /chemin`, `container nom · /chemin`), ou pourquoi il ne peut pas être affiché ; `revealable` si le dossier est sur cet ordinateur (issue #74). | |
| 191 | | `List(agent, dir)` | Les entrées de `dir` (`""` est le dossier), dossiers d'abord, puis par nom. | | 191 | | `List(agent, dir)` | Les entrées de `dir` (`""` est le dossier), dossiers d'abord, puis par nom. | |
| 192 | | `Read(agent, path)` | Un fichier texte de 1 Mo au plus ; un fichier binaire ou plus gros est une erreur. | | 192 | | `Read(agent, path)` | Un fichier texte de 1 Mo au plus ; un fichier binaire ou plus gros est une erreur. | |
| 193 | +| `Instructions(agent)` | Les instructions de l'agent (issue #113) : `{file, exists, content, version, files}` — le premier de `files` (d'après son programme : `CLAUDE.md` puis `AGENTS.md` pour Claude, `AGENTS.md` puis `GEMINI.md` pour Antigravity, sinon `AGENTS.md`) qui existe à la racine de son dossier, sinon le premier, à créer. | | ||
| 194 | +| `CreateInstructions(agent, content)`, `SaveInstructions(agent, content, version)`, `ImportInstructions(agent, hostPath)`, `ChooseInstructions()` | Écrivent le fichier d'instructions — seul moyen de le faire, puisqu'il est protégé (`protect`) : depuis un modèle (refusé s'il existe), modifié par-dessus `version` (`{instructions, conflict}` ; `conflict` et rien d'écrit s'il a changé), ou copié depuis un fichier texte UTF-8 de cet ordinateur (1 Mio au plus ; il le remplace). Jamais supprimé. | | ||
| 193 | | `Save(agent, path, content, version)` | Écrit le fichier s'il a toujours `version` ; sinon `{conflict: true}` et rien n'est écrit. Une `version` vide écrase. Le fichier est écrit à côté puis déplacé à sa place. | | 195 | | `Save(agent, path, content, version)` | Écrit le fichier s'il a toujours `version` ; sinon `{conflict: true}` et rien n'est écrit. Une `version` vide écrase. Le fichier est écrit à côté puis déplacé à sa place. | |
| 194 | | `Create(agent, dir, name)` | Crée un fichier vide ; refusé si le nom existe ou contient `/`. | | 196 | | `Create(agent, dir, name)` | Crée un fichier vide ; refusé si le nom existe ou contient `/`. | |
| 195 | | `Remove(agent, path)` | Supprime un fichier ou un dossier avec son contenu (voir le tableau ci-dessus). | | 197 | | `Remove(agent, path)` | Supprime un fichier ou un dossier avec son contenu (voir le tableau ci-dessus). | |
modified
docs/fr/reference/configuration.md +1 -1 | @@ -90,7 +90,7 @@ agentTools: | ||
| 90 | 90 | | `env` | dictionnaire texte → texte | non | | Variables d'environnement supplémentaires. | |
| 91 | 91 | | `afterStop` | liste de textes, au moins un | non | | Commande lancée à chaque fin du processus de l'agent — arrêt, crash, arrêt pour faire de la place, ou fermeture de Sidekicks : le programme (un nom seul est cherché dans le PATH, un chemin est relatif à ce fichier), puis ses arguments. Elle tourne dans `workspace` avec `env`, 30 s au plus ; sa sortie va dans le journal de l'agent ; Sidekicks l'attend avant de se fermer. Un programme introuvable est un avertissement. Exemple : `[../scripts/agents.sh, unload, alice]` pour décharger le modèle. | |
| 92 | 92 | | `workspace` | chemin | non | le dossier de la configuration | Le dossier de l'agent : le processus y démarre et c'est le `cwd` de ses sessions ACP. mm y lit `AGENTS.md` et `skills/`. | |
| 93 | -| `protect` | liste de textes | non | | Fichiers du dossier de l'agent que l'interface (onglet Files) ne peut ni modifier ni supprimer : chemins relatifs au dossier, ou motifs où `*` et `?` remplacent des caractères d'un nom et `**` un nombre quelconque de dossiers (`[AGENTS.md, "skills/**"]`). Un dossier qui contient un fichier protégé ne peut pas être supprimé. Toujours protégés, s'ils sont dans son dossier : `AGENTS.md`, `skills/**`, le fichier de configuration de l'agent (l'argument qui suit `--config`, `-config` ou `serve acp` dans `args`), et les fichiers à partir desquels `runtime.lifecycle` construit le conteneur ou la sandbox — le fichier Compose (après `-f`/`--file`, ou `compose.yaml`… sans lui), le `Dockerfile` du dossier des commandes pour un conteneur, le fichier d'environnement sbx (`sbxenv.yaml` ou celui nommé). Seule la configuration lève une protection ; l'agent lui-même, le terminal ou le Finder n'y sont pas soumis. | | |
| 93 | +| `protect` | liste de textes | non | | Fichiers du dossier de l'agent que l'interface (onglet Files) ne peut ni modifier ni supprimer : chemins relatifs au dossier, ou motifs où `*` et `?` remplacent des caractères d'un nom et `**` un nombre quelconque de dossiers (`[AGENTS.md, "skills/**"]`). Un dossier qui contient un fichier protégé ne peut pas être supprimé. Toujours protégés, s'ils sont dans son dossier : `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` (les instructions de l'agent, écrites seulement par son onglet Instructions, issue #113), `skills/**`, le fichier de configuration de l'agent (l'argument qui suit `--config`, `-config` ou `serve acp` dans `args`), et les fichiers à partir desquels `runtime.lifecycle` construit le conteneur ou la sandbox — le fichier Compose (après `-f`/`--file`, ou `compose.yaml`… sans lui), le `Dockerfile` du dossier des commandes pour un conteneur, le fichier d'environnement sbx (`sbxenv.yaml` ou celui nommé). Seule la configuration lève une protection ; l'agent lui-même, le terminal ou le Finder n'y sont pas soumis. | | |
| 94 | 94 | | `runtime` | objet | non | `{type: local}` | Où tourne l'agent (voir ci-dessous). | |
| 95 | 95 | |
| 96 | 96 | ### `runtime` |
| @@ -90,7 +90,7 @@ agentTools: | |||
| 90 | | `env` | dictionnaire texte → texte | non | | Variables d'environnement supplémentaires. | | 90 | | `env` | dictionnaire texte → texte | non | | Variables d'environnement supplémentaires. | |
| 91 | | `afterStop` | liste de textes, au moins un | non | | Commande lancée à chaque fin du processus de l'agent — arrêt, crash, arrêt pour faire de la place, ou fermeture de Sidekicks : le programme (un nom seul est cherché dans le PATH, un chemin est relatif à ce fichier), puis ses arguments. Elle tourne dans `workspace` avec `env`, 30 s au plus ; sa sortie va dans le journal de l'agent ; Sidekicks l'attend avant de se fermer. Un programme introuvable est un avertissement. Exemple : `[../scripts/agents.sh, unload, alice]` pour décharger le modèle. | | 91 | | `afterStop` | liste de textes, au moins un | non | | Commande lancée à chaque fin du processus de l'agent — arrêt, crash, arrêt pour faire de la place, ou fermeture de Sidekicks : le programme (un nom seul est cherché dans le PATH, un chemin est relatif à ce fichier), puis ses arguments. Elle tourne dans `workspace` avec `env`, 30 s au plus ; sa sortie va dans le journal de l'agent ; Sidekicks l'attend avant de se fermer. Un programme introuvable est un avertissement. Exemple : `[../scripts/agents.sh, unload, alice]` pour décharger le modèle. | |
| 92 | | `workspace` | chemin | non | le dossier de la configuration | Le dossier de l'agent : le processus y démarre et c'est le `cwd` de ses sessions ACP. mm y lit `AGENTS.md` et `skills/`. | | 92 | | `workspace` | chemin | non | le dossier de la configuration | Le dossier de l'agent : le processus y démarre et c'est le `cwd` de ses sessions ACP. mm y lit `AGENTS.md` et `skills/`. | |
| 93 | -| `protect` | liste de textes | non | | Fichiers du dossier de l'agent que l'interface (onglet Files) ne peut ni modifier ni supprimer : chemins relatifs au dossier, ou motifs où `*` et `?` remplacent des caractères d'un nom et `**` un nombre quelconque de dossiers (`[AGENTS.md, "skills/**"]`). Un dossier qui contient un fichier protégé ne peut pas être supprimé. Toujours protégés, s'ils sont dans son dossier : `AGENTS.md`, `skills/**`, le fichier de configuration de l'agent (l'argument qui suit `--config`, `-config` ou `serve acp` dans `args`), et les fichiers à partir desquels `runtime.lifecycle` construit le conteneur ou la sandbox — le fichier Compose (après `-f`/`--file`, ou `compose.yaml`… sans lui), le `Dockerfile` du dossier des commandes pour un conteneur, le fichier d'environnement sbx (`sbxenv.yaml` ou celui nommé). Seule la configuration lève une protection ; l'agent lui-même, le terminal ou le Finder n'y sont pas soumis. | | 93 | +| `protect` | liste de textes | non | | Fichiers du dossier de l'agent que l'interface (onglet Files) ne peut ni modifier ni supprimer : chemins relatifs au dossier, ou motifs où `*` et `?` remplacent des caractères d'un nom et `**` un nombre quelconque de dossiers (`[AGENTS.md, "skills/**"]`). Un dossier qui contient un fichier protégé ne peut pas être supprimé. Toujours protégés, s'ils sont dans son dossier : `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` (les instructions de l'agent, écrites seulement par son onglet Instructions, issue #113), `skills/**`, le fichier de configuration de l'agent (l'argument qui suit `--config`, `-config` ou `serve acp` dans `args`), et les fichiers à partir desquels `runtime.lifecycle` construit le conteneur ou la sandbox — le fichier Compose (après `-f`/`--file`, ou `compose.yaml`… sans lui), le `Dockerfile` du dossier des commandes pour un conteneur, le fichier d'environnement sbx (`sbxenv.yaml` ou celui nommé). Seule la configuration lève une protection ; l'agent lui-même, le terminal ou le Finder n'y sont pas soumis. | |
| 94 | | `runtime` | objet | non | `{type: local}` | Où tourne l'agent (voir ci-dessous). | | 94 | | `runtime` | objet | non | `{type: local}` | Où tourne l'agent (voir ci-dessous). | |
| 95 | 95 | ||
| 96 | ### `runtime` | 96 | ### `runtime` |
modified
docs/release-notes/v1.7.0.fr.md +7 -0 | @@ -13,6 +13,13 @@ Brouillon — complété au fil des tickets de la 1.7.0. | ||
| 13 | 13 | |
| 14 | 14 | → [Les fichiers et le terminal d'un agent](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/fr/how-to/fichiers-et-terminal-d-un-agent.md) |
| 15 | 15 | |
| 16 | +### Donner ses instructions à un agent (#113) | |
| 17 | + | |
| 18 | +- Un nouvel onglet **Instructions** dans le workspace d'un agent montre le fichier où il lit ses instructions — `AGENTS.md`, ou `CLAUDE.md` pour Claude : créez-le depuis un modèle, modifiez-le et enregistrez-le, ou importez un fichier de cet ordinateur. Quand l'agent tourne, **Redémarrer l'agent** lui fait lire les nouvelles instructions. | |
| 19 | +- Les fichiers d'instructions — `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` — restent protégés dans l'onglet Fichiers : seul l'onglet Instructions les écrit, et rien ne les supprime. | |
| 20 | + | |
| 21 | +→ [Les fichiers et le terminal d'un agent](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/fr/how-to/fichiers-et-terminal-d-un-agent.md) | |
| 22 | + | |
| 16 | 23 | ### Petits changements |
| 17 | 24 | |
| 18 | 25 | - Le code d'un fichier dont un agent donne le lien dans sa réponse est maintenant coloré dans le panneau à côté de la conversation, comme dans l'onglet Fichiers, en lecture seule (#117). |
| @@ -13,6 +13,13 @@ Brouillon — complété au fil des tickets de la 1.7.0. | |||
| 13 | 13 | ||
| 14 | → [Les fichiers et le terminal d'un agent](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/fr/how-to/fichiers-et-terminal-d-un-agent.md) | 14 | → [Les fichiers et le terminal d'un agent](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/fr/how-to/fichiers-et-terminal-d-un-agent.md) |
| 15 | 15 | ||
| 16 | +### Donner ses instructions à un agent (#113) | ||
| 17 | + | ||
| 18 | +- Un nouvel onglet **Instructions** dans le workspace d'un agent montre le fichier où il lit ses instructions — `AGENTS.md`, ou `CLAUDE.md` pour Claude : créez-le depuis un modèle, modifiez-le et enregistrez-le, ou importez un fichier de cet ordinateur. Quand l'agent tourne, **Redémarrer l'agent** lui fait lire les nouvelles instructions. | ||
| 19 | +- Les fichiers d'instructions — `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` — restent protégés dans l'onglet Fichiers : seul l'onglet Instructions les écrit, et rien ne les supprime. | ||
| 20 | + | ||
| 21 | +→ [Les fichiers et le terminal d'un agent](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/fr/how-to/fichiers-et-terminal-d-un-agent.md) | ||
| 22 | + | ||
| 16 | ### Petits changements | 23 | ### Petits changements |
| 17 | 24 | ||
| 18 | - Le code d'un fichier dont un agent donne le lien dans sa réponse est maintenant coloré dans le panneau à côté de la conversation, comme dans l'onglet Fichiers, en lecture seule (#117). | 25 | - Le code d'un fichier dont un agent donne le lien dans sa réponse est maintenant coloré dans le panneau à côté de la conversation, comme dans l'onglet Fichiers, en lecture seule (#117). |
modified
docs/release-notes/v1.7.0.md +7 -0 | @@ -13,6 +13,13 @@ Draft — completed as the 1.7.0 tickets are done. | ||
| 13 | 13 | |
| 14 | 14 | → [Work with an agent's files and terminal](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/en/how-to/work-with-an-agents-files.md#preview-a-document-or-an-image) |
| 15 | 15 | |
| 16 | +### Give an agent its instructions (#113) | |
| 17 | + | |
| 18 | +- A new **Instructions** tab in an agent's workspace shows the file it reads its instructions in — `AGENTS.md`, or `CLAUDE.md` for Claude: create it from a template, edit and save it, or import a file of this computer. When the agent is running, **Restart the agent** makes it read the new instructions. | |
| 19 | +- The instruction files — `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` — stay protected in the Files tab: only the Instructions tab writes them, and nothing deletes them. | |
| 20 | + | |
| 21 | +→ [Work with an agent's files and terminal](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/en/how-to/work-with-an-agents-files.md#give-the-agent-its-instructions) | |
| 22 | + | |
| 16 | 23 | ### Smaller changes |
| 17 | 24 | |
| 18 | 25 | - The code of a file an agent links to in its answer is now coloured in the panel beside the conversation, like in the Files tab, read-only (#117). |
| @@ -13,6 +13,13 @@ Draft — completed as the 1.7.0 tickets are done. | |||
| 13 | 13 | ||
| 14 | → [Work with an agent's files and terminal](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/en/how-to/work-with-an-agents-files.md#preview-a-document-or-an-image) | 14 | → [Work with an agent's files and terminal](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/en/how-to/work-with-an-agents-files.md#preview-a-document-or-an-image) |
| 15 | 15 | ||
| 16 | +### Give an agent its instructions (#113) | ||
| 17 | + | ||
| 18 | +- A new **Instructions** tab in an agent's workspace shows the file it reads its instructions in — `AGENTS.md`, or `CLAUDE.md` for Claude: create it from a template, edit and save it, or import a file of this computer. When the agent is running, **Restart the agent** makes it read the new instructions. | ||
| 19 | +- The instruction files — `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` — stay protected in the Files tab: only the Instructions tab writes them, and nothing deletes them. | ||
| 20 | + | ||
| 21 | +→ [Work with an agent's files and terminal](https://rickub.com/bots-garden/sidekicks/blob/v1.7.0/docs/en/how-to/work-with-an-agents-files.md#give-the-agent-its-instructions) | ||
| 22 | + | ||
| 16 | ### Smaller changes | 23 | ### Smaller changes |
| 17 | 24 | ||
| 18 | - The code of a file an agent links to in its answer is now coloured in the panel beside the conversation, like in the Files tab, read-only (#117). | 25 | - The code of a file an agent links to in its answer is now coloured in the panel beside the conversation, like in the Files tab, read-only (#117). |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/app/index.ts +2 -0 | @@ -28,6 +28,8 @@ export type { | ||
| 28 | 28 | CreatorFinish, |
| 29 | 29 | CreatorResult, |
| 30 | 30 | CreatorStart, |
| 31 | + Instructions, | |
| 32 | + InstructionsSave, | |
| 31 | 33 | LinkedFile, |
| 32 | 34 | OlderView, |
| 33 | 35 | ProblemView, |
| @@ -28,6 +28,8 @@ export type { | |||
| 28 | CreatorFinish, | 28 | CreatorFinish, |
| 29 | CreatorResult, | 29 | CreatorResult, |
| 30 | CreatorStart, | 30 | CreatorStart, |
| 31 | + Instructions, | ||
| 32 | + InstructionsSave, | ||
| 31 | LinkedFile, | 33 | LinkedFile, |
| 32 | OlderView, | 34 | OlderView, |
| 33 | ProblemView, | 35 | ProblemView, |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/app/models.ts +30 -0 | @@ -170,6 +170,36 @@ export interface CreatorStart { | ||
| 170 | 170 | "taken": string[] | null; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | +/** | |
| 174 | + * Instructions is where an agent's instructions are: File, at the root of | |
| 175 | + * its folder, and whether it exists (Content then holds it). | |
| 176 | + */ | |
| 177 | +export interface Instructions { | |
| 178 | + "file": string; | |
| 179 | + "exists": boolean; | |
| 180 | + "content": string; | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * Version is the version of the file read (workspace.File.Version). | |
| 184 | + */ | |
| 185 | + "version": string; | |
| 186 | + | |
| 187 | + /** | |
| 188 | + * Files is every file the agent reads, the one created first. | |
| 189 | + */ | |
| 190 | + "files": string[] | null; | |
| 191 | +} | |
| 192 | + | |
| 193 | +/** | |
| 194 | + * InstructionsSave is the result of SaveInstructions: the instructions | |
| 195 | + * written, or Conflict when the file changed since it was read (by the agent, | |
| 196 | + * or in another window) — nothing was written then. | |
| 197 | + */ | |
| 198 | +export interface InstructionsSave { | |
| 199 | + "instructions": Instructions; | |
| 200 | + "conflict": boolean; | |
| 201 | +} | |
| 202 | + | |
| 173 | 203 | /** |
| 174 | 204 | * LinkedFile is the file of an agent's folder a link of its answer leads to |
| 175 | 205 | * (issue #65). |
| @@ -170,6 +170,36 @@ export interface CreatorStart { | |||
| 170 | "taken": string[] | null; | 170 | "taken": string[] | null; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | +/** | ||
| 174 | + * Instructions is where an agent's instructions are: File, at the root of | ||
| 175 | + * its folder, and whether it exists (Content then holds it). | ||
| 176 | + */ | ||
| 177 | +export interface Instructions { | ||
| 178 | + "file": string; | ||
| 179 | + "exists": boolean; | ||
| 180 | + "content": string; | ||
| 181 | + | ||
| 182 | + /** | ||
| 183 | + * Version is the version of the file read (workspace.File.Version). | ||
| 184 | + */ | ||
| 185 | + "version": string; | ||
| 186 | + | ||
| 187 | + /** | ||
| 188 | + * Files is every file the agent reads, the one created first. | ||
| 189 | + */ | ||
| 190 | + "files": string[] | null; | ||
| 191 | +} | ||
| 192 | + | ||
| 193 | +/** | ||
| 194 | + * InstructionsSave is the result of SaveInstructions: the instructions | ||
| 195 | + * written, or Conflict when the file changed since it was read (by the agent, | ||
| 196 | + * or in another window) — nothing was written then. | ||
| 197 | + */ | ||
| 198 | +export interface InstructionsSave { | ||
| 199 | + "instructions": Instructions; | ||
| 200 | + "conflict": boolean; | ||
| 201 | +} | ||
| 202 | + | ||
| 173 | /** | 203 | /** |
| 174 | * LinkedFile is the file of an agent's folder a link of its answer leads to | 204 | * LinkedFile is the file of an agent's folder a link of its answer leads to |
| 175 | * (issue #65). | 205 | * (issue #65). |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/app/workspaceservice.ts +40 -0 | @@ -42,6 +42,14 @@ export function ChooseAttachment(): $CancellablePromise<string> { | ||
| 42 | 42 | return $Call.ByID(1274488746); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | +/** | |
| 46 | + * ChooseInstructions asks the user for a text file to import as an agent's | |
| 47 | + * instructions, starting in their home folder; "" when they cancelled. | |
| 48 | + */ | |
| 49 | +export function ChooseInstructions(): $CancellablePromise<string> { | |
| 50 | + return $Call.ByID(4180143450); | |
| 51 | +} | |
| 52 | + | |
| 45 | 53 | /** |
| 46 | 54 | * Create creates an empty file in folder dir. |
| 47 | 55 | */ |
| @@ -57,6 +65,14 @@ export function CreateFolder(agent: string, dir: string, name: string): $Cancell | ||
| 57 | 65 | return $Call.ByID(3711526042, agent, dir, name); |
| 58 | 66 | } |
| 59 | 67 | |
| 68 | +/** | |
| 69 | + * CreateInstructions writes content — a template the interface fills in — | |
| 70 | + * as the agent's instructions; ErrInstructionsExist when it has some. | |
| 71 | + */ | |
| 72 | +export function CreateInstructions(agent: string, content: string): $CancellablePromise<$models.Instructions> { | |
| 73 | + return $Call.ByID(623963639, agent, content); | |
| 74 | +} | |
| 75 | + | |
| 60 | 76 | /** |
| 61 | 77 | * Duplicate copies files and folders next to themselves, under a free name |
| 62 | 78 | * with "-copy" before the extension (plan.md → plan-copy.md, then |
| @@ -80,6 +96,14 @@ export function Image(agent: string, file: string): $CancellablePromise<string> | ||
| 80 | 96 | return $Call.ByID(1806569915, agent, file); |
| 81 | 97 | } |
| 82 | 98 | |
| 99 | +/** | |
| 100 | + * ImportInstructions copies a text file of this computer as the agent's | |
| 101 | + * instructions, replacing them if it has some (the interface asks first). | |
| 102 | + */ | |
| 103 | +export function ImportInstructions(agent: string, hostPath: string): $CancellablePromise<$models.Instructions> { | |
| 104 | + return $Call.ByID(1158620406, agent, hostPath); | |
| 105 | +} | |
| 106 | + | |
| 83 | 107 | /** |
| 84 | 108 | * Info describes the agent's folder. |
| 85 | 109 | */ |
| @@ -87,6 +111,14 @@ export function Info(agent: string): $CancellablePromise<$models.WorkspaceInfo> | ||
| 87 | 111 | return $Call.ByID(573611494, agent); |
| 88 | 112 | } |
| 89 | 113 | |
| 114 | +/** | |
| 115 | + * Instructions tells which instruction file the agent reads: the first of | |
| 116 | + * its files that exists, else the one to create. | |
| 117 | + */ | |
| 118 | +export function Instructions(agent: string): $CancellablePromise<$models.Instructions> { | |
| 119 | + return $Call.ByID(3864547483, agent); | |
| 120 | +} | |
| 121 | + | |
| 90 | 122 | /** |
| 91 | 123 | * Link finds the file of agent's folder that href, a link of one of its |
| 92 | 124 | * answers, leads to: a relative path, an absolute path in its folder (as |
| @@ -166,6 +198,14 @@ export function Save(agent: string, file: string, content: string, version: stri | ||
| 166 | 198 | return $Call.ByID(60595059, agent, file, content, version); |
| 167 | 199 | } |
| 168 | 200 | |
| 201 | +/** | |
| 202 | + * SaveInstructions writes the agent's instructions edited in its | |
| 203 | + * Instructions tab, over the version read; an empty version overwrites. | |
| 204 | + */ | |
| 205 | +export function SaveInstructions(agent: string, content: string, version: string): $CancellablePromise<$models.InstructionsSave> { | |
| 206 | + return $Call.ByID(1925077950, agent, content, version); | |
| 207 | +} | |
| 208 | + | |
| 169 | 209 | /** |
| 170 | 210 | * Unwatch stops following changes. |
| 171 | 211 | */ |
| @@ -42,6 +42,14 @@ export function ChooseAttachment(): $CancellablePromise<string> { | |||
| 42 | return $Call.ByID(1274488746); | 42 | return $Call.ByID(1274488746); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | +/** | ||
| 46 | + * ChooseInstructions asks the user for a text file to import as an agent's | ||
| 47 | + * instructions, starting in their home folder; "" when they cancelled. | ||
| 48 | + */ | ||
| 49 | +export function ChooseInstructions(): $CancellablePromise<string> { | ||
| 50 | + return $Call.ByID(4180143450); | ||
| 51 | +} | ||
| 52 | + | ||
| 45 | /** | 53 | /** |
| 46 | * Create creates an empty file in folder dir. | 54 | * Create creates an empty file in folder dir. |
| 47 | */ | 55 | */ |
| @@ -57,6 +65,14 @@ export function CreateFolder(agent: string, dir: string, name: string): $Cancell | |||
| 57 | return $Call.ByID(3711526042, agent, dir, name); | 65 | return $Call.ByID(3711526042, agent, dir, name); |
| 58 | } | 66 | } |
| 59 | 67 | ||
| 68 | +/** | ||
| 69 | + * CreateInstructions writes content — a template the interface fills in — | ||
| 70 | + * as the agent's instructions; ErrInstructionsExist when it has some. | ||
| 71 | + */ | ||
| 72 | +export function CreateInstructions(agent: string, content: string): $CancellablePromise<$models.Instructions> { | ||
| 73 | + return $Call.ByID(623963639, agent, content); | ||
| 74 | +} | ||
| 75 | + | ||
| 60 | /** | 76 | /** |
| 61 | * Duplicate copies files and folders next to themselves, under a free name | 77 | * Duplicate copies files and folders next to themselves, under a free name |
| 62 | * with "-copy" before the extension (plan.md → plan-copy.md, then | 78 | * with "-copy" before the extension (plan.md → plan-copy.md, then |
| @@ -80,6 +96,14 @@ export function Image(agent: string, file: string): $CancellablePromise<string> | |||
| 80 | return $Call.ByID(1806569915, agent, file); | 96 | return $Call.ByID(1806569915, agent, file); |
| 81 | } | 97 | } |
| 82 | 98 | ||
| 99 | +/** | ||
| 100 | + * ImportInstructions copies a text file of this computer as the agent's | ||
| 101 | + * instructions, replacing them if it has some (the interface asks first). | ||
| 102 | + */ | ||
| 103 | +export function ImportInstructions(agent: string, hostPath: string): $CancellablePromise<$models.Instructions> { | ||
| 104 | + return $Call.ByID(1158620406, agent, hostPath); | ||
| 105 | +} | ||
| 106 | + | ||
| 83 | /** | 107 | /** |
| 84 | * Info describes the agent's folder. | 108 | * Info describes the agent's folder. |
| 85 | */ | 109 | */ |
| @@ -87,6 +111,14 @@ export function Info(agent: string): $CancellablePromise<$models.WorkspaceInfo> | |||
| 87 | return $Call.ByID(573611494, agent); | 111 | return $Call.ByID(573611494, agent); |
| 88 | } | 112 | } |
| 89 | 113 | ||
| 114 | +/** | ||
| 115 | + * Instructions tells which instruction file the agent reads: the first of | ||
| 116 | + * its files that exists, else the one to create. | ||
| 117 | + */ | ||
| 118 | +export function Instructions(agent: string): $CancellablePromise<$models.Instructions> { | ||
| 119 | + return $Call.ByID(3864547483, agent); | ||
| 120 | +} | ||
| 121 | + | ||
| 90 | /** | 122 | /** |
| 91 | * Link finds the file of agent's folder that href, a link of one of its | 123 | * Link finds the file of agent's folder that href, a link of one of its |
| 92 | * answers, leads to: a relative path, an absolute path in its folder (as | 124 | * answers, leads to: a relative path, an absolute path in its folder (as |
| @@ -166,6 +198,14 @@ export function Save(agent: string, file: string, content: string, version: stri | |||
| 166 | return $Call.ByID(60595059, agent, file, content, version); | 198 | return $Call.ByID(60595059, agent, file, content, version); |
| 167 | } | 199 | } |
| 168 | 200 | ||
| 201 | +/** | ||
| 202 | + * SaveInstructions writes the agent's instructions edited in its | ||
| 203 | + * Instructions tab, over the version read; an empty version overwrites. | ||
| 204 | + */ | ||
| 205 | +export function SaveInstructions(agent: string, content: string, version: string): $CancellablePromise<$models.InstructionsSave> { | ||
| 206 | + return $Call.ByID(1925077950, agent, content, version); | ||
| 207 | +} | ||
| 208 | + | ||
| 169 | /** | 209 | /** |
| 170 | * Unwatch stops following changes. | 210 | * Unwatch stops following changes. |
| 171 | */ | 211 | */ |
modified
frontend/src/lib/agent/AgentView.svelte +7 -3 | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | <script lang="ts" module> |
| 3 | 3 | // The tab shown last for each agent: coming back to an agent shows its |
| 4 | 4 | // terminals again if they were in view (issue #72). |
| 5 | - const lastTab: Record<string, 'files' | 'terminal' | 'log'> = {} | |
| 5 | + const lastTab: Record<string, 'files' | 'instructions' | 'terminal' | 'log'> = {} | |
| 6 | 6 | </script> |
| 7 | 7 | |
| 8 | 8 | <script lang="ts"> |
| @@ -17,6 +17,7 @@ | ||
| 17 | 17 | import AgentLog from './AgentLog.svelte' |
| 18 | 18 | import FilesTab from './FilesTab.svelte' |
| 19 | 19 | import TerminalView from './TerminalView.svelte' |
| 20 | + import InstructionsTab from './InstructionsTab.svelte' | |
| 20 | 21 | import { signInKey } from '../signin' |
| 21 | 22 | import ErrorText from '../chat/ErrorText.svelte' |
| 22 | 23 | import { activeTerminal, closeTerminal, newTerminal, runningTerminals, terminalsOf } from '../terminalSessions.svelte' |
| @@ -29,7 +30,7 @@ | ||
| 29 | 30 | const channels = $derived(appState.channels.filter((channel) => !channel.direct && channel.members?.includes(name)).map((channel) => '#' + channel.name)) |
| 30 | 31 | const stateKey = $derived(`agent.state.${agent?.state ?? ''}`) |
| 31 | 32 | |
| 32 | - type Tab = 'files' | 'terminal' | 'log' | |
| 33 | + type Tab = 'files' | 'instructions' | 'terminal' | 'log' | |
| 33 | 34 | // svelte-ignore state_referenced_locally |
| 34 | 35 | let tab: Tab = $state(lastTab[name] ?? 'files') |
| 35 | 36 | // The terminals of the agent (issues #72 and #73) live outside this view: |
| @@ -118,7 +119,7 @@ | ||
| 118 | 119 | {/if} |
| 119 | 120 | |
| 120 | 121 | <div class="tabs" role="tablist"> |
| 121 | - {#each ['files', 'terminal', 'log'] as const as each (each)} | |
| 122 | + {#each ['files', 'instructions', 'terminal', 'log'] as const as each (each)} | |
| 122 | 123 | <button role="tab" aria-selected={tab === each} class:active={tab === each} onclick={() => show(each)}> |
| 123 | 124 | {t(`workspace.tab.${each}`)}{#if each === 'terminal' && runningTerminals(name) > 0}<span class="count" title={t('terminal.running', { count: runningTerminals(name) })}>{runningTerminals(name)}</span>{/if} |
| 124 | 125 | </button> |
| @@ -134,6 +135,9 @@ | ||
| 134 | 135 | <div class="pane" class:hidden={tab !== 'files'}> |
| 135 | 136 | <FilesTab agent={name} inContainer={!location.startsWith('local')} {revealable} /> |
| 136 | 137 | </div> |
| 138 | + {#if tab === 'instructions'} | |
| 139 | + <div class="pane"><InstructionsTab agent={name} /></div> | |
| 140 | + {/if} | |
| 137 | 141 | {#if tab === 'terminal'} |
| 138 | 142 | <div class="pane terminals"> |
| 139 | 143 | {#if appState.signInAgent === name} |
| @@ -2,7 +2,7 @@ | |||
| 2 | <script lang="ts" module> | 2 | <script lang="ts" module> |
| 3 | // The tab shown last for each agent: coming back to an agent shows its | 3 | // The tab shown last for each agent: coming back to an agent shows its |
| 4 | // terminals again if they were in view (issue #72). | 4 | // terminals again if they were in view (issue #72). |
| 5 | - const lastTab: Record<string, 'files' | 'terminal' | 'log'> = {} | 5 | + const lastTab: Record<string, 'files' | 'instructions' | 'terminal' | 'log'> = {} |
| 6 | </script> | 6 | </script> |
| 7 | 7 | ||
| 8 | <script lang="ts"> | 8 | <script lang="ts"> |
| @@ -17,6 +17,7 @@ | |||
| 17 | import AgentLog from './AgentLog.svelte' | 17 | import AgentLog from './AgentLog.svelte' |
| 18 | import FilesTab from './FilesTab.svelte' | 18 | import FilesTab from './FilesTab.svelte' |
| 19 | import TerminalView from './TerminalView.svelte' | 19 | import TerminalView from './TerminalView.svelte' |
| 20 | + import InstructionsTab from './InstructionsTab.svelte' | ||
| 20 | import { signInKey } from '../signin' | 21 | import { signInKey } from '../signin' |
| 21 | import ErrorText from '../chat/ErrorText.svelte' | 22 | import ErrorText from '../chat/ErrorText.svelte' |
| 22 | import { activeTerminal, closeTerminal, newTerminal, runningTerminals, terminalsOf } from '../terminalSessions.svelte' | 23 | import { activeTerminal, closeTerminal, newTerminal, runningTerminals, terminalsOf } from '../terminalSessions.svelte' |
| @@ -29,7 +30,7 @@ | |||
| 29 | const channels = $derived(appState.channels.filter((channel) => !channel.direct && channel.members?.includes(name)).map((channel) => '#' + channel.name)) | 30 | const channels = $derived(appState.channels.filter((channel) => !channel.direct && channel.members?.includes(name)).map((channel) => '#' + channel.name)) |
| 30 | const stateKey = $derived(`agent.state.${agent?.state ?? ''}`) | 31 | const stateKey = $derived(`agent.state.${agent?.state ?? ''}`) |
| 31 | 32 | ||
| 32 | - type Tab = 'files' | 'terminal' | 'log' | 33 | + type Tab = 'files' | 'instructions' | 'terminal' | 'log' |
| 33 | // svelte-ignore state_referenced_locally | 34 | // svelte-ignore state_referenced_locally |
| 34 | let tab: Tab = $state(lastTab[name] ?? 'files') | 35 | let tab: Tab = $state(lastTab[name] ?? 'files') |
| 35 | // The terminals of the agent (issues #72 and #73) live outside this view: | 36 | // The terminals of the agent (issues #72 and #73) live outside this view: |
| @@ -118,7 +119,7 @@ | |||
| 118 | {/if} | 119 | {/if} |
| 119 | 120 | ||
| 120 | <div class="tabs" role="tablist"> | 121 | <div class="tabs" role="tablist"> |
| 121 | - {#each ['files', 'terminal', 'log'] as const as each (each)} | 122 | + {#each ['files', 'instructions', 'terminal', 'log'] as const as each (each)} |
| 122 | <button role="tab" aria-selected={tab === each} class:active={tab === each} onclick={() => show(each)}> | 123 | <button role="tab" aria-selected={tab === each} class:active={tab === each} onclick={() => show(each)}> |
| 123 | {t(`workspace.tab.${each}`)}{#if each === 'terminal' && runningTerminals(name) > 0}<span class="count" title={t('terminal.running', { count: runningTerminals(name) })}>{runningTerminals(name)}</span>{/if} | 124 | {t(`workspace.tab.${each}`)}{#if each === 'terminal' && runningTerminals(name) > 0}<span class="count" title={t('terminal.running', { count: runningTerminals(name) })}>{runningTerminals(name)}</span>{/if} |
| 124 | </button> | 125 | </button> |
| @@ -134,6 +135,9 @@ | |||
| 134 | <div class="pane" class:hidden={tab !== 'files'}> | 135 | <div class="pane" class:hidden={tab !== 'files'}> |
| 135 | <FilesTab agent={name} inContainer={!location.startsWith('local')} {revealable} /> | 136 | <FilesTab agent={name} inContainer={!location.startsWith('local')} {revealable} /> |
| 136 | </div> | 137 | </div> |
| 138 | + {#if tab === 'instructions'} | ||
| 139 | + <div class="pane"><InstructionsTab agent={name} /></div> | ||
| 140 | + {/if} | ||
| 137 | {#if tab === 'terminal'} | 141 | {#if tab === 'terminal'} |
| 138 | <div class="pane terminals"> | 142 | <div class="pane terminals"> |
| 139 | {#if appState.signInAgent === name} | 143 | {#if appState.signInAgent === name} |
added
frontend/src/lib/agent/InstructionsTab.svelte +157 -0 | new file mode 100644 | ||
| @@ -0,0 +1,157 @@ | ||
| 1 | +<!-- Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE --> | |
| 2 | +<script lang="ts"> | |
| 3 | + // An agent's instructions (issue #113): the AGENTS.md — or CLAUDE.md for | |
| 4 | + // Claude — of its folder, which it reads when its session starts. Created | |
| 5 | + // from a template, edited here, or imported from a file of this computer. | |
| 6 | + // The file is protected in the Files tab; this tab is the one place that | |
| 7 | + // writes it (the owner's choice), and never removes it. | |
| 8 | + import { onMount } from 'svelte' | |
| 9 | + import { AgentService, WorkspaceService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | |
| 10 | + import type { Instructions } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | |
| 11 | + import { t } from '../i18n/index.svelte' | |
| 12 | + import { act, appState } from '../state.svelte' | |
| 13 | + import { instructionsTemplate } from '../instructions' | |
| 14 | + import ErrorText from '../chat/ErrorText.svelte' | |
| 15 | + import FileEditor from './FileEditor.svelte' | |
| 16 | + | |
| 17 | + let { agent }: { agent: string } = $props() | |
| 18 | + | |
| 19 | + const status = $derived(appState.agents.find((candidate) => candidate.name === agent)) | |
| 20 | + const running = $derived(['ready', 'busy'].includes(status?.state ?? '')) | |
| 21 | + let info = $state<Instructions | null>(null) | |
| 22 | + let text = $state('') | |
| 23 | + let problem = $state('') | |
| 24 | + let conflict = $state(false) | |
| 25 | + let busy = $state(false) | |
| 26 | + // Written since the agent started: it reads them at its next session. | |
| 27 | + let written = $state(false) | |
| 28 | + let confirmingImport = $state(false) | |
| 29 | + const dirty = $derived(info !== null && info.exists && text !== info.content) | |
| 30 | + | |
| 31 | + function errorOf(error: unknown): string { | |
| 32 | + return error instanceof Error ? error.message : String(error) | |
| 33 | + } | |
| 34 | + | |
| 35 | + function show(next: Instructions | null) { | |
| 36 | + if (!next) return | |
| 37 | + info = next | |
| 38 | + text = next.content | |
| 39 | + conflict = false | |
| 40 | + } | |
| 41 | + | |
| 42 | + async function load() { | |
| 43 | + problem = '' | |
| 44 | + try { | |
| 45 | + show(await WorkspaceService.Instructions(agent)) | |
| 46 | + } catch (error) { | |
| 47 | + problem = errorOf(error) | |
| 48 | + } | |
| 49 | + } | |
| 50 | + onMount(load) | |
| 51 | + | |
| 52 | + async function run(action: () => Promise<Instructions | null>) { | |
| 53 | + busy = true | |
| 54 | + problem = '' | |
| 55 | + try { | |
| 56 | + show(await action()) | |
| 57 | + written = true | |
| 58 | + } catch (error) { | |
| 59 | + problem = errorOf(error) | |
| 60 | + } finally { | |
| 61 | + busy = false | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 65 | + const create = () => run(() => WorkspaceService.CreateInstructions(agent, instructionsTemplate(status?.title || agent))) | |
| 66 | + | |
| 67 | + async function save() { | |
| 68 | + if (!info || !dirty) return | |
| 69 | + busy = true | |
| 70 | + problem = '' | |
| 71 | + try { | |
| 72 | + const result = await WorkspaceService.SaveInstructions(agent, text, info.version) | |
| 73 | + if (result?.conflict) conflict = true | |
| 74 | + else { | |
| 75 | + show(result?.instructions ?? null) | |
| 76 | + written = true | |
| 77 | + } | |
| 78 | + } catch (error) { | |
| 79 | + problem = errorOf(error) | |
| 80 | + } finally { | |
| 81 | + busy = false | |
| 82 | + } | |
| 83 | + } | |
| 84 | + | |
| 85 | + async function importFile() { | |
| 86 | + confirmingImport = false | |
| 87 | + const path = await WorkspaceService.ChooseInstructions().catch((error) => ((problem = errorOf(error)), '')) | |
| 88 | + if (path) await run(() => WorkspaceService.ImportInstructions(agent, path)) | |
| 89 | + } | |
| 90 | + | |
| 91 | + function restart() { | |
| 92 | + written = false | |
| 93 | + void act(() => AgentService.Restart(agent)) | |
| 94 | + } | |
| 95 | +</script> | |
| 96 | + | |
| 97 | +<div class="instructions"> | |
| 98 | + {#if info} | |
| 99 | + <p class="intro">{t('instructions.intro', { agent: status?.title || agent, file: info.file })}</p> | |
| 100 | + {#if problem}<div class="problem" role="alert"><ErrorText raw={problem} /></div>{/if} | |
| 101 | + {#if written && running} | |
| 102 | + <div class="note" role="status"> | |
| 103 | + <span>{t('instructions.restart', { agent: status?.title || agent })}</span> | |
| 104 | + <button type="button" onclick={restart}>{t('instructions.restartButton')}</button> | |
| 105 | + </div> | |
| 106 | + {/if} | |
| 107 | + {#if info.exists} | |
| 108 | + {#if conflict} | |
| 109 | + <div class="problem" role="alert"> | |
| 110 | + {t('instructions.conflict', { file: info.file })} | |
| 111 | + <button type="button" onclick={load}>{t('instructions.reload')}</button> | |
| 112 | + </div> | |
| 113 | + {/if} | |
| 114 | + <div class="editor"> | |
| 115 | + {#key info.version} | |
| 116 | + <FileEditor content={info.content} language="markdown" onChange={(next) => (text = next)} onSave={save} /> | |
| 117 | + {/key} | |
| 118 | + </div> | |
| 119 | + <div class="actions"> | |
| 120 | + {#if confirmingImport} | |
| 121 | + <span class="warning">{t('instructions.importReplaces', { file: info.file })}</span> | |
| 122 | + <button type="button" class="primary" onclick={importFile}>{t('instructions.importYes')}</button> | |
| 123 | + <button type="button" onclick={() => (confirmingImport = false)}>{t('creator.cancel')}</button> | |
| 124 | + {:else} | |
| 125 | + <button type="button" onclick={() => (confirmingImport = true)} disabled={busy}>{t('instructions.import')}</button> | |
| 126 | + <span class="grow"></span> | |
| 127 | + <button type="button" onclick={() => show(info)} disabled={busy || !dirty}>{t('instructions.revert')}</button> | |
| 128 | + <button type="button" class="primary" onclick={save} disabled={busy || !dirty}>{t('instructions.save')}</button> | |
| 129 | + {/if} | |
| 130 | + </div> | |
| 131 | + {:else} | |
| 132 | + <p>{t('instructions.none', { file: info.file })}</p> | |
| 133 | + <div class="actions"> | |
| 134 | + <button type="button" class="primary" onclick={create} disabled={busy}>{t('instructions.create')}</button> | |
| 135 | + <button type="button" onclick={importFile} disabled={busy}>{t('instructions.import')}</button> | |
| 136 | + </div> | |
| 137 | + {/if} | |
| 138 | + {:else if problem} | |
| 139 | + <div class="problem" role="alert"><ErrorText raw={problem} /></div> | |
| 140 | + {:else} | |
| 141 | + <p class="muted">…</p> | |
| 142 | + {/if} | |
| 143 | +</div> | |
| 144 | + | |
| 145 | +<style> | |
| 146 | + .instructions { height: 100%; display: flex; flex-direction: column; gap: 10px; min-height: 0; } | |
| 147 | + .intro, p { margin: 0; } | |
| 148 | + .intro, .muted { color: var(--muted); font-size: 13px; } | |
| 149 | + .editor { flex: 1; min-height: 160px; } | |
| 150 | + .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } | |
| 151 | + .grow { flex: 1; } | |
| 152 | + .note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--accent); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; } | |
| 153 | + .note span { flex: 1; min-width: 200px; } | |
| 154 | + .problem { border: 1px solid var(--danger); border-radius: var(--radius); color: var(--danger); padding: 8px 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } | |
| 155 | + .warning { color: var(--warn); font-size: 13px; } | |
| 156 | + .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } | |
| 157 | +</style> | |
| new file mode 100644 | |||
| @@ -0,0 +1,157 @@ | |||
| 1 | +<!-- Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE --> | ||
| 2 | +<script lang="ts"> | ||
| 3 | + // An agent's instructions (issue #113): the AGENTS.md — or CLAUDE.md for | ||
| 4 | + // Claude — of its folder, which it reads when its session starts. Created | ||
| 5 | + // from a template, edited here, or imported from a file of this computer. | ||
| 6 | + // The file is protected in the Files tab; this tab is the one place that | ||
| 7 | + // writes it (the owner's choice), and never removes it. | ||
| 8 | + import { onMount } from 'svelte' | ||
| 9 | + import { AgentService, WorkspaceService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | ||
| 10 | + import type { Instructions } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | ||
| 11 | + import { t } from '../i18n/index.svelte' | ||
| 12 | + import { act, appState } from '../state.svelte' | ||
| 13 | + import { instructionsTemplate } from '../instructions' | ||
| 14 | + import ErrorText from '../chat/ErrorText.svelte' | ||
| 15 | + import FileEditor from './FileEditor.svelte' | ||
| 16 | + | ||
| 17 | + let { agent }: { agent: string } = $props() | ||
| 18 | + | ||
| 19 | + const status = $derived(appState.agents.find((candidate) => candidate.name === agent)) | ||
| 20 | + const running = $derived(['ready', 'busy'].includes(status?.state ?? '')) | ||
| 21 | + let info = $state<Instructions | null>(null) | ||
| 22 | + let text = $state('') | ||
| 23 | + let problem = $state('') | ||
| 24 | + let conflict = $state(false) | ||
| 25 | + let busy = $state(false) | ||
| 26 | + // Written since the agent started: it reads them at its next session. | ||
| 27 | + let written = $state(false) | ||
| 28 | + let confirmingImport = $state(false) | ||
| 29 | + const dirty = $derived(info !== null && info.exists && text !== info.content) | ||
| 30 | + | ||
| 31 | + function errorOf(error: unknown): string { | ||
| 32 | + return error instanceof Error ? error.message : String(error) | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + function show(next: Instructions | null) { | ||
| 36 | + if (!next) return | ||
| 37 | + info = next | ||
| 38 | + text = next.content | ||
| 39 | + conflict = false | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + async function load() { | ||
| 43 | + problem = '' | ||
| 44 | + try { | ||
| 45 | + show(await WorkspaceService.Instructions(agent)) | ||
| 46 | + } catch (error) { | ||
| 47 | + problem = errorOf(error) | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + onMount(load) | ||
| 51 | + | ||
| 52 | + async function run(action: () => Promise<Instructions | null>) { | ||
| 53 | + busy = true | ||
| 54 | + problem = '' | ||
| 55 | + try { | ||
| 56 | + show(await action()) | ||
| 57 | + written = true | ||
| 58 | + } catch (error) { | ||
| 59 | + problem = errorOf(error) | ||
| 60 | + } finally { | ||
| 61 | + busy = false | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + const create = () => run(() => WorkspaceService.CreateInstructions(agent, instructionsTemplate(status?.title || agent))) | ||
| 66 | + | ||
| 67 | + async function save() { | ||
| 68 | + if (!info || !dirty) return | ||
| 69 | + busy = true | ||
| 70 | + problem = '' | ||
| 71 | + try { | ||
| 72 | + const result = await WorkspaceService.SaveInstructions(agent, text, info.version) | ||
| 73 | + if (result?.conflict) conflict = true | ||
| 74 | + else { | ||
| 75 | + show(result?.instructions ?? null) | ||
| 76 | + written = true | ||
| 77 | + } | ||
| 78 | + } catch (error) { | ||
| 79 | + problem = errorOf(error) | ||
| 80 | + } finally { | ||
| 81 | + busy = false | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + async function importFile() { | ||
| 86 | + confirmingImport = false | ||
| 87 | + const path = await WorkspaceService.ChooseInstructions().catch((error) => ((problem = errorOf(error)), '')) | ||
| 88 | + if (path) await run(() => WorkspaceService.ImportInstructions(agent, path)) | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + function restart() { | ||
| 92 | + written = false | ||
| 93 | + void act(() => AgentService.Restart(agent)) | ||
| 94 | + } | ||
| 95 | +</script> | ||
| 96 | + | ||
| 97 | +<div class="instructions"> | ||
| 98 | + {#if info} | ||
| 99 | + <p class="intro">{t('instructions.intro', { agent: status?.title || agent, file: info.file })}</p> | ||
| 100 | + {#if problem}<div class="problem" role="alert"><ErrorText raw={problem} /></div>{/if} | ||
| 101 | + {#if written && running} | ||
| 102 | + <div class="note" role="status"> | ||
| 103 | + <span>{t('instructions.restart', { agent: status?.title || agent })}</span> | ||
| 104 | + <button type="button" onclick={restart}>{t('instructions.restartButton')}</button> | ||
| 105 | + </div> | ||
| 106 | + {/if} | ||
| 107 | + {#if info.exists} | ||
| 108 | + {#if conflict} | ||
| 109 | + <div class="problem" role="alert"> | ||
| 110 | + {t('instructions.conflict', { file: info.file })} | ||
| 111 | + <button type="button" onclick={load}>{t('instructions.reload')}</button> | ||
| 112 | + </div> | ||
| 113 | + {/if} | ||
| 114 | + <div class="editor"> | ||
| 115 | + {#key info.version} | ||
| 116 | + <FileEditor content={info.content} language="markdown" onChange={(next) => (text = next)} onSave={save} /> | ||
| 117 | + {/key} | ||
| 118 | + </div> | ||
| 119 | + <div class="actions"> | ||
| 120 | + {#if confirmingImport} | ||
| 121 | + <span class="warning">{t('instructions.importReplaces', { file: info.file })}</span> | ||
| 122 | + <button type="button" class="primary" onclick={importFile}>{t('instructions.importYes')}</button> | ||
| 123 | + <button type="button" onclick={() => (confirmingImport = false)}>{t('creator.cancel')}</button> | ||
| 124 | + {:else} | ||
| 125 | + <button type="button" onclick={() => (confirmingImport = true)} disabled={busy}>{t('instructions.import')}</button> | ||
| 126 | + <span class="grow"></span> | ||
| 127 | + <button type="button" onclick={() => show(info)} disabled={busy || !dirty}>{t('instructions.revert')}</button> | ||
| 128 | + <button type="button" class="primary" onclick={save} disabled={busy || !dirty}>{t('instructions.save')}</button> | ||
| 129 | + {/if} | ||
| 130 | + </div> | ||
| 131 | + {:else} | ||
| 132 | + <p>{t('instructions.none', { file: info.file })}</p> | ||
| 133 | + <div class="actions"> | ||
| 134 | + <button type="button" class="primary" onclick={create} disabled={busy}>{t('instructions.create')}</button> | ||
| 135 | + <button type="button" onclick={importFile} disabled={busy}>{t('instructions.import')}</button> | ||
| 136 | + </div> | ||
| 137 | + {/if} | ||
| 138 | + {:else if problem} | ||
| 139 | + <div class="problem" role="alert"><ErrorText raw={problem} /></div> | ||
| 140 | + {:else} | ||
| 141 | + <p class="muted">…</p> | ||
| 142 | + {/if} | ||
| 143 | +</div> | ||
| 144 | + | ||
| 145 | +<style> | ||
| 146 | + .instructions { height: 100%; display: flex; flex-direction: column; gap: 10px; min-height: 0; } | ||
| 147 | + .intro, p { margin: 0; } | ||
| 148 | + .intro, .muted { color: var(--muted); font-size: 13px; } | ||
| 149 | + .editor { flex: 1; min-height: 160px; } | ||
| 150 | + .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } | ||
| 151 | + .grow { flex: 1; } | ||
| 152 | + .note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--accent); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; } | ||
| 153 | + .note span { flex: 1; min-width: 200px; } | ||
| 154 | + .problem { border: 1px solid var(--danger); border-radius: var(--radius); color: var(--danger); padding: 8px 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } | ||
| 155 | + .warning { color: var(--warn); font-size: 13px; } | ||
| 156 | + .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } | ||
| 157 | +</style> | ||
modified
frontend/src/lib/i18n/messages.ts +28 -0 | @@ -271,6 +271,20 @@ export const en = { | ||
| 271 | 271 | 'workspace.tab.files': 'Files', |
| 272 | 272 | 'workspace.tab.terminal': 'Terminal', |
| 273 | 273 | 'workspace.tab.log': 'Log', |
| 274 | + 'workspace.tab.instructions': 'Instructions', | |
| 275 | + 'instructions.intro': '{agent} reads its instructions in {file}, in its folder, when its session starts: its role, its tone, its rules. Write them in plain words.', | |
| 276 | + 'instructions.none': 'There is no {file} yet. Start from a template, or import a file you already have.', | |
| 277 | + 'instructions.create': 'Create from a template', | |
| 278 | + 'instructions.import': 'Import a file…', | |
| 279 | + 'instructions.importReplaces': 'The imported file replaces {file}.', | |
| 280 | + 'instructions.importYes': 'Choose the file…', | |
| 281 | + 'instructions.save': 'Save', | |
| 282 | + 'instructions.revert': 'Revert', | |
| 283 | + 'instructions.conflict': '{file} changed since it was opened (the agent may have written it). Reload it, then make your changes again.', | |
| 284 | + 'instructions.reload': 'Reload', | |
| 285 | + 'instructions.restart': '{agent} reads its instructions when its session starts: restart it so that it uses the new ones.', | |
| 286 | + 'instructions.restartButton': 'Restart the agent', | |
| 287 | + 'instructions.template': '# {agent}\n\n## Your role\n\nYou help me with … (say what the agent is for).\n\n## How you answer\n\n- In English, clearly and briefly.\n- Ask a question when something is not clear.\n\n## Rules\n\n- Ask before deleting or replacing a file.\n- Say when you are not sure.\n', | |
| 274 | 288 | 'workspace.conversation': '💬 Conversation', |
| 275 | 289 | 'workspace.start': '▶ Start', |
| 276 | 290 | 'workspace.restart': '↻ Restart', |
| @@ -799,6 +813,20 @@ export const fr: Record<MessageKey, string> = { | ||
| 799 | 813 | 'workspace.tab.files': 'Fichiers', |
| 800 | 814 | 'workspace.tab.terminal': 'Terminal', |
| 801 | 815 | 'workspace.tab.log': 'Journal', |
| 816 | + 'workspace.tab.instructions': 'Instructions', | |
| 817 | + 'instructions.intro': "{agent} lit ses instructions dans {file}, dans son dossier, au début de sa session : son rôle, son ton, ses règles. Écrivez-les avec des mots simples.", | |
| 818 | + 'instructions.none': "Il n'y a pas encore de {file}. Partez d'un modèle, ou importez un fichier que vous avez déjà.", | |
| 819 | + 'instructions.create': "Créer depuis un modèle", | |
| 820 | + 'instructions.import': 'Importer un fichier…', | |
| 821 | + 'instructions.importReplaces': 'Le fichier importé remplace {file}.', | |
| 822 | + 'instructions.importYes': 'Choisir le fichier…', | |
| 823 | + 'instructions.save': 'Enregistrer', | |
| 824 | + 'instructions.revert': 'Annuler les changements', | |
| 825 | + 'instructions.conflict': "{file} a changé depuis son ouverture (l'agent l'a peut-être écrit). Rechargez-le, puis refaites vos changements.", | |
| 826 | + 'instructions.reload': 'Recharger', | |
| 827 | + 'instructions.restart': "{agent} lit ses instructions au début de sa session : redémarrez-le pour qu'il utilise les nouvelles.", | |
| 828 | + 'instructions.restartButton': "Redémarrer l'agent", | |
| 829 | + 'instructions.template': "# {agent}\n\n## Ton rôle\n\nTu m'aides à … (dites à quoi sert l'agent).\n\n## Comment tu réponds\n\n- En français, clairement et brièvement.\n- Pose une question quand quelque chose n'est pas clair.\n\n## Règles\n\n- Demande avant de supprimer ou de remplacer un fichier.\n- Dis-le quand tu n'es pas sûr.\n", | |
| 802 | 830 | 'workspace.conversation': '💬 Conversation', |
| 803 | 831 | 'workspace.start': '▶ Démarrer', |
| 804 | 832 | 'workspace.restart': '↻ Redémarrer', |
| @@ -271,6 +271,20 @@ export const en = { | |||
| 271 | 'workspace.tab.files': 'Files', | 271 | 'workspace.tab.files': 'Files', |
| 272 | 'workspace.tab.terminal': 'Terminal', | 272 | 'workspace.tab.terminal': 'Terminal', |
| 273 | 'workspace.tab.log': 'Log', | 273 | 'workspace.tab.log': 'Log', |
| 274 | + 'workspace.tab.instructions': 'Instructions', | ||
| 275 | + 'instructions.intro': '{agent} reads its instructions in {file}, in its folder, when its session starts: its role, its tone, its rules. Write them in plain words.', | ||
| 276 | + 'instructions.none': 'There is no {file} yet. Start from a template, or import a file you already have.', | ||
| 277 | + 'instructions.create': 'Create from a template', | ||
| 278 | + 'instructions.import': 'Import a file…', | ||
| 279 | + 'instructions.importReplaces': 'The imported file replaces {file}.', | ||
| 280 | + 'instructions.importYes': 'Choose the file…', | ||
| 281 | + 'instructions.save': 'Save', | ||
| 282 | + 'instructions.revert': 'Revert', | ||
| 283 | + 'instructions.conflict': '{file} changed since it was opened (the agent may have written it). Reload it, then make your changes again.', | ||
| 284 | + 'instructions.reload': 'Reload', | ||
| 285 | + 'instructions.restart': '{agent} reads its instructions when its session starts: restart it so that it uses the new ones.', | ||
| 286 | + 'instructions.restartButton': 'Restart the agent', | ||
| 287 | + 'instructions.template': '# {agent}\n\n## Your role\n\nYou help me with … (say what the agent is for).\n\n## How you answer\n\n- In English, clearly and briefly.\n- Ask a question when something is not clear.\n\n## Rules\n\n- Ask before deleting or replacing a file.\n- Say when you are not sure.\n', | ||
| 274 | 'workspace.conversation': '💬 Conversation', | 288 | 'workspace.conversation': '💬 Conversation', |
| 275 | 'workspace.start': '▶ Start', | 289 | 'workspace.start': '▶ Start', |
| 276 | 'workspace.restart': '↻ Restart', | 290 | 'workspace.restart': '↻ Restart', |
| @@ -799,6 +813,20 @@ export const fr: Record<MessageKey, string> = { | |||
| 799 | 'workspace.tab.files': 'Fichiers', | 813 | 'workspace.tab.files': 'Fichiers', |
| 800 | 'workspace.tab.terminal': 'Terminal', | 814 | 'workspace.tab.terminal': 'Terminal', |
| 801 | 'workspace.tab.log': 'Journal', | 815 | 'workspace.tab.log': 'Journal', |
| 816 | + 'workspace.tab.instructions': 'Instructions', | ||
| 817 | + 'instructions.intro': "{agent} lit ses instructions dans {file}, dans son dossier, au début de sa session : son rôle, son ton, ses règles. Écrivez-les avec des mots simples.", | ||
| 818 | + 'instructions.none': "Il n'y a pas encore de {file}. Partez d'un modèle, ou importez un fichier que vous avez déjà.", | ||
| 819 | + 'instructions.create': "Créer depuis un modèle", | ||
| 820 | + 'instructions.import': 'Importer un fichier…', | ||
| 821 | + 'instructions.importReplaces': 'Le fichier importé remplace {file}.', | ||
| 822 | + 'instructions.importYes': 'Choisir le fichier…', | ||
| 823 | + 'instructions.save': 'Enregistrer', | ||
| 824 | + 'instructions.revert': 'Annuler les changements', | ||
| 825 | + 'instructions.conflict': "{file} a changé depuis son ouverture (l'agent l'a peut-être écrit). Rechargez-le, puis refaites vos changements.", | ||
| 826 | + 'instructions.reload': 'Recharger', | ||
| 827 | + 'instructions.restart': "{agent} lit ses instructions au début de sa session : redémarrez-le pour qu'il utilise les nouvelles.", | ||
| 828 | + 'instructions.restartButton': "Redémarrer l'agent", | ||
| 829 | + 'instructions.template': "# {agent}\n\n## Ton rôle\n\nTu m'aides à … (dites à quoi sert l'agent).\n\n## Comment tu réponds\n\n- En français, clairement et brièvement.\n- Pose une question quand quelque chose n'est pas clair.\n\n## Règles\n\n- Demande avant de supprimer ou de remplacer un fichier.\n- Dis-le quand tu n'es pas sûr.\n", | ||
| 802 | 'workspace.conversation': '💬 Conversation', | 830 | 'workspace.conversation': '💬 Conversation', |
| 803 | 'workspace.start': '▶ Démarrer', | 831 | 'workspace.start': '▶ Démarrer', |
| 804 | 'workspace.restart': '↻ Redémarrer', | 832 | 'workspace.restart': '↻ Redémarrer', |
added
frontend/src/lib/instructions.test.ts +16 -0 | new file mode 100644 | ||
| @@ -0,0 +1,16 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | +import { describe, expect, it } from 'vitest' | |
| 3 | +import { instructionsTemplate } from './instructions' | |
| 4 | +import { setLanguage } from './i18n/index.svelte' | |
| 5 | + | |
| 6 | +describe('the template of an agent\'s instructions (issue #113)', () => { | |
| 7 | + it('is Markdown named after the agent, in the language of the interface', () => { | |
| 8 | + setLanguage('en') | |
| 9 | + const english = instructionsTemplate('Marcel') | |
| 10 | + expect(english.startsWith('# Marcel\n\n## Your role\n')).toBe(true) | |
| 11 | + expect(english).toContain('- Ask before deleting or replacing a file.') | |
| 12 | + setLanguage('fr') | |
| 13 | + expect(instructionsTemplate('Marcel')).toContain('## Ton rôle') | |
| 14 | + setLanguage('en') | |
| 15 | + }) | |
| 16 | +}) | |
| new file mode 100644 | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | +import { describe, expect, it } from 'vitest' | ||
| 3 | +import { instructionsTemplate } from './instructions' | ||
| 4 | +import { setLanguage } from './i18n/index.svelte' | ||
| 5 | + | ||
| 6 | +describe('the template of an agent\'s instructions (issue #113)', () => { | ||
| 7 | + it('is Markdown named after the agent, in the language of the interface', () => { | ||
| 8 | + setLanguage('en') | ||
| 9 | + const english = instructionsTemplate('Marcel') | ||
| 10 | + expect(english.startsWith('# Marcel\n\n## Your role\n')).toBe(true) | ||
| 11 | + expect(english).toContain('- Ask before deleting or replacing a file.') | ||
| 12 | + setLanguage('fr') | ||
| 13 | + expect(instructionsTemplate('Marcel')).toContain('## Ton rôle') | ||
| 14 | + setLanguage('en') | ||
| 15 | + }) | ||
| 16 | +}) | ||
added
frontend/src/lib/instructions.ts +17 -0 | new file mode 100644 | ||
| @@ -0,0 +1,17 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +// The template of an agent's instructions (issue #113): a short Markdown | |
| 4 | +// file, in the language of the interface, that a person who is not a | |
| 5 | +// developer can fill in — the agent's role, its tone, its rules. | |
| 6 | + | |
| 7 | +import { t } from './i18n/index.svelte' | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * The instructions a new agent starts with, named after it. | |
| 11 | + * | |
| 12 | + * @example | |
| 13 | + * instructionsTemplate('Marcel') // '# Marcel\n\n## Your role\n…' | |
| 14 | + */ | |
| 15 | +export function instructionsTemplate(agent: string): string { | |
| 16 | + return t('instructions.template', { agent }) | |
| 17 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +// The template of an agent's instructions (issue #113): a short Markdown | ||
| 4 | +// file, in the language of the interface, that a person who is not a | ||
| 5 | +// developer can fill in — the agent's role, its tone, its rules. | ||
| 6 | + | ||
| 7 | +import { t } from './i18n/index.svelte' | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * The instructions a new agent starts with, named after it. | ||
| 11 | + * | ||
| 12 | + * @example | ||
| 13 | + * instructionsTemplate('Marcel') // '# Marcel\n\n## Your role\n…' | ||
| 14 | + */ | ||
| 15 | +export function instructionsTemplate(agent: string): string { | ||
| 16 | + return t('instructions.template', { agent }) | ||
| 17 | +} | ||
added
internal/agents/instructions.go +42 -0 | new file mode 100644 | ||
| @@ -0,0 +1,42 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package agents | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "path" | |
| 7 | + "strings" | |
| 8 | + | |
| 9 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | |
| 10 | +) | |
| 11 | + | |
| 12 | +// An agent's instructions (issue #113): the Markdown file of its folder it | |
| 13 | +// reads when its session starts — its role, its tone, its rules. Most agents | |
| 14 | +// read AGENTS.md (mini-me, Codex, Antigravity, Vibe, Copilot); Claude Code | |
| 15 | +// reads CLAUDE.md first, and AGENTS.md only when there is no CLAUDE.md and | |
| 16 | +// only in its recent versions; Antigravity also reads GEMINI.md. | |
| 17 | + | |
| 18 | +// DefaultInstructions is the file most agents read. | |
| 19 | +const DefaultInstructions = "AGENTS.md" | |
| 20 | + | |
| 21 | +// instructionsByProgram: the files an agent's program reads, the one to | |
| 22 | +// create first. | |
| 23 | +var instructionsByProgram = map[string][]string{ | |
| 24 | + "claude-agent-acp": {"CLAUDE.md", "AGENTS.md"}, | |
| 25 | + "claude": {"CLAUDE.md", "AGENTS.md"}, | |
| 26 | + "agy": {"AGENTS.md", "GEMINI.md"}, | |
| 27 | + "gemini": {"GEMINI.md", "AGENTS.md"}, | |
| 28 | +} | |
| 29 | + | |
| 30 | +// InstructionsFiles is the instruction files definition's agent reads, at | |
| 31 | +// the root of its folder: the first is the one to create when there is none. | |
| 32 | +// | |
| 33 | +// InstructionsFiles(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "claude", "claude-agent-acp"}}) // ["CLAUDE.md", "AGENTS.md"] | |
| 34 | +// InstructionsFiles(config.Agent{Command: "mm", Args: []string{"--acp"}}) // ["AGENTS.md"] | |
| 35 | +func InstructionsFiles(definition config.Agent) []string { | |
| 36 | + for _, word := range append([]string{definition.Command}, definition.Args...) { | |
| 37 | + if files, ok := instructionsByProgram[path.Base(strings.TrimSpace(word))]; ok { | |
| 38 | + return append([]string(nil), files...) | |
| 39 | + } | |
| 40 | + } | |
| 41 | + return []string{DefaultInstructions} | |
| 42 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package agents | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "path" | ||
| 7 | + "strings" | ||
| 8 | + | ||
| 9 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +// An agent's instructions (issue #113): the Markdown file of its folder it | ||
| 13 | +// reads when its session starts — its role, its tone, its rules. Most agents | ||
| 14 | +// read AGENTS.md (mini-me, Codex, Antigravity, Vibe, Copilot); Claude Code | ||
| 15 | +// reads CLAUDE.md first, and AGENTS.md only when there is no CLAUDE.md and | ||
| 16 | +// only in its recent versions; Antigravity also reads GEMINI.md. | ||
| 17 | + | ||
| 18 | +// DefaultInstructions is the file most agents read. | ||
| 19 | +const DefaultInstructions = "AGENTS.md" | ||
| 20 | + | ||
| 21 | +// instructionsByProgram: the files an agent's program reads, the one to | ||
| 22 | +// create first. | ||
| 23 | +var instructionsByProgram = map[string][]string{ | ||
| 24 | + "claude-agent-acp": {"CLAUDE.md", "AGENTS.md"}, | ||
| 25 | + "claude": {"CLAUDE.md", "AGENTS.md"}, | ||
| 26 | + "agy": {"AGENTS.md", "GEMINI.md"}, | ||
| 27 | + "gemini": {"GEMINI.md", "AGENTS.md"}, | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +// InstructionsFiles is the instruction files definition's agent reads, at | ||
| 31 | +// the root of its folder: the first is the one to create when there is none. | ||
| 32 | +// | ||
| 33 | +// InstructionsFiles(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "claude", "claude-agent-acp"}}) // ["CLAUDE.md", "AGENTS.md"] | ||
| 34 | +// InstructionsFiles(config.Agent{Command: "mm", Args: []string{"--acp"}}) // ["AGENTS.md"] | ||
| 35 | +func InstructionsFiles(definition config.Agent) []string { | ||
| 36 | + for _, word := range append([]string{definition.Command}, definition.Args...) { | ||
| 37 | + if files, ok := instructionsByProgram[path.Base(strings.TrimSpace(word))]; ok { | ||
| 38 | + return append([]string(nil), files...) | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + return []string{DefaultInstructions} | ||
| 42 | +} | ||
added
internal/agents/instructions_test.go +30 -0 | new file mode 100644 | ||
| @@ -0,0 +1,30 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package agents_test | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "slices" | |
| 7 | + "testing" | |
| 8 | + | |
| 9 | + "git.rickub.com/bots-garden/sidekicks/internal/agents" | |
| 10 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | |
| 11 | +) | |
| 12 | + | |
| 13 | +// Issue #113: the instruction file each kind of agent reads. | |
| 14 | +func TestInstructionsFilesFollowTheAgentsProgram(t *testing.T) { | |
| 15 | + sbx := config.Runtime{Type: "sbx"} | |
| 16 | + for _, test := range []struct { | |
| 17 | + agent config.Agent | |
| 18 | + want []string | |
| 19 | + }{ | |
| 20 | + {config.Agent{Command: "sbx", Args: []string{"exec", "-i", "claude", "claude-agent-acp"}, Runtime: sbx}, []string{"CLAUDE.md", "AGENTS.md"}}, | |
| 21 | + {config.Agent{Command: "sbx", Args: []string{"exec", "-i", "antigravity", "agy", "acp"}, Runtime: sbx}, []string{"AGENTS.md", "GEMINI.md"}}, | |
| 22 | + {config.Agent{Command: "sbx", Args: []string{"exec", "-i", "codex", "codex-acp"}, Runtime: sbx}, []string{"AGENTS.md"}}, | |
| 23 | + {config.Agent{Command: "/usr/local/bin/mm", Args: []string{"--acp"}}, []string{"AGENTS.md"}}, | |
| 24 | + {config.Agent{Command: "sbx", Args: []string{"exec", "-i", "copilot", "copilot", "--acp", "--stdio"}, Runtime: sbx}, []string{"AGENTS.md"}}, | |
| 25 | + } { | |
| 26 | + if got := agents.InstructionsFiles(test.agent); !slices.Equal(got, test.want) { | |
| 27 | + t.Errorf("%s %v: %v, want %v", test.agent.Command, test.agent.Args, got, test.want) | |
| 28 | + } | |
| 29 | + } | |
| 30 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package agents_test | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "slices" | ||
| 7 | + "testing" | ||
| 8 | + | ||
| 9 | + "git.rickub.com/bots-garden/sidekicks/internal/agents" | ||
| 10 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +// Issue #113: the instruction file each kind of agent reads. | ||
| 14 | +func TestInstructionsFilesFollowTheAgentsProgram(t *testing.T) { | ||
| 15 | + sbx := config.Runtime{Type: "sbx"} | ||
| 16 | + for _, test := range []struct { | ||
| 17 | + agent config.Agent | ||
| 18 | + want []string | ||
| 19 | + }{ | ||
| 20 | + {config.Agent{Command: "sbx", Args: []string{"exec", "-i", "claude", "claude-agent-acp"}, Runtime: sbx}, []string{"CLAUDE.md", "AGENTS.md"}}, | ||
| 21 | + {config.Agent{Command: "sbx", Args: []string{"exec", "-i", "antigravity", "agy", "acp"}, Runtime: sbx}, []string{"AGENTS.md", "GEMINI.md"}}, | ||
| 22 | + {config.Agent{Command: "sbx", Args: []string{"exec", "-i", "codex", "codex-acp"}, Runtime: sbx}, []string{"AGENTS.md"}}, | ||
| 23 | + {config.Agent{Command: "/usr/local/bin/mm", Args: []string{"--acp"}}, []string{"AGENTS.md"}}, | ||
| 24 | + {config.Agent{Command: "sbx", Args: []string{"exec", "-i", "copilot", "copilot", "--acp", "--stdio"}, Runtime: sbx}, []string{"AGENTS.md"}}, | ||
| 25 | + } { | ||
| 26 | + if got := agents.InstructionsFiles(test.agent); !slices.Equal(got, test.want) { | ||
| 27 | + t.Errorf("%s %v: %v, want %v", test.agent.Command, test.agent.Args, got, test.want) | ||
| 28 | + } | ||
| 29 | + } | ||
| 30 | +} | ||
added
internal/app/instructions.go +150 -0 | new file mode 100644 | ||
| @@ -0,0 +1,150 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package app | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "context" | |
| 7 | + "errors" | |
| 8 | + "fmt" | |
| 9 | + "os" | |
| 10 | + "path/filepath" | |
| 11 | + "unicode/utf8" | |
| 12 | + | |
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/agents" | |
| 14 | + "git.rickub.com/bots-garden/sidekicks/internal/workspace" | |
| 15 | +) | |
| 16 | + | |
| 17 | +// An agent's instructions (issue #113): the AGENTS.md (or CLAUDE.md…) of its | |
| 18 | +// folder, created from a template, edited in the Files tab, or imported from | |
| 19 | +// a file of this computer — on this computer, in its container or in its | |
| 20 | +// sandbox alike, through its workspace. | |
| 21 | + | |
| 22 | +// maxInstructionsSize bounds an imported instruction file. | |
| 23 | +const maxInstructionsSize = 1 << 20 | |
| 24 | + | |
| 25 | +// Instructions is where an agent's instructions are: File, at the root of | |
| 26 | +// its folder, and whether it exists (Content then holds it). | |
| 27 | +type Instructions struct { | |
| 28 | + File string `json:"file"` | |
| 29 | + Exists bool `json:"exists"` | |
| 30 | + Content string `json:"content"` | |
| 31 | + // Version is the version of the file read (workspace.File.Version). | |
| 32 | + Version string `json:"version"` | |
| 33 | + // Files is every file the agent reads, the one created first. | |
| 34 | + Files []string `json:"files"` | |
| 35 | +} | |
| 36 | + | |
| 37 | +// ErrInstructionsExist is returned by CreateInstructions when the agent | |
| 38 | +// already has its instructions: they are edited, not replaced. | |
| 39 | +var ErrInstructionsExist = errors.New("the agent already has its instructions") | |
| 40 | + | |
| 41 | +// Instructions tells which instruction file the agent reads: the first of | |
| 42 | +// its files that exists, else the one to create. | |
| 43 | +func (s *WorkspaceService) Instructions(ctx context.Context, agent string) (Instructions, error) { | |
| 44 | + definition, ok := s.Core.manager.Definition(agent) | |
| 45 | + if !ok { | |
| 46 | + return Instructions{}, fmt.Errorf("%w: %s", agents.ErrUnknownAgent, agent) | |
| 47 | + } | |
| 48 | + ws, err := s.Core.workspaceOf(agent) | |
| 49 | + if err != nil { | |
| 50 | + return Instructions{}, err | |
| 51 | + } | |
| 52 | + files := agents.InstructionsFiles(definition) | |
| 53 | + for _, file := range files { | |
| 54 | + read, err := ws.Read(ctx, file) | |
| 55 | + if err == nil { | |
| 56 | + return Instructions{File: file, Exists: true, Content: read.Content, Version: read.Version, Files: files}, nil | |
| 57 | + } | |
| 58 | + if !errors.Is(err, workspace.ErrNotFound) { | |
| 59 | + return Instructions{}, err | |
| 60 | + } | |
| 61 | + } | |
| 62 | + return Instructions{File: files[0], Files: files}, nil | |
| 63 | +} | |
| 64 | + | |
| 65 | +// CreateInstructions writes content — a template the interface fills in — | |
| 66 | +// as the agent's instructions; ErrInstructionsExist when it has some. | |
| 67 | +func (s *WorkspaceService) CreateInstructions(ctx context.Context, agent, content string) (Instructions, error) { | |
| 68 | + current, err := s.Instructions(ctx, agent) | |
| 69 | + if err != nil { | |
| 70 | + return Instructions{}, err | |
| 71 | + } | |
| 72 | + if current.Exists { | |
| 73 | + return current, ErrInstructionsExist | |
| 74 | + } | |
| 75 | + return s.writeInstructions(ctx, agent, current, content) | |
| 76 | +} | |
| 77 | + | |
| 78 | +// ImportInstructions copies a text file of this computer as the agent's | |
| 79 | +// instructions, replacing them if it has some (the interface asks first). | |
| 80 | +func (s *WorkspaceService) ImportInstructions(ctx context.Context, agent, hostPath string) (Instructions, error) { | |
| 81 | + current, err := s.Instructions(ctx, agent) | |
| 82 | + if err != nil { | |
| 83 | + return Instructions{}, err | |
| 84 | + } | |
| 85 | + info, err := os.Stat(hostPath) | |
| 86 | + if err != nil { | |
| 87 | + return Instructions{}, err | |
| 88 | + } | |
| 89 | + if info.IsDir() { | |
| 90 | + return Instructions{}, errors.New("a folder cannot be imported as instructions, only a text file") | |
| 91 | + } | |
| 92 | + if info.Size() > maxInstructionsSize { | |
| 93 | + return Instructions{}, fmt.Errorf("%s: %w (%d MiB at most)", filepath.Base(hostPath), workspace.ErrTooLarge, maxInstructionsSize>>20) | |
| 94 | + } | |
| 95 | + data, err := os.ReadFile(hostPath) | |
| 96 | + if err != nil { | |
| 97 | + return Instructions{}, err | |
| 98 | + } | |
| 99 | + if !utf8.Valid(data) { | |
| 100 | + return Instructions{}, fmt.Errorf("%s is not a text file", filepath.Base(hostPath)) | |
| 101 | + } | |
| 102 | + return s.writeInstructions(ctx, agent, current, string(data)) | |
| 103 | +} | |
| 104 | + | |
| 105 | +// InstructionsSave is the result of SaveInstructions: the instructions | |
| 106 | +// written, or Conflict when the file changed since it was read (by the agent, | |
| 107 | +// or in another window) — nothing was written then. | |
| 108 | +type InstructionsSave struct { | |
| 109 | + Instructions Instructions `json:"instructions"` | |
| 110 | + Conflict bool `json:"conflict"` | |
| 111 | +} | |
| 112 | + | |
| 113 | +// SaveInstructions writes the agent's instructions edited in its | |
| 114 | +// Instructions tab, over the version read; an empty version overwrites. | |
| 115 | +func (s *WorkspaceService) SaveInstructions(ctx context.Context, agent, content, version string) (InstructionsSave, error) { | |
| 116 | + current, err := s.Instructions(ctx, agent) | |
| 117 | + if err != nil { | |
| 118 | + return InstructionsSave{}, err | |
| 119 | + } | |
| 120 | + if version != "" && current.Exists && version != current.Version { | |
| 121 | + return InstructionsSave{Conflict: true}, nil | |
| 122 | + } | |
| 123 | + written, err := s.writeInstructions(ctx, agent, current, content) | |
| 124 | + if errors.Is(err, workspace.ErrConflict) { | |
| 125 | + return InstructionsSave{Conflict: true}, nil | |
| 126 | + } | |
| 127 | + return InstructionsSave{Instructions: written}, err | |
| 128 | +} | |
| 129 | + | |
| 130 | +// writeInstructions writes the agent's instruction file. The file is | |
| 131 | +// protected (config.AlwaysProtected) against the Files tab, not against this | |
| 132 | +// tab made for it (the owner's choice, issue #113); it is never removed. | |
| 133 | +func (s *WorkspaceService) writeInstructions(ctx context.Context, agent string, current Instructions, content string) (Instructions, error) { | |
| 134 | + ws, err := s.Core.workspaceOf(agent) | |
| 135 | + if err != nil { | |
| 136 | + return Instructions{}, err | |
| 137 | + } | |
| 138 | + // Replacing needs the version read: an empty one only creates. | |
| 139 | + written, err := ws.Write(ctx, current.File, content, current.Version) | |
| 140 | + if err != nil { | |
| 141 | + return Instructions{}, err | |
| 142 | + } | |
| 143 | + return Instructions{File: current.File, Exists: true, Content: written.Content, Version: written.Version, Files: current.Files}, nil | |
| 144 | +} | |
| 145 | + | |
| 146 | +// ChooseInstructions asks the user for a text file to import as an agent's | |
| 147 | +// instructions, starting in their home folder; "" when they cancelled. | |
| 148 | +func (s *WorkspaceService) ChooseInstructions() (string, error) { | |
| 149 | + return s.ChooseAttachment() | |
| 150 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,150 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package app | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "context" | ||
| 7 | + "errors" | ||
| 8 | + "fmt" | ||
| 9 | + "os" | ||
| 10 | + "path/filepath" | ||
| 11 | + "unicode/utf8" | ||
| 12 | + | ||
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/agents" | ||
| 14 | + "git.rickub.com/bots-garden/sidekicks/internal/workspace" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +// An agent's instructions (issue #113): the AGENTS.md (or CLAUDE.md…) of its | ||
| 18 | +// folder, created from a template, edited in the Files tab, or imported from | ||
| 19 | +// a file of this computer — on this computer, in its container or in its | ||
| 20 | +// sandbox alike, through its workspace. | ||
| 21 | + | ||
| 22 | +// maxInstructionsSize bounds an imported instruction file. | ||
| 23 | +const maxInstructionsSize = 1 << 20 | ||
| 24 | + | ||
| 25 | +// Instructions is where an agent's instructions are: File, at the root of | ||
| 26 | +// its folder, and whether it exists (Content then holds it). | ||
| 27 | +type Instructions struct { | ||
| 28 | + File string `json:"file"` | ||
| 29 | + Exists bool `json:"exists"` | ||
| 30 | + Content string `json:"content"` | ||
| 31 | + // Version is the version of the file read (workspace.File.Version). | ||
| 32 | + Version string `json:"version"` | ||
| 33 | + // Files is every file the agent reads, the one created first. | ||
| 34 | + Files []string `json:"files"` | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +// ErrInstructionsExist is returned by CreateInstructions when the agent | ||
| 38 | +// already has its instructions: they are edited, not replaced. | ||
| 39 | +var ErrInstructionsExist = errors.New("the agent already has its instructions") | ||
| 40 | + | ||
| 41 | +// Instructions tells which instruction file the agent reads: the first of | ||
| 42 | +// its files that exists, else the one to create. | ||
| 43 | +func (s *WorkspaceService) Instructions(ctx context.Context, agent string) (Instructions, error) { | ||
| 44 | + definition, ok := s.Core.manager.Definition(agent) | ||
| 45 | + if !ok { | ||
| 46 | + return Instructions{}, fmt.Errorf("%w: %s", agents.ErrUnknownAgent, agent) | ||
| 47 | + } | ||
| 48 | + ws, err := s.Core.workspaceOf(agent) | ||
| 49 | + if err != nil { | ||
| 50 | + return Instructions{}, err | ||
| 51 | + } | ||
| 52 | + files := agents.InstructionsFiles(definition) | ||
| 53 | + for _, file := range files { | ||
| 54 | + read, err := ws.Read(ctx, file) | ||
| 55 | + if err == nil { | ||
| 56 | + return Instructions{File: file, Exists: true, Content: read.Content, Version: read.Version, Files: files}, nil | ||
| 57 | + } | ||
| 58 | + if !errors.Is(err, workspace.ErrNotFound) { | ||
| 59 | + return Instructions{}, err | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + return Instructions{File: files[0], Files: files}, nil | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +// CreateInstructions writes content — a template the interface fills in — | ||
| 66 | +// as the agent's instructions; ErrInstructionsExist when it has some. | ||
| 67 | +func (s *WorkspaceService) CreateInstructions(ctx context.Context, agent, content string) (Instructions, error) { | ||
| 68 | + current, err := s.Instructions(ctx, agent) | ||
| 69 | + if err != nil { | ||
| 70 | + return Instructions{}, err | ||
| 71 | + } | ||
| 72 | + if current.Exists { | ||
| 73 | + return current, ErrInstructionsExist | ||
| 74 | + } | ||
| 75 | + return s.writeInstructions(ctx, agent, current, content) | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +// ImportInstructions copies a text file of this computer as the agent's | ||
| 79 | +// instructions, replacing them if it has some (the interface asks first). | ||
| 80 | +func (s *WorkspaceService) ImportInstructions(ctx context.Context, agent, hostPath string) (Instructions, error) { | ||
| 81 | + current, err := s.Instructions(ctx, agent) | ||
| 82 | + if err != nil { | ||
| 83 | + return Instructions{}, err | ||
| 84 | + } | ||
| 85 | + info, err := os.Stat(hostPath) | ||
| 86 | + if err != nil { | ||
| 87 | + return Instructions{}, err | ||
| 88 | + } | ||
| 89 | + if info.IsDir() { | ||
| 90 | + return Instructions{}, errors.New("a folder cannot be imported as instructions, only a text file") | ||
| 91 | + } | ||
| 92 | + if info.Size() > maxInstructionsSize { | ||
| 93 | + return Instructions{}, fmt.Errorf("%s: %w (%d MiB at most)", filepath.Base(hostPath), workspace.ErrTooLarge, maxInstructionsSize>>20) | ||
| 94 | + } | ||
| 95 | + data, err := os.ReadFile(hostPath) | ||
| 96 | + if err != nil { | ||
| 97 | + return Instructions{}, err | ||
| 98 | + } | ||
| 99 | + if !utf8.Valid(data) { | ||
| 100 | + return Instructions{}, fmt.Errorf("%s is not a text file", filepath.Base(hostPath)) | ||
| 101 | + } | ||
| 102 | + return s.writeInstructions(ctx, agent, current, string(data)) | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +// InstructionsSave is the result of SaveInstructions: the instructions | ||
| 106 | +// written, or Conflict when the file changed since it was read (by the agent, | ||
| 107 | +// or in another window) — nothing was written then. | ||
| 108 | +type InstructionsSave struct { | ||
| 109 | + Instructions Instructions `json:"instructions"` | ||
| 110 | + Conflict bool `json:"conflict"` | ||
| 111 | +} | ||
| 112 | + | ||
| 113 | +// SaveInstructions writes the agent's instructions edited in its | ||
| 114 | +// Instructions tab, over the version read; an empty version overwrites. | ||
| 115 | +func (s *WorkspaceService) SaveInstructions(ctx context.Context, agent, content, version string) (InstructionsSave, error) { | ||
| 116 | + current, err := s.Instructions(ctx, agent) | ||
| 117 | + if err != nil { | ||
| 118 | + return InstructionsSave{}, err | ||
| 119 | + } | ||
| 120 | + if version != "" && current.Exists && version != current.Version { | ||
| 121 | + return InstructionsSave{Conflict: true}, nil | ||
| 122 | + } | ||
| 123 | + written, err := s.writeInstructions(ctx, agent, current, content) | ||
| 124 | + if errors.Is(err, workspace.ErrConflict) { | ||
| 125 | + return InstructionsSave{Conflict: true}, nil | ||
| 126 | + } | ||
| 127 | + return InstructionsSave{Instructions: written}, err | ||
| 128 | +} | ||
| 129 | + | ||
| 130 | +// writeInstructions writes the agent's instruction file. The file is | ||
| 131 | +// protected (config.AlwaysProtected) against the Files tab, not against this | ||
| 132 | +// tab made for it (the owner's choice, issue #113); it is never removed. | ||
| 133 | +func (s *WorkspaceService) writeInstructions(ctx context.Context, agent string, current Instructions, content string) (Instructions, error) { | ||
| 134 | + ws, err := s.Core.workspaceOf(agent) | ||
| 135 | + if err != nil { | ||
| 136 | + return Instructions{}, err | ||
| 137 | + } | ||
| 138 | + // Replacing needs the version read: an empty one only creates. | ||
| 139 | + written, err := ws.Write(ctx, current.File, content, current.Version) | ||
| 140 | + if err != nil { | ||
| 141 | + return Instructions{}, err | ||
| 142 | + } | ||
| 143 | + return Instructions{File: current.File, Exists: true, Content: written.Content, Version: written.Version, Files: current.Files}, nil | ||
| 144 | +} | ||
| 145 | + | ||
| 146 | +// ChooseInstructions asks the user for a text file to import as an agent's | ||
| 147 | +// instructions, starting in their home folder; "" when they cancelled. | ||
| 148 | +func (s *WorkspaceService) ChooseInstructions() (string, error) { | ||
| 149 | + return s.ChooseAttachment() | ||
| 150 | +} | ||
added
internal/app/instructions_test.go +108 -0 | new file mode 100644 | ||
| @@ -0,0 +1,108 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package app_test | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "context" | |
| 7 | + "errors" | |
| 8 | + "os" | |
| 9 | + "path/filepath" | |
| 10 | + "testing" | |
| 11 | + | |
| 12 | + "git.rickub.com/bots-garden/sidekicks/internal/app" | |
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | |
| 14 | +) | |
| 15 | + | |
| 16 | +// instructionsSetup: alice runs mm, claude runs Claude Code's adapter, both | |
| 17 | +// on this computer, each with its folder. | |
| 18 | +func instructionsSetup(t *testing.T) (*app.WorkspaceService, string) { | |
| 19 | + t.Helper() | |
| 20 | + directory := t.TempDir() | |
| 21 | + for _, name := range []string{"alice", "claude"} { | |
| 22 | + if err := os.MkdirAll(filepath.Join(directory, name), 0o755); err != nil { | |
| 23 | + t.Fatal(err) | |
| 24 | + } | |
| 25 | + } | |
| 26 | + path := filepath.Join(directory, "config.yaml") | |
| 27 | + write(t, path, "version: 1\nagents:\n - name: alice\n command: mm\n args: [--acp]\n workspace: alice\n"+ | |
| 28 | + " - name: claude\n command: claude-agent-acp\n workspace: claude\n") | |
| 29 | + core := app.New(config.Location{Path: path, Source: config.SourceFlag}, app.Options{Starter: starter}) | |
| 30 | + t.Cleanup(func() { core.Shutdown(context.Background()) }) | |
| 31 | + return &app.WorkspaceService{Core: core}, directory | |
| 32 | +} | |
| 33 | + | |
| 34 | +// Issue #113: an agent without instructions gets them from a template, in | |
| 35 | +// the file its program reads; they are then edited, not replaced. | |
| 36 | +func TestInstructionsAreCreatedOnceInTheFileTheAgentReads(t *testing.T) { | |
| 37 | + service, directory := instructionsSetup(t) | |
| 38 | + ctx := context.Background() | |
| 39 | + if got, err := service.Instructions(ctx, "alice"); err != nil || got.Exists || got.File != "AGENTS.md" { | |
| 40 | + t.Fatalf("none yet: %+v %v", got, err) | |
| 41 | + } | |
| 42 | + created, err := service.CreateInstructions(ctx, "alice", "# Alice\n\nBe brief.\n") | |
| 43 | + if err != nil || !created.Exists || created.File != "AGENTS.md" { | |
| 44 | + t.Fatalf("created: %+v %v", created, err) | |
| 45 | + } | |
| 46 | + if data, _ := os.ReadFile(filepath.Join(directory, "alice", "AGENTS.md")); string(data) != "# Alice\n\nBe brief.\n" { | |
| 47 | + t.Fatalf("written: %q", data) | |
| 48 | + } | |
| 49 | + if _, err := service.CreateInstructions(ctx, "alice", "other"); !errors.Is(err, app.ErrInstructionsExist) { | |
| 50 | + t.Fatalf("never replaced by a template: %v", err) | |
| 51 | + } | |
| 52 | + if got, _ := service.Instructions(ctx, "claude"); got.File != "CLAUDE.md" || got.Exists { | |
| 53 | + t.Fatalf("Claude reads CLAUDE.md: %+v", got) | |
| 54 | + } | |
| 55 | + // An AGENTS.md already there is the one Claude reads (it has no CLAUDE.md). | |
| 56 | + write(t, filepath.Join(directory, "claude", "AGENTS.md"), "shared") | |
| 57 | + if got, _ := service.Instructions(ctx, "claude"); got.File != "AGENTS.md" || got.Content != "shared" { | |
| 58 | + t.Fatalf("the existing one: %+v", got) | |
| 59 | + } | |
| 60 | +} | |
| 61 | + | |
| 62 | +func TestInstructionsAreImportedFromATextFile(t *testing.T) { | |
| 63 | + service, directory := instructionsSetup(t) | |
| 64 | + ctx := context.Background() | |
| 65 | + source := filepath.Join(directory, "my rules.md") | |
| 66 | + write(t, source, "# Rules\n- Answer in French.\n") | |
| 67 | + imported, err := service.ImportInstructions(ctx, "claude", source) | |
| 68 | + if err != nil || imported.File != "CLAUDE.md" || imported.Content != "# Rules\n- Answer in French.\n" { | |
| 69 | + t.Fatalf("imported: %+v %v", imported, err) | |
| 70 | + } | |
| 71 | + write(t, source, "replaced") | |
| 72 | + if again, err := service.ImportInstructions(ctx, "claude", source); err != nil || again.Content != "replaced" { | |
| 73 | + t.Fatalf("an import replaces: %+v %v", again, err) | |
| 74 | + } | |
| 75 | + binary := filepath.Join(directory, "image.png") | |
| 76 | + if err := os.WriteFile(binary, []byte{0xff, 0xfe, 0x00, 0x89}, 0o644); err != nil { | |
| 77 | + t.Fatal(err) | |
| 78 | + } | |
| 79 | + if _, err := service.ImportInstructions(ctx, "claude", binary); err == nil { | |
| 80 | + t.Fatal("not a text file") | |
| 81 | + } | |
| 82 | + if _, err := service.ImportInstructions(ctx, "claude", directory); err == nil { | |
| 83 | + t.Fatal("not a folder") | |
| 84 | + } | |
| 85 | +} | |
| 86 | + | |
| 87 | +// Edited in the Instructions tab: written over the version read; a change | |
| 88 | +// made meanwhile is a conflict, and nothing is written. | |
| 89 | +func TestInstructionsAreSavedOverTheVersionRead(t *testing.T) { | |
| 90 | + service, directory := instructionsSetup(t) | |
| 91 | + ctx := context.Background() | |
| 92 | + created, _ := service.CreateInstructions(ctx, "alice", "v1") | |
| 93 | + saved, err := service.SaveInstructions(ctx, "alice", "v2", created.Version) | |
| 94 | + if err != nil || saved.Conflict || saved.Instructions.Content != "v2" { | |
| 95 | + t.Fatalf("saved: %+v %v", saved, err) | |
| 96 | + } | |
| 97 | + write(t, filepath.Join(directory, "alice", "AGENTS.md"), "changed by the agent") | |
| 98 | + if late, _ := service.SaveInstructions(ctx, "alice", "v3", saved.Instructions.Version); !late.Conflict { | |
| 99 | + t.Fatalf("a conflict: %+v", late) | |
| 100 | + } | |
| 101 | + if data, _ := os.ReadFile(filepath.Join(directory, "alice", "AGENTS.md")); string(data) != "changed by the agent" { | |
| 102 | + t.Fatalf("nothing written: %q", data) | |
| 103 | + } | |
| 104 | + // The Files tab still may not change it. | |
| 105 | + if _, err := (service).Save(ctx, "alice", "AGENTS.md", "x", ""); err == nil { | |
| 106 | + t.Fatal("protected in the Files tab") | |
| 107 | + } | |
| 108 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package app_test | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "context" | ||
| 7 | + "errors" | ||
| 8 | + "os" | ||
| 9 | + "path/filepath" | ||
| 10 | + "testing" | ||
| 11 | + | ||
| 12 | + "git.rickub.com/bots-garden/sidekicks/internal/app" | ||
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/config" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +// instructionsSetup: alice runs mm, claude runs Claude Code's adapter, both | ||
| 17 | +// on this computer, each with its folder. | ||
| 18 | +func instructionsSetup(t *testing.T) (*app.WorkspaceService, string) { | ||
| 19 | + t.Helper() | ||
| 20 | + directory := t.TempDir() | ||
| 21 | + for _, name := range []string{"alice", "claude"} { | ||
| 22 | + if err := os.MkdirAll(filepath.Join(directory, name), 0o755); err != nil { | ||
| 23 | + t.Fatal(err) | ||
| 24 | + } | ||
| 25 | + } | ||
| 26 | + path := filepath.Join(directory, "config.yaml") | ||
| 27 | + write(t, path, "version: 1\nagents:\n - name: alice\n command: mm\n args: [--acp]\n workspace: alice\n"+ | ||
| 28 | + " - name: claude\n command: claude-agent-acp\n workspace: claude\n") | ||
| 29 | + core := app.New(config.Location{Path: path, Source: config.SourceFlag}, app.Options{Starter: starter}) | ||
| 30 | + t.Cleanup(func() { core.Shutdown(context.Background()) }) | ||
| 31 | + return &app.WorkspaceService{Core: core}, directory | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +// Issue #113: an agent without instructions gets them from a template, in | ||
| 35 | +// the file its program reads; they are then edited, not replaced. | ||
| 36 | +func TestInstructionsAreCreatedOnceInTheFileTheAgentReads(t *testing.T) { | ||
| 37 | + service, directory := instructionsSetup(t) | ||
| 38 | + ctx := context.Background() | ||
| 39 | + if got, err := service.Instructions(ctx, "alice"); err != nil || got.Exists || got.File != "AGENTS.md" { | ||
| 40 | + t.Fatalf("none yet: %+v %v", got, err) | ||
| 41 | + } | ||
| 42 | + created, err := service.CreateInstructions(ctx, "alice", "# Alice\n\nBe brief.\n") | ||
| 43 | + if err != nil || !created.Exists || created.File != "AGENTS.md" { | ||
| 44 | + t.Fatalf("created: %+v %v", created, err) | ||
| 45 | + } | ||
| 46 | + if data, _ := os.ReadFile(filepath.Join(directory, "alice", "AGENTS.md")); string(data) != "# Alice\n\nBe brief.\n" { | ||
| 47 | + t.Fatalf("written: %q", data) | ||
| 48 | + } | ||
| 49 | + if _, err := service.CreateInstructions(ctx, "alice", "other"); !errors.Is(err, app.ErrInstructionsExist) { | ||
| 50 | + t.Fatalf("never replaced by a template: %v", err) | ||
| 51 | + } | ||
| 52 | + if got, _ := service.Instructions(ctx, "claude"); got.File != "CLAUDE.md" || got.Exists { | ||
| 53 | + t.Fatalf("Claude reads CLAUDE.md: %+v", got) | ||
| 54 | + } | ||
| 55 | + // An AGENTS.md already there is the one Claude reads (it has no CLAUDE.md). | ||
| 56 | + write(t, filepath.Join(directory, "claude", "AGENTS.md"), "shared") | ||
| 57 | + if got, _ := service.Instructions(ctx, "claude"); got.File != "AGENTS.md" || got.Content != "shared" { | ||
| 58 | + t.Fatalf("the existing one: %+v", got) | ||
| 59 | + } | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +func TestInstructionsAreImportedFromATextFile(t *testing.T) { | ||
| 63 | + service, directory := instructionsSetup(t) | ||
| 64 | + ctx := context.Background() | ||
| 65 | + source := filepath.Join(directory, "my rules.md") | ||
| 66 | + write(t, source, "# Rules\n- Answer in French.\n") | ||
| 67 | + imported, err := service.ImportInstructions(ctx, "claude", source) | ||
| 68 | + if err != nil || imported.File != "CLAUDE.md" || imported.Content != "# Rules\n- Answer in French.\n" { | ||
| 69 | + t.Fatalf("imported: %+v %v", imported, err) | ||
| 70 | + } | ||
| 71 | + write(t, source, "replaced") | ||
| 72 | + if again, err := service.ImportInstructions(ctx, "claude", source); err != nil || again.Content != "replaced" { | ||
| 73 | + t.Fatalf("an import replaces: %+v %v", again, err) | ||
| 74 | + } | ||
| 75 | + binary := filepath.Join(directory, "image.png") | ||
| 76 | + if err := os.WriteFile(binary, []byte{0xff, 0xfe, 0x00, 0x89}, 0o644); err != nil { | ||
| 77 | + t.Fatal(err) | ||
| 78 | + } | ||
| 79 | + if _, err := service.ImportInstructions(ctx, "claude", binary); err == nil { | ||
| 80 | + t.Fatal("not a text file") | ||
| 81 | + } | ||
| 82 | + if _, err := service.ImportInstructions(ctx, "claude", directory); err == nil { | ||
| 83 | + t.Fatal("not a folder") | ||
| 84 | + } | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +// Edited in the Instructions tab: written over the version read; a change | ||
| 88 | +// made meanwhile is a conflict, and nothing is written. | ||
| 89 | +func TestInstructionsAreSavedOverTheVersionRead(t *testing.T) { | ||
| 90 | + service, directory := instructionsSetup(t) | ||
| 91 | + ctx := context.Background() | ||
| 92 | + created, _ := service.CreateInstructions(ctx, "alice", "v1") | ||
| 93 | + saved, err := service.SaveInstructions(ctx, "alice", "v2", created.Version) | ||
| 94 | + if err != nil || saved.Conflict || saved.Instructions.Content != "v2" { | ||
| 95 | + t.Fatalf("saved: %+v %v", saved, err) | ||
| 96 | + } | ||
| 97 | + write(t, filepath.Join(directory, "alice", "AGENTS.md"), "changed by the agent") | ||
| 98 | + if late, _ := service.SaveInstructions(ctx, "alice", "v3", saved.Instructions.Version); !late.Conflict { | ||
| 99 | + t.Fatalf("a conflict: %+v", late) | ||
| 100 | + } | ||
| 101 | + if data, _ := os.ReadFile(filepath.Join(directory, "alice", "AGENTS.md")); string(data) != "changed by the agent" { | ||
| 102 | + t.Fatalf("nothing written: %q", data) | ||
| 103 | + } | ||
| 104 | + // The Files tab still may not change it. | ||
| 105 | + if _, err := (service).Save(ctx, "alice", "AGENTS.md", "x", ""); err == nil { | ||
| 106 | + t.Fatal("protected in the Files tab") | ||
| 107 | + } | ||
| 108 | +} | ||
modified
internal/config/config.go +6 -3 | @@ -130,8 +130,11 @@ type Agent struct { | ||
| 130 | 130 | var configFlags = map[string]bool{"--config": true, "-config": true} |
| 131 | 131 | |
| 132 | 132 | // AlwaysProtected are the files of every agent's folder the interface may |
| 133 | -// neither change nor remove: its instructions and its skills. | |
| 134 | -var AlwaysProtected = []string{"AGENTS.md", "skills/**"} | |
| 133 | +// neither change nor remove: its instructions — AGENTS.md, and CLAUDE.md and | |
| 134 | +// GEMINI.md that Claude Code and Gemini read (issue #113) — and its skills. | |
| 135 | +// Only the agent's Instructions tab writes an instruction file (never | |
| 136 | +// removes it): a deliberate edit, not a slip in the Files tab. | |
| 137 | +var AlwaysProtected = []string{"AGENTS.md", "CLAUDE.md", "GEMINI.md", "skills/**"} | |
| 135 | 138 | |
| 136 | 139 | // Protected returns the files of the agent's folder the interface may |
| 137 | 140 | // neither change nor remove, without repetition: Protect, the agent's |
| @@ -141,7 +144,7 @@ var AlwaysProtected = []string{"AGENTS.md", "skills/**"} | ||
| 141 | 144 | // lifecycleFiles), then AlwaysProtected. |
| 142 | 145 | // |
| 143 | 146 | // agent.Args = []string{"--acp", "--config", "agent.yaml"}; agent.Protect = []string{"notes/**"} |
| 144 | -// agent.Protected() // [notes/** agent.yaml AGENTS.md skills/**] | |
| 147 | +// agent.Protected() // [notes/** agent.yaml AGENTS.md CLAUDE.md GEMINI.md skills/**] | |
| 145 | 148 | func (a Agent) Protected() []string { |
| 146 | 149 | candidates := append([]string(nil), a.Protect...) |
| 147 | 150 | if file := a.configFile(); file != "" { |
| @@ -130,8 +130,11 @@ type Agent struct { | |||
| 130 | var configFlags = map[string]bool{"--config": true, "-config": true} | 130 | var configFlags = map[string]bool{"--config": true, "-config": true} |
| 131 | 131 | ||
| 132 | // AlwaysProtected are the files of every agent's folder the interface may | 132 | // AlwaysProtected are the files of every agent's folder the interface may |
| 133 | -// neither change nor remove: its instructions and its skills. | 133 | +// neither change nor remove: its instructions — AGENTS.md, and CLAUDE.md and |
| 134 | -var AlwaysProtected = []string{"AGENTS.md", "skills/**"} | 134 | +// GEMINI.md that Claude Code and Gemini read (issue #113) — and its skills. |
| 135 | +// Only the agent's Instructions tab writes an instruction file (never | ||
| 136 | +// removes it): a deliberate edit, not a slip in the Files tab. | ||
| 137 | +var AlwaysProtected = []string{"AGENTS.md", "CLAUDE.md", "GEMINI.md", "skills/**"} | ||
| 135 | 138 | ||
| 136 | // Protected returns the files of the agent's folder the interface may | 139 | // Protected returns the files of the agent's folder the interface may |
| 137 | // neither change nor remove, without repetition: Protect, the agent's | 140 | // neither change nor remove, without repetition: Protect, the agent's |
| @@ -141,7 +144,7 @@ var AlwaysProtected = []string{"AGENTS.md", "skills/**"} | |||
| 141 | // lifecycleFiles), then AlwaysProtected. | 144 | // lifecycleFiles), then AlwaysProtected. |
| 142 | // | 145 | // |
| 143 | // agent.Args = []string{"--acp", "--config", "agent.yaml"}; agent.Protect = []string{"notes/**"} | 146 | // agent.Args = []string{"--acp", "--config", "agent.yaml"}; agent.Protect = []string{"notes/**"} |
| 144 | -// agent.Protected() // [notes/** agent.yaml AGENTS.md skills/**] | 147 | +// agent.Protected() // [notes/** agent.yaml AGENTS.md CLAUDE.md GEMINI.md skills/**] |
| 145 | func (a Agent) Protected() []string { | 148 | func (a Agent) Protected() []string { |
| 146 | candidates := append([]string(nil), a.Protect...) | 149 | candidates := append([]string(nil), a.Protect...) |
| 147 | if file := a.configFile(); file != "" { | 150 | if file := a.configFile(); file != "" { |
modified
internal/config/config_test.go +9 -9 | @@ -505,11 +505,11 @@ agents: | ||
| 505 | 505 | t.Fatal(err) |
| 506 | 506 | } |
| 507 | 507 | want := map[string]string{ |
| 508 | - "mm": "[AGENTS.md skills/** agent.yaml]", | |
| 509 | - "dag": "[dag.yaml AGENTS.md skills/**]", | |
| 510 | - "outside": "[AGENTS.md skills/**]", | |
| 511 | - "boxed": "[agent.yaml AGENTS.md skills/**]", | |
| 512 | - "plain": "[AGENTS.md skills/**]", | |
| 508 | + "mm": "[AGENTS.md skills/** agent.yaml CLAUDE.md GEMINI.md]", | |
| 509 | + "dag": "[dag.yaml AGENTS.md CLAUDE.md GEMINI.md skills/**]", | |
| 510 | + "outside": "[AGENTS.md CLAUDE.md GEMINI.md skills/**]", | |
| 511 | + "boxed": "[agent.yaml AGENTS.md CLAUDE.md GEMINI.md skills/**]", | |
| 512 | + "plain": "[AGENTS.md CLAUDE.md GEMINI.md skills/**]", | |
| 513 | 513 | } |
| 514 | 514 | for _, agent := range cfg.Agents { |
| 515 | 515 | if got := fmt.Sprint(agent.Protected()); got != want[agent.Name] { |
| @@ -562,10 +562,10 @@ agents: | ||
| 562 | 562 | t.Fatal(err) |
| 563 | 563 | } |
| 564 | 564 | want := map[string]string{ |
| 565 | - "mario": "[compose.yaml Dockerfile AGENTS.md skills/**]", | |
| 566 | - "bare": "[AGENTS.md skills/**]", // the folder of the commands is outside the agent's | |
| 567 | - "milo": "[AGENTS.md skills/**]", // sbxenv.yaml is in agents/milo, outside agents/milo/workspace | |
| 568 | - "kit": "[dev.yaml AGENTS.md skills/**]", | |
| 565 | + "mario": "[compose.yaml Dockerfile AGENTS.md CLAUDE.md GEMINI.md skills/**]", | |
| 566 | + "bare": "[AGENTS.md CLAUDE.md GEMINI.md skills/**]", // the folder of the commands is outside the agent's | |
| 567 | + "milo": "[AGENTS.md CLAUDE.md GEMINI.md skills/**]", // sbxenv.yaml is in agents/milo, outside agents/milo/workspace | |
| 568 | + "kit": "[dev.yaml AGENTS.md CLAUDE.md GEMINI.md skills/**]", | |
| 569 | 569 | } |
| 570 | 570 | for _, agent := range cfg.Agents { |
| 571 | 571 | if got := fmt.Sprint(agent.Protected()); got != want[agent.Name] { |
| @@ -505,11 +505,11 @@ agents: | |||
| 505 | t.Fatal(err) | 505 | t.Fatal(err) |
| 506 | } | 506 | } |
| 507 | want := map[string]string{ | 507 | want := map[string]string{ |
| 508 | - "mm": "[AGENTS.md skills/** agent.yaml]", | 508 | + "mm": "[AGENTS.md skills/** agent.yaml CLAUDE.md GEMINI.md]", |
| 509 | - "dag": "[dag.yaml AGENTS.md skills/**]", | 509 | + "dag": "[dag.yaml AGENTS.md CLAUDE.md GEMINI.md skills/**]", |
| 510 | - "outside": "[AGENTS.md skills/**]", | 510 | + "outside": "[AGENTS.md CLAUDE.md GEMINI.md skills/**]", |
| 511 | - "boxed": "[agent.yaml AGENTS.md skills/**]", | 511 | + "boxed": "[agent.yaml AGENTS.md CLAUDE.md GEMINI.md skills/**]", |
| 512 | - "plain": "[AGENTS.md skills/**]", | 512 | + "plain": "[AGENTS.md CLAUDE.md GEMINI.md skills/**]", |
| 513 | } | 513 | } |
| 514 | for _, agent := range cfg.Agents { | 514 | for _, agent := range cfg.Agents { |
| 515 | if got := fmt.Sprint(agent.Protected()); got != want[agent.Name] { | 515 | if got := fmt.Sprint(agent.Protected()); got != want[agent.Name] { |
| @@ -562,10 +562,10 @@ agents: | |||
| 562 | t.Fatal(err) | 562 | t.Fatal(err) |
| 563 | } | 563 | } |
| 564 | want := map[string]string{ | 564 | want := map[string]string{ |
| 565 | - "mario": "[compose.yaml Dockerfile AGENTS.md skills/**]", | 565 | + "mario": "[compose.yaml Dockerfile AGENTS.md CLAUDE.md GEMINI.md skills/**]", |
| 566 | - "bare": "[AGENTS.md skills/**]", // the folder of the commands is outside the agent's | 566 | + "bare": "[AGENTS.md CLAUDE.md GEMINI.md skills/**]", // the folder of the commands is outside the agent's |
| 567 | - "milo": "[AGENTS.md skills/**]", // sbxenv.yaml is in agents/milo, outside agents/milo/workspace | 567 | + "milo": "[AGENTS.md CLAUDE.md GEMINI.md skills/**]", // sbxenv.yaml is in agents/milo, outside agents/milo/workspace |
| 568 | - "kit": "[dev.yaml AGENTS.md skills/**]", | 568 | + "kit": "[dev.yaml AGENTS.md CLAUDE.md GEMINI.md skills/**]", |
| 569 | } | 569 | } |
| 570 | for _, agent := range cfg.Agents { | 570 | for _, agent := range cfg.Agents { |
| 571 | if got := fmt.Sprint(agent.Protected()); got != want[agent.Name] { | 571 | if got := fmt.Sprint(agent.Protected()); got != want[agent.Name] { |