opencode-rag-plugin 2.11.2 → 2.12.1
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 +386 -222
- package/dist/cli/commands/backend-detect.d.ts +1 -1
- package/dist/cli/commands/backend-detect.js +1 -1
- package/dist/cli/commands/index.d.ts +0 -1
- package/dist/cli/commands/index.js +0 -1
- package/dist/cli/commands/setup.js +344 -85
- package/dist/cli/commands/{init-helpers.d.ts → workspace-helpers.d.ts} +10 -7
- package/dist/cli/commands/{init-helpers.js → workspace-helpers.js} +15 -62
- package/dist/cli/index.js +1 -2
- package/dist/cli/ollama.d.ts +12 -0
- package/dist/cli/ollama.js +26 -0
- package/dist/cli/prompt.d.ts +121 -0
- package/dist/cli/prompt.js +309 -0
- package/dist/cli/types.d.ts +31 -19
- package/dist/cli/wizard/apply.d.ts +60 -0
- package/dist/cli/wizard/apply.js +243 -0
- package/dist/cli/wizard/flow.d.ts +121 -0
- package/dist/cli/wizard/flow.js +904 -0
- package/dist/cli/wizard/model-catalog.d.ts +80 -0
- package/dist/cli/wizard/model-catalog.js +414 -0
- package/dist/cli/wizard/presets.d.ts +55 -0
- package/dist/cli/wizard/presets.js +70 -0
- package/dist/cli/wizard/repair.d.ts +54 -0
- package/dist/cli/wizard/repair.js +266 -0
- package/dist/cli/wizard/types.d.ts +99 -0
- package/dist/cli/wizard/types.js +5 -0
- package/dist/cli/workspace.d.ts +57 -0
- package/dist/cli/workspace.js +407 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/core/auto-scaffold.d.ts +21 -0
- package/dist/core/auto-scaffold.js +80 -0
- package/dist/core/config.d.ts +13 -2
- package/dist/core/config.js +13 -3
- package/dist/core/global-plugin.d.ts +48 -0
- package/dist/core/global-plugin.js +114 -0
- package/dist/core/provider-defaults.d.ts +2 -0
- package/dist/core/provider-defaults.js +4 -0
- package/dist/core/setup-runtime.js +40 -26
- package/dist/embedder/health.js +44 -2
- package/dist/eval/fast-index.js +1 -1
- package/dist/opencode/system-guidance.d.ts +1 -1
- package/dist/opencode/system-guidance.js +1 -1
- package/dist/tui.d.ts +11 -0
- package/dist/tui.js +12 -1
- package/dist/v2/v2-adapter.js +9 -0
- package/package.json +3 -2
- package/scripts/postinstall-setup.js +16 -0
- package/dist/cli/commands/init.d.ts +0 -51
- package/dist/cli/commands/init.js +0 -508
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Workspace scaffolding shared by `opencode-rag setup`.
|
|
3
|
+
*
|
|
4
|
+
* Creates/updates the `.opencode/` tree, plugin entrypoints (workspace mode),
|
|
5
|
+
* skills, `AGENTS.md` guidance and the workspace `package.json`. Configuration
|
|
6
|
+
* is written separately (see `src/cli/wizard/apply.ts`) so the wizard can
|
|
7
|
+
* decide what goes into the workspace file before `AGENTS.md` is rendered from
|
|
8
|
+
* the effective `decision`/`memory` flags.
|
|
9
|
+
*
|
|
10
|
+
* By default the plugin is installed ONCE in OpenCode's global plugin
|
|
11
|
+
* directory (`~/.config/opencode/plugins/opencode-rag/`), so a workspace only
|
|
12
|
+
* receives the config, skills, `AGENTS.md` and the `.gitignore` that protects
|
|
13
|
+
* its local LanceDB store. `workspacePlugin: true` restores the legacy
|
|
14
|
+
* per-repository plugin layout.
|
|
15
|
+
*/
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, rmSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
18
|
+
import { loadConfig, loadWorkspaceConfig, configuredSections, findConfigFile, projectConfigPath } from "../core/config.js";
|
|
19
|
+
import { resolveApiKey } from "../core/resolve-api-key.js";
|
|
20
|
+
import { checkProviderHealth, pullOllamaModels } from "../embedder/health.js";
|
|
21
|
+
import { c } from "./format.js";
|
|
22
|
+
import { getPackageMetadata, readJsonObject, writeJsonFile } from "./helpers.js";
|
|
23
|
+
import { isOllamaConnectionError, ollamaInstallHint } from "./ollama.js";
|
|
24
|
+
import { buildLegacyTuiConfig, buildOpencodeConfig, buildWorkspacePackageJson, generateDecisionSkillFile, generateLegacyWorkspacePluginFile, generateLegacyWorkspaceTuiPluginFile, generateSkillFile, generateWorkspacePluginFile, generateWorkspaceTuiPluginFile, installPluginFromGlobal, mergeAgentsMdContent, mergeGitignoreContent, LEGACY_PLUGIN_ENTRY, LEGACY_TUI_CONFIG, LEGACY_TUI_ENTRY, WORKSPACE_PLUGIN_DIR, WORKSPACE_PLUGIN_ENTRY, WORKSPACE_TUI_ENTRY, } from "./commands/workspace-helpers.js";
|
|
25
|
+
/**
|
|
26
|
+
* Best-effort check whether `cwd` looks like a project root (git repo or
|
|
27
|
+
* common project manifest files). `setup` uses this to warn before creating
|
|
28
|
+
* `.opencode/` in an unrelated directory.
|
|
29
|
+
*/
|
|
30
|
+
export function isLikelyProjectRoot(cwd) {
|
|
31
|
+
if (existsSync(path.join(cwd, ".git"))) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
const markers = [
|
|
35
|
+
"package.json",
|
|
36
|
+
"AGENTS.md",
|
|
37
|
+
"README.md",
|
|
38
|
+
"pyproject.toml",
|
|
39
|
+
"Cargo.toml",
|
|
40
|
+
"go.mod",
|
|
41
|
+
"opencode-rag.json",
|
|
42
|
+
".opencode/opencode-rag.json",
|
|
43
|
+
];
|
|
44
|
+
return markers.some((marker) => existsSync(path.join(cwd, marker)));
|
|
45
|
+
}
|
|
46
|
+
/** Remove a file only when its content matches exactly what setup generates. */
|
|
47
|
+
function removeGeneratedFile(filePath, expected, label) {
|
|
48
|
+
if (!existsSync(filePath))
|
|
49
|
+
return false;
|
|
50
|
+
try {
|
|
51
|
+
if (readFileSync(filePath, "utf-8") !== expected) {
|
|
52
|
+
console.log(` ${c.warn("Kept:")} ${label} (modified locally)`);
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
unlinkSync(filePath);
|
|
56
|
+
console.log(` ${c.updated("Removed:")} ${label} (superseded by the global plugin)`);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** Remove a junction created by a previous workspace-mode install. */
|
|
64
|
+
function removeJunction(linkPath, label) {
|
|
65
|
+
if (!existsSync(linkPath))
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
if (!lstatSync(linkPath).isSymbolicLink())
|
|
69
|
+
return;
|
|
70
|
+
rmSync(linkPath, { recursive: true, force: true });
|
|
71
|
+
console.log(` ${c.updated("Removed:")} ${label} (global plugin mode)`);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// Leave it; a stale link is harmless next to the global plugin.
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Remove a directory when it is empty. */
|
|
78
|
+
function removeIfEmpty(dirPath) {
|
|
79
|
+
try {
|
|
80
|
+
if (existsSync(dirPath) && readdirSync(dirPath).length === 0)
|
|
81
|
+
rmSync(dirPath, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// ignore
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create or refresh the workspace files.
|
|
89
|
+
*
|
|
90
|
+
* Idempotent: unchanged generated files are reported as existing and not
|
|
91
|
+
* rewritten. The workspace config is never modified here.
|
|
92
|
+
*/
|
|
93
|
+
export async function scaffoldWorkspace(options = {}) {
|
|
94
|
+
const cwd = process.cwd();
|
|
95
|
+
const packageMetadata = getPackageMetadata();
|
|
96
|
+
const configPath = options.configPath ?? findConfigFile(cwd) ?? projectConfigPath(cwd);
|
|
97
|
+
const workspacePlugin = options.workspacePlugin ?? false;
|
|
98
|
+
const opencodeDir = path.join(cwd, ".opencode");
|
|
99
|
+
const gitignorePath = path.join(opencodeDir, ".gitignore");
|
|
100
|
+
const opencodeConfigPath = path.join(opencodeDir, "opencode.json");
|
|
101
|
+
const pluginsDir = path.join(opencodeDir, "plugins");
|
|
102
|
+
const workspacePluginDir = path.join(pluginsDir, WORKSPACE_PLUGIN_DIR);
|
|
103
|
+
const pluginEntryPath = path.join(workspacePluginDir, "index.js");
|
|
104
|
+
const tuiPluginEntryPath = path.join(workspacePluginDir, "tui.js");
|
|
105
|
+
const legacyPluginEntryPath = path.join(pluginsDir, "rag-plugin.js");
|
|
106
|
+
const legacyTuiPluginEntryPath = path.join(pluginsDir, "rag-tui.js");
|
|
107
|
+
const legacyTuiConfigPath = path.join(opencodeDir, "tui.json");
|
|
108
|
+
const opencodePackagePath = path.join(opencodeDir, "package.json");
|
|
109
|
+
const runtimePluginLink = path.join(opencodeDir, "node_modules", packageMetadata.name);
|
|
110
|
+
const runtimeSdkLink = path.join(opencodeDir, "node_modules", "@opencode-ai", "plugin");
|
|
111
|
+
console.log(`\n${c.heading("Workspace files")}\n`);
|
|
112
|
+
if (!existsSync(opencodeDir)) {
|
|
113
|
+
mkdirSync(opencodeDir, { recursive: true });
|
|
114
|
+
console.log(` ${c.created("Created:")} .opencode/`);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
console.log(` ${c.exists("Exists:")} .opencode/`);
|
|
118
|
+
}
|
|
119
|
+
// The wiki is user-authored; setup never touches it.
|
|
120
|
+
const wikiDir = path.join(opencodeDir, "wiki");
|
|
121
|
+
if (existsSync(wikiDir)) {
|
|
122
|
+
console.log(` ${c.exists("Preserved:")} .opencode/wiki/ (never modified by setup)`);
|
|
123
|
+
}
|
|
124
|
+
const gitignoreExists = existsSync(gitignorePath);
|
|
125
|
+
const nextGitignoreContent = mergeGitignoreContent(gitignoreExists ? readFileSync(gitignorePath, "utf-8") : undefined);
|
|
126
|
+
if (!gitignoreExists || options.force || readFileSync(gitignorePath, "utf-8") !== nextGitignoreContent) {
|
|
127
|
+
writeFileSync(gitignorePath, nextGitignoreContent, "utf-8");
|
|
128
|
+
console.log(` ${gitignoreExists ? c.updated("Updated:") : c.created("Created:")} .opencode/.gitignore`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
console.log(` ${c.exists("Exists:")} .opencode/.gitignore`);
|
|
132
|
+
}
|
|
133
|
+
if (workspacePlugin) {
|
|
134
|
+
// ── Legacy per-repository plugin layout ──────────────────────────────
|
|
135
|
+
if (!existsSync(pluginsDir)) {
|
|
136
|
+
mkdirSync(pluginsDir, { recursive: true });
|
|
137
|
+
console.log(` ${c.created("Created:")} .opencode/plugins/`);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
console.log(` ${c.exists("Exists:")} .opencode/plugins/`);
|
|
141
|
+
}
|
|
142
|
+
const opencodeConfigExists = existsSync(opencodeConfigPath);
|
|
143
|
+
const nextOpencodeConfig = buildOpencodeConfig(readJsonObject(opencodeConfigPath));
|
|
144
|
+
if (!opencodeConfigExists || options.force) {
|
|
145
|
+
writeJsonFile(opencodeConfigPath, nextOpencodeConfig);
|
|
146
|
+
console.log(` ${opencodeConfigExists ? c.updated("Updated:") : c.created("Created:")} .opencode/opencode.json`);
|
|
147
|
+
}
|
|
148
|
+
else if (JSON.stringify(readJsonObject(opencodeConfigPath)) !== JSON.stringify(nextOpencodeConfig)) {
|
|
149
|
+
writeJsonFile(opencodeConfigPath, nextOpencodeConfig);
|
|
150
|
+
console.log(` ${c.updated("Updated:")} .opencode/opencode.json`);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
console.log(` ${c.exists("Exists:")} .opencode/opencode.json`);
|
|
154
|
+
}
|
|
155
|
+
// OpenCode 2 discovers plugin *directories* under `.opencode/plugins/`:
|
|
156
|
+
// `index.js` is the server entrypoint and `tui.js` beside it is the CLI
|
|
157
|
+
// entrypoint. Flat `.js` files only reach the server role.
|
|
158
|
+
if (!existsSync(workspacePluginDir)) {
|
|
159
|
+
mkdirSync(workspacePluginDir, { recursive: true });
|
|
160
|
+
console.log(` ${c.created("Created:")} .opencode/plugins/${WORKSPACE_PLUGIN_DIR}/`);
|
|
161
|
+
}
|
|
162
|
+
const pluginEntryExists = existsSync(pluginEntryPath);
|
|
163
|
+
const pluginEntryContent = generateWorkspacePluginFile(packageMetadata.name);
|
|
164
|
+
if (!pluginEntryExists || options.force) {
|
|
165
|
+
writeFileSync(pluginEntryPath, pluginEntryContent, "utf-8");
|
|
166
|
+
console.log(` ${pluginEntryExists ? c.updated("Updated:") : c.created("Created:")} ${WORKSPACE_PLUGIN_ENTRY}`);
|
|
167
|
+
}
|
|
168
|
+
else if (readFileSync(pluginEntryPath, "utf-8") !== pluginEntryContent) {
|
|
169
|
+
writeFileSync(pluginEntryPath, pluginEntryContent, "utf-8");
|
|
170
|
+
console.log(` ${c.updated("Updated:")} ${WORKSPACE_PLUGIN_ENTRY}`);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
console.log(` ${c.exists("Exists:")} ${WORKSPACE_PLUGIN_ENTRY}`);
|
|
174
|
+
}
|
|
175
|
+
const tuiPluginEntryExists = existsSync(tuiPluginEntryPath);
|
|
176
|
+
const tuiPluginEntryContent = generateWorkspaceTuiPluginFile(packageMetadata.name);
|
|
177
|
+
if (!tuiPluginEntryExists || options.force) {
|
|
178
|
+
writeFileSync(tuiPluginEntryPath, tuiPluginEntryContent, "utf-8");
|
|
179
|
+
console.log(` ${tuiPluginEntryExists ? c.updated("Updated:") : c.created("Created:")} ${WORKSPACE_TUI_ENTRY}`);
|
|
180
|
+
}
|
|
181
|
+
else if (readFileSync(tuiPluginEntryPath, "utf-8") !== tuiPluginEntryContent) {
|
|
182
|
+
writeFileSync(tuiPluginEntryPath, tuiPluginEntryContent, "utf-8");
|
|
183
|
+
console.log(` ${c.updated("Updated:")} ${WORKSPACE_TUI_ENTRY}`);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
console.log(` ${c.exists("Exists:")} ${WORKSPACE_TUI_ENTRY}`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// ── Global plugin layout (default) ────────────────────────────────────
|
|
191
|
+
// Remove the entries an older workspace-mode setup generated. Only exact
|
|
192
|
+
// matches are removed; hand-written files are kept.
|
|
193
|
+
removeGeneratedFile(pluginEntryPath, generateWorkspacePluginFile(packageMetadata.name), WORKSPACE_PLUGIN_ENTRY);
|
|
194
|
+
removeGeneratedFile(tuiPluginEntryPath, generateWorkspaceTuiPluginFile(packageMetadata.name), WORKSPACE_TUI_ENTRY);
|
|
195
|
+
removeIfEmpty(workspacePluginDir);
|
|
196
|
+
removeIfEmpty(pluginsDir);
|
|
197
|
+
removeJunction(runtimePluginLink, `.opencode/node_modules/${packageMetadata.name}`);
|
|
198
|
+
removeJunction(runtimeSdkLink, ".opencode/node_modules/@opencode-ai/plugin");
|
|
199
|
+
removeIfEmpty(path.join(opencodeDir, "node_modules", "@opencode-ai"));
|
|
200
|
+
removeIfEmpty(path.join(opencodeDir, "node_modules"));
|
|
201
|
+
console.log(` ${c.success("Plugin:")} global (~/.config/opencode/plugins/opencode-rag/)`);
|
|
202
|
+
}
|
|
203
|
+
// Remove only the V1-era flat entries that an older `init` wrote verbatim;
|
|
204
|
+
// modified files are kept (they are no longer loaded by OpenCode 2).
|
|
205
|
+
const legacyEntries = [
|
|
206
|
+
[legacyPluginEntryPath, generateLegacyWorkspacePluginFile(packageMetadata.name), LEGACY_PLUGIN_ENTRY],
|
|
207
|
+
[legacyTuiPluginEntryPath, generateLegacyWorkspaceTuiPluginFile(packageMetadata.name), LEGACY_TUI_ENTRY],
|
|
208
|
+
];
|
|
209
|
+
for (const [legacyPath, legacyContent, legacyRel] of legacyEntries) {
|
|
210
|
+
if (!existsSync(legacyPath))
|
|
211
|
+
continue;
|
|
212
|
+
if (readFileSync(legacyPath, "utf-8") === legacyContent) {
|
|
213
|
+
unlinkSync(legacyPath);
|
|
214
|
+
console.log(` ${c.updated("Removed:")} ${legacyRel} (superseded by ${WORKSPACE_PLUGIN_DIR}/)`);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
console.log(` ${c.warn("Kept:")} ${legacyRel} (modified locally — no longer loaded by OpenCode 2)`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (existsSync(legacyTuiConfigPath)) {
|
|
221
|
+
const sameLegacyConfig = JSON.stringify(readJsonObject(legacyTuiConfigPath)) === JSON.stringify(buildLegacyTuiConfig());
|
|
222
|
+
if (sameLegacyConfig) {
|
|
223
|
+
unlinkSync(legacyTuiConfigPath);
|
|
224
|
+
console.log(` ${c.updated("Removed:")} ${LEGACY_TUI_CONFIG} (V1 config — OpenCode 2 discovers CLI plugins)`);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
console.log(` ${c.warn("Kept:")} ${LEGACY_TUI_CONFIG} (V1 config — ignored by OpenCode 2)`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const skillsDir = path.join(opencodeDir, "skills");
|
|
231
|
+
const skillDir = path.join(skillsDir, "opencode-rag");
|
|
232
|
+
const skillPath = path.join(skillDir, "SKILL.md");
|
|
233
|
+
if (!existsSync(skillDir)) {
|
|
234
|
+
mkdirSync(skillDir, { recursive: true });
|
|
235
|
+
console.log(` ${c.created("Created:")} .opencode/skills/opencode-rag/`);
|
|
236
|
+
}
|
|
237
|
+
const skillContent = generateSkillFile();
|
|
238
|
+
const skillExists = existsSync(skillPath);
|
|
239
|
+
if (!skillExists || options.force) {
|
|
240
|
+
writeFileSync(skillPath, skillContent, "utf-8");
|
|
241
|
+
console.log(` ${skillExists ? c.updated("Updated:") : c.created("Created:")} .opencode/skills/opencode-rag/SKILL.md`);
|
|
242
|
+
}
|
|
243
|
+
else if (readFileSync(skillPath, "utf-8") !== skillContent) {
|
|
244
|
+
writeFileSync(skillPath, skillContent, "utf-8");
|
|
245
|
+
console.log(` ${c.updated("Updated:")} .opencode/skills/opencode-rag/SKILL.md`);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
console.log(` ${c.exists("Exists:")} .opencode/skills/opencode-rag/SKILL.md`);
|
|
249
|
+
}
|
|
250
|
+
const decisionSkillDir = path.join(skillsDir, "make-decision");
|
|
251
|
+
const decisionSkillPath = path.join(decisionSkillDir, "SKILL.md");
|
|
252
|
+
if (!existsSync(decisionSkillDir)) {
|
|
253
|
+
mkdirSync(decisionSkillDir, { recursive: true });
|
|
254
|
+
console.log(` ${c.created("Created:")} .opencode/skills/make-decision/`);
|
|
255
|
+
}
|
|
256
|
+
const decisionSkillContent = generateDecisionSkillFile();
|
|
257
|
+
const decisionSkillExists = existsSync(decisionSkillPath);
|
|
258
|
+
if (!decisionSkillExists || options.force) {
|
|
259
|
+
writeFileSync(decisionSkillPath, decisionSkillContent, "utf-8");
|
|
260
|
+
console.log(` ${decisionSkillExists ? c.updated("Updated:") : c.created("Created:")} .opencode/skills/make-decision/SKILL.md`);
|
|
261
|
+
}
|
|
262
|
+
else if (readFileSync(decisionSkillPath, "utf-8") !== decisionSkillContent) {
|
|
263
|
+
writeFileSync(decisionSkillPath, decisionSkillContent, "utf-8");
|
|
264
|
+
console.log(` ${c.updated("Updated:")} .opencode/skills/make-decision/SKILL.md`);
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
console.log(` ${c.exists("Exists:")} .opencode/skills/make-decision/SKILL.md`);
|
|
268
|
+
}
|
|
269
|
+
const agentsMdPath = path.join(cwd, "AGENTS.md");
|
|
270
|
+
const agentsMdExists = existsSync(agentsMdPath);
|
|
271
|
+
let promptEnforcement = true;
|
|
272
|
+
let decisionEnabled = false;
|
|
273
|
+
let routeBeforeAsking = false;
|
|
274
|
+
try {
|
|
275
|
+
if (existsSync(configPath)) {
|
|
276
|
+
const existingCfg = loadConfig(configPath, false);
|
|
277
|
+
promptEnforcement = existingCfg.memory?.promptEnforcement ?? true;
|
|
278
|
+
decisionEnabled = existingCfg.decision?.enabled ?? false;
|
|
279
|
+
routeBeforeAsking = existingCfg.decision?.routeBeforeAsking ?? false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
// Malformed or missing config — use defaults.
|
|
284
|
+
}
|
|
285
|
+
const nextAgentsMd = mergeAgentsMdContent(agentsMdExists ? readFileSync(agentsMdPath, "utf-8") : undefined, { promptEnforcement, decisionEnabled, routeBeforeAsking });
|
|
286
|
+
if (!agentsMdExists || options.force) {
|
|
287
|
+
writeFileSync(agentsMdPath, nextAgentsMd, "utf-8");
|
|
288
|
+
console.log(` ${agentsMdExists ? c.updated("Updated:") : c.created("Created:")} AGENTS.md`);
|
|
289
|
+
}
|
|
290
|
+
else if (readFileSync(agentsMdPath, "utf-8") !== nextAgentsMd) {
|
|
291
|
+
writeFileSync(agentsMdPath, nextAgentsMd, "utf-8");
|
|
292
|
+
console.log(` ${c.updated("Updated:")} AGENTS.md`);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
console.log(` ${c.exists("Exists:")} AGENTS.md`);
|
|
296
|
+
}
|
|
297
|
+
if (workspacePlugin) {
|
|
298
|
+
const workspacePackageExists = existsSync(opencodePackagePath);
|
|
299
|
+
const nextWorkspacePackage = buildWorkspacePackageJson(readJsonObject(opencodePackagePath), packageMetadata);
|
|
300
|
+
if (!workspacePackageExists || options.force) {
|
|
301
|
+
writeJsonFile(opencodePackagePath, nextWorkspacePackage);
|
|
302
|
+
console.log(` ${workspacePackageExists ? c.updated("Updated:") : c.created("Created:")} .opencode/package.json`);
|
|
303
|
+
}
|
|
304
|
+
else if (JSON.stringify(readJsonObject(opencodePackagePath)) !== JSON.stringify(nextWorkspacePackage)) {
|
|
305
|
+
writeJsonFile(opencodePackagePath, nextWorkspacePackage);
|
|
306
|
+
console.log(` ${c.updated("Updated:")} .opencode/package.json`);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
console.log(` ${c.exists("Exists:")} .opencode/package.json`);
|
|
310
|
+
}
|
|
311
|
+
if (options.skipInstall) {
|
|
312
|
+
console.log(`\n ${c.exists("Skipped:")} plugin installation (--skip-install)`);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
console.log(`\n${c.heading("Installing workspace-local plugin...")}\n`);
|
|
316
|
+
await installPluginFromGlobal(opencodeDir, packageMetadata.name, false);
|
|
317
|
+
console.log(`\n ${c.success("Installed:")} .opencode/node_modules/`);
|
|
318
|
+
console.log(` ${c.dim("Plugin is linked to the global runtime cache; no npm install was required.")}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Check provider connectivity and offer to pull missing Ollama models.
|
|
323
|
+
*
|
|
324
|
+
* Uses the effective config (global < workspace) so models chosen in the
|
|
325
|
+
* wizard are probed even though most provider settings live in the global
|
|
326
|
+
* file.
|
|
327
|
+
*
|
|
328
|
+
* @param options.autoPull Pull missing models without a second confirmation
|
|
329
|
+
* (used by the one-question recommended setup).
|
|
330
|
+
*/
|
|
331
|
+
export async function runWorkspaceHealthCheck(cwd, prompter, options = {}) {
|
|
332
|
+
console.log(`\n${c.heading("Checking provider connectivity...")}\n`);
|
|
333
|
+
const ragConfig = loadWorkspaceConfig(cwd);
|
|
334
|
+
// Resolve keys the way the runtime does (env vars, OpenCode provider config,
|
|
335
|
+
// auth store). Without this an on-demand override with no own key inherits
|
|
336
|
+
// the indexing section's key and reports a misleading 401.
|
|
337
|
+
resolveApiKey(ragConfig, cwd);
|
|
338
|
+
const results = await checkProviderHealth(ragConfig, configuredSections(cwd));
|
|
339
|
+
for (const result of results) {
|
|
340
|
+
const icon = result.status === "ok" ? c.success("✓") : result.status === "missing" ? c.warn("○") : c.error("✗");
|
|
341
|
+
const typeLabel = result.type === "image_description"
|
|
342
|
+
? "image description"
|
|
343
|
+
: result.type === "image_description_on_demand"
|
|
344
|
+
? "image description (on-demand)"
|
|
345
|
+
: result.type;
|
|
346
|
+
console.log(` ${icon} ${c.value(result.model)} (${result.provider}) — ${typeLabel} model: ${result.status}`);
|
|
347
|
+
if (result.error)
|
|
348
|
+
console.log(` ${c.dim(result.error)}`);
|
|
349
|
+
}
|
|
350
|
+
if (results.some((result) => result.provider === "ollama" && result.status === "error" && isOllamaConnectionError(result.error))) {
|
|
351
|
+
console.log(`\n ${c.warn("Ollama is not reachable.")} ${c.dim(ollamaInstallHint())}`);
|
|
352
|
+
console.log(` ${c.dim("Start it with: ollama serve")}`);
|
|
353
|
+
}
|
|
354
|
+
const missingOllama = results.filter((result) => result.status === "missing" && result.provider === "ollama");
|
|
355
|
+
if (missingOllama.length > 0) {
|
|
356
|
+
const pullEntries = missingOllama.map((result) => {
|
|
357
|
+
if (result.type === "embedding") {
|
|
358
|
+
return { model: result.model, baseUrl: ragConfig.embedding.baseUrl, proxy: ragConfig.embedding.proxy };
|
|
359
|
+
}
|
|
360
|
+
if (result.type === "description" && ragConfig.description) {
|
|
361
|
+
return { model: result.model, baseUrl: ragConfig.description.baseUrl, proxy: ragConfig.description.proxy };
|
|
362
|
+
}
|
|
363
|
+
if (result.type === "image_description" && ragConfig.imageDescription) {
|
|
364
|
+
return { model: result.model, baseUrl: ragConfig.imageDescription.baseUrl, proxy: ragConfig.imageDescription.proxy };
|
|
365
|
+
}
|
|
366
|
+
if (result.type === "image_description_on_demand" && ragConfig.imageDescription) {
|
|
367
|
+
const onDemand = ragConfig.imageDescription.onDemand;
|
|
368
|
+
return {
|
|
369
|
+
model: result.model,
|
|
370
|
+
baseUrl: onDemand?.baseUrl ?? ragConfig.imageDescription.baseUrl,
|
|
371
|
+
proxy: onDemand?.proxy ?? ragConfig.imageDescription.proxy,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
return { model: result.model, baseUrl: ragConfig.embedding.baseUrl, proxy: ragConfig.embedding.proxy };
|
|
375
|
+
});
|
|
376
|
+
console.log(`\n ${c.warn("Models not found:")} ${pullEntries.map((entry) => entry.model).join(", ")}`);
|
|
377
|
+
const pull = options.autoPull
|
|
378
|
+
? true
|
|
379
|
+
: prompter.interactive
|
|
380
|
+
? await prompter.confirm({
|
|
381
|
+
message: `Pull ${pullEntries.length === 1 ? "this model" : "these models"} now?`,
|
|
382
|
+
defaultValue: missingOllama.some((result) => result.type === "embedding"),
|
|
383
|
+
})
|
|
384
|
+
: false;
|
|
385
|
+
if (pull) {
|
|
386
|
+
console.log();
|
|
387
|
+
try {
|
|
388
|
+
await pullOllamaModels(pullEntries, (model, line) => {
|
|
389
|
+
console.log(` ${c.value(model)}: ${line}`);
|
|
390
|
+
});
|
|
391
|
+
console.log(`\n ${c.success("Models pulled successfully.")}`);
|
|
392
|
+
}
|
|
393
|
+
catch (err) {
|
|
394
|
+
console.error(`\n ${c.error("Pull failed:")} ${err.message}`);
|
|
395
|
+
console.log(` ${c.dim("Pull manually with: ollama pull <model>")}`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
console.log(` ${c.dim("Skipped. Pull manually with: ollama pull <model>")}`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (results.some((result) => result.status === "error")) {
|
|
403
|
+
console.log(`\n ${c.warn("Some providers are not reachable.")} Check configuration and network, then run ${c.file("'opencode-rag index'")}.`);
|
|
404
|
+
}
|
|
405
|
+
return results;
|
|
406
|
+
}
|
|
407
|
+
//# sourceMappingURL=workspace.js.map
|
package/dist/cli.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
/** Main CLI runner and auto-launch detection. */
|
|
6
6
|
export { runCli, shouldAutoRunCli } from "./cli/index.js";
|
|
7
7
|
/** Cleanup helper that removes stale global plugin registration symlinks. */
|
|
8
|
-
export { removeStaleGlobalPluginRegistrations } from "./cli/commands/
|
|
8
|
+
export { removeStaleGlobalPluginRegistrations } from "./cli/commands/workspace-helpers.js";
|
package/dist/cli.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
/** Main CLI runner and auto-launch detection. */
|
|
6
6
|
export { runCli, shouldAutoRunCli } from "./cli/index.js";
|
|
7
7
|
/** Cleanup helper that removes stale global plugin registration symlinks. */
|
|
8
|
-
export { removeStaleGlobalPluginRegistrations } from "./cli/commands/
|
|
8
|
+
export { removeStaleGlobalPluginRegistrations } from "./cli/commands/workspace-helpers.js";
|
|
9
9
|
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Create-only workspace scaffolding for the OpenCode plugin.
|
|
3
|
+
*
|
|
4
|
+
* With the plugin installed globally, a repository does not need a CLI run
|
|
5
|
+
* before it works: on first load the plugin creates the missing workspace
|
|
6
|
+
* files itself (config, skills, `AGENTS.md`, `.gitignore`). Existing files are
|
|
7
|
+
* never overwritten, and `setup.autoScaffold: false` disables the behaviour.
|
|
8
|
+
*/
|
|
9
|
+
/** Result of {@link autoScaffoldWorkspace}. */
|
|
10
|
+
export interface AutoScaffoldResult {
|
|
11
|
+
/** Workspace-relative paths created during this call. */
|
|
12
|
+
created: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create the missing workspace files for `directory`.
|
|
16
|
+
*
|
|
17
|
+
* Only runs when no workspace config exists yet *or* the effective config
|
|
18
|
+
* still has `setup.autoScaffold` enabled. The function never overwrites an
|
|
19
|
+
* existing file and never throws (plugin load must not break).
|
|
20
|
+
*/
|
|
21
|
+
export declare function autoScaffoldWorkspace(directory: string): AutoScaffoldResult;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Create-only workspace scaffolding for the OpenCode plugin.
|
|
3
|
+
*
|
|
4
|
+
* With the plugin installed globally, a repository does not need a CLI run
|
|
5
|
+
* before it works: on first load the plugin creates the missing workspace
|
|
6
|
+
* files itself (config, skills, `AGENTS.md`, `.gitignore`). Existing files are
|
|
7
|
+
* never overwritten, and `setup.autoScaffold: false` disables the behaviour.
|
|
8
|
+
*/
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { findConfigFile, loadWorkspaceConfig, projectConfigPath } from "./config.js";
|
|
12
|
+
import { appendDebugLog } from "./fileLogger.js";
|
|
13
|
+
import { generateDecisionSkillFile, generateDefaultConfigJson, generateSkillFile, mergeAgentsMdContent, mergeGitignoreContent, } from "../cli/commands/workspace-helpers.js";
|
|
14
|
+
/** Write a file when it does not exist yet. */
|
|
15
|
+
function createIfMissing(filePath, content, created, relativeTo) {
|
|
16
|
+
if (existsSync(filePath))
|
|
17
|
+
return;
|
|
18
|
+
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
19
|
+
writeFileSync(filePath, content, "utf-8");
|
|
20
|
+
created.push(path.relative(relativeTo, filePath).replace(/\\/g, "/"));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create the missing workspace files for `directory`.
|
|
24
|
+
*
|
|
25
|
+
* Only runs when no workspace config exists yet *or* the effective config
|
|
26
|
+
* still has `setup.autoScaffold` enabled. The function never overwrites an
|
|
27
|
+
* existing file and never throws (plugin load must not break).
|
|
28
|
+
*/
|
|
29
|
+
export function autoScaffoldWorkspace(directory) {
|
|
30
|
+
const created = [];
|
|
31
|
+
try {
|
|
32
|
+
const existingConfig = findConfigFile(directory);
|
|
33
|
+
if (existingConfig) {
|
|
34
|
+
try {
|
|
35
|
+
const cfg = loadWorkspaceConfig(directory, false);
|
|
36
|
+
if (cfg.setup?.autoScaffold === false)
|
|
37
|
+
return { created };
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Malformed config: still fill in the missing files.
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const opencodeDir = path.join(directory, ".opencode");
|
|
44
|
+
const configPath = projectConfigPath(directory);
|
|
45
|
+
mkdirSync(opencodeDir, { recursive: true });
|
|
46
|
+
if (!existingConfig) {
|
|
47
|
+
createIfMissing(configPath, generateDefaultConfigJson(), created, directory);
|
|
48
|
+
}
|
|
49
|
+
createIfMissing(path.join(opencodeDir, ".gitignore"), mergeGitignoreContent(undefined), created, directory);
|
|
50
|
+
createIfMissing(path.join(opencodeDir, "skills", "opencode-rag", "SKILL.md"), generateSkillFile(), created, directory);
|
|
51
|
+
createIfMissing(path.join(opencodeDir, "skills", "make-decision", "SKILL.md"), generateDecisionSkillFile(), created, directory);
|
|
52
|
+
const agentsPath = path.join(directory, "AGENTS.md");
|
|
53
|
+
if (!existsSync(agentsPath)) {
|
|
54
|
+
let promptEnforcement = true;
|
|
55
|
+
let decisionEnabled = false;
|
|
56
|
+
let routeBeforeAsking = false;
|
|
57
|
+
try {
|
|
58
|
+
const cfg = loadWorkspaceConfig(directory, false);
|
|
59
|
+
promptEnforcement = cfg.memory?.promptEnforcement ?? true;
|
|
60
|
+
decisionEnabled = cfg.decision?.enabled ?? false;
|
|
61
|
+
routeBeforeAsking = cfg.decision?.routeBeforeAsking ?? false;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Defaults.
|
|
65
|
+
}
|
|
66
|
+
createIfMissing(agentsPath, mergeAgentsMdContent(undefined, { promptEnforcement, decisionEnabled, routeBeforeAsking }), created, directory);
|
|
67
|
+
}
|
|
68
|
+
if (created.length > 0) {
|
|
69
|
+
appendDebugLog(path.join(opencodeDir, "opencode-rag.log"), {
|
|
70
|
+
scope: "setup",
|
|
71
|
+
message: `auto-scaffolded workspace files: ${created.join(", ")}`,
|
|
72
|
+
}, "info");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Never break plugin load because a workspace could not be scaffolded.
|
|
77
|
+
}
|
|
78
|
+
return { created };
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=auto-scaffold.js.map
|
package/dist/core/config.d.ts
CHANGED
|
@@ -479,6 +479,15 @@ export interface McpConfig {
|
|
|
479
479
|
/** Whether to auto-start the MCP server on plugin load. Default false — agent tools run in-process regardless. Set true only when an external MCP client needs to connect via `opencode-rag mcp`. */
|
|
480
480
|
enabled: boolean;
|
|
481
481
|
}
|
|
482
|
+
/** Configuration for workspace setup behaviour. */
|
|
483
|
+
export interface SetupConfig {
|
|
484
|
+
/**
|
|
485
|
+
* Create missing workspace files (config, skills, AGENTS.md) when the plugin
|
|
486
|
+
* loads in a repository that has not been set up yet. Create-only: existing
|
|
487
|
+
* files are never overwritten. Default true.
|
|
488
|
+
*/
|
|
489
|
+
autoScaffold: boolean;
|
|
490
|
+
}
|
|
482
491
|
/** Configuration for automatic self-updates. */
|
|
483
492
|
export interface AutoUpdateConfig {
|
|
484
493
|
/** Whether update checking is enabled (defaults to true). */
|
|
@@ -778,6 +787,8 @@ export interface RagConfig {
|
|
|
778
787
|
wikiMode?: WikiModeConfig;
|
|
779
788
|
/** MCP server integration config. */
|
|
780
789
|
mcp?: McpConfig;
|
|
790
|
+
/** Workspace setup behaviour (auto-scaffold). */
|
|
791
|
+
setup?: SetupConfig;
|
|
781
792
|
/** Auto-update checking config. */
|
|
782
793
|
autoUpdate?: AutoUpdateConfig;
|
|
783
794
|
/** Quirk memory config for experiential agent memory. */
|
|
@@ -825,9 +836,9 @@ export declare function validateConfig(config: RagConfig): ConfigValidationResul
|
|
|
825
836
|
* Config file locations to search, in order of precedence.
|
|
826
837
|
*
|
|
827
838
|
* `.opencode/opencode-rag.json` is the canonical workspace location — every
|
|
828
|
-
* writer (TUI, `
|
|
839
|
+
* writer (TUI, `setup`, `clickhouse setup`, the Web UI) creates and updates it
|
|
829
840
|
* there. The root-level `opencode-rag.json` is the legacy location, still read
|
|
830
|
-
* for compatibility (and migrated into `.opencode/` by `opencode-rag
|
|
841
|
+
* for compatibility (and migrated into `.opencode/` by `opencode-rag setup`);
|
|
831
842
|
* `.opencode/rag.json` is a legacy alias inside `.opencode/`.
|
|
832
843
|
*/
|
|
833
844
|
export declare const CONFIG_FILE_CANDIDATES: string[];
|
package/dist/core/config.js
CHANGED
|
@@ -328,6 +328,9 @@ export const DEFAULT_CONFIG = {
|
|
|
328
328
|
mcp: {
|
|
329
329
|
enabled: false,
|
|
330
330
|
},
|
|
331
|
+
setup: {
|
|
332
|
+
autoScaffold: true,
|
|
333
|
+
},
|
|
331
334
|
autoUpdate: {
|
|
332
335
|
enabled: true,
|
|
333
336
|
autoInstall: false,
|
|
@@ -397,7 +400,7 @@ export function validateConfig(config) {
|
|
|
397
400
|
const KNOWN_TOP_KEYS = new Set([
|
|
398
401
|
"embedding", "indexing", "vectorStore", "retrieval", "reranking",
|
|
399
402
|
"openCode", "chunkers", "chunking", "description",
|
|
400
|
-
"imageDescription", "decision", "shellGuard", "documentationMode", "wikiMode", "mcp", "autoUpdate", "memory", "ui", "tui", "logging",
|
|
403
|
+
"imageDescription", "decision", "shellGuard", "documentationMode", "wikiMode", "mcp", "autoUpdate", "memory", "ui", "tui", "logging", "setup",
|
|
401
404
|
]);
|
|
402
405
|
const topKeys = new Set(Object.keys(config));
|
|
403
406
|
for (const key of topKeys) {
|
|
@@ -682,6 +685,9 @@ export function validateConfig(config) {
|
|
|
682
685
|
}
|
|
683
686
|
}
|
|
684
687
|
}
|
|
688
|
+
if (config.setup && typeof config.setup.autoScaffold !== "boolean") {
|
|
689
|
+
warnings.push("setup.autoScaffold must be a boolean");
|
|
690
|
+
}
|
|
685
691
|
if (config.reranking?.enabled) {
|
|
686
692
|
const rr = config.reranking;
|
|
687
693
|
if (!rr.baseUrl)
|
|
@@ -707,9 +713,9 @@ export function validateConfig(config) {
|
|
|
707
713
|
* Config file locations to search, in order of precedence.
|
|
708
714
|
*
|
|
709
715
|
* `.opencode/opencode-rag.json` is the canonical workspace location — every
|
|
710
|
-
* writer (TUI, `
|
|
716
|
+
* writer (TUI, `setup`, `clickhouse setup`, the Web UI) creates and updates it
|
|
711
717
|
* there. The root-level `opencode-rag.json` is the legacy location, still read
|
|
712
|
-
* for compatibility (and migrated into `.opencode/` by `opencode-rag
|
|
718
|
+
* for compatibility (and migrated into `.opencode/` by `opencode-rag setup`);
|
|
713
719
|
* `.opencode/rag.json` is a legacy alias inside `.opencode/`.
|
|
714
720
|
*/
|
|
715
721
|
export const CONFIG_FILE_CANDIDATES = [
|
|
@@ -1068,6 +1074,10 @@ function buildConfig(parsed, validate) {
|
|
|
1068
1074
|
...DEFAULT_CONFIG.mcp,
|
|
1069
1075
|
...(safeObj(parsed.mcp) ?? {}),
|
|
1070
1076
|
},
|
|
1077
|
+
setup: {
|
|
1078
|
+
...DEFAULT_CONFIG.setup,
|
|
1079
|
+
...(safeObj(parsed.setup) ?? {}),
|
|
1080
|
+
},
|
|
1071
1081
|
autoUpdate: {
|
|
1072
1082
|
...DEFAULT_CONFIG.autoUpdate,
|
|
1073
1083
|
...(safeObj(parsed.autoUpdate) ?? {}),
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Global OpenCode plugin installation.
|
|
3
|
+
*
|
|
4
|
+
* OpenCode 2 loads plugins from `~/.config/opencode/plugins/` as well as from
|
|
5
|
+
* a workspace's `.opencode/plugins/`. Installing the RAG plugin once in the
|
|
6
|
+
* global directory removes the per-repository plugin entries, the
|
|
7
|
+
* `.opencode/node_modules` junction and the workspace `package.json`:
|
|
8
|
+
*
|
|
9
|
+
* ```
|
|
10
|
+
* ~/.config/opencode/plugins/opencode-rag/index.js (server role)
|
|
11
|
+
* ~/.config/opencode/plugins/opencode-rag/tui.js (TUI role)
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Both files re-export the plugin from the global runtime
|
|
15
|
+
* (`~/.opencode/node_modules/opencode-rag-plugin/dist/…`) via a relative
|
|
16
|
+
* path, so the install keeps working when the home directory moves. The
|
|
17
|
+
* vector store is NOT affected: `vectorStore.path` is resolved against the
|
|
18
|
+
* workspace, so every repository keeps its own local LanceDB.
|
|
19
|
+
*/
|
|
20
|
+
/** OpenCode's global plugin directory (`<config>/plugins`). */
|
|
21
|
+
export declare function getGlobalPluginsRoot(): string;
|
|
22
|
+
/** Our directory inside OpenCode's global plugin directory. */
|
|
23
|
+
export declare function getGlobalPluginDir(): string;
|
|
24
|
+
/** Dist directory of the plugin inside the runtime cache. */
|
|
25
|
+
export declare function getRuntimePluginDist(): string;
|
|
26
|
+
/** Result of {@link installGlobalPlugin}. */
|
|
27
|
+
export interface GlobalPluginResult {
|
|
28
|
+
/** Directory that holds the entrypoints. */
|
|
29
|
+
dir: string;
|
|
30
|
+
/** Files written during this call (empty when already up to date). */
|
|
31
|
+
written: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Install (or refresh) the global plugin entrypoints.
|
|
35
|
+
*
|
|
36
|
+
* @throws When the runtime plugin dist is missing (run the runtime step first).
|
|
37
|
+
*/
|
|
38
|
+
export declare function installGlobalPlugin(options?: {
|
|
39
|
+
force?: boolean;
|
|
40
|
+
}): GlobalPluginResult;
|
|
41
|
+
/** Whether both global entrypoints exist. */
|
|
42
|
+
export declare function isGlobalPluginInstalled(): boolean;
|
|
43
|
+
/** Remove the global plugin entrypoints. Returns `true` when something was removed. */
|
|
44
|
+
export declare function removeGlobalPlugin(): boolean;
|
|
45
|
+
/** Workspace-local plugin directory (legacy/per-repo mode). */
|
|
46
|
+
export declare function getWorkspacePluginDir(workspaceDir: string): string;
|
|
47
|
+
/** Whether a workspace still uses the per-repository plugin entries. */
|
|
48
|
+
export declare function isWorkspacePluginInstalled(workspaceDir: string): boolean;
|