chore: import upstream snapshot with attribution
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:38:58 +08:00
commit bb5c75ce05
8824 changed files with 1946442 additions and 0 deletions
@@ -0,0 +1,89 @@
-- Schema para tracking de versiones de Claude Code en Neon Database
-- Tabla principal: versiones de Claude Code
CREATE TABLE IF NOT EXISTS claude_code_versions (
id SERIAL PRIMARY KEY,
version VARCHAR(50) NOT NULL UNIQUE,
published_at TIMESTAMP WITH TIME ZONE NOT NULL,
changelog_content TEXT,
npm_url VARCHAR(500),
github_url VARCHAR(500),
discord_notified BOOLEAN DEFAULT FALSE,
discord_notification_sent_at TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Tabla: cambios individuales parseados del changelog
CREATE TABLE IF NOT EXISTS claude_code_changes (
id SERIAL PRIMARY KEY,
version_id INTEGER REFERENCES claude_code_versions(id) ON DELETE CASCADE,
change_type VARCHAR(50), -- 'feature', 'fix', 'improvement', 'breaking', 'deprecation'
description TEXT NOT NULL,
category VARCHAR(100), -- 'Plugin System', 'Performance', 'CLI', etc.
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Tabla: logs de notificaciones Discord
CREATE TABLE IF NOT EXISTS discord_notifications_log (
id SERIAL PRIMARY KEY,
version_id INTEGER REFERENCES claude_code_versions(id) ON DELETE CASCADE,
webhook_url VARCHAR(500),
payload JSONB,
response_status INTEGER,
response_body TEXT,
error_message TEXT,
sent_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Tabla: metadata de monitoreo
CREATE TABLE IF NOT EXISTS monitoring_metadata (
id SERIAL PRIMARY KEY,
last_check_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
last_version_found VARCHAR(50),
check_count INTEGER DEFAULT 0,
error_count INTEGER DEFAULT 0,
last_error TEXT,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Índices para optimización
CREATE INDEX idx_versions_version ON claude_code_versions(version);
CREATE INDEX idx_versions_published_at ON claude_code_versions(published_at DESC);
CREATE INDEX idx_versions_discord_notified ON claude_code_versions(discord_notified);
CREATE INDEX idx_changes_version_id ON claude_code_changes(version_id);
CREATE INDEX idx_changes_type ON claude_code_changes(change_type);
CREATE INDEX idx_notifications_version_id ON discord_notifications_log(version_id);
CREATE INDEX idx_notifications_sent_at ON discord_notifications_log(sent_at DESC);
-- Función para actualizar updated_at automáticamente
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- Trigger para claude_code_versions
CREATE TRIGGER update_claude_code_versions_updated_at
BEFORE UPDATE ON claude_code_versions
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();
-- Trigger para monitoring_metadata
CREATE TRIGGER update_monitoring_metadata_updated_at
BEFORE UPDATE ON monitoring_metadata
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();
-- Insertar registro inicial de metadata
INSERT INTO monitoring_metadata (last_version_found, check_count, error_count)
VALUES (NULL, 0, 0)
ON CONFLICT DO NOTHING;
-- Comentarios para documentación
COMMENT ON TABLE claude_code_versions IS 'Almacena todas las versiones de Claude Code detectadas';
COMMENT ON TABLE claude_code_changes IS 'Cambios individuales extraídos del changelog de cada versión';
COMMENT ON TABLE discord_notifications_log IS 'Log de todas las notificaciones enviadas a Discord';
COMMENT ON TABLE monitoring_metadata IS 'Metadata del sistema de monitoreo (última verificación, errores, etc)';
@@ -0,0 +1,114 @@
-- Schema for tracking CLI command usage in Neon Database
-- Main table: command execution logs
CREATE TABLE IF NOT EXISTS command_usage_logs (
id SERIAL PRIMARY KEY,
command_name VARCHAR(100) NOT NULL,
cli_version VARCHAR(50),
node_version VARCHAR(50),
platform VARCHAR(50),
arch VARCHAR(50),
execution_timestamp TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
session_id VARCHAR(100),
metadata JSONB,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Table: aggregated command statistics
CREATE TABLE IF NOT EXISTS command_usage_stats (
id SERIAL PRIMARY KEY,
command_name VARCHAR(100) NOT NULL UNIQUE,
total_executions BIGINT DEFAULT 0,
last_execution TIMESTAMP WITH TIME ZONE,
first_execution TIMESTAMP WITH TIME ZONE,
unique_sessions BIGINT DEFAULT 0,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Indexes for optimization
CREATE INDEX idx_command_logs_name ON command_usage_logs(command_name);
CREATE INDEX idx_command_logs_timestamp ON command_usage_logs(execution_timestamp DESC);
CREATE INDEX idx_command_logs_session ON command_usage_logs(session_id);
CREATE INDEX idx_command_logs_platform ON command_usage_logs(platform);
CREATE INDEX idx_command_stats_name ON command_usage_stats(command_name);
-- Function to update command stats automatically
CREATE OR REPLACE FUNCTION update_command_stats()
RETURNS TRIGGER AS $$
BEGIN
-- Upsert command statistics
INSERT INTO command_usage_stats (
command_name,
total_executions,
last_execution,
first_execution,
unique_sessions
)
VALUES (
NEW.command_name,
1,
NEW.execution_timestamp,
NEW.execution_timestamp,
1
)
ON CONFLICT (command_name) DO UPDATE SET
total_executions = command_usage_stats.total_executions + 1,
last_execution = NEW.execution_timestamp,
unique_sessions = (
SELECT COUNT(DISTINCT session_id)
FROM command_usage_logs
WHERE command_name = NEW.command_name
),
updated_at = NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- Trigger to update stats on new command log
CREATE TRIGGER trigger_update_command_stats
AFTER INSERT ON command_usage_logs
FOR EACH ROW
EXECUTE FUNCTION update_command_stats();
-- View: Daily command usage
CREATE OR REPLACE VIEW daily_command_usage AS
SELECT
command_name,
DATE(execution_timestamp) as date,
COUNT(*) as executions,
COUNT(DISTINCT session_id) as unique_users,
COUNT(DISTINCT platform) as platforms_count
FROM command_usage_logs
GROUP BY command_name, DATE(execution_timestamp)
ORDER BY date DESC, executions DESC;
-- View: Platform distribution
CREATE OR REPLACE VIEW platform_distribution AS
SELECT
platform,
COUNT(*) as total_executions,
COUNT(DISTINCT command_name) as unique_commands,
COUNT(DISTINCT session_id) as unique_users
FROM command_usage_logs
GROUP BY platform
ORDER BY total_executions DESC;
-- View: Most popular commands (last 30 days)
CREATE OR REPLACE VIEW popular_commands_30d AS
SELECT
command_name,
COUNT(*) as executions,
COUNT(DISTINCT session_id) as unique_users,
MAX(execution_timestamp) as last_used
FROM command_usage_logs
WHERE execution_timestamp > NOW() - INTERVAL '30 days'
GROUP BY command_name
ORDER BY executions DESC;
-- Comments for documentation
COMMENT ON TABLE command_usage_logs IS 'Raw logs of every CLI command execution';
COMMENT ON TABLE command_usage_stats IS 'Aggregated statistics for each command';
COMMENT ON VIEW daily_command_usage IS 'Daily breakdown of command usage';
COMMENT ON VIEW platform_distribution IS 'Usage distribution across platforms (macOS, Linux, Windows)';
COMMENT ON VIEW popular_commands_30d IS 'Most popular commands in the last 30 days';