opencodekit 0.21.7 → 0.21.9
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 +1 -1
- package/dist/template/.opencode/.template-manifest.json +0 -3
- package/dist/template/.opencode/plugin/copilot-auth.ts +6 -3
- package/dist/template/.opencode/plugin/lib/capture.ts +1 -1
- package/dist/template/.opencode/plugin/lib/db/schema.ts +102 -9
- package/dist/template/.opencode/plugin/lib/memory-db.ts +41 -17
- package/dist/template/.opencode/plugin/lib/operation-log.ts +1 -0
- package/dist/template/.opencode/plugin/sessions.ts +37 -8
- package/package.json +2 -2
- package/dist/template/.opencode/memory.db +0 -0
- package/dist/template/.opencode/memory.db-shm +0 -0
- package/dist/template/.opencode/memory.db-wal +0 -0
- package/dist/template/.opencode/opencode.json.tui-migration.bak +0 -1380
- package/dist/template/.opencode/plugin/notification.ts.bak +0 -64
- package/dist/template/.opencode/pnpm-lock.yaml +0 -287
package/dist/index.js
CHANGED
|
@@ -72,9 +72,6 @@
|
|
|
72
72
|
"memory/research/opencode-mcp-bug-report.md": "3104c0e549097bdbc4229493e78ba4beb69284a8e40fd63325787fad99b75478",
|
|
73
73
|
"memory/research/openspec-analysis.md": "64c35d8f5a35be36f798929cc916f3c185661ced02431cd232727a50ff4269a5",
|
|
74
74
|
"memory/session-context.md": "f27e447ac0c2977f000b8bf7ffa9b4817381879eed6671999c7de516fafc6a91",
|
|
75
|
-
"memory.db": "926f8ccaa5ec2aef3b728d5f76957c0c50adbd89f19232928450f0c5fd445fdb",
|
|
76
|
-
"memory.db-shm": "7e8e3a82bc1a6e68246938dc901973a3da706b648dae3b526dc5973c16bebe43",
|
|
77
|
-
"memory.db-wal": "62e5640770cd1f15a14e492c65da0a85c1aa0db453b9c14c3a53ca21ac619f2d",
|
|
78
75
|
"opencode.json": "7f217641b5347eb5b80dc06a5dea6d664471921bb0149cbdba6a88f824da82b1",
|
|
79
76
|
"opencode.json.tui-migration.bak": "61ccb1a419e93d2f85632366f9d5be4766e30fc0dc326a95e8738a384e2afcd7",
|
|
80
77
|
"opencodex-fast.jsonc": "4a30c9be3f878a9b2ecf59f5e0ada934c9d7e390f09c232597a46d5b4e929a50",
|
|
@@ -600,9 +600,12 @@ export const CopilotAuthPlugin: Plugin = async ({ client: sdk, directory }) => {
|
|
|
600
600
|
continue;
|
|
601
601
|
}
|
|
602
602
|
|
|
603
|
-
// Route OpenAI-compatible Copilot models through the
|
|
604
|
-
// SDK
|
|
605
|
-
|
|
603
|
+
// Route OpenAI-compatible Copilot models through the bundled
|
|
604
|
+
// @ai-sdk/github-copilot SDK. This SDK is shipped with OpenCode and
|
|
605
|
+
// supports both /chat/completions (gpt-4*, older) and /v1/responses
|
|
606
|
+
// (gpt-5.x reasoning models), so projects without local @ai-sdk/*
|
|
607
|
+
// dependencies can initialize the provider without ProviderInitError.
|
|
608
|
+
model.api.npm = "@ai-sdk/github-copilot";
|
|
606
609
|
}
|
|
607
610
|
}
|
|
608
611
|
|
|
@@ -5,9 +5,104 @@
|
|
|
5
5
|
* singleton database connection manager.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Database } from "bun:sqlite";
|
|
9
8
|
import { appendFileSync, existsSync, renameSync } from "node:fs";
|
|
10
9
|
import path from "node:path";
|
|
10
|
+
import { createRequire } from "node:module";
|
|
11
|
+
|
|
12
|
+
type SqlParam = string | number | bigint | null | Uint8Array;
|
|
13
|
+
type RunResult = { changes: number; lastInsertRowid: number | bigint };
|
|
14
|
+
type StatementResult = {
|
|
15
|
+
changes: number | bigint;
|
|
16
|
+
lastInsertRowid: number | bigint;
|
|
17
|
+
};
|
|
18
|
+
type StatementSyncLike = {
|
|
19
|
+
get(...params: SqlParam[]): unknown;
|
|
20
|
+
all(...params: SqlParam[]): unknown[];
|
|
21
|
+
run(...params: SqlParam[]): StatementResult;
|
|
22
|
+
};
|
|
23
|
+
type DatabaseSyncLike = {
|
|
24
|
+
prepare(sql: string): StatementSyncLike;
|
|
25
|
+
exec(sql: string): void;
|
|
26
|
+
close(): void;
|
|
27
|
+
};
|
|
28
|
+
type DatabaseSyncConstructor = new (
|
|
29
|
+
dbPath: string,
|
|
30
|
+
options?: { readOnly?: boolean; timeout?: number },
|
|
31
|
+
) => DatabaseSyncLike;
|
|
32
|
+
|
|
33
|
+
const require = createRequire(import.meta.url);
|
|
34
|
+
let DatabaseSyncCtor: DatabaseSyncConstructor | null = null;
|
|
35
|
+
|
|
36
|
+
function getDatabaseSyncConstructor(): DatabaseSyncConstructor {
|
|
37
|
+
if (!DatabaseSyncCtor) {
|
|
38
|
+
const sqlite = require("node:sqlite") as {
|
|
39
|
+
DatabaseSync: DatabaseSyncConstructor;
|
|
40
|
+
};
|
|
41
|
+
DatabaseSyncCtor = sqlite.DatabaseSync;
|
|
42
|
+
}
|
|
43
|
+
return DatabaseSyncCtor;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function normalizeParams(params: SqlParam[] | [SqlParam[]]): SqlParam[] {
|
|
47
|
+
if (params.length === 1 && Array.isArray(params[0])) {
|
|
48
|
+
return params[0];
|
|
49
|
+
}
|
|
50
|
+
return params as SqlParam[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class Database {
|
|
54
|
+
private readonly db: DatabaseSyncLike;
|
|
55
|
+
|
|
56
|
+
constructor(
|
|
57
|
+
dbPath: string,
|
|
58
|
+
options: { create?: boolean; readonly?: boolean } = {},
|
|
59
|
+
) {
|
|
60
|
+
const DatabaseSync = getDatabaseSyncConstructor();
|
|
61
|
+
this.db = new DatabaseSync(dbPath, {
|
|
62
|
+
readOnly: options.readonly ?? false,
|
|
63
|
+
timeout: 5000,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
run(sql: string, ...params: SqlParam[] | [SqlParam[]]): RunResult {
|
|
68
|
+
const result = this.db.prepare(sql).run(...normalizeParams(params));
|
|
69
|
+
return {
|
|
70
|
+
changes: Number(result.changes),
|
|
71
|
+
lastInsertRowid: result.lastInsertRowid,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
query<Result = unknown, Params extends SqlParam[] = SqlParam[]>(sql: string) {
|
|
76
|
+
const statement = this.db.prepare(sql);
|
|
77
|
+
return {
|
|
78
|
+
get: (...params: Params | [Params]) =>
|
|
79
|
+
statement.get(
|
|
80
|
+
...normalizeParams(params as SqlParam[] | [SqlParam[]]),
|
|
81
|
+
) as Result | null,
|
|
82
|
+
all: (...params: Params | [Params]) =>
|
|
83
|
+
statement.all(
|
|
84
|
+
...normalizeParams(params as SqlParam[] | [SqlParam[]]),
|
|
85
|
+
) as Result[],
|
|
86
|
+
run: (...params: Params | [Params]): RunResult => {
|
|
87
|
+
const result = statement.run(
|
|
88
|
+
...normalizeParams(params as SqlParam[] | [SqlParam[]]),
|
|
89
|
+
);
|
|
90
|
+
return {
|
|
91
|
+
changes: Number(result.changes),
|
|
92
|
+
lastInsertRowid: result.lastInsertRowid,
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
exec(sql: string): void {
|
|
99
|
+
this.db.exec(sql);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
close(): void {
|
|
103
|
+
this.db.close();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
11
106
|
|
|
12
107
|
// ============================================================================
|
|
13
108
|
// Recovery Logger
|
|
@@ -355,7 +450,10 @@ export function getMemoryDB(): Database {
|
|
|
355
450
|
// Close bad instance and attempt recovery
|
|
356
451
|
dbInstance.close();
|
|
357
452
|
dbInstance = null;
|
|
358
|
-
const recovered = attemptDBRecovery(
|
|
453
|
+
const recovered = attemptDBRecovery(
|
|
454
|
+
dbPath,
|
|
455
|
+
new Error("integrity check failed"),
|
|
456
|
+
);
|
|
359
457
|
if (!recovered) {
|
|
360
458
|
throw new Error(
|
|
361
459
|
`Memory database integrity check failed and recovery failed. ` +
|
|
@@ -365,10 +463,7 @@ export function getMemoryDB(): Database {
|
|
|
365
463
|
dbInstance = recovered;
|
|
366
464
|
}
|
|
367
465
|
} catch (err) {
|
|
368
|
-
if (
|
|
369
|
-
err instanceof Error &&
|
|
370
|
-
err.message.includes("recovery failed")
|
|
371
|
-
) {
|
|
466
|
+
if (err instanceof Error && err.message.includes("recovery failed")) {
|
|
372
467
|
throw err;
|
|
373
468
|
}
|
|
374
469
|
// integrity_check itself failed — try recovery
|
|
@@ -442,9 +537,7 @@ function attemptDBRecovery(
|
|
|
442
537
|
if (existsSync(dbPath)) {
|
|
443
538
|
const backupPath = `${dbPath}.corrupt.${Date.now()}`;
|
|
444
539
|
renameSync(dbPath, backupPath);
|
|
445
|
-
logRecovery(
|
|
446
|
-
`[memory-db] Corrupt database backed up to: ${backupPath}`,
|
|
447
|
-
);
|
|
540
|
+
logRecovery(`[memory-db] Corrupt database backed up to: ${backupPath}`);
|
|
448
541
|
|
|
449
542
|
// Also clean up WAL/SHM files
|
|
450
543
|
for (const suffix of ["-wal", "-shm"]) {
|
|
@@ -13,6 +13,22 @@
|
|
|
13
13
|
* db/graph.ts — Entity graph: temporal triples, queries, stats
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
export {
|
|
17
|
+
type CompiledArticle,
|
|
18
|
+
type CompileResult,
|
|
19
|
+
type ConceptCluster,
|
|
20
|
+
compileObservations,
|
|
21
|
+
} from "./compile.js";
|
|
22
|
+
// Entity Graph Operations (v3)
|
|
23
|
+
export {
|
|
24
|
+
addEntityTriple,
|
|
25
|
+
findContradictions as findGraphContradictions,
|
|
26
|
+
getEntityGraphStats,
|
|
27
|
+
getEntityTimeline,
|
|
28
|
+
getTripleById,
|
|
29
|
+
invalidateTriple,
|
|
30
|
+
queryEntity,
|
|
31
|
+
} from "./db/graph.js";
|
|
16
32
|
// Memory Files, FTS5, and Maintenance
|
|
17
33
|
export {
|
|
18
34
|
archiveOldObservations,
|
|
@@ -53,24 +69,32 @@ export {
|
|
|
53
69
|
storeDistillation,
|
|
54
70
|
storeTemporalMessage,
|
|
55
71
|
} from "./db/pipeline.js";
|
|
56
|
-
// Entity Graph Operations (v3)
|
|
57
|
-
export {
|
|
58
|
-
addEntityTriple,
|
|
59
|
-
findContradictions as findGraphContradictions,
|
|
60
|
-
getEntityGraphStats,
|
|
61
|
-
getEntityTimeline,
|
|
62
|
-
getTripleById,
|
|
63
|
-
invalidateTriple,
|
|
64
|
-
queryEntity,
|
|
65
|
-
} from "./db/graph.js";
|
|
66
72
|
// Database Manager
|
|
67
|
-
export { closeMemoryDB, getMemoryDB } from "./db/schema.js";
|
|
73
|
+
export { closeMemoryDB, Database, getMemoryDB } from "./db/schema.js";
|
|
68
74
|
// Types & Configuration
|
|
69
75
|
export * from "./db/types.js";
|
|
70
|
-
|
|
76
|
+
export {
|
|
77
|
+
generateMemoryIndex,
|
|
78
|
+
type IndexEntry,
|
|
79
|
+
type IndexResult,
|
|
80
|
+
} from "./index-generator.js";
|
|
71
81
|
// New modules (v2.1: lint, compile, index, validate, operation log)
|
|
72
|
-
export {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
export {
|
|
83
|
+
type LintIssue,
|
|
84
|
+
type LintIssueType,
|
|
85
|
+
type LintResult,
|
|
86
|
+
lintMemory,
|
|
87
|
+
} from "./lint.js";
|
|
88
|
+
export {
|
|
89
|
+
appendOperationLog,
|
|
90
|
+
getLogContent,
|
|
91
|
+
getRecentLogEntries,
|
|
92
|
+
type LogEntry,
|
|
93
|
+
type OperationType,
|
|
94
|
+
} from "./operation-log.js";
|
|
95
|
+
export {
|
|
96
|
+
type ValidationIssue,
|
|
97
|
+
type ValidationResult,
|
|
98
|
+
type ValidationVerdict,
|
|
99
|
+
validateObservation,
|
|
100
|
+
} from "./validate.js";
|
|
@@ -6,16 +6,42 @@
|
|
|
6
6
|
* - find_sessions: Multi-word AND search with relevance ranking
|
|
7
7
|
* - read_session: Full transcript with keyword filtering
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Uses Node's built-in node:sqlite module for zero-dep DB access.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { Database } from "bun:sqlite";
|
|
13
12
|
import { spawnSync } from "node:child_process";
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
14
|
import { join } from "node:path";
|
|
15
15
|
import type { Plugin } from "@opencode-ai/plugin";
|
|
16
16
|
import { tool } from "@opencode-ai/plugin/tool";
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
type SqlParam = string | number | bigint | null | Uint8Array;
|
|
19
|
+
type StatementSyncLike = {
|
|
20
|
+
get(...params: SqlParam[]): unknown;
|
|
21
|
+
all(...params: SqlParam[]): unknown[];
|
|
22
|
+
};
|
|
23
|
+
type DatabaseSyncLike = {
|
|
24
|
+
prepare(sql: string): StatementSyncLike;
|
|
25
|
+
close(): void;
|
|
26
|
+
};
|
|
27
|
+
type DatabaseSyncConstructor = new (
|
|
28
|
+
dbPath: string,
|
|
29
|
+
options?: { readOnly?: boolean; timeout?: number },
|
|
30
|
+
) => DatabaseSyncLike;
|
|
31
|
+
|
|
32
|
+
const require = createRequire(import.meta.url);
|
|
33
|
+
let DatabaseSyncCtor: DatabaseSyncConstructor | null = null;
|
|
34
|
+
|
|
35
|
+
function getDatabaseSyncConstructor(): DatabaseSyncConstructor {
|
|
36
|
+
if (!DatabaseSyncCtor) {
|
|
37
|
+
const sqlite = require("node:sqlite") as {
|
|
38
|
+
DatabaseSync: DatabaseSyncConstructor;
|
|
39
|
+
};
|
|
40
|
+
DatabaseSyncCtor = sqlite.DatabaseSync;
|
|
41
|
+
}
|
|
42
|
+
return DatabaseSyncCtor;
|
|
43
|
+
}
|
|
44
|
+
|
|
19
45
|
|
|
20
46
|
const SEARCH_CONFIG = {
|
|
21
47
|
roles: ["user", "assistant"],
|
|
@@ -66,13 +92,16 @@ const resolveDbPath = (): string => {
|
|
|
66
92
|
/** Resolved once at module load — no per-request resolution cost. */
|
|
67
93
|
const DEFAULT_DB_PATH = resolveDbPath();
|
|
68
94
|
|
|
69
|
-
const openReadonlyDb = (): {
|
|
95
|
+
const openReadonlyDb = (): {
|
|
96
|
+
db: DatabaseSyncLike | null;
|
|
97
|
+
error: string | null;
|
|
98
|
+
} => {
|
|
70
99
|
try {
|
|
100
|
+
const DatabaseSync = getDatabaseSyncConstructor();
|
|
71
101
|
return {
|
|
72
|
-
db: new
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
strict: true,
|
|
102
|
+
db: new DatabaseSync(DEFAULT_DB_PATH, {
|
|
103
|
+
readOnly: true,
|
|
104
|
+
timeout: 5000,
|
|
76
105
|
}),
|
|
77
106
|
error: null,
|
|
78
107
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencodekit",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.9",
|
|
4
4
|
"description": "CLI tool for bootstrapping and managing OpenCodeKit projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"dev": "tsx src/index.ts",
|
|
37
|
-
"build": "tsdown && mkdir -p dist/template && rsync -av --exclude=node_modules --exclude=dist --exclude=.git --exclude=coverage --exclude=.next --exclude=.turbo --exclude=logs --exclude=package-lock.json .opencode/ dist/template/.opencode/",
|
|
37
|
+
"build": "tsdown && mkdir -p dist/template && rsync -av --exclude=node_modules --exclude=dist --exclude=.git --exclude=coverage --exclude=.next --exclude=.turbo --exclude=logs --exclude=package-lock.json --exclude='plugin/*.bak' --exclude=memory.db --exclude=memory.db-shm --exclude=memory.db-wal --exclude='memory.db.corrupt.*' --exclude=memory-recovery.log .opencode/ dist/template/.opencode/",
|
|
38
38
|
"typecheck": "tsgo --noEmit",
|
|
39
39
|
"test": "vitest run",
|
|
40
40
|
"test:watch": "vitest",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|