opencode-autognosis 2.0.4 → 2.0.5

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.
@@ -1,10 +1,13 @@
1
1
  import { tool } from "@opencode-ai/plugin";
2
+ import * as fsSync from "node:fs";
3
+ import * as path from "node:path";
2
4
  import { systemTools } from "./system-tools.js";
3
5
  import { activeSetTools } from "./activeset.js";
4
6
  import { chunkCardsTools } from "./chunk-cards.js";
5
7
  import { moduleSummariesTools } from "./module-summaries.js";
6
8
  import { performanceTools } from "./performance-optimization.js";
7
9
  import { graphTools } from "./database.js";
10
+ const PROJECT_ROOT = process.cwd();
8
11
  // Aggregate all internal tools
9
12
  const internal = {
10
13
  ...systemTools(),
@@ -14,6 +17,55 @@ const internal = {
14
17
  ...performanceTools(),
15
18
  ...graphTools(),
16
19
  };
20
+ async function scoutPlugins() {
21
+ const plugins = new Set();
22
+ // 1. Check opencode.jsonc
23
+ try {
24
+ const config = JSON.parse(fsSync.readFileSync(path.join(PROJECT_ROOT, "opencode.jsonc"), "utf-8"));
25
+ if (config.plugin)
26
+ config.plugin.forEach((p) => plugins.add(p));
27
+ }
28
+ catch { }
29
+ // 2. Check package.json dependencies
30
+ try {
31
+ const pkg = JSON.parse(fsSync.readFileSync(path.join(PROJECT_ROOT, "package.json"), "utf-8"));
32
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
33
+ Object.keys(allDeps).forEach(d => {
34
+ if (d.includes("opencode"))
35
+ plugins.add(d);
36
+ });
37
+ }
38
+ catch { }
39
+ return Array.from(plugins);
40
+ }
41
+ async function updateBridgePrompt(plugins) {
42
+ const bridgePath = "/Users/user/.config/opencode/prompts/bridge.md";
43
+ if (!fsSync.existsSync(bridgePath))
44
+ return "bridge.md not found at " + bridgePath;
45
+ const toolsSection = `
46
+ ## Current Consolidated Tools (Autognosis v2)
47
+ - code_search: Universal search (semantic, symbol, filename, content).
48
+ - code_analyze: Deep structural analysis and impact reports.
49
+ - code_context: Working memory (ActiveSet) management.
50
+ - code_read: Precise symbol jumping and file slicing.
51
+ - code_propose: Planning and patch generation.
52
+ - code_status: System health and background job monitoring.
53
+ - code_setup: Environment initialization and maintenance.
54
+
55
+ ## Other Detected Plugins
56
+ ${plugins.filter(p => p !== "opencode-autognosis").map(p => `- ${p}`).join('\n')}
57
+ `;
58
+ let content = fsSync.readFileSync(bridgePath, "utf-8");
59
+ // Replace or Append Tool Usage section
60
+ if (content.includes("## Current Consolidated Tools")) {
61
+ content = content.replace(/## Current Consolidated Tools[\s\S]*?(?=\n#|$)/, toolsSection);
62
+ }
63
+ else {
64
+ content += "\n" + toolsSection;
65
+ }
66
+ fsSync.writeFileSync(bridgePath, content);
67
+ return "Updated bridge.md with consolidated tools and detected plugins.";
68
+ }
17
69
  export function unifiedTools() {
18
70
  return {
19
71
  code_search: tool({
@@ -128,9 +180,9 @@ export function unifiedTools() {
128
180
  }
129
181
  }),
130
182
  code_setup: tool({
131
- description: "One-time setup and maintenance tasks (AI, Git Journal, Indexing).",
183
+ description: "One-time setup and maintenance tasks (AI, Git Journal, Indexing, Prompt Scouting).",
132
184
  args: {
133
- action: tool.schema.enum(["init", "ai", "index", "journal"]),
185
+ action: tool.schema.enum(["init", "ai", "index", "journal", "scout"]),
134
186
  model: tool.schema.string().optional().describe("AI Model name"),
135
187
  limit: tool.schema.number().optional().describe("History limit")
136
188
  },
@@ -139,7 +191,11 @@ export function unifiedTools() {
139
191
  case "ai": return internal.autognosis_setup_ai.execute({ model: args.model });
140
192
  case "index": return internal.perf_incremental_index.execute({ background: true });
141
193
  case "journal": return internal.journal_build.execute({ limit: args.limit });
142
- default: return internal.autognosis_init.execute({ mode: "apply", token: "adhoc" }); // Simplified
194
+ case "scout": {
195
+ const plugins = await scoutPlugins();
196
+ return updateBridgePrompt(plugins);
197
+ }
198
+ default: return internal.autognosis_init.execute({ mode: "apply", token: "adhoc" });
143
199
  }
144
200
  }
145
201
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-autognosis",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Advanced RAG-powered codebase awareness for OpenCode agents. Features Chunk Cards synthesis, hierarchical reasoning, ActiveSet working memory, and performance optimization for enterprise-scale repositories.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",