opencode-orchestrator-plugin 1.0.0-beta.10 → 1.0.0-beta.11
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 +19 -58
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,73 +6,34 @@ import RevertPromptJson from "./prompts/orchestrator/revert.json" with { type: "
|
|
|
6
6
|
import SetupPromptJson from "./prompts/orchestrator/setup.json" with { type: "json" };
|
|
7
7
|
import StatusPromptJson from "./prompts/orchestrator/status.json" with { type: "json" };
|
|
8
8
|
import { detectOrchestratorConfig } from "./utils/configDetection.js";
|
|
9
|
-
import { buildIgnoreMatcher } from "./utils/ignoreMatcher.js";
|
|
10
9
|
const asPrompt = (prompt) => (typeof prompt === "string" ? prompt : "");
|
|
11
10
|
const asDescription = (description) => typeof description === "string" ? description : undefined;
|
|
12
11
|
export const MyPlugin = async ({ directory, }) => {
|
|
13
12
|
const orchestratorPath = path.join(directory, "orchestrator");
|
|
14
13
|
let fileHeirarchy = "";
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
gitignore: readIgnoreFile(gitIgnoreFile),
|
|
30
|
-
ignore: readIgnoreFile(ignoreFile),
|
|
31
|
-
geminiignore: readIgnoreFile(geminiIgnoreFile),
|
|
32
|
-
});
|
|
33
|
-
const directories = new Set();
|
|
34
|
-
const queue = [rootDir];
|
|
35
|
-
while (queue.length > 0) {
|
|
36
|
-
const current = queue.shift();
|
|
37
|
-
if (!current)
|
|
38
|
-
continue;
|
|
39
|
-
const entries = fs.readdirSync(current, { withFileTypes: true });
|
|
40
|
-
for (const entry of entries) {
|
|
41
|
-
const entryPath = path.join(current, entry.name);
|
|
42
|
-
const relativePath = path.relative(rootDir, entryPath) || ".";
|
|
43
|
-
if (entry.isDirectory()) {
|
|
44
|
-
const normalizedDir = relativePath === "." ? "" : relativePath;
|
|
45
|
-
if (!ig.shouldTraverse(normalizedDir)) {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (!ig.ignores(normalizedDir)) {
|
|
49
|
-
directories.add(relativePath || ".");
|
|
50
|
-
}
|
|
51
|
-
queue.push(entryPath);
|
|
52
|
-
}
|
|
53
|
-
else if (ig.ignores(relativePath)) {
|
|
54
|
-
continue;
|
|
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);
|
|
55
28
|
}
|
|
56
29
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let summary = "";
|
|
60
|
-
let count = 0;
|
|
61
|
-
for (const dir of sorted) {
|
|
62
|
-
if (summary.length >= maxChars || count >= maxEntries)
|
|
63
|
-
break;
|
|
64
|
-
summary += `${dir}\n`;
|
|
65
|
-
count += 1;
|
|
66
|
-
}
|
|
67
|
-
if (summary.length >= maxChars || count >= maxEntries) {
|
|
68
|
-
summary += "...\n";
|
|
69
|
-
}
|
|
70
|
-
return summary.trim();
|
|
30
|
+
});
|
|
31
|
+
return results;
|
|
71
32
|
};
|
|
72
33
|
if (fs.existsSync(orchestratorPath)) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
.map((
|
|
34
|
+
const files = getFilesRecursively(orchestratorPath);
|
|
35
|
+
fileHeirarchy = files
|
|
36
|
+
.map((f) => path.relative(directory, f))
|
|
76
37
|
.join("\n ");
|
|
77
38
|
}
|
|
78
39
|
const isOrchestratorSetup = () => {
|