Skip to content

Apply code + prompt review improvements, add test suite (59 tests)#1

Merged
ernlel merged 4 commits into
masterfrom
feature/improvment
Jul 7, 2026
Merged

Apply code + prompt review improvements, add test suite (59 tests)#1
ernlel merged 4 commits into
masterfrom
feature/improvment

Conversation

@ernlel

@ernlel ernlel commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

Comprehensive improvements from two review passes covering code quality, prompt engineering, and test coverage. The plugin now has safer error handling, portable shell scripts, a CI pipeline, and 59 tests across unit and integration.

Why

Code review (H1-H4, M5-M10, L11-L16)

  • H1: sed -i in uninstall.sh was GNU-only, broke on macOS
  • H2: npm run typecheck failed on fresh clone (no node_modules, no @types/node)
  • H3: Zero tests existed
  • H4: No CI to catch regressions
  • M5: Token budget was lines-only, long lines could blow context window
  • M6: AGENTS-memory.md hardcoded ~/.config/opencode/, wrong for XDG_CONFIG_HOME users
  • M7: No version check in installer — users on old opencode got silent failures
  • M8: Error catching was silent, permissions issues invisible
  • M9: No way to preview what install/uninstall would do
  • M10: Files in tools//domain/ not in the index were invisible to the agent

Prompt review (P1-P13)

  • P1: Reminder injected on every call wasted ~80 tokens and caused habituation
  • P2-P3: Entry format was a vague one-liner with no examples or anti-patterns
  • P4: Rule 6 required confirmation for every edit including formatting
  • P5-P9: Missing decision rules and concrete thresholds across commands
  • P10-P13: Redundant text, wasted prompt budget, missing guidance

Testing

npm run typecheck           # clean
npm test                    # 29 vitest unit tests
bash test/install.test.sh   # 30 shell integration tests

Unit tests (29): readTruncated (line/char truncation, errors), signature (mtimes, caching), checkOrphanedFiles, buildMemoryContext (project+global+orphans)

Shell tests (30): Fresh install, --force, --dry-run, uninstall default, --purge, idempotent re-install, fresh AGENTS.md patching — all in an isolated temp $HOME

CI runs all three steps on push/PR.

ernlel added 4 commits July 7, 2026 00:18
High:
- Replace GNU sed -i with portable awk in uninstall.sh
- Add npx prefix to typecheck, @types/node, package-lock.json, fix tsc
- Add vitest plugin unit tests (14 tests for readTruncated, signature)
- Add GitHub Actions CI pipeline

Medium:
- Add MAX_CHARS byte cap alongside line cap in readTruncated
- Substitute ~/.config/opencode with resolved OC_DIR at install time
- Add opencode v1.17+ version check in install.sh
- Log read/stat errors to stderr instead of swallowing silently
- Add --dry-run flag to install.sh and uninstall.sh
- Add checkOrphanedFiles warning for tools/domain/ files not in index

Low:
- Add CHANGELOG.md
- Add /ocmem-export backup command template
- Add CONTRIBUTING.md
- Document experimental hook dependency and minimum opencode version in plugin
- Clarify .gitignore note about committing project MEMORY.md
Critical:
- Shrink REMINDER to one-liner after first call (saves ~80 tokens/call)
- Define entry format with good/bad examples (YYYY-MM-DD, one-sentence)
- Add anti-patterns section (what NOT to record)
- Narrow rule 6: confirm only for removal/content, not formatting/reorg

Medium:
- Add tools vs domain decision rule (when in doubt, tools/)
- Optimize remember dedup to read index only, not every file
- Add concrete thresholds to reorganize (30 entries, 3+ sections)
- Decouple remember from specific tool API name
- Add domain promotion trigger (10 entries or 50 lines)

Low:
- De-duplicate REMINDER in AGENTS.md (one-line plugin reference)
- Trim MEMORY.md template to one-liner comment + example entry
- Add conflicting memory guidance (rule 7)
- Add concrete examples and usage guidance to general.md
Plugin tests (15 new):
- checkOrphanedFiles: no orphans, orphans detected, missing dirs, non-md files
- buildMemoryContext: empty, project-only, global-only, both, orphans in context
- readTruncated: MAX_CHARS truncation edge cases
- Refactored build() into exported buildMemoryContext for testability

Shell integration test (30 assertions, 8 suites):
- Fresh install, idempotent, --force, --dry-run
- Uninstall default, --purge, --dry-run
- AGENTS.md fresh/patched handling

Updated CI workflow to run shell tests
@ernlel ernlel merged commit ebd8e42 into master Jul 7, 2026
1 check passed
@ernlel ernlel deleted the feature/improvment branch July 7, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant