Skip to content

sugarcrm-developers/ai-for-sugar-devs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI for Sugar Devs πŸ€–πŸ¬

AI for Sugar Devs is a deterministic, agent-agnostic system for generating installable, upgrade-safe SugarCRM Module Loadable Packages (MLPs) using AI.

Designed for Sugar developers, it automates module generation while enforcing Extension Framework compliance, upgrade safety, and deterministic outputs.


πŸš€ Quick Start for Humans

You're reading the right file! This is the entry point for developers like you.

Step 1: Understand the Workflow

Review the workflow diagram and examples below to understand the complete process.

Step 2: Pick Your Feature Type

Choose your feature type from the examples and feature list below.

Step 3: Read Feature Specifications

Choose your feature type from /prompts/:

Step 4: Format Your Request

Use the format from prompts/feature_request_format.md and the examples below.

Step 5: Prompt the AI

Give the AI agent your formatted feature request. It will generate a complete package.

Step 6: Test & Install

cd build/<PackageName>
php pack.php 1.0.0
# Install the zip via Module Loader in Sugar

πŸ”„ Complete Workflow

Visual Workflow Diagram

sequenceDiagram
    participant Human as πŸ‘€ Developer (You)
    participant Docs as πŸ“š Documentation
    participant AI as πŸ€– AI Agent
    participant Build as πŸ“¦ Build Output
    participant Sugar as 🍬 SugarCRM

    Human->>Docs: 1. Read README.md
    Docs-->>Human: Overview & Complete Workflow
    
    Human->>Docs: 2. Review Examples Below
    Docs-->>Human: Feature Examples & Specifications
    
    Human->>Docs: 3. Read prompts/<feature_type>.md
    Docs-->>Human: Complete Specifications
    
    Human->>AI: 4. Submit Feature Request
    Note over AI: Reads AGENTS.md<br/>(Execution Contract)
    
    AI->>Docs: Consult prompts/<feature_type>.md
    Docs-->>AI: Feature Specifications
    
    AI->>Docs: Consult reference/master_reference.md
    Docs-->>AI: SugarCRM Extension Framework
    
    AI->>Build: 5. Generate Package
    Note over Build: build/<PackageName>/<br/>src/, pack.php,<br/>version, releases/
    
    AI-->>Human: Output Raw File Entries
    
    Human->>Build: 6. Run: php pack.php 1.0.0
    Build-->>Human: sugarcrm-<PackageName>-1.0.0.zip
    
    Human->>Sugar: 7. Install via Module Loader
    Sugar-->>Human: βœ… Package Installed
Loading

Step-by-Step Workflow

  1. You write feature request
  2. You read relevant prompt (or quick reference)
  3. You prompt AI with your request
  4. AI generates package in build/<PackageName>/
  5. You test with: php build/<PackageName>/pack.php
  6. You install zip in Sugar via Module Loader

πŸ“š Real-World Examples

Need templates to get started? Check the examples/ folder for copy/paste feature requests:

Two Ways to Request Features

Option 1: Use the structured format from examples

Feature Type: Custom Field
Module: Accounts
Field Name: customer_priority
Field Type: varchar
Label: Customer Priority
Package Name: Acme_AccountsPriority

Option 2: Describe in natural language

"A custom varchar field named customer_priority is added to the Accounts module under the package Test_AccountsCustomField, labeled "Customer Priority," and designed as a highlight field that allows users to choose background and foreground colors in Studio."

Both work equally well! Use whichever format feels more natural for your request.

Want to contribute your own? See examples/README.md to add examples for other feature types!


πŸ”§ Key Points for All Features

  • βœ… Review the workflow diagram and examples above
  • βœ… Choose your feature type from the examples
  • βœ… Read prompts/<feature_type>.md for complete specifications
  • βœ… Follow the format from prompts/feature_request_format.md
  • βœ… Prompt the AI with your formatted request
  • βœ… Test with php build/<PackageName>/pack.php
  • βœ… Install via Module Loader in Sugar

πŸ“š Features

  • Generate full MLPs: Logic Hooks, Custom Fields, Relationships, REST Endpoints, Scheduler Jobs, UI Customizations
  • Extension Framework only β€” no core overrides
  • Self-contained per-package builds in /build/<PackageName>/
  • Production-ready pack.php per package
  • Deterministic output β€” raw file entries, upgrade-safe, ready for Module Loader
  • Agent-agnostic β€” works with Claude, Copilot, ChatGPT, Codex, etc.

πŸ“ Architecture Overview

Each generated feature lives in an isolated directory:

/build/<PackageName>/
    src/                      # All Sugar files (Extension Framework only)
    pack.php                  # Executable package builder
    version                   # Version file
    releases/                 # Generated zip output

Running the package builder:

cd build/<PackageName>
php pack.php 1.0.0

Produces:

build/<PackageName>/releases/sugarcrm-<PackageName>-1.0.0.zip

Ready for Module Loader installation in Sugar.


πŸ“– Documentation Structure

README.md                     ← YOU ARE HERE (complete guide for humans)
β”œβ”€β”€ AGENTS.md                ← Technical contract (for AI agents, not humans)
└── prompts/
    β”œβ”€β”€ feature_request_format.md .... How to format your request
    β”œβ”€β”€ [11 feature-specific specs]
    β”‚   β”œβ”€β”€ logic_hook.md ........... Logic hook specifications
    β”‚   β”œβ”€β”€ custom_field.md ......... Simple field specifications
    β”‚   β”œβ”€β”€ custom_field_type.md .... Complex field type specifications
    β”‚   β”œβ”€β”€ relationship.md ......... Relationship specifications
    β”‚   β”œβ”€β”€ rest_endpoint.md ........ REST endpoint specifications
    β”‚   β”œβ”€β”€ scheduler.md ............ Scheduler specifications
    β”‚   β”œβ”€β”€ ui_customization.md ..... UI customization specifications
    β”‚   β”œβ”€β”€ feature_generator.md .... Master generation prompt
    β”‚   β”œβ”€β”€ pack_php.md ............ Pack.php generation
    β”‚   └── external_resource_client.md  HTTP request handling
└── reference/
    β”œβ”€β”€ README.md ........................... Reference guide
    β”œβ”€β”€ master_reference.md ................ Complete SugarCRM specs
    └── sugar_developer_guide_25.2_md/ .... Official SugarCRM documentation

βš™οΈ For AI Agents (Not for Humans)

AI agents: Read AGENTS.md for the binding execution contract.

This document specifies:

  • Mandatory directory structure
  • Required file formats
  • Extension Framework compliance rules
  • pack.php specifications
  • Output format requirements
  • Quality assurance checklist

πŸ”§ Key Points

  • No embedded Sugar Developer Guide content
  • Deterministic file output format

πŸ›  How to Use

1️⃣ Upload Repo to AI Agent

Upload the full repository to your AI coding agent (Claude, Copilot, ChatGPT, Codex, etc.).


2️⃣ Submit a Feature Request

Use the structured format defined in /prompts/feature_request_format.md.

Example Feature Requests & Updates

Logic Hook β†’ Webhook (Accounts)

Read and follow AGENTS.md strictly.
Read and follow prompts/feature_generator.md strictly.
No explanations. No markdown. Output raw file entries only.

Feature Type: Logic Hook
Module: Accounts
Trigger: after_save
Condition:
  field: account_type = 'Customer' or
  field: account_type = 'Prospect'
Action:
  type: webhook
  method: POST
  url: https://webhooks.com/mywebhook
  payload: full bean
  extract the response if http 200 log the result and return 'myresponse'
Package Name: Custom_AccountsCustomerWebhook

Custom Field β†’ New Account Field

Feature Type: Custom Field
Module: Accounts
Field Name: customer_priority
Field Type: varchar
Label: Customer Priority
Package Name: OOTB_AccountsCustomField

REST Endpoint β†’ Custom Contacts API

Feature Type: REST Endpoint
Module: Contacts
Endpoint: /custom/contacts/summary
Method: GET
Action: return summary of contact activity
Package Name: OOTB_ContactsSummaryEndpoint

Updating an Existing Package

Feature Type: Logic Hook
Module: Accounts
Trigger: after_save
Condition:
  field: account_status
  equals: Active
Action:
  type: webhook
  method: POST
  url: https://webhooks.com/active-customer
  payload: full bean
Package Name: OOTB_AccountsCustomerWebhook
Update: true

Update Workflow:

  1. Increment /version in the package directory.
  2. Submit feature request with Update: true.
  3. AI generates only the new/modified files.
  4. Run php pack.php <version> to produce new zip.
  5. Upload via Module Loader β€” upgrade-safe.

3️⃣ Build the Package

After AI generates the package:

cd build/<PackageName>
php pack.php 1.0.0

This produces the installable zip in:

build/<PackageName>/releases/sugarcrm-<PackageName>-1.0.0.zip

4️⃣ Install in Sugar

Upload the generated zip via Admin β†’ Module Loader.

Install β€” fully upgrade-safe, no manual corrections required.


πŸ— Project Structure

/AGENTS.md                              # Execution rules and standards
/prompts/
    feature_request_format.md           # Deterministic AI input schema
    feature_generator.md                # Generation instructions (CRITICAL - read first)
    pack_php.md                         # Pack.php generation rules (CRITICAL - prevents pack.php mistakes)
    external_resource_client.md         # ExternalResourceClient usage guide (CRITICAL - HTTP requests)
    logic_hook.md                       # Logic hook generation
    custom_field.md                     # Custom field generation
    relationship.md                     # Relationship generation
    rest_endpoint.md                    # REST endpoint generation
    scheduler.md                        # Scheduler job generation
    ui_customization.md                 # UI customization generation
    compliance_review.md                # Compliance checking
/templates/minimal_mlp/           
    pack.stub.php                       # Reference pack.php template (see pack_php.md)
/build/                            # Generated packages live here
/output/                           # Optional staging of zips
/reference/                        # Sugar Developer Guide (never included in output)
/README.md
/LICENSE

⚠️ CRITICAL PROMPTS (Read Before Generation):

  1. AGENTS.md β€” Authoritative execution contract
  2. prompts/feature_generator.md β€” Generation rules
  3. prompts/pack_php.md β€” Pack.php generation (prevents static array mistakes)
  4. prompts/external_resource_client.md β€” HTTP requests (prevents getInstance() errors)

βš™οΈ Developer Workflow Summary (1-Page Cheat Sheet)

Step Command / Action Notes
Upload repo to AI β€” Any agent: Claude, Copilot, ChatGPT, Codex
Submit feature request See structured format Include Update: true for updates
Check output /build/<PackageName>/src/, pack.php, version All files deterministic and Extension Framework only
Build zip cd build/<PackageName>
php pack.php 1.0.0
Version file determines zip
Install Module Loader β†’ Upload zip Upgrade-safe, no manual corrections
Update package Increment version
Submit feature request with Update: true
Only new files generated; old files remain intact

Supported Feature Types: Logic Hooks, Custom Fields, Relationships, REST Endpoints, Scheduler Jobs, UI Customizations


πŸ” Why This Matters

AI can generate Sugar code, but without structure it produces inconsistent and unsafe packages.

This system ensures:

  • Extension Framework purity
  • Upgrade safety by contract
  • Deterministic builds β€” reproducible, testable packages
  • Stateless, parallelizable execution

It transforms AI from a code assistant into a controlled, production-ready Sugar MLP compiler.

About

Open-Source hub for integrating AI into SugarCRM development

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages