feat: final schema pass — sync 9 schema changes from main repo

- Rename nodes.content → nodes.notes across all services, tools, API routes, and UI
- Add dimensions.icon column support (GET/POST routes, types)
- Add nodes.event_date column (create/update flows, types)
- Drop nodes.type and nodes.is_pinned references
- Drop edges.user_feedback references
- Drop chat_memory_state table (replaced with DROP IF EXISTS in migration)
- Update schema guide files (system/schema.md)
- Add runtime migration block in sqlite-client.ts for existing databases
- Fix MCP tool schemas (external API keeps 'content' param, maps to 'notes' internally)
- Update standalone MCP server (nodeService.js, sqlite-client.js, index.js)
- Update HTTP MCP server (server.js, stdio-server.js)
- Update all extraction tools (paper, website, youtube)
- Update all UI components (FocusPanel, ThreePanelLayout, GridView, ListView, FolderViewOverlay)
- TypeScript: 0 errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
“BeeRad”
2026-02-15 12:53:52 +11:00
co-authored by Claude Opus 4.6
parent 1d323de11a
commit 86f43c9975
36 changed files with 303 additions and 229 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ export const createNodeTool = tool({
description: 'Create node with title/content/link and optional dimensions (locked dimensions auto-assigned)',
inputSchema: z.object({
title: z.string().describe('The title of the node'),
content: z.string().optional().describe('The main content, description, or notes for this node'),
notes: z.string().optional().describe('The main notes, description, or notes for this node'),
link: z.string().optional().describe('A URL link to the source'),
dimensions: z
.array(z.string())
+5 -5
View File
@@ -6,9 +6,9 @@ export const getNodesByIdTool = tool({
description: 'Load full node records by IDs',
inputSchema: z.object({
nodeIds: z.array(z.number().int().positive()).min(1).max(10).describe('List of node IDs to load'),
includeContentPreview: z.boolean().default(true).describe('Whether to return a trimmed content preview for each node'),
includeNotesPreview: z.boolean().default(true).describe('Whether to return a trimmed content preview for each node'),
}),
execute: async ({ nodeIds, includeContentPreview }) => {
execute: async ({ nodeIds, includeNotesPreview }) => {
const uniqueIds = Array.from(new Set(nodeIds.filter(id => Number.isFinite(id) && id > 0)));
if (uniqueIds.length === 0) {
return {
@@ -23,8 +23,8 @@ export const getNodesByIdTool = tool({
try {
const node = await nodeService.getNodeById(id);
if (!node) return null;
const preview = includeContentPreview
? (node.content || node.description || '')
const preview = includeNotesPreview
? (node.notes || node.description || '')
.split(/\s+/)
.slice(0, 80)
.join(' ')
@@ -38,7 +38,7 @@ export const getNodesByIdTool = tool({
dimensions: node.dimensions || [],
chunk_status: node.chunk_status || 'unknown',
updated_at: node.updated_at,
content_preview: preview || null,
notes_preview: preview || null,
metadata: node.metadata ?? null,
};
} catch (error) {
+4 -4
View File
@@ -45,11 +45,11 @@ export const queryDimensionNodesTool = tool({
dimensions: node.dimensions || [],
};
if (includeContent && node.content) {
if (includeContent && node.notes) {
// Truncate to ~100 chars
formatted.contentPreview = node.content.length > 100
? node.content.substring(0, 100) + '...'
: node.content;
formatted.notesPreview = node.notes.length > 100
? node.notes.substring(0, 100) + '...'
: node.notes;
}
return formatted;
+2 -2
View File
@@ -5,11 +5,11 @@ import { formatNodeForChat } from '../infrastructure/nodeFormatter';
import type { Node } from '@/types/database';
export const queryNodesTool = tool({
description: 'Search nodes by title/content/dimensions',
description: 'Search nodes by title/notes/dimensions',
inputSchema: z.object({
filters: z.object({
dimensions: z.array(z.string()).describe('Filter by dimensions (e.g., ["research", "ai", "technology"]). Replaces old type/stage filtering.').optional(),
search: z.string().describe('Search term to match against title or content').optional(),
search: z.string().describe('Search term to match against title or notes').optional(),
limit: z.number().min(1).max(50).default(10).describe('Maximum number of results to return')
}).optional()
}),
+2 -6
View File
@@ -3,13 +3,12 @@ import { z } from 'zod';
import { edgeService } from '@/services/database/edges';
export const updateEdgeTool = tool({
description: 'Update edge context/source/feedback',
description: 'Update edge context/source',
inputSchema: z.object({
edge_id: z.number().describe('The ID of the edge to update'),
updates: z.object({
context: z.record(z.any()).optional().describe('Updated context information for this edge - can include explanation, relationship type, strength, notes, etc.'),
source: z.enum(['user', 'ai_similarity', 'helper_name']).optional().describe('Updated source classification for this edge'),
user_feedback: z.boolean().optional().describe('User feedback on this edge connection (true = positive, false = negative)')
}).describe('Fields to update on the edge')
}),
execute: async (params) => {
@@ -46,10 +45,7 @@ export const updateEdgeTool = tool({
const updateDescriptions = [];
if (cleanUpdates.context) updateDescriptions.push('context');
if (cleanUpdates.source) updateDescriptions.push(`source to ${cleanUpdates.source}`);
if (cleanUpdates.user_feedback !== undefined) {
updateDescriptions.push(`user feedback to ${cleanUpdates.user_feedback ? 'positive' : 'negative'}`);
}
return {
success: true,
data: updatedEdge,
+21 -21
View File
@@ -7,7 +7,7 @@ export const updateNodeTool = tool({
id: z.number().describe('The ID of the node to update'),
updates: z.object({
title: z.string().optional().describe('New title'),
content: z.string().optional().describe('New content/description/notes'),
notes: z.string().optional().describe('New content/description/notes'),
link: z.string().optional().describe('New link'),
dimensions: z.array(z.string()).optional().describe('New dimension tags - completely replaces existing dimensions'),
chunk: z.string().optional().describe('New chunk content'),
@@ -25,28 +25,28 @@ export const updateNodeTool = tool({
}
// FORCE APPEND for content field - fetch existing and append new content
if (updates.content) {
if (updates.notes) {
const fetchResponse = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000'}/api/nodes/${id}`);
if (fetchResponse.ok) {
const { node } = await fetchResponse.json();
const existingContent = (node?.content || '').trim();
const newContent = updates.content.trim();
const existingNotes = (node?.notes || '').trim();
const newNotes = updates.notes.trim();
// Skip if new content is identical to existing (model sent duplicate)
if (existingContent === newContent) {
console.log(`[updateNode] ERROR - new content identical to existing (${existingContent.length} chars). Model should NOT call updateNode again.`);
if (existingNotes === newNotes) {
console.log(`[updateNode] ERROR - new content identical to existing (${existingNotes.length} chars). Model should NOT call updateNode again.`);
return {
success: false,
error: 'Content already up to date - do not call updateNode again. Move to next step.',
error: 'Notes already up to date - do not call updateNode again. Move to next step.',
data: null
};
}
// Detect if adding a section that already exists (e.g., ## Integration Analysis)
const newSectionMatch = newContent.match(/^##\s+(.+)$/m);
if (newSectionMatch && existingContent) {
const newSectionMatch = newNotes.match(/^##\s+(.+)$/m);
if (newSectionMatch && existingNotes) {
const sectionHeader = newSectionMatch[0]; // e.g., "## Integration Analysis"
if (existingContent.includes(sectionHeader)) {
if (existingNotes.includes(sectionHeader)) {
console.log(`[updateNode] ERROR - Section "${sectionHeader}" already exists in node`);
return {
success: false,
@@ -57,19 +57,19 @@ export const updateNodeTool = tool({
}
// Detect if model included existing content + new content
if (existingContent && newContent.startsWith(existingContent)) {
if (existingNotes && newNotes.startsWith(existingNotes)) {
// Extract only the new part
const actualNewContent = newContent.substring(existingContent.length).trim();
console.log(`[updateNode] Model included existing content - extracting new part only (${actualNewContent.length} chars)`);
const separator = existingContent.endsWith('\n\n') ? '' : '\n\n';
updates.content = `${existingContent}${separator}${actualNewContent}`;
} else if (existingContent) {
const actualNewNotes = newNotes.substring(existingNotes.length).trim();
console.log(`[updateNode] Model included existing content - extracting new part only (${actualNewNotes.length} chars)`);
const separator = existingNotes.endsWith('\n\n') ? '' : '\n\n';
updates.notes = `${existingNotes}${separator}${actualNewNotes}`;
} else if (existingNotes) {
// Normal append
const separator = existingContent.endsWith('\n\n') ? '' : '\n\n';
updates.content = `${existingContent}${separator}${newContent}`;
console.log(`[updateNode] Appended content: ${existingContent.length} + ${newContent.length} = ${updates.content.length} chars`);
const separator = existingNotes.endsWith('\n\n') ? '' : '\n\n';
updates.notes = `${existingNotes}${separator}${newNotes}`;
console.log(`[updateNode] Appended notes: ${existingNotes.length} + ${newNotes.length} = ${updates.notes.length} chars`);
} else {
console.log(`[updateNode] No existing content, using new content as-is (${newContent.length} chars)`);
console.log(`[updateNode] No existing content, using new content as-is (${newNotes.length} chars)`);
}
}
}
@@ -79,7 +79,7 @@ export const updateNodeTool = tool({
// Call the nodes API endpoint
const response = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000'}/api/nodes/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
headers: { 'Notes-Type': 'application/json' },
body: JSON.stringify(updates)
});
+8 -8
View File
@@ -86,13 +86,13 @@ export const paperExtractTool = tool({
};
}
let result: { success: boolean; content?: string; chunk?: string; metadata?: any; error?: string };
let result: { success: boolean; notes?: string; chunk?: string; metadata?: any; error?: string };
try {
const extractionResult = await extractPaper(url);
result = {
success: true,
content: extractionResult.content,
notes: extractionResult.content,
chunk: extractionResult.chunk,
metadata: {
title: extractionResult.metadata.title,
@@ -110,7 +110,7 @@ export const paperExtractTool = tool({
};
}
if (!result.success || (!result.content && !result.chunk)) {
if (!result.success || (!result.notes && !result.chunk)) {
return {
success: false,
error: result.error || 'Failed to extract PDF content',
@@ -123,7 +123,7 @@ export const paperExtractTool = tool({
// Step 2: AI Analysis for enhanced metadata
const aiAnalysis = await analyzeContentWithAI(
result.metadata?.title || `PDF: ${new URL(url).pathname.split('/').pop()?.replace('.pdf', '')}`,
result.content?.substring(0, 2000) || 'PDF document content',
result.notes?.substring(0, 2000) || 'PDF document content',
'pdf'
);
@@ -143,17 +143,17 @@ export const paperExtractTool = tool({
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title: nodeTitle,
content: enhancedDescription,
notes: enhancedDescription,
link: url,
dimensions: trimmedDimensions,
chunk: result.chunk || result.content,
chunk: result.chunk || result.notes,
metadata: {
source: 'pdf',
hostname: new URL(url).hostname,
author: result.metadata?.author || result.metadata?.info?.Author,
pages: result.metadata?.pages,
file_size: result.metadata?.file_size,
content_length: (result.chunk || result.content)?.length,
content_length: (result.chunk || result.notes)?.length,
extraction_method: result.metadata?.extraction_method || 'python_pdfplumber',
ai_analysis: aiAnalysis?.reasoning,
enhanced_description: enhancedDescription,
@@ -187,7 +187,7 @@ export const paperExtractTool = tool({
data: {
nodeId: createResult.data?.id,
title: nodeTitle,
contentLength: (result.chunk || result.content || '').length,
contentLength: (result.chunk || result.notes || '').length,
url: url,
dimensions: actualDimensions
}
+8 -8
View File
@@ -76,13 +76,13 @@ export const websiteExtractTool = tool({
};
}
let result: { success: boolean; content?: string; chunk?: string; metadata?: any; error?: string };
let result: { success: boolean; notes?: string; chunk?: string; metadata?: any; error?: string };
try {
const extractionResult = await extractWebsite(url);
result = {
success: true,
content: extractionResult.content,
notes: extractionResult.content,
chunk: extractionResult.chunk,
metadata: {
title: extractionResult.metadata.title,
@@ -101,7 +101,7 @@ export const websiteExtractTool = tool({
};
}
if (!result.success || (!result.content && !result.chunk)) {
if (!result.success || (!result.notes && !result.chunk)) {
return {
success: false,
error: result.error || 'Failed to extract website content',
@@ -114,7 +114,7 @@ export const websiteExtractTool = tool({
// Step 2: AI Analysis for enhanced metadata
const aiAnalysis = await analyzeContentWithAI(
result.metadata?.title || `Website: ${new URL(url).hostname}`,
result.content?.substring(0, 2000) || 'Website content',
result.notes?.substring(0, 2000) || 'Website content',
'website'
);
@@ -134,16 +134,16 @@ export const websiteExtractTool = tool({
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title: nodeTitle,
content: enhancedDescription,
notes: enhancedDescription,
link: url,
dimensions: trimmedDimensions,
chunk: result.chunk || result.content,
chunk: result.chunk || result.notes,
metadata: {
source: 'website',
hostname: new URL(url).hostname,
author: result.metadata?.author,
published_date: result.metadata?.published_date || result.metadata?.date,
content_length: (result.chunk || result.content)?.length,
content_length: (result.chunk || result.notes)?.length,
extraction_method: result.metadata?.extraction_method || 'python_beautifulsoup',
ai_analysis: aiAnalysis?.reasoning,
enhanced_description: enhancedDescription,
@@ -177,7 +177,7 @@ export const websiteExtractTool = tool({
data: {
nodeId: createResult.data?.id,
title: nodeTitle,
contentLength: (result.chunk || result.content || '').length,
contentLength: (result.chunk || result.notes || '').length,
url: url,
dimensions: actualDimensions
}
+6 -6
View File
@@ -130,14 +130,14 @@ export const youtubeExtractTool = tool({
};
}
let result: { success: boolean; content?: string; chunk?: string; metadata?: any; error?: string };
let result: { success: boolean; notes?: string; chunk?: string; metadata?: any; error?: string };
console.log('📝 Using TypeScript yt-dlp extractor');
try {
const extractionResult = await extractYouTube(url);
result = {
success: extractionResult.success,
content: extractionResult.content,
notes: extractionResult.content,
chunk: extractionResult.chunk,
metadata: {
video_title: extractionResult.metadata.video_title,
@@ -159,7 +159,7 @@ export const youtubeExtractTool = tool({
};
}
if (!result.success || (!result.content && !result.chunk)) {
if (!result.success || (!result.notes && !result.chunk)) {
return {
success: false,
error: result.error || 'Failed to extract YouTube content',
@@ -178,7 +178,7 @@ export const youtubeExtractTool = tool({
// Step 3: Create node with extracted content and AI analysis
const nodeTitle = title || result.metadata?.video_title || `YouTube Video ${url.split('/').pop()?.split('?')[0]}`;
const transcriptSummary = await summariseTranscript(nodeTitle, result.chunk || result.content || '');
const transcriptSummary = await summariseTranscript(nodeTitle, result.chunk || result.notes || '');
const content = transcriptSummary || aiAnalysis?.enhancedDescription || `YouTube video by ${result.metadata?.channel_name || 'Unknown Channel'}`;
const suppliedDimensions = Array.isArray(dimensions) ? dimensions : [];
@@ -196,7 +196,7 @@ export const youtubeExtractTool = tool({
content,
link: url,
dimensions: trimmedDimensions,
chunk: result.chunk || result.content,
chunk: result.chunk || result.notes,
metadata: {
source: 'youtube',
video_id: result.metadata?.video_id,
@@ -239,7 +239,7 @@ export const youtubeExtractTool = tool({
data: {
nodeId: createResult.data?.id,
title: nodeTitle,
contentLength: (result.chunk || result.content || '').length,
contentLength: (result.chunk || result.notes || '').length,
url: url,
dimensions: actualDimensions
}