bear-notes-mcp 2.8.0 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.js CHANGED
@@ -1,4 +1,4 @@
1
- export const APP_VERSION = '2.8.0';
1
+ export const APP_VERSION = '2.8.1';
2
2
  export const BEAR_URL_SCHEME = 'bear://x-callback-url/';
3
3
  export const CORE_DATA_EPOCH_OFFSET = 978307200; // 2001-01-01 to Unix epoch
4
4
  export const DEFAULT_SEARCH_LIMIT = 50;
package/dist/main.js CHANGED
@@ -52,11 +52,27 @@ Use bear-search-notes to find the correct note identifier.`);
52
52
  `ID: ${noteWithContent.identifier}`,
53
53
  ];
54
54
  const noteText = noteWithContent.text || '*This note appears to be empty.*';
55
- return createToolResponse(`${noteInfo.join('\n')}
56
-
57
- ---
58
-
59
- ${noteText}`);
55
+ const annotations = { audience: ['user', 'assistant'] };
56
+ // Body and file metadata are separate content blocks so the synthetic
57
+ // file section can never leak back during write operations (#86)
58
+ const content = [
59
+ {
60
+ type: 'text',
61
+ text: `${noteInfo.join('\n')}\n\n---\n\n${noteText}`,
62
+ annotations,
63
+ },
64
+ ];
65
+ if (noteWithContent.files?.length) {
66
+ const fileEntries = noteWithContent.files
67
+ .map((f) => `## ${f.filename}\n\n${f.content}`)
68
+ .join('\n\n---\n\n');
69
+ content.push({
70
+ type: 'text',
71
+ text: `# Attached Files\n\n${fileEntries}`,
72
+ annotations,
73
+ });
74
+ }
75
+ return { content };
60
76
  }
61
77
  catch (error) {
62
78
  logger.error('bear-open-note failed:', error);
package/dist/notes.js CHANGED
@@ -91,8 +91,9 @@ export function getNoteContent(identifier) {
91
91
  // Process multiple rows (note + files) into single note object
92
92
  const firstRow = rows[0];
93
93
  const formattedNote = formatBearNote(firstRow);
94
- // Collect file content from all rows with clear source labeling
95
- const fileContents = [];
94
+ // Collect file content into a structured array kept separate from note text
95
+ // to prevent the synthetic file section from leaking into write operations (#86)
96
+ const files = [];
96
97
  for (const row of rows) {
97
98
  const rowData = row;
98
99
  const filename = rowData.filename;
@@ -102,21 +103,13 @@ export function getNoteContent(identifier) {
102
103
  const content = trimmed
103
104
  ? trimmed
104
105
  : '*[File content not available — Bear has not extracted text from this file type]*';
105
- fileContents.push(`##${filename}\n\n${content}`);
106
+ files.push({ filename, content });
106
107
  }
107
108
  }
108
- // Always append file content section, even if empty, to show structure
109
- const originalText = formattedNote.text || '';
110
- const filesSectionHeader = '\n\n---\n\n#Attached Files\n\n';
111
- if (fileContents.length > 0) {
112
- const fileSection = `${filesSectionHeader}${fileContents.join('\n\n---\n\n')}`;
113
- formattedNote.text = originalText + fileSection;
109
+ if (files.length > 0) {
110
+ formattedNote.files = files;
114
111
  }
115
- else {
116
- // Add a note that no files are attached for clarity
117
- formattedNote.text = originalText + `${filesSectionHeader}*No files attached to this note.*`;
118
- }
119
- logger.info(`Retrieved note content with ${fileContents.length} attached files for: ${formattedNote.title}`);
112
+ logger.info(`Retrieved note content with ${files.length} attached files for: ${formattedNote.title}`);
120
113
  return formattedNote;
121
114
  }
122
115
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bear-notes-mcp",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "description": "Bear Notes MCP server with TypeScript and native SQLite",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",