opencode-conductor-plugin 1.29.0 → 1.30.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/dist/index.js +70 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,71 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
1
3
|
import ImplementPrompt from "./prompts/conductor/implement.json" with { type: "json" };
|
|
2
4
|
import NewTrackPrompt from "./prompts/conductor/newTrack.json" with { type: "json" };
|
|
3
5
|
import RevertPrompt from "./prompts/conductor/revert.json" with { type: "json" };
|
|
4
6
|
import SetupPrompt from "./prompts/conductor/setup.json" with { type: "json" };
|
|
5
7
|
import StatusPrompt from "./prompts/conductor/status.json" with { type: "json" };
|
|
6
8
|
export const MyPlugin = async ({ project, client, $, directory, worktree, }) => {
|
|
9
|
+
// List all files and folders which are in conductor subfolder (.json and .md files only)
|
|
10
|
+
const conductorPath = path.join(directory, "conductor");
|
|
11
|
+
let files = [];
|
|
12
|
+
let fileHeirarchy = "";
|
|
13
|
+
let llmFiles = "";
|
|
14
|
+
const getFilesRecursively = (dir) => {
|
|
15
|
+
let results = [];
|
|
16
|
+
if (!fs.existsSync(dir))
|
|
17
|
+
return results;
|
|
18
|
+
const list = fs.readdirSync(dir);
|
|
19
|
+
list.forEach((file) => {
|
|
20
|
+
const filePath = path.join(dir, file);
|
|
21
|
+
const stat = fs.statSync(filePath);
|
|
22
|
+
if (stat && stat.isDirectory()) {
|
|
23
|
+
results = results.concat(getFilesRecursively(filePath));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (filePath.endsWith(".json") || filePath.endsWith(".md")) {
|
|
27
|
+
results.push(filePath);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return results;
|
|
32
|
+
};
|
|
33
|
+
if (fs.existsSync(conductorPath)) {
|
|
34
|
+
files = getFilesRecursively(conductorPath);
|
|
35
|
+
fileHeirarchy = files
|
|
36
|
+
.map((f) => path.relative(directory, f))
|
|
37
|
+
.join("\n ");
|
|
38
|
+
// Concat them nicely for the LLM using <> tags
|
|
39
|
+
llmFiles = files
|
|
40
|
+
.map((f) => {
|
|
41
|
+
const content = fs.readFileSync(f, "utf-8");
|
|
42
|
+
const relPath = path.relative(directory, f);
|
|
43
|
+
return `<File path="${relPath}">\n${content}\n</File>`;
|
|
44
|
+
})
|
|
45
|
+
.join("\n\n");
|
|
46
|
+
}
|
|
47
|
+
const isConductorSetup = () => {
|
|
48
|
+
const setupStatePath = path.join(conductorPath, "setup_state.json");
|
|
49
|
+
return fs.existsSync(setupStatePath);
|
|
50
|
+
};
|
|
51
|
+
// @note read setup json file and write a utility function which will determine if setup has occured within the project yet
|
|
52
|
+
const setupOccurred = isConductorSetup();
|
|
7
53
|
return {
|
|
8
54
|
config: async (_config) => {
|
|
9
55
|
_config.command = {
|
|
10
56
|
..._config.command,
|
|
11
57
|
"conductor:implement": {
|
|
12
|
-
template: ImplementPrompt.prompt
|
|
58
|
+
template: ImplementPrompt.prompt + `
|
|
59
|
+
Environment Details:
|
|
60
|
+
- Directory: ${directory}
|
|
61
|
+
- Conductor Setup: ${setupOccurred}
|
|
62
|
+
- Current Conductor Files (Location: ${directory}/conductor)
|
|
63
|
+
File Tree:
|
|
64
|
+
${fileHeirarchy}
|
|
65
|
+
|
|
66
|
+
Files Content:
|
|
67
|
+
${llmFiles}
|
|
68
|
+
`,
|
|
13
69
|
description: ImplementPrompt.description,
|
|
14
70
|
},
|
|
15
71
|
"conductor:newTrack": {
|
|
@@ -21,11 +77,22 @@ export const MyPlugin = async ({ project, client, $, directory, worktree, }) =>
|
|
|
21
77
|
description: RevertPrompt.description,
|
|
22
78
|
},
|
|
23
79
|
"conductor:setup": {
|
|
24
|
-
template: SetupPrompt.prompt
|
|
80
|
+
template: SetupPrompt.prompt + `
|
|
81
|
+
Environment Details:
|
|
82
|
+
- Directory: ${directory}
|
|
83
|
+
- Conductor Setup: ${setupOccurred}
|
|
84
|
+
`,
|
|
25
85
|
description: SetupPrompt.description,
|
|
26
86
|
},
|
|
27
87
|
"conductor:status": {
|
|
28
|
-
template: StatusPrompt.prompt
|
|
88
|
+
template: StatusPrompt.prompt + `
|
|
89
|
+
Environment Details:
|
|
90
|
+
- Directory: ${directory}
|
|
91
|
+
- Conductor Setup: ${setupOccurred}
|
|
92
|
+
- Current Conductor Files (Location: ${directory}/conductor)
|
|
93
|
+
File Tree:
|
|
94
|
+
${fileHeirarchy}
|
|
95
|
+
`,
|
|
29
96
|
description: StatusPrompt.description,
|
|
30
97
|
},
|
|
31
98
|
};
|