feat: add ISSLOP AI usage analysis CLI commands, game router, and politics topic

- Add `cmd_isslop_prune`, `cmd_isslop_clear`, `cmd_isslop_analyze` CLI commands for AI usage analysis job management
- Register `/game` router with `index` and `farm` endpoints for Code Farm idle game
- Add `politics` to allowed TOPICS constant replacing `signals`
- Introduce `ISSLOP_DIR`, `ISSLOP_WORKSPACES_DIR`, `ISSLOP_RUNS_DIR`, `ISSLOP_MEDIA_DIR` config paths
- Add `clear_user_stars` and `clear_user_projects_cache` calls on vote and project create/delete
- Update `make prod` to use `nproc` workers via `DEVPLACE_WEB_WORKERS` env var
- Convert `database.py` and `utils.py` to packages for modular structure
- Add `devplace apikey` and `devplace token` CLI subcommands for API key and access token management
This commit is contained in:
2026-07-06 03:57:47 +00:00
parent f1bdefd834
commit 9a8046ab2a
110 changed files with 1466 additions and 374 deletions
+1 -1
View File
@@ -458,7 +458,7 @@ four ways to sign requests.
"string",
True,
"vote",
"One of: comment, reply, mention, vote, follow, message, badge, level, issue.",
"One of: comment, reply, mention, vote, follow, message, badge, level, issue, reminder, harvest_stolen.",
),
field(
"channel",
+8 -6
View File
@@ -22,8 +22,9 @@ distinguish the form type).
The POST endpoints are **actions**: they accept form fields, set or clear the `session` cookie,
and return a `302` redirect (or the JSON envelope for JSON callers).
**Sign-up requires a valid `g-recaptcha-response`** when reCAPTCHA is enabled. Use the JSON
envelope to see validation errors as `{ "error": "validation", "fields": {...} }`.
**Sign-up requires a unique `username` and `email`** plus a `confirm_password` that matches the
password; **you log in with your `email` and password**. JSON callers receive validation errors
as a `422` with the shape `{ "fields": {...}, "messages": [...] }`.
""",
"endpoints": [
endpoint(
@@ -45,10 +46,10 @@ envelope to see validation errors as `{ "error": "validation", "fields": {...} }
encoding="form",
destructive=False,
params=[
field("username", "form", "string", True, "alice", "Username, 3-20 characters."),
field("username", "form", "string", True, "alice", "Username, 3-32 characters (letters, numbers, hyphens, underscores)."),
field("email", "form", "string", True, "alice@example.com", "Email address; must be unique and contain an @."),
field("password", "form", "string", True, "mysecret", "Password, 6+ characters."),
field("confirm_password", "form", "string", True, "mysecret", "Must match password."),
field("g-recaptcha-response", "form", "string", False, "", "reCAPTCHA token when enabled."),
],
),
endpoint(
@@ -68,12 +69,13 @@ envelope to see validation errors as `{ "error": "validation", "fields": {...} }
method="POST",
path="/auth/login",
title="Log in",
summary="Authenticate with username and password. Sets the session cookie.",
summary="Authenticate with email and password. Sets the session cookie.",
auth="public",
encoding="form",
params=[
field("username", "form", "string", True, "alice", "Your username."),
field("email", "form", "string", True, "alice@example.com", "Your registered email."),
field("password", "form", "string", True, "mysecret", "Your password."),
field("remember_me", "form", "string", False, "on", "Send 'on' to extend the session to the remember-me lifetime."),
field("next", "form", "string", False, "", "Redirect target after login."),
],
),
+6 -5
View File
@@ -9,9 +9,10 @@ GROUP = {
"intro": """
# Container Manager
Build versioned Docker images for a project and run supervised container instances. Every endpoint is
**administrator only** (running arbitrary Dockerfiles with docker socket access is root-equivalent).
Mutations flip desired state; a single reconciler converges containers to it.
Run supervised container instances for a project. There is no in-app image building: every instance
runs one shared prebuilt image (`ppy:latest`) with the project's workspace mounted at `/app`. Every
endpoint is **administrator only** (docker socket access is root-equivalent). Mutations flip desired
state; a single reconciler converges containers to it.
""",
"endpoints": [
endpoint(
@@ -118,7 +119,7 @@ Mutations flip desired state; a single reconciler converges containers to it.
"python app.py",
"Optional boot command.",
),
field("run_as_uid", "form", "string", False, "USER_UID", "DevPlace user uid whose identity and API key are injected (PRAVDA_API_KEY, PRAVDA_USER_UID). Does NOT change the container OS user (always pravda, uid 1000)."),
field("run_as_uid", "form", "string", False, "USER_UID", "DevPlace user uid whose identity and API key are injected (DEVPLACE_API_KEY, DEVPLACE_USER_UID). Does NOT change the container OS user (always pravda, uid 1000)."),
field("boot_language", "form", "enum", False, "none", "Boot source language.", ["none", "python", "bash"]),
field("boot_script", "form", "textarea", False, "print('hi')", "Boot source code run on launch (takes precedence over boot_command)."),
field(
@@ -478,7 +479,7 @@ Mutations flip desired state; a single reconciler converges containers to it.
params=[
field("project_slug", "form", "string", True, "PROJECT_SLUG", "Project that becomes the /app root."),
field("name", "form", "string", True, "staging", "Instance name."),
field("run_as_uid", "form", "string", False, "USER_UID", "DevPlace user uid whose identity and API key are injected (PRAVDA_API_KEY, PRAVDA_USER_UID). Does NOT change the container OS user (always pravda, uid 1000)."),
field("run_as_uid", "form", "string", False, "USER_UID", "DevPlace user uid whose identity and API key are injected (DEVPLACE_API_KEY, DEVPLACE_USER_UID). Does NOT change the container OS user (always pravda, uid 1000)."),
field("boot_language", "form", "enum", False, "none", "Boot source language.", ["none", "python", "bash"]),
field("boot_script", "form", "textarea", False, "print('hi')", "Boot source code run on launch (takes precedence over boot_command)."),
field("boot_command", "form", "string", False, "python app.py", "Fallback boot command when no boot_script is set."),
+2 -2
View File
@@ -344,7 +344,7 @@ four ways to sign requests.
method="POST",
path="/profile/{username}/notifications",
title="Toggle a notification preference",
summary="Enable or disable one notification type on one channel (in-app or push). Admins may target any user. Types: comment, reply, mention, vote, follow, message, badge, level, issue.",
summary="Enable or disable one notification type on one channel (in-app or push). Admins may target any user. Types: comment, reply, mention, vote, follow, message, badge, level, issue, reminder, harvest_stolen.",
auth="user",
encoding="form",
destructive=True,
@@ -363,7 +363,7 @@ four ways to sign requests.
"string",
True,
"vote",
"One of: comment, reply, mention, vote, follow, message, badge, level, issue.",
"One of: comment, reply, mention, vote, follow, message, badge, level, issue, reminder, harvest_stolen.",
),
field(
"channel",
+190 -1
View File
@@ -4,7 +4,7 @@ from .._shared import endpoint, field
GROUP = {
"slug": "tools",
"title": "Tools (SEO & DeepSearch)",
"title": "Tools (SEO, DeepSearch & AI Usage Analyzer)",
"intro": """
# Tools: SEO Diagnostics & DeepSearch
@@ -17,6 +17,10 @@ technical, on-page, structured-data, Core Web Vitals, accessibility and AI-readi
synthesises a cited report with confidence scoring and gap analysis, plus a grounded chat over
the results.
**AI Usage Analyzer** classifies a git repository or website as AI slop, sophisticated AI-assisted
work or genuine human work, and publishes a persistent report with an embeddable authenticity
badge.
Every endpoint follows the shared [Conventions & Errors](/docs/conventions.html). These are
**capability URLs**: the job `uid` is an unguessable identifier, so anyone holding it can read the
status and report.
@@ -229,5 +233,190 @@ status and report.
"export_pdf_url": "/tools/deepsearch/DEEPSEARCH_JOB_UID/export.pdf",
},
),
endpoint(
id="tools-isslop-run",
method="POST",
path="/tools/isslop/run",
title="Queue a AI usage analysis",
summary="Start a background authenticity analysis of a git repository or website. Returns the job uid plus status, events and report URLs.",
auth="public",
encoding="form",
params=[
field("url", "form", "string", True, "https://github.com/owner/repository", "Repository (http/git/ssh) or website URL to classify."),
],
sample_response={
"uid": "ISSLOP_UID",
"status_url": "/tools/isslop/ISSLOP_UID",
"events_url": "/tools/isslop/ISSLOP_UID/events",
"report_url": "/tools/isslop/ISSLOP_UID/report",
"topic": "public.isslop.ISSLOP_UID",
},
),
endpoint(
id="tools-isslop-list",
method="GET",
path="/tools/isslop/list",
title="My AI usage analyses",
summary="List the caller's analyses, newest first. Member history is account-bound; guest history is session-bound and claimed by the account on first signed-in call.",
auth="public",
params=[
field("limit", "query", "integer", False, "50", "Maximum analyses to return (1-200)."),
],
sample_response={
"analyses": [
{
"uid": "ISSLOP_UID",
"status": "completed",
"source_url": "https://github.com/owner/repository",
"source_kind": "git",
"grade": "B",
"human_percent": 71.4,
"ai_percent": 28.6,
"category": "human-clean",
"report_url": "/tools/isslop/ISSLOP_UID/report",
"badge_url": "/tools/isslop/ISSLOP_UID/badge.svg",
}
]
},
),
endpoint(
id="tools-isslop-status",
method="GET",
path="/tools/isslop/{uid}",
title="AI usage analysis status",
summary="Poll an analysis. Once completed, grade, category and the human/AI split are populated.",
auth="public",
params=[
field("uid", "path", "string", True, "ISSLOP_UID", "Analysis uid returned when the run was queued."),
],
sample_response={
"uid": "ISSLOP_UID",
"status": "completed",
"source_url": "https://github.com/owner/repository",
"source_kind": "git",
"grade": "B",
"slop_score": 31.2,
"origin_score": 28.0,
"quality_deficit_score": 22.5,
"human_percent": 71.4,
"ai_percent": 28.6,
"category": "human-clean",
"confidence": "medium",
"files_total": 120,
"files_analyzed": 96,
"report_url": "/tools/isslop/ISSLOP_UID/report",
"badge_url": "/tools/isslop/ISSLOP_UID/badge.svg",
"events_url": "/tools/isslop/ISSLOP_UID/events",
"topic": "public.isslop.ISSLOP_UID",
},
),
endpoint(
id="tools-isslop-events",
method="GET",
path="/tools/isslop/{uid}/events",
title="AI usage analysis event trail",
summary="The persisted, ordered event trail of an analysis. Use ?after=SEQ to poll incrementally; live frames also stream on the pub/sub topic.",
auth="public",
params=[
field("uid", "path", "string", True, "ISSLOP_UID", "Analysis uid."),
field("after", "query", "integer", False, "0", "Return only events with a sequence number greater than this."),
field("limit", "query", "integer", False, "2000", "Maximum events to return (1-5000)."),
],
sample_response={
"uid": "ISSLOP_UID",
"status": "running",
"events": [
{"seq": 1, "kind": "stage", "message": "Resolving source type", "data": {"stage": "resolve"}, "created_at": "2026-06-14T10:00:00+00:00"}
],
},
),
endpoint(
id="tools-isslop-report",
method="GET",
path="/tools/isslop/{uid}/report",
title="AI usage analysis report",
summary="Full report: verdict, markdown body, per-file results, image review and badge embeds. Negotiates HTML or JSON.",
auth="public",
params=[
field("uid", "path", "string", True, "ISSLOP_UID", "Analysis uid of a finished run."),
],
sample_response={
"uid": "ISSLOP_UID",
"status": "completed",
"source_url": "https://github.com/owner/repository",
"grade": "B",
"human_percent": 71.4,
"ai_percent": 28.6,
"category": "human-clean",
"markdown": "# Verdict...",
"generator_model": "molodetz",
"badge": {
"badge_url": "https://devplace.example/tools/isslop/ISSLOP_UID/badge.svg",
"report_url": "https://devplace.example/tools/isslop/ISSLOP_UID/report",
"markdown": "[![authenticity human score](...)](...)",
"html": "<a href=...><img src=.../></a>",
},
"files": [{"path": "src/main.py", "language": "python", "lines": 120, "origin_score": 35.0, "quality_deficit_score": 18.0, "category": "human-clean", "signals": []}],
"images": [{"path": "assets/hero.png", "ai_probability": 84.0, "grade": "F", "verdict": "ai-generated", "image_kind": "illustration", "tells": ["waxy skin"], "description": "...", "thumb_url": "/tools/isslop/ISSLOP_UID/media/0f3a9c2d1b4e5a67.webp"}],
},
),
endpoint(
id="tools-isslop-report-md",
method="GET",
path="/tools/isslop/{uid}/report.md",
title="Download report markdown",
summary="Download the full report as a markdown file.",
auth="public",
params=[
field("uid", "path", "string", True, "ISSLOP_UID", "Analysis uid of a finished run."),
],
),
endpoint(
id="tools-isslop-source",
method="GET",
path="/tools/isslop/{uid}/source",
title="Annotated source of a flagged file",
summary="The persisted source of a signal-bearing file with its signals, rendered with line numbers and highlighted findings (HTML) or as JSON. Linked from the report's file table, signal chips and prose.",
auth="public",
params=[
field("uid", "path", "string", True, "ISSLOP_UID", "Analysis uid."),
field("path", "query", "string", True, "src/libs/Env.ts", "Workspace-relative file path from the report."),
field("line", "query", "integer", False, "12", "Line to focus and highlight."),
],
sample_response={
"uid": "ISSLOP_UID",
"path": "src/libs/Env.ts",
"language": "typescript",
"category": "human-clean",
"origin_score": 24.0,
"quality_deficit_score": 34.9,
"source": "import { createEnv } from '@t3-oss/env-nextjs';...",
"truncated": False,
"signals": [{"code": "PUBLIC_ENV_SECRET", "title": "Secret exposed via public env variable", "severity": "strong", "line": 12}],
},
),
endpoint(
id="tools-isslop-media",
method="GET",
path="/tools/isslop/{uid}/media/{name}",
title="Reviewed image thumbnail",
summary="Aspect-preserving WebP thumbnail of a reviewed image, persisted as evidence. The name comes from the report's images[].thumb_url.",
auth="public",
params=[
field("uid", "path", "string", True, "ISSLOP_UID", "Analysis uid."),
field("name", "path", "string", True, "0f3a9c2d1b4e5a67.webp", "Thumbnail file name from the report."),
],
),
endpoint(
id="tools-isslop-badge",
method="GET",
path="/tools/isslop/{uid}/badge.svg",
title="Authenticity badge",
summary="Embeddable SVG badge showing the human score and authenticity grade, linking to the report.",
auth="public",
params=[
field("uid", "path", "string", True, "ISSLOP_UID", "Analysis uid."),
],
),
],
}