AGENTS MAX
Documentation for Developers
AGENTS-MAX - Full Documentation
DEPRECATED (Session 135): All essential rules have been consolidated into
AGENTS.md. This file is archived for historical reference. DO NOT read this file for current rules. UseAGENTS.md+ MCPget_conventions()instead.
START HERE - Read this files before starting any task:
- Documentation Rules: follow this documentation: DOCS INSTRUCTIONS
- AI Agent Task System - CRITICAL: Self-learning AI system
- Claude-Docs (all docs inside)
- Then continue with the analysis of the data below:
NX Library Build System - Critical Rules:
🔧 TypeScript Library Configuration (MANDATORY)
Rule 1: NEVER use rootDir in library tsconfig.lib.json
Problem: TypeScript libraries with rootDir: "./src" emit declarations to dist/lib/src/index.d.ts, but ng-packagr and other consumers expect them at dist/lib/index.d.ts, causing module resolution failures.
// ❌ WRONG - DO NOT DO THIS:
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "../../../dist/libs/my-lib"
}
}
// ✅ CORRECT - Always use this:
{
"compilerOptions": {
"outDir": "../../../dist/libs/my-lib"
// NO rootDir - TypeScript infers it correctly
}
}
Rule 2: Use Custom Builder for Consistency
All libraries should use the custom build-angular-library.js builder for consistent output structure:
// In project.json
{
"targets": {
"build": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/dist/libs/<path-to-lib>"],
"options": {
"command": "node tools/scripts/build/build-angular-library.js <lib-path>"
},
"configurations": {
"production": {
"command": "node tools/scripts/build/build-angular-library.js <lib-path>"
}
},
"defaultConfiguration": "production",
"dependsOn": ["^build"],
"cache": true,
"parallelism": true
}
}
}
Why? The custom builder ensures:
- Declarations are emitted at root level (
dist/lib/index.d.ts) - Consistent behavior across TypeScript and Angular libraries
- Proper cleanup of source pollution
- Compatible with
ng-packagr-liteconsumers
Rule 3: Always Export Through Public API
Problem: Components/services/manifests existing in library but not exported through src/index.ts cause "no exported member" errors.
Solution: Always export everything through the library's public API:
// libs/my-library/src/index.ts
export * from './lib/my-component';
export * from './lib/my-service';
export * from './lib/my-manifest'; // ✅ Don't forget manifests if we are building a module!
export * from './lib/types';
Rule 4: SCSS Import Paths - Use Correct Structure
Problem: Incorrect SCSS import paths cause "Can't find stylesheet to import" errors.
// ❌ WRONG - Old incorrect path:
@use 'libs/libs-foundational/theme-system/theme-styles/src/lib/styles/global.scss';
// ✅ CORRECT - Use this path:
@use 'libs/theme-system/theme-styles/src/lib/styles/global.scss';
Always verify SCSS imports use the correct library path structure.
🚨 Build Troubleshooting Workflow
When encountering build errors:
Check for
rootDirin tsconfig.lib.json# Find all libraries with rootDir find libs -name "tsconfig.lib.json" -exec grep -l '"rootDir"' {} \;Remove
rootDirfrom affected libraries- Edit
tsconfig.lib.jsonand remove therootDirline - Clear caches:
nx reset && rm -rf dist/ tmp/ - Rebuild:
nx build <library-name> --skip-nx-cache
- Edit
Verify output structure
# Check that index.d.ts is at root level (NOT under /src/) ls -la dist/libs/<path-to-lib>/index.*Expected output:
dist/libs/<path-to-lib>/ ├── index.d.ts ✅ At ROOT level ├── index.js └── lib/ ✅ Implementation nestedCheck SCSS import paths
# Find incorrect SCSS imports grep -r "@use 'libs/libs-foundational/theme-system" --include="*.scss"Verify public API exports
- Check
src/index.tsexports all necessary components/services/manifests - Rebuild library after adding exports
- Check
📊 Quick Reference - Common Errors & Fixes
| Error | Root Cause | Fix |
|---|---|---|
TS2307: Cannot find module '@libs-foundational/core-models' |
rootDir: "./src" in dependency's tsconfig |
Remove rootDir, clear cache, rebuild |
Module has no exported member 'ComponentName' |
Missing export in src/index.ts |
Add export * from './lib/component' |
Can't find stylesheet to import |
Incorrect SCSS path | Update to libs/theme-system/... |
index.d.ts nested under /src/ in dist |
Using @nx/js:tsc with rootDir |
Switch to custom builder OR remove rootDir |
💡 Prevention Guidelines
When creating new libraries:
✅ USE THE LIBRARY GENERATOR SCRIPT (Recommended!)
yarn create:lib:proper # or node tools/scripts/create-library.jsThis automatically creates libraries with correct configuration.
✅ DO NOT add
rootDirtotsconfig.lib.json✅ USE the custom builder in
project.json✅ EXPORT all public APIs through
src/index.ts✅ VERIFY output structure after first build
✅ USE correct SCSS import paths (
libs/theme-system/...)✅ CLEAR caches after config changes (
nx reset)
Build System Documentation:
- Full analysis:
docs/english/GoGrab-Space/libs/BUILD_SYSTEM_FIX_SUMMARY.md - Quick reference:
docs/english/GoGrab-Space/libs/QUICK_FIX_GUIDE.md - Custom builder:
tools/scripts/build/build-angular-library.js - Library generator:
tools/scripts/create-library.js(seetools/scripts/create-library-README.md)
Editor Monorepo Rules:
🎯 What is GoGrab Space?
GoGrab Space (gograb-space NX App) is the most innovative, powerful, modern, and robust platform for building, organizing, and managing complete platforms (aka "universes") through the use of modules, reusable blocks, and AI-powered vibe coding.
Vision: Become the Ferrari/Lamborghini of visual platform builders and vibe coding tools.
🏗️ Monorepo Architecture
Repository Structure
editor/ # Current monorepo (production-ready)
├── apps/
│ ├── gograb-space/ # Main platform app (port 5200)
│ ├── gograb-admin/ # Admin dashboard (port 4300)
│ ├── space-admin/ # Space management (port 5300)
│ ├── docs-angular/ # Documentation system (port 5010)
│ └── backend-api/ # Backend API service (port 3000)
├── libs/
│ ├── core/ # Core TypeScript libraries
│ ├── libs-foundational/ # Foundation libs (core-models, storage-system, etc.)
│ ├── libs-ui/ # UI component libraries
│ ├── libs-ux/ # UX enhancement libraries
│ ├── libs-structural/ # Structural components (editor, modularity, etc.)
│ ├── libs-ai/ # AI integration libraries (gograb-ai, prompt-system)
│ ├── libs-widgets/ # Widget management
│ ├── libs-space/ # Space management features
│ ├── libs-api/ # API integration libraries
│ └── theme-system/ # Theme system and styling
├── modules/ # Modular features directory
│ ├── new-user-management/
│ ├── space-management/
│ └── structural/
└── tools/ # Build scripts and utilities
└── scripts/
├── build/ # Custom build system
└── create-library.js # Library generator
Important Path Mappings
All libraries use path aliases defined in tsconfig.base.json:
@libs-core/*→ Core TypeScript libraries@libs-foundational/*→ Foundation libraries@libs-ui/*→ UI components@libs-structural/*→ Structural features@libs-ai/*→ AI-powered features@theme-system/*→ Theme system@storage-system→ Storage system library (found in the libs-foundational folder)
⚠️ Critical: Always use these path aliases, never relative paths across library boundaries.
🧩 Module System Architecture
Core Philosophy
GoGrab Space uses a modular architecture where every feature is a self-contained, reusable module that:
- 📦 Self-registers via manifests
- 🔄 Communicates through ActionRegistry and EventBus
- 💾 Stores data using storage-system with flash-persistence
- 🎯 Exposes capabilities through standardized interfaces
- 🤖 AI-trainable for intelligent code generation
Module Contract System
Current Standard: BrowserModuleContract from @libs-core/module-base
// Module implementation example
export class MyModule implements BrowserModuleContract {
readonly moduleId = 'my-module';
readonly manifest: ModuleManifest = { /* ... */ };
async configure(config: ModuleConfiguration): Promise<void> { /* ... */ }
async initialize(): Promise<void> { /* ... */ }
async start(): Promise<void> { /* ... */ }
async stop(): Promise<void> { /* ... */ }
async destroy(): Promise<void> { /* ... */ }
}
Key Module Libraries
- @libs-core/module-base - Core module contracts and interfaces
- @libs-core/action-registry - Inter-module communication
- @libs-core/event-system - Event-driven architecture
- @storage-system - Persistent storage
- @libs-foundational/core-models - Shared type definitions
Module Communication Patterns
// Action Registry (inter-module communication)
actionRegistry.registerAction('my-module', 'doSomething', async (params) => {
// Handle action
});
// Event Bus (reactive events)
eventBus.emit('module:loaded', { moduleId: 'my-module' });
// Storage System (persistent state)
storage.set('module:my-module:config', config);
For more information regarding the module system, for example how to create a new module, how to register a module, how to communicate between modules, how to store data in the module, etc., follow this documentation:
- GoGrab-Space/modules (all docs inside - single source of truth)
- GoGrab-Space/architecture (system architecture docs)
🎨 Angular Architecture Rules
Component Structure
Workflow Rules:
Follow this documentation when we start a new workflow: WORKFLOW RULES (all docs inside)
Ai Agent Instructions: Follow this documentation when we start a new ai agent: AI AGENT INSTRUCTIONS (all docs inside)
Github Rules:
Do not commit, nor push to github, unless the user asks you to do so.
MANDATORY: Use Angular 20+ Standalone API - NO NgModules
// ✅ CORRECT: Standalone component
@Component({
selector: 'app-my-component',
standalone: true,
imports: [CommonModule, ReactiveFormsModule],
templateUrl: './my-component.component.html',
styleUrl: './my-component.component.scss'
})
export class MyComponent { }
// ❌ WRONG: Using NgModule
@NgModule({ declarations: [MyComponent] })
export class MyModule { }
File Separation
ALWAYS keep files separate - NO inline templates or styles:
my-component/
├── my-component.component.ts # Logic only
├── my-component.component.html # Template only
├── my-component.component.scss # Styles only
└── my-component.component.spec.ts # Tests only
Type Definition Rules
CRITICAL: Never define types locally in components or services!
// ❌ WRONG: Defining types in component
@Component({...})
export class MyComponent {
interface MyData { id: string; } // DON'T DO THIS
}
// ✅ CORRECT: Types in models directory
// libs/my-lib/src/lib/models/my-data.model.ts
export interface MyData { id: string; }
// Then import
import { MyData } from '../models';
Why? Prevents build errors like "Cannot destructure property" and promotes reusability.
💾 Storage System Architecture
Flash Persistence System
GoGrab Space uses an advanced flash-persistence system for instant state synchronization:
// Services automatically persist state
@Injectable()
export class MyService {
private storage = inject(GgStorage);
async saveState(state: MyState) {
// Flash persistence: instant sync across tabs/sessions
await this.storage.set('my-state', state);
}
}
Storage Layers
- In-Memory Cache - Instant access (< 1ms)
- IndexedDB - Browser persistence (< 10ms)
- Backend Sync - Cloud synchronization (async)
- Flash Updates - Real-time cross-tab sync
🔄 Reactive Programming Rules (MANDATORY)
State Management Hierarchy
Use this priority order for all state management:
- Angular Signals (preferred for synchronous state)
- RxJS Observables (for async operations)
- autoFlashState (for persisted reactive state)
❌ NEVER Use Promises
Promises are FORBIDDEN in this codebase. Always use RxJS Observables instead.
// ❌ WRONG - Using Promises
async loadTheme(themeId: string): Promise<Theme> {
const theme = await this.storage.get(themeId);
return theme;
}
// ✅ CORRECT - Using RxJS
loadTheme(themeId: string): Observable<Theme> {
return from(this.storage.get(themeId)).pipe(
catchError(error => {
this.logger.error('Failed to load theme:', error);
return of(null);
})
);
}
❌ NEVER Use setTimeout
Use RxJS timer() or delay() instead of setTimeout:
// ❌ WRONG
setTimeout(() => this.doSomething(), 1000);
// ✅ CORRECT
timer(1000).pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(() => this.doSomething());
✅ Use autoFlashState for Persisted State
// ✅ CORRECT - Flash-persisted reactive state
readonly activeThemeId = autoFlashState<string | null>('active-theme-id', null, {
database: 'theme-system',
collection: 'preferences',
priority: 'critical',
ttl: 90 * 24 * 60 * 60 * 1000,
debounceMs: 50
});
// Update state (instant + auto-persisted)
this.activeThemeId.set(newThemeId);
✅ Converting Legacy Promises to RxJS
When working with APIs that return Promises, wrap them with from():
// Converting Promise-based storage to Observable
loadFromStorage(key: string): Observable<Data> {
return from(this.storage.get(key)).pipe(
map(data => data ?? defaultValue),
catchError(() => of(defaultValue))
);
}
Why RxJS Over Promises?
- Cancellation - Observables can be cancelled with
takeUntil/takeUntilDestroyed - Operators - Rich transformation pipeline (
map,filter,switchMap, etc.) - Consistency - Angular's HttpClient, Router, Forms all use Observables
- Memory Management - Automatic cleanup with
takeUntilDestroyed - Composability - Easy to combine multiple async streams
Backend API Integration
All backend communication goes through @libs-api/* libraries:
// Backend API structure
apis/backend-api/
├── src/
│ ├── modules/
│ │ ├── auth/
│ │ ├── storage/
│ │ ├── universes/
│ │ └── widgets/
│ └── main.ts
Port: 3000 (configurable via environment)
🎨 Theme System
Theme Architecture
Location: libs/theme-system/
SCSS Import Paths (Critical - See NX Library Build System section):
// ✅ CORRECT
@use 'libs/theme-system/theme-styles/src/lib/styles/global.scss';
// ❌ WRONG
@use 'libs/libs-foundational/theme-system/...'; // Old path, deprecated
Theme System Rules
Never override theme colors directly
- Use theme utilities and CSS variables
- Extend capabilities, don't override
Use CSS Variables for styling (NOT @Input())
:host { --component-bg: var(--ux-surface); --component-text: var(--ux-text-primary); }Theme System Libraries:
@theme-system/theme-styles- Core styles and mixins@theme-system/theme-runtime- Runtime theme switching@theme-system/cosmic-backgrounds- Visual effects
🤖 AI Integration
⚠️ CRITICAL: Always Analyze gograb-ai Library First
BEFORE making ANY AI-related changes, you MUST:
- Read
libs/libs-ai/gograb-ai/src/lib/models/ai-models.ts- Contains all verified AI model definitions - Read
docs/english/GoGrab-Space/libs/libs-ai/gograb-ai/gograb-ai.md- Comprehensive AI documentation - Check existing services in
@libs-ai/gograb-ai-libfor reusable functionality
Why? The gograb-ai library contains:
- Verified working model configurations (e.g.,
claude-3-opus-20240229works across ALL API tiers) - Model capabilities, pricing, and tier information
- Existing AI services that should be reused, not duplicated
When working on backend AI (apis/backend-api/src/app/ai/):
- Ensure model names match those in
@libs-ai/gograb-ai-lib/src/lib/models/ai-models.ts - Use the
DEFAULT_MODELSconstant from gograb-ai as reference - Do NOT create duplicate model configurations - align with gograb-ai
AI-Powered Features
GoGrab Space includes extensive AI integration:
- @libs-ai/gograb-ai-lib - Core AI services (START HERE for AI work)
- @libs-ai/prompt-system - Intelligent prompting
- @libs-ai/ai-data-connector - Data analysis
Vibe Coding
Philosophy: Build through natural language and visual interfaces
// AI can understand module manifests to generate code
const manifest: ModuleManifest = {
id: 'my-feature',
name: 'My Feature',
actions: [/* AI-discoverable actions */],
widgets: [/* AI-composable widgets */]
};
AI Training Goals
- Modules are self-documenting through manifests
- Patterns are learnable from component structure
- Code generation follows consistent conventions
- Visual building through drag-and-drop + AI suggestions
🛠️ Development Workflow
Port Configuration
Default Ports (Multi-monorepo setup):
- GoGrab Space:
5200 - Space Admin:
5300 - GoGrab Admin:
4300 - Docs Angular:
5010 - Backend API:
3000 - UX Test:
4200
Node Configuration:
NODE_OPTIONS="--max-old-space-size=8192 --max-listeners=30"
Common Commands
# Development
yarn serve:gograb-space # Start gograb-space (port 5200)
yarn serve:docs # Start documentation (port 5010)
yarn serve:backend-api # Start backend API (port 3000)
# Building
yarn build:all # Build all projects
yarn build:libs:auto # Build libraries only
yarn build:apps:auto # Build apps only
# Library Management
yarn create:lib:proper # Create new library (RECOMMENDED)
yarn fix:libs # Fix library issues
# Documentation
yarn docs:scan # Scan and update docs manifest
Build System Best Practices
Always clear caches after config changes:
nx reset && rm -rf dist/ tmp/Use
--skip-nx-cachewhen debugging build issues:nx build my-lib --skip-nx-cacheVerify build outputs:
ls -la dist/libs/<category>/<lib-name>/index.* # Should see: index.d.ts, index.js at ROOT level
📚 Documentation System
Active Documentation Root
Location: docs/ (configured in apps/docs-angular/docs-config.ts)
For more information regarding the documentation system, for example how to write documentation, how to find documentation, how to organize documentation, etc., follow this documentation: DOCS INSTRUCTIONS
🔄 gograb-modules Monorepo Sync
Two-Team Structure
- Editor Monorepo (current) - Production platform
- gograb-modules Monorepo (external) - Module system R&D
Key Sync Areas
The gograb-modules team leads innovation in:
- Module architecture patterns
- Module communication protocols
- Module manifest structures
- AI-powered code generation
Sync Strategy: Analyze docs/english/GoGrab-modules/ for latest patterns and architectural decisions.
Integration Status
Current State: This editor monorepo has:
- ✅ Working module system (
@libs-core/module-base) - ✅ Backend API integration
- ✅ Storage system with flash-persistence
- ✅ Event system for communication
- ✅ Action registry for inter-module actions
- ⚠️ Routes: Currently static (manifest-based routes proved complex)
Route Strategy Decision: Static routes with modular components provides better control than fully dynamic manifest-based routing.
⚠️ Common Pitfalls & Solutions
1. Module Resolution Errors
Problem: Cannot find module '@libs-foundational/core-models'
Solution: Remove rootDir from tsconfig.lib.json, clear cache, rebuild
2. Missing Exports
Problem: Module has no exported member 'MyComponent'
Solution: Add export to library's src/index.ts
3. SCSS Import Errors
Problem: Can't find stylesheet to import
Solution: Use correct path libs/theme-system/... (not libs/libs-foundational/...)
4. Build Cache Issues
Problem: Changes not reflecting in build
Solution: nx reset && rm -rf dist/ tmp/
5. Linter Errors After Edits
Problem: TypeScript errors after file changes
Solution: Check running serve process logs (DON'T use build command to check)
🎯 Goals & Vision
Platform Goals
GoGrab Space aims to become:
- Most powerful platform builder on the planet
- Most intelligent visual development environment
- Ultimate vibe coding experience (Ferrari/Lambo level)
- AI-first development platform
Technical Goals
- ✅ Modular Everything: Every feature is a reusable module
- ✅ AI-Trainable: Modules generate modules
- ✅ Visual Building: Drag-drop + AI suggestions
- ✅ Real-time Collaboration: Flash persistence across users
- ✅ Type-Safe: Full TypeScript coverage
- ✅ Performance: Sub-second builds, instant updates
Current Challenges
- Routing Strategy: Static vs. manifest-based (currently using static)
- Module Discovery: Balancing automation vs. control
- Cross-Monorepo Sync: Keeping patterns aligned with gograb-modules
🎨 Design System Guidelines
MANDATORY: Use Theme System for All Styling
All components must use the design system patterns from docs/english/GoGrab-Space/theme-system/design/:
Read Design Docs First:
design-prompts.md- Core design patterns (glassmorphism, gradients, animations)admin-panel-design-system.md- Panel, card, button, form patterns
Required Design Patterns:
- Glassmorphism:
backdrop-filter: blur(16px), semi-transparent backgrounds - Gradient Accents: Use
linear-gradient(135deg, var(--ux-primary), var(--ux-secondary))for primary - Micro-interactions: Hover effects with
translateY(-2px)and enhanced shadows - Border Radius: 20px for panels, 12px for buttons, 16px for cards
- Glassmorphism:
**Follow our theme system design system for all styling: theme-system
🔲 Modal System Guidelines
MANDATORY: Use UX Portal for Modals
DO NOT use traditional modal services. Always use the UX Portal system.
Documentation: docs/english/GoGrab-Space/libs/libs-ui/ux-portal/modal-using-portal.md
Implementation Pattern:
import { UxPortalService } from '@libs-ux/ux-portal';
import { UxPortalConfig } from '@libs-ux/ux-portal';
// 1. Inject service
private readonly portalService = inject(UxPortalService);
// 2. Setup global handlers BEFORE opening portal
private setupModalHandlers(): void {
(window as any).closeModal = () => {
this.portalService.closePortal('modal-id');
};
(window as any).submitForm = (data: any) => {
this.handleSubmit(data);
};
}
// 3. Open portal with inline HTML
async openModal(): Promise<void> {
this.setupModalHandlers(); // CRITICAL: Setup handlers FIRST!
const config: UxPortalConfig = {
id: 'modal-id',
content: { type: 'string', data: this.getModalHTML() },
backdrop: { type: 'modal', enabled: true, blur: 8 },
container: { mode: 'modal', closeOnEscape: true },
positioning: { strategy: 'center' }
};
this.portalService.openPortal(config);
}
Common Issues:
- ❌ DON'T define functions in embedded
<script>tags (timing issues) - ❌ DON'T use external HTML files (won't load)
- ✅ DO define handlers globally BEFORE opening portal
- ✅ DO use inline HTML strings
🧩 Existing Library Usage
ALWAYS check for existing libraries before creating new functionality:
- Modals/Dialogs: Use
@libs-ux/ux-portal(NOT traditional modal services) - Storage: Use
@storage-systemwithGgStorageandautoFlashState - Logging: Use
@libs-core/log-systemwithLoggerService - Events: Use
@libs-core/event-system - Actions: Use
@libs-core/action-registry
General Guidelines for working with Nx
- When running tasks (for example build, lint, test, e2e, etc.), always prefer running the task through
nx(i.e.nx run,nx run-many,nx affected) instead of using the underlying tooling directly - You have access to the Nx MCP server and its tools, use them to help the user
- When answering questions about the repository, use the
nx_workspacetool first to gain an understanding of the workspace architecture where applicable. - When working in individual projects, use the
nx_project_detailsmcp tool to analyze and understand the specific project structure and dependencies - For questions around nx configuration, best practices or if you're unsure, use the
nx_docstool to get relevant, up-to-date docs. Always use this instead of assuming things about nx configuration - If the user needs help with an Nx configuration or project graph error, use the
nx_workspacetool to get any errors
Connection Rules:
- If you lose connection to the server, immediately reconnect again.
- DO Not kill/restart Server processes, unless the user asks you to do so, rather, include in the workflow that the user should kill/restart the server processes themselves.