mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
test(cli-rs): add the P.1 plugin slot P-APP scenario
A test plugin appends a line to home.footer: TS loads it as a local plugin directory, Rust registers its twin.
This commit is contained in:
parent
59613ed1bc
commit
145c81c013
5 changed files with 562 additions and 1 deletions
|
|
@ -12,7 +12,9 @@ use opencode_api::memory::{Memory, Route as MemoryRoute};
|
|||
use opencode_local::cli_config::{self, Resolved};
|
||||
use opencode_parity::Fixture;
|
||||
use opencode_parity::app::{self, Recording, Sent, Step};
|
||||
use opencode_tui::{Args, Deps, Route};
|
||||
use opencode_plugin::{Definition, Placement, Setup, slot};
|
||||
use opencode_tui::{Args, Deps, Route, Tui};
|
||||
use opentui::prelude::*;
|
||||
use opentui::testing::TestApp;
|
||||
|
||||
/// How long a checkpoint waits for its `until` text. Longer than any MS1 screen takes; a screen the Rust TUI
|
||||
|
|
@ -87,6 +89,14 @@ fn run(recording: &Recording) -> (bool, String) {
|
|||
..Args::default()
|
||||
},
|
||||
);
|
||||
// The Rust twins of the TS test plugins under parity/plugins, which the Rust TUI lists as skipped (P.1).
|
||||
if recording
|
||||
.env
|
||||
.get("OPENCODE_PARITY_PLUGIN")
|
||||
.is_some_and(|plugin| plugin == "slot")
|
||||
{
|
||||
opencode_tui::plugins::host::add(&tui, slot_plugin());
|
||||
}
|
||||
|
||||
let mut passed = true;
|
||||
let mut report = String::new();
|
||||
|
|
@ -166,6 +176,20 @@ fn run(recording: &Recording) -> (bool, String) {
|
|||
(passed, report)
|
||||
}
|
||||
|
||||
/// `parity/plugins/slot/tui.tsx`: one line appended to `home.footer`.
|
||||
fn slot_plugin() -> Definition<Tui> {
|
||||
Definition::new("parity.slot", |cx: &mut Setup<'_, Tui>| {
|
||||
cx.slot(Placement::append(slot::HOME_FOOTER), |tui, _| {
|
||||
let app = &tui.app;
|
||||
Box::new(
|
||||
View::new(app)
|
||||
.padding_edge(Edge::Left, 2)
|
||||
.child(&Text::new(app, "slot plugin: home.footer").fg(tui.page().text.muted)),
|
||||
)
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/// The scenario routes first, then each recorded read by its exact query, then by path alone.
|
||||
fn routes(recording: &Recording) -> Vec<MemoryRoute> {
|
||||
let scenario = recording.routes.iter().map(|route| {
|
||||
|
|
|
|||
413
packages/cli-rs/parity/fixtures/P.1/slot.app.json
vendored
Normal file
413
packages/cli-rs/parity/fixtures/P.1/slot.app.json
vendored
Normal file
|
|
@ -0,0 +1,413 @@
|
|||
{
|
||||
"scenario": "P.1/slot",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"config": {
|
||||
"plugins": [
|
||||
"./plugins/slot"
|
||||
],
|
||||
"animations": false
|
||||
},
|
||||
"args": {},
|
||||
"env": {
|
||||
"OPENCODE_PARITY_PLUGIN": "slot"
|
||||
},
|
||||
"routes": [],
|
||||
"steps": [
|
||||
{
|
||||
"checkpoint": "home",
|
||||
"until": "slot plugin: home.footer",
|
||||
"masks": [
|
||||
{
|
||||
"x": 16,
|
||||
"y": 16,
|
||||
"width": 84,
|
||||
"height": 1,
|
||||
"reason": "the placeholder: random in TS, not drawn yet in Rust (T17-home-prompt)"
|
||||
}
|
||||
],
|
||||
"deviation": [
|
||||
"P01-read-only-prompt"
|
||||
],
|
||||
"fixture": "P.1/slot/home"
|
||||
}
|
||||
],
|
||||
"requests": {
|
||||
"writes": [],
|
||||
"reads": [
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/agent",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/command",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/config",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": []
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/experimental/migration/v1",
|
||||
"query": {},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"status": "completed"
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/form",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/fs/list",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"<cwd>"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/info",
|
||||
"query": {},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"version": "test",
|
||||
"pid": 0,
|
||||
"urls": [],
|
||||
"paths": {
|
||||
"tmp": "/tmp"
|
||||
},
|
||||
"capabilities": {
|
||||
"persistentPty": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/integration",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/location",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/mcp",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/mcp/resource",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"resources": [],
|
||||
"templates": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/model",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/plugin",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/project",
|
||||
"query": {},
|
||||
"status": 200,
|
||||
"json": []
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/provider",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/reference",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"canonical": "/tmp/opencode/packages/tui"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/session/active",
|
||||
"query": {},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"data": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/shell",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/skill",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/vcs",
|
||||
"query": {
|
||||
"location[directory]": [
|
||||
"/tmp/opencode/packages/tui"
|
||||
]
|
||||
},
|
||||
"status": 200,
|
||||
"json": {
|
||||
"location": {
|
||||
"directory": "/tmp/opencode/packages/tui",
|
||||
"project": {
|
||||
"id": "proj_test",
|
||||
"directory": "/tmp/opencode",
|
||||
"canonical": "/tmp/opencode"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"branch": {
|
||||
"current": "main",
|
||||
"default": "main"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
81
packages/cli-rs/parity/fixtures/P.1/slot/home.json
vendored
Normal file
81
packages/cli-rs/parity/fixtures/P.1/slot/home.json
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"rows": [
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ▄ ",
|
||||
" █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█ ",
|
||||
" █ █ █ █ █▀▀▀ █ █ █ █ █ █ █ █▀▀▀ ",
|
||||
" ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ",
|
||||
" ",
|
||||
" ",
|
||||
" ┃ ",
|
||||
" ┃ ",
|
||||
" ┃ ",
|
||||
" ┃ ",
|
||||
" ╹▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ",
|
||||
" /tmp/opencode/packages/tui:main shift+tab agents ctrl+p commands ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" test ",
|
||||
" ",
|
||||
" slot plugin: home.footer "
|
||||
],
|
||||
"styles": [
|
||||
"#ffffffff #0a0a0aff 0",
|
||||
"#808080ff #0a0a0aff 0",
|
||||
"#eeeeeeff #0a0a0aff 1",
|
||||
"#808080ff #282828ff 0",
|
||||
"#eeeeeeff #434343ff 1",
|
||||
"#282828ff #0a0a0aff 0",
|
||||
"#484848ff #0a0a0aff 0",
|
||||
"#ffffffff #1e1e1eff 0",
|
||||
"#00000000 #00000000 0",
|
||||
"#1e1e1eff #0a0a0aff 0",
|
||||
"#eeeeeeff #0a0a0aff 0"
|
||||
],
|
||||
"runs": [
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,31],[1,19],[0,1],[2,19],[0,30]],
|
||||
[[0,31],[1,19],[0,1],[2,19],[0,30]],
|
||||
[[0,31],[1,1],[3,2],[1,3],[3,2],[1,3],[3,3],[1,2],[3,2],[1,1],[0,1],[2,1],[4,3],[2,2],[4,2],[2,3],[4,2],[2,3],[4,3],[0,30]],
|
||||
[[0,31],[1,16],[5,2],[1,1],[0,1],[2,19],[0,30]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,13],[6,1],[7,74],[0,12]],
|
||||
[[0,13],[6,1],[7,2],[8,84]],
|
||||
[[0,13],[6,1],[7,74],[0,12]],
|
||||
[[0,13],[6,1],[7,74],[0,12]],
|
||||
[[0,13],[6,1],[9,74],[0,12]],
|
||||
[[0,13],[1,31],[0,11],[10,10],[1,6],[0,2],[10,7],[1,8],[0,12]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,94],[1,4],[0,2]],
|
||||
[[0,100]],
|
||||
[[0,2],[1,24],[0,74]]
|
||||
]
|
||||
}
|
||||
18
packages/cli-rs/parity/plugins/slot/tui.tsx
Normal file
18
packages/cli-rs/parity/plugins/slot/tui.tsx
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// The P.1 test plugin, TypeScript side: one line appended to the home.footer slot, after the footer built-in.
|
||||
// parity/scenarios/P.1/slot.app.ts loads this directory through the cli.json `plugins` entry; the Rust TUI
|
||||
// skips that entry and registers its Rust twin (`slot_plugin` in crates/tui/tests/app.rs).
|
||||
import type { Context } from "../../../../plugin/src/tui/plugin"
|
||||
|
||||
export default {
|
||||
id: "parity.slot",
|
||||
setup(context: Context) {
|
||||
context.ui.slot({
|
||||
append: "home.footer",
|
||||
render: () => (
|
||||
<box paddingLeft={2}>
|
||||
<text fg={context.theme.text.muted}>slot plugin: home.footer</text>
|
||||
</box>
|
||||
),
|
||||
})
|
||||
},
|
||||
}
|
||||
25
packages/cli-rs/parity/scenarios/P.1/slot.app.ts
vendored
Normal file
25
packages/cli-rs/parity/scenarios/P.1/slot.app.ts
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// A plugin in a slot (P.1): a test plugin appends a line to home.footer, under the footer built-in. TS loads it
|
||||
// from parity/plugins/slot as a local plugin; Rust registers its twin when OPENCODE_PARITY_PLUGIN is `slot`.
|
||||
import { defineApp } from "../../lib/app"
|
||||
|
||||
export default defineApp({
|
||||
config: { plugins: ["./plugins/slot"] },
|
||||
env: { OPENCODE_PARITY_PLUGIN: "slot" },
|
||||
steps: [
|
||||
{
|
||||
checkpoint: "home",
|
||||
until: "slot plugin: home.footer",
|
||||
masks: [
|
||||
{
|
||||
x: 16,
|
||||
y: 16,
|
||||
width: 84,
|
||||
height: 1,
|
||||
reason: "the placeholder: random in TS, not drawn yet in Rust (T17-home-prompt)",
|
||||
},
|
||||
],
|
||||
// The prompt footer hints are E.14's.
|
||||
deviation: ["P01-read-only-prompt"],
|
||||
},
|
||||
],
|
||||
})
|
||||
Loading…
Add table
Reference in a new issue