跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    keyvanarasteh

    Data Model

    v0.1.1代码智能
    opencode-data-model

    OpenCode plugin for generating data model documentation, database schemas, and TypeScript or JavaScript models

    GitHub 星标

    0

    月装机量

    34

    近 7 天 6

    综合评分SCORE

    25.5

    生态多维模型

    最近提交

    2 个月前

    2026-06-03

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-data-model@0.1.1"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    opencode-data-model

    opencode-data-model

    PR checks Publish npm License: MIT GitHub

    OpenCode plugin for generating normalized, high-performance schemas and compile-safe TypeScript or JavaScript data models.

    Why

    I asked LLMs to generate schemas a million times. Too often they looked right, then failed on relationships, constraints, nullability, indexes, SQL dialects, or TypeScript boundaries. This plugin adds a stronger prompt contract, forced validation, and optional AI double-checking to reduce those mistakes before the model reaches your codebase.

    Install

    OpenCode loads plugins from two sources.

    From npm (recommended)

    Add the package to the plugin array in your config file. OpenCode installs npm plugins automatically with Bun at startup and caches them (and their dependencies) under ~/.cache/opencode/node_modules/.

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-data-model"]
    }
    

    Both regular and scoped npm packages are supported. The same package works under npm or Bun — bun add opencode-data-model resolves the identical artifact.

    From local files

    Drop the built JavaScript/TypeScript file into a plugin directory and OpenCode loads it automatically at startup:

    • .opencode/plugins/ — project-level plugins
    • ~/.config/opencode/plugins/ — global plugins
    mise run build
    mise run link   # symlinks dist/index.js into ~/.config/opencode/plugins/
    

    To use external packages from a local plugin, create a package.json inside your config directory, or publish to npm and reference it from config instead.

    Load order

    Plugins load from all sources, and every hook runs in sequence:

    1. Global config (~/.config/opencode/opencode.json)
    2. Project config (opencode.json)
    3. Global plugin directory (~/.config/opencode/plugins/)
    4. Project plugin directory (.opencode/plugins/)

    Duplicate npm packages with the same name and version load once. A local plugin and an npm plugin with similar names load separately.

    Objects

    Object Command Tool
    Blueprint /model model_doc
    MySQL Forge /schema-mysql schema_mysql
    Postgres Forge /schema-pg schema_pg
    Type Loom /types-ts types_ts
    JSDoc Loom /types-js types_js
    Quality Map /data-model-roadmap roadmap_model
    Gatekeeper /model-check audit_model

    Classic /data-model-* commands and generate_* tool names are still available for compatibility.

    Prompt Contract

    • Act as a principal data architect.
    • Normalize write models first; document read-model exceptions.
    • Design for correctness, query performance, maintainability, and migrations.
    • Add indexes for real access patterns without over-indexing.
    • Make nullability, ownership, deletion behavior, and constraints explicit.
    • Keep TypeScript and JavaScript models compile-safe and boundary-aware.
    • Reject the draft if validation finds hallucinated fields, missing relations, weak indexes, dialect errors, or type/interface drift.

    Development

    mise trust
    bun install
    mise run build
    mise run lint
    mise run test
    mise run typecheck
    

    Validation uses Bun snapshots, Zod contract checks, SQL DDL parsing, and TypeScript syntax checks. Update snapshots with mise run test_update.

    Publishing

    npm login
    mise run publish --tag latest
    # if your npm account enforces publish 2FA:
    mise run publish --tag latest --otp <one-time-code>
    

    License

    MIT License. See LICENSE.