|
| 1 | +;; SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +;; AGENTIC.scm - AI agent interaction patterns for PanLL development |
| 3 | + |
| 4 | +(agentic |
| 5 | + (version "1.0.0") |
| 6 | + (last-updated "2026-02-07") |
| 7 | + (manifest-reference "0-AI-MANIFEST.a2ml") |
| 8 | + |
| 9 | + (agent-protocols |
| 10 | + (session-startup |
| 11 | + "1. Read 0-AI-MANIFEST.a2ml FIRST (mandatory, before any file operations)" |
| 12 | + "2. Acknowledge canonical locations (.machine_readable/, .bot_directives/)" |
| 13 | + "3. Read STATE.scm for current project status, progress, blockers" |
| 14 | + "4. Read META.scm for architecture decisions and design rationale" |
| 15 | + "5. Read ECOSYSTEM.scm for ecosystem position and dependencies" |
| 16 | + "6. Read AGENTIC.scm (this file) for interaction patterns" |
| 17 | + "7. Read NEUROSYM.scm for neurosymbolic integration config" |
| 18 | + "8. Read PLAYBOOK.scm for operational procedures" |
| 19 | + "9. Log session start in .machine_readable/session-log.txt (optional)" |
| 20 | + "10. Declare understanding of canonical file locations") |
| 21 | + |
| 22 | + (session-exit |
| 23 | + "1. Update STATE.scm if changes made (completion-percentage, work-completed, blockers)" |
| 24 | + "2. Update ECOSYSTEM.scm if dependencies changed" |
| 25 | + "3. Update META.scm if architecture decisions made" |
| 26 | + "4. Log session end in .machine_readable/session-log.txt (optional)" |
| 27 | + "5. Summarise outcomes in session-history section of STATE.scm") |
| 28 | + |
| 29 | + (file-modification-rules |
| 30 | + "1. NEVER create SCM files in repository root (STATE.scm, META.scm, etc.)" |
| 31 | + "2. SCM files ONLY in .machine_readable/ directory" |
| 32 | + "3. Always preserve SPDX license headers (PMPL-1.0-or-later)" |
| 33 | + "4. Always use author 'Jonathan D.A. Jewell <jonathan.jewell@open.ac.uk>'" |
| 34 | + "5. Follow ReScript style guide for .res files" |
| 35 | + "6. Follow Rust style guide for .rs files (rustfmt)" |
| 36 | + "7. Update STATE.scm when completing milestone steps")) |
| 37 | + |
| 38 | + (task-patterns |
| 39 | + (feature-implementation |
| 40 | + (approach "Test-driven development") |
| 41 | + (steps |
| 42 | + "1. Read STATE.scm to understand current position and blockers" |
| 43 | + "2. Identify affected modules (Model, Msg, Update, View, components)" |
| 44 | + "3. Write tests first (tests/*.test.js)" |
| 45 | + "4. Implement feature in ReScript" |
| 46 | + "5. Ensure rescript build compiles without errors" |
| 47 | + "6. Run tests (npm run test)" |
| 48 | + "7. Update STATE.scm (work-completed, completion-percentage)" |
| 49 | + "8. Update ROADMAP.adoc if milestone changed")) |
| 50 | + |
| 51 | + (bug-fixing |
| 52 | + (approach "Root cause analysis first") |
| 53 | + (steps |
| 54 | + "1. Reproduce bug reliably" |
| 55 | + "2. Identify root cause (check Model state transitions, Update logic)" |
| 56 | + "3. Add regression test" |
| 57 | + "4. Fix bug in minimal way" |
| 58 | + "5. Verify test passes" |
| 59 | + "6. Document fix in STATE.scm session-history")) |
| 60 | + |
| 61 | + (refactoring |
| 62 | + (approach "Incremental with tests") |
| 63 | + (steps |
| 64 | + "1. Ensure all tests passing before refactoring" |
| 65 | + "2. Make small, atomic changes" |
| 66 | + "3. Run tests after each change" |
| 67 | + "4. Update documentation if API changed" |
| 68 | + "5. Document rationale in META.scm if architecture changed")) |
| 69 | + |
| 70 | + (migration-work |
| 71 | + (approach "Follow migration guide, test incrementally") |
| 72 | + (current-migration "custom TEA → rescript-tea@0.16.0") |
| 73 | + (tracking-doc "MIGRATION-TO-RESCRIPT-TEA.md") |
| 74 | + (steps |
| 75 | + "1. Read migration guide to understand changes" |
| 76 | + "2. Update imports in one module at a time" |
| 77 | + "3. Run rescript build to check compilation" |
| 78 | + "4. Test module in isolation" |
| 79 | + "5. Commit after each working module" |
| 80 | + "6. Update STATE.scm work-in-progress section"))) |
| 81 | + |
| 82 | + (code-generation-guidelines |
| 83 | + (rescript |
| 84 | + (style "OCaml-influenced, functional-first") |
| 85 | + (conventions |
| 86 | + "- Use pattern matching for variant types (msg, viewMode, oodaPhase)" |
| 87 | + "- Prefer immutable updates (record spread: {...model, field: newValue})" |
| 88 | + "- Use option<'a> for nullable values (never null/undefined)" |
| 89 | + "- Type annotations for public functions" |
| 90 | + "- SPDX header: // SPDX-License-Identifier: PMPL-1.0-or-later" |
| 91 | + "- Doc comments: /// for module/function descriptions")) |
| 92 | + |
| 93 | + (rust |
| 94 | + (style "Tauri backend, memory-safe") |
| 95 | + (conventions |
| 96 | + "- #[tauri::command] for exposed commands" |
| 97 | + "- Result<T, String> for fallible operations" |
| 98 | + "- serde for JSON serialisation" |
| 99 | + "- SPDX header: // SPDX-License-Identifier: PMPL-1.0-or-later" |
| 100 | + "- Doc comments: /// for public functions")) |
| 101 | + |
| 102 | + (tests |
| 103 | + (framework "Vitest") |
| 104 | + (conventions |
| 105 | + "- One test file per module (Tea_Cmd.test.js, Tea_App.test.js)" |
| 106 | + "- describe() blocks for logical grouping" |
| 107 | + "- test() for individual cases" |
| 108 | + "- Aim for 95%+ coverage" |
| 109 | + "- Test pure functions (Model, Update) thoroughly" |
| 110 | + "- Integration tests for Tauri commands"))) |
| 111 | + |
| 112 | + (interaction-preferences |
| 113 | + (communication-style |
| 114 | + "Direct, technical, focused on implementation. " |
| 115 | + "Prefer code examples over abstract explanations. " |
| 116 | + "Use Binary Star metaphors when discussing architecture. " |
| 117 | + "Reference ADRs in META.scm when discussing design decisions.") |
| 118 | + |
| 119 | + (decision-making |
| 120 | + "Agent should propose solutions with rationale, but defer major architecture decisions to maintainer. " |
| 121 | + "Safe to make: Bug fixes, refactoring within existing patterns, test additions, documentation updates. " |
| 122 | + "Requires approval: New features, API changes, dependency additions, architecture changes.") |
| 123 | + |
| 124 | + (error-handling |
| 125 | + "When encountering errors:" |
| 126 | + "1. Include full error message and context" |
| 127 | + "2. Propose fix with explanation" |
| 128 | + "3. Update STATE.scm blockers if cannot resolve" |
| 129 | + "4. Never silently ignore errors") |
| 130 | + |
| 131 | + (documentation-updates |
| 132 | + "Update documentation when:" |
| 133 | + "- Adding new features (README.adoc, ROADMAP.adoc)" |
| 134 | + "- Making architecture decisions (META.scm ADRs)" |
| 135 | + "- Changing build process (README.adoc, PLAYBOOK.scm)" |
| 136 | + "- Completing milestones (STATE.scm, ROADMAP.adoc)")) |
| 137 | + |
| 138 | + (collaboration-patterns |
| 139 | + (with-human-maintainer |
| 140 | + "PanLL is alpha software with active development. " |
| 141 | + "Maintainer (Jonathan D.A. Jewell) reviews all changes. " |
| 142 | + "Agent should:" |
| 143 | + "- Propose changes with clear rationale" |
| 144 | + "- Highlight breaking changes explicitly" |
| 145 | + "- Defer UX decisions to maintainer" |
| 146 | + "- Document assumptions when making design choices") |
| 147 | + |
| 148 | + (with-other-agents |
| 149 | + "If multiple agents working on PanLL:" |
| 150 | + "- Use STATE.scm as source of truth for current state" |
| 151 | + "- Log session starts/ends to avoid conflicts" |
| 152 | + "- Coordinate on blockers via STATE.scm active-blockers" |
| 153 | + "- Commit frequently with clear messages") |
| 154 | + |
| 155 | + (with-gitbot-fleet |
| 156 | + "PanLL may integrate with gitbot-fleet automation:" |
| 157 | + "- rhodibot: Git operations, branch management" |
| 158 | + "- echidnabot: Code quality, formal verification" |
| 159 | + "- sustainabot: Dependency updates" |
| 160 | + "- glambot: Documentation generation" |
| 161 | + "Instructions in .bot_directives/ (when created)")) |
| 162 | + |
| 163 | + (anti-patterns |
| 164 | + "NEVER:" |
| 165 | + "- Create SCM files in repository root (STATE.scm, META.scm, etc.)" |
| 166 | + "- Use TypeScript (policy violation, use ReScript)" |
| 167 | + "- Use npm for runtime (policy violation, use Deno)" |
| 168 | + "- Use AGPL license (superseded by PMPL-1.0-or-later)" |
| 169 | + "- Hardcode author as 'hyperpolymath' (use Jonathan D.A. Jewell)" |
| 170 | + "- Force-push to main branch" |
| 171 | + "- Commit node_modules/ or generated .js files from ReScript" |
| 172 | + "- Skip tests when making changes") |
| 173 | + |
| 174 | + (tools-and-workflows |
| 175 | + (build-commands |
| 176 | + "npm run res:build - Compile ReScript to JavaScript" |
| 177 | + "npm run res:watch - Watch ReScript files, recompile on change" |
| 178 | + "deno task css:build - Compile Tailwind CSS (minified)" |
| 179 | + "deno task css:watch - Watch Tailwind, recompile on change" |
| 180 | + "deno task dev - Run Tailwind watch + Tauri dev" |
| 181 | + "deno task build - Full production build (CSS + Tauri)") |
| 182 | + |
| 183 | + (test-commands |
| 184 | + "npm run test - Run all tests" |
| 185 | + "npm run test:watch - Watch mode for tests" |
| 186 | + "npm run test:ui - Interactive test UI" |
| 187 | + "npm run test:coverage - Generate coverage report") |
| 188 | + |
| 189 | + (tauri-commands |
| 190 | + "npm run tauri:dev - Run Tauri in development mode" |
| 191 | + "npm run tauri:build - Build production Tauri app") |
| 192 | + |
| 193 | + (git-workflow |
| 194 | + "1. Create feature branch: git checkout -b feature/description" |
| 195 | + "2. Make changes, commit frequently" |
| 196 | + "3. Push to origin" |
| 197 | + "4. Create pull request" |
| 198 | + "5. CI/CD runs tests, linters" |
| 199 | + "6. After approval, merge to main"))) |
0 commit comments