Overview
GLYPH is available for 5 languages: Python, JavaScript/TypeScript, Go, Rust, and C. Choose your language below for installation instructions.
All implementations provide the same core functionality: parsing, emitting, JSON conversion, and fingerprinting.
Python
Requirements
- Python 3.8 or higher
- pip (Python package manager)
Install
Verify Installation
import glyph
# Check version
print(f"GLYPH version: {glyph.__version__}")
# Test basic functionality
data = {"test": "success", "active": True}
text = glyph.json_to_glyph(data)
print(f"GLYPH output: {text}")
# Expected: {active=t test=success}
restored = glyph.glyph_to_json(text)
assert restored == data
print("✓ Installation verified")
Available Functions
Core Functions
Value Constructors
Streaming
import glyph
# JSON conversion
glyph.json_to_glyph(data) # Python → GLYPH
glyph.glyph_to_json(text) # GLYPH → Python
# Parsing and emitting
glyph.parse(text) # Parse GLYPH text
glyph.emit(value) # Emit GLYPH text
# Fingerprinting
glyph.fingerprint_loose(data) # SHA-256 hash
glyph.equal_loose(a, b) # Semantic equality
from glyph import g, field
# Primitives
g.null()
g.bool(True)
g.int(42)
g.float(3.14)
g.str("hello")
# Collections
g.list(g.int(1), g.int(2), g.int(3))
g.map(field("key", g.str("value")))
g.struct("TypeName", field("x", g.int(1)))
from glyph import StreamingValidator, ToolRegistry
# Define tools
registry = ToolRegistry()
registry.register("search", args={...})
# Validate streaming tokens
validator = StreamingValidator(registry)
for token in stream:
result = validator.push(token)
if result.has_errors():
break
JavaScript / TypeScript
Requirements
- Node.js 16 or higher
- npm or yarn
Install
Verify Installation
import { ... } from 'glyph-js';
// Test basic functionality
const data = { test: 'success', active: true };
const text = emit(fromJSON(data));
console.log(`GLYPH output: ${text}`);
// Expected: {active=t test=success}
const value = parse(text);
const restored = toJSON(value);
console.log('✓ Installation verified');
Available Functions
Core Functions
Value Constructors
Fingerprinting
import { ... } from 'glyph-js';
// JSON conversion
const gv = fromJSON(data); // JS → GValue
const obj = toJSON(gv); // GValue → JS
// Parsing and emitting
const value = parse(text); // Parse GLYPH text
const text = emit(value); // Emit GLYPH text
import { ... } from 'glyph-js';
// Primitives
g.null()
g.bool(true)
g.int(42)
g.float(3.14)
g.str('hello')
// Collections
g.list(g.int(1), g.int(2), g.int(3))
g.map(field('key', g.str('value')))
g.struct('TypeName', field('x', g.int(1)))
import { ... } from 'glyph-js';
const data = { user: 'alice', count: 42 };
const hash = fingerprintLoose(data);
// sha256:a1b2c3d4...
TypeScript Support
GLYPH-JS includes full TypeScript definitions:
import { ... } from 'glyph-js';
const value: GValue = parse('{name=Alice age=30}');
const name: string | undefined = value.get('name');
Requirements
Install
go get github.com/Neumenon/glyph
Verify Installation
Create test.go:
package main
import (
"fmt"
"log"
"github.com/Neumenon/glyph/glyph"
)
func main() {
// Test basic functionality
text := `{test=success active=t}`
val, err := glyph.Parse([]byte(text))
if err != nil {
log.Fatal(err)
}
fmt.Printf("Parsed value: %v\n", val)
// Convert to JSON
data, err := glyph.ToJSONLoose(val)
if err != nil {
log.Fatal(err)
}
fmt.Printf("JSON: %v\n", data)
fmt.Println("✓ Installation verified")
}
Run:
Available Functions
Parsing & Emitting
JSON Conversion
Fingerprinting
Accessing Values
import "github.com/Neumenon/glyph/glyph"
// Parse GLYPH text
val, err := glyph.Parse([]byte(text))
// Emit GLYPH text
text := glyph.CanonicalizeLoose(val)
// Go data → GLYPH
data := map[string]interface{}{
"name": "Alice",
"age": 30,
}
v := glyph.FromJSONLoose(data)
text := glyph.CanonicalizeLoose(v)
// GLYPH → Go data
val, _ := glyph.Parse([]byte(text))
data, err := glyph.ToJSONLoose(val)
// Compute SHA-256 hash
hash := glyph.FingerprintLoose(val)
// sha256:a1b2c3d4...
// Check equality
equal := glyph.EqualLoose(v1, v2)
val, _ := glyph.Parse([]byte(`{name=Alice age=30}`))
// Access fields
name := val.Get("name").String() // "Alice"
age := val.Get("age").Int() // 30
// Check types
if val.Get("name").IsString() {
fmt.Println("name is a string")
}
Rust
Requirements
- Rust 1.70 or higher
- Cargo (Rust package manager)
Install
Add to your Cargo.toml:
[dependencies]
glyph-codec = "0.1"
Or use cargo:
Verify Installation
Create src/main.rs:
use glyph_codec::{from_json, to_json, canonicalize_loose};
use serde_json::json;
fn main() {
// Test basic functionality
let data = json!({
"test": "success",
"active": true
});
let gvalue = from_json(&data);
let glyph = canonicalize_loose(&gvalue);
println!("GLYPH output: {}", glyph);
// Expected: {active=t test=success}
let restored = to_json(&gvalue);
assert_eq!(restored, data);
println!("✓ Installation verified");
}
Run:
Available Functions
use glyph_codec::{from_json, to_json, canonicalize_loose};
use serde_json::json;
// JSON → GLYPH
let data = json!({"action": "search"});
let gvalue = from_json(&data);
let glyph = canonicalize_loose(&gvalue);
// GLYPH → JSON
let json = to_json(&gvalue);
use glyph_codec::parse;
let gvalue = parse("{name=Alice age=30}").unwrap();
Requirements
- GCC or Clang
- Make
- Standard C library
Install
Clone Repository
git clone https://github.com/Neumenon/glyph.git
cd glyph/c/glyph-codec
Build Library
This creates:
build/libglyph.a (static library)
build/libglyph.so (shared library)
Verify Installation
Create test.c:
#include "glyph.h"
#include <stdio.h>
#include <assert.h>
int main() {
// Test basic functionality
glyph_value_t *v = glyph_from_json(
"{\"test\": \"success\", \"active\": true}"
);
char *glyph = glyph_canonicalize_loose(v);
printf("GLYPH output: %s\n", glyph);
// Expected: {active=t test=success}
// Convert back to JSON
char *json = glyph_to_json(v);
printf("JSON: %s\n", json);
// Cleanup
glyph_free(glyph);
glyph_free(json);
glyph_value_free(v);
printf("✓ Installation verified\n");
return 0;
}
Compile and run:
gcc -I./include test.c -L./build -lglyph -lm -o test
./test
Available Functions
JSON Conversion
Value Construction
Parsing
Fingerprinting
#include "glyph.h"
// JSON → GLYPH
glyph_value_t *v = glyph_from_json(
"{\"action\": \"search\"}"
);
char *glyph = glyph_canonicalize_loose(v);
// GLYPH → JSON
char *json = glyph_to_json(v);
// Cleanup
glyph_free(glyph);
glyph_free(json);
glyph_value_free(v);
// Create map
glyph_value_t *map = glyph_map_new();
glyph_map_set(map, "name", glyph_str("Alice"));
glyph_map_set(map, "age", glyph_int(30));
// Emit
char *text = glyph_canonicalize_loose(map);
// {age=30 name=Alice}
glyph_free(text);
glyph_value_free(map);
// Parse GLYPH text
glyph_value_t *v = glyph_parse("{name=Alice age=30}");
// Access fields
glyph_value_t *name = glyph_get(v, "name");
const char *name_str = glyph_as_str(name);
glyph_value_t *age = glyph_get(v, "age");
int64_t age_int = glyph_as_int(age);
glyph_value_free(v);
// Compute hash
char *hash = glyph_fingerprint_loose(v);
printf("Hash: %s\n", hash);
glyph_free(hash);
Memory Management: Always free strings returned by GLYPH functions using glyph_free(), and free values using glyph_value_free().
Linux
All implementations work out of the box on Linux.
macOS
- Python, JavaScript, Go, Rust: Work natively
- C: May need Xcode Command Line Tools:
Windows
- Python, JavaScript: Work with standard installers
- Go, Rust: Work with official Windows installers
- C: Requires MinGW or Visual Studio:
# Using MinGW
mingw32-make
Development Setup
Running Tests
Python
JavaScript
Go
Rust
C
cd py
python -m pytest tests/ -v
cd c/glyph-codec
make test
Building from Source
# Clone repository
git clone https://github.com/Neumenon/glyph.git
cd glyph
# Choose your language directory
cd py # or js, go, rust, c/glyph-codec
# Follow language-specific build instructions
Troubleshooting
Python: ModuleNotFoundError
Make sure you installed from the correct environment:python -m pip install glyph-serial
# Verify
python -c "import glyph; print(glyph.__version__)"
JavaScript: Module not found
Check your package.json has the dependency:npm list glyph-js
# Reinstall if needed
npm install glyph-js
Make sure your go.mod is set up:go mod init your-project
go get github.com/Neumenon/glyph
Ensure you have build tools:# Ubuntu/Debian
sudo apt-get install build-essential
# macOS
xcode-select --install
# Check GCC
gcc --version
Next Steps
Now that you have GLYPH installed:
Quickstart Guide
Get working code in 5 minutes
API Reference
Complete API documentation
Agent Patterns
Tool calling and state management
Cookbook
10 practical recipes
Get Help