@agentick/cli 0.0.1

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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +353 -0
  3. package/dist/bin.d.ts +6 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +44 -0
  6. package/dist/bin.js.map +1 -0
  7. package/dist/chat-session.d.ts +37 -0
  8. package/dist/chat-session.d.ts.map +1 -0
  9. package/dist/chat-session.js +201 -0
  10. package/dist/chat-session.js.map +1 -0
  11. package/dist/cli.d.ts +84 -0
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +147 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/commands/chat.d.ts +13 -0
  16. package/dist/commands/chat.d.ts.map +1 -0
  17. package/dist/commands/chat.js +22 -0
  18. package/dist/commands/chat.js.map +1 -0
  19. package/dist/commands/send.d.ts +14 -0
  20. package/dist/commands/send.d.ts.map +1 -0
  21. package/dist/commands/send.js +77 -0
  22. package/dist/commands/send.js.map +1 -0
  23. package/dist/commands/status.d.ts +11 -0
  24. package/dist/commands/status.d.ts.map +1 -0
  25. package/dist/commands/status.js +22 -0
  26. package/dist/commands/status.js.map +1 -0
  27. package/dist/config.d.ts +36 -0
  28. package/dist/config.d.ts.map +1 -0
  29. package/dist/config.js +83 -0
  30. package/dist/config.js.map +1 -0
  31. package/dist/index.d.ts +12 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +12 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/ui/renderer.d.ts +85 -0
  36. package/dist/ui/renderer.d.ts.map +1 -0
  37. package/dist/ui/renderer.js +163 -0
  38. package/dist/ui/renderer.js.map +1 -0
  39. package/package.json +47 -0
  40. package/src/bin.ts +50 -0
  41. package/src/chat-session.ts +244 -0
  42. package/src/cli.ts +206 -0
  43. package/src/commands/chat.ts +34 -0
  44. package/src/commands/send.ts +95 -0
  45. package/src/commands/status.ts +32 -0
  46. package/src/config.ts +123 -0
  47. package/src/index.ts +12 -0
  48. package/src/types.d.ts +33 -0
  49. package/src/ui/renderer.ts +194 -0
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Renderer - Terminal output rendering
3
+ */
4
+
5
+ import chalk from "chalk";
6
+ import { Marked } from "marked";
7
+ import { markedTerminal } from "marked-terminal";
8
+
9
+ export interface RendererOptions {
10
+ /** Enable markdown rendering */
11
+ markdown?: boolean;
12
+
13
+ /** Enable debug output */
14
+ debug?: boolean;
15
+
16
+ /** Enable colors (default: true) */
17
+ colors?: boolean;
18
+ }
19
+
20
+ /**
21
+ * Terminal renderer with markdown support
22
+ */
23
+ export class Renderer {
24
+ private options: RendererOptions;
25
+ private marked: Marked;
26
+ private _isStreaming = false;
27
+ private streamBuffer = "";
28
+ private _isDebug: boolean;
29
+
30
+ constructor(options: RendererOptions = {}) {
31
+ this.options = options;
32
+ this._isDebug = options.debug ?? false;
33
+
34
+ // Set up marked with terminal renderer
35
+ this.marked = new Marked();
36
+ this.marked.use(
37
+ markedTerminal({
38
+ // Customize terminal rendering
39
+ code: chalk.cyan,
40
+ blockquote: chalk.gray.italic,
41
+ html: chalk.gray,
42
+ heading: chalk.bold,
43
+ firstHeading: chalk.bold.underline,
44
+ hr: chalk.gray,
45
+ listitem: chalk.reset,
46
+ table: chalk.reset,
47
+ paragraph: chalk.reset,
48
+ strong: chalk.bold,
49
+ em: chalk.italic,
50
+ codespan: chalk.cyan,
51
+ del: chalk.strikethrough,
52
+ link: chalk.blue.underline,
53
+ href: chalk.blue.underline,
54
+ }),
55
+ );
56
+ }
57
+
58
+ get isDebug(): boolean {
59
+ return this._isDebug;
60
+ }
61
+
62
+ toggleDebug(): void {
63
+ this._isDebug = !this._isDebug;
64
+ }
65
+
66
+ /**
67
+ * Render markdown text
68
+ */
69
+ markdown(text: string): string {
70
+ if (!this.options.markdown) {
71
+ return text;
72
+ }
73
+ try {
74
+ return this.marked.parse(text) as string;
75
+ } catch {
76
+ return text;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Print an info message
82
+ */
83
+ info(message: string): void {
84
+ console.log(chalk.gray(message));
85
+ }
86
+
87
+ /**
88
+ * Print an error message
89
+ */
90
+ error(message: string): void {
91
+ console.error(chalk.red(`Error: ${message}`));
92
+ }
93
+
94
+ /**
95
+ * Print a debug message
96
+ */
97
+ debug(message: string, data?: unknown): void {
98
+ if (!this._isDebug) return;
99
+ if (data !== undefined) {
100
+ console.log(chalk.dim(`[DEBUG] ${message}`), data);
101
+ } else {
102
+ console.log(chalk.dim(`[DEBUG] ${message}`));
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Start streaming output
108
+ */
109
+ streamStart(): void {
110
+ this._isStreaming = true;
111
+ this.streamBuffer = "";
112
+ process.stdout.write(chalk.green("\nAgent: "));
113
+ }
114
+
115
+ /**
116
+ * Add delta to stream
117
+ */
118
+ streamDelta(text: string): void {
119
+ if (!this._isStreaming) return;
120
+ this.streamBuffer += text;
121
+ process.stdout.write(text);
122
+ }
123
+
124
+ /**
125
+ * End streaming and render final output
126
+ */
127
+ streamEnd(): void {
128
+ if (!this._isStreaming) return;
129
+ this._isStreaming = false;
130
+
131
+ // Move to new line after stream
132
+ console.log("\n");
133
+
134
+ this.streamBuffer = "";
135
+ }
136
+
137
+ /**
138
+ * Show tool execution start
139
+ */
140
+ toolStart(name: string, args: Record<string, unknown>): void {
141
+ const argsStr =
142
+ Object.keys(args).length > 0 ? ` ${chalk.dim(JSON.stringify(args).slice(0, 50))}...` : "";
143
+ console.log(chalk.yellow(`\n[tool: ${name}]${argsStr}`));
144
+ }
145
+
146
+ /**
147
+ * Show tool execution end
148
+ */
149
+ toolEnd(name: string, _result: unknown): void {
150
+ this.debug(`Tool ${name} completed`);
151
+ }
152
+
153
+ /**
154
+ * Render a complete response (non-streaming)
155
+ */
156
+ response(text: string): void {
157
+ console.log(chalk.green("\nAgent: ") + this.markdown(text) + "\n");
158
+ }
159
+
160
+ /**
161
+ * Render user input echo
162
+ */
163
+ userInput(text: string): void {
164
+ console.log(chalk.blue("You: ") + text);
165
+ }
166
+
167
+ /**
168
+ * Print a separator line
169
+ */
170
+ separator(): void {
171
+ console.log(chalk.dim("─".repeat(50)));
172
+ }
173
+
174
+ /**
175
+ * Clear the screen
176
+ */
177
+ clear(): void {
178
+ console.clear();
179
+ }
180
+
181
+ /**
182
+ * Print JSON output
183
+ */
184
+ json(data: unknown): void {
185
+ console.log(JSON.stringify(data, null, 2));
186
+ }
187
+
188
+ /**
189
+ * Print plain text
190
+ */
191
+ plain(text: string): void {
192
+ console.log(text);
193
+ }
194
+ }