mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 03:03:44 +00:00
feat(coding-agent): add DOSBox terminal extension
- Render DOSBox framebuffer as images in terminal via emulators package - Support keyboard input with js-dos key codes - Push Kitty enhanced mode for proper key press/release events - Standalone app (npm start) and pi extension entry point - Exit with Ctrl+Q
This commit is contained in:
parent
df8b3544c3
commit
6515b1a3dd
6 changed files with 655 additions and 2 deletions
44
packages/coding-agent/examples/extensions/pi-dosbox/index.ts
Normal file
44
packages/coding-agent/examples/extensions/pi-dosbox/index.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* DOSBox extension for pi
|
||||
*
|
||||
* Usage: pi --extension ./examples/extensions/pi-dosbox
|
||||
* Command: /dosbox [bundle.jsdos]
|
||||
*/
|
||||
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||
import { DosboxComponent } from "./src/dosbox-component.js";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
pi.registerCommand("dosbox", {
|
||||
description: "Run DOSBox emulator",
|
||||
|
||||
handler: async (args, ctx) => {
|
||||
if (!ctx.hasUI) {
|
||||
ctx.ui.notify("DOSBox requires interactive mode", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
const bundlePath = args?.trim();
|
||||
let bundleData: Uint8Array | undefined;
|
||||
if (bundlePath) {
|
||||
try {
|
||||
const resolvedPath = resolve(ctx.cwd, bundlePath);
|
||||
bundleData = await readFile(resolvedPath);
|
||||
} catch (error) {
|
||||
ctx.ui.notify(
|
||||
`Failed to load bundle: ${error instanceof Error ? error.message : String(error)}`,
|
||||
"error",
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await ctx.ui.custom((tui, theme, _kb, done) => {
|
||||
const fallbackColor = (s: string) => theme.fg("warning", s);
|
||||
return new DosboxComponent(tui, fallbackColor, () => done(undefined), bundleData);
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue