@@ -1,6 +1,3 @@
1-import { stat } from "node:fs/promises";
2-import { homedir } from "node:os";
3-import { join } from "node:path";
41 import { cel, HStack, ProcessTerminal, VStack } from "@cel-tui/core";
52 import type {
63 AssistantMessage,
@@ -46,52 +43,6 @@ function clearOrAbort(state: TUIState) {
4643 }
4744 }
4845
49-async function directoryExists(path: string): Promise<boolean> {
50- try {
51- return (await stat(path)).isDirectory();
52- } catch {
53- return false;
54- }
55-}
56-
57-async function handleSkillSlashCommand(prompt: string) {
58- const match = prompt.trim().match(/^\/([a-zA-Z0-9_-]+)(?:\s|$)/);
59-
60- if (!match) return;
61-
62- const skillName = match[1];
63- const skillRoots = [
64- join(homedir(), ".agents", "skills"),
65- join(process.cwd(), ".agents", "skills"),
66- ];
67-
68- for (const root of skillRoots) {
69- if (!(await directoryExists(root))) {
70- continue;
71- }
72-
73- const glob = new Bun.Glob("*/SKILL.md");
74-
75- for await (const path of glob.scan({ cwd: root, absolute: true })) {
76- const file = Bun.file(path);
77-
78- if (!(await file.exists())) {
79- continue;
80- }
81-
82- const body = await file.text();
83- const frontmatter = body.match(/^---\s*\n([\s\S]*?)\n---/);
84- const name = frontmatter?.[1]
85- .match(/^name:\s*["']?([^"'\n]+)["']?\s*$/m)?.[1]
86- ?.trim();
87-
88- if (name === skillName) {
89- return body;
90- }
91- }
92- }
93-}
94-
9546 export function initTUI(state: TUIState, leave: (s: string) => void) {
9647 // TODO: Cleanup accumulated sessions for this cwd.
9748 const { spinnerEvery, currentSpinner } = Spinner();
@@ -137,16 +88,6 @@ export function initTUI(state: TUIState, leave: (s: string) => void) {
13788 const submit = async () => {
13889 await streamAgentTUI(state);
13990 };
140- const skillSubmit = async () => {
141- const skill = await handleSkillSlashCommand(state.prompt);
142- if (skill) {
143- state.streaming = true;
144- // This cause the prompt to flash the body before vanishing on submit.
145- // To avoid this I added a new state property
146- state.promptSkill = skill;
147- await streamAgentTUI(state);
148- }
149- };
15091 // onKeyPress
15192 if (key === "enter") {
15293 if (state.prompt === ":q") {
@@ -165,10 +106,6 @@ export function initTUI(state: TUIState, leave: (s: string) => void) {
165106 state.stickToBottom = true;
166107 return false;
167108 }
168- if (state.prompt && state.prompt[0] === "/" && !state.streaming) {
169- skillSubmit();
170- return false;
171- }
172109 if (state.prompt && !state.streaming) submit();
173110 return false;
174111 }
@@ -227,12 +164,6 @@ async function streamAgentTUI(state: TUIState) {
227164 ];
228165
229166 let userContent = state.prompt;
230- if (state.promptSkill) {
231- // TODO: Skill arguments? replace template marks in skill body for arguments?
232- // Right now we just appead the user prompt to the skill body
233- userContent = `${state.promptSkill}\n${state.prompt}`;
234- state.promptSkill = undefined;
235- }
236167 if (state.messages.length === 0) {
237168 const envReminder = await injectEnvReminder();
238169 userContent = `${envReminder}\n\n${userContent}`;