Commit Graph

586 Commits

Author SHA1 Message Date
root 2e1a5900ea docs(desktop-client): revise spec v2 with triple-review fixes
Address 6 Critical + 10 Warning findings from Claude + Codex + Gemini
cross-review:

- C1 Replace Network.responseReceivedExtraInfo path with EventSource /
  Fetch.takeResponseBodyAsStream routing per transport type; add
  Electron-Chromium CDP compatibility matrix commitment.
- C2 Default patch channel to pure-data DSL (no JS exec); executable
  fallback gated on utilityProcess + isolated-vm sandbox with frozen
  globals. Full TUF-style signing chain (patch_seq, hash, expires_at,
  key_id rotation, revokes, runtime hash re-verify).
- C3 Add RabbitMQ task_available fanout + Redis presence registry;
  SSE only pushes signals, task ownership decided atomically by
  lease endpoint.
- C4 platform_accounts gains platform_uid + account_fingerprint +
  UNIQUE(platform, platform_uid) enforcing workspace-exclusive
  binding in DB, not by client discipline.
- C5 Task protocol adds attempt_id + lease_token with
  extend/pause/resume/cancel endpoints; manual mode enters
  waiting_user status with extended lease; 409 on stale lease_token.
- C6 Rewrite scope estimate with 7 detect-only publish adapters and
  DeepSeek monitor placeholder called out explicitly; reshape as
  9-bucket 22-26 week effort; introduce Plan A/B/C split.

Warnings addressed: BrowserView->WebContentsView everywhere;
allowDowngrade spelling fix; client_token decoupled from
client_version with rotate/revoke APIs; safeStorage Linux
basic_text guard + separate vault-export for machine migration;
keep-alive token bucket + 429 backoff + resume warm-up;
packages/ui-shared carve-out (no admin-web cloning); state machine
gets failed/aborted/unknown terminal states; sqlc regeneration
footprint made explicit; crash recovery split by task.kind;
autoUpdater unit tests + pre-release smoke; trace phased
(Alpha=logs+shots, Phase 2=Playwright-compat export).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 21:05:41 +08:00
root 63667ed2d1 feat(membership): enforce tenant subscription plans with blocked UI
Add configurable membership plans (free/plus/pro) synced to DB on boot, a
subscription guard middleware that blocks tenant endpoints on expired or
missing plans, and a MembershipBlockedView that surfaces the reason so
the admin can contact the tenant owner. Quota and brand-library reads now
honor the active plan's policy JSON and expired subscriptions.
2026-04-18 20:56:05 +08:00
root 9ec9314aea docs(desktop-client): add Electron 桌面客户端 replacement design spec
Captures the full plan for replacing apps/browser-extension with an
Electron tray client: single main process with multi-session isolation,
embedded web-view login with OS-encrypted local cookie vault, CDP-based
LLM monitoring (no official APIs, cost-driven), unified PublishAdapter
and MonitorAdapter interfaces with dual-track updates (per-adapter patch
channel + full release channel), Playwright-grade tracing, new
/api/desktop/* protocol with SSE + 60s pull, and 5-arch multi-OS
packaging strategy.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 20:28:42 +08:00
root 6e77f72c53 feat(kol): return to source page after generation and poll while busy
- Add a ?source=workspace|templates query param when opening the
  generate page so the back button and the post-submit redirect return
  to the originating page; invalidate articles + workspace caches on
  success so the new article shows up immediately.
- Poll recent articles every 10s in WorkspaceView and TemplatesView
  while any article is in queued/pending/generating/running, and stop
  the timer once nothing is active.
- Mark the new article as generating inside the generation Submit
  transaction so the client sees the right status as soon as the task
  is queued.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 17:17:17 +08:00
root fe4a4ffeaa feat(kol): enrich assist generate with URL references and template prompt
- Add kolAssistURLResolver that fetches reference articles via the Ark
  URL extractor when the user's description contains http(s) links, and
  merges up to kolAssistReferenceContentMaxRunes of extracted content
  into the generate description.
- Rewrite the generate user prompt into a strict template-authoring
  brief: output only the final prompt template in Chinese, parameterize
  variable info as {{placeholder}}, require at least 3 placeholders
  when references exist, and cover goal/topic/title/structure/style/
  interaction/constraints.
- Wire LLMConfig and logger through NewKolAssistService and the
  handler.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 17:17:07 +08:00
root 052bf38dc4 feat(observability): enrich request logs with auth and knowledge context
- Collect per-request auth diagnostics (header presence, scheme, token
  fingerprint, failure stage/reason, subject, expiry) in the auth
  middleware and expose them through RequestLogContextFromGin so the
  shared logger middleware can emit them.
- Add route, query, user-agent, and referer fields to the request log.
- Log knowledge resolve outcome per stage (no_search_points,
  no_candidate_text, no_active_candidates, rerank_failed_fallback,
  resolved) with candidate/selected snippet previews and precise facts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 17:16:57 +08:00
root 4bbce5f083 feat(kol): add SSE streaming for prompt assist
- Extract assist runtime (prompt building, response parsing, finalize)
  from the worker into kol_assist_runtime so the sync streaming path
  and the async task path share the same logic.
- Add POST /kol/manage/assist/stream as a Server-Sent Events endpoint
  emitting start/delta/completed/error events, and wire it to a
  streamAssist helper on kolManageApi that reports ApiClientError with
  the server's error envelope.
- Stream generated content live in KolPromptEditor and KolGenerateView,
  switching KolPromptEditArea to a boolean aiBusy flag and refining the
  generator page layout.
- Add KolAssistStreamEvent to shared types.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 16:17:11 +08:00
root 79c65c1da7 feat(kol): expand variable schema and polish KOL UI
- Add length/range limits to KOL variable definitions: max_length and
  default_value for input/textarea, min_value/max_value/default_number
  for number. Backend validates and normalizes; frontend renders limit
  inputs in KolVariableConfig and applies limits at runtime in
  KolDynamicForm.
- Sort workspace cards by most recent prompt/package update, falling
  back to granted_at. Adds updated_at to KolWorkspaceCard.
- Polish TemplatesView, WorkspaceView, and KOL package management UI;
  route create/update/publish/archive/delete toasts through i18n and
  expand package form copy and status labels.
- Remove stale KnowledgeView.vue.patch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 15:01:40 +08:00
root 1dd316a34b feat(kol-web): add /kol/profile page with nav entry 2026-04-18 14:10:27 +08:00
root 4ac7339c2d feat(kol-web): add KolPersonaCard with inline editing 2026-04-18 14:09:20 +08:00
root 4026aa7dad feat(kol-web): add i18n keys for KOL profile page 2026-04-18 14:08:22 +08:00
root ccf7f8080b feat(kol-web): add updateProfile and uploadAvatar to kolManageApi 2026-04-18 14:07:01 +08:00
root d2922478ed feat(kol): expose PUT /kol/manage/profile and POST /kol/manage/profile/avatar 2026-04-18 14:06:20 +08:00
root 1393b25419 feat(kol): add avatar upload to KolProfileService 2026-04-18 14:05:09 +08:00
root 0e3515530f feat(kol): add KolProfileService.UpdateProfile 2026-04-18 14:03:49 +08:00
root 4bfa4242ef feat(kol): add KOL profile field validators 2026-04-18 14:03:07 +08:00
root 8c531054b3 docs: add KOL profile page implementation plan
9 TDD tasks, each with bite-sized steps and commit points:
validators → service → avatar upload → handlers/routes →
API client → i18n → persona card → view/route/nav → verify.
2026-04-18 14:01:54 +08:00
root 26dd75e548 docs: add KOL profile page design spec
- KOL 工作台新增「个人主页」独立页,明确与租户/SaaS 账号设置区分
- 定位为精调模版展示页 + KOL 人设自助编辑
- 页面内联编辑、头像复用 image_service、仅展示已发布模版
2026-04-18 13:55:20 +08:00
root b2605abd6a feat: Enhance Kol Generation Service with web search and knowledge group support
- Added `EnableWebSearch` and `KnowledgeGroupIDs` fields to `KolGenerationSubmitRequest`.
- Updated `Submit` method in `KolGenerationService` to handle new request fields.
- Integrated web search and knowledge group validation based on card configuration.
- Introduced caching mechanisms in `KolPackageService`, `KolPromptService`, and `KolSubscriptionAdminService` to improve performance.
- Implemented knowledge context resolution in `KolGenerationWorker` to enrich prompts with relevant knowledge snippets.
- Added utility functions for handling card configuration in both backend and frontend.
- Created tests for knowledge extraction and rendering to ensure accuracy and reliability.
2026-04-18 13:47:32 +08:00
root 3ef0807456 fix: Enhance Kol Variable Rendering and Management
- Updated the regex for placeholder matching to support more flexible key formats.
- Refactored variable storage to allow both ID and key lookups in rendering.
- Improved schema validation to check for duplicate keys and enforce non-empty keys.
- Added new utility functions for variable value lookup and display name generation.
- Enhanced tests to cover new key-based variable scenarios.
- Refactored KolPrompt repository to simplify prompt storage and management, including the removal of obsolete revision handling.
- Introduced new API endpoints for saving, activating, and archiving prompts.
- Added new utility functions for handling Kol placeholders and platform options in the admin web.
- Implemented database migrations to simplify prompt storage structure and ensure data integrity.
2026-04-18 00:47:57 +08:00
root 614ca4a2ea feat(kol): workspace KOL card area 2026-04-17 15:23:38 +08:00
root b6bd4f02fb feat(kol): workspace KOL cards + article source type 2026-04-17 15:19:11 +08:00
root 641383a585 feat(kol): dashboard view 2026-04-17 15:11:18 +08:00
root 6e95e00907 feat(kol): dashboard service + API 2026-04-17 15:05:09 +08:00
root 4b6d434556 feat(kol): dynamic-form generation view 2026-04-17 14:59:52 +08:00
root 97c18cdbef feat(kol): generation + schema HTTP endpoints 2026-04-17 14:52:16 +08:00
root 019410fffe feat(kol): generation service + worker branch 2026-04-17 14:52:08 +08:00
root 26bc8a3749 feat(kol): repo support for cross-tenant revision lookup 2026-04-17 14:51:54 +08:00
root d0747825e6 feat(kol): marketplace + package detail views 2026-04-17 14:30:47 +08:00
root 2a2489ce5c feat(kol): marketplace + admin subscription HTTP endpoints 2026-04-17 14:23:39 +08:00
root 99fc6c1af4 feat(kol): marketplace + subscription admin services + publish fan-out 2026-04-17 14:23:32 +08:00
root df334c1e26 feat(kol): marketplace and admin subscription repo queries 2026-04-17 14:23:25 +08:00
root 6eb663bd6e feat(kol): three-pane prompt editor + KolManageView UI 2026-04-17 14:08:34 +08:00
root d5f7cdfc5f feat(kol): AI assist HTTP endpoints 2026-04-17 13:52:08 +08:00
root d55f1276f3 feat(kol): AI assist service + worker 2026-04-17 13:52:01 +08:00
root 9cf9fac109 feat(kol): admin-web API client + router entries for KOL 2026-04-17 13:51:39 +08:00
root a6ded27c1d feat(kol): KOL workspace HTTP handlers + route registration 2026-04-17 09:19:37 +08:00
root 6029b0b169 feat(kol): KOL workspace services (profile/package/prompt/asset/renderer) 2026-04-17 09:19:30 +08:00
root 76f5c73773 feat(kol): sidebar nav groups for marketplace + KOL workspace 2026-04-17 09:02:39 +08:00
root 40519545c6 feat(kol): expose kol_profile on /api/auth/me and add seed script 2026-04-17 09:02:33 +08:00
root 70725193eb fix(kol): Phase 1 review — ACL lineage, expiry filters, tighter tenant scope
Addresses findings from consolidated Phase 1 code review:

- Add composite unique indexes + composite FKs so subscription_prompts and
  packages cannot reference mismatched (tenant_id, package_id, prompt_id)
  tuples, enforcing ACL lineage at the schema level.
- Add status CHECK constraints on all KOL tables as defense-in-depth.
- ListActiveSubscribersForPackage: drop meaningless tenant_id IS NOT NULL,
  add end_at expiry filter so fan-out skips expired subscribers.
- ApproveKolSubscription: add status='pending' guard to prevent double-approval.
- ListSubscriptionPromptsByTenant: join subscription/prompt/package/profile
  lifecycle so hidden/archived content no longer leaks; surface
  kol_display_name for UI.
- ListPublishedKolPackages: exclude expired subscribers from marketplace count.
- KolDashboardTrend: rewrite as CTE with day-series, returning both daily
  usage and new subscription counts.
- Remove cosmetic tenant_id IS NOT NULL from dashboard overview queries
  (the column is NOT NULL by schema).
- check_tenant_scope.sh: require tenant_id = sqlc.(n?)arg filter, reject
  tenant_id IS NOT NULL as a fake scope, maintain explicit exemption list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 08:34:12 +08:00
root 3d4842e983 feat(kol): repository layer for all KOL tables 2026-04-17 08:17:22 +08:00
root 2c58fc591e feat(kol): add KOL TypeScript shared types 2026-04-17 08:13:40 +08:00
root b78664c7d0 feat(kol): add sqlc queries for all KOL tables 2026-04-17 08:10:45 +08:00
root 5c8f2bffae feat(kol): add kol_prompt_id column to articles 2026-04-17 08:06:36 +08:00
root fd74ad703b feat(kol): enhance KOL constraints per review findings
- Add composite FK kol_usage_logs(prompt_id, prompt_revision_no) -> kol_prompt_revisions
  to enforce audit replay integrity
- Add CHECK constraint: active prompts must have a published revision
- Add tenant-leading index on kol_packages for list path performance

Addresses review feedback on commit 60fb8a4.
2026-04-17 08:04:56 +08:00
root 60fb8a4d7f feat(kol): add migration for KOL core tables 2026-04-17 07:53:56 +08:00
root 3e1b68f771 docs: add KOL feature implementation plan
8-phase plan covering data foundation, profile lifecycle, workspace
backend/frontend, marketplace+subscription, generation pipeline, dashboard,
and workspace integration. Each phase is a shippable milestone.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 07:46:29 +08:00
root 6b2810fc74 docs: revise KOL spec v2 — align with existing prompt sharing architecture
Addresses all critical findings from review:
- KOL identity via prompt_share_profiles, not platform_role
- Prompts stored as sealed article_templates, not parallel system
- Platform-level packages with proper API path separation
- Generation pipeline integrated with existing tx/quota/idempotency
- Variable model with immutable IDs and version snapshots
- Independent kol_assist_tasks table (decoupled from template_assist_tasks)
- Complete resource lifecycle and auth chain
- Consistent tenant-level subscription entity

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:24:11 +08:00
root 33f1121633 docs: add KOL feature design spec
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:08:50 +08:00