M0: compilable skeleton — Kigi 0.1.0 fork surgery
Hard fork of xai-org/grok-build (Apache-2.0) re-targeted as Kigi, an
unofficial Kimi Code CLI community build.
Rename & identity
- 72 xai-*/xai-grok-* crates -> kigi-* (explicit: xai-grok-pager-bin ->
kigi-bin [binary `kigi`], xai-grok-pager -> kigi-tui; rest mechanical);
ptyctl, ptyctl-cli, third_party/ unchanged; proto package
xai.grok.tools.v1 -> kigi.tools.v1
- Config home ~/.kigi (KIGI_SHARE_DIR override), env prefix GROK_* ->
KIGI_*, `kigi --version` carries the unofficial-community-build notice
- clap identity, help text, startup banner, prompt templates rebranded
(templates re-encrypted)
Deletions (PRD removal list #5/#6/#7/#9/#10)
- voice input (xai-grok-voice) and all TUI wiring
- telemetry: Mixpanel client, external OTel stream, Sentry, OTLP layers,
trace/GCS/S3 upload queues (kigi-file-utils halved), workspace upload
module & dc_log, heap-profile uploader, auth-diagnostics uploader,
session-analytics halves of feedback; local zero-egress observability
preserved in new kigi-log crate (unified log, --debug firehose,
subsystem file logs, opt-in instrumentation)
- announcements (crate, remote-settings fields, TUI surfaces)
- plugin marketplace (crate, sources/browse/CTA/extensions-modal tab);
direct plugin install/uninstall/update via kigi-agent git_install kept
- relay/gateway/assets endpoints and features (agent relay, headless
relay transport, gateway bridge, LeaderEnvUrls); leader IPC socket now
~/.kigi/leader.sock + KIGI_LEADER_SOCKET, no ws-url derivation
- functional types rehomed instead of deleted: PermissionMode ->
kigi-config-types, McpInitStrategy -> kigi-mcp, PrCreationSource ->
session signals, TerminalDiagnostics -> kigi-pager-render, agent_id ->
shell util
Endpoints
- kigi-env rewritten: single production KigiEndpoints {coding_api_base_url
https://api.kimi.com/coding/v1 (KIGI_CODE_BASE_URL), oauth_host
https://auth.kimi.com (KIGI_OAUTH_HOST), update_base_url (GitHub
Releases API), upgrade_page_url}; GrokBuildEnvironment enum deleted
Toolchain & workspace hygiene
- Rust 1.97.0 pinned; edition 2024; full cargo update; git2 hoisted to
workspace at 0.21 (Option->Result API migration), quick-xml 0.41
- Root Cargo.toml hand-maintained (PRD §8.1): version 0.1.0 inherited by
all members, members sorted, unused deps pruned
- cargo-deny advisories gate (deny.toml with documented transitive
exceptions); CI workflow (check/clippy/fmt/deny/test, macOS+Linux)
- cross-crate test seams re-gated behind `test-support` cargo feature;
insta snapshot baselines renamed to the kigi_tui prefix
- clippy --workspace --all-targets: zero warnings; fmt clean
Fixes surfaced by the port
- updater probe/installer divergence (bin/kigi vs bin/grok symlink set)
- idle model-metadata refresh dead under KIGI_CODE_BASE_URL override
(new is_effective_coding_endpoint_url, loopback+override aware)
- macOS symlinked-TMPDIR fixture canonicalization (foreign_sessions,
fast-worktree); RSS measurement tests serialized via serial_test
Docs & legal (Apache §4)
- NOTICE added (upstream attribution + change statement); THIRD-PARTY
notices sustained; kigi-tools ported-code notices extended; README,
CONTRIBUTING, SECURITY, AGENTS.md rewritten
Out of scope for M0 (tracked): Kimi auth/inference (M1), search/fetch,
command parity, config import (M2), Computer Hub excision & final
brand-token sweep (M2), distribution & self-update rewrite (M3).
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
//! Integration tests for the public render path through the default engine.
|
||||
//!
|
||||
//! These use only the public API (`default_engine` + `render_checked`) so they
|
||||
//! exercise the real, always-compiled dagre-based engine end to end.
|
||||
|
||||
use kigi_mermaid::{
|
||||
MermaidError, MermaidTheme, RenderLimits, RenderParams, default_engine, render_checked,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn default_engine_renders_a_flowchart() {
|
||||
let diagram = render_checked(
|
||||
default_engine().as_ref(),
|
||||
"flowchart LR\n A[Start] --> B[Finish]",
|
||||
&RenderParams::default(),
|
||||
&RenderLimits::default(),
|
||||
)
|
||||
.expect("the default engine must render a flowchart");
|
||||
assert!(diagram.width_px > 0 && diagram.height_px > 0);
|
||||
let img = image::load_from_memory(&diagram.png).expect("output must be a valid PNG");
|
||||
assert_eq!(img.width(), diagram.width_px);
|
||||
assert_eq!(img.height(), diagram.height_px);
|
||||
}
|
||||
|
||||
/// Untrusted-input contract through the real engine: a panic would surface as
|
||||
/// `MermaidError::Panic`, which we assert against. Unparseable input may return
|
||||
/// other errors (which degrade to the code-block fallback), never a panic.
|
||||
#[test]
|
||||
fn garbage_input_is_isolated_not_panicked() {
|
||||
let limits = RenderLimits::default();
|
||||
let params = RenderParams::default();
|
||||
for garbage in ["", "@@@@", "%% comment only", "????", "\u{0}\u{1}\u{2}"] {
|
||||
let out = render_checked(default_engine().as_ref(), garbage, ¶ms, &limits);
|
||||
assert!(
|
||||
!matches!(out, Err(MermaidError::Panic(_))),
|
||||
"engine panicked on {garbage:?}: {out:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sequence_diagram_with_activations_renders_to_png() {
|
||||
const SOURCE: &str = "sequenceDiagram\n\
|
||||
participant Dev as Developer\n\
|
||||
participant CI as CI Pipeline\n\
|
||||
participant K8s as Kubernetes\n\
|
||||
participant PD as PagerDuty\n\
|
||||
participant Cat as Office Cat\n\
|
||||
Dev->>CI: git push --force\n\
|
||||
activate CI\n\
|
||||
CI->>CI: run 4,000 tests\n\
|
||||
CI-->>Dev: \u{2705} all green (suspicious)\n\
|
||||
deactivate CI\n\
|
||||
Dev->>K8s: deploy to prod\n\
|
||||
activate K8s\n\
|
||||
K8s-->>Dev: 200 OK\n\
|
||||
deactivate K8s\n\
|
||||
Note over Dev: leaves for lunch\n\
|
||||
K8s->>PD: OOMKilled x47\n\
|
||||
PD->>Dev: CALL CALL CALL\n\
|
||||
Dev->>K8s: kubectl rollout undo\n\
|
||||
K8s-->>Dev: phew\n\
|
||||
Cat->>Dev: sits on keyboard\n\
|
||||
Dev->>K8s: jjjjjjjjjjjjjjjj\n";
|
||||
let diagram = render_checked(
|
||||
default_engine().as_ref(),
|
||||
SOURCE,
|
||||
&RenderParams::default(),
|
||||
&RenderLimits::default(),
|
||||
)
|
||||
.expect("a sequence diagram with activations must render");
|
||||
let img = image::load_from_memory(&diagram.png).expect("output must be a valid PNG");
|
||||
assert_eq!(img.width(), diagram.width_px);
|
||||
assert_eq!(img.height(), diagram.height_px);
|
||||
}
|
||||
|
||||
/// Regression: a class diagram using quoted cardinalities, stereotypes,
|
||||
/// generics, and the full relation set must render instead of erroring
|
||||
/// (previously failed with "Unrecognized classDiagram line" on
|
||||
/// `Owner "1" o-- "0..*" Animal`).
|
||||
#[test]
|
||||
fn class_diagram_with_cardinalities_renders() {
|
||||
let src = "classDiagram\n direction TB\n class Animal {\n <<abstract>>\n #String name\n +makeSound()* String\n }\n class Owner {\n +List~Animal~ pets\n +adopt(Animal pet) void\n }\n Animal <|-- Dog : extends\n Feedable <|.. Animal : implements\n Owner \"1\" o-- \"0..*\" Animal : owns\n Dog \"1\" --> \"0..1\" Ball : plays with\n Veterinarian ..> Animal : examines\n HealthReport --* Animal : belongs to";
|
||||
let engine = default_engine();
|
||||
let diagram = render_checked(
|
||||
engine.as_ref(),
|
||||
src,
|
||||
&RenderParams {
|
||||
theme: MermaidTheme::Dark,
|
||||
..Default::default()
|
||||
},
|
||||
&RenderLimits::default(),
|
||||
)
|
||||
.expect("class diagram with quoted cardinalities must render");
|
||||
assert!(!diagram.png.is_empty());
|
||||
}
|
||||
|
||||
/// Same source + params must produce identical PNG bytes (the engine's text
|
||||
/// metrics are font-free, so rendering is deterministic).
|
||||
#[test]
|
||||
fn rendering_is_deterministic() {
|
||||
let engine = default_engine();
|
||||
let params = RenderParams::default();
|
||||
let a = render_checked(
|
||||
engine.as_ref(),
|
||||
"flowchart LR\nA-->B-->C",
|
||||
¶ms,
|
||||
&RenderLimits::default(),
|
||||
)
|
||||
.expect("render a");
|
||||
let b = render_checked(
|
||||
engine.as_ref(),
|
||||
"flowchart LR\nA-->B-->C",
|
||||
¶ms,
|
||||
&RenderLimits::default(),
|
||||
)
|
||||
.expect("render b");
|
||||
assert_eq!(a.png, b.png, "same input must yield identical PNG bytes");
|
||||
}
|
||||
|
||||
/// End-to-end guard for the word-wrap fix: the real user diagram (a flowchart of
|
||||
/// long Python identifiers) must reach the rendered SVG with its identifiers
|
||||
/// intact, never hard-sliced mid-identifier. Renders through the same
|
||||
/// `mermaid_to_svg::render_mermaid_to_svg` path the pager uses.
|
||||
#[test]
|
||||
fn long_identifier_node_labels_survive_intact_in_svg() {
|
||||
let src = "flowchart TB
|
||||
subgraph main [resi_local.py / resi.py]
|
||||
nav[st.navigation]
|
||||
mark[mark_filter_restore_context]
|
||||
global[render_global_sidebar]
|
||||
sidebar[render_page_sidebar_filters]
|
||||
page[page.run]
|
||||
end
|
||||
nav --> mark --> global --> sidebar --> page";
|
||||
let svg = mermaid_to_svg::render_mermaid_to_svg(src, None)
|
||||
.expect("the real user flowchart must render to SVG");
|
||||
// Each long identifier appears as a COMPLETE single tspan; a slice (at any
|
||||
// offset) could never produce the whole identifier as one tspan's content.
|
||||
assert!(
|
||||
svg.contains(">mark_filter_restore_context</tspan>"),
|
||||
"{svg}"
|
||||
);
|
||||
assert!(
|
||||
svg.contains(">render_page_sidebar_filters</tspan>"),
|
||||
"{svg}"
|
||||
);
|
||||
}
|
||||
|
||||
/// A categorical-x-axis xychart with two `line` series must render to a decodable
|
||||
/// PNG through the full `[Open Image]` path (source -> SVG -> raster), on both
|
||||
/// themes. The categorical x-axis (no `-->`) previously failed to open.
|
||||
#[test]
|
||||
fn categorical_xychart_with_two_series_renders_to_png() {
|
||||
const SOURCE: &str = "xychart-beta\n \
|
||||
title \"Weekly active users by region\"\n \
|
||||
x-axis [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n \
|
||||
y-axis \"% of users\" 0 --> 40\n \
|
||||
line [20.3, 22.6, 24.2, 24.3, 26.2, 27.2, 32.4, 31.9, 31.4, 31.1, 33.6, 34.3]\n \
|
||||
line [3.2, 6.3, 10.0, 9.4, 11.1, 10.7, 15.3, 13.4, 13.5, 12.5, 15.4, 15.8]";
|
||||
let engine = default_engine();
|
||||
for theme in [MermaidTheme::Light, MermaidTheme::Dark] {
|
||||
let diagram = render_checked(
|
||||
engine.as_ref(),
|
||||
SOURCE,
|
||||
&RenderParams {
|
||||
theme,
|
||||
..Default::default()
|
||||
},
|
||||
&RenderLimits::default(),
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("categorical xychart must render ({theme:?}): {e}"));
|
||||
let img = image::load_from_memory(&diagram.png).expect("output must be a valid PNG");
|
||||
assert_eq!(img.width(), diagram.width_px);
|
||||
assert_eq!(img.height(), diagram.height_px);
|
||||
assert!(diagram.width_px > 0 && diagram.height_px > 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user