From 3b2d22f14482afce70b1bd68cc2eb32f8a8f21fe Mon Sep 17 00:00:00 2001 From: Vercel Date: Thu, 23 Jul 2026 01:19:40 +0000 Subject: [PATCH] Install Vercel Web Analytics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Vercel Web Analytics Installation Successfully installed and configured Vercel Web Analytics for this React/Vite project. ## Changes Made ### 1. Added Package Dependency - **File**: `package.json` - **Change**: Added `@vercel/analytics` version `^2.0.1` to dependencies - **Reason**: Required package for Vercel Web Analytics integration ### 2. Integrated Analytics Component - **File**: `client/src/App.tsx` - **Changes**: - Added import: `import { Analytics } from "@vercel/analytics/react";` - Added `` component inside the App function, placed at the end of the component tree within the ThemeProvider and TooltipProvider wrappers - **Reason**: Following Vercel's official documentation for React/Vite framework integration ### 3. Updated Dependencies - **File**: `pnpm-lock.yaml` - **Change**: Updated lockfile with @vercel/analytics package and its dependencies - **Reason**: Ensures consistent dependency resolution across environments ## Implementation Details Following the official Vercel Analytics Quickstart documentation (https://vercel.com/docs/analytics/quickstart), I implemented the framework-specific integration for React/Vite: 1. Installed the `@vercel/analytics` package using pnpm 2. Imported the `Analytics` component from `@vercel/analytics/react` 3. Added the component to the root App component to track page views across all routes The Analytics component is positioned at the end of the component tree to ensure it doesn't interfere with the existing application structure while still tracking all page views. ## Verification ✅ Build completed successfully (`pnpm run build:client`) ✅ TypeScript type checking passed (`pnpm run check`) ✅ All tests passed (9/9 tests) ✅ Code formatting applied ## Next Steps To complete the setup: 1. Deploy the application to Vercel 2. Enable Web Analytics in the Vercel Dashboard (Analytics section) 3. After deployment, verify tracking by checking the browser Network tab for requests to `/_vercel/insights/*` 4. Analytics data will appear in the Vercel Dashboard once user visits accumulate Co-authored-by: Vercel --- DAN_MARTELL_FRAMEWORK.md | 24 +- GEMINI_XPRIZE_BATTLE_PLAN.md | 79 +- MASTER_PROMPT.md | 12 + NSF_PROJECT_PITCH_TECHNICAL_DENSITY.md | 44 +- architecture-diagram.html | 1155 +++++++++++---- client/index.html | 21 +- client/public/__manus__/debug-collector.js | 90 +- client/src/App.tsx | 2 + client/src/_core/hooks/useAuth.ts | 2 +- client/src/components/AIChatBox.tsx | 11 +- client/src/components/AppLayout.tsx | 26 +- client/src/components/DashboardLayout.tsx | 7 +- .../components/DashboardLayoutSkeleton.tsx | 2 +- client/src/components/InAppBrowserBanner.tsx | 8 +- client/src/components/LookupGuide.tsx | 9 +- client/src/components/PaywallGate.tsx | 14 +- client/src/components/ThemeToggle.tsx | 6 +- client/src/components/ui/button.tsx | 3 +- client/src/components/ui/dialog.tsx | 3 +- client/src/components/ui/input.tsx | 6 +- client/src/components/ui/sidebar.tsx | 3 +- client/src/components/ui/textarea.tsx | 6 +- client/src/contexts/ThemeContext.tsx | 8 +- client/src/data/questionBank.ts | 1264 ++++++++++++----- client/src/hooks/useInAppBrowser.ts | 17 +- client/src/index.css | 17 +- client/src/main.tsx | 2 +- client/src/pages/CoPilot.tsx | 94 +- client/src/pages/ComponentShowcase.tsx | 13 +- client/src/pages/Dashboard.tsx | 85 +- client/src/pages/ExamMode.tsx | 170 ++- client/src/pages/Home.tsx | 2 +- client/src/pages/Onboarding.tsx | 55 +- client/src/pages/PaymentCancel.tsx | 4 +- client/src/pages/PaymentSuccess.tsx | 7 +- client/src/pages/Pricing.tsx | 81 +- client/src/pages/QuizMode.tsx | 159 ++- client/src/pages/SearchMode.tsx | 267 ++-- .../src/components/ThemeToggle.tsx | 6 +- codecompass-beta/src/lib/l5x-parser.ts | 9 +- codecompass-beta/src/lib/svg-renderer.ts | 3 +- codecompass-beta/src/routeTree.gen.ts | 796 ++++++----- .../src/routes/[.mcp]/invoke-tool/$tool.ts | 6 +- .../src/routes/[.mcp]/list-tools.ts | 6 +- .../[.well-known]/oauth-protected-resource.ts | 6 +- codecompass-beta/src/routes/api/parse-l5x.ts | 2 +- .../src/routes/api/stripe-checkout.ts | 64 +- .../src/routes/api/stripe-webhook.ts | 46 +- codecompass-beta/src/routes/mcp.ts | 6 +- drizzle/meta/0000_snapshot.json | 10 +- drizzle/meta/0001_snapshot.json | 10 +- drizzle/meta/0002_snapshot.json | 14 +- drizzle/meta/_journal.json | 2 +- drizzle/schema.ts | 19 +- ideas.md | 6 + package.json | 1 + pnpm-lock.yaml | 36 + server/_core/dataApi.ts | 9 +- server/_core/llm.ts | 13 +- server/_core/map.ts | 10 +- server/_core/notification.ts | 4 +- server/_core/oauth.ts | 5 +- server/_core/storageProxy.ts | 6 +- server/_core/trpc.ts | 6 +- server/_core/voiceTranscription.ts | 138 +- server/auth.logout.test.ts | 5 +- server/copilot.analyze.test.ts | 4 +- server/db.ts | 27 +- server/products.ts | 5 +- server/routers.ts | 33 +- server/routers/copilot.ts | 31 +- server/storage.ts | 8 +- server/stripe.checkout.test.ts | 14 +- server/stripeWebhook.ts | 72 +- shared/const.ts | 4 +- todo.md | 16 +- vite.config.ts | 12 +- 77 files changed, 3490 insertions(+), 1758 deletions(-) diff --git a/DAN_MARTELL_FRAMEWORK.md b/DAN_MARTELL_FRAMEWORK.md index c6163b7..1b9e348 100644 --- a/DAN_MARTELL_FRAMEWORK.md +++ b/DAN_MARTELL_FRAMEWORK.md @@ -1,4 +1,5 @@ # Dan Martell — "If I Started Over With $0, Here's My Exact Plan to Get to $1M" + ## Applied to Code Compass / NEC Co-Pilot Source: https://www.youtube.com/watch?v=dyrr4eAdnhg @@ -8,11 +9,13 @@ Source: https://www.youtube.com/watch?v=dyrr4eAdnhg ## THE 6-POINT FRAMEWORK ### Point 1: Find a Painful Problem + - Stop finding your passion — find a painful problem. - The pain point must be something people will PAY to solve. - **Code Compass application:** Every apprentice, journeyman, and master electrician studying for their license exam has the SAME painful problem: they don't know how to use the NEC book efficiently under exam pressure. This is a "bleeding neck" problem — it costs them time, money, and their license. ### Point 2: Build an Irresistible Offer + - Package your solution around a clear promise + guarantee + bonuses that handle objections. - Price based on value delivered, not time spent. - **Code Compass application:** @@ -22,6 +25,7 @@ Source: https://www.youtube.com/watch?v=dyrr4eAdnhg - **Guarantee:** If you don't pass, you get your money back. ### Point 3: Find Your Buyers + - 50 personalized outreaches per day. - Use AI to identify prospects, find contact info, and personalize messages. - **Code Compass application:** @@ -29,6 +33,7 @@ Source: https://www.youtube.com/watch?v=dyrr4eAdnhg - Outreach angle: "Are you studying for your journeyman exam? Here's the #1 reason people fail — and it's not the questions." ### Point 4: Sell Using the Rocket Selling System (9-Box Model) + 1. Setup — research the prospect before the call 2. Customer — understand their business/context 3. Decision — "What made you decide now is a good time?" @@ -40,6 +45,7 @@ Source: https://www.youtube.com/watch?v=dyrr4eAdnhg 9. Enroll — ask for the sale directly ### Point 5: Deliver Value Fast (Time To First Value = TTFV) + - The second someone pays, buyer's remorse kicks in. - Get them a quick win in MINUTES, not days. - **Code Compass application:** @@ -48,6 +54,7 @@ Source: https://www.youtube.com/watch?v=dyrr4eAdnhg - Roadmap: Show them their personalized study plan based on their exam date and state ### Point 6: Go. Now. + - Stop preparing to get ready. - Be patient with results, wildly impatient with action. - **Code Compass application:** The app is live. Start posting on TikTok TODAY. @@ -56,18 +63,19 @@ Source: https://www.youtube.com/watch?v=dyrr4eAdnhg ## CODE COMPASS MAPPED TO THE FRAMEWORK -| Framework Step | Code Compass Action | Status | -|---|---|---| -| Find the pain | NEC book navigation is the #1 exam failure point | ✅ Validated | -| Build the offer | Subscription + guarantee + cheat sheets | 🔨 In progress | -| Find buyers | TikTok, Instagram, Facebook Groups, Reddit | 🔨 Ready | -| Sell | DM automation + "are you studying?" hook | ⬜ Next | -| Deliver fast | "How to Use Your Book" module in app | ⬜ Building | -| Go now | Publish + post first TikTok | 🔨 Ready | +| Framework Step | Code Compass Action | Status | +| --------------- | ------------------------------------------------ | -------------- | +| Find the pain | NEC book navigation is the #1 exam failure point | ✅ Validated | +| Build the offer | Subscription + guarantee + cheat sheets | 🔨 In progress | +| Find buyers | TikTok, Instagram, Facebook Groups, Reddit | 🔨 Ready | +| Sell | DM automation + "are you studying?" hook | ⬜ Next | +| Deliver fast | "How to Use Your Book" module in app | ⬜ Building | +| Go now | Publish + post first TikTok | 🔨 Ready | --- ## IMMEDIATE NEXT ACTIONS (Priority Order) + 1. Add "How to Use Your Book" module to the app (the missing core) 2. Record first TikTok: "The #1 reason electricians fail their exam (it's not the questions)" 3. Set up DM automation with keyword trigger: "COMPASS" → sends free Index Cheat Sheet diff --git a/GEMINI_XPRIZE_BATTLE_PLAN.md b/GEMINI_XPRIZE_BATTLE_PLAN.md index 8a515c6..d3ca179 100644 --- a/GEMINI_XPRIZE_BATTLE_PLAN.md +++ b/GEMINI_XPRIZE_BATTLE_PLAN.md @@ -12,6 +12,7 @@ Code Compass is an AI-native NEC compliance co-pilot that connects electricians (apprentice → master) with expert code guidance. We transform the $120B electrical trade industry by replacing paper codebooks and guesswork with cryptographic verification, deterministic math engines, and real-time AI assistance. **Why we win:** + - Real revenue from arms-length customers during the hackathon window - AI live in production (Gemini + Qwen for NEC article retrieval) - Cryptographic audit trails (SHA-256 on every L5X file and AI output) @@ -25,6 +26,7 @@ Code Compass is an AI-native NEC compliance co-pilot that connects electricians **Category definition:** "Connecting everyday people with the expert guidance they need." **Our fit:** + - Master electricians charge $150-250/hour for code consultation - Code Compass provides instant NEC article lookup, worked examples, and compliance verification for $29/month - Target: 700,000+ licensed electricians in the US who need code guidance daily @@ -38,6 +40,7 @@ Code Compass is an AI-native NEC compliance co-pilot that connects electricians ## 3. Technical Requirements (Gemini API Integration) ### Current Stack: + - **AI:** Qwen/DashScope (qwen-max, qwen-plus) via OpenAI-compatible endpoint - **Deployment:** Vercel (codecompass.work live and serving) - **Database:** Supabase (RLS-enabled, AES-256 at rest) @@ -51,6 +54,7 @@ Code Compass is an AI-native NEC compliance co-pilot that connects electricians **Rule:** "Projects that include LLM functionality must use the Gemini API for at least one LLM call in the deployed application." **Implementation strategy:** + 1. Keep Qwen for NEC article retrieval (deterministic, proven) 2. Add Gemini for: - **Natural language question parsing** (extract intent, article numbers, table references) @@ -58,6 +62,7 @@ Code Compass is an AI-native NEC compliance co-pilot that connects electricians - **PLC logic explanation** (translate L5X rung comments into training material) **Code changes:** + ```typescript // server/lib/gemini.ts import { GoogleGenerativeAI } from "@google/generative-ai"; @@ -67,12 +72,16 @@ const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY!); export async function parseQuestion(userInput: string) { const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" }); const result = await model.generateContent({ - contents: [{ - role: "user", - parts: [{ - text: `Extract NEC article numbers, table references, and key concepts from: "${userInput}"` - }] - }], + contents: [ + { + role: "user", + parts: [ + { + text: `Extract NEC article numbers, table references, and key concepts from: "${userInput}"`, + }, + ], + }, + ], generationConfig: { responseMimeType: "application/json", responseSchema: { @@ -81,36 +90,43 @@ export async function parseQuestion(userInput: string) { articles: { type: "array", items: { type: "string" } }, tables: { type: "array", items: { type: "string" } }, concepts: { type: "array", items: { type: "string" } }, - intent: { type: "string", enum: ["lookup", "explain", "calculate", "validate"] } - } - } - } + intent: { + type: "string", + enum: ["lookup", "explain", "calculate", "validate"], + }, + }, + }, + }, }); return JSON.parse(result.response.text()); } ``` **Integration point:** + ```typescript // server/index.ts (modify /api/chat/qwen route) app.post("/api/chat/qwen", async (req, res) => { const { message } = req.body; - + // Step 1: Parse with Gemini (NEW) const parsed = await parseQuestion(message); - + // Step 2: Retrieve with Qwen (EXISTING) const necAnswer = await lookupNEC("gemini-xprize", message); - + // Step 3: Explain with Gemini (NEW) - const explanation = await genAI.getGenerativeModel({ model: "gemini-1.5-flash" }) - .generateContent(`Explain this NEC answer to an apprentice electrician in simple terms: ${necAnswer}`); - + const explanation = await genAI + .getGenerativeModel({ model: "gemini-1.5-flash" }) + .generateContent( + `Explain this NEC answer to an apprentice electrician in simple terms: ${necAnswer}` + ); + res.json({ answer: necAnswer, explanation: explanation.response.text(), parsed, - sources: parsed.articles + sources: parsed.articles, }); }); ``` @@ -138,6 +154,7 @@ app.post("/api/chat/qwen", async (req, res) => { #### C. Environment Variables **Vercel Dashboard → Settings → Environment Variables:** + ``` GEMINI_API_KEY=*** DASHSCOPE_API_KEY=*** @@ -155,12 +172,14 @@ POSTHOG_API_KEY=*** ### Revenue Model: **Tier 1: Apprentice ($19/month)** + - Quiz mode (unlimited) - Book Method (NEC navigation training) - Basic search - Progress tracking **Tier 2: Journeyman ($29/month)** + - Everything in Apprentice - Exam mode (timed 25-question simulations) - AI chat (Gemini + Qwen) @@ -169,6 +188,7 @@ POSTHOG_API_KEY=*** - Motor sizing wizard **Tier 3: Master ($49/month)** + - Everything in Journeyman - SHA-256 audit trail exports (for compliance documentation) - Multi-NEC-version comparison (2017/2020/2023/2026) @@ -176,6 +196,7 @@ POSTHOG_API_KEY=*** - Team management (up to 5 apprentices) **Tier 4: Enterprise ($199/month)** + - Everything in Master - Unlimited team seats - Custom L5X validation rules @@ -186,6 +207,7 @@ POSTHOG_API_KEY=*** ### 28-Day Revenue Sprint: **Week 1 (July 20-26): Launch & First Sales** + - Deploy Gemini integration - Launch landing page with Stripe checkout - Post in r/electricians, r/PLC, electrician Facebook groups @@ -193,6 +215,7 @@ POSTHOG_API_KEY=*** - **Target:** 5 paying subscribers @ $29/mo = $145 **Week 2 (July 27-Aug 2): Content Marketing** + - Publish 3 blog posts: - "How to Pass the Journeyman Exam in 30 Days" - "NEC 2026 Changes Every Electrician Needs to Know" @@ -202,12 +225,14 @@ POSTHOG_API_KEY=*** - **Target:** 10 new subscribers = $290 **Week 3 (Aug 3-9): Partnerships & Upsells** + - Pitch to IBEW local unions (offer 20% discount for members) - Contact electrical supply houses (offer affiliate program: 10% recurring) - Launch "Exam Prep Bootcamp" ($99 one-time, includes 30-day Journeyman access) - **Target:** 3 bootcamp sales ($297) + 5 new subs ($145) = $442 **Week 4 (Aug 10-16): Enterprise Outreach** + - Cold email 20 electrical contractors with 10+ employees - Offer free pilot: "Use Code Compass for 14 days, if your team passes more code inspections, pay us $199/month" - Close 1 enterprise deal @@ -228,6 +253,7 @@ POSTHOG_API_KEY=*** ### P&L Template (Cash-Basis): **Revenue (May 19 - Aug 17, 2026):** + - Apprentice subscriptions: $0 (not launched yet) - Journeyman subscriptions: $1,163 - Master subscriptions: $0 @@ -236,6 +262,7 @@ POSTHOG_API_KEY=*** - **Total Revenue: $1,659** **Expenses:** + - Vercel hosting: $0 (free tier) - Supabase: $0 (free tier) - Stripe fees (2.9% + $0.30): $48 @@ -255,18 +282,22 @@ POSTHOG_API_KEY=*** ### Target List (100 electricians in 28 days): **Batch 1 (Week 1): 20 electrical contractors** + - Search LinkedIn for "Electrical Contractor" + location (NYC, LA, Chicago, Houston) - Filter by company size: 10-50 employees - Message: "Hi [Name], I built an AI tool that helps your electricians pass code inspections on the first try. Can I send you a 2-minute demo video?" **Batch 2 (Week 2): 30 journeyman electricians** + - Search Reddit r/electricians for users asking NEC questions - DM them: "Hey, I saw your question about [article]. I built a tool that answers NEC questions instantly with SHA-256 verification. Want to try it free for 7 days?" **Batch 3 (Week 3): 20 apprentices** + - Post in r/ApprenticeElectrician: "I'm giving away 10 free 6-month subscriptions to Code Compass (AI NEC co-pilot) to apprentices studying for their journeyman exam. DM me if interested." **Batch 4 (Week 4): 30 electrical foremen/superintendents** + - LinkedIn search: "Electrical Foreman" OR "Electrical Superintendent" - Message: "I built a tool that reduces code violations by 40%. Your team can look up any NEC article in 3 seconds with cryptographic audit trails. Want to see a demo?" @@ -280,6 +311,7 @@ Show a 1,200-page NEC codebook. Flip through pages. "Finding Article 310.15 for **[0:45-1:30] Solution:** Screen recording: + 1. Type "What's the derating factor for 40°C ambient?" 2. AI responds in 2 seconds with answer + article citation 3. Show L5X parser: upload file → instant SVG ladder diagram with SHA-256 hash @@ -292,7 +324,7 @@ Screen recording: "$29/month for journeyman access. $199/month for enterprise teams. 7-day free trial." **[2:45-3:00] CTA:** -"Try it free at codecompass.work. Questions? Email me at ed***@***ompass.work" +"Try it free at codecompass.work. Questions? Email me at ed**_@_**ompass.work" --- @@ -335,22 +367,28 @@ Screen recording: ## 7. Risk Mitigation ### Risk 1: "No real revenue" + **Mitigation:** Aggressive 28-day sales sprint. Offer free trials that convert to paid. Partner with trade schools for bulk licenses. ### Risk 2: "Not enough Gemini usage" + **Mitigation:** Make Gemini the primary question parser. Log every Gemini API call. Show usage dashboard in submission. ### Risk 3: "Competitors exist" + **Mitigation:** Differentiate on: + - Cryptographic verification (SHA-256 on every AI output) - Deterministic math engines (no hallucination on voltage drop, motor sizing) - L5X parser (no other tool parses Rockwell ladder logic with SHA-256 verification) - NEC 2026 focus (most competitors still on 2020 or 2023) ### Risk 4: "Judges can't test it" -**Mitigation:** Provide test credentials (apprentice@***ompass.work / password123). Record a 5-minute walkthrough video showing every feature. + +**Mitigation:** Provide test credentials (apprentice@\*\*\*ompass.work / password123). Record a 5-minute walkthrough video showing every feature. ### Risk 5: "Domain not live" + **Mitigation:** codecompass.work is already deployed to Vercel and returning 200 OK. Verify before submission. --- @@ -358,12 +396,14 @@ Screen recording: ## 8. Post-Submission Strategy ### If we win: + - Use $500K to hire 2 engineers (full-stack + electrical domain expert) - Launch enterprise sales team (target top 100 electrical contractors) - Expand to HVAC and plumbing (same compliance problem, different codes) - Apply for NSF SBIR Phase II ($1.1M) ### If we don't win: + - Continue selling subscriptions (target $10K MRR by Dec 2026) - Apply to Y Combinator (Winter 2027 batch) - Pitch to electrical industry VCs (Schneider Electric, Eaton, ABB) @@ -411,6 +451,7 @@ Screen recording: --- **Bottom line:** Code Compass is already 80% ready for the Gemini XPRIZE. We need to: + 1. Add Gemini API integration (mandatory) 2. Get real revenue ($1,163 target in 28 days) 3. Document everything (P&L, user evidence, product evidence) diff --git a/MASTER_PROMPT.md b/MASTER_PROMPT.md index 8392c04..7d64938 100644 --- a/MASTER_PROMPT.md +++ b/MASTER_PROMPT.md @@ -1,18 +1,23 @@ # MASTER PROMPT — EDDIE x CODE COMPASS / NEC CO-PILOT + ## v4 · compressed · May 29, 2026 Paste as the first message in any new AI session (Claude, Gemini, Manus, Perplexity, ChatGPT). ## 0. CREDIT RULE + Do not spend Eddie's credits (Manus task credits, API keys, or anything paid) without asking first. ## 1. WHO I AM + Eddie (Edward Baxter) — artist, commercial electrician, self-taught programmer, solo founder building AI-powered income (web apps, automations, NEC tools / Code Compass). Works long days. Learns fast when pushed. Wants grounded, enterprise-grade output — not hype. Dictates by voice-to-text on a Chromebook (transcription errors expected — read for intent). ## 2. WHO YOU ARE + Co-founder, performance coach, learning architect, and senior engineer. On Code Compass / NEC Co-Pilot: senior product engineer, UX lead, and NEC subject-matter assistant. Goal: ship a production-ready NEC exam + lookup tool that helps apprentices, journeymen, and masters pass their tests and work faster on the job. ## 3. HOW WE WORK + - 10-80-10. Eddie gives vision. AI does ~80%. Eddie does final 10-20%. - Concrete, never vague. Clear recommendation + ready-to-paste content + short notes. - Tough love. Call out fluff, over-scoping, low-leverage work. @@ -20,27 +25,32 @@ Co-founder, performance coach, learning architect, and senior engineer. On Code - Humane override for health/money/safety urgencies. ## 4. ENTERPRISE-GRADE — NO HALLUCINATIONS + - Ground claims in verifiable sources or Eddie's own docs/repos. - Label: web sources / my documents / extrapolation. - If unsure, SAY SO. Never fabricate. - High-stakes: flag what to double-check, name fragile assumptions. ## 5. FOCUS & ACCOUNTABILITY + - Timer Mindset: every interaction has purpose and deadline. - Visual Grounding: ONLY refer to elements demonstrably present. - Completion Focus: finish current task before suggesting new directions. ## 6. LEARNING — 3C PROTOCOL + - COMPRESS — isolate 20% that drives 80%. - COMPILE — convert to action (drill, mini-project, teach-back). - CONSOLIDATE — summarize what we did, learned, and what changed. ## 7. BUSINESS — DAN MARTELL STYLE + - Offers before tools. - Leverage before grind. - Relationships multiply. ## 8. CODE COMPASS / NEC CO-PILOT — BUILD SPEC + **Next big build:** AI Q&A — ask any NEC question → plain-English answer + article citation. On Google Cloud / Gemini. **Vertex AI credits expire June 17, 2026. Build must start before then or credits are lost.** **Modules:** Exam Mode, Quiz Mode, Search Mode, Changes Mode @@ -50,7 +60,9 @@ Co-founder, performance coach, learning architect, and senior engineer. On Code **Guardrails:** Never imply this replaces official NEC. Never paste copyrighted text — paraphrase and cite. ## 9. SESSION FLOW + Open with: "What's the move today?" One step at a time. ## 10. EVOLUTION + Long-term build. Periodically propose upgrades, reflection rituals, and name avoidance/perfectionism-stalling plainly. diff --git a/NSF_PROJECT_PITCH_TECHNICAL_DENSITY.md b/NSF_PROJECT_PITCH_TECHNICAL_DENSITY.md index 6cb7af9..228f3e9 100644 --- a/NSF_PROJECT_PITCH_TECHNICAL_DENSITY.md +++ b/NSF_PROJECT_PITCH_TECHNICAL_DENSITY.md @@ -51,11 +51,11 @@ Pure string assembly (zero dependencies). Industrial Control Panel palette: oran **NEC Table 310.15(B)(1)** — Implemented in question bank and AI inference layer: -| Ambient Temp | 60°C Conductor | 75°C Conductor | 90°C Conductor | -|---|---|---|---| -| 30°C (baseline) | 1.00 | 1.00 | 1.00 | -| 40°C | — | **0.88** (validated in question 310-002) | — | -| 46°C (115°F rooftop) | — | **0.87** (validated in server mock response) | — | +| Ambient Temp | 60°C Conductor | 75°C Conductor | 90°C Conductor | +| -------------------- | -------------- | -------------------------------------------- | -------------- | +| 30°C (baseline) | 1.00 | 1.00 | 1.00 | +| 40°C | — | **0.88** (validated in question 310-002) | — | +| 46°C (115°F rooftop) | — | **0.87** (validated in server mock response) | — | **Application formula:** `Adjusted_Ampacity = Table_310.16_Ampacity × Correction_Factor × Adjustment_Factor` @@ -66,9 +66,11 @@ Pure string assembly (zero dependencies). Industrial Control Panel palette: oran **Resistivity constants:** K_Cu = 12.9 Ω·cmil/ft | K_Al = 21.2 Ω·cmil/ft **Single-phase voltage drop formula:** + ``` VD = (2 × K × I × L) / CM ``` + Where: I = current (amps), L = one-way length (feet), CM = circular mils from NEC Table 8 **Validated AWG circular mil table** (Chapter 9 Table 8): @@ -81,6 +83,7 @@ Where: I = current (amps), L = one-way length (feet), CM = circular mils from NE **FLA Table Lookup** — Verbatim values from NEC Tables 430.248 (single-phase) and 430.250 (three-phase). 10 HP ratings × 4-5 voltage classes = ~50 discrete data points. No interpolation — unsupported (HP, V) pairs return `{missing: true}`. **Branch-circuit conductor sizing (430.22):** `min_ampacity = FLA × 1.25` + - Validated: 5HP/230V/3φ → FLA 15.2 × 1.25 = **19.0A** **OCP Sizing (Table 430.52 + 240.6(A)):** @@ -92,9 +95,11 @@ Where: I = current (amps), L = one-way length (feet), CM = circular mils from NE | Inverse-time breaker | 2.5 (250%) | FLA 30.8 × 2.5 = 77 → standard **80A** | **Disconnect sizing (430.110(A)):** `min_amps = FLA × 1.15` + - Validated: 25HP/460V → FLA 34 × 1.15 = **39.1A** **Feeder ampacity (430.24):** `125% × largest_FLA + Σ(other FLAs)` + - Validated: Motors [34, 15.2, 7.6] → 34×1.25 + 15.2 + 7.6 = **65.3A** **Standard OCP ladder (240.6(A)):** 37 standard sizes from 15A to 6000A. Round-up algorithm with floating-point tolerance (1e-9). @@ -115,21 +120,22 @@ Where: I = current (amps), L = one-way length (feet), CM = circular mils from NE ### The 11 mandatory metadata fields per AI inference event: -| # | Field | Description | -|---|---|---| -| 1 | **Model Identifier** | AI model name and version (e.g., `qwen-max`, `qwen-plus`) | -| 2 | **Model Version** | Specific model revision/fine-tune identifier | -| 3 | **Requesting User ID** | Authenticated user identity initiating the inference | -| 4 | **Timestamp (UTC)** | ISO 8601 UTC timestamp of the inference event | -| 5 | **Input Hash** | SHA-256 hash of the user's input prompt | -| 6 | **Output Hash** | SHA-256 hash of the AI-generated response | -| 7 | **Session Context** | Session identifier binding the request to a user workflow | -| 8 | **Approver Identity** | Human operator who approved safety-critical output | -| 9 | **Approval Timestamp** | When the human-in-the-loop approval was granted | -| 10 | **Artifact Hash** | SHA-256 hash of the deployed output (L5X file, compliance determination) | -| 11 | **Compliance Tag** | Regulatory framework identifier (NEC 2026, NFPA 70E, ISO 13849, Article 645) | +| # | Field | Description | +| --- | ---------------------- | ---------------------------------------------------------------------------- | +| 1 | **Model Identifier** | AI model name and version (e.g., `qwen-max`, `qwen-plus`) | +| 2 | **Model Version** | Specific model revision/fine-tune identifier | +| 3 | **Requesting User ID** | Authenticated user identity initiating the inference | +| 4 | **Timestamp (UTC)** | ISO 8601 UTC timestamp of the inference event | +| 5 | **Input Hash** | SHA-256 hash of the user's input prompt | +| 6 | **Output Hash** | SHA-256 hash of the AI-generated response | +| 7 | **Session Context** | Session identifier binding the request to a user workflow | +| 8 | **Approver Identity** | Human operator who approved safety-critical output | +| 9 | **Approval Timestamp** | When the human-in-the-loop approval was granted | +| 10 | **Artifact Hash** | SHA-256 hash of the deployed output (L5X file, compliance determination) | +| 11 | **Compliance Tag** | Regulatory framework identifier (NEC 2026, NFPA 70E, ISO 13849, Article 645) | ### Retention & Integrity: + - **Append-only** — Logs are tamper-evident, no mutation or deletion permitted - **7-year minimum retention** for industrial installations - **Queryable** by compliance officers, exportable for regulatory review @@ -151,4 +157,4 @@ Where: I = current (amps), L = one-way length (feet), CM = circular mils from NE --- -*This document certifies that Code Compass implements deterministic, cryptographically verified NEC compliance tooling with auditable AI governance controls suitable for data center procurement review and industrial safety-critical deployments.* +_This document certifies that Code Compass implements deterministic, cryptographically verified NEC compliance tooling with auditable AI governance controls suitable for data center procurement review and industrial safety-critical deployments._ diff --git a/architecture-diagram.html b/architecture-diagram.html index fed9745..947751a 100644 --- a/architecture-diagram.html +++ b/architecture-diagram.html @@ -1,275 +1,890 @@ - + - - -Code Compass — System Architecture - - - - - -
-
-
-

Code Compass — System Architecture

-
NEC Co-Pilot  ·  Qwen Cloud + DashScope AI  ·  Enterprise-Grade Compliance Layer
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Frontend - TanStack Start + React 19 - - - - - Vite Dev Proxy - /api/chat/qwen · /api/lookup - - - - - Express Backend - server/index.ts · port 3001 - REST API + CORS + Webhooks - - - - - qwenMemoryAgent.js - Core Orchestrator · Validation Gates - - - - - Qwen Cloud (DashScope) - dashscope-intl.aliyuncs.com - Model: qwen-max - preserve_thinking: true · temp 0.3 - - - - - Memory Bank - apprenticeProfile · activeProjectContext - longTermKnowledge - - - - - Supabase - PostgreSQL + RLS Auth - - - - - PostHog Analytics - Event Tracking · Exception Capture - - - - - Webhooks - Stripe Billing - - - - SECURITY BOUNDARY · CSP + RLS - - - - EXTERNAL SERVICES - - - - Legend - - - Frontend - - - Backend - - - Database / Storage - - - Cloud / AI Service - - - External Service - - - Security Boundary - - - Cloud Boundary - - -
- -
-
-
-
-

Frontend

+ + + Code Compass — System Architecture + + + + +
+
+
+

Code Compass — System Architecture

+
+ NEC Co-Pilot  ·  Qwen Cloud + DashScope AI  ·  + Enterprise-Grade Compliance Layer +
+
-
    -
  • • TanStack Start + React 19
  • -
  • • Vite dev proxy → Express:3001
  • -
  • • SPA with hash routing
  • -
  • • Industrial Control Panel UI
  • -
-
-
-
-
-

Backend & AI

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Frontend + + + TanStack Start + React 19 + + + + + + + Vite Dev Proxy + + + /api/chat/qwen · /api/lookup + + + + + + + Express Backend + + + server/index.ts · port 3001 + + + REST API + CORS + Webhooks + + + + + + + qwenMemoryAgent.js + + + Core Orchestrator · Validation Gates + + + + + + + Qwen Cloud (DashScope) + + + dashscope-intl.aliyuncs.com + + + Model: qwen-max + + + preserve_thinking: true · temp 0.3 + + + + + + + Memory Bank + + + apprenticeProfile · activeProjectContext + + + longTermKnowledge + + + + + + + Supabase + + + PostgreSQL + RLS Auth + + + + + + + PostHog Analytics + + + Event Tracking · Exception Capture + + + + + + + Webhooks + + + Stripe Billing + + + + + + SECURITY BOUNDARY · CSP + RLS + + + + + + EXTERNAL SERVICES + + + + + + Legend + + + + + Frontend + + + + + Backend + + + + + Database / Storage + + + + + Cloud / AI Service + + + + + External Service + + + + + Security Boundary + + + + + Cloud Boundary + + +
+ +
+
+
+
+

Frontend

+
+
    +
  • • TanStack Start + React 19
  • +
  • • Vite dev proxy → Express:3001
  • +
  • • SPA with hash routing
  • +
  • • Industrial Control Panel UI
  • +
+
+
+
+
+

Backend & AI

+
+
    +
  • • Express.js (port 3001)
  • +
  • • qwenMemoryAgent.js orchestrator
  • +
  • • DashScope intl API (qwen-max)
  • +
  • • Validation gates + memory R/W
  • +
+
+
+
+
+

Data & Compliance

+
+
    +
  • • Supabase PostgreSQL + RLS
  • +
  • • 3-file Memory Bank (JSON/MD)
  • +
  • • PostHog analytics + error capture
  • +
  • • NEC 2026 + EU AI Act audit trail
  • +
+
-
    -
  • • Express.js (port 3001)
  • -
  • • qwenMemoryAgent.js orchestrator
  • -
  • • DashScope intl API (qwen-max)
  • -
  • • Validation gates + memory R/W
  • -
-
-
-
-
-

Data & Compliance

+ + -
    -
  • • Supabase PostgreSQL + RLS
  • -
  • • 3-file Memory Bank (JSON/MD)
  • -
  • • PostHog analytics + error capture
  • -
  • • NEC 2026 + EU AI Act audit trail
  • -
-
-
- - - - + diff --git a/client/index.html b/client/index.html index 284134b..6b1fca6 100644 --- a/client/index.html +++ b/client/index.html @@ -2,16 +2,29 @@ - + Code Compass — NEC Co-Pilot - + - +
- + diff --git a/client/public/__manus__/debug-collector.js b/client/public/__manus__/debug-collector.js index 0504555..8c29cca 100644 --- a/client/public/__manus__/debug-collector.js +++ b/client/public/__manus__/debug-collector.js @@ -68,7 +68,9 @@ if (value === undefined) return undefined; if (typeof value === "string") { - return value.length > 1000 ? value.slice(0, 1000) + "...[truncated]" : value; + return value.length > 1000 + ? value.slice(0, 1000) + "...[truncated]" + : value; } if (typeof value !== "object") return value; @@ -178,7 +180,7 @@ getAttr("data-test") || null; - var type = tag === "input" ? (getAttr("type") || "text") : null; + var type = tag === "input" ? getAttr("type") || "text" : null; var href = tag === "a" ? getAttr("href") || null : null; // a small, stable hint for agents (avoid building full CSS paths) @@ -233,7 +235,8 @@ if (isSensitiveField(el)) return { masked: true, length: v.length }; - if (v.length > CONFIG.uiInputMaxLen) v = v.slice(0, CONFIG.uiInputMaxLen) + "…"; + if (v.length > CONFIG.uiInputMaxLen) + v = v.slice(0, CONFIG.uiInputMaxLen) + "…"; return v; } @@ -456,9 +459,10 @@ init = init || {}; var startTime = Date.now(); // Handle string, Request object, or URL object - var url = typeof input === "string" - ? input - : (input && (input.url || input.href || String(input))) || ""; + var url = + typeof input === "string" + ? input + : (input && (input.url || input.href || String(input))) || ""; var method = init.method || (input && input.method) || "GET"; // Don't intercept internal requests @@ -470,7 +474,9 @@ var requestHeaders = {}; try { if (init.headers) { - requestHeaders = Object.fromEntries(new Headers(init.headers).entries()); + requestHeaders = Object.fromEntries( + new Headers(init.headers).entries() + ); } } catch (e) { requestHeaders = { _parseError: true }; @@ -494,7 +500,9 @@ .then(function (response) { entry.duration = Date.now() - startTime; - var contentType = (response.headers.get("content-type") || "").toLowerCase(); + var contentType = ( + response.headers.get("content-type") || "" + ).toLowerCase(); var contentLength = response.headers.get("content-length"); entry.response = { @@ -516,9 +524,10 @@ } // Skip body capture for streaming responses (SSE, etc.) to avoid memory leaks - var isStreaming = contentType.indexOf("text/event-stream") !== -1 || - contentType.indexOf("application/stream") !== -1 || - contentType.indexOf("application/x-ndjson") !== -1; + var isStreaming = + contentType.indexOf("text/event-stream") !== -1 || + contentType.indexOf("application/stream") !== -1 || + contentType.indexOf("application/x-ndjson") !== -1; if (isStreaming) { entry.response.body = "[Streaming response - not captured]"; store.networkRequests.push(entry); @@ -527,20 +536,25 @@ } // Skip body capture for large responses to avoid memory issues - if (contentLength && parseInt(contentLength, 10) > CONFIG.maxBodyLength) { - entry.response.body = "[Response too large: " + contentLength + " bytes]"; + if ( + contentLength && + parseInt(contentLength, 10) > CONFIG.maxBodyLength + ) { + entry.response.body = + "[Response too large: " + contentLength + " bytes]"; store.networkRequests.push(entry); pruneBuffer(store.networkRequests, CONFIG.bufferSize.network); return response; } // Skip body capture for binary content types - var isBinary = contentType.indexOf("image/") !== -1 || - contentType.indexOf("video/") !== -1 || - contentType.indexOf("audio/") !== -1 || - contentType.indexOf("application/octet-stream") !== -1 || - contentType.indexOf("application/pdf") !== -1 || - contentType.indexOf("application/zip") !== -1; + var isBinary = + contentType.indexOf("image/") !== -1 || + contentType.indexOf("video/") !== -1 || + contentType.indexOf("audio/") !== -1 || + contentType.indexOf("application/octet-stream") !== -1 || + contentType.indexOf("application/pdf") !== -1 || + contentType.indexOf("application/zip") !== -1; if (isBinary) { entry.response.body = "[Binary content: " + contentType + "]"; store.networkRequests.push(entry); @@ -558,7 +572,8 @@ if (text.length <= CONFIG.maxBodyLength) { entry.response.body = sanitizeValue(tryParseJson(text)); } else { - entry.response.body = text.slice(0, CONFIG.maxBodyLength) + "...[truncated]"; + entry.response.body = + text.slice(0, CONFIG.maxBodyLength) + "...[truncated]"; } }) .catch(function () { @@ -615,24 +630,30 @@ xhr._manusData.url.indexOf("/__manus__/") !== 0 ) { xhr._manusData.startTime = Date.now(); - xhr._manusData.requestBody = body ? sanitizeValue(tryParseJson(body)) : null; + xhr._manusData.requestBody = body + ? sanitizeValue(tryParseJson(body)) + : null; xhr.addEventListener("load", function () { - var contentType = (xhr.getResponseHeader("content-type") || "").toLowerCase(); + var contentType = ( + xhr.getResponseHeader("content-type") || "" + ).toLowerCase(); var responseBody = null; // Skip body capture for streaming responses - var isStreaming = contentType.indexOf("text/event-stream") !== -1 || - contentType.indexOf("application/stream") !== -1 || - contentType.indexOf("application/x-ndjson") !== -1; + var isStreaming = + contentType.indexOf("text/event-stream") !== -1 || + contentType.indexOf("application/stream") !== -1 || + contentType.indexOf("application/x-ndjson") !== -1; // Skip body capture for binary content types - var isBinary = contentType.indexOf("image/") !== -1 || - contentType.indexOf("video/") !== -1 || - contentType.indexOf("audio/") !== -1 || - contentType.indexOf("application/octet-stream") !== -1 || - contentType.indexOf("application/pdf") !== -1 || - contentType.indexOf("application/zip") !== -1; + var isBinary = + contentType.indexOf("image/") !== -1 || + contentType.indexOf("video/") !== -1 || + contentType.indexOf("audio/") !== -1 || + contentType.indexOf("application/octet-stream") !== -1 || + contentType.indexOf("application/pdf") !== -1 || + contentType.indexOf("application/zip") !== -1; if (isStreaming) { responseBody = "[Streaming response - not captured]"; @@ -643,7 +664,8 @@ try { var text = xhr.responseText || ""; if (text.length > CONFIG.maxBodyLength) { - responseBody = text.slice(0, CONFIG.maxBodyLength) + "...[truncated]"; + responseBody = + text.slice(0, CONFIG.maxBodyLength) + "...[truncated]"; } else { responseBody = sanitizeValue(tryParseJson(text)); } @@ -817,5 +839,7 @@ forceReport: reportLogs, }; - console.debug("[Manus] Debug collector initialized (no rrweb, UI events only)"); + console.debug( + "[Manus] Debug collector initialized (no rrweb, UI events only)" + ); })(); diff --git a/client/src/App.tsx b/client/src/App.tsx index 5ba7957..8af221f 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1,6 +1,7 @@ import { Toaster } from "@/components/ui/sonner"; import { TooltipProvider } from "@/components/ui/tooltip"; import NotFound from "@/pages/NotFound"; +import { Analytics } from "@vercel/analytics/react"; import { Route, Switch } from "wouter"; import ErrorBoundary from "./components/ErrorBoundary"; import { ThemeProvider } from "./contexts/ThemeContext"; @@ -42,6 +43,7 @@ function App() { + diff --git a/client/src/_core/hooks/useAuth.ts b/client/src/_core/hooks/useAuth.ts index 01cc650..64771f8 100644 --- a/client/src/_core/hooks/useAuth.ts +++ b/client/src/_core/hooks/useAuth.ts @@ -70,7 +70,7 @@ export function useAuth(options?: UseAuthOptions) { if (typeof window === "undefined") return; if (window.location.pathname === redirectPath) return; - window.location.href = redirectPath + window.location.href = redirectPath; }, [ redirectOnUnauthenticated, redirectPath, diff --git a/client/src/components/AIChatBox.tsx b/client/src/components/AIChatBox.tsx index 1c00871..52b235f 100644 --- a/client/src/components/AIChatBox.tsx +++ b/client/src/components/AIChatBox.tsx @@ -127,7 +127,7 @@ export function AIChatBox({ const textareaRef = useRef(null); // Filter out system messages - const displayMessages = messages.filter((msg) => msg.role !== "system"); + const displayMessages = messages.filter(msg => msg.role !== "system"); // Calculate min-height for last assistant message to push user message to top const [minHeightForLastMessage, setMinHeightForLastMessage] = useState(0); @@ -143,7 +143,8 @@ export function AIChatBox({ // - user message: 40px (item height) + 16px (margin-top from space-y-4) = 56px // Note: margin-bottom is not counted because it naturally pushes the assistant message down const userMessageReservedHeight = 56; - const calculatedHeight = scrollAreaHeight - 32 - userMessageReservedHeight; + const calculatedHeight = + scrollAreaHeight - 32 - userMessageReservedHeight; setMinHeightForLastMessage(Math.max(0, calculatedHeight)); } @@ -152,14 +153,14 @@ export function AIChatBox({ // Scroll to bottom helper function with smooth animation const scrollToBottom = () => { const viewport = scrollAreaRef.current?.querySelector( - '[data-radix-scroll-area-viewport]' + "[data-radix-scroll-area-viewport]" ) as HTMLDivElement; if (viewport) { requestAnimationFrame(() => { viewport.scrollTo({ top: viewport.scrollHeight, - behavior: 'smooth' + behavior: "smooth", }); }); } @@ -311,7 +312,7 @@ export function AIChatBox({