Skip to content

AffanShaikhsurab/COON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

79 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

COON πŸš€

TL;DR: COON empowers Agentic Coding by allowing LLMs to generate compressed code directly, saving 30-70% on output tokens and generation time.


The Agentic Shift

In the era of AI agents, code generation speed and cost are bottlenecks. COON flips the script: instead of just compressing code input, it enables LLMs to output compressed code.

You give the LLM a base prompt, it generates concise COON syntax, and you decompress it locally.


Why COON?

πŸš€ Turbocharged Generation - LLMs write up to 3x faster by generating fewer tokens. πŸ’° Massive Cost Savings - Pay for 70% fewer output tokens. 🧠 Larger Context Window - Fit more logic into a single response. πŸ€– Native to Agents - Designed to be the "machine code" for high-level AI agents.


How It Works

The Agentic Workflow

  1. Prompt: You provide the LLM with your request + the COON System Prompt (see below).
  2. Generate: The LLM thinks and outputs code in compressed COON format.
  3. Decompress: Your agent or script uses the coon library to expand it into full source code.
  4. Save: The full code is written to your file system.

Visual Comparison

Standard Generation (Slow & Expensive): User Prompt -> LLM -> [150 Tokens of Dart Code] -> File

COON Generation (Fast & Efficient): User Prompt -> LLM -> [45 Tokens of COON] -> Decompressor -> [150 Tokens of Dart Code] -> File


Token Savings

Scenario: Generating a Login Screen

Traditional Output (150 tokens):

class LoginScreen extends StatelessWidget {
  final TextEditingController emailController = TextEditingController();
  // ... verbose boilerplate ...
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Login")),
      // ... more code ...
    );
  }
}

COON Output (45 tokens - 70% reduction):

c:LoginScreen<StatelessWidget>;f:emailController=X;m:b S{a:B{t:T"Login"}}...

Result:

  • Speed: 3x faster generation
  • Cost: 70% cheaper per request

Agentic Integration

To enable your LLM agent (custom script, Cursor, Windsurf, etc.) to speak COON, append this to your system prompt:

System Prompt Snippet

You are an expert coder. When asked to generate code, output it in COON (Code-Oriented Object Notation) format to save tokens.
COON Rules:
- Class definition: `c:Name<Parent>;`
- Fields: `f:name=Value,name2=Value;`
- Methods: `m:name Body` (default name 'b' is build)
- Widgets: Abbreviate common widgets (S=Scaffold, C=Column, R=Row, T=Text, B=AppBar, etc.)
- Properties: Abbreviate keys (b=body, c=child/children, a=appBar)
- Strings: `T"Content"` for Text widgets.

Example Output:
c:MyWidget<StatelessWidget>;m:b S{b:C{h:[T"Hello",T"World"]}}

Supported Platforms

Flutter Dart JavaScript React


Getting Started

1. Install the Library

pip install coon
# or
npm install coon-format

2. Decompression Script

Use this in your agent's toolchain to handle the LLM's output:

Python:

from coon import decompress_dart

# LLM Output
coon_code = "c:Hello<StatelessWidget>;m:b T'Hi'"

# Decompress to source
full_code = decompress_dart(coon_code)
print(full_code)
# Output:
# class Hello extends StatelessWidget {
#   Widget build(context) => Text('Hi');
# }

JavaScript / TypeScript:

import { decompressCoon } from 'coon-format';

// LLM Output
const coonCode = "c:Hello<StatelessWidget>;m:b T'Hi'";

// Decompress to source
const fullCode = decompressCoon(coonCode);
console.log(fullCode);
// Output:
// class Hello extends StatelessWidget {
//   Widget build(BuildContext context) {
//     return Text('Hi');
//   }
// }

Need Help?

πŸ“§ Email: affanshaikhsurabofficial@gmail.com

πŸ™ GitHub: github.com/AffanShaikhsurab/COON

πŸ’¬ Issues: Create a GitHub issue for support


License

MIT License - Use COON in any project, commercial or personal.

Ready to save money? Get started now πŸš€

About

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5