Stellify Framework

0.2.2 · active · verified Sun Apr 19

Stellify Framework, currently at version 0.2.2, is a nascent frontend library meticulously engineered for optimal interoperability with AI code generation tools. Its primary objective is to mitigate common AI-induced issues like hallucination and inconsistent output by enforcing a highly constrained and predictable API surface. Unlike traditional frameworks that often offer multiple ways to achieve a single task, Stellify adheres to a "one obvious way" philosophy, coupled with a strict "Rule of Seven" for API method counts per module. The framework differentiates itself with Laravel-style chainable patterns, a core that remains agnostic to frontend frameworks, and dedicated adapters for React and Vue. This design ethos aims to foster more reliable and consistent code generation from AI agents. While specific release cadence details are not yet public, its low version number indicates active, early-stage development, suggesting potential for rapid evolution and breaking changes as it matures.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates core Stellify modules including form creation with validation, real-time LLM streaming to a UI element, voice input processing, and basic chat conversation management.

import { Form, Stream, Chat, Speech } from 'stellify-framework';

// Mock function for UI interaction
function appendToUI(text) {
  const streamOutput = document.getElementById('stream-output');
  if (streamOutput) {
    streamOutput.textContent += text;
  } else {
    console.log('Stream chunk:', text);
  }
}

// Mock chat state
const chat = {
  messages: [],
  addUser(text) {
    this.messages.push({ role: 'user', content: text });
    console.log('User added message:', text);
  },
  addAssistant(text) {
    this.messages.push({ role: 'assistant', content: text });
    console.log('Assistant added message:', text);
  },
  getMessages() { return this.messages; },
  fork() { console.log('Chat forked for regeneration.'); }
};

// Form with validation
const userForm = Form.create({ name: '', email: '' })
  .validate({ email: v => v?.includes('@') ? null : 'Invalid' })
  .onSuccess(data => console.log('Form submission successful:', data))
  .onError(errors => console.error('Form validation errors:', errors))
  .store('/api/users'); // This would typically trigger a fetch

console.log('Initial form data:', userForm.getData());
userForm.setData({ name: 'Jane Doe', email: 'jane@example.com' });
userForm.store('/api/users'); // Re-run store with new data

// LLM streaming
const dataStream = Stream.create('/api/chat')
  .onChunk(text => appendToUI(text))
  .onComplete(() => console.log('Streaming complete.'))
  .post({ messages: chat.getMessages() }); // Post initial chat messages

// Voice input
const speechInput = Speech.create()
  .onResult(text => chat.addUser(text))
  .onError(error => console.error('Speech recognition error:', error))
  .listen({ continuous: true }); // Start listening continuously

// Conversation management
chat.addUser('What is 2+2?');
chat.addAssistant('4');
chat.fork(); // Branch for regeneration

view raw JSON →