Skip to content

feat: detect and reconcile docs created outside the API#32

Open
wormuz wants to merge 58 commits into
0xranx:mainfrom
wormuz:feat/manifest-drift-detection
Open

feat: detect and reconcile docs created outside the API#32
wormuz wants to merge 58 commits into
0xranx:mainfrom
wormuz:feat/manifest-drift-detection

Conversation

@wormuz

@wormuz wormuz commented May 6, 2026

Copy link
Copy Markdown
Contributor

Files written under ~/.opencontext/contexts/ via Write/Edit (bypassing oc_create_doc) used to silently disappear from oc_manifest and oc_search because the manifest was a pure SELECT from SQLite. Agents thought the folder was empty and proposed re-creating it.

Three changes that make the drift impossible to miss:

  1. oc_manifest now scans the filesystem after the SELECT and returns { items, unindexed_files }. When unindexed_files is non-empty, MCP surfaces a warning field naming each file. Manifest stays read-only

    • no auto-insert.
  2. New oc index reconcile [folder] CLI command and oc_reconcile_folder MCP tool. They INSERT a docs row for every *.md present on disk but missing from SQLite, without recomputing embeddings (run oc index build separately for that). Fast path for picking up orphans after a Write or git pull.

  3. oc_create_doc / oc_set_doc_desc descriptions now open with a hard "REQUIRED for any file under ~/.opencontext/contexts/" notice that explicitly calls out Write/Edit as a bug, so MCP-aware agents stop reaching for them.

Rust core gains generate_manifest_full() and reconcile_folder() (the old generate_manifest is preserved for Tauri/UI/CLI callers). NAPI binding switches generateManifest to the wrapped form; existing JS callers updated. Three new core tests cover orphan detection, nested-folder scan, and reconcile idempotency. Tested end-to-end on a real folder with 6 orphans - manifest reported drift, reconcile registered all 6, follow-up manifest came back clean.

0xranx and others added 30 commits December 25, 2025 18:51
feat: enhance AI configuration and integrate idea management features
- Adjusted spacing and alignment in the SearchModal for better visual consistency.
- Updated button styles for improved usability and aesthetics.
- Added a separator line to enhance the input area layout.
- Added support for creating, renaming, and deleting Ideas Boxes in the sidebar.
- Enhanced the idea loading logic to filter threads by selected Ideas Box.
- Updated the LocalStorageAdapter to manage Ideas Boxes and their associated threads.
- Introduced a mobile editor for managing ideas with a new UI.
- Improved the search modal to display ideas with their respective boxes.
- Added localization strings for Ideas Box operations in English and Chinese.
- Refactored the TiptapMarkdown editor to handle composition events more effectively.
- Updated the ScrollSpy hook to maintain stable heading identifiers during composition.
feat: Implement Ideas Box functionality
feat: add swipeable actions for entry management in IdeasScreen
feat: update bundle identifier and enhance macOS build process
- Added dark mode configuration in Tailwind CSS.
- Updated components to support dark mode styling.
- Introduced ThemeContext for managing theme preferences.
- Enhanced localization for theme settings in English and Chinese.
- Refactored styles across various components to ensure consistency in dark mode.
MCP protocol requires structuredContent to be a record (object), not an array.
Arrays are now wrapped as { items: data } to comply with the specification.

Also adds docType parameter to SearchOptions interface.
feat: implement dark mode support and theme context management
- Introduced a new release.yml file to define a changelog template for releases.
- Updated desktop-build.yml to enable automatic generation of release notes based on the defined template.
fix: wrap array responses in object for MCP structuredContent compliance
  Add x86_64-unknown-linux-gnu target to GitHub workflow and npm package
  configuration to enable native bindings on Linux systems.

  - Add Linux to build matrix in native-build.yml (ubuntu-22.04)
  - Add Protobuf installation step for Linux builds
  - Add Linux target to publish script for npm packaging
  - Update napi.triples.additional with Linux target
  - Add @aicontextlab/core-native-linux-x64-gnu to optionalDependencies
…n error

Error was: Failed to convert napi value Null into rust type `u32` on ManifestOptions.limit
- Introduced a set of workflows for Claude to assist users with OpenContext commands, including help, context loading, document creation, and updates.
- Each workflow is defined in its own markdown file with detailed steps and safety guidelines.
- Updated project artifact generation to include these new workflows in the .claude/commands/ directory.
- Implemented functionality to minimize the main window to the system tray and restore it from the tray.
- Enhanced menu options for macOS to include a "Minimize to Tray" feature.
feat: enhance tray icon functionality and window management
- Introduced a new about icon for the application.
- Enhanced the application menu to include version information and the new about icon in the macOS menu.
feat: add about icon and metadata to application menu
…t option

- Added name and release notes generation for desktop releases.
- Set draft option to true for DMG and MSI files in the GitHub Actions workflow.
feat: add Linux x86_64 native bindings support
- Enhanced the README to clarify support for Cursor, Claude Code, and Codex in OpenContext.
- Removed deprecated command files for `/opencontext-context`, `/opencontext-create`, `/opencontext-help`, `/opencontext-iterate`, and `/opencontext-search`.
- Updated command definitions to include detailed instructions for tool selection and integration during initialization.
- Improved MCP server configuration handling for user-level tools.
feat: update README and command definitions for tool integrations
- Added support for building on Ubuntu 22.04 with x86_64 architecture.
- Included installation of necessary Linux dependencies for the build process.
- Implemented steps to build the Tauri app and upload the release artifacts for Linux.
0xranx and others added 28 commits January 18, 2026 22:25
feat: extend desktop build workflow to support Linux
When files are deleted from disk but their records remain in the
database (orphaned records), the indexer would fail with "No such
file or directory" error. Now it logs a warning and continues
indexing the remaining files.
fix(indexer): skip missing files during build_all indexing
feat: add CLI smoke test workflow and improve error handling in nativ…
chore: update @aicontextlab/core-native to version 0.2.1 in package.j…
Reduced MAX_CHARS from 8000 to 2000 characters to prevent "input length
exceeds context length" errors with embedding models like nomic-embed-text.
The previous limit was unsafe for Cyrillic/CJK text where char-to-token
ratio is much lower than English.
fix(embedding): reduce MAX_CHARS to prevent context length errors
fix: update Tiptap code block extension and add highlight.js support
Files written under ~/.opencontext/contexts/ via Write/Edit (bypassing
oc_create_doc) used to silently disappear from oc_manifest and oc_search
because the manifest was a pure SELECT from SQLite. Agents thought the
folder was empty and proposed re-creating it.

Three changes that make the drift impossible to miss:

1. oc_manifest now scans the filesystem after the SELECT and returns
   { items, unindexed_files }. When unindexed_files is non-empty, MCP
   surfaces a `warning` field naming each file. Manifest stays read-only
   - no auto-insert.

2. New `oc index reconcile [folder]` CLI command and `oc_reconcile_folder`
   MCP tool. They INSERT a docs row for every *.md present on disk but
   missing from SQLite, without recomputing embeddings (run
   `oc index build` separately for that). Fast path for picking up
   orphans after a Write or `git pull`.

3. oc_create_doc / oc_set_doc_desc descriptions now open with a hard
   "REQUIRED for any file under ~/.opencontext/contexts/" notice that
   explicitly calls out Write/Edit as a bug, so MCP-aware agents stop
   reaching for them.

Rust core gains generate_manifest_full() and reconcile_folder() (the
old generate_manifest is preserved for Tauri/UI/CLI callers). NAPI
binding switches generateManifest to the wrapped form; existing JS
callers updated. Three new core tests cover orphan detection,
nested-folder scan, and reconcile idempotency. Tested end-to-end on a
real folder with 6 orphans - manifest reported drift, reconcile
registered all 6, follow-up manifest came back clean.
The previous commit's oc_create_doc / oc_set_doc_desc descriptions told
agents to call `oc_save_doc` for body edits, but that tool was never
registered in src/mcp/server.js — only the Rust core / NAPI / JS layers
had it. Agents had to fall back to Edit on the absolute path, which is
safe but contradicts our own "REQUIRED — never use Write/Edit" guidance
and skips the updated_at bump + search-sync event.

Register oc_save_doc as a thin wrapper over store.saveDocContent so the
description's promise is actually fulfillable. Tighten neighbouring
descriptions to mention only tools that exist (drop the phantom
`oc_update_doc` and the JS-internal `saveDocContent`).
clippy::ptr_arg with -D warnings treats &PathBuf args as errors.
Replace with &Path — callers pass &path (PathBuf) which coerces automatically.
oc_search matches document body only — not folder/file names.
Agents searching by project name got 0 results and wrongly concluded
the project doesn't exist.

Add explicit routing hint to both descriptions:
- oc_search: 'Does NOT match folder/file names — use oc_manifest for known projects'
- oc_manifest: 'Use this when you know the project/folder name — oc_search matches content only'
- cargo fmt: fix unindexed_files formatting and use std import style
  to match CI rustfmt version
- cargo fmt: split multi-line name chain and condense write calls in tests
- test-js: uninstall published @aicontextlab/core-native before running
  tests so the locally built binary is loaded instead of stale npm package
@wormuz wormuz force-pushed the feat/manifest-drift-detection branch from 7897d32 to f7f6933 Compare June 13, 2026 10:08
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.

2 participants