opencode-autognosis 2.0.1 → 2.0.4

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.
@@ -0,0 +1,160 @@
1
+ import { tool } from "@opencode-ai/plugin";
2
+ import { systemTools } from "./system-tools.js";
3
+ import { activeSetTools } from "./activeset.js";
4
+ import { chunkCardsTools } from "./chunk-cards.js";
5
+ import { moduleSummariesTools } from "./module-summaries.js";
6
+ import { performanceTools } from "./performance-optimization.js";
7
+ import { graphTools } from "./database.js";
8
+ // Aggregate all internal tools
9
+ const internal = {
10
+ ...systemTools(),
11
+ ...activeSetTools(),
12
+ ...chunkCardsTools(),
13
+ ...moduleSummariesTools(),
14
+ ...performanceTools(),
15
+ ...graphTools(),
16
+ };
17
+ export function unifiedTools() {
18
+ return {
19
+ code_search: tool({
20
+ description: "Search the codebase using various engines (filename, content, symbol, or semantic/vector).",
21
+ args: {
22
+ query: tool.schema.string().describe("Search query"),
23
+ mode: tool.schema.enum(["filename", "content", "symbol", "semantic"]).optional().default("filename").describe("Search strategy"),
24
+ path: tool.schema.string().optional().default(".").describe("Root path for search"),
25
+ limit: tool.schema.number().optional().default(10).describe("Max results"),
26
+ plan_id: tool.schema.string().optional()
27
+ },
28
+ async execute(args) {
29
+ switch (args.mode) {
30
+ case "content": return internal.fast_search.execute({ ...args, mode: "content" });
31
+ case "symbol": return internal.graph_search_symbols.execute({ query: args.query });
32
+ case "semantic": return internal.graph_semantic_search.execute({ query: args.query, limit: args.limit });
33
+ default: return internal.fast_search.execute({ ...args, mode: "filename" });
34
+ }
35
+ }
36
+ }),
37
+ code_analyze: tool({
38
+ description: "Perform structural analysis on files or modules. Generates summaries, API maps, and impact reports.",
39
+ args: {
40
+ target: tool.schema.string().describe("File path or module ID"),
41
+ mode: tool.schema.enum(["summary", "api", "invariant", "module", "impact", "reasoning"]).optional().default("summary"),
42
+ force: tool.schema.boolean().optional().default(false),
43
+ plan_id: tool.schema.string().optional()
44
+ },
45
+ async execute(args) {
46
+ switch (args.mode) {
47
+ case "module": return internal.module_synthesize.execute({ file_path: args.target, force_resynthesize: args.force });
48
+ case "impact": return internal.brief_fix_loop.execute({ symbol: args.target, intent: "impact_analysis" });
49
+ case "reasoning": return internal.module_hierarchical_reasoning.execute({ module_id: args.target });
50
+ default: return internal.chunk_create_card.execute({ file_path: args.target, chunk_type: args.mode, force_recreate: args.force });
51
+ }
52
+ }
53
+ }),
54
+ code_context: tool({
55
+ description: "Manage working memory (ActiveSets). Limits context window usage by loading/unloading specific chunks.",
56
+ args: {
57
+ action: tool.schema.enum(["create", "load", "add", "remove", "status", "list", "close"]),
58
+ target: tool.schema.string().optional().describe("ActiveSet ID or Chunk IDs (comma separated)"),
59
+ name: tool.schema.string().optional().describe("Name for new ActiveSet"),
60
+ plan_id: tool.schema.string().optional()
61
+ },
62
+ async execute(args) {
63
+ const chunk_ids = args.target?.split(',').map(s => s.trim());
64
+ switch (args.action) {
65
+ case "create": return internal.activeset_create.execute({ name: args.name || "Context", chunk_ids });
66
+ case "load": return internal.activeset_load.execute({ set_id: args.target });
67
+ case "add": return internal.activeset_add_chunks.execute({ chunk_ids: chunk_ids });
68
+ case "remove": return internal.activeset_remove_chunks.execute({ chunk_ids: chunk_ids });
69
+ case "list": return internal.activeset_list.execute({});
70
+ case "close": return internal.activeset_close.execute({});
71
+ default: return internal.activeset_get_current.execute({});
72
+ }
73
+ }
74
+ }),
75
+ code_read: tool({
76
+ description: "Precise reading of symbols or file slices. Follows the current plan.",
77
+ args: {
78
+ symbol: tool.schema.string().optional().describe("Symbol to jump to"),
79
+ file: tool.schema.string().optional().describe("File path to read"),
80
+ start_line: tool.schema.number().optional(),
81
+ end_line: tool.schema.number().optional(),
82
+ plan_id: tool.schema.string().optional()
83
+ },
84
+ async execute(args) {
85
+ if (args.symbol)
86
+ return internal.jump_to_symbol.execute({ symbol: args.symbol, plan_id: args.plan_id });
87
+ if (args.file && args.start_line && args.end_line) {
88
+ return internal.read_slice.execute({ file: args.file, start_line: args.start_line, end_line: args.end_line, plan_id: args.plan_id });
89
+ }
90
+ throw new Error("Either 'symbol' or 'file' with line range must be provided.");
91
+ }
92
+ }),
93
+ code_propose: tool({
94
+ description: "Plan and propose changes. Generates worklists, diffs, and validates them.",
95
+ args: {
96
+ action: tool.schema.enum(["plan", "patch", "validate", "finalize"]),
97
+ symbol: tool.schema.string().optional().describe("Locus symbol for plan"),
98
+ intent: tool.schema.string().optional().describe("Work intent (e.g. refactor)"),
99
+ message: tool.schema.string().optional().describe("Commit message for patch"),
100
+ patch_path: tool.schema.string().optional().describe("Path to .diff file"),
101
+ plan_id: tool.schema.string().optional(),
102
+ outcome: tool.schema.string().optional()
103
+ },
104
+ async execute(args) {
105
+ switch (args.action) {
106
+ case "plan": return internal.brief_fix_loop.execute({ symbol: args.symbol, intent: args.intent });
107
+ case "patch": return internal.prepare_patch.execute({ message: args.message, plan_id: args.plan_id });
108
+ case "validate": return internal.validate_patch.execute({ patch_path: args.patch_path, plan_id: args.plan_id });
109
+ case "finalize": return internal.finalize_plan.execute({ plan_id: args.plan_id, outcome: args.outcome });
110
+ }
111
+ }
112
+ }),
113
+ code_status: tool({
114
+ description: "Monitor system health, background jobs, and plan metrics.",
115
+ args: {
116
+ mode: tool.schema.enum(["stats", "hot_files", "jobs", "plan"]).optional().default("stats"),
117
+ job_id: tool.schema.string().optional(),
118
+ plan_id: tool.schema.string().optional(),
119
+ path: tool.schema.string().optional().default("")
120
+ },
121
+ async execute(args) {
122
+ switch (args.mode) {
123
+ case "hot_files": return internal.journal_query_hot_files.execute({ path_prefix: args.path });
124
+ case "jobs": return internal.graph_background_status.execute({ job_id: args.job_id });
125
+ case "plan": return internal.graph_get_plan_metrics.execute({ plan_id: args.plan_id });
126
+ default: return internal.graph_stats.execute({});
127
+ }
128
+ }
129
+ }),
130
+ code_setup: tool({
131
+ description: "One-time setup and maintenance tasks (AI, Git Journal, Indexing).",
132
+ args: {
133
+ action: tool.schema.enum(["init", "ai", "index", "journal"]),
134
+ model: tool.schema.string().optional().describe("AI Model name"),
135
+ limit: tool.schema.number().optional().describe("History limit")
136
+ },
137
+ async execute(args) {
138
+ switch (args.action) {
139
+ case "ai": return internal.autognosis_setup_ai.execute({ model: args.model });
140
+ case "index": return internal.perf_incremental_index.execute({ background: true });
141
+ case "journal": return internal.journal_build.execute({ limit: args.limit });
142
+ default: return internal.autognosis_init.execute({ mode: "apply", token: "adhoc" }); // Simplified
143
+ }
144
+ }
145
+ }),
146
+ internal_call: tool({
147
+ description: "Advanced access to specialized internal tools. Use only when unified tools are insufficient.",
148
+ args: {
149
+ tool_name: tool.schema.string().describe("Internal tool name"),
150
+ args: tool.schema.any().describe("Arguments for the internal tool")
151
+ },
152
+ async execute({ tool_name, args }) {
153
+ const target = internal[tool_name];
154
+ if (!target)
155
+ throw new Error(`Internal tool '${tool_name}' not found.`);
156
+ return target.execute(args);
157
+ }
158
+ })
159
+ };
160
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-autognosis",
3
- "version": "2.0.1",
3
+ "version": "2.0.4",
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",
@@ -46,8 +46,12 @@
46
46
  "devDependencies": {
47
47
  "@opencode-ai/plugin": "^1.0.162",
48
48
  "@opencode-ai/sdk": "^1.1.40",
49
+ "@types/better-sqlite3": "^7.6.13",
49
50
  "@types/node": "^20.0.0",
50
51
  "typescript": "^5.0.0",
51
52
  "zod": "^4.3.6"
53
+ },
54
+ "dependencies": {
55
+ "better-sqlite3": "^12.6.2"
52
56
  }
53
57
  }