mini-coder 0.0.6 → 0.0.7
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/dist/mc.js +49 -35
- package/package.json +2 -1
package/dist/mc.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as c8 from "yoctocolors";
|
|
|
6
6
|
|
|
7
7
|
// src/agent/agent.ts
|
|
8
8
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
|
|
9
|
-
import { join as
|
|
9
|
+
import { join as join15 } from "path";
|
|
10
10
|
import * as c7 from "yoctocolors";
|
|
11
11
|
|
|
12
12
|
// src/cli/agents.ts
|
|
@@ -645,7 +645,7 @@ function renderChunk(text, inFence) {
|
|
|
645
645
|
|
|
646
646
|
// src/cli/output.ts
|
|
647
647
|
var HOME = homedir3();
|
|
648
|
-
var PACKAGE_VERSION = "0.
|
|
648
|
+
var PACKAGE_VERSION = "0.0.6";
|
|
649
649
|
function tildePath(p) {
|
|
650
650
|
return p.startsWith(HOME) ? `~${p.slice(HOME.length)}` : p;
|
|
651
651
|
}
|
|
@@ -2766,8 +2766,22 @@ var createTool = {
|
|
|
2766
2766
|
};
|
|
2767
2767
|
|
|
2768
2768
|
// src/tools/glob.ts
|
|
2769
|
-
import { join as
|
|
2769
|
+
import { join as join9, relative as relative3 } from "path";
|
|
2770
2770
|
import { z as z3 } from "zod";
|
|
2771
|
+
|
|
2772
|
+
// src/tools/ignore.ts
|
|
2773
|
+
import { join as join8 } from "path";
|
|
2774
|
+
import ignore from "ignore";
|
|
2775
|
+
async function loadGitignore(cwd) {
|
|
2776
|
+
try {
|
|
2777
|
+
const gitignore = await Bun.file(join8(cwd, ".gitignore")).text();
|
|
2778
|
+
return ignore().add(gitignore);
|
|
2779
|
+
} catch {
|
|
2780
|
+
return null;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
// src/tools/glob.ts
|
|
2771
2785
|
var GlobSchema = z3.object({
|
|
2772
2786
|
pattern: z3.string().describe("Glob pattern to match files against, e.g. '**/*.ts'"),
|
|
2773
2787
|
ignore: z3.array(z3.string()).optional().describe("Glob patterns to exclude")
|
|
@@ -2779,26 +2793,21 @@ var globTool = {
|
|
|
2779
2793
|
schema: GlobSchema,
|
|
2780
2794
|
execute: async (input) => {
|
|
2781
2795
|
const cwd = input.cwd ?? process.cwd();
|
|
2782
|
-
const defaultIgnore = [
|
|
2783
|
-
"node_modules/**",
|
|
2784
|
-
".git/**",
|
|
2785
|
-
"dist/**",
|
|
2786
|
-
"*.db",
|
|
2787
|
-
"*.db-shm",
|
|
2788
|
-
"*.db-wal"
|
|
2789
|
-
];
|
|
2796
|
+
const defaultIgnore = [".git/**", "node_modules/**"];
|
|
2790
2797
|
const ignorePatterns = [...defaultIgnore, ...input.ignore ?? []];
|
|
2798
|
+
const ignoreGlobs = ignorePatterns.map((pat) => new Bun.Glob(pat));
|
|
2799
|
+
const ig = await loadGitignore(cwd);
|
|
2791
2800
|
const glob = new Bun.Glob(input.pattern);
|
|
2792
2801
|
const matches = [];
|
|
2793
|
-
for await (const file of glob.scan({ cwd, onlyFiles: true })) {
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2802
|
+
for await (const file of glob.scan({ cwd, onlyFiles: true, dot: true })) {
|
|
2803
|
+
if (ig?.ignores(file))
|
|
2804
|
+
continue;
|
|
2805
|
+
const firstSegment = file.split("/")[0] ?? "";
|
|
2806
|
+
const ignored = ignoreGlobs.some((g) => g.match(file) || g.match(firstSegment));
|
|
2798
2807
|
if (ignored)
|
|
2799
2808
|
continue;
|
|
2800
2809
|
try {
|
|
2801
|
-
const fullPath =
|
|
2810
|
+
const fullPath = join9(cwd, file);
|
|
2802
2811
|
const stat = await Bun.file(fullPath).stat?.() ?? null;
|
|
2803
2812
|
matches.push({ path: file, mtime: stat?.mtime?.getTime() ?? 0 });
|
|
2804
2813
|
} catch {
|
|
@@ -2811,13 +2820,13 @@ var globTool = {
|
|
|
2811
2820
|
if (truncated)
|
|
2812
2821
|
matches.pop();
|
|
2813
2822
|
matches.sort((a, b) => b.mtime - a.mtime);
|
|
2814
|
-
const files = matches.map((m) => relative3(cwd,
|
|
2823
|
+
const files = matches.map((m) => relative3(cwd, join9(cwd, m.path)));
|
|
2815
2824
|
return { files, count: files.length, truncated };
|
|
2816
2825
|
}
|
|
2817
2826
|
};
|
|
2818
2827
|
|
|
2819
2828
|
// src/tools/grep.ts
|
|
2820
|
-
import { join as
|
|
2829
|
+
import { join as join10 } from "path";
|
|
2821
2830
|
import { z as z4 } from "zod";
|
|
2822
2831
|
|
|
2823
2832
|
// src/tools/hashline.ts
|
|
@@ -2895,15 +2904,20 @@ var grepTool = {
|
|
|
2895
2904
|
const ignoreGlob = DEFAULT_IGNORE.map((p) => new Bun.Glob(p));
|
|
2896
2905
|
const allMatches = [];
|
|
2897
2906
|
let truncated = false;
|
|
2907
|
+
const ig = await loadGitignore(cwd);
|
|
2898
2908
|
outer:
|
|
2899
2909
|
for await (const relPath of fileGlob.scan({
|
|
2900
2910
|
cwd,
|
|
2901
|
-
onlyFiles: true
|
|
2911
|
+
onlyFiles: true,
|
|
2912
|
+
dot: true
|
|
2902
2913
|
})) {
|
|
2903
|
-
if (
|
|
2914
|
+
if (ig?.ignores(relPath))
|
|
2915
|
+
continue;
|
|
2916
|
+
const firstSegment = relPath.split("/")[0] ?? "";
|
|
2917
|
+
if (ignoreGlob.some((g) => g.match(relPath) || g.match(firstSegment))) {
|
|
2904
2918
|
continue;
|
|
2905
2919
|
}
|
|
2906
|
-
const fullPath =
|
|
2920
|
+
const fullPath = join10(cwd, relPath);
|
|
2907
2921
|
let text;
|
|
2908
2922
|
try {
|
|
2909
2923
|
text = await Bun.file(fullPath).text();
|
|
@@ -2955,7 +2969,7 @@ var grepTool = {
|
|
|
2955
2969
|
// src/tools/hooks.ts
|
|
2956
2970
|
import { constants, accessSync } from "fs";
|
|
2957
2971
|
import { homedir as homedir6 } from "os";
|
|
2958
|
-
import { join as
|
|
2972
|
+
import { join as join11 } from "path";
|
|
2959
2973
|
function isExecutable(filePath) {
|
|
2960
2974
|
try {
|
|
2961
2975
|
accessSync(filePath, constants.X_OK);
|
|
@@ -2967,8 +2981,8 @@ function isExecutable(filePath) {
|
|
|
2967
2981
|
function findHook(toolName, cwd) {
|
|
2968
2982
|
const scriptName = `post-${toolName}`;
|
|
2969
2983
|
const candidates = [
|
|
2970
|
-
|
|
2971
|
-
|
|
2984
|
+
join11(cwd, ".agents", "hooks", scriptName),
|
|
2985
|
+
join11(homedir6(), ".agents", "hooks", scriptName)
|
|
2972
2986
|
];
|
|
2973
2987
|
for (const p of candidates) {
|
|
2974
2988
|
if (isExecutable(p))
|
|
@@ -3057,7 +3071,7 @@ function hookEnvForRead(input, cwd) {
|
|
|
3057
3071
|
}
|
|
3058
3072
|
|
|
3059
3073
|
// src/tools/insert.ts
|
|
3060
|
-
import { join as
|
|
3074
|
+
import { join as join12, relative as relative4 } from "path";
|
|
3061
3075
|
import { z as z5 } from "zod";
|
|
3062
3076
|
var InsertSchema = z5.object({
|
|
3063
3077
|
path: z5.string().describe("File path to edit (absolute or relative to cwd)"),
|
|
@@ -3072,7 +3086,7 @@ var insertTool = {
|
|
|
3072
3086
|
schema: InsertSchema,
|
|
3073
3087
|
execute: async (input) => {
|
|
3074
3088
|
const cwd = input.cwd ?? process.cwd();
|
|
3075
|
-
const filePath = input.path.startsWith("/") ? input.path :
|
|
3089
|
+
const filePath = input.path.startsWith("/") ? input.path : join12(cwd, input.path);
|
|
3076
3090
|
const relPath = relative4(cwd, filePath);
|
|
3077
3091
|
const file = Bun.file(filePath);
|
|
3078
3092
|
if (!await file.exists()) {
|
|
@@ -3117,7 +3131,7 @@ function parseAnchor(value) {
|
|
|
3117
3131
|
}
|
|
3118
3132
|
|
|
3119
3133
|
// src/tools/read.ts
|
|
3120
|
-
import { join as
|
|
3134
|
+
import { join as join13, relative as relative5 } from "path";
|
|
3121
3135
|
import { z as z6 } from "zod";
|
|
3122
3136
|
var ReadSchema = z6.object({
|
|
3123
3137
|
path: z6.string().describe("File path to read (absolute or relative to cwd)"),
|
|
@@ -3132,7 +3146,7 @@ var readTool = {
|
|
|
3132
3146
|
schema: ReadSchema,
|
|
3133
3147
|
execute: async (input) => {
|
|
3134
3148
|
const cwd = input.cwd ?? process.cwd();
|
|
3135
|
-
const filePath = input.path.startsWith("/") ? input.path :
|
|
3149
|
+
const filePath = input.path.startsWith("/") ? input.path : join13(cwd, input.path);
|
|
3136
3150
|
const file = Bun.file(filePath);
|
|
3137
3151
|
const exists = await file.exists();
|
|
3138
3152
|
if (!exists) {
|
|
@@ -3165,7 +3179,7 @@ var readTool = {
|
|
|
3165
3179
|
};
|
|
3166
3180
|
|
|
3167
3181
|
// src/tools/replace.ts
|
|
3168
|
-
import { join as
|
|
3182
|
+
import { join as join14, relative as relative6 } from "path";
|
|
3169
3183
|
import { z as z7 } from "zod";
|
|
3170
3184
|
var ReplaceSchema = z7.object({
|
|
3171
3185
|
path: z7.string().describe("File path to edit (absolute or relative to cwd)"),
|
|
@@ -3180,7 +3194,7 @@ var replaceTool = {
|
|
|
3180
3194
|
schema: ReplaceSchema,
|
|
3181
3195
|
execute: async (input) => {
|
|
3182
3196
|
const cwd = input.cwd ?? process.cwd();
|
|
3183
|
-
const filePath = input.path.startsWith("/") ? input.path :
|
|
3197
|
+
const filePath = input.path.startsWith("/") ? input.path : join14(cwd, input.path);
|
|
3184
3198
|
const relPath = relative6(cwd, filePath);
|
|
3185
3199
|
const file = Bun.file(filePath);
|
|
3186
3200
|
if (!await file.exists()) {
|
|
@@ -3426,9 +3440,9 @@ async function getGitBranch(cwd) {
|
|
|
3426
3440
|
}
|
|
3427
3441
|
function loadContextFile(cwd) {
|
|
3428
3442
|
const candidates = [
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3443
|
+
join15(cwd, "AGENTS.md"),
|
|
3444
|
+
join15(cwd, "CLAUDE.md"),
|
|
3445
|
+
join15(getConfigDir(), "AGENTS.md")
|
|
3432
3446
|
];
|
|
3433
3447
|
for (const p of candidates) {
|
|
3434
3448
|
if (existsSync6(p)) {
|
|
@@ -3903,7 +3917,7 @@ ${skill.content}
|
|
|
3903
3917
|
result = result.slice(0, match.index) + replacement + result.slice((match.index ?? 0) + match[0].length);
|
|
3904
3918
|
continue;
|
|
3905
3919
|
}
|
|
3906
|
-
const filePath = ref.startsWith("/") ? ref :
|
|
3920
|
+
const filePath = ref.startsWith("/") ? ref : join15(cwd, ref);
|
|
3907
3921
|
if (isImageFilename(ref)) {
|
|
3908
3922
|
const attachment = await loadImageFile(filePath);
|
|
3909
3923
|
if (attachment) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mini-coder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "A small, fast CLI coding agent",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@ai-sdk/openai-compatible": "^2.0.30",
|
|
23
23
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
24
24
|
"ai": "^6.0.94",
|
|
25
|
+
"ignore": "^7.0.5",
|
|
25
26
|
"ollama-ai-provider": "^1.2.0",
|
|
26
27
|
"yoctocolors": "^2.1.1",
|
|
27
28
|
"zod": "^4.3.6"
|