Commit graph

592 commits

Author SHA1 Message Date
Wenzheng Jiang
db97a8ace3
Prompt Improvement: Use getFileTree to explore ambiguous notes and folders (#1962)
* Prompt Improvement: Use getFileTree to explore ambiguous notes and folders.

* MInor

* fix: Clarify instructions for using getFileTree in note retrieval process
2025-10-26 13:46:34 -07:00
Logan Yang
2b5e07e61f
Stop condensing history in plus nonagent route (#1963) 2025-10-24 15:03:52 -07:00
Logan Yang
c394f4b95a
feat: Add UTF-8 byte length calculation and truncation functions (#1957)
- Implemented `getUtf8ByteLength` to calculate the byte length of strings in UTF-8, accommodating various character types including ASCII, Cyrillic, CJK, and emojis.
- Introduced `truncateToByteLimit` to truncate strings while respecting UTF-8 character boundaries, ensuring no multibyte characters are cut in half.
- Added unit tests for both functions to validate their behavior across different scenarios, including edge cases.
- Updated `ChatPersistenceManager` to utilize these functions for managing filename lengths, ensuring compliance with filesystem byte limits.
2025-10-23 17:22:23 -07:00
Logan Yang
b4fd925111
fix: Enhance error handling in AutonomousAgentChainRunner for local search and readNote tool calls (#1956) 2025-10-23 17:08:04 -07:00
Emt-lin
3a30b5bae6
feat: Improve error handling architecture across chain runners. (#1931)
* feat: Improve error handling architecture across chain runners.

# Conflicts:
#	src/LLMProviders/chainRunner/AutonomousAgentChainRunner.ts
#	src/chainFactory.ts
#	src/chainUtils.ts

* fix: Preserve correct content ordering in streaming messages

Fix two issues that could confuse users during streaming:
- Error blocks now inserted at correct stream position instead of always appending to end, preserving visual context
- Reset lastDisplayedContent between runs to prevent stale content from appearing in new responses

* fix: fix branch conflicts.

* fix: correctly dispose error block roots by parameterizing disposal helpers with registry.
2025-10-23 17:00:23 -07:00
Logan Yang
63a3f9fc5f
Add bedrock provider (#1955)
* Add Amazon Bedrock support

- Introduced new fields for Amazon Bedrock in `aiParams.ts` and `constants.ts`.
- Implemented API key and region validation in `utils.ts`.
- Created `BedrockChatModel` class for handling Bedrock-specific chat model interactions.
- Updated `ChatModelManager` to include Bedrock as a supported provider.
- Enhanced settings management to accommodate Bedrock API key and region.
- Added UI components for Bedrock model configuration in settings dialogs.
- Included unit tests for Bedrock chat model functionality.

This update expands the plugin's capabilities to integrate with Amazon Bedrock, allowing users to utilize its chat model features effectively.

* Support token count for bedrock

* Refactor Amazon Bedrock API key and region validation

- Simplified the API key validation logic in `utils.ts` to only require the API key, as the region defaults to "us-east-1" if not specified.
- Removed redundant checks for base URL and region in `chatModelManager.ts`, streamlining the endpoint construction process.

This update enhances the clarity and efficiency of the Bedrock integration, ensuring a smoother user experience.
2025-10-23 16:29:31 -07:00
Wenzheng Jiang
40d1badada
Add CRUD to Saved Memory (#1929) 2025-10-22 23:33:35 -07:00
Logan Yang
b90e80f509
Enable Openrouter thinking tokens (#1954)
* Fix sources css

* Enable thinking tokens for openrouter models

* Add reasoning effort for openrouter models

* Add unit tests for ThinkBlockStreamer to validate reasoning details handling and proper <think> tag placement

* Enable token count from openrouter models
2025-10-22 23:29:59 -07:00
Logan Yang
359fbc922b
Fix new note not discoverable in copilot chat (#1950) 2025-10-22 17:09:10 -07:00
Logan Yang
3c8420ae61
Stop rendering dataview result in AI response (#1947) 2025-10-21 11:50:14 -07:00
Zero Liu
3269943cc3
Improve custom command (#1942)
* Persist quick command configs

* upgrade langchain and fix gpt-5 in custom command

* Handle thinking in custom command

* code clean up

* Address cursor feedback
2025-10-20 17:52:50 -07:00
Wenzheng Jiang
49a28e3067
Enhance canvas creation spec with with JSON Canvas Spec (#1928)
* Enhance canvas file structure and validation in constants and tools

* Minor tweak on vault search tool

* Update integration tests
2025-10-16 16:50:45 -07:00
Zero Liu
dbec5f90e2
Properly render pills in custom command (#1927)
* Properly render pills in custom command

* Support tools as well
2025-10-16 16:42:13 -07:00
Wenzheng Jiang
6c818106ad
Turn autosaveChat ON by default (#1923) 2025-10-12 23:57:36 -07:00
Zero Liu
4df8af76a0
Sort notes in typeahead menu by creation time (#1922) 2025-10-12 23:56:46 -07:00
Logan Yang
b3fb645279
Implement tag list builtin tool (#1919) 2025-10-12 19:59:01 -07:00
Logan Yang
cea72d61b1
Support dataview result in active note (#1918) 2025-10-12 19:05:55 -07:00
Wenzheng Jiang
231d020fea
Turn on memory feature by default (#1914)
* Turn on memory feature by default

* Ensure default values for enableRecentConversations and enableSavedMemory settings are applied correctly
2025-10-12 12:19:59 -07:00
Logan Yang
800a3dbbf9
3.1.0 (#1911)
* 3.1.0

* Add experimental to Memory setting title
2025-10-11 08:22:10 -07:00
Logan Yang
19e5092759
Hide autocomplete setting for now (#1909)
* Hide autocomplete setting for now

* Add todos to search v3 doc
2025-10-10 22:50:34 -07:00
Logan Yang
5568b70e0f
Merge 3.1.0 preview (#1906)
* Building persistent memory for copilot (#1848)

* Implement chat input v3 (#1794)

* Fix chat crash React 409 (#1849)

* Fix mobile typeahead menu size (#1853)

* Enhance progress bar and bug fix (#1814)

* feat: Add edit context for progress card.
* fix: When adding a model, do not set the key in the single model setting.
* fix: fix the width of the popover on mobile.

* Refactor Brevilabs API integration to use models base URL (#1855)

- Updated constants to switch from BREVILABS_API_BASE_URL to BREVILABS_MODELS_BASE_URL for model-related API calls.
- Adjusted ChatModelManager and EmbeddingManager to utilize the new models base URL for configuration settings.

* feat: Add new chat history popover. (#1850)

* feat: Add new chat history popover.

* feat: Add open source file button to chat history popover

- Add ArrowUpRight button to each chat history item
- Implement openChatSourceFile method in main.ts
- Add onOpenSourceFile callback prop chain through components
- Open chat files in new Obsidian tabs when clicked
- Optimize error handling to prevent duplicate notices

* feat: Implement localSearch CiC prompting flow in CopilotPlusChainRunner (#1856)

* Properly extract response text in UserMemoryManager (#1857)

* feat: Temporarily disable autocomplete features (#1858)

* chore: Update version to 3.1.0-preview-250927 in manifest.json

* Support space in typeahead trigger and improve search (#1859)

* More chat input enhancement (#1864)

* Fix dropdown color
* Fix badge border in light theme
* Increase search result number
* support paste image
* fix folder context

* Enhance ChatPersistenceManager with filename sanitization tests (#1865)

- Added tests to ensure proper sanitization of wiki link brackets and illegal characters in filenames when saving chat messages.
- Updated filename generation logic to handle empty sanitized topics by defaulting to 'Untitled Chat'.
- Refactored imports in ChatPersistenceManager for better organization.

* Update ApplyView accept button styles for improved visibility and interaction (#1866)

- Adjusted the positioning of the action button to be further from the bottom of the viewport for better accessibility.
- Increased the z-index to ensure the button is always on top of other elements.
- Added a shadow effect to enhance the button's visibility against the background.

* Expose add selection to chat context to free users (#1867)

* New chat input improvements (#1868)

* Improve search logic in at mention search
* Subscribe to file changes
* Detect changes for folders and tags
* Make context badge tooltip always show
* Add full note path in preview
* Fix enter being blocked when no search result

* Rebuild "Active Note" and more chat input improvement (#1873)

* Performance improvement and extend "active note" to note typeahead menu (#1875)

* Add better agent prompt logging (#1882)

* Add read tool (#1883)

* Add readNote tool for reading notes in chunks

* Enhance readNote tool to support dynamic note path display and linked note extraction

* Refine readNote tool instructions for improved clarity and efficiency in note content retrieval

* Add support for readNote tool: integrate emoji, format results, and refine instructions

* Add inline citation reminder functionality to user questions

* Add an alert when user hits the maxToken limit (#1884)

* Refactor AutonomousAgentChainRunner (#1887)

* Refactor AutonomousAgentChainRunner to enhance agent workflow, streamline context preparation, and improve response handling

* Enhance type safety in addChatHistoryToMessages by specifying message structure

* Improve max iteration limit message for clarity and formatting

* Refactor tool display name handling for improved clarity and maintainability

* Refactor tool call ID generation and visibility handling for improved clarity and uniqueness

* Fix agent tool call ID (#1890)

* Enhance tool call ID generation and improve readNote handling in prompts

Update readNote description for clarity and improve prompt instructions

* Update instructions for registerFileTreeTool to clarify usage guidelines

* Clarify instructions for readNote tool to improve context inference and handling of partial note titles

* Add token counter (#1889)

* Fix index rebuild on semantic search toggle (#1891)

* Update token counter label (#1892)

* Implement tag search v3 (#1893)

* feat: Enhance TieredLexicalRetriever to support tag-based retrieval and improve search scoring

- Added support for returning all matching tags in TieredLexicalRetriever.
- Introduced new options for tag terms and returnAllTags in the retriever.
- Updated FullTextEngine to prioritize tag matches and improve scoring for documents with tags.
- Enhanced tokenization to handle hierarchical tags and prevent splitting hyphenated tags.
- Improved handling of frontmatter tags in documents.
- Updated search tools to accommodate new tag handling features.
- Added tests to verify the functionality of tag-based retrieval and scoring improvements.

* fix: Improve logging for query expansion in SearchCore

* feat: Add explanation for non-tag matches in FullTextEngine search results

* feat: Enhance QueryExpander to preserve standalone terms in tag handling and improve term validation

* feat: Enhance QueryExpander and TieredLexicalRetriever to improve tag handling and standalone term extraction

* Update version to 3.1.0-preview-251006 in manifest.json

* Normalize tag queries for case-insensitive matching and improve search functionality (#1894)

* Implement merge retriever (#1896)

* Fix note read (#1897)

* Enhance note resolution logic and add tests for wiki-linked notes and basename matching

* Implement note resolution outcome types and enhance readNoteTool tests for ambiguous matches

* Add deriveReadNoteDisplayName function and enhance readNoteTool tests for edge cases

* Fix note tool UI freeze (#1898)

* Update how tags work in context (#1895)

* Enhance file creation instructions in modelAdapter and update tool usage guidelines in builtinTools (#1901)

- Added instructions for confirming folder existence before creating new files in modelAdapter.
- Updated custom prompt instructions in builtinTools to clarify the use of getFileTree for folder lookups when creating new notes.

* Do not add url context for youtube url (#1899)

* Update YouTube Script command and modal title to indicate Plus feature (#1903)

* Enhance ChatPersistenceManager to handle file save conflicts (#1904)

* Enhance ChatPersistenceManager to handle file save conflicts and improve epoch handling

* Fix type checking for existing files in ChatPersistenceManager to prevent errors

* Fix verify add (#1905)

- Rename "Verify" button to "Test" in Add Model dialog
- Make verification not required for adding model in Set Keys
- Upgrade chatAnthropic client to fix the Top P -1 error for Claude Opus models

* Enhance XML parsing to handle tool calls missing closing tags

---------

Co-authored-by: Wenzheng Jiang <jwzh.hi@gmail.com>
Co-authored-by: Zero Liu <zero@lumos.com>
Co-authored-by: Emt-lin <41323133+Emt-lin@users.noreply.github.com>
2025-10-10 21:38:50 -07:00
Logan Yang
9327c7a916
Fix tool calls UI freeze (#1846)
* Fix tool call UI freeze
* Have no sources section rendered when there's none
2025-09-24 00:56:21 -07:00
Logan Yang
301b67e8b1
Fix chat save with instant title notice (#1845)
* Fix chat save AI-generated title parsing
* Make chat save instant with AI generated topic property
2025-09-23 21:29:40 -07:00
Logan Yang
97f3b5d2c4
Update model setting buttons (#1843)
* Add grok 4 fast openrouter

* Update model setting buttons
2025-09-22 20:13:03 -07:00
Logan Yang
7bed022d8a
fix: adjust vertical positioning in ModelTable component (#1840) 2025-09-22 19:34:40 -07:00
Emt-lin
86b7fcab88
feat: add mobile-responsive components for settings. (#1813)
* feat: add mobile-responsive components for settings.
* fix: Restrict HelpTooltip components to only affect mobile devices.
* fix: fix the args.diff case test.
2025-09-22 18:06:54 -07:00
Logan Yang
047d42c5a7
Update sources styling (#1838) 2025-09-22 17:19:17 -07:00
Logan Yang
feeea21127
Drop user and bot icons to save space and add shade to user message (#1837) 2025-09-22 14:22:52 -07:00
Logan Yang
09124e19e5
Add OpenRouter GPT-4.1 models to projects mode (#1832) 2025-09-22 00:39:58 -07:00
Logan Yang
dd7e9e185f
Refactor active note inclusion and index event handling to respect setting (#1831)
* Refactor active note inclusion logic

* Refactor IndexEventHandler to manage event listeners based on semantic search settings

- Introduced `shouldHandleEvents` method to determine if indexing-related events should be processed.
- Replaced `initializeEventListeners` with `syncEventListeners` to conditionally register listeners based on settings.
- Added `teardownEventListeners` method to clean up listeners and reset state when not needed.
- Subscribed to settings changes to dynamically manage event listeners.
2025-09-22 00:02:20 -07:00
Logan Yang
8076a0e171
Refactor constants and settings to enhance folder management (#1830)
* Refactor constants and settings to enhance folder management

- Introduced `COPILOT_FOLDER_ROOT` constant to streamline folder path definitions.
- Updated `DEFAULT_CHAT_HISTORY_FOLDER` and `DEFAULT_CUSTOM_PROMPTS_FOLDER` to use the new root constant for improved organization.
- Added `DEFAULT_QA_EXCLUSIONS_SETTING` to ensure consistent exclusion of the Copilot folder in QA settings.
- Implemented `sanitizeQaExclusions` function to normalize QA exclusion patterns, ensuring the Copilot folder is properly excluded from settings.

* Update log file management to reduce in-memory buffer size

- Decreased the in-memory ring buffer from 1000 to 500 entries to optimize memory usage.
- Adjusted documentation to reflect the new buffer size for clarity.
- Updated log truncation logic in BaseChainRunner to use a constant for maximum log length, enhancing maintainability.

* Add unit tests for sanitizeQaExclusions function

- Introduced a new test file `model.test.ts` to validate the behavior of the `sanitizeQaExclusions` function.
- Added tests to ensure proper handling of non-string values, distinct slash-only patterns, and normalization of trailing slashes.
- Enhanced the `sanitizeQaExclusions` function in `model.ts` to improve key handling and normalization logic for QA exclusion patterns.
2025-09-21 20:56:52 -07:00
Logan Yang
92d6f98af2
Implement inline citation (#1821)
* Implement inline citation for vault search for both vault QA and Plus chains

refactor: enhance citation utilities and improve source handling in chain runners

- Introduced new utility functions for citation management, including sanitization and formatting of source catalogs.
- Updated CopilotPlusChainRunner and VaultQAChainRunner to utilize the new citation utilities for improved citation handling.
- Enhanced ChatSingleMessage component to consolidate duplicate sources and ensure accurate citation numbering.
- Added comprehensive tests for citation utilities to ensure functionality and edge case handling.

refactor: dedupe chunks for unique titles in search tool sources

refactor: enhance citation handling in CopilotPlus and VaultQA chain runners

- Introduced a sanitization function to remove pre-existing citation markers from document content, preventing number leakage.
- Updated the formatting of retrieved documents in VaultQA to utilize the new sanitization function for cleaner output.
- Improved footnote renumbering logic in ChatSingleMessage to prioritize first-mention order, ensuring accurate citation mapping.

refactor: streamline source citation handling in ChatSingleMessage component and enhance web search tool instructions

- Simplified the processing of source links in ChatSingleMessage to use a more efficient mapping approach.
- Updated the web search tool's instruction to clarify the use of footnote-style citations, ensuring compatibility with Markdown formatting.

* feat: add inline citation setting toggle and refactor

- Introduced a new setting to enable inline citations in AI-generated responses, allowing for footnote-style references within the text.
- Updated citation utilities to manage fallback sources and improve citation instructions based on user settings.
- Enhanced CopilotPlusChainRunner and VaultQAChainRunner to utilize the new inline citation feature, ensuring accurate source representation.
- Modified ChatSingleMessage component to process inline citations based on the new setting, improving the display of sources in chat messages.
- Added tests for new citation functionalities to ensure reliability and correctness.

* feat: enhance citation utilities and add tests for normalization

- Introduced the `normalizeCitations` function to improve citation formatting by removing periods after citations and handling footnote references.
- Updated `processInlineCitations` to ensure correct mapping of non-sequential citations and consolidate duplicate sources.
- Added comprehensive tests for the new citation functionalities, ensuring accurate citation processing and representation in AI-generated responses.
- Modified QASettings description for clarity regarding the inline citations feature.

* fix: address critical bug in citation processing for consecutive citations

- Enhanced the `normalizeCitations` function to correctly handle consecutive citations without spaces, ensuring accurate mapping and representation in output.
- Added a test case to replicate and validate the fix for the identified bug, confirming that both citations are processed and displayed correctly.
- Updated existing citation handling logic to improve robustness and prevent unconverted citations in the output.

* refactor: improve citation handling and enhance citation utilities

- Refactored `CopilotPlusChainRunner` to streamline citation source management, replacing `lastCitationLines` with `lastCitationSources` for better clarity and structure.
- Updated the `addFallbackSources` function to handle citation formatting more effectively, ensuring proper display of titles and paths.
- Enhanced the `normalizeCitations` function to support multiple citations in brackets, ensuring correct sorting and mapping of citation numbers.
- Added new test cases to validate the handling of alternate headings, HTML summaries, and multiple citations, improving overall robustness of citation processing.
- Introduced `getWebSearchCitationInstructions` for web-specific citation guidance, enhancing user experience with clear instructions for inline citations.

* fix: move documentations

* refactor: normalize footnote rendering in ChatSingleMessage component

- Introduced `normalizeFootnoteRendering` function to streamline footnote display by removing separators and backreferences, and fixing numbering artifacts.
- Updated `ChatSingleMessage` to utilize the new normalization function, enhancing the clarity and presentation of footnotes in chat messages.
- Added unit tests for `normalizeFootnoteRendering` to ensure proper functionality and handling of various footnote scenarios.

* test: enhance ChatSingleMessage tests and add deduplication tests for search tools

- Updated `ChatSingleMessage.test.tsx` to include `TooltipProvider` for improved rendering context.
- Refactored mock implementation for `obsidian` to streamline testing setup.
- Introduced new test file `SearchTools.dedupe.test.ts` to validate the deduplication logic in search tool sources, ensuring correct handling of duplicate entries while preserving the highest score.
- Added tests to verify deduplication behavior for various scenarios, enhancing overall test coverage and reliability.
2025-09-21 20:03:09 -07:00
Wenzheng Jiang
a7c7823ba4
Map Copilot aliases to builtin tools (#1829) 2025-09-20 19:48:43 -07:00
Zero Liu
e3f232f795
Fix chat crash issue (#1827) 2025-09-19 14:37:29 -07:00
Wenzheng Jiang
b65600522e
FIX: Supporting creating new folders in composer tools (#1796)
* Create non-existent folder in composer tools

* Improve getFile
2025-09-15 17:28:19 -07:00
Logan Yang
b18782040e
feat: conditionally initialize VectorStoreManager and enhance relevant notes handling based on semantic search setting (#1817) 2025-09-12 18:26:18 -07:00
Logan Yang
0d477f869e
feat: enhance folder management by ensuring nested folder paths exist (#1816)
- Make sure nested folder works cross-platform
- Move defaults under copilot parent folder
- Update log file to only create on manual trigger
2025-09-12 16:30:30 -07:00
Logan Yang
5a2d4603b4
feat: add setting to generate AI chat title on save (#1811) 2025-09-11 18:36:40 -07:00
Logan Yang
b6da24d5ef
feat: move settings for context menu and markdown image handling to BasicSettings (#1810) 2025-09-11 16:50:22 -07:00
Logan Yang
5d93e6159d
Show embedding model (#1809) 2025-09-11 15:12:25 -07:00
Logan Yang
af5cc5ed19
feat: add search explanation table in log (#1805)
- Add search explanation table in log
- Clean up log for log file
- Implement open and clear log file commands
- Exclude log file from search (both lexical and semantic)
2025-09-11 01:05:34 -07:00
Emt-lin
3ddc42a9f1
fix: add safe area bottom padding to view content. (#1795) 2025-09-10 22:39:20 -07:00
Logan Yang
c033655b96
Implement log file (#1804) 2025-09-10 22:34:57 -07:00
Logan Yang
e50aa90187
Fix mobile embedded image passing (#1793)
- Replaced Buffer.from(...).toString("base64") with arrayBufferToBase64 in brevilabsClient, Chat, and ImageProcessor files for consistency and improved readability.
2025-09-10 18:08:51 -07:00
Emt-lin
0512e21471
fix: improve loading state management in project context updates. (#1787) 2025-09-05 12:38:00 -07:00
Emt-lin
946fb139ef
fix: Optimized the height of the modal box and the display of the close button on mobile devices. (#1786) 2025-09-05 12:10:14 -07:00
Zero Liu
bb8bbcb5d1
Only scroll to bottom when user messages are added (#1788) 2025-09-05 12:09:07 -07:00
Wenzheng Jiang
9239dab78a
Improve the regex for composer codeblock (#1778) 2025-09-03 13:51:34 -07:00
Wenzheng Jiang
ea66cfe56e
Switch to the new file when creating files with composer tools. (#1775)
* Switch to the new file when creating files with composer tools.

* Handle file creation race condition with improved error handling

Co-authored-by: jwzh.hi <jwzh.hi@gmail.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-08-30 22:55:36 -07:00
Logan Yang
8f6f98cdb1
Fix url processing with image false triggers (#1776)
- Implemented `extractNoteContent` method to gather content from `<note_context>` and `<active_note>` blocks, excluding `<url_content>`.
- Updated image processing logic to utilize extracted note content, ensuring relevant images are included when the `passMarkdownImages` setting is enabled.
2025-08-30 22:47:39 -07:00