@devang0907/agent-dev 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ async function collectStream(model, messages, settings, systemPrompt, signal, on
13
13
  systemPrompt,
14
14
  thinkingLevel: settings.thinkingLevel,
15
15
  signal,
16
- });
16
+ }, settings);
17
17
  for await (const event of stream) {
18
18
  if (event.type === "text_delta") {
19
19
  content += event.delta;
@@ -1,10 +1,9 @@
1
1
  import type { ProviderId } from "../providers/types.js";
2
- import type { ThinkingLevel, Theme } from "../providers/types.js";
2
+ import type { ThinkingLevel } from "../providers/types.js";
3
3
  export interface Settings {
4
4
  defaultProvider: ProviderId;
5
5
  defaultModel: string;
6
6
  thinkingLevel: ThinkingLevel;
7
- theme: Theme;
8
7
  apiKeys?: Partial<Record<ProviderId, string>>;
9
8
  }
10
9
  export declare function loadSettings(): Settings;
@@ -4,7 +4,6 @@ const DEFAULT_SETTINGS = {
4
4
  defaultProvider: "free",
5
5
  defaultModel: "meta-llama/llama-3.3-70b-instruct:free",
6
6
  thinkingLevel: "off",
7
- theme: "dark",
8
7
  };
9
8
  export function loadSettings() {
10
9
  if (!existsSync(SETTINGS_PATH)) {
@@ -12,7 +11,14 @@ export function loadSettings() {
12
11
  }
13
12
  try {
14
13
  const raw = readFileSync(SETTINGS_PATH, "utf-8");
15
- return { ...DEFAULT_SETTINGS, ...JSON.parse(raw) };
14
+ const parsed = JSON.parse(raw);
15
+ return {
16
+ ...DEFAULT_SETTINGS,
17
+ defaultProvider: parsed.defaultProvider ?? DEFAULT_SETTINGS.defaultProvider,
18
+ defaultModel: parsed.defaultModel ?? DEFAULT_SETTINGS.defaultModel,
19
+ thinkingLevel: parsed.thinkingLevel ?? DEFAULT_SETTINGS.thinkingLevel,
20
+ apiKeys: parsed.apiKeys,
21
+ };
16
22
  }
17
23
  catch {
18
24
  return { ...DEFAULT_SETTINGS };
@@ -1,6 +1,5 @@
1
1
  export type ProviderId = "openai" | "groq" | "gemini" | "free";
2
2
  export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high";
3
- export type Theme = "dark" | "light";
4
3
  export interface Model {
5
4
  provider: ProviderId;
6
5
  id: string;
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import type { ThemeColors } from "./theme.js";
3
+ import type { Model, ProviderId } from "../providers/types.js";
4
+ interface ApiKeyPromptProps {
5
+ theme: ThemeColors;
6
+ provider: ProviderId;
7
+ model: Model;
8
+ onSubmit: (apiKey: string) => void;
9
+ onCancel: () => void;
10
+ }
11
+ export declare function ApiKeyPrompt({ theme, provider, model, onSubmit, onCancel }: ApiKeyPromptProps): React.JSX.Element;
12
+ export {};
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ import { Box, Text, useInput } from "ink";
4
+ import { PROVIDER_LABELS } from "../config/models.js";
5
+ import { PROVIDER_ENV_VARS } from "../providers/registry.js";
6
+ import { LeftBorder } from "./LeftBorder.js";
7
+ import { Panel } from "./Panel.js";
8
+ function BlinkingCursor({ theme, visible }) {
9
+ if (!visible)
10
+ return null;
11
+ return _jsx(Text, { color: theme.primary, children: "\u258C" });
12
+ }
13
+ export function ApiKeyPrompt({ theme, provider, model, onSubmit, onCancel }) {
14
+ const [value, setValue] = useState("");
15
+ const [cursorOn, setCursorOn] = useState(true);
16
+ useEffect(() => {
17
+ const id = setInterval(() => setCursorOn((v) => !v), 530);
18
+ return () => clearInterval(id);
19
+ }, []);
20
+ useInput((input, key) => {
21
+ if (key.escape) {
22
+ onCancel();
23
+ return;
24
+ }
25
+ if (key.return) {
26
+ const trimmed = value.trim();
27
+ if (trimmed)
28
+ onSubmit(trimmed);
29
+ return;
30
+ }
31
+ if (key.backspace || key.delete) {
32
+ setValue((v) => v.slice(0, -1));
33
+ return;
34
+ }
35
+ if (input && !key.ctrl && !key.meta) {
36
+ setValue((v) => v + input);
37
+ }
38
+ });
39
+ const envVars = PROVIDER_ENV_VARS[provider];
40
+ const masked = "•".repeat(value.length);
41
+ return (_jsx(Box, { paddingX: 2, marginTop: 1, children: _jsxs(LeftBorder, { theme: theme, borderColor: theme.borderActive, children: [_jsx(Text, { color: theme.text, bold: true, children: "API key required" }), _jsx(Text, { color: theme.textMuted, children: " Enter save \u00B7 Esc back" }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { color: theme.textMuted, children: ["Provider: ", PROVIDER_LABELS[provider]] }), _jsxs(Text, { color: theme.textMuted, children: ["Model: ", model.name] })] }), _jsx(Box, { marginTop: 1, children: _jsx(Panel, { theme: theme, borderColor: theme.primary, marginBottom: 0, children: _jsx(Box, { flexDirection: "row", children: value.length > 0 ? (_jsxs(_Fragment, { children: [_jsx(Text, { color: theme.text, children: masked }), _jsx(BlinkingCursor, { theme: theme, visible: cursorOn })] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { color: theme.textMuted, children: "Paste API key\u2026" }), _jsx(BlinkingCursor, { theme: theme, visible: cursorOn })] })) }) }) }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: theme.textMuted, children: ["Or set env: ", envVars.join(" · ")] }) })] }) }));
42
+ }
package/dist/ui/App.js CHANGED
@@ -1,11 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useCallback, useRef } from "react";
3
- import { Box, Text, useInput, useApp } from "ink";
3
+ import { Box, useInput, useApp } from "ink";
4
4
  import { ChatView } from "./ChatView.js";
5
5
  import { Editor } from "./Editor.js";
6
6
  import { Footer } from "./Footer.js";
7
7
  import { ModelSelector } from "./ModelSelector.js";
8
+ import { ApiKeyPrompt } from "./ApiKeyPrompt.js";
8
9
  import { SettingsView } from "./SettingsView.js";
10
+ import { hasProviderAuth } from "../providers/registry.js";
11
+ import { StartupBanner } from "./StartupBanner.js";
9
12
  import { getTheme } from "./theme.js";
10
13
  import { saveSettings } from "../config/settings.js";
11
14
  export function App({ session, workdir, onQuit }) {
@@ -18,11 +21,12 @@ export function App({ session, workdir, onQuit }) {
18
21
  const [streamingText, setStreamingText] = useState("");
19
22
  const [overlay, setOverlay] = useState("none");
20
23
  const [modelFilter, setModelFilter] = useState();
24
+ const [pendingModel, setPendingModel] = useState(null);
21
25
  const [settings, setSettings] = useState(session.getSettings());
22
26
  const [model, setModel] = useState(session.getModel());
23
27
  const [running, setRunning] = useState(false);
24
28
  const streamingRef = useRef("");
25
- const theme = getTheme(settings.theme);
29
+ const theme = getTheme();
26
30
  useEffect(() => {
27
31
  const handler = (event) => {
28
32
  switch (event.type) {
@@ -115,7 +119,13 @@ export function App({ session, workdir, onQuit }) {
115
119
  return;
116
120
  await session.prompt(value);
117
121
  }, [session, running, onQuit, exit]);
118
- return (_jsxs(Box, { flexDirection: "column", height: "100%", children: [_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { color: theme.header, bold: true, children: "agent-dev" }), _jsx(Text, { color: theme.muted, children: " \u2014 /model /settings /new /quit | Esc abort" })] }), _jsx(ChatView, { messages: displayMessages, theme: theme, streamingText: streamingText }), _jsx(Footer, { workdir: workdir, model: model, theme: theme, running: running }), overlay === "none" && (_jsx(Editor, { theme: theme, disabled: running, onSubmit: handleSubmit })), overlay === "model" && (_jsx(ModelSelector, { theme: theme, settings: settings, filter: modelFilter, onSelect: (m) => {
122
+ const hasChat = displayMessages.length > 0 || streamingText.length > 0;
123
+ return (_jsxs(Box, { flexDirection: "column", height: "100%", children: [_jsx(Box, { paddingX: 2, marginBottom: 1, children: _jsx(StartupBanner, { theme: theme, compact: hasChat }) }), _jsx(ChatView, { messages: displayMessages, theme: theme, model: model, streamingText: streamingText, running: running }), _jsx(Footer, { workdir: workdir, model: model, theme: theme }), overlay === "none" && (_jsx(Editor, { theme: theme, model: model, disabled: running, running: running, onSubmit: handleSubmit })), overlay === "model" && (_jsx(ModelSelector, { theme: theme, settings: settings, filter: modelFilter, onSelect: (m) => {
124
+ if (!hasProviderAuth(m.provider, settings)) {
125
+ setPendingModel(m);
126
+ setOverlay("apiKey");
127
+ return;
128
+ }
119
129
  session.setModel(m);
120
130
  setModel(m);
121
131
  setOverlay("none");
@@ -123,6 +133,21 @@ export function App({ session, workdir, onQuit }) {
123
133
  }, onClose: () => {
124
134
  setOverlay("none");
125
135
  setModelFilter(undefined);
136
+ } })), overlay === "apiKey" && pendingModel && (_jsx(ApiKeyPrompt, { theme: theme, provider: pendingModel.provider, model: pendingModel, onSubmit: (apiKey) => {
137
+ const updated = {
138
+ ...settings,
139
+ apiKeys: { ...settings.apiKeys, [pendingModel.provider]: apiKey },
140
+ };
141
+ session.updateSettings(updated);
142
+ setSettings(updated);
143
+ session.setModel(pendingModel);
144
+ setModel(pendingModel);
145
+ setPendingModel(null);
146
+ setOverlay("none");
147
+ setModelFilter(undefined);
148
+ }, onCancel: () => {
149
+ setPendingModel(null);
150
+ setOverlay("model");
126
151
  } })), overlay === "settings" && (_jsx(SettingsView, { theme: theme, settings: settings, onUpdate: (s) => {
127
152
  session.updateSettings(s);
128
153
  setSettings(s);
@@ -1,10 +1,13 @@
1
1
  import React from "react";
2
2
  import type { DisplayMessage } from "./App.js";
3
3
  import type { ThemeColors } from "./theme.js";
4
+ import type { Model } from "../providers/types.js";
4
5
  interface ChatViewProps {
5
6
  messages: DisplayMessage[];
6
7
  theme: ThemeColors;
8
+ model: Model;
7
9
  streamingText?: string;
10
+ running?: boolean;
8
11
  }
9
- export declare function ChatView({ messages, theme, streamingText }: ChatViewProps): React.JSX.Element;
12
+ export declare function ChatView({ messages, theme, model, streamingText, running }: ChatViewProps): React.JSX.Element | null;
10
13
  export {};
@@ -1,5 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
2
3
  import { Box, Text } from "ink";
3
- export function ChatView({ messages, theme, streamingText }) {
4
- return (_jsxs(Box, { flexDirection: "column", flexGrow: 1, marginBottom: 1, children: [messages.length === 0 && !streamingText && (_jsx(Text, { color: theme.muted, children: "Type a message or /model to select a provider. /settings for options." })), messages.map((msg, i) => (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [msg.role === "user" && (_jsxs(Text, { color: theme.user, bold: true, children: ["You: ", msg.content] })), msg.role === "assistant" && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: theme.assistant, bold: true, children: "Assistant:" }), _jsx(Text, { color: theme.assistant, children: msg.content || "" })] })), msg.role === "tool" && (_jsx(Box, { flexDirection: "column", children: _jsxs(Text, { color: theme.tool, children: ["[", msg.toolName, "] ", msg.content.slice(0, 200), msg.content.length > 200 ? "..." : ""] }) }))] }, i))), streamingText && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: theme.assistant, bold: true, children: "Assistant:" }), _jsx(Text, { color: theme.assistant, children: streamingText })] }))] }));
4
+ import { SPINNER_FRAMES, TOOL_ICONS } from "./theme.js";
5
+ import { LeftBorder } from "./LeftBorder.js";
6
+ import { Panel } from "./Panel.js";
7
+ import { modelRef } from "../config/models.js";
8
+ function truncate(text, max) {
9
+ return text.length > max ? text.slice(0, max) + "…" : text;
10
+ }
11
+ export function ChatView({ messages, theme, model, streamingText, running }) {
12
+ const [spinIdx, setSpinIdx] = useState(0);
13
+ const hasContent = messages.length > 0 || (streamingText?.length ?? 0) > 0;
14
+ useEffect(() => {
15
+ if (!running && !streamingText)
16
+ return;
17
+ const id = setInterval(() => setSpinIdx((i) => (i + 1) % SPINNER_FRAMES.length), 80);
18
+ return () => clearInterval(id);
19
+ }, [running, streamingText]);
20
+ if (!hasContent) {
21
+ return null;
22
+ }
23
+ return (_jsxs(Panel, { theme: theme, flexGrow: 1, borderColor: theme.border, children: [messages.map((msg, i) => (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [msg.role === "user" && (_jsx(LeftBorder, { theme: theme, borderColor: theme.primary, marginBottom: 0, children: _jsx(Text, { color: theme.text, children: msg.content }) })), msg.role === "assistant" && (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsx(Text, { color: theme.text, children: msg.content || "" }), _jsxs(Text, { color: theme.textMuted, children: [_jsx(Text, { color: theme.primary, children: "\u25A3 " }), modelRef(model)] })] })), msg.role === "tool" && (_jsx(Box, { paddingLeft: 1, children: _jsxs(Text, { color: theme.text, children: [_jsx(Text, { color: theme.textMuted, children: TOOL_ICONS[msg.toolName ?? ""] ?? "⚙" }), " ", _jsx(Text, { bold: true, children: msg.toolName }), _jsxs(Text, { color: theme.textMuted, children: [" ", truncate(msg.content, 200)] })] }) }))] }, i))), streamingText && (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsx(Text, { color: theme.text, children: streamingText }), _jsxs(Text, { color: theme.textMuted, children: [_jsxs(Text, { color: theme.primary, children: [SPINNER_FRAMES[spinIdx], " "] }), "responding\u2026"] })] })), running && !streamingText && messages.length > 0 && (_jsx(Box, { paddingLeft: 1, children: _jsxs(Text, { color: theme.textMuted, children: [_jsx(Text, { color: theme.primary, children: SPINNER_FRAMES[spinIdx] }), " working\u2026"] }) }))] }));
5
24
  }
@@ -1,10 +1,12 @@
1
1
  import React from "react";
2
2
  import type { ThemeColors } from "./theme.js";
3
+ import type { Model } from "../providers/types.js";
3
4
  interface EditorProps {
4
5
  theme: ThemeColors;
6
+ model: Model;
5
7
  disabled?: boolean;
8
+ running?: boolean;
6
9
  onSubmit: (value: string) => void;
7
- filterHint?: string;
8
10
  }
9
- export declare function Editor({ theme, disabled, onSubmit, filterHint }: EditorProps): React.JSX.Element;
11
+ export declare function Editor({ theme, model, disabled, running, onSubmit }: EditorProps): React.JSX.Element;
10
12
  export {};
package/dist/ui/Editor.js CHANGED
@@ -1,10 +1,40 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
3
  import { Box, Text, useInput } from "ink";
4
- const SLASH_COMMANDS = ["/model", "/settings", "/new", "/quit"];
5
- export function Editor({ theme, disabled, onSubmit, filterHint }) {
6
- const [value, setValue] = useState(filterHint ?? "");
4
+ import { modelRef } from "../config/models.js";
5
+ import { matchSlashCommands, completeSlashInput, } from "./slash-commands.js";
6
+ import { Panel } from "./Panel.js";
7
+ import { SPINNER_FRAMES } from "./theme.js";
8
+ function BlinkingCursor({ theme, visible }) {
9
+ if (!visible)
10
+ return null;
11
+ return _jsx(Text, { color: theme.primary, children: "\u258C" });
12
+ }
13
+ export function Editor({ theme, model, disabled, running, onSubmit }) {
14
+ const [value, setValue] = useState("");
7
15
  const [suggestions, setSuggestions] = useState([]);
16
+ const [spinIdx, setSpinIdx] = useState(0);
17
+ const [cursorOn, setCursorOn] = useState(true);
18
+ useEffect(() => {
19
+ if (!running)
20
+ return;
21
+ const id = setInterval(() => setSpinIdx((i) => (i + 1) % SPINNER_FRAMES.length), 80);
22
+ return () => clearInterval(id);
23
+ }, [running]);
24
+ useEffect(() => {
25
+ if (disabled)
26
+ return;
27
+ const id = setInterval(() => setCursorOn((v) => !v), 530);
28
+ return () => clearInterval(id);
29
+ }, [disabled]);
30
+ const updateSuggestions = (text) => {
31
+ if (text.startsWith("/")) {
32
+ setSuggestions(matchSlashCommands(text));
33
+ }
34
+ else {
35
+ setSuggestions([]);
36
+ }
37
+ };
8
38
  useInput((input, key) => {
9
39
  if (disabled)
10
40
  return;
@@ -16,20 +46,33 @@ export function Editor({ theme, disabled, onSubmit, filterHint }) {
16
46
  setSuggestions([]);
17
47
  return;
18
48
  }
49
+ if (key.tab) {
50
+ if (value.startsWith("/")) {
51
+ const completed = completeSlashInput(value);
52
+ if (completed) {
53
+ setValue(completed);
54
+ setSuggestions(matchSlashCommands(completed));
55
+ }
56
+ else if (suggestions.length > 0) {
57
+ setValue(suggestions[0].cmd);
58
+ setSuggestions(matchSlashCommands(suggestions[0].cmd));
59
+ }
60
+ }
61
+ return;
62
+ }
19
63
  if (key.backspace || key.delete) {
20
- setValue((v) => v.slice(0, -1));
64
+ const newVal = value.slice(0, -1);
65
+ setValue(newVal);
66
+ updateSuggestions(newVal);
21
67
  return;
22
68
  }
23
69
  if (input && !key.ctrl && !key.meta) {
24
70
  const newVal = value + input;
25
71
  setValue(newVal);
26
- if (newVal.startsWith("/")) {
27
- setSuggestions(SLASH_COMMANDS.filter((c) => c.startsWith(newVal)));
28
- }
29
- else {
30
- setSuggestions([]);
31
- }
72
+ updateSuggestions(newVal);
32
73
  }
33
74
  });
34
- return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.accent, paddingX: 1, children: [suggestions.length > 0 && (_jsx(Text, { color: theme.muted, children: suggestions.join(" ") })), _jsxs(Text, { children: [_jsx(Text, { color: theme.accent, children: "> " }), _jsx(Text, { children: value }), _jsx(Text, { color: theme.muted, children: "\u2588" })] })] }));
75
+ const placeholder = "Ask anything…";
76
+ const showCursor = !disabled && cursorOn;
77
+ return (_jsxs(Box, { flexDirection: "column", marginX: 2, children: [suggestions.length > 0 && (_jsx(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.border, paddingX: 1, marginBottom: 1, children: suggestions.map((s) => (_jsxs(Text, { children: [_jsx(Text, { color: theme.primary, children: s.cmd }), _jsxs(Text, { color: theme.textMuted, children: [" \u2014 ", s.desc] })] }, s.cmd))) })), _jsxs(Panel, { theme: theme, borderColor: disabled ? theme.border : theme.primary, marginBottom: 0, children: [_jsx(Box, { flexDirection: "row", children: value.length > 0 ? (_jsxs(_Fragment, { children: [_jsx(Text, { color: theme.text, children: value }), _jsx(BlinkingCursor, { theme: theme, visible: showCursor })] })) : showCursor ? (_jsx(BlinkingCursor, { theme: theme, visible: true })) : (_jsx(Text, { color: theme.textMuted, children: placeholder })) }), _jsxs(Text, { color: theme.textMuted, children: ["agent-dev \u00B7 ", _jsx(Text, { color: theme.text, children: modelRef(model) })] })] }), _jsx(Box, { marginTop: 1, marginBottom: 1, children: running ? (_jsxs(Text, { color: theme.textMuted, children: [_jsx(Text, { color: theme.primary, children: SPINNER_FRAMES[spinIdx] }), " ", "esc interrupt"] })) : (_jsx(Text, { color: theme.textMuted, children: "Tab completes /commands" })) })] }));
35
78
  }
@@ -5,7 +5,6 @@ interface FooterProps {
5
5
  workdir: string;
6
6
  model: Model;
7
7
  theme: ThemeColors;
8
- running: boolean;
9
8
  }
10
- export declare function Footer({ workdir, model, theme, running }: FooterProps): React.JSX.Element;
9
+ export declare function Footer({ workdir, model, theme }: FooterProps): React.JSX.Element;
11
10
  export {};
package/dist/ui/Footer.js CHANGED
@@ -1,6 +1,11 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { modelRef } from "../config/models.js";
4
- export function Footer({ workdir, model, theme, running }) {
5
- return (_jsx(Box, { borderStyle: "single", borderColor: theme.border, paddingX: 1, children: _jsxs(Text, { color: theme.muted, children: [workdir, " | ", modelRef(model), " ", running ? "| working..." : ""] }) }));
4
+ function shortPath(path, max = 56) {
5
+ if (path.length <= max)
6
+ return path;
7
+ return "…" + path.slice(-(max - 1));
8
+ }
9
+ export function Footer({ workdir, model, theme }) {
10
+ return (_jsx(Box, { borderStyle: "single", borderColor: theme.border, borderLeft: false, borderRight: false, borderBottom: false, paddingX: 2, marginBottom: 1, children: _jsxs(Text, { color: theme.textMuted, children: [_jsx(Text, { color: theme.primary, children: "\u2302 " }), shortPath(workdir), " ", _jsx(Text, { color: theme.text, children: modelRef(model) })] }) }));
6
11
  }
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import type { ThemeColors } from "./theme.js";
3
+ interface LeftBorderProps {
4
+ theme: ThemeColors;
5
+ borderColor?: string;
6
+ marginBottom?: number;
7
+ children: React.ReactNode;
8
+ }
9
+ /** OpenCode-style left ┃ accent border */
10
+ export declare function LeftBorder({ theme, borderColor, marginBottom, children, }: LeftBorderProps): React.JSX.Element;
11
+ export {};
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from "ink";
3
+ /** OpenCode-style left ┃ accent border */
4
+ export function LeftBorder({ theme, borderColor = theme.primary, marginBottom = 0, children, }) {
5
+ return (_jsx(Box, { flexDirection: "column", borderStyle: "single", borderColor: borderColor, borderLeft: true, borderTop: false, borderRight: false, borderBottom: false, paddingLeft: 1, marginBottom: marginBottom, children: children }));
6
+ }
@@ -3,12 +3,13 @@ import { useState } from "react";
3
3
  import { Box, Text, useInput } from "ink";
4
4
  import { ALL_MODELS, modelRef, PROVIDER_LABELS } from "../config/models.js";
5
5
  import { hasProviderAuth } from "../providers/registry.js";
6
+ import { LeftBorder } from "./LeftBorder.js";
6
7
  function fuzzyMatch(text, query) {
7
8
  if (!query)
8
9
  return true;
9
10
  const lower = text.toLowerCase();
10
11
  const q = query.toLowerCase();
11
- return lower.includes(q) || modelRef({ provider: "openai", id: text, name: text }).includes(q);
12
+ return lower.includes(q);
12
13
  }
13
14
  export function ModelSelector({ theme, settings, filter, onSelect, onClose }) {
14
15
  const filtered = ALL_MODELS.filter((m) => {
@@ -17,7 +18,7 @@ export function ModelSelector({ theme, settings, filter, onSelect, onClose }) {
17
18
  });
18
19
  const [index, setIndex] = useState(0);
19
20
  const safeIndex = Math.min(index, Math.max(0, filtered.length - 1));
20
- useInput((input, key) => {
21
+ useInput((_, key) => {
21
22
  if (key.escape) {
22
23
  onClose();
23
24
  return;
@@ -29,14 +30,16 @@ export function ModelSelector({ theme, settings, filter, onSelect, onClose }) {
29
30
  if (key.return && filtered[safeIndex]) {
30
31
  onSelect(filtered[safeIndex]);
31
32
  }
32
- if (input && !key.ctrl) {
33
- // typing not used in overlay mode
34
- }
35
33
  });
36
34
  const providers = ["openai", "groq", "gemini", "free"];
37
- return (_jsxs(Box, { flexDirection: "column", borderStyle: "double", borderColor: theme.accent, padding: 1, children: [_jsx(Text, { color: theme.header, bold: true, children: "/model \u2014 select provider & model (Esc to close)" }), filter && _jsxs(Text, { color: theme.muted, children: ["Filter: ", filter] }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [filtered.length === 0 && _jsx(Text, { color: theme.muted, children: "No models match" }), filtered.map((m, i) => {
38
- const hasKey = hasProviderAuth(m.provider, settings);
39
- const selected = i === safeIndex;
40
- return (_jsxs(Text, { color: selected ? theme.accent : theme.assistant, children: [selected ? "> " : " ", "[", PROVIDER_LABELS[m.provider], "] ", m.name, !hasKey ? " (no key)" : ""] }, modelRef(m)));
41
- })] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: theme.muted, children: ["Providers: ", providers.map((p) => `${PROVIDER_LABELS[p]}${hasProviderAuth(p, settings) ? "" : " (no key)"}`).join(" | ")] }) })] }));
35
+ let lastProvider;
36
+ return (_jsx(Box, { paddingX: 2, marginTop: 1, children: _jsxs(LeftBorder, { theme: theme, borderColor: theme.borderActive, children: [_jsx(Text, { color: theme.text, bold: true, children: "/model" }), _jsx(Text, { color: theme.textMuted, children: " \u2191\u2193 navigate \u00B7 Enter select \u00B7 Esc close" }), _jsx(Text, { color: theme.textMuted, children: " Models without a key will prompt for an API key" }), filter && _jsxs(Text, { color: theme.textMuted, children: [" filter: ", filter] }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [filtered.length === 0 && _jsx(Text, { color: theme.textMuted, children: "No models match" }), filtered.map((m, i) => {
37
+ const selected = i === safeIndex;
38
+ const showHeader = m.provider !== lastProvider;
39
+ lastProvider = m.provider;
40
+ return (_jsxs(Box, { flexDirection: "column", children: [showHeader && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.textMuted, children: PROVIDER_LABELS[m.provider] }) })), _jsxs(Text, { color: selected ? theme.primary : theme.text, children: [selected ? "› " : " ", m.name, selected && _jsxs(Text, { color: theme.textMuted, children: [" ", modelRef(m)] })] })] }, modelRef(m)));
41
+ })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.textMuted, children: providers.map((p) => {
42
+ const ok = hasProviderAuth(p, settings);
43
+ return `${ok ? "●" : "○"} ${p}`;
44
+ }).join(" ") }) })] }) }));
42
45
  }
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import type { ThemeColors } from "./theme.js";
3
+ interface PanelProps {
4
+ theme: ThemeColors;
5
+ marginBottom?: number;
6
+ flexGrow?: number;
7
+ borderColor?: string;
8
+ children: React.ReactNode;
9
+ }
10
+ export declare function Panel({ theme, marginBottom, flexGrow, borderColor, children, }: PanelProps): React.JSX.Element;
11
+ export {};
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from "ink";
3
+ export function Panel({ theme, marginBottom = 1, flexGrow, borderColor = theme.border, children, }) {
4
+ return (_jsx(Box, { flexDirection: "column", flexGrow: flexGrow, borderStyle: "round", borderColor: borderColor, paddingX: 1, paddingY: 1, marginX: 2, marginBottom: marginBottom, children: children }));
5
+ }
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
3
  import { Box, Text, useInput } from "ink";
4
4
  import { PROVIDER_ENV_VARS } from "../providers/registry.js";
5
+ import { LeftBorder } from "./LeftBorder.js";
5
6
  const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high"];
6
- const THEMES = ["dark", "light"];
7
7
  export function SettingsView({ theme, settings, onUpdate, onClose }) {
8
8
  const [index, setIndex] = useState(0);
9
- const items = ["thinkingLevel", "theme", "envKeys"];
9
+ const items = ["thinkingLevel", "envKeys"];
10
10
  useInput((_, key) => {
11
11
  if (key.escape)
12
12
  onClose();
@@ -21,17 +21,12 @@ export function SettingsView({ theme, settings, onUpdate, onClose }) {
21
21
  const next = THINKING_LEVELS[(cur + 1) % THINKING_LEVELS.length];
22
22
  onUpdate({ ...settings, thinkingLevel: next });
23
23
  }
24
- else if (item === "theme") {
25
- const cur = THEMES.indexOf(settings.theme);
26
- const next = THEMES[(cur + 1) % THEMES.length];
27
- onUpdate({ ...settings, theme: next });
28
- }
29
24
  }
30
25
  });
31
26
  const providers = ["openai", "groq", "gemini", "free"];
32
- return (_jsxs(Box, { flexDirection: "column", borderStyle: "double", borderColor: theme.accent, padding: 1, children: [_jsx(Text, { color: theme.header, bold: true, children: "/settings (Enter to cycle, Esc to close)" }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { color: index === 0 ? theme.accent : theme.assistant, children: [index === 0 ? "> " : " ", "Thinking level: ", settings.thinkingLevel] }), _jsxs(Text, { color: index === 1 ? theme.accent : theme.assistant, children: [index === 1 ? "> " : " ", "Theme: ", settings.theme] }), _jsxs(Text, { color: index === 2 ? theme.accent : theme.muted, children: [index === 2 ? "> " : " ", "API keys (env vars):"] }), providers.map((p) => {
33
- const vars = PROVIDER_ENV_VARS[p];
34
- const set = vars.some((v) => process.env[v]);
35
- return (_jsxs(Text, { color: theme.muted, children: [" ", p, ": ", vars.join(" or "), " \u2014 ", set ? "set" : "not set"] }, p));
36
- })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.muted, children: "Set OPENAI_API_KEY, GROQ_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY" }) })] }));
27
+ return (_jsx(Box, { paddingX: 2, marginTop: 1, children: _jsxs(LeftBorder, { theme: theme, borderColor: theme.borderActive, children: [_jsx(Text, { color: theme.text, bold: true, children: "/settings" }), _jsx(Text, { color: theme.textMuted, children: " Enter cycle \u00B7 Esc close" }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { color: index === 0 ? theme.primary : theme.text, children: [index === 0 ? " " : " ", "Thinking:", " ", _jsx(Text, { bold: true, children: settings.thinkingLevel })] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: index === 1 ? theme.primary : theme.textMuted, children: [index === 1 ? " " : " ", "API keys"] }) }), providers.map((p) => {
28
+ const vars = PROVIDER_ENV_VARS[p];
29
+ const set = vars.some((v) => process.env[v]);
30
+ return (_jsxs(Text, { color: set ? theme.success : theme.textMuted, children: [" ", set ? "✓" : "○", " ", p, ": ", vars.join(" · ")] }, p));
31
+ })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.textMuted, children: "OPENAI_API_KEY \u00B7 GROQ_API_KEY \u00B7 GEMINI_API_KEY \u00B7 OPENROUTER_API_KEY" }) })] }) }));
37
32
  }
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import type { ThemeColors } from "./theme.js";
3
+ interface StartupBannerProps {
4
+ theme: ThemeColors;
5
+ compact?: boolean;
6
+ }
7
+ export declare const StartupBanner: React.NamedExoticComponent<StartupBannerProps>;
8
+ export {};
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo } from "react";
3
+ import { Box, Text } from "ink";
4
+ /**
5
+ * 5x7 block-letter glyphs for the "AGENT-DEV" wordmark.
6
+ * "█" = lit pixel, " " = empty pixel. Every glyph is exactly 5 columns
7
+ * wide and 7 rows tall, so glyphs line up cleanly when concatenated
8
+ * row-by-row to spell out a word.
9
+ */
10
+ const GLYPH_HEIGHT = 7;
11
+ const GLYPH_WIDTH = 5;
12
+ const GLYPHS = {
13
+ A: [" █ ", " █ █ ", "█ █", "█████", "█ █", "█ █", "█ █"],
14
+ G: [" ███ ", "█ ", "█ ", "█ ███", "█ █", "█ █", " ███ "],
15
+ E: ["█████", "█ ", "█ ", "████ ", "█ ", "█ ", "█████"],
16
+ N: ["█ █", "██ █", "█ █ █", "█ ██", "█ █", "█ █", "█ █"],
17
+ T: ["█████", " █ ", " █ ", " █ ", " █ ", " █ ", " █ "],
18
+ "-": [" ", " ", " ", "█████", " ", " ", " "],
19
+ D: ["████ ", "█ █", "█ █", "█ █", "█ █", "█ █", "████ "],
20
+ V: ["█ █", "█ █", "█ █", "█ █", " █ █ ", " █ █ ", " █ "],
21
+ };
22
+ const BLANK_GLYPH = Array(GLYPH_HEIGHT).fill(" ".repeat(GLYPH_WIDTH));
23
+ /** Wordmark color — matches the brand logo regardless of active theme. */
24
+ const LOGO_COLOR = "#F2A154";
25
+ function glyphFor(char) {
26
+ return GLYPHS[char.toUpperCase()] ?? BLANK_GLYPH;
27
+ }
28
+ /** Builds the word as GLYPH_HEIGHT lines of text, gap columns between letters. */
29
+ function buildBlockLines(word, gap = 1) {
30
+ const glyphs = word.split("").map(glyphFor);
31
+ const gapStr = " ".repeat(gap);
32
+ const lines = [];
33
+ for (let row = 0; row < GLYPH_HEIGHT; row++) {
34
+ lines.push(glyphs.map((g) => g[row]).join(gapStr));
35
+ }
36
+ return lines;
37
+ }
38
+ const LOGO_LINES = buildBlockLines("AGENT-DEV");
39
+ const LOGO_MINI = "AGENT-DEV";
40
+ export const StartupBanner = memo(function StartupBanner({ theme, compact, }) {
41
+ // Falls back to the brand orange; lets a theme override via an
42
+ // optional `accent` field without forcing it into ThemeColors.
43
+ const color = theme.accent ?? LOGO_COLOR;
44
+ if (compact) {
45
+ return (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: color, bold: true, children: LOGO_MINI }) }));
46
+ }
47
+ return (_jsx(Box, { flexDirection: "column", marginBottom: 1, children: LOGO_LINES.map((line, i) => (_jsx(Text, { color: color, bold: true, children: line }, i))) }));
48
+ });
@@ -0,0 +1,16 @@
1
+ export declare const SLASH_COMMANDS: readonly [{
2
+ readonly cmd: "/model";
3
+ readonly desc: "Select provider & model";
4
+ }, {
5
+ readonly cmd: "/settings";
6
+ readonly desc: "Thinking level & API keys";
7
+ }, {
8
+ readonly cmd: "/new";
9
+ readonly desc: "New session";
10
+ }, {
11
+ readonly cmd: "/quit";
12
+ readonly desc: "Exit";
13
+ }];
14
+ export declare function matchSlashCommands(input: string): typeof SLASH_COMMANDS[number][];
15
+ export declare function longestCommonPrefix(strings: string[]): string;
16
+ export declare function completeSlashInput(input: string): string | null;
@@ -0,0 +1,31 @@
1
+ export const SLASH_COMMANDS = [
2
+ { cmd: "/model", desc: "Select provider & model" },
3
+ { cmd: "/settings", desc: "Thinking level & API keys" },
4
+ { cmd: "/new", desc: "New session" },
5
+ { cmd: "/quit", desc: "Exit" },
6
+ ];
7
+ export function matchSlashCommands(input) {
8
+ if (!input.startsWith("/"))
9
+ return [];
10
+ return SLASH_COMMANDS.filter((c) => c.cmd.startsWith(input));
11
+ }
12
+ export function longestCommonPrefix(strings) {
13
+ if (strings.length === 0)
14
+ return "";
15
+ let prefix = strings[0];
16
+ for (let i = 1; i < strings.length; i++) {
17
+ while (prefix && !strings[i].startsWith(prefix)) {
18
+ prefix = prefix.slice(0, -1);
19
+ }
20
+ }
21
+ return prefix;
22
+ }
23
+ export function completeSlashInput(input) {
24
+ const matches = matchSlashCommands(input).map((c) => c.cmd);
25
+ if (matches.length === 0)
26
+ return null;
27
+ if (matches.length === 1)
28
+ return matches[0];
29
+ const common = longestCommonPrefix(matches);
30
+ return common.length > input.length ? common : null;
31
+ }
@@ -1,13 +1,16 @@
1
- import type { Theme } from "../providers/types.js";
2
1
  export interface ThemeColors {
3
- user: string;
4
- assistant: string;
5
- tool: string;
6
- border: string;
7
- muted: string;
8
- accent: string;
2
+ text: string;
3
+ textMuted: string;
4
+ primary: string;
5
+ secondary: string;
6
+ success: string;
7
+ warning: string;
9
8
  error: string;
10
- header: string;
9
+ border: string;
10
+ borderActive: string;
11
11
  }
12
- export declare const themes: Record<Theme, ThemeColors>;
13
- export declare function getTheme(theme: Theme): ThemeColors;
12
+ /** OpenCode-inspired palette standard terminal ANSI colors */
13
+ export declare const theme: ThemeColors;
14
+ export declare function getTheme(): ThemeColors;
15
+ export declare const SPINNER_FRAMES: string[];
16
+ export declare const TOOL_ICONS: Record<string, string>;
package/dist/ui/theme.js CHANGED
@@ -1,25 +1,22 @@
1
- export const themes = {
2
- dark: {
3
- user: "cyan",
4
- assistant: "white",
5
- tool: "yellow",
6
- border: "gray",
7
- muted: "gray",
8
- accent: "green",
9
- error: "red",
10
- header: "blue",
11
- },
12
- light: {
13
- user: "blue",
14
- assistant: "black",
15
- tool: "yellow",
16
- border: "gray",
17
- muted: "gray",
18
- accent: "green",
19
- error: "red",
20
- header: "blue",
21
- },
1
+ /** OpenCode-inspired palette standard terminal ANSI colors */
2
+ export const theme = {
3
+ text: "white",
4
+ textMuted: "gray",
5
+ primary: "cyan",
6
+ secondary: "blue",
7
+ success: "green",
8
+ warning: "yellow",
9
+ error: "red",
10
+ border: "gray",
11
+ borderActive: "white",
22
12
  };
23
- export function getTheme(theme) {
24
- return themes[theme];
13
+ export function getTheme() {
14
+ return theme;
25
15
  }
16
+ export const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
17
+ export const TOOL_ICONS = {
18
+ bash: "$",
19
+ read: "→",
20
+ write: "⚙",
21
+ edit: "%",
22
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devang0907/agent-dev",
3
- "version": "0.1.0",
4
- "description": "Minimal pi-like terminal coding agent with Ink UI",
3
+ "version": "0.1.2",
4
+ "description": "Minimal terminal coding agent",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Devang Rakholiya <rakholiyadevang@gmail.com>",
@@ -9,8 +9,17 @@
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/Devang0907/agent-dev.git"
11
11
  },
12
- "keywords": ["ai", "agent", "cli", "ink", "coding-agent"],
13
- "files": ["dist", "README.md"],
12
+ "keywords": [
13
+ "ai",
14
+ "agent",
15
+ "cli",
16
+ "ink",
17
+ "coding-agent"
18
+ ],
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
14
23
  "bin": {
15
24
  "agent": "dist/cli.js"
16
25
  },