@atmyapp/cli v0.0.4
๐ AtMyApp CLI
๐ง Migrate your TypeScript definitions seamlessly. The official CLI tool for AtMyApp - AI-powered content management that migrates your type definitions to the AtMyApp platform with zero configuration and lightning-fast parallel processing.
๐ Table of Contents
- ๐ Features
- ๐ฆ Installation
- ๐ Quick Start
- ๐ Commands
- โก Performance Features
- ๐ฏ Type Definitions
- ๐ก Examples
- ๐ง Configuration
- ๐๏ธ Architecture
- ๐งช Testing
- ๐ค Contributing
- ๐ License
๐ Features
โจ Automated Type Migration - Extracts TypeScript definitions and migrates them automatically
๐ Event Analytics Support - Built-in support for event tracking definitions
๐ผ๏ธ Media Type Support - Handles image and file definitions with optimization configs
๐ Real-time Processing - Process multiple definition files simultaneously
โก Lightning Fast - Multi-threaded parallel processing for large codebases
๐ฏ Type-Safe - Full TypeScript support with comprehensive validation
๐ Zero Configuration - Works out of the box with smart defaults
๐ Secure - API key authentication with session management
๐ Pipeline Architecture - Extensible processing pipeline for custom transformations
๐ Performance Monitoring - Built-in timing and performance metrics
๐ฆ Installation
# npm
npm install -g @atmyapp/cli
# yarn
yarn global add @atmyapp/cli
# pnpm
pnpm add -g @atmyapp/cli
๐ Quick Start
# 1. Authenticate with your AtMyApp project
ama use --token your-api-token --url https://your-project.atmyapp.com
# 2. Migrate your definitions with parallel processing
ama migrate
# 3. Or run in dry-run mode to preview changes
ama migrate --dry-run --verbose
๐ Commands
use Command
Authenticate and configure your AtMyApp project connection.
ama use [options]
Options:
-t, --token <token>
- Authentication token-u, --url <url>
- Project base URL
Interactive Mode:
ama use
# Will prompt for token and URL if not provided
Example:
ama use --token "ama_pk_..." --url "https://edge.atmyapp.com/projects/your-project-id"
migrate Command
Migrate TypeScript definitions to the AtMyApp platform with optimized parallel processing.
ama migrate [options]
Options:
--dry-run
- Generate definitions without uploading (default: false)--verbose
- Enable verbose logging (default: false)--tsconfig <path>
- Path to tsconfig.json (default: "tsconfig.json")--continue-on-error
- Continue processing even if some files fail (default: false)--parallel
- Enable parallel processing using worker threads (default: true)--max-workers <number>
- Maximum number of worker threads (default: CPU cores, max 8)--no-filtering
- Disable file pre-filtering optimization (default: false)
Examples:
# Basic migration with parallel processing (default)
ama migrate
# Dry run with verbose output and performance metrics
ama migrate --dry-run --verbose
# Use custom tsconfig and continue on errors
ama migrate --tsconfig ./custom-tsconfig.json --continue-on-error
# Force sequential processing (slower, for debugging)
ama migrate --no-parallel
# Use specific number of worker threads
ama migrate --max-workers 4
# Maximum performance for large codebases
ama migrate --max-workers 8 --verbose
โก Performance Features
Multi-threaded Processing
The CLI uses Node.js worker threads to process TypeScript files in parallel, providing significant performance improvements for large codebases:
- Automatic scaling: Uses optimal number of workers based on CPU cores
- Smart filtering: Pre-filters files to only process those with ATMYAPP exports
- Program caching: Reuses TypeScript compilation results across workers
- Batch processing: Groups schema generation for maximum efficiency
Performance Optimizations
- File Pre-filtering: Quickly scans files for ATMYAPP exports before processing
- Worker Pool Management: Efficiently distributes work across available CPU cores
- TypeScript Program Caching: Avoids redundant compilation overhead
- Parallel Schema Generation: Processes multiple definition types simultaneously
- Chunked Processing: Handles large file sets in optimized chunks
Performance Monitoring
Enable verbose mode to see detailed performance metrics:
ama migrate --verbose
Sample Output:
โ
Successfully processed 127 AMA contents in 2.34s
๐ Performance Summary:
Total time: 3.45s
Processing time: 2.34s
Files processed: 127
Processing mode: Parallel
Worker threads: 8
Expected Performance Improvements
With parallel processing enabled (default), you can expect:
- Small codebases (< 50 files): 1.5-2x faster
- Medium codebases (50-200 files): 2-4x faster
- Large codebases (200+ files): 3-6x faster
๐ฏ Type Definitions
Content Definitions
Define structured content using AmaContentDef
:
import { AmaContentDef } from "@atmyapp/core";
// Define your content structure
interface BlogPost {
title: string;
content: string;
publishedAt: string;
author: {
name: string;
avatar: string;
};
tags: string[];
}
// Create a typed content definition
export type BlogPostContent = AmaContentDef<"/blog/featured", BlogPost>;
// Export for migration
export type ATMYAPP = [BlogPostContent];
Event Definitions
Define analytics events using AmaCustomEventDef
with ordered columns:
import { AmaCustomEventDef } from "@atmyapp/core";
// Define event types for analytics tracking
export type PageViewEvent = AmaCustomEventDef<
"page_view",
["page", "referrer", "timestamp", "user_id"]
>;
export type PurchaseEvent = AmaCustomEventDef<
"purchase",
["product_id", "amount", "currency", "user_id", "timestamp"]
>;
export type ClickEvent = AmaCustomEventDef<
"button_click",
["element", "position", "timestamp"]
>;
// Export all events
export type ATMYAPP = [PageViewEvent, PurchaseEvent, ClickEvent];
Generated Output:
{
"events": {
"page_view": {
"columns": ["page", "referrer", "timestamp", "user_id"]
},
"purchase": {
"columns": ["product_id", "amount", "currency", "user_id", "timestamp"]
},
"button_click": {
"columns": ["element", "position", "timestamp"]
}
}
}
Image & File Definitions
Define optimized media with AmaImageDef
and AmaFileDef
:
import { AmaImageDef, AmaFileDef, AmaImageConfig } from "@atmyapp/core";
// Image with optimization config
interface HeroImageConfig extends AmaImageConfig {
optimizeFormat: "webp";
maxSize: { width: 1920; height: 1080 };
quality: 85;
}
export type HeroImage = AmaImageDef<"/images/hero", HeroImageConfig>;
// File definition
export type UserManual = AmaFileDef<"/docs/manual.pdf">;
export type ATMYAPP = [HeroImage, UserManual];
Icon Definitions
Define icons with AmaIconDef
(simpler than images, no configuration needed):
import { AmaIconDef } from "@atmyapp/core";
// Icon definitions
export type MenuIcon = AmaIconDef<"/icons/menu">;
export type SearchIcon = AmaIconDef<"/icons/search">;
export type UserIcon = AmaIconDef<"/icons/user">;
export type ATMYAPP = [MenuIcon, SearchIcon, UserIcon];
๐ก Examples
๐ช E-commerce Setup
// types/ecommerce.ts
import { AmaContentDef, AmaCustomEventDef, AmaImageDef } from "@atmyapp/core";
// Product catalog
interface Product {
id: string;
name: string;
price: number;
description: string;
inStock: boolean;
category: string;
}
export type ProductCatalog = AmaContentDef<"/products/catalog", Product[]>;
export type FeaturedProduct = AmaContentDef<"/products/featured", Product>;
// Product images
export type ProductImage = AmaImageDef<
"/images/products",
{
optimizeFormat: "webp";
maxSize: { width: 800; height: 800 };
}
>;
// UI Icons
export type CartIcon = AmaIconDef<"/icons/cart">;
export type WishlistIcon = AmaIconDef<"/icons/wishlist">;
export type CompareIcon = AmaIconDef<"/icons/compare">;
// E-commerce events
export type ProductViewEvent = AmaCustomEventDef<
"product_view",
["product_id", "category", "price", "user_id", "timestamp"]
>;
export type AddToCartEvent = AmaCustomEventDef<
"add_to_cart",
["product_id", "quantity", "price", "user_id", "timestamp"]
>;
export type PurchaseEvent = AmaCustomEventDef<
"purchase",
["order_id", "total_amount", "currency", "user_id", "timestamp"]
>;
// Export all definitions
export type ATMYAPP = [
ProductCatalog,
FeaturedProduct,
ProductImage,
CartIcon,
WishlistIcon,
CompareIcon,
ProductViewEvent,
AddToCartEvent,
PurchaseEvent,
];
๐ฐ Blog & Content Management
// types/blog.ts
import {
AmaContentDef,
AmaCustomEventDef,
AmaImageDef,
AmaIconDef,
} from "@atmyapp/core";
// Blog content types
interface BlogPost {
title: string;
slug: string;
content: string;
excerpt: string;
publishedAt: string;
author: {
name: string;
email: string;
avatar: string;
};
tags: string[];
featured: boolean;
}
interface Category {
name: string;
slug: string;
description: string;
color: string;
}
// Content definitions
export type BlogPosts = AmaContentDef<"/blog/posts", BlogPost[]>;
export type FeaturedPost = AmaContentDef<"/blog/featured", BlogPost>;
export type Categories = AmaContentDef<"/blog/categories", Category[]>;
// Featured images
export type BlogHeroImage = AmaImageDef<
"/images/blog/hero",
{
optimizeFormat: "webp";
maxSize: { width: 1200; height: 630 };
}
>;
// Blog UI icons
export type ShareIcon = AmaIconDef<"/icons/share">;
export type LikeIcon = AmaIconDef<"/icons/like">;
export type CommentIcon = AmaIconDef<"/icons/comment">;
// Blog analytics events
export type ArticleReadEvent = AmaCustomEventDef<
"article_read",
["article_id", "reading_time", "completion_rate", "referrer", "timestamp"]
>;
export type CommentEvent = AmaCustomEventDef<
"comment_posted",
["article_id", "comment_id", "user_id", "timestamp"]
>;
export type ShareEvent = AmaCustomEventDef<
"article_shared",
["article_id", "platform", "user_id", "timestamp"]
>;
export type ATMYAPP = [
BlogPosts,
FeaturedPost,
Categories,
BlogHeroImage,
ShareIcon,
LikeIcon,
CommentIcon,
ArticleReadEvent,
CommentEvent,
ShareEvent,
];
๐ฎ User Analytics Dashboard
// types/analytics.ts
import { AmaCustomEventDef } from "@atmyapp/core";
// User interaction events
export type PageViewEvent = AmaCustomEventDef<
"page_view",
["page", "referrer", "user_agent", "session_id", "timestamp"]
>;
export type ClickEvent = AmaCustomEventDef<
"click",
["element", "element_text", "page", "position_x", "position_y", "timestamp"]
>;
export type FormSubmissionEvent = AmaCustomEventDef<
"form_submit",
["form_id", "form_name", "success", "validation_errors", "timestamp"]
>;
export type ScrollEvent = AmaCustomEventDef<
"scroll",
["page", "scroll_depth", "session_id", "timestamp"]
>;
export type ErrorEvent = AmaCustomEventDef<
"error",
["error_message", "error_stack", "page", "user_agent", "timestamp"]
>;
// Performance events
export type PerformanceEvent = AmaCustomEventDef<
"performance",
["page", "load_time", "dom_ready", "first_paint", "timestamp"]
>;
export type ATMYAPP = [
PageViewEvent,
ClickEvent,
FormSubmissionEvent,
ScrollEvent,
ErrorEvent,
PerformanceEvent,
];
๐ง Configuration
Project Structure
your-project/
โโโ .ama/
โ โโโ session.json # Auth credentials (auto-generated)
โ โโโ definitions.json # Generated definitions (auto-generated)
โโโ types/
โ โโโ content.ts # Content definitions
โ โโโ events.ts # Event definitions
โ โโโ media.ts # Image/file definitions
โ โโโ icons.ts # Icon definitions
โโโ .gitignore # Updated automatically
โโโ tsconfig.json # TypeScript config
Environment Setup
The CLI automatically manages configuration through the .ama
directory:
session.json
- Stores authentication token and project URLdefinitions.json
- Generated output (for preview and debugging).gitignore
- Automatically updated to exclude sensitive files
Custom Configuration
// ama.config.ts (optional)
export default {
include: ["src/**/*.ts", "types/**/*.ts"],
exclude: ["**/*.test.ts"],
description: "My Project Definitions",
metadata: {
version: "1.0.0",
author: "Your Name",
environment: process.env.NODE_ENV,
},
};
๐๏ธ Architecture
Processing Pipeline
The CLI uses a modular pipeline architecture:
// 1. File Scanning
scanFiles(patterns)
โ
// 2. TypeScript Processing
createProject(files)
โ
// 3. Definition Extraction
processFiles(sourceFiles)
โ
// 4. Content Processing Pipeline
definitionPipeline.processDefinitions()
โ
// 5. Output Generation
generateOutput(contents)
โ
// 6. Upload (unless --dry-run)
uploadDefinitions(output)
Built-in Processors
- pathNormalizer - Normalizes file paths across platforms
- typeDetector - Detects content, event, image, file, and icon types
- duplicateValidator - Prevents duplicate path definitions
- metadataEnricher - Adds processing metadata to output
Extensibility
import {
definitionPipeline,
DefinitionProcessor,
ValidationRule,
OutputTransformer,
} from "@atmyapp/cli";
// Custom processor
const customProcessor: DefinitionProcessor = {
name: "custom-processor",
process: (content, context) => {
// Your custom logic
return modifiedContent;
},
};
// Register custom components
definitionPipeline.addProcessor(customProcessor);
definitionPipeline.addValidator(customValidator);
definitionPipeline.addOutputTransformer(customTransformer);
๐งช Testing
Running Tests
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run specific test suite
npm test -- --testNamePattern="Content Processor"
Test Structure
tests/
โโโ __tests__/
โ โโโ content-processor.test.ts # Content processing tests
โ โโโ definition-processor.test.ts # Pipeline tests
โ โโโ schema-processor.test.ts # TypeScript processing tests
โ โโโ parallel-processing.test.ts # Parallel processing tests
โ โโโ definitions-examples.test.ts # Example definition tests
โ โโโ integration.test.ts # End-to-end tests
โโโ definitions/
โ โโโ someFile.ts # Basic test definitions
โ โโโ multipleDefinitions.ts # Multi-definition tests
โ โโโ eventDefinitions.ts # Event definition tests
โโโ setup.ts # Test configuration
Example Test
describe("Icon Processing", () => {
it("should detect and process icon definitions", () => {
const contents: Content[] = [
{
path: "/icons/menu",
structure: { __amatype: "AmaIconDef" },
},
];
const contentType = determineContentType(contents[0]);
expect(contentType).toBe("icon");
});
});
๐จ Best Practices
Definition Organization
โ Do:
- Group related definitions in separate files
- Use descriptive type names for icons (e.g.,
MenuIcon
,SearchIcon
) - Keep event column order consistent
- Include comprehensive type documentation
โ Don't:
- Mix content, event, and media definitions unnecessarily
- Use dynamic or computed type names
- Ignore TypeScript compiler errors
Performance Tips
- โ Use specific include patterns to reduce scanning
- โ
Enable
--continue-on-error
for large codebases - โ
Run
--dry-run
first to preview changes - โ
Use
--verbose
for debugging issues
Security
- โ
Keep
.ama/session.json
private - โ Use environment variables for CI/CD
- โ Regularly rotate API tokens
- โ Review generated definitions before upload
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Write tests for your changes
- Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/atmyapp/cli.git
cd cli
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Link for local development
npm link
๐ License
This project is licensed under the ISC License - see the LICENSE file for details.
๐ AtMyApp Website โข ๐ Documentation โข ๐ฌ Support
Made with โค๏ธ by the AtMyApp team
Migrate your definitions with confidence.