-
Notifications
You must be signed in to change notification settings - Fork 9
feat: inject live notebook names into tool descriptions and add graceful fallback #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
autojack-bot
wants to merge
4
commits into
main
Choose a base branch
from
feat/notebook-aware-descriptions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a785e25
feat: inject live notebook names into tool descriptions and add grace…
autojack-bot[bot] 8bb17ad
chore: suppress dotenv verbose logging across all entrypoints
autojack-bot[bot] 2743533
fix(notebooks): load notebook cache during tool discovery
jack-arturo 79f6a76
fix(notebooks): address copilot review on PR #45
jack-arturo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { readFileSync } from 'fs'; | ||
| import { resolve } from 'path'; | ||
|
|
||
| const runtimeEntrypoints = [ | ||
| ['MCP stdio server', '../../src/index.ts'], | ||
| ['standalone auth CLI', '../../src/auth-standalone.ts'], | ||
| ['Claude install helper', '../../scripts/install-to-claude.js'], | ||
| ] as const; | ||
|
|
||
| describe('dotenv runtime logging', () => { | ||
| it.each(runtimeEntrypoints)('%s loads dotenv quietly', (_name, relativePath) => { | ||
| const source = readFileSync(resolve(__dirname, relativePath), 'utf-8'); | ||
|
|
||
| expect(source).toContain('config({ quiet: true })'); | ||
| expect(source).not.toMatch(/\bconfig\(\s*\)/); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import { describe, expect, it, jest } from '@jest/globals'; | ||
| import { | ||
| enrichToolsWithNotebookDescriptions, | ||
| resolveNotebookCacheForToolDescriptions, | ||
| } from '../../src/notebook-tool-descriptions'; | ||
|
|
||
| const baseTools = [ | ||
| { | ||
| name: 'evernote_create_note', | ||
| description: 'Create a note', | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { | ||
| title: { type: 'string', description: 'Title' }, | ||
| notebookName: { type: 'string', description: 'Name of notebook' }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: 'evernote_update_note', | ||
| description: 'Update a note', | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { | ||
| guid: { type: 'string', description: 'GUID' }, | ||
| notebookName: { type: 'string', description: 'Move note to this notebook' }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: 'evernote_search_notes', | ||
| description: 'Search notes', | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { | ||
| query: { type: 'string', description: 'Query' }, | ||
| }, | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| const notebooks = [ | ||
| { guid: 'personal-guid', name: 'Personal', defaultNotebook: true }, | ||
| { guid: 'work-guid', name: 'Work' }, | ||
| ]; | ||
|
|
||
| describe('notebook-aware tool descriptions', () => { | ||
| it('loads notebooks through ensureAPI when tool discovery happens before any tool call', async () => { | ||
| const api = {}; | ||
| const ensureAPI = jest.fn<() => Promise<object>>().mockResolvedValue(api); | ||
| const refreshNotebookCache = jest | ||
| .fn<(evernoteApi: object) => Promise<typeof notebooks>>() | ||
| .mockResolvedValue(notebooks); | ||
|
|
||
| const result = await resolveNotebookCacheForToolDescriptions({ | ||
| currentCache: null, | ||
| currentApi: null, | ||
| ensureAPI, | ||
| refreshNotebookCache, | ||
| logError: jest.fn(), | ||
| }); | ||
|
|
||
| expect(ensureAPI).toHaveBeenCalledTimes(1); | ||
| expect(refreshNotebookCache).toHaveBeenCalledWith(api); | ||
| expect(result).toEqual(notebooks); | ||
| }); | ||
|
|
||
| it('keeps tool discovery available when API initialization fails', async () => { | ||
| const ensureAPI = jest.fn<() => Promise<object>>().mockRejectedValue(new Error('auth failed')); | ||
| const refreshNotebookCache = jest.fn<(evernoteApi: object) => Promise<typeof notebooks>>(); | ||
|
|
||
| const result = await resolveNotebookCacheForToolDescriptions({ | ||
| currentCache: null, | ||
| currentApi: null, | ||
| ensureAPI, | ||
| refreshNotebookCache, | ||
| logError: jest.fn(), | ||
| }); | ||
|
|
||
| expect(result).toBeNull(); | ||
| expect(refreshNotebookCache).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('injects live notebook names into create and update tool schemas', () => { | ||
| const enriched = enrichToolsWithNotebookDescriptions(baseTools as any, notebooks); | ||
| const createNoteTool = enriched.find((tool: any) => tool.name === 'evernote_create_note')!; | ||
| const updateNoteTool = enriched.find((tool: any) => tool.name === 'evernote_update_note')!; | ||
| const searchTool = enriched.find((tool: any) => tool.name === 'evernote_search_notes')!; | ||
| const createNotebookDescription = (createNoteTool.inputSchema as any).properties.notebookName.description; | ||
| const updateNotebookDescription = (updateNoteTool.inputSchema as any).properties.notebookName.description; | ||
|
|
||
| expect(createNotebookDescription).toContain( | ||
| 'Available notebooks: "Personal", "Work".', | ||
| ); | ||
| expect(createNotebookDescription).toContain( | ||
| 'Default: "Personal".', | ||
| ); | ||
| expect(updateNotebookDescription).toBe(createNotebookDescription); | ||
| expect((searchTool.inputSchema as any).properties).not.toHaveProperty('notebookName'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.