mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 08:39:02 +03:00
docs(cli-rs): remove source inventories from diagram and build code
Describe the rendering and generator contracts where they constrain the code. Drop file-to-file migration notes and tracking labels.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
//! The character grid diagrams draw into (`core/canvas.ts`).
|
||||
|
||||
use super::text;
|
||||
|
||||
const MAX_CELLS: i64 = 250_000;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Color blending (`core/color/style.ts`). OpenTUI stores colors as bytes and rounds as `Math.round` does.
|
||||
//! Blended channels round to the nearest byte, with ties rounded up.
|
||||
|
||||
use opencode_plugin_abi::Rgba;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Box-drawing helpers (`core/drawing.ts`), with OpenTUI's `BorderChars`.
|
||||
|
||||
use super::geometry::{Bounds, Direction, Point, direction_between, walk_orthogonal_segment};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Grid geometry (`core/geometry.ts`).
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct Point {
|
||||
pub x: i32,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Shared grid, geometry, drawing, color, and text helpers (`packages/merman/src/core`).
|
||||
|
||||
pub mod canvas;
|
||||
pub mod color;
|
||||
pub mod drawing;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Cell claims and collision checks (`core/spatial.ts`).
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Text measurement and Mermaid line helpers (`core/text.ts`, `core/text-lines.ts`, `core/mermaid.ts`).
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Flowchart drawing (`flowchart/drawing.ts`) and its styles (`flowchart/style.ts`).
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Edge label placement (`flowchart/labels.ts`).
|
||||
|
||||
use super::types::Route;
|
||||
use crate::core::geometry::{
|
||||
Axis, Direction, Point, Segment, centered_span_start, clamp_point, inset_span, midpoint, point, point_on_segment,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! Flowchart layout (`flowchart/layout.ts`): ranks, node placement, subgraph frames, and the passes that
|
||||
//! separate top-level items before routing.
|
||||
//! Places ranks and separates top-level subgraphs before routing edges.
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::rc::Rc;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Flowcharts (`packages/merman/src/flowchart`).
|
||||
|
||||
pub mod drawing;
|
||||
pub mod labels;
|
||||
pub mod layout;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Flowchart parser (`flowchart/parser.ts`).
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::rc::Rc;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Edge routing (`flowchart/routing.ts`).
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Flowchart model (`flowchart/types.ts`).
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::core::geometry::{Axis, Bounds, Point};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! Gantt charts (`packages/merman/src/gantt`): parser and drawing with the plugin's default options
|
||||
//! (track style, thin line, labels on the left, spaced sections, faint track).
|
||||
//! Gantt charts with left-aligned labels and a faint track.
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Git graphs (`packages/merman/src/gitgraph`): parser and the vertical terminal drawing.
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! The Mermaid plugin: `opencode.merman`, a port of `packages/merman/src`. It draws
|
||||
//! `mermaid` fences in the transcript as terminal text: flowcharts, sequence, state, gantt, gitgraph, and
|
||||
//! timeline diagrams.
|
||||
//! Renders Mermaid fences in the transcript as styled terminal cells.
|
||||
// Bounds checks keep TS's inclusive `right = left + width - 1` form, so each condition reads as its source.
|
||||
#![allow(clippy::int_plus_one)]
|
||||
|
||||
@@ -68,7 +66,7 @@ impl std::fmt::Display for SyntaxError {
|
||||
}
|
||||
}
|
||||
|
||||
/// The kind of diagram `content` is, by its first meaningful line (`detect.ts`).
|
||||
/// Detects the diagram kind from its first meaningful line.
|
||||
pub fn detect(content: &str) -> Option<Kind> {
|
||||
if flowchart::parser::is_flowchart(content) {
|
||||
return Some(Kind::Flowchart);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! The diagram palette from the TUI theme (`palette.ts`).
|
||||
|
||||
use opencode_plugin_abi::{Read, Rgba, ThemeMode};
|
||||
|
||||
use crate::core::color::{blend, with_alpha};
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! The `opencode.merman` plugin (`plugin.ts`, `createMermaidCodeBlockRenderer`), on the one plugin API (O-67). The
|
||||
//! host draws its rows as TS `StaticDiagramRenderable` does: full width, the diagram's height, no wrap, not
|
||||
//! selectable, in a white default foreground, scrolled sideways by a left drag.
|
||||
//! Renders to the available width and reports the diagram's measured height.
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
@@ -13,7 +11,6 @@ use crate::{Diagram, Kind, Palette, Rendered, render};
|
||||
|
||||
pub const ID: &str = "opencode.merman";
|
||||
|
||||
/// The plugin, on the one plugin API (O-67).
|
||||
pub fn plugin() -> Plugin {
|
||||
Plugin { id: ID, setup }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Source to styled lines (`markdown.ts` `prepareDiagram` and the streaming fallback).
|
||||
//! Renders source to styled lines, including partial diagrams while streaming.
|
||||
|
||||
use opencode_plugin_abi::Rgba;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Sequence diagram drawing (`sequence/drawing.ts`) and styles (`sequence/style.ts`).
|
||||
|
||||
use super::placement::{GroupPlacement, HBounds, StepPlacement, plan};
|
||||
use super::{Diagram, FragmentKind, Head};
|
||||
use crate::core::canvas::{Canvas, SizeError};
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Sequence diagrams (`packages/merman/src/sequence`).
|
||||
|
||||
pub mod drawing;
|
||||
pub mod parser;
|
||||
pub mod placement;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Sequence diagram parser (`sequence/parser.ts`).
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Sequence diagram placement (`sequence/placement.ts`).
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! State diagram drawing (`state/drawing.ts`) and its styles (`state/style.ts`).
|
||||
|
||||
use super::layout::{
|
||||
Layout, NoteBox, create, expand_for_feedback, expand_for_internal_transitions, note_connector_of, separate_external,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! State diagram layout (`state/layout.ts`). TS shares one bounds object between `bounds` and
|
||||
//! `compositeBounds`; here both maps index one arena of boxes, so a move shows through either.
|
||||
//! The bounds and composite maps index the same boxes so moves remain visible through either.
|
||||
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! State diagrams (`packages/merman/src/state`), with `note.ts`, `visible-model.ts`, and `search.ts`.
|
||||
|
||||
pub mod drawing;
|
||||
pub mod layout;
|
||||
pub mod parser;
|
||||
@@ -96,8 +94,6 @@ pub fn end_marker_id(scope: Option<&str>) -> String {
|
||||
scope.map_or("__end".to_string(), |scope| format!("{scope}.__end"))
|
||||
}
|
||||
|
||||
// note.ts
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct NoteConnector {
|
||||
pub points: Vec<Point>,
|
||||
@@ -139,8 +135,6 @@ pub fn note_connector(note: &Rect, side: NoteSide, target: &Rect) -> NoteConnect
|
||||
}
|
||||
}
|
||||
|
||||
// visible-model.ts
|
||||
|
||||
pub fn is_hidden_composite_marker(state: Option<&State>) -> bool {
|
||||
state.is_some_and(|state| state.parent_id.is_some() && matches!(state.kind, StateKind::Start | StateKind::End))
|
||||
}
|
||||
@@ -208,8 +202,6 @@ pub fn visible(diagram: &Diagram) -> Diagram {
|
||||
}
|
||||
}
|
||||
|
||||
// search.ts
|
||||
|
||||
pub const MAX_SEARCH_VISITS: i64 = 250_000;
|
||||
|
||||
pub struct SearchSpace {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! State diagram parser (`state/parser.ts`).
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! State transition routing (`state/routing.ts`).
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Timelines (`packages/merman/src/timeline`): parser and the vertical terminal drawing.
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
//! P-COMP for P.3: `TextPart`'s Markdown with the Mermaid plugin's renderer, compared cell by cell with
|
||||
//! parity/fixtures/P.3/markdown.json (written by parity/component/P.3-markdown.tsx through the TS plugin).
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
use opencode_mermaid::{Palette, Rendered, fenced, render};
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
//! P-ORACLE for P.3: renders every source of parity/fixtures/P.3/corpus.json (written by
|
||||
//! parity/oracle/P.3-mermaid.ts from the TS plugin) and compares each styled line with TS.
|
||||
|
||||
use opencode_mermaid::{Palette, Rendered, render};
|
||||
use opencode_plugin::node::Reader;
|
||||
use opencode_plugin_abi::Rgba;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Generates crates/api/src/generated and crates/api-types/src/types.rs from ClientApi, with the options of the Promise client
|
||||
// (packages/client/script/generate.ts). docs/architecture.md describes what it generates.
|
||||
// Generates Rust API types and endpoints from ClientApi.
|
||||
import { compile, type Endpoint } from "@opencode/httpapi-codegen"
|
||||
import { ClientApi, clientNamespace, groupNames, promiseOmitEndpoints } from "@opencode/protocol/client"
|
||||
import { Schema, SchemaAST, SchemaRepresentation } from "effect"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Dumps the TypeScript CLI command tree (packages/cli/src/commands/commands.ts) to JSON. The Rust test
|
||||
// crates/cli/src/tests/tree.rs compares the command table against it: names, aliases, descriptions, arguments, flags.
|
||||
// Records the CLI command tree, including metadata not visible in help output.
|
||||
import { Effect, Exit, Option } from "effect"
|
||||
import { GlobalFlag } from "effect/cli"
|
||||
import { Commands, PrintLogs } from "../../../cli/src/commands/commands"
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Writes crates/mermaid/src/core/entities.rs: the HTML named character references that `entities`'
|
||||
// `decodeHTMLStrict` decodes (packages/merman/src/core/mermaid.ts), and decoding cases checked against it. The
|
||||
// package (7.x) ships its names only as a packed trie (`htmlDecodeTree`), so this walks the trie's branches, as
|
||||
// `EntityDecoder` and `determineBranch` read them, for every name it holds, and keeps each name whose `&name;`
|
||||
// `decodeHTMLStrict` decodes, with that value. Sorted by name for a binary search.
|
||||
// Generates strict HTML named references from the packed trie in `entities`, checking each name against its decoder.
|
||||
import { createRequire } from "node:module"
|
||||
|
||||
const require = createRequire(new URL("../../../merman/package.json", import.meta.url).pathname)
|
||||
|
||||
@@ -51,9 +51,7 @@ async function load(url: string, filetype: string) {
|
||||
return response.text()
|
||||
}
|
||||
|
||||
// Core's translateLuaMatch (parser.worker.ts), which it applies to every highlight query it loads: a #lua-match? whose
|
||||
// Lua pattern uses only literals, anchors, simple sets, %d, ".", "*", and "+" becomes #match?, and any other stays and
|
||||
// matches every node. Core writes "." as JavaScript's [^]; Rust's regex crate spells that (?s:.).
|
||||
// Convert only Lua patterns with an equivalent regex; keep unsupported predicates intact.
|
||||
function translateLuaMatch(query: string) {
|
||||
return query.replace(
|
||||
/#(not-)?(any-)?lua-match\?(\s+@[\w.-]+\s+)"(\^?(?:(?:[\w/!:#.]|\[\^?(?:[\w*-]|%d)+\])[*+]?)*\$?)"/g,
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
// Writes crates/plugin/src/pipe/compat.js: the JS host's V2 compatibility layer (P8, `crates/plugin/src/pipe/compat`)
|
||||
// bundled with what it serves plugins (Solid's client build, its store and universal renderer) and the generated
|
||||
// client, as one module the client embeds beside `host.ts`. First it writes `compat/opentui.gen.ts`: every name the
|
||||
// installed `@opentui/core` and `@opentui/solid` export, with the values of their small plain-data exports (enums,
|
||||
// border sets), and the methods of `CliRenderer`, so the layer exports each name and a plugin's import of one links
|
||||
// (FT-5, FT-6), and OpenTUI's filetype maps, which `infoStringToFiletype` reads (contract 2.x, step D: good-fences
|
||||
// registers a renderer for each filetype they name). Then `compat/events.gen.ts`: the event types the generated client names, which `data.listen` hears.
|
||||
// Bundles the JS plugin compatibility layer and the client-side Solid runtime it serves.
|
||||
import path from "node:path"
|
||||
|
||||
const root = new URL("../..", import.meta.url).pathname
|
||||
@@ -79,8 +73,7 @@ async function opentui() {
|
||||
// The methods its declarations say return a promise, which a stand-in answers with a resolved one.
|
||||
const declared = await Bun.file(path.join(path.dirname(Bun.resolveSync("@opentui/core", compat)), "renderer.d.ts")).text()
|
||||
const promised = [...declared.matchAll(/^\s+(\w+)\(.*\): Promise</gm)].map((match) => match[1]!)
|
||||
// The methods any of its declarations say return a promise (CT-16: `TreeSitterClient.initialize`), which an inert
|
||||
// call of answers a resolved one.
|
||||
// Inert implementations of async methods must still return a promise.
|
||||
const root = path.dirname(Bun.resolveSync("@opentui/core", compat))
|
||||
const promises = new Set<string>()
|
||||
for await (const file of new Bun.Glob("**/*.d.ts").scan({ cwd: root }))
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Writes crates/cli/src/run/mime.rs: the extension table of `mime-types`, which `FSUtil.mimeType` uses to type
|
||||
// `run -f` attachments (packages/util/src/fs-util.ts). Sorted by extension for a binary search.
|
||||
// Generates the extension-to-MIME table used for `run -f` attachments.
|
||||
import { createRequire } from "node:module"
|
||||
|
||||
const require = createRequire(new URL("../../../util/package.json", import.meta.url).pathname)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Writes crates/plugin-abi/schema/v2.json: the JSON Schema of plugin contract 2.0, generated from the Rust types of
|
||||
// `opencode_plugin_abi::v2` by its `schema` example (synthesis 4.6: "the schema is generated from the Rust types").
|
||||
// Generates the plugin contract schema from its Rust types.
|
||||
import { format, resolveConfig } from "prettier"
|
||||
|
||||
const root = new URL("../..", import.meta.url).pathname
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// Writes crates/acp/src/permission/structured_patch.json: `[old, new, ranges]` cases with the hunk ranges jsdiff's
|
||||
// `structuredPatch` reports (the `diff` package packages/cli/src/acp/permission.ts uses), for the port in
|
||||
// crates/acp/src/permission/unified.rs. A table of shapes, then seeded random texts.
|
||||
// Records jsdiff's structured patch hunk ranges for the ACP diff tests.
|
||||
import { createRequire } from "node:module"
|
||||
|
||||
const require = createRequire(new URL("../../../cli/package.json", import.meta.url).pathname)
|
||||
|
||||
@@ -153,7 +153,6 @@ function range(from: number, to: number, step: number) {
|
||||
return Array.from({ length: Math.ceil((to - from) / step) }, (_, index) => from + index * step)
|
||||
}
|
||||
|
||||
// packages/tui/src/util/form.ts
|
||||
function validDate(value: string) {
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) return false
|
||||
const date = new Date(`${value}T00:00:00.000Z`)
|
||||
|
||||
@@ -111,7 +111,6 @@ function union(types: Array<string>) {
|
||||
return unique.length === 1 ? unique[0] : `(${unique.join(" | ")})`
|
||||
}
|
||||
|
||||
// As `integer` in types.ts, which makes such a number an `i64`.
|
||||
function integer(r: SchemaRepresentation.Number) {
|
||||
const visit = (checks: ReadonlyArray<SchemaRepresentation.Check>): boolean =>
|
||||
checks.some((check) =>
|
||||
|
||||
Reference in New Issue
Block a user