# Lite Template Extraction Implementation Plan

> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.

**Goal:** Turn the current AIPROS project into a runnable, brandable Skill management template for classroom demos and customer practice.

**Architecture:** Keep the existing React/Hono app, but narrow the visible product surface to Skill upload, AI creation, display, download, API invocation, runtime configuration, user/audit management, process architecture, and a real operations ranking table. Hide knowledge-file and drawing modules from the template navigation while leaving the runtime and creator infrastructure intact.

**Tech Stack:** React 18, React Router 6, Vite 5, Tailwind CSS, Hono, SQLite/D1-style DB, Node `node:test`.

---

### Task 1: Add Lite Template Contract And Ranking Tests

**Files:**
- Create: `cf-worker/src/routes/ops-rankings.test.js`
- Modify: `cf-worker/src/routes/apikeys.test.js` or create focused test if absent

**Steps:**
1. Write failing backend coverage proving draft Skills cannot receive API Keys.
2. Write failing backend coverage proving `/api/ops/rankings` returns domain-level ranking rows and top Skill rows from existing tables.
3. Run focused tests and confirm failures are for missing behavior.

### Task 2: Implement Backend Contract

**Files:**
- Modify: `cf-worker/src/routes/apikeys.js`
- Create: `cf-worker/src/routes/ops.js`
- Modify: `cf-worker/src/index.js`

**Steps:**
1. Require `skills.status = 'published'` before creating API Keys.
2. Add `/api/ops/rankings` that aggregates by first segment of `node_path`.
3. Return counts for total Skills, published Skills, downloads, likes, dislikes, API calls, successful calls, failed calls, average latency, and ranked top Skills.
4. Run focused backend tests.

### Task 3: Add Product Configuration And Frontend Surface

**Files:**
- Create: `src/productConfig.js`
- Modify: `src/featureFlags.js`
- Modify: `src/components/Sidebar.jsx`
- Modify: `src/App.jsx`
- Modify: `src/pages/PlatformGovernance.jsx`
- Modify: `src/pages/Login.jsx`

**Steps:**
1. Add a single brand/config object for product name, subtitle, logo text, admin contacts, and visible modules.
2. Use config in navigation and brand surfaces.
3. Hide knowledge file routes and AI drawing from the visible template.
4. Route legacy `/create` to the AI creation experience.

### Task 4: Normalize Skill State And API Access UX

**Files:**
- Modify: `src/contexts/SkillsContext.jsx`
- Modify: `src/components/StatusBadge.jsx`
- Modify: `src/services/api.js`
- Modify: `src/pages/MySkills.jsx`
- Modify: `src/pages/SkillEditPage.jsx`
- Modify: `src/pages/ApiAccess.jsx`

**Steps:**
1. Standardize user-facing states to `draft`, `published`, `archived`.
2. Remove frontend version hard-coding; use backend `version` with `v0.0.0` fallback.
3. Show only published Skills in API Key creation selector.
4. Keep compatibility labels for older `testing/offline` rows.

### Task 5: Replace Skill Operations Dashboard With Operations Ranking Table

**Files:**
- Modify: `src/pages/SkillOps.jsx`
- Modify: `src/services/api.js`

**Steps:**
1. Add frontend API client for `/ops/rankings`.
2. Replace complex metric dashboard with a dense operations table and top Skill side panel.
3. Include domain, total/published counts, downloads, likes, API calls, success rate, average latency, and hot score.

### Task 6: Add Template Readme And Package Zip

**Files:**
- Create: `README-LITE-TEMPLATE.md`

**Steps:**
1. Document the standard schema, key routes, setup commands, branding config, and retained module scope.
2. Run frontend build and full focused test suites.
3. Create a clean source zip excluding `.git`, `node_modules`, `dist`, runtime data, uploads, outputs, and secret env files.
4. Place the zip in the `高维公开课` directory.
