openspec-ext

    Portable OpenSpec extensions, HTML designs and repository setup

    Download zip
    Author
    Version
    0.2.0
    License
    Apache-2.0
    Last updated
    9 hours ago
    Downloads
    3

    #OpenSpec extensions

    moonrockz/openspec-ext is the library behind mission-control-tools openspec. It owns the shared html-design bundle: proposal, capability specs, an offline design.html, and tasks. Repository context, tracking and approval rules stay in each consumer's AGENTS.md and openspec/config.yaml.

    Consumers do not use this module directly. They pin the released mission-control-tools binary; see apps/tools/README.md for the install entry, the commands and the migration from the old scripts/openspec-ext.mbtx copy.

    #Packages

    PackageContentTargets
    moonrockz/openspec-extThe bundle files, the config migration, the typed lock (format 1 and 2), the retired files and the pure snapshot and bundle checks. No I/O.wasm, wasm-gc, js, native
    moonrockz/openspec-ext/hostinstall, check and setup: file reads and writes, symlink guards, the retirement of old files and the isolated openspec init.wasm, native

    The host uses moonbitlang/async file and process support, which has no JS or wasm-gc backend. The wasm build runs under moonrun (moon run), which supplies the file system host.

    #Narrative designs

    The bundle guides authors through a concrete user or system journey. A running example connects the stages; each decision explains the constraint, choice, reason and alternatives. Diagrams clarify flow, boundaries or state transitions. Significant failures and recovery belong in the journey too.

    Scale the narrative to the change. A short paragraph and one example can be enough. Do not force personas, diagram quotas or repeated motivation. Separate observed behavior, proposed interfaces and assumptions. Requirements and scenarios remain normative and testable; explanatory context for a new capability goes under Purpose so it survives archive. Required artifact sections and decision identifiers stay intact.

    #Files and updates

    bundle.mbt is the source for all shared files. Each raw multiline literal is one installed file. Change it here, test it, and run mise run openspec:install for this repository. The managed set is openspec/schemas/html-design/ only: schema.yaml, four templates, LICENSE and NOTICE. Consumers commit these files, because OpenSpec reads them.

    The ownership lock (openspec/extensions.lock.json, format 2) records the tool module, the tool version and the SHA-256 of each managed file. A check never writes. The snapshot check compares the files with the lock; the bundle check also compares the lock tool version and the files with the bundle of the tool.

    An install replaces only missing files, identical files, or files that still match the previous lock. It refuses unmanaged conflicts and local edits before writing anything. A file that an older bundle managed and this bundle does not (scripts/openspec-ext.mbtx and its feature) is deleted when it still has the digest of the previous lock, and stops the install when it does not. Only these fixed paths are ever deleted. To adopt an existing custom schema, review it, move its policy into the project config, and move the old schema aside before installing. Unsupported YAML layouts fail before writes; ordinary block configs retain comments and all values except the default schema.

    The lock is written last. An interrupted install can leave partial files; rerun the same version to repair them. Concurrent installation in one repository is unsupported. Symlink destinations are refused.

    Existing changes keep their .openspec.yaml schema and their original designs. A default-schema change applies to new work.

    #Verify

    mise exec -- moon test apps/openspec-ext apps/tools tests/openspec-ext-acceptance --target native --deny-warn mise run openspec:check mise exec -- openspec schema validate html-design mise exec -- openspec validate --all --strict

    The packaged host uses the module dependencies in moon.mod, including moonbitlang/async@0.22.10, which cross-compiles on Linux with moonrockz/zig-cross@0.4.1.

    ExtensionError

    pub suberror ExtensionError {
    InvalidPath(String)
    InvalidConfig(String)
    InvalidDigest(String)
    InvalidTool(String)
    }

    ExtensionError::output

    #deprecated("`ExtensionError::output` is deprecated, use `Show::output` instead.")
    fn ExtensionError::output(self : ExtensionError, logger : &Logger) -> Unit

    ExtensionError::to_string

    #deprecated("`ExtensionError::to_string` is deprecated, use `Show::to_string` instead.")
    fn ExtensionError::to_string(self : ExtensionError) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    LockError

    pub suberror LockError {
    Syntax
    MissingField(String)
    UnknownFormat(String)
    WrongExtension(String)
    WrongModule(String)
    InvalidToolName(String)
    InvalidVersion(String)
    InvalidDigest(String)
    }

    Why lock text is not a supported lock. Each case names the rule that the text breaks.
    impl Show for LockError

    LockError::message

    fn LockError::message(self : LockError) -> String

    A message that names the rule.

    LockError::output

    #deprecated("`LockError::output` is deprecated, use `Show::output` instead.")
    fn LockError::output(self : LockError, logger : &Logger) -> Unit

    LockError::to_string

    #deprecated("`LockError::to_string` is deprecated, use `Show::to_string` instead.")
    fn LockError::to_string(self : LockError) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    OpenSpecVersionError

    pub suberror OpenSpecVersionError {
    InvalidOpenSpecVersion(String)
    UnsupportedOpenSpec(
    Version
    )
    }

    Why a version text is not an OpenSpec CLI version that setup supports.

    OpenSpecVersionError::message

    fn OpenSpecVersionError::message(self : OpenSpecVersionError) -> String

    The message of the error.

    OpenSpecVersionError::output

    #deprecated("`OpenSpecVersionError::output` is deprecated, use `Show::output` instead.")
    fn OpenSpecVersionError::output(self : OpenSpecVersionError, logger : &Logger) -> Unit

    OpenSpecVersionError::to_string

    #deprecated("`OpenSpecVersionError::to_string` is deprecated, use `Show::to_string` instead.")
    fn OpenSpecVersionError::to_string(self : OpenSpecVersionError) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    BundleFile

    pub(all) enum BundleFile {
    Schema
    Proposal
    Spec
    Design
    Tasks
    Notice
    License
    } derive(Eq)

    Fixed paths for files owned by the portable html-design bundle. The set is closed: a consumer's task scripts and tests are not part of it.

    BundleFile::content

    fn BundleFile::content(self : BundleFile) -> String

    BundleFile::equal

    #deprecated("`BundleFile::equal` is deprecated, use `Eq::equal` instead.")
    fn BundleFile::equal(BundleFile, BundleFile) -> Bool
    automatically derived

    BundleFile::not_equal

    #deprecated("`BundleFile::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn BundleFile::not_equal(x : BundleFile, y : BundleFile) -> Bool
    automatically derived

    BundleFile::path

    fn BundleFile::path(self : BundleFile) -> String

    CheckLevel

    pub(all) enum CheckLevel {
    Snapshot
    Bundle(Tool)
    }

    What a check compares the repository with.

    FileDigest

    pub struct FileDigest {
    // private fields
    } derive(Eq)

    A canonical lower-case SHA-256 digest, parsed once at the lock boundary.

    FileDigest::FileDigest

    fn FileDigest::FileDigest(value : String) -> FileDigest raise ExtensionError

    Parse 64 lower-case hexadecimal characters.

    FileDigest::equal

    #deprecated("`FileDigest::equal` is deprecated, use `Eq::equal` instead.")
    fn FileDigest::equal(FileDigest, FileDigest) -> Bool
    automatically derived

    FileDigest::not_equal

    #deprecated("`FileDigest::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn FileDigest::not_equal(x : FileDigest, y : FileDigest) -> Bool
    automatically derived

    FileDigest::text

    fn FileDigest::text(self : FileDigest) -> String

    The 64 hexadecimal characters.

    Input

    pub enum Input {
    LockFile
    Config
    Managed(BundleFile)
    } derive(Eq)

    An input of a check: the lock, the project config, or a managed file.

    Input::equal

    #deprecated("`Input::equal` is deprecated, use `Eq::equal` instead.")
    fn Input::equal(Input, Input) -> Bool
    automatically derived

    Input::not_equal

    #deprecated("`Input::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn Input::not_equal(x : Input, y : Input) -> Bool
    automatically derived

    Input::path

    fn Input::path(self : Input) -> String

    The repository-relative path of the input.

    Lock

    pub enum Lock {
    Legacy(LockedFiles)
    Current(Tool, LockedFiles)
    }

    A parsed ownership lock.

    Lock::files

    fn Lock::files(self : Lock) -> LockedFiles

    The digests of either format.

    LockedFiles

    pub struct LockedFiles {
    // private fields
    }

    The digests that a lock records, by repository-relative path. The map is private, so a lock cannot change after the parse.

    LockedFiles::get

    fn LockedFiles::get(self : LockedFiles, path : String) -> FileDigest?

    The digest that the lock records for path, if any.

    LockedFiles::length

    fn LockedFiles::length(self : LockedFiles) -> Int

    The number of recorded digests.

    Problem

    pub enum Problem {
    MissingFile(Input)
    UnsupportedLock
    LegacyLock
    FileSet
    MissingDigest(BundleFile)
    Drift(BundleFile)
    Schema
    ToolVersion(recorded~ : Tool, expected~ : Tool)
    BundleDrift(BundleFile, Tool)
    }

    One problem that a check found.

    Problem::code

    fn Problem::code(self : Problem) -> String

    A stable code for JSON reports.

    Problem::message

    fn Problem::message(self : Problem) -> String

    The message. The texts of the bundled script are kept without its source location.

    Problem::path

    fn Problem::path(self : Problem) -> String?

    The repository-relative path that the problem is about, if there is one.

    RepositoryPath

    pub struct RepositoryPath {
    // private fields
    }

    An explicitly supplied repository location, with no NUL or line breaks.

    RepositoryPath::RepositoryPath

    fn RepositoryPath::RepositoryPath(value : String) -> RepositoryPath raise ExtensionError

    RepositoryPath::text

    fn RepositoryPath::text(self : RepositoryPath) -> String

    The path as the user gave it.

    RetiredFile

    pub(all) enum RetiredFile {
    Script
    ScriptFeature
    } derive(Eq)

    A file that an earlier bundle managed and the current bundle does not. Install deletes it when it still has the digest of the previous lock. Only these fixed paths are ever deleted, whatever other paths a lock names.

    RetiredFile::equal

    #deprecated("`RetiredFile::equal` is deprecated, use `Eq::equal` instead.")
    fn RetiredFile::equal(RetiredFile, RetiredFile) -> Bool
    automatically derived

    RetiredFile::not_equal

    #deprecated("`RetiredFile::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn RetiredFile::not_equal(x : RetiredFile, y : RetiredFile) -> Bool
    automatically derived

    RetiredFile::path

    fn RetiredFile::path(self : RetiredFile) -> String

    The fixed repository-relative path of the retired file.

    Retirement

    pub enum Retirement {
    Absent
    Delete
    Edited
    Unmanaged
    }

    What a retired file needs at install time.

    SupportedOpenSpec

    pub struct SupportedOpenSpec {
    // private fields
    }

    An OpenSpec CLI version that setup supports: an entry of the support table accepts it.

    SupportedOpenSpec::SupportedOpenSpec

    fn SupportedOpenSpec::SupportedOpenSpec(text : String) -> SupportedOpenSpec raise OpenSpecVersionError

    Parse the text that openspec --version printed. The text must be X.Y.Z with no other characters, and the support table must accept the version.

    SupportedOpenSpec::scope_arguments

    fn SupportedOpenSpec::scope_arguments(self : SupportedOpenSpec) -> Array[String]

    The arguments that make openspec init keep the skills in the repository. OpenSpec 2 installs skills for every project on the machine unless --scope project is given; OpenSpec 1 keeps them in the repository and does not know the option.

    SupportedOpenSpec::version

    The version.

    Tool

    pub struct Tool {
    // private fields
    } derive(Eq)

    The tool that writes and checks a lock: a module name owner/name and its version.

    Tool::Tool

    fn Tool::Tool(module_name : String, version :
    Version
    ) -> Tool raise ExtensionError

    module_name is owner/name, each part lower-case letters, digits and -, not empty.

    Tool::equal

    #deprecated("`Tool::equal` is deprecated, use `Eq::equal` instead.")
    fn Tool::equal(Tool, Tool) -> Bool
    automatically derived

    Tool::module_name

    fn Tool::module_name(self : Tool) -> String

    The module name, such as moonrockz/mission-control-tools.

    Tool::name

    fn Tool::name(self : Tool) -> String

    The last part of the module name, which is also the executable name.

    Tool::not_equal

    #deprecated("`Tool::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn Tool::not_equal(x : Tool, y : Tool) -> Bool
    automatically derived

    Tool::version

    The version of the tool.

    can_replace

    fn can_replace(file : BundleFile, current : String?, previous_digest : FileDigest?) -> Bool

    Refuse to replace a pre-existing unowned file or a locally edited managed file.

    check_snapshot

    fn check_snapshot(lock~ : String?, config~ : String?, file~ : (BundleFile) -> String?, level~ : CheckLevel) -> Array[Problem]

    Check a snapshot from the texts that the host read. None is a missing file. The problems come in a fixed order: lock, managed files in bundle order, config. A missing managed file is reported even when the lock is missing or cannot be read. The function reads no files.

    config_path

    let config_path : String

    The repository-relative path of the OpenSpec project config.

    configure

    fn configure(source : String) -> String raise ExtensionError

    Select html-design while preserving the original config's comments and other values. Unsupported YAML layouts are refused before any file is written.

    digest

    fn digest(text : String) -> FileDigest

    The SHA-256 of the UTF-8 bytes of text.

    files

    fn files() -> Array[BundleFile]

    initial_config

    fn initial_config() -> String

    The config that install writes into a repository that has none.

    lock_path

    let lock_path : String

    The repository-relative path of the ownership lock.

    lock_text

    fn lock_text(tool : Tool) -> String

    The format 2 lock that tool writes for this bundle.

    parse_lock

    fn parse_lock(text : String) -> Lock raise LockError

    Parse lock text at the boundary into a format 1 or a format 2 lock.

    retired_files

    fn retired_files() -> Array[RetiredFile]

    Every retired file, in a fixed order.

    retirement

    fn retirement(file : RetiredFile, current : String?, previous : Lock?) -> Retirement

    Decide what install does with file, from its current text and the previous lock.

    supported_openspec

    let supported_openspec : String

    The supported versions as the messages name them, made from the support table: 1.14.3, 1.16.x or 2.2.x.