From b68504da63332665f47962703140d2c9dc8e3c8c Mon Sep 17 00:00:00 2001 From: Sean Luis Date: Fri, 14 Nov 2025 13:11:11 -0300 Subject: [PATCH 1/2] Update config options for ASON 2.0 and improve documentation - Replace useDictionary with useSections and useTabular in config - Add minFieldsForSection, minRowsForTabular, minReferenceOccurrences - Change default delimiter to pipe ("|") for tabular arrays - Update README to document new options and ASON 2.0 features - Revise MCP server responses and stats output for new config fields --- README.md | 62 +++++++++++++++++------------ src/index.ts | 91 ++++++++++++++++++++++++++++++++++--------- src/tools/compress.ts | 8 +++- src/tools/stats.ts | 8 +++- src/types.ts | 6 ++- 5 files changed, 127 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 1bb04be..27782db 100644 --- a/README.md +++ b/README.md @@ -73,27 +73,29 @@ Compress JSON data to ASON format. "json": {"users": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]}, "config": { "indent": 1, - "delimiter": ",", + "delimiter": "|", "useReferences": true, - "useDictionary": true + "useSections": true, + "useTabular": true } } ``` **Output:** ``` -ASON Output: +ASON 2.0 Output: -users:[2]@id,name -1,Alice -2,Bob +users:[2]{id,name} +1|Alice +2|Bob Configuration used: { "indent": 1, - "delimiter": ",", + "delimiter": "|", "useReferences": true, - "useDictionary": true + "useSections": true, + "useTabular": true } ``` @@ -104,7 +106,7 @@ Decompress ASON back to JSON. **Input:** ```json { - "ason": "users:[2]@id,name\n1,Alice\n2,Bob" + "ason": "users:[2]{id,name}\n1|Alice\n2|Bob" } ``` @@ -128,7 +130,7 @@ Analyze compression statistics. "json": {"users": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]}, "config": { "indent": 1, - "delimiter": "," + "delimiter": "|" } } ``` @@ -148,9 +150,10 @@ Savings: 37 bytes Configuration: { "indent": 1, - "delimiter": ",", + "delimiter": "|", "useReferences": true, - "useDictionary": true + "useSections": true, + "useTabular": true } ``` @@ -163,7 +166,7 @@ Update global compression settings. { "config": { "indent": 2, - "delimiter": "|", + "delimiter": ",", "useReferences": false } } @@ -175,9 +178,10 @@ Global configuration updated: { "indent": 2, - "delimiter": "|", + "delimiter": ",", "useReferences": false, - "useDictionary": true + "useSections": true, + "useTabular": true } ``` @@ -186,9 +190,13 @@ Global configuration updated: | Option | Type | Default | Description | |--------|------|---------|-------------| | `indent` | number | `1` | Indentation level for nested structures | -| `delimiter` | string | `","` | Field delimiter for uniform arrays | -| `useReferences` | boolean | `true` | Enable object reference aliasing (`&obj0`) | -| `useDictionary` | boolean | `true` | Enable inline-first value dictionary (`value #0`) | +| `delimiter` | string | `"|"` | Field delimiter for tabular arrays (pipe, comma, or tab) | +| `useReferences` | boolean | `true` | Enable `$var` reference deduplication | +| `useSections` | boolean | `true` | Enable `@section` organization for objects | +| `useTabular` | boolean | `true` | Enable `[N]{fields}` tabular format for arrays | +| `minFieldsForSection` | number | `3` | Minimum fields to create a `@section` | +| `minRowsForTabular` | number | `2` | Minimum rows for tabular array format | +| `minReferenceOccurrences` | number | `2` | Minimum occurrences to create a `$var` reference | ## Development @@ -218,9 +226,9 @@ Claude: I'll use the compress_json tool to compress this JSON. [Uses MCP tool compress_json] Result: -products:[2]@id,name,price -1,Laptop,999 -2,Mouse,25 +products:[2]{id,name,price} +1|Laptop|999 +2|Mouse|25 This compressed version uses 45% fewer tokens! ``` @@ -250,11 +258,17 @@ To release a new version: - ✅ **Continue** (VS Code extension) - ✅ **Any MCP client** with stdio transport -## 📚 What is ASON? +## 📚 What is ASON 2.0? + +ASON (Aliased Serialization Object Notation) 2.0 is a token-optimized JSON compression format designed for LLMs. It reduces token usage by 20-60% while maintaining 100% lossless round-trip fidelity. -ASON (Aliased Serialization Object Notation) is a token-optimized JSON compression format designed for LLMs. It reduces token usage by 20-60% while maintaining 100% lossless round-trip fidelity. +**Key features:** +- **Sections** (`@section`) - Organize related objects +- **Tabular Arrays** (`key:[N]{fields}`) - CSV-like format for uniform arrays +- **References** (`$var`) - Deduplicate repeated values +- **Pipe Delimiter** (`|`) - More token-efficient than commas -**Learn more**: [github.com/ason-format/ason](https://github.com/ason-format/ason) +**Learn more**: [ason-format.github.io/ason](https://ason-format.github.io/ason/) ## 📖 Documentation diff --git a/src/index.ts b/src/index.ts index f49a7d2..e95621f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,9 +11,13 @@ import type { CompressorConfig } from "./types.js"; */ let globalConfig: CompressorConfig = { indent: 1, - delimiter: ",", + delimiter: "|", useReferences: true, - useDictionary: true, + useSections: true, + useTabular: true, + minFieldsForSection: 3, + minRowsForTabular: 2, + minReferenceOccurrences: 2, }; /** @@ -53,15 +57,31 @@ class AsonMCPServer { delimiter: z .string() .optional() - .describe('Field delimiter (default: ",")'), + .describe('Field delimiter (default: "|")'), useReferences: z .boolean() .optional() - .describe("Enable object references (default: true)"), - useDictionary: z + .describe("Enable $var references (default: true)"), + useSections: z .boolean() .optional() - .describe("Enable value dictionary (default: true)"), + .describe("Enable @section organization (default: true)"), + useTabular: z + .boolean() + .optional() + .describe("Enable [N]{fields} tabular arrays (default: true)"), + minFieldsForSection: z + .number() + .optional() + .describe("Min fields to create @section (default: 3)"), + minRowsForTabular: z + .number() + .optional() + .describe("Min rows for tabular format (default: 2)"), + minReferenceOccurrences: z + .number() + .optional() + .describe("Min occurrences for $var reference (default: 2)"), }) .optional() .describe("Optional compression configuration"), @@ -84,11 +104,12 @@ class AsonMCPServer { { type: "text", text: - `Here's your compressed ASON format! The compression achieved:\n\n` + + `Here's your compressed ASON 2.0 format! The compression achieved:\n\n` + `**Key optimizations:**\n` + - `• Value deduplication: Repeated values are stored once as references\n` + - `• Compact syntax: Removed JSON's braces, brackets, and quotes where possible\n` + - `• Dot notation: Nested objects use concise dot notation\n\n` + + `• Sections (@section): Organize related data\n` + + `• Tabular Arrays ([N]{fields}): CSV-like format for uniform arrays\n` + + `• References ($var): Deduplicate repeated values\n` + + `• Pipe Delimiter (|): More token-efficient than commas\n\n` + `The ASON format is **fully reversible** back to the original JSON - it's lossless compression optimized for reducing token usage when working with LLMs!\n\n` + `\`\`\`ason\n` + result.ason + @@ -141,15 +162,31 @@ class AsonMCPServer { delimiter: z .string() .optional() - .describe('Field delimiter (default: ",")'), + .describe('Field delimiter (default: "|")'), useReferences: z .boolean() .optional() - .describe("Enable object references (default: true)"), - useDictionary: z + .describe("Enable $var references (default: true)"), + useSections: z + .boolean() + .optional() + .describe("Enable @section organization (default: true)"), + useTabular: z .boolean() .optional() - .describe("Enable value dictionary (default: true)"), + .describe("Enable [N]{fields} tabular arrays (default: true)"), + minFieldsForSection: z + .number() + .optional() + .describe("Min fields to create @section (default: 3)"), + minRowsForTabular: z + .number() + .optional() + .describe("Min rows for tabular format (default: 2)"), + minReferenceOccurrences: z + .number() + .optional() + .describe("Min occurrences for $var reference (default: 2)"), }) .optional() .describe("Optional compression configuration for analysis"), @@ -168,7 +205,7 @@ class AsonMCPServer { `📊 **Compression Statistics**\n\n` + `**Tokens**: ${stats.original_tokens} → ${stats.compressed_tokens} (${stats.reduction_percent.toFixed(1)}% reduction)\n` + `**Size**: ${stats.original_size} → ${stats.compressed_size} bytes (saved ${stats.savings_bytes} bytes)\n\n` + - `*Config: indent=${stats.config.indent}, delimiter="${stats.config.delimiter}", refs=${stats.config.useReferences}, dict=${stats.config.useDictionary}*`, + `*Config: indent=${stats.config.indent}, delimiter="${stats.config.delimiter}", refs=${stats.config.useReferences}, sections=${stats.config.useSections}, tabular=${stats.config.useTabular}*`, }, ], }; @@ -189,11 +226,27 @@ class AsonMCPServer { useReferences: z .boolean() .optional() - .describe("Enable object references"), - useDictionary: z + .describe("Enable $var references"), + useSections: z + .boolean() + .optional() + .describe("Enable @section organization"), + useTabular: z .boolean() .optional() - .describe("Enable value dictionary"), + .describe("Enable [N]{fields} tabular arrays"), + minFieldsForSection: z + .number() + .optional() + .describe("Min fields for @section"), + minRowsForTabular: z + .number() + .optional() + .describe("Min rows for tabular"), + minReferenceOccurrences: z + .number() + .optional() + .describe("Min occurrences for $var"), }) .describe("New global configuration"), }, @@ -207,7 +260,7 @@ class AsonMCPServer { content: [ { type: "text", - text: `✓ Global configuration updated:\n\n**indent**: ${globalConfig.indent}\n**delimiter**: "${globalConfig.delimiter}"\n**useReferences**: ${globalConfig.useReferences}\n**useDictionary**: ${globalConfig.useDictionary}`, + text: `✓ Global configuration updated:\n\n**indent**: ${globalConfig.indent}\n**delimiter**: "${globalConfig.delimiter}"\n**useReferences**: ${globalConfig.useReferences}\n**useSections**: ${globalConfig.useSections}\n**useTabular**: ${globalConfig.useTabular}\n**minFieldsForSection**: ${globalConfig.minFieldsForSection}\n**minRowsForTabular**: ${globalConfig.minRowsForTabular}\n**minReferenceOccurrences**: ${globalConfig.minReferenceOccurrences}`, }, ], }; diff --git a/src/tools/compress.ts b/src/tools/compress.ts index 2c819b7..ee26dd4 100644 --- a/src/tools/compress.ts +++ b/src/tools/compress.ts @@ -17,9 +17,13 @@ export function compressJson(input: CompressJsonInput): { ason: string; config: ason, config: { indent: config.indent ?? 1, - delimiter: config.delimiter ?? ',', + delimiter: config.delimiter ?? '|', useReferences: config.useReferences ?? true, - useDictionary: config.useDictionary ?? true + useSections: config.useSections ?? true, + useTabular: config.useTabular ?? true, + minFieldsForSection: config.minFieldsForSection ?? 3, + minRowsForTabular: config.minRowsForTabular ?? 2, + minReferenceOccurrences: config.minReferenceOccurrences ?? 2 } }; } diff --git a/src/tools/stats.ts b/src/tools/stats.ts index 6ebb7b1..e7850f4 100644 --- a/src/tools/stats.ts +++ b/src/tools/stats.ts @@ -26,9 +26,13 @@ export function getCompressionStats(input: GetStatsInput): CompressionStats & { savings_bytes: stats.original_size - stats.compressed_size, config: { indent: config.indent ?? 1, - delimiter: config.delimiter ?? ',', + delimiter: config.delimiter ?? '|', useReferences: config.useReferences ?? true, - useDictionary: config.useDictionary ?? true + useSections: config.useSections ?? true, + useTabular: config.useTabular ?? true, + minFieldsForSection: config.minFieldsForSection ?? 3, + minRowsForTabular: config.minRowsForTabular ?? 2, + minReferenceOccurrences: config.minReferenceOccurrences ?? 2 } }; } diff --git a/src/types.ts b/src/types.ts index 4c99e2d..2dd8f78 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,7 +5,11 @@ export interface CompressorConfig { indent?: number; delimiter?: string; useReferences?: boolean; - useDictionary?: boolean; + useSections?: boolean; + useTabular?: boolean; + minFieldsForSection?: number; + minRowsForTabular?: number; + minReferenceOccurrences?: number; } /** From 29bdcb04e79b4d0defcfe4565407105e67b50c6d Mon Sep 17 00:00:00 2001 From: Sean Luis Date: Sun, 16 Nov 2025 18:12:03 -0300 Subject: [PATCH 2/2] Release 2.0.0-preview with ASON 2.0 support and config updates --- CHANGELOG.md | 30 ++++++++++++++++++++++++++++++ package.json | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c864c2c..e45aceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.0.0-preview] - 2025-01-14 + +### Changed +- **BREAKING: ASON 2.0 Support** - Updated to support ASON 2.0 format +- **Configuration Options Updated**: + - ❌ Removed `useDictionary` (no longer exists in ASON 2.0) + - ✅ Added `useSections` - Enable `@section` organization for objects (default: true) + - ✅ Added `useTabular` - Enable `key:[N]{fields}` tabular arrays (default: true) + - ✅ Added `minFieldsForSection` - Min fields to create @section (default: 3) + - ✅ Added `minRowsForTabular` - Min rows for tabular format (default: 2) + - ✅ Added `minReferenceOccurrences` - Min occurrences for $var reference (default: 2) + - Changed default `delimiter` from `","` to `"|"` (pipe is more token-efficient) +- **Syntax Updates**: + - Arrays now use `key:[N]{fields}` instead of `key:[N]@fields` + - Tabular data uses pipe delimiter `|` by default instead of comma `,` + - References now use `$var` semantic names (already supported) + - Sections use `@section` for objects (already supported) +- **Updated Documentation**: + - All examples in README.md updated to ASON 2.0 syntax + - Tool descriptions updated to reflect new format + +### Dependencies +- Updated `@ason-format/ason` to `^2.0.0-preview` (from `^1.1.3`) + +### Migration Notes +- If you have existing MCP server configurations, update: + - `useDictionary: true` → Remove (or replace with `useSections: true, useTabular: true`) + - `delimiter: ","` → `delimiter: "|"` (recommended) +- ASON output format has changed - see ASON 2.0 documentation + ## [1.1.3] - 2025-11-13 ### Changed diff --git a/package.json b/package.json index 49857c3..ba7e696 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ason-format/mcp-server", - "version": "1.1.3", + "version": "2.0.0-preview", "description": "Model Context Protocol server for ASON compression/decompression. Compatible with Claude Desktop, Cline, Continue, and other MCP clients.", "type": "module", "main": "./dist/index.js", @@ -56,7 +56,7 @@ }, "dependencies": { "@modelcontextprotocol/sdk": "^1.21.1", - "@ason-format/ason": "^1.1.3" + "@ason-format/ason": "^2.0.0-preview" }, "devDependencies": { "@types/node": "^22.0.0",