cleanup
This commit is contained in:
		
							parent
							
								
									e93f394263
								
							
						
					
					
						commit
						c4c52f6064
					
				@ -1,4 +1,4 @@
 | 
			
		||||
// src/config/prompts.ts - Enhanced with phase completion reasoning
 | 
			
		||||
// src/config/prompts.ts
 | 
			
		||||
 | 
			
		||||
export const AI_PROMPTS = {
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
@ -180,7 +180,6 @@ export const POST: APIRoute = async ({ request }) => {
 | 
			
		||||
      return apiSpecial.invalidJSON();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Preprocess form data to handle autocomplete inputs
 | 
			
		||||
    body = preprocessFormData(body);
 | 
			
		||||
    
 | 
			
		||||
    const sanitizedBody = sanitizeInput(body);
 | 
			
		||||
 | 
			
		||||
@ -588,10 +588,8 @@ const currentUrl = Astro.url.href;
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Make generateTOCContent available globally for the auth check script
 | 
			
		||||
  window.generateTOCContent = generateTOCContent;
 | 
			
		||||
 | 
			
		||||
  // Initialize everything on page load
 | 
			
		||||
  document.addEventListener('DOMContentLoaded', () => {
 | 
			
		||||
    calculateReadingTime();
 | 
			
		||||
    generateSidebarTOC();
 | 
			
		||||
 | 
			
		||||
@ -1887,7 +1887,6 @@ input[type="checkbox"] {
 | 
			
		||||
  box-shadow: 0 2px 4px 0 rgb(255 255 255 / 10%);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Enhanced contextual analysis cards */
 | 
			
		||||
.contextual-analysis-card {
 | 
			
		||||
  margin-bottom: 2rem;
 | 
			
		||||
  border-left: 4px solid;
 | 
			
		||||
@ -1984,7 +1983,6 @@ input[type="checkbox"] {
 | 
			
		||||
  opacity: 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Enhanced queue status for micro-tasks */
 | 
			
		||||
.queue-status-card.micro-task-mode {
 | 
			
		||||
  border-left: 4px solid var(--color-primary);
 | 
			
		||||
}
 | 
			
		||||
@ -1997,7 +1995,6 @@ input[type="checkbox"] {
 | 
			
		||||
  border-radius: 0.5rem 0.5rem 0 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Mobile responsive adjustments */
 | 
			
		||||
@media (max-width: 768px) {
 | 
			
		||||
  .micro-task-steps {
 | 
			
		||||
    grid-template-columns: repeat(2, 1fr);
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,6 @@
 | 
			
		||||
  --color-warning: #d97706;
 | 
			
		||||
  --color-error: #dc2626;
 | 
			
		||||
  
 | 
			
		||||
  /* Enhanced card type colors */
 | 
			
		||||
  --color-hosted: #7c3aed;
 | 
			
		||||
  --color-hosted-bg: #f3f0ff;
 | 
			
		||||
  --color-oss: #059669;
 | 
			
		||||
 | 
			
		||||
@ -52,22 +52,17 @@ function getEnv(key: string): string {
 | 
			
		||||
 | 
			
		||||
export function getSessionFromRequest(request: Request): string | null {
 | 
			
		||||
  const cookieHeader = request.headers.get('cookie');
 | 
			
		||||
  console.log('[DEBUG] Cookie header:', cookieHeader ? 'present' : 'missing');
 | 
			
		||||
  
 | 
			
		||||
  if (!cookieHeader) return null;
 | 
			
		||||
  
 | 
			
		||||
  const cookies = parseCookie(cookieHeader);
 | 
			
		||||
  console.log('[DEBUG] Parsed cookies:', Object.keys(cookies));
 | 
			
		||||
  console.log('[DEBUG] Session cookie found:', !!cookies.session);
 | 
			
		||||
  
 | 
			
		||||
  return cookies.session || null;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function verifySession(sessionToken: string): Promise<SessionData | null> {
 | 
			
		||||
  try {
 | 
			
		||||
    console.log('[DEBUG] Verifying session token, length:', sessionToken.length);
 | 
			
		||||
    const { payload } = await jwtVerify(sessionToken, SECRET_KEY);
 | 
			
		||||
    console.log('[DEBUG] JWT verification successful, payload keys:', Object.keys(payload));
 | 
			
		||||
    
 | 
			
		||||
    if (
 | 
			
		||||
      typeof payload.userId === 'string' &&
 | 
			
		||||
@ -75,7 +70,6 @@ export async function verifySession(sessionToken: string): Promise<SessionData |
 | 
			
		||||
      typeof payload.authenticated === 'boolean' &&
 | 
			
		||||
      typeof payload.exp === 'number'
 | 
			
		||||
    ) {
 | 
			
		||||
      console.log('[DEBUG] Session validation successful for user:', payload.userId);
 | 
			
		||||
      return {
 | 
			
		||||
        userId: payload.userId,
 | 
			
		||||
        email: payload.email,
 | 
			
		||||
@ -84,17 +78,14 @@ export async function verifySession(sessionToken: string): Promise<SessionData |
 | 
			
		||||
      };
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    console.log('[DEBUG] Session payload validation failed, payload:', payload);
 | 
			
		||||
    return null;
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    console.log('[DEBUG] Session verification failed:', error.message);
 | 
			
		||||
    return null;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function createSession(userId: string, email: string): Promise<string> {
 | 
			
		||||
  const exp = Math.floor(Date.now() / 1000) + SESSION_DURATION;
 | 
			
		||||
  console.log('[DEBUG] Creating session for user:', userId, 'exp:', exp);
 | 
			
		||||
  
 | 
			
		||||
  const token = await new SignJWT({ 
 | 
			
		||||
    userId, 
 | 
			
		||||
@ -106,7 +97,6 @@ export async function createSession(userId: string, email: string): Promise<stri
 | 
			
		||||
    .setExpirationTime(exp)
 | 
			
		||||
    .sign(SECRET_KEY);
 | 
			
		||||
    
 | 
			
		||||
  console.log('[DEBUG] Session token created, length:', token.length);
 | 
			
		||||
  return token;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -123,7 +113,6 @@ export function createSessionCookie(sessionToken: string): string {
 | 
			
		||||
    path: '/'
 | 
			
		||||
  });
 | 
			
		||||
  
 | 
			
		||||
  console.log('[DEBUG] Created session cookie:', cookie.substring(0, 100) + '...');
 | 
			
		||||
  return cookie;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -292,8 +281,6 @@ export async function createSessionWithCookie(userInfo: UserInfo): Promise<{
 | 
			
		||||
 | 
			
		||||
export async function withAuth(Astro: AstroGlobal, context: AuthContextType = 'general'): Promise<AuthContext | Response> {
 | 
			
		||||
  const authRequired = getAuthRequirement(context);
 | 
			
		||||
  console.log(`[DEBUG PAGE] Auth required for ${context}:`, authRequired);
 | 
			
		||||
  console.log('[DEBUG PAGE] Request URL:', Astro.url.toString());
 | 
			
		||||
  
 | 
			
		||||
  if (!authRequired) {
 | 
			
		||||
    return {
 | 
			
		||||
@ -305,10 +292,8 @@ export async function withAuth(Astro: AstroGlobal, context: AuthContextType = 'g
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const sessionToken = getSessionFromRequest(Astro.request);
 | 
			
		||||
  console.log('[DEBUG PAGE] Session token found:', !!sessionToken);
 | 
			
		||||
  
 | 
			
		||||
  if (!sessionToken) {
 | 
			
		||||
    console.log('[DEBUG PAGE] No session token, redirecting to login');
 | 
			
		||||
    const loginUrl = `/api/auth/login?returnTo=${encodeURIComponent(Astro.url.toString())}`;
 | 
			
		||||
    return new Response(null, {
 | 
			
		||||
      status: 302,
 | 
			
		||||
@ -317,10 +302,8 @@ export async function withAuth(Astro: AstroGlobal, context: AuthContextType = 'g
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const session = await verifySession(sessionToken);
 | 
			
		||||
  console.log('[DEBUG PAGE] Session verification result:', !!session);
 | 
			
		||||
  
 | 
			
		||||
  if (!session) {
 | 
			
		||||
    console.log('[DEBUG PAGE] Session verification failed, redirecting to login');
 | 
			
		||||
    const loginUrl = `/api/auth/login?returnTo=${encodeURIComponent(Astro.url.toString())}`;
 | 
			
		||||
    return new Response(null, {
 | 
			
		||||
      status: 302,
 | 
			
		||||
@ -328,7 +311,6 @@ export async function withAuth(Astro: AstroGlobal, context: AuthContextType = 'g
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  console.log(`[DEBUG PAGE] Page authentication successful for ${context}:`, session.userId);
 | 
			
		||||
  return {
 | 
			
		||||
    authenticated: true,
 | 
			
		||||
    session,
 | 
			
		||||
@ -354,10 +336,8 @@ export async function withAPIAuth(request: Request, context: AuthContextType = '
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const sessionToken = getSessionFromRequest(request);
 | 
			
		||||
  console.log(`[DEBUG API] Session token found for ${context}:`, !!sessionToken);
 | 
			
		||||
  
 | 
			
		||||
  if (!sessionToken) {
 | 
			
		||||
    console.log(`[DEBUG API] No session token found for ${context}`);
 | 
			
		||||
    return { 
 | 
			
		||||
      authenticated: false, 
 | 
			
		||||
      userId: '', 
 | 
			
		||||
@ -366,10 +346,8 @@ export async function withAPIAuth(request: Request, context: AuthContextType = '
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const session = await verifySession(sessionToken);
 | 
			
		||||
  console.log(`[DEBUG API] Session verification result for ${context}:`, !!session);
 | 
			
		||||
  
 | 
			
		||||
  if (!session) {
 | 
			
		||||
    console.log(`[DEBUG API] Session verification failed for ${context}`);
 | 
			
		||||
    return { 
 | 
			
		||||
      authenticated: false, 
 | 
			
		||||
      userId: '', 
 | 
			
		||||
@ -377,7 +355,6 @@ export async function withAPIAuth(request: Request, context: AuthContextType = '
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  console.log(`[DEBUG API] Authentication successful for ${context}:`, session.userId);
 | 
			
		||||
  return {
 | 
			
		||||
    authenticated: true,
 | 
			
		||||
    userId: session.userId,
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
// src/utils/dataService.ts - Enhanced for micro-task AI pipeline
 | 
			
		||||
// src/utils/dataService.ts
 | 
			
		||||
import { promises as fs } from 'fs';
 | 
			
		||||
import { load } from 'js-yaml';
 | 
			
		||||
import path from 'path';
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
// src/utils/remarkVideoPlugin.ts - SIMPLIFIED: Basic video and iframe enhancement only
 | 
			
		||||
// src/utils/remarkVideoPlugin.ts
 | 
			
		||||
import { visit } from 'unist-util-visit';
 | 
			
		||||
import type { Plugin } from 'unified';
 | 
			
		||||
import type { Root } from 'hast';
 | 
			
		||||
@ -16,7 +16,6 @@ function escapeHtml(unsafe: string): string {
 | 
			
		||||
 | 
			
		||||
export const remarkVideoPlugin: Plugin<[], Root> = () => {
 | 
			
		||||
  return (tree: Root) => {
 | 
			
		||||
    // Process video tags
 | 
			
		||||
    visit(tree, 'html', (node: any, index: number | undefined, parent: any) => {
 | 
			
		||||
      if (node.value && node.value.includes('<video') && typeof index === 'number') {
 | 
			
		||||
        const srcMatch = node.value.match(/src=["']([^"']+)["']/);
 | 
			
		||||
@ -26,14 +25,12 @@ export const remarkVideoPlugin: Plugin<[], Root> = () => {
 | 
			
		||||
          const originalSrc = srcMatch[1];
 | 
			
		||||
          const title = titleMatch?.[1] || 'Video';
 | 
			
		||||
          
 | 
			
		||||
          // Extract existing attributes
 | 
			
		||||
          const hasControls = node.value.includes('controls');
 | 
			
		||||
          const hasAutoplay = node.value.includes('autoplay');
 | 
			
		||||
          const hasMuted = node.value.includes('muted');
 | 
			
		||||
          const hasLoop = node.value.includes('loop');
 | 
			
		||||
          const preloadMatch = node.value.match(/preload=["']([^"']+)["']/);
 | 
			
		||||
          
 | 
			
		||||
          // Create enhanced video with responsive wrapper
 | 
			
		||||
          const enhancedHTML = `
 | 
			
		||||
            <div class="video-container">
 | 
			
		||||
              <video 
 | 
			
		||||
@ -60,10 +57,8 @@ export const remarkVideoPlugin: Plugin<[], Root> = () => {
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      // Process all iframes with consistent styling
 | 
			
		||||
      if (node.value && node.value.includes('<iframe') && typeof index === 'number' && parent) {
 | 
			
		||||
        
 | 
			
		||||
        // Skip if already wrapped in video-container to prevent double-wrapping
 | 
			
		||||
        if (node.value.includes('video-container')) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
@ -71,7 +66,6 @@ export const remarkVideoPlugin: Plugin<[], Root> = () => {
 | 
			
		||||
        const titleMatch = node.value.match(/title=["']([^"']+)["']/);
 | 
			
		||||
        const title = titleMatch?.[1] || 'Embedded Video';
 | 
			
		||||
        
 | 
			
		||||
        // Wrap iframe in simple responsive container
 | 
			
		||||
        const enhancedHTML = `
 | 
			
		||||
          <div class="video-container">
 | 
			
		||||
            ${node.value}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user