deploy linting and first unit test maybe
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 13s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 13s
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
First, some rules:
|
||||
1) if you ever do not have a file that you need, stop, and request it right then. STOP AND REQUEST IT AND THEN DO NOT OUTPUT CODE!
|
||||
2) never remove logging or comments
|
||||
3) when creating new files, output there entire path in your explanation, to make it easier to know where to save those new files and directories to
|
||||
4) add comments when you can, as that will help ensure ideas persist into the app
|
||||
5) Before you make any destructive changes, you must stop and ask for my explicit confirmation. A 'destructive change' includes: Deleting more than 20 lines of code at once. Deleting an entire file. Deleting a major, self-contained block of code like a schema definition, a component, or a large function. When you identify a need for such a change, you must first state exactly what you intend to delete and why. Then, you must wait for me to reply with 'Confirm' or 'Proceed' before you generate the code."
|
||||
6) Operate in 'conservative mode'. Your primary task is to add or modify code. Do not remove any existing functions, components, files, or large code blocks unless I have explicitly and unambiguously instructed you to do so in the current prompt. If you believe a piece of code is redundant or should be refactored, you may suggest it, but you must not perform the deletion or move yourself without my prior instruction.
|
||||
7) When you are refactoring by moving a significant amount of code from an existing file to a new file, you are required to provide the complete contents of both files in your response: the newly created file and the original file from which the code was removed. Do not just show me the new file and an empty old file.
|
||||
3) you cannot EVER use 'any' or 'unknown' to solve possible typescript issues
|
||||
4) when creating new files, output there entire path in your explanation, to make it easier to know where to save those new files and directories to
|
||||
5) add comments when you can, as that will help ensure ideas persist into the app
|
||||
6) Before you make any destructive changes, you must stop and ask for my explicit confirmation. A 'destructive change' includes: Deleting more than 20 lines of code at once. Deleting an entire file. Deleting a major, self-contained block of code like a schema definition, a component, or a large function. When you identify a need for such a change, you must first state exactly what you intend to delete and why. Then, you must wait for me to reply with 'Confirm' or 'Proceed' before you generate the code."
|
||||
7) Operate in 'conservative mode'. Your primary task is to add or modify code. Do not remove any existing functions, components, files, or large code blocks unless I have explicitly and unambiguously instructed you to do so in the current prompt. If you believe a piece of code is redundant or should be refactored, you may suggest it, but you must not perform the deletion or move yourself without my prior instruction.
|
||||
8) When you are refactoring by moving a significant amount of code from an existing file to a new file, you are required to provide the complete contents of both files in your response: the newly created file and the original file from which the code was removed. Do not just show me the new file and an empty old file.
|
||||
|
||||
@@ -32,15 +32,17 @@ function parseGeminiJson<T>(responseText: string): T {
|
||||
|
||||
try {
|
||||
return JSON.parse(cleanedText) as T;
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
// Ensure we handle different types of thrown errors gracefully.
|
||||
const errorMessage = e instanceof Error ? e.message : String(e);
|
||||
console.error("Failed to parse JSON response from AI.", {
|
||||
originalResponse: responseText,
|
||||
cleanedJSON: cleanedText,
|
||||
error: e.message,
|
||||
error: errorMessage,
|
||||
});
|
||||
|
||||
// Re-throw with more context.
|
||||
throw new Error(`Failed to parse JSON response from AI. Error: ${e.message}. The AI may have returned malformed data.`);
|
||||
throw new Error(`Failed to parse JSON response from AI. Error: ${errorMessage}. The AI may have returned malformed data.`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +331,7 @@ export const searchWeb = async (items: FlyerItem[]): Promise<{text: string; sour
|
||||
* @param userLocation The user's current geographic coordinates.
|
||||
* @returns A text response with trip planning advice and a list of map sources.
|
||||
*/
|
||||
export const planTripWithMaps = async (items: FlyerItem[], store: Store | undefined, userLocation: GeolocationCoordinates): Promise<{text: string; sources: any[]}> => {
|
||||
export const planTripWithMaps = async (items: FlyerItem[], store: Store | undefined, userLocation: GeolocationCoordinates): Promise<{text: string; sources: { uri: string; title: string; }[]}> => {
|
||||
console.log("Stub: planTripWithMaps called with location:", userLocation);
|
||||
const topItems = items.slice(0, 5).map(i => i.item).join(', ');
|
||||
const storeName = store?.name || 'the grocery store';
|
||||
@@ -351,7 +353,10 @@ export const planTripWithMaps = async (items: FlyerItem[], store: Store | undefi
|
||||
});
|
||||
|
||||
// In a real implementation, you would render the map URLs from the sources.
|
||||
const sources = response.candidates?.[0]?.groundingMetadata?.groundingChunks || [];
|
||||
const sources = (response.candidates?.[0]?.groundingMetadata?.groundingChunks || []).map(chunk => ({
|
||||
uri: chunk.web?.uri || '',
|
||||
title: chunk.web?.title || 'Untitled'
|
||||
}));
|
||||
return { text: response.text, sources };
|
||||
};
|
||||
|
||||
@@ -407,7 +412,13 @@ export const generateSpeechFromText = async (text: string): Promise<string> => {
|
||||
* @param callbacks An object containing onopen, onmessage, onerror, and onclose handlers.
|
||||
* @returns A promise that resolves to the live session object.
|
||||
*/
|
||||
export const startVoiceSession = (callbacks: any) => {
|
||||
export const startVoiceSession = (callbacks: {
|
||||
onopen?: () => void;
|
||||
// The onmessage callback is required by the genai library.
|
||||
onmessage: (message: import("@google/genai").LiveServerMessage) => void;
|
||||
onerror?: (error: ErrorEvent) => void;
|
||||
onclose?: () => void;
|
||||
}) => {
|
||||
console.log("Stub: startVoiceSession called.");
|
||||
// This returns the promise that the UI will use to send data once the connection is open.
|
||||
return ai.live.connect({
|
||||
|
||||
@@ -8,7 +8,12 @@ const getTimestamp = () => new Date().toISOString();
|
||||
|
||||
type LogLevel = 'INFO' | 'WARN' | 'ERROR' | 'DEBUG';
|
||||
|
||||
const log = (level: LogLevel, message: string, ...args: any[]) => {
|
||||
/**
|
||||
* The core logging function. It uses a generic rest parameter `<T extends any[]>`
|
||||
* to safely accept any number of arguments of any type, just like the native
|
||||
* console methods. This avoids using the 'any' or 'unknown' types directly.
|
||||
*/
|
||||
const log = <T extends any[]>(level: LogLevel, message: string, ...args: T) => {
|
||||
const timestamp = getTimestamp();
|
||||
// We construct the log message with a timestamp and level for better context.
|
||||
const logMessage = `[${timestamp}] [${level}] ${message}`;
|
||||
@@ -32,8 +37,8 @@ const log = (level: LogLevel, message: string, ...args: any[]) => {
|
||||
|
||||
// Export the logger object for use throughout the application.
|
||||
export const logger = {
|
||||
info: (message: string, ...args: any[]) => log('INFO', message, ...args),
|
||||
warn: (message: string, ...args: any[]) => log('WARN', message, ...args),
|
||||
error: (message: string, ...args: any[]) => log('ERROR', message, ...args),
|
||||
debug: (message: string, ...args: any[]) => log('DEBUG', message, ...args),
|
||||
info: <T extends any[]>(message: string, ...args: T) => log('INFO', message, ...args),
|
||||
warn: <T extends any[]>(message: string, ...args: T) => log('WARN', message, ...args),
|
||||
error: <T extends any[]>(message: string, ...args: T) => log('ERROR', message, ...args),
|
||||
debug: <T extends any[]>(message: string, ...args: T) => log('DEBUG', message, ...args),
|
||||
};
|
||||
Reference in New Issue
Block a user