Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* text=auto eol=lf
*.ico binary
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.woff binary
*.woff2 binary
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ updates:
# Keep this pin until onnxruntime ships a darwin/x64 build after the
# macOS Ort::Env teardown fix (#27961 / #24579) and OpenCode embeds Bun >1.3.14.
- dependency-name: "onnxruntime-node"
# ESLint 10 / typescript-eslint do not support TypeScript 7 yet (peer: <6.1.0).
- dependency-name: "typescript"
versions: [">=7"]
update-types: ["version-update:semver-major"]

- package-ecosystem: "github-actions"
directory: "/"
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/platform-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
- "scripts/verify-nested-onnxruntime-fixture.mjs"
- "scripts/smoke-test.mjs"
- "web/**"
- "eslint.config.js"
- ".prettierrc"
- ".prettierignore"
- ".github/workflows/platform-smoke.yml"
workflow_dispatch:

Expand Down Expand Up @@ -52,6 +55,12 @@ jobs:
- name: Typecheck source
run: bun run typecheck

- name: Lint source
run: bun run lint

- name: Check formatting
run: bun run format:check

- name: Build package artifacts
run: bun run build

Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Quality

on:
pull_request:
push:
branches:
- main

concurrency:
group: quality-${{ github.repository }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
check:
name: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: oven-sh/setup-bun@v2

- name: Install source dependencies
run: bun install --frozen-lockfile

- name: Install web dependencies
working-directory: web
run: bun install --frozen-lockfile

- name: Check formatting
run: bun run format:check

- name: Lint
run: bun run lint

- name: Typecheck
run: bun run typecheck
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:

- run: bun run typecheck

- run: bun run lint

- run: bun run format:check

- run: bun run build

- name: Verify tag matches package version
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ If a shard becomes incompatible (for example after changing `embeddingDimensions

## Getting Started

Add to your OpenCode configuration at `~/.config/opencode/opencode.json`:
For OpenCode v2, add the package to the native `plugins` list:

```jsonc
{
"plugins": ["opencode-mem"],
}
```

For OpenCode v1, add the default entrypoint to your configuration at
`~/.config/opencode/opencode.json`:

```jsonc
{
Expand Down
815 changes: 792 additions & 23 deletions bun.lock

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import js from "@eslint/js";
import prettier from "eslint-config-prettier";
import reactHooks from "eslint-plugin-react-hooks";
import globals from "globals";
import ts from "typescript-eslint";

export default ts.config(
{
ignores: [
"coverage/**",
"dist/**",
"node_modules/**",
"out/**",
"web/dist/**",
"web/node_modules/**",
],
},
js.configs.recommended,
...ts.configs.recommended,
{
files: ["web/src/**/*.{ts,tsx}"],
plugins: {
"react-hooks": reactHooks,
},
rules: {
"react-hooks/exhaustive-deps": "error",
"react-hooks/rules-of-hooks": "error",
},
},
prettier,
{
languageOptions: {
globals: {
...globals.browser,
...globals.bun,
...globals.node,
},
},
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
},
}
);
32 changes: 25 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
"description": "OpenCode plugin that gives coding agents persistent memory using local Turso/libSQL vector search",
"type": "module",
"main": "dist/plugin.js",
"types": "dist/index.d.ts",
"types": "dist/plugin.d.ts",
"exports": {
".": {
"import": "./dist/plugin.js",
"types": "./dist/index.d.ts"
"types": "./dist/plugin.d.ts"
},
"./server": {
"import": "./dist/plugin.js",
"types": "./dist/index.d.ts"
"types": "./dist/plugin.d.ts"
},
"./v2": {
"import": "./dist/v2/plugin.js",
"types": "./dist/v2/plugin.d.ts"
},
"./tags": {
"import": "./dist/services/tags.js",
Expand All @@ -26,8 +30,10 @@
"dev": "tsc --watch",
"test": "bun test",
"typecheck": "tsc --noEmit",
"format": "prettier --write \"src/**/*.{ts,css,html}\" \"web/src/**/*.{ts,tsx,css,html}\"",
"format:check": "prettier --check \"src/**/*.{ts,css,html}\" \"web/src/**/*.{ts,tsx,css,html}\"",
"lint": "eslint . --max-warnings=0",
"format": "prettier --write .",
"format:check": "prettier --check .",
"check": "bun run format:check && bun run lint && bun run typecheck",
"prepare": "husky"
},
"keywords": [
Expand All @@ -54,6 +60,7 @@
"@libsql/client": "^0.17.4",
"@opencode-ai/plugin": "^1.18.15",
"@opencode-ai/sdk": "^1.18.15",
"@opencode/plugin": "^2.0.8",
"franc-min": "^6.2.0",
"hono": "^4.12.32",
"iso-639-3": "^3.0.1",
Expand All @@ -66,16 +73,23 @@
"bun-types": "1.3.14"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@types/bun": "^1.4.0",
"eslint": "^10.10.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-react-hooks": "^7.1.1",
"globals": "^17.12.0",
"husky": "^9.1.7",
"lint-staged": "^17.3.0",
"prettier": "^3.9.6",
"typescript": "7.0.2"
"typescript": "^6.0.3",
"typescript-eslint": "^8.70.0"
},
"opencode": {
"type": "plugin",
"hooks": [
"chat.message",
"chat.params",
"event"
]
},
Expand All @@ -84,7 +98,11 @@
"package.json"
],
"lint-staged": {
"*.{ts,tsx,css,html,json,md}": [
"*.{js,mjs,cjs,ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{css,html,json,jsonc,md,yml,yaml}": [
"prettier --write"
]
}
Expand Down
4 changes: 3 additions & 1 deletion scripts/native-deps-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ function formatError(error) {

const lockfile = readJson(lockfilePath);
const opencodeMemPkgPath = join(projectRoot, "node_modules", "opencode-mem", "package.json");
const rootPkg = existsSync(opencodeMemPkgPath) ? readJson(opencodeMemPkgPath) : readJson(join(projectRoot, "package.json"));
const rootPkg = existsSync(opencodeMemPkgPath)
? readJson(opencodeMemPkgPath)
: readJson(join(projectRoot, "package.json"));
const candidates = [];
const failures = [];

Expand Down
5 changes: 1 addition & 4 deletions scripts/verify-libsql-vector.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ async function removeDatabaseFiles(dbPath) {
break;
} catch (error) {
const code = error?.code;
if (
attempt >= FILE_LOCK_RETRY_DELAYS_MS.length ||
!RETRYABLE_FILE_LOCK_CODES.has(code)
) {
if (attempt >= FILE_LOCK_RETRY_DELAYS_MS.length || !RETRYABLE_FILE_LOCK_CODES.has(code)) {
throw error;
}
await delay(FILE_LOCK_RETRY_DELAYS_MS[attempt]);
Expand Down
10 changes: 7 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ function loadConfigFromPaths(paths: string[]): OpenCodeMemConfig {
const content = readFileSync(path, "utf-8");
const json = stripJsoncComments(content);
return JSON.parse(json) as OpenCodeMemConfig;
} catch {}
} catch {
// ignore unreadable or invalid config files
}
}
}
return {};
Expand Down Expand Up @@ -566,7 +568,9 @@ function ensureConfigExists(): void {
writeFileSync(configPath, CONFIG_TEMPLATE, "utf-8");
console.log(`\n✓ Created config template: ${configPath}`);
console.log(" Edit this file to customize opencode-mem settings.\n");
} catch {}
} catch {
// ignore if the template cannot be written
}
}
}

Expand Down Expand Up @@ -777,7 +781,7 @@ function buildConfig(fileConfig: OpenCodeMemConfig) {
};
}

let _globalFileConfig = loadConfigFromPaths(CONFIG_FILES);
const _globalFileConfig = loadConfigFromPaths(CONFIG_FILES);
export let CONFIG = buildConfig(_globalFileConfig);

type RuntimeConfig = ReturnType<typeof buildConfig>;
Expand Down
Loading
Loading