|
| 1 | +<!-- /AGENTS.md --> |
| 2 | +<!-- Master rules for human and AI collaborators --> |
| 3 | +<!-- Why: keep work simple, fast, and safe --> |
| 4 | +<!-- RELEVANT FILES: README.md, CONTRIBUTING.md, PHASE_2_PROGRESS.md --> |
| 5 | + |
| 6 | +# AGENTS Master Guide |
| 7 | + |
| 8 | +This is the source of truth for how humans and AI work together. |
| 9 | + |
| 10 | +## GOAL |
| 11 | +Ship value fast. Write clean, simple, modular code. Do exactly what is asked. |
| 12 | + |
| 13 | +## ABOUT THE PRODUCT |
| 14 | +OmniScript Format: universal document DSL for developers and AI agents. |
| 15 | + |
| 16 | +Resources are limited. Favor speed and simplicity. Pick the 80:20 solution. |
| 17 | + |
| 18 | +## PROJECT HISTORY AND VISION |
| 19 | + |
| 20 | +**Origin**: October 2025. Created to unify documents, presentations, spreadsheets into one Git-friendly, AI-friendly plain-text format. |
| 21 | + |
| 22 | +**Problem**: Binary formats (DOCX, PPTX, XLSX) hostile to version control and AI. |
| 23 | + |
| 24 | +**Solution**: Write once in .osf, export to everything. |
| 25 | + |
| 26 | +**Version History**: |
| 27 | +- v0.5.0 (Oct 2025): First public release |
| 28 | +- v0.6.0 (Oct 2025): Phase 1 complete, 3 npm packages, 79 tests |
| 29 | +- v0.1.0 (Oct 2025): VSCode extension |
| 30 | +- v1.0.0 (Target Q4 2025): Charts, diagrams, code blocks |
| 31 | + |
| 32 | +**Current**: Phase 2 (40% done). Building ecosystem: VSCode extension, examples, docs. |
| 33 | + |
| 34 | +**Vision 2026**: Reference implementation for universal document DSLs. Real-time collaboration, visual editor, plugin system. |
| 35 | + |
| 36 | +## MODUS OPERANDI |
| 37 | +Prefer boring solutions. Cut scope early. Avoid hidden complexity. Explain what and why. |
| 38 | + |
| 39 | +## TECH STACK |
| 40 | +Backend: Node.js 22, TypeScript 5.8. Frontend: Next.js 15.3, React 18, Tailwind 3.4. Infra: Docker, GitHub Actions, pnpm 10.12. Data: File-based, no database. |
| 41 | + |
| 42 | +## ARCHITECTURE |
| 43 | + |
| 44 | +**System Flow**: |
| 45 | +``` |
| 46 | +.osf file → Parser → AST → Renderer/Converter → PDF/DOCX/PPTX/XLSX |
| 47 | + ↓ |
| 48 | + VSCode → IntelliSense/Diagnostics |
| 49 | +``` |
| 50 | + |
| 51 | +**Packages**: |
| 52 | +- omniscript-parser (18 KB): Lexer, parser, AST |
| 53 | +- omniscript-cli (21 KB): Commands, themes |
| 54 | +- omniscript-converters (29 KB): PDF/DOCX/PPTX/XLSX |
| 55 | +- omniscript-vscode (2,500 lines): IDE support |
| 56 | +- omniscript-examples (2,700 lines): 25+ examples |
| 57 | +- omniscript-site: Next.js docs & playground |
| 58 | + |
| 59 | +**Block Types**: |
| 60 | +@meta (metadata), @doc (markdown), @slide (presentations), @sheet (spreadsheets), @chart/@diagram/@code (v1.0). |
| 61 | + |
| 62 | +**Integration Points**: |
| 63 | +VSCode ↔ Parser (real-time), CLI ↔ Parser ↔ Converters, Website ↔ Parser (playground), Examples ↔ Validator ↔ Parser (CI). |
| 64 | + |
| 65 | +## DEPLOYED ENVIRONMENTS |
| 66 | +Production: https://omniscriptosf.github.io. NPM: omniscript-parser, omniscript-converters, omniscript-cli. VSCode: marketplace.visualstudio.com. |
| 67 | + |
| 68 | +## VERSION CONTROL |
| 69 | +Git. Follow .cursor/rules/universal.mdc. Small commits with conventional commits: feat:, fix:, docs:, chore:. |
| 70 | + |
| 71 | +## ESSENTIAL COMMANDS |
| 72 | +Parser: cd omniscript-core/parser && pnpm test. Converters: cd omniscript-converters && pnpm test. CLI: osf render file.osf. VSCode: cd omniscript-vscode && npm run compile. Website: cd omniscript-site && npm run dev. Examples: cd omniscript-examples && npm run validate. |
| 73 | + |
| 74 | +## HEADER COMMENTS |
| 75 | +Every file starts with four lines: 1) exact file location, 2) what this file does, 3) why this file exists, 4) RELEVANT FILES: comma-separated list. Never remove. |
| 76 | + |
| 77 | +## WRITING STYLE |
| 78 | +Short sentences. Plain English. Split long sentences, add blank line. Comment non-obvious code. |
| 79 | + |
| 80 | +## SIMPLICITY |
| 81 | +Simple is good. Complex is bad. Fewer lines better if clarity stays high. Prefer standard library. |
| 82 | + |
| 83 | +## ROLES AND PERMISSIONS |
| 84 | +Product Owner: sets scope (Alphin Tom). Developers: implement, review, release. Editor AI: edits files, no npm publish without approval. Autonomous Agents: refactors/tests only when requested, no production changes. |
| 85 | + |
| 86 | +## UI PRINCIPLES |
| 87 | +NOIR design system: black backgrounds, white text, accent colors. Simple, minimal, clear hierarchy. Accessibility before decoration. |
| 88 | + |
| 89 | +## API CONVENTIONS |
| 90 | +Library exports. Parser: parse(text: string) → Document. Converters: convert(document, options) → Buffer. CLI: osf render <file> --format <type>. Errors: throw Error with context. |
| 91 | + |
| 92 | +## DATABASE PRINCIPLES |
| 93 | +No database. File-based .osf format. Version control via git. |
| 94 | + |
| 95 | +## SECURITY BASELINE |
| 96 | +No secrets in code. Validate OSF syntax at parse. Pin dependencies, run npm audit. VSCode: sandbox user code. |
| 97 | + |
| 98 | +## PRIVACY AND DATA RETENTION |
| 99 | +Collect no user data. Examples use synthetic data. Log no sensitive info. No telemetry in core packages. |
| 100 | + |
| 101 | +## LOGGING AND TELEMETRY |
| 102 | +Levels: debug, info, warn, error. Parser errors include line/column. CLI: stderr for logs, stdout for output. VSCode: output channel, not console. |
| 103 | + |
| 104 | +## ERROR HANDLING |
| 105 | +Parse: fail fast with line number. Converters: validate before conversion. CLI: exit 1 on error, 0 on success. Helpful messages, no internal stacks in production. |
| 106 | + |
| 107 | +## PERFORMANCE BUDGETS |
| 108 | +Parser: 1000-line doc in <100ms. Converters: PDF in <2s. Website: LCP <2s on 4G. CLI: total <5s for typical doc. |
| 109 | + |
| 110 | +## ACCESSIBILITY AND I18N |
| 111 | +WCAG 2.1 AA for website. Keyboard navigation. Screen reader support. CLI/parser language-agnostic. Error messages in English only. |
| 112 | + |
| 113 | +## FEATURE FLAGS AND ROLLOUT |
| 114 | +New @blocks start experimental. Document in spec with version tag. Parser accepts but warns. Promote to stable after 2 releases. |
| 115 | + |
| 116 | +## DEPENDENCIES |
| 117 | +Prefer standard library. Parser: zero dependencies. Converters: pdfkit, docx, pptxgenjs, exceljs. VSCode: @types and vscode SDK only. Website: Next.js, React, Tailwind. Review licenses. |
| 118 | + |
| 119 | +## FORMATTING AND LINTING |
| 120 | +TypeScript: ESLint v9 strict. Formatter: Prettier for TS/JS. Python (future): ruff, black. Run in CI. |
| 121 | + |
| 122 | +## RELEASE AND ROLLBACK |
| 123 | +Publish from main with version tag. Follow semver. Breaking changes = major bump. Monitor npm downloads and GitHub issues. Rollback: npm deprecate if critical bug. |
| 124 | + |
| 125 | +## MANDATORY FIRST ACTIONS |
| 126 | + |
| 127 | +**ALWAYS RUN THESE COMMANDS FIRST** before any work: |
| 128 | + |
| 129 | +1. **Get Current Date/Time** - NEVER assume dates: |
| 130 | + ```bash |
| 131 | + date "+%Y-%m-%d %H:%M:%S %Z" && date "+Today is %B %d, %Y" |
| 132 | + ``` |
| 133 | + Use this date in ALL documentation, examples, and release notes. |
| 134 | + |
| 135 | +2. **Read Context** - Read AGENTS.md for project rules. |
| 136 | + |
| 137 | +**CRITICAL**: Do not use assumed dates like "January 2025" or "today". Always get the actual system date first. |
| 138 | + |
| 139 | +## RESTRICTIONS |
| 140 | +Do not npm publish unless told. Do not push to remote unless told. Do not modify published packages. Do exactly what is asked. Test locally first. |
| 141 | + |
| 142 | +**NEVER CREATE META-DOCUMENTATION**: Do not create documentation about documentation work (e.g., DOCUMENTATION_CONSOLIDATION.md, FIXES_APPLIED_FINAL.md, TEST_RESULTS_COMPLETE.md, PUBLISHING_v1.0.md, LOCAL_INTEGRATION_TEST_REPORT.md, V1.0_LAUNCH_READY.md). Results go in proper docs (README, RELEASE_NOTES.md, docs/TESTING.md, docs/CODE_QUALITY.md, docs/DEVELOPMENT.md). Temporary work reports are forbidden. Only create docs requested by user or required for public API. |
| 143 | + |
| 144 | +## FILE LENGTH |
| 145 | +Keep under 300 lines. Parser: split by block type. Converters: one file per format. Examples: split by category. |
| 146 | + |
| 147 | +## READING FILES |
| 148 | +Read full file before editing. Read related files in same module. Check examples when changing parser. Check spec when adding features. |
| 149 | + |
| 150 | +## DATABASE CHANGES |
| 151 | +No database in project. File format changes require spec update first in spec/v1.0/ or new version folder. |
| 152 | + |
| 153 | +## OUTPUT STYLE |
| 154 | +State assumptions clearly. State conclusions briefly. Show code changes inline. Include test commands when relevant. |
| 155 | + |
| 156 | +## PULL REQUEST REVIEW PROCESS |
| 157 | + |
| 158 | +**MANDATORY BEFORE EVERY COMMIT**: Act as a staff engineer performing a Pull Request review using a P# severity scheme: P0 blocker, P1 high, P2 medium, P3 low. Read the diff and context, attempt to build and run tests if possible, and assess: |
| 159 | + |
| 160 | +- Correctness, test coverage and edge cases |
| 161 | +- Error handling and input validation |
| 162 | +- Concurrency and race conditions |
| 163 | +- Security including secrets, auth, OWASP risks |
| 164 | +- Performance and complexity, memory use |
| 165 | +- API contracts and backward compatibility |
| 166 | +- Database or migration safety |
| 167 | +- Dependency changes and licenses |
| 168 | +- CI configuration |
| 169 | +- Logging and observability |
| 170 | +- Accessibility and i18n |
| 171 | +- Readability and style |
| 172 | +- Documentation and comments |
| 173 | +- Alignment with architectural guidelines |
| 174 | + |
| 175 | +**Output Format**: |
| 176 | +- **Summary**: One sentence on risk and scope |
| 177 | +- **Verdict**: Approve or Request changes with rationale |
| 178 | +- **Findings**: Numbered list where each item starts with [P#] then file:line then description then why it matters then minimal patch |
| 179 | +- **Tests**: List missing or flaky tests with sample cases |
| 180 | +- **Follow-ups**: Optional small improvements |
| 181 | + |
| 182 | +**Commit Policy**: Only commit if there are NO P0-P3 issues found. |
| 183 | + |
| 184 | +--- |
| 185 | + |
| 186 | +## CHECKLIST FOR EVERY CHANGE |
| 187 | +- [ ] PR review process completed (no P0-P3 issues) |
| 188 | +- [ ] Scope confirmed |
| 189 | +- [ ] Relevant files read including spec |
| 190 | +- [ ] Header comments present and updated |
| 191 | +- [ ] File under 300 lines or split |
| 192 | +- [ ] Security checked: no secrets, input validated |
| 193 | +- [ ] Errors return helpful messages |
| 194 | +- [ ] Tests pass: npm test in affected package |
| 195 | +- [ ] Examples still validate if parser changed |
| 196 | +- [ ] Version bumped if publishing |
| 197 | +- [ ] CHANGELOG updated if publishing |
0 commit comments