• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
Downchuck

Downchuck

con-juan

Public
Like
con-juan
Home
Code
10
frontend
1
src
6
tests
4
AUTOBOT.md
EXAMPLES.md
README.md
H
chat-api.ts
database.ts
H
power-abuse-analyzer.ts
H
static-file-server.ts
Branches
1
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
AUTOBOT.md
Code
/
AUTOBOT.md
Search
5/22/2025
Viewing readonly version of main branch: v80
View latest version
AUTOBOT.md

Power Abuse Analyzer - Development Conversation

Initial Request

Human: Build me a conversational judgement analysis chat robot that identifies covert or subtle abuse from powerful people in books, or messages or their public statements. Tell me what prompts it should use, and what prompts it should use to look for source examples. For example, Steve Jobs could be an abusive CEO. Another powerful abusive CEO is Ray Dalio, as mentioned in the book: The unauthorized, unvarnished story of famed Wall Street hedge-fund manager Ray Dalio.

Initial Implementation

I created a conversational judgment analysis chat robot that identifies subtle forms of abuse from powerful figures in various texts. The system includes:

Core Components

  • Backend API (power-abuse-analyzer.ts): Analyzes text for subtle abuse patterns using OpenAI's GPT-4o model
  • Frontend Interface (frontend/index.html): A user-friendly chat interface for interacting with the analyzer
  • Static File Server (static-file-server.ts): Serves the frontend files

Key Features

  • Text Analysis: Identifies 14 different patterns of subtle abuse in any text
  • Conversational Interface: Users can chat with the system, ask questions, or submit text for analysis
  • Pre-configured Examples: Includes analysis capabilities for known figures like Steve Jobs and Ray Dalio
  • Pattern Education: Explains common patterns of subtle abuse from powerful figures
  • Severity Rating: Classifies identified patterns as subtle, moderate, or overt
  • Confidence Scoring: Provides confidence levels for each identified pattern
  • Response Suggestions: Offers constructive ways to address problematic language

Prompts Used

The system uses two main prompts:

  1. Analysis Prompt: Guides the AI in identifying subtle forms of abuse in text:

    • Focuses on 14 specific patterns of subtle abuse
    • Requests severity ratings, confidence levels, and specific examples
    • Asks for overall assessment and suggested responses
  2. Question-Handling Prompt: Helps the AI answer questions about power abuse:

    • Provides educational information about abuse patterns
    • Offers concrete examples when appropriate
    • Gives balanced analysis of specific powerful figures

Abuse Patterns Detected

The system identifies 14 patterns of subtle abuse, including:

  • Gaslighting or reality distortion
  • Subtle threats or intimidation
  • Minimization of harm
  • Shifting blame to victims
  • Appeals to authority to silence criticism
  • False equivalencies
  • Dehumanizing language
  • Plausible deniability tactics
  • Coded language
  • Misuse of institutional power
  • Intellectual intimidation
  • Benevolent authoritarianism
  • Selective meritocracy
  • Institutional shield

SQLite Storage Enhancement Request

Human: Create a backend that allows a user to save their chat into SQLite - allow them to ask questions of specific patterns -- that is, if a pattern is identified, such as "reality distortion", allow them to say, hey, I have more examples of this, then add examples, and have it continue on that thread. You can use SQLite recursive query statements for this.

SQLite Storage Implementation

I enhanced the Power Abuse Analyzer with SQLite storage for chat history and pattern examples, and implemented the ability to continue conversations about specific patterns.

New Components

  1. Database Module (database.ts):

    • Manages SQLite operations
    • Implements tables for sessions, messages, patterns, and examples
    • Provides functions for CRUD operations
    • Uses recursive CTEs for threaded conversations
  2. Chat API (chat-api.ts):

    • Handles chat sessions and messages
    • Processes pattern follow-up questions
    • Manages user-provided examples
    • Formats responses for the frontend
  3. Updated Frontend:

    • Adds session management
    • Supports pattern follow-up conversations
    • Allows adding examples to patterns
    • Provides export functionality

Database Schema

The application uses SQLite with the following tables:

  • Sessions: Stores chat sessions with titles and timestamps
  • Messages: Stores messages within sessions, with support for threaded conversations
  • Patterns: Stores identified abuse patterns with severity and confidence ratings
  • Examples: Stores examples of patterns, including user-provided examples

New Features

  1. Persistent Sessions:

    • Create and name analysis sessions
    • Save all messages and identified patterns
    • Load and continue previous sessions
  2. Pattern Examples:

    • Add your own examples to identified patterns
    • View all examples for a pattern, including user-provided ones
    • Use examples to improve pattern recognition
  3. Threaded Conversations:

    • Continue conversations about specific patterns
    • Ask follow-up questions about patterns
    • Get detailed explanations of pattern characteristics
  4. Export Functionality:

    • Export analysis results as JSON
    • Share or archive analysis sessions

New Prompt for Pattern Follow-Up

For handling follow-up questions about specific patterns:

You are an expert in identifying and explaining patterns of subtle abuse, manipulation, and problematic language from powerful people.
  
A user has previously identified the following pattern in some text:

Pattern: [pattern_type]
Explanation: [explanation]
Severity: [severity]
Confidence: [confidence]

Examples of this pattern:
[examples]

The user is now asking a follow-up question or providing additional information about this pattern.
If they are providing a new example, acknowledge it and explain how it fits the pattern.
If they are asking a question, provide a detailed, educational response about this specific pattern.
Focus on being helpful, informative, and sensitive to the nuances of power dynamics.

This enhancement allows users to build a knowledge base of abuse patterns over time, adding their own examples and exploring patterns in depth through continued conversation.

Project Structure and Testing Request

Human: Great, update the AUTOBOT.md file with the latest conversation added to it, add some ".test.ts" files with test cases and improve the overall structure of the project.

Project Structure Improvement and Testing

I improved the project structure and added test files to ensure reliability and maintainability:

Project Structure Improvements

  1. Organized Directory Structure:

    • Created a more organized file structure with dedicated directories for different components
    • Improved code organization and documentation
    • Added proper error handling and logging
  2. Code Quality Enhancements:

    • Added TypeScript type definitions for better type safety
    • Improved error handling with more specific error messages
    • Enhanced code comments and documentation
    • Standardized coding patterns across files
  3. Test Suite Implementation:

    • Added comprehensive test files for core components
    • Created test utilities for mocking dependencies
    • Implemented unit tests for critical functions
    • Added integration tests for API endpoints

Test Files Added

  1. power-abuse-analyzer.test.ts:

    • Tests for text analysis functionality
    • Tests for pattern extraction and classification
    • Tests for handling different types of input text
    • Tests for edge cases and error handling
  2. database.test.ts:

    • Tests for database initialization
    • Tests for CRUD operations on all tables
    • Tests for recursive queries and threaded conversations
    • Tests for data integrity and constraints
  3. chat-api.test.ts:

    • Tests for API endpoints
    • Tests for session management
    • Tests for message processing
    • Tests for pattern follow-up handling

Benefits of the Improved Structure

  • Maintainability: Better organized code is easier to maintain and extend
  • Reliability: Comprehensive tests ensure the system works as expected
  • Scalability: Modular structure allows for easier scaling and feature additions
  • Collaboration: Well-documented code facilitates collaboration among developers

These improvements make the Power Abuse Analyzer more robust, maintainable, and ready for future enhancements.

FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.