micode 0.6.0 → 0.7.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 +64 -331
- package/dist/hooks/auto-clear-ledger.d.ts +1 -1
- package/dist/index.js +840 -18
- package/dist/tools/pty/buffer.d.ts +11 -0
- package/dist/tools/pty/index.d.ts +74 -0
- package/dist/tools/pty/manager.d.ts +14 -0
- package/dist/tools/pty/tools/kill.d.ts +12 -0
- package/dist/tools/pty/tools/list.d.ts +6 -0
- package/dist/tools/pty/tools/read.d.ts +18 -0
- package/dist/tools/pty/tools/spawn.d.ts +20 -0
- package/dist/tools/pty/tools/write.d.ts +12 -0
- package/dist/tools/pty/types.d.ts +54 -0
- package/package.json +3 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SearchMatch } from "./types";
|
|
2
|
+
export declare class RingBuffer {
|
|
3
|
+
private lines;
|
|
4
|
+
private maxLines;
|
|
5
|
+
constructor(maxLines?: number);
|
|
6
|
+
append(data: string): void;
|
|
7
|
+
read(offset?: number, limit?: number): string[];
|
|
8
|
+
search(pattern: RegExp): SearchMatch[];
|
|
9
|
+
get length(): number;
|
|
10
|
+
clear(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export { PTYManager } from "./manager";
|
|
2
|
+
export { RingBuffer } from "./buffer";
|
|
3
|
+
export { createPtySpawnTool } from "./tools/spawn";
|
|
4
|
+
export { createPtyWriteTool } from "./tools/write";
|
|
5
|
+
export { createPtyReadTool } from "./tools/read";
|
|
6
|
+
export { createPtyListTool } from "./tools/list";
|
|
7
|
+
export { createPtyKillTool } from "./tools/kill";
|
|
8
|
+
export type { PTYSession, PTYSessionInfo, PTYStatus, SpawnOptions, ReadResult, SearchMatch, SearchResult, } from "./types";
|
|
9
|
+
import type { PTYManager } from "./manager";
|
|
10
|
+
export declare function createPtyTools(manager: PTYManager): {
|
|
11
|
+
pty_spawn: {
|
|
12
|
+
description: string;
|
|
13
|
+
args: {
|
|
14
|
+
command: import("zod").ZodString;
|
|
15
|
+
args: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
16
|
+
workdir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
17
|
+
env: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
|
|
18
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
19
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
20
|
+
};
|
|
21
|
+
execute(args: {
|
|
22
|
+
command: string;
|
|
23
|
+
args?: string[] | undefined;
|
|
24
|
+
workdir?: string | undefined;
|
|
25
|
+
env?: Record<string, string> | undefined;
|
|
26
|
+
title?: string | undefined;
|
|
27
|
+
description?: string | undefined;
|
|
28
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
29
|
+
};
|
|
30
|
+
pty_write: {
|
|
31
|
+
description: string;
|
|
32
|
+
args: {
|
|
33
|
+
id: import("zod").ZodString;
|
|
34
|
+
data: import("zod").ZodString;
|
|
35
|
+
};
|
|
36
|
+
execute(args: {
|
|
37
|
+
id: string;
|
|
38
|
+
data: string;
|
|
39
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
40
|
+
};
|
|
41
|
+
pty_read: {
|
|
42
|
+
description: string;
|
|
43
|
+
args: {
|
|
44
|
+
id: import("zod").ZodString;
|
|
45
|
+
offset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
46
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
47
|
+
pattern: import("zod").ZodOptional<import("zod").ZodString>;
|
|
48
|
+
ignoreCase: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
49
|
+
};
|
|
50
|
+
execute(args: {
|
|
51
|
+
id: string;
|
|
52
|
+
offset?: number | undefined;
|
|
53
|
+
limit?: number | undefined;
|
|
54
|
+
pattern?: string | undefined;
|
|
55
|
+
ignoreCase?: boolean | undefined;
|
|
56
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
57
|
+
};
|
|
58
|
+
pty_list: {
|
|
59
|
+
description: string;
|
|
60
|
+
args: {};
|
|
61
|
+
execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
62
|
+
};
|
|
63
|
+
pty_kill: {
|
|
64
|
+
description: string;
|
|
65
|
+
args: {
|
|
66
|
+
id: import("zod").ZodString;
|
|
67
|
+
cleanup: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
68
|
+
};
|
|
69
|
+
execute(args: {
|
|
70
|
+
id: string;
|
|
71
|
+
cleanup?: boolean | undefined;
|
|
72
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PTYSessionInfo, SpawnOptions, ReadResult, SearchResult } from "./types";
|
|
2
|
+
export declare class PTYManager {
|
|
3
|
+
private sessions;
|
|
4
|
+
spawn(opts: SpawnOptions): PTYSessionInfo;
|
|
5
|
+
write(id: string, data: string): boolean;
|
|
6
|
+
read(id: string, offset?: number, limit?: number): ReadResult | null;
|
|
7
|
+
search(id: string, pattern: RegExp, offset?: number, limit?: number): SearchResult | null;
|
|
8
|
+
list(): PTYSessionInfo[];
|
|
9
|
+
get(id: string): PTYSessionInfo | null;
|
|
10
|
+
kill(id: string, cleanup?: boolean): boolean;
|
|
11
|
+
cleanupBySession(parentSessionId: string): void;
|
|
12
|
+
cleanupAll(): void;
|
|
13
|
+
private toInfo;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PTYManager } from "../manager";
|
|
2
|
+
export declare function createPtyKillTool(manager: PTYManager): {
|
|
3
|
+
description: string;
|
|
4
|
+
args: {
|
|
5
|
+
id: import("zod").ZodString;
|
|
6
|
+
cleanup: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
7
|
+
};
|
|
8
|
+
execute(args: {
|
|
9
|
+
id: string;
|
|
10
|
+
cleanup?: boolean | undefined;
|
|
11
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PTYManager } from "../manager";
|
|
2
|
+
export declare function createPtyReadTool(manager: PTYManager): {
|
|
3
|
+
description: string;
|
|
4
|
+
args: {
|
|
5
|
+
id: import("zod").ZodString;
|
|
6
|
+
offset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
7
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
8
|
+
pattern: import("zod").ZodOptional<import("zod").ZodString>;
|
|
9
|
+
ignoreCase: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
10
|
+
};
|
|
11
|
+
execute(args: {
|
|
12
|
+
id: string;
|
|
13
|
+
offset?: number | undefined;
|
|
14
|
+
limit?: number | undefined;
|
|
15
|
+
pattern?: string | undefined;
|
|
16
|
+
ignoreCase?: boolean | undefined;
|
|
17
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PTYManager } from "../manager";
|
|
2
|
+
export declare function createPtySpawnTool(manager: PTYManager): {
|
|
3
|
+
description: string;
|
|
4
|
+
args: {
|
|
5
|
+
command: import("zod").ZodString;
|
|
6
|
+
args: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
7
|
+
workdir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
+
env: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
|
|
9
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
10
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
11
|
+
};
|
|
12
|
+
execute(args: {
|
|
13
|
+
command: string;
|
|
14
|
+
args?: string[] | undefined;
|
|
15
|
+
workdir?: string | undefined;
|
|
16
|
+
env?: Record<string, string> | undefined;
|
|
17
|
+
title?: string | undefined;
|
|
18
|
+
description?: string | undefined;
|
|
19
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PTYManager } from "../manager";
|
|
2
|
+
export declare function createPtyWriteTool(manager: PTYManager): {
|
|
3
|
+
description: string;
|
|
4
|
+
args: {
|
|
5
|
+
id: import("zod").ZodString;
|
|
6
|
+
data: import("zod").ZodString;
|
|
7
|
+
};
|
|
8
|
+
execute(args: {
|
|
9
|
+
id: string;
|
|
10
|
+
data: string;
|
|
11
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { RingBuffer } from "./buffer";
|
|
2
|
+
export type PTYStatus = "running" | "exited" | "killed";
|
|
3
|
+
export interface PTYSession {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
command: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
workdir: string;
|
|
9
|
+
env?: Record<string, string>;
|
|
10
|
+
status: PTYStatus;
|
|
11
|
+
exitCode?: number;
|
|
12
|
+
pid: number;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
parentSessionId: string;
|
|
15
|
+
buffer: RingBuffer;
|
|
16
|
+
process: import("bun-pty").IPty;
|
|
17
|
+
}
|
|
18
|
+
export interface PTYSessionInfo {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
command: string;
|
|
22
|
+
args: string[];
|
|
23
|
+
workdir: string;
|
|
24
|
+
status: PTYStatus;
|
|
25
|
+
exitCode?: number;
|
|
26
|
+
pid: number;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
lineCount: number;
|
|
29
|
+
}
|
|
30
|
+
export interface SpawnOptions {
|
|
31
|
+
command: string;
|
|
32
|
+
args?: string[];
|
|
33
|
+
workdir?: string;
|
|
34
|
+
env?: Record<string, string>;
|
|
35
|
+
title?: string;
|
|
36
|
+
parentSessionId: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ReadResult {
|
|
39
|
+
lines: string[];
|
|
40
|
+
totalLines: number;
|
|
41
|
+
offset: number;
|
|
42
|
+
hasMore: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface SearchMatch {
|
|
45
|
+
lineNumber: number;
|
|
46
|
+
text: string;
|
|
47
|
+
}
|
|
48
|
+
export interface SearchResult {
|
|
49
|
+
matches: SearchMatch[];
|
|
50
|
+
totalMatches: number;
|
|
51
|
+
totalLines: number;
|
|
52
|
+
offset: number;
|
|
53
|
+
hasMore: boolean;
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "micode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "OpenCode plugin with Brainstorm-Research-Plan-Implement workflow",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"url": "https://github.com/vtemian/micode/issues"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@opencode-ai/plugin": "^1.0.224"
|
|
47
|
+
"@opencode-ai/plugin": "^1.0.224",
|
|
48
|
+
"bun-pty": "^0.4.5"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@biomejs/biome": "^2.3.10",
|