mini-coder 0.5.13 → 0.6.0
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.
- package/README.md +25 -108
- package/bin/mc.ts +8 -11
- package/bun.lock +79 -269
- package/package.json +17 -22
- package/src/agent.ts +242 -915
- package/src/args.ts +289 -0
- package/src/headless.ts +43 -385
- package/src/index.ts +29 -836
- package/src/oauth.ts +117 -0
- package/src/prompt.ts +227 -276
- package/src/session.ts +57 -961
- package/src/shared.ts +117 -38
- package/src/tool-bash.ts +110 -0
- package/src/tool-edit.ts +133 -0
- package/src/tool-task.ts +114 -0
- package/src/tui-components.ts +150 -0
- package/src/tui-conversation.ts +262 -0
- package/src/tui-editor.ts +29 -0
- package/src/tui-overlay.ts +403 -0
- package/src/tui.ts +236 -0
- package/src/types.ts +160 -0
- package/tsconfig.json +17 -0
- package/BENCHMARK.md +0 -107
- package/LICENSE +0 -9
- package/PROGRESS.md +0 -4
- package/assets/icon-1-minimal.svg +0 -31
- package/assets/icon-2-dark-terminal.svg +0 -48
- package/assets/icon-3-gradient-modern.svg +0 -45
- package/assets/icon-4-filled-bold.svg +0 -54
- package/assets/icon-5-community-badge.svg +0 -63
- package/assets/mc-claude-smart.png +0 -0
- package/assets/mc-gpt-smart.png +0 -0
- package/assets/preview-0-5-0.png +0 -0
- package/assets/preview.gif +0 -0
- package/benchmark-baseline.sh +0 -15
- package/benchmark-loop.sh +0 -19
- package/skills-lock.json +0 -15
- package/src/cli.ts +0 -134
- package/src/errors.ts +0 -15
- package/src/git.ts +0 -247
- package/src/input.ts +0 -168
- package/src/mcp.ts +0 -609
- package/src/paths.ts +0 -37
- package/src/session-message.ts +0 -393
- package/src/settings.ts +0 -449
- package/src/skills.ts +0 -271
- package/src/submit.ts +0 -371
- package/src/text.ts +0 -71
- package/src/theme.ts +0 -330
- package/src/tool-common.ts +0 -93
- package/src/tool-grep.ts +0 -606
- package/src/tool-read.ts +0 -313
- package/src/tool-shell.ts +0 -1001
- package/src/tools.ts +0 -854
- package/src/ui/agent.ts +0 -317
- package/src/ui/commands.test.ts +0 -913
- package/src/ui/commands.ts +0 -834
- package/src/ui/conversation.test.ts +0 -585
- package/src/ui/conversation.ts +0 -1836
- package/src/ui/help.ts +0 -158
- package/src/ui/input.test.ts +0 -64
- package/src/ui/input.ts +0 -138
- package/src/ui/overlay.ts +0 -59
- package/src/ui/runtime.ts +0 -69
- package/src/ui/status.ts +0 -220
- package/src/ui.ts +0 -1190
- package/src/version.ts +0 -48
package/src/input.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User input parsing.
|
|
3
|
-
*
|
|
4
|
-
* Pure logic for detecting slash commands, skill references, image paths,
|
|
5
|
-
* and plain text from raw user input. No UI or IO beyond `existsSync`
|
|
6
|
-
* for image path validation.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { existsSync } from "node:fs";
|
|
12
|
-
import { extname, isAbsolute, join } from "node:path";
|
|
13
|
-
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
// Constants
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
/** All recognized slash commands. */
|
|
19
|
-
export const COMMANDS = [
|
|
20
|
-
"session",
|
|
21
|
-
"new",
|
|
22
|
-
"fork",
|
|
23
|
-
"undo",
|
|
24
|
-
"reasoning",
|
|
25
|
-
"verbose",
|
|
26
|
-
"mcp",
|
|
27
|
-
"todo",
|
|
28
|
-
"login",
|
|
29
|
-
"logout",
|
|
30
|
-
"help",
|
|
31
|
-
"model",
|
|
32
|
-
"effort",
|
|
33
|
-
] as const;
|
|
34
|
-
|
|
35
|
-
/** Slash helper that opens the interactive skill picker when submitted alone. */
|
|
36
|
-
export const SKILL_COMMAND = "skill" as const;
|
|
37
|
-
|
|
38
|
-
/** A recognized slash command name. */
|
|
39
|
-
type Command = (typeof COMMANDS)[number] | typeof SKILL_COMMAND;
|
|
40
|
-
|
|
41
|
-
const COMMAND_SET: ReadonlySet<string> = new Set(COMMANDS);
|
|
42
|
-
|
|
43
|
-
/** Image file extensions we recognize for embedding. */
|
|
44
|
-
const IMAGE_EXTENSIONS: ReadonlySet<string> = new Set([
|
|
45
|
-
".png",
|
|
46
|
-
".jpg",
|
|
47
|
-
".jpeg",
|
|
48
|
-
".gif",
|
|
49
|
-
".webp",
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
// ---------------------------------------------------------------------------
|
|
53
|
-
// Types
|
|
54
|
-
// ---------------------------------------------------------------------------
|
|
55
|
-
|
|
56
|
-
/** Result of parsing user input. */
|
|
57
|
-
type ParsedInput =
|
|
58
|
-
| { type: "command"; command: Command; args: string }
|
|
59
|
-
| { type: "skill"; skillName: string; userText: string }
|
|
60
|
-
| { type: "image"; path: string }
|
|
61
|
-
| { type: "text"; text: string };
|
|
62
|
-
|
|
63
|
-
/** Options for input parsing. */
|
|
64
|
-
interface ParseInputOpts {
|
|
65
|
-
/** Whether the current model supports image input. */
|
|
66
|
-
supportsImages?: boolean;
|
|
67
|
-
/** Working directory for resolving relative image paths. */
|
|
68
|
-
cwd?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
// Parsing
|
|
73
|
-
// ---------------------------------------------------------------------------
|
|
74
|
-
|
|
75
|
-
function isCommand(value: string): value is Command {
|
|
76
|
-
return COMMAND_SET.has(value);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function parseSlashInput(trimmed: string): ParsedInput | null {
|
|
80
|
-
if (trimmed === `/${SKILL_COMMAND}`) {
|
|
81
|
-
return {
|
|
82
|
-
type: "command",
|
|
83
|
-
command: SKILL_COMMAND,
|
|
84
|
-
args: "",
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const skillMatch = trimmed.match(/^\/skill:(\S+)(?:\s+(.*))?$/s);
|
|
89
|
-
if (skillMatch?.[1]) {
|
|
90
|
-
return {
|
|
91
|
-
type: "skill",
|
|
92
|
-
skillName: skillMatch[1],
|
|
93
|
-
userText: skillMatch[2]?.trim() ?? "",
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const commandMatch = trimmed.match(/^\/(\S+)(?:\s+(.*))?$/s);
|
|
98
|
-
const command = commandMatch?.[1];
|
|
99
|
-
if (!command || !isCommand(command)) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
type: "command",
|
|
105
|
-
command,
|
|
106
|
-
args: commandMatch[2]?.trim() ?? "",
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function resolveImagePath(input: string, cwd?: string): string {
|
|
111
|
-
if (isAbsolute(input) || !cwd) {
|
|
112
|
-
return input;
|
|
113
|
-
}
|
|
114
|
-
return join(cwd, input);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function parseImageInput(
|
|
118
|
-
trimmed: string,
|
|
119
|
-
opts?: ParseInputOpts,
|
|
120
|
-
): Extract<ParsedInput, { type: "image" }> | null {
|
|
121
|
-
if (!opts?.supportsImages) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
if (!IMAGE_EXTENSIONS.has(extname(trimmed).toLowerCase())) {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const resolvedPath = resolveImagePath(trimmed, opts.cwd);
|
|
129
|
-
if (!existsSync(resolvedPath)) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return { type: "image", path: resolvedPath };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Parse raw user input into a structured result.
|
|
138
|
-
*
|
|
139
|
-
* Priority order:
|
|
140
|
-
* 1. Slash commands (`/model`, `/help`, etc.)
|
|
141
|
-
* 2. Skill references (`/skill:name rest of message`)
|
|
142
|
-
* 3. Image paths (entire input is an existing image file)
|
|
143
|
-
* 4. Plain text
|
|
144
|
-
*
|
|
145
|
-
* @param raw - The raw input string from the user.
|
|
146
|
-
* @param opts - Optional parsing context (image support, cwd).
|
|
147
|
-
* @returns A {@link ParsedInput} describing what the input represents.
|
|
148
|
-
*/
|
|
149
|
-
export function parseInput(raw: string, opts?: ParseInputOpts): ParsedInput {
|
|
150
|
-
const trimmed = raw.trim();
|
|
151
|
-
if (trimmed.length === 0) {
|
|
152
|
-
return { type: "text", text: "" };
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (trimmed[0] === "/") {
|
|
156
|
-
const slashInput = parseSlashInput(trimmed);
|
|
157
|
-
if (slashInput) {
|
|
158
|
-
return slashInput;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const imageInput = parseImageInput(trimmed, opts);
|
|
163
|
-
if (imageInput) {
|
|
164
|
-
return imageInput;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return { type: "text", text: trimmed };
|
|
168
|
-
}
|