mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-05 13:29:44 +02:00
## Summary Adds per-user `profile_description` so coding agents have cheap, durable context about who is asking. v1 per the brief Xeon locked in on [MUL-2406](mention://issue/63a7247c-4f6a-42cf-90d1-7c746e77158a): - **DB** — `user.profile_description TEXT NOT NULL DEFAULT ''` (migration 096). 2000-rune cap enforced server-side. No nullable / privacy state to manage. - **API** — `PATCH /api/me` accepts the field; `UserResponse` always emits it. Client wraps `updateMe` in a lenient `UserSchema` + `EMPTY_USER` fallback per CLAUDE.md API Response Compatibility. - **UI** — Settings → Account gains an "About you" textarea with live `n/2000` counter, `maxLength` guard, and a localized too-long error (EN + zh-Hans). - **CLI** — `multica user profile get` / `multica user profile update` with `--description / --description-stdin / --description-file / --clear`, mirroring the existing `issue comment add` input-mode menu. - **Daemon injection** — claim handler resolves the runtime owner and stamps `requesting_user_name` + `requesting_user_profile_description` on the task. `buildMetaSkillContent` emits `## Requesting User` between `## Agent Identity` and `## Available Commands`, blockquoted and framed as background context. The block is omitted entirely when the description is empty (no token cost when unused). Brief is written **once per task** via `CLAUDE.md` / `AGENTS.md`, not the per-turn prompt — same path the agent already reads for identity, so no extra per-turn cost. ## Test plan - [x] `go build ./...`, `go vet ./...`, `go test ./internal/cli/ ./internal/daemon/ ./internal/daemon/execenv/ ./cmd/multica/` - [x] New brief tests: `TestBuildMetaSkillContentEmitsRequestingUser`, `TestBuildMetaSkillContentOmitsRequestingUserWhenEmpty` - [x] `pnpm typecheck`, `pnpm lint`, `pnpm test` (74 files, 644 tests pass) - [ ] Handler DB tests (`TestUpdateMe*`) require a migrated test DB — not runnable in this sandbox - [ ] Manual: open Settings → Account, set a description, confirm the next daemon-run agent's `CLAUDE.md` shows `## Requesting User`
285 lines
8.0 KiB
Go
285 lines
8.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: user.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO "user" (name, email, avatar_url)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING id, name, email, avatar_url, created_at, updated_at, onboarded_at, onboarding_questionnaire, cloud_waitlist_email, cloud_waitlist_reason, starter_content_state, language, profile_description
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
AvatarUrl pgtype.Text `json:"avatar_url"`
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
|
|
row := q.db.QueryRow(ctx, createUser, arg.Name, arg.Email, arg.AvatarUrl)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Email,
|
|
&i.AvatarUrl,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.OnboardedAt,
|
|
&i.OnboardingQuestionnaire,
|
|
&i.CloudWaitlistEmail,
|
|
&i.CloudWaitlistReason,
|
|
&i.StarterContentState,
|
|
&i.Language,
|
|
&i.ProfileDescription,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUser = `-- name: GetUser :one
|
|
SELECT id, name, email, avatar_url, created_at, updated_at, onboarded_at, onboarding_questionnaire, cloud_waitlist_email, cloud_waitlist_reason, starter_content_state, language, profile_description FROM "user"
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetUser(ctx context.Context, id pgtype.UUID) (User, error) {
|
|
row := q.db.QueryRow(ctx, getUser, id)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Email,
|
|
&i.AvatarUrl,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.OnboardedAt,
|
|
&i.OnboardingQuestionnaire,
|
|
&i.CloudWaitlistEmail,
|
|
&i.CloudWaitlistReason,
|
|
&i.StarterContentState,
|
|
&i.Language,
|
|
&i.ProfileDescription,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByEmail = `-- name: GetUserByEmail :one
|
|
SELECT id, name, email, avatar_url, created_at, updated_at, onboarded_at, onboarding_questionnaire, cloud_waitlist_email, cloud_waitlist_reason, starter_content_state, language, profile_description FROM "user"
|
|
WHERE email = $1
|
|
`
|
|
|
|
func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error) {
|
|
row := q.db.QueryRow(ctx, getUserByEmail, email)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Email,
|
|
&i.AvatarUrl,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.OnboardedAt,
|
|
&i.OnboardingQuestionnaire,
|
|
&i.CloudWaitlistEmail,
|
|
&i.CloudWaitlistReason,
|
|
&i.StarterContentState,
|
|
&i.Language,
|
|
&i.ProfileDescription,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const joinCloudWaitlist = `-- name: JoinCloudWaitlist :one
|
|
UPDATE "user" SET
|
|
cloud_waitlist_email = $2,
|
|
cloud_waitlist_reason = $3,
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, name, email, avatar_url, created_at, updated_at, onboarded_at, onboarding_questionnaire, cloud_waitlist_email, cloud_waitlist_reason, starter_content_state, language, profile_description
|
|
`
|
|
|
|
type JoinCloudWaitlistParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
CloudWaitlistEmail pgtype.Text `json:"cloud_waitlist_email"`
|
|
CloudWaitlistReason pgtype.Text `json:"cloud_waitlist_reason"`
|
|
}
|
|
|
|
// Records interest in cloud runtimes. Does NOT mark onboarding
|
|
// complete — the user still has to pick a real path (CLI / Skip)
|
|
// in Step 3. Repeating the call overwrites email + reason.
|
|
func (q *Queries) JoinCloudWaitlist(ctx context.Context, arg JoinCloudWaitlistParams) (User, error) {
|
|
row := q.db.QueryRow(ctx, joinCloudWaitlist, arg.ID, arg.CloudWaitlistEmail, arg.CloudWaitlistReason)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Email,
|
|
&i.AvatarUrl,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.OnboardedAt,
|
|
&i.OnboardingQuestionnaire,
|
|
&i.CloudWaitlistEmail,
|
|
&i.CloudWaitlistReason,
|
|
&i.StarterContentState,
|
|
&i.Language,
|
|
&i.ProfileDescription,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const markUserOnboarded = `-- name: MarkUserOnboarded :one
|
|
UPDATE "user" SET
|
|
onboarded_at = COALESCE(onboarded_at, now()),
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, name, email, avatar_url, created_at, updated_at, onboarded_at, onboarding_questionnaire, cloud_waitlist_email, cloud_waitlist_reason, starter_content_state, language, profile_description
|
|
`
|
|
|
|
func (q *Queries) MarkUserOnboarded(ctx context.Context, id pgtype.UUID) (User, error) {
|
|
row := q.db.QueryRow(ctx, markUserOnboarded, id)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Email,
|
|
&i.AvatarUrl,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.OnboardedAt,
|
|
&i.OnboardingQuestionnaire,
|
|
&i.CloudWaitlistEmail,
|
|
&i.CloudWaitlistReason,
|
|
&i.StarterContentState,
|
|
&i.Language,
|
|
&i.ProfileDescription,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const patchUserOnboarding = `-- name: PatchUserOnboarding :one
|
|
UPDATE "user" SET
|
|
onboarding_questionnaire = COALESCE($1, onboarding_questionnaire),
|
|
updated_at = now()
|
|
WHERE id = $2
|
|
RETURNING id, name, email, avatar_url, created_at, updated_at, onboarded_at, onboarding_questionnaire, cloud_waitlist_email, cloud_waitlist_reason, starter_content_state, language, profile_description
|
|
`
|
|
|
|
type PatchUserOnboardingParams struct {
|
|
Questionnaire []byte `json:"questionnaire"`
|
|
ID pgtype.UUID `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) PatchUserOnboarding(ctx context.Context, arg PatchUserOnboardingParams) (User, error) {
|
|
row := q.db.QueryRow(ctx, patchUserOnboarding, arg.Questionnaire, arg.ID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Email,
|
|
&i.AvatarUrl,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.OnboardedAt,
|
|
&i.OnboardingQuestionnaire,
|
|
&i.CloudWaitlistEmail,
|
|
&i.CloudWaitlistReason,
|
|
&i.StarterContentState,
|
|
&i.Language,
|
|
&i.ProfileDescription,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const setStarterContentState = `-- name: SetStarterContentState :one
|
|
UPDATE "user" SET
|
|
starter_content_state = $2,
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, name, email, avatar_url, created_at, updated_at, onboarded_at, onboarding_questionnaire, cloud_waitlist_email, cloud_waitlist_reason, starter_content_state, language, profile_description
|
|
`
|
|
|
|
type SetStarterContentStateParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
StarterContentState pgtype.Text `json:"starter_content_state"`
|
|
}
|
|
|
|
// Atomically transition starter_content_state. The handler is
|
|
// responsible for checking the current value first (to decide between
|
|
// "transition NULL -> imported and run the seeding" vs "already
|
|
// decided, short-circuit"). Using COALESCE here would swallow the
|
|
// transition, so this is a straight assignment.
|
|
func (q *Queries) SetStarterContentState(ctx context.Context, arg SetStarterContentStateParams) (User, error) {
|
|
row := q.db.QueryRow(ctx, setStarterContentState, arg.ID, arg.StarterContentState)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Email,
|
|
&i.AvatarUrl,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.OnboardedAt,
|
|
&i.OnboardingQuestionnaire,
|
|
&i.CloudWaitlistEmail,
|
|
&i.CloudWaitlistReason,
|
|
&i.StarterContentState,
|
|
&i.Language,
|
|
&i.ProfileDescription,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateUser = `-- name: UpdateUser :one
|
|
UPDATE "user" SET
|
|
name = COALESCE($2, name),
|
|
avatar_url = COALESCE($3, avatar_url),
|
|
language = COALESCE($4, language),
|
|
profile_description = COALESCE($5, profile_description),
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, name, email, avatar_url, created_at, updated_at, onboarded_at, onboarding_questionnaire, cloud_waitlist_email, cloud_waitlist_reason, starter_content_state, language, profile_description
|
|
`
|
|
|
|
type UpdateUserParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
AvatarUrl pgtype.Text `json:"avatar_url"`
|
|
Language pgtype.Text `json:"language"`
|
|
ProfileDescription pgtype.Text `json:"profile_description"`
|
|
}
|
|
|
|
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error) {
|
|
row := q.db.QueryRow(ctx, updateUser,
|
|
arg.ID,
|
|
arg.Name,
|
|
arg.AvatarUrl,
|
|
arg.Language,
|
|
arg.ProfileDescription,
|
|
)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Email,
|
|
&i.AvatarUrl,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.OnboardedAt,
|
|
&i.OnboardingQuestionnaire,
|
|
&i.CloudWaitlistEmail,
|
|
&i.CloudWaitlistReason,
|
|
&i.StarterContentState,
|
|
&i.Language,
|
|
&i.ProfileDescription,
|
|
)
|
|
return i, err
|
|
}
|