Stone.js

website·Indexed 32 days ago

https://stonejs.dev

The Continuum framework that allows developers to write their domain once to execute across server, edge, browser, and agent contexts.

Tokens
951
Snippets
1
Records
8
Agent score
16%

What's inside Stone.js

  1. Overview of Stone.js Extensions

    Stone.js provides opt-in capabilities that attach via blueprints to extend framework functionality. Available extensions include:

    • Validation: Unified schema enforcement for both APIs and forms.
    • Auth: Stateless JWT/OAuth implementation using requireAuth and requireScopes.
    • Authorization: Isomorphic RBAC and ABAC using defineAbility and authorize.
    • Resources: Output shaping via defineResource, fields, and envelopes.
    • OpenAPI: Automatic derivation of public contracts from schemas.
    • Testing: Behavioral testing using createTestApp and send(makeIncomingHttpEvent).
    • MCP Server & llms.txt: Agent tooling and documentation map generation.
    • Telemetry: Pluggable exporters for spans and metrics.
  2. Stone.js Architecture Overview

    Stone.js implements the 'Continuum Architecture', where an application is defined as: Domain × Context = Resolution. The developer writes the pure domain logic, and adapters supply the runtime context (e.g., Node, AWS Lambda, Cloudflare, Deno, Bun, Browser, or AI agents).

    Key architectural concepts include:

    • Superposition and Collapse: The domain exists in superposition across contexts and 'collapses' into a specific implementation at runtime based on the active adapter.
    • Ephemeral Context: A fresh container is created per event; only the adapter remains long-lived.
    • Blueprint: An immutable manifest addressed by stone.* keys that configures the application pipeline.
  3. Advanced Stone.js Architectural Patterns

    Stone.js supports advanced 'Frontier' patterns for modern application delivery:

    • Universal Apps: Implements SSR as a superposition of browser and server contexts.
    • Agent-native Patterns: Domain design optimized for machine consumption.
    • Performance: Optimized for fast construction and minimal cold starts.
    • Security: Focuses on a small trusted base and secure defaults at the boundary.
  4. Extend Stone.js with Custom Adapters, Plugins, and Decorators

    Stone.js allows developers to author their own building blocks through several extension points:

    • Adapters: Open new execution contexts using three primary verbs.
    • Packages/Plugins: Created using blueprints, providers, and decorators/define* functions.
    • Decorators: Based on TC39 stage-3 and Symbol.metadata, utilizing addMetadata and addBlueprint.
    • CLI Commands: Define custom commands using @Command or defineCommand, supporting arguments, flags, and I/O.
  5. Stone.js Kernel Primitives

    The Stone.js kernel is built upon three core primitive libraries:

    • Pipeline: Implements the chain of responsibility pattern using send, through, and then.
    • Service Container: A standalone library providing Dependency Injection (DI).
    • Config: A deep dotted-key store that serves as the underlying mechanism for Blueprints.
  6. Scaffold a new Stone.js project

    Use the official starter command to scaffold a new project with ready-to-use templates and community solutions.
    npm create @stone-js -- --starter <id>
  7. Available Runtime Adapters

    Adapters allow the same domain to be deployed to different environments. Available adapters include:

    • Node HTTP: @NodeHttp for production HTTP servers on Node.js.
    • Node CLI: @NodeConsole and @Command for CLI tools.
    • Fetch: @Fetch for Web-standard environments (Cloudflare, Deno, Bun, Vercel, Netlify).
    • AWS Lambda: @AwsLambdaHttp (for API Gateway) and @AwsLambda (generic).
    • Browser: @Browser for SPAs and hydration.
    • MCP: @Mcp to expose the domain as tools for AI agents.
    • Mobile: Forthcoming support for React Native / Expo.
  8. Supported Development Paradigms and Forms

    Stone.js supports two development paradigms at strict parity:

    1. Declarative: Uses TC39 stage-3 decorators with Symbol.metadata.
    2. Imperative: Uses define* meta-modules.

    Within these paradigms, three forms are supported everywhere: class, factory, and function. Note that the function form never receives the container, and providers forbid it.