riteway

repository·master·Indexed 22 days ago

https://github.com/paralleldrive/riteway

A testing framework (version 9.3.0) designed for AI-Driven Development (AIDD) and software agents. It provides a structured assertion style for unit tests that supply detailed bug reports upon failure and includes a specialized CLI (`riteway ai`) for evaluating AI agent prompts using SudoLang syntax in `.sudo` files.

Tokens
44.1K
Snippets
130
Records
226
Agent score
78%

What's inside riteway

  1. Overview of AI Agent Rules and Guidelines

    master
    The ai/rules/ directory contains specialized instruction files (.mdc and .md) that guide AI agents (like Aiden) in performing specific roles and tasks within the Riteway ecosystem. These rules are organized into subdirectories by domain (frameworks, javascript, security, sudolang) and individual files for specific professional personas or task types.
  2. Standard folder structure and dependency rules in Riteway

    master

    Riteway enforces a layered architecture to manage module dependencies. The hierarchy flows from high-level UI components down to low-level types. When organizing code, follow this dependency direction:

    typesservicespluginscomponents

    Key Dependency Constraints:

    • Components may depend on plugins (specifically Observe<Data> and void actions) and types. They must never depend on services.
    • Plugins may depend on services, types, and other plugins.
    • Services may depend on other services and types. They must never depend on components or plugins.
    • Types may only depend on other types. They must never depend on any other layer.

    Use these rules when creating new folders, moving files, or adding imports to ensure architectural integrity.

    DependencyRules [
      { layer: "components", mayDependOn: ["plugins (Observe<Data>, void actions)", "types"], mustNotDependOn: ["services"] },
      { layer: "plugins", mayDependOn: ["services", "types", "other plugins"], mustNotDependOn: [] },
      { layer: "services", mayDependOn: ["other services", "types"], mustNotDependOn: ["components", "plugins"] },
      { layer: "types", mayDependOn: ["other types"], mustNotDependOn: ["everything else"] }
    ]
  3. Use action callbacks instead of events

    master

    In Lit elements, communication from the presentation back to the binding element should use action callbacks, not events.

    • Naming Convention: Use verbNoun semantics (e.g., toggleView, signOut) rather than event-style names like onClick or onToggle.
    • Implementation: The binding element passes the callback (which calls a service or transaction directly) to the presentation. The presentation simply invokes the callback when a user intent occurs.
    // Binding element: binds the action (verbNoun)
    toggleView: () => this.toggleToolbarChild(name)
    
    // Presentation: receives and invokes when user acts
    item.toggleView()
  4. Understand the Observe pattern and Observe<T>

    master

    The Observe<T> pattern (from @adobe/data/observe) is a subscription mechanism used for reactive data flow. An Observe<T> instance is a function with the signature:

    (notify: (value: T) => void) => Unobserve

    When you subscribe to an observable, you provide a notify callback that is invoked zero or more times (either synchronously or asynchronously) whenever the value changes. The subscription returns an Unobserve function, which must be called to stop observing and prevent memory leaks.

    Use this pattern when working with observables, reactive data flows, or service properties that require subscription-based updates.

  5. Distinguish between Terminal and Layout components

    master

    To maintain UI efficiency and predictable styling, every component must be classified as either a TerminalComponent or a LayoutComponent. There is no overlap between these two types.

    Terminal Components

    Terminal components are the leaves of the component tree. They are responsible for rendering actual UI elements and their visual appearance.

    • Renders: Own UI (e.g., buttons, inputs, cards, text).
    • Styling: Contains CSS for appearance.
    • Constraint: Must never contain any external margin.

    Layout Components

    Layout components are structural containers used to organize other components.

    • Renders: Does not render any UI themselves; composed of other layout or terminal components only.
    • Responsibility: Manages interior gaps between children.
    • Constraint: Must never contain any external margin.
    • Styling: Should use standard layout tokens and should not require custom CSS 90% of the time.
    • Performance: Should generally contain no business logic and should never re-render. This keeps re-renders localized to the terminal levels.
    • Exceptions: Layout components that explicitly manage layout-specific state (e.g., animating, tabs, accordions) may contain logic and re-render.
    TerminalComponent {
      renders: "own UI (buttons, inputs, cards, text, etc.)"
      contains: "CSS for appearance"
      never: "contain any external margin"
      role: "leaves of the component tree; own visual styling and content"
    }
    
    LayoutComponent {
      doesNotRender: "any UI themselves"
      composedOf: "other layout or terminal components only"
      responsibleFor: "interior gaps between children"
      never: "contain any external margin"
      css: "Should not need CSS 90% of the time or more — use standard layout tokens"
      reRender: "Generally no business logic; should never re-render — keeps re-renders at terminal levels"
      exception: "Some layout components explicitly manage state (animating, tabs, accordions) — those have logic and may re-render"
    }
  6. Use the Aiden Agent Orchestrator for multi-role assistance

    master
    The agent-orchestrator.mdc rule is always active. It instructs the agent to act as a Senior Software Engineer, Product Manager, Project Manager, and Technical Writer assistant, utilizing reflective thinking to solve complex problems.
  7. Understand the /aidd-namespace output structure

    master

    After running /aidd-namespace on a file like src/types/point.ts, the tool generates a directory structure that follows this pattern:

    1. The Namespace Entry Point: src/types/point/point.ts contains the main type definitions and re-exports everything from public.js under the namespace name.
    2. The Public Aggregator: src/types/point/public.ts re-exports all logic from the individual implementation files.
    3. Individual Implementation Files: Each exported member (e.g., length.ts, add.ts) is moved to its own file for better modularity.
    // Resulting structure for src/types/point.ts:
    
    // src/types/point/point.ts
    export type Point = { x: number, y: number };
    export * as Point from "./public.js";
    
    // src/types/point/public.ts
    export * from "./length.js";
    export * from "./add.js";
    
    // src/types/point/length.ts
    export const length = ({ x, y }: Point) => Math.hypot(x, y);
    
    // src/types/point/add.ts
    export const add = ({ x: x1, y: y1 }: Point, { x: x2, y: y2 }: Point): Point => ({ x: x1 + x2, y: y1 + y2 });
  8. Use the Observe pattern for reactive data flow

    master

    When working with reactive data flows, observables, or service Observe properties, follow the best practices defined in the Observe pattern. This pattern is specifically required when implementing or interacting with the following methods:

    • Observe.withMap
    • Observe.withFilter
    • Observe.fromConstant
    • Observe.fromProperties

    Adhere to the standards established by @adobe/data/observe to ensure consistent behavior in observable-based systems.

  9. Understand the hotspot score formula

    master

    The hotspot score is a single value used to rank file risk. It is calculated by multiplying three signals:

    score = LoC × churn × complexity

    • LoC: Raw line count of the file.
    • Churn: Number of commits that touched the file within the configured window (e.g., via the --days flag).
    • Complexity: Cyclomatic complexity (calculated via tsmetrics-core for JS/TS files; non-JS/TS files default to 1).

    A high score indicates a file that is large, frequently modified, and contains many branches, making it a prime candidate for refactoring.