mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
18 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
01a01e2951
|
fix(brevilabs): rewrite uploads via requestUrl multipart (W8/9) (#2399)
* fix(brevilabs): rewrite uploads via requestUrl multipart (W8/9) Ninth of nine source workspaces splitting #2397. Replaces native fetch(FormData) calls in brevilabsClient with Obsidian's requestUrl plus a manually-constructed multipart body. This is required because Obsidian's CORS-bypass path can't handle native FormData streams. - src/LLMProviders/brevilabsClient.ts: buildMultipartFromFormData helper builds a Uint8Array body with explicit boundary; uploads now flow through requestUrl with a Content-Type header that includes the boundary string - __mocks__/obsidian.js: requestUrl jest mock + __setRequestUrlImpl helper so tests can swap in per-case responses Manual verification required: image upload, PDF upload, audio transcription, error path. Plus license needed to exercise real uploads. W0 already merged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * chore(network): dedupe brevilabs response parsing + bound model-fetch timeout - Extract parseBrevilabsResponse helper so makeRequest and makeFormDataRequest share one parse/error path. - Wrap fetchModelsForProvider's safeFetch in a 10s Promise.race (safeFetch ignores AbortSignal, so a dead base URL could hang the model-import dialog forever). - Preserve real @/utils exports in selfHostServices test mock via jest.requireActual. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(lint): fix typescript-eslint violations in brevilabs + tests Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
d6255374cb
|
chore(deps): swap unmaintained/legacy deps per e18e module-replacements (#2447)
- npm-run-all → npm-run-all2 (dev script uses run-p) - lint-staged → nano-staged (config block + husky hook) - lodash.debounce → local src/utils/debounce.ts with cancel/flush/leading/trailing - dotenv → process.loadEnvFile in integration test bootstrap - eslint-plugin-react → @eslint-react/eslint-plugin (flat-config migration) - js-yaml → yaml (mock + jest CJS moduleNameMapper for jsdom) - crypto-js → pure-JS md5/sha256 in src/utils/hash.ts producing byte-identical digests so all on-disk cache keys (PDF, file, project, search index) remain valid across the upgrade — no migration or re-parse cost Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
710acc2436
|
chore(lint): enable obsidianmd/no-global-this and fix violations (#2413)
Removes the deferred `"off"` override and rewrites the 55 violations (all in test/mocks/Node-script files) to use `window.*` instead of `global.*`. Production code was already cleaned up in #2401. - 18 test files + __mocks__/obsidian.js + jest.setup.js: mechanical `global.X` → `window.X` (Jest runs under jsdom, so window === globalThis) - scripts/printPromptDebugEntry.ts: inline eslint-disable — Node-only debug script with no window available Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
17739cafa0
|
Enable basic obsidian eslint rules (#2410) | ||
|
|
15ac5844ed
|
fix(vault): respect user trash preference via FileManager.trashFile (W7/9) (#2405)
* fix(vault): respect user trash preference via FileManager.trashFile (W7/9) Eighth of nine workspaces splitting #2397. Intentional behavior change: file deletions now honor the user's Settings -> Files and links -> Deleted files preference (system trash / .trash / permanent), instead of unconditionally calling vault.delete(file, true). - src/utils/vaultAdapterUtils.ts: add trashFile(app, file) helper that casts past the missing app.fileManager.trashFile typedef. createSyntheticTFile now uses Object.create(TFile.prototype) so instanceof TFile returns true. - src/projects/ProjectFileManager.ts: constructor takes App instead of Vault; all vault.delete(file, true) -> trashFile(app, file). Project create rollback now trashes partial files (was permanent- delete before). - src/projects/projectRegister.ts: constructor takes App. - src/projects/projectMigration.ts: rollbackCreatedFile(app, ...), ensureProjectsMigratedIfNeeded(app), all delete sites use trashFile. - src/main.ts: deleteChatHistory uses trashFile; ProjectRegister constructed with this.app. - src/system-prompts/systemPromptManager.ts: prompt delete via trashFile. - src/commands/customCommandManager.ts: command delete via trashFile. - src/LLMProviders/projectManager.ts, src/components/Chat.tsx, src/components/chat-components/ProjectList.tsx: pass app (not vault) to ProjectFileManager.getInstance. - __mocks__/obsidian.js: app.fileManager.trashFile jest mock. - Tests updated to expect trashFile + App constructor arg. W0, W1, and #2402 already merged. Behavior change requires manual verification (test plan section 1 + 6). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * chore(manifest): bump minAppVersion to 1.4.0 FileManager.trashFile (used by the vault deletion helper introduced in W7/9) requires Obsidian 1.4+. Bumping minAppVersion ensures the plugin store only offers this and future releases to compatible app versions; users on older Obsidian builds stay on their current Copilot version instead of receiving an update that would crash on delete. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
c67c4fc200
|
fix(popout): document ownership and selection listener fixes (W4/9) (#2406)
* fix(popout): document ownership and selection listener fixes (W4/9) Fifth of nine workspaces splitting #2397. Real popout-window correctness fixes — semantic choices about which window owns a DOM operation, plus selection-listener captured-document fixes. - document → activeDocument where a generic active-window lookup is correct (SourcesModal, ChatViewLayout, ItemView/Notice mocks, TabContext, ChatInput keydown listener, CopilotView keyboard observer, TypeaheadMenuPortal, AddImageModal, and ?? document fallbacks across draggable-modal, menu-command-modal, CustomCommandChatModal, use-draggable, use-resizable, and QuickAskOverlay). - document → root.ownerDocument in ChatSingleMessage's linkInlineCitations so DOM nodes end up in the citation's window; same pattern in the processMessage streaming block via contentRef.current.ownerDocument. - New getEditorDocument(editor) helper in BasePillNode. createDOM and exportDOM now accept the LexicalEditor; pills create DOM in the editor's window (correct popout behavior). All 6 pill subclasses updated to match the new signature. - main.ts: selectionListenerDocument captured at listener registration; remove uses the same document (fixes leak when activeDocument has drifted before unload). - chatSelectionHighlightController.ts: getActiveViewOfType(MarkdownView) replaces the brittle activeLeaf type comparison. - Test setup: (window as any).activeDocument = window.document in ChatSingleMessage.test; window.document.createElement in AgentPrompt.test Notice mock. Behavior fix: chat in a popout window now creates DOM nodes in the popout's document, not the focused window's document. W0, W1, and #2402 already merged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix(popout): prefer element.doc/.win over ownerDocument and activeDocument Switch popout-window-sensitive call sites to Obsidian's `.doc` / `.win` augmentations so DOM ops, listeners, portals, and positioning follow the element's actual owner window. Recreate Lexical root on view migration to rebind input handling after a leaf moves between windows. Document the decision order in AGENTS.md and polyfill `Node.doc` / `Node.win` in jest.setup.js so tests still run under jsdom. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * improve image upload implementation --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> |
||
|
|
e470b5c70c
|
chore(types): tighten types and replace TFile/TFolder casts (W1/9) (#2403) | ||
|
|
506de5477b
|
feat: migrate project storage from data.json to vault files (#2324)
* feat: migrate project storage from data.json to vault files Migrate project definitions and metadata from data.json to individual markdown files in the vault's projects directory. - Project file manager with YAML frontmatter parsing and persistence - Migration logic from legacy data.json format with unsupported/ backup - Project UI components (AddProjectModal, ProjectList, ProgressCard) - Chat history integration for the new storage model - Status sorting, cache-first ordering, and URL removal in processing - Atomic cache operations to prevent transient disappearance on rename - Awaited context cache cleanup on all delete/rename/folder-switch paths - Raw-content-first frontmatter parsing to avoid stale metadataCache - BOM/CRLF support in frontmatter read and write helpers - Accessibility: aria-labels on all icon-only buttons * fix: address codex review feedback - Defer vault listener registration from constructor to initialize() to avoid premature cache mutations and frontmatter writes during initial vault load (before onLayoutReady). - Coerce numeric YAML project IDs to strings so bare numeric values like `copilot-project-id: 123` are not silently dropped. |
||
|
|
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> |
||
|
|
4884d9513d
|
Setup Prompt test for Agent (#1688)
* Implement autonomous agent mode and new message architecture - Implement autonomous agent mode with sequential thinking capabilities - Migrate from sharedState to new clean message management architecture - Add ChatManager, MessageRepository, and ContextManager for better separation of concerns - Implement project-based chat isolation with separate message repositories per project - Add ChatPersistenceManager for saving/loading chat history - Refactor chain runner architecture with specialized runners (Autonomous, Project, VaultQA) - Add XML tool call handling for better compatibility across LLM providers - Introduce vault and web search toggles in settings - Enhance model adapters with explicit tool usage instructions - Add comprehensive test coverage for new architecture components - Update UI components to use new ChatUIState instead of SharedState 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Enhance context processing and documentation - Added detailed XML structure for context notes, including metadata (creation and modification times) for notes and selected text. - Introduced new tests for message lifecycle and XML tag formatting to ensure proper context handling. - Created TODO.md to track technical debt and future improvements related to context processing and file handling. - Updated CLAUDE.md to reference the new TODO.md for technical debt awareness. This commit improves the clarity and functionality of context processing in messages, ensuring rich context is maintained throughout the message lifecycle. * Fix composer instruction in new message implementation * Add writeToFile tool to agent (#1632) * Add writeToFile tool call to agent * Update src/LLMProviders/chainRunner/AutonomousAgentChainRunner.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/tools/ComposerTools.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove unuseful comment --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix tests * Enhance context processing with new XML tags for notes and selected text (#1633) * Enhance context processing with new XML tags for notes and selected text - Introduced new constants for XML tags: SELECTED_TEXT_TAG, VARIABLE_TAG, VARIABLE_NOTE_TAG, EMBEDDED_PDF_TAG, VAULT_NOTE_TAG, and RETRIEVED_DOCUMENT_TAG. - Updated context processing to format embedded PDFs and notes with XML structure. - Modified prompt processing to include XML tags for selected text and variables, improving clarity and structure in generated outputs. - Enhanced tests to validate the new XML formatting in processed prompts. * Implement XML escaping utility functions and integrate into context processing - Added `escapeXml` and `escapeXmlAttribute` functions to handle XML special character escaping, enhancing security against XML injection. - Updated context processing to utilize these functions for escaping note titles, paths, and content, ensuring proper XML formatting. - Enhanced tests to validate XML escaping functionality across various scenarios, including selected text and variable names. - Introduced new test files for XML utility functions to ensure comprehensive coverage and reliability. * Refactor XML utility functions and update imports - Moved `escapeXml` and `escapeXmlAttribute` functions from `utils/xmlUtils` to `LLMProviders/chainRunner/utils/xmlParsing`, enhancing modularity. - Updated all relevant imports across the codebase to reflect the new location of XML utility functions. - Removed obsolete `xmlUtils` file and its associated tests, consolidating XML handling in a single module for better maintainability. * Add message creation callback in ChatManager for immediate UI updates (#1634) - Introduced a new method `setOnMessageCreatedCallback` in ChatManager to allow setting a callback that triggers when a message is created. - Updated ChatUIState to utilize this callback for notifying listeners, ensuring the UI updates immediately upon message creation. - This enhancement improves the responsiveness of the chat interface by synchronizing message creation events with UI state updates. * Enhance TimeTools tests for invalid expressions - Added setup to mock console.warn in tests for invalid time expressions. - Verified that the appropriate warning message is logged when parsing fails. - Improved test coverage for handling various invalid time inputs. * Refactor local search handling and restore sources display - Unified tool handling in CopilotPlusChainRunner to fix websearch results being ignored when localSearch has results - All tool outputs now go through the same prepareEnhancedUserMessage method - Preserved QA format and instruction when only localSearch is used - Added proper validation for localSearch results (non-empty documents array) - Maintained time expression support for temporal queries - Fixed source tracking and display in ChatUIState - Enhanced error handling for JSON parsing of search results * Enhance AutonomousAgentChainRunner to track tool calls and results (#1639) - Introduced a new property to store LLM-formatted messages for memory management. - Reset LLM messages at the start of each run to ensure fresh context. - Updated response handling to include LLM-formatted outputs, enhancing memory context for future iterations. - Modified the base class to accept an optional LLM-formatted output parameter for improved context saving. - Enhanced the writeToFile tool's response message for clarity on user actions. * Quick Command (cmd+k) (#1640) * Quick Command (cmd+k) * Update custom command modal style * Improve prompt * Use submenu for commands * Fix cursor comment * Align selected_text variable name * Fix embedded image wikilinks (#1641) - Updated the `extractEmbeddedImages` method to accept an optional `sourcePath` parameter for resolving wikilinks. - Implemented logic to determine the source path from context notes or fallback to the active file. - Enhanced logging for unresolved images to improve debugging and user feedback. - Ensured that embedded images are processed correctly based on the new source path handling. * Fix salient term language issue * Dedupe source notes (#1642) * Fix salient term language issue * Refactor source handling to include path in addition to title and score - Updated source structures across multiple classes to include a `path` property alongside `title` and `score`. - Modified methods in `AutonomousAgentChainRunner`, `BaseChainRunner`, and `CopilotPlusChainRunner` to accommodate the new source format. - Enhanced the `deduplicateSources` function to use `path` as the unique key, falling back to `title` if necessary. - Adjusted the `SourcesModal` to display paths correctly and ensure links open using the appropriate source path. - Updated type definitions in `message.ts` to reflect the new source structure. * Update path handling in source mapping for AutonomousAgentChainRunner - Modified the source mapping logic to ensure the `path` property defaults to an empty string if not provided, enhancing robustness in source data handling. - This change improves the consistency of source objects by ensuring that all properties are defined, which aids in downstream processing. * Bump manifest version to v3 * Fix image (#1643) * Fix salient term language issue * Bump manifest version to v3 * Fix image passing - Updated Chat, ChatManager, MessageRepository, and ChatUIState to include an optional `content` parameter in message handling. - Adjusted method signatures and message creation logic to accommodate the new parameter, improving flexibility in message processing. * Fix regenerate (#1644) * Fix image in agent chain (#1646) * Add YouTube transcription processing to AutonomousAgentChainRunner (#1647) - Implemented a new method to extract and process YouTube URLs from user messages. - Fetch transcriptions using the simpleYoutubeTranscriptionTool and handle errors gracefully. - Updated conversation messages to include fetched transcriptions for improved context in responses. * Disable quick command when live-mode is not on (#1648) * Do not call writeToFileTool again for accepted changes as well (#1652) * Trigger youtube tool only for urls in prompt not context (#1653) * Stop calling youtube tool in context notes in agent mode - Added a new instruction for handling YouTube URLs in the DEFAULT_SYSTEM_PROMPT. - Removed the direct usage of simpleYoutubeTranscriptionTool in the AutonomousAgentChainRunner, as YouTube transcriptions are now automatically processed. - Updated parameter naming conventions in modelAdapter for clarity and consistency. - Cleaned up the simpleYoutubeTranscriptionTool definition by removing unnecessary parameters. * Add agent loop limit message (#1655) * Add composer toggle and implement auto-preview (#1651) * Update composer output format to XML and refactor related components - Changed the output format for composer instructions from JSON to XML in `constants.ts`. - Updated `CopilotPlusChainRunner` to utilize the new XML format and adjusted streaming logic accordingly. - Added a toggle for the composer feature in `ChatInput.tsx` and updated UI elements to reflect this change. - Removed the `ComposerCodeBlock` component as it is no longer needed with the new implementation. - Cleaned up unused code and comments in `ChatSingleMessage.tsx` related to the previous composer handling. * Update src/constants.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/constants.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove redundant tests * Update doc * Refactor composer handling and implement ActionBlockStreamer - Replaced `ComposerBlockStreamer` with `ActionBlockStreamer` to handle `writeToFile` blocks more efficiently. - Updated `constants.ts` to reflect changes in output format for composer instructions. - Enhanced `ChatSingleMessage.tsx` to process `writeToFile` sections and integrate collapsible UI elements. - Removed the deprecated `ComposerBlockStreamer` and its associated tests. - Improved handling of XML codeblocks and unclosed tags during streaming. * Fix reported bugs * Refactor ActionBlockStreamer tests and implementation - Updated `processChunks` to always push content, including null and empty strings, to the output. - Adjusted test expectations to reflect changes in output handling for chunks with null content. - Simplified regex in `findCompleteBlock` method by removing XML format handling. * Fix reported issue --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix tool description generation (#1659) * Access tool description from zod.shape when zod.properties is missing. * Remove the access to schema.properties * Remove unused print * Also support schema.propertes * Implement SimpleTool and remove Langchain tool calling (#1662) * Make web search tool not overly eager * Use SimpleTool interface instead of langchain tool call - Replaced LangChain tool definitions with a new SimpleTool interface for better type safety and validation. - Updated existing tools (e.g., writeToFile, localSearch, webSearch, and YouTube transcription) to utilize the new createTool function. - Enhanced parameter extraction from Zod schemas for improved tool description generation. - Cleaned up related code and documentation to reflect the new tool structure and ensure consistency across the codebase. - Add tests * Update ChatManager tests to handle undefined context cases - Modified test cases in ChatManager to include handling of undefined context parameters. - Ensured that the tests accurately reflect scenarios where no active file exists and when context is undefined. - Improved overall test coverage for message processing in various contexts. * Add validation tests for tool schemas and improve schema definitions - Introduced comprehensive validation tests for tool schemas in `allTools.validation.test.ts` and `SearchTools.schema.test.ts` to ensure adherence to best practices and proper typing. - Enhanced `SearchTools.ts` by replacing `z.any()` with specific object schemas for `chatHistory` to improve type safety. - Added tests for various tool patterns, including metadata validation and schema best practices, ensuring tools are correctly defined and validated against expected interfaces. * Add back example content for canvas file in ComposerTools schema * Make web search tool not overly eager * Add license key in agent mode (#1663) * Add tool execution tests and implement Plus subscription checks (#1664) - Introduced unit tests for the `executeSequentialToolCall` function to validate tool execution behavior, including handling of Plus-only tools. - Enhanced `executeSequentialToolCall` to check for Plus subscription requirements before executing tools. - Updated `createTool` and `SimpleTool` interfaces to include an `isPlusOnly` flag, indicating tools that require a Copilot Plus subscription. - Marked existing tools (e.g., webSearch and YouTube transcription) as Plus-only where applicable. * Add timezone conversion tools and enhance current time functionality (#1665) * Add timezone conversion tools and enhance current time functionality - Introduced `convertTimeBetweenTimezonesTool` to allow conversion of time between different timezones. - Updated `getCurrentTimeTool` to accept an optional timezone parameter, improving its functionality to return time in specified timezones. - Enhanced documentation and added examples for both tools in the codebase. - Added comprehensive unit tests for the new timezone conversion functionality to ensure accuracy and reliability. * Enhance timezone functionality and add unit tests - Updated `getCurrentTime` and `convertToTimeInfo` functions to utilize Luxon's offset for accurate timezone calculations. - Adjusted timezone offset handling to reflect correct signs. - Added unit tests for Tokyo and New York timezone offsets to ensure accuracy in timezone calculations. * Add unit test for past time conversion in timezone tool - Introduced a new test case to verify that converting a past time (6:00 AM PT) to Tokyo correctly reflects the same day (January 15) without erroneously adding a day. - Updated the `convertTimeBetweenTimezones` function to ensure accurate handling of past times without unintended date shifts. * Enhance timezone handling and update related tests - Added `convertTimeBetweenTimezonesTool` to facilitate time conversion between different UTC offsets. - Updated `getCurrentTimeTool` to accept timezone offsets instead of names, improving accuracy and flexibility. - Enhanced error handling for invalid timezone offset formats and added comprehensive unit tests to validate new functionality. - Updated existing tests to reflect changes in timezone offset handling and ensure consistent behavior across various scenarios. * Refactor timezone handling in convertTimeBetweenTimezones function - Updated the creation of DateTime objects to interpret parsed dates as already being in the source timezone, improving clarity and accuracy in timezone conversions. * Fix image in chat history (#1666) * Refactor chat history handling to preserve multimodal content - Removed the deprecated `extractChatHistory` function and replaced it with direct access to raw history from memory, allowing for the preservation of multimodal content. - Updated `AutonomousAgentChainRunner`, `BaseChainRunner`, and `CopilotPlusChainRunner` to utilize `BaseMessage` objects for chat history, ensuring that both user and AI messages maintain their original structure and content. - Enhanced message processing to accommodate multimodal inputs, storing them appropriately for later use. * Refactor chat history handling to improve message processing - Introduced `addChatHistoryToMessages` utility to streamline the addition of chat history, ensuring safe handling of various message formats. - Updated `AutonomousAgentChainRunner` and `CopilotPlusChainRunner` to utilize the new utility, enhancing clarity and maintainability of the code. - Removed deprecated manual processing of chat history to improve code efficiency and readability. * Refactor chat history processing to enhance multimodal support - Removed the deprecated `extractChatHistory` function and replaced it with `processRawChatHistory` to ensure consistent handling of chat history. - Introduced `processedMessagesToTextOnly` function to extract text-only content from multimodal messages, improving clarity for question condensing. - Updated `CopilotPlusChainRunner` to utilize the new processing functions, ensuring that both LLM and question condensing use the same data format. - Added comprehensive unit tests for `processedMessagesToTextOnly` to validate its functionality across various message formats. * Refactor memory management in BaseChainRunner to enhance context saving - Removed the creation of `HumanMessage` and `AIMessage` objects for chat history, simplifying the process. - Implemented `saveContext` for atomic operations, ensuring proper memory management while preserving input and output data. - Noted that LangChain's memory now expects text content, which limits the saving of multimodal content. * Remove multimodal content storage from userMessage in AutonomousAgentChainRunner and CopilotPlusChainRunner to streamline message processing. This change aligns with recent refactors to enhance memory management and improve clarity in handling chat history. * Enhance ChatInput component with autonomous agent toggle button (#1669) - Added a toggle for the autonomous agent feature, allowing users to enable or disable it within the ChatInput component. - Updated the state management to synchronize the autonomous agent toggle with user settings. - Introduced a button for toggling the autonomous agent mode, which is only visible in Copilot Plus mode. - Refactored tool call logic to accommodate the new autonomous agent toggle, ensuring proper handling of tool calls based on the toggle state. * Implement custom topic in conversation history (#1670) * Refactor LoadChatHistoryModal and ChatPersistenceManager for enhanced topic handling - Updated LoadChatHistoryModal to prioritize custom topics from file frontmatter, falling back to filename extraction if not present. - Enhanced ChatPersistenceManager to generate AI topics for new chat files and preserve existing topics when updating files. - Introduced new methods for finding files by epoch and generating AI topics based on conversation content, improving chat file management and organization. * Refactor LoadChatHistoryModal and ChatPersistenceManager for improved topic handling - Updated LoadChatHistoryModal to ensure custom topics are trimmed and validated before use. - Enhanced ChatPersistenceManager to utilize reduce for efficient conversation summary generation, introducing constants for message and character limits to improve readability and maintainability. * Implement tool call UI banner (#1671) * Only add tool call to the user message when agent is off - Updated the tool call logic to only add tool calls when the autonomous agent toggle is off, ensuring that the autonomous agent manages all tools internally when enabled. - Improved code clarity by adding comments to explain the new logic. * Implement tool call collapsible UI element - Introduced a new utility for managing tool call markers, allowing for structured display and tracking of tool calls during execution. - Updated the AutonomousAgentChainRunner to utilize the new tool call markers, improving clarity in the streaming response and tool execution process. - Added a ToolCallBanner component for better visualization of tool calls in the chat interface, including execution status and results. - Refactored ChatSingleMessage to handle tool call updates dynamically, ensuring that the UI reflects the current state of tool calls. - Enhanced CSS for tool call containers and added animations for improved user experience. * Fix disappearing tool call in final response * Implement tool call result formatting - Updated ChatSingleMessage to use a stable ID for message roots, enhancing memory management and preventing leaks. - Implemented cleanup logic for old message roots to optimize performance. - Introduced ToolResultFormatter to format tool results for better display in the UI, ensuring user-friendly output for various tool types. - Enhanced ToolCallBanner to utilize the new formatter, improving the presentation of tool call results in the chat interface. * Add YouTube transcription tool in agent and avoid mistrigger from context - Replaced the deprecated simpleYoutubeTranscriptionTool with a new youtubeTranscriptionTool that automatically extracts YouTube URLs from user messages. - Removed the processYouTubeUrls method to streamline the handling of YouTube transcriptions. - Updated tool execution logic to pass the original user message to tools that require it, enhancing flexibility in tool usage. - Improved the ToolResultFormatter to support multi-URL responses and provide better error handling for transcription failures. - Enhanced documentation for YouTube transcription usage in the codebase. * Enhance ToolCallBanner and ToolResultFormatter for improved user experience - Added animation constants to ToolCallBanner for better visual feedback. - Updated ToolResultFormatter to robustly handle JSON parsing, improving error handling for both single objects and arrays. - Implemented input validation in YouTube transcription tool to prevent excessive input lengths and ensure proper data types. * Refactor tool execution messages and enhance JSON parsing in ToolResultFormatter - Updated the confirmation message for the writeToFile tool to be more concise. - Added a private method in ToolResultFormatter to robustly parse JSON strings, improving error handling and ensuring consistent results. - Streamlined the handling of search results by separating JSON parsing and regex extraction logic in ToolResultFormatter. - Enforced required user message content in the YouTube transcription tool to prevent potential errors. * Truncate long tool results for compact memory (#1672) * Truncate long tool results for compact memory - Introduced `processToolResults` utility to format tool results for different contexts, allowing for both truncated and full results. - Updated `AutonomousAgentChainRunner` to utilize the new utility for improved memory management and clarity in tool result presentation. - Added unit tests for `toolResultUtils` to ensure proper functionality of truncation and formatting methods, enhancing reliability and maintainability of tool result processing. * Enhance tool results handling in AutonomousAgentChainRunner - Added a conditional check to ensure that only non-null tool results are pushed to the llmFormattedMessages array, improving the robustness of message formatting and preventing potential errors from undefined values. * Add Agent settings section (#1676) * Add autonomous agent settings and tool configurations - Introduced settings for enabling the autonomous agent mode, including maximum iterations and available tools. - Updated the CopilotPlusSettings component to allow users to toggle tools like local search, web search, and YouTube transcription. - Enhanced the model adapter to utilize the new settings for tool management. * Enhance tool management by adding always available tools and updating tool usage guidelines in autonomous agent mode * Make filetree tool always available * Refactor tool management system to use a centralized ToolRegistry, enabling dynamic tool registration and configuration. Update settings structure to support enabled tool IDs and enhance UI for tool selection in the Copilot settings. * Initialize built-in tools with vault access and improve tool registration logic * Enhance documentation for initializeBuiltinTools function to clarify tool registration process and dynamic filtering of user-enabled tools. * fix: Fix the shouldIndexFile method to return all files when inclusions is empty in project mode. (#1667) * feat: Display all category items by default in the context-manage-modal. (#1657) * Remove escapingXML for context data (#1678) * Add apply command (#1677) * Implement ReplaceInFile tool (#1661) * Relevant note improvements (#1681) * Change message scrolling behavior (#1680) * Fix timetools and tests (#1683) * Refactor time tool descriptions for clarity and examples * Update XML escaping tests to reflect correct behavior and remove unnecessary settings mock * Strip partial tool call tag (#1682) * Strip partial tool call tag * Show a placeholder message * Remove perserveToolIndicators option * Add tool dynamic prompt (#1679) * feat: Enhance tool execution error messages and update custom prompt instructions for built-in tools * feat: Add unit tests for ModelAdapter and enhance tool instructions for time-based queries * feat: Implement detailed formatting for replaceInFile tool results * feat: Enhance GPT model instructions and refine replaceInFile tool usage guidelines * feat: Expand documentation on schema descriptions and custom instructions for tool usage * feat: Refine tool documentation by clarifying schema descriptions and custom prompt instructions * feat: Update GitHub Actions workflow to run on all pull requests regardless of target branch * Fix tests * feat: Update integration tests to validate writeToFile blocks and enhance replaceInFile usage example * Enhance image extraction logic to support both wiki-style and markdown image syntax (#1685) * Turn off agent when in Projects mode (#1686) * Remove think and action blocks from copy and insert (#1687) * Remove think and action blocks from copy, and fix composer for thinking models * Setup AgentTest with correct prompt and tools * Clean up * Add a few more tests and validate call order --------- Co-authored-by: Logan Yang <logancyang@gmail.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Zero Liu <zero@lumos.com> Co-authored-by: Emt-lin <41323133+Emt-lin@users.noreply.github.com> |
||
|
|
bc2d7f660a
|
Implement autonomous agent (#1689)
* Implement autonomous agent mode and new message architecture - Implement autonomous agent mode with sequential thinking capabilities - Migrate from sharedState to new clean message management architecture - Add ChatManager, MessageRepository, and ContextManager for better separation of concerns - Implement project-based chat isolation with separate message repositories per project - Add ChatPersistenceManager for saving/loading chat history - Refactor chain runner architecture with specialized runners (Autonomous, Project, VaultQA) - Add XML tool call handling for better compatibility across LLM providers - Introduce vault and web search toggles in settings - Enhance model adapters with explicit tool usage instructions - Add comprehensive test coverage for new architecture components - Update UI components to use new ChatUIState instead of SharedState 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Enhance context processing and documentation - Added detailed XML structure for context notes, including metadata (creation and modification times) for notes and selected text. - Introduced new tests for message lifecycle and XML tag formatting to ensure proper context handling. - Created TODO.md to track technical debt and future improvements related to context processing and file handling. - Updated CLAUDE.md to reference the new TODO.md for technical debt awareness. This commit improves the clarity and functionality of context processing in messages, ensuring rich context is maintained throughout the message lifecycle. * Fix composer instruction in new message implementation * Add writeToFile tool to agent (#1632) * Add writeToFile tool call to agent * Update src/LLMProviders/chainRunner/AutonomousAgentChainRunner.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/tools/ComposerTools.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove unuseful comment --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix tests * Enhance context processing with new XML tags for notes and selected text (#1633) * Enhance context processing with new XML tags for notes and selected text - Introduced new constants for XML tags: SELECTED_TEXT_TAG, VARIABLE_TAG, VARIABLE_NOTE_TAG, EMBEDDED_PDF_TAG, VAULT_NOTE_TAG, and RETRIEVED_DOCUMENT_TAG. - Updated context processing to format embedded PDFs and notes with XML structure. - Modified prompt processing to include XML tags for selected text and variables, improving clarity and structure in generated outputs. - Enhanced tests to validate the new XML formatting in processed prompts. * Implement XML escaping utility functions and integrate into context processing - Added `escapeXml` and `escapeXmlAttribute` functions to handle XML special character escaping, enhancing security against XML injection. - Updated context processing to utilize these functions for escaping note titles, paths, and content, ensuring proper XML formatting. - Enhanced tests to validate XML escaping functionality across various scenarios, including selected text and variable names. - Introduced new test files for XML utility functions to ensure comprehensive coverage and reliability. * Refactor XML utility functions and update imports - Moved `escapeXml` and `escapeXmlAttribute` functions from `utils/xmlUtils` to `LLMProviders/chainRunner/utils/xmlParsing`, enhancing modularity. - Updated all relevant imports across the codebase to reflect the new location of XML utility functions. - Removed obsolete `xmlUtils` file and its associated tests, consolidating XML handling in a single module for better maintainability. * Add message creation callback in ChatManager for immediate UI updates (#1634) - Introduced a new method `setOnMessageCreatedCallback` in ChatManager to allow setting a callback that triggers when a message is created. - Updated ChatUIState to utilize this callback for notifying listeners, ensuring the UI updates immediately upon message creation. - This enhancement improves the responsiveness of the chat interface by synchronizing message creation events with UI state updates. * Enhance TimeTools tests for invalid expressions - Added setup to mock console.warn in tests for invalid time expressions. - Verified that the appropriate warning message is logged when parsing fails. - Improved test coverage for handling various invalid time inputs. * Refactor local search handling and restore sources display - Unified tool handling in CopilotPlusChainRunner to fix websearch results being ignored when localSearch has results - All tool outputs now go through the same prepareEnhancedUserMessage method - Preserved QA format and instruction when only localSearch is used - Added proper validation for localSearch results (non-empty documents array) - Maintained time expression support for temporal queries - Fixed source tracking and display in ChatUIState - Enhanced error handling for JSON parsing of search results * Enhance AutonomousAgentChainRunner to track tool calls and results (#1639) - Introduced a new property to store LLM-formatted messages for memory management. - Reset LLM messages at the start of each run to ensure fresh context. - Updated response handling to include LLM-formatted outputs, enhancing memory context for future iterations. - Modified the base class to accept an optional LLM-formatted output parameter for improved context saving. - Enhanced the writeToFile tool's response message for clarity on user actions. * Quick Command (cmd+k) (#1640) * Quick Command (cmd+k) * Update custom command modal style * Improve prompt * Use submenu for commands * Fix cursor comment * Align selected_text variable name * Fix embedded image wikilinks (#1641) - Updated the `extractEmbeddedImages` method to accept an optional `sourcePath` parameter for resolving wikilinks. - Implemented logic to determine the source path from context notes or fallback to the active file. - Enhanced logging for unresolved images to improve debugging and user feedback. - Ensured that embedded images are processed correctly based on the new source path handling. * Fix salient term language issue * Dedupe source notes (#1642) * Fix salient term language issue * Refactor source handling to include path in addition to title and score - Updated source structures across multiple classes to include a `path` property alongside `title` and `score`. - Modified methods in `AutonomousAgentChainRunner`, `BaseChainRunner`, and `CopilotPlusChainRunner` to accommodate the new source format. - Enhanced the `deduplicateSources` function to use `path` as the unique key, falling back to `title` if necessary. - Adjusted the `SourcesModal` to display paths correctly and ensure links open using the appropriate source path. - Updated type definitions in `message.ts` to reflect the new source structure. * Update path handling in source mapping for AutonomousAgentChainRunner - Modified the source mapping logic to ensure the `path` property defaults to an empty string if not provided, enhancing robustness in source data handling. - This change improves the consistency of source objects by ensuring that all properties are defined, which aids in downstream processing. * Bump manifest version to v3 * Fix image (#1643) * Fix salient term language issue * Bump manifest version to v3 * Fix image passing - Updated Chat, ChatManager, MessageRepository, and ChatUIState to include an optional `content` parameter in message handling. - Adjusted method signatures and message creation logic to accommodate the new parameter, improving flexibility in message processing. * Fix regenerate (#1644) * Fix image in agent chain (#1646) * Add YouTube transcription processing to AutonomousAgentChainRunner (#1647) - Implemented a new method to extract and process YouTube URLs from user messages. - Fetch transcriptions using the simpleYoutubeTranscriptionTool and handle errors gracefully. - Updated conversation messages to include fetched transcriptions for improved context in responses. * Disable quick command when live-mode is not on (#1648) * Do not call writeToFileTool again for accepted changes as well (#1652) * Trigger youtube tool only for urls in prompt not context (#1653) * Stop calling youtube tool in context notes in agent mode - Added a new instruction for handling YouTube URLs in the DEFAULT_SYSTEM_PROMPT. - Removed the direct usage of simpleYoutubeTranscriptionTool in the AutonomousAgentChainRunner, as YouTube transcriptions are now automatically processed. - Updated parameter naming conventions in modelAdapter for clarity and consistency. - Cleaned up the simpleYoutubeTranscriptionTool definition by removing unnecessary parameters. * Add agent loop limit message (#1655) * Add composer toggle and implement auto-preview (#1651) * Update composer output format to XML and refactor related components - Changed the output format for composer instructions from JSON to XML in `constants.ts`. - Updated `CopilotPlusChainRunner` to utilize the new XML format and adjusted streaming logic accordingly. - Added a toggle for the composer feature in `ChatInput.tsx` and updated UI elements to reflect this change. - Removed the `ComposerCodeBlock` component as it is no longer needed with the new implementation. - Cleaned up unused code and comments in `ChatSingleMessage.tsx` related to the previous composer handling. * Update src/constants.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/constants.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove redundant tests * Update doc * Refactor composer handling and implement ActionBlockStreamer - Replaced `ComposerBlockStreamer` with `ActionBlockStreamer` to handle `writeToFile` blocks more efficiently. - Updated `constants.ts` to reflect changes in output format for composer instructions. - Enhanced `ChatSingleMessage.tsx` to process `writeToFile` sections and integrate collapsible UI elements. - Removed the deprecated `ComposerBlockStreamer` and its associated tests. - Improved handling of XML codeblocks and unclosed tags during streaming. * Fix reported bugs * Refactor ActionBlockStreamer tests and implementation - Updated `processChunks` to always push content, including null and empty strings, to the output. - Adjusted test expectations to reflect changes in output handling for chunks with null content. - Simplified regex in `findCompleteBlock` method by removing XML format handling. * Fix reported issue --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix tool description generation (#1659) * Access tool description from zod.shape when zod.properties is missing. * Remove the access to schema.properties * Remove unused print * Also support schema.propertes * Implement SimpleTool and remove Langchain tool calling (#1662) * Make web search tool not overly eager * Use SimpleTool interface instead of langchain tool call - Replaced LangChain tool definitions with a new SimpleTool interface for better type safety and validation. - Updated existing tools (e.g., writeToFile, localSearch, webSearch, and YouTube transcription) to utilize the new createTool function. - Enhanced parameter extraction from Zod schemas for improved tool description generation. - Cleaned up related code and documentation to reflect the new tool structure and ensure consistency across the codebase. - Add tests * Update ChatManager tests to handle undefined context cases - Modified test cases in ChatManager to include handling of undefined context parameters. - Ensured that the tests accurately reflect scenarios where no active file exists and when context is undefined. - Improved overall test coverage for message processing in various contexts. * Add validation tests for tool schemas and improve schema definitions - Introduced comprehensive validation tests for tool schemas in `allTools.validation.test.ts` and `SearchTools.schema.test.ts` to ensure adherence to best practices and proper typing. - Enhanced `SearchTools.ts` by replacing `z.any()` with specific object schemas for `chatHistory` to improve type safety. - Added tests for various tool patterns, including metadata validation and schema best practices, ensuring tools are correctly defined and validated against expected interfaces. * Add back example content for canvas file in ComposerTools schema * Make web search tool not overly eager * Add license key in agent mode (#1663) * Add tool execution tests and implement Plus subscription checks (#1664) - Introduced unit tests for the `executeSequentialToolCall` function to validate tool execution behavior, including handling of Plus-only tools. - Enhanced `executeSequentialToolCall` to check for Plus subscription requirements before executing tools. - Updated `createTool` and `SimpleTool` interfaces to include an `isPlusOnly` flag, indicating tools that require a Copilot Plus subscription. - Marked existing tools (e.g., webSearch and YouTube transcription) as Plus-only where applicable. * Add timezone conversion tools and enhance current time functionality (#1665) * Add timezone conversion tools and enhance current time functionality - Introduced `convertTimeBetweenTimezonesTool` to allow conversion of time between different timezones. - Updated `getCurrentTimeTool` to accept an optional timezone parameter, improving its functionality to return time in specified timezones. - Enhanced documentation and added examples for both tools in the codebase. - Added comprehensive unit tests for the new timezone conversion functionality to ensure accuracy and reliability. * Enhance timezone functionality and add unit tests - Updated `getCurrentTime` and `convertToTimeInfo` functions to utilize Luxon's offset for accurate timezone calculations. - Adjusted timezone offset handling to reflect correct signs. - Added unit tests for Tokyo and New York timezone offsets to ensure accuracy in timezone calculations. * Add unit test for past time conversion in timezone tool - Introduced a new test case to verify that converting a past time (6:00 AM PT) to Tokyo correctly reflects the same day (January 15) without erroneously adding a day. - Updated the `convertTimeBetweenTimezones` function to ensure accurate handling of past times without unintended date shifts. * Enhance timezone handling and update related tests - Added `convertTimeBetweenTimezonesTool` to facilitate time conversion between different UTC offsets. - Updated `getCurrentTimeTool` to accept timezone offsets instead of names, improving accuracy and flexibility. - Enhanced error handling for invalid timezone offset formats and added comprehensive unit tests to validate new functionality. - Updated existing tests to reflect changes in timezone offset handling and ensure consistent behavior across various scenarios. * Refactor timezone handling in convertTimeBetweenTimezones function - Updated the creation of DateTime objects to interpret parsed dates as already being in the source timezone, improving clarity and accuracy in timezone conversions. * Fix image in chat history (#1666) * Refactor chat history handling to preserve multimodal content - Removed the deprecated `extractChatHistory` function and replaced it with direct access to raw history from memory, allowing for the preservation of multimodal content. - Updated `AutonomousAgentChainRunner`, `BaseChainRunner`, and `CopilotPlusChainRunner` to utilize `BaseMessage` objects for chat history, ensuring that both user and AI messages maintain their original structure and content. - Enhanced message processing to accommodate multimodal inputs, storing them appropriately for later use. * Refactor chat history handling to improve message processing - Introduced `addChatHistoryToMessages` utility to streamline the addition of chat history, ensuring safe handling of various message formats. - Updated `AutonomousAgentChainRunner` and `CopilotPlusChainRunner` to utilize the new utility, enhancing clarity and maintainability of the code. - Removed deprecated manual processing of chat history to improve code efficiency and readability. * Refactor chat history processing to enhance multimodal support - Removed the deprecated `extractChatHistory` function and replaced it with `processRawChatHistory` to ensure consistent handling of chat history. - Introduced `processedMessagesToTextOnly` function to extract text-only content from multimodal messages, improving clarity for question condensing. - Updated `CopilotPlusChainRunner` to utilize the new processing functions, ensuring that both LLM and question condensing use the same data format. - Added comprehensive unit tests for `processedMessagesToTextOnly` to validate its functionality across various message formats. * Refactor memory management in BaseChainRunner to enhance context saving - Removed the creation of `HumanMessage` and `AIMessage` objects for chat history, simplifying the process. - Implemented `saveContext` for atomic operations, ensuring proper memory management while preserving input and output data. - Noted that LangChain's memory now expects text content, which limits the saving of multimodal content. * Remove multimodal content storage from userMessage in AutonomousAgentChainRunner and CopilotPlusChainRunner to streamline message processing. This change aligns with recent refactors to enhance memory management and improve clarity in handling chat history. * Enhance ChatInput component with autonomous agent toggle button (#1669) - Added a toggle for the autonomous agent feature, allowing users to enable or disable it within the ChatInput component. - Updated the state management to synchronize the autonomous agent toggle with user settings. - Introduced a button for toggling the autonomous agent mode, which is only visible in Copilot Plus mode. - Refactored tool call logic to accommodate the new autonomous agent toggle, ensuring proper handling of tool calls based on the toggle state. * Implement custom topic in conversation history (#1670) * Refactor LoadChatHistoryModal and ChatPersistenceManager for enhanced topic handling - Updated LoadChatHistoryModal to prioritize custom topics from file frontmatter, falling back to filename extraction if not present. - Enhanced ChatPersistenceManager to generate AI topics for new chat files and preserve existing topics when updating files. - Introduced new methods for finding files by epoch and generating AI topics based on conversation content, improving chat file management and organization. * Refactor LoadChatHistoryModal and ChatPersistenceManager for improved topic handling - Updated LoadChatHistoryModal to ensure custom topics are trimmed and validated before use. - Enhanced ChatPersistenceManager to utilize reduce for efficient conversation summary generation, introducing constants for message and character limits to improve readability and maintainability. * Implement tool call UI banner (#1671) * Only add tool call to the user message when agent is off - Updated the tool call logic to only add tool calls when the autonomous agent toggle is off, ensuring that the autonomous agent manages all tools internally when enabled. - Improved code clarity by adding comments to explain the new logic. * Implement tool call collapsible UI element - Introduced a new utility for managing tool call markers, allowing for structured display and tracking of tool calls during execution. - Updated the AutonomousAgentChainRunner to utilize the new tool call markers, improving clarity in the streaming response and tool execution process. - Added a ToolCallBanner component for better visualization of tool calls in the chat interface, including execution status and results. - Refactored ChatSingleMessage to handle tool call updates dynamically, ensuring that the UI reflects the current state of tool calls. - Enhanced CSS for tool call containers and added animations for improved user experience. * Fix disappearing tool call in final response * Implement tool call result formatting - Updated ChatSingleMessage to use a stable ID for message roots, enhancing memory management and preventing leaks. - Implemented cleanup logic for old message roots to optimize performance. - Introduced ToolResultFormatter to format tool results for better display in the UI, ensuring user-friendly output for various tool types. - Enhanced ToolCallBanner to utilize the new formatter, improving the presentation of tool call results in the chat interface. * Add YouTube transcription tool in agent and avoid mistrigger from context - Replaced the deprecated simpleYoutubeTranscriptionTool with a new youtubeTranscriptionTool that automatically extracts YouTube URLs from user messages. - Removed the processYouTubeUrls method to streamline the handling of YouTube transcriptions. - Updated tool execution logic to pass the original user message to tools that require it, enhancing flexibility in tool usage. - Improved the ToolResultFormatter to support multi-URL responses and provide better error handling for transcription failures. - Enhanced documentation for YouTube transcription usage in the codebase. * Enhance ToolCallBanner and ToolResultFormatter for improved user experience - Added animation constants to ToolCallBanner for better visual feedback. - Updated ToolResultFormatter to robustly handle JSON parsing, improving error handling for both single objects and arrays. - Implemented input validation in YouTube transcription tool to prevent excessive input lengths and ensure proper data types. * Refactor tool execution messages and enhance JSON parsing in ToolResultFormatter - Updated the confirmation message for the writeToFile tool to be more concise. - Added a private method in ToolResultFormatter to robustly parse JSON strings, improving error handling and ensuring consistent results. - Streamlined the handling of search results by separating JSON parsing and regex extraction logic in ToolResultFormatter. - Enforced required user message content in the YouTube transcription tool to prevent potential errors. * Truncate long tool results for compact memory (#1672) * Truncate long tool results for compact memory - Introduced `processToolResults` utility to format tool results for different contexts, allowing for both truncated and full results. - Updated `AutonomousAgentChainRunner` to utilize the new utility for improved memory management and clarity in tool result presentation. - Added unit tests for `toolResultUtils` to ensure proper functionality of truncation and formatting methods, enhancing reliability and maintainability of tool result processing. * Enhance tool results handling in AutonomousAgentChainRunner - Added a conditional check to ensure that only non-null tool results are pushed to the llmFormattedMessages array, improving the robustness of message formatting and preventing potential errors from undefined values. * Add Agent settings section (#1676) * Add autonomous agent settings and tool configurations - Introduced settings for enabling the autonomous agent mode, including maximum iterations and available tools. - Updated the CopilotPlusSettings component to allow users to toggle tools like local search, web search, and YouTube transcription. - Enhanced the model adapter to utilize the new settings for tool management. * Enhance tool management by adding always available tools and updating tool usage guidelines in autonomous agent mode * Make filetree tool always available * Refactor tool management system to use a centralized ToolRegistry, enabling dynamic tool registration and configuration. Update settings structure to support enabled tool IDs and enhance UI for tool selection in the Copilot settings. * Initialize built-in tools with vault access and improve tool registration logic * Enhance documentation for initializeBuiltinTools function to clarify tool registration process and dynamic filtering of user-enabled tools. * fix: Fix the shouldIndexFile method to return all files when inclusions is empty in project mode. (#1667) * feat: Display all category items by default in the context-manage-modal. (#1657) * Remove escapingXML for context data (#1678) * Add apply command (#1677) * Implement ReplaceInFile tool (#1661) * Relevant note improvements (#1681) * Change message scrolling behavior (#1680) * Fix timetools and tests (#1683) * Refactor time tool descriptions for clarity and examples * Update XML escaping tests to reflect correct behavior and remove unnecessary settings mock * Strip partial tool call tag (#1682) * Strip partial tool call tag * Show a placeholder message * Remove perserveToolIndicators option * Add tool dynamic prompt (#1679) * feat: Enhance tool execution error messages and update custom prompt instructions for built-in tools * feat: Add unit tests for ModelAdapter and enhance tool instructions for time-based queries * feat: Implement detailed formatting for replaceInFile tool results * feat: Enhance GPT model instructions and refine replaceInFile tool usage guidelines * feat: Expand documentation on schema descriptions and custom instructions for tool usage * feat: Refine tool documentation by clarifying schema descriptions and custom prompt instructions * feat: Update GitHub Actions workflow to run on all pull requests regardless of target branch * Fix tests * feat: Update integration tests to validate writeToFile blocks and enhance replaceInFile usage example * Enhance image extraction logic to support both wiki-style and markdown image syntax (#1685) * Turn off agent when in Projects mode (#1686) * Remove think and action blocks from copy and insert (#1687) * Remove think and action blocks from copy, and fix composer for thinking models * Refactor ToolSettingsSection layout for improved readability and consistency --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: wenzhengjiang <jwzh.hi@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Zero Liu <zero@lumos.com> Co-authored-by: Emt-lin <41323133+Emt-lin@users.noreply.github.com> |
||
|
|
b79b8d0a38
|
Migrate chat messages (#1629)
* Migrate from sharedState to new chat message system - Replaced SharedState with a new ChatManager and ChatUIState architecture to streamline message processing and UI integration. - Updated message imports to utilize the new types from "@/types/message". - Introduced unique message IDs for better tracking and management. - Enhanced the Chat component to support pending messages and improved message deletion logic. - Removed deprecated shared state references and cleaned up related code for clarity and maintainability. Enhance message management architecture and context processing - Introduced a new MessageRepository for single source of truth in message storage, eliminating dual-array synchronization. - Updated ChatManager to coordinate message operations and context processing, ensuring fresh context during edits. - Refactored ChatUIState for clean UI state management, delegating business logic to ChatManager. - Added comprehensive testing for message handling and context processing to prevent bugs and ensure reliability. - Removed legacy SharedState references and improved overall architecture for clarity and maintainability. Update claude.md Remove conditional project tag from chat content rendering in Chat component Ensure project chat isolation - Introduced a method to retrieve the current project ID in ProjectManager. - Enhanced ChatManager to manage multiple project-specific message repositories, allowing for dynamic switching based on the current project. - Implemented logic to load existing messages from the ProjectManager's cache when creating new message repositories. - Updated message handling methods in ChatManager to utilize the current project's message repository, ensuring context consistency across project switches. * Fix message isolation between projects and non-project - Introduced ChatManager and ChatUIState to streamline message processing and UI updates. - Removed legacy message caching from ProjectManager, delegating message persistence to ChatManager. - Updated CopilotView and Chat components to utilize the new architecture, enhancing message loading and project switching. - Cleaned up deprecated code related to pending messages and shared state for improved maintainability. * Implement a new chat persistence module - Introduced ChatPersistenceManager to handle saving and loading chat history in markdown format, ensuring project-aware file naming. - Updated ChatManager to utilize the new persistence functionality, streamlining message loading and saving processes. - Refactored ChatUIState to support asynchronous loading and saving of messages, improving UI responsiveness. - Added comprehensive tests for ChatPersistenceManager to ensure reliability in chat content formatting and parsing. - Updated architecture documentation to reflect the new message management structure and flow. * Update message management architecture doc - Removed detailed architecture diagrams from CLAUDE.md and linked to MESSAGE_ARCHITECTURE.md for clarity. - Updated MESSAGE_ARCHITECTURE.md to include project isolation features, enhancing the message management system. - Improved documentation on message flow and project-specific repositories, ensuring seamless context switching. - Streamlined the explanation of core classes and their interactions within the new architecture. * Fix test * Use llm message for commands to ensure context access * Update docs |
||
|
|
321193993c
|
Format code (#521) | ||
|
|
bff586f784
|
Add gpt 4o mini (#486) | ||
|
|
17f41500f3
|
Fix frontmatter parsing and make tags case insensitive (#351) | ||
|
|
b0d427b408
|
Implement encryption and add tests (#306) | ||
|
|
8ceadc2372
|
First version of chat context filter by tags (#291) | ||
|
|
65f62513e0
|
Pass multiple notes to prompt by setting folder as context using Copilot command (#265) |