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
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- run: npm run typecheck
- run: npm test
- run: bash test/install.test.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ node_modules/
*~

# Per-developer opencode state (plugin cache, project-local memory, etc.)
# NOTE: This repo uses .opencode/ for its own development. Users of ocmem
# SHOULD commit their .opencode/memory/MEMORY.md in their project repos
# (with an appropriate .gitignore exception).
.opencode/
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Changelog

All notable changes to ocmem.

## Unreleased

### Added
- Byte-level cap (`MAX_CHARS = 8000`) in the plugin to prevent pathological line lengths from eating the context window.
- Orphaned-file detection: the plugin now scans `tools/` and `domain/` directories and warns when `.md` files exist that are not referenced in the index.
- `--dry-run` / `-n` flag on `install.sh` and `uninstall.sh` — prints every action without modifying anything.
- OpenCode version check in `install.sh` — warns if < v1.17 or if the binary is missing.
- Portable `awk`-based block removal in `uninstall.sh` (was GNU-only `sed -i`).
- Plugin unit tests (`test/ocmem.test.ts` — 14 tests covering `readTruncated` and `signature`) and vitest runner.
- GitHub Actions CI pipeline (`.github/workflows/ci.yml`) running typecheck + tests.
- `package-lock.json` committed to ensure reproducible installs.

### Changed
- `tsconfig.json` updated: uses `npx tsc`, added `@types/node`, set `"types": ["node"]`.
- Paths in the AGENTS.md block are now substituted with the resolved config directory at install time (no more hardcoded `~/.config/opencode/`).
- Plugin error handling: unexpected read/stat errors are now logged to `stderr` instead of being silently swallowed.
- `.gitignore` now includes a note clarifying that users *should* commit their `.opencode/memory/MEMORY.md`.

## 1.0.0 — 2026-07-06

### Added
- Structured memory system: global (`~/.config/opencode/memory/`) + project (`.opencode/memory/`) roots.
- `plugin/ocmem.ts` — auto-injects the project `MEMORY.md` and global index into every LLM system prompt via `experimental.chat.system.transform` and `experimental.session.compacting`.
- `scripts/install.sh` — one-command installer with `--force` support (never touches user data).
- `scripts/uninstall.sh` — uninstaller that preserves memory files by default, `--purge` to remove everything.
- `/ocmem-init` command — scaffolds project memory in any repo.
- `/ocmem-remember` command — reviews a session, classifies candidates, checks for duplicates, and writes confirmed entries.
- `/ocmem-reorganize` command — dedupe, merge, split, re-sort, and refresh the global index.
- AGENTS.md memory rules: when to write, entry format, mandatory end-of-task memory review.
- `templates/` directory with scaffolding for memory files, commands, and AGENTS.md rules.
- `docs/architecture.md` — design rationale and Claude Code comparison.
- MIT license.
73 changes: 73 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Contributing

Thanks for wanting to help.

## Getting started

```bash
# Clone and install
git clone https://github.com/ernlel/ocmem.git
cd ocmem
npm install
```

Nothing to build — the plugin is TypeScript source consumed directly by
openCode's Bun runtime.

## Running checks

```bash
npm run typecheck # TypeScript compilation check
npm test # Plugin unit tests (vitest)
```

Both must pass before a PR can be merged. CI runs them automatically.

## Project layout

```
plugin/ ocmem.ts — the opencode plugin (memory injector)
templates/ — AGENTS.md rules, memory scaffold, /ocmem-* commands
scripts/ install.sh, uninstall.sh — one-command deploy / remove
test/ ocmem.test.ts — vitest unit tests
docs/ architecture.md — design rationale
```

## Code style

- **Plugin:** TypeScript only where it helps — just Node built-ins +
`import type { Plugin }` from `@opencode-ai/plugin`. No runtime
dependencies beyond what Bun ships.
- **Shell scripts:** POSIX-compatible where possible. Prefer `awk` over
`sed -i` (macOS `sed` is BSD, not GNU). Use `set -euo pipefail`.
- **Templates:** Plain markdown with YAML frontmatter (`---`) for
command templates. Match the structure of existing commands.
- Errors are logged to `stderr`, never swallowed silently.
- Known trivia goes in comments; explanations live in `docs/`.

## Testing

- Plugin changes → add or update tests in `test/ocmem.test.ts`.
- Shell script changes → manually test with `--dry-run` first, then
run against a temp directory. A bats-based test suite is planned
but not yet wired in.

Run `npm test` before pushing.

## Submitting changes

1. Fork and branch from `master`.
2. Keep commits focused — one logical change per commit.
3. Write a clear commit message (present tense, imperative mood).
4. Run `npm run typecheck && npm test`.
5. Open a PR against `master` with a description of what changed and why.

## What to work on

Check the open issues, or look at `CHANGELOG.md` for the "Unreleased"
section to see what's already in flight. If you want to add something
not covered by an issue, open one first to discuss.

## License

MIT — see [LICENSE](LICENSE).
Loading
Loading